From 7b661685cc20134011f21beab4cf16cb57fd103f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 24 Oct 2017 15:22:46 +0200 Subject: [PATCH] Debug modBlockedLog module --- htdocs/blockedlog/class/blockedlog.class.php | 25 +++++++++++++------ htdocs/compta/bank/class/account.class.php | 2 +- htdocs/compta/salaries/card.php | 8 +++--- .../salaries/class/paymentsalary.class.php | 2 +- htdocs/compta/salaries/index.php | 2 +- ..._modBlockedlog_ActionsBlockedLog.class.php | 4 ++- 6 files changed, 28 insertions(+), 15 deletions(-) diff --git a/htdocs/blockedlog/class/blockedlog.class.php b/htdocs/blockedlog/class/blockedlog.class.php index 4bce16fb796..0fefb5baf00 100644 --- a/htdocs/blockedlog/class/blockedlog.class.php +++ b/htdocs/blockedlog/class/blockedlog.class.php @@ -155,10 +155,16 @@ class BlockedLog */ public function setObjectData(&$object) { - if($object->element=='payment') { + // Set date + if ($object->element=='payment') + { $this->date_object = $object->datepaye; } - else{ + if ($object->element=='payment_salary') + { + $this->date_object = $object->datev; + } + else { $this->date_object = $object->date; } @@ -168,7 +174,8 @@ class BlockedLog $this->object_data=new stdClass(); - if($this->element === 'facture') { + if ($this->element === 'facture') + { if(empty($object->thirdparty))$object->fetch_thirdparty(); $this->object_data->thirdparty = new stdClass(); @@ -182,14 +189,16 @@ class BlockedLog $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'){ - + elseif($this->element === 'payment') + { $this->object_data->amounts = $object->amounts; - } + elseif($this->element === 'payment_salary') + { + $this->object_data->amounts = array($object->amount); + } + } /** diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php index 8ad1ccd2ecf..824b3f50f26 100644 --- a/htdocs/compta/bank/class/account.class.php +++ b/htdocs/compta/bank/class/account.class.php @@ -386,7 +386,7 @@ class Account extends CommonObject * Add an entry into table ".MAIN_DB_PREFIX."bank * * @param int $date Date operation - * @param string $oper 1,2,3,4... (deprecated) or TYP,VIR,PRE,LIQ,VAD,CB,CHQ... + * @param string $oper 1,2,3,4... (deprecated) or 'TYP','VIR','PRE','LIQ','VAD','CB','CHQ'... * @param string $label Descripton * @param float $amount Amount * @param string $num_chq Numero cheque ou virement diff --git a/htdocs/compta/salaries/card.php b/htdocs/compta/salaries/card.php index 47d4c027185..a456777f631 100644 --- a/htdocs/compta/salaries/card.php +++ b/htdocs/compta/salaries/card.php @@ -73,6 +73,8 @@ if ($action == 'add' && $_POST["cancel"] <> $langs->trans("Cancel")) $dateep=dol_mktime(12,0,0, $_POST["dateepmonth"], $_POST["dateepday"], $_POST["dateepyear"]); if (empty($datev)) $datev=$datep; + $type_payment = dol_getIdFromCode($db, GETPOST("paymenttype", 'alpha'), 'c_paiement'); + $object->accountid=GETPOST("accountid") > 0 ? GETPOST("accountid","int") : 0; $object->fk_user=GETPOST("fk_user") > 0 ? GETPOST("fk_user","int") : 0; $object->datev=$datev; @@ -82,7 +84,7 @@ if ($action == 'add' && $_POST["cancel"] <> $langs->trans("Cancel")) $object->datesp=$datesp; $object->dateep=$dateep; $object->note=GETPOST("note"); - $object->type_payment=GETPOST("paymenttype") > 0 ? GETPOST("paymenttype", "int") : 0; + $object->type_payment=($type_payment > 0 ? $type_payment : 0); $object->num_payment=GETPOST("num_payment"); $object->fk_user_author=$user->id; @@ -101,7 +103,7 @@ if ($action == 'add' && $_POST["cancel"] <> $langs->trans("Cancel")) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Employee")), null, 'errors'); $error++; } - if (empty($object->type_payment) || $object->type_payment < 0) + if (empty($type_payment) || $type_payment < 0) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("PaymentMode")), null, 'errors'); $error++; @@ -292,7 +294,7 @@ if ($action == 'create') // Type payment print ''; print fieldLabel('PaymentMode','selectpaymenttype',1).''; - $form->select_types_paiements(GETPOST("paymenttype"), "paymenttype"); + $form->select_types_paiements(GETPOST("paymenttype"), "paymenttype", '', 2); print ''; // Number diff --git a/htdocs/compta/salaries/class/paymentsalary.class.php b/htdocs/compta/salaries/class/paymentsalary.class.php index 7fbbaf43d48..57d2d94f1a3 100644 --- a/htdocs/compta/salaries/class/paymentsalary.class.php +++ b/htdocs/compta/salaries/class/paymentsalary.class.php @@ -349,7 +349,7 @@ class PaymentSalary extends CommonObject $sql.= ", '".$this->db->idate($this->datev)."'"; $sql.= ", ".$this->amount; $sql.= ", ".($this->salary > 0 ? $this->salary : "null"); - $sql.= ", '".$this->db->escape($this->type_payment)."'"; + $sql.= ", ".$this->db->escape($this->type_payment); $sql.= ", '".$this->db->escape($this->num_payment)."'"; if ($this->note) $sql.= ", '".$this->db->escape($this->note)."'"; $sql.= ", '".$this->db->escape($this->label)."'"; diff --git a/htdocs/compta/salaries/index.php b/htdocs/compta/salaries/index.php index 6928d3e38f6..2da142aff15 100644 --- a/htdocs/compta/salaries/index.php +++ b/htdocs/compta/salaries/index.php @@ -114,7 +114,7 @@ $sql.= " AND s.entity = ".$conf->entity; // Search criteria if ($search_ref) $sql.=" AND s.rowid=".$search_ref; -if ($search_user) $sql.=natural_search(array('u.login', 'u.lastname', 'u.firstname', 'u.email', 'u.note'), $search_user); +if ($search_user) $sql.=natural_search(array('u.login', 'u.lastname', 'u.firstname', 'u.email'), $search_user); if ($search_label) $sql.=natural_search(array('s.label'), $search_label); if ($search_amount) $sql.=natural_search("s.amount", $search_amount, 1); if ($search_account > 0) $sql .=" AND b.fk_account=".$search_account; diff --git a/htdocs/core/triggers/interface_50_modBlockedlog_ActionsBlockedLog.class.php b/htdocs/core/triggers/interface_50_modBlockedlog_ActionsBlockedLog.class.php index 39dae7c209e..635a4649902 100644 --- a/htdocs/core/triggers/interface_50_modBlockedlog_ActionsBlockedLog.class.php +++ b/htdocs/core/triggers/interface_50_modBlockedlog_ActionsBlockedLog.class.php @@ -48,6 +48,8 @@ class InterfaceActionsBlockedLog extends DolibarrTriggers { if (empty($conf->blockedlog->enabled)) return 0; // Module not active, we do nothing + dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); + if($action==='BILL_VALIDATE' || $action === 'BILL_PAYED' || $action==='BILL_UNPAYED' || $action === 'BILL_SENTBYMAIL' || $action === 'DOC_DOWNLOAD' || $action === 'DOC_PREVIEW') { $amounts= (double) $object->total_ttc; @@ -72,7 +74,7 @@ class InterfaceActionsBlockedLog extends DolibarrTriggers $b=new BlockedLog($this->db); $b->action = $action; $b->amounts= $amounts; - $b->setObjectData($object); + $b->setObjectData($object); // Set field ref_object, fk_object, element, object_data $res = $b->create($user);