PageRenderTime 53ms CodeModel.GetById 10ms RepoModel.GetById 1ms app.codeStats 0ms

/libs/functions.php

https://github.com/zpartakov/pmCake
PHP | 2209 lines | 1638 code | 245 blank | 326 comment | 139 complexity | 07ac715af6e346acbdce96ff991beda8 MD5 | raw file
Possible License(s): LGPL-3.0, GPL-3.0

Large files files are truncated, but you can click here to view the full file

  1. <?php
  2. /*
  3. * all the external cakePHP functions for pmcake
  4. *
  5. * fonction principale: print_tasks
  6. */
  7. ####### PROJECTS ##########
  8. function temps_moyen_booking($pid,$cherche) {
  9. $sql2="
  10. SELECT SUM(hours) AS hours, COUNT(id) AS tasks
  11. FROM pm_tasks_time
  12. WHERE pm_tasks_time.task
  13. IN
  14. (
  15. SELECT id FROM pm_tasks
  16. WHERE project=32
  17. AND pm_tasks.name LIKE 'idBooking%'
  18. ) ";
  19. // echo $sql2;
  20. #echo mysql_result($sql,$i,'hours');
  21. $sql2=mysql_query($sql2);
  22. $hours=mysql_result($sql2,0,'hours');
  23. $sql3=" SELECT COUNT(id) AS tasks FROM pm_tasks WHERE project=32 AND pm_tasks.name LIKE '".$cherche."%'";
  24. $sql3=mysql_query($sql3);
  25. $tasks=mysql_result($sql3,0,'tasks');
  26. echo "<br>Total heures pour ce type de demande: " .$hours ." pour: #" .$tasks ." demandes";
  27. echo "<br>Moyenne heures pour ce type de demande: " .intval($hours/$tasks) ." heures";
  28. }
  29. function temps_moyen_lime($pid,$cherche) {
  30. $sql2="
  31. SELECT SUM(hours) AS hours, COUNT(id) AS tasks
  32. FROM pm_tasks_time
  33. WHERE pm_tasks_time.task
  34. IN
  35. (
  36. SELECT id FROM pm_tasks
  37. WHERE project=36
  38. ) ";
  39. // echo $sql2;
  40. #echo mysql_result($sql,$i,'hours');
  41. $sql2=mysql_query($sql2);
  42. $hours=mysql_result($sql2,0,'hours');
  43. $sql3=" SELECT COUNT(id) AS tasks FROM pm_tasks WHERE project=36 AND pm_tasks.name LIKE '".$cherche."%'";
  44. $sql3=mysql_query($sql3);
  45. $tasks=mysql_result($sql3,0,'tasks');
  46. echo "<br>Total heures pour ce type de demande: " .$hours ." pour: #" .$tasks ." demandes";
  47. echo "<br>Moyenne heures pour ce type de demande: " .intval($hours/$tasks) ." heures";
  48. }
  49. function temps_moyen($pid,$cherche) {
  50. $sql2="
  51. SELECT SUM(hours) AS hours, COUNT(id) AS tasks
  52. FROM pm_tasks_time
  53. WHERE pm_tasks_time.task
  54. IN
  55. (
  56. SELECT id FROM pm_tasks
  57. WHERE project=" .$pid ."
  58. ) ";
  59. // echo $sql2;
  60. #echo mysql_result($sql,$i,'hours');
  61. $sql2=mysql_query($sql2);
  62. $hours=mysql_result($sql2,0,'hours');
  63. $sql3=" SELECT COUNT(id) AS tasks FROM pm_tasks WHERE project=" .$pid ." AND pm_tasks.name LIKE '".$cherche."%'";
  64. $sql3=mysql_query($sql3);
  65. $tasks=mysql_result($sql3,0,'tasks');
  66. echo "<br>Total heures pour ce type de demande: " .$hours ." pour: #" .$tasks ." demandes";
  67. echo "<br>Moyenne heures pour ce type de demande: " .intval($hours/$tasks) ." heures";
  68. }
  69. function Total_heures($pid) {
  70. $sql2="
  71. SELECT SUM(hours) AS hours FROM pm_tasks_time WHERE pm_tasks_time.task IN (SELECT id FROM pm_tasks WHERE project=" .$pid .") ";
  72. //echo $sql2;
  73. #echo mysql_result($sql,$i,'hours');
  74. $sql2=mysql_query($sql2);
  75. $hours=mysql_result($sql2,0,'hours');
  76. echo $hours;
  77. }
  78. /* show tasks for current project */
  79. function project_tasks_show($plib,$pid,$order,$statut,$operator,$anchor) {
  80. $sql="SELECT * FROM pm_tasks WHERE project=".$pid;
  81. /*tâche statut priorité début délai milestone heures ok Actions*/
  82. $sql="SELECT `id`, `priority`, `status`, `name`, `start_date`,`due_date`,`milestone` FROM `pm_tasks` WHERE project=".$pid;
  83. if($_GET['statut']) {$statut = $_GET['statut'];}
  84. $statut = " AND status" .$operator .$statut;
  85. $sql.=$statut;
  86. $sql.= " ORDER BY " .$order;
  87. #echo $sql;
  88. $sql=mysql_query($sql);
  89. if(!$sql) { echo "SQL error: " .mysql_error(); }
  90. echo ' <a name="'.$anchor .'"></a>
  91. <div class="pmTasks index" style="background-color: #F1CB84; padding-bottom: 13px;">
  92. <a name="taches"></a><h2>';
  93. echo $plib;
  94. echo " (".mysql_num_rows($sql) .") ";
  95. echo '<a href="/intranet/pmcake/pm_tasks/add"><img src="/intranet/pmcake/img/toolbar/add.png" alt="Ajouter" title="Ajouter" /></a>';
  96. //e($html->link($html->image('toolbar/add.png', array('alt' => 'Ajouter', 'title' => 'Ajouter')), array('controller' => 'pm_tasks', 'action'=>'add'), array('escape' => false)));
  97. echo '
  98. </h2>
  99. <table>
  100. <tr>
  101. <th>tâche</th>
  102. <th>statut</th>
  103. <th>priorité</th>
  104. <th>début</th>
  105. <th>délai</th>
  106. <th>milestone</th>
  107. <th>heures</th>
  108. <th>ok</th>
  109. <th class="actions" colspan="2">Actions</th>
  110. </tr>
  111. ';
  112. $i=0;
  113. while($i<mysql_num_rows($sql)){
  114. $class = null;
  115. if (intval($i/2) == ($i/2)) {
  116. $class = ' class="altrow"';
  117. }
  118. echo ' <tr' .$class .'>
  119. <td>';
  120. //echo $this->Html->link(mysql_result($sql,$i,'name'), array('controller' => 'pm_tasks', 'action' => 'view', mysql_result($sql,$i,'id')));
  121. #echo '<a href="/intranet/pmcake/pm_tasks/view/' .mysql_result($sql,$i,'id') .'">' .mysql_result($sql,$i,'name') .'</a>';
  122. echo '<a href="' .CHEMIN .'pm_tasks/edit/'.mysql_result($sql,$i,'id').'" class="tooltip">'.mysql_result($sql,$i,'name');
  123. /*
  124. if(strlen( mysql_result($sql,$i,'description'))>0) {
  125. echo '<em><span></span>'.nl2br(mysql_result($sql,$i,'description')).'</em>';
  126. }*/
  127. echo '</a>';
  128. echo '</td>
  129. <td>';
  130. statut(mysql_result($sql,$i,'status'));
  131. echo ' </td>
  132. <td>';
  133. prioriteView( mysql_result($sql,$i,'priority'));
  134. echo '&nbsp;</td>
  135. <td>';
  136. echo mysql_result($sql,$i,'start_date');
  137. echo '&nbsp;</td>
  138. <td>';
  139. echo mysql_result($sql,$i,'due_date');
  140. echo '&nbsp;</td>
  141. <td>';
  142. echo mysql_result($sql,$i,'milestone');
  143. echo '&nbsp;</td>
  144. <td>';
  145. total_hours_task(mysql_result($sql,$i,'id'));
  146. echo '</td>
  147. <td class="oktask">
  148. <!-- ############ task ok ######### -->
  149. &#x2714;<input type="checkbox" title="OK?" onChange="task_ok(';
  150. echo mysql_result($sql,$i,'id');
  151. echo ',this.value)">
  152. <!-- http://fr.wikipedia.org/wiki/Coche_%28typographie%29 -->
  153. </td>
  154. <td class="actions">
  155. <!-- ################ PUSH DELAYS ################ -->
  156. <form action="repousser" method="GET" name="';
  157. echo mysql_result($sql,$i,'id');
  158. echo '">
  159. <input type="hidden" name="identifiant" value="';
  160. echo mysql_result($sql,$i,'id');
  161. echo '">
  162. <input type="image" src="/pmcake/img/icons/bullet_arrow.gif" alt="Déplacer à demain" title="Déplacer à demain" name="demain" value="demain">
  163. <select name="ajout" class="micro" size="1" onChange="task_goto_URL(';
  164. echo mysql_result($sql,$i,'id');
  165. echo ',this.value)">';
  166. delais();
  167. echo '</select>';
  168. $idaction=mysql_result($sql,$i,'id');
  169. les_actions($idaction);
  170. echo ' </form>
  171. </td>
  172. </tr>';
  173. $i++;
  174. }
  175. echo ' </table>
  176. </div>
  177. ';
  178. }
  179. /*function to get a scrolling list of projets and highlight the current project if exists*/
  180. function projets_sel($pid) {
  181. $sql="SELECT id, name, type FROM pm_projects ORDER BY name";
  182. #do and check sql
  183. $sql=mysql_query($sql);
  184. if(!$sql) {
  185. echo "SQL error: " .mysql_error(); exit;
  186. }
  187. $i=0;
  188. echo "<option value=''>### projet ###" ."</option>";
  189. while($i<mysql_num_rows($sql)){
  190. if(mysql_result($sql,$i,'type')=="p") {
  191. $css="projet_sel_perso";
  192. } else {
  193. $css="projet_sel";
  194. }
  195. echo "<option class=\"" .$css ."\" value=\"" .mysql_result($sql,$i,'id') ."\"";
  196. if($pid==mysql_result($sql,$i,'id')){
  197. echo " selected";
  198. }
  199. echo ">" .mysql_result($sql,$i,'name') ."</option>";
  200. $i++;
  201. }
  202. }
  203. /*function to print the name of a given project*/
  204. function projet_nom_print($pid) {
  205. $sql="SELECT name FROM pm_projects WHERE id=".$pid;
  206. #do and check sql
  207. $sql=mysql_query($sql);
  208. if(!$sql) {
  209. echo "SQL error: " .mysql_error(); exit;
  210. }
  211. echo "<a href=\"" .CHEMIN. "pm_projects/view/" .$pid ."\">";
  212. echo mysql_result($sql,0,'name');
  213. echo "</a>";
  214. }
  215. /*function to return the name of a given project*/
  216. function projet_nom_return($pid) {
  217. $sql="SELECT name FROM pm_projects WHERE id=".$pid;
  218. #do and check sql
  219. $sql=mysql_query($sql);
  220. if(!$sql) {
  221. echo "SQL error: " .mysql_error(); exit;
  222. }
  223. return utf8_encode(mysql_result($sql,0,'name'));
  224. }
  225. /*function to get a scrolling list of projets and highlight the current project if exists*/
  226. function statut_sel($statut) {
  227. $statuts=array(
  228. "Complet (client)",
  229. "Complet",
  230. "Non commencé",
  231. "Ouvert",
  232. "Suspendu",
  233. "En attente",
  234. "Délégué",
  235. "",
  236. "",
  237. "",
  238. "",
  239. "",
  240. "",
  241. "",
  242. "",
  243. "",
  244. "",
  245. "Incubateur",
  246. "",
  247. "",
  248. "",
  249. "",
  250. "Références"
  251. );
  252. for($i=0;$i<23;$i++) {
  253. $zestatut=$statuts[$i];
  254. if(strlen($zestatut)>1) {
  255. echo "<option value=\"" .$i ."\"";
  256. if($statut==$i){
  257. echo " selected";
  258. }
  259. echo ">" .$zestatut ."</option>";
  260. }
  261. }
  262. }
  263. /*function to get a scrolling list of projets and highlight the current project if exists*/
  264. function statut_radio($id,$statut) {
  265. $statuts=array(
  266. "Complet (client)",
  267. "Complet",
  268. "Non commencé",
  269. "Ouvert",
  270. "Suspendu",
  271. "En attente",
  272. "Délégué",
  273. "",
  274. "",
  275. "",
  276. "",
  277. "",
  278. "",
  279. "",
  280. "",
  281. "",
  282. "",
  283. "Incubateur",
  284. "",
  285. "",
  286. "",
  287. "",
  288. "Références"
  289. );
  290. for($i=0;$i<count($statuts);$i++) {
  291. $zestatut=$statuts[$i];
  292. if(strlen($zestatut)>1&&$zestatut!="Complet (client)") {
  293. echo "<span>
  294. <input type=\"radio\" name=\"radiovalue\" value=\"" .$i ."\"";
  295. echo " onChange=\"task_change_status(".$id.",".$i.")\"";
  296. if($statut==$i){
  297. echo " checked";
  298. }
  299. echo " / >&nbsp;" .$zestatut;
  300. echo "</span>";
  301. }
  302. }
  303. }
  304. /* function to extract specified status */
  305. function statut($id) {
  306. $statut=""; $lestyle="";
  307. if($id==0) {
  308. $statut="Complet (client)";
  309. }elseif($id==1) {
  310. $statut="Complet";
  311. }elseif($id==2) {
  312. $statut="Non commencé";
  313. }elseif($id==3) {
  314. $statut="Ouvert";
  315. }elseif($id==4) {
  316. $statut="Suspendu";
  317. }elseif($id==5) {
  318. }elseif($id==6) {
  319. }elseif($id==7) {
  320. }elseif($id==17) { //café papo 17
  321. $statut="Incubateur"; //dreams, boîte à idées
  322. $lestyle='" style="width: 20px"';
  323. }elseif($id==22) { //22 vla les flics
  324. $statut="Références"; //references
  325. $lestyle='" style="width: 30px"';
  326. }
  327. echo '<img src="/pmcake/img/gfx_status/' .$id .'.gif" alt="' .$statut .'" title="' .$statut .'" ' .$lestyle .' />';
  328. }
  329. /* function to return specified status */
  330. function statutreturn($id) {
  331. $statut=""; $lestyle="";
  332. if($id==0) {
  333. $statut="Complet (client)";
  334. }elseif($id==1) {
  335. $statut="Complet";
  336. }elseif($id==2) {
  337. $statut="Non commencé";
  338. }elseif($id==3) {
  339. $statut="Ouvert";
  340. }elseif($id==4) {
  341. $statut="Suspendu";
  342. }elseif($id==5) {
  343. }elseif($id==6) {
  344. }elseif($id==7) {
  345. }elseif($id==17) { //café papo 17
  346. $statut="Incubateur"; //dreams, boîte à idées
  347. $lestyle='" style="width: 20px"';
  348. }elseif($id==22) { //22 vla les flics
  349. $statut="Références"; //references
  350. $lestyle='" style="width: 20px"';
  351. }
  352. return '<img src="/pmcake/img/gfx_status/' .$id .'.gif" alt="' .$statut .'" title="' .$statut .'" ' .$lestyle .' />';
  353. }
  354. ####### TASKS #########
  355. /*function to get a scrolling list of tasks and select the current task if exists*/
  356. function tasks_sel($tid) {
  357. $sql="SELECT id, name FROM pm_tasks ORDER BY name";
  358. #do and check sql
  359. $sql=mysql_query($sql);
  360. if(!$sql) {
  361. echo "SQL error: " .mysql_error(); exit;
  362. }
  363. $i=0;
  364. while($i<mysql_num_rows($sql)){
  365. echo "<option value=\"" .mysql_result($sql,$i,'id') ."\"";
  366. if($tid==mysql_result($sql,$i,'id')){
  367. echo " selected";
  368. }
  369. echo ">" .mysql_result($sql,$i,'name') ."</option>";
  370. $i++;
  371. }
  372. }
  373. function completion($completion) {
  374. $pourcent=array(0,10,20,30,40,50,60,70,80,90,100);
  375. for($i=0;$i<11;$i++) {
  376. echo "<option value=\"" .$pourcent[$i] ."\"";
  377. if($i==$completion) {
  378. echo " selected";
  379. }
  380. echo ">" .$pourcent[$i] ."%</option>";
  381. }
  382. }
  383. function priorite($priorite) {
  384. $prioritelib=array("Vide","Très faible","Faible","Moyenne","Elevée","Très élevée");
  385. $prioritecolor=array( "white", "#00FF00", "#90EE90" ,"#FFA500" ,"#FFC0CB","#FF6C7F");
  386. for($i=0;$i<6;$i++) {
  387. echo "<option value=\"" .$i ."\"";
  388. if($i==$priorite) {
  389. echo " selected";
  390. }
  391. echo " style=\"background-color: " .$prioritecolor[$i] ."\"";
  392. echo ">" .$prioritelib[$i] ."</option>";
  393. }
  394. }
  395. function prioritehighlight($priorite) {
  396. $prioritelib=array("Vide","Très faible","Faible","Moyenne","Elevée","Très élevée");
  397. $prioritecolor=array( "white","#00FF00" , "#90EE90" ,"#FFA500" ,"#FFC0CB","#FF6C7F");
  398. echo "<div style=\"background-color: " .$prioritecolor[$priorite] ."\">";
  399. }
  400. function prioriteView($i) {
  401. $prioritelib=array("Vide","Très faible","Faible","Moyenne","Elevée","Très élevée");
  402. $prioritecolor=array( "white","#00FF00" , "#90EE90" ,"#FFA500" ,"#FFC0CB","#FF6C7F");
  403. echo "<span style=\"background-color: " .$prioritecolor[$i] ."\">" .$prioritelib[$i] ."</span>";
  404. }
  405. /*
  406. * change priority of a given task
  407. */
  408. function prioriteViewSelCol($priorite,$idtask) {
  409. $prioritelib=array("Vide","Très faible","Faible","Moyenne","Elevée","Très élevée");
  410. $prioritecolor=array( "white", "#00FF00", "#90EE90" ,"#FFA500" ,"#FFC0CB","#FF6C7F");
  411. echo "<div id=\"priorite" .$idtask ."\" style=\"padding: 3px; background-color:" .$prioritecolor[$priorite] ."\">";
  412. echo "<select id=\"PmTaskPriority\" name=\"data[PmTask][priority]\" ";
  413. //echo "size=\"6\"";
  414. //echo " onchange=\"change_priorite(".$idtask .",this.value)\">";
  415. echo ">";
  416. echo "<option value=\"\">*** priorité *** </option>";
  417. for($i=0;$i<6;$i++) {
  418. echo "<option value=\"" .$i ."\"";
  419. echo " style=\"background-color: " .$prioritecolor[$i] ."\"";
  420. if($i==$priorite) {
  421. echo " selected";
  422. } echo ">";
  423. echo $prioritelib[$i] ."</option>";
  424. }
  425. echo "</select></div>";
  426. }
  427. /*function to print the name of a given task*/
  428. function task_nom_print($pid) {
  429. $sql="SELECT name FROM pm_tasks WHERE id=".$pid;
  430. #do and check sql
  431. $sql=mysql_query($sql);
  432. if(!$sql) {
  433. echo "SQL error: " .mysql_error(); exit;
  434. }
  435. echo "<a href=\"" .CHEMIN. "pm_tasks/view/" .$pid ."\">";
  436. echo mysql_result($sql,0,'name');
  437. echo "</a>";
  438. }
  439. /*time spent on a task*/
  440. function total_hours_task($task_id) {
  441. $sql2="
  442. SELECT SUM(hours) AS hours FROM pm_tasks_time
  443. WHERE task=" .$task_id;
  444. #echo $sql2;
  445. #echo mysql_result($sql,$i,'hours');
  446. $sql2=mysql_query($sql2);
  447. $hours=mysql_result($sql2,0,'hours');
  448. echo $hours;
  449. $sql2="
  450. SELECT date, sum(hours) AS hours FROM pm_tasks_time
  451. WHERE task=" .$task_id ."
  452. GROUP BY date";
  453. echo "&nbsp;<a href=\"javascript:showdetailtaskhours()\">Détail</a><p><div id=\"showdetailtaskhours\" style=\"display: none\">Détail heures:<br/>";
  454. #echo $sql2;
  455. #echo mysql_result($sql,$i,'hours');
  456. $sql2=mysql_query($sql2);
  457. $i=0;
  458. while($i<mysql_num_rows($sql2)) {
  459. $hours=mysql_result($sql2,$i,'hours');
  460. dateSQL2frSmall(mysql_result($sql2,$i,'date'));
  461. echo ", " .$hours;
  462. echo "<br/>";
  463. $i++;
  464. }
  465. echo "</div></p>";
  466. }
  467. #############################################################################
  468. /*
  469. * function random list of tasks (todos, wishlist, reference) for home suggestions
  470. */
  471. function random_list_todos($nrandom,$prof_or_private) {
  472. /*
  473. * $prof_or_private
  474. * private: proj.type =='p'
  475. */
  476. if($prof_or_private=='p'){
  477. $prof_or_private=" LIKE '".$prof_or_private."'";
  478. $private="privé";
  479. $p="p";
  480. } else {
  481. $prof_or_private=" NOT LIKE 'p'";
  482. $private="prof.";
  483. $p="";
  484. }
  485. echo "
  486. <style>
  487. li {
  488. margin-bottom: 3px;
  489. }
  490. </style>
  491. <div class=\"random_list_todos\"><a name=\"random_list_todos".$p."\"></a>";
  492. //echo $this->html->image('dices0.png');
  493. echo "<h2><img style=\"padding-top: 4px; padding-left: 6px; padding-right: 10px; width: 20px; height: 20px\" src=\"/intranet/pmcake/img/dices0.png\" alt=\"" .$nrandom ." tâches aléatoires\">";
  494. echo "Liste aléatoire de #" .$nrandom." tâches/idées (".$private .")</h2>";
  495. $sql="
  496. SELECT * FROM pm_tasks AS tas, pm_projects as proj
  497. WHERE tas.status > 1
  498. AND tas.status < 22
  499. AND tas.due_date <> '--'
  500. AND tas.project=proj.id
  501. AND proj.type ".$prof_or_private ."
  502. ORDER BY RAND()
  503. LIMIT " .$nrandom;
  504. //echo $sql;
  505. $sql=mysql_query($sql);
  506. if(!$sql) {
  507. echo "SQL error: " .mysql_error(); exit;
  508. }
  509. /* todo: sort by due_date, not finished, begin */
  510. while ($row = mysql_fetch_array($sql, MYSQL_NUM)) {
  511. $all_data[] = $row;
  512. }
  513. // $all_data is now a 2-D array with all your data.
  514. usort($all_data, "due_date");
  515. /*
  516. echo "<pre>";
  517. print_r($all_data);
  518. echo "</pre>";
  519. exit;
  520. */
  521. /* todo: sort by due_date, not finished, end */
  522. $i=0;
  523. $i=0;$lesid="";
  524. echo "<table>";
  525. echo "<tr><th>Statut</th><th>Libellé</th><th>Projet</th><th>Délai</th><th>Début</th></tr>";
  526. while($i<mysql_num_rows($sql)){
  527. $class = null;
  528. if (intval($i/2) == ($i/2)) {
  529. $class = ' class="altrow"';
  530. }
  531. if(mysql_result($sql,$i,'status')==5 ) {
  532. /* special classes for statuts wait */
  533. $class = ' class="wait"';
  534. }
  535. echo "<tr" .$class ."><td>";
  536. if(mysql_result($sql,$i,'proj.type')=="p") {
  537. perso_list();
  538. }
  539. echo "&nbsp;";
  540. statut(mysql_result($sql,$i,'status'));
  541. echo "</td><td>";
  542. echo ' <a href="' .CHEMIN .'pm_tasks/edit/'.mysql_result($sql,$i,'id').'" class="tooltip">'.mysql_result($sql,$i,'name');
  543. if(strlen( mysql_result($sql,$i,'description'))>0) {
  544. echo '<em><span></span>'.nl2br(mysql_result($sql,$i,'description')).'</em>';
  545. }
  546. echo '</a>';
  547. echo "</td><td>";
  548. echo '<a href="/intranet/pmcake/pm_projects/view/'.mysql_result($sql,$i,'proj.id').'">'.mysql_result($sql,$i,'proj.name').'</a>';
  549. echo "</td><td>";
  550. dateSQL2fr(mysql_result($sql,$i,'due_date'));
  551. echo "</td><td>";
  552. echo "<em style=\"font-size: smaller\">(";
  553. dateSQL2frSmall(mysql_result($sql,$i,'start_date'));
  554. echo ")</em> ";
  555. echo "</td></tr>";
  556. $i++;
  557. }
  558. echo "</table>";
  559. echo "</div>";
  560. }
  561. /* MAIN function to extract the list of current tasks for a given category / period */
  562. function print_tasks($catlib,$quand) {
  563. $datenow=date("Y-m-d");
  564. /*
  565. * is the task private or not?
  566. */
  567. if($catlib=="prof") {
  568. $projtyp=" AND proj.type !='p'";
  569. } elseif($catlib=="perso") {
  570. $projtyp=" AND proj.type ='p'";
  571. }
  572. /*
  573. * when
  574. */
  575. if($quand=="auj") {
  576. $quandSQL=" AND (tas.due_date <= '".date("Y-m-d")."'";
  577. }elseif($quand=="demain") {
  578. $quandSQL=" AND (tas.due_date <= DATE_ADD('$datenow', INTERVAL 1 DAY) AND (tas.due_date > '$datenow') ";
  579. }
  580. /*
  581. * is it a task, a dream or a reference?
  582. */
  583. $taskstatus="< 17";
  584. if($catlib=="dreams") {
  585. $taskstatus="= 17";
  586. }
  587. if($catlib=="ref") {
  588. $taskstatus="= 22";
  589. }
  590. /*
  591. * sorting list
  592. */
  593. $ordertask=" ORDER BY tas.priority DESC, tas.status ASC, tas.due_date ASC";
  594. /*
  595. * present tasks
  596. */
  597. global $sql, $idc;
  598. $sql="
  599. SELECT * FROM pm_tasks AS tas, pm_projects as proj
  600. WHERE tas.status > 1
  601. AND tas.status " .$taskstatus . $quandSQL
  602. ." AND tas.due_date <> '--')
  603. AND tas.project=proj.id " .$projtyp .$ordertask;
  604. /*
  605. * future tasks
  606. */
  607. if($quand=="futur") {
  608. $sql="
  609. SELECT * FROM pm_tasks AS tas, pm_projects as proj
  610. WHERE tas.status > 1
  611. AND tas.status < 17
  612. AND (tas.due_date > DATE_ADD('".$datenow."', INTERVAL 1 DAY)) AND tas.due_date <> '--'
  613. AND tas.project=proj.id " .$ordertask ."
  614. LIMIT 0, 30";
  615. }
  616. /*
  617. * tests: show sql query; uncomment for debug
  618. */
  619. # echo nl2br($sql)."<br>"; //tests
  620. /*
  621. * run sql query
  622. */
  623. $sql=mysql_query($sql);
  624. if(!$sql) {
  625. echo "SQL error: " .mysql_error(); exit;
  626. }
  627. $i=0;
  628. /*
  629. * display main category
  630. */
  631. echo '<div id="' .$catlib .'"><h2><a name="' .$catlib .'"></a>'. ucfirst($catlib) .'</h2><form id="'.$catlib.'">';
  632. /*
  633. * some special css classes to hide/show
  634. */
  635. /*
  636. * tomorrow tasks
  637. */
  638. if($quand=="demain") {
  639. echo '<small><a onclick="montrecache1();"><img src="/intranet/pmcake/img/icons/open_tab.gif"></a></small>
  640. <div id="tomorrowContainer" style="display: none;">';
  641. /*
  642. * future tasks
  643. */
  644. }elseif($quand=="futur") {
  645. #echo '<div id="clickme2" style="display: block; position: relative; top: 18px; right: 20px;"><small><a onclick="montrecache2();"><img src="/intranet/pmcake/img/icons/open_tab.gif"></a></small></div><div id="futureContainer" style="display: none;">';
  646. echo '<small><a onclick="montrecache2();"><img src="/intranet/pmcake/img/icons/open_tab.gif"></a></small>
  647. <div id="futureContainer" style="display: none;">';
  648. }
  649. /*
  650. * total on field tasks + headers of the table
  651. */
  652. echo '<h3>Total tâches en cours: #'.mysql_num_rows($sql).'</h3>
  653. <table cellpadding="0" cellspacing="0">
  654. <tr>
  655. <th>project</th>
  656. <th>priority</th>
  657. <th>status</th>
  658. <!-- <th>owner</th>-->
  659. <th>name</th>
  660. <th>due_date</th>
  661. <th>milestone</th>
  662. <th class="actions" colspan="2">Actions
  663. </th>
  664. </tr>
  665. ';
  666. /*
  667. * loop on results
  668. */
  669. $i=0;$lesid="";
  670. while($i<mysql_num_rows($sql)){
  671. $idc=mysql_result($sql,$i,'id');
  672. $class = null;
  673. if (intval($i/2) == ($i/2)) {
  674. $class = ' class="altrow"';
  675. }
  676. if(mysql_result($sql,$i,'status')==5 ) {
  677. /* special classes for statuts wait */
  678. $class = ' class="wait"';
  679. }
  680. echo "<tr" .$class;
  681. echo " id=\"tr" .mysql_result($sql,$i,'id')."\"";
  682. echo ">";
  683. //experimental not working (select all and apply a common action
  684. #echo '<input id="User1Id" class="model_id" type="checkbox" value="1" name="data[User][1][id]">';
  685. // <input id="PmTask' .mysql_result($sql,$i,'id').'" class="cb-element" type="checkbox" value="' .mysql_result($sql,$i,'id').'" name="data[PmTask][' .mysql_result($sql,$i,'id').'][id]"></td>';
  686. echo "<td>";
  687. echo '<input type="checkbox" name="checkboxlist" value="'.mysql_result($sql,$i,'id').'" />';
  688. if(mysql_result($sql,$i,'proj.type')=="p") {
  689. perso_list();
  690. }
  691. echo '<a href="/intranet/pmcake/pm_projects/view/'.mysql_result($sql,$i,'proj.id').'">'.mysql_result($sql,$i,'proj.name').'</a>';
  692. echo "</td>";
  693. echo "<td>";
  694. //prioriteView(mysql_result($sql,$i,'priority'));
  695. prioriteView(mysql_result($sql,$i,'priority'), mysql_result($sql,$i,'id'));
  696. echo "</td>";
  697. echo "<td>";
  698. statut(mysql_result($sql,$i,'status'));
  699. echo "</td>";
  700. /*
  701. * affiche titre de la tâche
  702. */
  703. //original
  704. //echo '<td><a href="' .CHEMIN .'pm_tasks/edit/'.mysql_result($sql,$i,'id').'" class="tooltip">'.mysql_result($sql,$i,'name');
  705. //echo '<td><a href="' .CHEMIN .'pm_tasks/edit/'.mysql_result($sql,$i,'id').'" class="tooltip"><div class="taskedit">'.mysql_result($sql,$i,'name')."</div>";
  706. //test
  707. echo '<td>';
  708. echo '<a href="#" class="tooltip">';
  709. /*
  710. * dynamic ajax edit frontend see webroot/js/jquery.jeditable.example.js
  711. */
  712. echo '<div class="task" id="'.mysql_result($sql,$i,'id').'" onclick="cachedetails('.mysql_result($sql,$i,'id').')">'.mysql_result($sql,$i,'name');
  713. echo "</div>";
  714. /* affiche description, si elle existe */
  715. if(strlen( mysql_result($sql,$i,'description'))>0) {
  716. echo '<div id="detailstache'.mysql_result($sql,$i,'id').'"><em><span></span>'.nl2br(mysql_result($sql,$i,'description')).'</em></div>';
  717. }
  718. echo '</a>';
  719. echo "</td>";
  720. echo "<td>";
  721. echo '<a href="/intranet/pmcake/pm_tasks/edit/' .$idc .'" alt="Modifier" title="Modifier"><img src="/intranet/pmcake/img/toolbar/editor.png" alt="Modifier" /></a>';
  722. echo "&nbsp;";
  723. dateSQL2fr(mysql_result($sql,$i,'due_date'));
  724. echo "<br /><em style=\"font-size: smaller\">(";
  725. dateSQL2frSmall(mysql_result($sql,$i,'start_date'));
  726. echo ")</em> ";
  727. echo "</td>";
  728. echo "<td>" .mysql_result($sql,$i,'milestone') ."</td>";
  729. /*
  730. * add time to task £
  731. */
  732. echo ' <td>
  733. <form name="ajoutheure" action="/intranet/pmcake/pm_tasks_times/ajoutheure">
  734. <input type="hidden" name="projectid" value="'.mysql_result($sql,$i,'proj.id') .'">
  735. <input type="hidden" name="idtache" value="'.mysql_result($sql,$i,'id') .'">
  736. <select name="addtime" onChange="submit()"><option value=""> *** Temps travail *** </option>
  737. ';
  738. ajoutheure();
  739. echo '
  740. </select>
  741. </form>
  742. </td>';
  743. echo "<td>";
  744. ################ BEGIN PUSH DELAYS ################
  745. push_delays($idc);
  746. echo '<td>
  747. <a href="/intranet/pmcake/pm_tasks/view/' .$idc .'" alt="Voir" title="Voir">
  748. <img src="/intranet/pmcake/img/toolbar/loupe.png" alt="Voir" />
  749. </a>
  750. <a href="/intranet/pmcake/pm_tasks/edit/' .$idc .'" alt="Modifier" title="Modifier">
  751. <img src="/intranet/pmcake/img/toolbar/editor.png" alt="Modifier" />
  752. </a>
  753. <a href="/intranet/pmcake/pm_tasks/delete/' .$idc .'" alt="Effacer" title="Effacer" onclick="return confirm(\'Voulez-vous vraiment effacer cet élément ?\');">
  754. <img src="/intranet/pmcake/img/toolbar/drop.png" alt="effacer" />
  755. </a>
  756. </td>
  757. </tr>';
  758. ################ END PUSH DELAYS ################
  759. /* ACTIONS END */
  760. echo "</tr>\n\n";
  761. /* stores id's */
  762. $lesid=$lesid.mysql_result($sql,$i,'id').";";
  763. $i++;
  764. }
  765. echo '
  766. </table>';
  767. echo '<select id="pousserdelais" class="btnadd" onChange="sendselected()">';
  768. delais();
  769. echo '</select>';
  770. echo '
  771. <!--
  772. <div class="choose_action">
  773. Action à effectuer sur les éléments sélectionnés&nbsp;
  774. <?php
  775. push_all_delays($catlib);
  776. ?>
  777. </div>
  778. !-->
  779. </form>';
  780. ?>
  781. <?php
  782. if($quand=="demain"||$quand=="futur") {
  783. echo "</div>";
  784. }
  785. echo '</div>
  786. <!-- CLOSE '.$catlib.' TASKS -->
  787. ';
  788. }
  789. /* extract the tasks for a given projects, to select the parent_task_id for a given task */
  790. function parent_tasks($pid,$task_id) {
  791. //no project (new task)
  792. if($pid=="") {
  793. echo "<option value=\"0\">--- no parent ---</option>";
  794. } else {
  795. $sql="SELECT id, name FROM pm_tasks WHERE project=".$pid." AND status>2 AND status < 10 ORDER BY name";
  796. #do and check sql
  797. $sql=mysql_query($sql);
  798. if(!$sql) {
  799. echo "SQL error: " .mysql_error(); exit;
  800. }
  801. $i=0;
  802. echo "<option value=\"0\">--- no parent ---</option>";
  803. while($i<mysql_num_rows($sql)){
  804. echo "<option value=\"" .mysql_result($sql,$i,'id') ."\"";
  805. if($task_id==mysql_result($sql,$i,'id')){
  806. echo " selected";
  807. }
  808. echo ">" .mysql_result($sql,$i,'name') ."</option>";
  809. $i++;
  810. }
  811. }
  812. }
  813. /* extract the parent task for a given task */
  814. function parent_task($task_id) {
  815. //no project (new task)
  816. $sql="SELECT parent_id FROM pm_tasks WHERE id=".$task_id;
  817. // echo "<br>".$sql ."<br>"; //tests
  818. $sql=mysql_query($sql);
  819. if(!$sql) {
  820. echo "SQL error: " .mysql_error(); exit;
  821. }
  822. $task_id=mysql_result($sql,0,'parent_id');
  823. if($task_id>0) {
  824. $sql="SELECT id, name FROM pm_tasks WHERE id=".$task_id ." ORDER BY due_date";
  825. echo "<tr><td>";
  826. // echo "<br>".$sql ."<br>"; //tests
  827. #do and check sql
  828. $sql=mysql_query($sql);
  829. if(!$sql) {
  830. echo "SQL error: " .mysql_error(); exit;
  831. }
  832. $i=0;
  833. if(mysql_num_rows($sql)>0) {
  834. echo "<h2>Parent</h2>";
  835. //echo "<ol>";
  836. while($i<mysql_num_rows($sql)){
  837. echo "<li><a href=\"" .mysql_result($sql,$i,'id') ."\">" .mysql_result($sql,$i,'name') ."</a></li>";
  838. $i++;
  839. }
  840. //echo "</ol>";
  841. }
  842. echo "</td></tr>";
  843. /**/
  844. }
  845. }
  846. function parent_task_small($task_id) {
  847. //no project (new task)
  848. $sql="SELECT parent_id FROM pm_tasks WHERE id=".$task_id;
  849. // echo "<br>".$sql ."<br>"; //tests
  850. $sql=mysql_query($sql);
  851. if(!$sql) {
  852. echo "SQL error: " .mysql_error(); exit;
  853. }
  854. $task_id=mysql_result($sql,0,'parent_id');
  855. if($task_id>0) {
  856. $sql="SELECT id, name FROM pm_tasks WHERE id=".$task_id ." ORDER BY due_date";
  857. #do and check sql
  858. $sql=mysql_query($sql);
  859. if(!$sql) {
  860. echo "SQL error: " .mysql_error(); exit;
  861. }
  862. $i=0;
  863. if(mysql_num_rows($sql)>0) {
  864. while($i<mysql_num_rows($sql)){
  865. echo "<a href=\"" .mysql_result($sql,$i,'id') ."\">" .mysql_result($sql,$i,'name') ."</a>";
  866. $i++;
  867. }
  868. }
  869. } else {
  870. echo " - ";
  871. }
  872. }
  873. /* extract the children tasks for a given task */
  874. function children_tasks($task_id) {
  875. $sql="SELECT id, name FROM pm_tasks WHERE parent_id=".$task_id ." ORDER BY due_date";
  876. //echo "<br>".$sql ."<br>"; //tests
  877. #do and check sql
  878. $sql=mysql_query($sql);
  879. if(!$sql) {
  880. echo "SQL error: " .mysql_error(); exit;
  881. }
  882. $i=0;
  883. if(mysql_num_rows($sql)>0) {
  884. echo "<tr><td>";
  885. echo "<h2>Children Tasks</h2>";
  886. echo "<ol>";
  887. while($i<mysql_num_rows($sql)){
  888. echo "<li><a href=\"" .mysql_result($sql,$i,'id') ."\">" .mysql_result($sql,$i,'name') ."</a></li>";
  889. $i++;
  890. }
  891. echo "</ol>";
  892. echo "</td></tr>";
  893. }
  894. }
  895. /* total hours today */
  896. function task_total_today($s_edate2) {
  897. $sql="
  898. SELECT * FROM pm_tasks_time, pm_projects
  899. WHERE pm_tasks_time.date
  900. LIKE '$s_edate2'
  901. AND pm_tasks_time.project=pm_projects.id
  902. AND pm_projects.type NOT LIKE 'p'
  903. GROUP BY pm_projects.name
  904. ";
  905. #echo nl2br($sql)."<br>";
  906. $sql=mysql_query($sql);
  907. if(!$sql) {
  908. echo "SQL error: " .mysql_error(); exit;
  909. }
  910. #echo $sql;
  911. //echo "Total ";
  912. //dateSQL2fr($s_edate2);
  913. echo "Tot: ";
  914. $i=0;
  915. $total=0;
  916. while($i<mysql_num_rows($sql)){
  917. $pmid=mysql_result($sql,$i,'pm_tasks_time.project');
  918. $sql2="
  919. SELECT SUM(hours) AS hours FROM pm_tasks_time
  920. WHERE pm_tasks_time.date
  921. LIKE '$s_edate2'
  922. AND pm_tasks_time.project=$pmid
  923. ";
  924. $sql2=mysql_query($sql2);
  925. $hours=mysql_result($sql2,0,'hours');
  926. $total=$total+$hours;
  927. $i++;
  928. }
  929. echo $total;
  930. echo "h";
  931. }
  932. /* resume times for a given week */
  933. function task_resume_week() {
  934. /*
  935. * semaine précédente
  936. */
  937. $jour=date("D");
  938. if($jour=="Mon"){
  939. $recule=7;
  940. }elseif($jour=="Tue"){
  941. $recule=8;
  942. }elseif($jour=="Wed"){
  943. $recule=9;
  944. }elseif($jour=="Thu"){
  945. $recule=10;
  946. }elseif($jour=="Fri"){
  947. $recule=11;
  948. }elseif($jour=="Sat"){
  949. $recule=12;
  950. }elseif($jour=="Sun"){
  951. $recule=13;
  952. }
  953. $recule=$recule*24*3600;
  954. $date_beg=date("U");
  955. $date_beg=$date_beg-$recule;
  956. $week = date('W', $date_beg);
  957. $date_fin=$date_beg+(7*24*3600);
  958. $date_fin=$date_beg+(4*24*3600);
  959. $date_begL= date('D, Y-m-d',$date_beg);
  960. $date_beg= date('Y-m-d',$date_beg);
  961. $date_finL= date('D, Y-m-d',($date_fin-(24*2600)));
  962. $date_fin= date('Y-m-d',$date_fin);
  963. $sql="
  964. SELECT SUM(pm_tasks_time.hours) AS hours, pm_projects.name
  965. FROM pm_tasks_time, pm_projects
  966. WHERE
  967. pm_tasks_time.date >= '$date_beg'
  968. AND pm_tasks_time.date <= '$date_fin'
  969. AND pm_tasks_time.project=pm_projects.id
  970. AND pm_projects.type NOT LIKE 'p'
  971. GROUP BY pm_projects.name
  972. ";
  973. // echo nl2br($sql)."<br>";
  974. $sql=mysql_query($sql);
  975. if(!$sql) {
  976. echo "SQL error: " .mysql_error(); exit;
  977. }
  978. $i=0;
  979. $total=0;
  980. echo "<h2>Total pour la semaine #" .$week ." du " .$date_begL ." au " .$date_finL ."</h2><table>";
  981. while($i<mysql_num_rows($sql)){
  982. echo "<tr><td style=\"padding: 3px\">";
  983. echo mysql_result($sql,$i,'pm_projects.name');
  984. echo "</td><td>";
  985. echo mysql_result($sql,$i,'hours');
  986. $total=$total+mysql_result($sql,$i,'hours');
  987. echo "</td></tr>";
  988. $i++;
  989. }
  990. echo "<tr><td>Total</td><td>".$total ."</td></tr>";
  991. echo "</table>";
  992. /*
  993. * semaine courante
  994. */
  995. $jour=date("D");
  996. if($jour=="Mon"){
  997. $recule=0;
  998. }elseif($jour=="Tue"){
  999. $recule=1;
  1000. }elseif($jour=="Wed"){
  1001. $recule=2;
  1002. }elseif($jour=="Thu"){
  1003. $recule=3;
  1004. }elseif($jour=="Fri"){
  1005. $recule=4;
  1006. }elseif($jour=="Sat"){
  1007. $recule=5;
  1008. }elseif($jour=="Sun"){
  1009. $recule=6;
  1010. }
  1011. $recule=$recule*24*3600;
  1012. $date_beg=date("U");
  1013. $date_beg=$date_beg-$recule;
  1014. $week = date('W', $date_beg);
  1015. $date_fin=$date_beg+(7*24*3600);
  1016. $date_fin=$date_beg+(4*24*3600);
  1017. $date_begL= date('D, Y-m-d',$date_beg);
  1018. $date_beg= date('Y-m-d',$date_beg);
  1019. $date_finL= date('D, Y-m-d',($date_fin-(24*2600)));
  1020. $date_fin= date('Y-m-d',$date_fin);
  1021. $sql="
  1022. SELECT SUM(pm_tasks_time.hours) AS hours, pm_projects.name
  1023. FROM pm_tasks_time, pm_projects
  1024. WHERE
  1025. pm_tasks_time.date >= '$date_beg'
  1026. AND pm_tasks_time.date <= '$date_fin'
  1027. AND pm_tasks_time.project=pm_projects.id
  1028. AND pm_projects.type NOT LIKE 'p'
  1029. GROUP BY pm_projects.name
  1030. ";
  1031. // echo nl2br($sql)."<br>";
  1032. $sql=mysql_query($sql);
  1033. if(!$sql) {
  1034. echo "SQL error: " .mysql_error(); exit;
  1035. }
  1036. $i=0;
  1037. $total=0;
  1038. echo "<h2>Total pour la semaine courante #" .$week ." du " .$date_begL ." au " .$date_finL ."</h2><table>";
  1039. while($i<mysql_num_rows($sql)){
  1040. echo "<tr><td style=\"padding: 3px\">";
  1041. echo mysql_result($sql,$i,'pm_projects.name');
  1042. echo "</td><td>";
  1043. echo mysql_result($sql,$i,'hours');
  1044. $total=$total+mysql_result($sql,$i,'hours');
  1045. echo "</td></tr>";
  1046. $i++;
  1047. }
  1048. echo "<tr><td>Total</td><td>".$total ."</td></tr>";
  1049. echo "</table>";
  1050. }
  1051. /* resume task for a given date */
  1052. function task_resume($s_edate2) {
  1053. $sql="
  1054. SELECT * FROM pm_tasks_time, pm_projects
  1055. WHERE pm_tasks_time.date
  1056. LIKE '$s_edate2'
  1057. AND pm_tasks_time.project=pm_projects.id
  1058. AND pm_projects.type NOT LIKE 'p'
  1059. GROUP BY pm_projects.name
  1060. ";
  1061. #echo nl2br($sql)."<br>";
  1062. $sql=mysql_query($sql);
  1063. if(!$sql) {
  1064. echo "SQL error: " .mysql_error(); exit;
  1065. }
  1066. #echo $sql;
  1067. echo "<h2>Totaux pour le: ";
  1068. dateSQL2fr($s_edate2);
  1069. echo "</h2><table>";
  1070. $i=0;
  1071. $total=0;
  1072. while($i<mysql_num_rows($sql)){
  1073. echo "<tr><td style=\"padding: 3px\">";
  1074. echo mysql_result($sql,$i,'name');
  1075. $pmid=mysql_result($sql,$i,'pm_tasks_time.project');
  1076. echo "</td><td>";
  1077. $sql2="
  1078. SELECT SUM(hours) AS hours FROM pm_tasks_time
  1079. WHERE pm_tasks_time.date
  1080. LIKE '$s_edate2'
  1081. AND pm_tasks_time.project=$pmid
  1082. ";
  1083. #echo $sql2;
  1084. #echo mysql_result($sql,$i,'hours');
  1085. $sql2=mysql_query($sql2);
  1086. $hours=mysql_result($sql2,0,'hours');
  1087. echo $hours;
  1088. #echo mysql_result($sql,$i,'hours');
  1089. #$total=$total+mysql_result($sql,$i,'hours');
  1090. $total=$total+$hours;
  1091. echo "</td></tr>";
  1092. $i++;
  1093. }
  1094. echo "<tr><td style=\"padding: 3px\"><b>TOTAL</b></td><td style=\"padding: 3px\">" .$total ."</td></tr>";
  1095. echo "</table><br>";
  1096. }
  1097. /* detail task for a given date */
  1098. function task_detail($s_edate2) {
  1099. ######### DETAIL #########
  1100. $sql="
  1101. SELECT * FROM pm_tasks_time,pm_projects,pm_tasks
  1102. WHERE pm_tasks_time.date
  1103. LIKE '$s_edate2'
  1104. AND pm_tasks_time.project=pm_projects.id
  1105. AND pm_tasks.id=pm_tasks_time.task
  1106. AND pm_projects.type NOT LIKE 'p'
  1107. ORDER BY pm_tasks_time.id
  1108. ";
  1109. #echo $sql;
  1110. echo "<hr><h2>D&eacute;tail</h2>
  1111. <table>
  1112. <tr>
  1113. <th>project</th><th>task</th><th>created</th><th>modified</th><th>comments</th><th>hours</th>
  1114. </tr>";
  1115. $sql=mysql_query($sql);
  1116. $i=0;
  1117. $total=0;
  1118. while($i<mysql_num_rows($sql)){
  1119. if(intval($i/2)==($i/2)) {
  1120. $classe="";
  1121. }else{
  1122. $classe="pair";
  1123. }
  1124. echo "<tr><td class=\"" .$classe ."\">";
  1125. echo mysql_result($sql,$i,'pm_projects.name');
  1126. echo "</td><td class=\"" .$classe ."\">";
  1127. echo mysql_result($sql,$i,'pm_tasks.name');
  1128. echo " <a href=\"" .CHEMIN ."pm_tasks_times/edit/" .mysql_result($sql,$i,'pm_tasks_time.id') ."\" title=\"Modifier le temps\">";
  1129. echo "<img src=\"" .CHEMIN ."img/icons/chronometre.png\" alt=\"modifier heures\" style=\"width: 25px\">";
  1130. echo "</a>";
  1131. echo " <a href=\"" .CHEMIN ."pm_tasks_times/delete/" .mysql_result($sql,$i,'pm_tasks_time.id') ."\" title=\"Supprimer le temps\">";
  1132. echo "<img src=\"" .CHEMIN ."img/toolbar/drop.png\" alt=\"supprimer heures\" style=\"width: 25px\">";
  1133. echo "</a>";
  1134. echo " <a href=\"" .CHEMIN ."pm_tasks/edit/" .mysql_result($sql,$i,'pm_tasks.id') ."\" title=\"modifier tâche\">";
  1135. echo "<img src=\"" .CHEMIN ."img/toolbar/editor.png\" alt=\"modifier tâche\" style=\"width: 25px\">";
  1136. echo " <a href=\"" .CHEMIN ."pm_tasks/view/" .mysql_result($sql,$i,'pm_tasks.id') ."\"title=\"voir la tâche\">";
  1137. echo "<img src=\"" .CHEMIN ."img/toolbar/loupe.png\" alt=\"voir la tâche\" style=\"width: 25px\">";
  1138. echo "</a></td><td class=\"" .$classe ."\">";
  1139. echo mysql_result($sql,$i,'pm_tasks_time.created');
  1140. echo "</td><td class=\"" .$classe ."\">";
  1141. echo mysql_result($sql,$i,'pm_tasks_time.modified');
  1142. echo "</td><td class=\"" .$classe ."\">";
  1143. echo substr(mysql_result($sql,$i,'pm_tasks_time.comments'), 0,100);
  1144. echo "</td><td class=\"" .$classe ."\">";
  1145. echo mysql_result($sql,$i,'pm_tasks_time.hours');
  1146. echo "</td></tr>";
  1147. $i++;
  1148. }
  1149. echo "</table>";
  1150. }
  1151. ####### CLIENTS #########
  1152. /*function to get a scrolling list of projets and highlight the current project if exists*/
  1153. function clients_sel($pid) {
  1154. $sql="SELECT id, name FROM pm_organizations ORDER BY name";
  1155. #do and check sql
  1156. $sql=mysql_query($sql);
  1157. if(!$sql) {
  1158. echo "SQL error: " .mysql_error(); exit;
  1159. }
  1160. $i=0;
  1161. while($i<mysql_num_rows($sql)){
  1162. echo "<option value=\"" .mysql_result($sql,$i,'id') ."\"";
  1163. if($pid==mysql_result($sql,$i,'id')){
  1164. echo " selected";
  1165. }
  1166. echo ">" .mysql_result($sql,$i,'name') ."</option>";
  1167. $i++;
  1168. }
  1169. }
  1170. /* function to extract specified usagers/clients */
  1171. function clients($id) {
  1172. $sql="SELECT * FROM pm_organizations WHERE id=".$id;
  1173. $sql=mysql_query($sql);
  1174. if(!$sql) { echo "SQL error: " .mysql_error(); }
  1175. echo "<a href=\"" .CHEMIN."/pm_organizations/view/".mysql_result($sql,0,'id') ."\">" .mysql_result($sql,0,'name') ."</a>";
  1176. }
  1177. /* list of projets for a given client */
  1178. function client_projets($id) {
  1179. $sql="SELECT id, name FROM pm_projects WHERE pm_organization_id=".$id;
  1180. $sql=mysql_query($sql);
  1181. if(!$sql) { echo "SQL error: " .mysql_error(); }
  1182. $i=0;
  1183. echo "<ul>";
  1184. while($i<mysql_num_rows($sql)){
  1185. echo "<li><a href=\"" .CHEMIN."/pm_projects/view/".mysql_result($sql,$i,'id') ."\">" .mysql_result($sql,0,'name') ."</a></li>";
  1186. $i++;
  1187. }
  1188. echo "</ul>";
  1189. }
  1190. /* list of all tasks for a given client */
  1191. function client_tasks($id) {
  1192. $datenow = date("Y-m-d");
  1193. $sql="
  1194. SELECT * FROM pm_tasks AS tas, pm_projects as proj
  1195. WHERE tas.project=proj.id
  1196. AND proj.pm_organization_id=".$id ."
  1197. ORDER BY tas.due_date ASC
  1198. ";
  1199. $sql=mysql_query($sql);
  1200. if(!$sql) { echo "SQL error: " .mysql_error(); }
  1201. $i=0;
  1202. echo "<ul class=\"puce_cache\">";
  1203. while($i<mysql_num_rows($sql)){
  1204. echo "<li>";
  1205. statut(mysql_result($sql,$i,'tas.status'));
  1206. echo "&nbsp;<a href=\"" .CHEMIN."/pm_tasks/view/".mysql_result($sql,$i,'tas.id') ."\">" .mysql_result($sql,$i,'tas.name') ."</a>";
  1207. echo "&nbsp;<span style=\"font-style: italic; font-size: smaller;\">(" .mysql_result($sql,$i,'tas.due_date') .")</span>";
  1208. echo "</li>";
  1209. $i++;
  1210. }
  1211. echo "</ul>";
  1212. }
  1213. ######### USERS ###########
  1214. /* function to extract specified member (owners) */
  1215. function membres($id) {
  1216. $sql="SELECT * FROM pm_members WHERE id=".$id;
  1217. $sql=mysql_query($sql);
  1218. if(!$sql) { echo "SQL error: " .mysql_error(); }
  1219. echo "<a href=\"../pm_members/view/".mysql_result($sql,0,'id') ."\">" .mysql_result($sql,0,'login') ."</a>";
  1220. }
  1221. /* function to extract all members (owners) for a given task */
  1222. function ts_les_membres($id) {
  1223. $sql="SELECT * FROM pm_tasks_pm_members, pm_members
  1224. WHERE pm_tasks_pm_members.pm_task_id=".$id
  1225. ." AND pm_tasks_pm_members.pm_member_id=pm_members.id"
  1226. ;
  1227. $sql=mysql_query($sql);
  1228. if(!$sql) { echo "SQL error: " .mysql_error(); }
  1229. $i=0;
  1230. if(mysql_num_rows($sql)>0) {
  1231. echo "<ol>";
  1232. while($i<mysql_num_rows($sql)){
  1233. echo "<li><a href=\"" .mysql_result($sql,$i,'id') ."\">" .mysql_result($sql,$i,'name') ."</a></li>";
  1234. $i++;
  1235. }
  1236. echo "</ol>";
  1237. }
  1238. }
  1239. /*function to get a scrolling list of projets and highlight the current project if exists*/
  1240. function membres_sel($pid) {
  1241. $sql="SELECT id, name FROM pm_members ORDER BY name";
  1242. #do and check sql
  1243. $sql=mysql_query($sql);
  1244. if(!$sql) {
  1245. echo "SQL error: " .mysql_error(); exit;
  1246. }
  1247. $i=0;
  1248. while($i<mysql_num_rows($sql)){
  1249. echo "<option value=\"" .mysql_result($sql,$i,'id') ."\"";
  1250. if($pid==mysql_result($sql,$i,'id')){
  1251. echo " selected";
  1252. }
  1253. echo ">" .mysql_result($sql,$i,'name') ."</option>";
  1254. $i++;
  1255. }
  1256. }
  1257. function ae_gen_password($syllables = 3, $use_prefix = false)
  1258. {
  1259. // Define function unless it is already exists
  1260. if (!function_exists('ae_arr'))
  1261. {
  1262. // This function returns random array element
  1263. function ae_arr(&$arr)
  1264. {
  1265. return $arr[rand(0, sizeof($arr)-1)];
  1266. }
  1267. }
  1268. // 20 prefixes
  1269. $prefix = array('aero', 'anti', 'auto', 'bi', 'bio',
  1270. 'cine', 'deca', 'demo', 'dyna', 'eco',
  1271. 'ergo', 'geo', 'gyno', 'hypo', 'kilo',
  1272. 'mega', 'tera', 'mini', 'nano', 'duo');
  1273. // 10 random suffixes
  1274. $suffix = array('dom', 'ity', 'ment', 'sion', 'ness',
  1275. 'ence', 'er', 'ist', 'tion', 'or');
  1276. // 8 vowel sounds
  1277. $vowels = array('a', 'o', 'e', 'i', 'y', 'u', 'ou', 'oo');
  1278. // 20 random consonants
  1279. $consonants = array('w', 'r', 't', 'p', 's', 'd', 'f', 'g', 'h', 'j',
  1280. 'k', 'l', 'z', 'x', 'c', 'v', 'b', 'n', 'm', 'qu');
  1281. $password = $use_prefix?ae_arr($prefix):'';
  1282. $password_suffix = ae_arr($suffix);
  1283. for($i=0; $i<$syllables; $i++)
  1284. {
  1285. // selecting random consonant
  1286. $doubles = array('n', 'm', 't', 's');
  1287. $c = ae_arr($consonants);
  1288. if (in_array($c, $doubles)&&($i!=0)) { // maybe double it
  1289. if (rand(0, 2) == 1) // 33% probability
  1290. $c .= $c;
  1291. }
  1292. $password .= $c;
  1293. //
  1294. // selecting random vowel
  1295. $password .= ae_arr($vowels);
  1296. if ($i == $syllables - 1) // if suffix begin with vovel
  1297. if (in_array($password_suffix[0], $vowels)) // add one more consonant
  1298. $password .= ae_arr($consonants);
  1299. }
  1300. // selecting random suffix
  1301. $password .= $password_suffix;
  1302. return $password;
  1303. }
  1304. function generate_password($length){
  1305. // A List of vowels and vowel sounds that we can insert in
  1306. // the password string
  1307. $vowels = array("a", "e", "i", "o", "u", "ae", "ou", "io",
  1308. "ea", "ou", "ia", "ai");
  1309. // A List of Consonants and Consonant sounds that we can insert
  1310. // into the password string
  1311. $consonants = array("b", "c", "d", "g", "h", "j", "k", "l", "m",
  1312. "n", "p", "r", "s", "t", "u", "v", "w",
  1313. "tr", "cr", "fr", "dr", "wr", "pr", "th",
  1314. "ch", "ph", "st", "sl", "cl");
  1315. // For the call to rand(), saves a call to the count() function
  1316. // on each iteration of the for loop
  1317. $vowel_count = count($vowels);
  1318. $consonant_count = count($consonants);
  1319. // From $i .. $length, fill the string with alternating consonant
  1320. // vowel pairs.
  1321. for ($i = 0; $i < $length; ++$i) {
  1322. $pass .= $consonants[rand(0, $consonant_count - 1)] .
  1323. $vowels[rand(0, $vowel_count - 1)];
  1324. }
  1325. // Since some of our consonants and vowels are more than one
  1326. // character, our string can be longer than $length, use substr()
  1327. // to truncate the string
  1328. return substr($pass, 0, $length);
  1329. }
  1330. function generatePassword($length=9, $strength=0) {
  1331. $vowels = 'aeuy';
  1332. $consonants = 'bdghjmnpqrstvz';
  1333. if ($strength & 1) {
  1334. $consonants .= 'BDGHJLMNPQRSTVWXZ';
  1335. }
  1336. if ($strength & 2) {
  1337. $vowels .= "AEUY";
  1338. }
  1339. if ($strength & 4) {
  1340. $consonants .= '23456789';
  1341. }
  1342. if ($strength & 8) {
  1343. $consonants .= '@#$%';
  1344. }
  1345. $password = '';
  1346. $alt = time() % 2;
  1347. for ($i = 0; $i < $length; $i++) {
  1348. if ($alt == 1) {
  1349. $password .= $consonants[(rand() % strlen($consonants))];
  1350. $alt = 0;
  1351. } else {
  1352. $password .= $vowels[(rand() % strlen($vowels))];
  1353. $alt = 1;
  1354. }
  1355. }
  1356. return $password;
  1357. }
  1358. function passe_mnemo(){
  1359. #Description :
  1360. #Génère un mot de passe prononçable, pour faciliter sa mémorisation, mais malgré tout très compliqué.
  1361. #Par exemple :
  1362. #ZbleUrg (prononçable, mais difficile).
  1363. #Auteur : Damien Seguy
  1364. #Url : http://www.nexen.net
  1365. if (func_num_args() == 1){ $nb = func_get_arg(0);} else { $nb = 6;}
  1366. // on utilise certains chiffres : 1 = i, 5 = S, 6=b, 3=E, 9=G, 0=O
  1367. $lettre = array();
  1368. $lettre[0] = array('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i',
  1369. 'j', 'k', 'l', 'm', 'o', 'n', 'p', 'q', 'r',
  1370. 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A',
  1371. 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J',
  1372. 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'D',
  1373. 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '9',
  1374. '0', '6', '5', '1', '3');
  1375. $lettre[1] = array('a', 'e', 'i', 'o', 'u', 'y', 'A', 'E',
  1376. 'I', 'O', 'U', 'Y' , '1', '3', '0' );
  1377. $lettre[-1] = array('b', 'c', 'd', 'f', 'g', 'h', 'j', 'k',
  1378. 'l', 'm', 'n', 'p', 'q', 'r', 's', 't',
  1379. 'v', 'w', 'x', 'z', 'B', 'C', 'D', 'F',
  1380. 'G', 'H', 'J', 'K', 'L', 'M', 'N', 'P',
  1381. 'Q', 'R', 'S', 'T', 'V', 'W', 'X', 'Z',
  1382. '5', '6', '9');
  1383. /*
  1384. * mod radeff: suppressed i, I, 1, o, O and 0
  1385. *
  1386. */ $lettre[0] = array('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h',
  1387. 'j', 'k', 'm', 'n', 'p', 'q', 'r',
  1388. 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A',
  1389. 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J',
  1390. 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'D',
  1391. 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '9', '6', '5', '3');
  1392. $lettre[1] = array('a', 'e', 'o', 'u', 'y', 'A', 'E',
  1393. 'I', 'U', 'Y' , '3' );
  1394. $lettre[-1] = array('b', 'c', 'd', 'f', 'g', 'h', 'j', 'k',
  1395. 'm', 'n', 'p', 'q', 'r', 's', 't',
  1396. 'v', 'w', 'x', 'z', 'B', 'C', 'D', 'F',
  1397. 'G', 'H', 'J', 'K', 'L', 'M', 'N', 'P',
  1398. 'Q', 'R', 'S', 'T', 'V', 'W', 'X', 'Z',
  1399. '5', '6', '9');
  1400. $retour = "";
  1401. $prec = 1;
  1402. $precprec = -1;
  1403. srand((double)microtime()*20001107);
  1404. while(strlen($retour) < $nb){
  1405. // pour genere la suite de lettre, on dit : si les deux lettres sonts
  1406. // des consonnes (resp. des voyelles) on affiche des voyelles (resp, des consonnes).
  1407. // si les lettres sont de type differents, on affiche une lettre de l'alphabet
  1408. $type = ($precprec + $prec)/2;
  1409. $r = $lettre[$type][array_rand($lettre[$type], 1)];
  1410. $retour .= $r;
  1411. $precprec = $prec;
  1412. $prec = in_array($r, $lettre[-1]) - in_array($r, $lettre[1]);
  1413. }
  1414. // if(!preg_match("/i/i",$retour)&&!preg_match("/0/",$retour)&&!preg_match("/o/",$retour)){
  1415. return $retour;
  1416. // }else{
  1417. // passe_mnemo(func_get_arg(0));
  1418. // }
  1419. }
  1420. ######### FILES ###########
  1421. /* function to print specified filetypes */
  1422. function typefichier($id) {
  1423. echo '<img src="/pmcake/img/filetypes/' .$id .'.gif" alt="' .$id .'" />';
  1424. }
  1425. ######### MySQL ###########
  1426. /* function to clean strings before insert or modify SQL */
  1427. function normaliser($string) {
  1428. // return trim(addslashes($string));
  1429. return addslashes($string);
  1430. }
  1431. ######### HTML tools #######
  1432. /* keep record of every transactions for logs history */
  1433. function ecritlog() {
  1434. $db=connect_db();
  1435. $db_name=db_name();
  1436. mysql_select_db($db_name,$db);
  1437. $sql ="INSERT INTO `pm_urls_logs` (
  1438. `id` ,
  1439. `time` ,
  1440. `url`
  1441. )
  1442. VALUES (
  1443. NULL , '" .date("Y-m-d H:i:s") ."', '" .$_SERVER["REQUEST_URI"] ."'
  1444. );
  1445. ";
  1446. #echo $sql; exit;
  1447. #do and check sql
  1448. //don't run if image or so
  1449. if(!preg_match("/\.gif$/",$_SERVER["REQUEST_URI"])) {
  1450. $sql=mysql_query($sql);
  1451. if(!$sql) {
  1452. echo "SQL error: " .mysql_error(); exit;
  1453. }
  1454. }
  1455. }
  1456. /*convert SQL date time to french date*/
  1457. function dateSQL2fr($date) {
  1458. $date=explode(" ", $date);
  1459. $hour=$date[1];
  1460. $date=$date[0];
  1461. $date=explode("-", $date);
  1462. // $date=mktime(0,0,0,$date[2],$date[1],$date[0]);
  1463. $date=mktime(0,0,0,$date[1],$date[2],$date[0]);
  1464. echo strftime("%a, %d-%m-%Y", $date);
  1465. }
  1466. function dateSQLlong2fr($date) {
  1467. if($date>1000000000) {
  1468. //unixtime
  1469. $timestamp=$date;
  1470. } else {
  1471. $timestamp=strtotime($date);
  1472. }
  1473. //echo $date;
  1474. $date_mod= date('D, d-m-Y H:i',$timestamp);
  1475. $today1=dateen2fr($date_mod);
  1476. echo $today1;
  1477. }
  1478. /*same but no day name (shorter)*/
  1479. function dateSQL2frSmall($date) {
  1480. $date=explode(" ", $date);
  1481. $hour=$date[1];
  1482. $date=$date[0];
  1483. $date=explode("-", $date);
  1484. $date=mktime(0,0,0,$date[1],$date[2],$date[0]);
  1485. echo strftime("%d-%m-%Y", $date);
  1486. }
  1487. /*convert english short date to french short date*/
  1488. function dateen2fr($today1) {
  1489. #mois en francais - attention à le faire dans ce sens car Mar(s) < Mardi !
  1490. $today1 = preg_replace("/Jan/", "Janvier", $today1);
  1491. $today1 = preg_replace("/Feb/", "Février", $today1);
  1492. $today1 = preg_replace("/Mar/", "Mars", $today1);
  1493. $today1 = preg_replace("/Apr/", "Avril", $today1);
  1494. $today1 = preg_replace("/May/", "Mai", $today1);
  1495. $today1 = preg_replace("/Jun/", "Juin", $today1);
  1496. $today1 = preg_replace("/Jul/", "Juillet", $today1);
  1497. $today1 = preg_replace("/Aug/", "Août", $today1);
  1498. $today1 = preg_replace("/Sept/", "Septembre", $today1);
  1499. $today1 = preg_replace("/Oct/", "Octobre", $today1);
  1500. $today1 = preg_replace("/Nov/", "Novembre", $today1);
  1501. $today1 = preg_replace("/Dec/", "Décembre", $today1);
  1502. $today1 = preg_replace("/Mon/", "Lundi", $today1);
  1503. $today1 = preg_replace("/Tue/", "Mardi", $today1);
  1504. $today1 = preg_replace("/Wed/", "Mercredi", $today1);
  1505. $today1 = preg_replace("/Thu/", "Jeudi", $today1);
  1506. $today1 = preg_replace("/Fri/", "Vendredi", $today1);
  1507. $today1 = preg_replace("/Sat/", "Samedi", $today1);
  1508. $today1 = preg_replace("/Sun/", "Dimanche", $today1);
  1509. //$today1=preg_replace("/-/"," ", $today1);
  1510. return $today1;
  1511. }
  1512. /* function to extract urls from variables */
  1513. function urlise($chaine) {
  1514. $chaine = preg_replace("/(https:\/\/)(([[:punct:]]|[[:alnum:]]=?)*)/","<a target=\"_blank\" href=\"\\0\">\\0</a>",$chaine);
  1515. $chaine=preg_replace("/(http:\/\/)(([[:punct:]]|[[:alnum:]]=?)*)/","<a target=\"_blank\" href=\"\\0\">\\0</a>",$chaine);
  1516. if(preg_match("/([a-zA-Z0-9]*\.)?[a-zA-Z0-9]*\.[a-zA-Z0-9]*@/",$chaine)){ //replace emails with mailto
  1517. $search = '#(^|[ \n\r\t])(([a-z0-9\-_]+(\.?))+@([a-z0-9\-]+(\.?))+[a-z]{2,5})#si';
  1518. $replace = '\\1<a href="mailto:\\2">\\2</a>';
  1519. $chaine=preg_replace($search, $replace, $chaine);
  1520. }else {
  1521. if(!preg_match("/http:.*/",$chaine)){ //avoid to put a mailto: if the email is a GET variable
  1522. $chaine = preg_replace('/[-a-zA-Z0-9]*\.?[-a-zA-Z0-9!#$%&\'*+\/=?^_`{|}~]+@([.]?[a-zA-Z0-9_\/-])*/','<a href="mailto:\\0">\\0</a>',$chaine);
  1523. }
  1524. }
  1525. //echo nl2br($chaine);
  1526. $chaine=nl2br($chaine);
  1527. return $chaine;
  1528. }
  1529. function urlise2($chaine) {
  1530. #echo "test urlize: <br>" .$chaine ."<hr>";
  1531. #$chaine=ereg_replace("(http://)(([[:punct:]]|[[:alnum:]]=?)*)","<a href=\"\\0\">\\0</a>",$chaine);
  1532. $chaine = preg_replace("/(https:\/\/)(([[:punct:]]|[[:alnum:]]=?)*)/","<a target=\"_blank\" href=\"\\0\">\\0</a>",$chaine);
  1533. $chaine=preg_replace("/(http:\/\/)(([[:punct:]]|[[:alnum:]]=?)*)/","<a target=\"_blank\" href=\"\\0\">\\0</a>",$chaine);
  1534. //now replace emails
  1535. if(!preg_match("/[a-zA-Z0-9]*\.[a-zA-Z0-9]*@/",$chaine)){
  1536. #$chaine = ereg_replace('[-a-zA-Z0-9!#$%&\'*+/=?^_`{|}~]+@([.]?[a-zA-Z0-9_/-])*','<a href="mailto:\\0">\\0</a>',$chaine);
  1537. #$chaine = preg_replace('/[-a-zA-Z0-9!#$%&\'*+/=?^_`{|}~]+@([.]?[a-zA-Z0-9_\/-])*/','<a href="mailto:\\0">\\0</a>',$chaine);
  1538. }else {
  1539. $chaine = preg_replace('/[-a-zA-Z0-9]*\.?[-a-zA-Z0-9!#$%&\'*+\/=?^_`{|}~]+@([.]?[a-zA-Z0-9_\/-])*/','<a href="mailto:\\0">\\0</a>',$chaine);
  1540. }
  1541. //echo nl2br($chaine);
  1542. $chaine=nl2br($chaine);
  1543. echo $chaine;
  1544. }
  1545. function link_task($chaine) {
  1546. /*
  1547. * highlight tasks linked
  1548. */
  1549. $chaine = preg_replace('/\{\{(.*?)\|(.*?)\}\}/', "
  1550. <a href=\"/intranet/pmcake/pm_tasks/edit/$2\" title=\"linked task\">
  1551. <span style=\"color: #008080;\">
  1552. <img src=\"/intranet/pmcake/img/icons/bullet_arrow.gif\"
  1553. border=\"0\" alt=\"linked task\" />linked task</span></a>", $chaine);
  1554. return $chaine;
  1555. }
  1556. /* function to extract titles from variables */
  1557. function extrait_titres($chaine) {
  1558. #echo "test urlize: <br>" .$chaine ."<hr>";
  1559. #$chaine=ereg_replace("(http://)(([[:punct:]]|[[:alnum:]]=?)*)","<a href=\"\\0\">\\0</a>",$chaine);
  1560. $chaine = preg_replace("/=== (.*)/","<br/><h2>\\1</h2>",$chaine);
  1561. $chaine = preg_replace("/== (.*)/","<h3>\\1</h3>",$chaine);
  1562. $chaine = preg_replace("/= (.*)/","<h4>\\1</h4>",$chaine);
  1563. //echo nl2br($chaine);
  1564. // $chaine="bla".$chaine;
  1565. return $chaine;
  1566. }

Large files files are truncated, but you can click here to view the full file