function delete() { $id = empty($_GET['id']) ? 0 : $_GET['id']; $_house = new House(); $_house->deleteById($id); echo "success"; }
public function actionDesertion(AbsTown $town, House $house) { $town->setGold(self::GOLD); $town->setWood(self::WOOD); $town->setStone(self::STONE); $town->setFood(self::FOOD); $town->setProsperity(self::PROSPERITY); $house->destroy($town); }
function get_one_premises() { $pid = empty($_GET['pid']) ? 0 : $_GET['pid']; $_premises = new Premises(); $premises = $_premises->findPremisesById($pid); $_house = new House(); $houses = $_house->findByPremisesId($pid); $premises['houses'] = $houses; header("Content-type: application/json; charset=utf-8"); echo json_encode($premises); }
/** * Display the specified resource. * * @param int $id * @return Response */ public function show($id) { $tenants = Tenant::findOrFail($id); $tname = $tenants->name; $houses = House::where('tenant', '=', $tname)->get(); return View::make('backend.code.tenants.show', compact('tenants', 'houses')); }
public function actionMore() { Yii::app()->clientScript->registerCssFile(Yii::app()->theme->baseUrl . '/css/enjoy.css'); $city_id = Yii::app()->request->getQuery('city', 0); $time_sort = Yii::app()->request->getQuery('time_sort', 'DESC'); $price_sort = Yii::app()->request->getQuery('lp_dol'); $criteria = new CDbCriteria(); $criteria->order = 'id DESC'; if (!empty($city_id)) { $criteria->addCondition('city_id=' . $city_id); } if (!empty($time_sort)) { $criteria->order = 'accessDate ' . $time_sort; } if (!empty($price_sort)) { $criteria->order = 'lp_dol ' . $price_sort; } $criteria->addCondition('lp_dol>3000000'); $count = House::model()->count($criteria); $pager = new CPagination($count); $pager->pageSize = 10; $pager->applyLimit($criteria); $house_list = House::model()->findAll($criteria); $subject_list = Subject::model()->findAll(array('order' => 'id DESC')); $cur_city = City::model()->findByPk($city_id); $data = array('house_list' => $house_list, 'subject_list' => $subject_list, 'cur_city' => $cur_city, 'count' => $count, 'time_sort' => $time_sort, 'price_sort' => $price_sort, 'pages' => $pager); $this->render('more', $data); }
public function __construct($name, $maxrooms, $default_price) { $id = Houses::MakeID($name); parent::__construct($id, $name, $maxrooms, $default_price, new Position(2485, -1690), new Position(2505, -1710), 20, new Position(2496.05, -1692.9301, 1014.7422, 180), 3); /* Interior ID */ parent::AddHouseEntrance('street', new Position(893.5016000000001, -1637.2668, 14.9297, 180)); }
/** * 录入 * */ public function actionCreate() { parent::_acl('house_create'); $original = Yii::app()->request->getQuery('original'); $model = new House(); $imageList = $this->_gets->getPost('imageList'); $imageListSerialize = XUtils::imageListSerialize($imageList); if (isset($_POST['House'])) { $model->attributes = $_POST['House']; $model->accessDate = strtotime($_POST['House']['accessDate']); $model->match = implode(',', $_POST['House']['match']); $file = XUpload::upload($_FILES['house_image']); if (is_array($file)) { $model->house_image = $file['pathname']; } $model->image_list = $imageListSerialize['dataSerialize']; if ($model->save()) { AdminLogger::_create(array('catalog' => 'create', 'intro' => '录入房源信息,ID:' . $model->id)); if (!empty($original)) { $this->redirect($original); } else { $this->redirect(array('index')); } } } $this->subject_list = parent::_groupList('subject'); $this->city_list = parent::_groupList('city'); $this->district_list = parent::_groupList('district'); $this->investType_list = parent::_groupList('investType'); $this->propertyType_list = parent::_groupList('propertyType'); $this->match_list = parent::_groupList('match'); $this->render('create', array('model' => $model, 'imageList' => $imageListSerialize['data'], 'original' => $original)); }
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')); }
/** * 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); } }
/** * Show the form for creating a new resource. * GET /housedue/create * * @return Response */ public function create() { $houses = House::all(); $receivables = Receivable::all(); $frequencies = Frequency::all(); return View::make('backend.code.housedue.create', compact('houses', 'receivables', 'frequencies')); }
function init($id) { $this->_hid = $id; require_once R_P . 'mode/house/require/core.php'; $houseService = house::loadClass('house'); $housefieldsService = House::loadService('HouseFieldsService'); $house = $houseService->getHouseInfoByHid($id); empty($house) && Showmsg('data_error'); $title = $content = sprintf("[url=%s] %s [/url]", $this->_url . "&q=info&hid=" . $this->_hid, $house['name']); $position = ''; if ($house['area']) { $areaField = $housefieldsService->getCompsiteFieldsByType('area'); //所属区域 $area = $areaField[$house['area']]; $area = sprintf("[url=%s] %s [/url]", $this->_url . "&q=list&area=" . $house['area'], $area); $postion .= $area; } if ($house['plate']) { $plateField = $housefieldsService->getCompsiteFieldsByType('plate'); //所在商圈 $plate = $plateField[$house['plate']]; $plate = sprintf("[url=%s] %s [/url]", $this->_url . "&q=list&plate=" . $house['plate'], $plate); $postion .= $plate; } $postion .= $house['address']; $mailSubject = getLangInfo('app', 'house_recommend'); $mailContent = getLangInfo('app', 'ajax_sendweibo_houseinfo', array('title' => $title, 'postion' => $postion)); $this->_content = $content; $this->_mailSubject = $mailSubject; $this->_mailContent = $mailContent; }
/** * 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'); }
/** * 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')); }
public function __construct($name, $maxrooms, $default_price) { $id = Houses::MakeID($name); parent::__construct($id, $name, $maxrooms, $default_price, new Position(1220, -730), new Position(1320, -830), 100, new Position(1258.2936, -838.6871, 1084.0078, 0), 5); /* Interior ID */ $this->AddHouseEntrance('main', new Position(1298.5369, -798.8372000000001, 83.8, 180)); $this->AddHouseEntrance('roof', new Position(1287.4863, -788.7426, 92.0313, 90), new Position(1261.4065, -785.6282, 1091.9063, 270)); $this->SetKitchen(new Position(1276.972, -813.8871, 1085.6328)); $this->SetFridgePos(new Position(1275.4027, -822.4887, 1085.6328)); $this->LoadObjectsFromFile('Madd_House.txt'); }
public function add() { if ($this->request->is('post') || $this->request->is('put')) { $this->Expense->create(); unset($this->request->data['Template']); $this->request->data['Expense']['date'] = $this->Expense->dateFormatBeforeSave($this->request->data['Expense']['date']); //pr($this->Expense->find('first')); //pr($this->request->data); //die(); //$this->Expense->unBindModel(array('belongsTo' => array('Buyer'))); //$this->Expense->unBindModel(array('belongsTo' => array('House'))); if ($this->Expense->saveAll($this->request->data, array('deep' => true))) { // mandar notificacion via email foreach ($this->request->data['Perro'] as $perro) { $users_idTo[$perro['user_id']] = $perro['user_id']; } $namesTo = $this->Expense->Buyer->find('list', array('fields' => array('Buyer.id', 'Buyer.full_name'), 'conditions' => array('Buyer.id' => $users_idTo))); $users_idTo[$this->request->data['Expense']['user_id']] = $this->request->data['Expense']['user_id']; $emailsTo = $this->Expense->Buyer->find('list', array('fields' => array('Buyer.id', 'Buyer.email'), 'conditions' => array('Buyer.id' => $users_idTo, 'Buyer.notifications' => 1))); $nameFrom = $this->Expense->Buyer->find('list', array('fields' => array('Buyer.id', 'Buyer.full_name'), 'conditions' => array('Buyer.id' => $this->request->data['Expense']['user_id']))); $houseName = $this->Expense->House->find('list', array('fields' => array('House.id', 'House.name'), 'conditions' => array('House.id' => $this->request->data['Expense']['house_id']))); $vars = array('page' => NAME_SYSTEM, 'type' => 'Registro de Gasto', 'data' => $this->request->data['Expense'], 'nameHouse' => implode('', $houseName), 'nameFrom' => implode('', $nameFrom), 'namesTo' => implode(', ', $namesTo), 'countTo' => count($namesTo)); $this->GenPassword->sendPassword('send_notification', 'Notifications', $emailsTo, $vars); // end mandar notificacion via email $this->Session->setFlash(__('Gasto almacenado correctamente.'), 'alert', array('plugin' => 'BoostCake', 'class' => 'alert-success')); //$this->redirect(array('action' => 'index')); } else { $this->Session->setFlash(__('El Gasto no se ha almacenado, intente de nuevo.'), 'alert', array('plugin' => 'BoostCake', 'class' => 'alert-danger')); } $this->redirect(array('action' => 'index')); } else { App::import('Model', 'Service'); $mService = new Service(); App::import('Model', 'House'); $mHouse = new House(); $users_id = $mHouse->query('SELECT user_id FROM houses_users WHERE house_id="' . $this->Session->read("Auth.User.House") . '"'); $users_id = Set::classicExtract($users_id, '{n}.houses_users.user_id'); $this->set(array('sessionHouse' => $this->Session->read("Auth.User.House"), 'houses' => $this->Expense->House->find("list"), 'users' => $this->Expense->Buyer->find('list', array('conditions' => array('Buyer.id' => $users_id, 'Buyer.active' => 1))), 'sessionUser' => $this->Session->read("Auth.User"), 'services' => $mService->find('list', array('conditions' => array('Service.active' => 1))))); } }
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')); }
/** * 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'); }
public function actionPeriod($start = null, $end = null) { /*if(is_null($start) || is_null($end)) { \Yii::$app->getSession()->setFlash('error', 'Не выбраны интервалы'); $this->redirect('/addressload/address/index'); }*/ $dateStart = (new \DateTime($start))->format('Y-m-d'); $dateEnd = (new \DateTime($end))->format('Y-m-d'); $cities[] = ['Load', 'Num of cities', 'Num of connected']; $streets[] = ['Load', 'Num of streets', 'Streets Without Houses', 'StreetsConnected']; $houses[] = ['Load', 'Num of houses', 'Houses connected']; foreach (City::findBySql("SELECT LOADDATE,CITIESTOTAL,CITIESWITHOUTSTREETS,CITIESCONNECTED FROM CITY WHERE LOADDATE BETWEEN TO_DATE('" . $dateStart . "','yyyy-mm-dd') AND TO_DATE('" . $dateEnd . "','yyyy-mm-dd')")->all() as $city) { $cities[] = [(string) $city->LOADDATE, (int) $city->CITIESTOTAL, (int) $city->CITIESWITHOUTSTREETS, (int) $city->CITIESCONNECTED]; } foreach (Street::findBySql("SELECT LOADDATE,STREETSTOTAL,STREETSWITHOUTHOUSES,STREETSCONNECTED FROM STREET WHERE LOADDATE BETWEEN TO_DATE('" . $dateStart . "','yyyy-mm-dd') AND TO_DATE('" . $dateEnd . "','yyyy-mm-dd')")->all() as $street) { $streets[] = [(string) $street->LOADDATE, (int) $street->STREETSTOTAL, (int) $street->STREETSWITHOUTHOUSES, (int) $street->STREETSCONNECTED]; } foreach (House::findBySql("SELECT LOADDATE,HOUSESTOTAL,HOUSESCONNECTED FROM HOUSE WHERE LOADDATE BETWEEN TO_DATE('" . $start . "','yyyy-mm-dd') AND TO_DATE('" . $end . "','yyyy-mm-dd')")->all() as $house) { $houses[] = [(string) $house->LOADDATE, (int) $house->HOUSESTOTAL, (int) $house->HOUSESCONNECTED]; } return $this->render('index', ['cities' => $cities, 'streets' => $streets, 'houses' => $houses]); }
public function index() { $countHousesByCities = $this->houseModel->countHousesByCities(); $numberHousesSell = $this->houseModel->getCountHousesSell(); $numberHousesRent = $this->houseModel->getCountHousesRent(); $numberProjects = $this->projectModel->getCountProjects(); $numberDesigns = $this->designModel->getCountDesigns(); $numberResources = $numberHousesSell + $numberHousesRent + $numberProjects + $numberDesigns; $ratioHousesSell = \Kan\Core\Num::ratio($numberHousesSell, $numberResources); $ratioHousesRent = \Kan\Core\Num::ratio($numberHousesRent, $numberResources); $ratioProjects = \Kan\Core\Num::ratio($numberProjects, $numberResources); $ratioDesigns = \Kan\Core\Num::ratio($numberDesigns, $numberResources); $countCitiesByQuantityAndHousesSell = $this->houseModel->getCountCitiesByQuantityAndHousesSell(); $countCitiesByQuantityAndHousesRent = $this->houseModel->getCountCitiesByQuantityAndHousesRent(); $countCitiesByQuantityAndProjects = $this->projectModel->getCountCitiesByQuantityAndProjects(); $countCitiesByQuantityAndDesigns = $this->designModel->getCountCitiesByQuantityAndDesigns(); return view('charts.index')->with('countHousesByCities', json_encode($countHousesByCities))->with('countResourcesByQuantity', json_encode([$numberHousesSell, $numberHousesRent, $numberProjects, $numberDesigns]))->with('ratioResourceByQuantity', json_encode([$ratioHousesSell, $ratioHousesRent, $ratioProjects, $ratioDesigns]))->with('countCitiesByQuantityAndHousesSell', json_encode($countCitiesByQuantityAndHousesSell))->with('countCitiesByQuantityAndHousesRent', json_encode($countCitiesByQuantityAndHousesRent))->with('countCitiesByQuantityAndProjects', json_encode($countCitiesByQuantityAndProjects))->with('countCitiesByQuantityAndDesigns', json_encode($countCitiesByQuantityAndDesigns)); }
public function destroy($id) { Property::find($id)->delete(); House::where('propertyID', $id)->delete(); House::where('propertyID', $id)->delete(); Housedue::where('propertyID', $id)->delete(); return Redirect::route('admin.property.index'); }
/** * Show the form for editing the specified resource. * GET /accountreceivables/{id}/edit * * @param int $id * @return Response */ public function edit($id) { $occupancies = House::with('occupancy')->where('id', $id)->get(); if (is_null($occupancies)) { return Redirect::route('admin.occupancy.index'); } return View::make('backend.code.occupancy.edit', compact('occupancies')); }
public static function getAdminHouseList($action, $per_page = 10, $current_page = 1) { if ($action == 'listActive') { $where = "f.status='" . REALTY_STATUS_ACTIVE . "'"; } else { if ($action == 'listNew') { $where = "f.status='" . REALTY_STATUS_APPLY . "'"; } } $start_pos = ($current_page - 1) * $per_page; $limit = " LIMIT {$start_pos},{$per_page}"; $amount = House::getAmountInList($where); $order = " ORDER BY id DESC"; $db_res = House::getFullListLink($where . $order . $limit); $paginator = self::paginator("house.php?action={$action}", $amount, $per_page, $current_page); $html = "\n\t\t<div>{$paginator}</div>\n\t\t<div><a href='house.html?action=activateAll'>Активировать все</a></div>\t\n\t\t<table class='base_text'>\n\t\t<thead>\n\t\t<tr>\n\t\t <th>Адрес</th>\n\t\t <th>Цена</th>\t\t \n\t\t <th>Тип дома</th>\n\t\t <th>Этажность</th>\n\t\t <th>Карта</th>\n\t\t <th>Юзер</th>\t\t \n\t\t <th></th>\n\t\t <th></th>\n\t\t <th></th>\n\t\t <th></th>\n\t\t</tr>\n\t\t</thead>\n\t\t<tbody>\n\t\t"; while ($row = $db_res->fetchRow()) { $type = House::$TYPE[$row['type_id']]; $city = $row['city_id'] == 0 ? '' : $row['city'] . ','; $addr = $city; $price = number_format($row['price'], 0); $map = $row['lat'] && $row['lon'] ? 'Да' : '<b>Нет</b>'; $user = ''; if ($row['user_name'] != '') { $user = $row['user_name']; } if ($row['company_name'] != '') { $user .= ' - ' . $row['company_name']; } $html .= "<tr>\n\t\t\t<td>{$addr}</td>\n\t\t\t<td>{$price}</td>\n\t\t\t<td>{$type}</td>\n\t\t\t<td>{$row['storeys']}</td>\n\t\t\t<td>{$map}</td>\n\t\t\t<td>{$user}</td>\n\t\t\t<td><a href='/house.html?action=edit&id={$row['id']}' target='_blank'>Редактировать</a></td>\t\t\t\n\t\t\t<td><a href='/house.html?action=view&id={$row['id']}' target='_blank'>Смотреть</a></td>\n\t\t\t<td><a href='javascript:delObject({$row['id']})'>Удалить</a></td>\n\t\t\t<td><a href='/house.html?action=approve&id={$row['id']}' target='_blank'>Активировать</a></td>\n\t\t\t</tr>"; } $html .= "</tbody></table>\n\t\t<script>\t\t\n\t\t\tdelObject = function(id) {\n\t\t\tif (confirm('Вы уверены удалить этот дом?')) {\n\t\t\t\tlocation.href = '/house.html?action=delete&id='+id;\n\t\t\t}\n\t\t\treturn 0;\n\t\t}\t\t\t\t\n\t\t</script>"; return $html; }
public function actionHouseNews() { Yii::app()->clientScript->registerCssFile(Yii::app()->theme->baseUrl . '/css/post.css'); $catalog_id = Yii::app()->request->getQuery('catalog_id', 11); $special_news = Post::model()->findAll(array('select' => 'id, title, summary', 'condition' => 'catalog_id = :catalog_id', 'params' => array(':catalog_id' => $catalog_id), 'order' => 'id DESC', 'limit' => 1)); $special_id = $special_news[0]->id; $criteria = new CDbCriteria(); $criteria->order = 'id DESC'; if (!empty($catalog_id)) { $criteria->addCondition('catalog_id=' . $catalog_id); } $criteria->addCondition('id!=' . $special_id); $count = Post::model()->count($criteria); $pager = new CPagination($count); $pager->pageSize = 30; $pager->applyLimit($criteria); $more_news = Post::model()->findAll($criteria); //房展会 $exhibition = Post::model()->findAll(array('select' => 'id, title, image', 'condition' => 'catalog_id=:catalog_id AND image<>""', 'params' => array(':catalog_id' => 10), 'order' => 'id DESC', 'limit' => 5)); //房展会 //学区房新闻 $school_distrcit_house_news = Post::model()->findAll(array('select' => 'id, title', 'condition' => 'catalog_id = :catalog_id', 'params' => array(':catalog_id' => 11), 'order' => 'id DESC', 'limit' => 5)); //房产热点新闻 $house_hotspots = Post::model()->findAll(array('select' => 'id, title, create_time,last_update_time', 'condition' => 'catalog_id = :catalog_id', 'params' => array(':catalog_id' => 12), 'order' => 'id DESC', 'limit' => 5)); //房产资讯 $house_zixun = Post::model()->findAll(array('select' => 'id, title, create_time,last_update_time', 'condition' => 'catalog_id = :catalog_id', 'params' => array(':catalog_id' => 10), 'order' => 'id DESC', 'limit' => 5)); $house_property_special_news = Post::model()->findAll(array('select' => 'id, title, summary', 'condition' => 'catalog_id = :catalog_id', 'params' => array(':catalog_id' => 13), 'order' => 'id DESC', 'limit' => 1)); $house_property_special_id = $house_property_special_news[0]->id; //房产置业宝典 $house_property = Post::model()->findAll(array('select' => 'id, title, create_time,last_update_time', 'condition' => 'catalog_id = :catalog_id AND id != :id', 'params' => array(':catalog_id' => 13, ':id' => $house_property_special_id), 'order' => 'id DESC', 'limit' => 5)); //最新学区房 $school_distrcit_house = House::model()->findAll(array('select' => 'id, name, house_image', 'condition' => 'investType_id = :investType_id', 'params' => array(':investType_id' => 1), 'order' => 'id DESC', 'limit' => 3)); $data = array('catalog_id' => $catalog_id, 'special_news' => $special_news[0], 'more_news' => $more_news, 'exhibition' => $exhibition, 'school_distrcit_house_news' => $school_distrcit_house_news, 'house_hotspots' => $house_hotspots, 'house_zixun' => $house_zixun, 'house_property_special_news' => $house_property_special_news[0], 'house_property' => $house_property, 'school_distrcit_house' => $school_distrcit_house, 'pages' => $pager); $this->render('house_news', $data); }
/** * csv文件的某一行数据导入到数据库 */ function import_db_line($file_name, $line) { $msg = ''; $state = 0; $n = 0; $handle = fopen($file_name, 'r'); while ($data = fgetcsv($handle, 10000)) { ++$n; $is_print_col = 0; //读取第一行 if (1 == $is_print_col) { $num = count($data); echo '<tr> ' . "\r\n"; echo '<td>' . $line . '</td>' . "\r\n"; for ($i = 0; $i < $num; $i++) { //echo '<td>'.iconv('gb2312', 'utf-8', $data[$i]).'</td>' . "\r\n"; //中文转码 $this->p($i . '行: ' . $data[$i]); } echo '</tr> ' . "\r\n"; } if ($line == $n) { $msg = '读取第' . $n . '行;'; $num = count($data); if ($num > 0) { $addr = trim($data[0]); $a_c = trim($data[1]); $yr_built = trim($data[2]); $sqft = trim($data[3]); $area = trim($data[4]); $area_code = trim($data[5]); $bsmt1_out = trim($data[6]); $bsmt2_out = trim($data[7]); $br = trim($data[8]); $br_plus = trim($data[9]); $central_vac = trim($data[10]); $community = trim($data[11]); $community_code = trim($data[12]); $cross_st = trim($data[13]); $elevator = trim($data[14]); $constr1_out = trim($data[15]); $constr2_out = trim($data[16]); $extras = trim($data[17]); $fpl_num = trim($data[18]); $comp_pts = trim($data[19]); $furnished = trim($data[20]); $gar_spaces = trim($data[21]); if ($location != '') { $local_zb = $this->actionGetCodeAddress2($location); $longitude = $local_zb['lng']; // 经度////////待定 $latitude = $local_zb['lat']; // 纬度////////待定 // p($longitude); // p($latitude); } $is_print_value = 0; //是否输入 读入的csv值 if (1 == $is_print_value) { p('名称: ' . $addr); p('总价: ' . $a_c); p('开发商: ' . $yr_built); p('所属项目: ' . $sqft); p('挂牌时间: ' . $area); p('地址: ' . $area_code); p('描述: ' . $bsmt1_out); p('房源图片: ' . $bsmt2_out); p('组图: ' . $br); p('房源视频路径: ' . $br_plus); p('作者: ' . $central_vac); p('是否推荐: ' . $community); p('城市: ' . $community_code); p('地区: ' . $cross_st); p('社区: ' . $elevator); p('投资类型: ' . $constr1_out); p('物业类型: ' . $constr2_out); p('土地面积: ' . $extras); p('房屋面积: ' . $fpl_num); p('房屋层数: ' . $comp_pts); p('卧室数量: ' . $furnished); p('卫生间数量: ' . $gar_spaces); } parent::_acl('house_create'); $model = new House(); $model->addr = $addr; //名称 必填 $model->a_c = $a_c; //总价 必填 $model->yr_built = $yr_built; //开发商 必填 $model->sqft = $sqft; //所属项目 必填 $model->area = $area; //挂牌时间 $model->area_code = $area_code; // 地址 $model->bsmt1_out = $bsmt1_out; // 地址 $model->bsmt2_out = $bsmt2_out; // 地址 $model->br = $br; // 地址 $model->br_plus = $br_plus; // 地址 $model->central_vac = $central_vac; // 地址 $model->community = $community; // 地址 $model->community_code = $community_code; // 地址 $model->cross_st = $cross_st; // 地址 $model->elevator = $elevator; // 地址 $model->constr1_out = $constr1_out; // 地址 $model->constr2_out = $constr2_out; // 地址 $model->extras = $extras; // 地址 $model->fpl_num = $fpl_num; // 地址 $model->comp_pts = $comp_pts; // 地址 $model->furnished = $furnished; // 地址 $model->gar_spaces = $gar_spaces; // 地址 $is_save = 1; //是否保存 if ($is_save == 1) { if ($model->save()) { //echo '导入数据成功!'; $msg = $msg . '导入数据成功!'; $state = 1; } else { //echo '导入数据失败!'; $msg = $msg . '导入数据失败!'; $state = 0; //print_r($model->errors); } } } break; } } fclose($handle); //关闭指针 unset($handle); return array('line' => $line, 'state' => $state, 'msg' => $msg, 'err' => $model->errors); unset($model); }
public function destroy($id) { House::find($id)->delete(); Invoice::find($id)->delete(); return Redirect::route('invoice'); }
public $for_sale = true; public function __construct($color = null) { if ($color) { $this->color = $color; } } public function add_room() { $this->rooms++; } public function sell() { $this->for_sale = false; } } $house = new House('red'); $house->add_room(); $house->add_room(); echo "This {$house->color} house has {$house->rooms} rooms. "; echo $house->for_sale ? "It is for sale." : "It is not for sale."; echo "<br>"; $house2 = new House(); $house2->add_room(); $house2->add_room(); $house2->add_room(); $house2->add_room(); $house2->add_room(); $house2->sell(); echo "This {$house2->color} house2 has {$house2->rooms} rooms. "; echo $house2->for_sale ? "It is for sale." : "It is not for sale.";
function sold() { $id=intval($_GET['id']); if (isset($_SESSION['user_id'])) { House::setUserStatus($id,$_SESSION['user_id'],REALTY_STATUS_SOLD); } else { if (!isset($_SESSION['admin'])) { echo "Not admin"; //header("Location: /index.html"); exit(); } house::setStatus($id,REALTY_STATUS_SOLD); } header("Location: ".$_SERVER['HTTP_REFERER']); exit(); }
public function actionGetMapHouse() { ini_set("log_errors", 1); ini_set("error_log", "/tmp/php-error.log"); $result = array(); if (empty($_POST)) { $result['IsError'] = true; $result['Message'] = '数据接收失败'; } else { $result['IsError'] = false; //根据条件查询地图 $criteria = new CDbCriteria(); $criteria->select = 'id,ml_num,zip,county,municipality,lp_dol,num_kit,construction_year,depth,front_ft,br,addr,house_image,longitude,latitude,area,bath_tot'; //Search By Lease or Sale if ($_POST['type'] == "rent") { $criteria->addCondition('s_r = "Lease"'); $ss = " AND s_r = 'Lease' "; } else { $criteria->addCondition('s_r = "Sale"'); $ss = " AND s_r = 'Sale' "; } /* 排序 * <span data-value="1">价格:从高到低</span> <span data-value="2">价格:从低到高</span> <span data-value="3">日期:从后到前</span> <span data-value="4">日期:从前到后</span> */ if ($_POST['orderby'] == 1) { $criteria->order = 't.lp_dol desc'; } else { if ($_POST['orderby'] == 2) { $criteria->order = 't.lp_dol asc'; } else { if ($_POST['orderby'] == 3) { $criteria->order = 't.construction_year asc'; } else { if ($_POST['orderby'] == 4) { $criteria->order = 't.construction_year desc'; } else { $criteria->order = 't.id desc'; } } } } //city_id - province //if (!empty($_POST['province']) && trim($_POST['country']) != 'undefined') { // // $criteria->addCondition("t.city_id = :city_id"); // $criteria->params += array(':city_id' => intval($_POST['province'])); //} //district_id // if (!empty($_POST['district']) && trim($_POST['district']) != 'undefined') { // $criteria->addCondition("t.district_id = :district_id"); // $criteria->params += array(':district_id' => intval($_POST['district'])); // } //卫生间数量 1-5 if (!empty($_POST['housebaths']) && intval($_POST['housebaths']) > 0) { $criteria->addCondition("t.bath_tot = :bath_tot"); $criteria->params += array(':bath_tot' => intval($_POST['housebaths'])); $ss = $ss . " AND bath_tot = " . $_POST['housebaths']; } //土地面积 if (!empty($_POST['houseground'])) { $ground = explode(',', $_POST['houseground']); $minGround = intval($ground[0]); $maxGround = intval($ground[1]); if ($minGround != 0 || $maxGround != 0) { if ($maxGround > $minGround) { $criteria->addCondition("t.depth*t.front_ft <= :maxGround"); $criteria->params += array(':maxGround' => $maxGround); } $criteria->addCondition("t.depth*t.front_ft >= :minGround"); $criteria->params += array(':minGround' => $minGround); } } //价格区间 if (!empty($_POST['houseprice'])) { $price = explode(',', $_POST['houseprice']); $minPrice = intval($price[0]) * 10000; $maxPrice = intval($price[1]) * 10000; if ($maxPrice != 0 || $minPrice != 0) { if ($maxPrice > $minPrice) { $criteria->addCondition("t.lp_dol <= :maxPrice"); $criteria->params += array(':maxPrice' => $maxPrice); $ss = $ss . " AND lp_dol <= " . $maxPrice; } $criteria->addCondition("t.lp_dol >= :minPrice"); $criteria->params += array(':minPrice' => $minPrice); $ss = $ss . " AND lp_dol >= " . $minPrice; } } //房型 if (!empty($_POST['houseroom']) && intval($_POST['houseroom']) > 0) { $houseroom = intval($_POST['houseroom']); if ($houseroom == '6') { $criteria->addCondition("t.br >= :br"); } else { if ($houseroom > 0) { $criteria->addCondition("t.br = :br"); } } $criteria->params += array(':br' => $houseroom); } //房屋类型 if (!empty($_POST['housetype']) && intval($_POST['housetype']) != 0) { $criteria->addSearchCondition('propertyType_id', $_POST['housetype']); $ss = $ss . " AND propertyType_id = " . $_POST['housetype']; } //根据地区名字搜索 //if (!empty($_POST['city']) && trim($_POST['city']) != '州名/市名(中英)') { // $city = trim($_POST['city']); // $criteria->addCondition("t.addr like '%" . $city . "%' OR b.pinyin like '%" . $city . "%' OR b.englishName like '%" . $city . "%'"); //} // //建造年份 if (!empty($_POST['houseyear'])) { //$year = explode(',', $_POST['houseyear']); $year = $_POST['houseyear']; //$minYear = intval($year[0]); // $maxYear = intval($year[1]); $criteria->addCondition("t.yr_built = :year"); $criteria->params += array(':year' => $year); } //lat and long selection if (!empty($_POST['bounds'])) { $latlon = explode(',', $_POST['bounds']); $minLat = floatval($latlon[0]); $maxLat = floatval($latlon[2]); $minLon = floatval($latlon[1]); $maxLon = floatval($latlon[3]); $criteria->addCondition("t.latitude <= :maxLat"); $criteria->params += array(':maxLat' => $maxLat); $criteria->addCondition("t.latitude >= :minLat"); $criteria->params += array(':minLat' => $minLat); $criteria->addCondition("t.longitude <= :maxLon"); $criteria->params += array(':maxLon' => $maxLon); $criteria->addCondition("t.longitude >= :minLon"); $criteria->params += array(':minLon' => $minLon); } $criteria->with = array('mname', 'propertyType', 'city'); //End of Condition //Check number of house group by city $sql = "\r\n\t\t\tSELECT count(*) c, h.municipality m , municipality_cname cn,\tm.lat lat,m.lng lng\r\n\t\t\tFROM h_house h,h_mname m\r\n\t\t\tWHERE latitude <=" . $maxLat . "\r\n\t\t\tAND latitude >=" . $minLat . "\r\n\t\t\tAND longitude <=" . $maxLon . "\r\n\t\t\tAND longitude >=" . $minLon . $ss . "\r\n\t\t\t\r\n\t\t\tAND h.municipality = m.municipality\r\n\t\t\tGROUP BY m\r\n\t\t\tORDER BY c DESC\t"; $db = Yii::app()->db; $groupresult = $db->createCommand($sql)->query(); $citytotal = 0; $citylimit = 20; //control how many city marker displayed $result['Data']['AreaHouseCount'] = array(); $result['Data']['MapHouseList'] = array(); if (count($groupresult) > 0) { $cityint = 0; foreach ($groupresult as $citycount) { $result['Message'] = '成功'; $count = $citycount["c"]; $city = $citycount["m"]; $lat = $citycount["lat"]; $lng = $citycount["lng"]; ++$cityint; $citytotal += $count; if ($lat > 20 && $cityint < $citylimit) { //error_log($city.":".$count.":".$cityint); $result['Data']['AreaHouseCount'][$city]['Count']['NameCn'] = !empty($citycount["cn"]) ? $citycount["cn"] : "其他"; $result['Data']['AreaHouseCount'][$city]['Count']['HouseCount'] = $count; $result['Data']['AreaHouseCount'][$city]['Count']['GeocodeLat'] = $lat; $result['Data']['AreaHouseCount'][$city]['Count']['GeocodeLng'] = $lng; //$result['Data']['AreaHouseCount'][$val->municipality]['Count'] ['MaxZoom'] = 2; //$result['Data']['AreaHouseCount'][$val->municipality]['List'][] = $mapHouseList; } $result['Data']['Total'] = $citytotal; } //error_log("Total:".$citytotal); } //End of check $maxmarkers = 2000; if ($citytotal < $maxmarkers) { $house = House::model()->findAll($criteria); $totalcount = count($house); $result['Data']['Total'] = $totalcount; $result['Message'] = '成功'; foreach ($house as $val) { $mapHouseList = array(); $mapHouseList['Beds'] = $val->br; $mapHouseList['Baths'] = $val->bath_tot; $mapHouseList['Kitchen'] = $val->num_kit; $mapHouseList['GeocodeLat'] = $val->latitude; $mapHouseList['GeocodeLng'] = $val->longitude; $mapHouseList['Address'] = $val->addr; $mapHouseList['sqft'] = $val->sqft; $mapHouseList['Price'] = $val->lp_dol / 10000; $mapHouseList['Id'] = $val->id; $mapHouseList['HouseType'] = !empty($val->propertyType->name) ? $val->propertyType->name : '其他'; $mapHouseList['MunicipalityName'] = !empty($val->mname->municipality_cname) ? $val->mname->municipality_cname : "其他"; $mapHouseList['CountryName'] = $val->municipality; $mapHouseList['Zip'] = $val->zip; $mapHouseList['Country'] = $val->city_id; $mapHouseList['ProvinceEname'] = $val->county; $mapHouseList['ProvinceCname'] = $val->city->name; $mapHouseList['Money'] = 'CAD'; //$area2Name = District::model()->findByPk($val->district_id); $mapHouseList['Area2Name'] = !empty($area2Name) ? $area2Name->name : ''; //Get image from county $county = $val->county; $county = preg_replace('/\\s+/', '', $county); $county = str_replace("&", "", $county); $dir = "mlspic/crea/" . $county . "/Photo" . $val->ml_num . "/"; $num_files = 0; if (is_dir($dir)) { $picfiles = scandir($dir); $num_files = count(scandir($dir)) - 2; } //error_log($county.":".$dir); if ($num_files > 1) { $mapHouseList['CoverImg'] = $dir . $picfiles[2]; } else { $mapHouseList['CoverImg'] = 'uploads/201501/29cd77e5f187df554a1ff9facdc190e2.jpg'; } //$mapHouseList['CoverImg'] = !empty($val->house_image) ? $val->house_image : 'uploads/201501/29cd77e5f187df554a1ff9facdc190e2.jpg'; $mapHouseList['BuildYear'] = $val->yr_built; $result['Data']['MapHouseList'][] = $mapHouseList; } } } //error_log(json_encode($result)) ; echo json_encode($result); }
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')); }
function activateAll() { House::setStatusMass("status=".REALTY_STATUS_APPLY,REALTY_STATUS_SALE); header("Location: ".$_SERVER['HTTP_REFERER']); exit(); }