diff --git a/html/ajax_ledger.php b/html/ajax_ledger.php
index e82a4a8c9..ccfcf37e0 100644
--- a/html/ajax_ledger.php
+++ b/html/ajax_ledger.php
@@ -322,7 +322,7 @@ case 'rmf':
$op->oa_date=$row_ca['j_date'];
$op->oa_group=$group;
$op->oa_description=$_REQUEST['lib'];
- $op->save_form_plan($_REQUEST,$count);
+ $op->save_form_plan($_REQUEST,$count,$row_ca['j_id']);
$count++;
} //if myereg
}//foreach
diff --git a/html/js/anc_script.js b/html/js/anc_script.js
index e4687f34d..eb2ec293c 100644
--- a/html/js/anc_script.js
+++ b/html/js/anc_script.js
@@ -25,9 +25,8 @@
/*!\brief add a row for the CA
* \param p_table_id
* \param p_amount amount to reach
- * \param p_count count of col.
*/
-function add_row(p_table,p_seq,p_count) {
+function add_row(p_table,p_seq) {
var mytable=g(p_table).tBodies[0];
if ( ! mytable ) {return;}
@@ -44,13 +43,13 @@ function add_row(p_table,p_seq,p_count) {
for ( var i=0;i< rowToCopy.cells.length;i++) {
var cell=row.insertCell(i);
var txt=rowToCopy.cells[i].innerHTML;
- txt=txt.replace(/row_1/g,"row_"+new_value);
+// txt=txt.replace(/row_1/g,"row_"+new_value);
cell.innerHTML=txt;
}
// create the amount cell
- row.cells[i-1].innerHTML='';
+// row.cells[i-1].innerHTML='';
}
/*!
diff --git a/html/test.php b/html/test.php
index 72ed229d0..1a9e7d1eb 100644
--- a/html/test.php
+++ b/html/test.php
@@ -47,6 +47,7 @@ if ( ! isset($_REQUEST['gDossier'])) {
$array=array(
array(1,'Plan Analytic'),
array(2,'Poste Analytic'),
+ array(3,'Opération Analytic'),
array(11,'Periode'),
array(12,'verif.inc.php'),
array(13,'Rapport(class_acc_report'),
@@ -100,6 +101,10 @@ case 2:
require_once("class_anc_account.php");
Anc_Account::test_me();
break;
+case 3:
+ require_once ('class_anc_operation.php');
+ Anc_Operation::test_me();
+ break;
case 11:
require_once ('class_periode.php');
Periode::test_me();
diff --git a/include/class_acc_ledger.php b/include/class_acc_ledger.php
index 16100a8fa..34e98a744 100644
--- a/include/class_acc_ledger.php
+++ b/include/class_acc_ledger.php
@@ -993,13 +993,18 @@ jr_comment||' ('||jr_internal||')'||case when jr_pj_number is not null and jr_pj
}
/*!
- * \brief show the result of the array
+ * \brief show the result of the array to confirm
+ * before inserting
* \param $p_array array from the form
* \return string
*/
function show_summary($p_array) {
+ /**
+ *@todo add a call to verify ???
+ */
$this->id=$p_array['p_jrn'];
if ( empty($p_array)) return 'Aucun résultat';
+ $anc=null;
extract($p_array);
$lPeriode=new Periode($this->db);
if ($this->check_periode() == true) {
@@ -1007,6 +1012,8 @@ jr_comment||' ('||jr_internal||')'||case when jr_pj_number is not null and jr_pj
} else {
$lPeriode->find_periode($date);
}
+ $owner=new own($this->db);
+
$ret="";
$ret.="
";
$ret.="
"._('Date')." :
$date
";
@@ -1022,8 +1029,18 @@ jr_comment||' ('||jr_internal||')'||case when jr_pj_number is not null and jr_pj
$ret.=_("Poste")." ";
$ret.="
"._("Montant")."
";
$ret.="
"._("Débit")."
";
+ /* if we use the AC */
+ if ($owner->MY_ANALYTIC!='nu') {
+ $anc=new Anc_Plan($this->db);
+ $a_anc=$anc->get_list();
+ $x=count($a_anc);
+ /* set the width of the col */
+ $ret.='
'._('Compt. Analytique').'
';
+
+ /* add hidden variables pa[] to hold the value of pa_id */
+ $ret.=Anc_Plan::hidden($a_anc);
+ }
$ret.="";
- $own=new own($this->db);
$ret.=HtmlInput::hidden('date',$date);
$ret.=HtmlInput::hidden('desc',$desc);
@@ -1072,14 +1089,18 @@ jr_comment||' ('||jr_internal||')'||case when jr_pj_number is not null and jr_pj
$ret.="";
// CA
- if ( $own->MY_ANALYTIC!='nu') // use of AA
+ if ( $owner->MY_ANALYTIC!='nu') // use of AA
{
if ( myereg("^[6,7]+",$strPoste)) {
// show form
$op=new Anc_Operation($this->db);
- $null=($own->MY_ANALYTIC=='op')?1:0;
+ $null=($owner->MY_ANALYTIC=='op')?1:0;
+ $p_array['pa_id']=$a_anc;
+ /* op is the operation it contains either a sequence or a jrnx.j_id */
+ $ret.=HtmlInput::hidden('op[]=',$i);
+
$ret.='
';
$count++;
}
@@ -1186,8 +1207,8 @@ jr_comment||' ('||jr_internal||')'||case when jr_pj_number is not null and jr_pj
/* suggest PJ ? */
$default_pj='';
- $own=new Own($this->db);
- if ( $own->MY_PJ_SUGGEST=='Y') {
+ $owner=new Own($this->db);
+ if ( $owner->MY_PJ_SUGGEST=='Y') {
$default_pj=$this->guess_pj();
}
$wPJ->value=(isset($e_pj))?$e_pj:$default_pj;
@@ -1460,7 +1481,7 @@ jr_comment||' ('||jr_internal||')'||case when jr_pj_number is not null and jr_pj
$internal=$this->compute_internal_code($seq);
$group=$this->db->get_next_seq("s_oa_group");
- $own=new own($this->db);
+ $owner=new own($this->db);
$tot_amount=0;
$tot_deb=0;
$tot_cred=0;
@@ -1512,7 +1533,7 @@ jr_comment||' ('||jr_internal||')'||case when jr_pj_number is not null and jr_pj
$tot_amount+=round($acc_op->amount,2);
$tot_deb+=($acc_op->type=='d')?$acc_op->amount:0;
$tot_cred+=($acc_op->type=='c')?$acc_op->amount:0;
- if ( $own->MY_ANALYTIC != "nu" )
+ if ( $owner->MY_ANALYTIC != "nu" )
{
if ( myereg("^[6,7]+",$poste)) {
@@ -1523,7 +1544,7 @@ jr_comment||' ('||jr_internal||')'||case when jr_pj_number is not null and jr_pj
$op->oa_date=$date;
$op->oa_debit=($acc_op->type=='d' )?'t':'f';
$op->oa_description=$desc;
- $op->save_form_plan($p_array,$count);
+ $op->save_form_plan($p_array,$count,$j_id);
$count++;
}
}
@@ -1711,9 +1732,9 @@ jr_comment||' ('||jr_internal||')'||case when jr_pj_number is not null and jr_pj
* \return true if we are using the strict_mode
*/
function check_strict() {
- $own=new Own($this->db);
- if ( $own->MY_STRICT=='Y') return true;
- if ( $own->MY_STRICT=='N') return false;
+ $owner=new Own($this->db);
+ if ( $owner->MY_STRICT=='Y') return true;
+ if ( $owner->MY_STRICT=='N') return false;
exit("Valeur invalid ".__FILE__.':'.__LINE__);
}
/*!
@@ -1722,9 +1743,9 @@ function check_strict() {
* \return true if we are using the double encoding (date+periode)
*/
function check_periode() {
- $own=new Own($this->db);
- if ( $own->MY_CHECK_PERIODE=='Y') return true;
- if ( $own->MY_CHECK_PERIODE=='N') return false;
+ $owner=new Own($this->db);
+ if ( $owner->MY_CHECK_PERIODE=='Y') return true;
+ if ( $owner->MY_CHECK_PERIODE=='N') return false;
exit("Valeur invalid ".__FILE__.':'.__LINE__);
}
diff --git a/include/class_acc_ledger_purchase.php b/include/class_acc_ledger_purchase.php
index 9a643dab5..5c405a737 100644
--- a/include/class_acc_ledger_purchase.php
+++ b/include/class_acc_ledger_purchase.php
@@ -416,7 +416,7 @@ class Acc_Ledger_Purchase extends Acc_Ledger {
$op->oa_date=$e_date;
$op->oa_debit=($amount < 0 )?'t':'f';
$op->oa_description=FormatString($e_comm);
- $op->save_form_plan($_POST,$i);
+ $op->save_form_plan($_POST,$i,$j_id);
}
// insert into quant_purchase
//-----
@@ -1051,7 +1051,7 @@ array
function confirm($p_array) {
extract ($p_array);
$this->verify($p_array) ;
-
+ $anc=null;
// to show a select list for the analytic
// if analytic is op (optionnel) there is a blank line
$owner = new Own($this->db);
@@ -1106,7 +1106,19 @@ array
$r.="
"._('quantité')."
";
$r.='
'._('Total')."
";
}
- $r.=($owner->MY_ANALYTIC!='nu')?'
'._('Compt. Analytique').'
':'';
+
+ /* if we use the AC */
+ if ($owner->MY_ANALYTIC!='nu') {
+ $anc=new Anc_Plan($this->db);
+ $a_anc=$anc->get_list();
+ $x=count($a_anc);
+ /* set the width of the col */
+ $r.='
'._('Compt. Analytique').'
';
+
+ /* add hidden variables pa[] to hold the value of pa_id */
+ $r.=Anc_Plan::hidden($a_anc);
+ }
+
$r.='';
$tot_amount=0.0;
$tot_tva=0.0;
@@ -1182,6 +1194,9 @@ array
$null=($owner->MY_ANALYTIC=='op')?1:0;
$r.='
';
$p_mode=1;
+ $p_array['pa_id']=$a_anc;
+ /* op is the operation it contains either a sequence or a jrnx.j_id */
+ $r.=HtmlInput::hidden('op[]=',$i);
$r.=$anc_op->display_form_plan($p_array,$null,$p_mode,$i,$amount);
$r.='
';
}
diff --git a/include/class_acc_ledger_sold.php b/include/class_acc_ledger_sold.php
index ffe0f2389..97bff60b6 100644
--- a/include/class_acc_ledger_sold.php
+++ b/include/class_acc_ledger_sold.php
@@ -57,8 +57,12 @@ class Acc_Ledger_Sold extends Acc_Ledger {
public function verify($p_array) {
extract ($p_array);
/* check for a double reload */
- if ( isset($mt) && $this->db->count_sql('select jr_mt from jrn where jr_mt=$1',array($mt)) != 0 )
+ /**
+ *@todo REMOVE DEBUG FALSE
+ */
+ if ( false && isset($mt) && $this->db->count_sql('select jr_mt from jrn where jr_mt=$1',array($mt)) != 0 )
throw new Exception (_('Double Encodage'),5);
+
/* check if we can write into this ledger */
$user=new User($this->db);
if ( $user->check_jrn($p_jrn) != 'W' )
@@ -205,7 +209,6 @@ class Acc_Ledger_Sold extends Acc_Ledger {
*\note throw an Exception
*/
public function insert($p_array) {
-
extract ($p_array);
$this->verify($p_array) ;
@@ -308,6 +311,7 @@ class Acc_Ledger_Sold extends Acc_Ledger {
if ( $owner->MY_ANALYTIC != "nu" )
{
+ var_dump("save anal");
// for each item, insert into operation_analytique */
$op=new Anc_Operation($this->db);
$op->oa_group=$group;
@@ -315,7 +319,7 @@ class Acc_Ledger_Sold extends Acc_Ledger {
$op->oa_date=$e_date;
$op->oa_debit=($amount < 0 )?'t':'f';
$op->oa_description=FormatString($e_comm);
- $op->save_form_plan($_POST,$i);
+ $op->save_form_plan($_POST,$i,$j_id);
}
if ( $owner->MY_TVA_USE=='Y') {
/* save into quant_sold */
@@ -531,7 +535,7 @@ class Acc_Ledger_Sold extends Acc_Ledger {
function confirm($p_array) {
extract ($p_array);
$this->verify($p_array) ;
-
+ $anc=null;
// to show a select list for the analytic & VAT USE
// if analytic is op (optionnel) there is a blank line
$owner = new Own($this->db);
@@ -584,7 +588,17 @@ class Acc_Ledger_Sold extends Acc_Ledger {
$r.='
'._('Montant TVA').'
';
$r.='
'._('Montant HTVA').'
';
}
- $r.=($owner->MY_ANALYTIC!='nu')?'
'._('Compt. Analytique').'
':'';
+ /* if we use the AC */
+ if ($owner->MY_ANALYTIC!='nu') {
+ $anc=new Anc_Plan($this->db);
+ $a_anc=$anc->get_list();
+ $x=count($a_anc);
+ /* set the width of the col */
+ $r.='
'._('Compt. Analytique').'
';
+
+ /* add hidden variables pa[] to hold the value of pa_id */
+ $r.=Anc_Plan::hidden($a_anc);
+ }
$r.='';
$tot_amount=0.0;
$tot_tva=0.0;
@@ -654,6 +668,9 @@ class Acc_Ledger_Sold extends Acc_Ledger {
$null=($owner->MY_ANALYTIC=='op')?1:0;
$r.='
';
$p_mode=1;
+ $p_array['pa_id']=$a_anc;
+ /* op is the operation it contains either a sequence or a jrnx.j_id */
+ $r.=HtmlInput::hidden('op[]=',$i);
$r.=$anc_op->display_form_plan($p_array,$null,$p_mode,$i,$amount);
$r.='
';
}
diff --git a/include/class_anc_operation.php b/include/class_anc_operation.php
index f708f2115..7084a8e1e 100644
--- a/include/class_anc_operation.php
+++ b/include/class_anc_operation.php
@@ -289,7 +289,7 @@ class Anc_Operation
oa_row
from operation_analytique
where
- j_id=$p_jid order by j_id,oa_row";
+ j_id=$p_jid order by j_id,pa_id,oa_row";
$ret=$this->db->exec_sql($sql);
$res=Database::fetch_all($ret);
if ( $res== false) return null;
@@ -395,48 +395,45 @@ function get_balance($p_from,$p_to,$p_plan_id)
$result.='
';
$result.="
".$plan->header()."
montant
";
+ /* compute the number of rows */
+ $nb_row=count($p_array['pa_id'])/count($a_plan);
-
- $nb_row=(!isset(${'nb_'.$table_id}))?1:${'nb_'.$table_id};
- $result.=$hidden->input('nb_'.$table_id,$nb_row);
-
- for ( $i=1; $i <= $nb_row;$i++) {
+ for ( $i=0; $i < $nb_row;$i++) {
$result.='
';
$count=0;
foreach ($a_plan as $r_plan)
{
- $count++;
$array=$this->db->make_array(
- "select pa_id||'_'||po_id as value,".
+ "select po_id as value,".
" html_quote(po_name) as label from poste_analytique ".
" where pa_id = ".$r_plan['id'].
" order by po_name",$p_null);
- $select =new ISelect("ta_".$p_seq."o".$count."row_".$i,$array);
+ $select =new ISelect("hplan[".$p_seq."][]",$array);
$select->table=0;
- // view only or editable
+ // view only or editables
if ( $p_mode==1 ) {
// editable
$select->readonly=false;
- $select->selected=(isset(${"ta_".$p_seq."o".$count."row_".$i}))?${"ta_".$p_seq."o".$count."row_".$i}:0;
+ if ( isset($hplan) )
+ $select->selected=$hplan[$p_seq][$count];
} else {
// view only
$select->readonly=true;
- $select->selected=(isset(${"ta_".$p_seq."o".$count."row_".$i}))?${"ta_".$p_seq."o".$count."row_".$i}:0;
}
if ($p_mode==1)
- $result.='