Go to the source code of this file.
Functions | |
AddFiche ($p_cn, $p_type, $p_array) | |
ajoute une nouvelle fiche | |
EncodeFiche ($p_cn, $p_type, $p_array=null) | |
Affiche les détails d'une fiche et propose de mettre à jour ou si array est a null, permet d'ajouter une fiche, to fill the attribute. | |
GetBaseFiche ($p_cn, $p_type) | |
donne la classe comptable de base d'une fiche | |
GetBaseFicheDefault ($p_cn, $p_type) | |
Give the default accounts of fiche_def. | |
ViewFiche ($p_cn, $p_type) | |
Montre les fiches d'une rubrique. | |
GetNextFiche ($p_cn, $p_base) | |
Crée le poste suivant pour une fiche en fonction de la classe de base (fichedef(fd_class_base)). | |
ViewFicheDetail ($p_cn, $p_id) | |
Montre le detail d'une fiche et ajoute les lignes manquantes dans le cas où le modèle à changer. | |
UpdateFiche ($p_cn, $p_array) | |
Met a jour une fiche change dans le plan comptable, fiche,et isupp. | |
EncodeModele ($p_js) | |
parm :
| |
DefModele ($p_cn, $p_js, $p_array=null, $p_ligne=1) | |
Creation of a model of card or correction. | |
AddModele ($p_cn, $p_array) | |
Add a modele of card into the database. | |
UpdateModele ($p_cn, $p_fiche) | |
Modify the model of card change some attribute (fd_label) and permit to add line. | |
GetDataModele ($p_cn, $p_fiche) | |
Return the info of an fiche identified by p_fiche. | |
Remove ($p_cn, $p_fid) | |
enleve une fiche dans attr_value, jnt_fic_att_value et fiche a la condition que ce poste n'aie jamais été utilisé parm :
p_fid fiche(f_id) gen :
| |
getFicheName ($p_cn, $p_id) | |
retourne le nom de la fiche en fournissant le quick_code | |
getFicheNameById ($p_cn, $p_id) | |
retourne le nom de la fiche en fournissant le f_id | |
getFicheDefName ($p_cn, $p_id) | |
retourne le nom de la cat. de fiches | |
GetFicheJrn ($p_cn, $p_jrn, $p_type) | |
Get all the fiche related to a "journal". | |
Get_fiche_def_ref ($p_cn) | |
return an array containing all the data contained in the table fiche_def_ref parm :
| |
Get_attr_min ($p_cn, $p_fiche_def_ref) | |
retrieve the mandatory field of the card model | |
Get_attr_def ($p_cn, $p_fiche_def) | |
retrieve the fields of the card model | |
GetCreateAccount ($p_cn, $p_fiche_def) | |
retrieve the fields of the card model which indicate if each cards needs its own account parm :
$p_fiche_def_ref fiche_def.fd_id gen :
| |
GetFicheDefRef ($p_cn, $p_f_id) | |
retrieve the fiche_def.frd_id thanks the f_id of a card | |
GetFicheDef ($p_cn, $p_f_id) | |
retrieve the fiche_def.fd_id thanks the f_id of a card | |
GetClass ($p_cn, $p_fid) | |
Retrieve the account of a card. | |
InsertModeleLine ($p_cn, $p_fid, $p_adid) | |
Insert a new row into jnt_fic_attr for adding a new attribute to the card model parm :
the fiche_def.fd_id, id of the cat of the model
| |
SaveModeleName ($p_cn, $p_fid, $p_label) | |
Update the model's name. | |
DisplayDetailModele ($p_cn, $p_array, $MaxLine) | |
Show the data contained in an array of a model of card (fiche_def). | |
GetParent ($p_cn, $p_val) | |
Get the parent in tmp_pcmn. | |
getFicheAttribut ($p_cn, $p_id, $p_attr="") | |
retrun array of attribut or string | |
IsFicheOfJrn ($p_cn, $p_jrn, $p_fiche, $p_type="") | |
Check if a fiche is used by a jrn return 1 if the fiche is in the range otherwise 0. |
Definition in file fiche_inc.php.
|
ajoute une nouvelle fiche
Definition at line 38 of file fiche_inc.php. References $flag, $num, $p_parent, $Res, $sql, $Sql, CountSql(), echo_debug(), echo_error(), ExecSql(), exit, FormatString(), Get_attr_def(), GetBaseFiche(), GetCreateAccount(), GetNextFiche(), GetSequence(), and isNumber(). 00038 { 00039 // TODO ADD ROLLBACK !!! 00040 echo_debug('fiche_inc.php',__LINE__," AddFiche($p_cn,$p_type,$p_array) "); 00041 // Push the array in element starting with p 00042 // 00043 foreach ($p_array as $key=>$element){ 00044 ${"p_$key"}=$element; 00045 echo_debug('fiche_inc.php',__LINE__,"p_$key=$element;"); 00046 } 00047 // First verify that the name is not null 00048 // av_text.ATTR_DEF_NAME 00049 if ( strlen(trim($p_av_text0 )) ==0 ) 00050 return; 00051 00052 // First Get the attr of the fiche 00053 $field=Get_attr_def($p_cn,$p_fd_id); 00054 00055 $flag=1; 00056 00057 // Create the Fiche 00058 $Sql="insert into fiche (fd_id) values (".$p_fd_id.")"; 00059 $Res=ExecSql($p_cn,$Sql); 00060 00061 // Get is f_id (sequence) 00062 $l_f_id=GetSequence($p_cn,'s_fiche'); 00063 00064 // Should we Create accounts for each cards 00065 $create=GetCreateAccount($p_cn,$p_fd_id); 00066 00067 00068 // Is a account given ? 00069 for ( $i = 0; $i < $p_inc;$i++) { 00070 //Except for the class base 00071 if ( ${"p_ad_id$i"} == ATTR_DEF_ACCOUNT ) { 00072 if (strlen (trim(${"p_av_text$i"})) == 0 or 00073 isNumber(${"p_av_text$i"}) == 0 ) 00074 { 00075 break; 00076 } 00077 // if account already exist do nothing in tmp_pcmn otherwise add it 00078 if (CountSql($p_cn,"select pcm_val from tmp_pcmn where pcm_val=".${"p_av_text$i"}) == 0 ) 00079 { 00080 $len=strlen(${"p_av_text$i"})-1; 00081 // Mother account 00082 $p_parent=substr(${"p_av_text$i"},0,$len); 00083 while (CountSql($p_cn,"select pcm_val from tmp_pcmn where pcm_val=$p_parent") == 0 and 00084 $len > 0 ) { 00085 $len--; 00086 $p_parent=substr(${"p_av_text$i"},0,$len); 00087 } 00088 // If no parent found 00089 if ( $len <= 0 ) { 00090 echo_error ("No parent found"); 00091 exit("No parent found for ".${"p_av_text$i"}); 00092 00093 } // if $len == 0 00094 $lib=FormatString($p_av_text0); 00095 $sql=sprintf("insert into tmp_pcmn (pcm_val,pcm_lib,pcm_val_parent) 00096 values (%s,'%s',%d)", 00097 ${"p_av_text$i"}, 00098 $lib, 00099 $p_parent); 00100 00101 // Add if into tmp_pcmn 00102 $Res=ExecSql($p_cn,$Sql); 00103 } 00104 // Add it the jnt table 00105 // 5 is always for the account post 00106 $Sql=sprintf("insert into jnt_fic_att_value (f_id,ad_id) values (%d,%d)", 00107 $l_f_id,ATTR_DEF_ACCOUNT); 00108 $Res=ExecSql($p_cn,$Sql); 00109 00110 // Get the jft_id sequence (s_jnt_fic_att_value) 00111 $l_jft_id=GetSequence($p_cn,'s_jnt_fic_att_value'); 00112 00113 00114 // Add it the attr_value table 00115 $Sql=sprintf("insert into attr_value(jft_id,av_text) values (%d,'%s')", 00116 $l_jft_id,${"p_av_text$i"}); 00117 $Res=ExecSql($p_cn,$Sql); 00118 // If create == 0 we don't create automatically an account 00119 $create=0; 00120 } 00121 00122 } // for $i... 00123 00124 echo_debug ( " create = $create "); 00125 if ( $create == 1 ) { 00126 // We create an account for each 00127 // Get The Class Base 00128 $base=GetBaseFiche($p_cn,$p_type); 00129 00130 // If a specific post account is needed created it 00131 00132 if ( $base !=null ) { 00133 // if the class base is not null, create it in the tmp_pcmn 00134 $num=GetNextFiche($p_cn,$base); 00135 00136 $lib=FormatString($p_av_text0); 00137 $sql=sprintf("insert into tmp_pcmn (pcm_val,pcm_lib,pcm_val_parent) 00138 values (%s,'%s',%d)", 00139 $num, 00140 $lib, 00141 $base); 00142 echo_debug($sql); 00143 $Res=ExecSql($p_cn,$sql); 00144 // Add it the jnt table 00145 // 5 is always for the account post 00146 $Sql=sprintf("insert into jnt_fic_att_value (f_id,ad_id) values (%d,%d)", 00147 $l_f_id,ATTR_DEF_ACCOUNT); 00148 $Res=ExecSql($p_cn,$Sql); 00149 00150 // Get the jft_id sequence (s_jnt_fic_att_value) 00151 $l_jft_id=GetSequence($p_cn,'s_jnt_fic_att_value'); 00152 00153 00154 // Add it the attr_value table 00155 $Sql=sprintf("insert into attr_value(jft_id,av_text) values (%d,'%s')", 00156 $l_jft_id,$num); 00157 $Res=ExecSql($p_cn,$Sql); 00158 } 00159 }// end create accounts for each cards 00160 00161 00162 // Add the others attribut in jnt_fic_att_value and after in attr_value 00163 for ( $i = 0; $i < $p_inc;$i++) { 00164 //Except for the class base 00165 if ( ${"p_ad_id$i"} == ATTR_DEF_ACCOUNT ) continue; 00166 00167 // Special treatment for QuickCode 00168 if ( ${"p_ad_id$i"} == ATTR_DEF_QUICKCODE ) { 00169 $sql=sprintf("select insert_quick_code(%d,'%s')", 00170 $l_f_id,FormatString(${"p_av_text$i"})); 00171 $Res=ExecSql($p_cn,$sql); 00172 continue; 00173 } 00174 // Add it the jnt table 00175 $Sql=sprintf("insert into jnt_fic_att_value (f_id,ad_id) values (%d,%d)", 00176 $l_f_id,${"p_ad_id$i"}); 00177 $Res=ExecSql($p_cn,$Sql); 00178 00179 // Get the jft_id sequence (s_jnt_fic_att_value) 00180 $l_jft_id=GetSequence($p_cn,'s_jnt_fic_att_value'); 00181 00182 // test the vat rate 00183 if ( ${"p_ad_id$i"} == ATTR_DEF_TVA ) { 00184 // is a rate given 00185 if ( strlen(trim(${"p_av_text$i"})) != 0 and 00186 isNumber(${"p_av_text$i"}) == 1) { 00187 // is a valid rate ? 00188 if ( CountSql($p_cn,"select * from tva_rate where tva_id='".${"p_av_text$i"}."'") == 0 ) { 00189 // the rate doesn't exist 00190 ${"p_av_text$i"}=1; 00191 // warning 00192 echo_error('invalid rate') ; 00193 echo '<script> 00194 alert("Attention tva invalid, valeur par défaut =1 "); 00195 </script>'; 00196 00197 } 00198 }// if a rate is given 00199 } 00200 $text=FormatString(${"p_av_text$i"}); 00201 // Add it the attr_value table 00202 $Sql=sprintf("insert into attr_value(jft_id,av_text) values (%d,'%s')", 00203 $l_jft_id,$text); 00204 $Res=ExecSql($p_cn,$Sql); 00205 00206 } 00207 00208 }
|
|
Add a modele of card into the database. AddModele parm :
array gen :
Definition at line 779 of file fiche_inc.php. References $Res, $sql, echo_debug(), echo_error(), ExecSql(), FormatString(), Get_attr_min(), GetBaseFicheDefault(), GetSequence(), and isNumber(). 00779 { 00780 echo_debug('fiche_inc.php',__LINE__,"AddModele"); 00781 // Show what we receive for debug purpose only 00782 // 00783 foreach ( $p_array as $key=>$element ) { 00784 echo_debug('fiche_inc.php',__LINE__,"p_$key $element"); 00785 ${"p_$key"}=$element; 00786 } 00787 // Format correctly the name of the cat. of card 00788 $p_nom_mod=FormatString($p_nom_mod); 00789 echo_debug('fiche_inc.php',__LINE__,"Adding $p_nom_mod"); 00790 // Format the p_class_base 00791 // must be an integer 00792 if ( isNumber($p_class_base) == 0 && FormatString($p_class_base) != null ) { 00793 echo_error ('p_class_base is NOT a number'); 00794 } 00795 if ( strlen(trim($p_nom_mod)) == 0 ) 00796 return; 00797 00798 // $p_FICHE_REF cannot be null !!! (== fiche_def_ref.frd_id 00799 if (! isset ($p_FICHE_REF) or strlen($p_FICHE_REF) == 0 ) { 00800 echo_error ("AddModele : fiche_ref MUST NOT be null or empty"); 00801 return; 00802 } 00803 // build the sql request for fiche_def 00804 // and insert into fiche_def 00805 // if p_class_base is null get the default class base from 00806 // fiche_def_ref 00807 if ( FormatString($p_class_base) == null ) 00808 { // p_class is null 00809 // So we take the default one 00810 $p_class_base=GetBaseFicheDefault($p_cn,$p_FICHE_REF); 00811 } 00812 // Set the value of fiche_def.fd_create_account 00813 if ( isset($p_create)) 00814 $p_create='true'; 00815 else 00816 $p_create='false'; 00817 00818 // Class is valid ? 00819 if ( FormatString($p_class_base) != null) { 00820 00821 // p_class is a valid number 00822 $sql=sprintf("insert into fiche_def(fd_label,fd_class_base,frd_id,fd_create_account) 00823 values ('%s',%s,%d,'%s')", 00824 $p_nom_mod,$p_class_base,$p_FICHE_REF,$p_create); 00825 $Res=ExecSql($p_cn,$sql); 00826 00827 // p_class must be added to tmp_pcmn 00828 $sql=sprintf("select account_add(%d,'%s')", 00829 $p_class_base,$p_nom_mod); 00830 00831 $Res=ExecSql($p_cn,$sql); 00832 00833 // Get the fd_id 00834 $fd_id=GetSequence($p_cn,'s_fdef'); 00835 00836 // Add the class_base if needed 00837 00838 if ( $p_create=='true' ) { 00839 $sql=sprintf("insert into jnt_fic_attr(fd_id,ad_id) 00840 values (%d,%d)",$fd_id,ATTR_DEF_ACCOUNT); 00841 $Res=ExecSql($p_cn,$sql); 00842 } 00843 } else { 00844 //There is no class base not even as default 00845 $sql=sprintf("insert into fiche_def(fd_label,frd_id,fd_create_account) values ('%s',%d,'%s')", 00846 $p_nom_mod,$p_FICHE_REF,$p_create); 00847 00848 $Res=ExecSql($p_cn,$sql); 00849 00850 // Get the fd_id 00851 $fd_id=GetSequence($p_cn,'s_fdef'); 00852 00853 } 00854 00855 // Get the default attr_def from attr_min 00856 $def_attr=Get_attr_min($p_cn,$p_FICHE_REF); 00857 00858 //if defaut attr not null 00859 // build the sql insert for the table attr_def 00860 if (sizeof($def_attr) != 0 ) { 00861 // insert all the mandatory fields into jnt_fiche_attr 00862 foreach ( $def_attr as $i=>$v) { 00863 $sql=sprintf("insert into jnt_fic_Attr(fd_id,ad_id) 00864 values (%d,%s)", 00865 $fd_id,$v['ad_id']); 00866 ExecSql($p_cn,$sql); 00867 } 00868 } 00869 00870 00871 }
|
|
Creation of a model of card or correction. DefModele
Definition at line 707 of file fiche_inc.php. References $check, echo_debug(), Get_fiche_def_ref(), and METHOD. 00708 { 00709 echo_debug('fiche_inc.php',__LINE__,"DefModele ($p_array,$p_ligne=1) "); 00710 00711 // Creating form 00712 $display='<FORM ACTION="fiche.php" METHOD="POST">'; 00713 00714 // Number of line of the card 00715 $display.='<INPUT TYPE="HIDDEN" NAME="INC" VALUE="'.$p_ligne.'">'; 00716 00717 // Table of input 00718 $display.='<TABLE BORDER="0" CELLSPACING="0">'; 00719 00720 00721 //Name of the CARD (fiche_def.fd_label) 00722 $display.='<TR><TD> Catégorie de fiche </TD>'; 00723 $display.='<TD><INPUT TYPE="INPUT" NAME="nom_mod">'; 00724 $display.='</TD></TR>'; 00725 00726 // Class base fiche_def.fd_class_base (optional) 00727 $display.='<TR><TD> Classe de base </TD>'; 00728 $display.='<TD><INPUT TYPE="INPUT" NAME="class_base"> '.$p_js; 00729 $display.='</TD></TR>'; 00730 // Checkbox for the creation of a post 00731 $display.='<TR><TD> <INPUT TYPE="CHECKBOX" NAME="create" CHECKED>Création automatique du poste comptable</TD></TR>'; 00732 00733 //display the different template 00734 $ref=Get_fiche_def_ref($p_cn); 00735 00736 // check if $ref is an array 00737 // and display the choice 00738 00739 // select by default the first choice 00740 $check="CHECKED"; 00741 if ( sizeof($ref) ) { 00742 foreach ($ref as $i=>$v) { 00743 $display.='<TR><TD COLSPAN="2">'; 00744 00745 $display.='<INPUT TYPE="RADIO" NAME="FICHE_REF" VALUE="'.$v['id'].'"'.$check.'>'; 00746 $display.=$v['text']; 00747 // if a class base exist in fiche_def_ref, we display it 00748 if ( sizeof ($v['class']) != 0 ) 00749 $display.="  <I>Class base = ".$v['class']."</I>"; 00750 $display.="</TD></TR>"; 00751 $check=""; 00752 } 00753 00754 } 00755 // closing the form 00756 $display.='</TABLE>'; 00757 $display.='<INPUT TYPE="SUBMIT" NAME="add_modele" VALUE="Sauve">'; 00758 $display.='</FORM>'; 00759 00760 // display it 00761 echo $display; 00762 00763 }
|
|
Show the data contained in an array of a model of card (fiche_def). DisplayDetailModele parm :
Definition at line 1408 of file fiche_inc.php. References $i, $l, $M, $Res, echo_debug(), ExecSql(), label, and value. Referenced by UpdateModele(). 01409 { 01410 echo_debug('fiche_inc.php',__LINE__,"DisplayDetailModele"); 01411 01412 foreach ($p_array as $v=>$i) { 01413 echo_debug('fiche_inc.php',__LINE__,"v == $v i==$i"); 01414 ${"$v"}=$i; 01415 } 01416 echo '<FORM action="fiche.php" method="get">'; 01417 echo '<INPUT TYPE="HIDDEN" NAME="fd_id" VALUE="'.$fd_id.'">'; 01418 01419 printf("<TABLE>"); 01420 // Display each attribute 01421 for ($i=0;$i<$MaxLine;$i++) { 01422 echo '<TR><td>'; 01423 // Can change the name 01424 if ( ${"ad_id$i"} == ATTR_DEF_NAME ) { 01425 printf('Label</TD><TD><INPUT TYPE="TEXT" NAME="label" VALUE="%s">', 01426 $label); 01427 printf('</td><TD><input type="submit" NAME="change_name" value="Change Nom">'); 01428 } else { 01429 // The attr. 01430 printf('%s ', 01431 ${"ad_text$i"}); 01432 } 01433 echo '</td></tr>'; 01434 } 01435 01436 // Show the possible attribute which are not already attribute of the model 01437 // of card 01438 $Res=ExecSql($p_cn,"select ad_id,ad_text from attr_def 01439 where ad_id not in (select ad_id from fiche_def natural join jnt_fic_attr 01440 where fd_id=$fd_id)"); 01441 $M=pg_NumRows($Res); 01442 01443 // Show the unused attribute 01444 echo '<TR> <TD>'; 01445 echo '<SELECT NAME="ad_id">'; 01446 for ($i=0;$i<$M;$i++) { 01447 $l=pg_fetch_array($Res,$i); 01448 printf('<OPTION VALUE="%s"> %s', 01449 $l['ad_id'],$l['ad_text']); 01450 } 01451 echo '</SELECT>'; 01452 echo '</TD><TD> <INPUT TYPE="SUBMIT" Value="Add that line" NAME="add_ligne"></TD></TR>'; 01453 printf("</TABLE>"); 01454 echo '</FORM>'; 01455 }
|
|
Affiche les détails d'une fiche et propose de mettre à jour ou si array est a null, permet d'ajouter une fiche, to fill the attribute. EncodeFiche
Definition at line 225 of file fiche_inc.php. References $a, $l_line, $label, $Max, $Res, $sql, $url, echo_debug(), echo_error(), ExecSql(), f_id, GetArray(), getFicheNameById(), name, and value. Referenced by ViewFicheDetail(). 00225 { 00226 echo_debug('fiche_inc.php',__LINE__,"function EncodeFiche($p_cn,$p_type) "); 00227 00228 $ch_col="</TD><TD>"; 00229 $ch_li='</TR><TR>'; 00230 $url=""; 00231 // compute url 00232 // Bug 15640 : add get variabe to see the list of card after insertng a new one 00233 // or retrieve the fd_id when updating 00234 if ($p_array == null) { 00235 $url="?action=vue&fiche=$p_type"; 00236 } else { 00237 // find the modele of card (fd_id) 00238 $a=GetArray($p_cn,'select fd_id from fiche where f_id='.$p_type); 00239 if ( $a == null ) { 00240 echo_error(__FILE__.":".__LINE__." Aucune fiche trouvée"); 00241 return; 00242 } 00243 $url="?action=vue&fiche=".$a[0]['fd_id']; 00244 } 00245 00246 00247 echo '<FORM action="fiche.php'.$url.'" method="post" name="fiche">'; 00248 echo '<INPUT TYPE="HIDDEN" name="fiche" value="'.$p_type.'">'; 00249 $l_sessid=$_REQUEST['PHPSESSID']; 00250 $url=""; 00251 echo JS_SHOW_TVA; 00252 echo JS_SEARCH_POSTE; 00253 echo "<TABLE>"; 00254 if ($p_array == null) { 00255 00256 // Array is null so we display a blank form 00257 // echo '<H2 class="info">'.getFicheName($p_cn,$p_type).'</H2>'; 00258 echo '<H2 class="info">New </H2>'; 00259 $p_f_id=""; 00260 echo_debug('fiche_inc.php',__LINE__,"Array is null"); 00261 // Find all the attribute of the existing cards 00262 // --> Get_attr_def 00263 $sql="select frd_id,ad_id,ad_text from fiche_def join jnt_fic_attr using (fd_id) 00264 join attr_def using (ad_id) where fd_id=".$p_type." order by ad_id"; 00265 00266 $Res=ExecSql($p_cn,$sql); 00267 $Max=pg_NumRows($Res); 00268 // Put the card modele id (fiche_def.fd_id) 00269 echo '<INPUT TYPE="HIDDEN" name="fd_id" value="'.$p_type.'">'; 00270 for ($i=0;$i < $Max;$i++) { 00271 $l_line=pg_fetch_array($Res,$i); 00272 00273 // The number of the attribute 00274 $Hid=sprintf('<INPUT TYPE="HIDDEN" name="ad_id%d" value="%s">', 00275 $i,$l_line['ad_id']); 00276 00277 $but_search_poste=""; 00278 // Javascript for searching the account 00279 if ( $l_line ['ad_id'] == ATTR_DEF_ACCOUNT ) { 00280 $ctl_name="av_text$i"; 00281 $but_search_poste='<INPUT TYPE="BUTTON" VALUE="Cherche" OnClick="SearchPoste(\''.$l_sessid.'\',\''.$ctl_name.'\')">'; 00282 } 00283 // Javascript for showing the tva 00284 if ( $l_line ['ad_id'] == ATTR_DEF_TVA ) { 00285 $but_search_poste='<INPUT TYPE="BUTTON" VALUE="Montre" OnClick="ShowTva(\''.$l_sessid.'\', \'av_text'.$i.'\')">'; 00286 } 00287 // content of the attribute 00288 printf ('<TR><TD> %s </TD><TD><INPUT TYPE="TEXT" NAME="av_text%d">%s %s</TD></TR>', 00289 $l_line['ad_text'], $i,$Hid,$but_search_poste); 00290 } 00291 echo '</TR>'; 00292 echo '</TABLE>'; 00293 echo '<INPUT TYPE="HIDDEN" name="inc" value="'.$Max.'">'; 00294 echo '<INPUT TYPE="SUBMIT" name="add_fiche" value="ajoute">'; 00295 echo '</FORM>'; 00296 }else { 00297 // Array is not null so we have to find the card's data from the database 00298 // and display them 00299 00300 // Display the card name 00301 $label=getFicheNameById($p_cn,$p_type); 00302 echo '<H2 class="info">'.$label.'</H2>'; 00303 00304 // Find all the data related to the card 00305 $sql="select av_text,ad_id,ad_text,jft_id from attr_value 00306 natural join attr_def 00307 natural join jnt_fic_att_value 00308 natural join fiche where f_id=$p_type order by ad_id"; 00309 00310 $Res=ExecSql($p_cn,$sql); 00311 $Max=pg_NumRows($Res); 00312 echo_debug('fiche_inc.php',__LINE__,"Max ==== $Max"); 00313 00314 echo '<INPUT TYPE="HIDDEN" name="f_id" value="'.$p_type.'">'; 00315 echo '<INPUT TYPE="HIDDEN" name="f_label" value="'.$label.'">'; 00316 echo '<INPUT TYPE="HIDDEN" name="max" value="'.$Max.'">'; 00317 00318 for ($i=0;$i < $Max;$i++) { 00319 // fetch the data 00320 $l_line=pg_fetch_array($Res,$i); 00321 00322 // Put also the class in a special variable 00323 // useful when we want to update the PCMN 00324 00325 $but_search_poste=""; 00326 if ( $l_line['ad_id'] == ATTR_DEF_ACCOUNT ) { 00327 printf('<INPUT TYPE="HIDDEN" name="class" value="%s">', 00328 $l_line['av_text']); 00329 // Javascript for searching the account 00330 $ctl_name="av_text$i"; 00331 $but_search_poste='<INPUT TYPE="BUTTON" VALUE="Cherche" OnClick="SearchPoste(\''.$l_sessid.'\',\''.$ctl_name.'\')">'; 00332 } 00333 00334 // Javascript for showing the tva 00335 if ( $l_line ['ad_id'] == ATTR_DEF_TVA ) { 00336 $but_search_poste='<INPUT TYPE="BUTTON" VALUE="Montre" OnClick="ShowTva(\''.$l_sessid.'\',\'av_text'.$i.'\')">'; 00337 } 00338 00339 // hide ad_id 00340 $ad=sprintf('<input type="hidden" name="ad_id%d" value="%s">', 00341 $l_line['ad_id'],$l_line['av_text']); 00342 00343 // in hidden we put the jft_id 00344 $Hid=sprintf('<INPUT TYPE="HIDDEN" name="jft_id%d" value="%s">', 00345 $i,$l_line['jft_id']); 00346 printf ('<TR><TD> %s </TD><TD><INPUT TYPE="TEXT" NAME="av_text%d" VALUE="%s">%s %s %s</TD></TR>', 00347 $l_line['ad_text'], $i, $l_line['av_text'],$Hid,$but_search_poste,$ad); 00348 00349 } 00350 echo '</TR>'; 00351 echo '</TABLE>'; 00352 echo '<INPUT TYPE="SUBMIT" name="update_fiche" value="Mis à jour">'; 00353 echo '</FORM>'; 00354 } 00355 }
|
|
parm :
EncodeModele Definition at line 682 of file fiche_inc.php. 00683 { 00684 echo '<H2 CLASS="info"> Ajout d\'un modèle</H2>'; 00685 echo '<FORM ACTION="fiche.php" METHOD="post">'; 00686 echo '<BR>Libellé <INPUT TYPE="TEXT" NAME="nom_mod">'; 00687 echo '<BR>Classe de base <INPUT TYPE="TEXT" NAME="class_base">'; 00688 echo $p_js; 00689 echo '<INPUT TYPE="HIDDEN" NAME="inc" VALUE="1">'; 00690 echo '<BR><INPUT TYPE="SUBMIT" name="record_model" VALUE="Ajoute modèle">'; 00691 echo '</FORM>'; 00692 }
|
|
retrieve the fields of the card model Get_attr_def parm :
$p_fiche_def_ref fiche_def.fd_id gen :
Definition at line 1199 of file fiche_inc.php. References $array, $i, $Num, $Res, $Sql, and ExecSql(). Referenced by AddFiche(). 01199 { 01200 // find the min attr for the fiche_def_ref 01201 $Sql="select ad_id,ad_text from attr_def 01202 natural join jnt_fic_attr 01203 natural join fiche_def 01204 where 01205 fd_id= $p_fiche_def order by ad_id"; 01206 $Res=ExecSql($p_cn,$Sql); 01207 $Num=pg_NumRows($Res); 01208 01209 // test the number of returned rows 01210 if ($Num == 0 ) return null; 01211 01212 // Get Results & Store them in a array 01213 for ($i=0;$i<$Num;$i++) { 01214 $f=pg_fetch_array($Res,$i); 01215 $array[$i]['ad_id']=$f['ad_id']; 01216 $array[$i]['ad_text']=$f['ad_text']; 01217 } 01218 return $array; 01219 }
|
|
retrieve the mandatory field of the card model Get_attr_min parm :
$p_fiche_def_ref gen :
Definition at line 1167 of file fiche_inc.php. References $array, $i, $Num, $Res, $Sql, and ExecSql(). Referenced by AddModele(). 01167 { 01168 // find the min attr for the fiche_def_ref 01169 $Sql="select ad_id,ad_text from attr_min natural join attr_def 01170 natural join fiche_def_ref 01171 where 01172 frd_id= $p_fiche_def_ref"; 01173 $Res=ExecSql($p_cn,$Sql); 01174 $Num=pg_NumRows($Res); 01175 01176 // test the number of returned rows 01177 if ($Num == 0 ) return null; 01178 01179 // Get Results & Store them in a array 01180 for ($i=0;$i<$Num;$i++) { 01181 $f=pg_fetch_array($Res,$i); 01182 $array[$i]['ad_id']=$f['ad_id']; 01183 $array[$i]['ad_text']=$f['ad_text']; 01184 } 01185 return $array; 01186 }
|
|
return an array containing all the data contained in the table fiche_def_ref parm :
Get_fiche_def_ref Definition at line 1133 of file fiche_inc.php. References $array, $i, $Max, $Res, ExecSql(), frd_class_base, frd_id, and frd_text. Referenced by DefModele(). 01134 { 01135 // get all the data from fiche_def_ref 01136 $Res=ExecSql($p_cn, "select frd_id,frd_text,frd_class_base 01137 from fiche_def_ref 01138 order by frd_text"); 01139 01140 // check if the result is valid 01141 $Max=pg_NumRows($Res); 01142 if ( $Max == 0) return null; 01143 01144 // store the result in a array 01145 for ($i=0;$i<$Max;$i++) { 01146 $f=pg_fetch_array($Res,$i); 01147 $array[$i]['id']=$f['frd_id']; 01148 $array[$i]['text']=$f['frd_text']; 01149 $array[$i]['class']=$f['frd_class_base']; 01150 } 01151 01152 // return result 01153 return $array; 01154 }
|
|
donne la classe comptable de base d'une fiche GetBaseFiche parm :
p_type fiche id gen :
Definition at line 370 of file fiche_inc.php. References $Res, and ExecSql(). Referenced by AddFiche(). 00370 { 00371 $base=null; 00372 $Res=ExecSql($p_cn,"select fd_class_base from fiche_def where fd_id=".$p_type); 00373 if ( pg_NumRows($Res) == 0 ) return null; 00374 $base=pg_fetch_array($Res,0); 00375 return $base['fd_class_base']; 00376 }
|
|
Give the default accounts of fiche_def. GetBaseFicheDefault parm :
p_type fiche id gen :
Definition at line 392 of file fiche_inc.php. References $Res, ExecSql(), and frd_class_base. Referenced by AddModele(). 00392 { 00393 $base=null; 00394 $Res=ExecSql($p_cn,"select frd_class_base from fiche_def_ref where frd_id=".$p_type); 00395 if ( pg_NumRows($Res) == 0 ) return null; 00396 $base=pg_fetch_array($Res,0); 00397 return $base['frd_class_base']; 00398 }
|
|
Retrieve the account of a card. GetClass parm :
card id (fiche.f_id) gen :
Definition at line 1331 of file fiche_inc.php. References $Res, $sql, echo_debug(), and ExecSql(). Referenced by Remove(). 01331 { 01332 echo_debug('fiche_inc.php',__LINE__,"GetClass($p_fid)"); 01333 01334 // the account class is in the av_text with the ad_id=5 in 01335 // attr_Def 01336 $sql="select av_text from attr_value 01337 natural join jnt_fic_att_value 01338 natural join attr_def 01339 where 01340 ad_id=".ATTR_DEF_ACCOUNT." and f_id=$p_fid"; 01341 // Exec 01342 $Res=ExecSql($p_cn,$sql); 01343 if (pg_NumRows($Res) == 0 ) return null; 01344 01345 // Fetch the data and return it 01346 $f=pg_fetch_array($Res,0); 01347 return $f['av_text']; 01348 }
|
|
retrieve the fields of the card model which indicate if each cards needs its own account parm :
$p_fiche_def_ref fiche_def.fd_id gen :
GetCreateAccount Definition at line 1232 of file fiche_inc.php. References $Num, $Res, $Sql, echo_debug(), and ExecSql(). Referenced by AddFiche(), and Remove(). 01232 { 01233 // find the min attr for the fiche_def_ref 01234 $Sql="select fd_create_account 01235 from fiche_def 01236 where 01237 fd_id= $p_fiche_def"; 01238 $Res=ExecSql($p_cn,$Sql); 01239 $Num=pg_NumRows($Res); 01240 01241 // test the number of returned rows 01242 if ($Num == 0 ) return 0; 01243 01244 01245 for ($i=0;$i<$Num;$i++) { 01246 $f=pg_fetch_array($Res,$i); 01247 echo_debug ("fd_create_account == ".$f['fd_create_account']); 01248 if ( $f['fd_create_account']=='t') { 01249 echo_debug('fiche_inc.php',__LINE__,"fd_create_account return 1"); 01250 return 1; 01251 } 01252 } 01253 echo_debug('fiche_inc.php',__LINE__,"fd_create_account return 0"); 01254 return 0; 01255 }
|
|
Return the info of an fiche identified by p_fiche. GetDataModele parm :
fiche id gen :
Definition at line 913 of file fiche_inc.php. References $array, $line, $Max, $Res, ExecSql(), and label. Referenced by UpdateModele(). 00913 { 00914 $Res=ExecSql($p_cn,"select fd_class_base,ad_id,ad_text from 00915 fiche_def 00916 natural join jnt_fic_attr 00917 natural join attr_def 00918 where 00919 fd_id=$p_fiche"); 00920 $Max=pg_NumRows($Res) ; 00921 if ($Max==0) return null; 00922 00923 // store the data in an array 00924 for ($i=0; $i < $Max;$i++) { 00925 $line=pg_fetch_array($Res,$i); 00926 if ($i == 0 ) { 00927 $array['label']=GetFicheDefName($p_cn,$p_fiche); 00928 $array['class_base']=$line['fd_class_base']; 00929 $array['fd_id']=$p_fiche; 00930 }//if $i == 0 00931 00932 //Label 00933 $text=sprintf("ad_id%d",$i); 00934 $array[$text]=$line['ad_id']; 00935 //isd_id 00936 $text=sprintf("ad_text%d",$i); 00937 $array[$text]=$line['ad_text']; 00938 00939 }//for 00940 $array['ligne']=$Max; 00941 return $array; 00942 }
|
|
retrun array of attribut or string getFicheAttribut parm :
p_id quick_code
string avec nom fiche or array Definition at line 1492 of file fiche_inc.php. References $Res, and ExecSql(). Referenced by FormAchView(), FormVenteView(), and withStock(). 01492 { 01493 // Retrieve the attribute with the ad_id 1 01494 // 1 is always the name 01495 01496 if ( $p_attr != "") { 01497 $Res=ExecSql($p_cn,"select av_text from 01498 attr_value 01499 natural join jnt_fic_att_value 01500 natural join fiche 01501 where 01502 ad_id=$p_attr 01503 and f_id=(select f_id from vw_poste_qcode where j_qcode='$p_id') "); 01504 if ( pg_NumRows($Res) == 0 ) return NULL; 01505 $st=pg_fetch_array($Res,0); 01506 return $st['av_text']; 01507 } else { 01508 // Get attribut from the view 01509 $Res=ExecSql($p_cn,"select * from vw_fiche_attr where quick_code='$p_id'"); 01510 if ( pg_NumRows($Res) == 0 ) return null; 01511 $st=pg_fetch_array($Res,0); 01512 return $st; 01513 } 01514 }
|
|
retrieve the fiche_def.fd_id thanks the f_id of a card GetFicheRef parm :
$p_f_id fiche.f_id gen :
the fiche_def.fd_id or null if nothing has been found Definition at line 1300 of file fiche_inc.php. References $Res, $sql, and ExecSql(). Referenced by Remove(), and ViewFicheDetail(). 01301 { 01302 // Sql stmt 01303 $sql="select fd_id from fiche_def join fiche using (fd_id) 01304 where f_id=$p_f_id"; 01305 // Execute it 01306 $Res=ExecSql($p_cn,$sql); 01307 01308 // nothing is found 01309 if ( pg_NumRows($Res) == 0 ) return null; 01310 01311 // Fetch the data 01312 $f=pg_fetch_array($Res,0); 01313 01314 // return the value 01315 return $f['fd_id']; 01316 01317 }
|
|
retourne le nom de la cat. de fiches getFicheDefName parm :
p_id fiche id fiche_def.fd_id gen :
string fiche_def.fd_label Definition at line 1056 of file fiche_inc.php. References $Res, and ExecSql(). 01056 { 01057 $Res=ExecSql($p_cn,"select fd_label from fiche_def where fd_id=$p_id"); 01058 if ( pg_NumRows($Res) == 0 ) return "Unknown"; 01059 $st=pg_fetch_array($Res,0); 01060 return $st['fd_label']; 01061 }
|
|
retrieve the fiche_def.frd_id thanks the f_id of a card GetFicheDefRef parm :
$p_f_id fiche.f_id gen :
the fiche_def.frd_id or null if nothing has been found Definition at line 1269 of file fiche_inc.php. References $Res, $sql, ExecSql(), and frd_id. Referenced by UpdateFiche(). 01270 { 01271 // Sql stmt 01272 $sql="select frd_id from fiche_def join fiche using (fd_id) 01273 where f_id=$p_f_id"; 01274 // Execute it 01275 $Res=ExecSql($p_cn,$sql); 01276 01277 // nothing is found 01278 if ( pg_NumRows($Res) == 0 ) return null; 01279 01280 // Fetch the data 01281 $f=pg_fetch_array($Res,0); 01282 01283 // return the value 01284 return $f['frd_id']; 01285 01286 }
|
|
Get all the fiche related to a "journal". GetFicheJrn parm :
j_jrn journal_id
Definition at line 1075 of file fiche_inc.php. References $a, $i, $line, $list, $Max, $Res, $sql, echo_error(), echo_warning(), ExecSql(), exit, and f_id. 01076 { 01077 $get=""; 01078 if ( $p_type == 'deb' ) { 01079 $get='jrn_def_fiche_deb'; 01080 } 01081 if ( $p_type == 'cred' ) { 01082 $get='jrn_def_fiche_cred'; 01083 } 01084 if ( $get == "" ) { 01085 echo_error("Invalid p_type function GetFicheJrn($p_cn,$p_jrn,$p_type)"); 01086 exit -1; 01087 } 01088 $Res=ExecSql($p_cn,"select $get as fiche from jrn_def where jrn_def_id=$p_jrn"); 01089 $Max=pg_NumRows($Res); 01090 if ( $Max==0) { 01091 echo_warning("No rows"); 01092 return null; 01093 } 01094 // Normally Max must be == 1 01095 $list=pg_fetch_array($Res,0); 01096 if ( $list['fiche']=="") { 01097 echo_warning("No fiche"); 01098 return null; 01099 } 01100 01101 $sql="select f_id,av_text as f_label 01102 from fiche natural join jnt_fic_att_value 01103 natural join attr_def 01104 natural join attr_value 01105 natural join fiche_def 01106 where ad_id=1 and 01107 fd_id in (".$list['fiche'].") order by f_label"; 01108 01109 $Res=ExecSql($p_cn,$sql); 01110 $Max=pg_NumRows($Res); 01111 if ($Max==0 ) return null; 01112 // Get The result and put it into an array 01113 for ($i=0;$i<$Max;$i++) { 01114 $line=pg_fetch_array($Res,$i); 01115 $f_id=$line['f_id']; 01116 $f_label=$line['f_label']; 01117 $a[$i]=array($f_id,$f_label); 01118 } 01119 return $a; 01120 }
|
|
retourne le nom de la fiche en fournissant le quick_code getFicheName parm :
p_id quick_code gen :
string avec nom fiche Definition at line 1006 of file fiche_inc.php. References $Res, and ExecSql(). Referenced by FormAchView(), and FormVenteView(). 01006 { 01007 // Retrieve the attribute with the ad_id 1 01008 // 1 is always the name 01009 01010 $Res=ExecSql($p_cn,"select vw_name from 01011 vw_fiche_attr where quick_code='$p_id'"); 01012 if ( pg_NumRows($Res) == 0 ) return "Unknown"; 01013 $st=pg_fetch_array($Res,0); 01014 return $st['vw_name']; 01015 }
|
|
retourne le nom de la fiche en fournissant le f_id getFicheNameById parm :
p_id quick_code gen :
string avec nom fiche Definition at line 1028 of file fiche_inc.php. References $Res, and ExecSql(). Referenced by EncodeFiche(). 01028 { 01029 // Retrieve the attribute with the ad_id 1 01030 // 1 is always the name 01031 $Res=ExecSql($p_cn,"select av_text from 01032 attr_value 01033 natural join jnt_fic_att_value 01034 natural join fiche 01035 where 01036 f_id=$p_id and 01037 ad_id=".ATTR_DEF_NAME); 01038 01039 if ( pg_NumRows($Res) == 0 ) return "Unknown"; 01040 $st=pg_fetch_array($Res,0); 01041 return $st['av_text']; 01042 }
|
|
Crée le poste suivant pour une fiche en fonction de la classe de base (fichedef(fd_class_base)). GetNextFiche parm :
p_base gen :
Definition at line 480 of file fiche_inc.php. References $l_line, $Max, $Res, $ret, echo_debug(), and ExecSql(). Referenced by AddFiche(). 00480 { 00481 $Res=ExecSql($p_cn,"select max(pcm_val) as maxcode from tmp_pcmn where pcm_val_parent = $p_base"); 00482 $Max=pg_NumRows($Res); 00483 echo_debug('fiche_inc.php',__LINE__,"$Max=pg_NumRows"); 00484 $l_line=pg_fetch_array($Res,0); 00485 $ret=$l_line['maxcode']; 00486 if ( $ret == "" ) { 00487 $ret=sprintf("%d%04d",$p_base,0); 00488 return $ret+1; 00489 00490 } 00491 00492 echo_debug('fiche_inc.php',__LINE__,"ret $ret"); 00493 return $ret+1; 00494 }
|
|
Get the parent in tmp_pcmn. GetParent parm :
the base we want insert gen :
Definition at line 1468 of file fiche_inc.php. References $a, CountSql(), and echo_debug(). Referenced by UpdateFiche(). 01469 { 01470 $len=strlen($p_val)-1; 01471 for ($i=$len-1;$i>0;$i--) { 01472 $a=substr($p_val,0,$i); 01473 echo_debug ("parent == $a len =1"); 01474 if (CountSql($p_cn,"select pcm_val from tmp_pcmn where pcm_val=$a") == 1) 01475 return $a; 01476 } 01477 }
|
|
Insert a new row into jnt_fic_attr for adding a new attribute to the card model parm :
the fiche_def.fd_id, id of the cat of the model
InsertModeleLine Definition at line 1361 of file fiche_inc.php. References $Res, $sql, and ExecSql(). 01362 { 01363 // Insert a new attribute for the model 01364 // it means insert a row in jnt_fic_attr 01365 $sql=sprintf("insert into jnt_fic_attr (fd_id,ad_id) values (%d,%d)", 01366 $p_fid,$p_adid); 01367 $Res=ExecSql($p_cn,$sql); 01368 01369 }
|
|
Check if a fiche is used by a jrn return 1 if the fiche is in the range otherwise 0. IsFicheOfJrn parm :
j_jrn journal_id
return 1 if the fiche is in the range otherwise 0 Definition at line 1532 of file fiche_inc.php. References $list, $Max, $Res, $sql, echo_warning(), and ExecSql(). Referenced by form_verify_input(). 01533 { 01534 $get=""; 01535 if ( $p_type == 'deb' ) { 01536 $get='jrn_def_fiche_deb'; 01537 } 01538 if ( $p_type == 'cred' ) { 01539 $get='jrn_def_fiche_cred'; 01540 } 01541 if ( $get != "" ) { 01542 $Res=ExecSql($p_cn,"select $get as fiche from jrn_def where jrn_def_id=$p_jrn"); 01543 } else { 01544 // Get all the fiche type (deb and cred) 01545 $Res=ExecSql($p_cn," select jrn_def_fiche_cred as fiche 01546 from jrn_def where jrn_def_id=$p_jrn 01547 union 01548 select jrn_def_fiche_deb 01549 from jrn_def where jrn_def_id=$p_jrn" 01550 ); 01551 } 01552 $Max=pg_NumRows($Res); 01553 if ( $Max==0) { 01554 echo_warning("No rows"); 01555 return null; 01556 } 01557 // Normally Max must be == 1 01558 $list=pg_fetch_array($Res,0); 01559 if ( $list['fiche']=="") { 01560 echo_warning("No fiche"); 01561 return null; 01562 } 01563 01564 $sql="select * 01565 from vw_fiche_attr 01566 where 01567 fd_id in (".$list['fiche'].") and quick_code='$p_fiche'"; 01568 01569 $Res=ExecSql($p_cn,$sql); 01570 $Max=pg_NumRows($Res); 01571 if ($Max==0 ) 01572 return 0; 01573 else 01574 return 1; 01575 }
|
|
enleve une fiche dans attr_value, jnt_fic_att_value et fiche a la condition que ce poste n'aie jamais été utilisé parm :
p_fid fiche(f_id) gen :
none Remove Definition at line 956 of file fiche_inc.php. References $Res, CountSql(), echo_error(), ExecSql(), FormatString(), GetClass(), GetCreateAccount(), GetFicheDef(), and isNumber(). 00956 { 00957 if ( ! isset ($p_cn) || 00958 ! isset ($p_fid) ) { 00959 echo_error ("Remove Missing Parameter p_cn = $p_cn p_fid=$p_fid"); 00960 return; 00961 } 00962 // if the card has its own account in PCMN 00963 // Get the fiche_def.fd_id from fiche.f_id 00964 $fd_id=GetFicheDef($p_cn,$p_fid); 00965 if ( GetCreateAccount($p_cn,$fd_id) == 1 ) { 00966 // Retrieve the class 00967 $class=GetClass($p_cn,$p_fid); 00968 00969 // if class is not NULL and if we use it before, we can't remove it 00970 if (FormatString($class) != null && 00971 CountSql($p_cn,"select * from jrnx where j_poste=$class") != 0 ) { 00972 echo "<SCRIPT> alert('Impossible ce poste est utilisé dans un journal'); </SCRIPT>"; 00973 return; 00974 } else { 00975 // Remove in PCMN 00976 if ( trim(strlen($class)) != 0 and isNumber($class) == 1) 00977 ExecSql($p_cn,"delete from tmp_pcmn where pcm_val=".$class); 00978 } 00979 00980 } 00981 // Remove from attr_value 00982 $Res=ExecSql($p_cn,"delete from attr_value 00983 where jft_id in (select jft_id 00984 from jnt_fic_att_value 00985 natural join fiche where f_id=$p_fid)"); 00986 // Remove from jnt_fic_att_value 00987 $Res=ExecSql($p_cn,"delete from jnt_fic_att_value where f_id=$p_fid"); 00988 00989 // Remove from fiche 00990 $Res=ExecSql($p_cn,"delete from fiche where f_id=$p_fid"); 00991 00992 }
|
|
Update the model's name. SaveModeleName parm :
the fiche_def.fd_id, id of the cat of the model
Definition at line 1382 of file fiche_inc.php. References $Res, $sql, and ExecSql(). 01383 { 01384 // Insert a new attribute for the model 01385 // it means insert a row in jnt_fic_attr 01386 $sql=sprintf("update fiche_def set fd_label='%s' where 01387 fd_id=%d", 01388 $p_label,$p_fid); 01389 $Res=ExecSql($p_cn,$sql); 01390 01391 }
|
|
Met a jour une fiche change dans le plan comptable, fiche,et isupp. UpdateFiche parm :
p_array gen :
Definition at line 548 of file fiche_inc.php. References $a, $label, $Res, $sql, CountSql(), echo_debug(), echo_error(), ExecSql(), FormatString(), GetFicheDefRef(), GetParent(), and label. 00548 { 00549 00550 echo_debug ('fiche_inc.php',__LINE__,"UpdateFiche"); 00551 $tva_error=false; 00552 foreach ( $p_array as $key=> $element) { 00553 echo_debug('fiche_inc.php',__LINE__,"UF $key => $element"); 00554 ${"$key"}=$element; 00555 // Get the name 00556 if ( $key == "ad_id".ATTR_DEF_NAME ) { 00557 $label=$element; 00558 if (strlen(trim($label))== 0 ) 00559 return; 00560 } 00561 // Get the class base 00562 if ( $key=="ad_id".ATTR_DEF_ACCOUNT) { 00563 $class=$element; 00564 } 00565 // Get the vat and 00566 // test the vat rate 00567 if ( $key == 'ad_id'.ATTR_DEF_TVA ) { 00568 // is a valid rate ? 00569 if ( strlen(trim($element)) == 0 ) continue; 00570 if ( CountSql($p_cn,"select * from tva_rate where tva_id='".$element."'") == 0 ) { 00571 // warning 00572 echo_error('invalid rate') ; 00573 echo '<script> 00574 alert("Attention tva invalid remis à sa valeur par défaut "); 00575 </script>'; 00576 $tva_error=true; 00577 } 00578 } 00579 } 00580 // If each card has it own account must also update the tmp_pcm table 00581 // 00582 $fd_ref=GetFicheDefRef($p_cn,$fiche); 00583 // Update all the others data 00584 for ( $i =0 ; $i < $max ; $i++) { 00585 // Format text 00586 $text=FormatString( ${"av_text$i"}); 00587 // Check if we don't try to update a QUICK CODE 00588 $Res=ExecSql($p_cn,"select ad_id from jnt_fic_att_value where jft_id=".${"jft_id$i"}); 00589 $a=pg_fetch_array($Res,0); 00590 if ( $a['ad_id'] != ATTR_DEF_QUICKCODE) 00591 { 00592 $sql=sprintf("update attr_value set av_text='%s' where jft_id=%d", 00593 $text, 00594 ${"jft_id$i"}); 00595 } 00596 else 00597 { 00598 $sql=sprintf("select update_quick_code(%d,'%s')", 00599 ${"jft_id$i"}, 00600 $text); 00601 } 00602 // Execute SQL 00603 $Res=ExecSql($p_cn,$sql); 00604 } 00605 // Update tva to his default value 00606 if ( $tva_error == true ) { 00607 $sql="update attr_value set av_text=1 where jft_id = ( select jft_id from jnt_fic_att_value 00608 natural join fiche natural join attr_def 00609 where ad_id=".ATTR_DEF_TVA." and f_id=$fiche)"; 00610 $Res=ExecSql($p_cn,$sql); 00611 } 00612 00613 // Update the PCMN if needed 00614 $sql="select av_text from attr_value natural join jnt_fic_att_value 00615 where f_id=$fiche and ad_id=".ATTR_DEF_ACCOUNT; 00616 $Res=ExecSql($p_cn,$sql); 00617 00618 if ( pg_NumRows($Res) != 0 ) { 00619 // it means that a account exists 00620 // Retrieve the name and the ad_id 5 00621 $f=pg_fetch_array($Res,0); 00622 $class_old=$f['av_text']; 00623 00624 // if the class changed 00625 if ( $class != $class_old and $class != "" ) { 00626 if ( CountSql($p_cn,"select * from jrnx where j_poste=$class") or 00627 CountSql($p_cn,"select * from jrnx where j_poste=$class_old" )) 00628 { 00629 // No change if the account is already used 00630 echo_error("Not possible to change the account, already used"); 00631 } else { 00632 if ( CountSql($p_cn,"select * from tmp_pcmn where pcm_val=".$class) ==0) 00633 // we have to insert 00634 { 00635 // First we must use a parent 00636 $parent=GetParent($p_cn,$class); 00637 $Res=ExecSql($p_cn, 00638 "insert into tmp_pcmn (pcm_val,pcm_lib,pcm_val_parent) 00639 values ($class,'$f_label',$parent)"); 00640 } 00641 } 00642 $class=$class_old; 00643 } else // $class="" 00644 { 00645 00646 echo_debug('fiche_inc.php',__LINE__,"new account "); 00647 $class=$class_old; 00648 if ( CountSql($p_cn,"select * from tmp_pcmn where pcm_val=".$class) == 0 ) { 00649 // First we must use a parent 00650 $parent=GetParent($p_cn,$class); 00651 $Res=ExecSql($p_cn, 00652 "insert into tmp_pcmn (pcm_val,pcm_lib,pcm_val_parent) 00653 values ($class,'$f_label',$parent)"); 00654 } 00655 } 00656 00657 00658 // Change the name in TMP_PCMN 00659 // Get the new name 00660 $f_label=FormatString($f_label); 00661 ExecSql($p_cn,"update tmp_pcmn set pcm_lib='".$f_label."' where pcm_val=".$class); 00662 00663 00664 } 00665 // Update of TMP_PCMN if a class base is given (ad_id=5) 00666 00667 00668 00669 }
|
|
Modify the model of card change some attribute (fd_label) and permit to add line. UpdateModele parm :
p_fiche fichedef(f_id) gen :
Definition at line 887 of file fiche_inc.php. References $array, DisplayDetailModele(), echo_debug(), echo_error(), and GetDataModele(). 00887 { 00888 00889 $array=GetDataModele($p_cn,$p_fiche); 00890 if ($array==null) { 00891 echo_error ("fiche_inc:UpdateModele Fiche non trouvée"); 00892 return; 00893 } 00894 echo '<H2 class="info">'.getFicheDefName($p_cn,$p_fiche).'</H2>'; 00895 foreach ( $array as $key=>$element) echo_debug('fiche_inc.php',__LINE__,"$key => $element"); 00896 DisplayDetailModele($p_cn,$array,$array['ligne']); 00897 00898 }
|
|
Montre les fiches d'une rubrique. ViewFiche parm :
$p_type fiche_def.fd_id catg of card gen :
Definition at line 412 of file fiche_inc.php. References $_SESSION, $bar, $l_line, $Max, $offset, $page, $Res, $sql_limit, $sql_offset, $step, CountSql(), ExecSql(), jrn_navigation_bar(), METHOD, name, table, and value. 00412 { 00413 require_once("user_common.php"); 00414 echo '<H2 class="info">'.getFicheDefName($p_cn,$p_type).'</H2>'; 00415 00416 $step=$_SESSION['g_pagesize']; 00417 $sql_limit=""; 00418 $sql_offset=""; 00419 if ( $step != -1 ) { 00420 $page=(isset($_GET['page']))?$_GET['page']:1; 00421 $offset=(isset($_GET['offset']))?$_GET['offset']:0; 00422 $max_line=CountSql($p_cn,"select f_id,av_text from 00423 fiche join jnt_fic_att_value using (f_id) 00424 join attr_value using (jft_id) 00425 where fd_id='".$p_type."' and ad_id=".ATTR_DEF_NAME." order by f_id"); 00426 $sql_limit=" limit ".$step; 00427 $sql_offset=" offset ".$offset; 00428 $bar=jrn_navigation_bar($offset,$max_line,$step,$page); 00429 } 00430 00431 // Get all name the cards of the select category 00432 // 1 for attr_def.ad_id is always the name 00433 $Res=ExecSql($p_cn,"select f_id,av_text,j_qcode from 00434 fiche join jnt_fic_att_value using (f_id) 00435 join attr_value using (jft_id) 00436 left outer join vw_poste_qcode using(f_id) 00437 where fd_id='".$p_type. 00438 "' and ad_id=".ATTR_DEF_NAME." order by f_id $sql_offset $sql_limit "); 00439 $Max=pg_NumRows($Res); 00440 echo $bar; 00441 00442 echo '<table>'; 00443 for ( $i = 0; $i < $Max; $i++) { 00444 $l_line=pg_fetch_array($Res,$i); 00445 if ( $i%2 == 0) 00446 echo '<TR class="odd">'; 00447 else 00448 echo '<TR class="even">'; 00449 00450 $span_mod='<TD><A href="fiche.php?action=detail&fiche_id='.$l_line['f_id'].'">'.$l_line['j_qcode'].'</A></TD>'; 00451 $span_del='<TD>'. 00452 '<A href="fiche.php?f_fd_id='.$p_type.'&action=delete&fiche_id='.$l_line['f_id']. 00453 '"> delete</A></td>'; 00454 00455 echo $span_del.$span_mod.'<TD>'.$l_line['av_text']."</TD>"; 00456 echo '</tr>'; 00457 } 00458 echo '</table>'; 00459 echo '<FORM METHOD="POST" action="fiche.php">'; 00460 echo '<INPUT TYPE="HIDDEN" name="fiche" value="'.$p_type.'">'; 00461 echo '<INPUT TYPE="SUBMIT" name="add" Value="Ajout fiche">'; 00462 echo '</FORM>'; 00463 echo $bar; 00464 00465 }
|
|
Montre le detail d'une fiche et ajoute les lignes manquantes dans le cas où le modèle à changer. ViewFicheDetail parm :
id de la fiche fiche(f_id) gen :
Definition at line 510 of file fiche_inc.php. References $Res, $sql, EncodeFiche(), ExecSql(), and GetFicheDef(). 00510 { 00511 00512 // Retrieve the fiche_def.fd_id of the card 00513 $fd_id=GetFicheDef($p_cn,$p_id); 00514 00515 //Update the default attribute of a card if is model has changed 00516 $sql="insert into jnt_fic_att_value (f_id,ad_id) 00517 select $p_id, ad_id 00518 from jnt_fic_attr 00519 where fd_id=$fd_id and 00520 ad_id not in (select ad_id from jnt_fic_att_value where 00521 f_id=$p_id)"; 00522 00523 $Res=ExecSql($p_cn,$sql); 00524 00525 // add a empty string to attr_value 00526 $sql="insert into attr_value select jft_id,'' from jnt_fic_att_value 00527 where f_id=$p_id and jft_id not in (select jft_id from attr_value natural join jnt_fic_att_value where 00528 f_id = $p_id)"; 00529 $Res=ExecSql($p_cn,$sql); 00530 00531 EncodeFiche ($p_cn,$p_id,1); 00532 }
|