diff --git a/htdocs/blockedlog/admin/blockedlog_list.php b/htdocs/blockedlog/admin/blockedlog_list.php index 08b384d7ac5..d508d1edceb 100644 --- a/htdocs/blockedlog/admin/blockedlog_list.php +++ b/htdocs/blockedlog/admin/blockedlog_list.php @@ -453,24 +453,36 @@ if (is_array($blocks)) if (empty($search_showonlyerrors) || ! $checkresult[$block->id]) { print ''; + // ID print ''.$block->id.''; + // Date print ''.dol_print_date($block->date_creation,'dayhour').''; + // User print ''; + //print $block->getUser() print $block->user_fullname; print ''; + // Action print ''.$langs->trans('log'.$block->action).''; + // Ref print ''.$block->ref_object.''; + // Link to source object print ''.$object_link.''; + + // Amount print ''.price($block->amounts).''; + + // Details link print ''.img_info($langs->trans('ShowDetails')).''; + // Fingerprint print ''; print $form->textwithpicto(dol_trunc($block->signature, '12'), $block->signature, 1, 'help', '', 0, 2, 'fingerprint'); print ''; diff --git a/htdocs/blockedlog/class/blockedlog.class.php b/htdocs/blockedlog/class/blockedlog.class.php index 2f3c5d60640..d2f3a5ee179 100644 --- a/htdocs/blockedlog/class/blockedlog.class.php +++ b/htdocs/blockedlog/class/blockedlog.class.php @@ -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; diff --git a/htdocs/compta/bank/class/paymentvarious.class.php b/htdocs/compta/bank/class/paymentvarious.class.php index 5922b3f5aa7..fe56ea99504 100644 --- a/htdocs/compta/bank/class/paymentvarious.class.php +++ b/htdocs/compta/bank/class/paymentvarious.class.php @@ -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) { diff --git a/htdocs/compta/bank/various_payment/card.php b/htdocs/compta/bank/various_payment/card.php index 90aa3e5e432..b6649250e64 100644 --- a/htdocs/compta/bank/various_payment/card.php +++ b/htdocs/compta/bank/various_payment/card.php @@ -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 ''; // Label - print ''; + print ''; // Payment date print ""; diff --git a/htdocs/core/class/html.formprojet.class.php b/htdocs/core/class/html.formprojet.class.php index 0afae8e358f..f4a6d98c671 100644 --- a/htdocs/core/class/html.formprojet.class.php +++ b/htdocs/core/class/html.formprojet.class.php @@ -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 diff --git a/htdocs/core/triggers/interface_50_modBlockedlog_ActionsBlockedLog.class.php b/htdocs/core/triggers/interface_50_modBlockedlog_ActionsBlockedLog.class.php index 25dc957df02..ec0b0cb6941 100644 --- a/htdocs/core/triggers/interface_50_modBlockedlog_ActionsBlockedLog.class.php +++ b/htdocs/core/triggers/interface_50_modBlockedlog_ActionsBlockedLog.class.php @@ -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 diff --git a/htdocs/langs/en_US/blockedlog.lang b/htdocs/langs/en_US/blockedlog.lang index 93f64bddbaa..10939f1b5b6 100644 --- a/htdocs/langs/en_US/blockedlog.lang +++ b/htdocs/langs/en_US/blockedlog.lang @@ -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).
'.$langs->trans("Label").''.$object->label.'
'.$langs->trans("Label").''.$object->label.'