26require_once DOL_DOCUMENT_ROOT.
'/core/class/commonobject.class.php';
37 public $element =
'payment_donation';
42 public $table_element =
'payment_donation';
47 public $picto =
'payment';
77 public $amounts = array();
84 public $fk_typepayment;
105 public $fk_user_creat;
110 public $fk_user_modif;
138 public $bank_account;
147 public $ext_payment_id;
152 public $ext_payment_site;
172 public function create($user, $notrigger = 0)
180 $this->error =
'ErrorBadValueForParameterCreatePaymentDonation';
185 if (isset($this->chid)) {
186 $this->chid = (int) $this->chid;
187 } elseif (isset($this->fk_donation)) {
190 $this->chid = (int) $this->fk_donation;
192 if (isset($this->fk_donation)) {
193 $this->fk_donation = (int) $this->fk_donation;
195 if (isset($this->
amount)) {
198 if (isset($this->fk_typepayment)) {
199 $this->fk_typepayment = (int)
price2num($this->fk_typepayment);
201 if (isset($this->num_payment)) {
202 $this->num_payment = trim($this->num_payment);
204 if (isset($this->note_public)) {
205 $this->note_public = trim($this->note_public);
207 if (isset($this->fk_bank)) {
208 $this->fk_bank = (int) $this->fk_bank;
210 if (isset($this->fk_user_creat)) {
211 $this->fk_user_creat = (int) $this->fk_user_creat;
213 if (isset($this->fk_user_modif)) {
214 $this->fk_user_modif = (int) $this->fk_user_modif;
218 foreach ($this->amounts as $key => $value) {
219 $newvalue = (float)
price2num($value,
'MT');
220 $this->amounts[$key] = $newvalue;
221 $totalamount += $newvalue;
223 $totalamount = (float)
price2num($totalamount);
226 if ($totalamount == 0) {
233 if ($totalamount != 0) {
234 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"payment_donation (fk_donation, datec, datep, amount,";
235 $sql .=
" fk_typepayment, num_payment, note, ext_payment_id, ext_payment_site,";
236 $sql .=
" fk_user_creat, fk_bank)";
237 $sql .=
" VALUES (".((int) $this->chid).
", '".$this->db->idate($now).
"',";
238 $sql .=
" '".$this->db->idate($this->datep).
"',";
239 $sql .=
" ".((float)
price2num($totalamount)).
",";
240 $sql .=
" ".((int) $this->paymenttype).
", '".$this->db->escape($this->num_payment).
"', '".$this->db->escape($this->note_public).
"', ";
241 $sql .=
" ".($this->ext_payment_id ?
"'".$this->db->escape($this->ext_payment_id).
"'" :
"null").
", ".($this->ext_payment_site ?
"'".$this->db->escape($this->ext_payment_site).
"'" :
"null").
",";
242 $sql .=
" ".((int) $user->id).
", 0)";
244 dol_syslog(get_class($this).
"::create", LOG_DEBUG);
245 $resql = $this->db->query($sql);
247 $this->
id = $this->db->last_insert_id(MAIN_DB_PREFIX.
"payment_donation");
254 if (!$error && !$notrigger) {
256 $result = $this->call_trigger(
'DONATION_PAYMENT_CREATE', $user);
263 if ($totalamount != 0 && !$error) {
264 $this->
amount = $totalamount;
265 $this->total = $totalamount;
269 $this->error = $this->db->error();
270 $this->db->rollback();
286 $sql .=
" t.fk_donation,";
290 $sql .=
" t.amount,";
291 $sql .=
" t.fk_typepayment,";
292 $sql .=
" t.num_payment,";
293 $sql .=
" t.note as note_public,";
294 $sql .=
" t.fk_bank,";
295 $sql .=
" t.fk_user_creat,";
296 $sql .=
" t.fk_user_modif,";
297 $sql .=
" pt.code as type_code, pt.libelle as type_label,";
298 $sql .=
' b.fk_account';
299 $sql .=
" FROM ".MAIN_DB_PREFIX.
"payment_donation as t";
300 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_paiement as pt ON t.fk_typepayment = pt.id";
301 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'bank as b ON t.fk_bank = b.rowid';
302 $sql .=
" WHERE t.rowid = ".((int) $id);
304 dol_syslog(get_class($this).
"::fetch", LOG_DEBUG);
305 $resql = $this->db->query($sql);
307 if ($this->db->num_rows($resql)) {
308 $obj = $this->db->fetch_object($resql);
310 $this->
id = $obj->rowid;
311 $this->
ref = $obj->rowid;
313 $this->fk_donation = $obj->fk_donation;
314 $this->datec = $this->db->jdate($obj->datec);
315 $this->tms = $this->db->jdate($obj->tms);
316 $this->datep = $this->db->jdate($obj->datep);
317 $this->
amount = $obj->amount;
318 $this->fk_typepayment = $obj->fk_typepayment;
319 $this->paymenttype = $obj->fk_typepayment;
320 $this->num_payment = $obj->num_payment;
321 $this->note_public = $obj->note_public;
322 $this->fk_bank = $obj->fk_bank;
323 $this->fk_user_creat = $obj->fk_user_creat;
324 $this->fk_user_modif = $obj->fk_user_modif;
326 $this->type_code = $obj->type_code;
327 $this->type_label = $obj->type_label;
329 $this->bank_account = $obj->fk_account;
330 $this->bank_line = $obj->fk_bank;
332 $this->db->free($resql);
336 $this->error =
"Error ".$this->db->lasterror();
349 public function update($user, $notrigger = 0)
351 global
$conf, $langs;
356 if (isset($this->fk_donation)) {
357 $this->fk_donation = (int) $this->fk_donation;
359 if (isset($this->
amount)) {
362 if (isset($this->fk_typepayment)) {
363 $this->fk_typepayment = (int)
price2num($this->fk_typepayment);
365 if (isset($this->num_payment)) {
366 $this->num_payment = trim($this->num_payment);
368 if (isset($this->note_public)) {
369 $this->note_public = trim($this->note_public);
371 if (isset($this->fk_bank)) {
372 $this->fk_bank = (int) $this->fk_bank;
374 if (isset($this->fk_user_creat)) {
375 $this->fk_user_creat = (int) $this->fk_user_creat;
377 if (isset($this->fk_user_modif)) {
378 $this->fk_user_modif = (int) $this->fk_user_modif;
385 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"payment_donation SET";
386 $sql .=
" fk_donation=".(isset($this->fk_donation) ? $this->fk_donation :
"null").
",";
387 $sql .=
" datec=".(dol_strlen($this->datec) != 0 ?
"'".$this->db->idate($this->datec).
"'" :
'null').
",";
388 $sql .=
" tms=".(dol_strlen((
string) $this->tms) != 0 ?
"'".$this->db->idate($this->tms).
"'" :
'null').
",";
389 $sql .=
" datep=".(dol_strlen($this->datep) != 0 ?
"'".$this->db->idate($this->datep).
"'" :
'null').
",";
390 $sql .=
" amount=".(isset($this->
amount) ? $this->
amount :
"null").
",";
391 $sql .=
" fk_typepayment=".(isset($this->fk_typepayment) ? $this->fk_typepayment :
"null").
",";
392 $sql .=
" num_payment=".(isset($this->num_payment) ?
"'".$this->db->escape($this->num_payment).
"'" :
"null").
",";
393 $sql .=
" note=".(isset($this->note_public) ?
"'".$this->db->escape($this->note_public).
"'" :
"null").
",";
394 $sql .=
" fk_bank=".(isset($this->fk_bank) ? $this->fk_bank :
"null").
",";
395 $sql .=
" fk_user_creat=".(isset($this->fk_user_creat) ? $this->fk_user_creat :
"null").
",";
396 $sql .=
" fk_user_modif=".(isset($this->fk_user_modif) ? $this->fk_user_modif :
"null");
397 $sql .=
" WHERE rowid=".(int) $this->
id;
401 dol_syslog(get_class($this).
"::update", LOG_DEBUG);
402 $resql = $this->db->query($sql);
405 $this->errors[] =
"Error ".$this->db->lasterror();
408 if (!$error && !$notrigger) {
410 $result = $this->call_trigger(
'DONATION_PAYMENT_MODIFY', $user);
419 foreach ($this->errors as $errmsg) {
420 dol_syslog(get_class($this).
"::update ".$errmsg, LOG_ERR);
421 $this->error .= ($this->error ?
', '.$errmsg : $errmsg);
423 $this->db->rollback();
439 public function delete($user, $notrigger = 0)
441 global
$conf, $langs;
447 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"bank_url";
448 $sql .=
" WHERE type='payment_donation' AND url_id=".(int) $this->
id;
450 dol_syslog(get_class($this).
"::delete", LOG_DEBUG);
451 $resql = $this->db->query($sql);
454 $this->errors[] =
"Error ".$this->db->lasterror();
458 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"payment_donation";
459 $sql .=
" WHERE rowid=".((int) $this->
id);
461 dol_syslog(get_class($this).
"::delete", LOG_DEBUG);
462 $resql = $this->db->query($sql);
465 $this->errors[] =
"Error ".$this->db->lasterror();
469 if (!$error && !$notrigger) {
471 $result = $this->call_trigger(
'DONATION_PAYMENT_DELETE', $user);
480 foreach ($this->errors as $errmsg) {
481 dol_syslog(get_class($this).
"::delete ".$errmsg, LOG_ERR);
482 $this->error .= ($this->error ?
', '.$errmsg : $errmsg);
484 $this->db->rollback();
518 $object->context[
'createfromclone'] =
'createfromclone';
519 $result =
$object->create($user);
530 unset(
$object->context[
'createfromclone']);
537 $this->db->rollback();
582 $this->fk_donation = 0;
587 $this->fk_typepayment = 0;
588 $this->paymenttype = 0;
589 $this->num_payment =
'';
590 $this->note_public =
'Public note';
592 $this->fk_user_creat = 1;
593 $this->fk_user_modif = 1;
611 public function addPaymentToBank($user, $mode, $label, $accountid, $emetteur_nom, $emetteur_banque)
619 require_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/account.class.php';
622 $acc->fetch($accountid);
624 $total = $this->total;
625 if ($mode ==
'payment_donation') {
629 $bank_line_id = $acc->addline(
631 (
string) $this->paymenttype,
643 if ($bank_line_id > 0) {
652 if ($mode ==
'payment_donation') {
653 $url = DOL_URL_ROOT.
'/don/payment/card.php?rowid=';
656 $result = $acc->add_url_line($bank_line_id, $this->
id, $url,
'(paiement)', $mode);
663 $this->error = $acc->error;
686 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"payment_donation SET fk_bank = ".(int) $id_bank.
" WHERE rowid = ".(
int) $this->id;
688 dol_syslog(get_class($this).
"::update_fk_bank", LOG_DEBUG);
689 $result = $this->db->query($sql);
693 $this->error = $this->db->error();
707 global $langs, $hookmanager;
711 $label =
'<u>'.$langs->trans(
"DonationPayment").
'</u>';
713 $label .=
'<b>'.$langs->trans(
'Ref').
':</b> '.$this->ref;
715 if (!empty($this->
id)) {
716 $link =
'<a href="'.DOL_URL_ROOT.
'/don/payment/card.php?id='.$this->
id.
'" title="'.
dol_escape_htmltag($label, 1).
'" class="classfortooltip">';
720 $result .= ($link.img_object($label,
'payment',
'class="classfortooltip"').$linkend.
' ');
722 if ($withpicto && $withpicto != 2) {
725 if ($withpicto != 2) {
726 $result .= $link.($maxlen ?
dol_trunc($this->
ref, $maxlen) : $this->ref).$linkend;
731 $hookmanager->initHooks(array($this->element .
'dao'));
732 $parameters = array(
'id' => $this->
id,
'getnomurl' => &$result);
733 $reshook = $hookmanager->executeHooks(
'getNomUrl', $parameters, $this, $action);
735 $result = $hookmanager->resPrint;
737 $result .= $hookmanager->resPrint;
if(! $sortfield) if(! $sortorder) $object
Class to manage bank accounts.
Parent class of all other business classes (invoices, contracts, proposals, orders,...
setErrorsFromObject($object)
setErrorsFromObject
Class to manage payments of donations.
addPaymentToBank($user, $mode, $label, $accountid, $emetteur_nom, $emetteur_banque)
Add record into bank for payment with links between this bank record and invoices of payment.
initAsSpecimen()
Initialise an instance with random values.
create($user, $notrigger=0)
Create payment of donation into database.
LibStatut($status, $mode=0)
Return the label of a given status.
update_fk_bank($id_bank)
Update link between the donation payment and the generated line in llx_bank.
__construct($db)
Constructor.
getLibStatut($mode=0)
Return the label of the status.
createFromClone(User $user, $fromid)
Load an object from its id and create a new one in database.
fetch($id)
Load object in memory from database.
update($user, $notrigger=0)
Update database.
getNomUrl($withpicto=0, $maxlen=0)
Return clickable name (with picto eventually)
Class to manage Dolibarr users.
dol_now($mode='gmt')
Return date for now.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dol_trunc($string, $size=40, $trunc='right', $stringencoding='UTF-8', $nodot=0, $display=0)
Truncate a string to a particular length adding '…' if string larger than length.
isModEnabled($module)
Is Dolibarr module enabled.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
print $langs trans("Show") . '< td style="' . $timeColor . '" align="center"> s</td > badge status0 badge status4 badge status3 Error badge status8< td align="center">< span class="badge ' . $badge . '"></span ></td >< td align="center">< a href="#" class="button button-small" onclick="openLogModal(this)" data-req="' . dol_escape_htmltag($reqSafe) . '" data-res="' . dol_escape_htmltag($resSafe) . '" data-err="' . dol_escape_htmltag($errSafe) . '">< span class="fa fa-search-plus"></span ></a ></td ></tr >< tr >< td colspan="' . $colspan . '" class="opacitymedium"></td ></tr ></table ></div ></form > logModal none logModal none s a JSON string
buildzip.php
print $langs trans('Date')." left Ref Label right Qty right Price right TotalHT right TotalTTC right right right right right right right right right centpercent right TotalHT right n right VAT right n right TotalVAT right n No sujeto a RE IRPF right TotalLT1 right n right TotalLT2 right n right TotalTTC right n takeposcustomercurrency takeposcustomercurrency takeposcustomercurrency takeposcustomercurrency right TotalTTC takeposcustomercurrency right takeposcustomercurrency n right Paid right PaymentTypeShortLIQ right SELECT p pos_change as p datep as p p num_paiement as f pf amount as amount