[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
- [Noalyss-commit] [noalyss] 37/323: Task #1518:Modèle de Catégorie de fiche : ajout sécurité + attribut minimum, (continued)
- [Noalyss-commit] [noalyss] 37/323: Task #1518:Modèle de Catégorie de fiche : ajout sécurité + attribut minimum, Dany De Bontridder, 2018/03/14
- [Noalyss-commit] [noalyss] 31/323: documentation, Dany De Bontridder, 2018/03/14
- [Noalyss-commit] [noalyss] 33/323: documentation, Dany De Bontridder, 2018/03/14
- [Noalyss-commit] [noalyss] 36/323: Bug in Manage_Table_SQL when an exception is thrown from ajax_input, Dany De Bontridder, 2018/03/14
- [Noalyss-commit] [noalyss] 41/323: Category of card : dialog box too large for screen cannot be viewed, Dany De Bontridder, 2018/03/14
- [Noalyss-commit] [noalyss] 40/323: Category of card : cannot be removed due to FK in attr_min, Dany De Bontridder, 2018/03/14
- [Noalyss-commit] [noalyss] 42/323: Manage_Table dialog box draggable, Dany De Bontridder, 2018/03/14
- [Noalyss-commit] [noalyss] 46/323: Mix between odd and even row, Dany De Bontridder, 2018/03/14
- [Noalyss-commit] [noalyss] 23/323: Task #1485 : by default the dialog box are fixed but can be moved, Dany De Bontridder, 2018/03/14
- [Noalyss-commit] [noalyss] 51/323: 0001523: Dans HISTO , Operation History (HISTO) , tiers is clickable, Dany De Bontridder, 2018/03/14
- [Noalyss-commit] [noalyss] 50/323: task #0001513: Détail fiche : ajout bouton effacer,
Dany De Bontridder <=
- [Noalyss-commit] [noalyss] 49/323: Tak #1522 : Journaux peuvent être inactif, Dany De Bontridder, 2018/03/14
- [Noalyss-commit] [noalyss] 38/323: Task #1518 : ajout de modèle de catégorie de fiche Modification des attributs minimums, Dany De Bontridder, 2018/03/14
- [Noalyss-commit] [noalyss] 34/323: Rewriting Module Template Category of card, Dany De Bontridder, 2018/03/14
- [Noalyss-commit] [noalyss] 53/323: Bug : search cannot select ledger, Dany De Bontridder, 2018/03/14
- [Noalyss-commit] [noalyss] 47/323: Task #0001519: Assouplissement de la sécurité : Administrateur accès à tout, ajout d'utilisateur par défaut securité désactivée, Dany De Bontridder, 2018/03/14
- [Noalyss-commit] [noalyss] 72/323: typo, Dany De Bontridder, 2018/03/14
- [Noalyss-commit] [noalyss] 64/323: th.num align right, Dany De Bontridder, 2018/03/14
- [Noalyss-commit] [noalyss] 55/323: Task #1457 & 1281 : export PDF with opening writing, Dany De Bontridder, 2018/03/14
- [Noalyss-commit] [noalyss] 54/323: Task #1326 & #1512 = ajout détail extourne, libellé directement après ajout opération, Dany De Bontridder, 2018/03/14
- [Noalyss-commit] [noalyss] 57/323: Task #0001527: Effacement du champ code fiche : bouton , indent, Dany De Bontridder, 2018/03/14