33require_once DOL_DOCUMENT_ROOT.
'/core/class/commonobject.class.php';
34require_once DOL_DOCUMENT_ROOT.
'/core/class/commonpeople.class.php';
47 public $element =
'don';
52 public $table_element =
'don';
57 public $fk_element =
'fk_donation';
62 public $picto =
'donation';
128 public $phone_mobile;
133 public $mode_reglement;
138 public $mode_reglement_code;
153 public $fk_typepayment;
164 public $modepaymentid = 0;
176 const STATUS_DRAFT = 0;
177 const STATUS_VALIDATED = 1;
178 const STATUS_PAID = 2;
179 const STATUS_CANCELED = -1;
191 $this->ismultientitymanaged = 1;
217 if (empty($this->labelStatus) || empty($this->labelStatusShort)) {
219 $langs->load(
"donations");
220 $this->labelStatus[-1] = $langs->transnoentitiesnoconv(
"Canceled");
221 $this->labelStatus[0] = $langs->transnoentitiesnoconv(
"DonationStatusPromiseNotValidated");
222 $this->labelStatus[1] = $langs->transnoentitiesnoconv(
"DonationStatusPromiseValidated");
223 $this->labelStatus[2] = $langs->transnoentitiesnoconv(
"DonationStatusPaid");
224 $this->labelStatusShort[-1] = $langs->transnoentitiesnoconv(
"Canceled");
225 $this->labelStatusShort[0] = $langs->transnoentitiesnoconv(
"DonationStatusPromiseNotValidatedShort");
226 $this->labelStatusShort[1] = $langs->transnoentitiesnoconv(
"DonationStatusPromiseValidatedShort");
227 $this->labelStatusShort[2] = $langs->transnoentitiesnoconv(
"DonationStatusPaidShort");
230 $statusType =
'status'.$status;
231 if ($status == self::STATUS_CANCELED) {
232 $statusType =
'status9';
234 if ($status == self::STATUS_PAID) {
235 $statusType =
'status6';
238 return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status],
'', $statusType, $mode);
258 $sql =
"SELECT rowid";
259 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe";
260 $sql .=
" WHERE client IN (1, 3)";
261 $sql .=
" AND entity = ".$conf->entity;
264 $resql = $this->db->query($sql);
266 $num_socs = $this->db->num_rows($resql);
268 while ($i < $num_socs) {
269 $row = $this->db->fetch_row($resql);
270 $socids[$i] = $row[0];
278 $this->
ref =
'SPECIMEN';
280 $this->lastname =
'Doe';
281 $this->firstname =
'John';
282 $this->socid = empty($socids[0]) ? 0 : $socids[0];
284 $this->date_valid = $now;
285 $this->amount = 100.90;
287 $this->societe =
'The Company';
289 $this->zip =
'99999';
290 $this->town =
'Town';
291 $this->note_private =
'Private note';
292 $this->note_public =
'Public note';
293 $this->
email =
'email@email.com';
294 $this->phone =
'0123456789';
295 $this->phone_mobile =
'0606060606';
312 $langs->load(
'main');
313 $langs->load(
'companies');
315 $error_string = array();
321 $error_string[] = $langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
'Company').
'/'.$langs->transnoentitiesnoconv(
'Firstname').
'-'.$langs->transnoentitiesnoconv(
'Lastname'));
327 $error_string[] = $langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
'Address'));
332 $error_string[] = $langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
'Zip'));
337 $error_string[] = $langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
'Town'));
342 $error_string[] = $langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
'EMail'));
346 $this->amount = (float) $this->amount;
350 for ($i = 0; $i < $len; $i++) {
351 if (!isset($map[substr((
string) $this->amount, $i, 1)])) {
352 $error_string[] = $langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
'Amount'));
359 if (!$amount_invalid) {
360 if ($this->amount == 0) {
361 $error_string[] = $langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
'Amount'));
364 if ($this->amount < $minimum && $minimum > 0) {
365 $error_string[] = $langs->trans(
'MinimumAmount', $minimum);
372 $this->errors = $error_string;
387 public function create($user, $notrigger = 0)
389 global
$conf, $langs;
401 $this->amount = (float)
price2num($this->amount);
404 if ($this->amount < 0) {
405 $this->error = $langs->trans(
'FieldCannotBeNegative', $langs->transnoentitiesnoconv(
"Amount"));
411 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"don (";
415 $sql .=
", fk_payment";
417 $sql .=
", firstname";
418 $sql .=
", lastname";
423 $sql .=
", fk_country";
425 $sql .=
", fk_projet";
426 $sql .=
", note_private";
427 $sql .=
", note_public";
428 $sql .=
", fk_user_author";
429 $sql .=
", fk_user_valid";
433 $sql .=
", phone_mobile";
435 $sql .=
") VALUES (";
436 $sql .=
"'".$this->db->idate($this->date ? $this->date : $now).
"'";
437 $sql .=
", ".((int)
$conf->entity);
438 $sql .=
", ".((float) $this->amount);
439 $sql .=
", ".($this->modepaymentid ? $this->modepaymentid :
"null");
440 $sql .=
", ".($this->socid > 0 ? $this->socid :
"null");
441 $sql .=
", '".$this->db->escape($this->firstname).
"'";
442 $sql .=
", '".$this->db->escape($this->lastname).
"'";
443 $sql .=
", '".$this->db->escape($this->societe).
"'";
444 $sql .=
", '".$this->db->escape($this->
address).
"'";
445 $sql .=
", '".$this->db->escape($this->zip).
"'";
446 $sql .=
", '".$this->db->escape($this->town).
"'";
447 $sql .=
", ".(int) ($this->country_id > 0 ? $this->country_id : 0);
448 $sql .=
", ".(int) $this->
public;
449 $sql .=
", ".($this->fk_project > 0 ? (int) $this->fk_project :
"null");
450 $sql .=
", ".(!empty($this->note_private) ? (
"'".$this->db->escape($this->note_private).
"'") :
"NULL");
451 $sql .=
", ".(!empty($this->note_public) ? (
"'".$this->db->escape($this->note_public).
"'") :
"NULL");
452 $sql .=
", ".((int) $user->id);
454 $sql .=
", '".$this->db->idate($this->date).
"'";
455 $sql .=
", '".(!empty($this->
email) ? $this->db->escape(trim($this->
email)) :
"").
"'";
456 $sql .=
", '".(!empty($this->phone) ? $this->db->escape(trim($this->phone)) :
"").
"'";
457 $sql .=
", '".(!empty($this->phone_mobile) ? $this->db->escape(trim($this->phone_mobile)) :
"").
"'";
458 $sql .=
", '".(!empty($this->ip) ? $this->db->escape($this->ip) :
"null").
"'";
461 $resql = $this->db->query($sql);
463 $this->
id = $this->db->last_insert_id(MAIN_DB_PREFIX.
"don");
475 $this->error = $this->db->lasterror();
496 $this->db->rollback();
508 public function update($user, $notrigger = 0)
520 $this->amount = (float)
price2num($this->amount);
523 if ($this->amount < 0) {
524 $this->error = $langs->trans(
'FieldCannotBeNegative', $langs->transnoentitiesnoconv(
"Amount"));
530 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"don SET";
531 $sql .=
" amount = ".((float) $this->amount);
532 $sql .=
", fk_payment = ".($this->modepaymentid ? $this->modepaymentid :
"null");
533 $sql .=
", firstname = '".$this->db->escape($this->firstname).
"'";
534 $sql .=
", lastname='".$this->db->escape($this->lastname).
"'";
535 $sql .=
", societe='".$this->db->escape($this->societe).
"'";
536 $sql .=
", address='".$this->db->escape($this->
address).
"'";
537 $sql .=
", zip='".$this->db->escape($this->zip).
"'";
538 $sql .=
", town='".$this->db->escape($this->town).
"'";
539 $sql .=
", fk_country = ".($this->country_id > 0 ? ((int) $this->country_id) :
'0');
540 $sql .=
", public=".((int) $this->
public);
541 $sql .=
", fk_projet=".($this->fk_project > 0 ? $this->fk_project :
'null');
542 $sql .=
", note_private=".(!empty($this->note_private) ? (
"'".$this->db->escape($this->note_private).
"'") :
"NULL");
543 $sql .=
", note_public=".(!empty($this->note_public) ? (
"'".$this->db->escape($this->note_public).
"'") :
"NULL");
544 $sql .=
", datedon='".$this->db->idate($this->date).
"'";
545 $sql .=
", date_valid=".($this->date_valid ?
"'".$this->db->idate($this->date).
"'" :
"null");
546 $sql .=
", email='".$this->db->escape(trim($this->
email)).
"'";
547 $sql .=
", phone='".$this->db->escape(trim($this->phone)).
"'";
548 $sql .=
", phone_mobile='".$this->db->escape(trim($this->phone_mobile)).
"'";
549 $sql .=
", fk_statut=".((int) $this->
status);
550 $sql .=
" WHERE rowid = ".((int) $this->
id);
552 dol_syslog(get_class($this).
"::Update", LOG_DEBUG);
553 $resql = $this->db->query($sql);
576 $this->db->rollback();
580 $this->error = $this->db->lasterror();
581 $this->errors[] = $this->error;
582 $this->db->rollback();
583 dol_syslog(get_class($this).
"::Update error -2 ".$this->error, LOG_ERR);
596 public function delete($user, $notrigger = 0)
598 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
616 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"don_extrafields";
617 $sql .=
" WHERE fk_object = ".((int) $this->
id);
619 $resql = $this->db->query($sql);
621 $this->errors[] = $this->db->lasterror();
627 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"don";
628 $sql .=
" WHERE rowid=".((int) $this->
id);
630 $resql = $this->db->query($sql);
632 $this->errors[] = $this->db->lasterror();
638 $dir = DOL_DATA_ROOT.
'/'.$this->element.
'/'.$this->ref;
642 $this->errors[] = $this->error;
652 foreach ($this->errors as $errmsg) {
653 dol_syslog(get_class($this).
"::delete ".$errmsg, LOG_ERR);
654 $this->error .= ($this->error ?
', '.$errmsg : $errmsg);
656 dol_syslog(get_class($this).
"::delete ".$this->error, LOG_ERR);
657 $this->db->rollback();
669 public function fetch($id, $ref =
'')
671 $sql =
"SELECT d.rowid, d.datec, d.date_valid, d.tms as datem, d.datedon,";
672 $sql .=
" d.fk_soc as socid, d.firstname, d.lastname, d.societe, d.amount, d.fk_statut as status, d.address, d.zip, d.town, ";
673 $sql .=
" d.fk_country, d.public, d.amount, d.fk_payment, d.paid, d.note_private, d.note_public, d.email, d.phone, ";
674 $sql .=
" d.phone_mobile, d.fk_projet as fk_project, d.model_pdf,";
675 $sql .=
" p.ref as project_ref,";
676 $sql .=
" cp.libelle as payment_label, cp.code as payment_code,";
677 $sql .=
" c.code as country_code, c.label as country";
678 $sql .=
" FROM ".MAIN_DB_PREFIX.
"don as d";
679 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"projet as p ON p.rowid = d.fk_projet";
680 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_paiement as cp ON cp.id = d.fk_payment";
681 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_country as c ON d.fk_country = c.rowid";
682 $sql .=
" WHERE d.entity IN (".getEntity(
'donation').
")";
684 $sql .=
" AND d.rowid=".((int) $id);
685 } elseif (!empty($ref)) {
686 $sql .=
" AND d.ref='".$this->db->escape($ref).
"'";
689 dol_syslog(get_class($this).
"::fetch", LOG_DEBUG);
690 $resql = $this->db->query($sql);
692 if ($this->db->num_rows($resql)) {
693 $obj = $this->db->fetch_object($resql);
695 $this->
id = $obj->rowid;
696 $this->
ref = $obj->rowid;
697 $this->date_creation = $this->db->jdate($obj->datec);
698 $this->datec = $this->db->jdate($obj->datec);
699 $this->date_validation = $this->db->jdate($obj->date_valid);
700 $this->date_valid = $this->db->jdate($obj->date_valid);
701 $this->date_modification = $this->db->jdate($obj->datem);
702 $this->datem = $this->db->jdate($obj->datem);
703 $this->date = $this->db->jdate($obj->datedon);
704 $this->socid = $obj->socid;
705 $this->firstname = $obj->firstname;
706 $this->lastname = $obj->lastname;
707 $this->societe = $obj->societe;
708 $this->
status = $obj->status;
709 $this->statut = $obj->status;
710 $this->
address = $obj->address;
711 $this->zip = $obj->zip;
712 $this->town = $obj->town;
713 $this->country_id = $obj->fk_country;
714 $this->country_code = $obj->country_code;
715 $this->country = $obj->country;
716 $this->
email = $obj->email;
717 $this->phone = $obj->phone;
718 $this->phone_mobile = $obj->phone_mobile;
719 $this->project = $obj->project_ref;
720 $this->fk_projet = $obj->fk_project;
721 $this->fk_project = $obj->fk_project;
722 $this->
public = $obj->public;
723 $this->mode_reglement_id = $obj->fk_payment;
724 $this->mode_reglement_code = $obj->payment_code;
725 $this->mode_reglement = $obj->payment_label;
726 $this->paid = $obj->paid;
727 $this->amount = $obj->amount;
728 $this->note_private = $obj->note_private;
729 $this->note_public = $obj->note_public;
730 $this->model_pdf = $obj->model_pdf;
774 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"don SET fk_statut = 1, fk_user_valid = ".((int) $userid).
" WHERE rowid = ".((int) $id).
" AND fk_statut = 0";
776 $resql = $this->db->query($sql);
778 if ($this->db->affected_rows($resql)) {
790 $this->error = $this->db->lasterror();
798 $this->db->rollback();
810 public function setPaid($id, $modepayment = 0)
812 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"don SET fk_statut = 2, paid = 1";
814 $sql .=
", fk_payment = ".((int) $modepayment);
816 $sql .=
" WHERE rowid = ".((int) $id).
" AND fk_statut = 1";
818 $resql = $this->db->query($sql);
820 if ($this->db->affected_rows($resql)) {
843 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"don SET fk_statut = -1 WHERE rowid = ".((int) $id);
845 $resql = $this->db->query($sql);
847 if ($this->db->affected_rows($resql)) {
866 public function reopen($user, $notrigger = 0)
869 if ($this->
status != self::STATUS_CANCELED && $this->
status != self::STATUS_PAID) {
872 if ($this->statut == self::STATUS_PAID) {
873 $sql =
"UPDATE " . MAIN_DB_PREFIX .
"don SET paid = 0 WHERE rowid = " . ((int) $this->
id);
875 $resql = $this->db->query($sql);
877 if ($this->db->affected_rows($resql)) {
886 return $this->
setStatusCommon($user, self::STATUS_VALIDATED, $notrigger,
'DON_REOPEN');
903 $sql =
"SELECT sum(amount) as total";
904 $sql .=
" FROM ".MAIN_DB_PREFIX.
"don";
905 $sql .=
" WHERE fk_statut = ".((int) $param);
906 $sql .=
" AND entity = ".$conf->entity;
908 $resql = $this->db->query($sql);
910 $obj = $this->db->fetch_object($resql);
911 $result = $obj->total;
926 $sql =
"SELECT count(d.rowid) as nb";
927 $sql .=
" FROM ".MAIN_DB_PREFIX.
"don as d";
928 $sql .=
" WHERE d.fk_statut > 0";
929 $sql .=
" AND d.entity IN (".getEntity(
'donation').
")";
931 $resql = $this->db->query($sql);
933 while ($obj = $this->db->fetch_object($resql)) {
934 $this->nb[
"donations"] = $obj->nb;
936 $this->db->free($resql);
940 $this->error = $this->db->error();
954 public function getNomUrl($withpicto = 0, $notooltip = 0, $moretitle =
'', $save_lastsearch_value = -1)
956 global
$conf, $langs, $hookmanager;
958 if (!empty(
$conf->dol_no_mouse_hover)) {
963 $label =
img_picto(
'', $this->picto).
' <u class="paddingrightonly">'.$langs->trans(
"Donation").
'</u>';
964 if (isset($this->
status)) {
965 $label .=
' '.$this->getLibStatut(5);
967 if (!empty($this->
id)) {
968 $label .=
'<br><b>'.$langs->trans(
'Ref').
':</b> '.$this->id;
969 $label .=
'<br><b>'.$langs->trans(
'Date').
':</b> '.
dol_print_date($this->date,
'day');
972 $label .=
' - '.$moretitle;
975 $url = DOL_URL_ROOT.
'/don/card.php?id='.$this->id;
977 $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
978 if ($save_lastsearch_value == -1 && isset($_SERVER[
"PHP_SELF"]) && preg_match(
'/list\.php/', $_SERVER[
"PHP_SELF"])) {
979 $add_save_lastsearch_values = 1;
981 if ($add_save_lastsearch_values) {
982 $url .=
'&save_lastsearch_values=1';
985 $linkstart =
'<a href="'.$url.
'" title="'.
dol_escape_htmltag($label, 1).
'" class="classfortooltip">';
988 $result .= $linkstart;
990 $result .=
img_object(($notooltip ?
'' : $label), $this->picto, ($notooltip ? (($withpicto != 2) ?
'class="paddingright"' :
'') :
'class="'.(($withpicto != 2) ?
'paddingright ' :
'').
'classfortooltip"'), 0, 0, $notooltip ? 0 : 1);
992 if ($withpicto != 2) {
993 $result .= $this->ref;
997 $hookmanager->initHooks(array($this->element .
'dao'));
998 $parameters = array(
'id' => $this->
id,
'getnomurl' => &$result);
999 $reshook = $hookmanager->executeHooks(
'getNomUrl', $parameters, $this, $action);
1001 $result = $hookmanager->resPrint;
1003 $result .= $hookmanager->resPrint;
1016 $sql =
'SELECT d.rowid, d.datec, d.fk_user_author, d.fk_user_valid,';
1017 $sql .=
' d.tms as datem';
1018 $sql .=
' FROM '.MAIN_DB_PREFIX.
'don as d';
1019 $sql .=
' WHERE d.rowid = '.((int) $id);
1021 dol_syslog(get_class($this).
'::info', LOG_DEBUG);
1022 $result = $this->db->query($sql);
1025 if ($this->db->num_rows($result)) {
1026 $obj = $this->db->fetch_object($result);
1027 $this->
id = $obj->rowid;
1029 $this->user_creation_id = $obj->fk_user_author;
1030 $this->user_validation_id = $obj->fk_user_valid;
1031 $this->date_creation = $this->db->jdate($obj->datec);
1032 $this->date_modification = (!empty($obj->tms) ? $this->db->jdate($obj->tms) :
"");
1034 $this->db->free($result);
1051 public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0)
1053 global
$conf, $langs;
1055 $langs->load(
"bills");
1058 $modele =
'html_cerfafr';
1060 if ($this->model_pdf) {
1061 $modele = $this->model_pdf;
1073 $err = error_reporting();
1075 @set_time_limit(120);
1076 error_reporting($err);
1078 $srctemplatepath =
'';
1081 $tmp = explode(
':', $modele, 2);
1082 if (!empty($tmp[1])) {
1084 $srctemplatepath = $tmp[1];
1091 $dirmodels = array(
'/');
1092 if (is_array(
$conf->modules_parts[
'models'])) {
1093 $dirmodels = array_merge($dirmodels,
$conf->modules_parts[
'models']);
1095 foreach ($dirmodels as $reldir) {
1096 foreach (array(
'html',
'doc',
'pdf') as $prefix) {
1097 $file = $prefix.
"_".preg_replace(
'/^html_/',
'', $modele).
".modules.php";
1100 $file =
dol_buildpath($reldir.
"core/modules/dons/".$file, 0);
1101 if (file_exists($file)) {
1103 $classname = $prefix.
'_'.$modele;
1118 $classname = $modele;
1119 $obj =
new $classname($this->db);
1121 '@phan-var-force ModeleDon $obj';
1125 $sav_charset_output = $outputlangs->charset_output;
1126 if ($obj->write_file(
$object, $outputlangs, $srctemplatepath, $hidedetails, $hidedesc, $hideref) > 0) {
1127 $outputlangs->charset_output = $sav_charset_output;
1130 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
1134 $outputlangs->charset_output = $sav_charset_output;
1140 print $langs->trans(
"Error").
" ".$langs->trans(
"ErrorFileDoesNotExists", $file);
1171 if (empty($this->
id)) {
1172 $this->error =
'Missing object id';
1173 $this->errors[] = $this->error;
1174 dol_syslog(__METHOD__.
' : '.$this->error, LOG_ERR);
1178 $sql =
"SELECT SUM(amount) as sum_amount FROM ".MAIN_DB_PREFIX.
"payment_donation WHERE fk_donation = ".((int) $this->
id);
1179 $resql = $this->db->query($sql);
1184 $sum_amount = (float) $this->db->fetch_object($resql)->sum_amount;
1185 return (
float) ($this->amount - $sum_amount);
1198 global
$conf, $langs;
1200 $selected = (empty($arraydata[
'selected']) ? 0 : $arraydata[
'selected']);
1202 $return =
'<div class="box-flex-item box-flex-grow-zero">';
1203 $return .=
'<div class="info-box info-box-sm">';
1204 $return .=
'<span class="info-box-icon bg-infobox-action">';
1206 $return .=
'</span>';
1207 $return .=
'<div class="info-box-content">';
1208 $return .=
'<span class="info-box-ref inline-block tdoverflowmax150 valignmiddle">' . $this->
getNomUrl(1) .
'</span>';
1209 if ($selected >= 0) {
1210 $return .=
'<input id="cb'.$this->id.
'" class="flat checkforselect fright" type="checkbox" name="toselect[]" value="'.$this->
id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
1213 $return .=
' | <span class="info-box-label">'.dol_print_date($this->date,
'day',
'tzuserrel').
'</span>';
1215 if (!empty($this->societe)) {
1216 $return .=
'<br><span class="opacitymedium">'.$langs->trans(
"Company").
'</span> : <span class="info-box-label">'.$this->societe.
'</span>';
1218 if (!empty($this->amount)) {
1219 $return .=
'<br><span class="info-box-label amount">'.price($this->amount, 1, $langs, 1, -1, -1,
$conf->currency).
'</span>';
1221 if (isset($this->
status)) {
1222 $return .=
'<br><div class="info-box-status">'.$this->getLibStatut(3).
'</div>';
1224 $return .=
'</div>';
1225 $return .=
'</div>';
1226 $return .=
'</div>';
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Parent class of all other business classes (invoices, contracts, proposals, orders,...
fetch_optionals($rowid=null, $optionsArray=null)
Function to get extra fields of an object into $this->array_options This method is in most cases call...
deleteEcmFiles($mode=0)
Delete related files of object in database.
setStatusCommon($user, $status, $notrigger=0, $triggercode='')
Set to a status.
static commonReplaceThirdparty(DoliDB $dbs, $origin_id, $dest_id, array $tables, $ignoreerrors=0)
Function used to replace a thirdparty id with another one.
insertExtraFields($trigger='', $userused=null)
Add/Update all extra fields values for the current object.
call_trigger($triggerName, $user)
Call trigger based on this instance.
Class to manage Dolibarr database access.
Class to manage donations.
getLibStatut($mode=0)
Returns the donation status label (draft, valid, abandoned, paid)
__construct($db)
Constructor.
initAsSpecimen()
Initialise an instance with random values.
create($user, $notrigger=0)
Create donation record into database.
getRemainToPay()
Function to get remaining amount to pay for a donation.
check($minimum=0)
Check params and init ->errors array.
setValid($user, $notrigger=0)
Validate a intervention.
valid_promesse($id, $userid, $notrigger=0)
Validate a promise of donation.
getKanbanView($option='', $arraydata=null)
Return clickable link of object (with eventually picto)
LibStatut($status, $mode=0)
Return the label of a given status.
static replaceThirdparty(DoliDB $dbs, $origin_id, $dest_id)
Function used to replace a thirdparty id with another one.
fetch($id, $ref='')
Load donation from database.
reopen($user, $notrigger=0)
Set cancel status.
sum_donations($param)
Sum of donations.
info($id)
Information on record.
update($user, $notrigger=0)
Update a donation record.
set_cancel($id)
Set donation to status cancelled.
loadStateBoard()
Load the indicators this->nb for the state board.
setPaid($id, $modepayment=0)
Classify the donation as paid, the donation was received.
getNomUrl($withpicto=0, $notooltip=0, $moretitle='', $save_lastsearch_value=-1)
Return clickable name (with picto eventually)
print $langs trans("Ref").' m titre as m m statut as status
Or an array listing all the potential status of the object: array: int of the status => translated la...
print $script_file $mode $langs defaultlang(is_numeric($duration_value) ? " delay=". $duration_value :"").(is_numeric($duration_value2) ? " after cd cd cd description as p label as s rowid as s nom as s email
Sender: Who sends the email ("Sender" has sent emails on behalf of "From").
dol_delete_dir_recursive($dir, $count=0, $nophperrors=0, $onlysub=0, &$countdeleted=0, $indexdatabase=1, $nolog=0, $level=0)
Remove a directory $dir and its subdirectories (or only files and subdirectories)
dol_is_dir($folder)
Test if filename is a directory.
dol_delete_preview($object)
Delete all preview files linked to object instance.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
isDolTms($timestamp)
isDolTms check if a timestamp is valid.
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $allowothertags=array())
Show a picto called object_picto (generic function)
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
dol_now($mode='auto')
Return date for now.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dolGetStatus($statusLabel='', $statusLabelShort='', $html='', $statusType='status0', $displayMode=0, $url='', $params=array())
Output the badge of a status.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
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...
div refaddress div address
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...