37 $dispatched = array();
41 $sql =
'SELECT fk_product, SUM(qty) FROM '.MAIN_DB_PREFIX.
'commande_fournisseur_dispatch';
42 $sql .=
' WHERE fk_commande = '.((int) $order_id);
43 $sql .=
' GROUP BY fk_product';
44 $sql .=
' ORDER by fk_product';
45 $resql = $db->query($sql);
46 if ($resql && $db->num_rows($resql)) {
47 while ($obj = $db->fetch_object($resql)) {
48 $dispatched[$obj->fk_product] = $obj;
53 $sql =
'SELECT fk_product, SUM(qty) FROM '.MAIN_DB_PREFIX.
'commande_fournisseurdet';
54 $sql .=
' WHERE fk_commande = '.((int) $order_id);
55 $sql .=
' AND fk_product > 0';
56 if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) {
57 $sql .=
' AND product_type = 0';
59 $sql .=
' GROUP BY fk_product';
60 $sql .=
' ORDER by fk_product';
61 $resql = $db->query($sql);
62 if ($resql && $db->num_rows($resql)) {
63 while ($obj = $db->fetch_object($resql)) {
64 $ordered[$obj->fk_product] = $obj;
69 foreach ($ordered as $key => $val) {
70 if ($ordered[$key] > $dispatched[$key]) {
75 return ($todispatch ?
true :
false);
116 global $db, $langs, $conf;
118 $sql =
'SELECT DISTINCT cfd.fk_product, SUM(cfd.qty) as qty FROM';
119 $sql .=
' '.MAIN_DB_PREFIX.
'commande_fournisseurdet as cfd ';
120 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'commande_fournisseur as cf';
121 $sql .=
' ON cfd.fk_commande = cf.rowid WHERE';
122 if ($conf->global->STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER) {
123 $sql .=
' cf.fk_statut < 3';
124 } elseif ($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER) {
125 $sql .=
' cf.fk_statut < 6 AND cf.rowid NOT IN '.dispatchedOrders();
127 $sql .=
' cf.fk_statut < 5';
129 $sql .=
' AND cfd.fk_product = '.((int) $product_id);
130 $sql .=
' GROUP BY cfd.fk_product';
132 $resql = $db->query($sql);
134 $exists = $db->num_rows($resql);
136 $obj = $db->fetch_array($resql);
142 $error = $db->lasterror();
145 return $langs->trans(
'error');
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...