diff --git a/htdocs/comm/propal.php b/htdocs/comm/propal.php index 6b6faa5732f..73b6dc59b81 100644 --- a/htdocs/comm/propal.php +++ b/htdocs/comm/propal.php @@ -633,18 +633,25 @@ else if ($action == "setabsolutediscount" && $user->rights->propale->creer) //Ajout d'une ligne produit dans la propale else if ($action == "addline" && $user->rights->propale->creer) { - if (empty($_POST['idprod']) && GETPOST('type') < 0) + $idprod=GETPOST('idprod', 'int'); + //var_dump($_POST); + if (empty($idprod) && GETPOST('type') < 0) { setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Type")), 'errors'); $error++; } - if (empty($_POST['idprod']) && (! isset($_POST["np_price"]) || $_POST["np_price"]=='')) // Unit price can be 0 but not '' + if (empty($idprod) && (!(GETPOST('price_ht') >= 0) || GETPOST('price_ht') == '')) // Unit price can be 0 but not '' { setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("UnitPriceHT")), 'errors'); $error++; } + if (empty($idprod) && ! GETPOST('product_desc')) + { + setEventMessage($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Description")), 'errors'); + $error++; + } - if (! $error && isset($_POST['qty']) && ((GETPOST('np_price')!='' && (GETPOST('np_desc') || GETPOST('dp_desc'))) || GETPOST('idprod'))) + if (! $error && (GETPOST('qty') >= 0) && (GETPOST('product_desc') || ! empty($idprod))) { $pu_ht=0; $pu_ttc=0; @@ -654,10 +661,10 @@ else if ($action == "addline" && $user->rights->propale->creer) // Ecrase $pu par celui du produit // Ecrase $desc par celui du produit // Ecrase $txtva par celui du produit - if (GETPOST('idprod')) + if (! empty($idprod)) { $prod = new Product($db); - $prod->fetch(GETPOST('idprod')); + $prod->fetch($idprod); $tva_tx = get_default_tva($mysoc,$object->client,$prod->id); $localtax1_tx= get_localtax($tva_tx, 1, $object->client); //get_default_localtax($mysoc,$object->client,1,$prod->id); @@ -681,10 +688,10 @@ else if ($action == "addline" && $user->rights->propale->creer) } // Update if prices fields are defined - if (GETPOST('dp_price_ht') || GETPOST('dp_price_ttc')) + if (GETPOST('update_price') && (GETPOST('price_ht') || GETPOST('price_ttc'))) { - $price_ht=price2num(GETPOST('dp_price_ht'), 'MU'); - $price_ttc=price2num(GETPOST('dp_price_ttc'), 'MU'); + $price_ht=price2num(GETPOST('price_ht'), 'MU'); + $price_ttc=price2num(GETPOST('price_ttc'), 'MU'); if ($price_base_type == 'TTC' && $price_ttc != $pu_ttc) { @@ -712,43 +719,54 @@ else if ($action == "addline" && $user->rights->propale->creer) } } - // Define output language - if (! empty($conf->global->MAIN_MULTILANGS) && ! empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) - { - $outputlangs = $langs; - $newlang=''; - if (empty($newlang) && GETPOST('lang_id')) $newlang=GETPOST('lang_id'); - if (empty($newlang)) $newlang=$object->client->default_lang; - if (! empty($newlang)) - { - $outputlangs = new Translate("",$conf); - $outputlangs->setDefaultLang($newlang); + if (GETPOST('update_desc')) { + + $desc = (GETPOST('product_desc')?GETPOST('product_desc'):''); + + } else { + + // Define output language + if (! empty($conf->global->MAIN_MULTILANGS) && ! empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) + { + $outputlangs = $langs; + $newlang=''; + if (empty($newlang) && GETPOST('lang_id')) $newlang=GETPOST('lang_id'); + if (empty($newlang)) $newlang=$object->client->default_lang; + if (! empty($newlang)) + { + $outputlangs = new Translate("",$conf); + $outputlangs->setDefaultLang($newlang); + } + + $desc = (! empty($prod->multilangs[$outputlangs->defaultlang]["description"])) ? $prod->multilangs[$outputlangs->defaultlang]["description"] : $prod->description; + } + else + { + $desc = $prod->description; } - $desc = (! empty($prod->multilangs[$outputlangs->defaultlang]["description"])) ? $prod->multilangs[$outputlangs->defaultlang]["description"] : $prod->description; - } - else - { - $desc = $prod->description; + $desc.= ($desc && GETPOST('product_desc')) ? ((dol_textishtml($desc) || dol_textishtml(GETPOST('product_desc')))?"
\n":"\n") : ""; + $desc.= GETPOST('product_desc'); } - $desc.= ($desc && GETPOST('dp_desc')) ? ((dol_textishtml($desc) || dol_textishtml(GETPOST('dp_desc')))?"
\n":"\n") : ""; - $desc.= GETPOST('dp_desc'); + $label = ((GETPOST('update_label') && GETPOST('product_label')) ? GETPOST('product_label'):''); + $type = $prod->type; - $fournprice=(GETPOST('dp_fournprice')?GETPOST('dp_fournprice'):''); - $buyingprice=(GETPOST('dp_buying_price')?GETPOST('dp_buying_price'):''); + $fournprice=(GETPOST('fournprice')?GETPOST('fournprice'):''); + $buyingprice=(GETPOST('buying_price')?GETPOST('buying_price'):''); } else { - $pu_ht=GETPOST('np_price'); - $tva_tx=str_replace('*','',GETPOST('np_tva_tx')); - $tva_npr=preg_match('/\*/',GETPOST('np_tva_tx'))?1:0; - $desc=GETPOST('np_desc'); + $pu_ht=GETPOST('price_ht'); + $tva_tx=str_replace('*','',GETPOST('tva_tx')); + $tva_npr=preg_match('/\*/',GETPOST('tva_tx'))?1:0; + $label=(GETPOST('product_label')?GETPOST('product_label'):''); + $desc=GETPOST('product_desc'); $type=GETPOST('type'); $localtax1_tx=get_localtax($tva_tx,1,$object->client); $localtax2_tx=get_localtax($tva_tx,2,$object->client); - $fournprice=(GETPOST('np_fournprice')?GETPOST('np_fournprice'):''); - $buyingprice=(GETPOST('np_buying_price')?GETPOST('np_buying_price'):''); + $fournprice=(GETPOST('fournprice')?GETPOST('fournprice'):''); + $buyingprice=(GETPOST('buying_price')?GETPOST('buying_price'):''); } $info_bits=0; @@ -756,31 +774,32 @@ else if ($action == "addline" && $user->rights->propale->creer) if (! empty($price_min) && (price2num($pu_ht)*(1-price2num(GETPOST('remise_percent'))/100) < price2num($price_min))) { - $mesg = $langs->trans("CantBeLessThanMinPrice",price2num($price_min,'MU').' '.$langs->trans("Currency".$conf->currency)); + $mesg = $langs->trans("CantBeLessThanMinPrice",price2num($price_min,'MU').getCurrencySymbol($conf->currency)); setEventMessage($mesg, 'errors'); } else { // Insert line $result=$object->addline( - $id, - $desc, - $pu_ht, - GETPOST('qty'), - $tva_tx, - $localtax1_tx, - $localtax2_tx, - GETPOST('idprod'), - GETPOST('remise_percent'), - $price_base_type, - $pu_ttc, - $info_bits, - $type, - -1, - 0, - GETPOST('fk_parent_line'), - $fournprice, - $buyingprice + $id, + $desc, + $pu_ht, + GETPOST('qty'), + $tva_tx, + $localtax1_tx, + $localtax2_tx, + $idprod, + GETPOST('remise_percent'), + $price_base_type, + $pu_ttc, + $info_bits, + $type, + -1, + 0, + GETPOST('fk_parent_line'), + $fournprice, + $buyingprice, + $label ); if ($result > 0) @@ -803,17 +822,14 @@ else if ($action == "addline" && $user->rights->propale->creer) unset($_POST['qty']); unset($_POST['type']); - - unset($_POST['np_price']); - unset($_POST['np_tva_tx']); - unset($_POST['np_desc']); - unset($_POST['np_fournprice']); - unset($_POST['np_buying_price']); - - unset($_POST['dp_desc']); - unset($_POST['dp_price']); - unset($_POST['dp_fournprice']); - unset($_POST['dp_buying_price']); + unset($_POST['price_ht']); + unset($_POST['price_ttc']); + unset($_POST['tva_tx']); + unset($_POST['product_ref']); + unset($_POST['product_label']); + unset($_POST['product_desc']); + unset($_POST['fournprice']); + unset($_POST['buying_price']); } else { @@ -1562,25 +1578,16 @@ print ''; $result = $object->getLinesArray(); if (! empty($object->lines)) $object->printObjectLines($action,$mysoc,$soc,$lineid,0,$hookmanager); -/* - * Form to add new line - */ +// Form to add new line if ($object->statut == 0 && $user->rights->propale->creer) { if ($action != 'editline') { $var=true; - // Add free products/services + // Add free or predefined products/services $object->formAddFreeProduct(0,$mysoc,$soc,$hookmanager); - // Add predefined products/services - if ($conf->product->enabled || $conf->service->enabled) - { - $var=!$var; - $object->formAddPredefinedProduct(0,$mysoc,$soc,$hookmanager); - } - $parameters=array(); $reshook=$hookmanager->executeHooks('formAddObject',$parameters,$object,$action); // Note that $action and $object may have been modified by hook } diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 2d5a785e353..857de5cab90 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -309,7 +309,7 @@ class Propal extends CommonObject * * @see add_product */ - function addline($propalid, $desc, $pu_ht, $qty, $txtva, $txlocaltax1=0, $txlocaltax2=0, $fk_product=0, $remise_percent=0, $price_base_type='HT', $pu_ttc=0, $info_bits=0, $type=0, $rang=-1, $special_code=0, $fk_parent_line=0, $fk_fournprice=null, $pa_ht = 0) + function addline($propalid, $desc, $pu_ht, $qty, $txtva, $txlocaltax1=0, $txlocaltax2=0, $fk_product=0, $remise_percent=0, $price_base_type='HT', $pu_ttc=0, $info_bits=0, $type=0, $rang=-1, $special_code=0, $fk_parent_line=0, $fk_fournprice=null, $pa_ht = 0, $label='') { global $conf; @@ -380,6 +380,7 @@ class Propal extends CommonObject $this->line=new PropaleLigne($this->db); $this->line->fk_propal=$propalid; + $this->line->label=$label; $this->line->desc=$desc; $this->line->qty=$qty; $this->line->tva_tx=$txtva; @@ -462,7 +463,7 @@ class Propal extends CommonObject * @param int $pa_ht Buying price without tax * @return int 0 if OK, <0 if KO */ - function updateline($rowid, $pu, $qty, $remise_percent, $txtva, $txlocaltax1=0, $txlocaltax2=0, $desc='', $price_base_type='HT', $info_bits=0, $special_code=0, $fk_parent_line=0, $skip_update_total=0, $fk_fournprice=null, $pa_ht=0) + function updateline($rowid, $pu, $qty, $remise_percent, $txtva, $txlocaltax1=0, $txlocaltax2=0, $desc='', $price_base_type='HT', $info_bits=0, $special_code=0, $fk_parent_line=0, $skip_update_total=0, $fk_fournprice=null, $pa_ht=0, $label='') { global $conf,$user,$langs; @@ -519,6 +520,7 @@ class Propal extends CommonObject } $this->line->rowid = $rowid; + $this->line->label = $label; $this->line->desc = $desc; $this->line->qty = $qty; $this->line->tva_tx = $txtva; @@ -536,9 +538,9 @@ class Propal extends CommonObject $this->line->fk_parent_line = $fk_parent_line; $this->line->skip_update_total = $skip_update_total; - // infos marge - $this->line->fk_fournprice = $fk_fournprice; - $this->line->pa_ht = $pa_ht; + // infos marge + $this->line->fk_fournprice = $fk_fournprice; + $this->line->pa_ht = $pa_ht; // TODO deprecated $this->line->price=$price; @@ -737,26 +739,27 @@ class Propal extends CommonObject $fk_parent_line = 0; } - $result = $this->addline( - $this->id, - $this->lines[$i]->desc, - $this->lines[$i]->subprice, - $this->lines[$i]->qty, - $this->lines[$i]->tva_tx, - $this->lines[$i]->localtax1_tx, - $this->lines[$i]->localtax2_tx, - $this->lines[$i]->fk_product, - $this->lines[$i]->remise_percent, - 'HT', - 0, - 0, - $this->lines[$i]->product_type, - $this->lines[$i]->rang, - $this->lines[$i]->special_code, - $fk_parent_line, - $this->lines[$i]->fk_fournprice, - $this->lines[$i]->pa_ht - ); + $result = $this->addline( + $this->id, + $this->lines[$i]->label, + $this->lines[$i]->desc, + $this->lines[$i]->subprice, + $this->lines[$i]->qty, + $this->lines[$i]->tva_tx, + $this->lines[$i]->localtax1_tx, + $this->lines[$i]->localtax2_tx, + $this->lines[$i]->fk_product, + $this->lines[$i]->remise_percent, + 'HT', + 0, + 0, + $this->lines[$i]->product_type, + $this->lines[$i]->rang, + $this->lines[$i]->special_code, + $fk_parent_line, + $this->lines[$i]->fk_fournprice, + $this->lines[$i]->pa_ht + ); if ($result < 0) { @@ -1073,7 +1076,7 @@ class Propal extends CommonObject /* * Lignes propales liees a un produit ou non */ - $sql = "SELECT d.rowid, d.fk_propal, d.fk_parent_line, d.description, d.price, d.tva_tx, d.localtax1_tx, d.localtax2_tx, d.qty, d.fk_remise_except, d.remise_percent, d.subprice, d.fk_product,"; + $sql = "SELECT d.rowid, d.fk_propal, d.fk_parent_line, d.label as custom_label, d.description, d.price, d.tva_tx, d.localtax1_tx, d.localtax2_tx, d.qty, d.fk_remise_except, d.remise_percent, d.subprice, d.fk_product,"; $sql.= " d.info_bits, d.total_ht, d.total_tva, d.total_localtax1, d.total_localtax2, d.total_ttc, d.fk_product_fournisseur_price as fk_fournprice, d.buy_price_ht as pa_ht, d.special_code, d.rang, d.product_type,"; $sql.= ' p.ref as product_ref, p.description as product_desc, p.fk_product_type, p.label as product_label'; $sql.= " FROM ".MAIN_DB_PREFIX."propaldet as d"; @@ -1097,6 +1100,7 @@ class Propal extends CommonObject $line->fk_propal = $objp->fk_propal; $line->fk_parent_line = $objp->fk_parent_line; $line->product_type = $objp->product_type; + $line->label = $objp->custom_label; $line->desc = $objp->description; // Description ligne $line->qty = $objp->qty; $line->tva_tx = $objp->tva_tx; @@ -2378,7 +2382,7 @@ class Propal extends CommonObject */ function getLinesArray() { - $sql = 'SELECT pt.rowid, pt.description, pt.fk_product, pt.fk_remise_except,'; + $sql = 'SELECT pt.rowid, pt.label as custom_label, pt.description, pt.fk_product, pt.fk_remise_except,'; $sql.= ' pt.qty, pt.tva_tx, pt.remise_percent, pt.subprice, pt.info_bits,'; $sql.= ' pt.total_ht, pt.total_tva, pt.total_ttc, pt.fk_product_fournisseur_price as fk_fournprice, pt.buy_price_ht as pa_ht, pt.special_code, pt.localtax1_tx, pt.localtax2_tx,'; $sql.= ' pt.date_start, pt.date_end, pt.product_type, pt.rang, pt.fk_parent_line,'; @@ -2402,6 +2406,7 @@ class Propal extends CommonObject $this->lines[$i] = (object) array(); $this->lines[$i]->id = $obj->rowid; // for backward compatibility $this->lines[$i]->rowid = $obj->rowid; + $this->lines[$i]->label = $obj->custom_label; $this->lines[$i]->description = $obj->description; $this->lines[$i]->fk_product = $obj->fk_product; $this->lines[$i]->ref = $obj->ref; @@ -2525,11 +2530,11 @@ class PropaleLigne */ function fetch($rowid) { - $sql = 'SELECT pd.rowid, pd.fk_propal, pd.fk_parent_line, pd.fk_product, pd.description, pd.price, pd.qty, pd.tva_tx,'; + $sql = 'SELECT pd.rowid, pd.fk_propal, pd.fk_parent_line, pd.fk_product, pd.label as custom_label, pd.description, pd.price, pd.qty, pd.tva_tx,'; $sql.= ' pd.remise, pd.remise_percent, pd.fk_remise_except, pd.subprice,'; $sql.= ' pd.info_bits, pd.total_ht, pd.total_tva, pd.total_ttc, pd.fk_product_fournisseur_price as fk_fournprice, pd.buy_price_ht as pa_ht, pd.special_code, pd.rang,'; $sql.= ' pd.localtax1_tx, pd.localtax2_tx, pd.total_localtax1, pd.total_localtax2,'; - $sql.= ' p.ref as product_ref, p.label as product_libelle, p.description as product_desc'; + $sql.= ' p.ref as product_ref, p.label as product_label, p.description as product_desc'; $sql.= ' FROM '.MAIN_DB_PREFIX.'propaldet as pd'; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON pd.fk_product = p.rowid'; $sql.= ' WHERE pd.rowid = '.$rowid; @@ -2542,6 +2547,7 @@ class PropaleLigne $this->rowid = $objp->rowid; $this->fk_propal = $objp->fk_propal; $this->fk_parent_line = $objp->fk_parent_line; + $this->label = $objp->custom_label; $this->desc = $objp->description; $this->qty = $objp->qty; $this->price = $objp->price; // deprecated @@ -2569,8 +2575,8 @@ class PropaleLigne $this->ref = $objp->product_ref; // deprecated $this->product_ref = $objp->product_ref; - $this->libelle = $objp->product_libelle; // deprecated - $this->product_label = $objp->product_libelle; + $this->libelle = $objp->product_label; // deprecated + $this->product_label = $objp->product_label; $this->product_desc = $objp->product_desc; $this->db->free($result); @@ -2610,7 +2616,7 @@ class PropaleLigne if (empty($this->pa_ht)) $this->pa_ht=0; - // si prix d'achat non renseign� et utilis� pour calcul des marges alors prix achat = prix vente (idem pour remises) + // si prix d'achat non renseigne et utilise pour calcul des marges alors prix achat = prix vente (idem pour remises) if ($this->pa_ht == 0) { if ($this->subprice < 0 || (isset($conf->global->CalculateMarginsOnLinesWithoutBuyingPrice) && $conf->global->CalculateMarginsOnLinesWithoutBuyingPrice == 1)) $this->pa_ht = $this->subprice * (1 - $this->remise_percent / 100); @@ -2623,12 +2629,13 @@ class PropaleLigne // Insert line into database $sql = 'INSERT INTO '.MAIN_DB_PREFIX.'propaldet'; - $sql.= ' (fk_propal, fk_parent_line, description, fk_product, product_type, fk_remise_except, qty, tva_tx, localtax1_tx, localtax2_tx,'; + $sql.= ' (fk_propal, fk_parent_line, label, description, fk_product, product_type, fk_remise_except, qty, tva_tx, localtax1_tx, localtax2_tx,'; $sql.= ' subprice, remise_percent, '; $sql.= ' info_bits, '; $sql.= ' total_ht, total_tva, total_localtax1, total_localtax2, total_ttc, fk_product_fournisseur_price, buy_price_ht, special_code, rang)'; $sql.= " VALUES (".$this->fk_propal.","; $sql.= " ".($this->fk_parent_line>0?"'".$this->fk_parent_line."'":"null").","; + $sql.= " ".(! empty($this->label)?"'".$this->db->escape($this->label)."'":"null").","; $sql.= " '".$this->db->escape($this->desc)."',"; $sql.= " ".($this->fk_product?"'".$this->fk_product."'":"null").","; $sql.= " '".$this->product_type."',"; @@ -2746,7 +2753,7 @@ class PropaleLigne if (empty($this->pa_ht)) $this->pa_ht=0; - // si prix d'achat non renseign� et utilis� pour calcul des marges alors prix achat = prix vente (idem pour remises) + // si prix d'achat non renseigne et utilise pour calcul des marges alors prix achat = prix vente (idem pour remises) if ($this->pa_ht == 0) { if ($this->subprice < 0 || ($conf->global->CalculateMarginsOnLinesWithoutBuyingPrice == 1)) $this->pa_ht = $this->subprice * (1 - $this->remise_percent / 100); @@ -2757,6 +2764,9 @@ class PropaleLigne // Mise a jour ligne en base $sql = "UPDATE ".MAIN_DB_PREFIX."propaldet SET"; $sql.= " description='".$this->db->escape($this->desc)."'"; + if (! empty($this->label)) { + $sql.= " , label='".$this->db->escape($this->label)."'"; + } $sql.= " , tva_tx='".price2num($this->tva_tx)."'"; $sql.= " , localtax1_tx=".price2num($this->localtax1_tx); $sql.= " , localtax2_tx=".price2num($this->localtax2_tx); diff --git a/htdocs/commande/fiche.php b/htdocs/commande/fiche.php index 2e7b4f21ea6..b76be6a5d79 100644 --- a/htdocs/commande/fiche.php +++ b/htdocs/commande/fiche.php @@ -520,7 +520,7 @@ else if ($action == 'addline' && $user->rights->commande->creer) { $langs->load('errors'); $error = false; - +var_dump($_POST); exit; if ((GETPOST('np_price') < 0) && (GETPOST('qty') < 0)) { setEventMessage($langs->trans('ErrorBothFieldCantBeNegative', $langs->transnoentitiesnoconv('UnitPrice'), $langs->transnoentitiesnoconv('Qty')), 'errors'); @@ -2098,13 +2098,6 @@ if ($action == 'send' && ! GETPOST('addfile') && ! GETPOST('removedfile') && ! G $object->formAddFreeProduct(1,$mysoc,$soc,$hookmanager); - // Add predefined products/services - if ($conf->product->enabled || $conf->service->enabled) - { - $var=!$var; - $object->formAddPredefinedProduct(1,$mysoc,$soc,$hookmanager); - } - $parameters=array(); $reshook=$hookmanager->executeHooks('formAddObject',$parameters,$object,$action); // Note that $action and $object may have been modified by hook } @@ -2347,6 +2340,6 @@ if ($action == 'send' && ! GETPOST('addfile') && ! GETPOST('removedfile') && ! G } - llxFooter(); - $db->close(); - ?> +llxFooter(); +$db->close(); +?> \ No newline at end of file diff --git a/htdocs/core/ajax/price.php b/htdocs/core/ajax/price.php new file mode 100644 index 00000000000..55ad60dec95 --- /dev/null +++ b/htdocs/core/ajax/price.php @@ -0,0 +1,66 @@ + + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/core/ajax/price.php + * \brief File to get ht and ttc + */ + +if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Disables token renewal +if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); +//if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); +if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); +if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); +//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); + +require('../../main.inc.php'); + +$action = GETPOST('action','alpha'); +$pu_ht = price2num(GETPOST('pu_ht','alpha')); +$pu_ttc = price2num(GETPOST('pu_ttc','alpha')); +$tva_tx = str_replace('*','',GETPOST('tva_tx','alpha')); + +/* + * View + */ + +top_httphead(); + +//print ''."\n"; + +// Load original field value +if (! empty($action) && (isset($pu_ht) || isset($pu_ttc)) && isset($tva_tx)) +{ + $return=array(); + + if ($action == 'get_ttc') { + + $price = price2num($pu_ht * (1 + ($tva_tx/100)), 'MU'); + + } + else if ($action == 'get_ht') { + + $price = price2num($pu_ttc / (1 + ($tva_tx/100)), 'MU'); + + } + + $return['price'] = price($price); + + echo json_encode($return); +} + +?> diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 973f4882654..465ba3b34a0 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -2484,7 +2484,7 @@ abstract class CommonObject */ function formAddFreeProduct($dateSelector,$seller,$buyer,$hookmanager=false) { - global $conf,$langs,$object; + global $conf,$user,$langs,$object; global $form,$bcnd,$var; // Output template part (modules that overwrite templates must declare this into descriptor) @@ -2492,7 +2492,12 @@ abstract class CommonObject $dirtpls=array_merge($conf->modules_parts['tpl'],array('/core/tpl')); foreach($dirtpls as $reldir) { - $res=@include(dol_buildpath($reldir.'/freeproductline_create.tpl.php')); + // for view errors + if ($conf->file->strict_mode) { + $res=include(dol_buildpath($reldir.'/freeproductline_create.tpl.php')); + } else { + $res=@include(dol_buildpath($reldir.'/freeproductline_create.tpl.php')); + } if ($res) break; } } @@ -2528,6 +2533,7 @@ abstract class CommonObject print ''; print ''; print ''; + print ''; print ''; print ''; if (! empty($conf->margin->enabled)) { @@ -2637,9 +2643,8 @@ abstract class CommonObject $product_static->type=$line->fk_product_type; $product_static->id=$line->fk_product; $product_static->ref=$line->ref; - $product_static->libelle=$label; $text=$product_static->getNomUrl(1); - $text.= ' - '.$label; + $text.= ' - '.(! empty($line->label)?$line->label:$label); $description=($conf->global->PRODUIT_DESC_IN_FORM?'':dol_htmlentitiesbr($line->description)); // Output template part (modules that overwrite templates must declare this into descriptor) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 69efb5ea5b2..8f20cfe75be 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -340,7 +340,7 @@ class Form * @param int $direction -1=Le picto est avant, 0=pas de picto, 1=le picto est apres * @param string $img Code img du picto (use img_xxx() function to get it) * @param string $extracss Add a CSS style to td tags - * @param int $notabs Do not include table and tr tags + * @param int $notabs 1=Do not include table and tr tags, 2=use div, 3=use span * @param string $incbefore Include code before the text * @param int $noencodehtmltext Do not encode into html entity the htmltext * @return string Code html du tooltip (texte+picto) @@ -353,6 +353,10 @@ class Form if ($incbefore) $text = $incbefore.$text; if (! $htmltext) return $text; + $tag='td'; + if ($notabs == 2) $tag='div'; + if ($notabs == 3) $tag='span'; + // Sanitize tooltip $htmltext=str_replace("\\","\\\\",$htmltext); $htmltext=str_replace("\r","",$htmltext); @@ -365,7 +369,7 @@ class Form else $paramfortooltiptd =($extracss?' class="'.$extracss.'"':''); // Attribut to put on td text tag $s=""; - if (empty($notabs)) $s.='
'.$langs->trans('Description').''.$langs->trans('VAT').''.$langs->trans('PriceUHT').' '.$langs->trans('Qty').''.$langs->trans('ReductionShort').'
'; + if ($notabs < 2) $s.='
'; if ($direction > 0) { if ($text != '') @@ -381,12 +385,12 @@ class Form if ($direction) $s.=''.$img.''; if ($text != '') { - $s.=''; + $s.='<'.$tag.$paramfortooltiptd.'>'; if ($direction) $s.=' '; - $s.=$text.''; + $s.=$text.''; } } - if (empty($notabs)) $s.='
'; + if ($notabs < 2) $s.=''; return $s; } @@ -543,7 +547,7 @@ class Form || (empty($conf->product->enabled) && empty($conf->service->enabled))) { if (empty($hidetext)) print $langs->trans("Type").': '; - print ''; if ($showempty) { print '