Changeset 7828


Ignore:
Timestamp:
Nov 21, 2010, 4:47:29 PM (10 years ago)
Author:
LucMorizur
Message:

[Validity date] One step forward

Location:
extensions/event_cats/admin/template
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • extensions/event_cats/admin/template/autolog_new.js

    r7810 r7828  
    1717var ec_selected_old_group       = false;
    1818var ec_validity_on              = false;
    19 var m_offset                    = 0;
     19var m_offset                    = 0; /* // Inutile a priori
    2020var valid_annee                 = 0;
    2121var valid_mois                  = 0;
    2222var valid_date                  = 0;
    2323var valid_heures                = 0;
    24 var valid_minutes               = 0;
     24var valid_minutes               = 0; */
    2525var valid_timestamp             = 0;
    2626var ec_err                      = '';
     
    6161var validity_date               = maintenant;
    6262
    63 
    6463function de(ec_id) {
    6564  return document.getElementById(ec_id);
     
    6867function ec_add_0(s) {
    6968  var s2 = String(s);
    70   return (s2.length == 1) ? "0" + s2 : s2 ;
     69  return (s2.length == 1) ? "0" + s2 : s2;
    7170}
    7271
     
    704703}
    705704
    706 function ec_update_ts() { /*
    707   if (de('ec_valid_date_on_id').checked == '')
     705/* // Inutile a priori
     706function ec_update_ts(c) {
     707  if (c && de('ec_valid_date_on_id').checked == '')
    708708   de('ec_valid_date_on_id').checked = 'checked';
    709   valid_annee     = Number(de('ec_validity_year_id').value);
    710   valid_mois      = de('ec_validity_month_id').selectedIndex;
    711   valid_date      = de('ec_validity_day_id').selectedIndex;
    712   valid_heures    = Number(de('ec_validity_time_id').value.match(/^\d+/));
    713   valid_minutes   = Number(de('ec_validity_time_id').value.match(/\d+$/));
    714   validity_date.setFullYear(valid_annee);
    715   validity_date.setMonth(valid_mois);
    716   validity_date.setDate(valid_date);
    717   validity_date.setHours(valid_heures);
    718   validity_date.setMinutes(valid_minutes);
     709  valid_timestamp = validity_date.getTime();
     710  // For tests purpose, must be removed
     711  de('ec_span_tst_id').innerHTML = 'valid_timestamp : ' + valid_timestamp;
     712  // For tests purpose, must be removed
     713}
     714*/
     715
     716function ec_add_time(v2, k) {
     717  var v = (isNaN(v2)) ? 0 : Number(v2);
     718  var m = 0;
     719  if (v < 0) v = 0;
     720  validity_date.setFullYear(de('ec_validity_year_id').value);
     721  validity_date.setMonth(de('ec_validity_month_id').selectedIndex - 1);
     722  validity_date.setDate(de('ec_validity_day_id').selectedIndex);
     723  validity_date.setHours(de('ec_validity_time_id').value.match(/^\d+/));
     724  validity_date.setMinutes(de('ec_validity_time_id').value.match(/\d+$/));
    719725  validity_date.setSeconds(0);
    720726  validity_date.setMilliseconds(0);
    721727  valid_timestamp = validity_date.getTime();
    722   // For tests purpose, must be removed
    723   de('ec_span_tst_id').innerHTML = 'valid_timestamp&nbsp;: ' + valid_timestamp;
    724   // For tests purpose, must be removed */
    725 }
    726 
    727 function ec_update_date(v2, k) { // Validity period cannot be less than one minute
    728   var v = (isNaN(v2)) ? 0 : Number(v2);
    729   if (v < 0) v = 0;
    730728  switch (k) {
    731     case 0  :
    732       valid_timestamp += v * 60000;
    733       validity_date.setTime(valid_timestamp);
     729    case 0  : // minute(s)
     730      validity_date.setTime(valid_timestamp + (v *    60000));
    734731    break;
    735     case 1  :
    736       valid_timestamp += v * 3600000;
    737       validity_date.setTime(valid_timestamp);
     732    case 1  : // hour(s)
     733      validity_date.setTime(valid_timestamp + (v *  3600000));
    738734    break;
    739     case 2  :
    740       valid_timestamp += v * 86400000;
    741       validity_date.setTime(valid_timestamp);
     735    case 2  : // day(s)
     736      validity_date.setTime(valid_timestamp + (v * 86400000));
    742737    break;
    743     case 3  :
    744       valid_annee  = Number(de('ec_validity_year_id').value);
    745       var m        = de('ec_validity_month_id').selectedIndex + v;
    746       valid_mois   = m % 12;
    747       valid_annee += Math.floor(m / 12);
    748       validity_date.setFullYear(valid_annee);
    749       validity_date.setMonth(valid_mois);
    750       valid_timestamp = validity_date.getTime();
     738    case 3  : // month(s)
     739      m = de('ec_validity_month_id').selectedIndex + v;
     740      validity_date.setFullYear(
     741        Number(de('ec_validity_year_id').value) + Math.floor(m / 12)
     742      );
     743      validity_date.setMonth(m % 12); // % : modulo
    751744    break;
    752     case 4  :
    753       valid_annee  = Number(de('ec_validity_year_id').value) + v;
    754       validity_date.setFullYear(valid_annee);
    755       valid_timestamp = validity_date.getTime();
     745    case 4  : // year(s)
     746      validity_date.setFullYear(Number(de('ec_validity_year_id').value) + v);
    756747    break;
    757748  }
    758   valid_annee   = validity_date.getFullYear();
    759   valid_mois    = validity_date.getMonth();
    760   valid_date    = validity_date.getDate();
    761   valid_heures  = validity_date.getHours();
    762   valid_minutes = validity_date.getMinutes();
    763   de("ec_validity_year_id").value          = valid_annee;
    764   de("ec_validity_month_id").selectedIndex = valid_mois - 1;
    765   de("ec_validity_day_id").selectedIndex   = valid_date - 1;
     749  de("ec_validity_year_id").value          = validity_date.getFullYear();
     750  de("ec_validity_month_id").selectedIndex = validity_date.getMonth() + 1;
     751  de("ec_validity_day_id").selectedIndex   = validity_date.getDate();
    766752  de("ec_validity_time_id").value          =
    767    ec_add_0(valid_heures) + ":" + ec_add_0(valid_minutes);
     753   ec_add_0(validity_date.getHours()) +
     754   ":" +
     755   ec_add_0(validity_date.getMinutes());
    768756}
    769757
     
    803791  de('ec_input_action_home').checked              = 'checked';
    804792  de('ec_input_action_home').checked              = '';
    805  
     793  de("ec_min_year_id").value                      = maintenant.getFullYear();
     794  de("ec_min_month_id").selectedIndex             = maintenant.getMonth() + 1;
     795  de("ec_min_day_id").selectedIndex               = maintenant.getDate();
     796  de("ec_validity_year_id").value                 = maintenant.getFullYear();
     797  de("ec_validity_month_id").selectedIndex        = maintenant.getMonth() + 1;
     798  de("ec_validity_day_id").selectedIndex          = maintenant.getDate();
     799  de("ec_validity_time_id").value                 =
     800   ec_add_0(maintenant.getHours()) +
     801   ":" +
     802   ec_add_0(maintenant.getMinutes());
     803  pwg_initialization_datepicker("#ec_min_day_id", "#ec_min_month_id",
     804   "#ec_min_year_id", "#ec_min_date_id", null, null, null);
     805  pwg_initialization_datepicker("#ec_validity_day_id",
     806   "#ec_validity_month_id", "#ec_validity_year_id", "#ec_linked_date_id",
     807   null, "#ec_min_date_id", null);
    806808 
    807809  if (ec_is_creation) { // Entry creation
  • extensions/event_cats/admin/template/autolog_new.tpl

    r7811 r7828  
    324324  <fieldset>
    325325    <legend style = "font-weight:bold;">Date de validité</legend>
    326    
    327326    <table style = "margin-left: 0px; text-align:left;">
    328327      <tr>
     328       
    329329        <td style="vertical-align:top; margin-top:0;">
    330           <p style = "text-align: left; padding-bottom: 1em; padding-top: 0; margin-top: 0pt;">
     330          <p style = "text-align: left; padding-bottom: 1em; padding-top: 0; margin-top: 0pt; font-weight: bold;">
    331331            <label for = "ec_valid_date_on_id">
    332332              <input type = "checkbox" name = "ec_valid_date_on" id = "ec_valid_date_on_id">
     
    338338          </p>
    339339          <p style = "text-align:left;">
    340             <select id = "ec_validity_day_id" name = "ec_validity_day" {* onchange = "ec_update_ts();" *} >
     340            <select id = "ec_validity_day_id" name = "ec_validity_day">
    341341              <option value = "0">——</option>
    342342              {section name=day start=1 loop=32}
    343                 <option value = "{$smarty.section.day.index}" {if $smarty.section.day.index == 14} selected = "selected" {/if} >
     343                <option value = "{$smarty.section.day.index}">
    344344                  {$smarty.section.day.index}
    345345                </option>
    346346              {/section}
    347347            </select>
    348             <select id = "ec_validity_month_id" name = "ec_validity_month" {* onchange = "ec_update_ts();" *} >
    349               {html_options options=$month_list selected=11}
     348            <select id = "ec_validity_month_id" name = "ec_validity_month">
     349              {html_options options=$month_list}
    350350            </select>
    351             <input id = "ec_validity_year_id" name = "ec_validity_year" type = "text" size = "4" maxlength = "4" value = "2010" {* onchange = "ec_update_ts();" *} >
    352             <input id = "ec_validity_time_id" name = "ec_validity_time" type = "text" size = "5" maxlength = "5" value = "22:50" {* onchange = "ec_update_ts();" *} >
     351            <input id = "ec_validity_year_id" name = "ec_validity_year" type = "text" size = "4" maxlength = "4">
     352            <input id = "ec_validity_time_id" name = "ec_validity_time" type = "text" size = "5" maxlength = "5">
    353353            <input id = "ec_linked_date_id" name = "ec_linked_date_id" type = "hidden" size = "10" disabled = "disabled">
    354354          </p>
    355355          <p style = "text-align:left;">
    356356            <input id = "ec_date_add_btn_id" type = "button" value = "Ajouter"
    357              onclick = "ec_update_date(document.getElementById('ec_date_add_val_id').value, document.getElementById('ec_date_add_kind_id').selectedIndex);">&nbsp;
     357             onclick = "ec_add_time(document.getElementById('ec_date_add_val_id').value, document.getElementById('ec_date_add_kind_id').selectedIndex);">&nbsp;
    358358            <input id = "ec_date_add_val_id" type = "text" size = "5" maxlength = "5" value = "">&nbsp;
    359359            <select id = "ec_date_add_kind_id" name = "ec_date_add_kind">
     
    365365            </select>
    366366          </p>
     367          <p>
     368            <table>
     369              <tr>
     370                <td style = "text-align:right; vertical-align:top; font-weight:bold;">
     371                  <label for = "ec_notify_id">
     372                    <input type = "checkbox" name = "ec_notify" id = "ec_notify_id" disabled = "disabled">
     373                    Lorsque le code<br>
     374                    a expiré, notifier
     375                  </label>
     376                </td>
     377                <td style = "text-align:left;">
     378                  <ul style = "list-style-type:none; list-style-position:inside; padding-left: 0.5em;">
     379                    <li style = "margin-bottom:0;">
     380                      <label for = "ec_notify_user_id">
     381                        <input type = "checkbox" name = "ec_notify_user" id = "ec_notify_user_id">
     382                        l'utilisateur
     383                      </label>
     384                    </li>
     385                    <li style = "margin-bottom:0;">
     386                      <label for = "ec_notify_webm_id">
     387                        <input type = "checkbox" name = "ec_notify_webm" id = "ec_notify_webm_id">
     388                        le webmestre
     389                      </label>
     390                    </li>
     391                    <li style = "margin-bottom:0;">
     392                      <label for = "ec_notify_admins_id">
     393                        <input type = "checkbox" name = "ec_notify_admins" id = "ec_notify_admins_id">
     394                        tous les administrateurs
     395                      </label>
     396                    </li>
     397                  </ul>
     398                </td>
     399              </tr>
     400            </table>
     401          </p>
    367402          <p style = "display:none;">
    368403            <!-- jQuery datepicker : voir http://fr.piwigo.org/forum/viewtopic.php?id=19042 -->
     404            <select id = "ec_min_day_id" name = "ec_min_day">
     405              <option value = "0">——</option>
     406              {section name=day start=1 loop=32}
     407                <option value = "{$smarty.section.day.index}" {if $smarty.section.day.index == 14} selected = "selected" {/if} >
     408                  {$smarty.section.day.index}
     409                </option>
     410              {/section}
     411            </select>
     412            <select id = "ec_min_month_id" name = "ec_min_month">
     413              {html_options options=$month_list selected=11}
     414            </select>
     415            <input id = "ec_min_year_id" name = "ec_min_year" type = "text" size = "4" maxlength = "4" value = "2010" >
    369416            <input id = "ec_min_date_id" name = "ec_min_date_id" type = "hidden" size = "10" disabled = "disabled">
    370417          </p>
     
    375422          {* <!-- /For tests purpose ; must be removed --> *}
    376423        </td>
     424       
    377425        <td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td> {* <!-- sorry :-\ --> *}
    378         <td>
     426       
     427        <td style="vertical-align:top; margin-top:0;">
    379428          <table>
    380429            <tr>
    381430              <td style = "text-align:right; vertical-align:top; font-weight:bold;">
    382                 Page à utiliser après<br>
    383                 expiration du code
     431                Page à affecter au<br>
     432                code une fois expiré
    384433              </td>
    385434              <td style = "text-align:left;">
     
    428477<script type = "text/javascript" src = "{$RACINE_URL}{$EVNTCATS_PATH}admin/template/autolog_new.js"></script>
    429478<script type = "text/javascript"><!--
    430   pwg_initialization_datepicker("#ec_validity_day_id", "#ec_validity_month_id",
    431    "#ec_validity_year_id", "#ec_min_date_id", null, null, null);
    432   pwg_initialization_datepicker("#ec_validity_day_id", "#ec_validity_month_id",
    433    "#ec_validity_year_id", "#ec_linked_date_id", null, "#ec_min_date_id", null);
    434479  ec_is_creation                          = {if $ec_is_creation}true{else}false{/if};
    435480  ec_validity_on                          = {if $ec_validity_on}true{else}false{/if};
Note: See TracChangeset for help on using the changeset viewer.