batchcreate.bizext.html.hook.php 1.0 KB

1234567891011121314151617181920212223242526272829303132
  1. <?php
  2. namespace zin;
  3. $userCount = $userMaxCount = 0;
  4. if(data('properties.user'))
  5. {
  6. $lang = data('lang');
  7. global $app;
  8. $userMaxCount = data('properties.user.value');
  9. $userCount = $app->control->dao->select("COUNT('*') as count")->from(TABLE_USER)->where('deleted')->eq(0)->fetch('count');
  10. $checkWhenSubmit = jsCallback()
  11. ->const('userCount', $userCount)
  12. ->const('userMaxCount', $userMaxCount)
  13. ->const('noticeUserCreate', str_replace('%maxcount%', $userMaxCount, $lang->user->noticeUserCreate))
  14. ->do(<<<'JS'
  15. var allUserCount = parseInt(userCount);
  16. $('[data-name=account]').find('input').each(function(){
  17. if($(this).val().length > 0) allUserCount += 1;
  18. });
  19. if(allUserCount > userMaxCount)
  20. {
  21. zui.Modal.alert(noticeUserCreate.replace('%usercount%', allUserCount));
  22. return false;
  23. }
  24. JS
  25. );
  26. query('.form-actions .btn.primary')->on('click', $checkWhenSubmit);
  27. query('.form-actions .btn.primary')->append(''); // 删掉之后query->on('click')无法初始化,zui-init属性为空,不可删除
  28. }