diff --git a/html/admin/sql/dossier1/schema.sql b/html/admin/sql/dossier1/schema.sql index ddd80971c..d927332b3 100644 --- a/html/admin/sql/dossier1/schema.sql +++ b/html/admin/sql/dossier1/schema.sql @@ -135,7 +135,7 @@ CREATE TABLE import_tmp ( detail text, num_compte text, poste_comptable text, - status char(1) default 'w' not null check (status in ('t','d','w')), + status varchar(1) default 'n' not null check (status in ('t','d','w','n')), bq_account integer NOT NULL, jrn integer NOT NULL diff --git a/html/admin/sql/mod1/schema.sql b/html/admin/sql/mod1/schema.sql index 1402eedba..56592ae05 100644 --- a/html/admin/sql/mod1/schema.sql +++ b/html/admin/sql/mod1/schema.sql @@ -377,7 +377,7 @@ CREATE TABLE import_tmp ( detail text, num_compte text, poste_comptable text, - status char(1) default 'w' not null check (status in ('t','d','w')), + status varchar(1) default 'n' not null check (status in ('n','t','d','w')), bq_account integer NOT NULL, jrn integer NOT NULL diff --git a/html/admin/sql/mod2/schema.sql b/html/admin/sql/mod2/schema.sql index de0420964..f0a820608 100644 --- a/html/admin/sql/mod2/schema.sql +++ b/html/admin/sql/mod2/schema.sql @@ -151,7 +151,7 @@ CREATE TABLE import_tmp ( detail text, num_compte text, poste_comptable text, - status char(1) default 'w' not null check (status in ('t','d','w')), + status varchar(1) default 'n' not null check (status in ('n','t','d','w')), bq_account integer NOT NULL, jrn integer NOT NULL ); diff --git a/html/admin/sql/patch/upgrade14.sql b/html/admin/sql/patch/upgrade14.sql index 979c9ab76..5b899e2ba 100644 --- a/html/admin/sql/patch/upgrade14.sql +++ b/html/admin/sql/patch/upgrade14.sql @@ -1,6 +1,6 @@ begin; alter table import_tmp add column status varchar(1); -alter table import_tmp alter status set default 'w'; +alter table import_tmp alter status set default 'n'; create or replace function trim_cvs_quote() returns trigger as $trim$ declare modified import_tmp%ROWTYPE; @@ -16,10 +16,10 @@ end; $trim$ language plpgsql; update import_tmp set status = 't' where ok=true; -update import_tmp set status = 'w' where ok = false; -update import_tmp set status = 'w' where ok is null; +update import_tmp set status = 'n' where ok = false; +update import_tmp set status = 'n' where ok is null; -alter table import_tmp add constraint chk_status check (status in ('w','d','t')); +alter table import_tmp add constraint chk_status check (status in ('n','w','d','t')); alter table import_tmp drop column ok ; @@ -42,4 +42,4 @@ end; $trim$ language plpgsql; update version set val=15; -commit; \ No newline at end of file +commit; diff --git a/include/argenta_be.inc.php b/include/argenta_be.inc.php index 064508d2d..a776d75fe 100644 --- a/include/argenta_be.inc.php +++ b/include/argenta_be.inc.php @@ -87,7 +87,7 @@ echo "
"; detail, bq_account , jrn, - ok) + status) values ('$code', to_date('$date_exec','DD-MM-YYYY'), to_date('$date_exec','DD-MM-YYYY'), @@ -98,7 +98,7 @@ echo "
"; '".addslashes($detail)." ', '$p_bq_account', $p_jrn, - false)"; + 'n')"; if ( ExecSql($p_cn,$Sql) == false ) { Rollback($p_cn); break; diff --git a/include/cbc_be.inc.php b/include/cbc_be.inc.php index 5419540c0..5fb2b84ae 100644 --- a/include/cbc_be.inc.php +++ b/include/cbc_be.inc.php @@ -69,7 +69,7 @@ while (($data = fgetcsv($handle, 2000,'!@')) !== FALSE) { detail, bq_account , jrn, - ok) + status) values (nextval('s_cbc'), to_date('$date_exec','YYYYMMDD'), to_date('$date_exec','YYYYMMDD'), @@ -79,7 +79,7 @@ while (($data = fgetcsv($handle, 2000,'!@')) !== FALSE) { '".addslashes($detail).$num_compte." ', '$p_bq_account', $p_jrn, - false)"; + 'n')"; if ( ExecSql($p_cn,$Sql) == false ) { Rollback($p_cn); diff --git a/include/eub_be.inc.php b/include/eub_be.inc.php index 3c2ee7159..32ed617a3 100644 --- a/include/eub_be.inc.php +++ b/include/eub_be.inc.php @@ -61,7 +61,7 @@ while (($data = fgetcsv($handle, 2000,'!@')) !== FALSE) { num_compte, bq_account , jrn, - ok) + status) values ('$code', '$date_exec', '$date_exec', @@ -70,11 +70,11 @@ while (($data = fgetcsv($handle, 2000,'!@')) !== FALSE) { '".addslashes($detail)."', '$p_bq_account', $p_jrn, - false)"; + 'n')"; $Res=ExecSql($p_cn,$Sql); } } // for ($c=0;$c<$num;$c++) $row++; } // file is read fclose($handle); -?> \ No newline at end of file +?> diff --git a/include/fortis_be.inc.php b/include/fortis_be.inc.php index 8fb07b1bb..2c2b206f7 100644 --- a/include/fortis_be.inc.php +++ b/include/fortis_be.inc.php @@ -89,7 +89,7 @@ while (($data = fgetcsv($handle, 2000,'!@')) !== FALSE) { num_compte, bq_account , jrn, - ok) + status) values ('$code', '$date_exec', '$date_exec', @@ -100,7 +100,7 @@ while (($data = fgetcsv($handle, 2000,'!@')) !== FALSE) { '$num_compte', $p_bq_account, $p_jrn, - false)"; + 'n')"; $Res=ExecSql($p_cn,$Sql); } @@ -110,4 +110,4 @@ while (($data = fgetcsv($handle, 2000,'!@')) !== FALSE) { $row++; } // file is read fclose($handle); -?> \ No newline at end of file +?> diff --git a/include/import_inc.php b/include/import_inc.php index e17a97944..1cdc58ce0 100644 --- a/include/import_inc.php +++ b/include/import_inc.php @@ -67,7 +67,7 @@ function UpdateCSV($p_cn){ $code=$_POST['code']; $count=$_POST['count']; $poste=$_POST['poste'.$count]; - $sql = "update import_tmp set poste_comptable='".$poste."' where code='".$code."'"; + $sql = "update import_tmp set poste_comptable='".$poste."' ,status='w' where code='".$code."'"; $Res=ExecSql($p_cn,$sql); } @@ -78,10 +78,11 @@ function UpdateCSV($p_cn){ * are not included in the function and must set in the calling proc. * \param $p_val array (row from import_type) * \param $counter a counter used in the form + * \param $p_cn database connection * \param $p_form indicates if the button for the form is enable, * modify the Quick Code or remove record poss.value are form, remove */ -function ShowBox($p_val,$counter,$p_form='form'){ +function ShowBox($p_val,$counter,$p_cn,$p_form='form'){ $w=new widget('js_search_only'); $w->name='poste'.$counter; @@ -98,7 +99,7 @@ function ShowBox($p_val,$counter,$p_form='form'){ { $w->value=$p_val['poste_comptable']; $cn=DbConnect($_SESSION['g_dossier']); - $f=new fiche($cn); + $f=new fiche($p_cn); $f->GetByQCode($p_val['poste_comptable']); $s->value=$f->strAttribut(ATTR_DEF_NAME); } @@ -106,24 +107,27 @@ function ShowBox($p_val,$counter,$p_form='form'){ echo ''; echo ''; echo ''; + echo ""; echo ''; echo ''; echo ""; - if ( $p_form == 'form') - echo ''; + if ( $p_form == 'form') { + echo ''; + } if ($p_form == 'remove' ) - echo ''; + echo ''; echo '
'.$p_val['code'].''.$p_val['date_exec'].''.$p_val['montant'].' EUR
Journal : ".GetJrnName($p_cn,$p_val['jrn'])."poste comptable Destination : ".$p_val['bq_account']."
'.$p_val['detail'].'
'.$w->IOValue().' '.$s->IOValue('poste'.$counter.'_label').'n° compte : ".$p_val['num_compte']."
'; + echo '
'; } -/*!\brief Remove the record, the data are in $_POST +/*!\brief Remove the record from the transfert list, the data are in $_POST + * import_tmp.status is set to n for new * */ function RemoveCSV($cn) { - var_dump($_POST); - $sql="update import_tmp set poste_comptable=null where code='".$_POST['code']."'"; + $sql="update import_tmp set poste_comptable=null,status='n' where code='".$_POST['code']."'"; ExecSql($cn,$sql); } @@ -131,7 +135,8 @@ function RemoveCSV($cn) */ function VerifImport($p_cn){ - $sql = "select * from import_tmp where poste_comptable='' or poste_comptable is null order by date_exec,code"; + $sql = "select * from import_tmp where status='n' ". + " order by date_exec,code"; $Res=ExecSql($p_cn,$sql); $Num=pg_NumRows($Res); echo $Num." opérations à complèter.

"; @@ -140,7 +145,7 @@ function VerifImport($p_cn){ echo JS_SEARCH_CARD; while($val = pg_fetch_array($Res)){ echo '
'; - ShowBox($val,$i); + ShowBox($val,$i,$p_cn,'form'); echo '
'; $i++; } @@ -168,21 +173,21 @@ function ConfirmTransfert($p_cn,$periode){ $sql = "select code,to_char(date_exec,'DD.MM.YYYY') as date_exec, ". " montant,num_compte,poste_comptable,bq_account,jrn,detail ". - " from import_tmp where poste_comptable is not null and poste_comptable <> '' - and ok <> TRUE AND date_exec BETWEEN ".$start." and ".$end; + " from import_tmp where + status = 'w' AND date_exec BETWEEN ".$start." and ".$end; $Res=ExecSql($p_cn,$sql); $Num=pg_NumRows($Res); - echo $Num." opérations à complèter.

"; + echo $Num." opérations à transfèrer.

"; if ( $Num == 0 ) return; $i=1; while($val = pg_fetch_array($Res)){ echo '
'; echo ''; - ShowBox($val,$i,'remove'); + ShowBox($val,$i,$p_cn,'remove'); echo '
'; $i++; } @@ -194,6 +199,9 @@ function ConfirmTransfert($p_cn,$periode){ } /*!\brief Transfert data into the ledger + * set the column import_tmp.status to w (wait) if the account is not correct + * otherwise transfert it to the ledger and set the column import_tmp.status + * to t (transfert) * \param $p_cn connx * \param $periode periode */ @@ -219,8 +227,8 @@ function TransferCSV($p_cn, $periode){ // var_dump($val); $sql = "select code,to_char(date_exec,'DD.MM.YYYY') as date_exec, ". " montant,num_compte,poste_comptable,bq_account,jrn,detail ". - " from import_tmp where poste_comptable is not null and poste_comptable <> '' - and ok <> TRUE AND date_exec BETWEEN ".$start." and ".$end; + " from import_tmp where ". + " status= 'w' AND date_exec BETWEEN ".$start." and ".$end; $Res=ExecSql($p_cn,$sql); //echo "boucle: ".sizeof($Res)."
"; //while($val = pg_fetch_array($Res)){ @@ -253,7 +261,7 @@ function TransferCSV($p_cn, $periode){ // Test it if($test == 0) { - $sqlupdate = "update import_tmp set poste_comptable=null, ok='f' WHERE code='".$code."' AND num_compte='".$num_compte."' or num_compte is null"; + $sqlupdate = "update import_tmp set status='n' WHERE code='".$code."' AND num_compte='".$num_compte."' or num_compte is null"; $Resupdate=ExecSql($p_cn,$sqlupdate); echo "Poste comptable erronné pour l'opération ".$num_compte."-".$code.", réinitialisation du poste comptable
"; continue; @@ -284,7 +292,7 @@ function TransferCSV($p_cn, $periode){ echo "Tranfer de l'opération ".$code." effectué
"; - $sql2 = "update import_tmp set ok=TRUE where code='".$code."'"; + $sql2 = "update import_tmp set status='t' where code='".$code."'"; $Res2=ExecSql($p_cn,$sql2); @@ -320,4 +328,15 @@ $w=new widget("select"); echo ''; echo ''; } + +/*!\brief RemoveRow put a flag delete on a row of the table import_tmp + * (import_tmp.status) + * \param $p_cn database connection + * \param $p_code import_tmp.code must be unique + */ +function DropRecord($p_cn,$p_code) +{ + ExecSql($p_cn,"update import_tmp set status='d' where code='".$p_code."'"); +} + ?> diff --git a/include/ing_be.inc.php b/include/ing_be.inc.php index b8416f9e7..2854ec0c7 100644 --- a/include/ing_be.inc.php +++ b/include/ing_be.inc.php @@ -98,7 +98,7 @@ while (($data = fgetcsv($handle, 2000,'!@')) !== FALSE) { detail, bq_account , jrn, - ok) + status) values ('$code', '$date_exec', '$date_exec', @@ -108,7 +108,7 @@ while (($data = fgetcsv($handle, 2000,'!@')) !== FALSE) { '".addslashes($detail).$num_compte." ', '$p_bq_account', $p_jrn, - false)"; + 'n')"; echo $sql; $Res=ExecSql($p_cn,$Sql); } @@ -118,4 +118,4 @@ while (($data = fgetcsv($handle, 2000,'!@')) !== FALSE) { $row++; } // file is read fclose($handle); -?> \ No newline at end of file +?> diff --git a/sql/upgrade.sql b/sql/upgrade.sql index c3a325565..b0833438c 100644 --- a/sql/upgrade.sql +++ b/sql/upgrade.sql @@ -1,3 +1,25 @@ begin; +alter table import_tmp add column status char(1); +alter table import_tmp alter status set default 'w'; +update import_tmp set status = 't' where ok=true; +alter table import_tmp drop column ok ; +comment on table import_tmp is 'Table temporaire pour l''importation des banques en format CSV'; +comment on column import_tmp.status is 'Status doit être w pour en attente, t pour transfèrer ou d à effacer'; + + +create or replace function trim_cvs_quote() returns trigger as $trim$ +declare + modified import_tmp%ROWTYPE; +begin + modified:=NEW; + modified.devise=replace(new.devise,'"',''); + modified.poste_comptable=replace(new.poste_comptable,'"',''); + modified.compte_ordre=replace(NEW.COMPTE_ORDRE,'"',''); + modified.detail=replace(NEW.DETAIL,'"',''); + modified.num_compte=replace(NEW.NUM_COMPTE,'"',''); + return modified; +end; +$trim$ language plpgsql; + commit; \ No newline at end of file