html.formorder.class.php 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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 <http://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. print Form::selectarray($hmlname, $options, $selected, 1);
  58. }
  59. /**
  60. * Return list of input method (mode used to receive order, like order received by email, fax, online)
  61. * List found into table c_input_method.
  62. *
  63. * @param string $selected Id of preselected input method
  64. * @param string $htmlname Name of HTML select list
  65. * @param int $addempty 0=list with no empty value, 1=list with empty value
  66. * @return array Tableau des sources de commandes
  67. */
  68. public function selectInputMethod($selected='',$htmlname='source_id',$addempty=0)
  69. {
  70. global $langs;
  71. $listofmethods=array();
  72. $sql = "SELECT rowid, code, libelle as label";
  73. $sql.= " FROM ".MAIN_DB_PREFIX."c_input_method";
  74. $sql.= " WHERE active = 1";
  75. dol_syslog(get_class($this)."::selectInputMethod", LOG_DEBUG);
  76. $resql=$this->db->query($sql);
  77. if (!$resql) {
  78. dol_print_error($this->db);
  79. return -1;
  80. }
  81. while ($obj = $this->db->fetch_object($resql)) {
  82. $listofmethods[$obj->rowid] = $langs->trans($obj->code) != $obj->code ? $langs->trans($obj->code) : $obj->label;
  83. }
  84. print Form::selectarray($htmlname,$listofmethods,$selected,$addempty);
  85. return 1;
  86. }
  87. }