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';
44$langs->loadLangs(array(
"admin",
"errors",
"contracts"));
50$action =
GETPOST(
'action',
'aZ09');
51$value =
GETPOST(
'value',
'alpha');
52$modulepart =
GETPOST(
'modulepart',
'aZ09');
54$label =
GETPOST(
'label',
'alpha');
55$scandir =
GETPOST(
'scan_dir',
'alpha');
59 $conf->global->CONTRACT_ADDON =
'mod_contract_serpis';
67include DOL_DOCUMENT_ROOT.
'/core/actions_setmoduleoptions.inc.php';
71if ($action ==
'updateMask') {
72 $maskconst =
GETPOST(
'maskconstcontract',
'aZ09');
73 $maskvalue =
GETPOST(
'maskcontract',
'alpha');
75 if ($maskconst && preg_match(
'/_MASK$/', $maskconst)) {
88} elseif ($action ==
'specimen') {
89 $modele =
GETPOST(
'module',
'alpha');
92 $contract->initAsSpecimen();
97 $dirmodels = array_merge(array(
'/'), (array)
$conf->modules_parts[
'models']);
98 foreach ($dirmodels as $reldir) {
99 $file =
dol_buildpath($reldir.
"core/modules/contract/doc/pdf_".$modele.
".modules.php", 0);
100 if (file_exists($file)) {
101 $classname =
"pdf_".$modele;
106 if ($classname !==
'') {
109 $module =
new $classname($db);
110 '@phan-var-force ModelePDFContract $module';
113 if ($module->write_file($contract, $langs) > 0) {
114 header(
"Location: ".DOL_URL_ROOT.
"/document.php?modulepart=contract&file=SPECIMEN.pdf");
122 dol_syslog($langs->trans(
"ErrorModuleNotFound"), LOG_ERR);
124} elseif ($action ==
'set') {
127} elseif ($action ==
'del') {
130 if (
$conf->global->CONTRACT_ADDON_PDF ==
"$value") {
134} elseif ($action ==
'setdoc') {
139 $conf->global->CONTRACT_ADDON_PDF = $value;
147} elseif ($action ==
'unsetdoc') {
149} elseif ($action ==
'setmod') {
154} elseif ($action ==
'set_other') {
155 $freetext =
GETPOST(
'CONTRACT_FREE_TEXT',
'restricthtml');
158 $draft =
GETPOST(
'CONTRACT_DRAFT_WATERMARK',
'alpha');
161 $value =
GETPOST(
'activate_hideClosedServiceByDefault',
'alpha');
162 $res3 =
dolibarr_set_const($db,
"CONTRACT_HIDE_CLOSED_SERVICES_BY_DEFAULT", $value,
'chaine', 0,
'',
$conf->entity);
164 if (!($res1 > 0) || !($res2 > 0) || !($res3 > 0)) {
173} elseif ($action ==
"allowonlinesign") {
177} elseif (preg_match(
'/set_(.*)/', $action, $reg)) {
190 header(
"Location: " . $_SERVER[
"PHP_SELF"]);
193} elseif (preg_match(
'/del_(.*)/', $action, $reg)) {
205 header(
"Location: " . $_SERVER[
"PHP_SELF"]);
216$dirmodels = array_merge(array(
'/'), (array)
$conf->modules_parts[
'models']);
218llxHeader(
'',
'',
'',
'', 0, 0,
'',
'',
'',
'mod-admin page-contract');
220$form =
new Form($db);
222$linkback =
'<a href="'.DOL_URL_ROOT.
'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToModuleList").
'</a>';
223print
load_fiche_titre($langs->trans(
"ContractsSetup"), $linkback,
'title_setup');
227print
dol_get_fiche_head($head,
'contract', $langs->trans(
"Contracts"), -1,
'contract');
235print
'<div class="div-table-responsive-no-min">';
236print
'<table class="noborder centpercent">';
237print
'<tr class="liste_titre">';
238print
'<td width="100">'.$langs->trans(
"Name").
'</td>';
239print
'<td>'.$langs->trans(
"Description").
'</td>';
240print
'<td>'.$langs->trans(
"Example").
'</td>';
241print
'<td class="center" width="60">'.$langs->trans(
"Status").
'</td>';
242print
'<td class="center" width="16">'.$langs->trans(
"ShortInfo").
'</td>';
247foreach ($dirmodels as $reldir) {
251 $handle = opendir($dir);
252 if (is_resource($handle)) {
253 while (($file = readdir($handle)) !==
false) {
254 if (substr($file, 0, 13) ==
'mod_contract_' && substr($file,
dol_strlen($file) - 3, 3) ==
'php') {
255 $file = substr($file, 0,
dol_strlen($file) - 4);
257 require_once $dir.$file.
'.php';
259 $module =
new $file($db);
261 '@phan-var-force ModelNumRefContracts $module';
264 if ($module->version ==
'development' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 2) {
267 if ($module->version ==
'experimental' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 1) {
271 if ($module->isEnabled()) {
272 print
'<tr class="oddeven"><td>'.$module->name.
"</td><td>\n";
273 print $module->info($langs);
277 print
'<td class="nowrap">';
278 $tmp = $module->getExample();
279 if (preg_match(
'/^Error/', $tmp)) {
280 $langs->load(
"errors");
281 print
'<div class="error">'.$langs->trans($tmp).
'</div>';
282 } elseif ($tmp ==
'NotConfigured') {
283 print
'<span class="opacitymedium">'.$langs->trans($tmp).
'</span>';
289 print
'<td class="center">';
290 if (
$conf->global->CONTRACT_ADDON ==
"$file") {
291 print
img_picto($langs->trans(
"Activated"),
'switch_on');
293 print
'<a class="reposition" href="'.$_SERVER[
"PHP_SELF"].
'?action=setmod&token='.
newToken().
'&value='.urlencode($file).
'">';
294 print
img_picto($langs->trans(
"Disabled"),
'switch_off');
300 $contract->initAsSpecimen();
304 $htmltooltip .=
''.$langs->trans(
"Version").
': <b>'.$module->getVersion().
'</b><br>';
305 $nextval = $module->getNextValue($mysoc, $contract);
306 if (
"$nextval" != $langs->trans(
"NotAvailable")) {
307 $htmltooltip .=
''.$langs->trans(
"NextValue").
': ';
309 if (preg_match(
'/^Error/', $nextval) || $nextval ==
'NotConfigured') {
310 $nextval = $langs->trans($nextval);
312 $htmltooltip .= $nextval.
'<br>';
314 $htmltooltip .= $langs->trans($module->error).
'<br>';
318 print
'<td class="center">';
319 print $form->textwithpicto(
'', $htmltooltip, 1, 0);
331print
'</table></div><br>';
342$sql .=
" FROM ".MAIN_DB_PREFIX.
"document_model";
343$sql .=
" WHERE type = '".$db->escape($type).
"'";
344$sql .=
" AND entity = ".$conf->entity;
345$resql = $db->query($sql);
348 $num_rows = $db->num_rows($resql);
349 while ($i < $num_rows) {
350 $array = $db->fetch_array($resql);
351 if (is_array($array)) {
352 array_push($def, $array[0]);
361print
'<div class="div-table-responsive-no-min">';
362print
'<table class="noborder centpercent">';
363print
'<tr class="liste_titre">';
364print
'<td>'.$langs->trans(
"Name").
'</td>';
365print
'<td>'.$langs->trans(
"Description").
'</td>';
366print
'<td class="center" width="60">'.$langs->trans(
"Status").
"</td>\n";
367print
'<td class="center" width="60">'.$langs->trans(
"Default").
"</td>\n";
368print
'<td class="center" width="80">'.$langs->trans(
"ShortInfo").
'</td>';
369print
'<td class="center" width="80">'.$langs->trans(
"Preview").
'</td>';
374foreach ($dirmodels as $reldir) {
375 foreach (array(
'',
'/doc') as $valdir) {
376 $realpath = $reldir.
"core/modules/contract".$valdir;
380 $handle = opendir($dir);
381 if (is_resource($handle)) {
383 while (($file = readdir($handle)) !==
false) {
389 foreach ($filelist as $file) {
390 if (preg_match(
'/\.modules\.php$/i', $file) && preg_match(
'/^(pdf_|doc_)/', $file)) {
391 if (file_exists($dir.
'/'.$file)) {
392 $name = substr($file, 4,
dol_strlen($file) - 16);
393 $classname = substr($file, 0,
dol_strlen($file) - 12);
395 require_once $dir.
'/'.$file;
397 $module =
new $classname($db);
399 '@phan-var-force ModelePDFContract $module';
401 $modulequalified = 1;
402 if ($module->version ==
'development' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 2) {
403 $modulequalified = 0;
405 if ($module->version ==
'experimental' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 1) {
406 $modulequalified = 0;
409 if ($modulequalified) {
410 print
'<tr class="oddeven"><td width="100">';
411 print(empty($module->name) ? $name : $module->
name);
413 if (method_exists($module,
'info')) {
414 print $module->info($langs);
416 print $module->description;
421 if (in_array($name, $def)) {
422 print
'<td class="center">'.
"\n";
423 print
'<a class="reposition" href="'.$_SERVER[
"PHP_SELF"].
'?action=del&token='.
newToken().
'&value='.urlencode($name).
'">';
424 print
img_picto($langs->trans(
"Enabled"),
'switch_on');
428 print
'<td class="center">'.
"\n";
429 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>';
434 print
'<td class="center">';
436 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>';
438 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>';
443 $htmltooltip =
''.$langs->trans(
"Name").
': '.$module->name;
444 $htmltooltip .=
'<br>'.$langs->trans(
"Type").
': '.($module->type ? $module->type : $langs->trans(
"Unknown"));
445 if ($module->type ==
'pdf') {
446 $htmltooltip .=
'<br>'.$langs->trans(
"Width").
'/'.$langs->trans(
"Height").
': '.$module->page_largeur.
'/'.$module->page_hauteur;
448 $htmltooltip .=
'<br>'.$langs->trans(
"Path").
': '.preg_replace(
'/^\//',
'', $realpath).
'/'.$file;
450 $htmltooltip .=
'<br><br><u>'.$langs->trans(
"FeaturesSupported").
':</u>';
451 $htmltooltip .=
'<br>'.$langs->trans(
"Logo").
': '.
yn($module->option_logo, 1, 1);
452 $htmltooltip .=
'<br>'.$langs->trans(
"PaymentMode").
': '.
yn($module->option_modereg, 1, 1);
453 $htmltooltip .=
'<br>'.$langs->trans(
"PaymentConditions").
': '.
yn($module->option_condreg, 1, 1);
454 $htmltooltip .=
'<br>'.$langs->trans(
"MultiLanguage").
': '.
yn($module->option_multilang, 1, 1);
455 $htmltooltip .=
'<br>'.$langs->trans(
"WatermarkOnDraftOrders").
': '.
yn($module->option_draft_watermark, 1, 1);
458 print
'<td class="center">';
459 print $form->textwithpicto(
'', $htmltooltip, 1, 0);
463 print
'<td class="center">';
464 if ($module->type ==
'pdf') {
465 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=specimen&module='.$name.
'">'.
img_object($langs->trans(
"Preview"),
'pdf').
'</a>';
467 print
img_object($langs->trans(
"PreviewNotAvailable"),
'generic');
490print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="post">';
491print
'<input type="hidden" name="token" value="'.newToken().
'">';
492print
'<input type="hidden" name="action" value="set_other">';
496print
'<div class="div-table-responsive-no-min">';
497print
'<table class="noborder centpercent">';
498print
'<tr class="liste_titre">';
499print
'<td>'.$langs->trans(
"Parameter").
'</td>';
500print
'<td class="right">'.$langs->trans(
"Value").
'</td>';
504$substitutionarray[
'__(AnyTranslationKey)__'] = $langs->trans(
"Translation");
505$htmltext =
'<i>'.$langs->trans(
"AvailableVariables").
':<br>';
506foreach ($substitutionarray as $key => $val) {
507 $htmltext .= $key.
'<br>';
511print
'<tr class="oddeven"><td colspan="2">';
512print $form->textwithpicto($langs->trans(
"FreeLegalTextOnContracts"), $langs->trans(
"AddCRIfTooLong").
'<br><br>'.$htmltext, 1,
'help',
'', 0, 2,
'tooltiphelp');
514$variablename =
'CONTRACT_FREE_TEXT';
516 print
'<textarea name="'.$variablename.
'" class="flat" cols="120">'.
getDolGlobalString($variablename).
'</textarea>';
518 include_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
520 print $doleditor->Create();
522print
'</td></tr>'.
"\n";
526print
'<tr class="oddeven"><td>';
527print $form->textwithpicto($langs->trans(
"WatermarkOnDraftContractCards"), $htmltext, 1,
'help',
'', 0, 2,
'watermarktooltip').
'<br>';
528print
'</td><td class="right">';
529print
'<input class="flat minwidth200" type="text" name="CONTRACT_DRAFT_WATERMARK" value="'.dol_escape_htmltag(
getDolGlobalString(
'CONTRACT_DRAFT_WATERMARK')).
'">';
530print
'</td></tr>'.
"\n";
532print
'<tr class="oddeven">';
533print
'<td>'.$langs->trans(
"HideClosedServiceByDefault").
'</td>';
534print
'<td class="right">';
535print $form->selectyesno(
"activate_hideClosedServiceByDefault",
getDolGlobalInt(
'CONTRACT_HIDE_CLOSED_SERVICES_BY_DEFAULT', 0), 1);
540print
'<tr class="oddeven">';
541print
'<td>'.$langs->trans(
"AllowOnlineSign").
'</td>';
542print
'<td class="right">';
543if (
$conf->use_javascript_ajax) {
544 print ajax_constantonoff(
'CONTRACT_ALLOW_ONLINESIGN', array(),
null, 0, 0, 0, 2, 0, 1,
'',
'',
'inline-block', 0, $langs->trans(
"WarningOnlineSignature"));
547 print
'<a class="reposition" href="'.$_SERVER[
"PHP_SELF"].
'?action=allowonlinesign&token='.
newToken().
'&value=0">';
548 print
img_picto($langs->trans(
"Activated"),
'switch_on');
551 print
'<a class="reposition" href="'.$_SERVER[
"PHP_SELF"].
'?action=allowonlinesign&token='.
newToken().
'&value=1">';
552 print
img_picto($langs->trans(
"Disabled"),
'switch_off');
560print
'<tr class="oddeven">';
561print
'<td>'.$langs->trans(
"AllowExternalDownload").
'</td>';
562print
'<td class="right">';
563print ajax_constantonoff(
'CONTRACT_ALLOW_EXTERNAL_DOWNLOAD', array(),
null, 0, 0, 0, 2, 0, 1);
569print $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($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.
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)
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_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'.
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).
$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.