diff --git a/htdocs/comm/propal.php b/htdocs/comm/propal.php index b74810e261493cdecfaf92a70de3e5c834bf2908..4fb76387e61bc8b43636c15f8fae805c54c624b8 100644 --- a/htdocs/comm/propal.php +++ b/htdocs/comm/propal.php @@ -1569,7 +1569,7 @@ if (! empty($conf->global->MAIN_DISABLE_NOTES_TAB)) * Lines */ -if ($conf->use_javascript_ajax && $object->statut == 0) +if (! empty($conf->use_javascript_ajax) && $object->statut == 0) { include DOL_DOCUMENT_ROOT.'/core/tpl/ajaxrow.tpl.php'; } @@ -1578,7 +1578,8 @@ print '<table id="tablelines" class="noborder" width="100%">'; // Show object lines $result = $object->getLinesArray(); -if (! empty($object->lines)) $object->printObjectLines($action,$mysoc,$soc,$lineid,0,$hookmanager); +if (! empty($object->lines)) + $ret=$object->printObjectLines($action,$mysoc,$soc,$lineid,0,$hookmanager); // Form to add new line if ($object->statut == 0 && $user->rights->propale->creer) @@ -1588,10 +1589,10 @@ if ($object->statut == 0 && $user->rights->propale->creer) $var=true; // Add free or predefined products/services - $object->formAddFreeProduct(0,$mysoc,$soc,$hookmanager); + $object->formAddObjectLine(0,$mysoc,$soc,$hookmanager); $parameters=array(); - $reshook=$hookmanager->executeHooks('formAddObject',$parameters,$object,$action); // Note that $action and $object may have been modified by hook + $reshook=$hookmanager->executeHooks('formAddObjectLine',$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 b4943a9068fa03807d2399575b1e5e2b5a4fcc4c..4cace6ae58c4d88c22fc8db6ea23eb5a472a5f5d 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -2764,9 +2764,7 @@ 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.= " , label=".(! empty($this->label)?"'".$this->db->escape($this->label)."'":"null"); $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/class/commande.class.php b/htdocs/commande/class/commande.class.php index d209bb4aacd6d2c637f1b4f66a8b26a79d8a7933..877fd376942ed03e169347c4b671f0edf3cfc61a 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -3126,9 +3126,7 @@ class OrderLine // Mise a jour ligne en base $sql = "UPDATE ".MAIN_DB_PREFIX."commandedet SET"; $sql.= " description='".$this->db->escape($this->desc)."'"; - if (empty($this->label)) { - $sql.= " , label='".$this->db->escape($this->label)."'"; - } + $sql.= " , label=".(! empty($this->label)?"'".$this->db->escape($this->label)."'":"null"); $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 3ce4092de331f5ff7b19829639e602a1afc17516..b06a05b5ac4eb1dabe1f87e4da2a698945a2cbd2 100644 --- a/htdocs/commande/fiche.php +++ b/htdocs/commande/fiche.php @@ -552,9 +552,8 @@ else if ($action == 'addline' && $user->rights->commande->creer) if (! $error && (GETPOST('qty') >= 0) && (GETPOST('product_desc') || ! empty($idprod))) { // Clean parameters - $suffixe = (! empty($idprod) ? '_predef' : ''); - $date_start=dol_mktime(0, 0, 0, GETPOST('date_start'.$suffixe.'month'), GETPOST('date_start'.$suffixe.'day'), GETPOST('date_start'.$suffixe.'year')); - $date_end=dol_mktime(0, 0, 0, GETPOST('date_end'.$suffixe.'month'), GETPOST('date_end'.$suffixe.'day'), GETPOST('date_end'.$suffixe.'year')); + $date_start=dol_mktime(0, 0, 0, GETPOST('date_startmonth'), GETPOST('date_startday'), GETPOST('date_startyear')); + $date_end=dol_mktime(0, 0, 0, GETPOST('date_endmonth'), GETPOST('date_endday'), GETPOST('date_endyear')); $price_base_type = 'HT'; // Ecrase $pu par celui du produit @@ -754,10 +753,10 @@ else if ($action == 'updateligne' && $user->rights->commande->creer && GETPOST(' // Clean parameters $date_start=''; $date_end=''; - $date_start=dol_mktime(0, 0, 0, GETPOST('date_start'.$suffixe.'month'), GETPOST('date_start'.$suffixe.'day'), GETPOST('date_start'.$suffixe.'year')); - $date_end=dol_mktime(0, 0, 0, GETPOST('date_end'.$suffixe.'month'), GETPOST('date_end'.$suffixe.'day'), GETPOST('date_end'.$suffixe.'year')); - $description=dol_htmlcleanlastbr(GETPOST('desc')); - $up_ht=GETPOST('pu')?GETPOST('pu'):GETPOST('subprice'); + $date_start=dol_mktime(0, 0, 0, GETPOST('date_startmonth'), GETPOST('date_startday'), GETPOST('date_startyear')); + $date_end=dol_mktime(0, 0, 0, GETPOST('date_endmonth'), GETPOST('date_endday'), GETPOST('date_endyear')); + $description=dol_htmlcleanlastbr(GETPOST('product_desc')); + $pu_ht=GETPOST('price_ht'); // Define info_bits $info_bits=0; @@ -769,37 +768,37 @@ else if ($action == 'updateligne' && $user->rights->commande->creer && GETPOST(' $localtax1_rate=get_localtax($vat_rate,1,$object->client); $localtax2_rate=get_localtax($vat_rate,2,$object->client); - - // ajout prix d'achat - $fk_fournprice = GETPOST('fournprice'); - if (GETPOST('buying_price')) - $pa_ht = GETPOST('buying_price'); - else - $pa_ht = null; + // Add buying price + $fournprice=(GETPOST('fournprice')?GETPOST('fournprice'):''); + $buyingprice=(GETPOST('buying_price')?GETPOST('buying_price'):''); // Check minimum price - if (GETPOST('productid')) + if (GETPOST('productid', 'int')) { - $productid = GETPOST('productid'); + $productid = GETPOST('productid', 'int'); $product = new Product($db); $product->fetch($productid); $type=$product->type; $price_min = $product->price_min; - if ($conf->global->PRODUIT_MULTIPRICES && $object->client->price_level) $price_min = $product->multiprices_min[$object->client->price_level]; + if ($conf->global->PRODUIT_MULTIPRICES && $object->client->price_level) + $price_min = $product->multiprices_min[$object->client->price_level]; + + $label = ((GETPOST('update_label') && GETPOST('product_label')) ? GETPOST('product_label'):''); if ($price_min && (price2num($up_ht)*(1-price2num(GETPOST('remise_percent'))/100) < price2num($price_min))) { - $mesg = '<div class="error">'.$langs->trans("CantBeLessThanMinPrice",price2num($price_min,'MU').' '.$langs->trans("Currency".$conf->currency)).'</div>' ; + setEventMessage($langs->trans("CantBeLessThanMinPrice", price2num($price_min,'MU')).getCurrencySymbol($conf->currency), 'errors'); $error++; } } else { - $type=GETPOST('type'); + $type = GETPOST('type'); + $label = (GETPOST('product_label') ? GETPOST('product_label'):''); // Check parameters if (GETPOST('type') < 0) { - $mesg = '<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Type")).'</div>'; + setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Type"))); $error++; } } @@ -809,7 +808,7 @@ else if ($action == 'updateligne' && $user->rights->commande->creer && GETPOST(' $result = $object->updateline( GETPOST('lineid'), $description, - $up_ht, + $pu_ht, GETPOST('qty'), GETPOST('remise_percent'), $vat_rate, @@ -822,38 +821,46 @@ else if ($action == 'updateligne' && $user->rights->commande->creer && GETPOST(' $type, GETPOST('fk_parent_line'), 0, - $fk_fournprice, - $pa_ht + $fournprice, + $buyingprice, + $label ); if ($result >= 0) { - // Define output language - $outputlangs = $langs; - $newlang=''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id')) $newlang=GETPOST('lang_id'); - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang; - if (! empty($newlang)) + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { - $outputlangs = new Translate("",$conf); - $outputlangs->setDefaultLang($newlang); - } - if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) - { - $ret=$object->fetch($object->id); // Reload to get new records + // Define output language + $outputlangs = $langs; + $newlang=''; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id')) $newlang=GETPOST('lang_id'); + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang; + if (! empty($newlang)) + { + $outputlangs = new Translate("",$conf); + $outputlangs->setDefaultLang($newlang); + } + + $ret=$object->fetch($object->id); // Reload to get new records commande_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager); - unset($_POST['qty']); - unset($_POST['type']); - unset($_POST['np_price']); - unset($_POST['dp_desc']); - unset($_POST['np_tva_tx']); - unset($_POST['np_buying_price']); } + + unset($_POST['qty']); + unset($_POST['type']); + unset($_POST['productid']); + unset($_POST['remise_percent']); + 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 { - dol_print_error($db,$object->error); - exit; + setEventMessage($object->error, 'errors'); } } } @@ -2114,7 +2121,7 @@ if ($action == 'send' && ! GETPOST('addfile') && ! GETPOST('removedfile') && ! G $numlines = count($object->lines); - if ($conf->use_javascript_ajax && $object->statut == 0) + if (! empty($conf->use_javascript_ajax) && $object->statut == 0) { include DOL_DOCUMENT_ROOT.'/core/tpl/ajaxrow.tpl.php'; } @@ -2122,7 +2129,8 @@ if ($action == 'send' && ! GETPOST('addfile') && ! GETPOST('removedfile') && ! G print '<table id="tablelines" class="noborder" width="100%">'; // Show object lines - if (! empty($object->lines)) $object->printObjectLines($action,$mysoc,$soc,$lineid,1,$hookmanager); + if (! empty($object->lines)) + $ret=$object->printObjectLines($action,$mysoc,$soc,$lineid,1,$hookmanager); /* * Form to add new line @@ -2133,10 +2141,10 @@ if ($action == 'send' && ! GETPOST('addfile') && ! GETPOST('removedfile') && ! G { $var=true; - $object->formAddFreeProduct(1,$mysoc,$soc,$hookmanager); + $object->formAddObjectLine(1,$mysoc,$soc,$hookmanager); $parameters=array(); - $reshook=$hookmanager->executeHooks('formAddObject',$parameters,$object,$action); // Note that $action and $object may have been modified by hook + $reshook=$hookmanager->executeHooks('formAddObjectLine',$parameters,$object,$action); // Note that $action and $object may have been modified by hook } } print '</table>'; diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index b24cdfa6deeafcac253883cfd0dafc33b592807c..c49f9bce532e9a88c0b65e0fd6867b3997b6ee96 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -982,9 +982,8 @@ else if (($action == 'addline' || $action == 'addline_predef') && $user->rights- $ret=$object->fetch_thirdparty(); // Clean parameters - $suffixe = (! empty($idprod) ? '_predef' : ''); - $date_start=dol_mktime(GETPOST('date_start'.$suffixe.'hour'), GETPOST('date_start'.$suffixe.'min'), GETPOST('date_start'.$suffixe.'sec'), GETPOST('date_start'.$suffixe.'month'), GETPOST('date_start'.$suffixe.'day'), GETPOST('date_start'.$suffixe.'year')); - $date_end=dol_mktime(GETPOST('date_end'.$suffixe.'hour'), GETPOST('date_end'.$suffixe.'min'), GETPOST('date_end'.$suffixe.'sec'), GETPOST('date_end'.$suffixe.'month'), GETPOST('date_end'.$suffixe.'day'), GETPOST('date_end'.$suffixe.'year')); + $date_start=dol_mktime(GETPOST('date_starthour'), GETPOST('date_startmin'), GETPOST('date_startsec'), GETPOST('date_startmonth'), GETPOST('date_startday'), GETPOST('date_startyear')); + $date_end=dol_mktime(GETPOST('date_endhour'), GETPOST('date_endmin'), GETPOST('date_endsec'), GETPOST('date_endmonth'), GETPOST('date_endday'), GETPOST('date_endyear')); $price_base_type = 'HT'; // Ecrase $pu par celui du produit @@ -1112,7 +1111,7 @@ else if (($action == 'addline' || $action == 'addline_predef') && $user->rights- $info_bits=0; if ($tva_npr) $info_bits |= 0x01; - if (! empty($price_min) && (price2num($pu_ht)*(1-price2num($_POST['remise_percent'])/100) < price2num($price_min))) + if (! empty($price_min) && (price2num($pu_ht)*(1-price2num(GETPOST('remise_percent'))/100) < price2num($price_min))) { $mesg = $langs->trans("CantBeLessThanMinPrice",price2num($price_min,'MU').getCurrencySymbol($conf->currency)); setEventMessage($mesg, 'errors'); @@ -1197,8 +1196,8 @@ else if ($action == 'updateligne' && $user->rights->facture->creer && $_POST['sa // Clean parameters $date_start=''; $date_end=''; - $date_start=dol_mktime($_POST['date_start'.$suffixe.'hour'],$_POST['date_start'.$suffixe.'min'],$_POST['date_start'.$suffixe.'sec'],$_POST['date_start'.$suffixe.'month'],$_POST['date_start'.$suffixe.'day'],$_POST['date_start'.$suffixe.'year']); - $date_end=dol_mktime($_POST['date_end'.$suffixe.'hour'],$_POST['date_end'.$suffixe.'min'],$_POST['date_end'.$suffixe.'sec'],$_POST['date_end'.$suffixe.'month'],$_POST['date_end'.$suffixe.'day'],$_POST['date_end'.$suffixe.'year']); + $date_start=dol_mktime(GETPOST('date_starthour'), GETPOST('date_startmin'), GETPOST('date_startsec'), GETPOST('date_startmonth'), GETPOST('date_startday'), GETPOST('date_startyear')); + $date_end=dol_mktime(GETPOST('date_endhour'), GETPOST('date_endmin'), GETPOST('date_endsec'), GETPOST('date_endmonth'), GETPOST('date_endday'), GETPOST('date_endyear')); $description=dol_htmlcleanlastbr($_POST['desc']); $up_ht=GETPOST('pu')?GETPOST('pu'):GETPOST('subprice'); @@ -2970,7 +2969,7 @@ else if ($id > 0 || ! empty($ref)) */ $result = $object->getLinesArray(); - if ($conf->use_javascript_ajax && $object->statut == 0) + if (! empty($conf->use_javascript_ajax) && $object->statut == 0) { include DOL_DOCUMENT_ROOT.'/core/tpl/ajaxrow.tpl.php'; } @@ -2978,7 +2977,8 @@ else if ($id > 0 || ! empty($ref)) print '<table id="tablelines" class="noborder noshadow" width="100%">'; // Show object lines - if (! empty($object->lines)) $object->printObjectLines($action,$mysoc,$soc,$lineid,1,$hookmanager); + if (! empty($object->lines)) + $ret=$object->printObjectLines($action,$mysoc,$soc,$lineid,1,$hookmanager); /* * Form to add new line @@ -2987,10 +2987,10 @@ else if ($id > 0 || ! empty($ref)) { $var=true; - $object->formAddFreeProduct(1,$mysoc,$soc,$hookmanager); + $object->formAddObjectLine(1,$mysoc,$soc,$hookmanager); $parameters=array(); - $reshook=$hookmanager->executeHooks('formAddObject',$parameters,$object,$action); // Note that $action and $object may have been modified by hook + $reshook=$hookmanager->executeHooks('formAddObjectLine',$parameters,$object,$action); // Note that $action and $object may have been modified by hook } print "</table>\n"; diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index baf9ee69db4b79a97cdc6344917c5e4597cf4cbc..0ff49cd8f7e62f86fab3cba27f65888ca5513a44 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -3420,9 +3420,7 @@ class FactureLigne // Mise a jour ligne en base $sql = "UPDATE ".MAIN_DB_PREFIX."facturedet SET"; $sql.= " description='".$this->db->escape($this->desc)."'"; - if (! empty($this->label)) { - $sql.= " , label='".$this->db->escape($this->label)."'"; - } + $sql.= ",label=".(! empty($this->label)?"'".$this->db->escape($this->label)."'":"null"); $sql.= ",subprice=".price2num($this->subprice).""; $sql.= ",remise_percent=".price2num($this->remise_percent).""; if ($this->fk_remise_except) $sql.= ",fk_remise_except=".$this->fk_remise_except; diff --git a/htdocs/core/ajax/price.php b/htdocs/core/ajax/price.php index 55ad60dec95adb4ad2e0771fb6a18e35f54af827..ba6ebe615e568d738aba1b826ac7500091d09a19 100644 --- a/htdocs/core/ajax/price.php +++ b/htdocs/core/ajax/price.php @@ -43,22 +43,23 @@ top_httphead(); //print '<!-- Ajax page called with url '.$_SERVER["PHP_SELF"].'?'.$_SERVER["QUERY_STRING"].' -->'."\n"; // Load original field value -if (! empty($action) && (isset($pu_ht) || isset($pu_ttc)) && isset($tva_tx)) +if (! empty($action) && isset($tva_tx)) { $return=array(); + $price=''; - if ($action == 'get_ttc') { + if ($action == 'get_ttc' && isset($pu_ht) && $pu_ht != '') { $price = price2num($pu_ht * (1 + ($tva_tx/100)), 'MU'); } - else if ($action == 'get_ht') { + else if ($action == 'get_ht' && isset($pu_ttc) && $pu_ttc != '') { $price = price2num($pu_ttc / (1 + ($tva_tx/100)), 'MU'); } - $return['price'] = price($price); + $return['price'] = (isset($price) && $price != '' ? price($price) : ''); echo json_encode($return); } diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 7f5e36e860a814a5eb0b91a1be7c65575bc18f76..70da921121bab860e63a620f8d714764960f916e 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -2446,43 +2446,17 @@ abstract class CommonObject /** - * Show add predefined products/services form + * Show add free and predefined products/services form * TODO Edit templates to use global variables and include them directly in controller call * But for the moment we don't know if it's possible as we keep a method available on overloaded objects. * - * @param int $dateSelector 1=Show also date range input fields - * @param Societe $seller Object thirdparty who sell - * @param Societe $buyer Object thirdparty who buy - * @param HookManager $hookmanager Hook manager instance - * @return void - */ - function formAddPredefinedProduct($dateSelector,$seller,$buyer,$hookmanager=false) - { - global $conf,$langs,$object; - global $form,$bcnd,$var; - - // Output template part (modules that overwrite templates must declare this into descriptor) - // Use global variables + $dateSelector + $seller and $buyer - $dirtpls=array_merge($conf->modules_parts['tpl'],array('/core/tpl')); - foreach($dirtpls as $reldir) - { - $res=@include dol_buildpath($reldir.'/predefinedproductline_create.tpl.php'); - if ($res) break; - } - } - - /** - * Show add free products/services form - * TODO Edit templates to use global variables and include them directly in controller call - * But for the moment we don't know if it'st possible as we keep a method available on overloaded objects. - * * @param int $dateSelector 1=Show also date range input fields * @param Societe $seller Object thirdparty who sell * @param Societe $buyer Object thirdparty who buy * @param HookManager $hookmanager Hook manager instance * @return void */ - function formAddFreeProduct($dateSelector,$seller,$buyer,$hookmanager=false) + function formAddObjectLine($dateSelector,$seller,$buyer,$hookmanager=false) { global $conf,$user,$langs,$object; global $form,$bcnd,$var; @@ -2492,11 +2466,11 @@ abstract class CommonObject $dirtpls=array_merge($conf->modules_parts['tpl'],array('/core/tpl')); foreach($dirtpls as $reldir) { - // for view errors - if ($conf->file->strict_mode) { - $res=include dol_buildpath($reldir.'/freeproductline_create.tpl.php'); + $tpl = dol_buildpath($reldir.'/objectline_add.tpl.php'); + if (empty($conf->file->strict_mode)) { + $res=@include $tpl; } else { - $res=@include dol_buildpath($reldir.'/freeproductline_create.tpl.php'); + $res=include $tpl; // for debug } if ($res) break; } @@ -2580,8 +2554,6 @@ abstract class CommonObject /** * Return HTML content of a detail line * TODO Move this into an output class file (htmlline.class.php) - * If lines are into a template, title must also be into a template - * But for the moment we don't know if it's possible as we keep a method available on overloaded objects. * * @param string $action GET/POST action * @param array $line Selected object line to output @@ -2601,13 +2573,23 @@ abstract class CommonObject global $form,$bc,$bcdd; $element=$this->element; + $text=''; // Show product and description - $type=$line->product_type?$line->product_type:$line->fk_product_type; - // Try to enhance type detection using date_start and date_end for free lines where type - // was not saved. - if (! empty($line->date_start)) $type=1; - if (! empty($line->date_end)) $type=1; + $type=(! empty($line->product_type)?$line->product_type:$line->fk_product_type); + // Try to enhance type detection using date_start and date_end for free lines where type was not saved. + if (! empty($line->date_start)) $type=1; // deprecated + if (! empty($line->date_end)) $type=1; // deprecated + + if ($line->fk_product > 0) + { + $product_static = new Product($this->db); + + $product_static->type=$line->fk_product_type; + $product_static->id=$line->fk_product; + $product_static->ref=$line->ref; + $text=$product_static->getNomUrl(1); + } // Ligne en mode visu if ($action != 'editline' || $selected != $line->id) @@ -2615,13 +2597,11 @@ abstract class CommonObject // Produit if ($line->fk_product > 0) { - $product_static = new Product($this->db); - // Define output language if (! empty($conf->global->MAIN_MULTILANGS) && ! empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) { $this->fetch_thirdparty(); - $prod = new Product($this->db, $line->fk_product); + $prod = new Product($this->db); $outputlangs = $langs; $newlang=''; @@ -2640,59 +2620,46 @@ abstract class CommonObject $label = $line->product_label; } - $product_static->type=$line->fk_product_type; - $product_static->id=$line->fk_product; - $product_static->ref=$line->ref; - $text=$product_static->getNomUrl(1); $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) - // Use global variables + $dateSelector + $seller and $buyer - $dirtpls=array_merge($conf->modules_parts['tpl'],array('/core/tpl')); - foreach($dirtpls as $reldir) - { - $res=@include dol_buildpath($reldir.'/predefinedproductline_view.tpl.php'); - if ($res) break; - } } - else + + // Output template part (modules that overwrite templates must declare this into descriptor) + // Use global variables + $dateSelector + $seller and $buyer + $dirtpls=array_merge($conf->modules_parts['tpl'],array('/core/tpl')); + foreach($dirtpls as $reldir) { - // Output template part (modules that overwrite templates must declare this into descriptor) - // Use global variables + $dateSelector + $seller and $buyer - $dirtpls=array_merge($conf->modules_parts['tpl'],array('/core/tpl')); - foreach($dirtpls as $reldir) - { - $res=@include dol_buildpath($reldir.'/freeproductline_view.tpl.php'); - if ($res) break; - } + $tpl = dol_buildpath($reldir.'/objectline_view.tpl.php'); + if (empty($conf->file->strict_mode)) { + $res=@include $tpl; + } else { + $res=include $tpl; // for debug + } + if ($res) break; } } // Ligne en mode update if ($this->statut == 0 && $action == 'editline' && $selected == $line->id) { - if ($line->fk_product > 0) - { - // Output template part (modules that overwrite templates must declare this into descriptor) - // Use global variables + $dateSelector + $seller and $buyer - $dirtpls=array_merge($conf->modules_parts['tpl'],array('/core/tpl')); - foreach($dirtpls as $reldir) - { - $res=@include dol_buildpath($reldir.'/predefinedproductline_edit.tpl.php'); - if ($res) break; - } - } - else + $label = (! empty($line->label) ? $line->label : (($line->fk_product > 0) ? $line->product_label : '')); + if (! empty($conf->global->MAIN_HTML5_PLACEHOLDER)) $placeholder=' placeholder="'.$langs->trans("Label").'"'; + else $placeholder=' title="'.$langs->trans("Label").'"'; + + $pu_ttc = price2num($line->subprice * (1 + ($line->tva_tx/100)), 'MU'); + + // Output template part (modules that overwrite templates must declare this into descriptor) + // Use global variables + $dateSelector + $seller and $buyer + $dirtpls=array_merge($conf->modules_parts['tpl'],array('/core/tpl')); + foreach($dirtpls as $reldir) { - // Output template part (modules that overwrite templates must declare this into descriptor) - // Use global variables + $dateSelector + $seller and $buyer - $dirtpls=array_merge($conf->modules_parts['tpl'],array('/core/tpl')); - foreach($dirtpls as $reldir) - { - $res=@include dol_buildpath($reldir.'/freeproductline_edit.tpl.php'); - if ($res) break; - } + $tpl = dol_buildpath($reldir.'/objectline_edit.tpl.php'); + if (empty($conf->file->strict_mode)) { + $res=@include $tpl; + } else { + $res=include $tpl; // for debug + } + if ($res) break; } } } diff --git a/htdocs/core/js/lib_head.js b/htdocs/core/js/lib_head.js index dec139510a7543aa525cd79b4d4d22841fa0a38c..fc408e246e216e4f45a30d8aadef067ebe26946c 100644 --- a/htdocs/core/js/lib_head.js +++ b/htdocs/core/js/lib_head.js @@ -739,7 +739,7 @@ function hideMessage(fieldId,message) { $.widget("ui.onDelayedKeyup", { _init : function() { var self = this; - $(this.element).keyup(function() { + $(this.element).bind('change keyup input', function() { if(typeof(window['inputTimeout']) != "undefined"){ window.clearTimeout(inputTimeout); } diff --git a/htdocs/core/tpl/freeproductline_edit.tpl.php b/htdocs/core/tpl/freeproductline_edit.tpl.php deleted file mode 100644 index 6a5e6e7ef30c59fb2dcc922cff51bcc6534ac211..0000000000000000000000000000000000000000 --- a/htdocs/core/tpl/freeproductline_edit.tpl.php +++ /dev/null @@ -1,101 +0,0 @@ -<?php -/* Copyright (C) 2010-2011 Regis Houssin <regis@dolibarr.fr> - * Copyright (C) 2010-2012 Laurent Destailleur <eldy@users.sourceforge.net> - * Copyright (C) 2012 Christophe Battarel <christophe.battarel@altairis.fr> - * - * 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 <http://www.gnu.org/licenses/>. - * - * - * Need to have following variables defined: - * $conf - * $langs - * $dateSelector - * $this (invoice, order, ...) - * $line defined - */ -?> - -<!-- BEGIN PHP TEMPLATE freeproductline_edit.tpl.php --> -<form action="<?php echo $_SERVER["PHP_SELF"].'?id='.$this->id.'#'.$line->id; ?>" method="POST"> -<input type="hidden" name="token" value="<?php echo $_SESSION['newtoken']; ?>"> -<input type="hidden" name="action" value="updateligne"> -<input type="hidden" name="id" value="<?php echo $this->id; ?>"> -<input type="hidden" name="lineid" value="<?php echo $line->id; ?>"> -<input type="hidden" name="type" value="<?php echo $line->product_type; ?>"> - -<tr <?php echo $bc[$var]; ?>> - <td<?php echo (! empty($conf->global->MAIN_VIEW_LINE_NUMBER) ? ' colspan="2"' : ''); ?>> - <div id="<?php echo $line->id; ?>"></div> - - <?php - if (is_object($hookmanager)) - { - $parameters=array('line'=>$line,'fk_parent_line'=>$line->fk_parent_line,'var'=>$var,'dateSelector'=>$dateSelector,'seller'=>$seller,'buyer'=>$buyer); - $reshook=$hookmanager->executeHooks('formEditProductOptions',$parameters,$this,$action); - } - - // editeur wysiwyg - $nbrows=ROWS_2; - if (! empty($conf->global->MAIN_INPUT_DESC_HEIGHT)) $nbrows=$conf->global->MAIN_INPUT_DESC_HEIGHT; - require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor=new DolEditor('desc',$line->description,'',164,'dolibarr_details','',false,true,$conf->global->FCKEDITOR_ENABLE_DETAILS,$nbrows,70); - $doleditor->Create(); - ?> - </td> - - <td align="right"><?php echo $form->load_tva('tva_tx',$line->tva_tx,$seller,$buyer,0,$line->info_bits,$line->product_type); ?></td> - - <td align="right"><input size="6" type="text" class="flat" name="subprice" value="<?php echo price($line->subprice,0,'',0); ?>"></td> - - <td align="right"> - <?php if (($line->info_bits & 2) != 2) { ?> - <input size="2" type="text" class="flat" name="qty" value="<?php echo $line->qty; ?>"> - <?php } else { ?> - - <?php } ?> - </td> - - <td align="right" nowrap> - <?php if (($line->info_bits & 2) != 2) { ?> - <input size="1" type="text" class="flat" name="remise_percent" value="<?php echo $line->remise_percent; ?>">% - <?php } else { ?> - - <?php } ?> - </td> - -<?php -if (! empty($conf->margin->enabled)) { -?> - <td align="right"><input type="text" size="5" name="buying_price" value="<?php echo price($line->pa_ht,0,'',0); ?>"></td> -<?php -} -?> - <td align="center" colspan="5" valign="middle"><input type="submit" class="button" name="save" value="<?php echo $langs->trans("Save"); ?>"> - <br><input type="submit" class="button" name="cancel" value="<?php echo $langs->trans("Cancel"); ?>"></td> -</tr> - -<?php if ($conf->service->enabled && $dateSelector && $line->product_type == 1) { ?> -<tr <?php echo $bc[$var]; ?>> - <td colspan="9"><?php echo $langs->trans('ServiceLimitedDuration').' '.$langs->trans('From').' '; ?> - <?php - echo $form->select_date($line->date_start,'date_start',$conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE,$conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE,$line->date_start?0:1,"updateligne"); - echo ' '.$langs->trans('to').' '; - echo $form->select_date($line->date_end,'date_end',$conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE,$conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE,$line->date_end?0:1,"updateligne"); - ?> - </td> -</tr> -<?php } ?> - -</form> -<!-- END PHP TEMPLATE freeproductline_edit.tpl.php --> diff --git a/htdocs/core/tpl/freeproductline_create.tpl.php b/htdocs/core/tpl/objectline_add.tpl.php similarity index 94% rename from htdocs/core/tpl/freeproductline_create.tpl.php rename to htdocs/core/tpl/objectline_add.tpl.php index 5015205f631ad183d0d9a183cd639403bb190be4..a7d5e582fa06e9428c852cd408f3ef2734667073 100644 --- a/htdocs/core/tpl/freeproductline_create.tpl.php +++ b/htdocs/core/tpl/objectline_add.tpl.php @@ -235,10 +235,14 @@ $(document).ready(function() { $('#add_service_text').show(); $('#service_duration_area').show(); } - //$('#add_product_area').show(); - $('#addlinebutton').removeAttr('disabled'); + //$('#add_product_area').show(); // TODO for add product card + if (($('#price_ht').val().length > 0) || ($('#price_ttc').val().length > 0)) { + $('#addlinebutton').removeAttr('disabled'); + } else { + $('#addlinebutton').attr('disabled','disabled'); + } } else { - //$('#add_product_area').hide(); + //$('#add_product_area').hide(); // TODO for add product card $('#add_product_checkbox').removeAttr('checked'); $('#addlinebutton').attr('disabled','disabled'); $('#service_duration_area').hide(); @@ -348,6 +352,14 @@ $(document).ready(function() { function(data) { if (data && data.price.length > 0) { $('#price_ttc').val(data.price); + if ($('#select_type').val() >= 0) { + $('#addlinebutton').removeAttr('disabled'); + } else { + $('#addlinebutton').attr('disabled','disabled'); + } + } else { + $('#price_ttc').val(''); + $('#addlinebutton').attr('disabled','disabled'); } }, 'json'); } @@ -362,6 +374,14 @@ $(document).ready(function() { function(data) { if (data && data.price.length > 0) { $('#price_ht').val(data.price); + if ($('#select_type').val() >= 0) { + $('#addlinebutton').removeAttr('disabled'); + } else { + $('#addlinebutton').attr('disabled','disabled'); + } + } else { + $('#price_ht').val(''); + $('#addlinebutton').attr('disabled','disabled'); } }, 'json'); } diff --git a/htdocs/core/tpl/objectline_edit.tpl.php b/htdocs/core/tpl/objectline_edit.tpl.php new file mode 100644 index 0000000000000000000000000000000000000000..4238ac8d09ad9f433a5a7b88d56b2e66206f0ea6 --- /dev/null +++ b/htdocs/core/tpl/objectline_edit.tpl.php @@ -0,0 +1,260 @@ +<?php +/* Copyright (C) 2010-2012 Regis Houssin <regis@dolibarr.fr> + * Copyright (C) 2010-2012 Laurent Destailleur <eldy@users.sourceforge.net> + * Copyright (C) 2012 Christophe Battarel <christophe.battarel@altairis.fr> + * + * 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 <http://www.gnu.org/licenses/>. + * + * + * Need to have following variables defined: + * $conf + * $langs + * $dateSelector + * $this (invoice, order, ...) + * $line defined + */ +?> + +<!-- BEGIN PHP TEMPLATE objectline_edit.tpl.php --> +<form action="<?php echo $_SERVER["PHP_SELF"].'?id='.$this->id.'#'.$line->id; ?>" method="POST"> +<input type="hidden" name="token" value="<?php echo $_SESSION['newtoken']; ?>"> +<input type="hidden" name="action" value="updateligne"> +<input type="hidden" name="id" value="<?php echo $this->id; ?>"> +<input type="hidden" name="lineid" value="<?php echo $line->id; ?>"> +<input type="hidden" id="product_type" name="type" value="<?php echo $line->product_type; ?>"> +<input type="hidden" id="product_id" name="productid" value="<?php echo (! empty($line->fk_product)?$line->fk_product:''); ?>" /> + +<tr <?php echo $bc[$var]; ?>> + <td<?php echo (! empty($conf->global->MAIN_VIEW_LINE_NUMBER) ? ' colspan="2"' : ''); ?>> + <div id="<?php echo $line->id; ?>"></div> + + <?php if ($line->fk_product > 0) { ?> + <?php echo $text . ' - '; ?> + <?php } else { ?> + <?php echo $form->select_type_of_lines($line->product_type, 'type', 1, 1); ?> + <?php } ?> + + <input id="product_label" name="product_label" size="40" value="<?php echo $label; ?>"<?php echo $placeholder . ((! empty($line->fk_product) && empty($line->label)) ? ' disabled="disabled"' : ''); ?>> + <span id="update_label_area" class="hideobject"><input type="checkbox" id="update_label_checkbox" name="update_label" value="1" /> + <?php echo $form->textwithtooltip($langs->trans('UpdateOriginalProductLabel'), $langs->trans('HelpUpdateOriginalProductLabel'),1,0,'','',3); ?> + </span> + + <br> + + <?php + if (is_object($hookmanager)) + { + $fk_parent_line = (GETPOST('fk_parent_line') ? GETPOST('fk_parent_line') : $line->fk_parent_line); + $parameters=array('line'=>$line,'fk_parent_line'=>$fk_parent_line,'var'=>$var,'dateSelector'=>$dateSelector,'seller'=>$seller,'buyer'=>$buyer); + $reshook=$hookmanager->executeHooks('formEditProductOptions',$parameters,$this,$action); + } + + // editeur wysiwyg + $nbrows=ROWS_2; + if (! empty($conf->global->MAIN_INPUT_DESC_HEIGHT)) $nbrows=$conf->global->MAIN_INPUT_DESC_HEIGHT; + require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; + $doleditor=new DolEditor('product_desc',$line->description,'',164,'dolibarr_details','',false,true,$conf->global->FCKEDITOR_ENABLE_DETAILS,$nbrows,70); + $doleditor->Create(); + ?> + </td> + + <td align="right"><?php echo $form->load_tva('tva_tx',$line->tva_tx,$seller,$buyer,0,$line->info_bits,$line->product_type); ?></td> + + <td align="right"><input type="text" class="flat" size="6" id="price_ht" name="price_ht" value="<?php echo price($line->subprice,0,'',0); ?>"></td> + <td align="right"><input type="text" class="flat" size="6" id="price_ttc" name="price_ttc" value="<?php echo price($pu_ttc,0,'',0); ?>"></td> + + <td align="right"> + <?php if (($line->info_bits & 2) != 2) { ?> + <input size="2" type="text" class="flat" name="qty" value="<?php echo $line->qty; ?>"> + <?php } else { ?> + + <?php } ?> + </td> + + <td align="right" nowrap> + <?php if (($line->info_bits & 2) != 2) { ?> + <input size="1" type="text" class="flat" name="remise_percent" value="<?php echo $line->remise_percent; ?>">% + <?php } else { ?> + + <?php } ?> + </td> + + <?php if (! empty($conf->margin->enabled)) { ?> + <td align="right"> + <select id="fournprice" name="fournprice" class="hideobject"></select> + <input type="text" size="5" id="buying_price" name="buying_price" class="hideobject" value="<?php echo price($line->pa_ht,0,'',0); ?>"> + </td> + <?php } ?> + + <td align="center" colspan="5" valign="middle"> + <input type="submit" class="button" id="savelinebutton" name="save" value="<?php echo $langs->trans("Save"); ?>"><br> + <input type="submit" class="button" id="cancellinebutton" name="cancel" value="<?php echo $langs->trans("Cancel"); ?>"> + </td> +</tr> + +<?php if ($conf->service->enabled && $dateSelector) { ?> +<tr id="service_duration_area" <?php echo $bc[$var]; ?>> + <td colspan="11"><?php echo $langs->trans('ServiceLimitedDuration').' '.$langs->trans('From').' '; ?> + <?php + echo $form->select_date($line->date_start,'date_start',$conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE,$conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE,$line->date_start?0:1,"updateligne"); + echo ' '.$langs->trans('to').' '; + echo $form->select_date($line->date_end,'date_end',$conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE,$conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE,$line->date_end?0:1,"updateligne"); + ?> + </td> +</tr> +<?php } ?> + +</form> + +<script type="text/javascript"> +$(document).ready(function() { + + if ($('#product_type').val() == 0) { + $('#service_duration_area').hide(); + } else if ($('#product_type').val() == 1) { + $('#service_duration_area').show(); + } + + if ($('#product_label').attr('disabled')) { + $('#update_label_area').show(); + } + + $('#update_label_checkbox').change(function() { + if ($(this).attr('checked')) { + $('#product_label').removeAttr('disabled').focus(); + } else { + $('#product_label').attr('disabled','disabled'); + } + }); + + $('#select_type').change(function() { + var type = $(this).val(); + if (type >= 0) { + if (type == 0) { + $('#service_duration_area').hide(); + $('#date_start').val('').trigger('change'); + $('#date_end').val('').trigger('change'); + } else if (type == 1) { + $('#service_duration_area').show(); + } + if (($('#price_ht').val().length > 0) || ($('#price_ttc').val().length > 0)) { + $('#savelinebutton').removeAttr('disabled'); + } else { + $('#savelinebutton').attr('disabled','disabled'); + } + } else { + $('#savelinebutton').attr('disabled','disabled'); + $('#service_duration_area').hide(); + $('#date_start').val('').trigger('change'); + $('#date_end').val('').trigger('change'); + } + }); + + $('#price_ht').onDelayedKeyup({ handler: function() { + $.post('<?php echo DOL_URL_ROOT; ?>/core/ajax/price.php', { + 'action': 'get_ttc', + 'pu_ht': $(this).val(), + 'tva_tx': $('#tva_tx').val() + }, + function(data) { + if (data && data.price.length > 0) { + $('#price_ttc').val(data.price); + if (($('#product_id').val().length > 0) || ($('#select_type').val() >= 0)) { + $('#savelinebutton').removeAttr('disabled'); + } else { + $('#savelinebutton').attr('disabled','disabled'); + } + } else { + $('#price_ttc').val(''); + $('#savelinebutton').attr('disabled','disabled'); + } + }, 'json'); + } + }); + + $('#price_ttc').onDelayedKeyup({ handler: function() { + $.post('<?php echo DOL_URL_ROOT; ?>/core/ajax/price.php', { + 'action': 'get_ht', + 'pu_ttc': $(this).val(), + 'tva_tx': $('#tva_tx').val() + }, + function(data) { + if (data && data.price.length > 0) { + $('#price_ht').val(data.price); + if (($('#product_id').val().length > 0) || ($('#select_type').val() >= 0)) { + $('#savelinebutton').removeAttr('disabled'); + } else { + $('#savelinebutton').attr('disabled','disabled'); + } + } else { + $('#price_ht').val(''); + $('#savelinebutton').attr('disabled','disabled'); + } + }, 'json'); + } + }); + + $('#tva_tx').change(function() { + $.post('<?php echo DOL_URL_ROOT; ?>/core/ajax/price.php', { + 'action': 'get_ttc', + 'pu_ht': $('#price_ht').val(), + 'tva_tx': $(this).val() + }, + function(data) { + if (data && data.price.length > 0) { + $('#price_ttc').val(data.price); + } + }, 'json'); + }); + + <?php if (! empty($conf->margin->enabled)) { ?> + $.post('<?php echo DOL_URL_ROOT; ?>/fourn/ajax/getSupplierPrices.php', {'idprod': <?php echo $line->fk_product; ?>}, function(data) { + if (data.length > 0) { + var options = ''; + var trouve=false; + $(data).each(function() { + options += '<option value="'+this.id+'" price="'+this.price+'"'; + <?php if ($line->fk_fournprice > 0) { ?> + if (this.id == <?php echo $line->fk_fournprice; ?>) { + options += ' selected'; + $("#buying_price").val(this.price); + trouve = true; + } + <?php } ?> + options += '>'+this.label+'</option>'; + }); + options += '<option value=null'+(trouve?'':' selected')+'><?php echo $langs->trans("InputPrice"); ?></option>'; + $("#fournprice").html(options); + if (trouve) { + $("#buying_price").hide(); + $("#fournprice").show(); + } else { + $("#buying_price").show(); + } + $("#fournprice").change(function() { + var selval = $(this).find('option:selected').attr("price"); + if (selval) + $("#buying_price").val(selval).hide(); + else + $('#buying_price').show(); + }); + } else { + $("#fournprice").hide(); + $('#buying_price').show(); + } + }, 'json'); + <?php } ?> +}); +</script> +<!-- END PHP TEMPLATE objectline_edit.tpl.php --> diff --git a/htdocs/core/tpl/freeproductline_view.tpl.php b/htdocs/core/tpl/objectline_view.tpl.php similarity index 76% rename from htdocs/core/tpl/freeproductline_view.tpl.php rename to htdocs/core/tpl/objectline_view.tpl.php index 45ebf30fa0b52128e468e3ce06e87ed8078ba359..6d50b776c7f64dd0bdd437bdb9f76baa96275b07 100644 --- a/htdocs/core/tpl/freeproductline_view.tpl.php +++ b/htdocs/core/tpl/objectline_view.tpl.php @@ -1,7 +1,7 @@ <?php -/* Copyright (C) 2010-2011 Regis Houssin <regis@dolibarr.fr> - * Copyright (C) 2010-2011 Laurent Destailleur <eldy@users.sourceforge.net> - * Copyright (C) 2012 Christophe Battarel <christophe.battarel@altairis.fr> +/* Copyright (C) 2010-2012 Regis Houssin <regis@dolibarr.fr> + * Copyright (C) 2010-2011 Laurent Destailleur <eldy@users.sourceforge.net> + * Copyright (C) 2012 Christophe Battarel <christophe.battarel@altairis.fr> * * 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 @@ -19,7 +19,7 @@ */ ?> -<!-- BEGIN PHP TEMPLATE freeproductline_view.tpl.php --> +<!-- BEGIN PHP TEMPLATE objectline_view.tpl.php --> <tr <?php echo 'id="row-'.$line->id.'" '.$bcdd[$var]; ?>> <?php if (! empty($conf->global->MAIN_VIEW_LINE_NUMBER)) { ?> <td align="center"><?php echo ($i+1); ?></td> @@ -60,19 +60,35 @@ } else { - if (! empty($line->fk_parent_line)) echo img_picto('', 'rightarrow'); - if ($type==1) $text = img_object($langs->trans('Service'),'service'); - else $text = img_object($langs->trans('Product'),'product'); + if ($line->fk_product > 0) { + + echo $form->textwithtooltip($text,$description,3,'','',$i,0,($line->fk_parent_line?img_picto('', 'rightarrow'):'')); + + // Show range + print_date_range($line->date_start, $line->date_end); + + // Add description in form + if ($conf->global->PRODUIT_DESC_IN_FORM) + { + print (! empty($line->description) && $line->description!=$line->product_label)?'<br>'.dol_htmlentitiesbr($line->description):''; + } - if (! empty($line->label)) { - $text.= ' <strong>'.$line->label.'</strong>'; - echo $form->textwithtooltip($text,dol_htmlentitiesbr($line->description),3,'','',$i,0,($line->fk_parent_line?img_picto('', 'rightarrow'):'')); } else { - echo $text.' '.dol_htmlentitiesbr($line->description); - } - // Show range - print_date_range($line->date_start,$line->date_end); + if (! empty($line->fk_parent_line)) echo img_picto('', 'rightarrow'); + if ($type==1) $text = img_object($langs->trans('Service'),'service'); + else $text = img_object($langs->trans('Product'),'product'); + + if (! empty($line->label)) { + $text.= ' <strong>'.$line->label.'</strong>'; + echo $form->textwithtooltip($text,dol_htmlentitiesbr($line->description),3,'','',$i,0,($line->fk_parent_line?img_picto('', 'rightarrow'):'')); + } else { + echo $text.' '.dol_htmlentitiesbr($line->description); + } + + // Show range + print_date_range($line->date_start,$line->date_end); + } } ?> </td> @@ -148,4 +164,4 @@ <?php } ?> </tr> -<!-- END PHP TEMPLATE freeproductline_view.tpl.php --> +<!-- END PHP TEMPLATE objectline_view.tpl.php --> diff --git a/htdocs/core/tpl/predefinedproductline_create.tpl.php b/htdocs/core/tpl/predefinedproductline_create.tpl.php deleted file mode 100644 index 3450b4134a9e6fe8484807a25c8bdb25dffa7928..0000000000000000000000000000000000000000 --- a/htdocs/core/tpl/predefinedproductline_create.tpl.php +++ /dev/null @@ -1,183 +0,0 @@ -<?php -/* Copyright (C) 2010-2012 Regis Houssin <regis@dolibarr.fr> - * Copyright (C) 2010-2011 Laurent Destailleur <eldy@users.sourceforge.net> - * Copyright (C) 2012 Christophe Battarel <christophe.battarel@altairis.fr> - * - * 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 <http://www.gnu.org/licenses/>. - * - * - * Need to have following variables defined: - * $conf - * $langs - * $dateSelector - * $this (invoice, order, ...) - * $line defined - */ -?> - -<!-- BEGIN PHP TEMPLATE predefinedproductline_create.tpl.php --> - -<tr class="liste_titre nodrag nodrop"> - <td<?php echo (! empty($conf->global->MAIN_VIEW_LINE_NUMBER) ? ' colspan="3"' : ' colspan="2"'); ?>> - <?php - echo $langs->trans("AddNewLine").' - '; - if ($conf->service->enabled) - echo $langs->trans('RecordedProductsAndServices'); - else - echo $langs->trans('RecordedProducts'); - ?> - </td> - <td align="right"><?php echo $langs->trans('PriceUHT'); ?></td> - <td align="right"><?php echo $langs->trans('PriceUTTC'); ?></td> - <td align="right"><?php echo $langs->trans('Qty'); ?></td> - <td align="right"><?php echo $langs->trans('ReductionShort'); ?></td> -<?php -$colspan = 4; -if (! empty($conf->margin->enabled)) { -?> - <td align="right"><?php echo $langs->trans('BuyingPrice'); ?></td> -<?php - if($conf->global->DISPLAY_MARGIN_RATES) - $colspan++; - if($conf->global->DISPLAY_MARK_RATES) - $colspan++; -} -?> - <td colspan="<?php echo $colspan; ?>"> </td> -</tr> - -<form name="addpredefinedproduct" id="addpredefinedproduct" action="<?php echo $_SERVER["PHP_SELF"].'?id='.$this->id; ?>#add" method="POST"> -<input type="hidden" name="token" value="<?php echo $_SESSION['newtoken']; ?>" /> -<input type="hidden" name="action" value="addline" /> -<input type="hidden" name="id" value="<?php echo $this->id; ?>" /> - -<script type="text/javascript"> -jQuery(document).ready(function() { - jQuery('#idprod').change(function() { - jQuery('#dp_desc').focus(); - }); -}); -</script> - -<tr <?php echo $bcnd[$var]; ?>> - <td<?php echo (! empty($conf->global->MAIN_VIEW_LINE_NUMBER) ? ' colspan="3"' : ' colspan="2"'); ?>> - <?php - - $ajaxoptions=array( - 'update' => array( - 'dp_price_ht' => 'price_ht', - 'dp_price_ttc' => 'price_ttc' - ) - ); - $form->select_produits('', 'idprod', '', $conf->product->limit_size, $buyer->price_level, 1, 2, '', 0, $ajaxoptions); - - if (is_object($hookmanager)) - { - $parameters=array('fk_parent_line'=>$_POST["fk_parent_line"]); - $reshook=$hookmanager->executeHooks('formCreateProductOptions',$parameters,$object,$action); - } - - // Editor wysiwyg - require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $nbrows=ROWS_2; - if (! empty($conf->global->MAIN_INPUT_DESC_HEIGHT)) $nbrows=$conf->global->MAIN_INPUT_DESC_HEIGHT; - $doleditor=new DolEditor('dp_desc',$_POST["dp_desc"],'',100,'dolibarr_details','',false,true,$conf->global->FCKEDITOR_ENABLE_DETAILS,$nbrows,70); - $doleditor->Create(); - ?> - </td> - <td align="right"><input type="text" size="6" id="dp_price_ht" name="dp_price_ht" value="<?php echo (isset($_POST["dp_price_ht"])?$_POST["dp_price_ht"]:''); ?>"></td> - <td align="right"><input type="text" size="6" id="dp_price_ttc" name="dp_price_ttc" value="<?php echo (isset($_POST["dp_price_ttc"])?$_POST["dp_price_ttc"]:''); ?>"></td> - <td align="right"><input type="text" size="2" name="qty" value="1"></td> - <td align="right" nowrap="nowrap"><input type="text" size="1" name="remise_percent" value="<?php echo $buyer->remise_client; ?>">%</td> -<?php -$colspan = 4; -if (! empty($conf->margin->enabled)) { -?> - <td align="right"> - <select id="dp_fournprice" name="dp_fournprice" style="display: none;"></select> - <input type="text" size="5" id="dp_buying_price" name="dp_buying_price" value="<?php echo (isset($_POST["dp_buying_price"])?$_POST["dp_buying_price"]:''); ?>"> - </td> -<?php - if($conf->global->DISPLAY_MARGIN_RATES) - $colspan++; - if($conf->global->DISPLAY_MARK_RATES) - $colspan++; -} -?> - <td align="center" valign="middle" colspan="<?php echo $colspan; ?>"><input type="submit" class="button" value="<?php echo $langs->trans("Add"); ?>" name="addline"></td> -</tr> - -<?php if (! empty($conf->service->enabled) && $dateSelector) { -if (! empty($conf->global->MAIN_VIEW_LINE_NUMBER)) - $colspan = 10; -else - $colspan = 9; -if (! empty($conf->margin->enabled)) { - if($conf->global->DISPLAY_MARGIN_RATES) - $colspan++; - if($conf->global->DISPLAY_MARK_RATES) - $colspan++; -} -?> -<tr <?php echo $bcnd[$var]; ?>> - <td colspan="<?php echo $colspan; ?>"> - <?php - echo $langs->trans('ServiceLimitedDuration').' '.$langs->trans('From').' '; - echo $form->select_date('','date_start_predef',$conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE,$conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE,1,"addpredefinedproduct"); - echo ' '.$langs->trans('to').' '; - echo $form->select_date('','date_end_predef',$conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE,$conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE,1,"addpredefinedproduct"); - ?> - </td> -</tr> -<?php } ?> - -</form> -<?php -if (! empty($conf->margin->enabled)) { -?> -<script type="text/javascript"> -$("#idprod").change(function() { - $("#np_fournprice options").remove(); - $("#np_buying_price").show(); - $.post('<?php echo DOL_URL_ROOT; ?>/fourn/ajax/getSupplierPrices.php', {'idprod': $(this).val()}, function(data) { - if (data.length > 0) { - var options = ''; - var i = 0; - $(data).each(function() { - i++; - options += '<option value="'+this.id+'" price="'+this.price+'"'; - if (i == 1) { - options += ' selected'; - $("#np_buying_price").val(this.price); - } - options += '>'+this.label+'</option>'; - }); - options += '<option value=null><?php echo $langs->trans("InputPrice"); ?></option>'; - $("#np_fournprice").html(options); - $("#np_buying_price").hide(); - $("#np_fournprice").show(); - $("#np_fournprice").change(function() { - var selval = $(this).find('option:selected').attr("price"); - if (selval) - $("#np_buying_price").val(selval).hide(); - else - $('#np_buying_price').show(); - }); - } - }, - 'json'); -}); -</script> -<?php } ?> -<!-- END PHP TEMPLATE predefinedproductline_create.tpl.php --> diff --git a/htdocs/core/tpl/predefinedproductline_edit.tpl.php b/htdocs/core/tpl/predefinedproductline_edit.tpl.php deleted file mode 100644 index 4c9cd208eee7428eab87ceb5615adee64a702e45..0000000000000000000000000000000000000000 --- a/htdocs/core/tpl/predefinedproductline_edit.tpl.php +++ /dev/null @@ -1,164 +0,0 @@ -<?php -/* Copyright (C) 2010-2011 Regis Houssin <regis@dolibarr.fr> - * Copyright (C) 2010-2011 Laurent Destailleur <eldy@users.sourceforge.net> - * Copyright (C) 2012 Christophe Battarel <christophe.battarel@altairis.fr> - * - * 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 <http://www.gnu.org/licenses/>. - * - * - * Need to have following variables defined: - * $conf - * $langs - * $dateSelector - * $this (invoice, order, ...) - * $line defined - */ -?> - -<!-- BEGIN PHP TEMPLATE predefinedproductline_edit.tpl.php --> -<form action="<?php echo $_SERVER["PHP_SELF"].'?id='.$this->id.'#'.$line->id; ?>" method="POST"> -<input type="hidden" name="token" value="<?php echo $_SESSION['newtoken']; ?>" /> -<input type="hidden" name="action" value="updateligne" /> -<input type="hidden" name="id" value="<?php echo $this->id; ?>" /> -<input type="hidden" name="lineid" value="<?php echo $line->id; ?>" /> - -<tr <?php echo $bc[$var]; ?>> - <td<?php echo (! empty($conf->global->MAIN_VIEW_LINE_NUMBER) ? ' colspan="2"' : ''); ?>> - <div id="<?php echo $line->id; ?>"></div> - <input type="hidden" name="productid" value="<?php echo $line->fk_product; ?>" /> - <a href="<?php echo DOL_URL_ROOT.'/product/fiche.php?id='.$line->fk_product; ?>"> - <?php - if ($line->product_type==1) echo img_object($langs->trans('ShowService'),'service'); - else print img_object($langs->trans('ShowProduct'),'product'); - echo ' '.$line->ref; - ?> - </a> - <?php - echo ' - '.nl2br($line->product_label); - echo '<br>'; - - if (is_object($hookmanager)) - { - $fk_parent_line = ($_POST["fk_parent_line"] ? $_POST["fk_parent_line"] : $line->fk_parent_line); - $parameters=array('line'=>$line,'fk_parent_line'=>$fk_parent_line,'var'=>$var,'dateSelector'=>$dateSelector,'seller'=>$seller,'buyer'=>$buyer); - $reshook=$hookmanager->executeHooks('formEditProductOptions',$parameters,$this,$action); - } - - // editeur wysiwyg - $nbrows=ROWS_2; - if (! empty($conf->global->MAIN_INPUT_DESC_HEIGHT)) $nbrows=$conf->global->MAIN_INPUT_DESC_HEIGHT; - require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor=new DolEditor('desc',$line->description,'',164,'dolibarr_details','',false,true,$conf->global->FCKEDITOR_ENABLE_DETAILS,$nbrows,70); - $doleditor->Create(); - ?> - </td> - - <td align="right"><?php echo $form->load_tva('tva_tx',$line->tva_tx,$seller,$buyer,'',$line->info_bits); ?></td> - - <td align="right"> - <input size="6" type="text" class="flat" name="subprice" value="<?php echo price($line->subprice,0,'',0); ?>" /> - </td> - - <td align="right"> - <?php if (($line->info_bits & 2) != 2) { ?> - <input size="2" type="text" class="flat" name="qty" value="<?php echo $line->qty; ?>" /> - <?php } else { ?> <?php } ?> - </td> - - <td align="right" nowrap> - <?php if (($line->info_bits & 2) != 2) { ?> - <input size="1" type="text" class="flat" name="remise_percent" value="<?php echo $line->remise_percent; ?>" />% - <?php } else { ?> - - <?php } ?> - </td> -<?php -if (! empty($conf->margin->enabled)) { -?> - <td align="right"> - <select id="fournprice" name="fournprice"></select> - <input type="text" size="5" id="buying_price" name="buying_price" style="display: none;" value="<?php echo price($line->pa_ht,0,'',0); ?>"> - </td> -<?php -} -?> - - <td align="center" colspan="5" valign="middle"> - <input type="submit" class="button" name="save" value="<?php echo $langs->trans("Save"); ?>"><br> - <input type="submit" class="button" name="cancel" value="<?php echo $langs->trans("Cancel"); ?>"> - </td> -</tr> - -<?php if ($conf->service->enabled && $dateSelector && $line->product_type == 1) { ?> -<tr <?php echo $bc[$var]; ?>> - <td colspan="9"><?php echo $langs->trans('ServiceLimitedDuration').' '.$langs->trans('From').' '; ?> - <?php - echo $form->select_date($line->date_start,'date_start',$conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE,$conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE,$line->date_start?0:1,"updateligne"); - echo ' '.$langs->trans('to').' '; - echo $form->select_date($line->date_end,'date_end',$conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE,$conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE,$line->date_end?0:1,"updateligne"); - ?> - </td> -</tr> -<?php } ?></form> -<?php -if (! empty($conf->margin->enabled)) { -?> -<script type="text/javascript"> -$(document).ready(function() { - $.post('<?php echo DOL_URL_ROOT; ?>/fourn/ajax/getSupplierPrices.php', {'idprod': <?php echo $line->fk_product; ?>}, function(data) { - if (data.length > 0) { - var options = ''; - var trouve=false; - $(data).each(function() { - options += '<option value="'+this.id+'" price="'+this.price+'"'; - <?php - if ($line->fk_fournprice > 0) { - ?> - if (this.id == <?php echo $line->fk_fournprice; ?>) { - options += ' selected'; - $("#buying_price").val(this.price); - trouve = true; - } - <?php - } - ?> - options += '>'+this.label+'</option>'; - }); - options += '<option value=null'+(trouve?'':' selected')+'><?php echo $langs->trans("InputPrice"); ?></option>'; - $("#fournprice").html(options); - if (trouve) { - $("#buying_price").hide(); - $("#fournprice").show(); - } - else { - $("#buying_price").show(); - } - $("#fournprice").change(function() { - var selval = $(this).find('option:selected').attr("price"); - if (selval) - $("#buying_price").val(selval).hide(); - else - $('#buying_price').show(); - }); - } - else { - $("#fournprice").hide(); - $('#buying_price').show(); - } - }, - 'json'); -}); -</script> -<?php } ?> -<!-- END PHP TEMPLATE predefinedproductline_edit.tpl.php --> diff --git a/htdocs/core/tpl/predefinedproductline_view.tpl.php b/htdocs/core/tpl/predefinedproductline_view.tpl.php deleted file mode 100644 index e7773c48da3affd08c45d1cfe45966555221691c..0000000000000000000000000000000000000000 --- a/htdocs/core/tpl/predefinedproductline_view.tpl.php +++ /dev/null @@ -1,112 +0,0 @@ -<?php -/* Copyright (C) 2010-2011 Regis Houssin <regis@dolibarr.fr> - * Copyright (C) 2010-2011 Laurent Destailleur <eldy@users.sourceforge.net> - * Copyright (C) 2012 Christophe Battarel <christophe.battarel@altairis.fr> - * - * 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 <http://www.gnu.org/licenses/>. - * - */ -?> - -<!-- BEGIN PHP TEMPLATE predefinedproductline_view.tpl.php --> -<tr <?php echo 'id="row-'.$line->id.'" '.$bcdd[$var]; ?>> - <?php if (! empty($conf->global->MAIN_VIEW_LINE_NUMBER)) { ?> - <td align="center"><?php echo ($i+1); ?></td> - <?php } ?> - <td><div id="<?php echo $line->id; ?>"></div> - <?php - echo $form->textwithtooltip($text,$description,3,'','',$i,0,($line->fk_parent_line?img_picto('', 'rightarrow'):'')); - - // Show range - print_date_range($line->date_start, $line->date_end); - - // Add description in form - if ($conf->global->PRODUIT_DESC_IN_FORM) - { - print (! empty($line->description) && $line->description!=$line->product_label)?'<br>'.dol_htmlentitiesbr($line->description):''; - } - ?> - </td> - - <td align="right" nowrap="nowrap"><?php echo vatrate($line->tva_tx,'%',$line->info_bits); ?></td> - - <td align="right" nowrap="nowrap"><?php echo price($line->subprice); ?></td> - - <td align="right" nowrap="nowrap"> </td> - - <td align="right" nowrap="nowrap"> - <?php if ((($line->info_bits & 2) != 2) && $line->special_code != 3) echo $line->qty; - else echo ' '; ?> - </td> - - <?php if (!empty($line->remise_percent) && $line->special_code != 3) { ?> - <td align="right"><?php echo dol_print_reduction($line->remise_percent,$langs); ?></td> - <?php } else { ?> - <td> </td> - <?php } - - if (! empty($conf->margin->enabled)) { ?> - <td align="right" nowrap="nowrap"><?php echo price($line->pa_ht); ?></td> - <?php if ($conf->global->DISPLAY_MARGIN_RATES) {?> - <td align="right" nowrap="nowrap"><?php echo (($line->pa_ht == 0)?'n/a':price($line->marge_tx).'%'); ?></td> - <?php - } - if ($conf->global->DISPLAY_MARK_RATES) { ?> - <td align="right" nowrap="nowrap"><?php echo price($line->marque_tx).'%'; ?></td> - <?php } } ?> - - <?php if ($line->special_code == 3) { ?> - <td align="right" nowrap="nowrap"><?php echo $langs->trans('Option'); ?></td> - <?php } else { ?> - <td align="right" nowrap="nowrap"><?php echo price($line->total_ht); ?></td> - <?php } ?> - - <?php if ($this->statut == 0 && $user->rights->$element->creer) { ?> - <td align="center"> - <?php if (($line->info_bits & 2) == 2) { ?> - <?php } else { ?> - <a href="<?php echo $_SERVER["PHP_SELF"].'?id='.$this->id.'&action=editline&lineid='.$line->id.'#'.$line->id; ?>"> - <?php echo img_edit(); ?> - </a> - <?php } ?> - </td> - - <td align="center"> - <a href="<?php echo $_SERVER["PHP_SELF"].'?id='.$this->id.'&action=ask_deleteline&lineid='.$line->id; ?>"> - <?php echo img_delete(); ?> - </a> - </td> - - <?php if ($num > 1) { ?> - <td align="center" class="tdlineupdown"> - <?php if ($i > 0) { ?> - <a class="lineupdown" href="<?php echo $_SERVER["PHP_SELF"].'?id='.$this->id.'&action=up&rowid='.$line->id; ?>"> - <?php echo img_up(); ?> - </a> - <?php } ?> - <?php if ($i < $num-1) { ?> - <a class="lineupdown" href="<?php echo $_SERVER["PHP_SELF"].'?id='.$this->id.'&action=down&rowid='.$line->id; ?>"> - <?php echo img_down(); ?> - </a> - <?php } ?> - </td> - <?php } else { ?> - <td align="center" class="tdlineupdown"> </td> - <?php } ?> -<?php } else { ?> - <td colspan="3"> </td> -<?php } ?> - -</tr> -<!-- END PHP TEMPLATE predefinedproductline_view.tpl.php -->