25 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.commande.class.php';
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';
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';
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);
88 $sql =
'SELECT rowid FROM '.MAIN_DB_PREFIX.
'commande_fournisseur';
92 while ($obj = $db->fetch_object(
$resql)) {
94 $resarray[] = $obj->rowid;
99 if (count($resarray)) {
100 $res =
'('.implode(
',', $resarray).
')';
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');
159 $f = $order->fetch($order_id);
162 foreach ($order->lines as $line) {
163 if (!in_array($line->fk_product, $products)) {
164 $products[] = $line->fk_product;
Class to manage predefined suppliers products.
if(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') &&!empty($user->rights->don->lire)) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
ordered($product_id)
ordered
dolDispatchToDo($order_id)
Check if there is still some dispatching of stock to do.
getProducts($order_id)
getProducts
dispatchedOrders()
dispatchedOrders