public static function findAvailables($homeId, $editId = null)
 {
     $alreadySet = Doctrine_Query::create()->from('Model_Hm_Charge_Reservation_Home r')->select('r.id, r.hm_charge_reservation_id, r.hm_home_id')->where('r.hm_home_id = ?', $homeId)->execute(array(), Doctrine_Core::HYDRATE_ARRAY);
     $whereNotIn = array();
     foreach ($alreadySet as $charge) {
         if ($charge['hm_charge_reservation_id'] != $editId) {
             $whereNotIn[] = $charge['hm_charge_reservation_id'];
         }
     }
     return Doctrine_Query::create()->from('Model_Hm_Charge_Reservation r')->leftJoin('r.Translation t')->orderBy('t.title')->where('t.lang = ?', Model_Lang::getCurrent())->andWhereNotIn('r.id', $whereNotIn);
 }
Ejemplo n.º 2
0
 public static function findAllForMap()
 {
     return Doctrine_Query::create()->from('Model_Hm_Home h')->leftJoin('
         	h.Translation ht, h.City t, 
         	t.Region r, r.Country c, c.Translation ct
         	')->select('
         	h.id, h.hm_geo_city_id, h.active, 
         	h.address, h.number, h.zipcode, h.coordinate
         	ht.*, t.*, r.*, c.*, ct,*
         	')->where('ht.lang = ?', Model_Lang::getCurrent())->andWhere('ct.lang = ?', Model_Lang::getCurrent());
 }
Ejemplo n.º 3
0
 public function get()
 {
     $this->preAvailableOptions();
     $this->preHomeOptions();
     foreach ($this->availableOptions as $availableOption) {
         $childs = array();
         foreach ($availableOption->Options as $option) {
             $childs[] = array('name' => $option->Translation[Model_Lang::getCurrent()]->name, 'state' => $this->getState($option->id));
         }
         $options[] = array('name' => $availableOption->Translation[Model_Lang::getCurrent()]->name, 'Options' => $childs);
     }
     return $options;
 }
 /**
  * Find All available charges by home
  * @param $homeId
  * @param $exceptCharge
  */
 public static function findAvailables($homeId = null, $exceptCharge = null)
 {
     $homeCharges = Doctrine_Query::create()->from('Model_Hm_Charge_Optional_Home h')->select('h.id, h.hm_home_id, h.hm_charge_optional_id')->where('h.hm_home_id = ?', $homeId)->execute(null, Doctrine_Core::HYDRATE_ARRAY);
     $not = array();
     foreach ($homeCharges as $charge) {
         $id = $charge['hm_charge_optional_id'];
         if ($id != $exceptCharge) {
             $not[] = $id;
         }
     }
     $availableCharges = Doctrine_Query::create()->from('Model_Hm_Charge_Optional c')->leftJoin('c.Translation t')->where('t.lang = ?', Model_Lang::getCurrent())->orderBy('t.lang')->andWhereNotIn('c.id', $not);
     return $availableCharges;
 }
Ejemplo n.º 5
0
 public static function findAvailables($homeId, $editId = null)
 {
     // already setted charges
     $usedCharges = Doctrine_Query::create()->from('Model_Hm_Charge_Night_Home n')->select('n.id, n.hm_home_id, n.hm_charge_night_id')->where('n.hm_home_id = ?', $homeId)->execute(array(), Doctrine_Core::HYDRATE_ARRAY);
     // build array with setted id's
     $whereNotIn = array();
     foreach ($usedCharges as $charge) {
         if ($charge['hm_charge_night_id'] != $editId) {
             $whereNotIn[] = $charge['hm_charge_night_id'];
         }
     }
     // get all charges except the ones who are already set
     return Doctrine_Query::create()->from('Model_Hm_Charge_Night n')->leftJoin('n.Translation t')->orderBy('t.title')->where('t.lang = ?', Model_Lang::getCurrent())->whereNotIn('n.id', $whereNotIn);
 }
 public static function listAll()
 {
     return Doctrine_Query::create()->from('Model_Hm_Op_Category c')->leftJoin('c.Translation t')->orderBy('t.name')->where('t.lang = ?', Model_Lang::getCurrent());
 }
Ejemplo n.º 7
0
 public function __get($columnName)
 {
     return $this->translation[Model_Lang::getCurrent()]->{$columnName};
 }
 public function adminAction()
 {
     $this->_helper->layout()->setLayout('submenu');
     $this->view->geos = Doctrine_Query::create()->from('Model_Hm_Geo_Country y')->leftJoin('y.Translation yt, y.Regions r, r.Cities t')->where('yt.lang = ?', Model_Lang::getCurrent())->orderBy('yt.lang, r.name, t.name')->execute();
 }
Ejemplo n.º 9
0
 public static function findByHomeId($homeId)
 {
     return Doctrine_Query::create()->from('Model_Hm_Comment c')->leftJoin('c.Translation t')->orderBy('c.created_at DESC')->where('c.hm_home_id = ?', $homeId)->andWhere('t.lang = ?', Model_Lang::getCurrent());
 }
Ejemplo n.º 10
0
 public static function findAllByHomeIdForAdmin($homeId)
 {
     return Doctrine_Query::create()->from('Model_Hm_Invoice_Charge c')->leftJoin('c.Translation t')->orderBy('c.date DESC')->where('c.hm_home_id = ?', $homeId)->andWhere('t.lang = ?', Model_Lang::getCurrent());
 }
Ejemplo n.º 11
0
 public static function findTreeForNavigation()
 {
     return Doctrine_Query::create()->from('Model_Hm_Geo_Country c')->leftJoin('c.Translation ct, c.Regions r, r.Cities t')->where('ct.lang = ?', Model_Lang::getCurrent())->orderBy('ct.name, r.name, t.name');
 }
Ejemplo n.º 12
0
 public static function findByHomeId($homeId)
 {
     return Doctrine_Query::create()->from('Model_Hm_Photo p')->leftJoin('p.Translation t')->orderBy('p.sort_weight')->where('p.hm_home_id = ?', $homeId)->andWhere('t.lang = ?', Model_Lang::getCurrent());
 }
Ejemplo n.º 13
0
 public static function findAllByHome($homeId)
 {
     return Doctrine_Query::create()->from('Model_Hm_Charge_Reservation_Home h')->leftJoin('h.Charge c, c.Translation t')->where('t.lang = ?', Model_Lang::getCurrent())->orderBy('t.title');
 }
Ejemplo n.º 14
0
 public static function listAll()
 {
     return Doctrine_Query::create()->from('Model_Hm_Op_Option o')->leftJoin('o.Translation ot, o.Category c, c.Translation ct')->where('ct.lang = ?', Model_Lang::getCurrent())->andWhere('ot.lang = ?', Model_Lang::getCurrent())->orderBy('ct.name, ot.name');
 }
Ejemplo n.º 15
0
 public static function findAllForAdmin()
 {
     return Doctrine_Query::create()->from('Model_Hm_Geo_Region r')->leftJoin('r.Country c, c.Translation t')->where('t.lang = ?', Model_Lang::getCurrent())->orderBy('t.name, r.name');
 }
Ejemplo n.º 16
0
 /**
  * Get zend price
  */
 public function getZendPrice()
 {
     $zc = new Zend_Currency(array('value' => $this->_get('price')), strtoupper(Model_Lang::getCurrent()));
     return $zc->toString();
 }
Ejemplo n.º 17
0
 public static function findAllForMap()
 {
     return Doctrine_Query::create()->from('Model_Hm_Geo_City c')->leftJoin('c.Translation t, c.Region r, r.Country y, y.Translation yt')->where('t.lang = ?', Model_Lang::getCurrent())->andWhere('yt.lang = ?', Model_Lang::getCurrent());
 }
 public function init()
 {
     /*
      * 
      * Settings
      * 
      */
     $this->setName('holidayhome');
     $this->setMethod('post');
     /*
      * 
      * Elements
      * 
      */
     $element = new Zend_Form_Element_Select('hm_geo_city_id');
     $element->setLabel('Plaats')->addMultiOption('', '...')->setRequired(true);
     $geo = Doctrine_Query::create()->from('Model_Hm_Geo_City c')->leftJoin('c.Region r, r.Country y, y.Translation tr')->where('tr.lang = ?', Model_Lang::getCurrent())->orderBy('tr.name, r.name, c.name')->execute();
     foreach ($geo as $city) {
         $element->addMultiOption($city->id, $city->Region->Country->translationHandler()->name . " - " . $city->Region->name . " - " . $city->name);
     }
     $this->addElement($element);
     $element = new Zend_Form_Element_Select('hm_owner_id');
     $element->setLabel('Eigenaar')->addMultiOption('', '...')->setRequired(true);
     $owners = Doctrine_Query::create()->from('Model_Hm_Owner o')->leftJoin('o.User u')->orderBy('u.surname')->select('o.id')->execute();
     foreach ($owners as $owner) {
         $label = $owner->User->surname . ', ' . $owner->User->initials . ' ' . $owner->User->insertion . ' - (' . $owner->debtor_no . ')';
         $element->addMultiOption($owner->id, $label);
     }
     $this->addElement($element);
     $element = new Zend_Form_Element_Select('active');
     $element->setLabel('Actief')->setRequired(true)->addMultiOption('', '...')->addMultiOption('true', 'Actief')->addMultiOption('false', 'Niet actief');
     $this->addElement($element);
     $element = new Zend_Form_Element_Text('name');
     $element->setLabel('Naam')->setValidators(array(array('stringLength', null, array('min' => 4, 'max' => 128))))->setAttrib('maxlength', 128)->setRequired(true);
     $this->addElement($element);
     $element = new Zend_Form_Element_Text('address');
     $element->setLabel('Straat')->setValidators(array(array('stringLength', null, array('min' => 4, 'max' => 128))))->setAttrib('maxlength', 128)->setRequired(true);
     $this->addElement($element);
     $element = new Zend_Form_Element_Text('number');
     $element->setLabel('Huisnummer')->setValidators(array(array('stringLength', null, array('max' => 128))))->setAttrib('maxlength', 128)->setRequired(true);
     $this->addElement($element);
     $element = new Zend_Form_Element_Text('code');
     $element->setLabel('Code')->setValidators(array(array('stringLength', null, array('max' => 128))))->setAttrib('maxlength', 128)->setRequired(true);
     $this->addElement($element);
     $element = new Zend_Form_Element_Text('zipcode');
     $element->setLabel('Postcode')->setValidators(array(array('stringLength', null, array('min' => 2, 'max' => 8))))->setAttrib('maxlength', 8)->setRequired(true);
     $this->addElement($element);
     $element = new Zend_Form_Element_Text('surface_lot');
     $element->setLabel('Kavel')->setValidators(array(array('digits')))->setFilters(array(array('int')))->setAttrib('maxlength', 6);
     $this->addElement($element);
     $element = new Zend_Form_Element_Text('surface_build');
     $element->setLabel('Bebouwd')->setValidators(array(array('digits')))->setFilters(array(array('int')))->setAttrib('maxlength', 6);
     $this->addElement($element);
     $element = new Zend_Form_Element_Text('persons');
     $element->setLabel('Personen')->setValidators(array(array('digits')))->setFilters(array(array('int')))->setAttrib('maxlength', 6)->setRequired(true);
     $this->addElement($element);
     $element = new Zend_Form_Element_Text('bedrooms');
     $element->setLabel('Slaapkamers')->setValidators(array(array('digits')))->setFilters(array(array('int')))->setAttrib('maxlength', 6)->setRequired(true);
     $this->addElement($element);
     $element = new Zend_Form_Element_Text('toilets');
     $element->setLabel('Toiletten')->setValidators(array(array('digits')))->setFilters(array(array('int')))->setAttrib('maxlength', 6)->setRequired(true);
     $this->addElement($element);
     $element = new Zend_Form_Element_Text('showers');
     $element->setLabel('Badkamers')->setValidators(array(array('digits')))->setFilters(array(array('int')))->setAttrib('maxlength', 6)->setRequired(true);
     $this->addElement($element);
     $element = new Zend_Form_Element_Text('coordinate');
     $element->setLabel('Coordinaat')->setValidators(array(array('stringLength', null, array('min' => 8, 'max' => 32))))->setAttrib('maxlength', 32)->setRequired(true);
     $this->addElement($element);
     $element = new Zend_Form_Element_Text('price');
     $element->setLabel('Basisprijs')->setAttrib('maxlength', 20)->setRequired(true);
     $this->addElement($element);
     $element = new Zend_Form_Element_Text('extra_percentage');
     $element->setLabel('Gebroken week percentage')->setAttrib('maxlength', 20)->setRequired(true);
     $this->addElement($element);
     $element = new Zend_Form_Element_Text('maintenance_central_heating');
     $element->setLabel('Onderhoud centrale verwarming')->setValidators(array(array('stringLength', null, array('max' => 128))))->setAttrib('maxlength', 128);
     $this->addElement($element);
     $element = new Zend_Form_Element_Text('maintenance_garden');
     $element->setLabel('Onderhoud tuin')->setValidators(array(array('stringLength', null, array('max' => 128))))->setAttrib('maxlength', 128);
     $this->addElement($element);
     $element = new Zend_Form_Element_Text('insurance_name');
     $element->setLabel('Verzekerinig')->setValidators(array(array('stringLength', null, array('max' => 128))))->setAttrib('maxlength', 128);
     $this->addElement($element);
     $element = new Zend_Form_Element_Text('wifi_password');
     $element->setLabel('Wifi wachtwoord')->setValidators(array(array('stringLength', null, array('max' => 128))))->setAttrib('maxlength', 128);
     $this->addElement($element);
     $element = new Zend_Form_Element_Text('insurance_policy_no');
     $element->setLabel('Polisnummer')->setValidators(array(array('stringLength', null, array('max' => 128))))->setAttrib('maxlength', 128);
     $this->addElement($element);
     $element = new Zend_Form_Element_Text('insurance_agent');
     $element->setLabel('Contactpersoon')->setValidators(array(array('stringLength', null, array('max' => 128))))->setAttrib('maxlength', 128);
     $this->addElement($element);
     $element = new Zend_Form_Element_Text('insurance_phone_no');
     $element->setLabel('Telefoonnummer')->setValidators(array(array('stringLength', null, array('max' => 128))))->setAttrib('maxlength', 128);
     $this->addElement($element);
     $element = new Zend_Form_Element_Select('vat_publish');
     $element->setLabel('Belasting plichtig')->addMultiOption(null, '..')->addMultiOption('true', 'Ja')->addMultiOption('false', 'Nee')->setRequired(true);
     $this->addElement($element);
     $element = new Zend_Form_Element_Select('vat_outside');
     $element->setLabel('Belasting buitenland')->addMultiOption(null, '..')->addMultiOption('true', 'Ja')->addMultiOption('false', 'Nee')->setRequired(true);
     $this->addElement($element);
     $element = new Zend_Form_Element_MultiCheckbox('Categories');
     $element->setLabel('Categorieen waar woning in hoort');
     $categories = Model_Hm_Category::listAll()->execute();
     foreach ($categories as $category) {
         $element->addMultiOption($category->id, $category->translationHandler()->name);
     }
     $this->addElement($element);
     $element = new Zend_Form_Element_MultiCheckbox('Options');
     $element->setLabel('Kenmerken van deze woning');
     $options = Model_Hm_Op_Option::listAll()->execute();
     foreach ($options as $option) {
         $element->addMultiOption($option->id, $option->Category->translationHandler()->name . ' - ' . $option->translationHandler()->name);
     }
     $this->addElement($element);
     $element = new Zend_Form_Element_Submit('holidayhome_submit');
     $element->setLabel('Verwerken')->setAttrib('class', 'submit');
     $this->addElement($element);
     /*
      * 
      * Translations
      * 
      */
     // Create new translations subform
     $subForm = new Zend_Form_SubForm('Translation');
     // Run all languages
     foreach (Model_Hm_Lang::listAll() as $lang) {
         // Create subform for language
         $subSubForm = new Zend_Form_SubForm($lang->code);
         // Create description field
         $element = new Zend_Form_Element_Textarea('description');
         $element->setLabel('Omschrijving')->setAttrib('class', 'autoexpand')->setAttrib('rows', 2)->setAttrib('cols', 24)->setRequired(true)->setValidators(array(array('stringLength', false, array('min' => 40))));
         $subSubForm->addElement($element);
         // Add description field to language subform
         // Put each language in different fieldset
         $subSubForm->addDisplayGroup(array('description'), $lang->code, array('class' => 'textarea', 'legend' => 'Vertaling - ' . $lang->name));
         // Add language subform to Translation subform
         $subForm->addSubForm($subSubForm, $lang->code);
     }
     // Add Translation subform to normal form
     $this->addSubForm($subForm, 'Translation', 19);
     /*
      * 
      * Display groups
      * 
      */
     $this->addDisplayGroup(array('Options'), 'OptionsGroup', array('class' => 'checkboxes', 'legend' => 'Kenmerken', 'order' => 17));
     $this->addDisplayGroup(array('address', 'number', 'zipcode', 'code', 'hm_geo_city_id'), 'Adres', array('legend' => 'Adres', 'order' => 2));
     $this->addDisplayGroup(array('persons', 'bedrooms', 'toilets', 'showers'), 'Indeling', array('legend' => 'Indeling', 'order' => 3));
     $this->addDisplayGroup(array('surface_lot', 'surface_build'), 'Oppervlakte', array('legend' => 'Oppervlakte', 'order' => 6));
     $this->addDisplayGroup(array('vat_publish', 'vat_outside'), 'Belasting', array('legend' => 'Belasting', 'order' => 5));
     $this->addDisplayGroup(array('price', 'extra_percentage'), 'Prijscalculatie', array('legend' => 'Prijscalculatie', 'order' => 4));
     $this->addDisplayGroup(array('maintenance_central_heating', 'maintenance_garden', 'wifi_password'), 'hulpdiensten', array('legend' => 'Overige', 'order' => 11));
     $this->addDisplayGroup(array('insurance_name', 'insurance_policy_no', 'insurance_agent', 'insurance_phone_no'), 'verzekering', array('legend' => 'Verzekering', 'order' => 10));
     $this->addDisplayGroup(array('Categories'), 'categoriesgroup', array('legend' => 'Categorieen', 'class' => 'checkboxes', 'order' => 12));
     $this->addDisplayGroup(array('hm_owner_id', 'active', 'name', 'coordinate'), 'algemeen', array('legend' => 'Algemeen', 'order' => 1));
     $this->addDisplayGroup(array('holidayhome_submit'), 'submit', array('order' => 20, 'class' => 'submit'));
     /*
      * 
      * Decorators
      * 
      */
     $decorators = array('FormElements', 'Form');
     $displayGroupDecorators = array('Description', 'FormElements', 'Fieldset');
     $elementDecorators = array('Description', 'ViewHelper', 'Errors', array(array('p' => 'HtmlTag'), array('tag' => 'p')), array('Label', array('tag' => 'p')));
     $subDecorators = array('FormElements');
     $subDisplayGroupDecorators = array('Description', 'FormElements', 'Fieldset', array('HtmlTag', array('tag' => 'div')));
     $subElementDecorators = array('Description', 'ViewHelper', 'Errors', array(array('p' => 'HtmlTag'), array('tag' => 'p')), array('Label', array('tag' => 'p')));
     /*
      * 
      * Set decorators
      * 
      */
     $this->setDecorators($decorators)->setElementDecorators($elementDecorators)->setDisplayGroupDecorators($displayGroupDecorators);
     $translation = $this->getSubForm('Translation')->setDecorators($subDecorators)->setDisplayGroupDecorators($subDisplayGroupDecorators)->setElementDecorators($subElementDecorators);
     $subsubforms = $translation->getSubForms();
     foreach ($subsubforms as $subsubform) {
         $subsubform->setDecorators($subDecorators)->setDisplayGroupDecorators($subDisplayGroupDecorators)->setElementDecorators($subElementDecorators);
     }
     $submit = $this->getElement('holidayhome_submit');
     $submit->setDecorators(array('ViewHelper'));
 }