Example #1
0
 /**
  * @testdox A JobList has a list of attached Jobs.
  */
 public function jobs()
 {
     $type = new \App\Model\JobType();
     $type->save();
     $jobList = new JobList();
     $jobList->type_id = $type->id;
     $jobList->save();
     // One incomplete job.
     $job = new Job();
     $job->job_list_id = $jobList->id;
     $job->save();
     $this->assertEquals(1, $jobList->jobs->count());
     $this->assertEquals(0, $jobList->percentComplete());
     $this->assertEquals(100, $jobList->percentIncomplete());
     // Two incomplete jobs.
     $job2 = new Job();
     $job2->job_list_id = $jobList->id;
     $job2->save();
     $jobList->load('jobs');
     $this->assertEquals(2, $jobList->jobs->count());
     $this->assertEquals(0, $jobList->percentComplete());
     $this->assertEquals(100, $jobList->percentIncomplete());
     // Complete one of them.
     $job->date_resolved = '2015-09-09';
     $job->save();
     $this->assertEquals(50, $jobList->percentIncomplete());
 }
Example #2
0
 /**
  * @testdox A Job can be marked as complete with no date or any other metadata supplied.
  * @test
  */
 public function manualCompletion()
 {
     $type = new \App\Model\JobType();
     $type->save();
     $jobList = new JobList();
     $jobList->type_id = $type->id;
     $jobList->save();
     // One incomplete job
     $job = new Job();
     $job->job_list_id = $jobList->id;
     $job->save();
     $this->assertEquals('Incomplete', $job->status());
     //$job->resolution
 }
 public function search(Request $request)
 {
     $searchTerm = $request->query('quick_s');
     $searchType = $request->query('quick_t');
     switch ($searchType) {
         case 'a':
             $asset = Asset::whereIdentifier($searchTerm)->first();
             if (isset($asset->id)) {
                 return redirect('assets/' . $asset->id);
             } else {
                 return redirect("assets?identifier={$searchTerm}");
             }
             break;
         case 'j':
             $job = Job::whereId($searchTerm)->first();
             if (isset($job->id)) {
                 return redirect('jobs/' . $job->id);
             } else {
                 return redirect("jobs?id={$searchTerm}");
             }
             break;
         case 'jl':
             $jobList = JobList::whereName($searchTerm)->first();
             if (isset($jobList->id)) {
                 return redirect('job-lists/' . $jobList->id);
             } else {
                 return redirect("job-lists?name={$searchTerm}");
             }
             break;
         default:
             $this->view->quick_t = $searchType;
             $this->view->quick_s = $searchTerm;
             return $this->view;
     }
 }
 public function home()
 {
     $this->view->title = $this->view->site_name;
     $this->view->asset_count = Asset::count();
     $this->view->user_count = User::count();
     $this->view->crew_count = Crew::count();
     $this->view->job_list_count = JobList::count();
     $this->view->job_count = Job::count();
     $this->view->tag_count = Tag::count();
     return $this->view;
 }
 public function view(Request $request, $id)
 {
     $job = Job::find($id);
     if ($job === null) {
         abort(404);
     }
     $this->view->breadcrumbs = ['job-lists' => 'Job Lists', 'job-lists/' . $job->job_list_id => $job->jobList->name, 'jobs/' => 'Job #' . $job->id];
     $this->view->title = 'Job #' . $job->id;
     $this->view->job = $job;
     $this->view->quick_t = 'j';
     $this->view->quick_s = $job->id;
     return $this->view;
 }
 public function saveNew(Request $request)
 {
     DB::beginTransaction();
     $jobList = new JobList();
     $jobList->name = $request->input('name');
     $jobList->type_id = $request->input('type_id');
     $jobList->start_date = $request->input('start_date');
     $jobList->due_date = $request->input('due_date');
     $jobList->crew_id = $request->input('crew_id');
     $jobList->comments = $request->input('comments');
     $jobList->save();
     $jobList->addTags($request->input('tags'));
     // Then save all assets.
     $assets = $this->getAssets($request);
     foreach ($assets as $asset) {
         $job = new Job();
         $job->job_list_id = $jobList->id;
         $job->asset_id = $asset->id;
         $job->date_added = date('Y-m-d');
         $job->save();
     }
     DB::commit();
     return redirect('job-lists/' . $jobList->id);
 }