From 7906a0d4a526aaf44f66a2d093c8dcf85a835400 Mon Sep 17 00:00:00 2001 From: Andre Cianfarani Date: Mon, 20 Mar 2006 11:34:32 +0000 Subject: [PATCH] modifs --- htdocs/product/sousproduits/fiche.php | 115 ++++++++++++++------------ 1 file changed, 60 insertions(+), 55 deletions(-) diff --git a/htdocs/product/sousproduits/fiche.php b/htdocs/product/sousproduits/fiche.php index 63e906e61ea..540c9885157 100644 --- a/htdocs/product/sousproduits/fiche.php +++ b/htdocs/product/sousproduits/fiche.php @@ -50,6 +50,12 @@ $id=isset($_GET["id"])?$_GET["id"]:$_POST["id"]; $action=isset($_GET["action"])?$_GET["action"]:$_POST["action"]; $cancel=isset($_GET["cancel"])?$_GET["cancel"]:$_POST["cancel"]; +if ($action <> 're-edit') + { + $product = new Product($db); + if ($id) $result = $product->fetch($id); + if ($ref) $result = $product->fetch($ref); + } if (!$user->rights->produit->lire) accessforbidden(); @@ -58,47 +64,43 @@ $html = new Form($db); $types[0] = $langs->trans("Product"); $types[1] = $langs->trans("Service"); -// Action mise a jour d'un produit ou service -if ($action == 'update' && +// Action association d'un sousproduit +if ($action == 'add_prod' && $cancel <> $langs->trans("Cancel") && $user->rights->produit->creer) { - $product = new Product($db); - if ($product->fetch($_POST["id"])) - { - $product->ref = stripslashes($_POST["ref"]); - $product->libelle = stripslashes($_POST["libelle"]); - if ( isset( $_POST["price"] ) ) - $product->price = stripslashes($_POST["price"]); - $product->tva_tx = $_POST["tva_tx"]; - $product->description = stripslashes($_POST["desc"]); - $product->note = stripslashes($_POST["note"]); - $product->envente = $_POST["statut"]; - $product->seuil_stock_alerte = $_POST["seuil_stock_alerte"]; - $product->duration_value = $_POST["duration_value"]; - $product->duration_unit = $_POST["duration_unit"]; - - if ($product->check()) - { - if ($product->update($product->id, $user) > 0) - { - $action = ''; - $_GET["id"] = $_POST["id"]; - } - else - { - $action = 're-edit'; - $_GET["id"] = $_POST["id"]; - $mesg = $product->mesg_error; - } + + for($i=0;$i<$_POST["max_prod"];$i++) + { + // print "
: ".$_POST["prod_id_chk".$i]; + if($_POST["prod_id_chk".$i] != "") + { + if($product->add_sousproduit($id, $_POST["prod_id_".$i],$_POST["prod_qty_".$i]) ) + { + $action = 'edit'; + } + else + { + $action = 're-edit'; + $mesg = "erreur"; + } + } + else + { + if($product->del_sousproduit($id, $_POST["prod_id_".$i])) + { + $action = 'edit'; + } + else + { + $action = 're-edit'; + $mesg = "erreur"; + } + + + } } - else - { - $action = 're-edit'; - $_GET["id"] = $_POST["id"]; - $mesg = $langs->trans("ErrorProductBadRefOrLabel"); - } - } + } // action recherche des produits par mot-clé et/ou par catégorie if($action == 'search' ) @@ -142,8 +144,6 @@ if ($cancel == $langs->trans("Cancel")) exit; } - - llxHeader("","",$langs->trans("ProductServiceCard")); $html = new Form($db); @@ -154,13 +154,6 @@ $html = new Form($db); if ($id || $ref) { - if ($action <> 're-edit') - { - $product = new Product($db); - if ($id) $result = $product->fetch($id); - if ($ref) $result = $product->fetch($ref); - } - if ( $result ) { @@ -341,7 +334,7 @@ if ($id || $ref) $product->get_sousproduits_arbo (); print ''.$langs->trans("AssociatedProductsNumber").''.sizeof($product->get_arbo_each_prod()).''; print ''; - print ''.$langs->trans("ProductSearch").''; + print ''.$langs->trans("ProductToAddSearch").''; print ''; print ''; print ''; - print ''; print '
'; print $langs->trans("KeywordFilter"); @@ -353,35 +346,47 @@ if ($id || $ref) // if(MAIN_MODULE_CATEGORIE) print '
'.$html->select_all_categories($catMere).'
'; - print ''; - print ''; - print ''; - print ''; + print '
RefLibelleAjouter

'; + if($action == 'search') { + print ''; + print ''; + print ''; + print 'num_rows($resql); $i=0; + if($num == 0) + print ''; while ($i < $num) { $objp = $db->fetch_object($resql); - print ''; + print "\n"; print ''; print ''; - print ''; + print ''; + print ''; print ''; print ''; $i++; } + } else { dolibarr_print_error($db); } + print ''; + if($num > 0) + print ''; + print '
'.$langs->trans("Ref").''.$langs->trans("Label").''.$langs->trans("AddDel").''.$langs->trans("Quantity").'
'.$langs->trans("NoMatchFound").'
'.$objp->ref.''.$objp->label.'
'; } - print '
'; + print '
'; print '';