diff --git a/html/ajax_import.php b/html/ajax_import.php new file mode 100644 index 000000000..6102a2f60 --- /dev/null +++ b/html/ajax_import.php @@ -0,0 +1,75 @@ +Check(); +if ( isset ($_GET['action']) && + $_GET['action']=='update' + ) + + { + $code=FormatString($_GET['code']); + $count=FormatString($_GET['count']); + $poste=FormatString($_GET['poste']); + $concern=FormatString($_GET['concerned']); + $sql = "update import_tmp set poste_comptable='$poste' ,status='w',". + "jr_rapt='$concern' where code='$code'"; + + $Res=ExecSql($cn,$sql); + exit(); + } + +if ( isset ($_GET['action']) && + $_GET['action']=='delete' + ) + + { + $code=FormatString($_GET['code']); + $sql="update import_tmp set status='d' where code='".$code."'"; + ExecSql($cn,$sql); + exit(); + } +if ( isset ($_GET['action']) && + $_GET['action']=='not_confirmed' + ) + + { + $code=FormatString($_GET['code']); + $sql="update import_tmp set status='n' where code='".$code."'"; + ExecSql($cn,$sql); + exit(); + } diff --git a/html/import.php b/html/import.php index d80b32989..7aa96710b 100644 --- a/html/import.php +++ b/html/import.php @@ -40,7 +40,7 @@ $User=new cl_user($cn); $User->Check(); html_page_start($User->theme); - +echo JS_PROTOTYPE_JS; /* Admin. Dossier */ @@ -80,22 +80,12 @@ if ( isset ($_GET["action"]) ) { echo ""; } } - if ( isset ($_POST['trashit'])) { - DropRecord($cn,$_POST['code']); - echo '
'; - VerifImport($cn); - echo "
"; - exit(); - } if ($action == "verif" ) { - if(isset($_POST['count'])) { - UpdateCSV($cn); - } - echo '
'; VerifImport($cn); echo "
"; } + if ($action == "transfer" ) { echo '
'; diff --git a/html/js/scripts.js b/html/js/scripts.js index e602fb6b3..3898f1bc7 100644 --- a/html/js/scripts.js +++ b/html/js/scripts.js @@ -233,3 +233,85 @@ function ca_set_parent(p_ctl,p_value) { f.value=p_value; } +/*! \brief import : update a record (in ajax) + * \param $p_sessid : PHPSESSID + * \param $p_dossier : the dossier id + * \param $p_count : the item number + */ + +function import_update(p_sessid,p_dossier,p_count) { + // alert ("Dossier = "+p_dossier+" counter ="+p_count); + var query_string="PHPSESSID="+p_sessid+"&count="+p_count+"&gDossier="+p_dossier; + var code=$("code"+p_count); + var poste=$("poste"+p_count); + var concerned=$("e_concerned"+p_count); + var url="ajax_import.php"; + query_string+="&code="+code.value; + query_string+="&poste="+poste.value; + query_string+="&concerned="+concerned.value; + query_string+="&action=update"; + + + /* call the script which handle the query */ + var update= new Ajax.Request ( + url, + { + method:'get', + parameters:query_string, + } + ); + var form=$("form_"+p_count); + form.hide(); +} +/*! \brief remove : remove a record (in ajax) + * \param $p_sessid : PHPSESSID + * \param $p_dossier : the dossier id + * \param $p_count : the item number + */ + +function import_remove(p_sessid,p_dossier,p_count) { + // alert ("Dossier = "+p_dossier+" counter ="+p_count); + var query_string="PHPSESSID="+p_sessid+"&count="+p_count+"&gDossier="+p_dossier; + var code=$("code"+p_count); + var url="ajax_import.php"; + query_string+="&code="+code.value; + query_string+="&action=delete"; + var a = confirm("Etes-vous certain d'effacer cette operation ?"); + if ( a == false ) { return;} + + /* call the script which handle the query */ + var update= new Ajax.Request ( + url, + { + method:'get', + parameters:query_string, + } + ); + var form=$("form_"+p_count); + form.hide(); +} +/*! \brief remove : remove a record (in ajax) + * \param $p_sessid : PHPSESSID + * \param $p_dossier : the dossier id + * \param $p_count : the item number + */ + +function import_not_confirmed(p_sessid,p_dossier,p_count) { + // alert ("Dossier = "+p_dossier+" counter ="+p_count); + var query_string="PHPSESSID="+p_sessid+"&count="+p_count+"&gDossier="+p_dossier; + var code=$("code"+p_count); + var url="ajax_import.php"; + query_string+="&code="+code.value; + query_string+="&action=not_confirmed"; + + /* call the script which handle the query */ + var update= new Ajax.Request ( + url, + { + method:'get', + parameters:query_string, + } + ); + var form=$("form_"+p_count); + form.hide(); +} diff --git a/include/argenta_be.inc.php b/include/argenta_be.inc.php index 851a4e92d..61f5bd2bd 100644 --- a/include/argenta_be.inc.php +++ b/include/argenta_be.inc.php @@ -25,28 +25,27 @@ //----------------------------------------------------- // Bank Argenta //----------------------------------------------------- -$line=1; +$line=0; -while (($data = fgetcsv($handle, 2000,';')) !== FALSE) { +while (($data = fgetcsv($handle, 2000,"!")) !== FALSE) { $num = count($data); - for ($c=0; $c < $num; $c++) { if ( $line==1) { $row=split(';',$data[$c]); $num_compte=$row[1]; } - - if ( $line == 2 ) + if ( $line < 2 ) continue; //----------------------------------------------------- // Parsing CSV comes here //----------------------------------------------------- $row=split(';',$data[$c]); + echo 'ici sizeof $row = '.sizeof($row); echo_debug('argenta',__LINE__,'$row = '.var_export($row,true)); echo_debug('argenta',__LINE__,'sizeof($row)'.sizeof($row)); if ( sizeof ($row) < 9 ) continue; - + $date_exec=$row[5]; $date_val=$row[5]; @@ -64,7 +63,9 @@ while (($data = fgetcsv($handle, 2000,';')) !== FALSE) { //---------------------------------------------------- // Skip dubbel //---------------------------------------------------- -if ( CountSql($p_cn,"select * from import_tmp where code='$code' and num_compte='$num_compte' limit 2") != 0 ) + $code=FormatString($code); + $num_compte=FormatString($num_compte); + if ( CountSql($p_cn,"select * from import_tmp where code='$code' and num_compte='$num_compte' limit 2") != 0 ) { /* Skip it it already encoded */ echo "Doublon éliminé ".$detail; @@ -107,15 +108,16 @@ echo "
"; catch(Exception $e) { - echo_debug(__FILE__.":".__LINE__." Erreur : ".$e->getCode." msg ".$e->getMessage); + echo(__FILE__.":".__LINE__." Erreur : ".$e->getCode." msg ".$e->getMessage); rollback($p_cn); break; } } // for ($c=0;$c<$num;$c++) - $line++; + $line++; + } // file is read fclose($handle); - +commit($p_cn); ?> diff --git a/include/cbc_be.inc.php b/include/cbc_be.inc.php index e10477181..7a63cd77c 100644 --- a/include/cbc_be.inc.php +++ b/include/cbc_be.inc.php @@ -27,7 +27,7 @@ //----------------------------------------------------- $row=1; StartSql($p_cn); -while (($data = fgetcsv($handle, 2000,'!@')) !== FALSE) { +while (($data = fgetcsv($handle, 2000,'@')) !== FALSE) { $num = count($data); echo_debug('cbc_be',__LINE__,$num); echo_debug('cbc_be',__LINE__,var_export($data,true)); diff --git a/include/class_widget.php b/include/class_widget.php index ce4d40757..4e9330b8a 100644 --- a/include/class_widget.php +++ b/include/class_widget.php @@ -539,7 +539,7 @@ class widget { $r=sprintf("$td %s $etd $td - + $etd", $l_sessid, $this->name, @@ -547,6 +547,7 @@ class widget { $this->extra2, $this->label, $this->name, + $this->name, $this->value ); } else { diff --git a/include/constant.php b/include/constant.php index d8857379b..2f743e4b7 100644 --- a/include/constant.php +++ b/include/constant.php @@ -33,7 +33,7 @@ define ("domaine",""); define ("MAX_COMPTE",4); -define ("DEBUG","false"); +define ("DEBUG","true"); // securite correspond a la table // action @@ -225,7 +225,7 @@ function ChangeTVA(p_ctl,p_value) { define ("JS_AJAX_FICHE",''); define ("JS_AJAX_OP",''); - +define ("JS_PROTOTYPE_JS",''); // Sql string define ("SQL_LIST_ALL_INVOICE",""); diff --git a/include/debug.php b/include/debug.php index 198e911e6..8bd3a943d 100644 --- a/include/debug.php +++ b/include/debug.php @@ -35,7 +35,7 @@ function echo_debug ($file,$line="",$msg="") { if ( DEBUG=='true' ) { $f=fopen ($_ENV['TMP'].DIRECTORY_SEPARATOR."phpcompta.log","a+"); $a=var_export($msg,true); - $e=basename($file); + $e=basename($file); fwrite($f,"$e : $line $a\n"); fclose ($f); } diff --git a/include/dexia.inc.php b/include/dexia.inc.php index fb855c3da..d45d25bab 100644 --- a/include/dexia.inc.php +++ b/include/dexia.inc.php @@ -33,7 +33,7 @@ $LinesImported=0; $LinesDup=0; $row=1; StartSql($p_cn); -while (($data = fgetcsv($handle, 2000,'!@')) !== FALSE) +while (($data = fgetcsv($handle, 2000,'@')) !== FALSE) { $num = count($data); echo_debug('dexia_be',__LINE__,$num); diff --git a/include/dexia_be.inc.php b/include/dexia_be.inc.php index f4d92129c..080a6fb42 100644 --- a/include/dexia_be.inc.php +++ b/include/dexia_be.inc.php @@ -33,7 +33,7 @@ $LinesImported=0; $LinesDup=0; $row=1; StartSql($p_cn); -while (($data = fgetcsv($handle, 2000,'!@')) !== FALSE) { +while (($data = fgetcsv($handle, 2000,'@')) !== FALSE) { $num = count($data); echo_debug('dexia_be',__LINE__,$num); echo_debug('dexia_be',__LINE__,var_export($data,true)); diff --git a/include/eub_be.inc.php b/include/eub_be.inc.php index 97b4999d5..ede84b7c6 100644 --- a/include/eub_be.inc.php +++ b/include/eub_be.inc.php @@ -27,7 +27,7 @@ // Bank type = eub //----------------------------------------------------- $row=1; -while (($data = fgetcsv($handle, 2000,'!@')) !== FALSE) { +while (($data = fgetcsv($handle, 2000,'@')) !== FALSE) { $num = count($data); for ($c=0; $c < $num; $c++) { diff --git a/include/fortis_be.inc.php b/include/fortis_be.inc.php index 220fa4491..1e9cdf2cd 100644 --- a/include/fortis_be.inc.php +++ b/include/fortis_be.inc.php @@ -27,7 +27,7 @@ // Fortis Bank //----------------------------------------------------- $row=1; -while (($data = fgetcsv($handle, 2000,'!@')) !== FALSE) { +while (($data = fgetcsv($handle, 2000,'@')) !== FALSE) { $num = count($data); for ($c=0; $c < $num; $c++) { diff --git a/include/import_inc.php b/include/import_inc.php index 349ba07d9..c85cd21c4 100644 --- a/include/import_inc.php +++ b/include/import_inc.php @@ -85,7 +85,7 @@ function UpdateCSV($p_cn){ * modify the Quick Code or remove record poss.value are form, remove */ function ShowBox($p_val,$counter,$p_cn,$p_form='form'){ - echo JS_AJAX_FICHE; + $w=new widget('js_search_only'); $w->name='poste'.$counter; $w->extra='cred'; @@ -97,6 +97,7 @@ function ShowBox($p_val,$counter,$p_cn,$p_form='form'){ // widget concerned $wConcerned=new widget('js_concerned'); + $wConcerned->name="e_concerned"+$counter; $wConcerned->extra=abs($p_val['montant']); $wConcerned->extra2='paid'; $wConcerned->label='op. concernée'; @@ -117,7 +118,7 @@ function ShowBox($p_val,$counter,$p_cn,$p_form='form'){ $f->GetByQCode($p_val['poste_comptable']); $s->value=$f->strAttribut(ATTR_DEF_NAME); } - echo ''; + echo ''; echo ''; echo ''; echo ''; @@ -129,25 +130,33 @@ function ShowBox($p_val,$counter,$p_cn,$p_form='form'){ echo ""; if ( $p_form == 'form') { - echo ''; + $str_update=sprintf("import_update('%s','%s','%s');", + $_REQUEST['PHPSESSID'], + dossier::id(), + $counter); + $str_remove=sprintf("import_remove('%s','%s','%s');", + $_REQUEST['PHPSESSID'], + dossier::id(), + $counter); + + echo ''; + } + if ($p_form == 'remove' ) { + $str_notconfi=sprintf("import_not_confirmed('%s','%s','%s');", + $_REQUEST['PHPSESSID'], + dossier::id(), + $counter); + + echo ''; } - if ($p_form == 'remove' ) - echo ''; echo '
'.$p_val['code'].''.$p_val['date_exec'].''.$p_val['montant'].' EUR
n° compte : ".$p_val['num_compte']."'; - echo '
'; + echo ''. + '
'; } -/*!\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) -{ - $sql="update import_tmp set poste_comptable=null,status='n' where code='".$_POST['code']."'"; - ExecSql($cn,$sql); -} - /*!\brief Verify the import */ @@ -161,8 +170,10 @@ function VerifImport($p_cn){ // include javascript for popup echo JS_SEARCH_CARD; echo JS_CONCERNED_OP; + echo JS_AJAX_FICHE; + echo JS_PROTOTYPE_JS; while($val = pg_fetch_array($Res)){ - echo '
'; + echo ''; echo dossier::hidden(); ShowBox($val,$i,$p_cn,'form'); echo '
'; @@ -176,6 +187,7 @@ function VerifImport($p_cn){ * \param $periode user's periode */ function ConfirmTransfert($p_cn,$periode){ + $sql = "select to_char(p_start,'DD-MM-YYYY') as p_start,to_char(p_end,'DD-MM-YYYY') as p_end". " from parm_periode where p_id = '".$periode."'"; $Res=ExecSql($p_cn,$sql); @@ -204,14 +216,14 @@ function ConfirmTransfert($p_cn,$periode){ $i=1; while($val = pg_fetch_array($Res)){ - echo '
'; + echo ''; echo dossier::hidden(); echo ''; ShowBox($val,$i,$p_cn,'remove'); echo '
'; $i++; } - echo '
'; + echo ''; echo dossier::hidden(); echo ''; echo ''; diff --git a/include/ing_be.inc.php b/include/ing_be.inc.php index ede26ea58..c41efc659 100644 --- a/include/ing_be.inc.php +++ b/include/ing_be.inc.php @@ -27,7 +27,7 @@ // Bank ING //----------------------------------------------------- $row=1; -while (($data = fgetcsv($handle, 2000,'!@')) !== FALSE) { +while (($data = fgetcsv($handle, 2000,'@')) !== FALSE) { $num = count($data); for ($c=0; $c < $num; $c++) {