37 require_once DOL_DOCUMENT_ROOT.
'/workstation/class/workstation.class.php';
40 if (empty($object) || !is_object($object)) {
41 print
"Error, template page can't be called as URL";
46 if (empty($filtertype)) $filtertype = 0;
49 global $forceall, $senderissupplier, $inputalsopricewithtax, $outputalsopricetotalwithtax, $langs;
51 if (empty($dateSelector)) {
54 if (empty($forceall)) {
57 if (empty($senderissupplier)) {
58 $senderissupplier = 0;
60 if (empty($inputalsopricewithtax)) {
61 $inputalsopricewithtax = 0;
63 if (empty($outputalsopricetotalwithtax)) {
64 $outputalsopricetotalwithtax = 0;
68 if ($filtertype == 1) $domData =
' data-element="'.$line->element.
'service"';
69 else $domData =
' data-element="'.$line->element.
'"';
71 $domData .=
' data-id="'.$line->id.
'"';
72 $domData .=
' data-qty="'.$line->qty.
'"';
73 $domData .=
' data-product_type="'.$line->product_type.
'"';
76 $objectline =
new BOMLine($object->db);
79 print
"<!-- BEGIN PHP TEMPLATE objectline_view.tpl.php -->\n";
80 print
'<tr id="row-'.$line->id.
'" class="drag drop oddeven" '.$domData.
' >';
81 if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER)) {
82 print
'<td class="linecolnum center">'.($i + 1).
'</td>';
85 print
'<td class="linecoldescription minwidth300imp">';
86 print
'<div id="line_'.$line->id.
'"></div>';
88 $tmpproduct =
new Product($object->db);
89 $tmpproduct->fetch($line->fk_product);
90 $tmpbom =
new BOM($object->db);
91 $res = $tmpbom->fetch($line->fk_bom_child);
92 if ($tmpbom->id > 0) {
93 print $tmpproduct->getNomUrl(1);
94 print
' '.$langs->trans(
"or").
' ';
95 print $tmpbom->getNomUrl(1);
96 print
' <a class="collapse_bom" id="collapse-'.$line->id.
'" href="#">';
97 print (empty($conf->global->BOM_SHOW_ALL_BOM_BY_DEFAULT) ?
img_picto(
'',
'folder') :
img_picto(
'',
'folder-open'));
100 print $tmpproduct->getNomUrl(1);
101 print
' - '.$tmpproduct->label;
105 if (!empty($extrafields)) {
106 $temps = $line->showOptionals($extrafields,
'view', array(),
'',
'', 1,
'line');
107 if (!empty($temps)) {
108 print
'<div style="padding-top: 10px" id="extrafield_lines_area_'.$line->id.
'" name="extrafield_lines_area_'.$line->id.
'">';
116 print
'<td class="linecolqty nowrap right">';
118 echo
price($line->qty, 0,
'', 0, 0);
121 if ($filtertype != 1) {
123 print
'<td class="linecoluseunit nowrap left">';
124 $label = $tmpproduct->getLabelOfUnit(
'long');
126 print $langs->trans($label);
131 print
'<td class="linecolqtyfrozen nowrap right">';
133 echo $line->qty_frozen ?
yn($line->qty_frozen) :
'';
135 print
'<td class="linecoldisablestockchange nowrap right">';
137 echo $line->disable_stock_change ?
yn($line->disable_stock_change) :
'';
140 print
'<td class="linecolefficiency nowrap right">';
142 echo $line->efficiency;
146 print
'<td class="linecolunit nowrap right">';
149 if (!empty($line->fk_unit)) {
150 require_once DOL_DOCUMENT_ROOT.
'/core/class/cunits.class.php';
152 $unit->fetch($line->fk_unit);
153 print (isset($unit->label) ?
" ".$langs->trans(ucwords($unit->label)).
" " :
'');
161 $res = $workstation->fetch($tmpproduct->fk_default_workstation);
163 print
'<td class="linecolunit nowrap right">';
165 if ($res > 0) echo $workstation->getNomUrl();
170 print
'<td id="costline_'.$line->id.
'" class="linecolcost nowrap right">';
172 echo
'<span class="amount">'.price($line->total_cost).
'</span>';
175 if ($this->status == 0 && ($object_rights->write) && $action !=
'selectlines') {
176 print
'<td class="linecoledit center">';
178 if (($line->info_bits & 2) == 2 || !empty($disableedit)) {
180 print
'<a class="editfielda reposition" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$this->
id.
'&action=editline&token='.
newToken().
'&lineid='.$line->id.
'">'.
img_edit().
'</a>';
184 print
'<td class="linecoldelete center">';
186 if (($line->fk_prev_id ==
null) && empty($disableremove)) {
188 print
'<a class="reposition" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$this->
id.
'&action=deleteline&token='.
newToken().
'&lineid='.$line->id.
'">';
194 if ($num > 1 && $conf->browser->layout !=
'phone' && empty($disablemove)) {
195 print
'<td class="linecolmove tdlineupdown center">';
198 print
'<a class="lineupdown" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$this->
id.
'&action=up&token='.
newToken().
'&rowid='.$line->id.
'">';
199 echo
img_up(
'default', 0,
'imgupforline');
203 print
'<a class="lineupdown" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$this->
id.
'&action=down&token='.
newToken().
'&rowid='.$line->id.
'">';
204 echo
img_down(
'default', 0,
'imgdownforline');
209 print
'<td '.(($conf->browser->layout !=
'phone' && empty($disablemove)) ?
' class="linecolmove tdlineupdown center"' :
' class="linecolmove center"').
'></td>';
213 print
'<td colspan="3"></td>';
214 $coldisplay = $coldisplay + 3;
217 if ($action ==
'selectlines') {
218 print
'<td class="linecolcheck center">';
219 print
'<input type="checkbox" class="linecheckbox" name="line_checkbox['.($i + 1).
']" value="'.$line->id.
'" >';
227 $sql =
'SELECT rowid, fk_bom_child, fk_product, qty FROM '.MAIN_DB_PREFIX.
'bom_bomline AS bl';
228 $sql.=
' WHERE fk_bom ='. (int) $tmpbom->id;
229 $resql = $object->db->query($sql);
233 while ($obj = $object->db->fetch_object(
$resql)) {
234 $sub_bom_product =
new Product($object->db);
235 $sub_bom_product->fetch($obj->fk_product);
237 $sub_bom =
new BOM($object->db);
238 if (!empty($obj->fk_bom_child)) {
239 $sub_bom->fetch($obj->fk_bom_child);
242 $sub_bom_line =
new BOMLine($object->db);
243 $sub_bom_line->fetch($obj->rowid);
246 if (empty($conf->global->BOM_SHOW_ALL_BOM_BY_DEFAULT)) {
247 print
'<tr style="display:none" class="sub_bom_lines" parentid="'.$line->id.
'">';
249 print
'<tr class="sub_bom_lines" parentid="'.$line->id.
'">';
253 print
'<td style="padding-left: 5%" id="sub_bom_product_'.$sub_bom_line->id.
'">';
254 if (!empty($obj->fk_bom_child)) {
255 print $sub_bom_product->getNomUrl(1);
256 print
' '.$langs->trans(
'or').
' ';
257 print $sub_bom->getNomUrl(1);
259 print $sub_bom_product->getNomUrl(1);
264 if ($sub_bom_line->qty_frozen > 0) {
265 print
'<td class="linecolqty nowrap right" id="sub_bom_qty_'.$sub_bom_line->id.
'">'.
price($sub_bom_line->qty, 0,
'', 0, 0).
'</td>';
266 print
'<td class="linecolqtyfrozen nowrap right" id="sub_bom_qty_frozen_'.$sub_bom_line->id.
'">'.$langs->trans(
'Yes').
'</td>';
268 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>';
269 print
'<td class="linecolqtyfrozen nowrap right" id="sub_bom_qty_frozen_'.$sub_bom_line->id.
'"> </td>';
273 if ($sub_bom_line->disable_stock_change > 0) {
274 print
'<td class="linecoldisablestockchange nowrap right" id="sub_bom_stock_change_'.$sub_bom_line->id.
'">'.$sub_bom_line->disable_stock_change.
'</td>';
276 print
'<td class="linecoldisablestockchange nowrap right" id="sub_bom_stock_change_'.$sub_bom_line->id.
'"> </td>';
280 print
'<td class="linecolefficiency nowrap right" id="sub_bom_efficiency_'.$sub_bom_line->id.
'">'.$sub_bom_line->efficiency.
'</td>';
283 if (!empty($sub_bom->id)) {
284 $sub_bom->calculateCosts();
285 print
'<td class="linecolcost nowrap right" id="sub_bom_cost_'.$sub_bom_line->id.
'"><span class="amount">'.
price($sub_bom->total_cost * $sub_bom_line->qty * $line->qty).
'</span></td>';
286 $total_cost+= $sub_bom->total_cost * $sub_bom_line->qty * $line->qty;
287 } elseif ($sub_bom_product->cost_price > 0) {
288 print
'<td class="linecolcost nowrap right" id="sub_bom_cost_'.$sub_bom_line->id.
'"><span class="amount">'.
price($sub_bom_product->cost_price * $sub_bom_line->qty * $line->qty).
'</span></td>';
289 $total_cost+= $sub_bom_product->cost_price * $sub_bom_line->qty * $line->qty;
290 } elseif ($sub_bom_product->pmp > 0) {
291 print
'<td class="linecolcost nowrap right" id="sub_bom_cost_'.$sub_bom_line->id.
'"><span class="amount">'.
price($sub_bom_product->pmp * $sub_bom_line->qty * $line->qty).
'</span></td>';
292 $total_cost.= $sub_bom_product->pmp * $sub_bom_line->qty * $line->qty;
294 $sql_supplier_price =
'SELECT MIN(price) AS min_price, quantity AS qty FROM '.MAIN_DB_PREFIX.
'product_fournisseur_price';
295 $sql_supplier_price.=
' WHERE fk_product = '. (int) $sub_bom_product->id;
296 $resql_supplier_price = $object->db->query($sql_supplier_price);
297 if ($resql_supplier_price) {
298 $obj = $object->db->fetch_object($resql_supplier_price);
299 $line_cost = $obj->min_price/$obj->qty * $sub_bom_line->qty * $line->qty;
301 print
'<td class="linecolcost nowrap right" id="sub_bom_cost_'.$sub_bom_line->id.
'"><span class="amount">'.
price($line_cost).
'</span></td>';
302 $total_cost+= $line_cost;
314 if ($total_cost > 0) {
315 $line->total_cost =
price($total_cost);
318 $(
'#costline_<?php echo $line->id?>').html(
'<?php echo "<span class=\"amount\">".price($total_cost)."</span>"; ?>');
323 print
"<!-- END PHP TEMPLATE objectline_view.tpl.php -->\n";
Class of dictionary type of thirdparty (used by imports)
Class to manage products or services.
if(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') &&!empty($user->rights->don->lire)) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
img_delete($titlealt='default', $other='class="pictodelete"', $morecss='')
Show delete logo.
yn($yesno, $case=1, $color=0)
Return yes or no in current language.
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)
newToken()
Return the value of token currently saved into session with name 'newtoken'.
isModEnabled($module)
Is Dolibarr module enabled.
img_edit($titlealt='default', $float=0, $other='')
Show logo editer/modifier fiche.
img_up($titlealt='default', $selected=0, $moreclass='')
Show top arrow logo.
$conf db
API class for accounts.