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"));
36 $action =
GETPOST(
'action',
'aZ09');
37 $value =
GETPOST(
'value',
'alpha');
38 $label =
GETPOST(
'label',
'alpha');
39 $scandir =
GETPOST(
'scandir',
'alpha');
40 $type =
'supplier_payment';
47 include DOL_DOCUMENT_ROOT.
'/core/actions_setmoduleoptions.inc.php';
49 if ($action ==
'updateMask')
51 $maskconstsupplierpayment =
GETPOST(
'maskconstsupplierpayment',
'alpha');
52 $masksupplierpayment =
GETPOST(
'masksupplierpayment',
'alpha');
53 if ($maskconstsupplierpayment) $res =
dolibarr_set_const($db, $maskconstsupplierpayment, $masksupplierpayment,
'chaine', 0,
'', $conf->entity);
55 if (!($res > 0)) $error++;
63 } elseif ($action ==
'setmod')
65 dolibarr_set_const($db,
"SUPPLIER_PAYMENT_ADDON", $value,
'chaine', 0,
'', $conf->entity);
69 elseif ($action ==
'set')
72 } elseif ($action ==
'del')
77 if ($conf->global->FACTURE_ADDON_PDF ==
"$value")
dolibarr_del_const($db,
'SUPPLIER_PAYMENT_ADDON_PDF', $conf->entity);
82 elseif ($action ==
'setdoc')
84 if (
dolibarr_set_const($db,
"SUPPLIER_PAYMENT_ADDON_PDF", $value,
'chaine', 0,
'', $conf->entity))
88 $conf->global->FACTURE_ADDON_PDF = $value;
97 } elseif ($action ==
'specimen')
99 $modele =
GETPOST(
'module',
'alpha');
102 $paiementFourn->initAsSpecimen();
105 $file =
''; $classname =
''; $filefound = 0;
106 $dirmodels = array_merge(array(
'/'), (array) $conf->modules_parts[
'models']);
107 foreach ($dirmodels as $reldir)
109 $file =
dol_buildpath($reldir.
"core/modules/supplier_payment/doc/pdf_".$modele.
".modules.php", 0);
110 if (file_exists($file))
113 $classname =
"pdf_".$modele;
122 $module =
new $classname($db);
124 if ($module->write_file($paiementFourn, $langs) > 0)
126 header(
"Location: ".DOL_URL_ROOT.
"/document.php?modulepart=supplier_payment&file=SPECIMEN.pdf");
134 dol_syslog($langs->trans(
"ErrorModuleNotFound"), LOG_ERR);
136 } elseif ($action ==
'setparams')
138 $res =
dolibarr_set_const($db,
"PAYMENTS_FOURN_REPORT_GROUP_BY_MOD",
GETPOST(
'PAYMENTS_FOURN_REPORT_GROUP_BY_MOD',
'int'),
'chaine', 0,
'', $conf->entity);
139 if (!($res > 0)) $error++;
155 $dirmodels = array_merge(array(
'/'), (array) $conf->modules_parts[
'models']);
157 llxHeader(
"", $langs->trans(
"SupplierPaymentSetup"),
'EN:Supplier_Payment_Configuration|FR:Configuration_module_paiement_fournisseur');
159 $form =
new Form($db);
162 $linkback =
'<a href="'.DOL_URL_ROOT.
'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToModuleList").
'</a>';
168 print
dol_get_fiche_head($head,
'supplierpayment', $langs->trans(
"Suppliers"), -1,
'company');
174 if (empty($conf->global->SUPPLIER_PAYMENT_ADDON)) $conf->global->SUPPLIER_PAYMENT_ADDON =
'mod_supplier_payment_bronan';
181 $sql .=
" FROM ".MAIN_DB_PREFIX.
"document_model";
182 $sql .=
" WHERE type = '".$db->escape($type).
"'";
183 $sql .=
" AND entity = ".$conf->entity;
184 $resql = $db->query($sql);
188 $num_rows = $db->num_rows(
$resql);
189 while ($i < $num_rows)
191 $array = $db->fetch_array(
$resql);
192 array_push($def, $array[0]);
199 print
'<table class="noborder centpercent">';
200 print
'<tr class="liste_titre">';
201 print
'<td>'.$langs->trans(
"Name").
'</td>';
202 print
'<td>'.$langs->trans(
"Description").
'</td>';
203 print
'<td class="nowrap">'.$langs->trans(
"Example").
'</td>';
204 print
'<td align="center" width="60">'.$langs->trans(
"Status").
'</td>';
205 print
'<td align="center" width="16">'.$langs->trans(
"ShortInfo").
'</td>';
210 foreach ($dirmodels as $reldir)
212 $dir =
dol_buildpath($reldir.
"core/modules/supplier_payment/");
215 $handle = opendir($dir);
216 if (is_resource($handle))
218 while (($file = readdir($handle)) !==
false)
220 if (!is_dir($dir.$file) || (substr($file, 0, 1) <>
'.' && substr($file, 0, 3) <>
'CVS'))
223 $classname = preg_replace(
'/\.php$/',
'', $file);
225 if (!is_file($dir.$filebis))
227 $filebis = $file.
"/".$file.
".modules.php";
228 $classname =
"mod_supplier_payment_".$file;
231 preg_match(
'/\-(.*)_(.*)$/', $classname, $reg);
232 if (!empty($reg[2]) && $reg[2] != strtoupper($mysoc->country_code))
continue;
234 $classname = preg_replace(
'/\-.*$/',
'', $classname);
235 if (!class_exists($classname) && is_readable($dir.$filebis) && (preg_match(
'/mod_/', $filebis) || preg_match(
'/mod_/', $classname)) && substr($filebis,
dol_strlen($filebis) - 3, 3) ==
'php')
238 require_once $dir.$filebis;
240 $module =
new $classname($db);
243 if ($module->version ==
'development' && $conf->global->MAIN_FEATURES_LEVEL < 2)
continue;
244 if ($module->version ==
'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1)
continue;
246 if ($module->isEnabled())
248 print
'<tr class="oddeven"><td width="100">';
249 echo preg_replace(
'/\-.*$/',
'', preg_replace(
'/mod_supplier_payment_/',
'', preg_replace(
'/\.php$/',
'', $file)));
252 print $module->info();
257 print
'<td class="nowrap">';
258 $tmp = $module->getExample();
259 if (preg_match(
'/^Error/', $tmp)) {
260 $langs->load(
"errors");
261 print
'<div class="error">'.$langs->trans($tmp).
'</div>';
262 } elseif ($tmp ==
'NotConfigured') print $langs->trans($tmp);
266 print '<td class="center">';
268 if ($conf->global->SUPPLIER_PAYMENT_ADDON == $file || $conf->global->SUPPLIER_PAYMENT_ADDON.'.php' == $file)
270 print
img_picto($langs->trans(
"Activated"),
'switch_on');
272 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>';
277 $payment->initAsSpecimen();
281 $htmltooltip .=
''.$langs->trans(
"Version").
': <b>'.$module->getVersion().
'</b><br>';
282 $nextval = $module->getNextValue($mysoc, $payment);
283 if (
"$nextval" != $langs->trans(
"NotAvailable")) {
284 $htmltooltip .= $langs->trans(
"NextValue").
': ';
286 if (preg_match(
'/^Error/', $nextval) || $nextval ==
'NotConfigured')
287 $nextval = $langs->trans($nextval);
288 $htmltooltip .= $nextval.
'<br>';
290 $htmltooltip .= $langs->trans($module->error).
'<br>';
294 print
'<td class="center">';
295 print $form->textwithpicto(
'', $htmltooltip, 1, 0);
297 if ($conf->global->PAYMENT_ADDON.
'.php' == $file)
323 print
'<table class="noborder centpercent">'.
"\n";
324 print
'<tr class="liste_titre">'.
"\n";
325 print
'<td width="100">'.$langs->trans(
"Name").
'</td>'.
"\n";
326 print
'<td>'.$langs->trans(
"Description").
'</td>'.
"\n";
327 print
'<td align="center" width="60">'.$langs->trans(
"Status").
'</td>'.
"\n";
328 print
'<td align="center" width="60">'.$langs->trans(
"Default").
'</td>'.
"\n";
329 print
'<td align="center" width="40">'.$langs->trans(
"ShortInfo").
'</td>';
330 print
'<td align="center" width="40">'.$langs->trans(
"Preview").
'</td>';
335 foreach ($dirmodels as $reldir)
337 $realpath = $reldir.
"core/modules/supplier_payment/doc";
342 $handle = opendir($dir);
345 if (is_resource($handle))
347 while (($file = readdir($handle)) !==
false)
349 if (preg_match(
'/\.modules\.php$/i', $file) && preg_match(
'/^(pdf_|doc_)/', $file))
351 $name = substr($file, 4,
dol_strlen($file) - 16);
352 $classname = substr($file, 0,
dol_strlen($file) - 12);
354 require_once $dir.
'/'.$file;
357 print
"<tr class=\"oddeven\">\n";
359 print (empty($module->name) ? $name : $module->name);
362 require_once $dir.
'/'.$file;
363 $module =
new $classname($db, $specimenthirdparty);
364 if (method_exists($module,
'info')) print $module->info($langs);
365 else print $module->description;
370 if (in_array($name, $def))
372 print
'<td class="center">'.
"\n";
376 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=del&value='.$name.
'&scandir='.$module->scandir.
'&label='.urlencode($module->name).
'&type=SUPPLIER_PAYMENT">';
377 print
img_picto($langs->trans(
"Enabled"),
'switch_on');
386 print
'<td class="center">'.
"\n";
387 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=set&token='.
newToken().
'&value='.$name.
'&scandir='.$module->scandir.
'&label='.urlencode($module->name).
'&type=SUPPLIER_PAYMENT">'.
img_picto($langs->trans(
"Disabled"),
'switch_off').
'</a>';
392 print
'<td class="center">';
393 if ($conf->global->SUPPLIER_PAYMENT_ADDON_PDF ==
"$name")
397 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=unsetdoc&token='.
newToken().
'&value='.$name.
'&scandir='.$module->scandir.
'&label='.urlencode($module->name).
'&type=SUPPLIER_PAYMENT"" alt="'.$langs->trans(
"Disable").
'">'.
img_picto($langs->trans(
"Enabled"),
'on').
'</a>';
399 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=setdoc&token='.
newToken().
'&value='.$name.
'&scandir='.$module->scandir.
'&label='.urlencode($module->name).
'&type=SUPPLIER_PAYMENT"" alt="'.$langs->trans(
"Default").
'">'.
img_picto($langs->trans(
"Disabled"),
'off').
'</a>';
404 $htmltooltip =
''.$langs->trans(
"Name").
': '.$module->name;
405 $htmltooltip .=
'<br>'.$langs->trans(
"Type").
': '.($module->type ? $module->type : $langs->trans(
"Unknown"));
406 $htmltooltip .=
'<br>'.$langs->trans(
"Width").
'/'.$langs->trans(
"Height").
': '.$module->page_largeur.
'/'.$module->page_hauteur;
407 $htmltooltip .=
'<br>'.$langs->trans(
"Path").
': '.preg_replace(
'/^\//',
'', $realpath).
'/'.$file;
409 $htmltooltip .=
'<br><br><u>'.$langs->trans(
"FeaturesSupported").
':</u>';
410 $htmltooltip .=
'<br>'.$langs->trans(
"Logo").
': '.
yn($module->option_logo, 1, 1);
411 print
'<td class="center">';
412 print $form->textwithpicto(
'', $htmltooltip, 1, 0);
414 print
'<td class="center">';
415 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=specimen&module='.$name.
'">'.
img_object($langs->trans(
"Preview"),
'pdf').
'</a>';
437 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
438 print
'<input type="hidden" name="token" value="'.newToken().
'" />';
439 print
'<input type="hidden" name="action" value="setparams" />';
441 print
'<div class="div-table-responsive-no-min">';
442 print
'<table class="noborder centpercent">';
443 print
'<tr class="liste_titre">';
444 print
'<td>'.$langs->trans(
"Parameter").
'</td>';
445 print
'<td align="center" width="60">'.$langs->trans(
"Value").
'</td>';
446 print
'<td width="80"> </td>';
450 print
'<tr class="oddeven"><td>';
451 print $langs->trans(
"GroupPaymentsByModOnReports");
452 print
'</td><td width="60" align="center">';
453 print $form->selectyesno(
"PAYMENTS_FOURN_REPORT_GROUP_BY_MOD", $conf->global->PAYMENTS_FOURN_REPORT_GROUP_BY_MOD, 1);
454 print
'</td><td class="right">';
455 print
"</td></tr>\n";
462 print
'<div class="center">';
463 print
'<input type="submit" class="button" value="'.$langs->trans(
"Modify").
'" />';
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
delDocumentModel($name, $type)
Delete document model used by doc generator.
yn($yesno, $case=1, $color=0)
Return yes or no in current language.
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).
addDocumentModel($name, $type, $label= '', $description= '')
Add document model used by doc generator.
supplierorder_admin_prepare_head()
Return array head with list of tabs to view object informations.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
setEventMessages($mesg, $mesgs, $style= 'mesgs', $messagekey= '')
Set event messages in dol_events session object.
load_fiche_titre($titre, $morehtmlright= '', $picto= 'generic', $pictoisfullpath=0, $id= '', $morecssontable= '', $morehtmlcenter= '')
Load a title with picto.
dol_strlen($string, $stringencoding= 'UTF-8')
Make a strlen call.
dolibarr_del_const($db, $name, $entity=1)
Effacement d'une constante dans la base de donnees.
img_picto($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt= '', $morecss= '', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename= '', $restricttologhandler= '', $logcontext=null)
Write log message into outputs.
if(!GETPOST('transkey', 'alphanohtml')&&!GETPOST('transphrase', 'alphanohtml')) else
View.
img_object($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
accessforbidden($message= '', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program Calling this function terminate execution ...
dol_get_fiche_head($links=array(), $active= '', $title= '', $notab=0, $picto= '', $pictoisfullpath=0, $morehtmlright= '', $morecss= '', $limittoshow=0, $moretabssuffix= '')
Show tabs of a record.
dol_htmloutput_mesg($mesgstring= '', $mesgarray=array(), $style= 'ok', $keepembedded=0)
Print formated messages to output (Used to show messages on html output).
print
Draft customers invoices.
if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) if(!empty($conf->don->enabled)&&$user->rights->don->lire) if(!empty($conf->tax->enabled)&&$user->rights->tax->charges->lire) if(!empty($conf->facture->enabled)&&!empty($conf->commande->enabled)&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
newToken()
Return the value of token currently saved into session with name 'newtoken'.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
print $_SERVER["PHP_SELF"] n
Edit parameters.
Class to manage payments for supplier invoices.
if(!defined('CSRFCHECK_WITH_TOKEN')) define('CSRFCHECK_WITH_TOKEN'
Draft customers invoices.