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');
71include DOL_DOCUMENT_ROOT.
'/core/actions_setmoduleoptions.inc.php';
74if ($action ==
'updateMask') {
75 $maskconstpropal =
GETPOST(
'maskconstpropal',
'aZ09');
76 $maskpropal =
GETPOST(
'maskpropal',
'alpha');
80 if ($maskconstpropal && preg_match(
'/_MASK$/', $maskconstpropal)) {
93} elseif ($action ==
'specimen') {
94 $modele =
GETPOST(
'module',
'alpha');
96 $propal->initAsSpecimen();
101 $dirmodels = array_merge(array(
'/'), (array)
$conf->modules_parts[
'models']);
102 foreach ($dirmodels as $reldir) {
103 $file =
dol_buildpath($reldir.
"core/modules/propale/doc/pdf_".$modele.
".modules.php");
104 if (file_exists($file)) {
105 $classname =
"pdf_".$modele;
110 if ($classname !==
'') {
113 $module =
new $classname(
$db);
114 '@phan-var-force ModelePDFPropales $module';
117 if ($module->write_file($propal, $langs) > 0) {
118 header(
"Location: ".DOL_URL_ROOT.
"/document.php?modulepart=propal&file=SPECIMEN.pdf");
126 dol_syslog($langs->trans(
"ErrorModuleNotFound"), LOG_ERR);
128} elseif ($action ==
'setribchq') {
129 $rib =
GETPOST(
'rib',
'alpha');
130 $chq =
GETPOST(
'chq',
'alpha');
144} elseif ($action ==
'update') {
145 if (GETPOSTISSET(
'PROPALE_VALIDITY_DURATION')) {
146 $value =
GETPOST(
'PROPALE_VALIDITY_DURATION');
152 if (GETPOSTISSET(
'PROPALE_DRAFT_WATERMARK')) {
153 $draft =
GETPOST(
'PROPALE_DRAFT_WATERMARK',
'alpha');
159 if (GETPOSTISSET(
'PROPOSAL_FREE_TEXT')) {
160 $freetext =
GETPOST(
'PROPOSAL_FREE_TEXT',
'restricthtml');
166 if (GETPOSTISSET(
'PROPOSAL_ALLOW_ONLINESIGN')) {
168 if (!($result > 0)) {
172 if (GETPOSTISSET(
'PROPOSAL_ONLINE_SIGNATURE_SECURITY_TOKEN')) {
173 $result =
dolibarr_set_const(
$db,
"PROPOSAL_ONLINE_SIGNATURE_SECURITY_TOKEN",
GETPOST(
'PROPOSAL_ONLINE_SIGNATURE_SECURITY_TOKEN',
'alpha'),
'chaine', 0,
'',
$conf->entity);
174 if (!($result > 0)) {
184} elseif ($action ==
'set_BANK_ASK_PAYMENT_BANK_DURING_PROPOSAL') {
196} elseif ($action ==
'set') {
199} elseif ($action ==
'del') {
206} elseif ($action ==
'setdoc') {
208 $conf->global->PROPALE_ADDON_PDF = $value;
216} elseif ($action ==
'setmod') {
221} elseif (preg_match(
'/set_(.*)/', $action, $reg)) {
234 header(
"Location: " . $_SERVER[
"PHP_SELF"]);
237} elseif (preg_match(
'/del_(.*)/', $action, $reg)) {
249 header(
"Location: " . $_SERVER[
"PHP_SELF"]);
261$dirmodels = array_merge(array(
'/'), (array)
$conf->modules_parts[
'models']);
263llxHeader(
'', $langs->trans(
"PropalSetup"),
'',
'', 0, 0,
'',
'',
'',
'mod-admin page-propal');
267$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>';
269print
load_fiche_titre($langs->trans(
"PropalSetup"), $linkback,
'title_setup');
280print
'<div class="div-table-responsive-no-min">';
281print
'<table class="noborder centpercent">';
282print
'<tr class="liste_titre">';
283print
'<td>'.$langs->trans(
"Name").
"</td>\n";
284print
'<td>'.$langs->trans(
"Description").
"</td>\n";
285print
'<td class="nowrap">'.$langs->trans(
"Example").
"</td>\n";
286print
'<td align="center" width="60">'.$langs->trans(
"Status").
'</td>';
287print
'<td align="center" width="16">'.$langs->trans(
"ShortInfo").
'</td>';
292foreach ($dirmodels as $reldir) {
296 $handle = opendir($dir);
297 if (is_resource($handle)) {
298 while (($file = readdir($handle)) !==
false) {
299 if (substr($file, 0, 12) ==
'mod_propale_' && substr($file,
dol_strlen($file) - 3, 3) ==
'php') {
300 $file = substr($file, 0,
dol_strlen($file) - 4);
302 require_once $dir.
'/'.$file.
'.php';
304 $module =
new $file();
306 '@phan-var-force ModeleNumRefPropales $module';
309 if ($module->version ==
'development' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 2) {
312 if ($module->version ==
'experimental' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 1) {
316 if ($module->isEnabled()) {
317 print
'<tr class="oddeven"><td>'.$module->getName($langs).
"</td><td>\n";
318 print $module->info($langs);
322 print
'<td class="nowrap">';
323 $tmp = $module->getExample();
324 if (preg_match(
'/^Error/', $tmp)) {
325 $langs->load(
"errors");
326 print
'<div class="error">'.$langs->trans($tmp).
'</div>';
327 } elseif ($tmp ==
'NotConfigured') {
328 print
'<span class="opacitymedium">'.$langs->trans($tmp).
'</span>';
334 print
'<td class="center">';
336 print
img_picto($langs->trans(
"Activated"),
'switch_on');
338 print
'<a class="reposition" href="'.$_SERVER[
"PHP_SELF"].
'?action=setmod&token='.
newToken().
'&value='.urlencode($file).
'">';
339 print
img_picto($langs->trans(
"Disabled"),
'switch_off');
345 $propal->initAsSpecimen();
349 $htmltooltip .=
''.$langs->trans(
"Version").
': <b>'.$module->getVersion().
'</b><br>';
351 $nextval = $module->getNextValue(
$mysoc, $propal);
352 if ((
string) $nextval != $langs->trans(
"NotAvailable")) {
353 $htmltooltip .=
''.$langs->trans(
"NextValue").
': ';
355 if (preg_match(
'/^Error/', $nextval) || $nextval ==
'NotConfigured') {
356 $nextval = $langs->trans($nextval);
358 $htmltooltip .= $nextval.
'<br>';
360 $htmltooltip .= $langs->trans($module->error).
'<br>';
364 print
'<td class="center">';
365 print $form->textwithpicto(
'', $htmltooltip, 1,
'info');
376print
"</table></div><br>\n";
388$sql .=
" FROM ".MAIN_DB_PREFIX.
"document_model";
389$sql .=
" WHERE type = '".$db->escape($type).
"'";
390$sql .=
" AND entity = ".((int)
$conf->entity);
391$resql =
$db->query($sql);
394 $num_rows =
$db->num_rows($resql);
395 while ($i < $num_rows) {
396 $array =
$db->fetch_array($resql);
397 if (is_array($array)) {
398 array_push($def, $array[0]);
407print
'<div class="div-table-responsive-no-min">';
408print
'<table class="noborder centpercent">'.
"\n";
409print
"<tr class=\"liste_titre\">\n";
410print
" <td>".$langs->trans(
"Name").
"</td>\n";
411print
" <td>".$langs->trans(
"Description").
"</td>\n";
412print
'<td align="center" width="40">'.$langs->trans(
"Status").
"</td>\n";
413print
'<td align="center" width="40">'.$langs->trans(
"Default").
"</td>\n";
414print
'<td align="center" width="40">'.$langs->trans(
"ShortInfo").
'</td>';
415print
'<td align="center" width="40">'.$langs->trans(
"Preview").
'</td>';
420foreach ($dirmodels as $reldir) {
421 foreach (array(
'',
'/doc') as $valdir) {
422 $realpath = $reldir.
"core/modules/propale".$valdir;
426 $handle = opendir($dir);
427 if (is_resource($handle)) {
429 while (($file = readdir($handle)) !==
false) {
435 foreach ($filelist as $file) {
436 if (preg_match(
'/\.modules\.php$/i', $file) && preg_match(
'/^(pdf_|doc_)/', $file)) {
437 if (file_exists($dir.
'/'.$file)) {
438 $name = substr($file, 4,
dol_strlen($file) - 16);
439 $classname = substr($file, 0,
dol_strlen($file) - 12);
441 require_once $dir.
'/'.$file;
442 $module =
new $classname(
$db);
444 '@phan-var-force ModelePDFPropales $module';
446 $modulequalified = 1;
447 if ($module->version ==
'development' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 2) {
448 $modulequalified = 0;
450 if ($module->version ==
'experimental' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 1) {
451 $modulequalified = 0;
454 if ($modulequalified) {
455 print
'<tr class="oddeven"><td width="100">';
456 print(empty($module->name) ? $name : $module->
name);
458 if (method_exists($module,
'info')) {
459 print $module->info($langs);
461 print $module->description;
466 if (in_array($name, $def)) {
467 print
'<td class="center">'.
"\n";
468 print
'<a class="reposition" href="'.$_SERVER[
"PHP_SELF"].
'?action=del&token='.
newToken().
'&value='.urlencode($name).
'">';
469 print
img_picto($langs->trans(
"Enabled"),
'switch_on');
473 print
"<td align=\"center\">\n";
474 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>';
479 print
"<td align=\"center\">";
481 print
img_picto($langs->trans(
"Default"),
'on');
483 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>';
488 $htmltooltip = $langs->trans(
"Name").
': '.$module->name;
489 $htmltooltip .=
'<br>'.$langs->trans(
"Type").
': '.($module->type ? $module->type : $langs->trans(
"Unknown"));
490 if ($module->type ==
'pdf') {
491 $htmltooltip .=
'<br>'.$langs->trans(
"Width").
'/'.$langs->trans(
"Height").
': '.$module->page_largeur.
'/'.$module->page_hauteur;
493 $htmltooltip .=
'<br>'.$langs->trans(
"Path").
': '.preg_replace(
'/^\//',
'', $realpath).
'/'.$file;
495 $htmltooltip .=
'<br><br><u>'.$langs->trans(
"FeaturesSupported").
':</u>';
496 $htmltooltip .=
'<br>'.$langs->trans(
"Logo").
': '.
yn($module->option_logo, 1, 1);
497 $htmltooltip .=
'<br>'.$langs->trans(
"PaymentMode").
': '.
yn($module->option_modereg, 1, 1);
498 $htmltooltip .=
'<br>'.$langs->trans(
"PaymentConditions").
': '.
yn($module->option_condreg, 1, 1);
499 $htmltooltip .=
'<br>'.$langs->trans(
"MultiLanguage").
': '.
yn($module->option_multilang, 1, 1);
502 $htmltooltip .=
'<br>'.$langs->trans(
"WatermarkOnDraftProposal").
': '.
yn($module->option_draft_watermark, 1, 1);
505 print
'<td class="center">';
506 print $form->textwithpicto(
'', $htmltooltip, 1,
'info');
510 print
'<td class="center">';
511 if ($module->type ==
'pdf') {
512 print
'<a href="'.dolBuildUrl($_SERVER[
"PHP_SELF"], [
'action' =>
'specimen',
'module' => $name],
true).
'">'.
img_object($langs->trans(
"Preview"),
'pdf').
'</a>';
514 print
img_object($langs->transnoentitiesnoconv(
"PreviewNotAvailable"),
'generic');
537print
load_fiche_titre($langs->trans(
"SuggestedPaymentModesIfNotDefinedInProposal"),
'',
'');
539print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST" spellcheck="false">';
540print
'<input type="hidden" name="token" value="'.newToken().
'" />';
542print
'<table class="noborder centpercent">';
544print
'<tr class="liste_titre">';
546print
'<input type="hidden" name="action" value="setribchq">';
547print $langs->trans(
"PaymentMode").
'</td>';
548print
'<td align="right">';
550 print
'<input type="submit" class="button button-edit" value="'.$langs->trans(
"Modify").
'">';
555print
'<tr class="oddeven">';
556print
"<td>".$langs->trans(
"SuggestPaymentByRIBOnAccount").
"</td>";
560 $sql =
"SELECT rowid, label";
561 $sql .=
" FROM ".MAIN_DB_PREFIX.
"bank_account";
562 $sql .=
" WHERE clos = 0";
563 $sql .=
" AND courant = 1";
564 $sql .=
" AND entity IN (".getEntity(
'bank_account').
")";
565 $resql =
$db->query($sql);
567 $num =
$db->num_rows($resql);
570 print
'<select name="rib" class="flat" id="rib">';
571 print
'<option value="0">'.$langs->trans(
"DoNotSuggestPaymentMode").
'</option>';
573 $row =
$db->fetch_row($resql);
575 print
'<option value="'.$row[0].
'"';
577 print
'>'.$row[1].
'</option>';
583 print
"<i>".$langs->trans(
"NoActiveBankAccountDefined").
"</i>";
587 print
'<span class="opacitymedium">'.$langs->trans(
"BankModuleNotActive").
'</span>';
590 print
'<span class="opacitymedium">'.$langs->trans(
"SeeSetupOfModule", $langs->transnoentitiesnoconv(
"Module30Name")).
'</span>';
594print
'<tr class="oddeven">';
595print
"<td>".$langs->trans(
"SuggestPaymentByChequeToAddress").
"</td>";
598 print
'<select class="flat" name="chq" id="chq">';
599 print
'<option value="0">'.$langs->trans(
"DoNotSuggestPaymentMode").
'</option>';
600 print
'<option value="-1"'.(getDolGlobalString(
'FACTURE_CHQ_NUMBER') ?
' selected' :
'').
'>'.$langs->trans(
"MenuCompanySetup").
' ('.(
$mysoc->name ?
$mysoc->name : $langs->trans(
"NotDefined")).
')</option>';
602 $sql =
"SELECT rowid, label";
603 $sql .=
" FROM ".MAIN_DB_PREFIX.
"bank_account";
604 $sql .=
" WHERE clos = 0";
605 $sql .=
" AND courant = 1";
606 $sql .=
" AND entity IN (".getEntity(
'bank_account').
")";
608 $resql =
$db->query($sql);
610 $num =
$db->num_rows($resql);
613 $row =
$db->fetch_row($resql);
615 print
'<option value="'.$row[0].
'"';
617 print
'>'.$langs->trans(
"OwnerOfBankAccount", $row[1]).
'</option>';
624 print
'<span class="opacitymedium">'.$langs->trans(
"SeeSetupOfModule", $langs->transnoentitiesnoconv(
"Module30Name")).
'</span>';
640print
'<form method="POST" action="'.dolBuildUrl($_SERVER[
"PHP_SELF"]).
'" spellcheck="false">';
641print
'<input type="hidden" name="token" value="'.newToken().
'">';
642print
'<input type="hidden" name="page_y" value="">';
643print
'<input type="hidden" name="action" value="update">';
645print
'<table class="noborder centpercent">';
646print
"<tr class=\"liste_titre\">";
647print
"<td>".$langs->trans(
"Parameter").
"</td>\n";
648print
'<td class="center"></td>'.
"\n";
651print
'<tr class="oddeven">';
652print
'<td>'.$langs->trans(
"DefaultProposalDurationValidity").
'</td>';
654print
"<input size=\"3\" class=\"flat\" type=\"text\" name=\"PROPALE_VALIDITY_DURATION\" value=\"" .
getDolGlobalString(
'PROPALE_VALIDITY_DURATION').
"\"></td>";
658$substitutionarray[
'__(AnyTranslationKey)__'] = $langs->trans(
"Translation");
659$htmltext =
'<i>'.$langs->trans(
"AvailableVariables").
':<br>';
660foreach ($substitutionarray as $key => $val) {
661 $htmltext .= $key.
'<br>';
665print
'<tr class="oddeven"><td colspan="2">';
666print $form->textwithpicto($langs->trans(
"FreeLegalTextOnProposal"), $langs->trans(
"AddCRIfTooLong").
'<br><br>'.$htmltext, 1,
'help',
'', 0, 2,
'freetexttooltip').
'<br>';
667$variablename =
'PROPOSAL_FREE_TEXT';
669 print
'<textarea name="'.$variablename.
'" class="flat" cols="120">'.
getDolGlobalString($variablename).
'</textarea>';
671 include_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
673 print $doleditor->Create();
679print
'<tr class="oddeven"><td>';
680print $form->textwithpicto($langs->trans(
"WatermarkOnDraftProposal"), $htmltext, 1,
'help',
'', 0, 2,
'watermarktooltip').
'<br>';
682print
'<input class="flat minwidth200" type="text" name="PROPALE_DRAFT_WATERMARK" value="'.dol_escape_htmltag(
getDolGlobalString(
'PROPALE_DRAFT_WATERMARK')).
'">';
688print
'<tr class="oddeven">';
689print
'<td>'.$langs->trans(
"AllowExternalDownload").
'</td>';
691print ajax_constantonoff(
'PROPOSAL_ALLOW_EXTERNAL_DOWNLOAD', array(),
null, 0, 0, 0, 2, 0, 1);
695print
'<tr class="oddeven">';
696print
'<td>'.$langs->trans(
"AllowOnLineSign").
'</td>';
698print ajax_constantonoff(
'PROPOSAL_ALLOW_ONLINESIGN', array(),
null, 0, 0, 1, 2, 0, 1,
'',
'',
'inline-block', 0, $langs->transnoentitiesnoconv(
"WarningOnlineSignature",
"https://www.dolistore.com"));
714print
'<tr class="oddeven">';
715print
'<td>'.img_picto(
'',
'email',
'class="pictofixedwidth"').$langs->trans(
"Notifications").
'</td>';
717print $langs->trans(
"YouMayFindNotificationsFeaturesIntoModuleNotification");
721print
'<tr class="oddeven">';
722print
'<td>'.img_picto(
'',
'pdf',
'class="pictofixedwidth"').$langs->trans(
"MoreOptionsRelatedToPDF").
'</td>';
724print
img_picto(
'',
'url',
'class="pictofixedwidth"').
'<a href="'.DOL_URL_ROOT.
'/admin/pdf_other.php">'.$langs->trans(
"SeeInPDFSetupPage").
'</a>';
730print
'<center><input type="submit" class="button button-edit reposition" value="'.$langs->trans(
"Modify").
'"></center>';
734print
"</table>\n<br>";
736$constname =
'PROPOSAL_ONLINE_SIGNATURE_SECURITY_TOKEN';
739include_once DOL_DOCUMENT_ROOT.
'/core/lib/security2.lib.php';
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.
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, $nodefault=0)
Return value of a param into GET or POST supervariable.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
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.
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)
yn($yesno, $format=1, $color=0)
Return yes or no in current language.
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.
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.
dolJSToSetRandomPassword($htmlname, $htmlnameofbutton='generate_token', $generic=1)
Output javascript to autoset a generated password using default module into a HTML element.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.