diff --git a/htdocs/admin/bank.php b/htdocs/admin/bank.php index 8a5c60c8483..bccae5bbfaf 100644 --- a/htdocs/admin/bank.php +++ b/htdocs/admin/bank.php @@ -40,6 +40,7 @@ if (!$user->admin) accessforbidden(); $action = GETPOST('action','alpha'); +$type = 'bankaccount'; /* @@ -60,14 +61,82 @@ if ($action == 'setbankorder') } } + +if ($action == 'specimen') +{ + $modele=GETPOST('module','alpha'); + + $commande = new Commande($db); + $commande->initAsSpecimen(); + + // Search template files + $file=''; $classname=''; $filefound=0; + $dirmodels=array_merge(array('/'),(array) $conf->modules_parts['models']); + foreach($dirmodels as $reldir) + { + $file=dol_buildpath($reldir."core/modules/paymentorders/doc/pdf_".$modele.".modules.php",0); + if (file_exists($file)) + { + $filefound=1; + $classname = "pdf_".$modele; + break; + } + } + + if ($filefound) + { + require_once $file; + + $module = new $classname($db); + + if ($module->write_file($commande,$langs) > 0) + { + header("Location: ".DOL_URL_ROOT."/document.php?modulepart=paymentorders&file=SPECIMEN.pdf"); + return; + } + else + { + setEventMessages($module->error, null, 'errors'); + dol_syslog($module->error, LOG_ERR); + } + } + else + { + setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors'); + dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR); + } +} + +// Set default model +else if ($action == 'setdoc') +{ + if (dolibarr_set_const($db, "PAYMENTORDER_ADDON_PDF",$value,'chaine',0,'',$conf->entity)) + { + // The constant that was read before the new set + // We therefore requires a variable to have a coherent view + $conf->global->PAYMENTORDER_ADDON_PDF = $value; + } + + // On active le modele + $ret = delDocumentModel($value, $type); + if ($ret > 0) + { + $ret = addDocumentModel($value, $type, $label, $scandir); + } +} + + + /* * view */ -llxHeader("",$langs->trans("BankSetupModule")); - $form=new Form($db); +$dirmodels=array_merge(array('/'),(array) $conf->modules_parts['models']); + +llxHeader("",$langs->trans("BankSetupModule")); + $linkback=''.$langs->trans("BackToModuleList").''; print load_fiche_titre($langs->trans("BankSetupModule"),$linkback,'title_setup'); @@ -79,7 +148,7 @@ $var=true; $var=! $var; //Show bank account order -print load_fiche_titre($langs->trans("BankOrderShow")); +print load_fiche_titre($langs->trans("BankOrderShow"), '', ''); print '
| ' . $langs->trans("Name") . ' | '; +print '' . $langs->trans("Description") . ' | '; +print '' . $langs->trans("Status") . " | \n"; +print '' . $langs->trans("Default") . " | \n"; +print '' . $langs->trans("ShortInfo") . ' | '; +print '' . $langs->trans("Preview") . ' | '; +print "|
| '; + print(empty($module->name) ? $name : $module->name); + print " | \n"; + if (method_exists($module, 'info')) + print $module->info($langs); + else + print $module->description; + print ' | '; + + // Active + if (in_array($name, $def)) { + print '' . "\n"; + print ''; + print img_picto($langs->trans("Enabled"), 'switch_on'); + print ''; + print ' | '; + } else { + print '' . "\n"; + print 'scandir . '&label=' . urlencode($module->name) . '">' . img_picto($langs->trans("Disabled"), 'switch_off') . ''; + print " | "; + } + + // Default + print ''; + if ($conf->global->PAYMENTORDER_ADDON_PDF == $name) { + print img_picto($langs->trans("Default"), 'on'); + } else { + print 'scandir . '&label=' . urlencode($module->name) . '" alt="' . $langs->trans("Default") . '">' . img_picto($langs->trans("Disabled"), 'off') . ''; + } + print ' | '; + + // Info + $htmltooltip = '' . $langs->trans("Name") . ': ' . $module->name; + $htmltooltip .= ''; + print $form->textwithpicto('', $htmltooltip, 1, 0); + print ' | '; + + // Preview + print ''; + if ($module->type == 'pdf') { + print '' . img_object($langs->trans("Preview"), 'bill') . ''; + } else { + print img_object($langs->trans("PreviewNotAvailable"), 'generic'); + } + print ' | '; + + print "