Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop

This commit is contained in:
Laurent Destailleur 2023-04-06 18:44:14 +02:00
commit 6fa9c8dea6
10 changed files with 88 additions and 25 deletions

View File

@ -3393,7 +3393,6 @@ class Facture extends CommonInvoice
// Set new ref and define current status
if (!$error) {
$this->ref = $num;
$this->ref = $num;
$this->statut = self::STATUS_VALIDATED;
$this->status = self::STATUS_VALIDATED;

View File

@ -1236,8 +1236,8 @@ abstract class CommonDocGenerator
// save curent cell padding
$curentCellPaddinds = $pdf->getCellPaddings();
// set cell padding with column content definition
$pdf->setCellPaddings($colDef['content']['padding'][3], $colDef['content']['padding'][0], $colDef['content']['padding'][1], $colDef['content']['padding'][2]);
$pdf->writeHTMLCell($colDef['width'], 2, $colDef['xStartPos'], $curY, $columnText, 0, 1, 0, true, $colDef['content']['align']);
$pdf->setCellPaddings(isset($colDef['content']['padding'][3]) ? $colDef['content']['padding'][3] : 0, isset($colDef['content']['padding'][0]) ? $colDef['content']['padding'][0] : 0, isset($colDef['content']['padding'][1]) ? $colDef['content']['padding'][1] : 0, isset($colDef['content']['padding'][2]) ? $colDef['content']['padding'][2] : 0);
$pdf->writeHTMLCell($colDef['width'], 2, isset($colDef['xStartPos']) ? $colDef['xStartPos'] : 0, $curY, $columnText, 0, 1, 0, true, $colDef['content']['align']);
// restore cell padding
$pdf->setCellPaddings($curentCellPaddinds['L'], $curentCellPaddinds['T'], $curentCellPaddinds['R'], $curentCellPaddinds['B']);

View File

@ -1197,10 +1197,10 @@ class pdf_crabe extends ModelePDFFactures
if ($object->type != 2) {
// Check a payment mode is defined
if (empty($object->mode_reglement_code)
&& empty($conf->global->FACTURE_CHQ_NUMBER)
&& !getDolGlobalInt('FACTURE_CHQ_NUMBER')
&& !getDolGlobalInt('FACTURE_RIB_NUMBER')) {
$this->error = $outputlangs->transnoentities("ErrorNoPaiementModeConfigured");
} elseif (($object->mode_reglement_code == 'CHQ' && empty($conf->global->FACTURE_CHQ_NUMBER) && empty($object->fk_account) && empty($object->fk_bank))
} elseif (($object->mode_reglement_code == 'CHQ' && !getDolGlobalInt('FACTURE_CHQ_NUMBER') && empty($object->fk_account) && empty($object->fk_bank))
|| ($object->mode_reglement_code == 'VIR' && !getDolGlobalInt('FACTURE_RIB_NUMBER') && empty($object->fk_account) && empty($object->fk_bank))) {
// Avoid having any valid PDF with setup that is not complete
$outputlangs->load("errors");
@ -1286,12 +1286,12 @@ class pdf_crabe extends ModelePDFFactures
// Show payment mode CHQ
if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'CHQ') {
// If payment mode unregulated or payment mode forced to CHQ
if (!empty($conf->global->FACTURE_CHQ_NUMBER)) {
if (getDolGlobalInt('FACTURE_CHQ_NUMBER')) {
$diffsizetitle = (empty($conf->global->PDF_DIFFSIZE_TITLE) ? 3 : $conf->global->PDF_DIFFSIZE_TITLE);
if ($conf->global->FACTURE_CHQ_NUMBER > 0) {
$account = new Account($this->db);
$account->fetch($conf->global->FACTURE_CHQ_NUMBER);
$account->fetch(getDolGlobalInt('FACTURE_CHQ_NUMBER'));
$pdf->SetXY($this->marge_gauche, $posy);
$pdf->SetFont('', 'B', $default_font_size - $diffsizetitle);

View File

@ -1289,10 +1289,10 @@ class pdf_sponge extends ModelePDFFactures
if ($object->type != 2) {
// Check a payment mode is defined
if (empty($object->mode_reglement_code)
&& empty($conf->global->FACTURE_CHQ_NUMBER)
&& !getDolGlobalInt('FACTURE_CHQ_NUMBER')
&& !getDolGlobalInt('FACTURE_RIB_NUMBER')) {
$this->error = $outputlangs->transnoentities("ErrorNoPaiementModeConfigured");
} elseif (($object->mode_reglement_code == 'CHQ' && empty($conf->global->FACTURE_CHQ_NUMBER) && empty($object->fk_account) && empty($object->fk_bank))
} elseif (($object->mode_reglement_code == 'CHQ' && !getDolGlobalInt('FACTURE_CHQ_NUMBER') && empty($object->fk_account) && empty($object->fk_bank))
|| ($object->mode_reglement_code == 'VIR' && !getDolGlobalInt('FACTURE_RIB_NUMBER') && empty($object->fk_account) && empty($object->fk_bank))) {
// Avoid having any valid PDF with setup that is not complete
$outputlangs->load("errors");
@ -1381,12 +1381,12 @@ class pdf_sponge extends ModelePDFFactures
// Show payment mode CHQ
if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'CHQ') {
// If payment mode unregulated or payment mode forced to CHQ
if (!empty($conf->global->FACTURE_CHQ_NUMBER)) {
if (getDolGlobalInt('FACTURE_CHQ_NUMBER')) {
$diffsizetitle = (empty($conf->global->PDF_DIFFSIZE_TITLE) ? 3 : $conf->global->PDF_DIFFSIZE_TITLE);
if ($conf->global->FACTURE_CHQ_NUMBER > 0) {
$account = new Account($this->db);
$account->fetch($conf->global->FACTURE_CHQ_NUMBER);
$account->fetch(getDolGlobalInt('FACTURE_CHQ_NUMBER'));
$pdf->SetXY($this->marge_gauche, $posy);
$pdf->SetFont('', 'B', $default_font_size - $diffsizetitle);

View File

@ -1032,12 +1032,12 @@ class pdf_azur extends ModelePDFPropales
// Show payment mode CHQ
if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'CHQ') {
// Si mode reglement non force ou si force a CHQ
if (!empty($conf->global->FACTURE_CHQ_NUMBER)) {
if (getDolGlobalInt('FACTURE_CHQ_NUMBER')) {
$diffsizetitle = (empty($conf->global->PDF_DIFFSIZE_TITLE) ? 3 : $conf->global->PDF_DIFFSIZE_TITLE);
if ($conf->global->FACTURE_CHQ_NUMBER > 0) {
$account = new Account($this->db);
$account->fetch($conf->global->FACTURE_CHQ_NUMBER);
$account->fetch(getDolGlobalInt('FACTURE_CHQ_NUMBER'));
$pdf->SetXY($this->marge_gauche, $posy);
$pdf->SetFont('', 'B', $default_font_size - $diffsizetitle);

View File

@ -1143,12 +1143,12 @@ class pdf_cyan extends ModelePDFPropales
// Show payment mode CHQ
if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'CHQ') {
// Si mode reglement non force ou si force a CHQ
if (!empty($conf->global->FACTURE_CHQ_NUMBER)) {
if (getDolGlobalInt('FACTURE_CHQ_NUMBER')) {
$diffsizetitle = (empty($conf->global->PDF_DIFFSIZE_TITLE) ? 3 : $conf->global->PDF_DIFFSIZE_TITLE);
if ($conf->global->FACTURE_CHQ_NUMBER > 0) {
$account = new Account($this->db);
$account->fetch($conf->global->FACTURE_CHQ_NUMBER);
$account->fetch(getDolGlobalInt('FACTURE_CHQ_NUMBER'));
$pdf->SetXY($this->marge_gauche, $posy);
$pdf->SetFont('', 'B', $default_font_size - $diffsizetitle);
@ -1162,7 +1162,7 @@ class pdf_cyan extends ModelePDFPropales
$posy = $pdf->GetY() + 2;
}
}
if ($conf->global->FACTURE_CHQ_NUMBER == -1) {
if (getDolGlobalInt('FACTURE_CHQ_NUMBER') == -1) {
$pdf->SetXY($this->marge_gauche, $posy);
$pdf->SetFont('', 'B', $default_font_size - $diffsizetitle);
$pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo', $this->emetteur->name), 0, 'L', 0);

View File

@ -943,10 +943,10 @@ class pdf_eagle_proforma extends ModelePDFCommandes
// Show payment mode CHQ
if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'CHQ') {
// Si mode reglement non force ou si force a CHQ
if (!empty($conf->global->FACTURE_CHQ_NUMBER)) {
if (getDolGlobalInt('FACTURE_CHQ_NUMBER')) {
if ($conf->global->FACTURE_CHQ_NUMBER > 0) {
$account = new Account($this->db);
$account->fetch($conf->global->FACTURE_CHQ_NUMBER);
$account->fetch(getDolGlobalInt('FACTURE_CHQ_NUMBER'));
$pdf->SetXY($this->marge_gauche, $posy);
$pdf->SetFont('', 'B', $default_font_size - 3);
@ -960,7 +960,7 @@ class pdf_eagle_proforma extends ModelePDFCommandes
$posy = $pdf->GetY() + 2;
}
}
if ($conf->global->FACTURE_CHQ_NUMBER == -1) {
if (getDolGlobalInt('FACTURE_CHQ_NUMBER') == -1) {
$pdf->SetXY($this->marge_gauche, $posy);
$pdf->SetFont('', 'B', $default_font_size - 3);
$pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo', $this->emetteur->name), 0, 'L', 0);

View File

@ -841,12 +841,12 @@ class pdf_aurore extends ModelePDFSupplierProposal
// Show payment mode CHQ
if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'CHQ') {
// Si mode reglement non force ou si force a CHQ
if (!empty($conf->global->FACTURE_CHQ_NUMBER)) {
if (getDolGlobalInt('FACTURE_CHQ_NUMBER')) {
$diffsizetitle = (empty($conf->global->PDF_DIFFSIZE_TITLE) ? 3 : $conf->global->PDF_DIFFSIZE_TITLE);
if ($conf->global->FACTURE_CHQ_NUMBER > 0) {
$account = new Account($this->db);
$account->fetch($conf->global->FACTURE_CHQ_NUMBER);
$account->fetch(getDolGlobalInt('FACTURE_CHQ_NUMBER'));
$pdf->SetXY($this->marge_gauche, $posy);
$pdf->SetFont('', 'B', $default_font_size - $diffsizetitle);
@ -860,7 +860,7 @@ class pdf_aurore extends ModelePDFSupplierProposal
$posy = $pdf->GetY() + 2;
}
}
if ($conf->global->FACTURE_CHQ_NUMBER == -1) {
if (getDolGlobalInt('FACTURE_CHQ_NUMBER') == -1) {
$pdf->SetXY($this->marge_gauche, $posy);
$pdf->SetFont('', 'B', $default_font_size - $diffsizetitle);
$pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo', $this->emetteur->name), 0, 'L', 0);

View File

@ -1,6 +1,7 @@
<?php
/* Copyright (C) 2019-2020 Laurent Destailleur <eldy@users.sourceforge.net>
/* Copyright (C) 2023 Christian Humpel <christian.humpel@gmail.com>
* Copyright (C) 2023 Christian Humpel <christian.humpel@gmail.com>
* Copyright (C) 2023 Vincent de Grandpré <vincent@de-grandpre.quebec>
*
* 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
@ -442,6 +443,11 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
$res = $object->fetch_thirdparty();
$res = $object->fetch_optionals();
if (!empty($conf->global->STOCK_CONSUMPTION_FROM_MANUFACTURING_WAREHOUSE) && $object->fk_warehouse > 0) {
$tmpwarehouse->fetch($object->fk_warehouse);
$fk_default_warehouse = $object->fk_warehouse;
}
$head = moPrepareHead($object);
print dol_get_fiche_head($head, 'production', $langs->trans("ManufacturingOrder"), -1, $object->picto);
@ -924,6 +930,9 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
print '</td>';
// Warehouse
print '<td>';
if (!empty($conf->global->STOCK_CONSUMPTION_FROM_MANUFACTURING_WAREHOUSE) && $tmpwarehouse->id > 0) {
print img_picto('', $tmpwarehouse->picto)." ".$tmpwarehouse->label;
}
print '</td>';
// Stock
if (isModEnabled('stock')) {
@ -932,7 +941,18 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
if (!$line->disable_stock_change && $tmpproduct->stock_reel < ($line->qty - $alreadyconsumed)) {
print img_warning($langs->trans('StockTooLow')) . ' ';
}
print price2num($tmpproduct->stock_reel, 'MS'); // Available
if (empty($conf->global->STOCK_CONSUMPTION_FROM_MANUFACTURING_WAREHOUSE) || empty($tmpwarehouse->id)) {
print price2num($tmpproduct->stock_reel, 'MS'); // Available
} else {
// Print only the stock in the selected warehouse
$tmpproduct->load_stock();
$wh_stock = $tmpproduct->stock_warehouse[$tmpwarehouse->id];
if (!empty($wh_stock)) {
print price2num($wh_stock->real, 'MS');
} else {
print "0";
}
}
}
print '</td>';
}
@ -1123,6 +1143,12 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
});
</script>';
if (in_array($action, array('consumeorproduce', 'consumeandproduceall')) &&
!empty($conf->global->STOCK_CONSUMPTION_FROM_MANUFACTURING_WAREHOUSE)) {
print '<script>$(document).ready(function () {
$("#fk_default_warehouse").change();
});</script>';
}
// Lines to produce

View File

@ -5,6 +5,7 @@
* Copyright (C) 2013 Cédric Salvador <csalvador@gpcsolutions.fr>
* Copyright (C) 2015 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
* Copyright (C) 2019 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2023 Vincent de Grandpré <vincent@de-grandpre.quebec>
*
* 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
@ -172,7 +173,44 @@ if (!empty($search_categ) && $search_categ != '-1') {
}
$sql .= ")";
}
$sql .= " AND EXISTS (SELECT e.rowid FROM ".MAIN_DB_PREFIX."entrepot as e WHERE e.rowid = s.fk_entrepot AND e.entity IN (".getEntity('stock')."))";
if (empty($conf->global->PRODUCT_STOCK_LIST_SHOW_VIRTUAL_WITH_NO_PHYSICAL)) {
$sql .= " AND EXISTS (SELECT e.rowid FROM ".MAIN_DB_PREFIX."entrepot as e WHERE e.rowid = s.fk_entrepot AND e.entity IN (".getEntity('stock')."))";
} else {
$sql .= " AND
(
EXISTS
(SELECT e.rowid
FROM ".MAIN_DB_PREFIX."entrepot as e
WHERE e.rowid = s.fk_entrepot AND e.entity IN (".getEntity('stock')."))
OR (
SELECT SUM(cd1.qty) as qty
FROM ".MAIN_DB_PREFIX."commande_fournisseurdet as cd1
LEFT JOIN ".MAIN_DB_PREFIX."commande_fournisseur as c1
ON c1.rowid = cd1.fk_commande
WHERE c1.entity IN (1) AND cd1.fk_product = p.rowid AND c1.fk_statut in (3,4) AND cd1.qty <> 0
) IS NOT NULL
OR (
SELECT SUM(cd2.qty) as qty
FROM ".MAIN_DB_PREFIX."commandedet as cd2
LEFT JOIN ".MAIN_DB_PREFIX."commande as c2 ON c2.rowid = cd2.fk_commande
WHERE c2.entity IN (1) AND cd2.fk_product = p.rowid AND c2.fk_statut in (1,2) AND cd2.qty <> 0
) IS NOT NULL
OR (
SELECT SUM(ed3.qty) as qty
FROM ".MAIN_DB_PREFIX."expeditiondet as ed3
LEFT JOIN ".MAIN_DB_PREFIX."expedition as e3 ON e3.rowid = ed3.fk_expedition
LEFT JOIN ".MAIN_DB_PREFIX."commandedet as cd3 ON ed3.fk_origin_line = cd3.rowid
LEFT JOIN ".MAIN_DB_PREFIX."commande as c3 ON c3.rowid = cd3.fk_commande
WHERE e3.entity IN (1) AND cd3.fk_product = p.rowid AND c3.fk_statut IN (1,2) AND e3.fk_statut IN (1,2) AND ed3.qty <> 0
) IS NOT NULL
OR (
SELECT SUM(mp4.qty) as qty
FROM ".MAIN_DB_PREFIX."mrp_production as mp4
LEFT JOIN ".MAIN_DB_PREFIX."mrp_mo as m4 ON m4.rowid = mp4.fk_mo AND m4.entity IN (1) AND m4.status IN (1,2)
WHERE mp4.fk_product = p.rowid AND mp4.qty <> 0
) IS NOT NULL
) ";
}
if ($sall) {
$sql .= natural_search(array('p.ref', 'p.label', 'p.description', 'p.note'), $sall);
}