Rev 15827 | Rev 15837 | Ir a la última revisión | Autoría | Comparar con el anterior | Ultima modificación | Ver Log |
<?php
declare(strict_types=1);
namespace LeadersLinked\Controller;
use LeadersLinked\Model\User;
use Laminas\View\Model\JsonModel;
use Laminas\View\Model\ViewModel;
use LeadersLinked\Mapper\UserMapper;
use LeadersLinked\Mapper\QueryMapper;
use LeadersLinked\Mapper\DiscoveryContactMapper;
use LeadersLinked\Mapper\DiscoveryContactLogMapper;
use Laminas\Mvc\Controller\AbstractActionController;
use Laminas\Hydrator\ArraySerializableHydrator;
use Laminas\Db\ResultSet\HydratingResultSet;
use Laminas\Paginator\Adapter\DbSelect;
use Laminas\Paginator\Paginator;
use LeadersLinked\Mapper\CompanyMapper;
use LeadersLinked\Model\DiscoveryContactLog;
// Create an action controller.
class DiscoveryContactProgressController extends AbstractActionController
{
/**
*
* @var AdapterInterface
*/
private $adapter;
/**
*
* @var AbstractAdapter
*/
private $cache;
/**
*
* @var LoggerInterface
*/
private $logger;
/**
*
* @var array
*/
private $config;
/**
*
* @param AdapterInterface $adapter
* @param AbstractAdapter $cache
* @param LoggerInterface $logger
* @param array $config
*/
public function __construct($adapter, $cache, $logger, $config)
{
$this->adapter = $adapter;
$this->cache = $cache;
$this->logger = $logger;
$this->config = $config;
}
public function indexAction()
{
//Obtenemos los datos el usuario actualmente logueado
$currentUserPlugin = $this->plugin('currentUserPlugin');
$currentUser = $currentUserPlugin->getUser();
$currentNetworkPlugin = $this->plugin('currentNetworkPlugin');
$currentNetwork = $currentNetworkPlugin->getNetwork();
$request = $this->getRequest();
//if ($request->isGet()) {
$headers = $request->getHeaders();
$isJson = false;
if ($headers->has('Accept')) {
$accept = $headers->get('Accept');
$prioritized = $accept->getPrioritized();
foreach ($prioritized as $key => $value) {
$raw = trim($value->getRaw());
if (!$isJson) {
$isJson = strpos($raw, 'json');
}
}
}
//if ($isJson) {
$startDate = $this->params()->fromQuery('startDate');
if (empty($startDate)) {
$startDate = date('Y-m-d');
}
$endDate = $this->params()->fromQuery('endDate');
if (empty($endDate)) {
$endDate = date('Y-m-d');
}
$startDateA = '2023-01-09';
$endDateB = '2023-05-19';
$dtStartDate = \DateTime::createFromFormat('Y-n-d', $startDate);
$dtEndDate = \DateTime::createFromFormat('Y-n-d', $endDate);
if (!$dtStartDate || !$dtEndDate) {
$startDate = date('Y-m-d');
$endDate = date('Y-m-d');
} else {
if ($dtStartDate->getTimestamp() > $dtEndDate->getTimestamp()) {
$startDate = date('Y-m-d');
$endDate = date('Y-m-d');
}
}
$contactProgressRecordMapper = DiscoveryContactLogMapper::getInstance($this->adapter);
$dailyProgress = $contactProgressRecordMapper->fetchAllDataByDateRange($currentUser->id, $startDateA, $endDateB);
return new JsonModel([
'success' => true,
'message' => count($dailyProgress)
]);
//}
//}
}
}