diff --git a/htdocs/expedition/fiche.php b/htdocs/expedition/fiche.php index 77657e28c49..f9a8d612c00 100644 --- a/htdocs/expedition/fiche.php +++ b/htdocs/expedition/fiche.php @@ -713,21 +713,44 @@ else if ($ret == 'html') print '
'; } - // Calcul du poids total et du volume total des produits + // Calculate ture totalVeight and totalVolume for all products + // by adding weight and volume of each line. $totalWeight = ''; $totalVolume = ''; + $weightUnit=0; + $volumeUnit=0; for ($i = 0 ; $i < $num_prod ; $i++) { $weightUnit=0; $volumeUnit=0; if (! empty($lignes[$i]->weight_units)) $weightUnit = $lignes[$i]->weight_units; - $trueWeightUnit=pow(10,$weightUnit); - $totalWeight += $lignes[$i]->weight*$lignes[$i]->qty_shipped*$trueWeightUnit; if (! empty($lignes[$i]->volume_units)) $volumeUnit = $lignes[$i]->volume_units; - $trueVolumeUnit=pow(10,$volumeUnit); - $totalVolume += $lignes[$i]->volume*$lignes[$i]->qty_shipped*$trueVolumeUnit; + // TODO Use a function addvalueunits(val1,unit1,val2,unit2)=>(val,unit) + if ($lignes[$i]->weight_units < 50) + { + $trueWeightUnit=pow(10,$weightUnit); + $totalWeight += $lignes[$i]->weight*$lignes[$i]->qty_shipped*$trueWeightUnit; + } + else + { + $trueWeightUnit=$weightUnit; + $totalWeight += $lignes[$i]->weight*$lignes[$i]->qty_shipped; + } + if ($lignes[$i]->volume_units < 50) + { + //print $lignes[$i]->volume."x".$lignes[$i]->volume_units."x".($lignes[$i]->volume_units < 50)."x".$volumeUnit; + $trueVolumeUnit=pow(10,$volumeUnit); + //print $lignes[$i]->volume; + $totalVolume += $lignes[$i]->volume*$lignes[$i]->qty_shipped*$trueVolumeUnit; + } + else + { + $trueVolumeUnit=$volumeUnit; + $totalVolume += $lignes[$i]->volume*$lignes[$i]->qty_shipped; + } } $totalVolume=$totalVolume; + //print "totalVolume=".$totalVolume." volumeUnit=".$volumeUnit; print ''; @@ -831,8 +854,12 @@ else else { // If sending volume not defined we use sum of products - // TODO Show in best unit - if ($totalVolume > 0) print $totalVolume.' '.measuring_units_string(0,"volume"); + if ($totalVolume > 0) + { + print $totalVolume.' '; + if ($volumeUnit < 50) print measuring_units_string(0,"volume"); + else print measuring_units_string($volumeUnit,"volume"); + } else print ' '; } print "\n"; diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index 1cdf4d23f3a..c4025559c44 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -925,22 +925,30 @@ class CommandeFournisseur extends Commande /** * Add a product into a stock warehouse. * - * @param $user - * @param $product - * @param $qty + * @param $user User object making change + * @param $product Product object to dispatch + * @param $qty Qty to dispatch * @param $entrepot Id of warehouse to add product - * @param $price - * @return int <0 if KO, =0 if OK + * @param $price Price for PMP value calculation + * @param $comment Comment for stock movement + * @return int <0 if KO, >0 if OK */ - function DispatchProduct($user, $product, $qty, $entrepot, $price=0) + function DispatchProduct($user, $product, $qty, $entrepot, $price=0, $comment='') { global $conf; $error = 0; require_once DOL_DOCUMENT_ROOT ."/product/stock/class/mouvementstock.class.php"; + // Check parameters + if ($entrepot <= 0 || $qty <= 0) + { + $this->error='BadValueForParameter'; + return -1; + } + $now=dol_now(); - if ( ($this->statut == 3 || $this->statut == 4 || $this->statut == 5) && $qty > 0) + if (($this->statut == 3 || $this->statut == 4 || $this->statut == 5)) { $this->db->begin(); @@ -973,7 +981,7 @@ class CommandeFournisseur extends Commande if ($error == 0) { $this->db->commit(); - return 0; + return 1; } else { @@ -983,6 +991,7 @@ class CommandeFournisseur extends Commande } else { + $this->error='BadStatusForObject'; return -2; } } diff --git a/htdocs/fourn/commande/dispatch.php b/htdocs/fourn/commande/dispatch.php index 7280d17b4ae..def7060b5c0 100644 --- a/htdocs/fourn/commande/dispatch.php +++ b/htdocs/fourn/commande/dispatch.php @@ -46,12 +46,18 @@ $id = isset($_GET["id"])?$_GET["id"]:''; if ($user->societe_id) $socid=$user->societe_id; $result = restrictedArea($user, 'commande_fournisseur', $id,''); +if (empty($conf->stock->enabled)) +{ + accessforbidden(); +} + // Recuperation de l'id de projet $projectid = 0; if ($_GET["projectid"]) $projectid = $_GET["projectid"]; $mesg=''; + /* * Actions */ @@ -68,7 +74,14 @@ if ($_POST["action"] == 'dispatch' && $user->rights->fournisseur->commande->rece $qty = "qty_".$reg[1]; $ent = "entrepot_".$reg[1]; $pu = "pu_".$reg[1]; - $result = $commande->DispatchProduct($user, $_POST[$prod], $_POST[$qty], $_POST[$ent], $_POST[$pu]); + if ($_POST[$ent] > 0) + { + $result = $commande->DispatchProduct($user, $_POST[$prod], $_POST[$qty], $_POST[$ent], $_POST[$pu], $_POST["label"]); + } + else + { + dol_syslog('No dispatch for line '.$key.' as no warehouse choosed'); + } } } @@ -79,12 +92,11 @@ if ($_POST["action"] == 'dispatch' && $user->rights->fournisseur->commande->rece } else { - $mesg=$commande->error; + $mesg='
'.$langs->trans($commande->error).'
'; } } - /* * View */ @@ -182,6 +194,9 @@ if ($id > 0 || ! empty($ref)) if ($commande->statut == 3 || $commande->statut == 4 || $commande->statut == 5) { + $entrepot = new Entrepot($db); + $listwarehouses=$entrepot->list_array(1); + print ''; print ''; print ''; @@ -229,7 +244,6 @@ if ($id > 0 || ! empty($ref)) print "\n"; } - $entrepot = new Entrepot($db); $nbfreeproduct=0; $nbproduct=0; @@ -268,8 +282,14 @@ if ($id > 0 || ! empty($ref)) // Warehouse print '\n"; print "\n"; } @@ -287,7 +307,9 @@ if ($id > 0 || ! empty($ref)) if ($nbproduct) { - print '
'; + print '
'; } if (! $nbproduct && $nbfreeproduct) { diff --git a/htdocs/fourn/commande/fiche.php b/htdocs/fourn/commande/fiche.php index 187aac994ec..53fa1150568 100644 --- a/htdocs/fourn/commande/fiche.php +++ b/htdocs/fourn/commande/fiche.php @@ -293,7 +293,7 @@ if ($_REQUEST['action'] == 'confirm_valid' && $_REQUEST['confirm'] == 'yes' && $ $commande->fetch($id); - $commande->date_commande=time(); + $commande->date_commande=dol_now(); $result = $commande->valid($user); if ($result >= 0) { @@ -812,7 +812,7 @@ if ($id > 0 || ! empty($ref)) */ if ($_GET['action'] == 'approve') { - $ret=$html->form_confirm("fiche.php?id=$commande->id",$langs->trans("ApproveThisOrder"),$langs->trans("ConfirmApproveThisOrder"),"confirm_approve", '', 1, 1); + $ret=$html->form_confirm("fiche.php?id=$commande->id",$langs->trans("ApproveThisOrder"),$langs->trans("ConfirmApproveThisOrder",$commande->ref),"confirm_approve", '', 1, 1); if ($ret == 'html') print '
'; } /* @@ -820,7 +820,7 @@ if ($id > 0 || ! empty($ref)) */ if ($_GET['action'] == 'refuse') { - $ret=$html->form_confirm("fiche.php?id=$commande->id",$langs->trans("DenyingThisOrder"),$langs->trans("ConfirmDenyingThisOrder"),"confirm_refuse", '', 0, 1); + $ret=$html->form_confirm("fiche.php?id=$commande->id",$langs->trans("DenyingThisOrder"),$langs->trans("ConfirmDenyingThisOrder",$commande->ref),"confirm_refuse", '', 0, 1); if ($ret == 'html') print '
'; } /* @@ -828,7 +828,7 @@ if ($id > 0 || ! empty($ref)) */ if ($_GET['action'] == 'cancel') { - $ret=$html->form_confirm("fiche.php?id=$commande->id",$langs->trans("Cancel"),$langs->trans("ConfirmCancelThisOrder"),"confirm_cancel", '', 0, 1); + $ret=$html->form_confirm("fiche.php?id=$commande->id",$langs->trans("Cancel"),$langs->trans("ConfirmCancelThisOrder",$commande->ref),"confirm_cancel", '', 0, 1); if ($ret == 'html') print '
'; } diff --git a/htdocs/langs/en_US/suppliers.lang b/htdocs/langs/en_US/suppliers.lang index fb200de5fa3..18c0f38c54f 100644 --- a/htdocs/langs/en_US/suppliers.lang +++ b/htdocs/langs/en_US/suppliers.lang @@ -25,10 +25,10 @@ RefSupplierShort=Ref. supplier ExportDataset_fournisseur_1=Supplier invoices list and invoice's lines ExportDataset_fournisseur_2=Supplier invoices and payments ApproveThisOrder=Approve this order -ConfirmApproveThisOrder=Are you sure you want to approve this order ? +ConfirmApproveThisOrder=Are you sure you want to approve order %s ? DenyingThisOrder=Denying this order -ConfirmDenyingThisOrder=Are you sure you want to deny this order ? -ConfirmCancelThisOrder=Are you sure you want to cancel this order ? +ConfirmDenyingThisOrder=Are you sure you want to deny this order %s ? +ConfirmCancelThisOrder=Are you sure you want to cancel this order %s ? AddCustomerOrder=Create customer order AddCustomerInvoice=Create customer invoice AddSupplierOrder=Create supplier order diff --git a/htdocs/langs/fr_FR/suppliers.lang b/htdocs/langs/fr_FR/suppliers.lang index dcc6215780c..8011bacb061 100644 --- a/htdocs/langs/fr_FR/suppliers.lang +++ b/htdocs/langs/fr_FR/suppliers.lang @@ -24,10 +24,10 @@ RefSupplierShort=Réf. fournisseur ExportDataset_fournisseur_1=Factures fournisseurs et lignes de facture ExportDataset_fournisseur_2=Factures fournisseurs et règlements ApproveThisOrder=Approuver la commande -ConfirmApproveThisOrder=Êtes-vous sûr de vouloir approuver cette commande ? +ConfirmApproveThisOrder=Êtes-vous sûr de vouloir approuver la commande fournisseur % ? DenyingThisOrder=Refuser la commande -ConfirmDenyingThisOrder=Êtes-vous sûr de vouloir refuser cette commande ? -ConfirmCancelThisOrder=Êtes-vous sûr de vouloir annuler cette commande ? +ConfirmDenyingThisOrder=Êtes-vous sûr de vouloir refuser la commande fournisseur % ? +ConfirmCancelThisOrder=Êtes-vous sûr de vouloir annuler la commande fournisseur % ? AddCustomerOrder=Créer commande client AddCustomerInvoice=Créer facture/avoir client AddSupplierOrder=Créer commande fournisseur diff --git a/htdocs/product/stock/class/entrepot.class.php b/htdocs/product/stock/class/entrepot.class.php index 04b5f6341b3..309c18845cd 100644 --- a/htdocs/product/stock/class/entrepot.class.php +++ b/htdocs/product/stock/class/entrepot.class.php @@ -319,20 +319,20 @@ class Entrepot extends CommonObject /** - * \brief Renvoie la liste des entrep�ts ouverts + * Return list of all warehouses + * @return array Array list of warehouses */ - function list_array() + function list_array($status=1) { $liste = array(); $sql = "SELECT rowid, label"; $sql.= " FROM ".MAIN_DB_PREFIX."entrepot"; - $sql.= " WHERE statut = 1"; + $sql.= " WHERE statut = ".$status; $result = $this->db->query($sql) ; $i = 0; $num = $this->db->num_rows($result); - if ( $result ) { while ($i < $num) diff --git a/htdocs/product/stock/class/mouvementstock.class.php b/htdocs/product/stock/class/mouvementstock.class.php index 24af8adeb88..4ac54f0e184 100644 --- a/htdocs/product/stock/class/mouvementstock.class.php +++ b/htdocs/product/stock/class/mouvementstock.class.php @@ -27,7 +27,7 @@ /** * \class MouvementStock - * \brief Classe permettant la gestion des mouvements de stocks + * \brief Class to manage stock movements */ class MouvementStock { @@ -47,7 +47,7 @@ class MouvementStock * 0=input (stock increase after stock transfert), 1=output (stock decrease after stock transfer), * 2=output (stock decrease), 3=input (stock increase) * \param price Unit price HT of product - * \pamam label Label of stock movement + * \param label Label of stock movement * \return int <0 if KO, >0 if OK */ function _create($user, $fk_product, $entrepot_id, $qty, $type, $price=0, $label='') @@ -197,13 +197,13 @@ class MouvementStock // Add movement for sub products if (! $error && $conf->global->PRODUIT_SOUSPRODUITS) { - $error = $this->_createSubProduct($user, $fk_product, $entrepot_id, $qty, $type, 0); // pmp is not change for subproduct + $error = $this->_createSubProduct($user, $fk_product, $entrepot_id, $qty, $type, 0, $label); // pmp is not change for subproduct } // composition module (this is a non official external module) if (! $error && $qty < 0 && $conf->global->MAIN_MODULE_COMPOSITION) { - $error = $this->_createProductComposition($user, $fk_product, $entrepot_id, $qty, $type, 0); // pmp is not change for subproduct + $error = $this->_createProductComposition($user, $fk_product, $entrepot_id, $qty, $type, 0, $label); // pmp is not change for subproduct } if (! $error) @@ -221,10 +221,11 @@ class MouvementStock /** - * \brief Create movement in database for all subproducts - * \return int <0 si ko, 0 si ok + * Create movement in database for all subproducts + * @param label Label of stock movement + * @return int <0 if KO, 0 if OK */ - function _createSubProduct($user, $idProduct, $entrepot_id, $qty, $type, $price=0) + function _createSubProduct($user, $idProduct, $entrepot_id, $qty, $type, $price=0, $label='') { $error = 0; $pids = array(); @@ -256,7 +257,7 @@ class MouvementStock // Create movement for each subproduct foreach($pids as $key => $value) { - $this->_create($user, $pids[$key], $entrepot_id, ($qty * $pqtys[$key]), $type, 0); + $this->_create($user, $pids[$key], $entrepot_id, ($qty * $pqtys[$key]), $type, 0, $label); } return $error; @@ -264,12 +265,13 @@ class MouvementStock /** - * \brief Cree un mouvement en base pour toutes les compositions de produits - * \return int <0 si ko, 0 si ok + * Cree un mouvement en base pour toutes les compositions de produits + * @param label Label of stock movement + * @return int <0 if KO, 0 if OK */ - function _createProductComposition($user, $fk_product, $entrepot_id, $qty, $type, $price=0) + function _createProductComposition($user, $fk_product, $entrepot_id, $qty, $type, $price=0, $label='') { - dol_syslog("MouvementStock::_createProductComposition $user->id, $fk_product, $entrepot_id, $qty, $type, $price"); + dol_syslog("MouvementStock::_createProductComposition $user->id, $fk_product, $entrepot_id, $qty, $type, $price, $label"); $products_compo = array(); $sql = "SELECT fk_product_composition, qte, etat_stock"; @@ -295,7 +297,7 @@ class MouvementStock // Create movement for each subproduct foreach($products_compo as $product) { - $this->_create($user, $product->fk_product_composition, $entrepot_id, ($qty*$product->qte), $type, 0); + $this->_create($user, $product->fk_product_composition, $entrepot_id, ($qty*$product->qte), $type, 0, $label); } return 0; @@ -303,12 +305,13 @@ class MouvementStock /** - * \brief Decrease stock for product and subproducts - * \return int <0 if KO, >0 if OK + * Decrease stock for product and subproducts + * @param label Label of stock movement + * @return int <0 if KO, >0 if OK */ - function livraison($user, $fk_product, $entrepot_id, $qty, $price=0) + function livraison($user, $fk_product, $entrepot_id, $qty, $price=0, $label='') { - return $this->_create($user, $fk_product, $entrepot_id, (0 - $qty), 2, $price); + return $this->_create($user, $fk_product, $entrepot_id, (0 - $qty), 2, $price, $label); } @@ -316,9 +319,9 @@ class MouvementStock * \brief Increase stock for product and subproducts * \return int <0 if KO, >0 if OK */ - function reception($user, $fk_product, $entrepot_id, $qty, $price=0) + function reception($user, $fk_product, $entrepot_id, $qty, $price=0, $label='') { - return $this->_create($user, $fk_product, $entrepot_id, $qty, 3, $price); + return $this->_create($user, $fk_product, $entrepot_id, $qty, 3, $price, $label); }
'; - print $html->selectarray("entrepot_".$i, $entrepot->list_array(), '', $disabled, 0, 0, '', 0, 0, $disabled); - + if (sizeof($listwarehouses)) + { + print $html->selectarray("entrepot_".$i, $listwarehouses, '', $disabled, 0, 0, '', 0, 0, $disabled); + } + else + { + print $langs->trans("NoWarehouseDefined"); + } print "