CustomersEmailController.php
2.31 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
<?php
namespace controllers;
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
class CustomersEmailController extends \Phalcon\Mvc\Controller
{
public function initialize()
{
$this->view->setTemplateAfter('common');
}
function indexAction()
{
//Check if the user has uploaded files
if ($this->request->hasFiles() == true) {
//Print the real file names and their sizes
foreach ($this->request->getUploadedFiles() as $file){
//Move the file into the application
$route = STORAGE_PATH.'temp/'.$file->getName();
$file->moveTo($route);
}
$this->ServiceExcel->addFile($route);
$result = $this->ServiceExcel->getRows();
foreach($result as $row){
$model = new \customersEmailList();
$model->customers_id = $row[0];
$model->email = $row[1];
$model->name = $row[2];
$model->project_id = $this->session->get('project-id');
$model->save();
if(isset($model->id)){
$event_model = new \eventEmail();
$event_info = new \eventInfo();
$data = $event_model::findFirst("name = 'welcome_letter' AND email_type = 'event' AND project_id = {$this->session->get('project-id')} ");
$template = $data->emailTemplates;
$template->text = $this->UTMParser->parse($data->toArray(), $template->toArray());
$this->MyMailer->SendForSelect($template, array($model->toArray()));
$event_info->event_id = $data->id;
$event_info->customer_id = $model->id;
$event_info->project_id = $this->session->get('project-id');
$event_info->save();
}
}
}
}
public function getUsersLikeAction()
{
$like = $this->request->getPost('like', 'string', NULL );
$users = $this->models->getCustomers()->getActiveUsers($like);
$result = json_encode($users);
$this->view->disableLevel(\Phalcon\Mvc\View::LEVEL_MAIN_LAYOUT);
echo $result;
}
}