dolibarr  16.0.5
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)) {
42  $forceall = 0;
43 }
44 
45 
46 // Define colspan for the button 'Add'
47 $colspan = 3; // Columns: total ht + col edit + col delete
48 //print $object->element;
49 
50 // Lines for extrafield
51 $objectline = new BOMLine($this->db);
52 
53 print "<!-- BEGIN PHP TEMPLATE objectline_create.tpl.php -->\n";
54 
55 $nolinesbefore = (count($this->lines) == 0 || $forcetoshowtitlelines);
56 if ($nolinesbefore) {
57  print '<tr class="liste_titre nodrag nodrop">';
58  if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER)) {
59  print '<td class="linecolnum center"></td>';
60  }
61  print '<td class="linecoldescription minwidth500imp">';
62  print '<div id="add"></div><span class="hideonsmartphone">'.$langs->trans('AddNewLine').'</span>';
63  print '</td>';
64  print '<td class="linecolqty right">'.$langs->trans('Qty').'</td>';
65  if (!empty($conf->global->PRODUCT_USE_UNITS)) {
66  print '<td class="linecoluseunit left">';
67  print '<span id="title_units">';
68  print $langs->trans('Unit');
69  print '</span></td>';
70  }
71  print '<td class="linecolqtyfrozen right">'.$form->textwithpicto($langs->trans('QtyFrozen'), $langs->trans("QuantityConsumedInvariable")).'</td>';
72  print '<td class="linecoldisablestockchange right">'.$form->textwithpicto($langs->trans('DisableStockChange'), $langs->trans('DisableStockChangeHelp')).'</td>';
73  print '<td class="linecollost right">'.$form->textwithpicto($langs->trans('ManufacturingEfficiency'), $langs->trans('ValueOfMeansLoss')).'</td>';
74  print '<td class="linecoledit" colspan="'.$colspan.'">&nbsp;</td>';
75  print '</tr>';
76 }
77 print '<tr class="pair nodrag nodrop nohoverpair'.(($nolinesbefore || $object->element == 'contrat') ? '' : ' liste_titre_create').'">';
78 $coldisplay = 0;
79 
80 // Adds a line numbering column
81 if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER)) {
82  $coldisplay++;
83  echo '<td class="bordertop nobottom linecolnum center"></td>';
84 }
85 
86 $coldisplay++;
87 print '<td class="bordertop nobottom linecoldescription minwidth500imp">';
88 
89 // Predefined product/service
90 if (!empty($conf->product->enabled) || !empty($conf->service->enabled)) {
91  if (!empty($conf->global->BOM_SUB_BOM)) {
92  print $langs->trans("Product");
93  }
94  echo '<span class="prod_entry_mode_predef">';
95  $filtertype = 0;
96  if (!empty($object->element) && $object->element == 'contrat' && empty($conf->global->STOCK_SUPPORT_SERVICES)) {
97  $filtertype = -1;
98  }
99  $statustoshow = -1;
100  if (!empty($conf->global->ENTREPOT_EXTRA_STATUS)) {
101  // hide products in closed warehouse, but show products for internal transfer
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, 'warehouseopen,warehouseinternal', GETPOST('combinations', 'array'));
103  } else {
104  $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'));
105  }
106 
107  echo '</span>';
108 }
109 if (!empty($conf->global->BOM_SUB_BOM)) {
110  print '<br><span class="opacitymedium">'.$langs->trans("or").'</span><br>'.$langs->trans("BOM");
111  // TODO Add component to select a BOM
112  $form->select_bom();
113 }
114 print '</td>';
115 
116 
117 $coldisplay++;
118 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).'">';
119 print '</td>';
120 
121 if (!empty($conf->global->PRODUCT_USE_UNITS)) {
122  $coldisplay++;
123  print '<td class="nobottom linecoluseunit left">';
124  print '</td>';
125 }
126 
127 $coldisplay++;
128 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"' : '').'>';
129 print '</td>';
130 
131 $coldisplay++;
132 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"' : '').'">';
133 print '</td>';
134 
135 $coldisplay++;
136 print '<td class="bordertop nobottom nowrap linecollost right">';
137 print '<input type="text" size="2" name="efficiency" id="efficiency" class="flat right" value="'.((GETPOSTISSET("efficiency") && $action == 'addline') ?GETPOST("efficiency", 'alpha') : 1).'">';
138 print '</td>';
139 
140 $coldisplay++;
141 print '<td class="bordertop nobottom nowrap linecolcost right">';
142 print '&nbsp;';
143 print '</td>';
144 
145 $coldisplay += $colspan;
146 print '<td class="bordertop nobottom linecoledit center valignmiddle" colspan="'.$colspan.'">';
147 print '<input type="submit" class="button button-add" name="addline" id="addline" value="'.$langs->trans('Add').'">';
148 print '</td>';
149 print '</tr>';
150 
151 if (is_object($objectline)) {
152  print $objectline->showOptionals($extrafields, 'edit', array('style'=>$bcnd[$var], 'colspan'=>$coldisplay), '', '', 1, 'line');
153 }
154 ?>
155 
156 <script>
157 
158 /* JQuery for product free or predefined select */
159 jQuery(document).ready(function() {
160  /* When changing predefined product, we reload list of supplier prices required for margin combo */
161  $("#idprod").change(function()
162  {
163  console.log("#idprod change triggered");
164 
165  /* To set focus */
166  if (jQuery('#idprod').val() > 0)
167  {
168  /* focus work on a standard textarea but not if field was replaced with CKEDITOR */
169  jQuery('#dp_desc').focus();
170  /* focus if CKEDITOR */
171  if (typeof CKEDITOR == "object" && typeof CKEDITOR.instances != "undefined")
172  {
173  var editor = CKEDITOR.instances['dp_desc'];
174  if (editor) { editor.focus(); }
175  }
176  }
177  });
178 });
179 
180 </script>
181 
182 <!-- END PHP TEMPLATE objectline_create.tpl.php -->
db
$conf db
API class for accounts.
Definition: inc.php:41
GETPOST
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
Definition: functions.lib.php:484
BOMLine
Class for BOMLine.
Definition: bom.class.php:1202
$form
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Definition: card.php:142