forked from Wavyzz/dolibarr
Merge branch '20.0' of git@github.com:Dolibarr/dolibarr.git into develop
This commit is contained in:
@@ -3204,7 +3204,7 @@ class Facture extends CommonInvoice
|
|||||||
* @param string $force_number Reference to force on invoice
|
* @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 $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 $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
|
* @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)
|
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)) {
|
if (!$vallabel && getDolGlobalString($keymandatory)) {
|
||||||
$langs->load("errors");
|
$langs->load("errors");
|
||||||
$error++;
|
$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);
|
dol_syslog(get_class($this)."::validate", LOG_DEBUG);
|
||||||
$resql = $this->db->query($sql);
|
$resql = $this->db->query($sql);
|
||||||
if (!$resql) {
|
if (!$resql) {
|
||||||
dol_print_error($this->db);
|
$this->error = $this->db->lasterror();
|
||||||
$error++;
|
$error++;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3408,7 +3408,7 @@ class Facture extends CommonInvoice
|
|||||||
// Define third party as a customer
|
// Define third party as a customer
|
||||||
$result = $this->thirdparty->setAsCustomer();
|
$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) {
|
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';
|
require_once DOL_DOCUMENT_ROOT.'/product/stock/class/mouvementstock.class.php';
|
||||||
$langs->load("agenda");
|
$langs->load("agenda");
|
||||||
@@ -3418,20 +3418,23 @@ class Facture extends CommonInvoice
|
|||||||
for ($i = 0; $i < $cpt; $i++) {
|
for ($i = 0; $i < $cpt; $i++) {
|
||||||
if ($this->lines[$i]->fk_product > 0) {
|
if ($this->lines[$i]->fk_product > 0) {
|
||||||
$mouvP = new MouvementStock($this->db);
|
$mouvP = new MouvementStock($this->db);
|
||||||
$mouvP->origin = &$this;
|
$mouvP->origin = &$this; // deprecated
|
||||||
$mouvP->setOrigin($this->element, $this->id);
|
$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
|
// We decrease stock for product
|
||||||
if ($this->type == self::TYPE_CREDIT_NOTE) {
|
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) {
|
if ($result < 0) {
|
||||||
$error++;
|
$error++;
|
||||||
$this->error = $mouvP->error;
|
$this->error = $mouvP->error;
|
||||||
|
$this->errors = array_merge($this->errors, $mouvP->errors);
|
||||||
}
|
}
|
||||||
} else {
|
} 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;
|
$is_batch_line = false;
|
||||||
if ($batch_rule > 0) {
|
if ($batch_rule > 0) {
|
||||||
$productStatic->fetch($this->lines[$i]->fk_product);
|
$productStatic->fetch($this->lines[$i]->fk_product);
|
||||||
@@ -3441,7 +3444,7 @@ class Facture extends CommonInvoice
|
|||||||
|
|
||||||
$sortfield = null;
|
$sortfield = null;
|
||||||
$sortorder = 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) {
|
if ($batch_rule == Productbatch::BATCH_RULE_SELLBY_EATBY_DATES_FIRST) {
|
||||||
$sortfield = 'pl.sellby,pl.eatby,pb.qty,pl.rowid';
|
$sortfield = 'pl.sellby,pl.eatby,pb.qty,pl.rowid';
|
||||||
$sortorder = 'ASC,ASC,ASC,ASC';
|
$sortorder = 'ASC,ASC,ASC,ASC';
|
||||||
@@ -3479,7 +3482,7 @@ class Facture extends CommonInvoice
|
|||||||
if ($result < 0) {
|
if ($result < 0) {
|
||||||
$error++;
|
$error++;
|
||||||
$this->error = $mouvP->error;
|
$this->error = $mouvP->error;
|
||||||
$this->errors = $mouvP->errors;
|
$this->errors = array_merge($this->errors, $mouvP->errors);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3498,7 +3501,7 @@ class Facture extends CommonInvoice
|
|||||||
if ($result < 0) {
|
if ($result < 0) {
|
||||||
$error++;
|
$error++;
|
||||||
$this->error = $mouvP->error;
|
$this->error = $mouvP->error;
|
||||||
$this->errors = $mouvP->errors;
|
$this->errors = array_merge($this->errors, $mouvP->errors);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$error++;
|
$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));
|
$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) {
|
if ($result < 0) {
|
||||||
$error++;
|
$error++;
|
||||||
$this->error = $mouvP->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) {
|
if ($result < 0) {
|
||||||
$this->error = $invoice_situation->error;
|
$this->error = $invoice_situation->error;
|
||||||
$this->errors = $invoice_situation->errors;
|
$this->errors = array_merge($this->errors, $invoice_situation->errors);
|
||||||
$error++;
|
$error++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -6461,7 +6464,8 @@ class FactureLigne extends CommonInvoiceLine
|
|||||||
$sql .= ' info_bits, total_ht, total_tva, total_ttc, total_localtax1, total_localtax2,';
|
$sql .= ' info_bits, total_ht, total_tva, total_ttc, total_localtax1, total_localtax2,';
|
||||||
$sql .= ' situation_percent, fk_prev_id,';
|
$sql .= ' situation_percent, fk_prev_id,';
|
||||||
$sql .= ' fk_unit, fk_user_author, fk_user_modif,';
|
$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 .= ')';
|
||||||
$sql .= " VALUES (".$this->fk_facture.",";
|
$sql .= " VALUES (".$this->fk_facture.",";
|
||||||
$sql .= " ".($this->fk_parent_line > 0 ? $this->fk_parent_line : "null").",";
|
$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_ht);
|
||||||
$sql .= ", ".price2num($this->multicurrency_total_tva);
|
$sql .= ", ".price2num($this->multicurrency_total_tva);
|
||||||
$sql .= ", ".price2num($this->multicurrency_total_ttc);
|
$sql .= ", ".price2num($this->multicurrency_total_ttc);
|
||||||
|
$sql .= ", '".$this->db->escape($this->batch)."'";
|
||||||
|
$sql .= ", ".((int) $this->fk_warehouse);
|
||||||
$sql .= ')';
|
$sql .= ')';
|
||||||
|
|
||||||
dol_syslog(get_class($this)."::insert", LOG_DEBUG);
|
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_tva=".price2num($this->multicurrency_total_tva);
|
||||||
$sql .= ", multicurrency_total_ttc=".price2num($this->multicurrency_total_ttc);
|
$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);
|
$sql .= " WHERE rowid = ".((int) $this->rowid);
|
||||||
|
|
||||||
dol_syslog(get_class($this)."::update", LOG_DEBUG);
|
dol_syslog(get_class($this)."::update", LOG_DEBUG);
|
||||||
|
|||||||
@@ -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 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 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 $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 $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, 'MU' or 'MT' or a numeric to round to MU or MT or to a given number of decimal
|
* @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)
|
* @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
|
* @return string String with formatted amount
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ class modDataPolicy extends DolibarrModules
|
|||||||
// Name of image file used for this module.
|
// 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 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'
|
// 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...)
|
// Defined all module parts (triggers, login, substitutions, menus, css, etc...)
|
||||||
// for default path (eg: /datapolicy/core/xxxxx) (0=disable, 1=enable)
|
// for default path (eg: /datapolicy/core/xxxxx) (0=disable, 1=enable)
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
/* Copyright (C) 2004-2017 Laurent Destailleur <eldy@users.sourceforge.net>
|
/* Copyright (C) 2004-2017 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||||
* Copyright (C) 2018 Nicolas ZABOURI <info@inovea-conseil.com>
|
* 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
|
* 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
|
* 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');
|
$action = GETPOST('action', 'aZ09');
|
||||||
$backtopage = GETPOST('backtopage', 'alpha');
|
$backtopage = GETPOST('backtopage', 'alpha');
|
||||||
|
|
||||||
|
if (empty($action)) {
|
||||||
|
$action = 'edit';
|
||||||
|
}
|
||||||
|
|
||||||
$arrayofparameters = array();
|
$arrayofparameters = array();
|
||||||
$arrayofparameters['ThirdParty'] = array(
|
$arrayofparameters['ThirdParty'] = array(
|
||||||
'DATAPOLICY_TIERS_CLIENT' => array('css' => 'minwidth200', 'picto' => img_picto('', 'company', 'class="pictofixedwidth"')),
|
'DATAPOLICY_TIERS_CLIENT' => array('css' => 'minwidth200', 'picto' => img_picto('', 'company', 'class="pictofixedwidth"')),
|
||||||
@@ -85,6 +89,9 @@ if (!$user->admin) {
|
|||||||
/*
|
/*
|
||||||
* Actions
|
* Actions
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
$nbdone = 0;
|
||||||
|
|
||||||
foreach ($arrayofparameters as $title => $tab) {
|
foreach ($arrayofparameters as $title => $tab) {
|
||||||
foreach ($tab as $key => $val) {
|
foreach ($tab as $key => $val) {
|
||||||
// Modify constant only if key was posted (avoid resetting key to the null value)
|
// 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) {
|
if ($result < 0) {
|
||||||
$error++;
|
$error++;
|
||||||
break;
|
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, '');
|
print dol_get_fiche_head($head, 'settings', '', -1, '');
|
||||||
|
|
||||||
// Setup page goes here
|
// 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') {
|
if ($action == 'edit') {
|
||||||
@@ -136,45 +153,44 @@ if ($action == 'edit') {
|
|||||||
print '<input type="hidden" name="action" value="update">';
|
print '<input type="hidden" name="action" value="update">';
|
||||||
|
|
||||||
print '<table class="noborder centpercent">';
|
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) {
|
foreach ($arrayofparameters as $title => $tab) {
|
||||||
print '<tr class="trforbreak"><td class="titlefield trforbreak" colspan="2">'.$langs->trans($title).'</td></tr>';
|
print '<tr class="trforbreak"><td class="titlefield trforbreak" colspan="2">'.$langs->trans($title).'</td></tr>';
|
||||||
foreach ($tab as $key => $val) {
|
foreach ($tab as $key => $val) {
|
||||||
print '<tr class="oddeven"><td>';
|
print '<tr class="oddeven"><td>';
|
||||||
print $val['picto'];
|
print $val['picto'];
|
||||||
print $form->textwithpicto($langs->trans($key), $langs->trans('DATAPOLICY_Tooltip_SETUP'));
|
print $langs->trans($key);
|
||||||
print '</td><td>';
|
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) {
|
foreach ($valTab as $key1 => $val1) {
|
||||||
print '<option value="'.$key1.'" '.(getDolGlobalString($key) == $key1 ? 'selected="selected"' : '').'>';
|
print '<option value="'.$key1.'" '.(getDolGlobalString($key) == $key1 ? 'selected="selected"' : '').'>';
|
||||||
print $val1;
|
print $val1;
|
||||||
print '</option>';
|
print '</option>';
|
||||||
}
|
}
|
||||||
print '</select>';
|
print '</select>';
|
||||||
|
print ajax_combobox($key);
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
print '</table>';
|
print '</table>';
|
||||||
|
|
||||||
print '<br><div class="center">';
|
print $form->buttonsSaveCancel("Save", '');
|
||||||
print '<input class="button button-save" type="submit" value="'.$langs->trans("Save").'">';
|
|
||||||
print '</div>';
|
|
||||||
|
|
||||||
print '</form>';
|
print '</form>';
|
||||||
print '<br>';
|
print '<br>';
|
||||||
} else {
|
} else {
|
||||||
print '<table class="noborder centpercent">';
|
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) {
|
foreach ($arrayofparameters as $title => $tab) {
|
||||||
print '<tr class="trforbreak"><td class="titlefield trforbreak" colspan="2">'.$langs->trans($title).'</td></tr>';
|
print '<tr class="trforbreak"><td class="titlefield trforbreak" colspan="2">'.$langs->trans($title).'</td></tr>';
|
||||||
foreach ($tab as $key => $val) {
|
foreach ($tab as $key => $val) {
|
||||||
print '<tr class="oddeven"><td>';
|
print '<tr class="oddeven"><td>';
|
||||||
print $val['picto'];
|
print $val['picto'];
|
||||||
print $form->textwithpicto($langs->trans($key), $langs->trans('DATAPOLICY_Tooltip_SETUP'));
|
print $langs->trans($key);
|
||||||
print '</td><td>'.(getDolGlobalString($key) == '' ? $langs->trans('None') : $valTab[getDolGlobalString($key)]).'</td></tr>';
|
print '</td><td>'.(getDolGlobalString($key) == '' ? '<span class="opacitymedium">'.$valTab[''].'</span>' : $valTab[getDolGlobalString($key)]).'</td></tr>';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ DATAPOLICY_CONTACT_PROSPECT_CLIENT = Prospect/Customer
|
|||||||
DATAPOLICY_CONTACT_NIPROSPECT_NICLIENT = Nor prospect/Nor customer
|
DATAPOLICY_CONTACT_NIPROSPECT_NICLIENT = Nor prospect/Nor customer
|
||||||
DATAPOLICY_CONTACT_FOURNISSEUR = Supplier
|
DATAPOLICY_CONTACT_FOURNISSEUR = Supplier
|
||||||
DATAPOLICY_ADHERENT = Member
|
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.
|
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
|
SendAgreement = Send emails
|
||||||
AllAgreementSend = All emails have been sent
|
AllAgreementSend = All emails have been sent
|
||||||
|
|||||||
@@ -295,8 +295,8 @@ CurrencyXPF=CFP Francs
|
|||||||
CurrencySingXPF=CFP Franc
|
CurrencySingXPF=CFP Franc
|
||||||
CurrencyCentEUR=cents
|
CurrencyCentEUR=cents
|
||||||
CurrencyCentSingEUR=cent
|
CurrencyCentSingEUR=cent
|
||||||
CurrencyCentINR=paisa
|
CurrencyCentINR=paise
|
||||||
CurrencyCentSingINR=paise
|
CurrencyCentSingINR=paisa
|
||||||
CurrencyThousandthSingTND=thousandth
|
CurrencyThousandthSingTND=thousandth
|
||||||
#### Input reasons #####
|
#### Input reasons #####
|
||||||
DemandReasonTypeSRC_INTE=Internet
|
DemandReasonTypeSRC_INTE=Internet
|
||||||
|
|||||||
@@ -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="token" value="'.newToken().'">';
|
||||||
print '<input type="hidden" name="action" value="set">';
|
print '<input type="hidden" name="action" value="set">';
|
||||||
|
|
||||||
|
print '<br>';
|
||||||
|
|
||||||
print '<table class="noborder centpercent">';
|
print '<table class="noborder centpercent">';
|
||||||
print '<tr class="liste_titre">';
|
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";
|
print "</tr>\n";
|
||||||
|
|
||||||
// Color theme
|
// Color theme
|
||||||
|
|||||||
@@ -123,7 +123,7 @@ if (getDolGlobalInt('TAKEPOS_BAR_RESTAURANT')) {
|
|||||||
print '<div class="div-table-responsive-no-min">';
|
print '<div class="div-table-responsive-no-min">';
|
||||||
print '<table class="noborder centpercent">';
|
print '<table class="noborder centpercent">';
|
||||||
print '<tr class="liste_titre">';
|
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>\n";
|
||||||
|
|
||||||
print '<tr class="oddeven value"><td>';
|
print '<tr class="oddeven value"><td>';
|
||||||
|
|||||||
@@ -96,7 +96,10 @@ $url = 'https://www.dolistore.com/45-pos';
|
|||||||
print '<tr class="oddeven">'."\n";
|
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 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>'.$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 '</tr>';
|
||||||
|
|
||||||
print "</table>\n";
|
print "</table>\n";
|
||||||
@@ -118,9 +121,12 @@ print '</tr>';
|
|||||||
$url = 'https://www.takepos.com';
|
$url = 'https://www.takepos.com';
|
||||||
|
|
||||||
print '<tr class="oddeven">'."\n";
|
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>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 '</tr>';
|
||||||
|
|
||||||
print "</table>\n";
|
print "</table>\n";
|
||||||
|
|||||||
@@ -211,12 +211,14 @@ print "</td></tr>\n";
|
|||||||
print '</table>';
|
print '</table>';
|
||||||
print '</div>';
|
print '</div>';
|
||||||
|
|
||||||
print '<br>';
|
|
||||||
|
|
||||||
print $form->buttonsSaveCancel("Save", '');
|
print $form->buttonsSaveCancel("Save", '');
|
||||||
|
|
||||||
print "</form>\n";
|
print "</form>\n";
|
||||||
|
|
||||||
|
|
||||||
|
print '<br>';
|
||||||
|
|
||||||
|
|
||||||
print load_fiche_titre($langs->trans("Preview"), '', '');
|
print load_fiche_titre($langs->trans("Preview"), '', '');
|
||||||
print '<div style="width: 50%; float:center;background-color:#606060">';
|
print '<div style="width: 50%; float:center;background-color:#606060">';
|
||||||
print '<center>';
|
print '<center>';
|
||||||
|
|||||||
@@ -250,6 +250,9 @@ print "\n";
|
|||||||
|
|
||||||
print '<br>';
|
print '<br>';
|
||||||
|
|
||||||
|
|
||||||
|
print load_fiche_titre($langs->trans('Options'), '', '');
|
||||||
|
|
||||||
// Mode
|
// Mode
|
||||||
print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
|
print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
|
||||||
print '<input type="hidden" name="token" value="'.newToken().'">';
|
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 '<table class="noborder centpercent">';
|
||||||
|
|
||||||
print '<tr class="liste_titre">';
|
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";
|
print "</tr>\n";
|
||||||
|
|
||||||
// Terminals
|
// Terminals
|
||||||
@@ -479,7 +482,7 @@ if (getDolGlobalInt('TAKEPOS_ENABLE_SUMUP')) {
|
|||||||
print '<table class="noborder centpercent">';
|
print '<table class="noborder centpercent">';
|
||||||
|
|
||||||
print '<tr class="liste_titre">';
|
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>\n";
|
||||||
|
|
||||||
print '<tr class="oddeven"><td>';
|
print '<tr class="oddeven"><td>';
|
||||||
@@ -497,8 +500,6 @@ if (getDolGlobalInt('TAKEPOS_ENABLE_SUMUP')) {
|
|||||||
print '</div>';
|
print '</div>';
|
||||||
}
|
}
|
||||||
|
|
||||||
print '<br>';
|
|
||||||
|
|
||||||
print $form->buttonsSaveCancel("Save", '');
|
print $form->buttonsSaveCancel("Save", '');
|
||||||
|
|
||||||
print "</form>\n";
|
print "</form>\n";
|
||||||
|
|||||||
@@ -184,7 +184,7 @@ print '<input type="hidden" name="action" value="set">';
|
|||||||
print '<div class="div-table-responsive">';
|
print '<div class="div-table-responsive">';
|
||||||
print '<table class="noborder centpercent">';
|
print '<table class="noborder centpercent">';
|
||||||
print '<tr class="liste_titre">';
|
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>\n";
|
||||||
|
|
||||||
print '<tr class="oddeven"><td class="fieldrequired">'.$langs->trans("TerminalNameDesc").'</td>';
|
print '<tr class="oddeven"><td class="fieldrequired">'.$langs->trans("TerminalNameDesc").'</td>';
|
||||||
@@ -477,6 +477,9 @@ if (getDolGlobalString('TAKEPOS_ADDON') == "terminal") {
|
|||||||
}
|
}
|
||||||
|
|
||||||
print '</table>';
|
print '</table>';
|
||||||
|
|
||||||
|
print $form->buttonsSaveCancel("Save", '');
|
||||||
|
|
||||||
print '</div>';
|
print '</div>';
|
||||||
|
|
||||||
// add free text on each terminal of cash desk
|
// 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 info_admin($langs->trans("AtLeastOneDefaultBankAccountMandatory"), 0, 0, 'error');
|
||||||
}
|
}
|
||||||
|
|
||||||
print '<br>';
|
|
||||||
|
|
||||||
print $form->buttonsSaveCancel("Save", '');
|
print $form->buttonsSaveCancel("Save", '');
|
||||||
|
|
||||||
print "</form>\n";
|
print "</form>\n";
|
||||||
|
|||||||
@@ -112,7 +112,7 @@ top_htmlhead('', '', 0, 0, $arrayofjs, $arrayofcss);
|
|||||||
*/
|
*/
|
||||||
function Save() {
|
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);
|
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();
|
parent.$.colorbox.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -537,10 +537,12 @@ function ClickProduct(position, qty = 1) {
|
|||||||
console.log($('#prodiv4').data('rowid'));
|
console.log($('#prodiv4').data('rowid'));
|
||||||
invoiceid = $("#invoiceid").val();
|
invoiceid = $("#invoiceid").val();
|
||||||
idproduct=$('#prodiv'+position).data('rowid');
|
idproduct=$('#prodiv'+position).data('rowid');
|
||||||
console.log("Click on product at position "+position+" for idproduct "+idproduct+", qty="+qty+" invoicdeid="+invoiceid);
|
console.log("Click on product at position "+position+" for idproduct "+idproduct+", qty="+qty+" invoiceid="+invoiceid);
|
||||||
if (idproduct=="") return;
|
if (idproduct == "") {
|
||||||
|
return;
|
||||||
|
}
|
||||||
// Call page invoice.php to generate the section with product lines
|
// 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')) {
|
<?php if (getDolGlobalString('TAKEPOS_CUSTOMER_DISPLAY')) {
|
||||||
echo "CustomerDisplay();";
|
echo "CustomerDisplay();";
|
||||||
}?>
|
}?>
|
||||||
|
|||||||
@@ -233,6 +233,8 @@ if (empty($reshook)) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$constantforkey = 'CASHDESK_NO_DECREASE_STOCK'.(isset($_SESSION["takeposterminal"]) ? $_SESSION["takeposterminal"] : '');
|
$constantforkey = 'CASHDESK_NO_DECREASE_STOCK'.(isset($_SESSION["takeposterminal"]) ? $_SESSION["takeposterminal"] : '');
|
||||||
|
$allowstockchange = (getDolGlobalString($constantforkey) != "1");
|
||||||
|
|
||||||
if ($error) {
|
if ($error) {
|
||||||
dol_htmloutput_errors($errormsg, null, 1);
|
dol_htmloutput_errors($errormsg, null, 1);
|
||||||
} elseif ($invoice->status != Facture::STATUS_DRAFT) {
|
} elseif ($invoice->status != Facture::STATUS_DRAFT) {
|
||||||
@@ -247,31 +249,25 @@ if (empty($reshook)) {
|
|||||||
$error++;
|
$error++;
|
||||||
dol_syslog('Sale without lines');
|
dol_syslog('Sale without lines');
|
||||||
dol_htmloutput_errors($langs->trans("NoLinesToBill", "TakePos"), null, 1);
|
dol_htmloutput_errors($langs->trans("NoLinesToBill", "TakePos"), null, 1);
|
||||||
} elseif (isModEnabled('stock') && !isModEnabled('productbatch') && getDolGlobalString($constantforkey) != "1") {
|
} 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.
|
// 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.
|
// The case for isModEnabled('productbatch') is processed few lines later.
|
||||||
$savconst = getDolGlobalString('STOCK_CALCULATE_ON_BILL');
|
$savconst = getDolGlobalString('STOCK_CALCULATE_ON_BILL');
|
||||||
|
|
||||||
if (isModEnabled('productbatch') && !getDolGlobalInt('CASHDESK_FORCE_DECREASE_STOCK')) {
|
$conf->global->STOCK_CALCULATE_ON_BILL = 1; // To force the change of stock during invoice validation
|
||||||
$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
|
|
||||||
}
|
|
||||||
|
|
||||||
$constantforkey = 'CASHDESK_ID_WAREHOUSE'.$_SESSION["takeposterminal"];
|
$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;
|
// Validate invoice with stock change into warehouse getDolGlobalInt($constantforkey)
|
||||||
if (isModEnabled('productbatch') && getDolGlobalString('CASHDESK_FORCE_DECREASE_STOCK')) {
|
// Label of stock movement will be the same as when we validate invoice "Invoice XXXX validated"
|
||||||
require_once DOL_DOCUMENT_ROOT.'/product/class/productbatch.class.php';
|
$batch_rule = 0; // Module productbatch is disabled here, so no need for a batch_rule.
|
||||||
$batch_rule = Productbatch::BATCH_RULE_SELLBY_EATBY_DATES_FIRST;
|
|
||||||
}
|
|
||||||
$res = $invoice->validate($user, '', getDolGlobalInt($constantforkey), 0, $batch_rule);
|
$res = $invoice->validate($user, '', getDolGlobalInt($constantforkey), 0, $batch_rule);
|
||||||
|
|
||||||
|
// Restore setup
|
||||||
$conf->global->STOCK_CALCULATE_ON_BILL = $savconst;
|
$conf->global->STOCK_CALCULATE_ON_BILL = $savconst;
|
||||||
} else {
|
} 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);
|
$res = $invoice->validate($user);
|
||||||
if ($res < 0) {
|
if ($res < 0) {
|
||||||
$error++;
|
$error++;
|
||||||
@@ -331,32 +327,41 @@ if (empty($reshook)) {
|
|||||||
|
|
||||||
// Update stock for batch products
|
// Update stock for batch products
|
||||||
if (!$error && $res >= 0) {
|
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";
|
require_once DOL_DOCUMENT_ROOT . "/product/stock/class/mouvementstock.class.php";
|
||||||
$constantforkey = 'CASHDESK_ID_WAREHOUSE'.$_SESSION["takeposterminal"];
|
$constantforkey = 'CASHDESK_ID_WAREHOUSE'.$_SESSION["takeposterminal"];
|
||||||
$inventorycode = dol_print_date(dol_now(), 'dayhourlog');
|
$inventorycode = dol_print_date(dol_now(), 'dayhourlog');
|
||||||
|
// Label of stock movement will be "TakePOS - Invoice XXXX"
|
||||||
$labeltakeposmovement = 'TakePOS - '.$langs->trans("Invoice").' '.$invoice->ref;
|
$labeltakeposmovement = 'TakePOS - '.$langs->trans("Invoice").' '.$invoice->ref;
|
||||||
|
|
||||||
foreach ($invoice->lines as $line) {
|
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));
|
$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);
|
// var_dump('fk_product='.$line->fk_product.' batch='.$line->batch.' warehouse='.$line->fk_warehouse.' qty='.$line->qty);
|
||||||
if ($line->batch != '' && $warehouseid > 0) {
|
if ($line->batch != '' && $warehouseid > 0) {
|
||||||
$prod_batch = new Productbatch($db);
|
$prod_batch = new Productbatch($db);
|
||||||
$prod_batch->find(0, '', '', $line->batch, $warehouseid);
|
$prod_batch->find(0, '', '', $line->batch, $warehouseid);
|
||||||
|
|
||||||
$mouvP = new MouvementStock($db);
|
$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);
|
$res = $mouvP->livraison($user, $line->fk_product, $warehouseid, $line->qty, $line->price, $labeltakeposmovement, '', '', '', $prod_batch->batch, $prod_batch->id, $inventorycode);
|
||||||
if ($res < 0) {
|
if ($res < 0) {
|
||||||
setEventMessages($mouvP->error, $mouvP->errors, 'errors');
|
dol_htmloutput_errors($mouvP->error, $mouvP->errors, 1);
|
||||||
$error++;
|
$error++;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$mouvP = new MouvementStock($db);
|
$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);
|
$res = $mouvP->livraison($user, $line->fk_product, $warehouseid, $line->qty, $line->price, $labeltakeposmovement, '', '', '', '', 0, $inventorycode);
|
||||||
if ($res < 0) {
|
if ($res < 0) {
|
||||||
setEventMessages($mouvP->error, $mouvP->errors, 'errors');
|
dol_htmloutput_errors($mouvP->error, $mouvP->errors, 1);
|
||||||
$error++;
|
$error++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -387,11 +392,6 @@ if (empty($reshook)) {
|
|||||||
$fk_parent_line = 0; // Initialise
|
$fk_parent_line = 0; // Initialise
|
||||||
|
|
||||||
foreach ($invoice->lines as $line) {
|
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
|
// 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) {
|
if (($line->product_type != 9 && empty($line->fk_parent_line)) || $line->product_type == 9) {
|
||||||
$fk_parent_line = 0;
|
$fk_parent_line = 0;
|
||||||
@@ -472,6 +472,7 @@ if (empty($reshook)) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// We update field for credit notes
|
||||||
$line->fk_facture = $creditnote->id;
|
$line->fk_facture = $creditnote->id;
|
||||||
$line->fk_parent_line = $fk_parent_line;
|
$line->fk_parent_line = $fk_parent_line;
|
||||||
|
|
||||||
@@ -499,36 +500,95 @@ if (empty($reshook)) {
|
|||||||
}
|
}
|
||||||
$creditnote->update_price(1);
|
$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"] : '');
|
$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');
|
$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"] : '');
|
$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;
|
dol_syslog("Validate invoice with stock change into warehouse defined into constant ".$constantforkey." = ".getDolGlobalString($constantforkey)." or warehouseid= ".$warehouseid." if defined.");
|
||||||
if (isModEnabled('productbatch') && getDolGlobalString('CASHDESK_FORCE_DECREASE_STOCK')) {
|
|
||||||
require_once DOL_DOCUMENT_ROOT.'/product/class/productbatch.class.php';
|
// Validate invoice with stock change into warehouse getDolGlobalInt($constantforkey)
|
||||||
$batch_rule = Productbatch::BATCH_RULE_SELLBY_EATBY_DATES_FIRST;
|
// 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);
|
$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;
|
$conf->global->STOCK_CALCULATE_ON_BILL = $savconst;
|
||||||
} else {
|
} else {
|
||||||
$res = $creditnote->validate($user);
|
$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) {
|
if (!$error && $res >= 0) {
|
||||||
$db->commit();
|
$db->commit();
|
||||||
} else {
|
} 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();
|
$db->rollback();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (($action == 'history' || $action == 'creditnote') && $user->hasRight('takepos', 'run')) {
|
if (($action == 'history' || $action == 'creditnote') && $user->hasRight('takepos', 'run')) {
|
||||||
if ($action == 'creditnote') {
|
if ($action == 'creditnote' && $creditnote->id > 0) {
|
||||||
$placeid = $creditnote->id;
|
$placeid = $creditnote->id;
|
||||||
} else {
|
} else {
|
||||||
$placeid = GETPOSTINT('placeid');
|
$placeid = GETPOSTINT('placeid');
|
||||||
}
|
}
|
||||||
|
|
||||||
$invoice = new Facture($db);
|
$invoice = new Facture($db);
|
||||||
$invoice->fetch($placeid);
|
$invoice->fetch($placeid);
|
||||||
}
|
}
|
||||||
@@ -595,7 +655,7 @@ if (empty($reshook)) {
|
|||||||
if (isModEnabled('productbatch') && isModEnabled('stock')) {
|
if (isModEnabled('productbatch') && isModEnabled('stock')) {
|
||||||
$batch = GETPOST('batch', 'alpha');
|
$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";
|
$action = "setbatch";
|
||||||
} elseif ($prod->status_batch > 0) {
|
} elseif ($prod->status_batch > 0) {
|
||||||
// If product need a lot/serial, we show the list of lot/serial available for the product...
|
// 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);
|
//var_dump($prod->stock_warehouse);
|
||||||
foreach ($prod->stock_warehouse as $tmpwarehouseid => $tmpval) {
|
foreach ($prod->stock_warehouse as $tmpwarehouseid => $tmpval) {
|
||||||
if (getDolGlobalInt($constantforkey) && $tmpwarehouseid != getDolGlobalInt($constantforkey)) {
|
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;
|
continue;
|
||||||
}
|
}
|
||||||
if (!empty($prod->stock_warehouse[$tmpwarehouseid]) && is_array($prod->stock_warehouse[$tmpwarehouseid]->detail_batch)) {
|
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 "<script>\n";
|
||||||
echo "function addbatch(batch, warehouseid) {\n";
|
echo "function addbatch(batch, warehouseid) {\n";
|
||||||
echo "console.log('We add batch '+batch+' from warehouse id '+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 "}\n";
|
||||||
echo "</script>\n";
|
echo "</script>\n";
|
||||||
|
|
||||||
@@ -644,7 +704,7 @@ if (empty($reshook)) {
|
|||||||
$deliverableQty = min($quantityToBeDelivered, $batchStock);
|
$deliverableQty = min($quantityToBeDelivered, $batchStock);
|
||||||
print '<tr>';
|
print '<tr>';
|
||||||
print '<!-- subj='.$suggestednb.'/'.$nbofsuggested.' -->';
|
print '<!-- subj='.$suggestednb.'/'.$nbofsuggested.' -->';
|
||||||
print '<!-- Show details of lot -->';
|
print '<!-- Show details of lot/serial in warehouseid='.$tmpwarehouseid.' -->';
|
||||||
print '<td class="left">';
|
print '<td class="left">';
|
||||||
$detail = '';
|
$detail = '';
|
||||||
$detail .= '<span class="opacitymedium">'.$langs->trans("LotSerial").':</span> '.$dbatch->batch;
|
$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'))) {
|
if ($action == "setbatch" && ($user->hasRight('takepos', 'run') || defined('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE'))) {
|
||||||
$constantforkey = 'CASHDESK_ID_WAREHOUSE'.$_SESSION["takeposterminal"];
|
$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 = "UPDATE ".MAIN_DB_PREFIX."facturedet SET batch = '".$db->escape($batch)."', fk_warehouse = ".((int) $warehouseid);
|
||||||
$sql .= " WHERE rowid=".((int) $idoflineadded);
|
$sql .= " WHERE rowid=".((int) $idoflineadded);
|
||||||
$db->query($sql);
|
$db->query($sql);
|
||||||
@@ -1406,13 +1466,15 @@ function DolibarrTakeposPrinting(id) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Call url to generate a credit note (with same lines) from existing invoice
|
||||||
function CreditNote() {
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Call url to add notes
|
||||||
function SetNote() {
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1952,13 +2014,18 @@ if ($placeid > 0) {
|
|||||||
$stock_real = price2num($obj->reel, 'MS');
|
$stock_real = price2num($obj->reel, 'MS');
|
||||||
}
|
}
|
||||||
$htmlforlines .= $line->qty;
|
$htmlforlines .= $line->qty;
|
||||||
|
$htmlforlines .= ' ';
|
||||||
|
$htmlforlines .= '<span class="opacitylow" title="'.$langs->trans("Stock").' '.price($stock_real, 1, '', 1, 0).'">';
|
||||||
|
$htmlforlines .= '(';
|
||||||
if ($line->qty && $line->qty > $stock_real) {
|
if ($line->qty && $line->qty > $stock_real) {
|
||||||
$htmlforlines .= '<span style="color: var(--amountremaintopaycolor)">';
|
$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) {
|
if ($line->qty && $line->qty > $stock_real) {
|
||||||
$htmlforlines .= "</span>";
|
$htmlforlines .= "</span>";
|
||||||
}
|
}
|
||||||
|
$htmlforlines .= ')';
|
||||||
|
$htmlforlines .= '</span>';
|
||||||
} else {
|
} else {
|
||||||
dol_print_error($db);
|
dol_print_error($db);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,9 +43,9 @@ $_SESSION["takeposterminal"] = getDolGlobalInt('TAKEPOS_TERMINAL_NB_FOR_PUBLIC',
|
|||||||
|
|
||||||
define('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE', 1);
|
define('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE', 1);
|
||||||
if (GETPOSTISSET("mobilepage")) {
|
if (GETPOSTISSET("mobilepage")) {
|
||||||
require '../invoice.php';
|
require DOL_URL_ROOT.'/takepos/invoice.php';
|
||||||
} elseif (GETPOSTISSET("genimg")) {
|
} elseif (GETPOSTISSET("genimg")) {
|
||||||
require DOL_DOCUMENT_ROOT.'/takepos/genimg/index.php';
|
require DOL_DOCUMENT_ROOT.'/takepos/genimg/index.php';
|
||||||
} else {
|
} else {
|
||||||
require '../phone.php';
|
require DOL_URL_ROOT.'/takepos/phone.php';
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -156,6 +156,7 @@ div#topmenu-global-search-dropdown a::after, div#topmenu-quickadd-dropdown a::af
|
|||||||
/* font part */
|
/* font part */
|
||||||
font-family: "<?php echo getDolGlobalString('MAIN_FONTAWESOME_FAMILY', 'Font Awesome 5 Free'); ?>";
|
font-family: "<?php echo getDolGlobalString('MAIN_FONTAWESOME_FAMILY', 'Font Awesome 5 Free'); ?>";
|
||||||
font-size: 0.7em;
|
font-size: 0.7em;
|
||||||
|
line-height: 0.7em;
|
||||||
font-weight: 900;
|
font-weight: 900;
|
||||||
font-style: normal;
|
font-style: normal;
|
||||||
font-variant: normal;
|
font-variant: normal;
|
||||||
|
|||||||
Reference in New Issue
Block a user