contacts.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <?php
  2. /* Copyright (C) 2012 Regis Houssin <regis.houssin@inodbox.com>
  3. * Copyright (C) 2016 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 <http://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')) define('NOTOKENRENEWAL','1'); // Disables token renewal
  23. if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1');
  24. if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1');
  25. require '../../main.inc.php';
  26. $id = GETPOST('id','int');
  27. $action = GETPOST('action','alpha');
  28. $htmlname = GETPOST('htmlname','alpha');
  29. $showempty = GETPOST('showempty','int');
  30. /*
  31. * View
  32. */
  33. top_httphead();
  34. //print '<!-- Ajax page called with url '.dol_escape_htmltag($_SERVER["PHP_SELF"]).'?'.dol_escape_htmltag($_SERVER["QUERY_STRING"]).' -->'."\n";
  35. // Load original field value
  36. if (! empty($id) && ! empty($action) && ! empty($htmlname))
  37. {
  38. $form = new Form($db);
  39. $return=array();
  40. if (empty($showempty)) $showempty=0;
  41. $return['value'] = $form->selectcontacts($id,'',$htmlname,$showempty,'','',0,'',true);
  42. $return['num'] = $form->num;
  43. $return['error'] = $form->error;
  44. echo json_encode($return);
  45. }