contacts.php 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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. // Load Dolibarr environment
  32. require '../../main.inc.php';
  33. $id = GETPOST('id', 'int'); // id of thirdparty
  34. $action = GETPOST('action', 'aZ09');
  35. $htmlname = GETPOST('htmlname', 'alpha');
  36. $showempty = GETPOST('showempty', 'int');
  37. // Security check
  38. $result = restrictedArea($user, 'societe', $id, '&societe', '', 'fk_soc', 'rowid', 0);
  39. /*
  40. * View
  41. */
  42. top_httphead();
  43. //print '<!-- Ajax page called with url '.dol_escape_htmltag($_SERVER["PHP_SELF"]).'?'.dol_escape_htmltag($_SERVER["QUERY_STRING"]).' -->'."\n";
  44. // Load original field value
  45. if (!empty($id) && !empty($action) && !empty($htmlname)) {
  46. $form = new Form($db);
  47. $return = array();
  48. if (empty($showempty)) {
  49. $showempty = 0;
  50. }
  51. $return['value'] = $form->selectcontacts($id, '', $htmlname, $showempty, '', '', 0, '', true);
  52. $return['num'] = $form->num;
  53. $return['error'] = $form->error;
  54. echo json_encode($return);
  55. }