} if (array_key_exists($key . '_EXACT_MATCH', $_REQUEST) && $_REQUEST[$key . '_EXACT_MATCH'] == 'Y') { $op = '='; } else { $op = '%'; } if (array_key_exists($key, $_REQUEST) && strlen($_REQUEST[$key]) > 0) { if (in_array($key . '_EXACT_MATCH', $arFilterFields)) { $arFilter[$op . substr($key, 5)] = $_REQUEST[$key]; } else { $arFilter[substr($key, 5)] = $_REQUEST[$key]; } } } if (array_key_exists('GENERATE', $_POST) && $_POST['GENERATE'] == 'Y' && $bAdmin && check_bitrix_sessid()) { $COUPON = CSupportSuperCoupon::Generate(); if ($COUPON !== false) { $_SESSION['BX_LAST_COUPON'] = $COUPON; LocalRedirect($APPLICATION->GetCurPage() . '?SHOW_COUPON=Y&lang=' . LANG); } else { if ($e = $APPLICATION->GetException()) { $message = new CAdminMessage(GetMessage('SUP_CL_GENERATE_ERROR'), $e); } } } if (array_key_exists('SHOW_COUPON', $_GET) && $_GET['SHOW_COUPON'] == 'Y' && array_key_exists('BX_LAST_COUPON', $_SESSION)) { $message = new CAdminMessage(array('MESSAGE' => GetMessage('SUP_CL_GENERATE_MESS_OK', array('%COUPON%' => $_SESSION['BX_LAST_COUPON'])), 'TYPE' => 'OK')); } if ($bAdmin && $lAdmin->EditAction()) { $obSSC = new CSupportSuperCoupon(); foreach ($FIELDS as $ID => $arFields) {
$bAdmin = CTicket::IsAdmin(); if (!$bAdmin && !$bDemo) { $APPLICATION->AuthForm(GetMessage("ACCESS_DENIED")); } $LIST_URL = '/bitrix/admin/ticket_coupon_list.php'; $ID = intval($ID); $message = false; if ((strlen($save) > 0 || strlen($apply) > 0) && $REQUEST_METHOD == 'POST' && $bAdmin && check_bitrix_sessid()) { $obSSC = new CSupportSuperCoupon(); $bOK = false; $new = false; $arFields = array("ACTIVE_FROM" => $_POST['ACTIVE_FROM'], "ACTIVE_TO" => $_POST['ACTIVE_TO'], "ACTIVE" => $_POST['ACTIVE'], "COUNT_TICKETS" => IntVal($_POST['COUNT_TICKETS']), "SLA_ID" => IntVal($_POST['SLA_ID'])); if ($ID > 0) { $bOK = $obSSC->Update($ID, $arFields); } else { if ($COUPON = $obSSC->Generate($arFields)) { if ($COUPON !== false) { $_SESSION['BX_LAST_COUPON'] = $COUPON; $rsCoupons = $obSSC->GetList(false, array('COUPON' => $COUPON)); $arCoupon = $rsCoupons->Fetch(); $ID = intval($arCoupon['ID']); $bOK = true; $new = true; } else { $bOK = false; } } } if ($bOK) { if (strlen($save) > 0) { LocalRedirect($LIST_URL . '?lang=' . LANG . ($new ? '&SHOW_COUPON=Y' : ''));