Esempio n. 1
0
 function getCalendarInfoE($CalendarUid)
 {
     //if exists the row in the database propel will update it, otherwise will insert.
     $tr = CalendarDefinitionPeer::retrieveByPK($CalendarUid);
     $defaultCalendar['CALENDAR_UID'] = "00000000000000000000000000000001";
     $defaultCalendar['CALENDAR_NAME'] = "Default";
     $defaultCalendar['CALENDAR_CREATE_DATE'] = date("Y-m-d");
     $defaultCalendar['CALENDAR_UPDATE_DATE'] = date("Y-m-d");
     $defaultCalendar['CALENDAR_DESCRIPTION'] = "Default";
     $defaultCalendar['CALENDAR_STATUS'] = "ACTIVE";
     $defaultCalendar['CALENDAR_WORK_DAYS'] = "1|2|3|4|5";
     $defaultCalendar['CALENDAR_WORK_DAYS'] = explode("|", "1|2|3|4|5");
     $defaultCalendar['BUSINESS_DAY'][1]['CALENDAR_BUSINESS_DAY'] = 7;
     $defaultCalendar['BUSINESS_DAY'][1]['CALENDAR_BUSINESS_START'] = "09:00";
     $defaultCalendar['BUSINESS_DAY'][1]['CALENDAR_BUSINESS_END'] = "17:00";
     $defaultCalendar['HOLIDAY'] = array();
     if (is_object($tr) && get_class($tr) == 'CalendarDefinition') {
         $fields['CALENDAR_UID'] = $tr->getCalendarUid();
         $fields['CALENDAR_NAME'] = $tr->getCalendarName();
         $fields['CALENDAR_CREATE_DATE'] = $tr->getCalendarCreateDate();
         $fields['CALENDAR_UPDATE_DATE'] = $tr->getCalendarUpdateDate();
         $fields['CALENDAR_DESCRIPTION'] = $tr->getCalendarDescription();
         $fields['CALENDAR_STATUS'] = $tr->getCalendarStatus();
         $fields['CALENDAR_WORK_DAYS'] = $tr->getCalendarWorkDays();
         $fields['CALENDAR_WORK_DAYS_A'] = explode("|", $tr->getCalendarWorkDays());
     } else {
         $fields = $defaultCalendar;
         $this->saveCalendarInfo($fields);
         $fields['CALENDAR_WORK_DAYS'] = "1|2|3|4|5";
         $fields['CALENDAR_WORK_DAYS_A'] = explode("|", "1|2|3|4|5");
         $tr = CalendarDefinitionPeer::retrieveByPK($CalendarUid);
     }
     $CalendarBusinessHoursObj = new CalendarBusinessHours();
     $CalendarBusinessHours = $CalendarBusinessHoursObj->getCalendarBusinessHours($CalendarUid);
     $fields['BUSINESS_DAY'] = $CalendarBusinessHours;
     $CalendarHolidaysObj = new CalendarHolidays();
     $CalendarHolidays = $CalendarHolidaysObj->getCalendarHolidays($CalendarUid);
     $fields['HOLIDAY'] = $CalendarHolidays;
     // $fields=$this->validateCalendarInfo($fields, $defaultCalendar); //********************
     return $fields;
 }
Esempio n. 2
0
 /**
  * Get data of a Calendar from a record
  *
  * @param array $record Record
  *
  * return array Return an array with data Calendar
  */
 public function getCalendarDataFromRecord($record)
 {
     try {
         $calendarBusinessHours = new \CalendarBusinessHours();
         $calendarHolidays = new \CalendarHolidays();
         $arrayCalendarWorkHour = array();
         $arrayData = $calendarBusinessHours->getCalendarBusinessHours($record["CALENDAR_UID"]);
         foreach ($arrayData as $value) {
             $arrayCalendarWorkHour[] = array($this->getFieldNameByFormatFieldName("DAY") => $this->workDaysTransformData($value["CALENDAR_BUSINESS_DAY"] . "", false), $this->getFieldNameByFormatFieldName("HOUR_START") => $value["CALENDAR_BUSINESS_START"] . "", $this->getFieldNameByFormatFieldName("HOUR_END") => $value["CALENDAR_BUSINESS_END"] . "");
         }
         $arrayCalendarHoliday = array();
         $arrayData = $calendarHolidays->getCalendarHolidays($record["CALENDAR_UID"]);
         foreach ($arrayData as $value) {
             $arrayCalendarHoliday[] = array($this->getFieldNameByFormatFieldName("NAME") => $value["CALENDAR_HOLIDAY_NAME"] . "", $this->getFieldNameByFormatFieldName("DATE_START") => $value["CALENDAR_HOLIDAY_START"] . "", $this->getFieldNameByFormatFieldName("DATE_END") => $value["CALENDAR_HOLIDAY_END"] . "");
         }
         $conf = new \Configurations();
         $confEnvSetting = $conf->getFormats();
         $dateTime = new \DateTime($record["CALENDAR_CREATE_DATE"]);
         $dateCreate = $dateTime->format($confEnvSetting["dateFormat"]);
         $dateTime = new \DateTime($record["CALENDAR_UPDATE_DATE"]);
         $dateUpdate = $dateTime->format($confEnvSetting["dateFormat"]);
         $arrayCalendarWorkDays = array();
         foreach ($this->workDaysTransformData($record["CALENDAR_WORK_DAYS"] . "", false) as $value) {
             $arrayCalendarWorkDays[$value] = \G::LoadTranslation("ID_WEEKDAY_" . ($value != 7 ? $value : 0));
         }
         return array($this->getFieldNameByFormatFieldName("CAL_UID") => $record["CALENDAR_UID"], $this->getFieldNameByFormatFieldName("CAL_NAME") => $record["CALENDAR_NAME"], $this->getFieldNameByFormatFieldName("CAL_DESCRIPTION") => $record["CALENDAR_DESCRIPTION"] . "", $this->getFieldNameByFormatFieldName("CAL_WORK_DAYS") => $arrayCalendarWorkDays, $this->getFieldNameByFormatFieldName("CAL_STATUS") => $record["CALENDAR_STATUS"], $this->getFieldNameByFormatFieldName("CAL_WORK_HOUR") => $arrayCalendarWorkHour, $this->getFieldNameByFormatFieldName("CAL_HOLIDAY") => $arrayCalendarHoliday, $this->getFieldNameByFormatFieldName("CAL_CREATE_DATE") => $dateCreate, $this->getFieldNameByFormatFieldName("CAL_UPDATE_DATE") => $dateUpdate, $this->getFieldNameByFormatFieldName("CAL_TOTAL_USERS") => (int) $record["CALENDAR_TOTAL_USERS"], $this->getFieldNameByFormatFieldName("CAL_TOTAL_PROCESSES") => (int) $record["CALENDAR_TOTAL_PROCESSES"], $this->getFieldNameByFormatFieldName("CAL_TOTAL_TASKS") => (int) $record["CALENDAR_TOTAL_TASKS"]);
     } catch (\Exception $e) {
         throw $e;
     }
 }