projects.php 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. <?php
  2. /* Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr>
  3. * Copyright (C) 2005-2013 Regis Houssin <regis.houssin@inodbox.com>
  4. * Copyright (C) 2007-2020 Laurent Destailleur <eldy@users.sourceforge.net>
  5. * Copyright (C) 2014-2015 Marcos García <marcosgdf@gmail.com>
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 3 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  19. */
  20. /**
  21. * \file htdocs/projet/ajax/projects.php
  22. * \brief File to return Ajax response on product list request
  23. */
  24. if (!defined('NOTOKENRENEWAL')) {
  25. define('NOTOKENRENEWAL', 1); // Disables token renewal
  26. }
  27. if (!defined('NOREQUIREMENU')) {
  28. define('NOREQUIREMENU', '1');
  29. }
  30. if (!defined('NOREQUIREHTML')) {
  31. define('NOREQUIREHTML', '1');
  32. }
  33. if (!defined('NOREQUIREAJAX')) {
  34. define('NOREQUIREAJAX', '1');
  35. }
  36. if (!defined('NOREQUIRESOC')) {
  37. define('NOREQUIRESOC', '1');
  38. }
  39. if (!defined('NOREQUIREHTML')) {
  40. define('NOREQUIREHTML', '1');
  41. }
  42. // Load Dolibarr environment
  43. require '../../main.inc.php';
  44. $htmlname = GETPOST('htmlname', 'aZ09');
  45. $socid = GETPOST('socid', 'int');
  46. $mode = GETPOST('mode', 'aZ09');
  47. $discard_closed = GETPOST('discardclosed', 'int');
  48. // Security check
  49. restrictedArea($user, 'projet', 0, 'projet&project');
  50. /*
  51. * View
  52. */
  53. dol_syslog("Call ajax projet/ajax/projects.php");
  54. require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
  55. top_httphead('application/json');
  56. if (empty($htmlname) && !GETPOST('mode', 'aZ09')) {
  57. return;
  58. }
  59. // Mode to get list of projects
  60. if (empty($mode) || $mode != 'gettasks') {
  61. // When used from jQuery, the search term is added as GET param "term".
  62. $searchkey = (GETPOSTISSET($htmlname) ? GETPOST($htmlname, 'aZ09') : '');
  63. $formproject = new FormProjets($db);
  64. $arrayresult = $formproject->select_projects_list($socid, '', $htmlname, 0, 0, 1, $discard_closed, 0, 0, 1, $searchkey);
  65. }
  66. // Mode to get list of tasks
  67. if ($mode == 'gettasks') {
  68. $formproject = new FormProjets($db);
  69. $formproject->selectTasks((!empty($socid) ? $socid : -1), 0, 'taskid', 24, 1, '1', 1, 0, 0, 'maxwidth500', GETPOST('projectid', 'int'), '');
  70. return;
  71. }
  72. $db->close();
  73. print json_encode($arrayresult);