Skip to content

Commit

Permalink
Merge branch 'new-mass-facturation-from-expedition' of github.com:Jus…
Browse files Browse the repository at this point in the history
…tRaosha/dolibarr into new-mass-facturation-from-expedition
  • Loading branch information
YannisHoareau committed May 23, 2024
2 parents 0fd3b23 + 44952f1 commit 199e591
Show file tree
Hide file tree
Showing 28 changed files with 539 additions and 266 deletions.
2 changes: 1 addition & 1 deletion ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -9775,7 +9775,7 @@ For developers:
- New: Can add a link on title field of added dictionary.
- New: Uniformize code.
- New: Add option WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER and
WORKFLOW_DISABLE_CLASSIFY_BILLED_FROM_ORDER.
ORDER_DISABLE_CLASSIFY_BILLED_FROM_ORDER.
- New: A module can add several css and js.
- New: removed deprecated methods
ldap::connect, formadmin::select_lang,
Expand Down
16 changes: 11 additions & 5 deletions dev/translation/sanity_check_trans_missing_unused.sh
Original file line number Diff line number Diff line change
Expand Up @@ -123,12 +123,14 @@ fi
# > yyy
# Some output is already compatible with message extraction for github annotation (logToCs.py)
#

diff "${AVAILABLE_FILE}" "${EXPECTED_FILE}" \
| grep -E "^[<>]" \
| grep -v -P "^< ${EXPECTED_REGEX}$" \
| sort \
> "${MISSING_AND_UNUSED_FILE}"

rm -f "${UNUSED_FILE}.grep" >/dev/null 2>&1
sed -n 's@< \(.*\)@^\1\\s*=@p' \
< "${MISSING_AND_UNUSED_FILE}" \
> "${UNUSED_FILE}.grep"
Expand All @@ -137,13 +139,14 @@ sed -n 's@< \(.*\)@^\1\\s*=@p' \
# Prepare file with exact matches for use with `git grep`, supposing " quotes
#
REPL_STR=""
for t in trans transnoentities transnoentitiesnoconv ; do
for t in trans transnoentities transnoentitiesnoconv newItem buttonsSaveCancel; do
REPL_STR="${REPL_STR}\n->${t}(\"\\1\","
REPL_STR="${REPL_STR}\n->${t}('\\1',"
REPL_STR="${REPL_STR}\n->${t}(\"\\1\")"
REPL_STR="${REPL_STR}\n->${t}('\\1')"
done

rm -f "${MISSING_FILE}.grep" >/dev/null 2>&1
sed -n 's@> \(.*\)'"@${REPL_STR}@p" \
< "${MISSING_AND_UNUSED_FILE}" \
| grep -v -E '^$' \
Expand All @@ -168,23 +171,26 @@ if [ -s "${UNUSED_FILE}.grep" ] ; then

git grep -n --column -r -f "${UNUSED_FILE}.grep" -- "${LANG_DIR}"'/*.lang' \
| sort -t: -k 4 \
| sed 's@^\([^:]*:[^:]*:[^:]*:\)\s*@\1 Not used, translated; @'
| sed 's@^\([^:]*:[^:]*:[^:]*:\)\s*@Warning Not used, translated; @'

echo "##[endgroup]"
echo
fi


if [ -s "${MISSING_FILE}.grep" ] ; then
exit_code=1

# Report missing translation in recognizable format

echo "##[group]List missing translations (used by code but not found into lang files) - Generate CTI errors"

git grep -n --column -r -F -f "${MISSING_FILE}.grep" -- ':*.php' ':*.html' \
| sort -t: -k 4 \
| sed 's@^\([^:]*:[^:]*:[^:]*:\)\s*@\1 Missing translation; @'
| sed 's@^\([^:]*:[^:]*:[^:]*:\)\s*@\1 Missing translation; @' > "${MISSING_FILE}.result"

if [ -s "${MISSING_FILE}.result" ] ; then
exit_code=1
cat "${MISSING_FILE}.result"
fi

echo "##[endgroup]"
fi
Expand Down
1 change: 1 addition & 0 deletions htdocs/admin/invoice.php
Original file line number Diff line number Diff line change
Expand Up @@ -826,6 +826,7 @@
print ajax_constantonoff('INVOICE_CHECK_POSTERIOR_DATE');
print '</td></tr>';


// Allow external download
print '<tr class="oddeven">';
print '<td>'.$langs->trans("AllowExternalDownload").'</td>';
Expand Down
10 changes: 8 additions & 2 deletions htdocs/admin/modulehelp.php
Original file line number Diff line number Diff line change
Expand Up @@ -366,10 +366,16 @@
$textexternal .= ($objMod->editor_name != 'dolibarr' ? ' - ' : '').img_picto('', 'globe').' <a href="'.$editor_url.'" target="_blank" rel="noopener noreferrer external">'.$objMod->editor_url.'</a>';
}
$text .= $textexternal;
$text .= '<br>';
} else {
$text .= '<br><span class="opacitymedium">'.$langs->trans("Origin").':</span> '.$langs->trans("Core").'<br>';
$text .= '<br><span class="opacitymedium">'.$langs->trans("Origin").':</span> '.$langs->trans("Core");
if (empty($objMod->numero)) {
$text .= ' &nbsp; <span class="italic opacitymedium">('.$langs->trans("AlwaysEnabled").')</span>';
} elseif (!empty($objMod->enabled_bydefault)) {
$text .= ' &nbsp; <span class="italic opacitymedium">('.$langs->trans("EnabledByDefaultAtInstall").')</span>';
}
$text .= '<br>';
}
$text .= '<br>';

$moduledesclong = $objMod->getDescLong();
if ($moduledesclong) {
Expand Down
9 changes: 9 additions & 0 deletions htdocs/admin/order.php
Original file line number Diff line number Diff line change
Expand Up @@ -685,6 +685,15 @@
print '</td></tr>';
print '</form>';

// Disallow to classify billed an order without invoice, only if module invoice is enable
if (isModEnabled('invoice')) {
print '<tr class="oddeven"><td>'.$langs->trans("InvoiceClassifyBilledSupplierOrderWithoutInvoice"). '&nbsp;' ;
print $form->textwithpicto('', $langs->trans("InvoiceClassifyBilledSupplierOrderWithoutInvoiceHelp"), 1, 'help') . '</td>';
print '<td class="left" colspan="2">';
print ajax_constantonoff('ORDER_DISABLE_CLASSIFY_BILLED_FROM_ORDER');
print '</td></tr>';
}

/*
// Seems to be not so used. So kept hidden for the moment to avoid dangerous options inflation.
// TODO Must be implemented by PDF templates
Expand Down
66 changes: 64 additions & 2 deletions htdocs/admin/pdf_other.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,16 @@
dolibarr_del_const($db, "INVOICE_SHOW_SHIPPING_ADDRESS", $conf->entity);
}

if (GETPOSTISSET('BARCODE_ON_SHIPPING_PDF')) {
dolibarr_set_const($db, "BARCODE_ON_SHIPPING_PDF", GETPOSTINT("BARCODE_ON_SHIPPING_PDF"), 'chaine', 0, '', $conf->entity);
}
if (GETPOSTISSET('BARCODE_ON_RECEPTION_PDF')) {
dolibarr_set_const($db, "BARCODE_ON_RECEPTION_PDF", GETPOSTINT("BARCODE_ON_RECEPTION_PDF"), 'chaine', 0, '', $conf->entity);
}
if (GETPOSTISSET('BARCODE_ON_STOCKTRANSFER_PDF')) {
dolibarr_set_const($db, "BARCODE_ON_STOCKTRANSFER_PDF", GETPOSTINT("BARCODE_ON_STOCKTRANSFER_PDF"), 'chaine', 0, '', $conf->entity);
}

setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');

header("Location: ".$_SERVER["PHP_SELF"]."?mainmenu=home&leftmenu=setup");
Expand Down Expand Up @@ -312,6 +322,26 @@
print '</div>';
}

if (isModEnabled('shipping')) {
print load_fiche_titre($langs->trans("Shipments"), '', 'shipment');

print '<div class="div-table-responsive-no-min">';
print '<table summary="more" class="noborder centpercent">';
print '<tr class="liste_titre"><td class="titlefieldmiddle">'.$langs->trans("Parameters").'</td><td width="200px">'.$langs->trans("Value").'</td></tr>';

print '<tr class="oddeven"><td>';
print $langs->trans("BARCODE_ON_SHIPPING_PDF");
print '</td><td>';
if ($conf->use_javascript_ajax) {
print ajax_constantonoff('BARCODE_ON_SHIPPING_PDF');
} else {
$arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
print $form->selectarray("BARCODE_ON_SHIPPING_PDF", $arrval, getDolGlobalString('BARCODE_ON_SHIPPING_PDF'));
}
print '</td></tr>';
print '</table>';
print '</div>';
}


if (isModEnabled('reception')) {
Expand All @@ -328,7 +358,7 @@
print ajax_constantonoff('RECEPTION_PDF_HIDE_ORDERED');
} else {
$arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
print $form->selectarray("RECEPTION_PDF_HIDE_ORDERED", $arrval, $conf->global->RECEPTION_PDF_HIDE_ORDERED);
print $form->selectarray("RECEPTION_PDF_HIDE_ORDERED", $arrval, getDolGlobalString('RECEPTION_PDF_HIDE_ORDERED'));
}
print '</td></tr>';

Expand All @@ -339,7 +369,39 @@
print ajax_constantonoff('MAIN_PDF_RECEPTION_DISPLAY_AMOUNT_HT');
} else {
$arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
print $form->selectarray("MAIN_PDF_RECEPTION_DISPLAY_AMOUNT_HT", $arrval, $conf->global->MAIN_PDF_RECEPTION_DISPLAY_AMOUNT_HT);
print $form->selectarray("MAIN_PDF_RECEPTION_DISPLAY_AMOUNT_HT", $arrval, getDolGlobalString('MAIN_PDF_RECEPTION_DISPLAY_AMOUNT_HT'));
}
print '</td></tr>';

print '<tr class="oddeven"><td>';
print $langs->trans("BARCODE_ON_RECEPTION_PDF");
print '</td><td>';
if ($conf->use_javascript_ajax) {
print ajax_constantonoff('BARCODE_ON_RECEPTION_PDF');
} else {
$arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
print $form->selectarray("BARCODE_ON_RECEPTION_PDF", $arrval, getDolGlobalString('BARCODE_ON_RECEPTION_PDF'));
}
print '</td></tr>';
print '</table>';
print '</div>';
}

if (isModEnabled('stocktransfer')) {
print load_fiche_titre($langs->trans("StockTransfer"), '', 'stock');

print '<div class="div-table-responsive-no-min">';
print '<table summary="more" class="noborder centpercent">';
print '<tr class="liste_titre"><td class="titlefieldmiddle">'.$langs->trans("Parameters").'</td><td width="200px">'.$langs->trans("Value").'</td></tr>';

print '<tr class="oddeven"><td>';
print $langs->trans("BARCODE_ON_STOCKTRANSFER_PDF");
print '</td><td>';
if ($conf->use_javascript_ajax) {
print ajax_constantonoff('BARCODE_ON_STOCKTRANSFER_PDF');
} else {
$arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
print $form->selectarray("BARCODE_ON_STOCKTRANSFER_PDF", $arrval, getDolGlobalString('BARCODE_ON_STOCKTRANSFER_PDF'));
}
print '</td></tr>';

Expand Down
8 changes: 8 additions & 0 deletions htdocs/admin/supplier_order.php
Original file line number Diff line number Diff line change
Expand Up @@ -547,6 +547,14 @@
print "</td>\n";
print "</tr>\n";


// Disallow to classify billed a supplier order without invoice
print '<tr class="oddeven"><td>'.$langs->trans("SupplierOrderClassifyBilledWithoutInvoice"). '&nbsp;' ;
print $form->textwithpicto('', $langs->trans("SupplierOrderClassifyBilledWithoutInvoiceHelp"), 1, 'help') . '</td>';
print '<td class="left" colspan="2">';
print ajax_constantonoff('SUPPLIER_ORDER_DISABLE_CLASSIFY_BILLED_FROM_SUPPLIER_ORDER');
print '</td></tr>';

print '</table></div><br>';

print '</form>';
Expand Down
4 changes: 2 additions & 2 deletions htdocs/commande/card.php
Original file line number Diff line number Diff line change
Expand Up @@ -3055,12 +3055,12 @@
// Set billed or unbilled
// Note: Even if module invoice is not enabled, we should be able to use button "Classified billed"
if ($object->statut > Commande::STATUS_DRAFT && !$object->billed && $object->total_ttc >= 0) {
if ($usercancreate && $object->statut >= Commande::STATUS_VALIDATED && !getDolGlobalString('WORKFLOW_DISABLE_CLASSIFY_BILLED_FROM_ORDER') && !getDolGlobalString('WORKFLOW_BILL_ON_SHIPMENT')) {
if ($usercancreate && $object->statut >= Commande::STATUS_VALIDATED && !getDolGlobalString('ORDER_DISABLE_CLASSIFY_BILLED_FROM_ORDER') && !getDolGlobalString('WORKFLOW_BILL_ON_SHIPMENT')) {
print dolGetButtonAction('', $langs->trans('ClassifyBilled'), 'default', $_SERVER["PHP_SELF"].'?action=classifybilled&amp;token='.newToken().'&amp;id='.$object->id, '');
}
}
if ($object->statut > Commande::STATUS_DRAFT && $object->billed) {
if ($usercancreate && $object->statut >= Commande::STATUS_VALIDATED && !getDolGlobalString('WORKFLOW_DISABLE_CLASSIFY_BILLED_FROM_ORDER') && !getDolGlobalString('WORKFLOW_BILL_ON_SHIPMENT')) {
if ($usercancreate && $object->statut >= Commande::STATUS_VALIDATED && !getDolGlobalString('ORDER_DISABLE_CLASSIFY_BILLED_FROM_ORDER') && !getDolGlobalString('WORKFLOW_BILL_ON_SHIPMENT')) {
print dolGetButtonAction('', $langs->trans('ClassifyUnBilled'), 'delete', $_SERVER["PHP_SELF"].'?action=classifyunbilled&amp;token='.newToken().'&amp;id='.$object->id, '');
}
}
Expand Down
4 changes: 2 additions & 2 deletions htdocs/core/actions_setmoduleoptions.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

// $error must have been initialized to 0
// $action must be defined
// $arrayofparameters must be set for action 'update'
// $arrayofparameters must be set to list of parameters to update for action 'update' on constants
// $nomessageinupdate can be set to 1
// $nomessageinsetmoduleoptions can be set to 1
// $formSetup may be defined
Expand All @@ -35,7 +35,7 @@
}


if ($action == 'update' && is_array($arrayofparameters) && !empty($user->admin)) {
if ($action == 'update' && !empty($arrayofparameters) && is_array($arrayofparameters) && !empty($user->admin)) {
$db->begin();

foreach ($arrayofparameters as $key => $val) {
Expand Down
6 changes: 5 additions & 1 deletion htdocs/core/class/commonobject.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -4949,7 +4949,7 @@ public function getTotalDiscount()
* Return into unit=0, the calculated total of weight and volume of all lines * qty
* Calculate by adding weight and volume of each product line, so properties ->volume/volume_units/weight/weight_units must be loaded on line.
*
* @return array{weight:int|float,volume:int|float,ordered:int|float,toship:int|float} array('weight'=>...,'volume'=>...)
* @return array{weight:int|float,volume:int|float,ordered:int|float,toship:int|float}|array{} array('weight'=>...,'volume'=>...)
*/
public function getTotalWeightVolume()
{
Expand All @@ -4960,6 +4960,10 @@ public function getTotalWeightVolume()
// defined for shipment only
$totalToShip = '';

if (empty($this->lines)) {
return array();
}

foreach ($this->lines as $line) {
if (isset($line->qty_asked)) {
if (empty($totalOrdered)) {
Expand Down
2 changes: 1 addition & 1 deletion htdocs/core/class/extrafields.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -2555,7 +2555,7 @@ public function getOptionalsFromPost($extrafieldsobjectkey, $keyprefix = '', $ke
}
$value_key = dol_htmlcleanlastbr(GETPOST($keysuffix."options_".$key.$keyprefix, 'restricthtml'));
} else {
if (!GETPOST($keysuffix."options_".$key.$keyprefix)) {
if (!GETPOSTISSET($keysuffix."options_".$key.$keyprefix)) {
continue; // Value was not provided, we should not set it.
}
$value_key = GETPOST($keysuffix."options_".$key.$keyprefix);
Expand Down
53 changes: 28 additions & 25 deletions htdocs/core/lib/barcode.lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,14 @@
/**
* Print barcode
*
* @param string $code Code
* @param string $encoding Encoding ('EAN13', 'ISBN', 'C128', 'UPC', 'CBR', 'QRCODE', 'DATAMATRIX', 'ANY'...)
* @param int<1,max> $scale Scale
* @param string $mode 'png' or 'jpg' ...
* @param string $code Code
* @param string $encoding Encoding ('EAN13', 'ISBN', 'C128', 'UPC', 'CBR', 'QRCODE', 'DATAMATRIX', 'ANY'...)
* @param int<1,max> $scale Scale
* @param string $mode 'png', 'gif', 'jpg', 'jpeg' ...
* @param string $filebarcode Filename to store barcode image file if defined
* @return array{encoding:string,bars:string,text:string}|string $bars array('encoding': the encoding which has been used, 'bars': the bars, 'text': text-positioning info) or string with error message
*/
function barcode_print($code, $encoding = "ANY", $scale = 2, $mode = "png")
function barcode_print($code, $encoding = "ANY", $scale = 2, $mode = "png", $filebarcode = '')
{
dol_syslog("barcode.lib.php::barcode_print $code $encoding $scale $mode");

Expand All @@ -100,7 +101,9 @@ function barcode_print($code, $encoding = "ANY", $scale = 2, $mode = "png")
//if (preg_match("/^(text|txt|plain)$/i",$mode)) print barcode_outtext($bars['text'],$bars['bars']);
//elseif (preg_match("/^(html|htm)$/i",$mode)) print barcode_outhtml($bars['text'],$bars['bars'], $scale,0, 0);
//else
barcode_outimage($bars['text'], $bars['bars'], $scale, $mode);

barcode_outimage($bars['text'], $bars['bars'], $scale, $mode, 0, [], $filebarcode);

return $bars;
}

Expand Down Expand Up @@ -399,20 +402,20 @@ function barcode_encode_genbarcode($code, $encoding)
}

/**
* Output image onto standard output, or onto disk if global filebarcode is defined
* Output image onto standard output, or onto disk if $filebarcode is defined
*
* @param string $text the text-line (<position>:<font-size>:<character> ...)
* @param string $bars where to place the bars (<space-width><bar-width><space-width><bar-width>...)
* @param int<1,max> $scale scale factor ( 1 < scale < unlimited (scale 50 will produce 5400x300 pixels when using EAN-13!!!))
* @param string $mode png,gif,jpg (default='png')
* @param int $total_y the total height of the image ( default: scale * 60 )
* @param string $text the text-line (<position>:<font-size>:<character> ...)
* @param string $bars where to place the bars (<space-width><bar-width><space-width><bar-width>...)
* @param int<1,max> $scale scale factor ( 1 < scale < unlimited (scale 50 will produce 5400x300 pixels when using EAN-13!!!))
* @param string $mode Mime 'png', 'gif', 'jpg', 'jpeg' (default='png') or file disk if empty.
* @param int $total_y the total height of the image ( default: scale * 60 )
* @param array{}|array{top:int,bottom:int,left:int,right:int} $space default: $space[top] = 2 * $scale; $space[bottom]= 2 * $scale; $space[left] = 2 * $scale; $space[right] = 2 * $scale;
* @return string|void
* @param string $filebarcode Filename to store barcode image file
* @return void
*/
function barcode_outimage($text, $bars, $scale = 1, $mode = "png", $total_y = 0, $space = [])
function barcode_outimage($text, $bars, $scale = 1, $mode = "png", $total_y = 0, $space = [], $filebarcode = '')
{
global $bar_color, $bg_color, $text_color;
global $font_loc, $filebarcode;
global $bar_color, $bg_color, $text_color, $font_loc;

//print "$text, $bars, $scale, $mode, $total_y, $space, $font_loc, $filebarcode<br>";

Expand Down Expand Up @@ -452,7 +455,7 @@ function barcode_outimage($text, $bars, $scale = 1, $mode = "png", $total_y = 0,
$xpos = $space['left'];
if (!function_exists("imagecreate")) {
print "You don't have the gd2 extension enabled<br>\n";
return "";
return;
}
$im = imagecreate($total_x, $total_y);
/* create two images */
Expand Down Expand Up @@ -496,17 +499,17 @@ function barcode_outimage($text, $bars, $scale = 1, $mode = "png", $total_y = 0,

/* output the image */
$mode = strtolower($mode);
if ($mode == 'jpg' || $mode == 'jpeg') {
header("Content-Type: image/jpeg; name=\"barcode.jpg\"");
if (!empty($filebarcode) && (empty($mode) || $mode == 'png')) {
// To write into a file onto disk
imagepng($im, $filebarcode);
} elseif ($mode == 'jpg' || $mode == 'jpeg') {
top_httphead('image/jpeg; name="barcode.jpg"');
imagejpeg($im);
} elseif ($mode == 'gif') {
header("Content-Type: image/gif; name=\"barcode.gif\"");
top_httphead('image/gif; name="barcode.gif"');
imagegif($im);
} elseif (!empty($filebarcode)) {
// To write into a file onto disk
imagepng($im, $filebarcode);
} else {
header("Content-Type: image/png; name=\"barcode.png\"");
} elseif ($mode == 'png') {
top_httphead('image/png; name="barcode.png"');
imagepng($im);
}

Expand Down
2 changes: 1 addition & 1 deletion htdocs/core/lib/pdf.lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -651,7 +651,7 @@ function pdf_build_address($outputlangs, $sourcecompany, $targetcompany = '', $t
if (!empty($targetcontact->thirdparty->id) && $targetcontact->thirdparty->tva_intra) {
$stringaddress .= ($stringaddress ? "\n" : '') . $outputlangs->transnoentities("VATIntraShort") . ': ' . $outputlangs->convToOutputCharset($targetcontact->thirdparty->tva_intra);
}
} elseif ($targetcompany->tva_intra) {
} elseif (!empty($targetcompany->tva_intra)) {
$stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->transnoentities("VATIntraShort").': '.$outputlangs->convToOutputCharset($targetcompany->tva_intra);
}
}
Expand Down
Loading

0 comments on commit 199e591

Please sign in to comment.