showimport.html.php 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  1. <?php
  2. /**
  3. * The batch create view of user module of ZenTaoPMS.
  4. *
  5. * @copyright Copyright 2009-2022 禅道软件(青岛)有限公司(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 Gang Zeng
  8. * @package user
  9. * @version $Id$
  10. * @link http://www.zentao.net
  11. */
  12. ?>
  13. <?php include $app->getModuleRoot() . 'common/view/header.html.php';?>
  14. <?php if(empty($maxImport) and $allCount > $this->config->file->maxImport):?>
  15. <div id="mainContent" class="main-content">
  16. <div class="main-header">
  17. <h2><?php echo $lang->user->batchImport;?></h2>
  18. </div>
  19. <p><?php echo sprintf($lang->file->importSummary, $allCount, html::input('maxImport', $config->file->maxImport, "style='width:50px'"), ceil($allCount / $config->file->maxImport));?></p>
  20. <p><?php echo html::commonButton($lang->import, "id='import'", 'btn btn-primary');?></p>
  21. </div>
  22. <script>
  23. $(function()
  24. {
  25. $('#maxImport').keyup(function()
  26. {
  27. if(parseInt($('#maxImport').val())) $('#times').html(Math.ceil(parseInt($('#allCount').html()) / parseInt($('#maxImport').val())));
  28. });
  29. $('#import').click(function(){location.href = createLink('user', 'showImport', "pageID=1&maxImport=" + $('#maxImport').val())})
  30. });
  31. </script>
  32. <?php else:?>
  33. <?php js::import($jsRoot . 'md5.js');?>
  34. <?php js::set('roleGroup', $roleGroup);?>
  35. <div id="mainContent" class="main-content">
  36. <div class="main-header">
  37. <h2><?php echo $lang->user->batchImport;?></h2>
  38. <?php if($userAddWarning):?>
  39. <div class="text-danger" style="float:left;line-height:35px;"><?php echo $userAddWarning;?></div>
  40. <?php endif;?>
  41. </div>
  42. <?php
  43. $visibleFields = array();
  44. $requiredFields = array();
  45. foreach(explode(',', $showFields) as $field)
  46. {
  47. if(strpos(",{$config->user->availableBatchCreateFields},", ",{$field},") === false) continue;
  48. if($field) $visibleFields[$field] = '';
  49. }
  50. foreach(explode(',', $config->user->create->requiredFields) as $field)
  51. {
  52. if($field)
  53. {
  54. $requiredFields[$field] = '';
  55. if(strpos(",{$config->user->availableBatchCreateFields},", ",{$field},") !== false) $visibleFields[$field] = '';
  56. }
  57. }
  58. $minWidth = (count($visibleFields) > 3) ? 'w-150px' : '';
  59. $showVisionList = count($visionList) > 1;
  60. ?>
  61. <form method='post' class='load-indicator main-form' enctype='multipart/form-data' target='hiddenwin' id="batchCreateForm">
  62. <div class="table-responsive">
  63. <table class="table table-form">
  64. <thead>
  65. <tr class='text-center'>
  66. <th class='c-id'><?php echo $lang->idAB;?></th>
  67. <th class='c-dept<?php echo zget($visibleFields, 'dept', ' hidden') . zget($requiredFields, 'dept', '', ' required');?>'> <?php echo $lang->user->dept;?></th>
  68. <th class='accountThWidth required'><?php echo $lang->user->account;?></th>
  69. <th class='c-realname required'><?php echo $lang->user->realname;?></th>
  70. <?php if($showVisionList):?>
  71. <th class='c-visions required'><?php echo $lang->user->visions;?></th>
  72. <?php endif;?>
  73. <th class='c-role<?php echo zget($requiredFields, 'role', '', ' required')?>'><?php echo $lang->user->role;?></th>
  74. <th class='c-type'><?php echo $lang->user->type;?></th>
  75. <th class='c-group'><?php echo $lang->user->group;?></th>
  76. <th class='<?php echo zget($visibleFields, 'email', "$minWidth hidden", $minWidth) . zget($requiredFields, 'email', '', ' required')?>'><?php echo $lang->user->email;?></th>
  77. <th class='genderThWidth<?php echo zget($visibleFields, 'gender', ' hidden')?>'><?php echo $lang->user->gender;?></th>
  78. <th class="<?php echo $minWidth;?> required"><?php echo $lang->user->password;?></th>
  79. <th class='c-join'><?php echo $lang->user->join;?></th>
  80. <th class='c-contact'><?php echo $lang->user->qq;?></th>
  81. <th class='c-contact'><?php echo $lang->user->weixin;?></th>
  82. <th class='c-contact'><?php echo $lang->user->mobile;?></th>
  83. <th class='c-contact'><?php echo $lang->user->phone;?></th>
  84. <th class='c-contact'><?php echo $lang->user->address;?></th>
  85. </tr>
  86. </thead>
  87. <tbody>
  88. <?php $insert = true;?>
  89. <?php $depts = $depts + array('ditto' => $lang->user->ditto)?>
  90. <?php $lang->user->roleList = $lang->user->roleList + array('ditto' => $lang->user->ditto)?>
  91. <?php $groupList = $groupList + array('ditto' => $lang->user->ditto);?>
  92. <?php $visionList = $visionList + array('ditto' => $lang->user->ditto);?>
  93. <?php $i = 1;?>
  94. <?php foreach($userData as $key => $user):?>
  95. <?php
  96. if(empty($user->dept)) $user->dept = 0;
  97. if(empty($user->account)) $user->account = '';
  98. if(empty($user->realname)) $user->realname = '';
  99. if(empty($user->role)) $user->role = '';
  100. if(empty($user->email)) $user->email = '';
  101. if(empty($user->join)) $user->join = '';
  102. if(empty($user->qq)) $user->qq = '';
  103. if(empty($user->weixin)) $user->weixin = '';
  104. if(empty($user->mobile)) $user->mobile = '';
  105. if(empty($user->phone)) $user->phone = '';
  106. if(empty($user->address)) $user->address = '';
  107. ?>
  108. <tr class='text-center'>
  109. <td><?php echo $i;?></td>
  110. <td class='text-left' style='overflow:visible'><?php echo html::select("dept[$i]", $depts,($i > 1 and !$user->dept) ? 'ditto' : $user->dept, "class='form-control chosen'");?></td>
  111. <td><?php echo html::input("account[$i]", $user->account, "class='form-control account_$i' onchange='changeEmail($i)'");?></td>
  112. <td><?php echo html::input("realname[$i]", $user->realname, "class='form-control'");?></td>
  113. <?php if($showVisionList):?>
  114. <td class='text-left' style='overflow:visible'>
  115. <?php echo html::select("visions[$i][]", $visionList, $i > 1 ? 'ditto' : (isset($visionList[$this->config->vision]) ? $this->config->vision : key($visionList)), "class='form-control chosen' multiple");?>
  116. </td>
  117. <?php else:?>
  118. <?php echo html::hidden("visions[$i][]", $this->config->vision);?>
  119. <?php endif;?>
  120. <td><?php echo html::select("role[$i]", $lang->user->roleList, ($i > 1 and !$user->role) ? 'ditto' : $user->role, "class='form-control' onchange='changeGroup(this.value, $i)'");?></td>
  121. <td><?php echo html::select("type[$i]", array('inside' => $lang->user->inside, 'outside' => $lang->user->outside), $user->type, "class='form-control'");?></td>
  122. <td class='text-left' style='overflow:visible'><?php echo html::select("group[$i][]", $groupList, $i > 1 ? 'ditto' : '', "class='form-control chosen' multiple");?></td>
  123. <td><?php echo html::input("email[$i]", $user->email, "class='form-control email_$i' onchange='setDefaultEmail($i)'");?></td>
  124. <td><?php echo html::radio("gender[$i]", (array)$lang->user->genderList, !empty($user->gender) ? $user->gender : 'm');?></td>
  125. <td align='left'>
  126. <div class='input-group'>
  127. <?php
  128. echo html::input("password[$i]", '', "class='form-control' onkeyup='toggleCheck(this, $i)' oninput=\"this.value = this.value.replace(/[^\\x00-\\xff]/g, '');\"");
  129. echo "<span class='input-group-addon passwordStrength'></span>";
  130. if($i != 1) echo "<span class='input-group-addon passwordBox'><input type='checkbox' name='ditto[$i]' id='ditto$i' " . ($i > 1 ? "checked" : '') . " /> {$lang->user->ditto}</span>";
  131. ?>
  132. </div>
  133. </td>
  134. <td><?php echo html::input("join[$i]", $user->join, "class='form-control form-date'");?></td>
  135. <td><?php echo html::input("qq[$i]", $user->qq, "class='form-control'");?></td>
  136. <td><?php echo html::input("weixin[$i]", $user->weixin, "class='form-control'");?></td>
  137. <td><?php echo html::input("mobile[$i]", $user->mobile, "class='form-control'");?></td>
  138. <td><?php echo html::input("phone[$i]", $user->phone, "class='form-control'");?></td>
  139. <td><?php echo html::input("address[$i]", $user->address, "class='form-control'");?></td>
  140. </tr>
  141. <?php $i ++;?>
  142. <?php endforeach;?>
  143. <tr>
  144. <th colspan='2'><?php echo $lang->user->verifyPassword?></th>
  145. <td colspan='3'>
  146. <div class="required required-wrapper"></div>
  147. <input type='password' style="display:none"> <!-- for disable autocomplete all browser -->
  148. <?php echo html::password('verifyPassword', '', "class='form-control disabled-ie-placeholder' placeholder='{$lang->user->placeholder->verify}'");?>
  149. </td>
  150. </tr>
  151. </tbody>
  152. <tfoot>
  153. <tr>
  154. <td colspan="<?php echo count($visibleFields)?>" class="text-center form-actions">
  155. <?php
  156. $submitText = $isEndPage ? $this->lang->save : $this->lang->file->saveAndNext;
  157. $isStartPage = $pagerID == 1 ? true : false;
  158. if(!$insert and $dataInsert === '')
  159. {
  160. echo "<button type='button' data-toggle='modal' data-target='#importNoticeModal' class='btn btn-primary btn-wide'>{$submitText}</button>";
  161. }
  162. else
  163. {
  164. echo html::submitButton($submitText);
  165. if($dataInsert !== '') echo html::hidden('insert', $dataInsert);
  166. }
  167. echo html::hidden('isEndPage', $isEndPage ? 1 : 0);
  168. echo html::hidden('pagerID', $pagerID);
  169. ?>
  170. <?php echo html::linkButton($lang->goback, $this->createLink('company', 'browse'), 'self', '', 'btn btn-back btn-wide');?>
  171. </td>
  172. </tr>
  173. </tfoot>
  174. </table>
  175. <?php if(!$insert and $dataInsert === '') include $app->getModuleRoot() . 'common/view/noticeimport.html.php';?>
  176. </div>
  177. </form>
  178. </div>
  179. <?php echo html::hidden('verifyRand', $rand);?>
  180. <?php js::set('passwordStrengthList', $lang->user->passwordStrengthList)?>
  181. <?php js::set('batchCreateCount', $config->user->batchCreate)?>
  182. <?php endif;?>
  183. <?php if(!empty($properties['user'])):?>
  184. <?php
  185. $userMaxCount = $properties['user']['value'];
  186. $userCount = $this->dao->select("COUNT('*') as count")->from(TABLE_USER)
  187. ->where('deleted')->eq(0)
  188. ->fetch('count');
  189. js::set('userCount', $userCount);
  190. js::set('userMaxCount', $userMaxCount);
  191. js::set('noticeUserCreate', str_replace('%maxcount%', $userMaxCount, $lang->user->noticeUserCreate));
  192. ?>
  193. <script>
  194. $(function()
  195. {
  196. $('#submit').click(function()
  197. {
  198. if(userMaxCount > 0)
  199. {
  200. var allUserCount = parseInt(userCount);
  201. $('[id^="account"]').each(function()
  202. {
  203. if($(this).val()) allUserCount += 1;
  204. });
  205. if(allUserCount > userMaxCount)
  206. {
  207. alert(noticeUserCreate.replace('%usercount%', allUserCount));
  208. return false;
  209. }
  210. }
  211. })
  212. })
  213. </script>
  214. <?php endif;?>
  215. <?php include $app->getModuleRoot() . 'common/view/footer.html.php';?>