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,13 +83,11 @@ 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) {
?> ?>
<tr class="liste_titre<?php echo (($nolinesbefore || $object->element=='contrat')?'':' liste_titre_add_') ?> nodrag nodrop"> <tr class="liste_titre<?php echo (($nolinesbefore || $object->element=='contrat')?'':' liste_titre_add_') ?> nodrag nodrop">
<?php if (! empty($conf->global->MAIN_VIEW_LINE_NUMBER)) { ?> <?php if (! empty($conf->global->MAIN_VIEW_LINE_NUMBER)) { ?>
<td class="linecolnum center"></td> <td class="linecolnum center"></td>
<?php } ?> <?php } ?>
@ -153,29 +145,26 @@ if ($nolinesbefore) {
} }
?> ?>
<td class="linecoledit" colspan="<?php echo $colspan; ?>">&nbsp;</td> <td class="linecoledit" colspan="<?php echo $colspan; ?>">&nbsp;</td>
</tr> </tr>
<?php <?php
} }
?> ?>
<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)) {
{
$freelines = true; $freelines = true;
$forceall=1; // We always force all type for free lines (module product or service means we use predefined product or service) $forceall=1; // We always force all type for free lines (module product or service means we use predefined product or service)
if ($object->element == 'contrat') if ($object->element == 'contrat')
@ -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,15 +198,12 @@ 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)) {
{
if ($forceall >= 0 && $freelines) echo '<br>'; if ($forceall >= 0 && $freelines) echo '<br>';
echo '<span class="prod_entry_mode_predef">'; echo '<span class="prod_entry_mode_predef">';
echo '<label for="prod_entry_mode_predef">'; echo '<label for="prod_entry_mode_predef">';
@ -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))
{ {
?> ?>
@ -315,47 +295,41 @@ 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'));
$reshook=$hookmanager->executeHooks('formCreateProductOptions', $parameters, $object, $action); $reshook=$hookmanager->executeHooks('formCreateProductOptions', $parameters, $object, $action);
if (!empty($hookmanager->resPrint)) { if (!empty($hookmanager->resPrint)) {
print $hookmanager->resPrint; print $hookmanager->resPrint;
} }
} }
if (is_object($hookmanager) && ! empty($senderissupplier)) if (is_object($hookmanager) && ! empty($senderissupplier))
{ {
$parameters=array('htmlname'=>'addproduct'); $parameters=array('htmlname'=>'addproduct');
$reshook=$hookmanager->executeHooks('formCreateProductSupplierOptions', $parameters, $object, $action); $reshook=$hookmanager->executeHooks('formCreateProductSupplierOptions', $parameters, $object, $action);
if (!empty($hookmanager->resPrint)) { if (!empty($hookmanager->resPrint)) {
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; $enabled=(! empty($conf->global->FCKEDITOR_ENABLE_DETAILS)?$conf->global->FCKEDITOR_ENABLE_DETAILS:0);
$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;
if (! empty($conf->global->MAIN_INPUT_DESC_HEIGHT)) $nbrows=$conf->global->MAIN_INPUT_DESC_HEIGHT; $toolbarname='dolibarr_details';
$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
if (! empty($conf->service->enabled) && $object->element == 'facturerec')
// Show autofill date for recurring invoices {
if (! empty($conf->service->enabled) && $object->element == 'facturerec')
{
echo '<div class="divlinefordates"><br>'; echo '<div class="divlinefordates"><br>';
echo $langs->trans('AutoFillDateFrom').' '; echo $langs->trans('AutoFillDateFrom').' ';
echo $form->selectyesno('date_start_fill', $line->date_start_fill, 1); echo $form->selectyesno('date_start_fill', $line->date_start_fill, 1);
@ -363,16 +337,14 @@ if (! empty($conf->service->enabled) && $object->element == 'facturerec')
echo $langs->trans('AutoFillDateTo').' '; echo $langs->trans('AutoFillDateTo').' ';
echo $form->selectyesno('date_end_fill', $line->date_end_fill, 1); echo $form->selectyesno('date_end_fill', $line->date_end_fill, 1);
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);
@ -384,54 +356,49 @@ else echo $form->load_tva('tva_tx', (isset($_POST["tva_tx"])?GETPOST("tva_tx", '
<input type="text" size="5" name="price_ht" id="price_ht" class="flat right" value="<?php echo (isset($_POST["price_ht"])?GETPOST("price_ht", 'alpha', 2):''); ?>"> <input type="text" size="5" name="price_ht" id="price_ht" class="flat right" value="<?php echo (isset($_POST["price_ht"])?GETPOST("price_ht", 'alpha', 2):''); ?>">
</td> </td>
<?php if (!empty($conf->multicurrency->enabled) && $this->multicurrency_code != $conf->currency) { <?php if (!empty($conf->multicurrency->enabled) && $this->multicurrency_code != $conf->currency) {
$coldisplay++; $coldisplay++;
?> ?>
<td class="nobottom linecoluht_currency right"> <td class="nobottom linecoluht_currency right">
<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++;
?> ?>
<td class="nobottom linecoluttc right"> <td class="nobottom linecoluttc right">
<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); ?>">
</td> </td>
<?php <?php
if($conf->global->PRODUCT_USE_UNITS) if($conf->global->PRODUCT_USE_UNITS)
{ {
$coldisplay++; $coldisplay++;
print '<td class="nobottom linecoluseunit left">'; print '<td class="nobottom linecoluseunit left">';
print $form->selectUnits($line->fk_unit, "units"); print $form->selectUnits($line->fk_unit, "units");
print '</td>'; print '</td>';
} }
$remise_percent = $buyer->remise_percent; $remise_percent = $buyer->remise_percent;
if($object->element == 'supplier_proposal' || $object->element == 'order_supplier' || $object->element == 'invoice_supplier') if($object->element == 'supplier_proposal' || $object->element == 'order_supplier' || $object->element == 'invoice_supplier')
{ {
$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)) {
$coldisplay++; $coldisplay++;
?> ?>
@ -455,10 +422,9 @@ if (! empty($usemargins))
$coldisplay++; $coldisplay++;
} }
} }
} }
$coldisplay+=$colspan;
$coldisplay+=$colspan; ?>
?>
<td class="nobottom linecoledit center valignmiddle" colspan="<?php echo $colspan; ?>"> <td class="nobottom linecoledit center valignmiddle" colspan="<?php echo $colspan; ?>">
<input type="submit" class="button" value="<?php echo $langs->trans('Add'); ?>" name="addline" id="addline"> <input type="submit" class="button" value="<?php echo $langs->trans('Add'); ?>" name="addline" id="addline">
</td> </td>
@ -468,12 +434,11 @@ $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
{ {
?> ?>
<tr id="trlinefordates" <?php echo $bcnd[$var]; ?>> <tr id="trlinefordates" <?php echo $bcnd[$var]; ?>>
<?php if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER)) { print '<td></td>'; } ?> <?php if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER)) { print '<td></td>'; } ?>
<td colspan="<?php echo $coldisplay - (empty($conf->global->MAIN_VIEW_LINE_NUMBER) ? 0 : 1); ?>"> <td colspan="<?php echo $coldisplay - (empty($conf->global->MAIN_VIEW_LINE_NUMBER) ? 0 : 1); ?>">
<?php <?php
@ -513,12 +478,10 @@ if ((!empty($conf->service->enabled) || ($object->element == 'contrat')) && $dat
print '</script>'; print '</script>';
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)
{
?> ?>
/* Some js test when we click on button "Add" */ /* Some js test when we click on button "Add" */
@ -585,11 +548,11 @@ if (! empty($usemargins) && $user->rights->margins->creer)
} }
<?php <?php
} }
?> ?>
/* JQuery for product free or predefined select */ /* JQuery for product free or predefined select */
jQuery(document).ready(function() { jQuery(document).ready(function() {
jQuery("#price_ht").keyup(function(event) { jQuery("#price_ht").keyup(function(event) {
// console.log(event.which); // discard event tag and arrows // console.log(event.which); // discard event tag and arrows
if (event.which != 9 && (event.which < 37 ||event.which > 40) && jQuery("#price_ht").val() != '') { if (event.which != 9 && (event.which < 37 ||event.which > 40) && jQuery("#price_ht").val() != '') {
@ -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');
@ -820,10 +782,10 @@ jQuery(document).ready(function() {
<?php if (GETPOST('prod_entry_mode') == 'predef') { // When we submit with a predef product and it fails we must start with predef ?> <?php if (GETPOST('prod_entry_mode') == 'predef') { // When we submit with a predef product and it fails we must start with predef ?>
setforpredef(); setforpredef();
<?php } ?> <?php } ?>
}); });
/* Function to set fields from choice */ /* Function to set fields from choice */
function setforfree() { function setforfree() {
console.log("Call setforfree. We show most fields"); console.log("Call setforfree. We show most fields");
jQuery("#idprodfournprice").val('0'); // Set cursor on not selected product jQuery("#idprodfournprice").val('0'); // Set cursor on not selected product
jQuery("#prod_entry_mode_free").prop('checked',true).change(); jQuery("#prod_entry_mode_free").prop('checked',true).change();
@ -832,8 +794,8 @@ function setforfree() {
jQuery("#price_ht, #multicurrency_price_ht, #price_ttc, #price_ttc, #fourn_ref, #tva_tx, #buying_price, #title_vat, #title_up_ht, #title_up_ht_currency, #title_up_ttc, #title_up_ttc_currency").show(); jQuery("#price_ht, #multicurrency_price_ht, #price_ttc, #price_ttc, #fourn_ref, #tva_tx, #buying_price, #title_vat, #title_up_ht, #title_up_ht_currency, #title_up_ttc, #title_up_ttc_currency").show();
jQuery("#np_marginRate, #np_markRate, .np_marginRate, .np_markRate, #units, #title_units").show(); jQuery("#np_marginRate, #np_markRate, .np_marginRate, .np_markRate, #units, #title_units").show();
jQuery("#fournprice_predef").hide(); jQuery("#fournprice_predef").hide();
} }
function setforpredef() { function setforpredef() {
console.log("Call setforpredef. We hide some fields and show dates"); console.log("Call setforpredef. We hide some fields and show dates");
jQuery("#select_type").val(-1); jQuery("#select_type").val(-1);
jQuery("#prod_entry_mode_free").prop('checked',false).change(); jQuery("#prod_entry_mode_free").prop('checked',false).change();
@ -850,8 +812,8 @@ function setforpredef() {
jQuery("#np_marginRate, #np_markRate, .np_marginRate, .np_markRate, #units, #title_units").hide(); jQuery("#np_marginRate, #np_markRate, .np_marginRate, .np_markRate, #units, #title_units").hide();
jQuery("#buying_price").show(); jQuery("#buying_price").show();
jQuery('#trlinefordates, .divlinefordates').show(); jQuery('#trlinefordates, .divlinefordates').show();
} }
</script> </script>
<!-- END PHP TEMPLATE objectline_create.tpl.php --> <!-- END PHP TEMPLATE objectline_create.tpl.php -->