dolibarr  13.0.2
objectline_create.tpl.php
1 <?php
2 /* Copyright (C) 2010-2012 Regis Houssin <regis.houssin@inodbox.com>
3  * Copyright (C) 2010-2014 Laurent Destailleur <eldy@users.sourceforge.net>
4  * Copyright (C) 2012-2013 Christophe Battarel <christophe.battarel@altairis.fr>
5  * Copyright (C) 2012 Cédric Salvador <csalvador@gpcsolutions.fr>
6  * Copyright (C) 2014 Florian Henry <florian.henry@open-concept.pro>
7  * Copyright (C) 2014 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
8  * Copyright (C) 2015-2016 Marcos García <marcosgdf@gmail.com>
9  * Copyright (C) 2018-2019 Frédéric France <frederic.france@netlogic.fr>
10  * Copyright (C) 2018 Ferran Marcet <fmarcet@2byte.es>
11  *
12  * This program is free software; you can redistribute it and/or modify
13  * it under the terms of the GNU General Public License as published by
14  * the Free Software Foundation; either version 3 of the License, or
15  * (at your option) any later version.
16  *
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  * GNU General Public License for more details.
21  *
22  * You should have received a copy of the GNU General Public License
23  * along with this program. If not, see <https://www.gnu.org/licenses/>.
24  *
25  * Need to have following variables defined:
26  * $object (invoice, order, ...)
27  * $conf
28  * $langs
29  * $forceall (0 by default, 1 for supplier invoices/orders)
30  */
31 
32 // Protection to avoid direct call of template
33 if (empty($object) || !is_object($object)) {
34  print "Error: this template page cannot be called directly as an URL";
35  exit;
36 }
37 
38 
39 global $forceall, $forcetoshowtitlelines;
40 
41 if (empty($forceall)) $forceall = 0;
42 
43 
44 // Define colspan for the button 'Add'
45 $colspan = 3; // Columns: total ht + col edit + col delete
46 //print $object->element;
47 
48 // Lines for extrafield
49 $objectline = new BOMLine($this->db);
50 
51 print "<!-- BEGIN PHP TEMPLATE objectline_create.tpl.php -->\n";
52 
53 $nolinesbefore = (count($this->lines) == 0 || $forcetoshowtitlelines);
54 if ($nolinesbefore) {
55  print '<tr class="liste_titre nodrag nodrop">';
56  if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER)) {
57  print '<td class="linecolnum center"></td>';
58  }
59  print '<td class="linecoldescription minwidth500imp">';
60  print '<div id="add"></div><span class="hideonsmartphone">'.$langs->trans('AddNewLine').'</span>';
61  print '</td>';
62  print '<td class="linecolqty right">'.$langs->trans('Qty').'</td>';
63  if (!empty($conf->global->PRODUCT_USE_UNITS))
64  {
65  print '<td class="linecoluseunit left">';
66  print '<span id="title_units">';
67  print $langs->trans('Unit');
68  print '</span></td>';
69  }
70  print '<td class="linecolqtyfrozen right">'.$form->textwithpicto($langs->trans('QtyFrozen'), $langs->trans("QuantityConsumedInvariable")).'</td>';
71  print '<td class="linecoldisablestockchange right">'.$form->textwithpicto($langs->trans('DisableStockChange'), $langs->trans('DisableStockChangeHelp')).'</td>';
72  print '<td class="linecollost right">'.$form->textwithpicto($langs->trans('ManufacturingEfficiency'), $langs->trans('ValueOfMeansLoss')).'</td>';
73  print '<td class="linecoledit" colspan="'.$colspan.'">&nbsp;</td>';
74  print '</tr>';
75 }
76 print '<tr class="pair nodrag nodrop nohoverpair'.(($nolinesbefore || $object->element == 'contrat') ? '' : ' liste_titre_create').'">';
77 $coldisplay = 0;
78 
79 // Adds a line numbering column
80 if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER)) {
81  $coldisplay++;
82  echo '<td class="bordertop nobottom linecolnum center"></td>';
83 }
84 
85 $coldisplay++;
86 print '<td class="bordertop nobottom linecoldescription minwidth500imp">';
87 
88 // Predefined product/service
89 if (!empty($conf->product->enabled) || !empty($conf->service->enabled))
90 {
91  if ($forceall >= 0 && $freelines) echo '<br>';
92  echo '<span class="prod_entry_mode_predef">';
93  $filtertype = '';
94  if (!empty($object->element) && $object->element == 'contrat' && empty($conf->global->CONTRACT_SUPPORT_PRODUCTS)) $filtertype = '1';
95 
96  $statustoshow = -1;
97  if (!empty($conf->global->ENTREPOT_EXTRA_STATUS))
98  {
99  // hide products in closed warehouse, but show products for internal transfer
100  $form->select_produits(GETPOST('idprod', 'int'), 'idprod', $filtertype, $conf->product->limit_size, $buyer->price_level, $statustoshow, 2, '', 1, array(), $buyer->id, '1', 0, 'maxwidth500', 0, 'warehouseopen,warehouseinternal', GETPOST('combinations', 'array'));
101  } else {
102  $form->select_produits(GETPOST('idprod', 'int'), 'idprod', $filtertype, $conf->product->limit_size, $buyer->price_level, $statustoshow, 2, '', 1, array(), $buyer->id, '1', 0, 'maxwidth500', 0, '', GETPOST('combinations', 'array'));
103  }
104 
105  echo '</span>';
106 }
107 
108 $coldisplay++;
109 print '<td class="bordertop nobottom linecolqty right"><input type="text" size="2" name="qty" id="qty" class="flat right" value="'.(GETPOSTISSET("qty") ? GETPOST("qty", 'alpha', 2) : 1).'">';
110 print '</td>';
111 
112 if (!empty($conf->global->PRODUCT_USE_UNITS))
113 {
114  $coldisplay++;
115  print '<td class="nobottom linecoluseunit left">';
116  print '</td>';
117 }
118 
119 $coldisplay++;
120 print '<td class="bordertop nobottom linecolqtyfrozen right"><input type="checkbox" name="qty_frozen" id="qty_frozen" class="flat right" value="1"'.(GETPOST("qty_frozen", 'alpha') ? ' checked="checked"' : '').'>';
121 print '</td>';
122 
123 $coldisplay++;
124 print '<td class="bordertop nobottom linecoldisablestockchange right"><input type="checkbox" name="disable_stock_change" id="disable_stock_change" class="flat right" value="1"'.(GETPOST("disable_stock_change", 'alpha') ? ' checked="checked"' : '').'">';
125 print '</td>';
126 
127 $coldisplay++;
128 print '<td class="bordertop nobottom nowrap linecollost right">';
129 print '<input type="text" size="1" name="efficiency" id="efficiency" class="flat right" value="'.(GETPOSTISSET("efficiency") ?GETPOST("efficiency", 'alpha') : 1).'">';
130 print '</td>';
131 
132 $coldisplay++;
133 print '<td class="bordertop nobottom nowrap linecolcost right">';
134 print '&nbsp;';
135 print '</td>';
136 
137 $coldisplay += $colspan;
138 print '<td class="bordertop nobottom linecoledit center valignmiddle" colspan="'.$colspan.'">';
139 print '<input type="submit" class="button" value="'.$langs->trans('Add').'" name="addline" id="addline">';
140 print '</td>';
141 print '</tr>';
142 
143 if (is_object($objectline)) {
144  print $objectline->showOptionals($extrafields, 'edit', array('style'=>$bcnd[$var], 'colspan'=>$coldisplay), '', '', 1);
145 }
146 ?>
147 
148 <script>
149 
150 /* JQuery for product free or predefined select */
151 jQuery(document).ready(function() {
152  /* When changing predefined product, we reload list of supplier prices required for margin combo */
153  $("#idprod").change(function()
154  {
155  console.log("#idprod change triggered");
156 
157  /* To set focus */
158  if (jQuery('#idprod').val() > 0)
159  {
160  /* focus work on a standard textarea but not if field was replaced with CKEDITOR */
161  jQuery('#dp_desc').focus();
162  /* focus if CKEDITOR */
163  if (typeof CKEDITOR == "object" && typeof CKEDITOR.instances != "undefined")
164  {
165  var editor = CKEDITOR.instances['dp_desc'];
166  if (editor) { editor.focus(); }
167  }
168  }
169  });
170 });
171 
172 </script>
173 
174 <!-- END PHP TEMPLATE objectline_create.tpl.php -->
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
$conf db
API class for accounts.
Definition: inc.php:54
Class for BOMLine.
Definition: bom.class.php:1075
print
Draft customers invoices.
Definition: index.php:89