Proyectos de Subversion LeadersLinked - Services

Rev

Rev 1 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 1 Rev 152
Línea 347... Línea 347...
347
        $paginator->setItemCountPerPage($records_per_page);
347
        $paginator->setItemCountPerPage($records_per_page);
Línea 348... Línea 348...
348
        
348
        
349
        return $paginator;
349
        return $paginator;
Línea -... Línea 350...
-
 
350
    }
-
 
351
 
-
 
352
    /**
-
 
353
     * 
-
 
354
     * @param  int $company_id
-
 
355
     * @return string
-
 
356
     */
-
 
357
    public function fetchOneMaxDateActivityFromCompanyId($company_id)
-
 
358
    {
-
 
359
 
-
 
360
        
-
 
361
        $select = $this->sql->select();
-
 
362
        $select->columns(['date' => new Expression('DATE(MAX(added_on))') ] );
-
 
363
        $select->from(self::_TABLE);
-
 
364
        $select->where->equalTo('company_id', $company_id);
-
 
365
 
-
 
366
        
-
 
367
        $record = $this->executeFetchOneArray($select);
-
 
368
        return empty($record['date']) ? '' :   $record['date'];
-
 
369
    }
-
 
370
    
-
 
371
    
-
 
372
    
-
 
373
    /**
-
 
374
     * 
-
 
375
     * @param int $company_id
-
 
376
     * @param string $start_date
-
 
377
     * @param string $end_date
-
 
378
     * @return array
-
 
379
     */
-
 
380
    public function fetchAllCountClosedCapsulesDailyByCompanyIdAndStartDateAndEndDate($company_id, $start_date, $end_date)
-
 
381
    {
-
 
382
        $select = $this->sql->select();
-
 
383
        $select->columns(['total' => new Expression('COUNT(*)'), 'date' =>  new Expression('DATE(added_on)') ] );
-
 
384
        $select->from(self::_TABLE);
-
 
385
        $select->where->equalTo('company_id', $company_id);
-
 
386
        $select->where->between(new Expression('DATE(added_on)'), $start_date, $end_date);
-
 
387
        $select->group('date');
-
 
388
        $select->order('date desc');
-
 
389
        
-
 
390
       // echo $select->getSqlString($this->adapter->platform); exit;
-
 
391
        
-
 
392
        return $this->executeFetchAllArray($select);
-
 
393
    }
-
 
394
    
-
 
395
    /**
-
 
396
     *
-
 
397
     * @param int $company_id
-
 
398
     * @param string $start_date
-
 
399
     * @param string $end_date
-
 
400
     * @return array
-
 
401
     */
-
 
402
    public function fetchAllCountUsersWithClosedCapsulesDailyByCompanyIdAndStartDateAndEndDate($company_id, $start_date, $end_date)
-
 
403
    {
-
 
404
        $select = $this->sql->select();
-
 
405
        $select->columns(['total' => new Expression('COUNT(DISTINCT(user_id))'), 'date' =>  new Expression('DATE(added_on)') ] );
-
 
406
        $select->from(self::_TABLE);
-
 
407
        $select->where->equalTo('company_id', $company_id);
-
 
408
        $select->where->between(new Expression('DATE(added_on)'), $start_date, $end_date);
-
 
409
        $select->group('date');
-
 
410
        $select->order('date desc');
-
 
411
        
-
 
412
       
-
 
413
        
-
 
414
        return $this->executeFetchAllArray($select);
-
 
415
    }
-
 
416
    
-
 
417
    /*
-
 
418
 
-
 
419
select count(distinct(user_id)) as c, date(added_on) as d
-
 
420
from tbl_company_microlearning_user_log 
-
 
421
where company_id  = 1 and activity  = 'completed-capsule'
-
 
422
and date(added_on) BETWEEN  '2023-06-09'  and '2023-07-09'
-
 
423
group by d
-
 
424
order by d desc;
-
 
425
     
-
 
426
        select max(date(added_on)) from
-
 
427
        tbl_company_microlearning_user_log
-
 
428
        where company_id  = 1;
-
 
429
        
-
 
430
        select count(*) as c, date(added_on) as d
-
 
431
        from tbl_company_microlearning_user_log
-
 
432
        where company_id  = 1 and activity  = 'completed-capsule'
-
 
433
        and date(added_on) BETWEEN  '2023-06-09'  and '2023-07-09'
-
 
434
        group by d
-
 
435
        order by d desc
-
 
436
        
-
 
437
        select user_id, count(*) as c
-
 
438
        from tbl_company_microlearning_user_log
-
 
439
        where company_id  = 1 and activity  = 'completed-capsule'
-
 
440
        and date(added_on) BETWEEN  '2023-06-09'  and '2023-07-09'
-
 
441
        group by user_id
-
 
442
        order by c desc;
-
 
443
    */
Línea 350... Línea 444...
350
    }
444
    
351
 
445