ProgramList.php
2.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
<?php
namespace app\index\controller;
use app\common\controller\Frontend;
use app\expert\model\ProjectRegister;
use app\index\model\ItemDelay;
use think\Exception;
class ProgramList extends Frontend
{
protected $noNeedLogin = [];
protected $noNeedRight = '*';
protected $layout = 'default';
protected $model = null;
CONST PARAMS_ERROR = '参数错误';
CONST BAD_REQUEST = '非法请求';
CONST NOT_FOUND = '作品不存在';
CONST DELAY_APPLY = '您已申请项目延期';
public function _initialize()
{
parent::_initialize();
$this->model = new ProjectRegister();
$this->assign('index','index');
}
public function index()
{
// 查询学生报名的作品
$_list = $this->model->alias('r')
->field('r.* , pc.container_name , pt.name , pc.midterm_review_starttime, pc.midterm_review_endtime,pc.conclusion_starttime,pc.conclusion_endtime,
pc.project_starttime,pc.project_endtime,pc.project_double_starttime,pc.project_double_endtime,
pc.can_apply_mid,pc.can_apply_conclusion,pc.can_apply_approval,count(pd.id) as pd_count')
->join('project_container pc','pc.id = r.container_id','left')
->join('project_type pt','pt.id=r.project_type','left')
->join('project_delay pd','pd.register_id=r.id','left')
->where('r.user_id',$this->auth->id)->group('r.id')->paginate(1);
$_list_count = $this->model
->where('user_id',$this->auth->id)->count();
$this->assign('_list',$_list);
$this->assign('_list_count',$_list_count);
return $this->view->fetch();
}
// 项目延期申请
public function subject_delay(){
if (!request()->post()) $this->error(self::BAD_REQUEST);
$item_id = request()->param('item_id',false);
$delay_memo = request()->param('delay_memo',null);
if (!$item_id) $this->error(self::PARAMS_ERROR);
$item = $this->model->where('id',$item_id)->find();
if (!$item) $this->error(self::NOT_FOUND);
$_delay = ItemDelay::get(['register_id'=>$item_id]);
if ($_delay){
$this->error(self::DELAY_APPLY);
}
$created['register_id'] = $item_id;
$created['delay_memo'] = $delay_memo;
try {
ItemDelay::create($created);
}catch (Exception $e){
$this->error($e->getMessage());
}
$this->success("申请项目延期成功");
}
}