static function ShowClock($arrREQ) { if (!isset($arrREQ["CClockAJAXData"]) || !is_array($arrREQ["CClockAJAXData"]) || count($arrREQ["CClockAJAXData"]) <= 0 || !CSupportTools::array_keys_exists("i,j", $arrREQ["CClockAJAXData"])) { return false; } $arr = $arrREQ["CClockAJAXData"]; $i = intval($arr["i"]); $j = intval($arr["j"]); $val = array(1 => isset($arr["ValF"]) && strlen($arr["ValF"]) > 0 ? CUtil::JSEscape($arr["ValF"]) : self::DEFAULT_TIME, 2 => isset($arr["ValT"]) && strlen($arr["ValT"]) > 0 ? CUtil::JSEscape($arr["ValT"]) : self::DEFAULT_TIME); $ft = array(1 => "FROM", 2 => "TILL"); require_once $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/tools/clock.php"; $clock = array(); for ($k = 1; $k < 3; $k++) { ob_start(); CClock::Show(array('inputId' => "MINUTE_" . $ft[$k] . "_" . $i . "_" . $j, 'inputName' => "ArrShedule[{$i}][CUSTOM_TIME][{$j}][MINUTE_" . $ft[$k] . "]", 'view' => "label", 'showIcon' => true, 'initTime' => $val[$k], 'am_pm_mode' => false)); $clock[$k] = ob_get_contents(); ob_end_clean(); } $res = ' <td>' . $clock[1] . '</td> <td nowrap="" valign="middle" align="center"><nobr> - </nobr></td> <td>' . $clock[2] . '</td> <td> <a title="' . GetMessage("MAIN_ADMIN_MENU_COPY") . '" href="javascript: Copy(' . $i . ',' . $j . ')"><img src="/bitrix/images/support/copy.gif" width="15" height="15" border=0 hspace="2" alt="' . GetMessage("MAIN_ADMIN_MENU_COPY") . '"></a> </td>'; return $res; }
public function ToArray($fields = self::ALL, $notNull = array(), $forSQL = false, $row = null) { $row = $this->checkRow($row); $res = array(); $arFields = CSupportTools::prepareParamArray($fields, array_keys($this->_arFields[$row])); foreach ($arFields as $key => $name) { $fName = is_int($key) ? $name : $key; if (!array_key_exists($fName, $this->_arFieldsTypes)) { continue; } $v = $this->_arFields[$row][$fName]; $ft = $this->_arFieldsTypes[$fName]; if (in_array(self::ONLY_CHANGED, $notNull) && (!isset($this->_arModifiedFields[$row][$fName]) || $this->_arModifiedFields[$row][$fName] != true)) { continue; } elseif (in_array(self::NOT_NULL, $notNull) && $v === null) { continue; } elseif (in_array(self::NOT_DEFAULT, $notNull) && $v === $ft["DEF_VAL"]) { continue; } if ($forSQL) { if (array_key_exists("AUTO_CALCULATED", $ft)) { continue; } $res[$name] = self::ConvertForSQL($ft["TYPE"], $v); } else { $res[$name] = $v; } } return $res; }
public static function GetShedule($arFilter) { global $DB; $err_mess = self::err_mess() . "<br>Function: getShedule<br>Line: "; $res = array(); $t_sla = self::SLA; $t_sla_shedule = self::SLA_SHEDULE; $arSqlSearch = array(); foreach ($arFilter as $key => $val) { if (is_array($val) && count($val) <= 0 || !is_array($val) && strlen($val) <= 0) { continue; } $key = strtoupper($key); if (is_array($val)) { $val = implode(" | ", $val); } switch ($key) { case "SLA_ID": $arSqlSearch[] = GetFilterQuery("SLA.ID", $val, "N"); break; } } $strSqlSearch = GetFilterSqlSearch($arSqlSearch); $strSql = "\n\t\t\tSELECT\n\t\t\t\tSLA.ID SLA_ID,\n\t\t\t\tS.WEEKDAY_NUMBER,\n\t\t\t\tS.OPEN_TIME,\n\t\t\t\tS.MINUTE_FROM,\n\t\t\t\tS.MINUTE_TILL\n\t\t\tFROM\n\t\t\t\t{$t_sla} SLA\n\t\t\t\tINNER JOIN {$t_sla_shedule} S\n\t\t\t\t\tON SLA.TIMETABLE_ID = S.TIMETABLE_ID AND S.TIMETABLE_ID > 0\n\t\t\tWHERE\n\t\t\t\t{$strSqlSearch}\n\t\t\tORDER BY\n\t\t\t\tSLA_ID, WEEKDAY_NUMBER, MINUTE_FROM\n\t\t\t"; $q = $DB->Query($strSql, false, $err_mess . __LINE__); if (intval($q->SelectedRowsCount()) <= 0) { self::InsertDefaultValues(); $q = $DB->Query($strSql, false, $err_mess . __LINE__); } $res0 = array(); $noAdd = array(); $oldSLA = -1; $oldWN = -1; while ($arrR = $q->Fetch()) { if (!CSupportTools::array_keys_exists("SLA_ID,WEEKDAY_NUMBER,OPEN_TIME", $arrR)) { continue; } $cSLA = $arrR["SLA_ID"]; $cWN = intval($arrR["WEEKDAY_NUMBER"]); if ($oldSLA != $cSLA || $oldWN != $cWN) { if ($oldSLA != -1) { $res[$oldSLA][$oldWN] = self::MergeIntervals($res0); } $res0 = array(); $oldSLA = $cSLA; $oldWN = $cWN; } $cOT = $arrR["OPEN_TIME"]; if (isset($noAdd[$cSLA][$cWN])) { continue; } switch ($cOT) { case "24H": $res0 = array(0 => array("F" => 0, "T" => 24 * 60 * 60 - 1)); $noAdd[$cSLA][$cWN] = true; break; case "CLOSED": $res0 = array(); $noAdd[$cSLA][$cWN] = true; break; case "CUSTOM": $res0[] = array("F" => min(intval($arrR["MINUTE_FROM"]) * 60, intval($arrR["MINUTE_TILL"]) * 60), "T" => max(intval($arrR["MINUTE_FROM"]) * 60, intval($arrR["MINUTE_TILL"]) * 60)); break; } } if ($oldSLA > 0) { $res[$oldSLA][$oldWN] = self::MergeIntervals($res0); } return $res; }