projects.php 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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. // Mode to get list of projects
  56. if (empty($mode) || $mode != 'gettasks') {
  57. top_httphead('application/json');
  58. // When used from jQuery, the search term is added as GET param "term".
  59. $searchkey = (GETPOSTISSET($htmlname) ? GETPOST($htmlname, 'aZ09') : '');
  60. $formproject = new FormProjets($db);
  61. $arrayresult = $formproject->select_projects_list($socid, '', '', 0, 0, 1, $discard_closed, 0, 0, 1, $searchkey);
  62. $db->close();
  63. print json_encode($arrayresult);
  64. return;
  65. }
  66. // Mode to get list of tasks
  67. // THIS MODE RETURNS HTML NOT JSON - THE CALL SHOULD BE UPDATE IN THE FUTURE
  68. if ($mode == 'gettasks') {
  69. top_httphead();
  70. $formproject = new FormProjets($db);
  71. $formproject->selectTasks((!empty($socid) ? $socid : -1), 0, 'taskid', 24, 1, '1', 1, 0, 0, 'maxwidth500', GETPOST('projectid', 'int'), '');
  72. $db->close();
  73. return;
  74. }