diff --git a/html/js/ajax_fiche.js b/html/js/ajax_fiche.js index efecc0e45..03415c18a 100644 --- a/html/js/ajax_fiche.js +++ b/html/js/ajax_fiche.js @@ -266,11 +266,17 @@ category_card.add_attribut=function (p_dossier,p_fiche_def_ref,p_object_name) { onSuccess:function(req) { var answer=req.responseText.evalJSON(); if ( answer.status == 'OK') { - var newli=document.createElement("li") - newli.setAttribute("id",p_object_name+"_elt"+selected_attr); - newli.innerHTML=answer.content - $(p_object_name+"_list").append(newli); + var newli = document.createElement("li") + + $(p_object_name + "_list").append(newli); + newli.replace(answer.content); + document.getElementById('attribut_order').value = Sortable.serialize(p_object_name + "_list"); select.remove(select.selectedIndex); + Sortable.create(p_object_name + '_list', { + onUpdate: function () { + document.getElementById('attribut_order').value = Sortable.serialize(p_object_name + "_list") + } + }); } else { smoke.alert(answer.message); } diff --git a/include/ajax/ajax_template_cat_category.php b/include/ajax/ajax_template_cat_category.php index 692a86c95..a94e787a7 100644 --- a/include/ajax/ajax_template_cat_category.php +++ b/include/ajax/ajax_template_cat_category.php @@ -68,9 +68,13 @@ switch ($action) $answer['message']=""; $js=sprintf("category_card.remove_attribut('%s','%s','%s',%d)", Dossier::id(), $frd_id, $objname, $ad_id); - $answer['content']=$cn->get_value("select ad_text from attr_def where ad_id=$1", - [$ad_id]). - Icon_Action::trash(uniqid(), $js); + $label=$cn->get_value("select ad_text from attr_def where ad_id=$1", + [$ad_id]); + $content=sprintf('
  • %s', $objname + ,$ad_id,$label); + $content.=Icon_Action::trash(uniqid(), $js); + $content.='
  • '; + $answer['content']=$content; } catch (Exception $exc) { diff --git a/include/cfgfiche.inc.php b/include/cfgfiche.inc.php index ddbd84f8f..a865d6f8e 100644 --- a/include/cfgfiche.inc.php +++ b/include/cfgfiche.inc.php @@ -45,6 +45,9 @@ if ( $action == 'remove_cat' ) 'Les fiches non utilisées ont cependant été effacées')); } } + $fiche_def=new Fiche_def($cn); + $fiche_def->display(); + return; } /*******************************************************************************************/ // Change some basis info diff --git a/include/class/fiche_def.class.php b/include/class/fiche_def.class.php index 965f9159d..586a752a3 100644 --- a/include/class/fiche_def.class.php +++ b/include/class/fiche_def.class.php @@ -253,7 +253,7 @@ $order $p_create='true'; else $p_create='false'; - + $add_accounting=false; // Class is valid ? if ( sql_string($p_class_base) != null || ( $p_class_base !='' && strpos(',',$p_class_base) != 0 )) { @@ -272,10 +272,11 @@ $order // Get the fd_id $fd_id=$this->cn->get_current_seq('s_fdef'); - // update jnt_fic_attr - $sql=sprintf("insert into jnt_fic_attr(fd_id,ad_id,jnt_order) - values (%d,%d,10)",$fd_id,ATTR_DEF_ACCOUNT); - $Res=$this->cn->exec_sql($sql); +// // update jnt_fic_attr +// $sql=sprintf("insert into jnt_fic_attr(fd_id,ad_id,jnt_order) +// values (%d,%d,10)",$fd_id,ATTR_DEF_ACCOUNT); +// $Res=$this->cn->exec_sql($sql); + $add_accounting=true; } else { @@ -295,24 +296,39 @@ $order //if defaut attr not null // build the sql insert for the table attr_def + $add_qcode=true; if (sizeof($def_attr) != 0 ) { // insert all the mandatory fields into jnt_fiche_attr foreach ( $def_attr as $row) { - $order=$row['ad_default_order']; - if ( $row['ad_id'] == ATTR_DEF_NAME ) - $order=0; + $count=$this->cn->get_value("select count(*) from jnt_fic_attr where fd_id=$1 and ad_id=$2",array($fd_id,$row['ad_id'])); if ($count == 0) { $sql=sprintf("insert into jnt_fic_Attr(fd_id,ad_id,jnt_order) values (%d,%s,%d)", - $fd_id,$row['ad_id'],$order); + $fd_id,$row['ad_id'],$row['ad_default_order']); $this->cn->exec_sql($sql); } + // if there is an accounting , then not needed to add one + if ( $row['ad_id']==ATTR_DEF_ACCOUNT) $add_accounting=FALSE; + if ( $row['ad_id']==ATTR_DEF_QUICKCODE) $add_qcode=FALSE; } } + // if there is an base accounting, and the accounting is not in ATTR_MIN, + // then it is needed to add it + if ( $add_accounting) { + $sql=sprintf("insert into jnt_fic_attr(fd_id,ad_id,jnt_order) + values (%d,%d,10)",$fd_id,ATTR_DEF_ACCOUNT); + $Res=$this->cn->exec_sql($sql); + } + // if there is no quick code in attr_min, it is added + if ( $add_qcode) { + $sql=sprintf("insert into jnt_fic_attr(fd_id,ad_id,jnt_order) + values (%d,%d,10000)",$fd_id,ATTR_DEF_QUICKCODE); + $Res=$this->cn->exec_sql($sql); + } $this->id=$fd_id; return 0; @@ -710,9 +726,10 @@ $order { // find the min attr for the fiche_def_ref - $Sql="select ad_id,ad_text ,ad_default_order - from attr_min natural join attr_def - natural join fiche_def_ref + $Sql="select ad_id,ad_text ,attr_min.ad_default_order + from attr_min + join attr_def using(ad_id) + join fiche_def_ref using(frd_id) where frd_id= $1 order by ad_default_order"; $Res=$this->cn->exec_sql($Sql,array($p_fiche_def_ref)); diff --git a/include/class/template_card_category.class.php b/include/class/template_card_category.class.php index 2fae8bb75..7afa86637 100644 --- a/include/class/template_card_category.class.php +++ b/include/class/template_card_category.class.php @@ -148,19 +148,20 @@ EOF; $cn=Dossier::connect(); $dossier_id=Dossier::id(); $objname=$this->get_object_name(); - $a_attribut=$cn->get_array("select ad_id,ad_text,ad_type from attr_min join attr_def using (ad_id) where frd_id=$1 order by 2", + $a_attribut=$cn->get_array("select ad_id,ad_text,ad_type,a1.ad_default_order from attr_min a1 join attr_def using (ad_id) where frd_id=$1 order by a1.ad_default_order", [$this->table->frd_id]); $nb_attribut=count($a_attribut); - printf('