diff --git a/html/fiche_search.php b/html/fiche_search.php index 2712d6912..9885bc1b9 100644 --- a/html/fiche_search.php +++ b/html/fiche_search.php @@ -135,6 +135,7 @@ if ( isset ( $_POST['search']) ) { if (strlen(trim($e_fic_search) ) == 0 ) { $Res=ExecSql($cn,$sql); } else { + $e_fic_search=FormatString($e_fic_search); $Res=ExecSql($cn,"$sql and upper(vw_name) like upper('%$e_fic_search%')"); } @@ -149,7 +150,7 @@ if ( isset ( $_POST['search']) ) { //set focus on first "Select" button. $row=pg_fetch_array($Res,$i); - // if quick code is empty pass ( it not used for the contact) + // if quick code is empty pass if (trim($row['quick_code']) == "") continue; diff --git a/include/fiche_inc.php b/include/fiche_inc.php index f888bdcf3..72e21267b 100644 --- a/include/fiche_inc.php +++ b/include/fiche_inc.php @@ -1488,7 +1488,8 @@ function GetParent($p_cn,$p_val) * \param p_id quick_code * \param attribut if attribut == "" then return a array * taken from vw_fiche_attr - * \return string avec nom fiche or array + * \return string avec nom fiche is attr is not null + * or array is attr is empty * */ function getFicheAttribut($p_cn,$p_id,$p_attr="") { @@ -1520,15 +1521,14 @@ function getFicheAttribut($p_cn,$p_id,$p_attr="") { * \brief Check if a fiche is used by a jrn * return 1 if the fiche is in the range otherwise 0 * - * parm : - * - p_cn connextion - * - j_jrn journal_id - * - $p_type : deb or cred - * - $p_fiche : quick_code - * gen : - * - none + * + * \param $p_cn connextion + * \param $j_jrn journal_id + * \param $p_fiche : quick_code + * \param $p_type : deb or cred default empty + * * - * return 1 if the fiche is in the range otherwise 0 + * \return 1 if the fiche is in the range otherwise 0 * */ function IsFicheOfJrn($p_cn,$p_jrn,$p_fiche,$p_type="") diff --git a/include/user_common.php b/include/user_common.php index 036fa9b71..ff0c90f5d 100644 --- a/include/user_common.php +++ b/include/user_common.php @@ -600,7 +600,7 @@ function InsertStockGoods($p_cn,$p_j_id,$p_good,$p_quant,$p_type) // Retrieve the good account for stock $code_marchandise=GetFicheAttribut($p_cn,$p_good,ATTR_DEF_STOCK); $p_good=FormatString($p_good); - $sql="select f_id from vw_poste_qcode where j_qcode=upper('$p_good')/"; + $sql="select f_id from vw_poste_qcode where j_qcode=upper('$p_good')"; $Res=ExecSql($p_cn,$sql); $r=pg_fetch_array($Res,0); $f_id=$r['f_id']; diff --git a/include/user_form_ach.php b/include/user_form_ach.php index 2e09d6c30..9b260d21b 100644 --- a/include/user_form_ach.php +++ b/include/user_form_ach.php @@ -77,14 +77,9 @@ echo_debug('user_form_ach.php',__LINE__,"Enter FormAchInput($p_cn,$p_jrn,$p_peri echo_error('user_form_ach.php',__LINE__,'Erreur invalid request uri '.$href); exit (-1); } - - - // $r.="
"; $r.=""; } - $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.=''; // Date widget //-- @@ -122,18 +117,10 @@ echo_debug('user_form_ach.php',__LINE__,"Enter FormAchInput($p_cn,$p_jrn,$p_peri $e_client_label=""; // retrieve e_client_label - if ( isNumber($e_client) == 1 ) { - if ( isFicheOfJrn($p_cn,$p_jrn,$e_client,'cred') == 0 ) { - $msg="Fiche inexistante !!! "; - echo_error($msg); echo_error($msg); - // echo ""; - $e_client=""; - } else { - $a_client=GetFicheAttribut($p_cn,$e_client); - if ( $a_client != null) - $e_client_label=$a_client['vw_name']." adresse ".$a_client['vw_addr']." ".$a_client['vw_cp']; - } - } + $a_client=GetFicheAttribut($p_cn,$e_client); + if ( $a_client != null) + $e_client_label=$a_client['vw_name']." adresse ".$a_client['vw_addr']." ".$a_client['vw_cp']; + // widget search $W1=new widget("js_search"); $W1->label="Fournisseur"; diff --git a/include/user_form_ven.php b/include/user_form_ven.php index 9c0f66f3e..fd70aadd3 100644 --- a/include/user_form_ven.php +++ b/include/user_form_ven.php @@ -27,18 +27,17 @@ require_once("preference.php"); require_once("fiche_inc.php"); require_once("user_common.php"); /*! FormVenInput - \brief Display the form for a sell + * \brief Display the form for a sell * Used to show detail, encode a new invoice * or update one * - * \param - * - p_array which can be empty - * - the "journal" - * - $p_periode = periode - * - view_only if we cannot change it (no right or centralized op) - * - $p_article number of article + * + * \param p_array which can be empty + * \param the "journal" + * \param $p_periode = periode + * \param view_only if we cannot change it (no right or centralized op) + * \param $p_article number of article * \return string with the form - * TODO Add in parameters the infos about the company for making the invoice */ function FormVenInput($p_cn,$p_jrn,$p_periode,$p_array=null,$pview_only=true,$p_article=1) { @@ -83,8 +82,7 @@ function FormVenInput($p_cn,$p_jrn,$p_periode,$p_array=null,$pview_only=true,$p_ } - $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.='
'; // Date //-- @@ -126,18 +124,10 @@ function FormVenInput($p_cn,$p_jrn,$p_periode,$p_array=null,$pview_only=true,$p_ // retrieve e_client_label //-- - if ( isNumber($e_client) == 1 ) { - if ( isFicheOfJrn($p_cn,$p_jrn,$e_client,'deb') == 0 ) { - $msg="Fiche inexistante !!! "; - echo_error($msg); echo_error($msg); - echo ""; - $e_client=""; - } else { - $a_client=GetFicheAttribut($p_cn,$e_client); - if ( $a_client != null) - $e_client_label=$a_client['vw_name']." adresse ".$a_client['vw_addr']." ".$a_client['vw_cp']; - } - } + $a_client=GetFicheAttribut($p_cn,$e_client); + if ( $a_client != null) + $e_client_label=$a_client['vw_name']." adresse ".$a_client['vw_addr']." ".$a_client['vw_cp']; + $W1=new widget("js_search"); $W1->label="Client"; @@ -181,27 +171,18 @@ function FormVenInput($p_cn,$p_jrn,$p_periode,$p_array=null,$pview_only=true,$p_ $march_tva_label=""; $march_label=""; - // If $march has a value + // retrieve the tva label and name //-- - if ( isNumber($march) == 1 ) { - if ( isFicheOfJrn($p_cn,$p_jrn,$march,'cred') == 0 ) { - $msg="Fiche inexistante !!! "; - echo_error($msg); echo_error($msg); - echo ""; - $march=""; - } else { - // retrieve the tva label and name - //-- - $a_fiche=GetFicheAttribut($p_cn, $march); - if ( $a_fiche != null ) { - if ( $march_tva_id == "" ) { - $march_tva_id=$a_fiche['tva_id']; - $march_tva_label=$a_fiche['tva_label']; - } - $march_label=$a_fiche['vw_name']; - } + $a_fiche=GetFicheAttribut($p_cn, $march); + if ( $a_fiche != null ) { + if ( $march_tva_id == "" ) { + $march_tva_id=$a_fiche['tva_id']; + $march_tva_label=$a_fiche['tva_label']; } + $march_label=$a_fiche['vw_name']; } + + // Show input //-- $W1=new widget("js_search"); diff --git a/sql/upgrade.sql b/sql/upgrade.sql index e69de29bb..51a2dc965 100644 --- a/sql/upgrade.sql +++ b/sql/upgrade.sql @@ -0,0 +1,30 @@ +CREATE or replace FUNCTION insert_quant_sold + (p_internal text, + p_fiche character varying, + p_quant integer, + p_price numeric, + p_vat numeric, + p_vat_code integer, + p_client character varying) +RETURNS void + AS $$ +declare + fid_client integer; + fid_good integer; +begin + select f_id into fid_client from + attr_value join jnt_fic_att_value using (jft_id) where ad_id=23 and av_text=upper(p_client); + + select f_id into fid_good from + attr_value join jnt_fic_att_value using (jft_id) where ad_id=23 and av_text=upper(p_fiche); + + + insert into quant_sold + (qs_internal,qs_fiche,qs_quantite,qs_price,qs_vat,qs_vat_code,qs_client) + values + (p_internal,fid_good,p_quant,p_price,p_vat,p_vat_code,fid_client); + return; +end; +$$ + LANGUAGE plpgsql; +