This commit is contained in:
Nicolas 2019-11-30 12:49:31 +01:00
parent cfffcab950
commit fd7a18c26f

View File

@ -8,6 +8,7 @@
* Copyright (C) 2015-2016 Marcos García <marcosgdf@gmail.com> * Copyright (C) 2015-2016 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2018 Frédéric France <frederic.france@netlogic.fr> * Copyright (C) 2018 Frédéric France <frederic.france@netlogic.fr>
* Copyright (C) 2018 Ferran Marcet <fmarcet@2byte.es> * Copyright (C) 2018 Ferran Marcet <fmarcet@2byte.es>
* Copyright (C) 2019 Nicolas ZABOURI <info@inovea-conseil.com>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -31,35 +32,28 @@
* $senderissupplier (0 by default, 1 or 2 for supplier invoices/orders) * $senderissupplier (0 by default, 1 or 2 for supplier invoices/orders)
* $inputalsopricewithtax (0 by default, 1 to also show column with unit price including tax) * $inputalsopricewithtax (0 by default, 1 to also show column with unit price including tax)
*/ */
// Protection to avoid direct call of template // Protection to avoid direct call of template
if (empty($object) || !is_object($object)) { if (empty($object) || !is_object($object)) {
print "Error: this template page cannot be called directly as an URL"; print "Error: this template page cannot be called directly as an URL";
exit; exit;
} }
$usemargins = 0; $usemargins = 0;
if (!empty($conf->margin->enabled) && !empty($object->element) && in_array($object->element, array('facture', 'facturerec', 'propal', 'commande'))) if (!empty($conf->margin->enabled) && !empty($object->element) && in_array($object->element, array('facture', 'facturerec', 'propal', 'commande')))
{ {
$usemargins = 1; $usemargins = 1;
} }
if (!isset($dateSelector)) global $dateSelector; // Take global var only if not already defined into function calling (for example formAddObjectLine) if (!isset($dateSelector)) global $dateSelector; // Take global var only if not already defined into function calling (for example formAddObjectLine)
global $forceall, $forcetoshowtitlelines, $senderissupplier, $inputalsopricewithtax; global $forceall, $forcetoshowtitlelines, $senderissupplier, $inputalsopricewithtax;
if (!isset($dateSelector)) $dateSelector = 1; // For backward compatibility if (!isset($dateSelector)) $dateSelector = 1; // For backward compatibility
elseif (empty($dateSelector)) $dateSelector = 0; elseif (empty($dateSelector)) $dateSelector = 0;
if (empty($forceall)) $forceall = 0; if (empty($forceall)) $forceall = 0;
if (empty($senderissupplier)) $senderissupplier = 0; if (empty($senderissupplier)) $senderissupplier = 0;
if (empty($inputalsopricewithtax)) $inputalsopricewithtax = 0; if (empty($inputalsopricewithtax)) $inputalsopricewithtax = 0;
// Define colspan for the button 'Add' // Define colspan for the button 'Add'
$colspan = 3; // Columns: total ht + col edit + col delete $colspan = 3; // Columns: total ht + col edit + col delete
if (!empty($conf->multicurrency->enabled) && $this->multicurrency_code != $conf->currency) $colspan++; //Add column for Total (currency) if required if (!empty($conf->multicurrency->enabled) && $this->multicurrency_code != $conf->currency) $colspan++; //Add column for Total (currency) if required
if (in_array($object->element, array('propal', 'commande', 'order', 'facture', 'facturerec', 'invoice', 'supplier_proposal', 'order_supplier', 'invoice_supplier'))) $colspan++; // With this, there is a column move button if (in_array($object->element, array('propal', 'commande', 'order', 'facture', 'facturerec', 'invoice', 'supplier_proposal', 'order_supplier', 'invoice_supplier'))) $colspan++; // With this, there is a column move button
//print $object->element; //print $object->element;
// Lines for extrafield // Lines for extrafield
$objectline = null; $objectline = null;
if (!empty($extrafields)) if (!empty($extrafields))
@ -89,8 +83,6 @@ if (!empty($extrafields))
$objectline = new FactureLigneRec($this->db); $objectline = new FactureLigneRec($this->db);
} }
} }
print "<!-- BEGIN PHP TEMPLATE objectline_create.tpl.php -->\n"; print "<!-- BEGIN PHP TEMPLATE objectline_create.tpl.php -->\n";
$nolinesbefore=(count($this->lines) == 0 || $forcetoshowtitlelines); $nolinesbefore=(count($this->lines) == 0 || $forcetoshowtitlelines);
if ($nolinesbefore) { if ($nolinesbefore) {
@ -160,19 +152,16 @@ if ($nolinesbefore) {
<tr class="pair nodrag nodrop nohoverpair<?php echo ($nolinesbefore || $object->element=='contrat')?'':' liste_titre_create'; ?>"> <tr class="pair nodrag nodrop nohoverpair<?php echo ($nolinesbefore || $object->element=='contrat')?'':' liste_titre_create'; ?>">
<?php <?php
$coldisplay=0; $coldisplay=0;
// Adds a line numbering column // Adds a line numbering column
if (! empty($conf->global->MAIN_VIEW_LINE_NUMBER)) { if (! empty($conf->global->MAIN_VIEW_LINE_NUMBER)) {
$coldisplay++; $coldisplay++;
echo '<td class="nobottom linecolnum center"></td>'; echo '<td class="nobottom linecolnum center"></td>';
} }
$coldisplay++; $coldisplay++;
?> ?>
<td class="nobottom linecoldescription minwidth500imp"> <td class="nobottom linecoldescription minwidth500imp">
<?php <?php
$freelines = false; $freelines = false;
if (empty($conf->global->MAIN_DISABLE_FREE_LINES)) if (empty($conf->global->MAIN_DISABLE_FREE_LINES))
{ {
@ -183,7 +172,6 @@ if (empty($conf->global->MAIN_DISABLE_FREE_LINES))
if (empty($conf->product->enabled) && empty($conf->service->enabled) && empty($conf->global->CONTRACT_SUPPORT_PRODUCTS)) $forceall=-1; // With contract, by default, no choice at all, except if CONTRACT_SUPPORT_PRODUCTS is set if (empty($conf->product->enabled) && empty($conf->service->enabled) && empty($conf->global->CONTRACT_SUPPORT_PRODUCTS)) $forceall=-1; // With contract, by default, no choice at all, except if CONTRACT_SUPPORT_PRODUCTS is set
elseif (empty($conf->global->CONTRACT_SUPPORT_PRODUCTS)) $forceall=3; elseif (empty($conf->global->CONTRACT_SUPPORT_PRODUCTS)) $forceall=3;
} }
// Free line // Free line
echo '<span class="prod_entry_mode_free">'; echo '<span class="prod_entry_mode_free">';
// Show radio free line // Show radio free line
@ -210,12 +198,9 @@ if (empty($conf->global->MAIN_DISABLE_FREE_LINES))
echo ' '; echo ' ';
} }
} }
echo $form->select_type_of_lines(isset($_POST["type"])?GETPOST("type", 'alpha', 2):-1, 'type', 1, 1, $forceall); echo $form->select_type_of_lines(isset($_POST["type"])?GETPOST("type", 'alpha', 2):-1, 'type', 1, 1, $forceall);
echo '</span>'; echo '</span>';
} }
// Predefined product/service // Predefined product/service
if (! empty($conf->product->enabled) || ! empty($conf->service->enabled)) if (! empty($conf->product->enabled) || ! empty($conf->service->enabled))
{ {
@ -237,23 +222,20 @@ if (! empty($conf->product->enabled) || ! empty($conf->service->enabled))
} }
echo '</label>'; echo '</label>';
echo ' '; echo ' ';
$filtertype=''; $filtertype='';
if (! empty($object->element) && $object->element == 'contrat' && empty($conf->global->CONTRACT_SUPPORT_PRODUCTS)) $filtertype='1'; if (! empty($object->element) && $object->element == 'contrat' && empty($conf->global->CONTRACT_SUPPORT_PRODUCTS)) $filtertype='1';
if (empty($senderissupplier)) if (empty($senderissupplier))
{ {
$statustoshow = 1; $statustoshow = 1;
if (! empty($conf->global->ENTREPOT_EXTRA_STATUS)) if (! empty($conf->global->ENTREPOT_EXTRA_STATUS))
{ {
// hide products in closed warehouse, but show products for internal transfer // hide products in closed warehouse, but show products for internal transfer
$form->select_produits(GETPOST('idprod'), 'idprod', $filtertype, $conf->product->limit_size, $buyer->price_level, $statustoshow, 2, '', 1, array(), $buyer->id, '1', 0, 'maxwidth300', 0, 'warehouseopen,warehouseinternal', GETPOST('combinations', 'array')); $form->select_produits(GETPOST('idprod'), 'idprod', $filtertype, $conf->product->limit_size, $buyer->price_level, $statustoshow, 2, '', 1, array(), $buyer->id, '1', 0, 'maxwidth500', 0, 'warehouseopen,warehouseinternal', GETPOST('combinations', 'array'));
} }
else else
{ {
$form->select_produits(GETPOST('idprod'), 'idprod', $filtertype, $conf->product->limit_size, $buyer->price_level, $statustoshow, 2, '', 1, array(), $buyer->id, '1', 0, 'maxwidth300', 0, '', GETPOST('combinations', 'array')); $form->select_produits(GETPOST('idprod'), 'idprod', $filtertype, $conf->product->limit_size, $buyer->price_level, $statustoshow, 2, '', 1, array(), $buyer->id, '1', 0, 'maxwidth500', 0, '', GETPOST('combinations', 'array'));
} }
if (! empty($conf->global->MAIN_AUTO_OPEN_SELECT2_ON_FOCUS_FOR_CUSTOMER_PRODUCTS)) if (! empty($conf->global->MAIN_AUTO_OPEN_SELECT2_ON_FOCUS_FOR_CUSTOMER_PRODUCTS))
{ {
?> ?>
@ -292,9 +274,7 @@ if (! empty($conf->product->enabled) || ! empty($conf->service->enabled))
); );
$alsoproductwithnosupplierprice=1; $alsoproductwithnosupplierprice=1;
} }
$form->select_produits_fournisseurs($object->socid, GETPOST('idprodfournprice'), 'idprodfournprice', '', '', $ajaxoptions, 1, $alsoproductwithnosupplierprice, 'maxwidth500');
$form->select_produits_fournisseurs($object->socid, GETPOST('idprodfournprice'), 'idprodfournprice', '', '', $ajaxoptions, 1, $alsoproductwithnosupplierprice, 'maxwidth300');
if (! empty($conf->global->MAIN_AUTO_OPEN_SELECT2_ON_FOCUS_FOR_SUPPLIER_PRODUCTS)) if (! empty($conf->global->MAIN_AUTO_OPEN_SELECT2_ON_FOCUS_FOR_SUPPLIER_PRODUCTS))
{ {
?> ?>
@ -316,7 +296,6 @@ if (! empty($conf->product->enabled) || ! empty($conf->service->enabled))
echo '<input type="hidden" name="pbq" id="pbq" value="">'; echo '<input type="hidden" name="pbq" id="pbq" value="">';
echo '</span>'; echo '</span>';
} }
if (is_object($hookmanager) && empty($senderissupplier)) if (is_object($hookmanager) && empty($senderissupplier))
{ {
$parameters=array('fk_parent_line'=>GETPOST('fk_parent_line', 'int')); $parameters=array('fk_parent_line'=>GETPOST('fk_parent_line', 'int'));
@ -333,16 +312,12 @@ if (is_object($hookmanager) && ! empty($senderissupplier))
print $hookmanager->resPrint; print $hookmanager->resPrint;
} }
} }
if (! empty($conf->product->enabled) || ! empty($conf->service->enabled)) { if (! empty($conf->product->enabled) || ! empty($conf->service->enabled)) {
if (!empty($conf->variants->enabled)) { if (!empty($conf->variants->enabled)) {
echo '<div id="attributes_box"></div>'; echo '<div id="attributes_box"></div>';
} }
echo '<br>'; echo '<br>';
} }
// Editor wysiwyg // Editor wysiwyg
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
$nbrows=ROWS_2; $nbrows=ROWS_2;
@ -352,7 +327,6 @@ $toolbarname='dolibarr_details';
if (! empty($conf->global->FCKEDITOR_ENABLE_DETAILS_FULL)) $toolbarname='dolibarr_notes'; if (! empty($conf->global->FCKEDITOR_ENABLE_DETAILS_FULL)) $toolbarname='dolibarr_notes';
$doleditor=new DolEditor('dp_desc', GETPOST('dp_desc', 'none'), '', (empty($conf->global->MAIN_DOLEDITOR_HEIGHT)?100:$conf->global->MAIN_DOLEDITOR_HEIGHT), $toolbarname, '', false, true, $enabled, $nbrows, '98%'); $doleditor=new DolEditor('dp_desc', GETPOST('dp_desc', 'none'), '', (empty($conf->global->MAIN_DOLEDITOR_HEIGHT)?100:$conf->global->MAIN_DOLEDITOR_HEIGHT), $toolbarname, '', false, true, $enabled, $nbrows, '98%');
$doleditor->Create(); $doleditor->Create();
// Show autofill date for recurring invoices // Show autofill date for recurring invoices
if (! empty($conf->service->enabled) && $object->element == 'facturerec') if (! empty($conf->service->enabled) && $object->element == 'facturerec')
{ {
@ -365,14 +339,12 @@ if (! empty($conf->service->enabled) && $object->element == 'facturerec')
echo '</div>'; echo '</div>';
} }
echo '</td>'; echo '</td>';
if ($object->element == 'supplier_proposal' || $object->element == 'order_supplier' || $object->element == 'invoice_supplier') // We must have same test in printObjectLines if ($object->element == 'supplier_proposal' || $object->element == 'order_supplier' || $object->element == 'invoice_supplier') // We must have same test in printObjectLines
{ {
$coldisplay++; $coldisplay++;
?> ?>
<td class="nobottom linecolresupplier"><input id="fourn_ref" name="fourn_ref" class="flat minwidth50 maxwidth150" value="<?php echo (isset($_POST["fourn_ref"])?GETPOST("fourn_ref", 'alpha', 2):''); ?>"></td> <td class="nobottom linecolresupplier"><input id="fourn_ref" name="fourn_ref" class="flat minwidth50 maxwidth150" value="<?php echo (isset($_POST["fourn_ref"])?GETPOST("fourn_ref", 'alpha', 2):''); ?>"></td>
<?php } <?php }
print '<td class="nobottom linecolvat right">'; print '<td class="nobottom linecolvat right">';
$coldisplay++; $coldisplay++;
if ($seller->tva_assuj == "0") echo '<input type="hidden" name="tva_tx" id="tva_tx" value="0">'.vatrate(0, true); if ($seller->tva_assuj == "0") echo '<input type="hidden" name="tva_tx" id="tva_tx" value="0">'.vatrate(0, true);
@ -391,7 +363,6 @@ else echo $form->load_tva('tva_tx', (isset($_POST["tva_tx"])?GETPOST("tva_tx", '
<input type="text" size="5" name="multicurrency_price_ht" id="multicurrency_price_ht" class="flat right" value="<?php echo (isset($_POST["multicurrency_price_ht"])?GETPOST("multicurrency_price_ht", 'alpha', 2):''); ?>"> <input type="text" size="5" name="multicurrency_price_ht" id="multicurrency_price_ht" class="flat right" value="<?php echo (isset($_POST["multicurrency_price_ht"])?GETPOST("multicurrency_price_ht", 'alpha', 2):''); ?>">
</td> </td>
<?php } <?php }
if (! empty($inputalsopricewithtax)) { if (! empty($inputalsopricewithtax)) {
$coldisplay++; $coldisplay++;
?> ?>
@ -399,7 +370,6 @@ if (! empty($inputalsopricewithtax)) {
<input type="text" size="5" name="price_ttc" id="price_ttc" class="flat" value="<?php echo (isset($_POST["price_ttc"])?GETPOST("price_ttc", 'alpha', 2):''); ?>"> <input type="text" size="5" name="price_ttc" id="price_ttc" class="flat" value="<?php echo (isset($_POST["price_ttc"])?GETPOST("price_ttc", 'alpha', 2):''); ?>">
</td> </td>
<?php } <?php }
$coldisplay++; $coldisplay++;
?> ?>
<td class="nobottom linecolqty right"><input type="text" size="2" name="qty" id="qty" class="flat right" value="<?php echo (isset($_POST["qty"])?GETPOST("qty", 'alpha', 2):1); ?>"> <td class="nobottom linecolqty right"><input type="text" size="2" name="qty" id="qty" class="flat right" value="<?php echo (isset($_POST["qty"])?GETPOST("qty", 'alpha', 2):1); ?>">
@ -417,19 +387,16 @@ if($object->element == 'supplier_proposal' || $object->element == 'order_supplie
{ {
$remise_percent = $seller->remise_supplier_percent; $remise_percent = $seller->remise_supplier_percent;
} }
$coldisplay++; $coldisplay++;
?> ?>
<td class="nobottom nowrap linecoldiscount right"><input type="text" size="1" name="remise_percent" id="remise_percent" class="flat right" value="<?php echo (isset($_POST["remise_percent"])?GETPOST("remise_percent", 'alpha', 2):$remise_percent); ?>"><span class="hideonsmartphone">%</span></td> <td class="nobottom nowrap linecoldiscount right"><input type="text" size="1" name="remise_percent" id="remise_percent" class="flat right" value="<?php echo (isset($_POST["remise_percent"])?GETPOST("remise_percent", 'alpha', 2):$remise_percent); ?>"><span class="hideonsmartphone">%</span></td>
<?php <?php
if ($this->situation_cycle_ref) { if ($this->situation_cycle_ref) {
$coldisplay++; $coldisplay++;
print '<td class="nobottom nowrap right"><input class="falt right" type="text" size="1" value="0" name="progress">%</td>'; print '<td class="nobottom nowrap right"><input class="falt right" type="text" size="1" value="0" name="progress">%</td>';
$coldisplay++; $coldisplay++;
print '<td></td>'; print '<td></td>';
} }
if (! empty($usemargins)) if (! empty($usemargins))
{ {
if (!empty($user->rights->margins->creer)) { if (!empty($user->rights->margins->creer)) {
@ -456,7 +423,6 @@ if (! empty($usemargins))
} }
} }
} }
$coldisplay+=$colspan; $coldisplay+=$colspan;
?> ?>
<td class="nobottom linecoledit center valignmiddle" colspan="<?php echo $colspan; ?>"> <td class="nobottom linecoledit center valignmiddle" colspan="<?php echo $colspan; ?>">
@ -468,7 +434,6 @@ $coldisplay+=$colspan;
if (is_object($objectline)) { if (is_object($objectline)) {
print $objectline->showOptionals($extrafields, 'edit', array('colspan'=>$coldisplay), '', '', empty($conf->global->MAIN_EXTRAFIELDS_IN_ONE_TD) ? 0 : 1); print $objectline->showOptionals($extrafields, 'edit', array('colspan'=>$coldisplay), '', '', empty($conf->global->MAIN_EXTRAFIELDS_IN_ONE_TD) ? 0 : 1);
} }
if ((!empty($conf->service->enabled) || ($object->element == 'contrat')) && $dateSelector && GETPOST('type') != '0') // We show date field if required if ((!empty($conf->service->enabled) || ($object->element == 'contrat')) && $dateSelector && GETPOST('type') != '0') // We show date field if required
{ {
?> ?>
@ -514,9 +479,7 @@ if ((!empty($conf->service->enabled) || ($object->element == 'contrat')) && $dat
print '</td>'; print '</td>';
print "</tr>\n"; print "</tr>\n";
} }
print "<script>\n"; print "<script>\n";
if (! empty($usemargins) && $user->rights->margins->creer) if (! empty($usemargins) && $user->rights->margins->creer)
{ {
?> ?>
@ -675,7 +638,6 @@ jQuery(document).ready(function() {
<?php <?php
} }
if (!empty($usemargins) && $user->rights->margins->creer) if (!empty($usemargins) && $user->rights->margins->creer)
{ {
$langs->load('stocks'); $langs->load('stocks');