Example #1
0
 function get($criteria = null, $order = null)
 {
     $sql = "SELECT tasks.*, CONCAT(users.first_name, ' ', users.last_name) AS assigned_to_name\n                FROM tasks\n                LEFT JOIN users ON users.id = tasks.assigned_to";
     if (isset($criteria) && is_numeric($criteria)) {
         $sql .= " WHERE tasks.id = {$criteria}";
         $task = parent::get_one($sql);
         $this->update_status();
         return $task;
     } else {
         $sql = $this->add_criteria($sql, $criteria);
         $sql = $this->modify_sql_for_user_type($sql);
         $sql = $this->add_order_by($sql, $order);
         $tasks = parent::get($sql);
         foreach ($tasks as &$task) {
             //create the invoice
             $task_object = new Task($task);
             //todo: i don't think this makes any sense because the invoice status will already be updated when I create the invoice using new Invoice
             //store the current task status as it exists in the database
             $old_status = $task_object->status_text;
             //update the task status
             $task_object->update_status();
             //if the old status and the new status do not match, then we need to save this task back to the database.
             if ($old_status != (string) $task_object->status_text) {
                 //todo:make sure this isn't saving each time
                 $task_object->save(false);
             }
             //we need to add the status text back the task array, since we're sending the array to the client,
             //not the object
             $task['status_text'] = $task_object->status_text;
         }
         return $tasks;
     }
 }
Example #2
0
 public function after()
 {
     echo "after\n";
     $insert = 0;
     // 判断是否插入表
     $class_name = get_class($this);
     $type = str_replace('Event', '', $class_name);
     $task = new Task();
     if ($this->event_rs['err_no'] > 0) {
         //  代表错误
         $task->is_success = 0;
         $this->event_rs['class'] = $this->class;
         $this->event_rs['param'] = $this->param;
         if ($this->retry_cnt >= 3) {
             $insert = 1;
         }
     } else {
         $task->is_success = 1;
         $insert = 1;
     }
     // 成功则入库 第一次失败则不入库 第三次失败才一起入库
     $task->create_time = time();
     $task->retry_cnt = $this->retry_cnt;
     $task->event = $type;
     $task->param = json_encode($this->param);
     if ($insert > 0) {
         $task->save();
     }
     $this->event_rs['retry_cnt'] = $this->retry_cnt;
 }
 /**
  * Store a newly created resource in storage.
  * POST /task
  *
  * @return Response
  */
 public function store()
 {
     // Input::merge(array_map('trim', Input::all()));
     $input = Input::all();
     $validation = Validator::make($input, Task::$rules);
     if ($validation->passes()) {
         $task = new Task();
         $task->task = strtoupper(Input::get('task'));
         $task->description = strtoupper(Input::get('description'));
         $task->save();
         $id = $task->id;
         $gettime = time() - 14400;
         $datetime_now = date("H:i:s", $gettime);
         $task_approver = Input::get('task_approver');
         $task_receiver = Input::get('task_receiver');
         foreach ($task_approver as $row_approver) {
             DB::table('task_approver')->insert(array(['task_id' => $id, 'user_id' => $row_approver, 'datetime_created' => date('Y-m-d') . $datetime_now]));
         }
         foreach ($task_receiver as $row_receiver) {
             DB::table('task_receiver')->insert(array(['task_id' => $id, 'user_id' => $row_receiver, 'datetime_created' => date('Y-m-d') . $datetime_now]));
         }
         return Redirect::route('task.index')->with('class', 'success')->with('message', 'Record successfully created.');
     } else {
         return Redirect::route('task.create')->withInput()->withErrors($validation)->with('class', 'error')->with('message', 'There were validation error.');
     }
 }
Example #4
0
 public function actionCreate()
 {
     switch ($_GET['model']) {
         case 'user':
             $model = new User('create');
             break;
         case 'task':
             $model = new Task();
             break;
         default:
             $this->_sendResponse(501, Yii::t('tasklist', 'Mode "create" is not implemented for model "{model}"', array('{model}' => $_GET['model'])));
             exit;
     }
     foreach ($_POST as $var => $value) {
         if ($model->hasAttribute($var)) {
             $model->{$var} = $value;
         } else {
             $this->_sendResponse(500, Yii::t('tasklist', 'Parameter "{param}" is not allowed', array('{param}' => $var)));
         }
     }
     if ($model->save()) {
         $this->_sendResponse(200, CJSON::encode($model->attributes));
     } else {
         $this->_sendResponse(500, CJSON::encode($model->errors));
     }
 }
 public function testKanbanItemSave()
 {
     $accounts = Account::getByName('anAccount');
     $user = UserTestHelper::createBasicUser('Billy');
     $task = new Task();
     $task->name = 'MyTask';
     $task->owner = $user;
     $task->requestedByUser = $user;
     $task->description = 'my test description';
     $taskCheckListItem = new TaskCheckListItem();
     $taskCheckListItem->name = 'Test Check List Item';
     $task->checkListItems->add($taskCheckListItem);
     $task->activityItems->add($accounts[0]);
     $task->status = Task::STATUS_IN_PROGRESS;
     $this->assertTrue($task->save());
     $this->assertEquals(1, KanbanItem::getCount());
     $id = $task->id;
     unset($task);
     $task = Task::getById($id);
     //KanbanItem is created after saving Task
     $kanbanItems = KanbanItem::getAll();
     $this->assertCount(1, $kanbanItems);
     $kanbanItem = $kanbanItems[0];
     $this->assertEquals(KanbanItem::TYPE_IN_PROGRESS, $kanbanItem->type);
 }
Example #6
0
 public static function store()
 {
     self::check_logged_in();
     $params = $_POST;
     if (empty($_POST['projects'])) {
         $errors[] = 'Select at least one project!';
         $projects = '';
     } else {
         $projects = $_POST['projects'];
     }
     $attributes = array('description' => $params['description'], 'priority' => $params['priority'], 'status' => 0, 'projectids' => $projects);
     $task = new Task($attributes);
     //$errors = $task->errors(); // Deprecated: Switched to valitron. Calls all validators
     $errors = $task->validateTask();
     // Valitron takes care of putting all errors in one array
     //Kint::dump($params); // Debug, comment out Redirect if used!
     //Kint::dump($task);
     if (count($errors) == 0) {
         $task->save();
         // Tell task-model to save this object to DB
         foreach ($projects as $project) {
             Project::addTask($task->id, $project);
             // We don't know the id before it is saved!
             Project::updateCount($project);
         }
         Redirect::to('/task/' . $task->id, array('message' => 'Task added to database!'));
     } else {
         Kint::dump($errors);
         $projects = Project::all();
         Kint::dump($attributes);
         Kint::dump($projects);
         View::make('task/new.html', array('errors' => $errors, 'attributes' => $attributes, 'projects' => $projects));
     }
 }
Example #7
0
 function uncomplete_task()
 {
     $id = $this->input->post('id');
     $user = new User();
     $task = new Task();
     if ($task->where('user_id', $this->dx_auth->get_user_id())->where('id', $id)->count() == 0) {
         return;
     }
     $task->get_by_id($id);
     $task->completed = 0;
     $task->save();
     $docket = new Docket();
     $docket->get_by_id($task->docket_id);
     $task->clear();
     if ($task->where('docket_id', $docket->id)->where('completed', 0)->count() == 0) {
         $docket->completed = 1;
         $docket->save();
     } else {
         $docket->completed = 0;
         $docket->save();
     }
     $gold = $this->treasure->decrease($this->dx_auth->get_user_id());
     $task->clear();
     $task->get_by_id($id);
     $result = array('id' => $task->id, 'name' => $task->name, 'docket_id' => $docket->id, 'due' => $task->due, 'gold' => $gold);
     echo json_encode($result);
 }
Example #8
0
 public static function store()
 {
     parent::check_logged_in();
     // POST-pyynnön muuttujat sijaitsevat $_POST nimisessä assosiaatiolistassa
     $params = $_POST;
     // Alustetaan uusi task-luokan olion käyttäjän syöttämillä arvoilla
     /*$task = new task(array(
       'name' => $params['name'],
       'description' => $params['description'],
       'publisher' => $params['publisher'],
       'published' => $params['published']
       ));*/
     $params['user_id'] = parent::get_user_logged_in()->id;
     $task = new Task($params);
     $errors = $task->validate();
     if (!$errors) {
         // Kutsutaan alustamamme olion save metodia, joka tallentaa olion tietokantaan
         $task->save();
         // Ohjataan käyttäjä lisäyksen jälkeen pelin esittelysivulle
         //Redirect::to('/task/' . $task->id, array('message' => 'Task has been added!'));
         Redirect::to('/task', array('message' => 'Task has been added!'));
     } else {
         View::make('task/new.html', array('errors' => $errors, 'attributes' => $params, 'title' => 'new task'));
     }
 }
 public function addTask()
 {
     if ($_POST) {
         // Lets start validation
         // validate input
         $rules = array('name' => 'required|max:50', 'description' => 'required', 'didyouknow' => 'required', 'reference' => 'required');
         $validation = Validator::make(Input::all(), $rules);
         if ($validation->fails()) {
             Input::flash();
             return Redirect::back()->withInput()->withErrors($validation);
         }
         $task = new Task();
         $task->name = Input::get('name');
         $task->description = Input::get('description');
         $task->didyouknow = Input::get('didyouknow');
         $task->reference = Input::get('reference');
         $task->author = Input::get('taskauthor');
         $task->createdby = 0;
         $task->suspended = 0;
         $task->number = 0;
         $task->save();
         return Redirect::to('tasks/manage');
     }
     return View::make('task.add');
 }
 /**
  * Show the form for creating a new resource.
  * GET /tasks/create
  *
  * @return Response
  */
 public function create()
 {
     // Rules
     $rules = array('weight' => 'integer|between:1,5', 'name' => 'required');
     // Custom messages
     $messages = array('between' => 'The :attribute must be between :min - :max.', 'integer' => ':attribute must be a number');
     // Create validation
     $validator = Validator::make(Input::all(), $rules, $messages);
     // Check validation
     if ($validator->fails()) {
         return Redirect::back()->withErrors($validator)->withInput();
     }
     // Insert the task to database
     $task = new Task();
     $task->project_id = Input::get('projectId');
     $task->user_id = Auth::id();
     $task->name = Input::get('name');
     $task->weight = Input::get('weight');
     if (!Input::get('weight')) {
         $task->weight = 1;
     }
     $task->state = "incomplete";
     $task->save();
     // Increase the users overall task count
     $user = User::find(Auth::id());
     $user->tasks_created = $user->tasks_created + 1;
     $user->save();
     return Redirect::back()->with('success', Input::get('name') . " has been created.");
 }
Example #11
0
 public function store()
 {
     $task = new Task(Input::all());
     if (!$task->save()) {
         return Redirect::back()->withInput()->withErrors($task->getErrors());
     }
     return Redirect::home();
 }
Example #12
0
 /**
  * [addPostTask description]
  */
 public function store()
 {
     if (Input::has('task_label')) {
         $task = new Task();
         $task->label = Input::get('task_label');
         $task->save();
     }
     return Redirect::back();
 }
Example #13
0
 /**
  * 開始寫入資料
  */
 private function GetNewSEOState()
 {
     $taskModel = new Task();
     $date = new DateTime();
     $taskModel->attributes = array('date' => $date->format("Y-m-d H:i:s"));
     $taskModel->save();
     $taskID = $taskModel->getPrimaryKey();
     $this->GetSEOState($taskID);
 }
 /**
  * Store a newly created resource in storage.
  * POST /tasks
  *
  * @param Project $project
  * @return Response
  */
 public function store(Project $project)
 {
     $input = Input::all();
     $input['project_id'] = $project->id;
     $task = new Task($input);
     if ($task->save()) {
         return Redirect::route('projects.show', $project->slug)->with('message', 'Task created.');
     } else {
         return Redirect::route('projects.tasks.create', $project->slug)->withInput()->withErrors($task->errors());
     }
 }
 public function run()
 {
     $task1 = new Task();
     $task1->description = 'Do something';
     $task1->list_id = 1;
     $task1->save();
     $task2 = new Task();
     $task2->description = 'Do something else';
     $task2->list_id = 1;
     $task2->save();
 }
Example #16
0
 function test_getDescription()
 {
     //Arrange
     $description = "Wash the dog";
     $test_task = new Task($description);
     $test_task->save();
     //Act
     $result = $test_task->getDescription();
     //Assert
     $this->assertEquals("Wash the dog", $result);
 }
 function createTask()
 {
     $validator = Validator::make(Input::all(), ['name' => 'required|max:255']);
     if ($validator->fails()) {
         return redirect('/')->withInput()->withErrors($validator);
     }
     $task = new Task();
     $task->name = Input::get('name');
     $task->save();
     return Redirect::to('/');
 }
 public function testCreateChecklistItemViewForTaskUsingAjax()
 {
     $super = $this->logoutCurrentUserLoginNewUserAndGetByUsername('super');
     $task = new Task();
     $task->name = 'aTest1';
     $nowStamp = DateTimeUtil::convertTimestampToDbFormatDateTime(time());
     $this->assertTrue($task->save());
     $this->setGetArray(array('id' => $task->id, 'uniquePageId' => 'TaskCheckItemInlineEditForModelView'));
     $content = $this->runControllerWithNoExceptionsAndGetContent('tasks/taskCheckItems/inlineCreateTaskCheckItemFromAjax', false);
     $this->assertContains('TaskCheckListItem_name', $content);
 }
Example #19
0
 function test_find()
 {
     $description = "Wash the dog";
     $description2 = "Water the lawn";
     $test_Task = new Task($description);
     $test_Task->save();
     $test_Task2 = new Task($description2);
     $test_Task2->save();
     $id = $test_Task->getId();
     $result = Task::find($id);
     $this->assertEquals($test_Task, $result);
 }
 public function saveTask()
 {
     $taskName = Input::get('name');
     $taskDate = Input::get('due_date');
     $taskDone = false;
     $task = new Task();
     $task->name = $taskName;
     $task->due_date = $taskDate;
     $task->done = $taskDone;
     $task->save();
     return Response::json($task);
 }
 /**
  * Performs the work of inserting or updating the row in the database.
  *
  * If the object is new, it inserts it; otherwise an update is performed.
  * All related objects are also updated in this method.
  *
  * @param      PropelPDO $con
  * @return     int The number of rows affected by this insert/update and any referring fk objects' save() operations.
  * @throws     PropelException
  * @see        save()
  */
 protected function doSave(PropelPDO $con)
 {
     $affectedRows = 0;
     // initialize var to track total num of affected rows
     if (!$this->alreadyInSave) {
         $this->alreadyInSave = true;
         // We call the save method on the following object(s) if they
         // were passed to this object by their coresponding set
         // method.  This object relates to these object(s) by a
         // foreign key reference.
         if ($this->aTaskRelatedByTaskId !== null) {
             if ($this->aTaskRelatedByTaskId->isModified() || $this->aTaskRelatedByTaskId->isNew()) {
                 $affectedRows += $this->aTaskRelatedByTaskId->save($con);
             }
             $this->setTaskRelatedByTaskId($this->aTaskRelatedByTaskId);
         }
         if ($this->aTaskRelatedByOverrideTaskId !== null) {
             if ($this->aTaskRelatedByOverrideTaskId->isModified() || $this->aTaskRelatedByOverrideTaskId->isNew()) {
                 $affectedRows += $this->aTaskRelatedByOverrideTaskId->save($con);
             }
             $this->setTaskRelatedByOverrideTaskId($this->aTaskRelatedByOverrideTaskId);
         }
         if ($this->aUser !== null) {
             if ($this->aUser->isModified() || $this->aUser->isNew()) {
                 $affectedRows += $this->aUser->save($con);
             }
             $this->setUser($this->aUser);
         }
         if ($this->isNew()) {
             $this->modifiedColumns[] = OverrideTaskPeer::ID;
         }
         // If this object has been modified, then save it to the database.
         if ($this->isModified()) {
             if ($this->isNew()) {
                 $pk = OverrideTaskPeer::doInsert($this, $con);
                 $affectedRows += 1;
                 // we are assuming that there is only 1 row per doInsert() which
                 // should always be true here (even though technically
                 // BasePeer::doInsert() can insert multiple rows).
                 $this->setId($pk);
                 //[IMV] update autoincrement primary key
                 $this->setNew(false);
             } else {
                 $affectedRows += OverrideTaskPeer::doUpdate($this, $con);
             }
             $this->resetModified();
             // [HL] After being saved an object is no longer 'modified'
         }
         $this->alreadyInSave = false;
     }
     return $affectedRows;
 }
Example #22
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     $task = new Task();
     $task->unguard();
     $task->fill(Input::only(['name', 'user_id', 'description', 'status']));
     $task->deadline = new DateTime(Input::get('deadline'));
     if ($task->validate()) {
         $task->save();
     } else {
         return View::make('tasks.edit', ['task' => $task])->withErrors($task->validator());
     }
     return Redirect::to(route('tasks.index'))->with('message', ['content' => 'Taak met succes aangemaakt!', 'class' => 'success']);
 }
Example #23
0
 public function postTask(Request $request)
 {
     if (Auth::user()) {
         $id = Auth::user()->id;
         $tache = new Task();
         $tache->user_id = $id;
         $tache->name = $request->input('tache');
         $tache->descriptionTache = $request->input('description');
         $tache->fini = "0";
         $tache->save();
         return redirect('/')->with('flash_message', 'Ajouté avec succés');
     }
 }
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Task();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Task'])) {
         $model->attributes = $_POST['Task'];
         if ($model->save()) {
             $this->redirect(array('view', 'id' => $model->id));
         }
     }
     $this->render('create', array('model' => $model));
 }
 public function testInlineCreateTaskCheckItemSave()
 {
     $this->logoutCurrentUserLoginNewUserAndGetByUsername('super');
     $task = new Task();
     $task->name = 'aTest';
     $this->assertTrue($task->save());
     $this->setGetArray(array('relatedModelId' => $task->id, 'relatedModelClassName' => 'Task', 'relatedModelRelationName' => 'checkListItems', 'url' => Yii::app()->createUrl('tasks/taskCheckItems/inlineCreateTaskCheckItemFromAjax', array('id' => $task->id, 'uniquePageId' => 'TaskCheckItemInlineEditForModelView'))));
     $this->setPostArray(array('TaskCheckListItem' => array('name' => 'Test Item'), 'ajax' => 'task-check-item-inline-edit-form'));
     $this->runControllerWithExitExceptionAndGetContent('tasks/taskCheckItems/inlineCreateTaskCheckItemSave', true);
     $this->setGetArray(array('relatedModelId' => $task->id, 'relatedModelClassName' => 'Task', 'relatedModelRelationName' => 'checkListItems', 'url' => Yii::app()->createUrl('tasks/taskCheckItems/inlineCreateTaskCheckItemFromAjax', array('id' => $task->id, 'uniquePageId' => 'TaskCheckItemInlineEditForModelView'))));
     $this->setPostArray(array('TaskCheckListItem' => array('name' => 'Test Item')));
     $this->runControllerWithNoExceptionsAndGetContent('tasks/taskCheckItems/inlineCreateTaskCheckItemSave', true);
 }
Example #26
0
 public function storage()
 {
     $user_id = 2;
     if (Task::where('user_id', $user_id)->count()) {
         $task = Task::where('user_id', $user_id)->first();
     } else {
         $task = new Task();
     }
     $task->user_id = $user_id;
     $task->tasks = json_encode($_POST);
     $task->save();
     exit;
 }
Example #27
0
 public function executeUpdate()
 {
     $jira = new sfJiraPlugin($this->getUser()->getProfile()->getJiraLogin(), $this->getUser()->getProfile()->getJiraPassword());
     $aProjects = $jira->getProjects();
     foreach ($aProjects as $project) {
         #var_dump( $project );
         $c = new Criteria();
         $c->add(ProjectPeer::USER_ID, $this->getUser()->getProfile()->getId());
         $c->add(ProjectPeer::KEY, $project->key);
         $p = ProjectPeer::doSelectOne($c);
         $c = new Criteria();
         $c->add(UserPeer::JIRA_LOGIN, $project->lead);
         $u = UserPeer::doSelectOne($c);
         if (empty($p)) {
             $p = new Project();
             $p->setKey($project->key);
             $p->setLeadId(!empty($u) ? $u->getId() : null);
             $p->setUserId($this->getUser()->getProfile()->getId());
             $p->setName($project->name);
             $p->setUpdated(date('r'));
             $p->save();
         }
         $issues = $jira->getIssuesForProject($p->getKey());
         foreach ($issues as $issue) {
             #die($p->getKey());
             if ($issue->assignee == $this->getUser()->getProfile()->getJiraLogin()) {
                 $c = new Criteria();
                 $c->add(TaskPeer::KEY, $issue->key);
                 $t = TaskPeer::doSelectOne($c);
                 if (empty($t)) {
                     $c = new Criteria();
                     $c->add(UserPeer::JIRA_LOGIN, $issue->reporter);
                     $u = UserPeer::doSelectOne($c);
                     $t = new Task();
                     $t->setProjectId($p->getId());
                     $t->setTitle($issue->summary);
                     $t->setDescription($issue->description);
                     $t->setKey($issue->key);
                     $t->setUpdated(date('r'));
                     $t->setStatusId($issue->status);
                     $t->setPriorityId($issue->priority);
                     $t->setLeadId(!empty($u) ? $u->getId() : null);
                     $t->save();
                 }
             }
         }
     }
     $this->redirect('@homepage');
     return sfView::NONE;
 }
Example #28
0
 public function saveCreate()
 {
     $data = Input::all();
     $rules = array('title' => 'required', 'body' => 'required');
     $validator = Validator::make($data, $rules);
     if ($validator->passes()) {
         $task = new Task();
         $task->title = Input::get('title');
         $task->body = Input::get('body');
         $task->save();
         return Redirect::action('TasksController@home');
     }
     return Redirect::action('TasksController@create');
 }
Example #29
0
 function test_deleteAll()
 {
     //Arrange
     $description = "Wash the dog";
     $description2 = "Water the lawn";
     $test_Task = new Task($description);
     $test_Task->save();
     $test_Task2 = new Task($description2);
     $test_Task2->save();
     //Act
     Task::deleteAll();
     //Assert
     $result = Task::getAll();
     $this->assertEquals([], $result);
 }
Example #30
0
 public static function createTaskWithOwnerAndRelatedAccount($name, $owner, $account)
 {
     $dueStamp = DateTimeUtil::convertTimestampToDbFormatDateTime(time() + 10000);
     $completedStamp = DateTimeUtil::convertTimestampToDbFormatDateTime(time() + 9000);
     $task = new Task();
     $task->name = $name;
     $task->owner = $owner;
     $task->dueDateTime = $dueStamp;
     $task->completedDateTime = $completedStamp;
     $task->description = 'my test description';
     $task->activityItems->add($account);
     $saved = $task->save();
     assert('$saved');
     return $task;
 }