edit.html.php 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386
  1. <?php
  2. /**
  3. * The edit view file of workflowhook 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 workflowhook
  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 js::set('formulaLang', $lang->workflowfield->formula);?>
  16. <?php js::set('moduleName', $flow->module);?>
  17. <form id='editHookForm' class='hookForm' method='post' action='<?php echo inlink('edit', "action=$action->id&key=$key");?>'>
  18. <?php $hook = $action->hooks[$key];?>
  19. <?php $type = zget($hook, 'conditionType', 'data');?>
  20. <?php $class = empty($hook->conditions) ? 'hide' : '';?>
  21. <?php include './expression.html.php';?>
  22. <div id='conditionDIV' class='detail <?php echo $class;?>'>
  23. <div class='detail-heading'>
  24. <strong><?php echo $lang->workflowhook->condition;?></strong>
  25. </div>
  26. <div class='detail-content'>
  27. <table class='table table-form'>
  28. <tr>
  29. <th class='w-80px'></th>
  30. <td class='w-160px'></td>
  31. <td class='w-80px'></td>
  32. <td class='w-160px'></td>
  33. <td></td>
  34. <td class='w-100px'></td>
  35. </tr>
  36. <tr>
  37. <th><?php echo $lang->workflowhook->type;?></th>
  38. <td colspan='4'><?php echo html::select('conditionType', $lang->workflowhook->typeList, $type, "class='form-control'");?></td>
  39. <td></td>
  40. </tr>
  41. <?php $sqlConditionDatasources = $datasources;?>
  42. <?php unset($sqlConditionDatasources['formula']);?>
  43. <?php $dataConditionDatasources = $datasources;?>
  44. <?php unset($dataConditionDatasources['form']);?>
  45. <?php unset($dataConditionDatasources['record']);?>
  46. <?php unset($dataConditionDatasources['formula']);?>
  47. <?php $varKey = 1;?>
  48. <?php $dataKey = 1;?>
  49. <?php /* SQL TR */ ?>
  50. <?php if($type == 'sql'):?>
  51. <tr class='sqlTR'>
  52. <th><?php echo $lang->workflowhook->sql;?></th>
  53. <td colspan='4' class='required'><?php echo html::textarea('sql', $hook->conditions->sql, "rows='5' class='form-control' placeholder='{$lang->workflowhook->placeholder->sql}'");?></td>
  54. <td></td>
  55. </tr>
  56. <?php if(!empty($hook->conditions->sqlVars)):?>
  57. <?php foreach($hook->conditions->sqlVars as $sqlVar):?>
  58. <tr class='sqlTR' data-key='<?php echo $varKey;?>'>
  59. <th><?php echo $lang->workflowhook->varName;?></th>
  60. <td><?php echo html::input("varName[$varKey]", $sqlVar->varName, "class='form-control' autocomplete='off'");?></td>
  61. <td><?php echo html::input("operator[$varKey]", '=', "class='form-control' disabled");?></td>
  62. <td><?php echo html::select("paramType[$varKey]", $sqlConditionDatasources, $sqlVar->paramType, "class='form-control chosen'");?></td>
  63. <td class='paramTD'><?php echo html::input("param[$varKey]", $sqlVar->param, "id='param{$varKey}' class='form-control paramValue' autocomplete='off'");?></td>
  64. <td>
  65. <a href='javascript:;' class='btn addVar'><i class='icon-plus icon-large'></i></a>
  66. <a href='javascript:;' class='btn delVar'><i class='icon-close icon-large'></i></a>
  67. </td>
  68. </tr>
  69. <?php $varKey++;?>
  70. <?php endforeach;?>
  71. <?php else:?>
  72. <tr class='sqlTR' data-key='<?php echo $varKey;?>'>
  73. <th><?php echo $lang->workflowhook->varName;?></th>
  74. <td><?php echo html::input("varName[$varKey]", '', "class='form-control' autocomplete='off'");?></td>
  75. <td><?php echo html::input("operator[$varKey]", '=', "class='form-control' disabled");?></td>
  76. <td><?php echo html::select("paramType[$varKey]", $sqlConditionDatasources, 'custom', "class='form-control chosen'");?></td>
  77. <td class='paramTD'><?php echo html::input("param[$varKey]", '', "id='param{$varKey}' class='form-control' autocomplete='off'");?></td>
  78. <td>
  79. <a href='javascript:;' class='btn addVar'><i class='icon-plus icon-large'></i></a>
  80. <a href='javascript:;' class='btn delVar'><i class='icon-close icon-large'></i></a>
  81. </td>
  82. </tr>
  83. <?php $varKey++;?>
  84. <?php endif;?>
  85. <tr class='sqlTR'>
  86. <th><?php echo $lang->workflowhook->result;?></th>
  87. <td colspan='4'><?php echo html::select('sqlResult', $lang->workflowhook->resultList, $hook->conditions->sqlResult, "class='form-control'");?></td>
  88. <td></td>
  89. </tr>
  90. <?php /* Data TR */ ?>
  91. <tr class='dataTR' data-key='<?php echo $dataKey;?>'>
  92. <th>
  93. <?php echo $lang->workflowhook->field;?>
  94. <?php echo html::hidden("conditions[logicalOperator][$dataKey]", 'and');?>
  95. </th>
  96. <td><?php echo html::select("conditions[field][$dataKey]", $fields, '', "class='form-control chosen'");?></td>
  97. <td><?php echo html::select("conditions[operator][$dataKey]", $config->workflowhook->operatorList, 'equal', "class='form-control chosen'");?></td>
  98. <td><?php echo html::select("conditions[paramType][$dataKey]", $dataConditionDatasources, 'custom', "class='form-control chosen'");?></td>
  99. <td class='paramTD'><?php echo html::input("conditions[param][$dataKey]", '', "id='conditionsparam{$dataKEY}' class='form-control' autocomplete='off'");?></td>
  100. <td>
  101. <a href='javascript:;' class='btn addCondition'><i class='icon-plus icon-large'></i></a>
  102. </td>
  103. </tr>
  104. <?php $dataKey++;?>
  105. <?php endif;?>
  106. <?php if($type == 'data'):?>
  107. <?php /* SQL TR */ ?>
  108. <tr class='sqlTR'>
  109. <th><?php echo $lang->workflowhook->sql;?></th>
  110. <td colspan='4'><?php echo html::textarea('sql', '', "rows='5' class='form-control' placeholder='{$lang->workflowhook->placeholder->sql}'");?></td>
  111. <td></td>
  112. </tr>
  113. <tr class='sqlTR' data-key='<?php echo $varKey;?>'>
  114. <th><?php echo $lang->workflowhook->varName;?></th>
  115. <td><?php echo html::input("varName[$varKey]", '', "class='form-control' autocomplete='off'");?></td>
  116. <th><?php echo html::input("operator[$varKey]", '=', "class='form-control' disabled");?></th>
  117. <td><?php echo html::select("paramType[$varKey]", $sqlConditionDatasources, 'custom', "class='form-control chosen'");?></td>
  118. <td class='paramTD'><?php echo html::input("param[$varKey]", '', "id='param{$varKey}' class='form-control' autocomplete='off'");?></td>
  119. <td>
  120. <a href='javascript:;' class='btn addVar'><i class='icon-plus icon-large'></i></a>
  121. <a href='javascript:;' class='btn delVar'><i class='icon-close icon-large'></i></a>
  122. </td>
  123. </tr>
  124. <?php $varKey++;?>
  125. <tr class='sqlTR'>
  126. <th><?php echo $lang->workflowhook->result;?></th>
  127. <td colspan='4'><?php echo html::select('sqlResult', $lang->workflowhook->resultList, 'empty', "class='form-control'");?></td>
  128. <td></td>
  129. </tr>
  130. <?php /* Data TR */ ?>
  131. <?php if(!empty($hook->conditions)):?>
  132. <?php foreach($hook->conditions as $key => $condition):?>
  133. <tr class='dataTR' data-key='<?php echo $dataKey;?>'>
  134. <th>
  135. <?php if($key == 0):?>
  136. <?php echo $lang->workflowhook->field;?>
  137. <?php echo html::hidden("conditions[logicalOperator][$dataKey]", $condition->logicalOperator);?>
  138. <?php else:?>
  139. <?php echo html::select("conditions[logicalOperator][$dataKey]", $lang->workflowhook->logicalOperatorList, $condition->logicalOperator, "class='form-control'");?>
  140. <?php endif;?>
  141. </th>
  142. <td><?php echo html::select("conditions[field][$dataKey]", $fields, $condition->field, "class='form-control chosen'");?></td>
  143. <td><?php echo html::select("conditions[operator][$dataKey]", $config->workflowhook->operatorList, $condition->operator, "class='form-control chosen'");?></td>
  144. <td><?php echo html::select("conditions[paramType][$dataKey]", $dataConditionDatasources, $condition->paramType, "class='form-control chosen'");?></td>
  145. <td class='paramTD'><?php echo html::input("conditions[param][$dataKey]", $condition->param, "id='conditionsparam{$dataKey}' class='form-control paramValue' autocomplete='off'");?></td>
  146. <td>
  147. <a href='javascript:;' class='btn addCondition'><i class='icon-plus icon-large'></i></a>
  148. <?php if($dataKey > 1):?>
  149. <a href='javascript:;' class='btn delCondition'><i class='icon-close icon-large'></i></a>
  150. <?php endif;?>
  151. </td>
  152. </tr>
  153. <?php $dataKey++;?>
  154. <?php endforeach;?>
  155. <?php else:?>
  156. <tr class='dataTR' data-key='<?php echo $dataKey;?>'>
  157. <th>
  158. <?php echo $lang->workflowhook->field;?>
  159. <?php echo html::hidden("conditions[logicalOperator][$dataKey]", 'and');?>
  160. </th>
  161. <td><?php echo html::select("conditions[field][$dataKey]", $fields, '', "class='form-control chosen'");?></td>
  162. <td><?php echo html::select("conditions[operator][$dataKey]", $config->workflowhook->operatorList, 'equal', "class='form-control chosen'");?></td>
  163. <td><?php echo html::select("conditions[paramType][$dataKey]", $dataConditionDatasources, 'custom', "class='form-control chosen'");?></td>
  164. <td class='paramTD'><?php echo html::input("conditions[param][$dataKey]", '', "id='conditionsparam{$dataKey}' class='form-control' autocomplete='off'");?></td>
  165. <td>
  166. <a href='javascript:;' class='btn addCondition'><i class='icon-plus icon-large'></i></a>
  167. </td>
  168. </tr>
  169. <?php $dataKey++;?>
  170. <?php endif;?>
  171. <?php endif;?>
  172. </table>
  173. </div>
  174. </div>
  175. <div id='hookDIV' class='detail'>
  176. <div class='detail-heading'>
  177. <strong><?php echo $lang->workflowhook->hook;?></strong>
  178. </div>
  179. <div class='detail-content'>
  180. <table class='table table-form'>
  181. <tr>
  182. <th class='w-80px'><?php echo $lang->workflowhook->action;?></th>
  183. <td class='w-160px'><?php echo html::select('action', $lang->workflowhook->actionList, $hook->action, "class='form-control'");?></td>
  184. <th class='w-80px'><?php echo $lang->workflowhook->table;?></th>
  185. <td class='w-160px'><?php echo html::select('table', $tables, $hook->table, "class='form-control chosen'");?></td>
  186. <td></td>
  187. <td class='w-100px'></td>
  188. </tr>
  189. <?php /* Field TR */ ?>
  190. <?php $fieldKey = 1;?>
  191. <?php if(!empty($hook->fields)):?>
  192. <?php foreach($hook->fields as $field):?>
  193. <tr class='fieldTR' data-key='<?php echo $fieldKey;?>'>
  194. <th><?php if($fieldKey == 1) echo $lang->workflowhook->field;?></th>
  195. <td><?php echo html::select("fields[field][$fieldKey]", $hookFields, $field->field, "class='form-control chosen field'");?></td>
  196. <td><?php echo html::input("fields[operator][$fieldKey]", '=', "class='form-control' disabled");?></td>
  197. <td><?php echo html::select("fields[paramType][$fieldKey]", $datasources, $field->paramType, "class='form-control chosen'");?></td>
  198. <td class='paramTD'><?php echo html::input("fields[param][$fieldKey]", $field->param, "id='fieldsparam{$fieldKey}' class='form-control paramValue' autocomplete='off'");?></td>
  199. <td>
  200. <a href='javascript:;' class='btn addField'><i class='icon-plus icon-large'></i></a>
  201. <?php if($fieldKey > 1):?>
  202. <a href='javascript:;' class='btn delField'><i class='delField icon-close icon-large'></i></a>
  203. <?php endif;?>
  204. </td>
  205. </tr>
  206. <?php $fieldKey++;?>
  207. <?php endforeach;?>
  208. <?php else:?>
  209. <tr class='fieldTR' data-key='<?php echo $fieldKey;?>'>
  210. <th><?php echo $lang->workflowhook->field;?></th>
  211. <td><?php echo html::select("fields[field][$fieldKey]", $hookFields, '', "class='form-control chosen field'");?></td>
  212. <td><?php echo html::input("fields[operator][$fieldKey]", '=', "class='form-control' disabled");?></td>
  213. <td><?php echo html::select("fields[paramType][$fieldKey]", $datasources, 'custom', "class='form-control chosen'");?></td>
  214. <td class='paramTD'><?php echo html::input("fields[param][$fieldKey]", '', "id='fieldsparam{$fieldKey}' class='form-control' autocomplete='off'");?></td>
  215. <td>
  216. <a href='javascript:;' class='btn addField'><i class='icon-plus icon-large'></i></a>
  217. </td>
  218. </tr>
  219. <?php $fieldKey++;?>
  220. <?php endif;?>
  221. <?php /* Where TR */ ?>
  222. <?php $whereDatasources = $datasources;?>
  223. <?php unset($whereDatasources['formula']);?>
  224. <?php $whereKey = 1;?>
  225. <?php if(!empty($hook->wheres)):?>
  226. <?php foreach($hook->wheres as $where):?>
  227. <tr class='whereTR' data-key='<?php echo $whereKey;?>'>
  228. <th>
  229. <?php if($whereKey == 1):?>
  230. <?php echo $lang->workflowhook->where;?>
  231. <?php echo html::hidden("wheres[logicalOperator][$whereKey]", $where->logicalOperator);?>
  232. <?php else:?>
  233. <?php echo html::select("wheres[logicalOperator][$whereKey]", $lang->workflowhook->logicalOperatorList, $where->logicalOperator, "class='form-control'");?>
  234. <?php endif;?>
  235. </th>
  236. <td><?php echo html::select("wheres[field][$whereKey]", $hookFields, $where->field, "class='form-control chosen field'");?></td>
  237. <td><?php echo html::select("wheres[operator][$whereKey]", $config->workflowhook->operatorList, $where->operator, "class='form-control chosen'");?></td>
  238. <td><?php echo html::select("wheres[paramType][$whereKey]", $whereDatasources, $where->paramType, "class='form-control chosen'");?></td>
  239. <td class='paramTD'><?php echo html::input("wheres[param][$whereKey]", $where->param, "id='wheresparam{$whereKey}' class='form-control paramValue' autocomplete='off'");?></td>
  240. <td>
  241. <a href='javascript:;' class='btn addWhere'><i class='icon-plus icon-large'></i></a>
  242. <?php if($whereKey > 1):?>
  243. <a href='javascript:;' class='btn delWhere'><i class='icon-close icon-large'></i></a>
  244. <?php endif;?>
  245. </td>
  246. </tr>
  247. <?php $whereKey++;?>
  248. <?php endforeach;?>
  249. <?php else:?>
  250. <tr class='whereTR' data-key='<?php echo $whereKey;?>'>
  251. <th>
  252. <?php echo $lang->workflowhook->where;?>
  253. <?php echo html::hidden("wheres[logicalOperator][$whereKey]", 'and');?>
  254. </th>
  255. <td><?php echo html::select("wheres[field][$whereKey]", $hookFields, '', "class='form-control chosen field'");?></td>
  256. <td><?php echo html::select("wheres[operator][$whereKey]", $config->workflowhook->operatorList, '', "class='form-control chosen'");?></td>
  257. <td><?php echo html::select("wheres[paramType][$whereKey]", $whereDatasources, 'custom', "class='form-control chosen'");?></td>
  258. <td class='paramTD'><?php echo html::input("wheres[param][$whereKey]", '', "id='wheresparam{$whereKey}' class='form-control' autocomplete='off'");?></td>
  259. <td>
  260. <a href='javascript:;' class='btn addWhere'><i class='icon-plus icon-large'></i></a>
  261. </td>
  262. </tr>
  263. <?php $whereKey++;?>
  264. <?php endif;?>
  265. <tr>
  266. <th><?php echo $lang->workflowhook->message;?></th>
  267. <td colspan='4'><?php echo html::input('message', zget($hook, 'message', ''), "class='form-control' autocomplete='off'");?></td>
  268. <td></td>
  269. </tr>
  270. <tr>
  271. <th><?php echo $lang->comment;?></th>
  272. <td colspan='4'><?php echo html::textarea('comment', zget($hook, 'comment', ''), "class='form-control' rows='3'");?></td>
  273. <td></td>
  274. </tr>
  275. <tr>
  276. <th></th>
  277. <td class='form-actions' colspan='5'>
  278. <?php echo html::hidden('condition', empty($hook->conditions) ? 0 : 1);?>
  279. <?php echo baseHTML::a('javascript:;', $lang->workflowhook->condition, "class='btn btn-primary toggleCondition'");?>
  280. <?php echo html::submitButton();?>
  281. </td>
  282. </tr>
  283. </table>
  284. </div>
  285. </div>
  286. </form>
  287. <?php
  288. $varName = html::input('varName[KEY]', '', "class='form-control' autocomplete='off'");
  289. $operator = html::input('operator[KEY]', '=', "class='form-control' disabled");
  290. $paramType = html::select('paramType[KEY]', $sqlConditionDatasources, 'custom', "class='form-control chosen'");
  291. $param = html::input('param[KEY]', '', "id='paramKEY' class='form-control' autocomplete='off'");
  292. $varRow = <<<EOT
  293. <tr class='sqlTR' data-key='KEY'>
  294. <th></th>
  295. <td>{$varName}</td>
  296. <td>{$operator}</td>
  297. <td>{$paramType}</td>
  298. <td class='paramTD'>{$param}</td>
  299. <td>
  300. <a href='javascript:;' class='btn addVar'><i class='icon-plus icon-large'></i></a>
  301. <a href='javascript:;' class='btn delVar'><i class='icon-close icon-large'></i></a>
  302. </td>
  303. </tr>
  304. EOT;
  305. $logicOperater = html::select('conditions[logicalOperator][KEY]', $lang->workflowhook->logicalOperatorList, '', "class='form-control'");
  306. $field = html::select('conditions[field][KEY]', $fields, '', "class='form-control chosen'");
  307. $operator = html::select('conditions[operator][KEY]', $config->workflowhook->operatorList, 'equal', "class='form-control chosen'");
  308. $paramType = html::select('conditions[paramType][KEY]', $dataConditionDatasources, 'custom', "class='form-control chosen'");
  309. $param = html::input('conditions[param][KEY]', '', "id='conditionsparamKEY' class='form-control' autocomplete='off'");
  310. $conditionRow = <<<EOT
  311. <tr class='dataTR' data-key='KEY'>
  312. <th>{$logicOperater}</th>
  313. <td>{$field}</td>
  314. <td>{$operator}</td>
  315. <td>{$paramType}</td>
  316. <td class='paramTD'>{$param}</td>
  317. <td>
  318. <a href='javascript:;' class='btn addCondition'><i class='icon-plus icon-large'></i></a>
  319. <a href='javascript:;' class='btn delCondition'><i class='icon-close icon-large'></i></a>
  320. </td>
  321. </tr>
  322. EOT;
  323. $field = html::select('fields[field][KEY]', $fields, '', "class='form-control chosen field'");
  324. $operator = html::input('fields[operator][KEY]', '=', "class='form-control' disabled");
  325. $paramType = html::select('fields[paramType][KEY]', $datasources, 'custom', "class='form-control chosen'");
  326. $param = html::input('fields[param][KEY]', '', "id='fieldsparamKEY' class='form-control' autocomplete='off'");
  327. $fieldRow = <<<EOT
  328. <tr class='fieldTR' data-key='KEY'>
  329. <th></th>
  330. <td>{$field}</td>
  331. <td>{$operator}</td>
  332. <td>{$paramType}</td>
  333. <td class='paramTD'>{$param}</td>
  334. <td>
  335. <a href='javascript:;' class='btn addField'><i class='icon-plus icon-large'></i></a>
  336. <a href='javascript:;' class='btn delField'><i class='icon-close icon-large'></i></a>
  337. </td>
  338. </tr>
  339. EOT;
  340. $logicOperater = html::select('wheres[logicalOperator][KEY]', $lang->workflowhook->logicalOperatorList, '', "class='form-control'");
  341. $field = html::select('wheres[field][KEY]', $fields, '', "class='form-control chosen field'");
  342. $operator = html::select('wheres[operator][KEY]', $config->workflowhook->operatorList, 'equal', "class='form-control chosen'");
  343. $paramType = html::select('wheres[paramType][KEY]', $whereDatasources, 'custom', "class='form-control chosen'");
  344. $param = html::input('wheres[param][KEY]', '', "id='wheresparamKEY' class='form-control' autocomplete='off'");
  345. $whereRow = <<<EOT
  346. <tr class='whereTR' data-key='KEY'>
  347. <th>{$logicOperater}</th>
  348. <td>{$field}</td>
  349. <td>{$operator}</td>
  350. <td>{$paramType}</td>
  351. <td class='paramTD'>{$param}</td>
  352. <td>
  353. <a href='javascript:;' class='btn addWhere'><i class='icon-plus icon-large'></i></a>
  354. <a href='javascript:;' class='btn delWhere'><i class='icon-close icon-large'></i></a>
  355. </td>
  356. </tr>
  357. EOT;
  358. $recordFields = html::select('NAME', $fields, '', "class='form-control chosen'");
  359. $formFields = html::select('NAME', array('' => '') + $layoutFields, '', "class='form-control chosen'");
  360. js::set('recordFields', $recordFields);
  361. js::set('formFields', $formFields);
  362. js::set('hookVarKey', $varKey);
  363. js::set('hookDataKey', $dataKey);
  364. js::set('hookFieldKey', $fieldKey);
  365. js::set('hookWhereKey', $whereKey);
  366. js::set('varRow', $varRow);
  367. js::set('conditionRow', $conditionRow);
  368. js::set('fieldRow', $fieldRow);
  369. js::set('whereRow', $whereRow);
  370. ?>
  371. <?php include '../../common/view/footer.modal.html.php';?>