Merge branch '11.0' of git@github.com:Dolibarr/dolibarr.git into 12.0
Conflicts: htdocs/core/tpl/objectline_title.tpl.php htdocs/langs/en_US/bills.lang htdocs/projet/class/project.class.php
This commit is contained in:
commit
cce72ad8d6
@ -83,7 +83,7 @@ print '<td class="linecoldiscount right">'.$langs->trans('ReductionShort').'</td
|
|||||||
// Fields for situation invoice
|
// Fields for situation invoice
|
||||||
if ($this->situation_cycle_ref) {
|
if ($this->situation_cycle_ref) {
|
||||||
print '<td class="linecolcycleref right">'.$langs->trans('Progress').'</td>';
|
print '<td class="linecolcycleref right">'.$langs->trans('Progress').'</td>';
|
||||||
print '<td class="linecolcycleref2 right">'.$langs->trans('TotalHT100Short').'</td>';
|
print '<td class="linecolcycleref2 right">'.$form->textwithpicto($langs->trans('TotalHT100Short'), $langs->trans('UnitPriceXQtyLessDiscount')).'</td>';
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($usemargins && !empty($conf->margin->enabled) && empty($user->socid))
|
if ($usemargins && !empty($conf->margin->enabled) && empty($user->socid))
|
||||||
|
|||||||
@ -491,8 +491,13 @@ UPDATE llx_accounting_bookkeeping set date_creation = tms where date_creation IS
|
|||||||
-- UPDATE llx_facturedet_rec set label = NULL WHERE label IS NOT NULL;
|
-- UPDATE llx_facturedet_rec set label = NULL WHERE label IS NOT NULL;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
UPDATE llx_facturedet SET situation_percent = 100 WHERE situation_percent IS NULL AND fk_prev_id IS NULL;
|
UPDATE llx_facturedet SET situation_percent = 100 WHERE situation_percent IS NULL AND fk_prev_id IS NULL;
|
||||||
|
|
||||||
|
-- Test inconsistency of data into situation invoices: If it differs, it may be the total_ht that is wrong and situation_percent that is good.
|
||||||
|
-- select f.rowid, f.type, qty, subprice, situation_percent, total_ht, total_ttc, total_tva, multicurrency_total_ht, multicurrency_total_tva, multicurrency_total_ttc, (situation_percent / 100 * subprice * qty * (1 - (fd.remise_percent / 100)))
|
||||||
|
-- from llx_facturedet as fd, llx_facture as f where fd.fk_facture = f.rowid AND (total_ht - situation_percent / 100 * subprice * qty * (1 - (fd.remise_percent / 100))) > 0.01 and f.type = 5;
|
||||||
|
|
||||||
|
|
||||||
-- Note to make all deposit as payed when there is already a discount generated from it.
|
-- Note to make all deposit as payed when there is already a discount generated from it.
|
||||||
--drop table tmp_invoice_deposit_mark_as_available;
|
--drop table tmp_invoice_deposit_mark_as_available;
|
||||||
@ -501,6 +506,7 @@ UPDATE llx_facturedet SET situation_percent = 100 WHERE situation_percent IS NUL
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
-- Note to migrate from old counter aquarium to new one
|
-- Note to migrate from old counter aquarium to new one
|
||||||
-- drop table tmp;
|
-- drop table tmp;
|
||||||
-- create table tmp select rowid, code_client, concat(substr(code_client, 1, 6),'-0',substr(code_client, 8, 5)) as code_client2 from llx_societe where code_client like 'CU____-____';
|
-- create table tmp select rowid, code_client, concat(substr(code_client, 1, 6),'-0',substr(code_client, 8, 5)) as code_client2 from llx_societe where code_client like 'CU____-____';
|
||||||
|
|||||||
@ -573,3 +573,4 @@ AutoFillDateToShort=Set end date
|
|||||||
MaxNumberOfGenerationReached=Max number of gen. reached
|
MaxNumberOfGenerationReached=Max number of gen. reached
|
||||||
BILL_DELETEInDolibarr=Invoice deleted
|
BILL_DELETEInDolibarr=Invoice deleted
|
||||||
BILL_SUPPLIER_DELETEInDolibarr=Supplier invoice deleted
|
BILL_SUPPLIER_DELETEInDolibarr=Supplier invoice deleted
|
||||||
|
UnitPriceXQtyLessDiscount=Unit price x Qty - Discount
|
||||||
|
|||||||
@ -164,7 +164,7 @@ class Project extends CommonObject
|
|||||||
const STATUS_CLOSED = 2;
|
const STATUS_CLOSED = 2;
|
||||||
|
|
||||||
|
|
||||||
public $fields = array(
|
public $fields=array(
|
||||||
'rowid' =>array('type'=>'integer', 'label'=>'ID', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>10),
|
'rowid' =>array('type'=>'integer', 'label'=>'ID', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>10),
|
||||||
'fk_soc' =>array('type'=>'integer', 'label'=>'Fk soc', 'enabled'=>1, 'visible'=>-1, 'position'=>15),
|
'fk_soc' =>array('type'=>'integer', 'label'=>'Fk soc', 'enabled'=>1, 'visible'=>-1, 'position'=>15),
|
||||||
'datec' =>array('type'=>'datetime', 'label'=>'Datec', 'enabled'=>1, 'visible'=>-1, 'position'=>20),
|
'datec' =>array('type'=>'datetime', 'label'=>'Datec', 'enabled'=>1, 'visible'=>-1, 'position'=>20),
|
||||||
@ -316,15 +316,12 @@ class Project extends CommonObject
|
|||||||
|
|
||||||
// Update extrafield
|
// Update extrafield
|
||||||
if (!$error) {
|
if (!$error) {
|
||||||
if (!$error)
|
|
||||||
{
|
|
||||||
$result = $this->insertExtraFields();
|
$result = $this->insertExtraFields();
|
||||||
if ($result < 0)
|
if ($result < 0)
|
||||||
{
|
{
|
||||||
$error++;
|
$error++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (!$error && !empty($conf->global->MAIN_DISABLEDRAFTSTATUS))
|
if (!$error && !empty($conf->global->MAIN_DISABLEDRAFTSTATUS))
|
||||||
{
|
{
|
||||||
@ -403,8 +400,6 @@ class Project extends CommonObject
|
|||||||
if ($resql)
|
if ($resql)
|
||||||
{
|
{
|
||||||
// Update extrafield
|
// Update extrafield
|
||||||
if (!$error)
|
|
||||||
{
|
|
||||||
if (!$error)
|
if (!$error)
|
||||||
{
|
{
|
||||||
$result = $this->insertExtraFields();
|
$result = $this->insertExtraFields();
|
||||||
@ -413,7 +408,6 @@ class Project extends CommonObject
|
|||||||
$error++;
|
$error++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (!$error && !$notrigger)
|
if (!$error && !$notrigger)
|
||||||
{
|
{
|
||||||
@ -617,7 +611,7 @@ class Project extends CommonObject
|
|||||||
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX.$tablename." WHERE ".$projectkey." IN (".$ids.") AND entity IN (".getEntity($type).")";
|
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX.$tablename." WHERE ".$projectkey." IN (".$ids.") AND entity IN (".getEntity($type).")";
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($dates > 0 && $type == 'loan') {
|
if($dates > 0 && $type == 'loan'){
|
||||||
$sql .= " AND (dateend > '".$this->db->idate($dates)."' OR dateend IS NULL)";
|
$sql .= " AND (dateend > '".$this->db->idate($dates)."' OR dateend IS NULL)";
|
||||||
}
|
}
|
||||||
elseif ($dates > 0 && ($type != 'project_task')) // For table project_taks, we want the filter on date apply on project_time_spent table
|
elseif ($dates > 0 && ($type != 'project_task')) // For table project_taks, we want the filter on date apply on project_time_spent table
|
||||||
@ -627,7 +621,7 @@ class Project extends CommonObject
|
|||||||
$sql .= " AND (".$datefieldname." >= '".$this->db->idate($dates)."' OR ".$datefieldname." IS NULL)";
|
$sql .= " AND (".$datefieldname." >= '".$this->db->idate($dates)."' OR ".$datefieldname." IS NULL)";
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($datee > 0 && $type == 'loan') {
|
if($datee > 0 && $type == 'loan'){
|
||||||
$sql .= " AND (datestart < '".$this->db->idate($datee)."' OR datestart IS NULL)";
|
$sql .= " AND (datestart < '".$this->db->idate($datee)."' OR datestart IS NULL)";
|
||||||
}
|
}
|
||||||
elseif ($datee > 0 && ($type != 'project_task')) // For table project_taks, we want the filter on date apply on project_time_spent table
|
elseif ($datee > 0 && ($type != 'project_task')) // For table project_taks, we want the filter on date apply on project_time_spent table
|
||||||
@ -938,15 +932,14 @@ class Project extends CommonObject
|
|||||||
|
|
||||||
$error = 0;
|
$error = 0;
|
||||||
|
|
||||||
if ($this->statut != 2)
|
if ($this->statut != self::STATUS_CLOSED)
|
||||||
{
|
{
|
||||||
$this->db->begin();
|
$this->db->begin();
|
||||||
|
|
||||||
$sql = "UPDATE ".MAIN_DB_PREFIX."projet";
|
$sql = "UPDATE ".MAIN_DB_PREFIX."projet";
|
||||||
$sql .= " SET fk_statut = 2, fk_user_close = ".$user->id.", date_close = '".$this->db->idate($now)."'";
|
$sql .= " SET fk_statut = ".self::STATUS_CLOSED.", fk_user_close = ".$user->id.", date_close = '".$this->db->idate($now)."'";
|
||||||
$sql .= " WHERE rowid = ".$this->id;
|
$sql .= " WHERE rowid = ".$this->id;
|
||||||
$sql .= " AND entity = ".$conf->entity;
|
$sql .= " AND fk_statut = ".self::STATUS_VALIDATED;
|
||||||
$sql .= " AND fk_statut = 1";
|
|
||||||
|
|
||||||
if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES))
|
if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES))
|
||||||
{
|
{
|
||||||
@ -1232,9 +1225,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
|
||||||
@ -1244,67 +1237,67 @@ 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();
|
||||||
|
|
||||||
$sql = "SELECT ".(($mode == 0 || $mode == 1) ? "DISTINCT " : "")."p.rowid, p.ref";
|
$sql = "SELECT ".(($mode == 0 || $mode == 1) ? "DISTINCT " : "")."p.rowid, p.ref";
|
||||||
$sql .= " FROM ".MAIN_DB_PREFIX."projet as p";
|
$sql.= " FROM " . MAIN_DB_PREFIX . "projet as p";
|
||||||
if ($mode == 0)
|
if ($mode == 0)
|
||||||
{
|
{
|
||||||
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."element_contact as ec ON ec.element_id = p.rowid";
|
$sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "element_contact as ec ON ec.element_id = p.rowid";
|
||||||
}
|
}
|
||||||
elseif ($mode == 1)
|
elseif ($mode == 1)
|
||||||
{
|
{
|
||||||
$sql .= ", ".MAIN_DB_PREFIX."element_contact as ec";
|
$sql.= ", " . MAIN_DB_PREFIX . "element_contact as ec";
|
||||||
}
|
}
|
||||||
elseif ($mode == 2)
|
elseif ($mode == 2)
|
||||||
{
|
{
|
||||||
// No filter. Use this if user has permission to see all project
|
// No filter. Use this if user has permission to see all project
|
||||||
}
|
}
|
||||||
$sql .= " WHERE p.entity IN (".getEntity('project').")";
|
$sql.= " WHERE p.entity IN (".getEntity('project').")";
|
||||||
// Internal users must see project he is contact to even if project linked to a third party he can't see.
|
// Internal users must see project he is contact to even if project linked to a third party he can't see.
|
||||||
//if ($socid || ! $user->rights->societe->client->voir) $sql.= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")";
|
//if ($socid || ! $user->rights->societe->client->voir) $sql.= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")";
|
||||||
if ($socid > 0) $sql .= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")";
|
if ($socid > 0) $sql.= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = " . $socid . ")";
|
||||||
|
|
||||||
// Get id of types of contacts for projects (This list never contains a lot of elements)
|
// Get id of types of contacts for projects (This list never contains a lot of elements)
|
||||||
$listofprojectcontacttype = array();
|
$listofprojectcontacttype=array();
|
||||||
$sql2 = "SELECT ctc.rowid, ctc.code FROM ".MAIN_DB_PREFIX."c_type_contact as ctc";
|
$sql2 = "SELECT ctc.rowid, ctc.code FROM ".MAIN_DB_PREFIX."c_type_contact as ctc";
|
||||||
$sql2 .= " WHERE ctc.element = '".$this->db->escape($this->element)."'";
|
$sql2.= " WHERE ctc.element = '" . $this->db->escape($this->element) . "'";
|
||||||
$sql2 .= " AND ctc.source = 'internal'";
|
$sql2.= " AND ctc.source = 'internal'";
|
||||||
$resql = $this->db->query($sql2);
|
$resql = $this->db->query($sql2);
|
||||||
if ($resql)
|
if ($resql)
|
||||||
{
|
{
|
||||||
while ($obj = $this->db->fetch_object($resql))
|
while($obj = $this->db->fetch_object($resql))
|
||||||
{
|
{
|
||||||
$listofprojectcontacttype[$obj->rowid] = $obj->code;
|
$listofprojectcontacttype[$obj->rowid]=$obj->code;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else dol_print_error($this->db);
|
else dol_print_error($this->db);
|
||||||
if (count($listofprojectcontacttype) == 0) $listofprojectcontacttype[0] = '0'; // To avoid syntax error if not found
|
if (count($listofprojectcontacttype) == 0) $listofprojectcontacttype[0]='0'; // To avoid syntax error if not found
|
||||||
|
|
||||||
if ($mode == 0)
|
if ($mode == 0)
|
||||||
{
|
{
|
||||||
$sql .= " AND ( p.public = 1";
|
$sql.= " AND ( p.public = 1";
|
||||||
$sql .= " OR ( ec.fk_c_type_contact IN (".join(',', array_keys($listofprojectcontacttype)).")";
|
$sql.= " OR ( ec.fk_c_type_contact IN (".join(',', array_keys($listofprojectcontacttype)).")";
|
||||||
$sql .= " AND ec.fk_socpeople = ".$user->id.")";
|
$sql.= " AND ec.fk_socpeople = ".$user->id.")";
|
||||||
$sql .= " )";
|
$sql.= " )";
|
||||||
}
|
}
|
||||||
elseif ($mode == 1)
|
elseif ($mode == 1)
|
||||||
{
|
{
|
||||||
$sql .= " AND ec.element_id = p.rowid";
|
$sql.= " AND ec.element_id = p.rowid";
|
||||||
$sql .= " AND (";
|
$sql.= " AND (";
|
||||||
$sql .= " ( ec.fk_c_type_contact IN (".join(',', array_keys($listofprojectcontacttype)).")";
|
$sql.= " ( ec.fk_c_type_contact IN (".join(',', array_keys($listofprojectcontacttype)).")";
|
||||||
$sql .= " AND ec.fk_socpeople = ".$user->id.")";
|
$sql.= " AND ec.fk_socpeople = ".$user->id.")";
|
||||||
$sql .= " )";
|
$sql.= " )";
|
||||||
}
|
}
|
||||||
elseif ($mode == 2)
|
elseif ($mode == 2)
|
||||||
{
|
{
|
||||||
// No filter. Use this if user has permission to see all project
|
// No filter. Use this if user has permission to see all project
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql .= $filter;
|
$sql.= $filter;
|
||||||
//print $sql;
|
//print $sql;
|
||||||
|
|
||||||
$resql = $this->db->query($sql);
|
$resql = $this->db->query($sql);
|
||||||
@ -1335,9 +1328,9 @@ class Project extends CommonObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
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
|
||||||
@ -1352,8 +1345,8 @@ class Project extends CommonObject
|
|||||||
* @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;
|
||||||
@ -1529,17 +1522,17 @@ class Project extends CommonObject
|
|||||||
//Duplicate task
|
//Duplicate task
|
||||||
if ($clone_task)
|
if ($clone_task)
|
||||||
{
|
{
|
||||||
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);
|
||||||
|
|
||||||
// Security check
|
// Security check
|
||||||
$socid = 0;
|
$socid=0;
|
||||||
if ($user->socid > 0) $socid = $user->socid;
|
if ($user->socid > 0) $socid = $user->socid;
|
||||||
|
|
||||||
$tasksarray = $taskstatic->getTasksArray(0, 0, $fromid, $socid, 0);
|
$tasksarray=$taskstatic->getTasksArray(0, 0, $fromid, $socid, 0);
|
||||||
|
|
||||||
$tab_conv_child_parent = array();
|
$tab_conv_child_parent=array();
|
||||||
|
|
||||||
// Loop on each task, to clone it
|
// Loop on each task, to clone it
|
||||||
foreach ($tasksarray as $tasktoclone)
|
foreach ($tasksarray as $tasktoclone)
|
||||||
@ -1596,43 +1589,43 @@ class Project extends CommonObject
|
|||||||
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;
|
||||||
|
|
||||||
$taskstatic = new Task($this->db);
|
$taskstatic = new Task($this->db);
|
||||||
|
|
||||||
// Security check
|
// Security check
|
||||||
$socid = 0;
|
$socid=0;
|
||||||
if ($user->socid > 0) $socid = $user->socid;
|
if ($user->socid > 0) $socid = $user->socid;
|
||||||
|
|
||||||
$tasksarray = $taskstatic->getTasksArray(0, 0, $this->id, $socid, 0);
|
$tasksarray=$taskstatic->getTasksArray(0, 0, $this->id, $socid, 0);
|
||||||
|
|
||||||
foreach ($tasksarray as $tasktoshiftdate)
|
foreach ($tasksarray as $tasktoshiftdate)
|
||||||
{
|
{
|
||||||
$to_update = false;
|
$to_update=false;
|
||||||
// Fetch only if update of date will be made
|
// Fetch only if update of date will be made
|
||||||
if ((!empty($tasktoshiftdate->date_start)) || (!empty($tasktoshiftdate->date_end)))
|
if ((!empty($tasktoshiftdate->date_start)) || (!empty($tasktoshiftdate->date_end)))
|
||||||
{
|
{
|
||||||
//dol_syslog(get_class($this)."::shiftTaskDate to_update", LOG_DEBUG);
|
//dol_syslog(get_class($this)."::shiftTaskDate to_update", LOG_DEBUG);
|
||||||
$to_update = true;
|
$to_update=true;
|
||||||
$task = new Task($this->db);
|
$task = new Task($this->db);
|
||||||
$result = $task->fetch($tasktoshiftdate->id);
|
$result = $task->fetch($tasktoshiftdate->id);
|
||||||
if (!$result)
|
if (!$result)
|
||||||
{
|
{
|
||||||
$error++;
|
$error++;
|
||||||
$this->error .= $task->error;
|
$this->error.=$task->error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//print "$this->date_start + $tasktoshiftdate->date_start - $old_project_dt_start";exit;
|
//print "$this->date_start + $tasktoshiftdate->date_start - $old_project_dt_start";exit;
|
||||||
@ -1664,19 +1657,19 @@ class Project extends CommonObject
|
|||||||
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;
|
||||||
|
|
||||||
@ -1699,10 +1692,10 @@ class Project extends CommonObject
|
|||||||
} 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
|
||||||
@ -1711,8 +1704,8 @@ class Project extends CommonObject
|
|||||||
*
|
*
|
||||||
* @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;
|
||||||
|
|
||||||
@ -1734,9 +1727,9 @@ class Project extends CommonObject
|
|||||||
} 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)
|
||||||
@ -1746,18 +1739,18 @@ class Project extends CommonObject
|
|||||||
* @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");
|
||||||
|
|
||||||
if (!dol_strlen($modele)) {
|
if (! dol_strlen($modele)) {
|
||||||
$modele = 'baleine';
|
$modele = 'baleine';
|
||||||
|
|
||||||
if ($this->modelpdf) {
|
if ($this->modelpdf) {
|
||||||
$modele = $this->modelpdf;
|
$modele = $this->modelpdf;
|
||||||
} elseif (!empty($conf->global->PROJECT_ADDON_PDF)) {
|
} elseif (! empty($conf->global->PROJECT_ADDON_PDF)) {
|
||||||
$modele = $conf->global->PROJECT_ADDON_PDF;
|
$modele = $conf->global->PROJECT_ADDON_PDF;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1765,10 +1758,10 @@ class Project extends CommonObject
|
|||||||
$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.
|
||||||
*
|
*
|
||||||
@ -1777,37 +1770,37 @@ class Project extends CommonObject
|
|||||||
* @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();
|
||||||
$this->weekWorkLoadPerTask = array();
|
$this->weekWorkLoadPerTask=array();
|
||||||
|
|
||||||
if (empty($datestart)) dol_print_error('', 'Error datestart parameter is empty');
|
if (empty($datestart)) dol_print_error('', 'Error datestart parameter is empty');
|
||||||
|
|
||||||
$sql = "SELECT ptt.rowid as taskid, ptt.task_duration, ptt.task_date, ptt.task_datehour, ptt.fk_task";
|
$sql = "SELECT ptt.rowid as taskid, ptt.task_duration, ptt.task_date, ptt.task_datehour, ptt.fk_task";
|
||||||
$sql .= " FROM ".MAIN_DB_PREFIX."projet_task_time AS ptt, ".MAIN_DB_PREFIX."projet_task as pt";
|
$sql.= " FROM ".MAIN_DB_PREFIX."projet_task_time AS ptt, ".MAIN_DB_PREFIX."projet_task as pt";
|
||||||
$sql .= " WHERE ptt.fk_task = pt.rowid";
|
$sql.= " WHERE ptt.fk_task = pt.rowid";
|
||||||
$sql .= " AND pt.fk_projet = ".$this->id;
|
$sql.= " AND pt.fk_projet = ".$this->id;
|
||||||
$sql .= " AND (ptt.task_date >= '".$this->db->idate($datestart)."' ";
|
$sql.= " AND (ptt.task_date >= '".$this->db->idate($datestart)."' ";
|
||||||
$sql .= " AND ptt.task_date <= '".$this->db->idate(dol_time_plus_duree($datestart, 1, 'w') - 1)."')";
|
$sql.= " AND ptt.task_date <= '".$this->db->idate(dol_time_plus_duree($datestart, 1, 'w') - 1)."')";
|
||||||
if ($taskid) $sql .= " AND ptt.fk_task=".$taskid;
|
if ($taskid) $sql.= " AND ptt.fk_task=".$taskid;
|
||||||
if (is_numeric($userid)) $sql .= " AND ptt.fk_user=".$userid;
|
if (is_numeric($userid)) $sql.= " AND ptt.fk_user=".$userid;
|
||||||
|
|
||||||
//print $sql;
|
//print $sql;
|
||||||
$resql = $this->db->query($sql);
|
$resql=$this->db->query($sql);
|
||||||
if ($resql)
|
if ($resql)
|
||||||
{
|
{
|
||||||
$daylareadyfound = array();
|
$daylareadyfound=array();
|
||||||
|
|
||||||
$num = $this->db->num_rows($resql);
|
$num = $this->db->num_rows($resql);
|
||||||
$i = 0;
|
$i = 0;
|
||||||
// Loop on each record found, so each couple (project id, task id)
|
// Loop on each record found, so each couple (project id, task id)
|
||||||
while ($i < $num)
|
while ($i < $num)
|
||||||
{
|
{
|
||||||
$obj = $this->db->fetch_object($resql);
|
$obj=$this->db->fetch_object($resql);
|
||||||
$day = $this->db->jdate($obj->task_date); // task_date is date without hours
|
$day=$this->db->jdate($obj->task_date); // task_date is date without hours
|
||||||
if (empty($daylareadyfound[$day]))
|
if (empty($daylareadyfound[$day]))
|
||||||
{
|
{
|
||||||
$this->weekWorkLoad[$day] = $obj->task_duration;
|
$this->weekWorkLoad[$day] = $obj->task_duration;
|
||||||
@ -1818,7 +1811,7 @@ class Project extends CommonObject
|
|||||||
$this->weekWorkLoad[$day] += $obj->task_duration;
|
$this->weekWorkLoad[$day] += $obj->task_duration;
|
||||||
$this->weekWorkLoadPerTask[$day][$obj->fk_task] += $obj->task_duration;
|
$this->weekWorkLoadPerTask[$day][$obj->fk_task] += $obj->task_duration;
|
||||||
}
|
}
|
||||||
$daylareadyfound[$day] = 1;
|
$daylareadyfound[$day]=1;
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
$this->db->free($resql);
|
$this->db->free($resql);
|
||||||
@ -1830,8 +1823,9 @@ class Project extends CommonObject
|
|||||||
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.
|
||||||
*
|
*
|
||||||
@ -1840,8 +1834,8 @@ class Project extends CommonObject
|
|||||||
* @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();
|
||||||
@ -1896,18 +1890,18 @@ class Project extends CommonObject
|
|||||||
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;
|
||||||
|
|
||||||
@ -1966,10 +1960,10 @@ class Project extends CommonObject
|
|||||||
$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
|
||||||
@ -1977,24 +1971,24 @@ class Project extends CommonObject
|
|||||||
* @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;
|
||||||
|
|
||||||
@ -2026,16 +2020,16 @@ class Project extends CommonObject
|
|||||||
$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;
|
||||||
@ -2044,17 +2038,17 @@ class Project extends CommonObject
|
|||||||
$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';
|
||||||
@ -2092,9 +2086,9 @@ class Project extends CommonObject
|
|||||||
{
|
{
|
||||||
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.
|
||||||
@ -2104,8 +2098,8 @@ class Project extends CommonObject
|
|||||||
* @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
|
||||||
@ -2150,20 +2144,20 @@ class Project extends CommonObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user