Checkstyle
This commit is contained in:
parent
d47a78479e
commit
6599f2d755
@ -52,7 +52,7 @@ class Project extends CommonObject
|
|||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*
|
*
|
||||||
* @param DoliDB $DB Database handler
|
* @param DoliDB $db Database handler
|
||||||
*/
|
*/
|
||||||
function __construct($db)
|
function __construct($db)
|
||||||
{
|
{
|
||||||
@ -882,12 +882,11 @@ 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 int $fromid Id of object to clone
|
* @param int $fromid Id of object to clone
|
||||||
* @param bool $clone_contact clone contact of project
|
* @param bool $clone_contact clone contact of project
|
||||||
* @param bool $clone_ref clone ref of project
|
|
||||||
* @param bool $clone_task clone task of project
|
* @param bool $clone_task clone task of project
|
||||||
* @param bool $clone_file clone file of project
|
* @param bool $clone_file clone file of project
|
||||||
* @param bool $clone_note clone note of project
|
* @param bool $clone_note clone note of project
|
||||||
@ -898,7 +897,7 @@ class Project extends CommonObject
|
|||||||
global $user,$langs,$conf;
|
global $user,$langs,$conf;
|
||||||
|
|
||||||
$error=0;
|
$error=0;
|
||||||
|
|
||||||
$now = dol_mktime(0,0,0,idate('m',dol_now()),idate('d',dol_now()),idate('Y',dol_now()));
|
$now = dol_mktime(0,0,0,idate('m',dol_now()),idate('d',dol_now()),idate('Y',dol_now()));
|
||||||
|
|
||||||
$clone_project=new Project($this->db);
|
$clone_project=new Project($this->db);
|
||||||
@ -907,12 +906,12 @@ class Project extends CommonObject
|
|||||||
|
|
||||||
// Load source object
|
// Load source object
|
||||||
$clone_project->fetch($fromid);
|
$clone_project->fetch($fromid);
|
||||||
|
|
||||||
$orign_dt_start=$clone_project->date_start;
|
$orign_dt_start=$clone_project->date_start;
|
||||||
|
|
||||||
|
|
||||||
$orign_project_ref=$clone_project->ref;
|
$orign_project_ref=$clone_project->ref;
|
||||||
|
|
||||||
$clone_project->id=0;
|
$clone_project->id=0;
|
||||||
$clone_project->date_start = $now;
|
$clone_project->date_start = $now;
|
||||||
if (!(empty($clone_project->date_end)))
|
if (!(empty($clone_project->date_end)))
|
||||||
@ -923,13 +922,13 @@ class Project extends CommonObject
|
|||||||
$datetime_now = new DateTime();
|
$datetime_now = new DateTime();
|
||||||
$datetime_now->setTimestamp($now);
|
$datetime_now->setTimestamp($now);
|
||||||
$diff_dt = $datetime_start->diff($datetime_now);
|
$diff_dt = $datetime_start->diff($datetime_now);
|
||||||
|
|
||||||
$datetime_end = new DateTime();
|
$datetime_end = new DateTime();
|
||||||
$datetime_end->setTimestamp($clone_project->date_end);
|
$datetime_end->setTimestamp($clone_project->date_end);
|
||||||
$datetime_end->add($diff_dt);
|
$datetime_end->add($diff_dt);
|
||||||
$clone_project->date_end = $datetime_end->getTimestamp();
|
$clone_project->date_end = $datetime_end->getTimestamp();
|
||||||
}
|
}
|
||||||
|
|
||||||
$clone_project->datec = $now;
|
$clone_project->datec = $now;
|
||||||
|
|
||||||
if (!$clone_note)
|
if (!$clone_note)
|
||||||
@ -937,20 +936,20 @@ class Project extends CommonObject
|
|||||||
$clone_project->note_private='';
|
$clone_project->note_private='';
|
||||||
$clone_project->note_public='';
|
$clone_project->note_public='';
|
||||||
}
|
}
|
||||||
|
|
||||||
//Generate next ref
|
//Generate next ref
|
||||||
$defaultref='';
|
$defaultref='';
|
||||||
$obj = empty($conf->global->PROJECT_ADDON)?'mod_project_simple':$conf->global->PROJECT_ADDON;
|
$obj = empty($conf->global->PROJECT_ADDON)?'mod_project_simple':$conf->global->PROJECT_ADDON;
|
||||||
if (! empty($conf->global->PROJECT_ADDON) && is_readable(DOL_DOCUMENT_ROOT ."/core/modules/project/".$conf->global->PROJECT_ADDON.".php"))
|
if (! empty($conf->global->PROJECT_ADDON) && is_readable(DOL_DOCUMENT_ROOT ."/core/modules/project/".$conf->global->PROJECT_ADDON.".php"))
|
||||||
{
|
{
|
||||||
|
|
||||||
require_once(DOL_DOCUMENT_ROOT ."/core/modules/project/".$conf->global->PROJECT_ADDON.".php");
|
require_once(DOL_DOCUMENT_ROOT ."/core/modules/project/".$conf->global->PROJECT_ADDON.".php");
|
||||||
$modProject = new $obj;
|
$modProject = new $obj;
|
||||||
$defaultref = $modProject->getNextValue($clone_project->societe->id,$clone_project);
|
$defaultref = $modProject->getNextValue($clone_project->societe->id,$clone_project);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_numeric($defaultref) && $defaultref <= 0) $defaultref='';
|
if (is_numeric($defaultref) && $defaultref <= 0) $defaultref='';
|
||||||
|
|
||||||
$clone_project->ref=$defaultref;
|
$clone_project->ref=$defaultref;
|
||||||
|
|
||||||
// Create clone
|
// Create clone
|
||||||
@ -966,10 +965,10 @@ class Project extends CommonObject
|
|||||||
if (! $error)
|
if (! $error)
|
||||||
{
|
{
|
||||||
$this->db->commit();
|
$this->db->commit();
|
||||||
|
|
||||||
//Get the new project id
|
//Get the new project id
|
||||||
$clone_project_id=$clone_project->id;
|
$clone_project_id=$clone_project->id;
|
||||||
|
|
||||||
//Note Update
|
//Note Update
|
||||||
if (!$clone_note)
|
if (!$clone_note)
|
||||||
{
|
{
|
||||||
@ -990,7 +989,7 @@ class Project extends CommonObject
|
|||||||
{
|
{
|
||||||
$this->db->commit();
|
$this->db->commit();
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->db->begin();
|
$this->db->begin();
|
||||||
$res=$clone_project->update_note(dol_html_entity_decode($clone_project->note_private, ENT_QUOTES));
|
$res=$clone_project->update_note(dol_html_entity_decode($clone_project->note_private, ENT_QUOTES));
|
||||||
if ($res < 0)
|
if ($res < 0)
|
||||||
@ -1004,17 +1003,17 @@ class Project extends CommonObject
|
|||||||
$this->db->commit();
|
$this->db->commit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Duplicate contact
|
//Duplicate contact
|
||||||
if ($clone_contact)
|
if ($clone_contact)
|
||||||
{
|
{
|
||||||
$origin_project = new Project($this->db);
|
$origin_project = new Project($this->db);
|
||||||
$origin_project->fetch($fromid);
|
$origin_project->fetch($fromid);
|
||||||
|
|
||||||
foreach(array('internal','external') as $source)
|
foreach(array('internal','external') as $source)
|
||||||
{
|
{
|
||||||
$tab = $origin_project->liste_contact(-1,$source);
|
$tab = $origin_project->liste_contact(-1,$source);
|
||||||
|
|
||||||
foreach ($tab as $contacttoadd)
|
foreach ($tab as $contacttoadd)
|
||||||
{
|
{
|
||||||
$clone_project->add_contact($contacttoadd['id'], $contacttoadd['code'], $contacttoadd['source']);
|
$clone_project->add_contact($contacttoadd['id'], $contacttoadd['code'], $contacttoadd['source']);
|
||||||
@ -1025,7 +1024,7 @@ class Project extends CommonObject
|
|||||||
$error++;
|
$error++;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if ($clone_project->error!='')
|
if ($clone_project->error!='')
|
||||||
{
|
{
|
||||||
$this->error.=$clone_project->error;
|
$this->error.=$clone_project->error;
|
||||||
@ -1035,15 +1034,15 @@ class Project extends CommonObject
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Duplicate file
|
//Duplicate file
|
||||||
if ($clone_file)
|
if ($clone_file)
|
||||||
{
|
{
|
||||||
require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php");
|
require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php");
|
||||||
|
|
||||||
$clone_project_dir = $conf->projet->dir_output . "/" . dol_sanitizeFileName($defaultref);
|
$clone_project_dir = $conf->projet->dir_output . "/" . dol_sanitizeFileName($defaultref);
|
||||||
$ori_project_dir = $conf->projet->dir_output . "/" . dol_sanitizeFileName($orign_project_ref);
|
$ori_project_dir = $conf->projet->dir_output . "/" . dol_sanitizeFileName($orign_project_ref);
|
||||||
|
|
||||||
if (dol_mkdir($clone_project_dir) >= 0)
|
if (dol_mkdir($clone_project_dir) >= 0)
|
||||||
{
|
{
|
||||||
$filearray=dol_dir_list($ori_project_dir,"files",0,'','\.meta$','',SORT_ASC,1);
|
$filearray=dol_dir_list($ori_project_dir,"files",0,'','\.meta$','',SORT_ASC,1);
|
||||||
@ -1063,18 +1062,18 @@ class Project extends CommonObject
|
|||||||
$error++;
|
$error++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Duplicate task
|
//Duplicate task
|
||||||
if ($clone_task)
|
if ($clone_task)
|
||||||
{
|
{
|
||||||
$taskstatic = new Task($this->db);
|
$taskstatic = new Task($this->db);
|
||||||
|
|
||||||
// Security check
|
// Security check
|
||||||
$socid=0;
|
$socid=0;
|
||||||
if ($user->societe_id > 0) $socid = $user->societe_id;
|
if ($user->societe_id > 0) $socid = $user->societe_id;
|
||||||
|
|
||||||
$tasksarray=$taskstatic->getTasksArray(0, 0, $fromid, $socid, 0);
|
$tasksarray=$taskstatic->getTasksArray(0, 0, $fromid, $socid, 0);
|
||||||
|
|
||||||
//manage new parent clone task id
|
//manage new parent clone task id
|
||||||
$tab_conv_child_parent=array();
|
$tab_conv_child_parent=array();
|
||||||
|
|
||||||
@ -1090,7 +1089,7 @@ class Project extends CommonObject
|
|||||||
{
|
{
|
||||||
$new_task_id=$result_clone;
|
$new_task_id=$result_clone;
|
||||||
$taskstatic->fetch($tasktoclone->id);
|
$taskstatic->fetch($tasktoclone->id);
|
||||||
|
|
||||||
//manage new parent clone task id
|
//manage new parent clone task id
|
||||||
// if the current task has child we store the original task id and the equivalent clone task id
|
// if the current task has child we store the original task id and the equivalent clone task id
|
||||||
if (($taskstatic->hasChildren()) && !array_key_exists($tasktoclone->id,$tab_conv_child_parent))
|
if (($taskstatic->hasChildren()) && !array_key_exists($tasktoclone->id,$tab_conv_child_parent))
|
||||||
@ -1098,11 +1097,11 @@ class Project extends CommonObject
|
|||||||
$tab_conv_child_parent[$tasktoclone->id] = $new_task_id;
|
$tab_conv_child_parent[$tasktoclone->id] = $new_task_id;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//Parse all clone node to be sure to update new parent
|
//Parse all clone node to be sure to update new parent
|
||||||
$tasksarray=$taskstatic->getTasksArray(0, 0, $clone_project_id, $socid, 0);
|
$tasksarray=$taskstatic->getTasksArray(0, 0, $clone_project_id, $socid, 0);
|
||||||
foreach ($tasksarray as $task_cloned)
|
foreach ($tasksarray as $task_cloned)
|
||||||
{
|
{
|
||||||
$taskstatic->fetch($task_cloned->id);
|
$taskstatic->fetch($task_cloned->id);
|
||||||
@ -1118,9 +1117,9 @@ class Project extends CommonObject
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (! $error)
|
if (! $error)
|
||||||
{
|
{
|
||||||
return $clone_project_id;
|
return $clone_project_id;
|
||||||
@ -1130,7 +1129,7 @@ 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -1138,8 +1137,8 @@ class Project extends CommonObject
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/** Shift project task date from current date to delta
|
/** Shift project task date from current date to delta
|
||||||
*
|
*
|
||||||
* @param timestamp $old_project_dt_start old project start date
|
* @param timestamp $old_project_dt_start old project start date
|
||||||
@ -1150,18 +1149,18 @@ class Project extends CommonObject
|
|||||||
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->societe_id > 0) $socid = $user->societe_id;
|
if ($user->societe_id > 0) $socid = $user->societe_id;
|
||||||
|
|
||||||
//convert timestamp to datetime
|
//convert timestamp to datetime
|
||||||
$old_project_dt_st = new DateTime();
|
$old_project_dt_st = new DateTime();
|
||||||
$old_project_dt_st->setTimestamp($old_project_dt_start);
|
$old_project_dt_st->setTimestamp($old_project_dt_start);
|
||||||
$old_project_dt_st->setTime(0,0,0); //Use 00:00:00 as time to be sure to not have side
|
$old_project_dt_st->setTime(0,0,0); //Use 00:00:00 as time to be sure to not have side
|
||||||
|
|
||||||
$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)
|
||||||
@ -1183,37 +1182,37 @@ class Project extends CommonObject
|
|||||||
|
|
||||||
//Calcultate new task start date with difference between old proj start date and origin task start date
|
//Calcultate new task start date with difference between old proj start date and origin task start date
|
||||||
if (!empty($tasktoshiftdate->date_start))
|
if (!empty($tasktoshiftdate->date_start))
|
||||||
{
|
{
|
||||||
dol_syslog(get_class($this)."::shiftTaskDate to_update", LOG_DEBUG);
|
dol_syslog(get_class($this)."::shiftTaskDate to_update", LOG_DEBUG);
|
||||||
$orign_task_datetime_start = new DateTime();
|
$orign_task_datetime_start = new DateTime();
|
||||||
$orign_task_datetime_start->setTimestamp($tasktoshiftdate->date_start);
|
$orign_task_datetime_start->setTimestamp($tasktoshiftdate->date_start);
|
||||||
$orign_task_datetime_start->setTime(0,0,0); //Use 00:00:00 as time to be sure to not have side effect
|
$orign_task_datetime_start->setTime(0,0,0); //Use 00:00:00 as time to be sure to not have side effect
|
||||||
$diff_dt_st = $old_project_dt_st->diff($orign_task_datetime_start);
|
$diff_dt_st = $old_project_dt_st->diff($orign_task_datetime_start);
|
||||||
|
|
||||||
//Project new start date
|
//Project new start date
|
||||||
$datetime_start = new DateTime();
|
$datetime_start = new DateTime();
|
||||||
$datetime_start->setTimestamp($this->date_start);
|
$datetime_start->setTimestamp($this->date_start);
|
||||||
$datetime_start->setTime(0,0,0); //Use 00:00:00 as time to be sure to not have side
|
$datetime_start->setTime(0,0,0); //Use 00:00:00 as time to be sure to not have side
|
||||||
|
|
||||||
//New task start date
|
//New task start date
|
||||||
$datetime_start->add($diff_dt_st);
|
$datetime_start->add($diff_dt_st);
|
||||||
$task->date_start = $datetime_start->getTimestamp();
|
$task->date_start = $datetime_start->getTimestamp();
|
||||||
}
|
}
|
||||||
|
|
||||||
//Calcultate new task end date with difference between origin proj end date and origin task end date
|
//Calcultate new task end date with difference between origin proj end date and origin task end date
|
||||||
if (!empty($tasktoshiftdate->date_end))
|
if (!empty($tasktoshiftdate->date_end))
|
||||||
{
|
{
|
||||||
$orign_task_datetime_end = new DateTime();
|
$orign_task_datetime_end = new DateTime();
|
||||||
$orign_task_datetime_end->setTimestamp($tasktoshiftdate->date_end);
|
$orign_task_datetime_end->setTimestamp($tasktoshiftdate->date_end);
|
||||||
$orign_task_datetime_end->setTime(0,0,0); //Use 00:00:00 as hour to be sure to not have side effect
|
$orign_task_datetime_end->setTime(0,0,0); //Use 00:00:00 as hour to be sure to not have side effect
|
||||||
|
|
||||||
$diff_dt_end = $old_project_dt_st->diff($orign_task_datetime_end);
|
$diff_dt_end = $old_project_dt_st->diff($orign_task_datetime_end);
|
||||||
|
|
||||||
//Project new start date
|
//Project new start date
|
||||||
$datetime_end = new DateTime();
|
$datetime_end = new DateTime();
|
||||||
$datetime_end->setTimestamp($this->date_start);
|
$datetime_end->setTimestamp($this->date_start);
|
||||||
$datetime_end->setTime(0,0,0); //Use 00:00:00 as time to be sure to not have side
|
$datetime_end->setTime(0,0,0); //Use 00:00:00 as time to be sure to not have side
|
||||||
|
|
||||||
//New task start date
|
//New task start date
|
||||||
$datetime_end->add($diff_dt_end);
|
$datetime_end->add($diff_dt_end);
|
||||||
$task->date_end = $datetime_end->getTimestamp();
|
$task->date_end = $datetime_end->getTimestamp();
|
||||||
@ -1231,10 +1230,10 @@ class Project extends CommonObject
|
|||||||
}
|
}
|
||||||
if ($error!=0)
|
if ($error!=0)
|
||||||
{
|
{
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -64,7 +64,7 @@ class Task extends CommonObject
|
|||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*
|
*
|
||||||
* @param DoliDB $DB Database handler
|
* @param DoliDB $db Database handler
|
||||||
*/
|
*/
|
||||||
function __construct($db)
|
function __construct($db)
|
||||||
{
|
{
|
||||||
@ -305,7 +305,7 @@ class Task extends CommonObject
|
|||||||
*/
|
*/
|
||||||
function delete($user, $notrigger=0)
|
function delete($user, $notrigger=0)
|
||||||
{
|
{
|
||||||
|
|
||||||
global $conf, $langs;
|
global $conf, $langs;
|
||||||
|
|
||||||
$error=0;
|
$error=0;
|
||||||
@ -935,7 +935,7 @@ class Task extends CommonObject
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 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 int $fromid Id of object to clone
|
* @param int $fromid Id of object to clone
|
||||||
@ -943,7 +943,6 @@ class Task extends CommonObject
|
|||||||
* @param int $parent_task_id Id of task to attach clone task
|
* @param int $parent_task_id Id of task to attach clone task
|
||||||
* @param bool $clone_change_dt recalculate date of task regarding new project start date
|
* @param bool $clone_change_dt recalculate date of task regarding new project start date
|
||||||
* @param bool $clone_affectation clone affectation of project
|
* @param bool $clone_affectation clone affectation of project
|
||||||
* @param bool $clone_task clone task of project
|
|
||||||
* @param bool $clone_time clone time of project
|
* @param bool $clone_time clone time of project
|
||||||
* @param bool $clone_file clone file of project
|
* @param bool $clone_file clone file of project
|
||||||
* @param bool $clone_note clone note of project
|
* @param bool $clone_note clone note of project
|
||||||
@ -955,9 +954,9 @@ class Task extends CommonObject
|
|||||||
global $user,$langs,$conf;
|
global $user,$langs,$conf;
|
||||||
|
|
||||||
$error=0;
|
$error=0;
|
||||||
|
|
||||||
$now=dol_now();
|
$now=dol_now();
|
||||||
|
|
||||||
$datec = dol_mktime(0,0,0,idate('m',$now),idate('d',$now),idate('Y',$now));
|
$datec = dol_mktime(0,0,0,idate('m',$now),idate('d',$now),idate('Y',$now));
|
||||||
|
|
||||||
$clone_task=new Task($this->db);
|
$clone_task=new Task($this->db);
|
||||||
@ -966,24 +965,24 @@ class Task extends CommonObject
|
|||||||
|
|
||||||
// Load source object
|
// Load source object
|
||||||
$clone_task->fetch($fromid);
|
$clone_task->fetch($fromid);
|
||||||
|
|
||||||
$ori_project_id = $clone_task->fk_project;
|
$ori_project_id = $clone_task->fk_project;
|
||||||
|
|
||||||
$clone_task->id = 0;
|
$clone_task->id = 0;
|
||||||
$clone_task->fk_project = $project_id;
|
$clone_task->fk_project = $project_id;
|
||||||
$clone_task->fk_task_parent = $parent_task_id;
|
$clone_task->fk_task_parent = $parent_task_id;
|
||||||
$clone_task->date_c = $datec;
|
$clone_task->date_c = $datec;
|
||||||
|
|
||||||
//Manage Task Date
|
//Manage Task Date
|
||||||
if ($clone_change_dt)
|
if ($clone_change_dt)
|
||||||
{
|
{
|
||||||
$projectstatic=new Project($this->db);
|
$projectstatic=new Project($this->db);
|
||||||
$projectstatic->fetch($ori_project_id);
|
$projectstatic->fetch($ori_project_id);
|
||||||
|
|
||||||
//Origin project strat date
|
//Origin project strat date
|
||||||
$orign_project_dt_start = new DateTime();
|
$orign_project_dt_start = new DateTime();
|
||||||
$orign_project_dt_start->setTimestamp($projectstatic->date_start);
|
$orign_project_dt_start->setTimestamp($projectstatic->date_start);
|
||||||
|
|
||||||
//Calcultate new task start date with difference between origin proj start date and origin task start date
|
//Calcultate new task start date with difference between origin proj start date and origin task start date
|
||||||
if (!empty($clone_task->date_start))
|
if (!empty($clone_task->date_start))
|
||||||
{
|
{
|
||||||
@ -991,16 +990,16 @@ class Task extends CommonObject
|
|||||||
$orign_task_datetime_start->setTimestamp($clone_task->date_start);
|
$orign_task_datetime_start->setTimestamp($clone_task->date_start);
|
||||||
$orign_task_datetime_start->setTime(0,0,0); //Use 00:00:00 as hour to be sure to not have side effect
|
$orign_task_datetime_start->setTime(0,0,0); //Use 00:00:00 as hour to be sure to not have side effect
|
||||||
$diff_dt_st = $orign_project_dt_start->diff($orign_task_datetime_start);
|
$diff_dt_st = $orign_project_dt_start->diff($orign_task_datetime_start);
|
||||||
|
|
||||||
//cloned project start date
|
//cloned project start date
|
||||||
$datetime_start = new DateTime();
|
$datetime_start = new DateTime();
|
||||||
$datetime_start->setTimestamp($now);
|
$datetime_start->setTimestamp($now);
|
||||||
|
|
||||||
//New task start date
|
//New task start date
|
||||||
$datetime_start->add($diff_dt_st);
|
$datetime_start->add($diff_dt_st);
|
||||||
$clone_task->date_start = $datetime_start->getTimestamp();
|
$clone_task->date_start = $datetime_start->getTimestamp();
|
||||||
}
|
}
|
||||||
|
|
||||||
//Calcultate new task end date with difference between origin proj end date and origin task end date
|
//Calcultate new task end date with difference between origin proj end date and origin task end date
|
||||||
if (!empty($clone_task->date_end))
|
if (!empty($clone_task->date_end))
|
||||||
{
|
{
|
||||||
@ -1008,18 +1007,18 @@ class Task extends CommonObject
|
|||||||
$orign_task_datetime_end->setTimestamp($clone_task->date_end);
|
$orign_task_datetime_end->setTimestamp($clone_task->date_end);
|
||||||
$orign_task_datetime_end->setTime(0,0,0); //Use 00:00:00 as hour to be sure to not have side effect
|
$orign_task_datetime_end->setTime(0,0,0); //Use 00:00:00 as hour to be sure to not have side effect
|
||||||
$diff_dt_end = $orign_project_dt_start->diff($orign_task_datetime_end);
|
$diff_dt_end = $orign_project_dt_start->diff($orign_task_datetime_end);
|
||||||
|
|
||||||
//cloned project start date
|
//cloned project start date
|
||||||
$datetime_end = new DateTime();
|
$datetime_end = new DateTime();
|
||||||
$datetime_end->setTimestamp($now);
|
$datetime_end->setTimestamp($now);
|
||||||
|
|
||||||
//New task start date
|
//New task start date
|
||||||
$datetime_end->add($diff_dt_end);
|
$datetime_end->add($diff_dt_end);
|
||||||
$clone_task->date_end = $datetime_end->getTimestamp();
|
$clone_task->date_end = $datetime_end->getTimestamp();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$clone_prog)
|
if (!$clone_prog)
|
||||||
{
|
{
|
||||||
$clone_task->progress=0;
|
$clone_task->progress=0;
|
||||||
@ -1039,9 +1038,9 @@ class Task extends CommonObject
|
|||||||
if (! $error)
|
if (! $error)
|
||||||
{
|
{
|
||||||
$this->db->commit();
|
$this->db->commit();
|
||||||
|
|
||||||
$clone_task_id=$clone_task->id;
|
$clone_task_id=$clone_task->id;
|
||||||
|
|
||||||
//Note Update
|
//Note Update
|
||||||
if (!$clone_note)
|
if (!$clone_note)
|
||||||
{
|
{
|
||||||
@ -1062,7 +1061,7 @@ class Task extends CommonObject
|
|||||||
{
|
{
|
||||||
$this->db->commit();
|
$this->db->commit();
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->db->begin();
|
$this->db->begin();
|
||||||
$res=$clone_task->update_note(dol_html_entity_decode($clone_task->note_private, ENT_QUOTES));
|
$res=$clone_task->update_note(dol_html_entity_decode($clone_task->note_private, ENT_QUOTES));
|
||||||
if ($res < 0)
|
if ($res < 0)
|
||||||
@ -1076,30 +1075,30 @@ class Task extends CommonObject
|
|||||||
$this->db->commit();
|
$this->db->commit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Duplicate file
|
//Duplicate file
|
||||||
if ($clone_file)
|
if ($clone_file)
|
||||||
{
|
{
|
||||||
require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php");
|
require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php");
|
||||||
|
|
||||||
//retreive project origin ref to know folder to copy
|
//retreive project origin ref to know folder to copy
|
||||||
$projectstatic=new Project($this->db);
|
$projectstatic=new Project($this->db);
|
||||||
$projectstatic->fetch($ori_project_id);
|
$projectstatic->fetch($ori_project_id);
|
||||||
$ori_project_ref=$projectstatic->ref;
|
$ori_project_ref=$projectstatic->ref;
|
||||||
|
|
||||||
if ($ori_project_id!=$project_id)
|
if ($ori_project_id!=$project_id)
|
||||||
{
|
{
|
||||||
$projectstatic->fetch($project_id);
|
$projectstatic->fetch($project_id);
|
||||||
$clone_project_ref=$projectstatic->ref;
|
$clone_project_ref=$projectstatic->ref;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$clone_project_ref=$ori_project_ref;
|
$clone_project_ref=$ori_project_ref;
|
||||||
}
|
}
|
||||||
|
|
||||||
$clone_task_dir = $conf->projet->dir_output . "/" . dol_sanitizeFileName($clone_project_ref). "/" . dol_sanitizeFileName($clone_task_id);
|
$clone_task_dir = $conf->projet->dir_output . "/" . dol_sanitizeFileName($clone_project_ref). "/" . dol_sanitizeFileName($clone_task_id);
|
||||||
$ori_task_dir = $conf->projet->dir_output . "/" . dol_sanitizeFileName($ori_project_ref). "/" . dol_sanitizeFileName($fromid);
|
$ori_task_dir = $conf->projet->dir_output . "/" . dol_sanitizeFileName($ori_project_ref). "/" . dol_sanitizeFileName($fromid);
|
||||||
|
|
||||||
$filearray=dol_dir_list($ori_task_dir,"files",0,'','\.meta$','',SORT_ASC,1);
|
$filearray=dol_dir_list($ori_task_dir,"files",0,'','\.meta$','',SORT_ASC,1);
|
||||||
foreach($filearray as $key => $file)
|
foreach($filearray as $key => $file)
|
||||||
{
|
{
|
||||||
@ -1108,25 +1107,25 @@ class Task extends CommonObject
|
|||||||
if (dol_mkdir($clone_task_dir) < 0)
|
if (dol_mkdir($clone_task_dir) < 0)
|
||||||
{
|
{
|
||||||
$this->error.=$langs->trans('ErrorInternalErrorDetected').':dol_mkdir';
|
$this->error.=$langs->trans('ErrorInternalErrorDetected').':dol_mkdir';
|
||||||
$error++;
|
$error++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$rescopy = dol_copy($ori_task_dir . '/' . $file['name'], $clone_task_dir . '/' . $file['name'],0,1);
|
$rescopy = dol_copy($ori_task_dir . '/' . $file['name'], $clone_task_dir . '/' . $file['name'],0,1);
|
||||||
if (is_numeric($rescopy) && $rescopy < 0)
|
if (is_numeric($rescopy) && $rescopy < 0)
|
||||||
{
|
{
|
||||||
$this->error.=$langs->trans("ErrorFailToCopyFile",$ori_task_dir . '/' . $file['name'],$clone_task_dir . '/' . $file['name']);
|
$this->error.=$langs->trans("ErrorFailToCopyFile",$ori_task_dir . '/' . $file['name'],$clone_task_dir . '/' . $file['name']);
|
||||||
$error++;
|
$error++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// clone affectation
|
// clone affectation
|
||||||
if ($clone_affectation)
|
if ($clone_affectation)
|
||||||
{
|
{
|
||||||
$origin_task = new Task($this->db);
|
$origin_task = new Task($this->db);
|
||||||
$origin_task->fetch($fromid);
|
$origin_task->fetch($fromid);
|
||||||
|
|
||||||
foreach(array('internal','external') as $source)
|
foreach(array('internal','external') as $source)
|
||||||
{
|
{
|
||||||
$tab = $origin_task->liste_contact(-1,$source);
|
$tab = $origin_task->liste_contact(-1,$source);
|
||||||
@ -1153,12 +1152,12 @@ class Task extends CommonObject
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if($clone_time)
|
if($clone_time)
|
||||||
{
|
{
|
||||||
//TODO clone time of affectation
|
//TODO clone time of affectation
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! $error)
|
if (! $error)
|
||||||
{
|
{
|
||||||
return $clone_task_id;
|
return $clone_task_id;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user