diff --git a/htdocs/expedition/fiche.php b/htdocs/expedition/fiche.php index 51790d31462..69ec06a8720 100644 --- a/htdocs/expedition/fiche.php +++ b/htdocs/expedition/fiche.php @@ -541,7 +541,16 @@ if ($_GET["action"] == 'create') { foreach($prods_arbo as $key => $value) { - print $value[0]; + //print $value[0]; + $img=''; + if ($value['stock'] < $value['stock_alert']) + { + $img=img_warning($langs->trans("StockTooLow")); + } + print "      -> + ".$value['fullpath']." + (".$value['nb'].") ".$value['nb_total']."   + ".$value['stock']." ".$img.""; } } } diff --git a/htdocs/expedition/index.php b/htdocs/expedition/index.php index 21b59082f51..6dea2c35065 100644 --- a/htdocs/expedition/index.php +++ b/htdocs/expedition/index.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004-2009 Laurent Destailleur + * Copyright (C) 2004-2010 Laurent Destailleur * Copyright (C) 2005-2009 Regis Houssin * * This program is free software; you can redistribute it and/or modify @@ -26,6 +26,7 @@ */ require("../main.inc.php"); +require(DOL_DOCUMENT_ROOT."/commande/commande.class.php"); $langs->load("orders"); $langs->load("sendings"); @@ -34,6 +35,9 @@ $langs->load("sendings"); * View */ +$orderstatic=new Commande($db); +$companystatic=new Societe($db); + $helpurl='EN:Module_Shipments|FR:Module_Expéditions|ES:Módulo_Expediciones'; llxHeader('',$langs->trans("Sendings"),$helpurl); @@ -126,13 +130,18 @@ if ( $db->query($sql) ) $var = True; while ($i < $num) { - $var=!$var; - $obj = $db->fetch_object(); - print ""; - print ''; - print "rowid."\">".img_object($langs->trans("ShowOrder"),"order").' '.$obj->ref.''; - print ''.dol_trunc($obj->nom,20).''; - $i++; + $var=!$var; + $obj = $db->fetch_object(); + print ""; + print ''; + $orderstatic->id=$obj->rowid; + $orderstatic->ref=$obj->ref; + print $orderstatic->getNomUrl(1); + print ''; + print ''; + print ''.dol_trunc($obj->nom,20).''; + print ''; + $i++; } print "
"; } @@ -173,12 +182,15 @@ if ( $resql ) $var = True; while ($i < $num) { - $var=!$var; - $obj = $db->fetch_object($resql); - print "rowid."\">".img_object($langs->trans("ShowOrder"),"order").' '; - print $obj->ref.''; - print ''.$obj->nom.''; - $i++; + $var=!$var; + $obj = $db->fetch_object($resql); + print ""; + $orderstatic->id=$obj->rowid; + $orderstatic->ref=$obj->ref; + print $orderstatic->getNomUrl(1); + print ''; + print ''.$obj->nom.''; + $i++; } print "
"; } @@ -230,9 +242,11 @@ if ($resql) print ''; if ($obj->commande_id) { - print ''; - print img_object($langs->trans("ShowOrder"),"order").' '.$obj->commande_ref.''; - } else print ' '; + $orderstatic->id=$obj->commande_id; + $orderstatic->ref=$obj->commande_ref; + print $orderstatic->getNomUrl(1); + } + else print ' '; print ''; $i++; } diff --git a/htdocs/expedition/shipment.php b/htdocs/expedition/shipment.php index 88e0fdb43e1..01c82b0a086 100644 --- a/htdocs/expedition/shipment.php +++ b/htdocs/expedition/shipment.php @@ -528,7 +528,18 @@ if ($id > 0 || ! empty($ref)) foreach($prods_arbo as $key => $value) { print ''; + + $img=''; + if ($value['stock'] < $value['stock_alert']) + { + $img=img_warning($langs->trans("StockTooLow")); + } + print "      -> + ".$value['fullpath']." + (".$value['nb'].") ".$value['nb_total']."   + ".$value['stock']." ".$img.""; print $value[0]; + print ''."\n"; } } diff --git a/htdocs/langs/en_US/products.lang b/htdocs/langs/en_US/products.lang index ca1e61ddfa3..f4875320235 100644 --- a/htdocs/langs/en_US/products.lang +++ b/htdocs/langs/en_US/products.lang @@ -106,9 +106,9 @@ ServiceLimitedDuration=If product is a service with limited duration: MultiPricesAbility=Activate the multi-prices MultiPricesNumPrices=Number of price MultiPriceLevelsName=Price categories -AssociatedProductsAbility=Activate the associated products -AssociatedProducts=Associated products -AssociatedProductsNumber=Number of associated products +AssociatedProductsAbility=Activate the sub-products +AssociatedProducts=Sub-products +AssociatedProductsNumber=Number of products composing this product EditAssociate=Associate Translation=Translation KeywordFilter=Keyword filter diff --git a/htdocs/langs/fr_FR/products.lang b/htdocs/langs/fr_FR/products.lang index 3edf363debe..3700e98f3b4 100644 --- a/htdocs/langs/fr_FR/products.lang +++ b/htdocs/langs/fr_FR/products.lang @@ -106,10 +106,10 @@ ServiceLimitedDuration=Si produit de type service à durée limitée : MultiPricesAbility=Prise en charges de prix multiples MultiPricesNumPrices=Nombre de prix MultiPriceLevelsName=Catégorie de prix -AssociatedProductsAbility=Prise en charges des produits associés -AssociatedProducts=Produits associés -AssociatedProductsNumber=Nbre de produits associés -EditAssociate=Associer +AssociatedProductsAbility=Prise en charges des produits composés +AssociatedProducts=Composition +AssociatedProductsNumber=Nbre de sous-produits composant ce produit +EditAssociate=Composer Translation=Traduction KeywordFilter=Filtre par mot-clé CategoryFilter=Filtre par catégorie @@ -117,7 +117,7 @@ ProductToAddSearch=Recherche des produits à ajouter AddDel=Ajouter/Retirer Quantity=Quantité NoMatchFound=Aucun résultat n'a été trouvé -ProductAssociationList=Liste des produits/services associés : nom du produit/service (quantité affectée) +ProductAssociationList=Liste des produits/services composant ce produit: Le nombre entre paraenthèse est la quantité affectée dans cette composition. ErrorAssociationIsFatherOfThis=L'un des produits sélectionnés est parent du produit en cours DeleteProduct=Supprimer un produit/service ConfirmDeleteProduct=Etes-vous sûr de vouloir supprimer ce produit/service ? diff --git a/htdocs/product.class.php b/htdocs/product.class.php index c9781df0308..fefe9a678b7 100644 --- a/htdocs/product.class.php +++ b/htdocs/product.class.php @@ -1478,7 +1478,7 @@ class Product extends CommonObject * \brief Lie un produit associe au produit/service * \param id_pere Id du produit auquel sera lie le produit a lier * \param id_fils Id du produit a lier - * \return int < 0 si erreur, > 0 si ok + * \return int < 0 if KO, > 0 if OK */ function add_sousproduit($id_pere, $id_fils,$qty) { @@ -1839,15 +1839,16 @@ class Product extends CommonObject } /** - * \brief fonction recursive uniquement utilisee par get_arbo_each_prod, recompose l'arborescence des sousproduits + * \brief Fonction recursive uniquement utilisee par get_arbo_each_prod, recompose l'arborescence des sousproduits * \remarks Define value of this->res * \param multiply Because each sublevel must be multiplicated by parent nb * \return void */ function fetch_prod_arbo($prod, $compl_path="", $multiply=1, $level=1) { - global $langs; + global $conf,$langs; + $product = new Product($this->db); foreach($prod as $nom_pere => $desc_pere) { if (is_array($desc_pere)) // If this parent desc is an array, this is an array of childs @@ -1856,8 +1857,6 @@ class Product extends CommonObject { //print "XXX ".$desc_pere[1]." multiply=".$multiply; $img=""; - $trueValue=$desc_pere[1]*$multiply; - $product = new Product($this->db); $this->fetch($desc_pere[0]); $this->load_stock(); if ($this->stock_entrepot[1] < $this->seuil_stock_alerte) @@ -1865,18 +1864,35 @@ class Product extends CommonObject $img=img_warning($langs->trans("StockTooLow")); } $this->res[]= array( - "      -> +/* "      -> ".$compl_path.stripslashes($nom_pere)." - (".$desc_pere[1].") ".$trueValue."   + (".$desc_pere[1].") ".($desc_pere[1]*$multiply)."   ".$this->stock_entrepot[1]." ".$img."", - $desc_pere[0], - 'fullpath' => $compl_path.$nom_pere); + $desc_pere[0], // Id product +*/ 'id'=>$desc_pere[0], // Id product + 'nb'=>$desc_pere[1], // Nb of units that compose parent product + 'nb_total'=>$desc_pere[1]*$multiply, // Nb of units for all nb of product + 'stock'=>$this->stock_entrepot[1], // Stock + 'stock_alert'=>$this->seuil_stock_alerte, // Stock alert + 'fullpath' => $compl_path.$nom_pere, // Label + 'type'=>$desc_pere[2] // Nb of units that compose parent product + ); } else { - $this->res[]= array($compl_path.$nom_pere." (".$desc_pere[1].")", - $desc_pere[0], - 'fullpath' => $compl_path.$nom_pere); + $this->fetch($desc_pere[0]); + $this->load_stock(); + $this->res[]= array( +/* $compl_path.$nom_pere." (".$desc_pere[1].")", + $desc_pere[0], // Id product +*/ 'id'=>$desc_pere[0], // Id product + 'nb'=>$desc_pere[1], // Nb of units that compose parent product + 'nb_total'=>$desc_pere[1], // Nb of units for all nb of product + 'stock'=>$this->stock_entrepot[1], // Stock + 'stock_alert'=>$this->seuil_stock_alerte, // Stock alert + 'fullpath' => $compl_path.$nom_pere, // Label + 'type'=>$desc_pere[2] // Nb of units that compose parent product + ); } } else if($nom_pere != "0" && $nom_pere != "1") @@ -1952,15 +1968,15 @@ class Product extends CommonObject } /** - * \brief Return all parent products + * \brief Return all parent products fo current product * \return array prod */ function getParent() { - $sql = "SELECT p.label as label,p.rowid,pa.fk_product_pere as id"; - $sql.= " FROM ".MAIN_DB_PREFIX."product_association as pa"; - $sql.= ", ".MAIN_DB_PREFIX."product as p"; + $sql = "SELECT p.label as label,p.rowid,pa.fk_product_pere as id,p.fk_product_type"; + $sql.= " FROM ".MAIN_DB_PREFIX."product_association as pa,"; + $sql.= " ".MAIN_DB_PREFIX."product as p"; $sql.= " WHERE p.rowid = pa.fk_product_pere"; $sql.= " AND p.rowid = ".$this->id; @@ -1982,12 +1998,13 @@ class Product extends CommonObject } /** - * \brief Return childs - * \return array prod + * \brief Return childs of prodcut with if fk_parent + * \param fk_parent Id of product to search childs of + * \return array Prod */ function getChildsArbo($fk_parent) { - $sql = "SELECT p.rowid, p.label as label, pa.qty as qty, pa.fk_product_fils as id"; + $sql = "SELECT p.rowid, p.label as label, pa.qty as qty, pa.fk_product_fils as id, p.fk_product_type"; $sql.= " FROM ".MAIN_DB_PREFIX."product as p"; $sql.= ", ".MAIN_DB_PREFIX."product_association as pa"; $sql.= " WHERE p.rowid = pa.fk_product_fils"; @@ -1999,10 +2016,15 @@ class Product extends CommonObject $prods = array(); while ($rec = $this->db->fetch_array($res)) { + //$prods[addslashes($rec['label'])]= array(0=>$rec['id'],1=>$rec['qty'],2=>$rec['fk_product_type']); $prods[addslashes($rec['label'])]= array(0=>$rec['id'],1=>$rec['qty']); - foreach($this->getChildsArbo($rec['id']) as $keyChild => $valueChild) - $prods[addslashes($rec['label'])][$keyChild] = $valueChild; + $listofchilds=$this->getChildsArbo($rec['id']); + foreach($listofchilds as $keyChild => $valueChild) + { + $prods[addslashes($rec['label'])][$keyChild] = $valueChild; + } } + //var_dump($prods); return $prods; } else @@ -2027,6 +2049,7 @@ class Product extends CommonObject $parent[$key][$keyChild] = $valueChild; } } + //var_dump($parent); // concatenation foreach($parent as $key => $value) { diff --git a/htdocs/product/sousproduits/fiche.php b/htdocs/product/sousproduits/fiche.php index dfce8c21627..27b52c6f02f 100644 --- a/htdocs/product/sousproduits/fiche.php +++ b/htdocs/product/sousproduits/fiche.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004-2008 Laurent Destailleur + * Copyright (C) 2004-2010 Laurent Destailleur * Copyright (C) 2005 Eric Seigne * Copyright (C) 2005-2009 Regis Houssin * Copyright (C) 2006 Andre Cianfarani @@ -67,7 +67,7 @@ if ($action == 'add_prod' && $cancel <> $langs->trans("Cancel") && ($user->rights->produit->creer || $user->rights->service->creer)) { - + $error=0; for($i=0;$i<$_POST["max_prod"];$i++) { // print "
: ".$_POST["prod_id_chk".$i]; @@ -79,26 +79,33 @@ $cancel <> $langs->trans("Cancel") && } else { + $error++; $action = 're-edit'; - if($product->error == "isFatherOfThis") - $mesg = $langs->trans("ErrorAssociationIsFatherOfThis"); + if ($product->error == "isFatherOfThis") $mesg = $langs->trans("ErrorAssociationIsFatherOfThis"); + else $mesg=$product->error; } } else { - if($product->del_sousproduit($id, $_POST["prod_id_".$i])) + if ($product->del_sousproduit($id, $_POST["prod_id_".$i]) > 0) { $action = 'edit'; } else { + $error++; $action = 're-edit'; + $mesg=$product->error; } - - } } + if (! $error) + { + header("Location: ".$_SERVER["PHP_SELF"].'?id='.$product->id); + exit; + } } + // action recherche des produits par mot-cle et/ou par categorie if($action == 'search' ) { @@ -180,27 +187,32 @@ if ($id || $ref) print ''.$langs->trans("Label").''.$product->libelle.''; print ''; + // Number of subproducts $product->get_sousproduits_arbo (); print ''.$langs->trans("AssociatedProductsNumber").''.sizeof($product->get_arbo_each_prod()).''; - // associations sousproduits + // List of subproducts $prods_arbo = $product->get_arbo_each_prod(); if(sizeof($prods_arbo) > 0) { print ''; print ''.$langs->trans("ProductAssociationList").'
'; - foreach($prods_arbo as $key => $value) + print ''; + foreach($prods_arbo as $value) { - $productstatic->id=$value[1]; - $productstatic->type=0; - //$productstatic->ref=$value[0]; + $productstatic->id=$value['id']; + $productstatic->type=$value['type']; + $productstatic->ref=$value['fullpath']; //var_dump($value); //print '
'.$productstatic->ref.'
'; //print $productstatic->getNomUrl(1).'
'; - print $value[0]; // This contains a tr line. + //print $value[0]; // This contains a tr line. + print ''; + print ''; + print ''; + print ''; } - - + print '
'.$productstatic->getNomUrl(1).' ('.$value['nb'].')
'; print ''; } @@ -225,27 +237,45 @@ if ($id || $ref) // Reference print ''.$langs->trans("Ref").''; print $html->showrefnav($product,'ref','',1,'ref'); - print ''; - - if ($product->is_photo_available($conf->produit->dir_output)) - { - // Photo - print ''; - $nbphoto=$product->show_photos($conf->produit->dir_output,1,1,0); print ''; - } print ''; - // Libelle + // Label print ''.$langs->trans("Label").''.$product->libelle.''; print ''; - // Nombre de sousproduits associes + // Number of subproducts $product->get_sousproduits_arbo (); print ''.$langs->trans("AssociatedProductsNumber").''.sizeof($product->get_arbo_each_prod()).''; print ''; + // List of subproducts + $prods_arbo = $product->get_arbo_each_prod(); + //var_dump($prods_arbo); + if(sizeof($prods_arbo) > 0) + { + print ''; + print ''.$langs->trans("ProductAssociationList").'
'; + print ''; + foreach($prods_arbo as $value) + { + $productstatic->id=$value['id']; + $productstatic->type=$value['type']; + $productstatic->ref=$value['fullpath']; + //var_dump($value); + //print '
'.$productstatic->ref.'
'; + //print $productstatic->getNomUrl(1).'
'; + //print $value[0]; // This contains a tr line. + print ''; + print ''; + print ''; + print ''; + } + print '
'.$productstatic->getNomUrl(1).' ('.$value['nb'].')
'; + print ''; + } + print ''; print '
'; @@ -253,6 +283,7 @@ if ($id || $ref) print '
'; print ''; print ''; + print ''; print '
'.$langs->trans("ProductToAddSearch").'
'; print ''; print $langs->trans("KeywordFilter"); @@ -299,14 +330,16 @@ if ($id || $ref) if($objp->rowid != $id) { // check if a product is not already a parent product of this one - $prod_arbo=new Product($db,$objp->rowid); + $prod_arbo=new Product($db); + $prod_arbo->id=$objp->rowid; if ($prod_arbo->type==2 || $prod_arbo->type==3) { $is_pere=0; $prod_arbo->get_sousproduits_arbo (); // associations sousproduits $prods_arbo = $prod_arbo->get_arbo_each_prod(); - if(sizeof($prods_arbo) > 0) { + if (sizeof($prods_arbo) > 0) + { foreach($prods_arbo as $key => $value) { if ($value[1]==$id) @@ -354,8 +387,15 @@ if ($id || $ref) dol_print_error($db); } print ''; - if($num > 0) print '

trans("Update").'">
'; + + if($num > 0) + { + print '
trans("Update").'">'; + print '     '; + print '
'; + } + print '
'; }