diff --git a/workflow/engine/src/ProcessMaker/Services/Api/Dashboard.php b/workflow/engine/src/ProcessMaker/Services/Api/Dashboard.php index 6b268d136..f73d4d51c 100644 --- a/workflow/engine/src/ProcessMaker/Services/Api/Dashboard.php +++ b/workflow/engine/src/ProcessMaker/Services/Api/Dashboard.php @@ -3,6 +3,7 @@ namespace ProcessMaker\Services\Api; use \ProcessMaker\Services\Api; 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())); } } - + /** * Get dashboards data by user_uid * @@ -58,7 +59,7 @@ class Dashboard extends Api throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage())); } } - + /** * Get users by dashboards uid * @@ -141,10 +142,24 @@ class Dashboard extends Api public function doGetIndicatorsbyDasUid($das_uid, $dateIni="", $dateFin="") { try { - $dateIni = ($dateIni=="") ? date("Y/m/d") : $dateIni; - $dateFin = ($dateFin=="") ? date("Y/m/d") : $dateFin; + if ($dateIni == "") { + $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(); $response = $Dashboard->getIndicatorsByDasUid($das_uid, $dateIni, $dateFin, $usrUid); return $response; @@ -206,7 +221,7 @@ class Dashboard extends Api * */ public function doGetOwnersByDasUid( - $das_uid, + $das_uid, $start = 0, $limit = 0, $search = '') @@ -254,7 +269,7 @@ class Dashboard extends Api * @author Marco Antonio Nina * @copyright Colosa - Bolivia * - * @url PUT + * @url PUT * */ public function doPutDashboard($request_data) @@ -410,7 +425,7 @@ class Dashboard extends Api { try { $usrUid = $this->getUserId(); - + $ConfigDashboards = new \ProcessMaker\BusinessModel\Dashboard(); $response = $ConfigDashboards->postConfigByUsr($request_data, $usrUid); return $response; @@ -418,7 +433,7 @@ class Dashboard extends Api throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage())); } } - + /** * Get dashboards configuration by usr_uid * @@ -432,7 +447,7 @@ class Dashboard extends Api { try { $usrUid = $this->getUserId(); - + $Dashboard = new \ProcessMaker\BusinessModel\Dashboard(); $response = $Dashboard->getConfig($usrUid); return $response; @@ -440,7 +455,7 @@ class Dashboard extends Api throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage())); } } - + /** * Put dashboards configuration by usr_uid * @@ -456,7 +471,7 @@ class Dashboard extends Api { try { $usrUid = $this->getUserId(); - + $ConfigDashboards = new \ProcessMaker\BusinessModel\Dashboard(); $response = $ConfigDashboards->putConfigByUsr($request_data, $usrUid); return $response; diff --git a/workflow/engine/src/ProcessMaker/Services/Api/ReportingIndicators.php b/workflow/engine/src/ProcessMaker/Services/Api/ReportingIndicators.php index 12eb555fc..fc5f94721 100644 --- a/workflow/engine/src/ProcessMaker/Services/Api/ReportingIndicators.php +++ b/workflow/engine/src/ProcessMaker/Services/Api/ReportingIndicators.php @@ -3,6 +3,7 @@ namespace ProcessMaker\Services\Api; use \ProcessMaker\Services\Api; 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.) * * @param string $process_list {@from path} @@ -61,10 +80,11 @@ class ReportingIndicators extends Api try { $indicatorsObj = new \ProcessMaker\BusinessModel\ReportingIndicators(); $listArray = $listArray = explode(',', $process_list); - $response = $indicatorsObj->getPeiTasksStatistics($listArray, - new \DateTime($init_date), - new \DateTime($end_date), - $language); + $response = $indicatorsObj->getPeiTasksStatistics( + $listArray, + $this->convertDateTimeToUtc($init_date), + $this->convertDateTimeToUtc($end_date), + $language); return $response; } catch (\Exception $e) { 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) { try { + $indicatorsObj = new \ProcessMaker\BusinessModel\ReportingIndicators(); - $response = $indicatorsObj->getPeiCompleteData - ($indicator_uid, - new \DateTime($compare_date), - new \DateTime($measure_date), - $language); + $response = $indicatorsObj->getPeiCompleteData( + $indicator_uid, + $this->convertDateTimeToUtc($compare_date), + $this->convertDateTimeToUtc($measure_date), + $language); return $response; } catch (\Exception $e) { throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage())); } } - /** - * Returns the total of Cases with Completed time with the selected periodicity - * - * @param string $indicator_uid {@from path} - * @param string $measure_date {@from path} - * @param string $compare_date {@from path} - * @param string $language {@from path} - * @return array - * - * @url GET /employee-efficiency-data - */ + /** + * Returns the total of Cases with Completed time with the selected periodicity + * + * @param string $indicator_uid {@from path} + * @param string $measure_date {@from path} + * @param string $compare_date {@from path} + * @param string $language {@from path} + * @return array + * + * @url GET /employee-efficiency-data + */ public function doGetEmployeeEficciencyData($indicator_uid, $compare_date, $measure_date, $language) { try { $indicatorsObj = new \ProcessMaker\BusinessModel\ReportingIndicators(); - $response = $indicatorsObj->getUeiCompleteData - ($indicator_uid, - new \DateTime($compare_date), - new \DateTime($measure_date), - $language); + $response = $indicatorsObj->getUeiCompleteData ( + $indicator_uid, + $this->convertDateTimeToUtc($compare_date), + $this->convertDateTimeToUtc($measure_date), + $language ); return $response; } catch (\Exception $e) { 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 * - * @param string $indicator_uid {@from path} - * @param string $measure_date {@from path} - * @param string $compare_date {@from path} + * @param string $group_uid {@from path} + * @param string $init_date {@from path} + * @param string $end_date {@from path} * @param string $language {@from path} * @return array * @@ -138,11 +159,11 @@ class ReportingIndicators extends Api { try { $indicatorsObj = new \ProcessMaker\BusinessModel\ReportingIndicators(); - $response = $indicatorsObj->getUeiGroupsStatistics - ($group_uid, - new \DateTime($init_date), - new \DateTime($end_date), - $language); + $response = $indicatorsObj->getUeiGroupsStatistics( + $group_uid, + $this->convertDateTimeToUtc($init_date), + $this->convertDateTimeToUtc($end_date), + $language); return $response; } catch (\Exception $e) { throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage())); @@ -164,10 +185,10 @@ class ReportingIndicators extends Api { try { $indicatorsObj = new \ProcessMaker\BusinessModel\ReportingIndicators(); - $response = $indicatorsObj->getGeneralIndicatorStatistics - ($indicator_uid, - new \DateTime($init_date), - new \DateTime($end_date), + $response = $indicatorsObj->getGeneralIndicatorStatistics( + $indicator_uid, + $this->convertDateTimeToUtc($init_date), + $this->convertDateTimeToUtc($end_date), $language); return $response; } catch (\Exception $e) { @@ -210,12 +231,12 @@ class ReportingIndicators extends Api public function doGetHistoricDataFromIndicator($indicator_uid, $init_date, $end_date, $periodicity, $language) { try { $indicatorsObj = new \ProcessMaker\BusinessModel\ReportingIndicators(); - $response = $indicatorsObj->getHistoricData - ($indicator_uid, - new \DateTime($init_date), - new \DateTime($end_date), - $periodicity, - $language); + $response = $indicatorsObj->getHistoricData ( + $indicator_uid, + $this->convertDateTimeToUtc($init_date), + $this->convertDateTimeToUtc($end_date), + $periodicity, + $language); return $response; } catch (\Exception $e) { throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));