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');
47if (empty($conf->global->CONTRACT_ADDON)) {
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();
83 $file =
''; $classname =
''; $filefound = 0;
84 $dirmodels = array_merge(array(
'/'), (array) $conf->modules_parts[
'models']);
85 foreach ($dirmodels as $reldir) {
86 $file =
dol_buildpath($reldir.
"core/modules/contract/doc/pdf_".$modele.
".modules.php", 0);
87 if (file_exists($file)) {
89 $classname =
"pdf_".$modele;
97 $module =
new $classname($db);
99 if ($module->write_file($contract, $langs) > 0) {
100 header(
"Location: ".DOL_URL_ROOT.
"/document.php?modulepart=contract&file=SPECIMEN.pdf");
108 dol_syslog($langs->trans(
"ErrorModuleNotFound"), LOG_ERR);
110} elseif ($action ==
'set') {
113} elseif ($action ==
'del') {
116 if ($conf->global->CONTRACT_ADDON_PDF ==
"$value") {
120} elseif ($action ==
'setdoc') {
122 if (
dolibarr_set_const($db,
"CONTRACT_ADDON_PDF", $value,
'chaine', 0,
'', $conf->entity)) {
125 $conf->global->CONTRACT_ADDON_PDF = $value;
133} elseif ($action ==
'unsetdoc') {
135} elseif ($action ==
'setmod') {
140} elseif ($action ==
'set_other') {
141 $freetext =
GETPOST(
'CONTRACT_FREE_TEXT',
'restricthtml');
142 $res1 =
dolibarr_set_const($db,
"CONTRACT_FREE_TEXT", $freetext,
'chaine', 0,
'', $conf->entity);
144 $draft =
GETPOST(
'CONTRACT_DRAFT_WATERMARK',
'alpha');
145 $res2 =
dolibarr_set_const($db,
"CONTRACT_DRAFT_WATERMARK", trim($draft),
'chaine', 0,
'', $conf->entity);
147 $value =
GETPOST(
'activate_hideClosedServiceByDefault',
'alpha');
148 $res3 =
dolibarr_set_const($db,
"CONTRACT_HIDE_CLOSED_SERVICES_BY_DEFAULT", $value,
'chaine', 0,
'', $conf->entity);
150 if (!($res1 > 0) || !($res2 > 0) || !($res3 > 0)) {
159} elseif ($action ==
"allowonlinesign") {
160 if (!
dolibarr_set_const($db,
"CONTRACT_ALLOW_ONLINESIGN", $value,
'int', 0,
'', $conf->entity)) {
163} elseif (preg_match(
'/set_(.*)/', $action, $reg)) {
176 header(
"Location: " . $_SERVER[
"PHP_SELF"]);
179} elseif (preg_match(
'/del_(.*)/', $action, $reg)) {
191 header(
"Location: " . $_SERVER[
"PHP_SELF"]);
202$dirmodels = array_merge(array(
'/'), (array) $conf->modules_parts[
'models']);
206$form =
new Form($db);
208$linkback =
'<a href="'.DOL_URL_ROOT.
'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToModuleList").
'</a>';
209print
load_fiche_titre($langs->trans(
"ContractsSetup"), $linkback,
'title_setup');
213print
dol_get_fiche_head($head,
'contract', $langs->trans(
"Contracts"), -1,
'contract');
221print
'<div class="div-table-responsive-no-min">';
222print
'<table class="noborder centpercent">';
223print
'<tr class="liste_titre">';
224print
'<td width="100">'.$langs->trans(
"Name").
'</td>';
225print
'<td>'.$langs->trans(
"Description").
'</td>';
226print
'<td>'.$langs->trans(
"Example").
'</td>';
227print
'<td class="center" width="60">'.$langs->trans(
"Status").
'</td>';
228print
'<td class="center" width="16">'.$langs->trans(
"ShortInfo").
'</td>';
233foreach ($dirmodels as $reldir) {
237 $handle = opendir($dir);
238 if (is_resource($handle)) {
239 while (($file = readdir($handle)) !==
false) {
240 if (substr($file, 0, 13) ==
'mod_contract_' && substr($file,
dol_strlen($file) - 3, 3) ==
'php') {
241 $file = substr($file, 0,
dol_strlen($file) - 4);
243 require_once $dir.$file.
'.php';
245 $module =
new $file($db);
248 if ($module->version ==
'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) {
251 if ($module->version ==
'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) {
255 if ($module->isEnabled()) {
256 print
'<tr class="oddeven"><td>'.$module->nom.
"</td><td>\n";
257 print $module->info();
261 print
'<td class="nowrap">';
262 $tmp = $module->getExample();
263 if (preg_match(
'/^Error/', $tmp)) {
264 $langs->load(
"errors");
265 print
'<div class="error">'.$langs->trans($tmp).
'</div>';
266 } elseif ($tmp ==
'NotConfigured') {
267 print
'<span class="opacitymedium">'.$langs->trans($tmp).
'</span>';
273 print
'<td class="center">';
274 if ($conf->global->CONTRACT_ADDON ==
"$file") {
275 print
img_picto($langs->trans(
"Activated"),
'switch_on');
277 print
'<a class="reposition" href="'.$_SERVER[
"PHP_SELF"].
'?action=setmod&token='.newToken().
'&value='.urlencode($file).
'">';
278 print
img_picto($langs->trans(
"Disabled"),
'switch_off');
284 $contract->initAsSpecimen();
288 $htmltooltip .=
''.$langs->trans(
"Version").
': <b>'.$module->getVersion().
'</b><br>';
289 $nextval = $module->getNextValue($mysoc, $contract);
290 if (
"$nextval" != $langs->trans(
"NotAvailable")) {
291 $htmltooltip .=
''.$langs->trans(
"NextValue").
': ';
293 if (preg_match(
'/^Error/', $nextval) || $nextval ==
'NotConfigured') {
294 $nextval = $langs->trans($nextval);
296 $htmltooltip .= $nextval.
'<br>';
298 $htmltooltip .= $langs->trans($module->error).
'<br>';
302 print
'<td class="center">';
303 print $form->textwithpicto(
'', $htmltooltip, 1, 0);
315print
'</table></div><br>';
326$sql .=
" FROM ".MAIN_DB_PREFIX.
"document_model";
327$sql .=
" WHERE type = '".$db->escape($type).
"'";
328$sql .=
" AND entity = ".$conf->entity;
329$resql = $db->query($sql);
332 $num_rows = $db->num_rows($resql);
333 while ($i < $num_rows) {
334 $array = $db->fetch_array($resql);
335 array_push($def, $array[0]);
343print
'<div class="div-table-responsive-no-min">';
344print
'<table class="noborder centpercent">';
345print
'<tr class="liste_titre">';
346print
'<td>'.$langs->trans(
"Name").
'</td>';
347print
'<td>'.$langs->trans(
"Description").
'</td>';
348print
'<td class="center" width="60">'.$langs->trans(
"Status").
"</td>\n";
349print
'<td class="center" width="60">'.$langs->trans(
"Default").
"</td>\n";
350print
'<td class="center" width="80">'.$langs->trans(
"ShortInfo").
'</td>';
351print
'<td class="center" width="80">'.$langs->trans(
"Preview").
'</td>';
356foreach ($dirmodels as $reldir) {
357 foreach (array(
'',
'/doc') as $valdir) {
358 $realpath = $reldir.
"core/modules/contract".$valdir;
362 $handle = opendir($dir);
363 if (is_resource($handle)) {
364 while (($file = readdir($handle)) !==
false) {
370 foreach ($filelist as $file) {
371 if (preg_match(
'/\.modules\.php$/i', $file) && preg_match(
'/^(pdf_|doc_)/', $file)) {
372 if (file_exists($dir.
'/'.$file)) {
373 $name = substr($file, 4,
dol_strlen($file) - 16);
374 $classname = substr($file, 0,
dol_strlen($file) - 12);
376 require_once $dir.
'/'.$file;
377 $module =
new $classname($db);
379 $modulequalified = 1;
380 if ($module->version ==
'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) {
381 $modulequalified = 0;
383 if ($module->version ==
'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) {
384 $modulequalified = 0;
387 if ($modulequalified) {
388 print
'<tr class="oddeven"><td width="100">';
389 print (empty($module->name) ? $name : $module->
name);
391 if (method_exists($module,
'info')) {
392 print $module->info($langs);
394 print $module->description;
399 if (in_array($name, $def)) {
400 print
'<td class="center">'.
"\n";
401 print
'<a class="reposition" href="'.$_SERVER[
"PHP_SELF"].
'?action=del&token='.newToken().
'&value='.urlencode($name).
'">';
402 print
img_picto($langs->trans(
"Enabled"),
'switch_on');
406 print
'<td class="center">'.
"\n";
407 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>';
412 print
'<td class="center">';
414 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>';
416 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>';
421 $htmltooltip =
''.$langs->trans(
"Name").
': '.$module->name;
422 $htmltooltip .=
'<br>'.$langs->trans(
"Type").
': '.($module->type ? $module->type : $langs->trans(
"Unknown"));
423 if ($module->type ==
'pdf') {
424 $htmltooltip .=
'<br>'.$langs->trans(
"Width").
'/'.$langs->trans(
"Height").
': '.$module->page_largeur.
'/'.$module->page_hauteur;
426 $htmltooltip .=
'<br>'.$langs->trans(
"Path").
': '.preg_replace(
'/^\//',
'', $realpath).
'/'.$file;
428 $htmltooltip .=
'<br><br><u>'.$langs->trans(
"FeaturesSupported").
':</u>';
429 $htmltooltip .=
'<br>'.$langs->trans(
"Logo").
': '.
yn($module->option_logo, 1, 1);
430 $htmltooltip .=
'<br>'.$langs->trans(
"PaymentMode").
': '.
yn($module->option_modereg, 1, 1);
431 $htmltooltip .=
'<br>'.$langs->trans(
"PaymentConditions").
': '.
yn($module->option_condreg, 1, 1);
432 $htmltooltip .=
'<br>'.$langs->trans(
"MultiLanguage").
': '.
yn($module->option_multilang, 1, 1);
433 $htmltooltip .=
'<br>'.$langs->trans(
"WatermarkOnDraftOrders").
': '.
yn($module->option_draft_watermark, 1, 1);
436 print
'<td class="center">';
437 print $form->textwithpicto(
'', $htmltooltip, 1, 0);
441 print
'<td class="center">';
442 if ($module->type ==
'pdf') {
443 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=specimen&module='.$name.
'">'.
img_object($langs->trans(
"Preview"),
'pdf').
'</a>';
445 print
img_object($langs->trans(
"PreviewNotAvailable"),
'generic');
468print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="post">';
469print
'<input type="hidden" name="token" value="'.newToken().
'">';
470print
'<input type="hidden" name="action" value="set_other">';
474print
'<div class="div-table-responsive-no-min">';
475print
'<table class="noborder centpercent">';
476print
'<tr class="liste_titre">';
477print
'<td>'.$langs->trans(
"Parameter").
'</td>';
478print
'<td class="center" width="60">'.$langs->trans(
"Value").
'</td>';
482$substitutionarray[
'__(AnyTranslationKey)__'] = $langs->trans(
"Translation");
483$htmltext =
'<i>'.$langs->trans(
"AvailableVariables").
':<br>';
484foreach ($substitutionarray as $key => $val) {
485 $htmltext .= $key.
'<br>';
489print
'<tr class="oddeven"><td colspan="2">';
490print $form->textwithpicto($langs->trans(
"FreeLegalTextOnContracts"), $langs->trans(
"AddCRIfTooLong").
'<br><br>'.$htmltext, 1,
'help',
'', 0, 2,
'tooltiphelp');
492$variablename =
'CONTRACT_FREE_TEXT';
493if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) {
494 print
'<textarea name="'.$variablename.
'" class="flat" cols="120">'.
getDolGlobalString($variablename).
'</textarea>';
496 include_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
498 print $doleditor->Create();
500print
'</td></tr>'.
"\n";
504print
'<tr class="oddeven"><td>';
505print $form->textwithpicto($langs->trans(
"WatermarkOnDraftContractCards"), $htmltext, 1,
'help',
'', 0, 2,
'watermarktooltip').
'<br>';
507print
'<input class="flat minwidth200" type="text" name="CONTRACT_DRAFT_WATERMARK" value="'.dol_escape_htmltag(
getDolGlobalString(
'CONTRACT_DRAFT_WATERMARK')).
'">';
508print
'</td></tr>'.
"\n";
510print
'<tr class="oddeven">';
511print
'<td>'.$langs->trans(
"HideClosedServiceByDefault").
'</td>';
512print
'<td width="60" class="right">';
513print $form->selectyesno(
"activate_hideClosedServiceByDefault", (!empty($conf->global->CONTRACT_HIDE_CLOSED_SERVICES_BY_DEFAULT) ? $conf->global->CONTRACT_HIDE_CLOSED_SERVICES_BY_DEFAULT : 0), 1);
518print
'<tr class="oddeven">';
519print
'<td>'.$langs->trans(
"AllowOnlineSign").
'</td>';
520print
'<td class="center">';
522 print
'<a class="reposition" href="'.$_SERVER[
"PHP_SELF"].
'?action=allowonlinesign&token='.newToken().
'&value=0">';
523 print
img_picto($langs->trans(
"Activited"),
'switch_on');
526 print
'<a class="reposition" href="'.$_SERVER[
"PHP_SELF"].
'?action=allowonlinesign&token='.newToken().
'&value=1">';
527 print
img_picto($langs->trans(
"Disabled"),
'switch_off');
534print
'<tr class="oddeven">';
535print
'<td>'.$langs->trans(
"AllowExternalDownload").
'</td>';
536print
'<td class="center" colspan="2">';
537print ajax_constantonoff(
'CONTRACT_ALLOW_EXTERNAL_DOWNLOAD', array(),
null, 0, 0, 0, 2, 0, 1);
543print $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.
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.