Пример #1
0
 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"}';
     }
 }
 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  * @param integer $id the ID of the model to be loaded
  * @return TaskResourcePlan the loaded model
  * @throws CHttpException
  */
 public function loadModel($id)
 {
     $model = TaskResourcePlan::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
Пример #3
0
 public function getTaskResourcePlan($task_id, $account_id)
 {
     $tr_plan = TaskResourcePlan::model()->find('task_id = ' . intval($task_id) . ' AND account_id = ' . intval($account_id));
     return $tr_plan;
 }
Пример #4
0
 /**
  * % 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);
 }
Пример #5
0
        ?>
                          <tr>
                              <td><?php 
        echo CHtml::image('images/user.png', $account_id, array('width' => '40'));
        ?>
 [Name Account]</td>
                              <td><?php 
        echo CHtml::textField('trp-start-' . $i, date('d-m-Y', strtotime($resource_plan->trp_start)), array('class' => 'span1 date'));
        ?>
</td>
                              <td><?php 
        echo CHtml::textField('trp-end-' . $i, date('d-m-Y', strtotime($resource_plan->trp_end)), array('class' => 'span1 date'));
        ?>
</td>
                              <td><?php 
        echo CHtml::dropDownList('trp-work-load-' . $i, $resource_plan->trp_work_load, TaskResourcePlan::getDataWorkLoad(), array('class' => 'span1'));
        ?>
</td>
                              <td>
                                  <?php 
        echo CHtml::textField('trp-effort-' . $i, $resource_plan->trp_effort, array('class' => 'span1'));
        ?>
                                  <?php 
        echo CHtml::hiddenField('trp_id_' . $i, $resource_plan->trp_id, array('class' => 'span1'));
        ?>
                              </td>
                          </tr>
                              <?php 
    }
}
?>