dolibarr/htdocs/bom/tpl/objectline_create.tpl.php

183 lines
7.2 KiB
PHP
Raw Normal View History

2019-05-22 20:28:24 +02:00
<?php
/* Copyright (C) 2010-2012 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2010-2014 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) 2014 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2014 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
* Copyright (C) 2015-2016 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2018-2019 Frédéric France <frederic.france@netlogic.fr>
2019-05-22 20:28:24 +02:00
* Copyright (C) 2018 Ferran Marcet <fmarcet@2byte.es>
*
* 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 following variables defined:
* $object (invoice, order, ...)
* $conf
* $langs
* $forceall (0 by default, 1 for supplier invoices/orders)
*/
// Protection to avoid direct call of template
if (empty($object) || !is_object($object)) {
print "Error: this template page cannot be called directly as an URL";
exit;
2019-05-22 20:28:24 +02:00
}
2019-06-13 14:20:13 +02:00
global $forceall, $forcetoshowtitlelines;
2019-05-22 20:28:24 +02:00
2021-02-23 17:51:46 +01:00
if (empty($forceall)) {
$forceall = 0;
}
2019-05-22 20:28:24 +02:00
// Define colspan for the button 'Add'
$colspan = 3; // Columns: total ht + col edit + col delete
2019-05-22 20:28:24 +02:00
//print $object->element;
// Lines for extrafield
$objectline = new BOMLine($this->db);
2019-10-20 11:17:54 +02:00
print "<!-- BEGIN PHP TEMPLATE objectline_create.tpl.php -->\n";
$nolinesbefore = (count($this->lines) == 0 || $forcetoshowtitlelines);
2019-05-22 20:28:24 +02:00
if ($nolinesbefore) {
print '<tr class="liste_titre nodrag nodrop">';
if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER)) {
print '<td class="linecolnum center"></td>';
}
print '<td class="linecoldescription minwidth500imp">';
2019-10-20 11:17:54 +02:00
print '<div id="add"></div><span class="hideonsmartphone">'.$langs->trans('AddNewLine').'</span>';
print '</td>';
print '<td class="linecolqty right">'.$langs->trans('Qty').'</td>';
2021-02-23 17:51:46 +01:00
if (!empty($conf->global->PRODUCT_USE_UNITS)) {
print '<td class="linecoluseunit left">';
print '<span id="title_units">';
print $langs->trans('Unit');
print '</span></td>';
2019-05-22 20:28:24 +02:00
}
print '<td class="linecolqtyfrozen right">'.$form->textwithpicto($langs->trans('QtyFrozen'), $langs->trans("QuantityConsumedInvariable")).'</td>';
print '<td class="linecoldisablestockchange right">'.$form->textwithpicto($langs->trans('DisableStockChange'), $langs->trans('DisableStockChangeHelp')).'</td>';
2019-10-20 11:17:54 +02:00
print '<td class="linecollost right">'.$form->textwithpicto($langs->trans('ManufacturingEfficiency'), $langs->trans('ValueOfMeansLoss')).'</td>';
print '<td class="linecoledit" colspan="'.$colspan.'">&nbsp;</td>';
print '</tr>';
2019-05-22 20:28:24 +02:00
}
2020-04-26 23:52:23 +02:00
print '<tr class="pair nodrag nodrop nohoverpair'.(($nolinesbefore || $object->element == 'contrat') ? '' : ' liste_titre_create').'">';
$coldisplay = 0;
2019-05-22 20:28:24 +02:00
2019-10-20 11:17:54 +02:00
// Adds a line numbering column
if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER)) {
$coldisplay++;
echo '<td class="bordertop nobottom linecolnum center"></td>';
2019-10-20 11:17:54 +02:00
}
$coldisplay++;
2019-11-09 20:16:13 +01:00
print '<td class="bordertop nobottom linecoldescription minwidth500imp">';
2019-10-20 11:17:54 +02:00
// Predefined product/service
2021-02-23 17:51:46 +01:00
if (!empty($conf->product->enabled) || !empty($conf->service->enabled)) {
2021-10-28 15:05:50 +02:00
if (!empty($conf->global->BOM_SUB_BOM)) {
print $langs->trans("Product");
2021-02-23 17:51:46 +01:00
}
2019-10-20 11:17:54 +02:00
echo '<span class="prod_entry_mode_predef">';
2021-10-28 15:05:50 +02:00
$filtertype = 0;
if (!empty($object->element) && $object->element == 'contrat' && empty($conf->global->STOCK_SUPPORT_SERVICES)) {
$filtertype = -1;
2021-02-23 17:51:46 +01:00
}
2019-10-20 11:17:54 +02:00
$statustoshow = -1;
2021-02-23 17:51:46 +01:00
if (!empty($conf->global->ENTREPOT_EXTRA_STATUS)) {
2019-10-20 11:17:54 +02:00
// hide products in closed warehouse, but show products for internal transfer
$form->select_produits(GETPOST('idprod', 'int'), 'idprod', $filtertype, $conf->product->limit_size, $buyer->price_level, $statustoshow, 2, '', 1, array(), $buyer->id, '1', 0, 'maxwidth500', 0, 'warehouseopen,warehouseinternal', GETPOST('combinations', 'array'));
2020-05-21 15:05:19 +02:00
} else {
$form->select_produits(GETPOST('idprod', 'int'), 'idprod', $filtertype, $conf->product->limit_size, $buyer->price_level, $statustoshow, 2, '', 1, array(), $buyer->id, '1', 0, 'maxwidth500', 0, '', GETPOST('combinations', 'array'));
2019-05-22 20:28:24 +02:00
}
2019-10-20 11:17:54 +02:00
echo '</span>';
}
2021-10-28 15:05:50 +02:00
if (!empty($conf->global->BOM_SUB_BOM)) {
2022-01-03 19:32:21 +01:00
print '<br><span class="opacitymedium">'.$langs->trans("or").'</span><br>'.$langs->trans("BOM");
2021-10-28 15:05:50 +02:00
// TODO Add component to select a BOM
$form->select_bom();
2021-10-28 15:05:50 +02:00
}
print '</td>';
2019-10-20 11:17:54 +02:00
2021-10-28 15:05:50 +02:00
2019-10-20 11:17:54 +02:00
$coldisplay++;
2020-02-16 19:33:58 +01:00
print '<td class="bordertop nobottom linecolqty right"><input type="text" size="2" name="qty" id="qty" class="flat right" value="'.(GETPOSTISSET("qty") ? GETPOST("qty", 'alpha', 2) : 1).'">';
2019-10-20 11:17:54 +02:00
print '</td>';
2021-02-23 17:51:46 +01:00
if (!empty($conf->global->PRODUCT_USE_UNITS)) {
$coldisplay++;
2019-10-20 11:17:54 +02:00
print '<td class="nobottom linecoluseunit left">';
print '</td>';
}
2019-05-22 20:28:24 +02:00
2019-10-20 11:17:54 +02:00
$coldisplay++;
print '<td class="bordertop nobottom linecolqtyfrozen right"><input type="checkbox" name="qty_frozen" id="qty_frozen" class="flat right" value="1"'.(GETPOST("qty_frozen", 'alpha') ? ' checked="checked"' : '').'>';
print '</td>';
$coldisplay++;
print '<td class="bordertop nobottom linecoldisablestockchange right"><input type="checkbox" name="disable_stock_change" id="disable_stock_change" class="flat right" value="1"'.(GETPOST("disable_stock_change", 'alpha') ? ' checked="checked"' : '').'">';
print '</td>';
2019-10-20 11:17:54 +02:00
$coldisplay++;
print '<td class="bordertop nobottom nowrap linecollost right">';
2021-10-28 15:05:50 +02:00
print '<input type="text" size="2" name="efficiency" id="efficiency" class="flat right" value="'.((GETPOSTISSET("efficiency") && $action == 'addline') ?GETPOST("efficiency", 'alpha') : 1).'">';
print '</td>';
2019-10-20 11:17:54 +02:00
2020-03-24 10:32:31 +01:00
$coldisplay++;
print '<td class="bordertop nobottom nowrap linecolcost right">';
print '&nbsp;';
print '</td>';
2019-10-20 11:17:54 +02:00
$coldisplay += $colspan;
2019-11-09 20:16:13 +01:00
print '<td class="bordertop nobottom linecoledit center valignmiddle" colspan="'.$colspan.'">';
print '<input type="submit" class="button button-add" name="addline" id="addline" value="'.$langs->trans('Add').'">';
2019-10-20 11:17:54 +02:00
print '</td>';
print '</tr>';
2019-05-22 20:28:24 +02:00
if (is_object($objectline)) {
2021-01-04 20:00:57 +01:00
print $objectline->showOptionals($extrafields, 'edit', array('style'=>$bcnd[$var], 'colspan'=>$coldisplay), '', '', 1, 'line');
2019-05-22 20:28:24 +02:00
}
?>
<script>
/* JQuery for product free or predefined select */
jQuery(document).ready(function() {
/* When changing predefined product, we reload list of supplier prices required for margin combo */
2019-05-26 01:06:19 +02:00
$("#idprod").change(function()
2019-05-22 20:28:24 +02:00
{
2019-05-26 01:06:19 +02:00
console.log("#idprod change triggered");
2019-05-22 20:28:24 +02:00
2021-02-23 17:51:46 +01:00
/* To set focus */
if (jQuery('#idprod').val() > 0)
{
2019-05-22 20:28:24 +02:00
/* focus work on a standard textarea but not if field was replaced with CKEDITOR */
jQuery('#dp_desc').focus();
/* focus if CKEDITOR */
if (typeof CKEDITOR == "object" && typeof CKEDITOR.instances != "undefined")
{
var editor = CKEDITOR.instances['dp_desc'];
2021-02-23 17:51:46 +01:00
if (editor) { editor.focus(); }
}
2019-05-22 20:28:24 +02:00
}
});
});
</script>
<!-- END PHP TEMPLATE objectline_create.tpl.php -->