From 17e012e0ace7d912ec421fc197f4a8ef7a4974fc Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 5 Mar 2018 17:07:59 +0100 Subject: [PATCH] FIX Subscription not correctly log in blockedlog --- htdocs/blockedlog/admin/blockedlog_list.php | 4 +- htdocs/blockedlog/ajax/block-info.php | 2 +- htdocs/blockedlog/class/blockedlog.class.php | 54 ++++++++++++++++--- ..._modBlockedlog_ActionsBlockedLog.class.php | 6 ++- 4 files changed, 54 insertions(+), 12 deletions(-) diff --git a/htdocs/blockedlog/admin/blockedlog_list.php b/htdocs/blockedlog/admin/blockedlog_list.php index d508d1edceb..9410ef9be5e 100644 --- a/htdocs/blockedlog/admin/blockedlog_list.php +++ b/htdocs/blockedlog/admin/blockedlog_list.php @@ -474,7 +474,7 @@ if (is_array($blocks)) print ''.$block->ref_object.''; // Link to source object - print ''.$object_link.''; + print ''.$object_link.''; // Amount print ''.price($block->amounts).''; @@ -501,7 +501,7 @@ if (is_array($blocks)) print ''; - // Status note + // Note print ''; if (! $checkresult[$block->id] || ($loweridinerror && $block->id >= $loweridinerror)) // If error { diff --git a/htdocs/blockedlog/ajax/block-info.php b/htdocs/blockedlog/ajax/block-info.php index c8a9cbf70be..a092b13ca99 100644 --- a/htdocs/blockedlog/ajax/block-info.php +++ b/htdocs/blockedlog/ajax/block-info.php @@ -87,7 +87,7 @@ function formatObject($objtoshow, $prefix) { $s.=''.($prefix?$prefix.' > ':'').$key.''; $s.=''; - if (in_array($key, array('date','datef'))) + if (in_array($key, array('date','datef','dateh','datec','datem','datep'))) { $s.=dol_print_date($val, 'dayhour'); } diff --git a/htdocs/blockedlog/class/blockedlog.class.php b/htdocs/blockedlog/class/blockedlog.class.php index 3dc3ade52e5..13a2840e360 100644 --- a/htdocs/blockedlog/class/blockedlog.class.php +++ b/htdocs/blockedlog/class/blockedlog.class.php @@ -239,6 +239,17 @@ class BlockedLog $this->error++; } } + else if($this->element === 'subscription') { + require_once DOL_DOCUMENT_ROOT.'/adherents/class/subscription.class.php'; + + $object = new Subscription($this->db); + if ($object->fetch($this->fk_object)>0) { + return $object->getNomUrl(1); + } + else{ + $this->error++; + } + } else if ($this->action == 'MODULE_SET') { return 'System to track events into unalterable logs were enabled'; @@ -313,6 +324,10 @@ class BlockedLog { $this->date_object = $object->datepaid?$object->datepaid:$object->datep; } + elseif ($object->element=='subscription') + { + $this->date_object = $object->dateh; + } else { $this->date_object = $object->date; } @@ -323,7 +338,10 @@ class BlockedLog // id of object $this->fk_object = $object->id; + + // Set object_data $this->object_data=new stdClass(); + $arrayoffieldstoexclude = array('table_element','fields','ref_previous','ref_next','origin','origin_id','oldcopy','picto','error','modelpdf','table_element_line','linkedObjectsIds','linkedObjects','fk_delivery_address'); // Add thirdparty info if (empty($object->thirdparty) && method_exists($object, 'fetch_thirdparty')) $object->fetch_thirdparty(); @@ -333,7 +351,7 @@ class BlockedLog foreach($object->thirdparty as $key=>$value) { - if (in_array($key, array('fields'))) continue; // Discard some properties + if (in_array($key, $arrayoffieldstoexclude)) continue; // Discard some properties if (! in_array($key, array( 'name','name_alias','ref_ext','address','zip','town','state_code','country_code','idprof1','idprof2','idprof3','idprof4','idprof5','idprof6','phone','fax','email','barcode', 'tva_intra', 'localtax1_assuj', 'localtax1_value', 'localtax2_assuj', 'localtax2_value', 'managers', 'capital', 'typent_code', 'forme_juridique_code', 'code_client', 'code_fournisseur' @@ -349,7 +367,7 @@ class BlockedLog foreach($mysoc as $key=>$value) { - if (in_array($key, array('fields'))) continue; // Discard some properties + if (in_array($key, $arrayoffieldstoexclude)) continue; // Discard some properties if (! in_array($key, array( 'name','name_alias','ref_ext','address','zip','town','state_code','country_code','idprof1','idprof2','idprof3','idprof4','idprof5','idprof6','phone','fax','email','barcode', 'tva_intra', 'localtax1_assuj', 'localtax1_value', 'localtax2_assuj', 'localtax2_value', 'managers', 'capital', 'typent_code', 'forme_juridique_code', 'code_client', 'code_fournisseur' @@ -366,12 +384,11 @@ class BlockedLog } // Field specific to object - if ($this->element == 'facture') { foreach($object as $key=>$value) { - if (in_array($key, array('fields'))) continue; // Discard some properties + if (in_array($key, $arrayoffieldstoexclude)) continue; // Discard some properties if (! in_array($key, array( 'ref','facnumber','ref_client','ref_supplier','date','datef','type','total_ht','total_tva','total_ttc','localtax1','localtax2','revenuestamp','datepointoftax','note_public','lines' ))) continue; // Discard if not into a dedicated list @@ -402,7 +419,7 @@ class BlockedLog { foreach($object as $key=>$value) { - if (in_array($key, array('fields'))) continue; // Discard some properties + if (in_array($key, $arrayoffieldstoexclude)) continue; // Discard some properties if (! in_array($key, array( 'ref','facnumber','ref_client','ref_supplier','date','datef','type','total_ht','total_tva','total_ttc','localtax1','localtax2','revenuestamp','datepointoftax','note_public' ))) continue; // Discard if not into a dedicated list @@ -498,7 +515,7 @@ class BlockedLog $paymentpart->thirdparty = new stdClass(); foreach($tmpobject->thirdparty as $key=>$value) { - if (in_array($key, array('fields'))) continue; // Discard some properties + if (in_array($key, $arrayoffieldstoexclude)) continue; // Discard some properties if (! in_array($key, array( 'name','name_alias','ref_ext','address','zip','town','state_code','country_code','idprof1','idprof2','idprof3','idprof4','idprof5','idprof6','phone','fax','email','barcode', 'tva_intra', 'localtax1_assuj', 'localtax1_value', 'localtax2_assuj', 'localtax2_value', 'managers', 'capital', 'typent_code', 'forme_juridique_code', 'code_client', 'code_fournisseur' @@ -515,7 +532,7 @@ class BlockedLog { foreach($tmpobject as $key=>$value) { - if (in_array($key, array('fields'))) continue; // Discard some properties + if (in_array($key, $arrayoffieldstoexclude)) continue; // Discard some properties if (! in_array($key, array( 'ref','facnumber','ref_client','ref_supplier','date','datef','type','total_ht','total_tva','total_ttc','localtax1','localtax2','revenuestamp','datepointoftax','note_public' ))) continue; // Discard if not into a dedicated list @@ -542,6 +559,29 @@ class BlockedLog if (! empty($object->newref)) $this->object_data->ref = $object->newref; } + elseif($this->element == 'subscription') + { + foreach($object as $key=>$value) + { + if (in_array($key, $arrayoffieldstoexclude)) continue; // Discard some properties + if (! in_array($key, array( + 'id','datec','dateh','datef','fk_adherent','amount','import_key','statut','note' + ))) continue; // Discard if not into a dedicated list + if (!is_object($value)) $this->object_data->{$key} = $value; + } + + if (! empty($object->newref)) $this->object_data->ref = $object->newref; + } + else // Generic case + { + foreach($object as $key=>$value) + { + if (in_array($key, $arrayoffieldstoexclude)) continue; // Discard some properties + if (!is_object($value)) $this->object_data->{$key} = $value; + } + + if (! empty($object->newref)) $this->object_data->ref = $object->newref; + } return 1; } diff --git a/htdocs/core/triggers/interface_50_modBlockedlog_ActionsBlockedLog.class.php b/htdocs/core/triggers/interface_50_modBlockedlog_ActionsBlockedLog.class.php index ec0b0cb6941..f97d1400018 100644 --- a/htdocs/core/triggers/interface_50_modBlockedlog_ActionsBlockedLog.class.php +++ b/htdocs/core/triggers/interface_50_modBlockedlog_ActionsBlockedLog.class.php @@ -69,14 +69,16 @@ class InterfaceActionsBlockedLog extends DolibarrTriggers $amounts = 0; if ($action==='BILL_VALIDATE' || $action==='BILL_DELETE' || $action === 'BILL_SENTBYMAIL' || $action==='BILL_SUPPLIER_VALIDATE' || $action==='BILL_SUPPLIER_DELETE' || $action === 'BILL_SUPPLIER_SENTBYMAIL' - || $action==='MEMBER_SUBCRIPTION_CREATE' || $action==='MEMBER_SUBCRIPTION_MODIFY' || $action==='MEMBER_SUBCRIPTION_DELETE' + || $action==='MEMBER_SUBSCRIPTION_CREATE' || $action==='MEMBER_SUBSCRIPTION_MODIFY' || $action==='MEMBER_SUBSCRIPTION_DELETE' || $action==='DON_VALIDATE' || $action==='DON_MODIFY' || $action==='DON_DELETE' || (in_array($object->element, array('facture','suplier_invoice')) && $action === 'DOC_DOWNLOAD') || (in_array($object->element, array('facture','suplier_invoice')) && $action === 'DOC_PREVIEW') ) { $qualified++; - if ($action==='DON_VALIDATE') $amounts = (double) $object->amount; + if (in_array($action, array( + 'MEMBER_SUBSCRIPTION_CREATE','MEMBER_SUBSCRIPTION_MODIFY','MEMBER_SUBSCRIPTION_DELETE', + 'DON_VALIDATE','DON_MODIFY','DON_DELETE'))) $amounts = (double) $object->amount; else $amounts = (double) $object->total_ttc; } /*if ($action === 'BILL_PAYED' || $action==='BILL_UNPAYED'