34require
'../main.inc.php';
35require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
36require_once DOL_DOCUMENT_ROOT.
'/core/lib/pdf.lib.php';
37require_once DOL_DOCUMENT_ROOT.
'/comm/propal/class/propal.class.php';
38require_once DOL_DOCUMENT_ROOT.
'/core/lib/propal.lib.php';
41$langs->loadLangs(array(
"admin",
"other",
"errors",
"propal"));
47$action =
GETPOST(
'action',
'aZ09');
48$value =
GETPOST(
'value',
'alpha');
49$modulepart =
GETPOST(
'modulepart',
'aZ09');
51$label =
GETPOST(
'label',
'alpha');
52$scandir =
GETPOST(
'scan_dir',
'alpha');
59include DOL_DOCUMENT_ROOT.
'/core/actions_setmoduleoptions.inc.php';
62if ($action ==
'updateMask') {
63 $maskconstpropal =
GETPOST(
'maskconstpropal',
'aZ09');
64 $maskpropal =
GETPOST(
'maskpropal',
'alpha');
65 if ($maskconstpropal && preg_match(
'/_MASK$/', $maskconstpropal)) {
66 $res =
dolibarr_set_const($db, $maskconstpropal, $maskpropal,
'chaine', 0,
'', $conf->entity);
78} elseif ($action ==
'specimen') {
79 $modele =
GETPOST(
'module',
'alpha');
82 $propal->initAsSpecimen();
87 $dirmodels = array_merge(array(
'/'), (array) $conf->modules_parts[
'models']);
88 foreach ($dirmodels as $reldir) {
89 $file =
dol_buildpath($reldir.
"core/modules/propale/doc/pdf_".$modele.
".modules.php");
90 if (file_exists($file)) {
91 $classname =
"pdf_".$modele;
96 if ($classname !==
'') {
99 $module =
new $classname($db);
100 '@phan-var-force CommonDocGenerator $module';
102 if ($module->write_file($propal, $langs) > 0) {
103 header(
"Location: ".DOL_URL_ROOT.
"/document.php?modulepart=propal&file=SPECIMEN.pdf");
111 dol_syslog($langs->trans(
"ErrorModuleNotFound"), LOG_ERR);
113} elseif ($action ==
'setribchq') {
114 $rib =
GETPOST(
'rib',
'alpha');
115 $chq =
GETPOST(
'chq',
'alpha');
117 $res =
dolibarr_set_const($db,
"FACTURE_RIB_NUMBER", $rib,
'chaine', 0,
'', $conf->entity);
118 $res =
dolibarr_set_const($db,
"FACTURE_CHQ_NUMBER", $chq,
'chaine', 0,
'', $conf->entity);
129} elseif ($action ==
'update') {
130 if (GETPOSTISSET(
'PROPALE_VALIDITY_DURATION')) {
131 $value =
GETPOST(
'PROPALE_VALIDITY_DURATION');
132 $res =
dolibarr_set_const($db,
"PROPALE_VALIDITY_DURATION", $value,
'chaine', 0,
'', $conf->entity);
137 if (GETPOSTISSET(
'PROPALE_DRAFT_WATERMARK')) {
138 $draft =
GETPOST(
'PROPALE_DRAFT_WATERMARK',
'alpha');
139 $res =
dolibarr_set_const($db,
"PROPALE_DRAFT_WATERMARK", trim($draft),
'chaine', 0,
'', $conf->entity);
144 if (GETPOSTISSET(
'PROPOSAL_FREE_TEXT')) {
145 $freetext =
GETPOST(
'PROPOSAL_FREE_TEXT',
'restricthtml');
146 $res =
dolibarr_set_const($db,
"PROPOSAL_FREE_TEXT", $freetext,
'chaine', 0,
'', $conf->entity);
157} elseif ($action ==
'set_BANK_ASK_PAYMENT_BANK_DURING_PROPOSAL') {
158 $res =
dolibarr_set_const($db,
"BANK_ASK_PAYMENT_BANK_DURING_PROPOSAL", $value,
'chaine', 0,
'', $conf->entity);
169} elseif ($action ==
'set') {
172} elseif ($action ==
'del') {
175 if ($conf->global->PROPALE_ADDON_PDF ==
"$value") {
179} elseif ($action ==
'setdoc') {
180 if (
dolibarr_set_const($db,
"PROPALE_ADDON_PDF", $value,
'chaine', 0,
'', $conf->entity)) {
181 $conf->global->PROPALE_ADDON_PDF = $value;
189} elseif ($action ==
'setmod') {
194} elseif (preg_match(
'/set_(.*)/', $action, $reg)) {
207 header(
"Location: " . $_SERVER[
"PHP_SELF"]);
210} elseif (preg_match(
'/del_(.*)/', $action, $reg)) {
222 header(
"Location: " . $_SERVER[
"PHP_SELF"]);
232$form =
new Form($db);
234$dirmodels = array_merge(array(
'/'), (array) $conf->modules_parts[
'models']);
236llxHeader(
'', $langs->trans(
"PropalSetup"),
'',
'', 0, 0,
'',
'',
'',
'mod-admin page-propal');
240$linkback =
'<a href="'.DOL_URL_ROOT.
'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToModuleList").
'</a>';
241print
load_fiche_titre($langs->trans(
"PropalSetup"), $linkback,
'title_setup');
252print
'<table class="noborder centpercent">';
253print
'<tr class="liste_titre">';
254print
'<td>'.$langs->trans(
"Name").
"</td>\n";
255print
'<td>'.$langs->trans(
"Description").
"</td>\n";
256print
'<td class="nowrap">'.$langs->trans(
"Example").
"</td>\n";
257print
'<td align="center" width="60">'.$langs->trans(
"Status").
'</td>';
258print
'<td align="center" width="16">'.$langs->trans(
"ShortInfo").
'</td>';
263foreach ($dirmodels as $reldir) {
267 $handle = opendir($dir);
268 if (is_resource($handle)) {
269 while (($file = readdir($handle)) !==
false) {
270 if (substr($file, 0, 12) ==
'mod_propale_' && substr($file,
dol_strlen($file) - 3, 3) ==
'php') {
271 $file = substr($file, 0,
dol_strlen($file) - 4);
273 require_once $dir.
'/'.$file.
'.php';
275 $module =
new $file();
278 if ($module->version ==
'development' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 2) {
281 if ($module->version ==
'experimental' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 1) {
285 if ($module->isEnabled()) {
286 print
'<tr class="oddeven"><td>'.$module->nom.
"</td><td>\n";
287 print $module->info($langs);
291 print
'<td class="nowrap">';
292 $tmp = $module->getExample();
293 if (preg_match(
'/^Error/', $tmp)) {
294 $langs->load(
"errors");
295 print
'<div class="error">'.$langs->trans($tmp).
'</div>';
296 } elseif ($tmp ==
'NotConfigured') {
297 print
'<span class="opacitymedium">'.$langs->trans($tmp).
'</span>';
303 print
'<td class="center">';
304 if ($conf->global->PROPALE_ADDON ==
"$file") {
305 print
img_picto($langs->trans(
"Activated"),
'switch_on');
307 print
'<a class="reposition" href="'.$_SERVER[
"PHP_SELF"].
'?action=setmod&token='.
newToken().
'&value='.urlencode($file).
'">';
308 print
img_picto($langs->trans(
"Disabled"),
'switch_off');
313 $propal =
new Propal($db);
314 $propal->initAsSpecimen();
318 $htmltooltip .=
''.$langs->trans(
"Version").
': <b>'.$module->getVersion().
'</b><br>';
320 $nextval = $module->getNextValue($mysoc, $propal);
321 if (
"$nextval" != $langs->trans(
"NotAvailable")) {
322 $htmltooltip .=
''.$langs->trans(
"NextValue").
': ';
324 if (preg_match(
'/^Error/', $nextval) || $nextval ==
'NotConfigured') {
325 $nextval = $langs->trans($nextval);
327 $htmltooltip .= $nextval.
'<br>';
329 $htmltooltip .= $langs->trans($module->error).
'<br>';
333 print
'<td class="center">';
334 print $form->textwithpicto(
'', $htmltooltip, 1, 0);
345print
"</table><br>\n";
357$sql .=
" FROM ".MAIN_DB_PREFIX.
"document_model";
358$sql .=
" WHERE type = '".$db->escape($type).
"'";
359$sql .=
" AND entity = ".$conf->entity;
360$resql = $db->query($sql);
363 $num_rows = $db->num_rows($resql);
364 while ($i < $num_rows) {
365 $array = $db->fetch_array($resql);
366 if (is_array($array)) {
367 array_push($def, $array[0]);
376print
"<table class=\"noborder\" width=\"100%\">\n";
377print
"<tr class=\"liste_titre\">\n";
378print
" <td>".$langs->trans(
"Name").
"</td>\n";
379print
" <td>".$langs->trans(
"Description").
"</td>\n";
380print
'<td align="center" width="40">'.$langs->trans(
"Status").
"</td>\n";
381print
'<td align="center" width="40">'.$langs->trans(
"Default").
"</td>\n";
382print
'<td align="center" width="40">'.$langs->trans(
"ShortInfo").
'</td>';
383print
'<td align="center" width="40">'.$langs->trans(
"Preview").
'</td>';
388foreach ($dirmodels as $reldir) {
389 foreach (array(
'',
'/doc') as $valdir) {
390 $realpath = $reldir.
"core/modules/propale".$valdir;
394 $handle = opendir($dir);
395 if (is_resource($handle)) {
397 while (($file = readdir($handle)) !==
false) {
403 foreach ($filelist as $file) {
404 if (preg_match(
'/\.modules\.php$/i', $file) && preg_match(
'/^(pdf_|doc_)/', $file)) {
405 if (file_exists($dir.
'/'.$file)) {
406 $name = substr($file, 4,
dol_strlen($file) - 16);
407 $classname = substr($file, 0,
dol_strlen($file) - 12);
409 require_once $dir.
'/'.$file;
410 $module =
new $classname($db);
412 $modulequalified = 1;
413 if ($module->version ==
'development' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 2) {
414 $modulequalified = 0;
416 if ($module->version ==
'experimental' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 1) {
417 $modulequalified = 0;
420 if ($modulequalified) {
421 print
'<tr class="oddeven"><td width="100">';
422 print(empty($module->name) ? $name : $module->
name);
424 if (method_exists($module,
'info')) {
425 print $module->info($langs);
427 print $module->description;
432 if (in_array($name, $def)) {
433 print
'<td class="center">'.
"\n";
434 print
'<a class="reposition" href="'.$_SERVER[
"PHP_SELF"].
'?action=del&token='.
newToken().
'&value='.urlencode($name).
'">';
435 print
img_picto($langs->trans(
"Enabled"),
'switch_on');
439 print
"<td align=\"center\">\n";
440 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>';
445 print
"<td align=\"center\">";
446 if ($conf->global->PROPALE_ADDON_PDF ==
"$name") {
447 print
img_picto($langs->trans(
"Default"),
'on');
449 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>';
454 $htmltooltip = $langs->trans(
"Name").
': '.$module->name;
455 $htmltooltip .=
'<br>'.$langs->trans(
"Type").
': '.($module->type ? $module->type : $langs->trans(
"Unknown"));
456 if ($module->type ==
'pdf') {
457 $htmltooltip .=
'<br>'.$langs->trans(
"Width").
'/'.$langs->trans(
"Height").
': '.$module->page_largeur.
'/'.$module->page_hauteur;
459 $htmltooltip .=
'<br>'.$langs->trans(
"Path").
': '.preg_replace(
'/^\//',
'', $realpath).
'/'.$file;
461 $htmltooltip .=
'<br><br><u>'.$langs->trans(
"FeaturesSupported").
':</u>';
462 $htmltooltip .=
'<br>'.$langs->trans(
"Logo").
': '.
yn($module->option_logo, 1, 1);
463 $htmltooltip .=
'<br>'.$langs->trans(
"PaymentMode").
': '.
yn($module->option_modereg, 1, 1);
464 $htmltooltip .=
'<br>'.$langs->trans(
"PaymentConditions").
': '.
yn($module->option_condreg, 1, 1);
465 $htmltooltip .=
'<br>'.$langs->trans(
"MultiLanguage").
': '.
yn($module->option_multilang, 1, 1);
468 $htmltooltip .=
'<br>'.$langs->trans(
"WatermarkOnDraftProposal").
': '.
yn($module->option_draft_watermark, 1, 1);
471 print
'<td class="center">';
472 print $form->textwithpicto(
'', $htmltooltip, 1, 0);
476 print
'<td class="center">';
477 if ($module->type ==
'pdf') {
478 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=specimen&module='.$name.
'">'.
img_object($langs->trans(
"Preview"),
'pdf').
'</a>';
480 print
img_object($langs->trans(
"PreviewNotAvailable"),
'generic');
502print
load_fiche_titre($langs->trans(
"SuggestedPaymentModesIfNotDefinedInProposal"),
'',
'');
504print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
505print
'<input type="hidden" name="token" value="'.newToken().
'" />';
507print
'<table class="noborder centpercent">';
509print
'<tr class="liste_titre">';
511print
'<input type="hidden" name="action" value="setribchq">';
512print $langs->trans(
"PaymentMode").
'</td>';
513print
'<td align="right">';
514if (!isModEnabled(
'invoice')) {
515 print
'<input type="submit" class="button button-edit" value="'.$langs->trans(
"Modify").
'">';
520print
'<tr class="oddeven">';
521print
"<td>".$langs->trans(
"SuggestPaymentByRIBOnAccount").
"</td>";
523if (!isModEnabled(
'invoice')) {
524 if (isModEnabled(
"bank")) {
525 $sql =
"SELECT rowid, label";
526 $sql .=
" FROM ".MAIN_DB_PREFIX.
"bank_account";
527 $sql .=
" WHERE clos = 0";
528 $sql .=
" AND courant = 1";
529 $sql .=
" AND entity IN (".getEntity(
'bank_account').
")";
530 $resql = $db->query($sql);
532 $num = $db->num_rows($resql);
535 print
'<select name="rib" class="flat" id="rib">';
536 print
'<option value="0">'.$langs->trans(
"DoNotSuggestPaymentMode").
'</option>';
538 $row = $db->fetch_row($resql);
540 print
'<option value="'.$row[0].
'"';
541 print $conf->global->FACTURE_RIB_NUMBER == $row[0] ?
' selected' :
'';
542 print
'>'.$row[1].
'</option>';
548 print
"<i>".$langs->trans(
"NoActiveBankAccountDefined").
"</i>";
552 print
'<span class="opacitymedium">'.$langs->trans(
"BankModuleNotActive").
'</span>';
555 print
'<span class="opacitymedium">'.$langs->trans(
"SeeSetupOfModule", $langs->transnoentitiesnoconv(
"Module30Name")).
'</span>';
559print
'<tr class="oddeven">';
560print
"<td>".$langs->trans(
"SuggestPaymentByChequeToAddress").
"</td>";
562if (!isModEnabled(
'invoice')) {
563 print
'<select class="flat" name="chq" id="chq">';
564 print
'<option value="0">'.$langs->trans(
"DoNotSuggestPaymentMode").
'</option>';
565 print
'<option value="-1"'.($conf->global->FACTURE_CHQ_NUMBER ?
' selected' :
'').
'>'.$langs->trans(
"MenuCompanySetup").
' ('.($mysoc->name ? $mysoc->name : $langs->trans(
"NotDefined")).
')</option>';
567 $sql =
"SELECT rowid, label";
568 $sql .=
" FROM ".MAIN_DB_PREFIX.
"bank_account";
569 $sql .=
" WHERE clos = 0";
570 $sql .=
" AND courant = 1";
571 $sql .=
" AND entity IN (".getEntity(
'bank_account').
")";
573 $resql = $db->query($sql);
575 $num = $db->num_rows($resql);
578 $row = $db->fetch_row($resql);
580 print
'<option value="'.$row[0].
'"';
581 print $conf->global->FACTURE_CHQ_NUMBER == $row[0] ?
' selected' :
'';
582 print
'>'.$langs->trans(
"OwnerOfBankAccount", $row[1]).
'</option>';
589 print
'<span class="opacitymedium">'.$langs->trans(
"SeeSetupOfModule", $langs->transnoentitiesnoconv(
"Module30Name")).
'</span>';
605print
'<form method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
606print
'<input type="hidden" name="token" value="'.newToken().
'">';
607print
'<input type="hidden" name="page_y" value="">';
608print
'<input type="hidden" name="action" value="update">';
610print
'<table class="noborder centpercent">';
611print
"<tr class=\"liste_titre\">";
612print
"<td>".$langs->trans(
"Parameter").
"</td>\n";
613print
'<td width="60" align="center">'.$langs->trans(
"Value").
"</td>\n";
616print
'<tr class="oddeven">';
617print
'<td>'.$langs->trans(
"DefaultProposalDurationValidity").
'</td>';
618print
'<td width="60" align="center">';
619print
"<input size=\"3\" class=\"flat\" type=\"text\" name=\"PROPALE_VALIDITY_DURATION\" value=\"" .
getDolGlobalString(
'PROPALE_VALIDITY_DURATION').
"\"></td>";
623$substitutionarray[
'__(AnyTranslationKey)__'] = $langs->trans(
"Translation");
624$htmltext =
'<i>'.$langs->trans(
"AvailableVariables").
':<br>';
625foreach ($substitutionarray as $key => $val) {
626 $htmltext .= $key.
'<br>';
630print
'<tr class="oddeven"><td colspan="2">';
631print $form->textwithpicto($langs->trans(
"FreeLegalTextOnProposal"), $langs->trans(
"AddCRIfTooLong").
'<br><br>'.$htmltext, 1,
'help',
'', 0, 2,
'freetexttooltip').
'<br>';
632$variablename =
'PROPOSAL_FREE_TEXT';
634 print
'<textarea name="'.$variablename.
'" class="flat" cols="120">'.
getDolGlobalString($variablename).
'</textarea>';
636 include_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
638 print $doleditor->Create();
644print
'<tr class="oddeven"><td>';
645print $form->textwithpicto($langs->trans(
"WatermarkOnDraftProposal"), $htmltext, 1,
'help',
'', 0, 2,
'watermarktooltip').
'<br>';
647print
'<input class="flat minwidth200" type="text" name="PROPALE_DRAFT_WATERMARK" value="'.dol_escape_htmltag(
getDolGlobalString(
'PROPALE_DRAFT_WATERMARK')).
'">';
653print
'<tr class="oddeven">';
654print
'<td>'.$langs->trans(
"AllowExternalDownload").
'</td>';
655print
'<td class="center">';
656print ajax_constantonoff(
'PROPOSAL_ALLOW_EXTERNAL_DOWNLOAD', array(),
null, 0, 0, 0, 2, 0, 1);
660print
'<tr class="oddeven">';
661print
'<td>'.$langs->trans(
"AllowOnLineSign").
'</td>';
662print
'<td class="center">';
663print ajax_constantonoff(
'PROPOSAL_ALLOW_ONLINESIGN', array(),
null, 0, 0, 0, 2, 0, 1);
700print
'<center><input type="submit" class="button button-edit reposition" value="'.$langs->trans(
"Modify").
'"></center>';
711print
"<table class=\"noborder\" width=\"100%\">\n";
712print
"<tr class=\"liste_titre\">\n";
713print
" <td>".$langs->trans(
"Name").
"</td>\n";
714print
" <td>".$langs->trans(
"Value").
"</td>\n";
716print
"<tr class=\"oddeven\">\n <td width=\"140\">".$langs->trans(
"PathDirectory").
"</td>\n <td>".$conf->propal->multidir_output[$conf->entity].
"</td>\n</tr>\n";
717print
"</table>\n<br>";
725print
'<table class="noborder centpercent">';
726print
'<tr class="liste_titre">';
727print
'<td>'.$langs->trans(
"Parameter").
'</td>';
728print
'<td align="center" width="60"></td>';
729print
'<td width="80"> </td>';
732print
'<tr class="oddeven"><td colspan="2">';
733print $langs->trans(
"YouMayFindNotificationsFeaturesIntoModuleNotification").
'<br>';
734print
'</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($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)
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
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_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'.
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.
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 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 information.
$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.