noalyss-commit
[Top][All Lists]
Advanced

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

[Noalyss-commit] [noalyss] 50/323: task #0001513: Détail fiche : ajout


From: Dany De Bontridder
Subject: [Noalyss-commit] [noalyss] 50/323: task #0001513: Détail fiche : ajout bouton effacer
Date: Wed, 14 Mar 2018 17:38:16 -0400 (EDT)

sparkyx pushed a commit to branch master
in repository noalyss.

commit 78fe114d54a5eb16aff1fc455e5041ef20006893
Author: Dany De Bontridder <address@hidden>
Date:   Thu Jan 11 00:15:15 2018 +0100

    task #0001513: Détail fiche : ajout bouton effacer
---
 html/js/card.js               | 39 ++++++++++++++++++++++++++++++++++++++-
 include/ajax/ajax_card.php    | 40 ++++++++++++++++++++++++++++++++++++++++
 include/class/fiche.class.php | 17 +++++++++++++----
 3 files changed, 91 insertions(+), 5 deletions(-)

diff --git a/html/js/card.js b/html/js/card.js
index 5660426..1228ac2 100644
--- a/html/js/card.js
+++ b/html/js/card.js
@@ -982,4 +982,41 @@ function 
action_remove_concerned(p_dossier,p_fiche_id,p_action_id)
             }
     );
     }
-    
+/**
+ * Remove a card after checking it is not used
+ * @param object obj {gDossier,op,op2:rm_card,ctl,f_id}
+ */    
+function delete_card(obj) {
+    console.debug("delete_card");
+    console.debug(obj);
+    smoke.confirm("Confirmez ? ", function (e) {
+        if (e) {
+            waiting_box();
+            new Ajax.Request("ajax_misc.php", {
+                "method": "get",
+                parameters: obj,
+                onSuccess: function (req) {
+                    remove_waiting_box();
+                    var answer = req.responseXML;
+                    var a = answer.getElementsByTagName('ctl');
+                    if (a.length == 0)
+                    {
+                        var rec = req.responseText;
+                        alert_box('erreur :' + rec);
+                    }
+                    var html = answer.getElementsByTagName('code');
+                    var namectl = a[0].firstChild.nodeValue;
+                    var nodeXml = html[0];
+                    var code_html = getNodeText(nodeXml);
+                    code_html = unescape_xml(code_html);
+                    if ( code_html == "OK") {
+                        Effect.Fade(obj['ctl'], { duration: 1.5 });    
+                    } else {
+                        smoke.alert(code_html);
+                    }
+                }
+
+            });
+        }
+    });
+}
\ No newline at end of file
diff --git a/include/ajax/ajax_card.php b/include/ajax/ajax_card.php
index 10e4bf7..cbd679e 100644
--- a/include/ajax/ajax_card.php
+++ b/include/ajax/ajax_card.php
@@ -164,6 +164,12 @@ case 'dc':
                $html.=HtmlInput::submit('save',_('Sauver'));
              }
            if ( ! isset 
($nohistory))$html.=HtmlInput::history_card_button($f->id,_('Historique'));
+            // Display a remove button if not used and can modify card
+            if ( $can_modify == 1 && $f->is_used()==FALSE)
+            {
+                
$js=str_replace('"',"'",json_encode(["gDossier"=>Dossier::id(),'op'=>'card','op2'=>"rm_card","f_id"=>$f->id,'ctl'=>$ctl]));
+                $html.=HtmlInput::button_action(_("Efface"), 
"delete_card($js)","x","smallbutton");
+            }
             $html.='</p>';
            if ($can_modify==1)
              {
@@ -587,6 +593,40 @@ case 'upc':
          $html.=$f->Display(true);
        }
       }
+      break;
+      //------------------------------------------------------------------
+      // Unlink a card
+      //------------------------------------------------------------------
+        case 'rm_card':
+             $html=HtmlInput::title_box("Détail fiche", $ctl);
+
+  if ( $g_user->check_action(FIC)==0 )
+    {
+      $html.=alert(_('Action interdite'),true);
+    }
+  else
+    {
+      if ($cn->get_value('select count(*) from fiche where 
f_id=$1',array($_GET['f_id'])) == '0' )
+       {
+         $html.=alert(_('Fiche non valide'),true);
+         }
+
+      else
+       {
+
+         $f=new Fiche($cn,$_GET['f_id']);
+          if ( $f->is_used()==0){
+            $f->delete();
+            $html="OK";
+          } else {
+            $html="";
+            $html=_("Fiche non effacée");
+          }
+
+       }
+      }
+      break;
+            
 } // switch
 $xml=escape_xml($html);
 if (DEBUG && headers_sent()) {
diff --git a/include/class/fiche.class.php b/include/class/fiche.class.php
index bb1b278..d39ddf9 100644
--- a/include/class/fiche.class.php
+++ b/include/class/fiche.class.php
@@ -1973,19 +1973,28 @@ class Fiche
         $qcode=$this->strAttribut(ATTR_DEF_QUICKCODE);
         $sql='select count(*) as c from jrnx where j_qcode=$1';
         $count=$this->cn->get_value($sql,array($qcode));
-        if ( $count == 0 ) return false;
-        return true;
+        if ( $count > 0 ) return TRUE;
+        $count=$this->cn->get_value("select count(*) from action_gestion where 
f_id_dest=$1 or ag_contact=$1 ",
+                [$this->id]);
+        if ( $count > 0 ) return TRUE;
+        $count=$this->cn->get_value("select count(*) from action_person where 
f_id=$1 ",
+                [$this->id]);
+        if ( $count > 0 ) return TRUE;
+        
+        return FALSE;
     }
     /*\brief remove a card without verification */
     function delete()
     {
+        $this->cn->start();
         // Remove from attr_value
         $Res=$this->cn->exec_sql("delete from fiche_detail
                                  where
-                                   f_id=".$this->id);
+                                   f_id=$1",[$this->id]);
 
         // Remove from fiche
-        $Res=$this->cn->exec_sql("delete from fiche where f_id=".$this->id);
+        $Res=$this->cn->exec_sql("delete from fiche where 
f_id=$1",[$this->id]);
+        $this->cn->commit();
 
     }
     /*!\brief create the sql statement for retrieving all



reply via email to

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