29require
'../main.inc.php';
30require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
31require_once DOL_DOCUMENT_ROOT.
'/core/lib/pdf.lib.php';
32require_once DOL_DOCUMENT_ROOT.
'/supplier_proposal/class/supplier_proposal.class.php';
33require_once DOL_DOCUMENT_ROOT.
'/core/lib/supplier_proposal.lib.php';
45$langs->loadLangs(array(
"admin",
"errors",
"other",
"supplier_proposal"));
51$action =
GETPOST(
'action',
'aZ09');
52$value =
GETPOST(
'value',
'alpha');
53$modulepart =
GETPOST(
'modulepart',
'aZ09');
55$label =
GETPOST(
'label',
'alpha');
56$scandir =
GETPOST(
'scan_dir',
'alpha');
57$type =
'supplier_proposal';
66include DOL_DOCUMENT_ROOT.
'/core/actions_setmoduleoptions.inc.php';
68if ($action ==
'updateMask') {
69 $maskconstsupplier_proposal =
GETPOST(
'maskconstsupplier_proposal',
'aZ09');
70 $masksupplier_proposal =
GETPOST(
'masksupplier_proposal',
'alpha');
74 if ($maskconstsupplier_proposal && preg_match(
'/_MASK$/', $maskconstsupplier_proposal)) {
75 $res =
dolibarr_set_const($db, $maskconstsupplier_proposal, $masksupplier_proposal,
'chaine', 0,
'',
$conf->entity);
89if ($action ==
'specimen') {
90 $modele =
GETPOST(
'module',
'alpha');
93 $supplier_proposal->initAsSpecimen();
98 $dirmodels = array_merge(array(
'/'), (array)
$conf->modules_parts[
'models']);
99 foreach ($dirmodels as $reldir) {
100 $file =
dol_buildpath($reldir.
"core/modules/supplier_proposal/doc/pdf_".$modele.
".modules.php");
101 if (file_exists($file)) {
102 $classname =
"pdf_".$modele;
107 if ($classname !==
'') {
110 $module =
new $classname($db);
111 '@phan-var-force ModelePDFSupplierProposal $module';
113 if ($module->write_file($supplier_proposal, $langs) > 0) {
114 header(
"Location: ".DOL_URL_ROOT.
"/document.php?modulepart=supplier_proposal&file=SPECIMEN.pdf");
122 dol_syslog($langs->trans(
"ErrorModuleNotFound"), LOG_ERR);
126if ($action ==
'set_SUPPLIER_PROPOSAL_DRAFT_WATERMARK') {
127 $draft =
GETPOST(
'SUPPLIER_PROPOSAL_DRAFT_WATERMARK',
'alpha');
129 $res =
dolibarr_set_const($db,
"SUPPLIER_PROPOSAL_DRAFT_WATERMARK", trim($draft),
'chaine', 0,
'',
$conf->entity);
141if ($action ==
'set_SUPPLIER_PROPOSAL_FREE_TEXT') {
142 $freetext =
GETPOST(
'SUPPLIER_PROPOSAL_FREE_TEXT',
'restricthtml');
157if ($action ==
'set_BANK_ASK_PAYMENT_BANK_DURING_SUPPLIER_PROPOSAL') {
158 $res =
dolibarr_set_const($db,
"BANK_ASK_PAYMENT_BANK_DURING_SUPPLIER_PROPOSAL", $value,
'chaine', 0,
'',
$conf->entity);
172if ($action ==
'set') {
174} elseif ($action ==
'del') {
177 if (
$conf->global->SUPPLIER_PROPOSAL_ADDON_PDF ==
"$value") {
181} elseif ($action ==
'setdoc') {
183 $conf->global->SUPPLIER_PROPOSAL_ADDON_PDF = $value;
191} elseif ($action ==
'setmod') {
196} elseif (preg_match(
'/set_(.*)/', $action, $reg)) {
198 if ($code ==
"SUPPLIER_PROPOSAL_FREE_TEXT") {
199 $value = (
GETPOST($code,
'restricthtml') ?
GETPOST($code,
'restricthtml') : 1);
212 header(
"Location: " . $_SERVER[
"PHP_SELF"]);
215} elseif (preg_match(
'/del_(.*)/', $action, $reg)) {
227 header(
"Location: " . $_SERVER[
"PHP_SELF"]);
237$dirmodels = array_merge(array(
'/'), (array)
$conf->modules_parts[
'models']);
240llxHeader(
'', $langs->trans(
"SupplierProposalSetup"),
'',
'', 0, 0,
'',
'',
'',
'mod-admin page-supplier_proposal');
242$form =
new Form($db);
246$linkback =
'<a href="'.DOL_URL_ROOT.
'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToModuleList").
'</a>';
247print
load_fiche_titre($langs->trans(
"SupplierProposalSetup"), $linkback,
'title_setup');
251print
dol_get_fiche_head($head,
'general', $langs->trans(
"CommRequests"), -1,
'supplier_proposal');
256print
load_fiche_titre($langs->trans(
"SupplierProposalNumberingModules"),
'',
'');
258print
'<table class="noborder centpercent">';
259print
'<tr class="liste_titre">';
260print
'<td>'.$langs->trans(
"Name").
"</td>\n";
261print
'<td>'.$langs->trans(
"Description").
"</td>\n";
262print
'<td class="nowrap">'.$langs->trans(
"Example").
"</td>\n";
263print
'<td align="center" width="60">'.$langs->trans(
"Status").
'</td>';
264print
'<td align="center" width="16">'.$langs->trans(
"ShortInfo").
'</td>';
268foreach ($dirmodels as $reldir) {
269 $dir =
dol_buildpath($reldir.
"core/modules/supplier_proposal");
272 $handle = opendir($dir);
273 if (is_resource($handle)) {
274 while (($file = readdir($handle)) !==
false) {
275 if (substr($file, 0, 22) ==
'mod_supplier_proposal_' && substr($file,
dol_strlen($file) - 3, 3) ==
'php') {
276 $file = substr($file, 0,
dol_strlen($file) - 4);
278 require_once $dir.
'/'.$file.
'.php';
280 $module =
new $file();
281 '@phan-var-force ModeleNumRefSupplierProposal $module';
284 if ($module->version ==
'development' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 2) {
287 if ($module->version ==
'experimental' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 1) {
291 if ($module->isEnabled()) {
292 print
'<tr class="oddeven"><td>'.$module->getName($langs).
"</td><td>\n";
293 print $module->info($langs);
297 print
'<td class="nowrap">';
298 $tmp = $module->getExample();
299 if (preg_match(
'/^Error/', $tmp)) {
300 $langs->load(
"errors");
301 print
'<div class="error">'.$langs->trans($tmp).
'</div>';
302 } elseif ($tmp ==
'NotConfigured') {
303 print
'<span class="opacitymedium">'.$langs->trans($tmp).
'</span>';
309 print
'<td class="center">';
310 if (
$conf->global->SUPPLIER_PROPOSAL_ADDON ==
"$file") {
311 print
img_picto($langs->trans(
"Activated"),
'switch_on');
313 print
'<a class="reposition" href="'.$_SERVER[
"PHP_SELF"].
'?action=setmod&token='.
newToken().
'&value='.urlencode($file).
'">';
314 print
img_picto($langs->trans(
"Disabled"),
'switch_off');
320 $supplier_proposal->initAsSpecimen();
324 $htmltooltip .=
''.$langs->trans(
"Version").
': <b>'.$module->getVersion().
'</b><br>';
325 $nextval = $module->getNextValue($mysoc, $supplier_proposal);
326 if (
"$nextval" != $langs->trans(
"NotAvailable")) {
327 $htmltooltip .=
''.$langs->trans(
"NextValue").
': ';
329 if (preg_match(
'/^Error/', $nextval) || $nextval ==
'NotConfigured') {
330 $nextval = $langs->trans($nextval);
332 $htmltooltip .= $nextval.
'<br>';
334 $htmltooltip .= $langs->trans($module->error).
'<br>';
338 print
'<td class="center">';
339 print $form->textwithpicto(
'', $htmltooltip, 1, 0);
350print
"</table><br>\n";
362$sql .=
" FROM ".MAIN_DB_PREFIX.
"document_model";
363$sql .=
" WHERE type = '".$db->escape($type).
"'";
364$sql .=
" AND entity = ".$conf->entity;
365$resql = $db->query($sql);
368 $num_rows = $db->num_rows($resql);
369 while ($i < $num_rows) {
370 $array = $db->fetch_array($resql);
371 if (is_array($array)) {
372 array_push($def, $array[0]);
381print
"<table class=\"noborder\" width=\"100%\">\n";
382print
"<tr class=\"liste_titre\">\n";
383print
" <td>".$langs->trans(
"Name").
"</td>\n";
384print
" <td>".$langs->trans(
"Description").
"</td>\n";
385print
'<td align="center" width="40">'.$langs->trans(
"Status").
"</td>\n";
386print
'<td align="center" width="40">'.$langs->trans(
"Default").
"</td>\n";
387print
'<td align="center" width="40">'.$langs->trans(
"ShortInfo").
'</td>';
388print
'<td align="center" width="40">'.$langs->trans(
"Preview").
'</td>';
393foreach ($dirmodels as $reldir) {
394 foreach (array(
'',
'/doc') as $valdir) {
395 $realpath = $reldir.
"core/modules/supplier_proposal".$valdir;
399 $handle = opendir($dir);
400 if (is_resource($handle)) {
402 while (($file = readdir($handle)) !==
false) {
408 foreach ($filelist as $file) {
409 if (preg_match(
'/\.modules\.php$/i', $file) && preg_match(
'/^(pdf_|doc_)/', $file)) {
410 if (file_exists($dir.
'/'.$file)) {
411 $name = substr($file, 4,
dol_strlen($file) - 16);
412 $classname = substr($file, 0,
dol_strlen($file) - 12);
414 require_once $dir.
'/'.$file;
415 $module =
new $classname($db);
416 '@phan-var-force CommonDocGenerator $module';
418 $modulequalified = 1;
419 if ($module->version ==
'development' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 2) {
420 $modulequalified = 0;
422 if ($module->version ==
'experimental' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 1) {
423 $modulequalified = 0;
426 if ($modulequalified) {
427 print
'<tr class="oddeven"><td width="100">';
428 print(empty($module->name) ? $name : $module->
name);
430 if (method_exists($module,
'info')) {
431 print $module->info($langs);
433 print $module->description;
438 if (in_array($name, $def)) {
439 print
'<td class="center">'.
"\n";
440 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=del&token='.
newToken().
'&value='.urlencode($name).
'">';
441 print
img_picto($langs->trans(
"Enabled"),
'switch_on');
445 print
'<td align="center">'.
"\n";
446 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>';
451 print
'<td align="center">';
452 if (
$conf->global->SUPPLIER_PROPOSAL_ADDON_PDF ==
"$name") {
453 print
img_picto($langs->trans(
"Default"),
'on');
455 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>';
460 $htmltooltip =
''.$langs->trans(
"Name").
': '.$module->name;
461 $htmltooltip .=
'<br>'.$langs->trans(
"Type").
': '.($module->type ? $module->type : $langs->trans(
"Unknown"));
462 if ($module->type ==
'pdf') {
463 $htmltooltip .=
'<br>'.$langs->trans(
"Width").
'/'.$langs->trans(
"Height").
': '.$module->page_largeur.
'/'.$module->page_hauteur;
465 $htmltooltip .=
'<br>'.$langs->trans(
"Path").
': '.preg_replace(
'/^\//',
'', $realpath).
'/'.$file;
467 $htmltooltip .=
'<br><br><u>'.$langs->trans(
"FeaturesSupported").
':</u>';
468 $htmltooltip .=
'<br>'.$langs->trans(
"Logo").
': '.
yn($module->option_logo, 1, 1);
469 $htmltooltip .=
'<br>'.$langs->trans(
"PaymentMode").
': '.
yn($module->option_modereg, 1, 1);
470 $htmltooltip .=
'<br>'.$langs->trans(
"PaymentConditions").
': '.
yn($module->option_condreg, 1, 1);
471 $htmltooltip .=
'<br>'.$langs->trans(
"MultiLanguage").
': '.
yn($module->option_multilang, 1, 1);
474 $htmltooltip .=
'<br>'.$langs->trans(
"WatermarkOnDraftProposal").
': '.
yn($module->option_draft_watermark, 1, 1);
477 print
'<td class="center">';
478 print $form->textwithpicto(
'', $htmltooltip, 1, 0);
482 print
'<td class="center">';
483 if ($module->type ==
'pdf') {
484 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=specimen&module='.$name.
'">'.
img_object($langs->trans(
"Preview"),
'pdf').
'</a>';
486 print
img_object($langs->trans(
"PreviewNotAvailable"),
'generic');
510print
"<table class=\"noborder\" width=\"100%\">";
511print
"<tr class=\"liste_titre\">";
512print
"<td>".$langs->trans(
"Parameter").
"</td>\n";
513print
'<td width="60" align="center">'.$langs->trans(
"Value").
"</td>\n";
514print
"<td> </td>\n";
518$substitutionarray[
'__(AnyTranslationKey)__'] = $langs->trans(
"Translation");
519$htmltext =
'<i>'.$langs->trans(
"AvailableVariables").
':<br>';
520foreach ($substitutionarray as $key => $val) {
521 $htmltext .= $key.
'<br>';
525print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="post">';
526print
'<input type="hidden" name="token" value="'.newToken().
'">';
527print
'<input type="hidden" name="action" value="set_SUPPLIER_PROPOSAL_FREE_TEXT">';
528print
'<tr class="oddeven"><td colspan="2">';
529print $form->textwithpicto($langs->trans(
"FreeLegalTextOnSupplierProposal"), $langs->trans(
"AddCRIfTooLong").
'<br><br>'.$htmltext, 1,
'help',
'', 0, 2,
'freetexttooltip').
'<br>';
530$variablename =
'SUPPLIER_PROPOSAL_FREE_TEXT';
532 print
'<textarea name="'.$variablename.
'" class="flat" cols="120">'.
getDolGlobalString($variablename).
'</textarea>';
534 include_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
536 print $doleditor->Create();
538print
'</td><td class="right">';
539print
'<input type="submit" class="button button-edit" value="'.$langs->trans(
"Modify").
'">';
544print
"<form method=\"post\" action=\"".$_SERVER[
"PHP_SELF"].
"\">";
545print
'<input type="hidden" name="token" value="'.newToken().
'">';
546print
"<input type=\"hidden\" name=\"action\" value=\"set_SUPPLIER_PROPOSAL_DRAFT_WATERMARK\">";
547print
'<tr class="oddeven"><td>';
548print $form->textwithpicto($langs->trans(
"WatermarkOnDraftProposal"), $htmltext, 1,
'help',
'', 0, 2,
'watermarktooltip').
'<br>';
550print
'<input class="flat minwidth200" type="text" name="SUPPLIER_PROPOSAL_DRAFT_WATERMARK" value="'.dol_escape_htmltag(
getDolGlobalString(
'SUPPLIER_PROPOSAL_DRAFT_WATERMARK')).
'">';
551print
'</td><td class="right">';
552print
'<input type="submit" class="button button-edit" value="'.$langs->trans(
"Modify").
'">';
556if (isModEnabled(
'bank')) {
557 print
'<tr class="oddeven"><td>';
558 print $langs->trans(
"BANK_ASK_PAYMENT_BANK_DURING_SUPPLIER_PROPOSAL").
'</td><td> </td><td class="right">';
559 print ajax_constantonoff(
'BANK_ASK_PAYMENT_BANK_DURING_SUPPLIER_PROPOSAL');
562 print
'<tr class="oddeven"><td>';
563 print $langs->trans(
"BANK_ASK_PAYMENT_BANK_DURING_SUPPLIER_PROPOSAL").
'</td><td> </td><td align="center">'.$langs->trans(
'NotAvailable').
'</td></tr>';
567print
'<tr class="oddeven">';
568print
'<td>'.$langs->trans(
"AllowExternalDownload").
'</td><td> </td>';
569print
'<td class="right">';
570print ajax_constantonoff(
'PROPOSAL_ALLOW_EXTERNAL_DOWNLOAD', array(),
null, 0, 0, 0, 2, 0, 1);
583print
"<table class=\"noborder\" width=\"100%\">\n";
584print
"<tr class=\"liste_titre\">\n";
585print
" <td>".$langs->trans(
"Name").
"</td>\n";
586print
" <td>".$langs->trans(
"Value").
"</td>\n";
588print
"<tr class=\"oddeven\">\n <td width=\"140\">".$langs->trans(
"PathDirectory").
"</td>\n <td>".
$conf->supplier_proposal->dir_output.
"</td>\n</tr>\n";
589print
"</table>\n<br>";
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.
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Class to manage a WYSIWYG editor.
Class to manage price ask supplier.
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)
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
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'.
yn($yesno, $format=1, $color=0)
Return yes or no in current language.
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.
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 a Dolibarr global constant string value.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
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.
supplier_proposal_admin_prepare_head()
Return array head with list of tabs to view object information.