예제 #1
0
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     // Get task_assignment for this user
     // $assignments = TaskAssignment::model()->with('task')->findAll(array('condition'=>'member_id='.Yii::app()->user->id.' AND t.deleted=0 AND task.status != "Complete"'));
     // Create new TaskLog
     $model = new TaskLog();
     //$model->date = date('Y-m-d');
     $model->member_id = Yii::app()->user->id;
     if (isset($_POST['TaskLog'])) {
         $model->attributes = $_POST['TaskLog'];
         if ($model->type == "Non-project") {
             $model->task_assignment_id = null;
             if ($model->save()) {
                 $this->redirect(array('mylog'));
             }
         } else {
             if ($model->type == "Project") {
                 // Check wheter log already exists
                 $check_log = TaskLog::model()->find(array('condition' => 'member_id=' . Yii::app()->user->id . ' AND task_assignment_id=' . $model->task_assignment_id . ' AND date="' . $model->date . '" AND deleted=0'));
                 if ($check_log) {
                     throw new CHttpException(403, 'This log has already been exist.');
                 } else {
                     if ($model->save()) {
                         $this->redirect(array('mylog'));
                     }
                 }
             }
         }
     }
     $this->render('create', array('model' => $model));
 }
예제 #2
0
        // If client count is equal, place session task in-progress as it will likely start soon.
        if ($MSAs == $MultiSess->get('clients') || $MultiSess->get('sessclients') > 0 && $MultiSess->get('clients') > 0) {
            $MultiSess->set('stateID', 3);
        } else {
            $MultiSess->set('stateID', 1);
        }
    }
    // Save the info.
    if ($Task->save() && ($Task->get('typeID') == 8 ? $MultiSess->save() : true)) {
        if ($MultiSess && $MultiSess->isValid()) {
            $Host->set('imageID', $MultiSess->get('image'));
        }
        // Log it
        $ImagingLogs = $FOGCore->getClass('ImagingLogManager')->find(array('hostID' => $Host->get('id'), 'type' => $_REQUEST['type'], 'complete' => '0000-00-00 00:00:00'));
        foreach ($ImagingLogs as $ImagingLog) {
            $id[] = $ImagingLog->get('id');
        }
        if (!$id) {
            $il = new ImagingLog(array('hostID' => $Host->get('id'), 'start' => $FOGCore->nice_date()->format('Y-m-d H:i:s'), 'image' => $Task->getImage()->get('name'), 'type' => $_REQUEST['type']));
        } else {
            $il = new ImagingLog(max($id));
            $il->set('start', $FOGCore->nice_set()->format('Y-m-d H:i:s'));
        }
        $il->save();
        $TaskLog = new TaskLog(array('taskID' => $Task->get('id'), 'taskStateID' => $Task->get('stateID'), 'createdTime' => $Task->get('createdTime'), 'createdBy' => $Task->get('createdBy')));
        $TaskLog->save();
        print '##@GO';
    }
} catch (Exception $e) {
    print $e->getMessage();
}