PageRenderTime 71ms CodeModel.GetById 45ms RepoModel.GetById 0ms app.codeStats 0ms

/htdocs/projet/index.php

https://bitbucket.org/speedealing/speedealing
PHP | 136 lines | 80 code | 28 blank | 28 comment | 13 complexity | 9df3eca0ad05f244643e9d491357ed71 MD5 | raw file
Possible License(s): LGPL-3.0, LGPL-2.1, GPL-3.0, MIT
  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.houssin@capnetworks.com>
  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 3 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. */
  24. require '../main.inc.php';
  25. require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
  26. require_once DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php';
  27. $langs->load("projects");
  28. $langs->load("companies");
  29. $mine = $_REQUEST['mode']=='mine' ? 1 : 0;
  30. // Security check
  31. $socid=0;
  32. if ($user->societe_id > 0) $socid=$user->societe_id;
  33. if (!$user->rights->projet->lire) accessforbidden();
  34. $sortfield = GETPOST("sortfield",'alpha');
  35. $sortorder = GETPOST("sortorder",'alpha');
  36. /*
  37. * View
  38. */
  39. $socstatic=new Societe($db);
  40. $projectstatic=new Project($db);
  41. $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user,($mine?$mine:($user->rights->projet->all->lire?2:0)),1);
  42. //var_dump($projectsListId);
  43. llxHeader("",$langs->trans("Projects"),"EN:Module_Projects|FR:Module_Projets|ES:M&oacute;dulo_Proyectos");
  44. $text=$langs->trans("Projects");
  45. if ($mine) $text=$langs->trans("MyProjects");
  46. print_fiche_titre($text);
  47. // Show description of content
  48. if ($mine) print $langs->trans("MyProjectsDesc").'<br><br>';
  49. else
  50. {
  51. if ($user->rights->projet->all->lire && ! $socid) print $langs->trans("ProjectsDesc").'<br><br>';
  52. else print $langs->trans("ProjectsPublicDesc").'<br><br>';
  53. }
  54. print '<table border="0" width="100%" class="notopnoleftnoright">';
  55. print '<tr><td width="30%" valign="top" class="notopnoleft">';
  56. print_projecttasks_array($db,$socid,$projectsListId);
  57. print '</td><td width="70%" valign="top" class="notopnoleftnoright">';
  58. print '<table class="noborder" width="100%">';
  59. print '<tr class="liste_titre">';
  60. print_liste_field_titre($langs->trans("ThirdParties"),"index.php","s.nom","","","",$sortfield,$sortorder);
  61. print_liste_field_titre($langs->trans("NbOfProjects"),"","","","",'align="right"',$sortfield,$sortorder);
  62. print "</tr>\n";
  63. $sql = "SELECT count(p.rowid) as nb";
  64. $sql.= ", s.nom, s.rowid as socid";
  65. $sql.= " FROM ".MAIN_DB_PREFIX."projet as p";
  66. $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s on p.fk_soc = s.rowid";
  67. $sql.= " WHERE p.entity = ".$conf->entity;
  68. if ($mine || ! $user->rights->projet->all->lire) $sql.= " AND p.rowid IN (".$projectsListId.")";
  69. if ($socid) $sql.= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")";
  70. $sql.= " GROUP BY s.nom, s.rowid";
  71. $var=true;
  72. $resql = $db->query($sql);
  73. if ( $resql )
  74. {
  75. $num = $db->num_rows($resql);
  76. $i = 0;
  77. while ($i < $num)
  78. {
  79. $obj = $db->fetch_object($resql);
  80. $var=!$var;
  81. print "<tr $bc[$var]>";
  82. print '<td nowrap="nowrap">';
  83. if ($obj->socid)
  84. {
  85. $socstatic->id=$obj->socid;
  86. $socstatic->nom=$obj->nom;
  87. print $socstatic->getNomUrl(1);
  88. }
  89. else
  90. {
  91. print $langs->trans("OthersNotLinkedToThirdParty");
  92. }
  93. print '</td>';
  94. print '<td align="right"><a href="'.DOL_URL_ROOT.'/projet/liste.php?socid='.$obj->socid.'">'.$obj->nb.'</a></td>';
  95. print "</tr>\n";
  96. $i++;
  97. }
  98. $db->free($resql);
  99. }
  100. else
  101. {
  102. dol_print_error($db);
  103. }
  104. print "</table>";
  105. print '</td></tr></table>';
  106. llxFooter();
  107. $db->close();
  108. ?>