public static function sandbox() { // Testaa koodiasi täällä //View::make('helloworld.html'); $room = RentalUnit::find(2); $units = RentalUnit::search(); $amenities = Amenity::find_amenities_of_rental_unit(2); Kint::dump($room); Kint::dump($units); Kint::dump($amenities); }
public static function update_amenities_of($table, $id, $params) { if (Amenity::sanitized($table)) { Amenity::delete_amenities_of($table, $id); if (isset($params['amenities'])) { foreach ($params['amenities'] as $amenity) { if ($amenity) { Amenity::create($table, $id, $amenity); } } } } }
public static function updateLease($id, $leaseId) { $params = $_POST; if (parent::logged_in_user_is_landlord_of($id)) { $lease = new Lease(array('id' => $leaseId, 'tenant' => $params['tenant'], 'tenant_email' => $params['tenant_email'], 'rent' => $params['rent'], 'start_date' => $params['start_date'], 'end_date' => $params['end_date'], 'rental_unit' => $params['rental_unit'])); if ($lease->validate()) { $lease->update(); Amenity::update_amenities_of(Amenity::LEASE, $leaseId, $params); Redirect::to('/units/' . $params['rental_unit'], array('message' => 'lease updated')); } else { $errors = array_values($lease->errors()); Redirect::to('/units/' . $params['rental_unit'] . '/leases/' . $leaseId . '/edit', array('errors' => $errors, 'input' => $params, 'unit' => RentalUnit::find($params['rental_unit']))); } } Redirect::to('/units/' . $params['rental_unit'], array('message' => 'insufficient rights')); }
public static function updateUnit($id) { if (self::logged_in_user_is_landlord_of($id)) { $params = $_POST; $unit = RentalUnit::find($id); $unit->description_title = $params['description_title']; $unit->description = $params['description']; $unit->advertised_rent = $params['advertised_rent']; if ($unit->validate()) { $unit->updateUnit(); } else { $errors = array_values($unit->errors()); Redirect::to('/units/' . $unit->id, array('errors' => $errors)); } Amenity::update_amenities_of(Amenity::RENTAL_UNIT, $id, $params); Redirect::to('/units/' . $unit->id, array('message' => 'rental unit updated')); } Redirect::to('/units/' . $id, array('message' => 'insufficient rights')); }
function get_amenity($id = null) { App::import('Model', 'Amenity'); $objAmenity = new Amenity(); $arrData = $objAmenity->find("first", array("conditions" => array("Amenity.id" => $id), "order" => array('Amenity.name' => 'ASC'))); return $arrData['Amenity']['name']; }
public function changeamenitystatusAction() { global $mySession; $db = new Db(); $ptyleId = $_REQUEST['Id']; $status = $_REQUEST['Status']; if ($status == '1') { $status = '0'; } else { $status = '1'; } $myObj = new Amenity(); $Result = $myObj->statusAmenity($status, $ptyleId); exit; }