diff --git a/htdocs/admin/agenda_extsites.php b/htdocs/admin/agenda_extsites.php
index 272da835741..d689b2df8af 100644
--- a/htdocs/admin/agenda_extsites.php
+++ b/htdocs/admin/agenda_extsites.php
@@ -41,8 +41,7 @@ if (!$user->admin) {
$langs->loadLangs(array('agenda', 'admin', 'other'));
$def = array();
-$actiontest = GETPOST('test', 'alpha');
-$actionsave = GETPOST('save', 'alpha');
+$action = GETPOST('action', 'alpha');
if (empty($conf->global->AGENDA_EXT_NB)) {
$conf->global->AGENDA_EXT_NB = 5;
@@ -57,14 +56,57 @@ $colorlist = array('BECEDD', 'DDBECE', 'BFDDBE', 'F598B4', 'F68654', 'CBF654', '
* Actions
*/
-if ($actionsave) {
+$error = 0;
+$errors = array();
+
+if (preg_match('/set_(.*)/', $action, $reg)) {
+ $db->begin();
+
+ $code = $reg[1];
+ $value = (GETPOST($code) ? GETPOST($code) : 1);
+
+ $res = dolibarr_set_const($db, $code, $value, 'chaine', 0, '', $conf->entity);
+ if (!$res > 0) {
+ $error++;
+ $errors[] = $db->lasterror();
+ }
+
+ if ($error) {
+ $db->rollback();
+ setEventMessages('', $errors, 'errors');
+ } else {
+ $db->commit();
+ setEventMessage($langs->trans('SetupSaved'));
+ header('Location: ' . $_SERVER["PHP_SELF"]);
+ exit();
+ }
+} elseif (preg_match('/del_(.*)/', $action, $reg)) {
+ $db->begin();
+
+ $code = $reg[1];
+
+ $res = dolibarr_del_const($db, $code, $conf->entity);
+ if (!$res > 0) {
+ $error++;
+ $errors[] = $db->lasterror();
+ }
+
+ if ($error) {
+ $db->rollback();
+ setEventMessages('', $errors, 'errors');
+ } else {
+ $db->commit();
+ setEventMessage($langs->trans('SetupSaved'));
+ header('Location: ' . $_SERVER["PHP_SELF"]);
+ exit();
+ }
+} elseif ($action == 'save') {
$db->begin();
$disableext = GETPOST('AGENDA_DISABLE_EXT', 'alpha');
$res = dolibarr_set_const($db, 'AGENDA_DISABLE_EXT', $disableext, 'chaine', 0, '', $conf->entity);
$i = 1; $errorsaved = 0;
- $error = 0;
// Save agendas
while ($i <= $MAXAGENDA) {
@@ -159,6 +201,10 @@ print dol_get_fiche_head($head, 'extsites', $langs->trans("Agenda"), -1, 'action
print ''.$langs->trans("AgendaExtSitesDesc")."
\n";
print "
\n";
+
+$selectedvalue=$conf->global->AGENDA_DISABLE_EXT;
+if ($selectedvalue==1) $selectedvalue=0; else $selectedvalue=1;
+
print "
| ".$langs->trans("Name")." | "; print "".$langs->trans("ExtSiteUrlAgenda")." (".$langs->trans("Example").': http://yoursite/agenda/agenda.ics) | '; print "".$form->textwithpicto($langs->trans("FixTZ"), $langs->trans("FillFixTZOnlyIfRequired"), 1).' | '; print ''.$langs->trans("Color").' | '; +print ''.$langs->trans("ActiveByDefault").' | '; print "|||||
| '.$langs->trans("AgendaExtNb", $key)." | "; + print '' . $langs->trans("AgendaExtNb", $key) . " | "; // Name - print ''; + print ' | '; // URL - print ' | '; + print ' | '; // Offset TZ - print ' | '; + print ' | '; // Color (Possible colors are limited by Google) print ' | '; //print $formadmin->selectColor($conf->global->$color, "google_agenda_color".$key, $colorlist); - print $formother->selectColor((GETPOST("AGENDA_EXT_COLOR".$key) ?GETPOST("AGENDA_EXT_COLOR".$key) : getDolGlobalString($color)), "AGENDA_EXT_COLOR".$key, 'extsitesconfig', 1, '', 'hideifnotset'); + print $formother->selectColor((GETPOST("AGENDA_EXT_COLOR" . $key) ? GETPOST("AGENDA_EXT_COLOR" . $key) : getDolGlobalString($color)), "AGENDA_EXT_COLOR" . $key, 'extsitesconfig', 1, '', 'hideifnotset'); + print ' | '; + // Calendar active by default + print ''; + if ($conf->use_javascript_ajax) { + print ajax_constantonoff('AGENDA_EXT_ACTIVEBYDEFAULT' . $key); + } else { + if (empty($conf->global->{$default})) { + print '' . img_picto($langs->trans("Enabled"), 'on') . ''; + } else { + print '' . img_picto($langs->trans("Disabled"), 'off') . ''; + } + } print ' | '; print "