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)) {
53global $forceall, $senderissupplier, $inputalsopricewithtax, $outputalsopricetotalwithtax, $langs;
55if (empty($dateSelector)) {
58if (empty($forceall)) {
61if (empty($senderissupplier)) {
62 $senderissupplier = 0;
64if (empty($inputalsopricewithtax)) {
65 $inputalsopricewithtax = 0;
67if (empty($outputalsopricetotalwithtax)) {
68 $outputalsopricetotalwithtax = 0;
72if ($filtertype == 1) {
73 $domData =
' data-element="'.$line->element.
'service"';
75 $domData =
' data-element="'.$line->element.
'"';
78$domData .=
' data-id="'.$line->id.
'"';
79$domData .=
' data-qty="'.$line->qty.
'"';
80$domData .=
' data-product_type="'.$line->product_type.
'"';
83$objectline =
new BOMLine($object->db);
86print
"<!-- BEGIN PHP TEMPLATE objectline_view.tpl.php -->\n";
87print
'<tr id="row-'.$line->id.
'" class="drag drop oddeven" '.$domData.
' >';
91 print
'<td class="linecolnum center">'.($i + 1).
'</td>';
96print
'<td class="linecoldescription minwidth300imp">';
97print
'<div id="line_'.$line->id.
'"></div>';
99$tmpproduct =
new Product($object->db);
100$tmpproduct->fetch($line->fk_product);
101$tmpbom =
new BOM($object->db);
102$res = $tmpbom->fetch($line->fk_bom_child);
103if ($tmpbom->id > 0) {
104 print $tmpproduct->getNomUrl(1);
105 print
' '.$langs->trans(
"or").
' ';
106 print $tmpbom->getNomUrl(1);
107 print
' <a class="collapse_bom" id="collapse-'.$line->id.
'" href="#">';
111 print $tmpproduct->getNomUrl(1);
112 print
' - '.$tmpproduct->label;
116if (!empty($extrafields)) {
117 $temps = $line->showOptionals($extrafields,
'view', array(),
'',
'', 1,
'line');
118 if (!empty($temps)) {
119 print
'<div style="padding-top: 10px" id="extrafield_lines_area_'.$line->id.
'" name="extrafield_lines_area_'.$line->id.
'">';
128print
'<td class="linecolqty nowrap right">';
130echo
price($line->qty, 0,
'', 0, 0);
133if ($filtertype != 1) {
135 print
'<td class="linecoluseunit nowrap left">';
138 print $langs->trans($label);
143 print
'<td class="linecolqtyfrozen nowrap right">';
145 echo $line->qty_frozen ?
yn($line->qty_frozen) :
'';
147 print
'<td class="linecoldisablestockchange nowrap right">';
149 echo $line->disable_stock_change ?
yn($line->disable_stock_change) :
'';
152 print
'<td class="linecolefficiency nowrap right">';
154 echo $line->efficiency;
158 print
'<td class="linecolunit nowrap right">';
161 if (!empty($line->fk_unit)) {
162 require_once DOL_DOCUMENT_ROOT.
'/core/class/cunits.class.php';
163 $unit =
new CUnits($this->db);
164 $unit->fetch($line->fk_unit);
165 print(isset($unit->label) ?
" ".$langs->trans(ucwords($unit->label)).
" " :
'');
171 if (isModEnabled(
'workstation')) {
173 $res = $workstation->fetch($line->fk_default_workstation);
175 print
'<td class="linecolworkstation nowrap right">';
178 echo $workstation->getNomUrl(1);
186$tmpbom->calculateCosts();
187print
'<td id="costline_'.$line->id.
'" class="linecolcost nowrap right">';
189if (!empty($line->fk_bom_child)) {
190 echo
'<span class="amount">'.price($tmpbom->total_cost * $line->qty).
'</span>';
192 echo
'<span class="amount">'.price($line->total_cost).
'</span>';
196if ($this->
status == 0 && ($object_rights->write) && $action !=
'selectlines') {
197 print
'<td class="linecoledit center">';
199 if (($line->info_bits & 2) == 2 || !empty($disableedit)) {
201 print
'<a class="editfielda reposition" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$this->
id.
'&action=editline&token='.newToken().
'&lineid='.$line->id.
'">'.
img_edit().
'</a>';
205 print
'<td class="linecoldelete center">';
207 if (($line->fk_prev_id ==
null) && empty($disableremove)) {
209 print
'<a class="reposition" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$this->
id.
'&action=deleteline&token='.newToken().
'&lineid='.$line->id.
'">';
215 if ($num > 1 && $conf->browser->layout !=
'phone' && empty($disablemove)) {
216 print
'<td class="linecolmove tdlineupdown center">';
219 print
'<a class="lineupdown" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$this->
id.
'&action=up&token='.newToken().
'&rowid='.$line->id.
'">';
220 echo
img_up(
'default', 0,
'imgupforline');
224 print
'<a class="lineupdown" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$this->
id.
'&action=down&token='.newToken().
'&rowid='.$line->id.
'">';
225 echo
img_down(
'default', 0,
'imgdownforline');
230 print
'<td '.(($conf->browser->layout !=
'phone' && empty($disablemove)) ?
' class="linecolmove tdlineupdown center"' :
' class="linecolmove center"').
'></td>';
234 print
'<td colspan="3"></td>';
235 $coldisplay = $coldisplay + 3;
238if ($action ==
'selectlines') {
239 print
'<td class="linecolcheck center">';
240 print
'<input type="checkbox" class="linecheckbox" name="line_checkbox['.($i + 1).
']" value="'.$line->id.
'" >';
248$sql =
'SELECT rowid, fk_bom_child, fk_product, qty FROM '.MAIN_DB_PREFIX.
'bom_bomline AS bl';
249$sql.=
' WHERE fk_bom ='. (int) $tmpbom->id;
250$resql = $object->db->query($sql);
254 while ($obj = $object->db->fetch_object($resql)) {
255 $sub_bom_product =
new Product($object->db);
256 $sub_bom_product->fetch($obj->fk_product);
258 $sub_bom =
new BOM($object->db);
259 if (!empty($obj->fk_bom_child)) {
260 $sub_bom->fetch($obj->fk_bom_child);
263 $sub_bom_line =
new BOMLine($object->db);
264 $sub_bom_line->fetch($obj->rowid);
268 print
'<tr style="display:none" class="sub_bom_lines" parentid="'.$line->id.
'">';
270 print
'<tr class="sub_bom_lines" parentid="'.$line->id.
'">';
274 print
'<td style="padding-left: 5%" id="sub_bom_product_'.$sub_bom_line->id.
'">';
275 if (!empty($obj->fk_bom_child)) {
276 print $sub_bom_product->getNomUrl(1);
277 print
' '.$langs->trans(
'or').
' ';
278 print $sub_bom->getNomUrl(1);
280 print $sub_bom_product->getNomUrl(1);
285 $label = $sub_bom_product->getLabelOfUnit(
'long');
286 if ($sub_bom_line->qty_frozen > 0) {
287 print
'<td class="linecolqty nowrap right" id="sub_bom_qty_'.$sub_bom_line->id.
'">'.
price($sub_bom_line->qty, 0,
'', 0, 0).
'</td>';
289 print
'<td class="linecoluseunit nowrap left">';
291 print $langs->trans($label);
295 print
'<td class="linecolqtyfrozen nowrap right" id="sub_bom_qty_frozen_'.$sub_bom_line->id.
'">'.$langs->trans(
'Yes').
'</td>';
297 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>';
299 print
'<td class="linecoluseunit nowrap left">';
301 print $langs->trans($label);
306 print
'<td class="linecolqtyfrozen nowrap right" id="sub_bom_qty_frozen_'.$sub_bom_line->id.
'"> </td>';
310 if ($sub_bom_line->disable_stock_change > 0) {
311 print
'<td class="linecoldisablestockchange nowrap right" id="sub_bom_stock_change_'.$sub_bom_line->id.
'">'.$sub_bom_line->disable_stock_change.
'</td>';
313 print
'<td class="linecoldisablestockchange nowrap right" id="sub_bom_stock_change_'.$sub_bom_line->id.
'"> </td>';
317 print
'<td class="linecolefficiency nowrap right" id="sub_bom_efficiency_'.$sub_bom_line->id.
'">'.$sub_bom_line->efficiency.
'</td>';
320 if (!empty($sub_bom->id)) {
321 $sub_bom->calculateCosts();
322 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>';
323 $total_cost+= $sub_bom->total_cost * $sub_bom_line->qty * $line->qty;
324 } elseif ($sub_bom_product->type ==
Product::TYPE_SERVICE && isModEnabled(
'workstation') && !empty($sub_bom_product->fk_default_workstation)) {
329 $res = $workstation->fetch($sub_bom_product->fk_default_workstation);
331 $sub_bom_line->total_cost =
price2num($qty * ($workstation->thm_operator_estimated + $workstation->thm_machine_estimated),
'MT');
334 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>';
335 $this->total_cost += $line->total_cost;
336 } elseif ($sub_bom_product->cost_price > 0) {
337 print
'<td class="linecolcost nowrap right" id="sub_bom_cost_'.$sub_bom_line->id.
'">';
338 print
'<span class="amount">'.price(
price2num($sub_bom_product->cost_price * $sub_bom_line->qty * $line->qty,
'MT')).
'</span></td>';
339 $total_cost+= $sub_bom_product->cost_price * $sub_bom_line->qty * $line->qty;
340 } elseif ($sub_bom_product->pmp > 0) {
341 print
'<td class="linecolcost nowrap right" id="sub_bom_cost_'.$sub_bom_line->id.
'">';
342 print
'<span class="amount">'.price(
price2num($sub_bom_product->pmp * $sub_bom_line->qty * $line->qty,
'MT')).
'</span></td>';
343 $total_cost.= $sub_bom_product->pmp * $sub_bom_line->qty * $line->qty;
345 $sql_supplier_price =
'SELECT MIN(price) AS min_price, quantity AS qty FROM '.MAIN_DB_PREFIX.
'product_fournisseur_price';
346 $sql_supplier_price.=
' WHERE fk_product = '. (int) $sub_bom_product->id;
347 $resql_supplier_price = $object->db->query($sql_supplier_price);
348 if ($resql_supplier_price) {
349 $obj = $object->db->fetch_object($resql_supplier_price);
350 if (!empty($obj->qty) && !empty($sub_bom_line->qty) && !empty($line->qty)) {
351 $line_cost = $obj->min_price/$obj->qty * $sub_bom_line->qty * $line->qty;
353 $line_cost = $obj->min_price;
355 print
'<td class="linecolcost nowrap right" id="sub_bom_cost_'.$sub_bom_line->id.
'"><span class="amount">'.
price2num($line_cost,
'MT').
'</span></td>';
356 $total_cost+= $line_cost;
367print
"<!-- END PHP TEMPLATE objectline_view.tpl.php -->\n";
print $langs trans("AuditedSecurityEvents").'</strong >< span class="opacitymedium"></span >< br > status
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 a 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)
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
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.