From ded1394c267619629a1f7992865657ea49feb7da Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Sat, 26 Jun 2010 22:32:12 +0000 Subject: [PATCH] Operation details in HTML We progress, some bugs are still there * files (show_pj.php) * removing a row from of a table (javascript) ... --- html/ajax_ledger.php | 92 ++++++++++++++++++++++- html/js/acc_ledger.js | 24 ++++-- html/js/scripts.js | 6 ++ include/template/ledger_detail_bottom.php | 22 ++++-- include/template/ledger_detail_file.php | 2 +- include/template/ledger_detail_fin.php | 2 +- 6 files changed, 132 insertions(+), 16 deletions(-) diff --git a/html/ajax_ledger.php b/html/ajax_ledger.php index 1697cf7f7..3bf76ce72 100644 --- a/html/ajax_ledger.php +++ b/html/ajax_ledger.php @@ -99,18 +99,106 @@ case 'de': // form for the file ///////////////////////////////////////////////////////////////////////////// case 'file': + $op->get(); $obj=$op->get_quant(); /* return an obj. ACH / FIN or VEN or null if nothing is found*/ + + if ( $obj->det->jr_pj_name=='') { echo '
'; echo HtmlInput::hidden('act','loadfile'); echo dossier::hidden(); echo HtmlInput::hidden('jr_id',$jr_id); echo HtmlInput::hidden('div',$div); - echo ''; + echo ''; echo '
'; exit(); + } else { + echo ""; + $repo=new Database(); + $theme=$repo->get_value("select the_filestyle from theme where the_name=$1",array($_SESSION['g_theme'])); + echo " "; + echo ""; + echo '
'; + $h=sprintf('%s', + $gDossier,$ledger,$obj->det->jr_grpt_id,h( $obj->det->jr_pj_name)); + echo $h; + $x=sprintf('enlever', + $gDossier,$div,$jr_id); + echo $x; + echo '
'; + exit(); + } +///////////////////////////////////////////////////////////////////////////// +// load a file +///////////////////////////////////////////////////////////////////////////// case 'loadfile': - echo "save the file "; + if ( isset ($_FILES)) { + $cn->start(); + $grpt=$cn->get_value('select jr_grpt_id from jrn where jr_id=$1',array($jr_id)); + $cn->save_upload_document($grpt); + $cn->commit(); + } exit(); +///////////////////////////////////////////////////////////////////////////// +// remove a file +///////////////////////////////////////////////////////////////////////////// +case 'rmf': + echo '
'; + echo HtmlInput::hidden('act','loadfile'); + echo dossier::hidden(); + echo HtmlInput::hidden('jr_id',$jr_id); + echo HtmlInput::hidden('div',$div); + + echo ''; + echo '
'; + $ret=$cn->exec_sql("select jr_pj from jrn where jr_id=$1",array($jr_id)); + if (Database::num_row($ret) != 0) { + $r=Database::fetch_array($ret,0); + $old_oid=$r['jr_pj']; + if (strlen($old_oid) != 0) + { + // check if this pj is used somewhere else + $c=$cn->count_sql("select * from jrn where jr_pj=".$old_oid); + if ( $c == 1 ) + $cn->lo_unlink($old_oid); + } + $cn->exec_sql("update jrn set jr_pj=null, jr_pj_name=null, ". + "jr_pj_type=null where jr_id=$1",array($jr_id)); + } + exit(); +///////////////////////////////////////////////////////////////////////////// +// Save operation detail +///////////////////////////////////////////////////////////////////////////// + case 'save': + $cn->exec_sql('update jrn set jr_comment=$1,jr_pj_number=$2 where jr_id=$3', + array($_GET['lib'],$_GET['npj'],$jr_id)); + $rapt=$_GET['rapt']; + if (trim($rapt) != '') { + $rec=new Acc_Reconciliation ($cn); + $rec->set_jr_id($jr_id); + + if (strpos($rapt,",") != 0 ) { + $aRapt=explode(',',$rapt); + /* reconcialition */ + foreach ($aRapt as $rRapt) { + if ( isNumber($rRapt) == 1 ) + { + // Add a "concerned operation to bound these op.together + $rec->insert($rRapt); + } + } + } else + if ( isNumber($rapt) == 1 ) + { + $rec->insert($rapt); + } + } + break; + ///////////////////////////////////////////////////////////////////////////// + // remove a reconciliation +///////////////////////////////////////////////////////////////////////////// +case 'rmr': + + break; } $html=escape_xml($html); header('Content-type: text/xml; charset=UTF-8'); diff --git a/html/js/acc_ledger.js b/html/js/acc_ledger.js index 888deb0e3..a089f0190 100644 --- a/html/js/acc_ledger.js +++ b/html/js/acc_ledger.js @@ -467,9 +467,21 @@ function viewOperation(p_value,p_dossier) var win=window.open('modify_op.php?action=view_ca&line='+p_value+'&gDossier='+p_dossier,'','toolbar=no,width=690,height=410,scrollbars=yes,resizable=yes'); win.focus(); } -function dropLink(p_value,p_value2,p_dossier) { - var win=window.open('modify_op.php?action=delete&line='+p_value+'&line2='+p_value2+'&gDossier='+p_dossier,'Liaison','toolbar=no,width=500,height=400,scrollbars=yes,resizable=yes'); - } +function dropLink(p_dossier,p_div,p_jr_id,p_jr_id2) { + var querystring='?gDossier='+p_dossier; + querystring+='&div='+p_div; + querystring+='&jr_id='+p_jr_id; + querystring+='&act=rmr'; + querystring+='&jr_id2='+p_jr_id2; + var action=new Ajax.Request ( 'ajax_ledger.php', + { + method:'get', + parameters:querystring, + onFailure:null, + onSuccess:null + } + ); +} /** *@brief this function is called before the querystring is send to the * fid2.php, add a filter based on the ledger 'p_jrn' @@ -568,8 +580,9 @@ function search_letter(obj) { function op_save(obj) { queryString="?lib="+obj.lib.value; queryString+="&gDossier="+obj.gDossier.value; - queryString+="&rapt="+obj.rapt.value; - queryString+="&pj="+obj.pj.value; + var rapt2="rapt"+obj.whatdiv.value; + queryString+="&rapt="+g(rapt2).value; + queryString+="&npj="+obj.npj.value; queryString+='&jr_id='+obj.jr_id.value; queryString+='&div='+obj.whatdiv.value; queryString+='&act=save'; @@ -596,6 +609,7 @@ function op_success(req) { add_div(savebox); Effect.Fade(savebox.id,{duration:1.0} ); Effect.Fade(name_ctl,{duration:1.5}); +// removeDiv(savebox.id); removeDiv(name_ctl); } catch (e) { alert(e.message); diff --git a/html/js/scripts.js b/html/js/scripts.js index fda26a5e4..28e961579 100644 --- a/html/js/scripts.js +++ b/html/js/scripts.js @@ -36,6 +36,12 @@ if (confirm('Confirmez effacement')) g(tb).deleteRow(lidx); } } +function deleteRowRec(tb,obj) { + var td=obj.parentNode; + var tr=td.parentNode; + var lidx=tr.rowIndex; + g(tb).deleteRow(lidx); +} /*!\brief remove trailing and heading space * \param the string to modify * \return string without heading and trailing space diff --git a/include/template/ledger_detail_bottom.php b/include/template/ledger_detail_bottom.php index ddf77f51a..314a0a6ef 100644 --- a/include/template/ledger_detail_bottom.php +++ b/include/template/ledger_detail_bottom.php @@ -6,25 +6,33 @@ $oRap=new Acc_Reconciliation($cn); $oRap->jr_id=$jr_id; $aRap=$oRap->get(); if ($aRap != null ) { - echo ''; - echo ''; + $tableid="tb"+$div; + echo '
'; for ($e=0;$ejr_id=$aRap[$e]; $internal=$opRap->get_internal(); $amount=$cn->get_value('select jr_montant from jrn where jr_id=$1',array($aRap[$e])); $str="modifyOperation(".$aRap[$e].",".$gDossier.")"; - - echo td(''.$internal.'').td($amount); + $rmReconciliation=new IButton('rmr'); + $rmReconciliation->label='enlever'; + $rmReconciliation->javascript="if (confirm ('vous confirmez?') ) {"; + $rmReconciliation->javascript.=sprintf('dropLink(%s,%s,%s,%s);deleteRowRec(\'%s\',this);}', + $gDossier, + $div, + $jr_id, + $aRap[$e], + $tableid + ); + echo tr (td(''.$internal.'').td($amount).td($rmReconciliation->input())); } - echo ''; echo '
'; } ?> det->jr_montant."')\">"; -$rapt=new IText('rapt'); +$search='det->jr_montant."')\">"; +$rapt=new IText('rapt'.$div); echo $rapt->input().$search; ?> diff --git a/include/template/ledger_detail_file.php b/include/template/ledger_detail_file.php index 5495dac6f..47653bbdd 100644 --- a/include/template/ledger_detail_file.php +++ b/include/template/ledger_detail_file.php @@ -6,4 +6,4 @@ */ $str='?'.dossier::get()."&div=$div&act=file&jr_id=$jr_id"; ?> - \ No newline at end of file + \ No newline at end of file diff --git a/include/template/ledger_detail_fin.php b/include/template/ledger_detail_fin.php index 92cbee524..cfc408fbb 100644 --- a/include/template/ledger_detail_fin.php +++ b/include/template/ledger_detail_fin.php @@ -48,7 +48,7 @@ echo td(_('Libellé')).td($itext->input()); value=$obj->det->jr_pj_number; echo td(_('Pièce')).td($itext->input()); ?>