{{* ---------- Gestion des calendriers (ajout / suppression, admin) ---------- *}} {{#form on="add_calendrier"}} {{if $_POST.add_calendrier && $est_admin}} {{* Nom déjà existant ? *}} {{if $_POST.nom_calendrier}} {{#load where="$$.type = 'calendrier' AND $$.nom = '%s'"|args:$_POST.nom_calendrier}} {{:error message="Le nom du calendrier existe déjà."}} {{/load}} {{else}} {{:error message="Le nom du calendrier doit être renseigné."}} {{/if}} {{if $_POST.pardefaut == true}} {{* enlève le flag à un des autres calendriers *}} {{#load where="$$.type = 'calendrier' AND $$.par_defaut = true"|args:$_POST.nom_calendrier}} {{:assign var="_id_cal" value=$id}} {{/load}} {{if $_id_cal}} {{:save type="calendrier" id=$_id_cal par_defaut=false}} {{/if}} {{:assign _pardef=true}} {{else}} {{:assign _pardef=false}} {{/if}} {{:save type="calendrier" nom=$_POST.nom_calendrier par_defaut=$_pardef couleur=$_POST.couleur}} {{:redirect url="index.html?nav=conf&conf=manage_cal&msg=ajout"}} {{/if}} {{else}} {{:form_errors}} {{/form}} {{* Modifier un calendrier *}} {{#form on="mod_calendrier"}} {{:debug p=$_POST}} {{* vérifications *}} {{if !$_POST.mod_calendrier && !$est_admin}} {{:error message="Le calendrier n'existe pas."}} {{/if}} {{* Nom déjà existant ? *}} {{if $_POST.nom_calendrier}} {{#load where="$$.type = 'calendrier' AND $$.nom = '%s' AND id <> %d"|args:$_POST.nom_calendrier:$_POST.mod_calendrier}} {{:error message="Le nom du calendrier existe déjà."}} {{/load}} {{else}} {{:error message="Le nom du calendrier doit être renseigné."}} {{/if}} {{* Par défaut déjà existant ? *}} {{if $_POST.pardefaut == true}} {{* enlève le flag à un des autres calendriers *}} {{#load where="$$.type = 'calendrier' AND $$.par_defaut = true"|args:$_POST.nom_calendrier}} {{:assign var="_id_cal" value=$id}} {{/load}} {{if $_id_cal}} {{:save type="calendrier" id=$_id_cal par_defaut=false}} {{/if}} {{:assign _pardef=true}} {{else}} {{:assign _pardef=false}} {{/if}} {{:save type="calendrier" id=$_POST.mod_calendrier nom=$_POST.nom_calendrier par_defaut=$_pardef couleur=$_POST.couleur textecouleur=$_POST.couleur_texte categorie=$_POST.categorie}} {{else}} {{:form_errors}} {{/form}} {{* Supprimer un calendrier *}} {{if $_POST.suppr_calendrier && $est_admin}} {{:assign var="cal_a_suppr" value=$_POST.suppr_calendrier|strval|trim}} {{:assign var="where_reassign" value="$$.calendrier = '%s'"|args:$cal_a_suppr}} {{#load where=$where_reassign}} {{if $type == "event"}} {{:save id=$id type="event" titre=$titre date=$date debut=$debut fin=$fin lieu=$lieu description=$description lien=$lien lien1_label=$lien1_label lien1_url=$lien1_url lien2_label=$lien2_label lien2_url=$lien2_url lien3_label=$lien3_label lien3_url=$lien3_url couleur=$couleur calendrier=""}} {{elseif $type == "permanence"}} {{:save id=$id type="permanence" jour=$jour debut=$debut fin=$fin label=$label lieu=$lieu description=$description date_debut=$date_debut date_fin=$date_fin type_recurrence=$type_recurrence semaine_du_mois=$semaine_du_mois couleur=$couleur exceptions=$exceptions calendrier=""}} {{/if}} {{/load}} {{:delete id=$cal_a_suppr|intval}} {{:redirect url="index.html?nav=conf&conf=manage_cal&msg=suppression"}} {{/if}}