コード例 #1
0
 public function saveCalendarHolidays($aData)
 {
     $CalendarUid = $aData['CALENDAR_UID'];
     $CalendarHolidayName = $aData['CALENDAR_HOLIDAY_NAME'];
     $CalendarHolidayStart = $aData['CALENDAR_HOLIDAY_START'];
     $CalendarHolidayEnd = $aData['CALENDAR_HOLIDAY_END'];
     //if exists the row in the database propel will update it, otherwise will insert.
     $tr = CalendarHolidaysPeer::retrieveByPK($CalendarUid, $CalendarHolidayName);
     if (!(is_object($tr) && get_class($tr) == 'CalendarHolidays')) {
         $tr = new CalendarHolidays();
     }
     $tr->setCalendarUid($CalendarUid);
     $tr->setCalendarHolidayName($CalendarHolidayName);
     $tr->setCalendarHolidayStart($CalendarHolidayStart);
     $tr->setCalendarHolidayEnd($CalendarHolidayEnd);
     if ($tr->validate()) {
         $res = $tr->save();
     } else {
         // Something went wrong. We can now get the validationFailures and handle them.
         $msg = '';
         $validationFailuresArray = $tr->getValidationFailures();
         foreach ($validationFailuresArray as $objValidationFailure) {
             $msg .= $objValidationFailure->getMessage() . "<br/>";
         }
         //return array ( 'codError' => -100, 'rowsAffected' => 0, 'message' => $msg );
     }
     //to do: uniform  coderror structures for all classes
 }
コード例 #2
0
 function saveCalendarInfo($aData)
 {
     $CalendarUid = $aData['CALENDAR_UID'];
     $CalendarName = $aData['CALENDAR_NAME'];
     $CalendarDescription = $aData['CALENDAR_DESCRIPTION'];
     $CalendarStatus = isset($aData['CALENDAR_STATUS']) ? $aData['CALENDAR_STATUS'] : "INACTIVE";
     $defaultCalendars[] = '00000000000000000000000000000001';
     if (in_array($aData['CALENDAR_UID'], $defaultCalendars)) {
         $CalendarStatus = 'ACTIVE';
         $CalendarName = 'Default';
     }
     $CalendarWorkDays = isset($aData['CALENDAR_WORK_DAYS']) ? implode("|", $aData['CALENDAR_WORK_DAYS']) : "";
     //if exists the row in the database propel will update it, otherwise will insert.
     $tr = CalendarDefinitionPeer::retrieveByPK($CalendarUid);
     if (!(is_object($tr) && get_class($tr) == 'CalendarDefinition')) {
         $tr = new CalendarDefinition();
         $tr->setCalendarCreateDate('now');
     }
     $tr->setCalendarUid($CalendarUid);
     $tr->setCalendarName($CalendarName);
     $tr->setCalendarUpdateDate('now');
     $tr->setCalendarDescription($CalendarDescription);
     $tr->setCalendarStatus($CalendarStatus);
     $tr->setCalendarWorkDays($CalendarWorkDays);
     if ($tr->validate()) {
         // we save it, since we get no validation errors, or do whatever else you like.
         $res = $tr->save();
         //Calendar Business Hours Save code.
         //First Delete all current records
         $CalendarBusinessHoursObj = new CalendarBusinessHours();
         $CalendarBusinessHoursObj->deleteAllCalendarBusinessHours($CalendarUid);
         //Save all the sent records
         foreach ($aData['BUSINESS_DAY'] as $key => $objData) {
             $objData['CALENDAR_UID'] = $CalendarUid;
             $CalendarBusinessHoursObj->saveCalendarBusinessHours($objData);
         }
         //Holiday Save code.
         //First Delete all current records
         $CalendarHolidayObj = new CalendarHolidays();
         $CalendarHolidayObj->deleteAllCalendarHolidays($CalendarUid);
         //Save all the sent records
         foreach ($aData['HOLIDAY'] as $key => $objData) {
             if ($objData['CALENDAR_HOLIDAY_NAME'] != "" && $objData['CALENDAR_HOLIDAY_START'] != "" && $objData['CALENDAR_HOLIDAY_END'] != "") {
                 $objData['CALENDAR_UID'] = $CalendarUid;
                 $CalendarHolidayObj->saveCalendarHolidays($objData);
             }
         }
     } else {
         // Something went wrong. We can now get the validationFailures and handle them.
         $msg = '';
         $validationFailuresArray = $tr->getValidationFailures();
         foreach ($validationFailuresArray as $objValidationFailure) {
             $msg .= $objValidationFailure->getMessage() . "<br/>";
         }
         //return array ( 'codError' => -100, 'rowsAffected' => 0, 'message' => $msg );
     }
     //return array ( 'codError' => 0, 'rowsAffected' => $res, 'message' => '');
     //to do: uniform  coderror structures for all classes
     //if ( $res['codError'] < 0 ) {
     //  G::SendMessageText ( $res['message'] , 'error' );
     //}
 }
コード例 #3
0
 public function saveCalendarInfo($aData)
 {
     $CalendarUid = $aData['CALENDAR_UID'];
     $CalendarName = $aData['CALENDAR_NAME'];
     $CalendarDescription = $aData['CALENDAR_DESCRIPTION'];
     $CalendarStatus = isset($aData['CALENDAR_STATUS']) ? $aData['CALENDAR_STATUS'] : "INACTIVE";
     $defaultCalendars[] = '00000000000000000000000000000001';
     if (in_array($aData['CALENDAR_UID'], $defaultCalendars)) {
         $CalendarStatus = 'ACTIVE';
         $CalendarName = G::LoadTranslation('ID_DEFAULT_CALENDAR');
     }
     $CalendarWorkDays = isset($aData['CALENDAR_WORK_DAYS']) ? implode("|", $aData['CALENDAR_WORK_DAYS']) : "";
     $msgCalendarDescriptionStatus = $aData["CALENDAR_DESCRIPTION"] != "" ? ", Description: " . $aData["CALENDAR_DESCRIPTION"] . ", Status: " . ucwords(strtolower($aData["CALENDAR_STATUS"])) : ", Status: " . ucwords(strtolower($aData["CALENDAR_STATUS"]));
     //if exists the row in the database propel will update it, otherwise will insert.
     $tr = CalendarDefinitionPeer::retrieveByPK($CalendarUid);
     if (!(is_object($tr) && get_class($tr) == 'CalendarDefinition')) {
         $tr = new CalendarDefinition();
         $tr->setCalendarCreateDate('now');
         G::auditLog("CreateCalendar", "Calendar Name: " . $aData['CALENDAR_NAME'] . $msgCalendarDescriptionStatus);
     } else {
         G::auditLog("UpdateCalendar", "Calendar Name: " . $aData['CALENDAR_NAME'] . $msgCalendarDescriptionStatus . ", Calendar ID: (" . $CalendarUid . ") ");
     }
     $tr->setCalendarUid($CalendarUid);
     $tr->setCalendarName($CalendarName);
     $tr->setCalendarUpdateDate('now');
     $tr->setCalendarDescription($CalendarDescription);
     $tr->setCalendarStatus($CalendarStatus);
     $tr->setCalendarWorkDays($CalendarWorkDays);
     if ($tr->validate()) {
         // we save it, since we get no validation errors, or do whatever else you like.
         $res = $tr->save();
         //Calendar Business Hours Save code.
         //First Delete all current records
         $CalendarBusinessHoursObj = new CalendarBusinessHours();
         $CalendarBusinessHoursObj->deleteAllCalendarBusinessHours($CalendarUid);
         //Save all the sent records
         foreach ($aData['BUSINESS_DAY'] as $key => $objData) {
             $objData['CALENDAR_UID'] = $CalendarUid;
             $CalendarBusinessHoursObj->saveCalendarBusinessHours($objData);
         }
         //Holiday Save code.
         //First Delete all current records
         $CalendarHolidayObj = new CalendarHolidays();
         $CalendarHolidayObj->deleteAllCalendarHolidays($CalendarUid);
         //Save all the sent records
         foreach ($aData['HOLIDAY'] as $key => $objData) {
             if ($objData['CALENDAR_HOLIDAY_NAME'] != "" && $objData['CALENDAR_HOLIDAY_START'] != "" && $objData['CALENDAR_HOLIDAY_END'] != "") {
                 $objData['CALENDAR_UID'] = $CalendarUid;
                 $CalendarHolidayObj->saveCalendarHolidays($objData);
             }
         }
     } else {
         // Something went wrong. We can now get the validationFailures and handle them.
         $msg = '';
         $validationFailuresArray = $tr->getValidationFailures();
         foreach ($validationFailuresArray as $objValidationFailure) {
             $msg .= $objValidationFailure->getMessage() . "<br/>";
         }
         //return array ( 'codError' => -100, 'rowsAffected' => 0, 'message' => $msg );
     }
 }
コード例 #4
0
ファイル: Course.php プロジェクト: AtaBashir/ams
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getCalendarHolidays()
 {
     return $this->hasMany(CalendarHolidays::className(), ['ch_crs_id' => 'crs_id']);
 }
コード例 #5
0
ファイル: Calendar.php プロジェクト: emildev35/processmaker
 /**
  * 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;
     }
 }