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 $type =
GETPOST(
'type',
'alpha');
42 $value =
GETPOST(
'value',
'alpha');
43 $action =
GETPOST(
'action',
'aZ09');
45 $label =
GETPOST(
'label',
'alpha');
46 $scandir =
GETPOST(
'scan_dir',
'alpha');
48 $specimenthirdparty =
new Societe($db);
49 $specimenthirdparty->initAsSpecimen();
62 include DOL_DOCUMENT_ROOT.
'/core/actions_setmoduleoptions.inc.php';
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;
101 $file =
''; $classname =
''; $filefound = 0;
102 $dirmodels = array_merge(array(
'/'), (array) $conf->modules_parts[
'models']);
103 foreach ($dirmodels as $reldir) {
104 $file =
dol_buildpath($reldir.
"core/modules/supplier_invoice/doc/pdf_".$modele.
".modules.php", 0);
105 if (file_exists($file)) {
107 $classname =
"pdf_".$modele;
115 $module =
new $classname($db, $facture);
117 if ($module->write_file($facture, $langs) > 0) {
118 header(
"Location: ".DOL_URL_ROOT.
"/document.php?modulepart=facture_fournisseur&file=SPECIMEN.pdf");
126 dol_syslog($langs->trans(
"ErrorModuleNotFound"), LOG_ERR);
128 } elseif ($action ==
'set') {
131 } elseif ($action ==
'del') {
134 if ($conf->global->INVOICE_SUPPLIER_ADDON_PDF ==
"$value") {
138 } elseif ($action ==
'setdoc') {
140 if (
dolibarr_set_const($db,
"INVOICE_SUPPLIER_ADDON_PDF", $value,
'chaine', 0,
'', $conf->entity)) {
143 $conf->global->INVOICE_SUPPLIER_ADDON_PDF = $value;
151 } elseif ($action ==
'unsetdoc') {
155 if ($action ==
'setmod') {
159 dolibarr_set_const($db,
"INVOICE_SUPPLIER_ADDON_NUMBER", $value,
'chaine', 0,
'', $conf->entity);
162 if ($action ==
'addcat') {
164 $fourn->CreateCategory($user,
GETPOST(
'cat',
'alphanohtml'));
167 if ($action ==
'set_SUPPLIER_INVOICE_FREE_TEXT') {
168 $freetext =
GETPOST(
'SUPPLIER_INVOICE_FREE_TEXT',
'restricthtml');
170 $res =
dolibarr_set_const($db,
"SUPPLIER_INVOICE_FREE_TEXT", $freetext,
'chaine', 0,
'', $conf->entity);
188 $dirmodels = array_merge(array(
'/'), (array) $conf->modules_parts[
'models']);
194 $linkback =
'<a href="'.DOL_URL_ROOT.
'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToModuleList").
'</a>';
195 print
load_fiche_titre($langs->trans(
"SuppliersSetup"), $linkback,
'title_setup');
201 print
dol_get_fiche_head($head,
'invoice', $langs->trans(
"Suppliers"), -1,
'company');
206 print
load_fiche_titre($langs->trans(
"SuppliersInvoiceNumberingModel"),
'',
'');
208 print
'<table class="noborder centpercent">';
209 print
'<tr class="liste_titre">';
210 print
'<td width="100">'.$langs->trans(
"Name").
'</td>';
211 print
'<td>'.$langs->trans(
"Description").
'</td>';
212 print
'<td>'.$langs->trans(
"Example").
'</td>';
213 print
'<td align="center" width="60">'.$langs->trans(
"Status").
'</td>';
214 print
'<td align="center" width="16">'.$langs->trans(
"ShortInfo").
'</td>';
219 foreach ($dirmodels as $reldir) {
220 $dir =
dol_buildpath($reldir.
"core/modules/supplier_invoice");
223 $handle = opendir($dir);
224 if (is_resource($handle)) {
225 while (($file = readdir($handle)) !==
false) {
226 if (substr($file, 0, 24) ==
'mod_facture_fournisseur_' && substr($file,
dol_strlen($file) - 3, 3) ==
'php') {
227 $file = substr($file, 0,
dol_strlen($file) - 4);
229 require_once $dir.
'/'.$file.
'.php';
233 if ($module->isEnabled()) {
235 if ($module->version ==
'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) {
238 if ($module->version ==
'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) {
243 print
'<tr class="oddeven"><td>'.$module->nom.
"</td><td>\n";
244 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">';
261 if ($conf->global->INVOICE_SUPPLIER_ADDON_NUMBER ==
"$file") {
262 print
img_picto($langs->trans(
"Activated"),
'switch_on');
264 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>';
269 $invoice->initAsSpecimen();
273 $htmltooltip .=
''.$langs->trans(
"Version").
': <b>'.$module->getVersion().
'</b><br>';
274 $nextval = $module->getNextValue($mysoc, $invoice);
275 if (
"$nextval" != $langs->trans(
"NotAvailable")) {
276 $htmltooltip .=
''.$langs->trans(
"NextValue").
': ';
278 if (preg_match(
'/^Error/', $nextval) || $nextval ==
'NotConfigured') {
279 $nextval = $langs->trans($nextval);
281 $htmltooltip .= $nextval.
'<br>';
283 $htmltooltip .= $langs->trans($module->error).
'<br>';
287 print
'<td class="center">';
288 print
$form->textwithpicto(
'', $htmltooltip, 1, 0);
300 print
'</table><br>';
315 $sql .=
" FROM ".MAIN_DB_PREFIX.
"document_model";
316 $sql .=
" WHERE type = 'invoice_supplier'";
317 $sql .=
" AND entity = ".$conf->entity;
319 $resql = $db->query($sql);
322 $num_rows = $db->num_rows(
$resql);
323 while ($i < $num_rows) {
324 $array = $db->fetch_array(
$resql);
325 array_push($def, $array[0]);
332 print
'<table class="noborder centpercent">'.
"\n";
333 print
'<tr class="liste_titre">'.
"\n";
334 print
'<td width="100">'.$langs->trans(
"Name").
'</td>'.
"\n";
335 print
'<td>'.$langs->trans(
"Description").
'</td>'.
"\n";
336 print
'<td align="center" width="60">'.$langs->trans(
"Status").
'</td>'.
"\n";
337 print
'<td align="center" width="60">'.$langs->trans(
"Default").
'</td>'.
"\n";
338 print
'<td align="center" width="40">'.$langs->trans(
"ShortInfo").
'</td>';
339 print
'<td align="center" width="40">'.$langs->trans(
"Preview").
'</td>';
344 foreach ($dirmodels as $reldir) {
345 $realpath = $reldir.
"core/modules/supplier_invoice/doc";
349 $handle = opendir($dir);
352 if (is_resource($handle)) {
353 while (($file = readdir($handle)) !==
false) {
354 if (preg_match(
'/\.modules\.php$/i', $file) && preg_match(
'/^(pdf_|doc_)/', $file)) {
355 $name = substr($file, 4,
dol_strlen($file) - 16);
356 $classname = substr($file, 0,
dol_strlen($file) - 12);
358 require_once $dir.
'/'.$file;
362 print
"<tr class=\"oddeven\">\n";
364 print (empty($module->name) ? $name : $module->name);
367 require_once $dir.
'/'.$file;
368 $module =
new $classname($db, $specimenthirdparty);
369 if (method_exists($module,
'info')) {
370 print $module->info($langs);
372 print $module->description;
378 if (in_array($name, $def)) {
379 print
'<td class="center">'.
"\n";
383 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=del&token='.
newToken().
'&value='.urlencode($name).
'&scan_dir='.urlencode($module->scandir).
'&label='.urlencode($module->name).
'&type=invoice_supplier">';
384 print
img_picto($langs->trans(
"Enabled"),
'switch_on');
393 print
'<td class="center">'.
"\n";
394 print
'<a 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>';
399 print
'<td class="center">';
403 print
'<a 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>';
405 print
'<a 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>';
410 $htmltooltip =
''.$langs->trans(
"Name").
': '.$module->name;
411 $htmltooltip .=
'<br>'.$langs->trans(
"Type").
': '.($module->type ? $module->type : $langs->trans(
"Unknown"));
412 $htmltooltip .=
'<br>'.$langs->trans(
"Width").
'/'.$langs->trans(
"Height").
': '.$module->page_largeur.
'/'.$module->page_hauteur;
413 $htmltooltip .=
'<br>'.$langs->trans(
"Path").
': '.preg_replace(
'/^\//',
'', $realpath).
'/'.$file;
415 $htmltooltip .=
'<br><br><u>'.$langs->trans(
"FeaturesSupported").
':</u>';
416 $htmltooltip .=
'<br>'.$langs->trans(
"Logo").
': '.
yn($module->option_logo, 1, 1);
417 $htmltooltip .=
'<br>'.$langs->trans(
"PaymentMode").
': '.
yn($module->option_modereg, 1, 1);
418 $htmltooltip .=
'<br>'.$langs->trans(
"PaymentConditions").
': '.
yn($module->option_condreg, 1, 1);
419 print
'<td class="center">';
420 print
$form->textwithpicto(
'', $htmltooltip, 1, 0);
422 print
'<td class="center">';
423 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=specimen&module='.$name.
'">'.
img_object($langs->trans(
"Preview"),
'pdf').
'</a>';
435 print
'</table><br>';
441 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="post">';
442 print
'<input type="hidden" name="token" value="'.newToken().
'">';
443 print
'<input type="hidden" name="action" value="set_SUPPLIER_INVOICE_FREE_TEXT">';
446 print
'<table class="noborder centpercent">';
447 print
'<tr class="liste_titre">';
448 print
'<td>'.$langs->trans(
"Parameter").
'</td>';
449 print
'<td align="center" width="60">'.$langs->trans(
"Value").
'</td>';
450 print
'<td width="80"> </td>';
454 $substitutionarray[
'__(AnyTranslationKey)__'] = $langs->trans(
"Translation");
455 $htmltext =
'<i>'.$langs->trans(
"AvailableVariables").
':<br>';
456 foreach ($substitutionarray as $key => $val) {
457 $htmltext .= $key.
'<br>';
461 print
'<tr class="oddeven"><td colspan="2">';
462 print
$form->textwithpicto($langs->trans(
"FreeLegalTextOnInvoices"), $langs->trans(
"AddCRIfTooLong").
'<br><br>'.$htmltext, 1,
'help',
'', 0, 2,
'freetexttooltip').
'<br>';
463 $variablename =
'SUPPLIER_INVOICE_FREE_TEXT';
464 if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) {
465 print
'<textarea name="'.$variablename.
'" class="flat" cols="120">'.
getDolGlobalString($variablename).
'</textarea>';
467 include_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
469 print $doleditor->Create();
471 print
'</td><td class="right">';
472 print
'<input type="submit" class="button button-edit" value="'.$langs->trans(
"Modify").
'">';
473 print
"</td></tr>\n";
475 print
'</table><br>';
485 print
'<table class="noborder centpercent">';
486 print
'<tr class="liste_titre">';
487 print
'<td>'.$langs->trans(
"Parameter").
'</td>';
488 print
'<td align="center" width="60"></td>';
489 print
'<td width="80"> </td>';
492 print
'<tr class="oddeven"><td colspan="2">';
493 print $langs->trans(
"YouMayFindNotificationsFeaturesIntoModuleNotification").
'<br>';
494 print
'</td><td class="right">';
495 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.