Debug blockedlog for loi finance 2016

This commit is contained in:
Laurent Destailleur 2018-01-05 04:31:48 +01:00
parent 1e438b7ebd
commit dbf7603118
11 changed files with 330 additions and 181 deletions

View File

@ -1303,11 +1303,6 @@ class Adherent extends CommonObject
$this->last_subscription_amount=$montant;
$this->last_subscription_date_start=$date;
$this->last_subscription_date_end=$datefin;
// Call trigger
$result=$this->call_trigger('MEMBER_SUBSCRIPTION',$user);
if ($result < 0) { $error++; }
// End call triggers
}
if (! $error)

View File

@ -59,13 +59,16 @@ class Subscription extends CommonObject
/**
* Function who permitted cretaion of the subscription
*
* @param int $userid userid de celui qui insere
* @return int <0 if KO, Id subscription created if OK
* @param User $user User that create
* @param bool $notrigger false=launch triggers after, true=disable triggers
* @return int <0 if KO, Id subscription created if OK
*/
function create($userid)
function create($user, $notrigger = false)
{
global $langs;
$error = 0;
$now=dol_now();
// Check parameters
@ -75,6 +78,8 @@ class Subscription extends CommonObject
return -1;
}
$this->db->begin();
$sql = "INSERT INTO ".MAIN_DB_PREFIX."subscription (fk_adherent, datec, dateadh, datef, subscription, note)";
$sql.= " VALUES (".$this->fk_adherent.", '".$this->db->idate($now)."',";
$sql.= " '".$this->db->idate($this->dateh)."',";
@ -82,17 +87,32 @@ class Subscription extends CommonObject
$sql.= " ".$this->amount.",";
$sql.= " '".$this->db->escape($this->note)."')";
dol_syslog(get_class($this)."::create", LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql)
{
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."subscription");
return $this->id;
if ($res===false) {
$error++;
$this->errors[] = $this->db->lasterror();
}
else
if (! $error)
{
$this->error=$this->db->lasterror();
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX . $this->table_element);
}
if (! $error && ! $notrigger)
{
// Call triggers
$result=$this->call_trigger('MEMBER_SUBSCRIPTION_CREATE',$user);
if ($result < 0) { $error++; }
// End call triggers
}
// Commit or rollback
if ($error) {
$this->db->rollback();
return -1;
} else {
$this->db->commit();
return $this->id;
}
}
@ -154,8 +174,10 @@ class Subscription extends CommonObject
* @param int $notrigger 0=Disable triggers
* @return int <0 if KO, >0 if OK
*/
function update($user,$notrigger=0)
function update($user, $notrigger=0)
{
$error = 0;
$this->db->begin();
$sql = "UPDATE ".MAIN_DB_PREFIX."subscription SET ";
@ -177,14 +199,26 @@ class Subscription extends CommonObject
$result=$member->fetch($this->fk_adherent);
$result=$member->update_end_date($user);
$this->db->commit();
return 1;
if (! $error && ! $notrigger) {
// Call triggers
$result=$this->call_trigger('MEMBER_SUBSCRIPTION_MODIFY',$user);
if ($result < 0) { $error++; } //Do also here what you must do to rollback action if trigger fail
// End call triggers
}
}
else
{
$this->db->rollback();
$error++;
$this->error=$this->db->lasterror();
}
// Commit or rollback
if ($error) {
$this->db->rollback();
return -1;
} else {
$this->db->commit();
return $this->id;
}
}
@ -192,10 +226,13 @@ class Subscription extends CommonObject
* Delete a subscription
*
* @param User $user User that delete
* @param bool $notrigger false=launch triggers after, true=disable triggers
* @return int <0 if KO, 0 if not found, >0 if OK
*/
function delete($user)
function delete($user, $notrigger=false)
{
$error = 0;
// It subscription is linked to a bank transaction, we get it
if ($this->fk_bank > 0)
{
@ -206,51 +243,71 @@ class Subscription extends CommonObject
$this->db->begin();
$sql = "DELETE FROM ".MAIN_DB_PREFIX."subscription WHERE rowid = ".$this->id;
dol_syslog(get_class($this)."::delete", LOG_DEBUG);
$resql=$this->db->query($sql);
if ($resql)
{
$num=$this->db->affected_rows($resql);
if ($num)
{
require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
$member=new Adherent($this->db);
$result=$member->fetch($this->fk_adherent);
$result=$member->update_end_date($user);
if (! $error) {
if (! $notrigger) {
// Call triggers
$result=$this->call_trigger('MEMBER_SUBSCRIPTION_DELETE', $user);
if ($result < 0) { $error++; } // Do also here what you must do to rollback action if trigger fail
// End call triggers
}
}
if ($this->fk_bank > 0 && is_object($accountline) && $accountline->id > 0) // If we found bank account line (this means this->fk_bank defined)
if (! $error)
{
$sql = "DELETE FROM ".MAIN_DB_PREFIX."subscription WHERE rowid = ".$this->id;
dol_syslog(get_class($this)."::delete", LOG_DEBUG);
$resql=$this->db->query($sql);
if ($resql)
{
$num=$this->db->affected_rows($resql);
if ($num)
{
$result=$accountline->delete($user); // Return false if refused because line is conciliated
if ($result > 0)
require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
$member=new Adherent($this->db);
$result=$member->fetch($this->fk_adherent);
$result=$member->update_end_date($user);
if ($this->fk_bank > 0 && is_object($accountline) && $accountline->id > 0) // If we found bank account line (this means this->fk_bank defined)
{
$this->db->commit();
return 1;
$result=$accountline->delete($user); // Return false if refused because line is conciliated
if ($result > 0)
{
$this->db->commit();
return 1;
}
else
{
$this->error=$accountline->error;
$this->db->rollback();
return -1;
}
}
else
{
$this->error=$accountline->error;
$this->db->rollback();
return -1;
$this->db->commit();
return 1;
}
}
else
{
$this->db->commit();
return 1;
return 0;
}
}
else
{
$this->db->commit();
return 0;
$error++;
$this->error=$this->db->lasterror();
}
}
else
{
$this->error=$this->db->lasterror();
// Commit or rollback
if ($error) {
$this->db->rollback();
return -1;
} else {
$this->db->commit();
return 1;
}
}

View File

@ -26,9 +26,7 @@ require_once DOL_DOCUMENT_ROOT.'/blockedlog/lib/blockedlog.lib.php';
require_once DOL_DOCUMENT_ROOT.'/blockedlog/class/blockedlog.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
$langs->load("admin");
$langs->load("other");
$langs->load("blockedlog");
$langs->loadLangs(array("admin","other","blockedlog"));
if (! $user->admin || empty($conf->blockedlog->enabled)) accessforbidden();
@ -143,7 +141,7 @@ if ($resql)
{
while ($obj = $db->fetch_object($resql))
{
$countryArray[$obj->code_iso] = ($obj->code_iso && $langs->transnoentitiesnoconv("Country".$obj->code_iso)!="Country".$obj->code_iso?$langs->transnoentitiesnoconv("Country".$obj->code_iso):($obj->label!='-'?$obj->label:''));
$countryArray[$obj->code_iso] = ($obj->code_iso && $langs->transnoentitiesnoconv("Country".$obj->code_iso)!="Country".$obj->code_iso?$langs->transnoentitiesnoconv("Country".$obj->code_iso):($obj->label!='-'?$obj->label:''));
}
}
@ -162,7 +160,7 @@ print $langs->trans("ListOfTrackedEvents").'</td><td>';
$arrayoftrackedevents=$block_static->trackedevents;
foreach($arrayoftrackedevents as $key => $val)
{
print $key.'-'.$val.'<br>';
print $key.' - '.$langs->trans($val).'<br>';
}
print '</td></tr>';

View File

@ -32,7 +32,7 @@ $langs->loadLangs(array("admin", "other", "blockedlog", "bills"));
if (! $user->admin) accessforbidden();
$action = GETPOST('action','alpha');
$contextpage= GETPOST('contextpage','aZ')?GETPOST('contextpage','aZ'):'myobjectlist'; // To manage different context of search
$contextpage= GETPOST('contextpage','aZ')?GETPOST('contextpage','aZ'):'blockedloglist'; // To manage different context of search
$backtopage = GETPOST('backtopage','alpha'); // Go back to a dedicated page
$optioncss = GETPOST('optioncss','aZ'); // Option for the css output (always '' except when 'print')
@ -43,6 +43,7 @@ $search_start = -1;
if(GETPOST('search_startyear')!='') $search_start = dol_mktime(0, 0, 0, GETPOST('search_startmonth'), GETPOST('search_startday'), GETPOST('search_startyear'));
$search_end = -1;
if(GETPOST('search_endyear')!='') $search_end= dol_mktime(23, 59, 59, GETPOST('search_endmonth'), GETPOST('search_endday'), GETPOST('search_endyear'));
$search_code = GETPOST('search_code', 'alpha');
$search_ref = GETPOST('search_ref', 'alpha');
$search_amount = GETPOST('search_amount', 'alpha');
@ -76,6 +77,7 @@ if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x',
$search_fk_user = '';
$search_start = -1;
$search_end = -1;
$search_code = '';
$search_ref = '';
$search_amount = '';
$toselect='';
@ -167,7 +169,7 @@ else
llxHeader('',$langs->trans("BrowseBlockedLog"));
$blocks = $block_static->getLog('all', 0, GETPOST('all','alpha') ? 0 : 50, $sortfield, $sortorder, $search_fk_user, $search_start, $search_end, $search_ref, $search_amount);
$blocks = $block_static->getLog('all', 0, GETPOST('all','alpha') ? 0 : 50, $sortfield, $sortorder, $search_fk_user, $search_start, $search_end, $search_ref, $search_amount, $search_code);
if (! is_array($blocks))
{
dol_print_error($block_static->db);
@ -216,24 +218,41 @@ print ' </div>';
print '<div class="div-table-responsive">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table
print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">';
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
print '<input type="hidden" name="action" value="list">';
print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
print '<input type="hidden" name="page" value="'.$page.'">';
print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
print '<input type="hidden" name="withtab" value="'.GETPOST('withtab','alpha').'">';
print '<table class="noborder" width="100%">';
// Line of filters
print '<tr class="liste_titre_filter">';
print '<td class="liste_titre">&nbsp;</td>';
print '<td class="liste_titre">';
print $form->select_date($search_start,'search_start');
print $form->select_date($search_end,'search_end');
//print $langs->trans("from").': ';
$form->select_date($search_start,'search_start');
//print '<br>';
//print $langs->trans("to").': ';
$form->select_date($search_end,'search_end');
print '</td>';
// User
print '<td class="liste_titre">';
print $form->select_users($search_fk_user, 'search_fk_user', 1);
print $form->select_dolusers($search_fk_user, 'search_fk_user', 1);
print '</td>';
print '<td class="liste_titre"></td>';
// Actions code
$langs->load("blockedlog");
print '<td class="liste_titre">';
print $form->selectarray('search_code', $block_static->trackedevents, $search_code, 1, 0, 0, '', 1, 0, 0, 'ASC', 'maxwidth200', 1);
print '</td>';
// Ref
print '<td class="liste_titre"><input type="text" class="maxwidth50" name="search_ref" value="'.dol_escape_htmltag($search_ref).'"></td>';
@ -292,7 +311,9 @@ foreach($blocks as &$block) {
//print $block->getUser()
print $block->user_fullname;
print '</td>';
// Action
print '<td>'.$langs->trans('log'.$block->action).'</td>';
// Ref
print '<td>'.$block->ref_object.'</td>';
print '<td>'.$object_link.'</td>';
print '<td align="right">'.price($block->amounts).'</td>';
@ -329,6 +350,8 @@ print '</form>';
print '</div>';
print '<script type="text/javascript">
jQuery(document).ready(function () {
@ -374,29 +397,27 @@ jQuery(document).ready(function () {
</script>'."\n";
if(!empty($conf->global->BLOCKEDLOG_USE_REMOTE_AUTHORITY) && !empty($conf->global->BLOCKEDLOG_AUTHORITY_URL)) {
if(!empty($conf->global->BLOCKEDLOG_USE_REMOTE_AUTHORITY) && !empty($conf->global->BLOCKEDLOG_AUTHORITY_URL))
{
?>
<script type="text/javascript">
<script type="text/javascript">
$.ajax({
url : "<?php echo dol_buildpath('/blockedlog/ajax/check_signature.php',1) ?>"
,dataType:"html"
}).done(function(data) {
$.ajax({
url : "<?php echo dol_buildpath('/blockedlog/ajax/check_signature.php',1) ?>"
,dataType:"html"
}).done(function(data) {
if(data == 'hashisok') {
$('#blockchainstatus').html('<?php echo $langs->trans('AuthorityReconizeFingerprintConformity'). ' '. img_picto($langs->trans('SignatureOK'), 'on') ?>');
}
else{
$('#blockchainstatus').html('<?php echo $langs->trans('AuthorityDidntReconizeFingerprintConformity'). ' '.img_picto($langs->trans('SignatureKO'), 'off') ?>');
}
if(data == 'hashisok') {
$('#blockchainstatus').html('<?php echo $langs->trans('AuthorityReconizeFingerprintConformity'). ' '. img_picto($langs->trans('SignatureOK'), 'on') ?>');
}
else{
$('#blockchainstatus').html('<?php echo $langs->trans('AuthorityDidntReconizeFingerprintConformity'). ' '.img_picto($langs->trans('SignatureKO'), 'off') ?>');
}
});
</script>
});
</script>
<?php
}
if (GETPOST('withtab','alpha'))

View File

@ -109,42 +109,47 @@ class BlockedLog
$this->trackedevents = array();
if ($conf->facture->enabled) $this->trackedevents['BILL_VALIDATE']='BillValidate';
if ($conf->facture->enabled) $this->trackedevents['BILL_DELETE']='BillDelete';
if ($conf->facture->enabled) $this->trackedevents['BILL_SENTBYMAIL']='BillSentByEmail';
if ($conf->facture->enabled) $this->trackedevents['DOC_DOWNLOAD']='BillDownload';
if ($conf->facture->enabled) $this->trackedevents['DOC_PREVIEW']='BillPreview';
if ($conf->facture->enabled) $this->trackedevents['BILL_VALIDATE']='logBILL_VALIDATE';
if ($conf->facture->enabled) $this->trackedevents['BILL_DELETE']='logBILL_DELETE';
if ($conf->facture->enabled) $this->trackedevents['BILL_SENTBYMAIL']='logBILL_SENTBYMAIL';
if ($conf->facture->enabled) $this->trackedevents['DOC_DOWNLOAD']='BlockedLogBillDownload';
if ($conf->facture->enabled) $this->trackedevents['DOC_PREVIEW']='BlockedLogBillPreview';
if ($conf->facture->enabled) $this->trackedevents['PAYMENT_CUSTOMER_CREATE']='BillPaymentCreate';
if ($conf->facture->enabled) $this->trackedevents['PAYMENT_CUSTOMER_DELETE']='BillPaymentDelete';
if ($conf->facture->enabled) $this->trackedevents['PAYMENT_CUSTOMER_CREATE']='logPAYMENT_CUSTOMER_CREATE';
if ($conf->facture->enabled) $this->trackedevents['PAYMENT_CUSTOMER_DELETE']='logPAYMENT_CUSTOMER_DELETE';
/* Supplier
if ($conf->fournisseur->enabled) $this->trackedevents['BILL_SUPPLIER_VALIDATE']='SupplierBillValidate';
if ($conf->fournisseur->enabled) $this->trackedevents['BILL_SUPPLIER_DELETE']='SupplierBillDelete';
if ($conf->fournisseur->enabled) $this->trackedevents['BILL_SUPPLIER_SENTBYMAIL']='SupplierBillSentByEmail'; // Trigger key does not exists, we want just into array to list it as done
if ($conf->fournisseur->enabled) $this->trackedevents['SUPPLIER_DOC_DOWNLOAD']='SupplierBillDownload'; // Trigger key does not exists, we want just into array to list it as done
if ($conf->fournisseur->enabled) $this->trackedevents['SUPPLIER_DOC_PREVIEW']='SupplierBillPreview'; // Trigger key does not exists, we want just into array to list it as done
if ($conf->fournisseur->enabled) $this->trackedevents['BILL_SUPPLIER_VALIDATE']='BlockedLogSupplierBillValidate';
if ($conf->fournisseur->enabled) $this->trackedevents['BILL_SUPPLIER_DELETE']='BlockedLogSupplierBillDelete';
if ($conf->fournisseur->enabled) $this->trackedevents['BILL_SUPPLIER_SENTBYMAIL']='BlockedLogSupplierBillSentByEmail'; // Trigger key does not exists, we want just into array to list it as done
if ($conf->fournisseur->enabled) $this->trackedevents['SUPPLIER_DOC_DOWNLOAD']='BlockedLogSupplierBillDownload'; // Trigger key does not exists, we want just into array to list it as done
if ($conf->fournisseur->enabled) $this->trackedevents['SUPPLIER_DOC_PREVIEW']='BlockedLogSupplierBillPreview'; // Trigger key does not exists, we want just into array to list it as done
if ($conf->fournisseur->enabled) $this->trackedevents['PAYMENT_SUPPLIER_CREATE']='SupplierBillPaymentCreate';
if ($conf->fournisseur->enabled) $this->trackedevents['PAYMENT_SUPPLIER_DELETE']='supplierBillPaymentCreate';
if ($conf->fournisseur->enabled) $this->trackedevents['PAYMENT_SUPPLIER_CREATE']='BlockedLogSupplierBillPaymentCreate';
if ($conf->fournisseur->enabled) $this->trackedevents['PAYMENT_SUPPLIER_DELETE']='BlockedLogsupplierBillPaymentCreate';
*/
if ($conf->don->enabled) $this->trackedevents['DON_CREATE']='DonationCreate';
if ($conf->don->enabled) $this->trackedevents['DON_MODIFY']='DonationModify';
if ($conf->don->enabled) $this->trackedevents['DON_DELETE']='DonationDelete';
if ($conf->don->enabled) $this->trackedevents['DON_VALIDATE']='logDON_VALIDATE';
if ($conf->don->enabled) $this->trackedevents['DON_DELETE']='logDON_DELETE';
//if ($conf->don->enabled) $this->trackedevents['DON_SENTBYMAIL']='logDON_SENTBYMAIL';
if ($conf->don->enabled) $this->trackedevents['DONATION_PAYMENT_CREATE']='logDONATION_PAYMENT_CREATE';
if ($conf->don->enabled) $this->trackedevents['DONATION_PAYMENT_DELETE']='logDONATION_PAYMENT_DELETE';
/*
if ($conf->salary->enabled) $this->trackedevents['PAYMENT_SALARY_CREATE']='SalaryPaymentCreate';
if ($conf->salary->enabled) $this->trackedevents['PAYMENT_SALARY_MODIFY']='SalaryPaymentCreate';
if ($conf->salary->enabled) $this->trackedevents['PAYMENT_SALARY_DELETE']='SalaryPaymentCreate';
if ($conf->salary->enabled) $this->trackedevents['PAYMENT_SALARY_CREATE']='BlockedLogSalaryPaymentCreate';
if ($conf->salary->enabled) $this->trackedevents['PAYMENT_SALARY_MODIFY']='BlockedLogSalaryPaymentCreate';
if ($conf->salary->enabled) $this->trackedevents['PAYMENT_SALARY_DELETE']='BlockedLogSalaryPaymentCreate';
*/
if ($conf->adherent->enabled) $this->trackedevents['MEMBER_SUBSCRIPTION']='MemberSubscription';
if ($conf->adherent->enabled) $this->trackedevents['MEMBER_SUBSCRIPTION_CREATE']='logMEMBER_SUBSCRIPTION_CREATE';
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']='VariousPaymentCreate';
$trackedevents['PAYMENT_VARIOUS_MODIFY']='VariousPaymentModify';
$trackedevents['PAYMENT_VARIOUS_DELETE']='VariousPaymentDelete';
$trackedevents['PAYMENT_VARIOUS_CREATE']='BlockedLogVariousPaymentCreate';
$trackedevents['PAYMENT_VARIOUS_MODIFY']='BlockedLogVariousPaymentModify';
$trackedevents['PAYMENT_VARIOUS_DELETE']='BlockedLogVariousPaymentDelete';
*/
}
@ -199,6 +204,17 @@ class BlockedLog
$this->error++;
}
}
else if($this->element === 'payment_donation') {
require_once DOL_DOCUMENT_ROOT.'/don/class/paymentdonation.class.php';
$object = new PaymentDonation($this->db);
if($object->fetch($this->fk_object)>0) {
return $object->getNomUrl(1);
}
else{
$this->error++;
}
}
else if ($this->action == 'MODULE_SET')
{
return '<i class="opacitymedium">System to track events into unalterable logs were enabled</i>';
@ -269,6 +285,10 @@ class BlockedLog
{
$this->date_object = $object->datev;
}
elseif ($object->element == 'payment_donation')
{
$this->date_object = $object->datepaid?$object->datepaid:$object->datep;
}
else {
$this->date_object = $object->date;
}
@ -322,6 +342,7 @@ class BlockedLog
if ($this->element == 'facture')
{
var_dump($object);exit;
foreach($object as $key=>$value)
{
if (in_array($key, array('fields'))) continue; // Discard some properties
@ -342,12 +363,14 @@ class BlockedLog
if (!is_object($value)) $this->object_data->{$key} = $value;
}
}
elseif ($this->element == 'payment'|| $object->element == 'payment_supplier')
elseif ($this->element == 'payment' || $this->element == 'payment_supplier' || $this->element == 'payment_donation')
{
//var_dump($object);
$datepayment = $object->datepaye?$object->datepaye:($object->datepaid?$object->datepaid:$object->datep);
$paymenttypeid = $object->paiementid?$object->paiementid:$object->paymenttype;
$this->object_data->ref = $object->ref;
$this->object_data->date = $object->datepaye;
$this->object_data->type_code = dol_getIdFromCode($this->db, $object->paiementid, 'c_paiement', 'id', 'code');
$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->fk_account = $object->fk_account;
$this->object_data->note = $object->note;
@ -356,7 +379,7 @@ class BlockedLog
$totalamount=0;
$paymentpartnumber=0;
foreach($object->amounts as $invoiceid => $amount)
foreach($object->amounts as $objid => $amount)
{
if (empty($amount)) continue;
@ -364,49 +387,68 @@ class BlockedLog
if ($this->element == 'payment_supplier')
{
$tmpinvoice = new FactureFournisseur($this->db);
include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
$tmpobject = new FactureFournisseur($this->db);
}
else
elseif ($this->element == 'payment')
{
$tmpinvoice = new Facture($this->db);
include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
$tmpobject = new Facture($this->db);
}
$result = $tmpinvoice->fetch($invoiceid);
elseif ($this->element == 'payment_donation')
{
include_once DOL_DOCUMENT_ROOT.'/don/class/don.class.php';
$tmpobject = new Don($this->db);
}
$result = $tmpobject->fetch($objid);
if ($result <= 0)
{
$this->error = $tmpinvoice->error;
$this->errors = $tmpinvoice->errors;
return -1;
}
$result = $tmpinvoice->fetch_thirdparty();
if ($result <= 0)
{
$this->error = $tmpinvoice->error;
$this->errors = $tmpinvoice->errors;
$this->error = $tmpobject->error;
$this->errors = $tmpobject->errors;
return -1;
}
$paymentpart = new stdClass();
$paymentpart->amount = $amount;
$paymentpart->thirdparty = new stdClass();
foreach($tmpinvoice->thirdparty as $key=>$value)
if ($this->element != 'payment_donation')
{
if (in_array($key, array('fields'))) 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'
))) continue; // Discard if not into a dedicated list
if (!is_object($value)) $paymentpart->thirdparty->{$key} = $value;
$result = $tmpobject->fetch_thirdparty();
if ($result <= 0)
{
$this->error = $tmpobject->error;
$this->errors = $tmpobject->errors;
return -1;
}
$paymentpart->thirdparty = new stdClass();
foreach($tmpobject->thirdparty as $key=>$value)
{
if (in_array($key, array('fields'))) 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'
))) continue; // Discard if not into a dedicated list
if (!is_object($value)) $paymentpart->thirdparty->{$key} = $value;
}
}
$paymentpart->invoice = new stdClass();
foreach($tmpinvoice as $key=>$value)
// Init object to avoid warnings
if ($this->element == 'payment_donation') $paymentpart->donation = new stdClass();
else $paymentpart->invoice = new stdClass();
foreach($tmpobject as $key=>$value)
{
if (in_array($key, array('fields'))) continue; // Discard some properties
if (! in_array($key, array(
'ref','facnumber','ref_client','ref_supplier','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)) $paymentpart->invoice->{$key} = $value;
if (!is_object($value))
{
if ($this->element == 'payment_donation') $paymentpart->donation->{$key} = $value;
else $paymentpart->invoice->{$key} = $value;
}
}
$paymentpartnumber++;
@ -718,9 +760,10 @@ class BlockedLog
* @param int $search_end end time limit
* @param string $search_ref search ref
* @param string $search_amount search amount
* @param string $search_code search code
* @return array array of object log
*/
public function getLog($element, $fk_object, $limit = 0, $sortfield = '', $sortorder = '', $search_fk_user = -1, $search_start = -1, $search_end = -1, $search_ref='', $search_amount='')
public function getLog($element, $fk_object, $limit = 0, $sortfield = '', $sortorder = '', $search_fk_user = -1, $search_start = -1, $search_end = -1, $search_ref='', $search_amount='', $search_code='')
{
global $conf, $cachedlogs;
@ -748,11 +791,12 @@ class BlockedLog
WHERE entity=".$conf->entity." AND element='".$element."' AND fk_object=".(int) $fk_object;
}
if ($search_fk_user > 0) $sql.=" AND fk_user IN (".$this->db->escape($search_fk_user).")";
if ($search_start > 0) $sql.=" AND date_creation >= '".$this->db->idate($search_start)."'";
if ($search_end > 0) $sql.=" AND date_creation <= '".$this->db->idate($search_end)."'";
if ($search_ref != '') $sql.=natural_search("ref_object", $search_ref);
if ($search_fk_user > 0) $sql.=natural_search("fk_user", $search_fk_user, 2);
if ($search_start > 0) $sql.=" AND date_creation >= '".$this->db->idate($search_start)."'";
if ($search_end > 0) $sql.=" AND date_creation <= '".$this->db->idate($search_end)."'";
if ($search_ref != '') $sql.=natural_search("ref_object", $search_ref);
if ($search_amount != '') $sql.=natural_search("amounts", $search_amount, 1);
if ($search_code != '') $sql.=natural_search("action", $search_code, 3);
$sql.=$this->db->order($sortfield, $sortorder);

View File

@ -6589,6 +6589,7 @@ function dol_getmypid()
* or like "keyword1|keyword2" = We want record field like keyword1 OR field like keyword2
* If param $mode is 1, can contains an operator <, > or = like "<10" or ">=100.5 < 1000"
* If param $mode is 2, can contains a list of int id separated by comma like "1,3,4"
* If param $mode is 3, can contains a list of string separated by comma like "a,b,c"
* @param integer $mode 0=value is list of keyword strings, 1=value is a numeric test (Example ">5.5 <10"), 2=value is a list of id separated with comma (Example '1,3,4')
* @param integer $nofirstand 1=Do not output the first 'AND'
* @return string $res The statement to append to the SQL query
@ -6652,6 +6653,24 @@ function natural_search($fields, $value, $mode=0, $nofirstand=0)
$newres .= ($i2 > 0 ? ' OR ' : '') . $field . " IN (" . $db->escape(trim($crit)) . ")";
$i2++; // a criteria was added to string
}
else if ($mode == 3)
{
$tmparray=explode(',',trim($crit));
if (count($tmparray))
{
$listofcodes='';
foreach($tmparray as $val)
{
if ($val)
{
$listofcodes.=($listofcodes?',':'');
$listofcodes.="'".$db->escape(trim($val))."'";
}
}
$newres .= ($i2 > 0 ? ' OR ' : '') . $field . " IN (" . $listofcodes . ")";
$i2++; // a criteria was added to string
}
}
else // $mode=0
{
$textcrit = '';
@ -6661,7 +6680,7 @@ function natural_search($fields, $value, $mode=0, $nofirstand=0)
{
$newres .= (($i2 > 0 || $i3 > 0) ? ' OR ' : '');
if (preg_match('/\.(id|rowid)$/', $field)) // Special cas for rowid that is sometimes a ref so used as a search field
if (preg_match('/\.(id|rowid)$/', $field)) // Special case for rowid that is sometimes a ref so used as a search field
{
$newres .= $field . " = " . (is_numeric(trim($tmpcrit))?trim($tmpcrit):'0');
}

View File

@ -50,7 +50,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('payment', 'facture');
$listofqualifiedelement = array('facture', 'don', 'payment', 'payment_donation', 'subscription');
if (! in_array($object->element, $listofqualifiedelement)) return 1;
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
@ -68,6 +68,8 @@ 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==='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')
)
{
@ -80,8 +82,8 @@ class InterfaceActionsBlockedLog extends DolibarrTriggers
$qualified++;
$amounts= (double) $object->total_ttc;
}*/
if ($action === 'PAYMENT_CUSTOMER_CREATE' || $action === 'PAYMENT_SUPPLIER_CREATE'
|| $action === 'PAYMENT_CUSTOMER_DELETE' || $action === 'PAYMENT_SUPPLIER_DELETE') // 'PAYMENT_ADD_TO_BANK'
if ($action === 'PAYMENT_CUSTOMER_CREATE' || $action === 'PAYMENT_SUPPLIER_CREATE' || $action === 'DONATION_PAYMENT_CREATE'
|| $action === 'PAYMENT_CUSTOMER_DELETE' || $action === 'PAYMENT_SUPPLIER_DELETE' || $action === 'DONATION_PAYMENT_DELETE')
{
$qualified++;
$amounts = 0;
@ -91,10 +93,10 @@ class InterfaceActionsBlockedLog extends DolibarrTriggers
}
}
}
if (strpos($action,'PAYMENT')!==false && ! in_array($action, array('PAYMENT_ADD_TO_BANK')))
elseif (strpos($action,'PAYMENT')!==false && ! in_array($action, array('PAYMENT_ADD_TO_BANK')))
{
$qualified++;
$amounts= (double) $object->amount;
$amounts = (double) $object->amount;
}
// Another protection.
@ -109,7 +111,7 @@ class InterfaceActionsBlockedLog extends DolibarrTriggers
if ($result < 0)
{
$this->error = $b->error;
$this->errors = $b->erros;
$this->errors = $b->errors;
return -1;
}

View File

@ -740,7 +740,7 @@ if (! empty($id) && $action != 'edit')
}
else
{
print '<div class="inline-block divButAction"><a class="butActionDelete butActionRefused" href="#">'.$langs->trans("Delete")."</a></div>";
print '<div class="inline-block divButAction"><a class="butActionRefused" href="#">'.$langs->trans("Delete")."</a></div>";
}
}
else

View File

@ -67,10 +67,11 @@ class PaymentDonation extends CommonObject
* Create payment of donation into database.
* Use this->amounts to have list of lines for the payment
*
* @param User $user User making payment
* @return int <0 if KO, id of payment if OK
* @param User $user User making payment
* @param bool $notrigger false=launch triggers after, true=disable triggers
* @return int <0 if KO, id of payment if OK
*/
function create($user)
function create($user, $notrigger=false)
{
global $conf, $langs;
@ -125,12 +126,20 @@ class PaymentDonation extends CommonObject
if ($resql)
{
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."payment_donation");
$this->ref = $this->id;
}
else
{
$error++;
}
}
if (! $error && ! $notrigger)
{
// Call triggers
$result=$this->call_trigger('DONATION_PAYMENT_CREATE',$user);
if ($result < 0) { $error++; }
// End call triggers
}
if ($totalamount != 0 && ! $error)
@ -241,14 +250,11 @@ class PaymentDonation extends CommonObject
if (isset($this->fk_user_creat)) $this->fk_user_creat=trim($this->fk_user_creat);
if (isset($this->fk_user_modif)) $this->fk_user_modif=trim($this->fk_user_modif);
// Check parameters
// Put here code to add control on parameters values
// Update request
$sql = "UPDATE ".MAIN_DB_PREFIX."payment_donation SET";
$sql.= " fk_donation=".(isset($this->fk_donation)?$this->fk_donation:"null").",";
$sql.= " datec=".(dol_strlen($this->datec)!=0 ? "'".$this->db->idate($this->datec)."'" : 'null').",";
$sql.= " tms=".(dol_strlen($this->tms)!=0 ? "'".$this->db->idate($this->tms)."'" : 'null').",";
@ -260,8 +266,6 @@ class PaymentDonation extends CommonObject
$sql.= " fk_bank=".(isset($this->fk_bank)?$this->fk_bank:"null").",";
$sql.= " fk_user_creat=".(isset($this->fk_user_creat)?$this->fk_user_creat:"null").",";
$sql.= " fk_user_modif=".(isset($this->fk_user_modif)?$this->fk_user_modif:"null")."";
$sql.= " WHERE rowid=".$this->id;
$this->db->begin();
@ -274,15 +278,13 @@ class PaymentDonation extends CommonObject
{
if (! $notrigger)
{
// Uncomment this and change MYOBJECT to your own tag if you
// want this action call a trigger.
//// Call triggers
//include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
//$interface=new Interfaces($this->db);
//$result=$interface->run_triggers('MYOBJECT_MODIFY',$this,$user,$langs,$conf);
//if ($result < 0) { $error++; $this->errors=$interface->errors; }
//// End call triggers
if (! $error && ! $notrigger)
{
// Call triggers
$result=$this->call_trigger('DONATION_PAYMENT_MODIFY',$user);
if ($result < 0) { $error++; }
// End call triggers
}
}
}
@ -343,15 +345,13 @@ class PaymentDonation extends CommonObject
{
if (! $notrigger)
{
// Uncomment this and change MYOBJECT to your own tag if you
// want this action call a trigger.
//// Call triggers
//include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
//$interface=new Interfaces($this->db);
//$result=$interface->run_triggers('MYOBJECT_DELETE',$this,$user,$langs,$conf);
//if ($result < 0) { $error++; $this->errors=$interface->errors; }
//// End call triggers
if (! $error && ! $notrigger)
{
// Call triggers
$result=$this->call_trigger('DONATION_PAYMENT_DELETE',$user);
if ($result < 0) { $error++; }
// End call triggers
}
}
}

View File

@ -41,7 +41,7 @@ if ($user->societe_id) $socid=$user->societe_id;
//$result = restrictedArea($user, 'facture', $id,'');
$object = new PaymentDonation($db);
if ($id > 0)
if ($id > 0)
{
$result=$object->fetch($id);
if (! $result) dol_print_error($db,'Failed to get payment id '.$id);
@ -77,7 +77,7 @@ if ($action == 'confirm_valide' && $confirm == 'yes' && $user->rights->don->cree
$db->begin();
$result=$object->valide();
if ($result > 0)
{
$db->commit();
@ -126,7 +126,7 @@ $head[$h][1] = $langs->trans("Card");
$hselected = $h;
$h++;
dol_fiche_head($head, $hselected, $langs->trans("DonationPayment"), 0, 'payment');
dol_fiche_head($head, $hselected, $langs->trans("DonationPayment"), -1, 'payment');
/*
* Confirm deleting of the payment
@ -134,7 +134,7 @@ dol_fiche_head($head, $hselected, $langs->trans("DonationPayment"), 0, 'payment'
if ($action == 'delete')
{
print $form->formconfirm('card.php?id='.$object->id, $langs->trans("DeletePayment"), $langs->trans("ConfirmDeletePayment"), 'confirm_delete','',0,2);
}
/*
@ -144,12 +144,13 @@ if ($action == 'valide')
{
$facid = GETPOST('facid','int');
print $form->formconfirm('card.php?id='.$object->id.'&amp;facid='.$facid, $langs->trans("ValidatePayment"), $langs->trans("ConfirmValidatePayment"), 'confirm_valide','',0,2);
}
dol_banner_tab($object,'id','',1,'rowid','id');
print '<div class="fichecenter">';
print '<div class="underbanner clearboth"></div>';
print '<table class="border" width="100%">';
@ -231,7 +232,7 @@ if ($resql)
{
$objp = $db->fetch_object($resql);
print '<tr class="oddeven">';
// Ref
print '<td>';
@ -253,7 +254,7 @@ if ($resql)
$i++;
}
}
print "</table>\n";
$db->free($resql);
@ -265,6 +266,8 @@ else
print '</div>';
dol_fiche_end();
/*
* Actions buttons

View File

@ -15,15 +15,25 @@ AddedByAuthority=Stored into remote authority
NotAddedByAuthorityYet=Not yet stored into remote authority
ShowDetails=Show stored details
logPAYMENT_ADD_TO_BANK=Payment added to bank
logPAYMENT_CUSTOMER_CREATE=Payment of customer created
logPAYMENT_CUSTOMER_DELETE=Payment of customer deleted
logBILL_PAYED=Customer bill payed
logBILL_UNPAYED=Customer bill set unpayed
logBILL_VALIDATE=Customer bill validated
logBILL_SENTBYMAIL=Customer bill send by mail
logBILL_DELETE=Customer bill deleted
logPAYMENT_CUSTOMER_CREATE=Customer payment created
logPAYMENT_CUSTOMER_DELETE=Customer payment logical deletion
logDONATION_PAYMENT_CREATE=Donation payment created
logDONATION_PAYMENT_DELETE=Donation payment logical deletion
logBILL_PAYED=Customer invoice payed
logBILL_UNPAYED=Customer invoice set unpayed
logBILL_VALIDATE=Customer invoice validated
logBILL_SENTBYMAIL=Customer invoice send by mail
logBILL_DELETE=Customer invoice logically deleted
logMODULE_RESET=Module BlockedLog was disabled
logMODULE_SET=Module BlockedLog was enabled
logDON_VALIDATE=Donation validated
logDON_MODIFY=Donation modified
logDON_DELETE=Donation logical deletion
logMEMBER_SUBSCRIPTION_CREATE=Member subcription created
logMEMBER_SUBSCRIPTION_MODIFY=Member subcription modified
logMEMBER_SUBSCRIPTION_DELETE=Member subcription logical deletion
BlockedLogBillDownload=Customer invoice download
BlockedLogBillPreview=Customer invoice preview
BlockedlogInfoDialog=Log Details
ListOfTrackedEvents=List of tracked events
Fingerprint=Fingerprint
@ -34,4 +44,4 @@ DataOfArchivedEvent=Full datas of archived event
ImpossibleToReloadObject=Object (type %s, id %s) removed (see 'Full data' link for unerasable 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)
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)