2010-05-03 08:43:32 +00:00
< ? php
2012-01-27 14:17:36 +00:00
/* Copyright ( C ) 2008 - 2012 Laurent Destailleur < eldy @ users . sourceforge . net >
2016-04-16 19:33:23 +00:00
* Copyright ( C ) 2016 Marcos García < marcosgdf @ gmail . com >
2024-10-15 13:38:43 +00:00
* Copyright ( C ) 2024 MDW < mdeweerd @ users . noreply . github . com >
2010-05-03 08:43:32 +00:00
*
* This program is free software ; you can redistribute it and / or modify
* it under the terms of the GNU General Public License as published by
2013-01-16 14:36:08 +00:00
* the Free Software Foundation ; either version 3 of the License , or
2010-05-03 08:43:32 +00:00
* ( at your option ) any later version .
*
* This program is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU General Public License for more details .
*
* You should have received a copy of the GNU General Public License
2019-09-23 19:55:30 +00:00
* along with this program . If not , see < https :// www . gnu . org / licenses />.
2010-05-03 08:43:32 +00:00
*/
/**
2010-06-07 23:52:43 +00:00
* \file htdocs / core / class / html . formorder . class . php
2010-11-22 09:18:53 +00:00
* \ingroup core
2010-05-03 08:43:32 +00:00
* \brief File of predefined functions for HTML forms for order module
*/
2020-04-10 08:59:32 +00:00
require_once DOL_DOCUMENT_ROOT . '/core/class/html.form.class.php' ;
2024-02-20 01:12:06 +00:00
require_once DOL_DOCUMENT_ROOT . '/commande/class/commande.class.php' ;
2010-05-03 08:43:32 +00:00
/**
2014-04-02 12:53:42 +00:00
* Class to manage HTML output components for orders
* Before adding component here , check they are not into common part Form . class . php
2010-05-03 08:43:32 +00:00
*/
2016-04-16 19:33:23 +00:00
class FormOrder extends Form
2010-05-03 08:43:32 +00:00
{
2020-10-31 13:32:18 +00:00
/**
2024-01-13 18:48:20 +00:00
* Return combo list of different statuses of orders
2020-10-31 13:32:18 +00:00
*
* @ param string $selected Preselected value
* @ param int $short Use short labels
2024-10-15 13:38:43 +00:00
* @ param string $htmlname Name of HTML select element
2023-11-24 15:30:31 +00:00
* @ param string $morecss More CSS
2024-10-14 20:35:28 +00:00
* @ param int $multi Use a multiselect
2020-10-31 13:32:18 +00:00
* @ return void
*/
2024-10-15 13:38:43 +00:00
public function selectSupplierOrderStatus ( $selected = '' , $short = 0 , $htmlname = 'order_status' , $morecss = '' , $multi = 1 )
2020-10-31 13:32:18 +00:00
{
$options = array ();
// 7 is same label than 6. 8 does not exists (billed is another field)
$statustohow = array (
'0' => '0' ,
'1' => '1' ,
'2' => '2' ,
'3' => '3' ,
'4' => '4' ,
'5' => '5' ,
'6' => '6,7' ,
'9' => '9'
);
$tmpsupplierorder = new CommandeFournisseur ( $this -> db );
foreach ( $statustohow as $key => $value ) {
$tmpsupplierorder -> statut = $key ;
2024-10-14 20:35:28 +00:00
$tmpsupplierorder -> status = $key ;
2020-10-31 13:32:18 +00:00
$options [ $value ] = $tmpsupplierorder -> getLibStatut ( $short );
}
2021-02-23 21:03:23 +00:00
if ( is_array ( $selected )) {
$selectedarray = $selected ;
} else {
$selectedarray = explode ( ',' , $selected );
}
2020-11-26 16:53:57 +00:00
2024-10-14 20:35:28 +00:00
if ( ! empty ( $selectedarray [ 6 ])) { // special case for status '6,7'
unset ( $selectedarray [ 6 ]);
unset ( $selectedarray [ 7 ]);
2024-10-15 13:38:43 +00:00
$selectedarray [ '6,7' ] = '6,7' ;
2024-10-14 20:35:28 +00:00
}
if ( $multi ) {
2024-10-15 13:38:43 +00:00
print Form :: multiselectarray ( $htmlname , $options , $selectedarray , 0 , 0 , $morecss , 0 , 0 );
2024-10-14 20:35:28 +00:00
} else {
2024-10-15 13:38:43 +00:00
print Form :: selectarray ( $htmlname , $options , $selectedarray , 0 , 0 , 0 , '' , 0 , 0 , 0 , '' , $morecss ); // $selectedarray is ok for $id param @phan-suppress-current-line PhanPluginSuspiciousParamOrder
2024-10-14 20:35:28 +00:00
}
2024-02-20 01:12:06 +00:00
}
/**
* Return combo list of different status of orders
*
* @ param string $selected Preselected value
* @ param int $short Use short labels
2024-10-15 13:38:43 +00:00
* @ param string $htmlname Name of HTML select element
2024-02-20 01:12:06 +00:00
* @ return void
*/
2024-10-15 13:38:43 +00:00
public function selectOrderStatus ( $selected = '' , $short = 0 , $htmlname = 'order_status' )
2024-02-20 01:12:06 +00:00
{
$options = array ();
$statustohow = array (
Commande :: STATUS_DRAFT ,
Commande :: STATUS_VALIDATED ,
Commande :: STATUS_SHIPMENTONPROCESS ,
Commande :: STATUS_CLOSED ,
Commande :: STATUS_CANCELED
);
$tmpsupplierorder = new Commande ( $this -> db );
foreach ( $statustohow as $value ) {
2025-10-01 11:44:19 +00:00
$tmpsupplierorder -> status = $value ;
2024-02-20 01:12:06 +00:00
$options [ $value ] = $tmpsupplierorder -> getLibStatut ( $short );
}
if ( is_array ( $selected )) {
$selectedarray = $selected ;
} else {
$selectedarray = explode ( ',' , $selected );
}
2024-10-15 13:38:43 +00:00
print Form :: multiselectarray ( $htmlname , $options , $selectedarray , 0 , 0 , '' , 0 , 150 );
2020-12-01 01:41:19 +00:00
}
2014-04-02 12:53:42 +00:00
2010-05-03 08:43:32 +00:00
/**
2014-04-02 12:53:42 +00:00
* Return list of input method ( mode used to receive order , like order received by email , fax , online )
2014-05-01 14:26:57 +00:00
* List found into table c_input_method .
2010-05-03 08:43:32 +00:00
*
2012-01-27 14:17:36 +00:00
* @ param string $selected Id of preselected input method
* @ param string $htmlname Name of HTML select list
2014-04-02 12:53:42 +00:00
* @ param int $addempty 0 = list with no empty value , 1 = list with empty value
2023-12-01 18:51:32 +00:00
* @ return int Return integer < 0 if KO , > 0 if OK
2010-05-03 08:43:32 +00:00
*/
2019-01-27 14:20:16 +00:00
public function selectInputMethod ( $selected = '' , $htmlname = 'source_id' , $addempty = 0 )
2010-05-03 08:43:32 +00:00
{
2016-04-16 19:33:23 +00:00
global $langs ;
2015-06-29 23:34:17 +00:00
2020-10-31 13:32:18 +00:00
$listofmethods = array ();
2015-06-29 23:34:17 +00:00
2011-02-23 15:09:01 +00:00
$sql = " SELECT rowid, code, libelle as label " ;
2022-01-27 09:19:35 +00:00
$sql .= " FROM " . $this -> db -> prefix () . " c_input_method " ;
2020-04-10 08:59:32 +00:00
$sql .= " WHERE active = 1 " ;
2010-05-03 08:43:32 +00:00
2014-06-12 09:31:53 +00:00
dol_syslog ( get_class ( $this ) . " ::selectInputMethod " , LOG_DEBUG );
2020-04-10 08:59:32 +00:00
$resql = $this -> db -> query ( $sql );
2016-04-16 19:33:23 +00:00
if ( ! $resql ) {
2010-05-03 08:43:32 +00:00
dol_print_error ( $this -> db );
return - 1 ;
}
2016-04-16 19:33:23 +00:00
while ( $obj = $this -> db -> fetch_object ( $resql )) {
$listofmethods [ $obj -> rowid ] = $langs -> trans ( $obj -> code ) != $obj -> code ? $langs -> trans ( $obj -> code ) : $obj -> label ;
}
2019-01-27 10:55:16 +00:00
print Form :: selectarray ( $htmlname , $listofmethods , $selected , $addempty );
2016-04-16 19:33:23 +00:00
2010-05-03 08:43:32 +00:00
return 1 ;
}
}