39require_once DOL_DOCUMENT_ROOT.
'/workstation/class/workstation.class.php';
42if (empty($object) || !is_object($object)) {
43 print
"Error, template page can't be called as URL";
48if (empty($filtertype)) $filtertype = 0;
51global $forceall, $senderissupplier, $inputalsopricewithtax, $outputalsopricetotalwithtax, $langs;
53if (empty($dateSelector)) {
56if (empty($forceall)) {
59if (empty($senderissupplier)) {
60 $senderissupplier = 0;
62if (empty($inputalsopricewithtax)) {
63 $inputalsopricewithtax = 0;
65if (empty($outputalsopricetotalwithtax)) {
66 $outputalsopricetotalwithtax = 0;
70if ($filtertype == 1) $domData =
' data-element="'.$line->element.
'service"';
71else $domData =
' data-element="'.$line->element.
'"';
73$domData .=
' data-id="'.$line->id.
'"';
74$domData .=
' data-qty="'.$line->qty.
'"';
75$domData .=
' data-product_type="'.$line->product_type.
'"';
78$objectline =
new BOMLine($object->db);
81print
"<!-- BEGIN PHP TEMPLATE objectline_view.tpl.php -->\n";
82print
'<tr id="row-'.$line->id.
'" class="drag drop oddeven" '.$domData.
' >';
85if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER)) {
86 print
'<td class="linecolnum center">'.($i + 1).
'</td>';
91print
'<td class="linecoldescription minwidth300imp">';
92print
'<div id="line_'.$line->id.
'"></div>';
94$tmpproduct =
new Product($object->db);
95$tmpproduct->fetch($line->fk_product);
96$tmpbom =
new BOM($object->db);
97$res = $tmpbom->fetch($line->fk_bom_child);
99 print $tmpproduct->getNomUrl(1);
100 print
' '.$langs->trans(
"or").
' ';
101 print $tmpbom->getNomUrl(1);
102 print
' <a class="collapse_bom" id="collapse-'.$line->id.
'" href="#">';
103 print (empty($conf->global->BOM_SHOW_ALL_BOM_BY_DEFAULT) ?
img_picto(
'',
'folder') :
img_picto(
'',
'folder-open'));
106 print $tmpproduct->getNomUrl(1);
107 print
' - '.$tmpproduct->label;
111if (!empty($extrafields)) {
112 $temps = $line->showOptionals($extrafields,
'view', array(),
'',
'', 1,
'line');
113 if (!empty($temps)) {
114 print
'<div style="padding-top: 10px" id="extrafield_lines_area_'.$line->id.
'" name="extrafield_lines_area_'.$line->id.
'">';
123print
'<td class="linecolqty nowrap right">';
125echo
price($line->qty, 0,
'', 0, 0);
128if ($filtertype != 1) {
130 print
'<td class="linecoluseunit nowrap left">';
131 $label = $tmpproduct->getLabelOfUnit(
'long');
133 print $langs->trans($label);
138 print
'<td class="linecolqtyfrozen nowrap right">';
140 echo $line->qty_frozen ?
yn($line->qty_frozen) :
'';
142 print
'<td class="linecoldisablestockchange nowrap right">';
144 echo $line->disable_stock_change ?
yn($line->disable_stock_change) :
'';
147 print
'<td class="linecolefficiency nowrap right">';
149 echo $line->efficiency;
153 print
'<td class="linecolunit nowrap right">';
156 if (!empty($line->fk_unit)) {
157 require_once DOL_DOCUMENT_ROOT.
'/core/class/cunits.class.php';
158 $unit =
new CUnits($this->db);
159 $unit->fetch($line->fk_unit);
160 print (isset($unit->label) ?
" ".$langs->trans(ucwords($unit->label)).
" " :
'');
166 if (isModEnabled(
'workstation')) {
168 $res = $workstation->fetch($line->fk_default_workstation);
170 print
'<td class="linecolworkstation nowrap right">';
172 if ($res > 0) echo $workstation->getNomUrl();
179$tmpbom->calculateCosts();
180print
'<td id="costline_'.$line->id.
'" class="linecolcost nowrap right">';
182if (!empty($line->fk_bom_child)) {
183 echo
'<span class="amount">'.price($tmpbom->total_cost * $line->qty).
'</span>';
185 echo
'<span class="amount">'.price($line->total_cost).
'</span>';
189if ($this->status == 0 && ($object_rights->write) && $action !=
'selectlines') {
190 print
'<td class="linecoledit center">';
192 if (($line->info_bits & 2) == 2 || !empty($disableedit)) {
194 print
'<a class="editfielda reposition" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$this->
id.
'&action=editline&token='.newToken().
'&lineid='.$line->id.
'">'.
img_edit().
'</a>';
198 print
'<td class="linecoldelete center">';
200 if (($line->fk_prev_id ==
null) && empty($disableremove)) {
202 print
'<a class="reposition" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$this->
id.
'&action=deleteline&token='.newToken().
'&lineid='.$line->id.
'">';
208 if ($num > 1 && $conf->browser->layout !=
'phone' && empty($disablemove)) {
209 print
'<td class="linecolmove tdlineupdown center">';
212 print
'<a class="lineupdown" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$this->
id.
'&action=up&token='.newToken().
'&rowid='.$line->id.
'">';
213 echo
img_up(
'default', 0,
'imgupforline');
217 print
'<a class="lineupdown" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$this->
id.
'&action=down&token='.newToken().
'&rowid='.$line->id.
'">';
218 echo
img_down(
'default', 0,
'imgdownforline');
223 print
'<td '.(($conf->browser->layout !=
'phone' && empty($disablemove)) ?
' class="linecolmove tdlineupdown center"' :
' class="linecolmove center"').
'></td>';
227 print
'<td colspan="3"></td>';
228 $coldisplay = $coldisplay + 3;
231if ($action ==
'selectlines') {
232 print
'<td class="linecolcheck center">';
233 print
'<input type="checkbox" class="linecheckbox" name="line_checkbox['.($i + 1).
']" value="'.$line->id.
'" >';
241$sql =
'SELECT rowid, fk_bom_child, fk_product, qty FROM '.MAIN_DB_PREFIX.
'bom_bomline AS bl';
242$sql.=
' WHERE fk_bom ='. (int) $tmpbom->id;
243$resql = $object->db->query($sql);
247 while ($obj = $object->db->fetch_object($resql)) {
248 $sub_bom_product =
new Product($object->db);
249 $sub_bom_product->fetch($obj->fk_product);
251 $sub_bom =
new BOM($object->db);
252 if (!empty($obj->fk_bom_child)) {
253 $sub_bom->fetch($obj->fk_bom_child);
256 $sub_bom_line =
new BOMLine($object->db);
257 $sub_bom_line->fetch($obj->rowid);
260 if (empty($conf->global->BOM_SHOW_ALL_BOM_BY_DEFAULT)) {
261 print
'<tr style="display:none" class="sub_bom_lines" parentid="'.$line->id.
'">';
263 print
'<tr class="sub_bom_lines" parentid="'.$line->id.
'">';
267 print
'<td style="padding-left: 5%" id="sub_bom_product_'.$sub_bom_line->id.
'">';
268 if (!empty($obj->fk_bom_child)) {
269 print $sub_bom_product->getNomUrl(1);
270 print
' '.$langs->trans(
'or').
' ';
271 print $sub_bom->getNomUrl(1);
273 print $sub_bom_product->getNomUrl(1);
278 $label = $sub_bom_product->getLabelOfUnit(
'long');
279 if ($sub_bom_line->qty_frozen > 0) {
280 print
'<td class="linecolqty nowrap right" id="sub_bom_qty_'.$sub_bom_line->id.
'">'.
price($sub_bom_line->qty, 0,
'', 0, 0).
'</td>';
281 if (!empty($conf->global->PRODUCT_USE_UNITS)) {
282 print
'<td class="linecoluseunit nowrap left">';
283 if ($label !==
'') print $langs->trans($label);
286 print
'<td class="linecolqtyfrozen nowrap right" id="sub_bom_qty_frozen_'.$sub_bom_line->id.
'">'.$langs->trans(
'Yes').
'</td>';
288 print
'<td class="linecolqty nowrap right" id="sub_bom_qty_'.$sub_bom_line->id.
'">'.
price($sub_bom_line->qty * $line->qty, 0,
'', 0, 0).
'</td>';
289 if (!empty($conf->global->PRODUCT_USE_UNITS)) {
290 print
'<td class="linecoluseunit nowrap left">';
291 if ($label !==
'') print $langs->trans($label);
295 print
'<td class="linecolqtyfrozen nowrap right" id="sub_bom_qty_frozen_'.$sub_bom_line->id.
'"> </td>';
299 if ($sub_bom_line->disable_stock_change > 0) {
300 print
'<td class="linecoldisablestockchange nowrap right" id="sub_bom_stock_change_'.$sub_bom_line->id.
'">'.$sub_bom_line->disable_stock_change.
'</td>';
302 print
'<td class="linecoldisablestockchange nowrap right" id="sub_bom_stock_change_'.$sub_bom_line->id.
'"> </td>';
306 print
'<td class="linecolefficiency nowrap right" id="sub_bom_efficiency_'.$sub_bom_line->id.
'">'.$sub_bom_line->efficiency.
'</td>';
309 if (!empty($sub_bom->id)) {
310 $sub_bom->calculateCosts();
311 print
'<td class="linecolcost nowrap right" id="sub_bom_cost_'.$sub_bom_line->id.
'"><span class="amount">'.
price(
price2num($sub_bom->total_cost * $sub_bom_line->qty * $line->qty,
'MT')).
'</span></td>';
312 $total_cost+= $sub_bom->total_cost * $sub_bom_line->qty * $line->qty;
313 } elseif ($sub_bom_product->type ==
Product::TYPE_SERVICE && isModEnabled(
'workstation') && !empty($sub_bom_product->fk_default_workstation)) {
318 $res = $workstation->fetch($sub_bom_product->fk_default_workstation);
319 if ($res > 0) $sub_bom_line->total_cost =
price2num($qty * ($workstation->thm_operator_estimated + $workstation->thm_machine_estimated),
'MT');
321 print
'<td class="linecolcost nowrap right" id="sub_bom_cost_'.$sub_bom_line->id.
'"><span class="amount">'.
price(
price2num($sub_bom_line->total_cost,
'MT')).
'</span></td>';
322 $this->total_cost += $line->total_cost;
323 } elseif ($sub_bom_product->cost_price > 0) {
324 print
'<td class="linecolcost nowrap right" id="sub_bom_cost_'.$sub_bom_line->id.
'">';
325 print
'<span class="amount">'.price(
price2num($sub_bom_product->cost_price * $sub_bom_line->qty * $line->qty,
'MT')).
'</span></td>';
326 $total_cost+= $sub_bom_product->cost_price * $sub_bom_line->qty * $line->qty;
327 } elseif ($sub_bom_product->pmp > 0) {
328 print
'<td class="linecolcost nowrap right" id="sub_bom_cost_'.$sub_bom_line->id.
'">';
329 print
'<span class="amount">'.price(
price2num($sub_bom_product->pmp * $sub_bom_line->qty * $line->qty,
'MT')).
'</span></td>';
330 $total_cost.= $sub_bom_product->pmp * $sub_bom_line->qty * $line->qty;
332 $sql_supplier_price =
'SELECT MIN(price) AS min_price, quantity AS qty FROM '.MAIN_DB_PREFIX.
'product_fournisseur_price';
333 $sql_supplier_price.=
' WHERE fk_product = '. (int) $sub_bom_product->id;
334 $resql_supplier_price = $object->db->query($sql_supplier_price);
335 if ($resql_supplier_price) {
336 $obj = $object->db->fetch_object($resql_supplier_price);
337 if (!empty($obj->qty) && !empty($sub_bom_line->qty) && !empty($line->qty)) {
338 $line_cost = $obj->min_price/$obj->qty * $sub_bom_line->qty * $line->qty;
340 $line_cost = $obj->min_price;
342 print
'<td class="linecolcost nowrap right" id="sub_bom_cost_'.$sub_bom_line->id.
'"><span class="amount">'.
price2num($line_cost,
'MT').
'</span></td>';
343 $total_cost+= $line_cost;
354print
"<!-- END PHP TEMPLATE objectline_view.tpl.php -->\n";
Class of dictionary type of thirdparty (used by imports)
Class to manage products or services.
const TYPE_SERVICE
Service.
convertDurationtoHour($duration_value, $duration_unit)
Convert duration to hour.
img_delete($titlealt='default', $other='class="pictodelete"', $morecss='')
Show delete logo.
yn($yesno, $case=1, $color=0)
Return yes or no in current language.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
img_down($titlealt='default', $selected=0, $moreclass='')
Show down arrow logo.
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
getDolGlobalInt($key, $default=0)
Return dolibarr global constant int value.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
img_edit($titlealt='default', $float=0, $other='')
Show logo editer/modifier fiche.
img_up($titlealt='default', $selected=0, $moreclass='')
Show top arrow logo.
measuringUnitString($unit, $measuring_style='', $scale='', $use_short_label=0, $outputlangs=null)
Return translation label of a unit key.