dolibarr/htdocs/bom/tpl/objectline_view.tpl.php

405 lines
15 KiB
PHP
Raw Permalink Normal View History

2019-05-22 20:28:24 +02:00
<?php
/* Copyright (C) 2010-2013 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2010-2011 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2012-2013 Christophe Battarel <christophe.battarel@altairis.fr>
* Copyright (C) 2012 Cédric Salvador <csalvador@gpcsolutions.fr>
* Copyright (C) 2012-2014 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
* Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2017 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
add baseline exclude for phpstan (#31632) * add baseline exclude for phpstan * update * update * update * update * update * merge * restore one filter * delete old errors * fix * fix * fix * $moreforfilter can t be empty * fix * enable check * refresh baseline * add phpdoc * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix --------- Co-authored-by: Laurent Destailleur <eldy@destailleur.fr>
2024-11-04 23:53:20 +01:00
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
2019-05-22 20:28:24 +02:00
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
2019-09-23 21:55:30 +02:00
* along with this program. If not, see <https://www.gnu.org/licenses/>.
2019-05-22 20:28:24 +02:00
*
* Need to have the following variables defined:
2019-05-22 20:28:24 +02:00
* $object (invoice, order, ...)
* $conf
* $langs
* $forceall (0 by default, 1 for supplier invoices/orders)
Fix #28071 - New branch to fix bad merge (#28083) * Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop * Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop * Qual: Introduce getDataToShowPhoto to prepare generic code * Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop * Fix missing trans * Fix langs * Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop * Remove useless files in web templates * Clean code * Fix duplicate translation key * Fix duplicate translation key * Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop * Fix duplicate key * Fix $object * Debug v19 * WIP SMSing * Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop * WIP EMAILINGS_SUPPORT_ALSO_SMS * Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop * Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop * WIP SMSing * Debug the "validate" feature * Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop * Clean code * Move rights->x->y into hasRight('x', 'y') * Move rights->x->y into hasRight('x', 'y') * Move rights->x->y into hasRight('x', 'y') * Move rights->x->y into hasRight('x', 'y') * Move rights->x->y into hasRight('x', 'y') * Move rights->x->y into hasRight('x', 'y') * Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop * Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop * Enhance rector to fix empty($user->rights->modulex->perm1) * Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop * Fix template to use v19 dev rules * Fix use v19 dev rules * Fix phpunit * Debug v19 * Clean code * Use rector to convert user->rights into user->hasRight * Clean code * Use rector to convert user->rights into user->hasRight * Use rector to convert user->rights into user->hasRight * Clean code * Fix phpcs * add editorconfig for sql files (#27999) Co-authored-by: Laurent Destailleur <eldy@destailleur.fr> * add model_pdf field in llx_ticket-ticket.sql (#27996) * add model_pdf field in llx_ticket-ticket.sql * Update 19.0.0-20.0.0.sql * Update 19.0.0-20.0.0.sql * Improve wording in README (#27994) * fix phpstan (#27989) * fix phpstan * Update UserRightsToFunction.php --------- Co-authored-by: Laurent Destailleur <eldy@destailleur.fr> * Qual: Fix spelling/working in datapolicy translations (#28006) # Qual: Fix spelling/wording in datapolicy translations Fixed some spelling and wording in datapolicy translations. * qual: phpstan for htdocs/ticket/class/ticketstats.class.php (#27986) htdocs/ticket/class/ticketstats.class.php 98 Parameter #1 $year (string) of method TicketStats::getNbByMonth() should be compatible with parameter $year (int) of method Stats::getNbByMonth() * Merge branch '19.0' of git@github.com:Dolibarr/dolibarr.git into develop * Fix user with readonly perm on email template must be able to read. * Fix doc * Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop * Better message * Add missing fields in merge of thirdparty * Debug v19 selection of ticket printer per terminal * Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop * Use constant * NEW: Adding a recipient on emails sent, change status to sent partialy. * fix travis (#28052) * fix travis * Update partnership.class.php * fix php doc (#28047) * fix undefined array key (#28048) * Add region and departament for Cuba (#28046) * Update llx_10_c_regions.sql Add Cuba Regions (id_country=77) * Update llx_20_c_departements.sql Add Provinces Cuba (id country=77) * Find the typo (#28050) * Find the typo * clean code * add last_main_doc field to product (#28045) * add las_main_doc field to product * add field fetch * NEW Add Categorie filter for ActionComm (#28041) * New Add Categorie filter for ActionComm New Add Categorie filter for ActionComm * Fix space errors Fix space errors * Fix space errors 2 Fix space errors 2 * Update cunits.class.php (#28056) FIX: error SQL when creating a Cunit * Update codespell-lines-ignore.txt to avoid PR merge conflict --------- Co-authored-by: Laurent Destailleur <eldy@destailleur.fr> Co-authored-by: Frédéric FRANCE <frederic34@users.noreply.github.com> Co-authored-by: thibdrev <thibault.drevet@gmail.com> Co-authored-by: sonikf <93765174+sonikf@users.noreply.github.com> Co-authored-by: Ikarus <44511582+LeKarSol@users.noreply.github.com> Co-authored-by: Anthony Damhet <73399671+EchoLoGeek@users.noreply.github.com> Co-authored-by: Quentin-Seekness <72733832+Quentin-Seekness@users.noreply.github.com>
2024-02-09 15:58:49 +01:00
* $element (used to test $user->hasRight($element, 'creer'))
* $permtoedit (used to replace test $user->hasRight($element, 'creer'))
2019-05-22 20:28:24 +02:00
* $inputalsopricewithtax (0 by default, 1 to also show column with unit price including tax)
* $disableedit, $disablemove, $disableremove
*
* $type, $text, $description, $line
*/
/**
add baseline exclude for phpstan (#31632) * add baseline exclude for phpstan * update * update * update * update * update * merge * restore one filter * delete old errors * fix * fix * fix * $moreforfilter can t be empty * fix * enable check * refresh baseline * add phpdoc * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix --------- Co-authored-by: Laurent Destailleur <eldy@destailleur.fr>
2024-11-04 23:53:20 +01:00
* @var Conf $conf
2024-12-05 18:00:38 +01:00
* @var CommonObject $this
* @var CommonObject $object
* @var CommonObjectLine $line
add baseline exclude for phpstan (#31632) * add baseline exclude for phpstan * update * update * update * update * update * merge * restore one filter * delete old errors * fix * fix * fix * $moreforfilter can t be empty * fix * enable check * refresh baseline * add phpdoc * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix --------- Co-authored-by: Laurent Destailleur <eldy@destailleur.fr>
2024-11-04 23:53:20 +01:00
* @var Translate $langs
* @var User $user
*
* @var int $i
* @var int $num
2024-12-14 13:05:41 +01:00
* @var string $action
*/
'
@phan-var-force CommonObjectLine $line
@phan-var-force int $num
@phan-var-force int $i
@phan-var-force CommonObject $this
@phan-var-force CommonObject $object
';
2023-05-01 17:21:00 +02:00
2022-07-06 13:55:43 +02:00
require_once DOL_DOCUMENT_ROOT.'/workstation/class/workstation.class.php';
2019-05-22 20:28:24 +02:00
// Protection to avoid direct call of template
2021-02-23 17:51:46 +01:00
if (empty($object) || !is_object($object)) {
2019-05-22 20:28:24 +02:00
print "Error, template page can't be called as URL";
exit(1);
2019-05-22 20:28:24 +02:00
}
2022-07-06 13:55:43 +02:00
global $filtertype;
2023-12-04 12:01:45 +01:00
if (empty($filtertype)) {
$filtertype = 0;
}
2022-07-06 13:55:43 +02:00
2019-05-22 20:28:24 +02:00
global $forceall, $senderissupplier, $inputalsopricewithtax, $outputalsopricetotalwithtax, $langs;
2019-05-22 20:28:24 +02:00
2021-02-23 17:51:46 +01:00
if (empty($dateSelector)) {
$dateSelector = 0;
}
if (empty($forceall)) {
$forceall = 0;
}
if (empty($senderissupplier)) {
$senderissupplier = 0;
}
if (empty($inputalsopricewithtax)) {
$inputalsopricewithtax = 0;
}
if (empty($outputalsopricetotalwithtax)) {
$outputalsopricetotalwithtax = 0;
}
2019-05-22 20:28:24 +02:00
// add html5 elements
2023-12-04 12:01:45 +01:00
if ($filtertype == 1) {
$domData = ' data-element="'.$line->element.'service"';
} else {
$domData = ' data-element="'.$line->element.'"';
}
2022-09-08 11:40:40 +02:00
2019-05-22 20:28:24 +02:00
$domData .= ' data-id="'.$line->id.'"';
$domData .= ' data-qty="'.$line->qty.'"';
$domData .= ' data-product_type="'.$line->product_type.'"';
2019-06-03 19:29:49 +02:00
// Lines for extrafield
2019-06-03 22:07:34 +02:00
$objectline = new BOMLine($object->db);
2019-05-22 20:28:24 +02:00
$coldisplay = 0;
2024-07-17 16:23:24 +02:00
print "<!-- BEGIN PHP TEMPLATE bom/tpl/objectline_view.tpl.php -->\n";
2019-10-20 11:17:54 +02:00
print '<tr id="row-'.$line->id.'" class="drag drop oddeven" '.$domData.' >';
2023-04-27 14:02:59 +02:00
// Line nb
2023-11-27 11:39:32 +01:00
if (getDolGlobalString('MAIN_VIEW_LINE_NUMBER')) {
print '<td class="linecolnum center">'.($i + 1).'</td>';
2019-10-20 11:17:54 +02:00
$coldisplay++;
}
2023-04-27 14:02:59 +02:00
// Product
2024-07-17 16:23:24 +02:00
print '<td class="linecoldescription bomline minwidth300imp tdoverflowmax300">';
2019-10-20 11:17:54 +02:00
print '<div id="line_'.$line->id.'"></div>';
$coldisplay++;
$tmpproduct = new Product($object->db);
$tmpproduct->fetch($line->fk_product);
2021-08-20 13:37:28 +02:00
$tmpbom = new BOM($object->db);
2021-08-23 14:43:17 +02:00
$res = $tmpbom->fetch($line->fk_bom_child);
2021-10-28 15:05:50 +02:00
if ($tmpbom->id > 0) {
print $tmpproduct->getNomUrl(1);
2022-01-29 00:07:04 +01:00
print ' '.$langs->trans("or").' ';
2022-01-26 15:15:53 +01:00
print $tmpbom->getNomUrl(1);
2022-01-29 00:07:04 +01:00
print ' <a class="collapse_bom" id="collapse-'.$line->id.'" href="#">';
2023-12-04 12:01:45 +01:00
print(!getDolGlobalString('BOM_SHOW_ALL_BOM_BY_DEFAULT') ? img_picto('', 'folder') : img_picto('', 'folder-open'));
2022-01-29 00:07:04 +01:00
print '</a>';
2021-08-20 13:37:28 +02:00
} else {
2021-10-28 15:05:50 +02:00
print $tmpproduct->getNomUrl(1);
print ' - '.$tmpproduct->label;
2021-08-20 13:37:28 +02:00
}
2022-12-05 12:30:26 +01:00
// Line extrafield
if (!empty($extrafields)) {
$temps = $line->showOptionals($extrafields, 'view', array(), '', '', 1, 'line');
if (!empty($temps)) {
print '<div style="padding-top: 10px" id="extrafield_lines_area_'.$line->id.'" name="extrafield_lines_area_'.$line->id.'">';
print $temps;
print '</div>';
}
}
2021-10-28 15:05:50 +02:00
print '</td>';
2021-08-20 13:37:28 +02:00
2023-04-27 14:02:59 +02:00
// Qty
2019-10-20 11:17:54 +02:00
print '<td class="linecolqty nowrap right">';
$coldisplay++;
echo price($line->qty, 0, '', 0, 0); // Yes, it is a quantity, not a price, but we just want the formatting role of function price
2019-10-20 11:17:54 +02:00
print '</td>';
2019-05-22 20:28:24 +02:00
if ($filtertype != 1) { // Product
2024-06-23 22:10:12 +02:00
if (getDolGlobalInt('PRODUCT_USE_UNITS')) { // For product, unit is shown only if option PRODUCT_USE_UNITS is on
print '<td class="linecoluseunit nowrap">';
$label = measuringUnitString((int) $line->fk_unit, '', null, 1);
2022-07-06 13:55:43 +02:00
if ($label !== '') {
print $langs->trans($label);
}
print '</td>';
2019-05-22 20:28:24 +02:00
}
} else { // Service
2024-06-23 22:10:12 +02:00
// Unit // For services, units are always enabled
print '<td class="linecolunit nowrap">';
2022-07-06 13:55:43 +02:00
$coldisplay++;
if (!empty($line->fk_unit)) {
require_once DOL_DOCUMENT_ROOT.'/core/class/cunits.class.php';
$unit = new CUnits($this->db);
$unit->fetch($line->fk_unit);
2023-12-04 12:01:45 +01:00
print(isset($unit->label) ? "&nbsp;".$langs->trans(ucwords($unit->label))."&nbsp;" : '');
2022-07-06 15:00:07 +02:00
}
2022-07-06 13:55:43 +02:00
print '</td>';
}
if ($filtertype != 1 || getDolGlobalString('STOCK_SUPPORTS_SERVICES')) { // Product or stock support for Services is active
// Qty frozen
print '<td class="linecolqtyfrozen nowrap right">';
$coldisplay++;
echo $line->qty_frozen ? yn($line->qty_frozen) : '';
print '</td>';
// Disable stock change
print '<td class="linecoldisablestockchange nowrap right">';
$coldisplay++;
echo $line->disable_stock_change ? yn($line->disable_stock_change) : ''; // Yes, it is a quantity, not a price, but we just want the formatting role of function price
print '</td>';
2019-05-22 20:28:24 +02:00
// Efficiency
print '<td class="linecolefficiency nowrap right">';
$coldisplay++;
echo $line->efficiency;
print '</td>';
}
// Service and workstations are active
if ($filtertype == 1 && isModEnabled('workstation')) {
$workstation = new Workstation($object->db);
$res = $workstation->fetch($line->fk_default_workstation);
print '<td class="linecolworkstation nowrap">';
$coldisplay++;
if ($res > 0) {
$unit = new CUnits($object->db);
$fk_defaultUnit = $unit->getUnitFromCode('h', 'short_label', 'time');
$nbPlannedHour = $unit->unitConverter($line->qty, $line->fk_unit, $fk_defaultUnit);
$line->total_cost = 0;
if ($workstation->thm_machine_estimated) {
$line->total_cost += $nbPlannedHour * $workstation->thm_machine_estimated;
2023-12-04 12:01:45 +01:00
}
if ($workstation->thm_operator_estimated) {
$line->total_cost += $nbPlannedHour * $workstation->thm_operator_estimated;
}
echo $workstation->getNomUrl(1);
2022-07-06 13:55:43 +02:00
}
print '</td>';
2022-07-06 13:55:43 +02:00
}
2023-04-27 14:02:59 +02:00
// Cost
$total_cost = 0;
2023-01-17 17:22:32 +01:00
$tmpbom->calculateCosts();
print '<td id="costline_'.$line->id.'" class="linecolcost nowrap right">';
2020-03-24 10:32:31 +01:00
$coldisplay++;
2023-01-17 20:23:01 +01:00
if (!empty($line->fk_bom_child)) {
echo '<span class="amount">'.price($tmpbom->total_cost * (float) $line->qty).'</span>';
2023-01-17 17:22:32 +01:00
} else {
echo '<span class="amount">'.price($line->total_cost).'</span>';
}
2020-03-24 10:32:31 +01:00
print '</td>';
2024-08-27 06:20:04 +02:00
if ($this->status == 0 && $user->hasRight('bom', 'write') && $action != 'selectlines') {
2019-10-21 15:02:06 +02:00
print '<td class="linecoledit center">';
$coldisplay++;
if (($line->info_bits & 2) == 2 || !empty($disableedit)) {
} else {
2021-09-27 12:24:01 +02:00
print '<a class="editfielda reposition" href="'.$_SERVER["PHP_SELF"].'?id='.$this->id.'&action=editline&token='.newToken().'&lineid='.$line->id.'">'.img_edit().'</a>';
}
print '</td>';
print '<td class="linecoldelete center">';
$coldisplay++;
if (($line->fk_prev_id == null) && empty($disableremove)) {
//La suppression n'est autorisée que si il n'y a pas de ligne dans une précédente situation
print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?id='.$this->id.'&action=deleteline&token='.newToken().'&lineid='.$line->id.'">';
print img_delete();
print '</a>';
}
print '</td>';
2019-05-22 20:28:24 +02:00
2019-10-20 11:17:54 +02:00
if ($num > 1 && $conf->browser->layout != 'phone' && empty($disablemove)) {
print '<td class="linecolmove tdlineupdown center">';
$coldisplay++;
if ($i > 0) {
2022-03-24 14:04:03 +01:00
print '<a class="lineupdown" href="'.$_SERVER["PHP_SELF"].'?id='.$this->id.'&action=up&token='.newToken().'&rowid='.$line->id.'">';
2019-10-20 11:17:54 +02:00
echo img_up('default', 0, 'imgupforline');
print '</a>';
}
if ($i < $num - 1) {
2022-03-24 14:04:03 +01:00
print '<a class="lineupdown" href="'.$_SERVER["PHP_SELF"].'?id='.$this->id.'&action=down&token='.newToken().'&rowid='.$line->id.'">';
2019-10-20 11:17:54 +02:00
echo img_down('default', 0, 'imgdownforline');
print '</a>';
}
print '</td>';
} else {
print '<td '.(($conf->browser->layout != 'phone' && empty($disablemove)) ? ' class="linecolmove tdlineupdown center"' : ' class="linecolmove center"').'></td>';
2019-10-20 11:17:54 +02:00
$coldisplay++;
}
} else {
print '<td colspan="3"></td>';
Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests (#30544) * Remove PhanPluginDuplicateExpressionAssignmentOperation from baseline * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * fixup! Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests * Qual: Apply PhanPluginDuplicateExpressionAssignmentOperation as phan suggests --------- Co-authored-by: Laurent Destailleur <eldy@destailleur.fr>
2024-08-07 02:53:45 +02:00
$coldisplay += 3;
2019-10-20 11:17:54 +02:00
}
if ($action == 'selectlines') {
print '<td class="linecolcheck center">';
print '<input type="checkbox" class="linecheckbox" name="line_checkbox['.($i + 1).']" value="'.$line->id.'" >';
print '</td>';
2019-10-20 11:17:54 +02:00
}
print '</tr>';
2019-05-22 20:28:24 +02:00
2021-08-25 16:58:22 +02:00
// Select of all the sub-BOM lines
// From this point to the end of the file, we only take care of sub-BOM lines
$sql = 'SELECT rowid, fk_bom_child, fk_product, qty FROM '.MAIN_DB_PREFIX.'bom_bomline AS bl';
$sql .= ' WHERE fk_bom ='. (int) $tmpbom->id;
2021-08-20 13:37:28 +02:00
$resql = $object->db->query($sql);
2021-08-25 17:24:03 +02:00
if ($resql) {
2021-08-25 16:58:22 +02:00
// Loop on all the sub-BOM lines if they exist
2021-08-25 17:24:03 +02:00
while ($obj = $object->db->fetch_object($resql)) {
2021-08-20 13:37:28 +02:00
$sub_bom_product = new Product($object->db);
$sub_bom_product->fetch($obj->fk_product);
$sub_bom = new BOM($object->db);
2022-02-17 10:53:02 +01:00
if (!empty($obj->fk_bom_child)) {
2022-02-15 10:29:42 +01:00
$sub_bom->fetch($obj->fk_bom_child);
2022-02-17 10:53:02 +01:00
}
2021-08-20 13:37:28 +02:00
$sub_bom_line = new BOMLine($object->db);
$sub_bom_line->fetch($obj->rowid);
2021-08-25 16:58:22 +02:00
//If hidden conf is set, we show directly all the sub-BOM lines
2023-11-27 11:39:32 +01:00
if (!getDolGlobalString('BOM_SHOW_ALL_BOM_BY_DEFAULT')) {
2021-08-23 14:43:17 +02:00
print '<tr style="display:none" class="sub_bom_lines" parentid="'.$line->id.'">';
} else {
print '<tr class="sub_bom_lines" parentid="'.$line->id.'">';
}
2021-08-20 13:37:28 +02:00
// Product OR BOM
print '<td style="padding-left: 5%" id="sub_bom_product_'.$sub_bom_line->id.'">';
2022-01-26 15:15:53 +01:00
if (!empty($obj->fk_bom_child)) {
print $sub_bom_product->getNomUrl(1);
2022-01-26 14:46:45 +01:00
print ' '.$langs->trans('or').' ';
print $sub_bom->getNomUrl(1);
2022-01-26 15:15:53 +01:00
} else {
print $sub_bom_product->getNomUrl(1);
2022-01-26 15:15:53 +01:00
print '</td>';
}
2021-08-25 16:58:22 +02:00
// Qty
2022-12-12 11:41:54 +01:00
$label = $sub_bom_product->getLabelOfUnit('long');
2021-08-20 13:37:28 +02:00
if ($sub_bom_line->qty_frozen > 0) {
print '<td class="linecolqty nowrap right" id="sub_bom_qty_'.$sub_bom_line->id.'">'.price($sub_bom_line->qty, 0, '', 0, 0).'</td>';
2023-11-27 11:39:32 +01:00
if (getDolGlobalString('PRODUCT_USE_UNITS')) {
print '<td class="linecoluseunit nowrap left">';
2023-12-04 12:01:45 +01:00
if ($label !== '') {
print $langs->trans($label);
}
print '</td>';
}
print '<td class="linecolqtyfrozen nowrap right" id="sub_bom_qty_frozen_'.$sub_bom_line->id.'">'.$langs->trans('Yes').'</td>';
2021-08-20 13:37:28 +02:00
} else {
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>';
2023-11-27 11:39:32 +01:00
if (getDolGlobalString('PRODUCT_USE_UNITS')) {
print '<td class="linecoluseunit nowrap left">';
2023-12-04 12:01:45 +01:00
if ($label !== '') {
print $langs->trans($label);
}
print '</td>';
}
2021-08-20 13:37:28 +02:00
print '<td class="linecolqtyfrozen nowrap right" id="sub_bom_qty_frozen_'.$sub_bom_line->id.'">&nbsp;</td>';
}
2021-08-25 16:58:22 +02:00
// Disable stock change
2021-08-20 13:37:28 +02:00
if ($sub_bom_line->disable_stock_change > 0) {
print '<td class="linecoldisablestockchange nowrap right" id="sub_bom_stock_change_'.$sub_bom_line->id.'">'.$sub_bom_line->disable_stock_change.'</td>';
} else {
print '<td class="linecoldisablestockchange nowrap right" id="sub_bom_stock_change_'.$sub_bom_line->id.'">&nbsp;</td>';
}
2021-08-25 16:58:22 +02:00
// Efficiency
2021-08-20 13:37:28 +02:00
print '<td class="linecolefficiency nowrap right" id="sub_bom_efficiency_'.$sub_bom_line->id.'">'.$sub_bom_line->efficiency.'</td>';
2021-08-25 16:58:22 +02:00
2022-03-24 14:04:03 +01:00
// Cost
2022-02-17 10:53:02 +01:00
if (!empty($sub_bom->id)) {
$sub_bom->calculateCosts();
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>';
$total_cost += $sub_bom->total_cost * $sub_bom_line->qty * (float) $line->qty;
2023-02-10 14:47:46 +01:00
} elseif ($sub_bom_product->type == Product::TYPE_SERVICE && isModEnabled('workstation') && !empty($sub_bom_product->fk_default_workstation)) {
//Convert qty to hour
$unit = measuringUnitString($sub_bom_line->fk_unit, '', null, 1);
$qty = convertDurationtoHour($sub_bom_line->qty, $unit);
$workstation = new Workstation($this->db);
$res = $workstation->fetch($sub_bom_product->fk_default_workstation);
2023-12-04 12:01:45 +01:00
if ($res > 0) {
Fix #28071 - New branch to fix bad merge (#28083) * Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop * Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop * Qual: Introduce getDataToShowPhoto to prepare generic code * Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop * Fix missing trans * Fix langs * Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop * Remove useless files in web templates * Clean code * Fix duplicate translation key * Fix duplicate translation key * Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop * Fix duplicate key * Fix $object * Debug v19 * WIP SMSing * Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop * WIP EMAILINGS_SUPPORT_ALSO_SMS * Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop * Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop * WIP SMSing * Debug the "validate" feature * Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop * Clean code * Move rights->x->y into hasRight('x', 'y') * Move rights->x->y into hasRight('x', 'y') * Move rights->x->y into hasRight('x', 'y') * Move rights->x->y into hasRight('x', 'y') * Move rights->x->y into hasRight('x', 'y') * Move rights->x->y into hasRight('x', 'y') * Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop * Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop * Enhance rector to fix empty($user->rights->modulex->perm1) * Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop * Fix template to use v19 dev rules * Fix use v19 dev rules * Fix phpunit * Debug v19 * Clean code * Use rector to convert user->rights into user->hasRight * Clean code * Use rector to convert user->rights into user->hasRight * Use rector to convert user->rights into user->hasRight * Clean code * Fix phpcs * add editorconfig for sql files (#27999) Co-authored-by: Laurent Destailleur <eldy@destailleur.fr> * add model_pdf field in llx_ticket-ticket.sql (#27996) * add model_pdf field in llx_ticket-ticket.sql * Update 19.0.0-20.0.0.sql * Update 19.0.0-20.0.0.sql * Improve wording in README (#27994) * fix phpstan (#27989) * fix phpstan * Update UserRightsToFunction.php --------- Co-authored-by: Laurent Destailleur <eldy@destailleur.fr> * Qual: Fix spelling/working in datapolicy translations (#28006) # Qual: Fix spelling/wording in datapolicy translations Fixed some spelling and wording in datapolicy translations. * qual: phpstan for htdocs/ticket/class/ticketstats.class.php (#27986) htdocs/ticket/class/ticketstats.class.php 98 Parameter #1 $year (string) of method TicketStats::getNbByMonth() should be compatible with parameter $year (int) of method Stats::getNbByMonth() * Merge branch '19.0' of git@github.com:Dolibarr/dolibarr.git into develop * Fix user with readonly perm on email template must be able to read. * Fix doc * Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop * Better message * Add missing fields in merge of thirdparty * Debug v19 selection of ticket printer per terminal * Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop * Use constant * NEW: Adding a recipient on emails sent, change status to sent partialy. * fix travis (#28052) * fix travis * Update partnership.class.php * fix php doc (#28047) * fix undefined array key (#28048) * Add region and departament for Cuba (#28046) * Update llx_10_c_regions.sql Add Cuba Regions (id_country=77) * Update llx_20_c_departements.sql Add Provinces Cuba (id country=77) * Find the typo (#28050) * Find the typo * clean code * add last_main_doc field to product (#28045) * add las_main_doc field to product * add field fetch * NEW Add Categorie filter for ActionComm (#28041) * New Add Categorie filter for ActionComm New Add Categorie filter for ActionComm * Fix space errors Fix space errors * Fix space errors 2 Fix space errors 2 * Update cunits.class.php (#28056) FIX: error SQL when creating a Cunit * Update codespell-lines-ignore.txt to avoid PR merge conflict --------- Co-authored-by: Laurent Destailleur <eldy@destailleur.fr> Co-authored-by: Frédéric FRANCE <frederic34@users.noreply.github.com> Co-authored-by: thibdrev <thibault.drevet@gmail.com> Co-authored-by: sonikf <93765174+sonikf@users.noreply.github.com> Co-authored-by: Ikarus <44511582+LeKarSol@users.noreply.github.com> Co-authored-by: Anthony Damhet <73399671+EchoLoGeek@users.noreply.github.com> Co-authored-by: Quentin-Seekness <72733832+Quentin-Seekness@users.noreply.github.com>
2024-02-09 15:58:49 +01:00
$sub_bom_line->total_cost = (float) price2num($qty * ($workstation->thm_operator_estimated + $workstation->thm_machine_estimated), 'MT');
2023-12-04 12:01:45 +01:00
}
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>';
$this->total_cost += $line->total_cost;
2022-02-17 10:53:02 +01:00
} elseif ($sub_bom_product->cost_price > 0) {
2023-04-27 14:02:59 +02:00
print '<td class="linecolcost nowrap right" id="sub_bom_cost_'.$sub_bom_line->id.'">';
print '<span class="amount">'.price(price2num($sub_bom_product->cost_price * $sub_bom_line->qty * (float) $line->qty, 'MT')).'</span></td>';
$total_cost += $sub_bom_product->cost_price * $sub_bom_line->qty * (float) $line->qty;
2021-08-26 09:43:50 +02:00
} elseif ($sub_bom_product->pmp > 0) { // PMP if cost price isn't defined
2023-04-27 14:02:59 +02:00
print '<td class="linecolcost nowrap right" id="sub_bom_cost_'.$sub_bom_line->id.'">';
print '<span class="amount">'.price(price2num($sub_bom_product->pmp * $sub_bom_line->qty * (float) $line->qty, 'MT')).'</span></td>';
$total_cost .= $sub_bom_product->pmp * $sub_bom_line->qty * (float) $line->qty;
2021-08-26 09:43:50 +02:00
} else { // Minimum purchase price if cost price and PMP aren't defined
2024-04-03 03:27:28 +02:00
$sql_supplier_price = "SELECT MIN(price) AS min_price, quantity AS qty FROM ".MAIN_DB_PREFIX."product_fournisseur_price";
$sql_supplier_price .= " WHERE fk_product = ". (int) $sub_bom_product->id;
$sql_supplier_price .= " GROUP BY quantity ORDER BY quantity ASC";
$resql_supplier_price = $object->db->query($sql_supplier_price);
if ($resql_supplier_price) {
2024-04-03 03:27:28 +02:00
$obj = $object->db->fetch_object($resql_supplier_price); // Take first value so the ref with the smaller minimum quantity
2023-07-29 15:48:16 +02:00
if (!empty($obj->qty) && !empty($sub_bom_line->qty) && !empty($line->qty)) {
$line_cost = $obj->min_price / $obj->qty * $sub_bom_line->qty * (float) $line->qty;
} else {
$line_cost = $obj->min_price;
}
2022-12-09 17:00:11 +01:00
print '<td class="linecolcost nowrap right" id="sub_bom_cost_'.$sub_bom_line->id.'"><span class="amount">'.price2num($line_cost, 'MT').'</span></td>';
$total_cost += $line_cost;
}
}
2021-08-20 13:37:28 +02:00
print '<td></td>';
print '<td></td>';
print '<td></td>';
}
}
2019-10-20 11:17:54 +02:00
print "<!-- END PHP TEMPLATE objectline_view.tpl.php -->\n";