html.formorder.class.php 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. <?php
  2. /* Copyright (C) 2008-2012 Laurent Destailleur <eldy@users.sourceforge.net>
  3. * Copyright (C) 2016 Marcos García <marcosgdf@gmail.com>
  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/class/html.formorder.class.php
  20. * \ingroup core
  21. * \brief File of predefined functions for HTML forms for order module
  22. */
  23. require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php';
  24. /**
  25. * Class to manage HTML output components for orders
  26. * Before adding component here, check they are not into common part Form.class.php
  27. */
  28. class FormOrder extends Form
  29. {
  30. /**
  31. * Return combo list of differents status of a orders
  32. *
  33. * @param string $selected Preselected value
  34. * @param int $short Use short labels
  35. * @param string $hmlname Name of HTML select element
  36. * @return void
  37. */
  38. public function selectSupplierOrderStatus($selected = '', $short = 0, $hmlname = 'order_status')
  39. {
  40. $options = array();
  41. // 7 is same label than 6. 8 does not exists (billed is another field)
  42. $statustohow = array(
  43. '0' => '0',
  44. '1' => '1',
  45. '2' => '2',
  46. '3' => '3',
  47. '4' => '4',
  48. '5' => '5',
  49. '6' => '6,7',
  50. '9' => '9'
  51. );
  52. $tmpsupplierorder = new CommandeFournisseur($this->db);
  53. foreach ($statustohow as $key => $value) {
  54. $tmpsupplierorder->statut = $key;
  55. $options[$value] = $tmpsupplierorder->getLibStatut($short);
  56. }
  57. if (is_array($selected)) {
  58. $selectedarray = $selected;
  59. } else {
  60. $selectedarray = explode(',', $selected);
  61. }
  62. print Form::multiselectarray($hmlname, $options, $selectedarray, 0);
  63. }
  64. /**
  65. * Return list of input method (mode used to receive order, like order received by email, fax, online)
  66. * List found into table c_input_method.
  67. *
  68. * @param string $selected Id of preselected input method
  69. * @param string $htmlname Name of HTML select list
  70. * @param int $addempty 0=list with no empty value, 1=list with empty value
  71. * @return int <0 if KO, >0 if OK
  72. */
  73. public function selectInputMethod($selected = '', $htmlname = 'source_id', $addempty = 0)
  74. {
  75. global $langs;
  76. $listofmethods = array();
  77. $sql = "SELECT rowid, code, libelle as label";
  78. $sql .= " FROM ".$this->db->prefix()."c_input_method";
  79. $sql .= " WHERE active = 1";
  80. dol_syslog(get_class($this)."::selectInputMethod", LOG_DEBUG);
  81. $resql = $this->db->query($sql);
  82. if (!$resql) {
  83. dol_print_error($this->db);
  84. return -1;
  85. }
  86. while ($obj = $this->db->fetch_object($resql)) {
  87. $listofmethods[$obj->rowid] = $langs->trans($obj->code) != $obj->code ? $langs->trans($obj->code) : $obj->label;
  88. }
  89. print Form::selectarray($htmlname, $listofmethods, $selected, $addempty);
  90. return 1;
  91. }
  92. }