diff --git a/html/ajax_misc.php b/html/ajax_misc.php
index 7086ea5a5..17dcf6b91 100644
--- a/html/ajax_misc.php
+++ b/html/ajax_misc.php
@@ -197,7 +197,9 @@ $path = array(
// Update name and description
"anc_updatedescription"=>"ajax_anc_plan",
// Update, insert or delete accounting frmo CFGPCMN
- "accounting"=>"ajax_accounting"
+ "accounting"=>"ajax_accounting",
+ // Show detail of an ANC operation
+ "anc_detail_op"=>"ajax_anc_detail_operation"
) ;
if (array_key_exists($op, $path)) {
diff --git a/html/js/anc_script.js b/html/js/anc_script.js
index 20a6b69db..397b91d3b 100644
--- a/html/js/anc_script.js
+++ b/html/js/anc_script.js
@@ -553,4 +553,18 @@ function anc_key_compute_table()
}
$('total_key').innerHTML=Math.round(tot*100)/100;
+}
+
+function anc_detail_op(p_oa_group,gDossier) {
+ waiting_box();
+ // create div
+ new Ajax.Request ("ajax_misc.php",{
+ method:"get",
+ parameters:{"gDossier":gDossier,"op":"anc_detail_op","oa_group":p_oa_group},
+ onSuccess:function (req) {
+ add_div({"id":"anc_detail_op_div","cssclass":"inner_box","style":"position:fixed;top:5%"});
+ $('anc_detail_op_div').update(req.responseText);
+ remove_waiting_box();
+ }
+ });
}
\ No newline at end of file
diff --git a/include/ajax/ajax_anc_detail_operation.php b/include/ajax/ajax_anc_detail_operation.php
new file mode 100644
index 000000000..733859806
--- /dev/null
+++ b/include/ajax/ajax_anc_detail_operation.php
@@ -0,0 +1,92 @@
+
+
+if (!defined('ALLOWED'))
+ die('Appel direct ne sont pas permis');
+
+/**
+ * @file
+ * @brief display the detail of an anc operation
+ * parameters : oa_group
+ */
+$http=new HttpInput();
+$oa_group=$http->request("oa_group","number");
+bcscale(4);
+$row=$cn->get_row("select distinct oa_group,
+ to_char(oa_date,'DD.MM.YYYY') as str_date ,
+ oa_date,
+ oa_description,
+ jr_pj_number,
+ jr_id
+ from
+ operation_analytique as oa
+ join poste_analytique using (po_id)
+ left join (select jr_id,jr_pj_number,j_id from jrn join jrnx on (jr_grpt_id=j_grpt) ) as m on (m.j_id=oa.j_id)
+ where oa_group=$1",array($oa_group));
+echo HtmlInput::title_box(_('Détail'), "anc_detail_op_div");
+echo $row['str_date'],' ',
+ h($row['oa_description']),' ',
+ h($row['jr_pj_number']);
+$a_row=$cn->get_array("select distinct oa_row from operation_analytique where oa_group=$1",array($oa_group));
+$a_plan=$cn->get_array("select distinct pa_id,pa_name from operation_analytique join poste_analytique using (po_id) join plan_analytique using (pa_id) where oa_group=$1 order by pa_name",array($oa_group));
+$nb_row=count($a_row);
+$nb_plan=count($a_plan);
+echo '
';
+echo '';
+echo th(_('Fiche'));
+for ( $e=0;$e<$nb_plan;$e++) echo th($a_plan[$e]['pa_name']);
+echo th(_('Montant'),'style="text-align:right"');
+echo th(_('D/C'));
+echo '
';
+
+echo '
';
+for ($i=0;$i< $nb_row;$i++) {
+ $class=($i%2==0)?"even":"odd";
+ echo '';
+ // retrieve card
+ echo '| ';
+ $f_id=$cn->get_value("select distinct f_id from operation_analytique where oa_group = $1 and oa_row=$2",[$oa_group,$a_row[$i]['oa_row']]);
+ $qcode=$cn->get_value("select ad_value from fiche_detail where f_id=$1 and ad_id=$2",[$f_id,ATTR_DEF_QUICKCODE] );
+ echo $qcode;
+ echo ' | ';
+ for ( $e = 0;$e<$nb_plan;$e++) {
+ $detail_row=$cn->get_row("select po_name , oa_amount,oa_positive ,oa_debit
+ from operation_analytique
+ join poste_analytique using (po_id)
+ join plan_analytique using (pa_id)
+ where
+ oa_group=$1
+ and oa_row=$2
+ and pa_id=$3",array($oa_group,$a_row[$i]['oa_row'],$a_plan[$e]['pa_id']));
+ echo td($detail_row['po_name']);
+ }
+ $amount=$detail_row['oa_amount'];
+ if ( $detail_row['oa_positive']=="N") {$amount=bcmult($amount,-1);}
+ echo td($amount,'style="text-align:right"');
+ $debit=($detail_row['oa_debit'] == 'f')?"C":"D";
+ echo td($debit);
+ echo '
';
+
+}
+echo '
';
+echo '';
+echo '- ',HtmlInput::button_close("anc_detail_op_div");
+echo '
';
\ No newline at end of file
diff --git a/include/class/anc_operation.class.php b/include/class/anc_operation.class.php
index eda986ed0..1bbddc270 100644
--- a/include/class/anc_operation.class.php
+++ b/include/class/anc_operation.class.php
@@ -163,6 +163,34 @@ class Anc_Operation
$this->db->exec_sql($sql,array($this->oa_id));
}
+
+ function get_list_simple($p_from,$p_to)
+ {
+ $cond="";
+ $where=" where ";
+
+ if ($p_from!="") {
+ $cond="$where (oa_date >= to_date('$p_from','DD.MM.YYYY') or oa_date >= to_date('$p_from','DD.MM.YYYY') )";
+ $where=" and ";
+ }
+ if ( $p_to!="" )
+ $cond.="$where (oa_date <=to_date('$p_to','DD.MM.YYYY') or oa_date <=to_date('$p_to','DD.MM.YYYY')) ";
+
+ $sql="
+ select distinct oa_group,
+ to_char(oa_date,'DD.MM.YYYY') as str_date ,
+ oa_date,
+ oa_description,
+ jr_pj_number,
+ jr_id
+ from
+ operation_analytique as oa
+ left join (select jr_id,jr_pj_number,j_id from jrn join jrnx on (jr_grpt_id=j_grpt) ) as m on (m.j_id=oa.j_id)
+ $cond
+ order by oa_date ";
+ return $this->db->get_array($sql);
+
+ }
/*!\brief get a list of row from a certain periode
*/
@@ -237,7 +265,8 @@ class Anc_Operation
list($from,$to)=$p->get_date_limit($p_from);
}
- $array=$this->get_list($from,$to);
+ $array=$this->get_list_simple($from,$to);
+
if ( empty($array) )
return _("Pas d'enregistrement trouvé");
@@ -260,92 +289,37 @@ class Anc_Operation
$group=0;
$oldgroup=0;
$oldjrid=0;
-
+ $ret.=_("Chercher")." ".HtmlInput::filter_table("anc_operation_list_tb", '0,1,2', 1);
+ $ret.= "";
+ $ret.=th(_("Date"));
+ $ret.=th(_("Libellé"));
+ $ret.=th(_("Num Pièce"));
+ $ret.=th("");
+ $ret.=th("");
+ $i=0;
foreach ($view as $row)
{
- $group=$row['oa_group'];
- if ( $group !=$oldgroup )
- {
-
- if ( $oldgroup!=0 )
- {
-
- $efface=new IButton();
- $efface->javascript="anc_remove_operation(".$gDossier.",".$oldgroup.")";
- $efface->name=_("Efface");
- $efface->label=_("Efface");
- $ret.="| ".$efface->input()." | ";
-
- $this->oa_group=$oldgroup;
- $jr_id=$this->get_jrid();
-
- if ( $jr_id != 0)
- {
- // get the old jr_id
- $detail=new IButton();
- $detail->javascript="viewOperation($jr_id,$gDossier)";
- $detail->name=_("Detail");
- $detail->label=_("Detail");
- $ret.="".$detail->input()." | ";
- }
- $ret.='
';
-
- }
- $ret.='';
- $operation_detail= ($row['jr_id'] != 0)?HtmlInput::detail_op($row['jr_id'], h($row['oa_description']." ".$row['jr_pj_number'])):h($row['oa_description']);
- $ret.="".
- td($row['oa_date']).
- "| ".
- $operation_detail.
- " | ".
- td();
-
- $ret.="".
- _("Groupe id : ").$row['oa_group'].
- " | ".
-
- $oldgroup=$group;
-
+ $class=($i%2 == 0)?'class="even"':' class="odd"';
+ $i++;
+ $ret.="
";
+ $ret.=td($row['str_date']);
+ $ret.=td(h($row['oa_description']));
+ $ret.=td(h($row['jr_pj_number']));
+ $js="anc_remove_operation(".$gDossier.",".$oldgroup.")";
+
+ $ret.="| ".HtmlInput::image_click("trash-24.gif", $js, _("Effacer"))." | ";
+ if ( $row['jr_id'] != "") {
+ $js="viewOperation({$row['jr_id']},{$gDossier})";
+
+ } else {
+ $js="anc_detail_op({$row['oa_group']},{$gDossier})";
}
-
- $class=($count%2==0)?"odd":"even";
- $count++;
- $cred= ( $row['oa_debit'] == 'f')?"CREDIT":"DEBIT";
- $ret.="
";
- $ret.= "| ".
- h($row['po_name']).
- " | ";
-
- $ret.=td(h($row['po_description']));
-
- $ret.=''. nbm($row['oa_amount']).
- " | ".
- "".
- $cred.
- " | ".
-
- "
";
- }
-
-
- $efface=new IButton();
- $efface->javascript="anc_remove_operation("."$gDossier,".$oldgroup.")";
- $efface->name=_("Efface");
- $efface->label=_("Efface");
- $ret.="".$efface->input()." | ";
- // get the old jr_id
- $this->oa_group=$oldgroup;
- $jr_id=$this->get_jrid();
- if ( $jr_id != 0 )
- {
- $detail=new IButton();
- $detail->javascript="modifyOperation($jr_id,'".$gDossier."')";
- $detail->name=_("Detail");
- $detail->label=_("Detail");
- $ret.="".$detail->input()." | ";
- }
+ $ret .= "". HtmlInput::image_click("crayon-mod-b24.png", $js, _("Modifier"))." | ";
+ $ret.="";
+ }
$ret.='
';
$ret.=$bar;
+
return $ret;
}
/*!\brief retrieve an operation thanks a jrnx.j_id