Allows death removal in case of errors (Closes #1199).
authorStéphane Jacob <sj@m4x.org>
Tue, 3 Aug 2010 09:44:38 +0000 (11:44 +0200)
committerStéphane Jacob <sj@m4x.org>
Tue, 3 Aug 2010 09:44:38 +0000 (11:44 +0200)
Signed-off-by: Stéphane Jacob <sj@m4x.org>
modules/admin.php
templates/admin/deces_promo.tpl

index 624cb3f..70418e4 100644 (file)
@@ -949,15 +949,19 @@ class AdminModule extends PLModule
                                   WHERE  pd.promo = {?}', $promo);
             while (list($pid, $name, $death) = $res->next()) {
                 $val = Env::v('death_' . $pid);
-                if($val == $death || empty($val)) {
+                if ($val == $death) {
                     continue;
                 }
 
+                if (empty($val)) {
+                    $val = null;
+                }
                 XDB::execute('UPDATE  profiles
                                  SET  deathdate = {?}, deathdate_rec = NOW()
                                WHERE  pid = {?}', $val, $pid);
-                $page->trigSuccess('Ajout du décès de ' . $name . ' le ' . $val . '.');
-                if($death == '0000-00-00' || empty($death)) {
+
+                $page->trigSuccess('Édition du décès de ' . $name . ' (' . ($val ? $val : 'ressuscité') . ').');
+                if ($val && ($death == '0000-00-00' || empty($death))) {
                     $profile = Profile::get($pid);
                     $profile->clear();
                     $profile->owner()->clear(false);
@@ -970,7 +974,7 @@ class AdminModule extends PLModule
                           INNER JOIN  profile_display AS pd ON (p.pid = pd.pid)
                                WHERE  pd.promo = {?}
                             ORDER BY  pd.sort_name', $promo);
-        $page->assign('decedes', $res);
+        $page->assign('profileList', $res);
     }
 
     function handler_dead_but_active(&$page)
index cf5a6c1..d11cf46 100644 (file)
       <td>
         Promotion&nbsp;:
         <input type="text" name="promo" value="{$promo}" size="5" maxlength="5" />
-        <input type="submit" value="GO" />
+        <input type="submit" value="Afficher" />
       </td>
     </tr>
   </table>
 </form>
 
-{if t($decedes)}
+{if t($profileList)}
 <form action="admin/deaths/{$promo}/validate" id="deathDateList" method="post">
   {xsrf_token_field}
   <table class="bicol" summary="liste des dates de décès">
       <th>Nom</th>
       <th>Date de décès</th>
     </tr>
-    {iterate item=x from=$decedes}
+    {iterate item=profile from=$profileList}
     <tr class="{cycle values="impair,pair"}">
-      <td>{$x.directory_name}</td>
+      <td>{$profile.directory_name}</td>
       <td class="center">
-        <input type="text" class="deathDate" name="death_{$x.pid}" value="{$x.deathdate}" size="10" maxlength="10" />
+        <input type="text" name="death_{$profile.pid}" value="{$profile.deathdate}" size="10" maxlength="10" />
       </td>
     </tr>
     {/iterate}
     </tr>
   </table>
 </form>
-
-<script type="text/javascript">//<![CDATA[
-  {literal}
-  $('input.deathDate').change(function () {
-    $(this).addClass('sendDate');
-  });
-  
-  $('#deathDateList').submit(function () {
-    // Avoid sending useless data to the webserver
-    $('input.deathDate').not('.sendDate').attr('disabled', true);
-  });
-  {/literal}
-//]]></script>
 {/if}
 
 {* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *}