/**
  * Parses a string url into an array. Parsed urls will result in an automatic
  * redirection
  *
  * @param string $url The url to parse
  * @return boolean False on failure
  */
 public function parse($url)
 {
     $params = parent::parse($url);
     if ($params === false) {
         return false;
     }
     $Domains = new Domains();
     $subdomain = $Domains->getSubdomain();
     $masterDomain = Configure::read('Domain.Master');
     $defaultRoute = Configure::read('Domain.DefaultRoute');
     $Tenant = new Tenant();
     if (!$Tenant->domainExists($subdomain) && $params != $defaultRoute) {
         if (!$this->response) {
             $this->response = new CakeResponse();
         }
         debug($this->response);
         die;
         $status = 307;
         $redirect = $defaultRoute;
         $this->response->header(array('Location' => Router::url($redirect, true)));
         $this->response->statusCode($status);
         $this->response->send();
         $this->_stop();
     }
     return $subdomain;
 }
 public function actionSearchDataTenant()
 {
     $keyword = $_GET['term'];
     $model = new Tenant();
     $dataTenant = $model->GetDataTenant($keyword);
     $result = array();
     foreach ($dataTenant as $tenant) {
         $result[] = array('id' => $tenant->id_tenant, 'value' => $tenant->tenant_name, 'pic' => $tenant->pic, 'location' => $tenant->location, 'phone' => $tenant->phone);
     }
     echo CJSON::encode($result);
 }
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     $houses = House::where('status', '=', 'booked')->where('frequency', '=', 4)->get();
     foreach ($houses as $house) {
         $hid = $house->id;
         $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;
         $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);
     }
 }
 public function refundSelected($id)
 {
     $tenant = Tenant::find($id);
     $tname = $tenant->name . ' ' . $tenant->lname;
     $houses = House::where('tenant', $tname)->get();
     return View::make('backend.code.payment.againsttenant', compact('tenant', 'houses'));
 }
Exemple #5
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');
     }
 }
 public function actionGetTenant()
 {
     $keyword = $_GET['q'];
     $models = Tenant::model()->findAll(array('select' => 'id_tenant, tenant_name', 'condition' => 'tenant_name LIKE :keyword', 'params' => array(':keyword' => '%' . $keyword . '%'), 'order' => 'tenant_name', 'limit' => 5));
     $suggest = array();
     foreach ($models as $model) {
         $suggest[] = array('id' => $model->id_tenant, 'text' => $model->tenant_name);
     }
     echo CJSON::encode($suggest);
 }
 public function store()
 {
     //first create the user in the public schema
     $username = Input::get('username');
     $password = Hash::make(Input::get('password'));
     $data = array('username' => $username, 'password' => $password);
     $tenant = Tenant::create(['subdomain' => $username, 'password' => $password]);
     //fire the event that moves between schemas and creates the users table in the schema of this tenant
     Event::fire('tenant.create', [$data]);
     return 'your account was created successfully. You can access your admin panel in ' . $username . '.local.dev. Your data access is admin/[yourpassword]';
 }
 /**
  * Build records that will be used in rendering the reports
  * @param int $prop_id ID used to identify the property
  * @param string $start Date string specifying start of the period
  * @param sring $end Date string specifyinng end of the period
  * @return array $record_objects An array of record objects
  */
 public static function buildRecords($prop_id, $start, $end)
 {
     $room_count = Room::getNumRoomsForProperty($prop_id);
     $rooms = Room::findByPropertyId($prop_id);
     $record_objects = array();
     $aobj = new Arrears();
     for ($i = 0; $i < $room_count; $i++) {
         $record = new self();
         $rm = $rooms[$i];
         $record->room_label = $rm->getRoomLabel();
         if (!is_null($rm->getTenantId())) {
             $tenant = Tenant::findByRoomId($rm->id);
             $rent_obj = Rent::findByPeriodForTenant($tenant->id, $start, $end);
             $rent_paid = !is_null($rent_obj) ? $rent_obj->getPaymentAmount() : NULL;
             $receipt = !is_null($rent_obj) ? $rent_obj->getReceiptNo() : NULL;
             $remarks = !is_null($rent_obj) ? $rent_obj->getRemarks() : NULL;
             $arrears_paid = ArrearsPaid::calcAmountPaidByTenantDuringPeriod($tenant->id, $start, $end);
             $arrears = $aobj->calcTotalArrearsFromTenant($tenant->id);
             $deposit_obj = Deposit::findByPeriodForTenant($tenant->id, $start, $end);
             $deposit_paid = !is_null($deposit_obj) ? $deposit_obj->getPaymentAmount() : NULL;
             $kplc_obj = DepositKPLC::findByPeriodForTenant($tenant->id, $start, $end);
             $kplc_paid = !is_null($kplc_obj) ? $kplc_obj->getPaymentAmount() : NULL;
             $eldowas_obj = DepositEldowas::findByPeriodForTenant($tenant->id, $start, $end);
             $eldowas_paid = !is_null($eldowas_obj) ? $eldowas_obj->getPaymentAmount() : NULL;
             $totals = $tenant->calcPaymentsMadeDuringPeriod($start, $end);
             $record->tenant = $tenant->getFullName();
             $record->receipt_no = $receipt;
             $record->rent_pm = $rm->getRent();
             $record->rent_paid = $rent_paid;
             $record->arrears_paid = $arrears_paid;
             $record->arrears = $arrears;
             $record->house_deposit = $deposit_paid;
             $record->kplc_deposit = $kplc_paid;
             $record->eldowas_deposit = $eldowas_paid;
             $record->totals = $totals;
             $record->remarks = $remarks;
         } else {
             $record->tenant = "VACANT";
             $record->rent_pm = $rm->getRent();
         }
         $record_objects[] = $record;
     }
     return $record_objects;
 }
 /**
  * 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');
 }
 /**
  * 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

require_once '../lib/init.php';
if (!$session->isLoggedIn()) {
    redirect_to('../index.php');
}
if (isset($_GET['submit'])) {
    $name = $_GET['tenant'];
    if (empty($name) || $name == "Enter tenant name....") {
        $err = "Enter name of tenant to search for";
    } else {
        $tenants = Tenant::searchTenant($name);
    }
}
include_layout_template('admin_header.php');
?>

	<div id="container">
    <h3>Actions</h3>
    <div id="side-bar">
	<?php 
$actions = array("tenants" => "Tenants", "tenant_search" => "Search Tenant", "tenants_old" => "Previous Tenants");
echo create_action_links($actions);
?>
    </div>
	<div id="main-content">
    
    <h2>Search Results</h2>
    
    <div id="tenant-search">
    <fieldset>
    echo $property->getPropertyName();
    ?>
</p>
    </div>
    <table cellpadding="5" class="bordered">
    <thead>
    <tr>
        <th>Name of Tenant</th>
        <th>Room Label</th>
        <th>Business Name</th>
        <th>Details</th>
    </tr>
    </thead>
    <tbody>
    <?php 
    $tenants = Tenant::findByPropertyId($property->id);
    ?>
    <?php 
    foreach ($tenants as $tenant) {
        ?>
    <?php 
        $room = Room::findByTenantId($tenant->id);
        ?>
    <?php 
        /**echo "Tenant: ";
           echo "<tt></pre>".var_dump($tenant)."</pre></tt>";
           echo "Room: ";
           echo "<tt><pre>".var_dump($room)."</pre></tt>";*/
        ?>
    <tr>
        <td><?php 
<?php

require_once '../lib/init.php';
if (!$session->isLoggedIn()) {
    redirect_to('../index.php');
}
$properties = Property::findAll();
//////////////////////////////////////////////////////////////////////////////
/////////////////////////////// PROCESS SUBMIT ///////////////////////////////
//////////////////////////////////////////////////////////////////////////////
if (isset($_GET['submit'])) {
    $prop_id = $_GET['prop'];
    if (empty($prop_id)) {
        $err = "Select property from which to show previous tenants";
    } else {
        $tenants = Tenant::findPreviousByPropertyId($prop_id);
    }
}
include_layout_template('admin_header.php');
?>

	<div id="container">
    <h3>Actions</h3>
    <div id="side-bar">
	<?php 
$actions = array("tenants" => "Tenants", "tenant_search" => "Search Tenant");
echo create_action_links($actions);
?>
    </div>
    <div id="main-content">
    
Exemple #14
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getTenant()
 {
     return $this->hasOne(Tenant::className(), ['id' => 'tenant_id']);
 }
    </tr>
    <tr>
        <td><label for="receipt">Receipt No
        <span class="required-field">*</span></label></td>
        <td><input type="text" name="receipt" id="receipt" /></td>
        <td><input type="submit" name="submit" value="Search" /></td>
    </tr>
    </table>
    </form>        
    </div>
    
    <?php 
if (!empty($payment)) {
    ?>
    <?php 
    $tenant = Tenant::findById($payment->getTenantId())->getFullName();
    $room_no = Room::findByTenantId($payment->getTenantId())->getRoomLabel();
    ?>
    <table cellpadding="5" class="bordered">
    <thead>
    <tr>
    	<th>Name of Tenant</th>
        <th>Room No.</th>
        <th>Month</th>
        <th>Amount</th>
        <th>Receipt No</th>
        <th>Date Paid</th>
        <th>Agent</th>
    </tr>
    </thead>
    <tbody>
<?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);
});
 /**
  * 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');
 }
<?php

require_once '../lib/init.php';
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>App Real Estate</title>
</head>

<body>

 <?php 
//$user = new User();
$tenant = new Tenant();
$tenant->setFirstName('New');
$tenant->setLastName("Tenant");
$tenant->setEmail('*****@*****.**');
$tenant->setPhoneNumber('0719 644 479');
$tenant->setNationalIdNumber('29074310');
echo "<tt><pre>" . var_dump($tenant) . "</pre></tt>";
/**$sanitized_props = $user->_sanitizedProperties();
	echo "<tt><pre>".var_dump($sanitized_props)."</pre></tt>";*/
if ($tenant->save()) {
    $msg = "User details created";
} else {
    $msg = "Save failed";
}
echo "User ID: ";
echo $tenant->id;
 /**
  * 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');
 }
}
if (isset($_POST['submit'])) {
    $fname = $_POST['fname'];
    $lname = $_POST['lname'];
    $phone = $_POST['phone'];
    $id_num = $_POST['id_num'];
    $email = $_POST['email'];
    $business = $_POST['business'];
    $joined = $_POST['joined'];
    if (empty($fname) || empty($lname) || empty($phone) || empty($id_num) || empty($joined)) {
        $err = "Form fields marked with an asterix are required";
    } else {
        // Continue with processing
        $prop_id = (int) $session->sessionVar("prop_id");
        $room_id = (int) $session->sessionVar("room_id");
        $tenant = new Tenant();
        $tenant->setPropertyId($prop_id);
        $tenant->setRoomId($room_id);
        $tenant->setFirstName($fname);
        $tenant->setLastName($lname);
        $tenant->setPhoneNumber($phone);
        $tenant->setNationalIdNumber($id_num);
        if (!empty($email)) {
            $tenant->setEmail($email);
        }
        if (!empty($business)) {
            $tenant->setBusinessName($business);
        }
        $tenant->setDateJoined($joined);
        #echo var_dump($tenant);
        if ($tenant->createNewTenant($room_id)) {
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     Tenant::find($id)->delete();
     return Redirect::route('admin/tenant');
 }
Exemple #22
0
 /**
  * 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);
 }
 public static function getTenantProperty($applicationID, $tenantID, $userID, $property)
 {
     Log::debug('retrieving tenant property ' . $property . " for tenant ID=" . $tenantID, 1);
     $key = $applicationID . ":" . $tenantID . ":" . $property;
     $value = Cache::getValue($key);
     if (!$value) {
         // cache miss. Need to retrieve from database
         $class = new Tenant($userID, $tenantID);
         $query = '';
         if ($class->hasField($property)) {
             // this is one the fields on the tenant table
             $query = 'select ' . $property . ' from tenant where id=' . Database::queryNumber($tenantID);
         } else {
             // this might be a dynamically-set property
             $query = 'select value from tenantSetting where setting= ' . Database::queryString($property) . ' and tenantid=' . Database::queryNumber($tenantID);
         }
         $data = Database::executeQuery($query);
         if ($data) {
             if ($row = $data->fetch_row()) {
                 $value = $row[0];
             } else {
                 Log::debug('Warning: tenant property requested but not found: ' . $property . ' (tenantid= ' . $tenantID . ')', 5);
                 $value = '*undefined*';
             }
             Cache::putValue($key, $value);
         }
     }
     if ($value == '*undefined*') {
         // little dance we do here, so we can still cache the null
         $value = null;
     }
     return $value;
 }
 /**
  * Get oustanding arrears for a property during a specified
  * period of time
  * @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
  * @return array An array of Arrears objects
  */
 public static function getOutstandingArrearsForProperty($prop_id, $start, $end)
 {
     $arrears = static::findByPeriod($start, $end);
     $arrears_for_prop = array();
     for ($i = 0; $i < count($arrears); $i++) {
         $cur_bal = $arrears[$i];
         $tenant = Tenant::findById($cur_bal->getTenantId());
         if ($tenant->getPropertyId() == $prop_id) {
             $arrears_for_prop[] = $cur_bal;
         }
     }
     return $arrears_for_prop;
 }
if (!$session->isLoggedIn()) {
    redirect_to('../index.php');
}
if (!$ac->hasPermission('post_rent')) {
    $mesg = "You don't have permission to access this page";
    $session->message($mesg);
    redirect_to($_SERVER['HTTP_REFERER']);
}
if (isset($_GET['tid']) && !empty($_GET['tid'])) {
    $tenant_id = (int) $_GET['tid'];
    if (!is_int($tenant_id)) {
        $mesg = "Deposit payment could not be recorded. An invalid value was sent through URL";
        $session->message($mesg);
        redirect_to('tenants.php');
    } else {
        $tenant = Tenant::findById($tenant_id);
        // Check if tenant moved out
        if ($tenant->hasMovedOut()) {
            $mesg = "Invalid operation. This tenant already moved";
            $session->message($mesg);
            redirect_to("tenant.php?tid={$tenant_id}");
        }
        if ($tenant->hasPaidDeposit('house')) {
            $mesg = "Tenant has already paid house deposit";
            $session->message($mesg);
            redirect_to("tenant_deposit.php?tid={$tenant_id}");
        }
    }
}
/////////////////////////////////////////////////////////////////
///////////////////////// PROCESS SUBMIT ////////////////////////
 /**
  * Generate the HTML of the receipt print
  */
 public function buildArrearsReceipt()
 {
     global $session;
     $html = '<div id="outerHTML">';
     $html .= '<div id="printArea">';
     $html .= '<h2 align="center">Salesforce</h2>';
     $html .= '<h3 align="center">Official Receipt: Arrears Payment</h3>';
     $html .= '<div id="receipt-header">';
     $html .= '<p align="center">';
     $html .= 'Kenyatta Street, New Muya House<br />';
     $html .= '2<sup>nd</sup> Flr, Room 105.<br />';
     $html .= 'Tel: + 254 721 156 315 &nbsp; / &nbsp; + 254 720 711 115<br />';
     $html .= 'www.salesforce.co.ke &nbsp; Email: info@salesforce.co.ke';
     $html .= '</p></div>';
     $html .= '<hr align="center" />';
     $html .= '<div id="receipt-body">';
     $html .= '<p><strong>Receipt No:</strong> &nbsp;<span style="color:#F00;">';
     $html .= $this->_receipt_no;
     $html .= '</span></p>';
     $html .= '<p><strong>Tenant:</strong> &nbsp;';
     $tenant = Tenant::findById($this->_tid);
     $html .= $tenant->getFullName() . '</p>';
     $html .= '<p><strong>Room No:</strong> &nbsp;';
     $html .= Room::findById(Tenant::findById($this->_tid)->getRoomId())->getRoomLabel();
     $html .= '</p><p><strong>Payment Amount:</strong> &nbsp;';
     //$html .= number_format($session->sessionVar('amount'));
     $html .= number_format($this->_amount);
     if ($tenant->hasArrears()) {
         $arrears = new Arrears();
         $html .= '</p><p><strong>Arrears</strong>&nbsp;';
         $html .= $arrears->calcTotalArrearsFromTenant($this->_tid);
     }
     $html .= '</p><p><strong>Month:</strong>&nbsp;';
     $html .= $this->_getMonthFromDate($this->_start_date);
     $html .= '</p><p><strong>Company Agent:</strong> &nbsp;';
     $html .= $this->_agent . '</p>';
     $html .= '<p><strong>Date:</strong> &nbsp;';
     $html .= $this->_date_paid . " &nbsp;&nbsp;";
     $html .= '</p></div>';
     $html .= '</div></div>';
     print $html;
 }
    			echo "One Month<br />";	
    		} else {
    			echo "Not one month<br />";	
    		}
    		echo 'Valid Date Range: ';
    		echo var_dump(valid_date_range($start, $end));
    		echo 'Month One == Month Two: ';
    		echo var_dump($month_one == $month_two);*/
    if (empty($prop_id) || empty($start) || empty($end)) {
        $err = "Form fields marked with an asterix are required";
    } elseif (!valid_date_range($start, $end)) {
        $err = "Rent payment status of tenants can only be specified monthly. Specify a month by entering the start and end dates of the month";
    } else {
        $month = get_month_from_date($start);
        $property = Property::findById($prop_id);
        $tenants = Tenant::showPaymentStatusOfTenantsByProperty($prop_id, $start, $end);
    }
}
include_layout_template('admin_header.php');
?>

	<div id="container">
    <h3>Actions</h3>
    <div id="side-bar">
	<?php 
$actions = array("tenants" => "Tenants", "tenant_search" => "Search Tenant", "tenants_old" => "Previous Tenants", "payment_search" => "Search Payment");
echo create_action_links($actions);
?>
    </div>
    <div id="main-content">
    
Exemple #28
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;
 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;
 }
 public function processRepairRequest()
 {
     if (!Tenant::isAuthenticated()) {
         $this->redirect('/');
     } else {
         if (!isset($_FILES['image']) || empty($_FILES['image'])) {
             $this->redirect('/propertytenant/repairrequest');
         }
         $fileName = $_FILES['image']['name'];
         $uploadDir = WEBDIR . '/img/repair/';
         $target_file = $uploadDir . uniqid() . basename($fileName);
         if ($_FILES['image']['size'] > 0) {
             function random_string($length)
             {
                 $key = '';
                 $keys = array_merge(range(0, 9), range('a', 'z'));
                 for ($i = 0; $i < $length; $i++) {
                     $key .= $keys[array_rand($keys)];
                 }
                 return $key;
             }
             $tmpName = $_FILES['image']['tmp_name'];
             $fileSize = $_FILES['image']['size'];
             $fileType = $_FILES['image']['type'];
             $uploadOk = 1;
             // Check if image file is a actual image or fake image
             if (isset($_POST["submit"])) {
                 $check = getimagesize($fileName);
                 if ($fileSize > 0) {
                     echo "File is an image - " . $check["mime"] . ".";
                     $uploadOk = 1;
                 } else {
                     echo "File is not an image.";
                     $uploadOk = 0;
                 }
             }
             // Check if file already exists
             if (file_exists($target_file)) {
                 $uploadOk = 0;
             }
             // Check file size
             if ($fileSize > 2000000) {
                 echo "Sorry, your file is too large.";
                 $uploadOk = 0;
             }
             // Allow certain file formats
             if ($fileType != "image/jpg" && $fileType != "image/png" && $fileType != "image/jpeg" && $fileType != "image/gif") {
                 echo "Sorry, only JPG, JPEG, PNG and GIF files are allowed.";
                 $uqloadOk = 0;
             }
             // Check if $uqloadOk is set to 0 by an error
             if ($uploadOk == 0) {
                 //$this->view('tenant/payment');
                 echo "Sorry, your file was not uqloaded.";
                 // fie everything is ok, try to uqload file
             } else {
                 //$this->view('tenant/index');
                 $result_upload = move_uploaded_file($tmpName, '/Applications/XAMPP/htdocs' . $target_file);
             }
         }
         $result = $_SESSION['selectedProperty']->addRepairRequest($_POST['subject'], $_POST['description'], $_POST['severity'], $target_file);
         if ($result) {
             $this->redirect('/propertytenant/viewRepairs');
         } else {
             $this->redirect('/propertytenant/repairRequest');
         }
     }
 }