public function actionAddTaskProcess() { $model_r = false; $model_p = false; if (isset($_POST['task_id'])) { $task_id = $_POST['task_id']; $task_assignee = TaskAssignees::model()->findAll('task_id=' . intval($task_id)); foreach ($task_assignee as $task_assignee_item) { $account_id = $task_assignee_item->account_id; // Kiem tra xem da tao procress mat dinh cho account nay chua? $assign_procress = TaskProgress::model()->getTaskProgress($task_id, $account_id); count($assign_procress); //END // Neu chua co progess mat dinh thi them progress ban dau cho account nay. if (count($assign_procress) <= 0) { $model_p = TaskProgress::model()->AddTaskProgress($task_id, $account_id); } // Kiem tra xem da tao resource plan mat dinh cho account nay chua? $resource_plan = TaskResourcePlan::model()->getTaskResourcePlan($task_id, $account_id); //END // Neu chua co resource plan mat dinh thi them resource plan ban dau cho account nay. if (count($resource_plan) <= 0) { $model_r = TaskResourcePlan::model()->addTaskResourcePlan($task_id, $account_id); } } } if ($model_r || $model_p) { echo '{"status":"success"}'; } else { echo '{"status":"fail"}'; } }
/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate() { // $model=new TaskResourcePlan; // // // Uncomment the following line if AJAX validation is needed // // $this->performAjaxValidation($model); // // if(isset($_POST['TaskResourcePlan'])) // { // $model->attributes=$_POST['TaskResourcePlan']; // if($model->save()) // $this->redirect(array('view','id'=>$model->trp_id)); // } // // $this->render('create',array( // 'model'=>$model, // )); $model = false; if ($_POST['task_id']) { $task_id = $_POST['task_id']; $task_assignee = TaskAssignees::model()->findAll('task_id=' . intval($task_id)); foreach ($task_assignee as $task_assignee_item) { $account_id = $task_assignee_item->account_id; // Kiem tra xem da tao resource plan mat dinh cho account nay chua? $resource_plan = TaskResourcePlan::model()->getTaskResourcePlan($task_id, $account_id); count($resource_plan); //END // Neu chua co progess mat dinh thi them progress ban dau cho account nay. if (count($assign_procress) <= 0) { $model = TaskResourcePlan::model()->addTaskResourcePlan($task_id, $account_id); } } } if ($model) { echo '{"status":"success"}'; } else { echo '{"status":"fail"}'; } }
/** * % công việc cần xong theo như kế hoạch nhân sự * @param type $task_id * @return type float */ public function calculatePlanned($task_id) { $planned = 0; $task_assignee_arr = TaskAssignees::model()->findAll('task_id=' . intval($task_id)); foreach ($task_assignee_arr as $assignee_task) { $account_id = $assignee_task->account_id; $task_progress_plan = TaskResourcePlan::model()->getTaskResourcePlan($task_id, $account_id); //Tính % thời gian đãn trãi qua theo kế hoạch $date_current = date('Y-m-d'); $data_plan_start = date('Y-m-d'); $date_plan_end = date('Y-m-d'); $trp_work_load = 0; if (count($task_progress_plan) == 1) { $data_plan_start = $task_progress_plan->trp_start; $date_plan_end = $task_progress_plan->trp_end; $trp_work_load = $task_progress_plan->trp_work_load; } if ($date_plan_end <= $data_plan_start) { $lapsed_plan = 0; } else { //Sô ngày đã làm theo ke hoach. $actual = (strtotime($date_current) - strtotime($data_plan_start)) / (60 * 60 * 24); //Số ngày dự kiến theo ke hoach. $est = (strtotime($date_plan_end) - strtotime($data_plan_start)) / (60 * 60 * 24); // % thoi gian da trai qua cua nhan su theo ke hoach $lapsed_plan = $actual / $est; if ($lapsed_plan > 1) { $lapsed_plan = 100; } elseif ($lapsed_plan < 0) { $lapsed_plan = 0; } else { $lapsed_plan = $lapsed_plan * 100; } } //END $planned += $trp_work_load * $lapsed_plan; } $planned = $planned / 100; return round($planned, 1); }
<?php $task = Tasks::model()->findByPk($task_id); $task_assignee = $task_assignee_arr = TaskAssignees::model()->findAll('task_id=' . intval($task_id)); $count_task_assignee = count($task_assignee); ?> <h3>Task Progress</h3> <button type="button" class="btn btn-primary btn-lg" data-toggle="modal" data-target="#myModal" onclick="AddTaskProcess();return false;">Task Detail</button> <!-- Modal --> <div class="modal fade" id="myModal" style="z-index: 0;"> <div class="modal-dialog"> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button> <h4 class="modal-title" id="myModalLabel">Task Details</h4> <input type="hidden" id="toal_assign_task" value="<?php echo $count_task_assignee; ?> " /> </div> <div class="modal-body" style="max-height: 500px;"> <!-- ==================== SCHEDULE ================================ --> <div id="tp-schedule" > <h4>Schedule</h4> Start: <?php echo CHtml::textField('tp-shedule-start', date('d-m-Y', strtotime($task->task_start_date)), array('class' => 'span2')); ?>