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();
86 $dirmodels = array_merge(array(
'/'), (array) $conf->modules_parts[
'models']);
87 foreach ($dirmodels as $reldir) {
88 $file =
dol_buildpath($reldir.
"core/modules/propale/doc/pdf_".$modele.
".modules.php");
89 if (file_exists($file)) {
91 $classname =
"pdf_".$modele;
99 $module =
new $classname($db);
101 if ($module->write_file($propal, $langs) > 0) {
102 header(
"Location: ".DOL_URL_ROOT.
"/document.php?modulepart=propal&file=SPECIMEN.pdf");
110 dol_syslog($langs->trans(
"ErrorModuleNotFound"), LOG_ERR);
112} elseif ($action ==
'setribchq') {
113 $rib =
GETPOST(
'rib',
'alpha');
114 $chq =
GETPOST(
'chq',
'alpha');
116 $res =
dolibarr_set_const($db,
"FACTURE_RIB_NUMBER", $rib,
'chaine', 0,
'', $conf->entity);
117 $res =
dolibarr_set_const($db,
"FACTURE_CHQ_NUMBER", $chq,
'chaine', 0,
'', $conf->entity);
128} elseif ($action ==
'update') {
129 if (GETPOSTISSET(
'PROPALE_VALIDITY_DURATION')) {
130 $value =
GETPOST(
'PROPALE_VALIDITY_DURATION');
131 $res =
dolibarr_set_const($db,
"PROPALE_VALIDITY_DURATION", $value,
'chaine', 0,
'', $conf->entity);
136 if (GETPOSTISSET(
'PROPALE_DRAFT_WATERMARK')) {
137 $draft =
GETPOST(
'PROPALE_DRAFT_WATERMARK',
'alpha');
138 $res =
dolibarr_set_const($db,
"PROPALE_DRAFT_WATERMARK", trim($draft),
'chaine', 0,
'', $conf->entity);
143 if (GETPOSTISSET(
'PROPOSAL_FREE_TEXT')) {
144 $freetext =
GETPOST(
'PROPOSAL_FREE_TEXT',
'restricthtml');
145 $res =
dolibarr_set_const($db,
"PROPOSAL_FREE_TEXT", $freetext,
'chaine', 0,
'', $conf->entity);
156} elseif ($action ==
'set_BANK_ASK_PAYMENT_BANK_DURING_PROPOSAL') {
157 $res =
dolibarr_set_const($db,
"BANK_ASK_PAYMENT_BANK_DURING_PROPOSAL", $value,
'chaine', 0,
'', $conf->entity);
168} elseif ($action ==
'set') {
171} elseif ($action ==
'del') {
174 if ($conf->global->PROPALE_ADDON_PDF ==
"$value") {
178} elseif ($action ==
'setdoc') {
179 if (
dolibarr_set_const($db,
"PROPALE_ADDON_PDF", $value,
'chaine', 0,
'', $conf->entity)) {
180 $conf->global->PROPALE_ADDON_PDF = $value;
188} elseif ($action ==
'setmod') {
193} elseif (preg_match(
'/set_(.*)/', $action, $reg)) {
206 header(
"Location: " . $_SERVER[
"PHP_SELF"]);
209} elseif (preg_match(
'/del_(.*)/', $action, $reg)) {
221 header(
"Location: " . $_SERVER[
"PHP_SELF"]);
231$form =
new Form($db);
233$dirmodels = array_merge(array(
'/'), (array) $conf->modules_parts[
'models']);
235llxHeader(
'', $langs->trans(
"PropalSetup"));
239$linkback =
'<a href="'.DOL_URL_ROOT.
'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToModuleList").
'</a>';
240print
load_fiche_titre($langs->trans(
"PropalSetup"), $linkback,
'title_setup');
251print
'<table class="noborder centpercent">';
252print
'<tr class="liste_titre">';
253print
'<td>'.$langs->trans(
"Name").
"</td>\n";
254print
'<td>'.$langs->trans(
"Description").
"</td>\n";
255print
'<td class="nowrap">'.$langs->trans(
"Example").
"</td>\n";
256print
'<td align="center" width="60">'.$langs->trans(
"Status").
'</td>';
257print
'<td align="center" width="16">'.$langs->trans(
"ShortInfo").
'</td>';
262foreach ($dirmodels as $reldir) {
266 $handle = opendir($dir);
267 if (is_resource($handle)) {
268 while (($file = readdir($handle)) !==
false) {
269 if (substr($file, 0, 12) ==
'mod_propale_' && substr($file,
dol_strlen($file) - 3, 3) ==
'php') {
270 $file = substr($file, 0,
dol_strlen($file) - 4);
272 require_once $dir.
'/'.$file.
'.php';
274 $module =
new $file();
277 if ($module->version ==
'development' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 2) {
280 if ($module->version ==
'experimental' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 1) {
284 if ($module->isEnabled()) {
285 print
'<tr class="oddeven"><td>'.$module->nom.
"</td><td>\n";
286 print $module->info($langs);
290 print
'<td class="nowrap">';
291 $tmp = $module->getExample();
292 if (preg_match(
'/^Error/', $tmp)) {
293 $langs->load(
"errors");
294 print
'<div class="error">'.$langs->trans($tmp).
'</div>';
295 } elseif ($tmp ==
'NotConfigured') {
296 print
'<span class="opacitymedium">'.$langs->trans($tmp).
'</span>';
302 print
'<td class="center">';
303 if ($conf->global->PROPALE_ADDON ==
"$file") {
304 print
img_picto($langs->trans(
"Activated"),
'switch_on');
306 print
'<a class="reposition" href="'.$_SERVER[
"PHP_SELF"].
'?action=setmod&token='.newToken().
'&value='.urlencode($file).
'">';
307 print
img_picto($langs->trans(
"Disabled"),
'switch_off');
312 $propal =
new Propal($db);
313 $propal->initAsSpecimen();
317 $htmltooltip .=
''.$langs->trans(
"Version").
': <b>'.$module->getVersion().
'</b><br>';
319 $nextval = $module->getNextValue($mysoc, $propal);
320 if (
"$nextval" != $langs->trans(
"NotAvailable")) {
321 $htmltooltip .=
''.$langs->trans(
"NextValue").
': ';
323 if (preg_match(
'/^Error/', $nextval) || $nextval ==
'NotConfigured') {
324 $nextval = $langs->trans($nextval);
326 $htmltooltip .= $nextval.
'<br>';
328 $htmltooltip .= $langs->trans($module->error).
'<br>';
332 print
'<td class="center">';
333 print $form->textwithpicto(
'', $htmltooltip, 1, 0);
344print
"</table><br>\n";
356$sql .=
" FROM ".MAIN_DB_PREFIX.
"document_model";
357$sql .=
" WHERE type = '".$db->escape($type).
"'";
358$sql .=
" AND entity = ".$conf->entity;
359$resql = $db->query($sql);
362 $num_rows = $db->num_rows($resql);
363 while ($i < $num_rows) {
364 $array = $db->fetch_array($resql);
365 array_push($def, $array[0]);
373print
"<table class=\"noborder\" width=\"100%\">\n";
374print
"<tr class=\"liste_titre\">\n";
375print
" <td>".$langs->trans(
"Name").
"</td>\n";
376print
" <td>".$langs->trans(
"Description").
"</td>\n";
377print
'<td align="center" width="40">'.$langs->trans(
"Status").
"</td>\n";
378print
'<td align="center" width="40">'.$langs->trans(
"Default").
"</td>\n";
379print
'<td align="center" width="40">'.$langs->trans(
"ShortInfo").
'</td>';
380print
'<td align="center" width="40">'.$langs->trans(
"Preview").
'</td>';
385foreach ($dirmodels as $reldir) {
386 foreach (array(
'',
'/doc') as $valdir) {
387 $realpath = $reldir.
"core/modules/propale".$valdir;
391 $handle = opendir($dir);
392 if (is_resource($handle)) {
393 while (($file = readdir($handle)) !==
false) {
399 foreach ($filelist as $file) {
400 if (preg_match(
'/\.modules\.php$/i', $file) && preg_match(
'/^(pdf_|doc_)/', $file)) {
401 if (file_exists($dir.
'/'.$file)) {
402 $name = substr($file, 4,
dol_strlen($file) - 16);
403 $classname = substr($file, 0,
dol_strlen($file) - 12);
405 require_once $dir.
'/'.$file;
406 $module =
new $classname($db);
408 $modulequalified = 1;
409 if ($module->version ==
'development' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 2) {
410 $modulequalified = 0;
412 if ($module->version ==
'experimental' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 1) {
413 $modulequalified = 0;
416 if ($modulequalified) {
417 print
'<tr class="oddeven"><td width="100">';
418 print(empty($module->name) ? $name : $module->
name);
420 if (method_exists($module,
'info')) {
421 print $module->info($langs);
423 print $module->description;
428 if (in_array($name, $def)) {
429 print
'<td class="center">'.
"\n";
430 print
'<a class="reposition" href="'.$_SERVER[
"PHP_SELF"].
'?action=del&token='.newToken().
'&value='.urlencode($name).
'">';
431 print
img_picto($langs->trans(
"Enabled"),
'switch_on');
435 print
"<td align=\"center\">\n";
436 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>';
441 print
"<td align=\"center\">";
442 if ($conf->global->PROPALE_ADDON_PDF ==
"$name") {
443 print
img_picto($langs->trans(
"Default"),
'on');
445 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>';
450 $htmltooltip = $langs->trans(
"Name").
': '.$module->name;
451 $htmltooltip .=
'<br>'.$langs->trans(
"Type").
': '.($module->type ? $module->type : $langs->trans(
"Unknown"));
452 if ($module->type ==
'pdf') {
453 $htmltooltip .=
'<br>'.$langs->trans(
"Width").
'/'.$langs->trans(
"Height").
': '.$module->page_largeur.
'/'.$module->page_hauteur;
455 $htmltooltip .=
'<br>'.$langs->trans(
"Path").
': '.preg_replace(
'/^\//',
'', $realpath).
'/'.$file;
457 $htmltooltip .=
'<br><br><u>'.$langs->trans(
"FeaturesSupported").
':</u>';
458 $htmltooltip .=
'<br>'.$langs->trans(
"Logo").
': '.
yn($module->option_logo, 1, 1);
459 $htmltooltip .=
'<br>'.$langs->trans(
"PaymentMode").
': '.
yn($module->option_modereg, 1, 1);
460 $htmltooltip .=
'<br>'.$langs->trans(
"PaymentConditions").
': '.
yn($module->option_condreg, 1, 1);
461 $htmltooltip .=
'<br>'.$langs->trans(
"MultiLanguage").
': '.
yn($module->option_multilang, 1, 1);
464 $htmltooltip .=
'<br>'.$langs->trans(
"WatermarkOnDraftProposal").
': '.
yn($module->option_draft_watermark, 1, 1);
467 print
'<td class="center">';
468 print $form->textwithpicto(
'', $htmltooltip, 1, 0);
472 print
'<td class="center">';
473 if ($module->type ==
'pdf') {
474 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=specimen&module='.$name.
'">'.
img_object($langs->trans(
"Preview"),
'pdf').
'</a>';
476 print
img_object($langs->trans(
"PreviewNotAvailable"),
'generic');
498print
load_fiche_titre($langs->trans(
"SuggestedPaymentModesIfNotDefinedInProposal"),
'',
'');
500print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
501print
'<input type="hidden" name="token" value="'.newToken().
'" />';
503print
'<table class="noborder centpercent">';
505print
'<tr class="liste_titre">';
507print
'<input type="hidden" name="action" value="setribchq">';
508print $langs->trans(
"PaymentMode").
'</td>';
509print
'<td align="right">';
510if (!isModEnabled(
'facture')) {
511 print
'<input type="submit" class="button button-edit" value="'.$langs->trans(
"Modify").
'">';
516print
'<tr class="oddeven">';
517print
"<td>".$langs->trans(
"SuggestPaymentByRIBOnAccount").
"</td>";
519if (!isModEnabled(
'facture')) {
520 if (isModEnabled(
"banque")) {
521 $sql =
"SELECT rowid, label";
522 $sql .=
" FROM ".MAIN_DB_PREFIX.
"bank_account";
523 $sql .=
" WHERE clos = 0";
524 $sql .=
" AND courant = 1";
525 $sql .=
" AND entity IN (".getEntity(
'bank_account').
")";
526 $resql = $db->query($sql);
528 $num = $db->num_rows($resql);
531 print
'<select name="rib" class="flat" id="rib">';
532 print
'<option value="0">'.$langs->trans(
"DoNotSuggestPaymentMode").
'</option>';
534 $row = $db->fetch_row($resql);
536 print
'<option value="'.$row[0].
'"';
537 print $conf->global->FACTURE_RIB_NUMBER == $row[0] ?
' selected' :
'';
538 print
'>'.$row[1].
'</option>';
544 print
"<i>".$langs->trans(
"NoActiveBankAccountDefined").
"</i>";
548 print
'<span class="opacitymedium">'.$langs->trans(
"BankModuleNotActive").
'</span>';
551 print
'<span class="opacitymedium">'.$langs->trans(
"SeeSetupOfModule", $langs->transnoentitiesnoconv(
"Module30Name")).
'</span>';
555print
'<tr class="oddeven">';
556print
"<td>".$langs->trans(
"SuggestPaymentByChequeToAddress").
"</td>";
558if (!isModEnabled(
'facture')) {
559 print
'<select class="flat" name="chq" id="chq">';
560 print
'<option value="0">'.$langs->trans(
"DoNotSuggestPaymentMode").
'</option>';
561 print
'<option value="-1"'.($conf->global->FACTURE_CHQ_NUMBER ?
' selected' :
'').
'>'.$langs->trans(
"MenuCompanySetup").
' ('.($mysoc->name ? $mysoc->name : $langs->trans(
"NotDefined")).
')</option>';
563 $sql =
"SELECT rowid, label";
564 $sql .=
" FROM ".MAIN_DB_PREFIX.
"bank_account";
565 $sql .=
" WHERE clos = 0";
566 $sql .=
" AND courant = 1";
567 $sql .=
" AND entity IN (".getEntity(
'bank_account').
")";
569 $resql = $db->query($sql);
571 $num = $db->num_rows($resql);
574 $row = $db->fetch_row($resql);
576 print
'<option value="'.$row[0].
'"';
577 print $conf->global->FACTURE_CHQ_NUMBER == $row[0] ?
' selected' :
'';
578 print
'>'.$langs->trans(
"OwnerOfBankAccount", $row[1]).
'</option>';
585 print
'<span class="opacitymedium">'.$langs->trans(
"SeeSetupOfModule", $langs->transnoentitiesnoconv(
"Module30Name")).
'</span>';
601print
'<form method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
602print
'<input type="hidden" name="token" value="'.newToken().
'">';
603print
'<input type="hidden" name="page_y" value="">';
604print
'<input type="hidden" name="action" value="update">';
606print
'<table class="noborder centpercent">';
607print
"<tr class=\"liste_titre\">";
608print
"<td>".$langs->trans(
"Parameter").
"</td>\n";
609print
'<td width="60" align="center">'.$langs->trans(
"Value").
"</td>\n";
612print
'<tr class="oddeven">';
613print
'<td>'.$langs->trans(
"DefaultProposalDurationValidity").
'</td>';
614print
'<td width="60" align="center">';
615print
"<input size=\"3\" class=\"flat\" type=\"text\" name=\"PROPALE_VALIDITY_DURATION\" value=\"" .
getDolGlobalString(
'PROPALE_VALIDITY_DURATION').
"\"></td>";
619$substitutionarray[
'__(AnyTranslationKey)__'] = $langs->trans(
"Translation");
620$htmltext =
'<i>'.$langs->trans(
"AvailableVariables").
':<br>';
621foreach ($substitutionarray as $key => $val) {
622 $htmltext .= $key.
'<br>';
626print
'<tr class="oddeven"><td colspan="2">';
627print $form->textwithpicto($langs->trans(
"FreeLegalTextOnProposal"), $langs->trans(
"AddCRIfTooLong").
'<br><br>'.$htmltext, 1,
'help',
'', 0, 2,
'freetexttooltip').
'<br>';
628$variablename =
'PROPOSAL_FREE_TEXT';
630 print
'<textarea name="'.$variablename.
'" class="flat" cols="120">'.
getDolGlobalString($variablename).
'</textarea>';
632 include_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
634 print $doleditor->Create();
640print
'<tr class="oddeven"><td>';
641print $form->textwithpicto($langs->trans(
"WatermarkOnDraftProposal"), $htmltext, 1,
'help',
'', 0, 2,
'watermarktooltip').
'<br>';
643print
'<input class="flat minwidth200" type="text" name="PROPALE_DRAFT_WATERMARK" value="'.dol_escape_htmltag(
getDolGlobalString(
'PROPALE_DRAFT_WATERMARK')).
'">';
649print
'<tr class="oddeven">';
650print
'<td>'.$langs->trans(
"AllowExternalDownload").
'</td>';
651print
'<td class="center">';
652print ajax_constantonoff(
'PROPOSAL_ALLOW_EXTERNAL_DOWNLOAD', array(),
null, 0, 0, 0, 2, 0, 1);
656print
'<tr class="oddeven">';
657print
'<td>'.$langs->trans(
"AllowOnLineSign").
'</td>';
658print
'<td class="center">';
659print ajax_constantonoff(
'PROPOSAL_ALLOW_ONLINESIGN', array(),
null, 0, 0, 0, 2, 0, 1);
696print
'<center><input type="submit" class="button button-edit reposition" value="'.$langs->trans(
"Modify").
'"></center>';
707print
"<table class=\"noborder\" width=\"100%\">\n";
708print
"<tr class=\"liste_titre\">\n";
709print
" <td>".$langs->trans(
"Name").
"</td>\n";
710print
" <td>".$langs->trans(
"Value").
"</td>\n";
712print
"<tr class=\"oddeven\">\n <td width=\"140\">".$langs->trans(
"PathDirectory").
"</td>\n <td>".$conf->propal->multidir_output[$conf->entity].
"</td>\n</tr>\n";
713print
"</table>\n<br>";
721print
'<table class="noborder centpercent">';
722print
'<tr class="liste_titre">';
723print
'<td>'.$langs->trans(
"Parameter").
'</td>';
724print
'<td align="center" width="60"></td>';
725print
'<td width="80"> </td>';
728print
'<tr class="oddeven"><td colspan="2">';
729print $langs->trans(
"YouMayFindNotificationsFeaturesIntoModuleNotification").
'<br>';
730print
'</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.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
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.