public function execute() { $this->getInput(); $view = $this->getGlobalData()->getView(); $action = $this->action; // Show the list of settlements; $view->op_type = $this->operation_type; if ($action == 'firstpage') { $view->viewmode = 'firstpage'; $list = new RealEstateAgency_Object_SettlementList(); $list->setGlobalData($this->getGlobalData()); $list->setAreaId(1); $list->loadBy(); $view->list_of_links = $list->getArray(); } else { if ($action == 'secondpage') { $this->secondPage($view); //$view->settlement_name = $this->getSettlementName(); } else { if ($action == 'submit') { $view->viewmode = 'show'; $obj = new RealEstateAgency_Object_RealEstateObject(); $obj->setGlobalData($this->getGlobalData()); $brokerID = $this->getGlobalData()->getLoginObject()->getLoggedUserID(); $obj->setBrokerID($brokerID); //tools_log_debug($this->getGlobalData(),"validate reo",tools_get_input('op_type')); $obj->readWebForm(); $obj->toWebForm($view); $validation = $obj->validate(); if (count($validation) > 0) { $view->validation = $validation; $this->secondPage($view); //$view->settlement_name = $this->getSettlementName(); } else { // Submit; $view->settlement_name = $this->getSettlementName(); $time = tools_date2database(time()); $obj->setDateOfStart($time); $obj->setDateOfUpdate($time); if (!$this->do_not_save) { $obj->insert(); } } } } } }
public function test() { require_once 'RealEstateAgency/GlobalData.php'; $globalData = new RealEstateAgency_GlobalData(); $object = new RealEstateAgency_Object_RealEstateObject(); $object->setGlobalData($globalData); $object->setObjectID(NULL); $object->setBrokerID(1); $object->setDateOfStart(tools_date2database(time())); $object->setDateOfUpdate(NULL); $object->setPrice(10000); $object->setObjectType(3); $object->setRooms(5); $object->setRoomsType(1); $object->setSettlementID(1); $object->setLocationText("Альтернативне місцезнаходження"); $object->setSettlementAreaID(1); $object->setStreet("Оболонський просп."); $object->setHouseNumber('15a'); $object->setSquareAll(100.5); $object->setSquareLive(90.5); $object->setSquareKitchen(10.5); $object->setFloor(1); $object->setFloors(16); $object->setExternal(1); $object->setWcNumber(1); $object->setBathNumber(2); $object->setTelType(1); $object->setDescription("Якийсь додатковий опис."); $object->insert(); $obj_id = $object->getObjectID(); sleep(3); $object2 = $this->loadById($globalData, $obj_id); $object2->setPrice(20000); $update_time = time(); $object2->setDateOfUpdate(tools_date2database($update_time)); $object2->update(); $object3 = $this->loadById($globalData, $obj_id); if ($object3->getPrice() != 20000) { throw new Exception('Incorrect value - price, after update.'); } if (tools_database2date($object3->getDateOfUpdate()) != $update_time) { throw new Exception('Incorrect value - time, after update.'); } RealEstateAgency_Object_RealEstateObject::deleteById($globalData, $obj_id); }