Пример #1
1
 public function addToMenu()
 {
     $variable = new Todo();
     $variable->document = $this->document;
     $variable->document["_id"] = new MongoId();
     $variable->store();
 }
Пример #2
0
 public function updatePriority(Todo $todo){
     $query = $this->_db->prepare(' UPDATE t_todo SET priority=:priority WHERE id=:id')
     or die (print_r($this->_db->errorInfo()));
     $query->bindValue(':id', $todo->id());
     $query->bindValue(':priority', $todo->priority());
     $query->execute();
     $query->closeCursor();
 }
Пример #3
0
 public function testApiMapper()
 {
     // given
     $todo = new Todo(12, "foo", "new");
     // when
     $vo = $todo->marshal();
     $entity = Todo::unmarshal($vo);
     // then
     $this->assertEquals($todo, $entity, "api should be able to marshal/unmarshal without losing anything");
 }
Пример #4
0
 /**
  * @param String $todoString
  * @return Todo
  */
 public static function parse($todoString)
 {
     $completed = false;
     if ('x ' === substr($todoString, 0, 2)) {
         $completed = true;
     }
     if ($completed) {
         $todo = new Todo(self::getText($todoString), self::getCreationDate($todoString), null, self::getProjects($todoString), self::getContexts($todoString), self::getDueDate($todoString), true);
         $todo->done(self::getCompletedDate($todoString));
     } else {
         $todo = new Todo(self::getText($todoString), self::getCreationDate($todoString), self::getPriority($todoString), self::getProjects($todoString), self::getContexts($todoString), self::getDueDate($todoString));
     }
     return $todo;
 }
Пример #5
0
 /**
  * Metodi hakee liitoskyselynä kaikki muistutukset ja niihin liittyvät luokat,
  * luokkien nimet sekä halutun luokan nimen.
  * 
  * @param type $name    luokan nimi
  */
 public static function index($name)
 {
     $categories = Category::countAllRows();
     $todos = Todo::all();
     $data = array('todos' => $todos, 'categories' => $categories, 'className' => $name);
     View::make('reminders/class.html', $data);
 }
Пример #6
0
 public static function getById($id)
 {
     $connection = new Connection();
     $getId = $connection->mysql->real_escape_string($id);
     $query = "SELECT * FROM todo WHERE id = {$getId}";
     $results = $connection->mysql->query($query);
     if ($results->num_rows) {
         while ($row = $results->fetch_object()) {
             $obj = new Todo();
             $obj->setId($row->id);
             $obj->setTitle($row->title);
             $obj->setDescription($row->description);
         }
     }
     return $obj;
 }
 public function dashboard()
 {
     $counts = ['organizations' => Organization::count(), 'users' => User::count(), 'todos' => Todo::count(), 'mt_users' => User::has('organizations', '>', 1)->count()];
     $newestOrg = Organization::orderBy('created_at', 'desc')->first();
     $orgWithMostTodos = DB::table('organizations')->select(['organizations.name', DB::raw('count(todos.organization_id) as total')])->join('todos', 'todos.organization_id', '=', 'organizations.id')->orderBy('total', 'desc')->groupBy('todos.organization_id')->first();
     $this->view('dashboard', compact('counts', 'newestOrg', 'orgWithMostTodos'));
 }
 /** removes an item from the DB */
 public function checkbox()
 {
     $todo = Todo::find($this->params['id']);
     $todo->done = $todo->done ? 0 : 1;
     $todo->save();
     $this->redirect_to('all');
 }
Пример #9
0
 public function run()
 {
     $faker = Faker::create();
     foreach (range(1, 10) as $index) {
         Todo::create([]);
     }
 }
Пример #10
0
 public function indexAction()
 {
     $todos = Todo::find(array(array()));
     foreach ($todos as $todo) {
         //$todo->delete();
     }
     $this->view->todos = Todo::find();
 }
Пример #11
0
 /**
  * @param $id
  * @return Todo
  * @throws CHttpException
  */
 private function loadModel($id)
 {
     $model = Todo::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'Запрошенная страница не найдена.');
     }
     return $model;
 }
Пример #12
0
 public function action_do_create()
 {
     $project = Project::find(Input::get('project_id'));
     $new = array('title' => Input::get('title'), 'description' => Input::get('description'), 'customer_id' => $project->customer_id, 'project_id' => $project->id, 'organization_id' => Auth::user()->organization->id);
     $v = Todo::validate($new);
     if ($v->fails()) {
         // redirect back to the form with
         // errors, input and our currently
         // logged in user
         return Redirect::to_route('create_todo', $project->id)->with_errors($v)->with_input();
     }
     // create the new post
     $o = new Todo($new);
     $o->save();
     // redirect to viewing our new post
     return Redirect::to_route('read_customer', $project->customer_id);
 }
Пример #13
0
 public function action_create($todo_id = false)
 {
     if ($todo_id == false) {
         die("error");
     }
     $report = new Report();
     $todo = Todo::find($todo_id);
     return View::make('report.create')->with('report', $report)->with('todo', $todo);
 }
Пример #14
0
 function delete()
 {
     $items =& Todo::cache();
     if (is_null($this->id)) {
         return FALSE;
     }
     unset($items[$this->id]);
     return TRUE;
 }
 /**
  * Execute the console command.
  *
  * @return void
  */
 public function fire()
 {
     $archived = $this->option('archived');
     $tasks = $this->option('tasks');
     if (!is_null($tasks)) {
         $validTasks = array('all', 'next', 'normal', 'done');
         if (!in_array($tasks, $validTasks)) {
             $msg = sprintf("Invalid --tasks=%s. Must be one of '%s'.", $tasks, join("', '", $validTasks));
             $this->abort($msg);
         }
         if ($tasks == 'next') {
             $tasks = 'next action';
         }
         $completeFmt = Config::get('todo.dateCompleteFormat');
         $dueFmt = Config::get('todo.dateDueFormat');
     }
     // Get lists
     $lists = \Todo::allLists($archived);
     $lists = $this->sortListIds($lists);
     // Output title
     $listType = $archived ? 'archived lists' : 'lists';
     $listWhat = is_null($tasks) ? 'all' : "{$tasks} tasks in all";
     $this->info("Listing {$listWhat} {$listType}");
     // Different headers based on tasks usage
     if (is_null($tasks)) {
         $headers = array('list', 'next', 'todos', 'completed');
     } else {
         $headers = array('List', 'Next', 'Description', 'Extra');
     }
     $rows = array();
     foreach ($lists as $listId) {
         $list = \Todo::get($listId, $archived);
         // We're just outputing the lists
         if (is_null($tasks)) {
             $rows[] = array($listId, $list->taskCount('next'), $list->taskCount('todo'), $list->taskCount('done'));
         } else {
             // Loop through tasks to figure which to output
             foreach ($list->tasks() as $task) {
                 if ($task->isComplete()) {
                     if ($tasks == 'done' || $tasks == 'all') {
                         $done = $task->dateCompleted()->format($completeFmt);
                         $rows[] = array($listId, '', $task->description(), "Done {$done}");
                     }
                 } else {
                     $next = $task->isNextAction() ? 'YES' : '';
                     $due = $task->dateDue() ? 'Due ' . $task->dateDue()->format($dueFmt) : '';
                     if ($tasks == 'all' or $tasks == 'next action' && $next == 'YES' or $tasks == 'normal' && $next == '') {
                         $rows[] = array($listId, $next, $task->description(), $due);
                     }
                 }
             }
         }
     }
     // Output a pretty table
     $table = $this->getHelperSet()->get('table');
     $table->setHeaders($headers)->setRows($rows)->render($this->getOutput());
 }
Пример #16
0
 /**
  * Delete the to-do item
  *
  * @return bool
  *
  * @see ElggEntity::delete()
  */
 public function delete($recursive = true)
 {
     // notify about delete
     $acting_user = elgg_get_logged_in_user_entity();
     $subject = elgg_echo('todos:notify:todoitem:delete:subject', array($this->title));
     $message = elgg_echo('todos:notify:todoitem:delete:message', array($acting_user->name, $this->title));
     $this->notifyUsers($subject, $message);
     return parent::delete();
 }
 /**
  * update todo
  */
 public function put()
 {
     $data = json_decode($this->app->request()->getBody());
     $todo = Todo::find((int) $data->id);
     $todo->title = (string) $data->title;
     $todo->done = (bool) $data->done;
     $todo->save();
     echo $todo->to_json();
 }
 public function getDone($id)
 {
     if (Request::ajax()) {
         $task = Todo::find($id);
         $task->status = (int) $task->status == 1 ? 0 : 1;
         $task->save();
         return 'OK';
     }
 }
Пример #19
0
 /**
  * Saves object-specific attributes.
  *
  * @return bool
  *
  * @see ElggObject::save()
  */
 public function save()
 {
     $res = parent::save();
     if (!$res) {
         return $res;
     }
     $this->updateTodoItemAccess();
     return $res;
 }
 public function run()
 {
     DB::table('todos')->truncate();
     foreach (Organization::all() as $org) {
         Todo::create(['name' => 'First Todo', 'user_id' => $org->users[0]->id, 'organization_id' => $org->id, 'completed' => true]);
         Todo::create(['name' => 'Second Todo', 'user_id' => $org->users[0]->id, 'organization_id' => $org->id]);
         Todo::create(['name' => 'Todo from Second', 'user_id' => $org->users[1]->id, 'organization_id' => $org->id]);
         Todo::create(['name' => 'Third Todo', 'user_id' => $org->users[0]->id, 'organization_id' => $org->id]);
     }
 }
Пример #21
0
 public function checkSelf()
 {
     $messages = [];
     $count = Todo::model()->countUnfinished();
     if (!$count) {
         return false;
     }
     $messages[WebModule::CHECK_NOTICE][] = ['type' => WebModule::CHECK_NOTICE, 'message' => CHtml::link('Невыполненных задач - ' . $count, ['/todo/todoBackend/index'])];
     return $messages;
 }
Пример #22
0
 public function actionUpdate()
 {
     $postdata = file_get_contents("php://input");
     $post = CJSON::decode($postdata);
     if (isset($post['id'])) {
         $model = Todo::model()->findByPk($post['id']);
         if ($post['note'] == '') {
             $model->delete();
             echo "{}";
             return true;
         }
     } else {
         $model = new Todo();
     }
     $model->attributes = $post;
     $model->user_id = Yii::app()->user->id;
     $model->save();
     echo json_encode($model->attributes);
 }
Пример #23
0
 /**
  * Maps array to the given {@link Todo}.
  * <p>
  * Expected properties are:
  * <ul>
  *   <li>id</li>
  *   <li>priority</li>
  *   <li>created_on</li>
  *   <li>due_on</li>
  *   <li>last_modified_on</li>
  *   <li>title</li>
  *   <li>description</li>
  *   <li>comment</li>
  *   <li>status</li>
  *   <li>deleted</li>
  * </ul>
  * @param Todo $todo
  * @param array $properties
  */
 public static function map(Todo $todo, array $properties)
 {
     if (array_key_exists('id', $properties)) {
         $todo->setId($properties['id']);
     }
     if (array_key_exists('priority', $properties)) {
         $todo->setPriority($properties['priority']);
     }
     if (array_key_exists('created_on', $properties)) {
         $createdOn = self::createDateTime($properties['created_on']);
         if ($createdOn) {
             $todo->setCreatedOn($createdOn);
         }
     }
     if (array_key_exists('due_on', $properties)) {
         $dueOn = self::createDateTime($properties['due_on']);
         if ($dueOn) {
             $todo->setDueOn($dueOn);
         }
     }
     if (array_key_exists('last_modified_on', $properties)) {
         $lastModifiedOn = self::createDateTime($properties['last_modified_on']);
         if ($lastModifiedOn) {
             $todo->setLastModifiedOn($lastModifiedOn);
         }
     }
     if (array_key_exists('title', $properties)) {
         $todo->setTitle(trim($properties['title']));
     }
     if (array_key_exists('description', $properties)) {
         $todo->setDescription(trim($properties['description']));
     }
     if (array_key_exists('comment', $properties)) {
         $todo->setComment(trim($properties['comment']));
     }
     if (array_key_exists('status', $properties)) {
         $todo->setStatus($properties['status']);
     }
     if (array_key_exists('deleted', $properties)) {
         $todo->setDeleted($properties['deleted']);
     }
 }
Пример #24
0
 public function listFiltered()
 {
     $flag = Input::get('filter');
     $my = Input::get('my');
     $all = Input::get('all');
     $todos = Todo::getFilteredTodosByFlag($flag);
     $defaultActual = $flag;
     $users_opt = User::getUserOptions();
     $this->layout->title = trans('messages.Todo listings');
     $this->layout->main = View::make('users.dashboard')->nest('content', 'todos.list', compact('todos', 'users_opt', 'my', 'defaultActual', 'all'));
 }
 /**
  * レコード削除
  */
 public function delete($id = null)
 {
     if (!$id) {
         $this->Session->setFlash(__('不正なIDです', true));
         $this->redirect(array('action' => 'index'));
     }
     if ($this->Todo->del($id)) {
         $this->Session->setFlash(__('TODOを削除しました', true));
         $this->redirect(array('action' => 'index'));
     }
 }
Пример #26
0
 public static function getFilteredTodosByFlag($flag)
 {
     //workaround - big pagination due to bug of the component while using with post method
     $pagination = 200;
     if ($flag == 1) {
         return Todo::getTodosActual($pagination);
     }
     if ($flag == 2) {
         return Todo::getTodosNotActual($pagination);
     }
     return Todo::getTodosOrdered($pagination);
 }
Пример #27
0
 public function removeAction($id)
 {
     $task = Todo::findFirst("id = '" . $id . "'");
     if (!$task->delete()) {
         foreach ($task->getMessages() as $message) {
             $this->flash->error($message);
         }
         return $this->forward("todo/index");
     }
     $this->flash->success("Task was deleted");
     $this->dispatcher->forward(['action' => 'index']);
 }
Пример #28
0
 public function delete_index($id = null)
 {
     $todo = Todo::find($id);
     if ($todo->user_id != Auth::user()->id) {
         return Response::json('You are not the owner of this todo', 404);
     }
     if (is_null($todo)) {
         return Response::json('Todo not found', 404);
     }
     $deletedtodo = $todo;
     $todo->delete();
     return Response::eloquent($deletedtodo);
 }
Пример #29
0
 public function get_index()
 {
     // @TODO Make configurable. Global or per-user?
     $status_codes = array(0 => __('tinyissue.todo_status_0'), 1 => __('tinyissue.todo_status_1'), 2 => __('tinyissue.todo_status_2'), 3 => __('tinyissue.todo_status_3'));
     // Ensure we have an entry for each lane.
     $lanes = array();
     foreach ($status_codes as $index => $name) {
         $lanes[$index] = array();
     }
     // Load todos into lanes according to status.
     $todos = Todo::load_user_todos();
     foreach ($todos as $todo) {
         $lanes[$todo['status']][] = $todo;
     }
     return $this->layout->with('active', 'todo')->nest('content', 'todo.index', array('lanes' => $lanes, 'status' => $status_codes, 'columns' => count($status_codes)));
 }
 /**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     DB::transaction(function () {
         Schema::create('organization_user', function (Blueprint $table) {
             $table->increments('id');
             $table->integer('organization_id')->unsigned();
             $table->integer('user_id')->unsigned();
             $table->timestamps();
         });
         foreach (User::all() as $user) {
             $user->organizations()->attach($user->organization_id);
         }
         Schema::table('todos', function (Blueprint $table) {
             $table->integer('organization_id')->unsigned()->nullable();
         });
         foreach (Todo::withUsers()->get() as $todo) {
             $todo->organization_id = $todo->user->organization_id;
             $todo->save();
         }
         Schema::table('users', function (Blueprint $table) {
             $table->dropColumn('organization_id');
         });
     });
 }