PM-4162 Modificaciones en los KPIs para soportar timezones SOLVED
- Add validation datetime utc Change name function Add validation timezone Add validation type
This commit is contained in:
@@ -3,6 +3,7 @@ namespace ProcessMaker\Services\Api;
|
|||||||
|
|
||||||
use \ProcessMaker\Services\Api;
|
use \ProcessMaker\Services\Api;
|
||||||
use \Luracast\Restler\RestException;
|
use \Luracast\Restler\RestException;
|
||||||
|
use \ProcessMaker\Util\DateTime;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -36,7 +37,7 @@ class Dashboard extends Api
|
|||||||
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get dashboards data by user_uid
|
* Get dashboards data by user_uid
|
||||||
*
|
*
|
||||||
@@ -58,7 +59,7 @@ class Dashboard extends Api
|
|||||||
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get users by dashboards uid
|
* Get users by dashboards uid
|
||||||
*
|
*
|
||||||
@@ -141,10 +142,24 @@ class Dashboard extends Api
|
|||||||
public function doGetIndicatorsbyDasUid($das_uid, $dateIni="", $dateFin="")
|
public function doGetIndicatorsbyDasUid($das_uid, $dateIni="", $dateFin="")
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$dateIni = ($dateIni=="") ? date("Y/m/d") : $dateIni;
|
if ($dateIni == "") {
|
||||||
$dateFin = ($dateFin=="") ? date("Y/m/d") : $dateFin;
|
$dateTimezone = new \DateTime("now", new \DateTimeZone('UTC'));
|
||||||
|
$dateIni = $dateTimezone->format('Y-m-d H:i:s');
|
||||||
|
} else {
|
||||||
|
$dateTimezone = new \DateTime($dateIni, new \DateTimeZone('UTC'));
|
||||||
|
$dateTimezone = DateTime::convertDataToUtc($dateTimezone);
|
||||||
|
$dateIni = $dateTimezone->format('Y-m-d H:i:s');
|
||||||
|
}
|
||||||
|
if ($dateFin == "") {
|
||||||
|
$dateTimezone = new \DateTime("now", new \DateTimeZone('UTC'));
|
||||||
|
$dateFin = $dateTimezone->format('Y-m-d H:i:s');
|
||||||
|
} else {
|
||||||
|
$dateTimezone = new \DateTime($dateFin, new \DateTimeZone('UTC'));
|
||||||
|
$dateTimezone = DateTime::convertDataToUtc($dateTimezone);
|
||||||
|
$dateFin = $dateTimezone->format('Y-m-d H:i:s');
|
||||||
|
}
|
||||||
|
|
||||||
$usrUid = $this->getUserId();
|
$usrUid = $this->getUserId();
|
||||||
$Dashboard = new \ProcessMaker\BusinessModel\Dashboard();
|
$Dashboard = new \ProcessMaker\BusinessModel\Dashboard();
|
||||||
$response = $Dashboard->getIndicatorsByDasUid($das_uid, $dateIni, $dateFin, $usrUid);
|
$response = $Dashboard->getIndicatorsByDasUid($das_uid, $dateIni, $dateFin, $usrUid);
|
||||||
return $response;
|
return $response;
|
||||||
@@ -206,7 +221,7 @@ class Dashboard extends Api
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public function doGetOwnersByDasUid(
|
public function doGetOwnersByDasUid(
|
||||||
$das_uid,
|
$das_uid,
|
||||||
$start = 0,
|
$start = 0,
|
||||||
$limit = 0,
|
$limit = 0,
|
||||||
$search = '')
|
$search = '')
|
||||||
@@ -254,7 +269,7 @@ class Dashboard extends Api
|
|||||||
* @author Marco Antonio Nina <marco.antonio.nina@colosa.com>
|
* @author Marco Antonio Nina <marco.antonio.nina@colosa.com>
|
||||||
* @copyright Colosa - Bolivia
|
* @copyright Colosa - Bolivia
|
||||||
*
|
*
|
||||||
* @url PUT
|
* @url PUT
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public function doPutDashboard($request_data)
|
public function doPutDashboard($request_data)
|
||||||
@@ -410,7 +425,7 @@ class Dashboard extends Api
|
|||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$usrUid = $this->getUserId();
|
$usrUid = $this->getUserId();
|
||||||
|
|
||||||
$ConfigDashboards = new \ProcessMaker\BusinessModel\Dashboard();
|
$ConfigDashboards = new \ProcessMaker\BusinessModel\Dashboard();
|
||||||
$response = $ConfigDashboards->postConfigByUsr($request_data, $usrUid);
|
$response = $ConfigDashboards->postConfigByUsr($request_data, $usrUid);
|
||||||
return $response;
|
return $response;
|
||||||
@@ -418,7 +433,7 @@ class Dashboard extends Api
|
|||||||
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get dashboards configuration by usr_uid
|
* Get dashboards configuration by usr_uid
|
||||||
*
|
*
|
||||||
@@ -432,7 +447,7 @@ class Dashboard extends Api
|
|||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$usrUid = $this->getUserId();
|
$usrUid = $this->getUserId();
|
||||||
|
|
||||||
$Dashboard = new \ProcessMaker\BusinessModel\Dashboard();
|
$Dashboard = new \ProcessMaker\BusinessModel\Dashboard();
|
||||||
$response = $Dashboard->getConfig($usrUid);
|
$response = $Dashboard->getConfig($usrUid);
|
||||||
return $response;
|
return $response;
|
||||||
@@ -440,7 +455,7 @@ class Dashboard extends Api
|
|||||||
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Put dashboards configuration by usr_uid
|
* Put dashboards configuration by usr_uid
|
||||||
*
|
*
|
||||||
@@ -456,7 +471,7 @@ class Dashboard extends Api
|
|||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$usrUid = $this->getUserId();
|
$usrUid = $this->getUserId();
|
||||||
|
|
||||||
$ConfigDashboards = new \ProcessMaker\BusinessModel\Dashboard();
|
$ConfigDashboards = new \ProcessMaker\BusinessModel\Dashboard();
|
||||||
$response = $ConfigDashboards->putConfigByUsr($request_data, $usrUid);
|
$response = $ConfigDashboards->putConfigByUsr($request_data, $usrUid);
|
||||||
return $response;
|
return $response;
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ namespace ProcessMaker\Services\Api;
|
|||||||
|
|
||||||
use \ProcessMaker\Services\Api;
|
use \ProcessMaker\Services\Api;
|
||||||
use \Luracast\Restler\RestException;
|
use \Luracast\Restler\RestException;
|
||||||
|
use \ProcessMaker\Util\DateTime;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -41,7 +42,25 @@ class ReportingIndicators extends Api
|
|||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
/**
|
|
||||||
|
/**
|
||||||
|
* @param string $date
|
||||||
|
*
|
||||||
|
* @return \DateTime
|
||||||
|
*/
|
||||||
|
private function convertDateTimeToUtc ($date)
|
||||||
|
{
|
||||||
|
if ($date == "") {
|
||||||
|
$date = new \DateTime("now", new \DateTimeZone('UTC'));
|
||||||
|
} else {
|
||||||
|
$dateTimezone = new \DateTime($date, new \DateTimeZone('UTC'));
|
||||||
|
$date = DateTime::convertDataToUtc($dateTimezone);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $date;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
* Lists tasks of a process and it's statistics (efficiency, average times, etc.)
|
* Lists tasks of a process and it's statistics (efficiency, average times, etc.)
|
||||||
*
|
*
|
||||||
* @param string $process_list {@from path}
|
* @param string $process_list {@from path}
|
||||||
@@ -61,10 +80,11 @@ class ReportingIndicators extends Api
|
|||||||
try {
|
try {
|
||||||
$indicatorsObj = new \ProcessMaker\BusinessModel\ReportingIndicators();
|
$indicatorsObj = new \ProcessMaker\BusinessModel\ReportingIndicators();
|
||||||
$listArray = $listArray = explode(',', $process_list);
|
$listArray = $listArray = explode(',', $process_list);
|
||||||
$response = $indicatorsObj->getPeiTasksStatistics($listArray,
|
$response = $indicatorsObj->getPeiTasksStatistics(
|
||||||
new \DateTime($init_date),
|
$listArray,
|
||||||
new \DateTime($end_date),
|
$this->convertDateTimeToUtc($init_date),
|
||||||
$language);
|
$this->convertDateTimeToUtc($end_date),
|
||||||
|
$language);
|
||||||
return $response;
|
return $response;
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
||||||
@@ -85,37 +105,38 @@ class ReportingIndicators extends Api
|
|||||||
public function doGetProcessEficciencyData($indicator_uid, $compare_date, $measure_date, $language)
|
public function doGetProcessEficciencyData($indicator_uid, $compare_date, $measure_date, $language)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
|
|
||||||
$indicatorsObj = new \ProcessMaker\BusinessModel\ReportingIndicators();
|
$indicatorsObj = new \ProcessMaker\BusinessModel\ReportingIndicators();
|
||||||
$response = $indicatorsObj->getPeiCompleteData
|
$response = $indicatorsObj->getPeiCompleteData(
|
||||||
($indicator_uid,
|
$indicator_uid,
|
||||||
new \DateTime($compare_date),
|
$this->convertDateTimeToUtc($compare_date),
|
||||||
new \DateTime($measure_date),
|
$this->convertDateTimeToUtc($measure_date),
|
||||||
$language);
|
$language);
|
||||||
return $response;
|
return $response;
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Returns the total of Cases with Completed time with the selected periodicity
|
* Returns the total of Cases with Completed time with the selected periodicity
|
||||||
*
|
*
|
||||||
* @param string $indicator_uid {@from path}
|
* @param string $indicator_uid {@from path}
|
||||||
* @param string $measure_date {@from path}
|
* @param string $measure_date {@from path}
|
||||||
* @param string $compare_date {@from path}
|
* @param string $compare_date {@from path}
|
||||||
* @param string $language {@from path}
|
* @param string $language {@from path}
|
||||||
* @return array
|
* @return array
|
||||||
*
|
*
|
||||||
* @url GET /employee-efficiency-data
|
* @url GET /employee-efficiency-data
|
||||||
*/
|
*/
|
||||||
public function doGetEmployeeEficciencyData($indicator_uid, $compare_date, $measure_date, $language)
|
public function doGetEmployeeEficciencyData($indicator_uid, $compare_date, $measure_date, $language)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$indicatorsObj = new \ProcessMaker\BusinessModel\ReportingIndicators();
|
$indicatorsObj = new \ProcessMaker\BusinessModel\ReportingIndicators();
|
||||||
$response = $indicatorsObj->getUeiCompleteData
|
$response = $indicatorsObj->getUeiCompleteData (
|
||||||
($indicator_uid,
|
$indicator_uid,
|
||||||
new \DateTime($compare_date),
|
$this->convertDateTimeToUtc($compare_date),
|
||||||
new \DateTime($measure_date),
|
$this->convertDateTimeToUtc($measure_date),
|
||||||
$language);
|
$language );
|
||||||
return $response;
|
return $response;
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
||||||
@@ -125,9 +146,9 @@ class ReportingIndicators extends Api
|
|||||||
/**
|
/**
|
||||||
* Returns the total of Cases with Completed time with the selected periodicity
|
* Returns the total of Cases with Completed time with the selected periodicity
|
||||||
*
|
*
|
||||||
* @param string $indicator_uid {@from path}
|
* @param string $group_uid {@from path}
|
||||||
* @param string $measure_date {@from path}
|
* @param string $init_date {@from path}
|
||||||
* @param string $compare_date {@from path}
|
* @param string $end_date {@from path}
|
||||||
* @param string $language {@from path}
|
* @param string $language {@from path}
|
||||||
* @return array
|
* @return array
|
||||||
*
|
*
|
||||||
@@ -138,11 +159,11 @@ class ReportingIndicators extends Api
|
|||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$indicatorsObj = new \ProcessMaker\BusinessModel\ReportingIndicators();
|
$indicatorsObj = new \ProcessMaker\BusinessModel\ReportingIndicators();
|
||||||
$response = $indicatorsObj->getUeiGroupsStatistics
|
$response = $indicatorsObj->getUeiGroupsStatistics(
|
||||||
($group_uid,
|
$group_uid,
|
||||||
new \DateTime($init_date),
|
$this->convertDateTimeToUtc($init_date),
|
||||||
new \DateTime($end_date),
|
$this->convertDateTimeToUtc($end_date),
|
||||||
$language);
|
$language);
|
||||||
return $response;
|
return $response;
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
||||||
@@ -164,10 +185,10 @@ class ReportingIndicators extends Api
|
|||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$indicatorsObj = new \ProcessMaker\BusinessModel\ReportingIndicators();
|
$indicatorsObj = new \ProcessMaker\BusinessModel\ReportingIndicators();
|
||||||
$response = $indicatorsObj->getGeneralIndicatorStatistics
|
$response = $indicatorsObj->getGeneralIndicatorStatistics(
|
||||||
($indicator_uid,
|
$indicator_uid,
|
||||||
new \DateTime($init_date),
|
$this->convertDateTimeToUtc($init_date),
|
||||||
new \DateTime($end_date),
|
$this->convertDateTimeToUtc($end_date),
|
||||||
$language);
|
$language);
|
||||||
return $response;
|
return $response;
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
@@ -210,12 +231,12 @@ class ReportingIndicators extends Api
|
|||||||
public function doGetHistoricDataFromIndicator($indicator_uid, $init_date, $end_date, $periodicity, $language) {
|
public function doGetHistoricDataFromIndicator($indicator_uid, $init_date, $end_date, $periodicity, $language) {
|
||||||
try {
|
try {
|
||||||
$indicatorsObj = new \ProcessMaker\BusinessModel\ReportingIndicators();
|
$indicatorsObj = new \ProcessMaker\BusinessModel\ReportingIndicators();
|
||||||
$response = $indicatorsObj->getHistoricData
|
$response = $indicatorsObj->getHistoricData (
|
||||||
($indicator_uid,
|
$indicator_uid,
|
||||||
new \DateTime($init_date),
|
$this->convertDateTimeToUtc($init_date),
|
||||||
new \DateTime($end_date),
|
$this->convertDateTimeToUtc($end_date),
|
||||||
$periodicity,
|
$periodicity,
|
||||||
$language);
|
$language);
|
||||||
return $response;
|
return $response;
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
||||||
|
|||||||
Reference in New Issue
Block a user