2
0
forked from Wavyzz/dolibarr
This commit is contained in:
Frédéric FRANCE
2019-02-25 20:35:59 +01:00
parent 42a1387218
commit 1c07006015
125 changed files with 3394 additions and 3402 deletions

View File

@@ -37,7 +37,7 @@ class DolibarrApi
/** /**
* @var Restler $r Restler object * @var Restler $r Restler object
*/ */
var $r; public $r;
/** /**
* Constructor * Constructor
@@ -46,7 +46,7 @@ class DolibarrApi
* @param string $cachedir Cache dir * @param string $cachedir Cache dir
* @param boolean $refreshCache Update cache * @param boolean $refreshCache Update cache
*/ */
function __construct($db, $cachedir = '', $refreshCache = false) public function __construct($db, $cachedir = '', $refreshCache = false)
{ {
global $conf, $dolibarr_main_url_root; global $conf, $dolibarr_main_url_root;
@@ -94,7 +94,7 @@ class DolibarrApi
* @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
*/ */
function _cleanObjectDatas($object) private function _cleanObjectDatas($object)
{ {
// Remove $db object property for object // Remove $db object property for object
@@ -222,7 +222,7 @@ class DolibarrApi
* @return bool * @return bool
* @throws RestException * @throws RestException
*/ */
static function _checkAccessToResource($resource, $resource_id = 0, $dbtablename = '', $feature2 = '', $dbt_keyfield = 'fk_soc', $dbt_select = 'rowid') private static function _checkAccessToResource($resource, $resource_id = 0, $dbtablename = '', $feature2 = '', $dbt_keyfield = 'fk_soc', $dbt_select = 'rowid')
{ {
// Features/modules to check // Features/modules to check
@@ -240,7 +240,7 @@ class DolibarrApi
} }
return checkUserAccessToObject(DolibarrApiAccess::$user, $featuresarray, $resource_id, $dbtablename, $feature2, $dbt_keyfield, $dbt_select); return checkUserAccessToObject(DolibarrApiAccess::$user, $featuresarray, $resource_id, $dbtablename, $feature2, $dbt_keyfield, $dbt_select);
} }
/** /**
* Return if a $sqlfilters parameter is valid * Return if a $sqlfilters parameter is valid
@@ -248,7 +248,7 @@ class DolibarrApi
* @param string $sqlfilters sqlfilter string * @param string $sqlfilters sqlfilter string
* @return boolean True if valid, False if not valid * @return boolean True if valid, False if not valid
*/ */
function _checkFilters($sqlfilters) private function _checkFilters($sqlfilters)
{ {
//$regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; //$regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
//$tmp=preg_replace_all('/'.$regexstring.'/', '', $sqlfilters); //$tmp=preg_replace_all('/'.$regexstring.'/', '', $sqlfilters);
@@ -271,14 +271,14 @@ class DolibarrApi
return true; return true;
} }
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/** /**
* Function to forge a SQL criteria * Function to forge a SQL criteria
* *
* @param array $matches Array of found string by regex search * @param array $matches Array of found string by regex search
* @return string Forged criteria. Example: "t.field like 'abc%'" * @return string Forged criteria. Example: "t.field like 'abc%'"
*/ */
static function _forge_criteria_callback($matches) private static function _forge_criteria_callback($matches)
{ {
// phpcs:enable // phpcs:enable
global $db; global $db;

View File

@@ -173,20 +173,20 @@ class DolibarrApiAccess implements iAuthenticate
* @example Digest * @example Digest
* @example OAuth * @example OAuth
*/ */
public function __getWWWAuthenticateString() public function __getWWWAuthenticateString()
{ {
// phpcs:enable // phpcs:enable
return ''; return '';
} }
/** /**
* Verify access * Verify access
* *
* @param array $m Properties of method * @param array $m Properties of method
* *
* @access private * @access private
* @return bool * @return bool
*/ */
public static function verifyAccess(array $m) public static function verifyAccess(array $m)
{ {
$requires = isset($m['class']['DolibarrApiAccess']['properties']['requires']) $requires = isset($m['class']['DolibarrApiAccess']['properties']['requires'])

View File

@@ -43,7 +43,7 @@ class Documents extends DolibarrApi
/** /**
* Constructor * Constructor
*/ */
function __construct() public function __construct()
{ {
global $db; global $db;
$this->db = $db; $this->db = $db;
@@ -67,7 +67,7 @@ class Documents extends DolibarrApi
* *
* @url GET /download * @url GET /download
*/ */
public function index($module_part, $original_file='') public function index($module_part, $original_file = '')
{ {
global $conf, $langs; global $conf, $langs;
@@ -82,12 +82,11 @@ class Documents extends DolibarrApi
$entity=$conf->entity; $entity=$conf->entity;
$check_access = dol_check_secure_access_document($module_part, $original_file, $entity, DolibarrApiAccess::$user, '', 'read'); $check_access = dol_check_secure_access_document($module_part, $original_file, $entity, DolibarrApiAccess::$user, '', 'read');
$accessallowed = $check_access['accessallowed']; $accessallowed = $check_access['accessallowed'];
$sqlprotectagainstexternals = $check_access['sqlprotectagainstexternals']; $sqlprotectagainstexternals = $check_access['sqlprotectagainstexternals'];
$original_file = $check_access['original_file']; $original_file = $check_access['original_file'];
if (preg_match('/\.\./',$original_file) || preg_match('/[<>|]/',$original_file)) if (preg_match('/\.\./', $original_file) || preg_match('/[<>|]/', $original_file)) {
{
throw new RestException(401); throw new RestException(401);
} }
if (!$accessallowed) { if (!$accessallowed) {
@@ -127,7 +126,7 @@ class Documents extends DolibarrApi
* *
* @url PUT /builddoc * @url PUT /builddoc
*/ */
public function builddoc($module_part, $original_file='', $doctemplate='', $langcode='') public function builddoc($module_part, $original_file = '', $doctemplate = '', $langcode = '')
{ {
global $conf, $langs; global $conf, $langs;
@@ -153,7 +152,7 @@ class Documents extends DolibarrApi
$sqlprotectagainstexternals = $check_access['sqlprotectagainstexternals']; $sqlprotectagainstexternals = $check_access['sqlprotectagainstexternals'];
$original_file = $check_access['original_file']; $original_file = $check_access['original_file'];
if (preg_match('/\.\./',$original_file) || preg_match('/[<>|]/',$original_file)) { if (preg_match('/\.\./', $original_file) || preg_match('/[<>|]/', $original_file)) {
throw new RestException(401); throw new RestException(401);
} }
if (!$accessallowed) { if (!$accessallowed) {
@@ -245,7 +244,7 @@ class Documents extends DolibarrApi
* *
* @url GET / * @url GET /
*/ */
function getDocumentsListByElement($modulepart, $id=0, $ref='', $sortfield='', $sortorder='') public function getDocumentsListByElement($modulepart, $id = 0, $ref = '', $sortfield = '', $sortorder = '')
{ {
global $conf; global $conf;
@@ -376,7 +375,7 @@ class Documents extends DolibarrApi
throw new RestException(500, 'Modulepart '.$modulepart.' not implemented yet.'); throw new RestException(500, 'Modulepart '.$modulepart.' not implemented yet.');
} }
$filearray=dol_dir_list($upload_dir,"files",0,'','(\.meta|_preview.*\.png)$',$sortfield,(strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC),1); $filearray=dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC), 1);
if (empty($filearray)) { if (empty($filearray)) {
throw new RestException(404, 'Search for modulepart '.$modulepart.' with Id '.$object->id.(! empty($object->Ref)?' or Ref '.$object->ref:'').' does not return any document.'); throw new RestException(404, 'Search for modulepart '.$modulepart.' with Id '.$object->id.(! empty($object->Ref)?' or Ref '.$object->ref:'').' does not return any document.');
} }
@@ -412,6 +411,7 @@ class Documents extends DolibarrApi
* @param string $filecontent File content (string with file content. An empty file will be created if this parameter is not provided) * @param string $filecontent File content (string with file content. An empty file will be created if this parameter is not provided)
* @param string $fileencoding File encoding (''=no encoding, 'base64'=Base 64) {@example '' or 'base64'} * @param string $fileencoding File encoding (''=no encoding, 'base64'=Base 64) {@example '' or 'base64'}
* @param int $overwriteifexists Overwrite file if exists (1 by default) * @param int $overwriteifexists Overwrite file if exists (1 by default)
* @return string
* *
* @throws 200 * @throws 200
* @throws 400 * @throws 400
@@ -421,7 +421,7 @@ class Documents extends DolibarrApi
* *
* @url POST /upload * @url POST /upload
*/ */
public function post($filename, $modulepart, $ref='', $subdir='', $filecontent='', $fileencoding='', $overwriteifexists=0) public function post($filename, $modulepart, $ref = '', $subdir = '', $filecontent = '', $fileencoding = '', $overwriteifexists = 0)
{ {
global $db, $conf; global $db, $conf;
@@ -501,7 +501,7 @@ class Documents extends DolibarrApi
if($result == 0) if($result == 0)
{ {
throw new RestException(404, "Object with ref '".$ref."' was not found."); throw new RestException(404, "Object with ref '".$ref."' was not found.");
} }
elseif ($result < 0) elseif ($result < 0)
{ {
throw new RestException(500, 'Error while fetching object.'); throw new RestException(500, 'Error while fetching object.');
@@ -576,6 +576,7 @@ class Documents extends DolibarrApi
return dol_basename($destfile); return dol_basename($destfile);
} }
// phpcs:disable PEAR.NamingConventions.ValidFunctionName
/** /**
* Validate fields before create or update object * Validate fields before create or update object
* *
@@ -583,7 +584,8 @@ class Documents extends DolibarrApi
* @return array * @return array
* @throws RestException * @throws RestException
*/ */
function _validate_file($data) { private function _validate_file($data) {
// phpcs:enable
$result = array(); $result = array();
foreach (Documents::$DOCUMENT_FIELDS as $field) { foreach (Documents::$DOCUMENT_FIELDS as $field) {
if (!isset($data[$field])) if (!isset($data[$field]))

View File

@@ -29,11 +29,11 @@ class Login
/** /**
* Constructor of the class * Constructor of the class
*/ */
function __construct() public function __construct()
{ {
global $db; global $db;
$this->db = $db; $this->db = $db;
} }
/** /**
* Login * Login
@@ -136,5 +136,5 @@ class Login
'message' => 'Welcome ' . $login.($reset?' - Token is new':' - This is your token (generated by a previous call). You can use it to make any REST API call, or enter it into the DOLAPIKEY field to use the Dolibarr API explorer.') 'message' => 'Welcome ' . $login.($reset?' - Token is new':' - This is your token (generated by a previous call). You can use it to make any REST API call, or enter it into the DOLAPIKEY field to use the Dolibarr API explorer.')
) )
); );
} }
} }

View File

@@ -38,7 +38,7 @@ class Setup extends DolibarrApi
/** /**
* Constructor * Constructor
*/ */
function __construct() public function __construct()
{ {
global $db; global $db;
$this->db = $db; $this->db = $db;
@@ -61,7 +61,7 @@ class Setup extends DolibarrApi
* @throws 400 RestException * @throws 400 RestException
* @throws 200 OK * @throws 200 OK
*/ */
function getPaymentTypes($sortfield = "code", $sortorder = 'ASC', $limit = 100, $page = 0, $active = 1, $sqlfilters = '') public function getPaymentTypes($sortfield = "code", $sortorder = 'ASC', $limit = 100, $page = 0, $active = 1, $sqlfilters = '')
{ {
$list = array(); $list = array();
@@ -76,7 +76,7 @@ class Setup extends DolibarrApi
{ {
throw new RestException(400, 'error when validating parameter sqlfilters '.$sqlfilters); throw new RestException(400, '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).")";
} }
@@ -128,7 +128,7 @@ class Setup extends DolibarrApi
* *
* @throws RestException * @throws RestException
*/ */
function getListOfCountries($sortfield = "code", $sortorder = 'ASC', $limit = 100, $page = 0, $filter = '', $lang = '', $sqlfilters = '') public function getListOfCountries($sortfield = "code", $sortorder = 'ASC', $limit = 100, $page = 0, $filter = '', $lang = '', $sqlfilters = '')
{ {
$list = array(); $list = array();
@@ -195,7 +195,7 @@ class Setup extends DolibarrApi
* *
* @throws RestException * @throws RestException
*/ */
function getCountryByID($id, $lang = '') public function getCountryByID($id, $lang = '')
{ {
$country = new Ccountry($this->db); $country = new Ccountry($this->db);
@@ -228,7 +228,7 @@ class Setup extends DolibarrApi
* @throws 400 RestException * @throws 400 RestException
* @throws 200 OK * @throws 200 OK
*/ */
function getAvailability($sortfield = "code", $sortorder = 'ASC', $limit = 100, $page = 0, $active = 1, $sqlfilters = '') public function getAvailability($sortfield = "code", $sortorder = 'ASC', $limit = 100, $page = 0, $active = 1, $sqlfilters = '')
{ {
$list = array(); $list = array();
@@ -279,7 +279,7 @@ class Setup extends DolibarrApi
* @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
*/ */
function _cleanObjectDatas($object) private function _cleanObjectDatas($object)
{ {
$object = parent::_cleanObjectDatas($object); $object = parent::_cleanObjectDatas($object);
@@ -334,7 +334,7 @@ class Setup extends DolibarrApi
* *
* @throws RestException * @throws RestException
*/ */
function getListOfEventTypes($sortfield = "code", $sortorder = 'ASC', $limit = 100, $page = 0, $type = '', $module = '', $active = 1, $sqlfilters = '') public function getListOfEventTypes($sortfield = "code", $sortorder = 'ASC', $limit = 100, $page = 0, $type = '', $module = '', $active = 1, $sqlfilters = '')
{ {
$list = array(); $list = array();
@@ -397,7 +397,7 @@ class Setup extends DolibarrApi
* *
* @throws RestException * @throws RestException
*/ */
function getListOfCivilities($sortfield = "code", $sortorder = 'ASC', $limit = 100, $page = 0, $module = '', $active = 1, $sqlfilters = '') public function getListOfCivilities($sortfield = "code", $sortorder = 'ASC', $limit = 100, $page = 0, $module = '', $active = 1, $sqlfilters = '')
{ {
$list = array(); $list = array();
@@ -442,7 +442,7 @@ class Setup extends DolibarrApi
return $list; return $list;
} }
/** /**
* Get the list of currencies. * Get the list of currencies.
* *
@@ -458,10 +458,10 @@ class Setup extends DolibarrApi
* *
* @throws RestException * @throws RestException
*/ */
function getListOfCurrencies($sortfield = "code_iso", $sortorder = 'ASC', $limit = 100, $page = 0, $active = 1, $sqlfilters = '') public function getListOfCurrencies($sortfield = "code_iso", $sortorder = 'ASC', $limit = 100, $page = 0, $active = 1, $sqlfilters = '')
{ {
$list = array(); $list = array();
//TODO link with multicurrency module //TODO link with multicurrency module
$sql = "SELECT t.code_iso, t.label, t.unicode"; $sql = "SELECT t.code_iso, t.label, t.unicode";
$sql.= " FROM ".MAIN_DB_PREFIX."c_currencies as t"; $sql.= " FROM ".MAIN_DB_PREFIX."c_currencies as t";
$sql.= " WHERE t.active = ".$active; $sql.= " WHERE t.active = ".$active;
@@ -516,7 +516,7 @@ class Setup extends DolibarrApi
* *
* @throws RestException * @throws RestException
*/ */
function getListOfExtrafields($sortfield = "t.pos", $sortorder = 'ASC', $type = '', $sqlfilters = '') public function getListOfExtrafields($sortfield = "t.pos", $sortorder = 'ASC', $type = '', $sqlfilters = '')
{ {
$list = array(); $list = array();
@@ -595,7 +595,7 @@ class Setup extends DolibarrApi
* *
* @throws RestException * @throws RestException
*/ */
function getListOfTowns($sortfield = "zip,town", $sortorder = 'ASC', $limit = 100, $page = 0, $zipcode = '', $town = '', $active = 1, $sqlfilters = '') public function getListOfTowns($sortfield = "zip,town", $sortorder = 'ASC', $limit = 100, $page = 0, $zipcode = '', $town = '', $active = 1, $sqlfilters = '')
{ {
$list = array(); $list = array();
@@ -659,7 +659,7 @@ class Setup extends DolibarrApi
* @throws 400 RestException * @throws 400 RestException
* @throws 200 OK * @throws 200 OK
*/ */
function getPaymentTerms($sortfield = "sortorder", $sortorder = 'ASC', $limit = 100, $page = 0, $active = 1, $sqlfilters = '') public function getPaymentTerms($sortfield = "sortorder", $sortorder = 'ASC', $limit = 100, $page = 0, $active = 1, $sqlfilters = '')
{ {
$list = array(); $list = array();
@@ -720,7 +720,7 @@ class Setup extends DolibarrApi
* *
* @throws RestException * @throws RestException
*/ */
function getTicketsCategories($sortfield = "code", $sortorder = 'ASC', $limit = 100, $page = 0, $active = 1, $sqlfilters = '') public function getTicketsCategories($sortfield = "code", $sortorder = 'ASC', $limit = 100, $page = 0, $active = 1, $sqlfilters = '')
{ {
$list = array(); $list = array();
@@ -780,13 +780,13 @@ class Setup extends DolibarrApi
* *
* @throws RestException * @throws RestException
*/ */
function getTicketsSeverities($sortfield = "code", $sortorder = 'ASC', $limit = 100, $page = 0, $active = 1, $sqlfilters = '') public function getTicketsSeverities($sortfield = "code", $sortorder = 'ASC', $limit = 100, $page = 0, $active = 1, $sqlfilters = '')
{ {
$list = array(); $list = array();
$sql = "SELECT rowid, code, pos, label, use_default, color, description"; $sql = "SELECT rowid, code, pos, label, use_default, color, description";
$sql.= " FROM ".MAIN_DB_PREFIX."c_ticket_severity as t"; $sql.= " FROM ".MAIN_DB_PREFIX."c_ticket_severity as t";
$sql.= " WHERE t.active = ".$active; $sql.= " WHERE t.active = ".$active;
// Add sql filters // Add sql filters
if ($sqlfilters) if ($sqlfilters)
{ {
@@ -840,13 +840,13 @@ class Setup extends DolibarrApi
* *
* @throws RestException * @throws RestException
*/ */
function getTicketsTypes($sortfield = "code", $sortorder = 'ASC', $limit = 100, $page = 0, $active = 1, $sqlfilters = '') public function getTicketsTypes($sortfield = "code", $sortorder = 'ASC', $limit = 100, $page = 0, $active = 1, $sqlfilters = '')
{ {
$list = array(); $list = array();
$sql = "SELECT rowid, code, pos, label, use_default, description"; $sql = "SELECT rowid, code, pos, label, use_default, description";
$sql.= " FROM ".MAIN_DB_PREFIX."c_ticket_type as t"; $sql.= " FROM ".MAIN_DB_PREFIX."c_ticket_type as t";
$sql.= " WHERE t.active = ".$active; $sql.= " WHERE t.active = ".$active;
if ($type) $sql.=" AND t.type LIKE '%" . $this->db->escape($type) . "%'"; if ($type) $sql.=" AND t.type LIKE '%" . $this->db->escape($type) . "%'";
if ($module) $sql.=" AND t.module LIKE '%" . $this->db->escape($module) . "%'"; if ($module) $sql.=" AND t.module LIKE '%" . $this->db->escape($module) . "%'";
// Add sql filters // Add sql filters
@@ -898,7 +898,7 @@ class Setup extends DolibarrApi
* *
* @throws RestException * @throws RestException
*/ */
function getCheckIntegrity($target) public function getCheckIntegrity($target)
{ {
global $langs, $conf; global $langs, $conf;

View File

@@ -31,7 +31,7 @@ class Status
* *
* @return array * @return array
*/ */
function index() public function index()
{ {
global $conf; global $conf;

View File

@@ -23,8 +23,6 @@
*/ */
require_once DOL_DOCUMENT_ROOT . '/core/class/commonobject.class.php'; require_once DOL_DOCUMENT_ROOT . '/core/class/commonobject.class.php';
//require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php';
//require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php';
/** /**
* Class for Asset * Class for Asset
@@ -312,7 +310,7 @@ class Asset extends CommonObject
* @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
*/ */
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 $db, $conf, $langs; global $db, $conf, $langs;
global $dolibarr_main_authentication, $dolibarr_main_demo; global $dolibarr_main_authentication, $dolibarr_main_demo;
@@ -369,12 +367,12 @@ class Asset extends CommonObject
* @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto
* @return string Label of status * @return string Label of status
*/ */
function getLibStatut($mode = 0) public function getLibStatut($mode = 0)
{ {
return $this->LibStatut($this->status, $mode); return $this->LibStatut($this->status, $mode);
} }
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/** /**
* Return the status * Return the status
* *
@@ -382,7 +380,7 @@ class Asset extends CommonObject
* @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto
* @return string Label of status * @return string Label of status
*/ */
static function LibStatut($status, $mode = 0) public static function LibStatut($status, $mode = 0)
{ {
// phpcs:enable // phpcs:enable
global $langs; global $langs;
@@ -425,7 +423,7 @@ class Asset extends CommonObject
* @param int $id Id of order * @param int $id Id of order
* @return void * @return void
*/ */
function info($id) public function info($id)
{ {
$sql = 'SELECT rowid, date_creation as datec, tms as datem,'; $sql = 'SELECT rowid, date_creation as datec, tms as datem,';
$sql.= ' fk_user_creat, fk_user_modif'; $sql.= ' fk_user_creat, fk_user_modif';

View File

@@ -76,7 +76,7 @@ class AssetType extends CommonObject
* *
* @param DoliDB $db Database handler * @param DoliDB $db Database handler
*/ */
function __construct($db) public function __construct($db)
{ {
$this->db = $db; $this->db = $db;
} }
@@ -89,8 +89,8 @@ class AssetType extends CommonObject
* @param int $notrigger 1=do not execute triggers, 0 otherwise * @param int $notrigger 1=do not execute triggers, 0 otherwise
* @return int >0 if OK, < 0 if KO * @return int >0 if OK, < 0 if KO
*/ */
function create($user, $notrigger = 0) public function create($user, $notrigger = 0)
{ {
global $conf; global $conf;
$error=0; $error=0;
@@ -157,7 +157,7 @@ class AssetType extends CommonObject
$this->db->rollback(); $this->db->rollback();
return -1; return -1;
} }
} }
/** /**
* Met a jour en base donnees du type * Met a jour en base donnees du type
@@ -166,7 +166,7 @@ class AssetType extends CommonObject
* @param int $notrigger 1=do not execute triggers, 0 otherwise * @param int $notrigger 1=do not execute triggers, 0 otherwise
* @return int >0 if OK, < 0 if KO * @return int >0 if OK, < 0 if KO
*/ */
function update($user, $notrigger = 0) public function update($user, $notrigger = 0)
{ {
global $conf, $hookmanager; global $conf, $hookmanager;
@@ -233,7 +233,7 @@ class AssetType extends CommonObject
* *
* @return int >0 if OK, 0 if not found, < 0 if KO * @return int >0 if OK, 0 if not found, < 0 if KO
*/ */
function delete() public function delete()
{ {
global $user; global $user;
@@ -267,7 +267,7 @@ class AssetType extends CommonObject
* @param int $rowid Id of member type to load * @param int $rowid Id of member type to load
* @return int <0 if KO, >0 if OK * @return int <0 if KO, >0 if OK
*/ */
function fetch($rowid) public function fetch($rowid)
{ {
$sql = "SELECT d.rowid, d.label as label, d.accountancy_code_asset, d.accountancy_code_depreciation_asset, d.accountancy_code_depreciation_expense, d.note"; $sql = "SELECT d.rowid, d.label as label, d.accountancy_code_asset, d.accountancy_code_depreciation_asset, d.accountancy_code_depreciation_expense, d.note";
$sql .= " FROM ".MAIN_DB_PREFIX."asset_type as d"; $sql .= " FROM ".MAIN_DB_PREFIX."asset_type as d";
@@ -282,13 +282,13 @@ class AssetType extends CommonObject
{ {
$obj = $this->db->fetch_object($resql); $obj = $this->db->fetch_object($resql);
$this->id = $obj->rowid; $this->id = $obj->rowid;
$this->ref = $obj->rowid; $this->ref = $obj->rowid;
$this->label = $obj->label; $this->label = $obj->label;
$this->accountancy_code_asset = $obj->accountancy_code_asset; $this->accountancy_code_asset = $obj->accountancy_code_asset;
$this->accountancy_code_depreciation_asset = $obj->accountancy_code_depreciation_asset; $this->accountancy_code_depreciation_asset = $obj->accountancy_code_depreciation_asset;
$this->accountancy_code_depreciation_expense = $obj->accountancy_code_depreciation_expense; $this->accountancy_code_depreciation_expense = $obj->accountancy_code_depreciation_expense;
$this->note = $obj->note; $this->note = $obj->note;
} }
return 1; return 1;
@@ -300,13 +300,13 @@ class AssetType extends CommonObject
} }
} }
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/** /**
* Return list of asset's type * Return list of asset's type
* *
* @return array List of types of members * @return array List of types of members
*/ */
function liste_array() public function liste_array()
{ {
// phpcs:enable // phpcs:enable
global $conf,$langs; global $conf,$langs;
@@ -350,7 +350,7 @@ class AssetType extends CommonObject
* 2=Return array of asset id only * 2=Return array of asset id only
* @return mixed Array of asset or -1 on error * @return mixed Array of asset or -1 on error
*/ */
function listAssetForAssetType($excludefilter = '', $mode = 0) public function listAssetForAssetType($excludefilter = '', $mode = 0)
{ {
global $conf, $user; global $conf, $user;
@@ -405,7 +405,7 @@ class AssetType extends CommonObject
* @param int $notooltip 1=Disable tooltip * @param int $notooltip 1=Disable tooltip
* @return string String with URL * @return string String with URL
*/ */
function getNomUrl($withpicto = 0, $maxlen = 0, $notooltip = 0) public function getNomUrl($withpicto = 0, $maxlen = 0, $notooltip = 0)
{ {
global $langs; global $langs;
@@ -430,8 +430,8 @@ class AssetType extends CommonObject
* *
* @return void * @return void
*/ */
function initAsSpecimen() public function initAsSpecimen()
{ {
global $conf, $user, $langs; global $conf, $user, $langs;
// Initialize parameters // Initialize parameters
@@ -446,15 +446,15 @@ class AssetType extends CommonObject
$this->asset=array( $this->asset=array(
$user->id => $user $user->id => $user
); );
} }
/** /**
* getLibStatut * getLibStatut
* *
* @return string Return status of a type of asset * @return string Return status of a type of asset
*/ */
function getLibStatut() public function getLibStatut()
{ {
return ''; return '';
} }
} }

View File

@@ -82,7 +82,7 @@ class Bookmark extends CommonObject
* *
* @param DoliDB $db Database handler * @param DoliDB $db Database handler
*/ */
function __construct($db) public function __construct($db)
{ {
$this->db = $db; $this->db = $db;
} }
@@ -93,7 +93,7 @@ class Bookmark extends CommonObject
* @param int $id Bookmark Id Loader * @param int $id Bookmark Id Loader
* @return int <0 if KO, >0 if OK * @return int <0 if KO, >0 if OK
*/ */
function fetch($id) public function fetch($id)
{ {
global $conf; global $conf;
@@ -135,7 +135,7 @@ class Bookmark extends CommonObject
* *
* @return int <0 si ko, rowid du bookmark cree si ok * @return int <0 si ko, rowid du bookmark cree si ok
*/ */
function create() public function create()
{ {
global $conf; global $conf;
@@ -192,7 +192,7 @@ class Bookmark extends CommonObject
* *
* @return int <0 if KO, > if OK * @return int <0 if KO, > if OK
*/ */
function update() public function update()
{ {
// Clean parameters // Clean parameters
$this->url=trim($this->url); $this->url=trim($this->url);
@@ -227,7 +227,7 @@ class Bookmark extends CommonObject
* @param int $id Id removed bookmark * @param int $id Id removed bookmark
* @return int <0 si ko, >0 si ok * @return int <0 si ko, >0 si ok
*/ */
function remove($id) public function remove($id)
{ {
$sql = "DELETE FROM ".MAIN_DB_PREFIX."bookmark"; $sql = "DELETE FROM ".MAIN_DB_PREFIX."bookmark";
$sql .= " WHERE rowid = ".$id; $sql .= " WHERE rowid = ".$id;
@@ -268,7 +268,7 @@ class Bookmark extends CommonObject
* @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto
* @return string Label of contact status * @return string Label of contact status
*/ */
function getLibStatut($mode) public function getLibStatut($mode)
{ {
return ''; return '';
} }

View File

@@ -35,9 +35,9 @@ class Contracts extends DolibarrApi
*/ */
static $FIELDS = array( static $FIELDS = array(
'socid', 'socid',
'date_contrat', 'date_contrat',
'commercial_signature_id', 'commercial_signature_id',
'commercial_suivi_id' 'commercial_suivi_id'
); );
/** /**
@@ -48,10 +48,10 @@ class Contracts extends DolibarrApi
/** /**
* Constructor * Constructor
*/ */
function __construct() public function __construct()
{ {
global $db, $conf; global $db, $conf;
$this->db = $db; $this->db = $db;
$this->contract = new Contrat($this->db); $this->contract = new Contrat($this->db);
} }
@@ -65,23 +65,23 @@ class Contracts extends DolibarrApi
* *
* @throws RestException * @throws RestException
*/ */
function get($id) public function get($id)
{ {
if(! DolibarrApiAccess::$user->rights->contrat->lire) { if(! DolibarrApiAccess::$user->rights->contrat->lire) {
throw new RestException(401); throw new RestException(401);
} }
$result = $this->contract->fetch($id); $result = $this->contract->fetch($id);
if( ! $result ) { if( ! $result ) {
throw new RestException(404, 'Contract not found'); throw new RestException(404, 'Contract not found');
} }
if( ! DolibarrApi::_checkAccessToResource('contrat', $this->contract->id)) { if( ! DolibarrApi::_checkAccessToResource('contrat', $this->contract->id)) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
} }
$this->contract->fetchObjectLinked(); $this->contract->fetchObjectLinked();
return $this->_cleanObjectDatas($this->contract); return $this->_cleanObjectDatas($this->contract);
} }
@@ -99,9 +99,9 @@ class Contracts extends DolibarrApi
* @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 contract objects * @return array Array of contract objects
* *
* @throws RestException * @throws RestException
*/ */
function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $thirdparty_ids = '', $sqlfilters = '') public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $thirdparty_ids = '', $sqlfilters = '')
{ {
global $db, $conf; global $db, $conf;
@@ -136,7 +136,7 @@ class Contracts extends DolibarrApi
{ {
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).")";
} }
@@ -175,7 +175,7 @@ class Contracts extends DolibarrApi
if( ! count($obj_ret)) { if( ! count($obj_ret)) {
throw new RestException(404, 'No contract found'); throw new RestException(404, 'No contract found');
} }
return $obj_ret; return $obj_ret;
} }
/** /**
@@ -184,7 +184,7 @@ class Contracts extends DolibarrApi
* @param array $request_data Request data * @param array $request_data Request data
* @return int ID of contrat * @return int ID of contrat
*/ */
function post($request_data = null) public function post($request_data = null)
{ {
if(! DolibarrApiAccess::$user->rights->contrat->creer) { if(! DolibarrApiAccess::$user->rights->contrat->creer) {
throw new RestException(401, "Insuffisant rights"); throw new RestException(401, "Insuffisant rights");
@@ -218,7 +218,7 @@ class Contracts extends DolibarrApi
* *
* @return array * @return array
*/ */
function getLines($id) public function getLines($id)
{ {
if (! DolibarrApiAccess::$user->rights->contrat->lire) { if (! DolibarrApiAccess::$user->rights->contrat->lire) {
throw new RestException(401); throw new RestException(401);
@@ -229,8 +229,8 @@ class Contracts extends DolibarrApi
throw new RestException(404, 'Contract not found'); throw new RestException(404, 'Contract not found');
} }
if( ! DolibarrApi::_checkAccessToResource('contrat', $this->contract->id)) { if( ! DolibarrApi::_checkAccessToResource('contrat', $this->contract->id)) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
} }
$this->contract->getLinesArray(); $this->contract->getLinesArray();
$result = array(); $result = array();
@@ -250,21 +250,21 @@ class Contracts extends DolibarrApi
* *
* @return int|bool * @return int|bool
*/ */
function postLine($id, $request_data = null) public function postLine($id, $request_data = null)
{ {
if(! DolibarrApiAccess::$user->rights->contrat->creer) { if(! DolibarrApiAccess::$user->rights->contrat->creer) {
throw new RestException(401); throw new RestException(401);
} }
$result = $this->contract->fetch($id); $result = $this->contract->fetch($id);
if( ! $result ) { if( ! $result ) {
throw new RestException(404, 'Contract not found'); throw new RestException(404, 'Contract not found');
} }
if( ! DolibarrApi::_checkAccessToResource('contrat', $this->contract->id)) { if( ! DolibarrApi::_checkAccessToResource('contrat', $this->contract->id)) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
} }
$request_data = (object) $request_data; $request_data = (object) $request_data;
$updateRes = $this->contract->addline( $updateRes = $this->contract->addline(
$request_data->desc, $request_data->desc,
$request_data->subprice, $request_data->subprice,
@@ -274,16 +274,16 @@ class Contracts extends DolibarrApi
$request_data->localtax2_tx, $request_data->localtax2_tx,
$request_data->fk_product, $request_data->fk_product,
$request_data->remise_percent, $request_data->remise_percent,
$request_data->date_start, // date_start = date planned start, date ouverture = date_start_real $request_data->date_start, // date_start = date planned start, date ouverture = date_start_real
$request_data->date_end, // date_end = date planned end, date_cloture = date_end_real $request_data->date_end, // date_end = date planned end, date_cloture = date_end_real
$request_data->HT, $request_data->HT,
$request_data->subprice_excl_tax, $request_data->subprice_excl_tax,
$request_data->info_bits, $request_data->info_bits,
$request_data->fk_fournprice, $request_data->fk_fournprice,
$request_data->pa_ht, $request_data->pa_ht,
$request_data->array_options, $request_data->array_options,
$request_data->fk_unit, $request_data->fk_unit,
$request_data->rang $request_data->rang
); );
if ($updateRes > 0) { if ($updateRes > 0) {
@@ -303,20 +303,20 @@ class Contracts extends DolibarrApi
* *
* @return array|bool * @return array|bool
*/ */
function putLine($id, $lineid, $request_data = null) public function putLine($id, $lineid, $request_data = null)
{ {
if(! DolibarrApiAccess::$user->rights->contrat->creer) { if(! DolibarrApiAccess::$user->rights->contrat->creer) {
throw new RestException(401); throw new RestException(401);
} }
$result = $this->contract->fetch($id); $result = $this->contract->fetch($id);
if( ! $result ) { if( ! $result ) {
throw new RestException(404, 'Contrat not found'); throw new RestException(404, 'Contrat not found');
} }
if( ! DolibarrApi::_checkAccessToResource('contrat', $this->contract->id)) { if( ! DolibarrApi::_checkAccessToResource('contrat', $this->contract->id)) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
} }
$request_data = (object) $request_data; $request_data = (object) $request_data;
@@ -328,12 +328,12 @@ class Contracts extends DolibarrApi
$request_data->remise_percent, $request_data->remise_percent,
$request_data->date_ouveture_prevue, $request_data->date_ouveture_prevue,
$request_data->date_fin_validite, $request_data->date_fin_validite,
$request_data->tva_tx, $request_data->tva_tx,
$request_data->localtax1_tx, $request_data->localtax1_tx,
$request_data->localtax2_tx, $request_data->localtax2_tx,
$request_data->date_ouverture, $request_data->date_ouverture,
$request_data->date_cloture, $request_data->date_cloture,
'HT', 'HT',
$request_data->info_bits, $request_data->info_bits,
$request_data->fk_fourn_price, $request_data->fk_fourn_price,
$request_data->pa_ht, $request_data->pa_ht,
@@ -363,30 +363,30 @@ class Contracts extends DolibarrApi
* *
* @return array|bool * @return array|bool
*/ */
function activateLine($id, $lineid, $datestart, $dateend = null, $comment = null) public function activateLine($id, $lineid, $datestart, $dateend = null, $comment = null)
{ {
if(! DolibarrApiAccess::$user->rights->contrat->creer) { if(! DolibarrApiAccess::$user->rights->contrat->creer) {
throw new RestException(401); throw new RestException(401);
} }
$result = $this->contract->fetch($id); $result = $this->contract->fetch($id);
if (! $result) { if (! $result) {
throw new RestException(404, 'Contrat not found'); throw new RestException(404, 'Contrat not found');
} }
if( ! DolibarrApi::_checkAccessToResource('contrat', $this->contract->id)) { if( ! DolibarrApi::_checkAccessToResource('contrat', $this->contract->id)) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
} }
$updateRes = $this->contract->active_line(DolibarrApiAccess::$user, $lineid, $datestart, $dateend, $comment); $updateRes = $this->contract->active_line(DolibarrApiAccess::$user, $lineid, $datestart, $dateend, $comment);
if ($updateRes > 0) { if ($updateRes > 0) {
$result = $this->get($id); $result = $this->get($id);
unset($result->line); unset($result->line);
return $this->_cleanObjectDatas($result); return $this->_cleanObjectDatas($result);
} }
return false; return false;
} }
/** /**
@@ -401,32 +401,32 @@ class Contracts extends DolibarrApi
* *
* @return array|bool * @return array|bool
*/ */
function unactivateLine($id, $lineid, $datestart, $comment = null) public function unactivateLine($id, $lineid, $datestart, $comment = null)
{ {
if (! DolibarrApiAccess::$user->rights->contrat->creer) { if (! DolibarrApiAccess::$user->rights->contrat->creer) {
throw new RestException(401); throw new RestException(401);
} }
$result = $this->contract->fetch($id); $result = $this->contract->fetch($id);
if (! $result) { if (! $result) {
throw new RestException(404, 'Contrat not found'); throw new RestException(404, 'Contrat not found');
} }
if( ! DolibarrApi::_checkAccessToResource('contrat', $this->contract->id)) { if( ! DolibarrApi::_checkAccessToResource('contrat', $this->contract->id)) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
} }
$request_data = (object) $request_data; $request_data = (object) $request_data;
$updateRes = $this->contract->close_line(DolibarrApiAccess::$user, $lineid, $datestart, $comment); $updateRes = $this->contract->close_line(DolibarrApiAccess::$user, $lineid, $datestart, $comment);
if ($updateRes > 0) { if ($updateRes > 0) {
$result = $this->get($id); $result = $this->get($id);
unset($result->line); unset($result->line);
return $this->_cleanObjectDatas($result); return $this->_cleanObjectDatas($result);
} }
return false; return false;
} }
/** /**
@@ -442,19 +442,19 @@ class Contracts extends DolibarrApi
* @throws 401 * @throws 401
* @throws 404 * @throws 404
*/ */
function deleteLine($id, $lineid) public function deleteLine($id, $lineid)
{ {
if (! DolibarrApiAccess::$user->rights->contrat->creer) { if (! DolibarrApiAccess::$user->rights->contrat->creer) {
throw new RestException(401); throw new RestException(401);
} }
$result = $this->contract->fetch($id); $result = $this->contract->fetch($id);
if (! $result) { if (! $result) {
throw new RestException(404, 'Contrat not found'); throw new RestException(404, 'Contrat not found');
} }
if (! DolibarrApi::_checkAccessToResource('contrat', $this->contract->id)) { if (! DolibarrApi::_checkAccessToResource('contrat', $this->contract->id)) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
} }
// TODO Check the lineid $lineid is a line of object // TODO Check the lineid $lineid is a line of object
@@ -465,7 +465,7 @@ class Contracts extends DolibarrApi
} }
else else
{ {
throw new RestException(405, $this->contract->error); throw new RestException(405, $this->contract->error);
} }
} }
@@ -477,20 +477,20 @@ class Contracts extends DolibarrApi
* *
* @return int * @return int
*/ */
function put($id, $request_data = null) public function put($id, $request_data = null)
{ {
if (! DolibarrApiAccess::$user->rights->contrat->creer) { if (! DolibarrApiAccess::$user->rights->contrat->creer) {
throw new RestException(401); throw new RestException(401);
} }
$result = $this->contract->fetch($id); $result = $this->contract->fetch($id);
if (! $result) { if (! $result) {
throw new RestException(404, 'Contrat not found'); throw new RestException(404, 'Contrat not found');
} }
if (! DolibarrApi::_checkAccessToResource('contrat', $this->contract->id)) { if (! DolibarrApi::_checkAccessToResource('contrat', $this->contract->id)) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); throw new RestException(401, 'Access 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->contract->$field = $value; $this->contract->$field = $value;
@@ -502,7 +502,7 @@ class Contracts extends DolibarrApi
} }
else else
{ {
throw new RestException(500, $this->contract->error); throw new RestException(500, $this->contract->error);
} }
} }
@@ -513,19 +513,19 @@ class Contracts extends DolibarrApi
* *
* @return array * @return array
*/ */
function delete($id) public function delete($id)
{ {
if (! DolibarrApiAccess::$user->rights->contrat->supprimer) { if (! DolibarrApiAccess::$user->rights->contrat->supprimer) {
throw new RestException(401); throw new RestException(401);
} }
$result = $this->contract->fetch($id); $result = $this->contract->fetch($id);
if (! $result) { if (! $result) {
throw new RestException(404, 'Contract not found'); throw new RestException(404, 'Contract not found');
} }
if (! DolibarrApi::_checkAccessToResource('contrat', $this->contract->id)) { if (! DolibarrApi::_checkAccessToResource('contrat', $this->contract->id)) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
} }
if (! $this->contract->delete(DolibarrApiAccess::$user)) { if (! $this->contract->delete(DolibarrApiAccess::$user)) {
throw new RestException(500, 'Error when delete contract : '.$this->contract->error); throw new RestException(500, 'Error when delete contract : '.$this->contract->error);
@@ -555,27 +555,27 @@ class Contracts extends DolibarrApi
* "notrigger": 0 * "notrigger": 0
* } * }
*/ */
function validate($id, $notrigger = 0) public function validate($id, $notrigger = 0)
{ {
if (! DolibarrApiAccess::$user->rights->contrat->creer) { if (! DolibarrApiAccess::$user->rights->contrat->creer) {
throw new RestException(401); throw new RestException(401);
} }
$result = $this->contract->fetch($id); $result = $this->contract->fetch($id);
if (! $result) { if (! $result) {
throw new RestException(404, 'Contract not found'); throw new RestException(404, 'Contract not found');
} }
if (! DolibarrApi::_checkAccessToResource('contrat', $this->contract->id)) { if (! DolibarrApi::_checkAccessToResource('contrat', $this->contract->id)) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
} }
$result = $this->contract->validate(DolibarrApiAccess::$user, '', $notrigger); $result = $this->contract->validate(DolibarrApiAccess::$user, '', $notrigger);
if ($result == 0) { if ($result == 0) {
throw new RestException(304, 'Error nothing done. May be object is already validated'); throw new RestException(304, 'Error nothing done. May be object is already validated');
} }
if ($result < 0) { if ($result < 0) {
throw new RestException(500, 'Error when validating Contract: '.$this->contract->error); throw new RestException(500, 'Error when validating Contract: '.$this->contract->error);
} }
return array( return array(
'success' => array( 'success' => array(
@@ -601,34 +601,34 @@ class Contracts extends DolibarrApi
* "notrigger": 0 * "notrigger": 0
* } * }
*/ */
function close($id, $notrigger = 0) public function close($id, $notrigger = 0)
{ {
if (! DolibarrApiAccess::$user->rights->contrat->creer) { if (! DolibarrApiAccess::$user->rights->contrat->creer) {
throw new RestException(401); throw new RestException(401);
} }
$result = $this->contract->fetch($id); $result = $this->contract->fetch($id);
if (! $result) { if (! $result) {
throw new RestException(404, 'Contract not found'); throw new RestException(404, 'Contract not found');
} }
if (! DolibarrApi::_checkAccessToResource('contrat', $this->contract->id)) { if (! DolibarrApi::_checkAccessToResource('contrat', $this->contract->id)) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
} }
$result = $this->contract->closeAll(DolibarrApiAccess::$user, $notrigger); $result = $this->contract->closeAll(DolibarrApiAccess::$user, $notrigger);
if ($result == 0) { if ($result == 0) {
throw new RestException(304, 'Error nothing done. May be object is already close'); throw new RestException(304, 'Error nothing done. May be object is already close');
} }
if ($result < 0) { if ($result < 0) {
throw new RestException(500, 'Error when closing Contract: '.$this->contract->error); throw new RestException(500, 'Error when closing Contract: '.$this->contract->error);
} }
return array( return array(
'success' => array( 'success' => array(
'code' => 200, 'code' => 200,
'message' => 'Contract closed (Ref='.$this->contract->ref.'). All services were closed.' 'message' => 'Contract closed (Ref='.$this->contract->ref.'). All services were closed.'
) )
); );
} }
@@ -639,7 +639,7 @@ class Contracts extends DolibarrApi
* @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
*/ */
function _cleanObjectDatas($object) private function _cleanObjectDatas($object)
{ {
$object = parent::_cleanObjectDatas($object); $object = parent::_cleanObjectDatas($object);
@@ -666,7 +666,7 @@ class Contracts extends DolibarrApi
* @return array * @return array
* @throws RestException * @throws RestException
*/ */
function _validate($data) private function _validate($data)
{ {
$contrat = array(); $contrat = array();
foreach (Contracts::$FIELDS as $field) { foreach (Contracts::$FIELDS as $field) {

View File

@@ -188,7 +188,7 @@ class Contrat extends CommonObject
* *
* @param DoliDB $db Database handler * @param DoliDB $db Database handler
*/ */
function __construct($db) public function __construct($db)
{ {
$this->db = $db; $this->db = $db;
} }
@@ -199,7 +199,7 @@ class Contrat extends CommonObject
* @param Societe $soc Thirdparty object * @param Societe $soc Thirdparty object
* @return string free reference for contract * @return string free reference for contract
*/ */
function getNextNumRef($soc) public function getNextNumRef($soc)
{ {
global $db, $langs, $conf; global $db, $langs, $conf;
$langs->load("contracts"); $langs->load("contracts");
@@ -250,7 +250,7 @@ class Contrat extends CommonObject
} }
} }
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/** /**
* Activate a contract line * Activate a contract line
* *
@@ -261,7 +261,7 @@ class Contrat extends CommonObject
* @param string $comment A comment typed by user * @param string $comment A comment typed by user
* @return int <0 if KO, >0 if OK * @return int <0 if KO, >0 if OK
*/ */
function active_line($user, $line_id, $date, $date_end = '', $comment = '') public function active_line($user, $line_id, $date, $date_end = '', $comment = '')
{ {
// phpcs:enable // phpcs:enable
$result = $this->lines[$this->lines_id_index_mapper[$line_id]]->active_line($user, $date, $date_end, $comment); $result = $this->lines[$this->lines_id_index_mapper[$line_id]]->active_line($user, $date, $date_end, $comment);
@@ -274,7 +274,7 @@ class Contrat extends CommonObject
} }
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/** /**
* Close a contract line * Close a contract line
* *
@@ -284,7 +284,7 @@ class Contrat extends CommonObject
* @param string $comment A comment typed by user * @param string $comment A comment typed by user
* @return int <0 if KO, >0 if OK * @return int <0 if KO, >0 if OK
*/ */
function close_line($user, $line_id, $date_end, $comment = '') public function close_line($user, $line_id, $date_end, $comment = '')
{ {
// phpcs:enable // phpcs:enable
$result=$this->lines[$this->lines_id_index_mapper[$line_id]]->close_line($user, $date_end, $comment); $result=$this->lines[$this->lines_id_index_mapper[$line_id]]->close_line($user, $date_end, $comment);
@@ -307,7 +307,7 @@ class Contrat extends CommonObject
* @return int <0 if KO, >0 if OK * @return int <0 if KO, >0 if OK
* @see closeAll * @see closeAll
*/ */
function activateAll($user, $date_start = '', $notrigger = 0, $comment = '') public function activateAll($user, $date_start = '', $notrigger = 0, $comment = '')
{ {
if (empty($date_start)) $date_start = dol_now(); if (empty($date_start)) $date_start = dol_now();
@@ -363,7 +363,7 @@ class Contrat extends CommonObject
* @return int <0 if KO, >0 if OK * @return int <0 if KO, >0 if OK
* @see activateAll * @see activateAll
*/ */
function closeAll(User $user, $notrigger = 0, $comment = '') public function closeAll(User $user, $notrigger = 0, $comment = '')
{ {
$this->db->begin(); $this->db->begin();
@@ -419,7 +419,7 @@ class Contrat extends CommonObject
* @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @param int $notrigger 1=Does not execute triggers, 0= execute triggers
* @return int <0 if KO, >0 if OK * @return int <0 if KO, >0 if OK
*/ */
function validate(User $user, $force_number = '', $notrigger = 0) public function validate(User $user, $force_number = '', $notrigger = 0)
{ {
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
global $langs, $conf; global $langs, $conf;
@@ -547,7 +547,7 @@ class Contrat extends CommonObject
* @param int $notrigger 1=Does not execute triggers, 0=execute triggers * @param int $notrigger 1=Does not execute triggers, 0=execute triggers
* @return int <0 if KO, >0 if OK * @return int <0 if KO, >0 if OK
*/ */
function reopen($user, $notrigger = 0) public function reopen($user, $notrigger = 0)
{ {
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
global $langs, $conf; global $langs, $conf;
@@ -614,7 +614,7 @@ class Contrat extends CommonObject
* @param string $ref_supplier Supplier ref * @param string $ref_supplier Supplier ref
* @return int <0 if KO, 0 if not found, Id of contract if OK * @return int <0 if KO, 0 if not found, Id of contract if OK
*/ */
function fetch($id, $ref = '', $ref_customer = '', $ref_supplier = '') public function fetch($id, $ref = '', $ref_customer = '', $ref_supplier = '')
{ {
$sql = "SELECT rowid, statut, ref, fk_soc, mise_en_service as datemise,"; $sql = "SELECT rowid, statut, ref, fk_soc, mise_en_service as datemise,";
$sql.= " ref_supplier, ref_customer,"; $sql.= " ref_supplier, ref_customer,";
@@ -665,7 +665,7 @@ class Contrat extends CommonObject
$this->user_author_id = $obj->fk_user_author; $this->user_author_id = $obj->fk_user_author;
$this->commercial_signature_id = $obj->fk_commercial_signature; $this->commercial_signature_id = $obj->fk_commercial_signature;
$this->commercial_suivi_id = $obj->fk_commercial_suivi; $this->commercial_suivi_id = $obj->fk_commercial_suivi;
$this->note_private = $obj->note_private; $this->note_private = $obj->note_private;
@@ -678,7 +678,7 @@ class Contrat extends CommonObject
$this->socid = $obj->fk_soc; $this->socid = $obj->fk_soc;
$this->fk_soc = $obj->fk_soc; $this->fk_soc = $obj->fk_soc;
$this->extraparams = (array) json_decode($obj->extraparams, true); $this->extraparams = (array) json_decode($obj->extraparams, true);
$this->db->free($resql); $this->db->free($resql);
@@ -711,14 +711,14 @@ class Contrat extends CommonObject
} }
} }
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/** /**
* Load lines array into this->lines. * Load lines array into this->lines.
* This set also nbofserviceswait, nbofservicesopened, nbofservicesexpired and nbofservicesclosed * This set also nbofserviceswait, nbofservicesopened, nbofservicesexpired and nbofservicesclosed
* *
* @return ContratLigne[] Return array of contract lines * @return ContratLigne[] Return array of contract lines
*/ */
function fetch_lines() public function fetch_lines()
{ {
// phpcs:enable // phpcs:enable
$this->nbofserviceswait=0; $this->nbofserviceswait=0;
@@ -768,7 +768,7 @@ class Contrat extends CommonObject
while ($i < $num) while ($i < $num)
{ {
$objp = $this->db->fetch_object($result); $objp = $this->db->fetch_object($result);
$line = new ContratLigne($this->db); $line = new ContratLigne($this->db);
$line->id = $objp->rowid; $line->id = $objp->rowid;
@@ -829,7 +829,7 @@ class Contrat extends CommonObject
// fetch optionals attributes and labels // fetch optionals attributes and labels
$line->fetch_optionals(); $line->fetch_optionals();
$this->lines[$pos] = $line; $this->lines[$pos] = $line;
$this->lines_id_index_mapper[$line->id] = $pos; $this->lines_id_index_mapper[$line->id] = $pos;
//dol_syslog("1 ".$line->desc); //dol_syslog("1 ".$line->desc);
@@ -869,7 +869,7 @@ class Contrat extends CommonObject
* @param User $user User that create * @param User $user User that create
* @return int <0 if KO, id of contract if OK * @return int <0 if KO, id of contract if OK
*/ */
function create($user) public function create($user)
{ {
global $conf,$langs,$mysoc; global $conf,$langs,$mysoc;
@@ -1088,7 +1088,7 @@ class Contrat extends CommonObject
* @param User $user Utilisateur qui supprime * @param User $user Utilisateur qui supprime
* @return int < 0 si erreur, > 0 si ok * @return int < 0 si erreur, > 0 si ok
*/ */
function delete($user) public function delete($user)
{ {
global $conf, $langs; global $conf, $langs;
require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php';
@@ -1242,7 +1242,7 @@ class Contrat extends CommonObject
* @param int $notrigger 0=launch triggers after, 1=disable triggers * @param int $notrigger 0=launch triggers after, 1=disable triggers
* @return int <0 if KO, >0 if OK * @return int <0 if KO, >0 if OK
*/ */
function update($user, $notrigger = 0) public function update($user, $notrigger = 0)
{ {
global $conf, $langs; global $conf, $langs;
$error=0; $error=0;
@@ -1360,7 +1360,7 @@ class Contrat extends CommonObject
* @param string $rang Position * @param string $rang Position
* @return int <0 if KO, >0 if OK * @return int <0 if KO, >0 if OK
*/ */
function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1, $txlocaltax2, $fk_product, $remise_percent, $date_start, $date_end, $price_base_type = 'HT', $pu_ttc = 0.0, $info_bits = 0, $fk_fournprice = null, $pa_ht = 0, $array_options = 0, $fk_unit = null, $rang = 0) public function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1, $txlocaltax2, $fk_product, $remise_percent, $date_start, $date_end, $price_base_type = 'HT', $pu_ttc = 0.0, $info_bits = 0, $fk_fournprice = null, $pa_ht = 0, $array_options = 0, $fk_unit = null, $rang = 0)
{ {
global $user, $langs, $conf, $mysoc; global $user, $langs, $conf, $mysoc;
$error=0; $error=0;
@@ -1570,7 +1570,7 @@ class Contrat extends CommonObject
* @param string $fk_unit Code of the unit to use. Null to use the default one * @param string $fk_unit Code of the unit to use. Null to use the default one
* @return int < 0 si erreur, > 0 si ok * @return int < 0 si erreur, > 0 si ok
*/ */
function updateline($rowid, $desc, $pu, $qty, $remise_percent, $date_start, $date_end, $tvatx, $localtax1tx = 0.0, $localtax2tx = 0.0, $date_debut_reel = '', $date_fin_reel = '', $price_base_type = 'HT', $info_bits = 0, $fk_fournprice = null, $pa_ht = 0, $array_options = 0, $fk_unit = null) public function updateline($rowid, $desc, $pu, $qty, $remise_percent, $date_start, $date_end, $tvatx, $localtax1tx = 0.0, $localtax2tx = 0.0, $date_debut_reel = '', $date_fin_reel = '', $price_base_type = 'HT', $info_bits = 0, $fk_fournprice = null, $pa_ht = 0, $array_options = 0, $fk_unit = null)
{ {
global $user, $conf, $langs, $mysoc; global $user, $conf, $langs, $mysoc;
@@ -1647,21 +1647,21 @@ class Contrat extends CommonObject
} }
$sql = "UPDATE ".MAIN_DB_PREFIX."contratdet set description='".$this->db->escape($desc)."'"; $sql = "UPDATE ".MAIN_DB_PREFIX."contratdet set description='".$this->db->escape($desc)."'";
$sql.= ",price_ht='" . price2num($price)."'"; $sql.= ",price_ht='".price2num($price)."'";
$sql.= ",subprice='" . price2num($subprice)."'"; $sql.= ",subprice='".price2num($subprice)."'";
$sql.= ",remise='" . price2num($remise)."'"; $sql.= ",remise='".price2num($remise)."'";
$sql.= ",remise_percent='".price2num($remise_percent)."'"; $sql.= ",remise_percent='".price2num($remise_percent)."'";
$sql.= ",qty='".$qty."'"; $sql.= ",qty='".$qty."'";
$sql.= ",tva_tx='". price2num($tvatx)."'"; $sql.= ",tva_tx='".price2num($tvatx)."'";
$sql.= ",localtax1_tx='". price2num($localtax1tx)."'"; $sql.= ",localtax1_tx='".price2num($localtax1tx)."'";
$sql.= ",localtax2_tx='". price2num($localtax2tx)."'"; $sql.= ",localtax2_tx='".price2num($localtax2tx)."'";
$sql.= ",localtax1_type='".$localtax1_type."'"; $sql.= ",localtax1_type='".$localtax1_type."'";
$sql.= ",localtax2_type='".$localtax2_type."'"; $sql.= ",localtax2_type='".$localtax2_type."'";
$sql.= ", total_ht='". price2num($total_ht)."'"; $sql.= ", total_ht='".price2num($total_ht)."'";
$sql.= ", total_tva='". price2num($total_tva)."'"; $sql.= ", total_tva='".price2num($total_tva)."'";
$sql.= ", total_localtax1='".price2num($total_localtax1)."'"; $sql.= ", total_localtax1='".price2num($total_localtax1)."'";
$sql.= ", total_localtax2='".price2num($total_localtax2)."'"; $sql.= ", total_localtax2='".price2num($total_localtax2)."'";
$sql.= ", total_ttc='". price2num($total_ttc)."'"; $sql.= ", total_ttc='".price2num($total_ttc)."'";
$sql.= ", fk_product_fournisseur_price=".($fk_fournprice > 0 ? $fk_fournprice : "null"); $sql.= ", fk_product_fournisseur_price=".($fk_fournprice > 0 ? $fk_fournprice : "null");
$sql.= ", buy_price_ht='".price2num($pa_ht)."'"; $sql.= ", buy_price_ht='".price2num($pa_ht)."'";
if ($date_start > 0) { $sql.= ",date_ouverture_prevue='".$this->db->idate($date_start)."'"; } if ($date_start > 0) { $sql.= ",date_ouverture_prevue='".$this->db->idate($date_start)."'"; }
@@ -1733,7 +1733,7 @@ class Contrat extends CommonObject
* @param User $user User that delete * @param User $user User that delete
* @return int >0 if OK, <0 if KO * @return int >0 if OK, <0 if KO
*/ */
function deleteline($idline, User $user) public function deleteline($idline, User $user)
{ {
global $conf, $langs; global $conf, $langs;
@@ -1792,7 +1792,7 @@ class Contrat extends CommonObject
} }
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/** /**
* Update statut of contract according to services * Update statut of contract according to services
* *
@@ -1800,7 +1800,7 @@ class Contrat extends CommonObject
* @return int <0 if KO, >0 if OK * @return int <0 if KO, >0 if OK
* @deprecated This function will never be used. Status of a contract is status of its lines. * @deprecated This function will never be used. Status of a contract is status of its lines.
*/ */
function update_statut($user) public function update_statut($user)
{ {
// phpcs:enable // phpcs:enable
dol_syslog(__METHOD__ . " is deprecated", LOG_WARNING); dol_syslog(__METHOD__ . " is deprecated", LOG_WARNING);
@@ -1811,11 +1811,11 @@ class Contrat extends CommonObject
// Load $this->lines array // Load $this->lines array
// $this->fetch_lines(); // $this->fetch_lines();
// $newstatut=1; // $newstatut=1;
// foreach($this->lines as $key => $contractline) // foreach($this->lines as $key => $contractline)
// { // {
// // if ($contractline) // Loop on each service // // if ($contractline) // Loop on each service
// } // }
return 1; return 1;
} }
@@ -1827,7 +1827,7 @@ class Contrat extends CommonObject
* @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Long label of all services, 5=Libelle court + Picto, 6=Picto of all services, 7=Same than 6 with fixed length * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Long label of all services, 5=Libelle court + Picto, 6=Picto of all services, 7=Same than 6 with fixed length
* @return string Label * @return string Label
*/ */
function getLibStatut($mode) public function getLibStatut($mode)
{ {
return $this->LibStatut($this->statut, $mode); return $this->LibStatut($this->statut, $mode);
} }
@@ -1840,7 +1840,7 @@ class Contrat extends CommonObject
* @param int $mode 0=Long label, 1=Short label, 2=Picto + Libelle court, 3=Picto, 4=Picto + Long label of all services, 5=Libelle court + Picto, 6=Picto of all services, 7=Same than 6 with fixed length * @param int $mode 0=Long label, 1=Short label, 2=Picto + Libelle court, 3=Picto, 4=Picto + Long label of all services, 5=Libelle court + Picto, 6=Picto of all services, 7=Same than 6 with fixed length
* @return string Label * @return string Label
*/ */
function LibStatut($statut, $mode) public function LibStatut($statut, $mode)
{ {
// phpcs:enable // phpcs:enable
global $langs; global $langs;
@@ -1872,8 +1872,7 @@ class Contrat extends CommonObject
elseif ($mode == 4 || $mode == 6 || $mode == 7) elseif ($mode == 4 || $mode == 6 || $mode == 7)
{ {
$text=''; $text='';
if ($mode == 4) if ($mode == 4) {
{
$text ='<span class="hideonsmartphone">'; $text ='<span class="hideonsmartphone">';
$text.=($this->nbofserviceswait+$this->nbofservicesopened+$this->nbofservicesexpired+$this->nbofservicesclosed); $text.=($this->nbofserviceswait+$this->nbofservicesopened+$this->nbofservicesexpired+$this->nbofservicesclosed);
$text.=' '.$langs->trans("Services"); $text.=' '.$langs->trans("Services");
@@ -1909,7 +1908,7 @@ class Contrat extends CommonObject
* @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 Chaine avec URL * @return string Chaine avec URL
*/ */
function getNomUrl($withpicto = 0, $maxlength = 0, $notooltip = 0, $save_lastsearch_value = -1) public function getNomUrl($withpicto = 0, $maxlength = 0, $notooltip = 0, $save_lastsearch_value = -1)
{ {
global $conf, $langs, $user; global $conf, $langs, $user;
@@ -1973,7 +1972,7 @@ class Contrat extends CommonObject
* @param int $id id du contrat a charger * @param int $id id du contrat a charger
* @return void * @return void
*/ */
function info($id) public function info($id)
{ {
$sql = "SELECT c.rowid, c.ref, c.datec, c.date_cloture,"; $sql = "SELECT c.rowid, c.ref, c.datec, c.date_cloture,";
$sql.= " c.tms as date_modification,"; $sql.= " c.tms as date_modification,";
@@ -2022,7 +2021,7 @@ class Contrat extends CommonObject
* @param int $statut Status of lines to get * @param int $statut Status of lines to get
* @return array Array of line's rowid * @return array Array of line's rowid
*/ */
function array_detail($statut = -1) public function array_detail($statut = -1)
{ {
// phpcs:enable // phpcs:enable
$tab=array(); $tab=array();
@@ -2059,7 +2058,7 @@ class Contrat extends CommonObject
* @param string $option 'all' or 'others' * @param string $option 'all' or 'others'
* @return array Array of contracts id * @return array Array of contracts id
*/ */
function getListOfContracts($option = 'all') public function getListOfContracts($option = 'all')
{ {
$tab=array(); $tab=array();
@@ -2092,7 +2091,7 @@ class Contrat extends CommonObject
} }
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/** /**
* Load indicators for dashboard (this->nbtodo and this->nbtodolate) * Load indicators for dashboard (this->nbtodo and this->nbtodolate)
* *
@@ -2100,7 +2099,7 @@ class Contrat extends CommonObject
* @param string $mode "inactive" pour services a activer, "expired" pour services expires * @param string $mode "inactive" pour services a activer, "expired" pour services expires
* @return WorkboardResponse|int <0 if KO, WorkboardResponse if OK * @return WorkboardResponse|int <0 if KO, WorkboardResponse if OK
*/ */
function load_board($user, $mode) public function load_board($user, $mode)
{ {
// phpcs:enable // phpcs:enable
global $conf, $langs; global $conf, $langs;
@@ -2172,13 +2171,13 @@ class Contrat extends CommonObject
} }
} }
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/** /**
* Charge indicateurs this->nb de tableau de bord * Charge indicateurs this->nb de tableau de bord
* *
* @return int <0 si ko, >0 si ok * @return int <0 si ko, >0 si ok
*/ */
function load_state_board() public function load_state_board()
{ {
// phpcs:enable // phpcs:enable
global $conf, $user; global $conf, $user;
@@ -2223,7 +2222,7 @@ class Contrat extends CommonObject
* *
* @return array Liste des id contacts facturation * @return array Liste des id contacts facturation
*/ */
function getIdBillingContact() public function getIdBillingContact()
{ {
return $this->getIdContact('external', 'BILLING'); return $this->getIdContact('external', 'BILLING');
} }
@@ -2233,7 +2232,7 @@ class Contrat extends CommonObject
* *
* @return array Liste des id contacts prestation * @return array Liste des id contacts prestation
*/ */
function getIdServiceContact() public function getIdServiceContact()
{ {
return $this->getIdContact('external', 'SERVICE'); return $this->getIdContact('external', 'SERVICE');
} }
@@ -2245,9 +2244,9 @@ class Contrat extends CommonObject
* id must be 0 if object instance is a specimen. * id must be 0 if object instance is a specimen.
* *
* @return void * @return void
*/ */
function initAsSpecimen() public function initAsSpecimen()
{ {
global $user,$langs,$conf; global $user,$langs,$conf;
// Load array of products prodids // Load array of products prodids
@@ -2319,7 +2318,7 @@ class Contrat extends CommonObject
* *
* @return int >0 if OK, <0 if KO * @return int >0 if OK, <0 if KO
*/ */
function getLinesArray() public function getLinesArray()
{ {
return $this->fetch_lines(); return $this->fetch_lines();
} }
@@ -2382,7 +2381,7 @@ class Contrat extends CommonObject
* @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @param int $notrigger 1=Does not execute triggers, 0= execute triggers
* @return int New id of clone * @return int New id of clone
*/ */
function createFromClone($socid = 0, $notrigger = 0) public function createFromClone($socid = 0, $notrigger = 0)
{ {
global $db, $user, $langs, $conf, $hookmanager, $extrafields; global $db, $user, $langs, $conf, $hookmanager, $extrafields;
@@ -2631,7 +2630,7 @@ class ContratLigne extends CommonObjectLine
* *
* @param DoliDb $db Database handler * @param DoliDb $db Database handler
*/ */
function __construct($db) public function __construct($db)
{ {
$this->db = $db; $this->db = $db;
} }
@@ -2643,12 +2642,12 @@ class ContratLigne extends CommonObjectLine
* @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto
* @return string Libelle * @return string Libelle
*/ */
function getLibStatut($mode) public function getLibStatut($mode)
{ {
return $this->LibStatut($this->statut, $mode, ((! empty($this->date_fin_validite))?($this->date_fin_validite < dol_now()?1:0):-1)); return $this->LibStatut($this->statut, $mode, ((! empty($this->date_fin_validite))?($this->date_fin_validite < dol_now()?1:0):-1));
} }
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/** /**
* Return label of a contract line status * Return label of a contract line status
* *
@@ -2658,7 +2657,7 @@ class ContratLigne extends CommonObjectLine
* @param string $moreatt More attribute * @param string $moreatt More attribute
* @return string Libelle * @return string Libelle
*/ */
static function LibStatut($statut, $mode, $expired = -1, $moreatt = '') public static function LibStatut($statut, $mode, $expired = -1, $moreatt = '')
{ {
// phpcs:enable // phpcs:enable
global $langs; global $langs;
@@ -2720,7 +2719,7 @@ class ContratLigne extends CommonObjectLine
* @param int $maxlength Max length * @param int $maxlength Max length
* @return string Chaine avec URL * @return string Chaine avec URL
*/ */
function getNomUrl($withpicto = 0, $maxlength = 0) public function getNomUrl($withpicto = 0, $maxlength = 0)
{ {
global $langs; global $langs;
@@ -2741,13 +2740,13 @@ class ContratLigne extends CommonObjectLine
} }
/** /**
* Load object in memory from database * Load object in memory from database
* *
* @param int $id Id object * @param int $id Id object
* @param string $ref Ref of contract * @param string $ref Ref of contract
* @return int <0 if KO, >0 if OK * @return int <0 if KO, >0 if OK
*/ */
function fetch($id, $ref = '') public function fetch($id, $ref = '')
{ {
// Check parameters // Check parameters
@@ -2879,7 +2878,7 @@ class ContratLigne extends CommonObjectLine
* @param int $notrigger 0=no, 1=yes (no update trigger) * @param int $notrigger 0=no, 1=yes (no update trigger)
* @return int <0 if KO, >0 if OK * @return int <0 if KO, >0 if OK
*/ */
function update($user, $notrigger = 0) public function update($user, $notrigger = 0)
{ {
global $conf, $langs, $mysoc; global $conf, $langs, $mysoc;
@@ -3070,14 +3069,14 @@ class ContratLigne extends CommonObjectLine
} }
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/** /**
* Mise a jour en base des champs total_xxx de ligne * Mise a jour en base des champs total_xxx de ligne
* Used by migration process * Used by migration process
* *
* @return int <0 if KO, >0 if OK * @return int <0 if KO, >0 if OK
*/ */
function update_total() public function update_total()
{ {
// phpcs:enable // phpcs:enable
$this->db->begin(); $this->db->begin();
@@ -3188,7 +3187,7 @@ class ContratLigne extends CommonObjectLine
} }
} }
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/** /**
* Activate a contract line * Activate a contract line
* *
@@ -3198,7 +3197,7 @@ class ContratLigne extends CommonObjectLine
* @param string $comment A comment typed by user * @param string $comment A comment typed by user
* @return int <0 if KO, >0 if OK * @return int <0 if KO, >0 if OK
*/ */
function active_line($user, $date, $date_end = '', $comment = '') public function active_line($user, $date, $date_end = '', $comment = '')
{ {
// phpcs:enable // phpcs:enable
global $langs, $conf; global $langs, $conf;
@@ -3247,7 +3246,7 @@ class ContratLigne extends CommonObjectLine
} }
} }
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/** /**
* Close a contract line * Close a contract line
* *
@@ -3257,7 +3256,7 @@ class ContratLigne extends CommonObjectLine
* @param int $notrigger 1=Does not execute triggers, 0=Execute triggers * @param int $notrigger 1=Does not execute triggers, 0=Execute triggers
* @return int <0 if KO, >0 if OK * @return int <0 if KO, >0 if OK
*/ */
function close_line($user, $date_end, $comment = '', $notrigger = 0) public function close_line($user, $date_end, $comment = '', $notrigger = 0)
{ {
// phpcs:enable // phpcs:enable
global $langs, $conf; global $langs, $conf;

View File

@@ -61,7 +61,7 @@ class mod_barcode_product_standard extends ModeleNumRefBarCode
/** /**
* Constructor * Constructor
*/ */
function __construct() public function __construct()
{ {
$this->code_null = 0; $this->code_null = 0;
$this->code_modifiable = 1; $this->code_modifiable = 1;
@@ -77,7 +77,7 @@ class mod_barcode_product_standard extends ModeleNumRefBarCode
* @param Translate $langs Object langs * @param Translate $langs Object langs
* @return string Description of module * @return string Description of module
*/ */
function info($langs) public function info($langs)
{ {
global $conf, $mc; global $conf, $mc;
global $form; global $form;
@@ -119,7 +119,7 @@ class mod_barcode_product_standard extends ModeleNumRefBarCode
* @param Product $objproduct Object product * @param Product $objproduct Object product
* @return string Return string example * @return string Return string example
*/ */
function getExample($langs, $objproduct = 0) public function getExample($langs, $objproduct = 0)
{ {
$examplebarcode = $this->getNextValue($objproduct, ''); $examplebarcode = $this->getNextValue($objproduct, '');
if (! $examplebarcode) if (! $examplebarcode)
@@ -142,7 +142,7 @@ class mod_barcode_product_standard extends ModeleNumRefBarCode
* @param string $type Type of barcode (EAN, ISBN, ...) * @param string $type Type of barcode (EAN, ISBN, ...)
* @return string Value if OK, '' if module not configured, <0 if KO * @return string Value if OK, '' if module not configured, <0 if KO
*/ */
function getNextValue($objproduct = null, $type = '') public function getNextValue($objproduct = null, $type = '')
{ {
global $db,$conf; global $db,$conf;
@@ -184,7 +184,7 @@ class mod_barcode_product_standard extends ModeleNumRefBarCode
* -3 ErrorCustomerCodeAlreadyUsed * -3 ErrorCustomerCodeAlreadyUsed
* -4 ErrorPrefixRequired * -4 ErrorPrefixRequired
*/ */
function verif($db, &$code, $product, $thirdparty_type, $type) public function verif($db, &$code, $product, $thirdparty_type, $type)
{ {
global $conf; global $conf;
@@ -235,7 +235,7 @@ class mod_barcode_product_standard extends ModeleNumRefBarCode
} }
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/** /**
* Return if a code is used (by other element) * Return if a code is used (by other element)
* *
@@ -244,7 +244,7 @@ class mod_barcode_product_standard extends ModeleNumRefBarCode
* @param Product $product Objet product * @param Product $product Objet product
* @return int 0 if available, <0 if KO * @return int 0 if available, <0 if KO
*/ */
function verif_dispo($db, $code, $product) public function verif_dispo($db, $code, $product)
{ {
// phpcs:enable // phpcs:enable
$sql = "SELECT barcode FROM ".MAIN_DB_PREFIX."product"; $sql = "SELECT barcode FROM ".MAIN_DB_PREFIX."product";
@@ -269,7 +269,7 @@ class mod_barcode_product_standard extends ModeleNumRefBarCode
} }
} }
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/** /**
* Return if a barcode value match syntax * Return if a barcode value match syntax
* *
@@ -277,7 +277,7 @@ class mod_barcode_product_standard extends ModeleNumRefBarCode
* @param string $typefortest Type of barcode (ISBN, EAN, ...) * @param string $typefortest Type of barcode (ISBN, EAN, ...)
* @return int 0 if OK, <0 if KO * @return int 0 if OK, <0 if KO
*/ */
function verif_syntax($codefortest, $typefortest) public function verif_syntax($codefortest, $typefortest)
{ {
// phpcs:enable // phpcs:enable
global $conf; global $conf;
@@ -296,15 +296,15 @@ class mod_barcode_product_standard extends ModeleNumRefBarCode
$newcodefortest=$codefortest; $newcodefortest=$codefortest;
// Special case, if mask is on 12 digits instead of 13, we remove last char into code to test // Special case, if mask is on 12 digits instead of 13, we remove last char into code to test
if (in_array($typefortest, array('EAN13','ISBN'))) // We remove the CRC char not included into mask if (in_array($typefortest, array('EAN13','ISBN'))) // We remove the CRC char not included into mask
{ {
if (preg_match('/\{(0+)([@\+][0-9]+)?([@\+][0-9]+)?\}/i', $mask, $reg)) if (preg_match('/\{(0+)([@\+][0-9]+)?([@\+][0-9]+)?\}/i', $mask, $reg))
{ {
if (strlen($reg[1]) == 12) $newcodefortest=substr($newcodefortest, 0, 12); if (strlen($reg[1]) == 12) $newcodefortest=substr($newcodefortest, 0, 12);
dol_syslog(get_class($this).'::verif_syntax newcodefortest='.$newcodefortest); dol_syslog(get_class($this).'::verif_syntax newcodefortest='.$newcodefortest);
} }
} }
$result=check_value($mask, $newcodefortest); $result=check_value($mask, $newcodefortest);
if (is_string($result)) if (is_string($result))

View File

@@ -50,7 +50,7 @@ class mod_chequereceipt_mint extends ModeleNumRefChequeReceipts
* *
* @return string Text with description * @return string Text with description
*/ */
function info() public function info()
{ {
global $langs; global $langs;
return $langs->trans("SimpleNumRefModelDesc", $this->prefix); return $langs->trans("SimpleNumRefModelDesc", $this->prefix);
@@ -62,7 +62,7 @@ class mod_chequereceipt_mint extends ModeleNumRefChequeReceipts
* *
* @return string Example * @return string Example
*/ */
function getExample() public function getExample()
{ {
return $this->prefix."0501-0001"; return $this->prefix."0501-0001";
} }
@@ -74,7 +74,7 @@ class mod_chequereceipt_mint extends ModeleNumRefChequeReceipts
* *
* @return boolean false si conflit, true si ok * @return boolean false si conflit, true si ok
*/ */
function canBeActivated() public function canBeActivated()
{ {
global $conf,$langs,$db; global $conf,$langs,$db;
@@ -109,7 +109,7 @@ class mod_chequereceipt_mint extends ModeleNumRefChequeReceipts
* @param Object $object Object we need next value for * @param Object $object Object we need next value for
* @return string Value if KO, <0 if KO * @return string Value if KO, <0 if KO
*/ */
function getNextValue($objsoc, $object) public function getNextValue($objsoc, $object)
{ {
global $db,$conf; global $db,$conf;
@@ -153,7 +153,7 @@ class mod_chequereceipt_mint extends ModeleNumRefChequeReceipts
* @param string $objforref Object for number to search * @param string $objforref Object for number to search
* @return string Next free value * @return string Next free value
*/ */
function chequereceipt_get_num($objsoc, $objforref) public function chequereceipt_get_num($objsoc, $objforref)
{ {
// phpcs:enable // phpcs:enable
return $this->getNextValue($objsoc, $objforref); return $this->getNextValue($objsoc, $objforref);

View File

@@ -49,7 +49,7 @@ class mod_chequereceipt_thyme extends ModeleNumRefChequeReceipts
* *
* @return string Texte descripif * @return string Texte descripif
*/ */
function info() public function info()
{ {
global $conf, $langs; global $conf, $langs;
@@ -89,7 +89,7 @@ class mod_chequereceipt_thyme extends ModeleNumRefChequeReceipts
* *
* @return string Example * @return string Example
*/ */
function getExample() public function getExample()
{ {
global $conf,$langs,$mysoc; global $conf,$langs,$mysoc;
@@ -112,7 +112,7 @@ class mod_chequereceipt_thyme extends ModeleNumRefChequeReceipts
* @param Object $object Object we need next value for * @param Object $object Object we need next value for
* @return string Value if KO, <0 if KO * @return string Value if KO, <0 if KO
*/ */
function getNextValue($objsoc, $object) public function getNextValue($objsoc, $object)
{ {
global $db,$conf; global $db,$conf;
@@ -141,7 +141,7 @@ class mod_chequereceipt_thyme extends ModeleNumRefChequeReceipts
* @param string $objforref Object for number to search * @param string $objforref Object for number to search
* @return string Next free value * @return string Next free value
*/ */
function chequereceipt_get_num($objsoc, $objforref) public function chequereceipt_get_num($objsoc, $objforref)
{ {
// phpcs:enable // phpcs:enable
return $this->getNextValue($objsoc, $objforref); return $this->getNextValue($objsoc, $objforref);

View File

@@ -46,7 +46,7 @@ abstract class ModeleNumRefChequeReceipts
* *
* @return boolean true if module can be used * @return boolean true if module can be used
*/ */
function isEnabled() public function isEnabled()
{ {
return true; return true;
} }
@@ -56,7 +56,7 @@ abstract class ModeleNumRefChequeReceipts
* *
* @return string Texte descripif * @return string Texte descripif
*/ */
function info() public function info()
{ {
global $langs; global $langs;
$langs->load("bills"); $langs->load("bills");
@@ -68,7 +68,7 @@ abstract class ModeleNumRefChequeReceipts
* *
* @return string Example * @return string Example
*/ */
function getExample() public function getExample()
{ {
global $langs; global $langs;
$langs->load("bills"); $langs->load("bills");
@@ -80,7 +80,7 @@ abstract class ModeleNumRefChequeReceipts
* *
* @return boolean false si conflit, true si ok * @return boolean false si conflit, true si ok
*/ */
function canBeActivated() public function canBeActivated()
{ {
return true; return true;
} }
@@ -92,7 +92,7 @@ abstract class ModeleNumRefChequeReceipts
* @param Object $object Object we need next value for * @param Object $object Object we need next value for
* @return string Valeur * @return string Valeur
*/ */
function getNextValue($objsoc, $object) public function getNextValue($objsoc, $object)
{ {
global $langs; global $langs;
return $langs->trans("NotAvailable"); return $langs->trans("NotAvailable");
@@ -103,7 +103,7 @@ abstract class ModeleNumRefChequeReceipts
* *
* @return string Value * @return string Value
*/ */
function getVersion() public function getVersion()
{ {
global $langs; global $langs;
$langs->load("admin"); $langs->load("admin");
@@ -127,7 +127,7 @@ abstract class ModeleChequeReceipts extends CommonDocGenerator
*/ */
public $error=''; public $error='';
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/** /**
* Return list of active generation modules * Return list of active generation modules
* *
@@ -135,7 +135,7 @@ abstract class ModeleChequeReceipts extends CommonDocGenerator
* @param integer $maxfilenamelength Max length of value to show * @param integer $maxfilenamelength Max length of value to show
* @return array List of templates * @return array List of templates
*/ */
static function liste_modeles($db, $maxfilenamelength = 0) public static function liste_modeles($db, $maxfilenamelength = 0)
{ {
// phpcs:enable // phpcs:enable
global $conf; global $conf;
@@ -154,7 +154,7 @@ abstract class ModeleChequeReceipts extends CommonDocGenerator
/** /**
* Cree un bordereau remise de cheque * Cree un bordereau remise de cheque
* *
* @param DoliDB $db Database handler * @param DoliDB $db Database handler
* @param int $id Object invoice (or id of invoice) * @param int $id Object invoice (or id of invoice)

View File

@@ -60,7 +60,7 @@ class mod_commande_marbre extends ModeleNumRefCommandes
* *
* @return string Text with description * @return string Text with description
*/ */
function info() public function info()
{ {
global $langs; global $langs;
return $langs->trans("SimpleNumRefModelDesc", $this->prefix); return $langs->trans("SimpleNumRefModelDesc", $this->prefix);
@@ -72,7 +72,7 @@ class mod_commande_marbre extends ModeleNumRefCommandes
* *
* @return string Example * @return string Example
*/ */
function getExample() public function getExample()
{ {
return $this->prefix."0501-0001"; return $this->prefix."0501-0001";
} }
@@ -84,7 +84,7 @@ class mod_commande_marbre extends ModeleNumRefCommandes
* *
* @return boolean false si conflit, true si ok * @return boolean false si conflit, true si ok
*/ */
function canBeActivated() public function canBeActivated()
{ {
global $conf,$langs,$db; global $conf,$langs,$db;
@@ -119,7 +119,7 @@ class mod_commande_marbre extends ModeleNumRefCommandes
* @param Object $object Object we need next value for * @param Object $object Object we need next value for
* @return string Value if KO, <0 if KO * @return string Value if KO, <0 if KO
*/ */
function getNextValue($objsoc, $object) public function getNextValue($objsoc, $object)
{ {
global $db,$conf; global $db,$conf;
@@ -155,7 +155,7 @@ class mod_commande_marbre extends ModeleNumRefCommandes
} }
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/** /**
* Return next free value * Return next free value
* *
@@ -163,7 +163,7 @@ class mod_commande_marbre extends ModeleNumRefCommandes
* @param string $objforref Object for number to search * @param string $objforref Object for number to search
* @return string Next free value * @return string Next free value
*/ */
function commande_get_num($objsoc, $objforref) public function commande_get_num($objsoc, $objforref)
{ {
// phpcs:enable // phpcs:enable
return $this->getNextValue($objsoc, $objforref); return $this->getNextValue($objsoc, $objforref);

View File

@@ -62,7 +62,7 @@ class mod_commande_saphir extends ModeleNumRefCommandes
* *
* @return string Texte descripif * @return string Texte descripif
*/ */
function info() public function info()
{ {
global $conf, $langs; global $conf, $langs;
@@ -102,7 +102,7 @@ class mod_commande_saphir extends ModeleNumRefCommandes
* *
* @return string Example * @return string Example
*/ */
function getExample() public function getExample()
{ {
global $conf,$langs,$mysoc; global $conf,$langs,$mysoc;
@@ -128,7 +128,7 @@ class mod_commande_saphir extends ModeleNumRefCommandes
* @param Object $object Object we need next value for * @param Object $object Object we need next value for
* @return string Value if KO, <0 if KO * @return string Value if KO, <0 if KO
*/ */
function getNextValue($objsoc, $object) public function getNextValue($objsoc, $object)
{ {
global $db,$conf; global $db,$conf;
@@ -151,7 +151,7 @@ class mod_commande_saphir extends ModeleNumRefCommandes
} }
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/** /**
* Return next free value * Return next free value
* *
@@ -159,7 +159,7 @@ class mod_commande_saphir extends ModeleNumRefCommandes
* @param string $objforref Object for number to search * @param string $objforref Object for number to search
* @return string Next free value * @return string Next free value
*/ */
function commande_get_num($objsoc, $objforref) public function commande_get_num($objsoc, $objforref)
{ {
// phpcs:enable // phpcs:enable
return $this->getNextValue($objsoc, $objforref); return $this->getNextValue($objsoc, $objforref);

View File

@@ -40,7 +40,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php';
abstract class ModelePDFCommandes extends CommonDocGenerator abstract class ModelePDFCommandes extends CommonDocGenerator
{ {
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/** /**
* Return list of active generation modules * Return list of active generation modules
* *
@@ -48,7 +48,7 @@ abstract class ModelePDFCommandes extends CommonDocGenerator
* @param integer $maxfilenamelength Max length of value to show * @param integer $maxfilenamelength Max length of value to show
* @return array List of templates * @return array List of templates
*/ */
static function liste_modeles($db, $maxfilenamelength = 0) public static function liste_modeles($db, $maxfilenamelength = 0)
{ {
// phpcs:enable // phpcs:enable
global $conf; global $conf;
@@ -82,7 +82,7 @@ abstract class ModeleNumRefCommandes
* *
* @return boolean true if module can be used * @return boolean true if module can be used
*/ */
function isEnabled() public function isEnabled()
{ {
return true; return true;
} }
@@ -92,7 +92,7 @@ abstract class ModeleNumRefCommandes
* *
* @return string Texte descripif * @return string Texte descripif
*/ */
function info() public function info()
{ {
global $langs; global $langs;
$langs->load("orders"); $langs->load("orders");
@@ -104,7 +104,7 @@ abstract class ModeleNumRefCommandes
* *
* @return string Example * @return string Example
*/ */
function getExample() public function getExample()
{ {
global $langs; global $langs;
$langs->load("orders"); $langs->load("orders");
@@ -116,7 +116,7 @@ abstract class ModeleNumRefCommandes
* *
* @return boolean false si conflit, true si ok * @return boolean false si conflit, true si ok
*/ */
function canBeActivated() public function canBeActivated()
{ {
return true; return true;
} }
@@ -128,7 +128,7 @@ abstract class ModeleNumRefCommandes
* @param Object $object Object we need next value for * @param Object $object Object we need next value for
* @return string Valeur * @return string Valeur
*/ */
function getNextValue($objsoc, $object) public function getNextValue($objsoc, $object)
{ {
global $langs; global $langs;
return $langs->trans("NotAvailable"); return $langs->trans("NotAvailable");
@@ -139,7 +139,7 @@ abstract class ModeleNumRefCommandes
* *
* @return string Valeur * @return string Valeur
*/ */
function getVersion() public function getVersion()
{ {
global $langs; global $langs;
$langs->load("admin"); $langs->load("admin");

View File

@@ -59,7 +59,7 @@ class mod_contract_magre extends ModelNumRefContracts
* *
* @return string text description * @return string text description
*/ */
function info() public function info()
{ {
global $conf,$langs; global $conf,$langs;
@@ -95,7 +95,7 @@ class mod_contract_magre extends ModelNumRefContracts
* *
* @return string Example * @return string Example
*/ */
function getExample() public function getExample()
{ {
global $conf,$langs,$mysoc; global $conf,$langs,$mysoc;
@@ -118,7 +118,7 @@ class mod_contract_magre extends ModelNumRefContracts
* @param Object $contract contract object * @param Object $contract contract object
* @return string Value if OK, 0 if KO * @return string Value if OK, 0 if KO
*/ */
function getNextValue($objsoc, $contract) public function getNextValue($objsoc, $contract)
{ {
global $db,$conf; global $db,$conf;
@@ -145,7 +145,7 @@ class mod_contract_magre extends ModelNumRefContracts
* @param Object $objforref contract object * @param Object $objforref contract object
* @return string Value if OK, 0 if KO * @return string Value if OK, 0 if KO
*/ */
function contract_get_num($objsoc, $objforref) public function contract_get_num($objsoc, $objforref)
{ {
// phpcs:enable // phpcs:enable
return $this->getNextValue($objsoc, $objforref); return $this->getNextValue($objsoc, $objforref);

View File

@@ -66,7 +66,7 @@ class mod_contract_olive extends ModelNumRefContracts
* *
* @return string Description of module * @return string Description of module
*/ */
function info() public function info()
{ {
global $langs; global $langs;
@@ -81,7 +81,7 @@ class mod_contract_olive extends ModelNumRefContracts
* @param Contrat $contract Object contract * @param Contrat $contract Object contract
* @return string Return next value * @return string Return next value
*/ */
function getNextValue($objsoc, $contract) public function getNextValue($objsoc, $contract)
{ {
global $langs; global $langs;
return ''; return '';
@@ -101,7 +101,7 @@ class mod_contract_olive extends ModelNumRefContracts
* -3 ErrorProductCodeAlreadyUsed * -3 ErrorProductCodeAlreadyUsed
* -4 ErrorPrefixRequired * -4 ErrorPrefixRequired
*/ */
function verif($db, &$code, $product, $type) public function verif($db, &$code, $product, $type)
{ {
global $conf; global $conf;

View File

@@ -61,7 +61,7 @@ class mod_contract_serpis extends ModelNumRefContracts
* *
* @return string text description * @return string text description
*/ */
function info() public function info()
{ {
global $langs; global $langs;
return $langs->trans("SimpleNumRefModelDesc", $this->prefix); return $langs->trans("SimpleNumRefModelDesc", $this->prefix);
@@ -73,7 +73,7 @@ class mod_contract_serpis extends ModelNumRefContracts
* *
* @return string Example * @return string Example
*/ */
function getExample() public function getExample()
{ {
return $this->prefix."0501-0001"; return $this->prefix."0501-0001";
} }
@@ -84,7 +84,7 @@ class mod_contract_serpis extends ModelNumRefContracts
* *
* @return boolean false if conflit, true if ok * @return boolean false if conflit, true if ok
*/ */
function canBeActivated() public function canBeActivated()
{ {
global $conf,$langs,$db; global $conf,$langs,$db;
@@ -119,7 +119,7 @@ class mod_contract_serpis extends ModelNumRefContracts
* @param Object $contract contract object * @param Object $contract contract object
* @return string Value if OK, 0 if KO * @return string Value if OK, 0 if KO
*/ */
function getNextValue($objsoc, $contract) public function getNextValue($objsoc, $contract)
{ {
global $db,$conf; global $db,$conf;
@@ -153,7 +153,7 @@ class mod_contract_serpis extends ModelNumRefContracts
} }
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/** /**
* Return next value * Return next value
* *
@@ -161,7 +161,7 @@ class mod_contract_serpis extends ModelNumRefContracts
* @param Object $objforref contract object * @param Object $objforref contract object
* @return string Value if OK, 0 if KO * @return string Value if OK, 0 if KO
*/ */
function contract_get_num($objsoc, $objforref) public function contract_get_num($objsoc, $objforref)
{ {
// phpcs:enable // phpcs:enable
return $this->getNextValue($objsoc, $objforref); return $this->getNextValue($objsoc, $objforref);

View File

@@ -43,7 +43,7 @@ abstract class ModelePDFContract extends CommonDocGenerator
public $error=''; public $error='';
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/** /**
* Return list of active generation modules * Return list of active generation modules
* *
@@ -51,7 +51,7 @@ abstract class ModelePDFContract extends CommonDocGenerator
* @param integer $maxfilenamelength Max length of value to show * @param integer $maxfilenamelength Max length of value to show
* @return array List of templates * @return array List of templates
*/ */
static function liste_modeles($db, $maxfilenamelength = 0) public static function liste_modeles($db, $maxfilenamelength = 0)
{ {
// phpcs:enable // phpcs:enable
global $conf; global $conf;
@@ -82,7 +82,7 @@ class ModelNumRefContracts
* *
* @return boolean true if module can be used * @return boolean true if module can be used
*/ */
function isEnabled() public function isEnabled()
{ {
return true; return true;
} }
@@ -92,7 +92,7 @@ class ModelNumRefContracts
* *
* @return string text description * @return string text description
*/ */
function info() public function info()
{ {
global $langs; global $langs;
$langs->load("contracts"); $langs->load("contracts");
@@ -104,7 +104,7 @@ class ModelNumRefContracts
* *
* @return string Example * @return string Example
*/ */
function getExample() public function getExample()
{ {
global $langs; global $langs;
$langs->load("contracts"); $langs->load("contracts");
@@ -116,7 +116,7 @@ class ModelNumRefContracts
* *
* @return boolean false if conflict, true if ok * @return boolean false if conflict, true if ok
*/ */
function canBeActivated() public function canBeActivated()
{ {
return true; return true;
} }
@@ -128,7 +128,7 @@ class ModelNumRefContracts
* @param Object $contract contract object * @param Object $contract contract object
* @return string Value * @return string Value
*/ */
function getNextValue($objsoc, $contract) public function getNextValue($objsoc, $contract)
{ {
global $langs; global $langs;
return $langs->trans("NotAvailable"); return $langs->trans("NotAvailable");
@@ -139,7 +139,7 @@ class ModelNumRefContracts
* *
* @return string Value * @return string Value
*/ */
function getVersion() public function getVersion()
{ {
global $langs; global $langs;
$langs->load("admin"); $langs->load("admin");

View File

@@ -39,7 +39,7 @@ abstract class ModeleDon extends CommonDocGenerator
*/ */
public $error=''; public $error='';
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/** /**
* Return list of active generation modules * Return list of active generation modules
* *
@@ -47,7 +47,7 @@ abstract class ModeleDon extends CommonDocGenerator
* @param integer $maxfilenamelength Max length of value to show * @param integer $maxfilenamelength Max length of value to show
* @return array List of templates * @return array List of templates
*/ */
static function liste_modeles($db, $maxfilenamelength = 0) public static function liste_modeles($db, $maxfilenamelength = 0)
{ {
// phpcs:enable // phpcs:enable
global $conf; global $conf;
@@ -78,7 +78,7 @@ abstract class ModeleNumRefDons
* *
* @return boolean true if module can be used * @return boolean true if module can be used
*/ */
function isEnabled() public function isEnabled()
{ {
return true; return true;
} }
@@ -88,7 +88,7 @@ abstract class ModeleNumRefDons
* *
* @return string Texte descripif * @return string Texte descripif
*/ */
function info() public function info()
{ {
global $langs; global $langs;
$langs->load("bills"); $langs->load("bills");
@@ -100,7 +100,7 @@ abstract class ModeleNumRefDons
* *
* @return string Example * @return string Example
*/ */
function getExample() public function getExample()
{ {
global $langs; global $langs;
$langs->load("bills"); $langs->load("bills");
@@ -113,7 +113,7 @@ abstract class ModeleNumRefDons
* *
* @return boolean false si conflit, true si ok * @return boolean false si conflit, true si ok
*/ */
function canBeActivated() public function canBeActivated()
{ {
return true; return true;
} }
@@ -123,7 +123,7 @@ abstract class ModeleNumRefDons
* *
* @return string Valeur * @return string Valeur
*/ */
function getNextValue() public function getNextValue()
{ {
global $langs; global $langs;
return $langs->trans("NotAvailable"); return $langs->trans("NotAvailable");
@@ -134,7 +134,7 @@ abstract class ModeleNumRefDons
* *
* @return string Valeur * @return string Valeur
*/ */
function getVersion() public function getVersion()
{ {
global $langs; global $langs;
$langs->load("admin"); $langs->load("admin");

View File

@@ -37,7 +37,7 @@ class modAccounting extends DolibarrModules
* *
* @param DoliDB $db Database handler * @param DoliDB $db Database handler
*/ */
function __construct($db) public function __construct($db)
{ {
global $conf; global $conf;

View File

@@ -38,23 +38,23 @@ class modAdherent 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
*/ */
function __construct($db) public function __construct($db)
{ {
global $conf; global $conf;
$this->db = $db; $this->db = $db;
$this->numero = 310; $this->numero = 310;
$this->family = "hr"; $this->family = "hr";
$this->module_position = '55'; $this->module_position = '55';
// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
$this->name = preg_replace('/^mod/i', '', get_class($this)); $this->name = preg_replace('/^mod/i', '', get_class($this));
$this->description = "Management of members of a foundation or association"; $this->description = "Management of members of a foundation or association";
// Possible values for version are: 'development', 'experimental', 'dolibarr' or version // Possible values for version are: 'development', 'experimental', 'dolibarr' or version
$this->version = 'dolibarr'; $this->version = 'dolibarr';
$this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
$this->picto='user'; $this->picto='user';
@@ -67,9 +67,9 @@ class modAdherent extends DolibarrModules
// Dependencies // Dependencies
$this->hidden = false; // A condition to hide module $this->hidden = false; // A condition to hide module
$this->depends = array(); // List of module class names as string that must be enabled if this module is enabled $this->depends = array(); // List of module class names as string that must be enabled if this module is enabled
$this->requiredby = array(); // List of module ids to disable if this one is disabled $this->requiredby = array(); // List of module ids to disable if this one is disabled
$this->conflictwith = array('modMailmanSpip'); // List of module class names as string this module is in conflict with $this->conflictwith = array('modMailmanSpip'); // List of module class names as string this module is in conflict with
$this->langfiles = array("members","companies"); $this->langfiles = array("members","companies");
$this->phpmin = array(5,4); // Minimum version of PHP required by module $this->phpmin = array(5,4); // Minimum version of PHP required by module
@@ -248,9 +248,9 @@ class modAdherent extends DolibarrModules
$this->rights[$r][5] = 'creer'; $this->rights[$r][5] = 'creer';
// Menus // Menus
//------- //-------
$this->menu = 1; // This module add menu entries. They are coded into menu manager. $this->menu = 1; // This module add menu entries. They are coded into menu manager.
// Exports // Exports
@@ -269,36 +269,36 @@ class modAdherent extends DolibarrModules
$this->export_label[$r]='MembersAndSubscriptions'; $this->export_label[$r]='MembersAndSubscriptions';
$this->export_permission[$r]=array(array("adherent","export")); $this->export_permission[$r]=array(array("adherent","export"));
$this->export_fields_array[$r]=array( $this->export_fields_array[$r]=array(
'a.rowid'=>'Id','a.civility'=>"UserTitle",'a.lastname'=>"Lastname",'a.firstname'=>"Firstname",'a.login'=>"Login",'a.gender'=>"Gender",'a.morphy'=>'Nature', 'a.rowid'=>'Id','a.civility'=>"UserTitle",'a.lastname'=>"Lastname",'a.firstname'=>"Firstname",'a.login'=>"Login",'a.gender'=>"Gender",'a.morphy'=>'Nature',
'a.societe'=>'Company','a.address'=>"Address",'a.zip'=>"Zip",'a.town'=>"Town",'d.nom'=>"State",'co.code'=>"CountryCode",'co.label'=>"Country", 'a.societe'=>'Company','a.address'=>"Address",'a.zip'=>"Zip",'a.town'=>"Town",'d.nom'=>"State",'co.code'=>"CountryCode",'co.label'=>"Country",
'a.phone'=>"PhonePro",'a.phone_perso'=>"PhonePerso",'a.phone_mobile'=>"PhoneMobile",'a.email'=>"Email",'a.birth'=>"Birthday",'a.statut'=>"Status", 'a.phone'=>"PhonePro",'a.phone_perso'=>"PhonePerso",'a.phone_mobile'=>"PhoneMobile",'a.email'=>"Email",'a.birth'=>"Birthday",'a.statut'=>"Status",
'a.photo'=>"Photo",'a.note_public'=>"NotePublic",'a.note_private'=>"NotePrivate",'a.datec'=>'DateCreation','a.datevalid'=>'DateValidation', 'a.photo'=>"Photo",'a.note_public'=>"NotePublic",'a.note_private'=>"NotePrivate",'a.datec'=>'DateCreation','a.datevalid'=>'DateValidation',
'a.tms'=>'DateLastModification','a.datefin'=>'DateEndSubscription','ta.rowid'=>'MemberTypeId','ta.libelle'=>'MemberTypeLabel', 'a.tms'=>'DateLastModification','a.datefin'=>'DateEndSubscription','ta.rowid'=>'MemberTypeId','ta.libelle'=>'MemberTypeLabel',
'c.rowid'=>'SubscriptionId','c.dateadh'=>'DateSubscription','c.subscription'=>'Amount' 'c.rowid'=>'SubscriptionId','c.dateadh'=>'DateSubscription','c.subscription'=>'Amount'
); );
$this->export_TypeFields_array[$r]=array( $this->export_TypeFields_array[$r]=array(
'a.civility'=>"Text",'a.lastname'=>"Text",'a.firstname'=>"Text",'a.login'=>"Text",'a.gender'=>'Text','a.morphy'=>'Text','a.societe'=>'Text','a.address'=>"Text", 'a.civility'=>"Text",'a.lastname'=>"Text",'a.firstname'=>"Text",'a.login'=>"Text",'a.gender'=>'Text','a.morphy'=>'Text','a.societe'=>'Text','a.address'=>"Text",
'a.zip'=>"Text",'a.town'=>"Text",'d.nom'=>"Text",'co.code'=>'Text','co.label'=>"Text",'a.phone'=>"Text",'a.phone_perso'=>"Text",'a.phone_mobile'=>"Text", 'a.zip'=>"Text",'a.town'=>"Text",'d.nom'=>"Text",'co.code'=>'Text','co.label'=>"Text",'a.phone'=>"Text",'a.phone_perso'=>"Text",'a.phone_mobile'=>"Text",
'a.email'=>"Text",'a.birth'=>"Date",'a.statut'=>"Status",'a.note_public'=>"Text",'a.note_private'=>"Text",'a.datec'=>'Date','a.datevalid'=>'Date', 'a.email'=>"Text",'a.birth'=>"Date",'a.statut'=>"Status",'a.note_public'=>"Text",'a.note_private'=>"Text",'a.datec'=>'Date','a.datevalid'=>'Date',
'a.tms'=>'Date','a.datefin'=>'Date','ta.rowid'=>'List:adherent_type:libelle::member_type','ta.libelle'=>'Text','c.rowid'=>'Numeric','c.dateadh'=>'Date','c.subscription'=>'Numeric' 'a.tms'=>'Date','a.datefin'=>'Date','ta.rowid'=>'List:adherent_type:libelle::member_type','ta.libelle'=>'Text','c.rowid'=>'Numeric','c.dateadh'=>'Date','c.subscription'=>'Numeric'
); );
$this->export_entities_array[$r]=array( $this->export_entities_array[$r]=array(
'a.rowid'=>'member','a.civility'=>"member",'a.lastname'=>"member",'a.firstname'=>"member",'a.login'=>"member",'a.gender'=>'member','a.morphy'=>'member', 'a.rowid'=>'member','a.civility'=>"member",'a.lastname'=>"member",'a.firstname'=>"member",'a.login'=>"member",'a.gender'=>'member','a.morphy'=>'member',
'a.societe'=>'member','a.address'=>"member",'a.zip'=>"member",'a.town'=>"member",'d.nom'=>"member",'co.code'=>"member",'co.label'=>"member", 'a.societe'=>'member','a.address'=>"member",'a.zip'=>"member",'a.town'=>"member",'d.nom'=>"member",'co.code'=>"member",'co.label'=>"member",
'a.phone'=>"member",'a.phone_perso'=>"member",'a.phone_mobile'=>"member",'a.email'=>"member",'a.birth'=>"member",'a.statut'=>"member", 'a.phone'=>"member",'a.phone_perso'=>"member",'a.phone_mobile'=>"member",'a.email'=>"member",'a.birth'=>"member",'a.statut'=>"member",
'a.photo'=>"member",'a.note_public'=>"member",'a.note_private'=>"member",'a.datec'=>'member','a.datevalid'=>'member','a.tms'=>'member', 'a.photo'=>"member",'a.note_public'=>"member",'a.note_private'=>"member",'a.datec'=>'member','a.datevalid'=>'member','a.tms'=>'member',
'a.datefin'=>'member','ta.rowid'=>'member_type','ta.libelle'=>'member_type','c.rowid'=>'subscription','c.dateadh'=>'subscription','c.subscription'=>'subscription' 'a.datefin'=>'member','ta.rowid'=>'member_type','ta.libelle'=>'member_type','c.rowid'=>'subscription','c.dateadh'=>'subscription','c.subscription'=>'subscription'
); );
// Add extra fields // Add extra fields
$keyforselect='adherent'; $keyforelement='member'; $keyforaliasextra='extra'; $keyforselect='adherent'; $keyforelement='member'; $keyforaliasextra='extra';
include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';
// End add axtra fields // End add axtra fields
$this->export_sql_start[$r]='SELECT DISTINCT '; $this->export_sql_start[$r]='SELECT DISTINCT ';
$this->export_sql_end[$r] =' FROM ('.MAIN_DB_PREFIX.'adherent_type as ta, '.MAIN_DB_PREFIX.'adherent as a)'; $this->export_sql_end[$r] =' FROM ('.MAIN_DB_PREFIX.'adherent_type as ta, '.MAIN_DB_PREFIX.'adherent as a)';
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'adherent_extrafields as extra ON a.rowid = extra.fk_object'; $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'adherent_extrafields as extra ON a.rowid = extra.fk_object';
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'subscription as c ON c.fk_adherent = a.rowid'; $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'subscription as c ON c.fk_adherent = a.rowid';
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_departements as d ON a.state_id = d.rowid'; $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_departements as d ON a.state_id = d.rowid';
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as co ON a.country = co.rowid'; $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as co ON a.country = co.rowid';
$this->export_sql_end[$r] .=' WHERE a.fk_adherent_type = ta.rowid AND ta.entity IN ('.getEntity('member_type').') '; $this->export_sql_end[$r] .=' WHERE a.fk_adherent_type = ta.rowid AND ta.entity IN ('.getEntity('member_type').') ';
$this->export_dependencies_array[$r]=array('subscription'=>'c.rowid'); // To add unique key if we ask a field of a child to avoid the DISTINCT to discard them $this->export_dependencies_array[$r]=array('subscription'=>'c.rowid'); // To add unique key if we ask a field of a child to avoid the DISTINCT to discard them
@@ -317,54 +317,54 @@ class modAdherent extends DolibarrModules
$this->import_tables_array[$r]=array('a'=>MAIN_DB_PREFIX.'adherent','extra'=>MAIN_DB_PREFIX.'adherent_extrafields'); $this->import_tables_array[$r]=array('a'=>MAIN_DB_PREFIX.'adherent','extra'=>MAIN_DB_PREFIX.'adherent_extrafields');
$this->import_tables_creator_array[$r]=array('a'=>'fk_user_author'); // Fields to store import user id $this->import_tables_creator_array[$r]=array('a'=>'fk_user_author'); // Fields to store import user id
$this->import_fields_array[$r]=array( $this->import_fields_array[$r]=array(
'a.civility'=>"UserTitle",'a.lastname'=>"Lastname*",'a.firstname'=>"Firstname",'a.gender'=>"Gender",'a.login'=>"Login*","a.pass"=>"Password", 'a.civility'=>"UserTitle",'a.lastname'=>"Lastname*",'a.firstname'=>"Firstname",'a.gender'=>"Gender",'a.login'=>"Login*","a.pass"=>"Password",
"a.fk_adherent_type"=>"MemberType*",'a.morphy'=>'Nature*','a.societe'=>'Company','a.address'=>"Address",'a.zip'=>"Zip",'a.town'=>"Town", "a.fk_adherent_type"=>"MemberType*",'a.morphy'=>'Nature*','a.societe'=>'Company','a.address'=>"Address",'a.zip'=>"Zip",'a.town'=>"Town",
'a.state_id'=>'StateId','a.country'=>"CountryId",'a.phone'=>"PhonePro",'a.phone_perso'=>"PhonePerso",'a.phone_mobile'=>"PhoneMobile", 'a.state_id'=>'StateId','a.country'=>"CountryId",'a.phone'=>"PhonePro",'a.phone_perso'=>"PhonePerso",'a.phone_mobile'=>"PhoneMobile",
'a.email'=>"Email",'a.birth'=>"Birthday",'a.statut'=>"Status*",'a.photo'=>"Photo",'a.note_public'=>"NotePublic",'a.note_private'=>"NotePrivate", 'a.email'=>"Email",'a.birth'=>"Birthday",'a.statut'=>"Status*",'a.photo'=>"Photo",'a.note_public'=>"NotePublic",'a.note_private'=>"NotePrivate",
'a.datec'=>'DateCreation','a.datefin'=>'DateEndSubscription' 'a.datec'=>'DateCreation','a.datefin'=>'DateEndSubscription'
); );
// Add extra fields // Add extra fields
$sql="SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'adherent' AND entity IN (0,".$conf->entity.")"; $sql="SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'adherent' AND entity IN (0,".$conf->entity.")";
$resql=$this->db->query($sql); $resql=$this->db->query($sql);
if ($resql) // This can fail when class is used on old database (during migration for example) if ($resql) // This can fail when class is used on old database (during migration for example)
{ {
while ($obj=$this->db->fetch_object($resql)) while ($obj=$this->db->fetch_object($resql))
{ {
$fieldname='extra.'.$obj->name; $fieldname='extra.'.$obj->name;
$fieldlabel=ucfirst($obj->label); $fieldlabel=ucfirst($obj->label);
$this->import_fields_array[$r][$fieldname]=$fieldlabel.($obj->fieldrequired?'*':''); $this->import_fields_array[$r][$fieldname]=$fieldlabel.($obj->fieldrequired?'*':'');
} }
} }
// End add extra fields // End add extra fields
$this->import_fieldshidden_array[$r]=array('extra.fk_object'=>'lastrowid-'.MAIN_DB_PREFIX.'adherent'); // aliastable.field => ('user->id' or 'lastrowid-'.tableparent) $this->import_fieldshidden_array[$r]=array('extra.fk_object'=>'lastrowid-'.MAIN_DB_PREFIX.'adherent'); // aliastable.field => ('user->id' or 'lastrowid-'.tableparent)
$this->import_regex_array[$r]=array( $this->import_regex_array[$r]=array(
'a.civility'=>'code@'.MAIN_DB_PREFIX.'c_civility','a.fk_adherent_type'=>'rowid@'.MAIN_DB_PREFIX.'adherent_type','a.morphy'=>'(phy|mor)', 'a.civility'=>'code@'.MAIN_DB_PREFIX.'c_civility','a.fk_adherent_type'=>'rowid@'.MAIN_DB_PREFIX.'adherent_type','a.morphy'=>'(phy|mor)',
'a.statut'=>'^[0|1]','a.datec'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$','a.datefin'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$'); 'a.statut'=>'^[0|1]','a.datec'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$','a.datefin'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$');
$this->import_examplevalues_array[$r]=array( $this->import_examplevalues_array[$r]=array(
'a.civility'=>"MR",'a.lastname'=>'Smith','a.firstname'=>'John','a.login'=>'jsmith','a.pass'=>'passofjsmith','a.fk_adherent_type'=>'1', 'a.civility'=>"MR",'a.lastname'=>'Smith','a.firstname'=>'John','a.login'=>'jsmith','a.pass'=>'passofjsmith','a.fk_adherent_type'=>'1',
'a.morphy'=>'"mor" or "phy"','a.societe'=>'JS company','a.address'=>'21 jump street','a.zip'=>'55000','a.town'=>'New York','a.country'=>'1', 'a.morphy'=>'"mor" or "phy"','a.societe'=>'JS company','a.address'=>'21 jump street','a.zip'=>'55000','a.town'=>'New York','a.country'=>'1',
'a.email'=>'jsmith@example.com','a.birth'=>'1972-10-10','a.statut'=>"0 or 1",'a.note_public'=>"This is a public comment on member", 'a.email'=>'jsmith@example.com','a.birth'=>'1972-10-10','a.statut'=>"0 or 1",'a.note_public'=>"This is a public comment on member",
'a.note_private'=>"This is private comment on member",'a.datec'=>dol_print_date($now, '%Y-%m__%d'),'a.datefin'=>dol_print_date(dol_time_plus_duree($now, 1, 'y'), '%Y-%m-%d') 'a.note_private'=>"This is private comment on member",'a.datec'=>dol_print_date($now, '%Y-%m__%d'),'a.datefin'=>dol_print_date(dol_time_plus_duree($now, 1, 'y'), '%Y-%m-%d')
); );
// Cronjobs // Cronjobs
$arraydate=dol_getdate(dol_now()); $arraydate=dol_getdate(dol_now());
$datestart=dol_mktime(22, 0, 0, $arraydate['mon'], $arraydate['mday'], $arraydate['year']); $datestart=dol_mktime(22, 0, 0, $arraydate['mon'], $arraydate['mday'], $arraydate['year']);
$this->cronjobs = array( $this->cronjobs = array(
0=>array( 0=>array(
'label'=>'SendReminderForExpiredSubscriptionTitle', 'label'=>'SendReminderForExpiredSubscriptionTitle',
'jobtype'=>'method', 'class'=>'adherents/class/adherent.class.php', 'jobtype'=>'method', 'class'=>'adherents/class/adherent.class.php',
'objectname'=>'Adherent', 'objectname'=>'Adherent',
'method'=>'sendReminderForExpiredSubscription', 'method'=>'sendReminderForExpiredSubscription',
'parameters'=>'10;0', 'parameters'=>'10;0',
'comment'=>'SendReminderForExpiredSubscription', 'comment'=>'SendReminderForExpiredSubscription',
'frequency'=>1, 'frequency'=>1,
'unitfrequency'=> 3600 * 24, 'unitfrequency'=> 3600 * 24,
'priority'=>50, 'priority'=>50,
'status'=>1, 'status'=>1,
'test'=>'$conf->adherent->enabled', 'test'=>'$conf->adherent->enabled',
'datestart'=>$datestart 'datestart'=>$datestart
), ),
); );
} }

View File

@@ -43,7 +43,7 @@ class modAgenda extends DolibarrModules
* *
* @param DoliDB $db Database handler * @param DoliDB $db Database handler
*/ */
function __construct($db) public function __construct($db)
{ {
global $conf, $user; global $conf, $user;

View File

@@ -38,7 +38,7 @@ class modApi extends DolibarrModules
* *
* @param DoliDB $db Database handler * @param DoliDB $db Database handler
*/ */
function __construct($db) public function __construct($db)
{ {
global $langs,$conf; global $langs,$conf;

View File

@@ -313,22 +313,22 @@ class modAsset extends DolibarrModules
} }
/** /**
* 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
*/ */
function init($options = '') public function init($options = '')
{ {
global $conf; global $conf;
// Permissions // Permissions
$this->remove($options); $this->remove($options);
$sql = array(); $sql = array();
return $this->_init($sql, $options); return $this->_init($sql, $options);
} }
} }

View File

@@ -41,7 +41,7 @@ class modBanque extends DolibarrModules
* *
* @param DoliDB $db Database handler * @param DoliDB $db Database handler
*/ */
function __construct($db) public function __construct($db)
{ {
global $conf; global $conf;

View File

@@ -39,7 +39,7 @@ class modBarcode extends DolibarrModules
* *
* @param DoliDB $db Database handler * @param DoliDB $db Database handler
*/ */
function __construct($db) public function __construct($db)
{ {
$this->db = $db; $this->db = $db;
$this->numero = 55; $this->numero = 55;

View File

@@ -30,21 +30,21 @@ include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php';
class modBlockedLog extends DolibarrModules class modBlockedLog 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
*/ */
function __construct($db) public function __construct($db)
{ {
global $langs, $conf, $mysoc; global $langs, $conf, $mysoc;
$this->db = $db; $this->db = $db;
$this->numero = 3200; $this->numero = 3200;
// Key text used to identify module (for permissions, menus, etc...) // Key text used to identify module (for permissions, menus, etc...)
$this->rights_class = 'blockedlog'; $this->rights_class = 'blockedlog';
// Family can be 'crm','financial','hr','projects','products','ecm','technic','other' // Family can be 'crm','financial','hr','projects','products','ecm','technic','other'
// It is used to group modules in module setup page // It is used to group modules in module setup page
$this->family = "base"; $this->family = "base";
// 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 = '75'; $this->module_position = '75';
@@ -67,10 +67,10 @@ class modBlockedLog extends DolibarrModules
// Dependancies // Dependancies
//------------- //-------------
$this->hidden = false; // A condition to disable module $this->hidden = false; // A condition to disable module
$this->depends = array('always'=>'modFacture'); // List of modules id that must be enabled if this module is enabled $this->depends = array('always'=>'modFacture'); // List of modules id that must be enabled if this module is enabled
$this->requiredby = array(); // List of modules id to disable if this one is disabled $this->requiredby = array(); // List of modules id to disable if this one is disabled
$this->conflictwith = array(); // List of modules id this module is in conflict with $this->conflictwith = array(); // List of modules id this module is in conflict with
$this->langfiles = array('blockedlog'); $this->langfiles = array('blockedlog');
$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'...)
@@ -81,24 +81,24 @@ class modBlockedLog extends DolibarrModules
// enable this module. // enable this module.
/*if (! empty($conf->global->BLOCKEDLOG_DISABLE_NOT_ALLOWED_FOR_COUNTRY)) /*if (! empty($conf->global->BLOCKEDLOG_DISABLE_NOT_ALLOWED_FOR_COUNTRY))
{ {
$tmp=explode(',', $conf->global->BLOCKEDLOG_DISABLE_NOT_ALLOWED_FOR_COUNTRY); $tmp=explode(',', $conf->global->BLOCKEDLOG_DISABLE_NOT_ALLOWED_FOR_COUNTRY);
$this->automatic_activation = array(); $this->automatic_activation = array();
foreach($tmp as $key) foreach($tmp as $key)
{ {
$this->automatic_activation[$key]='BlockedLogActivatedBecauseRequiredByYourCountryLegislation'; $this->automatic_activation[$key]='BlockedLogActivatedBecauseRequiredByYourCountryLegislation';
} }
}*/ }*/
//var_dump($this->automatic_activation); //var_dump($this->automatic_activation);
$this->always_enabled = (!empty($conf->blockedlog->enabled) $this->always_enabled = (!empty($conf->blockedlog->enabled)
&& !empty($conf->global->BLOCKEDLOG_DISABLE_NOT_ALLOWED_FOR_COUNTRY) && !empty($conf->global->BLOCKEDLOG_DISABLE_NOT_ALLOWED_FOR_COUNTRY)
&& in_array($mysoc->country_code, explode(',', $conf->global->BLOCKEDLOG_DISABLE_NOT_ALLOWED_FOR_COUNTRY)) && in_array($mysoc->country_code, explode(',', $conf->global->BLOCKEDLOG_DISABLE_NOT_ALLOWED_FOR_COUNTRY))
&& $this->alreadyUsed(1)); && $this->alreadyUsed(1));
// Constants // Constants
//----------- //-----------
$this->const = array( $this->const = array(
1=>array('BLOCKEDLOG_DISABLE_NOT_ALLOWED_FOR_COUNTRY', 'chaine', 'FR', 'This is list of country code where the module may be mandatory', 0, 'current', 0) 1=>array('BLOCKEDLOG_DISABLE_NOT_ALLOWED_FOR_COUNTRY', 'chaine', 'FR', 'This is list of country code where the module may be mandatory', 0, 'current', 0)
); );
// New pages on tabs // New pages on tabs
@@ -148,9 +148,9 @@ class modBlockedLog extends DolibarrModules
function alreadyUsed() function alreadyUsed()
{ {
require_once DOL_DOCUMENT_ROOT.'/blockedlog/class/blockedlog.class.php'; require_once DOL_DOCUMENT_ROOT.'/blockedlog/class/blockedlog.class.php';
$b=new BlockedLog($this->db); $b=new BlockedLog($this->db);
return $b->alreadyUsed(1); return $b->alreadyUsed(1);
} }
@@ -164,87 +164,87 @@ class modBlockedLog extends DolibarrModules
*/ */
function init($options = '') function init($options = '')
{ {
global $conf, $user; global $conf, $user;
$sql = array(); $sql = array();
// If already used, we add an entry to show we enable module // If already used, we add an entry to show we enable module
require_once DOL_DOCUMENT_ROOT.'/blockedlog/class/blockedlog.class.php'; require_once DOL_DOCUMENT_ROOT.'/blockedlog/class/blockedlog.class.php';
$object=new stdClass(); $object=new stdClass();
$object->id = 1; $object->id = 1;
$object->element = 'module'; $object->element = 'module';
$object->ref = 'systemevent'; $object->ref = 'systemevent';
$object->entity = $conf->entity; $object->entity = $conf->entity;
$object->date = dol_now(); $object->date = dol_now();
$b=new BlockedLog($this->db); $b=new BlockedLog($this->db);
$result = $b->setObjectData($object, 'MODULE_SET', 0); $result = $b->setObjectData($object, 'MODULE_SET', 0);
if ($result < 0) if ($result < 0)
{ {
$this->error = $b->error; $this->error = $b->error;
$this->errors = $b->erros; $this->errors = $b->erros;
return 0; return 0;
} }
$res = $b->create($user); $res = $b->create($user);
if ($res<=0) { if ($res<=0) {
$this->error = $b->error; $this->error = $b->error;
$this->errors = $b->errors; $this->errors = $b->errors;
return $res; return $res;
} }
return $this->_init($sql, $options); return $this->_init($sql, $options);
} }
/** /**
* Function called when module is disabled. * Function called when module is disabled.
* The remove function removes tabs, constants, boxes, permissions and menus from Dolibarr database. * The remove function removes tabs, constants, boxes, permissions and menus 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
*/ */
function remove($options = '') function remove($options = '')
{ {
global $conf, $user; global $conf, $user;
$sql = array(); $sql = array();
// If already used, we add an entry to show we enable module // If already used, we add an entry to show we enable module
require_once DOL_DOCUMENT_ROOT.'/blockedlog/class/blockedlog.class.php'; require_once DOL_DOCUMENT_ROOT.'/blockedlog/class/blockedlog.class.php';
$object=new stdClass(); $object=new stdClass();
$object->id = 1; $object->id = 1;
$object->element = 'module'; $object->element = 'module';
$object->ref = 'systemevent'; $object->ref = 'systemevent';
$object->entity = $conf->entity; $object->entity = $conf->entity;
$object->date = dol_now(); $object->date = dol_now();
$b=new BlockedLog($this->db); $b=new BlockedLog($this->db);
$result = $b->setObjectData($object, 'MODULE_RESET', 0); $result = $b->setObjectData($object, 'MODULE_RESET', 0);
if ($result < 0) if ($result < 0)
{ {
$this->error = $b->error; $this->error = $b->error;
$this->errors = $b->erros; $this->errors = $b->erros;
return 0; return 0;
} }
if ($b->alreadyUsed(1)) if ($b->alreadyUsed(1))
{ {
$res = $b->create($user, '0000000000'); // If already used for something else than SET or UNSET, we log with error $res = $b->create($user, '0000000000'); // If already used for something else than SET or UNSET, we log with error
} }
else else
{ {
$res = $b->create($user); $res = $b->create($user);
} }
if ($res<=0) { if ($res<=0) {
$this->error = $b->error; $this->error = $b->error;
$this->errors = $b->errors; $this->errors = $b->errors;
return $res; return $res;
} }
return $this->_remove($sql, $options); return $this->_remove($sql, $options);
} }
} }

View File

@@ -38,7 +38,7 @@ class modBookmark extends DolibarrModules
* *
* @param DoliDB $db Database handler * @param DoliDB $db Database handler
*/ */
function __construct($db) public function __construct($db)
{ {
$this->db = $db; $this->db = $db;
$this->numero = 330; $this->numero = 330;

View File

@@ -35,7 +35,7 @@ class modCashDesk extends DolibarrModules
* *
* @param DoliDB $db Database handler * @param DoliDB $db Database handler
*/ */
function __construct($db) public function __construct($db)
{ {
$this->db = $db; $this->db = $db;

View File

@@ -37,7 +37,7 @@ class modCategorie extends DolibarrModules
* *
* @param DoliDB $db Database handler * @param DoliDB $db Database handler
*/ */
function __construct($db) public function __construct($db)
{ {
global $conf; global $conf;

View File

@@ -38,7 +38,7 @@ class modClickToDial extends DolibarrModules
* *
* @param DoliDB $db Database handler * @param DoliDB $db Database handler
*/ */
function __construct($db) public function __construct($db)
{ {
$this->db = $db; $this->db = $db;
$this->numero = 58; $this->numero = 58;

View File

@@ -32,33 +32,33 @@ class modCollab 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
*/ */
function __construct($db) public function __construct($db)
{ {
global $langs,$conf; global $langs,$conf;
$this->db = $db; $this->db = $db;
$this->numero = 30000; $this->numero = 30000;
// Family can be 'crm','financial','hr','projects','products','ecm','technic','other' // Family can be 'crm','financial','hr','projects','products','ecm','technic','other'
// It is used to group modules in module setup page // It is used to group modules in module setup page
$this->family = "portal"; $this->family = "portal";
$this->module_position = '51'; $this->module_position = '51';
// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
$this->name = preg_replace('/^mod/i', '', get_class($this)); $this->name = preg_replace('/^mod/i', '', get_class($this));
$this->description = "Enable the public collaboration features, like shared pad, shared online sheets, etc..."; $this->description = "Enable the public collaboration features, like shared pad, shared online sheets, etc...";
// Possible values for version are: 'development', 'experimental', 'dolibarr' or version // Possible values for version are: 'development', 'experimental', 'dolibarr' or version
$this->version = 'development'; $this->version = 'development';
// 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.
$this->picto='globe'; $this->picto='globe';
// Data directories to create when module is enabled // Data directories to create when module is enabled
$this->dirs = array("/collab/temp"); $this->dirs = array("/collab/temp");
// Config pages // Config pages
//------------- //-------------
@@ -66,15 +66,15 @@ class modCollab extends DolibarrModules
// Dependancies // Dependancies
//------------- //-------------
$this->hidden = ! empty($conf->global->MODULE_COLLAB_DISABLED); // A condition to disable module $this->hidden = ! empty($conf->global->MODULE_COLLAB_DISABLED); // A condition to disable module
$this->depends = array(); // List of modules id that must be enabled if this module is enabled $this->depends = array(); // List of modules id that must be enabled if this module is enabled
$this->requiredby = array(); // List of modules id to disable if this one is disabled $this->requiredby = array(); // List of modules id to disable if this one is disabled
$this->conflictwith = array(); // List of modules id this module is in conflict with $this->conflictwith = array(); // List of modules id this module is in conflict with
$this->langfiles = array("collab"); $this->langfiles = array("collab");
// Constants // Constants
//----------- //-----------
$this->const = array(); $this->const = array();
// New pages on tabs // New pages on tabs
// ----------------- // -----------------
@@ -84,42 +84,42 @@ class modCollab extends DolibarrModules
//------ //------
$this->boxes = array(); $this->boxes = array();
// Permissions // Permissions
$this->rights = array(); // Permission array used by this module $this->rights = array(); // Permission array used by this module
$this->rights_class = 'collab'; $this->rights_class = 'collab';
$r=0; $r=0;
/*$this->rights[$r][0] = 30001; /*$this->rights[$r][0] = 30001;
$this->rights[$r][1] = 'Read website content'; $this->rights[$r][1] = 'Read website content';
$this->rights[$r][3] = 0; $this->rights[$r][3] = 0;
$this->rights[$r][4] = 'read'; $this->rights[$r][4] = 'read';
$r++; $r++;
$this->rights[$r][0] = 30002; $this->rights[$r][0] = 30002;
$this->rights[$r][1] = 'Create/modify website content'; $this->rights[$r][1] = 'Create/modify website content';
$this->rights[$r][3] = 0; $this->rights[$r][3] = 0;
$this->rights[$r][4] = 'write'; $this->rights[$r][4] = 'write';
$r++; $r++;
$this->rights[$r][0] = 30003; $this->rights[$r][0] = 30003;
$this->rights[$r][1] = 'Delete website content'; $this->rights[$r][1] = 'Delete website content';
$this->rights[$r][3] = 0; $this->rights[$r][3] = 0;
$this->rights[$r][4] = 'delete'; $this->rights[$r][4] = 'delete';
$r++;*/ $r++;*/
// Main menu entries // Main menu entries
$r=0; $r=0;
$this->menu[$r]=array( 'fk_menu'=>'0', // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode $this->menu[$r]=array( 'fk_menu'=>'0', // 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 Left menu entry 'type'=>'top', // This is a Left menu entry
'titre'=>'Collab', 'titre'=>'Collab',
'mainmenu'=>'collab', 'mainmenu'=>'collab',
'url'=>'/collab/index.php', 'url'=>'/collab/index.php',
'langs'=>'collab', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. 'langs'=>'collab', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
'position'=>100, 'position'=>100,
'enabled'=>'$conf->collab->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->collab->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'=>'1', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules 'perms'=>'1', // 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
$r++; $r++;
} }
} }

View File

@@ -43,7 +43,7 @@ class modCommande extends DolibarrModules
* *
* @param DoliDB $db Database handler * @param DoliDB $db Database handler
*/ */
function __construct($db) public function __construct($db)
{ {
global $conf, $user; global $conf, $user;

View File

@@ -40,7 +40,7 @@ class modComptabilite extends DolibarrModules
* *
* @param DoliDB $db Database handler * @param DoliDB $db Database handler
*/ */
function __construct($db) public function __construct($db)
{ {
global $conf; global $conf;

View File

@@ -39,7 +39,7 @@ class modContrat extends DolibarrModules
* *
* @param DoliDB $db Database handler * @param DoliDB $db Database handler
*/ */
function __construct($db) public function __construct($db)
{ {
global $conf, $langs; global $conf, $langs;

View File

@@ -37,7 +37,7 @@ class modCron extends DolibarrModules
* *
* @param DoliDB $db Database handler * @param DoliDB $db Database handler
*/ */
function __construct($db) public function __construct($db)
{ {
global $langs, $conf; global $langs, $conf;

View File

@@ -210,15 +210,15 @@ class modDataPolicy extends DolibarrModules {
*/ */
public function init($options = '') public function init($options = '')
{ {
global $langs; global $langs;
$this->_load_tables('/datapolicy/sql/'); $this->_load_tables('/datapolicy/sql/');
// Create extrafields // Create extrafields
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);
/* /*
// Extrafield contact // Extrafield contact
$result1 = $extrafields->addExtraField('datapolicy_consentement', $langs->trans("DATAPOLICY_consentement"), 'boolean', 101, 3, 'thirdparty', 0, 0, '', '', 1, '', '3', 0, '', '', 'datapolicy@datapolicy', '$conf->datapolicy->enabled'); $result1 = $extrafields->addExtraField('datapolicy_consentement', $langs->trans("DATAPOLICY_consentement"), 'boolean', 101, 3, 'thirdparty', 0, 0, '', '', 1, '', '3', 0, '', '', 'datapolicy@datapolicy', '$conf->datapolicy->enabled');
$result1 = $extrafields->addExtraField('datapolicy_opposition_traitement', $langs->trans("DATAPOLICY_opposition_traitement"), 'boolean', 102, 3, 'thirdparty', 0, 0, '', '', 1, '', '3', 0, '', '', 'datapolicy@datapolicy', '$conf->datapolicy->enabled'); $result1 = $extrafields->addExtraField('datapolicy_opposition_traitement', $langs->trans("DATAPOLICY_opposition_traitement"), 'boolean', 102, 3, 'thirdparty', 0, 0, '', '', 1, '', '3', 0, '', '', 'datapolicy@datapolicy', '$conf->datapolicy->enabled');
@@ -239,7 +239,7 @@ class modDataPolicy extends DolibarrModules {
$result1 = $extrafields->addExtraField('datapolicy_opposition_prospection', $langs->trans("DATAPOLICY_opposition_prospection"), 'boolean', 103, 3, 'adherent', 0, 0, '', '', 1, '', '3', 0, '', '', 'datapolicy@datapolicy', '$conf->datapolicy->enabled'); $result1 = $extrafields->addExtraField('datapolicy_opposition_prospection', $langs->trans("DATAPOLICY_opposition_prospection"), 'boolean', 103, 3, 'adherent', 0, 0, '', '', 1, '', '3', 0, '', '', 'datapolicy@datapolicy', '$conf->datapolicy->enabled');
$result1 = $extrafields->addExtraField('datapolicy_date', $langs->trans("DATAPOLICY_date"), 'date', 104, 3, 'adherent', 0, 0, '', '', 1, '', '3', 0); $result1 = $extrafields->addExtraField('datapolicy_date', $langs->trans("DATAPOLICY_date"), 'date', 104, 3, 'adherent', 0, 0, '', '', 1, '', '3', 0);
$result1 = $extrafields->addExtraField('datapolicy_send', $langs->trans("DATAPOLICY_send"), 'date', 105, 3, 'adherent', 0, 0, '', '', 0, '', '0', 0); $result1 = $extrafields->addExtraField('datapolicy_send', $langs->trans("DATAPOLICY_send"), 'date', 105, 3, 'adherent', 0, 0, '', '', 0, '', '0', 0);
*/ */
$sql = array(); $sql = array();

View File

@@ -37,7 +37,7 @@ class modDeplacement extends DolibarrModules
* *
* @param DoliDB $db Database handler * @param DoliDB $db Database handler
*/ */
function __construct($db) public function __construct($db)
{ {
global $conf, $user; global $conf, $user;

View File

@@ -39,7 +39,7 @@ class modDocumentGeneration extends DolibarrModules
* *
* @param DoliDB $db Database handler * @param DoliDB $db Database handler
*/ */
function __construct($db) public function __construct($db)
{ {
$this->db = $db; $this->db = $db;
$this->numero = 1520; $this->numero = 1520;

View File

@@ -40,7 +40,7 @@ class modDon extends DolibarrModules
* *
* @param DoliDB $db Database handler * @param DoliDB $db Database handler
*/ */
function __construct($db) public function __construct($db)
{ {
$this->db = $db; $this->db = $db;
$this->numero = 700; $this->numero = 700;

View File

@@ -36,7 +36,7 @@ class modDynamicPrices extends DolibarrModules
* *
* @param DoliDB $db Database handler * @param DoliDB $db Database handler
*/ */
function __construct($db) public function __construct($db)
{ {
$this->db = $db; $this->db = $db;
$this->numero = 2200; $this->numero = 2200;

View File

@@ -37,7 +37,7 @@ class modECM extends DolibarrModules
* *
* @param DoliDB $db Database handler * @param DoliDB $db Database handler
*/ */
function __construct($db) public function __construct($db)
{ {
$this->db = $db; $this->db = $db;

View File

@@ -41,7 +41,7 @@ class modExpedition extends DolibarrModules
* *
* @param DoliDB $db Database handler * @param DoliDB $db Database handler
*/ */
function __construct($db) public function __construct($db)
{ {
global $conf, $user; global $conf, $user;

View File

@@ -36,7 +36,7 @@ class modExpenseReport extends DolibarrModules
* *
* @param Database $db Database handler * @param Database $db Database handler
*/ */
function __construct($db) public function __construct($db)
{ {
global $conf; global $conf;

View File

@@ -38,7 +38,7 @@ class modExport extends DolibarrModules
* *
* @param DoliDB $db Database handler * @param DoliDB $db Database handler
*/ */
function __construct($db) public function __construct($db)
{ {
$this->db = $db; $this->db = $db;
$this->numero = 240; $this->numero = 240;

View File

@@ -38,7 +38,7 @@ class modExternalRss extends DolibarrModules
* *
* @param DoliDB $db Database handler * @param DoliDB $db Database handler
*/ */
function __construct($db) public function __construct($db)
{ {
global $conf; global $conf;

View File

@@ -39,7 +39,7 @@ class modExternalSite extends DolibarrModules
* *
* @param DoliDB $db Database handler * @param DoliDB $db Database handler
*/ */
function __construct($db) public function __construct($db)
{ {
$this->db = $db; $this->db = $db;

View File

@@ -33,12 +33,12 @@ include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php';
class modFTP extends DolibarrModules class modFTP 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
*/ */
function __construct($db) public function __construct($db)
{ {
$this->db = $db; $this->db = $db;

View File

@@ -40,7 +40,7 @@ class modFacture extends DolibarrModules
* *
* @param DoliDB $db Database handler * @param DoliDB $db Database handler
*/ */
function __construct($db) public function __construct($db)
{ {
global $conf, $user; global $conf, $user;

View File

@@ -39,7 +39,7 @@ class modFckeditor extends DolibarrModules
* *
* @param DoliDB $db Database handler * @param DoliDB $db Database handler
*/ */
function __construct($db) public function __construct($db)
{ {
$this->db = $db; $this->db = $db;
$this->numero = 2000; $this->numero = 2000;

View File

@@ -42,7 +42,7 @@ class modFicheinter extends DolibarrModules
* *
* @param DoliDB $db Database handler * @param DoliDB $db Database handler
*/ */
function __construct($db) public function __construct($db)
{ {
global $conf; global $conf;

View File

@@ -39,7 +39,7 @@ class modFournisseur extends DolibarrModules
* *
* @param DoliDB $db Database handler * @param DoliDB $db Database handler
*/ */
function __construct($db) public function __construct($db)
{ {
global $conf, $user; global $conf, $user;

View File

@@ -37,7 +37,7 @@ class modGeoIPMaxmind extends DolibarrModules
* *
* @param DoliDB $db Database handler * @param DoliDB $db Database handler
*/ */
function __construct($db) public function __construct($db)
{ {
$this->db = $db; $this->db = $db;
$this->numero = 2900; $this->numero = 2900;

View File

@@ -36,7 +36,7 @@ class modGravatar extends DolibarrModules
* *
* @param DoliDB $db Database handler * @param DoliDB $db Database handler
*/ */
function __construct($db) public function __construct($db)
{ {
$this->db = $db; $this->db = $db;

View File

@@ -41,7 +41,7 @@ class modHoliday extends DolibarrModules
* *
* @param DoliDB $db Database handler * @param DoliDB $db Database handler
*/ */
function __construct($db) public function __construct($db)
{ {
$this->db = $db; $this->db = $db;

View File

@@ -38,7 +38,7 @@ class modImport extends DolibarrModules
* *
* @param DoliDB $db Database handler * @param DoliDB $db Database handler
*/ */
function __construct($db) public function __construct($db)
{ {
$this->db = $db; $this->db = $db;
$this->numero = 250; $this->numero = 250;

View File

@@ -38,8 +38,8 @@ class modIncoterm extends DolibarrModules
* *
* @param DoliDB $db Database handler * @param DoliDB $db Database handler
*/ */
function __construct($db) public function __construct($db)
{ {
global $langs,$conf; global $langs,$conf;
$this->db = $db; $this->db = $db;

View File

@@ -38,7 +38,7 @@ class modLabel extends DolibarrModules
* *
* @param DoliDB $db Database handler * @param DoliDB $db Database handler
*/ */
function __construct($db) public function __construct($db)
{ {
$this->db = $db; $this->db = $db;
$this->numero = 60; $this->numero = 60;

View File

@@ -37,7 +37,7 @@ class modLdap extends DolibarrModules
* *
* @param DoliDB $db Database handler * @param DoliDB $db Database handler
*/ */
function __construct($db) public function __construct($db)
{ {
$this->db = $db; $this->db = $db;
$this->numero = 200; $this->numero = 200;

View File

@@ -37,7 +37,7 @@ class modLoan extends DolibarrModules
* *
* @param DoliDB $db Database handler * @param DoliDB $db Database handler
*/ */
function __construct($db) public function __construct($db)
{ {
global $conf; global $conf;

View File

@@ -39,7 +39,7 @@ class modMailing extends DolibarrModules
* *
* @param DoliDB $db Database handler * @param DoliDB $db Database handler
*/ */
function __construct($db) public function __construct($db)
{ {
$this->db = $db; $this->db = $db;
$this->numero = 22; $this->numero = 22;

View File

@@ -38,7 +38,7 @@ class modMailmanSpip extends DolibarrModules
* *
* @param DoliDB $db Database handler * @param DoliDB $db Database handler
*/ */
function __construct($db) public function __construct($db)
{ {
$this->db = $db; $this->db = $db;
$this->numero = 105; $this->numero = 105;

View File

@@ -35,7 +35,7 @@ class modMargin extends DolibarrModules
* *
* @param DoliDB $db Database handler * @param DoliDB $db Database handler
*/ */
function __construct($db) public function __construct($db)
{ {
$this->db = $db; $this->db = $db;

View File

@@ -35,7 +35,7 @@ class modModuleBuilder extends DolibarrModules
* *
* @param DoliDB $db Database handler * @param DoliDB $db Database handler
*/ */
function __construct($db) public function __construct($db)
{ {
global $langs,$conf; global $langs,$conf;

View File

@@ -38,8 +38,8 @@ class modMultiCurrency extends DolibarrModules
* *
* @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;

View File

@@ -36,7 +36,7 @@ class modNotification extends DolibarrModules
* *
* @param DoliDB $db Database handler * @param DoliDB $db Database handler
*/ */
function __construct($db) public function __construct($db)
{ {
$this->db = $db; $this->db = $db;
$this->numero = 600; $this->numero = 600;

View File

@@ -40,7 +40,7 @@ class modOauth extends DolibarrModules
* *
* @param DoliDB $db Database handler * @param DoliDB $db Database handler
*/ */
function __construct($db) public function __construct($db)
{ {
$this->db = $db ; $this->db = $db ;
$this->numero = 66000; $this->numero = 66000;

View File

@@ -37,7 +37,7 @@ class modOpenSurvey extends DolibarrModules
* *
* @param DoliDB $db Database handler * @param DoliDB $db Database handler
*/ */
function __construct($db) public function __construct($db)
{ {
global $langs,$conf; global $langs,$conf;

View File

@@ -36,7 +36,7 @@ class modPayBox extends DolibarrModules
* *
* @param DoliDB $db Database handler * @param DoliDB $db Database handler
*/ */
function __construct($db) public function __construct($db)
{ {
$this->db = $db; $this->db = $db;

View File

@@ -37,7 +37,7 @@ class modPaypal extends DolibarrModules
* *
* @param DoliDB $db Database handler * @param DoliDB $db Database handler
*/ */
function __construct($db) public function __construct($db)
{ {
$this->db = $db; $this->db = $db;

View File

@@ -40,7 +40,7 @@ class modPrelevement extends DolibarrModules
* *
* @param DoliDB $db Database handler * @param DoliDB $db Database handler
*/ */
function __construct($db) public function __construct($db)
{ {
global $conf; global $conf;

View File

@@ -40,7 +40,7 @@ class modPrinting extends DolibarrModules
* *
* @param DoliDB $db Database handler * @param DoliDB $db Database handler
*/ */
function __construct($db) public function __construct($db)
{ {
$this->db = $db ; $this->db = $db ;
$this->numero = 64000; $this->numero = 64000;

View File

@@ -42,7 +42,7 @@ class modProduct extends DolibarrModules
* *
* @param DoliDB $db Database handler * @param DoliDB $db Database handler
*/ */
function __construct($db) public function __construct($db)
{ {
global $conf, $mysoc; global $conf, $mysoc;

View File

@@ -38,7 +38,7 @@ class modProductBatch extends DolibarrModules
* *
* @param DoliDB $db Database handler * @param DoliDB $db Database handler
*/ */
function __construct($db) public function __construct($db)
{ {
global $langs,$conf; global $langs,$conf;

View File

@@ -41,7 +41,7 @@ class modProjet extends DolibarrModules
* *
* @param DoliDB $db Database handler * @param DoliDB $db Database handler
*/ */
function __construct($db) public function __construct($db)
{ {
global $conf; global $conf;

View File

@@ -41,7 +41,7 @@ class modPropale extends DolibarrModules
* *
* @param DoliDB $db Database handler * @param DoliDB $db Database handler
*/ */
function __construct($db) public function __construct($db)
{ {
global $conf, $user; global $conf, $user;

View File

@@ -40,7 +40,7 @@ class modReceiptPrinter extends DolibarrModules
* *
* @param DoliDB $db Database handler * @param DoliDB $db Database handler
*/ */
function __construct($db) public function __construct($db)
{ {
$this->db = $db ; $this->db = $db ;
$this->numero = 67000; $this->numero = 67000;

View File

@@ -36,7 +36,7 @@ class modReception extends DolibarrModules
* *
* @param DoliDB $db Database handler * @param DoliDB $db Database handler
*/ */
function __construct($db) public function __construct($db)
{ {
global $conf, $user; global $conf, $user;

View File

@@ -40,7 +40,7 @@ class modService extends DolibarrModules
* *
* @param DoliDB $db Database handler * @param DoliDB $db Database handler
*/ */
function __construct($db) public function __construct($db)
{ {
global $conf, $mysoc; global $conf, $mysoc;

View File

@@ -36,7 +36,7 @@ class modSocialNetworks extends DolibarrModules
* *
* @param DoliDB $db Database handler * @param DoliDB $db Database handler
*/ */
function __construct($db) public function __construct($db)
{ {
global $langs,$conf; global $langs,$conf;

View File

@@ -41,7 +41,7 @@ class modSociete extends DolibarrModules
* *
* @param DoliDB $db Database handler * @param DoliDB $db Database handler
*/ */
function __construct($db) public function __construct($db)
{ {
global $conf, $user; global $conf, $user;

View File

@@ -40,7 +40,7 @@ class modStock extends DolibarrModules
* *
* @param DoliDB $db Database handler * @param DoliDB $db Database handler
*/ */
function __construct($db) public function __construct($db)
{ {
global $conf, $langs; global $conf, $langs;

View File

@@ -36,7 +36,7 @@ class modStripe extends DolibarrModules
* *
* @param DoliDB $db Database handler * @param DoliDB $db Database handler
*/ */
function __construct($db) public function __construct($db)
{ {
$this->db = $db; $this->db = $db;

View File

@@ -42,7 +42,7 @@ class modSupplierProposal extends DolibarrModules
* *
* @param DoliDB $db Database handler * @param DoliDB $db Database handler
*/ */
function __construct($db) public function __construct($db)
{ {
global $conf; global $conf;
@@ -57,10 +57,10 @@ class modSupplierProposal extends DolibarrModules
$this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
$this->picto='supplier_proposal'; $this->picto='supplier_proposal';
// Data directories to create when module is enabled. // Data directories to create when module is enabled.
$this->dirs = array(); $this->dirs = array();
// Config pages. Put here list of php page names stored in admin directory used to setup module. // Config pages. Put here list of php page names stored in admin directory used to setup module.
$this->config_page_url = array("supplier_proposal.php"); $this->config_page_url = array("supplier_proposal.php");
@@ -206,7 +206,7 @@ class modSupplierProposal extends DolibarrModules
* @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
*/ */
function init($options = '') public function init($options = '')
{ {
global $conf,$langs; global $conf,$langs;

View File

@@ -37,7 +37,7 @@ class modSyslog extends DolibarrModules
* *
* @param DoliDB $db Database handler * @param DoliDB $db Database handler
*/ */
function __construct($db) public function __construct($db)
{ {
$this->db = $db; $this->db = $db;
$this->numero = 42; $this->numero = 42;

View File

@@ -41,7 +41,7 @@ class modTax extends DolibarrModules
* *
* @param DoliDB $db Database handler * @param DoliDB $db Database handler
*/ */
function __construct($db) public function __construct($db)
{ {
global $conf; global $conf;

View File

@@ -38,7 +38,7 @@ class modUser extends DolibarrModules
* *
* @param DoliDB $db Database handler * @param DoliDB $db Database handler
*/ */
function __construct($db) public function __construct($db)
{ {
global $conf; global $conf;
@@ -331,8 +331,8 @@ class modUser extends DolibarrModules
* @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
*/ */
function init($options = '') public function init($options = '')
{ {
global $conf; global $conf;
// Permissions // Permissions
@@ -341,5 +341,5 @@ class modUser extends DolibarrModules
$sql = array(); $sql = array();
return $this->_init($sql, $options); return $this->_init($sql, $options);
} }
} }

View File

@@ -35,7 +35,7 @@ class modWebServices extends DolibarrModules
* *
* @param DoliDB $db Database handler * @param DoliDB $db Database handler
*/ */
function __construct($db) public function __construct($db)
{ {
$this->db = $db; $this->db = $db;
$this->numero = 2600; $this->numero = 2600;

View File

@@ -35,7 +35,7 @@ class modWebServicesClient extends DolibarrModules
* *
* @param DoliDB $db Database handler * @param DoliDB $db Database handler
*/ */
function __construct($db) public function __construct($db)
{ {
$this->db = $db; $this->db = $db;
$this->numero = 2660; $this->numero = 2660;

View File

@@ -36,7 +36,7 @@ class modWebsite extends DolibarrModules
* *
* @param DoliDB $db Database handler * @param DoliDB $db Database handler
*/ */
function __construct($db) public function __construct($db)
{ {
global $langs,$conf; global $langs,$conf;

View File

@@ -37,7 +37,7 @@ class modWorkflow extends DolibarrModules
* *
* @param DoliDB $db Database handler * @param DoliDB $db Database handler
*/ */
function __construct($db) public function __construct($db)
{ {
$this->db = $db; $this->db = $db;

View File

@@ -44,10 +44,10 @@ class Donations extends DolibarrApi
/** /**
* Constructor * Constructor
*/ */
function __construct() public function __construct()
{ {
global $db, $conf; global $db, $conf;
$this->db = $db; $this->db = $db;
$this->don = new Don($this->db); $this->don = new Don($this->db);
} }
@@ -61,7 +61,7 @@ class Donations extends DolibarrApi
* *
* @throws RestException * @throws RestException
*/ */
function get($id) public function get($id)
{ {
if(! DolibarrApiAccess::$user->rights->don->lire) { if(! DolibarrApiAccess::$user->rights->don->lire) {
throw new RestException(401); throw new RestException(401);
@@ -99,7 +99,7 @@ class Donations extends DolibarrApi
* *
* @throws RestException * @throws RestException
*/ */
function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $thirdparty_ids = '', $sqlfilters = '') public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $thirdparty_ids = '', $sqlfilters = '')
{ {
global $db, $conf; global $db, $conf;
@@ -115,7 +115,7 @@ class Donations extends DolibarrApi
$sql.= ' WHERE t.entity IN ('.getEntity('don').')'; $sql.= ' WHERE t.entity IN ('.getEntity('don').')';
if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) ) $sql.= " AND t.fk_soc = sc.fk_soc"; if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) ) $sql.= " AND t.fk_soc = sc.fk_soc";
if ($thirdparty_ids) $sql.= " AND t.fk_soc = ".$thirdparty_ids." "; if ($thirdparty_ids) $sql.= " AND t.fk_soc = ".$thirdparty_ids." ";
// Add sql filters // Add sql filters
if ($sqlfilters) if ($sqlfilters)
{ {
@@ -140,7 +140,7 @@ class Donations extends DolibarrApi
dol_syslog("API Rest request"); dol_syslog("API Rest request");
$result = $db->query($sql); $result = $db->query($sql);
if ($result) if ($result)
{ {
$num = $db->num_rows($result); $num = $db->num_rows($result);
@@ -164,7 +164,7 @@ class Donations extends DolibarrApi
if( ! count($obj_ret)) { if( ! count($obj_ret)) {
throw new RestException(404, 'No donation found'); throw new RestException(404, 'No donation found');
} }
return $obj_ret; return $obj_ret;
} }
@@ -174,15 +174,15 @@ class Donations extends DolibarrApi
* @param array $request_data Request data * @param array $request_data Request data
* @return int ID of order * @return int ID of order
*/ */
function post($request_data = null) public function post($request_data = null)
{ {
if(! DolibarrApiAccess::$user->rights->don->creer) { if (! DolibarrApiAccess::$user->rights->don->creer) {
throw new RestException(401, "Insuffisant rights"); throw new RestException(401, "Insuffisant rights");
} }
// 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->don->$field = $value; $this->don->$field = $value;
} }
/*if (isset($request_data["lines"])) { /*if (isset($request_data["lines"])) {
@@ -208,7 +208,7 @@ class Donations extends DolibarrApi
* *
* @return int * @return int
*/ */
function put($id, $request_data = null) public function put($id, $request_data = null)
{ {
if (! DolibarrApiAccess::$user->rights->don->creer) { if (! DolibarrApiAccess::$user->rights->don->creer) {
throw new RestException(401); throw new RestException(401);
@@ -222,7 +222,7 @@ class Donations extends DolibarrApi
if (! DolibarrApi::_checkAccessToResource('donation', $this->don->id)) { if (! DolibarrApi::_checkAccessToResource('donation', $this->don->id)) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); throw new RestException(401, 'Access 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->don->$field = $value; $this->don->$field = $value;
} }
@@ -243,7 +243,7 @@ class Donations extends DolibarrApi
* @param int $id Order ID * @param int $id Order ID
* @return array * @return array
*/ */
function delete($id) public function delete($id)
{ {
if(! DolibarrApiAccess::$user->rights->don->supprimer) { if(! DolibarrApiAccess::$user->rights->don->supprimer) {
throw new RestException(401); throw new RestException(401);
@@ -291,7 +291,7 @@ class Donations extends DolibarrApi
* *
* @return array * @return array
*/ */
function validate($id, $idwarehouse = 0, $notrigger = 0) public function validate($id, $idwarehouse = 0, $notrigger = 0)
{ {
if(! DolibarrApiAccess::$user->rights->don->creer) { if(! DolibarrApiAccess::$user->rights->don->creer) {
throw new RestException(401); throw new RestException(401);
@@ -332,7 +332,7 @@ class Donations extends DolibarrApi
* @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
*/ */
function _cleanObjectDatas($object) private function _cleanObjectDatas($object)
{ {
$object = parent::_cleanObjectDatas($object); $object = parent::_cleanObjectDatas($object);
@@ -354,7 +354,7 @@ class Donations extends DolibarrApi
* @return array * @return array
* @throws RestException * @throws RestException
*/ */
function _validate($data) private function _validate($data)
{ {
$don = array(); $don = array();
foreach (Orders::$FIELDS as $field) { foreach (Orders::$FIELDS as $field) {

View File

@@ -39,12 +39,12 @@ class DonationStats extends Stats
*/ */
public $table_element; public $table_element;
var $socid; public $socid;
var $userid; public $userid;
var $from; public $from;
var $field; public $field;
var $where; public $where;
/** /**
@@ -55,7 +55,7 @@ class DonationStats extends Stats
* @param string $mode Option (not used) * @param string $mode Option (not used)
* @param int $userid Id user for filter (creation user) * @param int $userid Id user for filter (creation user)
*/ */
function __construct($db, $socid, $mode, $userid = 0) public function __construct($db, $socid, $mode, $userid = 0)
{ {
global $user, $conf; global $user, $conf;
@@ -77,13 +77,13 @@ class DonationStats extends Stats
} }
/** /**
* Return shipment number by month for a year * Return shipment number by month for a year
* *
* @param int $year Year to scan * @param int $year Year to scan
* @param int $format 0=Label of absiss is a translated text, 1=Label of absiss is month number, 2=Label of absiss is first letter of month * @param int $format 0=Label of absiss is a translated text, 1=Label of absiss is month number, 2=Label of absiss is first letter of month
* @return array Array with number by month * @return array Array with number by month
*/ */
function getNbByMonth($year, $format = 0) public function getNbByMonth($year, $format = 0)
{ {
global $user; global $user;
@@ -104,7 +104,7 @@ class DonationStats extends Stats
* @return array Array with number by year * @return array Array with number by year
* *
*/ */
function getNbByYear() public function getNbByYear()
{ {
global $user; global $user;
@@ -117,21 +117,21 @@ class DonationStats extends Stats
return $this->_getNbByYear($sql); return $this->_getNbByYear($sql);
} }
/** /**
* Return nb, total and average * Return nb, total and average
* *
* @return array Array of values * @return array Array of values
*/ */
function getAllByYear() public function getAllByYear()
{ {
global $user; global $user;
$sql = "SELECT date_format(d.datedon,'%Y') as year, COUNT(*) as nb, SUM(d.".$this->field.") as total, AVG(".$this->field.") as avg"; $sql = "SELECT date_format(d.datedon,'%Y') as year, COUNT(*) as nb, SUM(d.".$this->field.") as total, AVG(".$this->field.") as avg";
$sql.= " FROM ".$this->from; $sql.= " FROM ".$this->from;
$sql.= " WHERE ".$this->where; $sql.= " WHERE ".$this->where;
$sql.= " GROUP BY year"; $sql.= " GROUP BY year";
$sql.= $this->db->order('year', 'DESC'); $sql.= $this->db->order('year', 'DESC');
return $this->_getAllByYear($sql); return $this->_getAllByYear($sql);
} }
} }

View File

@@ -88,7 +88,7 @@ class PaymentDonation extends CommonObject
* *
* @param DoliDB $db Database handler * @param DoliDB $db Database handler
*/ */
function __construct($db) public function __construct($db)
{ {
$this->db = $db; $this->db = $db;
} }
@@ -101,7 +101,7 @@ class PaymentDonation extends CommonObject
* @param bool $notrigger false=launch triggers after, true=disable triggers * @param bool $notrigger false=launch triggers after, true=disable triggers
* @return int <0 if KO, id of payment if OK * @return int <0 if KO, id of payment if OK
*/ */
function create($user, $notrigger = false) public function create($user, $notrigger = false)
{ {
global $conf, $langs; global $conf, $langs;
@@ -193,7 +193,7 @@ class PaymentDonation extends CommonObject
* @param int $id Id object * @param int $id Id object
* @return int <0 if KO, >0 if OK * @return int <0 if KO, >0 if OK
*/ */
function fetch($id) public function fetch($id)
{ {
global $langs; global $langs;
$sql = "SELECT"; $sql = "SELECT";
@@ -264,7 +264,7 @@ class PaymentDonation extends CommonObject
* @param int $notrigger 0=launch triggers after, 1=disable triggers * @param int $notrigger 0=launch triggers after, 1=disable triggers
* @return int <0 if KO, >0 if OK * @return int <0 if KO, >0 if OK
*/ */
function update($user, $notrigger = 0) public function update($user, $notrigger = 0)
{ {
global $conf, $langs; global $conf, $langs;
$error=0; $error=0;
@@ -344,7 +344,7 @@ class PaymentDonation extends CommonObject
* @param int $notrigger 0=launch triggers after, 1=disable triggers * @param int $notrigger 0=launch triggers after, 1=disable triggers
* @return int <0 if KO, >0 if OK * @return int <0 if KO, >0 if OK
*/ */
function delete($user, $notrigger = 0) public function delete($user, $notrigger = 0)
{ {
global $conf, $langs; global $conf, $langs;
$error=0; $error=0;
@@ -411,7 +411,7 @@ class PaymentDonation extends CommonObject
* @param int $fromid Id of object to clone * @param int $fromid Id of object to clone
* @return int New id of clone * @return int New id of clone
*/ */
function createFromClone($fromid) public function createFromClone($fromid)
{ {
global $user,$langs; global $user,$langs;
@@ -467,12 +467,12 @@ class PaymentDonation extends CommonObject
* @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long
* @return string Libelle * @return string Libelle
*/ */
function getLibStatut($mode = 0) public function getLibStatut($mode = 0)
{ {
return ''; return '';
} }
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/** /**
* Renvoi le libelle d'un statut donne * Renvoi le libelle d'un statut donne
* *
@@ -480,13 +480,13 @@ class PaymentDonation extends CommonObject
* @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto
* @return string Libelle du statut * @return string Libelle du statut
*/ */
function LibStatut($statut, $mode = 0) public function LibStatut($statut, $mode = 0)
{ {
// phpcs:enable // phpcs:enable
global $langs; global $langs;
return ''; return '';
} }
/** /**
@@ -496,7 +496,7 @@ class PaymentDonation extends CommonObject
* *
* @return void * @return void
*/ */
function initAsSpecimen() public function initAsSpecimen()
{ {
$this->id=0; $this->id=0;
@@ -526,7 +526,7 @@ class PaymentDonation extends CommonObject
* @param string $emetteur_banque Name of bank * @param string $emetteur_banque Name of bank
* @return int <0 if KO, >0 if OK * @return int <0 if KO, >0 if OK
*/ */
function addPaymentToBank($user, $mode, $label, $accountid, $emetteur_nom, $emetteur_banque) public function addPaymentToBank($user, $mode, $label, $accountid, $emetteur_nom, $emetteur_banque)
{ {
global $conf; global $conf;
@@ -597,14 +597,14 @@ class PaymentDonation extends CommonObject
} }
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/** /**
* Update link between the donation payment and the generated line in llx_bank * Update link between the donation payment and the generated line in llx_bank
* *
* @param int $id_bank Id if bank * @param int $id_bank Id if bank
* @return int >0 if OK, <=0 if KO * @return int >0 if OK, <=0 if KO
*/ */
function update_fk_bank($id_bank) public function update_fk_bank($id_bank)
{ {
// phpcs:enable // phpcs:enable
$sql = "UPDATE ".MAIN_DB_PREFIX."payment_donation SET fk_bank = ".$id_bank." WHERE rowid = ".$this->id; $sql = "UPDATE ".MAIN_DB_PREFIX."payment_donation SET fk_bank = ".$id_bank." WHERE rowid = ".$this->id;
@@ -629,7 +629,7 @@ class PaymentDonation extends CommonObject
* @param int $maxlen Longueur max libelle * @param int $maxlen Longueur max libelle
* @return string Chaine avec URL * @return string Chaine avec URL
*/ */
function getNomUrl($withpicto = 0, $maxlen = 0) public function getNomUrl($withpicto = 0, $maxlen = 0)
{ {
global $langs; global $langs;

View File

@@ -99,22 +99,22 @@ class EmailCollector extends CommonObject
'login' => array('type'=>'varchar(128)', 'label'=>'Login', 'visible'=>1, 'enabled'=>1, 'position'=>101, 'notnull'=>-1, 'index'=>1, 'comment'=>"IMAP login", 'help'=>'Example: myaccount@gmail.com'), 'login' => array('type'=>'varchar(128)', 'label'=>'Login', 'visible'=>1, 'enabled'=>1, 'position'=>101, 'notnull'=>-1, 'index'=>1, 'comment'=>"IMAP login", 'help'=>'Example: myaccount@gmail.com'),
'password' => array('type'=>'password', 'label'=>'Password', 'visible'=>-1, 'enabled'=>1, 'position'=>102, 'notnull'=>-1, 'comment'=>"IMAP password"), 'password' => array('type'=>'password', 'label'=>'Password', 'visible'=>-1, 'enabled'=>1, 'position'=>102, 'notnull'=>-1, 'comment'=>"IMAP password"),
'source_directory' => array('type'=>'varchar(255)', 'label'=>'MailboxSourceDirectory', 'visible'=>-1, 'enabled'=>1, 'position'=>103, 'notnull'=>1, 'default' => 'Inbox', 'help'=>'Example: INBOX'), 'source_directory' => array('type'=>'varchar(255)', 'label'=>'MailboxSourceDirectory', 'visible'=>-1, 'enabled'=>1, 'position'=>103, 'notnull'=>1, 'default' => 'Inbox', 'help'=>'Example: INBOX'),
//'filter' => array('type'=>'text', 'label'=>'Filter', 'visible'=>1, 'enabled'=>1, 'position'=>105), //'filter' => array('type'=>'text', 'label'=>'Filter', 'visible'=>1, 'enabled'=>1, 'position'=>105),
//'actiontodo' => array('type'=>'varchar(255)', 'label'=>'ActionToDo', 'visible'=>1, 'enabled'=>1, 'position'=>106), //'actiontodo' => array('type'=>'varchar(255)', 'label'=>'ActionToDo', 'visible'=>1, 'enabled'=>1, 'position'=>106),
'target_directory' => array('type'=>'varchar(255)', 'label'=>'MailboxTargetDirectory', 'visible'=>1, 'enabled'=>1, 'position'=>110, 'notnull'=>0, 'comment'=>"Where to store messages once processed"), 'target_directory' => array('type'=>'varchar(255)', 'label'=>'MailboxTargetDirectory', 'visible'=>1, 'enabled'=>1, 'position'=>110, 'notnull'=>0, 'comment'=>"Where to store messages once processed"),
'datelastresult' => array('type'=>'datetime', 'label'=>'DateLastResult', 'visible'=>1, 'enabled'=>'$action != "create" && $action != "edit"', 'position'=>121, 'notnull'=>-1,), 'datelastresult' => array('type'=>'datetime', 'label'=>'DateLastResult', 'visible'=>1, 'enabled'=>'$action != "create" && $action != "edit"', 'position'=>121, 'notnull'=>-1,),
'codelastresult' => array('type'=>'varchar(16)', 'label'=>'CodeLastResult', 'visible'=>1, 'enabled'=>'$action != "create" && $action != "edit"', 'position'=>122, 'notnull'=>-1,), 'codelastresult' => array('type'=>'varchar(16)', 'label'=>'CodeLastResult', 'visible'=>1, 'enabled'=>'$action != "create" && $action != "edit"', 'position'=>122, 'notnull'=>-1,),
'lastresult' => array('type'=>'varchar(255)', 'label'=>'LastResult', 'visible'=>1, 'enabled'=>'$action != "create" && $action != "edit"', 'position'=>123, 'notnull'=>-1,), 'lastresult' => array('type'=>'varchar(255)', 'label'=>'LastResult', 'visible'=>1, 'enabled'=>'$action != "create" && $action != "edit"', 'position'=>123, 'notnull'=>-1,),
'note_public' => array('type'=>'html', 'label'=>'NotePublic', 'visible'=>0, 'enabled'=>1, 'position'=>61, 'notnull'=>-1,), 'note_public' => array('type'=>'html', 'label'=>'NotePublic', 'visible'=>0, 'enabled'=>1, 'position'=>61, 'notnull'=>-1,),
'note_private' => array('type'=>'html', 'label'=>'NotePrivate', 'visible'=>0, 'enabled'=>1, 'position'=>62, 'notnull'=>-1,), 'note_private' => array('type'=>'html', 'label'=>'NotePrivate', 'visible'=>0, 'enabled'=>1, 'position'=>62, 'notnull'=>-1,),
'date_creation' => array('type'=>'datetime', 'label'=>'DateCreation', 'visible'=>-2, 'enabled'=>1, 'position'=>500, 'notnull'=>1,), 'date_creation' => array('type'=>'datetime', 'label'=>'DateCreation', 'visible'=>-2, 'enabled'=>1, 'position'=>500, 'notnull'=>1,),
'tms' => array('type'=>'timestamp', 'label'=>'DateModification', 'visible'=>-2, 'enabled'=>1, 'position'=>501, 'notnull'=>1,), 'tms' => array('type'=>'timestamp', 'label'=>'DateModification', 'visible'=>-2, 'enabled'=>1, 'position'=>501, 'notnull'=>1,),
//'date_validation' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-2, 'position'=>502), //'date_validation' => array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-2, 'position'=>502),
'fk_user_creat' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserAuthor', 'visible'=>-2, 'enabled'=>1, 'position'=>510, 'notnull'=>1,), 'fk_user_creat' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserAuthor', 'visible'=>-2, 'enabled'=>1, 'position'=>510, 'notnull'=>1,),
'fk_user_modif' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserModif', 'visible'=>-2, 'enabled'=>1, 'position'=>511, 'notnull'=>-1,), 'fk_user_modif' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserModif', 'visible'=>-2, 'enabled'=>1, 'position'=>511, 'notnull'=>-1,),
//'fk_user_valid' =>array('type'=>'integer', 'label'=>'UserValidation', 'enabled'=>1, 'visible'=>-1, 'position'=>512), //'fk_user_valid' =>array('type'=>'integer', 'label'=>'UserValidation', 'enabled'=>1, 'visible'=>-1, 'position'=>512),
'import_key' => array('type'=>'varchar(14)', 'label'=>'ImportId', 'visible'=>-2, 'enabled'=>1, 'position'=>1000, 'notnull'=>-1,), 'import_key' => array('type'=>'varchar(14)', 'label'=>'ImportId', 'visible'=>-2, 'enabled'=>1, 'position'=>1000, 'notnull'=>-1,),
'status' => array('type'=>'integer', 'label'=>'Status', 'visible'=>1, 'enabled'=>1, 'position'=>1000, 'notnull'=>1, 'index'=>1, 'arrayofkeyval'=>array('0'=>'Inactive', '1'=>'Active')) 'status' => array('type'=>'integer', 'label'=>'Status', 'visible'=>1, 'enabled'=>1, 'position'=>1000, 'notnull'=>1, 'index'=>1, 'arrayofkeyval'=>array('0'=>'Inactive', '1'=>'Active'))
); );
@@ -305,14 +305,16 @@ class EmailCollector extends CommonObject
* *
* @return int <0 if KO, 0 if not found, >0 if OK * @return int <0 if KO, 0 if not found, >0 if OK
*/ */
/*public function fetchLines() /*
{ public function fetchLines()
$this->lines=array(); {
$this->lines=array();
// Load lines with object EmailCollectorLine // Load lines with object EmailCollectorLine
return count($this->lines)?1:0; return count($this->lines)?1:0;
}*/ }
*/
/** /**
* Fetch all account and load objects into an array * Fetch all account and load objects into an array
@@ -407,7 +409,7 @@ class EmailCollector extends CommonObject
* @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
*/ */
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 $db, $conf, $langs, $hookmanager; global $db, $conf, $langs, $hookmanager;
global $dolibarr_main_authentication, $dolibarr_main_demo; global $dolibarr_main_authentication, $dolibarr_main_demo;
@@ -549,7 +551,7 @@ class EmailCollector extends CommonObject
*/ */
public function info($id) public function info($id)
{ {
$sql = 'SELECT rowid, date_creation as datec, tms as datem,'; $sql = 'SELECT rowid, date_creation as datec, tms as datem,';
$sql.= ' fk_user_creat, fk_user_modif'; $sql.= ' fk_user_creat, fk_user_modif';
$sql.= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; $sql.= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t';
$sql.= ' WHERE t.rowid = '.$id; $sql.= ' WHERE t.rowid = '.$id;
@@ -673,7 +675,7 @@ class EmailCollector extends CommonObject
* *
* @return string * @return string
*/ */
function getConnectStringIMAP() public function getConnectStringIMAP()
{ {
// Connect to IMAP // Connect to IMAP
$flags ='/service=imap'; // IMAP $flags ='/service=imap'; // IMAP

View File

@@ -32,298 +32,301 @@ require_once DOL_DOCUMENT_ROOT . '/core/class/commonobject.class.php';
*/ */
class EmailCollectorAction extends CommonObject class EmailCollectorAction extends CommonObject
{ {
/** /**
* @var string ID to identify managed object * @var string ID to identify managed object
*/ */
public $element = 'emailcollectoraction'; public $element = 'emailcollectoraction';
/** /**
* @var string Name of table without prefix where object is stored * @var string Name of table without prefix where object is stored
*/ */
public $table_element = 'emailcollector_emailcollectoraction'; public $table_element = 'emailcollector_emailcollectoraction';
/** /**
* @var int Does emailcollectoraction support multicompany module ? 0=No test on entity, 1=Test with field entity, 2=Test with link by societe * @var int Does emailcollectoraction support multicompany module ? 0=No test on entity, 1=Test with field entity, 2=Test with link by societe
*/ */
public $ismultientitymanaged = 0; public $ismultientitymanaged = 0;
/** /**
* @var int Does emailcollectoraction support extrafields ? 0=No, 1=Yes * @var int Does emailcollectoraction support extrafields ? 0=No, 1=Yes
*/ */
public $isextrafieldmanaged = 0; public $isextrafieldmanaged = 0;
/** /**
* @var string String with name of icon for emailcollectoraction. Must be the part after the 'object_' into object_emailcollectoraction.png * @var string String with name of icon for emailcollectoraction. Must be the part after the 'object_' into object_emailcollectoraction.png
*/ */
public $picto = 'emailcollectoraction@emailcollector'; public $picto = 'emailcollectoraction@emailcollector';
/** /**
* 'type' if the field format. * 'type' if the field format.
* 'label' the translation key. * 'label' the translation key.
* 'enabled' is a condition when the field must be managed. * 'enabled' is a condition when the field must be managed.
* 'visible' says if field is visible in list (Examples: 0=Not visible, 1=Visible on list and create/update/view forms, 2=Visible on list only. Using a negative value means field is not shown by default on list but can be selected for viewing) * 'visible' says if field is visible in list (Examples: 0=Not visible, 1=Visible on list and create/update/view forms, 2=Visible on list only. Using a negative value means field is not shown by default on list but can be selected for viewing)
* 'notnull' is set to 1 if not null in database. Set to -1 if we must set data to null if empty ('' or 0). * 'notnull' is set to 1 if not null in database. Set to -1 if we must set data to null if empty ('' or 0).
* 'default' is a default value for creation (can still be replaced by the global setup of default values) * 'default' is a default value for creation (can still be replaced by the global setup of default values)
* 'index' if we want an index in database. * 'index' if we want an index in database.
* 'foreignkey'=>'tablename.field' if the field is a foreign key (it is recommanded to name the field fk_...). * 'foreignkey'=>'tablename.field' if the field is a foreign key (it is recommanded to name the field fk_...).
* 'position' is the sort order of field. * 'position' is the sort order of field.
* 'searchall' is 1 if we want to search in this field when making a search from the quick search button. * 'searchall' is 1 if we want to search in this field when making a search from the quick search button.
* 'isameasure' must be set to 1 if you want to have a total on list for this field. Field type must be summable like integer or double(24,8). * 'isameasure' must be set to 1 if you want to have a total on list for this field. Field type must be summable like integer or double(24,8).
* 'css' is the CSS style to use on field. For example: 'maxwidth200' * 'css' is the CSS style to use on field. For example: 'maxwidth200'
* 'help' is a string visible as a tooltip on field * 'help' is a string visible as a tooltip on field
* 'comment' is not used. You can store here any text of your choice. It is not used by application. * 'comment' is not used. You can store here any text of your choice. It is not used by application.
* 'showoncombobox' if value of the field must be visible into the label of the combobox that list record * 'showoncombobox' if value of the field must be visible into the label of the combobox that list record
* 'arraykeyval' to set list of value if type is a list of predefined values. For example: array("0"=>"Draft","1"=>"Active","-1"=>"Cancel") * 'arraykeyval' to set list of value if type is a list of predefined values. For example: array("0"=>"Draft","1"=>"Active","-1"=>"Cancel")
*/ */
// 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'=>-1, 'position'=>1, 'notnull'=>1, 'index'=>1, 'comment'=>"Id",), 'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-1, 'position'=>1, 'notnull'=>1, 'index'=>1, 'comment'=>"Id",),
'fk_emailcollector' => array('type'=>'integer', 'label'=>'Id of emailcollector', 'foreignkey'=>'emailcollector.rowid'), 'fk_emailcollector' => array('type'=>'integer', 'label'=>'Id of emailcollector', 'foreignkey'=>'emailcollector.rowid'),
'type' => array('type'=>'varchar(128)', 'label'=>'Type', 'enabled'=>1, 'visible'=>1, 'position'=>10, 'notnull'=>1, 'index'=>1), 'type' => array('type'=>'varchar(128)', 'label'=>'Type', 'enabled'=>1, 'visible'=>1, 'position'=>10, 'notnull'=>1, 'index'=>1),
'actionparam' => array('type'=>'varchar(255)', 'label'=>'ParamForAction', 'enabled'=>1, 'visible'=>1, 'position'=>40, 'notnull'=>-1), 'actionparam' => array('type'=>'varchar(255)', 'label'=>'ParamForAction', 'enabled'=>1, 'visible'=>1, 'position'=>40, 'notnull'=>-1),
'date_creation' => array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-2, 'position'=>500, 'notnull'=>1,), 'date_creation' => array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-2, 'position'=>500, 'notnull'=>1,),
'tms' => array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-2, 'position'=>501, 'notnull'=>1,), 'tms' => array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-2, 'position'=>501, 'notnull'=>1,),
'fk_user_creat' => array('type'=>'integer', 'label'=>'UserAuthor', 'enabled'=>1, 'visible'=>-2, 'position'=>510, 'notnull'=>1, 'foreignkey'=>'llx_user.rowid',), 'fk_user_creat' => array('type'=>'integer', 'label'=>'UserAuthor', 'enabled'=>1, 'visible'=>-2, 'position'=>510, 'notnull'=>1, 'foreignkey'=>'llx_user.rowid',),
'fk_user_modif' => array('type'=>'integer', 'label'=>'UserModif', 'enabled'=>1, 'visible'=>-2, 'position'=>511, 'notnull'=>-1,), 'fk_user_modif' => array('type'=>'integer', 'label'=>'UserModif', 'enabled'=>1, 'visible'=>-2, 'position'=>511, 'notnull'=>-1,),
'position' => array('type'=>'integer', 'label'=>'Position', 'enabled'=>1, 'visible'=>1, 'position'=>600, 'default'=>'0',), 'position' => array('type'=>'integer', 'label'=>'Position', 'enabled'=>1, 'visible'=>1, 'position'=>600, 'default'=>'0',),
'import_key' => array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>1, 'visible'=>-2, 'position'=>1000, 'notnull'=>-1,), 'import_key' => array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>1, 'visible'=>-2, 'position'=>1000, 'notnull'=>-1,),
'status' => array('type'=>'integer', 'label'=>'Status', 'enabled'=>1, 'visible'=>1, 'position'=>1000, 'notnull'=>1, 'default'=>1, 'arrayofkeyval'=>array('0'=>'Disabled', '1'=>'Enabled')), 'status' => array('type'=>'integer', 'label'=>'Status', 'enabled'=>1, 'visible'=>1, 'position'=>1000, 'notnull'=>1, 'default'=>1, 'arrayofkeyval'=>array('0'=>'Disabled', '1'=>'Enabled')),
); );
public $rowid; public $rowid;
public $fk_emailcollector; public $fk_emailcollector;
public $type; public $type;
public $actionparam; public $actionparam;
public $date_creation; public $date_creation;
public $tms; public $tms;
public $fk_user_creat; public $fk_user_creat;
public $fk_user_modif; public $fk_user_modif;
public $position; public $position;
public $import_key; public $import_key;
public $status; public $status;
// END MODULEBUILDER PROPERTIES // END MODULEBUILDER PROPERTIES
// If this object has a subtable with lines // If this object has a subtable with lines
/** // /**
* @var int Name of subtable line // * @var int Name of subtable line
*/ // */
//public $table_element_line = 'emailcollectoractiondet'; //public $table_element_line = 'emailcollectoractiondet';
/** // /**
* @var int Field with ID of parent key if this field has a parent // * @var int Field with ID of parent key if this field has a parent
*/ // */
//public $fk_element = 'fk_emailcollectoraction'; //public $fk_element = 'fk_emailcollectoraction';
/** // /**
* @var int Name of subtable class that manage subtable lines // * @var int Name of subtable class that manage subtable lines
*/ // */
//public $class_element_line = 'EmailcollectorActionline'; //public $class_element_line = 'EmailcollectorActionline';
/** // /**
* @var array Array of child tables (child tables to delete before deleting a record) // * @var array Array of child tables (child tables to delete before deleting a record)
*/ // */
//protected $childtables=array('emailcollectoractiondet'); //protected $childtables=array('emailcollectoractiondet');
/** // /**
* @var EmailcollectorActionLine[] Array of subtable lines // * @var EmailcollectorActionLine[] Array of subtable lines
*/ // */
//public $lines = array(); //public $lines = array();
/** /**
* Constructor * Constructor
* *
* @param DoliDb $db Database handler * @param DoliDb $db Database handler
*/ */
public function __construct(DoliDB $db) public function __construct(DoliDB $db)
{ {
global $conf, $langs, $user; global $conf, $langs, $user;
$this->db = $db; $this->db = $db;
if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID) && isset($this->fields['rowid'])) $this->fields['rowid']['visible']=0; if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID) && isset($this->fields['rowid'])) $this->fields['rowid']['visible']=0;
if (empty($conf->multicompany->enabled) && isset($this->fields['entity'])) $this->fields['entity']['enabled']=0; if (empty($conf->multicompany->enabled) && isset($this->fields['entity'])) $this->fields['entity']['enabled']=0;
// Unset fields that are disabled // Unset fields that are disabled
foreach($this->fields as $key => $val) foreach($this->fields as $key => $val)
{ {
if (isset($val['enabled']) && empty($val['enabled'])) if (isset($val['enabled']) && empty($val['enabled']))
{ {
unset($this->fields[$key]); unset($this->fields[$key]);
} }
} }
// Translate some data of arrayofkeyval // Translate some data of arrayofkeyval
foreach($this->fields as $key => $val) foreach($this->fields as $key => $val)
{ {
if (is_array($this->fields['status']['arrayofkeyval'])) if (is_array($this->fields['status']['arrayofkeyval']))
{ {
foreach($this->fields['status']['arrayofkeyval'] as $key2 => $val2) foreach($this->fields['status']['arrayofkeyval'] as $key2 => $val2)
{ {
$this->fields['status']['arrayofkeyval'][$key2]=$langs->trans($val2); $this->fields['status']['arrayofkeyval'][$key2]=$langs->trans($val2);
} }
} }
} }
} }
/** /**
* Create object into database * Create object into database
* *
* @param User $user User that creates * @param User $user User that creates
* @param bool $notrigger false=launch triggers after, true=disable triggers * @param bool $notrigger false=launch triggers after, true=disable triggers
* @return int <0 if KO, Id of created object if OK * @return int <0 if KO, Id of created object if OK
*/ */
public function create(User $user, $notrigger = false) public function create(User $user, $notrigger = false)
{ {
global $langs; global $langs;
if (empty($this->type)) if (empty($this->type))
{ {
$langs->load("errors"); $langs->load("errors");
$this->errors[]=$langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")); $this->errors[]=$langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type"));
return -1; return -1;
} }
return $this->createCommon($user, $notrigger); return $this->createCommon($user, $notrigger);
} }
/** /**
* Clone and object into another one * Clone and object into another one
* *
* @param User $user User that creates * @param User $user User that creates
* @param int $fromid Id of object to clone * @param int $fromid Id of object to clone
* @return mixed New object created, <0 if KO * @return mixed New object created, <0 if KO
*/ */
public function createFromClone(User $user, $fromid) public function createFromClone(User $user, $fromid)
{ {
global $langs, $hookmanager, $extrafields; global $langs, $hookmanager, $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
$object->fetchCommon($fromid); $object->fetchCommon($fromid);
// 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 = "copy_of_".$object->ref; $object->ref = "copy_of_".$object->ref;
$object->title = $langs->trans("CopyOf")." ".$object->title; $object->title = $langs->trans("CopyOf")." ".$object->title;
// ... // ...
// 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->element); $extrafields->fetch_name_optionals_label($this->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; $thi /**
$this->errors = $object->errors; * @var EmailcollectorActionLine[] Array of subtable lines
} */
s->error = $object->error;
$this->errors = $object->errors;
}
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;
} }
} }
/** /**
* Load object in memory from the database * Load object in memory from the database
* *
* @param int $id Id object * @param int $id Id object
* @param string $ref Ref * @param string $ref Ref
* @return int <0 if KO, 0 if not found, >0 if OK * @return int <0 if KO, 0 if not found, >0 if OK
*/ */
public function fetch($id, $ref = null) public function fetch($id, $ref = null)
{ {
$result = $this->fetchCommon($id, $ref); $result = $this->fetchCommon($id, $ref);
if ($result > 0 && ! empty($this->table_element_line)) $this->fetchLines(); if ($result > 0 && ! empty($this->table_element_line)) $this->fetchLines();
return $result; return $result;
} }
/** /**
* Load object lines in memory from the database * Load object lines in memory from the database
* *
* @return int <0 if KO, 0 if not found, >0 if OK * @return int <0 if KO, 0 if not found, >0 if OK
*/ */
/*public function fetchLines() /*public function fetchLines()
{ {
$this->lines=array(); $this->lines=array();
// Load lines with object EmailcollectorActionLine // Load lines with object EmailcollectorActionLine
return count($this->lines)?1:0; return count($this->lines)?1:0;
}*/ }*/
/** /**
* Update object into database * Update object into database
* *
* @param User $user User that modifies * @param User $user User that modifies
* @param bool $notrigger false=launch triggers after, true=disable triggers * @param bool $notrigger false=launch triggers after, true=disable triggers
* @return int <0 if KO, >0 if OK * @return int <0 if KO, >0 if OK
*/ */
public function update(User $user, $notrigger = false) public function update(User $user, $notrigger = false)
{ {
return $this->updateCommon($user, $notrigger); return $this->updateCommon($user, $notrigger);
} }
/** /**
* Delete object in database * Delete object in database
* *
* @param User $user User that deletes * @param User $user User that deletes
* @param bool $notrigger false=launch triggers after, true=disable triggers * @param bool $notrigger false=launch triggers after, true=disable triggers
* @return int <0 if KO, >0 if OK * @return int <0 if KO, >0 if OK
*/ */
public function delete(User $user, $notrigger = false) public function delete(User $user, $notrigger = false)
{ {
return $this->deleteCommon($user, $notrigger); return $this->deleteCommon($user, $notrigger);
} }
/** /**
* 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
*/ */
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 $db, $conf, $langs, $hookmanager; global $db, $conf, $langs, $hookmanager;
global $dolibarr_main_authentication, $dolibarr_main_demo; global $dolibarr_main_authentication, $dolibarr_main_demo;
global $menumanager; global $menumanager;
@@ -340,10 +343,10 @@ class EmailCollectorAction extends CommonObject
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='';
@@ -366,152 +369,152 @@ class EmailCollectorAction extends CommonObject
} }
else $linkclose = ($morecss?' class="'.$morecss.'"':''); else $linkclose = ($morecss?' class="'.$morecss.'"':'');
$linkstart = '<a href="'.$url.'"'; $linkstart = '<a href="'.$url.'"';
$linkstart.=$linkclose.'>'; $linkstart.=$linkclose.'>';
$linkend='</a>'; $linkend='</a>';
$result .= $linkstart; $result .= $linkstart;
if ($withpicto) $result.=img_object(($notooltip?'':$label), ($this->picto?$this->picto:'generic'), ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip?0:1); if ($withpicto) $result.=img_object(($notooltip?'':$label), ($this->picto?$this->picto:'generic'), ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip?0:1);
if ($withpicto != 2) $result.= $this->ref; if ($withpicto != 2) $result.= $this->ref;
$result .= $linkend; $result .= $linkend;
//if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : ''); //if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : '');
global $action,$hookmanager; global $action,$hookmanager;
$hookmanager->initHooks(array('emailcollectoractiondao')); $hookmanager->initHooks(array('emailcollectoractiondao'));
$parameters=array('id'=>$this->id, 'getnomurl'=>$result); $parameters=array('id'=>$this->id, 'getnomurl'=>$result);
$reshook=$hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks $reshook=$hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook > 0) $result = $hookmanager->resPrint; if ($reshook > 0) $result = $hookmanager->resPrint;
else $result .= $hookmanager->resPrint; else $result .= $hookmanager->resPrint;
return $result; return $result;
} }
/** /**
* Return label of the status * Return label of the status
* *
* @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto
* @return string Label of status * @return string Label of status
*/ */
public function getLibStatut($mode = 0) public function getLibStatut($mode = 0)
{ {
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
* *
* @param int $status Id status * @param int $status Id status
* @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto
* @return string Label of status * @return string Label of status
*/ */
public function LibStatut($status, $mode = 0) public function LibStatut($status, $mode = 0)
{ {
// phpcs:enable // phpcs:enable
if (empty($this->labelstatus)) if (empty($this->labelstatus))
{ {
global $langs; global $langs;
//$langs->load("emailcollector"); //$langs->load("emailcollector");
$this->labelstatus[1] = $langs->trans('Enabled'); $this->labelstatus[1] = $langs->trans('Enabled');
$this->labelstatus[0] = $langs->trans('Disabled'); $this->labelstatus[0] = $langs->trans('Disabled');
} }
if ($mode == 0) if ($mode == 0)
{ {
return $this->labelstatus[$status]; return $this->labelstatus[$status];
} }
elseif ($mode == 1) elseif ($mode == 1)
{ {
return $this->labelstatus[$status]; return $this->labelstatus[$status];
} }
elseif ($mode == 2) elseif ($mode == 2)
{ {
if ($status == 1) return img_picto($this->labelstatus[$status], 'statut4', '', false, 0, 0, '', 'valignmiddle').' '.$this->labelstatus[$status]; if ($status == 1) return img_picto($this->labelstatus[$status], 'statut4', '', false, 0, 0, '', 'valignmiddle').' '.$this->labelstatus[$status];
elseif ($status == 0) return img_picto($this->labelstatus[$status], 'statut5', '', false, 0, 0, '', 'valignmiddle').' '.$this->labelstatus[$status]; elseif ($status == 0) return img_picto($this->labelstatus[$status], 'statut5', '', false, 0, 0, '', 'valignmiddle').' '.$this->labelstatus[$status];
} }
elseif ($mode == 3) elseif ($mode == 3)
{ {
if ($status == 1) return img_picto($this->labelstatus[$status], 'statut4', '', false, 0, 0, '', 'valignmiddle'); if ($status == 1) return img_picto($this->labelstatus[$status], 'statut4', '', false, 0, 0, '', 'valignmiddle');
elseif ($status == 0) return img_picto($this->labelstatus[$status], 'statut5', '', false, 0, 0, '', 'valignmiddle'); elseif ($status == 0) return img_picto($this->labelstatus[$status], 'statut5', '', false, 0, 0, '', 'valignmiddle');
} }
elseif ($mode == 4) elseif ($mode == 4)
{ {
if ($status == 1) return img_picto($this->labelstatus[$status], 'statut4', '', false, 0, 0, '', 'valignmiddle').' '.$this->labelstatus[$status]; if ($status == 1) return img_picto($this->labelstatus[$status], 'statut4', '', false, 0, 0, '', 'valignmiddle').' '.$this->labelstatus[$status];
elseif ($status == 0) return img_picto($this->labelstatus[$status], 'statut5', '', false, 0, 0, '', 'valignmiddle').' '.$this->labelstatus[$status]; elseif ($status == 0) return img_picto($this->labelstatus[$status], 'statut5', '', false, 0, 0, '', 'valignmiddle').' '.$this->labelstatus[$status];
} }
elseif ($mode == 5) elseif ($mode == 5)
{ {
if ($status == 1) return $this->labelstatus[$status].' '.img_picto($this->labelstatus[$status], 'statut4', '', false, 0, 0, '', 'valignmiddle'); if ($status == 1) return $this->labelstatus[$status].' '.img_picto($this->labelstatus[$status], 'statut4', '', false, 0, 0, '', 'valignmiddle');
elseif ($status == 0) return $this->labelstatus[$status].' '.img_picto($this->labelstatus[$status], 'statut5', '', false, 0, 0, '', 'valignmiddle'); elseif ($status == 0) return $this->labelstatus[$status].' '.img_picto($this->labelstatus[$status], 'statut5', '', false, 0, 0, '', 'valignmiddle');
} }
elseif ($mode == 6) elseif ($mode == 6)
{ {
if ($status == 1) return $this->labelstatus[$status].' '.img_picto($this->labelstatus[$status], 'statut4', '', false, 0, 0, '', 'valignmiddle'); if ($status == 1) return $this->labelstatus[$status].' '.img_picto($this->labelstatus[$status], 'statut4', '', false, 0, 0, '', 'valignmiddle');
elseif ($status == 0) return $this->labelstatus[$status].' '.img_picto($this->labelstatus[$status], 'statut5', '', false, 0, 0, '', 'valignmiddle'); elseif ($status == 0) return $this->labelstatus[$status].' '.img_picto($this->labelstatus[$status], 'statut5', '', false, 0, 0, '', 'valignmiddle');
} }
} }
/** /**
* Charge les informations d'ordre info dans l'objet commande * Charge les informations d'ordre info dans l'objet commande
* *
* @param int $id Id of order * @param int $id Id of order
* @return void * @return void
*/ */
public function info($id) public function info($id)
{ {
$sql = 'SELECT rowid, date_creation as datec, tms as datem,'; $sql = 'SELECT rowid, date_creation as datec, tms as datem,';
$sql.= ' fk_user_creat, fk_user_modif'; $sql.= ' fk_user_creat, fk_user_modif';
$sql.= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; $sql.= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t';
$sql.= ' WHERE t.rowid = '.$id; $sql.= ' WHERE t.rowid = '.$id;
$result=$this->db->query($sql); $result=$this->db->query($sql);
if ($result) if ($result)
{ {
if ($this->db->num_rows($result)) if ($this->db->num_rows($result))
{ {
$obj = $this->db->fetch_object($result); $obj = $this->db->fetch_object($result);
$this->id = $obj->rowid; $this->id = $obj->rowid;
if ($obj->fk_user_author) if ($obj->fk_user_author)
{ {
$cuser = new User($this->db); $cuser = new User($this->db);
$cuser->fetch($obj->fk_user_author); $cuser->fetch($obj->fk_user_author);
$this->user_creation = $cuser; $this->user_creation = $cuser;
} }
if ($obj->fk_user_valid) if ($obj->fk_user_valid)
{ {
$vuser = new User($this->db); $vuser = new User($this->db);
$vuser->fetch($obj->fk_user_valid); $vuser->fetch($obj->fk_user_valid);
$this->user_validation = $vuser; $this->user_validation = $vuser;
} }
if ($obj->fk_user_cloture) if ($obj->fk_user_cloture)
{ {
$cluser = new User($this->db); $cluser = new User($this->db);
$cluser->fetch($obj->fk_user_cloture); $cluser->fetch($obj->fk_user_cloture);
$this->user_cloture = $cluser; $this->user_cloture = $cluser;
} }
$this->date_creation = $this->db->jdate($obj->datec); $this->date_creation = $this->db->jdate($obj->datec);
$this->date_modification = $this->db->jdate($obj->datem); $this->date_modification = $this->db->jdate($obj->datem);
$this->date_validation = $this->db->jdate($obj->datev); $this->date_validation = $this->db->jdate($obj->datev);
} }
$this->db->free($result); $this->db->free($result);
} }
else else
{ {
dol_print_error($this->db); dol_print_error($this->db);
} }
} }
/** /**
* Initialise object with example values * Initialise object with example values
* Id must be 0 if object instance is a specimen * Id must be 0 if object instance is a specimen
* *
* @return void * @return void
*/ */
public function initAsSpecimen() public function initAsSpecimen()
{ {
$this->initAsSpecimenCommon(); $this->initAsSpecimenCommon();
} }
} }

Some files were not shown because too many files have changed in this diff Show More