51@phan-var-force CommonObjectLine $line
52@phan-var-force int $num
54@phan-var-force CommonObject $this
55@phan-var-force CommonObject $object
58require_once DOL_DOCUMENT_ROOT.
'/workstation/class/workstation.class.php';
62 print
"Error, template page can't be called as URL";
68if (empty($filtertype)) {
73global $forceall, $senderissupplier, $inputalsopricewithtax, $outputalsopricetotalwithtax, $langs;
75if (empty($dateSelector)) {
78if (empty($forceall)) {
81if (empty($senderissupplier)) {
82 $senderissupplier = 0;
84if (empty($inputalsopricewithtax)) {
85 $inputalsopricewithtax = 0;
87if (empty($outputalsopricetotalwithtax)) {
88 $outputalsopricetotalwithtax = 0;
92if ($filtertype == 1) {
93 $domData =
' data-element="'.$line->element.
'service"';
95 $domData =
' data-element="'.$line->element.
'"';
98$domData .=
' data-id="'.$line->id.
'"';
99$domData .=
' data-qty="'.$line->qty.
'"';
100$domData .=
' data-product_type="'.$line->product_type.
'"';
106print
"<!-- BEGIN PHP TEMPLATE bom/tpl/objectline_view.tpl.php -->\n";
107print
'<tr id="row-'.$line->id.
'" class="drag drop oddeven" '.$domData.
' >';
111 print
'<td class="linecolnum center">'.($i + 1).
'</td>';
116print
'<td class="linecoldescription bomline minwidth300imp tdoverflowmax300">';
117print
'<div id="line_'.$line->id.
'"></div>';
120$tmpproduct->fetch($line->fk_product);
122$res = $tmpbom->fetch($line->fk_bom_child);
123if ($tmpbom->id > 0) {
124 print $tmpproduct->getNomUrl(1);
125 print
' '.$langs->trans(
"or").
' ';
126 print $tmpbom->getNomUrl(1);
127 print
' <a class="collapse_bom" id="collapse-'.$line->id.
'" href="#">';
131 print $tmpproduct->getNomUrl(1);
132 print
' - '.$tmpproduct->label;
136if (!empty($extrafields)) {
137 $temps = $line->showOptionals($extrafields,
'view', array(),
'',
'', 1,
'line');
138 if (!empty($temps)) {
139 print
'<div style="padding-top: 10px" id="extrafield_lines_area_'.$line->id.
'" name="extrafield_lines_area_'.$line->id.
'">';
148print
'<td class="linecolqty nowrap right">';
150echo
price($line->qty, 0,
'', 0, 0);
153if ($filtertype != 1) {
155 print
'<td class="linecoluseunit nowrap">';
158 print $langs->trans($label);
164 print
'<td class="linecolunit nowrap">';
167 if (!empty($line->fk_unit)) {
168 require_once DOL_DOCUMENT_ROOT.
'/core/class/cunits.class.php';
169 $unit =
new CUnits($this->db);
170 $unit->fetch($line->fk_unit);
171 print(isset($unit->label) ?
" ".$langs->trans(ucwords($unit->label)).
" " :
'');
178 print
'<td class="linecolqtyfrozen nowrap right">';
180 echo $line->qty_frozen ?
yn($line->qty_frozen) :
'';
184 print
'<td class="linecoldisablestockchange nowrap right">';
186 echo $line->disable_stock_change ?
yn($line->disable_stock_change) :
'';
190 print
'<td class="linecolefficiency nowrap right">';
192 echo $line->efficiency;
197if ($filtertype == 1 && isModEnabled(
'workstation')) {
199 $res = $workstation->fetch($line->fk_default_workstation);
201 print
'<td class="linecolworkstation nowrap">';
205 $fk_defaultUnit = $unit->getUnitFromCode(
'h',
'short_label',
'time');
206 $nbPlannedHour = $unit->unitConverter($line->qty, $line->fk_unit, $fk_defaultUnit);
207 $line->total_cost = 0;
208 if ($workstation->thm_machine_estimated) {
209 $line->total_cost += $nbPlannedHour * $workstation->thm_machine_estimated;
211 if ($workstation->thm_operator_estimated) {
212 $line->total_cost += $nbPlannedHour * $workstation->thm_operator_estimated;
214 echo $workstation->getNomUrl(1);
222$tmpbom->calculateCosts();
223print
'<td id="costline_'.$line->id.
'" class="linecolcost nowrap right">';
225if (!empty($line->fk_bom_child)) {
226 echo
'<span class="amount">'.price($tmpbom->total_cost * (
float) $line->qty).
'</span>';
228 echo
'<span class="amount">'.price($line->total_cost).
'</span>';
232if ($this->
status == 0 && $user->hasRight(
'bom',
'write') && $action !=
'selectlines') {
233 print
'<td class="linecoledit center">';
235 if (($line->info_bits & 2) == 2 || !empty($disableedit)) {
237 print
'<a class="editfielda reposition" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$this->
id.
'&action=editline&token='.
newToken().
'&lineid='.$line->id.
'">'.
img_edit().
'</a>';
241 print
'<td class="linecoldelete center">';
243 if (($line->fk_prev_id ==
null) && empty($disableremove)) {
245 print
'<a class="reposition" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$this->
id.
'&action=deleteline&token='.
newToken().
'&lineid='.$line->id.
'">';
251 if ($num > 1 &&
$conf->browser->layout !=
'phone' && empty($disablemove)) {
252 print
'<td class="linecolmove tdlineupdown center">';
255 print
'<a class="lineupdown" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$this->
id.
'&action=up&token='.
newToken().
'&rowid='.$line->id.
'">';
256 echo
img_up(
'default', 0,
'imgupforline');
260 print
'<a class="lineupdown" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$this->
id.
'&action=down&token='.
newToken().
'&rowid='.$line->id.
'">';
261 echo
img_down(
'default', 0,
'imgdownforline');
266 print
'<td '.(($conf->browser->layout !=
'phone' && empty($disablemove)) ?
' class="linecolmove tdlineupdown center"' :
' class="linecolmove center"').
'></td>';
270 print
'<td colspan="3"></td>';
274if ($action ==
'selectlines') {
275 print
'<td class="linecolcheck center">';
276 print
'<input type="checkbox" class="linecheckbox" name="line_checkbox['.($i + 1).
']" value="'.$line->id.
'" >';
284$sql =
'SELECT rowid, fk_bom_child, fk_product, qty FROM '.MAIN_DB_PREFIX.
'bom_bomline AS bl';
285$sql .=
' WHERE fk_bom ='. (int) $tmpbom->id;
286$resql =
$object->db->query($sql);
290 while ($obj =
$object->db->fetch_object($resql)) {
292 $sub_bom_product->fetch($obj->fk_product);
295 if (!empty($obj->fk_bom_child)) {
296 $sub_bom->fetch($obj->fk_bom_child);
300 $sub_bom_line->fetch($obj->rowid);
304 print
'<tr style="display:none" class="sub_bom_lines" parentid="'.$line->id.
'">';
306 print
'<tr class="sub_bom_lines" parentid="'.$line->id.
'">';
310 print
'<td style="padding-left: 5%" id="sub_bom_product_'.$sub_bom_line->id.
'">';
311 if (!empty($obj->fk_bom_child)) {
312 print $sub_bom_product->getNomUrl(1);
313 print
' '.$langs->trans(
'or').
' ';
314 print $sub_bom->getNomUrl(1);
316 print $sub_bom_product->getNomUrl(1);
321 $label = $sub_bom_product->getLabelOfUnit(
'long');
322 if ($sub_bom_line->qty_frozen > 0) {
323 print
'<td class="linecolqty nowrap right" id="sub_bom_qty_'.$sub_bom_line->id.
'">'.
price($sub_bom_line->qty, 0,
'', 0, 0).
'</td>';
325 print
'<td class="linecoluseunit nowrap left">';
327 print $langs->trans($label);
331 print
'<td class="linecolqtyfrozen nowrap right" id="sub_bom_qty_frozen_'.$sub_bom_line->id.
'">'.$langs->trans(
'Yes').
'</td>';
333 print
'<td class="linecolqty nowrap right" id="sub_bom_qty_'.$sub_bom_line->id.
'">'.
price($sub_bom_line->qty * (
float) $line->qty, 0,
'', 0, 0).
'</td>';
335 print
'<td class="linecoluseunit nowrap left">';
337 print $langs->trans($label);
342 print
'<td class="linecolqtyfrozen nowrap right" id="sub_bom_qty_frozen_'.$sub_bom_line->id.
'"> </td>';
346 if ($sub_bom_line->disable_stock_change > 0) {
347 print
'<td class="linecoldisablestockchange nowrap right" id="sub_bom_stock_change_'.$sub_bom_line->id.
'">'.$sub_bom_line->disable_stock_change.
'</td>';
349 print
'<td class="linecoldisablestockchange nowrap right" id="sub_bom_stock_change_'.$sub_bom_line->id.
'"> </td>';
353 print
'<td class="linecolefficiency nowrap right" id="sub_bom_efficiency_'.$sub_bom_line->id.
'">'.$sub_bom_line->efficiency.
'</td>';
356 if (!empty($sub_bom->id)) {
357 $sub_bom->calculateCosts();
358 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 * (
float) $line->qty,
'MT')).
'</span></td>';
359 $total_cost += $sub_bom->total_cost * $sub_bom_line->qty * (float) $line->qty;
360 } elseif ($sub_bom_product->type ==
Product::TYPE_SERVICE && isModEnabled(
'workstation') && !empty($sub_bom_product->fk_default_workstation)) {
365 $res = $workstation->fetch($sub_bom_product->fk_default_workstation);
367 $sub_bom_line->total_cost = (float)
price2num($qty * ($workstation->thm_operator_estimated + $workstation->thm_machine_estimated),
'MT');
370 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>';
371 $this->total_cost += $line->total_cost;
372 } elseif ($sub_bom_product->cost_price > 0) {
373 print
'<td class="linecolcost nowrap right" id="sub_bom_cost_'.$sub_bom_line->id.
'">';
374 print
'<span class="amount">'.price(
price2num($sub_bom_product->cost_price * $sub_bom_line->qty * (
float) $line->qty,
'MT')).
'</span></td>';
375 $total_cost += $sub_bom_product->cost_price * $sub_bom_line->qty * (float) $line->qty;
376 } elseif ($sub_bom_product->pmp > 0) {
377 print
'<td class="linecolcost nowrap right" id="sub_bom_cost_'.$sub_bom_line->id.
'">';
378 print
'<span class="amount">'.price(
price2num($sub_bom_product->pmp * $sub_bom_line->qty * (
float) $line->qty,
'MT')).
'</span></td>';
379 $total_cost .= $sub_bom_product->pmp * $sub_bom_line->qty * (float) $line->qty;
381 $sql_supplier_price =
"SELECT MIN(price) AS min_price, quantity AS qty FROM ".MAIN_DB_PREFIX.
"product_fournisseur_price";
382 $sql_supplier_price .=
" WHERE fk_product = ". (int) $sub_bom_product->id;
383 $sql_supplier_price .=
" GROUP BY quantity ORDER BY quantity ASC";
384 $resql_supplier_price =
$object->db->query($sql_supplier_price);
385 if ($resql_supplier_price) {
386 $obj =
$object->db->fetch_object($resql_supplier_price);
387 if (!empty($obj->qty) && !empty($sub_bom_line->qty) && !empty($line->qty)) {
388 $line_cost = $obj->min_price / $obj->qty * $sub_bom_line->qty * (float) $line->qty;
390 $line_cost = $obj->min_price;
392 print
'<td class="linecolcost nowrap right" id="sub_bom_cost_'.$sub_bom_line->id.
'"><span class="amount">'.
price2num($line_cost,
'MT').
'</span></td>';
393 $total_cost += $line_cost;
404print
"<!-- END PHP TEMPLATE objectline_view.tpl.php -->\n";
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Class of dictionary type of thirdparty (used by imports)
Class to manage products or services.
const TYPE_SERVICE
Service.
print $langs trans("Ref").' m titre as m m statut as status
Or an array listing all the potential status of the object: array: int of the status => translated la...
convertDurationtoHour($duration_value, $duration_unit)
Convert duration to hour.
img_delete($titlealt='default', $other='class="pictodelete"', $morecss='')
Show delete logo.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
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.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
yn($yesno, $format=1, $color=0)
Return yes or no in current language.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
img_edit($titlealt='default', $float=0, $other='')
Show logo edit/modify fiche.
img_up($titlealt='default', $selected=0, $moreclass='')
Show top arrow logo.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
measuringUnitString($unitid, $measuring_style='', $unitscale='', $use_short_label=0, $outputlangs=null)
Return translation label of a unit key.