35require
'../main.inc.php';
44require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
45require_once DOL_DOCUMENT_ROOT.
'/core/lib/pdf.lib.php';
46require_once DOL_DOCUMENT_ROOT.
'/comm/propal/class/propal.class.php';
47require_once DOL_DOCUMENT_ROOT.
'/core/lib/propal.lib.php';
50$langs->loadLangs(array(
"admin",
"other",
"errors",
"propal"));
56$action =
GETPOST(
'action',
'aZ09');
57$value =
GETPOST(
'value',
'alpha');
58$modulepart =
GETPOST(
'modulepart',
'aZ09');
60$label =
GETPOST(
'label',
'alpha');
61$scandir =
GETPOST(
'scan_dir',
'alpha');
69include DOL_DOCUMENT_ROOT.
'/core/actions_setmoduleoptions.inc.php';
72if ($action ==
'updateMask') {
73 $maskconstpropal =
GETPOST(
'maskconstpropal',
'aZ09');
74 $maskpropal =
GETPOST(
'maskpropal',
'alpha');
78 if ($maskconstpropal && preg_match(
'/_MASK$/', $maskconstpropal)) {
79 $res =
dolibarr_set_const($db, $maskconstpropal, $maskpropal,
'chaine', 0,
'', $conf->entity);
91} elseif ($action ==
'specimen') {
92 $modele =
GETPOST(
'module',
'alpha');
95 $propal->initAsSpecimen();
100 $dirmodels = array_merge(array(
'/'), (array) $conf->modules_parts[
'models']);
101 foreach ($dirmodels as $reldir) {
102 $file =
dol_buildpath($reldir.
"core/modules/propale/doc/pdf_".$modele.
".modules.php");
103 if (file_exists($file)) {
104 $classname =
"pdf_".$modele;
109 if ($classname !==
'') {
112 $module =
new $classname($db);
113 '@phan-var-force ModelePDFPropales $module';
116 if ($module->write_file($propal, $langs) > 0) {
117 header(
"Location: ".DOL_URL_ROOT.
"/document.php?modulepart=propal&file=SPECIMEN.pdf");
125 dol_syslog($langs->trans(
"ErrorModuleNotFound"), LOG_ERR);
127} elseif ($action ==
'setribchq') {
128 $rib =
GETPOST(
'rib',
'alpha');
129 $chq =
GETPOST(
'chq',
'alpha');
131 $res =
dolibarr_set_const($db,
"FACTURE_RIB_NUMBER", $rib,
'chaine', 0,
'', $conf->entity);
132 $res =
dolibarr_set_const($db,
"FACTURE_CHQ_NUMBER", $chq,
'chaine', 0,
'', $conf->entity);
143} elseif ($action ==
'update') {
144 if (GETPOSTISSET(
'PROPALE_VALIDITY_DURATION')) {
145 $value =
GETPOST(
'PROPALE_VALIDITY_DURATION');
146 $res =
dolibarr_set_const($db,
"PROPALE_VALIDITY_DURATION", $value,
'chaine', 0,
'', $conf->entity);
151 if (GETPOSTISSET(
'PROPALE_DRAFT_WATERMARK')) {
152 $draft =
GETPOST(
'PROPALE_DRAFT_WATERMARK',
'alpha');
153 $res =
dolibarr_set_const($db,
"PROPALE_DRAFT_WATERMARK", trim($draft),
'chaine', 0,
'', $conf->entity);
158 if (GETPOSTISSET(
'PROPOSAL_FREE_TEXT')) {
159 $freetext =
GETPOST(
'PROPOSAL_FREE_TEXT',
'restricthtml');
160 $res =
dolibarr_set_const($db,
"PROPOSAL_FREE_TEXT", $freetext,
'chaine', 0,
'', $conf->entity);
171} elseif ($action ==
'set_BANK_ASK_PAYMENT_BANK_DURING_PROPOSAL') {
172 $res =
dolibarr_set_const($db,
"BANK_ASK_PAYMENT_BANK_DURING_PROPOSAL", $value,
'chaine', 0,
'', $conf->entity);
183} elseif ($action ==
'set') {
186} elseif ($action ==
'del') {
193} elseif ($action ==
'setdoc') {
194 if (
dolibarr_set_const($db,
"PROPALE_ADDON_PDF", $value,
'chaine', 0,
'', $conf->entity)) {
195 $conf->global->PROPALE_ADDON_PDF = $value;
203} elseif ($action ==
'setmod') {
208} elseif (preg_match(
'/set_(.*)/', $action, $reg)) {
221 header(
"Location: " . $_SERVER[
"PHP_SELF"]);
224} elseif (preg_match(
'/del_(.*)/', $action, $reg)) {
236 header(
"Location: " . $_SERVER[
"PHP_SELF"]);
246$form =
new Form($db);
248$dirmodels = array_merge(array(
'/'), (array) $conf->modules_parts[
'models']);
250llxHeader(
'', $langs->trans(
"PropalSetup"),
'',
'', 0, 0,
'',
'',
'',
'mod-admin page-propal');
254$linkback =
'<a href="'.dolBuildUrl(DOL_URL_ROOT.
'/admin/modules.php', [
'restore_lastsearch_values' => 1]).
'">'.
img_picto($langs->trans(
"BackToModuleList"),
'back',
'class="pictofixedwidth"').
'<span class="hideonsmartphone">'.$langs->trans(
"BackToModuleList").
'</span></a>';
256print
load_fiche_titre($langs->trans(
"PropalSetup"), $linkback,
'title_setup');
267print
'<div class="div-table-responsive-no-min">';
268print
'<table class="noborder centpercent">';
269print
'<tr class="liste_titre">';
270print
'<td>'.$langs->trans(
"Name").
"</td>\n";
271print
'<td>'.$langs->trans(
"Description").
"</td>\n";
272print
'<td class="nowrap">'.$langs->trans(
"Example").
"</td>\n";
273print
'<td align="center" width="60">'.$langs->trans(
"Status").
'</td>';
274print
'<td align="center" width="16">'.$langs->trans(
"ShortInfo").
'</td>';
279foreach ($dirmodels as $reldir) {
283 $handle = opendir($dir);
284 if (is_resource($handle)) {
285 while (($file = readdir($handle)) !==
false) {
286 if (substr($file, 0, 12) ==
'mod_propale_' && substr($file,
dol_strlen($file) - 3, 3) ==
'php') {
287 $file = substr($file, 0,
dol_strlen($file) - 4);
289 require_once $dir.
'/'.$file.
'.php';
291 $module =
new $file();
293 '@phan-var-force ModeleNumRefPropales $module';
296 if ($module->version ==
'development' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 2) {
299 if ($module->version ==
'experimental' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 1) {
303 if ($module->isEnabled()) {
304 print
'<tr class="oddeven"><td>'.$module->getName($langs).
"</td><td>\n";
305 print $module->info($langs);
309 print
'<td class="nowrap">';
310 $tmp = $module->getExample();
311 if (preg_match(
'/^Error/', $tmp)) {
312 $langs->load(
"errors");
313 print
'<div class="error">'.$langs->trans($tmp).
'</div>';
314 } elseif ($tmp ==
'NotConfigured') {
315 print
'<span class="opacitymedium">'.$langs->trans($tmp).
'</span>';
321 print
'<td class="center">';
323 print
img_picto($langs->trans(
"Activated"),
'switch_on');
325 print
'<a class="reposition" href="'.$_SERVER[
"PHP_SELF"].
'?action=setmod&token='.
newToken().
'&value='.urlencode($file).
'">';
326 print
img_picto($langs->trans(
"Disabled"),
'switch_off');
331 $propal =
new Propal($db);
332 $propal->initAsSpecimen();
336 $htmltooltip .=
''.$langs->trans(
"Version").
': <b>'.$module->getVersion().
'</b><br>';
338 $nextval = $module->getNextValue(
$mysoc, $propal);
339 if (
"$nextval" != $langs->trans(
"NotAvailable")) {
340 $htmltooltip .=
''.$langs->trans(
"NextValue").
': ';
342 if (preg_match(
'/^Error/', $nextval) || $nextval ==
'NotConfigured') {
343 $nextval = $langs->trans($nextval);
345 $htmltooltip .= $nextval.
'<br>';
347 $htmltooltip .= $langs->trans($module->error).
'<br>';
351 print
'<td class="center">';
352 print $form->textwithpicto(
'', $htmltooltip, 1,
'info');
363print
"</table></div><br>\n";
375$sql .=
" FROM ".MAIN_DB_PREFIX.
"document_model";
376$sql .=
" WHERE type = '".$db->escape($type).
"'";
377$sql .=
" AND entity = ".((int) $conf->entity);
378$resql = $db->query($sql);
381 $num_rows = $db->num_rows($resql);
382 while ($i < $num_rows) {
383 $array = $db->fetch_array($resql);
384 if (is_array($array)) {
385 array_push($def, $array[0]);
394print
'<div class="div-table-responsive-no-min">';
395print
'<table class="noborder centpercent">'.
"\n";
396print
"<tr class=\"liste_titre\">\n";
397print
" <td>".$langs->trans(
"Name").
"</td>\n";
398print
" <td>".$langs->trans(
"Description").
"</td>\n";
399print
'<td align="center" width="40">'.$langs->trans(
"Status").
"</td>\n";
400print
'<td align="center" width="40">'.$langs->trans(
"Default").
"</td>\n";
401print
'<td align="center" width="40">'.$langs->trans(
"ShortInfo").
'</td>';
402print
'<td align="center" width="40">'.$langs->trans(
"Preview").
'</td>';
407foreach ($dirmodels as $reldir) {
408 foreach (array(
'',
'/doc') as $valdir) {
409 $realpath = $reldir.
"core/modules/propale".$valdir;
413 $handle = opendir($dir);
414 if (is_resource($handle)) {
416 while (($file = readdir($handle)) !==
false) {
422 foreach ($filelist as $file) {
423 if (preg_match(
'/\.modules\.php$/i', $file) && preg_match(
'/^(pdf_|doc_)/', $file)) {
424 if (file_exists($dir.
'/'.$file)) {
425 $name = substr($file, 4,
dol_strlen($file) - 16);
426 $classname = substr($file, 0,
dol_strlen($file) - 12);
428 require_once $dir.
'/'.$file;
429 $module =
new $classname($db);
431 '@phan-var-force ModelePDFPropales $module';
433 $modulequalified = 1;
434 if ($module->version ==
'development' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 2) {
435 $modulequalified = 0;
437 if ($module->version ==
'experimental' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 1) {
438 $modulequalified = 0;
441 if ($modulequalified) {
442 print
'<tr class="oddeven"><td width="100">';
443 print(empty($module->name) ? $name : $module->
name);
445 if (method_exists($module,
'info')) {
446 print $module->info($langs);
448 print $module->description;
453 if (in_array($name, $def)) {
454 print
'<td class="center">'.
"\n";
455 print
'<a class="reposition" href="'.$_SERVER[
"PHP_SELF"].
'?action=del&token='.
newToken().
'&value='.urlencode($name).
'">';
456 print
img_picto($langs->trans(
"Enabled"),
'switch_on');
460 print
"<td align=\"center\">\n";
461 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>';
466 print
"<td align=\"center\">";
468 print
img_picto($langs->trans(
"Default"),
'on');
470 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>';
475 $htmltooltip = $langs->trans(
"Name").
': '.$module->name;
476 $htmltooltip .=
'<br>'.$langs->trans(
"Type").
': '.($module->type ? $module->type : $langs->trans(
"Unknown"));
477 if ($module->type ==
'pdf') {
478 $htmltooltip .=
'<br>'.$langs->trans(
"Width").
'/'.$langs->trans(
"Height").
': '.$module->page_largeur.
'/'.$module->page_hauteur;
480 $htmltooltip .=
'<br>'.$langs->trans(
"Path").
': '.preg_replace(
'/^\//',
'', $realpath).
'/'.$file;
482 $htmltooltip .=
'<br><br><u>'.$langs->trans(
"FeaturesSupported").
':</u>';
483 $htmltooltip .=
'<br>'.$langs->trans(
"Logo").
': '.
yn($module->option_logo, 1, 1);
484 $htmltooltip .=
'<br>'.$langs->trans(
"PaymentMode").
': '.
yn($module->option_modereg, 1, 1);
485 $htmltooltip .=
'<br>'.$langs->trans(
"PaymentConditions").
': '.
yn($module->option_condreg, 1, 1);
486 $htmltooltip .=
'<br>'.$langs->trans(
"MultiLanguage").
': '.
yn($module->option_multilang, 1, 1);
489 $htmltooltip .=
'<br>'.$langs->trans(
"WatermarkOnDraftProposal").
': '.
yn($module->option_draft_watermark, 1, 1);
492 print
'<td class="center">';
493 print $form->textwithpicto(
'', $htmltooltip, 1,
'info');
497 print
'<td class="center">';
498 if ($module->type ==
'pdf') {
499 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=specimen&module='.$name.
'">'.
img_object($langs->trans(
"Preview"),
'pdf').
'</a>';
501 print
img_object($langs->transnoentitiesnoconv(
"PreviewNotAvailable"),
'generic');
524print
load_fiche_titre($langs->trans(
"SuggestedPaymentModesIfNotDefinedInProposal"),
'',
'');
526print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
527print
'<input type="hidden" name="token" value="'.newToken().
'" />';
529print
'<table class="noborder centpercent">';
531print
'<tr class="liste_titre">';
533print
'<input type="hidden" name="action" value="setribchq">';
534print $langs->trans(
"PaymentMode").
'</td>';
535print
'<td align="right">';
537 print
'<input type="submit" class="button button-edit" value="'.$langs->trans(
"Modify").
'">';
542print
'<tr class="oddeven">';
543print
"<td>".$langs->trans(
"SuggestPaymentByRIBOnAccount").
"</td>";
547 $sql =
"SELECT rowid, label";
548 $sql .=
" FROM ".MAIN_DB_PREFIX.
"bank_account";
549 $sql .=
" WHERE clos = 0";
550 $sql .=
" AND courant = 1";
551 $sql .=
" AND entity IN (".getEntity(
'bank_account').
")";
552 $resql = $db->query($sql);
554 $num = $db->num_rows($resql);
557 print
'<select name="rib" class="flat" id="rib">';
558 print
'<option value="0">'.$langs->trans(
"DoNotSuggestPaymentMode").
'</option>';
560 $row = $db->fetch_row($resql);
562 print
'<option value="'.$row[0].
'"';
564 print
'>'.$row[1].
'</option>';
570 print
"<i>".$langs->trans(
"NoActiveBankAccountDefined").
"</i>";
574 print
'<span class="opacitymedium">'.$langs->trans(
"BankModuleNotActive").
'</span>';
577 print
'<span class="opacitymedium">'.$langs->trans(
"SeeSetupOfModule", $langs->transnoentitiesnoconv(
"Module30Name")).
'</span>';
581print
'<tr class="oddeven">';
582print
"<td>".$langs->trans(
"SuggestPaymentByChequeToAddress").
"</td>";
585 print
'<select class="flat" name="chq" id="chq">';
586 print
'<option value="0">'.$langs->trans(
"DoNotSuggestPaymentMode").
'</option>';
587 print
'<option value="-1"'.(getDolGlobalString(
'FACTURE_CHQ_NUMBER') ?
' selected' :
'').
'>'.$langs->trans(
"MenuCompanySetup").
' ('.(
$mysoc->name ?
$mysoc->name : $langs->trans(
"NotDefined")).
')</option>';
589 $sql =
"SELECT rowid, label";
590 $sql .=
" FROM ".MAIN_DB_PREFIX.
"bank_account";
591 $sql .=
" WHERE clos = 0";
592 $sql .=
" AND courant = 1";
593 $sql .=
" AND entity IN (".getEntity(
'bank_account').
")";
595 $resql = $db->query($sql);
597 $num = $db->num_rows($resql);
600 $row = $db->fetch_row($resql);
602 print
'<option value="'.$row[0].
'"';
604 print
'>'.$langs->trans(
"OwnerOfBankAccount", $row[1]).
'</option>';
611 print
'<span class="opacitymedium">'.$langs->trans(
"SeeSetupOfModule", $langs->transnoentitiesnoconv(
"Module30Name")).
'</span>';
627print
'<form method="POST" action="'.dolBuildUrl($_SERVER[
"PHP_SELF"]).
'">';
628print
'<input type="hidden" name="token" value="'.newToken().
'">';
629print
'<input type="hidden" name="page_y" value="">';
630print
'<input type="hidden" name="action" value="update">';
632print
'<table class="noborder centpercent">';
633print
"<tr class=\"liste_titre\">";
634print
"<td>".$langs->trans(
"Parameter").
"</td>\n";
635print
'<td class="center"></td>'.
"\n";
638print
'<tr class="oddeven">';
639print
'<td>'.$langs->trans(
"DefaultProposalDurationValidity").
'</td>';
641print
"<input size=\"3\" class=\"flat\" type=\"text\" name=\"PROPALE_VALIDITY_DURATION\" value=\"" .
getDolGlobalString(
'PROPALE_VALIDITY_DURATION').
"\"></td>";
645$substitutionarray[
'__(AnyTranslationKey)__'] = $langs->trans(
"Translation");
646$htmltext =
'<i>'.$langs->trans(
"AvailableVariables").
':<br>';
647foreach ($substitutionarray as $key => $val) {
648 $htmltext .= $key.
'<br>';
652print
'<tr class="oddeven"><td colspan="2">';
653print $form->textwithpicto($langs->trans(
"FreeLegalTextOnProposal"), $langs->trans(
"AddCRIfTooLong").
'<br><br>'.$htmltext, 1,
'help',
'', 0, 2,
'freetexttooltip').
'<br>';
654$variablename =
'PROPOSAL_FREE_TEXT';
656 print
'<textarea name="'.$variablename.
'" class="flat" cols="120">'.
getDolGlobalString($variablename).
'</textarea>';
658 include_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
660 print $doleditor->Create();
666print
'<tr class="oddeven"><td>';
667print $form->textwithpicto($langs->trans(
"WatermarkOnDraftProposal"), $htmltext, 1,
'help',
'', 0, 2,
'watermarktooltip').
'<br>';
669print
'<input class="flat minwidth200" type="text" name="PROPALE_DRAFT_WATERMARK" value="'.dol_escape_htmltag(
getDolGlobalString(
'PROPALE_DRAFT_WATERMARK')).
'">';
675print
'<tr class="oddeven">';
676print
'<td>'.$langs->trans(
"AllowExternalDownload").
'</td>';
678print ajax_constantonoff(
'PROPOSAL_ALLOW_EXTERNAL_DOWNLOAD', array(),
null, 0, 0, 0, 2, 0, 1);
682print
'<tr class="oddeven">';
683print
'<td>'.$langs->trans(
"AllowOnLineSign").
'</td>';
685print ajax_constantonoff(
'PROPOSAL_ALLOW_ONLINESIGN', array(),
null, 0, 0, 0, 2, 0, 1,
'',
'',
'inline-block', 0, $langs->transnoentitiesnoconv(
"WarningOnlineSignature",
"https://www.dolistore.com"));
690print
'<tr class="oddeven">';
691print
'<td>'.img_picto(
'',
'email',
'class="pictofixedwidth"').$langs->trans(
"Notifications").
'</td>';
693print $langs->trans(
"YouMayFindNotificationsFeaturesIntoModuleNotification");
697print
'<tr class="oddeven">';
698print
'<td>'.img_picto(
'',
'pdf',
'class="pictofixedwidth"').$langs->trans(
"MoreOptionsRelatedToPDF").
'</td>';
700print
img_picto(
'',
'url',
'class="pictofixedwidth"').
'<a href="'.DOL_URL_ROOT.
'/admin/pdf_other.php">'.$langs->trans(
"SeeInPDFSetupPage").
'</a>';
706print
'<center><input type="submit" class="button button-edit reposition" value="'.$langs->trans(
"Modify").
'"></center>';
710print
"</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 proposals.
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, $allowothertags=array())
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, $morecssdiv='')
Show tabs of a record.
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $allowothertags=array())
Show a picto called object_picto (generic function)
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...
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
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.