31 require
'../main.inc.php';
32 require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
33 require_once DOL_DOCUMENT_ROOT.
'/core/lib/pdf.lib.php';
34 require_once DOL_DOCUMENT_ROOT.
'/core/lib/fourn.lib.php';
35 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.class.php';
36 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.facture.class.php';
39 $langs->loadLangs(array(
"admin",
"other",
"orders"));
41 $action =
GETPOST(
'action',
'aZ09');
43 $type =
GETPOST(
'type',
'alpha');
44 $value =
GETPOST(
'value',
'alpha');
45 $modulepart =
GETPOST(
'modulepart',
'aZ09');
47 $label =
GETPOST(
'label',
'alpha');
48 $scandir =
GETPOST(
'scan_dir',
'alpha');
50 $specimenthirdparty =
new Societe($db);
51 $specimenthirdparty->initAsSpecimen();
64 if ($action ==
'updateMask') {
65 $maskconstinvoice =
GETPOST(
'maskconstinvoice',
'aZ09');
66 $maskconstcredit =
GETPOST(
'maskconstcredit',
'aZ09');
67 $maskconstdeposit =
GETPOST(
'maskconstdeposit',
'aZ09');
68 $maskinvoice =
GETPOST(
'maskinvoice',
'alpha');
69 $maskcredit =
GETPOST(
'maskcredit',
'alpha');
70 $maskdeposit =
GETPOST(
'maskdeposit',
'alpha');
72 if ($maskconstinvoice && preg_match(
'/_MASK$/', $maskconstinvoice)) {
73 $res =
dolibarr_set_const($db, $maskconstinvoice, $maskinvoice,
'chaine', 0,
'', $conf->entity);
75 if ($maskconstcredit && preg_match(
'/_MASK$/', $maskconstcredit)) {
76 $res =
dolibarr_set_const($db, $maskconstcredit, $maskcredit,
'chaine', 0,
'', $conf->entity);
78 if ($maskconstdeposit && preg_match(
'/_MASK$/', $maskconstdeposit)) {
79 $res =
dolibarr_set_const($db, $maskconstdeposit, $maskdeposit,
'chaine', 0,
'', $conf->entity);
93 if ($action ==
'specimen') {
94 $modele =
GETPOST(
'module',
'alpha');
97 $facture->initAsSpecimen();
98 $facture->thirdparty = $specimenthirdparty;
104 $dirmodels = array_merge(array(
'/'), (array) $conf->modules_parts[
'models']);
105 foreach ($dirmodels as $reldir) {
106 $file =
dol_buildpath($reldir.
"core/modules/supplier_invoice/doc/pdf_".$modele.
".modules.php", 0);
107 if (file_exists($file)) {
109 $classname =
"pdf_".$modele;
117 $module =
new $classname($db, $facture);
119 if ($module->write_file($facture, $langs) > 0) {
120 header(
"Location: ".DOL_URL_ROOT.
"/document.php?modulepart=facture_fournisseur&file=SPECIMEN.pdf");
128 dol_syslog($langs->trans(
"ErrorModuleNotFound"), LOG_ERR);
130 } elseif ($action ==
'set') {
133 } elseif ($action ==
'del') {
136 if ($conf->global->INVOICE_SUPPLIER_ADDON_PDF ==
"$value") {
140 } elseif ($action ==
'setdoc') {
142 if (
dolibarr_set_const($db,
"INVOICE_SUPPLIER_ADDON_PDF", $value,
'chaine', 0,
'', $conf->entity)) {
145 $conf->global->INVOICE_SUPPLIER_ADDON_PDF = $value;
153 } elseif ($action ==
'unsetdoc') {
157 if ($action ==
'setmod') {
161 dolibarr_set_const($db,
"INVOICE_SUPPLIER_ADDON_NUMBER", $value,
'chaine', 0,
'', $conf->entity);
164 if ($action ==
'addcat') {
166 $fourn->CreateCategory($user,
GETPOST(
'cat',
'alphanohtml'));
169 if ($action ==
'set_SUPPLIER_INVOICE_FREE_TEXT') {
170 $freetext =
GETPOST(
'SUPPLIER_INVOICE_FREE_TEXT',
'restricthtml');
172 $res =
dolibarr_set_const($db,
"SUPPLIER_INVOICE_FREE_TEXT", $freetext,
'chaine', 0,
'', $conf->entity);
192 $dirmodels = array_merge(array(
'/'), (array) $conf->modules_parts[
'models']);
196 $linkback =
'<a href="'.DOL_URL_ROOT.
'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToModuleList").
'</a>';
197 print
load_fiche_titre($langs->trans(
"SuppliersSetup"), $linkback,
'title_setup');
203 print
dol_get_fiche_head($head,
'invoice', $langs->trans(
"Suppliers"), -1,
'company');
208 print
load_fiche_titre($langs->trans(
"SuppliersInvoiceNumberingModel"),
'',
'');
210 print
'<div class="div-table-responsive-no-min">';
211 print
'<table class="noborder centpercent">';
212 print
'<tr class="liste_titre">';
213 print
'<td width="100">'.$langs->trans(
"Name").
'</td>';
214 print
'<td>'.$langs->trans(
"Description").
'</td>';
215 print
'<td>'.$langs->trans(
"Example").
'</td>';
216 print
'<td align="center" width="60">'.$langs->trans(
"Status").
'</td>';
217 print
'<td align="center" width="16">'.$langs->trans(
"ShortInfo").
'</td>';
222 foreach ($dirmodels as $reldir) {
223 $dir =
dol_buildpath($reldir.
"core/modules/supplier_invoice");
226 $handle = opendir($dir);
227 if (is_resource($handle)) {
228 while (($file = readdir($handle)) !==
false) {
229 if (substr($file, 0, 24) ==
'mod_facture_fournisseur_' && substr($file,
dol_strlen($file) - 3, 3) ==
'php') {
230 $file = substr($file, 0,
dol_strlen($file) - 4);
232 require_once $dir.
'/'.$file.
'.php';
236 if ($module->isEnabled()) {
238 if ($module->version ==
'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) {
241 if ($module->version ==
'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) {
246 print
'<tr class="oddeven"><td>'.$module->nom.
"</td><td>\n";
247 print $module->info();
251 print
'<td class="nowrap">';
252 $tmp = $module->getExample();
253 if (preg_match(
'/^Error/', $tmp)) {
254 $langs->load(
"errors");
255 print
'<div class="error">'.$langs->trans($tmp).
'</div>';
256 } elseif ($tmp ==
'NotConfigured') {
257 print
'<span class="opacitymedium">'.$langs->trans($tmp).
'</span>';
263 print
'<td class="center">';
264 if ($conf->global->INVOICE_SUPPLIER_ADDON_NUMBER ==
"$file") {
265 print
img_picto($langs->trans(
"Activated"),
'switch_on');
267 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>';
272 $invoice->initAsSpecimen();
276 $htmltooltip .=
''.$langs->trans(
"Version").
': <b>'.$module->getVersion().
'</b><br>';
277 $nextval = $module->getNextValue($mysoc, $invoice);
278 if (
"$nextval" != $langs->trans(
"NotAvailable")) {
279 $htmltooltip .=
''.$langs->trans(
"NextValue").
': ';
281 if (preg_match(
'/^Error/', $nextval) || $nextval ==
'NotConfigured') {
282 $nextval = $langs->trans($nextval);
284 $htmltooltip .= $nextval.
'<br>';
286 $htmltooltip .= $langs->trans($module->error).
'<br>';
290 print
'<td class="center">';
291 print
$form->textwithpicto(
'', $htmltooltip, 1, 0);
303 print
'</table></div><br>';
318 $sql .=
" FROM ".MAIN_DB_PREFIX.
"document_model";
319 $sql .=
" WHERE type = 'invoice_supplier'";
320 $sql .=
" AND entity = ".$conf->entity;
322 $resql = $db->query($sql);
325 $num_rows = $db->num_rows(
$resql);
326 while ($i < $num_rows) {
327 $array = $db->fetch_array(
$resql);
328 array_push($def, $array[0]);
335 print
'<div class="div-table-responsive-no-min">';
336 print
'<table class="noborder centpercent">'.
"\n";
337 print
'<tr class="liste_titre">'.
"\n";
338 print
'<td width="100">'.$langs->trans(
"Name").
'</td>'.
"\n";
339 print
'<td>'.$langs->trans(
"Description").
'</td>'.
"\n";
340 print
'<td align="center" width="60">'.$langs->trans(
"Status").
'</td>'.
"\n";
341 print
'<td align="center" width="60">'.$langs->trans(
"Default").
'</td>'.
"\n";
342 print
'<td align="center" width="40">'.$langs->trans(
"ShortInfo").
'</td>';
343 print
'<td align="center" width="40">'.$langs->trans(
"Preview").
'</td>';
348 foreach ($dirmodels as $reldir) {
349 $realpath = $reldir.
"core/modules/supplier_invoice/doc";
353 $handle = opendir($dir);
356 if (is_resource($handle)) {
357 while (($file = readdir($handle)) !==
false) {
358 if (preg_match(
'/\.modules\.php$/i', $file) && preg_match(
'/^(pdf_|doc_)/', $file)) {
359 $name = substr($file, 4,
dol_strlen($file) - 16);
360 $classname = substr($file, 0,
dol_strlen($file) - 12);
362 require_once $dir.
'/'.$file;
366 print
"<tr class=\"oddeven\">\n";
368 print (empty($module->name) ? $name : $module->name);
371 require_once $dir.
'/'.$file;
372 $module =
new $classname($db, $specimenthirdparty);
373 if (method_exists($module,
'info')) {
374 print $module->info($langs);
376 print $module->description;
382 if (in_array($name, $def)) {
383 print
'<td class="center">'.
"\n";
387 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">';
388 print
img_picto($langs->trans(
"Enabled"),
'switch_on');
397 print
'<td class="center">'.
"\n";
398 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>';
403 print
'<td class="center">';
407 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>';
409 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>';
414 $htmltooltip =
''.$langs->trans(
"Name").
': '.$module->name;
415 $htmltooltip .=
'<br>'.$langs->trans(
"Type").
': '.($module->type ? $module->type : $langs->trans(
"Unknown"));
416 $htmltooltip .=
'<br>'.$langs->trans(
"Width").
'/'.$langs->trans(
"Height").
': '.$module->page_largeur.
'/'.$module->page_hauteur;
417 $htmltooltip .=
'<br>'.$langs->trans(
"Path").
': '.preg_replace(
'/^\//',
'', $realpath).
'/'.$file;
419 $htmltooltip .=
'<br><br><u>'.$langs->trans(
"FeaturesSupported").
':</u>';
420 $htmltooltip .=
'<br>'.$langs->trans(
"Logo").
': '.
yn($module->option_logo, 1, 1);
421 $htmltooltip .=
'<br>'.$langs->trans(
"PaymentMode").
': '.
yn($module->option_modereg, 1, 1);
422 $htmltooltip .=
'<br>'.$langs->trans(
"PaymentConditions").
': '.
yn($module->option_condreg, 1, 1);
423 print
'<td class="center">';
424 print
$form->textwithpicto(
'', $htmltooltip, 1, 0);
426 print
'<td class="center">';
427 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=specimen&module='.urlencode($name).
'">'.
img_object($langs->trans(
"Preview"),
'pdf').
'</a>';
439 print
'</table></div><br>';
445 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="post">';
446 print
'<input type="hidden" name="token" value="'.newToken().
'">';
447 print
'<input type="hidden" name="action" value="set_SUPPLIER_INVOICE_FREE_TEXT">';
451 print
'<div class="div-table-responsive-no-min">';
452 print
'<table class="noborder centpercent">';
453 print
'<tr class="liste_titre">';
454 print
'<td>'.$langs->trans(
"Parameter").
'</td>';
455 print
'<td align="center" width="60">'.$langs->trans(
"Value").
'</td>';
456 print
'<td width="80"> </td>';
460 $substitutionarray[
'__(AnyTranslationKey)__'] = $langs->trans(
"Translation");
461 $htmltext =
'<i>'.$langs->trans(
"AvailableVariables").
':<br>';
462 foreach ($substitutionarray as $key => $val) {
463 $htmltext .= $key.
'<br>';
467 print
'<tr class="oddeven"><td colspan="2">';
468 print
$form->textwithpicto($langs->trans(
"FreeLegalTextOnInvoices"), $langs->trans(
"AddCRIfTooLong").
'<br><br>'.$htmltext, 1,
'help',
'', 0, 2,
'freetexttooltip').
'<br>';
469 $variablename =
'SUPPLIER_INVOICE_FREE_TEXT';
470 if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) {
471 print
'<textarea name="'.$variablename.
'" class="flat" cols="120">'.
getDolGlobalString($variablename).
'</textarea>';
473 include_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
475 print $doleditor->Create();
477 print
'</td><td class="right">';
478 print
'<input type="submit" class="button button-edit" value="'.$langs->trans(
"Modify").
'">';
479 print
"</td></tr>\n";
481 print
'</table></div><br>';
492 print
'<div class="div-table-responsive-no-min">';
493 print
'<table class="noborder centpercent">';
494 print
'<tr class="liste_titre">';
495 print
'<td>'.$langs->trans(
"Parameter").
'</td>';
496 print
'<td align="center" width="60"></td>';
497 print
'<td width="80"> </td>';
500 print
'<tr class="oddeven"><td colspan="2">';
501 print $langs->trans(
"YouMayFindNotificationsFeaturesIntoModuleNotification").
'<br>';
502 print
'</td><td class="right">';
503 print
"</td></tr>\n";
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.
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
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...)
if(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') &&!empty($user->rights->don->lire)) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
supplierorder_admin_prepare_head()
Return array head with list of tabs to view object informations.
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='')
Show tabs of a record.
yn($yesno, $case=1, $color=0)
Return yes or no in current language.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
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)
Return value of a param into GET or POST supervariable.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
if(!function_exists('utf8_encode')) if(!function_exists('utf8_decode')) getDolGlobalString($key, $default='')
Return 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)
Return array of possible substitutions for PDF content (without external module substitutions).
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.