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"));
37 $action =
GETPOST(
'action',
'aZ09');
38 $value =
GETPOST(
'value',
'alpha');
39 $label =
GETPOST(
'label',
'alpha');
40 $scandir =
GETPOST(
'scan_dir',
'alpha');
41 $type =
'supplier_proposal';
50 include DOL_DOCUMENT_ROOT.
'/core/actions_setmoduleoptions.inc.php';
52 if ($action ==
'updateMask')
54 $maskconstsupplier_proposal =
GETPOST(
'maskconstsupplier_proposal',
'alpha');
55 $masksupplier_proposal =
GETPOST(
'masksupplier_proposal',
'alpha');
56 if ($maskconstsupplier_proposal) $res =
dolibarr_set_const($db, $maskconstsupplier_proposal, $masksupplier_proposal,
'chaine', 0,
'', $conf->entity);
58 if (!($res > 0)) $error++;
68 if ($action ==
'specimen')
70 $modele =
GETPOST(
'module',
'alpha');
73 $supplier_proposal->initAsSpecimen();
76 $file =
''; $classname =
''; $filefound = 0;
77 $dirmodels = array_merge(array(
'/'), (array) $conf->modules_parts[
'models']);
78 foreach ($dirmodels as $reldir)
80 $file =
dol_buildpath($reldir.
"core/modules/supplier_proposal/doc/pdf_".$modele.
".modules.php");
81 if (file_exists($file))
84 $classname =
"pdf_".$modele;
93 $module =
new $classname($db);
95 if ($module->write_file($supplier_proposal, $langs) > 0)
97 header(
"Location: ".DOL_URL_ROOT.
"/document.php?modulepart=supplier_proposal&file=SPECIMEN.pdf");
105 dol_syslog($langs->trans(
"ErrorModuleNotFound"), LOG_ERR);
109 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);
114 if (!($res > 0)) $error++;
124 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);
130 if (!($res > 0)) $error++;
140 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);
144 if (!($res > 0)) $error++;
155 if ($action ==
'set')
158 } elseif ($action ==
'del')
163 if ($conf->global->SUPPLIER_PROPOSAL_ADDON_PDF ==
"$value")
dolibarr_del_const($db,
'SUPPLIER_PROPOSAL_ADDON_PDF', $conf->entity);
165 } elseif ($action ==
'setdoc')
167 if (
dolibarr_set_const($db,
"SUPPLIER_PROPOSAL_ADDON_PDF", $value,
'chaine', 0,
'', $conf->entity))
169 $conf->global->SUPPLIER_PROPOSAL_ADDON_PDF = $value;
178 } elseif ($action ==
'setmod')
183 dolibarr_set_const($db,
"SUPPLIER_PROPOSAL_ADDON", $value,
'chaine', 0,
'', $conf->entity);
191 $dirmodels = array_merge(array(
'/'), (array) $conf->modules_parts[
'models']);
194 llxHeader(
'', $langs->trans(
"SupplierProposalSetup"));
196 $form =
new Form($db);
200 $linkback =
'<a href="'.DOL_URL_ROOT.
'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToModuleList").
'</a>';
203 $head = supplier_proposal_admin_prepare_head();
212 print '<table class="noborder centpercent">';
213 print
'<tr class="liste_titre">';
214 print
'<td>'.$langs->trans(
"Name").
"</td>\n";
215 print
'<td>'.$langs->trans(
"Description").
"</td>\n";
216 print
'<td class="nowrap">'.$langs->trans(
"Example").
"</td>\n";
217 print
'<td align="center" width="60">'.$langs->trans(
"Status").
'</td>';
218 print
'<td align="center" width="16">'.$langs->trans(
"ShortInfo").
'</td>';
222 foreach ($dirmodels as $reldir)
224 $dir =
dol_buildpath($reldir.
"core/modules/supplier_proposal");
228 $handle = opendir($dir);
229 if (is_resource($handle))
231 while (($file = readdir($handle)) !==
false)
233 if (substr($file, 0, 22) ==
'mod_supplier_proposal_' && substr($file,
dol_strlen($file) - 3, 3) ==
'php')
235 $file = substr($file, 0,
dol_strlen($file) - 4);
237 require_once $dir.
'/'.$file.
'.php';
242 if ($module->version ==
'development' && $conf->global->MAIN_FEATURES_LEVEL < 2)
continue;
243 if ($module->version ==
'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1)
continue;
245 if ($module->isEnabled())
247 print
'<tr class="oddeven"><td>'.$module->nom.
"</td><td>\n";
248 print $module->info();
252 print
'<td class="nowrap">';
253 $tmp = $module->getExample();
254 if (preg_match(
'/^Error/', $tmp)) {
255 $langs->load(
"errors");
256 print
'<div class="error">'.$langs->trans($tmp).
'</div>';
257 } elseif ($tmp ==
'NotConfigured') print $langs->trans($tmp);
261 print '<td class="center">';
262 if ($conf->global->SUPPLIER_PROPOSAL_ADDON == "$file")
264 print
img_picto($langs->trans(
"Activated"),
'switch_on');
266 print
'<a class="reposition" href="'.$_SERVER[
"PHP_SELF"].
'?action=setmod&token='.
newToken().
'&value='.urlencode($file).
'">';
267 print
img_picto($langs->trans(
"Disabled"),
'switch_off');
273 $supplier_proposal->initAsSpecimen();
277 $htmltooltip .=
''.$langs->trans(
"Version").
': <b>'.$module->getVersion().
'</b><br>';
278 $nextval = $module->getNextValue($mysoc, $supplier_proposal);
279 if (
"$nextval" != $langs->trans(
"NotAvailable")) {
280 $htmltooltip .=
''.$langs->trans(
"NextValue").
': ';
282 if (preg_match(
'/^Error/', $nextval) || $nextval ==
'NotConfigured')
283 $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);
302 print
"</table><br>\n";
309 print
load_fiche_titre($langs->trans(
"SupplierProposalPDFModules"),
'',
'');
314 $sql .=
" FROM ".MAIN_DB_PREFIX.
"document_model";
315 $sql .=
" WHERE type = '".$db->escape($type).
"'";
316 $sql .=
" AND entity = ".$conf->entity;
317 $resql = $db->query($sql);
321 $num_rows = $db->num_rows(
$resql);
322 while ($i < $num_rows)
324 $array = $db->fetch_array(
$resql);
325 array_push($def, $array[0]);
333 print
"<table class=\"noborder\" width=\"100%\">\n";
334 print
"<tr class=\"liste_titre\">\n";
335 print
" <td>".$langs->trans(
"Name").
"</td>\n";
336 print
" <td>".$langs->trans(
"Description").
"</td>\n";
337 print
'<td align="center" width="40">'.$langs->trans(
"Status").
"</td>\n";
338 print
'<td align="center" width="40">'.$langs->trans(
"Default").
"</td>\n";
339 print
'<td align="center" width="40">'.$langs->trans(
"ShortInfo").
'</td>';
340 print
'<td align="center" width="40">'.$langs->trans(
"Preview").
'</td>';
345 foreach ($dirmodels as $reldir)
347 foreach (array(
'',
'/doc') as $valdir)
349 $realpath = $reldir.
"core/modules/supplier_proposal".$valdir;
354 $handle = opendir($dir);
355 if (is_resource($handle))
357 while (($file = readdir($handle)) !==
false)
364 foreach ($filelist as $file)
366 if (preg_match(
'/\.modules\.php$/i', $file) && preg_match(
'/^(pdf_|doc_)/', $file))
368 if (file_exists($dir.
'/'.$file))
370 $name = substr($file, 4,
dol_strlen($file) - 16);
371 $classname = substr($file, 0,
dol_strlen($file) - 12);
373 require_once $dir.
'/'.$file;
374 $module =
new $classname($db);
376 $modulequalified = 1;
377 if ($module->version ==
'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified = 0;
378 if ($module->version ==
'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified = 0;
380 if ($modulequalified)
382 print
'<tr class="oddeven"><td width="100">';
383 print (empty($module->name) ? $name : $module->name);
385 if (method_exists($module,
'info')) print $module->info($langs);
386 else print $module->description;
390 if (in_array($name, $def))
392 print
'<td class="center">'.
"\n";
393 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=del&token='.
newToken().
'&value='.$name.
'">';
394 print
img_picto($langs->trans(
"Enabled"),
'switch_on');
398 print
"<td align=\"center\">\n";
399 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=set&token='.
newToken().
'&value='.$name.
'&scan_dir='.$module->scandir.
'&label='.urlencode($module->name).
'">'.
img_picto($langs->trans(
"Disabled"),
'switch_off').
'</a>';
404 print
"<td align=\"center\">";
405 if ($conf->global->SUPPLIER_PROPOSAL_ADDON_PDF ==
"$name")
407 print
img_picto($langs->trans(
"Default"),
'on');
409 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=setdoc&token='.
newToken().
'&value='.$name.
'&scan_dir='.$module->scandir.
'&label='.urlencode($module->name).
'" 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 if ($module->type ==
'pdf')
418 $htmltooltip .=
'<br>'.$langs->trans(
"Width").
'/'.$langs->trans(
"Height").
': '.$module->page_largeur.
'/'.$module->page_hauteur;
420 $htmltooltip .=
'<br>'.$langs->trans(
"Path").
': '.preg_replace(
'/^\//',
'', $realpath).
'/'.$file;
422 $htmltooltip .=
'<br><br><u>'.$langs->trans(
"FeaturesSupported").
':</u>';
423 $htmltooltip .=
'<br>'.$langs->trans(
"Logo").
': '.
yn($module->option_logo, 1, 1);
424 $htmltooltip .=
'<br>'.$langs->trans(
"PaymentMode").
': '.
yn($module->option_modereg, 1, 1);
425 $htmltooltip .=
'<br>'.$langs->trans(
"PaymentConditions").
': '.
yn($module->option_condreg, 1, 1);
426 $htmltooltip .=
'<br>'.$langs->trans(
"MultiLanguage").
': '.
yn($module->option_multilang, 1, 1);
429 $htmltooltip .=
'<br>'.$langs->trans(
"WatermarkOnDraftProposal").
': '.
yn($module->option_draft_watermark, 1, 1);
432 print
'<td class="center">';
433 print $form->textwithpicto(
'', $htmltooltip, 1, 0);
437 print
'<td class="center">';
438 if ($module->type ==
'pdf')
440 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=specimen&module='.$name.
'">'.
img_object($langs->trans(
"Preview"),
'pdf').
'</a>';
442 print
img_object($langs->trans(
"PreviewNotAvailable"),
'generic');
466 print
"<table class=\"noborder\" width=\"100%\">";
467 print
"<tr class=\"liste_titre\">";
468 print
"<td>".$langs->trans(
"Parameter").
"</td>\n";
469 print
'<td width="60" align="center">'.$langs->trans(
"Value").
"</td>\n";
470 print
"<td> </td>\n";
474 $substitutionarray[
'__(AnyTranslationKey)__'] = $langs->trans(
"Translation");
475 $htmltext =
'<i>'.$langs->trans(
"AvailableVariables").
':<br>';
476 foreach ($substitutionarray as $key => $val) $htmltext .= $key.
'<br>';
479 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="post">';
480 print
'<input type="hidden" name="token" value="'.newToken().
'">';
481 print
'<input type="hidden" name="action" value="set_SUPPLIER_PROPOSAL_FREE_TEXT">';
482 print
'<tr class="oddeven"><td colspan="2">';
483 print $form->textwithpicto($langs->trans(
"FreeLegalTextOnSupplierProposal"), $langs->trans(
"AddCRIfTooLong").
'<br><br>'.$htmltext, 1,
'help',
'', 0, 2,
'freetexttooltip').
'<br>';
484 $variablename =
'SUPPLIER_PROPOSAL_FREE_TEXT';
485 if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT))
487 print
'<textarea name="'.$variablename.
'" class="flat" cols="120">'.$conf->global->$variablename.
'</textarea>';
489 include_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
490 $doleditor =
new DolEditor($variablename, $conf->global->$variablename,
'', 80,
'dolibarr_notes');
491 print $doleditor->Create();
493 print
'</td><td class="right">';
494 print
'<input type="submit" class="button" value="'.$langs->trans(
"Modify").
'">';
495 print
"</td></tr>\n";
499 print
"<form method=\"post\" action=\"".$_SERVER[
"PHP_SELF"].
"\">";
500 print
'<input type="hidden" name="token" value="'.newToken().
'">';
501 print
"<input type=\"hidden\" name=\"action\" value=\"set_SUPPLIER_PROPOSAL_DRAFT_WATERMARK\">";
502 print
'<tr class="oddeven"><td>';
503 print $form->textwithpicto($langs->trans(
"WatermarkOnDraftProposal"), $htmltext, 1,
'help',
'', 0, 2,
'watermarktooltip').
'<br>';
505 print
'<input size="50" class="flat" type="text" name="SUPPLIER_PROPOSAL_DRAFT_WATERMARK" value="'.$conf->global->SUPPLIER_PROPOSAL_DRAFT_WATERMARK.
'">';
506 print
'</td><td class="right">';
507 print
'<input type="submit" class="button" value="'.$langs->trans(
"Modify").
'">';
508 print
"</td></tr>\n";
511 if ($conf->banque->enabled)
513 print
'<tr class="oddeven"><td>';
514 print $langs->trans(
"BANK_ASK_PAYMENT_BANK_DURING_SUPPLIER_PROPOSAL").
'</td><td> </td><td class="right">';
515 if (!empty($conf->use_javascript_ajax))
519 if (empty($conf->global->BANK_ASK_PAYMENT_BANK_DURING_SUPPLIER_PROPOSAL))
521 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>';
523 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>';
528 print
'<tr class="oddeven"><td>';
529 print $langs->trans(
"BANK_ASK_PAYMENT_BANK_DURING_SUPPLIER_PROPOSAL").
'</td><td> </td><td align="center">'.$langs->trans(
'NotAvailable').
'</td></tr>';
542 print
"<table class=\"noborder\" width=\"100%\">\n";
543 print
"<tr class=\"liste_titre\">\n";
544 print
" <td>".$langs->trans(
"Name").
"</td>\n";
545 print
" <td>".$langs->trans(
"Value").
"</td>\n";
547 print
"<tr class=\"oddeven\">\n <td width=\"140\">".$langs->trans(
"PathDirectory").
"</td>\n <td>".$conf->supplier_proposal->dir_output.
"</td>\n</tr>\n";
548 print
"</table>\n<br>";
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
delDocumentModel($name, $type)
Delete document model used by doc generator.
yn($yesno, $case=1, $color=0)
Return yes or no in current language.
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).
addDocumentModel($name, $type, $label= '', $description= '')
Add document model used by doc generator.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
setEventMessages($mesg, $mesgs, $style= 'mesgs', $messagekey= '')
Set event messages in dol_events session object.
load_fiche_titre($titre, $morehtmlright= '', $picto= 'generic', $pictoisfullpath=0, $id= '', $morecssontable= '', $morehtmlcenter= '')
Load a title with picto.
dol_strlen($string, $stringencoding= 'UTF-8')
Make a strlen call.
dolibarr_del_const($db, $name, $entity=1)
Effacement d'une constante dans la base de donnees.
img_picto($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt= '', $morecss= '', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
ajax_constantonoff($code, $input=array(), $entity=null, $revertonoff=0, $strict=0, $forcereload=0, $marginleftonlyshort=2, $forcenoajax=0)
On/off button for constant.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename= '', $restricttologhandler= '', $logcontext=null)
Write log message into outputs.
if(!GETPOST('transkey', 'alphanohtml')&&!GETPOST('transphrase', 'alphanohtml')) else
View.
img_object($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
accessforbidden($message= '', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program Calling this function terminate execution ...
pdf_getSubstitutionArray($outputlangs, $exclude=null, $object=null, $onlykey=0)
Return array of possible substitutions for PDF content (without external module substitutions).
dol_get_fiche_head($links=array(), $active= '', $title= '', $notab=0, $picto= '', $pictoisfullpath=0, $morehtmlright= '', $morecss= '', $limittoshow=0, $moretabssuffix= '')
Show tabs of a record.
print
Draft customers invoices.
Class to manage price ask supplier.
if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) if(!empty($conf->don->enabled)&&$user->rights->don->lire) if(!empty($conf->tax->enabled)&&$user->rights->tax->charges->lire) if(!empty($conf->facture->enabled)&&!empty($conf->commande->enabled)&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
newToken()
Return the value of token currently saved into session with name 'newtoken'.
print $_SERVER["PHP_SELF"] n
Edit parameters.
Class to manage a WYSIWYG editor.
if(!defined('CSRFCHECK_WITH_TOKEN')) define('CSRFCHECK_WITH_TOKEN'
Draft customers invoices.