public function getForm(array $staff)
 {
     if (!$this->form) {
         $attendanceId = new Element\Hidden();
         $attendanceId->setName('attendanceId');
         $staffId = new Element\Select();
         $staffId->setName('staffId')->setLabel('Staff')->setAttribute('class', 'form-control')->setEmptyOption('-- Choose --')->setValueOptions($staff);
         $type = new Element\Select();
         $type->setName('type')->setLabel('Type')->setAttribute('class', 'form-control')->setValueOptions(array('I' => 'In', 'O' => 'Out'));
         $date = new Element\Date();
         $date->setName('attendanceDate')->setLabel('Date')->setAttributes(array('class' => 'form-control', 'allowPastDates' => true, 'momentConfig' => array('format' => 'YYYY-MM-DD')));
         $workingHours = array();
         for ($i = 8; $i < 20; $i++) {
             $workingHours[$i] = sprintf('%02d', $i);
         }
         $hour = new Element\Select();
         $hour->setName('hour')->setAttribute('class', 'form-control')->setValueOptions($workingHours);
         $workingMinutes = array();
         for ($i = 0; $i < 12; $i++) {
             $workingMinutes[$i] = sprintf('%02d', $i * 5);
         }
         $minute = new Element\Select();
         $minute->setName('minute')->setAttribute('class', 'form-control')->setValueOptions($workingMinutes);
         $form = new Form();
         $form->setAttributes(array('role' => 'form', 'class' => 'form-horizontal'));
         $form->add($attendanceId);
         $form->add($staffId);
         $form->add($type);
         $form->add($date);
         $form->add($hour);
         $form->add($minute);
         $this->form = $form;
     }
     return $this->form;
 }
Esempio n. 2
0
 public function __construct()
 {
     parent::__construct('personorg');
     $this->setAttribute('method', 'post');
     $this->add(new Element\Hidden('id_person'));
     $this->add(new Element\Hidden('id_organization'));
     $this->add(new Element\Hidden('bool_primary'));
     $this->add(new Element\Hidden('nid_lov_personorgtype'));
     $this->add(new Element\Hidden('dt_begin'));
     $name_title = new Element\Text('name_title');
     $name_title->setLabel('Title')->setAttributes(array('class' => 'largewhite'));
     $this->add($name_title);
     $pnum_primary_order = new Element\Select('num_primary_order');
     $pnum_primary_order->setLabel('Primary Order')->setAttributes(array('class' => 'tinywhite'));
     $this->add($pnum_primary_order);
     $dt_end = new Element\Date('dt_end');
     $dt_end->setLabel('End Date')->setAttributes(array('class' => 'smallwhite', 'type' => 'date', 'id' => 'dt_end'))->setOptions(array('datepickerOptions' => array('changeYear: true', 'changeMonth: true', 'yearRange: "c-100:c+100"')));
     $this->add($dt_end);
     $comment = new Element\Textarea('comment');
     $comment->setLabel('Comment')->setAttributes(array('class' => 'smallwhite'));
     $this->add($comment);
     $back = new Element\Button('back');
     $back->setLabel('Back')->setAttributes(array('id' => 'backbutton', 'class' => 'btn-success', 'style' => 'margin-right:70px;', 'onclick' => ''));
     $this->add($back);
     $submit = new Element\Submit('submit');
     $submit->setValue('Login')->setAttributes(array('id' => 'submitbutton', 'class' => 'btn-success', 'style' => 'margin: 10px 0 10px 140px'));
     $this->add($submit);
 }
Esempio n. 3
0
 public function testProvidesInputSpecificationThatIncludesValidatorsBasedOnAttributes()
 {
     $element = new DateElement('foo');
     $element->setAttributes(array('inclusive' => true, 'min' => '2000-01-01', 'max' => '2001-01-01', 'step' => '1'));
     $inputSpec = $element->getInputSpecification();
     $this->assertArrayHasKey('validators', $inputSpec);
     $this->assertInternalType('array', $inputSpec['validators']);
     $expectedClasses = array('Zend\\Validator\\Date', 'Zend\\Validator\\GreaterThan', 'Zend\\Validator\\LessThan', 'Zend\\Validator\\DateStep');
     foreach ($inputSpec['validators'] as $validator) {
         $class = get_class($validator);
         $this->assertTrue(in_array($class, $expectedClasses), $class);
         switch ($class) {
             case 'Zend\\Validator\\GreaterThan':
                 $this->assertTrue($validator->getInclusive());
                 $this->assertEquals('2000-01-01', $validator->getMin());
                 break;
             case 'Zend\\Validator\\LessThan':
                 $this->assertTrue($validator->getInclusive());
                 $this->assertEquals('2001-01-01', $validator->getMax());
                 break;
             case 'Zend\\Validator\\DateStep':
                 $dateInterval = new \DateInterval('P1D');
                 $this->assertEquals($dateInterval, $validator->getStep());
                 $this->assertEquals('2000-01-01', $validator->getBaseValue());
                 break;
             default:
                 break;
         }
     }
 }
Esempio n. 4
0
 public function prepareElements(array $categories)
 {
     $category = new Element\Select('category');
     $category->setLabel('Category')->setOptions(array('options' => $categories));
     $title = new Element\Text('title');
     $title->setLabel('Title')->setAttribute('title', 'Enter a suitable title for this posting')->setAttribute('size', 40)->setAttribute('maxlength', 128);
     $priceMin = new Element\Text('priceMin');
     $priceMin->setLabel('Minimum Price')->setAttribute('title', 'Enter mininum price as nnn.nn')->setAttribute('size', 16)->setAttribute('maxlength', 16);
     $priceMax = new Element\Text('priceMax');
     $priceMax->setLabel('Maximum Price')->setAttribute('title', 'Enter maximum price as nnn.nn')->setAttribute('size', 16)->setAttribute('maxlength', 16);
     $expires = new Element\Date('expires');
     $expires->setLabel('Expires')->setAttribute('title', 'The expiration date will be calculated from today')->setAttribute('size', 20)->setAttribute('maxlength', 20);
     $city = new Element\Text('city');
     $city->setLabel('Nearest City')->setAttribute('title', 'Select the city of the item')->setAttribute('size', 40)->setAttribute('maxlength', 255);
     $country = new Element\Text('country');
     $country->setLabel('Country Code')->setAttribute('title', 'Enter the 2 character ISO2 country code of the item')->setAttribute('size', 2)->setAttribute('maxlength', 2);
     $name = new Element\Text('name');
     $name->setLabel('Contact Name')->setAttribute('title', 'Enter the name of the person to contact for this item')->setAttribute('size', 40)->setAttribute('maxlength', 255);
     $phone = new Element\Text('phone');
     $phone->setLabel('Contact Phone Number')->setAttribute('title', 'Enter the phone number of the person to contact for this item')->setAttribute('size', 20)->setAttribute('maxlength', 32);
     $email = new Element\Email('email');
     $email->setLabel('Contact Email')->setAttribute('title', 'Enter the email address of the person to contact for this item')->setAttribute('size', 40)->setAttribute('maxlength', 255);
     $description = new Element\Textarea('description');
     $description->setLabel('Description')->setAttribute('title', 'Enter a suitable description for this posting')->setAttribute('rows', 4)->setAttribute('cols', 80);
     $submit = new Element\Submit('submit');
     $submit->setAttribute('value', 'Search')->setAttribute('title', 'Click here when done');
     $this->add($category)->add($title)->add($priceMin)->add($priceMax)->add($expires)->add($city)->add($country)->add($name)->add($phone)->add($email)->add($description)->add($submit);
 }
Esempio n. 5
0
 public function testValueReturnedFromComposedDateTimeIsRfc3339FullDateFormat()
 {
     $element = new DateElement('foo');
     $date = new DateTime();
     $element->setValue($date);
     $value = $element->getValue();
     $this->assertEquals($date->format('Y-m-d'), $value);
 }
Esempio n. 6
0
 protected function getDateElement($name, $options)
 {
     $elementSpec = isset($options[$name]) ? $options[$name] : '';
     $elementOptions = isset($elementSpec['options']) ? $elementSpec['options'] : array();
     $element = new Date($name, $elementOptions);
     if (isset($elementSpec['attributes'])) {
         $element->setAttributes($elementSpec['attributes']);
     }
     return $element;
 }
 public function indexAction()
 {
     $form = new Form();
     // Элемент Date/Time
     $dateTime = new Element\DateTime('element-date-time');
     $dateTime->setLabel('Date/Time Element')->setAttributes(array('min' => '2000-01-01T00:00:00Z', 'max' => '2020-01-01T00:00:00Z', 'step' => '1'));
     $form->add($dateTime);
     // Элемент Date/Time Local
     $dateTime = new Element\DateTimeLocal('element-date-time-local');
     $dateTime->setLabel('Date/Time Local Element')->setAttributes(array('min' => '2000-01-01T00:00:00Z', 'max' => '2020-01-01T00:00:00Z', 'step' => '1'));
     $form->add($dateTime);
     // Элемент Time
     $time = new Element\Time('element-time');
     $time->setLabel('Time Element');
     $form->add($time);
     // Элемент Date
     $date = new Element\Date('element-date');
     $date->setLabel('Date Element')->setAttributes(array('min' => '2000-01-01', 'max' => '2020-01-01', 'step' => '1'));
     $form->add($date);
     // Элемент Week
     $week = new Element\Week('element-week');
     $week->setLabel('Week Element');
     $form->add($week);
     // Элемент Month
     $month = new Element\Month('element-month');
     $month->setLabel('Month Element');
     $form->add($month);
     // Элемент Email
     $email = new Element\Email('element-email');
     $email->setLabel('Email Element');
     $form->add($email);
     // Элемент URL
     $url = new Element\Url('element-url');
     $url->setLabel('URL Element');
     $form->add($url);
     // Элемент Number
     //        $number   = new Element\Number('element-number');
     //        $number->setLabel('Number Element');
     //        $form->add($number);
     // Элемент Range
     //        $range    = new Element\Range('element-range');
     //        $range->setLabel('Range Element');
     //        $form->add($range);
     // Элемент Color
     $color = new Element\Color('element-color');
     $color->setLabel('Color Element');
     $form->add($color);
     return array('form' => $form);
 }
 public function getForm(array $currencies, array $companies, array $contacts, array $statusList)
 {
     if (!$this->form) {
         $hidId = new Element\Hidden();
         $hidId->setName('proposalId');
         $txtCompanyId = new Element\Select();
         $txtCompanyId->setLabel('Company Name')->setName("companyId")->setAttribute('class', 'form-control')->setEmptyOption("--Choose Company--")->setValueOptions($companies);
         $txtContactId = new Element\Select();
         $txtContactId->setLabel('Contact Name')->setName('contactId')->setAttribute('class', 'form-control')->setEmptyOption("--Choose Contact--")->setValueOptions($contacts);
         $txtCode = new Element\Text();
         $txtCode->setLabel('Code')->setName('code')->setAttribute('class', 'form-control');
         $txtName = new Element\Text();
         $txtName->setLabel('Name')->setName('name')->setAttribute('class', 'form-control');
         $txtAmount = new Element\Number();
         $txtAmount->setName("amount")->setLabel('Amount')->setAttribute('class', 'form-control')->setAttributes(array('min' => '100', 'max' => '99999999999', 'step' => '100'));
         $selectCurrency = new Element\Select();
         $selectCurrency->setName('currencyId')->setLabel('Currency')->setAttribute('class', 'form-control')->setValueOptions($currencies);
         $txtProposalDate = new Element\Date('proposalDate');
         $txtProposalDate->setLabel('Date')->setAttributes(array('class' => 'form-control', 'allowPastDates' => true, 'momentConfig' => array('format' => 'YYYY-MM-DD')));
         $txtProposalFile = new Element\File();
         $txtProposalFile->setName('proposalFile')->setLabel('Upload file');
         $txtNodes = new Element\Textarea();
         $txtNodes->setLabel('Notes')->setName('notes')->setAttribute('class', 'form-control');
         $txtProposalBy = new Element\Text();
         $txtProposalBy->setName('proposalBy')->setLabel('Proposal By')->setAttribute('class', 'form-control');
         $txtGroupCode = new Element\Text();
         $txtGroupCode->setLabel('Group Code')->setName('group_code')->setAttribute('class', 'form-control');
         $txtStatus = new Element\Select();
         $txtStatus->setName('status')->setLabel('Status')->setAttribute('class', 'form-control')->setValueOptions($statusList);
         $form = new Form();
         $form->setAttribute('class', 'form-horizontal');
         $form->setAttribute('enctype', 'multipart/form-data');
         $form->add($hidId);
         $form->add($txtCompanyId);
         $form->add($txtContactId);
         $form->add($txtCode);
         $form->add($txtName);
         $form->add($txtAmount);
         $form->add($selectCurrency);
         $form->add($txtProposalDate);
         $form->add($txtProposalFile);
         $form->add($txtNodes);
         $form->add($txtProposalBy);
         $form->add($txtGroupCode);
         $form->add($txtStatus);
         $this->form = $form;
     }
     return $this->form;
 }
 public function getLeaveForm(array $leaveList)
 {
     $leaveType = new Element\Select();
     $leaveType->setName('leaveType')->setLabel('Type')->setAttribute('class', 'form-control')->setValueOptions($leaveList);
     $date = new Element\Date();
     $date->setName('date')->setLabel('Date')->setAttributes(array('allowPastDates' => true, 'momentConfig' => array('format' => 'YYYY-MM-DD')));
     $description = new Element\Textarea('description');
     $description->setLabel('Description')->setAttribute('class', 'form-control');
     $form = new Form();
     $form->setAttribute('class', 'form');
     $form->add($leaveType);
     $form->add($date);
     $form->add($description);
     return $form;
 }
Esempio n. 10
0
 public function testCorrectFormatPassedToDateValidator()
 {
     $element = new DateElement('foo');
     $element->setAttributes(array('min' => '2012-01-01', 'max' => '2012-12-31'));
     $element->setFormat('d-m-Y');
     $inputSpec = $element->getInputSpecification();
     foreach ($inputSpec['validators'] as $validator) {
         switch (get_class($validator)) {
             case 'Zend\\Validator\\DateStep':
             case 'Zend\\Validator\\Date':
                 $this->assertEquals('d-m-Y', $validator->getFormat());
                 break;
         }
     }
 }
 public function getForm(array $usersData, array $positionsData, array $currencyData, array $defaultStatus)
 {
     if (!$this->form) {
         $hidId = new Element\Hidden();
         $hidId->setName('staffId');
         $selectUsers = new Element\Select();
         $selectUsers->setName('userId')->setLabel('User')->setAttribute('class', 'form-control')->setEmptyOption("--Choose User --")->setValueOptions($usersData);
         $staffCode = new Element\Text();
         $staffCode->setLabel('Code')->setName("staffCode")->setAttribute('class', 'form-control');
         $staffName = new Element\Text();
         $staffName->setLabel('Name')->setName("staffName")->setAttribute('class', 'form-control');
         $selectPosition = new Element\Select();
         $selectPosition->setName('positionId')->setLabel('Position')->setAttribute('class', 'form-control')->setEmptyOption("-- Choose Position --")->setValueOptions($positionsData);
         $selectDepartment = new Element\Hidden('departmentId');
         $salary = new Element\Number();
         $salary->setLabel('Salary')->setName("salary")->setAttributes(array('min' => '0', 'max' => '999999999999', 'step' => '1'));
         $leave = new Element\Number();
         $leave->setLabel('Leave')->setName("annual_leave")->setAttributes(array('min' => '0.5', 'max' => '100', 'step' => '0.5'));
         $PermanentDate = new Element\Date('permanentDate');
         $PermanentDate->setLabel('P-Date')->setAttributes(array('allowPastDates' => true, 'momentConfig' => array('format' => 'YYYY-MM-DD')));
         $birthDay = new Element\Date('birthday');
         $birthDay->setLabel('Birthday')->setAttributes(array('allowPastDates' => true, 'momentConfig' => array('format' => 'YYYY-MM-DD')));
         $selectCurrency = new Element\Select();
         $selectCurrency->setName('currencyId')->setAttribute('class', 'form-control')->setValueOptions($currencyData);
         $status = new Element\Select();
         $status->setName('status')->setLabel('Status')->setAttribute('class', 'form-control')->setValueOptions($defaultStatus);
         $bankCode = new Element\Text('bankCode');
         $bankCode->setLabel('Bank Account')->setAttributes(array('class' => 'form-control', 'placeholder' => 'Aya Bank Account No'));
         $form = new Form();
         $form->setAttribute('class', 'form-horizontal');
         $form->add($hidId);
         $form->add($selectUsers);
         $form->add($staffCode);
         $form->add($staffName);
         $form->add($selectPosition);
         $form->add($selectDepartment);
         $form->add($salary);
         $form->add($leave);
         $form->add($PermanentDate);
         $form->add($status);
         $form->add($birthDay);
         $form->add($selectCurrency);
         $form->add($bankCode);
         $this->form = $form;
     }
     return $this->form;
 }
 public function getForm(array $formulaList)
 {
     if (!$this->form) {
         $fromDate = new Element\Date('fromDate');
         $fromDate->setAttributes(array('allowPastDates' => true, 'style' => 'width:120px;', 'momentConfig' => array('format' => 'YYYY-MM-DD')));
         $fromDate->setValue(date('Y-m-26', strtotime('-1 month')));
         $toDate = new Element\Date('toDate');
         $toDate->setAttributes(array('allowPastDates' => true, 'style' => 'width:120px;margin-left:5px;', 'momentConfig' => array('format' => 'YYYY-MM-DD')));
         $toDate->setValue(date('Y-m-25', time('')));
         $formula = new Element\Select();
         $formula->setName('formula')->setAttribute('class', 'form-control')->setAttribute('style', 'width:200px')->setValueOptions($formulaList)->setEmptyOption('-- Choose Formula --');
         $form = new Form();
         $form->setAttributes(array('class' => 'form-inline', 'role' => 'form', 'id' => 'process-form'));
         $form->add($fromDate);
         $form->add($toDate);
         $form->add($formula);
         $this->form = $form;
     }
     return $this->form;
 }
Esempio n. 13
0
 public function __construct()
 {
     // we want to ignore the name passed
     parent::__construct('partyaddress');
     $this->add(new Element\Hidden('id_party'));
     $this->add(new Element\Hidden('id_address'));
     $this->add(new Element\Hidden('num_primary_order'));
     $this->setAttribute('method', 'post');
     $address = new AddressFieldset('address');
     $address->getOptions(array('use_as_base_fieldset' => true));
     $this->add($address);
     $nid_lov_addresstype = new Element\Select('nid_lov_addresstype');
     $nid_lov_addresstype->setLabel('Address Type')->setAttributes(array('class' => 'form-control input-sm'))->setValueOptions(array('' => 'Select an address type'));
     $this->add($nid_lov_addresstype);
     $bool_billing_address = new Element\Radio('bool_billing_address');
     $bool_billing_address->setLabel('Is billing address?')->setLabelAttributes(array('class' => 'radio-line'))->setValueOptions(array('1' => 'Yes', '0' => 'No'));
     $this->add($bool_billing_address);
     $bool_shipping_address = new Element\Radio('bool_shipping_address');
     $bool_shipping_address->setLabel('Is shipping address?')->setLabelAttributes(array('class' => 'radio-inline'))->setValueOptions(array('1' => 'Yes', '0' => 'No'));
     $this->add($bool_shipping_address);
     $flag_status = new Element\Radio('flag_status');
     $flag_status->setLabel('Flag')->setLabelAttributes(array('class' => 'radio-inilne'))->setValueOptions(array('1' => 'Active', '0' => 'Not Active'));
     $this->add($flag_status);
     $dt_begin = new Element\Date('dt_begin');
     $dt_begin->setLabel('Begin Date')->setAttributes(array('class' => 'form-control input-sm', 'type' => 'date', 'id' => 'dt_begin'))->setOptions(array('datepickerOptions' => array('changeYear: true', 'changeMonth: true', 'yearRange: "c-150:c+150"')));
     $this->add($dt_begin);
     $dt_end = new Element\Date('dt_end');
     $dt_end->setLabel('End Date')->setAttributes(array('class' => 'form-control input-sm', 'type' => 'date', 'id' => 'dt_end'))->setOptions(array('datepickerOptions' => array('changeYear: true', 'changeMonth: true', 'yearRange: "c-150:c+150"')));
     $this->add($dt_end);
     $comment = new Element\Textarea('comment');
     $comment->setLabel('Comment')->setAttributes(array('class' => 'form-control input-sm'));
     $this->add($comment);
     $back = new Element\Button('back');
     $back->setLabel('Back')->setAttributes(array('id' => 'backbutton', 'class' => 'btn btn-primary btn-sm', 'onclick' => ''));
     $this->add($back);
     $submit = new Element\Submit('submit');
     $submit->setValue('Go')->setAttributes(array('id' => 'submitbutton', 'class' => 'btn btn-primary btn-sm'));
     $this->add($submit);
 }
 public function getForm($managers)
 {
     if (!$this->form) {
         $projectId = new Element\Hidden();
         $projectId->setName('projectId');
         $code = new Element\Text();
         $code->setLabel('Code')->setName('code')->setAttributes(array('class' => 'form-control'), 'placeholder', 'Enter Code');
         $name = new Element\Text();
         $name->setLabel('Name')->setName('name')->setAttributes(array('class' => 'form-control'), 'placeholder', 'Enter Name');
         $description = new Element\Textarea();
         $description->setLabel('Description')->setName('description')->setAttributes(array('class' => 'form-control'), 'placeholder', 'Enter Description');
         $manager = new Element\Select();
         $manager->setLabel('Manager')->setAttribute('class', 'form-control')->setName('managerId')->setEmptyOption('---Choose Manager---')->setValueOptions($managers);
         $startDate = new Element\Date('startDate');
         $startDate->setLabel('Start Date')->setName('startDate')->setAttributes(array('class' => 'form-control', 'allowPastDates' => true, 'momentConfig' => array('format' => 'YYYY-MM-DD')));
         $endDate = new Element\Date('endDate');
         $endDate->setLabel('End Date')->setName('endDate')->setAttributes(array('class' => 'form-control', 'allowPastDates' => true, 'momentConfig' => array('format' => 'YYYY-MM-DD')));
         $group_code = new Element\Text();
         $group_code->setLabel('group_code')->setName('group_code')->setAttributes(array('class' => 'form-control', 'placeholder' => 'Enter Group Code'));
         $status = new Element\Select();
         $status->setLabel('Status')->setName('status')->setAttribute('class', 'form-control')->setValueOptions(array('A' => 'Active', 'D' => 'Inactive'));
         $remark = new Element\Textarea();
         $remark->setLabel('Remark')->setName('remark')->setAttributes(array('class' => 'form-control', 'placeholder' => 'Enter Remark'));
         $form = new Form();
         $form->setAttributes(array('class' => 'form-horizontal', 'enctype' => 'multipart/form-data'));
         $form->add($projectId);
         $form->add($code);
         $form->add($name);
         $form->add($description);
         $form->add($manager);
         $form->add($startDate);
         $form->add($endDate);
         $form->add($group_code);
         $form->add($status);
         $form->add($remark);
         $this->form = $form;
     }
     return $this->form;
 }
 public function getForm(array $currencies)
 {
     if (!$this->form) {
         $hidId = new Element\Hidden();
         $hidId->setName('receiveVoucherId');
         $txtVoucherNo = new Element\Text();
         $txtVoucherNo->setLabel('Number')->setName("voucherNo")->setAttribute('class', 'form-control text-center')->setAttribute('readonly', 'readonly');
         $txtVoucherDate = new Element\Date('voucherDate');
         $txtVoucherDate->setLabel('Date')->setAttributes(array('class' => 'form-control', 'allowPastDates' => true, 'momentConfig' => array('format' => 'YYYY-MM-DD')));
         $txtAccountType = new Element\Hidden('accountType');
         $txtDescription = new Element\Textarea();
         $txtDescription->setName("description")->setLabel('Description')->setAttribute('class', 'form-control');
         $txtAmount = new Element\Number();
         $txtAmount->setName("amount")->setLabel('Amount')->setAttribute('class', 'form-control')->setattributes(array('min' => '10', 'max' => '99999999999', 'step' => '1'));
         $cboCurrency = new Element\Select();
         $cboCurrency->setName('currencyId')->setLabel('Currency Type')->setAttribute('class', 'form-control')->setEmptyOption('-- Choose --')->setValueOptions($currencies);
         $txtDepositBy = new Element\Hidden();
         $txtDepositBy->setName("depositBy");
         $txtReason = new Element\Textarea();
         $txtReason->setName('reason');
         $txtGroupCode = new Element\Text();
         $txtGroupCode->setName('group_code')->setLabel('Group Code (optional)')->setAttribute('class', 'form-control');
         $form = new Form();
         $form->setAttribute('role', 'form');
         $form->add($hidId);
         $form->add($txtVoucherNo);
         $form->add($txtVoucherDate);
         $form->add($txtAccountType);
         $form->add($txtDescription);
         $form->add($txtAmount);
         $form->add($cboCurrency);
         $form->add($txtDepositBy);
         $form->add($txtReason);
         $form->add($txtGroupCode);
         $this->form = $form;
     }
     return $this->form;
 }
Esempio n. 16
0
 public function __construct($name = null)
 {
     parent::__construct('campaignForm');
     $this->setAttribute('method', 'post');
     $sponsor = new Element\Hidden('ID_SPONSOR');
     $sponsor->setValue('0');
     $nombre = new Element\Text('NOMBRE');
     $nombre->setLabel('Nombre de la campaña: ');
     $descripcion = new Element\Textarea('DESCRIPCION');
     $descripcion->setLabel('Descripcion: ');
     $slogan = new Element\Textarea('SLOGAN');
     $slogan->setLabel('Slogan de la campaña: ');
     $fecha_inicio = new Element\Date('FECHA_INICIO');
     $fecha_inicio->setLabel('Fecha de inicio de la campaña: ')->setAttributes(array('min' => '2012-01-01', 'max' => '2080-01-01', 'step' => '1'));
     $fecha_fin = new Element\Date('FECHA_FIN');
     $fecha_fin->setLabel('Fecha de fin de la campaña: ')->setAttributes(array('min' => '2012-01-01', 'max' => '2080-01-01', 'step' => '1'));
     $this->add($sponsor);
     $this->add($nombre);
     $this->add($descripcion);
     $this->add($slogan);
     $this->add($fecha_inicio);
     $this->add($fecha_fin);
     $this->add(array('name' => 'submit', 'attributes' => array('type' => 'submit', 'value' => 'Agregar campaña', 'id' => 'submitbutton')));
 }
 public function getForm(array $staffList, array $statusList, array $leaveList, $formType = 'W')
 {
     if (!$this->form) {
         $leaveId = new Element\Hidden('leaveId');
         $staff = new Element\Select();
         $staff->setName('staffId')->setEmptyOption('-- Choose Staff --')->setLabel('Staff')->setAttribute('class', 'form-control')->setValueOptions($staffList);
         $leaveType = new Element\Select();
         $leaveType->setName('leaveType')->setLabel('Type')->setAttribute('class', 'form-control')->setValueOptions($leaveList);
         $date = new Element\Date();
         $date->setName('date')->setLabel('Date')->setAttributes(array('allowPastDates' => true, 'momentConfig' => array('format' => 'YYYY-MM-DD')));
         $description = new Element\Textarea('description');
         $description->setLabel('Description')->setAttribute('class', 'form-control');
         $status = new Element\Select();
         $status->setName('status')->setLabel('Status')->setAttribute('class', 'form-control')->setValueOptions($statusList);
         if ($formType == 'R' || $formType == 'V') {
             $staff->setAttribute('disabled', 'disabled');
             $leaveType->setAttribute('disabled', 'disabled');
             $description->setAttribute('readonly', 'readonly');
         }
         if ($formType == 'V') {
             $status->setAttribute('disabled', 'disabled');
             $date = new Element\Text();
             $date->setName('date')->setLabel('Date')->setattributes(array('class' => 'form-control', 'disabled' => 'disabled'));
         }
         $form = new Form();
         $form->setAttribute('class', 'form-horizontal');
         $form->add($leaveId);
         $form->add($staff);
         $form->add($leaveType);
         $form->add($date);
         $form->add($description);
         $form->add($status);
         $this->form = $form;
     }
     return $this->form;
 }
Esempio n. 18
0
 public function __construct()
 {
     parent::__construct('person');
     $this->setAttribute('method', 'post');
     $nid_timezone = new Element\Select('nid_timezone');
     $nid_timezone->setLabel('Time Zone')->setAttributes(array('class' => 'form-control input-sm'))->setValueOptions(array('0' => 'Select a timezone'));
     $this->add($nid_timezone);
     $nid_locale = new Element\Select('nid_locale');
     $nid_locale->setLabel('Locale')->setAttributes(array('class' => 'form-control input-sm'))->setValueOptions(array('0' => 'Select a locale'));
     $this->add($nid_locale);
     $nid_language = new Element\Select('nid_language');
     $nid_language->setLabel('Language')->setAttributes(array('class' => 'form-control input-sm'))->setValueOptions(array('0' => 'Select a language'));
     $this->add($nid_language);
     $nid_lov_currency = new Element\Select('nid_lov_currency');
     $nid_lov_currency->setLabel('Currency')->setAttributes(array('class' => 'form-control input-sm'))->setValueOptions(array('0' => 'Select a Currency'));
     $this->add($nid_lov_currency);
     $name_party = new Element\Text('name_party');
     $name_party->setLabel('Party Name')->setAttributes(array('class' => 'form-control input-sm'));
     $this->add($name_party);
     $bool_active = new Element\Radio('bool_active');
     $bool_active->setLabel('Active')->setLabelAttributes(array('class' => 'radio-inline'))->setValueOptions(array('1' => 'Yes', '0' => 'No'));
     $this->add($bool_active);
     $party_alias = new Element\Text('party_alias');
     $party_alias->setLabel('Party Alias')->setAttributes(array('class' => 'form-control input-sm'));
     $this->add($party_alias);
     $id_pr_address = new Element\Radio('id_pr_address');
     $id_pr_address->setLabel('Primary Address')->setLabelAttributes(array('class' => 'radio-inline'))->setValueOptions(array('' => 'No Primary Address'));
     $this->add($id_pr_address);
     $id_pr_comm_phone = new Element\Select('id_pr_comm_phone');
     $id_pr_comm_phone->setLabel('Phone')->setAttributes(array('class' => 'form-control input-sm'))->setValueOptions(array('' => 'Select a phone'));
     $this->add($id_pr_comm_phone);
     $id_pr_comm_email = new Element\Select('id_pr_comm_email');
     $id_pr_comm_email->setLabel('Email')->setAttributes(array('class' => 'form-control input-sm'))->setValueOptions(array('' => 'Select an email'));
     $this->add($id_pr_comm_email);
     $id_pr_comm_fax = new Element\Select('id_pr_comm_fax');
     $id_pr_comm_fax->setLabel('Fax')->setAttributes(array('class' => 'form-control input-sm'))->setValueOptions(array('' => 'Select a fax'));
     $this->add($id_pr_comm_fax);
     $id_pr_comm_sm = new Element\Select('id_pr_comm_sm');
     $id_pr_comm_sm->setLabel('SM')->setAttributes(array('class' => 'form-control input-sm'))->setValueOptions(array('' => 'Select a SM'));
     $this->add($id_pr_comm_sm);
     $access_form = new Element\Text('access_form');
     $access_form->setLabel('Access Form')->setAttributes(array('class' => 'form-control input-sm'));
     $this->add($access_form);
     $name_first = new Element\Text('name_first');
     $name_first->setLabel('First Name')->setAttributes(array('class' => 'form-control input-sm'));
     $this->add($name_first);
     $name_last = new Element\Text('name_last');
     $name_last->setLabel('Last Name')->setAttributes(array('class' => 'form-control input-sm'));
     $this->add($name_last);
     $name_middle = new Element\Text('name_middle');
     $name_middle->setLabel('Middle Name')->setAttributes(array('class' => 'form-control input-sm'));
     $this->add($name_middle);
     $name_alias = new Element\Text('name_alias');
     $name_alias->setLabel('Nick Name')->setAttributes(array('class' => 'form-control input-sm'));
     $this->add($name_alias);
     $name_maiden = new Element\Text('name_maiden');
     $name_maiden->setLabel('Maiden Name')->setAttributes(array('class' => 'form-control input-sm'));
     $this->add($name_maiden);
     $name_mother_maiden = new Element\Text('name_mother_maiden');
     $name_mother_maiden->setLabel('Mother Maiden Name')->setAttributes(array('class' => 'form-control input-sm'));
     $this->add($name_mother_maiden);
     $dt_birth = new Element\Date('dt_birth');
     $dt_birth->setLabel('Date of Birth')->setAttributes(array('class' => 'form-control input-sm', 'type' => 'date', 'id' => 'dt_birth'))->setOptions(array('datepickerOptions' => array('changeYear: true', 'changeMonth: true', 'yearRange: "c-100:c"')));
     $this->add($dt_birth);
     $num_age_when_registered = new Element\Text('num_age_when_registered');
     $num_age_when_registered->setLabel('Age When Registered')->setAttributes(array('class' => 'form-control input-sm'));
     $this->add($num_age_when_registered);
     $nid_lov_gender = new Element\Radio('nid_lov_gender');
     $nid_lov_gender->setLabel('Gender')->setLabelAttributes(array('class' => 'radio-inline'))->setValueOptions(array('0' => 'male'));
     $this->add($nid_lov_gender);
     $id_emergcon = new Element\Select('id_emergcon');
     $id_emergcon->setLabel('Emergency Contact')->setAttributes(array('class' => 'form-control input-sm'))->setValueOptions(array('0' => 'Select a Contact'));
     $this->add($id_emergcon);
     $nid_lov_emergcon = new Element\Radio('nid_lov_emergcon');
     $nid_lov_emergcon->setLabel('Emergency Contact Type')->setLabelAttributes(array('class' => 'radio-inline'));
     $this->add($nid_lov_emergcon);
     $comment = new Element\Textarea('comment');
     $comment->setLabel('Comment')->setAttributes(array('class' => 'form-control input-sm'));
     $this->add($comment);
     $bool_active = new Element\Radio('bool_active');
     $bool_active->setLabel('Active')->setLabelAttributes(array('class' => 'radio-inline'))->setValueOptions(array('1' => 'Yes', '0' => 'No'));
     $this->add($bool_active);
     $back = new Element\Button('back');
     $back->setLabel('Back')->setAttributes(array('id' => 'backbutton', 'class' => 'btn btn-primary btn-sm', 'onclick' => ''));
     $this->add($back);
     $submit = new Element\Submit('submit');
     $submit->setValue('Login')->setAttributes(array('id' => 'submitbutton', 'class' => 'btn btn-primary btn-sm'));
     $this->add($submit);
 }
Esempio n. 19
0
 /**
  * Prepara os campos do formulário
  * @param  string    $fieldName
  * @param  array     $fieldParams
  * @param  array     $options
  * @return object
  * @throws Exception
  */
 private function prepareFields($fieldName, array $fieldParams, array $options = array())
 {
     $element = null;
     $extraLabel = " ";
     $this->aOptions = array();
     $this->aAttributes = array();
     /* Define o tooltip do campo */
     $tooltip = (isset($fieldParams['tooltip']) and $fieldParams['tooltip'] == 'true') ? "<a class=\"tooltip-marc\" href=\"#\" data-toggle=\"tooltip\" title=\"{$this->getTranslator($fieldName . '_tooltip')}\">[?]</a>" : null;
     $this->aOptions['tooltip'] = $tooltip;
     /* Define como será mostrado o nome do campo (se é obrigatório ou não) */
     if (strtolower($fieldParams['type']) != 'hidden') {
         if (isset($fieldParams['validation']) and stristr(strtolower($fieldParams['validation']), "required")) {
             $extraLabel = " * ";
         }
     }
     switch (strtolower($fieldParams['type'])) {
         /* Caso hidden */
         case 'primary':
         case 'hidden':
             $element = new ZendFormElement\Hidden($fieldName);
             break;
             /* Caso Csrf */
         /* Caso Csrf */
         case 'csrf':
         case 'sec':
             $element = new ZendFormElement\Csrf($fieldName);
             $element->setCsrfValidatorOptions(array('timeout' => '600'));
             break;
             /* Caso text */
         /* Caso text */
         case 'text':
             $element = new ZendFormElement\Text($fieldName);
             $element->setLabel($this->getTranslator($fieldName) . $extraLabel);
             $this->aAttributes['class'] = 'form-input';
             break;
             /* Caso textarea */
         /* Caso textarea */
         case 'textarea':
             $element = new ZendFormElement\Textarea($fieldName);
             $element->setLabel($this->getTranslator($fieldName) . $extraLabel);
             /* Define os padrões de colunas e linhas do campo */
             $this->aAttributes['rows'] = (isset($fieldParams['rows']) and !empty($fieldParams['rows'])) ? $fieldParams['rows'] : 5;
             $this->aAttributes['cols'] = (isset($fieldParams['cols']) and !empty($fieldParams['cols'])) ? $fieldParams['cols'] : 10;
             $this->aAttributes['class'] = 'form-input';
             $this->aAttributes['data-editor'] = 'false';
             break;
             /* Caso editor */
         /* Caso editor */
         case 'editor':
             $element = new ZendFormElement\Textarea($fieldName);
             $element->setLabel($this->getTranslator($fieldName) . $extraLabel);
             /* Define os padrões de colunas e linhas do campo */
             $this->aAttributes['rows'] = (isset($fieldParams['rows']) and !empty($fieldParams['rows'])) ? $fieldParams['rows'] : 5;
             $this->aAttributes['cols'] = (isset($fieldParams['cols']) and !empty($fieldParams['cols'])) ? $fieldParams['cols'] : 10;
             /* Verifica se utilizará o editor */
             $this->aAttributes['class'] = 'editorw';
             $this->aAttributes['data-editor'] = 'true';
             /* Verifica a pasta de upload */
             if (isset($this->formDefaultConfig['destination']) and !empty($this->formDefaultConfig['destination'])) {
                 /* Caso não exista a pasta cria o mesmo */
                 if (!is_dir(UPLOAD_PATH . $this->formDefaultConfig['destination'])) {
                     mkdir(UPLOAD_PATH . $this->formDefaultConfig['destination'], 0777, true);
                     chmod(UPLOAD_PATH . $this->formDefaultConfig['destination'], 0777);
                 }
                 $_SESSION['KCFINDER'] = array();
                 $_SESSION['KCFINDER']['disabled'] = false;
                 $_SESSION['KCFINDER']['uploadURL'] = URL_UPLOAD . $this->formDefaultConfig['destination'];
                 $_SESSION['KCFINDER']['uploadDir'] = UPLOAD_PATH . $this->formDefaultConfig['destination'];
             } else {
                 throw new \Exception('Defina a pasta de destino de upload das imagens do editor!', 500);
             }
             break;
             /* Caso password */
         /* Caso password */
         case 'password':
             $element = new ZendFormElement\Password($fieldName);
             $element->setLabel($this->getTranslator($fieldName) . $extraLabel);
             $this->aAttributes['renderPassword'] = true;
             $this->aAttributes['class'] = 'form-input';
             break;
             /* Caso radio */
         /* Caso radio */
         case 'radio':
             $element = new ZendFormElement\Radio($fieldName);
             $element->setLabel($this->getTranslator($fieldName) . $extraLabel);
             $this->aAttributes['class'] = 'radio';
             break;
             /* Caso checkbox */
         /* Caso checkbox */
         case 'checkbox':
             $element = new ZendFormElement\Checkbox($fieldName);
             $element->setLabel($this->getTranslator($fieldName) . $extraLabel);
             $element->setUncheckedValue(null);
             $this->aAttributes['class'] = 'checkbox';
             break;
             /* Caso multicheckbox */
         /* Caso multicheckbox */
         case 'multicheckbox':
             $element = new ZendFormElement\MultiCheckbox($fieldName);
             $element->setLabel($this->getTranslator($fieldName) . $extraLabel);
             $element->setUncheckedValue(null);
             break;
             /* Caso select */
         /* Caso select */
         case 'select':
             $element = new ZendFormElement\Select($fieldName, array('disable_inarray_validator' => true));
             $element->setLabel($this->getTranslator($fieldName) . $extraLabel);
             $this->selectOptions = array();
             if (isset($fieldParams['placeholder']) and strtolower($fieldParams['placeholder']) == 'true') {
                 $this->selectOptions[''] = $this->getTranslator($fieldName . '_placeholder');
             } else {
                 $this->selectOptions[''] = "---------";
             }
             $this->aAttributes['class'] = 'form-input-select';
             break;
             /* Caso selectgroup */
         /* Caso selectgroup */
         case 'selectgroup':
             $element = new ZendFormElement\Select($fieldName, array('disable_inarray_validator' => true));
             $element->setLabel($this->getTranslator($fieldName) . $extraLabel);
             $this->selectOptions = array();
             if (isset($fieldParams['placeholder']) and strtolower($fieldParams['placeholder']) == 'true') {
                 $this->selectOptions[''] = $this->getTranslator($fieldName . '_placeholder');
             } else {
                 $this->selectOptions[''] = "---------";
             }
             $this->aAttributes['class'] = 'form-input-select';
             break;
             /* Caso multiselect */
         /* Caso multiselect */
         case 'multiselect':
             $element = new ZendFormElement\Select($fieldName, array('disable_inarray_validator' => true));
             $element->setLabel($this->getTranslator($fieldName) . $extraLabel);
             $this->aAttributes['class'] = 'form-input-select ms';
             $this->aAttributes['multiple'] = 'multiple';
             break;
             /* Caso fileimage */
         /* Caso fileimage */
         case 'fileimage':
             $element = new ZendFormElement\File($fieldName);
             $element->setLabel($this->getTranslator($fieldName) . $extraLabel);
             //$this->aAttributes['multiple'] = true;
             $this->aAttributes['class'] = 'hiddenImageFile';
             /* Verifica a pasta de upload */
             if (isset($this->formDefaultConfig['pathfiles']) and !empty($this->formDefaultConfig['pathfiles'])) {
                 /* Caso não exista a pasta cria o mesmo */
                 if (!is_dir(UPLOAD_PATH . $this->formDefaultConfig['pathfiles'])) {
                     mkdir(UPLOAD_PATH . $this->formDefaultConfig['pathfiles'], 0777, true);
                     chmod(UPLOAD_PATH . $this->formDefaultConfig['pathfiles'], 0777);
                 }
                 $this->aAttributes['data-path'] = LINK_DEFAULT . 'uploads/' . $this->formDefaultConfig['pathfiles'];
             } else {
                 throw new \Exception('Defina a pasta de destino de upload das imagens do editor!', 500);
             }
             break;
             /* Caso file */
         /* Caso file */
         case 'file':
             $element = new ZendFormElement\File($fieldName);
             $element->setLabel($this->getTranslator($fieldName) . $extraLabel);
             break;
         case 'money':
             $element = new ZendFormElement\Text($fieldName);
             $element->setLabel($this->getTranslator($fieldName) . $extraLabel);
             $this->aAttributes['class'] = 'form-input';
             break;
             /* HTML5 Elements */
             /* Caso url */
         /* HTML5 Elements */
         /* Caso url */
         case 'url':
             $element = new ZendFormElement\Url($fieldName);
             $element->setLabel($this->getTranslator($fieldName) . $extraLabel);
             $this->aAttributes['class'] = 'form-input';
             break;
             /* Caso date */
         /* Caso date */
         case 'date':
             $element = new ZendFormElement\Date($fieldName);
             $element->setLabel($this->getTranslator($fieldName) . $extraLabel);
             $this->aAttributes['min'] = date("Y") - 10 . '-01-01';
             $this->aAttributes['max'] = date("Y") + 10 . '-12-31';
             $this->aAttributes['class'] = 'form-input';
             break;
         case 'dateage':
             $element = new ZendFormElement\Date($fieldName);
             $element->setLabel($this->getTranslator($fieldName) . $extraLabel);
             $this->aAttributes['min'] = date("Y") - 100 . '-01-01';
             $this->aAttributes['max'] = date("Y") + 100 . '-12-31';
             $this->aAttributes['class'] = 'form-input';
             break;
             /* Caso time */
         /* Caso time */
         case 'time':
             $element = new ZendFormElement\DateTime($fieldName);
             $element->setLabel($this->getTranslator($fieldName) . $extraLabel);
             $this->aAttributes['class'] = 'form-input';
             $this->aAttributes['min'] = '00:00:00';
             $this->aAttributes['max'] = '23:59:59';
             $this->aOptions['format'] = 'H:i:s';
             break;
             /* Caso date */
         /* Caso date */
         case 'datetime':
             $element = new ZendFormElement\DateTime($fieldName);
             $element->setLabel($this->getTranslator($fieldName) . $extraLabel);
             $this->aAttributes['min'] = date("Y") - 10 . '-01-01 00:00:00';
             $this->aAttributes['max'] = date("Y") + 10 . '-12-31 23:59:59';
             $this->aAttributes['class'] = 'form-input';
             break;
             /* Caso email */
         /* Caso email */
         case 'email':
             $element = new ZendFormElement\Email($fieldName);
             $element->setLabel($this->getTranslator($fieldName) . $extraLabel);
             $this->aAttributes['class'] = 'form-input';
             break;
             /* Caso number */
         /* Caso number */
         case 'number':
             $element = new ZendFormElement\Number($fieldName);
             $element->setLabel($this->getTranslator($fieldName) . $extraLabel);
             $this->aAttributes['step'] = '1';
             $this->aAttributes['class'] = 'form-input';
             break;
         case 'integer':
             $element = new ZendFormElement\Number($fieldName);
             $element->setLabel($this->getTranslator($fieldName) . $extraLabel);
             $this->aAttributes['min'] = '0';
             $this->aAttributes['max'] = '99999999999999999999';
             $this->aAttributes['step'] = '1';
             $this->aAttributes['class'] = 'form-input';
             break;
         case 'float':
             $element = new ZendFormElement\Number($fieldName);
             $element->setLabel($this->getTranslator($fieldName) . $extraLabel);
             $this->aAttributes['step'] = '0.001';
             $this->aAttributes['class'] = 'form-input';
             break;
             /* Plataforma */
             /* Caso select */
         /* Plataforma */
         /* Caso select */
         case 'status':
             $element = new ZendFormElement\Select($fieldName, array('disable_inarray_validator' => true));
             $element->setLabel($this->getTranslator($fieldName) . $extraLabel);
             if (isset($fieldParams['placeholder']) and strtolower($fieldParams['placeholder']) == 'true') {
                 $this->selectOptions[''] = $this->getTranslator($fieldName . '_placeholder');
             } else {
                 $this->selectOptions[''] = "---------";
             }
             $this->aAttributes['class'] = 'form-input-select';
             break;
             /* Caso boolean */
         /* Caso boolean */
         case 'boolean':
             $element = new ZendFormElement\Select($fieldName, array('disable_inarray_validator' => true));
             $element->setLabel($this->getTranslator($fieldName) . $extraLabel);
             if (isset($fieldParams['placeholder']) and strtolower($fieldParams['placeholder']) == 'true') {
                 $this->selectOptions[''] = $this->getTranslator($fieldName . '_placeholder');
             } else {
                 $this->selectOptions[''] = "---------";
             }
             $this->aAttributes['class'] = 'form-input-select';
             break;
     }
     /* Verifica se foi setado classe de estilo e implementa */
     if (isset($fieldParams['class']) and !empty($fieldParams['class'])) {
         if (isset($this->aAttributes['class']) and $this->aAttributes['class'] != "") {
             $this->aAttributes['class'] = $this->aAttributes['class'] . " " . $fieldParams['class'];
         } else {
             $this->aAttributes['class'] = $fieldParams['class'];
         }
     }
     /* Define a descrição abaixo do campo */
     if (isset($fieldParams['description']) and $fieldParams['description'] == 'true') {
         $this->aOptions['help-block'] = $this->getTranslator($fieldName . '_description');
     }
     /* Verifica se foi setado grupo do campo e implementa */
     if (isset($fieldParams['group']) and !empty($fieldParams['group'])) {
         $this->aOptions['group'] = $fieldParams['group'];
     }
     /* Verifica se foi setado placeholder no campo e implementa */
     if (isset($fieldParams['placeholder']) and strtolower($fieldParams['placeholder']) == 'true') {
         $this->aAttributes['placeholder'] = $this->getTranslator($fieldName . '_placeholder');
     }
     /* Verifica se foi setado somente leitura e implementa */
     if (isset($fieldParams['readonly']) and strtolower($fieldParams['readonly']) == 'true') {
         $this->aAttributes['readonly'] = 'readonly';
     }
     /* Verifica se foi setado desabilitado e implementa */
     if (isset($fieldParams['disabled']) and strtolower($fieldParams['disabled']) == 'true') {
         $this->aAttributes['disabled'] = true;
     }
     /* Verifica se utilizará mascara no campo */
     if (isset($fieldParams['mask']) and !empty($fieldParams['mask'])) {
         $this->aAttributes['data-inputmask'] = $fieldParams['mask'];
     }
     /* Verifica se foi setado inputgroup tipo append e implementa */
     if (isset($fieldParams['groupappend']) and !empty($fieldParams['groupappend'])) {
         $this->aOptions['add-on-append'] = $fieldParams['groupappend'];
     }
     /* Verifica se foi setado inputgroup tipo prepend e implementa */
     if (isset($fieldParams['groupprepend']) and !empty($fieldParams['groupprepend'])) {
         $this->aOptions['add-on-prepend'] = $fieldParams['groupprepend'];
     }
     /* Verifica se foi setado como array e implementa */
     if (isset($fieldParams['array']) and strtolower($fieldParams['array']) == 'true') {
         $this->aOptions['disable_inarray_validator'] = false;
     }
     if (strtolower($fieldParams['type']) !== 'checkbox' and strtolower($fieldParams['type']) !== 'button') {
         if (strtolower($fieldParams['type']) !== 'textarea' and strtolower($fieldParams['type']) !== 'editor') {
             //$this->aOptions['column-size'] = 'col4';
         } else {
             //$this->aOptions['column-size'] = 'col6';
         }
         $this->aOptions['labelattributes'] = array('class' => 'form-label');
     } else {
         //$this->aOptions['column-size'] = 'col6 col-sm-offset-2';
         unset($this->aOptions['labelattributes']);
     }
     return array('element' => $element, 'params' => $fieldParams);
 }
Esempio n. 20
0
 protected function generateFormElementByType($name, $type, $values = array(), $priority)
 {
     switch ($type) {
         case 'FILE':
             $elm = new Element\File();
             $elm->setLabel(strtoupper($name));
             break;
         case 'SELECT':
             $elm = new Element\Select($name);
             $elm->setLabel(strtoupper($name));
             $elm->setAttribute('id', $name . '_ID');
             if ($values instanceof \Traversable || is_array($values)) {
                 $elm->setValueOptions($values);
             }
             break;
         case 'DATE':
             if (isset($option_elements['DateTimePicker']) && $option_elements['DateTimePicker']['status'] == 'enabled') {
                 $elm = new \Zf2datatable\Form\Element\DateCalendar($name);
                 $elm->setAttribute('id', $name . '_ID');
                 $elm->setAttribute('class', 'form-control');
                 $elm->setLabel($name);
                 $elm->setAttribute('jsOption', $option_elements['DateTimePicker']['options']['date_js_properties']);
                 \Zf2datatable\Form\Element\DateCalendar::setDateFormatIn($option_elements['DateTimePicker']['options']['date_format_in']);
                 \Zf2datatable\Form\Element\DateCalendar::setDateFormatOut($option_elements['DateTimePicker']['options']['date_format_out']);
             } else {
                 $elm = new Element\Date($name);
                 $elm->setLabel(strtoupper($name));
                 $elm->setAttributes(array('type' => 'date'));
                 $elm->setFormat('Y-m-d');
             }
             break;
         case 'DATETIME':
             if (isset($option_elements['DateTimePicker']) && $option_elements['DateTimePicker']['status'] == 'enabled') {
                 $elm = new \Zf2datatable\Form\Element\DateTimeCalendar($name);
                 $elm->setAttribute('id', $name . '_ID');
                 $elm->setAttribute('class', 'form-control');
                 $elm->setLabel($name);
                 $elm->setAttribute('jsOption', $option_elements['DateTimePicker']['options']['datetime_js_properties']);
                 \Zf2datatable\Form\Element\DateTimeCalendar::setDateFormatIn($option_elements['DateTimePicker']['options']['datetime_format_in']);
                 \Zf2datatable\Form\Element\DateTimeCalendar::setDateFormatOut($option_elements['DateTimePicker']['options']['datetime_format_out']);
             } else {
                 $elm = new Element\DateTimeSelect($name);
                 $elm->setLabel(strtoupper($name));
             }
             break;
         default:
             $elm = new Element($name);
             $elm->setLabel(strtoupper($name));
             $elm->setAttributes(array('type' => 'text'));
             break;
     }
     $elm->setOption('priority', $priority);
     return $elm;
 }
Esempio n. 21
0
 public function init()
 {
     $customer = new Select('customer');
     $customer->setAttribute('id', 'customer');
     $customer->setAttribute('title', $this->translator->translate('web.form.document.customer.title'));
     $customer->setAttribute('class', 'form-control');
     $customer->setEmptyOption($this->translator->translate('web.form.document.customer.emptyOption'));
     $customer->setValueOptions($this->getCustomerValues());
     $customer->setLabel($this->translator->translate('web.form.document.customer.label'));
     $this->add($customer);
     $supplier = new Select('supplier');
     $supplier->setAttribute('id', 'supplier');
     $supplier->setAttribute('title', $this->translator->translate('web.form.document.supplier.title'));
     $supplier->setAttribute('class', 'form-control');
     $supplier->setEmptyOption($this->translator->translate('web.form.document.supplier.emptyOption'));
     $supplier->setValueOptions($this->getSupplierValues());
     $supplier->setLabel($this->translator->translate('web.form.document.supplier.label'));
     $this->add($supplier);
     $paymentType = new Select('paymentType');
     $paymentType->setAttribute('id', 'paymentType');
     $paymentType->setAttribute('title', $this->translator->translate('web.form.document.paymentMethod.title'));
     $paymentType->setAttribute('class', 'form-control');
     $paymentType->setEmptyOption($this->translator->translate('web.form.document.paymentMethod.emptyOption'));
     $paymentType->setValueOptions(Document::$paymentTypes);
     $paymentType->setLabel($this->translator->translate('web.form.document.paymentMethod.label'));
     $this->add($paymentType);
     $vat = new Select('vat');
     $vat->setAttribute('id', 'vat');
     $vat->setAttribute('title', $this->translator->translate('web.form.document.vat.title'));
     $vat->setAttribute('class', 'form-control');
     $vat->setEmptyOption($this->translator->translate('web.form.document.vat.emptyOption'));
     $vat->setValueOptions($this->getVatValues());
     $vat->setLabel($this->translator->translate('web.form.document.vat.label'));
     $this->add($vat);
     $docDate = new Date('docDate');
     $docDate->setAttributes(array('id' => 'docDate', 'type' => 'text', 'class' => 'input datepicker form-control', 'data-date-weekstart' => 1, 'data-date-format' => 'dd.mm.yyyy'));
     $docDate->setAttribute('title', $this->translator->translate('web.form.document.docDate.title'));
     $docDate->setAttribute('readonly', 'readonly');
     $docDate->setAttribute('placeholder', $this->translator->translate('web.form.document.docDate.placeholder'));
     $docDate->setLabel($this->translator->translate('web.form.document.docDate.label'));
     $this->add($docDate);
     $supplierDocNumber = new Text('supplierDocNumber');
     $supplierDocNumber->setAttribute('id', 'supplierDocNumber');
     $supplierDocNumber->setAttribute('title', $this->translator->translate('web.form.document.supplierDocNumber.title'));
     $supplierDocNumber->setAttribute('class', 'form-control');
     $supplierDocNumber->setAttribute('placeholder', $this->translator->translate('web.form.document.supplierDocNumber.placeholder'));
     $supplierDocNumber->setLabel($this->translator->translate('web.form.document.supplierDocNumber.label'));
     $this->add($supplierDocNumber);
     $deadlineDays = new Text('deadlineDays');
     $deadlineDays->setAttribute('id', 'deadlineDays');
     $deadlineDays->setAttribute('title', $this->translator->translate('web.form.document.deadlineDays.title'));
     $deadlineDays->setAttribute('class', 'form-control');
     $deadlineDays->setAttribute('placeholder', $this->translator->translate('web.form.document.deadlineDays.placeholder'));
     $deadlineDays->setLabel($this->translator->translate('web.form.document.deadlineDays.label'));
     $this->add($deadlineDays);
     $delayPercent = new Text('delayPercent');
     $delayPercent->setAttribute('id', 'delayPercent');
     $delayPercent->setAttribute('class', 'form-control');
     $delayPercent->setAttribute('title', $this->translator->translate('web.form.document.delayPercent.title'));
     $delayPercent->setAttribute('placeholder', $this->translator->translate('web.form.document.delayPercent.placeholder'));
     $delayPercent->setLabel($this->translator->translate('web.form.document.delayPercent.label'));
     $this->add($delayPercent);
     $amount = new Text('amount');
     $amount->setAttribute('id', 'amount');
     $amount->setAttribute('title', $this->translator->translate('web.form.document.amount.title'));
     $amount->setAttribute('class', 'form-control');
     $amount->setAttribute('readonly', 'readonly');
     $amount->setAttribute('placeholder', $this->translator->translate('web.form.document.amount.placeholder'));
     $amount->setLabel($this->translator->translate('web.form.document.amount.label'));
     $this->add($amount);
     $taxAmount = new Text('taxAmount');
     $taxAmount->setAttribute('id', 'taxAmount');
     $taxAmount->setAttribute('title', $this->translator->translate('web.form.document.taxAmount.title'));
     $taxAmount->setAttribute('class', 'form-control');
     $taxAmount->setAttribute('readonly', 'readonly');
     $taxAmount->setAttribute('placeholder', $this->translator->translate('web.form.document.taxAmount.placeholder'));
     $taxAmount->setLabel($this->translator->translate('web.form.document.taxAmount.label'));
     $this->add($taxAmount);
     $comment = new Textarea('comment');
     $comment->setAttribute('id', 'comment');
     $comment->setAttribute('title', $this->translator->translate('web.form.document.comment.title'));
     $comment->setAttribute('class', 'form-control');
     $comment->setAttribute('cols', 15);
     $comment->setAttribute('rows', 4);
     $comment->setAttribute('placeholder', $this->translator->translate('web.form.document.comment.placeholder'));
     $comment->setLabel($this->translator->translate('web.form.document.comment.label'));
     $this->add($comment);
     $amountTax = new Text('amountTax');
     $amountTax->setAttribute('id', 'amountTax');
     $amountTax->setAttribute('title', $this->translator->translate('web.form.document.amountTax.title'));
     $amountTax->setAttribute('class', 'form-control');
     $amountTax->setAttribute('readonly', 'readonly');
     $amountTax->setAttribute('placeholder', $this->translator->translate('web.form.document.amountTax.placeholder'));
     $amountTax->setLabel($this->translator->translate('web.form.document.amountTax.label'));
     $this->add($amountTax);
     return $this;
 }
Esempio n. 22
0
 public function __construct(ObjectManager $objectManager)
 {
     parent::__construct('register');
     $this->filter = new InputFilter();
     $primary = new Element\Hidden('primary');
     $this->add($primary);
     $callName = new Element\Text('callName');
     $callName->setAttribute('required', true);
     $callName->setAttribute('placeholder', 'Call Name');
     $this->add($callName);
     $callNameFilter = new Input('callName');
     $callNameFilter->setRequired(true);
     $callNameFilter->getFilterChain()->attach(new AppFilter\TitleCase());
     $callNameFilter->getFilterChain()->attach(new Filter\StringTrim());
     $callNameFilter->getFilterChain()->attach(new Filter\StripTags());
     $callNameFilter->getValidatorChain()->attach(new Validator\StringLength(array('max' => 15)));
     $callNameFilter->getValidatorChain()->attach(new LocaleValidator\Alpha(array('allowWhiteSpace' => true)));
     $this->filter->add($callNameFilter);
     $regName = new Element\Text('regName');
     $regName->setAttribute('placeholder', 'Registered Name');
     $this->add($regName);
     $regNameFilter = new Input('regName');
     $regNameFilter->setRequired(false);
     $regNameFilter->getFilterChain()->attach(new AppFilter\TitleCase());
     $regNameFilter->getFilterChain()->attach(new Filter\StringTrim());
     $regNameFilter->getFilterChain()->attach(new Filter\StripTags());
     $regNameFilter->getValidatorChain()->attach(new Validator\StringLength(array('max' => 50)));
     $regNameFilter->getValidatorChain()->attach(new Validator\Regex("/^[a-z][a-z\\'\\- ]*\$/i"));
     $this->filter->add($regNameFilter);
     $sex = new Element\Select('sex');
     $sex->setAttribute('required', true);
     $sex->setValueOptions(array(1 => 'Male', 2 => 'Female'));
     $sex->setEmptyOption('Select a Sex');
     $this->add($sex);
     $sexFilter = new Input('sex');
     $sexFilter->setRequired(true);
     $this->filter->add($sexFilter);
     $breed = new AppElement\ObjectLiveSearch('breed');
     $breed->setOption('object_manager', $objectManager);
     $breed->setOption('target_class', 'Application\\Entity\\Breed');
     $breed->setOption('find_method', array('name' => 'findBy', 'params' => array('criteria' => array(), 'orderBy' => array('name' => 'ASC'))));
     $breed->setEmptyOption('Select a Breed');
     $this->add($breed);
     $breedFilter = new Input('breed');
     $breedFilter->setRequired(true);
     $this->filter->add($breedFilter);
     $dateOfBirth = new Element\Date('dateOfBirth');
     $dateOfBirth->setAttribute('required', true);
     $dateOfBirth->setAttribute('data-placeholder', 'Date of Birth');
     // placeholder attr is invalid for date input
     $dateOfBirth->setAttribute('data-mask', '0000-00-00');
     $dateOfBirth->setAttribute('class', 'datepicker');
     $this->add($dateOfBirth);
     $dateOfBirthFilter = new Input('dateOfBirth');
     $dateOfBirthFilter->setRequired(true);
     $dateOfBirthFilter->getValidatorChain()->attach(new Validator\Date());
     $this->filter->add($dateOfBirthFilter);
     $height = new Element\Number('height');
     $height->setAttribute('required', true);
     $height->setAttribute('placeholder', 'Height (Inches)');
     $this->add($height);
     $heightFilter = new Input('height');
     $heightFilter->setRequired(true);
     $heightFilter->getValidatorChain()->attach(new Validator\Between(array('min' => 6, 'max' => 30)));
     $this->filter->add($heightFilter);
     $champion = new Element\Checkbox('champion');
     $champion->setLabel('Dog is a champion of record.');
     $this->add($champion);
     $championFilter = new Input('champion');
     $championFilter->setRequired(false);
     $this->filter->add($championFilter);
     $rescue = new Element\Checkbox('rescue');
     $rescue->setLabel('Dog is a rescue.');
     $this->add($rescue);
     $rescueFilter = new Input('rescue');
     $rescueFilter->setRequired(false);
     $this->filter->add($rescueFilter);
     $buttons = new Form('buttons');
     $buttons->setOption('twb-layout', 'inline');
     $buttons->setAttribute('class', 'form-group');
     $submit = new Element\Submit('submit');
     $submit->setAttribute('class', 'btn-primary pull-right');
     $submit->setOption('glyphicon', 'circle-arrow-up');
     $submit->setLabel('Register');
     $buttons->add($submit);
     $cancel = new Element\Submit('cancel');
     $cancel->setAttribute('formnovalidate', true);
     $cancel->setAttribute('class', 'btn-warning pull-right');
     $cancel->setOption('glyphicon', 'ban-circle');
     $cancel->setLabel('Cancel');
     $buttons->add($cancel);
     $this->add($buttons);
 }
Esempio n. 23
0
 public function testErrorShowTwice()
 {
     $element = new Element\Date('birth');
     $element->setFormat('Y-m-d');
     $element->setValue('2010-13-13');
     $validator = new \Zend\Validator\Date();
     $validator->isValid($element->getValue());
     $element->setMessages($validator->getMessages());
     $markup = $this->helper->__invoke($element);
     $this->assertEquals(2, count(explode("<ul><li>The input does not appear to be a valid date</li></ul>", $markup)));
 }
Esempio n. 24
0
 public function init()
 {
     $paymentType = new Radio('paymentType');
     $paymentType->setAttribute('id', 'paymentType');
     $paymentType->setAttribute('class', 'paymentType');
     $paymentType->setAttribute('title', $this->translator->translate('web.form.document.paymentType.title'));
     $paymentType->setAttribute('required', 'required');
     $paymentType->setLabel($this->translator->translate('web.form.document.paymentType.label'));
     $paymentType->setValueOptions(BankTransaction::$paymentTypes);
     $this->add($paymentType);
     $invoiceText = new Text('invoiceText');
     $invoiceText->setAttribute('id', 'invoiceText');
     $invoiceText->setAttribute('class', 'form-control')->setAttribute('placeholder', $this->translator->translate('transaction.form.invoiceText.placeholder'))->setLabel($this->translator->translate('transaction.form.invoiceText.label'));
     $this->add($invoiceText);
     $invoiceNumber = new Text('invoiceNumber');
     $invoiceNumber->setAttribute('id', 'invoiceNumber');
     $invoiceNumber->setAttribute('class', 'form-control')->setAttribute('readonly', 'readonly')->setAttribute('placeholder', $this->translator->translate('transaction.form.invoiceNumber.placeholder'))->setLabel($this->translator->translate('transaction.form.invoiceNumber.label'));
     $this->add($invoiceNumber);
     $invoiceId = new Text('invoiceId');
     $invoiceId->setAttribute('id', 'invoiceId');
     $this->add($invoiceId);
     $purchInvoiceText = new Text('purchInvoiceText');
     $purchInvoiceText->setAttribute('id', 'purchInvoiceText');
     $purchInvoiceText->setAttribute('class', 'form-control')->setAttribute('placeholder', $this->translator->translate('transaction.form.purchInvoiceText.placeholder'))->setLabel($this->translator->translate('transaction.form.purchInvoiceText.label'));
     $this->add($purchInvoiceText);
     $purchInvoiceNumber = new Text('purchInvoiceNumber');
     $purchInvoiceNumber->setAttribute('id', 'purchInvoiceNumber');
     $purchInvoiceNumber->setAttribute('class', 'form-control')->setAttribute('readonly', 'readonly')->setAttribute('placeholder', $this->translator->translate('transaction.form.purchInvoiceNumber.placeholder'))->setLabel($this->translator->translate('transaction.form.purchInvoiceNumber.label'));
     $this->add($purchInvoiceNumber);
     $purchInvoiceId = new Text('purchInvoiceId');
     $purchInvoiceId->setAttribute('id', 'purchInvoiceId');
     $this->add($purchInvoiceId);
     $paymentDate = new Date('paymentDate');
     $paymentDate->setAttributes(array('id' => 'paymentDate', 'type' => 'text', 'class' => 'input datepicker form-control', 'data-date-weekstart' => 1, 'data-date-format' => 'dd.mm.yyyy'));
     $paymentDate->setAttribute('title', $this->translator->translate('web.form.document.docDate.title'));
     $paymentDate->setAttribute('readonly', 'readonly');
     $paymentDate->setAttribute('placeholder', $this->translator->translate('web.form.document.docDate.placeholder'));
     $paymentDate->setLabel($this->translator->translate('web.form.document.docDate.label'));
     $this->add($paymentDate);
     $type = new Text('type');
     $type->setAttribute('id', 'type');
     $this->add($type);
     $name = new Text('name');
     $name->setAttribute('id', 'name');
     $name->setAttribute('class', 'form-control')->setAttribute('placeholder', $this->translator->translate('transaction.form.name.placeholder'))->setLabel($this->translator->translate('transaction.form.name.label'));
     $this->add($name);
     $referenceNumber = new Text('referenceNumber');
     $referenceNumber->setAttribute('id', 'referenceNumber');
     $referenceNumber->setAttribute('class', 'form-control')->setAttribute('placeholder', $this->translator->translate('transaction.form.referenceNumber.placeholder'))->setLabel($this->translator->translate('transaction.form.referenceNumber.label'));
     $this->add($referenceNumber);
     $sum = new Text('sum');
     $sum->setAttribute('id', 'sum');
     $sum->setAttribute('title', $this->translator->translate('transaction.form.amount.label'));
     $sum->setAttribute('class', 'form-control');
     $sum->setAttribute('required', 'required');
     $sum->setAttribute('placeholder', $this->translator->translate('transaction.form.amount.label'));
     $sum->setLabel($this->translator->translate('transaction.form.amount.label'));
     $this->add($sum);
     $description = new Text('description');
     $description->setAttribute('id', 'description');
     $description->setAttribute('class', 'form-control')->setAttribute('placeholder', $this->translator->translate('transaction.form.description.placeholder'))->setLabel($this->translator->translate('transaction.form.description.label'));
     $this->add($description);
     $payerIban = new Text('payerIban');
     $payerIban->setAttribute('id', 'payerIban');
     $payerIban->setAttribute('class', 'form-control')->setAttribute('placeholder', $this->translator->translate('transaction.form.payerIban.placeholder'))->setLabel($this->translator->translate('transaction.form.payerIban.label'));
     $this->add($payerIban);
     $archiveSign = new Text('archiveSign');
     $archiveSign->setAttribute('id', 'archiveSign');
     $archiveSign->setAttribute('class', 'form-control')->setAttribute('placeholder', $this->translator->translate('transaction.form.archiveSign.placeholder'))->setLabel($this->translator->translate('transaction.form.archiveSign.label'));
     $this->add($archiveSign);
     return $this;
 }