30require
'../../main.inc.php';
39require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
40require_once DOL_DOCUMENT_ROOT.
'/core/lib/donation.lib.php';
41require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
42require_once DOL_DOCUMENT_ROOT.
'/don/class/don.class.php';
43require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
45 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formaccounting.class.php';
49$langs->loadLangs(array(
'admin',
'donations',
'accountancy',
'other'));
55$action =
GETPOST(
'action',
'aZ09');
57$label =
GETPOST(
'label',
'alpha');
58$scandir =
GETPOST(
'scan_dir',
'alpha');
62$dirmodels = array_merge(array(
'/'), (array)
$conf->modules_parts[
'models']);
70if ($action ==
'specimen') {
71 $modele =
GETPOST(
'module',
'alpha');
74 $don->initAsSpecimen();
79 foreach ($dirmodels as $reldir) {
81 if (file_exists($file)) {
90 $classname = (string) $modele;
91 $obj =
new $classname($db);
92 '@phan-var-force ModeleDon $obj';
95 if ($obj->write_file($don, $langs) > 0) {
97 $specimenfile = empty($obj->result[
'fullpath']) ?
'SPECIMEN.html' : basename($obj->result[
'fullpath']);
98 header(
"Location: ".DOL_URL_ROOT.
"/document.php?modulepart=donation&file=".urlencode($specimenfile));
101 setEventMessages($obj->error, $obj->errors,
'errors');
105 setEventMessages($langs->trans(
"ErrorModuleNotFound"),
null,
'errors');
106 dol_syslog($langs->trans(
"ErrorModuleNotFound"), LOG_ERR);
108} elseif ($action ==
'setdoc') {
113 $conf->global->DON_ADDON_MODEL = $value;
121} elseif ($action ==
'set') {
124} elseif ($action ==
'del') {
134if ($action ==
'set_DONATION_ACCOUNTINGACCOUNT') {
135 $account =
GETPOST(
'DONATION_ACCOUNTINGACCOUNT',
'alpha');
144 setEventMessages($langs->trans(
"SetupSaved"),
null,
'mesgs');
147 setEventMessages($langs->trans(
"Error"),
null,
'errors');
152if ($action ==
'set_DONATION_MESSAGE') {
153 $freemessage =
GETPOST(
'DONATION_MESSAGE',
'restricthtml');
162 setEventMessages($langs->trans(
"SetupSaved"),
null,
'mesgs');
165 setEventMessages($langs->trans(
"Error"),
null,
'errors');
172if (preg_match(
'/set_([a-z0-9_\-]+)/i', $action, $reg)) {
175 header(
"Location: ".$_SERVER[
"PHP_SELF"]);
178 dol_print_error($db);
182if (preg_match(
'/del_([a-z0-9_\-]+)/i', $action, $reg)) {
185 header(
"Location: ".$_SERVER[
"PHP_SELF"]);
188 dol_print_error($db);
196$form =
new Form($db);
200 $formaccounting =
null;
204llxHeader(
'', $langs->trans(
"DonationsSetup"), $help_url,
'', 0, 0,
'',
'',
'',
'mod-donation page-admin');
206$linkback =
'<a href="'.dolBuildUrl(DOL_URL_ROOT.
'/admin/modules.php', [
'restore_lastsearch_values' => 1]).
'">'.img_picto($langs->trans(
"BackToModuleList"),
'back',
'class="pictofixedwidth"').
'<span class="hideonsmartphone">'.$langs->trans(
"BackToModuleList").
'</span></a>';
207print
load_fiche_titre($langs->trans(
"DonationsSetup"), $linkback,
'title_setup');
221$sql .=
" FROM ".MAIN_DB_PREFIX.
"document_model";
222$sql .=
" WHERE type = '".$db->escape($type).
"'";
223$resql = $db->query($sql);
226 $num_rows = $db->num_rows($resql);
227 while ($i < $num_rows) {
228 $array = $db->fetch_array($resql);
229 if (is_array($array)) {
230 array_push($def, $array[0]);
235 dol_print_error($db);
238print
'<table class="noborder centpercent">';
239print
'<tr class="liste_titre">';
240print
'<td>'.$langs->trans(
"Name").
'</td>';
241print
'<td>'.$langs->trans(
"Description").
'</td>';
242print
'<td class="center" width="60">'.$langs->trans(
"Activated").
'</td>';
243print
'<td class="center" width="60">'.$langs->trans(
"Default").
'</td>';
244print
'<td class="center" width="80">'.$langs->trans(
"ShortInfo").
'</td>';
245print
'<td class="center" width="80">'.$langs->trans(
"Preview").
'</td>';
252foreach ($dirmodels as $reldir) {
255 foreach (
dol_dir_list($dir,
'files', 0,
'\.modules\.php$',
'',
'name', SORT_ASC, 0, 1) as $tmpfile) {
256 if (!isset($filelist[$tmpfile[
'name']])) {
257 $filelist[$tmpfile[
'name']] = $tmpfile[
'fullname'];
263if (count($filelist)) {
264 $arrayofmodels = array();
266 foreach ($filelist as $file => $fullpath) {
267 if (preg_match(
'/\.modules\.php$/i', $file)) {
271 require_once $fullpath;
273 '@phan-var-force ModeleDon $module';
285 $arrayofmodels[$name] =
$module;
292 '@phan-var-force array<string,ModeleDon> $arrayofmodels';
294 foreach ($arrayofmodels as $name =>
$module) {
295 print
'<tr class="oddeven"><td width=\"100\">';
303 if (in_array($name, $def)) {
305 print
"<td class=\"center\">\n";
306 print img_picto($langs->trans(
"Enabled"),
'switch_on');
309 print
"<td class=\"center\">\n";
310 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=del&token='.
newToken().
'&value='.urlencode($name).
'&scan_dir='.urlencode(
$module->scandir).
'&label='.urlencode(
$module->name).
'">'.img_picto($langs->trans(
"Enabled"),
'switch_on').
'</a>';
314 print
"<td class=\"center\">\n";
315 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=set&token='.
newToken().
'&value='.urlencode($name).
'&scan_dir='.urlencode(
$module->scandir).
'&label='.urlencode(
$module->name).
'">'.img_picto($langs->trans(
"Disabled"),
'switch_off').
'</a>';
321 print
"<td class=\"center\">";
322 print img_picto($langs->trans(
"Default"),
'on');
325 print
"<td class=\"center\">";
326 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=setdoc&token='.
newToken().
'&value='.urlencode($name).
'&scan_dir='.urlencode(
$module->scandir).
'&label='.urlencode(
$module->name).
'" alt="'.$langs->trans(
"Default").
'">'.img_picto($langs->trans(
"Disabled"),
'off').
'</a>';
331 $htmltooltip =
''.$langs->trans(
"Name").
': '.
$module->name;
332 $htmltooltip .=
'<br>'.$langs->trans(
"Type").
': '.(
$module->type ?
$module->type : $langs->trans(
"Unknown"));
334 $htmltooltip .=
'<br>'.$langs->trans(
"Width").
'/'.$langs->trans(
"Height").
': '.
$module->page_largeur.
'/'.
$module->page_hauteur;
336 $htmltooltip .=
'<br><br><u>'.$langs->trans(
"FeaturesSupported").
':</u>';
337 $htmltooltip .=
'<br>'.$langs->trans(
"Logo").
': '.yn(
$module->option_logo, 1, 1);
338 $htmltooltip .=
'<br>'.$langs->trans(
"MultiLanguage").
': '.yn(
$module->option_multilang, 1, 1);
339 print
'<td class="center">';
340 print $form->textwithpicto(
'', $htmltooltip, -1,
'info');
344 print
'<td class="center">';
347 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=specimen&module='.urlencode($name).
'">'.img_object($langs->trans(
"Preview"),
'pdf').
'</a>';
349 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=specimen&module='.urlencode($name).
'" target="specimen">'.img_object($langs->trans(
"Preview"),
'generic').
'</a>';
364print
'<table class="noborder centpercent">';
365print
'<tr class="liste_titre">';
366print
'<td>'.$langs->trans(
"Parameters").
'</td>';
367print
'<td width="60" class="center">'.$langs->trans(
"Value").
"</td>\n";
372 print
'<tr class="oddeven">';
373 print
'<td colspan="2">';
374 print $langs->trans(
"DonationUseThirdparties");
376 print
'<td class="center">';
377 if (
$conf->use_javascript_ajax) {
378 print ajax_constantonoff(
'DONATION_USE_THIRDPARTIES');
380 $arrval = array(
'0' => $langs->trans(
"No"),
'1' => $langs->trans(
"Yes"));
381 print $form->selectarray(
"DONATION_USE_THIRDPARTIES", $arrval,
getDolGlobalString(
'DONATION_USE_THIRDPARTIES'));
387print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
388print
'<input type="hidden" name="token" value="'.newToken().
'" />';
389print
'<input type="hidden" name="action" value="set_DONATION_ACCOUNTINGACCOUNT" />';
391print
'<tr class="oddeven">';
393$label = $langs->trans(
"AccountAccounting");
394print
'<label for="DONATION_ACCOUNTINGACCOUNT">'.$label.
'</label></td>';
395print
'<td class="center">';
396if (
isModEnabled(
'accounting') && is_object($formaccounting)) {
398 print $formaccounting->select_account(
getDolGlobalString(
'DONATION_ACCOUNTINGACCOUNT'),
'DONATION_ACCOUNTINGACCOUNT', 1, array(), 1, 1);
400 print
'<input type="text" size="10" id="DONATION_ACCOUNTINGACCOUNT" name="DONATION_ACCOUNTINGACCOUNT" value="' .
getDolGlobalString(
'DONATION_ACCOUNTINGACCOUNT').
'">';
402print
'</td><td class="center">';
403print
'<input type="submit" class="button button-edit" value="'.$langs->trans(
"Modify").
'" />';
407print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
408print
'<input type="hidden" name="token" value="'.newToken().
'" />';
409print
'<input type="hidden" name="action" value="set_DONATION_MESSAGE" />';
411print
'<tr class="oddeven"><td colspan="2">';
412print $langs->trans(
"FreeTextOnDonations").
' '.img_info($langs->trans(
"AddCRIfTooLong")).
'<br>';
413print
'<textarea name="DONATION_MESSAGE" class="flat" cols="80">' .
getDolGlobalString(
'DONATION_MESSAGE').
'</textarea>';
414print
'</td><td class="center">';
415print
'<input type="submit" class="button button-edit" value="'.$langs->trans(
"Modify").
'" />';
424if (preg_match(
'/fr/i',
$mysoc->country_code)) {
428 print
'<table class="noborder centpercent">';
429 print
'<tr class="liste_titre">';
430 print
'<td>'.$langs->trans(
"Parameters").
'</td>'.
"\n";
431 print
'<td class="center">'.$langs->trans(
"Status").
'</td>'.
"\n";
434 print
'<tr class="oddeven">';
435 print
'<td width="80%">'.$langs->trans(
"DONATION_ART200").
'</td>';
436 print
'<td class="center">';
437 if (
$conf->use_javascript_ajax) {
438 print ajax_constantonoff(
'DONATION_ART200');
440 $arrval = array(
'0' => $langs->trans(
"No"),
'1' => $langs->trans(
"Yes"));
441 print $form->selectarray(
"DONATION_ART200", $arrval,
getDolGlobalString(
'DONATION_ART200'));
445 print
'<tr class="oddeven">';
446 print
'<td width="80%">'.$langs->trans(
"DONATION_ART238").
'</td>';
447 print
'<td class="center">';
448 if (
$conf->use_javascript_ajax) {
449 print ajax_constantonoff(
'DONATION_ART238');
451 $arrval = array(
'0' => $langs->trans(
"No"),
'1' => $langs->trans(
"Yes"));
452 print $form->selectarray(
"DONATION_ART238", $arrval,
getDolGlobalString(
'DONATION_ART238'));
456 print
'<tr class="oddeven">';
457 print
'<td width="80%">'.$langs->trans(
"DONATION_ART978").
'</td>';
458 print
'<td class="center">';
459 if (
$conf->use_javascript_ajax) {
460 print ajax_constantonoff(
'DONATION_ART978');
462 $arrval = array(
'0' => $langs->trans(
"No"),
'1' => $langs->trans(
"Yes"));
463 print $form->selectarray(
"DONATION_ART978", $arrval,
getDolGlobalString(
'DONATION_ART978'));
addDocumentModel($name, $type, $label='', $description='')
Add document model used by doc generator.
dolibarr_set_const($db, $name, $value, $type='chaine', $visible=0, $note='', $entity=1)
Insert a parameter (key,value) into database (delete old key then insert it again).
dolibarr_del_const($db, $name, $entity=1)
Delete a constant.
delDocumentModel($name, $type)
Delete document model used by doc generator.
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
Class to manage donations.
if(! $sortfield) if(! $sortorder) $module
donation_admin_prepare_head()
Prepare array with list of admin tabs.
dol_dir_list($utf8_path, $types="all", $recursive=0, $filter="", $excludefilter=null, $sortcriteria="name", $sortorder=SORT_ASC, $mode=0, $nohook=0, $relativename="", $donotfollowsymlinks=0, $nbsecondsold=0)
Scan a directory and return a list of files/directories.
dol_strlen($string, $stringencoding='UTF-8', $binarycount=0)
Make a strlen call.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1, $includequotes=0, $allowdash=0)
Clean a string to use it as a file name.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_sort_array(&$array, $index, $order='asc', $natsort=0, $case_sensitive=0, $keepindex=0)
Advanced sort array by the value of a given key, which produces ascending (default) or descending out...
newToken()
Return the value of token currently saved into session with name 'newtoken'.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0, $nodefault=0)
Return value of a param into GET or POST supervariable.
dol_substr($string, $start, $length=null, $stringencoding='', $trunconbytes=0)
Make a substring.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0, $morecssdiv='')
Show tabs of a record.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.