public static function listOptionWithOptionChecked($arrayOption, $chaine, $name_id, $optionCheckbox, $father = "") { $i = 1; foreach ($arrayOption as $key => $value) { //var_dump($value); if (is_array($value)) { $chaine = $chaine . '<li><strong class="btn-drop bold" >' . $key . '</strong></li>'; $otherfather = $father . "." . $key; $chaine = CityOpenData::listOptionWithOptionChecked($value, $chaine, $name_id, $optionCheckbox, $otherfather); } else { $trouver = false; foreach ($optionCheckbox as $optionKey => $optionValue) { if ($optionValue == $father . '.' . $key) { $list = '<li> <a class="btn-drop optionBtn" data-name="' . $father . '.' . $key . '"> <input type="checkbox" id="' . $name_id . $father . '.' . $key . '" name="' . $name_id . 'optionCheckbox" value="' . $father . '.' . $key . '" checked/> <label for="' . $father . '.' . $key . '" >' . $key . '</label> </a> </li>'; $trouver = true; break; } } if ($trouver == false) { $list = '<li> <a class="btn-drop optionBtn" data-name="' . $father . '.' . $key . '"> <input type="checkbox" id="' . $name_id . $father . '.' . $key . '" name="' . $name_id . 'optionCheckbox" value="' . $father . '.' . $key . '"/> <label for="' . $father . '.' . $key . '" >' . $key . '</label> </a> </li>'; } $chaine = $chaine . $list; $i++; } } return $chaine; }
public static function listOption2($arrayOption, $chaine, $first, $name_id, $father = "") { $i = 1; foreach ($arrayOption as $key => $value) { //if(is_array($value)) if (empty($value["value"]) && empty($value["label"])) { //var_dump($value); $otherfather = $father . "." . $key; if ($first == true && $i == 1) { $chaine = CityOpenData::listOption2($value, $chaine, true, $name_id, $otherfather); } else { $chaine = CityOpenData::listOption2($value, $chaine, false, $name_id, $otherfather); } } else { if ($first == true && $i == 1) { $list = '<option value="' . $father . '.' . $key . '" checked>' . $value["label"] . '</option>'; } else { $list = '<option value="' . $name_id . $father . '.' . $key . '">' . $value["label"] . '</option>'; } $chaine = $chaine . $list; // var_dump($chaine); $i++; } } return $chaine; }
<span id="label-option"> Total </span><span class="caret"></span> </a> <ul role="menu" class="dropdown-menu pull-right" id="filterGraph"> <?php $where = array("insee" => $_GET['insee'], $typeData => array('$exists' => 1)); $fields = array($typeData); $option = City::getWhereData($where, $fields); $chaine = ""; foreach ($option as $key => $value) { foreach ($value as $k => $v) { if ($k == $typeData) { if (isset($optionData)) { $chaine = CityOpenData::listOptionWithOptionChecked($v, $chaine, $name_id, $optionData); } else { $chaine = CityOpenData::listOption($v, $chaine, true, $name_id); } } } } echo $chaine; ?> </ul> </div> </li> </ul> </div> <div class="panel-heading border-light divline"> <ul class="panel-heading-tabs border-light ulline"> <li>
</select> </div> <div id="divTypeOption" class="col-sm-4 col-xs-12"> <label for="typeOption" />Option : </label> <select id="typeOption" class="col-sm-12 col-xs-12" multiple="multiple"> <?php $typeData = "population"; $where = array("insee" => $_GET['insee'], $typeData => array('$exists' => 1)); $fields = array($typeData); $option = City::getWhereData($where, $fields); $chaine = ""; foreach ($option as $key => $value) { foreach ($value as $k => $v) { if ($k == $typeData) { $chaine = CityOpenData::listOption2($v, $chaine, true, ""); } } } echo $chaine; ?> </select> </div> <div class="col-sm-4 col-xs-12"> <label for="typeGraph"/>Graphe :</label> <select id="typeGraph" class="col-sm-12 col-xs-12"> <option value="multibart">Multi-Bar</option> <option value="piechart">PieChart</option> </select> </div>