2
0
forked from Wavyzz/dolibarr

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

This commit is contained in:
Laurent Destailleur
2024-08-30 16:44:24 +02:00
17 changed files with 202 additions and 95 deletions

View File

@@ -3204,7 +3204,7 @@ class Facture extends CommonInvoice
* @param string $force_number Reference to force on invoice
* @param int $idwarehouse Id of warehouse to use for stock decrease if option to decrease on stock is on (0=no decrease)
* @param int $notrigger 1=Does not execute triggers, 0= execute triggers
* @param int $batch_rule 0=do not decrement batch, else batch rule to use, 1=take in batches ordered by sellby and eatby dates
* @param int $batch_rule 0=do not decrement batch, else batch rule to use: 1=take lot/serial ordered by sellby and eatby dates
* @return int Return integer <0 if KO, 0=Nothing done because invoice is not a draft, >0 if OK
*/
public function validate($user, $force_number = '', $idwarehouse = 0, $notrigger = 0, $batch_rule = 0)
@@ -3321,7 +3321,7 @@ class Facture extends CommonInvoice
if (!$vallabel && getDolGlobalString($keymandatory)) {
$langs->load("errors");
$error++;
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv($val)), null, 'errors');
$this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv($val));
}
}
@@ -3393,7 +3393,7 @@ class Facture extends CommonInvoice
dol_syslog(get_class($this)."::validate", LOG_DEBUG);
$resql = $this->db->query($sql);
if (!$resql) {
dol_print_error($this->db);
$this->error = $this->db->lasterror();
$error++;
}
@@ -3408,7 +3408,7 @@ class Facture extends CommonInvoice
// Define third party as a customer
$result = $this->thirdparty->setAsCustomer();
// If active we decrement the main product and its components at invoice validation
// If active (STOCK_CALCULATE_ON_BILL), we decrement the main product and its components at invoice validation
if ($this->type != self::TYPE_DEPOSIT && $result >= 0 && isModEnabled('stock') && getDolGlobalString('STOCK_CALCULATE_ON_BILL') && $idwarehouse > 0) {
require_once DOL_DOCUMENT_ROOT.'/product/stock/class/mouvementstock.class.php';
$langs->load("agenda");
@@ -3418,20 +3418,23 @@ class Facture extends CommonInvoice
for ($i = 0; $i < $cpt; $i++) {
if ($this->lines[$i]->fk_product > 0) {
$mouvP = new MouvementStock($this->db);
$mouvP->origin = &$this;
$mouvP->origin = &$this; // deprecated
$mouvP->setOrigin($this->element, $this->id);
// TODO If warehouseid has been set into invoice line, we should use this value in priority
// $idwarehouse = $this->lines[$i]->fk_warehouse;
// We decrease stock for product
if ($this->type == self::TYPE_CREDIT_NOTE) {
$result = $mouvP->reception($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, 0, $langs->trans("InvoiceValidatedInDolibarr", $num));
// TODO If warehouseid has been set into invoice line, we should use this value in priority
// $newidwarehouse = $this->lines[$i]->fk_warehouse ? $this->lines[$i]->fk_warehouse : $idwarehouse;
$result = $mouvP->reception($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, 0, $langs->trans("InvoiceValidatedInDolibarr", $num), '', '', $this->lines[$i]->batch);
if ($result < 0) {
$error++;
$this->error = $mouvP->error;
$this->errors = array_merge($this->errors, $mouvP->errors);
}
} else {
// TODO If warehouseid has been set into invoice line, we should use this value in priority
// $newidwarehouse = $this->lines[$i]->fk_warehouse ? $this->lines[$i]->fk_warehouse : $idwarehouse;
$is_batch_line = false;
if ($batch_rule > 0) {
$productStatic->fetch($this->lines[$i]->fk_product);
@@ -3441,7 +3444,7 @@ class Facture extends CommonInvoice
$sortfield = null;
$sortorder = null;
// find all batch order by sellby (DLC) and eatby dates (DLUO) first
// find lot/serial by sellby (DLC) and eatby dates (DLUO) first
if ($batch_rule == Productbatch::BATCH_RULE_SELLBY_EATBY_DATES_FIRST) {
$sortfield = 'pl.sellby,pl.eatby,pb.qty,pl.rowid';
$sortorder = 'ASC,ASC,ASC,ASC';
@@ -3479,7 +3482,7 @@ class Facture extends CommonInvoice
if ($result < 0) {
$error++;
$this->error = $mouvP->error;
$this->errors = $mouvP->errors;
$this->errors = array_merge($this->errors, $mouvP->errors);
break;
}
@@ -3498,7 +3501,7 @@ class Facture extends CommonInvoice
if ($result < 0) {
$error++;
$this->error = $mouvP->error;
$this->errors = $mouvP->errors;
$this->errors = array_merge($this->errors, $mouvP->errors);
}
} else {
$error++;
@@ -3512,12 +3515,12 @@ class Facture extends CommonInvoice
}
}
if (!$is_batch_line) {
if (!$is_batch_line) { // If stock move not yet processed
$result = $mouvP->livraison($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, $this->lines[$i]->subprice, $langs->trans("InvoiceValidatedInDolibarr", $num));
if ($result < 0) {
$error++;
$this->error = $mouvP->error;
$this->errors = $mouvP->errors;
$this->errors = array_merge($this->errors, $mouvP->errors);
}
}
}
@@ -3540,7 +3543,7 @@ class Facture extends CommonInvoice
}
if ($result < 0) {
$this->error = $invoice_situation->error;
$this->errors = $invoice_situation->errors;
$this->errors = array_merge($this->errors, $invoice_situation->errors);
$error++;
}
}
@@ -6461,7 +6464,8 @@ class FactureLigne extends CommonInvoiceLine
$sql .= ' info_bits, total_ht, total_tva, total_ttc, total_localtax1, total_localtax2,';
$sql .= ' situation_percent, fk_prev_id,';
$sql .= ' fk_unit, fk_user_author, fk_user_modif,';
$sql .= ' fk_multicurrency, multicurrency_code, multicurrency_subprice, multicurrency_total_ht, multicurrency_total_tva, multicurrency_total_ttc';
$sql .= ' fk_multicurrency, multicurrency_code, multicurrency_subprice, multicurrency_total_ht, multicurrency_total_tva, multicurrency_total_ttc,';
$sql .= ' batch, fk_warehouse';
$sql .= ')';
$sql .= " VALUES (".$this->fk_facture.",";
$sql .= " ".($this->fk_parent_line > 0 ? $this->fk_parent_line : "null").",";
@@ -6504,6 +6508,8 @@ class FactureLigne extends CommonInvoiceLine
$sql .= ", ".price2num($this->multicurrency_total_ht);
$sql .= ", ".price2num($this->multicurrency_total_tva);
$sql .= ", ".price2num($this->multicurrency_total_ttc);
$sql .= ", '".$this->db->escape($this->batch)."'";
$sql .= ", ".((int) $this->fk_warehouse);
$sql .= ')';
dol_syslog(get_class($this)."::insert", LOG_DEBUG);
@@ -6718,6 +6724,9 @@ class FactureLigne extends CommonInvoiceLine
$sql .= ", multicurrency_total_tva=".price2num($this->multicurrency_total_tva);
$sql .= ", multicurrency_total_ttc=".price2num($this->multicurrency_total_ttc);
$sql .= ", batch = '".$this->db->escape($this->batch)."'";
$sql .= ", fk_warehouse = ".((int) $this->fk_warehouse);
$sql .= " WHERE rowid = ".((int) $this->rowid);
dol_syslog(get_class($this)."::update", LOG_DEBUG);

View File

@@ -6666,8 +6666,8 @@ function vatrate($rate, $addpercent = false, $info_bits = 0, $usestarfornpr = 0,
* @param int<0,1> $form Type of formatting: 1=HTML, 0=no formatting (no by default)
* @param Translate|string|null $outlangs Object langs for output. '' use default lang. 'none' use international separators.
* @param int $trunc 1=Truncate if there is more decimals than MAIN_MAX_DECIMALS_SHOWN (default), 0=Does not truncate. Deprecated because amount are rounded (to unit or total amount accuracy) before being inserted into database or after a computation, so this parameter should be useless.
* @param int $rounding MINIMUM number of decimal to show: 0=no change, -1=we use min($conf->global->MAIN_MAX_DECIMALS_UNIT,$conf->global->MAIN_MAX_DECIMALS_TOT)
* @param int|string $forcerounding MAXIMUM number of decimal to forcerounding decimal: -1=no change, 'MU' or 'MT' or a numeric to round to MU or MT or to a given number of decimal
* @param int $rounding MINIMUM number of decimal to show: 0=no change, -1=we use min(getDolGlobalString('MAIN_MAX_DECIMALS_UNIT'), getDolGlobalString('MAIN_MAX_DECIMALS_TOT'))
* @param int|string $forcerounding MAXIMUM number of decimal to forcerounding decimal: -1=no change, -2=keep non zero part, 'MU' or 'MT' or a numeric to round to MU or MT or to a given number of decimal
* @param string $currency_code To add currency symbol (''=add nothing, 'auto'=Use default currency, 'XXX'=add currency symbols for XXX currency)
* @return string String with formatted amount
*

View File

@@ -75,7 +75,7 @@ class modDataPolicy extends DolibarrModules
// Name of image file used for this module.
// If file is in theme/yourtheme/img directory under name object_pictovalue.png, use this->picto='pictovalue'
// If file is in module/img directory under name object_pictovalue.png, use this->picto='pictovalue@module'
$this->picto = 'generic';
$this->picto = 'lock';
// Defined all module parts (triggers, login, substitutions, menus, css, etc...)
// for default path (eg: /datapolicy/core/xxxxx) (0=disable, 1=enable)

View File

@@ -1,7 +1,7 @@
<?php
/* Copyright (C) 2004-2017 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2018 Nicolas ZABOURI <info@inovea-conseil.com>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
*
* 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
@@ -35,6 +35,10 @@ $langs->loadLangs(array('admin', 'companies', 'members', 'datapolicy'));
$action = GETPOST('action', 'aZ09');
$backtopage = GETPOST('backtopage', 'alpha');
if (empty($action)) {
$action = 'edit';
}
$arrayofparameters = array();
$arrayofparameters['ThirdParty'] = array(
'DATAPOLICY_TIERS_CLIENT' => array('css' => 'minwidth200', 'picto' => img_picto('', 'company', 'class="pictofixedwidth"')),
@@ -85,6 +89,9 @@ if (!$user->admin) {
/*
* Actions
*/
$nbdone = 0;
foreach ($arrayofparameters as $title => $tab) {
foreach ($tab as $key => $val) {
// Modify constant only if key was posted (avoid resetting key to the null value)
@@ -103,11 +110,19 @@ foreach ($arrayofparameters as $title => $tab) {
if ($result < 0) {
$error++;
break;
} else {
$nbdone++;
}
}
}
}
if ($nbdone) {
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
}
if ($action == 'update') {
$action = 'edit';
}
/*
@@ -127,7 +142,9 @@ $head = datapolicyAdminPrepareHead();
print dol_get_fiche_head($head, 'settings', '', -1, '');
// Setup page goes here
echo '<span class="opacitymedium">'.$langs->trans("datapolicySetupPage").'</span><br><br>';
print '<span class="opacitymedium">'.$langs->trans("datapolicySetupPage").'</span><br>';
// print $form->textwithpicto('', $langs->trans('DATAPOLICY_Tooltip_SETUP'));
print '<br>';
if ($action == 'edit') {
@@ -136,45 +153,44 @@ if ($action == 'edit') {
print '<input type="hidden" name="action" value="update">';
print '<table class="noborder centpercent">';
print '<tr class="liste_titre"><td class="titlefield">'.$langs->trans("Parameter").'</td><td>'.$langs->trans("Value").'</td></tr>';
//print '<tr class="liste_titre"><td class="titlefield">'.$langs->trans("Parameter").'</td><td></td></tr>';
foreach ($arrayofparameters as $title => $tab) {
print '<tr class="trforbreak"><td class="titlefield trforbreak" colspan="2">'.$langs->trans($title).'</td></tr>';
foreach ($tab as $key => $val) {
print '<tr class="oddeven"><td>';
print $val['picto'];
print $form->textwithpicto($langs->trans($key), $langs->trans('DATAPOLICY_Tooltip_SETUP'));
print $langs->trans($key);
print '</td><td>';
print '<select name="'.$key.'" class="flat '.(empty($val['css']) ? 'minwidth200' : $val['css']).'">';
print '<select name="'.$key.'" id="'.$key.'" class="flat '.(empty($val['css']) ? 'minwidth200' : $val['css']).'">';
foreach ($valTab as $key1 => $val1) {
print '<option value="'.$key1.'" '.(getDolGlobalString($key) == $key1 ? 'selected="selected"' : '').'>';
print $val1;
print '</option>';
}
print '</select>';
print ajax_combobox($key);
print '</td></tr>';
}
}
print '</table>';
print '<br><div class="center">';
print '<input class="button button-save" type="submit" value="'.$langs->trans("Save").'">';
print '</div>';
print $form->buttonsSaveCancel("Save", '');
print '</form>';
print '<br>';
} else {
print '<table class="noborder centpercent">';
print '<tr class="liste_titre"><td class="titlefield">'.$langs->trans("Parameter").'</td><td>'.$langs->trans("Value").'</td></tr>';
//print '<tr class="liste_titre"><td class="titlefield">'.$langs->trans("Parameter").'</td><td></td></tr>';
foreach ($arrayofparameters as $title => $tab) {
print '<tr class="trforbreak"><td class="titlefield trforbreak" colspan="2">'.$langs->trans($title).'</td></tr>';
foreach ($tab as $key => $val) {
print '<tr class="oddeven"><td>';
print $val['picto'];
print $form->textwithpicto($langs->trans($key), $langs->trans('DATAPOLICY_Tooltip_SETUP'));
print '</td><td>'.(getDolGlobalString($key) == '' ? $langs->trans('None') : $valTab[getDolGlobalString($key)]).'</td></tr>';
print $langs->trans($key);
print '</td><td>'.(getDolGlobalString($key) == '' ? '<span class="opacitymedium">'.$valTab[''].'</span>' : $valTab[getDolGlobalString($key)]).'</td></tr>';
}
}

View File

@@ -33,7 +33,7 @@ DATAPOLICY_CONTACT_PROSPECT_CLIENT = Prospect/Customer
DATAPOLICY_CONTACT_NIPROSPECT_NICLIENT = Nor prospect/Nor customer
DATAPOLICY_CONTACT_FOURNISSEUR = Supplier
DATAPOLICY_ADHERENT = Member
DATAPOLICY_Tooltip_SETUP = Type of contact - Indicate your choices for each type.
DATAPOLICY_Tooltip_SETUP=Define the delay with no interaction after which you want the record to be automatically purged.
SendAgreementText = You can send a GDPR email to all your relevant contacts (who have not yet received an email and for which you have not registered anything about their GDPR agreement). To do this, use the following button.
SendAgreement = Send emails
AllAgreementSend = All emails have been sent

View File

@@ -295,8 +295,8 @@ CurrencyXPF=CFP Francs
CurrencySingXPF=CFP Franc
CurrencyCentEUR=cents
CurrencyCentSingEUR=cent
CurrencyCentINR=paisa
CurrencyCentSingINR=paise
CurrencyCentINR=paise
CurrencyCentSingINR=paisa
CurrencyThousandthSingTND=thousandth
#### Input reasons #####
DemandReasonTypeSRC_INTE=Internet

View File

@@ -84,9 +84,11 @@ print '<form action="'.$_SERVER["PHP_SELF"].'?terminal='.(empty($terminal) ? 1 :
print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="action" value="set">';
print '<br>';
print '<table class="noborder centpercent">';
print '<tr class="liste_titre">';
print '<td class="titlefield">'.$langs->trans("Parameters").'</td><td>'.$langs->trans("Value").'</td>';
print '<td>'.$langs->trans("Parameters").'</td><td></td>';
print "</tr>\n";
// Color theme

View File

@@ -123,7 +123,7 @@ if (getDolGlobalInt('TAKEPOS_BAR_RESTAURANT')) {
print '<div class="div-table-responsive-no-min">';
print '<table class="noborder centpercent">';
print '<tr class="liste_titre">';
print '<td>'.$langs->trans("Parameters").'</td><td class="">'.$langs->trans("Value").'</td>';
print '<td>'.$langs->trans("Parameters").'</td><td class=""></td>';
print "</tr>\n";
print '<tr class="oddeven value"><td>';

View File

@@ -96,7 +96,10 @@ $url = 'https://www.dolistore.com/45-pos';
print '<tr class="oddeven">'."\n";
print '<td class="titlefield"><a href="'.$url.'" target="_blank" rel="noopener noreferrer external"><img border="0" class="imgautosize imgmaxwidth180" src="'.DOL_URL_ROOT.'/theme/dolistore_logo.png"></a></td>';
print '<td>'.$langs->trans("DolistorePosCategory").'</td>';
print '<td><a href="'.$url.'" target="_blank" rel="noopener noreferrer external">'.$url.'</a></td>';
print '<td>';
print '<a href="'.$url.'" target="_blank" rel="noopener noreferrer external">';
print img_picto('', 'url', 'class="pictofixedwidth"');
print $url.'</a></td>';
print '</tr>';
print "</table>\n";
@@ -118,9 +121,12 @@ print '</tr>';
$url = 'https://www.takepos.com';
print '<tr class="oddeven">'."\n";
print '<td class="left"><a href="'.$url.'" target="_blank" rel="noopener noreferrer external"><img border="0" class="imgautosize imgmaxwidth180" src="../img/takepos.png"></a></td>';
print '<td class="titlefield"><a href="'.$url.'" target="_blank" rel="noopener noreferrer external"><img border="0" class="imgautosize imgmaxwidth180" src="../img/takepos.png"></a></td>';
print '<td>TakePOS original developers</td>';
print '<td><a href="'.$url.'" target="_blank" rel="noopener noreferrer external">'.$url.'</a></td>';
print '<td>';
print '<a href="'.$url.'" target="_blank" rel="noopener noreferrer external">';
print img_picto('', 'url', 'class="pictofixedwidth"');
print $url.'</a></td>';
print '</tr>';
print "</table>\n";

View File

@@ -211,12 +211,14 @@ print "</td></tr>\n";
print '</table>';
print '</div>';
print '<br>';
print $form->buttonsSaveCancel("Save", '');
print "</form>\n";
print '<br>';
print load_fiche_titre($langs->trans("Preview"), '', '');
print '<div style="width: 50%; float:center;background-color:#606060">';
print '<center>';

View File

@@ -250,6 +250,9 @@ print "\n";
print '<br>';
print load_fiche_titre($langs->trans('Options'), '', '');
// Mode
print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
print '<input type="hidden" name="token" value="'.newToken().'">';
@@ -259,7 +262,7 @@ print '<div class="div-table-responsive-no-min">';
print '<table class="noborder centpercent">';
print '<tr class="liste_titre">';
print '<td class="notitlefield">'.$langs->trans("Parameters").'</td><td>'.$langs->trans("Value").'</td>';
print '<td class="notitlefield">'.$langs->trans("Parameters").'</td><td></td>';
print "</tr>\n";
// Terminals
@@ -479,7 +482,7 @@ if (getDolGlobalInt('TAKEPOS_ENABLE_SUMUP')) {
print '<table class="noborder centpercent">';
print '<tr class="liste_titre">';
print '<td class="titlefield">'.$langs->trans("Sumup").'</td><td>'.$langs->trans("Value").'</td>';
print '<td class="titlefield">'.$langs->trans("Sumup").'</td><td></td>';
print "</tr>\n";
print '<tr class="oddeven"><td>';
@@ -497,8 +500,6 @@ if (getDolGlobalInt('TAKEPOS_ENABLE_SUMUP')) {
print '</div>';
}
print '<br>';
print $form->buttonsSaveCancel("Save", '');
print "</form>\n";

View File

@@ -184,7 +184,7 @@ print '<input type="hidden" name="action" value="set">';
print '<div class="div-table-responsive">';
print '<table class="noborder centpercent">';
print '<tr class="liste_titre">';
print '<td>'.$langs->trans("Parameters").'</td><td>'.$langs->trans("Value").'</td>';
print '<td>'.$langs->trans("Parameters").'</td><td></td>';
print "</tr>\n";
print '<tr class="oddeven"><td class="fieldrequired">'.$langs->trans("TerminalNameDesc").'</td>';
@@ -477,6 +477,9 @@ if (getDolGlobalString('TAKEPOS_ADDON') == "terminal") {
}
print '</table>';
print $form->buttonsSaveCancel("Save", '');
print '</div>';
// add free text on each terminal of cash desk
@@ -536,8 +539,6 @@ if ($atleastonefound == 0 && isModEnabled("bank")) {
print info_admin($langs->trans("AtLeastOneDefaultBankAccountMandatory"), 0, 0, 'error');
}
print '<br>';
print $form->buttonsSaveCancel("Save", '');
print "</form>\n";

View File

@@ -112,7 +112,7 @@ top_htmlhead('', '', 0, 0, $arrayofjs, $arrayofcss);
*/
function Save() {
console.log("We click so we call page invoice.php with invoiceid=<?php echo $invoiceid; ?>, place=<?php echo $place; ?>, amount="+$("#number").val()+", tva_tx="+vatRate);
parent.$("#poslines").load("invoice.php?action=freezone&token=<?php echo newToken(); ?>&invoiceid=<?php echo $invoiceid; ?>&place=<?php echo $place; ?>&number="+$("#number").val()+"&tva_tx="+vatRate, {desc:$("#desc").val()});
parent.$("#poslines").load("<?php echo DOL_URL_ROOT; ?>/takepos/invoice.php?action=freezone&token=<?php echo newToken(); ?>&invoiceid=<?php echo $invoiceid; ?>&place=<?php echo $place; ?>&number="+$("#number").val()+"&tva_tx="+vatRate, {desc:$("#desc").val()});
parent.$.colorbox.close();
}

View File

@@ -537,10 +537,12 @@ function ClickProduct(position, qty = 1) {
console.log($('#prodiv4').data('rowid'));
invoiceid = $("#invoiceid").val();
idproduct=$('#prodiv'+position).data('rowid');
console.log("Click on product at position "+position+" for idproduct "+idproduct+", qty="+qty+" invoicdeid="+invoiceid);
if (idproduct=="") return;
console.log("Click on product at position "+position+" for idproduct "+idproduct+", qty="+qty+" invoiceid="+invoiceid);
if (idproduct == "") {
return;
}
// Call page invoice.php to generate the section with product lines
$("#poslines").load("invoice.php?action=addline&token=<?php echo newToken() ?>&place="+place+"&idproduct="+idproduct+"&qty="+qty+"&invoiceid="+invoiceid, function() {
$("#poslines").load("invoice.php?action=addline&token=<?php echo newToken(); ?>&place="+place+"&idproduct="+idproduct+"&qty="+qty+"&invoiceid="+invoiceid, function() {
<?php if (getDolGlobalString('TAKEPOS_CUSTOMER_DISPLAY')) {
echo "CustomerDisplay();";
}?>

View File

@@ -233,6 +233,8 @@ if (empty($reshook)) {
}
$constantforkey = 'CASHDESK_NO_DECREASE_STOCK'.(isset($_SESSION["takeposterminal"]) ? $_SESSION["takeposterminal"] : '');
$allowstockchange = (getDolGlobalString($constantforkey) != "1");
if ($error) {
dol_htmloutput_errors($errormsg, null, 1);
} elseif ($invoice->status != Facture::STATUS_DRAFT) {
@@ -247,31 +249,25 @@ if (empty($reshook)) {
$error++;
dol_syslog('Sale without lines');
dol_htmloutput_errors($langs->trans("NoLinesToBill", "TakePos"), null, 1);
} elseif (isModEnabled('stock') && !isModEnabled('productbatch') && getDolGlobalString($constantforkey) != "1") {
// Validation of invoice with change into stock when produt/lot module is not enabled and stock change not disabled.
} elseif (isModEnabled('stock') && !isModEnabled('productbatch') && $allowstockchange) {
// Validation of invoice with change into stock when produt/lot module is NOT enabled and stock change NOT disabled.
// The case for isModEnabled('productbatch') is processed few lines later.
$savconst = getDolGlobalString('STOCK_CALCULATE_ON_BILL');
if (isModEnabled('productbatch') && !getDolGlobalInt('CASHDESK_FORCE_DECREASE_STOCK')) {
$conf->global->STOCK_CALCULATE_ON_BILL = 0; // To not change the stock (this will be done later)
} else {
// Deprecated: CASHDESK_FORCE_DECREASE_STOCK is now always false. No more required/used.
$conf->global->STOCK_CALCULATE_ON_BILL = 1; // To force the change of stock
}
$conf->global->STOCK_CALCULATE_ON_BILL = 1; // To force the change of stock during invoice validation
$constantforkey = 'CASHDESK_ID_WAREHOUSE'.$_SESSION["takeposterminal"];
dol_syslog("Validate invoice with stock change into warehouse defined into constant ".$constantforkey." = ".getDolGlobalString($constantforkey));
dol_syslog("Validate invoice with stock change. Warehouse defined into constant ".$constantforkey." = ".getDolGlobalString($constantforkey));
$batch_rule = 0;
if (isModEnabled('productbatch') && getDolGlobalString('CASHDESK_FORCE_DECREASE_STOCK')) {
require_once DOL_DOCUMENT_ROOT.'/product/class/productbatch.class.php';
$batch_rule = Productbatch::BATCH_RULE_SELLBY_EATBY_DATES_FIRST;
}
// Validate invoice with stock change into warehouse getDolGlobalInt($constantforkey)
// Label of stock movement will be the same as when we validate invoice "Invoice XXXX validated"
$batch_rule = 0; // Module productbatch is disabled here, so no need for a batch_rule.
$res = $invoice->validate($user, '', getDolGlobalInt($constantforkey), 0, $batch_rule);
// Restore setup
$conf->global->STOCK_CALCULATE_ON_BILL = $savconst;
} else {
// Validation of invoice with no change into stock
// Validation of invoice with no change into stock (because param $idwarehouse is not fill)
$res = $invoice->validate($user);
if ($res < 0) {
$error++;
@@ -331,32 +327,41 @@ if (empty($reshook)) {
// Update stock for batch products
if (!$error && $res >= 0) {
if (isModEnabled('stock') && isModEnabled('productbatch')) { // The case !isModEnabled('productbatch') was processed few lines before.
if (isModEnabled('stock') && isModEnabled('productbatch') && $allowstockchange) {
// Update stocks
dol_syslog("Now we record the stock movement for each qualified line");
// The case !isModEnabled('productbatch') was processed few lines before.
require_once DOL_DOCUMENT_ROOT . "/product/stock/class/mouvementstock.class.php";
$constantforkey = 'CASHDESK_ID_WAREHOUSE'.$_SESSION["takeposterminal"];
$inventorycode = dol_print_date(dol_now(), 'dayhourlog');
// Label of stock movement will be "TakePOS - Invoice XXXX"
$labeltakeposmovement = 'TakePOS - '.$langs->trans("Invoice").' '.$invoice->ref;
foreach ($invoice->lines as $line) {
// Use the warehouse id defined on invoice line else in the setup
$warehouseid = ($line->fk_warehouse ? $line->fk_warehouse : getDolGlobalInt($constantforkey));
// var_dump('fk_product='.$line->fk_product.' batch='.$line->batch.' warehouse='.$line->fk_warehouse.' qty='.$line->qty);
if ($line->batch != '' && $warehouseid > 0) {
$prod_batch = new Productbatch($db);
$prod_batch->find(0, '', '', $line->batch, $warehouseid);
$mouvP = new MouvementStock($db);
$mouvP->origin = $invoice;
$mouvP->setOrigin($invoice->element, $invoice->id);
$res = $mouvP->livraison($user, $line->fk_product, $warehouseid, $line->qty, $line->price, $labeltakeposmovement, '', '', '', $prod_batch->batch, $prod_batch->id, $inventorycode);
if ($res < 0) {
setEventMessages($mouvP->error, $mouvP->errors, 'errors');
dol_htmloutput_errors($mouvP->error, $mouvP->errors, 1);
$error++;
}
} else {
$mouvP = new MouvementStock($db);
$mouvP->origin = $invoice;
$mouvP->setOrigin($invoice->element, $invoice->id);
$res = $mouvP->livraison($user, $line->fk_product, $warehouseid, $line->qty, $line->price, $labeltakeposmovement, '', '', '', '', 0, $inventorycode);
if ($res < 0) {
setEventMessages($mouvP->error, $mouvP->errors, 'errors');
dol_htmloutput_errors($mouvP->error, $mouvP->errors, 1);
$error++;
}
}
@@ -387,11 +392,6 @@ if (empty($reshook)) {
$fk_parent_line = 0; // Initialise
foreach ($invoice->lines as $line) {
// Extrafields
if (method_exists($line, 'fetch_optionals')) {
// load extrafields
$line->fetch_optionals();
}
// Reset fk_parent_line for no child products and special product
if (($line->product_type != 9 && empty($line->fk_parent_line)) || $line->product_type == 9) {
$fk_parent_line = 0;
@@ -472,6 +472,7 @@ if (empty($reshook)) {
}
}
// We update field for credit notes
$line->fk_facture = $creditnote->id;
$line->fk_parent_line = $fk_parent_line;
@@ -499,36 +500,95 @@ if (empty($reshook)) {
}
$creditnote->update_price(1);
// The credit note is create here. We must now validate it.
$constantforkey = 'CASHDESK_NO_DECREASE_STOCK'.(isset($_SESSION["takeposterminal"]) ? $_SESSION["takeposterminal"] : '');
if (isModEnabled('stock') && getDolGlobalString($constantforkey) != "1") {
$allowstockchange = getDolGlobalString($constantforkey) != "1";
if (isModEnabled('stock') && !isModEnabled('productbatch') && $allowstockchange) {
// If module stock is enabled and we do not setup takepo to disable stock decrease
// The case for isModEnabled('productbatch') is processed few lines later.
$savconst = getDolGlobalString('STOCK_CALCULATE_ON_BILL');
$conf->global->STOCK_CALCULATE_ON_BILL = 1;
$conf->global->STOCK_CALCULATE_ON_BILL = 1; // We force setup to have update of stock on invoice validation/unvalidation
$constantforkey = 'CASHDESK_ID_WAREHOUSE'.(isset($_SESSION["takeposterminal"]) ? $_SESSION["takeposterminal"] : '');
dol_syslog("Validate invoice with stock change into warehouse defined into constant ".$constantforkey." = ".getDolGlobalString($constantforkey));
$batch_rule = 0;
if (isModEnabled('productbatch') && getDolGlobalString('CASHDESK_FORCE_DECREASE_STOCK')) {
require_once DOL_DOCUMENT_ROOT.'/product/class/productbatch.class.php';
$batch_rule = Productbatch::BATCH_RULE_SELLBY_EATBY_DATES_FIRST;
}
dol_syslog("Validate invoice with stock change into warehouse defined into constant ".$constantforkey." = ".getDolGlobalString($constantforkey)." or warehouseid= ".$warehouseid." if defined.");
// Validate invoice with stock change into warehouse getDolGlobalInt($constantforkey)
// Label of stock movement will be the same as when we validate invoice "Invoice XXXX validated"
$batch_rule = 0; // Module productbatch is disabled here, so no need for a batch_rule.
$res = $creditnote->validate($user, '', getDolGlobalString($constantforkey), 0, $batch_rule);
if ($res < 0) {
$error++;
dol_htmloutput_errors($creditnote->error, $creditnote->errors, 1);
}
// Restore setup
$conf->global->STOCK_CALCULATE_ON_BILL = $savconst;
} else {
$res = $creditnote->validate($user);
}
// Update stock for batch products
if (!$error && $res >= 0) {
if (isModEnabled('stock') && isModEnabled('productbatch') && $allowstockchange) {
// Update stocks
dol_syslog("Now we record the stock movement for each qualified line");
// The case !isModEnabled('productbatch') was processed few lines before.
require_once DOL_DOCUMENT_ROOT . "/product/stock/class/mouvementstock.class.php";
$constantforkey = 'CASHDESK_ID_WAREHOUSE'.$_SESSION["takeposterminal"];
$inventorycode = dol_print_date(dol_now(), 'dayhourlog');
// Label of stock movement will be "TakePOS - Invoice XXXX"
$labeltakeposmovement = 'TakePOS - '.$langs->trans("CreditNote").' '.$creditnote->ref;
foreach ($creditnote->lines as $line) {
// Use the warehouse id defined on invoice line else in the setup
$warehouseid = ($line->fk_warehouse ? $line->fk_warehouse : getDolGlobalInt($constantforkey));
//var_dump('fk_product='.$line->fk_product.' batch='.$line->batch.' warehouse='.$line->fk_warehouse.' qty='.$line->qty);exit;
if ($line->batch != '' && $warehouseid > 0) {
//$prod_batch = new Productbatch($db);
//$prod_batch->find(0, '', '', $line->batch, $warehouseid);
$mouvP = new MouvementStock($db);
$mouvP->setOrigin($creditnote->element, $creditnote->id);
$res = $mouvP->reception($user, $line->fk_product, $warehouseid, $line->qty, $line->price, $labeltakeposmovement, '', '', $line->batch, '', 0, $inventorycode);
if ($res < 0) {
dol_htmloutput_errors($mouvP->error, $mouvP->errors, 1);
$error++;
}
} else {
$mouvP = new MouvementStock($db);
$mouvP->setOrigin($creditnote->element, $creditnote->id);
$res = $mouvP->reception($user, $line->fk_product, $warehouseid, $line->qty, $line->price, $labeltakeposmovement, '', '', '', '', 0, $inventorycode);
if ($res < 0) {
dol_htmloutput_errors($mouvP->error, $mouvP->errors, 1);
$error++;
}
}
}
}
}
if (!$error && $res >= 0) {
$db->commit();
} else {
$creditnote->id = $placeid; // Creation has failed, we reset to ID of source invoice so we go back to this one in action=history
$db->rollback();
}
}
if (($action == 'history' || $action == 'creditnote') && $user->hasRight('takepos', 'run')) {
if ($action == 'creditnote') {
if ($action == 'creditnote' && $creditnote->id > 0) {
$placeid = $creditnote->id;
} else {
$placeid = GETPOSTINT('placeid');
}
$invoice = new Facture($db);
$invoice->fetch($placeid);
}
@@ -595,7 +655,7 @@ if (empty($reshook)) {
if (isModEnabled('productbatch') && isModEnabled('stock')) {
$batch = GETPOST('batch', 'alpha');
if (!empty($batch)) { // We have just clicked on the batch number
if (!empty($batch)) { // We have just clicked on a batch number, we will execute action=setbatch later...
$action = "setbatch";
} elseif ($prod->status_batch > 0) {
// If product need a lot/serial, we show the list of lot/serial available for the product...
@@ -610,7 +670,7 @@ if (empty($reshook)) {
//var_dump($prod->stock_warehouse);
foreach ($prod->stock_warehouse as $tmpwarehouseid => $tmpval) {
if (getDolGlobalInt($constantforkey) && $tmpwarehouseid != getDolGlobalInt($constantforkey)) {
// Not on the forced warehous, so we ignore this warehous
// Product to select is not on the warehouse configured for terminal, so we ignore this warehouse
continue;
}
if (!empty($prod->stock_warehouse[$tmpwarehouseid]) && is_array($prod->stock_warehouse[$tmpwarehouseid]->detail_batch)) {
@@ -626,7 +686,7 @@ if (empty($reshook)) {
echo "<script>\n";
echo "function addbatch(batch, warehouseid) {\n";
echo "console.log('We add batch '+batch+' from warehouse id '+warehouseid);\n";
echo '$("#poslines").load("invoice.php?action=addline&batch="+batch+"&warehouseid="+warehouseid+"&place='.$place.'&idproduct='.$idproduct.'&token='.newToken().'", function() {});'."\n";
echo '$("#poslines").load("'.DOL_URL_ROOT.'/takepos/invoice.php?action=addline&batch="+encodeURI(batch)+"&warehouseid="+warehouseid+"&place='.$place.'&idproduct='.$idproduct.'&token='.newToken().'", function() {});'."\n";
echo "}\n";
echo "</script>\n";
@@ -644,7 +704,7 @@ if (empty($reshook)) {
$deliverableQty = min($quantityToBeDelivered, $batchStock);
print '<tr>';
print '<!-- subj='.$suggestednb.'/'.$nbofsuggested.' -->';
print '<!-- Show details of lot -->';
print '<!-- Show details of lot/serial in warehouseid='.$tmpwarehouseid.' -->';
print '<td class="left">';
$detail = '';
$detail .= '<span class="opacitymedium">'.$langs->trans("LotSerial").':</span> '.$dbatch->batch;
@@ -1018,7 +1078,7 @@ if (empty($reshook)) {
if ($action == "setbatch" && ($user->hasRight('takepos', 'run') || defined('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE'))) {
$constantforkey = 'CASHDESK_ID_WAREHOUSE'.$_SESSION["takeposterminal"];
$warehouseid = getDolGlobalInt($constantforkey); // TODO Get the warehouse id from GETPOSTINT('warehouseid');
$warehouseid = (GETPOSTINT('warehouseid') > 0 ? GETPOSTINT('warehouseid') : getDolGlobalInt($constantforkey)); // Get the warehouse id from GETPOSTINT('warehouseid'), otherwise use default setup.
$sql = "UPDATE ".MAIN_DB_PREFIX."facturedet SET batch = '".$db->escape($batch)."', fk_warehouse = ".((int) $warehouseid);
$sql .= " WHERE rowid=".((int) $idoflineadded);
$db->query($sql);
@@ -1406,13 +1466,15 @@ function DolibarrTakeposPrinting(id) {
return true;
}
// Call url to generate a credit note (with same lines) from existing invoice
function CreditNote() {
$("#poslines").load("invoice.php?action=creditnote&token=<?php echo newToken() ?>&invoiceid="+placeid, function() { });
$("#poslines").load("<?php print DOL_URL_ROOT; ?>/takepos/invoice.php?action=creditnote&token=<?php echo newToken() ?>&invoiceid="+placeid, function() { });
return true;
}
// Call url to add notes
function SetNote() {
$("#poslines").load("invoice.php?action=addnote&token=<?php echo newToken() ?>&invoiceid="+placeid+"&idline="+selectedline, { "addnote": $("#textinput").val() });
$("#poslines").load("<?php print DOL_URL_ROOT; ?>/takepos/invoice.php?action=addnote&token=<?php echo newToken() ?>&invoiceid="+placeid+"&idline="+selectedline, { "addnote": $("#textinput").val() });
return true;
}
@@ -1952,13 +2014,18 @@ if ($placeid > 0) {
$stock_real = price2num($obj->reel, 'MS');
}
$htmlforlines .= $line->qty;
$htmlforlines .= '&nbsp; ';
$htmlforlines .= '<span class="opacitylow" title="'.$langs->trans("Stock").' '.price($stock_real, 1, '', 1, 0).'">';
$htmlforlines .= '(';
if ($line->qty && $line->qty > $stock_real) {
$htmlforlines .= '<span style="color: var(--amountremaintopaycolor)">';
}
$htmlforlines .= ' <span class="posstocktoolow">('.$langs->trans("Stock").' '.$stock_real.')</span>';
$htmlforlines .= img_picto('', 'stock', 'class="pictofixedwidth"').price($stock_real, 1, '', 1, 0);
if ($line->qty && $line->qty > $stock_real) {
$htmlforlines .= "</span>";
}
$htmlforlines .= ')';
$htmlforlines .= '</span>';
} else {
dol_print_error($db);
}

View File

@@ -43,9 +43,9 @@ $_SESSION["takeposterminal"] = getDolGlobalInt('TAKEPOS_TERMINAL_NB_FOR_PUBLIC',
define('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE', 1);
if (GETPOSTISSET("mobilepage")) {
require '../invoice.php';
require DOL_URL_ROOT.'/takepos/invoice.php';
} elseif (GETPOSTISSET("genimg")) {
require DOL_DOCUMENT_ROOT.'/takepos/genimg/index.php';
} else {
require '../phone.php';
require DOL_URL_ROOT.'/takepos/phone.php';
}

View File

@@ -156,6 +156,7 @@ div#topmenu-global-search-dropdown a::after, div#topmenu-quickadd-dropdown a::af
/* font part */
font-family: "<?php echo getDolGlobalString('MAIN_FONTAWESOME_FAMILY', 'Font Awesome 5 Free'); ?>";
font-size: 0.7em;
line-height: 0.7em;
font-weight: 900;
font-style: normal;
font-variant: normal;