public function viewinvoiceAction()
 {
     $this->getResponse()->setHeader('Content-type', 'text/plain');
     $invoice = $this->byId();
     $timesheet = $this->projectService->getTimesheet($invoice->timesheetid);
     if (!$timesheet) {
         throw new Exception("Must have a timesheet to view invoice");
     }
     $project = $this->projectService->getProject((int) $invoice->projectid);
     $this->view->client = $this->clientService->getClient($project->clientid);
     $this->view->invoice = $invoice;
     $timesheet->to = date('Y-m-d 23:59:59', strtotime($timesheet->to));
     // $this->view->tasks = $this->projectService->getTasks(array("projectid=" => $project->id));
     $this->view->records = $this->projectService->getSummaryTimesheet(null, null, $project->id, null, $timesheet->id, $timesheet->from, $timesheet->to);
     $this->view->project = $project;
     $this->renderRawView('invoice/view.php');
 }