Merge branch '11.0' of git@github.com:Dolibarr/dolibarr.git into 12.0

Conflicts:
	htdocs/projet/class/project.class.php
This commit is contained in:
Laurent Destailleur 2020-05-20 23:58:32 +02:00
commit 86de0d5e14

View File

@ -1228,9 +1228,9 @@ class Project extends CommonObject
} }
return ($userAccess ? $userAccess : -1); return ($userAccess ? $userAccess : -1);
} }
/** /**
* Return array of projects a user has permission on, is affected to, or all projects * Return array of projects a user has permission on, is affected to, or all projects
* *
* @param User $user User object * @param User $user User object
@ -1240,8 +1240,8 @@ class Project extends CommonObject
* @param string $filter additionnal filter on project (statut, ref, ...) * @param string $filter additionnal filter on project (statut, ref, ...)
* @return array or string Array of projects id, or string with projects id separated with "," if list is 1 * @return array or string Array of projects id, or string with projects id separated with "," if list is 1
*/ */
public function getProjectsAuthorizedForUser($user, $mode = 0, $list = 0, $socid = 0, $filter = '') public function getProjectsAuthorizedForUser($user, $mode = 0, $list = 0, $socid = 0, $filter = '')
{ {
$projects = array(); $projects = array();
$temp = array(); $temp = array();
@ -1331,9 +1331,9 @@ public function getProjectsAuthorizedForUser($user, $mode = 0, $list = 0, $socid
} }
return $projects; return $projects;
} }
/** /**
* Load an object from its id and create a new one in database * Load an object from its id and create a new one in database
* *
* @param User $user User making the clone * @param User $user User making the clone
@ -1348,8 +1348,8 @@ public function getProjectsAuthorizedForUser($user, $mode = 0, $list = 0, $socid
* @param int $newthirdpartyid New thirdparty id * @param int $newthirdpartyid New thirdparty id
* @return int New id of clone * @return int New id of clone
*/ */
public function createFromClone(User $user, $fromid, $clone_contact = false, $clone_task = true, $clone_project_file = false, $clone_task_file = false, $clone_note = true, $move_date = true, $notrigger = 0, $newthirdpartyid = 0) public function createFromClone(User $user, $fromid, $clone_contact = false, $clone_task = true, $clone_project_file = false, $clone_task_file = false, $clone_note = true, $move_date = true, $notrigger = 0, $newthirdpartyid = 0)
{ {
global $langs, $conf; global $langs, $conf;
$error = 0; $error = 0;
@ -1592,17 +1592,17 @@ public function createFromClone(User $user, $fromid, $clone_contact = false, $cl
dol_syslog(get_class($this)."::createFromClone nbError: ".$error." error : ".$this->error, LOG_ERR); dol_syslog(get_class($this)."::createFromClone nbError: ".$error." error : ".$this->error, LOG_ERR);
return -1; return -1;
} }
} }
/** /**
* Shift project task date from current date to delta * Shift project task date from current date to delta
* *
* @param integer $old_project_dt_start Old project start date * @param integer $old_project_dt_start Old project start date
* @return int 1 if OK or < 0 if KO * @return int 1 if OK or < 0 if KO
*/ */
public function shiftTaskDate($old_project_dt_start) public function shiftTaskDate($old_project_dt_start)
{ {
global $user, $langs, $conf; global $user, $langs, $conf;
$error=0; $error=0;
@ -1660,19 +1660,19 @@ public function shiftTaskDate($old_project_dt_start)
return -1; return -1;
} }
return $result; return $result;
} }
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/** /**
* Associate element to a project * Associate element to a project
* *
* @param string $tableName Table of the element to update * @param string $tableName Table of the element to update
* @param int $elementSelectId Key-rowid of the line of the element to update * @param int $elementSelectId Key-rowid of the line of the element to update
* @return int 1 if OK or < 0 if KO * @return int 1 if OK or < 0 if KO
*/ */
public function update_element($tableName, $elementSelectId) public function update_element($tableName, $elementSelectId)
{ {
// phpcs:enable // phpcs:enable
$sql = "UPDATE ".MAIN_DB_PREFIX.$tableName; $sql = "UPDATE ".MAIN_DB_PREFIX.$tableName;
@ -1695,10 +1695,10 @@ public function update_element($tableName, $elementSelectId)
} else { } else {
return 1; return 1;
} }
} }
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/** /**
* Associate element to a project * Associate element to a project
* *
* @param string $tableName Table of the element to update * @param string $tableName Table of the element to update
@ -1707,8 +1707,8 @@ public function update_element($tableName, $elementSelectId)
* *
* @return int 1 if OK or < 0 if KO * @return int 1 if OK or < 0 if KO
*/ */
public function remove_element($tableName, $elementSelectId, $projectfield = 'fk_projet') public function remove_element($tableName, $elementSelectId, $projectfield = 'fk_projet')
{ {
// phpcs:enable // phpcs:enable
$sql = "UPDATE ".MAIN_DB_PREFIX.$tableName; $sql = "UPDATE ".MAIN_DB_PREFIX.$tableName;
@ -1730,9 +1730,9 @@ public function remove_element($tableName, $elementSelectId, $projectfield = 'fk
} else { } else {
return 1; return 1;
} }
} }
/** /**
* Create an intervention document on disk using template defined into PROJECT_ADDON_PDF * Create an intervention document on disk using template defined into PROJECT_ADDON_PDF
* *
* @param string $modele Force template to use ('' by default) * @param string $modele Force template to use ('' by default)
@ -1742,8 +1742,8 @@ public function remove_element($tableName, $elementSelectId, $projectfield = 'fk
* @param int $hideref Hide ref * @param int $hideref Hide ref
* @return int 0 if KO, 1 if OK * @return int 0 if KO, 1 if OK
*/ */
public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0) public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0)
{ {
global $conf,$langs; global $conf,$langs;
$langs->load("projects"); $langs->load("projects");
@ -1761,10 +1761,10 @@ public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hided
$modelpath = "core/modules/project/doc/"; $modelpath = "core/modules/project/doc/";
return $this->commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref); return $this->commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref);
} }
/** /**
* Load time spent into this->weekWorkLoad and this->weekWorkLoadPerTask for all day of a week of project. * Load time spent into this->weekWorkLoad and this->weekWorkLoadPerTask for all day of a week of project.
* Note: array weekWorkLoad and weekWorkLoadPerTask are reset and filled at each call. * Note: array weekWorkLoad and weekWorkLoadPerTask are reset and filled at each call.
* *
@ -1773,8 +1773,8 @@ public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hided
* @param int $userid Time spent by a particular user * @param int $userid Time spent by a particular user
* @return int <0 if OK, >0 if KO * @return int <0 if OK, >0 if KO
*/ */
public function loadTimeSpent($datestart, $taskid = 0, $userid = 0) public function loadTimeSpent($datestart, $taskid = 0, $userid = 0)
{ {
$error=0; $error=0;
$this->weekWorkLoad=array(); $this->weekWorkLoad=array();
@ -1826,9 +1826,9 @@ public function loadTimeSpent($datestart, $taskid = 0, $userid = 0)
dol_syslog(get_class($this)."::fetch ".$this->error, LOG_ERR); dol_syslog(get_class($this)."::fetch ".$this->error, LOG_ERR);
return -1; return -1;
} }
} }
/** /**
* Load time spent into this->weekWorkLoad and this->weekWorkLoadPerTask for all day of a week of project. * Load time spent into this->weekWorkLoad and this->weekWorkLoadPerTask for all day of a week of project.
* Note: array weekWorkLoad and weekWorkLoadPerTask are reset and filled at each call. * Note: array weekWorkLoad and weekWorkLoadPerTask are reset and filled at each call.
* *
@ -1837,8 +1837,8 @@ public function loadTimeSpent($datestart, $taskid = 0, $userid = 0)
* @param int $userid Time spent by a particular user * @param int $userid Time spent by a particular user
* @return int <0 if OK, >0 if KO * @return int <0 if OK, >0 if KO
*/ */
public function loadTimeSpentMonth($datestart, $taskid = 0, $userid = 0) public function loadTimeSpentMonth($datestart, $taskid = 0, $userid = 0)
{ {
$error = 0; $error = 0;
$this->monthWorkLoad = array(); $this->monthWorkLoad = array();
@ -1893,18 +1893,18 @@ public function loadTimeSpentMonth($datestart, $taskid = 0, $userid = 0)
dol_syslog(get_class($this)."::fetch ".$this->error, LOG_ERR); dol_syslog(get_class($this)."::fetch ".$this->error, LOG_ERR);
return -1; return -1;
} }
} }
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/** /**
* Load indicators for dashboard (this->nbtodo and this->nbtodolate) * Load indicators for dashboard (this->nbtodo and this->nbtodolate)
* *
* @param User $user Objet user * @param User $user Objet user
* @return WorkboardResponse|int <0 if KO, WorkboardResponse if OK * @return WorkboardResponse|int <0 if KO, WorkboardResponse if OK
*/ */
public function load_board($user) public function load_board($user)
{ {
// phpcs:enable // phpcs:enable
global $conf, $langs; global $conf, $langs;
@ -1963,10 +1963,10 @@ public function load_board($user)
$this->error = $this->db->error(); $this->error = $this->db->error();
return -1; return -1;
} }
} }
/** /**
* Function used to replace a thirdparty id with another one. * Function used to replace a thirdparty id with another one.
* *
* @param DoliDB $db Database handler * @param DoliDB $db Database handler
@ -1974,24 +1974,24 @@ public function load_board($user)
* @param int $dest_id New thirdparty id * @param int $dest_id New thirdparty id
* @return bool * @return bool
*/ */
public static function replaceThirdparty(DoliDB $db, $origin_id, $dest_id) public static function replaceThirdparty(DoliDB $db, $origin_id, $dest_id)
{ {
$tables = array( $tables = array(
'projet' 'projet'
); );
return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables); return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables);
} }
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/** /**
* Charge indicateurs this->nb pour le tableau de bord * Charge indicateurs this->nb pour le tableau de bord
* *
* @return int <0 if KO, >0 if OK * @return int <0 if KO, >0 if OK
*/ */
public function load_state_board() public function load_state_board()
{ {
// phpcs:enable // phpcs:enable
global $user; global $user;
@ -2023,16 +2023,16 @@ public function load_state_board()
$this->error = $this->db->error(); $this->error = $this->db->error();
return -1; return -1;
} }
} }
/** /**
* Is the project delayed? * Is the project delayed?
* *
* @return bool * @return bool
*/ */
public function hasDelay() public function hasDelay()
{ {
global $conf; global $conf;
if (!($this->statut == self::STATUS_VALIDATED)) return false; if (!($this->statut == self::STATUS_VALIDATED)) return false;
@ -2041,17 +2041,17 @@ public function hasDelay()
$now = dol_now(); $now = dol_now();
return ($this->datee ? $this->datee : $this->date_end) < ($now - $conf->projet->warning_delay); return ($this->datee ? $this->datee : $this->date_end) < ($now - $conf->projet->warning_delay);
} }
/** /**
* Charge les informations d'ordre info dans l'objet commande * Charge les informations d'ordre info dans l'objet commande
* *
* @param int $id Id of order * @param int $id Id of order
* @return void * @return void
*/ */
public function info($id) public function info($id)
{ {
$sql = 'SELECT c.rowid, datec as datec, tms as datem,'; $sql = 'SELECT c.rowid, datec as datec, tms as datem,';
$sql .= ' date_close as datecloture,'; $sql .= ' date_close as datecloture,';
$sql .= ' fk_user_creat as fk_user_author, fk_user_close as fk_use_cloture'; $sql .= ' fk_user_creat as fk_user_author, fk_user_close as fk_use_cloture';
@ -2089,9 +2089,9 @@ public function info($id)
{ {
dol_print_error($this->db); dol_print_error($this->db);
} }
} }
/** /**
* Sets object to supplied categories. * Sets object to supplied categories.
* *
* Deletes object from existing categories not supplied. * Deletes object from existing categories not supplied.
@ -2101,8 +2101,8 @@ public function info($id)
* @param int[]|int $categories Category or categories IDs * @param int[]|int $categories Category or categories IDs
* @return void * @return void
*/ */
public function setCategories($categories) public function setCategories($categories)
{ {
$type_categ = Categorie::TYPE_PROJECT; $type_categ = Categorie::TYPE_PROJECT;
// Handle single category // Handle single category
@ -2147,20 +2147,20 @@ public function setCategories($categories)
} }
return 1; return 1;
} }
/** /**
* Create an array of tasks of current project * Create an array of tasks of current project
* *
* @param User $user Object user we want project allowed to * @param User $user Object user we want project allowed to
* @return int >0 if OK, <0 if KO * @return int >0 if OK, <0 if KO
*/ */
public function getLinesArray($user) public function getLinesArray($user)
{ {
require_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php'; require_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php';
$taskstatic = new Task($this->db); $taskstatic = new Task($this->db);
$this->lines = $taskstatic->getTasksArray(0, $user, $this->id, 0, 0); $this->lines = $taskstatic->getTasksArray(0, $user, $this->id, 0, 0);
} }
} }