Page principale | Liste alphabétique | Liste des classes | Liste des fichiers | Membres de classe | Membres de fichier

htdocs/lib/functions.inc.php

Aller à la documentation de ce fichier.
00001 <?PHP 00002 /* Copyright (C) 2000-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org> 00003 * Copyright (C) 2003 Jean-Louis Bergamo <jlb@j1b.org> 00004 * Copyright (C) 2004 Laurent Destailleur <eldy@users.sourceforge.net> 00005 * 00006 * This program is free software; you can redistribute it and/or modify 00007 * it under the terms of the GNU General Public License as published by 00008 * the Free Software Foundation; either version 2 of the License, or 00009 * (at your option) any later version. 00010 * 00011 * This program is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 * GNU General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU General Public License 00017 * along with this program; if not, write to the Free Software 00018 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00019 * or see http://www.gnu.org/ 00020 * 00021 * $Id$ 00022 * $Source$ 00023 * 00024 */ 00025 00036 $yn[0] = "non"; 00037 $yn[1] = "oui"; 00038 00044 function dolibarr_syslog($message) 00045 { 00046 define_syslog_variables(); 00047 00048 openlog("dolibarr", LOG_PID | LOG_PERROR, LOG_USER); # LOG_USER au lieu de LOG_LOCAL0 car non accepté par tous les PHP 00049 00050 syslog(LOG_WARNING, $message); 00051 00052 closelog(); 00053 } 00054 00063 function dolibarr_fiche_head($links, $active=0) 00064 { 00065 print "<!-- fiche --><div class=\"tabs\">\n"; 00066 00067 for ($i = 0 ; $i < sizeof($links) ; $i++) 00068 { 00069 if ($links[$i][2] == 'image') 00070 { 00071 print '<a class="tabimage" href="'.$links[$i][0].'">'.$links[$i][1].'</a>'."\n"; 00072 } 00073 else 00074 { 00075 if ($i == $active) 00076 { 00077 print '<a id="active" class="tab" href="'.$links[$i][0].'">'.$links[$i][1].'</a>'."\n"; 00078 } 00079 else 00080 { 00081 print '<a class="tab" href="'.$links[$i][0].'">'.$links[$i][1].'</a>'."\n"; 00082 } 00083 } 00084 } 00085 00086 print "</div>\n"; 00087 print "<div class=\"tabBar\">\n<br>\n"; 00088 } 00089 00103 function dolibarr_set_const($db, $name, $value, $type='chaine', $visible=0, $note='') 00104 { 00105 $sql = "REPLACE INTO llx_const SET name = '$name', value='$value', visible=$visible, type='$type', note='$note'"; 00106 00107 if ($db->query($sql)) 00108 { 00109 return 1; 00110 } 00111 else 00112 { 00113 return 0; 00114 } 00115 } 00116 00124 function dolibarr_del_const($db, $name) 00125 { 00126 $sql = "DELETE FROM llx_const WHERE name='$name'"; 00127 00128 if ($db->query($sql)) 00129 { 00130 return 1; 00131 } 00132 else 00133 { 00134 return 0; 00135 } 00136 } 00137 00144 function dolibarr_print_ca($ca) 00145 { 00146 if ($ca > 1000) 00147 { 00148 $cat = round(($ca / 1000),2); 00149 $cat = "$cat Keuros"; 00150 } 00151 else 00152 { 00153 $cat = round($ca,2); 00154 $cat = "$cat euros"; 00155 } 00156 00157 if ($ca > 1000000) 00158 { 00159 $cat = round(($ca / 1000000),2); 00160 $cat = "$cat Meuros"; 00161 } 00162 00163 return $cat; 00164 } 00165 00173 function dolibarr_print_date($time,$format="%d %b %Y") 00174 { 00175 return strftime($format,$time); 00176 } 00177 00178 00184 function dolibarr_print_object_info($object) 00185 { 00186 print "Créé par : " . $object->user_creation->fullname . '<br>'; 00187 print "Date de création : " . strftime("%A %d %B %Y %H:%M:%S",$object->date_creation) . '<br>'; 00188 print "Modifié par : " . $object->user_modification->fullname . '<br>'; 00189 print "Date de modification : " . strftime("%A %d %B %Y %H:%M:%S",$object->date_modification) . '<br>'; 00190 } 00191 00199 function dolibarr_print_phone($phone) 00200 { 00201 if (strlen(trim($phone)) == 10) 00202 { 00203 return substr($phone,0,2)." ".substr($phone,2,2)." ".substr($phone,4,2)." ".substr($phone,6,2)." ".substr($phone,8,2); 00204 } 00205 else 00206 { 00207 return $phone; 00208 } 00209 } 00210 00211 function img_file($alt = "Voir") 00212 { 00213 return '<img src="'.DOL_URL_ROOT.'/theme/'.MAIN_THEME.'/img/file.png" border="0" alt="'.$alt.'">'; 00214 } 00215 00216 function img_file_new($alt = "Voir") 00217 { 00218 return '<img src="'.DOL_URL_ROOT.'/theme/'.MAIN_THEME.'/img/filenew.png" border="0" alt="'.$alt.'">'; 00219 } 00220 00221 00222 function img_pdf($alt = "Voir") 00223 { 00224 return '<img src="'.DOL_URL_ROOT.'/theme/'.MAIN_THEME.'/img/pdf.png" border="0" alt="'.$alt.'">'; 00225 } 00226 00227 function img_warning($alt = "Voir") 00228 { 00229 return '<img src="'.DOL_URL_ROOT.'/theme/'.MAIN_THEME.'/img/warning.png" border="0" alt="'.$alt.'">'; 00230 } 00231 00232 function img_delete($alt = "Supprimer") 00233 { 00234 return '<img src="'.DOL_URL_ROOT.'/theme/'.MAIN_THEME.'/img/delete.png" border="0" alt="'.$alt.'" title="Supprimer">'; 00235 } 00236 00237 function img_info($alt = "Informations") 00238 { 00239 return '<img src="'.DOL_URL_ROOT.'/theme/'.MAIN_THEME.'/img/info.png" border="0" alt="'.$alt.'" title="Informations">'; 00240 } 00241 00242 00243 function img_edit($alt = "Modifier") 00244 { 00245 return '<img src="'.DOL_URL_ROOT.'/theme/'.MAIN_THEME.'/img/edit.png" border="0" alt="'.$alt.'" title="Modifier">'; 00246 } 00247 00248 function img_phone_in($alt = "Modifier") 00249 { 00250 return '<img src="'.DOL_URL_ROOT.'/theme/'.MAIN_THEME.'/img/call.png" border="0" alt="'.$alt.'" title="'.$alt.'">'; 00251 } 00252 00253 function img_phone_out($alt = "Modifier") 00254 { 00255 return '<img src="'.DOL_URL_ROOT.'/theme/'.MAIN_THEME.'/img/call_out.png" border="0" alt="'.$alt.'" title="'.$alt.'">'; 00256 } 00257 00258 00259 function img_alerte($alt = "Alerte") 00260 { 00261 return '<img src="'.DOL_URL_ROOT.'/theme/'.MAIN_THEME.'/img/alerte.png" border="0" alt="'.$alt.'" title="'.$alt.'">'; 00262 } 00263 00264 00265 function img_next($alt = "Suivant") 00266 { 00267 return '<img src="'.DOL_URL_ROOT.'/theme/'.MAIN_THEME.'/img/next.png" border="0" alt="'.$alt.'" title="'.$alt.'">'; 00268 } 00269 00270 function img_previous($alt = "Précédent") 00271 { 00272 return '<img src="'.DOL_URL_ROOT.'/theme/'.MAIN_THEME.'/img/previous.png" border="0" alt="'.$alt.'" title="'.$alt.'">'; 00273 } 00274 00281 function loginfunction() 00282 { 00283 print '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">'; 00284 print "\n<html><head><title>Dolibarr Authentification</title>"; 00285 print '<style type="text/css"> 00286 body { 00287 font-size:14px; 00288 font-family: Verdana, Tahoma, Arial, Helvetica, sans-serif; 00289 background-color: #cac8c0; 00290 margin-left: 30%; 00291 margin-right: 30%; 00292 margin-top: 10%; 00293 margin-bottom: 1%; 00294 } 00295 div.main { 00296 background-color: white; 00297 text-align: left; 00298 border: solid black 1px; 00299 } 00300 div.main-inside { 00301 background-color: white; 00302 padding-left: 20px; 00303 padding-right: 50px; 00304 text-align: center; 00305 margin-bottom: 50px; 00306 margin-top: 30px; 00307 } 00308 div.footer { 00309 background-color: #dcdff4; 00310 font-size: 10px; 00311 border-top: solid black 1px; 00312 padding-left: 5px; 00313 text-align: center; 00314 } 00315 div.header { 00316 background-color: #dcdff4; 00317 border-bottom: solid black 1px; 00318 padding-left: 5px; 00319 text-align: center; 00320 } 00321 div.footer p { 00322 margin: 0px; 00323 } 00324 a:link,a:visited,a:active { 00325 text-decoration:none; 00326 color:blue; 00327 } 00328 a:hover { 00329 text-decoration:underline; 00330 color:blue; 00331 } 00332 </style> 00333 <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-15"> 00334 <script language="javascript"> 00335 function donnefocus(){ 00336 document.identification.username.focus(); 00337 } 00338 </script> 00339 </head> 00340 <body onload="donnefocus();"> 00341 <div class="main"> 00342 <div class="header">'; 00343 print 'Dolibarr '.DOL_VERSION; 00344 print ' 00345 </div> 00346 <div class="main-inside"> 00347 '; 00348 00349 echo '<form method="post" action="' . $_SERVER['PHP_SELF'] . '" name="identification">'; 00350 print '<table><tr>'; 00351 print '<td>Login : </td><td><input type="text" name="username"></td></tr>';; 00352 print '<tr><td>Password : </td><td><input type="password" name="password"></td></tr>'; 00353 00354 echo '</table> 00355 <p align="center"><input value="Login" type="submit"> 00356 </form>'; 00357 } 00358 00363 function accessforbidden() 00364 { 00365 llxHeader(); 00366 print "Accés interdit"; 00367 llxFooter(); 00368 exit(0); 00369 } 00370 00377 function doliMoveFileUpload($src_file, $dest_file) 00378 { 00379 $file_name = $dest_file; 00380 00381 if (substr($file_name, strlen($file_name) -3 , 3) == 'php') 00382 { 00383 $file_name = $dest_file . ".txt"; 00384 } 00385 00386 return move_uploaded_file($src_file, $file_name); 00387 } 00388 00389 00390 function dolibarr_user_page_param($db, &$user) 00391 { 00392 foreach ($GLOBALS["_GET"] as $key=>$value) 00393 { 00394 if ($key == "sortfield") 00395 { 00396 $sql = "REPLACE INTO ".MAIN_DB_PREFIX."user_param "; 00397 $sql .= " SET fk_user =".$user->id; 00398 $sql .= " ,page='".$GLOBALS["SCRIPT_URL"] . "'"; 00399 $sql .= " ,param='sortfield'"; 00400 $sql .= " ,value='".urlencode($value)."'"; 00401 00402 $db->query($sql); 00403 $user->page_param["sortfield"] = $value; 00404 } 00405 00406 // print $key . "=".$value . "<br>"; 00407 00408 if ($key == "sortorder") 00409 { 00410 $sql = "REPLACE INTO ".MAIN_DB_PREFIX."user_param "; 00411 $sql .= " SET fk_user =".$user->id; 00412 $sql .= " ,page='".$GLOBALS["SCRIPT_URL"] . "'"; 00413 $sql .= " ,param='sortorder'"; 00414 $sql .= " ,value='".urlencode($value)."'"; 00415 00416 $db->query($sql); 00417 $user->page_param["sortorder"] = $value; 00418 } 00419 if ($key == "begin") 00420 { 00421 $sql = "REPLACE INTO ".MAIN_DB_PREFIX."user_param "; 00422 $sql .= " SET fk_user =".$user->id; 00423 $sql .= " ,page='".$GLOBALS["SCRIPT_URL"] . "'"; 00424 $sql .= " ,param='begin'"; 00425 $sql .= " ,value='".$value."'"; 00426 00427 $db->query($sql); 00428 $user->page_param["begin"] = $value; 00429 } 00430 if ($key == "page") 00431 { 00432 $sql = "REPLACE INTO ".MAIN_DB_PREFIX."user_param "; 00433 $sql .= " SET fk_user =".$user->id; 00434 $sql .= " ,page='".$GLOBALS["SCRIPT_URL"] . "'"; 00435 $sql .= " ,param='page'"; 00436 $sql .= " ,value='".$value."'"; 00437 00438 $db->query($sql); 00439 $user->page_param["page"] = $value; 00440 } 00441 } 00442 } 00443 00451 function transcoS2L($zonein,$devise) 00452 { 00453 // Open source offert par <A HREF="mailto:alainfloch@free.fr?subject=chif2let">alainfloch@free.fr</A> 28/10/2001, sans garantie. 00454 // début de la fonction de transcodification de somme en toutes lettres 00455 00456 /* $zonein = "123,56"; 00457 * $devise = "E"; // préciser F si francs , sinon ce sera de l'euro 00458 * $r = transcoS2L($zonein,$devise); // appeler la fonction 00459 * echo "résultat vaut $r<br>"; 00460 * $zonelettresM = strtoupper($r); // si vous voulez la même zone mais tout en majuscules 00461 * echo "résultat en Majuscules vaut $zonelettresM<br>"; 00462 * $zonein = "1,01"; 00463 * $r = transcoS2L($zonein,$devise); 00464 * echo "résultat vaut $r<br>"; 00465 */ 00466 00467 00468 if ($devise == "F") 00469 { 00470 $unite_singulier = " franc "; 00471 $unite_pluriel = " francs "; 00472 $cent_singulier = " centime"; 00473 } 00474 else 00475 { 00476 $unite_singulier = " euro "; 00477 $unite_pluriel = " euros "; 00478 $cent_singulier = " centime"; 00479 } 00480 00481 $arr1_99 = array("zéro","un","deux","trois", 00482 "quatre","cinq","six","sept", 00483 "huit","neuf","dix","onze","douze", 00484 "treize","quatorze","quinze","seize", 00485 "dix-sept","dix-huit","dix-neuf","vingt "); 00486 00487 $arr1_99[30] = "trente "; 00488 $arr1_99[40] = "quarante "; 00489 $arr1_99[50] = "cinquante "; 00490 $arr1_99[60] = "soixante "; 00491 $arr1_99[70] = "soixante-dix "; 00492 $arr1_99[71] = "soixante et onze"; 00493 $arr1_99[80] = "quatre-vingts "; 00494 $i = 22; 00495 while ($i < 63) {// initialise la table 00496 $arr1_99[$i - 1] = $arr1_99[$i - 2]." et un"; 00497 $j = 0; 00498 while ($j < 8) { 00499 $k = $i + $j; 00500 $arr1_99[$k] = $arr1_99[$i - 2].$arr1_99[$j + 2]; 00501 $j++; 00502 } 00503 $i = $i + 10; 00504 } // fin initialise la table 00505 00506 $i = 12; 00507 while ($i < 20) {// initialise la table (suite) 00508 $j = 60 + $i; 00509 $arr1_99[$j] = "soixante-".$arr1_99[$i]; 00510 $i++; 00511 } // fin initialise la table (suite) 00512 00513 $i = 1; 00514 while ($i < 20) {// initialise la table (fin) 00515 $j = 80 + $i; 00516 $arr1_99[$j] = "quatre-vingt-".$arr1_99[$i]; 00517 $i++; 00518 } // fin initialise la table (fin) 00519 // echo "Pour une valeur en entrée = $zonein<br>"; //pour ceux qui ne croient que ce qu'ils voient ! 00520 // quelques petits controles s'imposent !! 00521 $valid = "[a-zA-Z\&\é\"\'\(\-\è\_\ç\à\)\=\;\:\!\*\$\^<>]"; 00522 if (ereg($valid,$zonein)) 00523 { 00524 $r = "<b>la chaîne ".$zonein." n'est pas valide</b>"; 00525 return($r); 00526 } 00527 $zone = explode(" ",$zonein); // supprimer les blancs séparateurs 00528 $zonein = implode("",$zone); // reconcatène la zone input 00529 $zone = explode(".",$zonein); // supprimer les points séparateurs 00530 $zonein = implode("",$zone); // reconcatène la zone input, ça c'est fort ! merci PHP 00531 $virg = strpos($zonein,",",1); // à la poursuite de la virgule 00532 $i = strlen($zonein); // et de la longueur de la zone input 00533 if ($virg == 0) { // ya pas de virgule 00534 if ($i > 7) 00535 { 00536 $r = "<b>la chaîne ".$zonein." est trop longue (maxi = 9 millions)</b>"; 00537 return($r); 00538 } 00539 $deb = 7 - $i; 00540 $zoneanaly = substr($zonechiffres,0,$deb).$zonein.",00"; 00541 } 00542 else 00543 { //ya une virgule 00544 $ti = explode(",",$zonein); // mettre de côté ce qu'il y a devant la virgule 00545 $i = strlen($ti[0]); // en controler la longueur 00546 $zonechiffres = "0000000,00"; 00547 if ($i > 7) 00548 { 00549 $r = "<b>la chaîne ".$zonein." est trop longue (maxi = 9 millions,00)</b>"; 00550 return($r); 00551 } 00552 $deb = 7 - $i; 00553 $zoneanaly = substr($zonechiffres,0,$deb).$zonein; 00554 } 00555 $M= substr($zoneanaly,0,1); 00556 if ($M != 0) 00557 { // qui veut gagner des millions 00558 $r = $arr1_99[$M]." million"; 00559 if ($M ==1) $r = $r." "; 00560 else $r = $r."s "; 00561 if (substr($zoneanaly,1,6)==0) 00562 { 00563 if ($devise == 'F') $r = $r." de "; 00564 else $r = $r."d'"; 00565 } 00566 } 00567 $CM= substr($zoneanaly,1,1); 00568 if ($CM == 1) 00569 { // qui veut gagner des centaines de mille 00570 $r = $r." cent "; 00571 } 00572 else 00573 { // ya des centaines de mille 00574 if ($CM > 1) 00575 { 00576 $r = $r. $arr1_99[$CM]." cent "; 00577 } 00578 } // fin du else ya des centaines de mille 00579 $MM= substr($zoneanaly,2,2); 00580 if (substr($zoneanaly,2,1)==0){ $MM = substr($zoneanaly,3,1);} // enlever le zéro des milliers cause indexation 00581 if ($MM ==0 && $CM > 0) 00582 { 00583 $r = $r."mille "; 00584 } 00585 if ($MM != 0) 00586 { 00587 if ($MM == 80) 00588 { 00589 $r = $r."quatre-vingt mille "; 00590 } 00591 else 00592 { 00593 if ($MM > 1 ) 00594 { 00595 $r = $r.$arr1_99[$MM]." mille "; 00596 } 00597 else 00598 { 00599 if ($CM == 0) $r = $r." mille "; 00600 else 00601 { 00602 $r = $r.$arr1_99[$MM]." mille "; 00603 } 00604 } 00605 } 00606 } 00607 $C2= substr($zoneanaly,5,2); 00608 if (substr($zoneanaly,5,1)==0){ $C2 = substr($zoneanaly,6,1);} // enlever le zéro des centaines cause indexation 00609 $C1= substr($zoneanaly,4,1); 00610 if ($C2 ==0 && $C1 > 1) 00611 { 00612 $r = $r.$arr1_99[$C1]." cents "; 00613 } 00614 else 00615 { 00616 if ($C1 == 1) $r = $r." cent "; 00617 else 00618 { 00619 if ($C1 > 1) $r = $r.$arr1_99[$C1]." cent "; 00620 } 00621 } 00622 if ($C2 != 0) 00623 { 00624 $r = $r.$arr1_99[$C2]; 00625 } 00626 if ($virg !=0) 00627 { 00628 if ($ti[0] > 1) $r = $r. $unite_pluriel; else $r = "un ".$unite_singulier; 00629 } 00630 else 00631 { 00632 if ($zonein > 1) $r = $r.$unite_pluriel; else $r = "un ".$unite_singulier; 00633 } 00634 $UN= substr($zoneanaly,8,2); 00635 if ($UN != "00") 00636 { 00637 $cts = $UN; 00638 if (substr($UN,0,1)==0){ $cts = substr($UN,1,1);} // enlever le zéro des centimes cause indexation 00639 $r = $r." et ". $arr1_99[$cts].$cent_singulier; 00640 if ($UN > 1) $r =$r."s"; // accorde au pluriel 00641 } 00642 $r1 = ltrim($r); // enleve quelques blancs possibles en début de zone 00643 $r = ucfirst($r1); // met le 1er caractère en Majuscule, c'est + zoli 00644 return($r); // retourne le résultat 00645 } // fin fonction transcoS2L 00646 00658 function print_liste_field_titre($name, $file, $field, $begin="", $options="") 00659 { 00660 global $conf; 00661 00662 print $name."&nbsp;"; 00663 print '<a href="'.$file.'?sortfield='.$field.'&amp;sortorder=asc&amp;begin='.$begin.$options.'">'; 00664 print '<img src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/1downarrow.png" border="0" alt="A-Z"></a>'; 00665 print '<a href="'.$file.'?sortfield='.$field.'&amp;sortorder=desc&amp;begin='.$begin.$options.'">'; 00666 print '<img src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/1uparrow.png" border="0" alt="Z-A"></a>'; 00667 } 00668 00684 function print_liste_field_titre_new($name, $file, $field, $begin="", $options="", $td="", $sortfield="") 00685 { 00686 global $conf; 00687 if ($sortfield == $field) 00688 { 00689 print '<td class="menusel" '. $td.'>'; 00690 } 00691 else 00692 { 00693 print '<td '. $td.'>'; 00694 } 00695 print $name."&nbsp;"; 00696 print '<a href="'.$file.'?sortfield='.$field.'&amp;sortorder=asc&amp;begin='.$begin.$options.'">'; 00697 print '<img src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/1downarrow.png" border="0" alt="A-Z"></a>'; 00698 print '<a href="'.$file.'?sortfield='.$field.'&amp;sortorder=desc&amp;begin='.$begin.$options.'">'; 00699 print '<img src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/1uparrow.png" border="0" alt="Z-A"></a>'; 00700 print "</td>"; 00701 } 00702 00708 function print_titre($titre) 00709 { 00710 print '<div class="titre">'.$titre.'</div>'; 00711 } 00712 00719 function print_fiche_titre($titre, $mesg='') 00720 { 00721 print "\n".'<table width="100%" border="0" cellpadding="3" cellspacing="0">'; 00722 print '<tr><td><div class="titre" valign="middle">'.$titre.'</div></td>'; 00723 if (strlen($mesg)) 00724 { 00725 print '<td align="right" valign="middle"><b>'.$mesg.'</b></td>'; 00726 } 00727 print '</tr></table>'."\n"; 00728 } 00729 00735 function dol_delete_file($file) 00736 { 00737 return unlink($file); 00738 } 00739 00744 function block_access() 00745 { 00746 llxHeader(); 00747 print "Accés refusé"; 00748 llxFooter(); 00749 } 00750 00751 /* 00752 * 00753 * 00754 */ 00755 00756 function print_barre_liste($titre, $page, $file, $options='', $sortfield='', $sortorder='', $form='', $num=-1) 00757 { 00758 global $conf; 00759 00760 if ($num > $conf->liste_limit or $num == -1) 00761 { 00762 $nextpage = 1; 00763 } 00764 else 00765 { 00766 $nextpage = 0; 00767 } 00768 00769 print '<table width="100%" border="0" cellpadding="3" cellspacing="0">'; 00770 00771 if ($page > 0) 00772 { 00773 print '<tr><td><div class="titre">'.$titre.' - page '.($page+1).'</div></td>'; 00774 } 00775 else 00776 { 00777 print '<tr><td><div class="titre">'.$titre.'</div></td>'; 00778 } 00779 00780 if ($form) 00781 { 00782 print '<td align="left">'.$form.'</td>'; 00783 } 00784 00785 print '<td align="right">'; 00786 00787 if (strlen($sortfield)) 00788 { 00789 $options .= "&amp;sortfield=$sortfield"; 00790 } 00791 00792 if (strlen($sortorder)) 00793 { 00794 $options .= "&amp;sortorder=$sortorder"; 00795 } 00796 00797 // affichage des fleches de navigation 00798 00799 print_fleche_navigation($page,$file,$options, $nextpage); 00800 00801 print '</td></tr></table>'; 00802 } 00803 00812 function print_fleche_navigation($page,$file,$options='', $nextpage) 00813 { 00814 global $conf; 00815 if ($page > 0) 00816 { 00817 print '<a href="'.$file.'?page='.($page-1).$options.'"><img alt="Page précédente" src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/1leftarrow.png" border="0"></a>'; 00818 } 00819 00820 if ($nextpage > 0) 00821 { 00822 print '<a href="'.$file.'?page='.($page+1).$options.'"><img alt="Page suivante" src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/1rightarrow.png" border="0"></a>'; 00823 } 00824 } 00825 00832 function print_oui_non($value) 00833 { 00834 if ($value) 00835 { 00836 print '<option value="0">non'; 00837 print '<option value="1" selected>oui'; 00838 } 00839 else 00840 { 00841 print '<option value="0" selected>non'; 00842 print '<option value="1">oui'; 00843 } 00844 } 00845 00852 function print_date_select($set_time='') 00853 { 00854 if (! $set_time) 00855 { 00856 $set_time = time(); 00857 } 00858 00859 $strmonth[1] = "Janvier"; 00860 $strmonth[2] = "F&eacute;vrier"; 00861 $strmonth[3] = "Mars"; 00862 $strmonth[4] = "Avril"; 00863 $strmonth[5] = "Mai"; 00864 $strmonth[6] = "Juin"; 00865 $strmonth[7] = "Juillet"; 00866 $strmonth[8] = "Ao&ucirc;t"; 00867 $strmonth[9] = "Septembre"; 00868 $strmonth[10] = "Octobre"; 00869 $strmonth[11] = "Novembre"; 00870 $strmonth[12] = "D&eacute;cembre"; 00871 00872 $smonth = 1; $endmonth = 12; 00873 $sday = 1; $endday = 31; 00874 00875 $cday = date("d", $set_time); 00876 $cmonth = date("n", $set_time); 00877 $syear = date("Y", $set_time); 00878 00879 print "<select name=\"reday\">"; 00880 00881 for ($day = 1 ; $day <= $endday ; $day++) 00882 { 00883 if ($day == $cday) 00884 { 00885 print "<option value=\"$day\" selected>$day"; 00886 } 00887 else 00888 { 00889 print "<option value=\"$day\">$day"; 00890 } 00891 } 00892 00893 print "</select>"; 00894 00895 00896 print "<select name=\"remonth\">"; 00897 for ($month = $smonth ; $month <= $endmonth ; $month++) 00898 { 00899 if ($month == $cmonth) 00900 { 00901 print "<option value=\"$month\" selected>" . $strmonth[$month]; 00902 } 00903 else 00904 { 00905 print "<option value=\"$month\">" . $strmonth[$month]; 00906 } 00907 } 00908 print "</select>"; 00909 00910 print "<select name=\"reyear\">"; 00911 00912 for ($year = $syear - 2; $year < $syear + 5 ; $year++) 00913 { 00914 if ($year == $syear) 00915 { 00916 print "<option value=\"$year\" SELECTED>$year"; 00917 } 00918 else 00919 { 00920 print "<option value=\"$year\">$year"; 00921 } 00922 } 00923 print "</select>\n"; 00924 00925 } 00935 function print_heure_select($prefix,$begin=1,$end=23) { 00936 00937 print '<select name="'.$prefix.'hour">'; 00938 for ($hour = $begin ; $hour <= $end ; $hour++) { 00939 print "<option value=\"$hour\">$hour"; 00940 } 00941 print "</select>&nbsp;H&nbsp;"; 00942 print '<select name="'.$prefix.'min">'; 00943 for ($min = 0 ; $min < 60 ; $min=$min+5) { 00944 if ($min < 10) { 00945 $min = "0" . $min; 00946 } 00947 print "<option value=\"$min\">$min"; 00948 } 00949 print "</select>\n"; 00950 } 00951 00957 function print_duree_select($prefix) 00958 { 00959 print '<select name="'.$prefix.'hour">'; 00960 print "<option value=\"0\">0"; 00961 print "<option value=\"1\" SELECTED>1"; 00962 00963 for ($hour = 2 ; $hour < 13 ; $hour++) 00964 { 00965 print "<option value=\"$hour\">$hour"; 00966 } 00967 print "</select>&nbsp;H&nbsp;"; 00968 print '<select name="'.$prefix.'min">'; 00969 for ($min = 0 ; $min < 55 ; $min=$min+5) 00970 { 00971 print "<option value=\"$min\">$min"; 00972 } 00973 print "</select>\n"; 00974 } 00975 00985 function price($amount, $html=0) 00986 { 00987 if ($html) 00988 { 00989 00990 $dec='.'; $thousand=' '; 00991 return ereg_replace(' ','&nbsp;',number_format($amount, 2, $dec, $thousand)); 00992 00993 } 00994 else 00995 { 00996 return number_format($amount, 2, '.', ' '); 00997 } 00998 00999 } 01000 01007 function francs($euros) 01008 { 01009 return price($euros * 6.55957); 01010 } 01011 01018 function tva($euros, $taux=19.6) 01019 { 01020 $taux = $taux / 100 ; 01021 01022 return sprintf("%01.2f",($euros * $taux)); 01023 } 01024 01031 function inctva($euros, $taux=1.196) 01032 { 01033 return sprintf("%01.2f",($euros * $taux)); 01034 } 01035 01046 function stat_print($basename,$bc1,$bc2,$ftc, $jour) { 01047 01048 $db = pg_Connect("","","","","$basename"); 01049 if (!$db) { 01050 echo "Pas de connexion a la base\n"; 01051 exit ; 01052 } 01053 01054 $offset = $jour * 9; 01055 01056 $sql="SELECT s.date, s.nb, l.libelle FROM stat_base as s, stat_cat as l WHERE s.cat = l.id ORDER by s.date DESC, s.cat ASC LIMIT 9 OFFSET $offset"; 01057 01058 $result = $db->query($sql); 01059 if (!$result) { 01060 print "Erreur SELECT<br><h1>$sql</h1><br>"; 01061 return 1; 01062 } 01063 01064 print "<table border=1 cellspacing=0 cellpadding=2>"; 01065 print "<tr><td><font color=\"white\">base <b>$basename</b></font></td>"; 01066 print "<td><font color=\"white\">libelle</font></td>"; 01067 print "</tr>"; 01068 01069 $num = $db->num_rows(); 01070 $i = 0; 01071 01072 $tag = 1; 01073 while ( $i < $num) { 01074 $obj = $db->fetch_object( $i); 01075 01076 $tag = !$tag; 01077 01078 print "<TR><TD>$obj->date</TD><TD>$obj->libelle</TD>\n"; 01079 print "<TD align=\"center\">$obj->nb</TD></TR>\n"; 01080 $i++; 01081 } 01082 print "</TABLE>"; 01083 $db->free(); 01084 01085 $db->close(); 01086 01087 } 01088 01089 function tab_count($basename,$bc1,$bc2,$ftc) { 01090 01091 $db = pg_Connect("","","","","$basename"); 01092 if (!$db) { 01093 echo "Pas de connexion a la base\n"; 01094 exit ; 01095 } 01096 01097 $sql="SELECT count(*) AS nbcv from candidat WHERE active=1"; 01098 $result = $db->query($sql); 01099 if (!$result) { 01100 print "Erreur SELECT<br><h1>$sql</h1><br>"; 01101 return 1; 01102 } 01103 print "<table border=0 bgcolor=black cellspacing=0 cellpadding=0><tr><td>"; 01104 01105 print "<table border=0 cellspacing=1 cellpadding=1>"; 01106 print "<tr><td><font color=\"white\">base <b>$basename</b></font></td>"; 01107 print "<td><font color=\"white\">libelle</font></td>"; 01108 print "</tr>"; 01109 $nbcv = $db->result( $i, "nbcv"); 01110 01111 print "<tr $bc1><td><b>$ftc Nombre de CV</font></b></td>\n"; 01112 print "<td align=\"center\">$ftc $nbcv</td>\n"; 01113 print "</tr>\n"; 01114 $db->free(); 01115 01116 $sql="SELECT count(*) AS nbcv from offre WHERE active=1"; 01117 01118 $result = $db->query($sql); 01119 if (!$result) { 01120 print "Erreur SELECT<br><h1>$sql</h1><br>"; 01121 } 01122 $nbcv = $db->result( $i, "nbcv"); 01123 01124 print "<tr $bc2><td><b>$ftc Nombre d'offre</font></b></td>"; 01125 print "<td align=\"center\">$ftc $nbcv</td>"; 01126 print "</tr>"; 01127 01128 $db->free(); 01129 01130 01131 $sql="SELECT count(*) AS nbcv from candidat WHERE active=0"; 01132 01133 $result = $db->query($sql); 01134 if (!$result) { 01135 print "Erreur SELECT<br><h1>$sql</h1><br>"; 01136 } 01137 01138 $nbcv = $db->result( $i, "nbcv"); 01139 01140 print "<tr $bc1><td><b>$ftc Nombre de CV inactifs</font></b></td>\n"; 01141 print "<td align=\"center\">$ftc $nbcv</td>"; 01142 print "</tr>"; 01143 01144 $db->free(); 01145 01146 01147 $sql="SELECT count(*) AS nbcv from offre WHERE active=0"; 01148 01149 $result = $db->query($sql); 01150 if (!$result) { 01151 print "Erreur SELECT<br><h1>$sql</h1><br>"; 01152 } 01153 01154 $nbcv = $db->result( $i, "nbcv"); 01155 01156 print "<tr $bc2><td><b>$ftc Nombre d'offres inactives</font></b></td>\n"; 01157 print "<td align=\"center\">$ftc $nbcv</td>\n"; 01158 print "</tr>\n"; 01159 01160 $db->free(); 01161 01162 $sql="SELECT count(*) AS nbsoc from logsoc"; 01163 01164 $result = $db->query($sql); 01165 if (!$result) { 01166 print "Erreur SELECT<br><h1>$sql</h1><br>"; 01167 } 01168 01169 $nbsoc = $db->result( $i, "nbsoc"); 01170 01171 print "<tr $bc1><td><b>$ftc Nombre de logins societes</font></b></td>\n"; 01172 print "<td align=\"center\">$ftc $nbsoc</td>"; 01173 print "</tr>"; 01174 01175 print "</td></tr></table></td></tr></table>"; 01176 01177 $db->close(); 01178 01179 } 01180 01188 function logfile($str,$log="/var/log/dolibarr/dolibarr.log") 01189 { 01190 if (defined("MAIN_DEBUG") && MAIN_DEBUG ==1) 01191 { 01192 if (!file_exists($log)) 01193 { 01194 if (!$file=fopen($log,"w")) 01195 { 01196 return 0; 01197 } 01198 } 01199 else 01200 { 01201 if (!$file=fopen($log,"a+")) 01202 { 01203 return 0; 01204 } 01205 } 01206 $logentry=date("[d/M/Y:H:i:s] ").$str."\n"; 01207 if(!fwrite($file,$logentry)) { 01208 fclose($file); 01209 return 0; 01210 } 01211 fclose($file); 01212 return 1; 01213 } 01214 } 01215 01224 function creer_pass_aleatoire($longueur = 8, $sel = "") { 01225 $seed = (double) (microtime() + 1) * time(); 01226 srand($seed); 01227 01228 for ($i = 0; $i < $longueur; $i++) { 01229 if (!$s) { 01230 if (!$s) $s = rand(); 01231 $s = substr(md5(uniqid($s).$sel), 0, 16); 01232 } 01233 $r = unpack("Cr", pack("H2", $s.$s)); 01234 $x = $r['r'] & 63; 01235 if ($x < 10) $x = chr($x + 48); 01236 else if ($x < 36) $x = chr($x + 55); 01237 else if ($x < 62) $x = chr($x + 61); 01238 else if ($x == 63) $x = '/'; 01239 else $x = '.'; 01240 $pass .= $x; 01241 $s = substr($s, 2); 01242 } 01243 return $pass; 01244 } 01245 01251 function initialiser_sel() { 01252 global $htsalt; 01253 01254 $htsalt = '$1$'.creer_pass_aleatoire(); 01255 } 01256 01257 ?>

Généré le Fri Jul 16 00:31:06 2004 pour dolibarr par doxygen 1.3.7