public function init($sId) { global $mySession; $db = new Db(); $OfferName = ""; $min_nights_value = "0"; $min_nights_def_value = ""; if ($sId != "") { $PageData = $db->runQuery("select * from " . SPCL_OFFER_TYPES . " where id='" . $sId . "'"); $OfferName = $PageData[0]['type_name']; $status_value = $PageData[0]['status']; $promo_code_value = $PageData[0]['promo_code']; $discount_type_value = $PageData[0]['discount_type']; $min_nights_value = $PageData[0]['min_nights_type']; if ($min_nights_value == '1') { $min_nights_def_value = $PageData[0]['min_nights']; } } $offer_name = new Zend_Form_Element_Text('offer_name'); $offer_name->setRequired(true)->addValidator('NotEmpty', true, array('messages' => 'Country Name is required.'))->addDecorator('Errors', array('class' => 'error'))->setAttrib("class", "mws-textinput required")->setValue($OfferName); $statusArr[0]['key'] = '0'; $statusArr[0]['value'] = 'Disable'; $statusArr[1]['key'] = '1'; $statusArr[1]['value'] = 'Enable'; $status = new Zend_Form_Element_Select('status'); $status->addDecorator('Errors', array('class' => 'error'))->addMultiOptions($statusArr)->setAttrib("class", "mws-textinput required")->setValue($status_value); $promo_code = new Zend_Form_Element_Text('promo_code'); $promo_code->setRequired(true)->addValidator('NotEmpty', true, array('messages' => 'Promo Code is required.'))->addDecorator('Errors', array('class' => 'error'))->setAttrib("class", "mws-textinput required")->setAttrib("maxlength", "5")->setValue($promo_code_value); $nightsArr[1]['key'] = "0"; $nightsArr[1]['value'] = "Not Fixed"; $nightsArr[2]['key'] = "1"; $nightsArr[2]['value'] = "Fixed"; $min_nights = new Zend_Form_Element_Radio('min_nights'); $min_nights->setRequired(true)->addValidator('NotEmpty', true, array('messages' => 'Minimum stay value is required.'))->addDecorator('Errors', array('class' => 'error'))->setAttrib("class", "mws-textinput required")->setAttrib("onclick", "min_nightss();")->addMultiOptions($nightsArr)->setValue($min_nights_value); $min_nights_def = new Zend_Form_Element_Text('min_nights_def'); $min_nights_def->setAttrib("class", "mws-textinput required")->setAttrib("maxlength", "3")->setValue($min_nights_def_value); $discountArr[1]['key'] = "0"; $discountArr[1]['value'] = "Discount Percentage"; $discountArr[2]['key'] = "1"; $discountArr[2]['value'] = "Nights Free"; $discountArr[3]['key'] = "2"; $discountArr[3]['value'] = "Free Pool heating"; $discountArr[4]['key'] = "3"; $discountArr[4]['value'] = "7 Nights Free"; $discount_type = new Zend_Form_Element_Radio('discount_type'); $discount_type->setRequired(true)->addValidator('NotEmpty', true, array('messages' => 'Minimum stay value is required.'))->addDecorator('Errors', array('class' => 'error'))->setAttrib("class", "mws-textinput required")->addMultiOptions($discountArr)->setValue($discount_type_value); $this->addElements(array($offer_name, $status, $promo_code, $min_nights, $min_nights_def, $discount_type)); }
public function init() { // Set the method for the display form to POST $this->setMethod('post'); $this->setAttribs(array('class' => 'form-horizontal')); $decoratorField = new My_Decorator_Field(); $elements = array(); // Add name field $input = new Zend_Form_Element_Text('host', array('required' => true, 'label' => 'SMTP Host:', 'id' => 'host', 'placeholder' => 'Type something..', 'class' => 'form-control', 'value' => 'smtp.gmail.com')); $input->addValidators(array(new Zend_Validate_NotEmpty())); $input->addDecorator($decoratorField); $elements[] = $input; // Add category field $select = new Zend_Form_Element_Select('stype', array('required' => true, 'label' => 'Security:', 'id' => 'stype', 'class' => 'form-control')); $select->addMultiOption('TLS', 'TLS'); $select->addMultiOption('SSH', 'SSH'); $select->setValue('TLS'); $select->addDecorator($decoratorField); $elements[] = $select; // Add Price field $input = new Zend_Form_Element_Text('port', array('required' => true, 'label' => 'Port:', 'id' => 'port', 'placeholder' => 'Type something..', 'class' => 'form-control', 'min' => 0, 'step' => '1', 'type' => 'number', 'value' => '587')); $min = new Zend_Validate_GreaterThan(0); $input->addValidators(array(new Zend_Validate_Digits(), $min, new Zend_Validate_NotEmpty())); $input->addDecorator($decoratorField); $elements[] = $input; $input = new Zend_Form_Element_Text('email', array('required' => true, 'label' => 'SMTP Email Address:', 'id' => 'email', 'placeholder' => 'Your email..', 'class' => 'form-control', 'type' => 'email', 'value' => '*****@*****.**')); $input->addValidators(array(new Zend_Validate_EmailAddress(), new Zend_Validate_NotEmpty())); $input->addDecorator($decoratorField); $elements[] = $input; // Add category field $input = new Zend_Form_Element_Password('password1', array('required' => true, 'label' => 'Password:'******'id' => 'password1', 'class' => 'form-control', 'placeholder' => 'Your SMTP password..')); $input->addValidators(array(new Zend_Validate_NotEmpty())); $input->addDecorator($decoratorField); $elements[] = $input; // Add category field $input = new Zend_Form_Element_Password('password2', array('required' => true, 'label' => 'Password Again:', 'id' => 'password2', 'class' => 'form-control', 'placeholder' => 'Your SMTP password again..', 'validators' => array(array('identical', false, array('token' => 'password1'))))); $input->addDecorator($decoratorField); $elements[] = $input; //Add Submit button $input = new Zend_Form_Element_Submit('submit', array('Label' => ' ', 'class' => 'btn btn-info', 'value' => 'Add New Configuration')); $input->addDecorator($decoratorField); $elements[] = $input; $this->addElements($elements); $this->addDisplayGroup(array('host', 'stype', 'port', 'email', 'password1', 'password2', 'submit'), 'displgrp', array('legend' => 'Add Products', 'decorators' => array('FormElements', 'Fieldset'))); return $this; }
public function init($cId) { global $mySession; $db = new Db(); $amenity_value = ""; $description_value = ""; $status_value = ""; if ($cId != "") { $catData = $db->runQuery("select * from " . PROPERTY_SPEC_CAT . " where cat_id ='" . $cId . "'"); $category_value = $catData[0]['cat_name']; $status_value = $catData[0]['cat_status']; } $category = new Zend_Form_Element_Text('category'); $category->setRequired(true)->addValidator('NotEmpty', true, array('messages' => 'Category Name is required.'))->addDecorator('Errors', array('class' => 'error'))->setAttrib("class", "mws-textinput required")->setAttrib("maxlength", '65')->setAttrib("minlength", "3")->setAttrib("tabindex", '1')->setValue($category_value); $statusArr[0]['key'] = '0'; $statusArr[0]['value'] = 'Disable'; $statusArr[1]['key'] = '1'; $statusArr[1]['value'] = 'Enable'; $status = new Zend_Form_Element_Select('status'); $status->addDecorator('Errors', array('class' => 'error'))->addMultiOptions($statusArr)->setAttrib("class", "mws-textinput required")->setValue($status_value); $this->addElements(array($category, $status)); }
public function init($ptyleId) { global $mySession; $db = new Db(); $amenity_value = ""; $description_value = ""; $box1View_value = ""; $box2View_value = ""; $location_status = 0; //** array used when adding new amenity otherwise in editing next one will be overwritten **// $locationData = $db->runQuery("select * from " . LOCAL_AREA . " "); $i = 1; foreach ($locationData as $value) { $locationArr[$i]['key'] = $value['local_area_id']; $locationArr[$i]['value'] = $value['local_area_name']; $i++; } //$box2ViewArr = ""; if ($ptyleId != "") { $ptyleData = $db->runQuery("select * from " . AMENITY . " where amenity_id ='" . $ptyleId . "'"); $amenity_value = $ptyleData[0]['title']; $description_value = $ptyleData[0]['description']; $amenity_status_value = $ptyleData[0]['amenity_status']; $locations = explode(",", $ptyleData[0]['location_view']); } $amenity_name = new Zend_Form_Element_Text('amenity_name'); $amenity_name->setRequired(true)->addValidator('NotEmpty', true, array('messages' => 'Amenity Name is required.'))->addDecorator('Errors', array('class' => 'error'))->setAttrib("class", "mws-textinput required")->setAttrib("maxlength", '65')->setAttrib("minlength", "3")->setAttrib("tabindex", '1')->setValue($amenity_value); $description = new Zend_Form_Element_Textarea('description'); $description->addDecorator('Errors', array('class' => 'error'))->setAttrib("class", "mws-textinput")->setAttrib("maxlength", '100')->setValue($description_value); $statusArr[0]['key'] = '0'; $statusArr[0]['value'] = 'Disable'; $statusArr[1]['key'] = '1'; $statusArr[1]['value'] = 'Enable'; $amenity_status = new Zend_Form_Element_Select('amenity_status'); $amenity_status->addDecorator('Errors', array('class' => 'error'))->addMultiOptions($statusArr)->setAttrib("class", "mws-textinput required")->setValue($amenity_status_value); $this->addElements(array($amenity_name, $description, $amenity_status)); }
public function getSaveProductForm($id) { $form = new Zend_Form(); //get product whitch want update $productMapper = new Application_Model_ProductMapper(); $product = new Application_Model_Product(); if ($id) { $product = $productMapper->getProductById($id); } // Set the method for the display form to POST $form->setMethod('post'); $form->setAttribs(array('class' => 'form-horizontal', 'enctype' => 'multipart/form-data')); $decoratorField = new My_Decorator_Field(); $elements = array(); //Add id hidden field $input = new Zend_Form_Element_Hidden('id', array('value' => $id)); $elements[] = $input; // Add name field $input = new Zend_Form_Element_Text('name', array('required' => true, 'label' => 'Name:', 'id' => 'name', 'placeholder' => 'Type something..', 'value' => $product->getName(), 'class' => 'form-control')); $input->addValidators(array(new Zend_Validate_Alnum(), new Zend_Validate_NotEmpty())); $input->addDecorator($decoratorField); $elements[] = $input; // Add category field $select = new Zend_Form_Element_Select('category_id', array('required' => true, 'label' => 'Category:', 'id' => 'category', 'class' => 'form-control')); $categoryMapper = new Application_Model_CategoryMapper(); $categories = $categoryMapper->fetchAll(); foreach ($categories as $category) { $select->addMultiOption($category->getId(), $category->getName()); } // set selected option $select->setValue($product->getCategoryId()); $select->addDecorator($decoratorField); $elements[] = $select; $currencyMapper = new Application_Model_CurrencyMapper(); $currency = $currencyMapper->getDefaultCurrency(); // Add Price field $input = new Zend_Form_Element_Text('price', array('required' => true, 'label' => 'Price in ' . $currency->getCode() . ':', 'id' => 'price', 'placeholder' => 'Type something..', 'value' => number_format((double) $product->price, 2), 'class' => 'form-control', 'min' => self::MIN, 'max' => self::MAX, 'step' => 'any', 'type' => 'number')); $min = new Zend_Validate_LessThan(self::MAX); $max = new Zend_Validate_GreaterThan(self::MIN); $input->addValidators(array(new Zend_Validate_Float(), $min, $max, new Zend_Validate_NotEmpty())); $input->addDecorator($decoratorField); $elements[] = $input; if ($id) { //Add File field if ($product->file) { $input = new Zend_Form_Element('file', array('label' => 'File:', 'id' => 'file', 'class' => 'form-control', 'value' => $product->file)); $input->addDecorator(new My_Decorator_AnchoraFileForm()); $elements[] = $input; } else { $input = new Zend_Form_Element_File('file', array('label' => 'File:', 'id' => 'file', 'class' => 'form-control')); $input->addDecorator($decoratorField); $elements[] = $input; } //Add Image field if ($product->image) { $input = new Zend_Form_Element('image', array('label' => 'Image:', 'id' => 'image', 'class' => 'form-control', 'value' => $product->image)); $input->addDecorator(new My_Decorator_ImageForm()); $elements[] = $input; } else { $input = new Zend_Form_Element_File('image', array('label' => 'Image:', 'id' => 'image', 'class' => 'form-control')); $input->addDecorator($decoratorField); $elements[] = $input; } } else { //Add File field $input = new Zend_Form_Element_File('file', array('label' => 'File:', 'id' => 'file', 'class' => 'form-control')); $input->addDecorator($decoratorField); $elements[] = $input; //Add Image field $input = new Zend_Form_Element_File('image', array('label' => 'Image:', 'id' => 'image', 'class' => 'form-control')); $input->addDecorator($decoratorField); $elements[] = $input; } //Add Description field $input = new Zend_Form_Element_Textarea('description', array('label' => 'Description:', 'id' => 'description', 'class' => 'form-control', 'value' => $product->description)); $input->addDecorator($decoratorField); $elements[] = $input; //Add Submit button if (!$id) { $input = new Zend_Form_Element_Submit('submit', array('Label' => ' ', 'class' => 'btn btn-success', 'value' => 'Add New Product')); } else { $input = new Zend_Form_Element_Submit('submit', array('Label' => ' ', 'class' => 'btn btn-info', 'value' => 'Update Product')); } $input->addDecorator($decoratorField); $elements[] = $input; $form->addElements($elements); $form->addDisplayGroup(array('name', 'category_id', 'price', 'currency_id', 'file', 'image', 'description', 'submit'), 'displgrp', array('legend' => 'Add Products', 'decorators' => array('FormElements', 'Fieldset'))); return $form; }
public function init($specId) { global $mySession; $db = new Db(); $amenity_value = ""; $description_value = ""; $no_of_options_value = ""; $mandatory_value = ""; if ($specId != "") { $specData = $db->runQuery("select * from " . SPECIFICATION . " as s \n\t\t\t left join " . SPEC_CHILD . " as sc on\tsc.spec_id = s.spec_id\n\t\t\t\t\t\t\t\t\t inner join " . PROPERTY_SPEC_CAT . " as psc on\tpsc.cat_id = s.cat_id\n\t\t\t\t\t\t\t\t\t where s.spec_id ='" . $specId . "' "); $question_value = $specData[0]['question']; $input_type_value = $specData[0]['spec_type']; $spec_status_value = $specData[0]['status']; $category_value = $specData[0]['cat_id']; $no_of_options_value = count($specData); $mandatory_value = $specData[0]['mandatory']; if ($input_type_value == '1' || $input_type_value == '0' || $input_type_value == '4') { $i = 1; foreach ($specData as $value) { $options_value[$i] = $value['option']; $i++; } } } $categoryArr[0]['key'] = ""; $categoryArr[0]['value'] = "- - Select - -"; $catArr = $db->runQuery("select * from " . PROPERTY_SPEC_CAT . " "); $i = 1; foreach ($catArr as $values) { $categoryArr[$i]['key'] = $values['cat_id']; $categoryArr[$i]['value'] = $values['cat_name']; $i++; } $category = new Zend_Form_Element_Select('category'); $category->setRequired(true)->addMultiOptions($categoryArr)->addDecorator('Errors', array('class' => 'error'))->setAttrib("class", "mws-textinput")->setValue($category_value); $question = new Zend_Form_Element_Text('question'); $question->setRequired(true)->addValidator('NotEmpty', true, array('messages' => 'Question is required.'))->addDecorator('Errors', array('class' => 'error'))->setAttrib("class", "mws-textinput required")->setAttrib("tabindex", '1')->setValue($question_value); $typeArr[0]['key'] = ""; $typeArr[0]['value'] = '- - Select --'; $typeArr[1]['key'] = '0'; $typeArr[1]['value'] = 'Radio'; $typeArr[2]['key'] = '1'; $typeArr[2]['value'] = 'Selectbox'; $typeArr[3]['key'] = '2'; $typeArr[3]['value'] = 'Textarea'; $typeArr[4]['key'] = '3'; $typeArr[4]['value'] = 'Textbox'; $typeArr[5]['key'] = '4'; $typeArr[5]['value'] = 'Checkbox'; $input_type = new Zend_Form_Element_Select('input_type'); $input_type->setRequired(true)->addMultiOptions($typeArr)->addDecorator('Errors', array('class' => 'error'))->setAttrib("class", "mws-textinput")->setAttrib("onchange", "displayoption(this.value)")->setValue($input_type_value); /** no of options code **/ $numberArr[0]['key'] = ""; $numberArr[0]['value'] = "- - select - -"; for ($i = 1, $k = 2; $k <= 54; $i++, $k++) { $numberArr[$i]['key'] = $k; $numberArr[$i]['value'] = $k; } $no_of_options = new Zend_Form_Element_Select('no_of_options'); $no_of_options->addMultiOptions($numberArr)->addDecorator('Errors', array('class' => 'error'))->setAttrib("class", "mws-textinput required")->setAttrib("onchange", "addoptions(this.value)")->setValue($no_of_options_value); $this->addElement($no_of_options); /* options code **/ for ($j = 1; $j <= 54; $j++) { $options_add[$j] = new Zend_Form_Element_Text('options_add' . $j); $options_add[$j]->addDecorator('Errors', array('class' => 'error'))->setAttrib("class", "mws-textinput required")->setAttrib("tabindex", '1')->setValue($options_value[$j]); $this->addElement($options_add[$j]); } $statusArr[0]['key'] = '0'; $statusArr[0]['value'] = 'Disable'; $statusArr[1]['key'] = '1'; $statusArr[1]['value'] = 'Enable'; $spec_status = new Zend_Form_Element_Select('spec_status'); $spec_status->addDecorator('Errors', array('class' => 'error'))->addMultiOptions($statusArr)->setAttrib("class", "mws-textinput required")->setValue($spec_status_value); $mandatoryArr[0]['key'] = '0'; $mandatoryArr[0]['value'] = 'Not Mandatory'; $mandatoryArr[1]['key'] = '1'; $mandatoryArr[1]['value'] = 'Mandatory'; $mandatory = new Zend_Form_Element_Radio('mandatory'); $mandatory->addDecorator('Errors', array('class' => 'error'))->addMultiOptions($mandatoryArr)->setAttrib("class", "mws-textinput required")->setValue($mandatory_value); $this->addElements(array($question, $category, $input_type, $spec_status, $mandatory)); }