NEW ModuleBuilder can generate code of class from an existing SQL table
This commit is contained in:
parent
edaa111461
commit
fe6dcb2269
@ -294,6 +294,7 @@ ErrorFailedToLoadThirdParty=Failed to find/load thirdparty from id=%s, email=%s,
|
||||
ErrorThisPaymentModeIsNotSepa=This payment mode is not a bank account
|
||||
ErrorStripeCustomerNotFoundCreateFirst=Stripe customer is not set for this thirdparty (or set to a value deleted on Stripe side). Create (or re-attach) it first.
|
||||
ErrorCharPlusNotSupportedByImapForSearch=IMAP search is not able to search into sender or recipient for a string containing the character +
|
||||
ErrorTableNotFound=Table <b>%s</b> not found
|
||||
|
||||
# Warnings
|
||||
WarningParamUploadMaxFileSizeHigherThanPostMaxSize=Your PHP parameter upload_max_filesize (%s) is higher than PHP parameter post_max_size (%s). This is not a consistent setup.
|
||||
|
||||
@ -133,9 +133,9 @@ UseSpecificEditorURL = Use a specific editor URL
|
||||
UseSpecificFamily = Use a specific family
|
||||
UseSpecificAuthor = Use a specific author
|
||||
UseSpecificVersion = Use a specific initial version
|
||||
IncludeRefGeneration=The reference of object must be generated automatically by custom numbering rules
|
||||
IncludeRefGeneration=The reference of this object must be generated automatically by custom numbering rules
|
||||
IncludeRefGenerationHelp=Check this if you want to include code to manage the generation of the reference automatically using custom numbering rules
|
||||
IncludeDocGeneration=I want to generate some documents from templates for the object
|
||||
IncludeDocGeneration=I want the feature to generate some documents (PDF, ODT) from templates for this object
|
||||
IncludeDocGenerationHelp=If you check this, some code will be generated to add a "Generate document" box on the record.
|
||||
ShowOnCombobox=Show value into combobox
|
||||
KeyForTooltip=Key for tooltip
|
||||
@ -156,4 +156,7 @@ LinkToParentMenu=Parent menu (fk_xxxxmenu)
|
||||
ListOfTabsEntries=List of tab entries
|
||||
TabsDefDesc=Define here the tabs provided by your module
|
||||
TabsDefDescTooltip=The tabs provided by your module/application are defined into the array <strong>$this->tabs</strong> into the module descriptor file. You can edit manually this file or use the embedded editor.
|
||||
BadValueForType=Bad value for type %s
|
||||
BadValueForType=Bad value for type %s
|
||||
DefinePropertiesFromExistingTable=Define properties from an existing table
|
||||
DefinePropertiesFromExistingTableDesc=If a table in the database (for the object to create) already exists, you can use it to define the properties of the object.
|
||||
DefinePropertiesFromExistingTableDesc2=Keep empty if not table exists. The code generator will use different kinds of fields to build an example of table that you can edit later.
|
||||
|
||||
@ -894,238 +894,7 @@ if ($dirins && $action == 'confirm_removefile' && !empty($module)) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Build the $fields array from SQL table (initfromtablename)
|
||||
if ($dirins && $action == 'initobject' && $module && GETPOST('createtablearray', 'alpha')) {
|
||||
$tablename = GETPOST('initfromtablename', 'alpha');
|
||||
$_results = $db->DDLDescTable($tablename);
|
||||
if (empty($_results)) {
|
||||
setEventMessages($langs->trans("ErrorTableNotFound", $tablename), null, 'errors');
|
||||
} else {
|
||||
/**
|
||||
* 'type' field format ('integer', 'integer:ObjectClass:PathToClass[:AddCreateButtonOrNot[:Filter[:Sortfield]]]', 'sellist:TableName:LabelFieldName[:KeyFieldName[:KeyFieldParent[:Filter[:Sortfield]]]]', 'varchar(x)', 'double(24,8)', 'real', 'price', 'text', 'text:none', 'html', 'date', 'datetime', 'timestamp', 'duration', 'mail', 'phone', 'url', 'password')
|
||||
* Note: Filter can be a string like "(t.ref:like:'SO-%') or (t.date_creation:<:'20160101') or (t.nature:is:NULL)"
|
||||
* 'label' the translation key.
|
||||
* 'picto' is code of a picto to show before value in forms
|
||||
* 'enabled' is a condition when the field must be managed (Example: 1 or '$conf->global->MY_SETUP_PARAM' or 'isModEnabled("multicurrency")' ...)
|
||||
* 'position' is the sort order of field.
|
||||
* 'notnull' is set to 1 if not null in database. Set to -1 if we must set data to null if empty ('' or 0).
|
||||
* 'visible' says if field is visible in list (Examples: 0=Not visible, 1=Visible on list and create/update/view forms, 2=Visible on list only, 3=Visible on create/update/view form only (not list), 4=Visible on list and update/view form only (not create). 5=Visible on list and view only (not create/not update). Using a negative value means field is not shown by default on list but can be selected for viewing)
|
||||
* 'noteditable' says if field is not editable (1 or 0)
|
||||
* 'alwayseditable' says if field can be modified also when status is not draft ('1' or '0')
|
||||
* 'default' is a default value for creation (can still be overwrote by the Setup of Default Values if field is editable in creation form). Note: If default is set to '(PROV)' and field is 'ref', the default value will be set to '(PROVid)' where id is rowid when a new record is created.
|
||||
* 'index' if we want an index in database.
|
||||
* 'foreignkey'=>'tablename.field' if the field is a foreign key (it is recommanded to name the field fk_...).
|
||||
* 'searchall' is 1 if we want to search in this field when making a search from the quick search button.
|
||||
* 'isameasure' must be set to 1 or 2 if field can be used for measure. Field type must be summable like integer or double(24,8). Use 1 in most cases, or 2 if you don't want to see the column total into list (for example for percentage)
|
||||
* 'css' and 'cssview' and 'csslist' is the CSS style to use on field. 'css' is used in creation and update. 'cssview' is used in view mode. 'csslist' is used for columns in lists. For example: 'css'=>'minwidth300 maxwidth500 widthcentpercentminusx', 'cssview'=>'wordbreak', 'csslist'=>'tdoverflowmax200'
|
||||
* 'help' is a 'TranslationString' to use to show a tooltip on field. You can also use 'TranslationString:keyfortooltiponlick' for a tooltip on click.
|
||||
* 'showoncombobox' if value of the field must be visible into the label of the combobox that list record
|
||||
* 'disabled' is 1 if we want to have the field locked by a 'disabled' attribute. In most cases, this is never set into the definition of $fields into class, but is set dynamically by some part of code.
|
||||
* 'arrayofkeyval' to set a list of values if type is a list of predefined values. For example: array("0"=>"Draft","1"=>"Active","-1"=>"Cancel"). Note that type can be 'integer' or 'varchar'
|
||||
* 'autofocusoncreate' to have field having the focus on a create form. Only 1 field should have this property set to 1.
|
||||
* 'comment' is not used. You can store here any text of your choice. It is not used by application.
|
||||
* 'validate' is 1 if need to validate with $this->validateField()
|
||||
* 'copytoclipboard' is 1 or 2 to allow to add a picto to copy value into clipboard (1=picto after label, 2=picto after value)
|
||||
*/
|
||||
|
||||
/*public $fields=array(
|
||||
'rowid' =>array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'index'=>1, 'position'=>1, 'comment'=>'Id'),
|
||||
'ref' =>array('type'=>'varchar(128)', 'label'=>'Ref', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>10, 'searchall'=>1, 'comment'=>'Reference of object'),
|
||||
'entity' =>array('type'=>'integer', 'label'=>'Entity', 'enabled'=>1, 'visible'=>0, 'default'=>1, 'notnull'=>1, 'index'=>1, 'position'=>20),
|
||||
'label' =>array('type'=>'varchar(255)', 'label'=>'Label', 'enabled'=>1, 'visible'=>1, 'position'=>30, 'searchall'=>1, 'css'=>'minwidth200', 'help'=>'Help text', 'alwayseditable'=>'1'),
|
||||
'amount' =>array('type'=>'double(24,8)', 'label'=>'Amount', 'enabled'=>1, 'visible'=>1, 'default'=>'null', 'position'=>40, 'searchall'=>0, 'isameasure'=>1, 'help'=>'Help text'),
|
||||
'fk_soc' =>array('type'=>'integer:Societe:societe/class/societe.class.php', 'label'=>'ThirdParty', 'visible'=>1, 'enabled'=>1, 'position'=>50, 'notnull'=>-1, 'index'=>1, 'searchall'=>1, 'help'=>'LinkToThirdparty'),
|
||||
'description' =>array('type'=>'text', 'label'=>'Descrption', 'enabled'=>1, 'visible'=>0, 'position'=>60),
|
||||
'note_public' =>array('type'=>'html', 'label'=>'NotePublic', 'enabled'=>1, 'visible'=>0, 'position'=>61),
|
||||
'note_private' =>array('type'=>'html', 'label'=>'NotePrivate', 'enabled'=>1, 'visible'=>0, 'position'=>62),
|
||||
'date_creation' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>500),
|
||||
'tms' =>array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>501),
|
||||
//'date_valid' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-2, 'position'=>502),
|
||||
'fk_user_creat' =>array('type'=>'integer', 'label'=>'UserAuthor', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>510),
|
||||
'fk_user_modif' =>array('type'=>'integer', 'label'=>'UserModif', 'enabled'=>1, 'visible'=>-2, 'notnull'=>-1, 'position'=>511),
|
||||
//'fk_user_valid' =>array('type'=>'integer', 'label'=>'UserValidation', 'enabled'=>1, 'visible'=>-1, 'position'=>512),
|
||||
'import_key' =>array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>1, 'visible'=>-2, 'notnull'=>-1, 'index'=>0, 'position'=>1000),
|
||||
'status' =>array('type'=>'integer', 'label'=>'Status', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'default'=>0, 'index'=>1, 'position'=>1000, 'arrayofkeyval'=>array(0=>'Draft', 1=>'Active', -1=>'Cancel')),
|
||||
);*/
|
||||
|
||||
$string = 'public $fields=array('."\n";
|
||||
$string .= "<br>";
|
||||
$i = 10;
|
||||
while ($obj = $db->fetch_object($_results)) {
|
||||
// fieldname
|
||||
$fieldname = $obj->Field;
|
||||
// type
|
||||
$type = $obj->Type;
|
||||
if ($type == 'int(11)') {
|
||||
$type = 'integer';
|
||||
}
|
||||
if ($type == 'float') {
|
||||
$type = 'real';
|
||||
}
|
||||
if (strstr($type, 'tinyint')) {
|
||||
$type = 'integer';
|
||||
}
|
||||
if ($obj->Field == 'fk_soc') {
|
||||
$type = 'integer:Societe:societe/class/societe.class.php';
|
||||
}
|
||||
if (preg_match('/^fk_proj/', $obj->Field)) {
|
||||
$type = 'integer:Project:projet/class/project.class.php:1:fk_statut=1';
|
||||
}
|
||||
if (preg_match('/^fk_prod/', $obj->Field)) {
|
||||
$type = 'integer:Product:product/class/product.class.php:1';
|
||||
}
|
||||
if ($obj->Field == 'fk_warehouse') {
|
||||
$type = 'integer:Entrepot:product/stock/class/entrepot.class.php';
|
||||
}
|
||||
if (preg_match('/^(fk_user|fk_commercial)/', $obj->Field)) {
|
||||
$type = 'integer:User:user/class/user.class.php';
|
||||
}
|
||||
|
||||
// notnull
|
||||
$notnull = ($obj->Null == 'YES' ? 0 : 1);
|
||||
if ($fieldname == 'fk_user_modif') {
|
||||
$notnull = -1;
|
||||
}
|
||||
// label
|
||||
$label = preg_replace('/_/', '', ucfirst($fieldname));
|
||||
if ($fieldname == 'rowid') {
|
||||
$label = 'TechnicalID';
|
||||
}
|
||||
if ($fieldname == 'import_key') {
|
||||
$label = 'ImportId';
|
||||
}
|
||||
if ($fieldname == 'fk_soc') {
|
||||
$label = 'ThirdParty';
|
||||
}
|
||||
if ($fieldname == 'tms') {
|
||||
$label = 'DateModification';
|
||||
}
|
||||
if ($fieldname == 'datec') {
|
||||
$label = 'DateCreation';
|
||||
}
|
||||
if ($fieldname == 'date_valid') {
|
||||
$label = 'DateValidation';
|
||||
}
|
||||
if ($fieldname == 'datev') {
|
||||
$label = 'DateValidation';
|
||||
}
|
||||
if ($fieldname == 'note_private') {
|
||||
$label = 'NotePublic';
|
||||
}
|
||||
if ($fieldname == 'note_public') {
|
||||
$label = 'NotePrivate';
|
||||
}
|
||||
if ($fieldname == 'fk_user_creat') {
|
||||
$label = 'UserAuthor';
|
||||
}
|
||||
if ($fieldname == 'fk_user_modif') {
|
||||
$label = 'UserModif';
|
||||
}
|
||||
if ($fieldname == 'fk_user_valid') {
|
||||
$label = 'UserValidation';
|
||||
}
|
||||
// visible
|
||||
$visible = -1;
|
||||
if ($fieldname == 'entity') {
|
||||
$visible = -2;
|
||||
}
|
||||
if ($fieldname == 'import_key') {
|
||||
$visible = -2;
|
||||
}
|
||||
if ($fieldname == 'fk_user_creat') {
|
||||
$visible = -2;
|
||||
}
|
||||
if ($fieldname == 'fk_user_modif') {
|
||||
$visible = -2;
|
||||
}
|
||||
if (in_array($fieldname, array('ref_ext', 'model_pdf', 'note_public', 'note_private'))) {
|
||||
$visible = 0;
|
||||
}
|
||||
// enabled
|
||||
$enabled = 1;
|
||||
// default
|
||||
$default = '';
|
||||
if ($fieldname == 'entity') {
|
||||
$default = 1;
|
||||
}
|
||||
// position
|
||||
$position = $i;
|
||||
if (in_array($fieldname, array('status', 'statut', 'fk_status', 'fk_statut'))) {
|
||||
$position = 500;
|
||||
}
|
||||
if ($fieldname == 'import_key') {
|
||||
$position = 900;
|
||||
}
|
||||
// index
|
||||
$index = 0;
|
||||
if ($fieldname == 'entity') {
|
||||
$index = 1;
|
||||
}
|
||||
// css, cssview, csslist
|
||||
$css = '';
|
||||
$cssview = '';
|
||||
$csslist = '';
|
||||
if (preg_match('/^fk_/', $fieldname)) {
|
||||
$css = 'maxwidth500 widthcentpercentminusxx';
|
||||
}
|
||||
if ($fieldname == 'label') {
|
||||
$css = 'minwidth300';
|
||||
$cssview = 'wordbreak';
|
||||
}
|
||||
if (in_array($fieldname, array('note_public', 'note_private'))) {
|
||||
$cssview = 'wordbreak';
|
||||
}
|
||||
|
||||
// type
|
||||
$picto = $obj->Picto;
|
||||
if ($obj->Field == 'fk_soc') {
|
||||
$picto = 'company';
|
||||
}
|
||||
if (preg_match('/^fk_proj/', $obj->Field)) {
|
||||
$picto = 'project';
|
||||
}
|
||||
|
||||
// Build the property string
|
||||
$string .= "'".$obj->Field."'=>array('type'=>'".$type."', 'label'=>'".$label."',";
|
||||
if ($default != '') {
|
||||
$string .= " 'default'=>".$default.",";
|
||||
}
|
||||
$string .= " 'enabled'=>".$enabled.",";
|
||||
$string .= " 'visible'=>".$visible;
|
||||
if ($notnull) {
|
||||
$string .= ", 'notnull'=>".$notnull;
|
||||
}
|
||||
if ($fieldname == 'ref' || $fieldname == 'code') {
|
||||
$string .= ", 'showoncombobox'=>1";
|
||||
}
|
||||
$string .= ", 'position'=>".$position;
|
||||
if ($index) {
|
||||
$string .= ", 'index'=>".$index;
|
||||
}
|
||||
if ($picto) {
|
||||
$string .= ", 'picto'=>'".$picto."'";
|
||||
}
|
||||
if ($css) {
|
||||
$string .= ", 'css'=>".$css;
|
||||
}
|
||||
if ($cssview) {
|
||||
$string .= ", 'cssview'=>".$cssview;
|
||||
}
|
||||
if ($csslist) {
|
||||
$string .= ", 'csslist'=>".$csslist;
|
||||
}
|
||||
$string .= "),\n";
|
||||
$string .= "<br>";
|
||||
$i += 5;
|
||||
}
|
||||
$string .= ');'."\n";
|
||||
$string .= "<br>";
|
||||
print $string;
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
// Init an object
|
||||
if ($dirins && $action == 'initobject' && $module && $objectname) {
|
||||
$objectname = ucfirst($objectname);
|
||||
|
||||
@ -1169,6 +938,247 @@ if ($dirins && $action == 'initobject' && $module && $objectname) {
|
||||
}
|
||||
}
|
||||
|
||||
// If we must reuse a table for properties, define $stringforproperties
|
||||
$stringforproperties = '';
|
||||
$tablename = GETPOST('initfromtablename', 'alpha');
|
||||
if ($tablename) {
|
||||
$_results = $db->DDLDescTable($tablename);
|
||||
if (empty($_results)) {
|
||||
$error++;
|
||||
$langs->load("errors");
|
||||
setEventMessages($langs->trans("ErrorTableNotFound", $tablename), null, 'errors');
|
||||
} else {
|
||||
/**
|
||||
* 'type' field format ('integer', 'integer:ObjectClass:PathToClass[:AddCreateButtonOrNot[:Filter[:Sortfield]]]', 'sellist:TableName:LabelFieldName[:KeyFieldName[:KeyFieldParent[:Filter[:Sortfield]]]]', 'varchar(x)', 'double(24,8)', 'real', 'price', 'text', 'text:none', 'html', 'date', 'datetime', 'timestamp', 'duration', 'mail', 'phone', 'url', 'password')
|
||||
* Note: Filter can be a string like "(t.ref:like:'SO-%') or (t.date_creation:<:'20160101') or (t.nature:is:NULL)"
|
||||
* 'label' the translation key.
|
||||
* 'picto' is code of a picto to show before value in forms
|
||||
* 'enabled' is a condition when the field must be managed (Example: 1 or '$conf->global->MY_SETUP_PARAM' or 'isModEnabled("multicurrency")' ...)
|
||||
* 'position' is the sort order of field.
|
||||
* 'notnull' is set to 1 if not null in database. Set to -1 if we must set data to null if empty ('' or 0).
|
||||
* 'visible' says if field is visible in list (Examples: 0=Not visible, 1=Visible on list and create/update/view forms, 2=Visible on list only, 3=Visible on create/update/view form only (not list), 4=Visible on list and update/view form only (not create). 5=Visible on list and view only (not create/not update). Using a negative value means field is not shown by default on list but can be selected for viewing)
|
||||
* 'noteditable' says if field is not editable (1 or 0)
|
||||
* 'alwayseditable' says if field can be modified also when status is not draft ('1' or '0')
|
||||
* 'default' is a default value for creation (can still be overwrote by the Setup of Default Values if field is editable in creation form). Note: If default is set to '(PROV)' and field is 'ref', the default value will be set to '(PROVid)' where id is rowid when a new record is created.
|
||||
* 'index' if we want an index in database.
|
||||
* 'foreignkey'=>'tablename.field' if the field is a foreign key (it is recommanded to name the field fk_...).
|
||||
* 'searchall' is 1 if we want to search in this field when making a search from the quick search button.
|
||||
* 'isameasure' must be set to 1 or 2 if field can be used for measure. Field type must be summable like integer or double(24,8). Use 1 in most cases, or 2 if you don't want to see the column total into list (for example for percentage)
|
||||
* 'css' and 'cssview' and 'csslist' is the CSS style to use on field. 'css' is used in creation and update. 'cssview' is used in view mode. 'csslist' is used for columns in lists. For example: 'css'=>'minwidth300 maxwidth500 widthcentpercentminusx', 'cssview'=>'wordbreak', 'csslist'=>'tdoverflowmax200'
|
||||
* 'help' is a 'TranslationString' to use to show a tooltip on field. You can also use 'TranslationString:keyfortooltiponlick' for a tooltip on click.
|
||||
* 'showoncombobox' if value of the field must be visible into the label of the combobox that list record
|
||||
* 'disabled' is 1 if we want to have the field locked by a 'disabled' attribute. In most cases, this is never set into the definition of $fields into class, but is set dynamically by some part of code.
|
||||
* 'arrayofkeyval' to set a list of values if type is a list of predefined values. For example: array("0"=>"Draft","1"=>"Active","-1"=>"Cancel"). Note that type can be 'integer' or 'varchar'
|
||||
* 'autofocusoncreate' to have field having the focus on a create form. Only 1 field should have this property set to 1.
|
||||
* 'comment' is not used. You can store here any text of your choice. It is not used by application.
|
||||
* 'validate' is 1 if need to validate with $this->validateField()
|
||||
* 'copytoclipboard' is 1 or 2 to allow to add a picto to copy value into clipboard (1=picto after label, 2=picto after value)
|
||||
*/
|
||||
|
||||
/*public $fields=array(
|
||||
'rowid' =>array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'index'=>1, 'position'=>1, 'comment'=>'Id'),
|
||||
'ref' =>array('type'=>'varchar(128)', 'label'=>'Ref', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>10, 'searchall'=>1, 'comment'=>'Reference of object'),
|
||||
'entity' =>array('type'=>'integer', 'label'=>'Entity', 'enabled'=>1, 'visible'=>0, 'default'=>1, 'notnull'=>1, 'index'=>1, 'position'=>20),
|
||||
'label' =>array('type'=>'varchar(255)', 'label'=>'Label', 'enabled'=>1, 'visible'=>1, 'position'=>30, 'searchall'=>1, 'css'=>'minwidth200', 'help'=>'Help text', 'alwayseditable'=>'1'),
|
||||
'amount' =>array('type'=>'double(24,8)', 'label'=>'Amount', 'enabled'=>1, 'visible'=>1, 'default'=>'null', 'position'=>40, 'searchall'=>0, 'isameasure'=>1, 'help'=>'Help text'),
|
||||
'fk_soc' =>array('type'=>'integer:Societe:societe/class/societe.class.php', 'label'=>'ThirdParty', 'visible'=>1, 'enabled'=>1, 'position'=>50, 'notnull'=>-1, 'index'=>1, 'searchall'=>1, 'help'=>'LinkToThirdparty'),
|
||||
'description' =>array('type'=>'text', 'label'=>'Descrption', 'enabled'=>1, 'visible'=>0, 'position'=>60),
|
||||
'note_public' =>array('type'=>'html', 'label'=>'NotePublic', 'enabled'=>1, 'visible'=>0, 'position'=>61),
|
||||
'note_private' =>array('type'=>'html', 'label'=>'NotePrivate', 'enabled'=>1, 'visible'=>0, 'position'=>62),
|
||||
'date_creation' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>500),
|
||||
'tms' =>array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>501),
|
||||
//'date_valid' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-2, 'position'=>502),
|
||||
'fk_user_creat' =>array('type'=>'integer', 'label'=>'UserAuthor', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>510),
|
||||
'fk_user_modif' =>array('type'=>'integer', 'label'=>'UserModif', 'enabled'=>1, 'visible'=>-2, 'notnull'=>-1, 'position'=>511),
|
||||
//'fk_user_valid' =>array('type'=>'integer', 'label'=>'UserValidation', 'enabled'=>1, 'visible'=>-1, 'position'=>512),
|
||||
'import_key' =>array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>1, 'visible'=>-2, 'notnull'=>-1, 'index'=>0, 'position'=>1000),
|
||||
'status' =>array('type'=>'integer', 'label'=>'Status', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'default'=>0, 'index'=>1, 'position'=>1000, 'arrayofkeyval'=>array(0=>'Draft', 1=>'Active', -1=>'Cancel')),
|
||||
);*/
|
||||
|
||||
$stringforproperties = '// BEGIN MODULEBUILDER PROPERTIES'."\n";
|
||||
$stringforproperties .= 'public $fields=array('."\n";
|
||||
$i = 10;
|
||||
while ($obj = $db->fetch_object($_results)) {
|
||||
// fieldname
|
||||
$fieldname = $obj->Field;
|
||||
// type
|
||||
$type = $obj->Type;
|
||||
if ($type == 'int(11)') {
|
||||
$type = 'integer';
|
||||
}
|
||||
if ($type == 'float') {
|
||||
$type = 'real';
|
||||
}
|
||||
if (strstr($type, 'tinyint')) {
|
||||
$type = 'integer';
|
||||
}
|
||||
if ($obj->Field == 'fk_soc') {
|
||||
$type = 'integer:Societe:societe/class/societe.class.php';
|
||||
}
|
||||
if (preg_match('/^fk_proj/', $obj->Field)) {
|
||||
$type = 'integer:Project:projet/class/project.class.php:1:fk_statut=1';
|
||||
}
|
||||
if (preg_match('/^fk_prod/', $obj->Field)) {
|
||||
$type = 'integer:Product:product/class/product.class.php:1';
|
||||
}
|
||||
if ($obj->Field == 'fk_warehouse') {
|
||||
$type = 'integer:Entrepot:product/stock/class/entrepot.class.php';
|
||||
}
|
||||
if (preg_match('/^(fk_user|fk_commercial)/', $obj->Field)) {
|
||||
$type = 'integer:User:user/class/user.class.php';
|
||||
}
|
||||
|
||||
// notnull
|
||||
$notnull = ($obj->Null == 'YES' ? 0 : 1);
|
||||
if ($fieldname == 'fk_user_modif') {
|
||||
$notnull = -1;
|
||||
}
|
||||
// label
|
||||
$label = preg_replace('/_/', '', ucfirst($fieldname));
|
||||
if ($fieldname == 'rowid') {
|
||||
$label = 'TechnicalID';
|
||||
}
|
||||
if ($fieldname == 'import_key') {
|
||||
$label = 'ImportId';
|
||||
}
|
||||
if ($fieldname == 'fk_soc') {
|
||||
$label = 'ThirdParty';
|
||||
}
|
||||
if ($fieldname == 'tms') {
|
||||
$label = 'DateModification';
|
||||
}
|
||||
if ($fieldname == 'datec') {
|
||||
$label = 'DateCreation';
|
||||
}
|
||||
if ($fieldname == 'date_valid') {
|
||||
$label = 'DateValidation';
|
||||
}
|
||||
if ($fieldname == 'datev') {
|
||||
$label = 'DateValidation';
|
||||
}
|
||||
if ($fieldname == 'note_private') {
|
||||
$label = 'NotePublic';
|
||||
}
|
||||
if ($fieldname == 'note_public') {
|
||||
$label = 'NotePrivate';
|
||||
}
|
||||
if ($fieldname == 'fk_user_creat') {
|
||||
$label = 'UserAuthor';
|
||||
}
|
||||
if ($fieldname == 'fk_user_modif') {
|
||||
$label = 'UserModif';
|
||||
}
|
||||
if ($fieldname == 'fk_user_valid') {
|
||||
$label = 'UserValidation';
|
||||
}
|
||||
// visible
|
||||
$visible = -1;
|
||||
if ($fieldname == 'entity') {
|
||||
$visible = -2;
|
||||
}
|
||||
if ($fieldname == 'import_key') {
|
||||
$visible = -2;
|
||||
}
|
||||
if ($fieldname == 'fk_user_creat') {
|
||||
$visible = -2;
|
||||
}
|
||||
if ($fieldname == 'fk_user_modif') {
|
||||
$visible = -2;
|
||||
}
|
||||
if (in_array($fieldname, array('ref_ext', 'model_pdf', 'note_public', 'note_private'))) {
|
||||
$visible = 0;
|
||||
}
|
||||
// enabled
|
||||
$enabled = 1;
|
||||
// default
|
||||
$default = '';
|
||||
if ($fieldname == 'entity') {
|
||||
$default = 1;
|
||||
}
|
||||
// position
|
||||
$position = $i;
|
||||
if (in_array($fieldname, array('status', 'statut', 'fk_status', 'fk_statut'))) {
|
||||
$position = 500;
|
||||
}
|
||||
if ($fieldname == 'import_key') {
|
||||
$position = 900;
|
||||
}
|
||||
// $alwayseditable
|
||||
if ($fieldname == 'label') {
|
||||
$alwayseditable = 1;
|
||||
}
|
||||
// index
|
||||
$index = 0;
|
||||
if ($fieldname == 'entity') {
|
||||
$index = 1;
|
||||
}
|
||||
// css, cssview, csslist
|
||||
$css = '';
|
||||
$cssview = '';
|
||||
$csslist = '';
|
||||
if (preg_match('/^fk_/', $fieldname)) {
|
||||
$css = 'maxwidth500 widthcentpercentminusxx';
|
||||
}
|
||||
if ($fieldname == 'label') {
|
||||
$css = 'minwidth300';
|
||||
$cssview = 'wordbreak';
|
||||
}
|
||||
if (in_array($fieldname, array('note_public', 'note_private'))) {
|
||||
$cssview = 'wordbreak';
|
||||
}
|
||||
if (in_array($fieldname, array('ref', 'label')) || preg_match('/integer:/', $type)) {
|
||||
$csslist = 'tdoverflowmax150';
|
||||
}
|
||||
|
||||
// type
|
||||
$picto = $obj->Picto;
|
||||
if ($obj->Field == 'fk_soc') {
|
||||
$picto = 'company';
|
||||
}
|
||||
if (preg_match('/^fk_proj/', $obj->Field)) {
|
||||
$picto = 'project';
|
||||
}
|
||||
|
||||
// Build the property string
|
||||
$stringforproperties .= "'".$obj->Field."'=>array('type'=>'".$type."', 'label'=>'".$label."',";
|
||||
if ($default != '') {
|
||||
$stringforproperties .= " 'default'=>".$default.",";
|
||||
}
|
||||
$stringforproperties .= " 'enabled'=>".$enabled.",";
|
||||
$stringforproperties .= " 'visible'=>".$visible;
|
||||
if ($notnull) {
|
||||
$stringforproperties .= ", 'notnull'=>".$notnull;
|
||||
}
|
||||
if ($alwayseditable) {
|
||||
$stringforproperties .= ", 'alwayseditable'=>1";
|
||||
}
|
||||
if ($fieldname == 'ref' || $fieldname == 'code') {
|
||||
$stringforproperties .= ", 'showoncombobox'=>1";
|
||||
}
|
||||
$stringforproperties .= ", 'position'=>".$position;
|
||||
if ($index) {
|
||||
$stringforproperties .= ", 'index'=>".$index;
|
||||
}
|
||||
if ($picto) {
|
||||
$stringforproperties .= ", 'picto'=>'".$picto."'";
|
||||
}
|
||||
if ($css) {
|
||||
$stringforproperties .= ", 'css'=>'".$css."'";
|
||||
}
|
||||
if ($cssview) {
|
||||
$stringforproperties .= ", 'cssview'=>'".$cssview."'";
|
||||
}
|
||||
if ($csslist) {
|
||||
$stringforproperties .= ", 'csslist'=>'".$csslist."'";
|
||||
}
|
||||
$stringforproperties .= "),\n";
|
||||
$i += 5;
|
||||
}
|
||||
$stringforproperties .= ');'."\n";
|
||||
$stringforproperties .= '// END MODULEBUILDER PROPERTIES'."\n";
|
||||
}
|
||||
}
|
||||
|
||||
if (!$error) {
|
||||
// Copy some files
|
||||
$filetogenerate = array(
|
||||
@ -1209,20 +1219,33 @@ if ($dirins && $action == 'initobject' && $module && $objectname) {
|
||||
);
|
||||
}
|
||||
|
||||
foreach ($filetogenerate as $srcfile => $destfile) {
|
||||
$result = dol_copy($srcdir.'/'.$srcfile, $destdir.'/'.$destfile, $newmask, 0);
|
||||
if ($result <= 0) {
|
||||
if ($result < 0) {
|
||||
$error++;
|
||||
$langs->load("errors");
|
||||
setEventMessages($langs->trans("ErrorFailToCopyFile", $srcdir.'/'.$srcfile, $destdir.'/'.$destfile), null, 'errors');
|
||||
} else {
|
||||
// $result == 0
|
||||
setEventMessages($langs->trans("FileAlreadyExists", $destfile), null, 'warnings');
|
||||
|
||||
if (!$error) {
|
||||
foreach ($filetogenerate as $srcfile => $destfile) {
|
||||
$result = dol_copy($srcdir.'/'.$srcfile, $destdir.'/'.$destfile, $newmask, 0);
|
||||
if ($result <= 0) {
|
||||
if ($result < 0) {
|
||||
$error++;
|
||||
$langs->load("errors");
|
||||
setEventMessages($langs->trans("ErrorFailToCopyFile", $srcdir.'/'.$srcfile, $destdir.'/'.$destfile), null, 'errors');
|
||||
} else {
|
||||
// $result == 0
|
||||
setEventMessages($langs->trans("FileAlreadyExists", $destfile), null, 'warnings');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Replace property section with $stringforproperties
|
||||
if (!$error && $stringforproperties) {
|
||||
//var_dump($stringforproperties);exit;
|
||||
$arrayreplacement = array(
|
||||
'/\/\/ BEGIN MODULEBUILDER PROPERTIES.*\/\/ END MODULEBUILDER PROPERTIES/ims' => $stringforproperties
|
||||
);
|
||||
|
||||
dolReplaceInFile($destdir.'/class/'.strtolower($objectname).'.class.php', $arrayreplacement, '', 0, 0, 1);
|
||||
}
|
||||
|
||||
// Edit the class 'class/'.strtolower($objectname).'.class.php'
|
||||
if (GETPOST('includerefgeneration', 'aZ09')) {
|
||||
// Replace 'visible'=>1, 'noteditable'=>0, 'default'=>''
|
||||
@ -1405,6 +1428,8 @@ if ($dirins && $action == 'initobject' && $module && $objectname) {
|
||||
if (!$error) {
|
||||
setEventMessages($langs->trans('FilesForObjectInitialized', $objectname), null);
|
||||
$tabobj = $objectname;
|
||||
} else {
|
||||
$tabobj = 'newobject';
|
||||
}
|
||||
}
|
||||
|
||||
@ -1489,26 +1514,26 @@ if ($dirins && $action == 'addproperty' && empty($cancel) && !empty($module) &&
|
||||
|
||||
if (!$error && !GETPOST('regenerateclasssql')&& !GETPOST('regeneratemissing')) {
|
||||
$addfieldentry = array(
|
||||
'name'=>GETPOST('propname', 'aZ09'),
|
||||
'label'=>GETPOST('proplabel', 'alpha'),
|
||||
'type'=>GETPOST('proptype', 'alpha'),
|
||||
'arrayofkeyval'=>GETPOST('proparrayofkeyval', 'restricthtml'), // Example json string '{"0":"Draft","1":"Active","-1":"Cancel"}'
|
||||
'visible'=>GETPOST('propvisible', 'int'),
|
||||
'enabled'=>GETPOST('propenabled', 'int'),
|
||||
'position'=>GETPOST('propposition', 'int'),
|
||||
'notnull'=>GETPOST('propnotnull', 'int'),
|
||||
'index'=>GETPOST('propindex', 'int'),
|
||||
'searchall'=>GETPOST('propsearchall', 'int'),
|
||||
'isameasure'=>GETPOST('propisameasure', 'int'),
|
||||
'comment'=>GETPOST('propcomment', 'alpha'),
|
||||
'help'=>GETPOST('prophelp', 'alpha'),
|
||||
'css'=>GETPOST('propcss', 'alpha'), // Can be 'maxwidth500 widthcentpercentminusxx' for example
|
||||
'cssview'=>GETPOST('propcssview', 'alpha'),
|
||||
'csslist'=>GETPOST('propcsslist', 'alpha'),
|
||||
'default'=>GETPOST('propdefault', 'restricthtml'),
|
||||
'noteditable'=>intval(GETPOST('propnoteditable', 'int')),
|
||||
'alwayseditable'=>intval(GETPOST('propalwayseditable', 'int')),
|
||||
'validate' => GETPOST('propvalidate', 'int')
|
||||
'name'=>GETPOST('propname', 'aZ09'),
|
||||
'label'=>GETPOST('proplabel', 'alpha'),
|
||||
'type'=>GETPOST('proptype', 'alpha'),
|
||||
'arrayofkeyval'=>GETPOST('proparrayofkeyval', 'restricthtml'), // Example json string '{"0":"Draft","1":"Active","-1":"Cancel"}'
|
||||
'visible'=>GETPOST('propvisible', 'int'),
|
||||
'enabled'=>GETPOST('propenabled', 'int'),
|
||||
'position'=>GETPOST('propposition', 'int'),
|
||||
'notnull'=>GETPOST('propnotnull', 'int'),
|
||||
'index'=>GETPOST('propindex', 'int'),
|
||||
'searchall'=>GETPOST('propsearchall', 'int'),
|
||||
'isameasure'=>GETPOST('propisameasure', 'int'),
|
||||
'comment'=>GETPOST('propcomment', 'alpha'),
|
||||
'help'=>GETPOST('prophelp', 'alpha'),
|
||||
'css'=>GETPOST('propcss', 'alpha'), // Can be 'maxwidth500 widthcentpercentminusxx' for example
|
||||
'cssview'=>GETPOST('propcssview', 'alpha'),
|
||||
'csslist'=>GETPOST('propcsslist', 'alpha'),
|
||||
'default'=>GETPOST('propdefault', 'restricthtml'),
|
||||
'noteditable'=>intval(GETPOST('propnoteditable', 'int')),
|
||||
'alwayseditable'=>intval(GETPOST('propalwayseditable', 'int')),
|
||||
'validate' => GETPOST('propvalidate', 'int')
|
||||
);
|
||||
|
||||
|
||||
@ -2285,6 +2310,8 @@ if ($module == 'initmodule') {
|
||||
$head2[$h][2] = 'buildpackage';
|
||||
$h++;
|
||||
|
||||
$MAXTABFOROBJECT = 15;
|
||||
|
||||
print '<!-- Section for a given module -->';
|
||||
|
||||
// Note module is inside $dirread
|
||||
@ -2296,7 +2323,7 @@ if ($module == 'initmodule') {
|
||||
$pathtochangelog = $modulelowercase.'/ChangeLog.md';
|
||||
|
||||
if ($action != 'editfile' || empty($file)) {
|
||||
print dol_get_fiche_head($head2, $tab, '', -1, '', 0, '', '', 0, 'formodulesuffix'); // Description - level 2
|
||||
print dol_get_fiche_head($head2, $tab, '', -1, '', 0, '', '', $MAXTABFOROBJECT, 'formodulesuffix'); // Description - level 2
|
||||
|
||||
print '<span class="opacitymedium">'.$langs->trans("ModuleBuilderDesc".$tab).'</span>';
|
||||
$infoonmodulepath = '';
|
||||
@ -2456,7 +2483,7 @@ if ($module == 'initmodule') {
|
||||
print '</form>';
|
||||
}
|
||||
} else {
|
||||
print dol_get_fiche_head($head2, $tab, '', -1, '', 0, '', '', 0, 'formodulesuffix'); // Level 2
|
||||
print dol_get_fiche_head($head2, $tab, '', -1, '', 0, '', '', $MAXTABFOROBJECT, 'formodulesuffix'); // Level 2
|
||||
}
|
||||
|
||||
if ($tab == 'languages') {
|
||||
@ -2603,12 +2630,38 @@ if ($module == 'initmodule') {
|
||||
|
||||
print '<span class="opacitymedium">'.$langs->trans("EnterNameOfObjectDesc").'</span><br><br>';
|
||||
|
||||
print '<input type="text" name="objectname" maxlength="64" value="'.dol_escape_htmltag(GETPOST('objectname', 'alpha') ? GETPOST('objectname', 'alpha') : $modulename).'" placeholder="'.dol_escape_htmltag($langs->trans("ObjectKey")).'" autofocus><br>';
|
||||
print '<input type="checkbox" name="includerefgeneration" id="includerefgeneration" value="includerefgeneration"> <label for="includerefgeneration">'.$form->textwithpicto($langs->trans("IncludeRefGeneration"), $langs->trans("IncludeRefGenerationHelp")).'</label><br>';
|
||||
print '<div class="tagtable">';
|
||||
|
||||
print '<div class="tagtr"><div class="tagtd">';
|
||||
print '<span class="opacitymedium">'.$langs->trans("ObjectKey").'</span> ';
|
||||
print '</div><div class="tagtd">';
|
||||
print '<input type="text" name="objectname" maxlength="64" value="'.dol_escape_htmltag(GETPOST('objectname', 'alpha') ? GETPOST('objectname', 'alpha') : $modulename).'" autofocus><br>';
|
||||
print '</div></div>';
|
||||
|
||||
print '<div class="tagtr"><div class="tagtd">';
|
||||
print '<span class="opacitymedium">'.$langs->trans("Picto").'</span> ';
|
||||
print '</div><div class="tagtd">';
|
||||
print '<input type="text" name="idpicto" value="fa-generic" placeholder="'.dol_escape_htmltag($langs->trans("Picto")).'">';
|
||||
print $form->textwithpicto('', $langs->trans("Example").': fa-generic, fa-globe, ... any font awesome code.<br>Advanced syntax is fa-fakey[_faprefix[_facolor[_fasize]]]');
|
||||
print '</div></div>';
|
||||
|
||||
print '<div class="tagtr"><div class="tagtd">';
|
||||
print '<span class="opacitymedium">'.$langs->trans("DefinePropertiesFromExistingTable").'</span> ';
|
||||
print '</div><div class="tagtd">';
|
||||
print '<input type="text" name="initfromtablename" value="'.GETPOST('initfromtablename').'" placeholder="'.$langs->trans("TableName").'">';
|
||||
print $form->textwithpicto('', $langs->trans("DefinePropertiesFromExistingTableDesc").'<br>'.$langs->trans("DefinePropertiesFromExistingTableDesc2"));
|
||||
print '</div></div>';
|
||||
|
||||
print '</div>';
|
||||
|
||||
print '<br>';
|
||||
print '<input type="checkbox" name="includerefgeneration" id="includerefgeneration" value="includerefgeneration"> <label class="margintoponly" for="includerefgeneration">'.$form->textwithpicto($langs->trans("IncludeRefGeneration"), $langs->trans("IncludeRefGenerationHelp")).'</label><br>';
|
||||
print '<input type="checkbox" name="includedocgeneration" id="includedocgeneration" value="includedocgeneration"> <label for="includedocgeneration">'.$form->textwithpicto($langs->trans("IncludeDocGeneration"), $langs->trans("IncludeDocGenerationHelp")).'</label><br>';
|
||||
print '<input type="submit" class="button smallpaddingimp" name="create" value="'.dol_escape_htmltag($langs->trans("GenerateCode")).'"'.($dirins ? '' : ' disabled="disabled"').'>';
|
||||
print '<br>';
|
||||
print '<input type="submit" class="button small" name="create" value="'.dol_escape_htmltag($langs->trans("GenerateCode")).'"'.($dirins ? '' : ' disabled="disabled"').'>';
|
||||
print '<br>';
|
||||
print '<br>';
|
||||
/*
|
||||
print '<br>';
|
||||
print '<span class="opacitymedium">'.$langs->trans("or").'</span>';
|
||||
print '<br>';
|
||||
@ -2618,6 +2671,7 @@ if ($module == 'initmodule') {
|
||||
print '<input type="text" name="initfromtablename" value="" placeholder="'.$langs->trans("TableName").'">';
|
||||
print '<input type="submit" class="button smallpaddingimp" name="createtablearray" value="'.dol_escape_htmltag($langs->trans("GenerateCode")).'"'.($dirins ? '' : ' disabled="disabled"').'>';
|
||||
print '<br>';
|
||||
*/
|
||||
|
||||
print '</form>';
|
||||
} elseif ($tabobj == 'deleteobject') {
|
||||
@ -2679,7 +2733,7 @@ if ($module == 'initmodule') {
|
||||
}
|
||||
if (class_exists($tabobj)) {
|
||||
try {
|
||||
$tmpobjet = @new $tabobj($db);
|
||||
$tmpobject = @new $tabobj($db);
|
||||
} catch (Exception $e) {
|
||||
dol_syslog('Failed to load Constructor of class: '.$e->getMessage(), LOG_WARNING);
|
||||
}
|
||||
@ -2752,13 +2806,22 @@ if ($module == 'initmodule') {
|
||||
$urlofcard = dol_buildpath('/'.$pathtocard, 1);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
print '<!-- section for object -->';
|
||||
print '<div class="fichehalfleft smallxxx">';
|
||||
// Main DAO class file
|
||||
print '<span class="fa fa-file-o"></span> '.$langs->trans("ClassFile").' : <strong>'.(dol_is_file($realpathtoclass) ? '' : '<strike>').preg_replace('/^'.strtolower($module).'\//', '', $pathtoclass).(dol_is_file($realpathtoclass) ? '' : '</strike>').'</strong>';
|
||||
print ' <a class="editfielda" href="'.$_SERVER['PHP_SELF'].'?tab='.$tab.'&tabobj='.$tabobj.'&module='.$module.($forceddirread ? '@'.$dirread : '').'&action=editfile&token='.newToken().'&format=php&file='.urlencode($pathtoclass).'">'.img_picto($langs->trans("Edit"), 'edit').'</a>';
|
||||
print '<br>';
|
||||
// Image
|
||||
if (dol_is_file($realpathtopicto)) {
|
||||
print '<span class="fa fa-file-image-o"></span> '.$langs->trans("Image").' : <strong>'.(dol_is_file($realpathtopicto) ? '' : '<strike>').preg_replace('/^'.strtolower($module).'\//', '', $pathtopicto).(dol_is_file($realpathtopicto) ? '' : '</strike>').'</strong>';
|
||||
//print ' <a href="'.$_SERVER['PHP_SELF'].'?tab='.$tab.'&tabobj='.$tabobj.'&module='.$module.($forceddirread?'@'.$dirread:'').'&action=editfile&token='.newToken().'&format=php&file='.urlencode($pathtopicto).'">'.img_picto($langs->trans("Edit"), 'edit').'</a>';
|
||||
print '<br>';
|
||||
} elseif (!empty($tmpobject)) {
|
||||
print '<span class="fa fa-file-image-o"></span> '.$langs->trans("Image").' : '.img_picto('', $tmpobject->picto, 'class="pictofixedwidth"');
|
||||
print '<br>';
|
||||
}
|
||||
|
||||
// API file
|
||||
print '<br>';
|
||||
print '<span class="fa fa-file-o"></span> '.$langs->trans("ApiClassFile").' : <strong class="wordbreak">'.(dol_is_file($realpathtoapi) ? '' : '<strike><span class="opacitymedium">').preg_replace('/^'.strtolower($module).'\//', '', $pathtoapi).(dol_is_file($realpathtoapi)?'':'</span></strike>').'</strong>';
|
||||
@ -2795,12 +2858,6 @@ if ($module == 'initmodule') {
|
||||
print '<span class="fa fa-file-o"></span> '.$langs->trans("PageForObjLib").' : <strong class="wordbreak">'.(dol_is_file($realpathtoobjlib) ? '' : '<strike>').preg_replace('/^'.strtolower($module).'\//', '', $pathtoobjlib).(dol_is_file($realpathtoobjlib) ? '' : '</strike>').'</strong>';
|
||||
print ' <a class="editfielda" href="'.$_SERVER['PHP_SELF'].'?tab='.$tab.'&tabobj='.$tabobj.'&module='.$module.($forceddirread ? '@'.$dirread : '').'&action=editfile&token='.newToken().'&format=php&file='.urlencode($pathtoobjlib).'">'.img_picto($langs->trans("Edit"), 'edit').'</a>';
|
||||
print '<br>';
|
||||
// Image
|
||||
if (dol_is_file($realpathtopicto)) {
|
||||
print '<span class="fa fa-file-image-o"></span> '.$langs->trans("Image").' : <strong>'.(dol_is_file($realpathtopicto) ? '' : '<strike>').preg_replace('/^'.strtolower($module).'\//', '', $pathtopicto).(dol_is_file($realpathtopicto) ? '' : '</strike>').'</strong>';
|
||||
//print ' <a href="'.$_SERVER['PHP_SELF'].'?tab='.$tab.'&tabobj='.$tabobj.'&module='.$module.($forceddirread?'@'.$dirread:'').'&action=editfile&token='.newToken().'&format=php&file='.urlencode($pathtopicto).'">'.img_picto($langs->trans("Edit"), 'edit').'</a>';
|
||||
print '<br>';
|
||||
}
|
||||
|
||||
print '<br>';
|
||||
print '<span class="fa fa-file-o"></span> '.$langs->trans("SqlFile").' : <strong class="wordbreak">'.(dol_is_file($realpathtosql) ? '' : '<strike>').preg_replace('/^'.strtolower($module).'\//', '', $pathtosql).(dol_is_file($realpathtosql) ? '' : '</strike>').'</strong>';
|
||||
@ -2888,7 +2945,7 @@ if ($module == 'initmodule') {
|
||||
|
||||
print '<br><br><br>';
|
||||
|
||||
if (!empty($tmpobjet)) {
|
||||
if (!empty($tmpobject)) {
|
||||
$reflector = new ReflectionClass($tabobj);
|
||||
$reflectorproperties = $reflector->getProperties(); // Can also use get_object_vars
|
||||
$reflectorpropdefault = $reflector->getDefaultProperties(); // Can also use get_object_vars
|
||||
@ -2942,9 +2999,9 @@ if ($module == 'initmodule') {
|
||||
print '<th class="none"></th>';
|
||||
print '</tr>';
|
||||
|
||||
// We must use $reflectorpropdefault['fields'] to get list of fields because $tmpobjet->fields may have been
|
||||
// We must use $reflectorpropdefault['fields'] to get list of fields because $tmpobject->fields may have been
|
||||
// modified during the constructor and we want value into head of class before constructor is called.
|
||||
//$properties = dol_sort_array($tmpobjet->fields, 'position');
|
||||
//$properties = dol_sort_array($tmpobject->fields, 'position');
|
||||
$properties = dol_sort_array($reflectorpropdefault['fields'], 'position');
|
||||
|
||||
if (!empty($properties)) {
|
||||
@ -2984,7 +3041,7 @@ if ($module == 'initmodule') {
|
||||
{
|
||||
$propname=$propval->getName();
|
||||
$comment=$propval->getDocComment();
|
||||
$type=gettype($tmpobjet->$propname);
|
||||
$type=gettype($tmpobject->$propname);
|
||||
$default=$propdefault[$propname];
|
||||
// Discard generic properties
|
||||
if (in_array($propname, array('element', 'childtables', 'table_element', 'table_element_line', 'class_element_line', 'ismultientitymanaged'))) continue;
|
||||
|
||||
@ -116,19 +116,19 @@ class MyObject extends CommonObject
|
||||
'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-2, 'noteditable'=>1, 'notnull'=> 1, 'index'=>1, 'position'=>1, 'comment'=>'Id', 'css'=>'left'),
|
||||
'entity' => array('type'=>'integer', 'label'=>'Entity', 'enabled'=>1, 'visible'=>0, 'notnull'=> 1, 'default'=>1, 'index'=>1, 'position'=>10),
|
||||
'ref' => array('type'=>'varchar(128)', 'label'=>'Ref', 'enabled'=>1, 'visible'=>1, 'noteditable'=>0, 'default'=>'', 'notnull'=> 1, 'showoncombobox'=>1, 'index'=>1, 'position'=>20, 'searchall'=>1, 'comment'=>'Reference of object', 'validate'=>1),
|
||||
'label' => array('type'=>'varchar(255)', 'label'=>'Label', 'enabled'=>1, 'visible'=>1, 'position'=>30, 'searchall'=>1, 'css'=>'minwidth300', 'cssview'=>'wordbreak', 'help'=>'Help text', 'showoncombobox'=>2, 'validate'=>1),
|
||||
'label' => array('type'=>'varchar(255)', 'label'=>'Label', 'enabled'=>1, 'visible'=>1, 'position'=>30, 'searchall'=>1, 'css'=>'minwidth300', 'cssview'=>'wordbreak', 'help'=>'Help text', 'showoncombobox'=>2, 'validate'=>1, 'alwayseditable'=>1),
|
||||
'amount' => array('type'=>'price', 'label'=>'Amount', 'enabled'=>1, 'visible'=>1, 'default'=>'null', 'position'=>40, 'searchall'=>0, 'isameasure'=>1, 'help'=>'Help text for amount', 'validate'=>1),
|
||||
'qty' => array('type'=>'real', 'label'=>'Qty', 'enabled'=>1, 'visible'=>1, 'default'=>'0', 'position'=>45, 'searchall'=>0, 'isameasure'=>1, 'help'=>'Help text for quantity', 'css'=>'maxwidth75imp', 'validate'=>1),
|
||||
'fk_soc' => array('type'=>'integer:Societe:societe/class/societe.class.php:1:status=1 AND entity IN (__SHARED_ENTITIES__)', 'picto'=>'company', 'label'=>'ThirdParty', 'visible'=> 1, 'enabled'=>'$conf->societe->enabled', 'position'=>50, 'notnull'=>-1, 'index'=>1, 'help'=>'OrganizationEventLinkToThirdParty', 'validate'=>1, 'css'=>'maxwidth500 widthcentpercentminusxx'),
|
||||
'fk_project' => array('type'=>'integer:Project:projet/class/project.class.php:1', 'label'=>'Project', 'picto'=>'project', 'enabled'=>'$conf->project->enabled', 'visible'=>-1, 'position'=>52, 'notnull'=>-1, 'index'=>1, 'validate'=>1, 'css'=>'maxwidth500 widthcentpercentminusxx'),
|
||||
'fk_soc' => array('type'=>'integer:Societe:societe/class/societe.class.php:1:status=1 AND entity IN (__SHARED_ENTITIES__)', 'picto'=>'company', 'label'=>'ThirdParty', 'visible'=> 1, 'enabled'=>'$conf->societe->enabled', 'position'=>50, 'notnull'=>-1, 'index'=>1, 'help'=>'OrganizationEventLinkToThirdParty', 'validate'=>1, 'css'=>'maxwidth500 widthcentpercentminusxx', 'csslist'=>'tdoverflowmax150'),
|
||||
'fk_project' => array('type'=>'integer:Project:projet/class/project.class.php:1', 'label'=>'Project', 'picto'=>'project', 'enabled'=>'$conf->project->enabled', 'visible'=>-1, 'position'=>52, 'notnull'=>-1, 'index'=>1, 'validate'=>1, 'css'=>'maxwidth500 widthcentpercentminusxx', 'csslist'=>'tdoverflowmax150'),
|
||||
'description' => array('type'=>'text', 'label'=>'Description', 'enabled'=>1, 'visible'=>3, 'position'=>60, 'validate'=>1),
|
||||
'note_public' => array('type'=>'html', 'label'=>'NotePublic', 'enabled'=>1, 'visible'=>0, 'position'=>61, 'validate'=>1, 'cssview'=>'wordbreak'),
|
||||
'note_private' => array('type'=>'html', 'label'=>'NotePrivate', 'enabled'=>1, 'visible'=>0, 'position'=>62, 'validate'=>1, 'cssview'=>'wordbreak'),
|
||||
'date_creation' => array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-2, 'notnull'=> 1, 'position'=>500),
|
||||
'tms' => array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-2, 'notnull'=> 0, 'position'=>501),
|
||||
//'date_validation ' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-2, 'position'=>502),
|
||||
'fk_user_creat' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserAuthor', 'picto'=>'user', 'enabled'=>1, 'visible'=>-2, 'notnull'=> 1, 'position'=>510, 'foreignkey'=>'user.rowid'),
|
||||
'fk_user_modif' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserModif', 'picto'=>'user', 'enabled'=>1, 'visible'=>-2, 'notnull'=>-1, 'position'=>511),
|
||||
'fk_user_creat' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserAuthor', 'picto'=>'user', 'enabled'=>1, 'visible'=>-2, 'notnull'=> 1, 'position'=>510, 'foreignkey'=>'user.rowid', 'csslist'=>'tdoverflowmax150'),
|
||||
'fk_user_modif' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserModif', 'picto'=>'user', 'enabled'=>1, 'visible'=>-2, 'notnull'=>-1, 'position'=>511, 'csslist'=>'tdoverflowmax150'),
|
||||
//'fk_user_valid' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserValidation', 'enabled'=>1, 'visible'=>-1, 'position'=>512),
|
||||
'last_main_doc' => array('type'=>'varchar(255)', 'label'=>'LastMainDoc', 'enabled'=>1, 'visible'=>0, 'notnull'=>0, 'position'=>600),
|
||||
'import_key' => array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>1, 'visible'=>-2, 'notnull'=>-1, 'index'=>0, 'position'=>1000),
|
||||
|
||||
Loading…
Reference in New Issue
Block a user