35require
'../../main.inc.php';
46require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
47require_once DOL_DOCUMENT_ROOT.
'/core/lib/pdf.lib.php';
49 require_once DOL_DOCUMENT_ROOT .
'/core/lib/supplier_invoice.lib.php';
51 require_once DOL_DOCUMENT_ROOT .
'/core/lib/fourn.lib.php';
53require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.class.php';
54require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.facture.class.php';
57$langs->loadLangs(array(
"admin",
"other",
"orders"));
59$action =
GETPOST(
'action',
'aZ09');
61$type =
GETPOST(
'type',
'alpha');
62$value =
GETPOST(
'value',
'alpha');
63$modulepart =
GETPOST(
'modulepart',
'aZ09');
65$label =
GETPOST(
'label',
'alpha');
66$scandir =
GETPOST(
'scan_dir',
'alpha');
68$specimenthirdparty =
new Societe($db);
69$specimenthirdparty->initAsSpecimen();
82include DOL_DOCUMENT_ROOT.
'/core/actions_setmoduleoptions.inc.php';
84if ($action ==
'updateMask') {
85 $maskconstinvoice =
GETPOST(
'maskconstinvoice',
'aZ09');
86 $maskconstcredit =
GETPOST(
'maskconstcredit',
'aZ09');
87 $maskconstdeposit =
GETPOST(
'maskconstdeposit',
'aZ09');
88 $maskinvoice =
GETPOST(
'maskinvoice',
'alpha');
89 $maskcredit =
GETPOST(
'maskcredit',
'alpha');
90 $maskdeposit =
GETPOST(
'maskdeposit',
'alpha');
93 if ($maskconstinvoice && preg_match(
'/_MASK$/', $maskconstinvoice)) {
96 if ($maskconstcredit && preg_match(
'/_MASK$/', $maskconstcredit)) {
99 if ($maskconstdeposit && preg_match(
'/_MASK$/', $maskconstdeposit)) {
108 setEventMessages($langs->trans(
"SetupSaved"),
null,
'mesgs');
110 setEventMessages($langs->trans(
"Error"),
null,
'errors');
114if ($action ==
'specimen') {
115 $modele =
GETPOST(
'module',
'alpha');
118 $facture->initAsSpecimen();
119 $facture->thirdparty = $specimenthirdparty;
124 $dirmodels = array_merge(array(
'/'), (array)
$conf->modules_parts[
'models']);
125 foreach ($dirmodels as $reldir) {
126 $file =
dol_buildpath($reldir.
"core/modules/supplier_invoice/doc/pdf_".$modele.
".modules.php", 0);
127 if (file_exists($file)) {
128 $classname =
"pdf_".$modele;
133 if ($classname !==
'') {
136 $module =
new $classname($db, $facture);
137 '@phan-var-force ModelePDFSuppliersInvoices $module';
139 if (
$module->write_file($facture, $langs) > 0) {
140 header(
"Location: ".DOL_URL_ROOT.
"/document.php?modulepart=facture_fournisseur&file=SPECIMEN.pdf");
147 setEventMessages($langs->trans(
"ErrorModuleNotFound"),
null,
'errors');
148 dol_syslog($langs->trans(
"ErrorModuleNotFound"), LOG_ERR);
150} elseif ($action ==
'set') {
153} elseif ($action ==
'del') {
160} elseif ($action ==
'setdoc') {
165 $conf->global->INVOICE_SUPPLIER_ADDON_PDF = $value;
173} elseif ($action ==
'unsetdoc') {
177if ($action ==
'setmod') {
184if ($action ==
'addcat') {
186 $fourn->CreateCategory($user,
GETPOST(
'cat',
'alphanohtml'));
189if ($action ==
'set_SUPPLIER_INVOICE_FREE_TEXT') {
190 $freetext =
GETPOST(
'SUPPLIER_INVOICE_FREE_TEXT',
'restricthtml');
199 setEventMessages($langs->trans(
"SetupSaved"),
null,
'mesgs');
201 setEventMessages($langs->trans(
"Error"),
null,
'errors');
210$form =
new Form($db);
212$dirmodels = array_merge(array(
'/'), (array)
$conf->modules_parts[
'models']);
214llxHeader(
'',
'',
'',
'', 0, 0,
'',
'',
'',
'mod-admin page-supplier_invoice');
216$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>';
218print
load_fiche_titre($langs->trans(
"SuppliersSetup"), $linkback,
'title_setup');
232$invoice->initAsSpecimen();
234printNumberingModuleList(
'supplier_invoice',
'mod_facture_fournisseur_',
'INVOICE_SUPPLIER_ADDON_NUMBER', $langs->trans(
"SuppliersInvoiceNumberingModel"), $invoice);
251$sql .=
" FROM ".MAIN_DB_PREFIX.
"document_model";
252$sql .=
" WHERE type = 'invoice_supplier'";
253$sql .=
" AND entity = ".((int)
$conf->entity);
255$resql = $db->query($sql);
258 $num_rows = $db->num_rows($resql);
259 while ($i < $num_rows) {
260 $array = $db->fetch_array($resql);
261 if (is_array($array)) {
262 array_push($def, $array[0]);
267 dol_print_error($db);
270print
'<div class="div-table-responsive-no-min">';
271print
'<table class="noborder centpercent">'.
"\n";
272print
'<tr class="liste_titre">'.
"\n";
273print
'<td width="100">'.$langs->trans(
"Name").
'</td>'.
"\n";
274print
'<td>'.$langs->trans(
"Description").
'</td>'.
"\n";
275print
'<td align="center" width="60">'.$langs->trans(
"Status").
'</td>'.
"\n";
276print
'<td align="center" width="60">'.$langs->trans(
"Default").
'</td>'.
"\n";
277print
'<td align="center" width="40">'.$langs->trans(
"ShortInfo").
'</td>';
278print
'<td align="center" width="40">'.$langs->trans(
"Preview").
'</td>';
283foreach ($dirmodels as $reldir) {
284 $realpath = $reldir.
"core/modules/supplier_invoice/doc";
288 $handle = opendir($dir);
291 if (is_resource($handle)) {
292 while (($file = readdir($handle)) !==
false) {
293 if (preg_match(
'/\.modules\.php$/i', $file) && preg_match(
'/^(pdf_|doc_)/', $file)) {
297 require_once $dir.
'/'.$file;
300 '@phan-var-force ModelePDFSuppliersInvoices $module';
303 print
"<tr class=\"oddeven\">\n";
308 require_once $dir.
'/'.$file;
309 $module =
new $classname($db, $specimenthirdparty);
310 '@phan-var-force ModelePDFSuppliersInvoices $module';
311 if (method_exists(
$module,
'info')) {
320 if (in_array($name, $def)) {
321 print
'<td class="center">'.
"\n";
325 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">';
326 print img_picto($langs->trans(
"Enabled"),
'switch_on');
335 print
'<td class="center">'.
"\n";
336 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>';
341 print
'<td class="center">';
345 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>';
347 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>';
352 $htmltooltip =
''.$langs->trans(
"Name").
': '.
$module->name;
353 $htmltooltip .=
'<br>'.$langs->trans(
"Type").
': '.(
$module->type ?
$module->type : $langs->trans(
"Unknown"));
354 $htmltooltip .=
'<br>'.$langs->trans(
"Width").
'/'.$langs->trans(
"Height").
': '.
$module->page_largeur.
'/'.
$module->page_hauteur;
355 $htmltooltip .=
'<br>'.$langs->trans(
"Path").
': '.preg_replace(
'/^\//',
'', $realpath).
'/'.$file;
357 $htmltooltip .=
'<br><br><u>'.$langs->trans(
"FeaturesSupported").
':</u>';
358 $htmltooltip .=
'<br>'.$langs->trans(
"Logo").
': '.yn(
$module->option_logo, 1, 1);
359 $htmltooltip .=
'<br>'.$langs->trans(
"PaymentMode").
': '.yn(
$module->option_modereg, 1, 1);
360 $htmltooltip .=
'<br>'.$langs->trans(
"PaymentConditions").
': '.yn(
$module->option_condreg, 1, 1);
361 print
'<td class="center">';
362 print $form->textwithpicto(
'', $htmltooltip, 1,
'info');
364 print
'<td class="center">';
365 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=specimen&module='.urlencode($name).
'">'.img_object($langs->trans(
"Preview"),
'pdf').
'</a>';
377print
'</table></div><br>';
383print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="post">';
384print
'<input type="hidden" name="token" value="'.newToken().
'">';
385print
'<input type="hidden" name="action" value="set_SUPPLIER_INVOICE_FREE_TEXT">';
389print
'<div class="div-table-responsive-no-min">';
390print
'<table class="noborder centpercent">';
391print
'<tr class="liste_titre">';
392print
'<td>'.$langs->trans(
"Parameter").
'</td>';
394print
'<td width="80"> </td>';
398$substitutionarray[
'__(AnyTranslationKey)__'] = $langs->trans(
"Translation");
399$htmltext =
'<i>'.$langs->trans(
"AvailableVariables").
':<br>';
400foreach ($substitutionarray as $key => $val) {
401 $htmltext .= $key.
'<br>';
405print
'<tr class="oddeven"><td colspan="2">';
406print $form->textwithpicto($langs->trans(
"FreeLegalTextOnInvoices"), $langs->trans(
"AddCRIfTooLong").
'<br><br>'.$htmltext, 1,
'help',
'', 0, 2,
'freetexttooltip').
'<br>';
407$variablename =
'SUPPLIER_INVOICE_FREE_TEXT';
409 print
'<textarea name="'.$variablename.
'" class="flat" cols="120">'.
getDolGlobalString($variablename).
'</textarea>';
411 include_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
413 print $doleditor->Create();
415print
'</td><td class="right">';
416print
'<input type="submit" class="button button-edit" value="'.$langs->trans(
"Modify").
'">';
420print
'<tr class="oddeven">';
421print
'<td>'.$langs->trans(
"AllowExternalDownload").
'</td>';
422print
'<td class="left" colspan="2">';
423print ajax_constantonoff(
'SUPPLIER_INVOICE_ALLOW_EXTERNAL_DOWNLOAD', array(),
null, 0, 0, 0, 2, 0, 1);
427print
'<tr class="oddeven">';
428print
'<td>'.img_picto(
'',
'email',
'class="pictofixedwidth"').$langs->trans(
"Notifications").
'</td>';
429print
'<td colspan="2">';
430print $langs->trans(
"YouMayFindNotificationsFeaturesIntoModuleNotification");
442print
'</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.
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 a WYSIWYG editor.
Class to manage suppliers invoices.
Class to manage suppliers.
Class to manage third parties objects (customers, suppliers, prospects...)
if(! $sortfield) if(! $sortorder) $module
supplierorder_admin_prepare_head()
Return array head with list of tabs to view object information.
dol_strlen($string, $stringencoding='UTF-8', $binarycount=0)
Make a strlen call.
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.
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.
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.
supplier_invoice_admin_prepare_head()
Prepare array with list of tabs.