$v) { ${"$a"}=$v; } } // The date list ($l_date_start,$l_date_end)=GetPeriode($p_cn,$p_periode); $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('user_form_ven.php',__LINE__,"form_input.php.FormVentep_op_date is $op_date"); $r=""; if ( $pview_only == false) { $r.=JS_SEARCH_CARD; $r.=JS_SHOW_TVA; $r.=JS_TVA; // Compute href // $href=basename($_SERVER['PHP_SELF']); $href=basename($_SERVER['PHP_SELF']); switch ($href) { // user_jrn.php case 'user_jrn.php': $href="user_jrn.php?action=insert_vente&p_jrn=$p_jrn"; break; case 'commercial.php': $href="commercial.php?p_action=facture&p_jrn=$p_jrn"; break; default: echo_error('user_form_ven.php',__LINE__,'Erreur invalid request uri'); exit (-1); } $r.="
"; $r.=JS_CALC_LINE; } else { $r.=""; } return $r; } /*! form_verify_input ************************************************** \brief verify if the data to insert are valid * * parm : * - p_cn database connection * - p_jrn concerned ledger * - User periode * - array with the post data * - p_number number of items * gen : * - * return: */ function form_verify_input($p_cn,$p_jrn,$p_periode,$p_array,$p_number) { foreach ($p_array as $name=>$content) { ${"$name"}=$content; } // Verify the date if ( isDate($e_date) == null ) { echo_error("Invalid date $e_date"); echo_debug('user_form_ven.php',__LINE__,"Invalid date $e_date"); echo ""; return null; } // Verify the quantity for ($o = 0;$o < $p_number; $o++) { if ( isNumber(${"e_quant$o"}) == 0 ) { echo_debug('user_form_ven.php',__LINE__,"invalid quantity ".${"e_quant$o"}); echo_error("invalid quantity ".${"e_quant$o"}); echo ""; return null; } // check if vat is correct if ( strlen(trim(${"e_march$o"."_tva_id"})) !=0 and ${"e_march$o"."_tva_id"} != "-1") { // vat is given we check it now check if valid if (isNumber(${"e_march$o"."_tva_id"}) == 0 or CountSql($p_cn,"select tva_id from tva_rate where tva_id=".${"e_march$o"."_tva_id"}) ==0) { $msg="Invalid TVA !!! e_march".$o."_tva_id = ".${"e_march".$o."_tva_id"}; echo_error($msg); echo_error($msg); echo ""; return null; } } } // Verify the ech if (strlen($e_ech) != 0 and isNumber($e_ech) == 0 and isDate ($e_ech) == null ) { $msg="Echeance invalide"; echo_error($msg); echo_error($msg); echo ""; return null; } // if ech is a number of days then compute date limit if ( strlen($e_ech) != 0 and isNumber($e_ech) == 1) { list($day,$month,$year)=explode(".",$e_date); echo_debug('user_form_ven.php',__LINE__," date $e_date = $day.$month.$year"); $p_ech=date('d.m.Y',mktime(0,0,0,$month,$day+$e_ech,$year)); echo_debug('user_form_ven.php',__LINE__,"p_ech = $e_ech $p_ech"); $e_ech=$p_ech; $wHidden=new widget("hidden"); $data.=$wHidden->IOValue("e_ech",$e_ech); } // Check if the fiche is in the jrn if (IsFicheOfJrn($p_cn , $p_jrn, $e_client,'deb') == 0 ) { $msg="Client invalid please recheck"; echo_error($msg); echo ""; return null; } // Check if the card has a valid account if ( CheckPoste($p_cn,$e_client) == null ) return null; // check if all e_march are in fiche for ($i=0;$i<$p_number;$i++) { if ( trim(${"e_march$i"}) == "" ) { // no goods to sell continue; } // Check if ( isFicheOfJrn($p_cn,$p_jrn,${"e_march$i"},'cred') == 0 ) { $msg="Fiche inexistante !!! "; echo_error(__FILE__.__LINE__.$msg); echo ""; return null; } // Check if the card has a valid account if ( CheckPoste($p_cn,${"e_march$i"}) == null ) return null; } // Verify the userperiode // p_periode contient la periode par default list ($l_date_start,$l_date_end)=GetPeriode($p_cn,$p_periode); // Date dans la periode active echo_debug ('user_form_ven',__LINE__,"date start periode $l_date_start date fin periode $l_date_end date demande $e_date"); if ( cmpDate($e_date,$l_date_start)<0 || cmpDate($e_date,$l_date_end)>0 ) { $msg="Not in the active periode please change your preference"; echo ""; return null; } // Periode ferme if ( PeriodeClosed ($p_cn,$p_periode)=='t' ) { $msg="This periode is closed please change your preference"; echo_error($msg); echo_error($msg); echo ""; return null; } return true; } /*! FormVenteView ($p_cn,$p_jrn,$p_periode,$p_array,$p_number,$p_doc='html',$p_comment='') ************************************************** * \brief Show the invoice before inserting it * the database. * * * \param p_cn database connection * \param p_jrn journal * \param p_periode * \param array of value * \param nb of item * \param p_doc type pdf or html * \return string * */ function FormVenteView ($p_cn,$p_jrn,$p_periode,$p_array,$p_number,$p_doc='form',$p_comment='') { $r=""; $data=""; $head_ca=""; // Keep all the data if hidden // and store the array in variables $hidden=new widget("hidden"); foreach ($p_array as $name=>$content) { $data.=$hidden->IOValue($name,$content); ${"$name"}=$content; } // Compute href // $href=basename($_SERVER['PHP_SELF']); $href=basename($_SERVER['PHP_SELF']); switch ($href) { // user_jrn.php case 'user_jrn.php': $href="user_jrn.php?action=record&p_jrn=$p_jrn"; break; case 'commercial.php': $href="commercial.php?p_action=facture&sa=record&p_jrn=$p_jrn"; break; default: echo_error('user_form_ven.php',__LINE__,'Erreur invalid request uri'); exit (-1); } //---------------------------------------------------------------------- // Compute the col head for CA $head_ca=""; $own = new Own($p_cn); if ( $own->MY_ANALYTIC != "un" ) { $plan=new PlanAnalytic($p_cn); $a_plan=$plan->get_list(); foreach ($a_plan as $r_plan) { $head_ca.="