| 15670 |
anderson |
1 |
<?php
|
|
|
2 |
|
|
|
3 |
declare(strict_types=1);
|
|
|
4 |
|
|
|
5 |
namespace LeadersLinked\Controller;
|
|
|
6 |
|
| 15682 |
anderson |
7 |
use Laminas\View\Model\JsonModel;
|
|
|
8 |
use Laminas\View\Model\ViewModel;
|
|
|
9 |
use LeadersLinked\Mapper\DiscoveryContactLogMapper;
|
| 15670 |
anderson |
10 |
use Laminas\Mvc\Controller\AbstractActionController;
|
|
|
11 |
|
|
|
12 |
// Create an action controller.
|
|
|
13 |
class DiscoveryContactProgressController extends AbstractActionController
|
|
|
14 |
{
|
| 15682 |
anderson |
15 |
/**
|
|
|
16 |
*
|
|
|
17 |
* @var AdapterInterface
|
|
|
18 |
*/
|
|
|
19 |
private $adapter;
|
|
|
20 |
|
|
|
21 |
|
|
|
22 |
/**
|
|
|
23 |
*
|
|
|
24 |
* @var AbstractAdapter
|
|
|
25 |
*/
|
|
|
26 |
private $cache;
|
|
|
27 |
|
|
|
28 |
/**
|
|
|
29 |
*
|
|
|
30 |
* @var LoggerInterface
|
|
|
31 |
*/
|
|
|
32 |
private $logger;
|
|
|
33 |
|
|
|
34 |
/**
|
|
|
35 |
*
|
|
|
36 |
* @var array
|
|
|
37 |
*/
|
|
|
38 |
private $config;
|
|
|
39 |
|
|
|
40 |
/**
|
|
|
41 |
*
|
|
|
42 |
* @param AdapterInterface $adapter
|
|
|
43 |
* @param AbstractAdapter $cache
|
|
|
44 |
* @param LoggerInterface $logger
|
|
|
45 |
* @param array $config
|
|
|
46 |
*/
|
|
|
47 |
public function __construct($adapter, $cache, $logger, $config)
|
|
|
48 |
{
|
|
|
49 |
$this->adapter = $adapter;
|
|
|
50 |
$this->cache = $cache;
|
|
|
51 |
$this->logger = $logger;
|
|
|
52 |
$this->config = $config;
|
|
|
53 |
}
|
|
|
54 |
|
| 15670 |
anderson |
55 |
// Define an action "world".
|
|
|
56 |
public function indexAction()
|
|
|
57 |
{
|
| 15674 |
anderson |
58 |
$currentUserPlugin = $this->plugin('currentUserPlugin');
|
|
|
59 |
$currentUser = $currentUserPlugin->getUser();
|
|
|
60 |
$currentCompany = $currentUserPlugin->getCompany();
|
| 15670 |
anderson |
61 |
|
| 15674 |
anderson |
62 |
$request = $this->getRequest();
|
|
|
63 |
if ($request->isGet()) {
|
| 15677 |
anderson |
64 |
$headers = $request->getHeaders();
|
|
|
65 |
$isJson = false;
|
| 15678 |
anderson |
66 |
|
| 15680 |
anderson |
67 |
if ($headers->has('Accept')) {
|
|
|
68 |
$accept = $headers->get('Accept');
|
|
|
69 |
$prioritized = $accept->getPrioritized();
|
| 15679 |
anderson |
70 |
|
| 15680 |
anderson |
71 |
foreach ($prioritized as $key => $value) {
|
|
|
72 |
$raw = trim($value->getRaw());
|
| 15679 |
anderson |
73 |
|
| 15680 |
anderson |
74 |
if (!$isJson) {
|
|
|
75 |
$isJson = strpos($raw, 'json');
|
|
|
76 |
}
|
| 15679 |
anderson |
77 |
}
|
|
|
78 |
}
|
|
|
79 |
|
| 15681 |
anderson |
80 |
if ($isJson) {
|
| 15690 |
anderson |
81 |
// $search = $this->params()->fromQuery('search');
|
|
|
82 |
// $search = empty($search['value']) ? '' : filter_var($search['value'], FILTER_SANITIZE_STRING);
|
|
|
83 |
// $page = intval($this->params()->fromQuery('start', 1), 10);
|
|
|
84 |
// $records_x_page = intval($this->params()->fromQuery('length', 10), 10);
|
|
|
85 |
// $order = $this->params()->fromQuery('order', []);
|
|
|
86 |
// $order_field = empty($order[0]['column']) ? 99 : intval($order[0]['column'], 10);
|
|
|
87 |
// $order_direction = empty($order[0]['dir']) ? 'ASC' : strtoupper(filter_var($order[0]['dir'], FILTER_SANITIZE_STRING));
|
|
|
88 |
// $fields = ['first_name', 'last_name', 'corporate_email', 'activity'];
|
|
|
89 |
// $order_field = isset($fields[$order_field]) ? $fields[$order_field] : 'first_name';
|
| 15682 |
anderson |
90 |
|
| 15690 |
anderson |
91 |
// if (!in_array($order_direction, ['ASC', 'DESC'])) {
|
|
|
92 |
// $order_direction = 'ASC';
|
|
|
93 |
// }
|
| 15682 |
anderson |
94 |
|
| 15687 |
anderson |
95 |
|
| 15690 |
anderson |
96 |
// //Quede aqui en el mapper
|
|
|
97 |
// $discoveryContactMapper = DiscoveryContactLogMapper::getInstance($this->adapter);
|
|
|
98 |
// $paginator = $discoveryContactMapper->fetchAllDataTableForCompanyIdAndContactId($currentCompany->id, $currentUser->id, $page, $records_x_page);
|
|
|
99 |
// return new JsonModel([
|
|
|
100 |
// 'success' => true,
|
|
|
101 |
// 'paginator' => $paginator
|
|
|
102 |
// ]);
|
| 15681 |
anderson |
103 |
} else {
|
|
|
104 |
}
|
| 15679 |
anderson |
105 |
|
| 15681 |
anderson |
106 |
|
| 15689 |
anderson |
107 |
// return new JsonModel([
|
|
|
108 |
// 'success' => true,
|
|
|
109 |
// 'message' => $currentUser
|
|
|
110 |
// ]);
|
| 15675 |
anderson |
111 |
}
|
| 15690 |
anderson |
112 |
$search = $this->params()->fromQuery('search');
|
|
|
113 |
$search = empty($search['value']) ? '' : filter_var($search['value'], FILTER_SANITIZE_STRING);
|
|
|
114 |
$page = intval($this->params()->fromQuery('start', 1), 10);
|
|
|
115 |
$records_x_page = intval($this->params()->fromQuery('length', 10), 10);
|
|
|
116 |
$order = $this->params()->fromQuery('order', []);
|
|
|
117 |
$order_field = empty($order[0]['column']) ? 99 : intval($order[0]['column'], 10);
|
|
|
118 |
$order_direction = empty($order[0]['dir']) ? 'ASC' : strtoupper(filter_var($order[0]['dir'], FILTER_SANITIZE_STRING));
|
|
|
119 |
$fields = ['first_name', 'last_name', 'corporate_email', 'activity'];
|
|
|
120 |
$order_field = isset($fields[$order_field]) ? $fields[$order_field] : 'first_name';
|
|
|
121 |
|
|
|
122 |
if (!in_array($order_direction, ['ASC', 'DESC'])) {
|
|
|
123 |
$order_direction = 'ASC';
|
|
|
124 |
}
|
|
|
125 |
|
|
|
126 |
|
|
|
127 |
//Quede aqui en el mapper
|
|
|
128 |
$discoveryContactMapper = DiscoveryContactLogMapper::getInstance($this->adapter);
|
|
|
129 |
$paginator = $discoveryContactMapper->fetchAllDataTableForCompanyIdAndContactId($currentCompany->id, $currentUser->id, $page, $records_x_page);
|
| 15673 |
anderson |
130 |
return new JsonModel([
|
|
|
131 |
'success' => true,
|
| 15690 |
anderson |
132 |
'paginator' => $paginator
|
| 15673 |
anderson |
133 |
]);
|
| 15690 |
anderson |
134 |
|
|
|
135 |
|
|
|
136 |
// return new JsonModel([
|
|
|
137 |
// 'success' => true,
|
|
|
138 |
// 'message' => $currentCompany->id
|
|
|
139 |
// ]);
|
| 15670 |
anderson |
140 |
}
|
|
|
141 |
}
|