/** * 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'); $htenant = Input::get('tenant'); $invoice = new Invoice(); $invoice->type = Input::get('type'); $invoice->houseID = $hid; $invoice->recipient = $htenant; $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); $tenant_details = Tenant::where('name', $htenant)->get(); foreach ($tenant_details as $tenant_detail) { $number = $tenant_detail->phone; } #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'; LaravelAtApi::sendMessage($to, $message); return Redirect::intended('admin/invoice'); } return Redirect::back()->withInput()->withErrors($v)->with('message', 'There were validation errors'); }
/** * 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'); }
/** * 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'); }
public function fire($job, $data) { LaravelAtApi::sendMessage($data['number'], $data['message']); $job->delete(); }
/** * User create form processing. * * @return Redirect */ public function postCreate() { // Create a new validator instance from our validation rules $validator = Validator::make(Input::all(), $this->validationRules); // If validation fails, we'll exit the operation now. if ($validator->fails()) { // Ooops.. something went wrong return Redirect::back()->withInput()->withErrors($validator); } try { // We need to reverse the UI specific logic for our // permissions here before we create the user. $permissions = Input::get('permissions', array()); $this->decodePermissions($permissions); app('request')->request->set('permissions', $permissions); // Get the inputs, with some exceptions $inputs = Input::except('csrf_token', 'password_confirm', 'groups'); // Was the user created? if ($user = Sentry::getUserProvider()->create($inputs)) { // Assign the selected groups to this user foreach (Input::get('groups', array()) as $groupId) { $group = Sentry::getGroupProvider()->findById($groupId); $user->addGroup($group); $mail = Input::get('email'); $getu_id = \User::where('email', $mail)->first(); $user_id = $getu_id->id; $agent_id = Sentry::getUser()->id; $getu_id->created_by = $agent_id; $getu_id->update(); $passwordlogin = Input::get('password'); $maillogin = Input::get('email'); $fname = Input::get('first_name'); $to = Input::get('phone'); $message = ' Hi ' . $fname . ' Your Web ' . $group->name . ' username is ' . $maillogin . ' and the password: '******'.To logon Visit mteja.co.ke '; \LaravelAtApi::sendMessage($to, $message); if ($groupId == 3) { $user->addGroup($group); $tenant = new \Tenant(); $tenant->tenant_id = $user_id; $tenant->agent_id = $agent_id; $tenant->name = Input::get('first_name'); $tenant->lname = Input::get('last_name'); $tenant->phone = Input::get('phone'); $tenant->email = $mail; $tenant->save(); } else { if ($groupId == 1) { $user->addGroup($group); $owner = new \Owner(); $owner->owner_id = $user_id; $owner->agent_id = $agent_id; $owner->name = Input::get('first_name'); $owner->lname = Input::get('last_name'); $owner->phone = Input::get('phone'); $owner->email = $mail; $owner->save(); } } } // Prepare the success message $success = Lang::get('admin/users/message.success.create'); // Redirect to the new user page return Redirect::route('admin.invoice.index', $user->id)->withFlashMessage($group->name . ' Created successfully'); } // Prepare the error message $error = Lang::get('admin/users/message.error.create'); // Redirect to the user creation page return Redirect::route('create/user')->with('error', $error); } catch (LoginRequiredException $e) { $error = Lang::get('admin/users/message.user_login_required'); } catch (PasswordRequiredException $e) { $error = Lang::get('admin/users/message.user_password_required'); } catch (UserExistsException $e) { $error = Lang::get('admin/users/message.user_exists'); } // Redirect to the user creation page return Redirect::route('create/user')->withInput()->with('error', $error); }
foreach ($houses as $house) { $hid = $house->id; $houseName = $house->name; $rent = $house->rent; $water = $house->water; $garbage = $house->garbage; $frequency = $house->frequency; $tenant_id = $house->tenant; $tenant = Tenant::find($tenant_id); $t_name = $tenant->name; $to = $tenant->phone; $t_agent = $tenant->agent_id; $balance = $rent + $water + $garbage; $invoice = new Invoice(); $invoice->type = 'to tenant'; $invoice->houseID = $hid; $invoice->recipient = $t_name; $invoice->agent_id = $t_agent; $invoice->balance = $balance; $invoice->duedate = '2015/03/21'; $invoice->save(); $invoicedetail = new Invoicedetail(); $invoicedetail->rent = $rent; $invoicedetail->water = $water; $invoicedetail->garbage = $garbage; $invoice->invoicedetail()->save($invoicedetail); $message = ' Hi ' . $t_name . ', Your Monthly invoice of Ksh ' . number_format($balance, 2) . ' for ' . $houseName . ' is due .Please pay it in time.Thanks'; LaravelAtApi::sendMessage($to, $message); } return Redirect::intended('admin/invoice')->with('message', 'Annual invoice(s) generated successfully'); });