holiday.php 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574
  1. <?php
  2. /* Copyright (C) 2011-2019 Juanjo Menent <jmenent@2byte.es>
  3. * Copyright (C) 2011-2018 Philippe Grand <philippe.grand@atoo-net.com>
  4. * Copyright (C) 2018 Charlene Benke <charlie@patas-monkey.com>
  5. * Copyright (C) 2018 Frédéric France <frederic.france@netlogic.fr>
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 3 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  19. */
  20. /**
  21. * \file htdocs/admin/contract.php
  22. * \ingroup contract
  23. * \brief Setup page of module Contracts
  24. */
  25. // Load Dolibarr environment
  26. require '../main.inc.php';
  27. require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
  28. require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php';
  29. require_once DOL_DOCUMENT_ROOT.'/holiday/class/holiday.class.php';
  30. require_once DOL_DOCUMENT_ROOT.'/core/lib/holiday.lib.php';
  31. // Load translation files required by the page
  32. $langs->loadLangs(array("admin", "errors", "holiday"));
  33. if (!$user->admin) {
  34. accessforbidden();
  35. }
  36. $action = GETPOST('action', 'aZ09');
  37. $value = GETPOST('value', 'alpha');
  38. $modulepart = GETPOST('modulepart', 'aZ09'); // Used by actions_setmoduleoptions.inc.php
  39. $label = GETPOST('label', 'alpha');
  40. $scandir = GETPOST('scan_dir', 'alpha');
  41. $type = 'contract';
  42. if (!getDolGlobalString('HOLIDAY_ADDON')) {
  43. $conf->global->HOLIDAY_ADDON = 'mod_holiday_madonna';
  44. }
  45. /*
  46. * Actions
  47. */
  48. include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
  49. if ($action == 'updateMask') {
  50. $maskconst = GETPOST('maskconstholiday', 'aZ09');
  51. $maskvalue = GETPOST('maskholiday', 'alpha');
  52. if ($maskconst && preg_match('/_MASK$/', $maskconst)) {
  53. $res = dolibarr_set_const($db, $maskconst, $maskvalue, 'chaine', 0, '', $conf->entity);
  54. }
  55. if (!($res > 0)) {
  56. $error++;
  57. }
  58. if (!$error) {
  59. setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
  60. } else {
  61. setEventMessages($langs->trans("Error"), null, 'errors');
  62. }
  63. } elseif ($action == 'specimen') { // For contract
  64. $modele = GETPOST('module', 'alpha');
  65. $holiday = new Holiday($db);
  66. $holiday->initAsSpecimen();
  67. // Search template files
  68. $file = '';
  69. $classname = '';
  70. $filefound = 0;
  71. $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
  72. foreach ($dirmodels as $reldir) {
  73. $file = dol_buildpath($reldir."core/modules/holiday/doc/pdf_".$modele.".modules.php", 0);
  74. if (file_exists($file)) {
  75. $filefound = 1;
  76. $classname = "pdf_".$modele;
  77. break;
  78. }
  79. }
  80. if ($filefound) {
  81. require_once $file;
  82. $module = new $classname($db);
  83. if ($module->write_file($holiday, $langs) > 0) {
  84. header("Location: ".DOL_URL_ROOT."/document.php?modulepart=holiday&file=SPECIMEN.pdf");
  85. return;
  86. } else {
  87. setEventMessages($obj->error, $obj->errors, 'errors');
  88. dol_syslog($obj->error, LOG_ERR);
  89. }
  90. } else {
  91. setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors');
  92. dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR);
  93. }
  94. } elseif ($action == 'set') {
  95. // Activate a model
  96. $ret = addDocumentModel($value, $type, $label, $scandir);
  97. } elseif ($action == 'del') {
  98. $ret = delDocumentModel($value, $type);
  99. if ($ret > 0) {
  100. if ($conf->global->HOLIDAY_ADDON_PDF == "$value") {
  101. dolibarr_del_const($db, 'HOLIDAY_ADDON_PDF', $conf->entity);
  102. }
  103. }
  104. } elseif ($action == 'setdoc') {
  105. // Set default model
  106. if (dolibarr_set_const($db, "HOLIDAY_ADDON_PDF", $value, 'chaine', 0, '', $conf->entity)) {
  107. // La constante qui a ete lue en avant du nouveau set
  108. // on passe donc par une variable pour avoir un affichage coherent
  109. $conf->global->HOLIDAY_ADDON_PDF = $value;
  110. }
  111. // On active le modele
  112. $ret = delDocumentModel($value, $type);
  113. if ($ret > 0) {
  114. $ret = addDocumentModel($value, $type, $label, $scandir);
  115. }
  116. } elseif ($action == 'setmod') {
  117. // TODO Verifier si module numerotation choisi peut etre active
  118. // par appel methode canBeActivated
  119. dolibarr_set_const($db, "HOLIDAY_ADDON", $value, 'chaine', 0, '', $conf->entity);
  120. } elseif ($action == 'set_other') {
  121. $freetext = GETPOST('HOLIDAY_FREE_TEXT', 'restricthtml'); // No alpha here, we want exact string
  122. $res1 = dolibarr_set_const($db, "HOLIDAY_FREE_TEXT", $freetext, 'chaine', 0, '', $conf->entity);
  123. $draft = GETPOST('HOLIDAY_DRAFT_WATERMARK', 'alpha');
  124. $res2 = dolibarr_set_const($db, "HOLIDAY_DRAFT_WATERMARK", trim($draft), 'chaine', 0, '', $conf->entity);
  125. if (!($res1 > 0) || !($res2 > 0)) {
  126. $error++;
  127. }
  128. if (!$error) {
  129. setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
  130. } else {
  131. setEventMessages($langs->trans("Error"), null, 'errors');
  132. }
  133. }
  134. /*
  135. * View
  136. */
  137. $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
  138. llxHeader();
  139. $form = new Form($db);
  140. $linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
  141. print load_fiche_titre($langs->trans("HolidaySetup"), $linkback, 'title_setup');
  142. $head = holiday_admin_prepare_head();
  143. print dol_get_fiche_head($head, 'holiday', $langs->trans("Holidays"), -1, 'holiday');
  144. /*
  145. * Holiday Numbering model
  146. */
  147. print load_fiche_titre($langs->trans("HolidaysNumberingModules"), '', '');
  148. print '<div class="div-table-responsive-no-min">';
  149. print '<table class="noborder centpercent">';
  150. print '<tr class="liste_titre">';
  151. print '<td width="100">'.$langs->trans("Name").'</td>';
  152. print '<td>'.$langs->trans("Description").'</td>';
  153. print '<td>'.$langs->trans("Example").'</td>';
  154. print '<td align="center" width="60">'.$langs->trans("Status").'</td>';
  155. print '<td align="center" width="16">'.$langs->trans("ShortInfo").'</td>';
  156. print "</tr>\n";
  157. clearstatcache();
  158. foreach ($dirmodels as $reldir) {
  159. $dir = dol_buildpath($reldir."core/modules/holiday/");
  160. if (is_dir($dir)) {
  161. $handle = opendir($dir);
  162. if (is_resource($handle)) {
  163. while (($file = readdir($handle)) !== false) {
  164. if (substr($file, 0, 12) == 'mod_holiday_' && substr($file, dol_strlen($file) - 3, 3) == 'php') {
  165. $file = substr($file, 0, dol_strlen($file) - 4);
  166. require_once $dir.$file.'.php';
  167. $module = new $file($db);
  168. // Show modules according to features level
  169. if ($module->version == 'development' && getDolGlobalInt('MAIN_FEATURES_LEVEL') < 2) {
  170. continue;
  171. }
  172. if ($module->version == 'experimental' && getDolGlobalInt('MAIN_FEATURES_LEVEL') < 1) {
  173. continue;
  174. }
  175. if ($module->isEnabled()) {
  176. print '<tr class="oddeven"><td>'.$module->nom."</td><td>\n";
  177. print $module->info($langs);
  178. print '</td>';
  179. // Show example of numbering model
  180. print '<td class="nowrap">';
  181. $tmp = $module->getExample();
  182. if (preg_match('/^Error/', $tmp)) {
  183. $langs->load("errors");
  184. print '<div class="error">'.$langs->trans($tmp).'</div>';
  185. } elseif ($tmp == 'NotConfigured') {
  186. print '<span class="opacitymedium">'.$langs->trans($tmp).'</span>';
  187. } else {
  188. print $tmp;
  189. }
  190. print '</td>'."\n";
  191. print '<td class="center">';
  192. if ($conf->global->HOLIDAY_ADDON == "$file") {
  193. print img_picto($langs->trans("Activated"), 'switch_on');
  194. } else {
  195. print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setmod&token='.newToken().'&value='.urlencode($file).'">';
  196. print img_picto($langs->trans("Disabled"), 'switch_off');
  197. print '</a>';
  198. }
  199. print '</td>';
  200. $holiday = new Holiday($db);
  201. $holiday->initAsSpecimen();
  202. // Info
  203. $htmltooltip = '';
  204. $htmltooltip .= ''.$langs->trans("Version").': <b>'.$module->getVersion().'</b><br>';
  205. $nextval = $module->getNextValue($mysoc, $holiday);
  206. if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval
  207. $htmltooltip .= ''.$langs->trans("NextValue").': ';
  208. if ($nextval) {
  209. if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') {
  210. $nextval = $langs->trans($nextval);
  211. }
  212. $htmltooltip .= $nextval.'<br>';
  213. } else {
  214. $htmltooltip .= $langs->trans($module->error).'<br>';
  215. }
  216. }
  217. print '<td class="center">';
  218. print $form->textwithpicto('', $htmltooltip, 1, 0);
  219. print '</td>';
  220. print '</tr>';
  221. }
  222. }
  223. }
  224. closedir($handle);
  225. }
  226. }
  227. }
  228. print '</table>';
  229. print '</div>';
  230. print '<br>';
  231. /*
  232. * Documents models for Holidays
  233. */
  234. if (getDolGlobalInt('MAIN_FEATURES_LEVEL') >= 2) {
  235. print load_fiche_titre($langs->trans("TemplatePDFHolidays"), '', '');
  236. // Defined model definition table
  237. $def = array();
  238. $sql = "SELECT nom";
  239. $sql .= " FROM ".MAIN_DB_PREFIX."document_model";
  240. $sql .= " WHERE type = '".$db->escape($type)."'";
  241. $sql .= " AND entity = ".$conf->entity;
  242. $resql = $db->query($sql);
  243. if ($resql) {
  244. $i = 0;
  245. $num_rows = $db->num_rows($resql);
  246. while ($i < $num_rows) {
  247. $array = $db->fetch_array($resql);
  248. array_push($def, $array[0]);
  249. $i++;
  250. }
  251. } else {
  252. dol_print_error($db);
  253. }
  254. print '<div class="div-table-responsive-no-min">';
  255. print '<table class="noborder centpercent">';
  256. print '<tr class="liste_titre">';
  257. print '<td>'.$langs->trans("Name").'</td>';
  258. print '<td>'.$langs->trans("Description").'</td>';
  259. print '<td align="center" width="60">'.$langs->trans("Status")."</td>\n";
  260. print '<td align="center" width="60">'.$langs->trans("Default")."</td>\n";
  261. print '<td align="center" width="80">'.$langs->trans("ShortInfo").'</td>';
  262. print '<td align="center" width="80">'.$langs->trans("Preview").'</td>';
  263. print "</tr>\n";
  264. clearstatcache();
  265. foreach ($dirmodels as $reldir) {
  266. foreach (array('', '/doc') as $valdir) {
  267. $realpath = $reldir."core/modules/holiday".$valdir;
  268. $dir = dol_buildpath($realpath);
  269. if (is_dir($dir)) {
  270. $handle = opendir($dir);
  271. if (is_resource($handle)) {
  272. while (($file = readdir($handle)) !== false) {
  273. $filelist[] = $file;
  274. }
  275. closedir($handle);
  276. arsort($filelist);
  277. foreach ($filelist as $file) {
  278. if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) {
  279. if (file_exists($dir.'/'.$file)) {
  280. $name = substr($file, 4, dol_strlen($file) - 16);
  281. $classname = substr($file, 0, dol_strlen($file) - 12);
  282. require_once $dir.'/'.$file;
  283. $module = new $classname($db);
  284. $modulequalified = 1;
  285. if ($module->version == 'development' && getDolGlobalInt('MAIN_FEATURES_LEVEL') < 2) {
  286. $modulequalified = 0;
  287. }
  288. if ($module->version == 'experimental' && getDolGlobalInt('MAIN_FEATURES_LEVEL') < 1) {
  289. $modulequalified = 0;
  290. }
  291. if ($modulequalified) {
  292. print '<tr class="oddeven"><td width="100">';
  293. print(empty($module->name) ? $name : $module->name);
  294. print "</td><td>\n";
  295. if (method_exists($module, 'info')) {
  296. print $module->info($langs);
  297. } else {
  298. print $module->description;
  299. }
  300. print '</td>';
  301. // Active
  302. if (in_array($name, $def)) {
  303. print '<td class="center">'."\n";
  304. print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=del&token='.newToken().'&value='.urlencode($name).'">';
  305. print img_picto($langs->trans("Enabled"), 'switch_on');
  306. print '</a>';
  307. print '</td>';
  308. } else {
  309. print '<td class="center">'."\n";
  310. 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>';
  311. print "</td>";
  312. }
  313. // Default
  314. print '<td class="center">';
  315. if ($conf->global->HOLIDAY_ADDON_PDF == $name) {
  316. print img_picto($langs->trans("Default"), 'on');
  317. } else {
  318. 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>';
  319. }
  320. print '</td>';
  321. // Info
  322. $htmltooltip = ''.$langs->trans("Name").': '.$module->name;
  323. $htmltooltip .= '<br>'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown"));
  324. if ($module->type == 'pdf') {
  325. $htmltooltip .= '<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur;
  326. }
  327. $htmltooltip .= '<br>'.$langs->trans("Path").': '.preg_replace('/^\//', '', $realpath).'/'.$file;
  328. $htmltooltip .= '<br><br><u>'.$langs->trans("FeaturesSupported").':</u>';
  329. $htmltooltip .= '<br>'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1);
  330. $htmltooltip .= '<br>'.$langs->trans("PaymentMode").': '.yn($module->option_modereg, 1, 1);
  331. $htmltooltip .= '<br>'.$langs->trans("PaymentConditions").': '.yn($module->option_condreg, 1, 1);
  332. $htmltooltip .= '<br>'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1);
  333. $htmltooltip .= '<br>'.$langs->trans("WatermarkOnDraftOrders").': '.yn($module->option_draft_watermark, 1, 1);
  334. print '<td class="center">';
  335. print $form->textwithpicto('', $htmltooltip, 1, 0);
  336. print '</td>';
  337. // Preview
  338. print '<td class="center">';
  339. if ($module->type == 'pdf') {
  340. print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.$name.'">'.img_object($langs->trans("Preview"), 'pdf').'</a>';
  341. } else {
  342. print img_object($langs->trans("PreviewNotAvailable"), 'generic');
  343. }
  344. print '</td>';
  345. print "</tr>\n";
  346. }
  347. }
  348. }
  349. }
  350. }
  351. }
  352. }
  353. }
  354. print '</table>';
  355. print '</div>';
  356. print "<br>";
  357. }
  358. /*
  359. * Other options
  360. */
  361. print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
  362. print '<input type="hidden" name="token" value="'.newToken().'">';
  363. print '<input type="hidden" name="action" value="set_other">';
  364. print load_fiche_titre($langs->trans("OtherOptions"), '', '');
  365. print '<div class="div-table-responsive-no-min">';
  366. print '<table class="noborder centpercent">';
  367. print '<tr class="liste_titre">';
  368. print '<td>'.$langs->trans("Parameter").'</td>';
  369. print '<td align="center" width="60">'.$langs->trans("Value").'</td>';
  370. print "</tr>\n";
  371. //var_dump($conf->global->MAIN_NON_WORKING_DAYS_INCLUDE_MONDAY);
  372. //var_dump($conf->global->MAIN_NON_WORKING_DAYS_INCLUDE_FRIDAY);
  373. //var_dump($conf->global->MAIN_NON_WORKING_DAYS_INCLUDE_SATURDAY);
  374. //var_dump($conf->global->MAIN_NON_WORKING_DAYS_INCLUDE_SUNDAY);
  375. if (!isset($conf->global->MAIN_NON_WORKING_DAYS_INCLUDE_SATURDAY)) {
  376. $conf->global->MAIN_NON_WORKING_DAYS_INCLUDE_SATURDAY = 1;
  377. }
  378. if (!isset($conf->global->MAIN_NON_WORKING_DAYS_INCLUDE_SUNDAY)) {
  379. $conf->global->MAIN_NON_WORKING_DAYS_INCLUDE_SUNDAY = 1;
  380. }
  381. //var_dump($conf->global->MAIN_NON_WORKING_DAYS_INCLUDE_MONDAY);
  382. //var_dump($conf->global->MAIN_NON_WORKING_DAYS_INCLUDE_FRIDAY);
  383. //var_dump($conf->global->MAIN_NON_WORKING_DAYS_INCLUDE_SATURDAY);
  384. //var_dump($conf->global->MAIN_NON_WORKING_DAYS_INCLUDE_SUNDAY);
  385. // Set working days
  386. print '<tr class="oddeven">';
  387. print "<td>".$langs->trans("XIsAUsualNonWorkingDay", $langs->transnoentitiesnoconv("Monday"))."</td>";
  388. print '<td class="center">';
  389. if ($conf->use_javascript_ajax) {
  390. print ajax_constantonoff('MAIN_NON_WORKING_DAYS_INCLUDE_MONDAY', array(), null, 0);
  391. } else {
  392. if (getDolGlobalString('MAIN_NON_WORKING_DAYS_INCLUDE_MONDAY')) {
  393. print '<a href="'.$_SERVER['PHP_SELF'].'?action=set_other&token='.newToken().'&MAIN_NON_WORKING_DAYS_INCLUDE_MONDAY=1">'.img_picto($langs->trans("Enabled"), 'on').'</a>';
  394. } else {
  395. print '<a href="'.$_SERVER['PHP_SELF'].'?action=set_other&token='.newToken().'&MAIN_NON_WORKING_DAYS_INCLUDE_MONDAY=0">'.img_picto($langs->trans("Disabled"), 'off').'</a>';
  396. }
  397. }
  398. print "</td>";
  399. print "</tr>";
  400. // Set working days
  401. print '<tr class="oddeven">';
  402. print "<td>".$langs->trans("XIsAUsualNonWorkingDay", $langs->transnoentitiesnoconv("Friday"))."</td>";
  403. print '<td class="center">';
  404. if ($conf->use_javascript_ajax) {
  405. print ajax_constantonoff('MAIN_NON_WORKING_DAYS_INCLUDE_FRIDAY', array(), null, 0);
  406. } else {
  407. if (getDolGlobalString('MAIN_NON_WORKING_DAYS_INCLUDE_FRIDAY')) {
  408. print '<a href="'.$_SERVER['PHP_SELF'].'?action=set_other&token='.newToken().'&MAIN_NON_WORKING_DAYS_INCLUDE_FRIDAY=1">'.img_picto($langs->trans("Enabled"), 'on').'</a>';
  409. } else {
  410. print '<a href="'.$_SERVER['PHP_SELF'].'?action=set_other&token='.newToken().'&MAIN_NON_WORKING_DAYS_INCLUDE_FRIDAY=0">'.img_picto($langs->trans("Disabled"), 'off').'</a>';
  411. }
  412. }
  413. print "</td>";
  414. print "</tr>";
  415. // Set working days
  416. print '<tr class="oddeven">';
  417. print "<td>".$langs->trans("XIsAUsualNonWorkingDay", $langs->transnoentitiesnoconv("Saturday"))."</td>";
  418. print '<td class="center">';
  419. if ($conf->use_javascript_ajax) {
  420. print ajax_constantonoff('MAIN_NON_WORKING_DAYS_INCLUDE_SATURDAY', array(), null, 0, 0, 0, 2, 0, 1);
  421. } else {
  422. if (getDolGlobalString('MAIN_NON_WORKING_DAYS_INCLUDE_SATURDAY')) {
  423. print '<a href="'.$_SERVER['PHP_SELF'].'?action=set_other&token='.newToken().'&MAIN_NON_WORKING_DAYS_INCLUDE_SATURDAY=1">'.img_picto($langs->trans("Enabled"), 'on').'</a>';
  424. } else {
  425. print '<a href="'.$_SERVER['PHP_SELF'].'?action=set_other&token='.newToken().'&MAIN_NON_WORKING_DAYS_INCLUDE_SATURDAY=0">'.img_picto($langs->trans("Disabled"), 'off').'</a>';
  426. }
  427. }
  428. print "</td>";
  429. print "</tr>";
  430. // Set working days
  431. print '<tr class="oddeven">';
  432. print "<td>".$langs->trans("XIsAUsualNonWorkingDay", $langs->transnoentitiesnoconv("Sunday"))."</td>";
  433. print '<td class="center">';
  434. if ($conf->use_javascript_ajax) {
  435. print ajax_constantonoff('MAIN_NON_WORKING_DAYS_INCLUDE_SUNDAY', array(), null, 0, 0, 0, 2, 0, 1);
  436. } else {
  437. if (getDolGlobalString('MAIN_NON_WORKING_DAYS_INCLUDE_SUNDAY')) {
  438. print '<a href="'.$_SERVER['PHP_SELF'].'?action=set_other&token='.newToken().'&MAIN_NON_WORKING_DAYS_INCLUDE_SUNDAY=1">'.img_picto($langs->trans("Enabled"), 'on').'</a>';
  439. } else {
  440. print '<a href="'.$_SERVER['PHP_SELF'].'?action=set_other&token='.newToken().'&MAIN_NON_WORKING_DAYS_INCLUDE_SUNDAY=0">'.img_picto($langs->trans("Disabled"), 'off').'</a>';
  441. }
  442. }
  443. print "</td>";
  444. print "</tr>";
  445. if (getDolGlobalInt('MAIN_FEATURES_LEVEL') >= 2) {
  446. $substitutionarray = pdf_getSubstitutionArray($langs, array('objectamount'), null, 2);
  447. $substitutionarray['__(AnyTranslationKey)__'] = $langs->trans("Translation");
  448. $htmltext = '<i>'.$langs->trans("AvailableVariables").':<br>';
  449. foreach ($substitutionarray as $key => $val) {
  450. $htmltext .= $key.'<br>';
  451. }
  452. $htmltext .= '</i>';
  453. print '<tr class="oddeven"><td colspan="2">';
  454. print $form->textwithpicto($langs->trans("FreeLegalTextOnHolidays"), $langs->trans("AddCRIfTooLong").'<br><br>'.$htmltext, 1, 'help', '', 0, 2, 'tooltiphelp');
  455. print '<br>';
  456. $variablename = 'HOLIDAY_FREE_TEXT';
  457. if (!getDolGlobalString('PDF_ALLOW_HTML_FOR_FREE_TEXT')) {
  458. print '<textarea name="'.$variablename.'" class="flat" cols="120">'.getDolGlobalString($variablename).'</textarea>';
  459. } else {
  460. include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
  461. $doleditor = new DolEditor($variablename, getDolGlobalString($variablename), '', 80, 'dolibarr_notes');
  462. print $doleditor->Create();
  463. }
  464. print '</td></tr>'."\n";
  465. //Use draft Watermark
  466. print '<tr class="oddeven"><td>';
  467. print $form->textwithpicto($langs->trans("WatermarkOnDraftHolidayCards"), $htmltext, 1, 'help', '', 0, 2, 'watermarktooltip').'<br>';
  468. print '</td><td>';
  469. print '<input class="flat minwidth200" type="text" name="HOLIDAY_DRAFT_WATERMARK" value="'.dol_escape_htmltag(getDolGlobalString('HOLIDAY_DRAFT_WATERMARK')).'">';
  470. print '</td></tr>'."\n";
  471. }
  472. print '</table>';
  473. print '</div>';
  474. print $form->buttonsSaveCancel("Save", '');
  475. print '</form>';
  476. print dol_get_fiche_end();
  477. // End of page
  478. llxFooter();
  479. $db->close();