public function create()
 {
     $response = array('success' => false);
     if (Request::ajax()) {
         $postData = Input::all();
         $predictionId = $postData['predictionId'];
         $expenseValue = $postData['value'];
         $rules = array('predictionId' => array('required', 'not_in:0', 'exists:predictions,id'), 'value' => array('required', 'numeric', 'min:0'));
         $messages = array('predictionId.required' => 'Please select a category.', 'predictionId.not_in' => 'Please select a category.', 'predictionId.exists' => 'An error occured. Please try later.', 'value.required' => 'Please enter expense value.', 'value.numeric' => 'Expense must be a numeric value. Ex: 90, 3.42', 'value.min' => 'Value must be a positive number.');
         $validator = Validator::make($postData, $rules, $messages);
         if ($validator->fails()) {
             $messages = $validator->messages();
             $response['predictionMsg'] = $messages->first('predictionId');
             $response['valueMsg'] = $messages->first('value');
             return Response::json($response);
         }
         $expense = new Expense();
         $expense->prediction_id = $predictionId;
         $expense->value = $expenseValue;
         $expense->save();
         $response['expenseId'] = $expense->id;
         $response['success'] = true;
         Event::fire('expense.create.success', array($expense));
     }
     return Response::json($response);
 }
Пример #2
0
 /**
  * Display all expenses from current tablet
  * for current user
  * 
  * @return View
  */
 public function all()
 {
     $userTablet = $this->_getCurrentTablet();
     $expense = new Expense();
     $expenses = $expense->getLastExpenses($userTablet->id);
     return View::make('expense/all', array('expenses' => $expenses, 'tablet' => $userTablet));
 }
Пример #3
0
 /**
  * Index action. Render dashboard with tablet
  * @return string
  */
 public function index()
 {
     $userTablet = $this->_getCurrentTablet();
     if ($userTablet) {
         $predictionsByValue = $userTablet->predictions()->orderBy('value', 'desc')->get();
         $predictionsByName = $userTablet->predictions()->orderBy('name', 'asc')->get();
         $expense = new Expense();
         $lastExpenses = $expense->getLastExpenses($userTablet->id, 5);
         return View::make('dashboard/index', array('tablet' => $userTablet, 'predictions' => $predictionsByValue, 'lastExpenses' => $lastExpenses))->nest('predictionModal', 'dashboard.modal.prediction')->nest('expenseModal', 'dashboard.modal.expense', array('predictions' => $predictionsByName))->nest('incomeModal', 'dashboard.modal.income')->nest('economyModal', 'dashboard.modal.economy')->nest('closeTabletModal', 'dashboard.modal.closetablet');
     }
     $tabletsSoFar = count($this->_getCurrentUser()->tablets()->getResults());
     return View::make('dashboard/info', array('tabletsSoFar' => $tabletsSoFar));
 }
Пример #4
0
 public function run()
 {
     $faker = Faker::create();
     foreach (range(1, 10) as $index) {
         Expense::create([]);
     }
 }
Пример #5
0
 public function expenses()
 {
     $expenses = Expense::all();
     $organization = Organization::find(1);
     $pdf = PDF::loadView('erpreports.expensesReport', compact('expenses', 'organization'))->setPaper('a4')->setOrientation('potrait');
     return $pdf->stream('Expense List.pdf');
 }
Пример #6
0
 public function home()
 {
     $total = $this->User->query("SELECT SUM(amount) as total FROM expenses WHERE house_id='" . $this->Session->read("Auth.User.House") . "' AND user_id='" . $this->Session->read("Auth.User.id") . "' AND active=1");
     App::import('Model', 'Expense');
     $mExpense = new Expense();
     $expenses_id = $mExpense->query("SELECT expense_id FROM expenses_users WHERE user_id='" . $this->Session->read("Auth.User.id") . "'");
     $expenses_id = Set::classicExtract($expenses_id, '{n}.expenses_users.expense_id');
     $yourExpenses = $mExpense->find('all', array('conditions' => array('Expense.id' => $expenses_id, 'Expense.house_id' => $this->Session->read('Auth.User.House'), 'Expense.active' => 1)));
     $myTotal = 0.0;
     foreach ($yourExpenses as $expense) {
         $myTotal += $expense['Expense']['amount'] / count($expense['Perro']);
     }
     $totalP = $this->User->query("SELECT SUM(amount) as total FROM loans WHERE lender_id='" . $this->Session->read("Auth.User.id") . "' AND active=1");
     $total2P = $this->User->query("SELECT SUM(amount) as total FROM loans WHERE borrower_id='" . $this->Session->read("Auth.User.id") . "' AND active=1");
     $totalPaymentsP = $this->User->query("SELECT SUM(payments.amount) as total FROM payments, loans WHERE loans.id=payments.loan_id AND loans.lender_id='" . $this->Session->read("Auth.User.id") . "' AND loans.active=1 AND payments.active=1");
     $totalPayments2P = $this->User->query("SELECT SUM(payments.amount) as total FROM payments, loans WHERE loans.id=payments.loan_id AND loans.borrower_id='" . $this->Session->read("Auth.User.id") . "' AND loans.active=1 AND payments.active=1");
     $this->set(array('total' => $total[0][0]['total'], 'myTotal' => $myTotal, 'totalP' => $totalP['0']['0']['total'], 'total2P' => $total2P['0']['0']['total'], 'totalPaymentsP' => $totalPaymentsP['0']['0']['total'], 'totalPayments2P' => $totalPayments2P['0']['0']['total']));
 }
Пример #7
0
 /**
  * Displays a particular model.
  * @param integer $id the ID of the model to be displayed
  */
 public function actionView($id)
 {
     $viewModel = Expense::model()->findAll('employee_id = :id', array(':id' => $id));
     if (isset($_GET['asModal'])) {
         $this->renderPartial('view', array('model' => $this->loadModel($id), 'viewModel' => $viewModel));
     } else {
         $this->render('view', array('model' => $this->loadModel($id), 'viewModel' => $viewModel));
     }
 }
Пример #8
0
 public function destroy($id)
 {
     $targetExpense = Expense::find($id);
     if ($targetExpense) {
         $targetExpense->delete();
         return $this->index();
     } else {
         return $this->index();
     }
 }
 public function index()
 {
     if (Auth::check()) {
         $user_id = Auth::user()->id;
         $colonia = Session::get("colonia");
         //obtener el rol que desempeña en la colonia
         $rol_id = AssigmentRole::where('user_id', '=', $user_id)->where('colony_id', '=', $colonia)->pluck('role_id');
         Session::put("rol_usuario", $rol_id);
         $permisos = array();
         $permisos = DB::table('permission_role')->where("role_id", "=", $rol_id)->select("permission_role.id", "permission_role.state")->orderBy("permission_role.id")->get();
         Session::put("dato", $permisos);
         $urbanism = Urbanism::where('colony_id', '=', $colonia)->first();
         $urbanismo = $urbanism->id;
         $urb_name = $urbanism->Colony->name;
         $breadcrumbs = Neighbors::where('user_id', '=', $user_id)->first();
         $breadcrumbs_data = $breadcrumbs->name . " " . $breadcrumbs->last_name . " [ " . $urb_name . " ]";
         $Total = DB::table('neighbors_properties')->select(DB::raw('Count(neighbors_properties.id) as total'))->where('neighbors_properties.urbanism_id', '=', $urbanismo)->get();
         $Total = $Total[0]->total;
         $PorAceptar = DB::table('invited_neighbors')->select(DB::raw('count(invited_neighbors.id) as porAceptar'))->where('invited_neighbors.confirmed', '=', 0)->where('invited_neighbors.urbanism_id', '=', $urbanismo)->get();
         $PorAceptar = $PorAceptar[0]->porAceptar;
         $Aceptadas = DB::table('invited_neighbors')->select(DB::raw('count(invited_neighbors.id) as Aceptadas'))->where('invited_neighbors.confirmed', '=', 1)->where('invited_neighbors.urbanism_id', '=', $urbanismo)->get();
         $Aceptadas = $Aceptadas[0]->Aceptadas;
         $ano = date("Y");
         $monthly_all = MonthlyFee::where('monthly_fee.urbanism_id', '=', $urbanismo)->where(DB::raw('DATE_FORMAT(monthly_fee.since,\'%Y\')'), '=', $ano)->get();
         $months = array("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Decem");
         $cuotas = array();
         foreach ($monthly_all as $cuota_mensual) {
             $ini = (int) date("m", strtotime($cuota_mensual->since));
             $fin = (int) date("m", strtotime($cuota_mensual->until));
             if ($cuota_mensual->until == NULL) {
                 $fin = (int) date("m");
             }
             for ($i = $ini; $i <= $fin; $i++) {
                 $cuotas[$months[$i - 1]] = $cuota_mensual->amount;
             }
         }
         $j = (int) date("m");
         $monthly_fee = $cuotas[$months[$j - 1]];
         $mes = date("M");
         $pagoMensual = PaymentStates::join('neighbors_properties', 'payment_states.neighbor_property_id', '=', 'neighbors_properties.id')->where($mes, '>=', $monthly_fee)->where('neighbors_properties.urbanism_id', '=', $urbanismo)->select(DB::raw('count(neighbors_properties.id) as cant'))->get();
         if ($pagoMensual) {
             $pagoMensual = $pagoMensual[0]->cant;
         } else {
             $pagoMensual = 0;
         }
         $Egresos = Expense::join('sub_accounts', 'expenses.sub_account_id', '=', 'sub_accounts.id')->where('expenses.urbanism_id', '=', $urbanismo)->select(DB::raw('sum(expenses.amount) as amount'), 'sub_accounts.description')->groupBy('sub_accounts.description')->get();
         $Ingresos = Payment::join('sub_accounts', 'payments.sub_account_id', '=', 'sub_accounts.id')->join('neighbors_properties', 'payments.neighbor_property_id', '=', 'neighbors_properties.id')->where('neighbors_properties.urbanism_id', '=', $urbanismo)->select(DB::raw('sum(payments.amount) as amount'), 'sub_accounts.description')->groupBy('sub_accounts.description')->get();
         $EgresosMensual = Expense::where('expenses.urbanism_id', '=', $urbanismo)->select(DB::raw('sum(expenses.amount) as amount'), DB::raw('DATE_FORMAT(expenses.created_at,\'%m\') as mes'))->groupBy(DB::raw('Month(expenses.created_at)'))->get();
         $IngresosMensual = Payment::join('neighbors_properties', 'payments.neighbor_property_id', '=', 'neighbors_properties.id')->where('neighbors_properties.urbanism_id', '=', $urbanismo)->select(DB::raw('sum(payments.amount) as amount'), DB::raw('DATE_FORMAT(payments.created_at,\'%m\') as mes'))->groupBy(DB::raw('Month(payments.created_at)'))->get();
         return View::make('dashboard.home', ['Total' => $Total, 'PorAceptar' => $PorAceptar, 'Aceptadas' => $Aceptadas, 'monthly_fee' => $monthly_fee, 'pagoMensual' => $pagoMensual, 'Egresos' => $Egresos, 'Ingresos' => $Ingresos, 'EgresosMensual' => $EgresosMensual, 'IngresosMensual' => $IngresosMensual, 'Nombre' => $breadcrumbs_data]);
     } else {
         return Redirect::action('UsersController@login');
     }
 }
Пример #10
0
 public function get_report()
 {
     $account_id = Input::get('account_id');
     $periode = Input::get('periode', 'weekly');
     $date = Input::get('date');
     $end_date = Input::get('end_date');
     $today = strtotime(date('Y-m-d'));
     if (is_null($date) || empty($date)) {
         $last_week = $today - 3600 * 24 * 7;
         $date = date('Y-m-d', $last_week);
     }
     if ('daily' == $periode) {
         $range = array('start' => $date, 'end' => $date);
     } else {
         if ('weekly' == $periode) {
             $range = AppHelper::range_week($date);
         } else {
             if ('monthly' == $periode) {
                 $range = AppHelper::range_month($date);
             } else {
                 if ('custom' == $periode) {
                     $range = array('start' => $date, 'end' => $end_date);
                 }
             }
         }
     }
     $account = Account::find($account_id);
     $donations = Donation::where_between('donation_date', $range['start'], $range['end'])->where_account_id($account_id)->order_by('donation_date', 'asc')->get();
     $expenses = Expense::where_between('expense_date', $range['start'], $range['end'])->where_account_id($account_id)->order_by('expense_date', 'asc')->get();
     $transactions = Transaction::where_between('date', $range['start'], $range['end'])->where_account_id($account_id)->order_by('date', 'asc')->get();
     if (isset($donations[0]) || isset($expenses[0])) {
         $last_transaction = Transaction::earlier_than($transactions[0])->where_account_id($account_id)->first();
     } else {
         $last_transaction = Transaction::earlier_than_date($range['start'])->where_account_id($account_id)->first();
     }
     // var_dump($last_transaction); die;
     if (is_null($last_transaction)) {
         $last_transaction_balance = 0;
     } else {
         $last_transaction_balance = $last_transaction->balance->balance_amount;
     }
     $end_transaction = Transaction::where_between('date', $range['start'], $range['end'])->where_account_id($account_id)->order_by('date', 'desc')->order_by('id', 'desc')->first();
     if (is_null($end_transaction)) {
         $end_balance = 0;
     } else {
         $end_balance = $end_transaction->balance->balance_amount;
     }
     $data = array('range' => $range, 'account' => $account, 'donations' => $donations, 'expenses' => $expenses, 'last_transaction_balance' => $last_transaction_balance, 'end_balance' => $end_balance, 'periode' => $periode);
     return View::make('account.report', $data);
     // echo var_dump($end_balance);
 }
Пример #11
0
 public function confirmSaveRequest()
 {
     $flash = Flash::Instance();
     if (!$this->checkParams($this->modeltype)) {
         sendBack();
     }
     $errors = array();
     $this->_data[$this->modeltype]['authorised_date'] = date(DATE_FORMAT);
     if (!Expense::updateStatus($this->_data[$this->modeltype], $errors)) {
         $flash->addErrors($errors);
     } else {
         $flash->addMessage('Expenses updated OK');
     }
     sendTo($_SESSION['refererPage']['controller'], $_SESSION['refererPage']['action'], $_SESSION['refererPage']['modules'], isset($_SESSION['refererPage']['other']) ? $_SESSION['refererPage']['other'] : null);
 }
Пример #12
0
 public function checkBalance()
 {
     $start = Input::get('startDate');
     $end = Input::get('endDate');
     $startDate = date('Y-m-d', strtotime($start));
     $endDate = date('Y-m-d', strtotime($end));
     $totalIncome = Invoice::getTotalIncomeFromTo($startDate, $endDate);
     $totalIncomeVat = $totalIncome * 0.2;
     $totalExpenses = Expense::getTotalExpensesFromTo($startDate, $endDate);
     $totalExpensesVat = $totalExpenses * 0.2;
     $totalWages = Employee::getTotalSalariesSum($startDate, $endDate);
     $totalBalance = $totalIncome - ($totalExpenses + $totalWages);
     $totalBalance = number_format((double) $totalBalance, 2, '.', '');
     return View::make('balance.index')->with(['totalExpenses' => $totalExpenses, 'totalIncome' => $totalIncome, 'totalBalance' => $totalBalance, 'totalIncomeVat' => $totalIncomeVat, 'totalExpensesVat' => $totalExpensesVat, 'startDate' => $start, 'endDate' => $end, 'totalWages' => $totalWages]);
 }
Пример #13
0
 /**
  * create
  */
 public function create()
 {
     $res = new Response();
     $rec = Expense::create($this->params);
     echo "{\"items\": []}";
     return;
     $rec = Expense::create($this->params);
     if ($rec) {
         $res->success = true;
         $res->message = "Created new User" . $rec->id;
         $res->data = $rec->to_hash();
     } else {
         $res->message = "Failed to create User";
     }
     return $res->to_json();
 }
 public function insertEntity($aProperties)
 {
     $oExpense = new Expense();
     $oExpense->setExpenseAmount($aProperties['ExpenseAmount']);
     $oExpense->setExpenseCategory($aProperties['ExpenseCategory']);
     $oExpense->setExpenseDate($aProperties['ExpenseDate']);
     $oExpense->setExpenseName($aProperties['ExpenseName']);
     $oExpense->setExpenseSubCategory($aProperties['ExpenseSubCategory']);
     $oExpense->setIsExpensePrivate($aProperties['IsExpensePrivate']);
     $oRecord = new Record($oExpense);
     $bSuccess = $oRecord->createRecord();
     if ($bSuccess == TRUE) {
         //do something.
     } else {
         //do something else.
     }
 }
Пример #15
0
 public function Prod($depId, $dates)
 {
     $dishProd = Expense::model()->with('order.dish.dishStruct.Struct')->findAll('date(order_date) = :dates AND dish.department_id = :department_id', array(':dates' => $dates, ':department_id' => $depId));
     if (!empty($dishProd)) {
         foreach ($dishProd as $value) {
             foreach ($value->getRelated('order') as $val) {
                 foreach ($val->getRelated('dish')->getRelated('dishStruct') as $vals) {
                     $outProduct[$vals->prod_id] = $outProduct[$vals->prod_id] + $vals->amount / $val->getRelated('dish')->count * $val->count;
                 }
             }
         }
     }
     $Prod = Expense::model()->with('order.products')->findAll('date(order_date) = :dates AND products.department_id = :department_id', array(':dates' => $dates, ':department_id' => $depId));
     if (!empty($Prod)) {
         foreach ($Prod as $value) {
             foreach ($value->getRelated('order') as $val) {
                 $outProduct[$val->just_id] = $outProduct[$val->just_id] + $val->count;
             }
         }
     }
     return $outProduct;
 }
Пример #16
0
 public function view()
 {
     if (!$this->loadData()) {
         $this->_uses[$this->modeltype]->authorisationPolicy();
         if (!$this->loadData()) {
             $this->dataError($this->_no_access_msg);
             sendBack();
         }
         // User can only view other peoples data
         $restrict_inserts = $readonly = TRUE;
     }
     $employee = $this->_uses[$this->modeltype];
     $idfield = $employee->idField;
     $idvalue = $employee->{$idfield};
     // Do not allow the user to update their own details
     if ($idvalue == $employee->user_person_id) {
         $restrict_inserts = TRUE;
     }
     /* Get the details from the Person table*/
     $this->view->set('person', $employee->person);
     $this->view->set('holidays', $employee->getHolidayTotals());
     $sidebar = new SidebarController($this->view);
     $sidebarlist = array();
     $sidebarlist['view_all'] = array('tag' => 'view_all', 'link' => array('modules' => $this->_modules, 'controller' => $this->name, 'action' => 'index'));
     $sidebarlist['new_employee'] = array('tag' => 'new_employee', 'link' => array('modules' => $this->_modules, 'controller' => $this->name, 'action' => 'new'));
     $sidebar->addList('actions', $sidebarlist);
     $sidebarlist = array();
     $sidebarlist[$employee->employee] = array('tag' => $employee->employee, 'link' => array('modules' => $this->_modules, 'controller' => $this->name, 'action' => 'view', $idfield => $idvalue));
     if (!$readonly) {
         $sidebarlist['edit_employee'] = array('tag' => 'Edit Employee Details', 'link' => array('modules' => $this->_modules, 'controller' => $this->name, 'action' => 'edit', $idfield => $idvalue));
         $sidebarlist['edit_personal'] = array('tag' => 'Edit Personal Details', 'link' => array('modules' => $this->_modules, 'controller' => $this->name, 'action' => 'edit_personal', $idfield => $idvalue));
         $sidebarlist['edit_work'] = array('tag' => 'Edit Work Contact Details', 'link' => array('modules' => $this->_modules, 'controller' => $this->name, 'action' => 'edit_work', $idfield => $idvalue));
         if (is_null($employee->finished_date)) {
             $sidebarlist['make_leaver'] = array('tag' => 'Leaver', 'link' => array('modules' => $this->_modules, 'controller' => $this->name, 'action' => 'leaver', $idfield => $idvalue));
         }
     }
     $sidebar->addList('currently_viewing', $sidebarlist);
     $sidebarlist = array();
     $sidebarlist['expenses'] = array('tag' => 'View Expenses', 'link' => array('modules' => $this->_modules, 'controller' => 'expenses', 'action' => 'viewemployee', 'employee_id' => $idvalue), 'new' => array('modules' => $this->_modules, 'controller' => 'expenses', 'action' => 'new', 'employee_id' => $idvalue));
     $sidebarlist['expenses_for_payment'] = array('tag' => 'Expenses Awaiting Authorisation', 'link' => array('modules' => $this->_modules, 'controller' => 'expenses', 'action' => 'viewemployee', 'employee_id' => $idvalue, 'status' => Expense::statusAwaitingAuthorisation()));
     $sidebarlist['make_payment'] = array('tag' => 'Make Payment', 'link' => array('modules' => $this->_modules, 'controller' => $this->name, 'action' => 'make_payment', 'employee_id' => $idvalue));
     $sidebarlist['allocate_expenses'] = array('tag' => 'Allocate Expenses to Payments', 'link' => array('modules' => $this->_modules, 'controller' => $this->name, 'action' => 'allocate', 'employee_id' => $idvalue));
     if ($restrict_inserts) {
         $sidebarlist['holidayentitlement'] = array('tag' => 'Holiday Entitlement', 'link' => array('modules' => $this->_modules, 'controller' => 'holidayentitlements', 'action' => 'viewemployee', 'employee_id' => $idvalue));
     } else {
         $sidebarlist['holidayentitlement'] = array('tag' => 'Holiday Entitlement', 'link' => array('modules' => $this->_modules, 'controller' => 'holidayentitlements', 'action' => 'viewemployee', 'employee_id' => $idvalue), 'new' => array('modules' => $this->_modules, 'controller' => 'holidayentitlements', 'action' => 'new', 'employee_id' => $idvalue));
     }
     $sidebarlist['holidayrequest'] = array('tag' => 'Holiday Request', 'link' => array('modules' => $this->_modules, 'controller' => $this->name, 'action' => 'viewholidayrequests', 'employee_id' => $employee->id), 'new' => array('modules' => $this->_modules, 'controller' => 'holidayrequests', 'action' => 'new', 'employee_id' => $idvalue));
     $sidebarlist['trainingplan'] = array('tag' => 'Training Plan', 'link' => array('modules' => $this->_modules, 'controller' => 'employeetrainingplans', 'action' => 'viewemployeetrainingplans', 'employee_id' => $idvalue), 'new' => array('modules' => $this->_modules, 'controller' => 'employeetrainingplans', 'action' => 'new', 'employee_id' => $idvalue));
     if ($restrict_inserts) {
         $sidebarlist['employeerates'] = array('tag' => 'Pay Rates', 'link' => array('modules' => $this->_modules, 'controller' => 'employeerates', 'action' => 'view_employee', 'employee_id' => $idvalue));
     } else {
         $sidebarlist['employeerates'] = array('tag' => 'Pay Rates', 'link' => array('modules' => $this->_modules, 'controller' => 'employeerates', 'action' => 'view_employee', 'employee_id' => $idvalue), 'new' => array('modules' => $this->_modules, 'controller' => 'employeerates', 'action' => 'new', 'employee_id' => $idvalue));
     }
     if ($restrict_inserts) {
         $sidebarlist['employeecontractdetails'] = array('tag' => 'Contract Details', 'link' => array('modules' => $this->_modules, 'controller' => 'employeecontractdetails', 'action' => 'viewemployee', 'employee_id' => $idvalue));
     } else {
         $sidebarlist['employeecontractdetails'] = array('tag' => 'Contract Details', 'link' => array('modules' => $this->_modules, 'controller' => 'employeecontractdetails', 'action' => 'viewemployee', 'employee_id' => $idvalue), 'new' => array('modules' => $this->_modules, 'controller' => 'employeecontractdetails', 'action' => 'new', 'employee_id' => $idvalue));
     }
     $week_dates = $this->getWeekDates();
     $sidebarlist['hours'] = array('tag' => 'Timesheet Hours', 'link' => array('modules' => $this->_modules, 'controller' => $this->name, 'action' => 'view_hours_summary', 'person_id' => $employee->person_id, 'start_date' => $week_dates['week_start_date'], 'end_date' => $week_dates['week_end_date']), 'new' => array('modules' => $this->_modules, 'controller' => 'hours', 'action' => 'new', 'person_id' => $employee->person_id, 'start_date' => $week_dates['week_start_date'], 'end_date' => $week_dates['week_end_date']));
     if ($restrict_inserts) {
         $sidebarlist['payhistory'] = array('tag' => 'Pay History', 'link' => array('modules' => $this->_modules, 'controller' => 'employeepayhistorys', 'action' => 'view_employee', 'employee_id' => $idvalue));
     } else {
         $sidebarlist['payhistory'] = array('tag' => 'Pay History', 'link' => array('modules' => $this->_modules, 'controller' => 'employeepayhistorys', 'action' => 'view_employee', 'employee_id' => $idvalue), 'new' => array('modules' => $this->_modules, 'controller' => 'employeepayhistorys', 'action' => 'new', 'employee_id' => $idvalue));
     }
     $sidebar->addList('related_items', $sidebarlist);
     $authoriser = DataObjectFactory::Factory('HRAuthoriser');
     foreach ($authoriser->getTypesForEmployee($idvalue) as $authorisation_type) {
         $array[] = $authoriser->getEnum('authorisation_type', $authorisation_type);
     }
     if (!empty($array)) {
         $this->view->set('can_authorise', implode(',', $array));
     }
     $this->view->set('expense_authorisers', implode(',', $this->_templateobject->expense_model()->getAuthorisersByName($idvalue)));
     $this->view->set('holiday_authorisers', implode(',', $this->_templateobject->holiday_model()->getAuthorisersByName($idvalue)));
     $this->view->register('sidebar', $sidebar);
     $this->view->set('sidebar', $sidebar);
 }
Пример #17
0
 function delete($id = FALSE)
 {
     $expense = Expense::find($id);
     $expense->delete();
     $this->content_view = 'expenses/all';
     if (!$expense) {
         $this->session->set_flashdata('message', 'error:' . $this->lang->line('messages_delete_expense_error'));
     } else {
         $this->session->set_flashdata('message', 'success:' . $this->lang->line('messages_delete_expense_success'));
     }
     redirect('expenses');
 }
Пример #18
0
/**
 * Generate expense fields and populate it with existing data
 */
function getExpenseEntries()
{
    global $expenseTypes;
    global $expenses;
    global $expenseEntries;
    global $inputErrors;
    $result = "";
    $expenseIndex = 0;
    $numEntries = $inputErrors ? count($expenseEntries) : count($expenses);
    do {
        $result .= '<div class="expenseEntry"> ';
        $result .= '<label for="expenseDesc' . $expenseIndex . '" class="altDescLabel">Description: </label>';
        $result .= '<input type="text" id="expenseDesc' . $expenseIndex . '" name="expenseDesc' . $expenseIndex . '" class="desc';
        if ($inputErrors && isset($expenseEntries[$expenseIndex])) {
            if ($expenseEntries[$expenseIndex]["descError"]) {
                $result .= ' descError';
            }
        }
        $result .= '" placeholder="Description" maxlength="' . Expense::MAX_DESC_LENGTH . '"';
        if ($inputErrors && isset($expenseEntries[$expenseIndex])) {
            $result .= ' value="';
            $result .= htmlentities($expenseEntries[$expenseIndex]["desc"]);
            $result .= '"';
        } else {
            if (isset($expenses[$expenseIndex])) {
                $result .= ' value="';
                $result .= htmlentities($expenses[$expenseIndex]->description);
                $result .= '"';
            }
        }
        $result .= '> ';
        $result .= '<label for="expenseType' . $expenseIndex . '" class="altTypeLabel">Category: </label>';
        $result .= '<select id="expenseType' . $expenseIndex . '" name="expenseType' . $expenseIndex . '" class="type';
        if ($inputErrors && isset($expenseEntries[$expenseIndex])) {
            if ($expenseEntries[$expenseIndex]["typeError"]) {
                $result .= ' typeError';
            }
        }
        $result .= '"> ';
        foreach ($expenseTypes as $expenseType) {
            $result .= '<option value="' . $expenseType->category . '"';
            if ($inputErrors && isset($expenseEntries[$expenseIndex])) {
                if ($expenseEntries[$expenseIndex]["type"] === $expenseType->category) {
                    $result .= "selected";
                }
            } else {
                if (isset($expenses[$expenseIndex])) {
                    if ($expenses[$expenseIndex]->typeID === $expenseType->id) {
                        $result .= "selected";
                    }
                }
            }
            $result .= '>';
            $result .= $expenseType->category;
            $result .= '</option> ';
        }
        $result .= '</select> ';
        $result .= '<label for="expenseAmount' . $expenseIndex . '" class="altAmountLabel">Amount: </label>';
        $result .= '<input type="text" maxlength="20" id="expenseAmount' . $expenseIndex . '" name="expenseAmount' . $expenseIndex . '" class="amount';
        if ($inputErrors && isset($expenseEntries[$expenseIndex])) {
            if ($expenseEntries[$expenseIndex]["amountError"]) {
                $result .= ' amountError';
            }
        }
        $result .= '" placeholder="Amount"';
        if ($inputErrors && isset($expenseEntries[$expenseIndex])) {
            $result .= ' value="';
            $result .= htmlentities($expenseEntries[$expenseIndex]["amount"]);
            $result .= '"';
        } else {
            if (isset($expenses[$expenseIndex])) {
                $result .= ' value="';
                $result .= htmlentities(Expense::formatDisplayAmount($expenses[$expenseIndex]->amount));
                $result .= '"';
            }
        }
        $result .= '> ';
        $result .= '<label class="removeLabel">Remove: </label>';
        $result .= '<button type="button" id="deleteExpenseButton' . $expenseIndex . '" name="deleteExpenseButton' . $expenseIndex . '" class="deleteButton" title="Delete"> ';
        $result .= '&#10006;';
        $result .= '</button> ';
        $result .= '<br> ';
        $result .= '</div> ';
        $expenseIndex++;
    } while ($expenseIndex < $numEntries);
    return $result;
}
Пример #19
0
 public function actionRefreshTable()
 {
     $dates = date('Y-m-d');
     $model = Expense::model()->with('employee')->findAll('date(order_date) = :dates', array(':dates' => $dates));
     $this->renderPartial('cook', array('model' => $model));
 }
Пример #20
0
 public function actionViewStorage()
 {
     $dates = date("Y-m-d");
     $outProduct = array();
     $depOut = array();
     $depIn = array();
     $outStuff = array();
     $prodModel = Products::model()->findAll();
     foreach ($prodModel as $value) {
         $outProduct[$value->product_id] = $outProduct[$value->product_id] + 0;
         $depOut[$value->product_id] = $depOut[$value->product_id] + 0;
     }
     $depId = $_POST['department_id'];
     $departMoveOut = DepFaktura::model()->with('realizedProd')->findAll('date(t.real_date) = :dates AND t.department_id = :depId AND t.fromDepId <> :fromDepId', array(':dates' => $dates, ':depId' => $depId, ':fromDepId' => 0));
     foreach ($departMoveOut as $key => $val) {
         foreach ($val->getRelated('realizedProd') as $value) {
             $depIn[$value->prod_id] = $depIn[$value->prod_id] + $value->count;
         }
     }
     $departMoveIn = DepFaktura::model()->with('realizedProd')->findAll('date(t.real_date) = :dates AND t.fromDepId = :depId', array(':dates' => $dates, ':depId' => $depId));
     foreach ($departMoveIn as $value) {
         foreach ($value->getRelated('realizedProd') as $val) {
             $depOut[$val->prod_id] = $depOut[$val->prod_id] + $val->count;
         }
     }
     $curProd = DepBalance::model()->with('products')->findAll('date(t.b_date) = :dates AND t.department_id = :department_id AND t.type = :type', array(':dates' => $dates, ':department_id' => $depId, ':type' => 1));
     $curStuff = DepBalance::model()->with('stuff')->findAll('date(t.b_date) = :dates AND t.department_id = :department_id AND t.type = :type', array(':dates' => $dates, ':department_id' => $depId, ':type' => 2));
     $dish = new Expense();
     $stuff = new Halfstaff();
     $outProduct = $dish->getDishProd($depId, $dates);
     $outDishStuff = $dish->getDishStuff($depId, $dates);
     $inProducts = array();
     $model = DepFaktura::model()->with('realizedProd')->findAll('date(t.real_date) = :dates AND t.department_id = :depId AND t.fromDepId = :fromDepId', array(':dates' => $dates, ':depId' => $depId, ':fromDepId' => 0));
     foreach ($model as $key => $val) {
         foreach ($val->getRelated('realizedProd') as $value) {
             $inProducts[$value->prod_id] = $inProducts[$value->prod_id] + $value->count;
         }
     }
     $instuff = array();
     $outStuffProd = array();
     $model2 = Inexpense::model()->with('inorder.stuffs.stuffStruct')->findAll('date(t.inexp_date) = :dates AND t.department_id = :depId AND stuffStruct.types = :types AND t.fromDepId = :fromDepId', array(':dates' => $dates, 'depId' => $depId, ':types' => 1, ':fromDepId' => 0));
     foreach ($model2 as $val) {
         foreach ($val->getRelated('inorder') as $value) {
             $instuff[$value->stuff_id] = $instuff[$value->stuff_id] + $value->count;
             foreach ($value->getRelated('stuffs')->getRelated('stuffStruct') as $values) {
                 $outStuffProd[$values->prod_id] = $outStuffProd[$values->prod_id] + $values->amount / $value->getRelated('stuffs')->count * $value->count;
             }
         }
     }
     $model3 = Inexpense::model()->with('inorder.stuffs.stuffStruct.podstuff.podstuffStruct.Struct')->findAll('date(t.inexp_date) = :dates AND t.department_id = :depId AND stuffStruct.types = :types AND t.fromDepId = :fromDepId', array(':dates' => $dates, 'depId' => $depId, ':types' => 2, ':fromDepId' => 0));
     foreach ($model3 as $val) {
         foreach ($val->getRelated('inorder') as $value) {
             $instuff[$value->stuff_id] = $instuff[$value->stuff_id] + $value->count;
             foreach ($value->getRelated('stuffs')->getRelated('stuffStruct') as $values) {
                 $outStuff[$values->prod_id] = $outStuff[$values->prod_id] + $values->amount / $value->getRelated('stuffs')->count * $value->count;
                 foreach ($values->getRelated('podstuff')->getRelated('podstuffStruct') as $vals) {
                     $outStuffProd[$values->prod_id] = $outStuffProd[$values->prod_id] + $vals->amount / $values->getRelated('podstuff')->count * $values->amount / $value->getRelated('stuffs')->count * $value->count;
                 }
             }
         }
     }
     $outStuff = $stuff->sumArray($outDishStuff, $outStuff);
     $inexpense = new Inexpense();
     $depStuffIn = $inexpense->getDepIn($depId, $dates);
     $depStuffOut = $inexpense->getDepOut($depId, $dates);
     $this->renderPartial('viewStorage', array('depOut' => $depOut, 'depIn' => $depIn, 'depStuffOut' => $depStuffOut, 'depStuffIn' => $depStuffIn, 'prodModel' => $prodModel, 'curProd' => $curProd, 'curStuff' => $curStuff, 'inProduct' => $inProducts, 'inStuff' => $instuff, 'outProduct' => $outProduct, 'outStuff' => $outStuff, 'outStuffProd' => $outStuffProd));
 }
Пример #21
0
<script type="text/javascript">
    var totalIncome = <?php 
echo htmlentities($totalIncome);
?>
;
    var totalExpenses = <?php 
echo htmlentities($totalExpenses);
?>
;
    var totalIncomeDisplayString = "<?php 
echo htmlentities(Income::formatDisplayAmount($totalIncome));
?>
";
    var totalExpensesDisplayString = "<?php 
echo htmlentities(Expense::formatDisplayAmount($totalExpenses));
?>
";
    var totalTitle = "Income/Expenses";
    var incomeTitle = "Income";
    var expensesTitle = "Expenses";

    var totalChartArray = [<?php 
echo '["Type", "Amount"], ["Income", totalIncome], ["Expenses", totalExpenses]';
?>
];
    var incomeChartArray = [["Category", "Amount"],
        <?php 
foreach ($incomeTypeAmounts as $index => $incomeTypeAmount) {
    echo "['" . htmlentities($incomeTypeAmount["type"]) . "', " . htmlentities($incomeTypeAmount["amount"]) . "]";
    if ($index !== count($incomeTypeAmounts) - 1) {
        echo ", ";
Пример #22
0
<style>
    .btn{
        padding: 0px 12px;
    }
</style>
<?php 
$count = 1;
$expense = new Expense();
$curPercent = 0;
$summaP = 0;
$summa = 0;
?>
<table class="table table-hover table-bordered" id="dataTable">
    <thead>
    <tr>
        <th></th>
        <th>Дата и время</th>
        <th>Оплаченная дата</th>
        <th>Ответственный за заказ</th>
        <th>Стол №</th>
        <th>Сумма</th>
        <th>Процент обслуживания</th>
        <th>Сумма счета</th>
        <th>Комментарий</th>
        <th></th>
    </tr>
    </thead>
    <tbody>
    <?php 
foreach ($model as $value) {
    $procent = new Percent();
Пример #23
0
<?php

$count = 1;
$expense = new Expense();
$curPercent = 0;
$summaP = 0;
$summa = 0;
?>
<table class="table table-hover table-bordered">
    <thead>
    <tr>
        <th></th>
        <th>Дата и время</th>
        <th>Ответственный за заказ</th>
        <th>Стол №</th>
	    <th>Сумма</th>
	    <th>Процент обслуживания</th>
        <th>Сумма счета</th>
        <th></th>
    </tr>
    </thead>
    <tbody>
    <?php 
foreach ($newModel as $value) {
    ?>
	    <?php 
    if ($value->getRelated('employee')->check_percent == 1) {
        $curPercent = $percent;
    } else {
        $curPercent = 0;
    }
Пример #24
0
 public function actionToday()
 {
     $dates = date('Y-m-d');
     $startProducts = array();
     $inProducts = array();
     $outProducts = array();
     $inOutProducts = array();
     $endProducts = array();
     $prodModel = Products::model()->findAll();
     //Приход
     $fakturaProd = Faktura::model()->with('realize.products')->findAll('date(realize_date) = :realize_date', array('realize_date' => $dates));
     foreach ($fakturaProd as $value) {
         foreach ($value->getRelated('realize') as $key => $val) {
             $inProducts[$val->getRelated('products')->product_id] = $inProducts[$val->getRelated('products')->product_id] + $val->count;
         }
     }
     //Расход
     $Depfaktura = DepFaktura::model()->with('realizedProd')->findAll('date(real_date) = :real_date', array(':real_date' => $dates));
     foreach ($Depfaktura as $value) {
         foreach ($value->getRelated('realizedProd') as $val) {
             $outProducts[$val->prod_id] = $outProducts[$val->prod_id] + $val->count;
         }
     }
     $expense = Expense::model()->with('order.products')->findAll('date(order_date) = :dates AND t.kind = :kind', array(':kind' => 1, ':dates' => $dates));
     foreach ($expense as $value) {
         foreach ($value->getRelated('order') as $val) {
             $inOutProducts[$val->just_id] = $inOutProducts[$val->just_id] + $val->count;
         }
     }
     $curProd = Balance::model()->with('products')->findAll('b_date = :dates', array(':dates' => $dates), array('order' => 'products.name'));
     foreach ($curProd as $value) {
         $endProducts[$value->prod_id] = $endProducts[$value->prod_id] + $value->startCount + $inProducts[$value->prod_id] - $outProducts[$value->prod_id] - $inOutProducts[$value->prod_id];
     }
     $this->render('today', array('prodModel' => $prodModel, 'model' => $curProd, 'inProducts' => $inProducts, 'outProducts' => $outProducts, 'inOutProducts' => $inOutProducts, 'endProducts' => $endProducts));
 }
Пример #25
0
 public function actionAjaxBalance()
 {
     $dates = $_POST['dates'];
     $expense = new Expense();
     if (isset($_POST)) {
         $command = Yii::app()->db->createCommand();
         if ($_POST['types'] == 0) {
             foreach ($_POST['prod_id'] as $key => $val) {
                 $command->update('balance', array('CurEndCount' => $expense->changeToFloat($_POST['count'][$key])), 'b_date=:dates AND prod_id = :prod_id', array(':dates' => $dates, ':prod_id' => $val));
             }
         } elseif ($_POST['types'] == 1) {
             $depId = $_POST['depId'];
             foreach ($_POST['prod_id'] as $key => $val) {
                 $command->update('dep_balance', array('CurEndCount' => $expense->changeToFloat($_POST['pcount'][$key])), 'b_date=:dates AND prod_id = :prod_id AND type = :types AND department_id = :depId', array(':dates' => $dates, ':prod_id' => $val, ':types' => 1, ':depId' => $depId));
             }
             foreach ($_POST['stuff_id'] as $key => $val) {
                 $command->update('dep_balance', array('CurEndCount' => $expense->changeToFloat($_POST['hcount'][$key])), 'b_date=:dates AND prod_id = :prod_id AND type = :types AND department_id = :depId', array(':dates' => $dates, ':prod_id' => $val, ':types' => 2, ':depId' => $depId));
             }
         }
     }
 }
Пример #26
0
echo sizeof($mPendingExpenseList);
?>
)</h3>				
					</div> <!-- End .content-box-header -->				
					<div style="display: block;padding:0px;height:85%;overflow-y:auto" class="content-box-content">
					
						<div style="display:block;overflow-y:auto" class="tab-content default-tab">
						
							<table id="noti_table">
							<thead>
							<tr></tr>
							</thead>
							<tbody style="border-bottom:0px" id="bill_body">
							<?php 
for ($i = 0; $i < sizeof($mPendingExpenseList); $i++) {
    $mExpense = new Expense($mPendingExpenseList[$i]);
    $vehicleId = $mExpense->getVehicle();
    $mVehicle = new Vehicle($vehicleId);
    $driverId = $mExpense->getDriver();
    $mDriver = new Driver($driverId);
    $reason = $mExpense->getReason();
    $amount = $mExpense->getAmount();
    echo "<tr onMouseOver='this.bgColor='#EEEEEE''>\n\t\t\t\t\t\t\t\t\t\t\t<td style='width:30%'><b><a href='../vehicle/detail.php?id=" . $mVehicle->getId() . "'>" . $mVehicle->getVehicleNumber() . "</a></b></td>\n\t\t\t\t\t\t\t\t\t\t\t<td style='width:30%'><b><a href='../driver/detail.php?id=" . $mDriver->getId() . "'>" . $mDriver->getName() . "</a></b></td>\n\t\t\t\t\t\t\t\t\t\t\t<td>" . $reason . "</td>\n\t\t\t\t\t\t\t\t\t\t\t<td><b>Rs." . $amount . "</b></td>\n\t\t\t\t\t\t\t\t\t\t\t<td><a class='js-open-modal' href='#' data-modal-id='bill_popup' onClick='fetchBillDetails(" . $mExpense->getId() . ")'><img src='../../res/more_detail.png' width=20 height=20 style='cursor:hand;'/></a></td>\n\t\t\t\t\t\t\t\t\t\t</tr>";
}
?>
							</tbody>
							</table>
						</div>      
					
					</div> <!-- End .content-box-content -->			
				</div> <!-- End .content-box -->
Пример #27
0
        <th>Net</th>
    </tr>
    <?php 
for ($ii = 1; $ii <= $daysInSelectedMonth; $ii++) {
    ?>
        <tr>
            <td><a href="<?php 
    echo BASE_URL . "main/?month={$selectedMonth}&day={$ii}&year={$selectedYear}";
    ?>
"><?php 
    echo $selectedMonthName . " " . $ii;
    ?>
</a></td>
            <td><?php 
    echo htmlentities(Income::formatDisplayAmount($incomeEachDay[$ii - 1]));
    ?>
</td>
            <td><?php 
    echo htmlentities(Expense::formatDisplayAmount($expenseEachDay[$ii - 1]));
    ?>
</td>
            <td><?php 
    echo htmlentities(IncomeExpenseObject::formatDisplayAmount($totalEachDay[$ii - 1]));
    ?>
</td>
        </tr>
    <?php 
}
?>
</table>
Пример #28
0
 /**
  * Generate a report that outlines the rent collection for a particular 
  * property over a specified period of time
  * @param mixed $title The report title
  * @param object $result_obj A result object obtained from a SELECT query
  * @param object $arrears_paid_obj A result object obtained from a SELECT query
  * @param object $arrears_obj A result object obtained from a SELECT query
  * @param object $expenses_obj A result object obtained from a SELECT query
  * @param array $headings Array of table heading names
  * @param array $widths Array of column widths
  * @param array $aligns Array of column alignments
  * @param string $orientation The page orientation of the report
  * @param mixed $page_size Dimensions of page that displays report
  * @param int $prop_id The ID used to identify the property
  * @param string $start Date string specifying start of the period
  * @param string $end Date string specifying end of the period
  */
 public function pdf($title, $result_obj, $arrears_paid_obj, $arrears_obj, $expenses_obj, $headings = NULL, $widths = NULL, $aligns = NULL, $orientation = 'P', $page_size = 'A4', $prop_id, $start, $end)
 {
     define('HORZ_PADDING', 2);
     define('VERT_PADDING', 3);
     $filename = date('Y-m-d') . '-report-' . uniqid() . '.pdf';
     $pdf = new PDF_Report($orientation, 'pt', $page_size);
     $pdf->set_title($title);
     $pdf->setStartPeriod($start);
     $pdf->setEndPeriod($end);
     $pdf->SetX(-1);
     $page_width = $pdf->GetX() + 1;
     $pdf->AliasNbPages();
     $pdf->SetFont('Helvetica', '', 7);
     $pdf->SetLineWidth(0.1);
     $pdf->SetMargins(self::PDF_MARGIN, self::PDF_MARGIN);
     $pdf->SetAutoPageBreak(true, self::PDF_MARGIN);
     $pdf->SetHorizontalPadding(HORZ_PADDING);
     $pdf->SetVerticalPadding(VERT_PADDING);
     $ncols = $this->columnCount($result_obj);
     // Instantiate Helper Variables
     $rent = new Rent();
     $total_collection = Rent::calcTotalCollection($prop_id, $start, $end);
     $paid_arrears = ArrearsPaid::calcCollectionForPropertyDuringPeriod($prop_id, $start, $end);
     $owed_arrears = Arrears::calcArrearsForPropertyDuringPeriod($prop_id, $start, $end);
     $collection_summary = Rent::calcCollectionSummary($prop_id, $start, $end);
     $mgt_fee = $rent->calcManagementFee($prop_id, $start, $end);
     $net_amount = $rent->calcBalanceAfterMgtFee($prop_id, $start, $end);
     $total_expenses = Expense::calcTotalExpenses($prop_id, $start, $end);
     $net_banking = $rent->calcNetBanking($prop_id, $start, $end);
     $rent_collection_array = array(0 => 'Rent Collection', 1 => $total_collection);
     $paid_arrears_array = array(0 => 'Paid Arrears', 1 => $paid_arrears);
     $summary_collection_array = array(0 => 'Total Collection', 1 => $collection_summary);
     $percentage_mgt_fee = Property::findById($prop_id)->getManagementFee();
     $percentage_mgt_fee = '(' . $percentage_mgt_fee . '%)';
     $mgt_fee_array = array(0 => 'Management Fee' . $percentage_mgt_fee, 1 => $mgt_fee);
     $net_amount_array = array(0 => 'Net Collection (Balance after Management Fee)', 1 => $net_amount);
     $total_expenses_array = array(0 => 'Total Expenses', 1 => $total_expenses);
     $net_banking_array = array(0 => 'Banking(Money Deposited to Landlord\'s Account)', 1 => $net_banking);
     if (is_null($headings)) {
         $headings = $this->columnHeadings($result_obj);
     }
     //$pdf->set_headings($headings);
     //$pdf->SetFont('Helvetica', 'B', 8);
     //$pdf->RowX($headings, false);/
     if (is_null($widths)) {
         $w = ($page_width - 2 * self::PDF_MARGIN) / $ncols;
         for ($i = 0; $i < $ncols; $i++) {
             $widths[$i] = $w;
         }
     }
     if (count($widths) == $ncols - 1) {
         $n = 0;
         foreach ($widths as $w) {
             $n += $w;
         }
         $widths[$ncols - 1] = $page_width - 2 * self::PDF_MARGIN - $n;
     }
     $pdf->SetWidths($widths);
     if (!is_null($aligns)) {
         $a = 'R';
         for ($i = 0; $i < $ncols; $i++) {
             $aligns[$i] = $a;
         }
     }
     $pdf->SetAligns($aligns);
     $pdf->AddPage();
     $pdf->SetFont('Helvetica', 'B', 8);
     $pdf->RowX($headings, false);
     $pdf->SetFont('Helvetica', '', 7);
     while ($row = $result_obj->fetch_row()) {
         $pdf->RowX($row);
     }
     if (!is_null($total_collection)) {
         $xPos = $page_width - (self::PDF_MARGIN + $w);
         $pdf->SetX($xPos);
         $pdf->SetFont('Times', 'B', 8);
         $text = "Total: " . $total_collection;
         $pdf->MultiCell($w, 12, $text, 1, 'R');
     }
     $pdf->Ln();
     $pdf->Ln();
     $pdf->SetX(0 + self::PDF_MARGIN);
     $pdf->SetFont('Arial', 'B', 10);
     $pdf->SetTextColor(24);
     $timestamp_start = strtotime($start);
     $timestamp_end = strtotime($end);
     $text_arrears_paid = "Arrears Collected for Period ";
     $text_arrears_paid .= strftime("%B %d, %Y", $timestamp_start);
     $text_arrears_paid .= " to " . strftime("%B %d, %Y", $timestamp_end);
     $pdf->MultiCell($pdf->get_page_width() - self::PDF_MARGIN * 2, 8, $text_arrears_paid, 'B', 'C');
     $pdf->Ln();
     // Arrears Paid
     if ($arrears_paid_obj->num_rows >= 1) {
         $col_count_arrears_paid = $this->columnCount($arrears_paid_obj);
         $arrears_paid_headings = $this->columnHeadings($arrears_paid_obj);
         $arrears_paid_widths = array();
         $w = ($page_width - 2 * self::PDF_MARGIN) / $col_count_arrears_paid;
         for ($i = 0; $i < $col_count_arrears_paid; $i++) {
             $arrears_paid_widths[$i] = $w;
         }
         //$pdf->SetWidths(array(70, 70, 70, 70, 70, 70));
         $pdf->SetWidths($arrears_paid_widths);
         $arrears_paid_aligns = array();
         $a = 'R';
         for ($i = 0; $i < $col_count_arrears_paid; $i++) {
             $arrears_paid_aligns[$i] = $a;
         }
         $pdf->SetAligns($arrears_paid_aligns);
         $pdf->SetFont('Helvetica', 'B', 8);
         $pdf->RowX($arrears_paid_headings, false);
         $pdf->SetFont('Helvetica', '', 7);
         while ($row = $arrears_paid_obj->fetch_row()) {
             $pdf->RowX($row);
         }
         if (!is_null($paid_arrears)) {
             $xPos = $page_width - (self::PDF_MARGIN + $w);
             $pdf->SetX($xPos);
             $pdf->SetFont('Times', 'B', 8);
             $text = "Total: " . $paid_arrears;
             $pdf->MultiCell($w, 12, $text, 1, 'R');
         }
     } else {
         $no_arrears = "Ksh. 0.00";
         $xPos = $page_width - (self::PDF_MARGIN + $w);
         $pdf->SetX($xPos);
         $pdf->MultiCell($w, 8, $no_arrears, 0, 'R');
         $pdf->Ln();
     }
     // Outstanding Arrears
     $pdf->Ln();
     $pdf->Ln();
     $pdf->SetX(0 + self::PDF_MARGIN);
     $pdf->SetFont('Arial', 'B', 10);
     $pdf->SetTextColor(24);
     $arrears_owed = "Outstanding Rent Arrears for the Period ";
     $arrears_owed .= strftime("%B %d, %Y", $timestamp_start);
     $arrears_owed .= " to " . strftime("%B %d, %Y", $timestamp_end);
     $pdf->MultiCell($pdf->get_page_width() - self::PDF_MARGIN * 2, 8, $arrears_owed, 'B', 'C');
     $pdf->Ln();
     if ($arrears_obj->num_rows >= 1) {
         $col_count_arrears = $this->columnCount($arrears_obj);
         $arrears_headings = $this->columnHeadings($arrears_obj);
         $arrears_widths = array();
         $w = ($page_width - 2 * self::PDF_MARGIN) / $col_count_arrears;
         for ($i = 0; $i < $col_count_arrears; $i++) {
             $arrears_widths[$i] = $w;
         }
         //$pdf->SetWidths(array(70, 70, 70, 70, 70, 70));
         $pdf->SetWidths($arrears_widths);
         $arrears_aligns = array();
         $a = 'R';
         for ($i = 0; $i < $col_count_arrears; $i++) {
             $arrears_aligns[$i] = $a;
         }
         $pdf->SetAligns($arrears_aligns);
         $pdf->SetFont('Helvetica', 'B', 8);
         $pdf->RowX($arrears_headings, false);
         $pdf->SetFont('Helvetica', '', 7);
         while ($row = $arrears_obj->fetch_row()) {
             $pdf->RowX($row);
         }
         if (!is_null($owed_arrears)) {
             $xPos = $page_width - (self::PDF_MARGIN + $w);
             $pdf->SetX($xPos);
             $pdf->SetFont('Times', 'B', 8);
             $text = "Total: " . $owed_arrears;
             $pdf->MultiCell($w, 12, $text, 1, 'R');
         }
     } else {
         $no_arrears = "Ksh. 0.00";
         $xPos = $page_width - (self::PDF_MARGIN + $w);
         $pdf->SetX($xPos);
         $pdf->MultiCell($w, 8, $no_arrears, 0, 'R');
         $pdf->Ln();
     }
     // Collection Summary
     $pdf->Ln();
     $pdf->Ln();
     $pdf->SetX(0 + self::PDF_MARGIN);
     $pdf->SetFont('Arial', 'B', 10);
     $pdf->SetTextColor(24);
     $pdf->MultiCell($pdf->get_page_width() - self::PDF_MARGIN * 2, 8, 'Collection Summary', 'B', 'C');
     $pdf->Ln();
     $summary_aligns = array('R', 'R');
     $pdf->SetAligns($summary_aligns);
     $cell_width = $pdf->get_page_width() / 4;
     $summary_widths = array($cell_width, $cell_width);
     $pdf->SetWidths($summary_widths);
     $pdf->Ln();
     $xPos = $page_width - (self::PDF_MARGIN + $cell_width * 2);
     //$pdf->SetX($xPos);
     $pdf->RowX($rent_collection_array);
     //$pdf->SetX($xPos);
     $pdf->RowX($paid_arrears_array);
     //$pdf->SetX($xPos);
     $pdf->RowX($summary_collection_array);
     $pdf->Ln();
     $pdf->Ln();
     //$pdf->SetX($xPos);
     $pdf->RowX($mgt_fee_array);
     //$pdf->SetX($xPos);
     //$pdf->RowX($net_amount_array);
     $pdf->Ln();
     $pdf->Ln();
     // Outline Expenses
     $pdf->SetX(0 + self::PDF_MARGIN);
     $pdf->SetFont('Arial', 'B', 10);
     $pdf->SetTextColor(24);
     $exp_incurred = "Expenses for the Period ";
     $exp_incurred .= strftime("%B %d, %Y", $timestamp_start);
     $exp_incurred .= " to " . strftime("%B %d, %Y", $timestamp_end);
     $pdf->MultiCell($pdf->get_page_width() - self::PDF_MARGIN * 2, 8, $exp_incurred, 'B', 'C');
     $pdf->Ln();
     if ($expenses_obj->num_rows >= 1) {
         $col_count_expenses = $this->columnCount($expenses_obj);
         $expense_headings = $this->columnHeadings($expenses_obj);
         $expense_widths = array();
         $w = ($page_width - 2 * self::PDF_MARGIN) / $col_count_expenses;
         for ($i = 0; $i < $col_count_expenses; $i++) {
             $expense_widths[$i] = $w;
         }
         //$pdf->SetWidths(array(70, 70, 70, 70, 70, 70));
         $pdf->SetWidths($expense_widths);
         $expense_aligns = array();
         $a = 'R';
         for ($i = 0; $i < $col_count_expenses; $i++) {
             $expense_aligns[$i] = $a;
         }
         $pdf->SetAligns($expense_aligns);
         $pdf->SetFont('Helvetica', 'B', 8);
         $pdf->RowX($expense_headings, false);
         $pdf->SetFont('Helvetica', '', 7);
         while ($row = $expenses_obj->fetch_row()) {
             $pdf->RowX($row);
         }
         if (!is_null($total_expenses)) {
             $xPos = $page_width - (self::PDF_MARGIN + $w);
             $pdf->SetX($xPos);
             $pdf->SetFont('Times', 'B', 8);
             $text = "Total: " . $total_expenses;
             $pdf->MultiCell($w, 12, $text, 1, 'R');
         }
     } else {
         $no_expenses = "Ksh. 0.00";
         $xPos = $page_width - (self::PDF_MARGIN + $w);
         $pdf->SetX($xPos);
         $pdf->MultiCell($w, 8, $no_expenses, 0, 'R');
         $pdf->Ln();
     }
     $pdf->Ln();
     $pdf->Ln();
     $pdf->SetX(0 + self::PDF_MARGIN);
     $pdf->SetFont('Arial', 'B', 10);
     $pdf->SetTextColor(24);
     $pdf->MultiCell($pdf->get_page_width() - self::PDF_MARGIN * 2, 8, 'Banking', 'B', 'C');
     $banking_aligns = array('R', 'R');
     $pdf->SetAligns($banking_aligns);
     $cell_width = $pdf->get_page_width() / 4;
     $banking_widths = array($cell_width, $cell_width);
     $pdf->SetWidths($banking_widths);
     $pdf->Ln();
     $xPos = $page_width - (self::PDF_MARGIN + $cell_width * 2);
     //$pdf->SetX($xPos);
     $pdf->RowX($net_amount_array);
     //$pdf->SetX($xPos);
     $pdf->RowX($total_expenses_array);
     //$pdf->SetX($xPos);
     $pdf->RowX($net_banking_array);
     $pdf->Ln();
     $pdf->MultiCell($pdf->get_page_width() - self::PDF_MARGIN * 2, 8, 'Analysis', 'B', 'C');
     $pdf->Ln();
     $currProp = Property::findById($prop_id);
     $num_of_rooms = $currProp->getNumRooms();
     $num_occupied_rooms = $currProp->getNumRoomsOccupied();
     $occupancy_level = $currProp->calcOccupancyLevel();
     $monthly_collection = $currProp->calcExpectedMonthlyCollection();
     $expected_collection = $currProp->calcExpectedCollectionForPeriod($start, $end);
     $percentage_collection = $currProp->calcCollectionPercentageForPeriod($start, $end);
     $period = $currProp->getNumMonthsInPeriod($start, $end);
     $period = '( ' . $period . ' Month[s] )';
     $num_rooms_array = array(0 => 'Number of Rooms in Property', 1 => $num_of_rooms);
     $occupied_rooms_array = array(0 => 'No. of Occupied Rooms', 1 => $num_occupied_rooms);
     $occupancy_level_array = array(0 => 'Occupancy Level (%)', 1 => $occupancy_level . '%');
     $expected_monthly_collection = array(0 => 'Expected Monthly Collection', 1 => $monthly_collection);
     $amount_collected_array = array(0 => "Total Amount Collected in Period{$period}", 1 => $collection_summary);
     $expected_collection_array = array(0 => 'Expected Collection for Period', 1 => $expected_collection);
     $percentage_collection_array = array(0 => 'Collection Level (%)', 1 => $percentage_collection . '%');
     //$pdf->SetX($xPos);
     $pdf->RowX($num_rooms_array);
     //$pdf->SetX($xPos);
     $pdf->RowX($occupied_rooms_array);
     //$pdf->SetX($xPos);
     $pdf->RowX($occupancy_level_array);
     //$pdf->SetX($xPos);
     $pdf->RowX($expected_monthly_collection);
     //$pdf->SetX($xPos);
     $pdf->RowX($amount_collected_array);
     //$pdf->SetX($xPos);
     $pdf->RowX($expected_collection_array);
     //$pdf->SetX($xPos);
     $pdf->RowX($percentage_collection_array);
     $pdf->Output($filename, 'D');
 }
Пример #29
0
 * @package OfuzPage
 * @license ##License##
 * @version 0.6
 * @date 2010-09-06
 * @since 0.4
 */
include_once 'config.php';
$pageTitle = _('Expenses') . ' :: Ofuz ';
$Author = 'SQLFusion LLC';
$Keywords = 'Ofuz Expenses';
$Description = 'list and filter the Expenses ';
$background_color = 'white';
//   include_once('includes/ofuz_check_access.script.inc.php');
//   include_once('includes/header.inc.php');
if (!is_object($_SESSION['do_expense_list'])) {
    $do_expense_list = new Expense();
    $do_expense_list->sessionPersistent("do_expense_list", "index.php", OFUZ_TTL);
}
//echo $_SESSION['do_invoice_list']->getSqlQuery();
$user_settings = $_SESSION['do_User']->getChildUserSettings();
if ($user_settings->getNumRows()) {
    while ($user_settings->next()) {
        if ($user_settings->setting_name == 'currency' && $user_settings->setting_value != '') {
            $currency = explode("-", $user_settings->setting_value);
            $_SESSION['do_expense_list']->currency_iso_code = $currency[0];
            $_SESSION['do_expense_list']->currency_sign = $currency[1];
            $_SESSION['do_expense_list']->setCurrencyDisplay();
            $_SESSION['do_expense_list']->getCurrencyPostion();
        }
        if ($user_settings->setting_name == 'inv_date_format' && $user_settings->setting_value != '') {
            $_SESSION['do_expense_list']->inv_dd_format = $user_settings->setting_value;
Пример #30
0
 function item($id = FALSE)
 {
     if ($_POST) {
         unset($_POST['send']);
         $_POST = array_map('htmlspecialchars', $_POST);
         if ($_POST['name'] != "") {
             $_POST['name'] = $_POST['name'];
             $_POST['value'] = $_POST['value'];
             $_POST['type'] = $_POST['type'];
         } else {
             if ($_POST['item_id'] == "-") {
                 $this->session->set_flashdata('message', 'error:' . $this->lang->line('messages_add_item_error'));
                 redirect('invoices/view/' . $_POST['invoice_id']);
             } else {
                 $rebill = explode("_", $_POST['item_id']);
                 if ($rebill[0] == "rebill") {
                     $itemvalue = Expense::find_by_id($rebill[1]);
                     $_POST['name'] = $itemvalue->description;
                     $_POST['type'] = $_POST['item_id'];
                     $_POST['value'] = $itemvalue->value;
                     $itemvalue->rebill = 2;
                     $itemvalue->invoice_id = $_POST['invoice_id'];
                     $itemvalue->save();
                 } else {
                     $itemvalue = Item::find_by_id($_POST['item_id']);
                     $_POST['name'] = $itemvalue->name;
                     $_POST['type'] = $itemvalue->type;
                     $_POST['value'] = $itemvalue->value;
                 }
             }
         }
         $item = InvoiceHasItem::create($_POST);
         if (!$item) {
             $this->session->set_flashdata('message', 'error:' . $this->lang->line('messages_add_item_error'));
         } else {
             $this->session->set_flashdata('message', 'success:' . $this->lang->line('messages_add_item_success'));
         }
         redirect('invoices/view/' . $_POST['invoice_id']);
     } else {
         $this->view_data['invoice'] = Invoice::find($id);
         $this->view_data['items'] = Item::find('all', array('conditions' => array('inactive=?', '0')));
         $this->view_data['rebill'] = Expense::find('all', array('conditions' => array('project_id=? and (rebill=? or invoice_id=?)', $this->view_data['invoice']->project_id, 1, $id)));
         $this->theme_view = 'modal';
         $this->view_data['title'] = $this->lang->line('application_add_item');
         $this->view_data['form_action'] = 'invoices/item';
         $this->content_view = 'invoices/_item';
     }
 }