26require
'../main.inc.php';
27require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
28require_once DOL_DOCUMENT_ROOT.
'/core/lib/pdf.lib.php';
29require_once DOL_DOCUMENT_ROOT.
'/contrat/class/contrat.class.php';
30require_once DOL_DOCUMENT_ROOT.
'/core/lib/contract.lib.php';
33$langs->loadLangs(array(
"admin",
"errors",
"contracts"));
39$action =
GETPOST(
'action',
'aZ09');
40$value =
GETPOST(
'value',
'alpha');
41$modulepart =
GETPOST(
'modulepart',
'aZ09');
43$label =
GETPOST(
'label',
'alpha');
44$scandir =
GETPOST(
'scan_dir',
'alpha');
48 $conf->global->CONTRACT_ADDON =
'mod_contract_serpis';
56include DOL_DOCUMENT_ROOT.
'/core/actions_setmoduleoptions.inc.php';
60if ($action ==
'updateMask') {
61 $maskconst =
GETPOST(
'maskconstcontract',
'aZ09');
62 $maskvalue =
GETPOST(
'maskcontract',
'alpha');
63 if ($maskconst && preg_match(
'/_MASK$/', $maskconst)) {
64 $res =
dolibarr_set_const($db, $maskconst, $maskvalue,
'chaine', 0,
'', $conf->entity);
76} elseif ($action ==
'specimen') {
77 $modele =
GETPOST(
'module',
'alpha');
80 $contract->initAsSpecimen();
86 $dirmodels = array_merge(array(
'/'), (array) $conf->modules_parts[
'models']);
87 foreach ($dirmodels as $reldir) {
88 $file =
dol_buildpath($reldir.
"core/modules/contract/doc/pdf_".$modele.
".modules.php", 0);
89 if (file_exists($file)) {
91 $classname =
"pdf_".$modele;
99 $module =
new $classname($db);
101 if ($module->write_file($contract, $langs) > 0) {
102 header(
"Location: ".DOL_URL_ROOT.
"/document.php?modulepart=contract&file=SPECIMEN.pdf");
110 dol_syslog($langs->trans(
"ErrorModuleNotFound"), LOG_ERR);
112} elseif ($action ==
'set') {
115} elseif ($action ==
'del') {
118 if ($conf->global->CONTRACT_ADDON_PDF ==
"$value") {
122} elseif ($action ==
'setdoc') {
124 if (
dolibarr_set_const($db,
"CONTRACT_ADDON_PDF", $value,
'chaine', 0,
'', $conf->entity)) {
127 $conf->global->CONTRACT_ADDON_PDF = $value;
135} elseif ($action ==
'unsetdoc') {
137} elseif ($action ==
'setmod') {
142} elseif ($action ==
'set_other') {
143 $freetext =
GETPOST(
'CONTRACT_FREE_TEXT',
'restricthtml');
144 $res1 =
dolibarr_set_const($db,
"CONTRACT_FREE_TEXT", $freetext,
'chaine', 0,
'', $conf->entity);
146 $draft =
GETPOST(
'CONTRACT_DRAFT_WATERMARK',
'alpha');
147 $res2 =
dolibarr_set_const($db,
"CONTRACT_DRAFT_WATERMARK", trim($draft),
'chaine', 0,
'', $conf->entity);
149 $value =
GETPOST(
'activate_hideClosedServiceByDefault',
'alpha');
150 $res3 =
dolibarr_set_const($db,
"CONTRACT_HIDE_CLOSED_SERVICES_BY_DEFAULT", $value,
'chaine', 0,
'', $conf->entity);
152 if (!($res1 > 0) || !($res2 > 0) || !($res3 > 0)) {
161} elseif ($action ==
"allowonlinesign") {
162 if (!
dolibarr_set_const($db,
"CONTRACT_ALLOW_ONLINESIGN", $value,
'int', 0,
'', $conf->entity)) {
165} elseif (preg_match(
'/set_(.*)/', $action, $reg)) {
178 header(
"Location: " . $_SERVER[
"PHP_SELF"]);
181} elseif (preg_match(
'/del_(.*)/', $action, $reg)) {
193 header(
"Location: " . $_SERVER[
"PHP_SELF"]);
204$dirmodels = array_merge(array(
'/'), (array) $conf->modules_parts[
'models']);
208$form =
new Form($db);
210$linkback =
'<a href="'.DOL_URL_ROOT.
'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToModuleList").
'</a>';
211print
load_fiche_titre($langs->trans(
"ContractsSetup"), $linkback,
'title_setup');
215print
dol_get_fiche_head($head,
'contract', $langs->trans(
"Contracts"), -1,
'contract');
223print
'<div class="div-table-responsive-no-min">';
224print
'<table class="noborder centpercent">';
225print
'<tr class="liste_titre">';
226print
'<td width="100">'.$langs->trans(
"Name").
'</td>';
227print
'<td>'.$langs->trans(
"Description").
'</td>';
228print
'<td>'.$langs->trans(
"Example").
'</td>';
229print
'<td class="center" width="60">'.$langs->trans(
"Status").
'</td>';
230print
'<td class="center" width="16">'.$langs->trans(
"ShortInfo").
'</td>';
235foreach ($dirmodels as $reldir) {
239 $handle = opendir($dir);
240 if (is_resource($handle)) {
241 while (($file = readdir($handle)) !==
false) {
242 if (substr($file, 0, 13) ==
'mod_contract_' && substr($file,
dol_strlen($file) - 3, 3) ==
'php') {
243 $file = substr($file, 0,
dol_strlen($file) - 4);
245 require_once $dir.$file.
'.php';
247 $module =
new $file($db);
250 if ($module->version ==
'development' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 2) {
253 if ($module->version ==
'experimental' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 1) {
257 if ($module->isEnabled()) {
258 print
'<tr class="oddeven"><td>'.$module->nom.
"</td><td>\n";
259 print $module->info($langs);
263 print
'<td class="nowrap">';
264 $tmp = $module->getExample();
265 if (preg_match(
'/^Error/', $tmp)) {
266 $langs->load(
"errors");
267 print
'<div class="error">'.$langs->trans($tmp).
'</div>';
268 } elseif ($tmp ==
'NotConfigured') {
269 print
'<span class="opacitymedium">'.$langs->trans($tmp).
'</span>';
275 print
'<td class="center">';
276 if ($conf->global->CONTRACT_ADDON ==
"$file") {
277 print
img_picto($langs->trans(
"Activated"),
'switch_on');
279 print
'<a class="reposition" href="'.$_SERVER[
"PHP_SELF"].
'?action=setmod&token='.newToken().
'&value='.urlencode($file).
'">';
280 print
img_picto($langs->trans(
"Disabled"),
'switch_off');
286 $contract->initAsSpecimen();
290 $htmltooltip .=
''.$langs->trans(
"Version").
': <b>'.$module->getVersion().
'</b><br>';
291 $nextval = $module->getNextValue($mysoc, $contract);
292 if (
"$nextval" != $langs->trans(
"NotAvailable")) {
293 $htmltooltip .=
''.$langs->trans(
"NextValue").
': ';
295 if (preg_match(
'/^Error/', $nextval) || $nextval ==
'NotConfigured') {
296 $nextval = $langs->trans($nextval);
298 $htmltooltip .= $nextval.
'<br>';
300 $htmltooltip .= $langs->trans($module->error).
'<br>';
304 print
'<td class="center">';
305 print $form->textwithpicto(
'', $htmltooltip, 1, 0);
317print
'</table></div><br>';
328$sql .=
" FROM ".MAIN_DB_PREFIX.
"document_model";
329$sql .=
" WHERE type = '".$db->escape($type).
"'";
330$sql .=
" AND entity = ".$conf->entity;
331$resql = $db->query($sql);
334 $num_rows = $db->num_rows($resql);
335 while ($i < $num_rows) {
336 $array = $db->fetch_array($resql);
337 array_push($def, $array[0]);
345print
'<div class="div-table-responsive-no-min">';
346print
'<table class="noborder centpercent">';
347print
'<tr class="liste_titre">';
348print
'<td>'.$langs->trans(
"Name").
'</td>';
349print
'<td>'.$langs->trans(
"Description").
'</td>';
350print
'<td class="center" width="60">'.$langs->trans(
"Status").
"</td>\n";
351print
'<td class="center" width="60">'.$langs->trans(
"Default").
"</td>\n";
352print
'<td class="center" width="80">'.$langs->trans(
"ShortInfo").
'</td>';
353print
'<td class="center" width="80">'.$langs->trans(
"Preview").
'</td>';
358foreach ($dirmodels as $reldir) {
359 foreach (array(
'',
'/doc') as $valdir) {
360 $realpath = $reldir.
"core/modules/contract".$valdir;
364 $handle = opendir($dir);
365 if (is_resource($handle)) {
366 while (($file = readdir($handle)) !==
false) {
372 foreach ($filelist as $file) {
373 if (preg_match(
'/\.modules\.php$/i', $file) && preg_match(
'/^(pdf_|doc_)/', $file)) {
374 if (file_exists($dir.
'/'.$file)) {
375 $name = substr($file, 4,
dol_strlen($file) - 16);
376 $classname = substr($file, 0,
dol_strlen($file) - 12);
378 require_once $dir.
'/'.$file;
379 $module =
new $classname($db);
381 $modulequalified = 1;
382 if ($module->version ==
'development' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 2) {
383 $modulequalified = 0;
385 if ($module->version ==
'experimental' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 1) {
386 $modulequalified = 0;
389 if ($modulequalified) {
390 print
'<tr class="oddeven"><td width="100">';
391 print(empty($module->name) ? $name : $module->
name);
393 if (method_exists($module,
'info')) {
394 print $module->info($langs);
396 print $module->description;
401 if (in_array($name, $def)) {
402 print
'<td class="center">'.
"\n";
403 print
'<a class="reposition" href="'.$_SERVER[
"PHP_SELF"].
'?action=del&token='.newToken().
'&value='.urlencode($name).
'">';
404 print
img_picto($langs->trans(
"Enabled"),
'switch_on');
408 print
'<td class="center">'.
"\n";
409 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>';
414 print
'<td class="center">';
416 print
'<a class="reposition" href="'.$_SERVER[
"PHP_SELF"].
'?action=unsetdoc&token='.newToken().
'&value='.urlencode($name).
'&scan_dir='.urlencode($module->scandir).
'&label='.urlencode($module->name).
'&type=order_supplier" alt="'.$langs->trans(
"Disable").
'">'.
img_picto($langs->trans(
"Enabled"),
'on').
'</a>';
418 print
'<a class="reposition" href="'.$_SERVER[
"PHP_SELF"].
'?action=setdoc&token='.newToken().
'&value='.urlencode($name).
'&scan_dir='.urlencode($module->scandir).
'&label='.urlencode($module->name).
'" alt="'.$langs->trans(
"Default").
'">'.
img_picto($langs->trans(
"Disabled"),
'off').
'</a>';
423 $htmltooltip =
''.$langs->trans(
"Name").
': '.$module->name;
424 $htmltooltip .=
'<br>'.$langs->trans(
"Type").
': '.($module->type ? $module->type : $langs->trans(
"Unknown"));
425 if ($module->type ==
'pdf') {
426 $htmltooltip .=
'<br>'.$langs->trans(
"Width").
'/'.$langs->trans(
"Height").
': '.$module->page_largeur.
'/'.$module->page_hauteur;
428 $htmltooltip .=
'<br>'.$langs->trans(
"Path").
': '.preg_replace(
'/^\//',
'', $realpath).
'/'.$file;
430 $htmltooltip .=
'<br><br><u>'.$langs->trans(
"FeaturesSupported").
':</u>';
431 $htmltooltip .=
'<br>'.$langs->trans(
"Logo").
': '.
yn($module->option_logo, 1, 1);
432 $htmltooltip .=
'<br>'.$langs->trans(
"PaymentMode").
': '.
yn($module->option_modereg, 1, 1);
433 $htmltooltip .=
'<br>'.$langs->trans(
"PaymentConditions").
': '.
yn($module->option_condreg, 1, 1);
434 $htmltooltip .=
'<br>'.$langs->trans(
"MultiLanguage").
': '.
yn($module->option_multilang, 1, 1);
435 $htmltooltip .=
'<br>'.$langs->trans(
"WatermarkOnDraftOrders").
': '.
yn($module->option_draft_watermark, 1, 1);
438 print
'<td class="center">';
439 print $form->textwithpicto(
'', $htmltooltip, 1, 0);
443 print
'<td class="center">';
444 if ($module->type ==
'pdf') {
445 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=specimen&module='.$name.
'">'.
img_object($langs->trans(
"Preview"),
'pdf').
'</a>';
447 print
img_object($langs->trans(
"PreviewNotAvailable"),
'generic');
470print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="post">';
471print
'<input type="hidden" name="token" value="'.newToken().
'">';
472print
'<input type="hidden" name="action" value="set_other">';
476print
'<div class="div-table-responsive-no-min">';
477print
'<table class="noborder centpercent">';
478print
'<tr class="liste_titre">';
479print
'<td>'.$langs->trans(
"Parameter").
'</td>';
480print
'<td class="right">'.$langs->trans(
"Value").
'</td>';
484$substitutionarray[
'__(AnyTranslationKey)__'] = $langs->trans(
"Translation");
485$htmltext =
'<i>'.$langs->trans(
"AvailableVariables").
':<br>';
486foreach ($substitutionarray as $key => $val) {
487 $htmltext .= $key.
'<br>';
491print
'<tr class="oddeven"><td colspan="2">';
492print $form->textwithpicto($langs->trans(
"FreeLegalTextOnContracts"), $langs->trans(
"AddCRIfTooLong").
'<br><br>'.$htmltext, 1,
'help',
'', 0, 2,
'tooltiphelp');
494$variablename =
'CONTRACT_FREE_TEXT';
496 print
'<textarea name="'.$variablename.
'" class="flat" cols="120">'.
getDolGlobalString($variablename).
'</textarea>';
498 include_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
500 print $doleditor->Create();
502print
'</td></tr>'.
"\n";
506print
'<tr class="oddeven"><td>';
507print $form->textwithpicto($langs->trans(
"WatermarkOnDraftContractCards"), $htmltext, 1,
'help',
'', 0, 2,
'watermarktooltip').
'<br>';
508print
'</td><td class="right">';
509print
'<input class="flat minwidth200" type="text" name="CONTRACT_DRAFT_WATERMARK" value="'.dol_escape_htmltag(
getDolGlobalString(
'CONTRACT_DRAFT_WATERMARK')).
'">';
510print
'</td></tr>'.
"\n";
512print
'<tr class="oddeven">';
513print
'<td>'.$langs->trans(
"HideClosedServiceByDefault").
'</td>';
514print
'<td class="right">';
515print $form->selectyesno(
"activate_hideClosedServiceByDefault", (
getDolGlobalString(
'CONTRACT_HIDE_CLOSED_SERVICES_BY_DEFAULT') ? $conf->global->CONTRACT_HIDE_CLOSED_SERVICES_BY_DEFAULT : 0), 1);
520print
'<tr class="oddeven">';
521print
'<td>'.$langs->trans(
"AllowOnlineSign").
'</td>';
522print
'<td class="right">';
524 print
'<a class="reposition" href="'.$_SERVER[
"PHP_SELF"].
'?action=allowonlinesign&token='.newToken().
'&value=0">';
525 print
img_picto($langs->trans(
"Activited"),
'switch_on');
528 print
'<a class="reposition" href="'.$_SERVER[
"PHP_SELF"].
'?action=allowonlinesign&token='.newToken().
'&value=1">';
529 print
img_picto($langs->trans(
"Disabled"),
'switch_off');
536print
'<tr class="oddeven">';
537print
'<td>'.$langs->trans(
"AllowExternalDownload").
'</td>';
538print
'<td class="right">';
539print ajax_constantonoff(
'CONTRACT_ALLOW_EXTERNAL_DOWNLOAD', array(),
null, 0, 0, 0, 2, 0, 1);
545print $form->buttonsSaveCancel(
"Save",
'');
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 contracts.
Class to manage a WYSIWYG editor.
contract_admin_prepare_head()
Return array head with list of tabs to view object informations.
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_get_fiche_end($notab=0)
Return tab footer of a card.
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).
$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.