fix deprecated in project

This commit is contained in:
Frédéric France
2022-06-22 13:50:54 +02:00
parent eaafa59160
commit b46ede5eae
2 changed files with 40 additions and 15 deletions

View File

@@ -2549,8 +2549,8 @@ function print_projecttasks_array($db, $form, $socid, $projectsListId, $mytasks
$projectstatic->ref = $objp->ref; $projectstatic->ref = $objp->ref;
$projectstatic->status = $objp->status; $projectstatic->status = $objp->status;
$projectstatic->title = $objp->title; $projectstatic->title = $objp->title;
$projectstatic->datee = $db->jdate($objp->datee); $projectstatic->date_end = $db->jdate($objp->datee);
$projectstatic->dateo = $db->jdate($objp->dateo); $projectstatic->date_start = $db->jdate($objp->dateo);
print '<tr class="oddeven">'; print '<tr class="oddeven">';

View File

@@ -86,8 +86,33 @@ class Project extends CommonObject
*/ */
public $title; public $title;
/**
* @var int Date start
* @deprecated
* @see $date_start
*/
public $dateo;
/**
* @var int Date start
*/
public $date_start; public $date_start;
/**
* @var int Date end
* @deprecated
* @see $date_end
*/
public $datee;
/**
* @var int Date end
*/
public $date_end; public $date_end;
/**
* @var int Date close
*/
public $date_close; public $date_close;
public $socid; // To store id of thirdparty public $socid; // To store id of thirdparty
@@ -694,12 +719,12 @@ class Project extends CommonObject
* @param string $type 'propal','order','invoice','order_supplier','invoice_supplier',... * @param string $type 'propal','order','invoice','order_supplier','invoice_supplier',...
* @param string $tablename name of table associated of the type * @param string $tablename name of table associated of the type
* @param string $datefieldname name of date field for filter * @param string $datefieldname name of date field for filter
* @param int $dates Start date * @param int $date_start Start date
* @param int $datee End date * @param int $date_end End date
* @param string $projectkey Equivalent key to fk_projet for actual type * @param string $projectkey Equivalent key to fk_projet for actual type
* @return mixed Array list of object ids linked to project, < 0 or string if error * @return mixed Array list of object ids linked to project, < 0 or string if error
*/ */
public function get_element_list($type, $tablename, $datefieldname = '', $dates = '', $datee = '', $projectkey = 'fk_projet') public function get_element_list($type, $tablename, $datefieldname = '', $date_start = '', $date_end = '', $projectkey = 'fk_projet')
{ {
// phpcs:enable // phpcs:enable
@@ -729,28 +754,28 @@ class Project extends CommonObject
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX.$tablename." WHERE ".$projectkey." IN (".$this->db->sanitize($ids).") AND entity IN (".getEntity($type).")"; $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX.$tablename." WHERE ".$projectkey." IN (".$this->db->sanitize($ids).") AND entity IN (".getEntity($type).")";
} }
if ($dates > 0 && $type == 'loan') { if ($date_start > 0 && $type == 'loan') {
$sql .= " AND (dateend > '".$this->db->idate($dates)."' OR dateend IS NULL)"; $sql .= " AND (dateend > '".$this->db->idate($date_start)."' 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 ($date_start > 0 && ($type != 'project_task')) { // For table project_taks, we want the filter on date apply on project_time_spent table
if (empty($datefieldname) && !empty($this->table_element_date)) { if (empty($datefieldname) && !empty($this->table_element_date)) {
$datefieldname = $this->table_element_date; $datefieldname = $this->table_element_date;
} }
if (empty($datefieldname)) { if (empty($datefieldname)) {
return 'Error this object has no date field defined'; return 'Error this object has no date field defined';
} }
$sql .= " AND (".$datefieldname." >= '".$this->db->idate($dates)."' OR ".$datefieldname." IS NULL)"; $sql .= " AND (".$datefieldname." >= '".$this->db->idate($date_start)."' OR ".$datefieldname." IS NULL)";
} }
if ($datee > 0 && $type == 'loan') { if ($date_end > 0 && $type == 'loan') {
$sql .= " AND (datestart < '".$this->db->idate($datee)."' OR datestart IS NULL)"; $sql .= " AND (datestart < '".$this->db->idate($date_end)."' 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 ($date_end > 0 && ($type != 'project_task')) { // For table project_taks, we want the filter on date apply on project_time_spent table
if (empty($datefieldname) && !empty($this->table_element_date)) { if (empty($datefieldname) && !empty($this->table_element_date)) {
$datefieldname = $this->table_element_date; $datefieldname = $this->table_element_date;
} }
if (empty($datefieldname)) { if (empty($datefieldname)) {
return 'Error this object has no date field defined'; return 'Error this object has no date field defined';
} }
$sql .= " AND (".$datefieldname." <= '".$this->db->idate($datee)."' OR ".$datefieldname." IS NULL)"; $sql .= " AND (".$datefieldname." <= '".$this->db->idate($date_end)."' OR ".$datefieldname." IS NULL)";
} }
$parameters = array( $parameters = array(
@@ -758,8 +783,8 @@ class Project extends CommonObject
'type' => $type, 'type' => $type,
'tablename' => $tablename, 'tablename' => $tablename,
'datefieldname' => $datefieldname, 'datefieldname' => $datefieldname,
'dates' => $dates, 'dates' => $date_start,
'datee' => $datee, 'datee' => $date_end,
'fk_projet' => $projectkey, 'fk_projet' => $projectkey,
'ids' => $ids, 'ids' => $ids,
); );