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';
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');
68include DOL_DOCUMENT_ROOT.
'/core/actions_setmoduleoptions.inc.php';
71if ($action ==
'updateMask') {
72 $maskconstpropal =
GETPOST(
'maskconstpropal',
'aZ09');
73 $maskpropal =
GETPOST(
'maskpropal',
'alpha');
77 if ($maskconstpropal && preg_match(
'/_MASK$/', $maskconstpropal)) {
90} elseif ($action ==
'specimen') {
91 $modele =
GETPOST(
'module',
'alpha');
94 $propal->initAsSpecimen();
99 $dirmodels = array_merge(array(
'/'), (array)
$conf->modules_parts[
'models']);
100 foreach ($dirmodels as $reldir) {
101 $file =
dol_buildpath($reldir.
"core/modules/propale/doc/pdf_".$modele.
".modules.php");
102 if (file_exists($file)) {
103 $classname =
"pdf_".$modele;
108 if ($classname !==
'') {
111 $module =
new $classname($db);
112 '@phan-var-force ModelePDFPropales $module';
115 if ($module->write_file($propal, $langs) > 0) {
116 header(
"Location: ".DOL_URL_ROOT.
"/document.php?modulepart=propal&file=SPECIMEN.pdf");
124 dol_syslog($langs->trans(
"ErrorModuleNotFound"), LOG_ERR);
126} elseif ($action ==
'setribchq') {
127 $rib =
GETPOST(
'rib',
'alpha');
128 $chq =
GETPOST(
'chq',
'alpha');
142} elseif ($action ==
'update') {
143 if (GETPOSTISSET(
'PROPALE_VALIDITY_DURATION')) {
144 $value =
GETPOST(
'PROPALE_VALIDITY_DURATION');
150 if (GETPOSTISSET(
'PROPALE_DRAFT_WATERMARK')) {
151 $draft =
GETPOST(
'PROPALE_DRAFT_WATERMARK',
'alpha');
157 if (GETPOSTISSET(
'PROPOSAL_FREE_TEXT')) {
158 $freetext =
GETPOST(
'PROPOSAL_FREE_TEXT',
'restricthtml');
170} elseif ($action ==
'set_BANK_ASK_PAYMENT_BANK_DURING_PROPOSAL') {
171 $res =
dolibarr_set_const($db,
"BANK_ASK_PAYMENT_BANK_DURING_PROPOSAL", $value,
'chaine', 0,
'',
$conf->entity);
182} elseif ($action ==
'set') {
185} elseif ($action ==
'del') {
188 if (
$conf->global->PROPALE_ADDON_PDF ==
"$value") {
192} elseif ($action ==
'setdoc') {
194 $conf->global->PROPALE_ADDON_PDF = $value;
202} elseif ($action ==
'setmod') {
207} elseif (preg_match(
'/set_(.*)/', $action, $reg)) {
220 header(
"Location: " . $_SERVER[
"PHP_SELF"]);
223} elseif (preg_match(
'/del_(.*)/', $action, $reg)) {
235 header(
"Location: " . $_SERVER[
"PHP_SELF"]);
245$form =
new Form($db);
247$dirmodels = array_merge(array(
'/'), (array)
$conf->modules_parts[
'models']);
249llxHeader(
'', $langs->trans(
"PropalSetup"),
'',
'', 0, 0,
'',
'',
'',
'mod-admin page-propal');
253$linkback =
'<a href="'.DOL_URL_ROOT.
'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToModuleList").
'</a>';
254print
load_fiche_titre($langs->trans(
"PropalSetup"), $linkback,
'title_setup');
265print
'<table class="noborder centpercent">';
266print
'<tr class="liste_titre">';
267print
'<td>'.$langs->trans(
"Name").
"</td>\n";
268print
'<td>'.$langs->trans(
"Description").
"</td>\n";
269print
'<td class="nowrap">'.$langs->trans(
"Example").
"</td>\n";
270print
'<td align="center" width="60">'.$langs->trans(
"Status").
'</td>';
271print
'<td align="center" width="16">'.$langs->trans(
"ShortInfo").
'</td>';
276foreach ($dirmodels as $reldir) {
280 $handle = opendir($dir);
281 if (is_resource($handle)) {
282 while (($file = readdir($handle)) !==
false) {
283 if (substr($file, 0, 12) ==
'mod_propale_' && substr($file,
dol_strlen($file) - 3, 3) ==
'php') {
284 $file = substr($file, 0,
dol_strlen($file) - 4);
286 require_once $dir.
'/'.$file.
'.php';
288 $module =
new $file();
290 '@phan-var-force ModeleNumRefPropales $module';
293 if ($module->version ==
'development' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 2) {
296 if ($module->version ==
'experimental' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 1) {
300 if ($module->isEnabled()) {
301 print
'<tr class="oddeven"><td>'.$module->getName($langs).
"</td><td>\n";
302 print $module->info($langs);
306 print
'<td class="nowrap">';
307 $tmp = $module->getExample();
308 if (preg_match(
'/^Error/', $tmp)) {
309 $langs->load(
"errors");
310 print
'<div class="error">'.$langs->trans($tmp).
'</div>';
311 } elseif ($tmp ==
'NotConfigured') {
312 print
'<span class="opacitymedium">'.$langs->trans($tmp).
'</span>';
318 print
'<td class="center">';
319 if (
$conf->global->PROPALE_ADDON ==
"$file") {
320 print
img_picto($langs->trans(
"Activated"),
'switch_on');
322 print
'<a class="reposition" href="'.$_SERVER[
"PHP_SELF"].
'?action=setmod&token='.
newToken().
'&value='.urlencode($file).
'">';
323 print
img_picto($langs->trans(
"Disabled"),
'switch_off');
328 $propal =
new Propal($db);
329 $propal->initAsSpecimen();
333 $htmltooltip .=
''.$langs->trans(
"Version").
': <b>'.$module->getVersion().
'</b><br>';
335 $nextval = $module->getNextValue($mysoc, $propal);
336 if (
"$nextval" != $langs->trans(
"NotAvailable")) {
337 $htmltooltip .=
''.$langs->trans(
"NextValue").
': ';
339 if (preg_match(
'/^Error/', $nextval) || $nextval ==
'NotConfigured') {
340 $nextval = $langs->trans($nextval);
342 $htmltooltip .= $nextval.
'<br>';
344 $htmltooltip .= $langs->trans($module->error).
'<br>';
348 print
'<td class="center">';
349 print $form->textwithpicto(
'', $htmltooltip, 1, 0);
360print
"</table><br>\n";
372$sql .=
" FROM ".MAIN_DB_PREFIX.
"document_model";
373$sql .=
" WHERE type = '".$db->escape($type).
"'";
374$sql .=
" AND entity = ".$conf->entity;
375$resql = $db->query($sql);
378 $num_rows = $db->num_rows($resql);
379 while ($i < $num_rows) {
380 $array = $db->fetch_array($resql);
381 if (is_array($array)) {
382 array_push($def, $array[0]);
391print
"<table class=\"noborder\" width=\"100%\">\n";
392print
"<tr class=\"liste_titre\">\n";
393print
" <td>".$langs->trans(
"Name").
"</td>\n";
394print
" <td>".$langs->trans(
"Description").
"</td>\n";
395print
'<td align="center" width="40">'.$langs->trans(
"Status").
"</td>\n";
396print
'<td align="center" width="40">'.$langs->trans(
"Default").
"</td>\n";
397print
'<td align="center" width="40">'.$langs->trans(
"ShortInfo").
'</td>';
398print
'<td align="center" width="40">'.$langs->trans(
"Preview").
'</td>';
403foreach ($dirmodels as $reldir) {
404 foreach (array(
'',
'/doc') as $valdir) {
405 $realpath = $reldir.
"core/modules/propale".$valdir;
409 $handle = opendir($dir);
410 if (is_resource($handle)) {
412 while (($file = readdir($handle)) !==
false) {
418 foreach ($filelist as $file) {
419 if (preg_match(
'/\.modules\.php$/i', $file) && preg_match(
'/^(pdf_|doc_)/', $file)) {
420 if (file_exists($dir.
'/'.$file)) {
421 $name = substr($file, 4,
dol_strlen($file) - 16);
422 $classname = substr($file, 0,
dol_strlen($file) - 12);
424 require_once $dir.
'/'.$file;
425 $module =
new $classname($db);
427 '@phan-var-force ModelePDFPropales $module';
429 $modulequalified = 1;
430 if ($module->version ==
'development' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 2) {
431 $modulequalified = 0;
433 if ($module->version ==
'experimental' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 1) {
434 $modulequalified = 0;
437 if ($modulequalified) {
438 print
'<tr class="oddeven"><td width="100">';
439 print(empty($module->name) ? $name : $module->
name);
441 if (method_exists($module,
'info')) {
442 print $module->info($langs);
444 print $module->description;
449 if (in_array($name, $def)) {
450 print
'<td class="center">'.
"\n";
451 print
'<a class="reposition" href="'.$_SERVER[
"PHP_SELF"].
'?action=del&token='.
newToken().
'&value='.urlencode($name).
'">';
452 print
img_picto($langs->trans(
"Enabled"),
'switch_on');
456 print
"<td align=\"center\">\n";
457 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>';
462 print
"<td align=\"center\">";
463 if (
$conf->global->PROPALE_ADDON_PDF ==
"$name") {
464 print
img_picto($langs->trans(
"Default"),
'on');
466 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>';
471 $htmltooltip = $langs->trans(
"Name").
': '.$module->name;
472 $htmltooltip .=
'<br>'.$langs->trans(
"Type").
': '.($module->type ? $module->type : $langs->trans(
"Unknown"));
473 if ($module->type ==
'pdf') {
474 $htmltooltip .=
'<br>'.$langs->trans(
"Width").
'/'.$langs->trans(
"Height").
': '.$module->page_largeur.
'/'.$module->page_hauteur;
476 $htmltooltip .=
'<br>'.$langs->trans(
"Path").
': '.preg_replace(
'/^\//',
'', $realpath).
'/'.$file;
478 $htmltooltip .=
'<br><br><u>'.$langs->trans(
"FeaturesSupported").
':</u>';
479 $htmltooltip .=
'<br>'.$langs->trans(
"Logo").
': '.
yn($module->option_logo, 1, 1);
480 $htmltooltip .=
'<br>'.$langs->trans(
"PaymentMode").
': '.
yn($module->option_modereg, 1, 1);
481 $htmltooltip .=
'<br>'.$langs->trans(
"PaymentConditions").
': '.
yn($module->option_condreg, 1, 1);
482 $htmltooltip .=
'<br>'.$langs->trans(
"MultiLanguage").
': '.
yn($module->option_multilang, 1, 1);
485 $htmltooltip .=
'<br>'.$langs->trans(
"WatermarkOnDraftProposal").
': '.
yn($module->option_draft_watermark, 1, 1);
488 print
'<td class="center">';
489 print $form->textwithpicto(
'', $htmltooltip, 1, 0);
493 print
'<td class="center">';
494 if ($module->type ==
'pdf') {
495 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=specimen&module='.$name.
'">'.
img_object($langs->trans(
"Preview"),
'pdf').
'</a>';
497 print
img_object($langs->trans(
"PreviewNotAvailable"),
'generic');
519print
load_fiche_titre($langs->trans(
"SuggestedPaymentModesIfNotDefinedInProposal"),
'',
'');
521print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
522print
'<input type="hidden" name="token" value="'.newToken().
'" />';
524print
'<table class="noborder centpercent">';
526print
'<tr class="liste_titre">';
528print
'<input type="hidden" name="action" value="setribchq">';
529print $langs->trans(
"PaymentMode").
'</td>';
530print
'<td align="right">';
531if (!isModEnabled(
'invoice')) {
532 print
'<input type="submit" class="button button-edit" value="'.$langs->trans(
"Modify").
'">';
537print
'<tr class="oddeven">';
538print
"<td>".$langs->trans(
"SuggestPaymentByRIBOnAccount").
"</td>";
540if (!isModEnabled(
'invoice')) {
541 if (isModEnabled(
"bank")) {
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 $resql = $db->query($sql);
549 $num = $db->num_rows($resql);
552 print
'<select name="rib" class="flat" id="rib">';
553 print
'<option value="0">'.$langs->trans(
"DoNotSuggestPaymentMode").
'</option>';
555 $row = $db->fetch_row($resql);
557 print
'<option value="'.$row[0].
'"';
558 print
$conf->global->FACTURE_RIB_NUMBER == $row[0] ?
' selected' :
'';
559 print
'>'.$row[1].
'</option>';
565 print
"<i>".$langs->trans(
"NoActiveBankAccountDefined").
"</i>";
569 print
'<span class="opacitymedium">'.$langs->trans(
"BankModuleNotActive").
'</span>';
572 print
'<span class="opacitymedium">'.$langs->trans(
"SeeSetupOfModule", $langs->transnoentitiesnoconv(
"Module30Name")).
'</span>';
576print
'<tr class="oddeven">';
577print
"<td>".$langs->trans(
"SuggestPaymentByChequeToAddress").
"</td>";
579if (!isModEnabled(
'invoice')) {
580 print
'<select class="flat" name="chq" id="chq">';
581 print
'<option value="0">'.$langs->trans(
"DoNotSuggestPaymentMode").
'</option>';
582 print
'<option value="-1"'.($conf->global->FACTURE_CHQ_NUMBER ?
' selected' :
'').
'>'.$langs->trans(
"MenuCompanySetup").
' ('.($mysoc->name ? $mysoc->name : $langs->trans(
"NotDefined")).
')</option>';
584 $sql =
"SELECT rowid, label";
585 $sql .=
" FROM ".MAIN_DB_PREFIX.
"bank_account";
586 $sql .=
" WHERE clos = 0";
587 $sql .=
" AND courant = 1";
588 $sql .=
" AND entity IN (".getEntity(
'bank_account').
")";
590 $resql = $db->query($sql);
592 $num = $db->num_rows($resql);
595 $row = $db->fetch_row($resql);
597 print
'<option value="'.$row[0].
'"';
598 print
$conf->global->FACTURE_CHQ_NUMBER == $row[0] ?
' selected' :
'';
599 print
'>'.$langs->trans(
"OwnerOfBankAccount", $row[1]).
'</option>';
606 print
'<span class="opacitymedium">'.$langs->trans(
"SeeSetupOfModule", $langs->transnoentitiesnoconv(
"Module30Name")).
'</span>';
622print
'<form method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
623print
'<input type="hidden" name="token" value="'.newToken().
'">';
624print
'<input type="hidden" name="page_y" value="">';
625print
'<input type="hidden" name="action" value="update">';
627print
'<table class="noborder centpercent">';
628print
"<tr class=\"liste_titre\">";
629print
"<td>".$langs->trans(
"Parameter").
"</td>\n";
630print
'<td width="60" align="center">'.$langs->trans(
"Value").
"</td>\n";
633print
'<tr class="oddeven">';
634print
'<td>'.$langs->trans(
"DefaultProposalDurationValidity").
'</td>';
635print
'<td width="60" align="center">';
636print
"<input size=\"3\" class=\"flat\" type=\"text\" name=\"PROPALE_VALIDITY_DURATION\" value=\"" .
getDolGlobalString(
'PROPALE_VALIDITY_DURATION').
"\"></td>";
640$substitutionarray[
'__(AnyTranslationKey)__'] = $langs->trans(
"Translation");
641$htmltext =
'<i>'.$langs->trans(
"AvailableVariables").
':<br>';
642foreach ($substitutionarray as $key => $val) {
643 $htmltext .= $key.
'<br>';
647print
'<tr class="oddeven"><td colspan="2">';
648print $form->textwithpicto($langs->trans(
"FreeLegalTextOnProposal"), $langs->trans(
"AddCRIfTooLong").
'<br><br>'.$htmltext, 1,
'help',
'', 0, 2,
'freetexttooltip').
'<br>';
649$variablename =
'PROPOSAL_FREE_TEXT';
651 print
'<textarea name="'.$variablename.
'" class="flat" cols="120">'.
getDolGlobalString($variablename).
'</textarea>';
653 include_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
655 print $doleditor->Create();
661print
'<tr class="oddeven"><td>';
662print $form->textwithpicto($langs->trans(
"WatermarkOnDraftProposal"), $htmltext, 1,
'help',
'', 0, 2,
'watermarktooltip').
'<br>';
664print
'<input class="flat minwidth200" type="text" name="PROPALE_DRAFT_WATERMARK" value="'.dol_escape_htmltag(
getDolGlobalString(
'PROPALE_DRAFT_WATERMARK')).
'">';
670print
'<tr class="oddeven">';
671print
'<td>'.$langs->trans(
"AllowExternalDownload").
'</td>';
672print
'<td class="center">';
673print ajax_constantonoff(
'PROPOSAL_ALLOW_EXTERNAL_DOWNLOAD', array(),
null, 0, 0, 0, 2, 0, 1);
677print
'<tr class="oddeven">';
678print
'<td>'.$langs->trans(
"AllowOnLineSign").
'</td>';
679print
'<td class="center">';
680print ajax_constantonoff(
'PROPOSAL_ALLOW_ONLINESIGN', array(),
null, 0, 0, 0, 2, 0, 1,
'',
'',
'inline-block', 0, $langs->trans(
"WarningOnlineSignature"));
717print
'<center><input type="submit" class="button button-edit reposition" value="'.$langs->trans(
"Modify").
'"></center>';
721print
"</table>\n<br>";
731print
'<table class="noborder centpercent">';
733print
"<tr class=\"oddeven trfirstline\">\n <td>".$langs->trans(
"PathToDocuments").
"</td>\n <td>".
$conf->propal->multidir_output[
$conf->entity].
"</td>\n</tr>\n";
735print
'<tr class="oddeven lastline"><td>';
736print $langs->trans(
"YouMayFindNotificationsFeaturesIntoModuleNotification").
'<br>';
737print
'</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($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.
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)
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)
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)
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'.
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...
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
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.