fields.html.php 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. <?php
  2. $index = 1;
  3. $actionMethod = ($action->module == 'product' && in_array($action->method, array('requirement', 'epic'))) ? 'browse' : $action->method;
  4. $disabledFields = in_array($actionMethod, $config->workflowaction->defaultActions) ? zget($config->workflowlayout->disabledFields, $actionMethod, '') : $config->workflowlayout->disabledFields['custom'];
  5. $controlList = array('select', 'multi-select', 'checkbox', 'radio', 'date', 'datetime');
  6. $dateControlList = array('date', 'datetime');
  7. $requiredFields = zget($config->workflowlayout->default->required, $action->action, array());
  8. if($flow->approval == 'enabled') $requiredFields = array_merge($requiredFields, zget($config->workflowlayout->approval->required, $action->action, array()));
  9. ?>
  10. <table class='table table-bordered table-fixed table-origin'>
  11. <?php /* Begin foreach of fields. */ ?>
  12. <?php foreach($fields as $key => $field):?>
  13. <?php
  14. if($mode == 'view' && !$field->show) continue;
  15. if(strpos(",{$disabledFields},", ",{$key},") !== false) continue;
  16. if(isset($field->hasAction) && !$field->hasAction) $field->defaultValue = $field->default;
  17. $required = in_array($key, $requiredFields);
  18. $fixed = $required ? 'required' : 'enabled';
  19. $show = $field->show == '1';
  20. $subTable = isset($subTables[$key]);
  21. $disabled = $mode == 'edit' ? '' : "disabled='disabled'";
  22. $readonly = '';
  23. if($subTable) $disabled = "disabled='disabled'";
  24. if($mode == 'edit' && !empty($flow->belong) && $field->field == $flow->belong && ($action->action == 'create' || $action->action == 'batchcreate'))
  25. {
  26. $required = true;
  27. $disabled = "disabled='disabled'";
  28. }
  29. ?>
  30. <tr class='<?php echo (!$show ? ' disabled' : '') . ($required ? ' required' : '') . (' fixed-' . $fixed) . ($subTable ? " module-{$key}" : '');?>' <?php echo $subTable ? "data-child={$key}" : '';?> data-fixed='<?php echo $fixed;?>' data-module='<?php echo $field->module;?>' data-field='<?php echo $field->field;?>' data-control='<?php echo $field->control;?>'>
  31. <?php /* Row title. */ ?>
  32. <td class='title'>
  33. <span class='title-bar text-ellipsis' title='<?php echo $field->name;?>'>
  34. <i class='icon-check'></i>
  35. <strong><?php echo $field->name;?></strong>
  36. <?php if($mode == 'edit'):?>
  37. <i class='icon icon-move'></i>
  38. <?php endif;?>
  39. </span>
  40. <?php /* Row Actions. */ ?>
  41. <?php if($required) echo "({$lang->workflowlayout->require})";?>
  42. </td>
  43. <?php /* Summary. */ ?>
  44. <?php if($actionMethod == 'browse'):?>
  45. <?php if(in_array($field->type, $config->workflowfield->numberTypes) && strpos(",{$config->workflowlayout->noTotalFields},", ",{$field->field},") === false):?>
  46. <td class='w-300px'>
  47. <div class='input-group'>
  48. <span class='text-muted input-group-addon'><?php echo $lang->workflowlayout->summary;?></span>
  49. <?php echo html::select("summary[$key][]", $lang->workflowlayout->summaryList, !empty($field->summary) ? $field->summary: 0, "class='form-control chosen' multiple $disabled");?>
  50. </div>
  51. </td>
  52. <?php else:?>
  53. <td></td>
  54. <?php endif;?>
  55. <?php endif;?>
  56. <?php /* Width. */ ?>
  57. <?php if($actionMethod != 'view'):?>
  58. <td class='w-140px'>
  59. <div class='input-group'>
  60. <span class='input-group-addon text-muted'><?php echo $lang->workflowlayout->width;?></span>
  61. <?php echo html::input("width[$key]", $field->width, "id='width{$key}' class='form-control' readonly");?>
  62. </div>
  63. </td>
  64. <?php endif;?>
  65. <?php if($actionMethod != 'browse' && $actionMethod != 'view' && !is_numeric($key)):?>
  66. <?php /* Layout rules. */ ?>
  67. <td class='w-160px'>
  68. <div class='input-group'>
  69. <span class='text-muted input-group-addon'><?php echo $lang->workflowlayout->layoutRules;?></span>
  70. <?php if($subTable):?>
  71. <?php echo html::select("layoutRules[$key][]", $rules, '', "class='form-control chosen' multiple='multiple' disabled");?>
  72. <?php else:?>
  73. <?php echo html::select("layoutRules[$key][]", $rules, $field->layoutRules, "class='form-control chosen' multiple='multiple' $disabled");?>
  74. <?php endif;?>
  75. </div>
  76. </td>
  77. <?php if($field->control != 'file'):?>
  78. <?php /* Default value. */ ?>
  79. <td class='w-240px'>
  80. <div class='input-group'>
  81. <span class='text-muted input-group-addon'><?php echo $lang->workflowlayout->defaultValue;?></span>
  82. <?php
  83. $data = "data-module='{$flow->module}' data-field='{$field->field}'";
  84. if($field->control == 'multi-select' or $field->control == 'checkbox')
  85. {
  86. echo html::select("defaultValue[$key][]", $field->options, $field->defaultValue, "id='defaultValue{$key}' class='form-control picker-select' multiple $data $disabled");
  87. }
  88. else
  89. {
  90. echo html::select("defaultValue[$key]", array('' => '') + $field->options, $field->defaultValue, "id='defaultValue{$key}' class='form-control picker-select' $data $disabled");
  91. }
  92. echo "<span class='input-group-addon fix-border'></span>";
  93. if(in_array($field->control, $dateControlList))
  94. {
  95. $class = 'form-' . $field->control;
  96. echo html::input("defaultValue[$key]", ($field->defaultValue && $field->defaultValue != 'currentTime') ? $field->defaultValue : '', "id='defaultValue{$key}' class='form-control $class' $disabled");
  97. }
  98. else
  99. {
  100. echo html::input("defaultValue[$key]", (isset($field->defaultValue) && strpos(',currentUser,currentDept,currentTime,', ",$field->defaultValue,") === false) ? $field->defaultValue : '', "id='defaultValue{$key}' class='form-control' disabled='disabled'");
  101. }
  102. $checked = '';
  103. if(!in_array($field->control, $controlList)) $checked .= "checked='checked'";
  104. if(in_array($field->control, $dateControlList) && !empty($field->defaultValue) && $field->defaultValue != 'currentTime') $checked .= "checked='checked'";
  105. if(!in_array($field->control, $dateControlList)) $checked .= "disabled='disabled'";
  106. ?>
  107. <span class='input-group-addon'>
  108. <div class='checkbox-primary'>
  109. <input type='checkbox' name="custom[<?php echo $key;?>]" value='1' <?php echo "$checked $disabled";?>/>
  110. <label><?php echo $lang->workflowlayout->custom;?></label>
  111. </div>
  112. </span>
  113. </div>
  114. </td>
  115. <?php else:?>
  116. <td class='w-240px'>
  117. <div class='input-group'>
  118. <span class='text-muted input-group-addon'><?php echo $lang->workflowlayout->defaultValue;?></span>
  119. <?php echo html::input("defaultValue[$key]", '', "id='defaultValue{$key}' class='form-control' disabled='disabled'");?>
  120. <span class='input-group-addon'>
  121. <div class='checkbox-primary'>
  122. <input type='checkbox' name="custom[<?php echo $key;?>]" value='1' disabled='disabled'/>
  123. <label><?php echo $lang->workflowlayout->custom;?></label>
  124. </div>
  125. </span>
  126. </div>
  127. </td>
  128. <?php endif;?>
  129. <?php endif;?>
  130. <?php if($actionMethod == 'browse' or ($action->type == 'batch' && $action->batchMode == 'different')):?>
  131. <?php /* Display in mobile device. */ ?>
  132. <td class='w-160px'>
  133. <div class='input-group'>
  134. <span class='text-muted input-group-addon'><?php echo $lang->workflowlayout->mobileShow;?></span>
  135. <?php echo html::select("mobileShow[$key]", $lang->workflowlayout->mobileList, !empty($field->mobileShow) ? $field->mobileShow : 0, "class='form-control' $disabled");?>
  136. </div>
  137. </td>
  138. <?php endif;?>
  139. <?php /* Position. */ ?>
  140. <?php if($actionMethod == 'view' or $actionMethod == 'browse' or $action->layout == 'side'):?>
  141. <?php $width = $actionMethod == 'view' ? 'w-200px' : 'w-140px';?>
  142. <td class="<?php echo $width;?>">
  143. <div class='input-group'>
  144. <span class='text-muted input-group-addon'>
  145. <?php if($actionMethod == 'view' and $index == 1):?>
  146. <a data-toggle='tooltip' class='position-tips' title='<?php echo $lang->workflowlayout->tips->position;?>'><i class='icon-help-circle icon-md'></i></a>
  147. <?php endif;?>
  148. <?php echo $actionMethod == 'browse' ? $lang->workflowlayout->alignment : $lang->workflowlayout->position;?>
  149. </span>
  150. <?php echo html::select("position[$key]", $positionList, !empty($field->position) ? $field->position : zget($defaultPositions, $field->field, ''), "class='form-control' $disabled");?>
  151. </div>
  152. </td>
  153. <?php endif;?>
  154. <?php /* Readonly. */ ?>
  155. <?php if($action->type == 'single' && !in_array($actionMethod, $config->workflowaction->readonlyActions) && $field->field != 'actions' && $actionMethod != 'browse'):?>
  156. <td class='w-80px'>
  157. <?php $checked = $field->readonly ? "checked='checked'" : '';?>
  158. <?php $readonlyDisabled = ($disabled or $field->control == 'file') ? "disabled='disabled'" : '';?>
  159. <div class='checkbox-primary'>
  160. <input type='checkbox' name="readonly[<?php echo $key;?>]" value='1' <?php echo "$checked $readonlyDisabled";?>/>
  161. <label><?php echo $lang->workflowlayout->readonly;?></label>
  162. </div>
  163. </td>
  164. <?php endif;?>
  165. <?php /* Display or not. */ ?>
  166. <td class='w-100px text-center'>
  167. <?php if($mode == 'edit'):?>
  168. <button type='button' class='btn btn-link show-hide' <?php echo $disabled;?>>
  169. <span class='label-show'><?php echo $lang->workflowlayout->show;?></span>
  170. <span class='text-muted'>/</span>
  171. <span class='label-hide'><?php echo $lang->workflowlayout->hide;?></span>
  172. </button>
  173. <?php else:?>
  174. <?php echo $show ? $lang->workflowlayout->show : $lang->workflowlayout->hide;?>
  175. <?php endif;?>
  176. <?php echo html::hidden("show[$key]", $show ? '1' : '0');?>
  177. </td>
  178. </tr>
  179. <?php $index++;?>
  180. <?php endforeach;?>
  181. <?php /* End foreach of fields. */ ?>
  182. </table>