PageRenderTime 24ms CodeModel.GetById 29ms RepoModel.GetById 0ms app.codeStats 0ms

/htdocs/projet/index.php

https://gitlab.com/imagination/dolibarr
PHP | 134 lines | 78 code | 27 blank | 29 comment | 13 complexity | aaa1ab169e6d17901fd7d2c669e3430a MD5 | raw file
  1. <?php
  2. /* Copyright (C) 2001-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
  3. * Copyright (C) 2004-2010 Laurent Destailleur <eldy@users.sourceforge.net>
  4. * Copyright (C) 2005-2010 Regis Houssin <regis@dolibarr.fr>
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. /**
  20. * \file htdocs/projet/index.php
  21. * \ingroup projet
  22. * \brief Main project home page
  23. * \version $Id: index.php,v 1.76 2011/08/08 15:28:01 eldy Exp $
  24. */
  25. require("../main.inc.php");
  26. require_once(DOL_DOCUMENT_ROOT."/projet/class/project.class.php");
  27. require_once(DOL_DOCUMENT_ROOT."/lib/project.lib.php");
  28. $langs->load("projects");
  29. $langs->load("companies");
  30. $mine = $_REQUEST['mode']=='mine' ? 1 : 0;
  31. // Security check
  32. $socid=0;
  33. if ($user->societe_id > 0) $socid=$user->societe_id;
  34. if (!$user->rights->projet->lire) accessforbidden();
  35. /*
  36. * View
  37. */
  38. $socstatic=new Societe($db);
  39. $projectstatic=new Project($db);
  40. $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user,($mine?$mine:($user->rights->projet->all->lire?2:0)),1);
  41. //var_dump($projectsListId);
  42. llxHeader("",$langs->trans("Projects"),"EN:Module_Projects|FR:Module_Projets|ES:M&oacute;dulo_Proyectos");
  43. $text=$langs->trans("Projects");
  44. if ($mine) $text=$langs->trans("MyProjects");
  45. print_fiche_titre($text);
  46. // Show description of content
  47. if ($mine) print $langs->trans("MyProjectsDesc").'<br><br>';
  48. else
  49. {
  50. if ($user->rights->projet->all->lire && ! $socid) print $langs->trans("ProjectsDesc").'<br><br>';
  51. else print $langs->trans("ProjectsPublicDesc").'<br><br>';
  52. }
  53. print '<table border="0" width="100%" class="notopnoleftnoright">';
  54. print '<tr><td width="30%" valign="top" class="notopnoleft">';
  55. print_projecttasks_array($db,$socid,$projectsListId);
  56. print '</td><td width="70%" valign="top" class="notopnoleftnoright">';
  57. print '<table class="noborder" width="100%">';
  58. print '<tr class="liste_titre">';
  59. print_liste_field_titre($langs->trans("ThirdParties"),"index.php","s.nom","","","",$sortfield,$sortorder);
  60. print_liste_field_titre($langs->trans("NbOfProjects"),"","","","",'align="right"',$sortfield,$sortorder);
  61. print "</tr>\n";
  62. $sql = "SELECT count(p.rowid) as nb";
  63. $sql.= ", s.nom, s.rowid as socid";
  64. $sql.= " FROM ".MAIN_DB_PREFIX."projet as p";
  65. $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s on p.fk_soc = s.rowid";
  66. $sql.= " WHERE p.entity = ".$conf->entity;
  67. if ($mine || ! $user->rights->projet->all->lire) $sql.= " AND p.rowid IN (".$projectsListId.")";
  68. if ($socid) $sql.= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")";
  69. $sql.= " GROUP BY s.nom, s.rowid";
  70. $var=true;
  71. $resql = $db->query($sql);
  72. if ( $resql )
  73. {
  74. $num = $db->num_rows($resql);
  75. $i = 0;
  76. while ($i < $num)
  77. {
  78. $obj = $db->fetch_object($resql);
  79. $var=!$var;
  80. print "<tr $bc[$var]>";
  81. print '<td nowrap="nowrap">';
  82. if ($obj->socid)
  83. {
  84. $socstatic->id=$obj->socid;
  85. $socstatic->nom=$obj->nom;
  86. print $socstatic->getNomUrl(1);
  87. }
  88. else
  89. {
  90. print $langs->trans("OthersNotLinkedToThirdParty");
  91. }
  92. print '</td>';
  93. print '<td align="right"><a href="'.DOL_URL_ROOT.'/projet/liste.php?socid='.$obj->socid.'">'.$obj->nb.'</a></td>';
  94. print "</tr>\n";
  95. $i++;
  96. }
  97. $db->free($resql);
  98. }
  99. else
  100. {
  101. dol_print_error($db);
  102. }
  103. print "</table>";
  104. print '</td></tr></table>';
  105. $db->close();
  106. llxFooter('$Date: 2011/08/08 15:28:01 $ - $Revision: 1.76 $');
  107. ?>