| 15670 |
anderson |
1 |
<?php
|
|
|
2 |
|
|
|
3 |
declare(strict_types=1);
|
|
|
4 |
|
|
|
5 |
namespace LeadersLinked\Controller;
|
|
|
6 |
|
| 15718 |
anderson |
7 |
use LeadersLinked\Model\User;
|
| 15682 |
anderson |
8 |
use Laminas\View\Model\JsonModel;
|
|
|
9 |
use Laminas\View\Model\ViewModel;
|
| 15718 |
anderson |
10 |
use LeadersLinked\Mapper\UserMapper;
|
|
|
11 |
use LeadersLinked\Mapper\QueryMapper;
|
|
|
12 |
use LeadersLinked\Mapper\DiscoveryContactMapper;
|
| 15682 |
anderson |
13 |
use LeadersLinked\Mapper\DiscoveryContactLogMapper;
|
| 15670 |
anderson |
14 |
use Laminas\Mvc\Controller\AbstractActionController;
|
| 15727 |
anderson |
15 |
use Laminas\Hydrator\ArraySerializableHydrator;
|
|
|
16 |
use Laminas\Db\ResultSet\HydratingResultSet;
|
|
|
17 |
use Laminas\Paginator\Adapter\DbSelect;
|
|
|
18 |
use Laminas\Paginator\Paginator;
|
| 15732 |
anderson |
19 |
use LeadersLinked\Mapper\CompanyMapper;
|
| 15670 |
anderson |
20 |
|
|
|
21 |
// Create an action controller.
|
|
|
22 |
class DiscoveryContactProgressController extends AbstractActionController
|
|
|
23 |
{
|
| 15682 |
anderson |
24 |
/**
|
|
|
25 |
*
|
|
|
26 |
* @var AdapterInterface
|
|
|
27 |
*/
|
|
|
28 |
private $adapter;
|
|
|
29 |
|
|
|
30 |
|
|
|
31 |
/**
|
|
|
32 |
*
|
|
|
33 |
* @var AbstractAdapter
|
|
|
34 |
*/
|
|
|
35 |
private $cache;
|
|
|
36 |
|
|
|
37 |
/**
|
|
|
38 |
*
|
|
|
39 |
* @var LoggerInterface
|
|
|
40 |
*/
|
|
|
41 |
private $logger;
|
|
|
42 |
|
|
|
43 |
/**
|
|
|
44 |
*
|
|
|
45 |
* @var array
|
|
|
46 |
*/
|
|
|
47 |
private $config;
|
|
|
48 |
|
|
|
49 |
/**
|
|
|
50 |
*
|
|
|
51 |
* @param AdapterInterface $adapter
|
|
|
52 |
* @param AbstractAdapter $cache
|
|
|
53 |
* @param LoggerInterface $logger
|
|
|
54 |
* @param array $config
|
|
|
55 |
*/
|
|
|
56 |
public function __construct($adapter, $cache, $logger, $config)
|
|
|
57 |
{
|
|
|
58 |
$this->adapter = $adapter;
|
|
|
59 |
$this->cache = $cache;
|
|
|
60 |
$this->logger = $logger;
|
|
|
61 |
$this->config = $config;
|
|
|
62 |
}
|
|
|
63 |
|
| 15670 |
anderson |
64 |
|
| 15788 |
anderson |
65 |
// public function indexAction()
|
|
|
66 |
// {
|
|
|
67 |
// $currentUserPlugin = $this->plugin('currentUserPlugin');
|
|
|
68 |
// $currentUser = $currentUserPlugin->getUser();
|
|
|
69 |
// $currentCompany = $currentUserPlugin->getCompany();
|
| 15678 |
anderson |
70 |
|
| 15788 |
anderson |
71 |
// $request = $this->getRequest();
|
|
|
72 |
// if ($request->isGet()) {
|
|
|
73 |
// $headers = $request->getHeaders();
|
|
|
74 |
// $isJson = false;
|
| 15679 |
anderson |
75 |
|
| 15788 |
anderson |
76 |
// if ($headers->has('Accept')) {
|
|
|
77 |
// $accept = $headers->get('Accept');
|
|
|
78 |
// $prioritized = $accept->getPrioritized();
|
| 15679 |
anderson |
79 |
|
| 15788 |
anderson |
80 |
// foreach ($prioritized as $key => $value) {
|
|
|
81 |
// $raw = trim($value->getRaw());
|
| 15679 |
anderson |
82 |
|
| 15788 |
anderson |
83 |
// if (!$isJson) {
|
|
|
84 |
// $isJson = strpos($raw, 'json');
|
|
|
85 |
// }
|
|
|
86 |
// }
|
|
|
87 |
// }
|
| 15745 |
anderson |
88 |
|
| 15788 |
anderson |
89 |
// if ($isJson) {
|
| 15745 |
anderson |
90 |
|
| 15788 |
anderson |
91 |
// $data = [
|
|
|
92 |
// 'items' => [],
|
|
|
93 |
// 'total' => 0,
|
| 15745 |
anderson |
94 |
|
| 15788 |
anderson |
95 |
// ];
|
| 15682 |
anderson |
96 |
|
| 15788 |
anderson |
97 |
// $search = $this->params()->fromQuery('search');
|
|
|
98 |
// $search = empty($search['value']) ? '' : filter_var($search['value'], FILTER_SANITIZE_STRING);
|
|
|
99 |
// $page = intval($this->params()->fromQuery('start', 1), 10);
|
|
|
100 |
// $records_x_page = intval($this->params()->fromQuery('length', 10), 10);
|
|
|
101 |
// $order = $this->params()->fromQuery('order', []);
|
|
|
102 |
// $order_field = empty($order[0]['column']) ? 99 : intval($order[0]['column'], 10);
|
|
|
103 |
// $order_direction = empty($order[0]['dir']) ? 'ASC' : strtoupper(filter_var($order[0]['dir'], FILTER_SANITIZE_STRING));
|
|
|
104 |
// $fields = ['first_name', 'last_name', 'corporate_email', 'activity'];
|
|
|
105 |
// $order_field = isset($fields[$order_field]) ? $fields[$order_field] : 'first_name';
|
| 15682 |
anderson |
106 |
|
| 15788 |
anderson |
107 |
// if (!in_array($order_direction, ['ASC', 'DESC'])) {
|
|
|
108 |
// $order_direction = 'ASC';
|
|
|
109 |
// }
|
| 15687 |
anderson |
110 |
|
| 15717 |
anderson |
111 |
|
| 15788 |
anderson |
112 |
// //Quede aqui en el mapper
|
|
|
113 |
// $discoveryContactLogMapper = DiscoveryContactLogMapper::getInstance($this->adapter);
|
|
|
114 |
// $contactLogMappers = $discoveryContactLogMapper->fetchAll();
|
| 15785 |
anderson |
115 |
|
| 15788 |
anderson |
116 |
// $queryMapper = QueryMapper::getInstance($this->adapter);
|
|
|
117 |
// $sql = $queryMapper->getSql();
|
|
|
118 |
// $select = $sql->select();
|
|
|
119 |
// $select->columns(['user_id', 'activity', 'details', 'added_on']);
|
|
|
120 |
// $select->from(['tb1' => DiscoveryContactLogMapper::_TABLE], ['activity', 'details', 'added_on']);
|
|
|
121 |
// $select->join(['tb2' => UserMapper::_TABLE], 'tb1.user_id = tb2.id', ['uuid', 'first_name', 'last_name', 'email']);
|
|
|
122 |
// $select->join(['tb3' => CompanyMapper::_TABLE], 'tb1.company_id = tb3.id', ['name']);
|
| 15785 |
anderson |
123 |
|
| 15788 |
anderson |
124 |
// if ($search) {
|
|
|
125 |
// $select->where->nest()
|
|
|
126 |
// ->like('first_name', '%' . $search . '%')
|
|
|
127 |
// ->or->like('last_name', '%' . $search . '%')
|
|
|
128 |
// ->or->like('email', '%' . $search . '%')
|
|
|
129 |
// ->unnest();
|
|
|
130 |
// }
|
| 15727 |
anderson |
131 |
|
| 15788 |
anderson |
132 |
// $select->order($order_field . ' ' . $order_direction);
|
|
|
133 |
// $hydrator = new ArraySerializableHydrator();
|
|
|
134 |
// $resultset = new HydratingResultSet($hydrator);
|
|
|
135 |
// $adapter = new DbSelect($select, $sql, $resultset);
|
|
|
136 |
// $paginator = new Paginator($adapter);
|
|
|
137 |
// $paginator->setItemCountPerPage($records_x_page);
|
|
|
138 |
// $paginator->setCurrentPageNumber($page);
|
| 15782 |
anderson |
139 |
|
| 15727 |
anderson |
140 |
|
| 15788 |
anderson |
141 |
// $items = [];
|
|
|
142 |
// $records = $paginator->getCurrentItems();
|
|
|
143 |
// foreach ($records as $record) {
|
| 15727 |
anderson |
144 |
|
| 15788 |
anderson |
145 |
// $dt_added_on = \DateTime::createFromFormat('Y-m-d H:i:s', $record['added_on']);
|
|
|
146 |
// $added_on = $dt_added_on->format('d/m/Y h:i a');
|
|
|
147 |
// $item = [
|
|
|
148 |
// 'uuid' => $record['uuid'],
|
|
|
149 |
// 'first_name' => ucwords(strtolower($record['first_name'])),
|
|
|
150 |
// 'last_name' => ucwords(strtolower($record['last_name'])),
|
|
|
151 |
// 'email' => strtolower($record['email']),
|
|
|
152 |
// 'company' => $record['name'],
|
|
|
153 |
// 'activity' => $record['activity'],
|
|
|
154 |
// 'details' => $record['details'],
|
|
|
155 |
// 'added_on' => $added_on,
|
|
|
156 |
// ];
|
| 15727 |
anderson |
157 |
|
| 15733 |
anderson |
158 |
|
| 15788 |
anderson |
159 |
// array_push($items, $item);
|
|
|
160 |
// }
|
| 15733 |
anderson |
161 |
|
| 15788 |
anderson |
162 |
// $data['items'] = $items;
|
|
|
163 |
// $data['total'] = $paginator->getTotalItemCount();
|
| 15733 |
anderson |
164 |
|
| 15788 |
anderson |
165 |
// return new JsonModel([
|
|
|
166 |
// 'success' => true,
|
|
|
167 |
// 'data' => $data
|
|
|
168 |
// ]);
|
|
|
169 |
// } else {
|
|
|
170 |
// $this->layout()->setTemplate('layout/layout-backend');
|
|
|
171 |
// $viewModel = new ViewModel();
|
|
|
172 |
// $viewModel->setTemplate('leaders-linked/discovery-contact-progress/index.phtml');
|
|
|
173 |
// return $viewModel;
|
|
|
174 |
// return new JsonModel([
|
|
|
175 |
// 'success' => true,
|
|
|
176 |
// 'message' => $currentCompany->id
|
|
|
177 |
// ]);
|
|
|
178 |
// }
|
|
|
179 |
// }
|
|
|
180 |
// }
|
| 15745 |
anderson |
181 |
|
| 15788 |
anderson |
182 |
public function indexAction()
|
|
|
183 |
{
|
|
|
184 |
$data = [
|
|
|
185 |
'success' => true,
|
|
|
186 |
'message' => 'Hola desde controlador de progreso diario',
|
| 15746 |
anderson |
187 |
|
| 15788 |
anderson |
188 |
];
|
| 15670 |
anderson |
189 |
}
|
|
|
190 |
}
|