Exemple #1
0
 function Delete($id, $checkRights = true)
 {
     $err_mess = self::err_mess() . "<br>Function: Delete<br>Line: ";
     global $DB, $USER, $APPLICATION;
     $id = intval($id);
     $table = self::TABLE;
     $tableShedule = self::TABLE_SHEDULE;
     if ($id <= 0) {
         return false;
     }
     $isDemo = null;
     $isSupportClient = null;
     $isSupportTeam = null;
     $isAdmin = null;
     $isAccess = null;
     $userID = null;
     CTicket::GetRoles($isDemo, $isSupportClient, $isSupportTeam, $isAdmin, $isAccess, $userID, $checkRights);
     if (!$isAdmin) {
         $arMsg = array();
         $arMsg[] = array("id" => "PERMISSION", "text" => GetMessage("SUP_ERROR_ACCESS_DENIED"));
         $e = new CAdminException($arMsg);
         $APPLICATION->ThrowException($e);
         return false;
     }
     $strSql = "SELECT DISTINCT 'x' FROM b_ticket_sla WHERE TIMETABLE_ID = {$id}";
     $rs = $DB->Query($strSql, false, $err_mess . __LINE__);
     if (!$rs->Fetch()) {
         $DB->Query("DELETE FROM {$table} WHERE ID = {$id}", false, $err_mess . __LINE__);
         $DB->Query("DELETE FROM {$tableShedule} WHERE TIMETABLE_ID = {$id}", false, $err_mess . __LINE__);
         return true;
     } else {
         $APPLICATION->ThrowException(str_replace("#ID#", "{$id}", GetMessage("SUP_ERROR_TIMETABLE_HAS_SLA")));
     }
     return false;
 }
Exemple #2
0
 function Delete($id, $checkRights = true)
 {
     $err_mess = self::err_mess() . "<br>Function: Delete<br>Line: ";
     global $DB, $USER, $APPLICATION;
     $id = intval($id);
     $table = self::table;
     $table_s2h = self::table_s2h;
     if ($id <= 0) {
         return false;
     }
     $isDemo = null;
     $isSupportClient = null;
     $isSupportTeam = null;
     $isAdmin = null;
     $isAccess = null;
     $userID = null;
     CTicket::GetRoles($isDemo, $isSupportClient, $isSupportTeam, $isAdmin, $isAccess, $userID, $checkRights);
     if (!$isAdmin) {
         $arMsg = array();
         $arMsg[] = array("id" => "PERMISSION", "text" => GetMessage("SUP_ERROR_ACCESS_DENIED"));
         $e = new CAdminException($arMsg);
         $APPLICATION->ThrowException($e);
         return false;
     }
     // get affected sla
     $affected_sla = array();
     $res = $DB->Query("SELECT SLA_ID FROM b_ticket_sla_2_holidays WHERE HOLIDAYS_ID = {$id}");
     while ($row = $res->Fetch()) {
         $affected_sla[] = $row['SLA_ID'];
     }
     // delete
     $DB->Query("DELETE FROM {$table} WHERE ID = {$id}", false, $err_mess . __LINE__);
     $DB->Query("DELETE FROM {$table_s2h} WHERE HOLIDAYS_ID = {$id}", false, $err_mess . __LINE__);
     // recalculate only affected sla
     CSupportTimetableCache::toCache(array("SLA_ID" => $affected_sla));
     return true;
 }
Exemple #3
0
 public static function Delete($id, $checkRights = true)
 {
     $err_mess = CAllTicketSLA::err_mess() . "<br>Function: Delete<br>Line: ";
     global $DB, $USER, $APPLICATION;
     $id = intval($id);
     if ($id < 1) {
         return false;
     }
     if ($id == 1) {
         $APPLICATION->ThrowException(GetMessage("SUP_ERROR_SLA_1"));
         return false;
     }
     $isDemo = $isSupportClient = $isSupportTeam = $isAdmin = $isAccess = $userID = null;
     CTicket::GetRoles($isDemo, $isSupportClient, $isSupportTeam, $isAdmin, $isAccess, $userID, $checkRights);
     if ($isAdmin) {
         $strSql = "SELECT DISTINCT 'x' FROM b_ticket WHERE SLA_ID = {$id}";
         $rs = $DB->Query($strSql, false, $err_mess . __LINE__);
         if (!$rs->Fetch()) {
             $DB->Query("DELETE FROM b_ticket_sla_2_site WHERE SLA_ID = {$id}", false, $err_mess . __LINE__);
             $DB->Query("DELETE FROM b_ticket_sla_2_category WHERE SLA_ID = {$id}", false, $err_mess . __LINE__);
             $DB->Query("DELETE FROM b_ticket_sla_2_criticality WHERE SLA_ID = {$id}", false, $err_mess . __LINE__);
             $DB->Query("DELETE FROM b_ticket_sla_2_mark WHERE SLA_ID = {$id}", false, $err_mess . __LINE__);
             $DB->Query("DELETE FROM b_ticket_sla_2_user_group WHERE SLA_ID = {$id}", false, $err_mess . __LINE__);
             //$DB->Query("DELETE FROM b_ticket_sla_shedule WHERE SLA_ID = $id", false, $err_mess.__LINE__);
             $DB->Query("DELETE FROM b_ticket_sla_2_holidays WHERE SLA_ID = {$id}", false, $err_mess . __LINE__);
             $DB->Query("DELETE FROM b_ticket_sla WHERE ID = {$id}", false, $err_mess . __LINE__);
             $DB->Query("DELETE FROM b_ticket_timetable_cache WHERE SLA_ID = {$id}", false, $err_mess . __LINE__);
             return true;
         } else {
             $APPLICATION->ThrowException(str_replace("#ID#", "{$id}", GetMessage("SUP_ERROR_SLA_HAS_TICKET")));
         }
     } else {
         $APPLICATION->ThrowException(GetMessage("SUP_ERROR_ACCESS_DENIED"));
     }
     return false;
 }
 function Delete($id, $checkRights = true)
 {
     $err_mess = self::err_mess() . "<br>Function: Delete<br>Line: ";
     global $DB, $USER, $APPLICATION;
     $id = intval($id);
     $table = self::table;
     $table_s2h = self::table_s2h;
     if ($id <= 0) {
         return false;
     }
     $isDemo = null;
     $isSupportClient = null;
     $isSupportTeam = null;
     $isAdmin = null;
     $isAccess = null;
     $userID = null;
     CTicket::GetRoles($isDemo, $isSupportClient, $isSupportTeam, $isAdmin, $isAccess, $userID, $checkRights);
     if (!$isAdmin) {
         $arMsg = array();
         $arMsg[] = array("id" => "PERMISSION", "text" => GetMessage("SUP_ERROR_ACCESS_DENIED"));
         $e = new CAdminException($arMsg);
         $APPLICATION->ThrowException($e);
         return false;
     }
     $DB->Query("DELETE FROM {$table} WHERE ID = {$id}", false, $err_mess . __LINE__);
     $DB->Query("DELETE FROM {$table_s2h} WHERE HOLIDAYS_ID = {$id}", false, $err_mess . __LINE__);
     CSupportTimetableCache::toCache();
     return true;
 }