e22db2b7
Administrator
change request to...
|
1
2
3
4
5
6
|
<?php
namespace controllers;
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
92ff9978
Administrator
change request to...
|
7
|
class SeriesOfLettersController extends \Phalcon\Mvc\Controller
|
e22db2b7
Administrator
change request to...
|
8
9
10
11
12
13
14
|
{
public function initialize()
{
$this->view->setTemplateAfter('common');
}
public function indexAction(){
|
148776ae
Administrator
change request to...
|
15
|
|
b4efc94e
Administrator
change request to...
|
16
|
$data = \seriesOfLetters::find();
|
e22db2b7
Administrator
change request to...
|
17
18
|
$this->view->setVars([
|
b4efc94e
Administrator
change request to...
|
19
|
'data' => $data
|
e22db2b7
Administrator
change request to...
|
20
21
|
]);
}
|
466ec818
Administrator
change request to...
|
22
|
|
62ff66e4
Administrator
change request to...
|
23
|
|
466ec818
Administrator
change request to...
|
24
|
public function addAction(){
|
a9859077
Administrator
change request to...
|
25
26
|
if( $this->request->isPost() )
{
|
62ff66e4
Administrator
change request to...
|
27
|
|
a9859077
Administrator
change request to...
|
28
29
30
31
|
$data['project_id'] = $this->session->get('project-id');
$data['name'] = $this->request->getPost('name', 'string', NULL );
$data['status'] = $this->request->getPost('status')?$this->request->getPost('status'):0 ;
$data['event'] = $this->request->getPost('event' );
|
9f70333e
Administrator
change request to...
|
32
|
$data['period_val'] = $this->request->getPost('period_val' );
|
62ff66e4
Administrator
change request to...
|
33
|
$data['first_delivery'] = $this->request->getPost('first_delivery' );
|
9f70333e
Administrator
change request to...
|
34
|
$data['letters'] = implode(',',$data['event']);
|
511d3910
Administrator
change request to...
|
35
|
|
1b99d6c3
Administrator
change request to...
|
36
|
$model = new \seriesOfLetters();
|
9f70333e
Administrator
change request to...
|
37
|
if( !empty( $data['name'] ))
|
a9859077
Administrator
change request to...
|
38
39
40
41
|
{
if( $model->save( $data ) )
{
$this->flash->success( 'Сохранение прошло успешно' );
|
9f70333e
Administrator
change request to...
|
42
|
return $this->response->redirect('series_of_letters/index');
|
a9859077
Administrator
change request to...
|
43
44
45
46
47
48
49
|
}
else
{
$this->flash->error( 'Произошла ошибка во время добавления.' );
}
}
}
|
43d8495a
Administrator
change request to...
|
50
|
$this->view->pick( 'series_of_letters/addEdit' );
|
466ec818
Administrator
change request to...
|
51
|
$this->view->setVars([
|
62ff66e4
Administrator
change request to...
|
52
53
|
'page' => new \seriesOfLetters(),
'events' => []
|
466ec818
Administrator
change request to...
|
54
55
56
57
58
|
]);
}
public function deleteAction($id){
|
0a91a190
Administrator
change request to...
|
59
60
|
$data = \seriesOfLetters::find("id=$id AND project_id ={$this->session->get('project-id')} ");
$data->delete();
|
466ec818
Administrator
change request to...
|
61
62
63
64
65
|
$this->view->setVars([
'data' => $data
]);
}
|
0a91a190
Administrator
change request to...
|
66
|
public function updateAction($id){
|
62ff66e4
Administrator
change request to...
|
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
|
$model = \seriesOfLetters::findFirst("id=$id AND project_id ={$this->session->get('project-id')} ");
if( $this->request->isPost() )
{
$data['project_id'] = $this->session->get('project-id');
$data['name'] = $this->request->getPost('name', 'string', NULL );
$data['status'] = $this->request->getPost('status')?$this->request->getPost('status'):0 ;
$data['event'] = $this->request->getPost('event' );
$data['period_val'] = $this->request->getPost('period_val' );
$data['first_delivery'] = $this->request->getPost('first_delivery' );
$data['letters'] = implode(',',$data['event']);
if( !empty( $data['name'] ))
{
if( $model->save( $data ) )
{
$this->flash->success( 'Сохранение прошло успешно' );
return $this->response->redirect('series_of_letters/index');
}
else
{
$this->flash->error( 'Произошла ошибка во время добавления.' );
}
}
}
$events = \eventEmail::find("id IN ('".implode("','", explode(',',$model->letters))."') ");
$this->view->pick( 'series_of_letters/addEdit' );
$this->view->setVars([
'page' => $model,
'events' => $events
]);
|
466ec818
Administrator
change request to...
|
101
|
}
|
4081157a
Administrator
change request to...
|
102
103
|
public function getTemplateAction()
|
3ac99d6b
Administrator
change request to...
|
104
|
{
|
4081157a
Administrator
change request to...
|
105
106
|
$this->view->setTemplateAfter('none');
$like = $this->request->getPost('like', 'string', NULL );
|
3ac99d6b
Administrator
change request to...
|
107
108
|
$users = \eventEmail::find(array(
"name LIKE '%$like%' AND project_id = {$this->session->get('project-id')}"
|
4081157a
Administrator
change request to...
|
109
110
111
112
113
|
));
$result = json_encode($users->toArray());
$this->view->disableLevel(\Phalcon\Mvc\View::LEVEL_MAIN_LAYOUT);
echo $result;
}
|
e22db2b7
Administrator
change request to...
|
114
|
}
|