public function form($contact_id = null) { $form = parent::getForm('property'); if ($contact_id) { $form->addHidden('contact_id', $contact_id); $form->addHidden('cop', 'save_property'); $form->addHidden('k', $_SESSION['Contact_User']->getKey()); } else { $contacts = User::getContacts(); if (empty($contacts)) { return 'Please <a href="index.php?module=properties&aop=edit_contact">create a new contact</a>.'; } $form->addSelect('contact_id', $contacts); $form->setMatch('contact_id', $this->contact_id); $form->setLabel('contact_id', 'Property contact'); $form->addHidden('aop', 'save_property'); } if ($this->id) { $form->addHidden('pid', $this->id); $form->addSubmit('Update property'); } else { $form->addSubmit('Add property'); } $form->addText('address', $this->address); $form->setLabel('address', 'Address'); $form->setSize('address', 50); $form->setRequired('address'); $form->addText('admin_fee_amt', $this->getAdminFeeAmt()); $form->setLabel('admin_fee_amt', 'Administrative fee'); $form->setSize('admin_fee_amt', 8, 8); $form->addCheck('admin_fee_refund', 1); $form->setLabel('admin_fee_refund', 'Fee refunded'); $form->setMatch('admin_fee_refund', $this->admin_fee_refund); $bath['1'] = '1'; $bath['1.5'] = '1 1/2'; $bath['2'] = '2'; $bath['2.5'] = '2 1/2'; $bath['3'] = '3'; $bath['3.5'] = '3 1/2'; $bath['4'] = '4'; $bath['4.5'] = '4 1/2'; $bath['5'] = '5'; $bath['5.5'] = '5 1/2'; $form->addSelect('bathroom_no', $bath); $form->setMatch('bathroom_no', $this->bathroom_no); $form->setLabel('bathroom_no', 'Bathrooms'); $count = range(0, 8); unset($count[0]); $form->addSelect('bedroom_no', $count); $form->setMatch('bedroom_no', $this->bedroom_no); $form->setLabel('bedroom_no', 'Bedrooms'); $form->addText('clean_fee_amt', $this->getCleanFeeAmt()); $form->setLabel('clean_fee_amt', 'Clean fee amount'); $form->setSize('clean_fee_amt', 8, 8); $form->addCheck('clean_fee_refund', 1); $form->setLabel('clean_fee_refund', 'Fee refunded'); $form->setMatch('clean_fee_refund', $this->clean_fee_refund); $form->addCheck('efficiency', 1); $form->setLabel('efficiency', 'Efficiency'); $form->setMatch('efficiency', $this->efficiency); $form->addCheck('furnished', 1); $form->setLabel('furnished', 'Furnished'); $form->setMatch('furnished', $this->furnished); $form->addRadioAssoc('lease_type', array(JOINT_LEASE => 'Per unit', INDIVIDUAL_LEASE => 'Per person')); $form->setMatch('lease_type', $this->lease_type); $form->addTextarea('other_fees', $this->other_fees); $form->setLabel('other_fees', 'Other fees'); $form->addText('parking_fee', $this->getParkingFee()); $form->setLabel('parking_fee', 'Parking fee'); $form->setSize('parking_fee', 8, 8); $parking = range(0, 10); unset($parking[0]); $parking[NO_LIMIT_PARKING] = 'No limit'; $form->addSelect('parking_per_unit', $parking); $form->setLabel('parking_per_unit', 'Parking spaces available per unit'); $form->setMatch('parking_per_unit', $this->parking_per_unit); // Pet deposits are always refundable /* $form->addCheck('pet_dep_refund', 1); $form->setLabel('pet_dep_refund', 'Fee refunded'); $form->setMatch('pet_dep_refund', $this->pet_dep_refund); */ $form->addText('pet_deposit', $this->getPetDeposit()); $form->setLabel('pet_deposit', 'Pet deposit'); $form->setSize('pet_deposit', 8, 8); $form->addText('pet_fee', $this->getPetFee()); $form->setLabel('pet_fee', 'Pet fee'); $form->setSize('pet_fee', 8, 8); $form->addTextArea('pet_type', $this->pet_type); $form->setRows('pet_type', '5'); $form->setCols('pet_type', 20); $form->setLabel('pet_type', 'Allowed pet types'); $form->addText('security_amt', $this->getSecurityAmt()); $form->setLabel('security_amt', 'Security deposit amount'); $form->setSize('security_amt', 8, 8); $form->addCheck('security_refund', 1); $form->setMatch('security_refund', $this->security_refund); $form->setLabel('security_refund', 'Fee refunded'); $form->addRadioAssoc('student_type', array(NO_STUDENT_PREFERENCE => 'No preference', UNDERGRAD => 'Undergraduate', GRAD_STUDENT => 'Graduate')); $form->setMatch('student_type', $this->student_type); $form->addCheck('utilities_inc', 1); $form->setMatch('utilities_inc', $this->utilities_inc); $form->setLabel('utilities_inc', 'Utilities included in rent'); $form->addText('util_cable', $this->getUtilCable()); $form->setLabel('util_cable', 'Cable'); $form->setSize('util_cable', 8, 8); $form->addText('util_fuel', $this->getUtilFuel()); $form->setLabel('util_fuel', 'Fuel'); $form->setSize('util_fuel', 8, 8); $form->addText('util_internet', $this->getUtilInternet()); $form->setLabel('util_internet', 'Internet'); $form->setSize('util_internet', 8, 8); $form->addText('util_phone', $this->getUtilPhone()); $form->setLabel('util_phone', 'Phone'); $form->setSize('util_phone', 8, 8); $form->addText('util_power', $this->getUtilPower()); $form->setLabel('util_power', 'Power'); $form->setSize('util_power', 8, 8); $form->addText('util_trash', $this->getUtilTrash()); $form->setLabel('util_trash', 'Trash'); $form->setSize('util_trash', 8, 8); $form->addText('util_water', $this->getUtilWater()); $form->setLabel('util_water', 'Water'); $form->setSize('util_water', 8, 8); $hl[HT_HVAC] = 'HVAC (heat pump)'; $hl[HT_OIL] = 'Oil'; $hl[HT_PROPANE] = 'Propane'; $hl[HT_ELEC_BASE] = 'Electric baseboard'; $hl[HT_KEROSENE] = 'Kerosene'; $hl[HT_WOODSTOVE] = 'Woodstove/Fireplace'; $hl[HT_GAS] = 'Natural gas'; $form->addCheck('heat_type', array_keys($hl)); $form->setLabel('heat_type', $hl); $form->setMatch('heat_type', $this->heat_type); // necessary since there used to be a count instead of a bool $window_number = (int) (bool) $this->window_number; $form->addCheck('window_number', 1); $form->setMatch('window_number', $window_number); $form->setLabel('window_number', 'Windows in unit'); $form->setLabel('sublease', 'Subleasing permitted'); $tpl = $form->getTemplate(); if (!empty($this->errors)) { foreach ($this->errors as $key => $message) { $new_key = strtoupper($key) . '_ERROR'; $tpl[$new_key] = $message; } } return \PHPWS_Template::process($tpl, 'properties', 'edit_property.tpl'); }
public function form() { $form = parent::getForm('roommate'); $form->addHidden('rop', 'post_roommate'); $form->setLabel('name', 'Title'); $form->addCheck('share_bedroom', 1); $form->setLabel('share_bedroom', 'Bedroom shared'); $form->setMatch('share_bedroom', $this->share_bedroom); $form->addCheck('share_bathroom', 1); $form->setLabel('share_bathroom', 'Bathroom shared'); $form->setMatch('share_bathroom', $this->share_bathroom); $form->addRadioAssoc('smoking', array(0 => 'No preference', 1 => 'Non-smokers only', 2 => 'Smokers only')); $form->setMatch('smoking', $this->smoking); $genders[0] = 'No preference'; $genders[GENDER_MALE] = 'Male'; $genders[GENDER_FEMALE] = 'Female'; $form->addRadioAssoc('gender', $genders); $form->setMatch('gender', $this->gender); $form->addSubmit('Save'); $tpl = $form->getTemplate(); if (!empty($this->errors)) { foreach ($this->errors as $key => $message) { $new_key = strtoupper($key) . '_ERROR'; $tpl[$new_key] = $message; } } return \PHPWS_Template::process($tpl, 'properties', 'edit_roommate.tpl'); }