Created
October 1, 2015 05:51
-
-
Save manchumahara/e9a6a38ead311e7544bc to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class JFormFieldCheckboxFacility extends JFormField | |
| { | |
| /** | |
| * The form field type. | |
| * | |
| * @var string | |
| * @since 1.6 | |
| */ | |
| public $type = 'CheckboxFacility'; | |
| /** | |
| * Method to get the field input markup. | |
| * | |
| * @return string The field input markup. | |
| * @since 1.6 | |
| */ | |
| protected function getInput() | |
| { | |
| $listSelectedFacilities = $this->form->getValue('facility_id'); | |
| //$listSelectedFacilities = array_flip($listSelectedFacilities); | |
| /*$facility_checked = array(); | |
| foreach($listSelectedFacilities as $facilityobj){ | |
| $facility_checked[$facilityobj->facility_id] = ''; | |
| } | |
| */ | |
| /* echo '<pre>'; | |
| print_r($listSelectedFacilities); | |
| echo '</pre>';*/ | |
| $css = ".cbxpolicycat{ width: 25% !important; float: left !important; display: inline-block !important;}"; | |
| $doc = JFactory::getDocument(); | |
| $doc->addStyleDeclaration($css); | |
| $html = ''; | |
| $scopeId = ($this->form->getName() == 'com_solidres.reservationasset') ? 0 : 1; | |
| $model = JModelLegacy::getInstance('Facilities', 'SolidresModel', array('ignore_request' => true)); | |
| $model->setState('filter.scope_id', $scopeId); | |
| $model->setState('filter.state', 1); | |
| $model->setState('ordering','r.fcatid'); | |
| $list = $model->getItems(); | |
| /*echo '<pre>'; | |
| print_r($list); | |
| echo '</pre>';*/ | |
| if (!empty($list)) | |
| { | |
| $html_arr = array(); | |
| $cat_arr = array(); | |
| foreach ($list as $obj) | |
| { | |
| if($obj->fcatid == NULL){ | |
| $obj->fcatid = 0; | |
| $obj->fcatname = JText::_('SR_UNCAT'); | |
| } | |
| $cat_arr[$obj->fcatid] = $obj->fcatname; | |
| $html_arr[$obj->fcatid][] = ' | |
| <p class="facilities-wrapper-line"><label style="display: inline-block;" class="checkbox"> | |
| <input type="checkbox" | |
| value="'.$obj->id.'" | |
| id="checkbox_facility_id_'.$obj->id.'" | |
| class="checkbox_facility_class" | |
| name="jform[facility_id][]" '.(in_array($obj->id, $listSelectedFacilities) ? 'checked="checked"' : '').'/> | |
| '.$obj->title.' | |
| </label> </p>'; | |
| } | |
| /* | |
| | '.JText::_('SR_FACILITY_COMMERCIAL').' <input type="checkbox" | |
| value="'.$obj->id.'" | |
| id="checkbox_facility_id_commercial'.$obj->id.'" | |
| class="checkbox_facility_class" | |
| name="jform[facility_id][commercial][]" '.((isset($facility_checked[$obj->id]) && $facility_checked[$obj->id] == 1 ) ? 'checked="checked"' : '').' /> | |
| */ | |
| /*echo '<pre>'; | |
| print_r($html_arr); | |
| echo '</pre>';*/ | |
| foreach($cat_arr as $catid => $catname){ | |
| $html .= '<div class="cbxpolicycat">'; | |
| $html .= '<h3>'.$catname.'</h3>'; | |
| $html .= implode("",$html_arr[$catid]); | |
| $html .= '</div>'; | |
| //var_dump($html_arr[$catid]); | |
| } | |
| } | |
| else | |
| { | |
| $html = JText::_('SR_FACILITY_NOT_AVAILABLE'); | |
| } | |
| return $html; | |
| } | |
| } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment