Example #1
0
 /**
  * Storing Country filter, if applicable
  * @param $request
  * @return bool
  */
 public function storeCountryFilter($request)
 {
     $surveyFilterModel = new SurveyFilterModel();
     //If Country Filter is selected by the user
     if ($this->countryFilterApplied) {
         $this->countriesSelected = $request["country_ip_filter_countries"];
         $validCountries = SurveyRepository::getCountryIPFilterOptions();
         foreach ($this->countriesSelected as $countryISO) {
             if (!in_array($countryISO, array_keys($validCountries))) {
                 return ['country_filter_applied' => true, 'result' => false, 'validation_error' => 'ERR_COUNTRY_ISO_CODE_NOT_FOUND'];
             }
         }
         //Saving Country IP filter in the database
         if ($surveyFilterModel->storeCountryIPFilter($this)) {
             return ['country_filter_applied' => true, 'result' => true, 'validation_error' => ''];
         } else {
             return ['country_filter_applied' => true, 'result' => false, 'validation_error' => 'ERR_COUNTRY_FILTER_DATABASE_OPERATION'];
         }
     }
     //If Country Filter is not selected by the user, validate in database as well
     $result = $surveyFilterModel->removeCountryFilter($this);
     $validation_err = null;
     if (!$result) {
         $validation_err = "ERR_COUNTRY_FILTER_DATABASE_WHILE_REMOVING";
     }
     return ['country_filter_applied' => false, 'result' => $result, 'validation_error' => $validation_err];
 }
Example #2
0
                                                                >
                                                            </div>
                                                        </div>
                                                    </div>
                                                    <div class="col-xs-7">
                                                        <div class="form_field">
                                                            <div class="label">Select Countries (from which Respondents are acceptable)</div>
                                                            <div class="input_field">
                                                                <select multiple name="country_ip_filter_countries[]"
                                                                        id="country_ip_filter_countries"
                                                                        <?php 
echo !$countryFilterInfo["applied"] ? "disabled" : "";
?>
>
                                                                    <?php 
$countryList = SurveyRepository::getCountryIPFilterOptions();
foreach ($countryList as $countryISOCode => $country) {
    $selected = "";
    if (in_array($countryISOCode, $countryFilterInfo["countriesSelected"])) {
        $selected = "selected='selected'";
    }
    ?>
                                                                            <option <?php 
    echo "value='{$countryISOCode}' {$selected}";
    ?>
">
                                                                                <?php 
    echo $country;
    ?>
</option>
                                                                        <?php