Skip to content

Commit

Permalink
new :new column into extrafeild table to get update create information
Browse files Browse the repository at this point in the history
  • Loading branch information
atm-florian committed Jul 25, 2017
1 parent 73c7aa3 commit d2ecebd
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 8 deletions.
41 changes: 34 additions & 7 deletions htdocs/core/class/extrafields.class.php
Expand Up @@ -281,7 +281,7 @@ private function create($attrname, $type='varchar', $length=255, $elementtype='m
*/
private function create_label($attrname, $label='', $type='', $pos=0, $size=0, $elementtype='member', $unique=0, $required=0, $param='', $alwayseditable=0, $perms='', $list=0, $ishidden=0, $default='', $computed='')
{
global $conf;
global $conf,$user;

if ($elementtype == 'thirdparty') $elementtype='societe';
if ($elementtype == 'contact') $elementtype='socpeople';
Expand All @@ -305,7 +305,26 @@ private function create_label($attrname, $label='', $type='', $pos=0, $size=0, $
$params='';
}

$sql = "INSERT INTO ".MAIN_DB_PREFIX."extrafields(name, label, type, pos, size, entity, elementtype, fieldunique, fieldrequired, param, alwayseditable, perms, list, ishidden, fielddefault, fieldcomputed)";
$sql = "INSERT INTO ".MAIN_DB_PREFIX."extrafields(";
$sql.= " name,";
$sql.= " label,";
$sql.= " type,";
$sql.= " pos,";
$sql.= " size,";
$sql.= " elementtype,";
$sql.= " fieldunique,";
$sql.= " fieldrequired,";
$sql.= " param,";
$sql.= " alwayseditable,";
$sql.= " perms,";
$sql.= " list,";
$sql.= " ishidden,";
$sql.= " fielddefault,";
$sql.= " fieldcomputed,";
$sql.= " fk_user_author,";
$sql.= " fk_user_modif,";
$sql.= " datec";
$sql.= " )";
$sql.= " VALUES('".$attrname."',";
$sql.= " '".$this->db->escape($label)."',";
$sql.= " '".$type."',";
Expand All @@ -321,8 +340,10 @@ private function create_label($attrname, $label='', $type='', $pos=0, $size=0, $
$sql.= " ".$list.",";
$sql.= " ".$ishidden.",";
$sql.= " ".($default?"'".$this->db->escape($default)."'":"null").",";
$sql.= " ".($computed?"'".$this->db->escape($computed)."'":"null");
$sql.=')';
$sql.= " ".($computed?"'".$this->db->escape($computed)."'":"null").",";
$sql .= " " . $user->id . ",";
$sql .= " " . $user->id . ",";
$sql .= "'" . $this->db->idate(dol_now()) . "'";

dol_syslog(get_class($this)."::create_label", LOG_DEBUG);
if ($this->db->query($sql))
Expand Down Expand Up @@ -562,7 +583,7 @@ function update($attrname,$label,$type,$length,$elementtype,$unique=0,$required=
*/
private function update_label($attrname,$label,$type,$size,$elementtype,$unique=0,$required=0,$pos=0,$param='',$alwayseditable=0,$perms='',$list=0,$ishidden=0,$default='',$computed='')
{
global $conf;
global $conf, $user;
dol_syslog(get_class($this)."::update_label ".$attrname.", ".$label.", ".$type.", ".$size.", ".$elementtype.", ".$unique.", ".$required.", ".$pos.", ".$alwayseditable.", ".$perms.", ".$list.", ".$ishidden.", ".$default.", ".$computed);

// Clean parameters
Expand Down Expand Up @@ -603,7 +624,10 @@ private function update_label($attrname,$label,$type,$size,$elementtype,$unique=
$sql.= " list,";
$sql.= " ishidden,";
$sql.= " fielddefault,";
$sql.= " fieldcomputed";
$sql.= " fieldcomputed,";
$sql.= " fk_user_author,";
$sql.= " fk_user_modif,";
$sql.= " datec";
$sql.= ") VALUES (";
$sql.= "'".$attrname."',";
$sql.= " ".$conf->entity.",";
Expand All @@ -620,7 +644,10 @@ private function update_label($attrname,$label,$type,$size,$elementtype,$unique=
$sql.= " ".$list.", ";
$sql.= " ".$ishidden.", ";
$sql.= " ".($default?"'".$this->db->escape($default)."'":"null").",";
$sql.= " ".($computed?"'".$this->db->escape($computed)."'":"null");
$sql.= " ".($computed?"'".$this->db->escape($computed)."'":"null").",";
$sql .= " " . $user->id . ",";
$sql .= " " . $user->id . ",";
$sql .= "'" . $this->db->idate(dol_now()) . "'";
$sql.= ")";

$resql2=$this->db->query($sql);
Expand Down
6 changes: 5 additions & 1 deletion htdocs/install/mysql/tables/llx_extrafields.sql
Expand Up @@ -37,5 +37,9 @@ create table llx_extrafields
param text, -- extra parameters to define possible values of field
list integer DEFAULT 0, -- list of values for field that are combo lists
langs varchar(24), -- example: fileofmymodule@mymodule
ishidden integer DEFAULT 0 -- ??? example of use case ???
ishidden integer DEFAULT 0, -- Can be foreign key of external system
fk_user_author integer, -- user making creation
fk_user_modif integer, -- user making last change
datec datetime, -- date de creation
tms timestamp
)ENGINE=innodb;
1 change: 1 addition & 0 deletions htdocs/install/pgsql/functions/functions.sql
Expand Up @@ -165,6 +165,7 @@ CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_usergroup_extrafield
CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_product_price_by_qty FOR EACH ROW EXECUTE PROCEDURE update_modified_column_tms();
CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_website FOR EACH ROW EXECUTE PROCEDURE update_modified_column_tms();
CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_website_page FOR EACH ROW EXECUTE PROCEDURE update_modified_column_tms();
CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_extrafields FOR EACH ROW EXECUTE PROCEDURE update_modified_column_tms();


-- Add triggers for timestamp fields named date_m
Expand Down

0 comments on commit d2ecebd

Please sign in to comment.