diff --git a/htdocs/comm/propal.php b/htdocs/comm/propal.php index 343a559b7a9..c49e6fb36cd 100644 --- a/htdocs/comm/propal.php +++ b/htdocs/comm/propal.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004-2013 Laurent Destailleur + * Copyright (C) 2004-2014 Laurent Destailleur * Copyright (C) 2004 Eric Seigne * Copyright (C) 2005 Marc Barilley / Ocebo * Copyright (C) 2005-2012 Regis Houssin @@ -539,34 +539,24 @@ else if ($action == "setabsolutediscount" && $user->rights->propal->creer) { } // Add line -else if (($action == 'addline' || $action == 'addline_predef') && $user->rights->propal->creer) { +else if ($action == 'addline' && $user->rights->propal->creer) { + // Set if we used free entry or predefined product - if (GETPOST('addline_libre') - || (GETPOST('dp_desc') && ! GETPOST('addline_libre') && ! GETPOST('idprod', 'int')>0) // we push enter onto qty field - ) + $predef=''; + $product_desc=(GETPOST('dp_desc')?GETPOST('dp_desc'):''); + if (GETPOST('prod_entry_mode') == 'free') { - $predef=''; $idprod=0; - $product_desc=(GETPOST('dp_desc')?GETPOST('dp_desc'):''); $price_ht = GETPOST('price_ht'); $tva_tx = (GETPOST('tva_tx') ? GETPOST('tva_tx') : 0); } - if (GETPOST('addline_predefined') - || (! GETPOST('dp_desc') && ! GETPOST('addline_predefined') && GETPOST('idprod', 'int')>0) // we push enter onto qty field - ) + else { - $predef=(($conf->global->MAIN_FEATURES_LEVEL < 2) ? '_predef' : ''); $idprod=GETPOST('idprod', 'int'); - $product_desc = (GETPOST('product_desc')?GETPOST('product_desc'):(GETPOST('np_desc')?GETPOST('np_desc'):'')); $price_ht = ''; $tva_tx = ''; } - if (GETPOST('usenewaddlineform')) { - $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'); - $tva_tx = (GETPOST('tva_tx') ? GETPOST('tva_tx') : 0); - } + $qty = GETPOST('qty' . $predef); $remise_percent = GETPOST('remise_percent' . $predef); @@ -587,7 +577,7 @@ else if (($action == 'addline' || $action == 'addline_predef') && $user->rights- $error ++; } - if ((empty($idprod) || GETPOST('usenewaddlineform')) && $price_ht == '') // Unit price can be 0 but not ''. Also price can be negative for + if (empty($idprod) && $price_ht == '') // Unit price can be 0 but not ''. Also price can be negative for // proposal. { setEventMessage($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("UnitPriceHT")), 'errors'); @@ -616,13 +606,6 @@ else if (($action == 'addline' || $action == 'addline_predef') && $user->rights- $label = ((GETPOST('product_label') && GETPOST('product_label') != $prod->label) ? GETPOST('product_label') : ''); // If prices fields are update - if (GETPOST('usenewaddlineform')) { - $pu_ht = price2num($price_ht, 'MU'); - $pu_ttc = price2num(GETPOST('price_ttc'), 'MU'); - $tva_npr = (preg_match('/\*/', $tva_tx) ? 1 : 0); - $tva_tx = str_replace('*', '', $tva_tx); - $desc = $product_desc; - } else { $tva_tx = get_default_tva($mysoc, $object->client, $prod->id); $tva_npr = get_default_npr($mysoc, $object->client, $prod->id); @@ -706,7 +689,6 @@ else if (($action == 'addline' || $action == 'addline_predef') && $user->rights- $tmptxt .= ')'; $desc = dol_concatdesc($desc, $tmptxt); } - } $type = $prod->type; } else { @@ -756,6 +738,8 @@ else if (($action == 'addline' || $action == 'addline_predef') && $user->rights- propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); } + unset($_POST ['prod_entry_mode']); + unset($_POST ['qty']); unset($_POST ['type']); unset($_POST ['remise_percent']); @@ -1798,32 +1782,18 @@ if ($action == 'create') { if (! empty($object->lines)) $ret = $object->printObjectLines($action, $mysoc, $soc, $lineid, 1); - // Form to add new line - if ($object->statut == 0 && $user->rights->propal->creer) { - if ($action != 'editline') { + // Form to add new line + if ($object->statut == 0 && $user->rights->propal->creer) + { + if ($action != 'editline') + { $var = true; - if ($conf->global->MAIN_FEATURES_LEVEL > 1) - { - // Add free or predefined products/services - $object->formAddObjectLine(1, $mysoc, $soc); - } - else - { - // Add free products/services - $object->formAddFreeProduct(1, $mysoc, $soc); - - // Add predefined products/services - if (! empty($conf->product->enabled) || ! empty($conf->service->enabled)) { - $var = ! $var; - $object->formAddPredefinedProduct(1, $mysoc, $soc); - } - } + // Add free products/services + $object->formAddObjectLine(1, $mysoc, $soc); $parameters = array(); - $reshook = $hookmanager->executeHooks('formAddObjectLine', $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 } } @@ -1833,9 +1803,10 @@ if ($action == 'create') { dol_fiche_end(); - if ($action == 'statut') { + if ($action == 'statut') + { /* - * Formulaire cloture (signe ou non) + * Form to close proposal (signed or not) */ $form_close = '
'; $form_close .= ''; @@ -1956,7 +1927,8 @@ if ($action == 'create') { } print "
\n"; - if ($action != 'presend') { + if ($action != 'presend') + { print '
'; // print '
'; // print ''; // ancre @@ -1993,9 +1965,9 @@ if ($action == 'create') { /* * Action presend - * - */ - if ($action == 'presend') { + */ + if ($action == 'presend') + { $ref = dol_sanitizeFileName($object->ref); include_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; $fileparams = dol_most_recent_file($conf->propal->dir_output . '/' . $ref, preg_quote($ref, '/')); diff --git a/htdocs/commande/fiche.php b/htdocs/commande/fiche.php index 52e8053a1e6..f9aa58ddd1c 100644 --- a/htdocs/commande/fiche.php +++ b/htdocs/commande/fiche.php @@ -479,32 +479,21 @@ else if ($action == 'addline' && $user->rights->commande->creer) { $error = false; // Set if we used free entry or predefined product - if (GETPOST('addline_libre') - || (GETPOST('dp_desc') && ! GETPOST('addline_libre') && ! GETPOST('idprod', 'int')>0) // we push enter onto qty field - ) + $predef=''; + $product_desc=(GETPOST('dp_desc')?GETPOST('dp_desc'):''); + if (GETPOST('prod_entry_mode') == 'free') { - $predef=''; $idprod=0; - $product_desc=(GETPOST('dp_desc')?GETPOST('dp_desc'):''); $price_ht = GETPOST('price_ht'); $tva_tx = (GETPOST('tva_tx') ? GETPOST('tva_tx') : 0); } - if (GETPOST('addline_predefined') - || (! GETPOST('dp_desc') && ! GETPOST('addline_predefined') && GETPOST('idprod', 'int')>0) // we push enter onto qty field - ) + else { - $predef=(($conf->global->MAIN_FEATURES_LEVEL < 2) ? '_predef' : ''); $idprod=GETPOST('idprod', 'int'); - $product_desc = (GETPOST('product_desc')?GETPOST('product_desc'):(GETPOST('np_desc')?GETPOST('np_desc'):'')); $price_ht = ''; $tva_tx = ''; } - if (GETPOST('usenewaddlineform')) { - $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'); - $tva_tx = (GETPOST('tva_tx') ? GETPOST('tva_tx') : 0); - } + $qty = GETPOST('qty' . $predef); $remise_percent = GETPOST('remise_percent' . $predef); @@ -520,7 +509,7 @@ else if ($action == 'addline' && $user->rights->commande->creer) { } } - if ((empty($idprod) || GETPOST('usenewaddlineform')) && ($price_ht < 0) && ($qty < 0)) { + if (empty($idprod) && ($price_ht < 0) && ($qty < 0)) { setEventMessage($langs->trans('ErrorBothFieldCantBeNegative', $langs->transnoentitiesnoconv('UnitPriceHT'), $langs->transnoentitiesnoconv('Qty')), 'errors'); $error ++; } @@ -528,7 +517,7 @@ else if ($action == 'addline' && $user->rights->commande->creer) { setEventMessage($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Type')), 'errors'); $error ++; } - if ((empty($idprod) || GETPOST('usenewaddlineform')) && (! ($price_ht >= 0) || $price_ht == '')) // Unit price can be 0 but not '' + if (empty($idprod) && (! ($price_ht >= 0) || $price_ht == '')) // Unit price can be 0 but not '' { setEventMessage($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("UnitPriceHT")), 'errors'); $error ++; @@ -559,13 +548,6 @@ else if ($action == 'addline' && $user->rights->commande->creer) { $label = ((GETPOST('product_label') && GETPOST('product_label') != $prod->label) ? GETPOST('product_label') : ''); // Update if prices fields are defined - if (GETPOST('usenewaddlineform')) { - $pu_ht = price2num($price_ht, 'MU'); - $pu_ttc = price2num(GETPOST('price_ttc'), 'MU'); - $tva_npr = (preg_match('/\*/', $tva_tx) ? 1 : 0); - $tva_tx = str_replace('*', '', $tva_tx); - $desc = $product_desc; - } else { $tva_tx = get_default_tva($mysoc, $object->client, $prod->id); $tva_npr = get_default_npr($mysoc, $object->client, $prod->id); @@ -649,7 +631,6 @@ else if ($action == 'addline' && $user->rights->commande->creer) { $tmptxt .= ')'; $desc = dol_concatdesc($desc, $tmptxt); } - } $type = $prod->type; } else { @@ -700,6 +681,8 @@ else if ($action == 'addline' && $user->rights->commande->creer) { commande_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); } + unset($_POST ['prod_entry_mode']); + unset($_POST ['qty']); unset($_POST ['type']); unset($_POST ['remise_percent']); @@ -2098,30 +2081,17 @@ if ($action == 'create' && $user->rights->commande->creer) { /* * Form to add new line */ - if ($object->statut == 0 && $user->rights->commande->creer) { - if ($action != 'editline') { + if ($object->statut == 0 && $user->rights->commande->creer) + { + if ($action != 'editline') + { $var = true; - if ($conf->global->MAIN_FEATURES_LEVEL > 1) - { - // Add free or predefined products/services - $object->formAddObjectLine(1, $mysoc, $soc); - } - else - { - // Add free products/services - $object->formAddFreeProduct(1, $mysoc, $soc); - - // Add predefined products/services - if (! empty($conf->product->enabled) || ! empty($conf->service->enabled)) { - $var = ! $var; - $object->formAddPredefinedProduct(1, $mysoc, $soc); - } - } + // Add free products/services + $object->formAddObjectLine(1, $mysoc, $soc); $parameters = array(); - $reshook = $hookmanager->executeHooks('formAddObjectLine', $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 '
'; diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index ef276d6a96a..2c70be7c4c9 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -1037,39 +1037,27 @@ else if ($action == 'add' && $user->rights->facture->creer) } // Add a new line -else if (($action == 'addline' || $action == 'addline_predef') && $user->rights->facture->creer) +else if ($action == 'addline' && $user->rights->facture->creer) { $langs->load('errors'); $error = 0; // Set if we used free entry or predefined product - if (GETPOST('addline_libre') - || (GETPOST('dp_desc') && ! GETPOST('addline_libre') && ! GETPOST('idprod', 'int')>0) // we push enter onto qty field - ) + $predef=''; + $product_desc=(GETPOST('dp_desc')?GETPOST('dp_desc'):''); + if (GETPOST('prod_entry_mode') == 'free') { - $predef = ''; - $idprod = 0; - $product_desc = (GETPOST('dp_desc') ? GETPOST('dp_desc') : ''); + $idprod=0; $price_ht = GETPOST('price_ht'); $tva_tx = (GETPOST('tva_tx') ? GETPOST('tva_tx') : 0); } - if (GETPOST('addline_predefined') - || (! GETPOST('dp_desc') && ! GETPOST('addline_predefined') && GETPOST('idprod', 'int')>0) // we push enter onto qty field - ) + else { - $predef = (($conf->global->MAIN_FEATURES_LEVEL < 2) ? '_predef' : ''); - $idprod = GETPOST('idprod', 'int'); - $product_desc = (GETPOST('product_desc') ? GETPOST('product_desc') : (GETPOST('np_desc') ? GETPOST('np_desc') : '')); + $idprod=GETPOST('idprod', 'int'); $price_ht = ''; $tva_tx = ''; } - if (GETPOST('usenewaddlineform')) // TODO Remove this - { - $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'); - $tva_tx = (GETPOST('tva_tx') ? GETPOST('tva_tx') : 0); - } + $qty = GETPOST('qty' . $predef); $remise_percent = GETPOST('remise_percent' . $predef); @@ -1085,7 +1073,7 @@ else if (($action == 'addline' || $action == 'addline_predef') && $user->rights- } } - if ((empty($idprod) || GETPOST('usenewaddlineform')) && ($price_ht < 0) && ($qty < 0)) { + if (empty($idprod) && ($price_ht < 0) && ($qty < 0)) { setEventMessage($langs->trans('ErrorBothFieldCantBeNegative', $langs->transnoentitiesnoconv('UnitPriceHT'), $langs->transnoentitiesnoconv('Qty')), 'errors'); $error ++; } @@ -1093,7 +1081,7 @@ else if (($action == 'addline' || $action == 'addline_predef') && $user->rights- setEventMessage($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Type')), 'errors'); $error ++; } - if ((empty($idprod) || GETPOST('usenewaddlineform')) && (! ($price_ht >= 0) || $price_ht == '')) // Unit price can be 0 but not '' + if (empty($idprod) && (! ($price_ht >= 0) || $price_ht == '')) // Unit price can be 0 but not '' { setEventMessage($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("UnitPriceHT")), 'errors'); $error ++; @@ -1135,13 +1123,6 @@ else if (($action == 'addline' || $action == 'addline_predef') && $user->rights- $label = ((GETPOST('product_label') && GETPOST('product_label') != $prod->label) ? GETPOST('product_label') : ''); // Update if prices fields are defined - if (GETPOST('usenewaddlineform')) { - $pu_ht = price2num($price_ht, 'MU'); - $pu_ttc = price2num(GETPOST('price_ttc'), 'MU'); - $tva_npr = (preg_match('/\*/', $tva_tx) ? 1 : 0); - $tva_tx = str_replace('*', '', $tva_tx); - $desc = $product_desc; - } else { $tva_tx = get_default_tva($mysoc, $object->client, $prod->id); $tva_npr = get_default_npr($mysoc, $object->client, $prod->id); @@ -1225,7 +1206,6 @@ else if (($action == 'addline' || $action == 'addline_predef') && $user->rights- $tmptxt .= ')'; $desc = dol_concatdesc($desc, $tmptxt); } - } $type = $prod->type; } else { @@ -1273,6 +1253,8 @@ else if (($action == 'addline' || $action == 'addline_predef') && $user->rights- facture_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); } + unset($_POST ['prod_entry_mode']); + unset($_POST['qty']); unset($_POST['type']); unset($_POST['remise_percent']); @@ -3303,30 +3285,19 @@ if ($action == 'create') if (! empty($object->lines)) $ret = $object->printObjectLines($action, $mysoc, $soc, $lineid, 1); - // Form to add new line - if ($object->statut == 0 && $user->rights->facture->creer && $action != 'valid' && $action != 'editline') { - $var = true; + // Form to add new line + if ($object->statut == 0 && $user->rights->facture->creer && $action != 'valid' && $action != 'editline') + { + if ($action != 'editline') + { + $var = true; - if ($conf->global->MAIN_FEATURES_LEVEL > 1) - { - // Add free or predefined products/services - $object->formAddObjectLine(1, $mysoc, $soc); - } - else - { // Add free products/services - $object->formAddFreeProduct(1, $mysoc, $soc); + $object->formAddObjectLine(1, $mysoc, $soc); - // Add predefined products/services - if (! empty($conf->product->enabled) || ! empty($conf->service->enabled)) { - $var = ! $var; - $object->formAddPredefinedProduct(1, $mysoc, $soc); - } + $parameters = array(); + $reshook = $hookmanager->executeHooks('formAddObjectLine', $parameters, $object, $action); // Note that $action and $object may have been modified by hook } - - $parameters = array(); - $reshook = $hookmanager->executeHooks('formAddObjectLine', $parameters, $object, $action); // Note that $action and $object may have been modified by - // hook } print "\n"; diff --git a/htdocs/contrat/fiche.php b/htdocs/contrat/fiche.php index 5b67add45f6..361940f27e3 100644 --- a/htdocs/contrat/fiche.php +++ b/htdocs/contrat/fiche.php @@ -355,28 +355,21 @@ else if ($action == 'classin' && $user->rights->contrat->creer) else if ($action == 'addline' && $user->rights->contrat->creer) { // Set if we used free entry or predefined product - if (GETPOST('addline_libre')) + $predef=''; + $product_desc=(GETPOST('dp_desc')?GETPOST('dp_desc'):''); + if (GETPOST('prod_entry_mode') == 'free') { - $predef=''; $idprod=0; - $product_desc=(GETPOST('dp_desc')?GETPOST('dp_desc'):''); $price_ht = GETPOST('price_ht'); - $tva_tx=(GETPOST('tva_tx')?GETPOST('tva_tx'):0); + $tva_tx = (GETPOST('tva_tx') ? GETPOST('tva_tx') : 0); } - if (GETPOST('addline_predefined')) + else { - $predef=(($conf->global->MAIN_FEATURES_LEVEL < 2) ? '_predef' : ''); $idprod=GETPOST('idprod', 'int'); - $product_desc = (GETPOST('product_desc')?GETPOST('product_desc'):(GETPOST('np_desc')?GETPOST('np_desc'):'')); $price_ht = ''; $tva_tx = ''; } - if (GETPOST('usenewaddlineform')) { - $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'); - $tva_tx=(GETPOST('tva_tx')?GETPOST('tva_tx'):0); - } + $qty = GETPOST('qty'.$predef); $remise_percent=GETPOST('remise_percent'.$predef); @@ -520,6 +513,8 @@ else if ($action == 'addline' && $user->rights->contrat->creer) } */ + unset($_POST ['prod_entry_mode']); + unset($_POST['qty']); unset($_POST['type']); unset($_POST['remise_percent']); @@ -1161,7 +1156,12 @@ else $productstatic->type=$objp->ptype; $productstatic->ref=$objp->pref; print $productstatic->getNomUrl(1,'',20); - print $objp->label?' - '.dol_trunc($objp->label,16):''; + if ($objp->label) + { + print ' - '; + $productstatic->ref=$objp->label; + print $productstatic->getNomUrl(0,'',16); + } if ($objp->description) print '
'.dol_nl2br($objp->description); print ''; } @@ -1561,34 +1561,19 @@ else // Trick to not show product entries $savproductenabled=$conf->product->enabled; - $conf->product->enabled = 0; + if (empty($conf->global->CONTRACT_SUPPORT_PRODUCTS)) $conf->product->enabled = 0; // Form to add new line - if ($action != 'editline') - { - $var=true; + if ($action != 'editline') + { + $var = true; - if ($conf->global->MAIN_FEATURES_LEVEL > 1) - { - // Add free or predefined products/services - $object->formAddObjectLine($dateSelector,$mysoc,$object->thirdparty); - } - else - { - // Add free products/services - $object->formAddFreeProduct($dateSelector,$mysoc,$object->thirdparty); + // Add free products/services + $object->formAddObjectLine(1, $mysoc, $soc); - // Add predefined products/services - if (! empty($conf->product->enabled) || ! empty($conf->service->enabled)) - { - $var=!$var; - $object->formAddPredefinedProduct($dateSelector,$mysoc,$object->thirdparty); - } - } - - $parameters=array(); - $reshook=$hookmanager->executeHooks('formAddObjectLine',$parameters,$object,$action); // Note that $action and $object may have been modified by hook - } + $parameters = array(); + $reshook = $hookmanager->executeHooks('formAddObjectLine', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + } // Restore correct setup $conf->product->enabled = $savproductenabled; diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 7fbcc9d8b74..c2fb6d6d08d 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -2668,61 +2668,8 @@ 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 - * @return void - * @deprecated - */ - function formAddPredefinedProduct($dateSelector,$seller,$buyer) - { - global $conf,$langs,$object,$hookmanager; - global $form,$bcnd,$var; - global $user; - //Line extrafield - require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; - $extrafieldsline = new ExtraFields($this->db); - $extralabelslines=$extrafieldsline->fetch_name_optionals_label($this->table_element_line); - - // 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's possible as we keep a method available on overloaded objects. - * - * @param int $dateSelector 1=Show also date range input fields (start and end date) - * @param Societe $seller Object thirdparty who sell - * @param Societe $buyer Object thirdparty who buy - * @return void - */ - function formAddFreeProduct($dateSelector,$seller,$buyer) - { - global $conf,$langs,$object,$hookmanager; - global $form,$bcnd,$var; - global $user; - - //Line extrafield - require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; - $extrafieldsline = new ExtraFields($this->db); - $extralabelslines=$extrafieldsline->fetch_name_optionals_label($this->table_element_line); - - // Use global variables + $dateSelector + $seller and $buyer - include(DOL_DOCUMENT_ROOT.'/core/tpl/freeproductline_create.tpl.php'); - } - - /** * 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 @@ -2744,7 +2691,7 @@ abstract class CommonObject $dirtpls=array_merge($conf->modules_parts['tpl'],array('/core/tpl')); foreach($dirtpls as $reldir) { - $tpl = dol_buildpath($reldir.'/objectline_add.tpl.php'); + $tpl = dol_buildpath($reldir.'/objectline_create.tpl.php'); if (empty($conf->file->strict_mode)) { $res=@include $tpl; } else { diff --git a/htdocs/core/tpl/objectline_add.tpl.php b/htdocs/core/tpl/objectline_add.tpl.php deleted file mode 100644 index e26b684d405..00000000000 --- a/htdocs/core/tpl/objectline_add.tpl.php +++ /dev/null @@ -1,694 +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 3 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 - */ -?> - - - - global->MAIN_VIEW_LINE_NUMBER) ? ' colspan="2"' : ''); ?>>
trans('AddNewLine'); ?> - trans('VAT'); ?> - trans('PriceUHT'); ?> - trans('PriceUTTC'); ?> - trans('Qty'); ?> - trans('ReductionShort'); ?> -margin->enabled)) { -?> - trans('BuyingPrice'); ?> -rights->margins->creer) - { - if(! empty($conf->global->DISPLAY_MARGIN_RATES)) - { - echo ''.$langs->trans('MarginRate').''; - } - if(! empty($conf->global->DISPLAY_MARK_RATES)) - { - echo ''.$langs->trans('MarkRate').''; - } - } - else - { - if (! empty($conf->global->DISPLAY_MARGIN_RATES)) { - $colspan++; - $colspan2++; - } - if (! empty($conf->global->DISPLAY_MARK_RATES)) { - $colspan++; - $colspan2++; - } - } - if (! empty($conf->global->MAIN_VIEW_LINE_NUMBER)) { - $colspan2++; - } -} -?> -   - - -" /> - - - - -product->enabled) || ! empty($conf->service->enabled)) { ?> - - - product->enabled) || ! empty($conf->service->enabled)) - { - // show/hide, update elements after select - $ajaxoptions=array( - 'update' => array( - 'select_type' => 'type', - 'product_ref' => 'value', - 'product_label' => 'label2', - 'price_base_type' => 'pricebasetype', - 'price_ht' => 'price_ht', - 'origin_price_ht_cache' => 'price_ht', - 'origin_tva_tx_cache' => 'tva_tx', - 'origin_price_ttc_cache' => 'price_ttc', - 'qty' => 'qty', - 'remise_percent' => 'discount' - ), - 'update_textarea' => array( - 'product_desc' => 'desc' - ), - //'show' => array( - //'price_base_type_area' - //), - 'disabled' => array( - 'select_type' - ) - ); - $form->select_produits('', 'idprod', '', $conf->product->limit_size, $buyer->price_level, 1, 2, '', 3, $ajaxoptions,$buyer->id); - } - ?> - | - - textwithtooltip($langs->trans('AddThisProductCard'), $langs->trans('HelpAddThisProductCard'),1,0,'','',3); ?> - - - textwithtooltip($langs->trans('AddThisServiceCard'), $langs->trans('HelpAddThisServiceCard'),1,0,'','',3); ?> - - - - - - -> - - select_type_of_lines((GETPOST('type')?GETPOST('type'):-1), 'type', 1); ?> - - -   - - - -   - - - - | trans('PriceBase'); ?>: - - -GETPOST('fk_parent_line')); - $reshook=$hookmanager->executeHooks('formCreateProductOptions',$parameters,$object,$action); - } -?> - - -> - global->MAIN_VIEW_LINE_NUMBER) ? ' colspan="2"' : ''); ?>> - -global->MAIN_INPUT_DESC_HEIGHT)) $nbrows=$conf->global->MAIN_INPUT_DESC_HEIGHT; - $enable=(isset($conf->global->FCKEDITOR_ENABLE_DETAILS)?$conf->global->FCKEDITOR_ENABLE_DETAILS:0); - $doleditor=new DolEditor('product_desc', GETPOST('product_desc'), '', 150, 'dolibarr_details', '', false, true, $enable, $nbrows, 70); - $doleditor->Create(); - ?> - - - - load_tva('tva_tx', (GETPOST('tva_tx')?GETPOST('tva_tx'):-1), $seller, $buyer); ?> - - - - - - - - - - - - - % - - - margin->enabled)) { - ?> - - - - - rights->margins->creer) - { - if (! empty($conf->global->DISPLAY_MARGIN_RATES)) { - echo '%'; - } - elseif (! empty($conf->global->DISPLAY_MARK_RATES)) { - echo '%'; - } - } - else - { - if (! empty($conf->global->DISPLAY_MARGIN_RATES)) { - $colspan++; - } - if (! empty($conf->global->DISPLAY_MARK_RATES)) { - $colspan++; - } - } - } - ?> - -table_element_line=='commandedet') { - $newline = new OrderLine($this->db); - } - elseif ($this->table_element_line=='propaldet') { - $newline = new PropaleLigne($this->db); - } - elseif ($this->table_element_line=='facturedet') { - $newline = new FactureLigne($this->db); - } - if (is_object($newline)) { - print $newline->showOptionals($extrafieldsline,'edit',array('style'=>$bcnd[$var],'colspan'=>$coldisplay+8)); - } -} -?> - - - -service->enabled) && ! empty($dateSelector)) { -if (! empty($conf->global->MAIN_VIEW_LINE_NUMBER)) - $colspan = 12; -else - $colspan = 11; - -?> -> - - global->MAIN_USE_HOURMIN_IN_DATE_RANGE)?$conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE:''); - echo $langs->trans('ServiceLimitedDuration').' '.$langs->trans('From').' '; - echo $form->select_date('','date_start',$hourmin,$hourmin,1,"addproduct"); - echo ' '.$langs->trans('to').' '; - echo $form->select_date('','date_end',$hourmin,$hourmin,1,"addproduct"); - ?> - - - - - - - - diff --git a/htdocs/core/tpl/objectline_create.tpl.php b/htdocs/core/tpl/objectline_create.tpl.php new file mode 100644 index 00000000000..50a4d698149 --- /dev/null +++ b/htdocs/core/tpl/objectline_create.tpl.php @@ -0,0 +1,455 @@ + + * Copyright (C) 2010-2013 Laurent Destailleur + * Copyright (C) 2012-2013 Christophe Battarel + * Copyright (C) 2013 Florian Henry + * + * 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 3 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 + */ + +$usemargins=0; +if (! empty($conf->margin->enabled) && ! empty($object->element) && in_array($object->element,array('facture','propal','commande'))) $usemargins=1; + +?> + + + + + global->MAIN_VIEW_LINE_NUMBER) ? ' colspan="2"' : ''); ?>> +
trans('AddNewLine'); ?>trans("FreeZone"); ?> + + trans('VAT'); ?> + trans('PriceUHT'); ?> + trans('Qty'); ?> + trans('ReductionShort'); ?> + + + global->MARGIN_TYPE == "1") + echo $langs->trans('BuyingPrice'); + else + echo $langs->trans('CostPrice'); + ?> + + rights->margins->creer) + { + if(! empty($conf->global->DISPLAY_MARGIN_RATES)) + { + echo ''.$langs->trans('MarginRate').''; + } + if(! empty($conf->global->DISPLAY_MARK_RATES)) + { + echo ''.$langs->trans('MarkRate').''; + } + } + else + { + if (! empty($conf->global->DISPLAY_MARGIN_RATES)) $colspan++; + if (! empty($conf->global->DISPLAY_MARK_RATES)) $colspan++; + } + } + ?> +   + + +> +global->MAIN_VIEW_LINE_NUMBER)) { + $coldisplay=2; } +else { + $coldisplay=0; } +?> + + global->MAIN_VIEW_LINE_NUMBER) ? ' colspan="2"' : ''); ?>> + + + + '; + if (! empty($conf->product->enabled) || ! empty($conf->service->enabled)) + { + echo ' '; + } + if (! empty($conf->product->enabled) && ! empty($conf->service->enabled)) echo $langs->trans("FreeLineOfType").' '; + else if (empty($conf->product->enabled) && ! empty($conf->service->enabled)) echo $langs->trans("FreeLineOfType").' '.$langs->trans("Service"); + else if (! empty($conf->product->enabled) && empty($conf->service->enabled)) echo $langs->trans("FreeLineOfType").' '.$langs->trans("Product"); + echo $form->select_type_of_lines(isset($_POST["type"])?$_POST["type"]:-1,'type',1,1); + echo ''; + + if (! empty($conf->product->enabled) || ! empty($conf->service->enabled)) + { + echo '
'; + echo ' '; + + if (! empty($conf->product->enabled) && empty($conf->service->enabled)) echo $langs->trans('RecordedProducts'); + else if (empty($conf->product->enabled) && ! empty($conf->service->enabled)) echo $langs->trans('RecordedServices'); + else echo $langs->trans('RecordedProductsAndServices'); + echo ' '; + + $filtertype=''; + if (! empty($object->element) && $object->element == 'contrat' && empty($conf->global->CONTRACT_SUPPORT_PRODUCTS)) $filtertype='1'; + $form->select_produits('','idprod',$filtertype,$conf->product->limit_size,$buyer->price_level, 1, 2, '', 3, array(),$buyer->id); + echo ''; + } + + if (is_object($hookmanager)) + { + $parameters=array('fk_parent_line'=>GETPOST('fk_parent_line','int')); + $reshook=$hookmanager->executeHooks('formCreateProductOptions',$parameters,$object,$action); + } + + //if ((! empty($conf->product->enabled) && ! empty($conf->service->enabled)) || (empty($conf->product->enabled) && empty($conf->service->enabled))) echo '
'; + echo '
'; + + // Editor wysiwyg + require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; + $nbrows=ROWS_2; + $enabled=(! empty($conf->global->FCKEDITOR_ENABLE_DETAILS)?$conf->global->FCKEDITOR_ENABLE_DETAILS:0); + if (! empty($conf->global->MAIN_INPUT_DESC_HEIGHT)) $nbrows=$conf->global->MAIN_INPUT_DESC_HEIGHT; + $doleditor=new DolEditor('dp_desc',GETPOST('dp_desc'),'',100,'dolibarr_details','',false,true,$enabled,$nbrows,'98%'); + $doleditor->Create(); + ?> + + + tva_assuj == "0") echo '0'; + else echo $form->load_tva('tva_tx', (isset($_POST["tva_tx"])?$_POST["tva_tx"]:-1), $seller, $buyer); + ?> + + + "> + + + "> + + remise_client); ?>" name="remise_percent">% + + + + product->enabled) || ! empty($conf->service->enabled)) { ?> + + + + "> + + rights->margins->creer) + { + if (! empty($conf->global->DISPLAY_MARGIN_RATES)) { + echo '%'; + $colspan++; + $coldisplay++; + } + if (! empty($conf->global->DISPLAY_MARK_RATES)) { + echo '%'; + $colspan++; + $coldisplay++; + } + } + else + { + if (! empty($conf->global->DISPLAY_MARGIN_RATES)) { + $colspan++; + $coldisplay++; + } + if (! empty($conf->global->DISPLAY_MARK_RATES)) { + $colspan++; + $coldisplay++; + } + } + } + ?> + + + + table_element_line=='commandedet') { + $newline = new OrderLine($this->db); + } + elseif ($this->table_element_line=='propaldet') { + $newline = new PropaleLigne($this->db); + } + elseif ($this->table_element_line=='facturedet') { + $newline = new FactureLigne($this->db); + } + if (is_object($newline)) { + print $newline->showOptionals($extrafieldsline, 'edit', array('style'=>$bcnd[$var], 'colspan'=>$coldisplay+8)); + } + } + ?> + + +service->enabled) && $dateSelector) +{ + if(! empty($conf->global->MAIN_VIEW_LINE_NUMBER)) $colspan = 10; + else $colspan = 9; + + if (! empty($usemargins)) + { + $colspan++; // For the buying price + if (! empty($conf->global->DISPLAY_MARGIN_RATES)) $colspan++; + if (! empty($conf->global->DISPLAY_MARK_RATES)) $colspan++; + } +?> + +> + + element) && $object->element == 'contrat') + { + print $langs->trans("DateStartPlanned").' '; + $form->select_date('',"date_start",$usehm,$usehm,1,"addproduct"); + print '   '.$langs->trans("DateEndPlanned").' '; + $form->select_date('',"date_end",$usehm,$usehm,1,"addproduct"); + } + else + { + echo $langs->trans('ServiceLimitedDuration').' '.$langs->trans('From').' '; + echo $form->select_date('','date_start',empty($conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE)?0:1,empty($conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE)?0:1,1,"addproduct"); + echo ' '.$langs->trans('to').' '; + echo $form->select_date('','date_end',empty($conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE)?0:1,empty($conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE)?0:1,1,"addproduct"); + } + ?> + + + + + + diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index fe6f582135a..b5ef6639fcc 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -605,7 +605,8 @@ Notes=Notes AddNewLine=Add new line AddFile=Add file ListOfFiles=List of available files -FreeZone=Free text +FreeZone=Free entry +FreeLineOfType=Free entry of type CloneMainAttributes=Clone object with its main attributes PDFMerge=PDF Merge Merge=Merge