diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index 60314de1a1c..44d864743cc 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -54,7 +54,7 @@ $sall=isset($_GET['sall'])?trim($_GET['sall']):trim($_POST['sall']); $projectid=isset($_GET['projectid'])?$_GET['projectid']:0; // Security check -$socid=isset($_GET['socid'])?$_GET['socid']:$_POST['socid']; +$socid=GETPOST("socid"); $facid=GETPOST("id"); if (empty($facid)) $facid=GETPOST("facid"); // For backward compatibility $ref=GETPOST("ref"); diff --git a/htdocs/contrat/fiche.php b/htdocs/contrat/fiche.php index d456d29c585..a77962ab725 100644 --- a/htdocs/contrat/fiche.php +++ b/htdocs/contrat/fiche.php @@ -42,7 +42,7 @@ $langs->load("bills"); $langs->load("products"); // Security check -$socid=0; +$socid=GETPOST("socid"); $contratid = isset($_GET["id"])?$_GET["id"]:''; if ($user->societe_id) $socid=$user->societe_id; $result=restrictedArea($user,'contrat',$contratid,'contrat'); @@ -181,7 +181,7 @@ if ($_POST["action"] == 'classin') if ($_POST["action"] == 'addline' && $user->rights->contrat->creer) { - if ($_POST["pqty"] && (($_POST["pu"] != '' && $_POST["desc"]) || $_POST["p_idprod"])) + if ($_POST["pqty"] && (($_POST["pu"] != '' && $_POST["desc"]) || $_POST["idprod"])) { $contrat = new Contrat($db); $ret=$contrat->fetch($_GET["id"]); @@ -223,10 +223,10 @@ if ($_POST["action"] == 'addline' && $user->rights->contrat->creer) // Ecrase $desc par celui du produit // Ecrase $txtva par celui du produit // Ecrase $base_price_type par celui du produit - if ($_POST['p_idprod']) + if ($_POST['idprod']) { - $prod = new Product($db, $_POST['p_idprod']); - $prod->fetch($_POST['p_idprod']); + $prod = new Product($db, $_POST['idprod']); + $prod->fetch($_POST['idprod']); $tva_tx = get_default_tva($mysoc,$contrat->client,$prod->id); $tva_npr = get_default_npr($mysoc,$contrat->client,$prod->id); @@ -236,12 +236,14 @@ if ($_POST["action"] == 'addline' && $user->rights->contrat->creer) { $pu_ht = $prod->multiprices[$contrat->client->price_level]; $pu_ttc = $prod->multiprices_ttc[$contrat->client->price_level]; + $price_min = $prod->multiprices_min[$contrat->client->price_level]; $price_base_type = $prod->multiprices_base_type[$contrat->client->price_level]; } else { $pu_ht = $prod->price; $pu_ttc = $prod->price_ttc; + $price_min = $prod->price_min; $price_base_type = $prod->price_base_type; } @@ -277,23 +279,31 @@ if ($_POST["action"] == 'addline' && $user->rights->contrat->creer) $info_bits=0; if ($tva_npr) $info_bits |= 0x01; - - // Insert line - $result = $contrat->addline( - $desc, - $pu_ht, - $_POST["pqty"], - $tva_tx, - $localtax1_tx, - $localtax2_tx, - $_POST["p_idprod"], - $_POST["premise"], - $date_start, - $date_end, - $price_base_type, - $pu_ttc, - $info_bits - ); + + if($price_min && (price2num($pu_ht)*(1-price2num($_POST['remise_percent'])/100) < price2num($price_min))) + { + $contrat->error = $langs->trans("CantBeLessThanMinPrice",price2num($price_min,'MU').' '.$langs->trans("Currency".$conf->monnaie)) ; + $result = -1 ; + } + else + { + // Insert line + $result = $contrat->addline( + $desc, + $pu_ht, + $_POST["pqty"], + $tva_tx, + $localtax1_tx, + $localtax2_tx, + $_POST["idprod"], + $_POST["premise"], + $date_start, + $date_end, + $price_base_type, + $pu_ttc, + $info_bits + ); + } if ($result > 0) { @@ -344,6 +354,8 @@ if ($_POST["action"] == 'updateligne' && $user->rights->contrat->creer && ! $_PO $contratline->date_fin_validite=$date_end_update; $contratline->date_cloture=$date_end_real_update; $contratline->fk_user_cloture=$user->id; + + // TODO verifier price_min si fk_product et multiprix $result=$contratline->update($user); if ($result > 0) @@ -463,96 +475,80 @@ if ($_GET["action"] == 'create') dol_fiche_head($head, $a, $langs->trans("AddContract"), 0, 'contract'); if ($mesg) print $mesg; - - $new_contrat = new Contrat($db); - - $sql = "SELECT s.nom, s.prefix_comm, s.rowid"; - $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; - $sql.= " WHERE s.rowid = ".$_GET["socid"]; - - $resql=$db->query($sql); - if ($resql) + + $soc = new Societe($db); + $soc->fetch($socid); + + print '
\n"; +// TODO A quoi ca sert ? +/* if ($propalid) { - /* - * Produits - */ print '