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';
 
   41$langs->loadLangs(array(
"admin", 
"other", 
"orders"));
 
   43$action = 
GETPOST(
'action', 
'aZ09');
 
   45$type = 
GETPOST(
'type', 
'alpha');
 
   46$value = 
GETPOST(
'value', 
'alpha');
 
   47$modulepart = 
GETPOST(
'modulepart', 
'aZ09');  
 
   49$label = 
GETPOST(
'label', 
'alpha');
 
   50$scandir = 
GETPOST(
'scan_dir', 
'alpha');
 
   52$specimenthirdparty = 
new Societe($db);
 
   53$specimenthirdparty->initAsSpecimen();
 
   66include DOL_DOCUMENT_ROOT.
'/core/actions_setmoduleoptions.inc.php';
 
   68if ($action == 
'updateMask') {
 
   69  $maskconstinvoice = 
GETPOST(
'maskconstinvoice', 
'aZ09');
 
   70  $maskconstcredit = 
GETPOST(
'maskconstcredit', 
'aZ09');
 
   71  $maskconstdeposit = 
GETPOST(
'maskconstdeposit', 
'aZ09');
 
   72  $maskinvoice = 
GETPOST(
'maskinvoice', 
'alpha');
 
   73  $maskcredit = 
GETPOST(
'maskcredit', 
'alpha');
 
   74  $maskdeposit = 
GETPOST(
'maskdeposit', 
'alpha');
 
   76  if ($maskconstinvoice && preg_match(
'/_MASK$/', $maskconstinvoice)) {
 
   77    $res = 
dolibarr_set_const($db, $maskconstinvoice, $maskinvoice, 
'chaine', 0, 
'', $conf->entity);
 
   79  if ($maskconstcredit && preg_match(
'/_MASK$/', $maskconstcredit)) {
 
   80    $res = 
dolibarr_set_const($db, $maskconstcredit, $maskcredit, 
'chaine', 0, 
'', $conf->entity);
 
   82  if ($maskconstdeposit && preg_match(
'/_MASK$/', $maskconstdeposit)) {
 
   83    $res = 
dolibarr_set_const($db, $maskconstdeposit, $maskdeposit, 
'chaine', 0, 
'', $conf->entity);
 
   97if ($action == 
'specimen') {  
 
   98  $modele = 
GETPOST(
'module', 
'alpha');
 
  101  $facture->initAsSpecimen();
 
  102  $facture->thirdparty = $specimenthirdparty; 
 
  107  $dirmodels = array_merge(array(
'/'), (array) $conf->modules_parts[
'models']);
 
  108  foreach ($dirmodels as $reldir) {
 
  109    $file = 
dol_buildpath($reldir.
"core/modules/supplier_invoice/doc/pdf_".$modele.
".modules.php", 0);
 
  110    if (file_exists($file)) {
 
  111      $classname = 
"pdf_".$modele;
 
  116  if ($classname !== 
'') {
 
  119    $module = 
new $classname($db, $facture);
 
  120    '@phan-var-force CommonDocGenerator $module';
 
  122    if ($module->write_file($facture, $langs) > 0) {
 
  123      header(
"Location: ".DOL_URL_ROOT.
"/document.php?modulepart=facture_fournisseur&file=SPECIMEN.pdf");
 
  131    dol_syslog($langs->trans(
"ErrorModuleNotFound"), LOG_ERR);
 
  133} elseif ($action == 
'set') {
 
  136} elseif ($action == 
'del') {
 
  139    if ($conf->global->INVOICE_SUPPLIER_ADDON_PDF == 
"$value") {
 
  143} elseif ($action == 
'setdoc') {
 
  145  if (
dolibarr_set_const($db, 
"INVOICE_SUPPLIER_ADDON_PDF", $value, 
'chaine', 0, 
'', $conf->entity)) {
 
  148    $conf->global->INVOICE_SUPPLIER_ADDON_PDF = $value;
 
  156} elseif ($action == 
'unsetdoc') {
 
  160if ($action == 
'setmod') {
 
  164  dolibarr_set_const($db, 
"INVOICE_SUPPLIER_ADDON_NUMBER", $value, 
'chaine', 0, 
'', $conf->entity);
 
  167if ($action == 
'addcat') {
 
  169  $fourn->CreateCategory($user, 
GETPOST(
'cat', 
'alphanohtml'));
 
  172if ($action == 
'set_SUPPLIER_INVOICE_FREE_TEXT') {
 
  173  $freetext = 
GETPOST(
'SUPPLIER_INVOICE_FREE_TEXT', 
'restricthtml'); 
 
  175  $res = 
dolibarr_set_const($db, 
"SUPPLIER_INVOICE_FREE_TEXT", $freetext, 
'chaine', 0, 
'', $conf->entity);
 
  193$form = 
new Form($db);
 
  195$dirmodels = array_merge(array(
'/'), (array) $conf->modules_parts[
'models']);
 
  197llxHeader(
'', 
'', 
'', 
'', 0, 0, 
'', 
'', 
'', 
'mod-admin page-supplier_invoice');
 
  199$linkback = 
'<a href="'.DOL_URL_ROOT.
'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToModuleList").
'</a>';
 
  200print 
load_fiche_titre($langs->trans(
"SuppliersSetup"), $linkback, 
'title_setup');
 
  211print 
load_fiche_titre($langs->trans(
"SuppliersInvoiceNumberingModel"), 
'', 
'');
 
  213print 
'<div class="div-table-responsive-no-min">';
 
  214print 
'<table class="noborder centpercent">';
 
  215print 
'<tr class="liste_titre">';
 
  216print 
'<td width="100">'.$langs->trans(
"Name").
'</td>';
 
  217print 
'<td>'.$langs->trans(
"Description").
'</td>';
 
  218print 
'<td>'.$langs->trans(
"Example").
'</td>';
 
  219print 
'<td align="center" width="60">'.$langs->trans(
"Status").
'</td>';
 
  220print 
'<td align="center" width="16">'.$langs->trans(
"ShortInfo").
'</td>';
 
  225foreach ($dirmodels as $reldir) {
 
  226  $dir = 
dol_buildpath($reldir.
"core/modules/supplier_invoice");
 
  229    $handle = opendir($dir);
 
  230    if (is_resource($handle)) {
 
  231      while (($file = readdir($handle)) !== 
false) {
 
  232        if (substr($file, 0, 24) == 
'mod_facture_fournisseur_' && substr($file, 
dol_strlen($file) - 3, 3) == 
'php') {
 
  233          $file = substr($file, 0, 
dol_strlen($file) - 4);
 
  235          require_once $dir.
'/'.$file.
'.php';
 
  237          $module = 
new $file();
 
  239          if ($module->isEnabled()) {
 
  241            if ($module->version == 
'development' && 
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 2) {
 
  244            if ($module->version == 
'experimental' && 
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 1) {
 
  249            print 
'<tr class="oddeven"><td>'.$module->nom.
"</td><td>\n";
 
  250            print $module->info($langs);
 
  254            print 
'<td class="nowrap">';
 
  255            $tmp = $module->getExample();
 
  256            if (preg_match(
'/^Error/', $tmp)) {
 
  257              $langs->load(
"errors");
 
  258              print 
'<div class="error">'.$langs->trans($tmp).
'</div>';
 
  259            } elseif ($tmp == 
'NotConfigured') {
 
  260              print 
'<span class="opacitymedium">'.$langs->trans($tmp).
'</span>';
 
  266            print 
'<td class="center">';
 
  267            if ($conf->global->INVOICE_SUPPLIER_ADDON_NUMBER == 
"$file") {
 
  268              print 
img_picto($langs->trans(
"Activated"), 
'switch_on');
 
  270              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>';
 
  275            $invoice->initAsSpecimen();
 
  279            $htmltooltip .= 
''.$langs->trans(
"Version").
': <b>'.$module->getVersion().
'</b><br>';
 
  280            $nextval = $module->getNextValue($mysoc, $invoice);
 
  281            if (
"$nextval" != $langs->trans(
"NotAvailable")) {  
 
  282              $htmltooltip .= 
''.$langs->trans(
"NextValue").
': ';
 
  284                if (preg_match(
'/^Error/', $nextval) || $nextval == 
'NotConfigured') {
 
  285                  $nextval = $langs->trans($nextval);
 
  287                $htmltooltip .= $nextval.
'<br>';
 
  289                $htmltooltip .= $langs->trans($module->error).
'<br>';
 
  293            print 
'<td class="center">';
 
  294            print $form->textwithpicto(
'', $htmltooltip, 1, 0);
 
  306print 
'</table></div><br>';
 
  321$sql .= 
" FROM ".MAIN_DB_PREFIX.
"document_model";
 
  322$sql .= 
" WHERE type = 'invoice_supplier'";
 
  323$sql .= 
" AND entity = ".$conf->entity;
 
  325$resql = $db->query($sql);
 
  328  $num_rows = $db->num_rows($resql);
 
  329  while ($i < $num_rows) {
 
  330    $array = $db->fetch_array($resql);
 
  331    if (is_array($array)) {
 
  332      array_push($def, $array[0]);
 
  340print 
'<div class="div-table-responsive-no-min">';
 
  341print 
'<table class="noborder centpercent">'.
"\n";
 
  342print 
'<tr class="liste_titre">'.
"\n";
 
  343print 
'<td width="100">'.$langs->trans(
"Name").
'</td>'.
"\n";
 
  344print 
'<td>'.$langs->trans(
"Description").
'</td>'.
"\n";
 
  345print 
'<td align="center" width="60">'.$langs->trans(
"Status").
'</td>'.
"\n";
 
  346print 
'<td align="center" width="60">'.$langs->trans(
"Default").
'</td>'.
"\n";
 
  347print 
'<td align="center" width="40">'.$langs->trans(
"ShortInfo").
'</td>';
 
  348print 
'<td align="center" width="40">'.$langs->trans(
"Preview").
'</td>';
 
  353foreach ($dirmodels as $reldir) {
 
  354  $realpath = $reldir.
"core/modules/supplier_invoice/doc";
 
  358    $handle = opendir($dir);
 
  361    if (is_resource($handle)) {
 
  362      while (($file = readdir($handle)) !== 
false) {
 
  363        if (preg_match(
'/\.modules\.php$/i', $file) && preg_match(
'/^(pdf_|doc_)/', $file)) {
 
  364          $name = substr($file, 4, 
dol_strlen($file) - 16);
 
  365          $classname = substr($file, 0, 
dol_strlen($file) - 12);
 
  367          require_once $dir.
'/'.$file;
 
  371          print 
"<tr class=\"oddeven\">\n";
 
  373          print(empty($module->name) ? $name : $module->
name);
 
  376          require_once $dir.
'/'.$file;
 
  377          $module = 
new $classname($db, $specimenthirdparty);
 
  378          if (method_exists($module, 
'info')) {
 
  379            print $module->info($langs);
 
  381            print $module->description;
 
  387          if (in_array($name, $def)) {
 
  388            print 
'<td class="center">'.
"\n";
 
  392            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">';
 
  393            print 
img_picto($langs->trans(
"Enabled"), 
'switch_on');
 
  402            print 
'<td class="center">'.
"\n";
 
  403            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>';
 
  408          print 
'<td class="center">';
 
  412            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>';
 
  414            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>';
 
  419          $htmltooltip = 
''.$langs->trans(
"Name").
': '.$module->name;
 
  420          $htmltooltip .= 
'<br>'.$langs->trans(
"Type").
': '.($module->type ? $module->type : $langs->trans(
"Unknown"));
 
  421          $htmltooltip .= 
'<br>'.$langs->trans(
"Width").
'/'.$langs->trans(
"Height").
': '.$module->page_largeur.
'/'.$module->page_hauteur;
 
  422          $htmltooltip .= 
'<br>'.$langs->trans(
"Path").
': '.preg_replace(
'/^\//', 
'', $realpath).
'/'.$file;
 
  424          $htmltooltip .= 
'<br><br><u>'.$langs->trans(
"FeaturesSupported").
':</u>';
 
  425          $htmltooltip .= 
'<br>'.$langs->trans(
"Logo").
': '.
yn($module->option_logo, 1, 1);
 
  426          $htmltooltip .= 
'<br>'.$langs->trans(
"PaymentMode").
': '.
yn($module->option_modereg, 1, 1);
 
  427          $htmltooltip .= 
'<br>'.$langs->trans(
"PaymentConditions").
': '.
yn($module->option_condreg, 1, 1);
 
  428          print 
'<td class="center">';
 
  429          print $form->textwithpicto(
'', $htmltooltip, 1, 0);
 
  431          print 
'<td class="center">';
 
  432          print 
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=specimen&module='.urlencode($name).
'">'.
img_object($langs->trans(
"Preview"), 
'pdf').
'</a>';
 
  444print 
'</table></div><br>';
 
  450print 
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="post">';
 
  451print 
'<input type="hidden" name="token" value="'.newToken().
'">';
 
  452print 
'<input type="hidden" name="action" value="set_SUPPLIER_INVOICE_FREE_TEXT">';
 
  456print 
'<div class="div-table-responsive-no-min">';
 
  457print 
'<table class="noborder centpercent">';
 
  458print 
'<tr class="liste_titre">';
 
  459print 
'<td>'.$langs->trans(
"Parameter").
'</td>';
 
  460print 
'<td align="center" width="60">'.$langs->trans(
"Value").
'</td>';
 
  461print 
'<td width="80"> </td>';
 
  465$substitutionarray[
'__(AnyTranslationKey)__'] = $langs->trans(
"Translation");
 
  466$htmltext = 
'<i>'.$langs->trans(
"AvailableVariables").
':<br>';
 
  467foreach ($substitutionarray as $key => $val) {
 
  468  $htmltext .= $key.
'<br>';
 
  472print 
'<tr class="oddeven"><td colspan="2">';
 
  473print $form->textwithpicto($langs->trans(
"FreeLegalTextOnInvoices"), $langs->trans(
"AddCRIfTooLong").
'<br><br>'.$htmltext, 1, 
'help', 
'', 0, 2, 
'freetexttooltip').
'<br>';
 
  474$variablename = 
'SUPPLIER_INVOICE_FREE_TEXT';
 
  476  print 
'<textarea name="'.$variablename.
'" class="flat" cols="120">'.
getDolGlobalString($variablename).
'</textarea>';
 
  478  include_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
 
  480  print $doleditor->Create();
 
  482print 
'</td><td class="right">';
 
  483print 
'<input type="submit" class="button button-edit" value="'.$langs->trans(
"Modify").
'">';
 
  486print 
'</table></div><br>';
 
  497print 
'<div class="div-table-responsive-no-min">';
 
  498print 
'<table class="noborder centpercent">';
 
  499print 
'<tr class="liste_titre">';
 
  500print 
'<td>'.$langs->trans(
"Parameter").
'</td>';
 
  501print 
'<td align="center" width="60"></td>';
 
  502print 
'<td width="80"> </td>';
 
  505print 
'<tr class="oddeven"><td colspan="2">';
 
  506print $langs->trans(
"YouMayFindNotificationsFeaturesIntoModuleNotification").
'<br>';
 
  507print 
'</td><td class="right">';
 
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...)
 
supplierorder_admin_prepare_head()
Return array head with list of tabs to view object information.
 
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
 
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
 
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
 
yn($yesno, $case=1, $color=0)
Return yes or no in current language.
 
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0)
Show tabs of a record.
 
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'.
 
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
 
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
 
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...
 
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, $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.