job.ctrl.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. /**
  3. * [WeEngine System] Copyright (c) 2014 WE7.CC
  4. * WeEngine is NOT a free software, it under the license terms, visited http://www.we7.cc/ for more details.
  5. */
  6. defined('IN_IA') or exit('Access Denied');
  7. load()->model('job');
  8. $dos = array('clear', 'execute', 'display');
  9. $do = in_array($do, $dos) ? $do : 'display';
  10. if ($do == 'display') {
  11. $list = job_list($_W['uid'], $_W['isfounder']);
  12. $jobid = intval($_GPC['jobid']);
  13. if (is_array($list) && !empty($array)) {
  14. array_walk($list, function(&$item){
  15. $progress = $item['total'] > 0 ? $item['handled']/$item['total']*100 : 0;
  16. $item['progress'] = $item['status'] ? 100 : intval($progress);
  17. $item['createtime'] = date('Y-m-d H:i:s', $item['createtime']);
  18. $item['endtime'] = date('Y-m-d H:i:s', $item['endtime']);
  19. return $item;
  20. });
  21. }
  22. template('system/job');
  23. }
  24. if ($do == 'execute') {
  25. $id = intval($_GPC['id']);
  26. $job = job_single($id);
  27. if ($_W['isfounder'] || $job['uid'] == $_W['uid']) {
  28. $result = job_execute($id);
  29. if (is_error($result)) {
  30. iajax(1, $result['message']);
  31. }
  32. iajax(0, $result['message']);
  33. }
  34. }
  35. if ($do == 'clear') {
  36. $result = job_clear($uid, $_W['isfounder']);
  37. itoast(0, '清除成功', referer());
  38. }