26 require
'../main.inc.php';
27 require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
28 require_once DOL_DOCUMENT_ROOT.
'/core/lib/pdf.lib.php';
29 require_once DOL_DOCUMENT_ROOT.
'/supplier_proposal/class/supplier_proposal.class.php';
30 require_once DOL_DOCUMENT_ROOT.
'/core/lib/supplier_proposal.lib.php';
33 $langs->loadLangs(array(
"admin",
"errors",
"other",
"supplier_proposal"));
39 $action =
GETPOST(
'action',
'aZ09');
40 $value =
GETPOST(
'value',
'alpha');
41 $modulepart =
GETPOST(
'modulepart',
'aZ09');
43 $label =
GETPOST(
'label',
'alpha');
44 $scandir =
GETPOST(
'scan_dir',
'alpha');
45 $type =
'supplier_proposal';
54 include DOL_DOCUMENT_ROOT.
'/core/actions_setmoduleoptions.inc.php';
56 if ($action ==
'updateMask') {
57 $maskconstsupplier_proposal =
GETPOST(
'maskconstsupplier_proposal',
'alpha');
58 $masksupplier_proposal =
GETPOST(
'masksupplier_proposal',
'alpha');
59 if ($maskconstsupplier_proposal) {
60 $res =
dolibarr_set_const($db, $maskconstsupplier_proposal, $masksupplier_proposal,
'chaine', 0,
'', $conf->entity);
74 if ($action ==
'specimen') {
75 $modele =
GETPOST(
'module',
'alpha');
78 $supplier_proposal->initAsSpecimen();
81 $file =
''; $classname =
''; $filefound = 0;
82 $dirmodels = array_merge(array(
'/'), (array) $conf->modules_parts[
'models']);
83 foreach ($dirmodels as $reldir) {
84 $file =
dol_buildpath($reldir.
"core/modules/supplier_proposal/doc/pdf_".$modele.
".modules.php");
85 if (file_exists($file)) {
87 $classname =
"pdf_".$modele;
95 $module =
new $classname($db);
97 if ($module->write_file($supplier_proposal, $langs) > 0) {
98 header(
"Location: ".DOL_URL_ROOT.
"/document.php?modulepart=supplier_proposal&file=SPECIMEN.pdf");
106 dol_syslog($langs->trans(
"ErrorModuleNotFound"), LOG_ERR);
110 if ($action ==
'set_SUPPLIER_PROPOSAL_DRAFT_WATERMARK') {
111 $draft =
GETPOST(
'SUPPLIER_PROPOSAL_DRAFT_WATERMARK',
'alpha');
113 $res =
dolibarr_set_const($db,
"SUPPLIER_PROPOSAL_DRAFT_WATERMARK", trim($draft),
'chaine', 0,
'', $conf->entity);
125 if ($action ==
'set_SUPPLIER_PROPOSAL_FREE_TEXT') {
126 $freetext =
GETPOST(
'SUPPLIER_PROPOSAL_FREE_TEXT',
'restricthtml');
128 $res =
dolibarr_set_const($db,
"SUPPLIER_PROPOSAL_FREE_TEXT", $freetext,
'chaine', 0,
'', $conf->entity);
141 if ($action ==
'set_BANK_ASK_PAYMENT_BANK_DURING_SUPPLIER_PROPOSAL') {
142 $res =
dolibarr_set_const($db,
"BANK_ASK_PAYMENT_BANK_DURING_SUPPLIER_PROPOSAL", $value,
'chaine', 0,
'', $conf->entity);
156 if ($action ==
'set') {
158 } elseif ($action ==
'del') {
161 if ($conf->global->SUPPLIER_PROPOSAL_ADDON_PDF ==
"$value") {
165 } elseif ($action ==
'setdoc') {
166 if (
dolibarr_set_const($db,
"SUPPLIER_PROPOSAL_ADDON_PDF", $value,
'chaine', 0,
'', $conf->entity)) {
167 $conf->global->SUPPLIER_PROPOSAL_ADDON_PDF = $value;
175 } elseif ($action ==
'setmod') {
179 dolibarr_set_const($db,
"SUPPLIER_PROPOSAL_ADDON", $value,
'chaine', 0,
'', $conf->entity);
187 $dirmodels = array_merge(array(
'/'), (array) $conf->modules_parts[
'models']);
190 llxHeader(
'', $langs->trans(
"SupplierProposalSetup"));
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(
"SupplierProposalSetup"), $linkback,
'title_setup');
199 $head = supplier_proposal_admin_prepare_head();
201 print
dol_get_fiche_head($head,
'general', $langs->trans(
"CommRequests"), -1,
'supplier_proposal');
206 print
load_fiche_titre($langs->trans(
"SupplierProposalNumberingModules"),
'',
'');
208 print
'<table class="noborder centpercent">';
209 print
'<tr class="liste_titre">';
210 print
'<td>'.$langs->trans(
"Name").
"</td>\n";
211 print
'<td>'.$langs->trans(
"Description").
"</td>\n";
212 print
'<td class="nowrap">'.$langs->trans(
"Example").
"</td>\n";
213 print
'<td align="center" width="60">'.$langs->trans(
"Status").
'</td>';
214 print
'<td align="center" width="16">'.$langs->trans(
"ShortInfo").
'</td>';
218 foreach ($dirmodels as $reldir) {
219 $dir =
dol_buildpath($reldir.
"core/modules/supplier_proposal");
222 $handle = opendir($dir);
223 if (is_resource($handle)) {
224 while (($file = readdir($handle)) !==
false) {
225 if (substr($file, 0, 22) ==
'mod_supplier_proposal_' && substr($file,
dol_strlen($file) - 3, 3) ==
'php') {
226 $file = substr($file, 0,
dol_strlen($file) - 4);
228 require_once $dir.
'/'.$file.
'.php';
233 if ($module->version ==
'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) {
236 if ($module->version ==
'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) {
240 if ($module->isEnabled()) {
241 print
'<tr class="oddeven"><td>'.$module->nom.
"</td><td>\n";
242 print $module->info();
246 print
'<td class="nowrap">';
247 $tmp = $module->getExample();
248 if (preg_match(
'/^Error/', $tmp)) {
249 $langs->load(
"errors");
250 print
'<div class="error">'.$langs->trans($tmp).
'</div>';
251 } elseif ($tmp ==
'NotConfigured') {
252 print
'<span class="opacitymedium">'.$langs->trans($tmp).
'</span>';
258 print
'<td class="center">';
259 if ($conf->global->SUPPLIER_PROPOSAL_ADDON ==
"$file") {
260 print
img_picto($langs->trans(
"Activated"),
'switch_on');
262 print
'<a class="reposition" href="'.$_SERVER[
"PHP_SELF"].
'?action=setmod&token='.
newToken().
'&value='.urlencode($file).
'">';
263 print
img_picto($langs->trans(
"Disabled"),
'switch_off');
269 $supplier_proposal->initAsSpecimen();
273 $htmltooltip .=
''.$langs->trans(
"Version").
': <b>'.$module->getVersion().
'</b><br>';
274 $nextval = $module->getNextValue($mysoc, $supplier_proposal);
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);
299 print
"</table><br>\n";
306 print
load_fiche_titre($langs->trans(
"SupplierProposalPDFModules"),
'',
'');
311 $sql .=
" FROM ".MAIN_DB_PREFIX.
"document_model";
312 $sql .=
" WHERE type = '".$db->escape($type).
"'";
313 $sql .=
" AND entity = ".$conf->entity;
314 $resql = $db->query($sql);
317 $num_rows = $db->num_rows(
$resql);
318 while ($i < $num_rows) {
319 $array = $db->fetch_array(
$resql);
320 array_push($def, $array[0]);
328 print
"<table class=\"noborder\" width=\"100%\">\n";
329 print
"<tr class=\"liste_titre\">\n";
330 print
" <td>".$langs->trans(
"Name").
"</td>\n";
331 print
" <td>".$langs->trans(
"Description").
"</td>\n";
332 print
'<td align="center" width="40">'.$langs->trans(
"Status").
"</td>\n";
333 print
'<td align="center" width="40">'.$langs->trans(
"Default").
"</td>\n";
334 print
'<td align="center" width="40">'.$langs->trans(
"ShortInfo").
'</td>';
335 print
'<td align="center" width="40">'.$langs->trans(
"Preview").
'</td>';
340 foreach ($dirmodels as $reldir) {
341 foreach (array(
'',
'/doc') as $valdir) {
342 $realpath = $reldir.
"core/modules/supplier_proposal".$valdir;
346 $handle = opendir($dir);
347 if (is_resource($handle)) {
348 while (($file = readdir($handle)) !==
false) {
354 foreach ($filelist as $file) {
355 if (preg_match(
'/\.modules\.php$/i', $file) && preg_match(
'/^(pdf_|doc_)/', $file)) {
356 if (file_exists($dir.
'/'.$file)) {
357 $name = substr($file, 4,
dol_strlen($file) - 16);
358 $classname = substr($file, 0,
dol_strlen($file) - 12);
360 require_once $dir.
'/'.$file;
361 $module =
new $classname($db);
363 $modulequalified = 1;
364 if ($module->version ==
'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) {
365 $modulequalified = 0;
367 if ($module->version ==
'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) {
368 $modulequalified = 0;
371 if ($modulequalified) {
372 print
'<tr class="oddeven"><td width="100">';
373 print (empty($module->name) ? $name : $module->name);
375 if (method_exists($module,
'info')) {
376 print $module->info($langs);
378 print $module->description;
383 if (in_array($name, $def)) {
384 print
'<td class="center">'.
"\n";
385 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=del&token='.
newToken().
'&value='.urlencode($name).
'">';
386 print
img_picto($langs->trans(
"Enabled"),
'switch_on');
390 print
'<td align="center">'.
"\n";
391 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=set&token='.
newToken().
'&value='.urlencode($name).
'&scan_dir='.urlencode($module->scandir).
'&label='.urlencode($module->name).
'">'.
img_picto($langs->trans(
"Disabled"),
'switch_off').
'</a>';
396 print
'<td align="center">';
397 if ($conf->global->SUPPLIER_PROPOSAL_ADDON_PDF ==
"$name") {
398 print
img_picto($langs->trans(
"Default"),
'on');
400 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=setdoc&token='.
newToken().
'&value='.urlencode($name).
'&scan_dir='.urlencode($module->scandir).
'&label='.urlencode($module->name).
'" alt="'.$langs->trans(
"Default").
'">'.
img_picto($langs->trans(
"Disabled"),
'off').
'</a>';
405 $htmltooltip =
''.$langs->trans(
"Name").
': '.$module->name;
406 $htmltooltip .=
'<br>'.$langs->trans(
"Type").
': '.($module->type ? $module->type : $langs->trans(
"Unknown"));
407 if ($module->type ==
'pdf') {
408 $htmltooltip .=
'<br>'.$langs->trans(
"Width").
'/'.$langs->trans(
"Height").
': '.$module->page_largeur.
'/'.$module->page_hauteur;
410 $htmltooltip .=
'<br>'.$langs->trans(
"Path").
': '.preg_replace(
'/^\//',
'', $realpath).
'/'.$file;
412 $htmltooltip .=
'<br><br><u>'.$langs->trans(
"FeaturesSupported").
':</u>';
413 $htmltooltip .=
'<br>'.$langs->trans(
"Logo").
': '.
yn($module->option_logo, 1, 1);
414 $htmltooltip .=
'<br>'.$langs->trans(
"PaymentMode").
': '.
yn($module->option_modereg, 1, 1);
415 $htmltooltip .=
'<br>'.$langs->trans(
"PaymentConditions").
': '.
yn($module->option_condreg, 1, 1);
416 $htmltooltip .=
'<br>'.$langs->trans(
"MultiLanguage").
': '.
yn($module->option_multilang, 1, 1);
419 $htmltooltip .=
'<br>'.$langs->trans(
"WatermarkOnDraftProposal").
': '.
yn($module->option_draft_watermark, 1, 1);
422 print
'<td class="center">';
423 print
$form->textwithpicto(
'', $htmltooltip, 1, 0);
427 print
'<td class="center">';
428 if ($module->type ==
'pdf') {
429 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=specimen&module='.$name.
'">'.
img_object($langs->trans(
"Preview"),
'pdf').
'</a>';
431 print
img_object($langs->trans(
"PreviewNotAvailable"),
'generic');
455 print
"<table class=\"noborder\" width=\"100%\">";
456 print
"<tr class=\"liste_titre\">";
457 print
"<td>".$langs->trans(
"Parameter").
"</td>\n";
458 print
'<td width="60" align="center">'.$langs->trans(
"Value").
"</td>\n";
459 print
"<td> </td>\n";
463 $substitutionarray[
'__(AnyTranslationKey)__'] = $langs->trans(
"Translation");
464 $htmltext =
'<i>'.$langs->trans(
"AvailableVariables").
':<br>';
465 foreach ($substitutionarray as $key => $val) {
466 $htmltext .= $key.
'<br>';
470 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="post">';
471 print
'<input type="hidden" name="token" value="'.newToken().
'">';
472 print
'<input type="hidden" name="action" value="set_SUPPLIER_PROPOSAL_FREE_TEXT">';
473 print
'<tr class="oddeven"><td colspan="2">';
474 print
$form->textwithpicto($langs->trans(
"FreeLegalTextOnSupplierProposal"), $langs->trans(
"AddCRIfTooLong").
'<br><br>'.$htmltext, 1,
'help',
'', 0, 2,
'freetexttooltip').
'<br>';
475 $variablename =
'SUPPLIER_PROPOSAL_FREE_TEXT';
476 if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) {
477 print
'<textarea name="'.$variablename.
'" class="flat" cols="120">'.
getDolGlobalString($variablename).
'</textarea>';
479 include_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
481 print $doleditor->Create();
483 print
'</td><td class="right">';
484 print
'<input type="submit" class="button button-edit" value="'.$langs->trans(
"Modify").
'">';
485 print
"</td></tr>\n";
489 print
"<form method=\"post\" action=\"".$_SERVER[
"PHP_SELF"].
"\">";
490 print
'<input type="hidden" name="token" value="'.newToken().
'">';
491 print
"<input type=\"hidden\" name=\"action\" value=\"set_SUPPLIER_PROPOSAL_DRAFT_WATERMARK\">";
492 print
'<tr class="oddeven"><td>';
493 print
$form->textwithpicto($langs->trans(
"WatermarkOnDraftProposal"), $htmltext, 1,
'help',
'', 0, 2,
'watermarktooltip').
'<br>';
495 print
'<input class="flat minwidth200" type="text" name="SUPPLIER_PROPOSAL_DRAFT_WATERMARK" value="'.dol_escape_htmltag(
getDolGlobalString(
'SUPPLIER_PROPOSAL_DRAFT_WATERMARK')).
'">';
496 print
'</td><td class="right">';
497 print
'<input type="submit" class="button button-edit" value="'.$langs->trans(
"Modify").
'">';
498 print
"</td></tr>\n";
501 if (!empty($conf->banque->enabled)) {
502 print
'<tr class="oddeven"><td>';
503 print $langs->trans(
"BANK_ASK_PAYMENT_BANK_DURING_SUPPLIER_PROPOSAL").
'</td><td> </td><td class="right">';
504 if (!empty($conf->use_javascript_ajax)) {
507 if (empty($conf->global->BANK_ASK_PAYMENT_BANK_DURING_SUPPLIER_PROPOSAL)) {
508 print
'<a href="'.$_SERVER[
'PHP_SELF'].
'?action=set_BANK_ASK_PAYMENT_BANK_DURING_SUPPLIER_PROPOSAL&token='.
newToken().
'&value=1">'.
img_picto($langs->trans(
"Disabled"),
'switch_off').
'</a>';
510 print
'<a href="'.$_SERVER[
'PHP_SELF'].
'?action=set_BANK_ASK_PAYMENT_BANK_DURING_SUPPLIER_PROPOSAL&token='.
newToken().
'&value=0">'.
img_picto($langs->trans(
"Enabled"),
'switch_on').
'</a>';
515 print
'<tr class="oddeven"><td>';
516 print $langs->trans(
"BANK_ASK_PAYMENT_BANK_DURING_SUPPLIER_PROPOSAL").
'</td><td> </td><td align="center">'.$langs->trans(
'NotAvailable').
'</td></tr>';
529 print
"<table class=\"noborder\" width=\"100%\">\n";
530 print
"<tr class=\"liste_titre\">\n";
531 print
" <td>".$langs->trans(
"Name").
"</td>\n";
532 print
" <td>".$langs->trans(
"Value").
"</td>\n";
534 print
"<tr class=\"oddeven\">\n <td width=\"140\">".$langs->trans(
"PathDirectory").
"</td>\n <td>".$conf->supplier_proposal->dir_output.
"</td>\n</tr>\n";
535 print
"</table>\n<br>";