noalyss-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Noalyss-commit] [noalyss] 85/219: Task #1349 : si une seule catégorie


From: Dany De Bontridder
Subject: [Noalyss-commit] [noalyss] 85/219: Task #1349 : si une seule catégorie de fiche , alors on ne doit pas la choisir
Date: Mon, 18 Dec 2017 13:22:42 -0500 (EST)

sparkyx pushed a commit to branch master
in repository noalyss.

commit 77c37a8c8f7bf464f19afc55b0beab8c1a6a17bd
Author: Dany De Bontridder <address@hidden>
Date:   Sun Oct 15 01:01:15 2017 +0200

    Task #1349 : si une seule catégorie de fiche , alors on ne doit pas la
    choisir
---
 html/js/card.js            | 14 ++++++++++++-
 html/js/scripts.js         | 25 ++++++++---------------
 include/ajax/ajax_card.php | 51 ++++++++++++++++++++++++++++------------------
 3 files changed, 52 insertions(+), 38 deletions(-)

diff --git a/html/js/card.js b/html/js/card.js
index ddd44cb..2297744 100644
--- a/html/js/card.js
+++ b/html/js/card.js
@@ -607,7 +607,19 @@ function select_card_type(obj)
                                   parameters:queryString,
                                   onFailure:errorFid,
                                   onSuccess:function(req) { 
-                                   
+                                      // Get all the category, 
+                                      var 
answer=req.responseXML.getElementsByTagName("fiche_cat_item");
+                                      if (answer.length == 0) {
+                                          alert_box(req.responseText);
+                                          return;
+                                      }
+                                      if ( answer.length == 1) {
+                                          // There is only one category of card
+                                          
dis_blank_card({"ctl":"div_new_card","fd_id":answer[0].firstChild.nodeValue,"op2":"bc","op":"card",gDossier:dossier});
+                                          removeDiv(content);
+                                          remove_waiting_box();
+                                          return;
+                                      }
                                       fill_box(req);
                                        $('lk_cat_card_table').focus();
                                     }
diff --git a/html/js/scripts.js b/html/js/scripts.js
index 83054b9..a62c757 100644
--- a/html/js/scripts.js
+++ b/html/js/scripts.js
@@ -2758,23 +2758,14 @@ function show_description(p_id)
 
 }
 /**
- * Hightlight the row we select and restore previous one
- * @param {type} x
- * @returns {undefined}
- */
-var old_class = null;
-var old_select = null;
-
-function select_cat(x)
-{
-    if (old_select != null)
-    {
-        $(old_select).className = old_class;
-    }
-    old_select = $('select_cat_row_' + x);
-    old_class = old_select.className;
-    $(old_select).className = "highlight";
-    $('fd_id').value = x;
+ * Display an empty card to fill , with the right card category
+ * @param pn_fiche_card_id : fiche_def.fd_id
+ * @param pn_dossier_id
+  */
+function select_cat(pn_fiche_card_id,pn_dossier_id)
+{
+    
dis_blank_card({"ctl":"div_new_card","fd_id":pn_fiche_card_id,"op2":"bc","op":"card",gDossier:pn_dossier_id});
+    removeDiv('select_card_div');
 }
 /**
  * Show the DIV and hide the other, the array of possible DIV are
diff --git a/include/ajax/ajax_card.php b/include/ajax/ajax_card.php
index 59b51da..ff85a92 100644
--- a/include/ajax/ajax_card.php
+++ b/include/ajax/ajax_card.php
@@ -248,16 +248,16 @@ case 'st':
                                   sql_string($fil));
             }
     }
-       if ( strpos($where," in ()") != 0)
-       {
-                $html=HtmlInput::anchor_close('select_card_div');
-                $html.=h2info(_('Choix de la catégorie'));
-                $html.='<h3 class="notice">';
-                $html.=_("Aucune catégorie de fiche ne correspond à".
-                " votre demande, le journal pourrait n'avoir accès à aucune 
fiche");
-                $html.='</h3>';
-                break;
-       }
+    if ( strpos($where," in ()") != 0)
+    {
+             $html=HtmlInput::anchor_close('select_card_div');
+             $html.=h2info(_('Choix de la catégorie'));
+             $html.='<h3 class="notice">';
+             $html.=_("Aucune catégorie de fiche ne correspond à".
+            " votre demande, le journal pourrait n'avoir accès à aucune 
fiche");
+             $html.='</h3>';
+             break;
+    }
     $sql.=" ".$where." order by fd_label";
 
     $array=$cn->get_array($sql);
@@ -271,15 +271,14 @@ case 'st':
     }
     else
     {
+        $list_fiche="";
         $r='';
+        
+       $r.='<div dd>';
        $r.='<p  style="padding-left:2em">';
         $r.=_("Choisissez la catégorie de fiche à laquelle vous aimeriez 
ajouter une fiche").'</p>';
         
-       $r.='<div style="text-align:center">';
-        
         $msg=_('Choisissez une catégorie svp');
-        $r.='<form id="sel_type" method="GET" 
onsubmit="this.ipopup='.$ctl.";if ($('fd_id').value != 0 ) 
{dis_blank_card(this);return false;} else "
-                . "{ $('error_cat').innerHTML='".$msg."'; return false;}\">" ;
         $r.='<span id="error_cat" class="notice"></span>';
         $r.=dossier::hidden();
         $r.=(isset($ref))?HtmlInput::hidden('ref',1):'';
@@ -287,28 +286,40 @@ case 'st':
         $r.='<table id="cat_card_table" class="result">';
         for ($i=0;$i<count($array);$i++)
         {
+            
$list_fiche.=sprintf("<fiche_cat_item>%d</fiche_cat_item>",$array[$i]['fd_id']);
             $class=($i%2==0)?' class="even" ':' class="odd" ';
             $r.='<tr '.$class.' id="select_cat_row_'.$array[$i]['fd_id'].'">';
             $r.='<td >';
-            $r.='<a href="javascript:void(0)" 
onclick="select_cat(\''.$array[$i]['fd_id'].'\')">'.h($array[$i]['fd_label']).'</a>';
+            $r.='<a href="javascript:void(0)" 
onclick="select_cat(\''.$array[$i]['fd_id'].'\','.$gDossier.')">'.h($array[$i]['fd_label']).'</a>';
             $r.='</td>';
             $r.='<td>';
-            $r.='<a href="javascript:void(0)" 
onclick="select_cat(\''.$array[$i]['fd_id'].'\')">'.h($array[$i]['fd_description']).'</a>';
+            $r.='<a href="javascript:void(0)" 
onclick="select_cat(\''.$array[$i]['fd_id'].'\','.$gDossier.')">'.h($array[$i]['fd_description']).'</a>';
             $r.='</td>';
            
              $r.="</tr>";
         }
+        
         $r.='</table>';
         $r.=HtmlInput::hidden('fd_id',0);
         $r.='<p style="text-align:center">';
-        $r.=HtmlInput::submit('st','choix');
-       $r.=HtmlInput::button('Annuler',_('Annuler')," 
onclick=\"removeDiv('$ctl')\" ");
+       $r.=HtmlInput::button('Fermer',_('Fermer')," 
onclick=\"removeDiv('$ctl')\" ");
        $r.='</p>';
-        $r.='</form>';
         $r.='</div>';
         $html.=$r;
-
+        
     }
+    $xml=escape_xml($html);
+    header('Content-type: text/xml; charset=UTF-8');
+echo <<<EOF
+<?xml version="1.0" encoding="UTF-8"?>
+<data>
+<ctl>$ctl</ctl>
+<code>$xml</code>
+<fiche_cat>{$list_fiche}</fiche_cat>        
+</data>
+EOF;
+return;
+    
     break;
     /*----------------------------------------------------------------------
      * SC save card



reply via email to

[Prev in Thread] Current Thread [Next in Thread]