miholeus

Untitled

Jan 27th, 2013
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 0.76 KB | None | 0 0
  1. <?php
  2. $nonauth = 1;
  3. require_once 'config.inc.php';
  4.  
  5.  
  6.  
  7. $db = Db::getInstance();
  8.  
  9.  
  10. $res = $db->q("SELECT SUBSTRING_INDEX(annul,',', annulc) AS annul, products_quantity, c AS alltasks, pp FROM (
  11.  
  12. SELECT
  13.  
  14. GROUP_CONCAT(IF(sh.`id` IS NULL , p.`id`, NULL) ) AS annul,
  15.  
  16. (COUNT(p.id) - op.`products_quantity`) AS annulc, COUNT(p.id) AS c, op.`products_quantity`, GROUP_CONCAT(p.status), op.`orders_products_id`,
  17.  
  18. GROUP_CONCAT(p.id) AS pp
  19.  
  20.  
  21.  
  22. FROM orders_products op, wms_task_pickup p
  23.  
  24. LEFT JOIN wms_task_pickup_shipment sh ON (sh.`is_sorted` = 1 AND sh.`pickup_task_id` = p.id)
  25.  
  26. WHERE p.`orders_products_id` = op.`orders_products_id` AND p.`status` <= 3
  27.  
  28. GROUP BY op.orders_products_id
  29.  
  30. HAVING c > op.products_quantity) AS c");
  31.  
  32. var_dump($res);
  33. exit;
Advertisement
Add Comment
Please, Sign In to add comment