1<?php
2/* Copyright (C) 2003-2004 Rodolphe Quiedeville        <rodolphe@quiedeville.org>
3 * Copyright (C) 2004-2011 Laurent Destailleur         <eldy@users.sourceforge.net>
4 * Copyright (C) 2004      Sebastien Di Cintio         <sdicintio@ressource-toi.org>
5 * Copyright (C) 2004      Benoit Mortier              <benoit.mortier@opensides.be>
6 * Copyright (C) 2004      Eric Seigne                 <eric.seigne@ryxeo.com>
7 * Copyright (C) 2005-2012 Regis Houssin               <regis.houssin@inodbox.com>
8 * Copyright (C) 2008      Raphael Bertrand (Resultic) <raphael.bertrand@resultic.fr>
9 * Copyright (C) 2011-2013 Juanjo Menent			   <jmenent@2byte.es>
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 3 of the License, or
14 * (at your option) any later version.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program. If not, see <https://www.gnu.org/licenses/>.
23 */
24
25/**
26 *	    \file       htdocs/admin/propal.php
27 *		\ingroup    propale
28 *		\brief      Setup page for commercial proposal module
29 */
30
31require '../main.inc.php';
32require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
33require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php';
34require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php';
35require_once DOL_DOCUMENT_ROOT.'/core/lib/propal.lib.php';
36
37// Load translation files required by the page
38$langs->loadLangs(array("admin", "other", "errors", "propal"));
39
40if (!$user->admin) accessforbidden();
41
42$action = GETPOST('action', 'aZ09');
43$value = GETPOST('value', 'alpha');
44$label = GETPOST('label', 'alpha');
45$scandir = GETPOST('scan_dir', 'alpha');
46$type = 'propal';
47
48/*
49 * Actions
50 */
51
52include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
53
54$error = 0;
55if ($action == 'updateMask') {
56	$maskconstpropal = GETPOST('maskconstpropal', 'alpha');
57	$maskpropal = GETPOST('maskpropal', 'alpha');
58	if ($maskconstpropal) $res = dolibarr_set_const($db, $maskconstpropal, $maskpropal, 'chaine', 0, '', $conf->entity);
59
60	if (!($res > 0)) $error++;
61
62 	if (!$error)
63	{
64		setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
65	} else {
66		setEventMessages($langs->trans("Error"), null, 'errors');
67	}
68} elseif ($action == 'specimen') {
69	$modele = GETPOST('module', 'alpha');
70
71	$propal = new Propal($db);
72	$propal->initAsSpecimen();
73
74	// Search template files
75	$file = ''; $classname = ''; $filefound = 0;
76	$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
77	foreach ($dirmodels as $reldir)
78	{
79		$file = dol_buildpath($reldir."core/modules/propale/doc/pdf_".$modele.".modules.php");
80		if (file_exists($file))
81		{
82			$filefound = 1;
83			$classname = "pdf_".$modele;
84			break;
85		}
86	}
87
88	if ($filefound) {
89		require_once $file;
90
91		$module = new $classname($db);
92
93		if ($module->write_file($propal, $langs) > 0)
94		{
95			header("Location: ".DOL_URL_ROOT."/document.php?modulepart=propal&file=SPECIMEN.pdf");
96			return;
97		} else {
98			setEventMessages($module->error, $module->errors, 'errors');
99			dol_syslog($module->error, LOG_ERR);
100		}
101	} else {
102		setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors');
103		dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR);
104	}
105} elseif ($action == 'setribchq') {
106	$rib = GETPOST('rib', 'alpha');
107	$chq = GETPOST('chq', 'alpha');
108
109	$res = dolibarr_set_const($db, "FACTURE_RIB_NUMBER", $rib, 'chaine', 0, '', $conf->entity);
110	$res = dolibarr_set_const($db, "FACTURE_CHQ_NUMBER", $chq, 'chaine', 0, '', $conf->entity);
111
112	if (!($res > 0)) $error++;
113
114	if (!$error)
115	{
116		setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
117	} else {
118		setEventMessages($langs->trans("Error"), null, 'errors');
119	}
120} elseif ($action == 'set_PROPALE_DRAFT_WATERMARK') {
121	$draft = GETPOST('PROPALE_DRAFT_WATERMARK', 'alpha');
122
123	$res = dolibarr_set_const($db, "PROPALE_DRAFT_WATERMARK", trim($draft), 'chaine', 0, '', $conf->entity);
124	if (!($res > 0)) $error++;
125
126 	if (!$error)
127	{
128		setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
129	} else {
130		setEventMessages($langs->trans("Error"), null, 'errors');
131	}
132} elseif ($action == 'set_PROPOSAL_FREE_TEXT') {
133	$freetext = GETPOST('PROPOSAL_FREE_TEXT', 'restricthtml'); // No alpha here, we want exact string
134
135	$res = dolibarr_set_const($db, "PROPOSAL_FREE_TEXT", $freetext, 'chaine', 0, '', $conf->entity);
136
137	if (!($res > 0)) $error++;
138
139 	if (!$error)
140	{
141		setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
142	} else {
143		setEventMessages($langs->trans("Error"), null, 'errors');
144	}
145} elseif ($action == 'setdefaultduration') {
146	$res = dolibarr_set_const($db, "PROPALE_VALIDITY_DURATION", $value, 'chaine', 0, '', $conf->entity);
147
148	if (!($res > 0)) $error++;
149
150 	if (!$error)
151	{
152		setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
153	} else {
154		setEventMessages($langs->trans("Error"), null, 'errors');
155	}
156} elseif ($action == 'set_BANK_ASK_PAYMENT_BANK_DURING_PROPOSAL') {
157	$res = dolibarr_set_const($db, "BANK_ASK_PAYMENT_BANK_DURING_PROPOSAL", $value, 'chaine', 0, '', $conf->entity);
158
159	if (!($res > 0)) $error++;
160
161	if (!$error) {
162		setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
163	} else {
164		setEventMessages($langs->trans("Error"), null, 'errors');
165	}
166} elseif ($action == 'set') {
167	// Activate a model
168	$ret = addDocumentModel($value, $type, $label, $scandir);
169} elseif ($action == 'del') {
170	$ret = delDocumentModel($value, $type);
171	if ($ret > 0) {
172		if ($conf->global->PROPALE_ADDON_PDF == "$value") dolibarr_del_const($db, 'PROPALE_ADDON_PDF', $conf->entity);
173	}
174} elseif ($action == 'setdoc') {
175	if (dolibarr_set_const($db, "PROPALE_ADDON_PDF", $value, 'chaine', 0, '', $conf->entity)) {
176		$conf->global->PROPALE_ADDON_PDF = $value;
177	}
178
179	// On active le modele
180	$ret = delDocumentModel($value, $type);
181	if ($ret > 0) {
182		$ret = addDocumentModel($value, $type, $label, $scandir);
183	}
184} elseif ($action == 'setmod') {
185	// TODO Verifier si module numerotation choisi peut etre active
186	// par appel methode canBeActivated
187
188	dolibarr_set_const($db, "PROPALE_ADDON", $value, 'chaine', 0, '', $conf->entity);
189}
190
191
192/*
193 * View
194 */
195
196$form = new Form($db);
197
198$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
199
200llxHeader('', $langs->trans("PropalSetup"));
201
202//if ($mesg) print $mesg;
203
204$linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
205print load_fiche_titre($langs->trans("PropalSetup"), $linkback, 'title_setup');
206
207$head = propal_admin_prepare_head();
208
209print dol_get_fiche_head($head, 'general', $langs->trans("Proposals"), -1, 'propal');
210
211/*
212 *  Module numerotation
213 */
214print load_fiche_titre($langs->trans("ProposalsNumberingModules"), '', '');
215
216print '<table class="noborder centpercent">';
217print '<tr class="liste_titre">';
218print '<td>'.$langs->trans("Name")."</td>\n";
219print '<td>'.$langs->trans("Description")."</td>\n";
220print '<td class="nowrap">'.$langs->trans("Example")."</td>\n";
221print '<td align="center" width="60">'.$langs->trans("Status").'</td>';
222print '<td align="center" width="16">'.$langs->trans("ShortInfo").'</td>';
223print '</tr>'."\n";
224
225clearstatcache();
226
227foreach ($dirmodels as $reldir)
228{
229	$dir = dol_buildpath($reldir."core/modules/propale");
230
231	if (is_dir($dir))
232	{
233		$handle = opendir($dir);
234		if (is_resource($handle))
235		{
236			while (($file = readdir($handle)) !== false)
237			{
238				if (substr($file, 0, 12) == 'mod_propale_' && substr($file, dol_strlen($file) - 3, 3) == 'php')
239				{
240					$file = substr($file, 0, dol_strlen($file) - 4);
241
242					require_once $dir.'/'.$file.'.php';
243
244					$module = new $file;
245
246					// Show modules according to features level
247					if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue;
248					if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue;
249
250					if ($module->isEnabled())
251					{
252						print '<tr class="oddeven"><td>'.$module->nom."</td><td>\n";
253						print $module->info();
254						print '</td>';
255
256						// Show example of numbering module
257						print '<td class="nowrap">';
258						$tmp = $module->getExample();
259						if (preg_match('/^Error/', $tmp)) {
260							$langs->load("errors");
261							print '<div class="error">'.$langs->trans($tmp).'</div>';
262						} elseif ($tmp == 'NotConfigured') print $langs->trans($tmp);
263						else print $tmp;
264						print '</td>'."\n";
265
266						print '<td class="center">';
267						if ($conf->global->PROPALE_ADDON == "$file")
268						{
269							print img_picto($langs->trans("Activated"), 'switch_on');
270						} else {
271							print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setmod&amp;token='.newToken().'&amp;value='.urlencode($file).'">';
272							print img_picto($langs->trans("Disabled"), 'switch_off');
273							print '</a>';
274						}
275						print '</td>';
276
277						$propal = new Propal($db);
278						$propal->initAsSpecimen();
279
280						// Info
281						$htmltooltip = '';
282						$htmltooltip .= ''.$langs->trans("Version").': <b>'.$module->getVersion().'</b><br>';
283						$propal->type = 0;
284						$nextval = $module->getNextValue($mysoc, $propal);
285						if ("$nextval" != $langs->trans("NotAvailable")) {  // Keep " on nextval
286							$htmltooltip .= ''.$langs->trans("NextValue").': ';
287							if ($nextval) {
288								if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured')
289									$nextval = $langs->trans($nextval);
290								$htmltooltip .= $nextval.'<br>';
291							} else {
292								$htmltooltip .= $langs->trans($module->error).'<br>';
293							}
294						}
295
296						print '<td class="center">';
297						print $form->textwithpicto('', $htmltooltip, 1, 0);
298						print '</td>';
299
300						print "</tr>\n";
301					}
302				}
303			}
304			closedir($handle);
305		}
306	}
307}
308print "</table><br>\n";
309
310
311/*
312 * Document templates generators
313 */
314
315print load_fiche_titre($langs->trans("ProposalsPDFModules"), '', '');
316
317// Load array def with activated templates
318$def = array();
319$sql = "SELECT nom";
320$sql .= " FROM ".MAIN_DB_PREFIX."document_model";
321$sql .= " WHERE type = '".$db->escape($type)."'";
322$sql .= " AND entity = ".$conf->entity;
323$resql = $db->query($sql);
324if ($resql)
325{
326	$i = 0;
327	$num_rows = $db->num_rows($resql);
328	while ($i < $num_rows)
329	{
330		$array = $db->fetch_array($resql);
331		array_push($def, $array[0]);
332		$i++;
333	}
334} else {
335	dol_print_error($db);
336}
337
338
339print "<table class=\"noborder\" width=\"100%\">\n";
340print "<tr class=\"liste_titre\">\n";
341print "  <td>".$langs->trans("Name")."</td>\n";
342print "  <td>".$langs->trans("Description")."</td>\n";
343print '<td align="center" width="40">'.$langs->trans("Status")."</td>\n";
344print '<td align="center" width="40">'.$langs->trans("Default")."</td>\n";
345print '<td align="center" width="40">'.$langs->trans("ShortInfo").'</td>';
346print '<td align="center" width="40">'.$langs->trans("Preview").'</td>';
347print "</tr>\n";
348
349clearstatcache();
350
351foreach ($dirmodels as $reldir)
352{
353	foreach (array('', '/doc') as $valdir)
354	{
355		$realpath = $reldir."core/modules/propale".$valdir;
356		$dir = dol_buildpath($realpath);
357
358		if (is_dir($dir))
359		{
360			$handle = opendir($dir);
361			if (is_resource($handle))
362			{
363				while (($file = readdir($handle)) !== false)
364				{
365					$filelist[] = $file;
366				}
367				closedir($handle);
368				arsort($filelist);
369
370				foreach ($filelist as $file)
371				{
372					if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file))
373					{
374						if (file_exists($dir.'/'.$file))
375						{
376							$name = substr($file, 4, dol_strlen($file) - 16);
377							$classname = substr($file, 0, dol_strlen($file) - 12);
378
379							require_once $dir.'/'.$file;
380							$module = new $classname($db);
381
382							$modulequalified = 1;
383							if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified = 0;
384							if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified = 0;
385
386							if ($modulequalified)
387							{
388								$var = !$var;
389								print '<tr class="oddeven"><td width="100">';
390								print (empty($module->name) ? $name : $module->name);
391								print "</td><td>\n";
392								if (method_exists($module, 'info')) print $module->info($langs);
393								else print $module->description;
394								print '</td>';
395
396								// Active
397								if (in_array($name, $def))
398								{
399									print '<td class="center">'."\n";
400									print '<a href="'.$_SERVER["PHP_SELF"].'?action=del&amp;token='.newToken().'&amp;value='.$name.'">';
401									print img_picto($langs->trans("Enabled"), 'switch_on');
402									print '</a>';
403									print '</td>';
404								} else {
405									print "<td align=\"center\">\n";
406									print '<a href="'.$_SERVER["PHP_SELF"].'?action=set&amp;token='.newToken().'&amp;value='.$name.'&amp;scan_dir='.$module->scandir.'&amp;label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"), 'switch_off').'</a>';
407									print "</td>";
408								}
409
410								// Defaut
411								print "<td align=\"center\">";
412								if ($conf->global->PROPALE_ADDON_PDF == "$name")
413								{
414									print img_picto($langs->trans("Default"), 'on');
415								} else {
416									print '<a href="'.$_SERVER["PHP_SELF"].'?action=setdoc&amp;token='.newToken().'&amp;value='.$name.'&amp;scan_dir='.$module->scandir.'&amp;label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').'</a>';
417								}
418								print '</td>';
419
420								// Info
421								$htmltooltip = $langs->trans("Name").': '.$module->name;
422								$htmltooltip .= '<br>'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown"));
423								if ($module->type == 'pdf')
424								{
425									$htmltooltip .= '<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur;
426								}
427								$htmltooltip .= '<br>'.$langs->trans("Path").': '.preg_replace('/^\//', '', $realpath).'/'.$file;
428
429								$htmltooltip .= '<br><br><u>'.$langs->trans("FeaturesSupported").':</u>';
430								$htmltooltip .= '<br>'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1);
431								$htmltooltip .= '<br>'.$langs->trans("PaymentMode").': '.yn($module->option_modereg, 1, 1);
432								$htmltooltip .= '<br>'.$langs->trans("PaymentConditions").': '.yn($module->option_condreg, 1, 1);
433								$htmltooltip .= '<br>'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1);
434								//$htmltooltip.='<br>'.$langs->trans("Discounts").': '.yn($module->option_escompte,1,1);
435								//$htmltooltip.='<br>'.$langs->trans("CreditNote").': '.yn($module->option_credit_note,1,1);
436								$htmltooltip .= '<br>'.$langs->trans("WatermarkOnDraftProposal").': '.yn($module->option_draft_watermark, 1, 1);
437
438
439								print '<td class="center">';
440								print $form->textwithpicto('', $htmltooltip, 1, 0);
441								print '</td>';
442
443								// Preview
444								print '<td class="center">';
445								if ($module->type == 'pdf')
446								{
447									print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.$name.'">'.img_object($langs->trans("Preview"), 'pdf').'</a>';
448								} else {
449									print img_object($langs->trans("PreviewNotAvailable"), 'generic');
450								}
451								print '</td>';
452
453								print "</tr>\n";
454							}
455						}
456					}
457				}
458			}
459		}
460	}
461}
462
463print '</table>';
464
465
466/*
467 *  Payment mode
468 */
469
470print '<br>';
471print load_fiche_titre($langs->trans("SuggestedPaymentModesIfNotDefinedInProposal"), '', '');
472
473print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
474print '<input type="hidden" name="token" value="'.newToken().'" />';
475
476print '<table class="noborder centpercent">';
477
478print '<tr class="liste_titre">';
479print '<td>';
480print '<input type="hidden" name="action" value="setribchq">';
481print $langs->trans("PaymentMode").'</td>';
482print '<td align="right">';
483if (empty($conf->facture->enabled)) {
484	print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';
485}
486print '</td>';
487print "</tr>\n";
488
489print '<tr class="oddeven">';
490print "<td>".$langs->trans("SuggestPaymentByRIBOnAccount")."</td>";
491print "<td>";
492if (empty($conf->facture->enabled))
493{
494	if (!empty($conf->banque->enabled))
495	{
496		$sql = "SELECT rowid, label";
497		$sql .= " FROM ".MAIN_DB_PREFIX."bank_account";
498		$sql .= " WHERE clos = 0";
499		$sql .= " AND courant = 1";
500		$sql .= " AND entity IN (".getEntity('bank_account').")";
501		$resql = $db->query($sql);
502		if ($resql)
503		{
504			$num = $db->num_rows($resql);
505			$i = 0;
506			if ($num > 0)
507			{
508				print '<select name="rib" class="flat" id="rib">';
509				print '<option value="0">'.$langs->trans("DoNotSuggestPaymentMode").'</option>';
510				while ($i < $num)
511				{
512					$row = $db->fetch_row($resql);
513
514					print '<option value="'.$row[0].'"';
515					print $conf->global->FACTURE_RIB_NUMBER == $row[0] ? ' selected' : '';
516					print '>'.$row[1].'</option>';
517
518					$i++;
519				}
520				print "</select>";
521			} else {
522				print "<i>".$langs->trans("NoActiveBankAccountDefined")."</i>";
523			}
524		}
525	} else {
526		print '<span class="opacitymedium">'.$langs->trans("BankModuleNotActive").'</span>';
527	}
528} else {
529	print '<span class="opacitymedium">'.$langs->trans("SeeSetupOfModule", $langs->transnoentitiesnoconv("Module30Name")).'</span>';
530}
531print "</td></tr>";
532
533print '<tr class="oddeven">';
534print "<td>".$langs->trans("SuggestPaymentByChequeToAddress")."</td>";
535print "<td>";
536if (empty($conf->facture->enabled))
537{
538	print '<select class="flat" name="chq" id="chq">';
539	print '<option value="0">'.$langs->trans("DoNotSuggestPaymentMode").'</option>';
540	print '<option value="-1"'.($conf->global->FACTURE_CHQ_NUMBER ? ' selected' : '').'>'.$langs->trans("MenuCompanySetup").' ('.($mysoc->name ? $mysoc->name : $langs->trans("NotDefined")).')</option>';
541
542	$sql = "SELECT rowid, label";
543	$sql .= " FROM ".MAIN_DB_PREFIX."bank_account";
544	$sql .= " WHERE clos = 0";
545	$sql .= " AND courant = 1";
546	$sql .= " AND entity IN (".getEntity('bank_account').")";
547
548	$resql = $db->query($sql);
549	if ($resql)
550	{
551		$num = $db->num_rows($resql);
552		$i = 0;
553		while ($i < $num)
554		{
555			$row = $db->fetch_row($resql);
556
557			print '<option value="'.$row[0].'"';
558			print $conf->global->FACTURE_CHQ_NUMBER == $row[0] ? ' selected' : '';
559			print '>'.$langs->trans("OwnerOfBankAccount", $row[1]).'</option>';
560
561			$i++;
562		}
563	}
564	print "</select>";
565} else {
566	print '<span class="opacitymedium">'.$langs->trans("SeeSetupOfModule", $langs->transnoentitiesnoconv("Module30Name")).'</span>';
567}
568print "</td></tr>";
569print "</table>";
570print "</form>";
571
572
573print '<br>';
574
575
576/*
577 * Other options
578 */
579
580print load_fiche_titre($langs->trans("OtherOptions"), '', '');
581
582print "<table class=\"noborder\" width=\"100%\">";
583print "<tr class=\"liste_titre\">";
584print "<td>".$langs->trans("Parameter")."</td>\n";
585print '<td width="60" align="center">'.$langs->trans("Value")."</td>\n";
586print "<td>&nbsp;</td>\n";
587print "</tr>";
588
589
590print "<form method=\"post\" action=\"".$_SERVER["PHP_SELF"]."\">";
591print '<input type="hidden" name="token" value="'.newToken().'">';
592print "<input type=\"hidden\" name=\"action\" value=\"setdefaultduration\">";
593print '<tr class="oddeven">';
594print '<td>'.$langs->trans("DefaultProposalDurationValidity").'</td>';
595print '<td width="60" align="center">'."<input size=\"3\" class=\"flat\" type=\"text\" name=\"value\" value=\"".$conf->global->PROPALE_VALIDITY_DURATION."\"></td>";
596print '<td class="right"><input type="submit" class="button" value="'.$langs->trans("Modify").'"></td>';
597print '</tr>';
598print '</form>';
599
600/*
601print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
602print '<input type="hidden" name="token" value="'.newToken().'">';
603print '<input type="hidden" name="action" value="setusecustomercontactasrecipient">';
604print '<tr class="oddeven"><td>';
605print $langs->trans("UseCustomerContactAsPropalRecipientIfExist");
606print '</td><td width="60" align="center">';
607print $form->selectyesno("value",$conf->global->PROPALE_USE_CUSTOMER_CONTACT_AS_RECIPIENT,1);
608print '</td><td class="right">';
609print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';
610print "</td></tr>\n";
611print '</form>';
612*/
613
614$substitutionarray = pdf_getSubstitutionArray($langs, null, null, 2);
615$substitutionarray['__(AnyTranslationKey)__'] = $langs->trans("Translation");
616$htmltext = '<i>'.$langs->trans("AvailableVariables").':<br>';
617foreach ($substitutionarray as $key => $val)	$htmltext .= $key.'<br>';
618$htmltext .= '</i>';
619
620print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
621print '<input type="hidden" name="token" value="'.newToken().'">';
622print '<input type="hidden" name="action" value="set_PROPOSAL_FREE_TEXT">';
623print '<tr class="oddeven"><td colspan="2">';
624print $form->textwithpicto($langs->trans("FreeLegalTextOnProposal"), $langs->trans("AddCRIfTooLong").'<br><br>'.$htmltext, 1, 'help', '', 0, 2, 'freetexttooltip').'<br>';
625$variablename = 'PROPOSAL_FREE_TEXT';
626if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT))
627{
628	print '<textarea name="'.$variablename.'" class="flat" cols="120">'.$conf->global->$variablename.'</textarea>';
629} else {
630	include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
631	$doleditor = new DolEditor($variablename, $conf->global->$variablename, '', 80, 'dolibarr_notes');
632	print $doleditor->Create();
633}
634print '</td><td class="right">';
635print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';
636print "</td></tr>\n";
637print '</form>';
638
639
640print "<form method=\"post\" action=\"".$_SERVER["PHP_SELF"]."\">";
641print '<input type="hidden" name="token" value="'.newToken().'">';
642print "<input type=\"hidden\" name=\"action\" value=\"set_PROPALE_DRAFT_WATERMARK\">";
643print '<tr class="oddeven"><td>';
644print $form->textwithpicto($langs->trans("WatermarkOnDraftProposal"), $htmltext, 1, 'help', '', 0, 2, 'watermarktooltip').'<br>';
645print '</td><td>';
646print '<input class="flat minwidth200" type="text" name="PROPALE_DRAFT_WATERMARK" value="'.$conf->global->PROPALE_DRAFT_WATERMARK.'">';
647print '</td><td class="right">';
648print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';
649print "</td></tr>\n";
650print '</form>';
651
652/* Seems to be not so used. So kept hidden for the moment to avoid dangerous options inflation.
653if ($conf->banque->enabled)
654{
655
656    print '<tr class="oddeven"><td>';
657    print $langs->trans("BANK_ASK_PAYMENT_BANK_DURING_PROPOSAL").'</td><td>&nbsp</td><td class="right">';
658    if (! empty($conf->use_javascript_ajax))
659    {
660        print ajax_constantonoff('BANK_ASK_PAYMENT_BANK_DURING_PROPOSAL');
661    }
662    else
663    {
664        if (empty($conf->global->BANK_ASK_PAYMENT_BANK_DURING_PROPOSAL))
665        {
666            print '<a href="'.$_SERVER['PHP_SELF'].'?action=set_BANK_ASK_PAYMENT_BANK_DURING_PROPOSAL&amp;token='.newToken().'&amp;value=1">'.img_picto($langs->trans("Disabled"),'switch_off').'</a>';
667        }
668        else
669        {
670            print '<a href="'.$_SERVER['PHP_SELF'].'?action=set_BANK_ASK_PAYMENT_BANK_DURING_PROPOSAL&amp;token='.newToken().'&amp;value=0">'.img_picto($langs->trans("Enabled"),'switch_on').'</a>';
671        }
672    }
673    print '</td></tr>';
674}
675else
676{
677
678    print '<tr class="oddeven"><td>';
679    print $langs->trans("BANK_ASK_PAYMENT_BANK_DURING_PROPOSAL").'</td><td>&nbsp;</td><td align="center">'.$langs->trans('NotAvailable').'</td></tr>';
680}
681*/
682
683print '</table>';
684
685
686
687/*
688 *  Directory
689 */
690print '<br>';
691print load_fiche_titre($langs->trans("PathToDocuments"), '', '');
692
693print "<table class=\"noborder\" width=\"100%\">\n";
694print "<tr class=\"liste_titre\">\n";
695print "  <td>".$langs->trans("Name")."</td>\n";
696print "  <td>".$langs->trans("Value")."</td>\n";
697print "</tr>\n";
698print "<tr class=\"oddeven\">\n  <td width=\"140\">".$langs->trans("PathDirectory")."</td>\n  <td>".$conf->propal->multidir_output[$conf->entity]."</td>\n</tr>\n";
699print "</table>\n<br>";
700
701
702/*
703 * Notifications
704 */
705
706print load_fiche_titre($langs->trans("Notifications"), '', '');
707print '<table class="noborder centpercent">';
708print '<tr class="liste_titre">';
709print '<td>'.$langs->trans("Parameter").'</td>';
710print '<td align="center" width="60"></td>';
711print '<td width="80">&nbsp;</td>';
712print "</tr>\n";
713
714print '<tr class="oddeven"><td colspan="2">';
715print $langs->trans("YouMayFindNotificationsFeaturesIntoModuleNotification").'<br>';
716print '</td><td class="right">';
717print "</td></tr>\n";
718
719print '</table>';
720
721// End of page
722llxFooter();
723$db->close();
724