htdocs/lib/functions.inc.php
00001 <?PHP
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 $yn[0] = "non";
00027 $yn[1] = "oui";
00028
00029 Function dolibarr_syslog($message)
00030 {
00031 define_syslog_variables();
00032
00033 openlog("dolibarr", LOG_PID | LOG_PERROR, LOG_USER); # LOG_USER au lieu de LOG_LOCAL0 car non accepté par tous les PHP
00034
00035 syslog(LOG_WARNING, $message);
00036
00037 closelog();
00038 }
00039
00040 Function dolibarr_fiche_head($links, $active=0)
00041 {
00042 print "<!-- fiche --><div class=\"tabs\">\n";
00043
00044 for ($i = 0 ; $i < sizeof($links) ; $i++)
00045 {
00046 if ($links[$i][2] == 'image')
00047 {
00048 print '<a class="tabimage" href="'.$links[$i][0].'">'.$links[$i][1].'</a>'."\n";
00049 }
00050 else
00051 {
00052 if ($i == $active)
00053 {
00054 print '<a id="active" class="tab" href="'.$links[$i][0].'">'.$links[$i][1].'</a>'."\n";
00055 }
00056 else
00057 {
00058 print '<a class="tab" href="'.$links[$i][0].'">'.$links[$i][1].'</a>'."\n";
00059 }
00060 }
00061 }
00062
00063 print "</div>\n";
00064 print "<div class=\"tabBar\">\n<br>\n";
00065 }
00066
00067
00068 Function dolibarr_set_const($db, $name, $value, $type='chaine', $visible=0, $note='')
00069
00070
00071 {
00072 $sql = "REPLACE INTO llx_const SET name = '$name', value='$value', visible=$visible, type='$type', note='$note'";
00073
00074 if ($db->query($sql))
00075 {
00076 return 1;
00077 }
00078 else
00079 {
00080 return 0;
00081 }
00082 }
00083
00084 Function dolibarr_del_const($db, $name)
00085
00086
00087 {
00088 $sql = "DELETE FROM llx_const WHERE name='$name'";
00089
00090 if ($db->query($sql))
00091 {
00092 return 1;
00093 }
00094 else
00095 {
00096 return 0;
00097 }
00098 }
00099
00100 Function dolibarr_print_ca($ca)
00101 {
00102
00103 if ($ca > 1000)
00104 {
00105 $cat = round(($ca / 1000),2);
00106 $cat = "$cat Keuros";
00107 }
00108 else
00109 {
00110 $cat = round($ca,2);
00111 $cat = "$cat euros";
00112 }
00113
00114 if ($ca > 1000000)
00115 {
00116 $cat = round(($ca / 1000000),2);
00117 $cat = "$cat Meuros";
00118 }
00119
00120 return $cat;
00121 }
00122
00123 Function dolibarr_print_date($time,$format="%d %b %Y")
00124 {
00125
00126 return strftime($format,$time);
00127 }
00128
00129 Function dolibarr_print_object_info($object)
00130 {
00131 print "Créé par : " . $object->user_creation->fullname . '<br>';
00132 print "Date de création : " . strftime("%A %d %B %Y %H:%M:%S",$object->date_creation) . '<br>';
00133 print "Modifié par : " . $object->user_modification->fullname . '<br>';
00134 print "Date de modification : " . strftime("%A %d %B %Y %H:%M:%S",$object->date_modification) . '<br>';
00135 }
00136
00137 Function dolibarr_print_phone($phone)
00138 {
00139
00140 if (strlen(trim($phone)) == 10)
00141 {
00142 return substr($phone,0,2)." ".substr($phone,2,2)." ".substr($phone,4,2)." ".substr($phone,6,2)." ".substr($phone,8,2);
00143 }
00144 else
00145 {
00146 return $phone;
00147 }
00148 }
00149
00150 Function img_file($alt = "Voir")
00151 {
00152 return '<img src="'.DOL_URL_ROOT.'/theme/'.MAIN_THEME.'/img/file.png" border="0" alt="'.$alt.'">';
00153 }
00154
00155 Function img_file_new($alt = "Voir")
00156 {
00157 return '<img src="'.DOL_URL_ROOT.'/theme/'.MAIN_THEME.'/img/filenew.png" border="0" alt="'.$alt.'">';
00158 }
00159
00160
00161 Function img_pdf($alt = "Voir")
00162 {
00163 return '<img src="'.DOL_URL_ROOT.'/theme/'.MAIN_THEME.'/img/pdf.png" border="0" alt="'.$alt.'">';
00164 }
00165
00166 Function img_warning($alt = "Voir")
00167 {
00168 return '<img src="'.DOL_URL_ROOT.'/theme/'.MAIN_THEME.'/img/warning.png" border="0" alt="'.$alt.'">';
00169 }
00170
00171 Function img_delete($alt = "Supprimer")
00172 {
00173 return '<img src="'.DOL_URL_ROOT.'/theme/'.MAIN_THEME.'/img/delete.png" border="0" alt="'.$alt.'" title="Supprimer">';
00174 }
00175
00176 Function img_info($alt = "Informations")
00177 {
00178 return '<img src="'.DOL_URL_ROOT.'/theme/'.MAIN_THEME.'/img/info.png" border="0" alt="'.$alt.'" title="Informations">';
00179 }
00180
00181
00182 Function img_edit($alt = "Modifier")
00183 {
00184 return '<img src="'.DOL_URL_ROOT.'/theme/'.MAIN_THEME.'/img/edit.png" border="0" alt="'.$alt.'" title="Modifier">';
00185 }
00186
00187 Function img_phone_in($alt = "Modifier")
00188 {
00189 return '<img src="'.DOL_URL_ROOT.'/theme/'.MAIN_THEME.'/img/call.png" border="0" alt="'.$alt.'" title="'.$alt.'">';
00190 }
00191
00192 Function img_phone_out($alt = "Modifier")
00193 {
00194 return '<img src="'.DOL_URL_ROOT.'/theme/'.MAIN_THEME.'/img/call_out.png" border="0" alt="'.$alt.'" title="'.$alt.'">';
00195 }
00196
00197
00198 Function img_alerte($alt = "Alerte")
00199 {
00200 return '<img src="'.DOL_URL_ROOT.'/theme/'.MAIN_THEME.'/img/alerte.png" border="0" alt="'.$alt.'" title="'.$alt.'">';
00201 }
00202
00203
00204 Function img_next($alt = "Suivant")
00205 {
00206 return '<img src="'.DOL_URL_ROOT.'/theme/'.MAIN_THEME.'/img/next.png" border="0" alt="'.$alt.'" title="'.$alt.'">';
00207 }
00208
00209 Function img_previous($alt = "Précédent")
00210 {
00211 return '<img src="'.DOL_URL_ROOT.'/theme/'.MAIN_THEME.'/img/previous.png" border="0" alt="'.$alt.'" title="'.$alt.'">';
00212 }
00213
00214
00215 function loginFunction()
00216 {
00220 print '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">';
00221 print "\n<html><head><title>Dolibarr Authentification</title>";
00222 print '<style type="text/css">
00223 body {
00224 font-size:14px;
00225 font-family: Verdana, Tahoma, Arial, Helvetica, sans-serif;
00226 background-color: #cac8c0;
00227 margin-left: 30%;
00228 margin-right: 30%;
00229 margin-top: 10%;
00230 margin-bottom: 1%;
00231 }
00232 div.main {
00233 background-color: white;
00234 text-align: left;
00235 border: solid black 1px;
00236 }
00237 div.main-inside {
00238 background-color: white;
00239 padding-left: 20px;
00240 padding-right: 50px;
00241 text-align: center;
00242 margin-bottom: 50px;
00243 margin-top: 30px;
00244 }
00245 div.footer {
00246 background-color: #dcdff4;
00247 font-size: 10px;
00248 border-top: solid black 1px;
00249 padding-left: 5px;
00250 text-align: center;
00251 }
00252 div.header {
00253 background-color: #dcdff4;
00254 border-bottom: solid black 1px;
00255 padding-left: 5px;
00256 text-align: center;
00257 }
00258 div.footer p {
00259 margin: 0px;
00260 }
00261 a:link,a:visited,a:active {
00262 text-decoration:none;
00263 color:blue;
00264 }
00265 a:hover {
00266 text-decoration:underline;
00267 color:blue;
00268 }
00269 </style>
00270 <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-15">
00271 <script language="javascript">
00272 function donnefocus(){
00273 document.identification.username.focus();
00274 }
00275 </script>
00276 </head>
00277 <body onload="donnefocus();">
00278 <div class="main">
00279 <div class="header">';
00280 print 'Dolibarr '.DOL_VERSION;
00281 print '
00282 </div>
00283 <div class="main-inside">
00284 ';
00285
00286 echo '<form method="post" action="' . $_SERVER['PHP_SELF'] . '" name="identification">';
00287 print '<table><tr>';
00288 print '<td>Login : </td><td><input type="text" name="username"></td></tr>';;
00289 print '<tr><td>Password : </td><td><input type="password" name="password"></td></tr>';
00290
00291 echo '</table>
00292 <p align="center"><input value="Login" type="submit">
00293 </form>';
00294 }
00295
00296
00297
00298
00299 function accessforbidden()
00300 {
00301 llxHeader();
00302 print "Accés interdit";
00303 llxFooter();
00304 exit(0);
00305 }
00306
00307 function doliMoveFileUpload($src_file, $dest_file)
00308 {
00309 $file_name = $dest_file;
00310
00311 if (substr($file_name, strlen($file_name) -3 , 3) == 'php')
00312 {
00313 $file_name = $dest_file . ".txt";
00314 }
00315
00316 return move_uploaded_file($src_file, $file_name);
00317 }
00318
00319 function dolibarr_user_page_param($db, &$user)
00320 {
00321 foreach ($GLOBALS["_GET"] as $key=>$value)
00322 {
00323 if ($key == "sortfield")
00324 {
00325 $sql = "REPLACE INTO ".MAIN_DB_PREFIX."user_param ";
00326 $sql .= " SET fk_user =".$user->id;
00327 $sql .= " ,page='".$GLOBALS["SCRIPT_URL"] . "'";
00328 $sql .= " ,param='sortfield'";
00329 $sql .= " ,value='".urlencode($value)."'";
00330
00331 $db->query($sql);
00332 $user->page_param["sortfield"] = $value;
00333 }
00334
00335
00336
00337 if ($key == "sortorder")
00338 {
00339 $sql = "REPLACE INTO ".MAIN_DB_PREFIX."user_param ";
00340 $sql .= " SET fk_user =".$user->id;
00341 $sql .= " ,page='".$GLOBALS["SCRIPT_URL"] . "'";
00342 $sql .= " ,param='sortorder'";
00343 $sql .= " ,value='".urlencode($value)."'";
00344
00345 $db->query($sql);
00346 $user->page_param["sortorder"] = $value;
00347 }
00348 if ($key == "begin")
00349 {
00350 $sql = "REPLACE INTO ".MAIN_DB_PREFIX."user_param ";
00351 $sql .= " SET fk_user =".$user->id;
00352 $sql .= " ,page='".$GLOBALS["SCRIPT_URL"] . "'";
00353 $sql .= " ,param='begin'";
00354 $sql .= " ,value='".$value."'";
00355
00356 $db->query($sql);
00357 $user->page_param["begin"] = $value;
00358 }
00359 if ($key == "page")
00360 {
00361 $sql = "REPLACE INTO ".MAIN_DB_PREFIX."user_param ";
00362 $sql .= " SET fk_user =".$user->id;
00363 $sql .= " ,page='".$GLOBALS["SCRIPT_URL"] . "'";
00364 $sql .= " ,param='page'";
00365 $sql .= " ,value='".$value."'";
00366
00367 $db->query($sql);
00368 $user->page_param["page"] = $value;
00369 }
00370 }
00371 }
00372
00373 function transcoS2L($zonein,$devise)
00374 {
00375
00376
00377
00378
00379
00380
00381
00382
00383
00384
00385
00386
00387
00388
00389
00390 if ($devise == "F")
00391 {
00392 $unite_singulier = " franc ";
00393 $unite_pluriel = " francs ";
00394 $cent_singulier = " centime";
00395 }
00396 else
00397 {
00398 $unite_singulier = " euro ";
00399 $unite_pluriel = " euros ";
00400 $cent_singulier = " centime";
00401 }
00402
00403 $arr1_99 = array("zéro","un","deux","trois",
00404 "quatre","cinq","six","sept",
00405 "huit","neuf","dix","onze","douze",
00406 "treize","quatorze","quinze","seize",
00407 "dix-sept","dix-huit","dix-neuf","vingt ");
00408
00409 $arr1_99[30] = "trente ";
00410 $arr1_99[40] = "quarante ";
00411 $arr1_99[50] = "cinquante ";
00412 $arr1_99[60] = "soixante ";
00413 $arr1_99[70] = "soixante-dix ";
00414 $arr1_99[71] = "soixante et onze";
00415 $arr1_99[80] = "quatre-vingts ";
00416 $i = 22;
00417 while ($i < 63) {
00418 $arr1_99[$i - 1] = $arr1_99[$i - 2]." et un";
00419 $j = 0;
00420 while ($j < 8) {
00421 $k = $i + $j;
00422 $arr1_99[$k] = $arr1_99[$i - 2].$arr1_99[$j + 2];
00423 $j++;
00424 }
00425 $i = $i + 10;
00426 }
00427
00428 $i = 12;
00429 while ($i < 20) {
00430 $j = 60 + $i;
00431 $arr1_99[$j] = "soixante-".$arr1_99[$i];
00432 $i++;
00433 }
00434
00435 $i = 1;
00436 while ($i < 20) {
00437 $j = 80 + $i;
00438 $arr1_99[$j] = "quatre-vingt-".$arr1_99[$i];
00439 $i++;
00440 }
00441
00442
00443 $valid = "[a-zA-Z\&\é\"\'\(\-\è\_\ç\à\)\=\;\:\!\*\$\^<>]";
00444 if (ereg($valid,$zonein))
00445 {
00446 $r = "<b>la chaîne ".$zonein." n'est pas valide</b>";
00447 return($r);
00448 }
00449 $zone = explode(" ",$zonein);
00450 $zonein = implode("",$zone);
00451 $zone = explode(".",$zonein);
00452 $zonein = implode("",$zone);
00453 $virg = strpos($zonein,",",1);
00454 $i = strlen($zonein);
00455 if ($virg == 0) {
00456 if ($i > 7)
00457 {
00458 $r = "<b>la chaîne ".$zonein." est trop longue (maxi = 9 millions)</b>";
00459 return($r);
00460 }
00461 $deb = 7 - $i;
00462 $zoneanaly = substr($zonechiffres,0,$deb).$zonein.",00";
00463 }
00464 else
00465 {
00466 $ti = explode(",",$zonein);
00467 $i = strlen($ti[0]);
00468 $zonechiffres = "0000000,00";
00469 if ($i > 7)
00470 {
00471 $r = "<b>la chaîne ".$zonein." est trop longue (maxi = 9 millions,00)</b>";
00472 return($r);
00473 }
00474 $deb = 7 - $i;
00475 $zoneanaly = substr($zonechiffres,0,$deb).$zonein;
00476 }
00477 $M= substr($zoneanaly,0,1);
00478 if ($M != 0)
00479 {
00480 $r = $arr1_99[$M]." million";
00481 if ($M ==1) $r = $r." ";
00482 else $r = $r."s ";
00483 if (substr($zoneanaly,1,6)==0)
00484 {
00485 if ($devise == 'F') $r = $r." de ";
00486 else $r = $r."d'";
00487 }
00488 }
00489 $CM= substr($zoneanaly,1,1);
00490 if ($CM == 1)
00491 {
00492 $r = $r." cent ";
00493 }
00494 else
00495 {
00496 if ($CM > 1)
00497 {
00498 $r = $r. $arr1_99[$CM]." cent ";
00499 }
00500 }
00501 $MM= substr($zoneanaly,2,2);
00502 if (substr($zoneanaly,2,1)==0){ $MM = substr($zoneanaly,3,1);}
00503 if ($MM ==0 && $CM > 0)
00504 {
00505 $r = $r."mille ";
00506 }
00507 if ($MM != 0)
00508 {
00509 if ($MM == 80)
00510 {
00511 $r = $r."quatre-vingt mille ";
00512 }
00513 else
00514 {
00515 if ($MM > 1 )
00516 {
00517 $r = $r.$arr1_99[$MM]." mille ";
00518 }
00519 else
00520 {
00521 if ($CM == 0) $r = $r." mille ";
00522 else
00523 {
00524 $r = $r.$arr1_99[$MM]." mille ";
00525 }
00526 }
00527 }
00528 }
00529 $C2= substr($zoneanaly,5,2);
00530 if (substr($zoneanaly,5,1)==0){ $C2 = substr($zoneanaly,6,1);}
00531 $C1= substr($zoneanaly,4,1);
00532 if ($C2 ==0 && $C1 > 1)
00533 {
00534 $r = $r.$arr1_99[$C1]." cents ";
00535 }
00536 else
00537 {
00538 if ($C1 == 1) $r = $r." cent ";
00539 else
00540 {
00541 if ($C1 > 1) $r = $r.$arr1_99[$C1]." cent ";
00542 }
00543 }
00544 if ($C2 != 0)
00545 {
00546 $r = $r.$arr1_99[$C2];
00547 }
00548 if ($virg !=0)
00549 {
00550 if ($ti[0] > 1) $r = $r. $unite_pluriel; else $r = "un ".$unite_singulier;
00551 }
00552 else
00553 {
00554 if ($zonein > 1) $r = $r.$unite_pluriel; else $r = "un ".$unite_singulier;
00555 }
00556 $UN= substr($zoneanaly,8,2);
00557 if ($UN != "00")
00558 {
00559 $cts = $UN;
00560 if (substr($UN,0,1)==0){ $cts = substr($UN,1,1);}
00561 $r = $r." et ". $arr1_99[$cts].$cent_singulier;
00562 if ($UN > 1) $r =$r."s";
00563 }
00564 $r1 = ltrim($r);
00565 $r = ucfirst($r1);
00566 return($r);
00567 }
00568
00569
00570
00571 function print_liste_field_titre($name, $file, $field, $begin="", $options="")
00572 {
00573 global $conf;
00574
00575 print $name." ";
00576 print '<a href="'.$file.'?sortfield='.$field.'&sortorder=asc&begin='.$begin.$options.'">';
00577 print '<img src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/1downarrow.png" border="0" alt="A-Z"></a>';
00578 print '<a href="'.$file.'?sortfield='.$field.'&sortorder=desc&begin='.$begin.$options.'">';
00579 print '<img src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/1uparrow.png" border="0" alt="Z-A"></a>';
00580 }
00581
00582 function print_liste_field_titre_new($name, $file, $field, $begin="", $options="", $td="", $sortfield="")
00583 {
00584
00585
00586
00587
00588
00589 global $conf;
00590 if ($sortfield == $field)
00591 {
00592 print '<td class="menusel" '. $td.'>';
00593 }
00594 else
00595 {
00596 print '<td '. $td.'>';
00597 }
00598 print $name." ";
00599 print '<a href="'.$file.'?sortfield='.$field.'&sortorder=asc&begin='.$begin.$options.'">';
00600 print '<img src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/1downarrow.png" border="0" alt="A-Z"></a>';
00601 print '<a href="'.$file.'?sortfield='.$field.'&sortorder=desc&begin='.$begin.$options.'">';
00602 print '<img src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/1uparrow.png" border="0" alt="Z-A"></a>';
00603 print "</td>";
00604 }
00605
00606
00607
00608
00609 function print_titre($titre)
00610 {
00611 print '<div class="titre">'.$titre.'</div>';
00612 }
00613
00614
00615
00616 function print_fiche_titre($titre, $mesg='')
00617 {
00618 print "\n".'<table width="100%" border="0" cellpadding="3" cellspacing="0">';
00619 print '<tr><td><div class="titre" valign="middle">'.$titre.'</div></td>';
00620 if (strlen($mesg))
00621 {
00622 print '<td align="right" valign="middle"><b>'.$mesg.'</b></td>';
00623 }
00624 print '</tr></table>'."\n";
00625 }
00626
00627
00628
00629
00630
00631 function dol_delete_file($file)
00632 {
00633 return unlink($file);
00634 }
00635
00636
00637
00638
00639
00640 function block_access()
00641 {
00642 llxHeader();
00643 print "Accés refusé";
00644 llxFooter();
00645 }
00646
00647
00648
00649
00650
00651
00652 function print_barre_liste($titre, $page, $file, $options='', $sortfield='', $sortorder='', $form='', $num=-1)
00653 {
00654 global $conf;
00655
00656 if ($num > $conf->liste_limit or $num == -1)
00657 {
00658 $nextpage = 1;
00659 }
00660 else
00661 {
00662 $nextpage = 0;
00663 }
00664
00665 print '<table width="100%" border="0" cellpadding="3" cellspacing="0">';
00666
00667 if ($page > 0)
00668 {
00669 print '<tr><td><div class="titre">'.$titre.' - page '.($page+1).'</div></td>';
00670 }
00671 else
00672 {
00673 print '<tr><td><div class="titre">'.$titre.'</div></td>';
00674 }
00675
00676 if ($form)
00677 {
00678 print '<td align="left">'.$form.'</td>';
00679 }
00680
00681 print '<td align="right">';
00682
00683 if (strlen($sortfield))
00684 {
00685 $options .= "&sortfield=$sortfield";
00686 }
00687
00688 if (strlen($sortorder))
00689 {
00690 $options .= "&sortorder=$sortorder";
00691 }
00692
00693
00694
00695 print_fleche_navigation($page,$file,$options, $nextpage);
00696
00697 print '</td></tr></table>';
00698 }
00699
00700
00701
00702
00703
00704 function print_fleche_navigation($page,$file,$options='', $nextpage)
00705 {
00706 global $conf;
00707 if ($page > 0)
00708 {
00709 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>';
00710 }
00711
00712 if ($nextpage > 0)
00713 {
00714 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>';
00715 }
00716 }
00717
00718
00719
00720
00721 function print_oui_non($value)
00722 {
00723 if ($value)
00724 {
00725 print '<option value="0">non';
00726 print '<option value="1" selected>oui';
00727 }
00728 else
00729 {
00730 print '<option value="0" selected>non';
00731 print '<option value="1">oui';
00732 }
00733 }
00734
00735
00736
00737
00738 function print_date_select($set_time='')
00739 {
00740 if (! $set_time)
00741 {
00742 $set_time = time();
00743 }
00744
00745 $strmonth[1] = "Janvier";
00746 $strmonth[2] = "Février";
00747 $strmonth[3] = "Mars";
00748 $strmonth[4] = "Avril";
00749 $strmonth[5] = "Mai";
00750 $strmonth[6] = "Juin";
00751 $strmonth[7] = "Juillet";
00752 $strmonth[8] = "Août";
00753 $strmonth[9] = "Septembre";
00754 $strmonth[10] = "Octobre";
00755 $strmonth[11] = "Novembre";
00756 $strmonth[12] = "Décembre";
00757
00758 $smonth = 1; $endmonth = 12;
00759 $sday = 1; $endday = 31;
00760
00761 $cday = date("d", $set_time);
00762 $cmonth = date("n", $set_time);
00763 $syear = date("Y", $set_time);
00764
00765 print "<select name=\"reday\">";
00766
00767 for ($day = 1 ; $day <= $endday ; $day++)
00768 {
00769 if ($day == $cday)
00770 {
00771 print "<option value=\"$day\" selected>$day";
00772 }
00773 else
00774 {
00775 print "<option value=\"$day\">$day";
00776 }
00777 }
00778
00779 print "</select>";
00780
00781
00782 print "<select name=\"remonth\">";
00783 for ($month = $smonth ; $month <= $endmonth ; $month++)
00784 {
00785 if ($month == $cmonth)
00786 {
00787 print "<option value=\"$month\" selected>" . $strmonth[$month];
00788 }
00789 else
00790 {
00791 print "<option value=\"$month\">" . $strmonth[$month];
00792 }
00793 }
00794 print "</select>";
00795
00796 print "<select name=\"reyear\">";
00797
00798 for ($year = $syear - 2; $year < $syear + 5 ; $year++)
00799 {
00800 if ($year == $syear)
00801 {
00802 print "<option value=\"$year\" SELECTED>$year";
00803 }
00804 else
00805 {
00806 print "<option value=\"$year\">$year";
00807 }
00808 }
00809 print "</select>\n";
00810
00811 }
00812
00813
00814
00815
00816 function print_heure_select($prefix,$begin=1,$end=23) {
00817
00818 print '<select name="'.$prefix.'hour">';
00819 for ($hour = $begin ; $hour <= $end ; $hour++) {
00820 print "<option value=\"$hour\">$hour";
00821 }
00822 print "</select> H ";
00823 print '<select name="'.$prefix.'min">';
00824 for ($min = 0 ; $min < 60 ; $min=$min+5) {
00825 if ($min < 10) {
00826 $min = "0" . $min;
00827 }
00828 print "<option value=\"$min\">$min";
00829 }
00830 print "</select>\n";
00831 }
00832
00833
00834
00835
00836 function print_duree_select($prefix)
00837 {
00838 print '<select name="'.$prefix.'hour">';
00839 print "<option value=\"0\">0";
00840 print "<option value=\"1\" SELECTED>1";
00841
00842 for ($hour = 2 ; $hour < 13 ; $hour++)
00843 {
00844 print "<option value=\"$hour\">$hour";
00845 }
00846 print "</select> H ";
00847 print '<select name="'.$prefix.'min">';
00848 for ($min = 0 ; $min < 55 ; $min=$min+5)
00849 {
00850 print "<option value=\"$min\">$min";
00851 }
00852 print "</select>\n";
00853 }
00854
00855
00856
00857
00858
00859
00860 function price($amount, $html=0)
00861 {
00862 if ($html)
00863 {
00864
00865 $dec='.'; $thousand=' ';
00866 return ereg_replace(' ',' ',number_format($amount, 2, $dec, $thousand));
00867
00868 }
00869 else
00870 {
00871 return number_format($amount, 2, '.', ' ');
00872 }
00873
00874 }
00875
00876 function francs($euros)
00877 {
00878 return price($euros * 6.55957);
00879 }
00880
00881 function tva($euros, $taux=19.6)
00882 {
00883 $taux = $taux / 100 ;
00884
00885 return sprintf("%01.2f",($euros * $taux));
00886 }
00887 function inctva($euros, $taux=1.196)
00888 {
00889 return sprintf("%01.2f",($euros * $taux));
00890 }
00891
00892
00893
00894
00895
00896
00897 function stat_print($basename,$bc1,$bc2,$ftc, $jour) {
00898
00899 $db = pg_Connect("","","","","$basename");
00900 if (!$db) {
00901 echo "Pas de connexion a la base\n";
00902 exit ;
00903 }
00904
00905 $offset = $jour * 9;
00906
00907 $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";
00908
00909 $result = $db->query($sql);
00910 if (!$result) {
00911 print "Erreur SELECT<br><h1>$sql</h1><br>";
00912 return 1;
00913 }
00914
00915 print "<table border=1 cellspacing=0 cellpadding=2>";
00916 print "<tr><td><font color=\"white\">base <b>$basename</b></font></td>";
00917 print "<td><font color=\"white\">libelle</font></td>";
00918 print "</tr>";
00919
00920 $num = $db->num_rows();
00921 $i = 0;
00922
00923 $tag = 1;
00924 while ( $i < $num) {
00925 $obj = $db->fetch_object( $i);
00926
00927 $tag = !$tag;
00928
00929 print "<TR><TD>$obj->date</TD><TD>$obj->libelle</TD>\n";
00930 print "<TD align=\"center\">$obj->nb</TD></TR>\n";
00931 $i++;
00932 }
00933 print "</TABLE>";
00934 $db->free();
00935
00936 $db->close();
00937
00938 }
00939
00940 function tab_count($basename,$bc1,$bc2,$ftc) {
00941
00942 $db = pg_Connect("","","","","$basename");
00943 if (!$db) {
00944 echo "Pas de connexion a la base\n";
00945 exit ;
00946 }
00947
00948 $sql="SELECT count(*) AS nbcv from candidat WHERE active=1";
00949 $result = $db->query($sql);
00950 if (!$result) {
00951 print "Erreur SELECT<br><h1>$sql</h1><br>";
00952 return 1;
00953 }
00954 print "<table border=0 bgcolor=black cellspacing=0 cellpadding=0><tr><td>";
00955
00956 print "<table border=0 cellspacing=1 cellpadding=1>";
00957 print "<tr><td><font color=\"white\">base <b>$basename</b></font></td>";
00958 print "<td><font color=\"white\">libelle</font></td>";
00959 print "</tr>";
00960 $nbcv = $db->result( $i, "nbcv");
00961
00962 print "<tr $bc1><td><b>$ftc Nombre de CV</font></b></td>\n";
00963 print "<td align=\"center\">$ftc $nbcv</td>\n";
00964 print "</tr>\n";
00965 $db->free();
00966
00967 $sql="SELECT count(*) AS nbcv from offre WHERE active=1";
00968
00969 $result = $db->query($sql);
00970 if (!$result) {
00971 print "Erreur SELECT<br><h1>$sql</h1><br>";
00972 }
00973 $nbcv = $db->result( $i, "nbcv");
00974
00975 print "<tr $bc2><td><b>$ftc Nombre d'offre</font></b></td>";
00976 print "<td align=\"center\">$ftc $nbcv</td>";
00977 print "</tr>";
00978
00979 $db->free();
00980
00981
00982 $sql="SELECT count(*) AS nbcv from candidat WHERE active=0";
00983
00984 $result = $db->query($sql);
00985 if (!$result) {
00986 print "Erreur SELECT<br><h1>$sql</h1><br>";
00987 }
00988
00989 $nbcv = $db->result( $i, "nbcv");
00990
00991 print "<tr $bc1><td><b>$ftc Nombre de CV inactifs</font></b></td>\n";
00992 print "<td align=\"center\">$ftc $nbcv</td>";
00993 print "</tr>";
00994
00995 $db->free();
00996
00997
00998 $sql="SELECT count(*) AS nbcv from offre WHERE active=0";
00999
01000 $result = $db->query($sql);
01001 if (!$result) {
01002 print "Erreur SELECT<br><h1>$sql</h1><br>";
01003 }
01004
01005 $nbcv = $db->result( $i, "nbcv");
01006
01007 print "<tr $bc2><td><b>$ftc Nombre d'offres inactives</font></b></td>\n";
01008 print "<td align=\"center\">$ftc $nbcv</td>\n";
01009 print "</tr>\n";
01010
01011 $db->free();
01012
01013 $sql="SELECT count(*) AS nbsoc from logsoc";
01014
01015 $result = $db->query($sql);
01016 if (!$result) {
01017 print "Erreur SELECT<br><h1>$sql</h1><br>";
01018 }
01019
01020 $nbsoc = $db->result( $i, "nbsoc");
01021
01022 print "<tr $bc1><td><b>$ftc Nombre de logins societes</font></b></td>\n";
01023 print "<td align=\"center\">$ftc $nbsoc</td>";
01024 print "</tr>";
01025
01026 print "</td></tr></table></td></tr></table>";
01027
01028 $db->close();
01029
01030 }
01031
01032
01033
01034
01035
01036
01037 function logfile($str,$log="/var/log/dolibarr/dolibarr.log")
01038 {
01039 if (defined("MAIN_DEBUG") && MAIN_DEBUG ==1)
01040 {
01041 if (!file_exists($log))
01042 {
01043 if (!$file=fopen($log,"w"))
01044 {
01045 return 0;
01046 }
01047 }
01048 else
01049 {
01050 if (!$file=fopen($log,"a+"))
01051 {
01052 return 0;
01053 }
01054 }
01055 $logentry=date("[d/M/Y:H:i:s] ").$str."\n";
01056 if(!fwrite($file,$logentry)) {
01057 fclose($file);
01058 return 0;
01059 }
01060 fclose($file);
01061 return 1;
01062 }
01063 }
01064
01065
01066
01067
01068
01069 function creer_pass_aleatoire($longueur = 8, $sel = "") {
01070 $seed = (double) (microtime() + 1) * time();
01071 srand($seed);
01072
01073 for ($i = 0; $i < $longueur; $i++) {
01074 if (!$s) {
01075 if (!$s) $s = rand();
01076 $s = substr(md5(uniqid($s).$sel), 0, 16);
01077 }
01078 $r = unpack("Cr", pack("H2", $s.$s));
01079 $x = $r['r'] & 63;
01080 if ($x < 10) $x = chr($x + 48);
01081 else if ($x < 36) $x = chr($x + 55);
01082 else if ($x < 62) $x = chr($x + 61);
01083 else if ($x == 63) $x = '/';
01084 else $x = '.';
01085 $pass .= $x;
01086 $s = substr($s, 2);
01087 }
01088 return $pass;
01089 }
01090
01091
01092
01093
01094
01095
01096 function initialiser_sel() {
01097 global $htsalt;
01098
01099 $htsalt = '$1$'.creer_pass_aleatoire();
01100 }
01101
01102 ?>
Généré le Thu Jul 15 14:51:57 2004 pour dolibarr par
1.3.7