Exemplo n.º 1
0
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     $agent_id = Sentry::getUser()->id;
     $tenants = Tenant::where('agent_id', $agent_id)->get();
     foreach ($tenants as $tenant) {
         $tname = $tenant->name;
         $occupancies = House::where('tenant', $tname)->get();
     }
     return View::make('backend.code.tenants.index', compact('tenants', 'occupancies'));
 }
Exemplo n.º 2
0
 public function createOccupancy($id)
 {
     $houses = House::findOrFail($id);
     $tenants = Tenant::where('agent_id', '=', Sentry::getUser()->id)->get();
     if (!$tenants->isEmpty()) {
         return View::make('backend.code.occupancy.create', compact('houses', 'tenants'));
     } else {
         return Redirect::action('Controllers\\Admin\\UsersController@getCreate')->withFlashMessage('You need to create a Tenant first before you Proceed');
     }
 }
 /**
  * Store a newly created resource in storage.
  * POST /invoices
  *
  * @return Response
  */
 public function store()
 {
     $input = Input::all();
     $v = Validator::make(Input::All(), array('houseID' => 'required', 'tenant' => 'required', 'type' => 'required', 'rent' => 'required', 'service' => 'required', 'garbage' => 'required', 'water' => 'required', 'security' => 'required', 'electricity' => 'required', 'duedate' => 'required'));
     //if validation passes create an invoice
     if ($v->passes()) {
         $balance = Input::get('rent') + Input::get('water') + Input::get('service') + Input::get('garbage') + Input::get('electricity') + Input::get('security');
         $agent_id = Sentry::getUser()->id;
         $hid = Input::get('houseID');
         $house = House::find($hid);
         $houseOccupaied = $house->name;
         $htenant = Input::get('tenant');
         $tenant_details = Tenant::where('name', $htenant)->get();
         foreach ($tenant_details as $tenant_detail) {
             $number = $tenant_detail->phone;
             $lname = $tenant_detail->lname;
         }
         $nams = $htenant . ' ' . $lname;
         $invoice = new Invoice();
         $invoice->type = Input::get('type');
         $invoice->houseID = $houseOccupaied;
         $invoice->recipient = $nams;
         $invoice->agent_id = $agent_id;
         $invoice->balance = $balance;
         $invoice->duedate = Input::get('duedate');
         $invoice->save();
         $invoicedetail = new Invoicedetail();
         $invoicedetail->rent = Input::get('rent');
         $invoicedetail->water = Input::get('water');
         $invoicedetail->service = Input::get('service');
         $invoicedetail->garbage = Input::get('garbage');
         $invoicedetail->electricity = Input::get('electricity');
         $invoicedetail->security = Input::get('security');
         $invoice->invoicedetail()->save($invoicedetail);
         #send an sms to the tenant
         $to = $number;
         $message = ' Hi ' . $htenant . 'Your invoivce for this month of amount: Ksh. ' . number_format($balance, 2) . ' is due, Please for detailed information login at real-estate.kenya.com';
         Queue::push('SendSMS', array('message' => $message, 'number' => $to));
         return Redirect::intended('admin/invoice');
     }
     return Redirect::back()->withInput()->withErrors($v)->with('message', 'There were validation errors');
 }
Exemplo n.º 4
0
 /**
  * Store a newly created resource in storage.
  * POST /accountreceivables
  *
  * @return Response
  */
 public function store()
 {
     $input = Input::all();
     $v = Validator::make(Input::All(), array('invoiceID' => 'required|max:50|', 'houseID' => 'required', 'amount' => 'required|min:2', 'paymenttype' => 'required', 'amountpayed' => 'required', 'paymenttyperef' => 'required'));
     if ($v->passes()) {
         $gamount = Input::get('amount');
         $gpayed = Input::get('amountpayed');
         $initpaid = Input::get('initpaid');
         $id = Input::get('invoiceID');
         $balance = $gamount - $gpayed;
         $invoice = Invoice::find($id);
         $invoice->balance = $gamount - $gpayed;
         $invoice->amountpaid = $gpayed + $initpaid;
         $invoice->save();
         $payment = new Payment();
         $payment->invoiceID = Input::get('invoiceID');
         $payment->amount = Input::get('amount');
         $payment->amountpayed = Input::get('amountpayed');
         $payment->houseID = Input::get('houseID');
         $payment->balance = $gamount - $gpayed;
         $payment->paymenttype = Input::get('paymenttype');
         $payment->paymenttyperef = Input::get('paymenttyperef');
         $payment->save();
         #send an sms to the tenant
         $findTenant = $invoice->recipient;
         $tenants = Tenant::where('name', $findTenant)->get();
         foreach ($tenants as $tenant) {
             $t_name = $tenant->name;
             $to = $tenant->phone;
         }
         $message = ' Hi ' . $t_name . ', Your invoivce Payment  of amount: Ksh. ' . number_format($gpayed, 2) . ' has been received  due balance ' . number_format($balance, 2) . ', Thank you for Choosing us';
         LaravelAtApi::sendMessage($to, $message);
         return Redirect::route('admin.invoice.show', $id);
     }
     return Redirect::back()->withInput()->withErrors($v)->with('message', 'There were validation errors');
 }
<?php

Route::group(array('domain' => '{account}.local.dev', 'before' => 'tenantFilter'), function () {
    //login form for tenants
    Route::get('/', 'TenantsController@login');
    Route::post('/', 'TenantsController@createSession');
});
Route::get('/', 'HomeController@index');
Route::post('/tenants', ['as' => 'tenants.store', 'uses' => 'TenantsController@store']);
//before filter subdomain
Route::filter('tenantFilter', function () {
    //parse the url in order to get the subdomain
    $url = Request::url();
    $url = parse_url($url);
    $host = explode('.', $url['host']);
    $subdomain = $host[0];
    //verify the existence of subdomain
    $user = Tenant::where('subdomain', '=', $subdomain)->firstOrFail();
    //if user exists, change the schema to the tenant schema
    PGSchema::switchTo($subdomain);
});
Exemplo n.º 6
0
 /**
  * Store a newly created resource in storage.
  * POST /invoices
  *
  * @return Response
  */
 public function store()
 {
     $input = Input::all();
     $hinput = Input::only('status', 'tenant');
     $v = Validator::make(Input::All(), array('houseID' => 'required|max:50|unique:occupancies', 'tenant' => 'required', 'startdate' => 'required', 'enddate' => 'required', 'status' => 'required'));
     if ($v->passes()) {
         //get the id of the agent
         $agent_id = Sentry::getUser()->id;
         //update the occupancy status for the tenant
         $tname = Input::get('tenant');
         $tenant = Tenant::where('id', $tname)->first();
         $tenant->occupancy = 'true';
         $tenant->save();
         $tnames = Tenant::where('id', $tname)->get(array('name', 'lname', 'phone'));
         foreach ($tnames as $tname) {
             $names = $tname->name . ' ' . $tname->lname;
             $fname = $tname->name;
             $number = $tname->phone;
         }
         //update the occupancy status in the unit
         $hid = Input::get('houseID');
         $house = House::find($hid);
         $house->tenant = $names;
         $house->status = Input::get('status');
         $house->save();
         //Add a new occupancy
         $occupancy = new Occupancy();
         $occupancy->tenant = $names;
         $occupancy->startdate = Input::get('startdate');
         $occupancy->enddate = Input::get('enddate');
         $house->occupancy()->save($occupancy);
         //create an invoice for the new house
         $rent = $house->rent;
         $rentd = $house->rentd;
         $waterd = $house->waterd;
         $electricityd = $house->electricityd;
         $transportD = $house->transportD;
         $garbageD = $house->garbageD;
         $balance = $rent + $rentd + $waterd + $electricityd + $transportD + $garbageD;
         $invoice = new Invoice();
         $invoice->type = 'deposits';
         $invoice->houseID = $hid;
         $invoice->recipient = $fname;
         $invoice->agent_id = $agent_id;
         $invoice->balance = $balance;
         $invoice->duedate = '2015/03/21';
         $invoice->save();
         $invoicedetail = new Invoicedetail();
         $invoicedetail->rent = $rent;
         $invoicedetail->rentD = $rentd;
         $invoicedetail->waterD = $waterd;
         $invoicedetail->electricityD = $electricityd;
         $invoicedetail->transport_cost = $transportD;
         $invoicedetail->garbage = $garbageD;
         $invoice->invoicedetail()->save($invoicedetail);
         //send an sms to tenant of his occupancy status
         $houseName = $house->name;
         $to = $number;
         $message = ' Hi ' . $names . ', Your deposits of Ksh ' . number_format($balance, 2) . ' for ' . $houseName . ' has been received successfully. Welcome and Thank you for choosing us. ENJOY YOUR STAY';
         LaravelAtApi::sendMessage($to, $message);
         return Redirect::intended('admin/occupancy');
     }
     return Redirect::back()->withInput()->withErrors($v)->with('message', 'There were validation errors');
 }
Exemplo n.º 7
0
 public function selectToPay()
 {
     $tenants = Tenant::where('agent_id', '=', Sentry::getUser()->id)->where('occupancy', '=', 'true')->get();
     return View::make('backend.code.tenants.paytenant', compact('tenants'));
 }
 public function gerenateMonthly()
 {
     $input = Input::all();
     $v = Validator::make(Input::All(), array('houseID' => 'required', 'propertyid' => 'required', 'agent_id' => 'required'));
     if ($v->passes()) {
         $propertyidan = Input::get('propertyid');
         $houseID = Input::get('houseID');
         $startDate = time();
         $lastmonth = date('Y-m-d', strtotime('+5 day', $startDate));
         $ddate = date('d');
         $agent_id = Input::get('agent_id');
         $billedusr = User::find($agent_id);
         $hisBalance = $billedusr->credit_balance;
         $newBalance = $hisBalance - 3;
         $billedusr->credit_balance = $newBalance;
         $billedusr->save();
         $billstatement = new Statement();
         $billstatement->type = "Generating Invoice";
         $billstatement->amount = 3;
         $billstatement->save();
         if ($houseID === "All") {
             $houses = House::where('status', '=', 'booked')->where('frequency', '=', 1)->where('propertyID', $propertyidan)->get();
             foreach ($houses as $house) {
                 $hid = $house->id;
                 $houseName = $house->name;
                 $propid = $house->propertyID;
                 $propname = Property::where('id', $propid)->pluck('name');
                 $rent = $house->rent;
                 $water = $house->water;
                 $garbage = $house->garbage;
                 $electricity = $house->electricity;
                 $security = $house->security;
                 $frequency = $house->frequency;
                 $tenant_id = $house->tenant;
                 $tenantnames = strtok($tenant_id, " ");
                 $tenant = Tenant::where('name', $tenantnames)->first();
                 $t_name = $tenant->name;
                 $to = $tenant->phone;
                 $t_agent = $tenant->agent_id;
                 $balance = $rent + $water + $garbage + $electricity + $security;
                 $invoice = new Invoice();
                 $invoice->type = 'to tenant';
                 $invoice->houseID = $houseName;
                 $invoice->recipient = $t_name;
                 $invoice->agent_id = $t_agent;
                 $invoice->balance = $balance;
                 $invoice->propertyid = $propid;
                 $invoice->duedate = $lastmonth;
                 $invoice->save();
                 $invoicedetail = new Invoicedetail();
                 $invoicedetail->rent = $rent;
                 $invoicedetail->water = $water;
                 $invoicedetail->garbage = $garbage;
                 $invoicedetail->electricity = $electricity;
                 $invoicedetail->security = $security;
                 $invoice->invoicedetail()->save($invoicedetail);
                 $message = 'Dear ' . $t_name . ', your rent for this month of Ksh ' . number_format($balance, 2) . '  is due for payment. For inquiries contact 0700548168 Rehema House Ngong';
                 Queue::push('SendSMS', array('message' => $message, 'number' => $to));
             }
             $noteSuccesGen = array('error' => false, 'message' => "Monthly invoice(s) generated successfully");
             return $noteSuccesGen;
         } else {
             $house = House::where('name', '=', $houseID)->where('frequency', '=', 1)->first();
             $hid = $house->id;
             $houseName = $house->name;
             $propid = $house->propertyID;
             $propname = Property::where('id', $propid)->pluck('name');
             $rent = $house->rent;
             $water = $house->water;
             $garbage = $house->garbage;
             $electricity = $house->electricity;
             $security = $house->security;
             $frequency = $house->frequency;
             $tenant_id = $house->tenant;
             $tenantnames = strtok($tenant_id, " ");
             $tenant = Tenant::where('name', $tenantnames)->first();
             $t_name = $tenant->name;
             $to = $tenant->phone;
             $t_agent = $tenant->agent_id;
             $balance = $rent + $water + $garbage + $electricity + $security;
             $invoice = new Invoice();
             $invoice->type = 'to tenant';
             $invoice->houseID = $houseName;
             $invoice->recipient = $t_name;
             $invoice->agent_id = $t_agent;
             $invoice->balance = $balance;
             $invoice->propertyid = $propid;
             $invoice->duedate = $lastmonth;
             $invoice->save();
             $invoicedetail = new Invoicedetail();
             $invoicedetail->rent = $rent;
             $invoicedetail->water = $water;
             $invoicedetail->garbage = $garbage;
             $invoicedetail->electricity = $electricity;
             $invoicedetail->security = $security;
             $invoice->invoicedetail()->save($invoicedetail);
             $message = 'Dear ' . $t_name . ', your rent for this month of Ksh ' . number_format($balance, 2) . '  is due for payment.For inquiries contact 0700548168 Rehema House Ngong';
             Queue::push('SendSMS', array('message' => $message, 'number' => $to));
             $noteSuccesGen = array('error' => false, 'message' => "Monthly invoice(s) generated successfully");
             return $noteSuccesGen;
         }
     }
     $noteGenerate4 = array('error' => true, 'message' => $v->messages());
     return $noteGenerate4;
 }
 /**
  * Store a newly created resource in storage.
  * POST /accountreceivables
  *
  * @return Response
  */
 public function store()
 {
     $input = Input::all();
     $v = Validator::make(Input::All(), array('invoiceID' => 'required|max:50|', 'houseID' => 'required', 'amount' => 'required|min:2', 'paymenttype' => 'required', 'amountpayed' => 'required', 'paymenttyperef' => 'required'));
     if ($v->passes()) {
         $findHouse = Input::get('houseID');
         $propertyId = House::where('name', $findHouse)->pluck('propertyID');
         $propertyName = Property::where('id', $propertyId)->pluck('name');
         $agent_id = Sentry::getUser()->id;
         $gamount = Input::get('amount');
         $gpayed = Input::get('amountpayed');
         $initpaid = Input::get('initpaid');
         $b = $gamount - $gpayed;
         $id = Input::get('invoiceID');
         $balance = $gamount - $gpayed;
         $invoice = Invoice::find($id);
         $invoiceid = $invoice->id;
         $invoice->balance = $gamount - $gpayed;
         $invoice->amountpaid = $gpayed + $initpaid;
         $invoice->save();
         $reciept = new Receipt();
         $reciept->invoiceID = $invoice->id;
         $reciept->agent_id = $agent_id;
         $reciept->type = $invoice->type;
         $reciept->houseID = $invoice->houseID;
         $reciept->recipient = $invoice->recipient;
         $reciept->invoice_amt = $gpayed + $initpaid + $b;
         $reciept->amountpaid = $gpayed;
         $reciept->balance = $gamount - $gpayed;
         $reciept->duedate = $invoice->duedate;
         $reciept->save();
         $findTenant = $invoice->recipient;
         $ftname = strtok($findTenant, " ");
         $tenants = Tenant::where('name', $ftname)->get();
         foreach ($tenants as $tenant) {
             $t_name = $tenant->name;
             $to = $tenant->phone;
         }
         $payment = new Payment();
         $payment->invoiceID = Input::get('invoiceID');
         $payment->amount = Input::get('amount');
         $payment->amountpayed = Input::get('amountpayed');
         $payment->houseID = $findHouse;
         $payment->client = $invoice->recipient;
         $payment->property = $propertyName;
         $payment->balance = $gamount - $gpayed;
         $payment->paymenttype = Input::get('paymenttype');
         $payment->paymenttyperef = Input::get('paymenttyperef');
         $payment->save();
         #send an sms to the tenant
         $message = ' Hi ' . $t_name . ', Your payment of  Ksh. ' . number_format($gpayed, 2) . ' for invoice no. ' . $invoiceid . ' of ' . $findHouse . '   has been received successfully, due balance ' . number_format($balance, 2) . ', Thank you';
         Queue::push('SendSMS', array('message' => $message, 'number' => $to));
         return Redirect::route('show/receipts/index')->withFlashMessage('Payment received successfully');
     }
     return Redirect::back()->withInput()->withErrors($v)->with('message', 'There were validation errors');
 }
Exemplo n.º 10
0
 $lastmonth = date('Y-m-d', strtotime('+5 day', $startDate));
 $houses = House::where('status', '=', 'booked')->where('frequency', '=', 4)->get();
 foreach ($houses as $house) {
     $hid = $house->id;
     $houseName = $house->name;
     $propid = $house->propertyID;
     $propname = Property::where('id', $propid)->pluck('name');
     $rent = $house->rent;
     $water = $house->water;
     $garbage = $house->garbage;
     $electricity = $house->electricity;
     $security = $house->security;
     $frequency = $house->frequency;
     $tenant_id = $house->tenant;
     $tenantnames = strtok($tenant_id, " ");
     $tenant = Tenant::where('name', $tenantnames)->first();
     $t_name = $tenant->name;
     $to = $tenant->phone;
     $t_agent = $tenant->agent_id;
     $balance = $rent + $water + $garbage + $electricity + $security;
     $invoice = new Invoice();
     $invoice->type = 'to tenant';
     $invoice->houseID = $hid;
     $invoice->recipient = $t_name;
     $invoice->agent_id = $t_agent;
     $invoice->balance = $balance;
     $invoice->duedate = $lastmonth;
     $invoice->save();
     $invoicedetail = new Invoicedetail();
     $invoicedetail->rent = $rent;
     $invoicedetail->water = $water;
 /**
  * Remove the specified resource from storage.
  * DELETE /accountreceivables/{id}
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     $occupancy = Occupancy::find($id);
     $hrname = $occupancy->tenant;
     $hrid = $occupancy->houseID;
     $value = $hrname;
     $fname = strtok($value, " ");
     $tenant = Tenant::where('name', $fname)->first();
     $tenant->occupancy = 'false';
     $tenant->save();
     $house = House::find($hrid);
     $house->tenant = '';
     $house->status = '';
     $house->save();
     $occupancy->delete();
     return Redirect::route('occupancy');
 }