contacts.php 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <?php
  2. /* Copyright (C) 2012 Regis Houssin <regis.houssin@inodbox.com>
  3. * Copyright (C) 2020 Laurent Destailleur <eldy@users.sourceforge.net>
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 3 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  17. */
  18. /**
  19. * \file htdocs/core/ajax/contacts.php
  20. * \brief File to load contacts combobox
  21. */
  22. if (!defined('NOTOKENRENEWAL')) {
  23. define('NOTOKENRENEWAL', '1'); // Disables token renewal
  24. }
  25. if (!defined('NOREQUIREMENU')) {
  26. define('NOREQUIREMENU', '1');
  27. }
  28. if (!defined('NOREQUIREAJAX')) {
  29. define('NOREQUIREAJAX', '1');
  30. }
  31. require '../../main.inc.php';
  32. $id = GETPOST('id', 'int'); // id of thirdparty
  33. $action = GETPOST('action', 'aZ09');
  34. $htmlname = GETPOST('htmlname', 'alpha');
  35. $showempty = GETPOST('showempty', 'int');
  36. // Security check
  37. $result = restrictedArea($user, 'societe', $id, '&societe', '', 'fk_soc', 'rowid', 0);
  38. /*
  39. * View
  40. */
  41. top_httphead();
  42. //print '<!-- Ajax page called with url '.dol_escape_htmltag($_SERVER["PHP_SELF"]).'?'.dol_escape_htmltag($_SERVER["QUERY_STRING"]).' -->'."\n";
  43. // Load original field value
  44. if (!empty($id) && !empty($action) && !empty($htmlname)) {
  45. $form = new Form($db);
  46. $return = array();
  47. if (empty($showempty)) {
  48. $showempty = 0;
  49. }
  50. $return['value'] = $form->selectcontacts($id, '', $htmlname, $showempty, '', '', 0, '', true);
  51. $return['num'] = $form->num;
  52. $return['error'] = $form->error;
  53. echo json_encode($return);
  54. }