forked from Wavyzz/dolibarr
Merge branch '22.0' of git@github.com:Dolibarr/dolibarr.git into develop
This commit is contained in:
@@ -268,14 +268,15 @@ class Documentation
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Output header + body
|
* Output header + body
|
||||||
*
|
*
|
||||||
* @param string $title Title of page
|
* @param string $title Title of page
|
||||||
* @param string[] $arrayofjs Array of complementary js files
|
* @param string[] $arrayofjs Array of complementary js files
|
||||||
* @param string[] $arrayofcss Array of complementary css files
|
* @param string[] $arrayofcss Array of complementary css files
|
||||||
|
* @param string $hidenavmenu Hide nav menu
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function docHeader($title = '', $arrayofjs = [], $arrayofcss = [])
|
public function docHeader($title = '', $arrayofjs = [], $arrayofcss = [], $hidenavmenu = '')
|
||||||
{
|
{
|
||||||
global $langs;
|
global $langs;
|
||||||
$title = (!empty($title)) ? dol_escape_htmltag($title) : $langs->trans('Documentation');
|
$title = (!empty($title)) ? dol_escape_htmltag($title) : $langs->trans('Documentation');
|
||||||
@@ -284,7 +285,7 @@ class Documentation
|
|||||||
|
|
||||||
top_htmlhead('', $title, 0, 0, $arrayofjs, $arrayofcss);
|
top_htmlhead('', $title, 0, 0, $arrayofjs, $arrayofcss);
|
||||||
|
|
||||||
print '<body class="dolibarr-doc'.(GETPOST('hidenavmenu') ? "-bis" : "").'">';
|
print '<body class="dolibarr-doc'.($hidenavmenu ? "-bis" : "").'">';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ $langs->load('uxdocumentation');
|
|||||||
$documentation = new Documentation($db);
|
$documentation = new Documentation($db);
|
||||||
|
|
||||||
// Output html head + body - Param is Title
|
// Output html head + body - Param is Title
|
||||||
$documentation->docHeader('Icons', [], ['admin/tools/ui/css/doc-icons.css']);
|
$documentation->docHeader('Icons', [], ['admin/tools/ui/css/doc-icons.css'], GETPOST('hidenavmenu'));
|
||||||
|
|
||||||
// Set view for menu and breadcrumb
|
// Set view for menu and breadcrumb
|
||||||
// Menu must be set in constructor of documentation class
|
// Menu must be set in constructor of documentation class
|
||||||
|
|||||||
@@ -600,6 +600,7 @@ if ($dirins && $action == 'initsqlextrafields' && !empty($module) && $user->hasR
|
|||||||
// Now we update the object file to set $this->isextrafieldmanaged to 1
|
// Now we update the object file to set $this->isextrafieldmanaged to 1
|
||||||
$srcfile = $dirins.'/'.strtolower($module).'/class/'.strtolower($objectname).'.class.php';
|
$srcfile = $dirins.'/'.strtolower($module).'/class/'.strtolower($objectname).'.class.php';
|
||||||
$arrayreplacement = array('/\$this->isextrafieldmanaged = 0;/' => '$this->isextrafieldmanaged = 1;');
|
$arrayreplacement = array('/\$this->isextrafieldmanaged = 0;/' => '$this->isextrafieldmanaged = 1;');
|
||||||
|
$arrayreplacement = array('/\$isextrafieldmanaged = 0;/' => '$isextrafieldmanaged = 1;');
|
||||||
dolReplaceInFile($srcfile, $arrayreplacement, '', '0', 0, 1);
|
dolReplaceInFile($srcfile, $arrayreplacement, '', '0', 0, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1224,10 +1225,10 @@ if ($dirins && $action == 'initobject' && $module && $objectname && $user->hasRi
|
|||||||
if ($fieldname == 'fk_soc') {
|
if ($fieldname == 'fk_soc') {
|
||||||
$label = 'ThirdParty';
|
$label = 'ThirdParty';
|
||||||
}
|
}
|
||||||
if ($fieldname == 'tms') {
|
if (in_array($fieldname, array('tms', 'date_modification'))) {
|
||||||
$label = 'DateModification';
|
$label = 'DateModification';
|
||||||
}
|
}
|
||||||
if ($fieldname == 'datec') {
|
if (in_array($fieldname, array('datec', 'date_creation'))) {
|
||||||
$label = 'DateCreation';
|
$label = 'DateCreation';
|
||||||
}
|
}
|
||||||
if ($fieldname == 'date_valid') {
|
if ($fieldname == 'date_valid') {
|
||||||
@@ -1320,16 +1321,31 @@ if ($dirins && $action == 'initobject' && $module && $objectname && $user->hasRi
|
|||||||
}
|
}
|
||||||
|
|
||||||
// type
|
// type
|
||||||
if (isset($obj->Picto)) {
|
$picto = '';
|
||||||
|
if (isset($obj->Picto)) { // This should never exists
|
||||||
$picto = $obj->Picto;
|
$picto = $obj->Picto;
|
||||||
}
|
}
|
||||||
if ($obj->Field == 'fk_soc') {
|
if (preg_match('/^fk_soc/', $obj->Field)) {
|
||||||
$picto = 'company';
|
$picto = 'company';
|
||||||
}
|
} elseif (preg_match('/^fk_contact/', $obj->Field)) {
|
||||||
if (preg_match('/^fk_proj/', $obj->Field)) {
|
$picto = 'contact';
|
||||||
|
} elseif (preg_match('/^fk_bank/', $obj->Field)) {
|
||||||
|
$picto = 'bank';
|
||||||
|
} elseif (preg_match('/^fk_user/', $obj->Field)) {
|
||||||
|
$picto = 'user';
|
||||||
|
} elseif (preg_match('/^fk_warehouse/', $obj->Field)) {
|
||||||
|
$picto = 'warehouse';
|
||||||
|
} elseif (preg_match('/^fk_prod/', $obj->Field)) {
|
||||||
|
$picto = 'product';
|
||||||
|
} elseif (preg_match('/^fk_proj/', $obj->Field)) {
|
||||||
$picto = 'project';
|
$picto = 'project';
|
||||||
|
} elseif (preg_match('/^fk_task/', $obj->Field)) {
|
||||||
|
$picto = 'task';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// lang
|
||||||
|
$lang = $module.'@'.$module;
|
||||||
|
|
||||||
// Build the property string
|
// Build the property string
|
||||||
$stringforproperties .= "'".$obj->Field."' => array('type' => '".$type."', 'label' => '".$label."',";
|
$stringforproperties .= "'".$obj->Field."' => array('type' => '".$type."', 'label' => '".$label."',";
|
||||||
if ($default != '') {
|
if ($default != '') {
|
||||||
@@ -1362,6 +1378,9 @@ if ($dirins && $action == 'initobject' && $module && $objectname && $user->hasRi
|
|||||||
if ($csslist) {
|
if ($csslist) {
|
||||||
$stringforproperties .= ", 'csslist' => '".$csslist."'";
|
$stringforproperties .= ", 'csslist' => '".$csslist."'";
|
||||||
}
|
}
|
||||||
|
if ($lang) {
|
||||||
|
$stringforproperties .= ", 'lang' => '".$lang."'";
|
||||||
|
}
|
||||||
$stringforproperties .= "),\n";
|
$stringforproperties .= "),\n";
|
||||||
$i += 5;
|
$i += 5;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,30 +34,41 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php';
|
|||||||
class MyObject extends CommonObject
|
class MyObject extends CommonObject
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @var string ID of module.
|
* @var string ID of module.
|
||||||
*/
|
*/
|
||||||
public $module = 'mymodule';
|
public $module = 'mymodule';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var string ID to identify managed object.
|
* @var string ID to identify managed object.
|
||||||
*/
|
*/
|
||||||
public $element = 'myobject';
|
public $element = 'myobject';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var string Name of table without prefix where object is stored. This is also the key used for extrafields management (so extrafields know the link to the parent table).
|
* @var string Name of table without prefix where object is stored. This is also the key used for extrafields management (so extrafields know the link to the parent table).
|
||||||
*/
|
*/
|
||||||
public $table_element = 'mymodule_myobject';
|
public $table_element = 'mymodule_myobject';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var string If permission must be checkec with hasRight('mymodule', 'read') and not hasright('mymodyle', 'myobject', 'read'), you can uncomment this line
|
* @var string If permission must be checkec with hasRight('mymodule', 'read') and not hasright('mymodyle', 'myobject', 'read'), you can uncomment this line
|
||||||
*/
|
*/
|
||||||
//public $element_for_permission = 'mymodule';
|
//public $element_for_permission = 'mymodule';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var string String with name of icon for myobject. Must be a 'fa-xxx' fontawesome code (or 'fa-xxx_fa_color_size') or 'myobject@mymodule' if picto is file 'img/object_myobject.png'.
|
* @var string String with name of icon for myobject. Must be a 'fa-xxx' fontawesome code (or 'fa-xxx_fa_color_size') or 'myobject@mymodule' if picto is file 'img/object_myobject.png'.
|
||||||
*/
|
*/
|
||||||
public $picto = 'fa-file';
|
public $picto = 'fa-file';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var int<0,1> Does object support extrafields ? 0=No, 1=Yes
|
||||||
|
*/
|
||||||
|
public $isextrafieldmanaged = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var int<0,1>|string Does this object support multicompany module ?
|
||||||
|
* 0=No test on entity, 1=Test with field entity in local table, 'field@table'=Test entity into the field@table (example 'fk_soc@societe')
|
||||||
|
*/
|
||||||
|
public $ismultientitymanaged = 0;
|
||||||
|
|
||||||
|
|
||||||
const STATUS_DRAFT = 0;
|
const STATUS_DRAFT = 0;
|
||||||
const STATUS_VALIDATED = 1;
|
const STATUS_VALIDATED = 1;
|
||||||
@@ -112,24 +123,24 @@ class MyObject extends CommonObject
|
|||||||
* Array with all fields and their property. Do not use it as a static var. It may be modified by constructor.
|
* Array with all fields and their property. Do not use it as a static var. It may be modified by constructor.
|
||||||
*/
|
*/
|
||||||
public $fields = array(
|
public $fields = array(
|
||||||
'rowid' => array('type' => 'integer', 'label' => 'TechnicalID', 'enabled' => 1, 'position' => 1, 'notnull' => 1, 'visible' => 0, 'noteditable' => 1, 'index' => 1, 'css' => 'left', 'comment' => 'Id'),
|
'rowid' => array('type' => 'integer', 'label' => 'TechnicalID', 'enabled' => 1, 'position' => 1, 'notnull' => 1, 'visible' => 0, 'noteditable' => 1, 'index' => 1, 'css' => 'left', 'comment' => 'Id', 'lang' => 'mymodule@mymodule'),
|
||||||
'ref' => array('type' => 'varchar(128)', 'label' => 'Ref', 'enabled' => 1, 'position' => 20, 'notnull' => 1, 'visible' => 1, 'index' => 1, 'searchall' => 1, 'showoncombobox' => 1, 'validate' => 1, 'comment' => 'Reference of object'),
|
'ref' => array('type' => 'varchar(128)', 'label' => 'Ref', 'enabled' => 1, 'position' => 20, 'notnull' => 1, 'visible' => 1, 'index' => 1, 'searchall' => 1, 'showoncombobox' => 1, 'validate' => 1, 'comment' => 'Reference of object', 'lang' => 'mymodule@mymodule'),
|
||||||
'label' => array('type' => 'varchar(255)', 'label' => 'Label', 'enabled' => 1, 'position' => 30, 'notnull' => 0, 'visible' => 1, 'alwayseditable' => 1, 'searchall' => 1, 'css' => 'minwidth300', 'cssview' => 'wordbreak', 'help' => 'Help text', 'showoncombobox' => 2, 'validate' => 1,),
|
'label' => array('type' => 'varchar(255)', 'label' => 'Label', 'enabled' => 1, 'position' => 30, 'notnull' => 0, 'visible' => 1, 'alwayseditable' => 1, 'searchall' => 1, 'css' => 'minwidth300', 'cssview' => 'wordbreak', 'help' => 'Help text', 'showoncombobox' => 2, 'validate' => 1, 'lang' => 'mymodule@mymodule'),
|
||||||
'amount' => array('type' => 'price', 'label' => 'Amount', 'enabled' => 1, 'position' => 40, 'notnull' => 0, 'visible' => 1, 'default' => 'null', 'isameasure' => 1, 'help' => 'Help text for amount', 'validate' => 1,),
|
'amount' => array('type' => 'price', 'label' => 'Amount', 'enabled' => 1, 'position' => 40, 'notnull' => 0, 'visible' => 1, 'default' => 'null', 'isameasure' => 1, 'help' => 'Help text for amount', 'validate' => 1, 'lang' => 'mymodule@mymodule'),
|
||||||
'qty' => array('type' => 'real', 'label' => 'Qty', 'enabled' => 1, 'position' => 45, 'notnull' => 0, 'visible' => 1, 'default' => '0', 'isameasure' => 1, 'css' => 'maxwidth75imp', 'help' => 'Help text for quantity', 'validate' => 1,),
|
'qty' => array('type' => 'real', 'label' => 'Qty', 'enabled' => 1, 'position' => 45, 'notnull' => 0, 'visible' => 1, 'default' => '0', 'isameasure' => 1, 'css' => 'maxwidth75imp', 'help' => 'Help text for quantity', 'validate' => 1, 'lang' => 'mymodule@mymodule'),
|
||||||
'fk_soc' => array('type' => 'integer:Societe:societe/class/societe.class.php:1:((status:=:1) AND (entity:IN:__SHARED_ENTITIES__))', 'label' => 'ThirdParty', 'picto' => 'company', 'enabled' => 'isModEnabled("societe")', 'position' => 50, 'notnull' => -1, 'visible' => 1, 'index' => 1, 'css' => 'maxwidth500 widthcentpercentminusxx', 'csslist' => 'tdoverflowmax150', 'help' => 'OrganizationEventLinkToThirdParty', 'validate' => 1,),
|
'fk_soc' => array('type' => 'integer:Societe:societe/class/societe.class.php:1:((status:=:1) AND (entity:IN:__SHARED_ENTITIES__))', 'label' => 'ThirdParty', 'picto' => 'company', 'enabled' => 'isModEnabled("societe")', 'position' => 50, 'notnull' => -1, 'visible' => 1, 'index' => 1, 'css' => 'maxwidth500 widthcentpercentminusxx', 'csslist' => 'tdoverflowmax150', 'help' => 'OrganizationEventLinkToThirdParty', 'validate' => 1, 'lang' => 'mymodule@mymodule'),
|
||||||
'fk_project' => array('type' => 'integer:Project:projet/class/project.class.php:1', 'label' => 'Project', 'picto' => 'project', 'enabled' => 'isModEnabled("project")', 'position' => 52, 'notnull' => -1, 'visible' => -1, 'index' => 1, 'css' => 'maxwidth500 widthcentpercentminusxx', 'csslist' => 'tdoverflowmax150', 'validate' => 1,),
|
'fk_project' => array('type' => 'integer:Project:projet/class/project.class.php:1', 'label' => 'Project', 'picto' => 'project', 'enabled' => 'isModEnabled("project")', 'position' => 52, 'notnull' => -1, 'visible' => -1, 'index' => 1, 'css' => 'maxwidth500 widthcentpercentminusxx', 'csslist' => 'tdoverflowmax150', 'validate' => 1, 'lang' => 'mymodule@mymodule'),
|
||||||
'description' => array('type' => 'text', 'label' => 'Description', 'enabled' => 1, 'position' => 60, 'notnull' => 0, 'visible' => 3, 'validate' => 1,),
|
'description' => array('type' => 'text', 'label' => 'Description', 'enabled' => 1, 'position' => 60, 'notnull' => 0, 'visible' => 3, 'validate' => 1, 'lang' => 'mymodule@mymodule'),
|
||||||
'note_public' => array('type' => 'html', 'label' => 'NotePublic', 'enabled' => 1, 'position' => 61, 'notnull' => 0, 'visible' => 0, 'cssview' => 'wordbreak', 'validate' => 1,),
|
'note_public' => array('type' => 'html', 'label' => 'NotePublic', 'enabled' => 1, 'position' => 61, 'notnull' => 0, 'visible' => 0, 'cssview' => 'wordbreak', 'validate' => 1, 'lang' => 'mymodule@mymodule'),
|
||||||
'note_private' => array('type' => 'html', 'label' => 'NotePrivate', 'enabled' => 1, 'position' => 62, 'notnull' => 0, 'visible' => 0, 'cssview' => 'wordbreak', 'validate' => 1,),
|
'note_private' => array('type' => 'html', 'label' => 'NotePrivate', 'enabled' => 1, 'position' => 62, 'notnull' => 0, 'visible' => 0, 'cssview' => 'wordbreak', 'validate' => 1, 'lang' => 'mymodule@mymodule'),
|
||||||
'date_creation' => array('type' => 'datetime', 'label' => 'DateCreation', 'enabled' => 1, 'position' => 500, 'notnull' => 1, 'visible' => -2,),
|
'date_creation' => array('type' => 'datetime', 'label' => 'DateCreation', 'enabled' => 1, 'position' => 500, 'notnull' => 1, 'visible' => -2, 'lang' => 'mymodule@mymodule'),
|
||||||
'tms' => array('type' => 'timestamp', 'label' => 'DateModification', 'enabled' => 1, 'position' => 501, 'notnull' => 0, 'visible' => -2,),
|
'tms' => array('type' => 'timestamp', 'label' => 'DateModification', 'enabled' => 1, 'position' => 501, 'notnull' => 0, 'visible' => -2, 'lang' => 'mymodule@mymodule'),
|
||||||
'fk_user_creat' => array('type' => 'integer:User:user/class/user.class.php', 'label' => 'UserAuthor', 'picto' => 'user', 'enabled' => 1, 'position' => 510, 'notnull' => 1, 'visible' => -2, 'foreignkey' => '0', 'csslist' => 'tdoverflowmax150',),
|
'fk_user_creat' => array('type' => 'integer:User:user/class/user.class.php', 'label' => 'UserAuthor', 'picto' => 'user', 'enabled' => 1, 'position' => 510, 'notnull' => 1, 'visible' => -2, 'foreignkey' => '0', 'csslist' => 'tdoverflowmax150', 'lang' => 'mymodule@mymodule'),
|
||||||
'fk_user_modif' => array('type' => 'integer:User:user/class/user.class.php', 'label' => 'UserModif', 'picto' => 'user', 'enabled' => 1, 'position' => 511, 'notnull' => -1, 'visible' => -2, 'csslist' => 'tdoverflowmax150',),
|
'fk_user_modif' => array('type' => 'integer:User:user/class/user.class.php', 'label' => 'UserModif', 'picto' => 'user', 'enabled' => 1, 'position' => 511, 'notnull' => -1, 'visible' => -2, 'csslist' => 'tdoverflowmax150', 'lang' => 'mymodule@mymodule'),
|
||||||
'last_main_doc' => array('type' => 'varchar(255)', 'label' => 'LastMainDoc', 'enabled' => 1, 'position' => 600, 'notnull' => 0, 'visible' => 0,),
|
'last_main_doc' => array('type' => 'varchar(255)', 'label' => 'LastMainDoc', 'enabled' => 1, 'position' => 600, 'notnull' => 0, 'visible' => 0, 'lang' => 'mymodule@mymodule'),
|
||||||
'import_key' => array('type' => 'varchar(14)', 'label' => 'ImportId', 'enabled' => 1, 'position' => 1000, 'notnull' => -1, 'visible' => -2,),
|
'import_key' => array('type' => 'varchar(14)', 'label' => 'ImportId', 'enabled' => 1, 'position' => 1000, 'notnull' => -1, 'visible' => -2, 'lang' => 'mymodule@mymodule'),
|
||||||
'model_pdf' => array('type' => 'varchar(255)', 'label' => 'Model pdf', 'enabled' => 1, 'position' => 1010, 'notnull' => -1, 'visible' => 0,),
|
'model_pdf' => array('type' => 'varchar(255)', 'label' => 'Model pdf', 'enabled' => 1, 'position' => 1010, 'notnull' => -1, 'visible' => 0, 'lang' => 'mymodule@mymodule'),
|
||||||
'status' => array('type' => 'integer', 'label' => 'Status', 'enabled' => 1, 'position' => 2000, 'notnull' => 1, 'visible' => 1, 'index' => 1, 'arrayofkeyval' => array(0 => 'Draft', '1' => 'Validated', 9 => 'Canceled'), 'validate' => 1,),
|
'status' => array('type' => 'integer', 'label' => 'Status', 'enabled' => 1, 'position' => 2000, 'notnull' => 1, 'visible' => 1, 'index' => 1, 'arrayofkeyval' => array(0 => 'Draft', '1' => 'Validated', 9 => 'Canceled'), 'validate' => 1, 'lang' => 'mymodule@mymodule'),
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -240,8 +251,6 @@ class MyObject extends CommonObject
|
|||||||
global $langs;
|
global $langs;
|
||||||
|
|
||||||
$this->db = $db;
|
$this->db = $db;
|
||||||
$this->ismultientitymanaged = 0;
|
|
||||||
$this->isextrafieldmanaged = 1;
|
|
||||||
|
|
||||||
if (!getDolGlobalInt('MAIN_SHOW_TECHNICAL_ID') && isset($this->fields['rowid']) && !empty($this->fields['ref'])) {
|
if (!getDolGlobalInt('MAIN_SHOW_TECHNICAL_ID') && isset($this->fields['rowid']) && !empty($this->fields['ref'])) {
|
||||||
$this->fields['rowid']['visible'] = 0;
|
$this->fields['rowid']['visible'] = 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user