コード例 #1
0
ファイル: orders.php プロジェクト: nellka/mebel
 * Позволяет управлять заказами пользователей.
 *
 * @autor Авдеев Марк <*****@*****.**>
 */
$lang = MG::get('lang');
$model = new Models_Order();
$listStatus['null'] = 'Не выбрано';
$ls = Models_Order::$status;
foreach ($ls as $key => $value) {
    $listStatus[$key] = $lang[$value];
    $listStatusTemp[$key] = $lang[$value];
}
$this->statusList = $listStatusTemp;
$listStatus['null'] = 'Не выбрано';
$maxPrice = $model->getMaxPrice();
$minPrice = $model->getMinPrice();
$maxDate = $model->getMaxDate();
$minDate = $model->getMinDate();
$property = array('id' => array('type' => 'text', 'label' => $lang['EDIT_ORDER_13'], 'value' => !empty($_POST['id']) ? $_POST['id'] : null), 'number' => array('type' => 'text', 'label' => $lang['EDIT_ORDER_16'], 'value' => !empty($_POST['number']) ? $_POST['number'] : null), 'user_email' => array('type' => 'text', 'label' => 'email', 'value' => !empty($_POST['user_email']) ? $_POST['user_email'] : null), 'name_buyer' => array('type' => 'text', 'special' => 'like', 'label' => $lang['ORDER_BUYER'], 'value' => !empty($_POST['name_buyer'][0]) ? $_POST['name_buyer'][0] : null), 'status_id' => array('type' => 'select', 'option' => $listStatus, 'selected' => !empty($_POST['status_id']) || $_POST['status_id'] === '0' ? $_POST['status_id'] : 'null', 'label' => $lang['ORDER_STATUS']), 'summ' => array('type' => 'beetwen', 'label1' => $lang['EDIT_ORDER_12'], 'label2' => $lang['FILTR_PRICE4'], 'min' => !empty($_POST['summ'][0]) ? $_POST['summ'][0] : $minPrice, 'max' => !empty($_POST['summ'][1]) ? $_POST['summ'][1] : $maxPrice, 'factMin' => $minPrice, 'factMax' => $maxPrice, 'class' => 'price numericProtection'), 'add_date' => array('type' => 'beetwen', 'label1' => $lang['FILTR_PRICE5'], 'label2' => $lang['FILTR_PRICE6'], 'min' => !empty($_POST['add_date'][0]) ? $_POST['add_date'][0] : $minDate, 'max' => !empty($_POST['add_date'][1]) ? $_POST['add_date'][1] : $maxDate, 'factMin' => '', 'factMax' => '', 'special' => 'date', 'class' => 'date'), 'sorter' => array('type' => 'hidden', 'label' => 'сортировка по полю', 'value' => !empty($_POST['sorter']) ? $_POST['sorter'] : null));
if (isset($_POST['applyFilter'])) {
    $property['applyFilter'] = array('type' => 'hidden', 'label' => 'флаг примения фильтров', 'value' => 1);
}
$filter = new Filter($property);
$arr = array('o.id' => !empty($_POST['id']) ? $_POST['id'] : null, 'o.number' => !empty($_POST['number']) ? $_POST['number'] : null, 'o.add_date' => array(!empty($_POST['add_date'][0]) ? $_POST['add_date'][0] : $minDate, !empty($_POST['add_date'][1]) ? $_POST['add_date'][1] : $maxDate, 'date'), 'user_email' => !empty($_POST['user_email']) ? $_POST['user_email'] : null, 'status_id' => !empty($_POST['status_id']) || $_POST['status_id'] === '0' ? $_POST['status_id'] : 'null', 'summ+delivery_cost' => array(!empty($_POST['summ'][0]) ? $_POST['summ'][0] : $minPrice, !empty($_POST['summ'][1]) ? $_POST['summ'][1] : $maxPrice), 'name_buyer' => !empty($_POST['name_buyer']) ? $_POST['name_buyer'] : null);
$userFilter = $filter->getFilterSql($arr, explode('|', $_POST['sorter']));
$sorterData = explode('|', $_POST['sorter']);
if ($sorterData[1] > 0) {
    $sorterData[3] = 'desc';
} else {
    $sorterData[3] = 'asc';
}