function getUndefinedDealers() { $data = array(); // INNER JOIN {{dealers_status}} ON {{dealers}}.status = {{dealers_status}}.id $sql = ' SELECT {{dealers}}.* , {{dealers_status}}.shortname as statusname, {{dealers}}.id as dealer_id, ( SELECT COUNT(*) FROM {{dealers_orders}} LEFT JOIN {{dealers_orders_status}} ON {{dealers_orders}}.status = {{dealers_orders_status}}.id WHERE {{dealers_orders}}.`dealer` = dealer_id AND {{dealers_orders_status}}.path = \'new\' ) as new_orders FROM {{dealers}} LEFT JOIN {{dealers_status}} ON {{dealers}}.status = {{dealers_status}}.id WHERE {{dealers}}.active=1 ORDER BY new_orders DESC '; //getPagi не cпособен переварить запрос с подзапросами //вместо //$list=DB::getPagi($sql); //приходится делать так $dealers_count = DB::getOne('SELECT COUNT(*) FROM {{dealers}}'); if (Funcs::$OneSSA) { $perpage = $_SESSION['user']['perpage']; } else { if ($_SESSION['perpage'][end(Funcs::$uri)]) { $perpage = $_SESSION['perpage'][end(Funcs::$uri)]; } else { $perpage = 10; } } $page = intval($_GET['p']) > 0 ? $_GET['p'] : '1'; if (class_exists(PaginationWidget)) { PaginationWidget::$count = $dealers_count; } $sql .= ' LIMIT ' . ($page - 1) * $perpage . ',' . $perpage; $list = DB::getAll($sql); foreach ($list as $item) { $item['stores_cnt'] = DealersStores::getCount($item['id']); $item['consignee_cnt'] = DealersConsignee::getCount($item['id']); $item['balance'] = self::getBalance($item['id']); $item['files'] = DealersFiles::getCountFiles($item['id']); $item['orders'] = DealersOrders::getOrdersCountByStatus($item['id'], 'new') . '/' . DealersOrders::getOrdersCountByStatus($item['id']); $data[] = $item; } return $data; }
function getUndefinedDealers() { $data = array(); //$sql='SELECT * FROM {{dealers}} ORDER BY cdate'; $sql = ' SELECT {{dealers}}.* ,{{dealers_status}}.shortname as statusname FROM {{dealers}} INNER JOIN {{dealers_status}} ON {{dealers}}.status = {{dealers_status}}.id ORDER by cdate '; $list = DB::getPagi($sql); foreach ($list as $item) { $item['stores_cnt'] = DealersStores::getCount($item['id']); $item['consignee_cnt'] = DealersConsignee::getCount($item['id']); $item['balance'] = self::getBalance($item['id']); $item['files'] = DealersFiles::getCountFiles($item['id']); $item['orders'] = DealersOrders::getOrdersCountByStatus($item['id']); $data[] = $item; } return $data; }
public function actdelfile() { DealersFiles::delFile($_GET['id']); $this->redirect('/dealers/files/?id=' . $_GET['dealer']); //View::plugin('files/list',array('list'=>$list,'dealer'=>$dealer)); }
public static function delStore($id) { $sql = ' DELETE FROM {{dealers_stores}} WHERE id=' . $id . ' '; DB::exec($sql); //удалить фотографии адреса DealersFiles::deleteAllStorePhotos($id); }