';
print $langs->trans("NotificationDisableConfirmMessageUser").' ';
print '';
From f4d4733b15fac96d2fe011464fa40ee600900702 Mon Sep 17 00:00:00 2001
From: Adrien Raze
Date: Thu, 19 Aug 2021 15:37:32 +0200
Subject: [PATCH 007/341] NEW : Select for BOM workable + JS to fill it
according to the product selected
---
htdocs/bom/bom_card.php | 25 ++++++++++++++++++++
htdocs/bom/script/interface.php | 29 ++++++++++++++++++++++++
htdocs/bom/tpl/objectline_create.tpl.php | 4 ++++
htdocs/bom/tpl/objectline_title.tpl.php | 3 +++
htdocs/bom/tpl/objectline_view.tpl.php | 2 ++
htdocs/langs/en_US/mrp.lang | 1 +
htdocs/langs/fr_FR/mrp.lang | 1 +
7 files changed, 65 insertions(+)
create mode 100644 htdocs/bom/script/interface.php
diff --git a/htdocs/bom/bom_card.php b/htdocs/bom/bom_card.php
index cd530994b9b..7bcbcc19e46 100644
--- a/htdocs/bom/bom_card.php
+++ b/htdocs/bom/bom_card.php
@@ -570,6 +570,31 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
if (!empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action != 'selectlines' && $action != 'editline')) {
print '';
}
+ ?>
+
+ ';
print "\n";
diff --git a/htdocs/bom/script/interface.php b/htdocs/bom/script/interface.php
new file mode 100644
index 00000000000..d5811db0414
--- /dev/null
+++ b/htdocs/bom/script/interface.php
@@ -0,0 +1,29 @@
+query($sql);
+ if ($resql && $db->num_rows($resql) > 0) {
+ $options = array();
+ $cpt=0;
+ while ($obj = $db->fetch_object($resql)){
+
+ $options[$obj->rowid] = $obj->ref.' - '.$obj->label;
+ $cpt++;
+ }
+ print json_encode($options);
+ }
+
+ break;
+}
diff --git a/htdocs/bom/tpl/objectline_create.tpl.php b/htdocs/bom/tpl/objectline_create.tpl.php
index 7cc2873b261..5835849e9ff 100644
--- a/htdocs/bom/tpl/objectline_create.tpl.php
+++ b/htdocs/bom/tpl/objectline_create.tpl.php
@@ -107,6 +107,10 @@ if (!empty($conf->product->enabled) || !empty($conf->service->enabled)) {
echo '';
}
+$coldisplay++;
+print '';
+print ' ';
+print ' ';
$coldisplay++;
print ' ';
diff --git a/htdocs/bom/tpl/objectline_title.tpl.php b/htdocs/bom/tpl/objectline_title.tpl.php
index d1b29ee03b0..6b7f04b58f0 100644
--- a/htdocs/bom/tpl/objectline_title.tpl.php
+++ b/htdocs/bom/tpl/objectline_title.tpl.php
@@ -52,6 +52,9 @@ if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER)) {
// Description
print ''.$langs->trans('Description').' ';
+// Linked BOM
+print ''.$langs->trans('BOM').' ';
+
// Qty
print ''.$form->textwithpicto($langs->trans('Qty'), $langs->trans("QtyRequiredIfNoLoss")).' ';
diff --git a/htdocs/bom/tpl/objectline_view.tpl.php b/htdocs/bom/tpl/objectline_view.tpl.php
index fff9d077a08..d3559857a2a 100644
--- a/htdocs/bom/tpl/objectline_view.tpl.php
+++ b/htdocs/bom/tpl/objectline_view.tpl.php
@@ -83,6 +83,8 @@ $tmpproduct->fetch($line->fk_product);
print $tmpproduct->getNomUrl(1);
print ' - '.$tmpproduct->label;
print ' ';
+
+print ' ';
print '';
$coldisplay++;
echo price($line->qty, 0, '', 0, 0); // Yes, it is a quantity, not a price, but we just want the formating role of function price
diff --git a/htdocs/langs/en_US/mrp.lang b/htdocs/langs/en_US/mrp.lang
index 2414a92cefb..8aaf345feed 100644
--- a/htdocs/langs/en_US/mrp.lang
+++ b/htdocs/langs/en_US/mrp.lang
@@ -101,3 +101,4 @@ HumanMachine=Human / Machine
WorkstationArea=Workstation area
Machines=Machines
THMEstimatedHelp=This rate makes it possible to define a forecast cost of the item
+BOM=Nomenclature
diff --git a/htdocs/langs/fr_FR/mrp.lang b/htdocs/langs/fr_FR/mrp.lang
index e0a2e73365e..2db57d53bfb 100644
--- a/htdocs/langs/fr_FR/mrp.lang
+++ b/htdocs/langs/fr_FR/mrp.lang
@@ -101,3 +101,4 @@ HumanMachine=Humain/machine
WorkstationArea=Espace Poste de travail
Machines=Machines
THMEstimatedHelp=Ce taux permet de définir un coût prévisionnel de l'article
+BOM=Nomenclature
From 6de7d9b0af679fd56f68cebd8d604bbb31e598f3 Mon Sep 17 00:00:00 2001
From: Adrien Raze
Date: Fri, 20 Aug 2021 13:37:28 +0200
Subject: [PATCH 008/341] NEW : Add sub-BOM lines on BOM card
---
htdocs/bom/bom_card.php | 11 ++++-
htdocs/bom/class/bom.class.php | 6 +++
htdocs/bom/tpl/objectline_view.tpl.php | 56 +++++++++++++++++++++++++-
3 files changed, 71 insertions(+), 2 deletions(-)
diff --git a/htdocs/bom/bom_card.php b/htdocs/bom/bom_card.php
index 7bcbcc19e46..1126e04785e 100644
--- a/htdocs/bom/bom_card.php
+++ b/htdocs/bom/bom_card.php
@@ -140,6 +140,7 @@ if (empty($reshook)) {
// Set if we used free entry or predefined product
$idprod = (int) GETPOST('idprod', 'int');
+ $bom_child = (int) GETPOST('bom_select', 'int');
$qty = price2num(GETPOST('qty', 'alpha'), 'MS');
$qty_frozen = price2num(GETPOST('qty_frozen', 'alpha'), 'MS');
$disable_stock_change = GETPOST('disable_stock_change', 'int');
@@ -163,6 +164,7 @@ if (empty($reshook)) {
$bomline = new BOMLine($db);
$bomline->fk_bom = $id;
$bomline->fk_product = $idprod;
+ $bomline->fk_bom_child = $bom_child;
$bomline->qty = $qty;
$bomline->qty_frozen = (int) $qty_frozen;
$bomline->disable_stock_change = (int) $disable_stock_change;
@@ -574,18 +576,25 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
+
+ ';
*/
$coldisplay++;
+// For BOM
+print ' ';
print '';
if (($line->info_bits & 2) != 2) {
diff --git a/htdocs/bom/tpl/objectline_view.tpl.php b/htdocs/bom/tpl/objectline_view.tpl.php
index 623fdab1474..c869a617b2a 100644
--- a/htdocs/bom/tpl/objectline_view.tpl.php
+++ b/htdocs/bom/tpl/objectline_view.tpl.php
@@ -81,9 +81,9 @@ $coldisplay++;
$tmpproduct = new Product($object->db);
$tmpproduct->fetch($line->fk_product);
$tmpbom = new BOM($object->db);
-$res = $tmpbom->fetch($line->fk_bom_child);
+$tmpbom->fetch($line->fk_bom_child);
if (!empty($tmpbom->id)){
- print '' . (empty($conf->global->BOM_SHOW_ALL_BOM_BY_DEFAULT) ? '(+)' : '(-)') . ' ';
+ print '' . (empty($conf->global->BOM_SHOW_ALL_BOM_BY_DEFAULT) ? '(+)' : '(-)') . ' ';
}
print $tmpproduct->getNomUrl(1);
print ' - '.$tmpproduct->label;
@@ -193,15 +193,15 @@ if ($resql){
$sub_bom_line = new BOMLine($object->db);
$sub_bom_line->fetch($obj->rowid);
- print ' ';
+ print ' ';
- print ''.$sub_bom_product->getNomUrl(1).' ';
+ print ' '.$sub_bom_product->getNomUrl(1).' ';
if ($sub_bom_line->fk_bom_child > 0) {
print ''.$sub_bom->getNomUrl(1).' ';
} else {
print ' ';
}
- print ''.price($sub_bom_line->qty, 0, '', 0, 0).' ';
+ print ''.price($sub_bom_line->qty * $line->qty, 0, '', 0, 0).' ';
if ($sub_bom_line->qty_frozen > 0) {
print ''.$sub_bom_line->qty_frozen.' ';
} else {
@@ -215,7 +215,7 @@ if ($resql){
}
print ''.$sub_bom_line->efficiency.' ';
- print ''.price($sub_bom_line->total_cost).' ';
+ print ''.price($sub_bom_line->total_cost * $line->qty).' ';
print ' ';
print ' ';
print ' ';
From 2343ff2ed4a06690230c95204cf0ca7d307870f7 Mon Sep 17 00:00:00 2001
From: Adrien Raze
Date: Mon, 23 Aug 2021 11:58:15 +0200
Subject: [PATCH 010/341] NEW : ShowAll/HideAll Options
---
htdocs/bom/bom_card.php | 9 ++++-----
htdocs/bom/tpl/objectline_title.tpl.php | 2 ++
htdocs/bom/tpl/objectline_view.tpl.php | 2 +-
3 files changed, 7 insertions(+), 6 deletions(-)
diff --git a/htdocs/bom/bom_card.php b/htdocs/bom/bom_card.php
index 2df4278ecbe..71c64087419 100644
--- a/htdocs/bom/bom_card.php
+++ b/htdocs/bom/bom_card.php
@@ -615,7 +615,6 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
$(".collapse_bom").click(function() {
var id_bom_line = $(this).attr('id').replace('collapse-', '');
- console.log('tr [parentid="'+ id_bom_line +'"]')
if($(this).text().indexOf('+') > 0) {
$('[parentid="'+ id_bom_line +'"]').show();
$(this).html('(-) ');
@@ -630,14 +629,14 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
//TODO : SHOW ALL / COLLAPSE ALL
$("#show_all").click(function() {
- $("[class^=batch_warehouse]").show();
- $("[class^=collapse_batch]").html('(-) ');
+ $("[class^=sub_bom_lines]").show();
+ $("[class^=collapse_bom]").html('(-) ');
return false;
});
$("#hide_all").click(function() {
- $("[class^=batch_warehouse]").hide();
- $("[class^=collapse_batch]").html('(+) ');
+ $("[class^=sub_bom_lines]").hide();
+ $("[class^=collapse_bom]").html('(+) ');
return false;
});
diff --git a/htdocs/bom/tpl/objectline_title.tpl.php b/htdocs/bom/tpl/objectline_title.tpl.php
index 6b7f04b58f0..0656f23aed9 100644
--- a/htdocs/bom/tpl/objectline_title.tpl.php
+++ b/htdocs/bom/tpl/objectline_title.tpl.php
@@ -43,6 +43,8 @@ print "\n";
print "\n";
print '';
+print ''.img_picto('', 'folder-open', 'class="paddingright"').$langs->trans("ExpandAll").' ';
+print ''.img_picto('', 'folder', 'class="paddingright"').$langs->trans("UndoExpandAll").' ';
// Adds a line numbering column
if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER)) {
diff --git a/htdocs/bom/tpl/objectline_view.tpl.php b/htdocs/bom/tpl/objectline_view.tpl.php
index c869a617b2a..87013582fac 100644
--- a/htdocs/bom/tpl/objectline_view.tpl.php
+++ b/htdocs/bom/tpl/objectline_view.tpl.php
@@ -193,7 +193,7 @@ if ($resql){
$sub_bom_line = new BOMLine($object->db);
$sub_bom_line->fetch($obj->rowid);
- print ' ';
+ print ' ';
print ' '.$sub_bom_product->getNomUrl(1).' ';
if ($sub_bom_line->fk_bom_child > 0) {
From 6cd92ca82971b3cbf5654a3b8eb35651b0fe9ad5 Mon Sep 17 00:00:00 2001
From: Adrien Raze
Date: Mon, 23 Aug 2021 12:15:09 +0200
Subject: [PATCH 011/341] NEW : Trad + Comments + Adding tooltips for conf
---
htdocs/bom/bom_card.php | 4 ++--
htdocs/bom/tpl/objectline_title.tpl.php | 2 ++
htdocs/langs/en_US/mrp.lang | 4 +++-
htdocs/langs/fr_FR/mrp.lang | 1 +
4 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/htdocs/bom/bom_card.php b/htdocs/bom/bom_card.php
index 71c64087419..85ce0a0366d 100644
--- a/htdocs/bom/bom_card.php
+++ b/htdocs/bom/bom_card.php
@@ -627,13 +627,13 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
return false;
});
- //TODO : SHOW ALL / COLLAPSE ALL
+ //To Show all the sub bom lines
$("#show_all").click(function() {
$("[class^=sub_bom_lines]").show();
$("[class^=collapse_bom]").html('(-) ');
return false;
});
-
+ //To Hide all the sub bom lines
$("#hide_all").click(function() {
$("[class^=sub_bom_lines]").hide();
$("[class^=collapse_bom]").html('(+) ');
diff --git a/htdocs/bom/tpl/objectline_title.tpl.php b/htdocs/bom/tpl/objectline_title.tpl.php
index 0656f23aed9..ce811096d33 100644
--- a/htdocs/bom/tpl/objectline_title.tpl.php
+++ b/htdocs/bom/tpl/objectline_title.tpl.php
@@ -45,6 +45,8 @@ print "\n";
print '';
print ''.img_picto('', 'folder-open', 'class="paddingright"').$langs->trans("ExpandAll").' ';
print ''.img_picto('', 'folder', 'class="paddingright"').$langs->trans("UndoExpandAll").' ';
+$form = new Form($object->db);
+print $form->textwithpicto('', $langs->trans('CollapseBOMHelp'), 1, 'help', '');
// Adds a line numbering column
if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER)) {
diff --git a/htdocs/langs/en_US/mrp.lang b/htdocs/langs/en_US/mrp.lang
index 8aaf345feed..c414a219894 100644
--- a/htdocs/langs/en_US/mrp.lang
+++ b/htdocs/langs/en_US/mrp.lang
@@ -101,4 +101,6 @@ HumanMachine=Human / Machine
WorkstationArea=Workstation area
Machines=Machines
THMEstimatedHelp=This rate makes it possible to define a forecast cost of the item
-BOM=Nomenclature
+BOM=Bill Of Materials
+CollapseBOMHelp=You can define the default display of the details of the nomenclature in the configuration of the BOM module
+
diff --git a/htdocs/langs/fr_FR/mrp.lang b/htdocs/langs/fr_FR/mrp.lang
index 2db57d53bfb..12873fd5093 100644
--- a/htdocs/langs/fr_FR/mrp.lang
+++ b/htdocs/langs/fr_FR/mrp.lang
@@ -102,3 +102,4 @@ WorkstationArea=Espace Poste de travail
Machines=Machines
THMEstimatedHelp=Ce taux permet de définir un coût prévisionnel de l'article
BOM=Nomenclature
+CollapseBOMHelp=Vous pouvez définir l'affichage par défaut du détail des nomenclature dans la configuration du module "Nomenclature Produits"
From e282feb3970ef6f99b89b9ed1ced4364e91bd331 Mon Sep 17 00:00:00 2001
From: Adrien Raze
Date: Mon, 23 Aug 2021 14:43:17 +0200
Subject: [PATCH 012/341] NEW : Delete conf
---
htdocs/bom/tpl/objectline_title.tpl.php | 2 --
htdocs/bom/tpl/objectline_view.tpl.php | 8 ++++++--
2 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/htdocs/bom/tpl/objectline_title.tpl.php b/htdocs/bom/tpl/objectline_title.tpl.php
index ce811096d33..0656f23aed9 100644
--- a/htdocs/bom/tpl/objectline_title.tpl.php
+++ b/htdocs/bom/tpl/objectline_title.tpl.php
@@ -45,8 +45,6 @@ print "\n";
print '';
print ''.img_picto('', 'folder-open', 'class="paddingright"').$langs->trans("ExpandAll").' ';
print ''.img_picto('', 'folder', 'class="paddingright"').$langs->trans("UndoExpandAll").' ';
-$form = new Form($object->db);
-print $form->textwithpicto('', $langs->trans('CollapseBOMHelp'), 1, 'help', '');
// Adds a line numbering column
if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER)) {
diff --git a/htdocs/bom/tpl/objectline_view.tpl.php b/htdocs/bom/tpl/objectline_view.tpl.php
index 87013582fac..fbfb02576df 100644
--- a/htdocs/bom/tpl/objectline_view.tpl.php
+++ b/htdocs/bom/tpl/objectline_view.tpl.php
@@ -81,7 +81,7 @@ $coldisplay++;
$tmpproduct = new Product($object->db);
$tmpproduct->fetch($line->fk_product);
$tmpbom = new BOM($object->db);
-$tmpbom->fetch($line->fk_bom_child);
+$res = $tmpbom->fetch($line->fk_bom_child);
if (!empty($tmpbom->id)){
print '' . (empty($conf->global->BOM_SHOW_ALL_BOM_BY_DEFAULT) ? '(+)' : '(-)') . ' ';
}
@@ -193,7 +193,11 @@ if ($resql){
$sub_bom_line = new BOMLine($object->db);
$sub_bom_line->fetch($obj->rowid);
- print ' ';
+ if (empty($conf->global->BOM_SHOW_ALL_BOM_BY_DEFAULT)){
+ print ' ';
+ } else {
+ print ' ';
+ }
print ' '.$sub_bom_product->getNomUrl(1).' ';
if ($sub_bom_line->fk_bom_child > 0) {
From 7474d2eef57aaec32713309ece7f84f7b85d8d88 Mon Sep 17 00:00:00 2001
From: Adrien Raze
Date: Mon, 23 Aug 2021 15:08:32 +0200
Subject: [PATCH 013/341] FIX : Add BOM column for create view
---
htdocs/bom/tpl/objectline_create.tpl.php | 2 ++
1 file changed, 2 insertions(+)
diff --git a/htdocs/bom/tpl/objectline_create.tpl.php b/htdocs/bom/tpl/objectline_create.tpl.php
index 5835849e9ff..1a60029c439 100644
--- a/htdocs/bom/tpl/objectline_create.tpl.php
+++ b/htdocs/bom/tpl/objectline_create.tpl.php
@@ -61,6 +61,8 @@ if ($nolinesbefore) {
print '';
print '
'.$langs->trans('AddNewLine').' ';
print ' ';
+ // Linked BOM
+ print ''.$langs->trans('BOM').' ';
print ''.$langs->trans('Qty').' ';
if (!empty($conf->global->PRODUCT_USE_UNITS)) {
print '';
From 2ecc448bc032e626436544c5eb6c7d95598fd480 Mon Sep 17 00:00:00 2001
From: Adrien Raze
Date: Wed, 25 Aug 2021 11:21:54 +0200
Subject: [PATCH 014/341] FIX : Set total_cost for parent line by additionning
total_cost of the children lines
---
htdocs/bom/tpl/objectline_view.tpl.php | 33 +++++++++++++++++++++++---
1 file changed, 30 insertions(+), 3 deletions(-)
diff --git a/htdocs/bom/tpl/objectline_view.tpl.php b/htdocs/bom/tpl/objectline_view.tpl.php
index fbfb02576df..0d83754dd60 100644
--- a/htdocs/bom/tpl/objectline_view.tpl.php
+++ b/htdocs/bom/tpl/objectline_view.tpl.php
@@ -123,7 +123,8 @@ $coldisplay++;
echo $line->efficiency;
print ' ';
-print '';
+$total_cost = 0;
+print ' ';
$coldisplay++;
echo price($line->total_cost);
print ' ';
@@ -199,7 +200,7 @@ if ($resql){
print '';
}
- print ' '.$sub_bom_product->getNomUrl(1).' ';
+ print ''.$sub_bom_product->getNomUrl(1).' ';
if ($sub_bom_line->fk_bom_child > 0) {
print ''.$sub_bom->getNomUrl(1).' ';
} else {
@@ -219,13 +220,39 @@ if ($resql){
}
print ''.$sub_bom_line->efficiency.' ';
- print ''.price($sub_bom_line->total_cost * $line->qty).' ';
+ if ($sub_bom_product->cost_price > 0) {
+ print ''.price($sub_bom_product->cost_price * $line->qty).' ';
+ $total_cost.= $sub_bom_product->cost_price * $line->qty;
+ } else if ($sub_bom_product->pmp > 0) {
+ print ''.price($sub_bom_product->pmp * $line->qty).' ';
+ $total_cost.= $sub_bom_product->pmp * $line->qty;
+ } else {
+ $sql_supplier_price = 'SELECT MIN(price) AS min_price FROM '.MAIN_DB_PREFIX.'product_fournisseur_price';
+ $sql_supplier_price.= ' WHERE fk_product = '.$sub_bom_product->id;
+ $resql_supplier_price = $object->db->query($sql_supplier_price);
+ if ($resql_supplier_price) {
+ $obj = $object->db->fetch_object($resql_supplier_price);
+ print ''.price($obj->min_price * $line->qty).' ';
+ $total_cost+= $obj->min_price * $line->qty;
+ }
+ }
+
print ' ';
print ' ';
print ' ';
}
}
+if ($total_cost > 0) {
+ $line->total_cost = price($total_cost);
+ ?>
+
+ showOptionals($extrafields, 'view', array('style'=>'class="drag drop oddeven"', 'colspan'=>$coldisplay), '', '', 1, 'line');
From 5bf8685f72182994c38bde5dd35cabe75d516763 Mon Sep 17 00:00:00 2001
From: Adrien Raze
Date: Wed, 25 Aug 2021 16:58:22 +0200
Subject: [PATCH 015/341] NEW : Add comments
---
htdocs/bom/tpl/objectline_view.tpl.php | 22 ++++++++++++++++++++--
1 file changed, 20 insertions(+), 2 deletions(-)
diff --git a/htdocs/bom/tpl/objectline_view.tpl.php b/htdocs/bom/tpl/objectline_view.tpl.php
index 0d83754dd60..26f4d070876 100644
--- a/htdocs/bom/tpl/objectline_view.tpl.php
+++ b/htdocs/bom/tpl/objectline_view.tpl.php
@@ -89,6 +89,7 @@ print $tmpproduct->getNomUrl(1);
print ' - '.$tmpproduct->label;
print '';
+// To show BOM links in the list
if ($res > 0) {
print ''.$tmpbom->getNomUrl(1).' ';
} else {
@@ -179,11 +180,13 @@ if ($action == 'selectlines') {
print ' ';
+// Select of all the sub-BOM lines
$sql = 'SELECT rowid, fk_bom_child, fk_product FROM '.MAIN_DB_PREFIX.'bom_bomline AS bl';
$sql.= ' WHERE fk_bom = '.$tmpbom->id;
$resql = $object->db->query($sql);
if ($resql){
+ // Loop on all the sub-BOM lines if they exist
while ($obj = $object->db->fetch_object($resql)){
$sub_bom_product = new Product($object->db);
$sub_bom_product->fetch($obj->fk_product);
@@ -194,18 +197,24 @@ if ($resql){
$sub_bom_line = new BOMLine($object->db);
$sub_bom_line->fetch($obj->rowid);
+ //If hidden conf is set, we show directly all the sub-BOM lines
if (empty($conf->global->BOM_SHOW_ALL_BOM_BY_DEFAULT)){
print '';
} else {
print ' ';
}
+ // Product
print ''.$sub_bom_product->getNomUrl(1).' ';
+
+ // Sub-BOM
if ($sub_bom_line->fk_bom_child > 0) {
print ''.$sub_bom->getNomUrl(1).' ';
} else {
print ' ';
}
+
+ // Qty
print ''.price($sub_bom_line->qty * $line->qty, 0, '', 0, 0).' ';
if ($sub_bom_line->qty_frozen > 0) {
print ''.$sub_bom_line->qty_frozen.' ';
@@ -213,20 +222,28 @@ if ($resql){
print ' ';
}
+ // Disable stock change
if ($sub_bom_line->disable_stock_change > 0) {
print ''.$sub_bom_line->disable_stock_change.' ';
} else {
print ' ';
}
+ // Efficiency
print ''.$sub_bom_line->efficiency.' ';
+
+ // Cost price if it's defined
if ($sub_bom_product->cost_price > 0) {
print ''.price($sub_bom_product->cost_price * $line->qty).' ';
$total_cost.= $sub_bom_product->cost_price * $line->qty;
- } else if ($sub_bom_product->pmp > 0) {
+ }
+ // PMP if cost price isn't defined
+ else if ($sub_bom_product->pmp > 0) {
print ''.price($sub_bom_product->pmp * $line->qty).' ';
$total_cost.= $sub_bom_product->pmp * $line->qty;
- } else {
+ }
+ // Minimum purchase price if cost price and PMP aren't defined
+ else {
$sql_supplier_price = 'SELECT MIN(price) AS min_price FROM '.MAIN_DB_PREFIX.'product_fournisseur_price';
$sql_supplier_price.= ' WHERE fk_product = '.$sub_bom_product->id;
$resql_supplier_price = $object->db->query($sql_supplier_price);
@@ -243,6 +260,7 @@ if ($resql){
}
}
+// Replace of the total_cost value by the sum of all sub-BOM lines total_cost
if ($total_cost > 0) {
$line->total_cost = price($total_cost);
?>
From 3a7d062d7deee5461391351bdb1cbbe6b60c863b Mon Sep 17 00:00:00 2001
From: stickler-ci
Date: Wed, 25 Aug 2021 15:24:03 +0000
Subject: [PATCH 016/341] Fixing style errors.
---
htdocs/bom/script/interface.php | 5 ++---
htdocs/bom/tpl/objectline_view.tpl.php | 10 +++++-----
2 files changed, 7 insertions(+), 8 deletions(-)
diff --git a/htdocs/bom/script/interface.php b/htdocs/bom/script/interface.php
index d5811db0414..c93b54fdc33 100644
--- a/htdocs/bom/script/interface.php
+++ b/htdocs/bom/script/interface.php
@@ -7,7 +7,7 @@ $current_bom_id = GETPOST('current_bom_id', 'alphanohtml');
global $db;
-switch ($action){
+switch ($action) {
case 'select_BOM':
//Selection of nomenclatures corresponding to the selected product
$sql = 'SELECT b.rowid, b.ref, b.label, b.fk_product, p.label AS product_label FROM '.MAIN_DB_PREFIX.'bom_bom AS b ';
@@ -17,8 +17,7 @@ switch ($action){
if ($resql && $db->num_rows($resql) > 0) {
$options = array();
$cpt=0;
- while ($obj = $db->fetch_object($resql)){
-
+ while ($obj = $db->fetch_object($resql)) {
$options[$obj->rowid] = $obj->ref.' - '.$obj->label;
$cpt++;
}
diff --git a/htdocs/bom/tpl/objectline_view.tpl.php b/htdocs/bom/tpl/objectline_view.tpl.php
index 26f4d070876..a25cdeb87ec 100644
--- a/htdocs/bom/tpl/objectline_view.tpl.php
+++ b/htdocs/bom/tpl/objectline_view.tpl.php
@@ -82,7 +82,7 @@ $tmpproduct = new Product($object->db);
$tmpproduct->fetch($line->fk_product);
$tmpbom = new BOM($object->db);
$res = $tmpbom->fetch($line->fk_bom_child);
-if (!empty($tmpbom->id)){
+if (!empty($tmpbom->id)) {
print '' . (empty($conf->global->BOM_SHOW_ALL_BOM_BY_DEFAULT) ? '(+)' : '(-)') . ' ';
}
print $tmpproduct->getNomUrl(1);
@@ -185,9 +185,9 @@ $sql = 'SELECT rowid, fk_bom_child, fk_product FROM '.MAIN_DB_PREFIX.'bom_bomlin
$sql.= ' WHERE fk_bom = '.$tmpbom->id;
$resql = $object->db->query($sql);
-if ($resql){
+if ($resql) {
// Loop on all the sub-BOM lines if they exist
- while ($obj = $object->db->fetch_object($resql)){
+ while ($obj = $object->db->fetch_object($resql)) {
$sub_bom_product = new Product($object->db);
$sub_bom_product->fetch($obj->fk_product);
@@ -198,7 +198,7 @@ if ($resql){
$sub_bom_line->fetch($obj->rowid);
//If hidden conf is set, we show directly all the sub-BOM lines
- if (empty($conf->global->BOM_SHOW_ALL_BOM_BY_DEFAULT)){
+ if (empty($conf->global->BOM_SHOW_ALL_BOM_BY_DEFAULT)) {
print '';
} else {
print ' ';
@@ -238,7 +238,7 @@ if ($resql){
$total_cost.= $sub_bom_product->cost_price * $line->qty;
}
// PMP if cost price isn't defined
- else if ($sub_bom_product->pmp > 0) {
+ elseif ($sub_bom_product->pmp > 0) {
print ''.price($sub_bom_product->pmp * $line->qty).' ';
$total_cost.= $sub_bom_product->pmp * $line->qty;
}
From a79abfd4e01e70850c8893c1c5b645bd5fdb962c Mon Sep 17 00:00:00 2001
From: henrynopo
Date: Thu, 26 Aug 2021 10:37:03 +0800
Subject: [PATCH 017/341] Update card.php
---
htdocs/compta/facture/card.php | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php
index 31de2bbd4ff..4658c10873d 100644
--- a/htdocs/compta/facture/card.php
+++ b/htdocs/compta/facture/card.php
@@ -4052,6 +4052,8 @@ if ($action == 'create') {
$i++;
$close[$i]['code'] = 'badcustomer';
$i++;
+ $close[$i]['code'] = 'bankcharge';
+ $i++;
$close[$i]['code'] = 'other';
$i++;
// Help
@@ -4060,6 +4062,8 @@ if ($action == 'create') {
$i++;
$close[$i]['label'] = $langs->trans("ConfirmClassifyPaidPartiallyReasonBadCustomerDesc");
$i++;
+ $close[$i]['label'] = $langs->trans("ConfirmClassifyPaidPartiallyReasonBankChargeDesc");
+ $i++;
$close[$i]['label'] = $langs->trans("Other");
$i++;
// Texte
@@ -4068,6 +4072,8 @@ if ($action == 'create') {
$i++;
$close[$i]['reason'] = $form->textwithpicto($langs->transnoentities("ConfirmClassifyPaidPartiallyReasonBadCustomer", $resteapayer, $langs->trans("Currency".$conf->currency)), $close[$i]['label'], 1);
$i++;
+ $close[$i]['reason'] = $form->textwithpicto($langs->transnoentities("ConfirmClassifyPaidPartiallyReasonBankCharge", $resteapayer, $langs->trans("Currency".$conf->currency)), $close[$i]['label'], 1);
+ $i++;
$close[$i]['reason'] = $form->textwithpicto($langs->transnoentities("Other"), $close[$i]['label'], 1);
$i++;
// arrayreasons[code]=reason
From a25580f97cfeda3e314926264063d85e0d251a18 Mon Sep 17 00:00:00 2001
From: henrynopo
Date: Thu, 26 Aug 2021 10:38:53 +0800
Subject: [PATCH 018/341] Update bills.lang
---
htdocs/langs/en_US/bills.lang | 2 ++
1 file changed, 2 insertions(+)
diff --git a/htdocs/langs/en_US/bills.lang b/htdocs/langs/en_US/bills.lang
index a921aac9e48..6a88f2599dd 100644
--- a/htdocs/langs/en_US/bills.lang
+++ b/htdocs/langs/en_US/bills.lang
@@ -192,6 +192,7 @@ ConfirmClassifyPaidPartiallyReasonDiscount=Remaining unpaid (%s %s) is a
ConfirmClassifyPaidPartiallyReasonDiscountNoVat=Remaining unpaid (%s %s) is a discount granted because payment was made before term. I accept to lose the VAT on this discount.
ConfirmClassifyPaidPartiallyReasonDiscountVat=Remaining unpaid (%s %s) is a discount granted because payment was made before term. I recover the VAT on this discount without a credit note.
ConfirmClassifyPaidPartiallyReasonBadCustomer=Bad customer
+ConfirmClassifyPaidPartiallyReasonBankCharge=Deduction by bank (intermediary bank fees)
ConfirmClassifyPaidPartiallyReasonProductReturned=Products partially returned
ConfirmClassifyPaidPartiallyReasonOther=Amount abandoned for other reason
ConfirmClassifyPaidPartiallyReasonDiscountNoVatDesc=This choice is possible if your invoice has been provided with suitable comments. (Example «Only the tax corresponding to the price that has been actually paid gives rights to deduction»)
@@ -199,6 +200,7 @@ ConfirmClassifyPaidPartiallyReasonDiscountVatDesc=In some countries, this choice
ConfirmClassifyPaidPartiallyReasonAvoirDesc=Use this choice if all other does not suit
ConfirmClassifyPaidPartiallyReasonBadCustomerDesc=A bad customer is a customer that refuses to pay his debt.
ConfirmClassifyPaidPartiallyReasonProductReturnedDesc=This choice is used when payment is not complete because some of products were returned
+ConfirmClassifyPaidPartiallyReasonBankChargeDesc=The unpaid amount is intermediary bank fees , deducted directly from the correct amount paid by the Customer.
ConfirmClassifyPaidPartiallyReasonOtherDesc=Use this choice if all others are not suitable, for example in following situation: - payment not complete because some products were shipped back - amount claimed too important because a discount was forgotten In all cases, amount over-claimed must be corrected in accountancy system by creating a credit note.
ConfirmClassifyAbandonReasonOther=Other
ConfirmClassifyAbandonReasonOtherDesc=This choice will be used in all other cases. For example because you plan to create a replacing invoice.
From 0463846df1c65a23e128e51bb96a5f7a06bc333b Mon Sep 17 00:00:00 2001
From: Adrien Raze
Date: Thu, 26 Aug 2021 09:27:03 +0200
Subject: [PATCH 019/341] FIX : Stickler
---
htdocs/bom/tpl/objectline_view.tpl.php | 2 ++
1 file changed, 2 insertions(+)
diff --git a/htdocs/bom/tpl/objectline_view.tpl.php b/htdocs/bom/tpl/objectline_view.tpl.php
index 26f4d070876..3e1922db7fc 100644
--- a/htdocs/bom/tpl/objectline_view.tpl.php
+++ b/htdocs/bom/tpl/objectline_view.tpl.php
@@ -237,11 +237,13 @@ if ($resql){
print ''.price($sub_bom_product->cost_price * $line->qty).' ';
$total_cost.= $sub_bom_product->cost_price * $line->qty;
}
+
// PMP if cost price isn't defined
else if ($sub_bom_product->pmp > 0) {
print ''.price($sub_bom_product->pmp * $line->qty).' ';
$total_cost.= $sub_bom_product->pmp * $line->qty;
}
+
// Minimum purchase price if cost price and PMP aren't defined
else {
$sql_supplier_price = 'SELECT MIN(price) AS min_price FROM '.MAIN_DB_PREFIX.'product_fournisseur_price';
From 578de93dc4e98e3360223ca2053829605e73b676 Mon Sep 17 00:00:00 2001
From: stickler-ci
Date: Thu, 26 Aug 2021 07:30:36 +0000
Subject: [PATCH 020/341] Fixing style errors.
---
htdocs/bom/tpl/objectline_view.tpl.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/htdocs/bom/tpl/objectline_view.tpl.php b/htdocs/bom/tpl/objectline_view.tpl.php
index 1ee64890384..6aa00e79835 100644
--- a/htdocs/bom/tpl/objectline_view.tpl.php
+++ b/htdocs/bom/tpl/objectline_view.tpl.php
@@ -243,7 +243,7 @@ if ($resql) {
print ''.price($sub_bom_product->pmp * $line->qty).' ';
$total_cost.= $sub_bom_product->pmp * $line->qty;
}
-
+
// Minimum purchase price if cost price and PMP aren't defined
else {
$sql_supplier_price = 'SELECT MIN(price) AS min_price FROM '.MAIN_DB_PREFIX.'product_fournisseur_price';
From 0222df7ecc65c0589a32fb911102d9c18facf991 Mon Sep 17 00:00:00 2001
From: Adrien Raze
Date: Thu, 26 Aug 2021 09:34:30 +0200
Subject: [PATCH 021/341] FIX : Expected 1 space after closing brace; newline
found
---
htdocs/bom/tpl/objectline_view.tpl.php | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/htdocs/bom/tpl/objectline_view.tpl.php b/htdocs/bom/tpl/objectline_view.tpl.php
index 1ee64890384..b8d054d9ecc 100644
--- a/htdocs/bom/tpl/objectline_view.tpl.php
+++ b/htdocs/bom/tpl/objectline_view.tpl.php
@@ -236,14 +236,14 @@ if ($resql) {
if ($sub_bom_product->cost_price > 0) {
print ''.price($sub_bom_product->cost_price * $line->qty).' ';
$total_cost.= $sub_bom_product->cost_price * $line->qty;
- }
+ }
// PMP if cost price isn't defined
elseif ($sub_bom_product->pmp > 0) {
print ''.price($sub_bom_product->pmp * $line->qty).' ';
$total_cost.= $sub_bom_product->pmp * $line->qty;
}
-
+
// Minimum purchase price if cost price and PMP aren't defined
else {
$sql_supplier_price = 'SELECT MIN(price) AS min_price FROM '.MAIN_DB_PREFIX.'product_fournisseur_price';
From bdcddebb5fdc47084a5279b68ec65957cae47e54 Mon Sep 17 00:00:00 2001
From: stickler-ci
Date: Thu, 26 Aug 2021 07:37:39 +0000
Subject: [PATCH 022/341] Fixing style errors.
---
htdocs/bom/tpl/objectline_view.tpl.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/htdocs/bom/tpl/objectline_view.tpl.php b/htdocs/bom/tpl/objectline_view.tpl.php
index b8d054d9ecc..6aa00e79835 100644
--- a/htdocs/bom/tpl/objectline_view.tpl.php
+++ b/htdocs/bom/tpl/objectline_view.tpl.php
@@ -236,7 +236,7 @@ if ($resql) {
if ($sub_bom_product->cost_price > 0) {
print ''.price($sub_bom_product->cost_price * $line->qty).' ';
$total_cost.= $sub_bom_product->cost_price * $line->qty;
- }
+ }
// PMP if cost price isn't defined
elseif ($sub_bom_product->pmp > 0) {
From 05444078bdffd9fd880fd9b9a7cd537c3d34a58b Mon Sep 17 00:00:00 2001
From: Adrien Raze
Date: Thu, 26 Aug 2021 09:43:50 +0200
Subject: [PATCH 023/341] FIX : stickler
---
htdocs/bom/tpl/objectline_view.tpl.php | 10 ++--------
1 file changed, 2 insertions(+), 8 deletions(-)
diff --git a/htdocs/bom/tpl/objectline_view.tpl.php b/htdocs/bom/tpl/objectline_view.tpl.php
index b8d054d9ecc..41ff84b4d13 100644
--- a/htdocs/bom/tpl/objectline_view.tpl.php
+++ b/htdocs/bom/tpl/objectline_view.tpl.php
@@ -236,16 +236,10 @@ if ($resql) {
if ($sub_bom_product->cost_price > 0) {
print ''.price($sub_bom_product->cost_price * $line->qty).' ';
$total_cost.= $sub_bom_product->cost_price * $line->qty;
- }
-
- // PMP if cost price isn't defined
- elseif ($sub_bom_product->pmp > 0) {
+ } elseif ($sub_bom_product->pmp > 0) { // PMP if cost price isn't defined
print ''.price($sub_bom_product->pmp * $line->qty).' ';
$total_cost.= $sub_bom_product->pmp * $line->qty;
- }
-
- // Minimum purchase price if cost price and PMP aren't defined
- else {
+ } else { // Minimum purchase price if cost price and PMP aren't defined
$sql_supplier_price = 'SELECT MIN(price) AS min_price FROM '.MAIN_DB_PREFIX.'product_fournisseur_price';
$sql_supplier_price.= ' WHERE fk_product = '.$sub_bom_product->id;
$resql_supplier_price = $object->db->query($sql_supplier_price);
From e74043d48e8cec111fb052506bc9621f107b8f1d Mon Sep 17 00:00:00 2001
From: javieralapps4up
Date: Wed, 22 Sep 2021 17:56:31 +0200
Subject: [PATCH 024/341] Close: #18801 Jan-30 + 1m IS NOT Mar-2
Close: #18801 related to avoid this behaviour https://bugs.php.net/bug.php?id=74013
---
htdocs/core/lib/date.lib.php | 28 +++++++++++++++++++++++++++-
1 file changed, 27 insertions(+), 1 deletion(-)
diff --git a/htdocs/core/lib/date.lib.php b/htdocs/core/lib/date.lib.php
index fe21071901a..21a8835a229 100644
--- a/htdocs/core/lib/date.lib.php
+++ b/htdocs/core/lib/date.lib.php
@@ -166,7 +166,33 @@ function dol_time_plus_duree($time, $duration_value, $duration_unit)
} else {
$date->add($interval);
}
-
+ //Change the behavior of PHP over data-interval when the result of this function is Feb 29 (non-leap years), 30 or Feb 31 (php returns March 1, 2 or 3 respectively)
+ if ($conf->global->MAIN_DATE_CHANGE_PHP_DATEINTERVAL_RESULT_FEBRUARY && $duration_unit == 'm') {
+
+ $timeyear = dol_print_date($time, '%Y');
+ $timemonth = dol_print_date($time, '%m');
+ $timetotalmonths = (($timeyear * 12) + $timemonth);
+
+ $monthsexpected = ($timetotalmonths + $duration_value);
+
+ $newtime = $date->getTimestamp();
+
+ $newtimeyear = dol_print_date($newtime, '%Y');
+ $newtimemonth = dol_print_date($newtime, '%m');
+ $newtimetotalmonths = (($newtimeyear * 12) + $newtimemonth);
+
+ if ($monthsexpected < $newtimetotalmonths) {
+
+ $newtimehours = dol_print_date($newtime, '%m');
+ $newtimemins = dol_print_date($newtime, '%m');
+ $newtimesecs = dol_print_date($newtime, '%m');
+
+ $datelim = dol_mktime($newtimehours, $newtimemins, $newtimesecs, $newtimemonth, 1, $newtimeyear);
+ $datelim -= (3600 * 24);
+
+ $date->setTimestamp($datelim);
+ }
+ }
return $date->getTimestamp();
}
From e5cff0ede117553c11b269a2a529fbac41eee8fb Mon Sep 17 00:00:00 2001
From: stickler-ci
Date: Wed, 22 Sep 2021 16:07:36 +0000
Subject: [PATCH 025/341] Fixing style errors.
---
htdocs/core/lib/date.lib.php | 46 +++++++++++++++++-------------------
1 file changed, 22 insertions(+), 24 deletions(-)
diff --git a/htdocs/core/lib/date.lib.php b/htdocs/core/lib/date.lib.php
index 21a8835a229..cff6d22518f 100644
--- a/htdocs/core/lib/date.lib.php
+++ b/htdocs/core/lib/date.lib.php
@@ -168,30 +168,28 @@ function dol_time_plus_duree($time, $duration_value, $duration_unit)
}
//Change the behavior of PHP over data-interval when the result of this function is Feb 29 (non-leap years), 30 or Feb 31 (php returns March 1, 2 or 3 respectively)
if ($conf->global->MAIN_DATE_CHANGE_PHP_DATEINTERVAL_RESULT_FEBRUARY && $duration_unit == 'm') {
-
- $timeyear = dol_print_date($time, '%Y');
- $timemonth = dol_print_date($time, '%m');
- $timetotalmonths = (($timeyear * 12) + $timemonth);
-
- $monthsexpected = ($timetotalmonths + $duration_value);
-
- $newtime = $date->getTimestamp();
-
- $newtimeyear = dol_print_date($newtime, '%Y');
- $newtimemonth = dol_print_date($newtime, '%m');
- $newtimetotalmonths = (($newtimeyear * 12) + $newtimemonth);
-
- if ($monthsexpected < $newtimetotalmonths) {
-
- $newtimehours = dol_print_date($newtime, '%m');
- $newtimemins = dol_print_date($newtime, '%m');
- $newtimesecs = dol_print_date($newtime, '%m');
-
- $datelim = dol_mktime($newtimehours, $newtimemins, $newtimesecs, $newtimemonth, 1, $newtimeyear);
- $datelim -= (3600 * 24);
-
- $date->setTimestamp($datelim);
- }
+ $timeyear = dol_print_date($time, '%Y');
+ $timemonth = dol_print_date($time, '%m');
+ $timetotalmonths = (($timeyear * 12) + $timemonth);
+
+ $monthsexpected = ($timetotalmonths + $duration_value);
+
+ $newtime = $date->getTimestamp();
+
+ $newtimeyear = dol_print_date($newtime, '%Y');
+ $newtimemonth = dol_print_date($newtime, '%m');
+ $newtimetotalmonths = (($newtimeyear * 12) + $newtimemonth);
+
+ if ($monthsexpected < $newtimetotalmonths) {
+ $newtimehours = dol_print_date($newtime, '%m');
+ $newtimemins = dol_print_date($newtime, '%m');
+ $newtimesecs = dol_print_date($newtime, '%m');
+
+ $datelim = dol_mktime($newtimehours, $newtimemins, $newtimesecs, $newtimemonth, 1, $newtimeyear);
+ $datelim -= (3600 * 24);
+
+ $date->setTimestamp($datelim);
+ }
}
return $date->getTimestamp();
}
From c4f1eb0c46fdaa81cc335e906177d752e8bb829e Mon Sep 17 00:00:00 2001
From: javieralapps4up
Date: Mon, 27 Sep 2021 14:32:03 +0200
Subject: [PATCH 026/341] Update date.lib.php
Fix my error
---
htdocs/core/lib/date.lib.php | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/htdocs/core/lib/date.lib.php b/htdocs/core/lib/date.lib.php
index cff6d22518f..b17c0c9d56d 100644
--- a/htdocs/core/lib/date.lib.php
+++ b/htdocs/core/lib/date.lib.php
@@ -181,9 +181,9 @@ function dol_time_plus_duree($time, $duration_value, $duration_unit)
$newtimetotalmonths = (($newtimeyear * 12) + $newtimemonth);
if ($monthsexpected < $newtimetotalmonths) {
- $newtimehours = dol_print_date($newtime, '%m');
- $newtimemins = dol_print_date($newtime, '%m');
- $newtimesecs = dol_print_date($newtime, '%m');
+ $newtimehours = dol_print_date($newtime, '%h');
+ $newtimemins = dol_print_date($newtime, '%i');
+ $newtimesecs = dol_print_date($newtime, '%s');
$datelim = dol_mktime($newtimehours, $newtimemins, $newtimesecs, $newtimemonth, 1, $newtimeyear);
$datelim -= (3600 * 24);
From 11723c2cd08fb15ffac8a51e8526fb9fec5c287a Mon Sep 17 00:00:00 2001
From: javieralapps4up
Date: Mon, 27 Sep 2021 14:49:22 +0200
Subject: [PATCH 027/341] Update date.lib.php
Without words, sorry
---
htdocs/core/lib/date.lib.php | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/htdocs/core/lib/date.lib.php b/htdocs/core/lib/date.lib.php
index b17c0c9d56d..613533a443a 100644
--- a/htdocs/core/lib/date.lib.php
+++ b/htdocs/core/lib/date.lib.php
@@ -181,9 +181,9 @@ function dol_time_plus_duree($time, $duration_value, $duration_unit)
$newtimetotalmonths = (($newtimeyear * 12) + $newtimemonth);
if ($monthsexpected < $newtimetotalmonths) {
- $newtimehours = dol_print_date($newtime, '%h');
- $newtimemins = dol_print_date($newtime, '%i');
- $newtimesecs = dol_print_date($newtime, '%s');
+ $newtimehours = dol_print_date($newtime, '%H');
+ $newtimemins = dol_print_date($newtime, '%M');
+ $newtimesecs = dol_print_date($newtime, '%S');
$datelim = dol_mktime($newtimehours, $newtimemins, $newtimesecs, $newtimemonth, 1, $newtimeyear);
$datelim -= (3600 * 24);
From 2da16ade6c722e1464a6c8f571beaba150f194d9 Mon Sep 17 00:00:00 2001
From: atm-florian
Date: Fri, 8 Oct 2021 17:24:52 +0200
Subject: [PATCH 028/341] FIX: consistent UX when calling a tab from the
invoice card with empty ref / id
---
htdocs/compta/facture/card.php | 11 +++++++++++
htdocs/compta/facture/contact.php | 11 +++++++++++
htdocs/compta/facture/document.php | 11 +++++++++++
htdocs/compta/facture/info.php | 11 +++++++++++
htdocs/compta/facture/note.php | 11 +++++++++++
5 files changed, 55 insertions(+)
diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php
index e15b2722800..ab568332dd8 100644
--- a/htdocs/compta/facture/card.php
+++ b/htdocs/compta/facture/card.php
@@ -2756,6 +2756,17 @@ if (empty($reshook))
* View
*/
+if (empty($object->id)) {
+ llxHeader();
+ $head = facture_prepare_head($object);
+ $langs->load('errors');
+ echo dol_get_fiche_head($head, 'compta', $langs->trans("InvoiceCustomer"), -1, 'bill'),
+ '' . $langs->trans("ErrorRecordNotFound") . '
';
+ llxFooter();
+ dol_shutdown();
+ exit;
+}
+
$form = new Form($db);
$formother = new FormOther($db);
$formfile = new FormFile($db);
diff --git a/htdocs/compta/facture/contact.php b/htdocs/compta/facture/contact.php
index c340d68242e..c0e0a40c2c5 100644
--- a/htdocs/compta/facture/contact.php
+++ b/htdocs/compta/facture/contact.php
@@ -118,6 +118,17 @@ elseif ($action == 'deletecontact' && $user->rights->facture->creer)
* View
*/
+if (empty($object->id)) {
+ llxHeader();
+ $head = facture_prepare_head($object);
+ $langs->load('errors');
+ echo dol_get_fiche_head($head, 'contact', $langs->trans("InvoiceCustomer"), -1, 'bill'),
+ '' . $langs->trans("ErrorRecordNotFound") . '
';
+ llxFooter();
+ dol_shutdown();
+ exit;
+}
+
$title = $langs->trans('InvoiceCustomer')." - ".$langs->trans('ContactsAddresses');
$helpurl = "EN:Customers_Invoices|FR:Factures_Clients|ES:Facturas_a_clientes";
llxHeader('', $title, $helpurl);
diff --git a/htdocs/compta/facture/document.php b/htdocs/compta/facture/document.php
index e880d77db74..64ebed251d3 100644
--- a/htdocs/compta/facture/document.php
+++ b/htdocs/compta/facture/document.php
@@ -85,6 +85,17 @@ require_once DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php';
* View
*/
+if (empty($object->id)) {
+ llxHeader();
+ $head = facture_prepare_head($object);
+ $langs->load('errors');
+ echo dol_get_fiche_head($head, 'documents', $langs->trans("InvoiceCustomer"), -1, 'bill'),
+ '' . $langs->trans("ErrorRecordNotFound") . '
';
+ llxFooter();
+ dol_shutdown();
+ exit;
+}
+
$title = $langs->trans('InvoiceCustomer')." - ".$langs->trans('Documents');
$helpurl = "EN:Customers_Invoices|FR:Factures_Clients|ES:Facturas_a_clientes";
llxHeader('', $title, $helpurl);
diff --git a/htdocs/compta/facture/info.php b/htdocs/compta/facture/info.php
index bad63cf1f61..9e40fd8b5a8 100644
--- a/htdocs/compta/facture/info.php
+++ b/htdocs/compta/facture/info.php
@@ -43,6 +43,17 @@ $ref = GETPOST("ref", 'alpha');
* View
*/
+if (empty($object->id)) {
+ llxHeader();
+ $head = facture_prepare_head($object);
+ $langs->load('errors');
+ echo dol_get_fiche_head($head, 'info', $langs->trans("InvoiceCustomer"), -1, 'bill'),
+ '' . $langs->trans("ErrorRecordNotFound") . '
';
+ llxFooter();
+ dol_shutdown();
+ exit;
+}
+
$form = new Form($db);
$title = $langs->trans('InvoiceCustomer')." - ".$langs->trans('Info');
diff --git a/htdocs/compta/facture/note.php b/htdocs/compta/facture/note.php
index 07084a0cf2c..428383b4907 100644
--- a/htdocs/compta/facture/note.php
+++ b/htdocs/compta/facture/note.php
@@ -64,6 +64,17 @@ include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include,
* View
*/
+if (empty($object->id)) {
+ llxHeader();
+ $head = facture_prepare_head($object);
+ $langs->load('errors');
+ echo dol_get_fiche_head($head, 'note', $langs->trans("InvoiceCustomer"), -1, 'bill'),
+ '' . $langs->trans("ErrorRecordNotFound") . '
';
+ llxFooter();
+ dol_shutdown();
+ exit;
+}
+
$title = $langs->trans('InvoiceCustomer')." - ".$langs->trans('Notes');
$helpurl = "EN:Customers_Invoices|FR:Factures_Clients|ES:Facturas_a_clientes";
llxHeader('', $title, $helpurl);
From 57052e2fbabffa16b25a25fe02a1966e117d09db Mon Sep 17 00:00:00 2001
From: atm-florian
Date: Mon, 11 Oct 2021 11:10:14 +0200
Subject: [PATCH 029/341] FIX PR#18931 Remove useless explicit call to
dol_shutdown
---
htdocs/compta/facture/card.php | 1 -
htdocs/compta/facture/contact.php | 1 -
htdocs/compta/facture/document.php | 1 -
htdocs/compta/facture/info.php | 1 -
htdocs/compta/facture/note.php | 1 -
5 files changed, 5 deletions(-)
diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php
index ab568332dd8..c772fd0ad7b 100644
--- a/htdocs/compta/facture/card.php
+++ b/htdocs/compta/facture/card.php
@@ -2763,7 +2763,6 @@ if (empty($object->id)) {
echo dol_get_fiche_head($head, 'compta', $langs->trans("InvoiceCustomer"), -1, 'bill'),
'' . $langs->trans("ErrorRecordNotFound") . '
';
llxFooter();
- dol_shutdown();
exit;
}
diff --git a/htdocs/compta/facture/contact.php b/htdocs/compta/facture/contact.php
index c0e0a40c2c5..7177463c30e 100644
--- a/htdocs/compta/facture/contact.php
+++ b/htdocs/compta/facture/contact.php
@@ -125,7 +125,6 @@ if (empty($object->id)) {
echo dol_get_fiche_head($head, 'contact', $langs->trans("InvoiceCustomer"), -1, 'bill'),
'' . $langs->trans("ErrorRecordNotFound") . '
';
llxFooter();
- dol_shutdown();
exit;
}
diff --git a/htdocs/compta/facture/document.php b/htdocs/compta/facture/document.php
index 64ebed251d3..0818b944705 100644
--- a/htdocs/compta/facture/document.php
+++ b/htdocs/compta/facture/document.php
@@ -92,7 +92,6 @@ if (empty($object->id)) {
echo dol_get_fiche_head($head, 'documents', $langs->trans("InvoiceCustomer"), -1, 'bill'),
'' . $langs->trans("ErrorRecordNotFound") . '
';
llxFooter();
- dol_shutdown();
exit;
}
diff --git a/htdocs/compta/facture/info.php b/htdocs/compta/facture/info.php
index 9e40fd8b5a8..955c41693c0 100644
--- a/htdocs/compta/facture/info.php
+++ b/htdocs/compta/facture/info.php
@@ -50,7 +50,6 @@ if (empty($object->id)) {
echo dol_get_fiche_head($head, 'info', $langs->trans("InvoiceCustomer"), -1, 'bill'),
'' . $langs->trans("ErrorRecordNotFound") . '
';
llxFooter();
- dol_shutdown();
exit;
}
diff --git a/htdocs/compta/facture/note.php b/htdocs/compta/facture/note.php
index 428383b4907..dadb61b551d 100644
--- a/htdocs/compta/facture/note.php
+++ b/htdocs/compta/facture/note.php
@@ -71,7 +71,6 @@ if (empty($object->id)) {
echo dol_get_fiche_head($head, 'note', $langs->trans("InvoiceCustomer"), -1, 'bill'),
'' . $langs->trans("ErrorRecordNotFound") . '
';
llxFooter();
- dol_shutdown();
exit;
}
From e899d94ed5c396edb5956ea7ed4011a0acd7cb42 Mon Sep 17 00:00:00 2001
From: Alexandre SPANGARO
Date: Mon, 11 Oct 2021 12:50:07 +0200
Subject: [PATCH 030/341] NEW Accountancy - rewrite bind accountancy code
finding on purchase invoice
---
htdocs/accountancy/supplier/index.php | 90 ++++++++++----
htdocs/accountancy/supplier/list.php | 161 ++++++++++----------------
2 files changed, 130 insertions(+), 121 deletions(-)
diff --git a/htdocs/accountancy/supplier/index.php b/htdocs/accountancy/supplier/index.php
index 5e409f303ea..476ead53860 100644
--- a/htdocs/accountancy/supplier/index.php
+++ b/htdocs/accountancy/supplier/index.php
@@ -1,7 +1,7 @@
- * Copyright (C) 2013-2014 Florian Henry
- * Copyright (C) 2013-2020 Alexandre Spangaro
+ * Copyright (C) 2013-2021 Florian Henry
+ * Copyright (C) 2013-2021 Alexandre Spangaro
* Copyright (C) 2014 Juanjo Menent
*
* This program is free software; you can redistribute it and/or modify
@@ -29,6 +29,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
+require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php';
// Load translation files required by the page
$langs->loadLangs(array("compta", "bills", "other", "accountancy"));
@@ -44,6 +45,7 @@ if (!$user->rights->accounting->bind->write) {
accessforbidden();
}
+$accountingAccount = new AccountingAccount($db);
$month_start = ($conf->global->SOCIETE_FISCAL_MONTH_START ? ($conf->global->SOCIETE_FISCAL_MONTH_START) : 1);
if (GETPOST("year", 'int')) {
@@ -97,6 +99,7 @@ if (($action == 'clean' || $action == 'validatehistory') && $user->rights->accou
$sql1 .= ' ON accnt.fk_pcg_version = syst.pcg_version AND syst.rowid='.$conf->global->CHARTOFACCOUNTS.' AND accnt.entity = '.$conf->entity.')';
$sql1 .= ' AND fd.fk_facture_fourn IN (SELECT rowid FROM '.MAIN_DB_PREFIX.'facture_fourn WHERE entity = '.$conf->entity.')';
$sql1 .= ' AND fk_code_ventilation <> 0';
+
dol_syslog("htdocs/accountancy/customer/index.php fixaccountancycode", LOG_DEBUG);
$resql1 = $db->query($sql1);
if (!$resql1) {
@@ -163,7 +166,7 @@ if ($action == 'validatehistory') {
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON " . $alias_product_perentity . ".accountancy_code_buy = aa.account_number AND aa.active = 1 AND aa.fk_pcg_version = '".$db->escape($chartaccountcode)."' AND aa.entity = ".$conf->entity;
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa2 ON " . $alias_product_perentity . ".accountancy_code_buy_intra = aa2.account_number AND aa2.active = 1 AND aa2.fk_pcg_version = '".$db->escape($chartaccountcode)."' AND aa2.entity = ".$conf->entity;
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa3 ON " . $alias_product_perentity . ".accountancy_code_buy_export = aa3.account_number AND aa3.active = 1 AND aa3.fk_pcg_version = '".$db->escape($chartaccountcode)."' AND aa3.entity = ".$conf->entity;
- $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa4 ON " . $alias_product_perentity . ".accountancy_code_buy = aa4.account_number AND aa4.active = 1 AND aa4.fk_pcg_version = '".$db->escape($chartaccountcode)."' AND aa4.entity = ".$conf->entity;
+ $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa4 ON " . $alias_societe_perentity . ".accountancy_code_buy = aa4.account_number AND aa4.active = 1 AND aa4.fk_pcg_version = '".$db->escape($chartaccountcode)."' AND aa4.entity = ".$conf->entity;
$sql .= " WHERE f.fk_statut > 0 AND l.fk_code_ventilation <= 0";
$sql .= " AND l.product_type <= 2";
if (!empty($conf->global->ACCOUNTING_DATE_START_BINDING)) {
@@ -181,27 +184,74 @@ if ($action == 'validatehistory') {
$isBuyerInEEC = isInEEC($mysoc);
+ $thirdpartystatic = new Societe($db);
+ $facture_static = new FactureFournisseur($db);
+ $facture_static_det = new SupplierInvoiceLine($db);
+ $product_static = new Product($db);
+
$i = 0;
while ($i < min($num_lines, 10000)) { // No more than 10000 at once
$objp = $db->fetch_object($result);
- $isSellerInEEC = isInEEC($objp);
+ $thirdpartystatic->id = $objp->socid;
+ $thirdpartystatic->name = $objp->name;
+ $thirdpartystatic->client = $objp->client;
+ $thirdpartystatic->fournisseur = $objp->fournisseur;
+ $thirdpartystatic->code_client = $objp->code_client;
+ $thirdpartystatic->code_compta_client = $objp->code_compta_client;
+ $thirdpartystatic->code_fournisseur = $objp->code_fournisseur;
+ $thirdpartystatic->code_compta_fournisseur = $objp->code_compta_fournisseur;
+ $thirdpartystatic->email = $objp->email;
+ $thirdpartystatic->country_code = $objp->country_code;
+ $thirdpartystatic->tva_intra = $objp->tva_intra;
+ $thirdpartystatic->code_compta = $objp->company_code_sell;
- // Level 2: Search suggested account for product/service (similar code exists in page list.php to make manual binding)
- $suggestedaccountingaccountfor = '';
- if (($objp->country_code == $mysoc->country_code) || empty($objp->country_code)) { // If buyer in same country than seller (if not defined, we assume it is same country)
- $objp->code_buy_p = $objp->code_buy;
- $objp->aarowid_suggest = $objp->aarowid;
- $suggestedaccountingaccountfor = '';
+ $product_static->ref = $objp->product_ref;
+ $product_static->id = $objp->product_id;
+ $product_static->type = $objp->type;
+ $product_static->label = $objp->product_label;
+ $product_static->status = $objp->status;
+ $product_static->status_buy = $objp->status_buy;
+ $product_static->accountancy_code_sell = $objp->code_sell;
+ $product_static->accountancy_code_sell_intra = $objp->code_sell_intra;
+ $product_static->accountancy_code_sell_export = $objp->code_sell_export;
+ $product_static->accountancy_code_buy = $objp->code_buy;
+ $product_static->accountancy_code_buy_intra = $objp->code_buy_intra;
+ $product_static->accountancy_code_buy_export = $objp->code_buy_export;
+ $product_static->tva_tx = $objp->tva_tx_prod;
+
+ $facture_static->ref = $objp->ref;
+ $facture_static->id = $objp->facid;
+ $facture_static->type = $objp->ftype;
+ $facture_static->datef = $objp->datef;
+
+ $facture_static_det->id = $objp->rowid;
+ $facture_static_det->total_ht = $objp->total_ht;
+ $facture_static_det->tva_tx = $objp->tva_tx_line;
+ $facture_static_det->vat_src_code = $objp->vat_src_code;
+ $facture_static_det->product_type = $objp->type_l;
+ $facture_static_det->desc = $objp->description;
+
+ $accoutingAccountArray = array(
+ 'dom'=>$objp->aarowid,
+ 'intra'=>$objp->aarowid_intra,
+ 'export'=>$objp->aarowid_export,
+ 'thirdparty' =>$objp->aarowid_thirdparty);
+
+ $code_buy_p_notset = '';
+ $code_buy_t_notset = '';
+
+ $return = $accountingAccount->getAccountingCodeToBind($mysoc, $thirdpartystatic, $product_static, $facture_static, $facture_static_det, $accoutingAccountArray);
+ if (!is_array($return) && $return<0) {
+ setEventMessage($accountingAccount->error, 'errors');
} else {
- if ($isSellerInEEC && $isBuyerInEEC) { // European intravat sale
- $objp->code_buy_p = $objp->code_buy_intra;
- $objp->aarowid_suggest = $objp->aarowid_intra;
- $suggestedaccountingaccountfor = 'eec';
- } else { // Foreign sale
- $objp->code_buy_p = $objp->code_buy_export;
- $objp->aarowid_suggest = $objp->aarowid_export;
- $suggestedaccountingaccountfor = 'export';
+ $suggestedid=$return['suggestedid'];
+ $suggestedaccountingaccountfor=$return['suggestedaccountingaccountfor'];
+
+ if (!empty($suggestedid) && $suggestedaccountingaccountfor<>'') {
+ $suggestedid=$return['suggestedid'];
+ } else {
+ $suggestedid=0;
}
}
@@ -216,8 +266,8 @@ if ($action == 'validatehistory') {
if ($objp->aarowid_suggest > 0) {
$sqlupdate = "UPDATE ".MAIN_DB_PREFIX."facture_fourn_det";
- $sqlupdate .= " SET fk_code_ventilation = ".((int) $objp->aarowid_suggest);
- $sqlupdate .= " WHERE fk_code_ventilation <= 0 AND product_type <= 2 AND rowid = ".((int) $objp->rowid);
+ $sqlupdate .= " SET fk_code_ventilation = ".((int) $suggestedid);
+ $sqlupdate .= " WHERE fk_code_ventilation <= 0 AND product_type <= 2 AND rowid = ".((int) $facture_static_det->id);
$resqlupdate = $db->query($sqlupdate);
if (!$resqlupdate) {
diff --git a/htdocs/accountancy/supplier/list.php b/htdocs/accountancy/supplier/list.php
index ffdd5b6de57..d3bb7985376 100644
--- a/htdocs/accountancy/supplier/list.php
+++ b/htdocs/accountancy/supplier/list.php
@@ -2,7 +2,7 @@
/* Copyright (C) 2013-2014 Olivier Geffroy
* Copyright (C) 2013-2021 Alexandre Spangaro
* Copyright (C) 2014-2015 Ari Elbaz (elarifr)
- * Copyright (C) 2013-2014 Florian Henry
+ * Copyright (C) 2013-2021 Florian Henry
* Copyright (C) 2014 Juanjo Menent s
* Copyright (C) 2016 Laurent Destailleur
*
@@ -46,6 +46,7 @@ $massaction = GETPOST('massaction', 'alpha');
$show_files = GETPOST('show_files', 'int');
$confirm = GETPOST('confirm', 'alpha');
$toselect = GETPOST('toselect', 'array');
+$optioncss = GETPOST('optioncss', 'alpha');
// Select Box
$mesCasesCochees = GETPOST('toselect', 'array');
@@ -97,10 +98,7 @@ if (!$sortorder) {
$hookmanager->initHooks(array('accountancysupplierlist'));
$formaccounting = new FormAccounting($db);
-$accounting = new AccountingAccount($db);
-// TODO: we should need to check if result is a really exist accountaccount rowid.....
-$aarowid_s = $accounting->fetch('', $conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT, 1);
-$aarowid_p = $accounting->fetch('', $conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT, 1);
+$accountingAccount = new AccountingAccount($db);
$chartaccountcode = dol_getIdFromCode($db, $conf->global->CHARTOFACCOUNTS, 'accounting_system', 'rowid', 'pcg_version');
@@ -518,9 +516,9 @@ if ($result) {
$thirdpartystatic = new Societe($db);
$facturefourn_static = new FactureFournisseur($db);
+ $facturefourn_static_det = new SupplierInvoiceLine($db);
$product_static = new Product($db);
- $isBuyerInEEC = isInEEC($mysoc);
$accountingaccount_codetotid_cache = array();
@@ -543,6 +541,8 @@ if ($result) {
$thirdpartystatic->code_compta_fournisseur = $objp->code_compta_fournisseur;
$thirdpartystatic->email = $objp->email;
$thirdpartystatic->country_code = $objp->country_code;
+ $thirdpartystatic->tva_intra = $objp->tva_intra;
+ $thirdpartystatic->code_compta_fournisseur = $objp->company_code_buy;
$product_static->ref = $objp->product_ref;
$product_static->id = $objp->product_id;
@@ -556,95 +556,63 @@ if ($result) {
$product_static->accountancy_code_buy = $objp->code_buy;
$product_static->accountancy_code_buy_intra = $objp->code_buy_intra;
$product_static->accountancy_code_buy_export = $objp->code_buy_export;
+ $product_static->tva_tx = $objp->tva_tx_prod;
$facturefourn_static->ref = $objp->ref;
$facturefourn_static->id = $objp->facid;
$facturefourn_static->type = $objp->ftype;
$facturefourn_static->label = $objp->invoice_label;
+ $facturefourn_static_det->id = $objp->rowid;
+ $facturefourn_static_det->total_ht = $objp->total_ht;
+ $facturefourn_static_det->tva_tx_line = $objp->tva_tx_line;
+ $facturefourn_static_det->vat_src_code = $objp->vat_src_code;
+ $facturefourn_static_det->product_type = $objp->type_l;
+ $facturefourn_static_det->desc = $objp->description;
+
$code_buy_p_notset = '';
$code_buy_t_notset = '';
$objp->aarowid_suggest = ''; // Will be set later
- $isSellerInEEC = isInEEC($objp);
+ $accoutingAccountArray = array(
+ 'dom'=>$objp->aarowid,
+ 'intra'=>$objp->aarowid_intra,
+ 'export'=>$objp->aarowid_export,
+ 'thirdparty' =>$objp->aarowid_thirdparty);
- // Level 1: Search suggested default account for product/service
- $suggestedaccountingaccountbydefaultfor = '';
- if ($objp->type_l == 1) {
- if ($objp->country_code == $mysoc->country_code || empty($objp->country_code)) { // If buyer in same country than seller (if not defined, we assume it is same country)
- $objp->code_buy_l = (!empty($conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT : '');
- $suggestedaccountingaccountbydefaultfor = '';
- } else {
- if ($isSellerInEEC && $isBuyerInEEC) { // European intravat sale
- $objp->code_buy_l = (!empty($conf->global->ACCOUNTING_SERVICE_BUY_INTRA_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_BUY_INTRA_ACCOUNT : '');
- $suggestedaccountingaccountbydefaultfor = 'eec';
- } else { // Foreign sale
- $objp->code_buy_l = (!empty($conf->global->ACCOUNTING_SERVICE_BUY_EXPORT_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_BUY_EXPORT_ACCOUNT : '');
- $suggestedaccountingaccountbydefaultfor = 'export';
- }
- }
- } elseif ($objp->type_l == 0) {
- if ($objp->country_code == $mysoc->country_code || empty($objp->country_code)) { // If buyer in same country than seller (if not defined, we assume it is same country)
- $objp->code_buy_l = (!empty($conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT : '');
- $suggestedaccountingaccountbydefaultfor = '';
- } else {
- if ($isSellerInEEC && $isBuyerInEEC) { // European intravat sale
- $objp->code_buy_l = (!empty($conf->global->ACCOUNTING_PRODUCT_BUY_INTRA_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_BUY_INTRA_ACCOUNT : '');
- $suggestedaccountingaccountbydefaultfor = 'eec';
- } else {
- $objp->code_buy_l = (!empty($conf->global->ACCOUNTING_PRODUCT_BUY_EXPORT_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_BUY_EXPORT_ACCOUNT : '');
- $suggestedaccountingaccountbydefaultfor = 'export';
- }
- }
- }
- if ($objp->code_sell_l == -1) {
- $objp->code_sell_l = '';
- }
+ $code_buy_p_notset = '';
+ $code_buy_t_notset = '';
- // Level 2: Search suggested account for product/service (similar code exists in page index.php to make automatic binding)
- $suggestedaccountingaccountfor = '';
- if (($objp->country_code == $mysoc->country_code) || empty($objp->country_code)) { // If buyer in same country than seller (if not defined, we assume it is same country)
- $objp->code_buy_p = $objp->code_buy;
- $objp->aarowid_suggest = $objp->aarowid;
- $suggestedaccountingaccountfor = '';
+ $return=$accountingAccount->getAccountingCodeToBind($mysoc, $thirdpartystatic, $product_static, $facture_static, $facture_static_det, $accoutinAccountArray);
+ if (!is_array($return) && $return<0) {
+ setEventMessage($accountingAccount->error, 'errors');
} else {
- if ($isSellerInEEC && $isBuyerInEEC) { // European intravat sale
- $objp->code_buy_p = $objp->code_buy_intra;
- $objp->aarowid_suggest = $objp->aarowid_intra;
- $suggestedaccountingaccountfor = 'eec';
- } else { // Foreign sale
- $objp->code_buy_p = $objp->code_buy_export;
- $objp->aarowid_suggest = $objp->aarowid_export;
- $suggestedaccountingaccountfor = 'export';
- }
+ $suggestedid=$return['suggestedid'];
+ $suggestedaccountingaccountfor=$return['suggestedaccountingaccountfor'];
+ $suggestedaccountingaccountbydefaultfor=$return['suggestedaccountingaccountbydefaultfor'];
+ $code_buy_l=$return['code_buy_l'];
+ $code_buy_p=$return['code_buy_p'];
+ $code_buy_t=$return['code_buy_t'];
}
+ //var_dump($return);
- // Level 3: Search suggested account for this thirdparty (similar code exists in page index.php to make automatic binding)
- if (!empty($conf->global->ACCOUNTANCY_USE_PRODUCT_ACCOUNT_ON_THIRDPARTY)) {
- if (!empty($objp->company_code_buy)) {
- $objp->code_buy_t = $objp->company_code_buy;
- $objp->aarowid_suggest = $objp->aarowid_thirdparty;
- $suggestedaccountingaccountfor = '';
- }
- }
-
- if (!empty($objp->code_buy_p)) {
+ if (!empty($code_buy_p)) {
// Value was defined previously
} else {
$code_buy_p_notset = 'color:orange';
}
- if (empty($objp->code_buy_l) && empty($objp->code_buy_p)) {
+ if (empty($code_buy_l) && empty($code_buy_p)) {
$code_buy_p_notset = 'color:red';
}
- // $objp->code_buy_l is now default code of product/service
- // $objp->code_buy_p is now code of product/service
- // $objp->code_buy_t is now code of thirdparty
+ // $code_buy_l is now default code of product/service
+ // $code_buy_p is now code of product/service
+ // $code_buy_t is now code of thirdparty
print '';
// Line id
- print ''.$objp->rowid.' ';
+ print ''.$facturefourn_static_det->id.' ';
// Ref Invoice
print ''.$facturefourn_static->getNomUrl(1).' ';
@@ -654,23 +622,23 @@ if ($result) {
print '';
*/
- print ''.dol_print_date($db->jdate($objp->datef), 'day').' ';
+ print ''.dol_print_date($db->jdate($facturefourn_static_det->datef), 'day').' ';
// Ref Product
print '';
if ($product_static->id > 0) {
print $product_static->getNomUrl(1);
}
- if ($objp->product_label) {
- print ''.$objp->product_label.' ';
+ if ($product_static->product_label) {
+ print ''.$product_static->product_label.' ';
}
print ' ';
// Description
print '';
- $text = dolGetFirstLineOfText(dol_string_nohtmltag($objp->description));
+ $text = dolGetFirstLineOfText(dol_string_nohtmltag($facturefourn_static_det->desc));
$trunclength = empty($conf->global->ACCOUNTING_LENGTH_DESCRIPTION) ? 32 : $conf->global->ACCOUNTING_LENGTH_DESCRIPTION;
- print $form->textwithtooltip(dol_trunc($text, $trunclength), $objp->description);
+ print $form->textwithtooltip(dol_trunc($text, $trunclength), $facturefourn_static_det->desc);
print ' ';
print '';
@@ -678,11 +646,11 @@ if ($result) {
print ' ';
// Vat rate
- if ($objp->vat_tx_l != $objp->vat_tx_p) {
+ if ($product_static->vat_tx_l != $product_static->vat_tx_p) {
$code_vat_differ = 'font-weight:bold; text-decoration:blink; color:red';
}
print '';
- print vatrate($objp->tva_tx_line.($objp->vat_src_code ? ' ('.$objp->vat_src_code.')' : ''));
+ print vatrate($facturefourn_static_det->tva_tx_line.($facturefourn_static_det->vat_src_code ? ' ('.$facturefourn_static_det->vat_src_code.')' : ''));
print ' ';
// Thirdparty
@@ -699,26 +667,26 @@ if ($result) {
// Found accounts
print '';
- $s = '1. '.(($objp->type_l == 1) ? $langs->trans("DefaultForService") : $langs->trans("DefaultForProduct")).': ';
+ $s = '1. '.(($facturefourn_static_det->type_l == 1) ? $langs->trans("DefaultForService") : $langs->trans("DefaultForProduct")).': ';
$shelp = '';
if ($suggestedaccountingaccountbydefaultfor == 'eec') {
$shelp .= $langs->trans("SaleEEC");
} elseif ($suggestedaccountingaccountbydefaultfor == 'export') {
$shelp .= $langs->trans("SaleExport");
}
- $s .= ($objp->code_buy_l > 0 ? length_accountg($objp->code_buy_l) : ''.$langs->trans("NotDefined").' ');
+ $s .= ($code_buy_l > 0 ? length_accountg($code_buy_l) : ''.$langs->trans("NotDefined").' ');
print $form->textwithpicto($s, $shelp, 1, 'help', '', 0, 2, '', 1);
- if ($objp->product_id > 0) {
+ if ($product_static->id > 0) {
print ' ';
- $s = '2. '.(($objp->type_l == 1) ? $langs->trans("ThisService") : $langs->trans("ThisProduct")).': ';
- $shelp = '';
+ $s = '2. '.(($facturefourn_static_det->product_type == 1) ? $langs->trans("ThisService") : $langs->trans("ThisProduct")).': ';
+ $shelp = ''; $ttype = 'help';
if ($suggestedaccountingaccountfor == 'eec') {
$shelp = $langs->trans("SaleEEC");
} elseif ($suggestedaccountingaccountfor == 'export') {
$shelp = $langs->trans("SaleExport");
}
- $s .= (empty($objp->code_buy_p) ? ''.$langs->trans("NotDefined").' ' : length_accountg($objp->code_buy_p));
- print $form->textwithpicto($s, $shelp, 1, 'help', '', 0, 2, '', 1);
+ $s .= (empty($code_buy_p) ? ''.$langs->trans("NotDefined").' ' : length_accountg($code_buy_p));
+ print $form->textwithpicto($s, $shelp, 1, $ttype, '', 0, 2, '', 1);
} else {
print ' ';
$s = '2. '.(($objp->type_l == 1) ? $langs->trans("ThisService") : $langs->trans("ThisProduct")).': ';
@@ -728,35 +696,26 @@ if ($result) {
}
if (!empty($conf->global->ACCOUNTANCY_USE_PRODUCT_ACCOUNT_ON_THIRDPARTY)) {
print ' ';
- $s = '3. '.(($objp->type_l == 1) ? $langs->trans("ServiceForThisThirdparty") : $langs->trans("ProductForThisThirdparty")).': ';
+ $s = '3. '.(($facturefourn_static_det->product_type == 1) ? $langs->trans("ServiceForThisThirdparty") : $langs->trans("ProductForThisThirdparty")).': ';
$shelp = '';
- $s .= ($objp->code_buy_t > 0 ? length_accountg($objp->code_buy_t) : ''.$langs->trans("NotDefined").' ');
+ $s .= ($code_buy_t > 0 ? length_accountg($code_buy_t) : ''.$langs->trans("NotDefined").' ');
print $form->textwithpicto($s, $shelp, 1, 'help', '', 0, 2, '', 1);
}
print ' ';
// Suggested accounting account
print '';
- $suggestedid = $objp->aarowid_suggest;
- if (empty($suggestedid) && empty($objp->code_buy_p) && !empty($objp->code_buy_l) && empty($conf->global->ACCOUNTANCY_DO_NOT_AUTOFILL_ACCOUNT_WITH_GENERIC)) {
- if (empty($accountingaccount_codetotid_cache[$objp->code_buy_l])) {
- $tmpaccount = new AccountingAccount($db);
- $tmpaccount->fetch(0, $objp->code_buy_l, 1);
- if ($tmpaccount->id > 0) {
- $suggestedid = $tmpaccount->id;
- }
- $accountingaccount_codetotid_cache[$objp->code_buy_l] = $tmpaccount->id;
- } else {
- $suggestedid = $accountingaccount_codetotid_cache[$objp->code_buy_l];
- }
- }
- print $formaccounting->select_account($suggestedid, 'codeventil'.$objp->rowid, 1, array(), 0, 0, 'codeventil maxwidth200 maxwidthonsmartphone', 'cachewithshowemptyone');
+ print $formaccounting->select_account($suggestedid, 'codeventil'.$facturefourn_static_det->id, 1, array(), 0, 0, 'codeventil maxwidth200 maxwidthonsmartphone', 'cachewithshowemptyone');
print ' ';
// Column with checkbox
print '';
- $ischecked = $objp->aarowid_suggest;
- print ' ';
+ if (!empty($suggestedid)) {
+ $ischecked = 1;
+ } else {
+ $ischecked = 0;
+ }
+ print ' ';
print ' ';
print ' ';
From af8e8077b163eda70c4d0ca72a14d782a6590040 Mon Sep 17 00:00:00 2001
From: Alexandre SPANGARO
Date: Mon, 11 Oct 2021 12:50:16 +0200
Subject: [PATCH 031/341] Uniformize
---
htdocs/accountancy/customer/index.php | 19 +++++++++++++++----
htdocs/accountancy/customer/list.php | 9 ++++-----
2 files changed, 19 insertions(+), 9 deletions(-)
diff --git a/htdocs/accountancy/customer/index.php b/htdocs/accountancy/customer/index.php
index 7c3cc2cf0e2..795da583486 100644
--- a/htdocs/accountancy/customer/index.php
+++ b/htdocs/accountancy/customer/index.php
@@ -73,12 +73,23 @@ $action = GETPOST('action', 'aZ09');
$chartaccountcode = dol_getIdFromCode($db, $conf->global->CHARTOFACCOUNTS, 'accounting_system', 'rowid', 'pcg_version');
+// Security check
+if (empty($conf->accounting->enabled)) {
+ accessforbidden();
+}
+if ($user->socid > 0) {
+ accessforbidden();
+}
+if (empty($user->rights->accounting->mouvements->lire)) {
+ accessforbidden();
+}
+
/*
* Actions
*/
-if ($action == 'clean' || $action == 'validatehistory') {
+if (($action == 'clean' || $action == 'validatehistory') && $user->rights->accounting->bind->write) {
// Clean database
$db->begin();
$sql1 = "UPDATE ".MAIN_DB_PREFIX."facturedet as fd";
@@ -165,6 +176,7 @@ if ($action == 'validatehistory') {
}
dol_syslog('htdocs/accountancy/customer/index.php');
+
$result = $db->query($sql);
if (!$result) {
$error++;
@@ -209,7 +221,6 @@ if ($action == 'validatehistory') {
$product_static->accountancy_code_buy_intra = $objp->code_buy_intra;
$product_static->accountancy_code_buy_export = $objp->code_buy_export;
$product_static->tva_tx = $objp->tva_tx_prod;
- $product_static->tva_tx = $objp->tva_tx_prod;
$facture_static->ref = $objp->ref;
$facture_static->id = $objp->facid;
@@ -223,7 +234,7 @@ if ($action == 'validatehistory') {
$facture_static_det->product_type = $objp->type_l;
$facture_static_det->desc = $objp->description;
- $accoutinAccountArray = array(
+ $accoutingAccountArray = array(
'dom'=>$objp->aarowid,
'intra'=>$objp->aarowid_intra,
'export'=>$objp->aarowid_export,
@@ -232,7 +243,7 @@ if ($action == 'validatehistory') {
$code_sell_p_notset = '';
$code_sell_t_notset = '';
- $return=$accountingAccount->getAccountingCodeToBind($thirdpartystatic, $mysoc, $product_static, $facture_static, $facture_static_det, $accoutinAccountArray);
+ $return=$accountingAccount->getAccountingCodeToBind($thirdpartystatic, $mysoc, $product_static, $facture_static, $facture_static_det, $accoutingAccountArray);
if (!is_array($return) && $return<0) {
setEventMessage($accountingAccount->error, 'errors');
} else {
diff --git a/htdocs/accountancy/customer/list.php b/htdocs/accountancy/customer/list.php
index a730a8a9af6..88e6c52be3d 100644
--- a/htdocs/accountancy/customer/list.php
+++ b/htdocs/accountancy/customer/list.php
@@ -2,7 +2,7 @@
/* Copyright (C) 2013-2014 Olivier Geffroy
* Copyright (C) 2013-2021 Alexandre Spangaro
* Copyright (C) 2014-2015 Ari Elbaz (elarifr)
- * Copyright (C) 2013-2014 Florian Henry
+ * Copyright (C) 2013-2021 Florian Henry
* Copyright (C) 2014 Juanjo Menent
* Copyright (C) 2016 Laurent Destailleur
*
@@ -192,10 +192,10 @@ if ($massaction == 'ventil' && $user->rights->accounting->bind->write) {
dol_syslog("accountancy/customer/list.php", LOG_DEBUG);
if ($db->query($sql)) {
- $msg .= ''.$langs->trans("Lineofinvoice", $monId).' - '.$langs->trans("VentilatedinAccount").' : '.length_accountg($accountventilated->account_number).'
';
+ $msg .= ''.$langs->trans("Lineofinvoice").' '.$monId.' - '.$langs->trans("VentilatedinAccount").' : '.length_accountg($accountventilated->account_number).'
';
$ok++;
} else {
- $msg .= ''.$langs->trans("ErrorDB").' : '.$langs->trans("Lineofinvoice", $monId).' - '.$langs->trans("NotVentilatedinAccount").' : '.length_accountg($accountventilated->account_number).' '.$sql.' ';
+ $msg .= ''.$langs->trans("ErrorDB").' : '.$langs->trans("Lineofinvoice").' '.$monId.' - '.$langs->trans("NotVentilatedinAccount").' : '.length_accountg($accountventilated->account_number).' '.$sql.' ';
$ko++;
}
}
@@ -550,7 +550,6 @@ if ($result) {
$product_static->accountancy_code_buy_intra = $objp->code_buy_intra;
$product_static->accountancy_code_buy_export = $objp->code_buy_export;
$product_static->tva_tx = $objp->tva_tx_prod;
- $product_static->tva_tx = $objp->tva_tx_prod;
$facture_static->ref = $objp->ref;
$facture_static->id = $objp->facid;
@@ -564,7 +563,7 @@ if ($result) {
$facture_static_det->product_type = $objp->type_l;
$facture_static_det->desc = $objp->description;
- $accoutinAccountArray = array(
+ $accoutingAccountArray = array(
'dom'=>$objp->aarowid,
'intra'=>$objp->aarowid_intra,
'export'=>$objp->aarowid_export,
From 04091169dab12429e88430b9f2eb3cf0f8fd9e90 Mon Sep 17 00:00:00 2001
From: Alexandre SPANGARO
Date: Wed, 13 Oct 2021 02:48:42 +0200
Subject: [PATCH 032/341] Accountancy - Show message for admin if accountancy
hidden options are activated to help to resolve some problems
---
htdocs/accountancy/admin/index.php | 18 +++++++++++++++++-
1 file changed, 17 insertions(+), 1 deletion(-)
diff --git a/htdocs/accountancy/admin/index.php b/htdocs/accountancy/admin/index.php
index f8c0c95d3c1..4f4bff526c8 100644
--- a/htdocs/accountancy/admin/index.php
+++ b/htdocs/accountancy/admin/index.php
@@ -1,7 +1,7 @@
* Copyright (C) 2013-2014 Florian Henry
- * Copyright (C) 2013-2019 Alexandre Spangaro
+ * Copyright (C) 2013-2021 Alexandre Spangaro
* Copyright (C) 2014-2015 Ari Elbaz (elarifr)
* Copyright (C) 2014 Marcos García
* Copyright (C) 2014 Juanjo Menent
@@ -260,6 +260,22 @@ $linkback = '';
//$linkback = '' . $langs->trans("BackToModuleList") . ' ';
print load_fiche_titre($title, $linkback, 'accountancy');
+// Show message if accountancy hidden options are activated to help to resolve some problems
+if (!$user->admin) {
+ if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
+ print '' . $langs->trans("ConstantIsOn", "FACTURE_DEPOSITS_ARE_JUST_PAYMENTS") . '
';
+ }
+ if (!empty($conf->global->ACCOUNTANCY_USE_PRODUCT_ACCOUNT_ON_THIRDPARTY)) {
+ print '' . $langs->trans("ConstantIsOn", "ACCOUNTANCY_USE_PRODUCT_ACCOUNT_ON_THIRDPARTY") . '
';
+ }
+ if (!empty($conf->global->MAIN_COMPANY_PERENTITY_SHARED)) {
+ print '' . $langs->trans("ConstantIsOn", "MAIN_COMPANY_PERENTITY_SHARED") . '
';
+ }
+ if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) {
+ print '' . $langs->trans("ConstantIsOn", "MAIN_PRODUCT_PERENTITY_SHARED") . '
';
+ }
+}
+
print ' ';
// Address
print ''.$langs->trans("Address").' ';
- print '';
+ print '';
print ' ';
// Zip / Town
print ''.$langs->trans("Zip").' / '.$langs->trans("Town").' ';
- print $formcompany->select_ziptown((GETPOSTISSET('zipcode') ? GETPOST('zipcode', 'alphanohtml') : $object->zip), 'zipcode', array('town', 'selectcountry_id', 'state_id'), 6);
+ print $formcompany->select_ziptown((GETPOSTISSET('zipcode') ? GETPOST('zipcode', 'alphanohtml') : $soc->zip), 'zipcode', array('town', 'selectcountry_id', 'state_id'), 6);
print ' ';
- print $formcompany->select_ziptown((GETPOSTISSET('town') ? GETPOST('town', 'alphanohtml') : $object->town), 'town', array('zipcode', 'selectcountry_id', 'state_id'));
+ print $formcompany->select_ziptown((GETPOSTISSET('town') ? GETPOST('town', 'alphanohtml') : $soc->town), 'town', array('zipcode', 'selectcountry_id', 'state_id'));
print ' ';
// Country
$object->country_id = $object->country_id ? $object->country_id : $mysoc->country_id;
print ''.$langs->trans('Country').' ';
- print $form->select_country(GETPOSTISSET('country_id') ? GETPOST('country_id', 'alpha') : $object->country_id, 'country_id');
+ print $form->select_country(GETPOSTISSET('country_id') ? GETPOST('country_id', 'alpha') : $soc->country_id, 'country_id');
if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
print ' ';
// State
if (empty($conf->global->MEMBER_DISABLE_STATE)) {
print ''.$langs->trans('State').' ';
- if ($object->country_id) {
- print $formcompany->select_state(GETPOSTISSET('state_id') ? GETPOST('state_id', 'int') : $object->state_id, $object->country_code);
+ if ($soc->country_id) {
+ print $formcompany->select_state(GETPOSTISSET('state_id') ? GETPOST('state_id', 'int') : $soc->state_id, $soc->country_code);
} else {
print $countrynotdefined;
}
@@ -935,7 +935,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
// Pro phone
print ' '.$langs->trans("PhonePro").' ';
- print ''.img_picto('', 'object_phoning').' ';
+ print ''.img_picto('', 'object_phoning').' ';
// Personal phone
print ''.$langs->trans("PhonePerso").' ';
From ff7727466ad129070c0b56965eb0457f0ddf1795 Mon Sep 17 00:00:00 2001
From: atm-lena
Date: Thu, 14 Oct 2021 17:13:44 +0200
Subject: [PATCH 034/341] Function updateExtrafield : replace empty value to
null
---
htdocs/core/class/commonobject.class.php | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php
index 5a5e1a58928..50c6f1893ea 100644
--- a/htdocs/core/class/commonobject.class.php
+++ b/htdocs/core/class/commonobject.class.php
@@ -5492,7 +5492,6 @@ abstract class CommonObject
}
$sql .= ")";
-
$resql = $this->db->query($sql);
if (!$resql)
{
@@ -5792,7 +5791,7 @@ abstract class CommonObject
}
if ($linealreadyfound) {
- if ($this->array_options["options_".$key] === null) {
+ if ($this->array_options["options_".$key] === '') {
$sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element."_extrafields SET ".$key." = null";
} else {
$sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element."_extrafields SET ".$key." = '".$this->db->escape($this->array_options["options_".$key])."'";
From 316bc16634ffc8abb76bae5cb3b8c8e7af59a86d Mon Sep 17 00:00:00 2001
From: Henry
Date: Fri, 15 Oct 2021 15:05:13 +0800
Subject: [PATCH 035/341] Update card.php
---
htdocs/fourn/facture/card.php | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php
index 80f868f3484..8a148bbb666 100644
--- a/htdocs/fourn/facture/card.php
+++ b/htdocs/fourn/facture/card.php
@@ -2406,6 +2406,15 @@ if ($action == 'create') {
// $resteapayer=bcadd($resteapayer,$totalavoir,$conf->global->MAIN_MAX_DECIMALS_TOT);
$resteapayer = price2num($object->total_ttc - $totalpaye - $totalcreditnotes - $totaldeposits, 'MT');
+ // Multicurrency
+ if (!empty($conf->multicurrency->enabled)) {
+ $multicurrency_totalpaye = $object->getSommePaiement(1);
+ $multicurrency_totalcreditnotes = $object->getSumCreditNotesUsed(1);
+ $multicurrency_totaldeposits = $object->getSumDepositsUsed(1);
+ $multicurrency_resteapayer = price2num($object->multicurrency_total_ttc - $multicurrency_totalpaye - $multicurrency_totalcreditnotes - $multicurrency_totaldeposits, 'MT');
+ $resteapayer = price2num($multicurrency_resteapayer / $object->multicurrency_tx, 'MT');
+ }
+
if ($object->paye) {
$resteapayer = 0;
}
From 0cb19726740a7e78c7e3e8a34e81f37bf3acde86 Mon Sep 17 00:00:00 2001
From: Henry
Date: Fri, 15 Oct 2021 15:07:48 +0800
Subject: [PATCH 036/341] Update card.php
---
htdocs/compta/facture/card.php | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php
index 83c8ec8d718..5541725a480 100644
--- a/htdocs/compta/facture/card.php
+++ b/htdocs/compta/facture/card.php
@@ -3844,6 +3844,15 @@ if ($action == 'create') {
// $resteapayer=bcadd($object->total_ttc,$totalpaye,$conf->global->MAIN_MAX_DECIMALS_TOT);
// $resteapayer=bcadd($resteapayer,$totalavoir,$conf->global->MAIN_MAX_DECIMALS_TOT);
$resteapayer = price2num($object->total_ttc - $totalpaye - $totalcreditnotes - $totaldeposits, 'MT');
+
+ // Multicurrency
+ if (!empty($conf->multicurrency->enabled)) {
+ $multicurrency_totalpaye = $object->getSommePaiement(1);
+ $multicurrency_totalcreditnotes = $object->getSumCreditNotesUsed(1);
+ $multicurrency_totaldeposits = $object->getSumDepositsUsed(1);
+ $multicurrency_resteapayer = price2num($object->multicurrency_total_ttc - $multicurrency_totalpaye - $multicurrency_totalcreditnotes - $multicurrency_totaldeposits, 'MT');
+ $resteapayer = price2num($multicurrency_resteapayer / $object->multicurrency_tx, 'MT');
+ }
if ($object->paye) {
$resteapayer = 0;
From fb79aaeb0c2a4d187cc6aaa3c40430c975c125a2 Mon Sep 17 00:00:00 2001
From: stickler-ci
Date: Fri, 15 Oct 2021 07:19:49 +0000
Subject: [PATCH 037/341] Fixing style errors.
---
htdocs/compta/facture/card.php | 2 +-
htdocs/fourn/facture/card.php | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php
index 5541725a480..56e66b9f759 100644
--- a/htdocs/compta/facture/card.php
+++ b/htdocs/compta/facture/card.php
@@ -3844,7 +3844,7 @@ if ($action == 'create') {
// $resteapayer=bcadd($object->total_ttc,$totalpaye,$conf->global->MAIN_MAX_DECIMALS_TOT);
// $resteapayer=bcadd($resteapayer,$totalavoir,$conf->global->MAIN_MAX_DECIMALS_TOT);
$resteapayer = price2num($object->total_ttc - $totalpaye - $totalcreditnotes - $totaldeposits, 'MT');
-
+
// Multicurrency
if (!empty($conf->multicurrency->enabled)) {
$multicurrency_totalpaye = $object->getSommePaiement(1);
diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php
index 8a148bbb666..79a93cf3b0c 100644
--- a/htdocs/fourn/facture/card.php
+++ b/htdocs/fourn/facture/card.php
@@ -2414,7 +2414,7 @@ if ($action == 'create') {
$multicurrency_resteapayer = price2num($object->multicurrency_total_ttc - $multicurrency_totalpaye - $multicurrency_totalcreditnotes - $multicurrency_totaldeposits, 'MT');
$resteapayer = price2num($multicurrency_resteapayer / $object->multicurrency_tx, 'MT');
}
-
+
if ($object->paye) {
$resteapayer = 0;
}
From 0865916fe2c65db05c02926d38e3fec635fa662d Mon Sep 17 00:00:00 2001
From: Laurent Destailleur
Date: Fri, 15 Oct 2021 10:01:07 +0200
Subject: [PATCH 038/341] Init page for public subscription
---
htdocs/partnership/admin/website.php | 258 ++++++++
.../partnership/class/partnership.class.php | 4 +-
htdocs/partnership/lib/partnership.lib.php | 5 +
htdocs/public/partnership/index.php | 26 +
htdocs/public/partnership/new.php | 620 ++++++++++++++++++
htdocs/theme/eldy/btn.inc.php | 2 +-
6 files changed, 912 insertions(+), 3 deletions(-)
create mode 100644 htdocs/partnership/admin/website.php
create mode 100644 htdocs/public/partnership/index.php
create mode 100644 htdocs/public/partnership/new.php
diff --git a/htdocs/partnership/admin/website.php b/htdocs/partnership/admin/website.php
new file mode 100644
index 00000000000..96ebb4ba6e9
--- /dev/null
+++ b/htdocs/partnership/admin/website.php
@@ -0,0 +1,258 @@
+
+ * Copyright (C) 2006-2015 Laurent Destailleur
+ * Copyright (C) 2006-2012 Regis Houssin
+ * Copyright (C) 2011 Juanjo Menent
+ *
+ * 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
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+/**
+ * \file htdocs/partnership/admin/website.php
+ * \ingroup partnership
+ * \brief File of main public page for partnership module
+ */
+
+require '../../main.inc.php';
+require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
+require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
+require_once DOL_DOCUMENT_ROOT.'/core/lib/member.lib.php';
+require_once DOL_DOCUMENT_ROOT.'/partnership/lib/partnership.lib.php';
+require_once DOL_DOCUMENT_ROOT.'/partnership/class/partnership.class.php';
+
+// Load translation files required by the page
+$langs->loadLangs(array("admin", "partnership"));
+
+$action = GETPOST('action', 'aZ09');
+
+if (!$user->admin) {
+ accessforbidden();
+}
+
+$error = 0;
+
+
+/*
+ * Actions
+ */
+
+if ($action == 'setPARTNERSHIP_ENABLE_PUBLIC') {
+ if (GETPOST('value')) {
+ dolibarr_set_const($db, 'PARTNERSHIP_ENABLE_PUBLIC', 1, 'chaine', 0, '', $conf->entity);
+ } else {
+ dolibarr_set_const($db, 'PARTNERSHIP_ENABLE_PUBLIC', 0, 'chaine', 0, '', $conf->entity);
+ }
+}
+
+if ($action == 'update') {
+ $public = GETPOST('PARTNERSHIP_ENABLE_PUBLIC');
+
+ $res = dolibarr_set_const($db, "PARTNERSHIP_ENABLE_PUBLIC", $public, 'chaine', 0, '', $conf->entity);
+
+ if (!($res > 0)) {
+ $error++;
+ }
+
+ if (!$error) {
+ setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
+ } else {
+ setEventMessages($langs->trans("Error"), null, 'errors');
+ }
+}
+
+
+/*
+ * View
+ */
+
+$form = new Form($db);
+
+//$help_url = 'EN:Module_Partnership|FR:Module_Adhérents|ES:Módulo_Miembros';
+llxHeader('', $langs->trans("PartnershipsSetup"), $help_url);
+
+
+$linkback = ''.$langs->trans("BackToModuleList").' ';
+print load_fiche_titre($langs->trans("PartnershipsSetup"), $linkback, 'title_setup');
+
+$head = partnershipAdminPrepareHead();
+
+
+
+print '';
+
+
+if (!empty($conf->global->PARTNERSHIP_ENABLE_PUBLIC)) {
+ print ' ';
+ //print $langs->trans('FollowingLinksArePublic').' ';
+ print img_picto('', 'globe').' '.$langs->trans('BlankSubscriptionForm').' ';
+ if (!empty($conf->multicompany->enabled)) {
+ $entity_qr = '?entity='.$conf->entity;
+ } else {
+ $entity_qr = '';
+ }
+
+ // Define $urlwithroot
+ $urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root));
+ $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
+ //$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current
+
+ print '';
+ print ajax_autoselect('publicurlmember');
+}
+
+// End of page
+llxFooter();
+$db->close();
diff --git a/htdocs/partnership/class/partnership.class.php b/htdocs/partnership/class/partnership.class.php
index f40b771b34d..1e3d3cebab1 100644
--- a/htdocs/partnership/class/partnership.class.php
+++ b/htdocs/partnership/class/partnership.class.php
@@ -131,14 +131,14 @@ class Partnership extends CommonObject
*/
public $rowid;
- public $fk_soc;
+ public $fk_soc; // Link to thirdparty
+ public $fk_member; // Link to member
public $tms;
public $fk_user_creat;
public $fk_user_modif;
public $status;
- public $fk_member;
public $date_partnership_start;
public $date_partnership_end;
public $count_last_url_check_error;
diff --git a/htdocs/partnership/lib/partnership.lib.php b/htdocs/partnership/lib/partnership.lib.php
index 5305f86132e..23b5a2901fb 100644
--- a/htdocs/partnership/lib/partnership.lib.php
+++ b/htdocs/partnership/lib/partnership.lib.php
@@ -46,6 +46,11 @@ function partnershipAdminPrepareHead()
$head[$h][2] = 'partnership_extrafields';
$h++;
+ $head[$h][0] = dol_buildpath("/partnership/admin/website.php", 1);
+ $head[$h][1] = $langs->trans("BlankSubscriptionForm");
+ $head[$h][2] = 'website';
+ $h++;
+
/*
$head[$h][0] = dol_buildpath("/partnership/admin/about.php", 1);
$head[$h][1] = $langs->trans("About");
diff --git a/htdocs/public/partnership/index.php b/htdocs/public/partnership/index.php
new file mode 100644
index 00000000000..6a9a6f8a557
--- /dev/null
+++ b/htdocs/public/partnership/index.php
@@ -0,0 +1,26 @@
+
+ *
+ * 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
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+/**
+ * \file htdocs/public/partnership/index.php
+ * \ingroup core
+ * \brief A redirect page to an error
+ */
+
+require '../../master.inc.php';
+
+header("Location: ".DOL_URL_ROOT.'/public/error-404.php');
diff --git a/htdocs/public/partnership/new.php b/htdocs/public/partnership/new.php
new file mode 100644
index 00000000000..a46488ab5f9
--- /dev/null
+++ b/htdocs/public/partnership/new.php
@@ -0,0 +1,620 @@
+
+ * Copyright (C) 2001-2002 Jean-Louis Bergamo
+ * Copyright (C) 2006-2013 Laurent Destailleur
+ * Copyright (C) 2012 Regis Houssin
+ * Copyright (C) 2012 J. Fernando Lagrange
+ * Copyright (C) 2018-2019 Frédéric France
+ * Copyright (C) 2018 Alexandre Spangaro
+ * Copyright (C) 2021 Waël Almoman
+ *
+ * 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
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+/**
+ * \file htdocs/public/partnership/new.php
+ * \ingroup member
+ * \brief Example of form to add a new member
+ */
+
+if (!defined('NOLOGIN')) {
+ define("NOLOGIN", 1); // This means this output page does not require to be logged.
+}
+if (!defined('NOCSRFCHECK')) {
+ define("NOCSRFCHECK", 1); // We accept to go on this page from external web site.
+}
+if (!defined('NOIPCHECK')) {
+ define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip
+}
+if (!defined('NOBROWSERNOTIF')) {
+ define('NOBROWSERNOTIF', '1');
+}
+if (!defined('NOIPCHECK')) {
+ define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip
+}
+
+// For MultiCompany module.
+// Do not use GETPOST here, function is not defined and define must be done before including main.inc.php
+// TODO This should be useless. Because entity must be retrieve from object ref and not from url.
+$entity = (!empty($_GET['entity']) ? (int) $_GET['entity'] : (!empty($_POST['entity']) ? (int) $_POST['entity'] : 1));
+if (is_numeric($entity)) {
+ define("DOLENTITY", $entity);
+}
+
+require '../../main.inc.php';
+require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
+require_once DOL_DOCUMENT_ROOT.'/partnership/class/partnership.class.php';
+require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
+require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
+
+// Init vars
+$errmsg = '';
+$num = 0;
+$error = 0;
+$backtopage = GETPOST('backtopage', 'alpha');
+$action = GETPOST('action', 'aZ09');
+
+// Load translation files
+$langs->loadLangs(array("main", "members", "companies", "install", "other"));
+
+// Security check
+if (empty($conf->partnership->enabled)) {
+ accessforbidden('', 0, 0, 1);
+}
+
+if (empty($conf->global->PARTNERSHIP_ENABLE_PUBLIC)) {
+ print $langs->trans("Auto subscription form for public visitors has not been enabled");
+ exit;
+}
+
+// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
+$hookmanager->initHooks(array('publicnewpartnershipcard', 'globalcard'));
+
+$extrafields = new ExtraFields($db);
+
+$object = new Partnership($db);
+
+$user->loadDefaultValues();
+
+
+/**
+ * Show header for new partnership
+ *
+ * @param string $title Title
+ * @param string $head Head array
+ * @param int $disablejs More content into html header
+ * @param int $disablehead More content into html header
+ * @param array $arrayofjs Array of complementary js files
+ * @param array $arrayofcss Array of complementary css files
+ * @return void
+ */
+function llxHeaderVierge($title, $head = "", $disablejs = 0, $disablehead = 0, $arrayofjs = '', $arrayofcss = '')
+{
+ global $user, $conf, $langs, $mysoc;
+
+ top_htmlhead($head, $title, $disablejs, $disablehead, $arrayofjs, $arrayofcss); // Show html headers
+
+ print '';
+
+ // Define urllogo
+ $urllogo = DOL_URL_ROOT.'/theme/common/login_logo.png';
+
+ if (!empty($mysoc->logo_small) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_small)) {
+ $urllogo = DOL_URL_ROOT.'/viewimage.php?cache=1&modulepart=mycompany&file='.urlencode('logos/thumbs/'.$mysoc->logo_small);
+ } elseif (!empty($mysoc->logo) && is_readable($conf->mycompany->dir_output.'/logos/'.$mysoc->logo)) {
+ $urllogo = DOL_URL_ROOT.'/viewimage.php?cache=1&modulepart=mycompany&file='.urlencode('logos/'.$mysoc->logo);
+ } elseif (is_readable(DOL_DOCUMENT_ROOT.'/theme/dolibarr_logo.svg')) {
+ $urllogo = DOL_URL_ROOT.'/theme/dolibarr_logo.svg';
+ }
+
+ print '';
+
+ // Output html code for logo
+ if ($urllogo) {
+ print '
';
+ print '
';
+ print '
';
+ print '
';
+ if (empty($conf->global->MAIN_HIDE_POWERED_BY)) {
+ print '
';
+ }
+ print '
';
+ }
+
+ if (!empty($conf->global->PARTNERSHIP_IMAGE_PUBLIC_REGISTRATION)) {
+ print '
';
+ print '
';
+ print '
';
+ }
+
+ print '
';
+
+ print '';
+}
+
+/**
+ * Show footer for new member
+ *
+ * @return void
+ */
+function llxFooterVierge()
+{
+ print '
';
+
+ printCommonFooter('public');
+
+ print "\n";
+ print "