Commit 012aa125f1ecb90ca60cff8655fd1e9be950206e
1 parent
df7bbc3f
add order_1c
Showing
4 changed files
with
655 additions
and
1 deletions
Show diff stats
.gitignore
src/app/frontend/controllers/DealerController.php
| ... | ... | @@ -654,11 +654,55 @@ class DealerController extends \controllers\ControllerBase |
| 654 | 654 | } |
| 655 | 655 | |
| 656 | 656 | public function shipmentHistoryAction() { |
| 657 | + | |
| 658 | + if($this->session->has('id')) { | |
| 659 | + $customer = $this->models->getCustomers()->getOneData($this->session->get('id'))['0']; | |
| 660 | + $this->view->setVar('customer', $customer); | |
| 661 | + } | |
| 662 | + | |
| 663 | + if($this->session->get('special_users_id') != null) { | |
| 664 | + | |
| 665 | + $orders = $this->models->getOrders()->getOrdersByCustomerId( $this->session->get('id') ); | |
| 666 | + | |
| 667 | + foreach($orders as $key => $value) { | |
| 668 | + $orders[$key]['created_date'] = date('d', strtotime($value['created_date'])).'.'. | |
| 669 | + date('m', strtotime($value['created_date'])).'.'. | |
| 670 | + date('Y', strtotime($value['created_date'])); | |
| 671 | + $orders_sum = !empty($this->models->getOrders1C()->getOrdersSumById( $value['id'] )[0]) ? $this->models->getOrders()->getOrdersSumById( $value['id'] )[0] : 0; | |
| 672 | + $orders[$key]['price'] = $orders_sum['price']; | |
| 673 | + $orders[$key]['status'] = \config::get( 'global#status/'.$this->lang_id.'/'.$value['status'] ); | |
| 674 | + } | |
| 675 | + | |
| 676 | + $this->view->setVar('orders', $orders); | |
| 677 | + } | |
| 678 | + | |
| 657 | 679 | $this->view->pick('dealer/onlineOrderHistory'); |
| 658 | 680 | } |
| 659 | 681 | |
| 660 | 682 | public function onlineOrderHistoryAction() { |
| 661 | - //in init function of ControllerBase | |
| 683 | + | |
| 684 | + if($this->session->has('id')) { | |
| 685 | + $customer = $this->models->getCustomers()->getOneData($this->session->get('id'))['0']; | |
| 686 | + $this->view->setVar('customer', $customer); | |
| 687 | + } | |
| 688 | + | |
| 689 | + if($this->session->get('special_users_id') != null) { | |
| 690 | + | |
| 691 | + $orders = $this->models->getOrders1C()->getOrdersByCustomerId( $this->session->get('id') ); | |
| 692 | + | |
| 693 | + foreach($orders as $key => $value) { | |
| 694 | + $orders[$key]['created_date'] = date('d', strtotime($value['created_date'])).'.'. | |
| 695 | + date('m', strtotime($value['created_date'])).'.'. | |
| 696 | + date('Y', strtotime($value['created_date'])); | |
| 697 | + $orders_sum = !empty($this->models->getOrders1C()->getOrdersSumById( $value['id'] )[0]) ? $this->models->getOrders1C()->getOrdersSumById( $value['id'] )[0] : 0; | |
| 698 | + $orders[$key]['price'] = $orders_sum['price']; | |
| 699 | + $orders[$key]['status'] = \config::get( 'global#status/'.$this->lang_id.'/'.$value['status'] ); | |
| 700 | + } | |
| 701 | + | |
| 702 | + $this->view->setVar('orders', $orders); | |
| 703 | + } | |
| 704 | + | |
| 705 | + $this->view->pick('dealer/onlineOrderHistory'); | |
| 662 | 706 | } |
| 663 | 707 | |
| 664 | 708 | public function singleOrderAction($order_id) { | ... | ... |
src/lib/models.php
| ... | ... | @@ -18,6 +18,7 @@ namespace |
| 18 | 18 | protected $_items = false; |
| 19 | 19 | protected $_properties = false; |
| 20 | 20 | protected $_orders = false; |
| 21 | + protected $_orders_1c = false; | |
| 21 | 22 | protected $_pages = false; |
| 22 | 23 | protected $_news = false; |
| 23 | 24 | protected $_customers = false; |
| ... | ... | @@ -161,6 +162,27 @@ namespace |
| 161 | 162 | ///////////////////////////////////////////////////////////////////////////// |
| 162 | 163 | |
| 163 | 164 | /** |
| 165 | + * models::getOrders1C | |
| 166 | + * | |
| 167 | + * @author Jane Bezmaternykh | |
| 168 | + * @version 0.1.20140422 | |
| 169 | + * | |
| 170 | + * @return obj | |
| 171 | + */ | |
| 172 | + public function getOrders1C() | |
| 173 | + { | |
| 174 | + if( empty($this->_orders_1c) ) | |
| 175 | + { | |
| 176 | + $this->_orders_1c = new \models\orders_1c(); | |
| 177 | + $this->_orders_1c->setDi( $this->getDi() ); | |
| 178 | + } | |
| 179 | + | |
| 180 | + return $this->_orders_1c; | |
| 181 | + } | |
| 182 | + | |
| 183 | + ///////////////////////////////////////////////////////////////////////////// | |
| 184 | + | |
| 185 | + /** | |
| 164 | 186 | * models::getPages |
| 165 | 187 | * |
| 166 | 188 | * @author Jane Bezmaternykh | ... | ... |
| 1 | +<?php | |
| 2 | + | |
| 3 | +/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
| 4 | + | |
| 5 | +namespace models; | |
| 6 | + | |
| 7 | +class orders_1c extends \db | |
| 8 | +{ | |
| 9 | + ///////////////////////////////////////////////////////////////////////////// | |
| 10 | + | |
| 11 | + public function addOrder( $order) | |
| 12 | + { | |
| 13 | + $connection = $this->database; | |
| 14 | + $this->updateOrderId(); | |
| 15 | + try | |
| 16 | + | |
| 17 | + { | |
| 18 | + $connection->begin(); | |
| 19 | + if( !empty( $order['email'] ) ) | |
| 20 | + { | |
| 21 | + $data_customer_isset = $this->get( | |
| 22 | + ' | |
| 23 | + SELECT | |
| 24 | + id, | |
| 25 | + status | |
| 26 | + FROM | |
| 27 | + public.customers | |
| 28 | + WHERE | |
| 29 | + email = :email | |
| 30 | + LIMIT | |
| 31 | + 1 | |
| 32 | + ', | |
| 33 | + [ | |
| 34 | + 'email' => $order['email'] | |
| 35 | + ], | |
| 36 | + -1 | |
| 37 | + ); | |
| 38 | + } | |
| 39 | + else | |
| 40 | + { | |
| 41 | + $data_customer_isset = $this->get( | |
| 42 | + ' | |
| 43 | + SELECT | |
| 44 | + id, | |
| 45 | + status | |
| 46 | + FROM | |
| 47 | + public.customers | |
| 48 | + WHERE | |
| 49 | + phone = :phone | |
| 50 | + LIMIT | |
| 51 | + 1 | |
| 52 | + ', | |
| 53 | + [ | |
| 54 | + 'phone' => $order['phone'] | |
| 55 | + ], | |
| 56 | + -1 | |
| 57 | + ); | |
| 58 | + } | |
| 59 | + | |
| 60 | + if( empty( $data_customer_isset ) ) // new customer | |
| 61 | + { | |
| 62 | + $data_confirm_key = $this->getDi()->get('models')->getCustomers()->addNewCustomer( $order ); | |
| 63 | + $confirmed = 0; | |
| 64 | + $new = 1; | |
| 65 | + $customer_id = $data_confirm_key['0']['id']; | |
| 66 | + } | |
| 67 | + elseif( !empty( $data_customer_isset ) and $data_customer_isset['0']['status'] == 0 ) // the customer do not finish registration | |
| 68 | + { | |
| 69 | + $confirmed = 0; | |
| 70 | + $new = 0; | |
| 71 | + $customer_id = $data_customer_isset['0']['id']; | |
| 72 | + } | |
| 73 | + elseif( !empty( $data_customer_isset ) and $data_customer_isset['0']['status'] == 1 ) // the customer finish registration | |
| 74 | + { | |
| 75 | + $confirmed = 1; | |
| 76 | + $new = 0; | |
| 77 | + $customer_id = $data_customer_isset['0']['id']; | |
| 78 | + } | |
| 79 | + $data_orders = $this->get( | |
| 80 | + ' | |
| 81 | + INSERT INTO | |
| 82 | + public.orders_1c | |
| 83 | + ( | |
| 84 | + customer_id, | |
| 85 | + name, | |
| 86 | + phone, | |
| 87 | + city, | |
| 88 | + address, | |
| 89 | + delivery, | |
| 90 | + pay, | |
| 91 | + email, | |
| 92 | + comments, | |
| 93 | + action_discount_id, | |
| 94 | + firm_total, | |
| 95 | + promo_code | |
| 96 | + ) | |
| 97 | + VALUES | |
| 98 | + ( | |
| 99 | + :customer_id, | |
| 100 | + :name, | |
| 101 | + :phone, | |
| 102 | + :city, | |
| 103 | + :address, | |
| 104 | + :delivery, | |
| 105 | + :pay, | |
| 106 | + :email, | |
| 107 | + :comments, | |
| 108 | + :action_discount_id, | |
| 109 | + :firm_total, | |
| 110 | + :promo_code | |
| 111 | + ) | |
| 112 | + RETURNING id | |
| 113 | + ', | |
| 114 | + [ | |
| 115 | + 'customer_id' => $customer_id, | |
| 116 | + 'name' => $order['name'], | |
| 117 | + 'phone' => $order['phone'], | |
| 118 | + 'city' => $order['city'], | |
| 119 | + 'address' => $order['address'], | |
| 120 | + 'delivery' => $order['delivery'], | |
| 121 | + 'pay' => $order['pay'], | |
| 122 | + 'email' => $order['email'], | |
| 123 | + 'comments' => $order['comments'], | |
| 124 | + 'action_discount_id' => isset($order['action_id']) ? $order['action_id'] : null, | |
| 125 | + 'firm_total' => isset($order['firm_total']) ? $order['firm_total'] : null, | |
| 126 | + 'promo_code' => isset($order['promo_code']) ? $order['promo_code'] : null | |
| 127 | + ], | |
| 128 | + -1 | |
| 129 | + ); | |
| 130 | + | |
| 131 | + foreach( $order['items'] as $i ) | |
| 132 | + { | |
| 133 | + $data_orders2items = $this->get( | |
| 134 | + ' | |
| 135 | + INSERT INTO | |
| 136 | + public.orders2items_1c | |
| 137 | + ( | |
| 138 | + order_id, | |
| 139 | + item_id, | |
| 140 | + item_count, | |
| 141 | + price | |
| 142 | + ) | |
| 143 | + VALUES | |
| 144 | + ( | |
| 145 | + :order_id, | |
| 146 | + :item_id, | |
| 147 | + :item_count, | |
| 148 | + :price | |
| 149 | + ) | |
| 150 | + ', | |
| 151 | + [ | |
| 152 | + 'order_id' => $data_orders['0']['id'], | |
| 153 | + 'item_id' => $i['id'], | |
| 154 | + 'item_count' => $i['count'], | |
| 155 | + 'price' => $i['price2'] | |
| 156 | + ] | |
| 157 | + ); | |
| 158 | + } | |
| 159 | + | |
| 160 | + $data = | |
| 161 | + [ | |
| 162 | + 'proposal_number' => $data_orders['0']['id'], | |
| 163 | + 'confirmed' => $confirmed, | |
| 164 | + 'new' => $new, | |
| 165 | + ]; | |
| 166 | + | |
| 167 | + if( $order['delivery'] == 3 || $order['delivery'] == 4 ) | |
| 168 | + { | |
| 169 | + switch( $order['delivery'] ) | |
| 170 | + { | |
| 171 | + case 3: | |
| 172 | + default: | |
| 173 | + $order['rcpt_warehouse'] = substr( $order['store_address'], 0, strpos( $order['store_address'], '-' ) ); | |
| 174 | + $order['novaposhta_tnn'] = $this->getDi()->get('novaposhta')->ttn( $data_orders['0']['id'], $order['city'], $order['rcpt_warehouse'], NULL, $order['name'], $order['phone'], '10', $order['total_sum'] ); | |
| 175 | + //$order['novaposhta_tnn'] = $this->getDi()->get('novaposhta')->ttn_ref( $data_orders['0']['id'], $order['city_ref'], $order['store_ref'], NULL, $order['name'], $order['phone'], '10', $order['total_sum'] ); | |
| 176 | + break; | |
| 177 | + case 4: | |
| 178 | + $order['novaposhta_tnn'] = $this->getDi()->get('novaposhta')->ttn( $data_orders['0']['id'], $order['city'], NULL, $order['address'], $order['name'], $order['phone'], '10', $order['total_sum'] ); | |
| 179 | + break; | |
| 180 | + | |
| 181 | + | |
| 182 | + } | |
| 183 | + | |
| 184 | + if( !empty( $order['novaposhta_tnn'] ) && !empty( $data_orders['0']['id'] ) ) | |
| 185 | + { | |
| 186 | + $this->addNovaposhtaTnn( $order['novaposhta_tnn'], $data_orders['0']['id'] ); | |
| 187 | + $data['novaposhta_tnn'] = $order['novaposhta_tnn']; | |
| 188 | + } | |
| 189 | + } | |
| 190 | + | |
| 191 | + $connection->commit(); | |
| 192 | + return $data; | |
| 193 | + } | |
| 194 | + catch(\Exception $e) | |
| 195 | + { | |
| 196 | + $connection->rollback(); | |
| 197 | + } | |
| 198 | + | |
| 199 | + return false; | |
| 200 | + } | |
| 201 | + | |
| 202 | + ///////////////////////////////////////////////////////////////////////////// | |
| 203 | + | |
| 204 | + public function addNovaposhtaTnn( $tnn, $order_id ) | |
| 205 | + { | |
| 206 | + return $this->exec( | |
| 207 | + ' | |
| 208 | + UPDATE | |
| 209 | + public.orders_1c | |
| 210 | + SET | |
| 211 | + novaposhta_tnn = :novaposhta_tnn | |
| 212 | + WHERE | |
| 213 | + id = :id | |
| 214 | + ', | |
| 215 | + [ | |
| 216 | + 'novaposhta_tnn' => $tnn, | |
| 217 | + 'id' => $order_id | |
| 218 | + ] | |
| 219 | + ); | |
| 220 | + } | |
| 221 | + | |
| 222 | + ///////////////////////////////////////////////////////////////////////////// | |
| 223 | + | |
| 224 | + public function getOrdersSumById($id) { | |
| 225 | + return $this->get( | |
| 226 | + ' | |
| 227 | + SELECT | |
| 228 | + SUM((price * item_count)) as price | |
| 229 | + FROM | |
| 230 | + public.orders2items_1c | |
| 231 | + WHERE | |
| 232 | + order_id = :id | |
| 233 | + GROUP BY | |
| 234 | + order_id | |
| 235 | + ', | |
| 236 | + [ | |
| 237 | + 'id' => $id, | |
| 238 | + ], | |
| 239 | + -1 | |
| 240 | + ); | |
| 241 | + } | |
| 242 | + | |
| 243 | + public function getOrdersByCustomerId( $customer_id ) | |
| 244 | + { | |
| 245 | + return $this->get( | |
| 246 | + ' | |
| 247 | + SELECT | |
| 248 | + id, | |
| 249 | + created_date, | |
| 250 | + status, | |
| 251 | + delivery | |
| 252 | + FROM | |
| 253 | + public.orders_1c | |
| 254 | + WHERE | |
| 255 | + customer_id = :customer_id | |
| 256 | + ORDER BY id DESC | |
| 257 | + ', | |
| 258 | + [ | |
| 259 | + 'customer_id' => $customer_id | |
| 260 | + ], | |
| 261 | + -1 | |
| 262 | + ); | |
| 263 | + } | |
| 264 | + | |
| 265 | + ///////////////////////////////////////////////////////////////////////////// | |
| 266 | + | |
| 267 | + public function getOrdersByOrderId( $order_id, $lang_id ) | |
| 268 | + { | |
| 269 | + return $this->get( | |
| 270 | + ' | |
| 271 | + SELECT | |
| 272 | + item_id, | |
| 273 | + item_count, | |
| 274 | + ( | |
| 275 | + SELECT | |
| 276 | + group_id | |
| 277 | + FROM | |
| 278 | + public.items | |
| 279 | + WHERE | |
| 280 | + id = public.orders2items_1c.item_id | |
| 281 | + LIMIT 1 | |
| 282 | + ) AS group_id, | |
| 283 | + ( | |
| 284 | + SELECT | |
| 285 | + firm | |
| 286 | + FROM | |
| 287 | + public.items | |
| 288 | + WHERE | |
| 289 | + id = public.orders2items_1c.item_id | |
| 290 | + LIMIT 1 | |
| 291 | + ) AS firm, | |
| 292 | + ( | |
| 293 | + SELECT | |
| 294 | + price2 | |
| 295 | + FROM | |
| 296 | + public.items | |
| 297 | + WHERE | |
| 298 | + id = public.orders2items_1c.item_id | |
| 299 | + LIMIT 1 | |
| 300 | + ) AS price2, | |
| 301 | + ( | |
| 302 | + SELECT | |
| 303 | + size | |
| 304 | + FROM | |
| 305 | + public.items | |
| 306 | + WHERE | |
| 307 | + id = public.orders2items_1c.item_id | |
| 308 | + LIMIT 1 | |
| 309 | + ) AS size, | |
| 310 | + ( | |
| 311 | + SELECT | |
| 312 | + title | |
| 313 | + FROM | |
| 314 | + public.items_i18n | |
| 315 | + WHERE | |
| 316 | + item_id = public.orders2items_1c.item_id | |
| 317 | + AND | |
| 318 | + lang_id = :lang_id | |
| 319 | + LIMIT 1 | |
| 320 | + ) AS title, | |
| 321 | + ( | |
| 322 | + SELECT | |
| 323 | + alias | |
| 324 | + FROM | |
| 325 | + public.items_group_alias | |
| 326 | + WHERE | |
| 327 | + group_id = | |
| 328 | + ( | |
| 329 | + SELECT | |
| 330 | + group_id | |
| 331 | + FROM | |
| 332 | + public.items | |
| 333 | + WHERE | |
| 334 | + id = public.orders2items_1c.item_id | |
| 335 | + LIMIT 1 | |
| 336 | + ) | |
| 337 | + LIMIT 1 | |
| 338 | + ) AS group_alias, | |
| 339 | + ( | |
| 340 | + SELECT | |
| 341 | + cover | |
| 342 | + FROM | |
| 343 | + public.items_group | |
| 344 | + WHERE | |
| 345 | + group_id = | |
| 346 | + ( | |
| 347 | + SELECT | |
| 348 | + group_id | |
| 349 | + FROM | |
| 350 | + public.items | |
| 351 | + WHERE | |
| 352 | + id = public.orders2items_1c.item_id | |
| 353 | + LIMIT 1 | |
| 354 | + ) | |
| 355 | + LIMIT 1 | |
| 356 | + ) as cover, | |
| 357 | + ( | |
| 358 | + SELECT | |
| 359 | + alias | |
| 360 | + FROM | |
| 361 | + public.types_i18n | |
| 362 | + WHERE | |
| 363 | + type = | |
| 364 | + ( | |
| 365 | + SELECT | |
| 366 | + type | |
| 367 | + FROM | |
| 368 | + public.items | |
| 369 | + WHERE | |
| 370 | + id = public.orders2items_1c.item_id | |
| 371 | + LIMIT 1 | |
| 372 | + ) | |
| 373 | + AND | |
| 374 | + lang_id = :lang_id | |
| 375 | + LIMIT 1 | |
| 376 | + ) AS type_alias, | |
| 377 | + ( | |
| 378 | + SELECT | |
| 379 | + alias | |
| 380 | + FROM | |
| 381 | + public.subtypes_i18n | |
| 382 | + WHERE | |
| 383 | + subtype = | |
| 384 | + ( | |
| 385 | + SELECT | |
| 386 | + subtype | |
| 387 | + FROM | |
| 388 | + public.items | |
| 389 | + WHERE | |
| 390 | + id = public.orders2items_1c.item_id | |
| 391 | + LIMIT 1 | |
| 392 | + ) | |
| 393 | + AND | |
| 394 | + type = | |
| 395 | + ( | |
| 396 | + SELECT | |
| 397 | + type | |
| 398 | + FROM | |
| 399 | + public.items | |
| 400 | + WHERE | |
| 401 | + id = public.orders2items_1c.item_id | |
| 402 | + LIMIT 1 | |
| 403 | + ) | |
| 404 | + AND | |
| 405 | + lang_id = :lang_id | |
| 406 | + ) AS subtype_alias | |
| 407 | + FROM | |
| 408 | + public.orders2items_1c | |
| 409 | + WHERE | |
| 410 | + order_id = :order_id | |
| 411 | + ', | |
| 412 | + [ | |
| 413 | + 'order_id' => $order_id, | |
| 414 | + 'lang_id' => $lang_id | |
| 415 | + ], | |
| 416 | + -1 | |
| 417 | + ); | |
| 418 | + } | |
| 419 | + | |
| 420 | + ///////////////////////////////////////////////////////////////////////////// | |
| 421 | + | |
| 422 | + ///////////////////////////////////////////////////////////////////////////// | |
| 423 | + | |
| 424 | + ///////////////////////////////////////////////////////////////////////////// | |
| 425 | + | |
| 426 | + public function getAllOrders( $page ) | |
| 427 | + { | |
| 428 | + return $this->get( | |
| 429 | + ' | |
| 430 | + SELECT | |
| 431 | + id, | |
| 432 | + name, | |
| 433 | + created_date, | |
| 434 | + phone, | |
| 435 | + comments, | |
| 436 | + status, | |
| 437 | + status_pay, | |
| 438 | + delivery | |
| 439 | + FROM | |
| 440 | + public.orders_1c | |
| 441 | + ORDER BY | |
| 442 | + created_date | |
| 443 | + LIMIT | |
| 444 | + '.\config::get( 'limits/admin_orders' ).' | |
| 445 | + OFFSET | |
| 446 | + '.($page-1)*(\config::get( 'limits/admin_orders' )) | |
| 447 | + , | |
| 448 | + [ | |
| 449 | + | |
| 450 | + ], | |
| 451 | + -1 | |
| 452 | + ); | |
| 453 | + } | |
| 454 | + | |
| 455 | + ///////////////////////////////////////////////////////////////////////////// | |
| 456 | + | |
| 457 | + public function getSortedOrders( $sort_type, $sort_id, $page ) | |
| 458 | + { | |
| 459 | + return $this->get( | |
| 460 | + ' | |
| 461 | + SELECT | |
| 462 | + id, | |
| 463 | + name, | |
| 464 | + created_date, | |
| 465 | + phone, | |
| 466 | + comments, | |
| 467 | + status, | |
| 468 | + status_pay, | |
| 469 | + delivery | |
| 470 | + FROM | |
| 471 | + public.orders_1c | |
| 472 | + WHERE | |
| 473 | + '.$sort_type.' = '.$sort_id.' | |
| 474 | + ORDER BY | |
| 475 | + created_date | |
| 476 | + LIMIT | |
| 477 | + '.\config::get( 'limits/admin_orders' ).' | |
| 478 | + OFFSET | |
| 479 | + '.($page-1)*(\config::get( 'limits/admin_orders' )) | |
| 480 | + , | |
| 481 | + [ | |
| 482 | + | |
| 483 | + ], | |
| 484 | + -1 | |
| 485 | + ); | |
| 486 | + } | |
| 487 | + | |
| 488 | + ///////////////////////////////////////////////////////////////////////////// | |
| 489 | + | |
| 490 | + public function getOrdersWithIds( $orders_ids ) | |
| 491 | + { | |
| 492 | + return $this->get( | |
| 493 | + ' | |
| 494 | + SELECT | |
| 495 | + order_id, | |
| 496 | + item_count, | |
| 497 | + price | |
| 498 | + FROM | |
| 499 | + public.orders2items_1c | |
| 500 | + WHERE | |
| 501 | + order_id IN ('.join( ',', $orders_ids ).') | |
| 502 | + ', | |
| 503 | + [ | |
| 504 | + | |
| 505 | + ], | |
| 506 | + -1 | |
| 507 | + ); | |
| 508 | + } | |
| 509 | + | |
| 510 | + ///////////////////////////////////////////////////////////////////////////// | |
| 511 | + | |
| 512 | + public function countAllOrders() | |
| 513 | + { | |
| 514 | + return $this->get( | |
| 515 | + ' | |
| 516 | + SELECT | |
| 517 | + COUNT(id) AS total | |
| 518 | + FROM | |
| 519 | + public.orders_1c | |
| 520 | + ', | |
| 521 | + [ | |
| 522 | + | |
| 523 | + ], | |
| 524 | + -1 | |
| 525 | + ); | |
| 526 | + } | |
| 527 | + | |
| 528 | + ///////////////////////////////////////////////////////////////////////////// | |
| 529 | + | |
| 530 | + public function countSortedOrders( $sort_type, $sort_id ) | |
| 531 | + { | |
| 532 | + return $this->get( | |
| 533 | + ' | |
| 534 | + SELECT | |
| 535 | + COUNT(id) AS total | |
| 536 | + FROM | |
| 537 | + public.orders_1c | |
| 538 | + WHERE | |
| 539 | + '.$sort_type.' = '.$sort_id.' | |
| 540 | + ', | |
| 541 | + [ | |
| 542 | + | |
| 543 | + ], | |
| 544 | + -1 | |
| 545 | + ); | |
| 546 | + } | |
| 547 | + | |
| 548 | + ///////////////////////////////////////////////////////////////////////////// | |
| 549 | + | |
| 550 | + public function countStatus() | |
| 551 | + { | |
| 552 | + return $this->get( | |
| 553 | + ' | |
| 554 | + SELECT | |
| 555 | + COUNT(status) AS total, | |
| 556 | + status | |
| 557 | + FROM | |
| 558 | + public.orders_1c | |
| 559 | + GROUP BY | |
| 560 | + status | |
| 561 | + ', | |
| 562 | + [ | |
| 563 | + | |
| 564 | + ], | |
| 565 | + -1 | |
| 566 | + ); | |
| 567 | + } | |
| 568 | + | |
| 569 | + public function updateOrderId() | |
| 570 | + { | |
| 571 | + return $this->get( | |
| 572 | + " | |
| 573 | + SELECT setval('orders_id_seq', (SELECT MAX(id) FROM public.orders_1c)) | |
| 574 | + ", | |
| 575 | + [ | |
| 576 | + | |
| 577 | + ], | |
| 578 | + -1 | |
| 579 | + ); | |
| 580 | + } | |
| 581 | + | |
| 582 | + ///////////////////////////////////////////////////////////////////////////// | |
| 583 | + | |
| 584 | + | |
| 585 | +} | |
| 586 | + | |
| 587 | +/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
| 0 | 588 | \ No newline at end of file | ... | ... |