本文整理汇总了PHP中validation::numeric_interval方法的典型用法代码示例。如果您正苦于以下问题:PHP validation::numeric_interval方法的具体用法?PHP validation::numeric_interval怎么用?PHP validation::numeric_interval使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类validation
的用法示例。
在下文中一共展示了validation::numeric_interval方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: tu_validation
//.........这里部分代码省略.........
$description = trim(stripslashes(InPost('description')));
if (!$validator->required($description)) {
$errors['description'] = validation::VALIDATION_MSG_REQUIRED;
} elseif (!$validator->symbols_interval($description, 4, 5000)) {
$errors['description'] = sprintf(validation::VALIDATION_MSG_SYMBOLS_INTERVAL, 4, 5000);
}
//---
//$tservice->requirement = trim(htmlspecialchars(InPost('requirement'),ENT_QUOTES, "cp1251"));
//$requirement = trim(InPost('requirement'));
$tservice->requirement = trim(__paramInit('html', null, 'requirement', null, 5000, true));
$requirement = trim(stripslashes(InPost('requirement')));
if (!$validator->required($requirement)) {
$errors['requirement'] = validation::VALIDATION_MSG_REQUIRED;
} elseif (!$validator->symbols_interval($requirement, 4, 5000)) {
$errors['requirement'] = sprintf(validation::VALIDATION_MSG_SYMBOLS_INTERVAL, 4, 5000);
}
//---
$extra = __paramInit('array', null, 'extra', array());
$extra = is_array($extra) ? array_values($extra) : array();
$total_extra_price = 0;
if (count($extra)) {
$key = 0;
$tservice->extra = null;
foreach ($extra as $el) {
if (isset($el['title'], $el['price'], $el['days_db_id'])) {
$el['title'] = stripslashes($el['title']);
$title = trim(htmlspecialchars($el['title'], ENT_QUOTES, 'cp1251'));
$title_native = trim($el['title']);
$price = trim($el['price']);
if (!$validator->required($title_native) && !$validator->required($price)) {
continue;
}
$is_title = $validator->min_length($title_native, 4) && $validator->max_length($title_native, 255);
$is_price = $validator->is_integer_no_zero($price) && $validator->numeric_interval($price, -999999, 999999);
if (!$is_price) {
$errors['extra'][$key]['price'] = validation::VALIDATION_MSG_REQUIRED_PRICE;
}
if (!$is_title) {
$errors['extra'][$key]['title'] = sprintf(validation::VALIDATION_MSG_SYMBOLS_INTERVAL, 4, 255);
}
$days = trim($el['days_db_id']);
$is_days = $validator->is_natural($days) && $validator->less_than_equal_to($days, 5);
if (!$is_days) {
$errors['extra'][$key]['days'] = sprintf(validation::VALIDATION_MSG_INTERVAL, '0', '5 дней');
$days = 1;
}
$price = intval($price);
$days = intval($days);
$tservice->extra[$key] = array('title' => $title, 'price' => $price, 'days' => $days);
++$key;
if ($price < 0) {
$total_extra_price += $price;
}
}
}
}
//---
$tservice->is_express = 'f';
$tservice->express_price = 0;
$tservice->express_days = 1;
if (InPost('express_activate') == 1 && $tservice->days > 1) {
$express = InPost('express');
$price = trim($express['price']);
if (!$validator->is_natural_no_zero($price) || !$validator->less_than_equal_to($price, 999999)) {
$errors['express']['price'] = validation::VALIDATION_MSG_REQUIRED_PRICE;
}
示例2: tservicesOrdersSetPrice
/**
* Редактирование стоимости и сроков заказа ТУ
*
* @param type $order_id
* @param type $price
* @param type $days
*
* @return \xajaxResponse
*/
function tservicesOrdersSetPrice($order_id, $price, $days, $paytype)
{
$objResponse =& new xajaxResponse();
$uid = get_uid(false);
$price = intval($price);
$days = intval($days);
$paytype = intval($paytype);
//Валидация входных параметров
$validator = new validation();
$valid = $validator->is_natural_no_zero($price) && $validator->greater_than_equal_to($price, 300);
$valid = $valid && $validator->is_natural_no_zero($days) && $validator->numeric_interval($days, 1, 730);
$valid = $valid && in_array($valid, array(TServiceOrderModel::PAYTYPE_DEFAULT, TServiceOrderModel::PAYTYPE_RESERVE));
if (!$valid) {
return $objResponse;
}
//Получение заказа
$orderModel = TServiceOrderModel::model();
$order_id = intval($order_id);
$old_order = $orderModel->getCard($order_id, $uid);
if (!$old_order) {
return $objResponse;
}
//Валидация возможности изменений
$is_new_status = $old_order['status'] == TServiceOrderModel::STATUS_NEW;
$is_owner = $old_order['emp_id'] == $uid;
$is_reserve_accepted = isset($old_order['reserve_data']);
if (!($is_new_status && $is_owner && !$is_reserve_accepted)) {
return $objResponse;
}
//Проверка возможности смены типа оплаты
$is_reserve = tservices_helper::isOrderReserve($paytype);
if ($is_reserve && !tservices_helper::isAllowOrderReserve($old_order['category_id'])) {
return $objResponse;
}
if (!$is_reserve) {
$paytype = TServiceOrderModel::PAYTYPE_DEFAULT;
}
$data = array('order_price' => $price, 'order_days' => $days, 'pay_type' => $paytype);
//Меняем
if ($orderModel->edit($order_id, $data, $old_order['tax'])) {
$order = $old_order;
$order['order_price'] = $price;
$order['order_days'] = $days;
$order['pay_type'] = $paytype;
//Сохранить действие в историю
$history = new tservices_order_history($order_id);
$history->save($order, $old_order);
//Уведомление на почту
$tservices_smail = new tservices_smail();
$tservices_smail->changeOrder2($order, $old_order);
//Обновляем интерфейс цен и сроков
$objResponse->script("\$('tu-container-price').set('html', '" . tservices_helper::cost_format($price) . "');");
$objResponse->script("\$('tu-container-days').set('html', '" . tservices_helper::days_format($days) . "');");
$objResponse->script("\$('tu_edit_budjet_price').set('value', '" . $price . "');");
$objResponse->script("\$('tu_edit_budjet_days').set('value', '" . $days . "');");
//Обновляем сообщение статуса, т.к. вторая сторона тоже могла его изменить
$tserviceOrderStatusWidget = new TServiceOrderStatus();
$tserviceOrderStatusWidget->setIsEmp(true);
$tserviceOrderStatusWidget->setOrder($order);
$tserviceOrderStatusWidget->init();
ob_start();
$tserviceOrderStatusWidget->run();
$statusHtml = ob_get_contents();
ob_end_clean();
$objResponse->assign('tservices_order_status_' . $order_id, 'innerHTML', $statusHtml);
$objResponse->script("\n \$('tu-container-price').getParent()\n .removeClass('b-layout__link_bordbot_dot_" . ($is_reserve ? '000' : 'ee1d16') . "')\n .addClass('b-layout__link_bordbot_dot_" . ($is_reserve ? 'ee1d16' : '000') . "');\n \$('tu-container-price').getPrevious('span').set('html','" . ($is_reserve ? 'Бюджет:' : 'Стоимость:') . "'); \n ");
}
return $objResponse;
}