diff --git a/ChangeLog.md b/ChangeLog.md
index 833cc248..b29a41ee 100644
--- a/ChangeLog.md
+++ b/ChangeLog.md
@@ -3,6 +3,7 @@ All notable changes to this project will be documented in this file.
# [Unreleased]
## Release 3.29
+- FIX : COMPAT V23 - *02/12/2025* - 3.29.2
- FIX : query sql to order line when create invoice from order - *29/10/2025* - 3.29.1
- FIX : Prevent creating a new situation invoice when all lines have 100% progress- *01/10/2025* - 3.29.1
- NEW : COMPAT 22 - *02/07/2025* - 3.29.0
diff --git a/class/actions_subtotal.class.php b/class/actions_subtotal.class.php
index 1b22629b..1bd5cc9a 100644
--- a/class/actions_subtotal.class.php
+++ b/class/actions_subtotal.class.php
@@ -1,5 +1,19 @@
+
+ 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 .
+
* SPDX-License-Identifier: GPL-3.0-or-later
* This file is part of Dolibarr module Subtotal
*/
@@ -12,6 +26,11 @@
require_once __DIR__ . '/../backport/v19/core/class/commonhookactions.class.php';
+/**
+ * Class ActionsSubtotal
+ *
+ * Hook actions for Subtotal module
+ */
class ActionsSubtotal extends \subtotal\RetroCompatCommonHookActions
{
@@ -25,23 +44,28 @@ class ActionsSubtotal extends \subtotal\RetroCompatCommonHookActions
*/
public $errors = array();
- /**
- * @var int Subtotal current level
- */
- protected $subtotal_level_cur = 0;
+ /**
+ * @var int Subtotal current level
+ */
+ protected $subtotal_level_cur = 0;
- /**
- * @var bool Show subtotal qty by default
- */
- protected $subtotal_show_qty_by_default = false;
+ /**
+ * @var bool Show subtotal qty by default
+ */
+ protected $subtotal_show_qty_by_default = false;
- /**
- * @var bool Determine if sum on subtotal qty is enabled
- */
- protected $subtotal_sum_qty_enabled = false;
+ /**
+ * @var bool Determine if sum on subtotal qty is enabled
+ */
+ protected $subtotal_sum_qty_enabled = false;
- function __construct($db)
+ /**
+ * Constructor
+ *
+ * @param DoliDB $db Database handler
+ */
+ public function __construct($db)
{
global $langs;
@@ -51,13 +75,23 @@ function __construct($db)
$this->allow_move_block_lines = true;
}
- function printFieldListSelect($parameters, &$object, &$action, $hookmanager) {
+ /**
+ * Print field list select
+ *
+ * @param array $parameters Parameters
+ * @param CommonObject $object Object
+ * @param string $action Action
+ * @param HookManager $hookmanager Hook manager
+ * @return int
+ */
+ public function printFieldListSelect($parameters, &$object, &$action, $hookmanager)
+ {
global $type_element, $where;
- $contexts = explode(':',$parameters['context']);
+ $contexts = explode(':', $parameters['context']);
- if(in_array('consumptionthirdparty',$contexts) && in_array($type_element, array('propal', 'order', 'invoice', 'supplier_order', 'supplier_invoice', 'supplier_proposal'))) {
+ if (in_array('consumptionthirdparty', $contexts) && in_array($type_element, array('propal', 'order', 'invoice', 'supplier_order', 'supplier_invoice', 'supplier_proposal'))) {
$mod_num = TSubtotal::$module_number;
// Not a title (can't use TSubtotal class methods in sql)
@@ -66,23 +100,30 @@ function printFieldListSelect($parameters, &$object, &$action, $hookmanager) {
$where.= ' AND (d.special_code != '.$mod_num.' OR d.product_type != 9 OR d.qty < 90)';
// Not a free line text (can't use TSubtotal class methods in sql)
$where.= ' AND (d.special_code != '.$mod_num.' OR d.product_type != 9 OR d.qty != 50)';
-
}
return 0;
}
- function editDictionaryFieldlist($parameters, &$object, &$action, $hookmanager)
+ /**
+ * Edit dictionary field list
+ *
+ * @param array $parameters Parameters
+ * @param CommonObject $object Object
+ * @param string $action Action
+ * @param HookManager $hookmanager Hook manager
+ * @return int
+ */
+ public function editDictionaryFieldlist($parameters, &$object, &$action, $hookmanager)
{
global $conf;
$dictionnariesTablePrefix = '';
if (intval(DOL_VERSION)< 16) $dictionnariesTablePrefix = MAIN_DB_PREFIX;
- if ($parameters['tabname'] == $dictionnariesTablePrefix.'c_subtotal_free_text')
- {
- $value = TSubtotal::getHtmlDictionnary();
+ if ($parameters['tabname'] == $dictionnariesTablePrefix.'c_subtotal_free_text') {
+ $value = TSubtotal::getHtmlDictionnary();
?>
@@ -107,7 +148,7 @@ function editDictionaryFieldlist($parameters, &$object, &$action, $hookmanager)
versionCheck: false
});
});
-
+
}
});
@@ -116,16 +157,24 @@ function editDictionaryFieldlist($parameters, &$object, &$action, $hookmanager)
return 0;
}
- function createDictionaryFieldlist($parameters, &$object, &$action, $hookmanager)
+ /**
+ * Create dictionary field list
+ *
+ * @param array $parameters Parameters
+ * @param CommonObject $object Object
+ * @param string $action Action
+ * @param HookManager $hookmanager Hook manager
+ * @return int
+ */
+ public function createDictionaryFieldlist($parameters, &$object, &$action, $hookmanager)
{
global $conf;
$dictionnariesTablePrefix = '';
if (intval(DOL_VERSION)< 16) $dictionnariesTablePrefix = MAIN_DB_PREFIX;
- if ($parameters['tabname'] == $dictionnariesTablePrefix.'c_subtotal_free_text')
- {
- $value = TSubtotal::getHtmlDictionnary();
+ if ($parameters['tabname'] == $dictionnariesTablePrefix.'c_subtotal_free_text') {
+ $value = TSubtotal::getHtmlDictionnary();
?>
+
id] ) ? $_SESSION['subtotal_hideInnerLines_'.$parameters['modulepart']][$object->id] : 0;
- $hidedetails = isset( $_SESSION['subtotal_hidedetails_'.$parameters['modulepart']][$object->id] ) ? $_SESSION['subtotal_hidedetails_'.$parameters['modulepart']][$object->id] : 0;
+ && (in_array('invoicecard', $contextArray)
+ || in_array('invoicesuppliercard', $contextArray)
+ || in_array('propalcard', $contextArray)
+ || in_array('ordercard', $contextArray)
+ || in_array('ordersuppliercard', $contextArray)
+ || in_array('invoicereccard', $contextArray))
+ ) {
+ $hideInnerLines = isset($_SESSION['subtotal_hideInnerLines_'.$parameters['modulepart']][$object->id]) ? $_SESSION['subtotal_hideInnerLines_'.$parameters['modulepart']][$object->id] : 0;
+ $hidedetails = isset($_SESSION['subtotal_hidedetails_'.$parameters['modulepart']][$object->id]) ? $_SESSION['subtotal_hidedetails_'.$parameters['modulepart']][$object->id] : 0;
$hidepricesDefaultConf = getDolGlobalString('SUBTOTAL_HIDE_PRICE_DEFAULT_CHECKED')?getDolGlobalString('SUBTOTAL_HIDE_PRICE_DEFAULT_CHECKED') :0;
- $hideprices= !empty( $_SESSION['subtotal_hideprices_'.$parameters['modulepart']][$object->id] ) ? $_SESSION['subtotal_hideprices_'.$parameters['modulepart']][$object->id] : $hidepricesDefaultConf;
+ $hideprices= !empty($_SESSION['subtotal_hideprices_'.$parameters['modulepart']][$object->id]) ? $_SESSION['subtotal_hideprices_'.$parameters['modulepart']][$object->id] : $hidepricesDefaultConf;
$var=false;
$out = '';
- $out.= '
rel="subtotal" id="row-id ?>" style="qty==99) print 'background:#adadcf'; // Sub-total level 1
- else if($line->qty==98) print 'background:#ddddff;'; // Sub-total level 2
- else if($line->qty<=97 && $line->qty>=91) print 'background:#eeeeff;'; // Sub-total level 3 to 9
- else if($line->qty==1) print 'background:#adadcf;'; // Title level 1
- else if($line->qty==2) print 'background:#ddddff;'; // Title level 2
- else if($line->qty==50) print ''; // Free text
- else print 'background:#eeeeff;'; // Title level 3 to 9
-
- // À compléter si on veut plus de nuances de couleurs avec les niveaux 4,5,6,7,8 et 9
- }
- else
- {
- if($line->qty==99) print 'background:#ddffdd'; // Sub-total level 1
- else if($line->qty==98) print 'background:#ddddff;'; // Sub-total level 2
- else if($line->qty==2) print 'background:#eeeeff; '; // Title level 2
- else if($line->qty==50) print ''; // Free text
- else print 'background:#eeffee;' ; // Title level 1 and 3 to 9
- }
+ if (!empty(getDolGlobalString('SUBTOTAL_USE_NEW_FORMAT'))) {
+ if ($line->qty==99) print 'background:#adadcf'; // Sub-total level 1
+ elseif ($line->qty==98) print 'background:#ddddff;'; // Sub-total level 2
+ elseif ($line->qty<=97 && $line->qty>=91) print 'background:#eeeeff;'; // Sub-total level 3 to 9
+ elseif ($line->qty==1) print 'background:#adadcf;'; // Title level 1
+ elseif ($line->qty==2) print 'background:#ddddff;'; // Title level 2
+ elseif ($line->qty==50) print ''; // Free text
+ else print 'background:#eeeeff;'; // Title level 3 to 9
+
+ // À compléter si on veut plus de nuances de couleurs avec les niveaux 4,5,6,7,8 et 9
+ } else {
+ if ($line->qty==99) print 'background:#ddffdd'; // Sub-total level 1
+ elseif ($line->qty==98) print 'background:#ddddff;'; // Sub-total level 2
+ elseif ($line->qty==2) print 'background:#eeeeff; '; // Title level 2
+ elseif ($line->qty==50) print ''; // Free text
+ else print 'background:#eeffee;' ; // Title level 1 and 3 to 9
+ }
?>;">
-
+
|
@@ -2801,195 +2857,176 @@ function printObjectLine ($parameters, &$object, &$action, $hookmanager)
if ($object->element == 'invoice_supplier') {
$colspan -= 2;
}
- $line_show_qty = false;
-
- if(TSubtotal::isSubtotal($line)) {
-
- /* Total */
- $TSubtotalDatas = $this->getTotalLineFromObject($object, $line, '', 1);
- $total_line = $TSubtotalDatas[0];
- $total_qty = $TSubtotalDatas[4];
- if ($show_qty_bu_deault = TSubtotal::showQtyForObject($object)) {
- $line_show_qty = TSubtotal::showQtyForObjectLine($line, $show_qty_bu_deault);
+ $line_show_qty = false;
- }
- }
+ if (TSubtotal::isSubtotal($line)) {
+ /* Total */
+ $TSubtotalDatas = $this->getTotalLineFromObject($object, $line, '', 1);
+ $total_line = $TSubtotalDatas[0];
+ $total_qty = $TSubtotalDatas[4];
+ if ($show_qty_bu_deault = TSubtotal::showQtyForObject($object)) {
+ $line_show_qty = TSubtotal::showQtyForObjectLine($line, $show_qty_bu_deault);
+ }
+ }
?>
id && TSubtotal::isModSubtotalLine($line) ) {
-
- echo '';
- $params=array('line'=>$line);
- $reshook=$hookmanager->executeHooks('formEditProductOptions',$params,$object,$action);
-
- echo ''; // Imitation Dolibarr
- echo '';
- echo '';
- echo '';
- echo '';
-
- $isFreeText=false;
- if (TSubtotal::isTitle($line))
- {
- $qty_displayed = $line->qty;
- print img_picto('', 'subsubtotal@subtotal').''.$qty_displayed.' ';
+ if ($action=='editline' && GETPOST('lineid', 'int') == $line->id && TSubtotal::isModSubtotalLine($line) ) {
+ echo ' | ';
+ $params=array('line'=>$line);
+ $reshook=$hookmanager->executeHooks('formEditProductOptions', $params, $object, $action);
+
+ echo ''; // Imitation Dolibarr
+ echo '';
+ echo '';
+ echo '';
+ echo '';
+
+ $isFreeText=false;
+ if (TSubtotal::isTitle($line)) {
+ $qty_displayed = $line->qty;
+ print img_picto('', 'subsubtotal@subtotal').''.$qty_displayed.' ';
+ } elseif (TSubtotal::isSubtotal($line)) {
+ $qty_displayed = 100 - $line->qty;
+ print img_picto('', 'subsubtotal2@subtotal').''.$qty_displayed.' ';
+ } else {
+ $isFreeText = true;
+ }
+ if ($object->element == 'order_supplier' || $object->element == 'invoice_supplier') {
+ $line->label = !empty($line->description) ? $line->description : $line->desc;
+ $line->description = '';
+ }
+ $newlabel = $line->label;
+ if ($line->label=='' && !$isFreeText) {
+ if (TSubtotal::isSubtotal($line)) {
+ $newlabel = $line->description.' '.$this->getTitle($object, $line);
+ $line->description='';
}
- else if (TSubtotal::isSubtotal($line))
- {
- $qty_displayed = 100 - $line->qty;
- print img_picto('', 'subsubtotal2@subtotal').''.$qty_displayed.' ';
- }
- else
- {
- $isFreeText = true;
- }
+ }
- if ($object->element == 'order_supplier' || $object->element == 'invoice_supplier') {
- $line->label = !empty($line->description) ? $line->description : $line->desc;
- $line->description = '';
- }
- $newlabel = $line->label;
- if($line->label=='' && !$isFreeText) {
- if(TSubtotal::isSubtotal($line)) {
- $newlabel = $line->description.' '.$this->getTitle($object, $line);
- $line->description='';
- }
- }
+ $readonlyForSituation = '';
+ if (empty($line->fk_prev_id)) $line->fk_prev_id = null;
+ if (!empty($line->fk_prev_id) && $line->fk_prev_id != null) $readonlyForSituation = 'readonly';
- $readonlyForSituation = '';
- if(empty($line->fk_prev_id)) $line->fk_prev_id = null;
- if (!empty($line->fk_prev_id) && $line->fk_prev_id != null) $readonlyForSituation = 'readonly';
+ if (!$isFreeText) echo ' ';
- if (!$isFreeText) echo ' ';
+ if (getDolGlobalString('SUBTOTAL_USE_NEW_FORMAT') && (TSubtotal::isTitle($line) || TSubtotal::isSubtotal($line)) ) {
+ $select = ' ';
- if (getDolGlobalString('SUBTOTAL_USE_NEW_FORMAT') && (TSubtotal::isTitle($line) || TSubtotal::isSubtotal($line)) )
- {
- $select = ' ';
+ echo $select;
+ }
- echo $select;
- }
+ echo '';
+ if (!getDolGlobalString('SUBTOTAL_HIDE_OPTIONS_BREAK_PAGE_BEFORE')) {
+ echo ' ';
+ echo 'info_bits > 0) ? 'checked="checked"' : '') .' /> ';
+ echo '';
+ echo ' ';
+ }
+ if (TSubtotal::isTitle($line)&& !getDolGlobalString('SUBTOTAL_HIDE_OPTIONS_TITLE')) {
+ $form = new Form($db);
+ echo ' ';
+ echo '';
+ echo '';
+ echo ' ';
- echo ' ';
- if (!getDolGlobalString('SUBTOTAL_HIDE_OPTIONS_BREAK_PAGE_BEFORE')){
+ if (getDolGlobalString('INVOICE_USE_SITUATION') && $object->element == 'facture' && $object->type == Facture::TYPE_SITUATION) {
echo ' ';
- echo 'info_bits > 0) ? 'checked="checked"' : '') .' /> ';
- echo '';
+ echo ' %';
echo ' ';
}
- if (TSubtotal::isTitle($line)&& !getDolGlobalString('SUBTOTAL_HIDE_OPTIONS_TITLE'))
- {
- $form = new Form($db);
- echo ' ';
- echo '';
- echo '';
- echo ' ';
-
- if (getDolGlobalString('INVOICE_USE_SITUATION') && $object->element == 'facture' && $object->type == Facture::TYPE_SITUATION)
- {
- echo ' ';
- echo ' %';
- echo ' ';
- }
- echo ' ';
- echo 'array_options['options_show_total_ht']) && $line->array_options['options_show_total_ht'] > 0) ? 'checked="checked"' : '') .' /> ';
- echo '';
- echo ' ';
-
- echo ' ';
- echo 'array_options['options_show_reduc']) && $line->array_options['options_show_reduc'] > 0) ? 'checked="checked"' : '') .' /> ';
- echo '';
- echo ' ';
- }
- else if ($isFreeText) echo TSubtotal::getFreeTextHtml($line, (bool) $readonlyForSituation);
-
- if (TSubtotal::isSubtotal($line) && $show_qty_bu_deault = TSubtotal::showQtyForObject($object)) {
- $line_show_qty = TSubtotal::showQtyForObjectLine($line, $show_qty_bu_deault);
- echo ' ';
- echo ' ';
- echo '';
- echo ' ';
- }
+ echo ' ';
+ echo 'array_options['options_show_total_ht']) && $line->array_options['options_show_total_ht'] > 0) ? 'checked="checked"' : '') .' /> ';
+ echo '';
+ echo ' ';
+ echo ' ';
+ echo 'array_options['options_show_reduc']) && $line->array_options['options_show_reduc'] > 0) ? 'checked="checked"' : '') .' /> ';
+ echo '';
echo ' ';
+ } elseif ($isFreeText) echo TSubtotal::getFreeTextHtml($line, (bool) $readonlyForSituation);
- if (TSubtotal::isTitle($line))
- {
- // WYSIWYG editor
- require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php';
- $nbrows = ROWS_2;
- $cked_enabled = (getDolGlobalString('FCKEDITOR_ENABLE_DETAILS') ? getDolGlobalString('FCKEDITOR_ENABLE_DETAILS'): 0);
- if (getDolGlobalString('MAIN_INPUT_DESC_HEIGHT')) {
- $nbrows = getDolGlobalString('MAIN_INPUT_DESC_HEIGHT');
- }
- $toolbarname = 'dolibarr_details';
- if (getDolGlobalString('FCKEDITOR_ENABLE_DETAILS_FULL')) {
- $toolbarname = 'dolibarr_notes';
- }
- $doleditor = new DolEditor('line-description', $line->description, '', 100, $toolbarname, '',
- false, true, $cked_enabled, $nbrows, '98%', (bool) $readonlyForSituation);
- $doleditor->Create();
-
- $TKey = null;
- getDolGlobalString('SUBTOTAL_LIST_OF_EXTRAFIELDS_PROPALDET', '');
- getDolGlobalString('SUBTOTAL_LIST_OF_EXTRAFIELDS_COMMANDEDET', '');
- getDolGlobalString('SUBTOTAL_LIST_OF_EXTRAFIELDS_FACTUREDET', '');
- if ($line->element == 'propaldet') $TKey = explode(',', getDolGlobalString('SUBTOTAL_LIST_OF_EXTRAFIELDS_PROPALDET'));
- elseif ($line->element == 'commandedet') $TKey = explode(',', getDolGlobalString('SUBTOTAL_LIST_OF_EXTRAFIELDS_COMMANDEDET'));
- elseif ($line->element == 'facturedet') $TKey = explode(',', getDolGlobalString('SUBTOTAL_LIST_OF_EXTRAFIELDS_FACTUREDET'));
- // TODO ajouter la partie fournisseur
-
- if (!empty($TKey))
- {
- $extrafields = new ExtraFields($this->db);
- $extrafields->fetch_name_optionals_label($object->table_element_line);
- if(!empty($extrafields->attributes[$line->element]['param'])) {
- foreach($extrafields->attributes[$line->element]['param'] as $code => $val) {
- if(in_array($code, $TKey) && $extrafields->attributes[$line->element]['list'][$code] > 0) {
- echo ' ';
- echo '';
- if(floatval(DOL_VERSION) >= 17) echo $extrafields->showInputField($code, $line->array_options['options_'.$code], '', '', 'subtotal_','',0,$object->table_element_line);
- else echo $extrafields->showInputField($code, $line->array_options['options_'.$code], '', '', 'subtotal_');
- echo ' ';
- }
+ if (TSubtotal::isSubtotal($line) && $show_qty_bu_deault = TSubtotal::showQtyForObject($object)) {
+ $line_show_qty = TSubtotal::showQtyForObjectLine($line, $show_qty_bu_deault);
+ echo ' ';
+ echo ' ';
+ echo '';
+ echo ' ';
+ }
+
+ echo ' ';
+
+ if (TSubtotal::isTitle($line)) {
+ // WYSIWYG editor
+ require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php';
+ $nbrows = ROWS_2;
+ $cked_enabled = (getDolGlobalString('FCKEDITOR_ENABLE_DETAILS') ? getDolGlobalString('FCKEDITOR_ENABLE_DETAILS'): 0);
+ if (getDolGlobalString('MAIN_INPUT_DESC_HEIGHT')) {
+ $nbrows = getDolGlobalString('MAIN_INPUT_DESC_HEIGHT');
+ }
+ $toolbarname = 'dolibarr_details';
+ if (getDolGlobalString('FCKEDITOR_ENABLE_DETAILS_FULL')) {
+ $toolbarname = 'dolibarr_notes';
+ }
+ $doleditor = new DolEditor('line-description', $line->description, '', 100, $toolbarname, '',
+ false, true, $cked_enabled, $nbrows, '98%', (bool) $readonlyForSituation);
+ $doleditor->Create();
+
+ $TKey = null;
+ getDolGlobalString('SUBTOTAL_LIST_OF_EXTRAFIELDS_PROPALDET', '');
+ getDolGlobalString('SUBTOTAL_LIST_OF_EXTRAFIELDS_COMMANDEDET', '');
+ getDolGlobalString('SUBTOTAL_LIST_OF_EXTRAFIELDS_FACTUREDET', '');
+ if ($line->element == 'propaldet') $TKey = explode(',', getDolGlobalString('SUBTOTAL_LIST_OF_EXTRAFIELDS_PROPALDET'));
+ elseif ($line->element == 'commandedet') $TKey = explode(',', getDolGlobalString('SUBTOTAL_LIST_OF_EXTRAFIELDS_COMMANDEDET'));
+ elseif ($line->element == 'facturedet') $TKey = explode(',', getDolGlobalString('SUBTOTAL_LIST_OF_EXTRAFIELDS_FACTUREDET'));
+ // TODO ajouter la partie fournisseur
+
+ if (!empty($TKey)) {
+ $extrafields = new ExtraFields($this->db);
+ $extrafields->fetch_name_optionals_label($object->table_element_line);
+ if (!empty($extrafields->attributes[$line->element]['param'])) {
+ foreach ($extrafields->attributes[$line->element]['param'] as $code => $val) {
+ if (in_array($code, $TKey) && $extrafields->attributes[$line->element]['list'][$code] > 0) {
+ echo ' ';
+ echo '';
+ if (floatval(DOL_VERSION) >= 17) echo $extrafields->showInputField($code, $line->array_options['options_'.$code], '', '', 'subtotal_', '', 0, $object->table_element_line);
+ else echo $extrafields->showInputField($code, $line->array_options['options_'.$code], '', '', 'subtotal_');
+ echo ' ';
}
}
}
}
+ }
+ } else {
+ if ($line_show_qty) {
+ $colspan -= 2;
+
+ $style = getDolGlobalString('SUBTOTAL_TITLE_STYLE', '');
+ $titleStyleItalic = strpos($style, 'I') === false ? '' : ' font-style: italic;';
+ $titleStyleBold = strpos($style, 'B') === false ? '' : ' font-weight:bold;';
+ $titleStyleUnderline = strpos($style, 'U') === false ? '' : ' text-decoration: underline;';
+ $style = 'text-align:right;';
+ echo ' ';
+ echo '' . $langs->trans('Qty') . ' : ' . price($total_qty, 0, '', 0, 0);
+ echo ' | ';
+ $colspan = 2;
}
- else {
-
- if ($line_show_qty) {
- $colspan -= 2;
-
- $style = getDolGlobalString('SUBTOTAL_TITLE_STYLE', '');
- $titleStyleItalic = strpos($style, 'I') === false ? '' : ' font-style: italic;';
- $titleStyleBold = strpos($style, 'B') === false ? '' : ' font-weight:bold;';
- $titleStyleUnderline = strpos($style, 'U') === false ? '' : ' text-decoration: underline;';
-
- $style = 'text-align:right;';
- echo ' ';
- echo '' . $langs->trans('Qty') . ' : ' . price($total_qty, 0, '', 0, 0);
- echo ' | ';
- $colspan = 2;
- }
- if(TSubtotal::isSubtotal($line) && getDolGlobalString('DISPLAY_MARGIN_ON_SUBTOTALS')) {
+ if (TSubtotal::isSubtotal($line) && getDolGlobalString('DISPLAY_MARGIN_ON_SUBTOTALS')) {
$colspan --;
- $style = getDolGlobalString('SUBTOTAL_TITLE_STYLE', '');
+ $style = getDolGlobalString('SUBTOTAL_TITLE_STYLE', '');
$titleStyleItalic = strpos($style, 'I') === false ? '' : ' font-style: italic;';
$titleStyleBold = strpos($style, 'B') === false ? '' : ' font-weight:bold;';
$titleStyleUnderline = strpos($style, 'U') === false ? '' : ' text-decoration: underline;';
@@ -3003,21 +3040,21 @@ function printObjectLine ($parameters, &$object, &$action, $hookmanager)
echo ' Marge :';
- $parentTitleLine = TSubtotal::getParentTitleOfLine($object, $line->rang);
- $productLines = TSubtotal::getLinesFromTitleId($object, $parentTitleLine->id);
+ $parentTitleLine = TSubtotal::getParentTitleOfLine($object, $line->rang);
+ $productLines = TSubtotal::getLinesFromTitleId($object, $parentTitleLine->id);
$totalCostPrice = 0;
- if(!empty($productLines)){
+ if (!empty($productLines)) {
foreach ($productLines as $l) {
$product = new Product($db);
$res = $product->fetch($l->fk_product);
- if($res) {
- $totalCostPrice += $product->cost_price * $l->qty;
+ if ($res) {
+ $totalCostPrice += $product->cost_price * $l->qty;
}
- }
+ }
}
- $marge = $total_line - $totalCostPrice;
+ $marge = $total_line - $totalCostPrice;
echo ' '.price($marge);
echo ' | ';
@@ -3026,100 +3063,90 @@ function printObjectLine ($parameters, &$object, &$action, $hookmanager)
- //SousTotal :
- $style = TSubtotal::isFreeText($line) ? '' : 'font-weight:bold;';
- $style.= $line->qty>90 ? 'text-align:right' : '';
-
- echo '';
- if (getDolGlobalString('SUBTOTAL_USE_NEW_FORMAT'))
- {
- if(TSubtotal::isTitle($line))
- {
- echo str_repeat(' ', max(floatval($line->qty) - 1, 0));
+ //SousTotal :
+ $style = TSubtotal::isFreeText($line) ? '' : 'font-weight:bold;';
+ $style.= $line->qty>90 ? 'text-align:right' : '';
- if (TSubtotal::isTitle($line)) print img_picto('', 'subtotal@subtotal').''.$line->qty.' ';
- else print img_picto('', 'subtotal2@subtotal').''.(100-$line->qty).' ';
- }
- }
- else
- {
- if($line->qty<=1) print img_picto('', 'subtotal@subtotal');
- else if($line->qty==2) print img_picto('', 'subsubtotal@subtotal').' ';
- }
+ echo ' | ';
+ if (getDolGlobalString('SUBTOTAL_USE_NEW_FORMAT')) {
+ if (TSubtotal::isTitle($line)) {
+ echo str_repeat(' ', max(floatval($line->qty) - 1, 0));
+ if (TSubtotal::isTitle($line)) print img_picto('', 'subtotal@subtotal').''.$line->qty.' ';
+ else print img_picto('', 'subtotal2@subtotal').''.(100-$line->qty).' ';
+ }
+ } else {
+ if ($line->qty<=1) print img_picto('', 'subtotal@subtotal');
+ elseif ($line->qty==2) print img_picto('', 'subsubtotal@subtotal').' ';
+ }
- // Get display styles and apply them
- $style = '';
- $style = TSubtotal::isFreeText($line) ? getDolGlobalString('SUBTOTAL_TEXT_LINE_STYLE', '') : getDolGlobalString('SUBTOTAL_TITLE_STYLE', '');
- $titleStyleItalic = strpos($style, 'I') === false ? '' : ' font-style: italic;';
- $titleStyleBold = strpos($style, 'B') === false ? '' : ' font-weight:bold;';
- $titleStyleUnderline = strpos($style, 'U') === false ? '' : ' text-decoration: underline;';
-
- if (empty($line->label)) {
- if ($line->qty >= 91 && $line->qty <= 99 && getDolGlobalString('CONCAT_TITLE_LABEL_IN_SUBTOTAL_LABEL')) print $line->description.' '.''.$this->getTitle($object, $line).'';
- else print ''.$line->description.'';
- }
- else {
- if (getDolGlobalString('PRODUIT_DESC_IN_FORM') && !empty($line->description)) {
- // on ne veut pas afficher le label et la description si elles sont identiques
- $lineLabel = $line->description != $line->label ? $line->label.'
'.dol_htmlentitiesbr($line->description) : $line->label ;
- print '' . $lineLabel . ' ';
- }
- else{
- print ''.$line->label.'';
- }
+ // Get display styles and apply them
+ $style = '';
+ $style = TSubtotal::isFreeText($line) ? getDolGlobalString('SUBTOTAL_TEXT_LINE_STYLE', '') : getDolGlobalString('SUBTOTAL_TITLE_STYLE', '');
+ $titleStyleItalic = strpos($style, 'I') === false ? '' : ' font-style: italic;';
+ $titleStyleBold = strpos($style, 'B') === false ? '' : ' font-weight:bold;';
+ $titleStyleUnderline = strpos($style, 'U') === false ? '' : ' text-decoration: underline;';
- }
- if (TSubtotal::isTitle($line)) {
- //Folder for expand
- $titleAttr = (array_key_exists('options_hideblock', $line->array_options) && $line->array_options['options_hideblock'] == 1) ? $langs->trans("Subtotal_Show") : $langs->trans("Subtotal_Hide");
+ if (empty($line->label)) {
+ if ($line->qty >= 91 && $line->qty <= 99 && getDolGlobalString('CONCAT_TITLE_LABEL_IN_SUBTOTAL_LABEL')) print $line->description.' '.$this->getTitle($object, $line).'';
+ else print ''.$line->description.'';
+ } else {
+ if (getDolGlobalString('PRODUIT_DESC_IN_FORM') && !empty($line->description)) {
+ // on ne veut pas afficher le label et la description si elles sont identiques
+ $lineLabel = $line->description != $line->label ? $line->label.'
'.dol_htmlentitiesbr($line->description) : $line->label ;
+ print '' . $lineLabel . ' ';
+ } else {
+ print ''.$line->label.'';
+ }
+ }
+ if (TSubtotal::isTitle($line)) {
+ //Folder for expand
+ $titleAttr = (array_key_exists('options_hideblock', $line->array_options) && $line->array_options['options_hideblock'] == 1) ? $langs->trans("Subtotal_Show") : $langs->trans("Subtotal_Hide");
- print '';
+ print '';
- // bouton pour ouvrir/fermer le bloc
- print ' ';
- print ((array_key_exists('options_hideblock', $line->array_options) && $line->array_options['options_hideblock'] == 1) ? img_picto('', 'folder') : img_picto('', 'folder-open'));
- print '';
+ // bouton pour ouvrir/fermer le bloc
+ print ' ';
+ print ((array_key_exists('options_hideblock', $line->array_options) && $line->array_options['options_hideblock'] == 1) ? img_picto('', 'folder') : img_picto('', 'folder-open'));
+ print '';
- // Bouton pour ouvrir/fermer aussi les enfants
- print ' ';
- print ((array_key_exists('options_hideblock', $line->array_options) && $line->array_options['options_hideblock'] == 1) ? img_picto('', 'folder') : img_picto('', 'folder-open'));
- print '';
+ // Bouton pour ouvrir/fermer aussi les enfants
+ print ' ';
+ print ((array_key_exists('options_hideblock', $line->array_options) && $line->array_options['options_hideblock'] == 1) ? img_picto('', 'folder') : img_picto('', 'folder-open'));
+ print '';
- // un span pour contenir des infos comme le nombre de lignes cachées etc...
- print ' ';
+ // un span pour contenir des infos comme le nombre de lignes cachées etc...
+ print ' ';
- print '';
- }
+ print '';
+ }
- if($line->qty>90) print ' : ';
- if($line->info_bits > 0) echo img_picto($langs->trans('Pagebreak'), 'pagebreak@subtotal');
- }
- ?>
+ if ($line->qty>90) print ' : ';
+ if ($line->info_bits > 0) echo img_picto($langs->trans('Pagebreak'), 'pagebreak@subtotal');
+ }
+ ?>
qty>90) {
-
- /* Total */
- echo ' | '.price($total_line).' | ';
- if (isModEnabled('multicurrency') && ($object->multicurrency_code != $conf->currency)) {
- echo ' | ';
- }
- } else {
- echo ' | ';
- if (isModEnabled('multicurrency') && ($object->multicurrency_code != $conf->currency)) {
- echo ' | ';
- }
+ if ($line->qty>90) {
+ /* Total */
+ echo ''.price($total_line).' | ';
+ if (isModEnabled('multicurrency') && ($object->multicurrency_code != $conf->currency)) {
+ echo ' | ';
+ }
+ } else {
+ echo ' | ';
+ if (isModEnabled('multicurrency') && ($object->multicurrency_code != $conf->currency)) {
+ echo ' | ';
}
+ }
?>
id && TSubtotal::isModSubtotalLine($line) ) {
+ if ($action=='editline' && GETPOST('lineid', 'int') == $line->id && TSubtotal::isModSubtotalLine($line) ) {
?>
@@ -3133,27 +3160,22 @@ function printObjectLine ($parameters, &$object, &$action, $hookmanager)
statut == 0 && $createRight && getDolGlobalString('SUBTOTAL_ALLOW_DUPLICATE_BLOCK') && $object->element !== 'invoice_supplier')
- {
- if(empty($line->fk_prev_id)) $line->fk_prev_id = null;
- if(TSubtotal::isTitle($line) && ( $line->fk_prev_id === null )) {
+ } else {
+ if ($object->statut == 0 && $createRight && getDolGlobalString('SUBTOTAL_ALLOW_DUPLICATE_BLOCK') && $object->element !== 'invoice_supplier') {
+ if (empty($line->fk_prev_id)) $line->fk_prev_id = null;
+ if (TSubtotal::isTitle($line) && ( $line->fk_prev_id === null )) {
echo '';
- echo '';
+ echo '';
echo '';
}
}
- if ($object->statut == 0 && $createRight && getDolGlobalString('SUBTOTAL_ALLOW_EDIT_BLOCK'))
- {
+ if ($object->statut == 0 && $createRight && getDolGlobalString('SUBTOTAL_ALLOW_EDIT_BLOCK')) {
echo ''.img_edit().'';
}
}
-
}
?>
@@ -3163,29 +3185,24 @@ function printObjectLine ($parameters, &$object, &$action, $hookmanager)
statut == 0 && $createRight && !empty(getDolGlobalString('SUBTOTAL_ALLOW_REMOVE_BLOCK')))
- {
- if(empty($line->fk_prev_id)) $line->fk_prev_id = null;
- if (!isset($line->fk_prev_id) || $line->fk_prev_id === null)
- {
- echo ''.img_delete().'';
- }
-
- if(TSubtotal::isTitle($line) && (!isset($line->fk_prev_id) || (isset($line->fk_prev_id) && ($line->fk_prev_id === null))) )
- {
+ if ($object->statut == 0 && $createRight && !empty(getDolGlobalString('SUBTOTAL_ALLOW_REMOVE_BLOCK'))) {
+ if (empty($line->fk_prev_id)) $line->fk_prev_id = null;
+ if (!isset($line->fk_prev_id) || $line->fk_prev_id === null) {
+ echo ''.img_delete().'';
+ }
- $img_delete = img_delete($langs->trans('deleteWithAllLines'), ' style="color:#be3535 !important;" class="pictodelete pictodeleteallline"');
+ if (TSubtotal::isTitle($line) && (!isset($line->fk_prev_id) || (isset($line->fk_prev_id) && ($line->fk_prev_id === null))) ) {
+ $img_delete = img_delete($langs->trans('deleteWithAllLines'), ' style="color:#be3535 !important;" class="pictodelete pictodeleteallline"');
- echo ''.$img_delete.'';
- }
+ echo ''.$img_delete.'';
}
}
+ }
?>
|
statut == 0 && $createRight && !empty(getDolGlobalString('SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS')) && TSubtotal::isTitle($line) && $action != 'editline' && $action != 'selectlines')
- {
+ if ($object->statut == 0 && $createRight && !empty(getDolGlobalString('SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS')) && TSubtotal::isTitle($line) && $action != 'editline' && $action != 'selectlines') {
echo '';
echo 'array_options['options_subtotal_nc']) ? 'checked="checked"' : '').' />';
echo ' | ';
@@ -3202,12 +3219,11 @@ function printObjectLine ($parameters, &$object, &$action, $hookmanager)
status == $object::STATUS_DRAFT && $usercandelete && in_array($object->element,$Telement)|| $action == 'selectlines' ) { // dolibarr 8
-
+ if (!empty(getDolGlobalString('MASSACTION_CARD_ENABLE_SELECTLINES')) && $object->status == $object::STATUS_DRAFT && $usercandelete && in_array($object->element, $Telement)|| $action == 'selectlines' ) { // dolibarr 8
if ($action !== 'editline' && GETPOST('lineid', 'int') !== $line->id) {
$checked = '';
- if (!empty($toselect) && in_array($line->id,$toselect)){
+ if (!empty($toselect) && in_array($line->id, $toselect)) {
$checked = 'checked';
}
@@ -3225,8 +3241,7 @@ function printObjectLine ($parameters, &$object, &$action, $hookmanager)
// Affichage des extrafields à la Dolibarr (car sinon non affiché sur les titres)
- if(TSubtotal::isTitle($line) && getDolGlobalString('SUBTOTAL_ALLOW_EXTRAFIELDS_ON_TITLE')) {
-
+ if (TSubtotal::isTitle($line) && getDolGlobalString('SUBTOTAL_ALLOW_EXTRAFIELDS_ON_TITLE')) {
require_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php';
// Extrafields
@@ -3234,20 +3249,20 @@ function printObjectLine ($parameters, &$object, &$action, $hookmanager)
$extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line);
$colspan+=3; $mode = 'view';
- if($action === 'editline' && $line->rowid == GETPOST('lineid', 'int')) $mode = 'edit';
+ if ($action === 'editline' && $line->rowid == GETPOST('lineid', 'int')) $mode = 'edit';
$ex_element = $line->element;
$line->element = 'tr_extrafield_title '.$line->element; // Pour pouvoir manipuler ces tr
print $line->showOptionals($extrafieldsline, $mode, array('style'=>' style="background:#eeffee;" ','colspan'=>$colspan));
$isExtraSelected = false;
- foreach($line->array_options as $option) {
- if(!empty($option) && $option != "-1") {
+ foreach ($line->array_options as $option) {
+ if (!empty($option) && $option != "-1") {
$isExtraSelected = true;
break;
}
}
- if($mode === 'edit') {
+ if ($mode === 'edit') {
?>
'; // used also for subtotal.lib.js
- if(!getDolGlobalString('SUBTOTAL_DISABLE_SUMMARY')){
+ if (!getDolGlobalString('SUBTOTAL_DISABLE_SUMMARY')) {
$jsConfig = array(
'langs' => array(
'SubtotalSummaryTitle' => $langs->trans('QuickSummary')
@@ -3804,14 +3787,22 @@ function callAjaxUpdateLineNC(set, lineid, subtotal_nc)
return 0;
}
- function afterPDFCreation($parameters, &$pdf, &$action, $hookmanager)
+ /**
+ * After PDF creation
+ *
+ * @param array $parameters Parameters
+ * @param TCPDF $pdf PDF
+ * @param string $action Action
+ * @param HookManager $hookmanager Hook manager
+ * @return int
+ */
+ public function afterPDFCreation($parameters, &$pdf, &$action, $hookmanager)
{
global $conf;
$object = $parameters['object'];
- if ((getDolGlobalString('SUBTOTAL_PROPAL_ADD_RECAP') && $object->element == 'propal') || (getDolGlobalString('SUBTOTAL_COMMANDE_ADD_RECAP') && $object->element == 'commande') || (getDolGlobalString('SUBTOTAL_INVOICE_ADD_RECAP') && $object->element == 'facture'))
- {
+ if ((getDolGlobalString('SUBTOTAL_PROPAL_ADD_RECAP') && $object->element == 'propal') || (getDolGlobalString('SUBTOTAL_COMMANDE_ADD_RECAP') && $object->element == 'commande') || (getDolGlobalString('SUBTOTAL_INVOICE_ADD_RECAP') && $object->element == 'facture')) {
if (GETPOST('subtotal_add_recap', 'none')) {
dol_include_once('/subtotal/class/subtotal.class.php');
TSubtotal::addRecapPage($parameters, $pdf);
@@ -3821,114 +3812,131 @@ function afterPDFCreation($parameters, &$pdf, &$action, $hookmanager)
return 0;
}
- /** Overloading the getlinetotalremise function : replacing the parent's function with the one below
- * @param $parameters array meta datas of the hook (context, etc...)
- * @param $object CommonObject the object you want to process (an invoice if you are in invoice module, a propale in propale's module, etc...)
- * @param $action string current action (if set). Generally create or edit or null
- * @param $hookmanager HookManager current hook manager
- * @return void
+ /**
+ * Overloading the getlinetotalremise function : replacing the parent's function with the one below
+ *
+ * @param array $parameters Meta datas of the hook (context, etc...)
+ * @param CommonObject $object The object you want to process (an invoice if you are in invoice module, a propale in propale's module, etc...)
+ * @param string $action Current action (if set). Generally create or edit or null
+ * @param HookManager $hookmanager Current hook manager
+ * @return int
*/
- function getlinetotalremise($parameters, &$object, &$action, $hookmanager)
+ // phpcs:disable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
+ public function getlinetotalremise($parameters, &$object, &$action, $hookmanager)
{
- // Si c'est une ligne de sous-total, la méthode pdfGetLineTotalDiscountAmount ne doit rien renvoyer
- if (!empty($object->lines[$parameters['i']]) && TSubtotal::isModSubtotalLine($object->lines[$parameters['i']])) {
- $this->resprints = '';
- $this->results = [];
+ // Si c'est une ligne de sous-total, la méthode pdfGetLineTotalDiscountAmount ne doit rien renvoyer
+ if (!empty($object->lines[$parameters['i']]) && TSubtotal::isModSubtotalLine($object->lines[$parameters['i']])) {
+ $this->resprints = '';
+ $this->results = [];
- return 1;
- }
+ return 1;
+ }
- return 0;
- }
+ return 0;
+ }
// HTML 5 data for js
- private function _getHtmlData($parameters, &$object, &$action, $hookmanager)
+ /**
+ * Get HTML data
+ *
+ * @param array $parameters Parameters
+ * @param CommonObject $object Object
+ * @param string $action Action
+ * @param HookManager $hookmanager Hook manager
+ * @return string
+ */
+ private function getHtmlData($parameters, &$object, &$action, $hookmanager)
{
dol_include_once('/subtotal/class/subtotal.class.php');
- $line = &$parameters['line'];
+ $line = &$parameters['line'];
- $ThtmlData['data-id'] = $line->id;
- $ThtmlData['data-product_type'] = $line->product_type;
- $ThtmlData['data-qty'] = 0; //$line->qty;
- $ThtmlData['data-level'] = TSubtotal::getNiveau($line);
+ $ThtmlData['data-id'] = $line->id;
+ $ThtmlData['data-product_type'] = $line->product_type;
+ $ThtmlData['data-qty'] = 0; //$line->qty;
+ $ThtmlData['data-level'] = TSubtotal::getNiveau($line);
- if(TSubtotal::isTitle($line)){
- $ThtmlData['data-issubtotal'] = 'title';
+ if (TSubtotal::isTitle($line)) {
+ $ThtmlData['data-issubtotal'] = 'title';
$ThtmlData['data-folder-status'] = 'open';
- if(!empty($line->array_options['options_hideblock'])){
+ if (!empty($line->array_options['options_hideblock'])) {
$ThtmlData['data-folder-status'] = 'closed';
}
- }elseif(TSubtotal::isSubtotal($line)){
- $ThtmlData['data-issubtotal'] = 'subtotal';
- }
- else{
- $ThtmlData['data-issubtotal'] = 'freetext';
- }
-
- // Change or add data from hooks
- $parameters = array_replace($parameters , array( 'ThtmlData' => $ThtmlData ) );
-
- // hook
- $reshook = $hookmanager->executeHooks('subtotalLineHtmlData',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
- if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
- if ($reshook>0)
- {
- $ThtmlData = $this->results;
- }
-
- return $this->implodeHtmlData($ThtmlData);
+ } elseif (TSubtotal::isSubtotal($line)) {
+ $ThtmlData['data-issubtotal'] = 'subtotal';
+ } else {
+ $ThtmlData['data-issubtotal'] = 'freetext';
+ }
+
+ // Change or add data from hooks
+ $parameters = array_replace($parameters, array( 'ThtmlData' => $ThtmlData ));
+
+ // hook
+ $reshook = $hookmanager->executeHooks('subtotalLineHtmlData', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
+ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
+ if ($reshook>0) {
+ $ThtmlData = $this->results;
+ }
+ return $this->implodeHtmlData($ThtmlData);
}
- function implodeHtmlData($ThtmlData = array())
+ /**
+ * Implode HTML data
+ *
+ * @param array $ThtmlData HTML data
+ * @return string
+ */
+ public function implodeHtmlData($ThtmlData = array())
{
- $data = '';
- foreach($ThtmlData as $k => $h )
- {
- if(is_array($h))
- {
- $h = json_encode($h);
- }
-
- $data .= $k . '="'.dol_htmlentities($h, ENT_QUOTES).'" ';
- }
-
- return $data;
+ $data = '';
+ foreach ($ThtmlData as $k => $h) {
+ if (is_array($h)) {
+ $h = json_encode($h);
+ }
+
+ $data .= $k . '="'.dol_htmlentities($h, ENT_QUOTES).'" ';
+ }
+
+ return $data;
}
- function _ajax_block_order_js($object)
+ /**
+ * Ajax block order JS
+ *
+ * @param CommonObject $object Object
+ * @return void
+ */
+ public function ajaxBlockOrderJs($object)
{
- global $conf,$tagidfortablednd,$filepath,$langs;
+ global $conf,$tagidfortablednd,$filepath,$langs;
- /*
- * this part of js is base on dolibarr htdocs/core/tpl/ajaxrow.tpl.php
- * for compatibility reasons we don't use tableDnD but jquery sortable
- */
-
- $id=$object->id;
- $nboflines=(isset($object->lines)?count($object->lines):0);
- $forcereloadpage=!getDolGlobalString('MAIN_FORCE_RELOAD_PAGE')?0:1;
+ /*
+ * this part of js is base on dolibarr htdocs/core/tpl/ajaxrow.tpl.php
+ * for compatibility reasons we don't use tableDnD but jquery sortable
+ */
- $id=$object->id;
- $fk_element=$object->fk_element;
- $table_element_line=$object->table_element_line;
- $nboflines=(isset($object->lines)?count($object->lines):(empty($nboflines)?0:$nboflines));
- $tagidfortablednd=(empty($tagidfortablednd)?'tablelines':$tagidfortablednd);
- $filepath=(empty($filepath)?'':$filepath);
+ $id=$object->id;
+ $nboflines=(isset($object->lines)?count($object->lines):0);
+ $forcereloadpage=!getDolGlobalString('MAIN_FORCE_RELOAD_PAGE')?0:1;
+ $id=$object->id;
+ $fk_element=$object->fk_element;
+ $table_element_line=$object->table_element_line;
+ $nboflines=(isset($object->lines)?count($object->lines):(empty($nboflines)?0:$nboflines));
+ $tagidfortablednd=(empty($tagidfortablednd)?'tablelines':$tagidfortablednd);
+ $filepath=(empty($filepath)?'':$filepath);
- if (GETPOST('action','aZ09') != 'editline' && $nboflines > 1)
- {
+ if (GETPOST('action', 'aZ09') != 'editline' && $nboflines > 1) {
$jsConf = array(
'useOldSplittedTrForLine' => intval(DOL_VERSION) < 16 ? 1 : 0,
);
print '';
- ?>
+ ?>
- addline($parameters['TEnt_comm'][$object->order->id], $parameters['line']->id, $parameters['line']->qty);
- getDolGlobalString('STOCK_MUST_BE_ENOUGH_FOR_SHIPMENT', $confOld);
- }
-
- }
-
- }
+ /**
+ * Handle expedition title and total
+ *
+ * @param array $parameters Parameters
+ * @param CommonObject $object Object
+ * @param string $action Action
+ * @param HookManager $hookmanager Hook manager
+ * @return void
+ */
+ public function handleExpeditionTitleAndTotal($parameters, &$object, &$action, $hookmanager)
+ {
+ global $conf;
+ //var_dump($parameters['line']);
+ dol_include_once('subtotal/class/subtotal.class.php');
+ $currentcontext = explode(':', $parameters['context']);
+
+ if ( in_array('shippableorderlist', $currentcontext)) {
+ //var_dump($parameters['line']);
+ if (TSubtotal::isModSubtotalLine($parameters['line'])) {
+ $confOld = getDolGlobalString('STOCK_MUST_BE_ENOUGH_FOR_SHIPMENT');
+ getDolGlobalString('STOCK_MUST_BE_ENOUGH_FOR_SHIPMENT', 0);
+ $res = $parameters['shipping']->addline($parameters['TEnt_comm'][$object->order->id], $parameters['line']->id, $parameters['line']->qty);
+ getDolGlobalString('STOCK_MUST_BE_ENOUGH_FOR_SHIPMENT', $confOld);
+ }
+ }
+ }
/**
* Overloading the defineColumnField function
@@ -4099,18 +4103,20 @@ public function defineColumnField($parameters, &$pdfDoc, &$action, $hookmanager)
$parameters['object']->context['subtotalPdfModelInfo']->page_largeur = $pdfDoc->page_largeur;
$parameters['object']->context['subtotalPdfModelInfo']->page_hauteur = $pdfDoc->page_hauteur;
$parameters['object']->context['subtotalPdfModelInfo']->format = $pdfDoc->format;
- if (property_exists($pdfDoc, 'context') && array_key_exists('subtotalPdfModelInfo', $pdfDoc->context) && is_object($pdfDoc->context['subtotalPdfModelInfo'])) {
- $parameters['object']->context['subtotalPdfModelInfo']->defaultTitlesFieldsStyle = $pdfDoc->context['subtotalPdfModelInfo']->defaultTitlesFieldsStyle;
- $parameters['object']->context['subtotalPdfModelInfo']->defaultContentsFieldsStyle = $pdfDoc->context['subtotalPdfModelInfo']->defaultContentsFieldsStyle;
- }
+ if (property_exists($pdfDoc, 'context') && array_key_exists('subtotalPdfModelInfo', $pdfDoc->context) && is_object($pdfDoc->context['subtotalPdfModelInfo'])) {
+ $parameters['object']->context['subtotalPdfModelInfo']->defaultTitlesFieldsStyle = $pdfDoc->context['subtotalPdfModelInfo']->defaultTitlesFieldsStyle;
+ $parameters['object']->context['subtotalPdfModelInfo']->defaultContentsFieldsStyle = $pdfDoc->context['subtotalPdfModelInfo']->defaultContentsFieldsStyle;
+ }
return 0;
}
/**
* Add a checkbox on the bill orders forms (either the old orderstoinvoice or the new mass
* action) to create a title block per invoiced order when creating one invoice per client.
+ *
+ * @return void
*/
- private function _billOrdersAddCheckBoxForTitleBlocks()
+ private function billOrdersAddCheckBoxForTitleBlocks()
{
global $delayedhtmlcontent, $langs, $conf;
@@ -4161,114 +4167,118 @@ private function _billOrdersAddCheckBoxForTitleBlocks()
* @param HookManager $hookmanager Hook manager propagated to allow calling another hook
* @return int < 0 on error, 0 on success, 1 to replace standard code
*/
- public function afterCreationOfRecurringInvoice($parameters, &$object, &$action, $hookmanager){
- require_once __DIR__ . '/subtotal.class.php';
- $TSub = new TSubtotal;
- $TSub->generateDoc($object);
- return 0;
- }
+ public function afterCreationOfRecurringInvoice($parameters, &$object, &$action, $hookmanager)
+ {
+ require_once __DIR__ . '/subtotal.class.php';
+ $TSub = new TSubtotal;
+ $TSub->generateDoc($object);
+ return 0;
+ }
+ /**
+ * Print common footer
+ *
+ * @param array $parameters Parameters
+ * @param CommonObject $objectHook Object hook
+ * @param string $action Action
+ * @param HookManager $hookmanager Hook manager
+ * @return int
+ */
public function printCommonFooter(&$parameters, &$objectHook, &$action, $hookmanager)
{
global $langs, $db, $conf;
- $contextArray = explode(':',$parameters['context']);
+ $contextArray = explode(':', $parameters['context']);
/**Gestion des dossiers qui permettent de réduire un bloc**/
- if (
- in_array('invoicecard',$contextArray)
- || in_array('invoicesuppliercard',$contextArray)
- || in_array('propalcard',$contextArray)
- || in_array('ordercard',$contextArray)
- || in_array('ordersuppliercard',$contextArray)
- || in_array('invoicereccard',$contextArray)
- )
- {
- //On récupère les informations de l'objet actuel
- $id = GETPOST('id', 'int');
- if(empty($id)) $id = GETPOST('facid', 'int');
-
- //On détermine l'élement concernée en fonction du contexte
- $TCurrentContexts = explode('card', $parameters['currentcontext']);
- /**
- * TODO John le 11/08/2023 : Je trouve bizarre d'utiliser le contexte pour déterminer la class de l'objet alors
- * que l'objet est passé en paramètres ça doit être due à de vielle versions de Dolibarr ou une compat avec un module externe...
- * Cette methode de chargement d'objet a causée une fatale car la classe de l'objet correspondant au contexte n'était pas chargé ce qui n'est pas logique...
- * La logique voudrait que l'on utilise $object->element
- * Cependant si on regarde plus loin $object qui est passé en référence dans les paramètres de cette méthode est remplacé quelques lignes plus bas.
- */
- if($TCurrentContexts[0] == 'order'){
- $element = 'Commande';
- if(!class_exists($element)){ require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';}
- }
- elseif($TCurrentContexts[0] == 'invoice'){
- $element = 'Facture';
- if(!class_exists($element)){ require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php';}
- }
- elseif($TCurrentContexts[0] == 'invoicesupplier'){
- $element = 'FactureFournisseur';
- if(!class_exists($element)){ require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.facture.class.php';}
- }
- elseif($TCurrentContexts[0] == 'ordersupplier'){
- $element = 'CommandeFournisseur';
- if(!class_exists($element)){ require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.commande.class.php';}
- }
- elseif($TCurrentContexts[0] == 'invoicerec'){
- $element = 'FactureRec';
- if(!class_exists($element)){ require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture-rec.class.php';}
- }
- else $element = $TCurrentContexts[0];
-
-
- if(!class_exists($element)){
- // Pour éviter la fatale sur une page d'un module externe qui utiliserait un nom de context de Dolibarr mais qui
- $this->error = $langs->trans('ErrorClassXNotExists', $element);
- return -1;
- }
+ if (
+ in_array('invoicecard', $contextArray)
+ || in_array('invoicesuppliercard', $contextArray)
+ || in_array('propalcard', $contextArray)
+ || in_array('ordercard', $contextArray)
+ || in_array('ordersuppliercard', $contextArray)
+ || in_array('invoicereccard', $contextArray)
+ ) {
+ //On récupère les informations de l'objet actuel
+ $id = GETPOST('id', 'int');
+ if (empty($id)) $id = GETPOST('facid', 'int');
+
+ //On détermine l'élement concernée en fonction du contexte
+ $TCurrentContexts = explode('card', $parameters['currentcontext']);
+ /**
+ * TODO John le 11/08/2023 : Je trouve bizarre d'utiliser le contexte pour déterminer la class de l'objet alors
+ * que l'objet est passé en paramètres ça doit être due à de vielle versions de Dolibarr ou une compat avec un module externe...
+ * Cette methode de chargement d'objet a causée une fatale car la classe de l'objet correspondant au contexte n'était pas chargé ce qui n'est pas logique...
+ * La logique voudrait que l'on utilise $object->element
+ * Cependant si on regarde plus loin $object qui est passé en référence dans les paramètres de cette méthode est remplacé quelques lignes plus bas.
+ */
+ if ($TCurrentContexts[0] == 'order') {
+ $element = 'Commande';
+ if (!class_exists($element)) { require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';}
+ } elseif ($TCurrentContexts[0] == 'invoice') {
+ $element = 'Facture';
+ if (!class_exists($element)) { require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php';}
+ } elseif ($TCurrentContexts[0] == 'invoicesupplier') {
+ $element = 'FactureFournisseur';
+ if (!class_exists($element)) { require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.facture.class.php';}
+ } elseif ($TCurrentContexts[0] == 'ordersupplier') {
+ $element = 'CommandeFournisseur';
+ if (!class_exists($element)) { require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.commande.class.php';}
+ } elseif ($TCurrentContexts[0] == 'invoicerec') {
+ $element = 'FactureRec';
+ if (!class_exists($element)) { require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture-rec.class.php';}
+ } else $element = $TCurrentContexts[0];
+
+
+ if (!class_exists($element)) {
+ // Pour éviter la fatale sur une page d'un module externe qui utiliserait un nom de context de Dolibarr mais qui
+ $this->error = $langs->trans('ErrorClassXNotExists', $element);
+ return -1;
+ }
- $object = new $element($db);
- $object->fetch($id);
+ $object = new $element($db);
+ $object->fetch($id);
- //On récupère tous les titres sous-total
- $TLines = TSubtotal::getAllTitleFromDocument($object);
+ //On récupère tous les titres sous-total
+ $TLines = TSubtotal::getAllTitleFromDocument($object);
- //On définit quels sont les blocs à cacher en fonction des données existantes (hideblock)
+ //On définit quels sont les blocs à cacher en fonction des données existantes (hideblock)
$TBlocksToHide = array();
- if(!empty($TLines)) {
- foreach ($TLines as $line) {
- if (array_key_exists('options_hideblock', $line->array_options) && $line->array_options['options_hideblock']) $TBlocksToHide[] = $line->id;
- }
+ if (!empty($TLines)) {
+ foreach ($TLines as $line) {
+ if (array_key_exists('options_hideblock', $line->array_options) && $line->array_options['options_hideblock']) $TBlocksToHide[] = $line->id;
}
+ }
- $hideMode = getDolGlobalString('SUBTOTAL_BLOC_FOLD_MODE', 'default');
- if(!in_array($hideMode, array('default', 'keepTitle'))){
- $hideMode = 'default';
- }
+ $hideMode = getDolGlobalString('SUBTOTAL_BLOC_FOLD_MODE', 'default');
+ if (!in_array($hideMode, array('default', 'keepTitle'))) {
+ $hideMode = 'default';
+ }
- $jsConf = array(
- 'linesToHide' => $TBlocksToHide,
- 'hideFoldersByDefault' => getDolGlobalInt('SUBTOTAL_HIDE_FOLDERS_BY_DEFAULT'),
- 'closeMode' => $hideMode, // default, keepTitle
- 'interfaceUrl'=> dol_buildpath('/subtotal/script/interface.php', 1),
- 'element' => $element,
- 'element_id' => $id,
- 'img_folder_closed' => img_picto('', 'folder'),
- 'img_folder_open' => img_picto('', 'folder-open'),
- 'langs' => array(
- 'Subtotal_HideAll' => $langs->transnoentities("Subtotal_HideAll"),
- 'Subtotal_ShowAll' => $langs->transnoentities("Subtotal_ShowAll"),
- 'Subtotal_Hide' => $langs->transnoentities("Subtotal_Hide"),
- 'Subtotal_Show' => $langs->transnoentities("Subtotal_Show"),
- 'Subtotal_ForceHideAll' => $langs->transnoentities("Subtotal_ForceHideAll"),
- 'Subtotal_ForceShowAll' => $langs->transnoentities("Subtotal_ForceShowAll")
- )
- );
+ $jsConf = array(
+ 'linesToHide' => $TBlocksToHide,
+ 'hideFoldersByDefault' => getDolGlobalInt('SUBTOTAL_HIDE_FOLDERS_BY_DEFAULT'),
+ 'closeMode' => $hideMode, // default, keepTitle
+ 'interfaceUrl'=> dol_buildpath('/subtotal/script/interface.php', 1),
+ 'element' => $element,
+ 'element_id' => $id,
+ 'img_folder_closed' => img_picto('', 'folder'),
+ 'img_folder_open' => img_picto('', 'folder-open'),
+ 'langs' => array(
+ 'Subtotal_HideAll' => $langs->transnoentities("Subtotal_HideAll"),
+ 'Subtotal_ShowAll' => $langs->transnoentities("Subtotal_ShowAll"),
+ 'Subtotal_Hide' => $langs->transnoentities("Subtotal_Hide"),
+ 'Subtotal_Show' => $langs->transnoentities("Subtotal_Show"),
+ 'Subtotal_ForceHideAll' => $langs->transnoentities("Subtotal_ForceHideAll"),
+ 'Subtotal_ForceShowAll' => $langs->transnoentities("Subtotal_ForceShowAll")
+ )
+ );
- print '';
+ print '';
- ?>
+ ?>