/** * Формирование данных доступных в шаблоне страницы "мои заказы". */ function MyOrdersPage() { if (!A::$AUTH->isLogin()) { A::goUrl(getSectionLink(SECTION)); } $orders = array(); $pager = new A_Pager(20); $pager->tab = "orders"; $pager->query("SELECT * FROM " . SECTION . "_orders WHERE iduser=? ORDER BY date DESC", A::$AUTH->id); while ($row = $pager->fetchRow()) { if ($section = getSectionByModule('robopay')) { $row['paylink'] = getSectionLink($section) . "?action=pay&code=" . md5($section . $row['date']); } $row['pay'] = function_exists('pay_getname') ? pay_getname($row['pay']) : "Наличные"; $row['basket'] = !empty($row['basket']) ? unserialize($row['basket']) : array(); $row['sum'] = round($row['sum'], 2); $orders[] = $row; } $pager->free(); $this->Assign("orders", $orders); $this->Assign("orders_pager", $pager); $this->AddNavigation(SECTION_NAME, getSectionLink(SECTION)); }
/** * Формирование данных доступных в шаблоне. */ function createData() { if (!A_Session::is_set(SECTION . "_filter")) { $this->unFilter(); } $fields = A::$DB->getFields(SECTION . "_orders"); if (!in_array('pay', $fields)) { A::$DB->execute("ALTER TABLE `" . SECTION . "_orders` ADD `pay` int(11) NOT NULL default '0'"); } $categories = A::$DB->getAll("SELECT id,idker,name FROM " . SECTION . "_categories ORDER BY level,sort"); $this->Assign("categories", $categories); if (!empty($_GET['idcat'])) { $this->Assign("category", A::$DB->getRowById($_GET['idcat'], SECTION . "_categories")); $idcat = (int) $_GET['idcat']; $childcats = array($idcat); getTreeSubItems(SECTION . "_categories", $idcat, $childcats); $where = "(c.idcat IN(" . implode(",", $childcats) . ") OR c.idcat1 IN(" . implode(",", $childcats) . ") OR c.idcat2 IN(" . implode(",", $childcats) . "))"; $this->Assign("childcats", $childcats = count($childcats)); } else { $where = ""; } if ($filter = $this->getFilter()) { $where = !empty($where) ? "{$where} AND {$filter}" : $filter; } $this->Assign("treebox", new A_CategoriesTree("items")); $rows = A_Session::get(SECTION . "_rows", isset($_COOKIE[SECTION . '_rows']) ? $_COOKIE[SECTION . '_rows'] : 20); $sort = escape_order_string(A_Session::get(SECTION . "_sort", isset($_COOKIE[SECTION . '_sort']) ? $_COOKIE[SECTION . '_sort'] : A::$OPTIONS['sort'])); $items = array(); $pager = new A_Pager($rows); $pager->tab = "items"; $pager->query("\r\r\n\tSELECT c.*,c.svote/c.cvote AS vote,cc.name AS category\r\r\n\tFROM " . SECTION . "_catalog AS c\r\r\n\tLEFT JOIN " . SECTION . "_categories AS cc ON cc.id=c.idcat\r\r\n\t" . (!empty($where) ? " WHERE {$where}" : "") . "\r\r\n\tORDER BY {$sort}"); while ($row = $pager->fetchRow()) { $row['link'] = shoplite_createItemLink($row['id'], SECTION); $row['catpath'] = ""; if (empty($_GET['idcat']) || $childcats > 1) { $row['catpath'] .= getTreePath(SECTION . "_categories", $row['idcat']); } if (!empty($row['idcat1'])) { $row['catpath'] .= '<br>' . getTreePath(SECTION . "_categories", $row['idcat1']); } if (!empty($row['idcat2'])) { $row['catpath'] .= '<br>' . getTreePath(SECTION . "_categories", $row['idcat2']); } $row['vote'] = round($row['vote'], 2); if (A::$OPTIONS['useimages']) { $row['images'] = A::$DB->getAll("SELECT * FROM " . DOMAIN . "_images WHERE idsec=? AND iditem=? ORDER BY sort", array(SECTION_ID, $row['id'])); $row['idimg'] = isset($row['images'][0]['id']) ? $row['images'][0]['id'] : 0; } if (A::$OPTIONS['usefiles']) { $row['files'] = A::$DB->getAll("SELECT * FROM " . DOMAIN . "_files WHERE idsec=? AND iditem=? ORDER BY sort", array(SECTION_ID, $row['id'])); $row['idfile'] = isset($row['files'][0]['id']) ? $row['files'][0]['id'] : 0; } $items[] = $row; } $pager->free(); $this->Assign("items", $items); $this->Assign("items_pager", $pager); $this->Assign("rows", $rows); $this->Assign("sort", $sort); $this->Assign("filter", !empty($filter)); if (A::$OPTIONS['usecomments']) { $this->Assign("commbox", new A_CommentsEditor(SECTION . "_catalog")); } $rows = (int) A_Session::get(SECTION . "_rows2", 20); $idpays = A::$DB->getCol("SELECT DISTINCT pay FROM " . SECTION . "_orders ORDER BY pay"); $pays = array(); foreach ($idpays as $idpay) { $pays[$idpay] = function_exists('pay_getname') ? pay_getname($idpay) : "Наличные"; } $pays = array_unique($pays); $this->Assign("pays", $pays); $where = array(); if (isset($_GET['date'])) { if (!empty($_GET['from'])) { $where[] = "date>=" . (int) $_GET['from']; } if (!empty($_GET['to'])) { $where[] = "date<=" . (int) $_GET['to']; } } if (!empty($_GET['sum1'])) { $where[] = "sum>=" . (int) $_GET['sum1']; } if (!empty($_GET['sum2'])) { $where[] = "sum<=" . (int) $_GET['sum2']; } if (isset($_GET['status']) && $_GET['status'] >= 0) { $where[] = "status=" . (int) $_GET['status']; } if (isset($_GET['pay']) && $_GET['pay'] >= 0) { $where[] = "pay=" . (int) $_GET['pay']; } $where = implode(" AND ", $where); $orders = array(); $pager2 = new A_Pager($rows); $pager2->tab = "orders"; $pager2->query("SELECT * FROM " . SECTION . "_orders " . ($where ? "WHERE {$where}" : "") . " ORDER BY status,date DESC"); while ($row = $pager2->fetchRow()) { $row['pay'] = function_exists('pay_getname') ? pay_getname($row['pay']) : "Наличные"; $row['sum'] = round($row['sum'], 2); $orders[] = $row; } $pager2->free(); $this->Assign("orders", $orders); $this->Assign("orders_pager", $pager2); $this->Assign("rows2", $rows); $this->Assign("optbox1", new A_OptionsBox("Внешний вид на сайте:", array("idgroup" => 1))); $this->Assign("optbox2", new A_OptionsBox("Файлы:", array("idgroup" => 2))); $this->Assign("optbox3", new A_OptionsBox("Заказ:", array("idgroup" => 3))); $this->Assign("optbox4", new A_OptionsBox("Комментирование и голосование:", array("idgroup" => 4))); $this->Assign("optbox5", new A_OptionsBox("Дополнительно:", array("idgroup" => 5))); $this->Assign("fieldsbox", new A_FieldsEditor(SECTION . "_catalog", array('tab' => 'opt', 'tab_opt' => 'fields'), false, true)); $types = array('string' => 'Строка', 'int' => 'Целое число', 'float' => 'Дробное число', 'bool' => 'Логический (Да/Нет)', 'text' => 'Текст', 'select' => 'Значение из списка', 'mselect' => 'Множество значений из списка', 'mprice' => 'Модификатор цены', 'image' => 'Изображение', 'file' => 'Файл'); $nums = array('A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'); $cols = array(); A::$DB->query("SELECT * FROM " . SECTION . "_cols ORDER BY sort"); while ($row = A::$DB->fetchRow()) { $row['num'] = array_shift($nums); $row['type'] = isset($types[$row['type']]) ? $types[$row['type']] : $row['type']; $cols[] = $row; } A::$DB->free(); $this->Assign("cols", $cols); }