Exemplo n.º 1
0
	function GetMessages()
	{
		if($this->exception && method_exists($this->exception, 'GetMessages'))
			return $this->exception->GetMessages();
		return false;
	}
Exemplo n.º 2
0
 function Set($arFields, $arFieldsSLA)
 {
     global $DB, $APPLICATION;
     $err_mess = self::err_mess() . "<br>Function: Set<br>Line: ";
     $isDemo = null;
     $isSupportClient = null;
     $isSupportTeam = null;
     $isAdmin = null;
     $isAccess = null;
     $userID = null;
     CTicket::GetRoles($isDemo, $isSupportClient, $isSupportTeam, $isAdmin, $isAccess, $userID);
     if (!$isAdmin) {
         $arMsg = array();
         $arMsg[] = array("id" => "PERMISSION", "text" => GetMessage("SUP_ERROR_ACCESS_DENIED"));
         $e = new CAdminException($arMsg);
         $APPLICATION->ThrowException($e);
         return false;
     }
     if (is_array($arFields)) {
         $f = new CSupportTableFields(self::$holidays);
         $f->FromArray($arFields);
     } else {
         $f = $arFields;
     }
     if (is_array($arFieldsSLA)) {
         $f_s = new CSupportTableFields(self::$sla2holidays, CSupportTableFields::C_Table);
         $f_s->FromTable($arFieldsSLA);
     } else {
         $f_s = $arFieldsSLA;
     }
     $table = self::table;
     $table_s2h = self::table_s2h;
     $isNew = $f->ID <= 0;
     $objError = new CAdminException(array());
     if (strlen($f->NAME) <= 0) {
         $objError->AddMessage(array("text" => GetMessage('SUP_ERROR_EMPTY_NAME')));
     }
     if (strlen($f->OPEN_TIME) <= 0) {
         $objError->AddMessage(array("text" => GetMessage('SUP_ERROR_EMPTY_OPEN_TIME')));
     }
     $zd = mktime(0, 0, 0, 1, 1, 2010);
     if ($f->DATE_FROM < $zd || $f->DATE_FROM === null || $f->DATE_TILL < $zd || $f->DATE_TILL === null || $f->DATE_FROM > $f->DATE_TILL) {
         if ($f->DATE_FROM < $zd || $f->DATE_FROM === null) {
             $f->DATE_FROM = time() + CTimeZone::GetOffset();
         }
         if ($f->DATE_TILL < $zd || $f->DATE_TILL === null) {
             $f->DATE_TILL = time() + CTimeZone::GetOffset();
         }
         $objError->AddMessage(array("text" => GetMessage('SUP_ERROR_EMPTY_DATE')));
     }
     if (count($objError->GetMessages()) > 0) {
         $APPLICATION->ThrowException($objError);
         return false;
     }
     $arFields_i = $f->ToArray(CSupportTableFields::ALL, array(CSupportTableFields::NOT_NULL), true);
     $res = 0;
     if (count($arFields_i) > 0) {
         if ($isNew) {
             $res = $DB->Insert($table, $arFields_i, $err_mess . __LINE__);
             $f->ID = $res;
         } else {
             $res = $DB->Update($table, $arFields_i, "WHERE ID=" . $f->ID . "", $err_mess . __LINE__);
         }
     }
     if (intval($res) <= 0) {
         $APPLICATION->ThrowException(GetMessage('SUP_ERROR_DB_ERROR'));
         return false;
     }
     $DB->Query("DELETE FROM {$table_s2h} WHERE HOLIDAYS_ID = " . $f->ID, false, $err_mess . __LINE__);
     $f_s->ResetNext();
     while ($f_s->Next()) {
         $f_s->HOLIDAYS_ID = $f->ID;
         if ($f_s->SLA_ID > 0) {
             $strSql = "INSERT INTO " . $table_s2h . "(SLA_ID, HOLIDAYS_ID) VALUES (" . $f_s->SLA_ID . ", " . $f_s->HOLIDAYS_ID . ")";
             $res = $DB->Query($strSql, false, $err_mess . __LINE__);
         }
     }
     CSupportTimetableCache::toCache(array("SLA_ID" => $f_s->getColumn("SLA_ID")));
     return $f->ID;
 }