diff --git a/htdocs/modulebuilder/template/class/actions_mymodule.class.php b/htdocs/modulebuilder/template/class/actions_mymodule.class.php
index 91dae82343b..10bca2e8b9a 100644
--- a/htdocs/modulebuilder/template/class/actions_mymodule.class.php
+++ b/htdocs/modulebuilder/template/class/actions_mymodule.class.php
@@ -28,284 +28,284 @@
*/
class ActionsMyModule
{
- /**
- * @var DoliDB Database handler.
- */
- public $db;
+ /**
+ * @var DoliDB Database handler.
+ */
+ public $db;
- /**
- * @var string Error code (or message)
- */
- public $error = '';
+ /**
+ * @var string Error code (or message)
+ */
+ public $error = '';
- /**
- * @var array Errors
- */
- public $errors = array();
+ /**
+ * @var array Errors
+ */
+ public $errors = array();
- /**
- * @var array Hook results. Propagated to $hookmanager->resArray for later reuse
- */
- public $results = array();
+ /**
+ * @var array Hook results. Propagated to $hookmanager->resArray for later reuse
+ */
+ public $results = array();
- /**
- * @var string String displayed by executeHook() immediately after return
- */
- public $resprints;
+ /**
+ * @var string String displayed by executeHook() immediately after return
+ */
+ public $resprints;
- /**
- * Constructor
- *
- * @param DoliDB $db Database handler
- */
- public function __construct($db)
- {
- $this->db = $db;
- }
+ /**
+ * Constructor
+ *
+ * @param DoliDB $db Database handler
+ */
+ public function __construct($db)
+ {
+ $this->db = $db;
+ }
- /**
- * Execute action
- *
- * @param array $parameters Array of parameters
- * @param CommonObject $object The object to process (an invoice if you are in invoice module, a propale in propale's module, etc...)
- * @param string $action 'add', 'update', 'view'
- * @return int <0 if KO,
- * =0 if OK but we want to process standard actions too,
- * >0 if OK and we want to replace standard actions.
- */
- public function getNomUrl($parameters, &$object, &$action)
- {
- global $db, $langs, $conf, $user;
- $this->resprints = '';
- return 0;
- }
+ /**
+ * Execute action
+ *
+ * @param array $parameters Array of parameters
+ * @param CommonObject $object The object to process (an invoice if you are in invoice module, a propale in propale's module, etc...)
+ * @param string $action 'add', 'update', 'view'
+ * @return int <0 if KO,
+ * =0 if OK but we want to process standard actions too,
+ * >0 if OK and we want to replace standard actions.
+ */
+ public function getNomUrl($parameters, &$object, &$action)
+ {
+ global $db, $langs, $conf, $user;
+ $this->resprints = '';
+ return 0;
+ }
- /**
- * Overloading the doActions function : replacing the parent's function with the one below
- *
- * @param array $parameters Hook metadatas (context, etc...)
- * @param CommonObject $object The object to process (an invoice if you are in invoice module, a propale in propale's module, etc...)
- * @param string $action Current action (if set). Generally create or edit or null
- * @param HookManager $hookmanager Hook manager propagated to allow calling another hook
- * @return int < 0 on error, 0 on success, 1 to replace standard code
- */
- public function doActions($parameters, &$object, &$action, $hookmanager)
- {
- global $conf, $user, $langs;
+ /**
+ * Overloading the doActions function : replacing the parent's function with the one below
+ *
+ * @param array $parameters Hook metadatas (context, etc...)
+ * @param CommonObject $object The object to process (an invoice if you are in invoice module, a propale in propale's module, etc...)
+ * @param string $action Current action (if set). Generally create or edit or null
+ * @param HookManager $hookmanager Hook manager propagated to allow calling another hook
+ * @return int < 0 on error, 0 on success, 1 to replace standard code
+ */
+ public function doActions($parameters, &$object, &$action, $hookmanager)
+ {
+ global $conf, $user, $langs;
- $error = 0; // Error counter
+ $error = 0; // Error counter
- /* print_r($parameters); print_r($object); echo "action: " . $action; */
- if (in_array($parameters['currentcontext'], array('somecontext1', 'somecontext2'))) // do something only for the context 'somecontext1' or 'somecontext2'
- {
- // Do what you want here...
- // You can for example call global vars like $fieldstosearchall to overwrite them, or update database depending on $action and $_POST values.
- }
+ /* print_r($parameters); print_r($object); echo "action: " . $action; */
+ if (in_array($parameters['currentcontext'], array('somecontext1', 'somecontext2'))) // do something only for the context 'somecontext1' or 'somecontext2'
+ {
+ // Do what you want here...
+ // You can for example call global vars like $fieldstosearchall to overwrite them, or update database depending on $action and $_POST values.
+ }
- if (!$error) {
- $this->results = array('myreturn' => 999);
- $this->resprints = 'A text to show';
- return 0; // or return 1 to replace standard code
- } else {
- $this->errors[] = 'Error message';
- return -1;
- }
- }
+ if (!$error) {
+ $this->results = array('myreturn' => 999);
+ $this->resprints = 'A text to show';
+ return 0; // or return 1 to replace standard code
+ } else {
+ $this->errors[] = 'Error message';
+ return -1;
+ }
+ }
- /**
- * Overloading the doMassActions function : replacing the parent's function with the one below
- *
- * @param array $parameters Hook metadatas (context, etc...)
- * @param CommonObject $object The object to process (an invoice if you are in invoice module, a propale in propale's module, etc...)
- * @param string $action Current action (if set). Generally create or edit or null
- * @param HookManager $hookmanager Hook manager propagated to allow calling another hook
- * @return int < 0 on error, 0 on success, 1 to replace standard code
- */
- public function doMassActions($parameters, &$object, &$action, $hookmanager)
- {
- global $conf, $user, $langs;
+ /**
+ * Overloading the doMassActions function : replacing the parent's function with the one below
+ *
+ * @param array $parameters Hook metadatas (context, etc...)
+ * @param CommonObject $object The object to process (an invoice if you are in invoice module, a propale in propale's module, etc...)
+ * @param string $action Current action (if set). Generally create or edit or null
+ * @param HookManager $hookmanager Hook manager propagated to allow calling another hook
+ * @return int < 0 on error, 0 on success, 1 to replace standard code
+ */
+ public function doMassActions($parameters, &$object, &$action, $hookmanager)
+ {
+ global $conf, $user, $langs;
- $error = 0; // Error counter
+ $error = 0; // Error counter
- /* print_r($parameters); print_r($object); echo "action: " . $action; */
- if (in_array($parameters['currentcontext'], array('somecontext1', 'somecontext2'))) // do something only for the context 'somecontext1' or 'somecontext2'
- {
- foreach ($parameters['toselect'] as $objectid)
- {
- // Do action on each object id
- }
- }
+ /* print_r($parameters); print_r($object); echo "action: " . $action; */
+ if (in_array($parameters['currentcontext'], array('somecontext1', 'somecontext2'))) // do something only for the context 'somecontext1' or 'somecontext2'
+ {
+ foreach ($parameters['toselect'] as $objectid)
+ {
+ // Do action on each object id
+ }
+ }
- if (!$error) {
- $this->results = array('myreturn' => 999);
- $this->resprints = 'A text to show';
- return 0; // or return 1 to replace standard code
- } else {
- $this->errors[] = 'Error message';
- return -1;
- }
- }
+ if (!$error) {
+ $this->results = array('myreturn' => 999);
+ $this->resprints = 'A text to show';
+ return 0; // or return 1 to replace standard code
+ } else {
+ $this->errors[] = 'Error message';
+ return -1;
+ }
+ }
- /**
- * Overloading the addMoreMassActions function : replacing the parent's function with the one below
- *
- * @param array $parameters Hook metadatas (context, etc...)
- * @param CommonObject $object The object to process (an invoice if you are in invoice module, a propale in propale's module, etc...)
- * @param string $action Current action (if set). Generally create or edit or null
- * @param HookManager $hookmanager Hook manager propagated to allow calling another hook
- * @return int < 0 on error, 0 on success, 1 to replace standard code
- */
- public function addMoreMassActions($parameters, &$object, &$action, $hookmanager)
- {
- global $conf, $user, $langs;
+ /**
+ * Overloading the addMoreMassActions function : replacing the parent's function with the one below
+ *
+ * @param array $parameters Hook metadatas (context, etc...)
+ * @param CommonObject $object The object to process (an invoice if you are in invoice module, a propale in propale's module, etc...)
+ * @param string $action Current action (if set). Generally create or edit or null
+ * @param HookManager $hookmanager Hook manager propagated to allow calling another hook
+ * @return int < 0 on error, 0 on success, 1 to replace standard code
+ */
+ public function addMoreMassActions($parameters, &$object, &$action, $hookmanager)
+ {
+ global $conf, $user, $langs;
- $error = 0; // Error counter
+ $error = 0; // Error counter
- /* print_r($parameters); print_r($object); echo "action: " . $action; */
- if (in_array($parameters['currentcontext'], array('somecontext1', 'somecontext2'))) // do something only for the context 'somecontext1' or 'somecontext2'
- {
- $this->resprints = '';
- }
+ /* print_r($parameters); print_r($object); echo "action: " . $action; */
+ if (in_array($parameters['currentcontext'], array('somecontext1', 'somecontext2'))) // do something only for the context 'somecontext1' or 'somecontext2'
+ {
+ $this->resprints = '';
+ }
- if (!$error) {
- return 0; // or return 1 to replace standard code
- } else {
- $this->errors[] = 'Error message';
- return -1;
- }
- }
+ if (!$error) {
+ return 0; // or return 1 to replace standard code
+ } else {
+ $this->errors[] = 'Error message';
+ return -1;
+ }
+ }
- /**
- * Execute action
- *
- * @param array $parameters Array of parameters
- * @param Object $object Object output on PDF
- * @param string $action 'add', 'update', 'view'
- * @return int <0 if KO,
- * =0 if OK but we want to process standard actions too,
- * >0 if OK and we want to replace standard actions.
- */
- public function beforePDFCreation($parameters, &$object, &$action)
- {
- global $conf, $user, $langs;
- global $hookmanager;
+ /**
+ * Execute action
+ *
+ * @param array $parameters Array of parameters
+ * @param Object $object Object output on PDF
+ * @param string $action 'add', 'update', 'view'
+ * @return int <0 if KO,
+ * =0 if OK but we want to process standard actions too,
+ * >0 if OK and we want to replace standard actions.
+ */
+ public function beforePDFCreation($parameters, &$object, &$action)
+ {
+ global $conf, $user, $langs;
+ global $hookmanager;
- $outputlangs = $langs;
+ $outputlangs = $langs;
- $ret = 0; $deltemp = array();
- dol_syslog(get_class($this).'::executeHooks action='.$action);
+ $ret = 0; $deltemp = array();
+ dol_syslog(get_class($this).'::executeHooks action='.$action);
- /* print_r($parameters); print_r($object); echo "action: " . $action; */
- if (in_array($parameters['currentcontext'], array('somecontext1', 'somecontext2'))) // do something only for the context 'somecontext1' or 'somecontext2'
- {
- }
+ /* print_r($parameters); print_r($object); echo "action: " . $action; */
+ if (in_array($parameters['currentcontext'], array('somecontext1', 'somecontext2'))) // do something only for the context 'somecontext1' or 'somecontext2'
+ {
+ }
- return $ret;
- }
+ return $ret;
+ }
- /**
- * Execute action
- *
- * @param array $parameters Array of parameters
- * @param Object $pdfhandler PDF builder handler
- * @param string $action 'add', 'update', 'view'
- * @return int <0 if KO,
- * =0 if OK but we want to process standard actions too,
- * >0 if OK and we want to replace standard actions.
- */
- public function afterPDFCreation($parameters, &$pdfhandler, &$action)
- {
- global $conf, $user, $langs;
- global $hookmanager;
+ /**
+ * Execute action
+ *
+ * @param array $parameters Array of parameters
+ * @param Object $pdfhandler PDF builder handler
+ * @param string $action 'add', 'update', 'view'
+ * @return int <0 if KO,
+ * =0 if OK but we want to process standard actions too,
+ * >0 if OK and we want to replace standard actions.
+ */
+ public function afterPDFCreation($parameters, &$pdfhandler, &$action)
+ {
+ global $conf, $user, $langs;
+ global $hookmanager;
- $outputlangs = $langs;
+ $outputlangs = $langs;
- $ret = 0; $deltemp = array();
- dol_syslog(get_class($this).'::executeHooks action='.$action);
+ $ret = 0; $deltemp = array();
+ dol_syslog(get_class($this).'::executeHooks action='.$action);
- /* print_r($parameters); print_r($object); echo "action: " . $action; */
- if (in_array($parameters['currentcontext'], array('somecontext1', 'somecontext2'))) // do something only for the context 'somecontext1' or 'somecontext2'
- {
- }
+ /* print_r($parameters); print_r($object); echo "action: " . $action; */
+ if (in_array($parameters['currentcontext'], array('somecontext1', 'somecontext2'))) // do something only for the context 'somecontext1' or 'somecontext2'
+ {
+ }
- return $ret;
- }
+ return $ret;
+ }
- /**
- * Overloading the loadDataForCustomReports function : returns data to complete the customreport tool
- *
- * @param array $parameters Hook metadatas (context, etc...)
- * @param string $action Current action (if set). Generally create or edit or null
- * @param HookManager $hookmanager Hook manager propagated to allow calling another hook
- * @return int < 0 on error, 0 on success, 1 to replace standard code
- */
- public function loadDataForCustomReports($parameters, &$action, $hookmanager)
- {
- global $conf, $user, $langs;
+ /**
+ * Overloading the loadDataForCustomReports function : returns data to complete the customreport tool
+ *
+ * @param array $parameters Hook metadatas (context, etc...)
+ * @param string $action Current action (if set). Generally create or edit or null
+ * @param HookManager $hookmanager Hook manager propagated to allow calling another hook
+ * @return int < 0 on error, 0 on success, 1 to replace standard code
+ */
+ public function loadDataForCustomReports($parameters, &$action, $hookmanager)
+ {
+ global $conf, $user, $langs;
- $langs->load("mymodule@mymodule");
+ $langs->load("mymodule@mymodule");
- $this->results = array();
+ $this->results = array();
- $head = array();
- $h = 0;
+ $head = array();
+ $h = 0;
- if ($parameters['tabfamily'] == 'mymodule') {
- $head[$h][0] = dol_buildpath('/module/index.php', 1);
- $head[$h][1] = $langs->trans("Home");
- $head[$h][2] = 'home';
- $h++;
+ if ($parameters['tabfamily'] == 'mymodule') {
+ $head[$h][0] = dol_buildpath('/module/index.php', 1);
+ $head[$h][1] = $langs->trans("Home");
+ $head[$h][2] = 'home';
+ $h++;
- $this->results['title'] = $langs->trans("MyModule");
- $this->results['picto'] = 'mymodule@mymodule';
- }
+ $this->results['title'] = $langs->trans("MyModule");
+ $this->results['picto'] = 'mymodule@mymodule';
+ }
- $head[$h][0] = 'customreports.php?objecttype='.$parameters['objecttype'].(empty($parameters['tabfamily']) ? '' : '&tabfamily='.$parameters['tabfamily']);
- $head[$h][1] = $langs->trans("CustomReports");
- $head[$h][2] = 'customreports';
+ $head[$h][0] = 'customreports.php?objecttype='.$parameters['objecttype'].(empty($parameters['tabfamily']) ? '' : '&tabfamily='.$parameters['tabfamily']);
+ $head[$h][1] = $langs->trans("CustomReports");
+ $head[$h][2] = 'customreports';
- $this->results['head'] = $head;
+ $this->results['head'] = $head;
- return 1;
- }
+ return 1;
+ }
- /**
- * Overloading the restrictedArea function : check permission on an object
- *
- * @param array $parameters Hook metadatas (context, etc...)
- * @param string $action Current action (if set). Generally create or edit or null
- * @param HookManager $hookmanager Hook manager propagated to allow calling another hook
- * @return int <0 if KO,
- * =0 if OK but we want to process standard actions too,
- * >0 if OK and we want to replace standard actions.
- */
- public function restrictedArea($parameters, &$action, $hookmanager)
- {
- global $user;
+ /**
+ * Overloading the restrictedArea function : check permission on an object
+ *
+ * @param array $parameters Hook metadatas (context, etc...)
+ * @param string $action Current action (if set). Generally create or edit or null
+ * @param HookManager $hookmanager Hook manager propagated to allow calling another hook
+ * @return int <0 if KO,
+ * =0 if OK but we want to process standard actions too,
+ * >0 if OK and we want to replace standard actions.
+ */
+ public function restrictedArea($parameters, &$action, $hookmanager)
+ {
+ global $user;
- if ($parameters['features'] == 'myobject') {
- if ($user->rights->mymodule->myobject->read) {
- $this->results['result'] = 1;
- return 1;
- } else {
- $this->results['result'] = 0;
- return 1;
- }
- }
+ if ($parameters['features'] == 'myobject') {
+ if ($user->rights->mymodule->myobject->read) {
+ $this->results['result'] = 1;
+ return 1;
+ } else {
+ $this->results['result'] = 0;
+ return 1;
+ }
+ }
- return 0;
- }
+ return 0;
+ }
- /* Add here any other hooked methods... */
+ /* Add here any other hooked methods... */
}
diff --git a/htdocs/modulebuilder/template/class/api_mymodule.class.php b/htdocs/modulebuilder/template/class/api_mymodule.class.php
index 8477e3efdf6..f84210b9198 100644
--- a/htdocs/modulebuilder/template/class/api_mymodule.class.php
+++ b/htdocs/modulebuilder/template/class/api_mymodule.class.php
@@ -36,338 +36,338 @@ dol_include_once('/mymodule/class/myobject.class.php');
*/
class MyModuleApi extends DolibarrApi
{
- /**
- * @var MyObject $myobject {@type MyObject}
- */
- public $myobject;
+ /**
+ * @var MyObject $myobject {@type MyObject}
+ */
+ public $myobject;
- /**
- * Constructor
- *
- * @url GET /
- *
- */
- public function __construct()
- {
- global $db, $conf;
- $this->db = $db;
- $this->myobject = new MyObject($this->db);
- }
+ /**
+ * Constructor
+ *
+ * @url GET /
+ *
+ */
+ public function __construct()
+ {
+ global $db, $conf;
+ $this->db = $db;
+ $this->myobject = new MyObject($this->db);
+ }
- /**
- * Get properties of a myobject object
- *
- * Return an array with myobject informations
- *
- * @param int $id ID of myobject
- * @return array|mixed data without useless information
- *
- * @url GET myobjects/{id}
- *
- * @throws RestException
- */
- public function get($id)
- {
- if (!DolibarrApiAccess::$user->rights->mymodule->read) {
- throw new RestException(401);
- }
+ /**
+ * Get properties of a myobject object
+ *
+ * Return an array with myobject informations
+ *
+ * @param int $id ID of myobject
+ * @return array|mixed data without useless information
+ *
+ * @url GET myobjects/{id}
+ *
+ * @throws RestException
+ */
+ public function get($id)
+ {
+ if (!DolibarrApiAccess::$user->rights->mymodule->read) {
+ throw new RestException(401);
+ }
- $result = $this->myobject->fetch($id);
- if (!$result) {
- throw new RestException(404, 'MyObject not found');
- }
+ $result = $this->myobject->fetch($id);
+ if (!$result) {
+ throw new RestException(404, 'MyObject not found');
+ }
- if (!DolibarrApi::_checkAccessToResource('myobject', $this->myobject->id, 'mymodule_myobject')) {
- throw new RestException(401, 'Access to instance id='.$this->myobject->id.' of object not allowed for login '.DolibarrApiAccess::$user->login);
- }
+ if (!DolibarrApi::_checkAccessToResource('myobject', $this->myobject->id, 'mymodule_myobject')) {
+ throw new RestException(401, 'Access to instance id='.$this->myobject->id.' of object not allowed for login '.DolibarrApiAccess::$user->login);
+ }
- return $this->_cleanObjectDatas($this->myobject);
- }
+ return $this->_cleanObjectDatas($this->myobject);
+ }
- /**
- * List myobjects
- *
- * Get a list of myobjects
- *
- * @param string $sortfield Sort field
- * @param string $sortorder Sort order
- * @param int $limit Limit for list
- * @param int $page Page number
- * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.date_creation:<:'20160101')"
- * @return array Array of order objects
- *
- * @throws RestException
- *
- * @url GET /myobjects/
- */
- public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $sqlfilters = '')
- {
- global $db, $conf;
+ /**
+ * List myobjects
+ *
+ * Get a list of myobjects
+ *
+ * @param string $sortfield Sort field
+ * @param string $sortorder Sort order
+ * @param int $limit Limit for list
+ * @param int $page Page number
+ * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.date_creation:<:'20160101')"
+ * @return array Array of order objects
+ *
+ * @throws RestException
+ *
+ * @url GET /myobjects/
+ */
+ public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $sqlfilters = '')
+ {
+ global $db, $conf;
- $obj_ret = array();
- $tmpobject = new MyObject($db);
+ $obj_ret = array();
+ $tmpobject = new MyObject($db);
- if (!DolibarrApiAccess::$user->rights->bbb->read) {
- throw new RestException(401);
- }
+ if (!DolibarrApiAccess::$user->rights->bbb->read) {
+ throw new RestException(401);
+ }
- $socid = DolibarrApiAccess::$user->socid ? DolibarrApiAccess::$user->socid : '';
+ $socid = DolibarrApiAccess::$user->socid ? DolibarrApiAccess::$user->socid : '';
- $restrictonsocid = 0; // Set to 1 if there is a field socid in table of object
+ $restrictonsocid = 0; // Set to 1 if there is a field socid in table of object
- // If the internal user must only see his customers, force searching by him
- $search_sale = 0;
- if ($restrictonsocid && !DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) $search_sale = DolibarrApiAccess::$user->id;
+ // If the internal user must only see his customers, force searching by him
+ $search_sale = 0;
+ if ($restrictonsocid && !DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) $search_sale = DolibarrApiAccess::$user->id;
- $sql = "SELECT t.rowid";
- if ($restrictonsocid && (!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql .= ", sc.fk_soc, sc.fk_user"; // We need these fields in order to filter by sale (including the case where the user can only see his prospects)
- $sql .= " FROM ".MAIN_DB_PREFIX.$tmpobject->table_element." as t";
+ $sql = "SELECT t.rowid";
+ if ($restrictonsocid && (!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql .= ", sc.fk_soc, sc.fk_user"; // We need these fields in order to filter by sale (including the case where the user can only see his prospects)
+ $sql .= " FROM ".MAIN_DB_PREFIX.$tmpobject->table_element." as t";
- if ($restrictonsocid && (!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale
- $sql .= " WHERE 1 = 1";
+ if ($restrictonsocid && (!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale
+ $sql .= " WHERE 1 = 1";
- // Example of use $mode
- //if ($mode == 1) $sql.= " AND s.client IN (1, 3)";
- //if ($mode == 2) $sql.= " AND s.client IN (2, 3)";
+ // Example of use $mode
+ //if ($mode == 1) $sql.= " AND s.client IN (1, 3)";
+ //if ($mode == 2) $sql.= " AND s.client IN (2, 3)";
- if ($tmpobject->ismultientitymanaged) $sql .= ' AND t.entity IN ('.getEntity('myobject').')';
- if ($restrictonsocid && (!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql .= " AND t.fk_soc = sc.fk_soc";
- if ($restrictonsocid && $socid) $sql .= " AND t.fk_soc = ".$socid;
- if ($restrictonsocid && $search_sale > 0) $sql .= " AND t.rowid = sc.fk_soc"; // Join for the needed table to filter by sale
- // Insert sale filter
- if ($restrictonsocid && $search_sale > 0) {
- $sql .= " AND sc.fk_user = ".$search_sale;
- }
- if ($sqlfilters)
- {
- if (!DolibarrApi::_checkFilters($sqlfilters)) {
- throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters);
- }
- $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
- $sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
- }
+ if ($tmpobject->ismultientitymanaged) $sql .= ' AND t.entity IN ('.getEntity('myobject').')';
+ if ($restrictonsocid && (!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql .= " AND t.fk_soc = sc.fk_soc";
+ if ($restrictonsocid && $socid) $sql .= " AND t.fk_soc = ".$socid;
+ if ($restrictonsocid && $search_sale > 0) $sql .= " AND t.rowid = sc.fk_soc"; // Join for the needed table to filter by sale
+ // Insert sale filter
+ if ($restrictonsocid && $search_sale > 0) {
+ $sql .= " AND sc.fk_user = ".$search_sale;
+ }
+ if ($sqlfilters)
+ {
+ if (!DolibarrApi::_checkFilters($sqlfilters)) {
+ throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters);
+ }
+ $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
+ $sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
+ }
- $sql .= $db->order($sortfield, $sortorder);
- if ($limit) {
- if ($page < 0) {
- $page = 0;
- }
- $offset = $limit * $page;
+ $sql .= $db->order($sortfield, $sortorder);
+ if ($limit) {
+ if ($page < 0) {
+ $page = 0;
+ }
+ $offset = $limit * $page;
- $sql .= $db->plimit($limit + 1, $offset);
- }
+ $sql .= $db->plimit($limit + 1, $offset);
+ }
- $result = $db->query($sql);
- if ($result)
- {
- $num = $db->num_rows($result);
- while ($i < $num)
- {
- $obj = $db->fetch_object($result);
- $myobject_static = new MyObject($db);
- if ($myobject_static->fetch($obj->rowid)) {
- $obj_ret[] = $this->_cleanObjectDatas($myobject_static);
- }
- $i++;
- }
- }
- else {
- throw new RestException(503, 'Error when retrieving myobject list: '.$db->lasterror());
- }
- if (!count($obj_ret)) {
- throw new RestException(404, 'No myobject found');
- }
- return $obj_ret;
- }
+ $result = $db->query($sql);
+ if ($result)
+ {
+ $num = $db->num_rows($result);
+ while ($i < $num)
+ {
+ $obj = $db->fetch_object($result);
+ $myobject_static = new MyObject($db);
+ if ($myobject_static->fetch($obj->rowid)) {
+ $obj_ret[] = $this->_cleanObjectDatas($myobject_static);
+ }
+ $i++;
+ }
+ }
+ else {
+ throw new RestException(503, 'Error when retrieving myobject list: '.$db->lasterror());
+ }
+ if (!count($obj_ret)) {
+ throw new RestException(404, 'No myobject found');
+ }
+ return $obj_ret;
+ }
- /**
- * Create myobject object
- *
- * @param array $request_data Request datas
- * @return int ID of myobject
- *
- * @throws RestException
- *
- * @url POST myobjects/
- */
- public function post($request_data = null)
- {
- if (!DolibarrApiAccess::$user->rights->mymodule->write) {
- throw new RestException(401);
- }
- // Check mandatory fields
- $result = $this->_validate($request_data);
+ /**
+ * Create myobject object
+ *
+ * @param array $request_data Request datas
+ * @return int ID of myobject
+ *
+ * @throws RestException
+ *
+ * @url POST myobjects/
+ */
+ public function post($request_data = null)
+ {
+ if (!DolibarrApiAccess::$user->rights->mymodule->write) {
+ throw new RestException(401);
+ }
+ // Check mandatory fields
+ $result = $this->_validate($request_data);
- foreach ($request_data as $field => $value) {
- $this->myobject->$field = $value;
- }
- if (!$this->myobject->create(DolibarrApiAccess::$user)) {
- throw new RestException(500, "Error creating MyObject", array_merge(array($this->myobject->error), $this->myobject->errors));
- }
- return $this->myobject->id;
- }
+ foreach ($request_data as $field => $value) {
+ $this->myobject->$field = $value;
+ }
+ if (!$this->myobject->create(DolibarrApiAccess::$user)) {
+ throw new RestException(500, "Error creating MyObject", array_merge(array($this->myobject->error), $this->myobject->errors));
+ }
+ return $this->myobject->id;
+ }
- /**
- * Update myobject
- *
- * @param int $id Id of myobject to update
- * @param array $request_data Datas
- * @return int
- *
- * @throws RestException
- *
- * @url PUT myobjects/{id}
- */
- public function put($id, $request_data = null)
- {
- if (!DolibarrApiAccess::$user->rights->mymodule->write) {
- throw new RestException(401);
- }
+ /**
+ * Update myobject
+ *
+ * @param int $id Id of myobject to update
+ * @param array $request_data Datas
+ * @return int
+ *
+ * @throws RestException
+ *
+ * @url PUT myobjects/{id}
+ */
+ public function put($id, $request_data = null)
+ {
+ if (!DolibarrApiAccess::$user->rights->mymodule->write) {
+ throw new RestException(401);
+ }
- $result = $this->myobject->fetch($id);
- if (!$result) {
- throw new RestException(404, 'MyObject not found');
- }
+ $result = $this->myobject->fetch($id);
+ if (!$result) {
+ throw new RestException(404, 'MyObject not found');
+ }
- if (!DolibarrApi::_checkAccessToResource('myobject', $this->myobject->id, 'mymodule_myobject')) {
- throw new RestException(401, 'Access to instance id='.$this->myobject->id.' of object not allowed for login '.DolibarrApiAccess::$user->login);
- }
+ if (!DolibarrApi::_checkAccessToResource('myobject', $this->myobject->id, 'mymodule_myobject')) {
+ throw new RestException(401, 'Access to instance id='.$this->myobject->id.' of object not allowed for login '.DolibarrApiAccess::$user->login);
+ }
- foreach ($request_data as $field => $value) {
- if ($field == 'id') continue;
- $this->myobject->$field = $value;
- }
+ foreach ($request_data as $field => $value) {
+ if ($field == 'id') continue;
+ $this->myobject->$field = $value;
+ }
- if ($this->myobject->update($id, DolibarrApiAccess::$user) > 0)
- {
- return $this->get($id);
- }
- else
- {
- throw new RestException(500, $this->myobject->error);
- }
- }
+ if ($this->myobject->update($id, DolibarrApiAccess::$user) > 0)
+ {
+ return $this->get($id);
+ }
+ else
+ {
+ throw new RestException(500, $this->myobject->error);
+ }
+ }
- /**
- * Delete myobject
- *
- * @param int $id MyObject ID
- * @return array
- *
- * @throws RestException
- *
- * @url DELETE myobjects/{id}
- */
- public function delete($id)
- {
- if (!DolibarrApiAccess::$user->rights->mymodule->delete) {
- throw new RestException(401);
- }
- $result = $this->myobject->fetch($id);
- if (!$result) {
- throw new RestException(404, 'MyObject not found');
- }
+ /**
+ * Delete myobject
+ *
+ * @param int $id MyObject ID
+ * @return array
+ *
+ * @throws RestException
+ *
+ * @url DELETE myobjects/{id}
+ */
+ public function delete($id)
+ {
+ if (!DolibarrApiAccess::$user->rights->mymodule->delete) {
+ throw new RestException(401);
+ }
+ $result = $this->myobject->fetch($id);
+ if (!$result) {
+ throw new RestException(404, 'MyObject not found');
+ }
- if (!DolibarrApi::_checkAccessToResource('myobject', $this->myobject->id, 'mymodule_myobject')) {
- throw new RestException(401, 'Access to instance id='.$this->myobject->id.' of object not allowed for login '.DolibarrApiAccess::$user->login);
- }
+ if (!DolibarrApi::_checkAccessToResource('myobject', $this->myobject->id, 'mymodule_myobject')) {
+ throw new RestException(401, 'Access to instance id='.$this->myobject->id.' of object not allowed for login '.DolibarrApiAccess::$user->login);
+ }
- if (!$this->myobject->delete(DolibarrApiAccess::$user))
- {
- throw new RestException(500, 'Error when deleting MyObject : '.$this->myobject->error);
- }
+ if (!$this->myobject->delete(DolibarrApiAccess::$user))
+ {
+ throw new RestException(500, 'Error when deleting MyObject : '.$this->myobject->error);
+ }
- return array(
- 'success' => array(
- 'code' => 200,
- 'message' => 'MyObject deleted'
- )
- );
- }
+ return array(
+ 'success' => array(
+ 'code' => 200,
+ 'message' => 'MyObject deleted'
+ )
+ );
+ }
- // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
- /**
- * Clean sensible object datas
- *
- * @param object $object Object to clean
- * @return array Array of cleaned object properties
- */
- protected function _cleanObjectDatas($object)
- {
- // phpcs:enable
- $object = parent::_cleanObjectDatas($object);
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
+ /**
+ * Clean sensible object datas
+ *
+ * @param object $object Object to clean
+ * @return array Array of cleaned object properties
+ */
+ protected function _cleanObjectDatas($object)
+ {
+ // phpcs:enable
+ $object = parent::_cleanObjectDatas($object);
- unset($object->rowid);
- unset($object->canvas);
+ unset($object->rowid);
+ unset($object->canvas);
- /*unset($object->name);
- unset($object->lastname);
- unset($object->firstname);
- unset($object->civility_id);
- unset($object->statut);
- unset($object->state);
- unset($object->state_id);
- unset($object->state_code);
- unset($object->region);
- unset($object->region_code);
- unset($object->country);
- unset($object->country_id);
- unset($object->country_code);
- unset($object->barcode_type);
- unset($object->barcode_type_code);
- unset($object->barcode_type_label);
- unset($object->barcode_type_coder);
- unset($object->total_ht);
- unset($object->total_tva);
- unset($object->total_localtax1);
- unset($object->total_localtax2);
- unset($object->total_ttc);
- unset($object->fk_account);
- unset($object->comments);
- unset($object->note);
- unset($object->mode_reglement_id);
- unset($object->cond_reglement_id);
- unset($object->cond_reglement);
- unset($object->shipping_method_id);
- unset($object->fk_incoterms);
- unset($object->label_incoterms);
- unset($object->location_incoterms);
+ /*unset($object->name);
+ unset($object->lastname);
+ unset($object->firstname);
+ unset($object->civility_id);
+ unset($object->statut);
+ unset($object->state);
+ unset($object->state_id);
+ unset($object->state_code);
+ unset($object->region);
+ unset($object->region_code);
+ unset($object->country);
+ unset($object->country_id);
+ unset($object->country_code);
+ unset($object->barcode_type);
+ unset($object->barcode_type_code);
+ unset($object->barcode_type_label);
+ unset($object->barcode_type_coder);
+ unset($object->total_ht);
+ unset($object->total_tva);
+ unset($object->total_localtax1);
+ unset($object->total_localtax2);
+ unset($object->total_ttc);
+ unset($object->fk_account);
+ unset($object->comments);
+ unset($object->note);
+ unset($object->mode_reglement_id);
+ unset($object->cond_reglement_id);
+ unset($object->cond_reglement);
+ unset($object->shipping_method_id);
+ unset($object->fk_incoterms);
+ unset($object->label_incoterms);
+ unset($object->location_incoterms);
*/
- // If object has lines, remove $db property
- if (isset($object->lines) && is_array($object->lines) && count($object->lines) > 0) {
- $nboflines = count($object->lines);
- for ($i = 0; $i < $nboflines; $i++)
- {
- $this->_cleanObjectDatas($object->lines[$i]);
+ // If object has lines, remove $db property
+ if (isset($object->lines) && is_array($object->lines) && count($object->lines) > 0) {
+ $nboflines = count($object->lines);
+ for ($i = 0; $i < $nboflines; $i++)
+ {
+ $this->_cleanObjectDatas($object->lines[$i]);
- unset($object->lines[$i]->lines);
- unset($object->lines[$i]->note);
- }
- }
+ unset($object->lines[$i]->lines);
+ unset($object->lines[$i]->note);
+ }
+ }
- return $object;
- }
+ return $object;
+ }
- /**
- * Validate fields before create or update object
- *
- * @param array $data Array of data to validate
- * @return array
- *
- * @throws RestException
- */
- private function _validate($data)
- {
- $myobject = array();
- foreach ($this->myobject->fields as $field => $propfield) {
- if (in_array($field, array('rowid', 'entity', 'date_creation', 'tms', 'fk_user_creat')) || $propfield['notnull'] != 1) continue; // Not a mandatory field
- if (!isset($data[$field]))
- throw new RestException(400, "$field field missing");
- $myobject[$field] = $data[$field];
- }
- return $myobject;
- }
+ /**
+ * Validate fields before create or update object
+ *
+ * @param array $data Array of data to validate
+ * @return array
+ *
+ * @throws RestException
+ */
+ private function _validate($data)
+ {
+ $myobject = array();
+ foreach ($this->myobject->fields as $field => $propfield) {
+ if (in_array($field, array('rowid', 'entity', 'date_creation', 'tms', 'fk_user_creat')) || $propfield['notnull'] != 1) continue; // Not a mandatory field
+ if (!isset($data[$field]))
+ throw new RestException(400, "$field field missing");
+ $myobject[$field] = $data[$field];
+ }
+ return $myobject;
+ }
}
diff --git a/htdocs/modulebuilder/template/class/myobject.class.php b/htdocs/modulebuilder/template/class/myobject.class.php
index 656483d8f18..af707c3c87d 100644
--- a/htdocs/modulebuilder/template/class/myobject.class.php
+++ b/htdocs/modulebuilder/template/class/myobject.class.php
@@ -90,16 +90,16 @@ class MyObject extends CommonObject
// BEGIN MODULEBUILDER PROPERTIES
/**
- * @var array Array with all fields and their property. Do not use it as a static var. It may be modified by constructor.
- */
+ * @var array Array with all fields and their property. Do not use it as a static var. It may be modified by constructor.
+ */
public $fields = array(
- 'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-2, 'noteditable'=>1, 'notnull'=> 1, 'index'=>1, 'position'=>1, 'comment'=>'Id'),
+ 'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-2, 'noteditable'=>1, 'notnull'=> 1, 'index'=>1, 'position'=>1, 'comment'=>'Id'),
'ref' => array('type'=>'varchar(128)', 'label'=>'Ref', 'enabled'=>1, 'visible'=>1, 'noteditable'=>0, 'default'=>'', 'notnull'=> 1, 'showoncombobox'=>1, 'index'=>1, 'position'=>10, 'searchall'=>1, 'comment'=>'Reference of object'),
- 'entity' => array('type'=>'integer', 'label'=>'Entity', 'enabled'=>1, 'visible'=>0, 'notnull'=> 1, 'default'=>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', 'showoncombobox'=>1),
- 'amount' => array('type'=>'price', 'label'=>'Amount', 'enabled'=>1, 'visible'=>1, 'default'=>'null', 'position'=>40, 'searchall'=>0, 'isameasure'=>1, 'help'=>'Help text for amount'),
- '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'),
- 'fk_soc' => array('type'=>'integer:Societe:societe/class/societe.class.php:1:status=1 AND entity IN (__SHARED_ENTITIES__)', 'label'=>'ThirdParty', 'visible'=> 1, 'enabled'=>1, 'position'=>50, 'notnull'=>-1, 'index'=>1, 'help'=>'LinkToThirparty'),
+ 'entity' => array('type'=>'integer', 'label'=>'Entity', 'enabled'=>1, 'visible'=>0, 'notnull'=> 1, 'default'=>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', 'showoncombobox'=>1),
+ 'amount' => array('type'=>'price', 'label'=>'Amount', 'enabled'=>1, 'visible'=>1, 'default'=>'null', 'position'=>40, 'searchall'=>0, 'isameasure'=>1, 'help'=>'Help text for amount'),
+ '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'),
+ 'fk_soc' => array('type'=>'integer:Societe:societe/class/societe.class.php:1:status=1 AND entity IN (__SHARED_ENTITIES__)', 'label'=>'ThirdParty', 'visible'=> 1, 'enabled'=>1, 'position'=>50, 'notnull'=>-1, 'index'=>1, 'help'=>'LinkToThirparty'),
'fk_project' => array('type'=>'integer:Project:projet/class/project.class.php:1', 'label'=>'Project', 'enabled'=>1, 'visible'=>-1, 'position'=>52, 'notnull'=>-1, 'index'=>1),
'description' => array('type'=>'text', 'label'=>'Description', 'enabled'=>1, 'visible'=>3, 'position'=>60),
'note_public' => array('type'=>'html', 'label'=>'NotePublic', 'enabled'=>1, 'visible'=>0, 'position'=>61),
@@ -112,7 +112,7 @@ class MyObject extends CommonObject
//'fk_user_valid' => array('type'=>'integer:User:user/class/user.class.php', '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),
'model_pdf' => array('type'=>'varchar(255)', 'label'=>'Model pdf', 'enabled'=>1, 'visible'=>0, 'notnull'=>-1, 'position'=>1010),
- 'status' => array('type'=>'smallint', 'label'=>'Status', 'enabled'=>1, 'visible'=>1, 'notnull'=> 1, 'default'=>0, 'index'=>1, 'position'=>1000, 'arrayofkeyval'=>array(0=>'Draft', 1=>'Validated', 9=>'Canceled')),
+ 'status' => array('type'=>'smallint', 'label'=>'Status', 'enabled'=>1, 'visible'=>1, 'notnull'=> 1, 'default'=>0, 'index'=>1, 'position'=>1000, 'arrayofkeyval'=>array(0=>'Draft', 1=>'Validated', 9=>'Canceled')),
);
/**
@@ -131,13 +131,13 @@ class MyObject extends CommonObject
public $entity;
/**
- * @var string label
- */
- public $label;
+ * @var string label
+ */
+ public $label;
- /**
- * @var string amount
- */
+ /**
+ * @var string amount
+ */
public $amount;
/**
@@ -146,28 +146,28 @@ class MyObject extends CommonObject
public $status;
/**
- * @var integer|string date_creation
- */
+ * @var integer|string date_creation
+ */
public $date_creation;
/**
- * @var integer tms
- */
+ * @var integer tms
+ */
public $tms;
/**
- * @var int ID
- */
+ * @var int ID
+ */
public $fk_user_creat;
/**
- * @var int ID
- */
+ * @var int ID
+ */
public $fk_user_modif;
/**
- * @var string import_key
- */
+ * @var string import_key
+ */
public $import_key;
// END MODULEBUILDER PROPERTIES
@@ -273,86 +273,86 @@ class MyObject extends CommonObject
public function createFromClone(User $user, $fromid)
{
global $langs, $extrafields;
- $error = 0;
+ $error = 0;
- dol_syslog(__METHOD__, LOG_DEBUG);
+ dol_syslog(__METHOD__, LOG_DEBUG);
- $object = new self($this->db);
+ $object = new self($this->db);
- $this->db->begin();
+ $this->db->begin();
- // Load source object
- $result = $object->fetchCommon($fromid);
- if ($result > 0 && !empty($object->table_element_line)) $object->fetchLines();
+ // Load source object
+ $result = $object->fetchCommon($fromid);
+ if ($result > 0 && !empty($object->table_element_line)) $object->fetchLines();
- // get lines so they will be clone
- //foreach($this->lines as $line)
- // $line->fetch_optionals();
+ // get lines so they will be clone
+ //foreach($this->lines as $line)
+ // $line->fetch_optionals();
- // Reset some properties
- unset($object->id);
- unset($object->fk_user_creat);
- unset($object->import_key);
+ // Reset some properties
+ unset($object->id);
+ unset($object->fk_user_creat);
+ unset($object->import_key);
- // Clear fields
- $object->ref = empty($this->fields['ref']['default']) ? "copy_of_".$object->ref : $this->fields['ref']['default'];
- $object->label = empty($this->fields['label']['default']) ? $langs->trans("CopyOf")." ".$object->label : $this->fields['label']['default'];
- $object->status = self::STATUS_DRAFT;
- // ...
- // Clear extrafields that are unique
- if (is_array($object->array_options) && count($object->array_options) > 0)
- {
- $extrafields->fetch_name_optionals_label($this->table_element);
- foreach ($object->array_options as $key => $option)
- {
- $shortkey = preg_replace('/options_/', '', $key);
- if (!empty($extrafields->attributes[$this->element]['unique'][$shortkey]))
- {
- //var_dump($key); var_dump($clonedObj->array_options[$key]); exit;
- unset($object->array_options[$key]);
- }
- }
- }
+ // Clear fields
+ $object->ref = empty($this->fields['ref']['default']) ? "copy_of_".$object->ref : $this->fields['ref']['default'];
+ $object->label = empty($this->fields['label']['default']) ? $langs->trans("CopyOf")." ".$object->label : $this->fields['label']['default'];
+ $object->status = self::STATUS_DRAFT;
+ // ...
+ // Clear extrafields that are unique
+ if (is_array($object->array_options) && count($object->array_options) > 0)
+ {
+ $extrafields->fetch_name_optionals_label($this->table_element);
+ foreach ($object->array_options as $key => $option)
+ {
+ $shortkey = preg_replace('/options_/', '', $key);
+ if (!empty($extrafields->attributes[$this->element]['unique'][$shortkey]))
+ {
+ //var_dump($key); var_dump($clonedObj->array_options[$key]); exit;
+ unset($object->array_options[$key]);
+ }
+ }
+ }
- // Create clone
+ // Create clone
$object->context['createfromclone'] = 'createfromclone';
- $result = $object->createCommon($user);
- if ($result < 0) {
- $error++;
- $this->error = $object->error;
- $this->errors = $object->errors;
- }
+ $result = $object->createCommon($user);
+ if ($result < 0) {
+ $error++;
+ $this->error = $object->error;
+ $this->errors = $object->errors;
+ }
- if (!$error)
- {
- // copy internal contacts
- if ($this->copy_linked_contact($object, 'internal') < 0)
- {
- $error++;
- }
- }
+ if (!$error)
+ {
+ // copy internal contacts
+ if ($this->copy_linked_contact($object, 'internal') < 0)
+ {
+ $error++;
+ }
+ }
- if (!$error)
- {
- // copy external contacts if same company
- if (property_exists($this, 'socid') && $this->socid == $object->socid)
- {
- if ($this->copy_linked_contact($object, 'external') < 0)
- $error++;
- }
- }
+ if (!$error)
+ {
+ // copy external contacts if same company
+ if (property_exists($this, 'socid') && $this->socid == $object->socid)
+ {
+ if ($this->copy_linked_contact($object, 'external') < 0)
+ $error++;
+ }
+ }
- unset($object->context['createfromclone']);
+ unset($object->context['createfromclone']);
- // End
- if (!$error) {
- $this->db->commit();
- return $object;
- } else {
- $this->db->rollback();
- return -1;
- }
+ // End
+ if (!$error) {
+ $this->db->commit();
+ return $object;
+ } else {
+ $this->db->rollback();
+ return -1;
+ }
}
/**
@@ -439,10 +439,10 @@ class MyObject extends CommonObject
$resql = $this->db->query($sql);
if ($resql) {
$num = $this->db->num_rows($resql);
- $i = 0;
+ $i = 0;
while ($i < min($limit, $num))
{
- $obj = $this->db->fetch_object($resql);
+ $obj = $this->db->fetch_object($resql);
$record = new self($this->db);
$record->setVarsFromFetchObj($obj);
@@ -714,53 +714,53 @@ class MyObject extends CommonObject
return $this->setStatusCommon($user, self::STATUS_VALIDATED, $notrigger, 'MYOBJECT_REOPEN');
}
- /**
- * Return a link to the object card (with optionaly the picto)
- *
- * @param int $withpicto Include picto in link (0=No picto, 1=Include picto into link, 2=Only picto)
- * @param string $option On what the link point to ('nolink', ...)
- * @param int $notooltip 1=Disable tooltip
- * @param string $morecss Add more css on link
- * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking
- * @return string String with URL
- */
- public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1)
- {
- global $conf, $langs, $hookmanager;
+ /**
+ * Return a link to the object card (with optionaly the picto)
+ *
+ * @param int $withpicto Include picto in link (0=No picto, 1=Include picto into link, 2=Only picto)
+ * @param string $option On what the link point to ('nolink', ...)
+ * @param int $notooltip 1=Disable tooltip
+ * @param string $morecss Add more css on link
+ * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking
+ * @return string String with URL
+ */
+ public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1)
+ {
+ global $conf, $langs, $hookmanager;
- if (!empty($conf->dol_no_mouse_hover)) $notooltip = 1; // Force disable tooltips
+ if (!empty($conf->dol_no_mouse_hover)) $notooltip = 1; // Force disable tooltips
- $result = '';
+ $result = '';
- $label = ''.$langs->trans("MyObject").'';
- $label .= '
';
- $label .= ''.$langs->trans('Ref').': '.$this->ref;
- if (isset($this->status)) {
- $label .= '
'.$langs->trans("Status").": ".$this->getLibStatut(5);
- }
+ $label = ''.$langs->trans("MyObject").'';
+ $label .= '
';
+ $label .= ''.$langs->trans('Ref').': '.$this->ref;
+ if (isset($this->status)) {
+ $label .= '
'.$langs->trans("Status").": ".$this->getLibStatut(5);
+ }
- $url = dol_buildpath('/mymodule/myobject_card.php', 1).'?id='.$this->id;
+ $url = dol_buildpath('/mymodule/myobject_card.php', 1).'?id='.$this->id;
- if ($option != 'nolink')
- {
- // Add param to save lastsearch_values or not
- $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
- if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values = 1;
- if ($add_save_lastsearch_values) $url .= '&save_lastsearch_values=1';
- }
+ if ($option != 'nolink')
+ {
+ // Add param to save lastsearch_values or not
+ $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
+ if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values = 1;
+ if ($add_save_lastsearch_values) $url .= '&save_lastsearch_values=1';
+ }
- $linkclose = '';
- if (empty($notooltip))
- {
- if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER))
- {
- $label = $langs->trans("ShowMyObject");
- $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"';
- }
- $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"';
- $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"';
- }
- else $linkclose = ($morecss ? ' class="'.$morecss.'"' : '');
+ $linkclose = '';
+ if (empty($notooltip))
+ {
+ if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER))
+ {
+ $label = $langs->trans("ShowMyObject");
+ $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"';
+ }
+ $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"';
+ $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"';
+ }
+ else $linkclose = ($morecss ? ' class="'.$morecss.'"' : '');
$linkstart = '';
@@ -810,7 +810,7 @@ class MyObject extends CommonObject
else $result .= $hookmanager->resPrint;
return $result;
- }
+ }
/**
* Return label of the status
@@ -823,7 +823,7 @@ class MyObject extends CommonObject
return $this->LibStatut($this->status, $mode);
}
- // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Return the status
*
@@ -924,22 +924,22 @@ class MyObject extends CommonObject
*/
public function getLinesArray()
{
- $this->lines = array();
+ $this->lines = array();
- $objectline = new MyObjectLine($this->db);
- $result = $objectline->fetchAll('ASC', 'position', 0, 0, array('customsql'=>'fk_myobject = '.$this->id));
+ $objectline = new MyObjectLine($this->db);
+ $result = $objectline->fetchAll('ASC', 'position', 0, 0, array('customsql'=>'fk_myobject = '.$this->id));
- if (is_numeric($result))
- {
- $this->error = $this->error;
- $this->errors = $this->errors;
- return $result;
- }
- else
- {
- $this->lines = $result;
- return $this->lines;
- }
+ if (is_numeric($result))
+ {
+ $this->error = $this->error;
+ $this->errors = $this->errors;
+ return $result;
+ }
+ else
+ {
+ $this->lines = $result;
+ return $this->lines;
+ }
}
/**
diff --git a/htdocs/modulebuilder/template/core/boxes/mymodulewidget1.php b/htdocs/modulebuilder/template/core/boxes/mymodulewidget1.php
index dcdf94c8666..482455e103d 100644
--- a/htdocs/modulebuilder/template/core/boxes/mymodulewidget1.php
+++ b/htdocs/modulebuilder/template/core/boxes/mymodulewidget1.php
@@ -194,18 +194,18 @@ class mymodulewidget1 extends ModeleBoxes
);
}
- /**
- * Method to show box. Called by Dolibarr eatch time it wants to display the box.
- *
- * @param array $head Array with properties of box title
- * @param array $contents Array with properties of box lines
- * @param int $nooutput No print, only return string
- * @return void
- */
- public function showBox($head = null, $contents = null, $nooutput = 0)
- {
- // You may make your own code here…
- // … or use the parent's class function using the provided head and contents templates
- parent::showBox($this->info_box_head, $this->info_box_contents);
- }
+ /**
+ * Method to show box. Called by Dolibarr eatch time it wants to display the box.
+ *
+ * @param array $head Array with properties of box title
+ * @param array $contents Array with properties of box lines
+ * @param int $nooutput No print, only return string
+ * @return void
+ */
+ public function showBox($head = null, $contents = null, $nooutput = 0)
+ {
+ // You may make your own code here…
+ // … or use the parent's class function using the provided head and contents templates
+ parent::showBox($this->info_box_head, $this->info_box_contents);
+ }
}
diff --git a/htdocs/modulebuilder/template/core/modules/mailings/mailinglist_mymodule_myobject.modules.php b/htdocs/modulebuilder/template/core/modules/mailings/mailinglist_mymodule_myobject.modules.php
index b6aa0399447..39b325924fc 100644
--- a/htdocs/modulebuilder/template/core/modules/mailings/mailinglist_mymodule_myobject.modules.php
+++ b/htdocs/modulebuilder/template/core/modules/mailings/mailinglist_mymodule_myobject.modules.php
@@ -17,189 +17,189 @@ dol_include_once("/mymodule/class/myobject.class.php");
*/
class mailing_mailinglist_mymodule_myobject extends MailingTargets
{
- // CHANGE THIS: Put here a name not already used
- public $name = 'mailinglist_mymodule_myobject';
- // CHANGE THIS: Put here a description of your selector module
- public $desc = 'My object emailing target selector';
- // CHANGE THIS: Set to 1 if selector is available for admin users only
- public $require_admin = 0;
+ // CHANGE THIS: Put here a name not already used
+ public $name = 'mailinglist_mymodule_myobject';
+ // CHANGE THIS: Put here a description of your selector module
+ public $desc = 'My object emailing target selector';
+ // CHANGE THIS: Set to 1 if selector is available for admin users only
+ public $require_admin = 0;
- public $enabled = 0;
- public $require_module = array();
+ public $enabled = 0;
+ public $require_module = array();
- /**
- * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png
- */
- public $picto = 'mymodule@mymodule';
+ /**
+ * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png
+ */
+ public $picto = 'mymodule@mymodule';
- /**
- * @var DoliDB Database handler.
- */
- public $db;
+ /**
+ * @var DoliDB Database handler.
+ */
+ public $db;
- /**
- * Constructor
- *
- * @param DoliDB $db Database handler
- */
- public function __construct($db)
- {
- global $conf;
+ /**
+ * Constructor
+ *
+ * @param DoliDB $db Database handler
+ */
+ public function __construct($db)
+ {
+ global $conf;
- $this->db = $db;
- if (is_array($conf->modules))
- {
- $this->enabled = in_array('mymodule', $conf->modules) ? 1 : 0;
- }
- }
+ $this->db = $db;
+ if (is_array($conf->modules))
+ {
+ $this->enabled = in_array('mymodule', $conf->modules) ? 1 : 0;
+ }
+ }
- /**
- * Affiche formulaire de filtre qui apparait dans page de selection des destinataires de mailings
- *
- * @return string Retourne zone select
- */
- public function formFilter()
- {
- global $langs;
- $langs->load("members");
+ /**
+ * Affiche formulaire de filtre qui apparait dans page de selection des destinataires de mailings
+ *
+ * @return string Retourne zone select
+ */
+ public function formFilter()
+ {
+ global $langs;
+ $langs->load("members");
- $form = new Form($this->db);
+ $form = new Form($this->db);
- $arraystatus = array(1=>'Option 1', 2=>'Option 2');
+ $arraystatus = array(1=>'Option 1', 2=>'Option 2');
- $s = '';
- $s .= $langs->trans("Status").': ';
- $s .= '';
- $s .= '
';
+ $s = '';
+ $s .= $langs->trans("Status").': ';
+ $s .= '';
+ $s .= '
';
- return $s;
- }
+ return $s;
+ }
- /**
- * Renvoie url lien vers fiche de la source du destinataire du mailing
- *
- * @param int $id ID
- * @return string Url lien
- */
- public function url($id)
- {
- return ''.img_object('', "generic").'';
- }
+ /**
+ * Renvoie url lien vers fiche de la source du destinataire du mailing
+ *
+ * @param int $id ID
+ * @return string Url lien
+ */
+ public function url($id)
+ {
+ return ''.img_object('', "generic").'';
+ }
- // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
- /**
- * This is the main function that returns the array of emails
- *
- * @param int $mailing_id Id of emailing
- * @return int <0 if error, number of emails added if ok
- */
- public function add_to_target($mailing_id)
- {
- // phpcs:enable
- $target = array();
- $j = 0;
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+ /**
+ * This is the main function that returns the array of emails
+ *
+ * @param int $mailing_id Id of emailing
+ * @return int <0 if error, number of emails added if ok
+ */
+ public function add_to_target($mailing_id)
+ {
+ // phpcs:enable
+ $target = array();
+ $j = 0;
- $sql = " select rowid as id, email, firstname, lastname, plan, partner";
- $sql .= " from ".MAIN_DB_PREFIX."myobject";
- $sql .= " where email IS NOT NULL AND email != ''";
- if (GETPOSTISSET('filter') && GETPOST('filter', 'alphanohtml') != 'none') $sql .= " AND status = '".$this->db->escape(GETPOST('filter', 'alphanohtml'))."'";
- $sql .= " ORDER BY email";
+ $sql = " select rowid as id, email, firstname, lastname, plan, partner";
+ $sql .= " from ".MAIN_DB_PREFIX."myobject";
+ $sql .= " where email IS NOT NULL AND email != ''";
+ if (GETPOSTISSET('filter') && GETPOST('filter', 'alphanohtml') != 'none') $sql .= " AND status = '".$this->db->escape(GETPOST('filter', 'alphanohtml'))."'";
+ $sql .= " ORDER BY email";
- // Stocke destinataires dans target
- $result = $this->db->query($sql);
- if ($result)
- {
- $num = $this->db->num_rows($result);
- $i = 0;
+ // Stocke destinataires dans target
+ $result = $this->db->query($sql);
+ if ($result)
+ {
+ $num = $this->db->num_rows($result);
+ $i = 0;
- dol_syslog("mailinglist_mymodule_myobject.modules.php: mailing ".$num." targets found");
+ dol_syslog("mailinglist_mymodule_myobject.modules.php: mailing ".$num." targets found");
- $old = '';
- while ($i < $num)
- {
- $obj = $this->db->fetch_object($result);
- if ($old <> $obj->email)
- {
- $target[$j] = array(
- 'email' => $obj->email,
- 'name' => $obj->lastname,
- 'id' => $obj->id,
- 'firstname' => $obj->firstname,
- 'other' => $obj->plan.';'.$obj->partner,
- 'source_url' => $this->url($obj->id),
- 'source_id' => $obj->id,
- 'source_type' => 'dolicloud'
- );
- $old = $obj->email;
- $j++;
- }
+ $old = '';
+ while ($i < $num)
+ {
+ $obj = $this->db->fetch_object($result);
+ if ($old <> $obj->email)
+ {
+ $target[$j] = array(
+ 'email' => $obj->email,
+ 'name' => $obj->lastname,
+ 'id' => $obj->id,
+ 'firstname' => $obj->firstname,
+ 'other' => $obj->plan.';'.$obj->partner,
+ 'source_url' => $this->url($obj->id),
+ 'source_id' => $obj->id,
+ 'source_type' => 'dolicloud'
+ );
+ $old = $obj->email;
+ $j++;
+ }
- $i++;
- }
- }
- else
- {
- dol_syslog($this->db->error());
- $this->error = $this->db->error();
- return -1;
- }
+ $i++;
+ }
+ }
+ else
+ {
+ dol_syslog($this->db->error());
+ $this->error = $this->db->error();
+ return -1;
+ }
- // You must fill the $target array with record like this
- // $target[0]=array('email'=>'email_0','name'=>'name_0','firstname'=>'firstname_0');
- // ...
- // $target[n]=array('email'=>'email_n','name'=>'name_n','firstname'=>'firstname_n');
+ // You must fill the $target array with record like this
+ // $target[0]=array('email'=>'email_0','name'=>'name_0','firstname'=>'firstname_0');
+ // ...
+ // $target[n]=array('email'=>'email_n','name'=>'name_n','firstname'=>'firstname_n');
- // Example: $target[0]=array('email'=>'myemail@mydomain.com','name'=>'Doe','firstname'=>'John');
+ // Example: $target[0]=array('email'=>'myemail@mydomain.com','name'=>'Doe','firstname'=>'John');
- // ----- Your code end here -----
+ // ----- Your code end here -----
- return parent::addTargetsToDatabase($mailing_id, $target);
- }
+ return parent::addTargetsToDatabase($mailing_id, $target);
+ }
- /**
- * On the main mailing area, there is a box with statistics.
- * If you want to add a line in this report you must provide an
- * array of SQL request that returns two field:
- * One called "label", One called "nb".
- *
- * @return array
- */
- public function getSqlArrayForStats()
- {
- // CHANGE THIS: Optionnal
+ /**
+ * On the main mailing area, there is a box with statistics.
+ * If you want to add a line in this report you must provide an
+ * array of SQL request that returns two field:
+ * One called "label", One called "nb".
+ *
+ * @return array
+ */
+ public function getSqlArrayForStats()
+ {
+ // CHANGE THIS: Optionnal
- //var $statssql=array();
- //$this->statssql[0]="SELECT field1 as label, count(distinct(email)) as nb FROM mytable WHERE email IS NOT NULL";
+ //var $statssql=array();
+ //$this->statssql[0]="SELECT field1 as label, count(distinct(email)) as nb FROM mytable WHERE email IS NOT NULL";
- return array();
- }
+ return array();
+ }
- /**
- * Return here number of distinct emails returned by your selector.
- * For example if this selector is used to extract 500 different
- * emails from a text file, this function must return 500.
- *
- * @param string $filter Filter
- * @param string $option Options
- * @return int Nb of recipients or -1 if KO
- */
- public function getNbOfRecipients($filter = 1, $option = '')
- {
- $a = parent::getNbOfRecipients("select count(distinct(email)) as nb from ".MAIN_DB_PREFIX."myobject as p where email IS NOT NULL AND email != ''");
+ /**
+ * Return here number of distinct emails returned by your selector.
+ * For example if this selector is used to extract 500 different
+ * emails from a text file, this function must return 500.
+ *
+ * @param string $filter Filter
+ * @param string $option Options
+ * @return int Nb of recipients or -1 if KO
+ */
+ public function getNbOfRecipients($filter = 1, $option = '')
+ {
+ $a = parent::getNbOfRecipients("select count(distinct(email)) as nb from ".MAIN_DB_PREFIX."myobject as p where email IS NOT NULL AND email != ''");
- if ($a < 0) return -1;
- return $a;
- }
+ if ($a < 0) return -1;
+ return $a;
+ }
}
diff --git a/htdocs/modulebuilder/template/core/modules/modMyModule.class.php b/htdocs/modulebuilder/template/core/modules/modMyModule.class.php
index ba956e46af9..21ede6bfd58 100644
--- a/htdocs/modulebuilder/template/core/modules/modMyModule.class.php
+++ b/htdocs/modulebuilder/template/core/modules/modMyModule.class.php
@@ -33,419 +33,419 @@ include_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php';
*/
class modMyModule extends DolibarrModules
{
- /**
- * Constructor. Define names, constants, directories, boxes, permissions
- *
- * @param DoliDB $db Database handler
- */
- public function __construct($db)
- {
- global $langs, $conf;
- $this->db = $db;
+ /**
+ * Constructor. Define names, constants, directories, boxes, permissions
+ *
+ * @param DoliDB $db Database handler
+ */
+ public function __construct($db)
+ {
+ global $langs, $conf;
+ $this->db = $db;
- // Id for module (must be unique).
- // Use here a free id (See in Home -> System information -> Dolibarr for list of used modules id).
- $this->numero = 500000; // TODO Go on page https://wiki.dolibarr.org/index.php/List_of_modules_id to reserve an id number for your module
- // Key text used to identify module (for permissions, menus, etc...)
- $this->rights_class = 'mymodule';
- // Family can be 'base' (core modules),'crm','financial','hr','projects','products','ecm','technic' (transverse modules),'interface' (link with external tools),'other','...'
- // It is used to group modules by family in module setup page
- $this->family = "other";
- // Module position in the family on 2 digits ('01', '10', '20', ...)
- $this->module_position = '90';
- // Gives the possibility for the module, to provide his own family info and position of this family (Overwrite $this->family and $this->module_position. Avoid this)
- //$this->familyinfo = array('myownfamily' => array('position' => '01', 'label' => $langs->trans("MyOwnFamily")));
- // Module label (no space allowed), used if translation string 'ModuleMyModuleName' not found (MyModule is name of module).
- $this->name = preg_replace('/^mod/i', '', get_class($this));
- // Module description, used if translation string 'ModuleMyModuleDesc' not found (MyModule is name of module).
- $this->description = "MyModuleDescription";
- // Used only if file README.md and README-LL.md not found.
- $this->descriptionlong = "MyModule description (Long)";
- $this->editor_name = 'Editor name';
- $this->editor_url = 'https://www.example.com';
- // Possible values for version are: 'development', 'experimental', 'dolibarr', 'dolibarr_deprecated' or a version string like 'x.y.z'
- $this->version = '1.0';
- // Url to the file with your last numberversion of this module
- //$this->url_last_version = 'http://www.example.com/versionmodule.txt';
+ // Id for module (must be unique).
+ // Use here a free id (See in Home -> System information -> Dolibarr for list of used modules id).
+ $this->numero = 500000; // TODO Go on page https://wiki.dolibarr.org/index.php/List_of_modules_id to reserve an id number for your module
+ // Key text used to identify module (for permissions, menus, etc...)
+ $this->rights_class = 'mymodule';
+ // Family can be 'base' (core modules),'crm','financial','hr','projects','products','ecm','technic' (transverse modules),'interface' (link with external tools),'other','...'
+ // It is used to group modules by family in module setup page
+ $this->family = "other";
+ // Module position in the family on 2 digits ('01', '10', '20', ...)
+ $this->module_position = '90';
+ // Gives the possibility for the module, to provide his own family info and position of this family (Overwrite $this->family and $this->module_position. Avoid this)
+ //$this->familyinfo = array('myownfamily' => array('position' => '01', 'label' => $langs->trans("MyOwnFamily")));
+ // Module label (no space allowed), used if translation string 'ModuleMyModuleName' not found (MyModule is name of module).
+ $this->name = preg_replace('/^mod/i', '', get_class($this));
+ // Module description, used if translation string 'ModuleMyModuleDesc' not found (MyModule is name of module).
+ $this->description = "MyModuleDescription";
+ // Used only if file README.md and README-LL.md not found.
+ $this->descriptionlong = "MyModule description (Long)";
+ $this->editor_name = 'Editor name';
+ $this->editor_url = 'https://www.example.com';
+ // Possible values for version are: 'development', 'experimental', 'dolibarr', 'dolibarr_deprecated' or a version string like 'x.y.z'
+ $this->version = '1.0';
+ // Url to the file with your last numberversion of this module
+ //$this->url_last_version = 'http://www.example.com/versionmodule.txt';
- // Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase)
- $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
- // Name of image file used for this module.
- // If file is in theme/yourtheme/img directory under name object_pictovalue.png, use this->picto='pictovalue'
- // If file is in module/img directory under name object_pictovalue.png, use this->picto='pictovalue@module'
- $this->picto = 'generic';
- // Define some features supported by module (triggers, login, substitutions, menus, css, etc...)
- $this->module_parts = array(
- // Set this to 1 if module has its own trigger directory (core/triggers)
- 'triggers' => 0,
- // Set this to 1 if module has its own login method file (core/login)
- 'login' => 0,
- // Set this to 1 if module has its own substitution function file (core/substitutions)
- 'substitutions' => 0,
- // Set this to 1 if module has its own menus handler directory (core/menus)
- 'menus' => 0,
- // Set this to 1 if module overwrite template dir (core/tpl)
- 'tpl' => 0,
- // Set this to 1 if module has its own barcode directory (core/modules/barcode)
- 'barcode' => 0,
- // Set this to 1 if module has its own models directory (core/modules/xxx)
- 'models' => 0,
- // Set this to 1 if module has its own theme directory (theme)
- 'theme' => 0,
- // Set this to relative path of css file if module has its own css file
- 'css' => array(
- // '/mymodule/css/mymodule.css.php',
- ),
- // Set this to relative path of js file if module must load a js on all pages
- 'js' => array(
- // '/mymodule/js/mymodule.js.php',
- ),
- // Set here all hooks context managed by module. To find available hook context, make a "grep -r '>initHooks(' *" on source code. You can also set hook context to 'all'
- 'hooks' => array(
- // 'data' => array(
- // 'hookcontext1',
- // 'hookcontext2',
- // ),
- // 'entity' => '0',
- ),
- // Set this to 1 if features of module are opened to external users
- 'moduleforexternal' => 0,
- );
- // Data directories to create when module is enabled.
- // Example: this->dirs = array("/mymodule/temp","/mymodule/subdir");
- $this->dirs = array("/mymodule/temp");
- // Config pages. Put here list of php page, stored into mymodule/admin directory, to use to setup module.
- $this->config_page_url = array("setup.php@mymodule");
- // Dependencies
- // A condition to hide module
- $this->hidden = false;
- // List of module class names as string that must be enabled if this module is enabled. Example: array('always1'=>'modModuleToEnable1','always2'=>'modModuleToEnable2', 'FR1'=>'modModuleToEnableFR'...)
- $this->depends = array();
- $this->requiredby = array(); // List of module class names as string to disable if this one is disabled. Example: array('modModuleToDisable1', ...)
- $this->conflictwith = array(); // List of module class names as string this module is in conflict with. Example: array('modModuleToDisable1', ...)
- $this->langfiles = array("mymodule@mymodule");
- $this->phpmin = array(5, 5); // Minimum version of PHP required by module
- $this->need_dolibarr_version = array(11, -3); // Minimum version of Dolibarr required by module
- $this->warnings_activation = array(); // Warning to show when we activate module. array('always'='text') or array('FR'='textfr','ES'='textes'...)
- $this->warnings_activation_ext = array(); // Warning to show when we activate an external module. array('always'='text') or array('FR'='textfr','ES'='textes'...)
- //$this->automatic_activation = array('FR'=>'MyModuleWasAutomaticallyActivatedBecauseOfYourCountryChoice');
- //$this->always_enabled = true; // If true, can't be disabled
+ // Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase)
+ $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
+ // Name of image file used for this module.
+ // If file is in theme/yourtheme/img directory under name object_pictovalue.png, use this->picto='pictovalue'
+ // If file is in module/img directory under name object_pictovalue.png, use this->picto='pictovalue@module'
+ $this->picto = 'generic';
+ // Define some features supported by module (triggers, login, substitutions, menus, css, etc...)
+ $this->module_parts = array(
+ // Set this to 1 if module has its own trigger directory (core/triggers)
+ 'triggers' => 0,
+ // Set this to 1 if module has its own login method file (core/login)
+ 'login' => 0,
+ // Set this to 1 if module has its own substitution function file (core/substitutions)
+ 'substitutions' => 0,
+ // Set this to 1 if module has its own menus handler directory (core/menus)
+ 'menus' => 0,
+ // Set this to 1 if module overwrite template dir (core/tpl)
+ 'tpl' => 0,
+ // Set this to 1 if module has its own barcode directory (core/modules/barcode)
+ 'barcode' => 0,
+ // Set this to 1 if module has its own models directory (core/modules/xxx)
+ 'models' => 0,
+ // Set this to 1 if module has its own theme directory (theme)
+ 'theme' => 0,
+ // Set this to relative path of css file if module has its own css file
+ 'css' => array(
+ // '/mymodule/css/mymodule.css.php',
+ ),
+ // Set this to relative path of js file if module must load a js on all pages
+ 'js' => array(
+ // '/mymodule/js/mymodule.js.php',
+ ),
+ // Set here all hooks context managed by module. To find available hook context, make a "grep -r '>initHooks(' *" on source code. You can also set hook context to 'all'
+ 'hooks' => array(
+ // 'data' => array(
+ // 'hookcontext1',
+ // 'hookcontext2',
+ // ),
+ // 'entity' => '0',
+ ),
+ // Set this to 1 if features of module are opened to external users
+ 'moduleforexternal' => 0,
+ );
+ // Data directories to create when module is enabled.
+ // Example: this->dirs = array("/mymodule/temp","/mymodule/subdir");
+ $this->dirs = array("/mymodule/temp");
+ // Config pages. Put here list of php page, stored into mymodule/admin directory, to use to setup module.
+ $this->config_page_url = array("setup.php@mymodule");
+ // Dependencies
+ // A condition to hide module
+ $this->hidden = false;
+ // List of module class names as string that must be enabled if this module is enabled. Example: array('always1'=>'modModuleToEnable1','always2'=>'modModuleToEnable2', 'FR1'=>'modModuleToEnableFR'...)
+ $this->depends = array();
+ $this->requiredby = array(); // List of module class names as string to disable if this one is disabled. Example: array('modModuleToDisable1', ...)
+ $this->conflictwith = array(); // List of module class names as string this module is in conflict with. Example: array('modModuleToDisable1', ...)
+ $this->langfiles = array("mymodule@mymodule");
+ $this->phpmin = array(5, 5); // Minimum version of PHP required by module
+ $this->need_dolibarr_version = array(11, -3); // Minimum version of Dolibarr required by module
+ $this->warnings_activation = array(); // Warning to show when we activate module. array('always'='text') or array('FR'='textfr','ES'='textes'...)
+ $this->warnings_activation_ext = array(); // Warning to show when we activate an external module. array('always'='text') or array('FR'='textfr','ES'='textes'...)
+ //$this->automatic_activation = array('FR'=>'MyModuleWasAutomaticallyActivatedBecauseOfYourCountryChoice');
+ //$this->always_enabled = true; // If true, can't be disabled
- // Constants
- // List of particular constants to add when module is enabled (key, 'chaine', value, desc, visible, 'current' or 'allentities', deleteonunactive)
- // Example: $this->const=array(1 => array('MYMODULE_MYNEWCONST1', 'chaine', 'myvalue', 'This is a constant to add', 1),
- // 2 => array('MYMODULE_MYNEWCONST2', 'chaine', 'myvalue', 'This is another constant to add', 0, 'current', 1)
- // );
- $this->const = array(
- // 1 => array('MYMODULE_MYCONSTANT', 'chaine', 'avalue', 'This is a constant to add', 1, 'allentities', 1)
- );
+ // Constants
+ // List of particular constants to add when module is enabled (key, 'chaine', value, desc, visible, 'current' or 'allentities', deleteonunactive)
+ // Example: $this->const=array(1 => array('MYMODULE_MYNEWCONST1', 'chaine', 'myvalue', 'This is a constant to add', 1),
+ // 2 => array('MYMODULE_MYNEWCONST2', 'chaine', 'myvalue', 'This is another constant to add', 0, 'current', 1)
+ // );
+ $this->const = array(
+ // 1 => array('MYMODULE_MYCONSTANT', 'chaine', 'avalue', 'This is a constant to add', 1, 'allentities', 1)
+ );
- // Some keys to add into the overwriting translation tables
- /*$this->overwrite_translation = array(
- 'en_US:ParentCompany'=>'Parent company or reseller',
- 'fr_FR:ParentCompany'=>'Maison mère ou revendeur'
- )*/
+ // Some keys to add into the overwriting translation tables
+ /*$this->overwrite_translation = array(
+ 'en_US:ParentCompany'=>'Parent company or reseller',
+ 'fr_FR:ParentCompany'=>'Maison mère ou revendeur'
+ )*/
- if (!isset($conf->mymodule) || !isset($conf->mymodule->enabled)) {
- $conf->mymodule = new stdClass();
- $conf->mymodule->enabled = 0;
- }
+ if (!isset($conf->mymodule) || !isset($conf->mymodule->enabled)) {
+ $conf->mymodule = new stdClass();
+ $conf->mymodule->enabled = 0;
+ }
- // Array to add new pages in new tabs
- $this->tabs = array();
- // Example:
- // $this->tabs[] = array('data'=>'objecttype:+tabname1:Title1:mylangfile@mymodule:$user->rights->mymodule->read:/mymodule/mynewtab1.php?id=__ID__'); // To add a new tab identified by code tabname1
- // $this->tabs[] = array('data'=>'objecttype:+tabname2:SUBSTITUTION_Title2:mylangfile@mymodule:$user->rights->othermodule->read:/mymodule/mynewtab2.php?id=__ID__', // To add another new tab identified by code tabname2. Label will be result of calling all substitution functions on 'Title2' key.
- // $this->tabs[] = array('data'=>'objecttype:-tabname:NU:conditiontoremove'); // To remove an existing tab identified by code tabname
- //
- // Where objecttype can be
- // 'categories_x' to add a tab in category view (replace 'x' by type of category (0=product, 1=supplier, 2=customer, 3=member)
- // 'contact' to add a tab in contact view
- // 'contract' to add a tab in contract view
- // 'group' to add a tab in group view
- // 'intervention' to add a tab in intervention view
- // 'invoice' to add a tab in customer invoice view
- // 'invoice_supplier' to add a tab in supplier invoice view
- // 'member' to add a tab in fundation member view
- // 'opensurveypoll' to add a tab in opensurvey poll view
- // 'order' to add a tab in customer order view
- // 'order_supplier' to add a tab in supplier order view
- // 'payment' to add a tab in payment view
- // 'payment_supplier' to add a tab in supplier payment view
- // 'product' to add a tab in product view
- // 'propal' to add a tab in propal view
- // 'project' to add a tab in project view
- // 'stock' to add a tab in stock view
- // 'thirdparty' to add a tab in third party view
- // 'user' to add a tab in user view
+ // Array to add new pages in new tabs
+ $this->tabs = array();
+ // Example:
+ // $this->tabs[] = array('data'=>'objecttype:+tabname1:Title1:mylangfile@mymodule:$user->rights->mymodule->read:/mymodule/mynewtab1.php?id=__ID__'); // To add a new tab identified by code tabname1
+ // $this->tabs[] = array('data'=>'objecttype:+tabname2:SUBSTITUTION_Title2:mylangfile@mymodule:$user->rights->othermodule->read:/mymodule/mynewtab2.php?id=__ID__', // To add another new tab identified by code tabname2. Label will be result of calling all substitution functions on 'Title2' key.
+ // $this->tabs[] = array('data'=>'objecttype:-tabname:NU:conditiontoremove'); // To remove an existing tab identified by code tabname
+ //
+ // Where objecttype can be
+ // 'categories_x' to add a tab in category view (replace 'x' by type of category (0=product, 1=supplier, 2=customer, 3=member)
+ // 'contact' to add a tab in contact view
+ // 'contract' to add a tab in contract view
+ // 'group' to add a tab in group view
+ // 'intervention' to add a tab in intervention view
+ // 'invoice' to add a tab in customer invoice view
+ // 'invoice_supplier' to add a tab in supplier invoice view
+ // 'member' to add a tab in fundation member view
+ // 'opensurveypoll' to add a tab in opensurvey poll view
+ // 'order' to add a tab in customer order view
+ // 'order_supplier' to add a tab in supplier order view
+ // 'payment' to add a tab in payment view
+ // 'payment_supplier' to add a tab in supplier payment view
+ // 'product' to add a tab in product view
+ // 'propal' to add a tab in propal view
+ // 'project' to add a tab in project view
+ // 'stock' to add a tab in stock view
+ // 'thirdparty' to add a tab in third party view
+ // 'user' to add a tab in user view
- // Dictionaries
- $this->dictionaries = array();
- /* Example:
- $this->dictionaries=array(
- 'langs'=>'mymodule@mymodule',
- // List of tables we want to see into dictonnary editor
- 'tabname'=>array(MAIN_DB_PREFIX."table1", MAIN_DB_PREFIX."table2", MAIN_DB_PREFIX."table3"),
- // Label of tables
- 'tablib'=>array("Table1", "Table2", "Table3"),
- // Request to select fields
- 'tabsql'=>array('SELECT f.rowid as rowid, f.code, f.label, f.active FROM '.MAIN_DB_PREFIX.'table1 as f', 'SELECT f.rowid as rowid, f.code, f.label, f.active FROM '.MAIN_DB_PREFIX.'table2 as f', 'SELECT f.rowid as rowid, f.code, f.label, f.active FROM '.MAIN_DB_PREFIX.'table3 as f'),
- // Sort order
- 'tabsqlsort'=>array("label ASC", "label ASC", "label ASC"),
- // List of fields (result of select to show dictionary)
- 'tabfield'=>array("code,label", "code,label", "code,label"),
- // List of fields (list of fields to edit a record)
- 'tabfieldvalue'=>array("code,label", "code,label", "code,label"),
- // List of fields (list of fields for insert)
- 'tabfieldinsert'=>array("code,label", "code,label", "code,label"),
- // Name of columns with primary key (try to always name it 'rowid')
- 'tabrowid'=>array("rowid", "rowid", "rowid"),
- // Condition to show each dictionary
- 'tabcond'=>array($conf->mymodule->enabled, $conf->mymodule->enabled, $conf->mymodule->enabled)
- );
- */
+ // Dictionaries
+ $this->dictionaries = array();
+ /* Example:
+ $this->dictionaries=array(
+ 'langs'=>'mymodule@mymodule',
+ // List of tables we want to see into dictonnary editor
+ 'tabname'=>array(MAIN_DB_PREFIX."table1", MAIN_DB_PREFIX."table2", MAIN_DB_PREFIX."table3"),
+ // Label of tables
+ 'tablib'=>array("Table1", "Table2", "Table3"),
+ // Request to select fields
+ 'tabsql'=>array('SELECT f.rowid as rowid, f.code, f.label, f.active FROM '.MAIN_DB_PREFIX.'table1 as f', 'SELECT f.rowid as rowid, f.code, f.label, f.active FROM '.MAIN_DB_PREFIX.'table2 as f', 'SELECT f.rowid as rowid, f.code, f.label, f.active FROM '.MAIN_DB_PREFIX.'table3 as f'),
+ // Sort order
+ 'tabsqlsort'=>array("label ASC", "label ASC", "label ASC"),
+ // List of fields (result of select to show dictionary)
+ 'tabfield'=>array("code,label", "code,label", "code,label"),
+ // List of fields (list of fields to edit a record)
+ 'tabfieldvalue'=>array("code,label", "code,label", "code,label"),
+ // List of fields (list of fields for insert)
+ 'tabfieldinsert'=>array("code,label", "code,label", "code,label"),
+ // Name of columns with primary key (try to always name it 'rowid')
+ 'tabrowid'=>array("rowid", "rowid", "rowid"),
+ // Condition to show each dictionary
+ 'tabcond'=>array($conf->mymodule->enabled, $conf->mymodule->enabled, $conf->mymodule->enabled)
+ );
+ */
- // Boxes/Widgets
- // Add here list of php file(s) stored in mymodule/core/boxes that contains a class to show a widget.
- $this->boxes = array(
- // 0 => array(
- // 'file' => 'mymodulewidget1.php@mymodule',
- // 'note' => 'Widget provided by MyModule',
- // 'enabledbydefaulton' => 'Home',
- // ),
- // ...
- );
+ // Boxes/Widgets
+ // Add here list of php file(s) stored in mymodule/core/boxes that contains a class to show a widget.
+ $this->boxes = array(
+ // 0 => array(
+ // 'file' => 'mymodulewidget1.php@mymodule',
+ // 'note' => 'Widget provided by MyModule',
+ // 'enabledbydefaulton' => 'Home',
+ // ),
+ // ...
+ );
- // Cronjobs (List of cron jobs entries to add when module is enabled)
- // unit_frequency must be 60 for minute, 3600 for hour, 86400 for day, 604800 for week
- $this->cronjobs = array(
- // 0 => array(
- // 'label' => 'MyJob label',
- // 'jobtype' => 'method',
- // 'class' => '/mymodule/class/myobject.class.php',
- // 'objectname' => 'MyObject',
- // 'method' => 'doScheduledJob',
- // 'parameters' => '',
- // 'comment' => 'Comment',
- // 'frequency' => 2,
- // 'unitfrequency' => 3600,
- // 'status' => 0,
- // 'test' => '$conf->mymodule->enabled',
- // 'priority' => 50,
- // ),
- );
- // Example: $this->cronjobs=array(
- // 0=>array('label'=>'My label', 'jobtype'=>'method', 'class'=>'/dir/class/file.class.php', 'objectname'=>'MyClass', 'method'=>'myMethod', 'parameters'=>'param1, param2', 'comment'=>'Comment', 'frequency'=>2, 'unitfrequency'=>3600, 'status'=>0, 'test'=>'$conf->mymodule->enabled', 'priority'=>50),
- // 1=>array('label'=>'My label', 'jobtype'=>'command', 'command'=>'', 'parameters'=>'param1, param2', 'comment'=>'Comment', 'frequency'=>1, 'unitfrequency'=>3600*24, 'status'=>0, 'test'=>'$conf->mymodule->enabled', 'priority'=>50)
- // );
+ // Cronjobs (List of cron jobs entries to add when module is enabled)
+ // unit_frequency must be 60 for minute, 3600 for hour, 86400 for day, 604800 for week
+ $this->cronjobs = array(
+ // 0 => array(
+ // 'label' => 'MyJob label',
+ // 'jobtype' => 'method',
+ // 'class' => '/mymodule/class/myobject.class.php',
+ // 'objectname' => 'MyObject',
+ // 'method' => 'doScheduledJob',
+ // 'parameters' => '',
+ // 'comment' => 'Comment',
+ // 'frequency' => 2,
+ // 'unitfrequency' => 3600,
+ // 'status' => 0,
+ // 'test' => '$conf->mymodule->enabled',
+ // 'priority' => 50,
+ // ),
+ );
+ // Example: $this->cronjobs=array(
+ // 0=>array('label'=>'My label', 'jobtype'=>'method', 'class'=>'/dir/class/file.class.php', 'objectname'=>'MyClass', 'method'=>'myMethod', 'parameters'=>'param1, param2', 'comment'=>'Comment', 'frequency'=>2, 'unitfrequency'=>3600, 'status'=>0, 'test'=>'$conf->mymodule->enabled', 'priority'=>50),
+ // 1=>array('label'=>'My label', 'jobtype'=>'command', 'command'=>'', 'parameters'=>'param1, param2', 'comment'=>'Comment', 'frequency'=>1, 'unitfrequency'=>3600*24, 'status'=>0, 'test'=>'$conf->mymodule->enabled', 'priority'=>50)
+ // );
- // Permissions provided by this module
- $this->rights = array();
- $r = 0;
- // Add here entries to declare new permissions
- /* BEGIN MODULEBUILDER PERMISSIONS */
- $this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used)
- $this->rights[$r][1] = 'Read objects of MyModule'; // Permission label
- $this->rights[$r][4] = 'myobject'; // In php code, permission will be checked by test if ($user->rights->mymodule->level1->level2)
- $this->rights[$r][5] = 'read'; // In php code, permission will be checked by test if ($user->rights->mymodule->level1->level2)
- $r++;
- $this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used)
- $this->rights[$r][1] = 'Create/Update objects of MyModule'; // Permission label
- $this->rights[$r][4] = 'myobject'; // In php code, permission will be checked by test if ($user->rights->mymodule->level1->level2)
- $this->rights[$r][5] = 'write'; // In php code, permission will be checked by test if ($user->rights->mymodule->level1->level2)
- $r++;
- $this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used)
- $this->rights[$r][1] = 'Delete objects of MyModule'; // Permission label
- $this->rights[$r][4] = 'myobject'; // In php code, permission will be checked by test if ($user->rights->mymodule->level1->level2)
- $this->rights[$r][5] = 'delete'; // In php code, permission will be checked by test if ($user->rights->mymodule->level1->level2)
- $r++;
- /* END MODULEBUILDER PERMISSIONS */
+ // Permissions provided by this module
+ $this->rights = array();
+ $r = 0;
+ // Add here entries to declare new permissions
+ /* BEGIN MODULEBUILDER PERMISSIONS */
+ $this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used)
+ $this->rights[$r][1] = 'Read objects of MyModule'; // Permission label
+ $this->rights[$r][4] = 'myobject'; // In php code, permission will be checked by test if ($user->rights->mymodule->level1->level2)
+ $this->rights[$r][5] = 'read'; // In php code, permission will be checked by test if ($user->rights->mymodule->level1->level2)
+ $r++;
+ $this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used)
+ $this->rights[$r][1] = 'Create/Update objects of MyModule'; // Permission label
+ $this->rights[$r][4] = 'myobject'; // In php code, permission will be checked by test if ($user->rights->mymodule->level1->level2)
+ $this->rights[$r][5] = 'write'; // In php code, permission will be checked by test if ($user->rights->mymodule->level1->level2)
+ $r++;
+ $this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used)
+ $this->rights[$r][1] = 'Delete objects of MyModule'; // Permission label
+ $this->rights[$r][4] = 'myobject'; // In php code, permission will be checked by test if ($user->rights->mymodule->level1->level2)
+ $this->rights[$r][5] = 'delete'; // In php code, permission will be checked by test if ($user->rights->mymodule->level1->level2)
+ $r++;
+ /* END MODULEBUILDER PERMISSIONS */
- // Main menu entries to add
- $this->menu = array();
- $r = 0;
- // Add here entries to declare new menus
- /* BEGIN MODULEBUILDER TOPMENU */
- $this->menu[$r++] = array(
- 'fk_menu'=>'', // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode
- 'type'=>'top', // This is a Top menu entry
- 'titre'=>'MyModule',
- 'mainmenu'=>'mymodule',
- 'leftmenu'=>'',
- 'url'=>'/mymodule/mymoduleindex.php',
- 'langs'=>'mymodule@mymodule', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
- 'position'=>1000 + $r,
- 'enabled'=>'$conf->mymodule->enabled', // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled.
- 'perms'=>'$user->rights->mymodule->myobject->read', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules
- 'target'=>'',
- 'user'=>2, // 0=Menu for internal users, 1=external users, 2=both
- );
- /* END MODULEBUILDER TOPMENU */
- /* BEGIN MODULEBUILDER LEFTMENU MYOBJECT
- $this->menu[$r++]=array(
- 'fk_menu'=>'fk_mainmenu=mymodule', // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode
- 'type'=>'left', // This is a Top menu entry
- 'titre'=>'MyObject',
- 'mainmenu'=>'mymodule',
- 'leftmenu'=>'myobject',
- 'url'=>'/mymodule/mymoduleindex.php',
- 'langs'=>'mymodule@mymodule', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
- 'position'=>1000+$r,
- 'enabled'=>'$conf->mymodule->enabled', // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled.
- 'perms'=>'$user->rights->mymodule->myobject->read', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules
- 'target'=>'',
- 'user'=>2, // 0=Menu for internal users, 1=external users, 2=both
- );
- $this->menu[$r++]=array(
- 'fk_menu'=>'fk_mainmenu=mymodule,fk_leftmenu=myobject', // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode
- 'type'=>'left', // This is a Left menu entry
- 'titre'=>'List MyObject',
- 'mainmenu'=>'mymodule',
- 'leftmenu'=>'mymodule_myobject_list',
- 'url'=>'/mymodule/myobject_list.php',
- 'langs'=>'mymodule@mymodule', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
- 'position'=>1000+$r,
- 'enabled'=>'$conf->mymodule->enabled', // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected.
- 'perms'=>'$user->rights->mymodule->myobject->read', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules
- 'target'=>'',
- 'user'=>2, // 0=Menu for internal users, 1=external users, 2=both
- );
- $this->menu[$r++]=array(
- 'fk_menu'=>'fk_mainmenu=mymodule,fk_leftmenu=myobject', // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode
- 'type'=>'left', // This is a Left menu entry
- 'titre'=>'New MyObject',
- 'mainmenu'=>'mymodule',
- 'leftmenu'=>'mymodule_myobject_new',
- 'url'=>'/mymodule/myobject_page.php?action=create',
- 'langs'=>'mymodule@mymodule', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
- 'position'=>1000+$r,
- 'enabled'=>'$conf->mymodule->enabled', // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected.
- 'perms'=>'$user->rights->mymodule->myobject->write', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules
- 'target'=>'',
- 'user'=>2, // 0=Menu for internal users, 1=external users, 2=both
- );
- END MODULEBUILDER LEFTMENU MYOBJECT */
+ // Main menu entries to add
+ $this->menu = array();
+ $r = 0;
+ // Add here entries to declare new menus
+ /* BEGIN MODULEBUILDER TOPMENU */
+ $this->menu[$r++] = array(
+ 'fk_menu'=>'', // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode
+ 'type'=>'top', // This is a Top menu entry
+ 'titre'=>'MyModule',
+ 'mainmenu'=>'mymodule',
+ 'leftmenu'=>'',
+ 'url'=>'/mymodule/mymoduleindex.php',
+ 'langs'=>'mymodule@mymodule', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
+ 'position'=>1000 + $r,
+ 'enabled'=>'$conf->mymodule->enabled', // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled.
+ 'perms'=>'$user->rights->mymodule->myobject->read', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules
+ 'target'=>'',
+ 'user'=>2, // 0=Menu for internal users, 1=external users, 2=both
+ );
+ /* END MODULEBUILDER TOPMENU */
+ /* BEGIN MODULEBUILDER LEFTMENU MYOBJECT
+ $this->menu[$r++]=array(
+ 'fk_menu'=>'fk_mainmenu=mymodule', // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode
+ 'type'=>'left', // This is a Top menu entry
+ 'titre'=>'MyObject',
+ 'mainmenu'=>'mymodule',
+ 'leftmenu'=>'myobject',
+ 'url'=>'/mymodule/mymoduleindex.php',
+ 'langs'=>'mymodule@mymodule', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
+ 'position'=>1000+$r,
+ 'enabled'=>'$conf->mymodule->enabled', // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled.
+ 'perms'=>'$user->rights->mymodule->myobject->read', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules
+ 'target'=>'',
+ 'user'=>2, // 0=Menu for internal users, 1=external users, 2=both
+ );
+ $this->menu[$r++]=array(
+ 'fk_menu'=>'fk_mainmenu=mymodule,fk_leftmenu=myobject', // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode
+ 'type'=>'left', // This is a Left menu entry
+ 'titre'=>'List MyObject',
+ 'mainmenu'=>'mymodule',
+ 'leftmenu'=>'mymodule_myobject_list',
+ 'url'=>'/mymodule/myobject_list.php',
+ 'langs'=>'mymodule@mymodule', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
+ 'position'=>1000+$r,
+ 'enabled'=>'$conf->mymodule->enabled', // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected.
+ 'perms'=>'$user->rights->mymodule->myobject->read', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules
+ 'target'=>'',
+ 'user'=>2, // 0=Menu for internal users, 1=external users, 2=both
+ );
+ $this->menu[$r++]=array(
+ 'fk_menu'=>'fk_mainmenu=mymodule,fk_leftmenu=myobject', // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode
+ 'type'=>'left', // This is a Left menu entry
+ 'titre'=>'New MyObject',
+ 'mainmenu'=>'mymodule',
+ 'leftmenu'=>'mymodule_myobject_new',
+ 'url'=>'/mymodule/myobject_page.php?action=create',
+ 'langs'=>'mymodule@mymodule', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
+ 'position'=>1000+$r,
+ 'enabled'=>'$conf->mymodule->enabled', // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected.
+ 'perms'=>'$user->rights->mymodule->myobject->write', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules
+ 'target'=>'',
+ 'user'=>2, // 0=Menu for internal users, 1=external users, 2=both
+ );
+ END MODULEBUILDER LEFTMENU MYOBJECT */
- // Exports profiles provided by this module
- $r = 1;
- /* BEGIN MODULEBUILDER EXPORT MYOBJECT */
- /*
- $langs->load("mymodule@mymodule");
- $this->export_code[$r]=$this->rights_class.'_'.$r;
- $this->export_label[$r]='MyObjectLines'; // Translation key (used only if key ExportDataset_xxx_z not found)
- $this->export_icon[$r]='myobject@mymodule';
- // Define $this->export_fields_array, $this->export_TypeFields_array and $this->export_entities_array
- $keyforclass = 'MyObject'; $keyforclassfile='/mymobule/class/myobject.class.php'; $keyforelement='myobject@mymodule';
- include DOL_DOCUMENT_ROOT.'/core/commonfieldsinexport.inc.php';
- //$this->export_fields_array[$r]['t.fieldtoadd']='FieldToAdd'; $this->export_TypeFields_array[$r]['t.fieldtoadd']='Text';
- //unset($this->export_fields_array[$r]['t.fieldtoremove']);
- //$keyforclass = 'MyObjectLine'; $keyforclassfile='/mymodule/class/myobject.class.php'; $keyforelement='myobjectline@mymodule'; $keyforalias='tl';
+ // Exports profiles provided by this module
+ $r = 1;
+ /* BEGIN MODULEBUILDER EXPORT MYOBJECT */
+ /*
+ $langs->load("mymodule@mymodule");
+ $this->export_code[$r]=$this->rights_class.'_'.$r;
+ $this->export_label[$r]='MyObjectLines'; // Translation key (used only if key ExportDataset_xxx_z not found)
+ $this->export_icon[$r]='myobject@mymodule';
+ // Define $this->export_fields_array, $this->export_TypeFields_array and $this->export_entities_array
+ $keyforclass = 'MyObject'; $keyforclassfile='/mymobule/class/myobject.class.php'; $keyforelement='myobject@mymodule';
+ include DOL_DOCUMENT_ROOT.'/core/commonfieldsinexport.inc.php';
+ //$this->export_fields_array[$r]['t.fieldtoadd']='FieldToAdd'; $this->export_TypeFields_array[$r]['t.fieldtoadd']='Text';
+ //unset($this->export_fields_array[$r]['t.fieldtoremove']);
+ //$keyforclass = 'MyObjectLine'; $keyforclassfile='/mymodule/class/myobject.class.php'; $keyforelement='myobjectline@mymodule'; $keyforalias='tl';
//include DOL_DOCUMENT_ROOT.'/core/commonfieldsinexport.inc.php';
- $keyforselect='myobject'; $keyforaliasextra='extra'; $keyforelement='myobject@mymodule';
- include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';
- //$keyforselect='myobjectline'; $keyforaliasextra='extraline'; $keyforelement='myobjectline@mymodule';
- //include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';
- //$this->export_dependencies_array[$r] = array('myobjectline'=>array('tl.rowid','tl.ref')); // To force to activate one or several fields if we select some fields that need same (like to select a unique key if we ask a field of a child to avoid the DISTINCT to discard them, or for computed field than need several other fields)
- //$this->export_special_array[$r] = array('t.field'=>'...');
- //$this->export_examplevalues_array[$r] = array('t.field'=>'Example');
- //$this->export_help_array[$r] = array('t.field'=>'FieldDescHelp');
- $this->export_sql_start[$r]='SELECT DISTINCT ';
- $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'myobject as t';
- //$this->export_sql_end[$r] =' LEFT JOIN '.MAIN_DB_PREFIX.'myobject_line as tl ON tl.fk_myobject = t.rowid';
- $this->export_sql_end[$r] .=' WHERE 1 = 1';
- $this->export_sql_end[$r] .=' AND t.entity IN ('.getEntity('myobject').')';
- $r++; */
- /* END MODULEBUILDER EXPORT MYOBJECT */
+ $keyforselect='myobject'; $keyforaliasextra='extra'; $keyforelement='myobject@mymodule';
+ include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';
+ //$keyforselect='myobjectline'; $keyforaliasextra='extraline'; $keyforelement='myobjectline@mymodule';
+ //include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';
+ //$this->export_dependencies_array[$r] = array('myobjectline'=>array('tl.rowid','tl.ref')); // To force to activate one or several fields if we select some fields that need same (like to select a unique key if we ask a field of a child to avoid the DISTINCT to discard them, or for computed field than need several other fields)
+ //$this->export_special_array[$r] = array('t.field'=>'...');
+ //$this->export_examplevalues_array[$r] = array('t.field'=>'Example');
+ //$this->export_help_array[$r] = array('t.field'=>'FieldDescHelp');
+ $this->export_sql_start[$r]='SELECT DISTINCT ';
+ $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'myobject as t';
+ //$this->export_sql_end[$r] =' LEFT JOIN '.MAIN_DB_PREFIX.'myobject_line as tl ON tl.fk_myobject = t.rowid';
+ $this->export_sql_end[$r] .=' WHERE 1 = 1';
+ $this->export_sql_end[$r] .=' AND t.entity IN ('.getEntity('myobject').')';
+ $r++; */
+ /* END MODULEBUILDER EXPORT MYOBJECT */
- // Imports profiles provided by this module
- $r = 1;
- /* BEGIN MODULEBUILDER IMPORT MYOBJECT */
- /*
- $langs->load("mymodule@mymodule");
- $this->export_code[$r]=$this->rights_class.'_'.$r;
- $this->export_label[$r]='MyObjectLines'; // Translation key (used only if key ExportDataset_xxx_z not found)
- $this->export_icon[$r]='myobject@mymodule';
- $keyforclass = 'MyObject'; $keyforclassfile='/mymobule/class/myobject.class.php'; $keyforelement='myobject@mymodule';
- include DOL_DOCUMENT_ROOT.'/core/commonfieldsinexport.inc.php';
- $keyforselect='myobject'; $keyforaliasextra='extra'; $keyforelement='myobject@mymodule';
- include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';
- //$this->export_dependencies_array[$r]=array('mysubobject'=>'ts.rowid', 't.myfield'=>array('t.myfield2','t.myfield3')); // To force to activate one or several fields if we select some fields that need same (like to select a unique key if we ask a field of a child to avoid the DISTINCT to discard them, or for computed field than need several other fields)
- $this->export_sql_start[$r]='SELECT DISTINCT ';
- $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'myobject as t';
- $this->export_sql_end[$r] .=' WHERE 1 = 1';
- $this->export_sql_end[$r] .=' AND t.entity IN ('.getEntity('myobject').')';
- $r++; */
- /* END MODULEBUILDER IMPORT MYOBJECT */
- }
+ // Imports profiles provided by this module
+ $r = 1;
+ /* BEGIN MODULEBUILDER IMPORT MYOBJECT */
+ /*
+ $langs->load("mymodule@mymodule");
+ $this->export_code[$r]=$this->rights_class.'_'.$r;
+ $this->export_label[$r]='MyObjectLines'; // Translation key (used only if key ExportDataset_xxx_z not found)
+ $this->export_icon[$r]='myobject@mymodule';
+ $keyforclass = 'MyObject'; $keyforclassfile='/mymobule/class/myobject.class.php'; $keyforelement='myobject@mymodule';
+ include DOL_DOCUMENT_ROOT.'/core/commonfieldsinexport.inc.php';
+ $keyforselect='myobject'; $keyforaliasextra='extra'; $keyforelement='myobject@mymodule';
+ include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';
+ //$this->export_dependencies_array[$r]=array('mysubobject'=>'ts.rowid', 't.myfield'=>array('t.myfield2','t.myfield3')); // To force to activate one or several fields if we select some fields that need same (like to select a unique key if we ask a field of a child to avoid the DISTINCT to discard them, or for computed field than need several other fields)
+ $this->export_sql_start[$r]='SELECT DISTINCT ';
+ $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'myobject as t';
+ $this->export_sql_end[$r] .=' WHERE 1 = 1';
+ $this->export_sql_end[$r] .=' AND t.entity IN ('.getEntity('myobject').')';
+ $r++; */
+ /* END MODULEBUILDER IMPORT MYOBJECT */
+ }
- /**
- * Function called when module is enabled.
- * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database.
- * It also creates data directories
- *
- * @param string $options Options when enabling module ('', 'noboxes')
- * @return int 1 if OK, 0 if KO
- */
- public function init($options = '')
- {
- global $conf, $langs;
+ /**
+ * Function called when module is enabled.
+ * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database.
+ * It also creates data directories
+ *
+ * @param string $options Options when enabling module ('', 'noboxes')
+ * @return int 1 if OK, 0 if KO
+ */
+ public function init($options = '')
+ {
+ global $conf, $langs;
- $result = $this->_load_tables('/mymodule/sql/');
- if ($result < 0) return -1; // Do not activate module if error 'not allowed' returned when loading module SQL queries (the _load_table run sql with run_sql with the error allowed parameter set to 'default')
+ $result = $this->_load_tables('/mymodule/sql/');
+ if ($result < 0) return -1; // Do not activate module if error 'not allowed' returned when loading module SQL queries (the _load_table run sql with run_sql with the error allowed parameter set to 'default')
- // Create extrafields during init
- //include_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
- //$extrafields = new ExtraFields($this->db);
- //$result1=$extrafields->addExtraField('mymodule_myattr1', "New Attr 1 label", 'boolean', 1, 3, 'thirdparty', 0, 0, '', '', 1, '', 0, 0, '', '', 'mymodule@mymodule', '$conf->mymodule->enabled');
- //$result2=$extrafields->addExtraField('mymodule_myattr2', "New Attr 2 label", 'varchar', 1, 10, 'project', 0, 0, '', '', 1, '', 0, 0, '', '', 'mymodule@mymodule', '$conf->mymodule->enabled');
- //$result3=$extrafields->addExtraField('mymodule_myattr3', "New Attr 3 label", 'varchar', 1, 10, 'bank_account', 0, 0, '', '', 1, '', 0, 0, '', '', 'mymodule@mymodule', '$conf->mymodule->enabled');
- //$result4=$extrafields->addExtraField('mymodule_myattr4', "New Attr 4 label", 'select', 1, 3, 'thirdparty', 0, 1, '', array('options'=>array('code1'=>'Val1','code2'=>'Val2','code3'=>'Val3')), 1,'', 0, 0, '', '', 'mymodule@mymodule', '$conf->mymodule->enabled');
- //$result5=$extrafields->addExtraField('mymodule_myattr5', "New Attr 5 label", 'text', 1, 10, 'user', 0, 0, '', '', 1, '', 0, 0, '', '', 'mymodule@mymodule', '$conf->mymodule->enabled');
+ // Create extrafields during init
+ //include_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
+ //$extrafields = new ExtraFields($this->db);
+ //$result1=$extrafields->addExtraField('mymodule_myattr1', "New Attr 1 label", 'boolean', 1, 3, 'thirdparty', 0, 0, '', '', 1, '', 0, 0, '', '', 'mymodule@mymodule', '$conf->mymodule->enabled');
+ //$result2=$extrafields->addExtraField('mymodule_myattr2', "New Attr 2 label", 'varchar', 1, 10, 'project', 0, 0, '', '', 1, '', 0, 0, '', '', 'mymodule@mymodule', '$conf->mymodule->enabled');
+ //$result3=$extrafields->addExtraField('mymodule_myattr3', "New Attr 3 label", 'varchar', 1, 10, 'bank_account', 0, 0, '', '', 1, '', 0, 0, '', '', 'mymodule@mymodule', '$conf->mymodule->enabled');
+ //$result4=$extrafields->addExtraField('mymodule_myattr4', "New Attr 4 label", 'select', 1, 3, 'thirdparty', 0, 1, '', array('options'=>array('code1'=>'Val1','code2'=>'Val2','code3'=>'Val3')), 1,'', 0, 0, '', '', 'mymodule@mymodule', '$conf->mymodule->enabled');
+ //$result5=$extrafields->addExtraField('mymodule_myattr5', "New Attr 5 label", 'text', 1, 10, 'user', 0, 0, '', '', 1, '', 0, 0, '', '', 'mymodule@mymodule', '$conf->mymodule->enabled');
- // Permissions
- $this->remove($options);
+ // Permissions
+ $this->remove($options);
- $sql = array();
+ $sql = array();
- // ODT template
- /*
- $src=DOL_DOCUMENT_ROOT.'/install/doctemplates/mymodule/template_myobjects.odt';
- $dirodt=DOL_DATA_ROOT.'/doctemplates/mymodule';
- $dest=$dirodt.'/template_myobjects.odt';
+ // ODT template
+ /*
+ $src=DOL_DOCUMENT_ROOT.'/install/doctemplates/mymodule/template_myobjects.odt';
+ $dirodt=DOL_DATA_ROOT.'/doctemplates/mymodule';
+ $dest=$dirodt.'/template_myobjects.odt';
- if (file_exists($src) && ! file_exists($dest))
- {
- require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
- dol_mkdir($dirodt);
- $result=dol_copy($src, $dest, 0, 0);
- if ($result < 0)
- {
- $langs->load("errors");
- $this->error=$langs->trans('ErrorFailToCopyFile', $src, $dest);
- return 0;
- }
- }
+ if (file_exists($src) && ! file_exists($dest))
+ {
+ require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
+ dol_mkdir($dirodt);
+ $result=dol_copy($src, $dest, 0, 0);
+ if ($result < 0)
+ {
+ $langs->load("errors");
+ $this->error=$langs->trans('ErrorFailToCopyFile', $src, $dest);
+ return 0;
+ }
+ }
- $sql = array(
- "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->db->escape($this->const[0][2])."' AND type = 'mymodule' AND entity = ".$conf->entity,
- "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape($this->const[0][2])."','mymodule',".$conf->entity.")"
- );
- */
+ $sql = array(
+ "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->db->escape($this->const[0][2])."' AND type = 'mymodule' AND entity = ".$conf->entity,
+ "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape($this->const[0][2])."','mymodule',".$conf->entity.")"
+ );
+ */
- return $this->_init($sql, $options);
- }
+ return $this->_init($sql, $options);
+ }
- /**
- * Function called when module is disabled.
- * Remove from database constants, boxes and permissions from Dolibarr database.
- * Data directories are not deleted
- *
- * @param string $options Options when enabling module ('', 'noboxes')
- * @return int 1 if OK, 0 if KO
- */
- public function remove($options = '')
- {
- $sql = array();
- return $this->_remove($sql, $options);
- }
+ /**
+ * Function called when module is disabled.
+ * Remove from database constants, boxes and permissions from Dolibarr database.
+ * Data directories are not deleted
+ *
+ * @param string $options Options when enabling module ('', 'noboxes')
+ * @return int 1 if OK, 0 if KO
+ */
+ public function remove($options = '')
+ {
+ $sql = array();
+ return $this->_remove($sql, $options);
+ }
}
diff --git a/htdocs/modulebuilder/template/core/modules/mymodule/doc/doc_generic_myobject_odt.modules.php b/htdocs/modulebuilder/template/core/modules/mymodule/doc/doc_generic_myobject_odt.modules.php
index 22be3dee4ed..98c2c94bc7b 100644
--- a/htdocs/modulebuilder/template/core/modules/mymodule/doc/doc_generic_myobject_odt.modules.php
+++ b/htdocs/modulebuilder/template/core/modules/mymodule/doc/doc_generic_myobject_odt.modules.php
@@ -47,14 +47,14 @@ class doc_generic_myobject_odt extends ModelePDFMyObject
public $emetteur;
/**
- * @var array Minimum version of PHP required by module.
- * e.g.: PHP ≥ 5.5 = array(5, 5)
- */
+ * @var array Minimum version of PHP required by module.
+ * e.g.: PHP ≥ 5.5 = array(5, 5)
+ */
public $phpmin = array(5, 5);
/**
- * @var string Dolibarr version of the loaded document
- */
+ * @var string Dolibarr version of the loaded document
+ */
public $version = 'dolibarr';
@@ -63,12 +63,12 @@ class doc_generic_myobject_odt extends ModelePDFMyObject
*
* @param DoliDB $db Database handler
*/
- public function __construct($db)
+ public function __construct($db)
{
global $conf, $langs, $mysoc;
// Load translation files required by the page
- $langs->loadLangs(array("main", "companies"));
+ $langs->loadLangs(array("main", "companies"));
$this->db = $db;
$this->name = "ODT templates";
@@ -108,12 +108,12 @@ class doc_generic_myobject_odt extends ModelePDFMyObject
* @param Translate $langs Lang object to use for output
* @return string Description
*/
- public function info($langs)
+ public function info($langs)
{
global $conf, $langs;
// Load translation files required by the page
- $langs->loadLangs(array("errors", "companies"));
+ $langs->loadLangs(array("errors", "companies"));
$form = new Form($this->db);
@@ -170,12 +170,12 @@ class doc_generic_myobject_odt extends ModelePDFMyObject
if ($nbofiles)
{
- $texte .= '
| ';
if ($key == 'status') print $object->getLibStatut(5);
diff --git a/htdocs/modulebuilder/template/myobject_note.php b/htdocs/modulebuilder/template/myobject_note.php
index 13d54251215..f116bf51f5b 100644
--- a/htdocs/modulebuilder/template/myobject_note.php
+++ b/htdocs/modulebuilder/template/myobject_note.php
@@ -111,35 +111,35 @@ if ($id > 0 || !empty($ref))
// Project
if (! empty($conf->projet->enabled))
{
- $langs->load("projects");
- $morehtmlref.=' '.$langs->trans('Project') . ' '; - if ($permissiontoadd) - { - if ($action != 'classify') - //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; - $morehtmlref.=' : '; - if ($action == 'classify') { - //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); - $morehtmlref.=''; - } else { - $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); - } - } else { - if (! empty($object->fk_project)) { - $proj = new Project($db); - $proj->fetch($object->fk_project); - $morehtmlref.=''; - $morehtmlref.=$proj->ref; - $morehtmlref.=''; - } else { - $morehtmlref.=''; - } - } + $langs->load("projects"); + $morehtmlref.=' '.$langs->trans('Project') . ' '; + if ($permissiontoadd) + { + if ($action != 'classify') + //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; + $morehtmlref.=' : '; + if ($action == 'classify') { + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref.=''; + } else { + $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + } + } else { + if (! empty($object->fk_project)) { + $proj = new Project($db); + $proj->fetch($object->fk_project); + $morehtmlref.=''; + $morehtmlref.=$proj->ref; + $morehtmlref.=''; + } else { + $morehtmlref.=''; + } + } }*/ $morehtmlref .= ''; diff --git a/htdocs/modulebuilder/template/scripts/mymodule.php b/htdocs/modulebuilder/template/scripts/mymodule.php index 9b9192ef84f..02024759058 100644 --- a/htdocs/modulebuilder/template/scripts/mymodule.php +++ b/htdocs/modulebuilder/template/scripts/mymodule.php @@ -29,7 +29,7 @@ $path = __DIR__.'/'; // Test if batch mode if (substr($sapi_type, 0, 3) == 'cgi') { - echo "Error: You are using PHP for CGI. To execute ".$script_file." from command line, you must use PHP for CLI mode.\n"; + echo "Error: You are using PHP for CGI. To execute ".$script_file." from command line, you must use PHP for CLI mode.\n"; exit(-1); } @@ -68,7 +68,7 @@ $user->getrights(); print "***** ".$script_file." (".$version.") pid=".dol_getmypid()." *****\n"; if (!isset($argv[1])) { // Check parameters - print "Usage: ".$script_file." param1 param2 ...\n"; + print "Usage: ".$script_file." param1 param2 ...\n"; exit(-1); } print '--- start'."\n"; diff --git a/htdocs/modulebuilder/template/test/phpunit/MyModuleFunctionalTest.php b/htdocs/modulebuilder/template/test/phpunit/MyModuleFunctionalTest.php index 7c038971ed6..9701e27d06e 100644 --- a/htdocs/modulebuilder/template/test/phpunit/MyModuleFunctionalTest.php +++ b/htdocs/modulebuilder/template/test/phpunit/MyModuleFunctionalTest.php @@ -69,14 +69,14 @@ class MyModuleFunctionalTest extends \PHPUnit_Extensions_Selenium2TestCase ), // Geckodriver does not keep the session at the moment?! // XPath selectors also don't seem to work - //array( - // 'browser' => 'Mozilla Firefox on Linux', - // 'browserName' => 'firefox', - // 'sessionStrategy' => 'shared', - // 'desiredCapabilities' => array( - // 'marionette' => true, - // ), - //) + //array( + // 'browser' => 'Mozilla Firefox on Linux', + // 'browserName' => 'firefox', + // 'sessionStrategy' => 'shared', + // 'desiredCapabilities' => array( + // 'marionette' => true, + // ), + //) ); /** @@ -99,7 +99,7 @@ class MyModuleFunctionalTest extends \PHPUnit_Extensions_Selenium2TestCase /** * Global test setup - * @return void + * @return void */ public static function setUpBeforeClass() { @@ -107,7 +107,7 @@ class MyModuleFunctionalTest extends \PHPUnit_Extensions_Selenium2TestCase /** * Unit test setup - * @return void + * @return void */ public function setUp() { @@ -117,7 +117,7 @@ class MyModuleFunctionalTest extends \PHPUnit_Extensions_Selenium2TestCase /** * Verify pre conditions - * @return void + * @return void */ protected function assertPreConditions() { @@ -125,7 +125,7 @@ class MyModuleFunctionalTest extends \PHPUnit_Extensions_Selenium2TestCase /** * Handle Dolibarr authentication - * @return void + * @return void */ private function authenticate() { @@ -146,7 +146,7 @@ class MyModuleFunctionalTest extends \PHPUnit_Extensions_Selenium2TestCase /** * Test enabling developer mode - * @return bool + * @return bool */ public function testEnableDeveloperMode() { @@ -166,7 +166,7 @@ class MyModuleFunctionalTest extends \PHPUnit_Extensions_Selenium2TestCase * Test enabling the module * * @depends testEnableDeveloperMode - * @return bool + * @return bool */ public function testModuleEnabled() { @@ -192,7 +192,7 @@ class MyModuleFunctionalTest extends \PHPUnit_Extensions_Selenium2TestCase * Test access to the configuration page * * @depends testModuleEnabled - * @return bool + * @return bool */ public function testConfigurationPage() { @@ -205,7 +205,7 @@ class MyModuleFunctionalTest extends \PHPUnit_Extensions_Selenium2TestCase * Test access to the about page * * @depends testConfigurationPage - * @return bool + * @return bool */ public function testAboutPage() { @@ -218,13 +218,13 @@ class MyModuleFunctionalTest extends \PHPUnit_Extensions_Selenium2TestCase * Test about page is rendering Markdown * * @depends testAboutPage - * @return bool + * @return bool */ public function testAboutPageRendersMarkdownReadme() { $this->url('/custom/mymodule/admin/about.php'); $this->authenticate(); - return $this->assertEquals( + return $this->assertEquals( 'Dolibarr Module Template (aka My Module)', $this->byTag('h1')->text(), "Readme title" @@ -235,7 +235,7 @@ class MyModuleFunctionalTest extends \PHPUnit_Extensions_Selenium2TestCase * Test box is properly declared * * @depends testModuleEnabled - * @return bool + * @return bool */ public function testBoxDeclared() { @@ -248,13 +248,13 @@ class MyModuleFunctionalTest extends \PHPUnit_Extensions_Selenium2TestCase * Test trigger is properly enabled * * @depends testModuleEnabled - * @return bool + * @return bool */ public function testTriggerDeclared() { $this->url('/admin/triggers.php'); $this->authenticate(); - return $this->assertContains( + return $this->assertContains( 'interface_99_modMyModule_MyModuleTriggers.class.php', $this->byTag('body')->text(), "Trigger declared" @@ -265,13 +265,13 @@ class MyModuleFunctionalTest extends \PHPUnit_Extensions_Selenium2TestCase * Test trigger is properly declared * * @depends testTriggerDeclared - * @return bool + * @return bool */ public function testTriggerEnabled() { $this->url('/admin/triggers.php'); $this->authenticate(); - return $this->assertContains( + return $this->assertContains( 'tick.png', $this->byXPath('//td[text()="interface_99_modMyModule_MyTrigger.class.php"]/following::img')->attribute('src'), "Trigger enabled" @@ -280,7 +280,7 @@ class MyModuleFunctionalTest extends \PHPUnit_Extensions_Selenium2TestCase /** * Verify post conditions - * @return void + * @return void */ protected function assertPostConditions() { @@ -288,7 +288,7 @@ class MyModuleFunctionalTest extends \PHPUnit_Extensions_Selenium2TestCase /** * Unit test teardown - * @return void + * @return void */ public function tearDown() { @@ -296,7 +296,7 @@ class MyModuleFunctionalTest extends \PHPUnit_Extensions_Selenium2TestCase /** * Global test teardown - * @return void + * @return void */ public static function tearDownAfterClass() { |