diff --git a/include/class_widget.php b/include/class_widget.php
index abad9e608..c0a8d23a3 100644
--- a/include/class_widget.php
+++ b/include/class_widget.php
@@ -53,21 +53,22 @@ class widget {
function SetReadOnly($p_read) {
$this->readonly=$p_read;
}
- /*+++
- function IOValue($p_name,$p_value="",$p_label="") {
- purpose : create the INPUT tag
- parameters: $p_name is the INPUT NAME
- $p_value is the INPUT VALUE or an array for select
- $p_label is the label of the INPUT
- return : string containing the tag
- +++*/
+ /* function IOValue($p_name,$p_value="",$p_label="")
+ *****************************************************
+ * purpose : create the corresponding INPUT tag
+ *
+ * parameters: $p_name is the INPUT NAME
+ * $p_value is the INPUT VALUE or an array for select
+ * $p_label is the label of the INPUT
+ * return : string containing the tag
+ */
function IOValue($p_name=null,$p_value=null,$p_label="") {
- // echo __FILE__."p_value $p_value";
+
if ( $p_name != null)
$this->name=$p_name;
$this->value=($p_value===null)?$this->value:$p_value;
$this->label=($p_label == "")?$this->label:$p_label;
- //echo "this->value =".$this->value;
+
// Input text type
$disabled = $this->disabled ? "DISABLED" : "";
if (strtoupper($this->type)=="TEXT") {
diff --git a/include/user_common.php b/include/user_common.php
index 00a1e5b4a..33c27b29e 100644
--- a/include/user_common.php
+++ b/include/user_common.php
@@ -36,12 +36,15 @@ include_once("postgres.php");
*/
function GetTvaRate($p_cn,$p_tva_id) {
+ // $p_tva_id is an empty string, returns 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;
-$r=pg_fetch_array($Res,0);
-return $r;
+ // Get vat info from the database
+ $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;
+
+ $r=pg_fetch_array($Res,0);
+ return $r;
}
/* function ComputeVat($p_cn,$a_fiche,$a_quant,$a_price,$ap_vat)
@@ -53,10 +56,10 @@ return $r;
*
* parm :
* - database connection
- * - fiche id array
- * - quantity array
- * - price array
- * - $ap_vat Array of tva id
+ * - fiche id array
+ * 1- quantity array
+ * - price array
+ * - $ap_vat Array of tva id
* gen :
* -
* return: array
@@ -69,6 +72,7 @@ echo_debug(__FILE__,__LINE__,"ComputeVat $a_fiche $a_quant $a_price");
}
$r=null;
// foreach goods
+//--
foreach ( $a_fiche as $idx=>$element) {
echo_debug ("idx $idx element $element");
// if the card id is null or empty
@@ -369,68 +373,66 @@ function ListJrn($p_cn,$p_jrn,$p_where="",$p_array=null,$p_value=0)
$r.="";
// echeance
$r.="
";
+
+ // Amount
+ // If the ledger is financial :
+ // the credit must be negative and written in red
+ // Get the jrn type
+ $jrn_prop=GetJrnProp($p_cn,$row['jrn_def_id'],1);
+ $positive=0;
+ if ( $positive=1 && $jrn_prop['jrn_def_type'] == 'FIN' ) {
+ $positive = CountSql($p_cn,"select * from jrn inner join jrnx on jr_grpt_id=j_grpt ".
+ " where jr_id=".$row['jr_id']." and (j_poste like '55%' or j_poste like '57%' )".
+ " and j_debit='f'");
+ }
+ $r.="
";
-
-// Amount
- // If the ledger is financial :
- // the credit must be negative and written in red
- // Get the jrn type
- $jrn_prop=GetJrnProp($p_cn,$row['jrn_def_id'],1);
- $positive=0;
- if ( $positive=1 && $jrn_prop['jrn_def_type'] == 'FIN' ) {
- $positive = CountSql($p_cn,"select * from jrn inner join jrnx on jr_grpt_id=j_grpt ".
- " where jr_id=".$row['jr_id']." and (j_poste like '55%' or j_poste like '57%' )".
- " and j_debit='f'");
- }
- $r.="
";
+ } else {
+ // all operations can be removed either by setting to 0 the amount
+ // or by writing the opposite operation if the period is closed
+ $r.="
";
+
+ // end row
+ $r.="";
+
+ }
+ $r.="";
+
return array ($count,$r);
}
diff --git a/include/user_form_ach.php b/include/user_form_ach.php
index 33128ff92..f0ea02745 100644
--- a/include/user_form_ach.php
+++ b/include/user_form_ach.php
@@ -29,15 +29,14 @@ require_once("user_common.php");
* or update one
*
* parm :
- * - p_array which can be empty
- * - the "journal"
+ * - $p_array which can be empty (normally = $_POST)
+ * - $p_jrn the ledger
* - $p_periode = periode
- * - view_only if we cannot change it (no right or centralized op)
+ * - $pview_only if we cannot change it (no right or centralized op)
* - $p_article number of article
* gen :
* -
* return: string with the form
- * TODO Add in parameters the infos about the company for making the invoice
*/
function FormAchInput($p_cn,$p_jrn,$p_periode,$p_array=null,$p_submit="",$pview_only=true,$p_article=1)
{
@@ -51,7 +50,7 @@ function FormAchInput($p_cn,$p_jrn,$p_periode,$p_array=null,$p_submit="",$pview_
$op_date=( ! isset($e_date) ) ?substr($l_date_start,2,8):$e_date;
$e_ech=(isset($e_ech))?$e_ech:"";
$e_comm=(isset($e_comm))?$e_comm:"";
- // $e_jrn=(isset($e_jrn))?$e_jrn:"";
+
// Save old value and set a new one
echo_debug(__FILE__,__LINE__,"form_input.php.FormSell_op_date is $op_date");
$r="";
@@ -65,20 +64,24 @@ function FormAchInput($p_cn,$p_jrn,$p_periode,$p_array=null,$p_submit="",$pview_
$sql="select jrn_def_id as value,jrn_def_name as label from jrn_def where jrn_def_type='VEN'";
$list=GetArray($p_cn,$sql);
$r.='
";
// price
$Price=new widget("text");
$Price->SetReadOnly($pview_only);
$Price->table=1;
- //$r.=InputType("","text","e_march".$i."_sell",$march_sell,$pview_only);
$r.=$Price->IOValue("e_march".$i."_sell",$march_sell);
// vat label
+ //--
$select_tva=make_array($p_cn,"select tva_id,tva_label from tva_rate order by tva_id",1);
$Tva=new widget("select");
$Tva->table=1;
@@ -200,6 +209,7 @@ function FormVenInput($p_cn,$p_jrn,$p_periode,$p_array=null,$pview_only=true,$p_
$r.=$Tva->IOValue("e_march$i"."_tva_id",$select_tva);
// quantity
+ //--
$quant=(isset(${"e_quant$i"}))?${"e_quant$i"}:"0";
$Quantity=new widget("text");
$Quantity->SetReadOnly($pview_only);
@@ -562,13 +572,14 @@ function RecordInvoice($p_cn,$p_array,$p_user,$p_jrn)
$periode=$p_user->GetPeriode();
$amount=0.0;
// Computing total customer
+ //--
for ($i=0;$i<$nb_item;$i++) {
// store quantity & goods in array
$a_good[$i]=${"e_march$i"};
$a_quant[$i]=${"e_quant$i"};
$a_price[$i]=0;
$a_vat[$i]=${"e_march$i"."_tva_id"};
- // check wether the price is set or no
+ // check whether the price is set or no
if ( isNumber(${"e_march$i"."_sell"}) == 0 ) {
if ( isNumber($a_good[$i]) == 1 ) {
// If the price is not set we have to find it from the database
@@ -579,10 +590,12 @@ function RecordInvoice($p_cn,$p_array,$p_user,$p_jrn)
$a_price[$i]=${"e_march$i"."_sell"};
}
$amount+=$a_price[$i]*$a_quant[$i];
- }
- $comm=FormatString($e_comm);
- $a_vat=ComputeVat($p_cn,$a_good,$a_quant,$a_price,$a_vat);
+ }// for
+ $comm=FormatString($e_comm);
+ // Compute VAT
+ //--
+ $a_vat=ComputeVat($p_cn,$a_good,$a_quant,$a_price,$a_vat);
$sum_vat=0.0;
if ( $a_vat != null ){
foreach ( $a_vat as $element => $t) {