Proyectos de Subversion LeadersLinked - Backend

Rev

Rev 16629 | Rev 16766 | Ir a la última revisión | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 16629 Rev 16758
Línea 2... Línea 2...
2
 
2
 
Línea 3... Línea 3...
3
declare(strict_types=1);
3
declare(strict_types=1);
Línea -... Línea 4...
-
 
4
 
-
 
5
namespace LeadersLinked\Controller;
-
 
6
 
-
 
7
 
4
 
8
use Laminas\Db\Adapter\AdapterInterface;
-
 
9
use Laminas\Cache\Storage\Adapter\AbstractAdapter;
-
 
10
use Laminas\Mvc\Controller\AbstractActionController;
5
namespace LeadersLinked\Controller;
11
use Laminas\Log\LoggerInterface;
6
 
12
use Laminas\Mvc\I18n\Translator;
7
use LeadersLinked\Model\User;
13
 
8
use Laminas\View\Model\JsonModel;
14
use Laminas\View\Model\JsonModel;
9
use Laminas\View\Model\ViewModel;
15
use Laminas\View\Model\ViewModel;
10
use LeadersLinked\Mapper\UserMapper;
-
 
11
use LeadersLinked\Mapper\QueryMapper;
-
 
12
use LeadersLinked\Mapper\DiscoveryContactMapper;
-
 
13
use LeadersLinked\Mapper\DiscoveryContactLogMapper;
16
use LeadersLinked\Mapper\UserMapper;
14
use Laminas\Mvc\Controller\AbstractActionController;
-
 
15
use Laminas\Hydrator\ArraySerializableHydrator;
17
use LeadersLinked\Mapper\QueryMapper;
16
use Laminas\Db\ResultSet\HydratingResultSet;
18
use LeadersLinked\Mapper\DiscoveryContactMapper;
17
use Laminas\Paginator\Adapter\DbSelect;
19
use Laminas\Db\Sql\Expression;
18
use Laminas\Paginator\Paginator;
20
use LeadersLinked\Mapper\DiscoveryContactInteractionMapper;
-
 
21
use LeadersLinked\Mapper\DiscoveryContactInteractionTypeMapper;
Línea 19... Línea 22...
19
use LeadersLinked\Mapper\CompanyMapper;
22
use PhpOffice\PhpSpreadsheet\IOFactory;
20
use LeadersLinked\Model\DiscoveryContactLog;
23
use PhpOffice\PhpSpreadsheet\Spreadsheet;
21
use LeadersLinked\Model\Push;
24
 
22
 
25
 
23
// Create an action controller.
26
// Create an action controller.
24
class DiscoveryContactProgressController extends AbstractActionController
27
class DiscoveryContactProgressController extends AbstractActionController
25
{
28
{
26
    /**
29
    /**
27
     *
30
     *
28
     * @var AdapterInterface
31
     * @var AdapterInterface
29
     */
32
     */
30
    private $adapter;
33
    private $adapter;
31
 
34
    
32
 
35
    
33
    /**
36
    /**
34
     *
37
     *
35
     * @var AbstractAdapter
38
     * @var AbstractAdapter
36
     */
39
     */
37
    private $cache;
40
    private $cache;
38
 
41
    
39
    /**
42
    /**
40
     *
43
     *
41
     * @var  LoggerInterface
44
     * @var  LoggerInterface
42
     */
45
     */
43
    private $logger;
46
    private $logger;
44
 
47
    
45
    /**
48
    /**
46
     *
49
     *
-
 
50
     * @var array
-
 
51
     */
-
 
52
    private $config;
-
 
53
    
-
 
54
    /**
-
 
55
     *
47
     * @var array
56
     * @var Translator
48
     */
57
     */
49
    private $config;
58
    private $translator;
50
 
59
    
51
    /**
60
    /**
52
     *
61
     *
-
 
62
     * @param AdapterInterface $adapter
53
     * @param AdapterInterface $adapter
63
     * @param AbstractAdapter $cache
54
     * @param AbstractAdapter $cache
64
     * @param LoggerInterface $logger
55
     * @param LoggerInterface $logger
65
     * @param array $config
56
     * @param array $config
66
     * @param Translator $translator;
57
     */
67
     */
58
    public function __construct($adapter, $cache, $logger, $config)
68
    public function __construct($adapter, $cache, $logger, $config, $translator)
59
    {
69
    {
-
 
70
        $this->adapter      = $adapter;
60
        $this->adapter      = $adapter;
71
        $this->cache        = $cache;
Línea 61... Línea 72...
61
        $this->cache        = $cache;
72
        $this->logger       = $logger;
62
        $this->logger       = $logger;
73
        $this->config       = $config;
63
        $this->config       = $config;
74
        $this->translator   = $translator;
64
    }
75
    }
65
 
-
 
66
 
-
 
67
 
-
 
68
 
-
 
Línea -... Línea 76...
-
 
76
 
Línea 69... Línea 77...
69
    public function indexAction()
77
 
70
    {
78
 
71
        $currentUserPlugin = $this->plugin('currentUserPlugin');
79
 
Línea 91... Línea 99...
91
                    if (!$isJson) {
99
                    if (!$isJson) {
92
                        $isJson = strpos($raw, 'json');
100
                        $isJson = strpos($raw, 'json');
93
                    }
101
                    }
94
                }
102
                }
95
            }
103
            }
-
 
104
           
-
 
105
            
96
            //Anderson
106
            //$isJson =  true;
97
            if ($isJson) {
107
            if ($isJson) {
Línea 98... Línea 108...
98
 
108
 
99
                $startDate = $this->params()->fromQuery('startDate');
109
                $startDate = $this->params()->fromQuery('startDate');
100
                if (empty($startDate)) {
110
                if (empty($startDate)) {
Línea 103... Línea 113...
103
 
113
 
104
                $endDate = $this->params()->fromQuery('endDate');
114
                $endDate = $this->params()->fromQuery('endDate');
105
                if (empty($endDate)) {
115
                if (empty($endDate)) {
106
                    $endDate = date('Y-m-d');
116
                    $endDate = date('Y-m-d');
107
                }
117
                }
108
 
-
 
109
                $startDate = '2023-01-01';
-
 
110
                $endDate = '2023-12-31';
-
 
111
 
118
                
112
                $dtStartDate = \DateTime::createFromFormat('Y-n-d', $startDate);
119
                $dtStartDate = \DateTime::createFromFormat('Y-n-d', $startDate);
-
 
120
                $dtEndDate = \DateTime::createFromFormat('Y-n-d', $endDate);
-
 
121
                
Línea 113... Línea 122...
113
                $dtEndDate = \DateTime::createFromFormat('Y-n-d', $endDate);
122
 
114
 
123
 
115
                if (!$dtStartDate || !$dtEndDate) {
124
                if (!$dtStartDate || !$dtEndDate) {
116
                    $startDate = date('Y-m-d');
125
                    $startDate = date('Y-m-d');
Línea 117... Línea 126...
117
                    $endDate = date('Y-m-d');
126
                    $endDate = date('Y-m-d');
118
                } else {
127
                } else {
119
 
128
 
120
                    if ($dtStartDate->getTimestamp() > $dtEndDate->getTimestamp()) {
129
                    if ($dtStartDate->getTimestamp() > $dtEndDate->getTimestamp()) {
-
 
130
                        $startDate = date('Y-m-d');
121
                        $startDate = date('Y-m-d');
131
                        $endDate = date('Y-m-d');
-
 
132
                    }
-
 
133
                    
-
 
134
                }
-
 
135
                
-
 
136
                //echo ' $startDate  = ' .  $startDate  . ' $endDate = ' . $endDate; exit;
-
 
137
                
-
 
138
                $graph = [];
-
 
139
                
-
 
140
 
-
 
141
                $dt = \DateTime::createFromFormat('Y-m-d', $startDate);
-
 
142
                
-
 
143
                do {
-
 
144
                    $tempDate = $dt->format('Y-m-d');
-
 
145
                    $graph[ $tempDate ] = ['label' => $dt->format('d/m/Y'), 'value' => 0];
-
 
146
                    $dt->add(new \DateInterval('P1D'));
-
 
147
                     
-
 
148
                    
-
 
149
                } while($endDate > $tempDate);
-
 
150
                
-
 
151
                
-
 
152
                $queryMapper = QueryMapper::getInstance($this->adapter);
-
 
153
                
-
 
154
                /*
-
 
155
                select count(*) as cant, date(added_on) as date from tbl_discovery_contacts
-
 
156
                where date(added_on) BETWEEN '2023-05-05' AND '2023-05-31'
-
 
157
                group by date(added_on)
-
 
158
                order by date ASC
-
 
159
                 */
-
 
160
                
-
 
161
                $select = $queryMapper->getSql()->select(DiscoveryContactMapper::_TABLE);
-
 
162
                $select->columns([
-
 
163
                    'total' => new Expression('COUNT(*)'),
-
 
164
                    'date' => new Expression('DATE(added_on)'),
-
 
165
                ]);
-
 
166
                $select->where->between( new Expression('DATE(added_on)') , $startDate,  $endDate);
-
 
167
                $select->group(new Expression('DATE(added_on)'));
-
 
168
                $select->order('date ASC');
-
 
169
                
Línea 122... Línea 170...
122
                        $endDate = date('Y-m-d');
170
                $records = $queryMapper->fetchAll($select);
-
 
171
                foreach($records as $record)
-
 
172
                {
123
                    }
173
 
124
                }
174
                    $graph[ $record['date']  ][ 'value' ] = $record['total']; 
125
 
175
                }
-
 
176
                
126
                $contactProgressRecordMapper = DiscoveryContactLogMapper::getInstance($this->adapter);
177
                $discoveryContactInteractionTypeMapper = DiscoveryContactInteractionTypeMapper::getInstance($this->adapter);
127
                $dailyProgress = $contactProgressRecordMapper->fetchAllDataByDateRange($currentUser->id, $startDate, $endDate);
178
                $discoveryContactInteractionType =  $discoveryContactInteractionTypeMapper->fetchOneDefaultByCompanyId($currentCompany->id);
128
                $dateByRage = $contactProgressRecordMapper->anderson($startDate, $endDate);
179
                if(!$discoveryContactInteractionType) {
-
 
180
                    $discoveryContactInteractionType = $discoveryContactInteractionTypeMapper->fetchOneFirstActiveByCompanyId($currentCompany->id);
-
 
181
                }
-
 
182
                
129
                $items = [];
183
                
-
 
184
                /*
-
 
185
                  select count(*), user_id, date(added_on) as date from tbl_discovery_contact_interactions
-
 
186
                where interaction_type_id = 1 and date(added_on) BETWEEN '2023-05-05' AND '2023-05-31'
-
 
187
                group by date(added_on), user_id
-
 
188
                order by date
130
                $i = 0;
189
                */
131
 
190
                
132
 
191
                $table = [];
133
                foreach ($dateByRage as $key => $value) {
192
                $select = $queryMapper->getSql()->select(DiscoveryContactInteractionMapper::_TABLE);
-
 
193
                $select->columns([
134
                    setlocale(LC_TIME, "es_ES");
194
                    'user_id',
135
                    setlocale(LC_TIME, 'es_ES.UTF-8');
195
                    'total' => new Expression('COUNT(*)'),
136
                    $userOne = UserMapper::getInstance($this->adapter);
196
                    'date' => new Expression('DATE(added_on)'),
137
                    $users = $userOne->fetchOne($value['user_id']);
197
                ]);
-
 
198
                $select->where->equalTo('interaction_type_id', $discoveryContactInteractionType->id);
138
                    $added_on = strtoupper(date("d/F", strtotime($value['date'])));
199
                $select->where->between( new Expression('DATE(added_on)') , $startDate,  $endDate);
139
                    $items[$i]["month"] = $added_on;
200
                $select->group([ new Expression('DATE(added_on)'), 'user_id']);
140
                    $items[$i]["users"] = $users->first_name . ' ' . $users->last_name;
201
                $select->order('date ASC');
-
 
202
                
-
 
203
                $records = $queryMapper->fetchAll($select);
-
 
204
                foreach($records as $record)
141
                    $items[$i]["total"] = $value['total'];
205
                {
142
                    $items[$i]["users_id"] = $users->id;
206
                    $user_id =  $record['user_id'];
-
 
207
                    
-
 
208
                    if(!isset( $table[ $user_id  ])) {
-
 
209
                        
143
                    $i++;
210
                        $items = [];
-
 
211
                        
-
 
212
                        $dt = \DateTime::createFromFormat('Y-m-d', $startDate);
-
 
213
                        
-
 
214
                        do {
-
 
215
                            $tempDate = $dt->format('Y-m-d');
-
 
216
                            $items[ $tempDate ] = ['label' => $dt->format('d/m/Y'), 'value' => 0];
-
 
217
                            $dt->add(new \DateInterval('P1D'));
-
 
218
                            
144
                }
219
                            
145
 
220
                        } while($endDate > $tempDate);
146
                // var_dump($items);
221
                        
-
 
222
                        $table[ $user_id  ] = $items;
147
                // die();
223
                       
-
 
224
                        
148
 
225
                    }
149
 
226
                    
150
                //var_dump($ander);
227
                    
151
 
228
                    $table[ $user_id ][ $record['date'] ]['value'] = $record['total'];
152
                //die();
229
                }
153
 
230
                
-
 
231
                $records = array_values($graph);
-
 
232
                
-
 
233
                $labels = [];
154
                $total = count($dailyProgress);
234
                $values = [];
-
 
235
                
-
 
236
         
-
 
237
                
155
 
238
                foreach($records as $record)
-
 
239
                {
156
                $data = [
240
                    array_push($labels, $record['label']);
157
                    'total_by_day' => [],
241
                    array_push($values, $record['value']);
158
                    'added_on' => [],
242
                }
159
                    'total' => [],
243
                
160
                    'first_name' => [],
-
 
161
                    'last_name' => [],
244
                $graph = [
-
 
245
                    'labels' => $labels,
162
                    'email' => []
246
                    'values' => $values
163
                ];
247
                ];
164
                //$items = [];
248
                
165
 
249
                $userMapper = UserMapper::getInstance($this->adapter);
166
 
250
                
-
 
251
                
167
 
252
                $first = true;
168
                foreach ($dailyProgress as $record) {
253
                $labels = [];
-
 
254
                $users = [];
169
                    $users = $record['user_id'];
255
                
170
                    $added_on = date("d-m-Y", strtotime($record['added_on']));
256
                $records = $table;
171
                    $total = count($dailyProgress);
257
                foreach($records as  $user_id => $items)
172
                    $first_name = $record['first_name'];
258
                {
-
 
259
                    $user = $userMapper->fetchOne($user_id);
-
 
260
                    if(!$user) {
173
                    $last_name = $record['last_name'];
261
                        continue;
174
                    $email = $record['email'];
262
                    }
-
 
263
                    
175
                    array_push($data['total_by_day'], $users);
264
                    
176
                    array_push($data['added_on'], $added_on);
265
                    $values = [];
177
                    array_push($data['total'], $total);
266
                    foreach($items as $item)
178
                    array_push($data['first_name'], $first_name);
267
                    {
179
                    array_push($data['last_name'], $last_name);
268
                        if($first) {
-
 
269
                            array_push($labels,['date' =>  $item['label'] ]);
180
                    array_push($data['email'], $email);
270
                        }
181
                    // $item = [
271
                        array_push($values,['value' =>  $item['value'] ]);
182
                    //     'total_by_day' => $users,
272
                    }
183
                    //     'added_on' => $added_on,
273
                    
-
 
274
                    array_push($users, [
184
                    //     'total' => $total,
275
                       'first_name' => $user->first_name, 
185
                    //     'first_name' =>  $first_name,
276
                       'last_name' => $user->last_name,
186
                    //     'last_name' => $last_name,
277
                       'email' => $user->email,
-
 
278
                       'values' => $values,
187
                    //     'email' => $email,
279
                    ]);
-
 
280
                    
-
 
281
                    $first = false;
-
 
282
                    
-
 
283
                }
-
 
284
                
-
 
285
                
-
 
286
                usort($users, function($a, $b) {
-
 
287
                   
-
 
288
                    $result = $a['first_name'] <=> $b['last_name'];
-
 
289
                    if($result === 0) {
-
 
290
                        $a['last_name'] <=> $b['last_name'];
-
 
291
                    }
-
 
292
                    
-
 
293
                    return $result;
-
 
294
                    
-
 
295
                    
-
 
296
                });
-
 
297
                
Línea 188... Línea 298...
188
                    // ];
298
                $table = [
189
 
299
                    'labels' => $labels, 
190
                    // array_push($items, $item);
300
                    'users' => $users,
191
                }
301
                ];
-
 
302
 
192
 
303
                
-
 
304
                return new JsonModel([
-
 
305
                    'success' => true,
193
 
306
                    'data' => [
194
                return new JsonModel([
307
                        'graph' => $graph,
195
                    'success' => true,
308
                        'table' => $table,
196
                    'data' => $data, //grafica
309
                    ],
197
                    'items' => $items //tabla
310
                    
198
                ]);
311
                ]);
199
            } else {
312
            } else {
200
                $this->layout()->setTemplate('layout/layout-backend');
313
                $this->layout()->setTemplate('layout/layout-backend');
-
 
314
                $viewModel = new ViewModel();
-
 
315
                $viewModel->setTemplate('leaders-linked/discovery-contact-progress/index.phtml');
-
 
316
                return $viewModel;
-
 
317
            }
-
 
318
        }
-
 
319
        
-
 
320
        return new JsonModel([
-
 
321
            'success' => false,
-
 
322
            'data' => 'ERROR_METHOD_NOT_ALLOWED'
-
 
323
        ]);
-
 
324
    }
-
 
325
    
-
 
326
    public function downloadAction()
-
 
327
    {
-
 
328
        $currentUserPlugin = $this->plugin('currentUserPlugin');
-
 
329
        $currentCompany = $currentUserPlugin->getCompany();
-
 
330
        
-
 
331
        $request = $this->getRequest();
-
 
332
        
-
 
333
        if ($request->isGet()) {
-
 
334
            $startDate = $this->params()->fromQuery('startDate');
-
 
335
            if (empty($startDate)) {
-
 
336
                $startDate = date('Y-m-d');
-
 
337
            }
-
 
338
            
-
 
339
            $endDate = $this->params()->fromQuery('endDate');
-
 
340
            if (empty($endDate)) {
-
 
341
                $endDate = date('Y-m-d');
-
 
342
            }
-
 
343
            
-
 
344
            $dtStartDate = \DateTime::createFromFormat('Y-n-d', $startDate);
-
 
345
            $dtEndDate = \DateTime::createFromFormat('Y-n-d', $endDate);
-
 
346
            
-
 
347
            
-
 
348
            
-
 
349
            if (!$dtStartDate || !$dtEndDate) {
-
 
350
                $startDate = date('Y-m-d');
-
 
351
                $endDate = date('Y-m-d');
-
 
352
            } else {
-
 
353
                
-
 
354
                if ($dtStartDate->getTimestamp() > $dtEndDate->getTimestamp()) {
-
 
355
                    $startDate = date('Y-m-d');
-
 
356
                    $endDate = date('Y-m-d');
-
 
357
                }
-
 
358
                
-
 
359
            }
-
 
360
            
-
 
361
            //echo ' $startDate  = ' .  $startDate  . ' $endDate = ' . $endDate; exit;
-
 
362
            
-
 
363
            $graph = [];
-
 
364
            
-
 
365
            
-
 
366
            $dt = \DateTime::createFromFormat('Y-m-d', $startDate);
-
 
367
            
-
 
368
            do {
-
 
369
                $tempDate = $dt->format('Y-m-d');
-
 
370
                $graph[ $tempDate ] = ['label' => $dt->format('d/m/Y'), 'value' => 0];
-
 
371
                $dt->add(new \DateInterval('P1D'));
-
 
372
                
-
 
373
                
-
 
374
            } while($endDate > $tempDate);
-
 
375
            
-
 
376
            
-
 
377
            $queryMapper = QueryMapper::getInstance($this->adapter);
-
 
378
            
-
 
379
            /*
-
 
380
             select count(*) as cant, date(added_on) as date from tbl_discovery_contacts
-
 
381
             where date(added_on) BETWEEN '2023-05-05' AND '2023-05-31'
-
 
382
             group by date(added_on)
-
 
383
             order by date ASC
-
 
384
             */
-
 
385
            
-
 
386
            $select = $queryMapper->getSql()->select(DiscoveryContactMapper::_TABLE);
-
 
387
            $select->columns([
-
 
388
                'total' => new Expression('COUNT(*)'),
-
 
389
                'date' => new Expression('DATE(added_on)'),
-
 
390
            ]);
-
 
391
            $select->where->between( new Expression('DATE(added_on)') , $startDate,  $endDate);
-
 
392
            $select->group(new Expression('DATE(added_on)'));
-
 
393
            $select->order('date ASC');
-
 
394
            
-
 
395
            $records = $queryMapper->fetchAll($select);
-
 
396
            foreach($records as $record)
-
 
397
            {
-
 
398
                
-
 
399
                $graph[ $record['date']  ][ 'value' ] = $record['total'];
-
 
400
            }
-
 
401
            
-
 
402
            $discoveryContactInteractionTypeMapper = DiscoveryContactInteractionTypeMapper::getInstance($this->adapter);
-
 
403
            $discoveryContactInteractionType =  $discoveryContactInteractionTypeMapper->fetchOneDefaultByCompanyId($currentCompany->id);
-
 
404
            if(!$discoveryContactInteractionType) {
-
 
405
                $discoveryContactInteractionType = $discoveryContactInteractionTypeMapper->fetchOneFirstActiveByCompanyId($currentCompany->id);
-
 
406
            }
-
 
407
            
-
 
408
            
-
 
409
            /*
-
 
410
             select count(*), user_id, date(added_on) as date from tbl_discovery_contact_interactions
-
 
411
             where interaction_type_id = 1 and date(added_on) BETWEEN '2023-05-05' AND '2023-05-31'
-
 
412
             group by date(added_on), user_id
-
 
413
             order by date
-
 
414
             */
-
 
415
            
-
 
416
            $table = [];
-
 
417
            $select = $queryMapper->getSql()->select(DiscoveryContactInteractionMapper::_TABLE);
-
 
418
            $select->columns([
-
 
419
                'user_id',
-
 
420
                'total' => new Expression('COUNT(*)'),
-
 
421
                'date' => new Expression('DATE(added_on)'),
-
 
422
            ]);
-
 
423
            $select->where->equalTo('interaction_type_id', $discoveryContactInteractionType->id);
-
 
424
            $select->where->between( new Expression('DATE(added_on)') , $startDate,  $endDate);
-
 
425
            $select->group([ new Expression('DATE(added_on)'), 'user_id']);
-
 
426
            $select->order('date ASC');
-
 
427
            
-
 
428
            $records = $queryMapper->fetchAll($select);
-
 
429
            foreach($records as $record)
-
 
430
            {
-
 
431
                $user_id =  $record['user_id'];
-
 
432
                
-
 
433
                if(!isset( $table[ $user_id  ])) {
-
 
434
                    
-
 
435
                    $items = [];
-
 
436
                    
-
 
437
                    $dt = \DateTime::createFromFormat('Y-m-d', $startDate);
-
 
438
                    
-
 
439
                    do {
-
 
440
                        $tempDate = $dt->format('Y-m-d');
-
 
441
                        $items[ $tempDate ] = ['label' => $dt->format('d/m/Y'), 'value' => 0];
-
 
442
                        $dt->add(new \DateInterval('P1D'));
-
 
443
                        
-
 
444
                        
-
 
445
                    } while($endDate > $tempDate);
-
 
446
                    
-
 
447
                    $table[ $user_id  ] = $items;
-
 
448
                    
-
 
449
                    
-
 
450
                }
-
 
451
                
-
 
452
                
-
 
453
                $table[ $user_id ][ $record['date'] ]['value'] = $record['total'];
-
 
454
            }
-
 
455
            
-
 
456
            $records = array_values($graph);
-
 
457
            
-
 
458
            $spreadsheet = new Spreadsheet();
-
 
459
            $spreadsheet->getProperties()->setTitle('Relevamiento de Contacto');
-
 
460
            
-
 
461
            $spreadsheet->setActiveSheetIndex(0);
-
 
462
            
-
 
463
            $dt = \DateTime::createFromFormat('Y-m-d', $startDate);
-
 
464
            $spreadsheet->getActiveSheet()->SetCellValue('A1', 'Desde:');
-
 
465
            $spreadsheet->getActiveSheet()->SetCellValue('B1', $dt->format('d/m/Y'));
-
 
466
            
-
 
467
            
-
 
468
            $dt = \DateTime::createFromFormat('Y-m-d', $startDate);
-
 
469
            $spreadsheet->getActiveSheet()->SetCellValue('C1', 'Hasta:');
-
 
470
            $spreadsheet->getActiveSheet()->SetCellValue('D1', $dt->format('d/m/Y'));
-
 
471
            
-
 
472
     
-
 
473
           
-
 
474
            
-
 
475
            $col = 1;
-
 
476
            
-
 
477
            foreach($records as $record)
-
 
478
            {
-
 
479
                $spreadsheet->getActiveSheet()->setCellValue([$col, 3], $record['label']);
-
 
480
                $spreadsheet->getActiveSheet()->setCellValue([$col, 4], $record['value']);
-
 
481
                $col++;
-
 
482
            }
-
 
483
            
-
 
484
            $spreadsheet->getActiveSheet()->SetCellValue('A6', $this->translator->translate('LABEL_FIRST_NAME'));
-
 
485
            $spreadsheet->getActiveSheet()->SetCellValue('B6', $this->translator->translate('LABEL_LAST_NAME'));
-
 
486
            $spreadsheet->getActiveSheet()->SetCellValue('C6', $this->translator->translate('LABEL_EMAIL'));
-
 
487
 
-
 
488
            
-
 
489
            $col = 4;
-
 
490
            
-
 
491
            foreach($records as $record)
-
 
492
            {
-
 
493
                $spreadsheet->getActiveSheet()->setCellValue([$col, 6], $record['label']);
-
 
494
 
-
 
495
                $col++;
-
 
496
            }
-
 
497
            
-
 
498
            
-
 
499
            $userMapper = UserMapper::getInstance($this->adapter);
-
 
500
 
-
 
501
 
-
 
502
            
-
 
503
            $row = 7;
-
 
504
            $records = $table;
-
 
505
            foreach($records as  $user_id => $items)
-
 
506
            {
-
 
507
                $user = $userMapper->fetchOne($user_id);
-
 
508
                if(!$user) {
-
 
509
                    continue;
-
 
510
                }
-
 
511
                
-
 
512
                
-
 
513
                $spreadsheet->getActiveSheet()->SetCellValue([1, $row], $user->first_name);
-
 
514
                $spreadsheet->getActiveSheet()->SetCellValue([2, $row], $user->last_name);
-
 
515
                $spreadsheet->getActiveSheet()->SetCellValue([3, $row], $user->email);
-
 
516
                
-
 
517
                
-
 
518
                $col = 4;
-
 
519
 
-
 
520
                foreach($items as $item)
-
 
521
                {
-
 
522
                    $spreadsheet->getActiveSheet()->SetCellValue([$col, $row],  $item['value']);
-
 
523
                    $col++;
-
 
524
 
-
 
525
                }
-
 
526
                
-
 
527
                $row++;
-
 
528
                
-
 
529
            }
-
 
530
            
-
 
531
            $fileName = 'reporte_relevamiento_de_contact_progreso_por_dia_'  . date('d-m-Y-h-i-a', time()) . '.xls';
-
 
532
            $tempFilename = tempnam(sys_get_temp_dir(), 'reporte_relevamiento_de_contact_progreso_por_dia_' . time());
-
 
533
            
-
 
534
            $writer = IOFactory::createWriter($spreadsheet, 'Xlsx');
-
 
535
            $writer->save($tempFilename);
-
 
536
            
-
 
537
            $content = file_get_contents($tempFilename);
-
 
538
            @unlink($tempFilename);
-
 
539
            
-
 
540
            return new JsonModel([
-
 
541
                'success' => true,
-
 
542
                'data' => [
-
 
543
                    'content' => base64_encode($content),
-
 
544
                    'basename' => $fileName
-
 
545
                    
-
 
546
                ]
-
 
547
            ]);
-
 
548
 
-
 
549
        }
201
                $viewModel = new ViewModel();
550
        
202
                $viewModel->setTemplate('leaders-linked/discovery-contact-progress/index.phtml');
551
        return new JsonModel([