diff --git a/htdocs/api/class/api.class.php b/htdocs/api/class/api.class.php index 5595f94a950..c45d30c3a45 100644 --- a/htdocs/api/class/api.class.php +++ b/htdocs/api/class/api.class.php @@ -37,7 +37,7 @@ class DolibarrApi /** * @var Restler $r Restler object */ - var $r; + public $r; /** * Constructor @@ -46,7 +46,7 @@ class DolibarrApi * @param string $cachedir Cache dir * @param boolean $refreshCache Update cache */ - function __construct($db, $cachedir = '', $refreshCache = false) + public function __construct($db, $cachedir = '', $refreshCache = false) { global $conf, $dolibarr_main_url_root; @@ -94,7 +94,7 @@ class DolibarrApi * @param object $object Object to clean * @return array Array of cleaned object properties */ - function _cleanObjectDatas($object) + private function _cleanObjectDatas($object) { // Remove $db object property for object @@ -222,7 +222,7 @@ class DolibarrApi * @return bool * @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 @@ -240,7 +240,7 @@ class DolibarrApi } return checkUserAccessToObject(DolibarrApiAccess::$user, $featuresarray, $resource_id, $dbtablename, $feature2, $dbt_keyfield, $dbt_select); - } + } /** * Return if a $sqlfilters parameter is valid @@ -248,7 +248,7 @@ class DolibarrApi * @param string $sqlfilters sqlfilter string * @return boolean True if valid, False if not valid */ - function _checkFilters($sqlfilters) + private function _checkFilters($sqlfilters) { //$regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; //$tmp=preg_replace_all('/'.$regexstring.'/', '', $sqlfilters); @@ -271,14 +271,14 @@ class DolibarrApi return true; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Function to forge a SQL criteria * * @param array $matches Array of found string by regex search * @return string Forged criteria. Example: "t.field like 'abc%'" */ - static function _forge_criteria_callback($matches) + private static function _forge_criteria_callback($matches) { // phpcs:enable global $db; diff --git a/htdocs/api/class/api_access.class.php b/htdocs/api/class/api_access.class.php index 9c748fb5f03..010bb854f25 100644 --- a/htdocs/api/class/api_access.class.php +++ b/htdocs/api/class/api_access.class.php @@ -173,20 +173,20 @@ class DolibarrApiAccess implements iAuthenticate * @example Digest * @example OAuth */ - public function __getWWWAuthenticateString() + public function __getWWWAuthenticateString() { // phpcs:enable return ''; } - /** - * Verify access - * - * @param array $m Properties of method - * - * @access private - * @return bool - */ + /** + * Verify access + * + * @param array $m Properties of method + * + * @access private + * @return bool + */ public static function verifyAccess(array $m) { $requires = isset($m['class']['DolibarrApiAccess']['properties']['requires']) diff --git a/htdocs/api/class/api_documents.class.php b/htdocs/api/class/api_documents.class.php index 8db471855d6..a946aa86333 100644 --- a/htdocs/api/class/api_documents.class.php +++ b/htdocs/api/class/api_documents.class.php @@ -43,7 +43,7 @@ class Documents extends DolibarrApi /** * Constructor */ - function __construct() + public function __construct() { global $db; $this->db = $db; @@ -67,7 +67,7 @@ class Documents extends DolibarrApi * * @url GET /download */ - public function index($module_part, $original_file='') + public function index($module_part, $original_file = '') { global $conf, $langs; @@ -82,12 +82,11 @@ class Documents extends DolibarrApi $entity=$conf->entity; $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']; - $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); } if (!$accessallowed) { @@ -127,7 +126,7 @@ class Documents extends DolibarrApi * * @url PUT /builddoc */ - public function builddoc($module_part, $original_file='', $doctemplate='', $langcode='') + public function builddoc($module_part, $original_file = '', $doctemplate = '', $langcode = '') { global $conf, $langs; @@ -153,7 +152,7 @@ class Documents extends DolibarrApi $sqlprotectagainstexternals = $check_access['sqlprotectagainstexternals']; $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); } if (!$accessallowed) { @@ -245,7 +244,7 @@ class Documents extends DolibarrApi * * @url GET / */ - function getDocumentsListByElement($modulepart, $id=0, $ref='', $sortfield='', $sortorder='') + public function getDocumentsListByElement($modulepart, $id = 0, $ref = '', $sortfield = '', $sortorder = '') { global $conf; @@ -376,7 +375,7 @@ class Documents extends DolibarrApi 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)) { 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 $fileencoding File encoding (''=no encoding, 'base64'=Base 64) {@example '' or 'base64'} * @param int $overwriteifexists Overwrite file if exists (1 by default) + * @return string * * @throws 200 * @throws 400 @@ -421,7 +421,7 @@ class Documents extends DolibarrApi * * @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; @@ -501,7 +501,7 @@ class Documents extends DolibarrApi if($result == 0) { throw new RestException(404, "Object with ref '".$ref."' was not found."); - } + } elseif ($result < 0) { throw new RestException(500, 'Error while fetching object.'); @@ -576,6 +576,7 @@ class Documents extends DolibarrApi return dol_basename($destfile); } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName /** * Validate fields before create or update object * @@ -583,7 +584,8 @@ class Documents extends DolibarrApi * @return array * @throws RestException */ - function _validate_file($data) { + private function _validate_file($data) { + // phpcs:enable $result = array(); foreach (Documents::$DOCUMENT_FIELDS as $field) { if (!isset($data[$field])) diff --git a/htdocs/api/class/api_login.class.php b/htdocs/api/class/api_login.class.php index 43a0aeb9bbb..2bf464f7296 100644 --- a/htdocs/api/class/api_login.class.php +++ b/htdocs/api/class/api_login.class.php @@ -29,11 +29,11 @@ class Login /** * Constructor of the class */ - function __construct() + public function __construct() { - global $db; - $this->db = $db; - } + global $db; + $this->db = $db; + } /** * 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.') ) ); - } + } } diff --git a/htdocs/api/class/api_setup.class.php b/htdocs/api/class/api_setup.class.php index 00a84a00555..766cf79f7be 100644 --- a/htdocs/api/class/api_setup.class.php +++ b/htdocs/api/class/api_setup.class.php @@ -38,7 +38,7 @@ class Setup extends DolibarrApi /** * Constructor */ - function __construct() + public function __construct() { global $db; $this->db = $db; @@ -61,7 +61,7 @@ class Setup extends DolibarrApi * @throws 400 RestException * @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(); @@ -76,7 +76,7 @@ class Setup extends DolibarrApi { throw new RestException(400, 'error when validating parameter sqlfilters '.$sqlfilters); } - $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; + $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; $sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; } @@ -128,7 +128,7 @@ class Setup extends DolibarrApi * * @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(); @@ -195,7 +195,7 @@ class Setup extends DolibarrApi * * @throws RestException */ - function getCountryByID($id, $lang = '') + public function getCountryByID($id, $lang = '') { $country = new Ccountry($this->db); @@ -228,7 +228,7 @@ class Setup extends DolibarrApi * @throws 400 RestException * @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(); @@ -279,7 +279,7 @@ class Setup extends DolibarrApi * @param object $object Object to clean * @return array Array of cleaned object properties */ - function _cleanObjectDatas($object) + private function _cleanObjectDatas($object) { $object = parent::_cleanObjectDatas($object); @@ -334,7 +334,7 @@ class Setup extends DolibarrApi * * @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(); @@ -397,7 +397,7 @@ class Setup extends DolibarrApi * * @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(); @@ -442,7 +442,7 @@ class Setup extends DolibarrApi return $list; } - + /** * Get the list of currencies. * @@ -458,10 +458,10 @@ class Setup extends DolibarrApi * * @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(); - //TODO link with multicurrency module + //TODO link with multicurrency module $sql = "SELECT t.code_iso, t.label, t.unicode"; $sql.= " FROM ".MAIN_DB_PREFIX."c_currencies as t"; $sql.= " WHERE t.active = ".$active; @@ -516,7 +516,7 @@ class Setup extends DolibarrApi * * @throws RestException */ - function getListOfExtrafields($sortfield = "t.pos", $sortorder = 'ASC', $type = '', $sqlfilters = '') + public function getListOfExtrafields($sortfield = "t.pos", $sortorder = 'ASC', $type = '', $sqlfilters = '') { $list = array(); @@ -595,7 +595,7 @@ class Setup extends DolibarrApi * * @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(); @@ -659,7 +659,7 @@ class Setup extends DolibarrApi * @throws 400 RestException * @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(); @@ -720,7 +720,7 @@ class Setup extends DolibarrApi * * @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(); @@ -780,13 +780,13 @@ class Setup extends DolibarrApi * * @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(); $sql = "SELECT rowid, code, pos, label, use_default, color, description"; $sql.= " FROM ".MAIN_DB_PREFIX."c_ticket_severity as t"; - $sql.= " WHERE t.active = ".$active; + $sql.= " WHERE t.active = ".$active; // Add sql filters if ($sqlfilters) { @@ -840,13 +840,13 @@ class Setup extends DolibarrApi * * @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(); $sql = "SELECT rowid, code, pos, label, use_default, description"; $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 ($module) $sql.=" AND t.module LIKE '%" . $this->db->escape($module) . "%'"; // Add sql filters @@ -898,7 +898,7 @@ class Setup extends DolibarrApi * * @throws RestException */ - function getCheckIntegrity($target) + public function getCheckIntegrity($target) { global $langs, $conf; diff --git a/htdocs/api/class/api_status.class.php b/htdocs/api/class/api_status.class.php index 3ade4ea51b8..3e61b2e6d0a 100644 --- a/htdocs/api/class/api_status.class.php +++ b/htdocs/api/class/api_status.class.php @@ -31,7 +31,7 @@ class Status * * @return array */ - function index() + public function index() { global $conf; diff --git a/htdocs/asset/class/asset.class.php b/htdocs/asset/class/asset.class.php index aca175b59d2..8e9e31e68b2 100644 --- a/htdocs/asset/class/asset.class.php +++ b/htdocs/asset/class/asset.class.php @@ -23,8 +23,6 @@ */ 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 @@ -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 * @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 $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 * @return string Label of status */ - function getLibStatut($mode = 0) + public function getLibStatut($mode = 0) { return $this->LibStatut($this->status, $mode); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * 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 * @return string Label of status */ - static function LibStatut($status, $mode = 0) + public static function LibStatut($status, $mode = 0) { // phpcs:enable global $langs; @@ -425,7 +423,7 @@ class Asset extends CommonObject * @param int $id Id of order * @return void */ - function info($id) + public function info($id) { $sql = 'SELECT rowid, date_creation as datec, tms as datem,'; $sql.= ' fk_user_creat, fk_user_modif'; diff --git a/htdocs/asset/class/asset_type.class.php b/htdocs/asset/class/asset_type.class.php index 58baf280036..9cc96ae6c44 100644 --- a/htdocs/asset/class/asset_type.class.php +++ b/htdocs/asset/class/asset_type.class.php @@ -76,7 +76,7 @@ class AssetType extends CommonObject * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; } @@ -89,8 +89,8 @@ class AssetType extends CommonObject * @param int $notrigger 1=do not execute triggers, 0 otherwise * @return int >0 if OK, < 0 if KO */ - function create($user, $notrigger = 0) - { + public function create($user, $notrigger = 0) + { global $conf; $error=0; @@ -157,7 +157,7 @@ class AssetType extends CommonObject $this->db->rollback(); return -1; } - } + } /** * 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 * @return int >0 if OK, < 0 if KO */ - function update($user, $notrigger = 0) + public function update($user, $notrigger = 0) { global $conf, $hookmanager; @@ -233,7 +233,7 @@ class AssetType extends CommonObject * * @return int >0 if OK, 0 if not found, < 0 if KO */ - function delete() + public function delete() { global $user; @@ -267,7 +267,7 @@ class AssetType extends CommonObject * @param int $rowid Id of member type to load * @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 .= " FROM ".MAIN_DB_PREFIX."asset_type as d"; @@ -282,13 +282,13 @@ class AssetType extends CommonObject { $obj = $this->db->fetch_object($resql); - $this->id = $obj->rowid; - $this->ref = $obj->rowid; - $this->label = $obj->label; - $this->accountancy_code_asset = $obj->accountancy_code_asset; - $this->accountancy_code_depreciation_asset = $obj->accountancy_code_depreciation_asset; - $this->accountancy_code_depreciation_expense = $obj->accountancy_code_depreciation_expense; - $this->note = $obj->note; + $this->id = $obj->rowid; + $this->ref = $obj->rowid; + $this->label = $obj->label; + $this->accountancy_code_asset = $obj->accountancy_code_asset; + $this->accountancy_code_depreciation_asset = $obj->accountancy_code_depreciation_asset; + $this->accountancy_code_depreciation_expense = $obj->accountancy_code_depreciation_expense; + $this->note = $obj->note; } 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 array List of types of members */ - function liste_array() + public function liste_array() { // phpcs:enable global $conf,$langs; @@ -350,7 +350,7 @@ class AssetType extends CommonObject * 2=Return array of asset id only * @return mixed Array of asset or -1 on error */ - function listAssetForAssetType($excludefilter = '', $mode = 0) + public function listAssetForAssetType($excludefilter = '', $mode = 0) { global $conf, $user; @@ -405,7 +405,7 @@ class AssetType extends CommonObject * @param int $notooltip 1=Disable tooltip * @return string String with URL */ - function getNomUrl($withpicto = 0, $maxlen = 0, $notooltip = 0) + public function getNomUrl($withpicto = 0, $maxlen = 0, $notooltip = 0) { global $langs; @@ -430,8 +430,8 @@ class AssetType extends CommonObject * * @return void */ - function initAsSpecimen() - { + public function initAsSpecimen() + { global $conf, $user, $langs; // Initialize parameters @@ -446,15 +446,15 @@ class AssetType extends CommonObject $this->asset=array( $user->id => $user ); - } + } - /** - * getLibStatut - * - * @return string Return status of a type of asset - */ - function getLibStatut() - { - return ''; - } + /** + * getLibStatut + * + * @return string Return status of a type of asset + */ + public function getLibStatut() + { + return ''; + } } diff --git a/htdocs/bookmarks/class/bookmark.class.php b/htdocs/bookmarks/class/bookmark.class.php index f66ef8e4d80..eb1342ad119 100644 --- a/htdocs/bookmarks/class/bookmark.class.php +++ b/htdocs/bookmarks/class/bookmark.class.php @@ -82,7 +82,7 @@ class Bookmark extends CommonObject * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; } @@ -93,7 +93,7 @@ class Bookmark extends CommonObject * @param int $id Bookmark Id Loader * @return int <0 if KO, >0 if OK */ - function fetch($id) + public function fetch($id) { global $conf; @@ -135,7 +135,7 @@ class Bookmark extends CommonObject * * @return int <0 si ko, rowid du bookmark cree si ok */ - function create() + public function create() { global $conf; @@ -192,7 +192,7 @@ class Bookmark extends CommonObject * * @return int <0 if KO, > if OK */ - function update() + public function update() { // Clean parameters $this->url=trim($this->url); @@ -227,7 +227,7 @@ class Bookmark extends CommonObject * @param int $id Id removed bookmark * @return int <0 si ko, >0 si ok */ - function remove($id) + public function remove($id) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."bookmark"; $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 * @return string Label of contact status */ - function getLibStatut($mode) + public function getLibStatut($mode) { return ''; } diff --git a/htdocs/contrat/class/api_contracts.class.php b/htdocs/contrat/class/api_contracts.class.php index b93c9db55d5..6f4a2041670 100644 --- a/htdocs/contrat/class/api_contracts.class.php +++ b/htdocs/contrat/class/api_contracts.class.php @@ -35,9 +35,9 @@ class Contracts extends DolibarrApi */ static $FIELDS = array( 'socid', - 'date_contrat', - 'commercial_signature_id', - 'commercial_suivi_id' + 'date_contrat', + 'commercial_signature_id', + 'commercial_suivi_id' ); /** @@ -48,10 +48,10 @@ class Contracts extends DolibarrApi /** * Constructor */ - function __construct() + public function __construct() { - global $db, $conf; - $this->db = $db; + global $db, $conf; + $this->db = $db; $this->contract = new Contrat($this->db); } @@ -65,23 +65,23 @@ class Contracts extends DolibarrApi * * @throws RestException */ - function get($id) + public function get($id) { - if(! DolibarrApiAccess::$user->rights->contrat->lire) { - throw new RestException(401); - } + if(! DolibarrApiAccess::$user->rights->contrat->lire) { + throw new RestException(401); + } $result = $this->contract->fetch($id); if( ! $result ) { throw new RestException(404, 'Contract not found'); } - if( ! DolibarrApi::_checkAccessToResource('contrat', $this->contract->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } + if( ! DolibarrApi::_checkAccessToResource('contrat', $this->contract->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } $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')" * @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; @@ -136,7 +136,7 @@ class Contracts extends DolibarrApi { throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); } - $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; + $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; $sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; } @@ -175,7 +175,7 @@ class Contracts extends DolibarrApi if( ! count($obj_ret)) { 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 * @return int ID of contrat */ - function post($request_data = null) + public function post($request_data = null) { if(! DolibarrApiAccess::$user->rights->contrat->creer) { throw new RestException(401, "Insuffisant rights"); @@ -218,7 +218,7 @@ class Contracts extends DolibarrApi * * @return array */ - function getLines($id) + public function getLines($id) { if (! DolibarrApiAccess::$user->rights->contrat->lire) { throw new RestException(401); @@ -229,8 +229,8 @@ class Contracts extends DolibarrApi throw new RestException(404, 'Contract not found'); } - if( ! DolibarrApi::_checkAccessToResource('contrat', $this->contract->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + if( ! DolibarrApi::_checkAccessToResource('contrat', $this->contract->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } $this->contract->getLinesArray(); $result = array(); @@ -250,21 +250,21 @@ class Contracts extends DolibarrApi * * @return int|bool */ - function postLine($id, $request_data = null) + public function postLine($id, $request_data = null) { if(! DolibarrApiAccess::$user->rights->contrat->creer) { - throw new RestException(401); - } + throw new RestException(401); + } $result = $this->contract->fetch($id); if( ! $result ) { throw new RestException(404, 'Contract not found'); } - if( ! DolibarrApi::_checkAccessToResource('contrat', $this->contract->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + if( ! DolibarrApi::_checkAccessToResource('contrat', $this->contract->id)) { + 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( $request_data->desc, $request_data->subprice, @@ -274,16 +274,16 @@ class Contracts extends DolibarrApi $request_data->localtax2_tx, $request_data->fk_product, $request_data->remise_percent, - $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_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->HT, - $request_data->subprice_excl_tax, - $request_data->info_bits, + $request_data->subprice_excl_tax, + $request_data->info_bits, $request_data->fk_fournprice, - $request_data->pa_ht, - $request_data->array_options, - $request_data->fk_unit, - $request_data->rang + $request_data->pa_ht, + $request_data->array_options, + $request_data->fk_unit, + $request_data->rang ); if ($updateRes > 0) { @@ -303,20 +303,20 @@ class Contracts extends DolibarrApi * * @return array|bool */ - function putLine($id, $lineid, $request_data = null) + public function putLine($id, $lineid, $request_data = null) { if(! DolibarrApiAccess::$user->rights->contrat->creer) { - throw new RestException(401); - } + throw new RestException(401); + } $result = $this->contract->fetch($id); if( ! $result ) { throw new RestException(404, 'Contrat not found'); } - if( ! DolibarrApi::_checkAccessToResource('contrat', $this->contract->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } + if( ! DolibarrApi::_checkAccessToResource('contrat', $this->contract->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } $request_data = (object) $request_data; @@ -328,12 +328,12 @@ class Contracts extends DolibarrApi $request_data->remise_percent, $request_data->date_ouveture_prevue, $request_data->date_fin_validite, - $request_data->tva_tx, + $request_data->tva_tx, $request_data->localtax1_tx, $request_data->localtax2_tx, $request_data->date_ouverture, $request_data->date_cloture, - 'HT', + 'HT', $request_data->info_bits, $request_data->fk_fourn_price, $request_data->pa_ht, @@ -363,30 +363,30 @@ class Contracts extends DolibarrApi * * @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) { - throw new RestException(401); - } + if(! DolibarrApiAccess::$user->rights->contrat->creer) { + throw new RestException(401); + } - $result = $this->contract->fetch($id); - if (! $result) { - throw new RestException(404, 'Contrat not found'); - } + $result = $this->contract->fetch($id); + if (! $result) { + throw new RestException(404, 'Contrat not found'); + } - if( ! DolibarrApi::_checkAccessToResource('contrat', $this->contract->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } + if( ! DolibarrApi::_checkAccessToResource('contrat', $this->contract->id)) { + 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) { - $result = $this->get($id); - unset($result->line); - return $this->_cleanObjectDatas($result); - } + if ($updateRes > 0) { + $result = $this->get($id); + unset($result->line); + return $this->_cleanObjectDatas($result); + } - return false; + return false; } /** @@ -401,32 +401,32 @@ class Contracts extends DolibarrApi * * @return array|bool */ - function unactivateLine($id, $lineid, $datestart, $comment = null) + public function unactivateLine($id, $lineid, $datestart, $comment = null) { - if (! DolibarrApiAccess::$user->rights->contrat->creer) { - throw new RestException(401); - } + if (! DolibarrApiAccess::$user->rights->contrat->creer) { + throw new RestException(401); + } - $result = $this->contract->fetch($id); - if (! $result) { - throw new RestException(404, 'Contrat not found'); - } + $result = $this->contract->fetch($id); + if (! $result) { + throw new RestException(404, 'Contrat not found'); + } - if( ! DolibarrApi::_checkAccessToResource('contrat', $this->contract->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } + if( ! DolibarrApi::_checkAccessToResource('contrat', $this->contract->id)) { + 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) { - $result = $this->get($id); - unset($result->line); - return $this->_cleanObjectDatas($result); - } + if ($updateRes > 0) { + $result = $this->get($id); + unset($result->line); + return $this->_cleanObjectDatas($result); + } - return false; + return false; } /** @@ -442,19 +442,19 @@ class Contracts extends DolibarrApi * @throws 401 * @throws 404 */ - function deleteLine($id, $lineid) + public function deleteLine($id, $lineid) { if (! DolibarrApiAccess::$user->rights->contrat->creer) { - throw new RestException(401); - } + throw new RestException(401); + } $result = $this->contract->fetch($id); if (! $result) { throw new RestException(404, 'Contrat not found'); } - if (! DolibarrApi::_checkAccessToResource('contrat', $this->contract->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + if (! DolibarrApi::_checkAccessToResource('contrat', $this->contract->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } // TODO Check the lineid $lineid is a line of object @@ -465,7 +465,7 @@ class Contracts extends DolibarrApi } 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 */ - function put($id, $request_data = null) + public function put($id, $request_data = null) { if (! DolibarrApiAccess::$user->rights->contrat->creer) { - throw new RestException(401); - } + throw new RestException(401); + } $result = $this->contract->fetch($id); if (! $result) { throw new RestException(404, 'Contrat not found'); } - if (! DolibarrApi::_checkAccessToResource('contrat', $this->contract->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } + if (! DolibarrApi::_checkAccessToResource('contrat', $this->contract->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } foreach($request_data as $field => $value) { if ($field == 'id') continue; $this->contract->$field = $value; @@ -502,7 +502,7 @@ class Contracts extends DolibarrApi } 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 */ - function delete($id) + public function delete($id) { if (! DolibarrApiAccess::$user->rights->contrat->supprimer) { - throw new RestException(401); - } + throw new RestException(401); + } $result = $this->contract->fetch($id); if (! $result) { throw new RestException(404, 'Contract not found'); } - if (! DolibarrApi::_checkAccessToResource('contrat', $this->contract->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } + if (! DolibarrApi::_checkAccessToResource('contrat', $this->contract->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } if (! $this->contract->delete(DolibarrApiAccess::$user)) { throw new RestException(500, 'Error when delete contract : '.$this->contract->error); @@ -555,27 +555,27 @@ class Contracts extends DolibarrApi * "notrigger": 0 * } */ - function validate($id, $notrigger = 0) + public function validate($id, $notrigger = 0) { if (! DolibarrApiAccess::$user->rights->contrat->creer) { - throw new RestException(401); - } + throw new RestException(401); + } $result = $this->contract->fetch($id); if (! $result) { throw new RestException(404, 'Contract not found'); } - if (! DolibarrApi::_checkAccessToResource('contrat', $this->contract->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } + if (! DolibarrApi::_checkAccessToResource('contrat', $this->contract->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } - $result = $this->contract->validate(DolibarrApiAccess::$user, '', $notrigger); - if ($result == 0) { - throw new RestException(304, 'Error nothing done. May be object is already validated'); - } - if ($result < 0) { - throw new RestException(500, 'Error when validating Contract: '.$this->contract->error); - } + $result = $this->contract->validate(DolibarrApiAccess::$user, '', $notrigger); + if ($result == 0) { + throw new RestException(304, 'Error nothing done. May be object is already validated'); + } + if ($result < 0) { + throw new RestException(500, 'Error when validating Contract: '.$this->contract->error); + } return array( 'success' => array( @@ -601,34 +601,34 @@ class Contracts extends DolibarrApi * "notrigger": 0 * } */ - function close($id, $notrigger = 0) + public function close($id, $notrigger = 0) { - if (! DolibarrApiAccess::$user->rights->contrat->creer) { - throw new RestException(401); - } - $result = $this->contract->fetch($id); - if (! $result) { - throw new RestException(404, 'Contract not found'); - } + if (! DolibarrApiAccess::$user->rights->contrat->creer) { + throw new RestException(401); + } + $result = $this->contract->fetch($id); + if (! $result) { + throw new RestException(404, 'Contract not found'); + } - if (! DolibarrApi::_checkAccessToResource('contrat', $this->contract->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } + if (! DolibarrApi::_checkAccessToResource('contrat', $this->contract->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } - $result = $this->contract->closeAll(DolibarrApiAccess::$user, $notrigger); - if ($result == 0) { - throw new RestException(304, 'Error nothing done. May be object is already close'); - } - if ($result < 0) { - throw new RestException(500, 'Error when closing Contract: '.$this->contract->error); - } + $result = $this->contract->closeAll(DolibarrApiAccess::$user, $notrigger); + if ($result == 0) { + throw new RestException(304, 'Error nothing done. May be object is already close'); + } + if ($result < 0) { + throw new RestException(500, 'Error when closing Contract: '.$this->contract->error); + } - return array( - 'success' => array( - 'code' => 200, - 'message' => 'Contract closed (Ref='.$this->contract->ref.'). All services were closed.' - ) - ); + return array( + 'success' => array( + 'code' => 200, + '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 * @return array Array of cleaned object properties */ - function _cleanObjectDatas($object) + private function _cleanObjectDatas($object) { $object = parent::_cleanObjectDatas($object); @@ -666,7 +666,7 @@ class Contracts extends DolibarrApi * @return array * @throws RestException */ - function _validate($data) + private function _validate($data) { $contrat = array(); foreach (Contracts::$FIELDS as $field) { diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index 6e907699f22..405cfeca0b4 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -188,7 +188,7 @@ class Contrat extends CommonObject * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; } @@ -199,7 +199,7 @@ class Contrat extends CommonObject * @param Societe $soc Thirdparty object * @return string free reference for contract */ - function getNextNumRef($soc) + public function getNextNumRef($soc) { global $db, $langs, $conf; $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 * @@ -261,7 +261,7 @@ class Contrat extends CommonObject * @param string $comment A comment typed by user * @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 $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 * @@ -284,7 +284,7 @@ class Contrat extends CommonObject * @param string $comment A comment typed by user * @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 $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 * @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(); @@ -363,7 +363,7 @@ class Contrat extends CommonObject * @return int <0 if KO, >0 if OK * @see activateAll */ - function closeAll(User $user, $notrigger = 0, $comment = '') + public function closeAll(User $user, $notrigger = 0, $comment = '') { $this->db->begin(); @@ -419,7 +419,7 @@ class Contrat extends CommonObject * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @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'; global $langs, $conf; @@ -547,7 +547,7 @@ class Contrat extends CommonObject * @param int $notrigger 1=Does not execute triggers, 0=execute triggers * @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'; global $langs, $conf; @@ -614,7 +614,7 @@ class Contrat extends CommonObject * @param string $ref_supplier Supplier ref * @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.= " ref_supplier, ref_customer,"; @@ -665,7 +665,7 @@ class Contrat extends CommonObject $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->note_private = $obj->note_private; @@ -678,7 +678,7 @@ class Contrat extends CommonObject $this->socid = $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); @@ -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. * This set also nbofserviceswait, nbofservicesopened, nbofservicesexpired and nbofservicesclosed * * @return ContratLigne[] Return array of contract lines */ - function fetch_lines() + public function fetch_lines() { // phpcs:enable $this->nbofserviceswait=0; @@ -768,7 +768,7 @@ class Contrat extends CommonObject while ($i < $num) { - $objp = $this->db->fetch_object($result); + $objp = $this->db->fetch_object($result); $line = new ContratLigne($this->db); $line->id = $objp->rowid; @@ -829,7 +829,7 @@ class Contrat extends CommonObject // fetch optionals attributes and labels $line->fetch_optionals(); - $this->lines[$pos] = $line; + $this->lines[$pos] = $line; $this->lines_id_index_mapper[$line->id] = $pos; //dol_syslog("1 ".$line->desc); @@ -869,7 +869,7 @@ class Contrat extends CommonObject * @param User $user User that create * @return int <0 if KO, id of contract if OK */ - function create($user) + public function create($user) { global $conf,$langs,$mysoc; @@ -1088,7 +1088,7 @@ class Contrat extends CommonObject * @param User $user Utilisateur qui supprime * @return int < 0 si erreur, > 0 si ok */ - function delete($user) + public function delete($user) { global $conf, $langs; 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 * @return int <0 if KO, >0 if OK */ - function update($user, $notrigger = 0) + public function update($user, $notrigger = 0) { global $conf, $langs; $error=0; @@ -1360,7 +1360,7 @@ class Contrat extends CommonObject * @param string $rang Position * @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; $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 * @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; @@ -1647,21 +1647,21 @@ class Contrat extends CommonObject } $sql = "UPDATE ".MAIN_DB_PREFIX."contratdet set description='".$this->db->escape($desc)."'"; - $sql.= ",price_ht='" . price2num($price)."'"; - $sql.= ",subprice='" . price2num($subprice)."'"; - $sql.= ",remise='" . price2num($remise)."'"; + $sql.= ",price_ht='".price2num($price)."'"; + $sql.= ",subprice='".price2num($subprice)."'"; + $sql.= ",remise='".price2num($remise)."'"; $sql.= ",remise_percent='".price2num($remise_percent)."'"; $sql.= ",qty='".$qty."'"; - $sql.= ",tva_tx='". price2num($tvatx)."'"; - $sql.= ",localtax1_tx='". price2num($localtax1tx)."'"; - $sql.= ",localtax2_tx='". price2num($localtax2tx)."'"; + $sql.= ",tva_tx='".price2num($tvatx)."'"; + $sql.= ",localtax1_tx='".price2num($localtax1tx)."'"; + $sql.= ",localtax2_tx='".price2num($localtax2tx)."'"; $sql.= ",localtax1_type='".$localtax1_type."'"; $sql.= ",localtax2_type='".$localtax2_type."'"; - $sql.= ", total_ht='". price2num($total_ht)."'"; - $sql.= ", total_tva='". price2num($total_tva)."'"; + $sql.= ", total_ht='".price2num($total_ht)."'"; + $sql.= ", total_tva='".price2num($total_tva)."'"; $sql.= ", total_localtax1='".price2num($total_localtax1)."'"; $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.= ", buy_price_ht='".price2num($pa_ht)."'"; 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 * @return int >0 if OK, <0 if KO */ - function deleteline($idline, User $user) + public function deleteline($idline, User $user) { 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 * @@ -1800,7 +1800,7 @@ class Contrat extends CommonObject * @return int <0 if KO, >0 if OK * @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 dol_syslog(__METHOD__ . " is deprecated", LOG_WARNING); @@ -1811,11 +1811,11 @@ class Contrat extends CommonObject // Load $this->lines array // $this->fetch_lines(); -// $newstatut=1; -// foreach($this->lines as $key => $contractline) -// { -// // if ($contractline) // Loop on each service -// } + // $newstatut=1; + // foreach($this->lines as $key => $contractline) + // { + // // if ($contractline) // Loop on each service + // } 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 * @return string Label */ - function getLibStatut($mode) + public function getLibStatut($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 * @return string Label */ - function LibStatut($statut, $mode) + public function LibStatut($statut, $mode) { // phpcs:enable global $langs; @@ -1872,8 +1872,7 @@ class Contrat extends CommonObject elseif ($mode == 4 || $mode == 6 || $mode == 7) { $text=''; - if ($mode == 4) - { + if ($mode == 4) { $text =''; $text.=($this->nbofserviceswait+$this->nbofservicesopened+$this->nbofservicesexpired+$this->nbofservicesclosed); $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 * @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; @@ -1973,7 +1972,7 @@ class Contrat extends CommonObject * @param int $id id du contrat a charger * @return void */ - function info($id) + public function info($id) { $sql = "SELECT c.rowid, c.ref, c.datec, c.date_cloture,"; $sql.= " c.tms as date_modification,"; @@ -2022,7 +2021,7 @@ class Contrat extends CommonObject * @param int $statut Status of lines to get * @return array Array of line's rowid */ - function array_detail($statut = -1) + public function array_detail($statut = -1) { // phpcs:enable $tab=array(); @@ -2059,7 +2058,7 @@ class Contrat extends CommonObject * @param string $option 'all' or 'others' * @return array Array of contracts id */ - function getListOfContracts($option = 'all') + public function getListOfContracts($option = 'all') { $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) * @@ -2100,7 +2099,7 @@ class Contrat extends CommonObject * @param string $mode "inactive" pour services a activer, "expired" pour services expires * @return WorkboardResponse|int <0 if KO, WorkboardResponse if OK */ - function load_board($user, $mode) + public function load_board($user, $mode) { // phpcs:enable 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 * * @return int <0 si ko, >0 si ok */ - function load_state_board() + public function load_state_board() { // phpcs:enable global $conf, $user; @@ -2223,7 +2222,7 @@ class Contrat extends CommonObject * * @return array Liste des id contacts facturation */ - function getIdBillingContact() + public function getIdBillingContact() { return $this->getIdContact('external', 'BILLING'); } @@ -2233,7 +2232,7 @@ class Contrat extends CommonObject * * @return array Liste des id contacts prestation */ - function getIdServiceContact() + public function getIdServiceContact() { return $this->getIdContact('external', 'SERVICE'); } @@ -2245,9 +2244,9 @@ class Contrat extends CommonObject * id must be 0 if object instance is a specimen. * * @return void - */ - function initAsSpecimen() - { + */ + public function initAsSpecimen() + { global $user,$langs,$conf; // Load array of products prodids @@ -2319,7 +2318,7 @@ class Contrat extends CommonObject * * @return int >0 if OK, <0 if KO */ - function getLinesArray() + public function getLinesArray() { return $this->fetch_lines(); } @@ -2382,7 +2381,7 @@ class Contrat extends CommonObject * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @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; @@ -2631,7 +2630,7 @@ class ContratLigne extends CommonObjectLine * * @param DoliDb $db Database handler */ - function __construct($db) + public function __construct($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 * @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)); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return label of a contract line status * @@ -2658,7 +2657,7 @@ class ContratLigne extends CommonObjectLine * @param string $moreatt More attribute * @return string Libelle */ - static function LibStatut($statut, $mode, $expired = -1, $moreatt = '') + public static function LibStatut($statut, $mode, $expired = -1, $moreatt = '') { // phpcs:enable global $langs; @@ -2720,7 +2719,7 @@ class ContratLigne extends CommonObjectLine * @param int $maxlength Max length * @return string Chaine avec URL */ - function getNomUrl($withpicto = 0, $maxlength = 0) + public function getNomUrl($withpicto = 0, $maxlength = 0) { 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 string $ref Ref of contract - * @return int <0 if KO, >0 if OK + * @param int $id Id object + * @param string $ref Ref of contract + * @return int <0 if KO, >0 if OK */ - function fetch($id, $ref = '') + public function fetch($id, $ref = '') { // Check parameters @@ -2879,7 +2878,7 @@ class ContratLigne extends CommonObjectLine * @param int $notrigger 0=no, 1=yes (no update trigger) * @return int <0 if KO, >0 if OK */ - function update($user, $notrigger = 0) + public function update($user, $notrigger = 0) { 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 * Used by migration process * * @return int <0 if KO, >0 if OK */ - function update_total() + public function update_total() { // phpcs:enable $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 * @@ -3198,7 +3197,7 @@ class ContratLigne extends CommonObjectLine * @param string $comment A comment typed by user * @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 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 * @@ -3257,7 +3256,7 @@ class ContratLigne extends CommonObjectLine * @param int $notrigger 1=Does not execute triggers, 0=Execute triggers * @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 global $langs, $conf; diff --git a/htdocs/core/modules/barcode/mod_barcode_product_standard.php b/htdocs/core/modules/barcode/mod_barcode_product_standard.php index 239a1683fad..936e7b87be4 100644 --- a/htdocs/core/modules/barcode/mod_barcode_product_standard.php +++ b/htdocs/core/modules/barcode/mod_barcode_product_standard.php @@ -61,7 +61,7 @@ class mod_barcode_product_standard extends ModeleNumRefBarCode /** * Constructor */ - function __construct() + public function __construct() { $this->code_null = 0; $this->code_modifiable = 1; @@ -77,7 +77,7 @@ class mod_barcode_product_standard extends ModeleNumRefBarCode * @param Translate $langs Object langs * @return string Description of module */ - function info($langs) + public function info($langs) { global $conf, $mc; global $form; @@ -119,7 +119,7 @@ class mod_barcode_product_standard extends ModeleNumRefBarCode * @param Product $objproduct Object product * @return string Return string example */ - function getExample($langs, $objproduct = 0) + public function getExample($langs, $objproduct = 0) { $examplebarcode = $this->getNextValue($objproduct, ''); if (! $examplebarcode) @@ -142,7 +142,7 @@ class mod_barcode_product_standard extends ModeleNumRefBarCode * @param string $type Type of barcode (EAN, ISBN, ...) * @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; @@ -184,7 +184,7 @@ class mod_barcode_product_standard extends ModeleNumRefBarCode * -3 ErrorCustomerCodeAlreadyUsed * -4 ErrorPrefixRequired */ - function verif($db, &$code, $product, $thirdparty_type, $type) + public function verif($db, &$code, $product, $thirdparty_type, $type) { 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) * @@ -244,7 +244,7 @@ class mod_barcode_product_standard extends ModeleNumRefBarCode * @param Product $product Objet product * @return int 0 if available, <0 if KO */ - function verif_dispo($db, $code, $product) + public function verif_dispo($db, $code, $product) { // phpcs:enable $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 * @@ -277,7 +277,7 @@ class mod_barcode_product_standard extends ModeleNumRefBarCode * @param string $typefortest Type of barcode (ISBN, EAN, ...) * @return int 0 if OK, <0 if KO */ - function verif_syntax($codefortest, $typefortest) + public function verif_syntax($codefortest, $typefortest) { // phpcs:enable global $conf; @@ -296,15 +296,15 @@ class mod_barcode_product_standard extends ModeleNumRefBarCode $newcodefortest=$codefortest; - // 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 (preg_match('/\{(0+)([@\+][0-9]+)?([@\+][0-9]+)?\}/i', $mask, $reg)) - { - if (strlen($reg[1]) == 12) $newcodefortest=substr($newcodefortest, 0, 12); - dol_syslog(get_class($this).'::verif_syntax newcodefortest='.$newcodefortest); - } - } + // 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 (preg_match('/\{(0+)([@\+][0-9]+)?([@\+][0-9]+)?\}/i', $mask, $reg)) + { + if (strlen($reg[1]) == 12) $newcodefortest=substr($newcodefortest, 0, 12); + dol_syslog(get_class($this).'::verif_syntax newcodefortest='.$newcodefortest); + } + } $result=check_value($mask, $newcodefortest); if (is_string($result)) diff --git a/htdocs/core/modules/cheque/mod_chequereceipt_mint.php b/htdocs/core/modules/cheque/mod_chequereceipt_mint.php index 0bdf6f0fc91..e696f086269 100644 --- a/htdocs/core/modules/cheque/mod_chequereceipt_mint.php +++ b/htdocs/core/modules/cheque/mod_chequereceipt_mint.php @@ -50,7 +50,7 @@ class mod_chequereceipt_mint extends ModeleNumRefChequeReceipts * * @return string Text with description */ - function info() + public function info() { global $langs; return $langs->trans("SimpleNumRefModelDesc", $this->prefix); @@ -62,7 +62,7 @@ class mod_chequereceipt_mint extends ModeleNumRefChequeReceipts * * @return string Example */ - function getExample() + public function getExample() { return $this->prefix."0501-0001"; } @@ -74,7 +74,7 @@ class mod_chequereceipt_mint extends ModeleNumRefChequeReceipts * * @return boolean false si conflit, true si ok */ - function canBeActivated() + public function canBeActivated() { global $conf,$langs,$db; @@ -109,7 +109,7 @@ class mod_chequereceipt_mint extends ModeleNumRefChequeReceipts * @param Object $object Object we need next value for * @return string Value if KO, <0 if KO */ - function getNextValue($objsoc, $object) + public function getNextValue($objsoc, $object) { global $db,$conf; @@ -153,7 +153,7 @@ class mod_chequereceipt_mint extends ModeleNumRefChequeReceipts * @param string $objforref Object for number to search * @return string Next free value */ - function chequereceipt_get_num($objsoc, $objforref) + public function chequereceipt_get_num($objsoc, $objforref) { // phpcs:enable return $this->getNextValue($objsoc, $objforref); diff --git a/htdocs/core/modules/cheque/mod_chequereceipt_thyme.php b/htdocs/core/modules/cheque/mod_chequereceipt_thyme.php index c978dbaa0f3..c33699a1a27 100644 --- a/htdocs/core/modules/cheque/mod_chequereceipt_thyme.php +++ b/htdocs/core/modules/cheque/mod_chequereceipt_thyme.php @@ -49,7 +49,7 @@ class mod_chequereceipt_thyme extends ModeleNumRefChequeReceipts * * @return string Texte descripif */ - function info() + public function info() { global $conf, $langs; @@ -89,7 +89,7 @@ class mod_chequereceipt_thyme extends ModeleNumRefChequeReceipts * * @return string Example */ - function getExample() + public function getExample() { global $conf,$langs,$mysoc; @@ -112,7 +112,7 @@ class mod_chequereceipt_thyme extends ModeleNumRefChequeReceipts * @param Object $object Object we need next value for * @return string Value if KO, <0 if KO */ - function getNextValue($objsoc, $object) + public function getNextValue($objsoc, $object) { global $db,$conf; @@ -141,7 +141,7 @@ class mod_chequereceipt_thyme extends ModeleNumRefChequeReceipts * @param string $objforref Object for number to search * @return string Next free value */ - function chequereceipt_get_num($objsoc, $objforref) + public function chequereceipt_get_num($objsoc, $objforref) { // phpcs:enable return $this->getNextValue($objsoc, $objforref); diff --git a/htdocs/core/modules/cheque/modules_chequereceipts.php b/htdocs/core/modules/cheque/modules_chequereceipts.php index d13384805d5..29fd071200a 100644 --- a/htdocs/core/modules/cheque/modules_chequereceipts.php +++ b/htdocs/core/modules/cheque/modules_chequereceipts.php @@ -46,7 +46,7 @@ abstract class ModeleNumRefChequeReceipts * * @return boolean true if module can be used */ - function isEnabled() + public function isEnabled() { return true; } @@ -56,7 +56,7 @@ abstract class ModeleNumRefChequeReceipts * * @return string Texte descripif */ - function info() + public function info() { global $langs; $langs->load("bills"); @@ -68,7 +68,7 @@ abstract class ModeleNumRefChequeReceipts * * @return string Example */ - function getExample() + public function getExample() { global $langs; $langs->load("bills"); @@ -80,7 +80,7 @@ abstract class ModeleNumRefChequeReceipts * * @return boolean false si conflit, true si ok */ - function canBeActivated() + public function canBeActivated() { return true; } @@ -92,7 +92,7 @@ abstract class ModeleNumRefChequeReceipts * @param Object $object Object we need next value for * @return string Valeur */ - function getNextValue($objsoc, $object) + public function getNextValue($objsoc, $object) { global $langs; return $langs->trans("NotAvailable"); @@ -103,7 +103,7 @@ abstract class ModeleNumRefChequeReceipts * * @return string Value */ - function getVersion() + public function getVersion() { global $langs; $langs->load("admin"); @@ -127,7 +127,7 @@ abstract class ModeleChequeReceipts extends CommonDocGenerator */ public $error=''; - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of active generation modules * @@ -135,7 +135,7 @@ abstract class ModeleChequeReceipts extends CommonDocGenerator * @param integer $maxfilenamelength Max length of value to show * @return array List of templates */ - static function liste_modeles($db, $maxfilenamelength = 0) + public static function liste_modeles($db, $maxfilenamelength = 0) { // phpcs:enable 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 int $id Object invoice (or id of invoice) diff --git a/htdocs/core/modules/commande/mod_commande_marbre.php b/htdocs/core/modules/commande/mod_commande_marbre.php index e888905b3be..b0b462e96dc 100644 --- a/htdocs/core/modules/commande/mod_commande_marbre.php +++ b/htdocs/core/modules/commande/mod_commande_marbre.php @@ -60,7 +60,7 @@ class mod_commande_marbre extends ModeleNumRefCommandes * * @return string Text with description */ - function info() + public function info() { global $langs; return $langs->trans("SimpleNumRefModelDesc", $this->prefix); @@ -72,7 +72,7 @@ class mod_commande_marbre extends ModeleNumRefCommandes * * @return string Example */ - function getExample() + public function getExample() { return $this->prefix."0501-0001"; } @@ -84,7 +84,7 @@ class mod_commande_marbre extends ModeleNumRefCommandes * * @return boolean false si conflit, true si ok */ - function canBeActivated() + public function canBeActivated() { global $conf,$langs,$db; @@ -119,7 +119,7 @@ class mod_commande_marbre extends ModeleNumRefCommandes * @param Object $object Object we need next value for * @return string Value if KO, <0 if KO */ - function getNextValue($objsoc, $object) + public function getNextValue($objsoc, $object) { 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 * @@ -163,7 +163,7 @@ class mod_commande_marbre extends ModeleNumRefCommandes * @param string $objforref Object for number to search * @return string Next free value */ - function commande_get_num($objsoc, $objforref) + public function commande_get_num($objsoc, $objforref) { // phpcs:enable return $this->getNextValue($objsoc, $objforref); diff --git a/htdocs/core/modules/commande/mod_commande_saphir.php b/htdocs/core/modules/commande/mod_commande_saphir.php index bfe853996ce..373f1e01200 100644 --- a/htdocs/core/modules/commande/mod_commande_saphir.php +++ b/htdocs/core/modules/commande/mod_commande_saphir.php @@ -62,7 +62,7 @@ class mod_commande_saphir extends ModeleNumRefCommandes * * @return string Texte descripif */ - function info() + public function info() { global $conf, $langs; @@ -102,7 +102,7 @@ class mod_commande_saphir extends ModeleNumRefCommandes * * @return string Example */ - function getExample() + public function getExample() { global $conf,$langs,$mysoc; @@ -128,7 +128,7 @@ class mod_commande_saphir extends ModeleNumRefCommandes * @param Object $object Object we need next value for * @return string Value if KO, <0 if KO */ - function getNextValue($objsoc, $object) + public function getNextValue($objsoc, $object) { 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 * @@ -159,7 +159,7 @@ class mod_commande_saphir extends ModeleNumRefCommandes * @param string $objforref Object for number to search * @return string Next free value */ - function commande_get_num($objsoc, $objforref) + public function commande_get_num($objsoc, $objforref) { // phpcs:enable return $this->getNextValue($objsoc, $objforref); diff --git a/htdocs/core/modules/commande/modules_commande.php b/htdocs/core/modules/commande/modules_commande.php index 6090ad35028..e0a0e454861 100644 --- a/htdocs/core/modules/commande/modules_commande.php +++ b/htdocs/core/modules/commande/modules_commande.php @@ -40,7 +40,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php'; abstract class ModelePDFCommandes extends CommonDocGenerator { - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of active generation modules * @@ -48,7 +48,7 @@ abstract class ModelePDFCommandes extends CommonDocGenerator * @param integer $maxfilenamelength Max length of value to show * @return array List of templates */ - static function liste_modeles($db, $maxfilenamelength = 0) + public static function liste_modeles($db, $maxfilenamelength = 0) { // phpcs:enable global $conf; @@ -82,7 +82,7 @@ abstract class ModeleNumRefCommandes * * @return boolean true if module can be used */ - function isEnabled() + public function isEnabled() { return true; } @@ -92,7 +92,7 @@ abstract class ModeleNumRefCommandes * * @return string Texte descripif */ - function info() + public function info() { global $langs; $langs->load("orders"); @@ -104,7 +104,7 @@ abstract class ModeleNumRefCommandes * * @return string Example */ - function getExample() + public function getExample() { global $langs; $langs->load("orders"); @@ -116,7 +116,7 @@ abstract class ModeleNumRefCommandes * * @return boolean false si conflit, true si ok */ - function canBeActivated() + public function canBeActivated() { return true; } @@ -128,7 +128,7 @@ abstract class ModeleNumRefCommandes * @param Object $object Object we need next value for * @return string Valeur */ - function getNextValue($objsoc, $object) + public function getNextValue($objsoc, $object) { global $langs; return $langs->trans("NotAvailable"); @@ -139,7 +139,7 @@ abstract class ModeleNumRefCommandes * * @return string Valeur */ - function getVersion() + public function getVersion() { global $langs; $langs->load("admin"); diff --git a/htdocs/core/modules/contract/mod_contract_magre.php b/htdocs/core/modules/contract/mod_contract_magre.php index db7689d7855..2eb0e03ec63 100644 --- a/htdocs/core/modules/contract/mod_contract_magre.php +++ b/htdocs/core/modules/contract/mod_contract_magre.php @@ -59,7 +59,7 @@ class mod_contract_magre extends ModelNumRefContracts * * @return string text description */ - function info() + public function info() { global $conf,$langs; @@ -95,7 +95,7 @@ class mod_contract_magre extends ModelNumRefContracts * * @return string Example */ - function getExample() + public function getExample() { global $conf,$langs,$mysoc; @@ -118,7 +118,7 @@ class mod_contract_magre extends ModelNumRefContracts * @param Object $contract contract object * @return string Value if OK, 0 if KO */ - function getNextValue($objsoc, $contract) + public function getNextValue($objsoc, $contract) { global $db,$conf; @@ -145,7 +145,7 @@ class mod_contract_magre extends ModelNumRefContracts * @param Object $objforref contract object * @return string Value if OK, 0 if KO */ - function contract_get_num($objsoc, $objforref) + public function contract_get_num($objsoc, $objforref) { // phpcs:enable return $this->getNextValue($objsoc, $objforref); diff --git a/htdocs/core/modules/contract/mod_contract_olive.php b/htdocs/core/modules/contract/mod_contract_olive.php index 799bd297633..c1a395c4439 100644 --- a/htdocs/core/modules/contract/mod_contract_olive.php +++ b/htdocs/core/modules/contract/mod_contract_olive.php @@ -66,7 +66,7 @@ class mod_contract_olive extends ModelNumRefContracts * * @return string Description of module */ - function info() + public function info() { global $langs; @@ -81,7 +81,7 @@ class mod_contract_olive extends ModelNumRefContracts * @param Contrat $contract Object contract * @return string Return next value */ - function getNextValue($objsoc, $contract) + public function getNextValue($objsoc, $contract) { global $langs; return ''; @@ -101,7 +101,7 @@ class mod_contract_olive extends ModelNumRefContracts * -3 ErrorProductCodeAlreadyUsed * -4 ErrorPrefixRequired */ - function verif($db, &$code, $product, $type) + public function verif($db, &$code, $product, $type) { global $conf; diff --git a/htdocs/core/modules/contract/mod_contract_serpis.php b/htdocs/core/modules/contract/mod_contract_serpis.php index 2106463107e..2f644f2762f 100644 --- a/htdocs/core/modules/contract/mod_contract_serpis.php +++ b/htdocs/core/modules/contract/mod_contract_serpis.php @@ -61,7 +61,7 @@ class mod_contract_serpis extends ModelNumRefContracts * * @return string text description */ - function info() + public function info() { global $langs; return $langs->trans("SimpleNumRefModelDesc", $this->prefix); @@ -73,7 +73,7 @@ class mod_contract_serpis extends ModelNumRefContracts * * @return string Example */ - function getExample() + public function getExample() { return $this->prefix."0501-0001"; } @@ -84,7 +84,7 @@ class mod_contract_serpis extends ModelNumRefContracts * * @return boolean false if conflit, true if ok */ - function canBeActivated() + public function canBeActivated() { global $conf,$langs,$db; @@ -119,7 +119,7 @@ class mod_contract_serpis extends ModelNumRefContracts * @param Object $contract contract object * @return string Value if OK, 0 if KO */ - function getNextValue($objsoc, $contract) + public function getNextValue($objsoc, $contract) { 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 * @@ -161,7 +161,7 @@ class mod_contract_serpis extends ModelNumRefContracts * @param Object $objforref contract object * @return string Value if OK, 0 if KO */ - function contract_get_num($objsoc, $objforref) + public function contract_get_num($objsoc, $objforref) { // phpcs:enable return $this->getNextValue($objsoc, $objforref); diff --git a/htdocs/core/modules/contract/modules_contract.php b/htdocs/core/modules/contract/modules_contract.php index 0c126459436..9cbc2092979 100644 --- a/htdocs/core/modules/contract/modules_contract.php +++ b/htdocs/core/modules/contract/modules_contract.php @@ -43,7 +43,7 @@ abstract class ModelePDFContract extends CommonDocGenerator public $error=''; - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of active generation modules * @@ -51,7 +51,7 @@ abstract class ModelePDFContract extends CommonDocGenerator * @param integer $maxfilenamelength Max length of value to show * @return array List of templates */ - static function liste_modeles($db, $maxfilenamelength = 0) + public static function liste_modeles($db, $maxfilenamelength = 0) { // phpcs:enable global $conf; @@ -82,7 +82,7 @@ class ModelNumRefContracts * * @return boolean true if module can be used */ - function isEnabled() + public function isEnabled() { return true; } @@ -92,7 +92,7 @@ class ModelNumRefContracts * * @return string text description */ - function info() + public function info() { global $langs; $langs->load("contracts"); @@ -104,7 +104,7 @@ class ModelNumRefContracts * * @return string Example */ - function getExample() + public function getExample() { global $langs; $langs->load("contracts"); @@ -116,7 +116,7 @@ class ModelNumRefContracts * * @return boolean false if conflict, true if ok */ - function canBeActivated() + public function canBeActivated() { return true; } @@ -128,7 +128,7 @@ class ModelNumRefContracts * @param Object $contract contract object * @return string Value */ - function getNextValue($objsoc, $contract) + public function getNextValue($objsoc, $contract) { global $langs; return $langs->trans("NotAvailable"); @@ -139,7 +139,7 @@ class ModelNumRefContracts * * @return string Value */ - function getVersion() + public function getVersion() { global $langs; $langs->load("admin"); diff --git a/htdocs/core/modules/dons/modules_don.php b/htdocs/core/modules/dons/modules_don.php index adda4dce750..9957bf4f326 100644 --- a/htdocs/core/modules/dons/modules_don.php +++ b/htdocs/core/modules/dons/modules_don.php @@ -39,7 +39,7 @@ abstract class ModeleDon extends CommonDocGenerator */ public $error=''; - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of active generation modules * @@ -47,7 +47,7 @@ abstract class ModeleDon extends CommonDocGenerator * @param integer $maxfilenamelength Max length of value to show * @return array List of templates */ - static function liste_modeles($db, $maxfilenamelength = 0) + public static function liste_modeles($db, $maxfilenamelength = 0) { // phpcs:enable global $conf; @@ -78,7 +78,7 @@ abstract class ModeleNumRefDons * * @return boolean true if module can be used */ - function isEnabled() + public function isEnabled() { return true; } @@ -88,7 +88,7 @@ abstract class ModeleNumRefDons * * @return string Texte descripif */ - function info() + public function info() { global $langs; $langs->load("bills"); @@ -100,7 +100,7 @@ abstract class ModeleNumRefDons * * @return string Example */ - function getExample() + public function getExample() { global $langs; $langs->load("bills"); @@ -113,7 +113,7 @@ abstract class ModeleNumRefDons * * @return boolean false si conflit, true si ok */ - function canBeActivated() + public function canBeActivated() { return true; } @@ -123,7 +123,7 @@ abstract class ModeleNumRefDons * * @return string Valeur */ - function getNextValue() + public function getNextValue() { global $langs; return $langs->trans("NotAvailable"); @@ -134,7 +134,7 @@ abstract class ModeleNumRefDons * * @return string Valeur */ - function getVersion() + public function getVersion() { global $langs; $langs->load("admin"); diff --git a/htdocs/core/modules/modAccounting.class.php b/htdocs/core/modules/modAccounting.class.php index 2a4ff0fc42e..ea247d3b5f9 100644 --- a/htdocs/core/modules/modAccounting.class.php +++ b/htdocs/core/modules/modAccounting.class.php @@ -37,7 +37,7 @@ class modAccounting extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $conf; diff --git a/htdocs/core/modules/modAdherent.class.php b/htdocs/core/modules/modAdherent.class.php index 6cf5e45c7f2..763ec1a1370 100644 --- a/htdocs/core/modules/modAdherent.class.php +++ b/htdocs/core/modules/modAdherent.class.php @@ -38,23 +38,23 @@ class modAdherent extends DolibarrModules { /** - * Constructor. Define names, constants, directories, boxes, permissions - * - * @param DoliDB $db Database handler + * Constructor. Define names, constants, directories, boxes, permissions + * + * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { - global $conf; + global $conf; $this->db = $db; $this->numero = 310; $this->family = "hr"; $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) - $this->name = preg_replace('/^mod/i', '', get_class($this)); + // 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->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->const_name = 'MAIN_MODULE_'.strtoupper($this->name); $this->picto='user'; @@ -67,9 +67,9 @@ class modAdherent extends DolibarrModules // Dependencies $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->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->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->conflictwith = array('modMailmanSpip'); // List of module class names as string this module is in conflict with $this->langfiles = array("members","companies"); $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'; - // Menus - //------- - $this->menu = 1; // This module add menu entries. They are coded into menu manager. + // Menus + //------- + $this->menu = 1; // This module add menu entries. They are coded into menu manager. // Exports @@ -269,36 +269,36 @@ class modAdherent extends DolibarrModules $this->export_label[$r]='MembersAndSubscriptions'; $this->export_permission[$r]=array(array("adherent","export")); $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.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.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', - 'c.rowid'=>'SubscriptionId','c.dateadh'=>'DateSubscription','c.subscription'=>'Amount' - ); + '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.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.tms'=>'DateLastModification','a.datefin'=>'DateEndSubscription','ta.rowid'=>'MemberTypeId','ta.libelle'=>'MemberTypeLabel', + 'c.rowid'=>'SubscriptionId','c.dateadh'=>'DateSubscription','c.subscription'=>'Amount' + ); $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.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.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.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.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' + ); $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.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.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.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.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.datefin'=>'member','ta.rowid'=>'member_type','ta.libelle'=>'member_type','c.rowid'=>'subscription','c.dateadh'=>'subscription','c.subscription'=>'subscription' + ); // Add extra fields $keyforselect='adherent'; $keyforelement='member'; $keyforaliasextra='extra'; 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_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.'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_country as co ON a.country = co.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] .=' 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 @@ -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_creator_array[$r]=array('a'=>'fk_user_author'); // Fields to store import user id $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.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.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' - ); - // Add extra fields - $sql="SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'adherent' AND entity IN (0,".$conf->entity.")"; - $resql=$this->db->query($sql); - if ($resql) // This can fail when class is used on old database (during migration for example) - { - while ($obj=$this->db->fetch_object($resql)) - { - $fieldname='extra.'.$obj->name; - $fieldlabel=ucfirst($obj->label); - $this->import_fields_array[$r][$fieldname]=$fieldlabel.($obj->fieldrequired?'*':''); - } - } - // 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_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.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.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.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.datec'=>'DateCreation','a.datefin'=>'DateEndSubscription' + ); + // Add extra fields + $sql="SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'adherent' AND entity IN (0,".$conf->entity.")"; + $resql=$this->db->query($sql); + if ($resql) // This can fail when class is used on old database (during migration for example) + { + while ($obj=$this->db->fetch_object($resql)) + { + $fieldname='extra.'.$obj->name; + $fieldlabel=ucfirst($obj->label); + $this->import_fields_array[$r][$fieldname]=$fieldlabel.($obj->fieldrequired?'*':''); + } + } + // 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_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.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( - '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.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.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.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') + ); // Cronjobs $arraydate=dol_getdate(dol_now()); $datestart=dol_mktime(22, 0, 0, $arraydate['mon'], $arraydate['mday'], $arraydate['year']); $this->cronjobs = array( - 0=>array( - 'label'=>'SendReminderForExpiredSubscriptionTitle', - 'jobtype'=>'method', 'class'=>'adherents/class/adherent.class.php', - 'objectname'=>'Adherent', - 'method'=>'sendReminderForExpiredSubscription', - 'parameters'=>'10;0', - 'comment'=>'SendReminderForExpiredSubscription', - 'frequency'=>1, - 'unitfrequency'=> 3600 * 24, - 'priority'=>50, - 'status'=>1, - 'test'=>'$conf->adherent->enabled', - 'datestart'=>$datestart - ), + 0=>array( + 'label'=>'SendReminderForExpiredSubscriptionTitle', + 'jobtype'=>'method', 'class'=>'adherents/class/adherent.class.php', + 'objectname'=>'Adherent', + 'method'=>'sendReminderForExpiredSubscription', + 'parameters'=>'10;0', + 'comment'=>'SendReminderForExpiredSubscription', + 'frequency'=>1, + 'unitfrequency'=> 3600 * 24, + 'priority'=>50, + 'status'=>1, + 'test'=>'$conf->adherent->enabled', + 'datestart'=>$datestart + ), ); } diff --git a/htdocs/core/modules/modAgenda.class.php b/htdocs/core/modules/modAgenda.class.php index fc2c173d90c..20b3c74ee40 100644 --- a/htdocs/core/modules/modAgenda.class.php +++ b/htdocs/core/modules/modAgenda.class.php @@ -43,7 +43,7 @@ class modAgenda extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $conf, $user; diff --git a/htdocs/core/modules/modApi.class.php b/htdocs/core/modules/modApi.class.php index 8bfec6a1734..0ed62e76627 100644 --- a/htdocs/core/modules/modApi.class.php +++ b/htdocs/core/modules/modApi.class.php @@ -38,7 +38,7 @@ class modApi extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $langs,$conf; diff --git a/htdocs/core/modules/modAsset.class.php b/htdocs/core/modules/modAsset.class.php index d7464c8ac0e..b162fabc559 100644 --- a/htdocs/core/modules/modAsset.class.php +++ b/htdocs/core/modules/modAsset.class.php @@ -313,22 +313,22 @@ class modAsset extends DolibarrModules } /** - * Function called when module is enabled. - * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. - * It also creates data directories + * Function called when module is enabled. + * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. + * It also creates data directories * - * @param string $options Options when enabling module ('', 'noboxes') - * @return int 1 if OK, 0 if KO + * @param string $options Options when enabling module ('', 'noboxes') + * @return int 1 if OK, 0 if KO */ - function init($options = '') - { - global $conf; + public function init($options = '') + { + global $conf; - // Permissions - $this->remove($options); + // Permissions + $this->remove($options); - $sql = array(); + $sql = array(); - return $this->_init($sql, $options); - } + return $this->_init($sql, $options); + } } diff --git a/htdocs/core/modules/modBanque.class.php b/htdocs/core/modules/modBanque.class.php index 08dcd61351d..b578b783ace 100644 --- a/htdocs/core/modules/modBanque.class.php +++ b/htdocs/core/modules/modBanque.class.php @@ -41,7 +41,7 @@ class modBanque extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $conf; diff --git a/htdocs/core/modules/modBarcode.class.php b/htdocs/core/modules/modBarcode.class.php index 7c4fcd78bf1..8f2023b4a36 100644 --- a/htdocs/core/modules/modBarcode.class.php +++ b/htdocs/core/modules/modBarcode.class.php @@ -39,7 +39,7 @@ class modBarcode extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; $this->numero = 55; diff --git a/htdocs/core/modules/modBlockedLog.class.php b/htdocs/core/modules/modBlockedLog.class.php index 0ed248f00ab..1ef90f8cc3f 100644 --- a/htdocs/core/modules/modBlockedLog.class.php +++ b/htdocs/core/modules/modBlockedLog.class.php @@ -30,21 +30,21 @@ include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php'; class modBlockedLog extends DolibarrModules { /** - * Constructor. Define names, constants, directories, boxes, permissions - * - * @param DoliDB $db Database handler + * Constructor. Define names, constants, directories, boxes, permissions + * + * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { - global $langs, $conf, $mysoc; + global $langs, $conf, $mysoc; $this->db = $db; $this->numero = 3200; // Key text used to identify module (for permissions, menus, etc...) $this->rights_class = 'blockedlog'; - // Family can be 'crm','financial','hr','projects','products','ecm','technic','other' - // It is used to group modules in module setup page + // Family can be 'crm','financial','hr','projects','products','ecm','technic','other' + // It is used to group modules in module setup page $this->family = "base"; // Module position in the family on 2 digits ('01', '10', '20', ...) $this->module_position = '75'; @@ -67,10 +67,10 @@ class modBlockedLog extends DolibarrModules // Dependancies //------------- - $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->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->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->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. /*if (! empty($conf->global->BLOCKEDLOG_DISABLE_NOT_ALLOWED_FOR_COUNTRY)) { - $tmp=explode(',', $conf->global->BLOCKEDLOG_DISABLE_NOT_ALLOWED_FOR_COUNTRY); - $this->automatic_activation = array(); - foreach($tmp as $key) - { - $this->automatic_activation[$key]='BlockedLogActivatedBecauseRequiredByYourCountryLegislation'; - } + $tmp=explode(',', $conf->global->BLOCKEDLOG_DISABLE_NOT_ALLOWED_FOR_COUNTRY); + $this->automatic_activation = array(); + foreach($tmp as $key) + { + $this->automatic_activation[$key]='BlockedLogActivatedBecauseRequiredByYourCountryLegislation'; + } }*/ //var_dump($this->automatic_activation); $this->always_enabled = (!empty($conf->blockedlog->enabled) - && !empty($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)); + && !empty($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)); // Constants //----------- $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 @@ -148,9 +148,9 @@ class modBlockedLog extends DolibarrModules function alreadyUsed() { - require_once DOL_DOCUMENT_ROOT.'/blockedlog/class/blockedlog.class.php'; - $b=new BlockedLog($this->db); - return $b->alreadyUsed(1); + require_once DOL_DOCUMENT_ROOT.'/blockedlog/class/blockedlog.class.php'; + $b=new BlockedLog($this->db); + return $b->alreadyUsed(1); } @@ -164,87 +164,87 @@ class modBlockedLog extends DolibarrModules */ 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 - require_once DOL_DOCUMENT_ROOT.'/blockedlog/class/blockedlog.class.php'; + // If already used, we add an entry to show we enable module + require_once DOL_DOCUMENT_ROOT.'/blockedlog/class/blockedlog.class.php'; - $object=new stdClass(); - $object->id = 1; - $object->element = 'module'; - $object->ref = 'systemevent'; - $object->entity = $conf->entity; - $object->date = dol_now(); + $object=new stdClass(); + $object->id = 1; + $object->element = 'module'; + $object->ref = 'systemevent'; + $object->entity = $conf->entity; + $object->date = dol_now(); - $b=new BlockedLog($this->db); - $result = $b->setObjectData($object, 'MODULE_SET', 0); - if ($result < 0) - { - $this->error = $b->error; - $this->errors = $b->erros; - return 0; - } + $b=new BlockedLog($this->db); + $result = $b->setObjectData($object, 'MODULE_SET', 0); + if ($result < 0) + { + $this->error = $b->error; + $this->errors = $b->erros; + return 0; + } - $res = $b->create($user); - if ($res<=0) { - $this->error = $b->error; - $this->errors = $b->errors; - return $res; - } + $res = $b->create($user); + if ($res<=0) { + $this->error = $b->error; + $this->errors = $b->errors; + return $res; + } - return $this->_init($sql, $options); + return $this->_init($sql, $options); } /** - * Function called when module is disabled. - * The remove function removes tabs, constants, boxes, permissions and menus from Dolibarr database. - * Data directories are not deleted - * - * @param string $options Options when enabling module ('', 'noboxes') - * @return int 1 if OK, 0 if KO - */ + * Function called when module is disabled. + * The remove function removes tabs, constants, boxes, permissions and menus from Dolibarr database. + * Data directories are not deleted + * + * @param string $options Options when enabling module ('', 'noboxes') + * @return int 1 if OK, 0 if KO + */ 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 - require_once DOL_DOCUMENT_ROOT.'/blockedlog/class/blockedlog.class.php'; + // If already used, we add an entry to show we enable module + require_once DOL_DOCUMENT_ROOT.'/blockedlog/class/blockedlog.class.php'; - $object=new stdClass(); - $object->id = 1; - $object->element = 'module'; - $object->ref = 'systemevent'; - $object->entity = $conf->entity; - $object->date = dol_now(); + $object=new stdClass(); + $object->id = 1; + $object->element = 'module'; + $object->ref = 'systemevent'; + $object->entity = $conf->entity; + $object->date = dol_now(); - $b=new BlockedLog($this->db); - $result = $b->setObjectData($object, 'MODULE_RESET', 0); - if ($result < 0) - { - $this->error = $b->error; - $this->errors = $b->erros; - return 0; - } + $b=new BlockedLog($this->db); + $result = $b->setObjectData($object, 'MODULE_RESET', 0); + if ($result < 0) + { + $this->error = $b->error; + $this->errors = $b->erros; + return 0; + } - if ($b->alreadyUsed(1)) - { - $res = $b->create($user, '0000000000'); // If already used for something else than SET or UNSET, we log with error - } - else - { - $res = $b->create($user); - } - if ($res<=0) { - $this->error = $b->error; - $this->errors = $b->errors; - return $res; - } + if ($b->alreadyUsed(1)) + { + $res = $b->create($user, '0000000000'); // If already used for something else than SET or UNSET, we log with error + } + else + { + $res = $b->create($user); + } + if ($res<=0) { + $this->error = $b->error; + $this->errors = $b->errors; + return $res; + } - return $this->_remove($sql, $options); + return $this->_remove($sql, $options); } } diff --git a/htdocs/core/modules/modBookmark.class.php b/htdocs/core/modules/modBookmark.class.php index 38da9a62059..0717236a1bb 100644 --- a/htdocs/core/modules/modBookmark.class.php +++ b/htdocs/core/modules/modBookmark.class.php @@ -38,7 +38,7 @@ class modBookmark extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; $this->numero = 330; diff --git a/htdocs/core/modules/modCashDesk.class.php b/htdocs/core/modules/modCashDesk.class.php index ed1a4485152..5a809302ea4 100644 --- a/htdocs/core/modules/modCashDesk.class.php +++ b/htdocs/core/modules/modCashDesk.class.php @@ -35,7 +35,7 @@ class modCashDesk extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; diff --git a/htdocs/core/modules/modCategorie.class.php b/htdocs/core/modules/modCategorie.class.php index 82d0d9d8289..b61ab34f05d 100644 --- a/htdocs/core/modules/modCategorie.class.php +++ b/htdocs/core/modules/modCategorie.class.php @@ -37,7 +37,7 @@ class modCategorie extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $conf; diff --git a/htdocs/core/modules/modClickToDial.class.php b/htdocs/core/modules/modClickToDial.class.php index 6e8ad1d3041..a25b0fd4571 100644 --- a/htdocs/core/modules/modClickToDial.class.php +++ b/htdocs/core/modules/modClickToDial.class.php @@ -38,7 +38,7 @@ class modClickToDial extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; $this->numero = 58; diff --git a/htdocs/core/modules/modCollab.class.php b/htdocs/core/modules/modCollab.class.php index 1e1db01f616..62de6a62b0c 100644 --- a/htdocs/core/modules/modCollab.class.php +++ b/htdocs/core/modules/modCollab.class.php @@ -32,33 +32,33 @@ class modCollab extends DolibarrModules { /** - * Constructor. Define names, constants, directories, boxes, permissions - * - * @param DoliDB $db Database handler + * Constructor. Define names, constants, directories, boxes, permissions + * + * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { - global $langs,$conf; + global $langs,$conf; $this->db = $db; $this->numero = 30000; - // Family can be 'crm','financial','hr','projects','products','ecm','technic','other' - // It is used to group modules in module setup page + // Family can be 'crm','financial','hr','projects','products','ecm','technic','other' + // It is used to group modules in module setup page $this->family = "portal"; $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) $this->name = preg_replace('/^mod/i', '', get_class($this)); $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'; // Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase) $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); // Name of image file used for this module. $this->picto='globe'; - // Data directories to create when module is enabled - $this->dirs = array("/collab/temp"); + // Data directories to create when module is enabled + $this->dirs = array("/collab/temp"); // Config pages //------------- @@ -66,15 +66,15 @@ class modCollab extends DolibarrModules // Dependancies //------------- - $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->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->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"); // Constants //----------- - $this->const = array(); + $this->const = array(); // New pages on tabs // ----------------- @@ -84,42 +84,42 @@ class modCollab extends DolibarrModules //------ $this->boxes = array(); - // Permissions - $this->rights = array(); // Permission array used by this module - $this->rights_class = 'collab'; - $r=0; + // Permissions + $this->rights = array(); // Permission array used by this module + $this->rights_class = 'collab'; + $r=0; - /*$this->rights[$r][0] = 30001; - $this->rights[$r][1] = 'Read website content'; - $this->rights[$r][3] = 0; - $this->rights[$r][4] = 'read'; - $r++; + /*$this->rights[$r][0] = 30001; + $this->rights[$r][1] = 'Read website content'; + $this->rights[$r][3] = 0; + $this->rights[$r][4] = 'read'; + $r++; - $this->rights[$r][0] = 30002; - $this->rights[$r][1] = 'Create/modify website content'; - $this->rights[$r][3] = 0; - $this->rights[$r][4] = 'write'; - $r++; + $this->rights[$r][0] = 30002; + $this->rights[$r][1] = 'Create/modify website content'; + $this->rights[$r][3] = 0; + $this->rights[$r][4] = 'write'; + $r++; - $this->rights[$r][0] = 30003; - $this->rights[$r][1] = 'Delete website content'; - $this->rights[$r][3] = 0; - $this->rights[$r][4] = 'delete'; - $r++;*/ + $this->rights[$r][0] = 30003; + $this->rights[$r][1] = 'Delete website content'; + $this->rights[$r][3] = 0; + $this->rights[$r][4] = 'delete'; + $r++;*/ // Main menu entries $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 - 'type'=>'top', // This is a Left menu entry - 'titre'=>'Collab', + 'type'=>'top', // This is a Left menu entry + 'titre'=>'Collab', 'mainmenu'=>'collab', - 'url'=>'/collab/index.php', - 'langs'=>'collab', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. - '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. - 'perms'=>'1', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules - 'target'=>'', - 'user'=>2); // 0=Menu for internal users, 1=external users, 2=both + 'url'=>'/collab/index.php', + 'langs'=>'collab', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. + '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. + 'perms'=>'1', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules + 'target'=>'', + 'user'=>2); // 0=Menu for internal users, 1=external users, 2=both $r++; } } diff --git a/htdocs/core/modules/modCommande.class.php b/htdocs/core/modules/modCommande.class.php index 63e2fe4bf88..631f80c1075 100644 --- a/htdocs/core/modules/modCommande.class.php +++ b/htdocs/core/modules/modCommande.class.php @@ -43,7 +43,7 @@ class modCommande extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $conf, $user; diff --git a/htdocs/core/modules/modComptabilite.class.php b/htdocs/core/modules/modComptabilite.class.php index 226292537f5..cf30480a8df 100644 --- a/htdocs/core/modules/modComptabilite.class.php +++ b/htdocs/core/modules/modComptabilite.class.php @@ -40,7 +40,7 @@ class modComptabilite extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $conf; diff --git a/htdocs/core/modules/modContrat.class.php b/htdocs/core/modules/modContrat.class.php index 8bcc645d3ba..628ca6183f5 100644 --- a/htdocs/core/modules/modContrat.class.php +++ b/htdocs/core/modules/modContrat.class.php @@ -39,7 +39,7 @@ class modContrat extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $conf, $langs; diff --git a/htdocs/core/modules/modCron.class.php b/htdocs/core/modules/modCron.class.php index 31d27abac0b..f07ddeaeaae 100644 --- a/htdocs/core/modules/modCron.class.php +++ b/htdocs/core/modules/modCron.class.php @@ -37,7 +37,7 @@ class modCron extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $langs, $conf; diff --git a/htdocs/core/modules/modDataPolicy.class.php b/htdocs/core/modules/modDataPolicy.class.php index 5dfc0fb83dd..be88c709090 100644 --- a/htdocs/core/modules/modDataPolicy.class.php +++ b/htdocs/core/modules/modDataPolicy.class.php @@ -210,15 +210,15 @@ class modDataPolicy extends DolibarrModules { */ public function init($options = '') { - global $langs; + global $langs; - $this->_load_tables('/datapolicy/sql/'); + $this->_load_tables('/datapolicy/sql/'); // Create extrafields include_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php'; $extrafields = new ExtraFields($this->db); - /* + /* // 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_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_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); - */ + */ $sql = array(); diff --git a/htdocs/core/modules/modDeplacement.class.php b/htdocs/core/modules/modDeplacement.class.php index ce2a8056e48..c48aaf44449 100644 --- a/htdocs/core/modules/modDeplacement.class.php +++ b/htdocs/core/modules/modDeplacement.class.php @@ -37,7 +37,7 @@ class modDeplacement extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $conf, $user; diff --git a/htdocs/core/modules/modDocumentGeneration.class.php b/htdocs/core/modules/modDocumentGeneration.class.php index 455c28914da..99c7e0ffbdf 100644 --- a/htdocs/core/modules/modDocumentGeneration.class.php +++ b/htdocs/core/modules/modDocumentGeneration.class.php @@ -39,7 +39,7 @@ class modDocumentGeneration extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; $this->numero = 1520; diff --git a/htdocs/core/modules/modDon.class.php b/htdocs/core/modules/modDon.class.php index bb27b309c1d..c9cd7c417e4 100644 --- a/htdocs/core/modules/modDon.class.php +++ b/htdocs/core/modules/modDon.class.php @@ -40,7 +40,7 @@ class modDon extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; $this->numero = 700; diff --git a/htdocs/core/modules/modDynamicPrices.class.php b/htdocs/core/modules/modDynamicPrices.class.php index 6e915afc6f8..708f0fb86a7 100644 --- a/htdocs/core/modules/modDynamicPrices.class.php +++ b/htdocs/core/modules/modDynamicPrices.class.php @@ -36,7 +36,7 @@ class modDynamicPrices extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; $this->numero = 2200; diff --git a/htdocs/core/modules/modECM.class.php b/htdocs/core/modules/modECM.class.php index 602bc37a03c..0208541d2e2 100644 --- a/htdocs/core/modules/modECM.class.php +++ b/htdocs/core/modules/modECM.class.php @@ -37,7 +37,7 @@ class modECM extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; diff --git a/htdocs/core/modules/modExpedition.class.php b/htdocs/core/modules/modExpedition.class.php index 443146d13a4..1aa04bb18c8 100644 --- a/htdocs/core/modules/modExpedition.class.php +++ b/htdocs/core/modules/modExpedition.class.php @@ -41,7 +41,7 @@ class modExpedition extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $conf, $user; diff --git a/htdocs/core/modules/modExpenseReport.class.php b/htdocs/core/modules/modExpenseReport.class.php index d715cb119ca..977ded085c2 100644 --- a/htdocs/core/modules/modExpenseReport.class.php +++ b/htdocs/core/modules/modExpenseReport.class.php @@ -36,7 +36,7 @@ class modExpenseReport extends DolibarrModules * * @param Database $db Database handler */ - function __construct($db) + public function __construct($db) { global $conf; diff --git a/htdocs/core/modules/modExport.class.php b/htdocs/core/modules/modExport.class.php index b0d95137316..d636772caff 100644 --- a/htdocs/core/modules/modExport.class.php +++ b/htdocs/core/modules/modExport.class.php @@ -38,7 +38,7 @@ class modExport extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; $this->numero = 240; diff --git a/htdocs/core/modules/modExternalRss.class.php b/htdocs/core/modules/modExternalRss.class.php index e384bccbcba..7925a6c4369 100644 --- a/htdocs/core/modules/modExternalRss.class.php +++ b/htdocs/core/modules/modExternalRss.class.php @@ -38,7 +38,7 @@ class modExternalRss extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $conf; diff --git a/htdocs/core/modules/modExternalSite.class.php b/htdocs/core/modules/modExternalSite.class.php index 0a720579eda..6cbd7141af8 100644 --- a/htdocs/core/modules/modExternalSite.class.php +++ b/htdocs/core/modules/modExternalSite.class.php @@ -39,7 +39,7 @@ class modExternalSite extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; diff --git a/htdocs/core/modules/modFTP.class.php b/htdocs/core/modules/modFTP.class.php index a54cbc24963..699617cd99e 100644 --- a/htdocs/core/modules/modFTP.class.php +++ b/htdocs/core/modules/modFTP.class.php @@ -33,12 +33,12 @@ include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php'; class modFTP extends DolibarrModules { - /** - * Constructor. Define names, constants, directories, boxes, permissions - * - * @param DoliDB $db Database handler + /** + * Constructor. Define names, constants, directories, boxes, permissions + * + * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; diff --git a/htdocs/core/modules/modFacture.class.php b/htdocs/core/modules/modFacture.class.php index c8e29205306..80a3fe5f8c6 100644 --- a/htdocs/core/modules/modFacture.class.php +++ b/htdocs/core/modules/modFacture.class.php @@ -40,7 +40,7 @@ class modFacture extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $conf, $user; diff --git a/htdocs/core/modules/modFckeditor.class.php b/htdocs/core/modules/modFckeditor.class.php index 873aba7eb30..7085fbef000 100644 --- a/htdocs/core/modules/modFckeditor.class.php +++ b/htdocs/core/modules/modFckeditor.class.php @@ -39,7 +39,7 @@ class modFckeditor extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; $this->numero = 2000; diff --git a/htdocs/core/modules/modFicheinter.class.php b/htdocs/core/modules/modFicheinter.class.php index de2d40490c0..ed2add33648 100644 --- a/htdocs/core/modules/modFicheinter.class.php +++ b/htdocs/core/modules/modFicheinter.class.php @@ -42,7 +42,7 @@ class modFicheinter extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $conf; diff --git a/htdocs/core/modules/modFournisseur.class.php b/htdocs/core/modules/modFournisseur.class.php index 3510834a836..55f9adfb0d8 100644 --- a/htdocs/core/modules/modFournisseur.class.php +++ b/htdocs/core/modules/modFournisseur.class.php @@ -39,7 +39,7 @@ class modFournisseur extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $conf, $user; diff --git a/htdocs/core/modules/modGeoIPMaxmind.class.php b/htdocs/core/modules/modGeoIPMaxmind.class.php index 0b090abfa80..91c82e713db 100644 --- a/htdocs/core/modules/modGeoIPMaxmind.class.php +++ b/htdocs/core/modules/modGeoIPMaxmind.class.php @@ -37,7 +37,7 @@ class modGeoIPMaxmind extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; $this->numero = 2900; diff --git a/htdocs/core/modules/modGravatar.class.php b/htdocs/core/modules/modGravatar.class.php index 9dbf4ee124f..bfff235bdae 100644 --- a/htdocs/core/modules/modGravatar.class.php +++ b/htdocs/core/modules/modGravatar.class.php @@ -36,7 +36,7 @@ class modGravatar extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; diff --git a/htdocs/core/modules/modHoliday.class.php b/htdocs/core/modules/modHoliday.class.php index 01a70a429ad..09a30e16914 100644 --- a/htdocs/core/modules/modHoliday.class.php +++ b/htdocs/core/modules/modHoliday.class.php @@ -41,7 +41,7 @@ class modHoliday extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; diff --git a/htdocs/core/modules/modImport.class.php b/htdocs/core/modules/modImport.class.php index e7d47763013..2f5c8c77db8 100644 --- a/htdocs/core/modules/modImport.class.php +++ b/htdocs/core/modules/modImport.class.php @@ -38,7 +38,7 @@ class modImport extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; $this->numero = 250; diff --git a/htdocs/core/modules/modIncoterm.class.php b/htdocs/core/modules/modIncoterm.class.php index 9d07028c5dd..8cae0980ff7 100644 --- a/htdocs/core/modules/modIncoterm.class.php +++ b/htdocs/core/modules/modIncoterm.class.php @@ -38,8 +38,8 @@ class modIncoterm extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) - { + public function __construct($db) + { global $langs,$conf; $this->db = $db; diff --git a/htdocs/core/modules/modLabel.class.php b/htdocs/core/modules/modLabel.class.php index c0f02229f2b..0bbddb6adc7 100644 --- a/htdocs/core/modules/modLabel.class.php +++ b/htdocs/core/modules/modLabel.class.php @@ -38,7 +38,7 @@ class modLabel extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; $this->numero = 60; diff --git a/htdocs/core/modules/modLdap.class.php b/htdocs/core/modules/modLdap.class.php index a2a355060d1..b2a290fe46a 100644 --- a/htdocs/core/modules/modLdap.class.php +++ b/htdocs/core/modules/modLdap.class.php @@ -37,7 +37,7 @@ class modLdap extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; $this->numero = 200; diff --git a/htdocs/core/modules/modLoan.class.php b/htdocs/core/modules/modLoan.class.php index 43a2876ef79..8bd5d194068 100644 --- a/htdocs/core/modules/modLoan.class.php +++ b/htdocs/core/modules/modLoan.class.php @@ -37,7 +37,7 @@ class modLoan extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $conf; diff --git a/htdocs/core/modules/modMailing.class.php b/htdocs/core/modules/modMailing.class.php index bbcd651d453..b978b8cb214 100644 --- a/htdocs/core/modules/modMailing.class.php +++ b/htdocs/core/modules/modMailing.class.php @@ -39,7 +39,7 @@ class modMailing extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; $this->numero = 22; diff --git a/htdocs/core/modules/modMailmanSpip.class.php b/htdocs/core/modules/modMailmanSpip.class.php index 2c4123fc3fa..ecae27155b5 100644 --- a/htdocs/core/modules/modMailmanSpip.class.php +++ b/htdocs/core/modules/modMailmanSpip.class.php @@ -38,7 +38,7 @@ class modMailmanSpip extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; $this->numero = 105; diff --git a/htdocs/core/modules/modMargin.class.php b/htdocs/core/modules/modMargin.class.php index 22124404673..f5b79570c1a 100644 --- a/htdocs/core/modules/modMargin.class.php +++ b/htdocs/core/modules/modMargin.class.php @@ -35,7 +35,7 @@ class modMargin extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; diff --git a/htdocs/core/modules/modModuleBuilder.class.php b/htdocs/core/modules/modModuleBuilder.class.php index 94d307ae522..59b3dcde2ce 100644 --- a/htdocs/core/modules/modModuleBuilder.class.php +++ b/htdocs/core/modules/modModuleBuilder.class.php @@ -35,7 +35,7 @@ class modModuleBuilder extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $langs,$conf; diff --git a/htdocs/core/modules/modMultiCurrency.class.php b/htdocs/core/modules/modMultiCurrency.class.php index 32bd1bd5980..e3f37c5f284 100644 --- a/htdocs/core/modules/modMultiCurrency.class.php +++ b/htdocs/core/modules/modMultiCurrency.class.php @@ -38,8 +38,8 @@ class modMultiCurrency extends DolibarrModules * * @param DoliDB $db Database handler */ - public function __construct($db) - { + public function __construct($db) + { global $langs, $conf; $this->db = $db; diff --git a/htdocs/core/modules/modNotification.class.php b/htdocs/core/modules/modNotification.class.php index 54698dca703..c3ccca4ef46 100644 --- a/htdocs/core/modules/modNotification.class.php +++ b/htdocs/core/modules/modNotification.class.php @@ -36,7 +36,7 @@ class modNotification extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; $this->numero = 600; diff --git a/htdocs/core/modules/modOauth.class.php b/htdocs/core/modules/modOauth.class.php index 27310e9c84e..ec12a6a2c6c 100644 --- a/htdocs/core/modules/modOauth.class.php +++ b/htdocs/core/modules/modOauth.class.php @@ -40,7 +40,7 @@ class modOauth extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db ; $this->numero = 66000; diff --git a/htdocs/core/modules/modOpenSurvey.class.php b/htdocs/core/modules/modOpenSurvey.class.php index a47a2791b60..c4e7e8b8338 100644 --- a/htdocs/core/modules/modOpenSurvey.class.php +++ b/htdocs/core/modules/modOpenSurvey.class.php @@ -37,7 +37,7 @@ class modOpenSurvey extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $langs,$conf; diff --git a/htdocs/core/modules/modPaybox.class.php b/htdocs/core/modules/modPaybox.class.php index 6349d5474b3..635c428f3fa 100644 --- a/htdocs/core/modules/modPaybox.class.php +++ b/htdocs/core/modules/modPaybox.class.php @@ -36,7 +36,7 @@ class modPayBox extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; diff --git a/htdocs/core/modules/modPaypal.class.php b/htdocs/core/modules/modPaypal.class.php index a4aa8fcc6b0..99ef4dd45de 100644 --- a/htdocs/core/modules/modPaypal.class.php +++ b/htdocs/core/modules/modPaypal.class.php @@ -37,7 +37,7 @@ class modPaypal extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; diff --git a/htdocs/core/modules/modPrelevement.class.php b/htdocs/core/modules/modPrelevement.class.php index f18bf1bf03c..475d3a1b24b 100644 --- a/htdocs/core/modules/modPrelevement.class.php +++ b/htdocs/core/modules/modPrelevement.class.php @@ -40,7 +40,7 @@ class modPrelevement extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $conf; diff --git a/htdocs/core/modules/modPrinting.class.php b/htdocs/core/modules/modPrinting.class.php index bb8a2be6120..09992bd176d 100644 --- a/htdocs/core/modules/modPrinting.class.php +++ b/htdocs/core/modules/modPrinting.class.php @@ -40,7 +40,7 @@ class modPrinting extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db ; $this->numero = 64000; diff --git a/htdocs/core/modules/modProduct.class.php b/htdocs/core/modules/modProduct.class.php index 4c6c420aa50..4a0af38dc34 100644 --- a/htdocs/core/modules/modProduct.class.php +++ b/htdocs/core/modules/modProduct.class.php @@ -42,7 +42,7 @@ class modProduct extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $conf, $mysoc; diff --git a/htdocs/core/modules/modProductBatch.class.php b/htdocs/core/modules/modProductBatch.class.php index f5e8fc6324c..be5952c35f5 100644 --- a/htdocs/core/modules/modProductBatch.class.php +++ b/htdocs/core/modules/modProductBatch.class.php @@ -38,7 +38,7 @@ class modProductBatch extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $langs,$conf; diff --git a/htdocs/core/modules/modProjet.class.php b/htdocs/core/modules/modProjet.class.php index eeca1e8883f..b50ad86e1e8 100644 --- a/htdocs/core/modules/modProjet.class.php +++ b/htdocs/core/modules/modProjet.class.php @@ -41,7 +41,7 @@ class modProjet extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $conf; diff --git a/htdocs/core/modules/modPropale.class.php b/htdocs/core/modules/modPropale.class.php index a2a32241065..c297cef47ec 100644 --- a/htdocs/core/modules/modPropale.class.php +++ b/htdocs/core/modules/modPropale.class.php @@ -41,7 +41,7 @@ class modPropale extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $conf, $user; diff --git a/htdocs/core/modules/modReceiptPrinter.class.php b/htdocs/core/modules/modReceiptPrinter.class.php index 6d00acb2d16..51313d5b1db 100644 --- a/htdocs/core/modules/modReceiptPrinter.class.php +++ b/htdocs/core/modules/modReceiptPrinter.class.php @@ -40,7 +40,7 @@ class modReceiptPrinter extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db ; $this->numero = 67000; diff --git a/htdocs/core/modules/modReception.class.php b/htdocs/core/modules/modReception.class.php index 663a854f7a5..f4d191c472e 100644 --- a/htdocs/core/modules/modReception.class.php +++ b/htdocs/core/modules/modReception.class.php @@ -36,7 +36,7 @@ class modReception extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $conf, $user; diff --git a/htdocs/core/modules/modService.class.php b/htdocs/core/modules/modService.class.php index 2e3ed91bf06..eb1b55000b9 100644 --- a/htdocs/core/modules/modService.class.php +++ b/htdocs/core/modules/modService.class.php @@ -40,7 +40,7 @@ class modService extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $conf, $mysoc; diff --git a/htdocs/core/modules/modSocialNetworks.class.php b/htdocs/core/modules/modSocialNetworks.class.php index b7e1bfd44a3..d8d8d8fb76e 100644 --- a/htdocs/core/modules/modSocialNetworks.class.php +++ b/htdocs/core/modules/modSocialNetworks.class.php @@ -36,7 +36,7 @@ class modSocialNetworks extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $langs,$conf; diff --git a/htdocs/core/modules/modSociete.class.php b/htdocs/core/modules/modSociete.class.php index b879959946d..f618236911b 100644 --- a/htdocs/core/modules/modSociete.class.php +++ b/htdocs/core/modules/modSociete.class.php @@ -41,7 +41,7 @@ class modSociete extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $conf, $user; diff --git a/htdocs/core/modules/modStock.class.php b/htdocs/core/modules/modStock.class.php index fa283c58137..153634f795e 100644 --- a/htdocs/core/modules/modStock.class.php +++ b/htdocs/core/modules/modStock.class.php @@ -40,7 +40,7 @@ class modStock extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $conf, $langs; diff --git a/htdocs/core/modules/modStripe.class.php b/htdocs/core/modules/modStripe.class.php index a2b2a68127a..ae15e763fd8 100644 --- a/htdocs/core/modules/modStripe.class.php +++ b/htdocs/core/modules/modStripe.class.php @@ -36,7 +36,7 @@ class modStripe extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; diff --git a/htdocs/core/modules/modSupplierProposal.class.php b/htdocs/core/modules/modSupplierProposal.class.php index 3d580fa439c..882b02b5fb4 100644 --- a/htdocs/core/modules/modSupplierProposal.class.php +++ b/htdocs/core/modules/modSupplierProposal.class.php @@ -42,7 +42,7 @@ class modSupplierProposal extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $conf; @@ -57,10 +57,10 @@ class modSupplierProposal extends DolibarrModules $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); $this->picto='supplier_proposal'; - + // Data directories to create when module is enabled. $this->dirs = array(); - + // 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"); @@ -206,7 +206,7 @@ class modSupplierProposal extends DolibarrModules * @param string $options Options when enabling module ('', 'noboxes') * @return int 1 if OK, 0 if KO */ - function init($options = '') + public function init($options = '') { global $conf,$langs; diff --git a/htdocs/core/modules/modSyslog.class.php b/htdocs/core/modules/modSyslog.class.php index a291b7977ee..1ac6ead1087 100644 --- a/htdocs/core/modules/modSyslog.class.php +++ b/htdocs/core/modules/modSyslog.class.php @@ -37,7 +37,7 @@ class modSyslog extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; $this->numero = 42; diff --git a/htdocs/core/modules/modTax.class.php b/htdocs/core/modules/modTax.class.php index a2f51ef0cc1..56983bbb207 100644 --- a/htdocs/core/modules/modTax.class.php +++ b/htdocs/core/modules/modTax.class.php @@ -41,7 +41,7 @@ class modTax extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $conf; diff --git a/htdocs/core/modules/modUser.class.php b/htdocs/core/modules/modUser.class.php index bef84b3a157..baf7f94d0f4 100644 --- a/htdocs/core/modules/modUser.class.php +++ b/htdocs/core/modules/modUser.class.php @@ -38,7 +38,7 @@ class modUser extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $conf; @@ -331,8 +331,8 @@ class modUser extends DolibarrModules * @param string $options Options when enabling module ('', 'noboxes') * @return int 1 if OK, 0 if KO */ - function init($options = '') - { + public function init($options = '') + { global $conf; // Permissions @@ -341,5 +341,5 @@ class modUser extends DolibarrModules $sql = array(); return $this->_init($sql, $options); - } + } } diff --git a/htdocs/core/modules/modWebServices.class.php b/htdocs/core/modules/modWebServices.class.php index 9d32b03df79..2aa98e80679 100644 --- a/htdocs/core/modules/modWebServices.class.php +++ b/htdocs/core/modules/modWebServices.class.php @@ -35,7 +35,7 @@ class modWebServices extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; $this->numero = 2600; diff --git a/htdocs/core/modules/modWebServicesClient.class.php b/htdocs/core/modules/modWebServicesClient.class.php index 6ec7bb5aae9..33c7bae997a 100644 --- a/htdocs/core/modules/modWebServicesClient.class.php +++ b/htdocs/core/modules/modWebServicesClient.class.php @@ -35,7 +35,7 @@ class modWebServicesClient extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; $this->numero = 2660; diff --git a/htdocs/core/modules/modWebsite.class.php b/htdocs/core/modules/modWebsite.class.php index 4fd6cd2976f..3fd1166b171 100644 --- a/htdocs/core/modules/modWebsite.class.php +++ b/htdocs/core/modules/modWebsite.class.php @@ -36,7 +36,7 @@ class modWebsite extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $langs,$conf; diff --git a/htdocs/core/modules/modWorkflow.class.php b/htdocs/core/modules/modWorkflow.class.php index 955165ffd80..5c1a2163537 100644 --- a/htdocs/core/modules/modWorkflow.class.php +++ b/htdocs/core/modules/modWorkflow.class.php @@ -37,7 +37,7 @@ class modWorkflow extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; diff --git a/htdocs/don/class/api_donations.class.php b/htdocs/don/class/api_donations.class.php index 6e38b67d2f1..8d722e31a0f 100644 --- a/htdocs/don/class/api_donations.class.php +++ b/htdocs/don/class/api_donations.class.php @@ -44,10 +44,10 @@ class Donations extends DolibarrApi /** * Constructor */ - function __construct() + public function __construct() { - global $db, $conf; - $this->db = $db; + global $db, $conf; + $this->db = $db; $this->don = new Don($this->db); } @@ -61,7 +61,7 @@ class Donations extends DolibarrApi * * @throws RestException */ - function get($id) + public function get($id) { if(! DolibarrApiAccess::$user->rights->don->lire) { throw new RestException(401); @@ -99,7 +99,7 @@ class Donations extends DolibarrApi * * @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; @@ -115,7 +115,7 @@ class Donations extends DolibarrApi $sql.= ' WHERE t.entity IN ('.getEntity('don').')'; 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." "; - + // Add sql filters if ($sqlfilters) { @@ -140,7 +140,7 @@ class Donations extends DolibarrApi dol_syslog("API Rest request"); $result = $db->query($sql); - + if ($result) { $num = $db->num_rows($result); @@ -164,7 +164,7 @@ class Donations extends DolibarrApi if( ! count($obj_ret)) { throw new RestException(404, 'No donation found'); } - + return $obj_ret; } @@ -174,15 +174,15 @@ class Donations extends DolibarrApi * @param array $request_data Request data * @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"); } // Check mandatory fields $result = $this->_validate($request_data); - foreach($request_data as $field => $value) { + foreach ($request_data as $field => $value) { $this->don->$field = $value; } /*if (isset($request_data["lines"])) { @@ -208,7 +208,7 @@ class Donations extends DolibarrApi * * @return int */ - function put($id, $request_data = null) + public function put($id, $request_data = null) { if (! DolibarrApiAccess::$user->rights->don->creer) { throw new RestException(401); @@ -222,7 +222,7 @@ class Donations extends DolibarrApi if (! DolibarrApi::_checkAccessToResource('donation', $this->don->id)) { 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; $this->don->$field = $value; } @@ -243,7 +243,7 @@ class Donations extends DolibarrApi * @param int $id Order ID * @return array */ - function delete($id) + public function delete($id) { if(! DolibarrApiAccess::$user->rights->don->supprimer) { throw new RestException(401); @@ -291,7 +291,7 @@ class Donations extends DolibarrApi * * @return array */ - function validate($id, $idwarehouse = 0, $notrigger = 0) + public function validate($id, $idwarehouse = 0, $notrigger = 0) { if(! DolibarrApiAccess::$user->rights->don->creer) { throw new RestException(401); @@ -332,7 +332,7 @@ class Donations extends DolibarrApi * @param object $object Object to clean * @return array Array of cleaned object properties */ - function _cleanObjectDatas($object) + private function _cleanObjectDatas($object) { $object = parent::_cleanObjectDatas($object); @@ -354,7 +354,7 @@ class Donations extends DolibarrApi * @return array * @throws RestException */ - function _validate($data) + private function _validate($data) { $don = array(); foreach (Orders::$FIELDS as $field) { diff --git a/htdocs/don/class/donstats.class.php b/htdocs/don/class/donstats.class.php index 2418f1babfd..bf6a61bb248 100644 --- a/htdocs/don/class/donstats.class.php +++ b/htdocs/don/class/donstats.class.php @@ -39,12 +39,12 @@ class DonationStats extends Stats */ public $table_element; - var $socid; - var $userid; + public $socid; + public $userid; - var $from; - var $field; - var $where; + public $from; + public $field; + public $where; /** @@ -55,7 +55,7 @@ class DonationStats extends Stats * @param string $mode Option (not used) * @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; @@ -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 $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 + * @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 + * @return array Array with number by month */ - function getNbByMonth($year, $format = 0) + public function getNbByMonth($year, $format = 0) { global $user; @@ -104,7 +104,7 @@ class DonationStats extends Stats * @return array Array with number by year * */ - function getNbByYear() + public function getNbByYear() { global $user; @@ -117,21 +117,21 @@ class DonationStats extends Stats return $this->_getNbByYear($sql); } - /** - * Return nb, total and average - * - * @return array Array of values - */ - function getAllByYear() - { - global $user; + /** + * Return nb, total and average + * + * @return array Array of values + */ + public function getAllByYear() + { + 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.= " FROM ".$this->from; - $sql.= " WHERE ".$this->where; - $sql.= " GROUP BY year"; + $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.= " WHERE ".$this->where; + $sql.= " GROUP BY year"; $sql.= $this->db->order('year', 'DESC'); - return $this->_getAllByYear($sql); - } + return $this->_getAllByYear($sql); + } } diff --git a/htdocs/don/class/paymentdonation.class.php b/htdocs/don/class/paymentdonation.class.php index deec339c1cc..ac35e3f5c44 100644 --- a/htdocs/don/class/paymentdonation.class.php +++ b/htdocs/don/class/paymentdonation.class.php @@ -88,7 +88,7 @@ class PaymentDonation extends CommonObject * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; } @@ -101,7 +101,7 @@ class PaymentDonation extends CommonObject * @param bool $notrigger false=launch triggers after, true=disable triggers * @return int <0 if KO, id of payment if OK */ - function create($user, $notrigger = false) + public function create($user, $notrigger = false) { global $conf, $langs; @@ -193,7 +193,7 @@ class PaymentDonation extends CommonObject * @param int $id Id object * @return int <0 if KO, >0 if OK */ - function fetch($id) + public function fetch($id) { global $langs; $sql = "SELECT"; @@ -264,7 +264,7 @@ class PaymentDonation extends CommonObject * @param int $notrigger 0=launch triggers after, 1=disable triggers * @return int <0 if KO, >0 if OK */ - function update($user, $notrigger = 0) + public function update($user, $notrigger = 0) { global $conf, $langs; $error=0; @@ -344,7 +344,7 @@ class PaymentDonation extends CommonObject * @param int $notrigger 0=launch triggers after, 1=disable triggers * @return int <0 if KO, >0 if OK */ - function delete($user, $notrigger = 0) + public function delete($user, $notrigger = 0) { global $conf, $langs; $error=0; @@ -411,7 +411,7 @@ class PaymentDonation extends CommonObject * @param int $fromid Id of object to clone * @return int New id of clone */ - function createFromClone($fromid) + public function createFromClone($fromid) { 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 * @return string Libelle */ - function getLibStatut($mode = 0) + public function getLibStatut($mode = 0) { return ''; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * 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 * @return string Libelle du statut */ - function LibStatut($statut, $mode = 0) - { + public function LibStatut($statut, $mode = 0) + { // phpcs:enable global $langs; - return ''; - } + return ''; + } /** @@ -496,7 +496,7 @@ class PaymentDonation extends CommonObject * * @return void */ - function initAsSpecimen() + public function initAsSpecimen() { $this->id=0; @@ -526,7 +526,7 @@ class PaymentDonation extends CommonObject * @param string $emetteur_banque Name of bank * @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; @@ -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 * * @param int $id_bank Id if bank * @return int >0 if OK, <=0 if KO */ - function update_fk_bank($id_bank) + public function update_fk_bank($id_bank) { // phpcs:enable $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 * @return string Chaine avec URL */ - function getNomUrl($withpicto = 0, $maxlen = 0) + public function getNomUrl($withpicto = 0, $maxlen = 0) { global $langs; diff --git a/htdocs/emailcollector/class/emailcollector.class.php b/htdocs/emailcollector/class/emailcollector.class.php index 7a4744d789f..e0f745dabec 100644 --- a/htdocs/emailcollector/class/emailcollector.class.php +++ b/htdocs/emailcollector/class/emailcollector.class.php @@ -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'), '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'), - //'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), + //'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), '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,), '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,), - '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,), + '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_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,), - '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), - '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_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,), - 'status' => array('type'=>'integer', 'label'=>'Status', 'visible'=>1, 'enabled'=>1, 'position'=>1000, 'notnull'=>1, 'index'=>1, 'arrayofkeyval'=>array('0'=>'Inactive', '1'=>'Active')) + '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), + '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_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,), + '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 */ - /*public function fetchLines() - { - $this->lines=array(); + /* + public function fetchLines() + { + $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 @@ -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 * @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 $dolibarr_main_authentication, $dolibarr_main_demo; @@ -549,7 +551,7 @@ class EmailCollector extends CommonObject */ 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.= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; $sql.= ' WHERE t.rowid = '.$id; @@ -673,7 +675,7 @@ class EmailCollector extends CommonObject * * @return string */ - function getConnectStringIMAP() + public function getConnectStringIMAP() { // Connect to IMAP $flags ='/service=imap'; // IMAP diff --git a/htdocs/emailcollector/class/emailcollectoraction.class.php b/htdocs/emailcollector/class/emailcollectoraction.class.php index 6eec6190b71..d49c28716cf 100644 --- a/htdocs/emailcollector/class/emailcollectoraction.class.php +++ b/htdocs/emailcollector/class/emailcollectoraction.class.php @@ -32,298 +32,301 @@ require_once DOL_DOCUMENT_ROOT . '/core/class/commonobject.class.php'; */ class EmailCollectorAction extends CommonObject { - /** - * @var string ID to identify managed object - */ - public $element = 'emailcollectoraction'; + /** + * @var string ID to identify managed object + */ + public $element = 'emailcollectoraction'; - /** - * @var string Name of table without prefix where object is stored - */ - public $table_element = 'emailcollector_emailcollectoraction'; + /** + * @var string Name of table without prefix where object is stored + */ + 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 - */ - public $ismultientitymanaged = 0; + /** + * @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; - /** - * @var int Does emailcollectoraction support extrafields ? 0=No, 1=Yes - */ - public $isextrafieldmanaged = 0; + /** + * @var int Does emailcollectoraction support extrafields ? 0=No, 1=Yes + */ + public $isextrafieldmanaged = 0; - /** - * @var string String with name of icon for emailcollectoraction. Must be the part after the 'object_' into object_emailcollectoraction.png - */ - public $picto = 'emailcollectoraction@emailcollector'; + /** + * @var string String with name of icon for emailcollectoraction. Must be the part after the 'object_' into object_emailcollectoraction.png + */ + public $picto = 'emailcollectoraction@emailcollector'; - /** - * 'type' if the field format. - * 'label' the translation key. - * '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) - * '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) - * '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_...). - * '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. - * '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' - * '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. - * '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") - */ + /** + * 'type' if the field format. + * 'label' the translation key. + * '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) + * '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) + * '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_...). + * '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. + * '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' + * '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. + * '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") + */ - // 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. - */ - public $fields=array( - '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'), - '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), - '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,), - '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,), - '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,), - '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 $fk_emailcollector; - public $type; - public $actionparam; - public $date_creation; - public $tms; - public $fk_user_creat; - public $fk_user_modif; - public $position; - public $import_key; - public $status; - // END 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. + */ + public $fields=array( + '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'), + '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), + '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,), + '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,), + '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,), + '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 $fk_emailcollector; + public $type; + public $actionparam; + public $date_creation; + public $tms; + public $fk_user_creat; + public $fk_user_modif; + public $position; + public $import_key; + public $status; + // 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 - */ - //public $table_element_line = 'emailcollectoractiondet'; + // /** + // * @var int Name of subtable line + // */ + //public $table_element_line = 'emailcollectoractiondet'; - /** - * @var int Field with ID of parent key if this field has a parent - */ - //public $fk_element = 'fk_emailcollectoraction'; + // /** + // * @var int Field with ID of parent key if this field has a parent + // */ + //public $fk_element = 'fk_emailcollectoraction'; - /** - * @var int Name of subtable class that manage subtable lines - */ - //public $class_element_line = 'EmailcollectorActionline'; + // /** + // * @var int Name of subtable class that manage subtable lines + // */ + //public $class_element_line = 'EmailcollectorActionline'; - /** - * @var array Array of child tables (child tables to delete before deleting a record) - */ - //protected $childtables=array('emailcollectoractiondet'); + // /** + // * @var array Array of child tables (child tables to delete before deleting a record) + // */ + //protected $childtables=array('emailcollectoractiondet'); - /** - * @var EmailcollectorActionLine[] Array of subtable lines - */ - //public $lines = array(); + // /** + // * @var EmailcollectorActionLine[] Array of subtable lines + // */ + //public $lines = array(); - /** - * Constructor - * - * @param DoliDb $db Database handler - */ - public function __construct(DoliDB $db) - { - global $conf, $langs, $user; + /** + * Constructor + * + * @param DoliDb $db Database handler + */ + public function __construct(DoliDB $db) + { + 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->multicompany->enabled) && isset($this->fields['entity'])) $this->fields['entity']['enabled']=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; - // Unset fields that are disabled - foreach($this->fields as $key => $val) - { - if (isset($val['enabled']) && empty($val['enabled'])) - { - unset($this->fields[$key]); - } - } + // Unset fields that are disabled + foreach($this->fields as $key => $val) + { + if (isset($val['enabled']) && empty($val['enabled'])) + { + unset($this->fields[$key]); + } + } - // Translate some data of arrayofkeyval - foreach($this->fields as $key => $val) - { - if (is_array($this->fields['status']['arrayofkeyval'])) - { - foreach($this->fields['status']['arrayofkeyval'] as $key2 => $val2) - { - $this->fields['status']['arrayofkeyval'][$key2]=$langs->trans($val2); - } - } - } - } + // Translate some data of arrayofkeyval + foreach($this->fields as $key => $val) + { + if (is_array($this->fields['status']['arrayofkeyval'])) + { + foreach($this->fields['status']['arrayofkeyval'] as $key2 => $val2) + { + $this->fields['status']['arrayofkeyval'][$key2]=$langs->trans($val2); + } + } + } + } - /** - * Create object into database - * - * @param User $user User that creates - * @param bool $notrigger false=launch triggers after, true=disable triggers - * @return int <0 if KO, Id of created object if OK - */ - public function create(User $user, $notrigger = false) - { - global $langs; - if (empty($this->type)) - { - $langs->load("errors"); - $this->errors[]=$langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")); - return -1; - } + /** + * Create object into database + * + * @param User $user User that creates + * @param bool $notrigger false=launch triggers after, true=disable triggers + * @return int <0 if KO, Id of created object if OK + */ + public function create(User $user, $notrigger = false) + { + global $langs; + if (empty($this->type)) + { + $langs->load("errors"); + $this->errors[]=$langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")); + return -1; + } - return $this->createCommon($user, $notrigger); - } + return $this->createCommon($user, $notrigger); + } - /** - * Clone and object into another one - * - * @param User $user User that creates - * @param int $fromid Id of object to clone - * @return mixed New object created, <0 if KO - */ - public function createFromClone(User $user, $fromid) - { - global $langs, $hookmanager, $extrafields; - $error = 0; + /** + * Clone and object into another one + * + * @param User $user User that creates + * @param int $fromid Id of object to clone + * @return mixed New object created, <0 if KO + */ + public function createFromClone(User $user, $fromid) + { + global $langs, $hookmanager, $extrafields; + $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 - $object->fetchCommon($fromid); - // Reset some properties - unset($object->id); - unset($object->fk_user_creat); - unset($object->import_key); + // Load source object + $object->fetchCommon($fromid); + // Reset some properties + unset($object->id); + unset($object->fk_user_creat); + unset($object->import_key); - // Clear fields - $object->ref = "copy_of_".$object->ref; - $object->title = $langs->trans("CopyOf")." ".$object->title; - // ... - // Clear extrafields that are unique - if (is_array($object->array_options) && count($object->array_options) > 0) - { - $extrafields->fetch_name_optionals_label($this->element); - foreach($object->array_options as $key => $option) - { - $shortkey = preg_replace('/options_/', '', $key); - if (! empty($extrafields->attributes[$this->element]['unique'][$shortkey])) - { - //var_dump($key); var_dump($clonedObj->array_options[$key]); exit; - unset($object->array_options[$key]); - } - } - } + // Clear fields + $object->ref = "copy_of_".$object->ref; + $object->title = $langs->trans("CopyOf")." ".$object->title; + // ... + // Clear extrafields that are unique + if (is_array($object->array_options) && count($object->array_options) > 0) + { + $extrafields->fetch_name_optionals_label($this->element); + foreach($object->array_options as $key => $option) + { + $shortkey = preg_replace('/options_/', '', $key); + if (! empty($extrafields->attributes[$this->element]['unique'][$shortkey])) + { + //var_dump($key); var_dump($clonedObj->array_options[$key]); exit; + unset($object->array_options[$key]); + } + } + } - // Create clone - $object->context['createfromclone'] = 'createfromclone'; - $result = $object->createCommon($user); - if ($result < 0) { - $error++; - $this->error = $object->error; - $this->errors = $object->errors; - } + // Create clone + $object->context['createfromclone'] = 'createfromclone'; + $result = $object->createCommon($user); + if ($result < 0) { + $error++; + $thi /** + * @var EmailcollectorActionLine[] Array of subtable lines + */ + s->error = $object->error; + $this->errors = $object->errors; + } - unset($object->context['createfromclone']); + unset($object->context['createfromclone']); - // End - if (!$error) { - $this->db->commit(); - return $object; - } else { - $this->db->rollback(); - return -1; - } - } + // End + if (!$error) { + $this->db->commit(); + return $object; + } else { + $this->db->rollback(); + return -1; + } + } - /** - * Load object in memory from the database - * - * @param int $id Id object - * @param string $ref Ref - * @return int <0 if KO, 0 if not found, >0 if OK - */ - public function fetch($id, $ref = null) - { - $result = $this->fetchCommon($id, $ref); - if ($result > 0 && ! empty($this->table_element_line)) $this->fetchLines(); - return $result; - } + /** + * Load object in memory from the database + * + * @param int $id Id object + * @param string $ref Ref + * @return int <0 if KO, 0 if not found, >0 if OK + */ + public function fetch($id, $ref = null) + { + $result = $this->fetchCommon($id, $ref); + if ($result > 0 && ! empty($this->table_element_line)) $this->fetchLines(); + return $result; + } - /** - * Load object lines in memory from the database - * - * @return int <0 if KO, 0 if not found, >0 if OK - */ - /*public function fetchLines() - { - $this->lines=array(); + /** + * Load object lines in memory from the database + * + * @return int <0 if KO, 0 if not found, >0 if OK + */ + /*public function fetchLines() + { + $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 - * - * @param User $user User that modifies - * @param bool $notrigger false=launch triggers after, true=disable triggers - * @return int <0 if KO, >0 if OK - */ - public function update(User $user, $notrigger = false) - { - return $this->updateCommon($user, $notrigger); - } + /** + * Update object into database + * + * @param User $user User that modifies + * @param bool $notrigger false=launch triggers after, true=disable triggers + * @return int <0 if KO, >0 if OK + */ + public function update(User $user, $notrigger = false) + { + return $this->updateCommon($user, $notrigger); + } - /** - * Delete object in database - * - * @param User $user User that deletes - * @param bool $notrigger false=launch triggers after, true=disable triggers - * @return int <0 if KO, >0 if OK - */ - public function delete(User $user, $notrigger = false) - { - return $this->deleteCommon($user, $notrigger); - } + /** + * Delete object in database + * + * @param User $user User that deletes + * @param bool $notrigger false=launch triggers after, true=disable triggers + * @return int <0 if KO, >0 if OK + */ + public function delete(User $user, $notrigger = false) + { + return $this->deleteCommon($user, $notrigger); + } - /** - * Return a link to the object card (with optionaly the picto) - * - * @param int $withpicto Include picto in link (0=No picto, 1=Include picto into link, 2=Only picto) - * @param string $option On what the link point to ('nolink', ...) + /** + * Return a link to the object card (with optionaly the picto) + * + * @param int $withpicto Include picto in link (0=No picto, 1=Include picto into link, 2=Only picto) + * @param string $option On what the link point to ('nolink', ...) * @param int $notooltip 1=Disable tooltip * @param string $morecss Add more css on link * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking - * @return string String with URL - */ - function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1) - { - global $db, $conf, $langs, $hookmanager; + * @return string String with URL + */ + public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1) + { + global $db, $conf, $langs, $hookmanager; global $dolibarr_main_authentication, $dolibarr_main_demo; global $menumanager; @@ -340,10 +343,10 @@ class EmailCollectorAction extends CommonObject if ($option != 'nolink') { - // Add param to save lastsearch_values or not - $add_save_lastsearch_values=($save_lastsearch_value == 1 ? 1 : 0); - if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values=1; - if ($add_save_lastsearch_values) $url.='&save_lastsearch_values=1'; + // Add param to save lastsearch_values or not + $add_save_lastsearch_values=($save_lastsearch_value == 1 ? 1 : 0); + if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values=1; + if ($add_save_lastsearch_values) $url.='&save_lastsearch_values=1'; } $linkclose=''; @@ -366,152 +369,152 @@ class EmailCollectorAction extends CommonObject } else $linkclose = ($morecss?' class="'.$morecss.'"':''); - $linkstart = ''; - $linkend=''; + $linkstart = ''; + $linkend=''; - $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 != 2) $result.= $this->ref; - $result .= $linkend; - //if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : ''); + $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 != 2) $result.= $this->ref; + $result .= $linkend; + //if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : ''); - global $action,$hookmanager; - $hookmanager->initHooks(array('emailcollectoractiondao')); - $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 - if ($reshook > 0) $result = $hookmanager->resPrint; - else $result .= $hookmanager->resPrint; + global $action,$hookmanager; + $hookmanager->initHooks(array('emailcollectoractiondao')); + $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 + if ($reshook > 0) $result = $hookmanager->resPrint; + else $result .= $hookmanager->resPrint; - return $result; - } + return $result; + } - /** - * 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 - * @return string Label of status - */ - public function getLibStatut($mode = 0) - { - return $this->LibStatut($this->status, $mode); - } + /** + * 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 + * @return string Label of status + */ + public function getLibStatut($mode = 0) + { + return $this->LibStatut($this->status, $mode); + } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Return the 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 - * @return string Label of status - */ - public function LibStatut($status, $mode = 0) - { - // phpcs:enable - if (empty($this->labelstatus)) - { - global $langs; - //$langs->load("emailcollector"); - $this->labelstatus[1] = $langs->trans('Enabled'); - $this->labelstatus[0] = $langs->trans('Disabled'); - } + /** + * Return the 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 + * @return string Label of status + */ + public function LibStatut($status, $mode = 0) + { + // phpcs:enable + if (empty($this->labelstatus)) + { + global $langs; + //$langs->load("emailcollector"); + $this->labelstatus[1] = $langs->trans('Enabled'); + $this->labelstatus[0] = $langs->trans('Disabled'); + } - if ($mode == 0) - { - return $this->labelstatus[$status]; - } - elseif ($mode == 1) - { - return $this->labelstatus[$status]; - } - elseif ($mode == 2) - { - 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 ($mode == 3) - { - 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 ($mode == 4) - { - 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 ($mode == 5) - { - 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 ($mode == 6) - { - 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'); - } - } + if ($mode == 0) + { + return $this->labelstatus[$status]; + } + elseif ($mode == 1) + { + return $this->labelstatus[$status]; + } + elseif ($mode == 2) + { + 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 ($mode == 3) + { + 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 ($mode == 4) + { + 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 ($mode == 5) + { + 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 ($mode == 6) + { + 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'); + } + } - /** - * Charge les informations d'ordre info dans l'objet commande - * - * @param int $id Id of order - * @return void - */ - public function info($id) - { - $sql = 'SELECT rowid, date_creation as datec, tms as datem,'; - $sql.= ' fk_user_creat, fk_user_modif'; - $sql.= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; - $sql.= ' WHERE t.rowid = '.$id; - $result=$this->db->query($sql); - if ($result) - { - if ($this->db->num_rows($result)) - { - $obj = $this->db->fetch_object($result); - $this->id = $obj->rowid; - if ($obj->fk_user_author) - { - $cuser = new User($this->db); - $cuser->fetch($obj->fk_user_author); - $this->user_creation = $cuser; - } + /** + * Charge les informations d'ordre info dans l'objet commande + * + * @param int $id Id of order + * @return void + */ + public function info($id) + { + $sql = 'SELECT rowid, date_creation as datec, tms as datem,'; + $sql.= ' fk_user_creat, fk_user_modif'; + $sql.= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; + $sql.= ' WHERE t.rowid = '.$id; + $result=$this->db->query($sql); + if ($result) + { + if ($this->db->num_rows($result)) + { + $obj = $this->db->fetch_object($result); + $this->id = $obj->rowid; + if ($obj->fk_user_author) + { + $cuser = new User($this->db); + $cuser->fetch($obj->fk_user_author); + $this->user_creation = $cuser; + } - if ($obj->fk_user_valid) - { - $vuser = new User($this->db); - $vuser->fetch($obj->fk_user_valid); - $this->user_validation = $vuser; - } + if ($obj->fk_user_valid) + { + $vuser = new User($this->db); + $vuser->fetch($obj->fk_user_valid); + $this->user_validation = $vuser; + } - if ($obj->fk_user_cloture) - { - $cluser = new User($this->db); - $cluser->fetch($obj->fk_user_cloture); - $this->user_cloture = $cluser; - } + if ($obj->fk_user_cloture) + { + $cluser = new User($this->db); + $cluser->fetch($obj->fk_user_cloture); + $this->user_cloture = $cluser; + } - $this->date_creation = $this->db->jdate($obj->datec); - $this->date_modification = $this->db->jdate($obj->datem); - $this->date_validation = $this->db->jdate($obj->datev); - } + $this->date_creation = $this->db->jdate($obj->datec); + $this->date_modification = $this->db->jdate($obj->datem); + $this->date_validation = $this->db->jdate($obj->datev); + } - $this->db->free($result); - } - else - { - dol_print_error($this->db); - } - } + $this->db->free($result); + } + else + { + dol_print_error($this->db); + } + } - /** - * Initialise object with example values - * Id must be 0 if object instance is a specimen - * - * @return void - */ - public function initAsSpecimen() - { - $this->initAsSpecimenCommon(); - } + /** + * Initialise object with example values + * Id must be 0 if object instance is a specimen + * + * @return void + */ + public function initAsSpecimen() + { + $this->initAsSpecimenCommon(); + } } diff --git a/htdocs/emailcollector/class/emailcollectorfilter.class.php b/htdocs/emailcollector/class/emailcollectorfilter.class.php index e0556bf865b..d46dfb1c9ae 100644 --- a/htdocs/emailcollector/class/emailcollectorfilter.class.php +++ b/htdocs/emailcollector/class/emailcollectorfilter.class.php @@ -296,7 +296,7 @@ class EmailCollectorFilter extends CommonObject * @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 */ - 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 $dolibarr_main_authentication, $dolibarr_main_demo; diff --git a/htdocs/expedition/class/api_shipments.class.php b/htdocs/expedition/class/api_shipments.class.php index 4f8d1ac0301..73923105c7d 100644 --- a/htdocs/expedition/class/api_shipments.class.php +++ b/htdocs/expedition/class/api_shipments.class.php @@ -48,8 +48,8 @@ class Shipments extends DolibarrApi */ public function __construct() { - global $db, $conf; - $this->db = $db; + global $db, $conf; + $this->db = $db; $this->shipment = new Expedition($this->db); } @@ -65,21 +65,21 @@ class Shipments extends DolibarrApi */ public function get($id) { - if(! DolibarrApiAccess::$user->rights->expedition->lire) { - throw new RestException(401); - } + if(! DolibarrApiAccess::$user->rights->expedition->lire) { + throw new RestException(401); + } $result = $this->shipment->fetch($id); if( ! $result ) { throw new RestException(404, 'Shipment not found'); } - if( ! DolibarrApi::_checkAccessToResource('expedition', $this->shipment->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } + if( ! DolibarrApi::_checkAccessToResource('expedition', $this->shipment->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } $this->shipment->fetchObjectLinked(); - return $this->_cleanObjectDatas($this->shipment); + return $this->_cleanObjectDatas($this->shipment); } @@ -97,7 +97,7 @@ class Shipments 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')" * @return array Array of shipment objects * - * @throws RestException + * @throws RestException */ public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $thirdparty_ids = '', $sqlfilters = '') { @@ -134,7 +134,7 @@ class Shipments extends DolibarrApi { throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); } - $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; + $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; $sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; } @@ -173,7 +173,7 @@ class Shipments extends DolibarrApi if( ! count($obj_ret)) { throw new RestException(404, 'No shipment found'); } - return $obj_ret; + return $obj_ret; } /** @@ -378,30 +378,30 @@ class Shipments extends DolibarrApi */ public function deleteLine($id, $lineid) { - if(! DolibarrApiAccess::$user->rights->expedition->creer) { - throw new RestException(401); - } + if(! DolibarrApiAccess::$user->rights->expedition->creer) { + throw new RestException(401); + } - $result = $this->shipment->fetch($id); - if( ! $result ) { - throw new RestException(404, 'Shipment not found'); - } + $result = $this->shipment->fetch($id); + if( ! $result ) { + throw new RestException(404, 'Shipment not found'); + } - if( ! DolibarrApi::_checkAccessToResource('expedition', $this->shipment->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } + if( ! DolibarrApi::_checkAccessToResource('expedition', $this->shipment->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } - // TODO Check the lineid $lineid is a line of ojbect + // TODO Check the lineid $lineid is a line of ojbect - $request_data = (object) $request_data; - $updateRes = $this->shipment->deleteline(DolibarrApiAccess::$user, $lineid); - if ($updateRes > 0) { - return $this->get($id); - } - else - { - throw new RestException(405, $this->shipment->error); - } + $request_data = (object) $request_data; + $updateRes = $this->shipment->deleteline(DolibarrApiAccess::$user, $lineid); + if ($updateRes > 0) { + return $this->get($id); + } + else + { + throw new RestException(405, $this->shipment->error); + } } /** @@ -423,9 +423,9 @@ class Shipments extends DolibarrApi throw new RestException(404, 'Shipment not found'); } - if (! DolibarrApi::_checkAccessToResource('expedition', $this->shipment->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } + if (! DolibarrApi::_checkAccessToResource('expedition', $this->shipment->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } foreach($request_data as $field => $value) { if ($field == 'id') continue; $this->shipment->$field = $value; @@ -437,7 +437,7 @@ class Shipments extends DolibarrApi } else { - throw new RestException(500, $this->shipment->error); + throw new RestException(500, $this->shipment->error); } } @@ -451,16 +451,16 @@ class Shipments extends DolibarrApi public function delete($id) { if(! DolibarrApiAccess::$user->rights->shipment->supprimer) { - throw new RestException(401); - } + throw new RestException(401); + } $result = $this->shipment->fetch($id); if( ! $result ) { throw new RestException(404, 'Shipment not found'); } - if( ! DolibarrApi::_checkAccessToResource('expedition', $this->shipment->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } + if( ! DolibarrApi::_checkAccessToResource('expedition', $this->shipment->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } if( ! $this->shipment->delete(DolibarrApiAccess::$user)) { throw new RestException(500, 'Error when deleting shipment : '.$this->shipment->error); @@ -496,23 +496,23 @@ class Shipments extends DolibarrApi public function validate($id, $notrigger = 0) { if (! DolibarrApiAccess::$user->rights->expedition->creer) { - throw new RestException(401); - } + throw new RestException(401); + } $result = $this->shipment->fetch($id); if ( ! $result ) { throw new RestException(404, 'Shipment not found'); } - if ( ! DolibarrApi::_checkAccessToResource('expedition', $this->shipment->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } + if ( ! DolibarrApi::_checkAccessToResource('expedition', $this->shipment->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } - $result = $this->shipment->valid(DolibarrApiAccess::$user, $notrigger); - if ($result == 0) { - throw new RestException(304, 'Error nothing done. May be object is already validated'); - } - if ($result < 0) { - throw new RestException(500, 'Error when validating Shipment: '.$this->shipment->error); + $result = $this->shipment->valid(DolibarrApiAccess::$user, $notrigger); + if ($result == 0) { + throw new RestException(304, 'Error nothing done. May be object is already validated'); + } + if ($result < 0) { + throw new RestException(500, 'Error when validating Shipment: '.$this->shipment->error); } $result = $this->shipment->fetch($id); if ( ! $result ) { @@ -608,7 +608,7 @@ class Shipments extends DolibarrApi $this->shipment->fetchObjectLinked(); return $this->_cleanObjectDatas($this->shipment); } - */ + */ /** * Clean sensible object datas @@ -634,15 +634,15 @@ class Shipments extends DolibarrApi { foreach ($object->lines as $line) { - unset($line->tva_tx); - unset($line->vat_src_code); - unset($line->total_ht); - unset($line->total_ttc); - unset($line->total_tva); - unset($line->total_localtax1); - unset($line->total_localtax2); - unset($line->remise_percent); - } + unset($line->tva_tx); + unset($line->vat_src_code); + unset($line->total_ht); + unset($line->total_ttc); + unset($line->total_tva); + unset($line->total_localtax1); + unset($line->total_localtax2); + unset($line->remise_percent); + } } return $object; diff --git a/htdocs/expensereport/class/api_expensereports.class.php b/htdocs/expensereport/class/api_expensereports.class.php index 02e1021a141..35ce9f9a4a2 100644 --- a/htdocs/expensereport/class/api_expensereports.class.php +++ b/htdocs/expensereport/class/api_expensereports.class.php @@ -45,7 +45,7 @@ class ExpenseReports extends DolibarrApi /** * Constructor */ - function __construct() + public function __construct() { global $db, $conf; $this->db = $db; @@ -59,26 +59,26 @@ class ExpenseReports extends DolibarrApi * * @param int $id ID of Expense Report * @return array|mixed Data without useless information - * + * * @throws RestException */ - function get($id) + public function get($id) { - if(! DolibarrApiAccess::$user->rights->expensereport->lire) { - throw new RestException(401); - } + if(! DolibarrApiAccess::$user->rights->expensereport->lire) { + throw new RestException(401); + } $result = $this->expensereport->fetch($id); if( ! $result ) { throw new RestException(404, 'Expense report not found'); } - if( ! DolibarrApi::_checkAccessToResource('expensereport', $this->expensereport->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } + if( ! DolibarrApi::_checkAccessToResource('expensereport', $this->expensereport->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } $this->expensereport->fetchObjectLinked(); - return $this->_cleanObjectDatas($this->expensereport); + return $this->_cleanObjectDatas($this->expensereport); } /** @@ -94,7 +94,7 @@ class ExpenseReports 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')" * @return array Array of Expense Report objects */ - function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $user_ids = 0, $sqlfilters = '') + public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $user_ids = 0, $sqlfilters = '') { global $db, $conf; @@ -115,7 +115,7 @@ class ExpenseReports extends DolibarrApi { throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); } - $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; + $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; $sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; } @@ -152,7 +152,7 @@ class ExpenseReports extends DolibarrApi if( ! count($obj_ret)) { throw new RestException(404, 'No Expense Report found'); } - return $obj_ret; + return $obj_ret; } /** @@ -161,7 +161,7 @@ class ExpenseReports extends DolibarrApi * @param array $request_data Request data * @return int ID of Expense Report */ - function post($request_data = null) + public function post($request_data = null) { if(! DolibarrApiAccess::$user->rights->expensereport->creer) { throw new RestException(401, "Insuffisant rights"); @@ -195,8 +195,8 @@ class ExpenseReports extends DolibarrApi * * @return int */ -/* - function getLines($id) + /* + public function getLines($id) { if(! DolibarrApiAccess::$user->rights->expensereport->lire) { throw new RestException(401); @@ -217,7 +217,7 @@ class ExpenseReports extends DolibarrApi } return $result; } -*/ + */ /** * Add a line to given Expense Report @@ -229,22 +229,22 @@ class ExpenseReports extends DolibarrApi * * @return int */ -/* - function postLine($id, $request_data = null) + /* + public function postLine($id, $request_data = null) { if(! DolibarrApiAccess::$user->rights->expensereport->creer) { - throw new RestException(401); - } + throw new RestException(401); + } $result = $this->expensereport->fetch($id); if( ! $result ) { throw new RestException(404, 'expensereport not found'); } - if( ! DolibarrApi::_checkAccessToResource('expensereport',$this->expensereport->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + if( ! DolibarrApi::_checkAccessToResource('expensereport',$this->expensereport->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } - $request_data = (object) $request_data; + $request_data = (object) $request_data; $updateRes = $this->expensereport->addline( $request_data->desc, $request_data->subprice, @@ -279,7 +279,7 @@ class ExpenseReports extends DolibarrApi } return false; } -*/ + */ /** * Update a line to given Expense Report @@ -293,22 +293,22 @@ class ExpenseReports extends DolibarrApi * @return object */ /* - function putLine($id, $lineid, $request_data = null) + public function putLine($id, $lineid, $request_data = null) { - if(! DolibarrApiAccess::$user->rights->expensereport->creer) { - throw new RestException(401); - } + if(! DolibarrApiAccess::$user->rights->expensereport->creer) { + throw new RestException(401); + } - $result = $this->expensereport->fetch($id); - if( ! $result ) { - throw new RestException(404, 'expensereport not found'); - } + $result = $this->expensereport->fetch($id); + if( ! $result ) { + throw new RestException(404, 'expensereport not found'); + } - if( ! DolibarrApi::_checkAccessToResource('expensereport',$this->expensereport->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } - $request_data = (object) $request_data; - $updateRes = $this->expensereport->updateline( + if( ! DolibarrApi::_checkAccessToResource('expensereport',$this->expensereport->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } + $request_data = (object) $request_data; + $updateRes = $this->expensereport->updateline( $lineid, $request_data->desc, $request_data->subprice, @@ -330,16 +330,16 @@ class ExpenseReports extends DolibarrApi $request_data->special_code, $request_data->array_options, $request_data->fk_unit - ); + ); - if ($updateRes > 0) { - $result = $this->get($id); - unset($result->line); - return $this->_cleanObjectDatas($result); - } - return false; + if ($updateRes > 0) { + $result = $this->get($id); + unset($result->line); + return $this->_cleanObjectDatas($result); + } + return false; } - */ + */ /** * Delete a line of given Expense Report @@ -352,19 +352,19 @@ class ExpenseReports extends DolibarrApi * @return int */ /* - function deleteLine($id, $lineid) + public function deleteLine($id, $lineid) { if(! DolibarrApiAccess::$user->rights->expensereport->creer) { - throw new RestException(401); - } + throw new RestException(401); + } $result = $this->expensereport->fetch($id); if( ! $result ) { throw new RestException(404, 'expensereport not found'); } - if( ! DolibarrApi::_checkAccessToResource('expensereport',$this->expensereport->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + if( ! DolibarrApi::_checkAccessToResource('expensereport',$this->expensereport->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } // TODO Check the lineid $lineid is a line of ojbect @@ -385,7 +385,7 @@ class ExpenseReports extends DolibarrApi * * @return int */ - function put($id, $request_data = null) + public function put($id, $request_data = null) { if(! DolibarrApiAccess::$user->rights->expensereport->creer) { throw new RestException(401); @@ -407,11 +407,11 @@ class ExpenseReports extends DolibarrApi if ($this->expensereport->update(DolibarrApiAccess::$user) > 0) { return $this->get($id); - } - else - { - throw new RestException(500, $this->expensereport->error); - } + } + else + { + throw new RestException(500, $this->expensereport->error); + } } /** @@ -421,19 +421,19 @@ class ExpenseReports extends DolibarrApi * * @return array */ - function delete($id) + public function delete($id) { if(! DolibarrApiAccess::$user->rights->expensereport->supprimer) { - throw new RestException(401); - } + throw new RestException(401); + } $result = $this->expensereport->fetch($id); if( ! $result ) { throw new RestException(404, 'Expense Report not found'); } - if( ! DolibarrApi::_checkAccessToResource('expensereport', $this->expensereport->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } + if( ! DolibarrApi::_checkAccessToResource('expensereport', $this->expensereport->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } if( ! $this->expensereport->delete(DolibarrApiAccess::$user)) { throw new RestException(500, 'Error when delete Expense Report : '.$this->expensereport->error); @@ -463,19 +463,19 @@ class ExpenseReports extends DolibarrApi * } */ /* - function validate($id, $idwarehouse=0) + public function validate($id, $idwarehouse=0) { if(! DolibarrApiAccess::$user->rights->expensereport->creer) { - throw new RestException(401); - } + throw new RestException(401); + } $result = $this->expensereport->fetch($id); if( ! $result ) { throw new RestException(404, 'expensereport not found'); } - if( ! DolibarrApi::_checkAccessToResource('expensereport',$this->expensereport->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } + if( ! DolibarrApi::_checkAccessToResource('expensereport',$this->expensereport->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } if( ! $this->expensereport->valid(DolibarrApiAccess::$user, $idwarehouse)) { throw new RestException(500, 'Error when validate expensereport'); @@ -495,17 +495,17 @@ class ExpenseReports extends DolibarrApi * @param object $object Object to clean * @return array Array of cleaned object properties */ - function _cleanObjectDatas($object) + private function _cleanObjectDatas($object) { - $object = parent::_cleanObjectDatas($object); + $object = parent::_cleanObjectDatas($object); - unset($object->barcode_type); - unset($object->barcode_type_code); - unset($object->barcode_type_label); - unset($object->barcode_type_coder); + unset($object->barcode_type); + unset($object->barcode_type_code); + unset($object->barcode_type_label); + unset($object->barcode_type_coder); - return $object; + return $object; } /** @@ -515,7 +515,7 @@ class ExpenseReports extends DolibarrApi * @return array * @throws RestException */ - function _validate($data) + private function _validate($data) { $expensereport = array(); foreach (ExpenseReports::$FIELDS as $field) { diff --git a/htdocs/expensereport/class/expensereport.class.php b/htdocs/expensereport/class/expensereport.class.php index 8dc0cbcdcf8..9df4596a8d6 100644 --- a/htdocs/expensereport/class/expensereport.class.php +++ b/htdocs/expensereport/class/expensereport.class.php @@ -44,62 +44,62 @@ class ExpenseReport extends CommonObject */ public $table_element='expensereport'; - var $table_element_line = 'expensereport_det'; - var $fk_element = 'fk_expensereport'; - var $picto = 'trip'; + public $table_element_line = 'expensereport_det'; + public $fk_element = 'fk_expensereport'; + public $picto = 'trip'; - var $lines=array(); + public $lines=array(); public $date_debut; public $date_fin; - var $status; - var $fk_statut; // -- 0=draft, 2=validated (attente approb), 4=canceled, 5=approved, 6=payed, 99=denied - var $fk_c_paiement; - var $paid; + public $status; + public $fk_statut; // -- 0=draft, 2=validated (attente approb), 4=canceled, 5=approved, 6=payed, 99=denied + public $fk_c_paiement; + public $paid; - var $user_author_infos; - var $user_validator_infos; + public $user_author_infos; + public $user_validator_infos; - var $fk_typepayment; - var $num_payment; - var $code_paiement; - var $code_statut; + public $fk_typepayment; + public $num_payment; + public $code_paiement; + public $code_statut; // ACTIONS // Create - var $date_create; - var $fk_user_author; // Note fk_user_author is not the 'author' but the guy the expense report is for. + public $date_create; + public $fk_user_author; // Note fk_user_author is not the 'author' but the guy the expense report is for. // Update - var $date_modif; - var $fk_user_modif; + public $date_modif; + public $fk_user_modif; // Refus - var $date_refuse; - var $detail_refuse; - var $fk_user_refuse; + public $date_refuse; + public $detail_refuse; + public $fk_user_refuse; // Annulation - var $date_cancel; - var $detail_cancel; - var $fk_user_cancel; + public $date_cancel; + public $detail_cancel; + public $fk_user_cancel; - var $fk_user_validator; // User that is defined to approve + public $fk_user_validator; // User that is defined to approve // Validation - var $date_valid; // User making validation - var $fk_user_valid; - var $user_valid_infos; + public $date_valid; // User making validation + public $fk_user_valid; + public $user_valid_infos; // Approve - var $date_approve; - var $fk_user_approve; // User that has approved + public $date_approve; + public $fk_user_approve; // User that has approved // Paiement - var $user_paid_infos; + public $user_paid_infos; /* END ACTIONS @@ -2484,17 +2484,17 @@ class ExpenseReportLine public $projet_ref; public $projet_title; - var $vatrate; - var $total_ht; - var $total_tva; - var $total_ttc; + public $vatrate; + public $total_ht; + public $total_tva; + public $total_ttc; /** * Constructor * * @param DoliDB $db Handlet database */ - function __construct($db) + public function __construct($db) { $this->db= $db; } @@ -2505,7 +2505,7 @@ class ExpenseReportLine * @param int $rowid Id of object to load * @return int <0 if KO, >0 if OK */ - function fetch($rowid) + public function fetch($rowid) { $sql = 'SELECT fde.rowid, fde.fk_expensereport, fde.fk_c_type_fees, fde.fk_c_exp_tax_cat, fde.fk_projet, fde.date,'; $sql.= ' fde.tva_tx as vatrate, fde.vat_src_code, fde.comments, fde.qty, fde.value_unit, fde.total_ht, fde.total_tva, fde.total_ttc,'; @@ -2557,7 +2557,7 @@ class ExpenseReportLine * @param bool $fromaddline false=keep default behavior, true=exclude the update_price() of parent object * @return int <0 if KO, >0 if OK */ - function insert($notrigger = 0, $fromaddline = false) + public function insert($notrigger = 0, $fromaddline = false) { global $langs,$user,$conf; @@ -2679,7 +2679,7 @@ class ExpenseReportLine * @param User $fuser User * @return int <0 if KO, >0 if OK */ - function update($fuser) + public function update($fuser) { global $fuser,$langs,$conf; @@ -2758,7 +2758,6 @@ class ExpenseReportLine } -// phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps /** * Retourne la liste deroulante des differents etats d'une note de frais. * Les valeurs de la liste sont les id de la table c_expensereport_statuts @@ -2771,7 +2770,6 @@ class ExpenseReportLine */ function select_expensereport_statut($selected = '', $htmlname = 'fk_statut', $useempty = 1, $useshortlabel = 0) { - // phpcs:enable global $db, $langs; $tmpep=new ExpenseReport($db); @@ -2796,7 +2794,6 @@ function select_expensereport_statut($selected = '', $htmlname = 'fk_statut', $u print ''; } -// phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps /** * Return list of types of notes with select value = id * @@ -2808,7 +2805,6 @@ function select_expensereport_statut($selected = '', $htmlname = 'fk_statut', $u */ function select_type_fees_id($selected = '', $htmlname = 'type', $showempty = 0, $active = 1) { - // phpcs:enable global $db,$langs,$user; $langs->load("trips"); diff --git a/htdocs/expensereport/class/expensereportstats.class.php b/htdocs/expensereport/class/expensereportstats.class.php index 0eec447d997..082e3ce016e 100644 --- a/htdocs/expensereport/class/expensereportstats.class.php +++ b/htdocs/expensereport/class/expensereportstats.class.php @@ -50,7 +50,7 @@ class ExpenseReportStats extends Stats * @param int $userid Id user for filter * @return void */ - function __construct($db, $socid = 0, $userid = 0) + public function __construct($db, $socid = 0, $userid = 0) { global $conf, $user; @@ -89,7 +89,7 @@ class ExpenseReportStats extends Stats * * @return array Array of values */ - function getNbByYear() + public function getNbByYear() { $sql = "SELECT YEAR(".$this->db->ifsql('e.date_valid IS NULL', 'e.date_create', 'e.date_valid').") as dm, count(*)"; $sql.= " FROM ".$this->from; @@ -107,7 +107,7 @@ class ExpenseReportStats extends Stats * @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 of values */ - function getNbByMonth($year, $format = 0) + public function getNbByMonth($year, $format = 0) { $sql = "SELECT MONTH(".$this->db->ifsql('e.date_valid IS NULL', 'e.date_create', 'e.date_valid').") as dm, count(*)"; $sql.= " FROM ".$this->from; @@ -129,7 +129,7 @@ class ExpenseReportStats extends Stats * @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 of values */ - function getAmountByMonth($year, $format = 0) + public function getAmountByMonth($year, $format = 0) { $sql = "SELECT date_format(".$this->db->ifsql('e.date_valid IS NULL', 'e.date_create', 'e.date_valid').",'%m') as dm, sum(".$this->field.")"; $sql.= " FROM ".$this->from; @@ -149,7 +149,7 @@ class ExpenseReportStats extends Stats * @param int $year Year to scan * @return array Array of values */ - function getAverageByMonth($year) + public function getAverageByMonth($year) { $sql = "SELECT date_format(".$this->db->ifsql('e.date_valid IS NULL', 'e.date_create', 'e.date_valid').",'%m') as dm, avg(".$this->field.")"; $sql.= " FROM ".$this->from; @@ -166,7 +166,7 @@ class ExpenseReportStats extends Stats * * @return array Array of values */ - function getAllByYear() + public function getAllByYear() { $sql = "SELECT date_format(".$this->db->ifsql('e.date_valid IS NULL', 'e.date_create', 'e.date_valid').",'%Y') as year, count(*) as nb, sum(".$this->field.") as total, avg(".$this->field.") as avg"; $sql.= " FROM ".$this->from; @@ -174,6 +174,6 @@ class ExpenseReportStats extends Stats $sql.= " GROUP BY year"; $sql.= $this->db->order('year', 'DESC'); - return $this->_getAllByYear($sql); - } + return $this->_getAllByYear($sql); + } } diff --git a/htdocs/expensereport/class/paymentexpensereport.class.php b/htdocs/expensereport/class/paymentexpensereport.class.php index 655c148069e..f731638ea1d 100644 --- a/htdocs/expensereport/class/paymentexpensereport.class.php +++ b/htdocs/expensereport/class/paymentexpensereport.class.php @@ -92,7 +92,7 @@ class PaymentExpenseReport extends CommonObject * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; } @@ -104,7 +104,7 @@ class PaymentExpenseReport extends CommonObject * @param User $user User making payment * @return int <0 if KO, id of payment if OK */ - function create($user) + public function create($user) { global $conf, $langs; @@ -113,8 +113,7 @@ class PaymentExpenseReport extends CommonObject $now=dol_now(); // Validate parameters - if (! $this->datepaid) - { + if (! $this->datepaid) { $this->error='ErrorBadValueForParameterCreatePaymentExpenseReport'; return -1; } @@ -184,10 +183,10 @@ class PaymentExpenseReport extends CommonObject /** * Load object in memory from database * - * @param int $id Id object + * @param int $id Id object * @return int <0 if KO, >0 if OK */ - function fetch($id) + public function fetch($id) { global $langs; $sql = "SELECT"; @@ -258,7 +257,7 @@ class PaymentExpenseReport extends CommonObject * @param int $notrigger 0=launch triggers after, 1=disable triggers * @return int <0 if KO, >0 if OK */ - function update($user = null, $notrigger = 0) + public function update($user = null, $notrigger = 0) { // phpcs:enable global $conf, $langs; @@ -266,7 +265,7 @@ class PaymentExpenseReport extends CommonObject // Clean parameters - if (isset($this->fk_expensereport)) $this->fk_expensereport=trim($this->fk_expensereport); + if (isset($this->fk_expensereport)) $this->fk_expensereport=trim($this->fk_expensereport); if (isset($this->amount)) $this->amount=trim($this->amount); if (isset($this->fk_typepayment)) $this->fk_typepayment=trim($this->fk_typepayment); if (isset($this->num_payment)) $this->num_payment=trim($this->num_payment); @@ -341,11 +340,11 @@ class PaymentExpenseReport extends CommonObject /** * Delete object in database * - * @param User $user User that delete + * @param User $user User that delete * @param int $notrigger 0=launch triggers after, 1=disable triggers * @return int <0 if KO, >0 if OK */ - function delete($user, $notrigger = 0) + public function delete($user, $notrigger = 0) { // phpcs:enable global $conf, $langs; @@ -370,13 +369,16 @@ class PaymentExpenseReport extends CommonObject dol_syslog(get_class($this)."::delete", LOG_DEBUG); $resql = $this->db->query($sql); - if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } + if (! $resql) { + $error++; + $this->errors[]="Error ".$this->db->lasterror(); + } } - if (! $error) - { - if (! $notrigger) - { + //if (! $error) + //{ + // if (! $notrigger) + // { // Uncomment this and change MYOBJECT to your own tag if you // want this action call a trigger. @@ -386,8 +388,8 @@ class PaymentExpenseReport extends CommonObject //$result=$interface->run_triggers('MYOBJECT_DELETE',$this,$user,$langs,$conf); //if ($result < 0) { $error++; $this->errors=$interface->errors; } //// End call triggers - } - } + // } + //} // Commit or rollback if ($error) @@ -415,7 +417,7 @@ class PaymentExpenseReport extends CommonObject * @param int $fromid Id of object to clone * @return int New id of clone */ - function createFromClone($fromid) + public function createFromClone($fromid) { global $user,$langs; @@ -444,11 +446,6 @@ class PaymentExpenseReport extends CommonObject $error++; } - if (! $error) - { - - } - unset($object->context['createfromclone']); // End @@ -471,12 +468,12 @@ class PaymentExpenseReport extends CommonObject * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long * @return string Libelle */ - function getLibStatut($mode = 0) + public function getLibStatut($mode = 0) { return ''; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Renvoi le libelle d'un statut donne * @@ -484,13 +481,13 @@ class PaymentExpenseReport 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 * @return string Libelle du statut */ - function LibStatut($statut, $mode = 0) - { + public function LibStatut($statut, $mode = 0) + { // phpcs:enable - global $langs; + global $langs; - return ''; - } + return ''; + } /** @@ -500,7 +497,7 @@ class PaymentExpenseReport extends CommonObject * * @return void */ - function initAsSpecimen() + public function initAsSpecimen() { $this->id=0; @@ -530,7 +527,7 @@ class PaymentExpenseReport extends CommonObject * @param string $emetteur_banque Name of bank * @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 $langs,$conf; @@ -631,14 +628,14 @@ class PaymentExpenseReport extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Update link between the expense report payment and the generated line in llx_bank * * @param int $id_bank Id if bank * @return int >0 if OK, <=0 if KO */ - function update_fk_bank($id_bank) + public function update_fk_bank($id_bank) { // phpcs:enable $sql = "UPDATE ".MAIN_DB_PREFIX."payment_expensereport SET fk_bank = ".$id_bank." WHERE rowid = ".$this->id; @@ -659,11 +656,11 @@ class PaymentExpenseReport extends CommonObject /** * Return clicable name (with picto eventually) * - * @param int $withpicto 0=No picto, 1=Include picto into link, 2=Only picto - * @param int $maxlen Longueur max libelle - * @return string Chaine avec URL + * @param int $withpicto 0=No picto, 1=Include picto into link, 2=Only picto + * @param int $maxlen Longueur max libelle + * @return string Chaine avec URL */ - function getNomUrl($withpicto = 0, $maxlen = 0) + public function getNomUrl($withpicto = 0, $maxlen = 0) { global $langs; @@ -691,8 +688,8 @@ class PaymentExpenseReport extends CommonObject * @param int $id Payment id * @return void */ - function info($id) - { + public function info($id) + { $sql = 'SELECT e.rowid, e.datec, e.fk_user_creat, e.fk_user_modif, e.tms'; $sql.= ' FROM '.MAIN_DB_PREFIX.'payment_expensereport as e'; $sql.= ' WHERE e.rowid = '.$id; @@ -718,7 +715,7 @@ class PaymentExpenseReport extends CommonObject $muser->fetch($obj->fk_user_modif); $this->user_modification = $muser; } - $this->date_creation = $this->db->jdate($obj->datec); + $this->date_creation = $this->db->jdate($obj->datec); $this->date_modification = $this->db->jdate($obj->tms); } $this->db->free($result); @@ -727,5 +724,5 @@ class PaymentExpenseReport extends CommonObject { dol_print_error($this->db); } - } + } } diff --git a/htdocs/exports/class/export.class.php b/htdocs/exports/class/export.class.php index a964f5f373a..5b7205247ac 100644 --- a/htdocs/exports/class/export.class.php +++ b/htdocs/exports/class/export.class.php @@ -35,28 +35,28 @@ class Export */ public $db; - var $array_export_code=array(); // Tableau de "idmodule_numlot" - var $array_export_module=array(); // Tableau de "nom de modules" - var $array_export_label=array(); // Tableau de "libelle de lots" - var $array_export_sql_start=array(); // Tableau des "requetes sql" - var $array_export_sql_end=array(); // Tableau des "requetes sql" - var $array_export_sql_order=array(); // Tableau des "requetes sql" + public $array_export_code=array(); // Tableau de "idmodule_numlot" + public $array_export_module=array(); // Tableau de "nom de modules" + public $array_export_label=array(); // Tableau de "libelle de lots" + public $array_export_sql_start=array(); // Tableau des "requetes sql" + public $array_export_sql_end=array(); // Tableau des "requetes sql" + public $array_export_sql_order=array(); // Tableau des "requetes sql" - var $array_export_fields=array(); // Tableau des listes de champ+libelle a exporter - var $array_export_TypeFields=array(); // Tableau des listes de champ+Type de filtre - var $array_export_FilterValue=array(); // Tableau des listes de champ+Valeur a filtrer - var $array_export_entities=array(); // Tableau des listes de champ+alias a exporter - var $array_export_dependencies=array(); // array of list of entities that must take care of the DISTINCT if a field is added into export - var $array_export_special=array(); // Tableau des operations speciales sur champ - var $array_export_examplevalues=array(); // array with examples + public $array_export_fields=array(); // Tableau des listes de champ+libelle a exporter + public $array_export_TypeFields=array(); // Tableau des listes de champ+Type de filtre + public $array_export_FilterValue=array(); // Tableau des listes de champ+Valeur a filtrer + public $array_export_entities=array(); // Tableau des listes de champ+alias a exporter + public $array_export_dependencies=array(); // array of list of entities that must take care of the DISTINCT if a field is added into export + public $array_export_special=array(); // Tableau des operations speciales sur champ + public $array_export_examplevalues=array(); // array with examples - // To store export modules - var $hexa; - var $hexafiltervalue; - var $datatoexport; - var $model_name; + // To store export modules + public $hexa; + public $hexafiltervalue; + public $datatoexport; + public $model_name; - var $sqlusedforexport; + public $sqlusedforexport; /** @@ -64,13 +64,13 @@ class Export * * @param DoliDB $db Database handler */ - function __construct($db) - { - $this->db=$db; - } + public function __construct($db) + { + $this->db=$db; + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load an exportable dataset * @@ -78,12 +78,12 @@ class Export * @param string $filter Load a particular dataset only * @return int <0 if KO, >0 if OK */ - function load_arrays($user, $filter = '') - { + public function load_arrays($user, $filter = '') + { // phpcs:enable - global $langs,$conf,$mysoc; + global $langs,$conf,$mysoc; - dol_syslog(get_class($this)."::load_arrays user=".$user->id." filter=".$filter); + dol_syslog(get_class($this)."::load_arrays user=".$user->id." filter=".$filter); $i=0; @@ -209,7 +209,7 @@ class Export } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Build the sql export request. * Arrays this->array_export_xxx are already loaded for required datatoexport @@ -219,8 +219,8 @@ class Export * @param array $array_filterValue Filter records on array of value for fields * @return string SQL String. Example "select s.rowid as r_rowid, s.status as s_status from ..." */ - function build_sql($indice, $array_selected, $array_filterValue) - { + public function build_sql($indice, $array_selected, $array_filterValue) + { // phpcs:enable // Build the sql request $sql=$this->array_export_sql_start[$indice]; @@ -273,7 +273,7 @@ class Export return $sql; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Build the conditionnal string from filter the query * @@ -282,8 +282,8 @@ class Export * @param string $ValueField Value of the field for filter. Must not be '' * @return string sql string of then field ex : "field='xxx'>" */ - function build_filterQuery($TypeField, $NameField, $ValueField) - { + public function build_filterQuery($TypeField, $NameField, $ValueField) + { // phpcs:enable //print $TypeField." ".$NameField." ".$ValueField; $InfoFieldList = explode(":", $TypeField); @@ -352,21 +352,21 @@ class Export } /** - * conditionDate + * conditionDate * * @param string $Field Field operand 1 * @param string $Value Value operand 2 * @param string $Sens Comparison operator * @return string */ - function conditionDate($Field, $Value, $Sens) - { + public function conditionDate($Field, $Value, $Sens) + { // TODO date_format is forbidden, not performant and not portable. Use instead BETWEEN if (strlen($Value)==4) $Condition=" date_format(".$Field.",'%Y') ".$Sens." '".$Value."'"; elseif (strlen($Value)==6) $Condition=" date_format(".$Field.",'%Y%m') ".$Sens." '".$Value."'"; else $Condition=" date_format(".$Field.",'%Y%m%d') ".$Sens." ".$Value; return $Condition; - } + } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps /** @@ -377,8 +377,8 @@ class Export * @param string $ValueField Initial value of the field to filter * @return string html string of the input field ex : "" */ - function build_filterField($TypeField, $NameField, $ValueField) - { + public function build_filterField($TypeField, $NameField, $ValueField) + { // phpcs:enable global $conf,$langs; @@ -488,15 +488,15 @@ class Export } return $szFilterField; - } + } - /** - * Build an input field used to filter the query + /** + * Build an input field used to filter the query * * @param string $TypeField Type of Field to filter * @return string html string of the input field ex : "" */ - function genDocFilter($TypeField) + public function genDocFilter($TypeField) { global $langs; @@ -523,7 +523,7 @@ class Export return $szMsg; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Build export file. * File is built into directory $conf->export->dir_temp.'/'.$user->id @@ -537,8 +537,8 @@ class Export * @param string $sqlquery If set, transmit the sql request for select (otherwise, sql request is generated from arrays) * @return int <0 if KO, >0 if OK */ - function build_file($user, $model, $datatoexport, $array_selected, $array_filterValue, $sqlquery = '') - { + public function build_file($user, $model, $datatoexport, $array_selected, $array_filterValue, $sqlquery = '') + { // phpcs:enable global $conf,$langs; @@ -698,7 +698,7 @@ class Export * @param User $user Object user that save * @return int <0 if KO, >0 if OK */ - function create($user) + public function create($user) { global $conf; @@ -741,11 +741,11 @@ class Export /** * Load an export profil from database * - * @param int $id Id of profil to load - * @return int <0 if KO, >0 if OK + * @param int $id Id of profil to load + * @return int <0 if KO, >0 if OK */ - function fetch($id) - { + public function fetch($id) + { $sql = 'SELECT em.rowid, em.label, em.type, em.field, em.filter'; $sql.= ' FROM '.MAIN_DB_PREFIX.'export_model as em'; $sql.= ' WHERE em.rowid = '.$id; @@ -757,12 +757,12 @@ class Export $obj = $this->db->fetch_object($result); if ($obj) { - $this->id = $obj->rowid; - $this->model_name = $obj->label; - $this->datatoexport = $obj->type; + $this->id = $obj->rowid; + $this->model_name = $obj->label; + $this->datatoexport = $obj->type; - $this->hexa = $obj->field; - $this->hexafiltervalue = $obj->filter; + $this->hexa = $obj->field; + $this->hexafiltervalue = $obj->filter; return 1; } @@ -787,7 +787,7 @@ class Export * @param int $notrigger 0=launch triggers after, 1=disable triggers * @return int <0 if KO, >0 if OK */ - function delete($user, $notrigger = 0) + public function delete($user, $notrigger = 0) { global $conf, $langs; $error=0; @@ -835,15 +835,15 @@ class Export } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Output list all export models * TODO Move this into a class htmlxxx.class.php * * @return void */ - function list_export_model() - { + public function list_export_model() + { // phpcs:enable global $conf, $langs; @@ -886,9 +886,8 @@ class Export $i++; } - } - else { - dol_print_error($this->db); - } - } + } else { + dol_print_error($this->db); + } + } } diff --git a/htdocs/fichinter/class/api_interventions.class.php b/htdocs/fichinter/class/api_interventions.class.php index 26173db12af..6ceb56d1a84 100644 --- a/htdocs/fichinter/class/api_interventions.class.php +++ b/htdocs/fichinter/class/api_interventions.class.php @@ -55,10 +55,10 @@ class Interventions extends DolibarrApi /** * Constructor */ - function __construct() + public function __construct() { - global $db, $conf; - $this->db = $db; + global $db, $conf; + $this->db = $db; $this->fichinter = new Fichinter($this->db); } @@ -72,23 +72,23 @@ class Interventions extends DolibarrApi * * @throws RestException */ - function get($id) + public function get($id) { - if(! DolibarrApiAccess::$user->rights->ficheinter->lire) { - throw new RestException(401); - } + if(! DolibarrApiAccess::$user->rights->ficheinter->lire) { + throw new RestException(401); + } - $result = $this->fichinter->fetch($id); - if( ! $result ) { - throw new RestException(404, 'Intervention report not found'); - } + $result = $this->fichinter->fetch($id); + if( ! $result ) { + throw new RestException(404, 'Intervention report not found'); + } - if( ! DolibarrApi::_checkAccessToResource('fichinter', $this->fichinter->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } + if( ! DolibarrApi::_checkAccessToResource('fichinter', $this->fichinter->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } - $this->fichinter->fetchObjectLinked(); - return $this->_cleanObjectDatas($this->fichinter); + $this->fichinter->fetchObjectLinked(); + return $this->_cleanObjectDatas($this->fichinter); } /** @@ -106,7 +106,7 @@ class Interventions extends DolibarrApi * * @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; @@ -141,7 +141,7 @@ class Interventions extends DolibarrApi { throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); } - $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; + $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; $sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; } @@ -169,7 +169,7 @@ class Interventions extends DolibarrApi $obj = $db->fetch_object($result); $fichinter_static = new Fichinter($db); if($fichinter_static->fetch($obj->rowid)) { - $obj_ret[] = $this->_cleanObjectDatas($fichinter_static); + $obj_ret[] = $this->_cleanObjectDatas($fichinter_static); } $i++; } @@ -180,7 +180,7 @@ class Interventions extends DolibarrApi if( ! count($obj_ret)) { throw new RestException(404, 'No finchinter found'); } - return $obj_ret; + return $obj_ret; } /** @@ -189,7 +189,7 @@ class Interventions extends DolibarrApi * @param array $request_data Request data * @return int ID of intervention */ - function post($request_data = null) + public function post($request_data = null) { if(! DolibarrApiAccess::$user->rights->ficheinter->creer) { throw new RestException(401, "Insuffisant rights"); @@ -218,28 +218,28 @@ class Interventions extends DolibarrApi * @return int */ /* TODO - function getLines($id) + public function getLines($id) { - if(! DolibarrApiAccess::$user->rights->ficheinter->lire) { - throw new RestException(401); - } + if(! DolibarrApiAccess::$user->rights->ficheinter->lire) { + throw new RestException(401); + } - $result = $this->fichinter->fetch($id); - if( ! $result ) { - throw new RestException(404, 'Intervention not found'); - } + $result = $this->fichinter->fetch($id); + if( ! $result ) { + throw new RestException(404, 'Intervention not found'); + } - if( ! DolibarrApi::_checkAccessToResource('fichinter',$this->fichinter->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } - $this->fichinter->getLinesArray(); - $result = array(); - foreach ($this->fichinter->lines as $line) { - array_push($result,$this->_cleanObjectDatas($line)); - } - return $result; + if( ! DolibarrApi::_checkAccessToResource('fichinter',$this->fichinter->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } + $this->fichinter->getLinesArray(); + $result = array(); + foreach ($this->fichinter->lines as $line) { + array_push($result,$this->_cleanObjectDatas($line)); + } + return $result; } - */ + */ /** * Add a line to given intervention @@ -251,7 +251,7 @@ class Interventions extends DolibarrApi * * @return int */ - function postLine($id, $request_data = null) + public function postLine($id, $request_data = null) { if(! DolibarrApiAccess::$user->rights->ficheinter->creer) { throw new RestException(401, "Insuffisant rights"); @@ -292,30 +292,30 @@ class Interventions extends DolibarrApi * @param int $id Order ID * @return array */ - function delete($id) + public function delete($id) { - if(! DolibarrApiAccess::$user->rights->ficheinter->supprimer) { - throw new RestException(401); - } - $result = $this->fichinter->fetch($id); - if( ! $result ) { - throw new RestException(404, 'Intervention not found'); - } + if(! DolibarrApiAccess::$user->rights->ficheinter->supprimer) { + throw new RestException(401); + } + $result = $this->fichinter->fetch($id); + if( ! $result ) { + throw new RestException(404, 'Intervention not found'); + } - if( ! DolibarrApi::_checkAccessToResource('commande', $this->fichinter->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } + if( ! DolibarrApi::_checkAccessToResource('commande', $this->fichinter->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } - if( ! $this->fichinter->delete(DolibarrApiAccess::$user)) { - throw new RestException(500, 'Error when delete intervention : '.$this->fichinter->error); - } + if( ! $this->fichinter->delete(DolibarrApiAccess::$user)) { + throw new RestException(500, 'Error when delete intervention : '.$this->fichinter->error); + } - return array( - 'success' => array( - 'code' => 200, - 'message' => 'Intervention deleted' - ) - ); + return array( + 'success' => array( + 'code' => 200, + 'message' => 'Intervention deleted' + ) + ); } /** @@ -333,7 +333,7 @@ class Interventions extends DolibarrApi * * @return array */ - function validate($id, $notrigger = 0) + public function validate($id, $notrigger = 0) { if(! DolibarrApiAccess::$user->rights->ficheinter->creer) { throw new RestException(401, "Insuffisant rights"); @@ -369,7 +369,7 @@ class Interventions extends DolibarrApi * * @return array */ - function closeFichinter($id) + public function closeFichinter($id) { if(! DolibarrApiAccess::$user->rights->ficheinter->creer) { @@ -406,7 +406,7 @@ class Interventions extends DolibarrApi * * @throws RestException */ - function _validate($data) + private function _validate($data) { $fichinter = array(); foreach (Interventions::$FIELDS as $field) { @@ -424,16 +424,16 @@ class Interventions extends DolibarrApi * @param object $object Object to clean * @return array Array of cleaned object properties */ - function _cleanObjectDatas($object) + private function _cleanObjectDatas($object) { - $object = parent::_cleanObjectDatas($object); + $object = parent::_cleanObjectDatas($object); - unset($object->statuts_short); - unset($object->statuts_logo); - unset($object->statuts); + unset($object->statuts_short); + unset($object->statuts_logo); + unset($object->statuts); - return $object; + return $object; } /** @@ -444,7 +444,7 @@ class Interventions extends DolibarrApi * * @throws RestException */ - function _validateLine($data) + private function _validateLine($data) { $fichinter = array(); foreach (Interventions::$FIELDSLINE as $field) { diff --git a/htdocs/fichinter/class/fichinter.class.php b/htdocs/fichinter/class/fichinter.class.php index 97ecffacf95..6db992b4e22 100644 --- a/htdocs/fichinter/class/fichinter.class.php +++ b/htdocs/fichinter/class/fichinter.class.php @@ -122,7 +122,7 @@ class Fichinter extends CommonObject * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; @@ -135,7 +135,7 @@ class Fichinter extends CommonObject * * @return int <0 if KO, >0 if OK */ - function load_state_board() + public function load_state_board() { // phpcs:enable global $user; @@ -179,7 +179,7 @@ class Fichinter extends CommonObject * @param int $notrigger Disable all triggers * @return int <0 if KO, >0 if OK */ - function create($user, $notrigger = 0) + public function create($user, $notrigger = 0) { global $conf, $langs; @@ -313,7 +313,7 @@ class Fichinter extends CommonObject * @param int $notrigger Disable all triggers * @return int <0 if KO, >0 if OK */ - function update($user, $notrigger = 0) + public function update($user, $notrigger = 0) { if (! is_numeric($this->duration)) { $this->duration = 0; @@ -373,7 +373,7 @@ class Fichinter extends CommonObject * @param string $ref Ref of intervention * @return int <0 if KO, >0 if OK */ - function fetch($rowid, $ref = '') + public function fetch($rowid, $ref = '') { $sql = "SELECT f.rowid, f.ref, f.description, f.fk_soc, f.fk_statut,"; $sql.= " f.datec, f.dateo, f.datee, f.datet, f.fk_user_author,"; @@ -407,15 +407,15 @@ class Fichinter extends CommonObject $this->datet = $this->db->jdate($obj->datet); $this->datev = $this->db->jdate($obj->datev); $this->datem = $this->db->jdate($obj->datem); - $this->fk_project = $obj->fk_projet; - $this->note_public = $obj->note_public; + $this->fk_project = $obj->fk_projet; + $this->note_public = $obj->note_public; $this->note_private = $obj->note_private; - $this->modelpdf = $obj->model_pdf; - $this->fk_contrat = $obj->fk_contrat; + $this->modelpdf = $obj->model_pdf; + $this->fk_contrat = $obj->fk_contrat; - $this->user_creation= $obj->fk_user_author; + $this->user_creation = $obj->fk_user_author; - $this->extraparams = (array) json_decode($obj->extraparams, true); + $this->extraparams = (array) json_decode($obj->extraparams, true); if ($this->statut == 0) $this->brouillon = 1; @@ -447,7 +447,7 @@ class Fichinter extends CommonObject * @param User $user User that set draft * @return int <0 if KO, >0 if OK */ - function setDraft($user) + public function setDraft($user) { global $langs, $conf; @@ -483,7 +483,7 @@ class Fichinter extends CommonObject * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int <0 if KO, >0 if OK */ - function setValid($user, $notrigger = 0) + public function setValid($user, $notrigger = 0) { global $conf; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; @@ -595,7 +595,7 @@ class Fichinter extends CommonObject * * @return float Amount */ - function getAmount() + public function getAmount() { global $db; @@ -653,12 +653,12 @@ class Fichinter 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 * @return string Label */ - function getLibStatut($mode = 0) + public function getLibStatut($mode = 0) { return $this->LibStatut($this->statut, $mode); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Returns the label of a statut * @@ -666,7 +666,7 @@ class Fichinter 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 * @return string Label */ - function LibStatut($statut, $mode = 0) + public function LibStatut($statut, $mode = 0) { // phpcs:enable // Init/load array of translation of status @@ -716,7 +716,7 @@ class Fichinter extends CommonObject * @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 */ - function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $save_lastsearch_value = -1) + public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $save_lastsearch_value = -1) { global $conf, $langs, $hookmanager; @@ -782,7 +782,7 @@ class Fichinter extends CommonObject * @param Societe $soc Thirdparty object * @return string Free reference for intervention */ - function getNextNumRef($soc) + public function getNextNumRef($soc) { global $conf, $db, $langs; $langs->load("interventions"); @@ -838,7 +838,7 @@ class Fichinter extends CommonObject * @param int $id Id of object * @return void */ - function info($id) + public function info($id) { global $conf; @@ -897,7 +897,7 @@ class Fichinter extends CommonObject * @param int $notrigger Disable trigger * @return int <0 if KO, >0 if OK */ - function delete($user, $notrigger = 0) + public function delete($user, $notrigger = 0) { global $conf,$langs; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; @@ -1010,7 +1010,7 @@ class Fichinter extends CommonObject * @param date $date_delivery date of delivery * @return int <0 if ko, >0 if ok */ - function set_date_delivery($user, $date_delivery) + public function set_date_delivery($user, $date_delivery) { // phpcs:enable global $conf; @@ -1036,7 +1036,7 @@ class Fichinter extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Define the label of the intervention * @@ -1044,7 +1044,7 @@ class Fichinter extends CommonObject * @param string $description description * @return int <0 if KO, >0 if OK */ - function set_description($user, $description) + public function set_description($user, $description) { // phpcs:enable global $conf; @@ -1071,7 +1071,7 @@ class Fichinter extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Link intervention to a contract * @@ -1079,8 +1079,8 @@ class Fichinter extends CommonObject * @param int $contractid Description * @return int <0 if ko, >0 if ok */ - function set_contrat($user, $contractid) - { + public function set_contrat($user, $contractid) + { // phpcs:enable global $conf; @@ -1112,7 +1112,7 @@ class Fichinter extends CommonObject * @param int $socid Id of thirdparty * @return int New id of clone */ - function createFromClone($socid = 0) + public function createFromClone($socid = 0) { global $user,$hookmanager; @@ -1205,7 +1205,7 @@ class Fichinter extends CommonObject * @param array $array_options Array option * @return int >0 if ok, <0 if ko */ - function addline($user, $fichinterid, $desc, $date_intervention, $duration, $array_options = '') + public function addline($user, $fichinterid, $desc, $date_intervention, $duration, $array_options = '') { dol_syslog(get_class($this)."::addline $fichinterid, $desc, $date_intervention, $duration"); @@ -1249,7 +1249,7 @@ class Fichinter extends CommonObject * * @return void */ - function initAsSpecimen() + public function initAsSpecimen() { global $user,$langs,$conf; @@ -1280,14 +1280,14 @@ class Fichinter extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load array lines ->lines * * @return int <0 if KO, >0 if OK */ - function fetch_lines() - { + public function fetch_lines() + { // phpcs:enable $this->lines = array(); @@ -1395,7 +1395,7 @@ class FichinterLigne extends CommonObjectLine * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; } @@ -1406,7 +1406,7 @@ class FichinterLigne extends CommonObjectLine * @param int $rowid Line id * @return int <0 if KO, >0 if OK */ - function fetch($rowid) + public function fetch($rowid) { $sql = 'SELECT ft.rowid, ft.fk_fichinter, ft.description, ft.duree, ft.rang,'; $sql.= ' ft.date as datei'; @@ -1443,7 +1443,7 @@ class FichinterLigne extends CommonObjectLine * @param int $notrigger Disable all triggers * @return int <0 if ko, >0 if ok */ - function insert($user, $notrigger = 0) + public function insert($user, $notrigger = 0) { global $langs,$conf; @@ -1539,7 +1539,7 @@ class FichinterLigne extends CommonObjectLine * @param int $notrigger Disable all triggers * @return int <0 if ko, >0 if ok */ - function update($user, $notrigger = 0) + public function update($user, $notrigger = 0) { global $langs,$conf; @@ -1600,13 +1600,13 @@ class FichinterLigne extends CommonObjectLine } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Update total duration into llx_fichinter * * @return int <0 si ko, >0 si ok */ - function update_total() + public function update_total() { // phpcs:enable global $conf; @@ -1660,7 +1660,7 @@ class FichinterLigne extends CommonObjectLine * @param int $notrigger Disable all triggers * @return int >0 if ok, <0 if ko */ - function deleteline($user, $notrigger = 0) + public function deleteline($user, $notrigger = 0) { global $langs,$conf; diff --git a/htdocs/fichinter/class/fichinterstats.class.php b/htdocs/fichinter/class/fichinterstats.class.php index 80d7e6107c8..7112f6cdf77 100644 --- a/htdocs/fichinter/class/fichinterstats.class.php +++ b/htdocs/fichinter/class/fichinterstats.class.php @@ -33,181 +33,181 @@ include_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php'; */ class FichinterStats extends Stats { - /** - * @var string Name of table without prefix where object is stored - */ - public $table_element; + /** + * @var string Name of table without prefix where object is stored + */ + public $table_element; - var $socid; - var $userid; + public $socid; + public $userid; - var $from; - var $field; - var $where; + public $from; + public $field; + public $where; - /** - * Constructor - * - * @param DoliDB $db Database handler - * @param int $socid Id third party for filter. This value must be forced during the new to external user company if user is an external user. - * @param string $mode Option ('customer', 'supplier') - * @param int $userid Id user for filter (creation user) - */ - function __construct($db, $socid, $mode, $userid = 0) - { - global $user, $conf; + /** + * Constructor + * + * @param DoliDB $db Database handler + * @param int $socid Id third party for filter. This value must be forced during the new to external user company if user is an external user. + * @param string $mode Option ('customer', 'supplier') + * @param int $userid Id user for filter (creation user) + */ + public function __construct($db, $socid, $mode, $userid = 0) + { + global $user, $conf; - $this->db = $db; + $this->db = $db; - $this->socid = ($socid > 0 ? $socid : 0); + $this->socid = ($socid > 0 ? $socid : 0); $this->userid = $userid; - $this->cachefilesuffix = $mode; + $this->cachefilesuffix = $mode; - $this->where.= " c.entity = ".$conf->entity; - if ($mode == 'customer') - { - $object=new Fichinter($this->db); - $this->from = MAIN_DB_PREFIX.$object->table_element." as c"; - $this->from_line = MAIN_DB_PREFIX.$object->table_element_line." as tl"; - $this->field='0'; - $this->field_line='0'; - //$this->where.= " AND c.fk_statut > 0"; // Not draft and not cancelled - } - if (!$user->rights->societe->client->voir && !$this->socid) $this->where .= " AND c.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id; - if ($this->socid) - { - $this->where.=" AND c.fk_soc = ".$this->socid; - } + $this->where.= " c.entity = ".$conf->entity; + if ($mode == 'customer') + { + $object=new Fichinter($this->db); + $this->from = MAIN_DB_PREFIX.$object->table_element." as c"; + $this->from_line = MAIN_DB_PREFIX.$object->table_element_line." as tl"; + $this->field='0'; + $this->field_line='0'; + //$this->where.= " AND c.fk_statut > 0"; // Not draft and not cancelled + } + if (!$user->rights->societe->client->voir && !$this->socid) $this->where .= " AND c.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id; + if ($this->socid) + { + $this->where.=" AND c.fk_soc = ".$this->socid; + } if ($this->userid > 0) $this->where.=' AND c.fk_user_author = '.$this->userid; - } + } - /** - * Return intervention number by month for a year - * - * @param int $year Year to scan + /** + * Return intervention number by month for a year + * + * @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 - * @return array Array with number by month - */ - function getNbByMonth($year, $format = 0) - { - global $user; + * @return array Array with number by month + */ + public function getNbByMonth($year, $format = 0) + { + global $user; - $sql = "SELECT date_format(c.date_valid,'%m') as dm, COUNT(*) as nb"; - $sql.= " FROM ".$this->from; - if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE c.date_valid BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'"; - $sql.= " AND ".$this->where; - $sql.= " GROUP BY dm"; + $sql = "SELECT date_format(c.date_valid,'%m') as dm, COUNT(*) as nb"; + $sql.= " FROM ".$this->from; + if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql.= " WHERE c.date_valid BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'"; + $sql.= " AND ".$this->where; + $sql.= " GROUP BY dm"; $sql.= $this->db->order('dm', 'DESC'); - $res=$this->_getNbByMonth($year, $sql, $format); - return $res; - } + $res=$this->_getNbByMonth($year, $sql, $format); + return $res; + } - /** - * Return interventions number per year - * - * @return array Array with number by year - * - */ - function getNbByYear() - { - global $user; + /** + * Return interventions number per year + * + * @return array Array with number by year + * + */ + public function getNbByYear() + { + global $user; - $sql = "SELECT date_format(c.date_valid,'%Y') as dm, COUNT(*) as nb, 0"; - $sql.= " FROM ".$this->from; - if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE ".$this->where; - $sql.= " GROUP BY dm"; + $sql = "SELECT date_format(c.date_valid,'%Y') as dm, COUNT(*) as nb, 0"; + $sql.= " FROM ".$this->from; + if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql.= " WHERE ".$this->where; + $sql.= " GROUP BY dm"; $sql.= $this->db->order('dm', 'DESC'); - return $this->_getNbByYear($sql); - } + return $this->_getNbByYear($sql); + } - /** - * Return the intervention amount by month for a year - * - * @param int $year Year to scan + /** + * Return the intervention amount by month for a year + * + * @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 - * @return array Array with amount by month - */ - function getAmountByMonth($year, $format = 0) - { - global $user; + * @return array Array with amount by month + */ + public function getAmountByMonth($year, $format = 0) + { + global $user; - $sql = "SELECT date_format(c.date_valid,'%m') as dm, 0"; - $sql.= " FROM ".$this->from; - if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE c.date_valid BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'"; - $sql.= " AND ".$this->where; - $sql.= " GROUP BY dm"; + $sql = "SELECT date_format(c.date_valid,'%m') as dm, 0"; + $sql.= " FROM ".$this->from; + if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql.= " WHERE c.date_valid BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'"; + $sql.= " AND ".$this->where; + $sql.= " GROUP BY dm"; $sql.= $this->db->order('dm', 'DESC'); - $res=$this->_getAmountByMonth($year, $sql, $format); - return $res; - } + $res=$this->_getAmountByMonth($year, $sql, $format); + return $res; + } - /** - * Return the intervention amount average by month for a year - * - * @param int $year year for stats - * @return array array with number by month - */ - function getAverageByMonth($year) - { - global $user; + /** + * Return the intervention amount average by month for a year + * + * @param int $year year for stats + * @return array array with number by month + */ + public function getAverageByMonth($year) + { + global $user; - $sql = "SELECT date_format(c.date_valid,'%m') as dm, 0"; - $sql.= " FROM ".$this->from; - if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE c.date_valid BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'"; - $sql.= " AND ".$this->where; - $sql.= " GROUP BY dm"; + $sql = "SELECT date_format(c.date_valid,'%m') as dm, 0"; + $sql.= " FROM ".$this->from; + if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql.= " WHERE c.date_valid BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'"; + $sql.= " AND ".$this->where; + $sql.= " GROUP BY dm"; $sql.= $this->db->order('dm', 'DESC'); - return $this->_getAverageByMonth($year, $sql); - } + return $this->_getAverageByMonth($year, $sql); + } - /** - * Return nb, total and average - * - * @return array Array of values - */ - function getAllByYear() - { - global $user; + /** + * Return nb, total and average + * + * @return array Array of values + */ + public function getAllByYear() + { + global $user; - $sql = "SELECT date_format(c.date_valid,'%Y') as year, COUNT(*) as nb, 0 as total, 0 as avg"; - $sql.= " FROM ".$this->from; - if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE ".$this->where; - $sql.= " GROUP BY year"; + $sql = "SELECT date_format(c.date_valid,'%Y') as year, COUNT(*) as nb, 0 as total, 0 as avg"; + $sql.= " FROM ".$this->from; + if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql.= " WHERE ".$this->where; + $sql.= " GROUP BY year"; $sql.= $this->db->order('year', 'DESC'); - return $this->_getAllByYear($sql); - } + return $this->_getAllByYear($sql); + } - /** - * Return nb, amount of predefined product for year - * - * @param int $year Year to scan - * @return array Array of values - */ - function getAllByProduct($year) - { - global $user; + /** + * Return nb, amount of predefined product for year + * + * @param int $year Year to scan + * @return array Array of values + */ + public function getAllByProduct($year) + { + global $user; - $sql = "SELECT product.ref, COUNT(product.ref) as nb, 0 as total, 0 as avg"; - $sql.= " FROM ".$this->from.", ".$this->from_line.", ".MAIN_DB_PREFIX."product as product"; - //if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE ".$this->where; - $sql.= " AND c.rowid = tl.fk_fichinter AND tl.fk_product = product.rowid"; - $sql.= " AND c.date_valid BETWEEN '".$this->db->idate(dol_get_first_day($year, 1, false))."' AND '".$this->db->idate(dol_get_last_day($year, 12, false))."'"; - $sql.= " GROUP BY product.ref"; + $sql = "SELECT product.ref, COUNT(product.ref) as nb, 0 as total, 0 as avg"; + $sql.= " FROM ".$this->from.", ".$this->from_line.", ".MAIN_DB_PREFIX."product as product"; + //if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql.= " WHERE ".$this->where; + $sql.= " AND c.rowid = tl.fk_fichinter AND tl.fk_product = product.rowid"; + $sql.= " AND c.date_valid BETWEEN '".$this->db->idate(dol_get_first_day($year, 1, false))."' AND '".$this->db->idate(dol_get_last_day($year, 12, false))."'"; + $sql.= " GROUP BY product.ref"; $sql.= $this->db->order('nb', 'DESC'); //$sql.= $this->db->plimit(20); - return $this->_getAllByProduct($sql); - } + return $this->_getAllByProduct($sql); + } } diff --git a/htdocs/holiday/class/holiday.class.php b/htdocs/holiday/class/holiday.class.php index 078fcb2c59d..b914666011d 100644 --- a/htdocs/holiday/class/holiday.class.php +++ b/htdocs/holiday/class/holiday.class.php @@ -149,7 +149,7 @@ class Holiday extends CommonObject * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; } @@ -162,7 +162,7 @@ class Holiday extends CommonObject * @param Societe $objsoc third party object * @return string Holiday free reference */ - function getNextNumRef($objsoc) + public function getNextNumRef($objsoc) { global $langs, $conf; $langs->load("order"); @@ -221,7 +221,7 @@ class Holiday extends CommonObject * * @return int <0 if KO, >0 if OK */ - function updateBalance() + public function updateBalance() { $this->db->begin(); @@ -250,7 +250,7 @@ class Holiday extends CommonObject * @param int $notrigger 0=launch triggers after, 1=disable triggers * @return int <0 if KO, Id of created object if OK */ - function create($user, $notrigger = 0) + public function create($user, $notrigger = 0) { global $conf; $error=0; @@ -336,7 +336,7 @@ class Holiday extends CommonObject * @param string $ref Ref object * @return int <0 if KO, >0 if OK */ - function fetch($id, $ref = '') + public function fetch($id, $ref = '') { global $langs; @@ -420,7 +420,7 @@ class Holiday extends CommonObject * @param string $filter SQL Filter * @return int -1 if KO, 1 if OK, 2 if no result */ - function fetchByUser($user_id, $order = '', $filter = '') + public function fetchByUser($user_id, $order = '', $filter = '') { global $langs, $conf; @@ -548,7 +548,7 @@ class Holiday extends CommonObject * @param string $filter SQL Filter * @return int -1 if KO, 1 if OK, 2 if no result */ - function fetchAll($order, $filter) + public function fetchAll($order, $filter) { global $langs; @@ -674,7 +674,7 @@ class Holiday extends CommonObject * @param int $notrigger 0=launch triggers after, 1=disable triggers * @return int <0 if KO, >0 if OK */ - function validate($user = null, $notrigger = 0) + public function validate($user = null, $notrigger = 0) { global $conf, $langs; $error=0; @@ -745,7 +745,7 @@ class Holiday extends CommonObject * @param int $notrigger 0=launch triggers after, 1=disable triggers * @return int <0 if KO, >0 if OK */ - function approve($user = null, $notrigger = 0) + public function approve($user = null, $notrigger = 0) { global $conf, $langs; $error=0; @@ -858,7 +858,7 @@ class Holiday extends CommonObject * @param int $notrigger 0=launch triggers after, 1=disable triggers * @return int <0 if KO, >0 if OK */ - function update($user = null, $notrigger = 0) + public function update($user = null, $notrigger = 0) { global $conf, $langs; $error=0; @@ -972,7 +972,7 @@ class Holiday extends CommonObject * @param int $notrigger 0=launch triggers after, 1=disable triggers * @return int <0 if KO, >0 if OK */ - function delete($user, $notrigger = 0) + public function delete($user, $notrigger = 0) { global $conf, $langs; $error=0; @@ -1030,7 +1030,7 @@ class Holiday extends CommonObject * @return boolean False = New range overlap an existing holiday, True = no overlapping (is never on holiday during checked period). * @see verifDateHolidayForTimestamp */ - function verifDateHolidayCP($fk_user, $dateStart, $dateEnd, $halfday = 0) + public function verifDateHolidayCP($fk_user, $dateStart, $dateEnd, $halfday = 0) { $this->fetchByUser($fk_user, '', ''); @@ -1112,7 +1112,7 @@ class Holiday extends CommonObject * @return array array('morning'=> ,'afternoon'=> ), Boolean is true if user is available for day timestamp. * @see verifDateHolidayCP */ - function verifDateHolidayForTimestamp($fk_user, $timestamp, $status = '-1') + public function verifDateHolidayForTimestamp($fk_user, $timestamp, $status = '-1') { global $langs, $conf; @@ -1175,7 +1175,7 @@ class Holiday extends CommonObject * @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 */ - function getNomUrl($withpicto = 0, $save_lastsearch_value = -1) + public function getNomUrl($withpicto = 0, $save_lastsearch_value = -1) { global $langs; @@ -1211,7 +1211,7 @@ class Holiday 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 * @return string Label */ - function getLibStatut($mode = 0) + public function getLibStatut($mode = 0) { return $this->LibStatut($this->statut, $mode, $this->date_debut); } @@ -1225,7 +1225,7 @@ class Holiday extends CommonObject * @param date $startdate Date holiday should start * @return string Label */ - function LibStatut($statut, $mode = 0, $startdate = '') + public function LibStatut($statut, $mode = 0, $startdate = '') { // phpcs:enable global $langs; @@ -1290,7 +1290,7 @@ class Holiday extends CommonObject * @param string $htmlname Name of HTML select field * @return string Show select of status */ - function selectStatutCP($selected = '', $htmlname = 'select_statut') + public function selectStatutCP($selected = '', $htmlname = 'select_statut') { global $langs; @@ -1324,7 +1324,7 @@ class Holiday extends CommonObject * @param string $value vrai si mise à jour OK sinon faux * @return boolean ok or ko */ - function updateConfCP($name, $value) + public function updateConfCP($name, $value) { $sql = "UPDATE ".MAIN_DB_PREFIX."holiday_config SET"; @@ -1348,7 +1348,7 @@ class Holiday extends CommonObject * @param string $createifnotfound 'stringvalue'=Create entry with string value if not found. For example 'YYYYMMDDHHMMSS'. * @return string Value of parameter. Example: 'YYYYMMDDHHMMSS' or < 0 if error */ - function getConfCP($name, $createifnotfound = '') + public function getConfCP($name, $createifnotfound = '') { $sql = "SELECT value"; $sql.= " FROM ".MAIN_DB_PREFIX."holiday_config"; @@ -1403,7 +1403,7 @@ class Holiday extends CommonObject * @param int $fk_type Type of vacation * @return int 0=Nothing done, 1=OK, -1=KO */ - function updateSoldeCP($userID = '', $nbHoliday = '', $fk_type = '') + public function updateSoldeCP($userID = '', $nbHoliday = '', $fk_type = '') { global $user, $langs; @@ -1552,7 +1552,7 @@ class Holiday extends CommonObject * @param string $name name du paramètre de configuration * @return string retourne checked si > 0 */ - function getCheckOption($name) + public function getCheckOption($name) { $sql = "SELECT value"; @@ -1579,7 +1579,7 @@ class Holiday extends CommonObject * @param int $userid Id user * @return void */ - function createCPusers($single = false, $userid = '') + public function createCPusers($single = false, $userid = '') { // Si c'est l'ensemble des utilisateurs à ajouter if (! $single) @@ -1614,7 +1614,7 @@ class Holiday extends CommonObject * @param int $user_id ID de l'utilisateur à supprimer * @return boolean Vrai si pas d'erreur, faut si Erreur */ - function deleteCPuser($user_id) + public function deleteCPuser($user_id) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."holiday_users"; @@ -1631,7 +1631,7 @@ class Holiday extends CommonObject * @param int $fk_type Filter on type * @return float Retourne le solde de congés payés de l'utilisateur */ - function getCPforUser($user_id, $fk_type = 0) + public function getCPforUser($user_id, $fk_type = 0) { $sql = "SELECT nb_holiday"; $sql.= " FROM ".MAIN_DB_PREFIX."holiday_users"; @@ -1661,7 +1661,7 @@ class Holiday extends CommonObject * @param string $filters Filters * @return array|string|int Return an array */ - function fetchUsers($stringlist = true, $type = true, $filters = '') + public function fetchUsers($stringlist = true, $type = true, $filters = '') { global $conf; @@ -1881,7 +1881,7 @@ class Holiday extends CommonObject * * @return array Array of user ids */ - function fetch_users_approver_holiday() + public function fetch_users_approver_holiday() { // phpcs:enable $users_validator=array(); @@ -1922,7 +1922,7 @@ class Holiday extends CommonObject * * @return int retourne le nombre d'utilisateur */ - function countActiveUsers() + public function countActiveUsers() { $sql = "SELECT count(u.rowid) as compteur"; $sql.= " FROM ".MAIN_DB_PREFIX."user as u"; @@ -1938,7 +1938,7 @@ class Holiday extends CommonObject * * @return int retourne le nombre d'utilisateur */ - function countActiveUsersWithoutCP() + public function countActiveUsersWithoutCP() { $sql = "SELECT count(u.rowid) as compteur"; @@ -1958,7 +1958,7 @@ class Holiday extends CommonObject * @param int $userCP Number of active users into table of holidays * @return int <0 if KO, >0 if OK */ - function verifNbUsers($userDolibarrWithoutCP, $userCP) + public function verifNbUsers($userDolibarrWithoutCP, $userCP) { if (empty($userCP)) $userCP=0; dol_syslog(get_class($this).'::verifNbUsers userDolibarr='.$userDolibarrWithoutCP.' userCP='.$userCP); @@ -1976,7 +1976,7 @@ class Holiday extends CommonObject * @param int $fk_type Type of vacation * @return int Id of record added, 0 if nothing done, < 0 if KO */ - function addLogCP($fk_user_action, $fk_user_update, $label, $new_solde, $fk_type) + public function addLogCP($fk_user_action, $fk_user_update, $label, $new_solde, $fk_type) { global $conf, $langs; @@ -2045,7 +2045,7 @@ class Holiday extends CommonObject * @param string $filter Filtre de séléction * @return int -1 si erreur, 1 si OK et 2 si pas de résultat */ - function fetchLog($order, $filter) + public function fetchLog($order, $filter) { global $langs; @@ -2122,7 +2122,7 @@ class Holiday extends CommonObject * @param int $affect Filter on affect (a request will change sold or not). -1 = Both * @return array Return array with list of types */ - function getTypes($active = -1, $affect = -1) + public function getTypes($active = -1, $affect = -1) { global $mysoc; @@ -2159,7 +2159,7 @@ class Holiday extends CommonObject * * @return void */ - function initAsSpecimen() + public function initAsSpecimen() { global $user,$langs; diff --git a/htdocs/hrm/class/establishment.class.php b/htdocs/hrm/class/establishment.class.php index 5759d567761..bb0bfd342ac 100644 --- a/htdocs/hrm/class/establishment.class.php +++ b/htdocs/hrm/class/establishment.class.php @@ -102,7 +102,7 @@ class Establishment extends CommonObject * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; @@ -116,7 +116,7 @@ class Establishment extends CommonObject * @param User $user User making creation * @return int <0 if KO, >0 if OK */ - function create($user) + public function create($user) { global $conf, $langs; @@ -187,7 +187,7 @@ class Establishment extends CommonObject * @param User $user User making update * @return int <0 if KO, >0 if OK */ - function update($user) + public function update($user) { global $langs; @@ -228,7 +228,7 @@ class Establishment extends CommonObject * @param int $id Id of record to load * @return int <0 if KO, >0 if OK */ - function fetch($id) + public function fetch($id) { $sql = "SELECT e.rowid, e.name, e.address, e.zip, e.town, e.status, e.fk_country as country_id,"; $sql.= ' c.code as country_code, c.label as country'; @@ -269,7 +269,7 @@ class Establishment extends CommonObject * @param int $id Id of record to delete * @return int <0 if KO, >0 if OK */ - function delete($id) + public function delete($id) { $this->db->begin(); @@ -296,7 +296,7 @@ class Establishment 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 * @return string Label */ - function getLibStatut($mode = 0) + public function getLibStatut($mode = 0) { return $this->LibStatut($this->status, $mode); } @@ -309,7 +309,7 @@ class Establishment 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 * @return string Label */ - function LibStatut($status, $mode = 0) + public function LibStatut($status, $mode = 0) { // phpcs:enable global $langs; @@ -350,7 +350,7 @@ class Establishment extends CommonObject * @param int $id Id of record * @return void */ - function info($id) + public function info($id) { $sql = 'SELECT e.rowid, e.datec, e.fk_user_author, e.tms, e.fk_user_mod'; $sql.= ' FROM '.MAIN_DB_PREFIX.'establishment as e'; @@ -396,7 +396,7 @@ class Establishment extends CommonObject * @param int $withpicto 0=No picto, 1=Include picto into link, 2=Only picto * @return string String with URL */ - function getNomUrl($withpicto = 0) + public function getNomUrl($withpicto = 0) { global $langs; @@ -420,7 +420,7 @@ class Establishment extends CommonObject * * @return string country code */ - function getCountryCode() + public function getCountryCode() { global $mysoc; diff --git a/htdocs/supplier_proposal/class/api_supplier_proposals.class.php b/htdocs/supplier_proposal/class/api_supplier_proposals.class.php index d856cd1250d..15f4278bf49 100644 --- a/htdocs/supplier_proposal/class/api_supplier_proposals.class.php +++ b/htdocs/supplier_proposal/class/api_supplier_proposals.class.php @@ -30,164 +30,164 @@ require_once DOL_DOCUMENT_ROOT.'/supplier_proposal/class/supplier_proposal.class class Supplierproposals extends DolibarrApi { - /** - * @var array $FIELDS Mandatory fields, checked when create and update object - */ - static $FIELDS = array( - 'socid' - ); + /** + * @var array $FIELDS Mandatory fields, checked when create and update object + */ + static $FIELDS = array( + 'socid' + ); - /** - * @var SupplierProposal $supplier_proposal {@type SupplierProposal} - */ - public $supplier_proposal; + /** + * @var SupplierProposal $supplier_proposal {@type SupplierProposal} + */ + public $supplier_proposal; - /** - * Constructor - */ - function __construct() - { - global $db, $conf; - $this->db = $db; - $this->supplier_proposal = new SupplierProposal($this->db); - } - - /** - * Get properties of a supplier proposal (price request) object - * - * Return an array with supplier proposal informations - * - * @param int $id ID of supplier proposal - * @return array|mixed data without useless information - * - * @throws RestException - */ - function get($id) - { - if(! DolibarrApiAccess::$user->rights->supplier_proposal->lire) { - throw new RestException(401); - } - - $result = $this->supplier_proposal->fetch($id); - if( ! $result ) { - throw new RestException(404, 'Supplier Proposal not found'); - } - - if( ! DolibarrApi::_checkAccessToResource('supplier_proposal', $this->propal->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } - - $this->supplier_proposal->fetchObjectLinked(); - return $this->_cleanObjectDatas($this->supplier_proposal); - } - - /** - * List supplier proposals - * - * Get a list of supplier proposals - * - * @param string $sortfield Sort field - * @param string $sortorder Sort order - * @param int $limit Limit for list - * @param int $page Page number - * @param string $thirdparty_ids Thirdparty ids to filter supplier proposals. {@example '1' or '1,2,3'} {@pattern /^[0-9,]*$/i} - * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.datec:<:'20160101')" - * @return array Array of order objects - */ - function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $thirdparty_ids = '', $sqlfilters = '') + /** + * Constructor + */ + public function __construct() { - global $db, $conf; + global $db, $conf; + $this->db = $db; + $this->supplier_proposal = new SupplierProposal($this->db); + } - $obj_ret = array(); + /** + * Get properties of a supplier proposal (price request) object + * + * Return an array with supplier proposal informations + * + * @param int $id ID of supplier proposal + * @return array|mixed data without useless information + * + * @throws RestException + */ + public function get($id) + { + if(! DolibarrApiAccess::$user->rights->supplier_proposal->lire) { + throw new RestException(401); + } - // case of external user, $thirdparty_ids param is ignored and replaced by user's socid - $socids = DolibarrApiAccess::$user->societe_id ? DolibarrApiAccess::$user->societe_id : $thirdparty_ids; + $result = $this->supplier_proposal->fetch($id); + if( ! $result ) { + throw new RestException(404, 'Supplier Proposal not found'); + } - // If the internal user must only see his customers, force searching by him - $search_sale = 0; - if (! DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) $search_sale = DolibarrApiAccess::$user->id; + if( ! DolibarrApi::_checkAccessToResource('supplier_proposal', $this->propal->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } - $sql = "SELECT t.rowid"; - if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql .= ", sc.fk_soc, sc.fk_user"; // We need these fields in order to filter by sale (including the case where the user can only see his prospects) - $sql.= " FROM ".MAIN_DB_PREFIX."supplier_proposal as t"; + $this->supplier_proposal->fetchObjectLinked(); + return $this->_cleanObjectDatas($this->supplier_proposal); + } - if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale + /** + * List supplier proposals + * + * Get a list of supplier proposals + * + * @param string $sortfield Sort field + * @param string $sortorder Sort order + * @param int $limit Limit for list + * @param int $page Page number + * @param string $thirdparty_ids Thirdparty ids to filter supplier proposals. {@example '1' or '1,2,3'} {@pattern /^[0-9,]*$/i} + * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.datec:<:'20160101')" + * @return array Array of order objects + */ + public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $thirdparty_ids = '', $sqlfilters = '') + { + global $db, $conf; - $sql.= ' WHERE t.entity IN ('.getEntity('propal').')'; - if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql.= " AND t.fk_soc = sc.fk_soc"; - if ($socids) $sql.= " AND t.fk_soc IN (".$socids.")"; - if ($search_sale > 0) $sql.= " AND t.rowid = sc.fk_soc"; // Join for the needed table to filter by sale - // Insert sale filter - if ($search_sale > 0) - { - $sql .= " AND sc.fk_user = ".$search_sale; - } - // Add sql filters - if ($sqlfilters) - { - if (! DolibarrApi::_checkFilters($sqlfilters)) - { - throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); - } - $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; - $sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; - } + $obj_ret = array(); - $sql.= $db->order($sortfield, $sortorder); - if ($limit) { - if ($page < 0) - { - $page = 0; - } - $offset = $limit * $page; + // case of external user, $thirdparty_ids param is ignored and replaced by user's socid + $socids = DolibarrApiAccess::$user->societe_id ? DolibarrApiAccess::$user->societe_id : $thirdparty_ids; - $sql.= $db->plimit($limit + 1, $offset); - } + // If the internal user must only see his customers, force searching by him + $search_sale = 0; + if (! DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) $search_sale = DolibarrApiAccess::$user->id; - $result = $db->query($sql); + $sql = "SELECT t.rowid"; + if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql .= ", sc.fk_soc, sc.fk_user"; // We need these fields in order to filter by sale (including the case where the user can only see his prospects) + $sql.= " FROM ".MAIN_DB_PREFIX."supplier_proposal as t"; - if ($result) - { - $num = $db->num_rows($result); - $min = min($num, ($limit <= 0 ? $num : $limit)); - $i=0; - while ($i < $min) - { - $obj = $db->fetch_object($result); - $propal_static = new SupplierProposal($db); - if($propal_static->fetch($obj->rowid)) { - $obj_ret[] = $this->_cleanObjectDatas($propal_static); - } - $i++; - } - } - else { - throw new RestException(503, 'Error when retrieving supplier proposal list : '.$db->lasterror()); - } - if( ! count($obj_ret)) { - throw new RestException(404, 'No supplier proposal found'); - } - return $obj_ret; - } + if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale + + $sql.= ' WHERE t.entity IN ('.getEntity('propal').')'; + if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql.= " AND t.fk_soc = sc.fk_soc"; + if ($socids) $sql.= " AND t.fk_soc IN (".$socids.")"; + if ($search_sale > 0) $sql.= " AND t.rowid = sc.fk_soc"; // Join for the needed table to filter by sale + // Insert sale filter + if ($search_sale > 0) + { + $sql .= " AND sc.fk_user = ".$search_sale; + } + // Add sql filters + if ($sqlfilters) + { + if (! DolibarrApi::_checkFilters($sqlfilters)) + { + throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); + } + $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; + $sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; + } + + $sql.= $db->order($sortfield, $sortorder); + if ($limit) { + if ($page < 0) + { + $page = 0; + } + $offset = $limit * $page; + + $sql.= $db->plimit($limit + 1, $offset); + } + + $result = $db->query($sql); + + if ($result) + { + $num = $db->num_rows($result); + $min = min($num, ($limit <= 0 ? $num : $limit)); + $i=0; + while ($i < $min) + { + $obj = $db->fetch_object($result); + $propal_static = new SupplierProposal($db); + if($propal_static->fetch($obj->rowid)) { + $obj_ret[] = $this->_cleanObjectDatas($propal_static); + } + $i++; + } + } + else { + throw new RestException(503, 'Error when retrieving supplier proposal list : '.$db->lasterror()); + } + if( ! count($obj_ret)) { + throw new RestException(404, 'No supplier proposal found'); + } + return $obj_ret; + } - /** - * Validate fields before create or update object - * - * @param array $data Array with data to verify - * @return array - * @throws RestException - */ - function _validate($data) - { - $propal = array(); - foreach (SupplierProposals::$FIELDS as $field) { - if (!isset($data[$field])) - throw new RestException(400, "$field field missing"); - $propal[$field] = $data[$field]; - } - return $propal; - } + /** + * Validate fields before create or update object + * + * @param array $data Array with data to verify + * @return array + * @throws RestException + */ + private function _validate($data) + { + $propal = array(); + foreach (SupplierProposals::$FIELDS as $field) { + if (!isset($data[$field])) + throw new RestException(400, "$field field missing"); + $propal[$field] = $data[$field]; + } + return $propal; + } /** @@ -196,7 +196,7 @@ class Supplierproposals extends DolibarrApi * @param object $object Object to clean * @return array Array of cleaned object properties */ - function _cleanObjectDatas($object) + private function _cleanObjectDatas($object) { $object = parent::_cleanObjectDatas($object); diff --git a/htdocs/supplier_proposal/class/supplier_proposal.class.php b/htdocs/supplier_proposal/class/supplier_proposal.class.php index a5c6ee84e86..6b9c5d3db26 100644 --- a/htdocs/supplier_proposal/class/supplier_proposal.class.php +++ b/htdocs/supplier_proposal/class/supplier_proposal.class.php @@ -47,23 +47,23 @@ require_once DOL_DOCUMENT_ROOT .'/multicurrency/class/multicurrency.class.php'; class SupplierProposal extends CommonObject { /** - * @var string ID to identify managed object - */ - public $element='supplier_proposal'; + * @var string ID to identify managed object + */ + public $element='supplier_proposal'; /** - * @var string Name of table without prefix where object is stored - */ - public $table_element='supplier_proposal'; + * @var string Name of table without prefix where object is stored + */ + public $table_element='supplier_proposal'; /** - * @var int Name of subtable line - */ - public $table_element_line='supplier_proposaldet'; + * @var int Name of subtable line + */ + public $table_element_line='supplier_proposaldet'; - /** - * @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_supplier_proposal'; public $picto='propal'; @@ -87,10 +87,10 @@ class SupplierProposal extends CommonObject public $socid; // Id client - /** - * @deprecated - * @see user_author_id - */ + /** + * @deprecated + * @see user_author_id + */ public $author; public $ref_fourn; //Reference saisie lors de l'ajout d'une ligne à la demande @@ -99,51 +99,51 @@ class SupplierProposal extends CommonObject public $date; // Date of proposal public $date_livraison; - /** - * @deprecated - * @see date_creation - */ - public $datec; + /** + * @deprecated + * @see date_creation + */ + public $datec; - /** - * Creation date - * @var int - */ - public $date_creation; + /** + * Creation date + * @var int + */ + public $date_creation; - /** - * @deprecated - * @see date_validation - */ - public $datev; + /** + * @deprecated + * @see date_validation + */ + public $datev; - /** - * Validation date - * @var int - */ - public $date_validation; + /** + * Validation date + * @var int + */ + public $date_validation; public $user_author_id; public $user_valid_id; public $user_close_id; - /** - * @deprecated - * @see price_ht - */ + /** + * @deprecated + * @see price_ht + */ public $price; - /** - * @deprecated - * @see total_tva - */ + /** + * @deprecated + * @see total_tva + */ public $tva; - /** - * @deprecated - * @see total_ttc - */ + /** + * @deprecated + * @see total_ttc + */ public $total; public $cond_reglement_code; @@ -166,42 +166,42 @@ class SupplierProposal extends CommonObject public $specimen; - // Multicurrency - /** + // Multicurrency + /** * @var int ID */ - public $fk_multicurrency; + public $fk_multicurrency; - public $multicurrency_code; - public $multicurrency_tx; - public $multicurrency_total_ht; - public $multicurrency_total_tva; - public $multicurrency_total_ttc; + public $multicurrency_code; + public $multicurrency_tx; + public $multicurrency_total_ht; + public $multicurrency_total_tva; + public $multicurrency_total_ttc; - /** - * Draft status - */ - const STATUS_DRAFT = 0; + /** + * Draft status + */ + const STATUS_DRAFT = 0; - /** - * Validated status - */ - const STATUS_VALIDATED = 1; + /** + * Validated status + */ + const STATUS_VALIDATED = 1; - /** - * Signed quote - */ - const STATUS_SIGNED = 2; + /** + * Signed quote + */ + const STATUS_SIGNED = 2; - /** - * Not signed quote, canceled - */ - const STATUS_NOTSIGNED = 3; + /** + * Not signed quote, canceled + */ + const STATUS_NOTSIGNED = 3; - /** - * Billed or closed/processed quote - */ - const STATUS_CLOSE = 4; + /** + * Billed or closed/processed quote + */ + const STATUS_CLOSE = 4; @@ -212,7 +212,7 @@ class SupplierProposal extends CommonObject * @param int $socid Id third party * @param int $supplier_proposalid Id supplier_proposal */ - function __construct($db, $socid = "", $supplier_proposalid = 0) + public function __construct($db, $socid = "", $supplier_proposalid = 0) { global $conf,$langs; @@ -225,7 +225,7 @@ class SupplierProposal extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Add line into array products * $this->client doit etre charge @@ -238,7 +238,7 @@ class SupplierProposal extends CommonObject * TODO Remplacer les appels a cette fonction par generation objet Ligne * insere dans tableau $this->products */ - function add_product($idproduct, $qty, $remise_percent = 0) + public function add_product($idproduct, $qty, $remise_percent = 0) { // phpcs:enable global $conf, $mysoc; @@ -282,14 +282,14 @@ class SupplierProposal extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Adding line of fixed discount in the proposal in DB * * @param int $idremise Id of fixed discount * @return int >0 if OK, <0 if KO */ - function insert_discount($idremise) + public function insert_discount($idremise) { // phpcs:enable global $langs; @@ -386,18 +386,18 @@ class SupplierProposal extends CommonObject * @param int $pa_ht Buying price without tax * @param string $label ??? * @param array $array_option extrafields array - * @param string $ref_supplier Supplier price reference - * @param int $fk_unit Id of the unit to use. - * @param string $origin 'order', 'supplier_proposal', ... - * @param int $origin_id Id of origin line + * @param string $ref_supplier Supplier price reference + * @param int $fk_unit Id of the unit to use. + * @param string $origin 'order', 'supplier_proposal', ... + * @param int $origin_id Id of origin line * @param double $pu_ht_devise Amount in currency * @return int >0 if OK, <0 if KO * * @see add_product */ - function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1 = 0, $txlocaltax2 = 0, $fk_product = 0, $remise_percent = 0, $price_base_type = 'HT', $pu_ttc = 0, $info_bits = 0, $type = 0, $rang = -1, $special_code = 0, $fk_parent_line = 0, $fk_fournprice = 0, $pa_ht = 0, $label = '', $array_option = 0, $ref_supplier = '', $fk_unit = '', $origin = '', $origin_id = 0, $pu_ht_devise = 0) + public function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1 = 0, $txlocaltax2 = 0, $fk_product = 0, $remise_percent = 0, $price_base_type = 'HT', $pu_ttc = 0, $info_bits = 0, $type = 0, $rang = -1, $special_code = 0, $fk_parent_line = 0, $fk_fournprice = 0, $pa_ht = 0, $label = '', $array_option = 0, $ref_supplier = '', $fk_unit = '', $origin = '', $origin_id = 0, $pu_ht_devise = 0) { - global $mysoc, $conf; + global $mysoc, $conf; dol_syslog(get_class($this)."::addline supplier_proposalid=$this->id, desc=$desc, pu_ht=$pu_ht, qty=$qty, txtva=$txtva, fk_product=$fk_product, remise_except=$remise_percent, price_base_type=$price_base_type, pu_ttc=$pu_ttc, info_bits=$info_bits, type=$type"); include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php'; @@ -417,7 +417,7 @@ class SupplierProposal extends CommonObject $txtva=price2num($txtva); $txlocaltax1=price2num($txlocaltax1); $txlocaltax2=price2num($txlocaltax2); - $pa_ht=price2num($pa_ht); + $pa_ht=price2num($pa_ht); if ($price_base_type=='HT') { $pu=$pu_ht; @@ -436,65 +436,65 @@ class SupplierProposal extends CommonObject if ($fk_product > 0) { - if (! empty($conf->global->SUPPLIER_PROPOSAL_WITH_PREDEFINED_PRICES_ONLY)) - { - // Check quantity is enough - dol_syslog(get_class($this)."::addline we check supplier prices fk_product=".$fk_product." fk_fournprice=".$fk_fournprice." qty=".$qty." ref_supplier=".$ref_supplier); - $prod = new Product($this->db, $fk_product); - if ($prod->fetch($fk_product) > 0) - { - $product_type = $prod->type; - $label = $prod->label; - $fk_prod_fourn_price = $fk_fournprice; + if (! empty($conf->global->SUPPLIER_PROPOSAL_WITH_PREDEFINED_PRICES_ONLY)) + { + // Check quantity is enough + dol_syslog(get_class($this)."::addline we check supplier prices fk_product=".$fk_product." fk_fournprice=".$fk_fournprice." qty=".$qty." ref_supplier=".$ref_supplier); + $prod = new Product($this->db, $fk_product); + if ($prod->fetch($fk_product) > 0) + { + $product_type = $prod->type; + $label = $prod->label; + $fk_prod_fourn_price = $fk_fournprice; - // We use 'none' instead of $ref_supplier, because fourn_ref may not exists anymore. So we will take the first supplier price ok. - // If we want a dedicated supplier price, we must provide $fk_prod_fourn_price. - $result=$prod->get_buyprice($fk_prod_fourn_price, $qty, $fk_product, 'none', ($this->fk_soc?$this->fk_soc:$this->socid)); // Search on couple $fk_prod_fourn_price/$qty first, then on triplet $qty/$fk_product/$ref_supplier/$this->fk_soc - if ($result > 0) - { - $pu = $prod->fourn_pu; // Unit price supplier price set by get_buyprice - $ref_supplier = $prod->ref_supplier; // Ref supplier price set by get_buyprice - // is remise percent not keyed but present for the product we add it - if ($remise_percent == 0 && $prod->remise_percent !=0) - $remise_percent =$prod->remise_percent; - } - if ($result == 0) // If result == 0, we failed to found the supplier reference price - { - $langs->load("errors"); - $this->error = "Ref " . $prod->ref . " " . $langs->trans("ErrorQtyTooLowForThisSupplier"); - $this->db->rollback(); - dol_syslog(get_class($this)."::addline we did not found supplier price, so we can't guess unit price"); - //$pu = $prod->fourn_pu; // We do not overwrite unit price - //$ref = $prod->ref_fourn; // We do not overwrite ref supplier price - return -1; - } - if ($result == -1) - { - $langs->load("errors"); - $this->error = "Ref " . $prod->ref . " " . $langs->trans("ErrorQtyTooLowForThisSupplier"); - $this->db->rollback(); - dol_syslog(get_class($this)."::addline result=".$result." - ".$this->error, LOG_DEBUG); - return -1; - } - if ($result < -1) - { - $this->error=$prod->error; - $this->db->rollback(); - dol_syslog(get_class($this)."::addline result=".$result." - ".$this->error, LOG_ERR); - return -1; - } - } - else - { - $this->error=$prod->error; - $this->db->rollback(); - return -1; - } - } + // We use 'none' instead of $ref_supplier, because fourn_ref may not exists anymore. So we will take the first supplier price ok. + // If we want a dedicated supplier price, we must provide $fk_prod_fourn_price. + $result=$prod->get_buyprice($fk_prod_fourn_price, $qty, $fk_product, 'none', ($this->fk_soc?$this->fk_soc:$this->socid)); // Search on couple $fk_prod_fourn_price/$qty first, then on triplet $qty/$fk_product/$ref_supplier/$this->fk_soc + if ($result > 0) + { + $pu = $prod->fourn_pu; // Unit price supplier price set by get_buyprice + $ref_supplier = $prod->ref_supplier; // Ref supplier price set by get_buyprice + // is remise percent not keyed but present for the product we add it + if ($remise_percent == 0 && $prod->remise_percent !=0) + $remise_percent =$prod->remise_percent; + } + if ($result == 0) // If result == 0, we failed to found the supplier reference price + { + $langs->load("errors"); + $this->error = "Ref " . $prod->ref . " " . $langs->trans("ErrorQtyTooLowForThisSupplier"); + $this->db->rollback(); + dol_syslog(get_class($this)."::addline we did not found supplier price, so we can't guess unit price"); + //$pu = $prod->fourn_pu; // We do not overwrite unit price + //$ref = $prod->ref_fourn; // We do not overwrite ref supplier price + return -1; + } + if ($result == -1) + { + $langs->load("errors"); + $this->error = "Ref " . $prod->ref . " " . $langs->trans("ErrorQtyTooLowForThisSupplier"); + $this->db->rollback(); + dol_syslog(get_class($this)."::addline result=".$result." - ".$this->error, LOG_DEBUG); + return -1; + } + if ($result < -1) + { + $this->error=$prod->error; + $this->db->rollback(); + dol_syslog(get_class($this)."::addline result=".$result." - ".$this->error, LOG_ERR); + return -1; + } + } + else + { + $this->error=$prod->error; + $this->db->rollback(); + return -1; + } + } } else { - $product_type = $type; + $product_type = $type; } // Calcul du total TTC et de la TVA pour la ligne a partir de @@ -517,8 +517,8 @@ class SupplierProposal extends CommonObject $total_localtax2 = $tabprice[10]; $pu = $pu_ht = $tabprice[3]; - // MultiCurrency - $multicurrency_total_ht = $tabprice[16]; + // MultiCurrency + $multicurrency_total_ht = $tabprice[16]; $multicurrency_total_tva = $tabprice[17]; $multicurrency_total_ttc = $tabprice[18]; $pu_ht_devise = $tabprice[19]; @@ -552,7 +552,7 @@ class SupplierProposal extends CommonObject $this->line->localtax1_tx=($total_localtax1?$localtaxes_type[1]:0); $this->line->localtax2_tx=($total_localtax2?$localtaxes_type[3]:0); $this->line->localtax1_type = $localtaxes_type[0]; - $this->line->localtax2_type = $localtaxes_type[2]; + $this->line->localtax2_type = $localtaxes_type[2]; $this->line->fk_product=$fk_product; $this->line->remise_percent=$remise_percent; $this->line->subprice=$pu_ht; @@ -569,25 +569,25 @@ class SupplierProposal extends CommonObject $this->line->fk_unit=$fk_unit; $this->line->origin=$origin; $this->line->origin_id=$origin_id; - $this->line->ref_fourn = $this->db->escape($ref_supplier); + $this->line->ref_fourn = $this->db->escape($ref_supplier); - // infos marge - if (!empty($fk_product) && empty($fk_fournprice) && empty($pa_ht)) { - // by external module, take lowest buying price - include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php'; - $productFournisseur = new ProductFournisseur($this->db); - $productFournisseur->find_min_price_product_fournisseur($fk_product); - $this->line->fk_fournprice = $productFournisseur->product_fourn_price_id; - } else { - $this->line->fk_fournprice = $fk_fournprice; - } - $this->line->pa_ht = $pa_ht; + // infos marge + if (!empty($fk_product) && empty($fk_fournprice) && empty($pa_ht)) { + // by external module, take lowest buying price + include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php'; + $productFournisseur = new ProductFournisseur($this->db); + $productFournisseur->find_min_price_product_fournisseur($fk_product); + $this->line->fk_fournprice = $productFournisseur->product_fourn_price_id; + } else { + $this->line->fk_fournprice = $fk_fournprice; + } + $this->line->pa_ht = $pa_ht; - // Multicurrency - $this->line->fk_multicurrency = $this->fk_multicurrency; - $this->line->multicurrency_code = $this->multicurrency_code; + // Multicurrency + $this->line->fk_multicurrency = $this->fk_multicurrency; + $this->line->multicurrency_code = $this->multicurrency_code; $this->line->multicurrency_subprice = $pu_ht_devise; - $this->line->multicurrency_total_ht = $multicurrency_total_ht; + $this->line->multicurrency_total_ht = $multicurrency_total_ht; $this->line->multicurrency_total_tva = $multicurrency_total_tva; $this->line->multicurrency_total_ttc = $multicurrency_total_ttc; @@ -599,7 +599,7 @@ class SupplierProposal extends CommonObject $this->line->remise=$remise; if (is_array($array_option) && count($array_option)>0) { - $this->line->array_options=$array_option; + $this->line->array_options=$array_option; } $result=$this->line->insert(); @@ -652,12 +652,12 @@ class SupplierProposal extends CommonObject * @param int $pa_ht Price (without tax) of product when it was bought * @param string $label ??? * @param int $type 0/1=Product/service - * @param array $array_option extrafields array - * @param string $ref_supplier Supplier price reference - * @param int $fk_unit Id of the unit to use. + * @param array $array_option extrafields array + * @param string $ref_supplier Supplier price reference + * @param int $fk_unit Id of the unit to use. * @return int 0 if OK, <0 if KO */ - function updateline($rowid, $pu, $qty, $remise_percent, $txtva, $txlocaltax1 = 0, $txlocaltax2 = 0, $desc = '', $price_base_type = 'HT', $info_bits = 0, $special_code = 0, $fk_parent_line = 0, $skip_update_total = 0, $fk_fournprice = 0, $pa_ht = 0, $label = '', $type = 0, $array_option = 0, $ref_supplier = '', $fk_unit = '') + public function updateline($rowid, $pu, $qty, $remise_percent, $txtva, $txlocaltax1 = 0, $txlocaltax2 = 0, $desc = '', $price_base_type = 'HT', $info_bits = 0, $special_code = 0, $fk_parent_line = 0, $skip_update_total = 0, $fk_fournprice = 0, $pa_ht = 0, $label = '', $type = 0, $array_option = 0, $ref_supplier = '', $fk_unit = '') { global $conf,$user,$langs, $mysoc; @@ -671,7 +671,7 @@ class SupplierProposal extends CommonObject $txtva = price2num($txtva); $txlocaltax1=price2num($txlocaltax1); $txlocaltax2=price2num($txlocaltax2); - $pa_ht=price2num($pa_ht); + $pa_ht=price2num($pa_ht); if (empty($qty) && empty($special_code)) $special_code=3; // Set option tag if (! empty($qty) && $special_code == 3) $special_code=0; // Remove option tag @@ -694,8 +694,8 @@ class SupplierProposal extends CommonObject $total_localtax1 = $tabprice[9]; $total_localtax2 = $tabprice[10]; - // MultiCurrency - $multicurrency_total_ht = $tabprice[16]; + // MultiCurrency + $multicurrency_total_ht = $tabprice[16]; $multicurrency_total_tva = $tabprice[17]; $multicurrency_total_ttc = $tabprice[18]; @@ -730,8 +730,8 @@ class SupplierProposal extends CommonObject $this->line->tva_tx = $txtva; $this->line->localtax1_tx = $txlocaltax1; $this->line->localtax2_tx = $txlocaltax2; - $this->line->localtax1_type = $localtaxes_type[0]; - $this->line->localtax2_type = $localtaxes_type[2]; + $this->line->localtax1_type = $localtaxes_type[0]; + $this->line->localtax2_type = $localtaxes_type[2]; $this->line->remise_percent = $remise_percent; $this->line->subprice = $pu; $this->line->info_bits = $info_bits; @@ -744,18 +744,18 @@ class SupplierProposal extends CommonObject $this->line->fk_parent_line = $fk_parent_line; $this->line->skip_update_total = $skip_update_total; $this->line->ref_fourn = $ref_supplier; - $this->line->fk_unit = $fk_unit; + $this->line->fk_unit = $fk_unit; // infos marge if (!empty($fk_product) && empty($fk_fournprice) && empty($pa_ht)) { // by external module, take lowest buying price include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php'; - $productFournisseur = new ProductFournisseur($this->db); - $productFournisseur->find_min_price_product_fournisseur($fk_product); - $this->line->fk_fournprice = $productFournisseur->product_fourn_price_id; - } else { - $this->line->fk_fournprice = $fk_fournprice; - } + $productFournisseur = new ProductFournisseur($this->db); + $productFournisseur->find_min_price_product_fournisseur($fk_product); + $this->line->fk_fournprice = $productFournisseur->product_fourn_price_id; + } else { + $this->line->fk_fournprice = $fk_fournprice; + } $this->line->pa_ht = $pa_ht; // TODO deprecated @@ -763,12 +763,12 @@ class SupplierProposal extends CommonObject $this->line->remise=$remise; if (is_array($array_option) && count($array_option)>0) { - $this->line->array_options=$array_option; + $this->line->array_options=$array_option; } - // Multicurrency - $this->line->multicurrency_subprice = price2num($pu * $this->multicurrency_tx); - $this->line->multicurrency_total_ht = $multicurrency_total_ht; + // Multicurrency + $this->line->multicurrency_subprice = price2num($pu * $this->multicurrency_tx); + $this->line->multicurrency_total_ht = $multicurrency_total_ht; $this->line->multicurrency_total_tva = $multicurrency_total_tva; $this->line->multicurrency_total_ttc = $multicurrency_total_ttc; @@ -807,7 +807,7 @@ class SupplierProposal extends CommonObject * @param int $lineid Id of line to delete * @return int >0 if OK, <0 if KO */ - function deleteline($lineid) + public function deleteline($lineid) { if ($this->statut == 0) { @@ -842,7 +842,7 @@ class SupplierProposal extends CommonObject * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int <0 if KO, >=0 if OK */ - function create($user, $notrigger = 0) + public function create($user, $notrigger = 0) { global $langs, $conf, $mysoc, $hookmanager; $error=0; @@ -861,26 +861,26 @@ class SupplierProposal extends CommonObject } // Check parameters - if (! empty($this->ref)) // We check that ref is not already used - { - $result=self::isExistingObject($this->element, 0, $this->ref); // Check ref is not yet used - if ($result > 0) - { - $this->error='ErrorRefAlreadyExists'; - dol_syslog(get_class($this)."::create ".$this->error, LOG_WARNING); - $this->db->rollback(); - return -1; - } - } + if (! empty($this->ref)) // We check that ref is not already used + { + $result=self::isExistingObject($this->element, 0, $this->ref); // Check ref is not yet used + if ($result > 0) + { + $this->error='ErrorRefAlreadyExists'; + dol_syslog(get_class($this)."::create ".$this->error, LOG_WARNING); + $this->db->rollback(); + return -1; + } + } - // Multicurrency - if (!empty($this->multicurrency_code)) list($this->fk_multicurrency,$this->multicurrency_tx) = MultiCurrency::getIdAndTxFromCode($this->db, $this->multicurrency_code); - if (empty($this->fk_multicurrency)) - { - $this->multicurrency_code = $conf->currency; - $this->fk_multicurrency = 0; - $this->multicurrency_tx = 1; - } + // Multicurrency + if (!empty($this->multicurrency_code)) list($this->fk_multicurrency,$this->multicurrency_tx) = MultiCurrency::getIdAndTxFromCode($this->db, $this->multicurrency_code); + if (empty($this->fk_multicurrency)) + { + $this->multicurrency_code = $conf->currency; + $this->fk_multicurrency = 0; + $this->multicurrency_tx = 1; + } $this->db->begin(); @@ -931,9 +931,9 @@ class SupplierProposal extends CommonObject $sql.= ", ".($this->shipping_method_id>0?$this->shipping_method_id:'NULL'); $sql.= ", ".($this->fk_project?$this->fk_project:"null"); $sql.= ", ".$conf->entity; - $sql.= ", ".(int) $this->fk_multicurrency; - $sql.= ", '".$this->db->escape($this->multicurrency_code)."'"; - $sql.= ", ".(double) $this->multicurrency_tx; + $sql.= ", ".(int) $this->fk_multicurrency; + $sql.= ", '".$this->db->escape($this->multicurrency_code)."'"; + $sql.= ", ".(double) $this->multicurrency_tx; $sql.= ")"; dol_syslog(get_class($this)."::create", LOG_DEBUG); @@ -953,34 +953,34 @@ class SupplierProposal extends CommonObject if (! empty($this->linkedObjectsIds) && empty($this->linked_objects)) // To use new linkedObjectsIds instead of old linked_objects { - $this->linked_objects = $this->linkedObjectsIds; // TODO Replace linked_objects with linkedObjectsIds + $this->linked_objects = $this->linkedObjectsIds; // TODO Replace linked_objects with linkedObjectsIds } // Add object linked if (! $error && $this->id && is_array($this->linked_objects) && ! empty($this->linked_objects)) { - foreach($this->linked_objects as $origin => $tmp_origin_id) - { - if (is_array($tmp_origin_id)) // New behaviour, if linked_object can have several links per type, so is something like array('contract'=>array(id1, id2, ...)) - { - foreach($tmp_origin_id as $origin_id) - { - $ret = $this->add_object_linked($origin, $origin_id); - if (! $ret) - { - dol_print_error($this->db); - $error++; - } - } - } - } + foreach($this->linked_objects as $origin => $tmp_origin_id) + { + if (is_array($tmp_origin_id)) // New behaviour, if linked_object can have several links per type, so is something like array('contract'=>array(id1, id2, ...)) + { + foreach($tmp_origin_id as $origin_id) + { + $ret = $this->add_object_linked($origin, $origin_id); + if (! $ret) + { + dol_print_error($this->db); + $error++; + } + } + } + } } // Add linked object (deprecated, use ->linkedObjectsIds instead) if (! $error && $this->origin && $this->origin_id) { - $ret = $this->add_object_linked(); - if (! $ret) dol_print_error($this->db); + $ret = $this->add_object_linked(); + if (! $ret) dol_print_error($this->db); } /* @@ -998,31 +998,31 @@ class SupplierProposal extends CommonObject $fk_parent_line = 0; } - $result = $this->addline( - $this->lines[$i]->desc, - $this->lines[$i]->subprice, - $this->lines[$i]->qty, - $this->lines[$i]->tva_tx, - $this->lines[$i]->localtax1_tx, - $this->lines[$i]->localtax2_tx, - $this->lines[$i]->fk_product, - $this->lines[$i]->remise_percent, - 'HT', - 0, - 0, - $this->lines[$i]->product_type, - $this->lines[$i]->rang, - $this->lines[$i]->special_code, - $fk_parent_line, - $this->lines[$i]->fk_fournprice, - $this->lines[$i]->pa_ht, - $this->lines[$i]->label, - $this->lines[$i]->array_options, - $this->lines[$i]->ref_fourn, - $this->lines[$i]->fk_unit, - 'supplier_proposal', - $this->lines[$i]->rowid - ); + $result = $this->addline( + $this->lines[$i]->desc, + $this->lines[$i]->subprice, + $this->lines[$i]->qty, + $this->lines[$i]->tva_tx, + $this->lines[$i]->localtax1_tx, + $this->lines[$i]->localtax2_tx, + $this->lines[$i]->fk_product, + $this->lines[$i]->remise_percent, + 'HT', + 0, + 0, + $this->lines[$i]->product_type, + $this->lines[$i]->rang, + $this->lines[$i]->special_code, + $fk_parent_line, + $this->lines[$i]->fk_fournprice, + $this->lines[$i]->pa_ht, + $this->lines[$i]->label, + $this->lines[$i]->array_options, + $this->lines[$i]->ref_fourn, + $this->lines[$i]->fk_unit, + 'supplier_proposal', + $this->lines[$i]->rowid + ); if ($result < 0) { @@ -1044,17 +1044,17 @@ class SupplierProposal extends CommonObject $resql=$this->update_price(1); if ($resql) { - $action='update'; + $action='update'; - // Actions on extra fields - if (! $error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) - { - $result=$this->insertExtraFields(); - if ($result < 0) - { - $error++; - } - } + // Actions on extra fields + if (! $error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) + { + $result=$this->insertExtraFields(); + if ($result < 0) + { + $error++; + } + } if (! $error && ! $notrigger) { @@ -1065,14 +1065,14 @@ class SupplierProposal extends CommonObject } } else - { + { $this->error=$this->db->lasterror(); $error++; } } } else - { + { $this->error=$this->db->lasterror(); $error++; } @@ -1098,7 +1098,7 @@ class SupplierProposal extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Insert into DB a supplier_proposal object completely defined by its data members (ex, results from copy). * @@ -1106,7 +1106,7 @@ class SupplierProposal extends CommonObject * @return int Id of the new object if ok, <0 if ko * @see create */ - function create_from($user) + public function create_from($user) { // phpcs:enable $this->products=$this->lines; @@ -1120,7 +1120,7 @@ class SupplierProposal extends CommonObject * @param int $socid Id of thirdparty * @return int New id of clone */ - function createFromClone($socid = 0) + public function createFromClone($socid = 0) { global $user,$langs,$conf,$hookmanager; @@ -1129,12 +1129,12 @@ class SupplierProposal extends CommonObject $this->db->begin(); - // get extrafields so they will be clone - foreach($this->lines as $line) - $line->fetch_optionals(); + // get extrafields so they will be clone + foreach($this->lines as $line) + $line->fetch_optionals(); - // Load source object - $objFrom = clone $this; + // Load source object + $objFrom = clone $this; $objsoc=new Societe($this->db); @@ -1215,7 +1215,7 @@ class SupplierProposal extends CommonObject * @param string $ref Ref of proposal * @return int >0 if OK, <0 if KO */ - function fetch($rowid, $ref = '') + public function fetch($rowid, $ref = '') { global $conf; @@ -1232,7 +1232,7 @@ class SupplierProposal extends CommonObject $sql.= ", p.fk_mode_reglement"; $sql.= ', p.fk_account'; $sql.= ", p.fk_shipping_method"; - $sql.= ", p.fk_multicurrency, p.multicurrency_code, p.multicurrency_tx, p.multicurrency_total_ht, p.multicurrency_total_tva, p.multicurrency_total_ttc"; + $sql.= ", p.fk_multicurrency, p.multicurrency_code, p.multicurrency_tx, p.multicurrency_total_ht, p.multicurrency_total_tva, p.multicurrency_total_ttc"; $sql.= ", c.label as statut_label"; $sql.= ", cr.code as cond_reglement_code, cr.libelle as cond_reglement, cr.libelle_facture as cond_reglement_libelle_doc"; $sql.= ", cp.code as mode_reglement_code, cp.libelle as mode_reglement"; @@ -1295,13 +1295,13 @@ class SupplierProposal extends CommonObject $this->user_valid_id = $obj->fk_user_valid; $this->user_close_id = $obj->fk_user_cloture; - // Multicurrency - $this->fk_multicurrency = $obj->fk_multicurrency; - $this->multicurrency_code = $obj->multicurrency_code; - $this->multicurrency_tx = $obj->multicurrency_tx; - $this->multicurrency_total_ht = $obj->multicurrency_total_ht; - $this->multicurrency_total_tva = $obj->multicurrency_total_tva; - $this->multicurrency_total_ttc = $obj->multicurrency_total_ttc; + // Multicurrency + $this->fk_multicurrency = $obj->fk_multicurrency; + $this->multicurrency_code = $obj->multicurrency_code; + $this->multicurrency_tx = $obj->multicurrency_tx; + $this->multicurrency_total_ht = $obj->multicurrency_total_ht; + $this->multicurrency_total_tva = $obj->multicurrency_total_tva; + $this->multicurrency_total_ttc = $obj->multicurrency_total_ttc; if ($obj->fk_statut == 0) { @@ -1318,10 +1318,10 @@ class SupplierProposal extends CommonObject // Lines of supplier proposals $sql = "SELECT d.rowid, d.fk_supplier_proposal, d.fk_parent_line, d.label as custom_label, d.description, d.price, d.tva_tx, d.localtax1_tx, d.localtax2_tx, d.qty, d.fk_remise_except, d.remise_percent, d.subprice, d.fk_product,"; - $sql.= " d.info_bits, d.total_ht, d.total_tva, d.total_localtax1, d.total_localtax2, d.total_ttc, d.fk_product_fournisseur_price as fk_fournprice, d.buy_price_ht as pa_ht, d.special_code, d.rang, d.product_type,"; + $sql.= " d.info_bits, d.total_ht, d.total_tva, d.total_localtax1, d.total_localtax2, d.total_ttc, d.fk_product_fournisseur_price as fk_fournprice, d.buy_price_ht as pa_ht, d.special_code, d.rang, d.product_type,"; $sql.= ' p.ref as product_ref, p.description as product_desc, p.fk_product_type, p.label as product_label,'; $sql.= ' d.ref_fourn as ref_produit_fourn,'; - $sql.= ' d.fk_multicurrency, d.multicurrency_code, d.multicurrency_subprice, d.multicurrency_total_ht, d.multicurrency_total_tva, d.multicurrency_total_ttc, d.fk_unit'; + $sql.= ' d.fk_multicurrency, d.multicurrency_code, d.multicurrency_subprice, d.multicurrency_total_ht, d.multicurrency_total_tva, d.multicurrency_total_ttc, d.fk_unit'; $sql.= " FROM ".MAIN_DB_PREFIX."supplier_proposaldet as d"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON d.fk_product = p.rowid"; $sql.= " WHERE d.fk_supplier_proposal = ".$this->id; @@ -1361,11 +1361,11 @@ class SupplierProposal extends CommonObject $line->total_localtax1 = $objp->total_localtax1; $line->total_localtax2 = $objp->total_localtax2; $line->total_ttc = $objp->total_ttc; - $line->fk_fournprice = $objp->fk_fournprice; - $marginInfos = getMarginInfos($objp->subprice, $objp->remise_percent, $objp->tva_tx, $objp->localtax1_tx, $objp->localtax2_tx, $line->fk_fournprice, $objp->pa_ht); - $line->pa_ht = $marginInfos[0]; - $line->marge_tx = $marginInfos[1]; - $line->marque_tx = $marginInfos[2]; + $line->fk_fournprice = $objp->fk_fournprice; + $marginInfos = getMarginInfos($objp->subprice, $objp->remise_percent, $objp->tva_tx, $objp->localtax1_tx, $objp->localtax2_tx, $line->fk_fournprice, $objp->pa_ht); + $line->pa_ht = $marginInfos[0]; + $line->marge_tx = $marginInfos[1]; + $line->marque_tx = $marginInfos[2]; $line->special_code = $objp->special_code; $line->rang = $objp->rang; @@ -1378,16 +1378,16 @@ class SupplierProposal extends CommonObject $line->product_desc = $objp->product_desc; // Description produit $line->fk_product_type = $objp->fk_product_type; - $line->ref_fourn = $objp->ref_produit_fourn; + $line->ref_fourn = $objp->ref_produit_fourn; - // Multicurrency - $line->fk_multicurrency = $objp->fk_multicurrency; - $line->multicurrency_code = $objp->multicurrency_code; - $line->multicurrency_subprice = $objp->multicurrency_subprice; - $line->multicurrency_total_ht = $objp->multicurrency_total_ht; - $line->multicurrency_total_tva = $objp->multicurrency_total_tva; - $line->multicurrency_total_ttc = $objp->multicurrency_total_ttc; - $line->fk_unit = $objp->fk_unit; + // Multicurrency + $line->fk_multicurrency = $objp->fk_multicurrency; + $line->multicurrency_code = $objp->multicurrency_code; + $line->multicurrency_subprice = $objp->multicurrency_subprice; + $line->multicurrency_total_ht = $objp->multicurrency_total_ht; + $line->multicurrency_total_tva = $objp->multicurrency_total_tva; + $line->multicurrency_total_ttc = $objp->multicurrency_total_ttc; + $line->fk_unit = $objp->fk_unit; $this->lines[$i] = $line; @@ -1425,17 +1425,17 @@ class SupplierProposal extends CommonObject * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int <0 if KO, >=0 if OK */ - function valid($user, $notrigger = 0) + public function valid($user, $notrigger = 0) { - require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - global $conf,$langs; + global $conf,$langs; $error=0; $now=dol_now(); if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->supplier_proposal->creer)) - || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->supplier_proposal->validate_advance))) + || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->supplier_proposal->validate_advance))) { $this->db->begin(); @@ -1446,11 +1446,11 @@ class SupplierProposal extends CommonObject // Define new ref if (! $error && (preg_match('/^[\(]?PROV/i', $this->ref) || empty($this->ref))) // empty should not happened, but when it occurs, the test save life { - $num = $this->getNextNumRef($soc); + $num = $this->getNextNumRef($soc); } else { - $num = $this->ref; + $num = $this->ref; } $this->newref = $num; @@ -1460,16 +1460,16 @@ class SupplierProposal extends CommonObject $sql.= " WHERE rowid = ".$this->id." AND fk_statut = 0"; dol_syslog(get_class($this)."::valid", LOG_DEBUG); - $resql=$this->db->query($sql); - if (! $resql) - { - dol_print_error($this->db); - $error++; - } + $resql=$this->db->query($sql); + if (! $resql) + { + dol_print_error($this->db); + $error++; + } - // Trigger calls - if (! $error && ! $notrigger) - { + // Trigger calls + if (! $error && ! $notrigger) + { // Call trigger $result=$this->call_trigger('SUPPLIER_PROPOSAL_VALIDATE', $user); if ($result < 0) { $error++; } @@ -1478,61 +1478,61 @@ class SupplierProposal extends CommonObject if (! $error) { - $this->oldref = $this->ref; + $this->oldref = $this->ref; - // Rename directory if dir was a temporary ref - if (preg_match('/^[\(]?PROV/i', $this->ref)) - { - // Rename of propal directory ($this->ref = old ref, $num = new ref) - // to not lose the linked files - $oldref = dol_sanitizeFileName($this->ref); - $newref = dol_sanitizeFileName($num); - $dirsource = $conf->supplier_proposal->dir_output.'/'.$oldref; - $dirdest = $conf->supplier_proposal->dir_output.'/'.$newref; + // Rename directory if dir was a temporary ref + if (preg_match('/^[\(]?PROV/i', $this->ref)) + { + // Rename of propal directory ($this->ref = old ref, $num = new ref) + // to not lose the linked files + $oldref = dol_sanitizeFileName($this->ref); + $newref = dol_sanitizeFileName($num); + $dirsource = $conf->supplier_proposal->dir_output.'/'.$oldref; + $dirdest = $conf->supplier_proposal->dir_output.'/'.$newref; - if (file_exists($dirsource)) - { - dol_syslog(get_class($this)."::validate rename dir ".$dirsource." into ".$dirdest); - if (@rename($dirsource, $dirdest)) - { - dol_syslog("Rename ok"); - // Rename docs starting with $oldref with $newref - $listoffiles=dol_dir_list($conf->supplier_proposal->dir_output.'/'.$newref, 'files', 1, '^'.preg_quote($oldref, '/')); - foreach($listoffiles as $fileentry) - { - $dirsource=$fileentry['name']; - $dirdest=preg_replace('/^'.preg_quote($oldref, '/').'/', $newref, $dirsource); - $dirsource=$fileentry['path'].'/'.$dirsource; - $dirdest=$fileentry['path'].'/'.$dirdest; - @rename($dirsource, $dirdest); - } - } - } - } + if (file_exists($dirsource)) + { + dol_syslog(get_class($this)."::validate rename dir ".$dirsource." into ".$dirdest); + if (@rename($dirsource, $dirdest)) + { + dol_syslog("Rename ok"); + // Rename docs starting with $oldref with $newref + $listoffiles=dol_dir_list($conf->supplier_proposal->dir_output.'/'.$newref, 'files', 1, '^'.preg_quote($oldref, '/')); + foreach($listoffiles as $fileentry) + { + $dirsource=$fileentry['name']; + $dirdest=preg_replace('/^'.preg_quote($oldref, '/').'/', $newref, $dirsource); + $dirsource=$fileentry['path'].'/'.$dirsource; + $dirdest=$fileentry['path'].'/'.$dirdest; + @rename($dirsource, $dirdest); + } + } + } + } - $this->ref=$num; - $this->brouillon=0; - $this->statut = 1; - $this->user_valid_id=$user->id; - $this->datev=$now; + $this->ref=$num; + $this->brouillon=0; + $this->statut = 1; + $this->user_valid_id=$user->id; + $this->datev=$now; - $this->db->commit(); - return 1; + $this->db->commit(); + return 1; } else - { - $this->db->rollback(); - return -1; + { + $this->db->rollback(); + return -1; } } else { - dol_syslog("You don't have permission to validate supplier proposal", LOG_WARNING); - return -2; + dol_syslog("You don't have permission to validate supplier proposal", LOG_WARNING); + return -2; } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Set delivery date * @@ -1540,7 +1540,7 @@ class SupplierProposal extends CommonObject * @param int $date_livraison Delivery date * @return int <0 if ko, >0 if ok */ - function set_date_livraison($user, $date_livraison) + public function set_date_livraison($user, $date_livraison) { // phpcs:enable if (! empty($user->rights->supplier_proposal->creer)) @@ -1563,7 +1563,7 @@ class SupplierProposal extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Set an overall discount on the proposal * @@ -1571,7 +1571,7 @@ class SupplierProposal extends CommonObject * @param double $remise Amount discount * @return int <0 if ko, >0 if ok */ - function set_remise_percent($user, $remise) + public function set_remise_percent($user, $remise) { // phpcs:enable $remise=trim($remise)?trim($remise):0; @@ -1598,7 +1598,7 @@ class SupplierProposal extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Set an absolute overall discount on the proposal * @@ -1606,7 +1606,7 @@ class SupplierProposal extends CommonObject * @param double $remise Amount discount * @return int <0 if ko, >0 if ok */ - function set_remise_absolue($user, $remise) + public function set_remise_absolue($user, $remise) { // phpcs:enable $remise=trim($remise)?trim($remise):0; @@ -1644,7 +1644,7 @@ class SupplierProposal extends CommonObject * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int <0 if KO, >0 if OK */ - function reopen($user, $statut, $note = '', $notrigger = 0) + public function reopen($user, $statut, $note = '', $notrigger = 0) { global $langs,$conf; @@ -1653,47 +1653,47 @@ class SupplierProposal extends CommonObject $sql = "UPDATE ".MAIN_DB_PREFIX."supplier_proposal"; $sql.= " SET fk_statut = ".$this->statut.","; - if (! empty($note)) $sql.= " note_private = '".$this->db->escape($note)."',"; + if (! empty($note)) $sql.= " note_private = '".$this->db->escape($note)."',"; $sql.= " date_cloture=NULL, fk_user_cloture=NULL"; $sql.= " WHERE rowid = ".$this->id; - $this->db->begin(); + $this->db->begin(); - dol_syslog(get_class($this)."::reopen", LOG_DEBUG); - $resql = $this->db->query($sql); - if (! $resql) { - $error++; $this->errors[]="Error ".$this->db->lasterror(); - } - if (! $error) - { - if (! $notrigger) - { + dol_syslog(get_class($this)."::reopen", LOG_DEBUG); + $resql = $this->db->query($sql); + if (! $resql) { + $error++; $this->errors[]="Error ".$this->db->lasterror(); + } + if (! $error) + { + if (! $notrigger) + { // Call trigger $result=$this->call_trigger('SUPPLIER_PROPOSAL_REOPEN', $user); if ($result < 0) { $error++; } // End call triggers - } - } + } + } - // Commit or rollback - if ($error) - { - if (!empty($this->errors)) - { - foreach($this->errors as $errmsg) - { - dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR); - $this->error.=($this->error?', '.$errmsg:$errmsg); - } - } - $this->db->rollback(); - return -1*$error; - } - else - { - $this->db->commit(); - return 1; - } + // Commit or rollback + if ($error) + { + if (!empty($this->errors)) + { + foreach($this->errors as $errmsg) + { + dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR); + $this->error.=($this->error?', '.$errmsg:$errmsg); + } + } + $this->db->rollback(); + return -1*$error; + } + else + { + $this->db->commit(); + return 1; + } } @@ -1705,7 +1705,7 @@ class SupplierProposal extends CommonObject * @param string $note Comment * @return int <0 if KO, >0 if OK */ - function cloture($user, $statut, $note) + public function cloture($user, $statut, $note) { global $langs,$conf; @@ -1722,13 +1722,13 @@ class SupplierProposal extends CommonObject $resql=$this->db->query($sql); if ($resql) { - $modelpdf=$conf->global->SUPPLIER_PROPOSAL_ADDON_PDF_ODT_CLOSED?$conf->global->SUPPLIER_PROPOSAL_ADDON_PDF_ODT_CLOSED:$this->modelpdf; - $trigger_name='SUPPLIER_PROPOSAL_CLOSE_REFUSED'; + $modelpdf=$conf->global->SUPPLIER_PROPOSAL_ADDON_PDF_ODT_CLOSED?$conf->global->SUPPLIER_PROPOSAL_ADDON_PDF_ODT_CLOSED:$this->modelpdf; + $trigger_name='SUPPLIER_PROPOSAL_CLOSE_REFUSED'; if ($statut == 2) { - $trigger_name='SUPPLIER_PROPOSAL_CLOSE_SIGNED'; - $modelpdf=$conf->global->SUPPLIER_PROPOSAL_ADDON_PDF_ODT_TOBILL?$conf->global->SUPPLIER_PROPOSAL_ADDON_PDF_ODT_TOBILL:$this->modelpdf; + $trigger_name='SUPPLIER_PROPOSAL_CLOSE_SIGNED'; + $modelpdf=$conf->global->SUPPLIER_PROPOSAL_ADDON_PDF_ODT_TOBILL?$conf->global->SUPPLIER_PROPOSAL_ADDON_PDF_ODT_TOBILL:$this->modelpdf; if (! empty($conf->global->SUPPLIER_PROPOSAL_UPDATE_PRICE_ON_SUPPlIER_PROPOSAL)) // TODO This option was not tested correctly. Error if product ref does not exists { @@ -1737,21 +1737,21 @@ class SupplierProposal extends CommonObject } if ($statut == 4) { - $trigger_name='SUPPLIER_PROPOSAL_CLASSIFY_BILLED'; + $trigger_name='SUPPLIER_PROPOSAL_CLASSIFY_BILLED'; } if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { - // Define output language - $outputlangs = $langs; - if (! empty($conf->global->MAIN_MULTILANGS)) - { - $outputlangs = new Translate("", $conf); - $newlang=(GETPOST('lang_id', 'aZ09') ? GETPOST('lang_id', 'aZ09') : $this->thirdparty->default_lang); - $outputlangs->setDefaultLang($newlang); - } - //$ret=$object->fetch($id); // Reload to get new records - $this->generateDocument($modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); + // Define output language + $outputlangs = $langs; + if (! empty($conf->global->MAIN_MULTILANGS)) + { + $outputlangs = new Translate("", $conf); + $newlang=(GETPOST('lang_id', 'aZ09') ? GETPOST('lang_id', 'aZ09') : $this->thirdparty->default_lang); + $outputlangs->setDefaultLang($newlang); + } + //$ret=$object->fetch($id); // Reload to get new records + $this->generateDocument($modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); } // Call trigger @@ -1779,97 +1779,97 @@ class SupplierProposal extends CommonObject } } - /** + /** * Add or update supplier price according to result of proposal * - * @param User $user Object user - * @return int > 0 if OK + * @param User $user Object user + * @return int > 0 if OK */ - function updateOrCreatePriceFournisseur($user) - { - $productsupplier = new ProductFournisseur($this->db); + public function updateOrCreatePriceFournisseur($user) + { + $productsupplier = new ProductFournisseur($this->db); - dol_syslog(get_class($this)."::updateOrCreatePriceFournisseur", LOG_DEBUG); - foreach ($this->lines as $product) - { - if ($product->subprice <= 0) continue; + dol_syslog(get_class($this)."::updateOrCreatePriceFournisseur", LOG_DEBUG); + foreach ($this->lines as $product) + { + if ($product->subprice <= 0) continue; - $idProductFourn = $productsupplier->find_min_price_product_fournisseur($product->fk_product, $product->qty); - $res = $productsupplier->fetch($idProductFourn); + $idProductFourn = $productsupplier->find_min_price_product_fournisseur($product->fk_product, $product->qty); + $res = $productsupplier->fetch($idProductFourn); - if ($productsupplier->id) { - if ($productsupplier->fourn_qty == $product->qty) { - $this->updatePriceFournisseur($productsupplier->product_fourn_price_id, $product, $user); - } else { - $this->createPriceFournisseur($product, $user); - } - } else { - $this->createPriceFournisseur($product, $user); - } - } + if ($productsupplier->id) { + if ($productsupplier->fourn_qty == $product->qty) { + $this->updatePriceFournisseur($productsupplier->product_fourn_price_id, $product, $user); + } else { + $this->createPriceFournisseur($product, $user); + } + } else { + $this->createPriceFournisseur($product, $user); + } + } - return 1; - } + return 1; + } - /** + /** * Upate ProductFournisseur * - * @param int $idProductFournPrice id of llx_product_fournisseur_price - * @param Product $product contain informations to update - * @param User $user Object user + * @param int $idProductFournPrice id of llx_product_fournisseur_price + * @param Product $product contain informations to update + * @param User $user Object user * @return int <0 if KO, >0 if OK */ - function updatePriceFournisseur($idProductFournPrice, $product, $user) + public function updatePriceFournisseur($idProductFournPrice, $product, $user) { - $price=price2num($product->subprice*$product->qty, 'MU'); - $unitPrice = price2num($product->subprice, 'MU'); + $price=price2num($product->subprice*$product->qty, 'MU'); + $unitPrice = price2num($product->subprice, 'MU'); - $sql = 'UPDATE '.MAIN_DB_PREFIX.'product_fournisseur_price SET '.(!empty($product->ref_fourn) ? 'ref_fourn = "'.$product->ref_fourn.'", ' : '').' price ='.$price.', unitprice ='.$unitPrice.' WHERE rowid = '.$idProductFournPrice; + $sql = 'UPDATE '.MAIN_DB_PREFIX.'product_fournisseur_price SET '.(!empty($product->ref_fourn) ? 'ref_fourn = "'.$product->ref_fourn.'", ' : '').' price ='.$price.', unitprice ='.$unitPrice.' WHERE rowid = '.$idProductFournPrice; - $resql = $this->db->query($sql); - if (!$resql) { - $this->error=$this->db->error(); + $resql = $this->db->query($sql); + if (!$resql) { + $this->error=$this->db->error(); $this->db->rollback(); return -1; - } - } + } + } - /** + /** * Create ProductFournisseur - * + * * @param Product $product Object Product - * @param User $user Object user + * @param User $user Object user * @return int <0 if KO, >0 if OK */ - function createPriceFournisseur($product, $user) + public function createPriceFournisseur($product, $user) { - $price=price2num($product->subprice*$product->qty, 'MU'); - $qty=price2num($product->qty); - $unitPrice = price2num($product->subprice, 'MU'); - $now=dol_now(); + $price=price2num($product->subprice*$product->qty, 'MU'); + $qty=price2num($product->qty); + $unitPrice = price2num($product->subprice, 'MU'); + $now=dol_now(); - $values = array( - "'".$this->db->idate($now)."'", - $product->fk_product, - $this->thirdparty->id, - "'".$product->ref_fourn."'", - $price, - $qty, - $unitPrice, - $product->tva_tx, - $user->id - ); + $values = array( + "'".$this->db->idate($now)."'", + $product->fk_product, + $this->thirdparty->id, + "'".$product->ref_fourn."'", + $price, + $qty, + $unitPrice, + $product->tva_tx, + $user->id + ); - $sql = 'INSERT INTO '.MAIN_DB_PREFIX.'product_fournisseur_price '; - $sql .= '(datec, fk_product, fk_soc, ref_fourn, price, quantity, unitprice, tva_tx, fk_user) VALUES ('.implode(',', $values).')'; + $sql = 'INSERT INTO '.MAIN_DB_PREFIX.'product_fournisseur_price '; + $sql .= '(datec, fk_product, fk_soc, ref_fourn, price, quantity, unitprice, tva_tx, fk_user) VALUES ('.implode(',', $values).')'; - $resql = $this->db->query($sql); - if (!$resql) { - $this->error=$this->db->error(); + $resql = $this->db->query($sql); + if (!$resql) { + $this->error=$this->db->error(); $this->db->rollback(); return -1; - } - } + } + } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps /** @@ -1878,7 +1878,7 @@ class SupplierProposal extends CommonObject * @param User $user Object user that modify * @return int <0 if KO, >0 if OK */ - function set_draft($user) + public function set_draft($user) { // phpcs:enable global $conf,$langs; @@ -1899,7 +1899,7 @@ class SupplierProposal extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of askprice (eventually filtered on user) into an array * @@ -1913,7 +1913,7 @@ class SupplierProposal extends CommonObject * @param string $sortorder Sort order * @return int -1 if KO, array with result if OK */ - function liste_array($shortlist = 0, $draft = 0, $notcurrentuser = 0, $socid = 0, $limit = 0, $offset = 0, $sortfield = 'p.datec', $sortorder = 'DESC') + public function liste_array($shortlist = 0, $draft = 0, $notcurrentuser = 0, $socid = 0, $limit = 0, $offset = 0, $sortfield = 'p.datec', $sortorder = 'DESC') { // phpcs:enable global $conf,$user; @@ -1925,13 +1925,13 @@ class SupplierProposal extends CommonObject $sql.= " p.datep as dp, p.fin_validite as datelimite"; if (! $user->rights->societe->client->voir && ! $socid) $sql .= ", sc.fk_soc, sc.fk_user"; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."supplier_proposal as p, ".MAIN_DB_PREFIX."c_propalst as c"; - if (! $user->rights->societe->client->voir && ! $socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + if (! $user->rights->societe->client->voir && ! $socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= " WHERE p.entity IN (".getEntity('supplier_proposal').")"; $sql.= " AND p.fk_soc = s.rowid"; $sql.= " AND p.fk_statut = c.id"; if (! $user->rights->societe->client->voir && ! $socid) //restriction { - $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; + $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; } if ($socid) $sql.= " AND s.rowid = ".$socid; if ($draft) $sql.= " AND p.fk_statut = 0"; @@ -1959,7 +1959,7 @@ class SupplierProposal extends CommonObject $ga[$obj->supplier_proposalid] = $obj->ref.' ('.$obj->name.')'; } else - { + { $ga[$i]['id'] = $obj->supplier_proposalid; $ga[$i]['ref'] = $obj->ref; $ga[$i]['name'] = $obj->name; @@ -2029,7 +2029,7 @@ class SupplierProposal extends CommonObject { $this->error='ErrorFailToDeleteFile'; $this->errors=array('ErrorFailToDeleteFile'); - $this->db->rollback(); + $this->db->rollback(); return 0; } } @@ -2050,16 +2050,16 @@ class SupplierProposal extends CommonObject // Removed extrafields if (! $error) { - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used - { - $result=$this->deleteExtraFields(); - if ($result < 0) - { - $error++; - $errorflag=-4; - dol_syslog(get_class($this)."::delete erreur ".$errorflag." ".$this->error, LOG_ERR); - } - } + if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used + { + $result=$this->deleteExtraFields(); + if ($result < 0) + { + $error++; + $errorflag=-4; + dol_syslog(get_class($this)."::delete erreur ".$errorflag." ".$this->error, LOG_ERR); + } + } } if (! $error) @@ -2102,7 +2102,7 @@ class SupplierProposal extends CommonObject * @param int $id Proposal id * @return void */ - function info($id) + public function info($id) { $sql = "SELECT c.rowid, "; $sql.= " c.datec, c.date_valid as datev, c.date_cloture as dateo,"; @@ -2157,12 +2157,12 @@ class SupplierProposal 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 * @return string Label */ - function getLibStatut($mode = 0) + public function getLibStatut($mode = 0) { return $this->LibStatut($this->statut, $mode); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return label of a status (draft, validated, ...) * @@ -2170,44 +2170,44 @@ class SupplierProposal 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 * @return string Label */ - function LibStatut($statut, $mode = 1) + public function LibStatut($statut, $mode = 1) { // phpcs:enable - // Init/load array of translation of status - if (empty($this->labelstatut) || empty($this->labelstatut_short)) - { - global $langs; - $langs->load("supplier_proposal"); - $this->labelstatut[0]=$langs->trans("SupplierProposalStatusDraft"); - $this->labelstatut[1]=$langs->trans("SupplierProposalStatusValidated"); - $this->labelstatut[2]=$langs->trans("SupplierProposalStatusSigned"); - $this->labelstatut[3]=$langs->trans("SupplierProposalStatusNotSigned"); - $this->labelstatut[4]=$langs->trans("SupplierProposalStatusClosed"); - $this->labelstatut_short[0]=$langs->trans("SupplierProposalStatusDraftShort"); - $this->labelstatut_short[1]=$langs->trans("Opened"); - $this->labelstatut_short[2]=$langs->trans("SupplierProposalStatusSignedShort"); - $this->labelstatut_short[3]=$langs->trans("SupplierProposalStatusNotSignedShort"); - $this->labelstatut_short[4]=$langs->trans("SupplierProposalStatusClosedShort"); - } + // Init/load array of translation of status + if (empty($this->labelstatut) || empty($this->labelstatut_short)) + { + global $langs; + $langs->load("supplier_proposal"); + $this->labelstatut[0]=$langs->trans("SupplierProposalStatusDraft"); + $this->labelstatut[1]=$langs->trans("SupplierProposalStatusValidated"); + $this->labelstatut[2]=$langs->trans("SupplierProposalStatusSigned"); + $this->labelstatut[3]=$langs->trans("SupplierProposalStatusNotSigned"); + $this->labelstatut[4]=$langs->trans("SupplierProposalStatusClosed"); + $this->labelstatut_short[0]=$langs->trans("SupplierProposalStatusDraftShort"); + $this->labelstatut_short[1]=$langs->trans("Opened"); + $this->labelstatut_short[2]=$langs->trans("SupplierProposalStatusSignedShort"); + $this->labelstatut_short[3]=$langs->trans("SupplierProposalStatusNotSignedShort"); + $this->labelstatut_short[4]=$langs->trans("SupplierProposalStatusClosedShort"); + } - $statuttrans=''; - if ($statut==0) $statuttrans='statut0'; - elseif ($statut==1) $statuttrans='statut1'; - elseif ($statut==2) $statuttrans='statut3'; - elseif ($statut==3) $statuttrans='statut5'; - elseif ($statut==4) $statuttrans='statut6'; + $statuttrans=''; + if ($statut==0) $statuttrans='statut0'; + elseif ($statut==1) $statuttrans='statut1'; + elseif ($statut==2) $statuttrans='statut3'; + elseif ($statut==3) $statuttrans='statut5'; + elseif ($statut==4) $statuttrans='statut6'; - if ($mode == 0) return $this->labelstatut[$statut]; - elseif ($mode == 1) return $this->labelstatut_short[$statut]; - elseif ($mode == 2) return img_picto($this->labelstatut[$statut], $statuttrans).' '.$this->labelstatut_short[$statut]; - elseif ($mode == 3) return img_picto($this->labelstatut[$statut], $statuttrans); - elseif ($mode == 4) return img_picto($this->labelstatut[$statut], $statuttrans).' '.$this->labelstatut[$statut]; - elseif ($mode == 5) return ''.$this->labelstatut_short[$statut].' '.img_picto($this->labelstatut[$statut], $statuttrans); - elseif ($mode == 6) return ''.$this->labelstatut[$statut].' '.img_picto($this->labelstatut[$statut], $statuttrans); - } + if ($mode == 0) return $this->labelstatut[$statut]; + elseif ($mode == 1) return $this->labelstatut_short[$statut]; + elseif ($mode == 2) return img_picto($this->labelstatut[$statut], $statuttrans).' '.$this->labelstatut_short[$statut]; + elseif ($mode == 3) return img_picto($this->labelstatut[$statut], $statuttrans); + elseif ($mode == 4) return img_picto($this->labelstatut[$statut], $statuttrans).' '.$this->labelstatut[$statut]; + elseif ($mode == 5) return ''.$this->labelstatut_short[$statut].' '.img_picto($this->labelstatut[$statut], $statuttrans); + elseif ($mode == 6) return ''.$this->labelstatut[$statut].' '.img_picto($this->labelstatut[$statut], $statuttrans); + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load indicators for dashboard (this->nbtodo and this->nbtodolate) * @@ -2215,7 +2215,7 @@ class SupplierProposal extends CommonObject * @param int $mode "opened" for askprice to close, "signed" for proposal to invoice * @return int <0 if KO, >0 if OK */ - function load_board($user, $mode) + public function load_board($user, $mode) { // phpcs:enable global $conf, $user, $langs; @@ -2242,21 +2242,21 @@ class SupplierProposal extends CommonObject if ($resql) { if ($mode == 'opened') { - $delay_warning=$conf->supplier_proposal->cloture->warning_delay; - $statut = self::STATUS_VALIDATED; - $label = $langs->trans("SupplierProposalsToClose"); + $delay_warning=$conf->supplier_proposal->cloture->warning_delay; + $statut = self::STATUS_VALIDATED; + $label = $langs->trans("SupplierProposalsToClose"); } if ($mode == 'signed') { - $delay_warning=$conf->supplier_proposal->facturation->warning_delay; - $statut = self::STATUS_SIGNED; - $label = $langs->trans("SupplierProposalsToProcess"); // May be billed or ordered + $delay_warning=$conf->supplier_proposal->facturation->warning_delay; + $statut = self::STATUS_SIGNED; + $label = $langs->trans("SupplierProposalsToProcess"); // May be billed or ordered } - $response = new WorkboardResponse(); - $response->warning_delay = $delay_warning/60/60/24; - $response->label = $label; - $response->url = DOL_URL_ROOT.'/supplier_proposal/list.php?viewstatut='.$statut; - $response->img = img_object('', "propal"); + $response = new WorkboardResponse(); + $response->warning_delay = $delay_warning/60/60/24; + $response->label = $label; + $response->url = DOL_URL_ROOT.'/supplier_proposal/list.php?viewstatut='.$statut; + $response->img = img_object('', "propal"); // This assignment in condition is not a bug. It allows walking the results. while ($obj=$this->db->fetch_object($resql)) @@ -2290,7 +2290,7 @@ class SupplierProposal extends CommonObject * * @return void */ - function initAsSpecimen() + public function initAsSpecimen() { global $user,$langs,$conf; @@ -2355,8 +2355,8 @@ class SupplierProposal extends CommonObject if ($num_prods > 0) { - $prodid = mt_rand(1, $num_prods); - $line->fk_product=$prodids[$prodid]; + $prodid = mt_rand(1, $num_prods); + $line->fk_product=$prodids[$prodid]; } $this->lines[$xnbp]=$line; @@ -2369,13 +2369,13 @@ class SupplierProposal extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Charge indicateurs this->nb de tableau de bord * * @return int <0 if ko, >0 if ok */ - function load_state_board() + public function load_state_board() { // phpcs:enable global $conf, $user; @@ -2421,14 +2421,14 @@ class SupplierProposal extends CommonObject * @param Societe $soc Object thirdparty * @return string Reference libre pour la propale */ - function getNextNumRef($soc) + public function getNextNumRef($soc) { global $conf, $db, $langs; $langs->load("supplier_proposal"); if (! empty($conf->global->SUPPLIER_PROPOSAL_ADDON)) { - $mybool=false; + $mybool=false; $file = $conf->global->SUPPLIER_PROPOSAL_ADDON.".php"; $classname = $conf->global->SUPPLIER_PROPOSAL_ADDON; @@ -2445,8 +2445,8 @@ class SupplierProposal extends CommonObject if (! $mybool) { - dol_print_error('', "Failed to include file ".$file); - return ''; + dol_print_error('', "Failed to include file ".$file); + return ''; } $obj = new $classname(); @@ -2458,13 +2458,13 @@ class SupplierProposal extends CommonObject return $numref; } else - { + { $this->error=$obj->error; return ""; } } else - { + { $langs->load("errors"); print $langs->trans("Error")." ".$langs->trans("ErrorModuleSetupNotComplete"); return ""; @@ -2481,7 +2481,7 @@ class SupplierProposal extends CommonObject * @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 */ - function getNomUrl($withpicto = 0, $option = '', $get_params = '', $notooltip = 0, $save_lastsearch_value = -1) + public function getNomUrl($withpicto = 0, $option = '', $get_params = '', $notooltip = 0, $save_lastsearch_value = -1) { global $langs, $conf, $user; @@ -2510,10 +2510,10 @@ class SupplierProposal extends CommonObject if ($option !== 'nolink') { - // Add param to save lastsearch_values or not - $add_save_lastsearch_values=($save_lastsearch_value == 1 ? 1 : 0); - if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values=1; - if ($add_save_lastsearch_values) $url.='&save_lastsearch_values=1'; + // Add param to save lastsearch_values or not + $add_save_lastsearch_values=($save_lastsearch_value == 1 ? 1 : 0); + if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values=1; + if ($add_save_lastsearch_values) $url.='&save_lastsearch_values=1'; } $linkclose=''; @@ -2544,10 +2544,10 @@ class SupplierProposal extends CommonObject /** * Retrieve an array of supplier proposal lines - * - * @return int >0 if OK, <0 if KO + * + * @return int >0 if OK, <0 if KO */ - function getLinesArray() + public function getLinesArray() { // For other object, here we call fetch_lines. But fetch_lines does not exists on supplier proposal @@ -2557,7 +2557,7 @@ class SupplierProposal extends CommonObject $sql.= ' pt.product_type, pt.rang, pt.fk_parent_line,'; $sql.= ' p.label as product_label, p.ref, p.fk_product_type, p.rowid as prodid,'; $sql.= ' p.description as product_desc, pt.ref_fourn as ref_supplier,'; - $sql.= ' pt.fk_multicurrency, pt.multicurrency_code, pt.multicurrency_subprice, pt.multicurrency_total_ht, pt.multicurrency_total_tva, pt.multicurrency_total_ttc, pt.fk_unit'; + $sql.= ' pt.fk_multicurrency, pt.multicurrency_code, pt.multicurrency_subprice, pt.multicurrency_total_ht, pt.multicurrency_total_tva, pt.multicurrency_total_ttc, pt.fk_unit'; $sql.= ' FROM '.MAIN_DB_PREFIX.'supplier_proposaldet as pt'; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON pt.fk_product=p.rowid'; $sql.= ' WHERE pt.fk_supplier_proposal = '.$this->id; @@ -2594,26 +2594,26 @@ class SupplierProposal extends CommonObject $this->lines[$i]->total_ht = $obj->total_ht; $this->lines[$i]->total_tva = $obj->total_tva; $this->lines[$i]->total_ttc = $obj->total_ttc; - $this->lines[$i]->fk_fournprice = $obj->fk_fournprice; - $marginInfos = getMarginInfos($obj->subprice, $obj->remise_percent, $obj->tva_tx, $obj->localtax1_tx, $obj->localtax2_tx, $this->lines[$i]->fk_fournprice, $obj->pa_ht); - $this->lines[$i]->pa_ht = $marginInfos[0]; - $this->lines[$i]->marge_tx = $marginInfos[1]; - $this->lines[$i]->marque_tx = $marginInfos[2]; - $this->lines[$i]->fk_parent_line = $obj->fk_parent_line; + $this->lines[$i]->fk_fournprice = $obj->fk_fournprice; + $marginInfos = getMarginInfos($obj->subprice, $obj->remise_percent, $obj->tva_tx, $obj->localtax1_tx, $obj->localtax2_tx, $this->lines[$i]->fk_fournprice, $obj->pa_ht); + $this->lines[$i]->pa_ht = $marginInfos[0]; + $this->lines[$i]->marge_tx = $marginInfos[1]; + $this->lines[$i]->marque_tx = $marginInfos[2]; + $this->lines[$i]->fk_parent_line = $obj->fk_parent_line; $this->lines[$i]->special_code = $obj->special_code; $this->lines[$i]->rang = $obj->rang; $this->lines[$i]->ref_fourn = $obj->ref_supplier; // deprecated $this->lines[$i]->ref_supplier = $obj->ref_supplier; - // Multicurrency - $this->lines[$i]->fk_multicurrency = $obj->fk_multicurrency; - $this->lines[$i]->multicurrency_code = $obj->multicurrency_code; - $this->lines[$i]->multicurrency_subprice = $obj->multicurrency_subprice; - $this->lines[$i]->multicurrency_total_ht = $obj->multicurrency_total_ht; - $this->lines[$i]->multicurrency_total_tva = $obj->multicurrency_total_tva; - $this->lines[$i]->multicurrency_total_ttc = $obj->multicurrency_total_ttc; - $this->lines[$i]->fk_unit = $obj->fk_unit; + // Multicurrency + $this->lines[$i]->fk_multicurrency = $obj->fk_multicurrency; + $this->lines[$i]->multicurrency_code = $obj->multicurrency_code; + $this->lines[$i]->multicurrency_subprice = $obj->multicurrency_subprice; + $this->lines[$i]->multicurrency_total_ht = $obj->multicurrency_total_ht; + $this->lines[$i]->multicurrency_total_tva = $obj->multicurrency_total_tva; + $this->lines[$i]->multicurrency_total_ttc = $obj->multicurrency_total_ttc; + $this->lines[$i]->fk_unit = $obj->fk_unit; $i++; } @@ -2628,56 +2628,56 @@ class SupplierProposal extends CommonObject } } - /** - * Create a document onto disk according to template module. - * - * @param string $modele Force model to use ('' to not force) - * @param Translate $outputlangs Object langs to use for output - * @param int $hidedetails Hide details of lines - * @param int $hidedesc Hide description - * @param int $hideref Hide ref + /** + * Create a document onto disk according to template module. + * + * @param string $modele Force model to use ('' to not force) + * @param Translate $outputlangs Object langs to use for output + * @param int $hidedetails Hide details of lines + * @param int $hidedesc Hide description + * @param int $hideref Hide ref * @param null|array $moreparams Array to provide more information - * @return int 0 if KO, 1 if OK - */ - public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0, $moreparams = null) - { - global $conf, $langs; + * @return int 0 if KO, 1 if OK + */ + public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0, $moreparams = null) + { + global $conf, $langs; - $langs->load("supplier_proposal"); + $langs->load("supplier_proposal"); - if (! dol_strlen($modele)) { + if (! dol_strlen($modele)) { - $modele = 'aurore'; + $modele = 'aurore'; - if ($this->modelpdf) { - $modele = $this->modelpdf; - } elseif (! empty($conf->global->SUPPLIER_PROPOSAL_ADDON_PDF)) { - $modele = $conf->global->SUPPLIER_PROPOSAL_ADDON_PDF; - } - } + if ($this->modelpdf) { + $modele = $this->modelpdf; + } elseif (! empty($conf->global->SUPPLIER_PROPOSAL_ADDON_PDF)) { + $modele = $conf->global->SUPPLIER_PROPOSAL_ADDON_PDF; + } + } - $modelpath = "core/modules/supplier_proposal/doc/"; + $modelpath = "core/modules/supplier_proposal/doc/"; - return $this->commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams); - } + return $this->commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams); + } - /** - * Function used to replace a thirdparty id with another one. - * - * @param DoliDB $db Database handler - * @param int $origin_id Old thirdparty id - * @param int $dest_id New thirdparty id - * @return bool - */ - public static function replaceThirdparty(DoliDB $db, $origin_id, $dest_id) - { - $tables = array( - 'supplier_proposal' - ); + /** + * Function used to replace a thirdparty id with another one. + * + * @param DoliDB $db Database handler + * @param int $origin_id Old thirdparty id + * @param int $dest_id New thirdparty id + * @return bool + */ + public static function replaceThirdparty(DoliDB $db, $origin_id, $dest_id) + { + $tables = array( + 'supplier_proposal' + ); - return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables); - } + return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables); + } } @@ -2692,19 +2692,19 @@ class SupplierProposalLine extends CommonObjectLine public $db; /** - * @var string Error code (or message) - */ - public $error=''; + * @var string Error code (or message) + */ + public $error=''; /** - * @var string ID to identify managed object - */ - public $element='supplier_proposaldet'; + * @var string ID to identify managed object + */ + public $element='supplier_proposaldet'; /** - * @var string Name of table without prefix where object is stored - */ - public $table_element='supplier_proposaldet'; + * @var string Name of table without prefix where object is stored + */ + public $table_element='supplier_proposaldet'; public $oldline; @@ -2712,11 +2712,11 @@ class SupplierProposalLine extends CommonObjectLine public $rowid; // deprecated /** - * @var int ID - */ - public $id; + * @var int ID + */ + public $id; - /** + /** * @var int ID */ public $fk_supplier_proposal; @@ -2733,16 +2733,16 @@ class SupplierProposalLine extends CommonObjectLine */ public $fk_product; // Id produit predefini - /** - * @deprecated - * @see product_type - */ - public $fk_product_type; - /** - * Product type - * @var int - * @see Product::TYPE_PRODUCT, Product::TYPE_SERVICE - */ + /** + * @deprecated + * @see product_type + */ + public $fk_product_type; + /** + * Product type + * @var int + * @see Product::TYPE_PRODUCT, Product::TYPE_SERVICE + */ public $product_type = Product::TYPE_PRODUCT; public $qty; @@ -2760,11 +2760,11 @@ class SupplierProposalLine extends CommonObjectLine /** * @var int ID */ - public $fk_fournprice; + public $fk_fournprice; - public $pa_ht; - public $marge_tx; - public $marque_tx; + public $pa_ht; + public $marge_tx; + public $marque_tx; public $special_code; // Tag for special lines (exlusive tags) // 1: frais de port @@ -2779,53 +2779,53 @@ class SupplierProposalLine extends CommonObjectLine public $total_tva; // Total TVA de la ligne toute quantite et incluant la remise ligne public $total_ttc; // Total TTC de la ligne toute quantite et incluant la remise ligne - /** - * @deprecated - * @see remise_percent, fk_remise_except - */ + /** + * @deprecated + * @see remise_percent, fk_remise_except + */ public $remise; - /** - * @deprecated - * @see subprice - */ + /** + * @deprecated + * @see subprice + */ public $price; // From llx_product - /** - * @deprecated - * @see product_ref - */ - public $ref; + /** + * @deprecated + * @see product_ref + */ + public $ref; - /** - * Product reference - * @var string - */ - public $product_ref; + /** + * Product reference + * @var string + */ + public $product_ref; - /** - * @deprecated - * @see product_label - */ - public $libelle; + /** + * @deprecated + * @see product_label + */ + public $libelle; - /** - * Product label - * @var string - */ - public $product_label; + /** + * Product label + * @var string + */ + public $product_label; - /** - * Product description - * @var string - */ - public $product_desc; + /** + * Product description + * @var string + */ + public $product_desc; public $localtax1_tx; // Local tax 1 public $localtax2_tx; // Local tax 2 public $localtax1_type; // Local tax 1 type - public $localtax2_type; // Local tax 2 type + public $localtax2_type; // Local tax 2 type public $total_localtax1; // Line total local tax 1 public $total_localtax2; // Line total local tax 2 @@ -2834,24 +2834,24 @@ class SupplierProposalLine extends CommonObjectLine public $ref_fourn; public $ref_supplier; - // Multicurrency - /** + // Multicurrency + /** * @var int ID */ - public $fk_multicurrency; + public $fk_multicurrency; - public $multicurrency_code; - public $multicurrency_subprice; - public $multicurrency_total_ht; - public $multicurrency_total_tva; - public $multicurrency_total_ttc; + public $multicurrency_code; + public $multicurrency_subprice; + public $multicurrency_total_ht; + public $multicurrency_total_tva; + public $multicurrency_total_ttc; /** * Class line Contructor * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db= $db; } @@ -2862,79 +2862,79 @@ class SupplierProposalLine extends CommonObjectLine * @param int $rowid Propal line id * @return int <0 if KO, >0 if OK */ - function fetch($rowid) - { - $sql = 'SELECT pd.rowid, pd.fk_supplier_proposal, pd.fk_parent_line, pd.fk_product, pd.label as custom_label, pd.description, pd.price, pd.qty, pd.tva_tx,'; - $sql.= ' pd.remise, pd.remise_percent, pd.fk_remise_except, pd.subprice,'; - $sql.= ' pd.info_bits, pd.total_ht, pd.total_tva, pd.total_ttc, pd.fk_product_fournisseur_price as fk_fournprice, pd.buy_price_ht as pa_ht, pd.special_code, pd.rang,'; - $sql.= ' pd.localtax1_tx, pd.localtax2_tx, pd.total_localtax1, pd.total_localtax2,'; - $sql.= ' p.ref as product_ref, p.label as product_label, p.description as product_desc,'; - $sql.= ' pd.product_type, pd.ref_fourn as ref_produit_fourn,'; - $sql.= ' pd.fk_multicurrency, pd.multicurrency_code, pd.multicurrency_subprice, pd.multicurrency_total_ht, pd.multicurrency_total_tva, pd.multicurrency_total_ttc, pd.fk_unit'; - $sql.= ' FROM '.MAIN_DB_PREFIX.'supplier_proposaldet as pd'; - $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON pd.fk_product = p.rowid'; - $sql.= ' WHERE pd.rowid = '.$rowid; + public function fetch($rowid) + { + $sql = 'SELECT pd.rowid, pd.fk_supplier_proposal, pd.fk_parent_line, pd.fk_product, pd.label as custom_label, pd.description, pd.price, pd.qty, pd.tva_tx,'; + $sql.= ' pd.remise, pd.remise_percent, pd.fk_remise_except, pd.subprice,'; + $sql.= ' pd.info_bits, pd.total_ht, pd.total_tva, pd.total_ttc, pd.fk_product_fournisseur_price as fk_fournprice, pd.buy_price_ht as pa_ht, pd.special_code, pd.rang,'; + $sql.= ' pd.localtax1_tx, pd.localtax2_tx, pd.total_localtax1, pd.total_localtax2,'; + $sql.= ' p.ref as product_ref, p.label as product_label, p.description as product_desc,'; + $sql.= ' pd.product_type, pd.ref_fourn as ref_produit_fourn,'; + $sql.= ' pd.fk_multicurrency, pd.multicurrency_code, pd.multicurrency_subprice, pd.multicurrency_total_ht, pd.multicurrency_total_tva, pd.multicurrency_total_ttc, pd.fk_unit'; + $sql.= ' FROM '.MAIN_DB_PREFIX.'supplier_proposaldet as pd'; + $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON pd.fk_product = p.rowid'; + $sql.= ' WHERE pd.rowid = '.$rowid; - $result = $this->db->query($sql); - if ($result) - { - $objp = $this->db->fetch_object($result); + $result = $this->db->query($sql); + if ($result) + { + $objp = $this->db->fetch_object($result); - $this->rowid = $objp->rowid; // deprecated - $this->id = $objp->rowid; - $this->fk_supplier_proposal = $objp->fk_supplier_proposal; - $this->fk_parent_line = $objp->fk_parent_line; - $this->label = $objp->custom_label; - $this->desc = $objp->description; - $this->qty = $objp->qty; - $this->price = $objp->price; // deprecated - $this->subprice = $objp->subprice; - $this->tva_tx = $objp->tva_tx; - $this->remise = $objp->remise; - $this->remise_percent = $objp->remise_percent; - $this->fk_remise_except = $objp->fk_remise_except; - $this->fk_product = $objp->fk_product; - $this->info_bits = $objp->info_bits; + $this->rowid = $objp->rowid; // deprecated + $this->id = $objp->rowid; + $this->fk_supplier_proposal = $objp->fk_supplier_proposal; + $this->fk_parent_line = $objp->fk_parent_line; + $this->label = $objp->custom_label; + $this->desc = $objp->description; + $this->qty = $objp->qty; + $this->price = $objp->price; // deprecated + $this->subprice = $objp->subprice; + $this->tva_tx = $objp->tva_tx; + $this->remise = $objp->remise; + $this->remise_percent = $objp->remise_percent; + $this->fk_remise_except = $objp->fk_remise_except; + $this->fk_product = $objp->fk_product; + $this->info_bits = $objp->info_bits; - $this->total_ht = $objp->total_ht; - $this->total_tva = $objp->total_tva; - $this->total_ttc = $objp->total_ttc; + $this->total_ht = $objp->total_ht; + $this->total_tva = $objp->total_tva; + $this->total_ttc = $objp->total_ttc; - $this->fk_fournprice = $objp->fk_fournprice; + $this->fk_fournprice = $objp->fk_fournprice; - $marginInfos = getMarginInfos($objp->subprice, $objp->remise_percent, $objp->tva_tx, $objp->localtax1_tx, $objp->localtax2_tx, $this->fk_fournprice, $objp->pa_ht); - $this->pa_ht = $marginInfos[0]; - $this->marge_tx = $marginInfos[1]; - $this->marque_tx = $marginInfos[2]; + $marginInfos = getMarginInfos($objp->subprice, $objp->remise_percent, $objp->tva_tx, $objp->localtax1_tx, $objp->localtax2_tx, $this->fk_fournprice, $objp->pa_ht); + $this->pa_ht = $marginInfos[0]; + $this->marge_tx = $marginInfos[1]; + $this->marque_tx = $marginInfos[2]; - $this->special_code = $objp->special_code; - $this->product_type = $objp->product_type; - $this->rang = $objp->rang; + $this->special_code = $objp->special_code; + $this->product_type = $objp->product_type; + $this->rang = $objp->rang; - $this->ref = $objp->product_ref; // deprecated - $this->product_ref = $objp->product_ref; - $this->libelle = $objp->product_label; // deprecated - $this->product_label = $objp->product_label; - $this->product_desc = $objp->product_desc; + $this->ref = $objp->product_ref; // deprecated + $this->product_ref = $objp->product_ref; + $this->libelle = $objp->product_label; // deprecated + $this->product_label = $objp->product_label; + $this->product_desc = $objp->product_desc; - $this->ref_fourn = $objp->ref_produit_forun; + $this->ref_fourn = $objp->ref_produit_forun; - // Multicurrency - $this->fk_multicurrency = $objp->fk_multicurrency; - $this->multicurrency_code = $objp->multicurrency_code; - $this->multicurrency_subprice = $objp->multicurrency_subprice; - $this->multicurrency_total_ht = $objp->multicurrency_total_ht; - $this->multicurrency_total_tva = $objp->multicurrency_total_tva; - $this->multicurrency_total_ttc = $objp->multicurrency_total_ttc; - $this->fk_unit = $objp->fk_unit; + // Multicurrency + $this->fk_multicurrency = $objp->fk_multicurrency; + $this->multicurrency_code = $objp->multicurrency_code; + $this->multicurrency_subprice = $objp->multicurrency_subprice; + $this->multicurrency_total_ht = $objp->multicurrency_total_ht; + $this->multicurrency_total_tva = $objp->multicurrency_total_tva; + $this->multicurrency_total_ttc = $objp->multicurrency_total_ttc; + $this->fk_unit = $objp->fk_unit; - $this->db->free($result); - } - else - { - dol_print_error($this->db); - } - } + $this->db->free($result); + } + else + { + dol_print_error($this->db); + } + } /** * Insert object line propal in database @@ -2942,7 +2942,7 @@ class SupplierProposalLine extends CommonObjectLine * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int <0 if KO, >0 if OK */ - function insert($notrigger = 0) + public function insert($notrigger = 0) { global $conf,$langs,$user; @@ -2955,7 +2955,7 @@ class SupplierProposalLine extends CommonObjectLine if (empty($this->localtax1_tx)) $this->localtax1_tx=0; if (empty($this->localtax2_tx)) $this->localtax2_tx=0; if (empty($this->localtax1_type)) $this->localtax1_type=0; - if (empty($this->localtax2_type)) $this->localtax2_type=0; + if (empty($this->localtax2_type)) $this->localtax2_type=0; if (empty($this->total_localtax1)) $this->total_localtax1=0; if (empty($this->total_localtax2)) $this->total_localtax2=0; if (empty($this->rang)) $this->rang=0; @@ -2970,18 +2970,18 @@ class SupplierProposalLine extends CommonObjectLine if (empty($this->pa_ht)) $this->pa_ht=0; - // if buy price not defined, define buyprice as configured in margin admin - if ($this->pa_ht == 0) - { - if (($result = $this->defineBuyPrice($this->subprice, $this->remise_percent, $this->fk_product)) < 0) - { - return $result; - } - else - { - $this->pa_ht = $result; - } - } + // if buy price not defined, define buyprice as configured in margin admin + if ($this->pa_ht == 0) + { + if (($result = $this->defineBuyPrice($this->subprice, $this->remise_percent, $this->fk_product)) < 0) + { + return $result; + } + else + { + $this->pa_ht = $result; + } + } // Check parameters if ($this->product_type < 0) return -1; @@ -2991,12 +2991,12 @@ class SupplierProposalLine extends CommonObjectLine // Insert line into database $sql = 'INSERT INTO '.MAIN_DB_PREFIX.'supplier_proposaldet'; $sql.= ' (fk_supplier_proposal, fk_parent_line, label, description, fk_product, product_type,'; - $sql.= ' fk_remise_except, qty, tva_tx, localtax1_tx, localtax2_tx, localtax1_type, localtax2_type,'; + $sql.= ' fk_remise_except, qty, tva_tx, localtax1_tx, localtax2_tx, localtax1_type, localtax2_type,'; $sql.= ' subprice, remise_percent, '; $sql.= ' info_bits, '; $sql.= ' total_ht, total_tva, total_localtax1, total_localtax2, total_ttc, fk_product_fournisseur_price, buy_price_ht, special_code, rang,'; $sql.= ' ref_fourn,'; - $sql.= ' fk_multicurrency, multicurrency_code, multicurrency_subprice, multicurrency_total_ht, multicurrency_total_tva, multicurrency_total_ttc, fk_unit)'; + $sql.= ' fk_multicurrency, multicurrency_code, multicurrency_subprice, multicurrency_total_ht, multicurrency_total_tva, multicurrency_total_ttc, fk_unit)'; $sql.= " VALUES (".$this->fk_supplier_proposal.","; $sql.= " ".($this->fk_parent_line>0?"'".$this->db->escape($this->fk_parent_line)."'":"null").","; $sql.= " ".(! empty($this->label)?"'".$this->db->escape($this->label)."'":"null").","; @@ -3008,8 +3008,8 @@ class SupplierProposalLine extends CommonObjectLine $sql.= " ".price2num($this->tva_tx).","; $sql.= " ".price2num($this->localtax1_tx).","; $sql.= " ".price2num($this->localtax2_tx).","; - $sql.= " '".$this->db->escape($this->localtax1_type)."',"; - $sql.= " '".$this->db->escape($this->localtax2_type)."',"; + $sql.= " '".$this->db->escape($this->localtax1_type)."',"; + $sql.= " '".$this->db->escape($this->localtax2_type)."',"; $sql.= " ".(!empty($this->subprice)?price2num($this->subprice):"null").","; $sql.= " ".price2num($this->remise_percent).","; $sql.= " ".(isset($this->info_bits)?"'".$this->db->escape($this->info_bits)."'":"null").","; @@ -3023,29 +3023,29 @@ class SupplierProposalLine extends CommonObjectLine $sql.= ' '.$this->special_code.','; $sql.= ' '.$this->rang.','; $sql.= " '".$this->db->escape($this->ref_fourn)."'"; - $sql.= ", ".($this->fk_multicurrency > 0?$this->fk_multicurrency:'null'); - $sql.= ", '".$this->db->escape($this->multicurrency_code)."'"; - $sql.= ", ".$this->multicurrency_subprice; - $sql.= ", ".$this->multicurrency_total_ht; - $sql.= ", ".$this->multicurrency_total_tva; - $sql.= ", ".$this->multicurrency_total_ttc; + $sql.= ", ".($this->fk_multicurrency > 0?$this->fk_multicurrency:'null'); + $sql.= ", '".$this->db->escape($this->multicurrency_code)."'"; + $sql.= ", ".$this->multicurrency_subprice; + $sql.= ", ".$this->multicurrency_total_ht; + $sql.= ", ".$this->multicurrency_total_tva; + $sql.= ", ".$this->multicurrency_total_ttc; $sql.= ", ".($this->fk_unit?$this->fk_unit:'null'); - $sql.= ')'; + $sql.= ')'; dol_syslog(get_class($this).'::insert', LOG_DEBUG); $resql=$this->db->query($sql); if ($resql) { $this->rowid=$this->db->last_insert_id(MAIN_DB_PREFIX.'supplier_proposaldet'); - $this->id=$this->rowid; + $this->id=$this->rowid; if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used { - $result=$this->insertExtraFields(); - if ($result < 0) - { - $error++; - } + $result=$this->insertExtraFields(); + if ($result < 0) + { + $error++; + } } if (! $error && ! $notrigger) @@ -3076,7 +3076,7 @@ class SupplierProposalLine extends CommonObjectLine * * @return int <0 if ko, >0 if ok */ - function delete() + public function delete() { global $conf,$langs,$user; @@ -3088,17 +3088,17 @@ class SupplierProposalLine extends CommonObjectLine if ($this->db->query($sql) ) { - // Remove extrafields - if ((! $error) && (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED))) // For avoid conflicts if trigger used - { - $this->id=$this->rowid; - $result=$this->deleteExtraFields(); - if ($result < 0) - { - $error++; - dol_syslog(get_class($this)."::delete error -4 ".$this->error, LOG_ERR); - } - } + // Remove extrafields + if ((! $error) && (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED))) // For avoid conflicts if trigger used + { + $this->id=$this->rowid; + $result=$this->deleteExtraFields(); + if ($result < 0) + { + $error++; + dol_syslog(get_class($this)."::delete error -4 ".$this->error, LOG_ERR); + } + } // Call trigger $result=$this->call_trigger('LINESUPPLIER_PROPOSAL_DELETE', $user); @@ -3127,7 +3127,7 @@ class SupplierProposalLine extends CommonObjectLine * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int <0 if ko, >0 if ok */ - function update($notrigger = 0) + public function update($notrigger = 0) { global $conf,$langs,$user; @@ -3139,8 +3139,8 @@ class SupplierProposalLine extends CommonObjectLine if (empty($this->localtax2_tx)) $this->localtax2_tx=0; if (empty($this->total_localtax1)) $this->total_localtax1=0; if (empty($this->total_localtax2)) $this->total_localtax2=0; - if (empty($this->localtax1_type)) $this->localtax1_type=0; - if (empty($this->localtax2_type)) $this->localtax2_type=0; + if (empty($this->localtax1_type)) $this->localtax1_type=0; + if (empty($this->localtax2_type)) $this->localtax2_type=0; if (empty($this->marque_tx)) $this->marque_tx=0; if (empty($this->marge_tx)) $this->marge_tx=0; if (empty($this->price)) $this->price=0; // TODO A virer @@ -3153,20 +3153,20 @@ class SupplierProposalLine extends CommonObjectLine if (empty($this->fk_unit)) $this->fk_unit=0; if (empty($this->subprice)) $this->subprice=0; - if (empty($this->pa_ht)) $this->pa_ht=0; + if (empty($this->pa_ht)) $this->pa_ht=0; - // if buy price not defined, define buyprice as configured in margin admin - if ($this->pa_ht == 0) - { - if (($result = $this->defineBuyPrice($this->subprice, $this->remise_percent, $this->fk_product)) < 0) - { - return $result; - } - else - { - $this->pa_ht = $result; - } - } + // if buy price not defined, define buyprice as configured in margin admin + if ($this->pa_ht == 0) + { + if (($result = $this->defineBuyPrice($this->subprice, $this->remise_percent, $this->fk_product)) < 0) + { + return $result; + } + else + { + $this->pa_ht = $result; + } + } $this->db->begin(); @@ -3178,8 +3178,8 @@ class SupplierProposalLine extends CommonObjectLine $sql.= " , tva_tx='".price2num($this->tva_tx)."'"; $sql.= " , localtax1_tx=".price2num($this->localtax1_tx); $sql.= " , localtax2_tx=".price2num($this->localtax2_tx); - $sql.= " , localtax1_type='".$this->db->escape($this->localtax1_type)."'"; - $sql.= " , localtax2_type='".$this->db->escape($this->localtax2_type)."'"; + $sql.= " , localtax1_type='".$this->db->escape($this->localtax1_type)."'"; + $sql.= " , localtax2_type='".$this->db->escape($this->localtax2_type)."'"; $sql.= " , qty='".price2num($this->qty)."'"; $sql.= " , subprice=".price2num($this->subprice).""; $sql.= " , remise_percent=".price2num($this->remise_percent).""; @@ -3194,35 +3194,35 @@ class SupplierProposalLine extends CommonObjectLine $sql.= " , total_localtax1=".price2num($this->total_localtax1).""; $sql.= " , total_localtax2=".price2num($this->total_localtax2).""; } - $sql.= " , fk_product_fournisseur_price=".(! empty($this->fk_fournprice)?"'".$this->db->escape($this->fk_fournprice)."'":"null"); - $sql.= " , buy_price_ht=".price2num($this->pa_ht); + $sql.= " , fk_product_fournisseur_price=".(! empty($this->fk_fournprice)?"'".$this->db->escape($this->fk_fournprice)."'":"null"); + $sql.= " , buy_price_ht=".price2num($this->pa_ht); if (strlen($this->special_code)) $sql.= " , special_code=".$this->special_code; $sql.= " , fk_parent_line=".($this->fk_parent_line>0?$this->fk_parent_line:"null"); if (! empty($this->rang)) $sql.= ", rang=".$this->rang; $sql.= " , ref_fourn=".(! empty($this->ref_fourn)?"'".$this->db->escape($this->ref_fourn)."'":"null"); $sql.= " , fk_unit=".($this->fk_unit?$this->fk_unit:'null'); - // Multicurrency - $sql.= " , multicurrency_subprice=".price2num($this->multicurrency_subprice).""; + // Multicurrency + $sql.= " , multicurrency_subprice=".price2num($this->multicurrency_subprice).""; $sql.= " , multicurrency_total_ht=".price2num($this->multicurrency_total_ht).""; $sql.= " , multicurrency_total_tva=".price2num($this->multicurrency_total_tva).""; $sql.= " , multicurrency_total_ttc=".price2num($this->multicurrency_total_ttc).""; - $sql.= " WHERE rowid = ".$this->rowid; + $sql.= " WHERE rowid = ".$this->rowid; dol_syslog(get_class($this)."::update", LOG_DEBUG); $resql=$this->db->query($sql); if ($resql) { - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used - { - $this->id=$this->rowid; - $result=$this->insertExtraFields(); - if ($result < 0) - { - $error++; - } - } + if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used + { + $this->id=$this->rowid; + $result=$this->insertExtraFields(); + if ($result < 0) + { + $error++; + } + } if (! $error && ! $notrigger) { @@ -3247,14 +3247,14 @@ class SupplierProposalLine extends CommonObjectLine } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Update DB line fields total_xxx * Used by migration * * @return int <0 if ko, >0 if ok */ - function update_total() + public function update_total() { // phpcs:enable $this->db->begin(); diff --git a/htdocs/ticket/class/actions_ticket.class.php b/htdocs/ticket/class/actions_ticket.class.php index 05b30c2b1a3..395ab2078c7 100644 --- a/htdocs/ticket/class/actions_ticket.class.php +++ b/htdocs/ticket/class/actions_ticket.class.php @@ -45,14 +45,14 @@ class ActionsTicket public $mesg; /** - * @var string Error code (or message) - */ - public $error; + * @var string Error code (or message) + */ + public $error; /** - * @var string[] Error codes (or messages) - */ - public $errors = array(); + * @var string[] Error codes (or messages) + */ + public $errors = array(); //! Numero de l'erreur public $errno = 0; @@ -66,18 +66,18 @@ class ActionsTicket public $label; /** - * @var string description - */ - public $description; + * @var string description + */ + public $description; - /** + /** * @var int ID */ public $fk_statut; /** - * @var int Thirdparty ID - */ + * @var int Thirdparty ID + */ public $fk_soc; /** @@ -119,7 +119,7 @@ class ActionsTicket if (GETPOST('addfile')) { // altairis : allow files from public interface if (GETPOST('track_id')) { - $res = $object->fetch('', '', GETPOST('track_id', 'alpha')); + $res = $object->fetch('', '', GETPOST('track_id', 'alpha')); } ////if($res > 0) @@ -374,7 +374,7 @@ class ActionsTicket if (! $error) // Update list of contacts { - // Si déjà un user assigné on le supprime des contacts + // Si déjà un user assigné on le supprime des contacts if ($useroriginassign > 0) { $internal_contacts = $object->listeContact(-1, 'internal'); @@ -760,12 +760,12 @@ class ActionsTicket // If public interface is not enable, use link to internal page into mail $url_public_ticket = (!empty($conf->global->TICKET_ENABLE_PUBLIC_INTERFACE) ? - (!empty($conf->global->TICKET_URL_PUBLIC_INTERFACE) ? - $conf->global->TICKET_URL_PUBLIC_INTERFACE . '/view.php' : - dol_buildpath('/public/ticket/view.php', 2) - ) : - dol_buildpath('/ticket/card.php', 2) - ) . '?track_id=' . $object->track_id; + (!empty($conf->global->TICKET_URL_PUBLIC_INTERFACE) ? + $conf->global->TICKET_URL_PUBLIC_INTERFACE . '/view.php' : + dol_buildpath('/public/ticket/view.php', 2) + ) : + dol_buildpath('/ticket/card.php', 2) + ) . '?track_id=' . $object->track_id; $message .= "\n" . $langs->trans('TicketNewEmailBodyInfosTrackUrlCustomer') . ' : ' . '' . $object->track_id . '' . "\n"; // Build final message @@ -779,8 +779,8 @@ class ActionsTicket } if ($object->fk_soc > 0 && ! in_array($object->origin_email, $sendto)) { - $object->socid = $object->fk_soc; - $object->fetch_thirdparty(); + $object->socid = $object->fk_soc; + $object->fetch_thirdparty(); if(!empty($object->thirdparty->email)) $sendto[] = $object->thirdparty->email; } @@ -954,7 +954,7 @@ class ActionsTicket header("Location: " . $url); exit; } else { - setEventMessages($object->error, $object->errors, 'errors'); + setEventMessages($object->error, $object->errors, 'errors'); } } else { setEventMessages($this->error, $this->errors, 'errors'); @@ -1095,43 +1095,43 @@ class ActionsTicket */ public function viewTimelineTicketLogs($show_user = true, $object = true) { - global $conf, $langs; + global $conf, $langs; - // Load logs in cache - $ret = $object->loadCacheLogsTicket(); + // Load logs in cache + $ret = $object->loadCacheLogsTicket(); - if (is_array($object->cache_logs_ticket) && count($object->cache_logs_ticket) > 0) { - print '
'; + if (is_array($object->cache_logs_ticket) && count($object->cache_logs_ticket) > 0) { + print '
'; - foreach ($object->cache_logs_ticket as $id => $arraylogs) { - print '
'; - print '
'; - //print ''; - print '
'; + foreach ($object->cache_logs_ticket as $id => $arraylogs) { + print '
'; + print '
'; + //print ''; + print '
'; - print '
'; - print dol_nl2br($arraylogs['message']); + print '
'; + print dol_nl2br($arraylogs['message']); - print ''; - print dol_print_date($arraylogs['datec'], 'dayhour'); + print ''; + print dol_print_date($arraylogs['datec'], 'dayhour'); - if ($show_user) { - if ($arraylogs['fk_user_create'] > 0) { - $userstat = new User($this->db); - $res = $userstat->fetch($arraylogs['fk_user_create']); - if ($res) { - print '
'.$userstat->getNomUrl(1).''; - } - } - } - print '
'; - print '
'; - print '
'; - } - print '
'; - } else { - print '
' . $langs->trans('NoLogForThisTicket') . '
'; - } + if ($show_user) { + if ($arraylogs['fk_user_create'] > 0) { + $userstat = new User($this->db); + $res = $userstat->fetch($arraylogs['fk_user_create']); + if ($res) { + print '
'.$userstat->getNomUrl(1).''; + } + } + } + print ''; + print ' '; + print ' '; + } + print '
'; + } else { + print '
' . $langs->trans('NoLogForThisTicket') . '
'; + } } /** @@ -1144,55 +1144,55 @@ class ActionsTicket */ public function viewTicketOriginalMessage($user, $action, $object) { - global $langs; - if (!empty($user->rights->ticket->manage) && $action == 'edit_message_init') { - // MESSAGE + global $langs; + if (!empty($user->rights->ticket->manage) && $action == 'edit_message_init') { + // MESSAGE - print '
'; - print ''; - print ''; - print ''; - } + print ''; + print ''; + print ''; + print ''; + } - // Initial message - print '
'; - print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table - print ''; - print ''; + // Initial message + print '
'; + print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table + print '
'; - print $langs->trans("InitialMessage"); - print ''; - if ($user->rights->ticket->manage) { - print '' . img_edit($langs->trans('Modify')) . ''; - } - print '
'; + print ''; - print ''; - print ''; + print ''; - print ''; - print '
'; + print $langs->trans("InitialMessage"); + print ''; + if ($user->rights->ticket->manage) { + print '' . img_edit($langs->trans('Modify')) . ''; + } + print '
'; - if (!empty($user->rights->ticket->manage) && $action == 'edit_message_init') { - // MESSAGE - $msg = GETPOST('message_initial', 'alpha') ? GETPOST('message_initial', 'alpha') : $object->message; - include_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php'; - $uselocalbrowser = true; - $doleditor = new DolEditor('message_initial', $msg, '100%', 250, 'dolibarr_details', 'In', true, $uselocalbrowser); - $doleditor->Create(); - } else { - // Deal with format differences (text / HTML) - if (dol_textishtml($object->message)) { - print $object->message; - } else { - print dol_nl2br($object->message); - } + print '
'; + if (!empty($user->rights->ticket->manage) && $action == 'edit_message_init') { + // MESSAGE + $msg = GETPOST('message_initial', 'alpha') ? GETPOST('message_initial', 'alpha') : $object->message; + include_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php'; + $uselocalbrowser = true; + $doleditor = new DolEditor('message_initial', $msg, '100%', 250, 'dolibarr_details', 'In', true, $uselocalbrowser); + $doleditor->Create(); + } else { + // Deal with format differences (text / HTML) + if (dol_textishtml($object->message)) { + print $object->message; + } else { + print dol_nl2br($object->message); + } - //print '
' . $object->message . '
'; - } - print '
'; - if ($user->rights->ticket->manage && $action == 'edit_message_init') { - print ' '; - print ' '; - print ''; - } + //print '
' . $object->message . '
'; + } + print ''; + print ''; + print ''; + if ($user->rights->ticket->manage && $action == 'edit_message_init') { + print ' '; + print ' '; + print ''; + } } /** * View html list of message for ticket @@ -1275,29 +1275,29 @@ class ActionsTicket */ public function viewTicketTimelineMessages($show_private, $show_user, Ticket $object) { - global $conf, $langs, $user; + global $conf, $langs, $user; - // Load logs in cache - $ret = $object->loadCacheMsgsTicket(); - $action = GETPOST('action'); + // Load logs in cache + $ret = $object->loadCacheMsgsTicket(); + $action = GETPOST('action'); - if (is_array($object->cache_msgs_ticket) && count($object->cache_msgs_ticket) > 0) { - print '
'; + if (is_array($object->cache_msgs_ticket) && count($object->cache_msgs_ticket) > 0) { + print '
'; - foreach ($object->cache_msgs_ticket as $id => $arraymsgs) { - if (!$arraymsgs['private'] - || ($arraymsgs['private'] == "1" && $show_private) - ) { - print '
'; - print '
'; - print ''; - print '
'; + foreach ($object->cache_msgs_ticket as $id => $arraymsgs) { + if (!$arraymsgs['private'] + || ($arraymsgs['private'] == "1" && $show_private) + ) { + print '
'; + print '
'; + print ''; + print '
'; - print '
'; - print $arraymsgs['message']; + print '
'; + print $arraymsgs['message']; - print ''; - print dol_print_date($arraymsgs['datec'], 'dayhour'); + print ''; + print dol_print_date($arraymsgs['datec'], 'dayhour'); if ($show_user) { if ($arraymsgs['fk_user_action'] > 0) { @@ -1312,18 +1312,18 @@ class ActionsTicket print $langs->trans('Customer'); } } - print ''; - print '
'; - print '
'; + print ''; + print '
'; + print '
'; } - } - print '
'; - } else { - print '
' . $langs->trans('NoMsgForThisTicket') . '
'; - } + } + print '
'; + } else { + print '
' . $langs->trans('NoMsgForThisTicket') . '
'; + } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * load_previous_next_ref * @@ -1331,7 +1331,7 @@ class ActionsTicket * @param int $fieldid Id * @return int 0 */ - function load_previous_next_ref($filter, $fieldid) + public function load_previous_next_ref($filter, $fieldid) { // phpcs:enable $this->getInstanceDao(); @@ -1498,9 +1498,9 @@ class ActionsTicket print '
'; if ($status == 1) - $urlforbutton = $_SERVER['PHP_SELF'] . '?track_id=' . $object->track_id . '&action=mark_ticket_read'; // To set as read, we use a dedicated action - else - $urlforbutton = $_SERVER['PHP_SELF'] . '?track_id=' . $object->track_id . '&action=set_status&new_status=' . $status; + $urlforbutton = $_SERVER['PHP_SELF'] . '?track_id=' . $object->track_id . '&action=mark_ticket_read'; // To set as read, we use a dedicated action + else + $urlforbutton = $_SERVER['PHP_SELF'] . '?track_id=' . $object->track_id . '&action=set_status&new_status=' . $status; print ''; print img_picto($langs->trans($object->statuts_short[$status]), 'statut' . $status . '.png@ticket') . ' ' . $langs->trans($object->statuts_short[$status]); @@ -1512,14 +1512,14 @@ class ActionsTicket } - /** - * deleteObjectLinked - * - * @return number - */ + /** + * deleteObjectLinked + * + * @return number + */ public function deleteObjectLinked() { - return $this->dao->deleteObjectLinked(); + return $this->dao->deleteObjectLinked(); } /** @@ -1533,19 +1533,19 @@ class ActionsTicket */ public function emailElementlist($parameters, &$object, &$action, $hookmanager) { - global $langs; + global $langs; - $error = 0; + $error = 0; - if (in_array('admin', explode(':', $parameters['context']))) { + if (in_array('admin', explode(':', $parameters['context']))) { $this->results = array('ticket_send' => $langs->trans('MailToSendTicketMessage')); - } + } - if (! $error) { + if (! $error) { return 0; // or return 1 to replace standard code - } else { - $this->errors[] = 'Error message'; - return -1; - } + } else { + $this->errors[] = 'Error message'; + return -1; + } } } diff --git a/htdocs/ticket/class/api_tickets.class.php b/htdocs/ticket/class/api_tickets.class.php index fd698e6de06..005d8084f31 100644 --- a/htdocs/ticket/class/api_tickets.class.php +++ b/htdocs/ticket/class/api_tickets.class.php @@ -55,8 +55,8 @@ class Tickets extends DolibarrApi */ public function __construct() { - global $db; - $this->db = $db; + global $db; + $this->db = $db; $this->ticket = new Ticket($this->db); } @@ -72,9 +72,9 @@ class Tickets extends DolibarrApi * @throws 403 * @throws 404 */ - function get($id) + public function get($id) { - return $this->getCommon($id, '', ''); + return $this->getCommon($id, '', ''); } /** @@ -93,7 +93,7 @@ class Tickets extends DolibarrApi */ public function getByTrackId($track_id) { - return $this->getCommon(0, $track_id, ''); + return $this->getCommon(0, $track_id, ''); } /** @@ -112,13 +112,13 @@ class Tickets extends DolibarrApi */ public function getByRef($ref) { - try { - return $this->getCommon(0, '', $ref); - } - catch(Exception $e) - { - throw $e; - } + try { + return $this->getCommon(0, '', $ref); + } + catch(Exception $e) + { + throw $e; + } } /** @@ -301,22 +301,22 @@ class Tickets extends DolibarrApi } // Add sql filters if ($sqlfilters) { - if (! DolibarrApi::_checkFilters($sqlfilters)) { - throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); - } - $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; - $sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; + if (! DolibarrApi::_checkFilters($sqlfilters)) { + throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); + } + $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; + $sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; } $sql.= $db->order($sortfield, $sortorder); if ($limit) { - if ($page < 0) { - $page = 0; - } - $offset = $limit * $page; + if ($page < 0) { + $page = 0; + } + $offset = $limit * $page; - $sql .= $this->db->plimit($limit, $offset); + $sql .= $this->db->plimit($limit, $offset); } $result = $db->query($sql); @@ -341,7 +341,7 @@ class Tickets extends DolibarrApi if (! count($obj_ret)) { throw new RestException(404, 'No ticket found'); } - return $obj_ret; + return $obj_ret; } /** @@ -355,8 +355,8 @@ class Tickets extends DolibarrApi { $ticketstatic = new Ticket($this->db); if (! DolibarrApiAccess::$user->rights->ticket->write) { - throw new RestException(401); - } + throw new RestException(401); + } // Check mandatory fields $result = $this->_validate($request_data); @@ -417,17 +417,17 @@ class Tickets extends DolibarrApi public function put($id, $request_data = null) { if (! DolibarrApiAccess::$user->rights->ticket->write) { - throw new RestException(401); - } + throw new RestException(401); + } $result = $this->ticket->fetch($id); if (! $result) { throw new RestException(404, 'Ticket not found'); } - if (! DolibarrApi::_checkAccessToResource('ticket', $this->ticket->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } + if (! DolibarrApi::_checkAccessToResource('ticket', $this->ticket->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } foreach ($request_data as $field => $value) { $this->ticket->$field = $value; @@ -450,16 +450,16 @@ class Tickets extends DolibarrApi public function delete($id) { if (! DolibarrApiAccess::$user->rights->ticket->delete) { - throw new RestException(401); - } + throw new RestException(401); + } $result = $this->ticket->fetch($id); if (! $result) { throw new RestException(404, 'Ticket not found'); } - if (! DolibarrApi::_checkAccessToResource('ticket', $this->ticket->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } + if (! DolibarrApi::_checkAccessToResource('ticket', $this->ticket->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } if (!$this->ticket->delete($id)) { throw new RestException(500); @@ -523,12 +523,12 @@ class Tickets extends DolibarrApi * @todo use an array for properties to clean * */ - function _cleanObjectDatas($object) + private function _cleanObjectDatas($object) { - $object = parent::_cleanObjectDatas($object); + $object = parent::_cleanObjectDatas($object); - // Other attributes to clean + // Other attributes to clean $attr2clean = array( "contact", "contact_id", @@ -568,8 +568,8 @@ class Tickets extends DolibarrApi "civility_id", "cache_msgs_ticket", "cache_logs_ticket", - "statuts_short", - "statuts" + "statuts_short", + "statuts" ); foreach ($attr2clean as $toclean) { unset($object->$toclean); diff --git a/htdocs/ticket/class/ticket.class.php b/htdocs/ticket/class/ticket.class.php index 618eb654b1c..19b77331b3a 100644 --- a/htdocs/ticket/class/ticket.class.php +++ b/htdocs/ticket/class/ticket.class.php @@ -179,18 +179,18 @@ class Ticket extends CommonObject public $fields=array( 'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'position'=>1, 'visible'=>-2, 'enabled'=>1, 'position'=>1, 'notnull'=>1, 'index'=>1, 'comment'=>"Id"), - 'entity' => array('type'=>'integer', 'label'=>'Entity', 'visible'=>0, 'enabled'=>1, 'position'=>5, 'notnull'=>1, 'index'=>1), - 'ref' => array('type'=>'varchar(128)', 'label'=>'Ref', 'visible'=>1, 'enabled'=>1, 'position'=>10, 'notnull'=>1, 'index'=>1, 'searchall'=>1, 'comment'=>"Reference of object", 'css'=>''), - 'track_id' => array('type'=>'varchar(255)', 'label'=>'TrackID', 'visible'=>0, 'enabled'=>1, 'position'=>11, 'notnull'=>-1, 'searchall'=>1, 'help'=>"Help text"), - 'fk_user_create' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'Author', 'visible'=>1, 'enabled'=>1, 'position'=>15, 'notnull'=>1, 'css'=>'nowraponall'), - 'origin_email' => array('type'=>'mail', 'label'=>'OriginEmail', 'visible'=>-2, 'enabled'=>1, 'position'=>16, 'notnull'=>1, 'index'=>1, 'searchall'=>1, 'comment'=>"Reference of object"), - 'subject' => array('type'=>'varchar(255)', 'label'=>'Subject', 'visible'=>1, 'enabled'=>1, 'position'=>18, 'notnull'=>-1, 'searchall'=>1, 'help'=>""), - 'type_code' => array('type'=>'varchar(32)', 'label'=>'Type', 'visible'=>1, 'enabled'=>1, 'position'=>20, 'notnull'=>-1, 'searchall'=>1, 'help'=>"", 'css'=>'maxwidth100'), - 'category_code' => array('type'=>'varchar(32)', 'label'=>'Category', 'visible'=>-1, 'enabled'=>1, 'position'=>21, 'notnull'=>-1, 'searchall'=>1, 'help'=>"", 'css'=>'maxwidth100'), - 'severity_code' => array('type'=>'varchar(32)', 'label'=>'Severity', 'visible'=>1, 'enabled'=>1, 'position'=>22, 'notnull'=>-1, 'searchall'=>1, 'help'=>"", 'css'=>'maxwidth100'), - 'fk_soc' => array('type'=>'integer:Societe:societe/class/societe.class.php', 'label'=>'ThirdParty', 'visible'=>1, 'enabled'=>1, 'position'=>50, 'notnull'=>-1, 'index'=>1, 'searchall'=>1, 'help'=>"LinkToThirparty"), - 'notify_tiers_at_create' => array('type'=>'integer', 'label'=>'NotifyThirdparty', 'visible'=>-1, 'enabled'=>0, 'position'=>51, 'notnull'=>1, 'index'=>1), - 'fk_project' => array('type'=>'integer:Project:projet/class/project.class.php', 'label'=>'Project', 'visible'=>-1, 'enabled'=>1, 'position'=>52, 'notnull'=>-1, 'index'=>1, 'searchall'=>1, 'help'=>"LinkToProject"), + 'entity' => array('type'=>'integer', 'label'=>'Entity', 'visible'=>0, 'enabled'=>1, 'position'=>5, 'notnull'=>1, 'index'=>1), + 'ref' => array('type'=>'varchar(128)', 'label'=>'Ref', 'visible'=>1, 'enabled'=>1, 'position'=>10, 'notnull'=>1, 'index'=>1, 'searchall'=>1, 'comment'=>"Reference of object", 'css'=>''), + 'track_id' => array('type'=>'varchar(255)', 'label'=>'TrackID', 'visible'=>0, 'enabled'=>1, 'position'=>11, 'notnull'=>-1, 'searchall'=>1, 'help'=>"Help text"), + 'fk_user_create' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'Author', 'visible'=>1, 'enabled'=>1, 'position'=>15, 'notnull'=>1, 'css'=>'nowraponall'), + 'origin_email' => array('type'=>'mail', 'label'=>'OriginEmail', 'visible'=>-2, 'enabled'=>1, 'position'=>16, 'notnull'=>1, 'index'=>1, 'searchall'=>1, 'comment'=>"Reference of object"), + 'subject' => array('type'=>'varchar(255)', 'label'=>'Subject', 'visible'=>1, 'enabled'=>1, 'position'=>18, 'notnull'=>-1, 'searchall'=>1, 'help'=>""), + 'type_code' => array('type'=>'varchar(32)', 'label'=>'Type', 'visible'=>1, 'enabled'=>1, 'position'=>20, 'notnull'=>-1, 'searchall'=>1, 'help'=>"", 'css'=>'maxwidth100'), + 'category_code' => array('type'=>'varchar(32)', 'label'=>'Category', 'visible'=>-1, 'enabled'=>1, 'position'=>21, 'notnull'=>-1, 'searchall'=>1, 'help'=>"", 'css'=>'maxwidth100'), + 'severity_code' => array('type'=>'varchar(32)', 'label'=>'Severity', 'visible'=>1, 'enabled'=>1, 'position'=>22, 'notnull'=>-1, 'searchall'=>1, 'help'=>"", 'css'=>'maxwidth100'), + 'fk_soc' => array('type'=>'integer:Societe:societe/class/societe.class.php', 'label'=>'ThirdParty', 'visible'=>1, 'enabled'=>1, 'position'=>50, 'notnull'=>-1, 'index'=>1, 'searchall'=>1, 'help'=>"LinkToThirparty"), + 'notify_tiers_at_create' => array('type'=>'integer', 'label'=>'NotifyThirdparty', 'visible'=>-1, 'enabled'=>0, 'position'=>51, 'notnull'=>1, 'index'=>1), + 'fk_project' => array('type'=>'integer:Project:projet/class/project.class.php', 'label'=>'Project', 'visible'=>-1, 'enabled'=>1, 'position'=>52, 'notnull'=>-1, 'index'=>1, 'searchall'=>1, 'help'=>"LinkToProject"), 'timing' => array('type'=>'varchar(20)', 'label'=>'Timing', 'visible'=>-1, 'enabled'=>1, 'position'=>42, 'notnull'=>-1, 'searchall'=>1, 'help'=>""), 'datec' => array('type'=>'datetime', 'label'=>'DateCreation', 'visible'=>1, 'enabled'=>1, 'position'=>500, 'notnull'=>1), 'date_read' => array('type'=>'datetime', 'label'=>'TicketReadOn', 'visible'=>1, 'enabled'=>1, 'position'=>500, 'notnull'=>1), @@ -200,7 +200,7 @@ class Ticket extends CommonObject 'message' => array('type'=>'text', 'label'=>'Message', 'visible'=>-2, 'enabled'=>1, 'position'=>540, 'notnull'=>-1,), 'progress' => array('type'=>'varchar(100)', 'label'=>'Progression', 'visible'=>-1, 'enabled'=>1, 'position'=>540, 'notnull'=>-1, 'searchall'=>1, 'css'=>'right', 'help'=>""), 'resolution' => array('type'=>'integer', 'label'=>'Resolution', 'visible'=>-1, 'enabled'=>1, 'position'=>550, 'notnull'=>1), - 'fk_statut' => array('type'=>'integer', 'label'=>'Status', 'visible'=>1, 'enabled'=>1, 'position'=>600, 'notnull'=>1, 'index'=>1, 'arrayofkeyval'=>array(0 => 'Unread', 1 => 'Read', 3 => 'Answered', 4 => 'Assigned', 5 => 'InProgress', 6 => 'Waiting', 8 => 'Closed', 9 => 'Deleted')) + 'fk_statut' => array('type'=>'integer', 'label'=>'Status', 'visible'=>1, 'enabled'=>1, 'position'=>600, 'notnull'=>1, 'index'=>1, 'arrayofkeyval'=>array(0 => 'Unread', 1 => 'Read', 3 => 'Answered', 4 => 'Assigned', 5 => 'InProgress', 6 => 'Waiting', 8 => 'Closed', 9 => 'Deleted')) ); /** @@ -393,12 +393,12 @@ class Ticket extends CommonObject $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX . "ticket"); if (!$notrigger) { - // Call trigger - $result=$this->call_trigger('TICKET_CREATE', $user); - if ($result < 0) { + // Call trigger + $result=$this->call_trigger('TICKET_CREATE', $user); + if ($result < 0) { $error++; } - // End call triggers + // End call triggers } } @@ -537,10 +537,10 @@ class Ticket extends CommonObject $this->db->free($resql); return 1; } - else - { - return 0; - } + else + { + return 0; + } } else { $this->error = "Error " . $this->db->lasterror(); dol_syslog(get_class($this) . "::fetch " . $this->error, LOG_ERR); @@ -595,7 +595,7 @@ class Ticket extends CommonObject $sql .= ", type.label as type_label, category.label as category_label, severity.label as severity_label"; // Add fields for extrafields foreach ($extrafields->attributes[$this->table_element]['label'] as $key => $val) { - $sql .= ($extrafields->attributes[$this->table_element]['type'][$key] != 'separate' ? ",ef." . $key . ' as options_' . $key : ''); + $sql .= ($extrafields->attributes[$this->table_element]['type'][$key] != 'separate' ? ",ef." . $key . ' as options_' . $key : ''); } $sql .= " FROM " . MAIN_DB_PREFIX . "ticket as t"; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_ticket_type as type ON type.code=t.type_code"; @@ -699,7 +699,7 @@ class Ticket extends CommonObject // Extra fields if (is_array($extrafields->attributes[$this->table_element]['label']) && count($extrafields->attributes[$this->table_element]['label'])) { - foreach ($extrafields->attributes[$this->table_element]['label'] as $key => $val) { + foreach ($extrafields->attributes[$this->table_element]['label'] as $key => $val) { $tmpkey = 'options_' . $key; $line->{$tmpkey} = $obj->$tmpkey; } @@ -839,12 +839,12 @@ class Ticket extends CommonObject } if (! $error && ! $notrigger) { - // Call trigger - $result=$this->call_trigger('TICKET_MODIFY', $user); - if ($result < 0) { + // Call trigger + $result=$this->call_trigger('TICKET_MODIFY', $user); + if ($result < 0) { $error++; } - // End call triggers + // End call triggers } // Commit or rollback @@ -902,18 +902,18 @@ class Ticket extends CommonObject } if (!$error) { - $sql = "DELETE FROM " . MAIN_DB_PREFIX . "ticket_msg"; - $sql .= " WHERE fk_track_id = '" . $this->db->escape($this->track_id) . "'"; - $resql = $this->db->query($sql); + $sql = "DELETE FROM " . MAIN_DB_PREFIX . "ticket_msg"; + $sql .= " WHERE fk_track_id = '" . $this->db->escape($this->track_id) . "'"; + $resql = $this->db->query($sql); } // Removed extrafields if (!$error) { - $result = $this->deleteExtraFields(); - if ($result < 0) { - $error++; - dol_syslog(get_class($this) . "::delete error -3 " . $this->error, LOG_ERR); - } + $result = $this->deleteExtraFields(); + if ($result < 0) { + $error++; + dol_syslog(get_class($this) . "::delete error -3 " . $this->error, LOG_ERR); + } } if (!$error) { @@ -1167,7 +1167,7 @@ class Ticket extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return status label of object * @@ -1175,7 +1175,7 @@ class Ticket 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 * @return string Label */ - function LibStatut($statut, $mode = 0) + public function LibStatut($statut, $mode = 0) { // phpcs:enable global $langs; @@ -1331,57 +1331,57 @@ class Ticket extends CommonObject * @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 */ - 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 $dolibarr_main_authentication, $dolibarr_main_demo; - global $menumanager; + global $db, $conf, $langs; + global $dolibarr_main_authentication, $dolibarr_main_demo; + global $menumanager; - if (! empty($conf->dol_no_mouse_hover)) $notooltip=1; // Force disable tooltips + if (! empty($conf->dol_no_mouse_hover)) $notooltip=1; // Force disable tooltips - $result = ''; - $companylink = ''; + $result = ''; + $companylink = ''; - $label = '' . $langs->trans("ShowTicket") . ''; - $label.= '
'; - $label.= '' . $langs->trans('Ref') . ': ' . $this->ref.'
'; - $label.= '' . $langs->trans('TicketTrackId') . ': ' . $this->track_id.'
'; - $label.= '' . $langs->trans('Subject') . ': ' . $this->subject; + $label = '' . $langs->trans("ShowTicket") . ''; + $label.= '
'; + $label.= '' . $langs->trans('Ref') . ': ' . $this->ref.'
'; + $label.= '' . $langs->trans('TicketTrackId') . ': ' . $this->track_id.'
'; + $label.= '' . $langs->trans('Subject') . ': ' . $this->subject; - $url = dol_buildpath('/ticket/card.php', 1).'?id='.$this->id; + $url = dol_buildpath('/ticket/card.php', 1).'?id='.$this->id; - if ($option != 'nolink') - { - // Add param to save lastsearch_values or not - $add_save_lastsearch_values=($save_lastsearch_value == 1 ? 1 : 0); - if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values=1; - if ($add_save_lastsearch_values) $url.='&save_lastsearch_values=1'; - } + if ($option != 'nolink') + { + // Add param to save lastsearch_values or not + $add_save_lastsearch_values=($save_lastsearch_value == 1 ? 1 : 0); + if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values=1; + if ($add_save_lastsearch_values) $url.='&save_lastsearch_values=1'; + } - $linkclose=''; - if (empty($notooltip)) - { - if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) - { - $label=$langs->trans("ShowTicket"); - $linkclose.=' alt="'.dol_escape_htmltag($label, 1).'"'; - } - $linkclose.=' title="'.dol_escape_htmltag($label, 1).'"'; - $linkclose.=' class="classfortooltip'.($morecss?' '.$morecss:'').'"'; - } - else $linkclose = ($morecss?' class="'.$morecss.'"':''); + $linkclose=''; + if (empty($notooltip)) + { + if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) + { + $label=$langs->trans("ShowTicket"); + $linkclose.=' alt="'.dol_escape_htmltag($label, 1).'"'; + } + $linkclose.=' title="'.dol_escape_htmltag($label, 1).'"'; + $linkclose.=' class="classfortooltip'.($morecss?' '.$morecss:'').'"'; + } + else $linkclose = ($morecss?' class="'.$morecss.'"':''); - $linkstart = '
'; - $linkend=''; + $linkstart = ''; + $linkend=''; - $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 != 2) $result.= $this->ref; - $result .= $linkend; - //if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : ''); + $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 != 2) $result.= $this->ref; + $result .= $linkend; + //if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : ''); - return $result; + return $result; } @@ -1406,14 +1406,14 @@ class Ticket extends CommonObject dol_syslog(get_class($this) . "::markAsRead sql=" . $sql); $resql = $this->db->query($sql); if ($resql) { - if (!$error && !$notrigger) { - // Call trigger - $result=$this->call_trigger('TICKET_MARK_READ', $user); - if ($result < 0) { + if (!$error && !$notrigger) { + // Call trigger + $result=$this->call_trigger('TICKET_MARK_READ', $user); + if ($result < 0) { $error++; } - // End call triggers - } + // End call triggers + } if (!$error) { @@ -1434,61 +1434,61 @@ class Ticket extends CommonObject } } - /** - * Mark a message as read - * - * @param User $user Object user - * @param int $id_assign_user ID of user assigned - * @param int $notrigger Disable trigger - * @return int <0 if KO, 0=Nothing done, >0 if OK - */ - public function assignUser($user, $id_assign_user, $notrigger = 0) - { - global $conf, $langs; + /** + * Mark a message as read + * + * @param User $user Object user + * @param int $id_assign_user ID of user assigned + * @param int $notrigger Disable trigger + * @return int <0 if KO, 0=Nothing done, >0 if OK + */ + public function assignUser($user, $id_assign_user, $notrigger = 0) + { + global $conf, $langs; - $this->db->begin(); + $this->db->begin(); - $sql = "UPDATE " . MAIN_DB_PREFIX . "ticket"; - if ($id_assign_user > 0) - { - $sql .= " SET fk_user_assign=".$id_assign_user.", fk_statut=4"; - } - else - { - $sql .= " SET fk_user_assign=null, fk_statut=1"; - } - $sql .= " WHERE rowid = " . $this->id; + $sql = "UPDATE " . MAIN_DB_PREFIX . "ticket"; + if ($id_assign_user > 0) + { + $sql .= " SET fk_user_assign=".$id_assign_user.", fk_statut=4"; + } + else + { + $sql .= " SET fk_user_assign=null, fk_statut=1"; + } + $sql .= " WHERE rowid = " . $this->id; - dol_syslog(get_class($this) . "::assignUser sql=" . $sql); - $resql = $this->db->query($sql); - if ($resql) { - $this->fk_user_assign = $id_assign_user; // May be used by trigger + dol_syslog(get_class($this) . "::assignUser sql=" . $sql); + $resql = $this->db->query($sql); + if ($resql) { + $this->fk_user_assign = $id_assign_user; // May be used by trigger - if (! $notrigger) { - // Call trigger - $result = $this->call_trigger('TICKET_ASSIGNED', $user); - if ($result < 0) { - $error ++; - } - // End call triggers - } + if (! $notrigger) { + // Call trigger + $result = $this->call_trigger('TICKET_ASSIGNED', $user); + if ($result < 0) { + $error ++; + } + // End call triggers + } - if (! $error) { - $this->db->commit(); - return 1; - } else { - $this->db->rollback(); - $this->error = join(',', $this->errors); - dol_syslog(get_class($this) . "::assignUser " . $this->error, LOG_ERR); - return - 1; - } - } else { - $this->db->rollback(); - $this->error = $this->db->lasterror(); - dol_syslog(get_class($this) . "::assignUser " . $this->error, LOG_ERR); - return - 1; - } - } + if (! $error) { + $this->db->commit(); + return 1; + } else { + $this->db->rollback(); + $this->error = join(',', $this->errors); + dol_syslog(get_class($this) . "::assignUser " . $this->error, LOG_ERR); + return - 1; + } + } else { + $this->db->rollback(); + $this->error = $this->db->lasterror(); + dol_syslog(get_class($this) . "::assignUser " . $this->error, LOG_ERR); + return - 1; + } + } /** * Create log for the ticket @@ -1521,19 +1521,19 @@ class Ticket extends CommonObject // so the event is stored by the agenda/event trigger if (!$error) { - $this->db->commit(); + $this->db->commit(); - if ($conf->global->TICKET_ACTIVATE_LOG_BY_EMAIL && !$noemail) { - $this->sendLogByEmail($user, $message); - } + if ($conf->global->TICKET_ACTIVATE_LOG_BY_EMAIL && !$noemail) { + $this->sendLogByEmail($user, $message); + } - return 1; + return 1; } else { - $this->db->rollback(); + $this->db->rollback(); - return -1; + return -1; } } @@ -1811,32 +1811,32 @@ class Ticket extends CommonObject $this->fetchObjectLinked($this->id, $this->element, null, 'fichinter'); if ($this->linkedObjectsIds) { - foreach ($this->linkedObjectsIds['fichinter'] as $fichinter_id) { - $fichinter = new Fichinter($this->db); - $fichinter->fetch($fichinter_id); - if($fichinter->statut == 0) { - $result = $fichinter->setValid($user); - if (!$result) { - $this->errors[] = $fichinter->error; - $error++; - } - } - if ($fichinter->statut < 3) { - $result = $fichinter->setStatut(3); - if (!$result) { - $this->errors[] = $fichinter->error; - $error++; - } - } - } + foreach ($this->linkedObjectsIds['fichinter'] as $fichinter_id) { + $fichinter = new Fichinter($this->db); + $fichinter->fetch($fichinter_id); + if($fichinter->statut == 0) { + $result = $fichinter->setValid($user); + if (!$result) { + $this->errors[] = $fichinter->error; + $error++; + } + } + if ($fichinter->statut < 3) { + $result = $fichinter->setStatut(3); + if (!$result) { + $this->errors[] = $fichinter->error; + $error++; + } + } + } } - // Call trigger - $result=$this->call_trigger('TICKET_CLOSE', $user); - if ($result < 0) { + // Call trigger + $result=$this->call_trigger('TICKET_CLOSE', $user); + if ($result < 0) { $error++; } - // End call triggers + // End call triggers if (!$error) { $this->db->commit(); @@ -2363,22 +2363,22 @@ class Ticket extends CommonObject $transkey = "TypeContact_" . $obj->element . "_" . $obj->source . "_" . $obj->code; $libelle_type = ($langs->trans($transkey) != $transkey ? $langs->trans($transkey) : $obj->libelle); $tab[$i] = array( - 'source' => $obj->source, - 'socid' => $obj->socid, - 'id' => $obj->id, - 'nom' => $obj->lastname, // For backward compatibility - 'civility' => $obj->civility, - 'lastname' => $obj->lastname, - 'firstname' => $obj->firstname, - 'email' => $obj->email, - 'rowid' => $obj->rowid, - 'code' => $obj->code, - 'libelle' => $libelle_type, - 'status' => $obj->statuslink, - 'statuscontact'=>$obj->statuscontact, - 'fk_c_type_contact' => $obj->fk_c_type_contact, - 'phone' => $obj->phone, - 'phone_mobile' => $obj->phone_mobile); + 'source' => $obj->source, + 'socid' => $obj->socid, + 'id' => $obj->id, + 'nom' => $obj->lastname, // For backward compatibility + 'civility' => $obj->civility, + 'lastname' => $obj->lastname, + 'firstname' => $obj->firstname, + 'email' => $obj->email, + 'rowid' => $obj->rowid, + 'code' => $obj->code, + 'libelle' => $libelle_type, + 'status' => $obj->statuslink, + 'statuscontact'=>$obj->statuscontact, + 'fk_c_type_contact' => $obj->fk_c_type_contact, + 'phone' => $obj->phone, + 'phone_mobile' => $obj->phone_mobile); } else { $tab[$i] = $obj->id; } @@ -2438,11 +2438,11 @@ class Ticket extends CommonObject // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps /** - * Return if at least one photo is available - * - * @param string $sdir Directory to scan - * @return boolean True if at least one photo is available, False if not - */ + * Return if at least one photo is available + * + * @param string $sdir Directory to scan + * @return boolean True if at least one photo is available, False if not + */ function is_photo_available($sdir) { // phpcs:enable @@ -2479,9 +2479,9 @@ class Ticket extends CommonObject class TicketsLine { /** - * @var int ID - */ - public $id; + * @var int ID + */ + public $id; /** * @var string $ref Ticket reference @@ -2489,107 +2489,107 @@ class TicketsLine public $ref; /** - * Hash to identify ticket - */ + * Hash to identify ticket + */ public $track_id; /** - * @var int Thirdparty ID - */ + * @var int Thirdparty ID + */ public $fk_soc; /** - * Project ID - */ + * Project ID + */ public $fk_project; /** - * Person email who have create ticket - */ + * Person email who have create ticket + */ public $origin_email; /** - * User id who have create ticket - */ + * User id who have create ticket + */ public $fk_user_create; /** - * User id who have ticket assigned - */ + * User id who have ticket assigned + */ public $fk_user_assign; /** - * Ticket subject - */ + * Ticket subject + */ public $subject; /** - * Ticket message - */ + * Ticket message + */ public $message; /** - * Ticket statut - */ + * Ticket statut + */ public $fk_statut; /** - * State resolution - */ + * State resolution + */ public $resolution; /** - * Progress in percent - */ + * Progress in percent + */ public $progress; /** - * Duration for ticket - */ + * Duration for ticket + */ public $timing; /** - * Type code - */ + * Type code + */ public $type_code; /** - * Category code - */ + * Category code + */ public $category_code; /** - * Severity code - */ + * Severity code + */ public $severity_code; /** - * Type label - */ + * Type label + */ public $type_label; /** - * Category label - */ + * Category label + */ public $category_label; /** - * Severity label - */ + * Severity label + */ public $severity_label; /** - * Creation date - */ + * Creation date + */ public $datec = ''; /** - * Read date - */ + * Read date + */ public $date_read = ''; /** - * Close ticket date - */ + * Close ticket date + */ public $date_close = ''; } diff --git a/htdocs/ticket/class/ticketstats.class.php b/htdocs/ticket/class/ticketstats.class.php index 44360c788a5..2f2e04baba9 100644 --- a/htdocs/ticket/class/ticketstats.class.php +++ b/htdocs/ticket/class/ticketstats.class.php @@ -30,9 +30,9 @@ require_once 'ticket.class.php'; class TicketStats extends Stats { /** - * @var string Name of table without prefix where object is stored - */ - public $table_element; + * @var string Name of table without prefix where object is stored + */ + public $table_element; public $socid; public $userid; diff --git a/htdocs/user/class/api_users.class.php b/htdocs/user/class/api_users.class.php index 874e518511a..625fd913f5e 100644 --- a/htdocs/user/class/api_users.class.php +++ b/htdocs/user/class/api_users.class.php @@ -44,7 +44,7 @@ class Users extends DolibarrApi /** * Constructor */ - function __construct() + public function __construct() { global $db, $conf; $this->db = $db; @@ -65,7 +65,7 @@ class Users 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')" * @return array Array of User objects */ - function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $user_ids = 0, $sqlfilters = '') + public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $user_ids = 0, $sqlfilters = '') { global $db, $conf; @@ -139,7 +139,7 @@ class Users extends DolibarrApi * * @throws RestException */ - function get($id) + public function get($id) { //if (!DolibarrApiAccess::$user->rights->user->user->lire) { //throw new RestException(401); @@ -166,7 +166,7 @@ class Users extends DolibarrApi * @param array $request_data New user data * @return int */ - function post($request_data = null) + public function post($request_data = null) { // check user authorization //if(! DolibarrApiAccess::$user->rights->user->creer) { @@ -201,7 +201,7 @@ class Users extends DolibarrApi * * @throws RestException */ - function put($id, $request_data = null) + public function put($id, $request_data = null) { //if (!DolibarrApiAccess::$user->rights->user->user->creer) { //throw new RestException(401); @@ -256,7 +256,7 @@ class Users extends DolibarrApi * * @url GET {id}/groups */ - function getGroups($id) + public function getGroups($id) { $obj_ret = array(); @@ -290,7 +290,7 @@ class Users extends DolibarrApi * * @url GET {id}/setGroup/{group} */ - function setGroup($id, $group, $entity = 1) + public function setGroup($id, $group, $entity = 1) { global $conf; @@ -335,7 +335,7 @@ class Users extends DolibarrApi * @param int $id Account ID * @return array */ - function delete($id) + public function delete($id) { //if (!DolibarrApiAccess::$user->rights->user->user->supprimer) { //throw new RestException(401); @@ -360,7 +360,7 @@ class Users extends DolibarrApi * @param object $object Object to clean * @return array Array of cleaned object properties */ - function _cleanObjectDatas($object) + private function _cleanObjectDatas($object) { global $conf; @@ -418,16 +418,15 @@ class Users extends DolibarrApi * @param array|null $data Data to validate * @return array * @throws RestException - */ - function _validate($data) + */ + private function _validate($data) { - $account = array(); - foreach (Users::$FIELDS as $field) - { - if (!isset($data[$field])) - throw new RestException(400, "$field field missing"); - $account[$field] = $data[$field]; - } - return $account; - } + $account = array(); + foreach (Users::$FIELDS as $field) { + if (!isset($data[$field])) + throw new RestException(400, "$field field missing"); + $account[$field] = $data[$field]; + } + return $account; + } } diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index a6bc202d17f..3b26bb8cdfb 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -185,7 +185,7 @@ class User extends CommonObject * * @param DoliDb $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; @@ -201,11 +201,11 @@ class User extends CommonObject $this->admin = 0; $this->employee = 1; - $this->conf = new stdClass(); - $this->rights = new stdClass(); - $this->rights->user = new stdClass(); - $this->rights->user->user = new stdClass(); - $this->rights->user->self = new stdClass(); + $this->conf = new stdClass(); + $this->rights = new stdClass(); + $this->rights->user = new stdClass(); + $this->rights->user->user = new stdClass(); + $this->rights->user->self = new stdClass(); } /** @@ -219,7 +219,7 @@ class User extends CommonObject * @param int $entity If a value is >= 0, we force the search on a specific entity. If -1, means search depens on default setup. * @return int <0 if KO, 0 not found, >0 if OK */ - function fetch($id = '', $login = '', $sid = '', $loadpersonalconf = 0, $entity = -1) + public function fetch($id = '', $login = '', $sid = '', $loadpersonalconf = 0, $entity = -1) { global $conf, $user; @@ -320,17 +320,17 @@ class User extends CommonObject $this->zip = $obj->zip; $this->town = $obj->town; - $this->country_id = $obj->country_id; + $this->country_id = $obj->country_id; $this->country_code = $obj->country_id?$obj->country_code:''; - //$this->country = $obj->country_id?($langs->trans('Country'.$obj->country_code)!='Country'.$obj->country_code?$langs->transnoentities('Country'.$obj->country_code):$obj->country):''; + //$this->country = $obj->country_id?($langs->trans('Country'.$obj->country_code)!='Country'.$obj->country_code?$langs->transnoentities('Country'.$obj->country_code):$obj->country):''; $this->state_id = $obj->state_id; $this->state_code = $obj->state_code; $this->state = ($obj->state!='-'?$obj->state:''); $this->office_phone = $obj->office_phone; - $this->office_fax = $obj->office_fax; - $this->user_mobile = $obj->user_mobile; + $this->office_fax = $obj->office_fax; + $this->user_mobile = $obj->user_mobile; $this->email = $obj->email; $this->skype = $obj->skype; $this->twitter = $obj->twitter; @@ -344,14 +344,14 @@ class User extends CommonObject $this->openid = $obj->openid; $this->lang = $obj->lang; $this->entity = $obj->entity; - $this->accountancy_code = $obj->accountancy_code; + $this->accountancy_code = $obj->accountancy_code; $this->thm = $obj->thm; $this->tjm = $obj->tjm; $this->salary = $obj->salary; $this->salaryextra = $obj->salaryextra; - $this->weeklyhours = $obj->weeklyhours; + $this->weeklyhours = $obj->weeklyhours; $this->color = $obj->color; - $this->dateemployment = $this->db->jdate($obj->dateemployment); + $this->dateemployment = $this->db->jdate($obj->dateemployment); $this->dateemploymentend = $this->db->jdate($obj->dateemploymentend); $this->datec = $this->db->jdate($obj->datec); @@ -366,8 +366,8 @@ class User extends CommonObject $this->fk_member = $obj->fk_member; $this->fk_user = $obj->fk_user; - $this->default_range = $obj->default_range; - $this->default_c_exp_tax_cat = $obj->default_c_exp_tax_cat; + $this->default_range = $obj->default_range; + $this->default_c_exp_tax_cat = $obj->default_c_exp_tax_cat; // Protection when module multicompany was set, admin was set to first entity and then, the module was disabled, // in such case, this admin user must be admin for ALL entities. @@ -439,7 +439,7 @@ class User extends CommonObject * * @return int > 0 if OK, < 0 if KO */ - function loadDefaultValues() + public function loadDefaultValues() { global $conf; @@ -501,7 +501,7 @@ class User extends CommonObject * @return int > 0 if OK, < 0 if KO * @see clearrights, delrights, getrights */ - function addrights($rid, $allmodule = '', $allperms = '', $entity = 0, $notrigger = 0) + public function addrights($rid, $allmodule = '', $allperms = '', $entity = 0, $notrigger = 0) { global $conf, $user, $langs; @@ -627,7 +627,7 @@ class User extends CommonObject * @return int > 0 if OK, < 0 if OK * @see clearrights, addrights, getrights */ - function delrights($rid, $allmodule = '', $allperms = '', $entity = 0, $notrigger = 0) + public function delrights($rid, $allmodule = '', $allperms = '', $entity = 0, $notrigger = 0) { global $conf, $user, $langs; @@ -637,8 +637,7 @@ class User extends CommonObject $this->db->begin(); - if (! empty($rid)) - { + if (! empty($rid)) { // Si on a demande supression d'un droit en particulier, on recupere // les caracteristiques module, perms et subperms de ce droit. $sql = "SELECT module, perms, subperms"; @@ -663,8 +662,7 @@ class User extends CommonObject // Suppression des droits induits if ($subperms=='lire' || $subperms=='read') $wherefordel.=" OR (module='$module' AND perms='$perms' AND subperms IS NOT NULL)"; if ($perms=='lire' || $perms=='read') $wherefordel.=" OR (module='$module')"; - } - else { + } else { // On a demande suppression d'un droit sur la base d'un nom de module ou perms // Where pour la liste des droits a supprimer if (! empty($allmodule)) @@ -745,7 +743,7 @@ class User extends CommonObject * @return void * @see getrights */ - function clearrights() + public function clearrights() { dol_syslog(get_class($this)."::clearrights reset user->rights"); $this->rights=''; @@ -762,7 +760,7 @@ class User extends CommonObject * @return void * @see clearrights, delrights, addrights */ - function getrights($moduletag = '', $forcereload = 0) + public function getrights($moduletag = '', $forcereload = 0) { global $conf; @@ -919,7 +917,7 @@ class User extends CommonObject * @param int $statut Status to set * @return int <0 if KO, 0 if nothing is done, >0 if OK */ - function setstatus($statut) + public function setstatus($statut) { global $conf,$langs,$user; @@ -1010,7 +1008,7 @@ class User extends CommonObject * @param User $user User than delete * @return int <0 if KO, >0 if OK */ - function delete(User $user) + public function delete(User $user) { global $conf,$langs; @@ -1102,7 +1100,7 @@ class User extends CommonObject * @param int $notrigger 1=do not execute triggers, 0 otherwise * @return int <0 if KO, id of created user if OK */ - function create($user, $notrigger = 0) + public function create($user, $notrigger = 0) { global $conf,$langs; global $mysoc; @@ -1227,7 +1225,7 @@ class User extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Create a user from a contact object. User will be internal but if contact is linked to a third party, user will be external * @@ -1236,7 +1234,7 @@ class User extends CommonObject * @param string $password Password to force * @return int <0 if error, if OK returns id of created user */ - function create_from_contact($contact, $login = '', $password = '') + public function create_from_contact($contact, $login = '', $password = '') { // phpcs:enable global $conf,$user,$langs; @@ -1244,23 +1242,23 @@ class User extends CommonObject $error=0; // Define parameters - $this->admin = 0; - $this->lastname = $contact->lastname; - $this->firstname = $contact->firstname; - $this->gender = $contact->gender; - $this->email = $contact->email; - $this->skype = $contact->skype; - $this->twitter = $contact->twitter; - $this->facebook = $contact->facebook; - $this->office_phone = $contact->phone_pro; - $this->office_fax = $contact->fax; - $this->user_mobile = $contact->phone_mobile; - $this->address = $contact->address; - $this->zip = $contact->zip; - $this->town = $contact->town; - $this->state_id = $contact->state_id; - $this->country_id = $contact->country_id; - $this->employee = 0; + $this->admin = 0; + $this->lastname = $contact->lastname; + $this->firstname = $contact->firstname; + $this->gender = $contact->gender; + $this->email = $contact->email; + $this->skype = $contact->skype; + $this->twitter = $contact->twitter; + $this->facebook = $contact->facebook; + $this->office_phone = $contact->phone_pro; + $this->office_fax = $contact->fax; + $this->user_mobile = $contact->phone_mobile; + $this->address = $contact->address; + $this->zip = $contact->zip; + $this->town = $contact->town; + $this->state_id = $contact->state_id; + $this->country_id = $contact->country_id; + $this->employee = 0; if (empty($login)) $login=strtolower(substr($contact->firstname, 0, 4)) . strtolower(substr($contact->lastname, 0, 4)); $this->login = $login; @@ -1308,7 +1306,7 @@ class User extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Create a user into database from a member object * @@ -1316,7 +1314,7 @@ class User extends CommonObject * @param string $login Login to force * @return int <0 if KO, if OK, return id of created account */ - function create_from_member($member, $login = '') + public function create_from_member($member, $login = '') { // phpcs:enable global $conf,$user,$langs; @@ -1383,13 +1381,13 @@ class User extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Assign rights by default * * @return integer erreur <0, si ok renvoi le nbre de droits par defaut positionnes */ - function set_default_rights() + public function set_default_rights() { // phpcs:enable global $conf; @@ -1438,7 +1436,7 @@ class User extends CommonObject * @param int $nosynccontact 0=Synchronize linked contact, 1=Do not synchronize linked contact * @return int <0 si KO, >=0 si OK */ - function update($user, $notrigger = 0, $nosyncmember = 0, $nosyncmemberpass = 0, $nosynccontact = 0) + public function update($user, $notrigger = 0, $nosyncmember = 0, $nosyncmemberpass = 0, $nosynccontact = 0) { global $conf, $langs; @@ -1479,8 +1477,8 @@ class User extends CommonObject $this->zip = empty($this->zip)?'':$this->zip; $this->town = empty($this->town)?'':$this->town; $this->accountancy_code = trim($this->accountancy_code); - $this->color = empty($this->color)?'':$this->color; - $this->dateemployment = empty($this->dateemployment)?'':$this->dateemployment; + $this->color = empty($this->color)?'':$this->color; + $this->dateemployment = empty($this->dateemployment)?'':$this->dateemployment; $this->dateemploymentend = empty($this->dateemploymentend)?'':$this->dateemploymentend; // Check parameters @@ -1733,14 +1731,14 @@ class User extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Mise a jour en base de la date de derniere connexion d'un utilisateur * Fonction appelee lors d'une nouvelle connexion * * @return <0 si echec, >=0 si ok */ - function update_last_login_date() + public function update_last_login_date() { // phpcs:enable $now=dol_now(); @@ -1777,7 +1775,7 @@ class User extends CommonObject * @param int $nosyncmember Do not synchronize linked member * @return string If OK return clear password, 0 if no change, < 0 if error */ - function setPassword($user, $password = '', $changelater = 0, $notrigger = 0, $nosyncmember = 0) + public function setPassword($user, $password = '', $changelater = 0, $notrigger = 0, $nosyncmember = 0) { global $conf, $langs; require_once DOL_DOCUMENT_ROOT .'/core/lib/security2.lib.php'; @@ -1900,7 +1898,7 @@ class User extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Send new password by email * @@ -1909,7 +1907,7 @@ class User extends CommonObject * @param int $changelater 0=Send clear passwod into email, 1=Change password only after clicking on confirm email. @TODO Add method 2 = Send link to reset password * @return int < 0 si erreur, > 0 si ok */ - function send_password($user, $password = '', $changelater = 0) + public function send_password($user, $password = '', $changelater = 0) { // phpcs:enable global $conf, $langs; @@ -1977,8 +1975,8 @@ class User extends CommonObject dol_syslog(get_class($this)."::send_password changelater is on, url=".$url); } -$mailfile = new CMailFile( - $subject, + $mailfile = new CMailFile( + $subject, $this->email, $conf->global->MAIN_MAIL_EMAIL_FROM, $mesg, @@ -1988,8 +1986,8 @@ $mailfile = new CMailFile( '', '', 0, - $msgishtml - ); + $msgishtml + ); if ($mailfile->sendfile()) { @@ -2008,19 +2006,19 @@ $mailfile = new CMailFile( * * @return string chaine erreur */ - function error() + public function error() { return $this->error; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Read clicktodial information for user * * @return <0 if KO, >0 if OK */ - function fetch_clicktodial() + public function fetch_clicktodial() { // phpcs:enable $sql = "SELECT url, login, pass, poste "; @@ -2052,14 +2050,14 @@ $mailfile = new CMailFile( } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Update clicktodial info * * @return integer - */ - function update_clicktodial() - { + */ + public function update_clicktodial() + { // phpcs:enable $this->db->begin(); @@ -2090,10 +2088,10 @@ $mailfile = new CMailFile( $this->error=$this->db->lasterror(); return -1; } - } + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Add user into a group * @@ -2102,7 +2100,7 @@ $mailfile = new CMailFile( * @param int $notrigger Disable triggers * @return int <0 if KO, >0 if OK */ - function SetInGroup($group, $entity, $notrigger = 0) + public function SetInGroup($group, $entity, $notrigger = 0) { // phpcs:enable global $conf, $langs, $user; @@ -2155,7 +2153,7 @@ $mailfile = new CMailFile( } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Remove a user from a group * @@ -2164,7 +2162,7 @@ $mailfile = new CMailFile( * @param int $notrigger Disable triggers * @return int <0 if KO, >0 if OK */ - function RemoveFromGroup($group, $entity, $notrigger = 0) + public function RemoveFromGroup($group, $entity, $notrigger = 0) { // phpcs:enable global $conf,$langs,$user; @@ -2224,7 +2222,7 @@ $mailfile = new CMailFile( * @param string $imagesize 'mini', 'small' or '' (original) * @return string String with URL link */ - function getPhotoUrl($width, $height, $cssclass = '', $imagesize = '') + public function getPhotoUrl($width, $height, $cssclass = '', $imagesize = '') { $result =''; $result.=Form::showphoto('userphoto', $this, $width, $height, 0, $cssclass, $imagesize); @@ -2248,7 +2246,7 @@ $mailfile = new CMailFile( * @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 */ - function getNomUrl($withpictoimg = 0, $option = '', $infologin = 0, $notooltip = 0, $maxlen = 24, $hidethirdpartylogo = 0, $mode = '', $morecss = '', $save_lastsearch_value = -1) + public function getNomUrl($withpictoimg = 0, $option = '', $infologin = 0, $notooltip = 0, $maxlen = 24, $hidethirdpartylogo = 0, $mode = '', $morecss = '', $save_lastsearch_value = -1) { global $langs, $conf, $db, $hookmanager, $user; global $dolibarr_main_authentication, $dolibarr_main_demo; @@ -2385,7 +2383,7 @@ $mailfile = new CMailFile( * @param string $option Sur quoi pointe le lien * @return string Chaine avec URL */ - function getLoginUrl($withpicto = 0, $option = '') + public function getLoginUrl($withpicto = 0, $option = '') { global $langs, $user; @@ -2422,12 +2420,12 @@ $mailfile = new CMailFile( * @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 */ - function getLibStatut($mode = 0) + public function getLibStatut($mode = 0) { return $this->LibStatut($this->statut, $mode); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Renvoi le libelle d'un statut donne * @@ -2435,7 +2433,7 @@ $mailfile = new CMailFile( * @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 */ - function LibStatut($statut, $mode = 0) + public function LibStatut($statut, $mode = 0) { // phpcs:enable global $langs; @@ -2484,7 +2482,7 @@ $mailfile = new CMailFile( * 2=Return key only (RDN) (uid=qqq) * @return string DN */ - function _load_ldap_dn($info, $mode = 0) + private function _load_ldap_dn($info, $mode = 0) { // phpcs:enable global $conf; @@ -2501,7 +2499,7 @@ $mailfile = new CMailFile( * * @return array Tableau info des attributs */ - function _load_ldap_info() + private function _load_ldap_info() { // phpcs:enable global $conf,$langs; @@ -2623,7 +2621,7 @@ $mailfile = new CMailFile( * * @return void */ - function initAsSpecimen() + public function initAsSpecimen() { global $user,$langs; @@ -2668,7 +2666,7 @@ $mailfile = new CMailFile( * @param int $id Id of user to load * @return void */ - function info($id) + public function info($id) { $sql = "SELECT u.rowid, u.login as ref, u.datec,"; $sql.= " u.tms as date_modification, u.entity"; @@ -2684,10 +2682,10 @@ $mailfile = new CMailFile( $this->id = $obj->rowid; - $this->ref = (! $obj->ref) ? $obj->rowid : $obj->ref; - $this->date_creation = $this->db->jdate($obj->datec); + $this->ref = (! $obj->ref) ? $obj->rowid : $obj->ref; + $this->date_creation = $this->db->jdate($obj->datec); $this->date_modification = $this->db->jdate($obj->date_modification); - $this->entity = $obj->entity; + $this->entity = $obj->entity; } $this->db->free($result); @@ -2704,7 +2702,7 @@ $mailfile = new CMailFile( * * @return int Number of EMailings */ - function getNbOfEMailings() + public function getNbOfEMailings() { $sql = "SELECT count(mc.email) as nb"; $sql.= " FROM ".MAIN_DB_PREFIX."mailing_cibles as mc"; @@ -2735,7 +2733,7 @@ $mailfile = new CMailFile( * @param int $admin Filter on admin tag * @return int Number of users */ - function getNbOfUsers($limitTo, $option = '', $admin = -1) + public function getNbOfUsers($limitTo, $option = '', $admin = -1) { global $conf; @@ -2769,7 +2767,7 @@ $mailfile = new CMailFile( } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Update user using data from the LDAP * @@ -2777,7 +2775,7 @@ $mailfile = new CMailFile( * * @return int <0 if KO, >0 if OK */ - function update_ldap2dolibarr(&$ldapuser) + public function update_ldap2dolibarr(&$ldapuser) { // phpcs:enable // TODO: Voir pourquoi le update met à jour avec toutes les valeurs vide (global $user écrase ?) @@ -2809,14 +2807,14 @@ $mailfile = new CMailFile( } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return and array with all instanciated first level children users of current user * * @return void * @see getAllChildIds */ - function get_children() + public function get_children() { // phpcs:enable $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."user"; @@ -2844,9 +2842,9 @@ $mailfile = new CMailFile( /** - * Load this->parentof that is array(id_son=>id_parent, ...) + * Load this->parentof that is array(id_son=>id_parent, ...) * - * @return int <0 if KO, >0 if OK + * @return int <0 if KO, >0 if OK */ private function loadParentOf() { @@ -2891,8 +2889,8 @@ $mailfile = new CMailFile( * @param string $filter SQL filter on users * @return array Array of users $this->users. Note: $this->parentof is also set. */ - function get_full_tree($deleteafterid = 0, $filter = '') - { + public function get_full_tree($deleteafterid = 0, $filter = '') + { // phpcs:enable global $conf, $user; global $hookmanager; @@ -2993,8 +2991,8 @@ $mailfile = new CMailFile( * @return array Array of user id lower than user (all levels under user). This overwrite this->users. * @see get_children */ - function getAllChildIds($addcurrentuser = 0) - { + public function getAllChildIds($addcurrentuser = 0) + { $childids=array(); if (isset($this->cache_childids[$this->id])) @@ -3022,7 +3020,7 @@ $mailfile = new CMailFile( return $childids; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * For user id_user and its childs available in this->users, define property fullpath and fullname. * Function called by get_full_tree(). @@ -3031,8 +3029,8 @@ $mailfile = new CMailFile( * @param int $protection Deep counter to avoid infinite loop (no more required, a protection is added with array useridfound) * @return int < 0 if KO (infinit loop), >= 0 if OK */ - function build_path_from_id_user($id_user, $protection = 0) - { + public function build_path_from_id_user($id_user, $protection = 0) + { // phpcs:enable dol_syslog(get_class($this)."::build_path_from_id_user id_user=".$id_user." protection=".$protection, LOG_DEBUG); @@ -3086,13 +3084,13 @@ $mailfile = new CMailFile( } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Charge indicateurs this->nb pour le tableau de bord * * @return int <0 if KO, >0 if OK */ - function load_state_board() + public function load_state_board() { // phpcs:enable global $conf; @@ -3158,7 +3156,7 @@ $mailfile = new CMailFile( return $this->commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return property of user from its id * @@ -3166,7 +3164,7 @@ $mailfile = new CMailFile( * @param string $mode 'email' or 'mobile' * @return string Email of user with format: "Full name " */ - function user_get_property($rowid, $mode) + public function user_get_property($rowid, $mode) { // phpcs:enable $user_property=''; @@ -3208,9 +3206,9 @@ $mailfile = new CMailFile( * @param string $filtermode Filter mode (AND or OR) * @return int <0 if KO, >0 if OK */ - function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, $filter = array(), $filtermode = 'AND') - { - global $conf; + public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, $filter = array(), $filtermode = 'AND') + { + global $conf; $sql="SELECT t.rowid"; $sql.= ' FROM '.MAIN_DB_PREFIX .$this->table_element.' as t '; @@ -3263,8 +3261,8 @@ $mailfile = new CMailFile( } else { - $this->errors[] = $this->db->lasterror(); - return -1; - } - } + $this->errors[] = $this->db->lasterror(); + return -1; + } + } } diff --git a/htdocs/user/class/userbankaccount.class.php b/htdocs/user/class/userbankaccount.class.php index 8e9ad2745c3..18c1ab742a1 100644 --- a/htdocs/user/class/userbankaccount.class.php +++ b/htdocs/user/class/userbankaccount.class.php @@ -34,16 +34,16 @@ require_once DOL_DOCUMENT_ROOT .'/compta/bank/class/account.class.php'; */ class UserBankAccount extends Account { - var $socid; + public $socid; - var $datec; - var $datem; + public $datec; + public $datem; /** - * Constructor - * - * @param DoliDB $db Database handler + * Constructor + * + * @param DoliDB $db Database handler */ public function __construct(DoliDB $db) { @@ -62,7 +62,7 @@ class UserBankAccount extends Account * @param int $notrigger 1=Disable triggers * @return int <0 if KO, >= 0 if OK */ - function create(User $user = null, $notrigger = 0) + public function create(User $user = null, $notrigger = 0) { $now=dol_now(); @@ -92,9 +92,9 @@ class UserBankAccount extends Account * @param int $notrigger 1=Disable triggers * @return int <=0 if KO, >0 if OK */ - function update(User $user = null, $notrigger = 0) + public function update(User $user = null, $notrigger = 0) { - global $conf; + global $conf; if (! $this->id) { @@ -113,7 +113,7 @@ class UserBankAccount extends Account $sql.= ",proprio = '".$this->db->escape($this->proprio)."'"; $sql.= ",owner_address = '".$this->db->escape($this->owner_address)."'"; - if (trim($this->label) != '') + if (trim($this->label) != '') $sql.= ",label = '".$this->db->escape($this->label)."'"; else $sql.= ",label = NULL"; @@ -139,7 +139,7 @@ class UserBankAccount extends Account * @param int $userid User id * @return int <0 if KO, >0 if OK */ - function fetch($id, $ref = '', $userid = 0) + public function fetch($id, $ref = '', $userid = 0) { if (empty($id) && empty($ref) && empty($userid)) return -1; @@ -157,21 +157,21 @@ class UserBankAccount extends Account { $obj = $this->db->fetch_object($resql); - $this->id = $obj->rowid; - $this->socid = $obj->fk_soc; - $this->bank = $obj->bank; - $this->code_banque = $obj->code_banque; - $this->code_guichet = $obj->code_guichet; - $this->number = $obj->number; - $this->cle_rib = $obj->cle_rib; - $this->bic = $obj->bic; - $this->iban = $obj->iban; - $this->domiciliation = $obj->domiciliation; - $this->proprio = $obj->proprio; - $this->owner_address = $obj->owner_address; - $this->label = $obj->label; - $this->datec = $this->db->jdate($obj->datec); - $this->datem = $this->db->jdate($obj->datem); + $this->id = $obj->rowid; + $this->socid = $obj->fk_soc; + $this->bank = $obj->bank; + $this->code_banque = $obj->code_banque; + $this->code_guichet = $obj->code_guichet; + $this->number = $obj->number; + $this->cle_rib = $obj->cle_rib; + $this->bic = $obj->bic; + $this->iban = $obj->iban; + $this->domiciliation = $obj->domiciliation; + $this->proprio = $obj->proprio; + $this->owner_address = $obj->owner_address; + $this->label = $obj->label; + $this->datec = $this->db->jdate($obj->datec); + $this->datem = $this->db->jdate($obj->datem); } $this->db->free($resql); @@ -184,25 +184,25 @@ class UserBankAccount extends Account } } - /** - * Return RIB - * - * @param boolean $displayriblabel Prepend or Hide Label - * @return string RIB - */ - public function getRibLabel($displayriblabel = true) - { - $rib = ''; + /** + * Return RIB + * + * @param boolean $displayriblabel Prepend or Hide Label + * @return string RIB + */ + public function getRibLabel($displayriblabel = true) + { + $rib = ''; - if ($this->code_banque || $this->code_guichet || $this->number || $this->cle_rib) { + if ($this->code_banque || $this->code_guichet || $this->number || $this->cle_rib) { - if ($this->label && $displayriblabel) { - $rib = $this->label." : "; - } + if ($this->label && $displayriblabel) { + $rib = $this->label." : "; + } - $rib .= (string) $this; - } + $rib .= (string) $this; + } - return $rib; - } + return $rib; + } } diff --git a/htdocs/user/class/usergroup.class.php b/htdocs/user/class/usergroup.class.php index 4b199b4671d..3123900dc85 100644 --- a/htdocs/user/class/usergroup.class.php +++ b/htdocs/user/class/usergroup.class.php @@ -1,5 +1,5 @@ +/* Copyright (c) 2005 Rodolphe Quiedeville * Copyright (c) 2005-2018 Laurent Destailleur * Copyright (c) 2005-2018 Regis Houssin * Copyright (C) 2012 Florian Henry @@ -91,8 +91,8 @@ class UserGroup extends CommonObject * Constructor de la classe * * @param DoliDb $db Database handler - */ - function __construct($db) + */ + public function __construct($db) { $this->db = $db; $this->nb_rights = 0; @@ -100,14 +100,14 @@ class UserGroup extends CommonObject /** - * Charge un objet group avec toutes ces caracteristiques (except ->members array) + * Charge un objet group avec toutes ces caracteristiques (except ->members array) * * @param int $id Id of group to load * @param string $groupname Name of group to load * @param boolean $load_members Load all members of the group * @return int <0 if KO, >0 if OK */ - function fetch($id = '', $groupname = '', $load_members = true) + public function fetch($id = '', $groupname = '', $load_members = true) { global $conf; @@ -163,13 +163,13 @@ class UserGroup extends CommonObject /** - * Return array of groups objects for a particular user + * Return array of groups objects for a particular user * - * @param int $userid User id to search + * @param int $userid User id to search * @param boolean $load_members Load all members of the group - * @return array Array of groups objects + * @return array Array of groups objects */ - function listGroupsForUser($userid, $load_members = true) + public function listGroupsForUser($userid, $load_members = true) { global $conf, $user; @@ -224,7 +224,7 @@ class UserGroup extends CommonObject * @param int $mode 0=Return array of user instance, 1=Return array of users id only * @return mixed Array of users or -1 on error */ - function listUsersForGroup($excludefilter = '', $mode = 0) + public function listUsersForGroup($excludefilter = '', $mode = 0) { global $conf, $user; @@ -289,7 +289,7 @@ class UserGroup extends CommonObject * @param int $entity Entity to use * @return int > 0 if OK, < 0 if KO */ - function addrights($rid, $allmodule = '', $allperms = '', $entity = 0) + public function addrights($rid, $allmodule = '', $allperms = '', $entity = 0) { global $conf, $user, $langs; @@ -415,7 +415,7 @@ class UserGroup extends CommonObject * @param int $entity Entity to use * @return int > 0 if OK, < 0 if OK */ - function delrights($rid, $allmodule = '', $allperms = '', $entity = 0) + public function delrights($rid, $allmodule = '', $allperms = '', $entity = 0) { global $conf, $user, $langs; @@ -456,8 +456,7 @@ class UserGroup extends CommonObject // Pour compatibilite, si lowid = 0, on est en mode suppression de tout // TODO A virer quand sera gere par l'appelant //if (substr($rid,-1,1) == 0) $wherefordel="module='$module'"; - } - else { + } else { // Where pour la liste des droits a supprimer if (! empty($allmodule)) { @@ -535,9 +534,9 @@ class UserGroup extends CommonObject * Charge dans l'objet group, la liste des permissions auquels le groupe a droit * * @param string $moduletag Name of module we want permissions ('' means all) - * @return int <0 if KO, >0 if OK + * @return int <0 if KO, >0 if OK */ - function getrights($moduletag = '') + public function getrights($moduletag = '') { global $conf; @@ -622,7 +621,7 @@ class UserGroup extends CommonObject * @param User $user User that delete * @return <0 if KO, > 0 if OK */ - function delete(User $user) + public function delete(User $user) { global $conf,$langs; @@ -676,7 +675,7 @@ class UserGroup extends CommonObject * @param int $notrigger 0=triggers enabled, 1=triggers disabled * @return int <0 if KO, >=0 if OK */ - function create($notrigger = 0) + public function create($notrigger = 0) { global $user, $conf, $langs, $hookmanager; @@ -747,7 +746,7 @@ class UserGroup extends CommonObject * @param int $notrigger 0=triggers enabled, 1=triggers disabled * @return int <0 if KO, >=0 if OK */ - function update($notrigger = 0) + public function update($notrigger = 0) { global $user, $conf, $langs, $hookmanager; @@ -817,12 +816,12 @@ class UserGroup 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 * @return string Label of status */ - function getLibStatut($mode = 0) + public function getLibStatut($mode = 0) { return $this->LibStatut(0, $mode); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Renvoi le libelle d'un statut donne * @@ -830,7 +829,7 @@ class UserGroup 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 * @return string Label of status */ - function LibStatut($statut, $mode = 0) + public function LibStatut($statut, $mode = 0) { // phpcs:enable global $langs; @@ -840,16 +839,16 @@ class UserGroup extends CommonObject /** * Return a link to the user card (with optionaly the picto) - * Use this->id,this->lastname, this->firstname + * Use this->id,this->lastname, this->firstname * - * @param int $withpicto Include picto in link (0=No picto, 1=Include picto into link, 2=Only picto, -1=Include photo into link, -2=Only picto photo, -3=Only photo very small) - * @param string $option On what the link point to ('nolink', ) + * @param int $withpicto Include picto in link (0=No picto, 1=Include picto into link, 2=Only picto, -1=Include photo into link, -2=Only picto photo, -3=Only photo very small) + * @param string $option On what the link point to ('nolink', ) * @param integer $notooltip 1=Disable tooltip on picto and name * @param string $morecss Add more css on link * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking * @return string String with URL */ - 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 $langs, $conf, $db, $hookmanager; global $dolibarr_main_authentication, $dolibarr_main_demo; @@ -925,7 +924,7 @@ class UserGroup extends CommonObject * 2=Return key only (uid=qqq) * @return string DN */ - function _load_ldap_dn($info, $mode = 0) + private function _load_ldap_dn($info, $mode = 0) { // phpcs:enable global $conf; @@ -943,7 +942,7 @@ class UserGroup extends CommonObject * * @return array Tableau info des attributs */ - function _load_ldap_info() + private function _load_ldap_info() { // phpcs:enable global $conf,$langs; @@ -979,8 +978,8 @@ class UserGroup extends CommonObject * id must be 0 if object instance is a specimen. * * @return void - */ - function initAsSpecimen() + */ + public function initAsSpecimen() { global $conf, $user, $langs; @@ -994,11 +993,11 @@ class UserGroup extends CommonObject $this->datec=time(); $this->datem=time(); - // Members of this group is just me - $this->members=array( - $user->id => $user - ); - } + // Members of this group is just me + $this->members=array( + $user->id => $user + ); + } /** * Create a document onto disk according to template module. diff --git a/htdocs/variants/class/ProductAttributeValue.class.php b/htdocs/variants/class/ProductAttributeValue.class.php index e5257c5fd0a..09c733e3dc7 100644 --- a/htdocs/variants/class/ProductAttributeValue.class.php +++ b/htdocs/variants/class/ProductAttributeValue.class.php @@ -63,7 +63,7 @@ class ProductAttributeValue $this->db = $db; $this->entity = $conf->entity; - } + } /** * Gets a product attribute value diff --git a/htdocs/website/class/website.class.php b/htdocs/website/class/website.class.php index 9d36449da30..6bfbadfb197 100644 --- a/htdocs/website/class/website.class.php +++ b/htdocs/website/class/website.class.php @@ -134,15 +134,15 @@ class Website extends CommonObject if (isset($this->status)) { $this->status = (int) $this->status; } - if (empty($this->date_creation)) { + if (empty($this->date_creation)) { $this->date_creation = $now; } - if (empty($this->date_modification)) { + if (empty($this->date_modification)) { $this->date_modification = $now; } - // Check parameters - if (empty($this->entity)) { + // Check parameters + if (empty($this->entity)) { $this->entity = $conf->entity; } @@ -671,7 +671,7 @@ class Website extends CommonObject * @param string $morecss Add more css on link * @return string String with URL */ - function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $maxlen = 24, $morecss = '') + public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $maxlen = 24, $morecss = '') { global $langs, $conf, $db; global $dolibarr_main_authentication, $dolibarr_main_demo; @@ -707,12 +707,12 @@ class Website 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 * @return string Label of status */ - function getLibStatut($mode = 0) + public function getLibStatut($mode = 0) { return $this->LibStatut($this->status, $mode); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Renvoi le libelle d'un status donne * @@ -720,7 +720,7 @@ class Website 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 * @return string Label of status */ - function LibStatut($status, $mode = 0) + public function LibStatut($status, $mode = 0) { // phpcs:enable global $langs; @@ -728,27 +728,27 @@ class Website extends CommonObject if ($mode == 0 || $mode == 1) { if ($status == 1) return $langs->trans('Enabled'); - if ($status == 0) return $langs->trans('Disabled'); + elseif ($status == 0) return $langs->trans('Disabled'); } elseif ($mode == 2) { if ($status == 1) return img_picto($langs->trans('Enabled'), 'statut4').' '.$langs->trans('Enabled'); - if ($status == 0) return img_picto($langs->trans('Disabled'), 'statut5').' '.$langs->trans('Disabled'); + elseif ($status == 0) return img_picto($langs->trans('Disabled'), 'statut5').' '.$langs->trans('Disabled'); } elseif ($mode == 3) { if ($status == 1) return img_picto($langs->trans('Enabled'), 'statut4'); - if ($status == 0) return img_picto($langs->trans('Disabled'), 'statut5'); + elseif ($status == 0) return img_picto($langs->trans('Disabled'), 'statut5'); } elseif ($mode == 4) { if ($status == 1) return img_picto($langs->trans('Enabled'), 'statut4').' '.$langs->trans('Enabled'); - if ($status == 0) return img_picto($langs->trans('Disabled'), 'statut5').' '.$langs->trans('Disabled'); + elseif ($status == 0) return img_picto($langs->trans('Disabled'), 'statut5').' '.$langs->trans('Disabled'); } elseif ($mode == 5) { if ($status == 1) return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'), 'statut4'); - if ($status == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'), 'statut5'); + elseif ($status == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'), 'statut5'); } } @@ -783,7 +783,7 @@ class Website extends CommonObject * * @return string Path to file with zip */ - function exportWebSite() + public function exportWebSite() { global $conf, $mysoc; @@ -958,7 +958,7 @@ class Website extends CommonObject * @param string $pathtofile Path of zip file * @return int <0 if KO, Id of new website if OK */ - function importWebSite($pathtofile) + public function importWebSite($pathtofile) { global $conf, $mysoc; @@ -1195,22 +1195,22 @@ class Website extends CommonObject $out.= ''; } $i=0; - if (is_array($languagecodes)) - { - foreach($languagecodes as $languagecode) - { - if ($languagecode == $languagecodeselected) continue; // Already output - $shortcode = strtolower(substr($languagecode, -2)); - $label = $weblangs->trans("Language_".$languagecode); - if ($shortcode == 'us') $label = preg_replace('/\s*\(.*\)/', '', $label); - $out.= '
  • '.$label; - if (empty($i) && empty($languagecodeselected)) $out.= ''; - $out.= '
  • '; - $i++; - } - } - $out.= ''; + if (is_array($languagecodes)) + { + foreach($languagecodes as $languagecode) + { + if ($languagecode == $languagecodeselected) continue; // Already output + $shortcode = strtolower(substr($languagecode, -2)); + $label = $weblangs->trans("Language_".$languagecode); + if ($shortcode == 'us') $label = preg_replace('/\s*\(.*\)/', '', $label); + $out.= '
  • '.$label; + if (empty($i) && empty($languagecodeselected)) $out.= ''; + $out.= '
  • '; + $i++; + } + } + $out.= ''; - return $out; - } + return $out; + } } diff --git a/htdocs/website/class/websitepage.class.php b/htdocs/website/class/websitepage.class.php index 62a50ed1a56..8814756284c 100644 --- a/htdocs/website/class/websitepage.class.php +++ b/htdocs/website/class/websitepage.class.php @@ -148,12 +148,12 @@ class WebsitePage extends CommonObject /** * Load object in memory from the database * - * @param int $id Id object. - * - If this is 0, the value into $page will be used. If not found or $page not defined, the default page of website_id will be used or the first page found if not set. - * - If value is < 0, we must exclude this ID. - * @param string $website_id Web site id (page name must also be filled if this parameter is used) - * @param string $page Page name (website id must also be filled if this parameter is used) - * @param string $aliasalt Alternative alias to search page (slow) + * @param int $id Id object. + * - If this is 0, the value into $page will be used. If not found or $page not defined, the default page of website_id will be used or the first page found if not set. + * - If value is < 0, we must exclude this ID. + * @param string $website_id Web site id (page name must also be filled if this parameter is used) + * @param string $page Page name (website id must also be filled if this parameter is used) + * @param string $aliasalt Alternative alias to search page (slow) * * @return int <0 if KO, 0 if not found, >0 if OK */ @@ -472,7 +472,7 @@ class WebsitePage extends CommonObject * @param string $morecss Add more css on link * @return string String with URL */ - function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $maxlen = 24, $morecss = '') + public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $maxlen = 24, $morecss = '') { global $langs, $conf, $db; global $dolibarr_main_authentication, $dolibarr_main_demo; @@ -507,12 +507,12 @@ class WebsitePage 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 * @return string Label of status */ - function getLibStatut($mode = 0) + public function getLibStatut($mode = 0) { return $this->LibStatut($this->status, $mode); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Renvoi le libelle d'un status donne * @@ -520,7 +520,7 @@ class WebsitePage 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 * @return string Label of status */ - function LibStatut($status, $mode = 0) + public function LibStatut($status, $mode = 0) { // phpcs:enable global $langs; @@ -529,32 +529,32 @@ class WebsitePage extends CommonObject { $prefix=''; if ($status == 1) return $langs->trans('Enabled'); - if ($status == 0) return $langs->trans('Disabled'); + elseif ($status == 0) return $langs->trans('Disabled'); } elseif ($mode == 1) { if ($status == 1) return $langs->trans('Enabled'); - if ($status == 0) return $langs->trans('Disabled'); + elseif ($status == 0) return $langs->trans('Disabled'); } elseif ($mode == 2) { if ($status == 1) return img_picto($langs->trans('Enabled'), 'statut4').' '.$langs->trans('Enabled'); - if ($status == 0) return img_picto($langs->trans('Disabled'), 'statut5').' '.$langs->trans('Disabled'); + elseif ($status == 0) return img_picto($langs->trans('Disabled'), 'statut5').' '.$langs->trans('Disabled'); } elseif ($mode == 3) { if ($status == 1) return img_picto($langs->trans('Enabled'), 'statut4'); - if ($status == 0) return img_picto($langs->trans('Disabled'), 'statut5'); + elseif ($status == 0) return img_picto($langs->trans('Disabled'), 'statut5'); } elseif ($mode == 4) { if ($status == 1) return img_picto($langs->trans('Enabled'), 'statut4').' '.$langs->trans('Enabled'); - if ($status == 0) return img_picto($langs->trans('Disabled'), 'statut5').' '.$langs->trans('Disabled'); + elseif ($status == 0) return img_picto($langs->trans('Disabled'), 'statut5').' '.$langs->trans('Disabled'); } elseif ($mode == 5) { if ($status == 1) return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'), 'statut4'); - if ($status == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'), 'statut5'); + elseif ($status == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'), 'statut5'); } }