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.
'/don/class/don.class.php';
42require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
44 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formaccounting.class.php';
48$langs->loadLangs(array(
'admin',
'donations',
'accountancy',
'other'));
54$action =
GETPOST(
'action',
'aZ09');
56$label =
GETPOST(
'label',
'alpha');
57$scandir =
GETPOST(
'scan_dir',
'alpha');
67if ($action ==
'specimen') {
68 $modele =
GETPOST(
'module',
'alpha');
71 $don->initAsSpecimen();
74 $dir = DOL_DOCUMENT_ROOT.
"/core/modules/dons/";
75 $file = $modele.
".modules.php";
76 if ($modele !==
'' && file_exists($dir.$file)) {
77 require_once $dir.$file;
79 $classname = (string) $modele;
80 $obj =
new $classname($db);
81 '@phan-var-force ModeleDon $obj';
84 if ($obj->write_file($don, $langs) > 0) {
85 header(
"Location: ".DOL_URL_ROOT.
"/document.php?modulepart=donation&file=SPECIMEN.html");
88 setEventMessages($obj->error, $obj->errors,
'errors');
92 setEventMessages($langs->trans(
"ErrorModuleNotFound"),
null,
'errors');
93 dol_syslog($langs->trans(
"ErrorModuleNotFound"), LOG_ERR);
95} elseif ($action ==
'setdoc') {
100 $conf->global->DON_ADDON_MODEL = $value;
108} elseif ($action ==
'set') {
111} elseif ($action ==
'del') {
121if ($action ==
'set_DONATION_ACCOUNTINGACCOUNT') {
122 $account =
GETPOST(
'DONATION_ACCOUNTINGACCOUNT',
'alpha');
131 setEventMessages($langs->trans(
"SetupSaved"),
null,
'mesgs');
134 setEventMessages($langs->trans(
"Error"),
null,
'errors');
139if ($action ==
'set_DONATION_MESSAGE') {
140 $freemessage =
GETPOST(
'DONATION_MESSAGE',
'restricthtml');
149 setEventMessages($langs->trans(
"SetupSaved"),
null,
'mesgs');
152 setEventMessages($langs->trans(
"Error"),
null,
'errors');
159if (preg_match(
'/set_([a-z0-9_\-]+)/i', $action, $reg)) {
162 header(
"Location: ".$_SERVER[
"PHP_SELF"]);
165 dol_print_error($db);
169if (preg_match(
'/del_([a-z0-9_\-]+)/i', $action, $reg)) {
172 header(
"Location: ".$_SERVER[
"PHP_SELF"]);
175 dol_print_error($db);
183$dir =
"../../core/modules/dons/";
184$form =
new Form($db);
188 $formaccounting =
null;
192llxHeader(
'', $langs->trans(
"DonationsSetup"), $help_url,
'', 0, 0,
'',
'',
'',
'mod-donation page-admin');
194$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>';
195print
load_fiche_titre($langs->trans(
"DonationsSetup"), $linkback,
'title_setup');
209$sql .=
" FROM ".MAIN_DB_PREFIX.
"document_model";
210$sql .=
" WHERE type = '".$db->escape($type).
"'";
211$resql = $db->query($sql);
214 $num_rows = $db->num_rows($resql);
215 while ($i < $num_rows) {
216 $array = $db->fetch_array($resql);
217 if (is_array($array)) {
218 array_push($def, $array[0]);
223 dol_print_error($db);
226print
'<table class="noborder centpercent">';
227print
'<tr class="liste_titre">';
228print
'<td>'.$langs->trans(
"Name").
'</td>';
229print
'<td>'.$langs->trans(
"Description").
'</td>';
230print
'<td class="center" width="60">'.$langs->trans(
"Activated").
'</td>';
231print
'<td class="center" width="60">'.$langs->trans(
"Default").
'</td>';
232print
'<td class="center" width="80">'.$langs->trans(
"ShortInfo").
'</td>';
233print
'<td class="center" width="80">'.$langs->trans(
"Preview").
'</td>';
238$handle = opendir($dir);
240if (is_resource($handle)) {
241 while (($file = readdir($handle)) !==
false) {
242 if (preg_match(
'/\.modules\.php$/i', $file)) {
246 require_once $dir.
'/'.$file;
248 '@phan-var-force ModeleDon $module';
260 print
'<tr class="oddeven"><td width=\"100\">';
268 if (in_array($name, $def)) {
270 print
"<td class=\"center\">\n";
271 print img_picto($langs->trans(
"Enabled"),
'switch_on');
274 print
"<td class=\"center\">\n";
275 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>';
279 print
"<td class=\"center\">\n";
280 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>';
286 print
"<td class=\"center\">";
287 print img_picto($langs->trans(
"Default"),
'on');
290 print
"<td class=\"center\">";
291 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>';
296 $htmltooltip =
''.$langs->trans(
"Name").
': '.
$module->name;
297 $htmltooltip .=
'<br>'.$langs->trans(
"Type").
': '.(
$module->type ?
$module->type : $langs->trans(
"Unknown"));
299 $htmltooltip .=
'<br>'.$langs->trans(
"Width").
'/'.$langs->trans(
"Height").
': '.
$module->page_largeur.
'/'.
$module->page_hauteur;
301 $htmltooltip .=
'<br><br><u>'.$langs->trans(
"FeaturesSupported").
':</u>';
302 $htmltooltip .=
'<br>'.$langs->trans(
"Logo").
': '.yn(
$module->option_logo, 1, 1);
303 $htmltooltip .=
'<br>'.$langs->trans(
"MultiLanguage").
': '.yn(
$module->option_multilang, 1, 1);
304 print
'<td class="center">';
305 print $form->textwithpicto(
'', $htmltooltip, -1,
'info');
309 print
'<td class="center">';
310 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=specimen&module='.$name.
'" target="specimen">'.img_object($langs->trans(
"Preview"),
'generic').
'</a>';
327print
'<table class="noborder centpercent">';
328print
'<tr class="liste_titre">';
329print
'<td>'.$langs->trans(
"Parameters").
'</td>';
330print
'<td width="60" class="center">'.$langs->trans(
"Value").
"</td>\n";
335 print
'<tr class="oddeven">';
336 print
'<td colspan="2">';
337 print $langs->trans(
"DonationUseThirdparties");
339 print
'<td class="center">';
340 if (
$conf->use_javascript_ajax) {
341 print ajax_constantonoff(
'DONATION_USE_THIRDPARTIES');
343 $arrval = array(
'0' => $langs->trans(
"No"),
'1' => $langs->trans(
"Yes"));
344 print $form->selectarray(
"DONATION_USE_THIRDPARTIES", $arrval,
getDolGlobalString(
'DONATION_USE_THIRDPARTIES'));
350print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
351print
'<input type="hidden" name="token" value="'.newToken().
'" />';
352print
'<input type="hidden" name="action" value="set_DONATION_ACCOUNTINGACCOUNT" />';
354print
'<tr class="oddeven">';
356$label = $langs->trans(
"AccountAccounting");
357print
'<label for="DONATION_ACCOUNTINGACCOUNT">'.$label.
'</label></td>';
358print
'<td class="center">';
359if (
isModEnabled(
'accounting') && is_object($formaccounting)) {
361 print $formaccounting->select_account(
getDolGlobalString(
'DONATION_ACCOUNTINGACCOUNT'),
'DONATION_ACCOUNTINGACCOUNT', 1, array(), 1, 1);
363 print
'<input type="text" size="10" id="DONATION_ACCOUNTINGACCOUNT" name="DONATION_ACCOUNTINGACCOUNT" value="' .
getDolGlobalString(
'DONATION_ACCOUNTINGACCOUNT').
'">';
365print
'</td><td class="center">';
366print
'<input type="submit" class="button button-edit" value="'.$langs->trans(
"Modify").
'" />';
370print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
371print
'<input type="hidden" name="token" value="'.newToken().
'" />';
372print
'<input type="hidden" name="action" value="set_DONATION_MESSAGE" />';
374print
'<tr class="oddeven"><td colspan="2">';
375print $langs->trans(
"FreeTextOnDonations").
' '.img_info($langs->trans(
"AddCRIfTooLong")).
'<br>';
376print
'<textarea name="DONATION_MESSAGE" class="flat" cols="80">' .
getDolGlobalString(
'DONATION_MESSAGE').
'</textarea>';
377print
'</td><td class="center">';
378print
'<input type="submit" class="button button-edit" value="'.$langs->trans(
"Modify").
'" />';
387if (preg_match(
'/fr/i',
$mysoc->country_code)) {
391 print
'<table class="noborder centpercent">';
392 print
'<tr class="liste_titre">';
393 print
'<td>'.$langs->trans(
"Parameters").
'</td>'.
"\n";
394 print
'<td class="center">'.$langs->trans(
"Status").
'</td>'.
"\n";
397 print
'<tr class="oddeven">';
398 print
'<td width="80%">'.$langs->trans(
"DONATION_ART200").
'</td>';
399 print
'<td class="center">';
400 if (
$conf->use_javascript_ajax) {
401 print ajax_constantonoff(
'DONATION_ART200');
403 $arrval = array(
'0' => $langs->trans(
"No"),
'1' => $langs->trans(
"Yes"));
404 print $form->selectarray(
"DONATION_ART200", $arrval,
getDolGlobalString(
'DONATION_ART200'));
408 print
'<tr class="oddeven">';
409 print
'<td width="80%">'.$langs->trans(
"DONATION_ART238").
'</td>';
410 print
'<td class="center">';
411 if (
$conf->use_javascript_ajax) {
412 print ajax_constantonoff(
'DONATION_ART238');
414 $arrval = array(
'0' => $langs->trans(
"No"),
'1' => $langs->trans(
"Yes"));
415 print $form->selectarray(
"DONATION_ART238", $arrval,
getDolGlobalString(
'DONATION_ART238'));
419 print
'<tr class="oddeven">';
420 print
'<td width="80%">'.$langs->trans(
"DONATION_ART978").
'</td>';
421 print
'<td class="center">';
422 if (
$conf->use_javascript_ajax) {
423 print ajax_constantonoff(
'DONATION_ART978');
425 $arrval = array(
'0' => $langs->trans(
"No"),
'1' => $langs->trans(
"Yes"));
426 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.
Class to manage donations.
if(! $sortfield) if(! $sortorder) $module
donation_admin_prepare_head()
Prepare array with list of admin tabs.
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
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.
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.