Debug modBlockedLog module

This commit is contained in:
Laurent Destailleur 2017-10-24 15:22:46 +02:00
parent 78133244f8
commit 7b661685cc
6 changed files with 28 additions and 15 deletions

View File

@ -155,10 +155,16 @@ class BlockedLog
*/ */
public function setObjectData(&$object) { public function setObjectData(&$object) {
if($object->element=='payment') { // Set date
if ($object->element=='payment')
{
$this->date_object = $object->datepaye; $this->date_object = $object->datepaye;
} }
else{ if ($object->element=='payment_salary')
{
$this->date_object = $object->datev;
}
else {
$this->date_object = $object->date; $this->date_object = $object->date;
} }
@ -168,7 +174,8 @@ class BlockedLog
$this->object_data=new stdClass(); $this->object_data=new stdClass();
if($this->element === 'facture') { if ($this->element === 'facture')
{
if(empty($object->thirdparty))$object->fetch_thirdparty(); if(empty($object->thirdparty))$object->fetch_thirdparty();
$this->object_data->thirdparty = new stdClass(); $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_localtax1= (double) $object->total_localtax1;
$this->object_data->total_localtax2= (double) $object->total_localtax2; $this->object_data->total_localtax2= (double) $object->total_localtax2;
$this->object_data->note_public = (double) $object->note_public; $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; $this->object_data->amounts = $object->amounts;
} }
elseif($this->element === 'payment_salary')
{
$this->object_data->amounts = array($object->amount);
}
} }
/** /**

View File

@ -386,7 +386,7 @@ class Account extends CommonObject
* Add an entry into table ".MAIN_DB_PREFIX."bank * Add an entry into table ".MAIN_DB_PREFIX."bank
* *
* @param int $date Date operation * @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 string $label Descripton
* @param float $amount Amount * @param float $amount Amount
* @param string $num_chq Numero cheque ou virement * @param string $num_chq Numero cheque ou virement

View File

@ -73,6 +73,8 @@ if ($action == 'add' && $_POST["cancel"] <> $langs->trans("Cancel"))
$dateep=dol_mktime(12,0,0, $_POST["dateepmonth"], $_POST["dateepday"], $_POST["dateepyear"]); $dateep=dol_mktime(12,0,0, $_POST["dateepmonth"], $_POST["dateepday"], $_POST["dateepyear"]);
if (empty($datev)) $datev=$datep; 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->accountid=GETPOST("accountid") > 0 ? GETPOST("accountid","int") : 0;
$object->fk_user=GETPOST("fk_user") > 0 ? GETPOST("fk_user","int") : 0; $object->fk_user=GETPOST("fk_user") > 0 ? GETPOST("fk_user","int") : 0;
$object->datev=$datev; $object->datev=$datev;
@ -82,7 +84,7 @@ if ($action == 'add' && $_POST["cancel"] <> $langs->trans("Cancel"))
$object->datesp=$datesp; $object->datesp=$datesp;
$object->dateep=$dateep; $object->dateep=$dateep;
$object->note=GETPOST("note"); $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->num_payment=GETPOST("num_payment");
$object->fk_user_author=$user->id; $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'); setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Employee")), null, 'errors');
$error++; $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'); setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("PaymentMode")), null, 'errors');
$error++; $error++;
@ -292,7 +294,7 @@ if ($action == 'create')
// Type payment // Type payment
print '<tr><td>'; print '<tr><td>';
print fieldLabel('PaymentMode','selectpaymenttype',1).'</td><td>'; print fieldLabel('PaymentMode','selectpaymenttype',1).'</td><td>';
$form->select_types_paiements(GETPOST("paymenttype"), "paymenttype"); $form->select_types_paiements(GETPOST("paymenttype"), "paymenttype", '', 2);
print '</td></tr>'; print '</td></tr>';
// Number // Number

View File

@ -349,7 +349,7 @@ class PaymentSalary extends CommonObject
$sql.= ", '".$this->db->idate($this->datev)."'"; $sql.= ", '".$this->db->idate($this->datev)."'";
$sql.= ", ".$this->amount; $sql.= ", ".$this->amount;
$sql.= ", ".($this->salary > 0 ? $this->salary : "null"); $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)."'"; $sql.= ", '".$this->db->escape($this->num_payment)."'";
if ($this->note) $sql.= ", '".$this->db->escape($this->note)."'"; if ($this->note) $sql.= ", '".$this->db->escape($this->note)."'";
$sql.= ", '".$this->db->escape($this->label)."'"; $sql.= ", '".$this->db->escape($this->label)."'";

View File

@ -114,7 +114,7 @@ $sql.= " AND s.entity = ".$conf->entity;
// Search criteria // Search criteria
if ($search_ref) $sql.=" AND s.rowid=".$search_ref; 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_label) $sql.=natural_search(array('s.label'), $search_label);
if ($search_amount) $sql.=natural_search("s.amount", $search_amount, 1); if ($search_amount) $sql.=natural_search("s.amount", $search_amount, 1);
if ($search_account > 0) $sql .=" AND b.fk_account=".$search_account; if ($search_account > 0) $sql .=" AND b.fk_account=".$search_account;

View File

@ -48,6 +48,8 @@ class InterfaceActionsBlockedLog extends DolibarrTriggers
{ {
if (empty($conf->blockedlog->enabled)) return 0; // Module not active, we do nothing 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' 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') {
$amounts= (double) $object->total_ttc; $amounts= (double) $object->total_ttc;
@ -72,7 +74,7 @@ class InterfaceActionsBlockedLog extends DolibarrTriggers
$b=new BlockedLog($this->db); $b=new BlockedLog($this->db);
$b->action = $action; $b->action = $action;
$b->amounts= $amounts; $b->amounts= $amounts;
$b->setObjectData($object); $b->setObjectData($object); // Set field ref_object, fk_object, element, object_data
$res = $b->create($user); $res = $b->create($user);