Reindent module template

This commit is contained in:
nervo
2020-05-01 08:40:55 +02:00
parent 625c7216a9
commit ba0ca3f7f7
20 changed files with 1900 additions and 1900 deletions

View File

@@ -28,284 +28,284 @@
*/ */
class ActionsMyModule class ActionsMyModule
{ {
/** /**
* @var DoliDB Database handler. * @var DoliDB Database handler.
*/ */
public $db; public $db;
/** /**
* @var string Error code (or message) * @var string Error code (or message)
*/ */
public $error = ''; public $error = '';
/** /**
* @var array Errors * @var array Errors
*/ */
public $errors = array(); public $errors = array();
/** /**
* @var array Hook results. Propagated to $hookmanager->resArray for later reuse * @var array Hook results. Propagated to $hookmanager->resArray for later reuse
*/ */
public $results = array(); public $results = array();
/** /**
* @var string String displayed by executeHook() immediately after return * @var string String displayed by executeHook() immediately after return
*/ */
public $resprints; public $resprints;
/** /**
* Constructor * Constructor
* *
* @param DoliDB $db Database handler * @param DoliDB $db Database handler
*/ */
public function __construct($db) public function __construct($db)
{ {
$this->db = $db; $this->db = $db;
} }
/** /**
* Execute action * Execute action
* *
* @param array $parameters Array of parameters * @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 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' * @param string $action 'add', 'update', 'view'
* @return int <0 if KO, * @return int <0 if KO,
* =0 if OK but we want to process standard actions too, * =0 if OK but we want to process standard actions too,
* >0 if OK and we want to replace standard actions. * >0 if OK and we want to replace standard actions.
*/ */
public function getNomUrl($parameters, &$object, &$action) public function getNomUrl($parameters, &$object, &$action)
{ {
global $db, $langs, $conf, $user; global $db, $langs, $conf, $user;
$this->resprints = ''; $this->resprints = '';
return 0; return 0;
} }
/** /**
* Overloading the doActions function : replacing the parent's function with the one below * Overloading the doActions function : replacing the parent's function with the one below
* *
* @param array $parameters Hook metadatas (context, etc...) * @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 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 string $action Current action (if set). Generally create or edit or null
* @param HookManager $hookmanager Hook manager propagated to allow calling another hook * @param HookManager $hookmanager Hook manager propagated to allow calling another hook
* @return int < 0 on error, 0 on success, 1 to replace standard code * @return int < 0 on error, 0 on success, 1 to replace standard code
*/ */
public function doActions($parameters, &$object, &$action, $hookmanager) public function doActions($parameters, &$object, &$action, $hookmanager)
{ {
global $conf, $user, $langs; global $conf, $user, $langs;
$error = 0; // Error counter $error = 0; // Error counter
/* print_r($parameters); print_r($object); echo "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' if (in_array($parameters['currentcontext'], array('somecontext1', 'somecontext2'))) // do something only for the context 'somecontext1' or 'somecontext2'
{ {
// Do what you want here... // 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. // You can for example call global vars like $fieldstosearchall to overwrite them, or update database depending on $action and $_POST values.
} }
if (!$error) { if (!$error) {
$this->results = array('myreturn' => 999); $this->results = array('myreturn' => 999);
$this->resprints = 'A text to show'; $this->resprints = 'A text to show';
return 0; // or return 1 to replace standard code return 0; // or return 1 to replace standard code
} else { } else {
$this->errors[] = 'Error message'; $this->errors[] = 'Error message';
return -1; return -1;
} }
} }
/** /**
* Overloading the doMassActions function : replacing the parent's function with the one below * Overloading the doMassActions function : replacing the parent's function with the one below
* *
* @param array $parameters Hook metadatas (context, etc...) * @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 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 string $action Current action (if set). Generally create or edit or null
* @param HookManager $hookmanager Hook manager propagated to allow calling another hook * @param HookManager $hookmanager Hook manager propagated to allow calling another hook
* @return int < 0 on error, 0 on success, 1 to replace standard code * @return int < 0 on error, 0 on success, 1 to replace standard code
*/ */
public function doMassActions($parameters, &$object, &$action, $hookmanager) public function doMassActions($parameters, &$object, &$action, $hookmanager)
{ {
global $conf, $user, $langs; global $conf, $user, $langs;
$error = 0; // Error counter $error = 0; // Error counter
/* print_r($parameters); print_r($object); echo "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' if (in_array($parameters['currentcontext'], array('somecontext1', 'somecontext2'))) // do something only for the context 'somecontext1' or 'somecontext2'
{ {
foreach ($parameters['toselect'] as $objectid) foreach ($parameters['toselect'] as $objectid)
{ {
// Do action on each object id // Do action on each object id
} }
} }
if (!$error) { if (!$error) {
$this->results = array('myreturn' => 999); $this->results = array('myreturn' => 999);
$this->resprints = 'A text to show'; $this->resprints = 'A text to show';
return 0; // or return 1 to replace standard code return 0; // or return 1 to replace standard code
} else { } else {
$this->errors[] = 'Error message'; $this->errors[] = 'Error message';
return -1; return -1;
} }
} }
/** /**
* Overloading the addMoreMassActions function : replacing the parent's function with the one below * Overloading the addMoreMassActions function : replacing the parent's function with the one below
* *
* @param array $parameters Hook metadatas (context, etc...) * @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 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 string $action Current action (if set). Generally create or edit or null
* @param HookManager $hookmanager Hook manager propagated to allow calling another hook * @param HookManager $hookmanager Hook manager propagated to allow calling another hook
* @return int < 0 on error, 0 on success, 1 to replace standard code * @return int < 0 on error, 0 on success, 1 to replace standard code
*/ */
public function addMoreMassActions($parameters, &$object, &$action, $hookmanager) public function addMoreMassActions($parameters, &$object, &$action, $hookmanager)
{ {
global $conf, $user, $langs; global $conf, $user, $langs;
$error = 0; // Error counter $error = 0; // Error counter
/* print_r($parameters); print_r($object); echo "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' if (in_array($parameters['currentcontext'], array('somecontext1', 'somecontext2'))) // do something only for the context 'somecontext1' or 'somecontext2'
{ {
$this->resprints = '<option value="0"'.($disabled ? ' disabled="disabled"' : '').'>'.$langs->trans("MyModuleMassAction").'</option>'; $this->resprints = '<option value="0"'.($disabled ? ' disabled="disabled"' : '').'>'.$langs->trans("MyModuleMassAction").'</option>';
} }
if (!$error) { if (!$error) {
return 0; // or return 1 to replace standard code return 0; // or return 1 to replace standard code
} else { } else {
$this->errors[] = 'Error message'; $this->errors[] = 'Error message';
return -1; return -1;
} }
} }
/** /**
* Execute action * Execute action
* *
* @param array $parameters Array of parameters * @param array $parameters Array of parameters
* @param Object $object Object output on PDF * @param Object $object Object output on PDF
* @param string $action 'add', 'update', 'view' * @param string $action 'add', 'update', 'view'
* @return int <0 if KO, * @return int <0 if KO,
* =0 if OK but we want to process standard actions too, * =0 if OK but we want to process standard actions too,
* >0 if OK and we want to replace standard actions. * >0 if OK and we want to replace standard actions.
*/ */
public function beforePDFCreation($parameters, &$object, &$action) public function beforePDFCreation($parameters, &$object, &$action)
{ {
global $conf, $user, $langs; global $conf, $user, $langs;
global $hookmanager; global $hookmanager;
$outputlangs = $langs; $outputlangs = $langs;
$ret = 0; $deltemp = array(); $ret = 0; $deltemp = array();
dol_syslog(get_class($this).'::executeHooks action='.$action); dol_syslog(get_class($this).'::executeHooks action='.$action);
/* print_r($parameters); print_r($object); echo "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' if (in_array($parameters['currentcontext'], array('somecontext1', 'somecontext2'))) // do something only for the context 'somecontext1' or 'somecontext2'
{ {
} }
return $ret; return $ret;
} }
/** /**
* Execute action * Execute action
* *
* @param array $parameters Array of parameters * @param array $parameters Array of parameters
* @param Object $pdfhandler PDF builder handler * @param Object $pdfhandler PDF builder handler
* @param string $action 'add', 'update', 'view' * @param string $action 'add', 'update', 'view'
* @return int <0 if KO, * @return int <0 if KO,
* =0 if OK but we want to process standard actions too, * =0 if OK but we want to process standard actions too,
* >0 if OK and we want to replace standard actions. * >0 if OK and we want to replace standard actions.
*/ */
public function afterPDFCreation($parameters, &$pdfhandler, &$action) public function afterPDFCreation($parameters, &$pdfhandler, &$action)
{ {
global $conf, $user, $langs; global $conf, $user, $langs;
global $hookmanager; global $hookmanager;
$outputlangs = $langs; $outputlangs = $langs;
$ret = 0; $deltemp = array(); $ret = 0; $deltemp = array();
dol_syslog(get_class($this).'::executeHooks action='.$action); dol_syslog(get_class($this).'::executeHooks action='.$action);
/* print_r($parameters); print_r($object); echo "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' 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 * Overloading the loadDataForCustomReports function : returns data to complete the customreport tool
* *
* @param array $parameters Hook metadatas (context, etc...) * @param array $parameters Hook metadatas (context, etc...)
* @param string $action Current action (if set). Generally create or edit or null * @param string $action Current action (if set). Generally create or edit or null
* @param HookManager $hookmanager Hook manager propagated to allow calling another hook * @param HookManager $hookmanager Hook manager propagated to allow calling another hook
* @return int < 0 on error, 0 on success, 1 to replace standard code * @return int < 0 on error, 0 on success, 1 to replace standard code
*/ */
public function loadDataForCustomReports($parameters, &$action, $hookmanager) public function loadDataForCustomReports($parameters, &$action, $hookmanager)
{ {
global $conf, $user, $langs; global $conf, $user, $langs;
$langs->load("mymodule@mymodule"); $langs->load("mymodule@mymodule");
$this->results = array(); $this->results = array();
$head = array(); $head = array();
$h = 0; $h = 0;
if ($parameters['tabfamily'] == 'mymodule') { if ($parameters['tabfamily'] == 'mymodule') {
$head[$h][0] = dol_buildpath('/module/index.php', 1); $head[$h][0] = dol_buildpath('/module/index.php', 1);
$head[$h][1] = $langs->trans("Home"); $head[$h][1] = $langs->trans("Home");
$head[$h][2] = 'home'; $head[$h][2] = 'home';
$h++; $h++;
$this->results['title'] = $langs->trans("MyModule"); $this->results['title'] = $langs->trans("MyModule");
$this->results['picto'] = 'mymodule@mymodule'; $this->results['picto'] = 'mymodule@mymodule';
} }
$head[$h][0] = 'customreports.php?objecttype='.$parameters['objecttype'].(empty($parameters['tabfamily']) ? '' : '&tabfamily='.$parameters['tabfamily']); $head[$h][0] = 'customreports.php?objecttype='.$parameters['objecttype'].(empty($parameters['tabfamily']) ? '' : '&tabfamily='.$parameters['tabfamily']);
$head[$h][1] = $langs->trans("CustomReports"); $head[$h][1] = $langs->trans("CustomReports");
$head[$h][2] = '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 * Overloading the restrictedArea function : check permission on an object
* *
* @param array $parameters Hook metadatas (context, etc...) * @param array $parameters Hook metadatas (context, etc...)
* @param string $action Current action (if set). Generally create or edit or null * @param string $action Current action (if set). Generally create or edit or null
* @param HookManager $hookmanager Hook manager propagated to allow calling another hook * @param HookManager $hookmanager Hook manager propagated to allow calling another hook
* @return int <0 if KO, * @return int <0 if KO,
* =0 if OK but we want to process standard actions too, * =0 if OK but we want to process standard actions too,
* >0 if OK and we want to replace standard actions. * >0 if OK and we want to replace standard actions.
*/ */
public function restrictedArea($parameters, &$action, $hookmanager) public function restrictedArea($parameters, &$action, $hookmanager)
{ {
global $user; global $user;
if ($parameters['features'] == 'myobject') { if ($parameters['features'] == 'myobject') {
if ($user->rights->mymodule->myobject->read) { if ($user->rights->mymodule->myobject->read) {
$this->results['result'] = 1; $this->results['result'] = 1;
return 1; return 1;
} else { } else {
$this->results['result'] = 0; $this->results['result'] = 0;
return 1; return 1;
} }
} }
return 0; return 0;
} }
/* Add here any other hooked methods... */ /* Add here any other hooked methods... */
} }

View File

@@ -36,338 +36,338 @@ dol_include_once('/mymodule/class/myobject.class.php');
*/ */
class MyModuleApi extends DolibarrApi class MyModuleApi extends DolibarrApi
{ {
/** /**
* @var MyObject $myobject {@type MyObject} * @var MyObject $myobject {@type MyObject}
*/ */
public $myobject; public $myobject;
/** /**
* Constructor * Constructor
* *
* @url GET / * @url GET /
* *
*/ */
public function __construct() public function __construct()
{ {
global $db, $conf; global $db, $conf;
$this->db = $db; $this->db = $db;
$this->myobject = new MyObject($this->db); $this->myobject = new MyObject($this->db);
} }
/** /**
* Get properties of a myobject object * Get properties of a myobject object
* *
* Return an array with myobject informations * Return an array with myobject informations
* *
* @param int $id ID of myobject * @param int $id ID of myobject
* @return array|mixed data without useless information * @return array|mixed data without useless information
* *
* @url GET myobjects/{id} * @url GET myobjects/{id}
* *
* @throws RestException * @throws RestException
*/ */
public function get($id) public function get($id)
{ {
if (!DolibarrApiAccess::$user->rights->mymodule->read) { if (!DolibarrApiAccess::$user->rights->mymodule->read) {
throw new RestException(401); throw new RestException(401);
} }
$result = $this->myobject->fetch($id); $result = $this->myobject->fetch($id);
if (!$result) { if (!$result) {
throw new RestException(404, 'MyObject not found'); throw new RestException(404, 'MyObject not found');
} }
if (!DolibarrApi::_checkAccessToResource('myobject', $this->myobject->id, 'mymodule_myobject')) { 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); 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 * List myobjects
* *
* Get a list of myobjects * Get a list of myobjects
* *
* @param string $sortfield Sort field * @param string $sortfield Sort field
* @param string $sortorder Sort order * @param string $sortorder Sort order
* @param int $limit Limit for list * @param int $limit Limit for list
* @param int $page Page number * @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')" * @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 * @return array Array of order objects
* *
* @throws RestException * @throws RestException
* *
* @url GET /myobjects/ * @url GET /myobjects/
*/ */
public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $sqlfilters = '') public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $sqlfilters = '')
{ {
global $db, $conf; global $db, $conf;
$obj_ret = array(); $obj_ret = array();
$tmpobject = new MyObject($db); $tmpobject = new MyObject($db);
if (!DolibarrApiAccess::$user->rights->bbb->read) { if (!DolibarrApiAccess::$user->rights->bbb->read) {
throw new RestException(401); 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 // If the internal user must only see his customers, force searching by him
$search_sale = 0; $search_sale = 0;
if ($restrictonsocid && !DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) $search_sale = DolibarrApiAccess::$user->id; if ($restrictonsocid && !DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) $search_sale = DolibarrApiAccess::$user->id;
$sql = "SELECT t.rowid"; $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) 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 .= " 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 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"; $sql .= " WHERE 1 = 1";
// Example of use $mode // Example of use $mode
//if ($mode == 1) $sql.= " AND s.client IN (1, 3)"; //if ($mode == 1) $sql.= " AND s.client IN (1, 3)";
//if ($mode == 2) $sql.= " AND s.client IN (2, 3)"; //if ($mode == 2) $sql.= " AND s.client IN (2, 3)";
if ($tmpobject->ismultientitymanaged) $sql .= ' AND t.entity IN ('.getEntity('myobject').')'; 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 && (!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 && $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 if ($restrictonsocid && $search_sale > 0) $sql .= " AND t.rowid = sc.fk_soc"; // Join for the needed table to filter by sale
// Insert sale filter // Insert sale filter
if ($restrictonsocid && $search_sale > 0) { if ($restrictonsocid && $search_sale > 0) {
$sql .= " AND sc.fk_user = ".$search_sale; $sql .= " AND sc.fk_user = ".$search_sale;
} }
if ($sqlfilters) if ($sqlfilters)
{ {
if (!DolibarrApi::_checkFilters($sqlfilters)) { if (!DolibarrApi::_checkFilters($sqlfilters)) {
throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters);
} }
$regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
$sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; $sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
} }
$sql .= $db->order($sortfield, $sortorder); $sql .= $db->order($sortfield, $sortorder);
if ($limit) { if ($limit) {
if ($page < 0) { if ($page < 0) {
$page = 0; $page = 0;
} }
$offset = $limit * $page; $offset = $limit * $page;
$sql .= $db->plimit($limit + 1, $offset); $sql .= $db->plimit($limit + 1, $offset);
} }
$result = $db->query($sql); $result = $db->query($sql);
if ($result) if ($result)
{ {
$num = $db->num_rows($result); $num = $db->num_rows($result);
while ($i < $num) while ($i < $num)
{ {
$obj = $db->fetch_object($result); $obj = $db->fetch_object($result);
$myobject_static = new MyObject($db); $myobject_static = new MyObject($db);
if ($myobject_static->fetch($obj->rowid)) { if ($myobject_static->fetch($obj->rowid)) {
$obj_ret[] = $this->_cleanObjectDatas($myobject_static); $obj_ret[] = $this->_cleanObjectDatas($myobject_static);
} }
$i++; $i++;
} }
} }
else { else {
throw new RestException(503, 'Error when retrieving myobject list: '.$db->lasterror()); throw new RestException(503, 'Error when retrieving myobject list: '.$db->lasterror());
} }
if (!count($obj_ret)) { if (!count($obj_ret)) {
throw new RestException(404, 'No myobject found'); throw new RestException(404, 'No myobject found');
} }
return $obj_ret; return $obj_ret;
} }
/** /**
* Create myobject object * Create myobject object
* *
* @param array $request_data Request datas * @param array $request_data Request datas
* @return int ID of myobject * @return int ID of myobject
* *
* @throws RestException * @throws RestException
* *
* @url POST myobjects/ * @url POST myobjects/
*/ */
public function post($request_data = null) public function post($request_data = null)
{ {
if (!DolibarrApiAccess::$user->rights->mymodule->write) { if (!DolibarrApiAccess::$user->rights->mymodule->write) {
throw new RestException(401); throw new RestException(401);
} }
// Check mandatory fields // Check mandatory fields
$result = $this->_validate($request_data); $result = $this->_validate($request_data);
foreach ($request_data as $field => $value) { foreach ($request_data as $field => $value) {
$this->myobject->$field = $value; $this->myobject->$field = $value;
} }
if (!$this->myobject->create(DolibarrApiAccess::$user)) { if (!$this->myobject->create(DolibarrApiAccess::$user)) {
throw new RestException(500, "Error creating MyObject", array_merge(array($this->myobject->error), $this->myobject->errors)); throw new RestException(500, "Error creating MyObject", array_merge(array($this->myobject->error), $this->myobject->errors));
} }
return $this->myobject->id; return $this->myobject->id;
} }
/** /**
* Update myobject * Update myobject
* *
* @param int $id Id of myobject to update * @param int $id Id of myobject to update
* @param array $request_data Datas * @param array $request_data Datas
* @return int * @return int
* *
* @throws RestException * @throws RestException
* *
* @url PUT myobjects/{id} * @url PUT myobjects/{id}
*/ */
public function put($id, $request_data = null) public function put($id, $request_data = null)
{ {
if (!DolibarrApiAccess::$user->rights->mymodule->write) { if (!DolibarrApiAccess::$user->rights->mymodule->write) {
throw new RestException(401); throw new RestException(401);
} }
$result = $this->myobject->fetch($id); $result = $this->myobject->fetch($id);
if (!$result) { if (!$result) {
throw new RestException(404, 'MyObject not found'); throw new RestException(404, 'MyObject not found');
} }
if (!DolibarrApi::_checkAccessToResource('myobject', $this->myobject->id, 'mymodule_myobject')) { 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); 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) { foreach ($request_data as $field => $value) {
if ($field == 'id') continue; if ($field == 'id') continue;
$this->myobject->$field = $value; $this->myobject->$field = $value;
} }
if ($this->myobject->update($id, DolibarrApiAccess::$user) > 0) if ($this->myobject->update($id, DolibarrApiAccess::$user) > 0)
{ {
return $this->get($id); return $this->get($id);
} }
else else
{ {
throw new RestException(500, $this->myobject->error); throw new RestException(500, $this->myobject->error);
} }
} }
/** /**
* Delete myobject * Delete myobject
* *
* @param int $id MyObject ID * @param int $id MyObject ID
* @return array * @return array
* *
* @throws RestException * @throws RestException
* *
* @url DELETE myobjects/{id} * @url DELETE myobjects/{id}
*/ */
public function delete($id) public function delete($id)
{ {
if (!DolibarrApiAccess::$user->rights->mymodule->delete) { if (!DolibarrApiAccess::$user->rights->mymodule->delete) {
throw new RestException(401); throw new RestException(401);
} }
$result = $this->myobject->fetch($id); $result = $this->myobject->fetch($id);
if (!$result) { if (!$result) {
throw new RestException(404, 'MyObject not found'); throw new RestException(404, 'MyObject not found');
} }
if (!DolibarrApi::_checkAccessToResource('myobject', $this->myobject->id, 'mymodule_myobject')) { 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); 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)) if (!$this->myobject->delete(DolibarrApiAccess::$user))
{ {
throw new RestException(500, 'Error when deleting MyObject : '.$this->myobject->error); throw new RestException(500, 'Error when deleting MyObject : '.$this->myobject->error);
} }
return array( return array(
'success' => array( 'success' => array(
'code' => 200, 'code' => 200,
'message' => 'MyObject deleted' 'message' => 'MyObject deleted'
) )
); );
} }
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
/** /**
* Clean sensible object datas * Clean sensible object datas
* *
* @param object $object Object to clean * @param object $object Object to clean
* @return array Array of cleaned object properties * @return array Array of cleaned object properties
*/ */
protected function _cleanObjectDatas($object) protected function _cleanObjectDatas($object)
{ {
// phpcs:enable // phpcs:enable
$object = parent::_cleanObjectDatas($object); $object = parent::_cleanObjectDatas($object);
unset($object->rowid); unset($object->rowid);
unset($object->canvas); unset($object->canvas);
/*unset($object->name); /*unset($object->name);
unset($object->lastname); unset($object->lastname);
unset($object->firstname); unset($object->firstname);
unset($object->civility_id); unset($object->civility_id);
unset($object->statut); unset($object->statut);
unset($object->state); unset($object->state);
unset($object->state_id); unset($object->state_id);
unset($object->state_code); unset($object->state_code);
unset($object->region); unset($object->region);
unset($object->region_code); unset($object->region_code);
unset($object->country); unset($object->country);
unset($object->country_id); unset($object->country_id);
unset($object->country_code); unset($object->country_code);
unset($object->barcode_type); unset($object->barcode_type);
unset($object->barcode_type_code); unset($object->barcode_type_code);
unset($object->barcode_type_label); unset($object->barcode_type_label);
unset($object->barcode_type_coder); unset($object->barcode_type_coder);
unset($object->total_ht); unset($object->total_ht);
unset($object->total_tva); unset($object->total_tva);
unset($object->total_localtax1); unset($object->total_localtax1);
unset($object->total_localtax2); unset($object->total_localtax2);
unset($object->total_ttc); unset($object->total_ttc);
unset($object->fk_account); unset($object->fk_account);
unset($object->comments); unset($object->comments);
unset($object->note); unset($object->note);
unset($object->mode_reglement_id); unset($object->mode_reglement_id);
unset($object->cond_reglement_id); unset($object->cond_reglement_id);
unset($object->cond_reglement); unset($object->cond_reglement);
unset($object->shipping_method_id); unset($object->shipping_method_id);
unset($object->fk_incoterms); unset($object->fk_incoterms);
unset($object->label_incoterms); unset($object->label_incoterms);
unset($object->location_incoterms); unset($object->location_incoterms);
*/ */
// If object has lines, remove $db property // If object has lines, remove $db property
if (isset($object->lines) && is_array($object->lines) && count($object->lines) > 0) { if (isset($object->lines) && is_array($object->lines) && count($object->lines) > 0) {
$nboflines = count($object->lines); $nboflines = count($object->lines);
for ($i = 0; $i < $nboflines; $i++) for ($i = 0; $i < $nboflines; $i++)
{ {
$this->_cleanObjectDatas($object->lines[$i]); $this->_cleanObjectDatas($object->lines[$i]);
unset($object->lines[$i]->lines); unset($object->lines[$i]->lines);
unset($object->lines[$i]->note); unset($object->lines[$i]->note);
} }
} }
return $object; return $object;
} }
/** /**
* Validate fields before create or update object * Validate fields before create or update object
* *
* @param array $data Array of data to validate * @param array $data Array of data to validate
* @return array * @return array
* *
* @throws RestException * @throws RestException
*/ */
private function _validate($data) private function _validate($data)
{ {
$myobject = array(); $myobject = array();
foreach ($this->myobject->fields as $field => $propfield) { 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 (in_array($field, array('rowid', 'entity', 'date_creation', 'tms', 'fk_user_creat')) || $propfield['notnull'] != 1) continue; // Not a mandatory field
if (!isset($data[$field])) if (!isset($data[$field]))
throw new RestException(400, "$field field missing"); throw new RestException(400, "$field field missing");
$myobject[$field] = $data[$field]; $myobject[$field] = $data[$field];
} }
return $myobject; return $myobject;
} }
} }

View File

@@ -90,16 +90,16 @@ class MyObject extends CommonObject
// BEGIN MODULEBUILDER PROPERTIES // 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( 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'), '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), '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), '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'), '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'), '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_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), '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), '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), '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), //'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), '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), '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; public $entity;
/** /**
* @var string label * @var string label
*/ */
public $label; public $label;
/** /**
* @var string amount * @var string amount
*/ */
public $amount; public $amount;
/** /**
@@ -146,28 +146,28 @@ class MyObject extends CommonObject
public $status; public $status;
/** /**
* @var integer|string date_creation * @var integer|string date_creation
*/ */
public $date_creation; public $date_creation;
/** /**
* @var integer tms * @var integer tms
*/ */
public $tms; public $tms;
/** /**
* @var int ID * @var int ID
*/ */
public $fk_user_creat; public $fk_user_creat;
/** /**
* @var int ID * @var int ID
*/ */
public $fk_user_modif; public $fk_user_modif;
/** /**
* @var string import_key * @var string import_key
*/ */
public $import_key; public $import_key;
// END MODULEBUILDER PROPERTIES // END MODULEBUILDER PROPERTIES
@@ -273,86 +273,86 @@ class MyObject extends CommonObject
public function createFromClone(User $user, $fromid) public function createFromClone(User $user, $fromid)
{ {
global $langs, $extrafields; 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 // Load source object
$result = $object->fetchCommon($fromid); $result = $object->fetchCommon($fromid);
if ($result > 0 && !empty($object->table_element_line)) $object->fetchLines(); if ($result > 0 && !empty($object->table_element_line)) $object->fetchLines();
// get lines so they will be clone // get lines so they will be clone
//foreach($this->lines as $line) //foreach($this->lines as $line)
// $line->fetch_optionals(); // $line->fetch_optionals();
// Reset some properties // Reset some properties
unset($object->id); unset($object->id);
unset($object->fk_user_creat); unset($object->fk_user_creat);
unset($object->import_key); unset($object->import_key);
// Clear fields // Clear fields
$object->ref = empty($this->fields['ref']['default']) ? "copy_of_".$object->ref : $this->fields['ref']['default']; $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->label = empty($this->fields['label']['default']) ? $langs->trans("CopyOf")." ".$object->label : $this->fields['label']['default'];
$object->status = self::STATUS_DRAFT; $object->status = self::STATUS_DRAFT;
// ... // ...
// Clear extrafields that are unique // Clear extrafields that are unique
if (is_array($object->array_options) && count($object->array_options) > 0) if (is_array($object->array_options) && count($object->array_options) > 0)
{ {
$extrafields->fetch_name_optionals_label($this->table_element); $extrafields->fetch_name_optionals_label($this->table_element);
foreach ($object->array_options as $key => $option) foreach ($object->array_options as $key => $option)
{ {
$shortkey = preg_replace('/options_/', '', $key); $shortkey = preg_replace('/options_/', '', $key);
if (!empty($extrafields->attributes[$this->element]['unique'][$shortkey])) if (!empty($extrafields->attributes[$this->element]['unique'][$shortkey]))
{ {
//var_dump($key); var_dump($clonedObj->array_options[$key]); exit; //var_dump($key); var_dump($clonedObj->array_options[$key]); exit;
unset($object->array_options[$key]); unset($object->array_options[$key]);
} }
} }
} }
// Create clone // Create clone
$object->context['createfromclone'] = 'createfromclone'; $object->context['createfromclone'] = 'createfromclone';
$result = $object->createCommon($user); $result = $object->createCommon($user);
if ($result < 0) { if ($result < 0) {
$error++; $error++;
$this->error = $object->error; $this->error = $object->error;
$this->errors = $object->errors; $this->errors = $object->errors;
} }
if (!$error) if (!$error)
{ {
// copy internal contacts // copy internal contacts
if ($this->copy_linked_contact($object, 'internal') < 0) if ($this->copy_linked_contact($object, 'internal') < 0)
{ {
$error++; $error++;
} }
} }
if (!$error) if (!$error)
{ {
// copy external contacts if same company // copy external contacts if same company
if (property_exists($this, 'socid') && $this->socid == $object->socid) if (property_exists($this, 'socid') && $this->socid == $object->socid)
{ {
if ($this->copy_linked_contact($object, 'external') < 0) if ($this->copy_linked_contact($object, 'external') < 0)
$error++; $error++;
} }
} }
unset($object->context['createfromclone']); unset($object->context['createfromclone']);
// End // End
if (!$error) { if (!$error) {
$this->db->commit(); $this->db->commit();
return $object; return $object;
} else { } else {
$this->db->rollback(); $this->db->rollback();
return -1; return -1;
} }
} }
/** /**
@@ -439,10 +439,10 @@ class MyObject extends CommonObject
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if ($resql) { if ($resql) {
$num = $this->db->num_rows($resql); $num = $this->db->num_rows($resql);
$i = 0; $i = 0;
while ($i < min($limit, $num)) while ($i < min($limit, $num))
{ {
$obj = $this->db->fetch_object($resql); $obj = $this->db->fetch_object($resql);
$record = new self($this->db); $record = new self($this->db);
$record->setVarsFromFetchObj($obj); $record->setVarsFromFetchObj($obj);
@@ -714,53 +714,53 @@ class MyObject extends CommonObject
return $this->setStatusCommon($user, self::STATUS_VALIDATED, $notrigger, 'MYOBJECT_REOPEN'); return $this->setStatusCommon($user, self::STATUS_VALIDATED, $notrigger, 'MYOBJECT_REOPEN');
} }
/** /**
* Return a link to the object card (with optionaly the picto) * 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 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 string $option On what the link point to ('nolink', ...)
* @param int $notooltip 1=Disable tooltip * @param int $notooltip 1=Disable tooltip
* @param string $morecss Add more css on link * @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 * @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 * @return string String with URL
*/ */
public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1) public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1)
{ {
global $conf, $langs, $hookmanager; 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 = '<u>'.$langs->trans("MyObject").'</u>'; $label = '<u>'.$langs->trans("MyObject").'</u>';
$label .= '<br>'; $label .= '<br>';
$label .= '<b>'.$langs->trans('Ref').':</b> '.$this->ref; $label .= '<b>'.$langs->trans('Ref').':</b> '.$this->ref;
if (isset($this->status)) { if (isset($this->status)) {
$label .= '<br><b>'.$langs->trans("Status").":</b> ".$this->getLibStatut(5); $label .= '<br><b>'.$langs->trans("Status").":</b> ".$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') if ($option != 'nolink')
{ {
// Add param to save lastsearch_values or not // Add param to save lastsearch_values or not
$add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); $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 ($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 ($add_save_lastsearch_values) $url .= '&save_lastsearch_values=1';
} }
$linkclose = ''; $linkclose = '';
if (empty($notooltip)) if (empty($notooltip))
{ {
if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER))
{ {
$label = $langs->trans("ShowMyObject"); $label = $langs->trans("ShowMyObject");
$linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"';
} }
$linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"';
$linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"'; $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"';
} }
else $linkclose = ($morecss ? ' class="'.$morecss.'"' : ''); else $linkclose = ($morecss ? ' class="'.$morecss.'"' : '');
$linkstart = '<a href="'.$url.'"'; $linkstart = '<a href="'.$url.'"';
$linkstart .= $linkclose.'>'; $linkstart .= $linkclose.'>';
@@ -810,7 +810,7 @@ class MyObject extends CommonObject
else $result .= $hookmanager->resPrint; else $result .= $hookmanager->resPrint;
return $result; return $result;
} }
/** /**
* Return label of the status * Return label of the status
@@ -823,7 +823,7 @@ class MyObject extends CommonObject
return $this->LibStatut($this->status, $mode); return $this->LibStatut($this->status, $mode);
} }
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/** /**
* Return the status * Return the status
* *
@@ -924,22 +924,22 @@ class MyObject extends CommonObject
*/ */
public function getLinesArray() public function getLinesArray()
{ {
$this->lines = array(); $this->lines = array();
$objectline = new MyObjectLine($this->db); $objectline = new MyObjectLine($this->db);
$result = $objectline->fetchAll('ASC', 'position', 0, 0, array('customsql'=>'fk_myobject = '.$this->id)); $result = $objectline->fetchAll('ASC', 'position', 0, 0, array('customsql'=>'fk_myobject = '.$this->id));
if (is_numeric($result)) if (is_numeric($result))
{ {
$this->error = $this->error; $this->error = $this->error;
$this->errors = $this->errors; $this->errors = $this->errors;
return $result; return $result;
} }
else else
{ {
$this->lines = $result; $this->lines = $result;
return $this->lines; return $this->lines;
} }
} }
/** /**

View File

@@ -194,18 +194,18 @@ class mymodulewidget1 extends ModeleBoxes
); );
} }
/** /**
* Method to show box. Called by Dolibarr eatch time it wants to display the box. * 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 $head Array with properties of box title
* @param array $contents Array with properties of box lines * @param array $contents Array with properties of box lines
* @param int $nooutput No print, only return string * @param int $nooutput No print, only return string
* @return void * @return void
*/ */
public function showBox($head = null, $contents = null, $nooutput = 0) public function showBox($head = null, $contents = null, $nooutput = 0)
{ {
// You may make your own code here… // You may make your own code here…
// … or use the parent's class function using the provided head and contents templates // … or use the parent's class function using the provided head and contents templates
parent::showBox($this->info_box_head, $this->info_box_contents); parent::showBox($this->info_box_head, $this->info_box_contents);
} }
} }

View File

@@ -17,189 +17,189 @@ dol_include_once("/mymodule/class/myobject.class.php");
*/ */
class mailing_mailinglist_mymodule_myobject extends MailingTargets class mailing_mailinglist_mymodule_myobject extends MailingTargets
{ {
// CHANGE THIS: Put here a name not already used // CHANGE THIS: Put here a name not already used
public $name = 'mailinglist_mymodule_myobject'; public $name = 'mailinglist_mymodule_myobject';
// CHANGE THIS: Put here a description of your selector module // CHANGE THIS: Put here a description of your selector module
public $desc = 'My object emailing target selector'; public $desc = 'My object emailing target selector';
// CHANGE THIS: Set to 1 if selector is available for admin users only // CHANGE THIS: Set to 1 if selector is available for admin users only
public $require_admin = 0; public $require_admin = 0;
public $enabled = 0; public $enabled = 0;
public $require_module = array(); public $require_module = array();
/** /**
* @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png
*/ */
public $picto = 'mymodule@mymodule'; public $picto = 'mymodule@mymodule';
/** /**
* @var DoliDB Database handler. * @var DoliDB Database handler.
*/ */
public $db; public $db;
/** /**
* Constructor * Constructor
* *
* @param DoliDB $db Database handler * @param DoliDB $db Database handler
*/ */
public function __construct($db) public function __construct($db)
{ {
global $conf; global $conf;
$this->db = $db; $this->db = $db;
if (is_array($conf->modules)) if (is_array($conf->modules))
{ {
$this->enabled = in_array('mymodule', $conf->modules) ? 1 : 0; $this->enabled = in_array('mymodule', $conf->modules) ? 1 : 0;
} }
} }
/** /**
* Affiche formulaire de filtre qui apparait dans page de selection des destinataires de mailings * Affiche formulaire de filtre qui apparait dans page de selection des destinataires de mailings
* *
* @return string Retourne zone select * @return string Retourne zone select
*/ */
public function formFilter() public function formFilter()
{ {
global $langs; global $langs;
$langs->load("members"); $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 = '';
$s .= $langs->trans("Status").': '; $s .= $langs->trans("Status").': ';
$s .= '<select name="filter" class="flat">'; $s .= '<select name="filter" class="flat">';
$s .= '<option value="none">&nbsp;</option>'; $s .= '<option value="none">&nbsp;</option>';
foreach ($arraystatus as $status) foreach ($arraystatus as $status)
{ {
$s .= '<option value="'.$status.'">'.$status.'</option>'; $s .= '<option value="'.$status.'">'.$status.'</option>';
} }
$s .= '</select>'; $s .= '</select>';
$s .= '<br>'; $s .= '<br>';
return $s; return $s;
} }
/** /**
* Renvoie url lien vers fiche de la source du destinataire du mailing * Renvoie url lien vers fiche de la source du destinataire du mailing
* *
* @param int $id ID * @param int $id ID
* @return string Url lien * @return string Url lien
*/ */
public function url($id) public function url($id)
{ {
return '<a href="'.dol_buildpath('/mymodule/myobject_card.php', 1).'?id='.$id.'">'.img_object('', "generic").'</a>'; return '<a href="'.dol_buildpath('/mymodule/myobject_card.php', 1).'?id='.$id.'">'.img_object('', "generic").'</a>';
} }
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/** /**
* This is the main function that returns the array of emails * This is the main function that returns the array of emails
* *
* @param int $mailing_id Id of emailing * @param int $mailing_id Id of emailing
* @return int <0 if error, number of emails added if ok * @return int <0 if error, number of emails added if ok
*/ */
public function add_to_target($mailing_id) public function add_to_target($mailing_id)
{ {
// phpcs:enable // phpcs:enable
$target = array(); $target = array();
$j = 0; $j = 0;
$sql = " select rowid as id, email, firstname, lastname, plan, partner"; $sql = " select rowid as id, email, firstname, lastname, plan, partner";
$sql .= " from ".MAIN_DB_PREFIX."myobject"; $sql .= " from ".MAIN_DB_PREFIX."myobject";
$sql .= " where email IS NOT NULL AND email != ''"; $sql .= " where email IS NOT NULL AND email != ''";
if (GETPOSTISSET('filter') && GETPOST('filter', 'alphanohtml') != 'none') $sql .= " AND status = '".$this->db->escape(GETPOST('filter', 'alphanohtml'))."'"; if (GETPOSTISSET('filter') && GETPOST('filter', 'alphanohtml') != 'none') $sql .= " AND status = '".$this->db->escape(GETPOST('filter', 'alphanohtml'))."'";
$sql .= " ORDER BY email"; $sql .= " ORDER BY email";
// Stocke destinataires dans target // Stocke destinataires dans target
$result = $this->db->query($sql); $result = $this->db->query($sql);
if ($result) if ($result)
{ {
$num = $this->db->num_rows($result); $num = $this->db->num_rows($result);
$i = 0; $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 = ''; $old = '';
while ($i < $num) while ($i < $num)
{ {
$obj = $this->db->fetch_object($result); $obj = $this->db->fetch_object($result);
if ($old <> $obj->email) if ($old <> $obj->email)
{ {
$target[$j] = array( $target[$j] = array(
'email' => $obj->email, 'email' => $obj->email,
'name' => $obj->lastname, 'name' => $obj->lastname,
'id' => $obj->id, 'id' => $obj->id,
'firstname' => $obj->firstname, 'firstname' => $obj->firstname,
'other' => $obj->plan.';'.$obj->partner, 'other' => $obj->plan.';'.$obj->partner,
'source_url' => $this->url($obj->id), 'source_url' => $this->url($obj->id),
'source_id' => $obj->id, 'source_id' => $obj->id,
'source_type' => 'dolicloud' 'source_type' => 'dolicloud'
); );
$old = $obj->email; $old = $obj->email;
$j++; $j++;
} }
$i++; $i++;
} }
} }
else else
{ {
dol_syslog($this->db->error()); dol_syslog($this->db->error());
$this->error = $this->db->error(); $this->error = $this->db->error();
return -1; return -1;
} }
// You must fill the $target array with record like this // You must fill the $target array with record like this
// $target[0]=array('email'=>'email_0','name'=>'name_0','firstname'=>'firstname_0'); // $target[0]=array('email'=>'email_0','name'=>'name_0','firstname'=>'firstname_0');
// ... // ...
// $target[n]=array('email'=>'email_n','name'=>'name_n','firstname'=>'firstname_n'); // $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. * 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 * If you want to add a line in this report you must provide an
* array of SQL request that returns two field: * array of SQL request that returns two field:
* One called "label", One called "nb". * One called "label", One called "nb".
* *
* @return array * @return array
*/ */
public function getSqlArrayForStats() public function getSqlArrayForStats()
{ {
// CHANGE THIS: Optionnal // CHANGE THIS: Optionnal
//var $statssql=array(); //var $statssql=array();
//$this->statssql[0]="SELECT field1 as label, count(distinct(email)) as nb FROM mytable WHERE email IS NOT NULL"; //$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. * Return here number of distinct emails returned by your selector.
* For example if this selector is used to extract 500 different * For example if this selector is used to extract 500 different
* emails from a text file, this function must return 500. * emails from a text file, this function must return 500.
* *
* @param string $filter Filter * @param string $filter Filter
* @param string $option Options * @param string $option Options
* @return int Nb of recipients or -1 if KO * @return int Nb of recipients or -1 if KO
*/ */
public function getNbOfRecipients($filter = 1, $option = '') 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 != ''"); $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; if ($a < 0) return -1;
return $a; return $a;
} }
} }

View File

@@ -33,419 +33,419 @@ include_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php';
*/ */
class modMyModule extends DolibarrModules class modMyModule extends DolibarrModules
{ {
/** /**
* Constructor. Define names, constants, directories, boxes, permissions * Constructor. Define names, constants, directories, boxes, permissions
* *
* @param DoliDB $db Database handler * @param DoliDB $db Database handler
*/ */
public function __construct($db) public function __construct($db)
{ {
global $langs, $conf; global $langs, $conf;
$this->db = $db; $this->db = $db;
// Id for module (must be unique). // Id for module (must be unique).
// Use here a free id (See in Home -> System information -> Dolibarr for list of used modules id). // 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 $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...) // Key text used to identify module (for permissions, menus, etc...)
$this->rights_class = 'mymodule'; $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','...' // 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 // It is used to group modules by family in module setup page
$this->family = "other"; $this->family = "other";
// Module position in the family on 2 digits ('01', '10', '20', ...) // Module position in the family on 2 digits ('01', '10', '20', ...)
$this->module_position = '90'; $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) // 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"))); //$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). // 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)); $this->name = preg_replace('/^mod/i', '', get_class($this));
// Module description, used if translation string 'ModuleMyModuleDesc' not found (MyModule is name of module). // Module description, used if translation string 'ModuleMyModuleDesc' not found (MyModule is name of module).
$this->description = "MyModuleDescription"; $this->description = "MyModuleDescription";
// Used only if file README.md and README-LL.md not found. // Used only if file README.md and README-LL.md not found.
$this->descriptionlong = "MyModule description (Long)"; $this->descriptionlong = "MyModule description (Long)";
$this->editor_name = 'Editor name'; $this->editor_name = 'Editor name';
$this->editor_url = 'https://www.example.com'; $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' // Possible values for version are: 'development', 'experimental', 'dolibarr', 'dolibarr_deprecated' or a version string like 'x.y.z'
$this->version = '1.0'; $this->version = '1.0';
// Url to the file with your last numberversion of this module // Url to the file with your last numberversion of this module
//$this->url_last_version = 'http://www.example.com/versionmodule.txt'; //$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) // 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); $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
// Name of image file used for this module. // 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 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' // If file is in module/img directory under name object_pictovalue.png, use this->picto='pictovalue@module'
$this->picto = 'generic'; $this->picto = 'generic';
// Define some features supported by module (triggers, login, substitutions, menus, css, etc...) // Define some features supported by module (triggers, login, substitutions, menus, css, etc...)
$this->module_parts = array( $this->module_parts = array(
// Set this to 1 if module has its own trigger directory (core/triggers) // Set this to 1 if module has its own trigger directory (core/triggers)
'triggers' => 0, 'triggers' => 0,
// Set this to 1 if module has its own login method file (core/login) // Set this to 1 if module has its own login method file (core/login)
'login' => 0, 'login' => 0,
// Set this to 1 if module has its own substitution function file (core/substitutions) // Set this to 1 if module has its own substitution function file (core/substitutions)
'substitutions' => 0, 'substitutions' => 0,
// Set this to 1 if module has its own menus handler directory (core/menus) // Set this to 1 if module has its own menus handler directory (core/menus)
'menus' => 0, 'menus' => 0,
// Set this to 1 if module overwrite template dir (core/tpl) // Set this to 1 if module overwrite template dir (core/tpl)
'tpl' => 0, 'tpl' => 0,
// Set this to 1 if module has its own barcode directory (core/modules/barcode) // Set this to 1 if module has its own barcode directory (core/modules/barcode)
'barcode' => 0, 'barcode' => 0,
// Set this to 1 if module has its own models directory (core/modules/xxx) // Set this to 1 if module has its own models directory (core/modules/xxx)
'models' => 0, 'models' => 0,
// Set this to 1 if module has its own theme directory (theme) // Set this to 1 if module has its own theme directory (theme)
'theme' => 0, 'theme' => 0,
// Set this to relative path of css file if module has its own css file // Set this to relative path of css file if module has its own css file
'css' => array( 'css' => array(
// '/mymodule/css/mymodule.css.php', // '/mymodule/css/mymodule.css.php',
), ),
// Set this to relative path of js file if module must load a js on all pages // Set this to relative path of js file if module must load a js on all pages
'js' => array( 'js' => array(
// '/mymodule/js/mymodule.js.php', // '/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' // 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( 'hooks' => array(
// 'data' => array( // 'data' => array(
// 'hookcontext1', // 'hookcontext1',
// 'hookcontext2', // 'hookcontext2',
// ), // ),
// 'entity' => '0', // 'entity' => '0',
), ),
// Set this to 1 if features of module are opened to external users // Set this to 1 if features of module are opened to external users
'moduleforexternal' => 0, 'moduleforexternal' => 0,
); );
// Data directories to create when module is enabled. // Data directories to create when module is enabled.
// Example: this->dirs = array("/mymodule/temp","/mymodule/subdir"); // Example: this->dirs = array("/mymodule/temp","/mymodule/subdir");
$this->dirs = array("/mymodule/temp"); $this->dirs = array("/mymodule/temp");
// Config pages. Put here list of php page, stored into mymodule/admin directory, to use to setup module. // 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"); $this->config_page_url = array("setup.php@mymodule");
// Dependencies // Dependencies
// A condition to hide module // A condition to hide module
$this->hidden = false; $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'...) // 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->depends = array();
$this->requiredby = array(); // List of module class names as string to disable if this one is disabled. Example: array('modModuleToDisable1', ...) $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->conflictwith = array(); // List of module class names as string this module is in conflict with. Example: array('modModuleToDisable1', ...)
$this->langfiles = array("mymodule@mymodule"); $this->langfiles = array("mymodule@mymodule");
$this->phpmin = array(5, 5); // Minimum version of PHP required by module $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->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 = 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->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->automatic_activation = array('FR'=>'MyModuleWasAutomaticallyActivatedBecauseOfYourCountryChoice');
//$this->always_enabled = true; // If true, can't be disabled //$this->always_enabled = true; // If true, can't be disabled
// Constants // Constants
// List of particular constants to add when module is enabled (key, 'chaine', value, desc, visible, 'current' or 'allentities', deleteonunactive) // 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), // 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) // 2 => array('MYMODULE_MYNEWCONST2', 'chaine', 'myvalue', 'This is another constant to add', 0, 'current', 1)
// ); // );
$this->const = array( $this->const = array(
// 1 => array('MYMODULE_MYCONSTANT', 'chaine', 'avalue', 'This is a constant to add', 1, 'allentities', 1) // 1 => array('MYMODULE_MYCONSTANT', 'chaine', 'avalue', 'This is a constant to add', 1, 'allentities', 1)
); );
// Some keys to add into the overwriting translation tables // Some keys to add into the overwriting translation tables
/*$this->overwrite_translation = array( /*$this->overwrite_translation = array(
'en_US:ParentCompany'=>'Parent company or reseller', 'en_US:ParentCompany'=>'Parent company or reseller',
'fr_FR:ParentCompany'=>'Maison mère ou revendeur' 'fr_FR:ParentCompany'=>'Maison mère ou revendeur'
)*/ )*/
if (!isset($conf->mymodule) || !isset($conf->mymodule->enabled)) { if (!isset($conf->mymodule) || !isset($conf->mymodule->enabled)) {
$conf->mymodule = new stdClass(); $conf->mymodule = new stdClass();
$conf->mymodule->enabled = 0; $conf->mymodule->enabled = 0;
} }
// Array to add new pages in new tabs // Array to add new pages in new tabs
$this->tabs = array(); $this->tabs = array();
// Example: // 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:+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:+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 // $this->tabs[] = array('data'=>'objecttype:-tabname:NU:conditiontoremove'); // To remove an existing tab identified by code tabname
// //
// Where objecttype can be // 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) // '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 // 'contact' to add a tab in contact view
// 'contract' to add a tab in contract view // 'contract' to add a tab in contract view
// 'group' to add a tab in group view // 'group' to add a tab in group view
// 'intervention' to add a tab in intervention view // 'intervention' to add a tab in intervention view
// 'invoice' to add a tab in customer invoice view // 'invoice' to add a tab in customer invoice view
// 'invoice_supplier' to add a tab in supplier invoice view // 'invoice_supplier' to add a tab in supplier invoice view
// 'member' to add a tab in fundation member view // 'member' to add a tab in fundation member view
// 'opensurveypoll' to add a tab in opensurvey poll view // 'opensurveypoll' to add a tab in opensurvey poll view
// 'order' to add a tab in customer order view // 'order' to add a tab in customer order view
// 'order_supplier' to add a tab in supplier order view // 'order_supplier' to add a tab in supplier order view
// 'payment' to add a tab in payment view // 'payment' to add a tab in payment view
// 'payment_supplier' to add a tab in supplier payment view // 'payment_supplier' to add a tab in supplier payment view
// 'product' to add a tab in product view // 'product' to add a tab in product view
// 'propal' to add a tab in propal view // 'propal' to add a tab in propal view
// 'project' to add a tab in project view // 'project' to add a tab in project view
// 'stock' to add a tab in stock view // 'stock' to add a tab in stock view
// 'thirdparty' to add a tab in third party view // 'thirdparty' to add a tab in third party view
// 'user' to add a tab in user view // 'user' to add a tab in user view
// Dictionaries // Dictionaries
$this->dictionaries = array(); $this->dictionaries = array();
/* Example: /* Example:
$this->dictionaries=array( $this->dictionaries=array(
'langs'=>'mymodule@mymodule', 'langs'=>'mymodule@mymodule',
// List of tables we want to see into dictonnary editor // List of tables we want to see into dictonnary editor
'tabname'=>array(MAIN_DB_PREFIX."table1", MAIN_DB_PREFIX."table2", MAIN_DB_PREFIX."table3"), 'tabname'=>array(MAIN_DB_PREFIX."table1", MAIN_DB_PREFIX."table2", MAIN_DB_PREFIX."table3"),
// Label of tables // Label of tables
'tablib'=>array("Table1", "Table2", "Table3"), 'tablib'=>array("Table1", "Table2", "Table3"),
// Request to select fields // 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'), '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 // Sort order
'tabsqlsort'=>array("label ASC", "label ASC", "label ASC"), 'tabsqlsort'=>array("label ASC", "label ASC", "label ASC"),
// List of fields (result of select to show dictionary) // List of fields (result of select to show dictionary)
'tabfield'=>array("code,label", "code,label", "code,label"), 'tabfield'=>array("code,label", "code,label", "code,label"),
// List of fields (list of fields to edit a record) // List of fields (list of fields to edit a record)
'tabfieldvalue'=>array("code,label", "code,label", "code,label"), 'tabfieldvalue'=>array("code,label", "code,label", "code,label"),
// List of fields (list of fields for insert) // List of fields (list of fields for insert)
'tabfieldinsert'=>array("code,label", "code,label", "code,label"), 'tabfieldinsert'=>array("code,label", "code,label", "code,label"),
// Name of columns with primary key (try to always name it 'rowid') // Name of columns with primary key (try to always name it 'rowid')
'tabrowid'=>array("rowid", "rowid", "rowid"), 'tabrowid'=>array("rowid", "rowid", "rowid"),
// Condition to show each dictionary // Condition to show each dictionary
'tabcond'=>array($conf->mymodule->enabled, $conf->mymodule->enabled, $conf->mymodule->enabled) 'tabcond'=>array($conf->mymodule->enabled, $conf->mymodule->enabled, $conf->mymodule->enabled)
); );
*/ */
// Boxes/Widgets // Boxes/Widgets
// Add here list of php file(s) stored in mymodule/core/boxes that contains a class to show a widget. // Add here list of php file(s) stored in mymodule/core/boxes that contains a class to show a widget.
$this->boxes = array( $this->boxes = array(
// 0 => array( // 0 => array(
// 'file' => 'mymodulewidget1.php@mymodule', // 'file' => 'mymodulewidget1.php@mymodule',
// 'note' => 'Widget provided by MyModule', // 'note' => 'Widget provided by MyModule',
// 'enabledbydefaulton' => 'Home', // 'enabledbydefaulton' => 'Home',
// ), // ),
// ... // ...
); );
// Cronjobs (List of cron jobs entries to add when module is enabled) // 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 // unit_frequency must be 60 for minute, 3600 for hour, 86400 for day, 604800 for week
$this->cronjobs = array( $this->cronjobs = array(
// 0 => array( // 0 => array(
// 'label' => 'MyJob label', // 'label' => 'MyJob label',
// 'jobtype' => 'method', // 'jobtype' => 'method',
// 'class' => '/mymodule/class/myobject.class.php', // 'class' => '/mymodule/class/myobject.class.php',
// 'objectname' => 'MyObject', // 'objectname' => 'MyObject',
// 'method' => 'doScheduledJob', // 'method' => 'doScheduledJob',
// 'parameters' => '', // 'parameters' => '',
// 'comment' => 'Comment', // 'comment' => 'Comment',
// 'frequency' => 2, // 'frequency' => 2,
// 'unitfrequency' => 3600, // 'unitfrequency' => 3600,
// 'status' => 0, // 'status' => 0,
// 'test' => '$conf->mymodule->enabled', // 'test' => '$conf->mymodule->enabled',
// 'priority' => 50, // 'priority' => 50,
// ), // ),
); );
// Example: $this->cronjobs=array( // 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), // 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) // 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 // Permissions provided by this module
$this->rights = array(); $this->rights = array();
$r = 0; $r = 0;
// Add here entries to declare new permissions // Add here entries to declare new permissions
/* BEGIN MODULEBUILDER PERMISSIONS */ /* BEGIN MODULEBUILDER PERMISSIONS */
$this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used) $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][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][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) $this->rights[$r][5] = 'read'; // In php code, permission will be checked by test if ($user->rights->mymodule->level1->level2)
$r++; $r++;
$this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used) $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][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][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) $this->rights[$r][5] = 'write'; // In php code, permission will be checked by test if ($user->rights->mymodule->level1->level2)
$r++; $r++;
$this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used) $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][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][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) $this->rights[$r][5] = 'delete'; // In php code, permission will be checked by test if ($user->rights->mymodule->level1->level2)
$r++; $r++;
/* END MODULEBUILDER PERMISSIONS */ /* END MODULEBUILDER PERMISSIONS */
// Main menu entries to add // Main menu entries to add
$this->menu = array(); $this->menu = array();
$r = 0; $r = 0;
// Add here entries to declare new menus // Add here entries to declare new menus
/* BEGIN MODULEBUILDER TOPMENU */ /* BEGIN MODULEBUILDER TOPMENU */
$this->menu[$r++] = array( $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 '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 'type'=>'top', // This is a Top menu entry
'titre'=>'MyModule', 'titre'=>'MyModule',
'mainmenu'=>'mymodule', 'mainmenu'=>'mymodule',
'leftmenu'=>'', 'leftmenu'=>'',
'url'=>'/mymodule/mymoduleindex.php', 'url'=>'/mymodule/mymoduleindex.php',
'langs'=>'mymodule@mymodule', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. 'langs'=>'mymodule@mymodule', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
'position'=>1000 + $r, '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. '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 'perms'=>'$user->rights->mymodule->myobject->read', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules
'target'=>'', 'target'=>'',
'user'=>2, // 0=Menu for internal users, 1=external users, 2=both 'user'=>2, // 0=Menu for internal users, 1=external users, 2=both
); );
/* END MODULEBUILDER TOPMENU */ /* END MODULEBUILDER TOPMENU */
/* BEGIN MODULEBUILDER LEFTMENU MYOBJECT /* BEGIN MODULEBUILDER LEFTMENU MYOBJECT
$this->menu[$r++]=array( $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 '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 'type'=>'left', // This is a Top menu entry
'titre'=>'MyObject', 'titre'=>'MyObject',
'mainmenu'=>'mymodule', 'mainmenu'=>'mymodule',
'leftmenu'=>'myobject', 'leftmenu'=>'myobject',
'url'=>'/mymodule/mymoduleindex.php', 'url'=>'/mymodule/mymoduleindex.php',
'langs'=>'mymodule@mymodule', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. 'langs'=>'mymodule@mymodule', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
'position'=>1000+$r, '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. '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 'perms'=>'$user->rights->mymodule->myobject->read', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules
'target'=>'', 'target'=>'',
'user'=>2, // 0=Menu for internal users, 1=external users, 2=both 'user'=>2, // 0=Menu for internal users, 1=external users, 2=both
); );
$this->menu[$r++]=array( $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 '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 'type'=>'left', // This is a Left menu entry
'titre'=>'List MyObject', 'titre'=>'List MyObject',
'mainmenu'=>'mymodule', 'mainmenu'=>'mymodule',
'leftmenu'=>'mymodule_myobject_list', 'leftmenu'=>'mymodule_myobject_list',
'url'=>'/mymodule/myobject_list.php', 'url'=>'/mymodule/myobject_list.php',
'langs'=>'mymodule@mymodule', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. 'langs'=>'mymodule@mymodule', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
'position'=>1000+$r, '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. '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 'perms'=>'$user->rights->mymodule->myobject->read', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules
'target'=>'', 'target'=>'',
'user'=>2, // 0=Menu for internal users, 1=external users, 2=both 'user'=>2, // 0=Menu for internal users, 1=external users, 2=both
); );
$this->menu[$r++]=array( $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 '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 'type'=>'left', // This is a Left menu entry
'titre'=>'New MyObject', 'titre'=>'New MyObject',
'mainmenu'=>'mymodule', 'mainmenu'=>'mymodule',
'leftmenu'=>'mymodule_myobject_new', 'leftmenu'=>'mymodule_myobject_new',
'url'=>'/mymodule/myobject_page.php?action=create', '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. 'langs'=>'mymodule@mymodule', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
'position'=>1000+$r, '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. '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 'perms'=>'$user->rights->mymodule->myobject->write', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules
'target'=>'', 'target'=>'',
'user'=>2, // 0=Menu for internal users, 1=external users, 2=both 'user'=>2, // 0=Menu for internal users, 1=external users, 2=both
); );
END MODULEBUILDER LEFTMENU MYOBJECT */ END MODULEBUILDER LEFTMENU MYOBJECT */
// Exports profiles provided by this module // Exports profiles provided by this module
$r = 1; $r = 1;
/* BEGIN MODULEBUILDER EXPORT MYOBJECT */ /* BEGIN MODULEBUILDER EXPORT MYOBJECT */
/* /*
$langs->load("mymodule@mymodule"); $langs->load("mymodule@mymodule");
$this->export_code[$r]=$this->rights_class.'_'.$r; $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_label[$r]='MyObjectLines'; // Translation key (used only if key ExportDataset_xxx_z not found)
$this->export_icon[$r]='myobject@mymodule'; $this->export_icon[$r]='myobject@mymodule';
// Define $this->export_fields_array, $this->export_TypeFields_array and $this->export_entities_array // 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'; $keyforclass = 'MyObject'; $keyforclassfile='/mymobule/class/myobject.class.php'; $keyforelement='myobject@mymodule';
include DOL_DOCUMENT_ROOT.'/core/commonfieldsinexport.inc.php'; include DOL_DOCUMENT_ROOT.'/core/commonfieldsinexport.inc.php';
//$this->export_fields_array[$r]['t.fieldtoadd']='FieldToAdd'; $this->export_TypeFields_array[$r]['t.fieldtoadd']='Text'; //$this->export_fields_array[$r]['t.fieldtoadd']='FieldToAdd'; $this->export_TypeFields_array[$r]['t.fieldtoadd']='Text';
//unset($this->export_fields_array[$r]['t.fieldtoremove']); //unset($this->export_fields_array[$r]['t.fieldtoremove']);
//$keyforclass = 'MyObjectLine'; $keyforclassfile='/mymodule/class/myobject.class.php'; $keyforelement='myobjectline@mymodule'; $keyforalias='tl'; //$keyforclass = 'MyObjectLine'; $keyforclassfile='/mymodule/class/myobject.class.php'; $keyforelement='myobjectline@mymodule'; $keyforalias='tl';
//include DOL_DOCUMENT_ROOT.'/core/commonfieldsinexport.inc.php'; //include DOL_DOCUMENT_ROOT.'/core/commonfieldsinexport.inc.php';
$keyforselect='myobject'; $keyforaliasextra='extra'; $keyforelement='myobject@mymodule'; $keyforselect='myobject'; $keyforaliasextra='extra'; $keyforelement='myobject@mymodule';
include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';
//$keyforselect='myobjectline'; $keyforaliasextra='extraline'; $keyforelement='myobjectline@mymodule'; //$keyforselect='myobjectline'; $keyforaliasextra='extraline'; $keyforelement='myobjectline@mymodule';
//include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; //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_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_special_array[$r] = array('t.field'=>'...');
//$this->export_examplevalues_array[$r] = array('t.field'=>'Example'); //$this->export_examplevalues_array[$r] = array('t.field'=>'Example');
//$this->export_help_array[$r] = array('t.field'=>'FieldDescHelp'); //$this->export_help_array[$r] = array('t.field'=>'FieldDescHelp');
$this->export_sql_start[$r]='SELECT DISTINCT '; $this->export_sql_start[$r]='SELECT DISTINCT ';
$this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'myobject as t'; $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] =' 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] .=' WHERE 1 = 1';
$this->export_sql_end[$r] .=' AND t.entity IN ('.getEntity('myobject').')'; $this->export_sql_end[$r] .=' AND t.entity IN ('.getEntity('myobject').')';
$r++; */ $r++; */
/* END MODULEBUILDER EXPORT MYOBJECT */ /* END MODULEBUILDER EXPORT MYOBJECT */
// Imports profiles provided by this module // Imports profiles provided by this module
$r = 1; $r = 1;
/* BEGIN MODULEBUILDER IMPORT MYOBJECT */ /* BEGIN MODULEBUILDER IMPORT MYOBJECT */
/* /*
$langs->load("mymodule@mymodule"); $langs->load("mymodule@mymodule");
$this->export_code[$r]=$this->rights_class.'_'.$r; $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_label[$r]='MyObjectLines'; // Translation key (used only if key ExportDataset_xxx_z not found)
$this->export_icon[$r]='myobject@mymodule'; $this->export_icon[$r]='myobject@mymodule';
$keyforclass = 'MyObject'; $keyforclassfile='/mymobule/class/myobject.class.php'; $keyforelement='myobject@mymodule'; $keyforclass = 'MyObject'; $keyforclassfile='/mymobule/class/myobject.class.php'; $keyforelement='myobject@mymodule';
include DOL_DOCUMENT_ROOT.'/core/commonfieldsinexport.inc.php'; include DOL_DOCUMENT_ROOT.'/core/commonfieldsinexport.inc.php';
$keyforselect='myobject'; $keyforaliasextra='extra'; $keyforelement='myobject@mymodule'; $keyforselect='myobject'; $keyforaliasextra='extra'; $keyforelement='myobject@mymodule';
include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; 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_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_start[$r]='SELECT DISTINCT ';
$this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'myobject as t'; $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] .=' WHERE 1 = 1';
$this->export_sql_end[$r] .=' AND t.entity IN ('.getEntity('myobject').')'; $this->export_sql_end[$r] .=' AND t.entity IN ('.getEntity('myobject').')';
$r++; */ $r++; */
/* END MODULEBUILDER IMPORT MYOBJECT */ /* END MODULEBUILDER IMPORT MYOBJECT */
} }
/** /**
* Function called when module is enabled. * Function called when module is enabled.
* The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database.
* It also creates data directories * It also creates data directories
* *
* @param string $options Options when enabling module ('', 'noboxes') * @param string $options Options when enabling module ('', 'noboxes')
* @return int 1 if OK, 0 if KO * @return int 1 if OK, 0 if KO
*/ */
public function init($options = '') public function init($options = '')
{ {
global $conf, $langs; global $conf, $langs;
$result = $this->_load_tables('/mymodule/sql/'); $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') 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 // Create extrafields during init
//include_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; //include_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
//$extrafields = new ExtraFields($this->db); //$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'); //$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'); //$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'); //$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'); //$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'); //$result5=$extrafields->addExtraField('mymodule_myattr5', "New Attr 5 label", 'text', 1, 10, 'user', 0, 0, '', '', 1, '', 0, 0, '', '', 'mymodule@mymodule', '$conf->mymodule->enabled');
// Permissions // Permissions
$this->remove($options); $this->remove($options);
$sql = array(); $sql = array();
// ODT template // ODT template
/* /*
$src=DOL_DOCUMENT_ROOT.'/install/doctemplates/mymodule/template_myobjects.odt'; $src=DOL_DOCUMENT_ROOT.'/install/doctemplates/mymodule/template_myobjects.odt';
$dirodt=DOL_DATA_ROOT.'/doctemplates/mymodule'; $dirodt=DOL_DATA_ROOT.'/doctemplates/mymodule';
$dest=$dirodt.'/template_myobjects.odt'; $dest=$dirodt.'/template_myobjects.odt';
if (file_exists($src) && ! file_exists($dest)) if (file_exists($src) && ! file_exists($dest))
{ {
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
dol_mkdir($dirodt); dol_mkdir($dirodt);
$result=dol_copy($src, $dest, 0, 0); $result=dol_copy($src, $dest, 0, 0);
if ($result < 0) if ($result < 0)
{ {
$langs->load("errors"); $langs->load("errors");
$this->error=$langs->trans('ErrorFailToCopyFile', $src, $dest); $this->error=$langs->trans('ErrorFailToCopyFile', $src, $dest);
return 0; return 0;
} }
} }
$sql = array( $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, "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.")" "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. * Function called when module is disabled.
* Remove from database constants, boxes and permissions from Dolibarr database. * Remove from database constants, boxes and permissions from Dolibarr database.
* Data directories are not deleted * Data directories are not deleted
* *
* @param string $options Options when enabling module ('', 'noboxes') * @param string $options Options when enabling module ('', 'noboxes')
* @return int 1 if OK, 0 if KO * @return int 1 if OK, 0 if KO
*/ */
public function remove($options = '') public function remove($options = '')
{ {
$sql = array(); $sql = array();
return $this->_remove($sql, $options); return $this->_remove($sql, $options);
} }
} }

View File

@@ -47,14 +47,14 @@ class doc_generic_myobject_odt extends ModelePDFMyObject
public $emetteur; public $emetteur;
/** /**
* @var array Minimum version of PHP required by module. * @var array Minimum version of PHP required by module.
* e.g.: PHP ≥ 5.5 = array(5, 5) * e.g.: PHP ≥ 5.5 = array(5, 5)
*/ */
public $phpmin = 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'; public $version = 'dolibarr';
@@ -63,12 +63,12 @@ class doc_generic_myobject_odt extends ModelePDFMyObject
* *
* @param DoliDB $db Database handler * @param DoliDB $db Database handler
*/ */
public function __construct($db) public function __construct($db)
{ {
global $conf, $langs, $mysoc; global $conf, $langs, $mysoc;
// Load translation files required by the page // Load translation files required by the page
$langs->loadLangs(array("main", "companies")); $langs->loadLangs(array("main", "companies"));
$this->db = $db; $this->db = $db;
$this->name = "ODT templates"; $this->name = "ODT templates";
@@ -108,12 +108,12 @@ class doc_generic_myobject_odt extends ModelePDFMyObject
* @param Translate $langs Lang object to use for output * @param Translate $langs Lang object to use for output
* @return string Description * @return string Description
*/ */
public function info($langs) public function info($langs)
{ {
global $conf, $langs; global $conf, $langs;
// Load translation files required by the page // Load translation files required by the page
$langs->loadLangs(array("errors", "companies")); $langs->loadLangs(array("errors", "companies"));
$form = new Form($this->db); $form = new Form($this->db);
@@ -170,12 +170,12 @@ class doc_generic_myobject_odt extends ModelePDFMyObject
if ($nbofiles) if ($nbofiles)
{ {
$texte .= '<div id="div_'.get_class($this).'" class="hidden">'; $texte .= '<div id="div_'.get_class($this).'" class="hidden">';
foreach ($listoffiles as $file) foreach ($listoffiles as $file)
{ {
$texte .= $file['name'].'<br>'; $texte .= $file['name'].'<br>';
} }
$texte .= '</div>'; $texte .= '</div>';
} }
$texte .= '</td>'; $texte .= '</td>';
@@ -191,7 +191,7 @@ class doc_generic_myobject_odt extends ModelePDFMyObject
return $texte; return $texte;
} }
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/** /**
* Function to build a document on disk using the generic odt module. * Function to build a document on disk using the generic odt module.
* *
@@ -203,9 +203,9 @@ class doc_generic_myobject_odt extends ModelePDFMyObject
* @param int $hideref Do not show ref * @param int $hideref Do not show ref
* @return int 1 if OK, <=0 if KO * @return int 1 if OK, <=0 if KO
*/ */
public function write_file($object, $outputlangs, $srctemplatepath, $hidedetails = 0, $hidedesc = 0, $hideref = 0) public function write_file($object, $outputlangs, $srctemplatepath, $hidedetails = 0, $hidedesc = 0, $hideref = 0)
{ {
// phpcs:enable // phpcs:enable
global $user, $langs, $conf, $mysoc, $hookmanager; global $user, $langs, $conf, $mysoc, $hookmanager;
if (empty($srctemplatepath)) if (empty($srctemplatepath))
@@ -271,8 +271,8 @@ class doc_generic_myobject_odt extends ModelePDFMyObject
$newfileformat = substr($newfile, strrpos($newfile, '.') + 1); $newfileformat = substr($newfile, strrpos($newfile, '.') + 1);
if (!empty($conf->global->MAIN_DOC_USE_TIMING)) if (!empty($conf->global->MAIN_DOC_USE_TIMING))
{ {
$format = $conf->global->MAIN_DOC_USE_TIMING; $format = $conf->global->MAIN_DOC_USE_TIMING;
if ($format == '1') $format = '%Y%m%d%H%M%S'; if ($format == '1') $format = '%Y%m%d%H%M%S';
$filename = $newfiletmp.'-'.dol_print_date(dol_now(), $format).'.'.$newfileformat; $filename = $newfiletmp.'-'.dol_print_date(dol_now(), $format).'.'.$newfileformat;
} }
else else
@@ -304,10 +304,10 @@ class doc_generic_myobject_odt extends ModelePDFMyObject
// On peut utiliser le nom de la societe du contact // On peut utiliser le nom de la societe du contact
if (!empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socobject = $object->contact; if (!empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socobject = $object->contact;
else { else {
$socobject = $object->thirdparty; $socobject = $object->thirdparty;
// if we have a CUSTOMER contact and we dont use it as recipient we store the contact object for later use // if we have a CUSTOMER contact and we dont use it as recipient we store the contact object for later use
$contactobject = $object->contact; $contactobject = $object->contact;
} }
} }
else else
{ {
@@ -338,7 +338,7 @@ class doc_generic_myobject_odt extends ModelePDFMyObject
// Open and load template // Open and load template
require_once ODTPHP_PATH.'odf.php'; require_once ODTPHP_PATH.'odf.php';
try { try {
$odfHandler = new odf( $odfHandler = new odf(
$srctemplatepath, $srctemplatepath,
array( array(
'PATH_TO_TMP' => $conf->commande->dir_temp, 'PATH_TO_TMP' => $conf->commande->dir_temp,
@@ -367,7 +367,7 @@ class doc_generic_myobject_odt extends ModelePDFMyObject
} }
catch (OdfException $e) catch (OdfException $e)
{ {
dol_syslog($e->getMessage(), LOG_INFO); dol_syslog($e->getMessage(), LOG_INFO);
} }
// Define substitution array // Define substitution array
@@ -404,7 +404,7 @@ class doc_generic_myobject_odt extends ModelePDFMyObject
} }
catch (OdfException $e) catch (OdfException $e)
{ {
dol_syslog($e->getMessage(), LOG_INFO); dol_syslog($e->getMessage(), LOG_INFO);
} }
} }
// Replace tags of lines // Replace tags of lines
@@ -439,11 +439,11 @@ class doc_generic_myobject_odt extends ModelePDFMyObject
} }
catch (OdfException $e) catch (OdfException $e)
{ {
dol_syslog($e->getMessage(), LOG_INFO); dol_syslog($e->getMessage(), LOG_INFO);
} }
catch (SegmentException $e) catch (SegmentException $e)
{ {
dol_syslog($e->getMessage(), LOG_INFO); dol_syslog($e->getMessage(), LOG_INFO);
} }
} }
$listlines->merge(); $listlines->merge();
@@ -467,7 +467,7 @@ class doc_generic_myobject_odt extends ModelePDFMyObject
} }
catch (OdfException $e) catch (OdfException $e)
{ {
dol_syslog($e->getMessage(), LOG_INFO); dol_syslog($e->getMessage(), LOG_INFO);
} }
} }
@@ -481,8 +481,8 @@ class doc_generic_myobject_odt extends ModelePDFMyObject
try { try {
$odfHandler->exportAsAttachedPDF($file); $odfHandler->exportAsAttachedPDF($file);
} catch (Exception $e) { } catch (Exception $e) {
$this->error = $e->getMessage(); $this->error = $e->getMessage();
dol_syslog($e->getMessage(), LOG_INFO); dol_syslog($e->getMessage(), LOG_INFO);
return -1; return -1;
} }
} }
@@ -490,8 +490,8 @@ class doc_generic_myobject_odt extends ModelePDFMyObject
try { try {
$odfHandler->saveToDisk($file); $odfHandler->saveToDisk($file);
} catch (Exception $e) { } catch (Exception $e) {
$this->error = $e->getMessage(); $this->error = $e->getMessage();
dol_syslog($e->getMessage(), LOG_INFO); dol_syslog($e->getMessage(), LOG_INFO);
return -1; return -1;
} }
} }

View File

@@ -98,15 +98,15 @@ class mod_myobject_advanced extends ModeleNumRefMyObject
*/ */
public function getExample() public function getExample()
{ {
global $conf, $db, $langs, $mysoc; global $conf, $db, $langs, $mysoc;
$object = new MyObject($db); $object = new MyObject($db);
$object->initAsSpecimen(); $object->initAsSpecimen();
/*$old_code_client = $mysoc->code_client; /*$old_code_client = $mysoc->code_client;
$old_code_type = $mysoc->typent_code; $old_code_type = $mysoc->typent_code;
$mysoc->code_client = 'CCCCCCCCCC'; $mysoc->code_client = 'CCCCCCCCCC';
$mysoc->typent_code = 'TTTTTTTTTT';*/ $mysoc->typent_code = 'TTTTTTTTTT';*/
$numExample = $this->getNextValue($object); $numExample = $this->getNextValue($object);

View File

@@ -57,7 +57,7 @@ class mod_myobject_standard extends ModeleNumRefMyObject
public function info() public function info()
{ {
global $langs; global $langs;
return $langs->trans("SimpleNumRefModelDesc", $this->prefix); return $langs->trans("SimpleNumRefModelDesc", $this->prefix);
} }

View File

@@ -38,17 +38,17 @@ $langs->load("mymodule");
$total = 0; $ilink = 0; $total = 0; $ilink = 0;
foreach ($linkedObjectBlock as $key => $objectlink) foreach ($linkedObjectBlock as $key => $objectlink)
{ {
$ilink++; $ilink++;
$trclass = 'oddeven'; $trclass = 'oddeven';
if ($ilink == count($linkedObjectBlock) && empty($noMoreLinkedObjectBlockAfter) && count($linkedObjectBlock) <= 1) $trclass .= ' liste_sub_total'; if ($ilink == count($linkedObjectBlock) && empty($noMoreLinkedObjectBlockAfter) && count($linkedObjectBlock) <= 1) $trclass .= ' liste_sub_total';
?> ?>
<tr class="<?php echo $trclass; ?>"> <tr class="<?php echo $trclass; ?>">
<td><?php echo $langs->trans("MyObject"); ?></td> <td><?php echo $langs->trans("MyObject"); ?></td>
<td><?php echo $objectlink->getNomUrl(1); ?></td> <td><?php echo $objectlink->getNomUrl(1); ?></td>
<td></td> <td></td>
<td class="center"><?php echo dol_print_date($objectlink->date, 'day'); ?></td> <td class="center"><?php echo dol_print_date($objectlink->date, 'day'); ?></td>
<td class="right"><?php echo ''; ?></td> <td class="right"><?php echo ''; ?></td>
<td class="right"><?php echo $objectlink->getLibStatut(7); ?></td> <td class="right"><?php echo $objectlink->getLibStatut(7); ?></td>
<td class="right"><a class="reposition" href="<?php echo $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=dellink&dellinkid='.$key; ?>"><?php echo img_picto($langs->transnoentitiesnoconv("RemoveLink"), 'unlink'); ?></a></td> <td class="right"><a class="reposition" href="<?php echo $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=dellink&dellinkid='.$key; ?>"><?php echo img_picto($langs->transnoentitiesnoconv("RemoveLink"), 'unlink'); ?></a></td>
</tr> </tr>

View File

@@ -40,278 +40,278 @@ require_once DOL_DOCUMENT_ROOT.'/core/triggers/dolibarrtriggers.class.php';
*/ */
class InterfaceMyModuleTriggers extends DolibarrTriggers class InterfaceMyModuleTriggers extends DolibarrTriggers
{ {
/** /**
* @var DoliDB Database handler * @var DoliDB Database handler
*/ */
protected $db; protected $db;
/** /**
* Constructor * Constructor
* *
* @param DoliDB $db Database handler * @param DoliDB $db Database handler
*/ */
public function __construct($db) public function __construct($db)
{ {
$this->db = $db; $this->db = $db;
$this->name = preg_replace('/^Interface/i', '', get_class($this)); $this->name = preg_replace('/^Interface/i', '', get_class($this));
$this->family = "demo"; $this->family = "demo";
$this->description = "MyModule triggers."; $this->description = "MyModule triggers.";
// 'development', 'experimental', 'dolibarr' or version // 'development', 'experimental', 'dolibarr' or version
$this->version = 'development'; $this->version = 'development';
$this->picto = 'mymodule@mymodule'; $this->picto = 'mymodule@mymodule';
} }
/** /**
* Trigger name * Trigger name
* *
* @return string Name of trigger file * @return string Name of trigger file
*/ */
public function getName() public function getName()
{ {
return $this->name; return $this->name;
} }
/** /**
* Trigger description * Trigger description
* *
* @return string Description of trigger file * @return string Description of trigger file
*/ */
public function getDesc() public function getDesc()
{ {
return $this->description; return $this->description;
} }
/** /**
* Function called when a Dolibarrr business event is done. * Function called when a Dolibarrr business event is done.
* All functions "runTrigger" are triggered if file * All functions "runTrigger" are triggered if file
* is inside directory core/triggers * is inside directory core/triggers
* *
* @param string $action Event action code * @param string $action Event action code
* @param CommonObject $object Object * @param CommonObject $object Object
* @param User $user Object user * @param User $user Object user
* @param Translate $langs Object langs * @param Translate $langs Object langs
* @param Conf $conf Object conf * @param Conf $conf Object conf
* @return int <0 if KO, 0 if no triggered ran, >0 if OK * @return int <0 if KO, 0 if no triggered ran, >0 if OK
*/ */
public function runTrigger($action, $object, User $user, Translate $langs, Conf $conf) public function runTrigger($action, $object, User $user, Translate $langs, Conf $conf)
{ {
if (empty($conf->mymodule->enabled)) return 0; // If module is not enabled, we do nothing if (empty($conf->mymodule->enabled)) return 0; // If module is not enabled, we do nothing
// Put here code you want to execute when a Dolibarr business events occurs. // Put here code you want to execute when a Dolibarr business events occurs.
// Data and type of action are stored into $object and $action // Data and type of action are stored into $object and $action
switch ($action) { switch ($action) {
// Users // Users
//case 'USER_CREATE': //case 'USER_CREATE':
//case 'USER_MODIFY': //case 'USER_MODIFY':
//case 'USER_NEW_PASSWORD': //case 'USER_NEW_PASSWORD':
//case 'USER_ENABLEDISABLE': //case 'USER_ENABLEDISABLE':
//case 'USER_DELETE': //case 'USER_DELETE':
//case 'USER_SETINGROUP': //case 'USER_SETINGROUP':
//case 'USER_REMOVEFROMGROUP': //case 'USER_REMOVEFROMGROUP':
// Actions // Actions
//case 'ACTION_MODIFY': //case 'ACTION_MODIFY':
//case 'ACTION_CREATE': //case 'ACTION_CREATE':
//case 'ACTION_DELETE': //case 'ACTION_DELETE':
// Groups // Groups
//case 'USERGROUP_CREATE': //case 'USERGROUP_CREATE':
//case 'USERGROUP_MODIFY': //case 'USERGROUP_MODIFY':
//case 'USERGROUP_DELETE': //case 'USERGROUP_DELETE':
// Companies // Companies
//case 'COMPANY_CREATE': //case 'COMPANY_CREATE':
//case 'COMPANY_MODIFY': //case 'COMPANY_MODIFY':
//case 'COMPANY_DELETE': //case 'COMPANY_DELETE':
// Contacts // Contacts
//case 'CONTACT_CREATE': //case 'CONTACT_CREATE':
//case 'CONTACT_MODIFY': //case 'CONTACT_MODIFY':
//case 'CONTACT_DELETE': //case 'CONTACT_DELETE':
//case 'CONTACT_ENABLEDISABLE': //case 'CONTACT_ENABLEDISABLE':
// Products // Products
//case 'PRODUCT_CREATE': //case 'PRODUCT_CREATE':
//case 'PRODUCT_MODIFY': //case 'PRODUCT_MODIFY':
//case 'PRODUCT_DELETE': //case 'PRODUCT_DELETE':
//case 'PRODUCT_PRICE_MODIFY': //case 'PRODUCT_PRICE_MODIFY':
//case 'PRODUCT_SET_MULTILANGS': //case 'PRODUCT_SET_MULTILANGS':
//case 'PRODUCT_DEL_MULTILANGS': //case 'PRODUCT_DEL_MULTILANGS':
//Stock mouvement //Stock mouvement
//case 'STOCK_MOVEMENT': //case 'STOCK_MOVEMENT':
//MYECMDIR //MYECMDIR
//case 'MYECMDIR_CREATE': //case 'MYECMDIR_CREATE':
//case 'MYECMDIR_MODIFY': //case 'MYECMDIR_MODIFY':
//case 'MYECMDIR_DELETE': //case 'MYECMDIR_DELETE':
// Customer orders // Customer orders
//case 'ORDER_CREATE': //case 'ORDER_CREATE':
//case 'ORDER_MODIFY': //case 'ORDER_MODIFY':
//case 'ORDER_VALIDATE': //case 'ORDER_VALIDATE':
//case 'ORDER_DELETE': //case 'ORDER_DELETE':
//case 'ORDER_CANCEL': //case 'ORDER_CANCEL':
//case 'ORDER_SENTBYMAIL': //case 'ORDER_SENTBYMAIL':
//case 'ORDER_CLASSIFY_BILLED': //case 'ORDER_CLASSIFY_BILLED':
//case 'ORDER_SETDRAFT': //case 'ORDER_SETDRAFT':
//case 'LINEORDER_INSERT': //case 'LINEORDER_INSERT':
//case 'LINEORDER_UPDATE': //case 'LINEORDER_UPDATE':
//case 'LINEORDER_DELETE': //case 'LINEORDER_DELETE':
// Supplier orders // Supplier orders
//case 'ORDER_SUPPLIER_CREATE': //case 'ORDER_SUPPLIER_CREATE':
//case 'ORDER_SUPPLIER_MODIFY': //case 'ORDER_SUPPLIER_MODIFY':
//case 'ORDER_SUPPLIER_VALIDATE': //case 'ORDER_SUPPLIER_VALIDATE':
//case 'ORDER_SUPPLIER_DELETE': //case 'ORDER_SUPPLIER_DELETE':
//case 'ORDER_SUPPLIER_APPROVE': //case 'ORDER_SUPPLIER_APPROVE':
//case 'ORDER_SUPPLIER_REFUSE': //case 'ORDER_SUPPLIER_REFUSE':
//case 'ORDER_SUPPLIER_CANCEL': //case 'ORDER_SUPPLIER_CANCEL':
//case 'ORDER_SUPPLIER_SENTBYMAIL': //case 'ORDER_SUPPLIER_SENTBYMAIL':
//case 'ORDER_SUPPLIER_DISPATCH': //case 'ORDER_SUPPLIER_DISPATCH':
//case 'LINEORDER_SUPPLIER_DISPATCH': //case 'LINEORDER_SUPPLIER_DISPATCH':
//case 'LINEORDER_SUPPLIER_CREATE': //case 'LINEORDER_SUPPLIER_CREATE':
//case 'LINEORDER_SUPPLIER_UPDATE': //case 'LINEORDER_SUPPLIER_UPDATE':
//case 'LINEORDER_SUPPLIER_DELETE': //case 'LINEORDER_SUPPLIER_DELETE':
// Proposals // Proposals
//case 'PROPAL_CREATE': //case 'PROPAL_CREATE':
//case 'PROPAL_MODIFY': //case 'PROPAL_MODIFY':
//case 'PROPAL_VALIDATE': //case 'PROPAL_VALIDATE':
//case 'PROPAL_SENTBYMAIL': //case 'PROPAL_SENTBYMAIL':
//case 'PROPAL_CLOSE_SIGNED': //case 'PROPAL_CLOSE_SIGNED':
//case 'PROPAL_CLOSE_REFUSED': //case 'PROPAL_CLOSE_REFUSED':
//case 'PROPAL_DELETE': //case 'PROPAL_DELETE':
//case 'LINEPROPAL_INSERT': //case 'LINEPROPAL_INSERT':
//case 'LINEPROPAL_UPDATE': //case 'LINEPROPAL_UPDATE':
//case 'LINEPROPAL_DELETE': //case 'LINEPROPAL_DELETE':
// SupplierProposal // SupplierProposal
//case 'SUPPLIER_PROPOSAL_CREATE': //case 'SUPPLIER_PROPOSAL_CREATE':
//case 'SUPPLIER_PROPOSAL_MODIFY': //case 'SUPPLIER_PROPOSAL_MODIFY':
//case 'SUPPLIER_PROPOSAL_VALIDATE': //case 'SUPPLIER_PROPOSAL_VALIDATE':
//case 'SUPPLIER_PROPOSAL_SENTBYMAIL': //case 'SUPPLIER_PROPOSAL_SENTBYMAIL':
//case 'SUPPLIER_PROPOSAL_CLOSE_SIGNED': //case 'SUPPLIER_PROPOSAL_CLOSE_SIGNED':
//case 'SUPPLIER_PROPOSAL_CLOSE_REFUSED': //case 'SUPPLIER_PROPOSAL_CLOSE_REFUSED':
//case 'SUPPLIER_PROPOSAL_DELETE': //case 'SUPPLIER_PROPOSAL_DELETE':
//case 'LINESUPPLIER_PROPOSAL_INSERT': //case 'LINESUPPLIER_PROPOSAL_INSERT':
//case 'LINESUPPLIER_PROPOSAL_UPDATE': //case 'LINESUPPLIER_PROPOSAL_UPDATE':
//case 'LINESUPPLIER_PROPOSAL_DELETE': //case 'LINESUPPLIER_PROPOSAL_DELETE':
// Contracts // Contracts
//case 'CONTRACT_CREATE': //case 'CONTRACT_CREATE':
//case 'CONTRACT_MODIFY': //case 'CONTRACT_MODIFY':
//case 'CONTRACT_ACTIVATE': //case 'CONTRACT_ACTIVATE':
//case 'CONTRACT_CANCEL': //case 'CONTRACT_CANCEL':
//case 'CONTRACT_CLOSE': //case 'CONTRACT_CLOSE':
//case 'CONTRACT_DELETE': //case 'CONTRACT_DELETE':
//case 'LINECONTRACT_INSERT': //case 'LINECONTRACT_INSERT':
//case 'LINECONTRACT_UPDATE': //case 'LINECONTRACT_UPDATE':
//case 'LINECONTRACT_DELETE': //case 'LINECONTRACT_DELETE':
// Bills // Bills
//case 'BILL_CREATE': //case 'BILL_CREATE':
//case 'BILL_MODIFY': //case 'BILL_MODIFY':
//case 'BILL_VALIDATE': //case 'BILL_VALIDATE':
//case 'BILL_UNVALIDATE': //case 'BILL_UNVALIDATE':
//case 'BILL_SENTBYMAIL': //case 'BILL_SENTBYMAIL':
//case 'BILL_CANCEL': //case 'BILL_CANCEL':
//case 'BILL_DELETE': //case 'BILL_DELETE':
//case 'BILL_PAYED': //case 'BILL_PAYED':
//case 'LINEBILL_INSERT': //case 'LINEBILL_INSERT':
//case 'LINEBILL_UPDATE': //case 'LINEBILL_UPDATE':
//case 'LINEBILL_DELETE': //case 'LINEBILL_DELETE':
//Supplier Bill //Supplier Bill
//case 'BILL_SUPPLIER_CREATE': //case 'BILL_SUPPLIER_CREATE':
//case 'BILL_SUPPLIER_UPDATE': //case 'BILL_SUPPLIER_UPDATE':
//case 'BILL_SUPPLIER_DELETE': //case 'BILL_SUPPLIER_DELETE':
//case 'BILL_SUPPLIER_PAYED': //case 'BILL_SUPPLIER_PAYED':
//case 'BILL_SUPPLIER_UNPAYED': //case 'BILL_SUPPLIER_UNPAYED':
//case 'BILL_SUPPLIER_VALIDATE': //case 'BILL_SUPPLIER_VALIDATE':
//case 'BILL_SUPPLIER_UNVALIDATE': //case 'BILL_SUPPLIER_UNVALIDATE':
//case 'LINEBILL_SUPPLIER_CREATE': //case 'LINEBILL_SUPPLIER_CREATE':
//case 'LINEBILL_SUPPLIER_UPDATE': //case 'LINEBILL_SUPPLIER_UPDATE':
//case 'LINEBILL_SUPPLIER_DELETE': //case 'LINEBILL_SUPPLIER_DELETE':
// Payments // Payments
//case 'PAYMENT_CUSTOMER_CREATE': //case 'PAYMENT_CUSTOMER_CREATE':
//case 'PAYMENT_SUPPLIER_CREATE': //case 'PAYMENT_SUPPLIER_CREATE':
//case 'PAYMENT_ADD_TO_BANK': //case 'PAYMENT_ADD_TO_BANK':
//case 'PAYMENT_DELETE': //case 'PAYMENT_DELETE':
// Online // Online
//case 'PAYMENT_PAYBOX_OK': //case 'PAYMENT_PAYBOX_OK':
//case 'PAYMENT_PAYPAL_OK': //case 'PAYMENT_PAYPAL_OK':
//case 'PAYMENT_STRIPE_OK': //case 'PAYMENT_STRIPE_OK':
// Donation // Donation
//case 'DON_CREATE': //case 'DON_CREATE':
//case 'DON_UPDATE': //case 'DON_UPDATE':
//case 'DON_DELETE': //case 'DON_DELETE':
// Interventions // Interventions
//case 'FICHINTER_CREATE': //case 'FICHINTER_CREATE':
//case 'FICHINTER_MODIFY': //case 'FICHINTER_MODIFY':
//case 'FICHINTER_VALIDATE': //case 'FICHINTER_VALIDATE':
//case 'FICHINTER_DELETE': //case 'FICHINTER_DELETE':
//case 'LINEFICHINTER_CREATE': //case 'LINEFICHINTER_CREATE':
//case 'LINEFICHINTER_UPDATE': //case 'LINEFICHINTER_UPDATE':
//case 'LINEFICHINTER_DELETE': //case 'LINEFICHINTER_DELETE':
// Members // Members
//case 'MEMBER_CREATE': //case 'MEMBER_CREATE':
//case 'MEMBER_VALIDATE': //case 'MEMBER_VALIDATE':
//case 'MEMBER_SUBSCRIPTION': //case 'MEMBER_SUBSCRIPTION':
//case 'MEMBER_MODIFY': //case 'MEMBER_MODIFY':
//case 'MEMBER_NEW_PASSWORD': //case 'MEMBER_NEW_PASSWORD':
//case 'MEMBER_RESILIATE': //case 'MEMBER_RESILIATE':
//case 'MEMBER_DELETE': //case 'MEMBER_DELETE':
// Categories // Categories
//case 'CATEGORY_CREATE': //case 'CATEGORY_CREATE':
//case 'CATEGORY_MODIFY': //case 'CATEGORY_MODIFY':
//case 'CATEGORY_DELETE': //case 'CATEGORY_DELETE':
//case 'CATEGORY_SET_MULTILANGS': //case 'CATEGORY_SET_MULTILANGS':
// Projects // Projects
//case 'PROJECT_CREATE': //case 'PROJECT_CREATE':
//case 'PROJECT_MODIFY': //case 'PROJECT_MODIFY':
//case 'PROJECT_DELETE': //case 'PROJECT_DELETE':
// Project tasks // Project tasks
//case 'TASK_CREATE': //case 'TASK_CREATE':
//case 'TASK_MODIFY': //case 'TASK_MODIFY':
//case 'TASK_DELETE': //case 'TASK_DELETE':
// Task time spent // Task time spent
//case 'TASK_TIMESPENT_CREATE': //case 'TASK_TIMESPENT_CREATE':
//case 'TASK_TIMESPENT_MODIFY': //case 'TASK_TIMESPENT_MODIFY':
//case 'TASK_TIMESPENT_DELETE': //case 'TASK_TIMESPENT_DELETE':
//case 'PROJECT_ADD_CONTACT': //case 'PROJECT_ADD_CONTACT':
//case 'PROJECT_DELETE_CONTACT': //case 'PROJECT_DELETE_CONTACT':
//case 'PROJECT_DELETE_RESOURCE': //case 'PROJECT_DELETE_RESOURCE':
// Shipping // Shipping
//case 'SHIPPING_CREATE': //case 'SHIPPING_CREATE':
//case 'SHIPPING_MODIFY': //case 'SHIPPING_MODIFY':
//case 'SHIPPING_VALIDATE': //case 'SHIPPING_VALIDATE':
//case 'SHIPPING_SENTBYMAIL': //case 'SHIPPING_SENTBYMAIL':
//case 'SHIPPING_BILLED': //case 'SHIPPING_BILLED':
//case 'SHIPPING_CLOSED': //case 'SHIPPING_CLOSED':
//case 'SHIPPING_REOPEN': //case 'SHIPPING_REOPEN':
//case 'SHIPPING_DELETE': //case 'SHIPPING_DELETE':
// and more... // and more...
default: default:
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
break; break;
} }
return 0; return 0;
} }
} }

View File

@@ -55,7 +55,7 @@ session_cache_limiter('public');
// Load user to have $user->conf loaded (not done by default here because of NOLOGIN constant defined) and load permission if we need to use them in CSS // Load user to have $user->conf loaded (not done by default here because of NOLOGIN constant defined) and load permission if we need to use them in CSS
/*if (empty($user->id) && ! empty($_SESSION['dol_login'])) /*if (empty($user->id) && ! empty($_SESSION['dol_login']))
{ {
$user->fetch('',$_SESSION['dol_login']); $user->fetch('',$_SESSION['dol_login']);
$user->getrights(); $user->getrights();
}*/ }*/
@@ -70,10 +70,10 @@ else header('Cache-Control: no-cache');
?> ?>
div.mainmenu.mymodule::before { div.mainmenu.mymodule::before {
content: "\f249"; content: "\f249";
} }
div.mainmenu.mymodule { div.mainmenu.mymodule {
background-image: none; background-image: none;
} }
.myclasscss { .myclasscss {

View File

@@ -88,7 +88,7 @@ if (! empty($conf->mymodule->enabled) && $user->rights->mymodule->read)
$langs->load("orders"); $langs->load("orders");
$sql = "SELECT c.rowid, c.ref, c.ref_client, c.total_ht, c.tva as total_tva, c.total_ttc, s.rowid as socid, s.nom as name, s.client, s.canvas"; $sql = "SELECT c.rowid, c.ref, c.ref_client, c.total_ht, c.tva as total_tva, c.total_ttc, s.rowid as socid, s.nom as name, s.client, s.canvas";
$sql.= ", s.code_client"; $sql.= ", s.code_client";
$sql.= " FROM ".MAIN_DB_PREFIX."commande as c"; $sql.= " FROM ".MAIN_DB_PREFIX."commande as c";
$sql.= ", ".MAIN_DB_PREFIX."societe as s"; $sql.= ", ".MAIN_DB_PREFIX."societe as s";
if (! $user->rights->societe->client->voir && ! $socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; if (! $user->rights->societe->client->voir && ! $socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
@@ -117,21 +117,21 @@ if (! empty($conf->mymodule->enabled) && $user->rights->mymodule->read)
$obj = $db->fetch_object($resql); $obj = $db->fetch_object($resql);
print '<tr class="oddeven"><td class="nowrap">'; print '<tr class="oddeven"><td class="nowrap">';
$orderstatic->id=$obj->rowid; $orderstatic->id=$obj->rowid;
$orderstatic->ref=$obj->ref; $orderstatic->ref=$obj->ref;
$orderstatic->ref_client=$obj->ref_client; $orderstatic->ref_client=$obj->ref_client;
$orderstatic->total_ht = $obj->total_ht; $orderstatic->total_ht = $obj->total_ht;
$orderstatic->total_tva = $obj->total_tva; $orderstatic->total_tva = $obj->total_tva;
$orderstatic->total_ttc = $obj->total_ttc; $orderstatic->total_ttc = $obj->total_ttc;
print $orderstatic->getNomUrl(1); print $orderstatic->getNomUrl(1);
print '</td>'; print '</td>';
print '<td class="nowrap">'; print '<td class="nowrap">';
$companystatic->id=$obj->socid; $companystatic->id=$obj->socid;
$companystatic->name=$obj->name; $companystatic->name=$obj->name;
$companystatic->client=$obj->client; $companystatic->client=$obj->client;
$companystatic->code_client = $obj->code_client; $companystatic->code_client = $obj->code_client;
$companystatic->code_fournisseur = $obj->code_fournisseur; $companystatic->code_fournisseur = $obj->code_fournisseur;
$companystatic->canvas=$obj->canvas; $companystatic->canvas=$obj->canvas;
print $companystatic->getNomUrl(1,'customer',16); print $companystatic->getNomUrl(1,'customer',16);
print '</td>'; print '</td>';
print '<td class="right" class="nowrap">'.price($obj->total_ttc).'</td></tr>'; print '<td class="right" class="nowrap">'.price($obj->total_ttc).'</td></tr>';
@@ -172,7 +172,7 @@ $max = 3;
if (! empty($conf->mymodule->enabled) && $user->rights->mymodule->read) if (! empty($conf->mymodule->enabled) && $user->rights->mymodule->read)
{ {
$sql = "SELECT s.rowid, s.nom as name, s.client, s.datec, s.tms, s.canvas"; $sql = "SELECT s.rowid, s.nom as name, s.client, s.datec, s.tms, s.canvas";
$sql.= ", s.code_client"; $sql.= ", s.code_client";
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s";
if (! $user->rights->societe->client->voir && ! $socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; if (! $user->rights->societe->client->voir && ! $socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql.= " WHERE s.client IN (1, 2, 3)"; $sql.= " WHERE s.client IN (1, 2, 3)";
@@ -192,7 +192,7 @@ if (! empty($conf->mymodule->enabled) && $user->rights->mymodule->read)
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print '<th colspan="2">'; print '<th colspan="2">';
if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) print $langs->trans("BoxTitleLastCustomersOrProspects",$max); if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) print $langs->trans("BoxTitleLastCustomersOrProspects",$max);
else if (! empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) print $langs->trans("BoxTitleLastModifiedProspects",$max); else if (! empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) print $langs->trans("BoxTitleLastModifiedProspects",$max);
else print $langs->trans("BoxTitleLastModifiedCustomers",$max); else print $langs->trans("BoxTitleLastModifiedCustomers",$max);
print '</th>'; print '</th>';
print '<th class="right">'.$langs->trans("DateModificationShort").'</th>'; print '<th class="right">'.$langs->trans("DateModificationShort").'</th>';
@@ -205,9 +205,9 @@ if (! empty($conf->mymodule->enabled) && $user->rights->mymodule->read)
$companystatic->id=$objp->rowid; $companystatic->id=$objp->rowid;
$companystatic->name=$objp->name; $companystatic->name=$objp->name;
$companystatic->client=$objp->client; $companystatic->client=$objp->client;
$companystatic->code_client = $objp->code_client; $companystatic->code_client = $objp->code_client;
$companystatic->code_fournisseur = $objp->code_fournisseur; $companystatic->code_fournisseur = $objp->code_fournisseur;
$companystatic->canvas=$objp->canvas; $companystatic->canvas=$objp->canvas;
print '<tr class="oddeven">'; print '<tr class="oddeven">';
print '<td class="nowrap">'.$companystatic->getNomUrl(1,'customer',48).'</td>'; print '<td class="nowrap">'.$companystatic->getNomUrl(1,'customer',48).'</td>';
print '<td class="right nowrap">'; print '<td class="right nowrap">';

View File

@@ -56,12 +56,12 @@ $backtopage = GETPOST('backtopage', 'alpha');
if (GETPOST('actioncode', 'array')) if (GETPOST('actioncode', 'array'))
{ {
$actioncode = GETPOST('actioncode', 'array', 3); $actioncode = GETPOST('actioncode', 'array', 3);
if (!count($actioncode)) $actioncode = '0'; if (!count($actioncode)) $actioncode = '0';
} }
else else
{ {
$actioncode = GETPOST("actioncode", "alpha", 3) ?GETPOST("actioncode", "alpha", 3) : (GETPOST("actioncode") == '0' ? '0' : (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT)); $actioncode = GETPOST("actioncode", "alpha", 3) ?GETPOST("actioncode", "alpha", 3) : (GETPOST("actioncode") == '0' ? '0' : (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT));
} }
$search_agenda_label = GETPOST('search_agenda_label'); $search_agenda_label = GETPOST('search_agenda_label');
@@ -106,19 +106,19 @@ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'e
if (empty($reshook)) if (empty($reshook))
{ {
// Cancel // Cancel
if (GETPOST('cancel', 'alpha') && !empty($backtopage)) if (GETPOST('cancel', 'alpha') && !empty($backtopage))
{ {
header("Location: ".$backtopage); header("Location: ".$backtopage);
exit; exit;
} }
// Purge search criteria // Purge search criteria
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers
{ {
$actioncode = ''; $actioncode = '';
$search_agenda_label = ''; $search_agenda_label = '';
} }
} }
@@ -161,40 +161,40 @@ if ($object->id > 0)
if ($permissiontoadd) if ($permissiontoadd)
{ {
if ($action != 'classify') if ($action != 'classify')
//$morehtmlref.='<a class="editfielda" href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : '; //$morehtmlref.='<a class="editfielda" href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : ';
$morehtmlref.=' : '; $morehtmlref.=' : ';
if ($action == 'classify') { if ($action == 'classify') {
//$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
$morehtmlref.='<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">'; $morehtmlref.='<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
$morehtmlref.='<input type="hidden" name="action" value="classin">'; $morehtmlref.='<input type="hidden" name="action" value="classin">';
$morehtmlref.='<input type="hidden" name="token" value="'.newToken().'">'; $morehtmlref.='<input type="hidden" name="token" value="'.newToken().'">';
$morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
$morehtmlref.='<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">'; $morehtmlref.='<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
$morehtmlref.='</form>'; $morehtmlref.='</form>';
} else { } else {
$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
} }
} else { } else {
if (! empty($object->fk_project)) { if (! empty($object->fk_project)) {
$proj = new Project($db); $proj = new Project($db);
$proj->fetch($object->fk_project); $proj->fetch($object->fk_project);
$morehtmlref.='<a href="'.DOL_URL_ROOT.'/projet/card.php?id=' . $object->fk_project . '" title="' . $langs->trans('ShowProject') . '">'; $morehtmlref.='<a href="'.DOL_URL_ROOT.'/projet/card.php?id=' . $object->fk_project . '" title="' . $langs->trans('ShowProject') . '">';
$morehtmlref.=$proj->ref; $morehtmlref.=$proj->ref;
$morehtmlref.='</a>'; $morehtmlref.='</a>';
} else { } else {
$morehtmlref.=''; $morehtmlref.='';
} }
} }
}*/ }*/
$morehtmlref .= '</div>'; $morehtmlref .= '</div>';
dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
print '<div class="fichecenter">'; print '<div class="fichecenter">';
print '<div class="underbanner clearboth"></div>'; print '<div class="underbanner clearboth"></div>';
$object->info($object->id); $object->info($object->id);
dol_print_object_info($object, 1); dol_print_object_info($object, 1);
print '</div>'; print '</div>';
@@ -205,54 +205,54 @@ if ($object->id > 0)
// Actions buttons // Actions buttons
$objthirdparty = $object; $objthirdparty = $object;
$objcon = new stdClass(); $objcon = new stdClass();
$out = '&origin='.$object->element.'&originid='.$object->id; $out = '&origin='.$object->element.'&originid='.$object->id;
$permok = $user->rights->agenda->myactions->create; $permok = $user->rights->agenda->myactions->create;
if ((!empty($objthirdparty->id) || !empty($objcon->id)) && $permok) if ((!empty($objthirdparty->id) || !empty($objcon->id)) && $permok)
{ {
//$out.='<a href="'.DOL_URL_ROOT.'/comm/action/card.php?action=create'; //$out.='<a href="'.DOL_URL_ROOT.'/comm/action/card.php?action=create';
if (get_class($objthirdparty) == 'Societe') $out .= '&amp;socid='.$objthirdparty->id; if (get_class($objthirdparty) == 'Societe') $out .= '&amp;socid='.$objthirdparty->id;
$out .= (!empty($objcon->id) ? '&amp;contactid='.$objcon->id : '').'&amp;backtopage=1&amp;percentage=-1'; $out .= (!empty($objcon->id) ? '&amp;contactid='.$objcon->id : '').'&amp;backtopage=1&amp;percentage=-1';
//$out.=$langs->trans("AddAnAction").' '; //$out.=$langs->trans("AddAnAction").' ';
//$out.=img_picto($langs->trans("AddAnAction"),'filenew'); //$out.=img_picto($langs->trans("AddAnAction"),'filenew');
//$out.="</a>"; //$out.="</a>";
} }
print '<div class="tabsAction">'; print '<div class="tabsAction">';
if (!empty($conf->agenda->enabled)) if (!empty($conf->agenda->enabled))
{ {
if (!empty($user->rights->agenda->myactions->create) || !empty($user->rights->agenda->allactions->create)) if (!empty($user->rights->agenda->myactions->create) || !empty($user->rights->agenda->allactions->create))
{ {
print '<a class="butAction" href="'.DOL_URL_ROOT.'/comm/action/card.php?action=create'.$out.'">'.$langs->trans("AddAction").'</a>'; print '<a class="butAction" href="'.DOL_URL_ROOT.'/comm/action/card.php?action=create'.$out.'">'.$langs->trans("AddAction").'</a>';
} }
else else
{ {
print '<a class="butActionRefused classfortooltip" href="#">'.$langs->trans("AddAction").'</a>'; print '<a class="butActionRefused classfortooltip" href="#">'.$langs->trans("AddAction").'</a>';
} }
} }
print '</div>'; print '</div>';
if (!empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read))) if (!empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read)))
{ {
$param = '&id='.$object->id.'&socid='.$socid; $param = '&id='.$object->id.'&socid='.$socid;
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage);
if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit);
//print load_fiche_titre($langs->trans("ActionsOnMyObject"), '', ''); //print load_fiche_titre($langs->trans("ActionsOnMyObject"), '', '');
// List of all actions // List of all actions
$filters = array(); $filters = array();
$filters['search_agenda_label'] = $search_agenda_label; $filters['search_agenda_label'] = $search_agenda_label;
// TODO Replace this with same code than into list.php // TODO Replace this with same code than into list.php
show_actions_done($conf, $langs, $db, $object, null, 0, $actioncode, '', $filters, $sortfield, $sortorder); show_actions_done($conf, $langs, $db, $object, null, 0, $actioncode, '', $filters, $sortfield, $sortorder);
} }
} }
// End of page // End of page

View File

@@ -127,47 +127,47 @@ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'e
if (empty($reshook)) if (empty($reshook))
{ {
$error = 0; $error = 0;
$backurlforlist = dol_buildpath('/mymodule/myobject_list.php', 1); $backurlforlist = dol_buildpath('/mymodule/myobject_list.php', 1);
if (empty($backtopage) || ($cancel && empty($id))) { if (empty($backtopage) || ($cancel && empty($id))) {
if (empty($backtopage) || ($cancel && strpos($backtopage, '__ID__'))) { if (empty($backtopage) || ($cancel && strpos($backtopage, '__ID__'))) {
if (empty($id) && (($action != 'add' && $action != 'create') || $cancel)) $backtopage = $backurlforlist; if (empty($id) && (($action != 'add' && $action != 'create') || $cancel)) $backtopage = $backurlforlist;
else $backtopage = dol_buildpath('/mymodule/myobject_card.php', 1).'?id='.($id > 0 ? $id : '__ID__'); else $backtopage = dol_buildpath('/mymodule/myobject_card.php', 1).'?id='.($id > 0 ? $id : '__ID__');
} }
} }
$triggermodname = 'MYMODULE_MYOBJECT_MODIFY'; // Name of trigger action code to execute when we modify record $triggermodname = 'MYMODULE_MYOBJECT_MODIFY'; // Name of trigger action code to execute when we modify record
// Actions cancel, add, update, update_extras, confirm_validate, confirm_delete, confirm_deleteline, confirm_clone, confirm_close, confirm_setdraft, confirm_reopen // Actions cancel, add, update, update_extras, confirm_validate, confirm_delete, confirm_deleteline, confirm_clone, confirm_close, confirm_setdraft, confirm_reopen
include DOL_DOCUMENT_ROOT.'/core/actions_addupdatedelete.inc.php'; include DOL_DOCUMENT_ROOT.'/core/actions_addupdatedelete.inc.php';
// Actions when linking object each other // Actions when linking object each other
include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php'; include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php';
// Actions when printing a doc from card // Actions when printing a doc from card
include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php'; include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php';
// Action to move up and down lines of object // Action to move up and down lines of object
//include DOL_DOCUMENT_ROOT.'/core/actions_lineupdown.inc.php'; //include DOL_DOCUMENT_ROOT.'/core/actions_lineupdown.inc.php';
// Action to build doc // Action to build doc
include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php'; include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php';
if ($action == 'set_thirdparty' && $permissiontoadd) if ($action == 'set_thirdparty' && $permissiontoadd)
{ {
$object->setValueFrom('fk_soc', GETPOST('fk_soc', 'int'), '', '', 'date', '', $user, 'MYOBJECT_MODIFY'); $object->setValueFrom('fk_soc', GETPOST('fk_soc', 'int'), '', '', 'date', '', $user, 'MYOBJECT_MODIFY');
} }
if ($action == 'classin' && $permissiontoadd) if ($action == 'classin' && $permissiontoadd)
{ {
$object->setProject(GETPOST('projectid', 'int')); $object->setProject(GETPOST('projectid', 'int'));
} }
// Actions to send emails // Actions to send emails
$triggersendname = 'MYOBJECT_SENTBYMAIL'; $triggersendname = 'MYOBJECT_SENTBYMAIL';
$autocopy = 'MAIN_MAIL_AUTOCOPY_MYOBJECT_TO'; $autocopy = 'MAIN_MAIL_AUTOCOPY_MYOBJECT_TO';
$trackid = 'myobject'.$object->id; $trackid = 'myobject'.$object->id;
include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php'; include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php';
} }
@@ -244,7 +244,7 @@ if (($id || $ref) && $action == 'edit')
print load_fiche_titre($langs->trans("MyObject")); print load_fiche_titre($langs->trans("MyObject"));
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">'; print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
print '<input type="hidden" name="token" value="'.newToken().'">'; print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="action" value="update">'; print '<input type="hidden" name="action" value="update">';
print '<input type="hidden" name="id" value="'.$object->id.'">'; print '<input type="hidden" name="id" value="'.$object->id.'">';
if ($backtopage) print '<input type="hidden" name="backtopage" value="'.$backtopage.'">'; if ($backtopage) print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
@@ -274,7 +274,7 @@ if (($id || $ref) && $action == 'edit')
// Part to show record // Part to show record
if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create'))) if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create')))
{ {
$res = $object->fetch_optionals(); $res = $object->fetch_optionals();
$head = myobjectPrepareHead($object); $head = myobjectPrepareHead($object);
dol_fiche_head($head, 'card', $langs->trans("MyObject"), -1, $object->picto); dol_fiche_head($head, 'card', $langs->trans("MyObject"), -1, $object->picto);
@@ -284,7 +284,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
// Confirmation to delete // Confirmation to delete
if ($action == 'delete') if ($action == 'delete')
{ {
$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteMyObject'), $langs->trans('ConfirmDeleteObject'), 'confirm_delete', '', 0, 1); $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteMyObject'), $langs->trans('ConfirmDeleteObject'), 'confirm_delete', '', 0, 1);
} }
// Confirmation to delete line // Confirmation to delete line
if ($action == 'deleteline') if ($action == 'deleteline')
@@ -302,17 +302,17 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
if ($action == 'xxx') if ($action == 'xxx')
{ {
$formquestion = array(); $formquestion = array();
/* /*
$forcecombo=0; $forcecombo=0;
if ($conf->browser->name == 'ie') $forcecombo = 1; // There is a bug in IE10 that make combo inside popup crazy if ($conf->browser->name == 'ie') $forcecombo = 1; // There is a bug in IE10 that make combo inside popup crazy
$formquestion = array( $formquestion = array(
// 'text' => $langs->trans("ConfirmClone"), // 'text' => $langs->trans("ConfirmClone"),
// array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1), // array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1),
// array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"), 'value' => 1), // array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"), 'value' => 1),
// array('type' => 'other', 'name' => 'idwarehouse', 'label' => $langs->trans("SelectWarehouseForStockDecrease"), 'value' => $formproduct->selectWarehouses(GETPOST('idwarehouse')?GETPOST('idwarehouse'):'ifone', 'idwarehouse', '', 1, 0, 0, '', 0, $forcecombo)) // array('type' => 'other', 'name' => 'idwarehouse', 'label' => $langs->trans("SelectWarehouseForStockDecrease"), 'value' => $formproduct->selectWarehouses(GETPOST('idwarehouse')?GETPOST('idwarehouse'):'ifone', 'idwarehouse', '', 1, 0, 0, '', 0, $forcecombo))
); );
*/ */
$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('XXX'), $text, 'confirm_xxx', $formquestion, 0, 1, 220); $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('XXX'), $text, 'confirm_xxx', $formquestion, 0, 1, 220);
} }
// Call Hook formConfirm // Call Hook formConfirm
@@ -339,32 +339,32 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
// Project // Project
if (! empty($conf->projet->enabled)) if (! empty($conf->projet->enabled))
{ {
$langs->load("projects"); $langs->load("projects");
$morehtmlref.='<br>'.$langs->trans('Project') . ' '; $morehtmlref.='<br>'.$langs->trans('Project') . ' ';
if ($permissiontoadd) if ($permissiontoadd)
{ {
if ($action != 'classify') if ($action != 'classify')
$morehtmlref.='<a class="editfielda" href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : '; $morehtmlref.='<a class="editfielda" href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : ';
if ($action == 'classify') { if ($action == 'classify') {
//$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
$morehtmlref.='<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">'; $morehtmlref.='<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
$morehtmlref.='<input type="hidden" name="action" value="classin">'; $morehtmlref.='<input type="hidden" name="action" value="classin">';
$morehtmlref.='<input type="hidden" name="token" value="'.newToken().'">'; $morehtmlref.='<input type="hidden" name="token" value="'.newToken().'">';
$morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', 0, 0, 1, 0, 1, 0, 0, '', 1); $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', 0, 0, 1, 0, 1, 0, 0, '', 1);
$morehtmlref.='<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">'; $morehtmlref.='<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
$morehtmlref.='</form>'; $morehtmlref.='</form>';
} else { } else {
$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
} }
} else { } else {
if (! empty($object->fk_project)) { if (! empty($object->fk_project)) {
$proj = new Project($db); $proj = new Project($db);
$proj->fetch($object->fk_project); $proj->fetch($object->fk_project);
$morehtmlref.=$proj->getNomUrl(); $morehtmlref.=$proj->getNomUrl();
} else { } else {
$morehtmlref.=''; $morehtmlref.='';
} }
} }
} }
*/ */
$morehtmlref .= '</div>'; $morehtmlref .= '</div>';
@@ -402,147 +402,147 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
if (!empty($object->table_element_line)) if (!empty($object->table_element_line))
{ {
// Show object lines // Show object lines
$result = $object->getLinesArray(); $result = $object->getLinesArray();
print ' <form name="addproduct" id="addproduct" action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.(($action != 'editline') ? '#addline' : '#line_'.GETPOST('lineid', 'int')).'" method="POST"> print ' <form name="addproduct" id="addproduct" action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.(($action != 'editline') ? '#addline' : '#line_'.GETPOST('lineid', 'int')).'" method="POST">
<input type="hidden" name="token" value="' . newToken().'"> <input type="hidden" name="token" value="' . newToken().'">
<input type="hidden" name="action" value="' . (($action != 'editline') ? 'addline' : 'updateline').'"> <input type="hidden" name="action" value="' . (($action != 'editline') ? 'addline' : 'updateline').'">
<input type="hidden" name="mode" value=""> <input type="hidden" name="mode" value="">
<input type="hidden" name="id" value="' . $object->id.'"> <input type="hidden" name="id" value="' . $object->id.'">
'; ';
if (!empty($conf->use_javascript_ajax) && $object->status == 0) { if (!empty($conf->use_javascript_ajax) && $object->status == 0) {
include DOL_DOCUMENT_ROOT.'/core/tpl/ajaxrow.tpl.php'; include DOL_DOCUMENT_ROOT.'/core/tpl/ajaxrow.tpl.php';
} }
print '<div class="div-table-responsive-no-min">'; print '<div class="div-table-responsive-no-min">';
if (!empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action != 'selectlines' && $action != 'editline')) if (!empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action != 'selectlines' && $action != 'editline'))
{ {
print '<table id="tablelines" class="noborder noshadow" width="100%">'; print '<table id="tablelines" class="noborder noshadow" width="100%">';
} }
if (!empty($object->lines)) if (!empty($object->lines))
{ {
$object->printObjectLines($action, $mysoc, null, GETPOST('lineid', 'int'), 1); $object->printObjectLines($action, $mysoc, null, GETPOST('lineid', 'int'), 1);
} }
// Form to add new line // Form to add new line
if ($object->status == 0 && $permissiontoadd && $action != 'selectlines') if ($object->status == 0 && $permissiontoadd && $action != 'selectlines')
{ {
if ($action != 'editline') if ($action != 'editline')
{ {
// Add products/services form // Add products/services form
$object->formAddObjectLine(1, $mysoc, $soc); $object->formAddObjectLine(1, $mysoc, $soc);
$parameters = array(); $parameters = array();
$reshook = $hookmanager->executeHooks('formAddObjectLine', $parameters, $object, $action); // Note that $action and $object may have been modified by hook $reshook = $hookmanager->executeHooks('formAddObjectLine', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
} }
} }
if (!empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action != 'selectlines' && $action != 'editline')) if (!empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action != 'selectlines' && $action != 'editline'))
{ {
print '</table>'; print '</table>';
} }
print '</div>'; print '</div>';
print "</form>\n"; print "</form>\n";
} }
// Buttons for actions // Buttons for actions
if ($action != 'presend' && $action != 'editline') { if ($action != 'presend' && $action != 'editline') {
print '<div class="tabsAction">'."\n"; print '<div class="tabsAction">'."\n";
$parameters = array(); $parameters = array();
$reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
if (empty($reshook)) if (empty($reshook))
{ {
// Send // Send
if (empty($user->socid)) { if (empty($user->socid)) {
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=presend&mode=init#formmailbeforetitle">'.$langs->trans('SendMail').'</a>'."\n"; print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=presend&mode=init#formmailbeforetitle">'.$langs->trans('SendMail').'</a>'."\n";
} }
// Back to draft // Back to draft
if ($object->status == $object::STATUS_VALIDATED) if ($object->status == $object::STATUS_VALIDATED)
{ {
if ($permissiontoadd) if ($permissiontoadd)
{ {
print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=confirm_setdraft&confirm=yes">'.$langs->trans("SetToDraft").'</a>'; print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=confirm_setdraft&confirm=yes">'.$langs->trans("SetToDraft").'</a>';
} }
} }
// Modify // Modify
if ($permissiontoadd) if ($permissiontoadd)
{ {
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=edit">'.$langs->trans("Modify").'</a>'."\n"; print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=edit">'.$langs->trans("Modify").'</a>'."\n";
} }
else else
{ {
print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("NotEnoughPermissions")).'">'.$langs->trans('Modify').'</a>'."\n"; print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("NotEnoughPermissions")).'">'.$langs->trans('Modify').'</a>'."\n";
} }
// Validate // Validate
if ($object->status == $object::STATUS_DRAFT) if ($object->status == $object::STATUS_DRAFT)
{ {
if ($permissiontoadd) if ($permissiontoadd)
{ {
if (empty($object->table_element_line) || (is_array($object->lines) && count($object->lines) > 0)) if (empty($object->table_element_line) || (is_array($object->lines) && count($object->lines) > 0))
{ {
print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=confirm_validate&confirm=yes">'.$langs->trans("Validate").'</a>'; print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=confirm_validate&confirm=yes">'.$langs->trans("Validate").'</a>';
} }
else else
{ {
$langs->load("errors"); $langs->load("errors");
print '<a class="butActionRefused" href="" title="'.$langs->trans("ErrorAddAtLeastOneLineFirst").'">'.$langs->trans("Validate").'</a>'; print '<a class="butActionRefused" href="" title="'.$langs->trans("ErrorAddAtLeastOneLineFirst").'">'.$langs->trans("Validate").'</a>';
} }
} }
} }
// Clone // Clone
if ($permissiontoadd) if ($permissiontoadd)
{ {
print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&socid='.$object->socid.'&action=clone&object=myobject">'.$langs->trans("ToClone").'</a>'."\n"; print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&socid='.$object->socid.'&action=clone&object=myobject">'.$langs->trans("ToClone").'</a>'."\n";
} }
/* /*
if ($permissiontoadd) if ($permissiontoadd)
{ {
if ($object->status == $object::STATUS_ENABLED) if ($object->status == $object::STATUS_ENABLED)
{ {
print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=disable">'.$langs->trans("Disable").'</a>'."\n"; print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=disable">'.$langs->trans("Disable").'</a>'."\n";
} }
else else
{ {
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=enable">'.$langs->trans("Enable").'</a>'."\n"; print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=enable">'.$langs->trans("Enable").'</a>'."\n";
} }
} }
if ($permissiontoadd) if ($permissiontoadd)
{ {
if ($object->status == $object::STATUS_VALIDATED) if ($object->status == $object::STATUS_VALIDATED)
{ {
print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=close">'.$langs->trans("Cancel").'</a>'."\n"; print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=close">'.$langs->trans("Cancel").'</a>'."\n";
} }
else else
{ {
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=reopen">'.$langs->trans("Re-Open").'</a>'."\n"; print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=reopen">'.$langs->trans("Re-Open").'</a>'."\n";
} }
} }
*/ */
// Delete (need delete permission, or if draft, just need create/modify permission) // Delete (need delete permission, or if draft, just need create/modify permission)
if ($permissiontodelete) if ($permissiontodelete)
{ {
print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=delete">'.$langs->trans('Delete').'</a>'."\n"; print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=delete">'.$langs->trans('Delete').'</a>'."\n";
} }
else else
{ {
print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("NotEnoughPermissions")).'">'.$langs->trans('Delete').'</a>'."\n"; print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("NotEnoughPermissions")).'">'.$langs->trans('Delete').'</a>'."\n";
} }
} }
print '</div>'."\n"; print '</div>'."\n";
} }
@@ -553,38 +553,38 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
if ($action != 'presend') if ($action != 'presend')
{ {
print '<div class="fichecenter"><div class="fichehalfleft">'; print '<div class="fichecenter"><div class="fichehalfleft">';
print '<a name="builddoc"></a>'; // ancre print '<a name="builddoc"></a>'; // ancre
// Documents // Documents
/*$objref = dol_sanitizeFileName($object->ref); /*$objref = dol_sanitizeFileName($object->ref);
$relativepath = $objref . '/' . $objref . '.pdf'; $relativepath = $objref . '/' . $objref . '.pdf';
$filedir = $conf->mymodule->dir_output . '/' . $objref; $filedir = $conf->mymodule->dir_output . '/' . $objref;
$urlsource = $_SERVER["PHP_SELF"] . "?id=" . $object->id; $urlsource = $_SERVER["PHP_SELF"] . "?id=" . $object->id;
$genallowed = $user->rights->mymodule->myobject->read; // If you can read, you can build the PDF to read content $genallowed = $user->rights->mymodule->myobject->read; // If you can read, you can build the PDF to read content
$delallowed = $user->rights->mymodule->myobject->create; // If you can create/edit, you can remove a file on card $delallowed = $user->rights->mymodule->myobject->create; // If you can create/edit, you can remove a file on card
print $formfile->showdocuments('mymodule', $objref, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 1, 0, 0, 28, 0, '', '', '', $langs->defaultlang); print $formfile->showdocuments('mymodule', $objref, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 1, 0, 0, 28, 0, '', '', '', $langs->defaultlang);
*/ */
// Show links to link elements // Show links to link elements
$linktoelem = $form->showLinkToObjectBlock($object, null, array('myobject')); $linktoelem = $form->showLinkToObjectBlock($object, null, array('myobject'));
$somethingshown = $form->showLinkedObjectBlock($object, $linktoelem); $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem);
print '</div><div class="fichehalfright"><div class="ficheaddleft">'; print '</div><div class="fichehalfright"><div class="ficheaddleft">';
$MAXEVENT = 10; $MAXEVENT = 10;
$morehtmlright = '<a href="'.dol_buildpath('/mymodule/myobject_agenda.php', 1).'?id='.$object->id.'">'; $morehtmlright = '<a href="'.dol_buildpath('/mymodule/myobject_agenda.php', 1).'?id='.$object->id.'">';
$morehtmlright .= $langs->trans("SeeAll"); $morehtmlright .= $langs->trans("SeeAll");
$morehtmlright .= '</a>'; $morehtmlright .= '</a>';
// List of actions on element // List of actions on element
include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'; include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php';
$formactions = new FormActions($db); $formactions = new FormActions($db);
$somethingshown = $formactions->showactions($object, $object->element, (is_object($object->thirdparty) ? $object->thirdparty->id : 0), 1, '', $MAXEVENT, '', $morehtmlright); $somethingshown = $formactions->showactions($object, $object->element, (is_object($object->thirdparty) ? $object->thirdparty->id : 0), 1, '', $MAXEVENT, '', $morehtmlright);
print '</div></div></div>'; print '</div></div></div>';
} }
//Select mail models is same action as presend //Select mail models is same action as presend

View File

@@ -131,9 +131,9 @@ if ($object->id)
dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
print '<div class="fichecenter">'; print '<div class="fichecenter">';
print '<div class="underbanner clearboth"></div>'; print '<div class="underbanner clearboth"></div>';
print '<table class="border centpercent tableforfield">'; print '<table class="border centpercent tableforfield">';
// Number of files // Number of files

View File

@@ -344,8 +344,8 @@ if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&co
if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit);
foreach ($search as $key => $val) foreach ($search as $key => $val)
{ {
if (is_array($search[$key]) && count($search[$key])) foreach ($search[$key] as $skey) $param .= '&search_'.$key.'[]='.urlencode($skey); if (is_array($search[$key]) && count($search[$key])) foreach ($search[$key] as $skey) $param .= '&search_'.$key.'[]='.urlencode($skey);
else $param .= '&search_'.$key.'='.urlencode($search[$key]); else $param .= '&search_'.$key.'='.urlencode($search[$key]);
} }
if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss); if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss);
// Add $param from extra fields // Add $param from extra fields
@@ -353,10 +353,10 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
// List of mass actions available // List of mass actions available
$arrayofmassactions = array( $arrayofmassactions = array(
//'validate'=>$langs->trans("Validate"), //'validate'=>$langs->trans("Validate"),
//'generate_doc'=>$langs->trans("ReGeneratePDF"), //'generate_doc'=>$langs->trans("ReGeneratePDF"),
//'builddoc'=>$langs->trans("PDFMerge"), //'builddoc'=>$langs->trans("PDFMerge"),
//'presend'=>$langs->trans("SendByMail"), //'presend'=>$langs->trans("SendByMail"),
); );
if ($permissiontodelete) $arrayofmassactions['predelete'] = '<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete"); if ($permissiontodelete) $arrayofmassactions['predelete'] = '<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete");
if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array(); if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array();
@@ -504,16 +504,16 @@ while ($i < ($limit ? min($num, $limit) : $num))
foreach ($object->fields as $key => $val) foreach ($object->fields as $key => $val)
{ {
$cssforfield = (empty($val['css']) ? '' : $val['css']); $cssforfield = (empty($val['css']) ? '' : $val['css']);
if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'center'; if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'center';
elseif ($key == 'status') $cssforfield .= ($cssforfield ? ' ' : '').'center'; elseif ($key == 'status') $cssforfield .= ($cssforfield ? ' ' : '').'center';
if (in_array($val['type'], array('timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; if (in_array($val['type'], array('timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
elseif ($key == 'ref') $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; elseif ($key == 'ref') $cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $key != 'status') $cssforfield .= ($cssforfield ? ' ' : '').'right'; if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $key != 'status') $cssforfield .= ($cssforfield ? ' ' : '').'right';
//if (in_array($key, array('fk_soc', 'fk_user', 'fk_warehouse'))) $cssforfield = 'tdoverflowmax100'; //if (in_array($key, array('fk_soc', 'fk_user', 'fk_warehouse'))) $cssforfield = 'tdoverflowmax100';
if (!empty($arrayfields['t.'.$key]['checked'])) if (!empty($arrayfields['t.'.$key]['checked']))
{ {
print '<td'.($cssforfield ? ' class="'.$cssforfield.'"' : '').'>'; print '<td'.($cssforfield ? ' class="'.$cssforfield.'"' : '').'>';
if ($key == 'status') print $object->getLibStatut(5); if ($key == 'status') print $object->getLibStatut(5);

View File

@@ -111,35 +111,35 @@ if ($id > 0 || !empty($ref))
// Project // Project
if (! empty($conf->projet->enabled)) if (! empty($conf->projet->enabled))
{ {
$langs->load("projects"); $langs->load("projects");
$morehtmlref.='<br>'.$langs->trans('Project') . ' '; $morehtmlref.='<br>'.$langs->trans('Project') . ' ';
if ($permissiontoadd) if ($permissiontoadd)
{ {
if ($action != 'classify') if ($action != 'classify')
//$morehtmlref.='<a class="editfielda" href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : '; //$morehtmlref.='<a class="editfielda" href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : ';
$morehtmlref.=' : '; $morehtmlref.=' : ';
if ($action == 'classify') { if ($action == 'classify') {
//$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
$morehtmlref.='<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">'; $morehtmlref.='<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
$morehtmlref.='<input type="hidden" name="action" value="classin">'; $morehtmlref.='<input type="hidden" name="action" value="classin">';
$morehtmlref.='<input type="hidden" name="token" value="'.newToken().'">'; $morehtmlref.='<input type="hidden" name="token" value="'.newToken().'">';
$morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
$morehtmlref.='<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">'; $morehtmlref.='<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
$morehtmlref.='</form>'; $morehtmlref.='</form>';
} else { } else {
$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
} }
} else { } else {
if (! empty($object->fk_project)) { if (! empty($object->fk_project)) {
$proj = new Project($db); $proj = new Project($db);
$proj->fetch($object->fk_project); $proj->fetch($object->fk_project);
$morehtmlref.='<a href="'.DOL_URL_ROOT.'/projet/card.php?id=' . $object->fk_project . '" title="' . $langs->trans('ShowProject') . '">'; $morehtmlref.='<a href="'.DOL_URL_ROOT.'/projet/card.php?id=' . $object->fk_project . '" title="' . $langs->trans('ShowProject') . '">';
$morehtmlref.=$proj->ref; $morehtmlref.=$proj->ref;
$morehtmlref.='</a>'; $morehtmlref.='</a>';
} else { } else {
$morehtmlref.=''; $morehtmlref.='';
} }
} }
}*/ }*/
$morehtmlref .= '</div>'; $morehtmlref .= '</div>';

View File

@@ -29,7 +29,7 @@ $path = __DIR__.'/';
// Test if batch mode // Test if batch mode
if (substr($sapi_type, 0, 3) == 'cgi') { 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); exit(-1);
} }
@@ -68,7 +68,7 @@ $user->getrights();
print "***** ".$script_file." (".$version.") pid=".dol_getmypid()." *****\n"; print "***** ".$script_file." (".$version.") pid=".dol_getmypid()." *****\n";
if (!isset($argv[1])) { // Check parameters if (!isset($argv[1])) { // Check parameters
print "Usage: ".$script_file." param1 param2 ...\n"; print "Usage: ".$script_file." param1 param2 ...\n";
exit(-1); exit(-1);
} }
print '--- start'."\n"; print '--- start'."\n";

View File

@@ -69,14 +69,14 @@ class MyModuleFunctionalTest extends \PHPUnit_Extensions_Selenium2TestCase
), ),
// Geckodriver does not keep the session at the moment?! // Geckodriver does not keep the session at the moment?!
// XPath selectors also don't seem to work // XPath selectors also don't seem to work
//array( //array(
// 'browser' => 'Mozilla Firefox on Linux', // 'browser' => 'Mozilla Firefox on Linux',
// 'browserName' => 'firefox', // 'browserName' => 'firefox',
// 'sessionStrategy' => 'shared', // 'sessionStrategy' => 'shared',
// 'desiredCapabilities' => array( // 'desiredCapabilities' => array(
// 'marionette' => true, // 'marionette' => true,
// ), // ),
//) //)
); );
/** /**
@@ -99,7 +99,7 @@ class MyModuleFunctionalTest extends \PHPUnit_Extensions_Selenium2TestCase
/** /**
* Global test setup * Global test setup
* @return void * @return void
*/ */
public static function setUpBeforeClass() public static function setUpBeforeClass()
{ {
@@ -107,7 +107,7 @@ class MyModuleFunctionalTest extends \PHPUnit_Extensions_Selenium2TestCase
/** /**
* Unit test setup * Unit test setup
* @return void * @return void
*/ */
public function setUp() public function setUp()
{ {
@@ -117,7 +117,7 @@ class MyModuleFunctionalTest extends \PHPUnit_Extensions_Selenium2TestCase
/** /**
* Verify pre conditions * Verify pre conditions
* @return void * @return void
*/ */
protected function assertPreConditions() protected function assertPreConditions()
{ {
@@ -125,7 +125,7 @@ class MyModuleFunctionalTest extends \PHPUnit_Extensions_Selenium2TestCase
/** /**
* Handle Dolibarr authentication * Handle Dolibarr authentication
* @return void * @return void
*/ */
private function authenticate() private function authenticate()
{ {
@@ -146,7 +146,7 @@ class MyModuleFunctionalTest extends \PHPUnit_Extensions_Selenium2TestCase
/** /**
* Test enabling developer mode * Test enabling developer mode
* @return bool * @return bool
*/ */
public function testEnableDeveloperMode() public function testEnableDeveloperMode()
{ {
@@ -166,7 +166,7 @@ class MyModuleFunctionalTest extends \PHPUnit_Extensions_Selenium2TestCase
* Test enabling the module * Test enabling the module
* *
* @depends testEnableDeveloperMode * @depends testEnableDeveloperMode
* @return bool * @return bool
*/ */
public function testModuleEnabled() public function testModuleEnabled()
{ {
@@ -192,7 +192,7 @@ class MyModuleFunctionalTest extends \PHPUnit_Extensions_Selenium2TestCase
* Test access to the configuration page * Test access to the configuration page
* *
* @depends testModuleEnabled * @depends testModuleEnabled
* @return bool * @return bool
*/ */
public function testConfigurationPage() public function testConfigurationPage()
{ {
@@ -205,7 +205,7 @@ class MyModuleFunctionalTest extends \PHPUnit_Extensions_Selenium2TestCase
* Test access to the about page * Test access to the about page
* *
* @depends testConfigurationPage * @depends testConfigurationPage
* @return bool * @return bool
*/ */
public function testAboutPage() public function testAboutPage()
{ {
@@ -218,13 +218,13 @@ class MyModuleFunctionalTest extends \PHPUnit_Extensions_Selenium2TestCase
* Test about page is rendering Markdown * Test about page is rendering Markdown
* *
* @depends testAboutPage * @depends testAboutPage
* @return bool * @return bool
*/ */
public function testAboutPageRendersMarkdownReadme() public function testAboutPageRendersMarkdownReadme()
{ {
$this->url('/custom/mymodule/admin/about.php'); $this->url('/custom/mymodule/admin/about.php');
$this->authenticate(); $this->authenticate();
return $this->assertEquals( return $this->assertEquals(
'Dolibarr Module Template (aka My Module)', 'Dolibarr Module Template (aka My Module)',
$this->byTag('h1')->text(), $this->byTag('h1')->text(),
"Readme title" "Readme title"
@@ -235,7 +235,7 @@ class MyModuleFunctionalTest extends \PHPUnit_Extensions_Selenium2TestCase
* Test box is properly declared * Test box is properly declared
* *
* @depends testModuleEnabled * @depends testModuleEnabled
* @return bool * @return bool
*/ */
public function testBoxDeclared() public function testBoxDeclared()
{ {
@@ -248,13 +248,13 @@ class MyModuleFunctionalTest extends \PHPUnit_Extensions_Selenium2TestCase
* Test trigger is properly enabled * Test trigger is properly enabled
* *
* @depends testModuleEnabled * @depends testModuleEnabled
* @return bool * @return bool
*/ */
public function testTriggerDeclared() public function testTriggerDeclared()
{ {
$this->url('/admin/triggers.php'); $this->url('/admin/triggers.php');
$this->authenticate(); $this->authenticate();
return $this->assertContains( return $this->assertContains(
'interface_99_modMyModule_MyModuleTriggers.class.php', 'interface_99_modMyModule_MyModuleTriggers.class.php',
$this->byTag('body')->text(), $this->byTag('body')->text(),
"Trigger declared" "Trigger declared"
@@ -265,13 +265,13 @@ class MyModuleFunctionalTest extends \PHPUnit_Extensions_Selenium2TestCase
* Test trigger is properly declared * Test trigger is properly declared
* *
* @depends testTriggerDeclared * @depends testTriggerDeclared
* @return bool * @return bool
*/ */
public function testTriggerEnabled() public function testTriggerEnabled()
{ {
$this->url('/admin/triggers.php'); $this->url('/admin/triggers.php');
$this->authenticate(); $this->authenticate();
return $this->assertContains( return $this->assertContains(
'tick.png', 'tick.png',
$this->byXPath('//td[text()="interface_99_modMyModule_MyTrigger.class.php"]/following::img')->attribute('src'), $this->byXPath('//td[text()="interface_99_modMyModule_MyTrigger.class.php"]/following::img')->attribute('src'),
"Trigger enabled" "Trigger enabled"
@@ -280,7 +280,7 @@ class MyModuleFunctionalTest extends \PHPUnit_Extensions_Selenium2TestCase
/** /**
* Verify post conditions * Verify post conditions
* @return void * @return void
*/ */
protected function assertPostConditions() protected function assertPostConditions()
{ {
@@ -288,7 +288,7 @@ class MyModuleFunctionalTest extends \PHPUnit_Extensions_Selenium2TestCase
/** /**
* Unit test teardown * Unit test teardown
* @return void * @return void
*/ */
public function tearDown() public function tearDown()
{ {
@@ -296,7 +296,7 @@ class MyModuleFunctionalTest extends \PHPUnit_Extensions_Selenium2TestCase
/** /**
* Global test teardown * Global test teardown
* @return void * @return void
*/ */
public static function tearDownAfterClass() public static function tearDownAfterClass()
{ {