Beispiel #1
0
 /**
  * Store a newly created kin in storage.
  *
  * @return Response
  */
 public function store()
 {
     $validator = Validator::make($data = Input::all(), Property::$rules, Property::$messages);
     if ($validator->fails()) {
         return Redirect::back()->withErrors($validator)->withInput();
     }
     $property = new Property();
     $property->employee_id = Input::get('employee_id');
     $property->name = Input::get('name');
     $property->description = Input::get('desc');
     $property->serial = Input::get('serial');
     $property->digitalserial = Input::get('dserial');
     $property->monetary = Input::get('amount');
     $property->issued_by = Confide::user()->id;
     $property->issue_date = Input::get('idate');
     $property->scheduled_return_date = Input::get('sdate');
     if (filter_var(Input::get('active'), FILTER_VALIDATE_BOOLEAN)) {
         $property->state = 1;
         $property->received_by = Confide::user()->id;
         $property->return_date = Input::get('idate');
     } else {
         $property->state = 0;
         $property->received_by = 0;
         $property->return_date = null;
     }
     $property->save();
     Audit::logaudit('Properties', 'create', 'created: ' . $property->name);
     return Redirect::route('Properties.index')->withFlashMessage('Company property successfully created!');
 }
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Property();
     $fsUtil = new FileSystemUtil();
     if (isset($_POST['Property'])) {
         $model->attributes = $_POST['Property'];
         if ($model->save()) {
             //creo el directorio para las imagenes del inmueble
             $fsUtil->createPropertyFoderIfNotExists($model->id);
             //guardo las imagenes para el inmueble
             $images = $fsUtil->getTmpFilesNames();
             foreach ($images as $img) {
                 $imgInm = new ImagenProperty();
                 $imgInm->id_inmueble = $model->id;
                 $imgInm->ruta = $img;
                 if ($imgInm->save()) {
                     $fsUtil->copyFileFromTmpToFs($imgInm->ruta, $model->id);
                 }
             }
             $this->audit->registrarAuditoria(Yii::app()->user->id, new DateTime(), Constants::AUDITORIA_OBJETO_INMUEBLE, Constants::AUDITORIA_OPERACION_ALTA, $model->id);
             $this->render('/site/successfullOperation', array('header' => 'Inmueble creado con éxito', 'message' => 'Haga click en volver para regresar a la gestión de inmuebles', 'returnUrl' => Yii::app()->createUrl('inmueble/admin'), 'viewUrl' => Yii::app()->createUrl("inmueble/view", array("id" => $model->id))));
             return;
         }
     }
     $fsUtil->clearUserTmpFolder();
     $this->render('create', array('model' => $model));
 }
 /**
  * Store a newly created resource in storage.
  * POST /properties
  *
  * @return Response
  */
 public function store()
 {
     $input = Input::all();
     $v = Validator::make(Input::All(), array('name' => 'required|max:50|', 'description' => 'required|max:400|min:10', 'ownerID' => 'required'));
     if ($v->passes()) {
         $agent_id = Sentry::getUser()->id;
         $property = new Property();
         $property->name = Input::get('name');
         $property->description = Input::get('description');
         $property->ownerID = Input::get('ownerID');
         $property->agent_id = $agent_id;
         $property->save();
         $newprop = Property::where('name', Input::get('name'))->first();
         $newprop_id = $newprop->id;
         foreach (Input::get('CBgroup1', array()) as $value) {
             $housedue = new Housedue();
             $housedue->propertyID = $newprop_id;
             $housedue->receivable = $value;
             $converted = strtolower(preg_replace("/[[:blank:]]+/", "_", $value));
             $housedue->db_name = $converted;
             $housedue->save();
         }
         return Redirect::intended('admin/property');
     }
     return Redirect::back()->withInput()->withErrors($v)->with('message', 'There were validation errors');
 }
 /**
  * Creates a new Property model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Property();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'id' => $model->property_id]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
 /**
  * Shorthand to create or update properties
  *
  * @return void
  * @author Carlos Escribano <*****@*****.**>
  **/
 public static function set($key, $value)
 {
     if (!($p = Doctrine::getTable('Property')->findOneBy('keey', $key))) {
         $p = new Property();
         $p->setKeey($key);
     }
     $p->setValue($value);
     $p->save();
 }
 public function test_deletion_from_collection_should_destroy_the_active_record()
 {
     $Property = new Property(array('description' => 'This is a Property'));
     $Picture = $Property->picture->create(array('title' => 'Front'));
     $this->assertTrue($Property->save());
     $this->assertTrue($Picture instanceof AkActiveRecord);
     $Property->picture->delete($Picture);
     $StoredProperty = $this->Property->find('first');
     $this->assertEqual($Property->getId(), $StoredProperty->getId());
     $this->assertFalse($this->Picture->find('first', array('default' => false)));
 }
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Property();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Property'])) {
         $model->attributes = $_POST['Property'];
         if ($model->save()) {
             $this->redirect(array('view', 'id' => $model->id));
         }
     }
     $this->render('create', array('model' => $model));
 }
 public function setUp()
 {
     Yii::app()->db->createCommand()->truncateTable('link_client_to_instruction');
     Yii::app()->db->createCommand()->truncateTable('property');
     Yii::app()->db->createCommand()->truncateTable('deal');
     Yii::app()->db->createCommand()->truncateTable('client');
     Yii::app()->db->createCommand()->truncateTable('currentPropertyOwner');
     Yii::app()->db->createCommand()->truncateTable('cli2off');
     Yii::app()->db->createCommand()->truncateTable('offer');
     $this->migration = new m121127_103823_populate_currentPropertyOwners_table();
     $this->migration->down();
     $this->property = new Property();
     $this->property->save(false);
     $this->assertInstanceOf('Property', $this->property);
     $this->owner1 = new Client();
     $this->owner1->save(false);
     $this->owner2 = new Client();
     $this->owner2->save(false);
     $this->owner3 = new Client();
     $this->owner3->save(false);
     $this->owner4 = new Client();
     $this->owner4->save(false);
 }
 /**
  * Store a newly created resource in storage.
  * POST /properties
  *
  * @return Response
  */
 public function store()
 {
     $input = Input::all();
     $v = Validator::make(Input::All(), array('name' => 'required|max:50|', 'description' => 'required|max:400|min:10', 'ownerID' => 'required'));
     if ($v->passes()) {
         $agent_id = Sentry::getUser()->id;
         $property = new Property();
         $property->name = Input::get('name');
         $property->description = Input::get('description');
         $property->ownerID = Input::get('ownerID');
         $property->agent_id = $agent_id;
         $property->save();
         return Redirect::intended('admin/property');
     }
     return Redirect::back()->withInput()->withErrors($v)->with('message', 'There were validation errors');
 }
Beispiel #10
0
 /**
  * Performs the work of inserting or updating the row in the database.
  *
  * If the object is new, it inserts it; otherwise an update is performed.
  * All related objects are also updated in this method.
  *
  * @param PropelPDO $con
  * @return int             The number of rows affected by this insert/update and any referring fk objects' save() operations.
  * @throws PropelException
  * @see        save()
  */
 protected function doSave(PropelPDO $con)
 {
     $affectedRows = 0;
     // initialize var to track total num of affected rows
     if (!$this->alreadyInSave) {
         $this->alreadyInSave = true;
         // We call the save method on the following object(s) if they
         // were passed to this object by their coresponding set
         // method.  This object relates to these object(s) by a
         // foreign key reference.
         if ($this->aDomain !== null) {
             if ($this->aDomain->isModified() || $this->aDomain->isNew()) {
                 $affectedRows += $this->aDomain->save($con);
             }
             $this->setDomain($this->aDomain);
         }
         if ($this->aProperty !== null) {
             if ($this->aProperty->isModified() || $this->aProperty->isNew()) {
                 $affectedRows += $this->aProperty->save($con);
             }
             $this->setProperty($this->aProperty);
         }
         if ($this->aUser !== null) {
             if ($this->aUser->isModified() || $this->aUser->isNew()) {
                 $affectedRows += $this->aUser->save($con);
             }
             $this->setUser($this->aUser);
         }
         if ($this->isNew() || $this->isModified()) {
             // persist changes
             if ($this->isNew()) {
                 $this->doInsert($con);
             } else {
                 $this->doUpdate($con);
             }
             $affectedRows += 1;
             $this->resetModified();
         }
         $this->alreadyInSave = false;
     }
     return $affectedRows;
 }
 /**
  * if $_GET['owner'] is passed that means that proeprty will have an owner before it is created.
  * it is used in situation when wi select a client and want to create a property for him (valuation for example) then it is obvious that client is an owner
  *
  * @param Property $model property to edit
  */
 public function edit(Property $model)
 {
     /**
      * @var $address Address
      */
     if (isset($_POST['Property']) && $_POST['Property']) {
         $model->attributes = $_POST['Property'];
         $model->setClients(isset($_POST['owner']) && $_POST['owner'] ? $_POST['owner'] : [], Property::CLIENT_TYPE_OWNER);
         $model->setClients(isset($_POST['tenant']) && $_POST['tenant'] ? $_POST['tenant'] : [], Property::CLIENT_TYPE_TENANT);
         if (isset($_POST['propertyAddress']['id']) && $_POST['propertyAddress']['id']) {
             $address = Address::model()->findByPk($_POST['propertyAddress']['id']);
             if ($address) {
                 $model->setAddress($address);
             }
         }
         if ($model->save()) {
             Yii::app()->user->setFlash('property-update-success', 'Property updated.');
             $url = array('update', 'id' => $model->pro_id);
             if (isset($_GET['nextStep']) && $_GET['nextStep']) {
                 if (isset($_POST['proceed'])) {
                     if ($_GET['nextStep'] == 'AppointmentBuilder_propertySelected') {
                     }
                     $url = $this->createUrl('AppointmentBuilder/propertySelected', ['propertyId' => $model->pro_id]);
                 } else {
                     $url['nextStep'] = $_GET['nextStep'];
                 }
             }
             $this->redirect($url);
         }
     }
     $suggesstedOwner = null;
     if (Yii::app()->user->hasFlash('suggest-new-owner')) {
         $suggesstedOwner = Client::model()->findByPk(Yii::app()->user->getFlash('suggest-new-owner', null, false));
     }
     $this->render('edit', ['model' => $model, 'suggestedOwner' => $suggesstedOwner]);
 }
Beispiel #12
0
 public function test_scope_for_multiple_member_deletion()
 {
     $PisoJose = new Property('description->', 'Piso Jose');
     $PisoBermi = new Property('description->', 'Piso Bermi');
     $Atico = new PropertyType('description->', 'Ático');
     $Apartamento = new PropertyType('description->', 'Apartamento');
     $this->assertTrue($PisoJose->save() && $PisoBermi->save() && $Atico->save() && $Apartamento->save());
     $PisoJose->property_type->add($Atico);
     $PisoJose->property_type->add($Apartamento);
     $PisoBermi->property_type->add($Atico);
     $PisoBermi->property_type->add($Apartamento);
     $this->assertTrue($PisoJose =& $PisoJose->findFirstBy('description', 'Piso Jose'));
     $this->assertTrue($Atico =& $Atico->findFirstBy('description', 'Ático'));
     $PisoJose->property_type->load();
     $PisoJose->property_type->delete($Atico);
     $this->assertTrue($PisoBermi =& $PisoBermi->findFirstBy('description', 'Piso Bermi'));
     $this->assertTrue($PisoJose =& $PisoJose->findFirstBy('description', 'Piso Jose'));
     $PisoJose->property_type->load();
     $this->assertTrue($Atico =& $Atico->findFirstBy('description', 'Ático'));
     $this->assertTrue($Apartamento =& $Apartamento->findFirstBy('description', 'Apartamento'));
     $this->assertEqual($PisoJose->property_types[0]->getId(), $Apartamento->getId());
     $this->assertEqual($PisoBermi->property_type->count(), 2);
 }
Beispiel #13
0
<?php

include_once 'config/database.php';
include_once 'repository/Property.php';
$database = new Database();
$db = $database->getConnection();
$property = new Property($db);
$property->name = $_POST['name'];
$property->address = $_POST['address'];
$property->save();
print $property->name;
Beispiel #14
0
 /**
  * Updates a property
  *
  * @param int $id The property ID
  * @param array $data
  * @return int The property ID
  */
 public function do_update($id, $data = null)
 {
     $user = $this->requireUser();
     if (!$user->isAdmin()) {
         throw new Exception('Only administrators are allowed to edit properties.');
     }
     // Validate input data
     $validator = new KickstartValidator();
     $locale = Localizer::getInstance();
     $warnings = $validator->filterErrors($data, $this->initFilter($this->filter_basic, $locale));
     if ($warnings) {
         return array('result' => false, 'warnings' => $warnings);
     }
     $query = PropertyQuery::create()->filterByAccount($user->getAccount());
     if ($id !== null) {
         $query->filterById($id, Criteria::NOT_EQUAL);
         $property = PropertyQuery::create()->filterByAccount($user->getAccount())->findOneById($id);
         if (!$property) {
             throw new Exception('Property not found; ID: ' . $id);
         }
     } else {
         $property = new Property();
     }
     // Check for duplicates
     if (isset($data['Name']) and $query->findOneByName($data['Name'])) {
         throw new Exception($locale->insert('error.taken', array('value' => '"' . $data['Name'] . '"')));
     }
     unset($data['Id']);
     $property->fromArray($data);
     $property->setAccount($user->getAccount());
     $property->save();
     return $property->getId();
 }
 public function createProperty()
 {
     $input = Input::all();
     $v = Validator::make(Input::All(), array('name' => 'required|max:50|', 'ownerID' => 'required', 'CBgroup1' => 'required', 'agent_id' => 'required'));
     if ($v->passes()) {
         $agent_id = Input::get('agent_id');
         $properties = Owner::where('agent_id', $agent_id)->get();
         if (!$properties->isEmpty()) {
             $property = new Property();
             $property->name = Input::get('name');
             $property->ownerID = Input::get('ownerID');
             $property->agent_id = $agent_id;
             $property->save();
             $newprop = Property::where('name', Input::get('name'))->first();
             $newprop_id = $newprop->id;
             $payment = Input::get('CBgroup1');
             $fields = preg_split("/[\\s,]+/", $payment);
             $arrlength = count($fields);
             for ($x = 0; $x < $arrlength; $x++) {
                 $housedue = new Housedue();
                 $housedue->propertyID = $newprop_id;
                 $converted = ucfirst(preg_replace("/[[:blank:]]+/", " ", $fields[$x]));
                 $housedue->receivable = $converted;
                 $housedue->db_name = $fields[$x];
                 $housedue->save();
             }
             $noteProperty2 = array('error' => false, 'message' => 'Property Created Successfully');
             return $noteProperty2;
         }
         $noteProperty3 = array('error' => true, 'message' => 'Only owners are allowed to create properties');
         return $noteProperty3;
     }
     $noteProperty4 = array('error' => true, 'message' => $v->messages());
     return $noteProperty4;
 }
Beispiel #16
0
 /**
  * This method accepts user's id and an array of data and creates the model.
  * Returns model if successfully created.
  * Returns the error validated model if validation fails.
  *
  * data array should have the following hash keys-
  * 1.user_id
  * 2.i_want_to
  * 3.property_name
  * 4.description
  * 5.features
  * 6.featured
  * 7.jackpot_investment
  * 8.instant_home
  * 9.property_type_id
  * 10.transaction_type_id
  * 11.locality_id
  * 12.address
  * 13.properties_available
  * 14.bathrooms
  * 15.bedrooms
  * 16.furnished
  * 17.age_of_construction
  * 18.ownership_type
  * 19.covered_area_price
  * 20.land_area_price
  * 21.total_price
  * 22.per_unit_price
  * 23.area_type
  * 24.display_price
  * 25.price_negotiable
  * 26.available_from
  * 27.available_units
  * 28.facing, floor_number
  * 29.total_floors
  * 30.landmarks
  * 31.tax_fees
  * 32.terms_and_conditions
  * 33.views
  * 34.recently_viewed
  * @param array $data,string $userId
  * @return model || model with errors
  */
 public static function createProperty($userId, $data)
 {
     $property = new Property();
     $property->attributes = $data;
     $property->user_id = $userId;
     $property->save();
     return $property;
 }
    $landlord = $_POST['owner'];
    $date_added = $_POST['added'];
    // Confirm that all fields are submitted with values
    if (empty($name) || empty($num_rooms) || empty($fee) || empty($landlord) || empty($date_added)) {
        $err = "Form fields marked with an asterix are required";
    } elseif (!is_numeric($fee)) {
        $err = "Management fee can only be specified as a numeric value";
    } else {
        // Continue with processing
        $property = new Property();
        $property->setPropertyName($name);
        $property->setNumRooms($num_rooms);
        $property->setManagementFee($fee);
        $property->setLandLord($landlord);
        $property->setDateAdded($date_added);
        if ($property->save()) {
            $mesg = "Property Created";
            $session->message($mesg);
            redirect_to("property.php");
        } else {
            $err = "An error occured preventing the property from being saved. Please ";
            $err .= "try again later";
        }
    }
} else {
    // Form not submitted
    $err = "";
}
include_layout_template("admin_header.php");
?>
Beispiel #18
0
 public function test_clean_up_dependencies()
 {
     $Property = new Property(array('description' => 'Ruins in Matamon'));
     $this->assertTrue($Property->save());
     $South =& $Property->picture->create(array('title' => 'South views'));
     $this->assertReference($South, $Property->pictures[0]);
     $this->assertFalse($South->isNewRecord());
     $pic_id = $South->getId();
     $Property = new Property($Property->getId());
     $this->assertTrue($Property->destroy());
     $Picture = new Picture();
     $this->assertFalse($Picture->find($pic_id));
 }