Go to the source code of this file.
Functions | |
ShowDossier ($p_type, $p_first=0, $p_max=10, $p_Num=0) | |
DbConnect ($p_db=-1, $p_type='dossier') | |
connect to the database | |
ExecSql ($p_connection, $p_string) | |
send a sql string to the database | |
GetAllUser () | |
Return all the users as an array. | |
GetUid ($p_uid) | |
Check if the User is valid and return an array with his property. | |
GetPriv ($p_dossier, $p_login) | |
Get the privilege of an user on a folder. | |
ExisteJnt ($p_dossier, $p_user) | |
Get the number of rows from table jnt_use_dos where $p_dossier = dos_id and use_id=$p_user. | |
ExistePriv ($p_jntid) | |
GetJnt ($p_dossier, $p_user) | |
GetDbId ($p_name) | |
CountSql ($p_conn, $p_sql) | |
GetDossierName ($p_dossier) | |
GetSequence ($p_cn, $p_seq) | |
get the current sequence | |
NextSequence ($p_cn, $p_seq) | |
get the current sequence | |
StartSql ($p_cn) | |
EndSql ($p_cn) | |
Commit ($p_cn) | |
Rollback ($p_cn) | |
AlterSequence ($p_cn, $p_name, $p_value) | |
GetLogin ($p_uid) | |
SyncRight ($p_dossier, $p_user) | |
Synchronize les droits par défaut avec les journaux existants. | |
GetUserProperty ($p_cn, $p_user) | |
Get the properties of an user it means theme, profile, admin... | |
GetModeleId ($p_cn, $p_modname) | |
Give the mod_id from modeledef. | |
GetArray ($p_cn, $p_sql) | |
purpose return the result of a sql statment in a array | |
save_upload_document ($cn, $seq) | |
Save a "piece justificative". | |
getDbValue ($p_cn, $sql) | |
return the value of the sql, the sql will return only one value with the value |
Definition in file postgres.php.
|
Definition at line 269 of file postgres.php. References $Res, and ExecSql().
|
|
Definition at line 263 of file postgres.php. References $Res, and ExecSql(). Referenced by Centralise(), Document_modele::Delete(), Document::Generate(), Document_modele::Get(), ImportCSV(), fiche::insert(), RecordInvoice(), RecordSell(), Document_modele::Save(), Document::SaveGenerated(), Document::Send(), TransferCSV(), and Document::Upload().
|
|
Definition at line 222 of file postgres.php. References ExecSql(). Referenced by cl_user::AccessJrn(), AddFiche(), cl_user::Admin(), CheckDossier(), CheckIsAdmin(), CheckJrn(), CheckPoste(), DeleteRapt(), action::Display(), form_verify_input(), FormODS(), FormVenteView(), GetParent(), GetRappel(), fiche_def::HasAttribute(), fiche::insert(), InsertRapt(), ListJrn(), action::myList(), NextJrn(), Remove(), ShowDossier(), fiche::update(), UpdateFiche(), and ViewFiche(). 00223 { 00224 $r_sql=ExecSql($p_conn,$p_sql); 00225 return pg_NumRows($r_sql); 00226 00227 }
|
|
connect to the database
Definition at line 72 of file postgres.php. References $a, and echo_debug(). Referenced by cl_user::Admin(), cl_user::Check(), CheckAction(), CheckDossier(), CheckIsAdmin(), CheckJrn(), cl_user::cl_user(), ExisteJnt(), ExistePriv(), GetAllUser(), GetAvailableFolder(), GetDbId(), GetDossierName(), GetFirstJrnIdForJrnType(), GetJnt(), GetJrnProp(), GetLogin(), GetNumberLine(), GetPosteLibelle(), GetPriv(), GetUid(), html_page_start(), ListJrn(), MenuJrn(), ParseFormula(), RecordJrn(), ShowBox(), ShowDossier(), ShowMenuComptaForm(), ShowMenuFiche(), ShowMenuJrnUser(), SyncRight(), and ViewJrn(). 00072 { 00073 if ( $p_db==-1) 00074 $l_dossier=sprintf("%saccount_repository",domaine); 00075 else { 00076 if ( $p_db == -2 ) 00077 $l_dossier=$p_type; 00078 else 00079 switch ($p_type) { 00080 case 'dossier': 00081 $l_dossier=sprintf("%sdossier%d",domaine,$p_db); 00082 break; 00083 case 'mod': 00084 $l_dossier=sprintf("%smod%d",domaine,$p_db); 00085 break; 00086 } 00087 } 00088 $password=phpcompta_password; 00089 $a=pg_connect("dbname=$l_dossier host=127.0.0.1 user='phpcompta' password='$password'"); 00090 echo_debug ('postgres.php',__LINE__,"connect to $p_db dbname $l_dossier"); 00091 return $a; 00092 }
|
|
Definition at line 260 of file postgres.php. References $Res, and ExecSql(). Referenced by Centralise().
|
|
|
Get the number of rows from table jnt_use_dos where $p_dossier = dos_id and use_id=$p_user.
Definition at line 168 of file postgres.php. References $cn, $Res, DbConnect(), and ExecSql(). 00169 { 00170 $cn=DbConnect(); 00171 $Res=ExecSql($cn,"select * from jnt_use_dos where dos_id=".$p_dossier." and use_id=".$p_user); 00172 return pg_NumRows($Res); 00173 }
|
|
Definition at line 179 of file postgres.php. References $cn, $Res, DbConnect(), and ExecSql(). 00180 { 00181 $cn=DbConnect(); 00182 $Res=ExecSql($cn,"select * from priv_user where priv_jnt=".$p_jntid); 00183 return pg_NumRows($Res); 00184 }
|
|
Return all the users as an array.
Definition at line 117 of file postgres.php. References $cn, $Num, $Res, $sql, $User, DbConnect(), echo_debug(), and ExecSql(). 00117 { 00118 echo_debug('postgres.php',__LINE__,"GetUser"); 00119 $cn=DbConnect(); 00120 $sql="select * from ac_users where use_login!='phpcompta'"; 00121 echo_debug('postgres.php',__LINE__,"ExecSql"); 00122 $Res=ExecSql($cn,$sql); 00123 $Num=pg_NumRows($Res); 00124 if ( $Num == 0 ) return null; 00125 for ($i=0;$i < $Num; $i++) { 00126 $User[]=pg_fetch_array($Res,$i); 00127 } 00128 return $User; 00129 }
|
|
purpose return the result of a sql statment in a array
Definition at line 353 of file postgres.php. References $array, $r, echo_debug(), and ExecSql(). Referenced by EncodeFiche(), FormAchInput(), and FormVenInput(). 00353 { 00354 echo_debug('postgres.php',__LINE__,"GetArray"); 00355 $r=ExecSql($p_cn,$p_sql); 00356 if ( ($Max= pg_NumRows($r)) == 0 ) return null; 00357 $array=pg_fetch_all($r); 00358 echo_debug('postgres.php',__LINE__,var_export($array,true)); 00359 return $array; 00360 }
|
|
Definition at line 201 of file postgres.php. References $cn, $num, DbConnect(), and ExecSql(). 00202 { 00203 $cn=DbConnect(); 00204 $r_sql=ExecSql($cn,"select dos_id from ac_dossier 00205 where dos_name='".$p_name."'"); 00206 $num=pg_NumRows($r_sql); 00207 if ( $num == 0 ) { 00208 return 0; 00209 } else { 00210 $l_db=pg_fetch_array($r_sql,0); 00211 return $l_db['dos_id']; 00212 } 00213 00214 }
|
|
return the value of the sql, the sql will return only one value with the value
Definition at line 414 of file postgres.php. References $r, $ret, and ExecSql(). Referenced by action::Display(). 00415 { 00416 $ret=ExecSql($p_cn,$sql); 00417 if ( pg_NumRows($ret) == 0 ) return ""; 00418 $r=pg_fetch_row($ret,0); 00419 return $r[0]; 00420 }
|
|
Definition at line 232 of file postgres.php. References $cn, $r, $Ret, DbConnect(), and ExecSql(). 00233 { 00234 $cn=DbConnect(); 00235 $Ret=ExecSql($cn,"select dos_name from ac_dossier where dos_id=".$p_dossier); 00236 $r= pg_fetch_array($Ret,0); 00237 return $r['dos_name']; 00238 }
|
|
Definition at line 190 of file postgres.php. References $cn, $Res, DbConnect(), and ExecSql(). 00191 { 00192 $cn=DbConnect(); 00193 $Res=ExecSql($cn,"select jnt_id from jnt_use_dos where dos_id=".$p_dossier." and use_id=".$p_user); 00194 $R=pg_fetch_array($Res,0); 00195 return $R['jnt_id']; 00196 }
|
|
Definition at line 273 of file postgres.php. References $cn, $Res, DbConnect(), and ExecSql(). 00274 { 00275 $cn=DbConnect(); 00276 $Res=ExecSql($cn,"select use_login from ac_users where use_id=$p_uid"); 00277 if ( pg_NumRows($Res) == 0 ) return null; 00278 $a_login=pg_fetch_array($Res,0); 00279 return $a_login['use_login']; 00280 }
|
|
Give the mod_id from modeledef.
Definition at line 340 of file postgres.php. References $Res, and ExecSql(). 00340 { 00341 $Res=ExecSql($p_cn,"select mod_id from modeledef where mod_name='$p_modname'"); 00342 if (pg_NumRows($Res) == 0) return 0; 00343 $name=pg_fetch_array($Res,0); 00344 return $name['mod_id']; 00345 }
|
|
Get the privilege of an user on a folder.
Definition at line 147 of file postgres.php. References $cn, $i, $Num, $Res, DbConnect(), echo_debug(), and ExecSql(). Referenced by SyncRight(). 00148 { 00149 $cn=DbConnect(); 00150 $Res=ExecSql($cn,"select priv_priv 00151 from priv_user left join jnt_use_dos on jnt_id=priv_jnt 00152 inner join ac_users on ac_users.use_id=jnt_use_dos.use_id 00153 where use_login='$p_login' and dos_id=$p_dossier"); 00154 $Num=pg_NumRows($Res); 00155 echo_debug('postgres.php',__LINE__,"Found ".$Num." rows in GetPriv"); 00156 if ( $Num==0) { return 0;} 00157 for($i=0;$i < $Num;$i++) { 00158 $Right=pg_fetch_array($Res,$i); 00159 $Priv[]=$Right['priv_priv']; 00160 } 00161 return $Priv; 00162 }
|
|
get the current sequence
Definition at line 242 of file postgres.php. References $Res, $seq, and ExecSql(). Referenced by AddFiche(), AddForm(), AddModele(), InsertJrn(), InsertJrnx(), and Document::SaveGenerated(). 00243 { 00244 $Res=ExecSql($p_cn,"select currval('$p_seq') as seq"); 00245 $seq=pg_fetch_array($Res,0); 00246 return $seq['seq']; 00247 }
|
|
Check if the User is valid and return an array with his property.
Definition at line 134 of file postgres.php. References $cn, $Num, $Res, DbConnect(), and ExecSql(). 00134 { 00135 $cn=DbConnect(); 00136 $Res=ExecSql($cn,"select * from ac_users where use_id=".$p_uid); 00137 $Num=pg_NumRows($Res); 00138 if ( $Num == 0 ) { return false; } 00139 for ($i=0;$i < $Num; $i++) { 00140 $Prop[]=pg_fetch_array($Res,$i); 00141 } 00142 return $Prop; 00143 }
|
|
Get the properties of an user it means theme, profile, admin...
Definition at line 315 of file postgres.php. References $a, $Ret, $sql, and ExecSql(). 00316 { 00317 $sql="select use_login,use_first_name,use_name,use_admin,use_usertype,g_theme 00318 from ac_users where use_login='$p_user'"; 00319 $Ret=ExecSql($p_cn,$sql); 00320 if ( pg_NumRows($Ret) == 0) 00321 return array('use_first_name'=>'?', 00322 'use_name'=>'Unknown', 00323 'use_admin'=>0, 00324 'use_usertype'=>'user', 00325 'g_theme'=>'classic', 00326 'use_login'=>$p_user); 00327 00328 $a=pg_fetch_array($Ret,0); 00329 return $a; 00330 }
|
|
get the current sequence
Definition at line 251 of file postgres.php. References $Res, $seq, and ExecSql(). Referenced by Document::blank(), Document::Generate(), fiche::insert(), RecordFin(), RecordInvoice(), RecordODS(), RecordSell(), Document_modele::Save(), action::SaveStage2(), SetInternalCode(), and TransferCSV(). 00252 { 00253 $Res=ExecSql($p_cn,"select nextval('$p_seq') as seq"); 00254 $seq=pg_fetch_array($Res,0); 00255 return $seq['seq']; 00256 }
|
|
Definition at line 266 of file postgres.php. References $Res, and ExecSql(). Referenced by ExecuteScript(), RecordFin(), RecordInvoice(), RecordSell(), Document_modele::Save(), save_upload_document(), Document::SaveGenerated(), TransferCSV(), and Document::Upload().
|
|
Save a "piece justificative". save_upload_document
Definition at line 371 of file postgres.php. References $old_oid, $r, $ret, echo_debug(), echo_error(), ExecSql(), name, and Rollback(). Referenced by RecordInvoice(), and RecordSell(). 00371 { 00372 00373 $new_name=tempnam('/tmp','pj'); 00374 echo_debug('postgres.php',__LINE__,"new name=".$new_name); 00375 if ( strlen ($_FILES['pj']['tmp_name']) != 0 ) { 00376 if (move_uploaded_file($_FILES['pj']['tmp_name'], 00377 $new_name)) { 00378 // echo "Image saved"; 00379 00380 $oid= pg_lo_import($cn,$new_name); 00381 if ( $oid == false ) { 00382 echo_error('postgres.php',__LINE__,"cannot upload document"); 00383 Rollback($cn); 00384 return; 00385 } 00386 echo_debug('postgres.php',__LINE__,"Loading document"); 00387 // Remove old document 00388 $ret=ExecSql($cn,"select jr_pj from jrn where jr_grpt_id=$seq"); 00389 if (pg_num_rows($ret) != 0) { 00390 $r=pg_fetch_array($ret,0); 00391 $old_oid=$r['jr_pj']; 00392 if (strlen($old_oid) != 0) 00393 pg_lo_unlink($cn,$old_oid); 00394 } 00395 // Load new document 00396 ExecSql($cn,"update jrn set jr_pj=".$oid.", jr_pj_name='".$_FILES['pj']['name']."', ". 00397 "jr_pj_type='".$_FILES['pj']['type']."' where jr_grpt_id=$seq"); 00398 return $oid; 00399 00400 } else { 00401 echo "<H1>Error</H1>"; 00402 Rollback($cn); 00403 return null; 00404 } 00405 } 00406 00407 }
|
|
Definition at line 32 of file postgres.php. References $_SESSION, $cn, $Max, $row, CountSql(), DbConnect(), echo_debug(), and ExecSql(). 00032 { 00033 $l_user=$_SESSION['g_user']; 00034 if ( $p_max == 0 ) { 00035 $l_step=""; 00036 } else { 00037 $l_step="LIMIT $p_max OFFSET $p_first"; 00038 } 00039 $cn=DbConnect(); 00040 if ( $p_type == "all") { 00041 $l_sql="select *, 'W' as priv_priv from ac_dossier ORDER BY dos_name "; 00042 $p_Num=CountSql($cn,$l_sql); 00043 } else { 00044 $l_sql="select * from jnt_use_dos 00045 natural join ac_dossier 00046 natural join ac_users 00047 inner join priv_user on priv_jnt=jnt_id where 00048 use_login='".$l_user."' and priv_priv !='NO' 00049 order by dos_name "; 00050 $p_Num=CountSql($cn,$l_sql); 00051 } 00052 $l_sql=$l_sql.$l_step; 00053 $p_res=ExecSql($cn,$l_sql); 00054 00055 echo_debug('postgres.php',__LINE__,"ShowDossier:".$p_res." Line = $p_Num"); 00056 00057 $Max=pg_NumRows($p_res); 00058 if ( $Max == 0 ) return null; 00059 for ( $i=0;$i<$Max; $i++) { 00060 // echo_debug ("i = $i"); 00061 $row[]=pg_fetch_array($p_res,$i); 00062 //echo $row[dossier]; 00063 } 00064 return $row; 00065 }
|
|
Definition at line 257 of file postgres.php. References $Res, and ExecSql(). Referenced by Centralise(), Document_modele::Delete(), Document::Generate(), Document_modele::Get(), ImportCSV(), fiche::insert(), RecordFin(), RecordInvoice(), RecordODS(), RecordSell(), Document_modele::Save(), Document::SaveGenerated(), Document::Send(), TransferCSV(), and Document::Upload().
|
|
Synchronize les droits par défaut avec les journaux existants. SyncRight
Definition at line 289 of file postgres.php. References $cn, $priv, $Res, $right, $sql, DbConnect(), ExecSql(), and GetPriv(). 00289 { 00290 $priv=GetPriv($p_dossier,$p_user); 00291 $right=$priv[0]; 00292 00293 $cn=DbConnect($p_dossier); 00294 00295 $sql="insert into user_sec_jrn(uj_login,uj_jrn_id,uj_priv) ". 00296 "select '".$p_user."',jrn_def_id,'".$right."' from jrn_def ". 00297 "where jrn_def_id not in ". 00298 "(select uj_jrn_id from user_sec_jrn where uj_login='".$p_user."')"; 00299 $Res=ExecSql($cn,$sql); 00300 }
|