sync with UpdateDocument

use same way to select expiration date, call hook
editDocumentContenAttributes, fix checking form
This commit is contained in:
Uwe Steinmann 2018-02-27 16:12:36 +01:00
parent 9ff60e8a35
commit 0bb1035261

View File

@ -29,18 +29,14 @@ class SeedDMS_View_CheckInDocument extends SeedDMS_Bootstrap_Style {
function js() { /* {{{ */
$strictformcheck = $this->params['strictformcheck'];
$dropfolderdir = $this->params['dropfolderdir'];
header('Content-Type: application/javascript; charset=UTF-8');
$this->printSelectPresetButtonJs();
$this->printInputPresetButtonJs();
$this->printCheckboxPresetButtonJs();
?>
function checkForm()
{
msg = new Array();
<?php if($dropfolderdir) { ?>
if (document.form1.userfile.value == "" && document.form1.dropfolderfileform1.value == "") msg.push("<?php printMLText("js_no_file");?>");
<?php } else { ?>
if (document.form1.userfile.value == "") msg.push("<?php printMLText("js_no_file");?>");
<?php } ?>
<?php
if ($strictformcheck) {
?>
@ -68,6 +64,12 @@ $(document).ready(function() {
if(checkForm()) return;
event.preventDefault();
});
$('#presetexpdate').on('change', function(ev){
if($(this).val() == 'date')
$('#control_expdate').show();
else
$('#control_expdate').hide();
});
});
<?php
} /* }}} */
@ -83,7 +85,6 @@ $(document).ready(function() {
$enableownerrevapp = $this->params['enableownerrevapp'];
$enableselfrevapp = $this->params['enableselfrevapp'];
$enableselfreceipt = $this->params['enableselfreceipt'];
$dropfolderdir = $this->params['dropfolderdir'];
$workflowmode = $this->params['workflowmode'];
$presetexpiration = $this->params['presetexpiration'];
$documentid = $document->getId();
@ -162,39 +163,75 @@ $(document).ready(function() {
<tr>
<td><?php printMLText("comment");?>:</td>
<td class="standardText">
<textarea name="comment" rows="4" cols="80"></textarea>
<textarea name="comment" rows="4" cols="80"<?php echo $strictformcheck ? ' required' : ''; ?>></textarea>
</td>
</tr>
<?php
if($presetexpiration) {
if(!($expts = strtotime($presetexpiration)))
$expts = time();
$expts = false;
} else {
$expts = time();
$expts = false;
}
?>
<tr>
<td><?php printMLText("preset_expires");?>:</td>
<td>
<select class="span6" name="presetexpdate" id="presetexpdate">
<option value="never"><?php printMLText('does_not_expire');?></option>
<option value="date"<?php echo ($expts != '' ? " selected" : ""); ?>><?php printMLText('expire_by_date');?></option>
<option value="1w"><?php printMLText('expire_in_1w');?></option>
<option value="1m"><?php printMLText('expire_in_1m');?></option>
<option value="1y"><?php printMLText('expire_in_1y');?></option>
<option value="2y"><?php printMLText('expire_in_2y');?></option>
</select>
</td>
</tr>
<tr id="control_expdate" <?php echo ($expts == false ? 'style="display: none;"' : ''); ?>>
<td><?php printMLText("expires");?>:</td>
<td class="standardText">
<span class="input-append date span12" id="expirationdate" data-date="<?php echo date('d-m-Y', $expts); ?>" data-date-format="dd-mm-yyyy" data-date-language="<?php echo str_replace('_', '-', $this->params['session']->getLanguage()); ?>">
<input class="span3" size="16" name="expdate" type="text" value="<?php echo date('d-m-Y', $expts); ?>">
<span class="input-append date span12" id="expirationdate" data-date="<?php echo ($expts ? date('Y-m-d', $expts) : ''); ?>" data-date-format="yyyy-mm-dd" data-date-language="<?php echo str_replace('_', '-', $this->params['session']->getLanguage()); ?>">
<input class="span3" size="16" name="expdate" type="text" value="<?php echo ($expts ? date('Y-m-d', $expts) : ''); ?>">
<span class="add-on"><i class="icon-calendar"></i></span>
</span><br />
<label class="checkbox inline">
<input type="checkbox" name="expires" value="false"<?php if (!$document->expires()) print " checked";?>><?php printMLText("does_not_expire");?><br>
</label>
</span>
</td>
</tr>
<?php
$attrdefs = $dms->getAllAttributeDefinitions(array(SeedDMS_Core_AttributeDefinition::objtype_documentcontent, SeedDMS_Core_AttributeDefinition::objtype_all));
if($attrdefs) {
foreach($attrdefs as $attrdef) {
$arr = $this->callHook('editDocumentContentAttribute', $document, $attrdef);
if(is_array($arr)) {
if($arr) {
echo "<tr>";
echo "<td>".$arr[0].":</td>";
echo "<td>".$arr[1]."</td>";
echo "</tr>";
}
} else {
?>
<tr>
<td><?php echo htmlspecialchars($attrdef->getName()); ?>:</td>
<td><?php $this->printAttributeEditField($attrdef, '') ?></td>
<td><?php $this->printAttributeEditField($attrdef, '', 'attributes_version') ?>
<?php
if($latestContent->getAttributeValue($attrdef)) {
switch($attrdef->getType()) {
case SeedDMS_Core_AttributeDefinition::type_string:
case SeedDMS_Core_AttributeDefinition::type_date:
case SeedDMS_Core_AttributeDefinition::type_int:
case SeedDMS_Core_AttributeDefinition::type_float:
$this->printInputPresetButtonHtml('attributes_version_'.$attrdef->getID(), $latestContent->getAttributeValue($attrdef), $attrdef->getValueSetSeparator());
break;
case SeedDMS_Core_AttributeDefinition::type_boolean:
$this->printCheckboxPresetButtonHtml('attributes_version_'.$attrdef->getID(), $latestContent->getAttributeValue($attrdef));
break;
}
// print_r($latestContent->getAttributeValue($attrdef));
}
?></td>
</tr>
<?php
}
}
}
if($workflowmode == 'traditional' || $workflowmode == 'traditional_only_approval') {