32require
'../main.inc.php';
33require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
34require_once DOL_DOCUMENT_ROOT.
'/core/lib/pdf.lib.php';
35require_once DOL_DOCUMENT_ROOT.
'/comm/propal/class/propal.class.php';
36require_once DOL_DOCUMENT_ROOT.
'/core/lib/propal.lib.php';
39$langs->loadLangs(array(
"admin",
"other",
"errors",
"propal"));
45$action =
GETPOST(
'action',
'aZ09');
46$value =
GETPOST(
'value',
'alpha');
47$modulepart =
GETPOST(
'modulepart',
'aZ09');
49$label =
GETPOST(
'label',
'alpha');
50$scandir =
GETPOST(
'scan_dir',
'alpha');
57include DOL_DOCUMENT_ROOT.
'/core/actions_setmoduleoptions.inc.php';
60if ($action ==
'updateMask') {
61 $maskconstpropal =
GETPOST(
'maskconstpropal',
'aZ09');
62 $maskpropal =
GETPOST(
'maskpropal',
'alpha');
63 if ($maskconstpropal && preg_match(
'/_MASK$/', $maskconstpropal)) {
64 $res =
dolibarr_set_const($db, $maskconstpropal, $maskpropal,
'chaine', 0,
'', $conf->entity);
76} elseif ($action ==
'specimen') {
77 $modele =
GETPOST(
'module',
'alpha');
80 $propal->initAsSpecimen();
83 $file =
''; $classname =
''; $filefound = 0;
84 $dirmodels = array_merge(array(
'/'), (array) $conf->modules_parts[
'models']);
85 foreach ($dirmodels as $reldir) {
86 $file =
dol_buildpath($reldir.
"core/modules/propale/doc/pdf_".$modele.
".modules.php");
87 if (file_exists($file)) {
89 $classname =
"pdf_".$modele;
97 $module =
new $classname($db);
99 if ($module->write_file($propal, $langs) > 0) {
100 header(
"Location: ".DOL_URL_ROOT.
"/document.php?modulepart=propal&file=SPECIMEN.pdf");
108 dol_syslog($langs->trans(
"ErrorModuleNotFound"), LOG_ERR);
110} elseif ($action ==
'setribchq') {
111 $rib =
GETPOST(
'rib',
'alpha');
112 $chq =
GETPOST(
'chq',
'alpha');
114 $res =
dolibarr_set_const($db,
"FACTURE_RIB_NUMBER", $rib,
'chaine', 0,
'', $conf->entity);
115 $res =
dolibarr_set_const($db,
"FACTURE_CHQ_NUMBER", $chq,
'chaine', 0,
'', $conf->entity);
126} elseif ($action ==
'set_PROPALE_DRAFT_WATERMARK') {
127 $draft =
GETPOST(
'PROPALE_DRAFT_WATERMARK',
'alpha');
129 $res =
dolibarr_set_const($db,
"PROPALE_DRAFT_WATERMARK", trim($draft),
'chaine', 0,
'', $conf->entity);
139} elseif ($action ==
'set_PROPOSAL_FREE_TEXT') {
140 $freetext =
GETPOST(
'PROPOSAL_FREE_TEXT',
'restricthtml');
142 $res =
dolibarr_set_const($db,
"PROPOSAL_FREE_TEXT", $freetext,
'chaine', 0,
'', $conf->entity);
153} elseif ($action ==
'setdefaultduration') {
154 $res =
dolibarr_set_const($db,
"PROPALE_VALIDITY_DURATION", $value,
'chaine', 0,
'', $conf->entity);
165} elseif ($action ==
'set_BANK_ASK_PAYMENT_BANK_DURING_PROPOSAL') {
166 $res =
dolibarr_set_const($db,
"BANK_ASK_PAYMENT_BANK_DURING_PROPOSAL", $value,
'chaine', 0,
'', $conf->entity);
177} elseif ($action ==
'set') {
180} elseif ($action ==
'del') {
183 if ($conf->global->PROPALE_ADDON_PDF ==
"$value") {
187} elseif ($action ==
'setdoc') {
188 if (
dolibarr_set_const($db,
"PROPALE_ADDON_PDF", $value,
'chaine', 0,
'', $conf->entity)) {
189 $conf->global->PROPALE_ADDON_PDF = $value;
197} elseif ($action ==
'setmod') {
202} elseif (preg_match(
'/set_(.*)/', $action, $reg)) {
215 header(
"Location: " . $_SERVER[
"PHP_SELF"]);
218} elseif (preg_match(
'/del_(.*)/', $action, $reg)) {
230 header(
"Location: " . $_SERVER[
"PHP_SELF"]);
240$form =
new Form($db);
242$dirmodels = array_merge(array(
'/'), (array) $conf->modules_parts[
'models']);
244llxHeader(
'', $langs->trans(
"PropalSetup"));
248$linkback =
'<a href="'.DOL_URL_ROOT.
'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToModuleList").
'</a>';
249print
load_fiche_titre($langs->trans(
"PropalSetup"), $linkback,
'title_setup');
260print
'<table class="noborder centpercent">';
261print
'<tr class="liste_titre">';
262print
'<td>'.$langs->trans(
"Name").
"</td>\n";
263print
'<td>'.$langs->trans(
"Description").
"</td>\n";
264print
'<td class="nowrap">'.$langs->trans(
"Example").
"</td>\n";
265print
'<td align="center" width="60">'.$langs->trans(
"Status").
'</td>';
266print
'<td align="center" width="16">'.$langs->trans(
"ShortInfo").
'</td>';
271foreach ($dirmodels as $reldir) {
275 $handle = opendir($dir);
276 if (is_resource($handle)) {
277 while (($file = readdir($handle)) !==
false) {
278 if (substr($file, 0, 12) ==
'mod_propale_' && substr($file,
dol_strlen($file) - 3, 3) ==
'php') {
279 $file = substr($file, 0,
dol_strlen($file) - 4);
281 require_once $dir.
'/'.$file.
'.php';
286 if ($module->version ==
'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) {
289 if ($module->version ==
'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) {
293 if ($module->isEnabled()) {
294 print
'<tr class="oddeven"><td>'.$module->nom.
"</td><td>\n";
295 print $module->info();
299 print
'<td class="nowrap">';
300 $tmp = $module->getExample();
301 if (preg_match(
'/^Error/', $tmp)) {
302 $langs->load(
"errors");
303 print
'<div class="error">'.$langs->trans($tmp).
'</div>';
304 } elseif ($tmp ==
'NotConfigured') {
305 print
'<span class="opacitymedium">'.$langs->trans($tmp).
'</span>';
311 print
'<td class="center">';
312 if ($conf->global->PROPALE_ADDON ==
"$file") {
313 print
img_picto($langs->trans(
"Activated"),
'switch_on');
315 print
'<a class="reposition" href="'.$_SERVER[
"PHP_SELF"].
'?action=setmod&token='.newToken().
'&value='.urlencode($file).
'">';
316 print
img_picto($langs->trans(
"Disabled"),
'switch_off');
321 $propal =
new Propal($db);
322 $propal->initAsSpecimen();
326 $htmltooltip .=
''.$langs->trans(
"Version").
': <b>'.$module->getVersion().
'</b><br>';
328 $nextval = $module->getNextValue($mysoc, $propal);
329 if (
"$nextval" != $langs->trans(
"NotAvailable")) {
330 $htmltooltip .=
''.$langs->trans(
"NextValue").
': ';
332 if (preg_match(
'/^Error/', $nextval) || $nextval ==
'NotConfigured') {
333 $nextval = $langs->trans($nextval);
335 $htmltooltip .= $nextval.
'<br>';
337 $htmltooltip .= $langs->trans($module->error).
'<br>';
341 print
'<td class="center">';
342 print $form->textwithpicto(
'', $htmltooltip, 1, 0);
353print
"</table><br>\n";
365$sql .=
" FROM ".MAIN_DB_PREFIX.
"document_model";
366$sql .=
" WHERE type = '".$db->escape($type).
"'";
367$sql .=
" AND entity = ".$conf->entity;
368$resql = $db->query($sql);
371 $num_rows = $db->num_rows($resql);
372 while ($i < $num_rows) {
373 $array = $db->fetch_array($resql);
374 array_push($def, $array[0]);
382print
"<table class=\"noborder\" width=\"100%\">\n";
383print
"<tr class=\"liste_titre\">\n";
384print
" <td>".$langs->trans(
"Name").
"</td>\n";
385print
" <td>".$langs->trans(
"Description").
"</td>\n";
386print
'<td align="center" width="40">'.$langs->trans(
"Status").
"</td>\n";
387print
'<td align="center" width="40">'.$langs->trans(
"Default").
"</td>\n";
388print
'<td align="center" width="40">'.$langs->trans(
"ShortInfo").
'</td>';
389print
'<td align="center" width="40">'.$langs->trans(
"Preview").
'</td>';
394foreach ($dirmodels as $reldir) {
395 foreach (array(
'',
'/doc') as $valdir) {
396 $realpath = $reldir.
"core/modules/propale".$valdir;
400 $handle = opendir($dir);
401 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);
417 $modulequalified = 1;
418 if ($module->version ==
'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) {
419 $modulequalified = 0;
421 if ($module->version ==
'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) {
422 $modulequalified = 0;
425 if ($modulequalified) {
426 print
'<tr class="oddeven"><td width="100">';
427 print (empty($module->name) ? $name : $module->
name);
429 if (method_exists($module,
'info')) {
430 print $module->info($langs);
432 print $module->description;
437 if (in_array($name, $def)) {
438 print
'<td class="center">'.
"\n";
439 print
'<a class="reposition" href="'.$_SERVER[
"PHP_SELF"].
'?action=del&token='.newToken().
'&value='.urlencode($name).
'">';
440 print
img_picto($langs->trans(
"Enabled"),
'switch_on');
444 print
"<td align=\"center\">\n";
445 print
'<a class="reposition" 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>';
450 print
"<td align=\"center\">";
451 if ($conf->global->PROPALE_ADDON_PDF ==
"$name") {
452 print
img_picto($langs->trans(
"Default"),
'on');
454 print
'<a class="reposition" 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>';
459 $htmltooltip = $langs->trans(
"Name").
': '.$module->name;
460 $htmltooltip .=
'<br>'.$langs->trans(
"Type").
': '.($module->type ? $module->type : $langs->trans(
"Unknown"));
461 if ($module->type ==
'pdf') {
462 $htmltooltip .=
'<br>'.$langs->trans(
"Width").
'/'.$langs->trans(
"Height").
': '.$module->page_largeur.
'/'.$module->page_hauteur;
464 $htmltooltip .=
'<br>'.$langs->trans(
"Path").
': '.preg_replace(
'/^\//',
'', $realpath).
'/'.$file;
466 $htmltooltip .=
'<br><br><u>'.$langs->trans(
"FeaturesSupported").
':</u>';
467 $htmltooltip .=
'<br>'.$langs->trans(
"Logo").
': '.
yn($module->option_logo, 1, 1);
468 $htmltooltip .=
'<br>'.$langs->trans(
"PaymentMode").
': '.
yn($module->option_modereg, 1, 1);
469 $htmltooltip .=
'<br>'.$langs->trans(
"PaymentConditions").
': '.
yn($module->option_condreg, 1, 1);
470 $htmltooltip .=
'<br>'.$langs->trans(
"MultiLanguage").
': '.
yn($module->option_multilang, 1, 1);
473 $htmltooltip .=
'<br>'.$langs->trans(
"WatermarkOnDraftProposal").
': '.
yn($module->option_draft_watermark, 1, 1);
476 print
'<td class="center">';
477 print $form->textwithpicto(
'', $htmltooltip, 1, 0);
481 print
'<td class="center">';
482 if ($module->type ==
'pdf') {
483 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=specimen&module='.$name.
'">'.
img_object($langs->trans(
"Preview"),
'pdf').
'</a>';
485 print
img_object($langs->trans(
"PreviewNotAvailable"),
'generic');
507print
load_fiche_titre($langs->trans(
"SuggestedPaymentModesIfNotDefinedInProposal"),
'',
'');
509print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
510print
'<input type="hidden" name="token" value="'.newToken().
'" />';
512print
'<table class="noborder centpercent">';
514print
'<tr class="liste_titre">';
516print
'<input type="hidden" name="action" value="setribchq">';
517print $langs->trans(
"PaymentMode").
'</td>';
518print
'<td align="right">';
519if (!isModEnabled(
'facture')) {
520 print
'<input type="submit" class="button button-edit" value="'.$langs->trans(
"Modify").
'">';
525print
'<tr class="oddeven">';
526print
"<td>".$langs->trans(
"SuggestPaymentByRIBOnAccount").
"</td>";
528if (!isModEnabled(
'facture')) {
529 if (isModEnabled(
"banque")) {
530 $sql =
"SELECT rowid, label";
531 $sql .=
" FROM ".MAIN_DB_PREFIX.
"bank_account";
532 $sql .=
" WHERE clos = 0";
533 $sql .=
" AND courant = 1";
534 $sql .=
" AND entity IN (".getEntity(
'bank_account').
")";
535 $resql = $db->query($sql);
537 $num = $db->num_rows($resql);
540 print
'<select name="rib" class="flat" id="rib">';
541 print
'<option value="0">'.$langs->trans(
"DoNotSuggestPaymentMode").
'</option>';
543 $row = $db->fetch_row($resql);
545 print
'<option value="'.$row[0].
'"';
546 print $conf->global->FACTURE_RIB_NUMBER == $row[0] ?
' selected' :
'';
547 print
'>'.$row[1].
'</option>';
553 print
"<i>".$langs->trans(
"NoActiveBankAccountDefined").
"</i>";
557 print
'<span class="opacitymedium">'.$langs->trans(
"BankModuleNotActive").
'</span>';
560 print
'<span class="opacitymedium">'.$langs->trans(
"SeeSetupOfModule", $langs->transnoentitiesnoconv(
"Module30Name")).
'</span>';
564print
'<tr class="oddeven">';
565print
"<td>".$langs->trans(
"SuggestPaymentByChequeToAddress").
"</td>";
567if (!isModEnabled(
'facture')) {
568 print
'<select class="flat" name="chq" id="chq">';
569 print
'<option value="0">'.$langs->trans(
"DoNotSuggestPaymentMode").
'</option>';
570 print
'<option value="-1"'.($conf->global->FACTURE_CHQ_NUMBER ?
' selected' :
'').
'>'.$langs->trans(
"MenuCompanySetup").
' ('.($mysoc->name ? $mysoc->name : $langs->trans(
"NotDefined")).
')</option>';
572 $sql =
"SELECT rowid, label";
573 $sql .=
" FROM ".MAIN_DB_PREFIX.
"bank_account";
574 $sql .=
" WHERE clos = 0";
575 $sql .=
" AND courant = 1";
576 $sql .=
" AND entity IN (".getEntity(
'bank_account').
")";
578 $resql = $db->query($sql);
580 $num = $db->num_rows($resql);
583 $row = $db->fetch_row($resql);
585 print
'<option value="'.$row[0].
'"';
586 print $conf->global->FACTURE_CHQ_NUMBER == $row[0] ?
' selected' :
'';
587 print
'>'.$langs->trans(
"OwnerOfBankAccount", $row[1]).
'</option>';
594 print
'<span class="opacitymedium">'.$langs->trans(
"SeeSetupOfModule", $langs->transnoentitiesnoconv(
"Module30Name")).
'</span>';
610print
"<table class=\"noborder\" width=\"100%\">";
611print
"<tr class=\"liste_titre\">";
612print
"<td>".$langs->trans(
"Parameter").
"</td>\n";
613print
'<td width="60" align="center">'.$langs->trans(
"Value").
"</td>\n";
614print
"<td> </td>\n";
618print
"<form method=\"post\" action=\"".$_SERVER[
"PHP_SELF"].
"\">";
619print
'<input type="hidden" name="token" value="'.newToken().
'">';
620print
"<input type=\"hidden\" name=\"action\" value=\"setdefaultduration\">";
621print
'<tr class="oddeven">';
622print
'<td>'.$langs->trans(
"DefaultProposalDurationValidity").
'</td>';
623print
'<td width="60" align="center">'.
"<input size=\"3\" class=\"flat\" type=\"text\" name=\"value\" value=\"".$conf->global->PROPALE_VALIDITY_DURATION.
"\"></td>";
624print
'<td class="right"><input type="submit" class="button button-edit" value="'.$langs->trans(
"Modify").
'"></td>';
629print
'<tr class="oddeven">';
630print
'<td>'.$langs->trans(
"AllowExternalDownload").
'</td>';
631print
'<td class="center" colspan="2">';
632print ajax_constantonoff(
'PROPOSAL_ALLOW_EXTERNAL_DOWNLOAD', array(),
null, 0, 0, 0, 2, 0, 1);
674$substitutionarray[
'__(AnyTranslationKey)__'] = $langs->trans(
"Translation");
675$htmltext =
'<i>'.$langs->trans(
"AvailableVariables").
':<br>';
676foreach ($substitutionarray as $key => $val) {
677 $htmltext .= $key.
'<br>';
681print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="post">';
682print
'<input type="hidden" name="token" value="'.newToken().
'">';
683print
'<input type="hidden" name="action" value="set_PROPOSAL_FREE_TEXT">';
684print
'<tr class="oddeven"><td colspan="2">';
685print $form->textwithpicto($langs->trans(
"FreeLegalTextOnProposal"), $langs->trans(
"AddCRIfTooLong").
'<br><br>'.$htmltext, 1,
'help',
'', 0, 2,
'freetexttooltip').
'<br>';
686$variablename =
'PROPOSAL_FREE_TEXT';
687if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) {
688 print
'<textarea name="'.$variablename.
'" class="flat" cols="120">'.
getDolGlobalString($variablename).
'</textarea>';
690 include_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
692 print $doleditor->Create();
694print
'</td><td class="right">';
695print
'<input type="submit" class="button button-edit" value="'.$langs->trans(
"Modify").
'">';
700print
"<form method=\"post\" action=\"".$_SERVER[
"PHP_SELF"].
"\">";
701print
'<input type="hidden" name="token" value="'.newToken().
'">';
702print
"<input type=\"hidden\" name=\"action\" value=\"set_PROPALE_DRAFT_WATERMARK\">";
703print
'<tr class="oddeven"><td>';
704print $form->textwithpicto($langs->trans(
"WatermarkOnDraftProposal"), $htmltext, 1,
'help',
'', 0, 2,
'watermarktooltip').
'<br>';
706print
'<input class="flat minwidth200" type="text" name="PROPALE_DRAFT_WATERMARK" value="'.dol_escape_htmltag(
getDolGlobalString(
'PROPALE_DRAFT_WATERMARK')).
'">';
707print
'</td><td class="right">';
708print
'<input type="submit" class="button button-edit" value="'.$langs->trans(
"Modify").
'">';
753print
"<table class=\"noborder\" width=\"100%\">\n";
754print
"<tr class=\"liste_titre\">\n";
755print
" <td>".$langs->trans(
"Name").
"</td>\n";
756print
" <td>".$langs->trans(
"Value").
"</td>\n";
758print
"<tr class=\"oddeven\">\n <td width=\"140\">".$langs->trans(
"PathDirectory").
"</td>\n <td>".$conf->propal->multidir_output[$conf->entity].
"</td>\n</tr>\n";
759print
"</table>\n<br>";
767print
'<table class="noborder centpercent">';
768print
'<tr class="liste_titre">';
769print
'<td>'.$langs->trans(
"Parameter").
'</td>';
770print
'<td align="center" width="60"></td>';
771print
'<td width="80"> </td>';
774print
'<tr class="oddeven"><td colspan="2">';
775print $langs->trans(
"YouMayFindNotificationsFeaturesIntoModuleNotification").
'<br>';
776print
'</td><td class="right">';
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.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
Class to manage a WYSIWYG editor.
Class to manage proposals.
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
yn($yesno, $case=1, $color=0)
Return yes or no in current language.
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_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
pdf_getSubstitutionArray($outputlangs, $exclude=null, $object=null, $onlykey=0, $include=null)
Return array of possible substitutions for PDF content (without external module substitutions).
propal_admin_prepare_head()
Return array head with list of tabs to view object informations.
$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.