26 require
'../main.inc.php';
27 require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
28 require_once DOL_DOCUMENT_ROOT.
'/core/lib/fourn.lib.php';
29 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/paiementfourn.class.php';
32 $langs->loadLangs(array(
"admin",
"errors",
"other",
"bills",
"orders"));
38 $action =
GETPOST(
'action',
'aZ09');
39 $value =
GETPOST(
'value',
'alpha');
40 $modulepart =
GETPOST(
'modulepart',
'aZ09');
42 $label =
GETPOST(
'label',
'alpha');
43 $scandir =
GETPOST(
'scandir',
'alpha');
44 $type =
'supplier_payment';
51 include DOL_DOCUMENT_ROOT.
'/core/actions_setmoduleoptions.inc.php';
53 if ($action ==
'updateMask') {
54 $maskconstsupplierpayment =
GETPOST(
'maskconstsupplierpayment',
'alpha');
55 $masksupplierpayment =
GETPOST(
'masksupplierpayment',
'alpha');
56 if ($maskconstsupplierpayment) {
57 $res =
dolibarr_set_const($db, $maskconstsupplierpayment, $masksupplierpayment,
'chaine', 0,
'', $conf->entity);
69 } elseif ($action ==
'setmod') {
70 dolibarr_set_const($db,
"SUPPLIER_PAYMENT_ADDON", $value,
'chaine', 0,
'', $conf->entity);
71 } elseif ($action ==
'set') {
74 } elseif ($action ==
'del') {
77 if ($conf->global->FACTURE_ADDON_PDF ==
"$value") {
81 } elseif ($action ==
'setdoc') {
83 if (
dolibarr_set_const($db,
"SUPPLIER_PAYMENT_ADDON_PDF", $value,
'chaine', 0,
'', $conf->entity)) {
86 $conf->global->FACTURE_ADDON_PDF = $value;
94 } elseif ($action ==
'unsetdoc') {
96 } elseif ($action ==
'specimen') {
97 $modele =
GETPOST(
'module',
'alpha');
100 $paiementFourn->initAsSpecimen();
103 $file =
''; $classname =
''; $filefound = 0;
104 $dirmodels = array_merge(array(
'/'), (array) $conf->modules_parts[
'models']);
105 foreach ($dirmodels as $reldir) {
106 $file =
dol_buildpath($reldir.
"core/modules/supplier_payment/doc/pdf_".$modele.
".modules.php", 0);
107 if (file_exists($file)) {
109 $classname =
"pdf_".$modele;
117 $module =
new $classname($db);
119 if ($module->write_file($paiementFourn, $langs) > 0) {
120 header(
"Location: ".DOL_URL_ROOT.
"/document.php?modulepart=supplier_payment&file=SPECIMEN.pdf");
128 dol_syslog($langs->trans(
"ErrorModuleNotFound"), LOG_ERR);
130 } elseif ($action ==
'setparams') {
131 $res =
dolibarr_set_const($db,
"PAYMENTS_FOURN_REPORT_GROUP_BY_MOD",
GETPOST(
'PAYMENTS_FOURN_REPORT_GROUP_BY_MOD',
'int'),
'chaine', 0,
'', $conf->entity);
148 $dirmodels = array_merge(array(
'/'), (array) $conf->modules_parts[
'models']);
150 llxHeader(
"", $langs->trans(
"SupplierPaymentSetup"),
'EN:Supplier_Payment_Configuration|FR:Configuration_module_paiement_fournisseur');
155 $linkback =
'<a href="'.DOL_URL_ROOT.
'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToModuleList").
'</a>';
156 print
load_fiche_titre($langs->trans(
"SupplierPaymentSetup"), $linkback,
'title_setup');
161 print
dol_get_fiche_head($head,
'supplierpayment', $langs->trans(
"Suppliers"), -1,
'company');
167 if (empty($conf->global->SUPPLIER_PAYMENT_ADDON)) {
168 $conf->global->SUPPLIER_PAYMENT_ADDON =
'mod_supplier_payment_bronan';
176 $sql .=
" FROM ".MAIN_DB_PREFIX.
"document_model";
177 $sql .=
" WHERE type = '".$db->escape($type).
"'";
178 $sql .=
" AND entity = ".$conf->entity;
179 $resql = $db->query($sql);
182 $num_rows = $db->num_rows(
$resql);
183 while ($i < $num_rows) {
184 $array = $db->fetch_array(
$resql);
185 array_push($def, $array[0]);
192 print
'<table class="noborder centpercent">';
193 print
'<tr class="liste_titre">';
194 print
'<td>'.$langs->trans(
"Name").
'</td>';
195 print
'<td>'.$langs->trans(
"Description").
'</td>';
196 print
'<td class="nowrap">'.$langs->trans(
"Example").
'</td>';
197 print
'<td align="center" width="60">'.$langs->trans(
"Status").
'</td>';
198 print
'<td align="center" width="16">'.$langs->trans(
"ShortInfo").
'</td>';
203 foreach ($dirmodels as $reldir) {
204 $dir =
dol_buildpath($reldir.
"core/modules/supplier_payment/");
206 $handle = opendir($dir);
207 if (is_resource($handle)) {
208 while (($file = readdir($handle)) !==
false) {
209 if (!is_dir($dir.$file) || (substr($file, 0, 1) <>
'.' && substr($file, 0, 3) <>
'CVS')) {
211 $classname = preg_replace(
'/\.php$/',
'', $file);
213 if (!is_file($dir.$filebis)) {
214 $filebis = $file.
"/".$file.
".modules.php";
215 $classname =
"mod_supplier_payment_".$file;
218 preg_match(
'/\-(.*)_(.*)$/', $classname, $reg);
219 if (!empty($reg[2]) && $reg[2] != strtoupper($mysoc->country_code)) {
223 $classname = preg_replace(
'/\-.*$/',
'', $classname);
224 if (!class_exists($classname) && is_readable($dir.$filebis) && (preg_match(
'/mod_/', $filebis) || preg_match(
'/mod_/', $classname)) && substr($filebis,
dol_strlen($filebis) - 3, 3) ==
'php') {
226 require_once $dir.$filebis;
228 $module =
new $classname($db);
231 if ($module->version ==
'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) {
234 if ($module->version ==
'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) {
238 if ($module->isEnabled()) {
239 print
'<tr class="oddeven"><td width="100">';
240 echo preg_replace(
'/\-.*$/',
'', preg_replace(
'/mod_supplier_payment_/',
'', preg_replace(
'/\.php$/',
'', $file)));
243 print $module->info();
248 print
'<td class="nowrap">';
249 $tmp = $module->getExample();
250 if (preg_match(
'/^Error/', $tmp)) {
251 $langs->load(
"errors");
252 print
'<div class="error">'.$langs->trans($tmp).
'</div>';
253 } elseif ($tmp ==
'NotConfigured') {
254 print
'<span class="opacitymedium">'.$langs->trans($tmp).
'</span>';
260 print
'<td class="center">';
262 if ($conf->global->SUPPLIER_PAYMENT_ADDON == $file || $conf->global->SUPPLIER_PAYMENT_ADDON.
'.php' == $file) {
263 print
img_picto($langs->trans(
"Activated"),
'switch_on');
265 print
'<a class="reposition" href="'.$_SERVER[
"PHP_SELF"].
'?action=setmod&token='.
newToken().
'&value='.preg_replace(
'/\.php$/',
'', $file).
'&scandir='.$module->scandir.
'&label='.urlencode($module->name).
'" alt="'.$langs->trans(
"Default").
'">'.
img_picto($langs->trans(
"Disabled"),
'switch_off').
'</a>';
270 $payment->initAsSpecimen();
274 $htmltooltip .=
''.$langs->trans(
"Version").
': <b>'.$module->getVersion().
'</b><br>';
275 $nextval = $module->getNextValue($mysoc, $payment);
276 if (
"$nextval" != $langs->trans(
"NotAvailable")) {
277 $htmltooltip .= $langs->trans(
"NextValue").
': ';
279 if (preg_match(
'/^Error/', $nextval) || $nextval ==
'NotConfigured') {
280 $nextval = $langs->trans($nextval);
282 $htmltooltip .= $nextval.
'<br>';
284 $htmltooltip .= $langs->trans($module->error).
'<br>';
288 print
'<td class="center">';
289 print
$form->textwithpicto(
'', $htmltooltip, 1, 0);
291 if ($conf->global->PAYMENT_ADDON.
'.php' == $file) {
292 if (!empty($module->error)) {
318 print
'<table class="noborder centpercent">'.
"\n";
319 print
'<tr class="liste_titre">'.
"\n";
320 print
'<td width="100">'.$langs->trans(
"Name").
'</td>'.
"\n";
321 print
'<td>'.$langs->trans(
"Description").
'</td>'.
"\n";
322 print
'<td align="center" width="60">'.$langs->trans(
"Status").
'</td>'.
"\n";
323 print
'<td align="center" width="60">'.$langs->trans(
"Default").
'</td>'.
"\n";
324 print
'<td align="center" width="40">'.$langs->trans(
"ShortInfo").
'</td>';
325 print
'<td align="center" width="40">'.$langs->trans(
"Preview").
'</td>';
330 foreach ($dirmodels as $reldir) {
331 $realpath = $reldir.
"core/modules/supplier_payment/doc";
335 $handle = opendir($dir);
338 if (is_resource($handle)) {
339 while (($file = readdir($handle)) !==
false) {
340 if (preg_match(
'/\.modules\.php$/i', $file) && preg_match(
'/^(pdf_|doc_)/', $file)) {
341 $name = substr($file, 4,
dol_strlen($file) - 16);
342 $classname = substr($file, 0,
dol_strlen($file) - 12);
344 require_once $dir.
'/'.$file;
347 print
"<tr class=\"oddeven\">\n";
349 print (empty($module->name) ? $name : $module->name);
352 require_once $dir.
'/'.$file;
353 $module =
new $classname($db, $specimenthirdparty);
354 if (method_exists($module,
'info')) {
355 print $module->info($langs);
357 print $module->description;
363 if (in_array($name, $def)) {
364 print
'<td class="center">'.
"\n";
368 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=del&value='.$name.
'&scandir='.$module->scandir.
'&label='.urlencode($module->name).
'&type=SUPPLIER_PAYMENT">';
369 print
img_picto($langs->trans(
"Enabled"),
'switch_on');
378 print
'<td class="center">'.
"\n";
379 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=set&token='.
newToken().
'&value='.urlencode($name).
'&scandir='.urlencode($module->scandir).
'&label='.urlencode($module->name).
'&type=SUPPLIER_PAYMENT">'.
img_picto($langs->trans(
"Disabled"),
'switch_off').
'</a>';
384 print
'<td class="center">';
385 if ($conf->global->SUPPLIER_PAYMENT_ADDON_PDF ==
"$name") {
388 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=unsetdoc&token='.
newToken().
'&value='.urlencode($name).
'&scandir='.urlencode($module->scandir).
'&label='.urlencode($module->name).
'&type=SUPPLIER_PAYMENT"" alt="'.$langs->trans(
"Disable").
'">'.
img_picto($langs->trans(
"Enabled"),
'on').
'</a>';
390 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=setdoc&token='.
newToken().
'&value='.urlencode($name).
'&scandir='.urlencode($module->scandir).
'&label='.urlencode($module->name).
'&type=SUPPLIER_PAYMENT"" alt="'.$langs->trans(
"Default").
'">'.
img_picto($langs->trans(
"Disabled"),
'off').
'</a>';
395 $htmltooltip =
''.$langs->trans(
"Name").
': '.$module->name;
396 $htmltooltip .=
'<br>'.$langs->trans(
"Type").
': '.($module->type ? $module->type : $langs->trans(
"Unknown"));
397 $htmltooltip .=
'<br>'.$langs->trans(
"Width").
'/'.$langs->trans(
"Height").
': '.$module->page_largeur.
'/'.$module->page_hauteur;
398 $htmltooltip .=
'<br>'.$langs->trans(
"Path").
': '.preg_replace(
'/^\//',
'', $realpath).
'/'.$file;
400 $htmltooltip .=
'<br><br><u>'.$langs->trans(
"FeaturesSupported").
':</u>';
401 $htmltooltip .=
'<br>'.$langs->trans(
"Logo").
': '.
yn($module->option_logo, 1, 1);
402 print
'<td class="center">';
403 print
$form->textwithpicto(
'', $htmltooltip, 1, 0);
405 print
'<td class="center">';
406 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=specimen&module='.$name.
'">'.
img_object($langs->trans(
"Preview"),
'pdf').
'</a>';
428 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
429 print
'<input type="hidden" name="token" value="'.newToken().
'" />';
430 print
'<input type="hidden" name="action" value="setparams" />';
432 print
'<div class="div-table-responsive-no-min">';
433 print
'<table class="noborder centpercent">';
434 print
'<tr class="liste_titre">';
435 print
'<td>'.$langs->trans(
"Parameter").
'</td>';
436 print
'<td align="center" width="60">'.$langs->trans(
"Value").
'</td>';
437 print
'<td width="80"> </td>';
441 print
'<tr class="oddeven"><td>';
442 print $langs->trans(
"GroupPaymentsByModOnReports");
443 print
'</td><td width="60" align="center">';
444 print
$form->selectyesno(
"PAYMENTS_FOURN_REPORT_GROUP_BY_MOD", $conf->global->PAYMENTS_FOURN_REPORT_GROUP_BY_MOD, 1);
445 print
'</td><td class="right">';
446 print
"</td></tr>\n";
453 print
'<div class="center">';
454 print
'<input type="submit" class="button button-edit" value="'.$langs->trans(
"Modify").
'" />';