30require_once DOL_DOCUMENT_ROOT.
'/core/modules/dons/modules_don.php';
31require_once DOL_DOCUMENT_ROOT.
'/don/class/don.class.php';
32require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
50 $this->
name =
"generic";
51 $this->
description = $langs->trans(
'DonationsReceiptModel').
'';
52 $this->option_multilang = 1;
75 if (!is_object($outputlangs)) {
77 $outputlangs = $langs;
80 $outputlangs->loadLangs(array(
"main",
"dict",
"companies",
"bills",
"products",
"donations"));
93 $formclass =
new Form($this->db);
97 $formclass->load_cache_types_paiements();
99 if ($don->mode_reglement_id) {
100 $paymentmode = $formclass->cache_types_paiements[$don->mode_reglement_id][
'label'];
118 global $user, $conf, $langs, $mysoc;
122 $currency = !empty($currency) ? $currency : $conf->currency;
124 $donmodel = DOL_DOCUMENT_ROOT.
"/core/modules/dons/html_generic.html";
125 $form = implode(
'', file($donmodel));
126 $form = str_replace(
'__NOW__',
dol_print_date($now,
'day',
false, $outputlangs), $form);
127 $form = str_replace(
'__REF__', (
string) $don->id, $form);
128 $form = str_replace(
'__DATE__',
dol_print_date($don->date,
'day',
false, $outputlangs), $form);
130 $form = str_replace(
'__BENEFICIARY_NAME__', $mysoc->name, $form);
131 $form = str_replace(
'__BENEFICIARY_FULL_ADDRESS__', $mysoc->getFullAddress(1,
"<br>", 1), $form);
134 $form = str_replace(
'__AMOUNT__',
price($don->amount), $form);
135 $form = str_replace(
'__CURRENCY_CODE__', $conf->currency, $form);
136 if (isModEnabled(
"societe") &&
getDolGlobalString(
'DONATION_USE_THIRDPARTIES') && $don->socid > 0 && $don->thirdparty) {
137 $form = str_replace(
'__DONOR_FULL_NAME__', $don->thirdparty->name, $form);
138 $form = str_replace(
'__DONOR_FULL_ADDRESS__', $don->thirdparty->getFullAddress(1,
", ", 1), $form);
140 $form = str_replace(
'__DONOR_FULL_NAME__', $don->getFullName($langs), $form);
141 $form = str_replace(
'__DONOR_FULL_ADDRESS__', $don->getFullAddress(1,
" ", 1), $form);
144 $form = str_replace(
'__DonationTitle__', $outputlangs->trans(
"DonationTitle"), $form);
145 $form = str_replace(
'__DonationRef__', $outputlangs->trans(
"DonationRef"), $form);
146 $form = str_replace(
'__Date__', $outputlangs->trans(
"Date"), $form);
147 $form = str_replace(
'__DonationDatePayment__', $outputlangs->trans(
"DonationDatePayment"), $form);
148 $form = str_replace(
'__Donor__', $outputlangs->trans(
"Donor"), $form);
149 $form = str_replace(
'__Amount__', $outputlangs->trans(
"Amount"), $form);
150 $form = str_replace(
'__PaymentMode__', $outputlangs->trans(
"PaymentMode"), $form);
153 if (
getDolGlobalInt(
'DONATION_NOTE_PUBLIC') >= 1 && !empty($don->note_public)) {
154 $notePublic =
'<div id="note-public"><p>'.$don->note_public.
'</p></div>';
156 $form = str_replace(
'__NOTE_PUBLIC__', $notePublic, $form);
158 $donationMessage =
'';
160 $donationMessage =
'<div id="donation-message"><p>' .
getDolGlobalString(
'DONATION_MESSAGE').
'</p></div>';
162 $form = str_replace(
'__DONATION_MESAGE__', $donationMessage, $form);
177 $handle = fopen($path,
"w");
178 fwrite($handle, $contents);
194 public function write_file($don, $outputlangs, $currency =
'')
197 global $user, $conf, $langs, $mysoc;
199 $id = (!is_object($don) ? $don :
'');
203 if (!empty($conf->don->dir_output)) {
205 if (!is_object($don)) {
206 $don =
new Don($this->db);
207 $ret = $don->fetch(
$id);
212 if (!empty($don->specimen)) {
213 $dir = $conf->don->dir_output;
214 $file = $dir.
"/SPECIMEN.html";
217 $dir = $conf->don->dir_output.
"/".$donref;
218 $file = $dir.
"/".$donref.
".html";
221 if (!file_exists($dir)) {
223 $this->error = $langs->trans(
"ErrorCanNotCreateDir", $dir);
228 if (file_exists($dir)) {
231 $this->result = array(
'fullpath' => $file);
235 $this->error = $langs->trans(
"ErrorCanNotCreateDir", $dir);
239 $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.
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_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
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_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.