public function order_delAction() { if ($order = eShopOrder::get(system::url(2))) { if ($order->getUserId() == user::get('id')) { $order->delete(); } } system::redirect('/eshop/order-list'); }
public function orderList($templ_name = 'order_list') { $templ_file = '/eshop/' . $templ_name . '.tpl'; $TEMPLATE = page::getTemplate($templ_file); if (!is_array($TEMPLATE)) { return page::errorNotFound('eshop.orderList', $templ_file); } $sel = new ormSelect('eshop_order'); $sel->where('parents', '=', user::get('id')); $sel->orderBy('name', desc); $list = ''; while ($obj = $sel->getObject()) { $order = new eShopOrder($obj); page::assign('order.id', $order->id); page::assign('order.number', $order->getNumber()); page::assign('order.cost', $order->getTotalCost()); page::assign('order.state', $order->_state); page::assign('order.date', $order->date); $list .= page::parse($TEMPLATE['list']); } if (!empty($list)) { page::assign('list', $list); return page::parse($TEMPLATE['frame']); } else { return page::parse($TEMPLATE['empty']); } }
public function del() { if (system::issetUrl(2) && is_numeric(system::url(2))) { // Одиночное удаление if ($obj = eShopOrder::get(system::url(2))) { $obj->delete(); echo 'delete'; } } else { if (isset($_POST['objects'])) { // Множественное удаление while (list($id, $val) = each($_POST['objects'])) { if ($obj = eShopOrder::get($val)) { $obj->delete(); } } echo 'delete'; } } system::stop(); }