/** * Display the specified resource. * GET /accountreceivables/{id} * * @param int $id * @return Response */ public function show($id) { $invoices = Invoice::with('invoicedetail')->find($id); if ($invoices->type === "to tenant") { $total = $invoices->invoicedetail->rent + $invoices->invoicedetail->water + $invoices->invoicedetail->electricity + $invoices->invoicedetail->security + $invoices->invoicedetail->service + $invoices->invoicedetail->garbage; } elseif ($invoices->type === "refund") { $total = $invoices->invoicedetail->rentD + $invoices->invoicedetail->waterD + $invoices->invoicedetail->electricityD + $invoices->invoicedetail->g_repairs + $invoices->invoicedetail->transport_cost + $invoices->invoicedetail->o_bills + $invoices->invoicedetail->storage_fees + $invoices->invoicedetail->fixed_unit; } elseif ($invoices->type === "deposits") { $total = $invoices->invoicedetail->rentD + $invoices->invoicedetail->waterD + $invoices->invoicedetail->electricityD + $invoices->invoicedetail->g_repairs + $invoices->invoicedetail->transport_cost + $invoices->invoicedetail->o_bills + $invoices->invoicedetail->storage_fees + $invoices->invoicedetail->fixed_unit + $invoices->invoicedetail->rent; } $houseid = $invoices->id; $hid = $invoices->houseID; $housename = House::where('id', $hid)->pluck('name'); $propertyid = House::where('id', $hid)->pluck('propertyID'); $propertyname = Property::where('id', $propertyid)->pluck('name'); $allbal = Invoice::where('houseID', $hid)->sum('balance'); if ($invoices->amountpaid <= 0) { $outstandingbal = $allbal; } else { $outstandingbal = $allbal - $invoices->balance; } $balance = $invoices->balance; if ($outstandingbal == $invoices->balance) { $amountdue = $invoices->balance; } else { $amountdue = $invoices->balance + $outstandingbal; } $title = "Print Invoice"; return View::make('backend.code.invoice.show', compact('invoices', 'housename', 'title', 'outstandingbal', 'propertyname', 'invoicedetails', 'total', 'balance', 'amountdue')); }
/** * Store a newly created resource in storage. * POST /properties * * @return Response */ public function store() { $input = Input::all(); $v = Validator::make(Input::All(), array('name' => 'required|max:50|', 'description' => 'required|max:400|min:10', 'ownerID' => 'required')); if ($v->passes()) { $agent_id = Sentry::getUser()->id; $property = new Property(); $property->name = Input::get('name'); $property->description = Input::get('description'); $property->ownerID = Input::get('ownerID'); $property->agent_id = $agent_id; $property->save(); $newprop = Property::where('name', Input::get('name'))->first(); $newprop_id = $newprop->id; foreach (Input::get('CBgroup1', array()) as $value) { $housedue = new Housedue(); $housedue->propertyID = $newprop_id; $housedue->receivable = $value; $converted = strtolower(preg_replace("/[[:blank:]]+/", "_", $value)); $housedue->db_name = $converted; $housedue->save(); } return Redirect::intended('admin/property'); } return Redirect::back()->withInput()->withErrors($v)->with('message', 'There were validation errors'); }
/** * Display the specified resource. * GET /accountreceivables/{id} * * @param int $id * @return Response */ public function show($id) { $housedues = Housedue::findOrFail($id); $houseduepid = $housedues->propertyID; $propetyName = Property::where('id', $houseduepid)->pluck('name'); return View::make('backend.code.housedue.show', compact('housedues', 'propetyName')); }
/** * Update the specified resource in storage. * PUT /properties/{id} * * @param int $id * @return Response */ public function update($id) { $property = Property::where('id', $id)->update(Input::all()); if ($property) { return ['status' => true, 'property' => $property]; } else { return ['status' => false]; } }
public function main() { $data['properties'] = Property::where('status', 1)->orderBy('created_at', 'desc')->limit(3)->get(); View::share('page_title', 'Homepage'); View::share('sliders', Property::where('status', 1)->orderBy(DB::raw('RAND()'))->limit(10)->get()); View::share('sidebar', true); View::share('homepage', true); return View::make('public.home', $data); }
public static function got_property($id) { $property = Property::where('location_id', '=', $id); if ($property->count() > 0) { return true; } else { return false; } }
/** * 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'); }
public function showReceipt($id) { $receipts = Receipt::find($id); $hid = $receipts->houseID; $housename = $hid; $propertyid = House::where('name', $hid)->pluck('propertyID'); $propertyname = Property::where('id', $propertyid)->pluck('name'); $inid = $receipts->invoiceID; $allbal = Invoice::where('houseID', $hid)->sum('balance'); $current_bal = Invoice::where('id', $inid)->pluck('balance'); $outstandingbal = $allbal - $current_bal; $amountdue = $allbal; $balance = $receipts->balance; return View::make('backend.code.invoice.showr', compact('receipts', 'amountdue', 'housename', 'outstandingbal', 'propertyname', 'invoicedetails', 'total', 'balance', 'amountdue')); }
public function getPreview($template, $type = null) { $prop = Property::where('brchead', 'exists', true)->where('brchead', '!=', '')->first()->toArray(); //print_r($prop); //die(); //return View::make('print.brochure')->with('prop',$prop)->render(); if (!is_null($type) && $type != 'pdf') { $content = View::make('brochuretmpl.' . $template)->with('prop', $prop)->render(); return $content; } else { //return PDF::loadView('print.brochure',array('prop'=>$prop)) // ->stream('download.pdf'); return PDF::loadView('brochuretmpl.' . $template, array('prop' => $prop))->setOption('margin-top', '0mm')->setOption('margin-left', '0mm')->setOption('margin-right', '0mm')->setOption('margin-bottom', '0mm')->setOption('dpi', 200)->setPaper('A4')->stream($prop['propertyId'] . '.pdf'); //return PDF::html('print.brochure',array('prop' => $prop), 'download.pdf'); } }
$sdata = array('sequence' => $nseq, 'propertyId' => Config::get('ia.property_id_prefix') . $nseq); if ($property->where('_id', '=', $_id)->update($sdata)) { print $p['_id'] . '->' . $sdata['propertyId'] . '<br />'; } } }); Route::get('tonumber', function () { $property = new Property(); $props = $property->get()->toArray(); $seq = new Sequence(); foreach ($props as $p) { $_id = new MongoId($p['_id']); $price = new MongoInt32($p['listingPrice']); $fmv = new MongoInt32($p['FMV']); $sdata = array('listingPrice' => $price, 'FMV' => $fmv); if ($property->where('_id', '=', $_id)->update($sdata)) { print $p['_id'] . '->' . $sdata['listingPrice'] . '<br />'; } } }); Route::get('regeneratepic/{obj?}', function ($obj = null) { set_time_limit(0); if (is_null($obj)) { $product = new Product(); } else { switch ($obj) { case 'product': $product = new Product(); break; case 'page': $product = new Page();
/** * Show the form for editing the specified resource. * GET /accountreceivables/{id}/edit * * @param int $id * @return Response */ public function edit($id) { $invoices = Invoice::find($id); $hid = $invoices->houseID; $housename = $hid; $propertyid = House::where('name', $hid)->pluck('propertyID'); $propertyname = Property::where('id', $propertyid)->pluck('name'); if (is_null($invoices)) { return Redirect::route('invoice.index'); } return View::make('backend.code.invoice.edit', compact('invoices', 'properties', 'housename', 'propertyid', 'propertyname')); }
/** * Display a listing of the resource. * GET /properties * * @return Response */ public function index() { $properties = Property::where('agent_id', '=', Sentry::getUser()->id)->get(); return View::make('backend.code.property.index', compact('properties'))->with('message', 'Select a property to create Units'); }
$user->save(); }); Route::post('request_location', function () { if (Request::ajax()) { $location = strtolower(Input::get('location')); $all_types = Type::all(); $all_developers = Developer::all(); $response = array('count' => 0, 'types' => array(0 => 'Any'), 'developers' => array(0 => 'Any')); foreach ($all_types as $a) { $response['types'][$a->id] = ucwords($a->name); } foreach ($all_developers as $a) { $response['developers'][$a->id] = ucwords($a->name); } // LETS FIND PROPERTIES WITH $properties = Property::where('location_id', $location)->get(); $count = count($properties); if ($count > 0) { $response['count'] = 1; $response['types'] = array(0 => 'Any'); $response['developers'] = array(0 => 'Any'); foreach ($properties as $p) { if (!in_array($p->type->id, array_keys($response["types"]))) { $response['types'][$p->type->id] = ucwords($p->type->name); } if (!in_array($p->developer->id, array_keys($response["developers"]))) { $response['developers'][$p->developer->id] = ucwords($p->developer->name); } } } header("content-type:application/json");
return Redirect::to("Villa_General_Belgrano/Propiedad/{$id}/{$nombre}"); } }); Route::get('/Casas', array('as' => 'casas', 'uses' => 'PropertiesController@listCasas')); Route::get('/Locales', array('as' => 'locales', 'uses' => 'PropertiesController@listLocales')); Route::get('/Complejos', array('as' => 'complejos', 'uses' => 'PropertiesController@listComplejos')); Route::get('/Departamentos', array('as' => 'departamentos', 'uses' => 'PropertiesController@listDepartamentos')); Route::get('/Terrenos', array('as' => 'terrenos', 'uses' => 'PropertiesController@listTerrenos')); Route::get('/Fondos_de_Comercio', array('as' => 'fondos de comercio', 'uses' => 'PropertiesController@listFondosComercio')); Route::get('/Fondos de Comercio', array('as' => 'fondos de comercio2', 'uses' => 'PropertiesController@listFondosComercio')); Route::get('/Alquileres_Permanantes', array('as' => 'alquileres_permanentes', 'uses' => 'PropertiesController@listAlquileresPermanentes')); Route::get('/Alquileres_Temporarios', array('as' => 'alquileres_temporarios', 'uses' => 'PropertiesController@listAlquileresTemporarios')); Route::get('/Oportunidades', array('as' => 'oportunidades', 'uses' => 'PropertiesController@listOportunidades')); }); Route::get('/', function () { $properties = Property::where('homepage', '=', 1)->get(); return View::make('index2', array('properties' => $properties)); }); Route::get('/contacto', function () { return View::make('contacto'); }); Route::post('/contacto', function () { $rules = array('nombre' => 'required|min:3', 'telefono' => 'required|min:5', 'email' => 'required|email', 'consulta' => 'required|min:5'); $messages = array('required' => 'El campo :attribute es obligatorio', 'email' => 'El email ingresado no es vĂ¡lido', 'min' => 'El campo :attribute debe tener al menos :min caracteres'); $validator = Validator::make(Input::all(), $rules, $messages); if ($validator->fails()) { return Redirect::to("/contacto")->withErrors($validator)->withInput(); } else { $input = Input::all(); $input = array('nombre' => $input['nombre'], 'telefono' => $input['telefono'], 'email' => $input['email'], 'consulta' => $input['consulta']); Mail::send('emails.consulta', $input, function ($message) {
$invoicedetail->security = $security; $invoice->invoicedetail()->save($invoicedetail); $message = ' Hi ' . $t_name . ', this is to notify you that your invoice of Ksh ' . number_format($balance, 2) . ' for ' . $propname . ' unit ' . $houseName . ' is due on ' . $lastmonth . '.Thanks'; Queue::push('SendSMS', array('message' => $message, 'number' => $to)); } return 'Semi-annually invoice(s) generated successfully'; }); Route::get('/cron/run/annualy/lvWVYpnQ7xqFLbjaoG1oDUlTHQ4GMlmx', function () { $startDate = time(); $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';
public function createProperty() { $input = Input::all(); $v = Validator::make(Input::All(), array('name' => 'required|max:50|', 'ownerID' => 'required', 'CBgroup1' => 'required', 'agent_id' => 'required')); if ($v->passes()) { $agent_id = Input::get('agent_id'); $properties = Owner::where('agent_id', $agent_id)->get(); if (!$properties->isEmpty()) { $property = new Property(); $property->name = Input::get('name'); $property->ownerID = Input::get('ownerID'); $property->agent_id = $agent_id; $property->save(); $newprop = Property::where('name', Input::get('name'))->first(); $newprop_id = $newprop->id; $payment = Input::get('CBgroup1'); $fields = preg_split("/[\\s,]+/", $payment); $arrlength = count($fields); for ($x = 0; $x < $arrlength; $x++) { $housedue = new Housedue(); $housedue->propertyID = $newprop_id; $converted = ucfirst(preg_replace("/[[:blank:]]+/", " ", $fields[$x])); $housedue->receivable = $converted; $housedue->db_name = $fields[$x]; $housedue->save(); } $noteProperty2 = array('error' => false, 'message' => 'Property Created Successfully'); return $noteProperty2; } $noteProperty3 = array('error' => true, 'message' => 'Only owners are allowed to create properties'); return $noteProperty3; } $noteProperty4 = array('error' => true, 'message' => $v->messages()); return $noteProperty4; }
public function showSpeReceipts($id) { $invoices = Invoice::with('invoicedetail')->find($id); if ($invoices->type === "to tenant") { $total = $invoices->invoicedetail->rent + $invoices->invoicedetail->water + $invoices->invoicedetail->electricity + $invoices->invoicedetail->security + $invoices->invoicedetail->service + $invoices->invoicedetail->garbage; } elseif ($invoices->type === "refund") { $total = $invoices->invoicedetail->rentD + $invoices->invoicedetail->waterD + $invoices->invoicedetail->electricityD + $invoices->invoicedetail->g_repairs + $invoices->invoicedetail->transport_cost + $invoices->invoicedetail->o_bills + $invoices->invoicedetail->storage_fees + $invoices->invoicedetail->fixed_unit; } elseif ($invoices->type === "deposits") { $total = $invoices->invoicedetail->rentD + $invoices->invoicedetail->waterD + $invoices->invoicedetail->electricityD + $invoices->invoicedetail->g_repairs + $invoices->invoicedetail->transport_cost + $invoices->invoicedetail->o_bills + $invoices->invoicedetail->storage_fees + $invoices->invoicedetail->fixed_unit + $invoices->invoicedetail->rent; } $houseid = $invoices->id; $hid = $invoices->houseID; $housename = House::where('id', $hid)->pluck('name'); $tenantname = House::where('id', $hid)->pluck('tenant'); $propertyid = House::where('id', $hid)->pluck('propertyID'); $propertyname = Property::where('id', $propertyid)->pluck('name'); $allbal = Invoice::where('houseID', $hid)->sum('balance'); if ($invoices->amountpaid <= 0) { $outstandingbal = $allbal; } else { $outstandingbal = $allbal - $invoices->balance; } $balance = $invoices->balance; if ($outstandingbal == $invoices->balance) { $amountdue = $invoices->balance; } else { $amountdue = $invoices->balance + $outstandingbal; } $title = "Print Receipt"; /* $emailcontent = array ( 'propertyname'=> $propertyname, 'housename'=> $housename, 'tenant'=> $tenantname, 'tfname'=> $invoices->recipient, 'invoiceid'=> $invoices->id, 'created_at'=> $invoices->created_at, 'invoicetype'=> $invoices->type, 'rent'=> $invoices->invoicedetail->rent, 'water'=> $invoices->invoicedetail->water, 'electricity'=> $invoices->invoicedetail->electricity, 'security'=> $invoices->invoicedetail->security, 'service'=> $invoices->invoicedetail->service, 'garbage'=> $invoices->invoicedetail->garbage, 'rentD'=> $invoices->invoicedetail->rentD, 'rent'=> $invoices->invoicedetail->rent, 'waterD'=> $invoices->invoicedetail->waterD, 'electricityD'=> $invoices->invoicedetail->electricityD, 'garbage'=> $invoices->invoicedetail->garbage, 'transport_cost'=> $invoices->invoicedetail->transport_cost, 'g_repairs'=> $invoices->invoicedetail->g_repairs, 'o_bills'=> $invoices->invoicedetail->o_bills, 'storage_fees'=> $invoices->invoicedetail->storage_fees, 'total'=> $total, 'amountpaid'=> $invoices->amountpaid, 'balance'=> $balance, 'outstandingbal'=> $outstandingbal, 'amountdue'=> $amountdue, 'duedate'=> $invoices->duedate ); Mail::send('emails.receipts', $emailcontent, function($message) { $message->to('*****@*****.**') ->subject('Receipts'); }); */ return View::make('backend.code.invoice.show', compact('invoices', 'title', 'housename', 'outstandingbal', 'propertyname', 'invoicedetails', 'total', 'balance', 'amountdue')); }
<?php Event::listen('log.a', function ($class, $method, $actor, $result) { $data = array('timestamp' => new MongoDate(), 'class' => $class, 'method' => $method, 'actor' => $actor, 'result' => $result); Activelog::insert($data); return true; }); Event::listen('cleanup', function () { $last = new MongoDate(time() - Config::get('ia.reserveTimeOut')); $props = Property::where('locked', '=', 1)->where('reservedAt', '<', $last)->get(); foreach ($props as $property) { $property->propertyStatus = $property->propertyLastStatus; $property->reservedBy = ''; $property->reservedAt = ''; $property->lock = 0; $property->save(); } return true; });