edit.html.php 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301
  1. <?php
  2. /**
  3. * The edit view file of wordflowfield module of ZDOO.
  4. *
  5. * @copyright Copyright 2009-2016 青岛易软天创网络科技有限公司(QingDao Nature Easy Soft Network Technology Co,LTD, www.cnezsoft.com)
  6. * @license 商业软件,非开源软件
  7. * @author Gang Liu <liugang@cnezsoft.com>
  8. * @package workflowfield
  9. * @version $Id$
  10. * @link http://www.zdoo.com
  11. */
  12. ?>
  13. <?php include '../../common/view/header.modal.html.php';?>
  14. <?php include '../../common/view/picker.html.php';?>
  15. <?php include $app->getModuleRoot() . 'common/view/sortable.html.php';?>
  16. <?php include './expression.html.php';?>
  17. <?php js::set('fieldID', $field->id);?>
  18. <?php js::set('hiddenPlaceholder', $config->workflowfield->hiddenPlaceholder);?>
  19. <form method='post' id='editFieldForm' class='fieldForm' action='<?php echo inlink('edit', "module=$field->module&id=$field->id");?>'>
  20. <table class='table table-form' id='fieldTable'>
  21. <?php
  22. /* 内置字段中subStatus可以编辑,其他不可编辑。默认字段中status、subStatus可以编辑,其他不可编辑。非内置且非默认字段可以编辑。*/
  23. /* The subStatus in the built-in field can be edited, and the others cannot be edited. The status, status, and status in the default field can be edited, and others cannot be edited. Non-built-in and non-default fields can be edited. */
  24. ?>
  25. <tr>
  26. <th class='w-80px'><?php echo $lang->workflowfield->name;?></th>
  27. <td class='w-200px'><?php echo html::input('name', $field->name, "class='form-control'" . ($field->role == 'quote' ? " disabled='disabled'" : ''));?></td>
  28. <td class='w-60px'></td>
  29. <td></td>
  30. </tr>
  31. <?php if(!$field->readonly):?>
  32. <tr>
  33. <th><?php echo $lang->workflowfield->field;?></th>
  34. <td>
  35. <?php echo html::input('field', $field->field, "class='form-control' placeholder='{$lang->workflowfield->placeholder->code}' disabled='disabled'");?>
  36. </td>
  37. <td></td>
  38. <td></td>
  39. </tr>
  40. <tr>
  41. <th><?php echo $lang->workflowfield->control;?></th>
  42. <td>
  43. <?php
  44. unset($lang->workflowfield->controlTypeList['label']);
  45. $disabled = ($field->field == 'status' or $field->field == 'subStatus' or $this->config->db->driver != 'mysql') ? "disabled='disabled'" : '';
  46. if($field->role == 'quote') $disabled = 'disabled="disabled"';
  47. if($disabled) echo html::hidden('control', $field->control);
  48. echo html::select('control', $lang->workflowfield->controlTypeList, $field->control, "class='form-control chosen' onchange='showTips()' $disabled");
  49. ?>
  50. </td>
  51. <td></td>
  52. <td></td>
  53. </tr>
  54. <tr>
  55. <th><?php echo $lang->workflowfield->type;?></th>
  56. <td>
  57. <?php if($disabled) echo html::hidden('type', $field->type);?>
  58. <select id='type' name='type' <?php echo $disabled;?> class='form-control'>
  59. <?php
  60. foreach($config->workflowfield->typeList as $type => $typeList)
  61. {
  62. foreach($typeList as $key => $value)
  63. {
  64. $selected = $key == $field->type ? "selected='selected'" : '';
  65. echo "<option class='{$type}' value='{$key}' {$selected}>{$value}</option>";
  66. }
  67. }
  68. ?>
  69. </select>
  70. </td>
  71. <td colspan='2'>
  72. <div class='input-group'>
  73. <?php
  74. if($field->type == 'decimal')
  75. {
  76. list($integerDigits, $decimalDigits) = explode(',', $field->length);
  77. }
  78. else
  79. {
  80. $integerDigits = $config->workflowfield->default->integerDigits;
  81. $decimalDigits = $config->workflowfield->default->decimalDigits;
  82. }
  83. ?>
  84. <span class='input-group-addon length'><?php echo $lang->workflowfield->length;?></span>
  85. <?php if($disabled) echo html::hidden('length', $field->length);?>
  86. <?php echo html::number('length', $field->length, "max='{$config->workflowfield->max->varcharLength}' min='{$config->workflowfield->min->varcharLength}' step='1' class='form-control length' placeholder='{$lang->workflowfield->placeholder->varcharLength}' title='{$lang->workflowfield->placeholder->varcharLength}' $disabled");?>
  87. <span class='input-group-addon digits'><?php echo $lang->workflowfield->integerDigits;?></span>
  88. <?php if($disabled) echo html::hidden('integerDigits', $integerDigits);?>
  89. <?php echo html::number('integerDigits', $integerDigits, "max='{$config->workflowfield->max->integerDigits}' min='{$config->workflowfield->min->integerDigits}' step='1' class='form-control digits' placeholder='{$lang->workflowfield->placeholder->integerDigits}' title='{$lang->workflowfield->placeholder->integerDigits}' $disabled");?>
  90. <span class='input-group-addon digits'><?php echo $lang->workflowfield->decimalDigits;?></span>
  91. <?php if($disabled) echo html::hidden('decimalDigits', $decimalDigits);?>
  92. <?php echo html::number('decimalDigits', $decimalDigits, "max='{$config->workflowfield->max->decimalDigits}' min='{$config->workflowfield->min->decimalDigits}' step='1' class='form-control digits' placeholder='{$lang->workflowfield->placeholder->decimalDigits}' title='{$lang->workflowfield->placeholder->decimalDigits}' $disabled");?>
  93. </div>
  94. </td>
  95. </tr>
  96. <tr class='hide'>
  97. <th></th>
  98. <td colspan='3' class='dataTip text-warning'></td>
  99. </tr>
  100. <tr class='hide'>
  101. <th><?php echo $lang->workflowfield->expression;?></th>
  102. <td colspan='3'>
  103. <div class='expression'></div>
  104. <?php echo baseHTML::a('javascript:;', $lang->workflowfield->formula->set, "class='set-expression'");?>
  105. <?php echo html::hidden('expression', $field->expression);?>
  106. </td>
  107. </tr>
  108. <tr>
  109. <th><?php echo $lang->workflowfield->datasource;?></th>
  110. <td colspan='3'>
  111. <?php
  112. $disabled = $field->field == 'subStatus' ? "disabled='disabled'" : '';
  113. if($field->role == 'quote') $disabled = 'disabled="disabled"';
  114. $optionType = (is_array($field->options)) ? 'custom' : $field->options;
  115. if($disabled) echo html::hidden('optionType', $optionType);
  116. echo html::select('optionType', $datasources, $optionType, "class='form-control chosen optionType' onchange='showTips()' $disabled");
  117. ?>
  118. </td>
  119. </tr>
  120. <tr class='sqlTR'>
  121. <th><?php echo $lang->workflowfield->sql;?></th>
  122. <td colspan='3'><?php echo html::textarea('sql', $field->sql, "rows='4' class='form-control' placeholder='{$lang->workflowfield->placeholder->sql}'");?></td>
  123. </tr>
  124. <tr class='hide' id='varsTR'>
  125. <th><?php echo $lang->workflowfield->vars;?></th>
  126. <td colspan='3' id='varsTD'>
  127. <?php foreach($field->sqlVars as $var):?>
  128. <div id='<?php echo $var->varName;?>' class='w-p45 varControl'>
  129. <div class='input-group'>
  130. <?php echo $this->fetch('workflow', 'buildVarControl', "varName={$var->varName}");?>
  131. </div>
  132. </div>
  133. <?php endforeach;?>
  134. </td>
  135. </tr>
  136. <tr class='hide'>
  137. <th></th>
  138. <td colspan='3'><?php echo baseHTML::a(inlink('addSqlVar'), $lang->workflowfield->addVar, "class='btn' data-toggle='modal'");?></td>
  139. </tr>
  140. <?php if($field->field == 'subStatus'):?>
  141. <tr id='optionTR'>
  142. <th><?php echo $lang->workflowfield->options;?></th>
  143. <td colspan='3' class='subStatusTd'>
  144. <?php $statusList = array();?>
  145. <?php $statusField = $this->workflowfield->getByField($flow->module, 'status');?>
  146. <?php if($statusField) $statusList = $this->workflowfield->getFieldOptions($statusField, $emptyOption = false);?>
  147. <?php if(!$statusList):?>
  148. <strong class='text-red'><?php echo $lang->workflowfield->tips->emptyStatus;?></strong>
  149. <?php else:?>
  150. <table class='table table-form table-bordered'>
  151. <thead>
  152. <tr class='text-center'>
  153. <th class='w-100px'><?php echo $lang->workflowfield->status;?></th>
  154. <th><?php echo $lang->workflowfield->subStatus;?></th>
  155. </tr>
  156. </thead>
  157. <?php foreach($statusList as $parentCode => $parentName):?>
  158. <?php if(!$parentName) continue;?>
  159. <tr>
  160. <td class='text-center'>
  161. <?php echo $parentName;?>
  162. <?php echo html::hidden('parentCode[]', $parentCode);?>
  163. <?php echo html::hidden('parentName[]', $parentName);?>
  164. </td>
  165. <td class='sortTd'>
  166. <?php $subStatus = zget($field->options, $parentCode, null);?>
  167. <?php $default = zget($subStatus, 'default', '');?>
  168. <?php $options = zget($subStatus, 'options', array());?>
  169. <?php if(empty($options)) $options = array('' => '');?>
  170. <?php if(is_array($options)):?>
  171. <?php $hiddenSort = count($options) == 1 ? 'hidden' : '';?>
  172. <?php foreach($options as $code => $name):?>
  173. <div class='input-group'>
  174. <span class='statusKey input-group-addon'><?php echo $lang->workflowfield->key;?></span>
  175. <?php echo html::input("optionCode[$parentCode][]", $code, "class='form-control' placeholder='{$lang->workflowfield->placeholder->optionCode}'");?>
  176. <span class='input-group-addon'><?php echo $lang->workflowfield->value;?></span>
  177. <?php echo html::input("optionName[$parentCode][]", $name, "class='form-control'");?>
  178. <span class='input-group-btn sort-btn <?php echo $hiddenSort?>'>
  179. <a href='javascript:;' class='btn btn-default sortItem'><i class='icon-move'></i></a>
  180. </span>
  181. <span class='input-group-btn'>
  182. <a href='javascript:;' class='btn btn-default addItem'><i class='icon-plus'></i></a>
  183. </span>
  184. <span class='input-group-btn'>
  185. <a href='javascript:;' class='btn btn-default delItem'><i class='icon-minus'></i></a>
  186. </span>
  187. <span class='input-group-addon'>
  188. <?php echo html::radio("optionDefault[$parentCode]", array($code => $lang->workflowfield->defaultSubStatus), $default);?>
  189. </span>
  190. </div>
  191. <?php endforeach;?>
  192. <?php else:?>
  193. <div class='input-group'>
  194. <span class='statusKey input-group-addon'><?php echo $lang->workflowfield->key;?></span>
  195. <?php echo html::input("optionCode[$parentCode][]", '', "class='form-control' placeholder='{$lang->workflowfield->placeholder->optionCode}'");?>
  196. <span class='input-group-addon'><?php echo $lang->workflowfield->value;?></span>
  197. <?php echo html::input("optionName[$parentCode][]", '', "class='form-control'");?>
  198. <span class='input-group-btn sort-btn hidden'>
  199. <a href='javascript:;' class='btn btn-default sortItem'><i class='icon-move'></i></a>
  200. </span>
  201. <span class='input-group-btn'>
  202. <a href='javascript:;' class='btn btn-default addItem'><i class='icon-plus'></i></a>
  203. </span>
  204. <span class='input-group-btn'>
  205. <a href='javascript:;' class='btn btn-default delItem'><i class='icon-minus'></i></a>
  206. </span>
  207. <span class='input-group-addon'>
  208. <?php echo html::radio("optionDefault[$parentCode]", array('default' => $lang->workflowfield->defaultSubStatus));?>
  209. </span>
  210. </div>
  211. <?php endif;?>
  212. <div id='optionDefault<?php echo $parentCode;?>'></div>
  213. </td>
  214. </tr>
  215. <?php endforeach;?>
  216. </table>
  217. <?php endif;?>
  218. <div id='optionsDIV'></div>
  219. </td>
  220. </tr>
  221. <?php else:?>
  222. <tr id='optionTR'>
  223. <th><?php echo $lang->workflowfield->options;?></th>
  224. <td colspan='3' class='sortTd'>
  225. <?php $options = array('' => '');?>
  226. <?php if(is_array($field->options)) $options = $field->options + array('' => '');?>
  227. <?php foreach($options as $code => $name):?>
  228. <div class="input-group">
  229. <span class='statusKey input-group-addon'><?php echo $lang->workflowfield->key;?></span>
  230. <?php echo html::input('options[code][]', $code, "class='form-control' placeholder='{$lang->workflowfield->placeholder->optionCode}'");?>
  231. <span class='input-group-addon'><?php echo $lang->workflowfield->value;?></span>
  232. <?php echo html::input('options[name][]', $name, "class='form-control'");?>
  233. <span class='input-group-btn sort-btn'>
  234. <a href='javascript:;' class='btn btn-default sortItem'><i class='icon-move'></i></a>
  235. </span>
  236. <span class='input-group-btn'>
  237. <a href='javascript:;' class='btn btn-default addItem'><i class='icon-plus'></i></a>
  238. </span>
  239. <span class='input-group-btn'>
  240. <a href='javascript:;' class='btn btn-default delItem'><i class='icon-minus'></i></a>
  241. </span>
  242. </div>
  243. <?php endforeach;?>
  244. <div id='optionsDIV'></div>
  245. </td>
  246. </tr>
  247. <tr>
  248. <th><?php echo $lang->workflowfield->defaultValue;?></th>
  249. <td colspan='3'><?php echo html::input('default', $field->default, "class='form-control'");?></td>
  250. </tr>
  251. <tr class='tipInfoBox'>
  252. <th><?php echo $lang->workflowfield->tipInfo;?></th>
  253. <td colspan='3'><?php echo html::input('placeholder', $field->placeholder, "class='form-control'");?></td>
  254. </tr>
  255. <tr class='tipInfoBox'>
  256. <th></th>
  257. <td colspan='3' class='text-warning'><?php echo $lang->workflowfield->tips->placeholder;?></td>
  258. </tr>
  259. <?php endif;?>
  260. <tr>
  261. <th><?php echo $lang->workflowfield->rules;?></th>
  262. <td colspan='3'><?php echo html::select('rules[]', $rules, $field->rules, "multiple class='chosen form-control'");?></td>
  263. </tr>
  264. <?php endif;?>
  265. <?php if($groupPairs):?>
  266. <tr>
  267. <td colspan='4'>
  268. <?php
  269. $groupName = implode(',', $groupPairs);
  270. $tips = $lang->workflowfield->tips->syncQuoteNoOptions;
  271. if(in_array($field->control, $config->workflowfield->optionControls) && is_array($field->options)) $tips = $lang->workflowfield->tips->syncQuoteFields;
  272. $tips = sprintf($tips, $groupName);
  273. echo js::set('syncQuoteNoOptions', $lang->workflowfield->tips->syncQuoteNoOptions);
  274. echo js::set('syncQuoteFields', $lang->workflowfield->tips->syncQuoteFields);
  275. echo js::set('joinedGroupName', $groupName);
  276. echo "<div id='tipsBox' class='alert alert-warning'>{$tips}</div>";
  277. ?>
  278. </td>
  279. </tr>
  280. <?php endif;?>
  281. <tr>
  282. <th></th>
  283. <td colspan='3' class='form-actions'>
  284. <?php echo html::submitButton();?>
  285. <div id='alertDIV' class='hide'>
  286. <div id='alert' class='alert alert-warning'></div>
  287. <?php echo baseHTML::commonButton($lang->determine, 'btn btn-default', "id='alertBtn'");?>
  288. </div>
  289. </td>
  290. </tr>
  291. </table>
  292. </form>
  293. <div id='varGroup' class='hide'>
  294. <div id='key' class='w-p45 varControl'>
  295. <div class='input-group'>
  296. </div>
  297. </div>
  298. </div>
  299. <?php include '../../common/view/footer.modal.html.php';?>