browse.html.php 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292
  1. <?php
  2. /**
  3. * The browse of opportunity module of ZenTaoPMS.
  4. *
  5. * @copyright Copyright 2009-2021 禅道软件(青岛)有限公司(ZenTao Software (Qingdao) Co., Ltd. www.cnezsoft.com)
  6. * @license ZPL(http://zpl.pub/page/zplv12.html) or AGPL(https://www.gnu.org/licenses/agpl-3.0.en.html)
  7. * @author Shujie Tian <tianshujie@easycorp.ltd>
  8. * @package opportunity
  9. * @version $Id: browse.html.php 4903 2021-05-26 09:32:59Z tsj $
  10. * @link https://www.zentao.net
  11. */
  12. ?>
  13. <?php include $app->getModuleRoot() . "common/view/header.html.php"?>
  14. <?php $hasOpportunitylib = helper::hasFeature('opportunitylib');?>
  15. <div id="mainMenu" class="clearfix">
  16. <div class="btn-toobar pull-left">
  17. <?php
  18. $menus = customModel::getFeatureMenu($this->moduleName, $this->methodName);
  19. foreach($menus as $menuItem)
  20. {
  21. $active = $menuItem->name == $browseType ? ' btn-active-text' : '';
  22. echo html::a($this->createLink('opportunity', 'browse', "projectID=$projectID&from=$from&browseType=$menuItem->name"), "<span class='text'>{$menuItem->text}</span> " . ($browseType == $menuItem->name ? "<span class='label label-light label-badge'>{$pager->recTotal}</span>" : ''), '', "class='btn btn-link $active' data-app='{$app->tab}'");
  23. }
  24. ?>
  25. <a class="btn btn-link querybox-toggle" id='bysearchTab'><i class="icon icon-search muted"></i> <?php echo $lang->opportunity->byQuery;?></a>
  26. </div>
  27. <div class="btn-toolbar pull-right">
  28. <div class='btn-group'>
  29. <button class="btn btn-link" data-toggle="dropdown"><i class="icon icon-export muted"></i> <span class="text"><?php echo $lang->export ?></span> <span class="caret"></span></button>
  30. <ul class='dropdown-menu pull-right' id='exportActionMenu'>
  31. <?php
  32. $class = common::hasPriv('opportunity', 'export') ? "" : "class='disabled'";
  33. $misc = common::hasPriv('opportunity', 'export') ? "class='export'" : "class='disabled'";
  34. $link = common::hasPriv('opportunity', 'export') ? $this->createLink('opportunity', 'export', "objectID=$projectID&browseType=$browseType&orderBy=$orderBy") : '#';
  35. echo "<li $class>" . html::a($link, $lang->opportunity->export, '', $misc) . "</li>";
  36. ?>
  37. </ul>
  38. </div>
  39. <div class='btn-group'>
  40. <button class="btn btn-link" data-toggle='dropdown' id='importAction'><i class='icon icon-import muted'></i> <?php echo $lang->import;?><span class='caret'></span></button>
  41. <ul class='dropdown-menu pull-right' id='importActionMenu'>
  42. <?php
  43. $canChangeObject = common::canModify($from, $object);
  44. $class = ($canChangeObject && common::hasPriv('opportunity', 'importFromLib') && $hasOpportunitylib) ? '' : "class=disabled";
  45. $misc = ($canChangeObject && common::hasPriv('opportunity', 'importFromLib') && $hasOpportunitylib) ? "data-app='{$app->tab}'" : "class=disabled";
  46. $link = ($canChangeObject && common::hasPriv('opportunity', 'importFromLib') && $hasOpportunitylib) ? $this->createLink('opportunity', 'importFromLib', "projectID=$projectID&from=$from") : '#';
  47. echo "<li $class>" . html::a($link, $lang->opportunity->importFromLib, '', $misc) . "</li>";
  48. ?>
  49. </ul>
  50. </div>
  51. <?php if($canChangeObject && (common::hasPriv('opportunity', 'create') || common::hasPriv('opportunity', 'batchCreate'))):?>
  52. <div class='btn-group dropdown'>
  53. <?php
  54. if(common::hasPriv('opportunity', 'create'))
  55. {
  56. $actionLink = $this->createLink('opportunity', 'create', "projectID=$projectID&from=$from");
  57. echo html::a($actionLink, "<i class='icon icon-plus'></i> {$lang->opportunity->create}", '', "class='btn btn-primary' data-app='{$app->tab}'");
  58. }
  59. elseif(common::hasPriv('opportunity', 'batchCreate'))
  60. {
  61. $actionLink = $this->createLink('opportunity', 'batchCreate', "projectID=$projectID&from=$from");
  62. echo html::a($actionLink, "<i class='icon icon-plus'></i> {$lang->opportunity->batchCreate}", '', "class='btn btn-primary' data-app='{$app->tab}'");
  63. }
  64. ?>
  65. <?php if((common::hasPriv('opportunity', 'create')) and (common::hasPriv('opportunity', 'batchCreate'))):?>
  66. <button type='button' class='btn btn-primary dropdown-toggle' data-toggle='dropdown'><span class='caret'></span></button>
  67. <ul class='dropdown-menu pull-right'>
  68. <li><?php echo html::a($actionLink, $lang->opportunity->create, '' ,"data-app=$app->tab");?></li>
  69. <li><?php echo html::a($this->createLink('opportunity', 'batchCreate', "projectID=$projectID&from=$from"), $lang->opportunity->batchCreate, '', "data-app='{$app->tab}'");?></li>
  70. </ul>
  71. <?php endif;?>
  72. </div>
  73. <?php endif;?>
  74. </div>
  75. </div>
  76. <div class="cell<?php if($browseType == 'bysearch') echo ' show';?>" id="queryBox" data-url="<?php echo $this->createLink('search', 'buildOldForm', 'module=opportunity');?>"data-module='opportunity'></div>
  77. <div id="mainContent" class="main-table">
  78. <?php if(empty($opportunities)):?>
  79. <div class="table-empty-tip">
  80. <p>
  81. <span class="text-muted"><?php echo $lang->noData;?></span>
  82. <?php if(common::hasPriv('opportunity', 'create')):?>
  83. <?php echo html::a($this->createLink('opportunity', 'create', "projectID=$projectID&from=$from"), "<i class='icon icon-plus'></i> " . $lang->opportunity->create, '', "class='btn btn-info' data-app='{$app->tab}'");?>
  84. <?php endif;?>
  85. </p>
  86. </div>
  87. <?php else:?>
  88. <form class='main-table' id='opportunityForm' method='post' data-ride="table">
  89. <table class="table has-sort-head" id='opportunityList'>
  90. <?php
  91. $vars = "projectID=$projectID&from=$from&browseType=$browseType&param=$param&orderBy=%s&recTotal={$pager->recTotal}&recPerPage={$pager->recPerPage}";
  92. $canBatchEdit = common::hasPriv('opportunity', 'batchEdit');
  93. $canBatchAssignTo = common::hasPriv('opportunity', 'batchAssignTo');
  94. $canBatchClose = common::hasPriv('opportunity', 'batchClose');
  95. $canBatchCancel = common::hasPriv('opportunity', 'batchCancel');
  96. $canBatchHangup = common::hasPriv('opportunity', 'batchHangup');
  97. $canBatchActivate = common::hasPriv('opportunity', 'batchActivate');
  98. $canBatchImportToLib = (common::hasPriv('opportunity', 'batchImportToLib') and $hasOpportunitylib);
  99. $canBatchAction = $canChangeObject && ($canBatchEdit or $canBatchAssignTo or $canBatchClose or $canBatchCancel or $canBatchHangup or $canBatchActivate or $canBatchImportToLib);
  100. ?>
  101. <thead>
  102. <tr>
  103. <th class='text-left w-80px'>
  104. <?php
  105. if($canBatchAction) echo "<div class='checkbox-primary check-all' title='{$this->lang->selectAll}'><label></label></div>";
  106. common::printOrderLink('id', $orderBy, $vars, $lang->opportunity->id);
  107. ?>
  108. </th>
  109. <th class='c-name'><?php common::printOrderLink('name', $orderBy, $vars, $lang->opportunity->name);?></th>
  110. <th class='c-pri'><?php common::printOrderLink('pri', $orderBy, $vars, $lang->priAB);?></th>
  111. <th class='c-ratio'><?php common::printOrderLink('ratio', $orderBy, $vars, $lang->opportunity->ratio);?></th>
  112. <th class='c-status'><?php common::printOrderLink('status', $orderBy, $vars, $lang->opportunity->status);?></th>
  113. <th class='c-type'><?php common::printOrderLink('type', $orderBy, $vars, $lang->opportunity->type);?></th>
  114. <th class='c-identifiedDate'><?php common::printOrderLink('identifiedDate', $orderBy, $vars, $lang->opportunity->identifiedDate);?></th>
  115. <th class='c-assignedTo'><?php common::printOrderLink('assignedTo', $orderBy, $vars, $lang->opportunity->assignedTo);?></th>
  116. <th class='c-strategy'><?php common::printOrderLink('strategy', $orderBy, $vars, $lang->opportunity->strategy);?></th>
  117. <th class='c-actions'><?php echo $lang->actions;?></th>
  118. </tr>
  119. </thead>
  120. <tbody>
  121. <?php foreach($opportunities as $opportunity):?>
  122. <tr>
  123. <td>
  124. <?php echo $canBatchAction ? html::checkbox('opportunityIDList', array($opportunity->id => '')) . sprintf('%03d',$opportunity->id) : sprintf('%03d',$opportunity->id);?>
  125. </td>
  126. <td class='c-name' title=<?php echo $opportunity->name;?>>
  127. <?php
  128. if(commonModel::hasPriv('opportunity', 'view'))
  129. {
  130. echo html::a($this->createLink('opportunity', 'view', "opportunityID=$opportunity->id&from=$from"), $opportunity->name, '', "data-app='{$app->tab}'");
  131. }
  132. else
  133. {
  134. echo $opportunity->name;
  135. }
  136. ?>
  137. </td>
  138. <td><?php echo "<span class='pri-{$opportunity->pri}'>" . zget($lang->opportunity->priList, $opportunity->pri) . "</span>";?></td>
  139. <td><?php echo $opportunity->ratio;?></td>
  140. <td><?php echo zget($lang->opportunity->statusList, $opportunity->status);?></td>
  141. <td><?php echo zget($lang->opportunity->typeList, $opportunity->type);?></td>
  142. <td><?php echo helper::isZeroDate($opportunity->identifiedDate) ? '' : $opportunity->identifiedDate;?></td>
  143. <td><?php echo $this->opportunity->printAssignedHtml($opportunity, $users);?></td>
  144. <td><?php echo zget($lang->opportunity->strategyList, $opportunity->strategy);?></td>
  145. <td class='c-actions'>
  146. <?php
  147. if($canChangeObject)
  148. {
  149. $params = "opportunityID=$opportunity->id";
  150. common::printIcon('opportunity', 'track', $params, $opportunity, "list", 'checked', '', 'iframe', true);
  151. common::printIcon('opportunity', 'close', $params, $opportunity, "list", '', '', 'iframe', true);
  152. common::printIcon('opportunity', 'cancel', $params, $opportunity, "list", '', '', 'iframe', true);
  153. common::printIcon('opportunity', 'hangup', $params, $opportunity, "list", 'arrow-up', '', 'iframe', true);
  154. common::printIcon('opportunity', 'activate', $params, $opportunity, "list", '', '', 'iframe', true);
  155. common::printIcon('opportunity', 'edit', $params . "&from=$from", $opportunity, "list");
  156. }
  157. ?>
  158. </td>
  159. </tr>
  160. <?php endforeach;?>
  161. </tbody>
  162. </table>
  163. <div class='table-footer'>
  164. <?php if($canBatchAction):?>
  165. <div class="checkbox-primary check-all"><label><?php echo $lang->selectAll?></label></div>
  166. <?php endif;?>
  167. <div class="table-actions btn-toolbar">
  168. <div class='btn-group dropup'>
  169. <?php
  170. $actionLink = $this->createLink('opportunity', 'batchEdit', "projectID=$projectID&from=$from");
  171. $disabled = $canBatchEdit ? '' : "disabled='disabled'";
  172. echo html::commonButton($lang->edit, "data-form-action='$actionLink' $disabled");
  173. echo "<button type='button' class='btn dropdown-toggle' data-toggle='dropdown'><span class='caret'></span></button>";
  174. echo "<ul class='dropdown-menu'>";
  175. $class = $canBatchClose ? '' : "class=disabled";
  176. $actionLink = $this->createLink('opportunity', 'batchClose');
  177. $misc = $canBatchClose ? "onclick=\"setFormAction('$actionLink', 'hiddenwin', '#opportunityList')\"" : '';
  178. echo "<li $class>" . html::a('#', $lang->close, '', $misc) . "</li>";
  179. if($canBatchCancel)
  180. {
  181. echo "<li class='dropdown-submenu'>";
  182. echo html::a('javascript:;', $lang->opportunity->cancel, '', "id='reasonItem'");
  183. echo "<ul class='dropdown-menu'>";
  184. foreach($lang->opportunity->cancelReasonList as $key => $cancelReason)
  185. {
  186. if(empty($key)) continue;
  187. $actionLink = $this->createLink('opportunity', 'batchCancel', "cancelReason=$key");
  188. echo "<li>" . html::a('#', $cancelReason, '', "onclick=\"setFormAction('$actionLink', 'hiddenwin', '#opportunityList')\"") . "</li>";
  189. }
  190. echo '</ul></li>';
  191. }
  192. else
  193. {
  194. $class = "class='disabled'";
  195. echo "<li $class>" . html::a('javascript:;', $lang->opportunity->cancel, '', $class) . '</li>';
  196. }
  197. $class = $canBatchHangup ? '' : "class=disabled";
  198. $actionLink = $this->createLink('opportunity', 'batchHangup');
  199. $misc = $canBatchHangup ? "onclick=\"setFormAction('$actionLink', 'hiddenwin', '#opportunityList')\"" : '';
  200. echo "<li $class>" . html::a('#', $lang->opportunity->hangup, '', $misc) . "</li>";
  201. $class = $canBatchActivate ? '' : "class=disabled";
  202. $actionLink = $this->createLink('opportunity', 'batchActivate');
  203. $misc = $canBatchActivate ? "onclick=\"setFormAction('$actionLink', 'hiddenwin', '#opportunityList')\"" : '';
  204. echo "<li $class>" . html::a('#', $lang->opportunity->activate, '', $misc) . "</li>";
  205. echo "</ul>";
  206. ?>
  207. </div>
  208. <?php if($canBatchAssignTo):?>
  209. <div class="btn-group dropup">
  210. <button data-toggle="dropdown" type="button" class="btn"><?php echo $lang->opportunity->assignedTo;?> <span class="caret"></span></button>
  211. <?php
  212. $withSearch = count($members) > 10;
  213. $actionLink = $this->createLink('opportunity', 'batchAssignTo', "projectID=$projectID");
  214. echo html::select('assignedTo', $members, '', 'class="hidden"');
  215. if($withSearch):
  216. ?>
  217. <div class="dropdown-menu search-list search-box-sink" data-ride="searchList">
  218. <div class="input-control search-box has-icon-left has-icon-right search-example">
  219. <input id="userSearchBox" type="search" autocomplete="off" class="form-control search-input">
  220. <label for="userSearchBox" class="input-control-icon-left search-icon"><i class="icon icon-search"></i></label>
  221. <a class="input-control-icon-right search-clear-btn"><i class="icon icon-close icon-sm"></i></a>
  222. </div>
  223. <?php $membersPinYin = common::convert2Pinyin($members);?>
  224. <?php else:?>
  225. <div class="dropdown-menu search-list">
  226. <?php endif;?>
  227. <div class="list-group">
  228. <?php
  229. foreach($members as $key => $value)
  230. {
  231. if(empty($key)) continue;
  232. $searchKey = $withSearch ? ('data-key="' . zget($membersPinYin, $value, '') . " @$key\"") : "data-key='@$key'";
  233. echo html::a("javascript:$(\".table-actions #assignedTo\").val(\"$key\");setFormAction(\"$actionLink\", \"hiddenwin\", \"#opportunityList\")", $value, '', $searchKey);
  234. }
  235. ?>
  236. </div>
  237. </div>
  238. </div>
  239. <?php endif;?>
  240. <?php if($canBatchImportToLib):?>
  241. <?php echo html::a('#batchImportToLib', $lang->opportunity->importToLib, '', 'class="btn" data-toggle="modal" id="importToLib"');?>
  242. <?php endif;?>
  243. </div>
  244. <?php $pager->show('right', 'pagerjs');?>
  245. </div>
  246. <?php endif;?>
  247. </form>
  248. </div>
  249. <div class="modal fade" id="batchImportToLib">
  250. <div class="modal-dialog mw-500px">
  251. <div class="modal-content">
  252. <div class="modal-header">
  253. <button type="button" class="close" data-dismiss="modal" aria-hidden="true"><i class="icon icon-close"></i></button>
  254. <h4 class="modal-title"><?php echo $lang->opportunity->importToLib;?></h4>
  255. </div>
  256. <div class="modal-body">
  257. <form method='post' class='form-ajax' action='<?php echo $this->createLink('opportunity', 'batchImportToLib');?>'>
  258. <table class='table table-form'>
  259. <tr>
  260. <th class='lib-th'><?php echo $lang->opportunity->lib;?></th>
  261. <td>
  262. <?php echo html::select('lib', $libs, '', "class='form-control chosen' required");?>
  263. </td>
  264. </tr>
  265. <?php if(!common::hasPriv('assetlib', 'approveOpportunity') and !common::hasPriv('assetlib', 'batchApproveOpportunity')):?>
  266. <tr>
  267. <th><?php echo $lang->opportunity->approver;?></th>
  268. <td>
  269. <?php echo html::select('assignedTo', $approvers, '', "class='form-control chosen'");?>
  270. </td>
  271. </tr>
  272. <?php endif;?>
  273. <tr>
  274. <td colspan='2' class='text-center'>
  275. <?php echo html::hidden('opportunityIDList', '');?>
  276. <?php echo html::submitButton($lang->import, '', 'btn btn-primary');?>
  277. </td>
  278. </tr>
  279. </table>
  280. </form>
  281. </div>
  282. </div>
  283. </div>
  284. </div>
  285. <?php include $app->getModuleRoot() . "common/view/footer.html.php"?>