29require_once DOL_DOCUMENT_ROOT.
'/core/modules/dons/modules_don.php';
30require_once DOL_DOCUMENT_ROOT.
'/don/class/don.class.php';
31require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
49 $this->
name =
"generic";
50 $this->
description = $langs->trans(
'DonationsReceiptModel').
'';
51 $this->option_multilang = 1;
74 if (!is_object($outputlangs)) {
76 $outputlangs = $langs;
79 $outputlangs->loadLangs(array(
"main",
"dict",
"companies",
"bills",
"products",
"donations"));
92 $formclass =
new Form($this->db);
96 $formclass->load_cache_types_paiements();
98 if ($don->mode_reglement_id) {
99 $paymentmode = $formclass->cache_types_paiements[$don->mode_reglement_id][
'label'];
117 global $user, $conf, $langs, $mysoc;
121 $currency = !empty($currency) ? $currency : $conf->currency;
123 $donmodel = DOL_DOCUMENT_ROOT.
"/core/modules/dons/html_generic.html";
124 $form = implode(
'', file($donmodel));
125 $form = str_replace(
'__NOW__',
dol_print_date($now,
'day',
false, $outputlangs), $form);
126 $form = str_replace(
'__REF__', $don->id, $form);
127 $form = str_replace(
'__DATE__',
dol_print_date($don->date,
'day',
false, $outputlangs), $form);
129 $form = str_replace(
'__BENEFICIARY_NAME__', $mysoc->name, $form);
130 $form = str_replace(
'__BENEFICIARY_FULL_ADDRESS__', $mysoc->getFullAddress(1,
"<br>", 1), $form);
133 $form = str_replace(
'__AMOUNT__',
price($don->amount), $form);
134 $form = str_replace(
'__CURRENCY_CODE__', $conf->currency, $form);
135 if (isModEnabled(
"societe") &&
getDolGlobalString(
'DONATION_USE_THIRDPARTIES') && $don->socid > 0 && $don->thirdparty) {
136 $form = str_replace(
'__DONOR_FULL_NAME__', $don->thirdparty->name, $form);
137 $form = str_replace(
'__DONOR_FULL_ADDRESS__', $don->thirdparty->getFullAddress(1,
", ", 1), $form);
139 $form = str_replace(
'__DONOR_FULL_NAME__', $don->getFullName($langs), $form);
140 $form = str_replace(
'__DONOR_FULL_ADDRESS__', $don->getFullAddress(1,
" ", 1), $form);
143 $form = str_replace(
'__DonationTitle__', $outputlangs->trans(
"DonationTitle"), $form);
144 $form = str_replace(
'__DonationRef__', $outputlangs->trans(
"DonationRef"), $form);
145 $form = str_replace(
'__Date__', $outputlangs->trans(
"Date"), $form);
146 $form = str_replace(
'__DonationDatePayment__', $outputlangs->trans(
"DonationDatePayment"), $form);
147 $form = str_replace(
'__Donor__', $outputlangs->trans(
"Donor"), $form);
148 $form = str_replace(
'__Amount__', $outputlangs->trans(
"Amount"), $form);
149 $form = str_replace(
'__PaymentMode__', $outputlangs->trans(
"PaymentMode"), $form);
152 if (
getDolGlobalInt(
'DONATION_NOTE_PUBLIC') >= 1 && !empty($don->note_public)) {
153 $notePublic =
'<div id="note-public"><p>'.$don->note_public.
'</p></div>';
155 $form = str_replace(
'__NOTE_PUBLIC__', $notePublic, $form);
157 $donationMessage =
'';
159 $donationMessage =
'<div id="donation-message"><p>' .
getDolGlobalString(
'DONATION_MESSAGE').
'</p></div>';
161 $form = str_replace(
'__DONATION_MESAGE__', $donationMessage, $form);
176 $handle = fopen($path,
"w");
177 fwrite($handle, $contents);
191 public function write_file($don, $outputlangs, $currency =
'')
194 global $user, $conf, $langs, $mysoc;
196 $id = (!is_object($don) ? $don :
'');
200 if (!empty($conf->don->dir_output)) {
202 if (!is_object($don)) {
203 $don =
new Don($this->db);
204 $ret = $don->fetch($id);
209 if (!empty($don->specimen)) {
210 $dir = $conf->don->dir_output;
211 $file = $dir.
"/SPECIMEN.html";
214 $dir = $conf->don->dir_output.
"/".$donref;
215 $file = $dir.
"/".$donref.
".html";
218 if (!file_exists($dir)) {
220 $this->error = $langs->trans(
"ErrorCanNotCreateDir", $dir);
225 if (file_exists($dir)) {
228 $this->result = array(
'fullpath'=>$file);
232 $this->error = $langs->trans(
"ErrorCanNotCreateDir", $dir);
236 $this->error = $langs->trans(
"ErrorConstantNotDefined",
"DON_OUTPUTDIR");
Class to manage donations.
Parent class of subscription templates.
Class to generate document for a generic donations receipt.
saveFile($path, $contents)
Write the object to document file to disk.
getDonationPaymentType($don)
Write the object to document file to disk.
__construct($db)
Constructor.
getContents($don, $outputlangs, $currency)
Get the contents of the file.
write_file($don, $outputlangs, $currency='')
Write the object to document file to disk.
isEnabled()
Return if a module can be used or not.
loadTranslationFiles($outputlangs)
Load translation files.
print $script_file $mode $langs defaultlang(is_numeric($duration_value) ? " delay=". $duration_value :"").(is_numeric($duration_value2) ? " after cd cd cd description as description
Only used if Module[ID]Desc translation string is not found.
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dolChmod($filepath, $newmask='')
Change mod of a file.
dol_now($mode='auto')
Return date for now.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
dol_mkdir($dir, $dataroot='', $newmask='')
Creation of a directory (this can create recursive subdir)
if(preg_match('/crypted:/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
$conf db name
Only used if Module[ID]Name translation string is not found.