Debug blockedlog with various payments

This commit is contained in:
Laurent Destailleur 2018-01-29 18:22:26 +01:00
parent 8ae25b3c65
commit 4eb7d7a332
7 changed files with 92 additions and 44 deletions

View File

@ -453,24 +453,36 @@ if (is_array($blocks))
if (empty($search_showonlyerrors) || ! $checkresult[$block->id])
{
print '<tr class="oddeven">';
// ID
print '<td>'.$block->id.'</td>';
// Date
print '<td>'.dol_print_date($block->date_creation,'dayhour').'</td>';
// User
print '<td>';
//print $block->getUser()
print $block->user_fullname;
print '</td>';
// Action
print '<td>'.$langs->trans('log'.$block->action).'</td>';
// Ref
print '<td class="nowrap">'.$block->ref_object.'</td>';
// Link to source object
print '<td>'.$object_link.'</td>';
// Amount
print '<td align="right">'.price($block->amounts).'</td>';
// Details link
print '<td align="center"><a href="#" data-blockid="'.$block->id.'" rel="show-info">'.img_info($langs->trans('ShowDetails')).'</a></td>';
// Fingerprint
print '<td>';
print $form->textwithpicto(dol_trunc($block->signature, '12'), $block->signature, 1, 'help', '', 0, 2, 'fingerprint');
print '</td>';

View File

@ -149,11 +149,10 @@ class BlockedLog
if ($conf->adherent->enabled) $this->trackedevents['MEMBER_SUBSCRIPTION_MODIFY']='logMEMBER_SUBSCRIPTION_MODIFY';
if ($conf->adherent->enabled) $this->trackedevents['MEMBER_SUBSCRIPTION_DELETE']='logMEMBER_SUBSCRIPTION_DELETE';
/*
$trackedevents['PAYMENT_VARIOUS_CREATE']='BlockedLogVariousPaymentCreate';
$trackedevents['PAYMENT_VARIOUS_MODIFY']='BlockedLogVariousPaymentModify';
$trackedevents['PAYMENT_VARIOUS_DELETE']='BlockedLogVariousPaymentDelete';
*/
if ($conf->banque->enabled) $this->trackedevents['PAYMENT_VARIOUS_CREATE']='logBlockedLogVariousPaymentCreate';
if ($conf->banque->enabled) $this->trackedevents['PAYMENT_VARIOUS_MODIFY']='logBlockedLogVariousPaymentModify';
if ($conf->banque->enabled) $this->trackedevents['PAYMENT_VARIOUS_DELETE']='logBlockedLogVariousPaymentDelete';
}
/**
@ -218,6 +217,17 @@ class BlockedLog
$this->error++;
}
}
else if($this->element === 'payment_various') {
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/paymentvarious.class.php';
$object = new PaymentVarious($this->db);
if ($object->fetch($this->fk_object)>0) {
return $object->getNomUrl(1);
}
else{
$this->error++;
}
}
else if($this->element === 'don' || $this->element === 'donation') {
require_once DOL_DOCUMENT_ROOT.'/don/class/don.class.php';
@ -299,7 +309,7 @@ class BlockedLog
{
$this->date_object = $object->datev;
}
elseif ($object->element == 'payment_donation')
elseif ($object->element == 'payment_donation' || $object->element == 'payment_various')
{
$this->date_object = $object->datepaid?$object->datepaid:$object->datep;
}
@ -401,21 +411,26 @@ class BlockedLog
if (! empty($object->newref)) $this->object_data->ref = $object->newref;
}
elseif ($this->element == 'payment' || $this->element == 'payment_supplier' || $this->element == 'payment_donation')
elseif ($this->element == 'payment' || $this->element == 'payment_supplier' || $this->element == 'payment_donation' || $this->element == 'payment_various')
{
$datepayment = $object->datepaye?$object->datepaye:($object->datepaid?$object->datepaid:$object->datep);
$paymenttypeid = $object->paiementid?$object->paiementid:$object->paymenttype;
$paymenttypeid = $object->paiementid?$object->paiementid:($object->paymenttype?$object->paymenttype:$object->type_payment);
$this->object_data->ref = $object->ref;
$this->object_data->date = $datepayment;
$this->object_data->type_code = dol_getIdFromCode($this->db, $paymenttypeid, 'c_paiement', 'id', 'code');
$this->object_data->payment_num = $object->num_paiement;
$this->object_data->payment_num = ($object->num_paiement?$object->num_paiement:$object->num_payment);
//$this->object_data->fk_account = $object->fk_account;
$this->object_data->note = $object->note;
//var_dump($this->object_data);exit;
$totalamount=0;
if (! is_array($object->amounts) && $object->amount)
{
$object->amounts=array($object->id => $object->amount);
}
$paymentpartnumber=0;
foreach($object->amounts as $objid => $amount)
{
@ -439,26 +454,41 @@ class BlockedLog
include_once DOL_DOCUMENT_ROOT.'/don/class/don.class.php';
$tmpobject = new Don($this->db);
}
elseif ($this->element == 'payment_various')
{
include_once DOL_DOCUMENT_ROOT.'/compta/bank/class/paymentvarious.class.php';
$tmpobject = new PaymentVarious($this->db);
}
if (! is_object($tmpobject))
{
continue;
}
$result = $tmpobject->fetch($objid);
if ($result <= 0)
{
$this->error = $tmpobject->error;
$this->errors = $tmpobject->errors;
dol_syslog("Failed to fetch object with id ".$objid, LOG_ERR);
return -1;
}
$paymentpart = new stdClass();
$paymentpart->amount = $amount;
if ($this->element != 'payment_donation')
if (! in_array($this->element, array('payment_donation', 'payment_various')))
{
$result = $tmpobject->fetch_thirdparty();
if ($result <= 0)
if ($result == 0)
{
$this->error='Failed to fetch thirdparty for object with id '.$tmpobject->id;
$this->errors[] = $this->error;
dol_syslog("Failed to fetch thirdparty for object with id ".$tmpobject->id, LOG_ERR);
return -1;
}
elseif ($result < 0)
{
$this->error = $tmpobject->error;
$this->errors = $tmpobject->errors;
@ -481,21 +511,25 @@ class BlockedLog
if ($this->element == 'payment_donation') $paymentpart->donation = new stdClass();
else $paymentpart->invoice = new stdClass();
foreach($tmpobject as $key=>$value)
if ($this->element != 'payment_various')
{
if (in_array($key, array('fields'))) 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
if (!is_object($value))
foreach($tmpobject as $key=>$value)
{
if ($this->element == 'payment_donation') $paymentpart->donation->{$key} = $value;
else $paymentpart->invoice->{$key} = $value;
if (in_array($key, array('fields'))) 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
if (!is_object($value))
{
if ($this->element == 'payment_donation') $paymentpart->donation->{$key} = $value;
elseif ($this->element == 'payment_various') $paymentpart->various->{$key} = $value;
else $paymentpart->invoice->{$key} = $value;
}
}
}
$paymentpartnumber++;
$this->object_data->payment_part[$paymentpartnumber] = $paymentpart;
$paymentpartnumber++; // first payment will be 1
$this->object_data->payment_part[$paymentpartnumber] = $paymentpart;
}
}
$this->object_data->amount = $totalamount;

View File

@ -34,6 +34,8 @@ class PaymentVarious extends CommonObject
public $table_element='payment_various'; //!< Name of table without prefix where object is stored
public $picto = 'bill';
var $id;
var $ref;
var $tms;
var $datep;
var $datev;
@ -87,8 +89,7 @@ class PaymentVarious extends CommonObject
// Update request
$sql = "UPDATE ".MAIN_DB_PREFIX."payment_various SET";
$sql.= " tms='".$this->db->idate($this->tms)."',";
if ($this->tms) $sql.= " tms='".$this->db->idate($this->tms)."',";
$sql.= " datep='".$this->db->idate($this->datep)."',";
$sql.= " datev='".$this->db->idate($this->datev)."',";
$sql.= " sens=".$this->sens.",";
@ -102,7 +103,6 @@ class PaymentVarious extends CommonObject
$sql.= " fk_bank=".($this->fk_bank > 0 ? $this->fk_bank:"null").",";
$sql.= " fk_user_author=".$this->fk_user_author.",";
$sql.= " fk_user_modif=".$this->fk_user_modif;
$sql.= " WHERE rowid=".$this->id;
dol_syslog(get_class($this)."::update", LOG_DEBUG);
@ -146,7 +146,6 @@ class PaymentVarious extends CommonObject
global $langs;
$sql = "SELECT";
$sql.= " v.rowid,";
$sql.= " v.tms,";
$sql.= " v.datep,";
$sql.= " v.datev,";
@ -164,7 +163,6 @@ class PaymentVarious extends CommonObject
$sql.= " b.fk_account,";
$sql.= " b.fk_type,";
$sql.= " b.rappro";
$sql.= " FROM ".MAIN_DB_PREFIX."payment_various as v";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON v.fk_bank = b.rowid";
$sql.= " WHERE v.rowid = ".$id;
@ -184,7 +182,7 @@ class PaymentVarious extends CommonObject
$this->datev = $this->db->jdate($obj->datev);
$this->sens = $obj->sens;
$this->amount = $obj->amount;
$this->type_payement = $obj->fk_typepayment;
$this->type_payment = $obj->fk_typepayment;
$this->num_payment = $obj->num_payment;
$this->label = $obj->label;
$this->note = $obj->note;
@ -350,6 +348,7 @@ class PaymentVarious extends CommonObject
if ($result)
{
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."payment_various");
$this->ref = $this->id;
if ($this->id > 0)
{

View File

@ -49,7 +49,7 @@ $sens=GETPOST("sens","int");
$amount=GETPOST("amount");
$paymenttype=GETPOST("paymenttype");
$accountancy_code=GETPOST("accountancy_code","int");
$projectid = (GETPOST('projectid') ? GETPOST('projectid', 'int') : 0);
$projectid = (GETPOST('projectid','int') ? GETPOST('projectid', 'int') : GETPOST('fk_project','int'));
// Security check
$socid = GETPOST("socid","int");
@ -96,22 +96,23 @@ if (empty($reshook))
{
$error=0;
$datep=dol_mktime(12,0,0, GETPOST("datepmonth"), GETPOST("datepday"), GETPOST("datepyear"));
$datev=dol_mktime(12,0,0, GETPOST("datevmonth"), GETPOST("datevday"), GETPOST("datevyear"));
$datep=dol_mktime(12,0,0, GETPOST("datepmonth",'int'), GETPOST("datepday",'int'), GETPOST("datepyear",'int'));
$datev=dol_mktime(12,0,0, GETPOST("datevmonth",'int'), GETPOST("datevday",'int'), GETPOST("datevyear",'int'));
if (empty($datev)) $datev=$datep;
$object->accountid=GETPOST("accountid") > 0 ? GETPOST("accountid","int") : 0;
$object->ref=''; // TODO
$object->accountid=GETPOST("accountid",'int') > 0 ? GETPOST("accountid","int") : 0;
$object->datev=$datev;
$object->datep=$datep;
$object->amount=price2num(GETPOST("amount"));
$object->label=GETPOST("label");
$object->note=GETPOST("note");
$object->type_payment=GETPOST("paymenttype") > 0 ? GETPOST("paymenttype", "int") : 0;
$object->num_payment=GETPOST("num_payment");
$object->amount=price2num(GETPOST("amount",'alpha'));
$object->label=GETPOST("label",'none');
$object->note=GETPOST("note",'none');
$object->type_payment=GETPOST("paymenttype",'int') > 0 ? GETPOST("paymenttype", "int") : 0;
$object->num_payment=GETPOST("num_payment",'alpha');
$object->fk_user_author=$user->id;
$object->accountancy_code=GETPOST("accountancy_code") > 0 ? GETPOST("accountancy_code","int") : "";
$object->sens=GETPOST('sens');
$object->fk_project= GETPOST('fk_project');
$object->fk_project= GETPOST('fk_project','int');
if (empty($datep) || empty($datev))
{
@ -411,7 +412,7 @@ if ($id)
print '<table class="border" width="100%">';
// Label
print '<tr><td>'.$langs->trans("Label").'</td><td>'.$object->label.'</td></tr>';
print '<tr><td class="titlefield">'.$langs->trans("Label").'</td><td>'.$object->label.'</td></tr>';
// Payment date
print "<tr>";

View File

@ -47,7 +47,7 @@ class FormProjets
* Output a combo list with projects qualified for a third party / user
*
* @param int $socid Id third party (-1=all, 0=only projects not linked to a third party, id=projects not linked or linked to third party id)
* @param int $selected Id project preselected
* @param string $selected Id project preselected ('' or id of project)
* @param string $htmlname Name of HTML field
* @param int $maxlength Maximum length of label
* @param int $option_only Return only html options lines without the select tag

View File

@ -51,7 +51,7 @@ class InterfaceActionsBlockedLog extends DolibarrTriggers
if (empty($conf->blockedlog->enabled)) return 0; // Module not active, we do nothing
// Test if event/record is qualified
$listofqualifiedelement = array('facture', 'don', 'payment', 'payment_donation', 'subscription');
$listofqualifiedelement = array('facture', 'don', 'payment', 'payment_donation', 'subscription','payment_various');
if (! in_array($object->element, $listofqualifiedelement)) return 1;
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
@ -120,9 +120,10 @@ class InterfaceActionsBlockedLog extends DolibarrTriggers
$res = $b->create($user);
if ($res<0)
if ($res < 0)
{
setEventMessages($b->error, $b->errors, 'errors');
$this->error = $b->error;
$this->errors = $b->errors;
return -1;
}
else

View File

@ -14,6 +14,7 @@ OkCheckFingerprintValidityButChainIsKo=Archived log seems valid compared to prev
AddedByAuthority=Stored into remote authority
NotAddedByAuthorityYet=Not yet stored into remote authority
ShowDetails=Show stored details
logPAYMENT_VARIOUS_CREATE=Payment (not assigned to invoice)
logPAYMENT_ADD_TO_BANK=Payment added to bank
logPAYMENT_CUSTOMER_CREATE=Customer payment created
logPAYMENT_CUSTOMER_DELETE=Customer payment logical deletion
@ -41,7 +42,7 @@ DownloadLogCSV=Export archived logs (CSV)
logDOC_PREVIEW=Preview of a validated document in order to print or download
logDOC_DOWNLOAD=Download of a validated document in order to print or send
DataOfArchivedEvent=Full datas of archived event
ImpossibleToReloadObject=Object (type %s, id %s) removed (see 'Full data' link for unerasable saved data)
ImpossibleToReloadObject=Original object (type %s, id %s) not linked (see 'Full datas' column to get unalterable saved data)
BlockedLogAreRequiredByYourCountryLegislation=Unalterable Logs module may be required by the legislation of your country. Disabling this module may render any future transactions invalid with respect to the law and the use of legal software as they can not be validated by a tax audit.
BlockedLogActivatedBecauseRequiredByYourCountryLegislation=Unalterable Logs module was activated because of the legislation of your country. Disabling this module may render any future transactions invalid with respect to the law and the use of legal software as they can not be validated by a tax audit.
BlockedLogDisableNotAllowedForCountry=List of countries where usage of this module is mandatory (just to prevent to disable the module by error, if your country is in this list, disable of module is not possible without editing this list first. Note also that enabling/disabling this module will keep a track into the unalterable log).