public static function all($params)
 {
     $mysqli = DB::getInstance();
     //Checked is used here to see if the user is a premium user.
     $checked = Todolist::checkIfPremium($params);
     //Total Dashboard for user is shown, with overall scores and statistic.
     $dashboard = Todolist::dashboard();
     $cleanUserId = $mysqli->real_escape_string($_SESSION['user']['id']);
     $result = $mysqli->query("\n\t\t \t\t\t\t\tSELECT * FROM todolist\n\t\t \t\t\t\t\tWHERE todolist.user_id = " . $cleanUserId . "\n\t\t \t\t\t\t\tAND todolist.expiration > NOW()\n\t\t \t  \t\t\t\t");
     while ($todolist = $result->fetch_assoc()) {
         $todolists[] = $todolist;
     }
     return ['todolists' => $todolists, 'premium' => $checked, 'dashboard' => $dashboard];
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     //        TodoList::create([
     //            'name' => 'San Juan Vacation',
     //            'description' => 'Things to do before we leave for Puerto Rico!'
     //        ]);
     //
     //        TodoList::create([
     //            'name' => 'Home Winterization',
     //            'description' => 'Winter is coming.'
     //        ]);
     //        TodoList::create([
     //            'name' => 'Rental Maintenance',
     //            'description' => 'Cleanup and improvements for new tenants'
     //        ]);
     $faker = \Faker\Factory::create();
     //        TodoList::truncate();
     foreach (range(0, 500) as $index) {
         Todolist::create(['name' => $faker->sentence(2), 'description' => $faker->sentence(4)]);
     }
 }
 /**
  * Displays a particular model.
  * @param integer $id the ID of the model to be displayed
  */
 public function actionView($id)
 {
     if (Yii::app()->user->checkAccess('viewTasks')) {
         $workers = new CActiveDataProvider('Users', array('criteria' => array('condition' => 'Tasks.task_id = :task_id', 'params' => array(':task_id' => $id), 'together' => true, 'order' => 't.user_name', 'with' => array('Tasks'))));
         Users::model()->verifyUserInProject((int) Yii::app()->user->getState('project_selected'), 1);
         $availableUsers = Users::model()->availablesUsersToTakeTask(Yii::app()->user->getState('project_selected'), $id);
         $this->render('view', array('model' => $this->loadModel($id), 'workers' => $workers, 'hasTodoList' => Todolist::model()->findList($id), 'availableUsers' => $availableUsers));
     } else {
         throw new CHttpException(403, Yii::t('site', '403_Error'));
     }
 }
 /**
  * Get list of subtask or toDolist
  * @param int $task_id
  * @return model of todolist
  */
 public function getTodoList($task_id)
 {
     return Todolist::model()->findActivity($task_id);
 }
Exemple #5
0
 public function destroy($id)
 {
     $user = \Auth::user();
     $list = Todolist::findOrFail($id);
     $list->delete();
     return \Redirect::route('lists.index')->with('message', 'Task deleted!');
 }
 /**
  * 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 the ID of the model to be loaded
  */
 public function loadModel($id)
 {
     $model = Todolist::model()->find(array('condition' => 't.task_id = :task_id AND t.todolist_id = :todolist_id', 'params' => array(':todolist_id' => $_POST['id'], ':task_id' => $_POST['task_id'])));
     if ($model === null) {
         throw new CHttpException(404, Yii::t('site', '404_Error'));
     }
     return $model;
 }
 public function findActivity($task_id)
 {
     return Todolist::model()->with('Task')->findAll(array('condition' => 't.task_id = :task_id', 'params' => array(':task_id' => $task_id), 'order' => 't.todolist_position ASC', 'together' => true));
 }