diff --git a/html/admin/sql/patch/upgrade84.sql b/html/admin/sql/patch/upgrade84.sql index a050d579c..8c1794c10 100644 --- a/html/admin/sql/patch/upgrade84.sql +++ b/html/admin/sql/patch/upgrade84.sql @@ -9,6 +9,8 @@ ALTER TABLE quant_sold REFERENCES jrn (jr_internal) MATCH SIMPLE ON UPDATE CASCADE ON DELETE CASCADE; +delete from stock_goods where j_id not in (select j_id from jrnx); + ALTER TABLE stock_goods ADD CONSTRAINT stock_goods_j_id_fkey FOREIGN KEY (j_id) REFERENCES jrnx (j_id) MATCH SIMPLE diff --git a/html/admin/sql/patch/upgrade85.sql b/html/admin/sql/patch/upgrade85.sql index 13ecef7ef..1e6dba826 100644 --- a/html/admin/sql/patch/upgrade85.sql +++ b/html/admin/sql/patch/upgrade85.sql @@ -129,7 +129,6 @@ ALTER TABLE jrn_def ADD COLUMN jrn_def_bank bigint; alter table jrn_def add jrn_def_num_op integer; ALTER TABLE del_jrnx ADD COLUMN f_id bigint; -DROP FUNCTION comptaproc.jrnx_del(); CREATE OR REPLACE FUNCTION comptaproc.jrnx_del() RETURNS trigger AS @@ -153,4 +152,4 @@ $BODY$ update version set val=86; -commit; \ No newline at end of file +commit; diff --git a/html/poste_csv.php b/html/poste_csv.php index f20317831..e2f0fc39b 100644 --- a/html/poste_csv.php +++ b/html/poste_csv.php @@ -57,7 +57,7 @@ if ( ! isset ($_REQUEST['oper_detail'])) { foreach ($a_poste as $pos) { $Poste=new Acc_Account_Ledger($cn,$pos['pcm_val']); - $Poste->get_name(); + $name=$Poste->get_name(); list($array,$tot_deb,$tot_cred)=$Poste->get_row_date( $_REQUEST['from_periode'], $_REQUEST['to_periode'], $_GET['ople'] @@ -65,22 +65,26 @@ if ( ! isset ($_REQUEST['oper_detail'])) { if ( count($Poste->row ) == 0 ) continue; - echo '"Poste";'. + echo '"Poste";'.'"Lib.";'. "\"Code interne\";". "\"Date\";". "\"Description\";". "\"Débit\";". - "\"Crédit\""; + "\"Crédit\";". + "\"Prog.\""; printf("\n"); - + $prog=0; foreach ( $Poste->row as $op ) { + $prog+=$op['deb_montant']-$op['cred_montant']; echo '"'.$pos['pcm_val'].'";'. + '"'.$name.'";'. '"'.$op['jr_internal'].'"'.";". '"'.$op['j_date_fmt'].'"'.";". '"'.$op['description']." ".$op['jr_pj_number'].'"'.";". nb($op['deb_montant']).";". - nb($op['cred_montant']); + nb($op['cred_montant']).";". + nb(abs($prog)); printf("\n"); diff --git a/html/poste_pdf.php b/html/poste_pdf.php index 009654674..656a4fc2c 100644 --- a/html/poste_pdf.php +++ b/html/poste_pdf.php @@ -60,8 +60,8 @@ if ( count($a_poste) == 0 ) { $pdf->Output('poste.pdf','I'); exit; } -$size=array(13,25,20,80,12,20,20); -$align=array('L','C','C','L','R','R','R'); +$size=array(13,25,20,60,12,20,20,20); +$align=array('L','C','C','L','R','R','R','R'); foreach ($a_poste as $poste) { @@ -85,11 +85,14 @@ foreach ($a_poste as $poste) $pdf->Cell($size[$l],6,'Let',0,0,'R');$l++; $pdf->Cell($size[$l],6,'Debit',0,0,'R');$l++; $pdf->Cell($size[$l],6,'Credit',0,0,'R');$l++; + $pdf->Cell($size[$l],6,'Prog',0,0,'R');$l++; $pdf->ln(); - $tot_deb=0;$tot_cred=0; + $tot_deb=0;$tot_cred=0;$prog=0; for ($e=0;$eCell($size[$l],6,$date,0,0,$align[$l]);$l++; $pdf->Cell($size[$l],6,$row['jr_internal'],0,0,$align[$l]);$l++; @@ -98,6 +101,7 @@ foreach ($a_poste as $poste) $pdf->Cell($size[$l],6,(($row['letter']!=-1)?$row['letter']:''),0,0,$align[$l]);$l++; $pdf->Cell($size[$l],6,(sprintf('% 12.2f',$row['deb_montant'])),0,0,$align[$l]);$l++; $pdf->Cell($size[$l],6,(sprintf('% 12.2f',$row['cred_montant'])),0,0,$align[$l]);$l++; + $pdf->Cell($size[$l],6,(sprintf('% 12.2f',abs($prog))),0,0,$align[$l]);$l++; $pdf->ln(); $tot_deb+=$row['deb_montant']; $tot_cred+=$row['cred_montant']; diff --git a/html/quick_code_csv.php b/html/quick_code_csv.php index d50ff9ae1..cc3ce8717 100644 --- a/html/quick_code_csv.php +++ b/html/quick_code_csv.php @@ -57,15 +57,20 @@ echo '"Qcode";'. "\"Date\";". "\"Description\";". "\"Débit\";". -"\"Crédit\""; +"\"Crédit\";". +"\"Prog.\""; printf("\n"); +$progress=0; foreach ( $Fiche->row as $op ) { + $progress+=$op['deb_montant']-$op['cred_montant']; + echo '"'.$op['j_qcode'].'";'. '"'.$op['jr_internal'].'"'.";". '"'.$op['j_date_fmt'].'"'.";". '"'.$op['description'].'"'.";". nb($op['deb_montant']).";". - nb($op['cred_montant']); + nb($op['cred_montant']).";". + nb(abs($progress)); printf("\n"); } diff --git a/html/quick_code_pdf.php b/html/quick_code_pdf.php index 3342af2e6..a0d132a07 100644 --- a/html/quick_code_pdf.php +++ b/html/quick_code_pdf.php @@ -52,8 +52,8 @@ list($array,$tot_deb,$tot_cred)=$Fiche->get_row_date($from_periode,$to_periode,$ if ( count($array) == 0 ) { exit; } -$size=array(13,25,20,80,12,20,20); -$align=array('L','C','C','L','R','R','R'); +$size=array(13,25,20,60,12,20,20,20); +$align=array('L','C','C','L','R','R','R','R'); $Libelle=sprintf("(%s) %s ",$Fiche->id,$Fiche->getName()); $pdf->SetFont('DejaVu','',10); @@ -70,11 +70,15 @@ $pdf->Ln(); $pdf->Cell($size[$l],6,'Let',0,0,'R');$l++; $pdf->Cell($size[$l],6,'Debit',0,0,'R');$l++; $pdf->Cell($size[$l],6,'Credit',0,0,'R');$l++; + $pdf->Cell($size[$l],6,'Prog',0,0,'R');$l++; $pdf->ln(); - $tot_deb=0;$tot_cred=0; +$tot_deb=0;$tot_cred=0;$progress=0; for ($e=0;$eCell($size[$l],6,$date,0,0,$align[$l]);$l++; $pdf->Cell($size[$l],6,$row['jr_internal'],0,0,$align[$l]);$l++; @@ -83,6 +87,7 @@ $pdf->Ln(); $pdf->Cell($size[$l],6,(($row['letter']!=-1)?$row['letter']:''),0,0,$align[$l]);$l++; $pdf->Cell($size[$l],6,(sprintf('% 12.2f',$row['deb_montant'])),0,0,$align[$l]);$l++; $pdf->Cell($size[$l],6,(sprintf('% 12.2f',$row['cred_montant'])),0,0,$align[$l]);$l++; + $pdf->Cell($size[$l],6,(sprintf('% 12.2f',abs($progress))),0,0,$align[$l]);$l++; $pdf->ln(); $tot_deb+=$row['deb_montant']; $tot_cred+=$row['cred_montant']; diff --git a/include/class_acc_account_ledger.php b/include/class_acc_account_ledger.php index a50cd63f5..c46b23434 100644 --- a/include/class_acc_account_ledger.php +++ b/include/class_acc_account_ledger.php @@ -300,20 +300,25 @@ function get_solde_detail($p_cond="") { " Description ". " Débit ". " Crédit ". - th('Let.','style=\"text-align:right\"'). + th('Prog.','style="text-align:right"'). + th('Let.','style="text-align:right"'); ""; - + $progress=0; foreach ( $this->row as $op ) { $vw_operation=sprintf('%s', $op['jr_id'], dossier::id(), $op['jr_internal']); $let=''; if ( $op['letter'] !=-1) $let=$op['letter']; + $progress+=$op['deb_montant']-$op['cred_montant']; + echo "". "".$vw_operation."". "".$op['j_date']."". "".h($op['description']).' '.h($op['jr_pj_number'])."". "".sprintf("%.2f",$op['deb_montant'])."". "".sprintf("%.2f",$op['cred_montant'])."". + td(sprintf('%.2f',abs($progress)),'style="text-align:right"'). + td($let,' style="color:red;text-align:right"'). ""; diff --git a/include/class_fiche.php b/include/class_fiche.php index b1c060dcf..b77089ea4 100644 --- a/include/class_fiche.php +++ b/include/class_fiche.php @@ -1096,7 +1096,7 @@ av_text1=>'name' { if ( $p_array == null) $p_array=$_REQUEST; - + $progress=0; $name=h($this->getName()).'['.$this->strAttribut(ATTR_DEF_QUICKCODE).']'; list($array,$tot_deb,$tot_cred)=$this->get_row_date( $p_array['from_periode'], @@ -1118,7 +1118,8 @@ av_text1=>'name' ""._('Description')." ". ""._('Débit')." ". ""._('Crédit')." ". - th('Let.','style=\"text-align:right\"'); + th('Prog.','style="text-align:right"'). + th('Let.','style="text-align:right"'); ""; foreach ( $this->row as $op ) { @@ -1126,12 +1127,14 @@ av_text1=>'name' $op['jr_id'], dossier::id(), $op['jr_internal']); $let=''; if ( $op['letter'] !=-1) $let=$op['letter']; + $progress+=$op['deb_montant']-$op['cred_montant']; echo "". "".$vw_operation."". "".format_date($op['j_date_fmt'])."". "".h($op['description'])."". "".sprintf("%.2f",$op['deb_montant'])."". "".sprintf("%.2f",$op['cred_montant'])."". + td(sprintf('%.2f',abs($progress)),'style="text-align:right"'). td($let,' style="color:red;text-align:right"'). ""; diff --git a/include/stock_inc.php b/include/stock_inc.php index 4bd96e57f..f193e9150 100644 --- a/include/stock_inc.php +++ b/include/stock_inc.php @@ -47,7 +47,7 @@ function ViewStock($p_cn,$p_year) { $sql=" select distinct sg_code from stock_goods where - sg_code is not null and sg_code != '' and sg_code!='null'"; + sg_code is not null and sg_code not in ('','null','--not found--','- ERROR -')"; @@ -202,7 +202,7 @@ $sql="select sg_code, $r.="Quantité"; $r.="Prix/Cout Unitaire"; $r.=""; - + $tot_quantity=0; for ( $i=0; $i < $M;$i++) { $l=Database::fetch_array($Res,$i); $r.=""; @@ -217,7 +217,12 @@ $sql="select sg_code, $r.=($l['sg_type']=='c')?'OUT':'IN'; $r.=""; + if ( $l['sg_type']=='c') + $quantity=(-1)*$l['sg_quantity']; + else + $quantity=$l['sg_quantity']; + $tot_quantity+=$quantity; // comment $r.=""; $r.=$l['comment']; @@ -240,7 +245,7 @@ $sql="select sg_code, $r.=""; //quantity $r.=''; - $r.=$l['sg_quantity']; + $r.=$quantity; $r.=""; // Unit Price @@ -253,6 +258,11 @@ $sql="select sg_code, $r.=""; }// for ($i + // write the total + $row=td('Total',' colspan="4" style="width:auto;text-align:right"'); + $row.=td($tot_quantity, 'style="text-align:right"'); + $row.=td(); + $r.=td($row); $r.="";