Add tpl files for standalone reception (#35966)

* Add tpl for standalone reception

* try to fix phan
This commit is contained in:
sonikf 2025-10-28 02:10:11 +02:00 committed by GitHub
parent 210328dd33
commit 8ed78a31b1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 633 additions and 0 deletions

View file

@ -0,0 +1,186 @@
<?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-2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2018 Ferran Marcet <fmarcet@2byte.es>
* Copyright (C) 2024 Vincent Maury <vmaury@timgroup.fr>
* Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2025 Nick Fragoulis
*
* 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
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* Need to have the following variables defined:
* $object (invoice, order, ...)
* $conf
* $langs
* $forceall (0 by default, 1 for supplier invoices/orders)
*/
require_once DOL_DOCUMENT_ROOT."/product/class/html.formproduct.class.php";
/**
* @var CommonObject $this
* @var CommonObject $object
* @var Form $form
* @var Societe $buyer
* @var Translate $langs
*/
// 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;
}
'
@phan-var-force CommonObject $this
@phan-var-force CommonObject $object
@phan-var-force Societe $buyer
';
global $forceall, $forcetoshowtitlelines, $filtertype;
if (empty($forceall)) {
$forceall = 0;
}
if (empty($filtertype)) {
$filtertype = 0;
}
$formproduct = new FormProduct($object->db);
// Define colspan for the button 'Add'
$colspan = 3;
// Lines for extrafield
$objectline = new ReceptionLineBatch($this->db);
print "<!-- BEGIN PHP TEMPLATE reception/tpl/objectline_create.tpl.php -->\n";
$nolinesbefore = (count($this->lines) == 0 || $forcetoshowtitlelines);
if ($nolinesbefore) {
print '<tr class="liste_titre nodrag nodrop">';
if (getDolGlobalString('MAIN_VIEW_LINE_NUMBER')) {
print '<td class="linecolnum center"></td>';
}
print '<td class="linecoldescription minwidth500imp">';
print '<div id="add"></div><span class="hideonsmartphone">'.$langs->trans('AddNewLine').'</span>';
print '</td>';
print '<td class="linecolqty right">'.$langs->trans('Qty').'</td>';
if (getDolGlobalInt('PRODUCT_USE_UNITS')) {
print '<td class="linecoluseunit left">';
print '<span id="title_units">';
print $langs->trans('Unit');
print '</span></td>';
}
print '</tr>';
}
print '<tr class="pair nodrag nodrop nohoverpair'.(($nolinesbefore || $object->element == 'contrat') ? '' : ' liste_titre_create').'">';
$coldisplay = 0;
// Adds a line numbering column
if (getDolGlobalString('MAIN_VIEW_LINE_NUMBER')) {
$coldisplay++;
echo '<td class="bordertop nobottom linecolnum center"></td>';
}
// Product
$coldisplay++;
print '<td class="bordertop nobottom linecoldescription line minwidth500imp">';
// Predefined product/service
if (isModEnabled("product")) {
if ($filtertype == 1) {
print $langs->trans("Service");
} else {
print $langs->trans("Product");
}
echo '<span class="prod_entry_mode_predef nowraponall">';
$statustoshow = -1;
echo '</span>';
}
if (!empty($extrafields)) {
$temps = $objectline->showOptionals($extrafields, 'create', array(), '', '', '1', 'line');
if (!empty($temps)) {
print '<div style="padding-top: 10px" id="extrafield_lines_area_create" name="extrafield_lines_area_create">';
print $temps;
print '</div>';
}
}
print '</td>';
// Qty
$coldisplay++;
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).'">';
print '</td>';
// Unit
if (getDolGlobalInt('PRODUCT_USE_UNITS')) {
$coldisplay++;
print '<td class="nobottom linecoluseunit">';
print '</td>';
}
$coldisplay += $colspan;
print '<td class="bordertop nobottom linecoledit right valignmiddle" colspan="' . $colspan . '">';
print '<input type="submit" class="button button-add small" name="addline" id="addline" value="' . $langs->trans('Add') . '">';
print '</td>';
print '</tr>';
?>
<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 */
$("#idprod").change(function()
{
console.log("#idprod change triggered");
/* To set focus */
if (jQuery('#idprod').val() > 0)
{
/* 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'];
if (editor) { editor.focus(); }
}
}
});
});
</script>
<!-- END PHP TEMPLATE objectline_create.tpl.php -->

View file

@ -0,0 +1,165 @@
<?php
/* Copyright (C) 2010-2012 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2010-2012 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2012 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) 2018-2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2024 Vincent Maury <vmaury@timgroup.fr>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2025 Nick Fragoulis
*
* 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
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* Need to have the following variables defined:
* $object (invoice, order, ...)
* $conf
* $langs
* $seller, $buyer
* $dateSelector
* $forceall (0 by default, 1 for supplier invoices/orders)
* $senderissupplier (0 by default, 1 for supplier invoices/orders)
* $inputalsopricewithtax (0 by default, 1 to also show column with unit price including tax)
*/
require_once DOL_DOCUMENT_ROOT."/product/class/html.formproduct.class.php";
/**
* @var CommonObject $this
* @var CommonObject $object
* @var HookManager $hookmanager
* @var CommonObjectLine $line
* @var Societe $buyer
* @var Societe $seller
* @var Translate $langs
*
* @var string $action
* @var int $i
* @var bool $var
*/
// Protection to avoid direct call of template
if (empty($object) || !is_object($object)) {
print "Error, template page can't be called as URL";
exit(1);
}
'
@phan-var-force receptionlinebatch $line
@phan-var-force CommonObject $this
@phan-var-force CommonObject $object
@phan-var-force int $i
@phan-var-force bool $var
@phan-var-force Societe $buyer
@phan-var-force Societe $seller
';
global $forceall, $filtertype;
if (empty($forceall)) {
$forceall = 0;
}
if (empty($filtertype)) {
$filtertype = 0;
}
$formproduct = new FormProduct($object->db);
$form = new Form($object->db);
// Define colspan for the button 'Add'
$colspan = 3;
// Lines for extrafield
$objectline = new ReceptionLineBatch($this->db);
print "<!-- BEGIN PHP TEMPLATE reception/tpl/objectline_edit.tpl.php -->\n";
$coldisplay = 0;
print '<tr class="oddeven tredited">';
// Adds a line numbering column
if (getDolGlobalString('MAIN_VIEW_LINE_NUMBER')) {
print '<td class="linecolnum center">'.($i + 1).'</td>';
$coldisplay++;
}
$coldisplay++;
?>
<td>
<div id="line_<?php echo $line->id; ?>"></div>
<input type="hidden" name="lineid" value="<?php echo $line->id; ?>">
<input type="hidden" id="product_type" name="type" value="<?php echo $line->product_type; ?>">
<input type="hidden" id="product_id" name="productid" value="<?php echo(!empty($line->fk_product) ? $line->fk_product : 0); ?>" />
<input type="hidden" id="special_code" name="special_code" value="<?php echo $line->special_code; ?>">
<?php
// Predefined product/service
if ($line->fk_product > 0) {
$tmpproduct = new Product($object->db);
$tmpproduct->fetch($line->fk_product);
print $tmpproduct->getNomUrl(1);
print ' - '.$tmpproduct->label;
}
//Line extrafield
if (!empty($extrafields)) {
$temps = $line->showOptionals($extrafields, 'edit', array('class' => 'tredited'), '', '', '1', 'line');
if (!empty($temps)) {
print '<div style="padding-top: 10px" id="extrafield_lines_area_edit" name="extrafield_lines_area_edit">';
print $temps;
print '</div>';
}
}
print '</td>';
$coldisplay++;
print '<td class="nobottom linecolqty right">';
if (((int) $line->info_bits & 2) != 2) {
print '<input size="3" type="text" class="flat right" name="qty" id="qty" value="'.$line->qty.'">';
}
print '</td>';
if (getDolGlobalString('PRODUCT_USE_UNITS')) {
$unit_type = false;
// limit unit select to unit type
if (!empty($line->fk_unit) && !getDolGlobalString('MAIN_EDIT_LINE_ALLOW_ALL_UNIT_TYPE')) {
include_once DOL_DOCUMENT_ROOT.'/core/class/cunits.class.php';
$cUnit = new CUnits($line->db);
if ($cUnit->fetch((int) $line->fk_unit) > 0) {
if (!empty($cUnit->unit_type)) {
$unit_type = $cUnit->unit_type;
}
}
}
$coldisplay++;
print '<td class="left">';
print $form->selectUnits(GETPOSTISSET('units') ? GETPOST('units') : $line->fk_unit, "units", 0, $unit_type);
print '</td>';
}
$coldisplay += $colspan;
print '<td class="nobottom linecoledit center valignmiddle" colspan="'.$colspan.'">';
$coldisplay += $colspan;
print '<input type="submit" class="reposition button buttongen margintoponly marginbottomonly button-save" id="savelinebutton" name="save" value="'.$langs->trans("Save").'">';
print '<input type="submit" class="reposition button buttongen margintoponly marginbottomonly button-cancel" id="cancellinebutton" name="cancel" value="'.$langs->trans("Cancel").'">';
print '</td>';
print '</tr>';
print "<!-- END PHP TEMPLATE objectline_edit.tpl.php -->\n";

View file

@ -0,0 +1,101 @@
<?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 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2025 Nick Fragoulis
*
* 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
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* Need to have the following variables defined:
* $object (invoice, order, ...)
* $conf
* $langs
* $element (used to test $user->hasRight($element, 'creer'))
* $permtoedit (used to replace test $user->hasRight($element, 'creer'))
* $inputalsopricewithtax (0 by default, 1 to also show column with unit price including tax)
* $outputalsopricetotalwithtax
* $usemargins (0 to disable all margins columns, 1 to show according to margin setup)
*
* $type, $text, $description, $line
*/
/**
* @var CommonObject $this
* @var CommonObject $object
* @var Form $form
* @var Translate $langs
*
* @var string $action
*/
// Protection to avoid direct call of template
if (empty($object) || !is_object($object)) {
print "Error, template page can't be called as URL";
exit(1);
}
'@phan-var-force CommonObject $this
@phan-var-force CommonObject $object';
global $filtertype;
if (empty($filtertype)) {
$filtertype = 0;
}
print "<!-- BEGIN PHP TEMPLATE reception/tpl/objectline_title.tpl.php -->\n";
// Title line
print "<thead>\n";
print '<tr class="liste_titre nodrag nodrop">';
// Adds a line numbering column
if (getDolGlobalString('MAIN_VIEW_LINE_NUMBER')) {
print '<td class="linecolnum center">&nbsp;</td>';
}
// Product
print '<th class="linecoldescription">'.$langs->trans('Description');
// Qty
print '<th class="linecolqty right">'.$langs->trans('Qty').'</th>';
// Unit
if (getDolGlobalString('PRODUCT_USE_UNITS')) {
print '<th class="linecoluseunit left">'.$langs->trans('Unit').'</th>';
}
print '<td class="linecoledit" style="width: 10px"></td>'; // No width to allow autodim
print '<td class="linecoldelete" style="width: 10px"></td>';
print '<td class="linecolmove" style="width: 10px"></td>';
if ($action == 'selectlines') {
print '<td class="linecolcheckall center">';
print '<input type="checkbox" class="linecheckboxtoggle" />';
print '<script>$(document).ready(function() {$(".linecheckboxtoggle").click(function() {var checkBoxes = $(".linecheckbox");checkBoxes.prop("checked", this.checked);})});</script>';
print '</td>';
}
print "</tr>\n";
print "</thead>\n";
print "<!-- END PHP TEMPLATE objectline_title.tpl.php -->\n";

View file

@ -0,0 +1,181 @@
<?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>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2025 Nick Fragoulis
*
* 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
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* Need to have the following variables defined:
* $object (invoice, order, ...)
* $conf
* $langs
* $forceall (0 by default, 1 for supplier invoices/orders)
* $element (used to test $user->hasRight($element, 'creer'))
* $permtoedit (used to replace test $user->hasRight($element, 'creer'))
* $inputalsopricewithtax (0 by default, 1 to also show column with unit price including tax)
* $disableedit, $disablemove, $disableremove
*
* $type, $text, $description, $line
*/
/**
* @var Conf $conf
* @var CommonObject $this
* @var CommonObject $object
* @var CommonObjectLine $line
* @var Translate $langs
* @var User $user
*
* @var int $i
* @var int $num
* @var string $action
*/
'
@phan-var-force receptionlinebatch $line
@phan-var-force int $num
@phan-var-force int $i
@phan-var-force CommonObject $this
@phan-var-force CommonObject $object
';
// Protection to avoid direct call of template
if (empty($object) || !is_object($object)) {
print "Error, template page can't be called as URL";
exit(1);
}
global $filtertype;
if (empty($filtertype)) {
$filtertype = 0;
}
global $forceall, $senderissupplier, $inputalsopricewithtax, $outputalsopricetotalwithtax, $langs;
if (empty($dateSelector)) {
$dateSelector = 0;
}
if (empty($forceall)) {
$forceall = 0;
}
// add html5 elements
$domData = ' data-element="'.$line->element.'"';
$domData .= ' data-id="'.$line->id.'"';
$domData .= ' data-qty="'.$line->qty.'"';
$domData .= ' data-product_type="'.$line->product_type.'"';
// Lines for extrafield
$objectline = new ReceptionLineBatch($this->db);
$coldisplay = 0;
print "<!-- BEGIN PHP TEMPLATE reception/tpl/objectline_view.tpl.php -->\n";
print '<tr id="row-'.$line->id.'" class="drag drop oddeven" '.$domData.' >';
// Line nb
if (getDolGlobalString('MAIN_VIEW_LINE_NUMBER')) {
print '<td class="linecolnum center">'.($i + 1).'</td>';
$coldisplay++;
}
// Product
print '<td class="linecoldescription line minwidth300imp tdoverflowmax300">';
print '<div id="line_'.$line->id.'"></div>';
$coldisplay++;
$tmpproduct = new Product($object->db);
$tmpproduct->fetch($line->fk_product);
$tmprecep = new Reception($object->db);
if ($line->fk_product > 0) {
print $tmpproduct->getNomUrl(1);
print ' - '.$tmpproduct->label;
} else {
print ' - '.$line->description;
}
print '</td>';
// Qty
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
print '</td>';
// Unit
if (getDolGlobalInt('PRODUCT_USE_UNITS')) { // For product, unit is shown only if option PRODUCT_USE_UNITS is on
print '<td class="linecoluseunit nowrap">';
$coldisplay++;
$label = measuringUnitString((int) $line->fk_unit, '', null, 1);
if ($label !== '') {
print $langs->trans($label);
}
print '</td>';
}
if ($this->status == 0 && $user->hasRight('reception', 'write') && $action != 'selectlines') {
print '<td class="linecoledit center">';
$coldisplay++;
if (((int) $line->info_bits & 2) == 2 || !empty($disableedit)) {
} else {
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++;
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>';
if ($num > 1 && $conf->browser->layout != 'phone' && empty($disablemove)) {
print '<td class="linecolmove tdlineupdown center">';
$coldisplay++;
if ($i > 0) {
print '<a class="lineupdown" href="'.$_SERVER["PHP_SELF"].'?id='.$this->id.'&action=up&token='.newToken().'&rowid='.$line->id.'">';
echo img_up('default', 0, 'imgupforline');
print '</a>';
}
if ($i < $num - 1) {
print '<a class="lineupdown" href="'.$_SERVER["PHP_SELF"].'?id='.$this->id.'&action=down&token='.newToken().'&rowid='.$line->id.'">';
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>';
$coldisplay++;
}
} else {
print '<td colspan="3"></td>';
$coldisplay += 3;
}
if ($action == 'selectlines') {
print '<td class="linecolcheck center">';
print '<input type="checkbox" class="linecheckbox" name="line_checkbox['.($i + 1).']" value="'.$line->id.'" >';
print '</td>';
}
print '</tr>';
print "<!-- END PHP TEMPLATE objectline_view.tpl.php -->\n";