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');
66 if ($maskconst && preg_match(
'/_MASK$/', $maskconst)) {
67 $res =
dolibarr_set_const($db, $maskconst, $maskvalue,
'chaine', 0,
'', $conf->entity);
79} elseif ($action ==
'specimen') {
80 $modele =
GETPOST(
'module',
'alpha');
83 $contract->initAsSpecimen();
88 $dirmodels = array_merge(array(
'/'), (array) $conf->modules_parts[
'models']);
89 foreach ($dirmodels as $reldir) {
90 $file =
dol_buildpath($reldir.
"core/modules/contract/doc/pdf_".$modele.
".modules.php", 0);
91 if (file_exists($file)) {
92 $classname =
"pdf_".$modele;
97 if ($classname !==
'') {
100 $module =
new $classname($db);
101 '@phan-var-force ModelePDFContract $module';
104 if ($module->write_file($contract, $langs) > 0) {
105 header(
"Location: ".DOL_URL_ROOT.
"/document.php?modulepart=contract&file=SPECIMEN.pdf");
113 dol_syslog($langs->trans(
"ErrorModuleNotFound"), LOG_ERR);
115} elseif ($action ==
'set') {
118} elseif ($action ==
'del') {
121 if ($conf->global->CONTRACT_ADDON_PDF ==
"$value") {
125} elseif ($action ==
'setdoc') {
127 if (
dolibarr_set_const($db,
"CONTRACT_ADDON_PDF", $value,
'chaine', 0,
'', $conf->entity)) {
130 $conf->global->CONTRACT_ADDON_PDF = $value;
138} elseif ($action ==
'unsetdoc') {
140} elseif ($action ==
'setmod') {
145} elseif ($action ==
'set_other') {
146 $freetext =
GETPOST(
'CONTRACT_FREE_TEXT',
'restricthtml');
147 $res1 =
dolibarr_set_const($db,
"CONTRACT_FREE_TEXT", $freetext,
'chaine', 0,
'', $conf->entity);
149 $draft =
GETPOST(
'CONTRACT_DRAFT_WATERMARK',
'alpha');
150 $res2 =
dolibarr_set_const($db,
"CONTRACT_DRAFT_WATERMARK", trim($draft),
'chaine', 0,
'', $conf->entity);
152 $value =
GETPOST(
'activate_hideClosedServiceByDefault',
'alpha');
153 $res3 =
dolibarr_set_const($db,
"CONTRACT_HIDE_CLOSED_SERVICES_BY_DEFAULT", $value,
'chaine', 0,
'', $conf->entity);
155 if (!($res1 > 0) || !($res2 > 0) || !($res3 > 0)) {
164} elseif ($action ==
"allowonlinesign") {
165 if (!
dolibarr_set_const($db,
"CONTRACT_ALLOW_ONLINESIGN", $value,
'int', 0,
'', $conf->entity)) {
168} elseif (preg_match(
'/set_(.*)/', $action, $reg)) {
181 header(
"Location: " . $_SERVER[
"PHP_SELF"]);
184} elseif (preg_match(
'/del_(.*)/', $action, $reg)) {
196 header(
"Location: " . $_SERVER[
"PHP_SELF"]);
207$dirmodels = array_merge(array(
'/'), (array) $conf->modules_parts[
'models']);
209llxHeader(
'',
'',
'',
'', 0, 0,
'',
'',
'',
'mod-admin page-contract');
211$form =
new Form($db);
213$linkback =
'<a href="'.DOL_URL_ROOT.
'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToModuleList").
'</a>';
214print
load_fiche_titre($langs->trans(
"ContractsSetup"), $linkback,
'title_setup');
218print
dol_get_fiche_head($head,
'contract', $langs->trans(
"Contracts"), -1,
'contract');
226print
'<div class="div-table-responsive-no-min">';
227print
'<table class="noborder centpercent">';
228print
'<tr class="liste_titre">';
229print
'<td width="100">'.$langs->trans(
"Name").
'</td>';
230print
'<td>'.$langs->trans(
"Description").
'</td>';
231print
'<td>'.$langs->trans(
"Example").
'</td>';
232print
'<td class="center" width="60">'.$langs->trans(
"Status").
'</td>';
233print
'<td class="center" width="16">'.$langs->trans(
"ShortInfo").
'</td>';
238foreach ($dirmodels as $reldir) {
242 $handle = opendir($dir);
243 if (is_resource($handle)) {
244 while (($file = readdir($handle)) !==
false) {
245 if (substr($file, 0, 13) ==
'mod_contract_' && substr($file,
dol_strlen($file) - 3, 3) ==
'php') {
246 $file = substr($file, 0,
dol_strlen($file) - 4);
248 require_once $dir.$file.
'.php';
250 $module =
new $file($db);
252 '@phan-var-force ModelNumRefContracts $module';
255 if ($module->version ==
'development' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 2) {
258 if ($module->version ==
'experimental' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 1) {
262 if ($module->isEnabled()) {
263 print
'<tr class="oddeven"><td>'.$module->name.
"</td><td>\n";
264 print $module->info($langs);
268 print
'<td class="nowrap">';
269 $tmp = $module->getExample();
270 if (preg_match(
'/^Error/', $tmp)) {
271 $langs->load(
"errors");
272 print
'<div class="error">'.$langs->trans($tmp).
'</div>';
273 } elseif ($tmp ==
'NotConfigured') {
274 print
'<span class="opacitymedium">'.$langs->trans($tmp).
'</span>';
280 print
'<td class="center">';
281 if ($conf->global->CONTRACT_ADDON ==
"$file") {
282 print
img_picto($langs->trans(
"Activated"),
'switch_on');
284 print
'<a class="reposition" href="'.$_SERVER[
"PHP_SELF"].
'?action=setmod&token='.
newToken().
'&value='.urlencode($file).
'">';
285 print
img_picto($langs->trans(
"Disabled"),
'switch_off');
291 $contract->initAsSpecimen();
295 $htmltooltip .=
''.$langs->trans(
"Version").
': <b>'.$module->getVersion().
'</b><br>';
296 $nextval = $module->getNextValue($mysoc, $contract);
297 if (
"$nextval" != $langs->trans(
"NotAvailable")) {
298 $htmltooltip .=
''.$langs->trans(
"NextValue").
': ';
300 if (preg_match(
'/^Error/', $nextval) || $nextval ==
'NotConfigured') {
301 $nextval = $langs->trans($nextval);
303 $htmltooltip .= $nextval.
'<br>';
305 $htmltooltip .= $langs->trans($module->error).
'<br>';
309 print
'<td class="center">';
310 print $form->textwithpicto(
'', $htmltooltip, 1, 0);
322print
'</table></div><br>';
333$sql .=
" FROM ".MAIN_DB_PREFIX.
"document_model";
334$sql .=
" WHERE type = '".$db->escape($type).
"'";
335$sql .=
" AND entity = ".$conf->entity;
336$resql = $db->query($sql);
339 $num_rows = $db->num_rows($resql);
340 while ($i < $num_rows) {
341 $array = $db->fetch_array($resql);
342 if (is_array($array)) {
343 array_push($def, $array[0]);
352print
'<div class="div-table-responsive-no-min">';
353print
'<table class="noborder centpercent">';
354print
'<tr class="liste_titre">';
355print
'<td>'.$langs->trans(
"Name").
'</td>';
356print
'<td>'.$langs->trans(
"Description").
'</td>';
357print
'<td class="center" width="60">'.$langs->trans(
"Status").
"</td>\n";
358print
'<td class="center" width="60">'.$langs->trans(
"Default").
"</td>\n";
359print
'<td class="center" width="80">'.$langs->trans(
"ShortInfo").
'</td>';
360print
'<td class="center" width="80">'.$langs->trans(
"Preview").
'</td>';
365foreach ($dirmodels as $reldir) {
366 foreach (array(
'',
'/doc') as $valdir) {
367 $realpath = $reldir.
"core/modules/contract".$valdir;
371 $handle = opendir($dir);
372 if (is_resource($handle)) {
374 while (($file = readdir($handle)) !==
false) {
380 foreach ($filelist as $file) {
381 if (preg_match(
'/\.modules\.php$/i', $file) && preg_match(
'/^(pdf_|doc_)/', $file)) {
382 if (file_exists($dir.
'/'.$file)) {
383 $name = substr($file, 4,
dol_strlen($file) - 16);
384 $classname = substr($file, 0,
dol_strlen($file) - 12);
386 require_once $dir.
'/'.$file;
388 $module =
new $classname($db);
390 '@phan-var-force ModelePDFContract $module';
392 $modulequalified = 1;
393 if ($module->version ==
'development' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 2) {
394 $modulequalified = 0;
396 if ($module->version ==
'experimental' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 1) {
397 $modulequalified = 0;
400 if ($modulequalified) {
401 print
'<tr class="oddeven"><td width="100">';
402 print(empty($module->name) ? $name : $module->
name);
404 if (method_exists($module,
'info')) {
405 print $module->info($langs);
407 print $module->description;
412 if (in_array($name, $def)) {
413 print
'<td class="center">'.
"\n";
414 print
'<a class="reposition" href="'.$_SERVER[
"PHP_SELF"].
'?action=del&token='.
newToken().
'&value='.urlencode($name).
'">';
415 print
img_picto($langs->trans(
"Enabled"),
'switch_on');
419 print
'<td class="center">'.
"\n";
420 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>';
425 print
'<td class="center">';
427 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>';
429 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>';
434 $htmltooltip =
''.$langs->trans(
"Name").
': '.$module->name;
435 $htmltooltip .=
'<br>'.$langs->trans(
"Type").
': '.($module->type ? $module->type : $langs->trans(
"Unknown"));
436 if ($module->type ==
'pdf') {
437 $htmltooltip .=
'<br>'.$langs->trans(
"Width").
'/'.$langs->trans(
"Height").
': '.$module->page_largeur.
'/'.$module->page_hauteur;
439 $htmltooltip .=
'<br>'.$langs->trans(
"Path").
': '.preg_replace(
'/^\//',
'', $realpath).
'/'.$file;
441 $htmltooltip .=
'<br><br><u>'.$langs->trans(
"FeaturesSupported").
':</u>';
442 $htmltooltip .=
'<br>'.$langs->trans(
"Logo").
': '.
yn($module->option_logo, 1, 1);
443 $htmltooltip .=
'<br>'.$langs->trans(
"PaymentMode").
': '.
yn($module->option_modereg, 1, 1);
444 $htmltooltip .=
'<br>'.$langs->trans(
"PaymentConditions").
': '.
yn($module->option_condreg, 1, 1);
445 $htmltooltip .=
'<br>'.$langs->trans(
"MultiLanguage").
': '.
yn($module->option_multilang, 1, 1);
446 $htmltooltip .=
'<br>'.$langs->trans(
"WatermarkOnDraftOrders").
': '.
yn($module->option_draft_watermark, 1, 1);
449 print
'<td class="center">';
450 print $form->textwithpicto(
'', $htmltooltip, 1, 0);
454 print
'<td class="center">';
455 if ($module->type ==
'pdf') {
456 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=specimen&module='.$name.
'">'.
img_object($langs->trans(
"Preview"),
'pdf').
'</a>';
458 print
img_object($langs->trans(
"PreviewNotAvailable"),
'generic');
481print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="post">';
482print
'<input type="hidden" name="token" value="'.newToken().
'">';
483print
'<input type="hidden" name="action" value="set_other">';
487print
'<div class="div-table-responsive-no-min">';
488print
'<table class="noborder centpercent">';
489print
'<tr class="liste_titre">';
490print
'<td>'.$langs->trans(
"Parameter").
'</td>';
491print
'<td class="right">'.$langs->trans(
"Value").
'</td>';
495$substitutionarray[
'__(AnyTranslationKey)__'] = $langs->trans(
"Translation");
496$htmltext =
'<i>'.$langs->trans(
"AvailableVariables").
':<br>';
497foreach ($substitutionarray as $key => $val) {
498 $htmltext .= $key.
'<br>';
502print
'<tr class="oddeven"><td colspan="2">';
503print $form->textwithpicto($langs->trans(
"FreeLegalTextOnContracts"), $langs->trans(
"AddCRIfTooLong").
'<br><br>'.$htmltext, 1,
'help',
'', 0, 2,
'tooltiphelp');
505$variablename =
'CONTRACT_FREE_TEXT';
507 print
'<textarea name="'.$variablename.
'" class="flat" cols="120">'.
getDolGlobalString($variablename).
'</textarea>';
509 include_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
511 print $doleditor->Create();
513print
'</td></tr>'.
"\n";
517print
'<tr class="oddeven"><td>';
518print $form->textwithpicto($langs->trans(
"WatermarkOnDraftContractCards"), $htmltext, 1,
'help',
'', 0, 2,
'watermarktooltip').
'<br>';
519print
'</td><td class="right">';
520print
'<input class="flat minwidth200" type="text" name="CONTRACT_DRAFT_WATERMARK" value="'.dol_escape_htmltag(
getDolGlobalString(
'CONTRACT_DRAFT_WATERMARK')).
'">';
521print
'</td></tr>'.
"\n";
523print
'<tr class="oddeven">';
524print
'<td>'.$langs->trans(
"HideClosedServiceByDefault").
'</td>';
525print
'<td class="right">';
526print $form->selectyesno(
"activate_hideClosedServiceByDefault",
getDolGlobalInt(
'CONTRACT_HIDE_CLOSED_SERVICES_BY_DEFAULT', 0), 1);
531print
'<tr class="oddeven">';
532print
'<td>'.$langs->trans(
"AllowOnlineSign").
'</td>';
533print
'<td class="right">';
535 print
'<a class="reposition" href="'.$_SERVER[
"PHP_SELF"].
'?action=allowonlinesign&token='.
newToken().
'&value=0">';
536 print
img_picto($langs->trans(
"Activated"),
'switch_on');
539 print
'<a class="reposition" href="'.$_SERVER[
"PHP_SELF"].
'?action=allowonlinesign&token='.
newToken().
'&value=1">';
540 print
img_picto($langs->trans(
"Disabled"),
'switch_off');
547print
'<tr class="oddeven">';
548print
'<td>'.$langs->trans(
"AllowExternalDownload").
'</td>';
549print
'<td class="right">';
550print ajax_constantonoff(
'CONTRACT_ALLOW_EXTERNAL_DOWNLOAD', array(),
null, 0, 0, 0, 2, 0, 1);
556print $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.
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.