33require
'../main.inc.php';
34require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
35require_once DOL_DOCUMENT_ROOT.
'/core/lib/pdf.lib.php';
36require_once DOL_DOCUMENT_ROOT.
'/core/lib/fourn.lib.php';
37require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.class.php';
38require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.facture.class.php';
50$langs->loadLangs(array(
"admin",
"other",
"orders"));
52$action =
GETPOST(
'action',
'aZ09');
54$type =
GETPOST(
'type',
'alpha');
55$value =
GETPOST(
'value',
'alpha');
56$modulepart =
GETPOST(
'modulepart',
'aZ09');
58$label =
GETPOST(
'label',
'alpha');
59$scandir =
GETPOST(
'scan_dir',
'alpha');
61$specimenthirdparty =
new Societe($db);
62$specimenthirdparty->initAsSpecimen();
75include DOL_DOCUMENT_ROOT.
'/core/actions_setmoduleoptions.inc.php';
77if ($action ==
'updateMask') {
78 $maskconstinvoice =
GETPOST(
'maskconstinvoice',
'aZ09');
79 $maskconstcredit =
GETPOST(
'maskconstcredit',
'aZ09');
80 $maskconstdeposit =
GETPOST(
'maskconstdeposit',
'aZ09');
81 $maskinvoice =
GETPOST(
'maskinvoice',
'alpha');
82 $maskcredit =
GETPOST(
'maskcredit',
'alpha');
83 $maskdeposit =
GETPOST(
'maskdeposit',
'alpha');
86 if ($maskconstinvoice && preg_match(
'/_MASK$/', $maskconstinvoice)) {
87 $res =
dolibarr_set_const($db, $maskconstinvoice, $maskinvoice,
'chaine', 0,
'', $conf->entity);
89 if ($maskconstcredit && preg_match(
'/_MASK$/', $maskconstcredit)) {
90 $res =
dolibarr_set_const($db, $maskconstcredit, $maskcredit,
'chaine', 0,
'', $conf->entity);
92 if ($maskconstdeposit && preg_match(
'/_MASK$/', $maskconstdeposit)) {
93 $res =
dolibarr_set_const($db, $maskconstdeposit, $maskdeposit,
'chaine', 0,
'', $conf->entity);
107if ($action ==
'specimen') {
108 $modele =
GETPOST(
'module',
'alpha');
111 $facture->initAsSpecimen();
112 $facture->thirdparty = $specimenthirdparty;
117 $dirmodels = array_merge(array(
'/'), (array) $conf->modules_parts[
'models']);
118 foreach ($dirmodels as $reldir) {
119 $file =
dol_buildpath($reldir.
"core/modules/supplier_invoice/doc/pdf_".$modele.
".modules.php", 0);
120 if (file_exists($file)) {
121 $classname =
"pdf_".$modele;
126 if ($classname !==
'') {
129 $module =
new $classname($db, $facture);
130 '@phan-var-force ModelePDFSuppliersInvoices $module';
132 if ($module->write_file($facture, $langs) > 0) {
133 header(
"Location: ".DOL_URL_ROOT.
"/document.php?modulepart=facture_fournisseur&file=SPECIMEN.pdf");
141 dol_syslog($langs->trans(
"ErrorModuleNotFound"), LOG_ERR);
143} elseif ($action ==
'set') {
146} elseif ($action ==
'del') {
153} elseif ($action ==
'setdoc') {
155 if (
dolibarr_set_const($db,
"INVOICE_SUPPLIER_ADDON_PDF", $value,
'chaine', 0,
'', $conf->entity)) {
158 $conf->global->INVOICE_SUPPLIER_ADDON_PDF = $value;
166} elseif ($action ==
'unsetdoc') {
170if ($action ==
'setmod') {
174 dolibarr_set_const($db,
"INVOICE_SUPPLIER_ADDON_NUMBER", $value,
'chaine', 0,
'', $conf->entity);
177if ($action ==
'addcat') {
179 $fourn->CreateCategory($user,
GETPOST(
'cat',
'alphanohtml'));
182if ($action ==
'set_SUPPLIER_INVOICE_FREE_TEXT') {
183 $freetext =
GETPOST(
'SUPPLIER_INVOICE_FREE_TEXT',
'restricthtml');
185 $res =
dolibarr_set_const($db,
"SUPPLIER_INVOICE_FREE_TEXT", $freetext,
'chaine', 0,
'', $conf->entity);
203$form =
new Form($db);
205$dirmodels = array_merge(array(
'/'), (array) $conf->modules_parts[
'models']);
207llxHeader(
'',
'',
'',
'', 0, 0,
'',
'',
'',
'mod-admin page-supplier_invoice');
209$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>';
211print
load_fiche_titre($langs->trans(
"SuppliersSetup"), $linkback,
'title_setup');
222print
load_fiche_titre($langs->trans(
"SuppliersInvoiceNumberingModel"),
'',
'');
224print
'<div class="div-table-responsive-no-min">';
225print
'<table class="noborder centpercent">';
226print
'<tr class="liste_titre">';
227print
'<td width="100">'.$langs->trans(
"Name").
'</td>';
228print
'<td>'.$langs->trans(
"Description").
'</td>';
229print
'<td>'.$langs->trans(
"Example").
'</td>';
230print
'<td align="center" width="60">'.$langs->trans(
"Status").
'</td>';
231print
'<td align="center" width="16">'.$langs->trans(
"ShortInfo").
'</td>';
236foreach ($dirmodels as $reldir) {
237 $dir =
dol_buildpath($reldir.
"core/modules/supplier_invoice");
240 $handle = opendir($dir);
241 if (is_resource($handle)) {
242 while (($file = readdir($handle)) !==
false) {
243 if (substr($file, 0, 24) ==
'mod_facture_fournisseur_' && substr($file,
dol_strlen($file) - 3, 3) ==
'php') {
244 $file = substr($file, 0,
dol_strlen($file) - 4);
246 require_once $dir.
'/'.$file.
'.php';
248 $module =
new $file();
250 '@phan-var-force ModeleNumRefSuppliersInvoices $module';
252 if ($module->isEnabled()) {
254 if ($module->version ==
'development' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 2) {
257 if ($module->version ==
'experimental' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 1) {
262 print
'<tr class="oddeven"><td>'.$module->getName($langs).
"</td><td>\n";
263 print $module->info($langs);
267 print
'<td class="nowrap">';
268 $tmp = $module->getExample();
269 if (preg_match(
'/^Error/', $tmp)) {
270 $langs->load(
"errors");
271 print
'<div class="error">'.$langs->trans($tmp).
'</div>';
272 } elseif ($tmp ==
'NotConfigured') {
273 print
'<span class="opacitymedium">'.$langs->trans($tmp).
'</span>';
279 print
'<td class="center">';
281 print
img_picto($langs->trans(
"Activated"),
'switch_on');
283 print
'<a class="reposition" href="'.$_SERVER[
"PHP_SELF"].
'?action=setmod&token='.
newToken().
'&value='.urlencode($file).
'" alt="'.$langs->trans(
"Default").
'">'.
img_picto($langs->trans(
"Disabled"),
'switch_off').
'</a>';
288 $invoice->initAsSpecimen();
292 $htmltooltip .=
''.$langs->trans(
"Version").
': <b>'.$module->getVersion().
'</b><br>';
293 $nextval = $module->getNextValue(
$mysoc, $invoice);
294 if (
"$nextval" != $langs->trans(
"NotAvailable")) {
295 $htmltooltip .=
''.$langs->trans(
"NextValue").
': ';
297 if (preg_match(
'/^Error/', $nextval) || $nextval ==
'NotConfigured') {
298 $nextval = $langs->trans($nextval);
300 $htmltooltip .= $nextval.
'<br>';
302 $htmltooltip .= $langs->trans($module->error).
'<br>';
306 print
'<td class="center">';
307 print $form->textwithpicto(
'', $htmltooltip, 1,
'info');
319print
'</table></div><br>';
334$sql .=
" FROM ".MAIN_DB_PREFIX.
"document_model";
335$sql .=
" WHERE type = 'invoice_supplier'";
336$sql .=
" AND entity = ".((int) $conf->entity);
338$resql = $db->query($sql);
341 $num_rows = $db->num_rows($resql);
342 while ($i < $num_rows) {
343 $array = $db->fetch_array($resql);
344 if (is_array($array)) {
345 array_push($def, $array[0]);
353print
'<div class="div-table-responsive-no-min">';
354print
'<table class="noborder centpercent">'.
"\n";
355print
'<tr class="liste_titre">'.
"\n";
356print
'<td width="100">'.$langs->trans(
"Name").
'</td>'.
"\n";
357print
'<td>'.$langs->trans(
"Description").
'</td>'.
"\n";
358print
'<td align="center" width="60">'.$langs->trans(
"Status").
'</td>'.
"\n";
359print
'<td align="center" width="60">'.$langs->trans(
"Default").
'</td>'.
"\n";
360print
'<td align="center" width="40">'.$langs->trans(
"ShortInfo").
'</td>';
361print
'<td align="center" width="40">'.$langs->trans(
"Preview").
'</td>';
366foreach ($dirmodels as $reldir) {
367 $realpath = $reldir.
"core/modules/supplier_invoice/doc";
371 $handle = opendir($dir);
374 if (is_resource($handle)) {
375 while (($file = readdir($handle)) !==
false) {
376 if (preg_match(
'/\.modules\.php$/i', $file) && preg_match(
'/^(pdf_|doc_)/', $file)) {
377 $name = substr($file, 4,
dol_strlen($file) - 16);
378 $classname = substr($file, 0,
dol_strlen($file) - 12);
380 require_once $dir.
'/'.$file;
383 '@phan-var-force ModelePDFSuppliersInvoices $module';
386 print
"<tr class=\"oddeven\">\n";
388 print(empty($module->name) ? $name : $module->
name);
391 require_once $dir.
'/'.$file;
392 $module =
new $classname($db, $specimenthirdparty);
393 '@phan-var-force ModelePDFSuppliersInvoices $module';
394 if (method_exists($module,
'info')) {
395 print $module->info($langs);
397 print $module->description;
403 if (in_array($name, $def)) {
404 print
'<td class="center">'.
"\n";
408 print
'<a class="reposition" href="'.$_SERVER[
"PHP_SELF"].
'?action=del&token='.
newToken().
'&value='.urlencode($name).
'&scan_dir='.urlencode($module->scandir).
'&label='.urlencode($module->name).
'&type=invoice_supplier">';
409 print
img_picto($langs->trans(
"Enabled"),
'switch_on');
418 print
'<td class="center">'.
"\n";
419 print
'<a class="reposition" href="'.$_SERVER[
"PHP_SELF"].
'?action=set&token='.
newToken().
'&value='.urlencode($name).
'&scan_dir='.urlencode($module->scandir).
'&label='.urlencode($module->name).
'&type=invoice_supplier">'.
img_picto($langs->trans(
"Disabled"),
'switch_off').
'</a>';
424 print
'<td class="center">';
428 print
'<a class="reposition" href="'.$_SERVER[
"PHP_SELF"].
'?action=unsetdoc&token='.
newToken().
'&value='.$name.
'&scan_dir='.$module->scandir.
'&label='.urlencode($module->name).
'&type=invoice_supplier"" alt="'.$langs->trans(
"Disable").
'">'.
img_picto($langs->trans(
"Enabled"),
'on').
'</a>';
430 print
'<a class="reposition" href="'.$_SERVER[
"PHP_SELF"].
'?action=setdoc&token='.
newToken().
'&value='.$name.
'&scan_dir='.$module->scandir.
'&label='.urlencode($module->name).
'&type=invoice_supplier"" alt="'.$langs->trans(
"Default").
'">'.
img_picto($langs->trans(
"Disabled"),
'off').
'</a>';
435 $htmltooltip =
''.$langs->trans(
"Name").
': '.$module->name;
436 $htmltooltip .=
'<br>'.$langs->trans(
"Type").
': '.($module->type ? $module->type : $langs->trans(
"Unknown"));
437 $htmltooltip .=
'<br>'.$langs->trans(
"Width").
'/'.$langs->trans(
"Height").
': '.$module->page_largeur.
'/'.$module->page_hauteur;
438 $htmltooltip .=
'<br>'.$langs->trans(
"Path").
': '.preg_replace(
'/^\//',
'', $realpath).
'/'.$file;
440 $htmltooltip .=
'<br><br><u>'.$langs->trans(
"FeaturesSupported").
':</u>';
441 $htmltooltip .=
'<br>'.$langs->trans(
"Logo").
': '.
yn($module->option_logo, 1, 1);
442 $htmltooltip .=
'<br>'.$langs->trans(
"PaymentMode").
': '.
yn($module->option_modereg, 1, 1);
443 $htmltooltip .=
'<br>'.$langs->trans(
"PaymentConditions").
': '.
yn($module->option_condreg, 1, 1);
444 print
'<td class="center">';
445 print $form->textwithpicto(
'', $htmltooltip, 1,
'info');
447 print
'<td class="center">';
448 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=specimen&module='.urlencode($name).
'">'.
img_object($langs->trans(
"Preview"),
'pdf').
'</a>';
460print
'</table></div><br>';
466print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="post">';
467print
'<input type="hidden" name="token" value="'.newToken().
'">';
468print
'<input type="hidden" name="action" value="set_SUPPLIER_INVOICE_FREE_TEXT">';
472print
'<div class="div-table-responsive-no-min">';
473print
'<table class="noborder centpercent">';
474print
'<tr class="liste_titre">';
475print
'<td>'.$langs->trans(
"Parameter").
'</td>';
477print
'<td width="80"> </td>';
481$substitutionarray[
'__(AnyTranslationKey)__'] = $langs->trans(
"Translation");
482$htmltext =
'<i>'.$langs->trans(
"AvailableVariables").
':<br>';
483foreach ($substitutionarray as $key => $val) {
484 $htmltext .= $key.
'<br>';
488print
'<tr class="oddeven"><td colspan="2">';
489print $form->textwithpicto($langs->trans(
"FreeLegalTextOnInvoices"), $langs->trans(
"AddCRIfTooLong").
'<br><br>'.$htmltext, 1,
'help',
'', 0, 2,
'freetexttooltip').
'<br>';
490$variablename =
'SUPPLIER_INVOICE_FREE_TEXT';
492 print
'<textarea name="'.$variablename.
'" class="flat" cols="120">'.
getDolGlobalString($variablename).
'</textarea>';
494 include_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
496 print $doleditor->Create();
498print
'</td><td class="right">';
499print
'<input type="submit" class="button button-edit" value="'.$langs->trans(
"Modify").
'">';
504print
'<tr class="oddeven">';
505print
'<td>'.img_picto(
'',
'email',
'class="pictofixedwidth"').$langs->trans(
"Notifications").
'</td>';
506print
'<td colspan="2">';
507print $langs->trans(
"YouMayFindNotificationsFeaturesIntoModuleNotification");
519print
'</table></div><br>';
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 a WYSIWYG editor.
Class to manage suppliers invoices.
Class to manage suppliers.
Class to manage third parties objects (customers, suppliers, prospects...)
supplierorder_admin_prepare_head()
Return array head with list of tabs to view object information.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
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.
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $allowothertags=array())
Show a picto called object_picto (generic function)
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'.
yn($yesno, $format=1, $color=0)
Return yes or no in current language.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
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.
pdf_getSubstitutionArray($outputlangs, $exclude=null, $object=null, $onlykey=0, $include=null)
Return array of possible substitutions for PDF content (without external module substitutions).
$conf db name
Only used if Module[ID]Name translation string is not found.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.