28require
'../main.inc.php';
29require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
30require_once DOL_DOCUMENT_ROOT.
'/core/lib/pdf.lib.php';
31require_once DOL_DOCUMENT_ROOT.
'/contrat/class/contrat.class.php';
32require_once DOL_DOCUMENT_ROOT.
'/core/lib/contract.lib.php';
35$langs->loadLangs(array(
"admin",
"errors",
"contracts"));
41$action =
GETPOST(
'action',
'aZ09');
42$value =
GETPOST(
'value',
'alpha');
43$modulepart =
GETPOST(
'modulepart',
'aZ09');
45$label =
GETPOST(
'label',
'alpha');
46$scandir =
GETPOST(
'scan_dir',
'alpha');
50 $conf->global->CONTRACT_ADDON =
'mod_contract_serpis';
58include DOL_DOCUMENT_ROOT.
'/core/actions_setmoduleoptions.inc.php';
62if ($action ==
'updateMask') {
63 $maskconst =
GETPOST(
'maskconstcontract',
'aZ09');
64 $maskvalue =
GETPOST(
'maskcontract',
'alpha');
65 if ($maskconst && preg_match(
'/_MASK$/', $maskconst)) {
66 $res =
dolibarr_set_const($db, $maskconst, $maskvalue,
'chaine', 0,
'', $conf->entity);
78} elseif ($action ==
'specimen') {
79 $modele =
GETPOST(
'module',
'alpha');
82 $contract->initAsSpecimen();
87 $dirmodels = array_merge(array(
'/'), (array) $conf->modules_parts[
'models']);
88 foreach ($dirmodels as $reldir) {
89 $file =
dol_buildpath($reldir.
"core/modules/contract/doc/pdf_".$modele.
".modules.php", 0);
90 if (file_exists($file)) {
91 $classname =
"pdf_".$modele;
96 if ($classname !==
'') {
99 $module =
new $classname($db);
100 '@phan-var-force ModelePDFContract $module';
102 if ($module->write_file($contract, $langs) > 0) {
103 header(
"Location: ".DOL_URL_ROOT.
"/document.php?modulepart=contract&file=SPECIMEN.pdf");
111 dol_syslog($langs->trans(
"ErrorModuleNotFound"), LOG_ERR);
113} elseif ($action ==
'set') {
116} elseif ($action ==
'del') {
119 if ($conf->global->CONTRACT_ADDON_PDF ==
"$value") {
123} elseif ($action ==
'setdoc') {
125 if (
dolibarr_set_const($db,
"CONTRACT_ADDON_PDF", $value,
'chaine', 0,
'', $conf->entity)) {
128 $conf->global->CONTRACT_ADDON_PDF = $value;
136} elseif ($action ==
'unsetdoc') {
138} elseif ($action ==
'setmod') {
143} elseif ($action ==
'set_other') {
144 $freetext =
GETPOST(
'CONTRACT_FREE_TEXT',
'restricthtml');
145 $res1 =
dolibarr_set_const($db,
"CONTRACT_FREE_TEXT", $freetext,
'chaine', 0,
'', $conf->entity);
147 $draft =
GETPOST(
'CONTRACT_DRAFT_WATERMARK',
'alpha');
148 $res2 =
dolibarr_set_const($db,
"CONTRACT_DRAFT_WATERMARK", trim($draft),
'chaine', 0,
'', $conf->entity);
150 $value =
GETPOST(
'activate_hideClosedServiceByDefault',
'alpha');
151 $res3 =
dolibarr_set_const($db,
"CONTRACT_HIDE_CLOSED_SERVICES_BY_DEFAULT", $value,
'chaine', 0,
'', $conf->entity);
153 if (!($res1 > 0) || !($res2 > 0) || !($res3 > 0)) {
162} elseif ($action ==
"allowonlinesign") {
163 if (!
dolibarr_set_const($db,
"CONTRACT_ALLOW_ONLINESIGN", $value,
'int', 0,
'', $conf->entity)) {
166} elseif (preg_match(
'/set_(.*)/', $action, $reg)) {
179 header(
"Location: " . $_SERVER[
"PHP_SELF"]);
182} elseif (preg_match(
'/del_(.*)/', $action, $reg)) {
194 header(
"Location: " . $_SERVER[
"PHP_SELF"]);
205$dirmodels = array_merge(array(
'/'), (array) $conf->modules_parts[
'models']);
207llxHeader(
'',
'',
'',
'', 0, 0,
'',
'',
'',
'mod-admin page-contract');
209$form =
new Form($db);
211$linkback =
'<a href="'.DOL_URL_ROOT.
'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToModuleList").
'</a>';
212print
load_fiche_titre($langs->trans(
"ContractsSetup"), $linkback,
'title_setup');
216print
dol_get_fiche_head($head,
'contract', $langs->trans(
"Contracts"), -1,
'contract');
224print
'<div class="div-table-responsive-no-min">';
225print
'<table class="noborder centpercent">';
226print
'<tr class="liste_titre">';
227print
'<td width="100">'.$langs->trans(
"Name").
'</td>';
228print
'<td>'.$langs->trans(
"Description").
'</td>';
229print
'<td>'.$langs->trans(
"Example").
'</td>';
230print
'<td class="center" width="60">'.$langs->trans(
"Status").
'</td>';
231print
'<td class="center" width="16">'.$langs->trans(
"ShortInfo").
'</td>';
236foreach ($dirmodels as $reldir) {
240 $handle = opendir($dir);
241 if (is_resource($handle)) {
242 while (($file = readdir($handle)) !==
false) {
243 if (substr($file, 0, 13) ==
'mod_contract_' && substr($file,
dol_strlen($file) - 3, 3) ==
'php') {
244 $file = substr($file, 0,
dol_strlen($file) - 4);
246 require_once $dir.$file.
'.php';
248 $module =
new $file($db);
251 if ($module->version ==
'development' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 2) {
254 if ($module->version ==
'experimental' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 1) {
258 if ($module->isEnabled()) {
259 print
'<tr class="oddeven"><td>'.$module->name.
"</td><td>\n";
260 print $module->info($langs);
264 print
'<td class="nowrap">';
265 $tmp = $module->getExample();
266 if (preg_match(
'/^Error/', $tmp)) {
267 $langs->load(
"errors");
268 print
'<div class="error">'.$langs->trans($tmp).
'</div>';
269 } elseif ($tmp ==
'NotConfigured') {
270 print
'<span class="opacitymedium">'.$langs->trans($tmp).
'</span>';
276 print
'<td class="center">';
277 if ($conf->global->CONTRACT_ADDON ==
"$file") {
278 print
img_picto($langs->trans(
"Activated"),
'switch_on');
280 print
'<a class="reposition" href="'.$_SERVER[
"PHP_SELF"].
'?action=setmod&token='.
newToken().
'&value='.urlencode($file).
'">';
281 print
img_picto($langs->trans(
"Disabled"),
'switch_off');
287 $contract->initAsSpecimen();
291 $htmltooltip .=
''.$langs->trans(
"Version").
': <b>'.$module->getVersion().
'</b><br>';
292 $nextval = $module->getNextValue($mysoc, $contract);
293 if (
"$nextval" != $langs->trans(
"NotAvailable")) {
294 $htmltooltip .=
''.$langs->trans(
"NextValue").
': ';
296 if (preg_match(
'/^Error/', $nextval) || $nextval ==
'NotConfigured') {
297 $nextval = $langs->trans($nextval);
299 $htmltooltip .= $nextval.
'<br>';
301 $htmltooltip .= $langs->trans($module->error).
'<br>';
305 print
'<td class="center">';
306 print $form->textwithpicto(
'', $htmltooltip, 1, 0);
318print
'</table></div><br>';
329$sql .=
" FROM ".MAIN_DB_PREFIX.
"document_model";
330$sql .=
" WHERE type = '".$db->escape($type).
"'";
331$sql .=
" AND entity = ".$conf->entity;
332$resql = $db->query($sql);
335 $num_rows = $db->num_rows($resql);
336 while ($i < $num_rows) {
337 $array = $db->fetch_array($resql);
338 if (is_array($array)) {
339 array_push($def, $array[0]);
348print
'<div class="div-table-responsive-no-min">';
349print
'<table class="noborder centpercent">';
350print
'<tr class="liste_titre">';
351print
'<td>'.$langs->trans(
"Name").
'</td>';
352print
'<td>'.$langs->trans(
"Description").
'</td>';
353print
'<td class="center" width="60">'.$langs->trans(
"Status").
"</td>\n";
354print
'<td class="center" width="60">'.$langs->trans(
"Default").
"</td>\n";
355print
'<td class="center" width="80">'.$langs->trans(
"ShortInfo").
'</td>';
356print
'<td class="center" width="80">'.$langs->trans(
"Preview").
'</td>';
361foreach ($dirmodels as $reldir) {
362 foreach (array(
'',
'/doc') as $valdir) {
363 $realpath = $reldir.
"core/modules/contract".$valdir;
367 $handle = opendir($dir);
368 if (is_resource($handle)) {
370 while (($file = readdir($handle)) !==
false) {
376 foreach ($filelist as $file) {
377 if (preg_match(
'/\.modules\.php$/i', $file) && preg_match(
'/^(pdf_|doc_)/', $file)) {
378 if (file_exists($dir.
'/'.$file)) {
379 $name = substr($file, 4,
dol_strlen($file) - 16);
380 $classname = substr($file, 0,
dol_strlen($file) - 12);
382 require_once $dir.
'/'.$file;
384 $module =
new $classname($db);
386 $modulequalified = 1;
387 if ($module->version ==
'development' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 2) {
388 $modulequalified = 0;
390 if ($module->version ==
'experimental' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 1) {
391 $modulequalified = 0;
394 if ($modulequalified) {
395 print
'<tr class="oddeven"><td width="100">';
396 print(empty($module->name) ? $name : $module->
name);
398 if (method_exists($module,
'info')) {
399 print $module->info($langs);
401 print $module->description;
406 if (in_array($name, $def)) {
407 print
'<td class="center">'.
"\n";
408 print
'<a class="reposition" href="'.$_SERVER[
"PHP_SELF"].
'?action=del&token='.
newToken().
'&value='.urlencode($name).
'">';
409 print
img_picto($langs->trans(
"Enabled"),
'switch_on');
413 print
'<td class="center">'.
"\n";
414 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>';
419 print
'<td class="center">';
421 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>';
423 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>';
428 $htmltooltip =
''.$langs->trans(
"Name").
': '.$module->name;
429 $htmltooltip .=
'<br>'.$langs->trans(
"Type").
': '.($module->type ? $module->type : $langs->trans(
"Unknown"));
430 if ($module->type ==
'pdf') {
431 $htmltooltip .=
'<br>'.$langs->trans(
"Width").
'/'.$langs->trans(
"Height").
': '.$module->page_largeur.
'/'.$module->page_hauteur;
433 $htmltooltip .=
'<br>'.$langs->trans(
"Path").
': '.preg_replace(
'/^\//',
'', $realpath).
'/'.$file;
435 $htmltooltip .=
'<br><br><u>'.$langs->trans(
"FeaturesSupported").
':</u>';
436 $htmltooltip .=
'<br>'.$langs->trans(
"Logo").
': '.
yn($module->option_logo, 1, 1);
437 $htmltooltip .=
'<br>'.$langs->trans(
"PaymentMode").
': '.
yn($module->option_modereg, 1, 1);
438 $htmltooltip .=
'<br>'.$langs->trans(
"PaymentConditions").
': '.
yn($module->option_condreg, 1, 1);
439 $htmltooltip .=
'<br>'.$langs->trans(
"MultiLanguage").
': '.
yn($module->option_multilang, 1, 1);
440 $htmltooltip .=
'<br>'.$langs->trans(
"WatermarkOnDraftOrders").
': '.
yn($module->option_draft_watermark, 1, 1);
443 print
'<td class="center">';
444 print $form->textwithpicto(
'', $htmltooltip, 1, 0);
448 print
'<td class="center">';
449 if ($module->type ==
'pdf') {
450 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=specimen&module='.$name.
'">'.
img_object($langs->trans(
"Preview"),
'pdf').
'</a>';
452 print
img_object($langs->trans(
"PreviewNotAvailable"),
'generic');
475print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="post">';
476print
'<input type="hidden" name="token" value="'.newToken().
'">';
477print
'<input type="hidden" name="action" value="set_other">';
481print
'<div class="div-table-responsive-no-min">';
482print
'<table class="noborder centpercent">';
483print
'<tr class="liste_titre">';
484print
'<td>'.$langs->trans(
"Parameter").
'</td>';
485print
'<td class="right">'.$langs->trans(
"Value").
'</td>';
489$substitutionarray[
'__(AnyTranslationKey)__'] = $langs->trans(
"Translation");
490$htmltext =
'<i>'.$langs->trans(
"AvailableVariables").
':<br>';
491foreach ($substitutionarray as $key => $val) {
492 $htmltext .= $key.
'<br>';
496print
'<tr class="oddeven"><td colspan="2">';
497print $form->textwithpicto($langs->trans(
"FreeLegalTextOnContracts"), $langs->trans(
"AddCRIfTooLong").
'<br><br>'.$htmltext, 1,
'help',
'', 0, 2,
'tooltiphelp');
499$variablename =
'CONTRACT_FREE_TEXT';
501 print
'<textarea name="'.$variablename.
'" class="flat" cols="120">'.
getDolGlobalString($variablename).
'</textarea>';
503 include_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
505 print $doleditor->Create();
507print
'</td></tr>'.
"\n";
511print
'<tr class="oddeven"><td>';
512print $form->textwithpicto($langs->trans(
"WatermarkOnDraftContractCards"), $htmltext, 1,
'help',
'', 0, 2,
'watermarktooltip').
'<br>';
513print
'</td><td class="right">';
514print
'<input class="flat minwidth200" type="text" name="CONTRACT_DRAFT_WATERMARK" value="'.dol_escape_htmltag(
getDolGlobalString(
'CONTRACT_DRAFT_WATERMARK')).
'">';
515print
'</td></tr>'.
"\n";
517print
'<tr class="oddeven">';
518print
'<td>'.$langs->trans(
"HideClosedServiceByDefault").
'</td>';
519print
'<td class="right">';
520print $form->selectyesno(
"activate_hideClosedServiceByDefault",
getDolGlobalInt(
'CONTRACT_HIDE_CLOSED_SERVICES_BY_DEFAULT', 0), 1);
525print
'<tr class="oddeven">';
526print
'<td>'.$langs->trans(
"AllowOnlineSign").
'</td>';
527print
'<td class="right">';
529 print
'<a class="reposition" href="'.$_SERVER[
"PHP_SELF"].
'?action=allowonlinesign&token='.
newToken().
'&value=0">';
530 print
img_picto($langs->trans(
"Activated"),
'switch_on');
533 print
'<a class="reposition" href="'.$_SERVER[
"PHP_SELF"].
'?action=allowonlinesign&token='.
newToken().
'&value=1">';
534 print
img_picto($langs->trans(
"Disabled"),
'switch_off');
541print
'<tr class="oddeven">';
542print
'<td>'.$langs->trans(
"AllowExternalDownload").
'</td>';
543print
'<td class="right">';
544print ajax_constantonoff(
'CONTRACT_ALLOW_EXTERNAL_DOWNLOAD', array(),
null, 0, 0, 0, 2, 0, 1);
550print $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 information.
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)
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
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_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.
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)
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.
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 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.