Task #1440 CA - opération diverses inaccessibles
Task #1370 les OD en comptabilité analytique - problème. Rewrite the OD history + ajax for the detail of ANC misc. operations
This commit is contained in:
parent
9b52096914
commit
12ef663715
4 changed files with 165 additions and 83 deletions
|
|
@ -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)) {
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
}
|
||||
});
|
||||
}
|
||||
92
include/ajax/ajax_anc_detail_operation.php
Normal file
92
include/ajax/ajax_anc_detail_operation.php
Normal file
|
|
@ -0,0 +1,92 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of NOALYSS.
|
||||
*
|
||||
* PhpCompta is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* PhpCompta is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with PhpCompta; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
// Copyright (2016) Author Dany De Bontridder <dany@alchimerys.be>
|
||||
|
||||
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 '<table class="result">';
|
||||
echo '<tr>';
|
||||
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 '<tr>';
|
||||
|
||||
echo '</tr>';
|
||||
for ($i=0;$i< $nb_row;$i++) {
|
||||
$class=($i%2==0)?"even":"odd";
|
||||
echo '<tr class="'.$class.'">';
|
||||
// retrieve card
|
||||
echo '<td>';
|
||||
$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 '</td>';
|
||||
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 '</tr>';
|
||||
|
||||
}
|
||||
echo '</table>';
|
||||
echo '<ul class="aligned-block">';
|
||||
echo '<li>',HtmlInput::button_close("anc_detail_op_div");
|
||||
echo '</ul >';
|
||||
|
|
@ -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.= "<table id=\"anc_operation_list_tb\"class=\"result\">";
|
||||
$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.="<td>".$efface->input()."</td>";
|
||||
|
||||
$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.="<td>".$detail->input()."</td>";
|
||||
}
|
||||
$ret.='</table>';
|
||||
|
||||
}
|
||||
$ret.='<table id="'.$row['oa_group'].'" class="result">';
|
||||
$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.="<tr class=\"highlight\">".
|
||||
td($row['oa_date']).
|
||||
"<td>".
|
||||
$operation_detail.
|
||||
"</td>".
|
||||
td();
|
||||
|
||||
$ret.="<td>".
|
||||
_("Groupe id : ").$row['oa_group'].
|
||||
"</td>".
|
||||
|
||||
$oldgroup=$group;
|
||||
|
||||
$class=($i%2 == 0)?'class="even"':' class="odd"';
|
||||
$i++;
|
||||
$ret.="<tr $class>";
|
||||
$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.="<td>".HtmlInput::image_click("trash-24.gif", $js, _("Effacer"))."</td>";
|
||||
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.="<tr class=\"$class\">";
|
||||
$ret.= "<td>".
|
||||
h($row['po_name']).
|
||||
"</td>";
|
||||
|
||||
$ret.=td(h($row['po_description']));
|
||||
|
||||
$ret.='<td class="num">'. nbm($row['oa_amount']).
|
||||
"</td>".
|
||||
"<td>".
|
||||
$cred.
|
||||
"</td>".
|
||||
|
||||
"</tr>";
|
||||
}
|
||||
|
||||
|
||||
$efface=new IButton();
|
||||
$efface->javascript="anc_remove_operation("."$gDossier,".$oldgroup.")";
|
||||
$efface->name=_("Efface");
|
||||
$efface->label=_("Efface");
|
||||
$ret.="<td>".$efface->input()."</td>";
|
||||
// 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.="<td>".$detail->input()."</td>";
|
||||
}
|
||||
$ret .= "<td>". HtmlInput::image_click("crayon-mod-b24.png", $js, _("Modifier"))."</td>";
|
||||
$ret.="</tr>";
|
||||
}
|
||||
$ret.='</table>';
|
||||
$ret.=$bar;
|
||||
|
||||
return $ret;
|
||||
}
|
||||
/*!\brief retrieve an operation thanks a jrnx.j_id
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue