Operation details in HTML

We progress, some bugs are still there
  * files (show_pj.php)
  * removing a row from  of a table (javascript)
...
This commit is contained in:
Dany De Bontridder 2010-06-26 22:32:12 +00:00
parent d77a7009e5
commit ded1394c26
6 changed files with 132 additions and 16 deletions

View file

@ -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 '<FORM METHOD="POST" ENCTYPE="multipart/form-data" id="form_file">';
echo HtmlInput::hidden('act','loadfile');
echo dossier::hidden();
echo HtmlInput::hidden('jr_id',$jr_id);
echo HtmlInput::hidden('div',$div);
echo '<INPUT TYPE="FILE" id="file" onchange="submit(this)">';
echo '<INPUT TYPE="FILE" name="pj" onchange="submit(this)">';
echo '</FORM>';
exit();
} else {
echo "<html><head>";
$repo=new Database();
$theme=$repo->get_value("select the_filestyle from theme where the_name=$1",array($_SESSION['g_theme']));
echo " <LINK REL=\"stylesheet\" type=\"text/css\" href=\"$theme\" media=\"screen\">";
echo "</head>";
echo '<div class="content">';
$h=sprintf('<a class="mtitle" href="show_pj.php?gDossier=%d&jrn=%d&jr_grpt_id=%d">%s</a>',
$gDossier,$ledger,$obj->det->jr_grpt_id,h( $obj->det->jr_pj_name));
echo $h;
$x=sprintf('<a class="mtitle" href="ajax_ledger.php?gDossier=%d&div=%s&jr_id=%s&act=rmf" onclick="return confirm(\'Effacer le document ?\')">enlever</a>',
$gDossier,$div,$jr_id);
echo $x;
echo '</div>';
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 '<FORM METHOD="POST" ENCTYPE="multipart/form-data" id="form_file">';
echo HtmlInput::hidden('act','loadfile');
echo dossier::hidden();
echo HtmlInput::hidden('jr_id',$jr_id);
echo HtmlInput::hidden('div',$div);
echo '<INPUT TYPE="FILE" name="pj" onchange="submit(this)">';
echo '</FORM>';
$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');

View file

@ -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);

View file

@ -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

View file

@ -6,25 +6,33 @@ $oRap=new Acc_Reconciliation($cn);
$oRap->jr_id=$jr_id;
$aRap=$oRap->get();
if ($aRap != null ) {
echo '<table>';
echo '<tr>';
$tableid="tb"+$div;
echo '<table id="'.$tableid.'">';
for ($e=0;$e<count($aRap);$e++) {
$opRap=new Acc_Operation($cn);
$opRap->jr_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('<a href="#" onclick="'.$str.'" >'.$internal.'</A>').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('<a href="#" onclick="'.$str.'" >'.$internal.'</A>').td($amount).td($rmReconciliation->input()));
}
echo '</tr>';
echo '</table>';
}
?>
</legend>
<?
$search='<INPUT TYPE="BUTTON" class="button" VALUE="Cherche" OnClick="SearchJrn('.$gDossier.",'rapt','".$obj->det->jr_montant."')\">";
$rapt=new IText('rapt');
$search='<INPUT TYPE="BUTTON" class="button" VALUE="Cherche" OnClick="SearchJrn('.$gDossier.",'rapt".$div."','".$obj->det->jr_montant."')\">";
$rapt=new IText('rapt'.$div);
echo $rapt->input().$search;
?>
</fieldset>

View file

@ -6,4 +6,4 @@
*/
$str='?'.dossier::get()."&div=$div&act=file&jr_id=$jr_id";
?>
<iframe style="border:0;width:auto;height:50" src="<? echo 'ajax_ledger.php'.$str; ?>"> </iframe>
<iframe style="border:0;width:500;height:1050;overflow:auto" src="<? echo 'ajax_ledger.php'.$str; ?>"> </iframe>

View file

@ -48,7 +48,7 @@ echo td(_('Libellé')).td($itext->input());
</tr>
<tr>
<?
$itext=new IText('pj');
$itext=new IText('npj');
$itext->value=$obj->det->jr_pj_number;
echo td(_('Pièce')).td($itext->input());
?>