Add extrafield tables
This commit is contained in:
parent
53f512b7dc
commit
4f43ec0acf
@ -5,6 +5,7 @@
|
|||||||
* Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be>
|
* Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be>
|
||||||
* Copyright (C) 2009-2012 Laurent Destailleur <eldy@users.sourceforge.net>
|
* Copyright (C) 2009-2012 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||||
* Copyright (C) 2009-2012 Regis Houssin <regis.houssin@capnetworks.com>
|
* Copyright (C) 2009-2012 Regis Houssin <regis.houssin@capnetworks.com>
|
||||||
|
* Copyright (C) 2013 Florian Henry <forian.henry@open-concept.pro>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -622,7 +623,7 @@ class ExtraFields
|
|||||||
$out = $formstat->select_date($value, 'options_'.$key, $showtime, $showtime, $required, '', 1, 1, 1, 0, 1);
|
$out = $formstat->select_date($value, 'options_'.$key, $showtime, $showtime, $required, '', 1, 1, 1, 0, 1);
|
||||||
//$out='<input type="text" name="options_'.$key.'" size="'.$showsize.'" maxlength="'.$newsize.'" value="'.$value.'"'.($moreparam?$moreparam:'').'>';
|
//$out='<input type="text" name="options_'.$key.'" size="'.$showsize.'" maxlength="'.$newsize.'" value="'.$value.'"'.($moreparam?$moreparam:'').'>';
|
||||||
}
|
}
|
||||||
elseif (in_array($type,array('int','double')))
|
elseif (in_array($type,array('int')))
|
||||||
{
|
{
|
||||||
$tmp=explode(',',$size);
|
$tmp=explode(',',$size);
|
||||||
$newsize=$tmp[0];
|
$newsize=$tmp[0];
|
||||||
@ -660,6 +661,13 @@ class ExtraFields
|
|||||||
{
|
{
|
||||||
$out='<input type="text" name="options_'.$key.'" size="6" value="'.price($value).'"> '.$langs->getCurrencySymbol($conf->currency);
|
$out='<input type="text" name="options_'.$key.'" size="6" value="'.price($value).'"> '.$langs->getCurrencySymbol($conf->currency);
|
||||||
}
|
}
|
||||||
|
elseif ($type == 'double')
|
||||||
|
{
|
||||||
|
if (!empty($value)) {
|
||||||
|
$value=price($value);
|
||||||
|
}
|
||||||
|
$out='<input type="text" name="options_'.$key.'" size="6" value="'.$value.'"> ';
|
||||||
|
}
|
||||||
elseif ($type == 'select')
|
elseif ($type == 'select')
|
||||||
{
|
{
|
||||||
$out='<select name="options_'.$key.'">';
|
$out='<select name="options_'.$key.'">';
|
||||||
@ -703,7 +711,13 @@ class ExtraFields
|
|||||||
while ($i < $num)
|
while ($i < $num)
|
||||||
{
|
{
|
||||||
$obj = $this->db->fetch_object($resql);
|
$obj = $this->db->fetch_object($resql);
|
||||||
$labeltoshow=dol_trunc($obj->$InfoFieldList[1],18);
|
$translabel=$langs->trans($obj->$InfoFieldList[1]);
|
||||||
|
if ($translabel!=$obj->$InfoFieldList[1]) {
|
||||||
|
$labeltoshow=dol_trunc($translabel,18);
|
||||||
|
}else {
|
||||||
|
$labeltoshow=dol_trunc($obj->$InfoFieldList[1],18);
|
||||||
|
}
|
||||||
|
|
||||||
if ($value==$obj->rowid)
|
if ($value==$obj->rowid)
|
||||||
{
|
{
|
||||||
$out.='<option value="'.$obj->rowid.'" selected="selected">'.$labeltoshow.'</option>';
|
$out.='<option value="'.$obj->rowid.'" selected="selected">'.$labeltoshow.'</option>';
|
||||||
@ -790,6 +804,12 @@ class ExtraFields
|
|||||||
{
|
{
|
||||||
$showsize=10;
|
$showsize=10;
|
||||||
}
|
}
|
||||||
|
elseif ($type == 'double')
|
||||||
|
{
|
||||||
|
if (!empty($value)) {
|
||||||
|
$value=price($value);
|
||||||
|
}
|
||||||
|
}
|
||||||
elseif ($type == 'boolean')
|
elseif ($type == 'boolean')
|
||||||
{
|
{
|
||||||
$checked='';
|
$checked='';
|
||||||
@ -832,7 +852,13 @@ class ExtraFields
|
|||||||
if ($resql)
|
if ($resql)
|
||||||
{
|
{
|
||||||
$obj = $this->db->fetch_object($resql);
|
$obj = $this->db->fetch_object($resql);
|
||||||
$value=$obj->$InfoFieldList[1];
|
$translabel=$langs->trans($obj->$InfoFieldList[1]);
|
||||||
|
if ($translabel!=$obj->$InfoFieldList[1]) {
|
||||||
|
$value=dol_trunc($translabel,18);
|
||||||
|
}else {
|
||||||
|
$value=$obj->$InfoFieldList[1];
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
elseif ($type == 'radio')
|
elseif ($type == 'radio')
|
||||||
@ -900,6 +926,11 @@ class ExtraFields
|
|||||||
$value_arr=GETPOST("options_".$key);
|
$value_arr=GETPOST("options_".$key);
|
||||||
$value_key=implode($value_arr,',');
|
$value_key=implode($value_arr,',');
|
||||||
}
|
}
|
||||||
|
else if (in_array($key_type,array('price','double')))
|
||||||
|
{
|
||||||
|
$value_arr=GETPOST("options_".$key);
|
||||||
|
$value_key=price2num($value_arr);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$value_key=GETPOST("options_".$key);
|
$value_key=GETPOST("options_".$key);
|
||||||
@ -913,5 +944,51 @@ class ExtraFields
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* return array_options array for object by extrafields value (using for data send by forms)
|
||||||
|
*
|
||||||
|
* @param array $extralabels $array of extrafields
|
||||||
|
* @return int 1 if array_options set / 0 if no value
|
||||||
|
*/
|
||||||
|
function getOptionalsFromPost($extralabels)
|
||||||
|
{
|
||||||
|
global $_POST;
|
||||||
|
|
||||||
|
$array_options = array();
|
||||||
|
if (is_array($extralabels))
|
||||||
|
{
|
||||||
|
// Get extra fields
|
||||||
|
foreach ($extralabels as $key => $value)
|
||||||
|
{
|
||||||
|
$key_type = $this->attribute_type[$key];
|
||||||
|
|
||||||
|
if (in_array($key_type,array('date','datetime')))
|
||||||
|
{
|
||||||
|
// Clean parameters
|
||||||
|
$value_key=dol_mktime($_POST["options_".$key."hour"], $_POST["options_".$key."min"], 0, $_POST["options_".$key."month"], $_POST["options_".$key."day"], $_POST["options_".$key."year"]);
|
||||||
|
}
|
||||||
|
else if (in_array($key_type,array('checkbox')))
|
||||||
|
{
|
||||||
|
$value_arr=GETPOST("options_".$key);
|
||||||
|
$value_key=implode($value_arr,',');
|
||||||
|
}
|
||||||
|
else if (in_array($key_type,array('price','double')))
|
||||||
|
{
|
||||||
|
$value_arr=GETPOST("options_".$key);
|
||||||
|
$value_key=price2num($value_arr);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$value_key=GETPOST("options_".$key);
|
||||||
|
}
|
||||||
|
$array_options["options_".$key]=$value_key;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $array_options;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|||||||
@ -32,4 +32,34 @@ create table llx_fichinter_extrafields
|
|||||||
|
|
||||||
ALTER TABLE llx_fichinter_extrafields ADD INDEX idx_ficheinter_extrafields (fk_object);
|
ALTER TABLE llx_fichinter_extrafields ADD INDEX idx_ficheinter_extrafields (fk_object);
|
||||||
|
|
||||||
|
create table llx_commandedet_extrafields
|
||||||
|
(
|
||||||
|
rowid integer AUTO_INCREMENT PRIMARY KEY,
|
||||||
|
tms timestamp,
|
||||||
|
fk_object integer NOT NULL,
|
||||||
|
import_key varchar(14)
|
||||||
|
)ENGINE=innodb;
|
||||||
|
|
||||||
|
ALTER TABLE llx_commandedet_extrafields ADD INDEX idx_commandedet_extrafields (fk_object);
|
||||||
|
|
||||||
|
create table llx_facturedet_extrafields
|
||||||
|
(
|
||||||
|
rowid integer AUTO_INCREMENT PRIMARY KEY,
|
||||||
|
tms timestamp,
|
||||||
|
fk_object integer NOT NULL, -- object id
|
||||||
|
import_key varchar(14) -- import key
|
||||||
|
)ENGINE=innodb;
|
||||||
|
|
||||||
|
ALTER TABLE llx_facturedet_extrafields ADD INDEX idx_facturedet_extrafields (fk_object);
|
||||||
|
|
||||||
|
create table llx_propaldet_extrafields
|
||||||
|
(
|
||||||
|
rowid integer AUTO_INCREMENT PRIMARY KEY,
|
||||||
|
tms timestamp,
|
||||||
|
fk_object integer NOT NULL, -- object id
|
||||||
|
import_key varchar(14) -- import key
|
||||||
|
)ENGINE=innodb;
|
||||||
|
|
||||||
|
ALTER TABLE llx_propaldet_extrafields ADD INDEX idx_propaldet_extrafields (fk_object);
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
24
htdocs/install/mysql/tables/llx_commandedet_extrafields.key.sql
Executable file
24
htdocs/install/mysql/tables/llx_commandedet_extrafields.key.sql
Executable file
@ -0,0 +1,24 @@
|
|||||||
|
-- ===================================================================
|
||||||
|
-- Copyright (C) 2002-2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||||
|
-- Copyright (C) 2002-2003 Jean-Louis Bergamo <jlb@j1b.org>
|
||||||
|
-- Copyright (C) 2009 Regis Houssin <regis.houssin@capnetworks.com>
|
||||||
|
-- Copyright (C) 2011 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||||
|
-- Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
|
||||||
|
--
|
||||||
|
-- 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
|
||||||
|
-- the Free Software Foundation; either version 3 of the License, or
|
||||||
|
-- (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
|
||||||
|
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
--
|
||||||
|
-- ===================================================================
|
||||||
|
|
||||||
|
|
||||||
|
ALTER TABLE llx_commandedet_extrafields ADD INDEX idx_commandedet_extrafields (fk_object);
|
||||||
25
htdocs/install/mysql/tables/llx_commandedet_extrafields.sql
Executable file
25
htdocs/install/mysql/tables/llx_commandedet_extrafields.sql
Executable file
@ -0,0 +1,25 @@
|
|||||||
|
-- ===================================================================
|
||||||
|
-- Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
|
||||||
|
--
|
||||||
|
-- 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
|
||||||
|
-- the Free Software Foundation; either version 3 of the License, or
|
||||||
|
-- (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
|
||||||
|
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
--
|
||||||
|
-- ===================================================================
|
||||||
|
|
||||||
|
create table llx_commandedet_extrafields
|
||||||
|
(
|
||||||
|
rowid integer AUTO_INCREMENT PRIMARY KEY,
|
||||||
|
tms timestamp,
|
||||||
|
fk_object integer NOT NULL, -- object id
|
||||||
|
import_key varchar(14) -- import key
|
||||||
|
)ENGINE=innodb;
|
||||||
20
htdocs/install/mysql/tables/llx_facturedet_extrafields.key.sql
Executable file
20
htdocs/install/mysql/tables/llx_facturedet_extrafields.key.sql
Executable file
@ -0,0 +1,20 @@
|
|||||||
|
-- ===================================================================
|
||||||
|
-- Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
|
||||||
|
--
|
||||||
|
-- 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
|
||||||
|
-- the Free Software Foundation; either version 3 of the License, or
|
||||||
|
-- (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
|
||||||
|
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
--
|
||||||
|
-- ===================================================================
|
||||||
|
|
||||||
|
|
||||||
|
ALTER TABLE llx_facturedet_extrafields ADD INDEX idx_facturedet_extrafields (fk_object);
|
||||||
25
htdocs/install/mysql/tables/llx_facturedet_extrafields.sql
Executable file
25
htdocs/install/mysql/tables/llx_facturedet_extrafields.sql
Executable file
@ -0,0 +1,25 @@
|
|||||||
|
-- ===================================================================
|
||||||
|
-- Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
|
||||||
|
--
|
||||||
|
-- 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
|
||||||
|
-- the Free Software Foundation; either version 3 of the License, or
|
||||||
|
-- (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
|
||||||
|
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
--
|
||||||
|
-- ===================================================================
|
||||||
|
|
||||||
|
create table llx_facturedet_extrafields
|
||||||
|
(
|
||||||
|
rowid integer AUTO_INCREMENT PRIMARY KEY,
|
||||||
|
tms timestamp,
|
||||||
|
fk_object integer NOT NULL, -- object id
|
||||||
|
import_key varchar(14) -- import key
|
||||||
|
)ENGINE=innodb;
|
||||||
20
htdocs/install/mysql/tables/llx_propaldet_extrafields.key.sql
Executable file
20
htdocs/install/mysql/tables/llx_propaldet_extrafields.key.sql
Executable file
@ -0,0 +1,20 @@
|
|||||||
|
-- ===================================================================
|
||||||
|
-- Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
|
||||||
|
--
|
||||||
|
-- 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
|
||||||
|
-- the Free Software Foundation; either version 3 of the License, or
|
||||||
|
-- (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
|
||||||
|
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
--
|
||||||
|
-- ===================================================================
|
||||||
|
|
||||||
|
|
||||||
|
ALTER TABLE llx_propaldet_extrafields ADD INDEX idx_propaldet_extrafields (fk_object);
|
||||||
25
htdocs/install/mysql/tables/llx_propaldet_extrafields.sql
Executable file
25
htdocs/install/mysql/tables/llx_propaldet_extrafields.sql
Executable file
@ -0,0 +1,25 @@
|
|||||||
|
-- ===================================================================
|
||||||
|
-- Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
|
||||||
|
--
|
||||||
|
-- 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
|
||||||
|
-- the Free Software Foundation; either version 3 of the License, or
|
||||||
|
-- (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
|
||||||
|
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
--
|
||||||
|
-- ===================================================================
|
||||||
|
|
||||||
|
create table llx_propaldet_extrafields
|
||||||
|
(
|
||||||
|
rowid integer AUTO_INCREMENT PRIMARY KEY,
|
||||||
|
tms timestamp,
|
||||||
|
fk_object integer NOT NULL, -- object id
|
||||||
|
import_key varchar(14) -- import key
|
||||||
|
)ENGINE=innodb;
|
||||||
Loading…
Reference in New Issue
Block a user