Example #1
0
 public function execute()
 {
     $expenses = $this->expenseService->getExpenses(array('status=' => Expense::PENDING));
     $approvers = $this->userService->getApprovers();
     if (count($approvers)) {
         // Notify of the application
         $msg = new TemplatedMessage('pending-expenses.php', array('expenses' => $expenses));
         $this->notificationService->notifyUser('Pending Expenses', $approvers, $msg);
     }
 }
Example #2
0
 public function domultipleAction()
 {
     $selected = $this->_getParam('selected');
     $ids = split(',', $selected);
     $status = mb_strtolower($this->_getParam('expenseaction'));
     $user = $this->_getParam('user');
     $client = $this->_getParam('clientid');
     $status = $status == 'approve' ? Expense::APPROVED : Expense::DENIED;
     foreach ($ids as $id) {
         $expense = $this->byId($id);
         if ($expense != null) {
             $this->expenseService->setExpenseStatus($expense, $status);
         }
     }
     if ($user) {
         $this->redirect('expense', 'listforuser', array('username' => $user));
     } else {
         $this->redirect('client', 'view', array('id' => $client, '#expenses'));
     }
 }
Example #3
0
 /**
  * View the expenses for a given user / client
  */
 public function viewAction()
 {
     $view = new CompositeView();
     $view->addScriptPath('extensions/expenses/views');
     $report = $this->byId(null, 'ExpenseReport');
     $client = null;
     $user = null;
     $expenses = array();
     // we either have a fixed report, or we have a dynamic one
     if ($report) {
         if (mb_strlen($report->username)) {
             $expenses = $this->expenseService->getExpenses(array('userreportid=' => $report->id));
             $user = $this->userService->getUserByField('username', $report->username);
         } else {
             $expenses = $this->expenseService->getExpenses(array('expensereportid=' => $report->id));
             $client = $this->clientService->getClient($report->clientid);
         }
         $view->start = $report->from;
         $view->end = $report->to;
     } else {
         $client = $this->clientService->getClient($this->_getParam('clientid'));
         $user = $this->userService->getUserByField('username', $this->_getParam('username'));
         $view->user = $user;
         $start = $this->_getParam('start', $this->_getParam('start', $this->calculateDefaultStartDate()));
         $end = $this->_getParam('end', $this->_getParam('end', $this->calculateDefaultEndDate()));
         $expenses = $this->expenseService->getDynamicExpenseReport($start, $end, $user, $client);
         $view->start = $start;
         $view->end = $end;
     }
     $view->expenses = $expenses;
     $view->client = $client;
     $view->user = $user;
     $view->report = $report;
     $view->mode = $this->_getParam('pdf') ? 'pdf' : 'html';
     $content = $view->render('expense/view.php');
     if ($this->_getParam('pdf')) {
         ini_set('memory_limit', '32M');
         include_once "dompdf/dompdf_config.inc.php";
         include_once "dompdf/include/dompdf.cls.php";
         include_once "dompdf/include/frame_tree.cls.php";
         include_once "dompdf/include/stylesheet.cls.php";
         include_once "dompdf/include/frame.cls.php";
         include_once "dompdf/include/style.cls.php";
         include_once "dompdf/include/attribute_translator.cls.php";
         include_once "dompdf/include/frame_factory.cls.php";
         include_once "dompdf/include/frame_decorator.cls.php";
         include_once "dompdf/include/positioner.cls.php";
         include_once "dompdf/include/block_positioner.cls.php";
         include_once "dompdf/include/block_frame_decorator.cls.php";
         include_once "dompdf/include/frame_reflower.cls.php";
         include_once "dompdf/include/block_frame_reflower.cls.php";
         include_once "dompdf/include/frame_reflower.cls.php";
         include_once "dompdf/include/text_frame_reflower.cls.php";
         include_once "dompdf/include/canvas_factory.cls.php";
         include_once "dompdf/include/canvas.cls.php";
         include_once "dompdf/include/abstract_renderer.cls.php";
         include_once "dompdf/include/renderer.cls.php";
         include_once "dompdf/include/cpdf_adapter.cls.php";
         include_once "dompdf/include/font_metrics.cls.php";
         include_once "dompdf/include/block_renderer.cls.php";
         include_once "dompdf/include/text_renderer.cls.php";
         include_once "dompdf/include/image_cache.cls.php";
         include_once "dompdf/include/text_frame_decorator.cls.php";
         include_once "dompdf/include/inline_positioner.cls.php";
         include_once "dompdf/include/page_frame_reflower.cls.php";
         include_once "dompdf/include/page_frame_decorator.cls.php";
         include_once "dompdf/include/table_frame_decorator.cls.php";
         include_once "dompdf/include/cellmap.cls.php";
         include_once "dompdf/include/table_frame_reflower.cls.php";
         include_once "dompdf/include/table_row_frame_decorator.cls.php";
         include_once "dompdf/include/null_positioner.cls.php";
         include_once "dompdf/include/table_row_frame_reflower.cls.php";
         include_once "dompdf/include/table_cell_frame_decorator.cls.php";
         include_once "dompdf/include/table_cell_positioner.cls.php";
         include_once "dompdf/include/table_cell_frame_reflower.cls.php";
         include_once "dompdf/include/table_row_group_frame_decorator.cls.php";
         include_once "dompdf/include/table_row_group_frame_reflower.cls.php";
         include_once "dompdf/include/table_cell_renderer.cls.php";
         include_once "dompdf/include/inline_frame_decorator.cls.php";
         include_once "dompdf/include/inline_frame_reflower.cls.php";
         include_once "dompdf/include/image_frame_decorator.cls.php";
         include_once "dompdf/include/image_frame_reflower.cls.php";
         include_once "dompdf/include/inline_renderer.cls.php";
         include_once "dompdf/include/image_renderer.cls.php";
         include_once "dompdf/include/dompdf_exception.cls.php";
         $dompdf = new DOMPDF();
         // $dompdf->set_paper('letter', 'landscape');
         $dompdf->load_html($content);
         $dompdf->render();
         $name = "expenses-" . date('Y-m-d', strtotime($view->start)) . '-to-' . date('Y-m-d', strtotime($view->end)) . '.pdf';
         $dompdf->stream($name);
     } else {
         echo $content;
     }
 }