Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions admin/infrastructuresetup.php
Original file line number Diff line number Diff line change
Expand Up @@ -248,11 +248,11 @@ function infrastructureResetSelect2Width($container) {
infrastructure_print_subTitle(4, 'InfrastructureSetupForExtrafields');
$metas = ['class' => 'flat infrastructurewidth270 infrastructurefontsizeinherit'];
$num = infrastructure_print_input('INFRASTRUCTURE_ALLOW_EXTRAFIELDS_ON_TITLE', 'on_off', $langs->trans('InfrastructureAllowExtrafieldsOnTitle'), '', [], 2, 1, '', $num);
$metas = $form->multiselectarray('INFRASTRUCTURE_LIST_OF_EXTRAFIELDS_PROPALDET', $extrafields->fetch_name_optionals_label('propaldet'), $propalSelected, 0, 0, 'flat infrastructurewidth270 infrastructurefontsizeinherit', 0, 0, '', '', '');
$metas = $form->multiselectarray('INFRASTRUCTURE_LIST_OF_EXTRAFIELDS_PROPALDET', getVisibleExtrafields('propaldet'), $propalSelected, 0, 0, 'flat infrastructurewidth270 infrastructurefontsizeinherit', 0, 0, '', '', '');
$num = infrastructure_print_input('', 'select', $langs->trans('InfrastructureListOfExtrafieldsPropaldet'), '', $metas, 1, 2, '', $num);
$metas = $form->multiselectarray('INFRASTRUCTURE_LIST_OF_EXTRAFIELDS_COMMANDEDET', $extrafields->fetch_name_optionals_label('commandedet'), $orderSelected, 0, 0, 'flat infrastructurewidth270 infrastructurefontsizeinherit', 0, 0, '', '', '');
$metas = $form->multiselectarray('INFRASTRUCTURE_LIST_OF_EXTRAFIELDS_COMMANDEDET', getVisibleExtrafields('commandedet'), $orderSelected, 0, 0, 'flat infrastructurewidth270 infrastructurefontsizeinherit', 0, 0, '', '', '');
$num = infrastructure_print_input('', 'select', $langs->trans('InfrastructureListOfExtrafieldsCommandedet'), '', $metas, 1, 2, '', $num);
$metas = $form->multiselectarray('INFRASTRUCTURE_LIST_OF_EXTRAFIELDS_FACTUREDET', $extrafields->fetch_name_optionals_label('facturedet'), $invoiceSelected, 0, 0, 'flat infrastructurewidth270 infrastructurefontsizeinherit', 0, 0, '', '', '');
$metas = $form->multiselectarray('INFRASTRUCTURE_LIST_OF_EXTRAFIELDS_FACTUREDET', getVisibleExtrafields('facturedet'), $invoiceSelected, 0, 0, 'flat infrastructurewidth270 infrastructurefontsizeinherit', 0, 0, '', '', '');
$num = infrastructure_print_input('', 'select', $langs->trans('InfrastructureListOfExtrafieldsFacturedet'), '', $metas, 1, 2, '', $num);
// num = 10
infrastructure_print_subTitle(4, 'InfrastructureSetupForShipping');
Expand Down
4 changes: 1 addition & 3 deletions class/actions_infrastructure.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -360,9 +360,7 @@ public function formBuilddocOptions($parameters, &$object, &$action, HookManager
if (($object instanceof Propal && getDolGlobalString('INFRASTRUCTURE_PROPAL_ADD_RECAP')) ||
($object instanceof Commande && getDolGlobalString('INFRASTRUCTURE_COMMANDE_ADD_RECAP')) ||
($object instanceof Facture && getDolGlobalString('INFRASTRUCTURE_INVOICE_ADD_RECAP')) ||
($object instanceof FactureRec && getDolGlobalString('INFRASTRUCTURE_INVOICE_ADD_RECAP')) ||
($object instanceof CommandeFournisseur && getDolGlobalString('INFRASTRUCTURE_COMMANDE_ADD_RECAP')) ||
($object instanceof FactureFournisseur && getDolGlobalString('INFRASTRUCTURE_INVOICE_ADD_RECAP')))
($object instanceof FactureRec && getDolGlobalString('INFRASTRUCTURE_INVOICE_ADD_RECAP')))
{
$this->resprints .= ' <tr class = "oddeven infrastructurefoldable">
<td colspan = "'.$colspan.'" class = "right">
Expand Down
18 changes: 8 additions & 10 deletions class/infrastructure.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,29 +146,27 @@ static function showQtyForObjectLine($line, $show_by_default = false)
*/
static function addInfrastructureLine(&$object, $label, $qty, $rang=-1, $desc = '')
{
$res = 0;
$desc = '';
$TNotElements = ['invoice_supplier', 'order_supplier'];
$res = 0;
$desc = '';
$TNotElements = ['invoice_supplier', 'order_supplier'];
if ($qty == 50 && !in_array($object->element, $TNotElements)) {
$desc = $label;
$label = '';
$desc = $label;
$label = '';
}
if ($object->element=='facture') {
$res = $object->addline($desc, 0, $qty, 0, 0, 0, 0, 0, '', '', 0, 0, 0, 'HT', 0, 9, $rang, TInfrastructure::getModuleNumber(), '', 0, 0, null, 0, $label);
} elseif ($object->element=='invoice_supplier') {
$object->special_code = TInfrastructure::getModuleNumber();
$res = $object->addline($label, 0, 0, 0, 0, $qty, 0, 0, 0, 0, 0, 0, 'HT', 9, $rang, false, [], null, 0, 0, '', TInfrastructure::getModuleNumber());
$res = $object->addline($label, 0, 0, 0, 0, $qty, 0, 0, 0, 0, 0, 0, 'HT', 9, $rang, false, [], null, 0, 0, '', TInfrastructure::getModuleNumber());
} elseif ($object->element=='propal') {
$res = $object->addline($desc, 0, $qty, 0, 0, 0, 0, 0, 'HT', 0, 0, 9, $rang, TInfrastructure::getModuleNumber(), 0, 0, 0, $label);
} elseif ($object->element=='supplier_proposal') {
$res = $object->addline($desc, 0, $qty, 0, 0, 0, 0, 0, 'HT', 0, 0, 9, $rang, TInfrastructure::getModuleNumber(), 0, 0, 0, $label);
} elseif ($object->element=='commande') {
$res = $object->addline($desc, 0, $qty, 0, 0, 0, 0, 0, 0, 0, 'HT', 0, '', '', 9, $rang, TInfrastructure::getModuleNumber(), 0, null, 0, $label);
} elseif ($object->element=='order_supplier') {
$object->special_code = TInfrastructure::getModuleNumber(); // à garder pour la rétrocompatibilité
$res = $object->addline($label, 0, $qty, 0, 0, 0, 0, 0, '', 0, 'HT', 0, 9, 0, false, null, null, 0, null, 0, '', 0, -1, TInfrastructure::getModuleNumber());
$res = $object->addline($label, 0, $qty, 0, 0, 0, 0, 0, '', 0, 'HT', 0, 9, 0, false, null, null, 0, null, 0, '', 0, $rang, TInfrastructure::getModuleNumber());
} elseif ($object->element=='facturerec') {
$res = $object->addline($desc, 0, $qty, 0, 0, 0, 0, 0, 'HT', 0, '', 0, 9, $rang, TInfrastructure::getModuleNumber(), $label);
$res = $object->addline($desc, 0, $qty, 0, 0, 0, 0, 0, 'HT', 0, '', 0, 9, $rang, TInfrastructure::getModuleNumber(), $label);
}
self::generateDoc($object);
return $res;
Expand Down
62 changes: 46 additions & 16 deletions core/lib/infrastructure.lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,26 @@ function infrastructure_addNumerotation(&$object)
}
}

/**
* List extrafields with "list"(Visible field) attribute > 0 for a given element type (propaldet, commandedet, ...)
*
* @param string $elementtype Element type (propaldet, commandedet, facturedet, ...)
* @return array List of extrafields [fieldname => label]
*/
function getVisibleExtrafields($elementtype) {
global $db;

$extrafields = new ExtraFields($db);
$all = $extrafields->fetch_name_optionals_label($elementtype);
$list = [];
foreach ($all as $key => $label) {
if ((int) ($extrafields->attributes[$elementtype]['list'][$key] ?? 0) > 0) {
$list[$key] = $label;
}
}
return $list;
}

/**
* Ajax block order JS
*
Expand Down Expand Up @@ -229,10 +249,10 @@ function infrastructure_billOrdersAddCheckBoxForTitleBlocks()

ob_start();
$jsConf = ['langs' => ['AddTitleBlocFromOrdersToInvoice' => $langs->trans('InfrastructureAddTitleBlocFromOrderstoinvoice'),
'AddShippingListToTile' => $langs->trans('InfrastructureAddShippingListToTile'),
'InfrastructureOptions' => $langs->trans('InfrastructureOptions'),
'UseHiddenConfToAutoCheck' => $langs->trans('InfrastructureUseHiddenConfToAutoCheck'),
],
'AddShippingListToTile' => $langs->trans('InfrastructureAddShippingListToTile'),
'InfrastructureOptions' => $langs->trans('InfrastructureOptions'),
'UseHiddenConfToAutoCheck' => $langs->trans('InfrastructureUseHiddenConfToAutoCheck'),
],
'isModShippingEnable' => isModEnabled('expedition'),
'INFRASTRUCTURE_DEFAULT_CHECK_SHIPPING_LIST_FOR_TITLE_DESC' => getDolGlobalInt('INFRASTRUCTURE_DEFAULT_CHECK_SHIPPING_LIST_FOR_TITLE_DESC')
];
Expand Down Expand Up @@ -753,15 +773,11 @@ function infrastructure_updateInfrastructureLine(&$object, &$line)
}
// TODO ajouter la partie fournisseur
if (!empty($TKey)) {
$extrafields = new ExtraFields($object->db);
$extrafields->fetch_name_optionals_label($line->element);
$TPost = $extrafields->getOptionalsFromPost($line->element, '', 'infrastructure_');
$TLine = TInfrastructure::getLinesFromTitleId($object, $line->id);
$TLine = TInfrastructure::getLinesFromTitleId($object, $line->id);
foreach ($TLine as $object_line) {
foreach ($TKey as $key) {
// TODO remove "true"
if (isset($TPost['infrastructure_options_'.$key])) {
$object_line->array_options['options_'.$key] = $TPost['infrastructure_options_'.$key];
if (array_key_exists('options_'.$key, $line->array_options)) {
$object_line->array_options['options_'.$key] = $line->array_options['options_'.$key];
}
}
$object_line->insertExtraFields();
Expand All @@ -781,14 +797,20 @@ function infrastructure_updateInfrastructureBloc($object, $line)
{
global $langs;

$infrastructure_tva_tx = $infrastructure_tva_tx_init = GETPOST('infrastructure_tva_tx', 'int');
$infrastructure_progress = $infrastructure_progress_init = GETPOST('infrastructure_progress', 'int');
$array_options = $line->array_options;
$showBlockExtrafields = GETPOST('showBlockExtrafields', 'aZ09');
$infrastructure_tva_tx = $infrastructure_tva_tx_init = GETPOST('infrastructure_tva_tx', 'int');
$infrastructure_progress = $infrastructure_progress_init = GETPOST('infrastructure_progress', 'int');
$array_options = $line->array_options;
$showBlockExtrafields = GETPOST('showBlockExtrafields', 'aZ09');
if ($infrastructure_tva_tx != '' || $infrastructure_progress != '' || (!empty($showBlockExtrafields) && !empty($array_options))) {
$error_progress = $nb_progress_update = $nb_progress_not_updated = 0;
$TLine = TInfrastructure::getLinesFromTitleId($object, $line->id);
$parentTitleId = $line->id;
$TLine = TInfrastructure::getLinesFromTitleId($object, $line->id, true);
// Clés propres au module infrastructure — ne pas les propager aux titres enfants
$infrastructureOwnKeys = ['options_show_total_ht', 'options_show_reduc', 'options_infrastructure_show_qty', 'options_hideblock', 'options_show_table_header_before', 'options_print_as_list', 'options_print_condensed', 'options_infrastructure_ol'];
foreach ($TLine as &$line) {
if ($line->id == $parentTitleId || TInfrastructure::isTotal($line)) {
continue; // Ignorer le titre parent lui-même et les sous-totaux
}
if (!TInfrastructure::isModInfrastructureLine($line)) {
$infrastructure_tva_tx = $infrastructure_tva_tx_init; // ré-init car la variable peut évoluer
if (!empty($showBlockExtrafields)) {
Expand All @@ -815,6 +837,14 @@ function infrastructure_updateInfrastructureBloc($object, $line)
} else {
$error_updated_line++;
}
} elseif (TInfrastructure::isTitle($line) && !empty($showBlockExtrafields) && !empty($array_options)) {
// Titre enfant : propager uniquement les extrafields non gérés par infrastructure
foreach ($array_options as $optKey => $optVal) {
if (!in_array($optKey, $infrastructureOwnKeys)) {
$line->array_options[$optKey] = $optVal;
}
}
$line->insertExtraFields();
}
}
if ($nb_progress_not_updated > 0) {
Expand Down
24 changes: 1 addition & 23 deletions core/tpl/infrastructureline_edit.tpl.php
Original file line number Diff line number Diff line change
Expand Up @@ -190,31 +190,9 @@
if (getDolGlobalString('FCKEDITOR_ENABLE_DETAILS_FULL')) {
$toolbarname = 'dolibarr_notes';
}
echo '<div id="infrastructure_desc">';
$doleditor = new DolEditor('line-description', $line->description, '', 100, $toolbarname, '', false, true, $cked_enabled, $nbrows, '98%', (bool) $readonlyForSituation);
$doleditor->Create();
$TKey = null;
if ($line->element == 'propaldet') {
$TKey = explode(',', getDolGlobalString('INFRASTRUCTURE_LIST_OF_EXTRAFIELDS_PROPALDET'));
} elseif ($line->element == 'commandedet') {
$TKey = explode(',', getDolGlobalString('INFRASTRUCTURE_LIST_OF_EXTRAFIELDS_COMMANDEDET'));
} elseif ($line->element == 'facturedet') {
$TKey = explode(',', getDolGlobalString('INFRASTRUCTURE_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) {
print ' <div class="sub-'.$code.'">
<label class="">'.$extrafields->attributes[$line->element]['label'][$code].'</label>';
print $extrafields->showInputField($code, $line->array_options['options_'.$code], '', '', 'infrastructure_', '', 0, $object->table_element_line);
print '</div>';
}
}
}
}
}
?>
<!-- END PHP TEMPLATE infrastructureline_edit.tpl.php -->
9 changes: 5 additions & 4 deletions core/tpl/infrastructureline_row_document.tpl.php
Original file line number Diff line number Diff line change
Expand Up @@ -252,23 +252,24 @@
</tr>
<?php
// Affichage des extrafields à la Dolibarr (sinon non affiché sur les titres)
if (TInfrastructure::isTitle($line) && getDolGlobalInt('INFRASTRUCTURE_ALLOW_EXTRAFIELDS_ON_TITLE')) {
if (TInfrastructure::isTitle($line) && getDolGlobalInt('INFRASTRUCTURE_ALLOW_EXTRAFIELDS_ON_TITLE') && (getDolGlobalString('INFRASTRUCTURE_LIST_OF_EXTRAFIELDS_PROPALDET') || getDolGlobalString('INFRASTRUCTURE_LIST_OF_EXTRAFIELDS_COMMANDEDET') || getDolGlobalString('INFRASTRUCTURE_LIST_OF_EXTRAFIELDS_FACTUREDET'))) {
$extrafieldsline = new ExtraFields($db);
$extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line);
$mode = $action === 'editline' && $line->rowid == GETPOST('lineid', 'int') ? 'edit' : 'view';
$ex_element = $line->element;
$line->element = 'tr_extrafield_title '.$line->element; // Pour pouvoir manipuler ces tr
$isExtraSelected = false;
$bgBrightness = colorLighten(getDolGlobalString('INFRASTRUCTURE_TITLE_BACKGROUND_COLOR'), 25);
$colspan += 5;
print $line->showOptionals($extrafieldsline, $mode, ['style' => ' style="background:#eeffee;" ', 'colspan' => $colspan]);
foreach ($line->array_options as $option) {
if (!empty($option) && $option != "-1") {
$isExtraSelected = true;
break;
}
}
if ($mode === 'edit') {
?>
print $line->showOptionals($extrafieldsline, $mode, ['style' => ' style="background:'.$bgBrightness.';color:'.getDolGlobalString('INFRASTRUCTURE_TITLE_COLOR').';" ', 'colspan' => $colspan]);
?>
<script>
$(document).ready(function () {
var all_tr_extrafields = $("tr.tr_extrafield_title");
Expand All @@ -284,7 +285,7 @@
echo 'var extra = 1;';
}
?>
$("div .infrastructure_underline").append(
$("#infrastructure_desc").append(
'<a id="printBlocExtrafields" onclick="return false;" href="#">' + trad + '</a>'
+ '<input type="hidden" name="showBlockExtrafields" id="showBlockExtrafields" value="' + extra + '" />');
$(document).on('click', "#printBlocExtrafields", function() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -568,7 +568,7 @@ private function ShippingCreate($object, $user, $langs)
foreach ($object->lines as &$line) {
$orderline = new OrderLine($this->db);
$orderline->fetch($line->origin_line_id);
if (getDolGlobalString('NO_TITLE_SHOW_ON_EXPED_GENERATION')) {
if (getDolGlobalString('INFRASTRUCTURE_NO_TITLE_SHOW_ON_EXPED_GENERATION')) {
if (!isset($line->special_code) && $cmd) {
foreach ($cmd->lines as $cmdLine) {
if ($cmdLine->id == $line->origin_line_id) {
Expand Down
3 changes: 2 additions & 1 deletion docs/changelog.xml
Original file line number Diff line number Diff line change
Expand Up @@ -490,8 +490,9 @@
<change type='fix'>Correction d'une page parasite (page blanche + bandeau bleu vide sans label sur la page suivante). Cause : quand le libellé déborde, TCPDF déclenche un auto-page-break interne au writeHTMLCell qui crée une page parasite => la réservation d'espace s'applique désormais à tous les titres infrastructure.</change>
<change type='fix'>Suppression d'un code mort : L'option est déclarée mais jamais utilisée.</change>
<change type='fix'>Page récapitulatif InfraSPackPlus (option INFRASTRUCTURE_*_ADD_RECAP) non générée quand INFRASTRUCTURE_PDF_TITLE_WITH_TOTAL est actif. Cause : infrastructure_applyTitleWithTotal() supprimait les sous-totaux de $object->lines avant que la boucle de préparation de write_file() d'InfraSPackPlus ne les parcoure ; $subtotalRecap restait vide. Correction : les sous-totaux retirés sont désormais sauvegardés dans $object->context['infrastructureCache']['removedTotals'] (avec le rang du titre parent et le niveau) avant suppression, permettant à InfraSPackPlus de reconstruire $subtotalRecap depuis ce contexte.</change>
<change type='fix'>ExtraFields sur titre (INFRASTRUCTURE_LIST_OF_EXTRAFIELDS_*) non enregistrés quand les lignes de toggle (showOptionals) sont visibles => suppression du bloc showInputField() de infrastructureline_edit.tpl.php (un seul mécanisme d'affichage : showOptionals) ; la logique TKey ne lit plus POST — elle propage simplement $line->array_options vers les lignes enfants du bloc (valeur déjà correcte : setOptionalsFromPost quand showBlockExtrafields=1, valeur BD sinon).</change>
</Version>
<InfraS Downloaded="20260601"/>
<InfraS Downloaded="20260604"/>
<Dolibarr minVersion="21.0.0" maxVersion="24.x.x"/>
<PHP minVersion="7.4" maxVersion="8.4"/>
</changelog>
4 changes: 2 additions & 2 deletions langs/en_US/infrastructure.lang
Original file line number Diff line number Diff line change
Expand Up @@ -247,5 +247,5 @@ InfrastructurePdfTotalBackgroundCellHeightOffset = Height offset (mm) of t
InfrastructurePdfTotalBackgroundCellPosYOffset = Vertical offset (mm) of the colored background cell for totals in PDFs
InfrastructureBackgroundCellOffsetInfo = Allows fine-tuning of the colored background cell rendering to compensate for differences between text height and cell height. No effect if no background color is defined.
InfrastructureBackgroundCellOffsetInfo1 = Allows fine-tuning of the colored background cell rendering to compensate for differences between text height and cell height. No effect if no background color is defined. Positive number moves down, otherwise moves up.
InfrastructureDefaultCheckShippingListForTitleDesc = Pre-check « Include shipping list » by default when adding a title
InfrastructureDefaultCheckShippingListForTitleDescInfo = When enabled, the « Add shipping list to title description » checkbox is pre-checked in the title add/edit form.
InfrastructureDefaultCheckShippingListForTitleDesc = Pre-check the « Add the reference list of related shipping or delivery notes to the title block description » checkbox by default when invoicing orders in bulk.
InfrastructureDefaultCheckShippingListForTitleDescInfo = When enabled, the « Add the reference list of related shipping or delivery notes to the title block description » checkbox is pre-checked by default in the mass order invoicing form.
4 changes: 2 additions & 2 deletions langs/es_ES/infrastructure.lang
Original file line number Diff line number Diff line change
Expand Up @@ -247,5 +247,5 @@ InfrastructurePdfTotalBackgroundCellHeightOffset = Desplazamiento de altur
InfrastructurePdfTotalBackgroundCellPosYOffset = Desplazamiento vertical (mm) de la celda de fondo coloreada de los subtotales en los PDF
InfrastructureBackgroundCellOffsetInfo = Permite ajustar finamente la representación de la celda de fondo coloreada para compensar las diferencias entre la altura del texto y la altura de la celda. Sin efecto si no se define un color de fondo.
InfrastructureBackgroundCellOffsetInfo1 = Permite ajustar finamente la representación de la celda de fondo coloreada para compensar las diferencias entre la altura del texto y la altura de la celda. Sin efecto si no se define un color de fondo. Número positivo desplaza hacia abajo, de lo contrario hacia arriba.
InfrastructureDefaultCheckShippingListForTitleDesc = Marcar por defecto « Incluir lista de envíos » al añadir un título
InfrastructureDefaultCheckShippingListForTitleDescInfo = Cuando se activa, la casilla « Añadir la lista de envíos a la descripción del título » se marca previamente en el formulario de añadir/editar título.
InfrastructureDefaultCheckShippingListForTitleDesc = Marcar por defecto « Agregar la lista de referencias de los albaranes o notas de entrega relacionados a la descripción del bloque de título » al facturar pedidos en masa.
InfrastructureDefaultCheckShippingListForTitleDescInfo = Cuando se activa, la casilla « Agregar la lista de referencias de los albaranes o notas de entrega relacionados a la descripción del bloque de título » se marca previamente por defecto en el formulario de facturación masiva de pedidos.
Loading