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 TaskProgress the loaded model * @throws CHttpException */ public function loadModel($id) { $model = TaskProgress::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
public function AddTaskProgress($task_id, $account_id, $percent_completed = 0, $days_completed = 0) { $user_id = Yii::app()->user->id; $task_progress = new TaskProgress(); $task_progress->tp_id = ""; $task_progress->task_id = $task_id; $task_progress->account_id = $account_id; $task_progress->tp_days_completed = $days_completed; $task_progress->tp_percent_completed = $percent_completed; $task_progress->tp_last_update_by = intval($user_id); $task_progress->tp_last_update = date('Y-m-d H:i:s'); if ($task_progress->save()) { return true; } return false; }
<?php /*@var task_id*/ $completed = TaskProgress::model()->calculateCompleted($task_id); $lapsed = TaskProgress::model()->calculateLapsed($task_id); $bg_completed = TaskProgress::model()->getProgressColor($task_id); TaskProgress::model()->calculatePlanned($task_id); ?> <div id="task-progress" style="margin-top: 20px;width: 230px;overflow: hidden;"> <div> <div style="float: left;width: 75px;">Completed: </div> <div class="progress" style="float: right;width: 150px;"> <div class="progress-bar bar-computer" role="progressbar" aria-valuenow="40" aria-valuemin="0" aria-valuemax="100" style="width: <?php echo $completed; ?> %; text-align: right; background: <?php echo $bg_completed; ?> "> <span class="sr-only"><?php echo $completed; ?> %</span> </div> </div> </div> <div style="clear: both;"> <div style="width: 75px;float: left;">Lapsed:</div> <div class="progress" style="float: right;width: 150px;"> <div class="progress-bar bar-lapsed" role="progressbar" aria-valuenow="20" aria-valuemin="0" aria-valuemax="100" style="width: <?php echo $lapsed;
echo CHtml::textField('tp-shedule-end', date('d-m-Y', strtotime($task->task_end_date)), array('class' => 'span2')); ?> </div> <!-- ----------------------END SCHEDULE ------------------------------------ --> <!-- ==================== INDIVIDUAL PROGRESS ================================ --> <div id="tp-individual" style="margin-top: 20px;"> <h4>Individual Progress</h4> <div> <ul style="margin: 0 0 10px 5px;"> <?php $i = 0; foreach ($task_assignee as $task_assignee_item) { $i++; $account_id = $task_assignee_item->account_id; $task_progress = TaskProgress::model()->getTaskProgress($task_id, $account_id); if (count($task_progress) > 0) { ?> <li style="list-style: none;"> <div style="width: 10%; float: left;margin-top: -3px;"><?php echo CHtml::image('images/user.png', $task_progress->account_id, array('width' => '40')); ?> </div> <div style="width: 56%; background: none repeat scroll 0 0 #ccc; float: left;"> <?php echo CHtml::hiddenField('tp_assignee_startAt_' . $i, $task_progress->tp_percent_completed, array('class' => 'span1')); ?> <?php echo CHtml::hiddenField('tp_account_' . $i, $account_id, array('class' => 'span1')); ?>