From 08e83983d0466fc7573eb6deaaac5e31942a3369 Mon Sep 17 00:00:00 2001 From: atm-ph Date: Thu, 26 Oct 2017 09:40:12 +0200 Subject: [PATCH 1/7] Fix empty extrafields if from origin --- htdocs/contrat/card.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php index d618a7c4b1e..14571949467 100644 --- a/htdocs/contrat/card.php +++ b/htdocs/contrat/card.php @@ -333,6 +333,15 @@ if (empty($reshook)) $desc = dol_htmlentitiesbr($lines[$i]->desc); } + // Extrafields + $array_options = array(); + if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && method_exists($lines[$i], 'fetch_optionals')) // For avoid conflicts if + // trigger used + { + $lines[$i]->fetch_optionals($lines[$i]->rowid); + $array_options = $lines[$i]->array_options; + } + $txtva = $lines[$i]->vat_src_code ? $lines[$i]->tva_tx . ' (' . $lines[$i]->vat_src_code . ')' : $lines[$i]->tva_tx; // View third's localtaxes for now @@ -355,7 +364,7 @@ if (empty($reshook)) $lines[$i]->info_bits, $lines[$i]->fk_fournprice, $lines[$i]->pa_ht, - array(), + $array_options, $lines[$i]->fk_unit ); From 1d0c93c0b6dcf2dcbafe4a17d7b8d7e675ed35cc Mon Sep 17 00:00:00 2001 From: florian HENRY Date: Thu, 26 Oct 2017 10:31:14 +0200 Subject: [PATCH 2/7] FIX : #7458 --- htdocs/blockedlog/class/blockedlog.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/blockedlog/class/blockedlog.class.php b/htdocs/blockedlog/class/blockedlog.class.php index 8a1508b7a04..b2178bcb039 100644 --- a/htdocs/blockedlog/class/blockedlog.class.php +++ b/htdocs/blockedlog/class/blockedlog.class.php @@ -153,7 +153,7 @@ class BlockedLog */ public function setObjectData(&$object) { - if($object->element=='payment') { + if($object->element=='payment' || $object->element=='payment_supplier') { $this->date_object = $object->datepaye; } else{ From 9427b2f4b1569c02dccf3612dc0d744f415d3543 Mon Sep 17 00:00:00 2001 From: florian HENRY Date: Thu, 26 Oct 2017 10:40:36 +0200 Subject: [PATCH 3/7] fix supplier payamnet blockedlog --- htdocs/blockedlog/class/blockedlog.class.php | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/htdocs/blockedlog/class/blockedlog.class.php b/htdocs/blockedlog/class/blockedlog.class.php index b2178bcb039..47de8669dd5 100644 --- a/htdocs/blockedlog/class/blockedlog.class.php +++ b/htdocs/blockedlog/class/blockedlog.class.php @@ -119,6 +119,17 @@ class BlockedLog $this->error++; } } + else if($this->element === 'payment_supplier') { + require_once DOL_DOCUMENT_ROOT.'/fourn/class/paiementfourn.class.php'; + + $object = new PaiementFourn($this->db); + if($object->fetch($this->fk_object)>0) { + return $object->getNomUrl(1); + } + else{ + $this->error++; + } + } return $langs->trans('ImpossibleToReloadObject', $this->element, $this->fk_object); @@ -511,6 +522,15 @@ class BlockedLog $this->amounts = (double) $obj->amount; } } + if($this->element === 'payment_supplier') { + $sql="SELECT amount FROM ".MAIN_DB_PREFIX."paiementfourn WHERE rowid=".$this->fk_object; + + $res = $this->db->query($sql); + + if($res && $obj = $this->db->fetch_object($res)) { + $this->amounts = (double) $obj->amount; + } + } elseif($this->element === 'facture') { $sql="SELECT total_ttc FROM ".MAIN_DB_PREFIX."facture WHERE rowid=".$this->fk_object; From 5f89b4427f05baa6163e71f2744795591e6da59f Mon Sep 17 00:00:00 2001 From: florian HENRY Date: Thu, 26 Oct 2017 10:49:11 +0200 Subject: [PATCH 4/7] fixagain blocked log supplier --- htdocs/blockedlog/class/blockedlog.class.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/htdocs/blockedlog/class/blockedlog.class.php b/htdocs/blockedlog/class/blockedlog.class.php index 47de8669dd5..4e959c84b20 100644 --- a/htdocs/blockedlog/class/blockedlog.class.php +++ b/htdocs/blockedlog/class/blockedlog.class.php @@ -194,13 +194,11 @@ class BlockedLog $this->object_data->note_private= (double) $object->note_private; } - elseif($this->element==='payment'){ + elseif($this->element==='payment'|| $object->element=='payment_supplier'){ $this->object_data->amounts = $object->amounts; } - - } /** From a7655b69e87bb6fe0b62552b8ed74db49175b9aa Mon Sep 17 00:00:00 2001 From: florian HENRY Date: Thu, 26 Oct 2017 12:13:47 +0200 Subject: [PATCH 5/7] agin fix blockedlog on supplier incvoive payument --- htdocs/blockedlog/class/blockedlog.class.php | 28 +++++++++++++++++++ ..._modBlockedlog_ActionsBlockedLog.class.php | 3 +- 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/htdocs/blockedlog/class/blockedlog.class.php b/htdocs/blockedlog/class/blockedlog.class.php index 4e959c84b20..2ad4582634f 100644 --- a/htdocs/blockedlog/class/blockedlog.class.php +++ b/htdocs/blockedlog/class/blockedlog.class.php @@ -108,6 +108,17 @@ class BlockedLog $this->error++; } } + if($this->element === 'invoice_supplier') { + require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; + + $object = new FactureFournisseur($this->db); + if($object->fetch($this->fk_object)>0) { + return $object->getNomUrl(1); + } + else{ + $this->error++; + } + } else if($this->element === 'payment') { require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php'; @@ -193,6 +204,23 @@ class BlockedLog $this->object_data->note_public = (double) $object->note_public; $this->object_data->note_private= (double) $object->note_private; + } + if($this->element === 'invoice_supplier') { + if(empty($object->thirdparty))$object->fetch_thirdparty(); + $this->object_data->thirdparty = new stdClass(); + + foreach($object->thirdparty as $key=>$value) { + if(!is_object($value)) $this->object_data->thirdparty->{$key} = $value; + } + + $this->object_data->total_ht = (double) $object->total_ht; + $this->object_data->total_tva = (double) $object->total_tva; + $this->object_data->total_ttc = (double) $object->total_ttc; + $this->object_data->total_localtax1= (double) $object->total_localtax1; + $this->object_data->total_localtax2= (double) $object->total_localtax2; + $this->object_data->note_public = (double) $object->note_public; + $this->object_data->note_private= (double) $object->note_private; + } elseif($this->element==='payment'|| $object->element=='payment_supplier'){ diff --git a/htdocs/core/triggers/interface_50_modBlockedlog_ActionsBlockedLog.class.php b/htdocs/core/triggers/interface_50_modBlockedlog_ActionsBlockedLog.class.php index 39dae7c209e..367912a72ec 100644 --- a/htdocs/core/triggers/interface_50_modBlockedlog_ActionsBlockedLog.class.php +++ b/htdocs/core/triggers/interface_50_modBlockedlog_ActionsBlockedLog.class.php @@ -49,7 +49,8 @@ class InterfaceActionsBlockedLog extends DolibarrTriggers if (empty($conf->blockedlog->enabled)) return 0; // Module not active, we do nothing if($action==='BILL_VALIDATE' || $action === 'BILL_PAYED' || $action==='BILL_UNPAYED' - || $action === 'BILL_SENTBYMAIL' || $action === 'DOC_DOWNLOAD' || $action === 'DOC_PREVIEW') { + || $action === 'BILL_SENTBYMAIL' || $action === 'DOC_DOWNLOAD' || $action === 'DOC_PREVIEW' + || $action === 'BILL_SUPPLIER_PAYED') { $amounts= (double) $object->total_ttc; } else if($action === 'PAYMENT_CUSTOMER_CREATE' || $action === 'PAYMENT_ADD_TO_BANK') { From f4a95f89ac323775998dce0c349f622cfe44cf03 Mon Sep 17 00:00:00 2001 From: florian HENRY Date: Thu, 26 Oct 2017 12:26:25 +0200 Subject: [PATCH 6/7] Ok, now suppliers payment are correctly logged --- .../interface_50_modBlockedlog_ActionsBlockedLog.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/triggers/interface_50_modBlockedlog_ActionsBlockedLog.class.php b/htdocs/core/triggers/interface_50_modBlockedlog_ActionsBlockedLog.class.php index 367912a72ec..fbd9469b391 100644 --- a/htdocs/core/triggers/interface_50_modBlockedlog_ActionsBlockedLog.class.php +++ b/htdocs/core/triggers/interface_50_modBlockedlog_ActionsBlockedLog.class.php @@ -53,7 +53,7 @@ class InterfaceActionsBlockedLog extends DolibarrTriggers || $action === 'BILL_SUPPLIER_PAYED') { $amounts= (double) $object->total_ttc; } - else if($action === 'PAYMENT_CUSTOMER_CREATE' || $action === 'PAYMENT_ADD_TO_BANK') { + else if($action === 'PAYMENT_CUSTOMER_CREATE' || $action === 'PAYMENT_ADD_TO_BANK' || $action === 'PAYMENT_SUPPLIER_CREATE') { $amounts = 0; if(!empty($object->amounts)) { foreach($object->amounts as $amount) { From 82231b77a246722e33bcb63f59a62d6871ab187c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 27 Oct 2017 01:46:54 +0200 Subject: [PATCH 7/7] Fix data for supplier must be not visible if supplier module off --- htdocs/margin/tabs/thirdpartyMargins.php | 2 +- htdocs/societe/card.php | 11 +++++++---- htdocs/societe/notify/card.php | 2 +- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/htdocs/margin/tabs/thirdpartyMargins.php b/htdocs/margin/tabs/thirdpartyMargins.php index bc8928bdc6e..c0ec385cff6 100644 --- a/htdocs/margin/tabs/thirdpartyMargins.php +++ b/htdocs/margin/tabs/thirdpartyMargins.php @@ -109,7 +109,7 @@ if ($socid > 0) print ''; } - if ($object->fournisseur) + if (! empty($conf->fournisseur->enabled) && $object->fournisseur && ! empty($user->rights->fournisseur->lire)) { print ''; print $langs->trans('SupplierCode').''; diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index 876300aef28..4807591b9f3 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -2021,10 +2021,13 @@ else print $object->getLibCustProspStatut(); print ''; - // Prospect/Customer - print ''.$langs->trans('Supplier').''; - print yn($object->fournisseur); - print ''; + // Supplier + if (! empty($conf->fournisseur->enabled)) + { + print ''.$langs->trans('Supplier').''; + print yn($object->fournisseur); + print ''; + } // Prefix if (! empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field diff --git a/htdocs/societe/notify/card.php b/htdocs/societe/notify/card.php index 697ae315fb3..5733ffa9568 100644 --- a/htdocs/societe/notify/card.php +++ b/htdocs/societe/notify/card.php @@ -180,7 +180,7 @@ if ($result > 0) print ''; } - if ($object->fournisseur) + if (! empty($conf->fournisseur->enabled) && $object->fournisseur && ! empty($user->rights->fournisseur->lire)) { print ''; print $langs->trans('SupplierCode').'';