diff --git a/htdocs/comm/propal.php b/htdocs/comm/propal.php index 809f97f27f5..171746ac591 100644 --- a/htdocs/comm/propal.php +++ b/htdocs/comm/propal.php @@ -80,7 +80,7 @@ if ($id > 0 || ! empty($ref)) $ret=$object->fetch($id, $ref); if ($ret == 0) { - $langs->load("errors"); + $langs->load("errors"); setEventMessage($langs->trans('ErrorRecordNotFound'), 'errors'); $error++; } @@ -94,7 +94,7 @@ if ($id > 0 || ! empty($ref)) } else { - Header('Location: '.DOL_URL_ROOT.'/comm/propal/list.php'); + Header('Location: '.DOL_URL_ROOT.'/comm/propal/list.php'); exit; } @@ -633,24 +633,32 @@ else if ($action == "setabsolutediscount" && $user->rights->propal->creer) else if ($action == "addline" && $user->rights->propal->creer) { $idprod=GETPOST('idprod', 'int'); + $product_desc = (GETPOST('product_desc')?GETPOST('product_desc'):(GETPOST('np_desc')?GETPOST('np_desc'):(GETPOST('dp_desc')?GETPOST('dp_desc'):''))); + $price_ht = GETPOST('price_ht'); + $np_price = GETPOST('np_price'); if (empty($idprod) && GETPOST('type') < 0) { setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Type")), 'errors'); $error++; } - if (empty($idprod) && (!(GETPOST('price_ht') >= 0) || GETPOST('price_ht') == '')) // Unit price can be 0 but not '' + if ($conf->global->MAIN_FEATURES_LEVEL > 1 && empty($idprod) && (!($price_ht >= 0) || $price_ht == '')) // Unit price can be 0 but not '' { setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("UnitPriceHT")), 'errors'); $error++; } - if (empty($idprod) && ! GETPOST('product_desc')) + else if (empty($idprod) && (!($np_price >= 0) || $np_price == '')) // Unit price can be 0 but not '' + { + setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("UnitPriceHT")), 'errors'); + $error++; + } + if (empty($idprod) && empty($product_desc)) { setEventMessage($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Description")), 'errors'); $error++; } - if (! $error && (GETPOST('qty') >= 0) && (GETPOST('product_desc') || ! empty($idprod))) + if (! $error && (GETPOST('qty') >= 0) && (! empty($product_desc) || ! empty($idprod))) { $pu_ht=0; $pu_ttc=0; @@ -718,7 +726,7 @@ else if ($action == "addline" && $user->rights->propal->creer) if (GETPOST('update_desc')) { - $desc = (GETPOST('product_desc')?GETPOST('product_desc'):''); + $desc = $product_desc; } else { @@ -742,8 +750,8 @@ else if ($action == "addline" && $user->rights->propal->creer) $desc = $prod->description; } - $desc.= ($desc && GETPOST('product_desc')) ? ((dol_textishtml($desc) || dol_textishtml(GETPOST('product_desc')))?"
\n":"\n") : ""; - $desc.= GETPOST('product_desc'); + $desc.= ($desc && ! empty($product_desc)) ? ((dol_textishtml($desc) || dol_textishtml($product_desc))?"
\n":"\n") : ""; + $desc.= $product_desc; } $label = ((GETPOST('update_label') && GETPOST('product_label')) ? GETPOST('product_label'):''); @@ -752,17 +760,18 @@ else if ($action == "addline" && $user->rights->propal->creer) } else { - $pu_ht=GETPOST('price_ht'); - $tva_tx=str_replace('*','',GETPOST('tva_tx')); - $tva_npr=preg_match('/\*/',GETPOST('tva_tx'))?1:0; + $pu_ht=(isset($price_ht)?$price_ht:$np_price); + $rate=GETPOST('tva_tx')?GETPOST('tva_tx'):GETPOST('np_tva_tx'); + $tva_tx=str_replace('*','',$rate); + $tva_npr=preg_match('/\*/',$rate)?1:0; $label=(GETPOST('product_label')?GETPOST('product_label'):''); - $desc=GETPOST('product_desc'); + $desc=$product_desc; $type=GETPOST('type'); } // Margin - $fournprice=(GETPOST('fournprice')?GETPOST('fournprice'):''); - $buyingprice=(GETPOST('buying_price')?GETPOST('buying_price'):''); + $fournprice=(GETPOST('fournprice')?GETPOST('fournprice'):(GETPOST('np_fournprice')?GETPOST('np_fournprice'):'')); + $buyingprice=(GETPOST('buying_price')?GETPOST('buying_price'):(GETPOST('np_buying_price')?GETPOST('np_buying_price'):'')); // Local Taxes $localtax1_tx= get_localtax($tva_tx, 1, $object->client); @@ -831,6 +840,13 @@ else if ($action == "addline" && $user->rights->propal->creer) unset($_POST['product_desc']); unset($_POST['fournprice']); unset($_POST['buying_price']); + + // old method + unset($_POST['np_price']); + unset($_POST['np_desc']); + unset($_POST['dp_desc']); + unset($_POST['np_fournprice']); + unset($_POST['np_buying_price']); } else { @@ -1634,8 +1650,23 @@ if ($object->statut == 0 && $user->rights->propal->creer) { $var=true; - // Add free or predefined products/services - $object->formAddObjectLine(0,$mysoc,$soc,$hookmanager); + if ($conf->global->MAIN_FEATURES_LEVEL > 1) + { + // Add free or predefined products/services + $object->formAddObjectLine(0,$mysoc,$soc,$hookmanager); + } + else + { + // Add free 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('formAddObjectLine',$parameters,$object,$action); // Note that $action and $object may have been modified by hook diff --git a/htdocs/comm/propal/contact.php b/htdocs/comm/propal/contact.php index 60f354d5f2a..9e45b637878 100644 --- a/htdocs/comm/propal/contact.php +++ b/htdocs/comm/propal/contact.php @@ -147,75 +147,75 @@ $form = new Form($db); $formcompany= new FormCompany($db); $formother = new FormOther($db); -if ($object->id > 0) -{ - $head = propal_prepare_head($object); - dol_fiche_head($head, 'contact', $langs->trans("Proposal"), 0, 'propal'); - - /* +if ($object->id > 0) +{ + $head = propal_prepare_head($object); + dol_fiche_head($head, 'contact', $langs->trans("Proposal"), 0, 'propal'); + + /* * Propal synthese pour rappel - */ - print ''; - - $linkback=''.$langs->trans("BackToList").''; - - // Ref - print ''; - - // Ref client - print ''; - print ''; - - // Customer - print ""; - print ''; - - // Delivery address - if (! empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT)) - { - print ''; + print '
'.$langs->trans('Ref').''; - print $form->showrefnav($object,'ref',$linkback,1,'ref','ref',''); - print '
'; - print ''; - print '
'; - print $langs->trans('RefCustomer').''; - print '
'; - print '
'; - print $object->ref_client; - print '
".$langs->trans("Company")."'.$object->client->getNomUrl(1).'
'; - print ''; - + */ + print '
'; - print $langs->trans('DeliveryAddress'); - print '
'; + + $linkback=''.$langs->trans("BackToList").''; + + // Ref + print ''; + + // Ref client + print ''; + print ''; + + // Customer + print ""; + print ''; + + // Delivery address + if (! empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT)) + { + print ''; - } - - print "
'.$langs->trans('Ref').''; + print $form->showrefnav($object,'ref',$linkback,1,'ref','ref',''); + print '
'; + print ''; + print '
'; + print $langs->trans('RefCustomer').''; + print '
'; + print '
'; + print $object->ref_client; + print '
".$langs->trans("Company")."'.$object->client->getNomUrl(1).'
'; + print ''; + if ($action != 'editdelivery_address' && ! empty($object->brouillon)) - print ''; - print '
'; + print $langs->trans('DeliveryAddress'); + print 'socid.'&id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetDeliveryAddress'),1).'
'; - print '
'; - - if ($action == 'editdelivery_address') - { - $formother->form_address($_SERVER['PHP_SELF'].'?id='.$object->id,$object->fk_delivery_address,$object->socid,'fk_address','propal',$object->id); - } - else - { - $formother->form_address($_SERVER['PHP_SELF'].'?id='.$object->id,$object->fk_delivery_address,$object->socid,'none','propal',$object->id); - } - print '
"; - - print ''; - - print '
'; - - // Contacts lines (modules that overwrite templates must declare this into descriptor) - $dirtpls=array_merge($conf->modules_parts['tpl'],array('/core/tpl')); - foreach($dirtpls as $reldir) - { - $res=@include dol_buildpath($reldir.'/contacts.tpl.php'); - if ($res) break; - } + print '
socid.'&id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetDeliveryAddress'),1).'
'; + print ''; + + if ($action == 'editdelivery_address') + { + $formother->form_address($_SERVER['PHP_SELF'].'?id='.$object->id,$object->fk_delivery_address,$object->socid,'fk_address','propal',$object->id); + } + else + { + $formother->form_address($_SERVER['PHP_SELF'].'?id='.$object->id,$object->fk_delivery_address,$object->socid,'none','propal',$object->id); + } + print ''; + } + + print ""; + + print ''; + + print '
'; + + // Contacts lines (modules that overwrite templates must declare this into descriptor) + $dirtpls=array_merge($conf->modules_parts['tpl'],array('/core/tpl')); + foreach($dirtpls as $reldir) + { + $res=@include dol_buildpath($reldir.'/contacts.tpl.php'); + if ($res) break; + } } llxFooter(); diff --git a/htdocs/commande/fiche.php b/htdocs/commande/fiche.php index 509ef57a856..579472db09c 100644 --- a/htdocs/commande/fiche.php +++ b/htdocs/commande/fiche.php @@ -525,8 +525,16 @@ else if ($action == 'addline' && $user->rights->commande->creer) $error = false; $idprod=GETPOST('idprod', 'int'); + $product_desc = (GETPOST('product_desc')?GETPOST('product_desc'):(GETPOST('np_desc')?GETPOST('np_desc'):(GETPOST('dp_desc')?GETPOST('dp_desc'):''))); + $price_ht = GETPOST('price_ht'); + $np_price = GETPOST('np_price'); - if ((empty($idprod) || GETPOST('update_price')) && (GETPOST('price_ht') < 0) && (GETPOST('qty') < 0)) + if ($conf->global->MAIN_FEATURES_LEVEL > 1 && (empty($idprod) || GETPOST('update_price')) && ($price_ht < 0) && (GETPOST('qty') < 0)) + { + setEventMessage($langs->trans('ErrorBothFieldCantBeNegative', $langs->transnoentitiesnoconv('UnitPriceHT'), $langs->transnoentitiesnoconv('Qty')), 'errors'); + $error = true; + } + else if (empty($idprod) && ($np_price < 0) && (GETPOST('qty') < 0)) { setEventMessage($langs->trans('ErrorBothFieldCantBeNegative', $langs->transnoentitiesnoconv('UnitPriceHT'), $langs->transnoentitiesnoconv('Qty')), 'errors'); $error = true; @@ -536,27 +544,33 @@ else if ($action == 'addline' && $user->rights->commande->creer) setEventMessage($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Type')), 'errors'); $error = true; } - if (empty($idprod) && (!(GETPOST('price_ht') >= 0) || GETPOST('price_ht') == '')) // Unit price can be 0 but not '' + if ($conf->global->MAIN_FEATURES_LEVEL > 1 && empty($idprod) && (!($price_ht >= 0) || $price_ht == '')) // Unit price can be 0 but not '' { - setEventMessage($langs->trans($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('UnitPriceHT'))), 'errors'); - $error = true; + setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("UnitPriceHT")), 'errors'); + $error++; + } + else if (empty($idprod) && (!($np_price >= 0) || $np_price == '')) // Unit price can be 0 but not '' + { + setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("UnitPriceHT")), 'errors'); + $error++; } if (! GETPOST('qty') && GETPOST('qty') == '') { setEventMessage($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Qty')), 'errors'); $error = true; } - if (empty($idprod) && ! GETPOST('product_desc')) + if (empty($idprod) && empty($product_desc)) { setEventMessage($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Description')), 'errors'); $error = true; } - if (! $error && (GETPOST('qty') >= 0) && (GETPOST('product_desc') || ! empty($idprod))) + if (! $error && (GETPOST('qty') >= 0) && (! empty($product_desc) || ! empty($idprod))) { // Clean parameters - $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')); + $predef=((! empty($idprod) && $conf->global->MAIN_FEATURES_LEVEL < 2) ? '_predef' : ''); + $date_start=dol_mktime(0, 0, 0, GETPOST('date_start'.$predef.'month'), GETPOST('date_start'.$predef.'day'), GETPOST('date_start'.$predef.'year')); + $date_end=dol_mktime(0, 0, 0, GETPOST('date_end'.$predef.'month'), GETPOST('date_end'.$predef.'day'), GETPOST('date_end'.$predef.'year')); $price_base_type = 'HT'; // Ecrase $pu par celui du produit @@ -621,7 +635,7 @@ else if ($action == 'addline' && $user->rights->commande->creer) if (GETPOST('update_desc')) { - $desc = (GETPOST('product_desc')?GETPOST('product_desc'):''); + $desc = $product_desc; } else { @@ -645,8 +659,8 @@ else if ($action == 'addline' && $user->rights->commande->creer) $desc = $prod->description; } - $desc.= ($desc && GETPOST('product_desc')) ? ((dol_textishtml($desc) || dol_textishtml(GETPOST('product_desc')))?"
\n":"\n") : ""; - $desc.= GETPOST('product_desc'); + $desc.= ($desc && ! empty($product_desc)) ? ((dol_textishtml($desc) || dol_textishtml($product_desc))?"
\n":"\n") : ""; + $desc.= $product_desc; } $label = ((GETPOST('update_label') && GETPOST('product_label')) ? GETPOST('product_label'):''); @@ -655,17 +669,18 @@ else if ($action == 'addline' && $user->rights->commande->creer) } else { - $pu_ht=GETPOST('price_ht'); - $tva_tx=str_replace('*','',GETPOST('tva_tx')); - $tva_npr=preg_match('/\*/',GETPOST('tva_tx'))?1:0; + $pu_ht=($price_ht?$price_ht:$np_price); + $rate=GETPOST('tva_tx')?GETPOST('tva_tx'):GETPOST('np_tva_tx'); + $tva_tx=str_replace('*','',$rate); + $tva_npr=preg_match('/\*/',$rate)?1:0; $label=(GETPOST('product_label')?GETPOST('product_label'):''); - $desc=GETPOST('product_desc'); + $desc=$product_desc; $type=GETPOST('type'); } // Margin - $fournprice=(GETPOST('fournprice')?GETPOST('fournprice'):''); - $buyingprice=(GETPOST('buying_price')?GETPOST('buying_price'):''); + $fournprice=(GETPOST('fournprice')?GETPOST('fournprice'):(GETPOST('np_fournprice')?GETPOST('np_fournprice'):'')); + $buyingprice=(GETPOST('buying_price')?GETPOST('buying_price'):(GETPOST('np_buying_price')?GETPOST('np_buying_price'):'')); // Local Taxes $localtax1_tx= get_localtax($tva_tx, 1, $object->client); @@ -739,6 +754,13 @@ else if ($action == 'addline' && $user->rights->commande->creer) unset($_POST['product_desc']); unset($_POST['fournprice']); unset($_POST['buying_price']); + + // old method + unset($_POST['np_price']); + unset($_POST['np_desc']); + unset($_POST['dp_desc']); + unset($_POST['np_fournprice']); + unset($_POST['np_buying_price']); } else { @@ -2145,7 +2167,23 @@ if ($action == 'send' && ! GETPOST('addfile') && ! GETPOST('removedfile') && ! G { $var=true; - $object->formAddObjectLine(1,$mysoc,$soc,$hookmanager); + if ($conf->global->MAIN_FEATURES_LEVEL > 1) + { + // Add free or predefined products/services + $object->formAddObjectLine(1,$mysoc,$soc,$hookmanager); + } + else + { + // Add free products/services + $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('formAddObjectLine',$parameters,$object,$action); // Note that $action and $object may have been modified by hook diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index 8d7c10787b3..383e12e2ed8 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -948,10 +948,18 @@ else if (($action == 'addline' || $action == 'addline_predef') && $user->rights- $error = false; $idprod=GETPOST('idprod', 'int'); + $product_desc = (GETPOST('product_desc')?GETPOST('product_desc'):(GETPOST('np_desc')?GETPOST('np_desc'):(GETPOST('dp_desc')?GETPOST('dp_desc'):''))); + $price_ht = GETPOST('price_ht'); + $np_price = GETPOST('np_price'); - if ((empty($idprod) || GETPOST('update_price')) && (GETPOST('price_ht') < 0) && (GETPOST('qty') < 0)) + if ($conf->global->MAIN_FEATURES_LEVEL > 1 && (empty($idprod) || GETPOST('update_price')) && ($price_ht < 0) && (GETPOST('qty') < 0)) { - setEventMessage($langs->trans('ErrorBothFieldCantBeNegative', $langs->transnoentitiesnoconv('UnitPriceHT'), $langs->transnoentitiesnoconv('Qty')), 'errors'); + setEventMessage($langs->trans('ErrorBothFieldCantBeNegative', $langs->transnoentitiesnoconv('UnitPriceHT'), $langs->transnoentitiesnoconv('Qty')), 'errors'); + $error = true; + } + else if (empty($idprod) && ($np_price < 0) && (GETPOST('qty') < 0)) + { + setEventMessage($langs->trans('ErrorBothFieldCantBeNegative', $langs->transnoentitiesnoconv('UnitPriceHT'), $langs->transnoentitiesnoconv('Qty')), 'errors'); $error = true; } if (empty($idprod) && GETPOST('type') < 0) @@ -959,23 +967,28 @@ else if (($action == 'addline' || $action == 'addline_predef') && $user->rights- setEventMessage($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Type')), 'errors'); $error = true; } - if (empty($idprod) && (!(GETPOST('price_ht') >= 0) || GETPOST('price_ht') == '')) // Unit price can be 0 but not '' - { - setEventMessage($langs->trans($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('UnitPriceHT'))), 'errors'); - $error = true; - } + if ($conf->global->MAIN_FEATURES_LEVEL > 1 && empty($idprod) && (!($price_ht >= 0) || $price_ht == '')) // Unit price can be 0 but not '' + { + setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("UnitPriceHT")), 'errors'); + $error++; + } + else if (empty($idprod) && (!($np_price >= 0) || $np_price == '')) // Unit price can be 0 but not '' + { + setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("UnitPriceHT")), 'errors'); + $error++; + } if (! GETPOST('qty') && GETPOST('qty') == '') { setEventMessage($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Qty')), 'errors'); $error = true; } - if (empty($idprod) && ! GETPOST('product_desc')) + if (empty($idprod) && empty($product_desc)) { setEventMessage($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Description')), 'errors'); $error = true; } - if (! $error && (GETPOST('qty') >= 0) && (GETPOST('product_desc') || ! empty($idprod))) + if (! $error && (GETPOST('qty') >= 0) && (! empty($product_desc) || ! empty($idprod))) { $ret=$object->fetch($id); if ($ret < 0) @@ -986,8 +999,9 @@ else if (($action == 'addline' || $action == 'addline_predef') && $user->rights- $ret=$object->fetch_thirdparty(); // Clean parameters - $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')); + $predef=((! empty($idprod) && $conf->global->MAIN_FEATURES_LEVEL < 2) ? '_predef' : ''); + $date_start=dol_mktime(GETPOST('date_start'.$predef.'hour'), GETPOST('date_start'.$predef.'min'), GETPOST('date_start'.$predef.'sec'), GETPOST('date_start'.$predef.'month'), GETPOST('date_start'.$predef.'day'), GETPOST('date_start'.$predef.'year')); + $date_end=dol_mktime(GETPOST('date_end'.$predef.'hour'), GETPOST('date_end'.$predef.'min'), GETPOST('date_end'.$predef.'sec'), GETPOST('date_end'.$predef.'month'), GETPOST('date_end'.$predef.'day'), GETPOST('date_end'.$predef.'year')); $price_base_type = 'HT'; // Ecrase $pu par celui du produit @@ -1052,7 +1066,7 @@ else if (($action == 'addline' || $action == 'addline_predef') && $user->rights- if (GETPOST('update_desc')) { - $desc = (GETPOST('product_desc')?GETPOST('product_desc'):''); + $desc = $product_desc; } else { @@ -1076,8 +1090,8 @@ else if (($action == 'addline' || $action == 'addline_predef') && $user->rights- $desc = $prod->description; } - $desc.= ($desc && GETPOST('product_desc')) ? ((dol_textishtml($desc) || dol_textishtml(GETPOST('product_desc')))?"
\n":"\n") : ""; - $desc.= GETPOST('product_desc'); + $desc.= ($desc && ! empty($product_desc)) ? ((dol_textishtml($desc) || dol_textishtml($product_desc))?"
\n":"\n") : ""; + $desc.= $product_desc; } if (! empty($prod->customcode) || ! empty($prod->country_code)) @@ -1096,17 +1110,18 @@ else if (($action == 'addline' || $action == 'addline_predef') && $user->rights- } else { - $pu_ht=GETPOST('price_ht'); - $tva_tx=str_replace('*','',GETPOST('tva_tx')); - $tva_npr=preg_match('/\*/',GETPOST('tva_tx'))?1:0; + $pu_ht=($price_ht?$price_ht:$np_price); + $rate=GETPOST('tva_tx')?GETPOST('tva_tx'):GETPOST('np_tva_tx'); + $tva_tx=str_replace('*','',$rate); + $tva_npr=preg_match('/\*/',$rate)?1:0; $label=(GETPOST('product_label')?GETPOST('product_label'):''); - $desc=GETPOST('product_desc'); + $desc=$product_desc; $type=GETPOST('type'); } // Margin - $fournprice=(GETPOST('fournprice')?GETPOST('fournprice'):''); - $buyingprice=(GETPOST('buying_price')?GETPOST('buying_price'):''); + $fournprice=(GETPOST('fournprice')?GETPOST('fournprice'):(GETPOST('np_fournprice')?GETPOST('np_fournprice'):'')); + $buyingprice=(GETPOST('buying_price')?GETPOST('buying_price'):(GETPOST('np_buying_price')?GETPOST('np_buying_price'):'')); // Local Taxes $localtax1_tx= get_localtax($tva_tx, 1, $object->client); @@ -1181,6 +1196,13 @@ else if (($action == 'addline' || $action == 'addline_predef') && $user->rights- unset($_POST['product_desc']); unset($_POST['fournprice']); unset($_POST['buying_price']); + + // old method + unset($_POST['np_price']); + unset($_POST['np_desc']); + unset($_POST['dp_desc']); + unset($_POST['np_fournprice']); + unset($_POST['np_buying_price']); } else { @@ -3009,7 +3031,23 @@ else if ($id > 0 || ! empty($ref)) { $var=true; - $object->formAddObjectLine(1,$mysoc,$soc,$hookmanager); + if ($conf->global->MAIN_FEATURES_LEVEL > 1) + { + // Add free or predefined products/services + $object->formAddObjectLine(1,$mysoc,$soc,$hookmanager); + } + else + { + // Add free products/services + $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('formAddObjectLine',$parameters,$object,$action); // Note that $action and $object may have been modified by hook diff --git a/htdocs/core/ajax/price.php b/htdocs/core/ajax/price.php index 79f7d1f439b..306519fda94 100644 --- a/htdocs/core/ajax/price.php +++ b/htdocs/core/ajax/price.php @@ -49,18 +49,18 @@ if (! empty($output) && isset($amount) && isset($tva_tx)) if (is_numeric($amount) && $amount != '') { - if ($output == 'price_ttc') { - - $price = price2num($amount * (1 + ($tva_tx/100)), 'MU'); - $return['price_ht'] = $amount; - $return['price_ttc'] = (isset($price) && $price != '' ? price($price) : ''); - - } - else if ($output == 'price_ht') { - - $price = price2num($amount / (1 + ($tva_tx/100)), 'MU'); - $return['price_ht'] = (isset($price) && $price != '' ? price($price) : ''); - $return['price_ttc'] = ($tva_tx == 0 ? $price : $amount); + if ($output == 'price_ttc') { + + $price = price2num($amount * (1 + ($tva_tx/100)), 'MU'); + $return['price_ht'] = $amount; + $return['price_ttc'] = (isset($price) && $price != '' ? price($price) : ''); + + } + else if ($output == 'price_ht') { + + $price = price2num($amount / (1 + ($tva_tx/100)), 'MU'); + $return['price_ht'] = (isset($price) && $price != '' ? price($price) : ''); + $return['price_ttc'] = ($tva_tx == 0 ? $price : $amount); } } diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 0f536a7c746..1fc0023ac3a 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -2444,46 +2444,46 @@ abstract class CommonObject /* This is to show add lines */ - /** - * Show add 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 + /** + * Show add 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 - * @deprecated - */ - function formAddPredefinedProduct($dateSelector,$seller,$buyer,$hookmanager=false) - { - global $conf,$langs,$object; - global $form,$bcnd,$var; - - // Use global variables + $dateSelector + $seller and $buyer - include(DOL_DOCUMENT_ROOT.'/core/tpl/predefinedproductline_create.tpl.php'); - } - - /** - * 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 + * @deprecated + */ + function formAddPredefinedProduct($dateSelector,$seller,$buyer,$hookmanager=false) + { + global $conf,$langs,$object; + global $form,$bcnd,$var; + + // Use global variables + $dateSelector + $seller and $buyer + include(DOL_DOCUMENT_ROOT.'/core/tpl/predefinedproductline_create.tpl.php'); + } + + /** + * 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 - * @deprecated - */ - function formAddFreeProduct($dateSelector,$seller,$buyer,$hookmanager=false) - { - global $conf,$langs,$object; - global $form,$bcnd,$var; - - // Use global variables + $dateSelector + $seller and $buyer - include(DOL_DOCUMENT_ROOT.'/core/tpl/freeproductline_create.tpl.php'); + * @deprecated + */ + function formAddFreeProduct($dateSelector,$seller,$buyer,$hookmanager=false) + { + global $conf,$langs,$object; + global $form,$bcnd,$var; + + // Use global variables + $dateSelector + $seller and $buyer + include(DOL_DOCUMENT_ROOT.'/core/tpl/freeproductline_create.tpl.php'); } @@ -2549,7 +2549,8 @@ abstract class CommonObject print ''.$langs->trans('Description').''; print ''.$langs->trans('VAT').''; print ''.$langs->trans('PriceUHT').''; - print ' '; + if ($conf->global->MAIN_FEATURES_LEVEL > 1) + print ' '; print ''.$langs->trans('Qty').''; print ''.$langs->trans('ReductionShort').''; if (! empty($conf->margin->enabled)) { diff --git a/htdocs/core/modules/dons/html_cerfafr.modules.php b/htdocs/core/modules/dons/html_cerfafr.modules.php index e3e39d92322..d97bedd0936 100644 --- a/htdocs/core/modules/dons/html_cerfafr.modules.php +++ b/htdocs/core/modules/dons/html_cerfafr.modules.php @@ -82,7 +82,7 @@ class html_cerfafr extends ModeleDon $outputlangs->load("companies"); $outputlangs->load("bills"); $outputlangs->load("products"); - $outputlangs->load("donations"); + $outputlangs->load("donations"); if (! empty($conf->don->dir_output)) { @@ -143,17 +143,17 @@ class html_cerfafr extends ModeleDon $form = str_replace('__DonationPaymentDate__',$outputlangs->trans("DonationPaymentDate"),$form); $form = str_replace('__DonationPaymentMode__',$outputlangs->trans("DonationPaymentMode"),$form); $form = str_replace('__Name__',$outputlangs->trans("Name"),$form); - $form = str_replace('__Address__',$outputlangs->trans("Address"),$form); - $form = str_replace('__Zip__',$outputlangs->trans("Zip"),$form); - $form = str_replace('__Town__',$outputlangs->trans("Town"),$form); - $form = str_replace('__Donor__',$outputlangs->trans("Donor"),$form); - $form = str_replace('__Date__',$outputlangs->trans("Date"),$form); - $form = str_replace('__Signature__',$outputlangs->trans("Signature"),$form); + $form = str_replace('__Address__',$outputlangs->trans("Address"),$form); + $form = str_replace('__Zip__',$outputlangs->trans("Zip"),$form); + $form = str_replace('__Town__',$outputlangs->trans("Town"),$form); + $form = str_replace('__Donor__',$outputlangs->trans("Donor"),$form); + $form = str_replace('__Date__',$outputlangs->trans("Date"),$form); + $form = str_replace('__Signature__',$outputlangs->trans("Signature"),$form); $form = str_replace('__ThankYou__',$outputlangs->trans("ThankYou"),$form); $form = str_replace('__IConfirmDonationReception__',$outputlangs->trans("IConfirmDonationReception"),$form); $frencharticle=''; if (preg_match('/fr/i',$outputlangs->defaultlang)) $frencharticle='(Article 200-5 du Code Général des Impôts)
+ article 238 bis'; - $form = str_replace('__FrenchArticle__',$frencharticle,$form); + $form = str_replace('__FrenchArticle__',$frencharticle,$form); // Sauve fichier sur disque dol_syslog("html_cerfafr::write_file $file"); diff --git a/htdocs/core/modules/dons/modules_don.php b/htdocs/core/modules/dons/modules_don.php index 1f7d3f5c965..c86a75652a5 100644 --- a/htdocs/core/modules/dons/modules_don.php +++ b/htdocs/core/modules/dons/modules_don.php @@ -156,10 +156,10 @@ function don_create($db, $id, $message, $modele, $outputlangs) $eror=0; - // Increase limit for PDF build - $err=error_reporting(); - error_reporting(0); - @set_time_limit(120); + // Increase limit for PDF build + $err=error_reporting(); + error_reporting(0); + @set_time_limit(120); error_reporting($err); $srctemplatepath=''; @@ -178,34 +178,34 @@ function don_create($db, $id, $message, $modele, $outputlangs) } } - // If selected modele is a filename template (then $modele="modelname:filename") - $tmp=explode(':',$modele,2); - if (! empty($tmp[1])) - { - $modele=$tmp[0]; - $srctemplatepath=$tmp[1]; - } + // If selected modele is a filename template (then $modele="modelname:filename") + $tmp=explode(':',$modele,2); + if (! empty($tmp[1])) + { + $modele=$tmp[0]; + $srctemplatepath=$tmp[1]; + } - // Search template files - $file=''; $classname=''; $filefound=0; - $dirmodels=array('/'); - if (is_array($conf->modules_parts['models'])) $dirmodels=array_merge($dirmodels,$conf->modules_parts['models']); - foreach($dirmodels as $reldir) - { - foreach(array('html','doc','pdf') as $prefix) - { - $file = $prefix."_".preg_replace('/^html_/','',$modele).".modules.php"; - - // On verifie l'emplacement du modele - $file=dol_buildpath($reldir."core/modules/dons/".$file,0); - if (file_exists($file)) - { - $filefound=1; - $classname=$prefix.'_'.$modele; - break; - } - } - if ($filefound) break; + // Search template files + $file=''; $classname=''; $filefound=0; + $dirmodels=array('/'); + if (is_array($conf->modules_parts['models'])) $dirmodels=array_merge($dirmodels,$conf->modules_parts['models']); + foreach($dirmodels as $reldir) + { + foreach(array('html','doc','pdf') as $prefix) + { + $file = $prefix."_".preg_replace('/^html_/','',$modele).".modules.php"; + + // On verifie l'emplacement du modele + $file=dol_buildpath($reldir."core/modules/dons/".$file,0); + if (file_exists($file)) + { + $filefound=1; + $classname=$prefix.'_'.$modele; + break; + } + } + if ($filefound) break; } // Charge le modele diff --git a/htdocs/core/tpl/freeproductline_edit.tpl.php b/htdocs/core/tpl/freeproductline_edit.tpl.php deleted file mode 100644 index 6a5e6e7ef30..00000000000 --- a/htdocs/core/tpl/freeproductline_edit.tpl.php +++ /dev/null @@ -1,101 +0,0 @@ - - * Copyright (C) 2010-2012 Laurent Destailleur - * Copyright (C) 2012 Christophe Battarel - * - * 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 . - * - * - * Need to have following variables defined: - * $conf - * $langs - * $dateSelector - * $this (invoice, order, ...) - * $line defined - */ -?> - - -
id; ?>" method="POST"> - - - - - - -> - global->MAIN_VIEW_LINE_NUMBER) ? ' colspan="2"' : ''); ?>> -
- - $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(); - ?> - - - load_tva('tva_tx',$line->tva_tx,$seller,$buyer,0,$line->info_bits,$line->product_type); ?> - - - - - info_bits & 2) != 2) { ?> - - -   - - - - - info_bits & 2) != 2) { ?> - % - -   - - - -margin->enabled)) { -?> - - - "> -
"> - - -service->enabled && $dateSelector && $line->product_type == 1) { ?> -> - trans('ServiceLimitedDuration').' '.$langs->trans('From').' '; ?> - 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"); - ?> - - - - - - diff --git a/htdocs/core/tpl/freeproductline_view.tpl.php b/htdocs/core/tpl/freeproductline_view.tpl.php deleted file mode 100644 index e5746c52d58..00000000000 --- a/htdocs/core/tpl/freeproductline_view.tpl.php +++ /dev/null @@ -1,142 +0,0 @@ - - * Copyright (C) 2010-2011 Laurent Destailleur - * Copyright (C) 2012 Christophe Battarel - * - * 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 . - * - */ -?> - - -> - global->MAIN_VIEW_LINE_NUMBER)) { ?> - - -
- info_bits & 2) == 2) { ?> - - trans("ShowReduc"),'reduc').' '; - if ($line->description == '(DEPOSIT)') $txt=$langs->trans("Deposit"); - //else $txt=$langs->trans("Discount"); - print $txt; - ?> - - description) - { - if ($line->description == '(CREDIT_NOTE)') - { - $discount=new DiscountAbsolute($this->db); - $discount->fetch($line->fk_remise_except); - echo ($txt?' - ':'').$langs->transnoentities("DiscountFromCreditNote",$discount->getNomUrl(0)); - } - elseif ($line->description == '(DEPOSIT)') - { - $discount=new DiscountAbsolute($this->db); - $discount->fetch($line->fk_remise_except); - echo ($txt?' - ':'').$langs->transnoentities("DiscountFromDeposit",$discount->getNomUrl(0)); - // Add date of deposit - if (! empty($conf->global->INVOICE_ADD_DEPOSIT_DATE)) echo ' ('.dol_print_date($discount->datec).')'; - } - else - { - echo ($txt?' - ':'').dol_htmlentitiesbr($line->description); - } - } - } - 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'); - echo $text.' '.dol_htmlentitiesbr($line->description); - // Show range - print_date_range($line->date_start,$line->date_end); - } - ?> - - - tva_tx,'%',$line->info_bits); ?> - - subprice); ?> - - - info_bits & 2) != 2) && $line->special_code != 3) echo $line->qty; - else echo ' '; ?> - - - remise_percent) && $line->special_code != 3) { ?> - remise_percent,$langs); ?> - -   - margin->enabled)) { - ?> - pa_ht); ?> - global->DISPLAY_MARGIN_RATES) {?> - pa_ht == 0)?'n/a':price($line->marge_tx).'%'); ?> - global->DISPLAY_MARK_RATES) {?> - marque_tx).'%'; ?> - - - special_code == 3) { ?> - trans('Option'); ?> - - total_ht); ?> - - - statut == 0 && $user->rights->$element->creer) { ?> - - info_bits & 2) == 2) { ?> - - id.'#'.$line->id; ?>"> - - - - - - - id; ?>"> - - - - - 1) { ?> - - 0) { ?> - id; ?>"> - - - - - id; ?>"> - - - - - -   - - -   - - - - diff --git a/htdocs/core/tpl/objectline_edit.tpl.php b/htdocs/core/tpl/objectline_edit.tpl.php index 06b5a17bfc8..1e23aa1c16c 100644 --- a/htdocs/core/tpl/objectline_edit.tpl.php +++ b/htdocs/core/tpl/objectline_edit.tpl.php @@ -39,6 +39,8 @@ global->MAIN_VIEW_LINE_NUMBER) ? ' colspan="2"' : ''); ?>>
+ global->MAIN_FEATURES_LEVEL > 1) { ?> + fk_product > 0) { ?> @@ -52,6 +54,19 @@ + fk_product > 0) { ?> + + + product_type==1) echo img_object($langs->trans('ShowService'),'service'); + else print img_object($langs->trans('ShowProduct'),'product'); + echo ' '.$line->ref; + ?> + + product_label); ?> + + +
load_tva('tva_tx',$line->tva_tx,$seller,$buyer,0,$line->info_bits,$line->product_type); ?> + global->MAIN_FEATURES_LEVEL > 1) { ?> + info_bits & 2) != 2) { ?> @@ -122,6 +139,8 @@ - - diff --git a/htdocs/core/tpl/predefinedproductline_view.tpl.php b/htdocs/core/tpl/predefinedproductline_view.tpl.php deleted file mode 100644 index 5aef6995f74..00000000000 --- a/htdocs/core/tpl/predefinedproductline_view.tpl.php +++ /dev/null @@ -1,111 +0,0 @@ - - * Copyright (C) 2010-2011 Laurent Destailleur - * Copyright (C) 2012 Christophe Battarel - * - * 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 . - * - */ -?> - - -> - global->MAIN_VIEW_LINE_NUMBER)) { ?> - - -
- 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 ($line->description && $line->description!=$line->product_label)?'
'.dol_htmlentitiesbr($line->description):''; - } - ?> - - - tva_tx,'%',$line->info_bits); ?> - - subprice); ?> - - - info_bits & 2) != 2) && $line->special_code != 3) echo $line->qty; - else echo ' '; ?> - - - remise_percent) && $line->special_code != 3) { ?> - remise_percent,$langs); ?> - -   - margin->enabled)) { - ?> - pa_ht); ?> - global->DISPLAY_MARGIN_RATES) {?> - pa_ht == 0)?'n/a':price($line->marge_tx).'%'); ?> - global->DISPLAY_MARK_RATES) {?> - marque_tx).'%'; ?> - - - special_code == 3) { ?> - trans('Option'); ?> - - total_ht); ?> - - - statut == 0 && $user->rights->$element->creer) { ?> - - info_bits & 2) == 2) { ?> - - id.'#'.$line->id; ?>"> - - - - - - - id; ?>"> - - - - - 1) { ?> - - 0) { ?> - id; ?>"> - - - - - id; ?>"> - - - - - -   - - -   - - - - diff --git a/htdocs/product/ajax/products.php b/htdocs/product/ajax/products.php index 5f7c8f7506f..d51468627ff 100644 --- a/htdocs/product/ajax/products.php +++ b/htdocs/product/ajax/products.php @@ -61,44 +61,44 @@ if (! empty($action) && $action == 'fetch' && ! empty($id)) $ret=$object->fetch($id); if ($ret > 0) { - $outref=$object->ref; - $outlabel=$object->label; - $outdesc=$object->description; + $outref=$object->ref; + $outlabel=$object->label; + $outdesc=$object->description; $outtype=$object->type; - $found=false; - - // Multiprice - if ($price_level >= 1) // If we need a particular price level (from 1 to 6) - { - $sql= "SELECT price, price_ttc, price_base_type "; - $sql.= "FROM ".MAIN_DB_PREFIX."product_price "; - $sql.= "WHERE fk_product='".$id."'"; - $sql.= " AND price_level=".$price_level; - $sql.= " ORDER BY date_price"; - $sql.= " DESC LIMIT 1"; - - $result = $this->db->query($sql); - if ($result) - { - $objp = $this->db->fetch_object($result); - if ($objp) + $found=false; + + // Multiprice + if ($price_level >= 1) // If we need a particular price level (from 1 to 6) + { + $sql= "SELECT price, price_ttc, price_base_type "; + $sql.= "FROM ".MAIN_DB_PREFIX."product_price "; + $sql.= "WHERE fk_product='".$id."'"; + $sql.= " AND price_level=".$price_level; + $sql.= " ORDER BY date_price"; + $sql.= " DESC LIMIT 1"; + + $result = $this->db->query($sql); + if ($result) + { + $objp = $this->db->fetch_object($result); + if ($objp) { - $found=true; - $outprice_ht=price($objp->price); - $outprice_ttc=price($objp->price_ttc); - $outpricebasetype=$objp->price_base_type; - } - } + $found=true; + $outprice_ht=price($objp->price); + $outprice_ttc=price($objp->price_ttc); + $outpricebasetype=$objp->price_base_type; + } + } } if (! $found) - { - $outprice_ht=price($object->price); - $outprice_ttc=price($object->price_ttc); + { + $outprice_ht=price($object->price); + $outprice_ttc=price($object->price_ttc); $outpricebasetype=$object->price_base_type; - } - + } + $outjson = array('ref'=>$outref, 'label'=>$outlabel, 'desc'=>$outdesc, 'type'=>$outtype, 'price_ht'=>$outprice_ht, 'price_ttc'=>$outprice_ttc, 'pricebasetype'=>$outpricebasetype); } @@ -107,36 +107,36 @@ if (! empty($action) && $action == 'fetch' && ! empty($id)) } else { - require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'; - - $langs->load("products"); + require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'; + + $langs->load("products"); $langs->load("main"); top_httphead(); - if (empty($htmlname)) return; - - $match = preg_grep('/('.$htmlname.'[0-9]+)/',array_keys($_GET)); - sort($match); - $idprod = (! empty($match[0]) ? $match[0] : ''); - - if (! GETPOST($htmlname) && ! GETPOST($idprod)) return; - - // When used from jQuery, the search term is added as GET param "term". - $searchkey=(GETPOST($idprod)?GETPOST($idprod):(GETPOST($htmlname)?GETPOST($htmlname):'')); - - $form = new Form($db); - if (empty($mode) || $mode == 1) - { - $arrayresult=$form->select_produits_do("",$htmlname,$type,"",$pricelevel,$searchkey,$status,2,$outjson); - } - elseif ($mode == 2) - { - $arrayresult=$form->select_produits_fournisseurs_do($socid,"",$htmlname,$type,"",$searchkey,$status,$outjson); - } - - $db->close(); - + if (empty($htmlname)) return; + + $match = preg_grep('/('.$htmlname.'[0-9]+)/',array_keys($_GET)); + sort($match); + $idprod = (! empty($match[0]) ? $match[0] : ''); + + if (! GETPOST($htmlname) && ! GETPOST($idprod)) return; + + // When used from jQuery, the search term is added as GET param "term". + $searchkey=(GETPOST($idprod)?GETPOST($idprod):(GETPOST($htmlname)?GETPOST($htmlname):'')); + + $form = new Form($db); + if (empty($mode) || $mode == 1) + { + $arrayresult=$form->select_produits_do("",$htmlname,$type,"",$pricelevel,$searchkey,$status,2,$outjson); + } + elseif ($mode == 2) + { + $arrayresult=$form->select_produits_fournisseurs_do($socid,"",$htmlname,$type,"",$searchkey,$status,$outjson); + } + + $db->close(); + if ($outjson) print json_encode($arrayresult); }