Commit 576e8c450f7312a027b4a7f2bf7f631ba87474c4
1 parent
e9c1bcf3
change request to massage
Showing
2 changed files
with
26 additions
and
4 deletions
Show diff stats
src/app/frontend/controllers/EventsController.php
@@ -285,13 +285,27 @@ class EventsController extends \Phalcon\Mvc\Controller | @@ -285,13 +285,27 @@ class EventsController extends \Phalcon\Mvc\Controller | ||
285 | if($customer instanceof \customersEmailList){ | 285 | if($customer instanceof \customersEmailList){ |
286 | 286 | ||
287 | } else { | 287 | } else { |
288 | + $data = \seriesOfLetters::find("project_id ={$user['project_id']} "); | ||
288 | $this->customers_model->save($user); | 289 | $this->customers_model->save($user); |
289 | - $days = 10; | ||
290 | - for($i=1; $i<$days; $i++){ | ||
291 | - $date = $this->getEventDate("+". $i*7 ." days"); | ||
292 | - } | 290 | + foreach($data as $row){ |
291 | + | ||
292 | + $letters = explode(',',$row->letters); | ||
293 | 293 | ||
294 | 294 | ||
295 | + $days = count($letters); | ||
296 | + for($i=0; $i<$days; $i++){ | ||
297 | + $date = $this->getEventDate("+". ($i+1)*$row->period_val ." days"); | ||
298 | + $event = new \eventInfo(); | ||
299 | + $event->customer_id = $this->customers_model->id; | ||
300 | + $event->event_id = $letters[$i]; | ||
301 | + $event->next_delivery = $date; | ||
302 | + $event->project_id = $user['project_id']; | ||
303 | + $event->event_trigger = 'series_of_letter'; | ||
304 | + $event->save(); | ||
305 | + } | ||
306 | + | ||
307 | + } | ||
308 | + | ||
295 | } | 309 | } |
296 | 310 | ||
297 | } | 311 | } |
@@ -320,6 +334,7 @@ class EventsController extends \Phalcon\Mvc\Controller | @@ -320,6 +334,7 @@ class EventsController extends \Phalcon\Mvc\Controller | ||
320 | if(isset($this->post['event_type'])){ | 334 | if(isset($this->post['event_type'])){ |
321 | switch ($this->post['event_type']) { | 335 | switch ($this->post['event_type']) { |
322 | case 'add_subscribe': | 336 | case 'add_subscribe': |
337 | + | ||
323 | $this->subscribeNewCustomer(); | 338 | $this->subscribeNewCustomer(); |
324 | 339 | ||
325 | 340 |
src/lib/models/eventInfo.php
@@ -2,10 +2,17 @@ | @@ -2,10 +2,17 @@ | ||
2 | 2 | ||
3 | class eventInfo extends \Phalcon\Mvc\Model | 3 | class eventInfo extends \Phalcon\Mvc\Model |
4 | { | 4 | { |
5 | + public $customer_id; | ||
6 | + public $event_id; | ||
7 | + public $project_id; | ||
8 | + public $last_delivery; | ||
9 | + public $next_delivery; | ||
10 | + public $event_trigger; | ||
5 | 11 | ||
6 | public function getSource() | 12 | public function getSource() |
7 | { | 13 | { |
8 | return "event_info"; | 14 | return "event_info"; |
9 | } | 15 | } |
10 | 16 | ||
17 | + | ||
11 | } | 18 | } |
12 | \ No newline at end of file | 19 | \ No newline at end of file |