29 include_once DOL_DOCUMENT_ROOT.
'/core/modules/DolibarrModules.class.php';
48 $this->numero = 500000;
51 $this->rights_class =
'mymodule';
55 $this->family =
"other";
58 $this->module_position =
'90';
63 $this->
name = preg_replace(
'/^mod/i',
'', get_class($this));
68 $this->descriptionlong =
"MyModuleDescription";
71 $this->editor_name =
'Editor name';
72 $this->editor_url =
'https://www.example.com';
75 $this->version =
'1.0';
80 $this->const_name =
'MAIN_MODULE_'.strtoupper($this->
name);
86 $this->picto =
'generic';
89 $this->module_parts = array(
125 'moduleforexternal' => 0,
130 $this->dirs = array(
"/mymodule/temp");
133 $this->config_page_url = array(
"setup.php@mymodule");
137 $this->hidden =
false;
139 $this->depends = array();
140 $this->requiredby = array();
141 $this->conflictwith = array();
144 $this->langfiles = array(
"mymodule@mymodule");
147 $this->phpmin = array(5, 5);
148 $this->need_dolibarr_version = array(11, -3);
151 $this->warnings_activation = array();
152 $this->warnings_activation_ext = array();
161 $this->
const = array();
169 if (!isset($conf->mymodule) || !isset($conf->mymodule->enabled)) {
170 $conf->mymodule =
new stdClass();
171 $conf->mymodule->enabled = 0;
175 $this->tabs = array();
203 $this->dictionaries = array();
230 $this->boxes = array(
241 $this->cronjobs = array(
263 $this->rights = array();
267 $this->rights[$r][0] = $this->numero + $r;
268 $this->rights[$r][1] =
'Read objects of MyModule';
269 $this->rights[$r][4] =
'myobject';
270 $this->rights[$r][5] =
'read';
272 $this->rights[$r][0] = $this->numero + $r;
273 $this->rights[$r][1] =
'Create/Update objects of MyModule';
274 $this->rights[$r][4] =
'myobject';
275 $this->rights[$r][5] =
'write';
277 $this->rights[$r][0] = $this->numero + $r;
278 $this->rights[$r][1] =
'Delete objects of MyModule';
279 $this->rights[$r][4] =
'myobject';
280 $this->rights[$r][5] =
'delete';
285 $this->menu = array();
289 $this->menu[$r++] = array(
292 'titre'=>
'ModuleMyModuleName',
293 'mainmenu'=>
'mymodule',
295 'url'=>
'/mymodule/mymoduleindex.php',
296 'langs'=>
'mymodule@mymodule',
297 'position'=>1000 + $r,
298 'enabled'=>
'$conf->mymodule->enabled',
408 public function init($options =
'')
410 global $conf, $langs;
413 if ($result < 0)
return -1;
425 $this->
remove($options);
430 $moduledir =
'mymodule';
431 $myTmpObjects = array();
432 $myTmpObjects[
'MyObject'] = array(
'includerefgeneration'=>0,
'includedocgeneration'=>0);
434 foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) {
435 if ($myTmpObjectKey ==
'MyObject')
continue;
436 if ($myTmpObjectArray[
'includerefgeneration']) {
437 $src = DOL_DOCUMENT_ROOT.
'/install/doctemplates/mymodule/template_myobjects.odt';
438 $dirodt = DOL_DATA_ROOT.
'/doctemplates/mymodule';
439 $dest = $dirodt.
'/template_myobjects.odt';
441 if (file_exists($src) && !file_exists($dest))
443 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
445 $result =
dol_copy($src, $dest, 0, 0);
448 $langs->load(
"errors");
449 $this->error = $langs->trans(
'ErrorFailToCopyFile', $src, $dest);
454 $sql = array_merge($sql, array(
455 "DELETE FROM ".MAIN_DB_PREFIX.
"document_model WHERE nom = 'standard_".strtolower($myTmpObjectKey).
"' AND type = '".strtolower($myTmpObjectKey).
"' AND entity = ".$conf->entity,
456 "INSERT INTO ".MAIN_DB_PREFIX.
"document_model (nom, type, entity) VALUES('standard_".strtolower($myTmpObjectKey).
"','".strtolower($myTmpObjectKey).
"',".$conf->entity.
")",
457 "DELETE FROM ".MAIN_DB_PREFIX.
"document_model WHERE nom = 'generic_".strtolower($myTmpObjectKey).
"_odt' AND type = '".strtolower($myTmpObjectKey).
"' AND entity = ".$conf->entity,
458 "INSERT INTO ".MAIN_DB_PREFIX.
"document_model (nom, type, entity) VALUES('generic_".strtolower($myTmpObjectKey).
"_odt', '".strtolower($myTmpObjectKey).
"', ".$conf->entity.
")"
463 return $this->
_init($sql, $options);
474 public function remove($options =
'')
477 return $this->
_remove($sql, $options);
dol_copy($srcfile, $destfile, $newmask=0, $overwriteifexists=1)
Copy a file to another file.
__construct($db)
Constructor.
</td > param sortfield sortorder printFieldListOption< tdclass="liste_titremaxwidthsearchright"></td ></tr >< trclass="liste_titre">< inputtype="checkbox"onClick="toggle(this)"/> Ref p ref Label p label Duration p duration center DesiredStock p desiredstock right StockLimitShort p seuil_stock_alerte right stock_physique right stock_real_warehouse right Ordered right StockToBuy right SupplierRef right param sortfield sortorder printFieldListTitle warehouseinternal SELECT description FROM product_lang WHERE qty< br > qty qty qty StockTooLow StockTooLow help help help< trclass="oddeven">< td >< inputtype="checkbox"class="check"name="choose'.$i.'"></td >< tdclass="nowrap"> stock</td >< td >< inputtype="hidden"name="desc'.$i.'"value="'.dol_escape_htmltag($objp-> description
Only used if Module[ID]Desc translation string is not found.
$conf db name
Only used if Module[ID]Name translation string is not found.
$conf db
API class for accounts.
_remove($array_sql, $options= '')
Disable function.
init($options= '')
Function called when module is enabled.
_init($array_sql, $options= '')
Enables a module.
Description and activation class for module MyModule.
dol_mkdir($dir, $dataroot= '', $newmask=null)
Creation of a directory (this can create recursive subdir)
_load_tables($reldir)
Create tables and keys required by module.