36 |
*/ |
*/ |
37 |
|
|
38 |
function GetTvaRate($p_cn,$p_tva_id) { |
function GetTvaRate($p_cn,$p_tva_id) { |
39 |
|
// $p_tva_id is an empty string, returns 0 |
40 |
if (strlen(trim($p_tva_id))==0) return 0; |
if (strlen(trim($p_tva_id))==0) return 0; |
|
$Res=ExecSql($p_cn,"select tva_id,tva_rate,tva_label from tva_rate where tva_id=".$p_tva_id); |
|
|
if (pg_NumRows($Res) == 0 ) return null; |
|
41 |
|
|
42 |
$r=pg_fetch_array($Res,0); |
// Get vat info from the database |
43 |
return $r; |
$Res=ExecSql($p_cn,"select tva_id,tva_rate,tva_label from tva_rate where tva_id=".$p_tva_id); |
44 |
|
if (pg_NumRows($Res) == 0 ) return null; |
45 |
|
|
46 |
|
$r=pg_fetch_array($Res,0); |
47 |
|
return $r; |
48 |
|
|
49 |
} |
} |
50 |
/* function ComputeVat($p_cn,$a_fiche,$a_quant,$a_price,$ap_vat) |
/* function ComputeVat($p_cn,$a_fiche,$a_quant,$a_price,$ap_vat) |
56 |
* |
* |
57 |
* parm : |
* parm : |
58 |
* - database connection |
* - database connection |
59 |
* - fiche id array |
* - fiche id array |
60 |
* - quantity array |
* 1- quantity array |
61 |
* - price array |
* - price array |
62 |
* - $ap_vat Array of tva id |
* - $ap_vat Array of tva id |
63 |
* gen : |
* gen : |
64 |
* - |
* - |
65 |
* return: array |
* return: array |
72 |
} |
} |
73 |
$r=null; |
$r=null; |
74 |
// foreach goods |
// foreach goods |
75 |
|
//-- |
76 |
foreach ( $a_fiche as $idx=>$element) { |
foreach ( $a_fiche as $idx=>$element) { |
77 |
echo_debug ("idx $idx element $element"); |
echo_debug ("idx $idx element $element"); |
78 |
// if the card id is null or empty |
// if the card id is null or empty |
373 |
$r.="</TD>"; |
$r.="</TD>"; |
374 |
// echeance |
// echeance |
375 |
$r.="<TD>"; |
$r.="<TD>"; |
376 |
$r.=$row['jr_ech']; |
$r.=$row['jr_ech']; |
377 |
$r.="</TD>"; |
$r.="</TD>"; |
378 |
|
|
379 |
// comment |
// comment |
380 |
$r.="<TD>"; |
$r.="<TD>"; |
381 |
$r.=$row['jr_comment']; |
$r.=$row['jr_comment']; |
382 |
$r.="</TD>"; |
$r.="</TD>"; |
383 |
|
|
384 |
// Amount |
// Amount |
385 |
// If the ledger is financial : |
// If the ledger is financial : |
386 |
// the credit must be negative and written in red |
// the credit must be negative and written in red |
387 |
// Get the jrn type |
// Get the jrn type |
388 |
$jrn_prop=GetJrnProp($p_cn,$row['jrn_def_id'],1); |
$jrn_prop=GetJrnProp($p_cn,$row['jrn_def_id'],1); |
389 |
$positive=0; |
$positive=0; |
390 |
if ( $positive=1 && $jrn_prop['jrn_def_type'] == 'FIN' ) { |
if ( $positive=1 && $jrn_prop['jrn_def_type'] == 'FIN' ) { |
391 |
$positive = CountSql($p_cn,"select * from jrn inner join jrnx on jr_grpt_id=j_grpt ". |
$positive = CountSql($p_cn,"select * from jrn inner join jrnx on jr_grpt_id=j_grpt ". |
392 |
" where jr_id=".$row['jr_id']." and (j_poste like '55%' or j_poste like '57%' )". |
" where jr_id=".$row['jr_id']." and (j_poste like '55%' or j_poste like '57%' )". |
393 |
" and j_debit='f'"); |
" and j_debit='f'"); |
394 |
} |
} |
395 |
$r.="<TD align=\"right\">"; |
$r.="<TD align=\"right\">"; |
396 |
$r.=( $positive != 0 )?"<font color=\"red\"> - ".sprintf("%8.2f",$row['jr_montant'])."</font>":sprintf("%8.2f",$row['jr_montant']); |
$r.=( $positive != 0 )?"<font color=\"red\"> - ".sprintf("%8.2f",$row['jr_montant'])."</font>":sprintf("%8.2f",$row['jr_montant']); |
397 |
$r.="</TD>"; |
$r.="</TD>"; |
398 |
|
|
399 |
// Rapt |
// Rapt |
400 |
$a=GetConcerned($p_cn,$row['jr_id']); |
$a=GetConcerned($p_cn,$row['jr_id']); |
401 |
$r.="<TD>"; |
$r.="<TD>"; |
402 |
if ( $a != null ) { |
if ( $a != null ) { |
403 |
// $r.="operation concernée "; |
// $r.="operation concernée "; |
404 |
|
|
405 |
foreach ($a as $key => $element) { |
foreach ($a as $key => $element) { |
406 |
$r.= "<A class=\"detail\" HREF=\"javascript:viewDetail('".GetGrpt($p_cn,$element)."','$l_sessid')\" > ".GetInternal($p_cn,$element)."</A>"; |
$r.= "<A class=\"detail\" HREF=\"javascript:viewDetail('".GetGrpt($p_cn,$element)."','$l_sessid')\" > ".GetInternal($p_cn,$element)."</A>"; |
|
|
|
|
}//for |
|
|
}// if ( $a != null ) { |
|
|
$r.="</TD>"; |
|
|
//$l=user_jrn.php?action=update&line=91 |
|
|
|
|
|
if ( $row['jr_valid'] == 'f' ) { |
|
|
$r.="<TD> Opération annulée</TD>"; |
|
|
} |
|
|
else { |
|
|
// if ( $row ['p_closed'] == 'f' && $p_jrn != 0 ) { |
|
|
// TODO Add print |
|
|
$r.="<TD>"; |
|
|
// cancel operation |
|
|
$r.=sprintf('<input TYPE="BUTTON" VALUE="%s" onClick="cancelOperation(\'%s\',\'%s\',\'%s\')">', |
|
|
"Annuler",$row['jr_grpt_id'],$l_sessid,$p_jrn); |
|
|
$r.="</TD>"; |
|
|
// } |
|
|
} |
|
|
//document |
|
|
$r.="<TD>".sprintf('<A class="detail" HREF="show_document.php?jrn=%s&jr_grpt_id=%s">%s</A>', |
|
|
$p_jrn, |
|
|
$row['jr_grpt_id'], |
|
|
$row['jr_pj_name'])."</TD>"; |
|
|
|
|
|
// end row |
|
|
$r.="</tr>"; |
|
407 |
|
|
408 |
} |
}//for |
409 |
$r.="</table>"; |
}// if ( $a != null ) { |
410 |
|
$r.="</TD>"; |
411 |
|
//$l=user_jrn.php?action=update&line=91 |
412 |
|
|
413 |
|
if ( $row['jr_valid'] == 'f' ) { |
414 |
|
$r.="<TD> Opération annulée</TD>"; |
415 |
|
} else { |
416 |
|
// all operations can be removed either by setting to 0 the amount |
417 |
|
// or by writing the opposite operation if the period is closed |
418 |
|
$r.="<TD>"; |
419 |
|
// cancel operation |
420 |
|
$r.=sprintf('<input TYPE="BUTTON" VALUE="%s" onClick="cancelOperation(\'%s\',\'%s\',\'%s\')">', |
421 |
|
"Annuler",$row['jr_grpt_id'],$l_sessid,$p_jrn); |
422 |
|
$r.="</TD>"; |
423 |
|
} // else |
424 |
|
//document |
425 |
|
$r.="<TD>".sprintf('<A class="detail" HREF="show_document.php?jrn=%s&jr_grpt_id=%s">%s</A>', |
426 |
|
$p_jrn, |
427 |
|
$row['jr_grpt_id'], |
428 |
|
$row['jr_pj_name'])."</TD>"; |
429 |
|
|
430 |
|
// end row |
431 |
|
$r.="</tr>"; |
432 |
|
|
433 |
|
} |
434 |
|
$r.="</table>"; |
435 |
|
|
436 |
return array ($count,$r); |
return array ($count,$r); |
437 |
} |
} |
438 |
|
|