Index: /extensions/event_cats/admin/template/autolog_new.js
===================================================================
--- /extensions/event_cats/admin/template/autolog_new.js	(revision 7692)
+++ /extensions/event_cats/admin/template/autolog_new.js	(revision 7693)
@@ -7,4 +7,5 @@
 // of .tpl file, thus some values below are modified during the HTML page
 // "reading and displaying"
+
 var ec_avoid_infinite_loop      = true;
 var ec_is_creation              = true;
@@ -15,4 +16,12 @@
 var ec_dont_check               = false;
 var ec_selected_old_group       = false;
+var ec_validity_on              = false;
+var m_offset                    = 0;
+var valid_annee                 = 0;
+var valid_mois                  = 0;
+var valid_date                  = 0;
+var valid_heures                = 0;
+var valid_minutes               = 0;
+var valid_timestamp             = 0;
 var ec_err                      = '';
 var ec_selected_img             = '';
@@ -37,4 +46,5 @@
 var ec_selected_code            = '-1';
 var ec_selected_action          = '-1';
+var maintenant                  = new Date();
 var ec_JS_message               = new Array();
 var ec_duplic_codes             = new Array();
@@ -49,11 +59,15 @@
     ec_lists['comment']         = new Array();
 var d                           = document;
-
-/*
-// Function defined in ./plugins/event_cats/admin/template/autolog_new.tpl
+var validity_date               = maintenant;
+
+
 function de(ec_id) {
   return document.getElementById(ec_id);
 }
-*/
+
+function ec_add_0(s) {
+  var s2 = String(s);
+  return (s2.length == 1) ? "0" + s2 : s2 ;
+}
 
 function ec_check_exist_value(ec_id, ec_val) {
@@ -690,4 +704,68 @@
 }
 
+function ec_update_ts() {
+  if (de('ec_valid_date_on_id').checked == '')
+   de('ec_valid_date_on_id').checked = 'checked';
+  valid_annee     = Number(de('ec_validity_year_id').value);
+  valid_mois      = de('ec_validity_month_id').selectedIndex;
+  valid_date      = de('ec_validity_day_id').selectedIndex;
+  valid_heures    = Number(de('ec_validity_time_id').value.match(/^\d+/));
+  valid_minutes   = Number(de('ec_validity_time_id').value.match(/\d+$/));
+  validity_date.setFullYear(valid_annee);
+  validity_date.setMonth(valid_mois);
+  validity_date.setDate(valid_date);
+  validity_date.setHours(valid_heures);
+  validity_date.setMinutes(valid_minutes);
+  validity_date.setSeconds(0);
+  validity_date.setMilliseconds(0);
+  valid_timestamp = validity_date.getTime();
+  // For tests purpose, must be removed
+  de('ec_span_tst_id').innerHTML = 'valid_timestamp&nbsp;: ' + valid_timestamp;
+  // For tests purpose, must be removed
+}
+
+function ec_update_date(v2, k) { // Validity period cannot be less than one minute
+  var v = (isNaN(v2)) ? 0 : Number(v2);
+  if (v < 0) v = 0;
+  switch (k) {
+    case 0  :
+      valid_timestamp += v * 60000;
+      validity_date.setTime(valid_timestamp);
+    break;
+    case 1  :
+      valid_timestamp += v * 3600000;
+      validity_date.setTime(valid_timestamp);
+    break;
+    case 2  :
+      valid_timestamp += v * 86400000;
+      validity_date.setTime(valid_timestamp);
+    break;
+    case 3  :
+      valid_annee  = Number(de('ec_validity_year_id').value);
+      var m        = de('ec_validity_month_id').selectedIndex + v;
+      valid_mois   = m % 12;
+      valid_annee += Math.floor(m / 12);
+      validity_date.setFullYear(valid_annee);
+      validity_date.setMonth(valid_mois);
+      valid_timestamp = validity_date.getTime();
+    break;
+    case 4  :
+      valid_annee  = Number(de('ec_validity_year_id').value) + v;
+      validity_date.setFullYear(valid_annee);
+      valid_timestamp = validity_date.getTime();
+    break;
+  }
+  valid_annee   = validity_date.getFullYear();
+  valid_mois    = validity_date.getMonth();
+  valid_date    = validity_date.getDate();
+  valid_heures  = validity_date.getHours();
+  valid_minutes = validity_date.getMinutes();
+  de("ec_validity_year_id").value          = valid_annee;
+  de("ec_validity_month_id").selectedIndex = valid_mois - 1;
+  de("ec_validity_day_id").selectedIndex   = valid_date - 1;
+  de("ec_validity_time_id").value          =
+   ec_add_0(valid_heures) + ":" + ec_add_0(valid_minutes);
+}
+
 function ec_init() {
   ec_selected_old_group                           = false;
@@ -708,4 +786,5 @@
   ec_selected_user                                = '-1';
   ec_selected_code                                = '-1';
+  m_offset                                   = maintenant.getTimezoneOffset();
   de('ec_style_forced_id').innerHTML              = ec_up_code_lbl_forced_txt;
   de('ec_act1_id').value                          = ec_default_action;
@@ -724,4 +803,5 @@
   de('ec_input_action_home').checked              = 'checked';
   de('ec_input_action_home').checked              = '';
+  
   
   if (ec_is_creation) { // Entry creation
Index: /extensions/event_cats/admin/template/autolog_new.tpl
===================================================================
--- /extensions/event_cats/admin/template/autolog_new.tpl	(revision 7692)
+++ /extensions/event_cats/admin/template/autolog_new.tpl	(revision 7693)
@@ -63,5 +63,5 @@
     {if $ec_is_creation}
       <br><br>
-      <input class = "submit" type = "button" name = "ec_submit_gen_full_auto" value = "{'Full auto'|@translate}"
+      <input class = "submit" type = "button" value = "{'Full auto'|@translate}"
        id = "ec_submit_gen_full_auto_id" onclick = "ec_gen_full_auto();" style = "margin-top:0;"/>
     {/if}
@@ -88,5 +88,5 @@
           <span {$ec_hidden_when_no_code} >&nbsp;</span>
           <label for = "ec_in_up_code_id" style = "margin:0;">
-            <input class = "submit" type = "button" name = "ec_submit_gen_code" value = "{'Auto code button'|@translate}"
+            <input class = "submit" type = "button" value = "{'Auto code button'|@translate}"
              id = "ec_submit_gen_code_id" onclick = "ec_gen_code();" style = "margin:0;"
            >
@@ -194,5 +194,5 @@
           <span {$ec_hidden_when_no_user} >&nbsp;</span>
           <label for = "ec_in_up_usr_txt_id" style = "margin:0;">
-            <input class = "submit" type = "button" name = "ec_submit_gen_user" value = "{'Generate username'|@translate}"
+            <input class = "submit" type = "button" value = "{'Generate username'|@translate}"
              id = "ec_submit_gen_user_id" onclick = "ec_gen_user();"
            >
@@ -315,5 +315,5 @@
     <table style = "margin-left: 0px; text-align:left;">
       <tr>
-        <td style="vertical-align:top;">
+        <td style="vertical-align:top; margin-top:0;">
           <p style = "text-align:left; margin-bottom:0.5em;">
             <label for = "ec_valid_date_on_id">
@@ -323,5 +323,5 @@
           </p>
           <p style = "text-align:left;">
-            <select id = "ec_validity_day_id" name = "ec_validity_day">
+            <select id = "ec_validity_day_id" name = "ec_validity_day" onchange = "ec_update_ts();">
               <option value = "0">--</option>
               {section name=day start=1 loop=32}
@@ -331,38 +331,34 @@
               {/section}
             </select>
-            <select id = "ec_validity_month_id" name = "ec_validity_month">
+            <select id = "ec_validity_month_id" name = "ec_validity_month" onchange = "ec_update_ts();">
               {html_options options=$month_list}
             </select>
-            <input id = "ec_validity_year_id" name = "ec_validity_year" type = "text" size = "4" maxlength = "4" value = "">
-            <input id = "ec_validity_time_id" name = "ec_validity_time" type = "text" size = "5" maxlength = "5" value = "">
-            
-            <script type = "text/javascript"><!--
-              {literal}
-                function de(ec_id) {
-                  return document.getElementById(ec_id);
-                }
-                var maintenant = new Date();
-                var local_date = maintenant;
-                var m_offset = maintenant.getTimezoneOffset();
-                local_date.setTime(maintenant.getTime() + m_offset);
-                var mlocal_annee = local_date.getFullYear();
-                var mlocal_mois = local_date.getMonth() + 1; // In JavaScript, January is 0 and December is 11
-                var mlocal_date = local_date.getDay();
-                var mlocal_heures = local_date.getHours();
-                var mlocal_minutes = local_date.getMinutes() + 1; // Validity period cannot be less than one minute
-                de("ec_validity_day_id").selectedIndex = mlocal_date - 1;
-                de("ec_validity_month_id").selectedIndex = mlocal_mois - 1;
-                de("ec_validity_year_id").value = mlocal_annee;
-                de("ec_validity_time_id").value = mlocal_heures + ":" + mlocal_minutes;
-              {/literal}
-              // -->
-            </script>
+            <input id = "ec_validity_year_id" name = "ec_validity_year" type = "text" size = "4" maxlength = "4" value = "" onchange = "ec_update_ts();">
+            <input id = "ec_validity_time_id" name = "ec_validity_time" type = "text" size = "5" maxlength = "5" value = "" onchange = "ec_update_ts();">
             
             {* <!-- ec_linked_date_id représente la date indiquée par les listes déroulantes, et permet de limiter
                     le choix dans la date, en l'occurrence à des dates uniquement postérieures (grâce au 6° paramètre de pwg_initialization_datepicker) --> *}
             <input id = "ec_linked_date_id" name = "ec_linked_date" type = "hidden" size = "10" disabled = "disabled">
-            <script type = "text/javascript">
-            </script><br>
           </p>
+          <p style = "text-align:left;">
+            <input id = "ec_date_add_btn_id" type = "button" value = "Ajouter"
+             onclick = "ec_update_date(document.getElementById('ec_date_add_val_id').value, document.getElementById('ec_date_add_kind_id').selectedIndex);">&nbsp;
+            <input id = "ec_date_add_val_id" type = "text" size = "5" maxlength = "5" value = "">&nbsp;
+            <select id = "ec_date_add_kind_id" name = "ec_date_add_kind">
+              <option label = "minute(s)" value = "minutes">minute(s)</option>
+              <option label = "heure(s)"  value = "hours"  >heure(s)</option>
+              <option label = "jour(s)"   value = "days"   >jour(s)</option>
+              <option label = "mois"      value = "months" >mois</option>
+              <option label = "année(s)"  value = "years"  >année(s)</option>
+            </select>
+          </p>
+          <p style = "text-align:left;">
+            <input id = "ec_date_today_btn_id" type = "button" value = "Aujourd'hui" onclick = "">
+          </p>
+          {* <!-- For tests purpose ; must be removed --> *}
+          <p style = "text-align:left;">
+            <span id = "ec_span_tst_id"></span>
+          </p>
+          {* <!-- /For tests purpose ; must be removed --> *}
         </td>
         
@@ -411,4 +407,6 @@
 <script type = "text/javascript"><!--
   ec_is_creation                          = {if $ec_is_creation}true{else}false{/if};
+  ec_validity_on                          = {if $ec_validity_on}true{else}false{/if};
+  valid_timestamp                         = 0{$valid_timestamp};
   ec_up_code_lbl_forced_txt               = "{'Forced'|@translate}";
   ec_JS_message['ec_gen_user_act_miss']   = "{'ec_gen_user_act_miss'|@translate|@escape:javascript}";
@@ -441,7 +439,7 @@
   {/foreach}
   ec_build_ec_lists();
-  ec_init();
   pwg_initialization_datepicker("#ec_validity_day_id", "#ec_validity_month_id",
    "#ec_validity_year_id", "#ec_linked_date_id", null, "#ec_linked_date_id");
+  ec_init();
   //-->
 </script>
