task #0001513: Détail fiche : ajout bouton effacer
This commit is contained in:
parent
5b9362c903
commit
78fe114d54
3 changed files with 91 additions and 5 deletions
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
@ -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()) {
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue