diff --git a/controllers/d.poi.php b/controllers/d.poi.php index aa71f59..8c63a1b 100755 --- a/controllers/d.poi.php +++ b/controllers/d.poi.php @@ -56,7 +56,6 @@ switch ($controller->splitted_url[1]) { } } - $poi->parameters = json_encode($params, JSON_UNESCAPED_UNICODE); if (!$poi->checkPermalink($_POST['permalink'], 1)) { @@ -125,9 +124,44 @@ switch ($controller->splitted_url[1]) { $poi->lat = $_POST['lat']; $poi->lon = $_POST['lon']; $poi->ele = $_POST['ele']; - $poi->is_commentable = isset($_POST['is_commentable']) ? 't' : 'f'; $poi->author = $user->id; - // $poi->parameters = ... // à remplir si tu veux éditer les champs dynamiques + $poi->source = "kab"; + $poi->is_commentable = isset($_POST['is_commentable']) ? 't' : 'f'; + + $definition = $poi_types[$poi->poi_type][5]; + $params = []; + + foreach ($definition as $key => $label) { + + if (isset($_POST[$key])) { + $value = $_POST[$key]; + + if (str_starts_with($key, 'b_')) { + // 3 états : 1 = oui, 0 = non, -1 = non renseigné + $params[$key] = ($value === "1" ? 1 : + ($value === "0" ? 0 : -1)); + } + elseif (str_starts_with($key, 'n_')) { + $params[$key] = is_numeric($value) ? (0 + $value) : null; + } + elseif (str_starts_with($key, 't_') || str_starts_with($key, 'l_')) { + $params[$key] = trim($value); + } + else { + $params[$key] = $value; + } + + } else { + // Champ absent → booléen = -1 (non renseigné) + if (str_starts_with($key, 'b_')) { + $params[$key] = -1; + } else { + $params[$key] = null; + } + } + } + + $poi->parameters = json_encode($params, JSON_UNESCAPED_UNICODE); $poi->update(); header('Location: '.$config['rel_root_folder']."poi/".$poi->permalink); } else { diff --git a/includes/poi_types.struct.php b/includes/poi_types.struct.php index 70a1f29..4dcc279 100644 --- a/includes/poi_types.struct.php +++ b/includes/poi_types.struct.php @@ -39,8 +39,8 @@ $poi_types = array( 't_access' => "🧭 Description de l'accès, des transports en commun, et d'éventuels passages délicats", 't_description' => "📝 Description sur le refuge et remarques", 'b_usable' => "🚫 Refuge condamné, détruit ou fermé ?", - 'n_bed' => "Places en période gardée ☀️ :", - 'n_bed_winter' => "Places en période non gardée ❄️ :", + 'n_bed' => "☀️ Places en période gardée :", + 'n_bed_winter' => "❄️ Places en période non gardée :", 'n_mattress' => "🛌 Matelas en période non gardée :", 'b_cover' => "🧣 Couvertures disponibles ?", 'b_water' => "💧 Possibilité de se ravitailler en eau ?", diff --git a/models/d.poi.php b/models/d.poi.php index 7697682..a8e57b5 100755 --- a/models/d.poi.php +++ b/models/d.poi.php @@ -250,9 +250,9 @@ class Poi pg_execute($con, "poi_insert_specs_update", array( $this->version_id, $this->lon, $this->lat, $this->ele, $this->source, $this->remote_source_id )); // 4) Update is_commentable - $query = "UPDATE contents SET is_commentable = $1 WHERE id = $2"; + $query = "UPDATE contents SET is_commentable = $1, poi_type = $2 WHERE id = $3"; pg_prepare($con, "poi_update_commentable", $query); - pg_execute($con, "poi_update_commentable", array( $this->is_commentable ? 't' : 'f', $this->content_id)); + pg_execute($con, "poi_update_commentable", array( $this->is_commentable ? 't' : 'f', $this->poi_type, $this->content_id)); // 5) Add contributor $query = "INSERT INTO content_contributors (content, contributor) diff --git a/views/css/d.poi.css b/views/css/d.poi.css index 4bdc742..d9c78a8 100755 --- a/views/css/d.poi.css +++ b/views/css/d.poi.css @@ -548,7 +548,6 @@ form.form input[type="checkbox"]:checked + span:before { } .bool-row.labels { - font-weight: 600; font-size: 16px; } diff --git a/views/d.poi.edit.html b/views/d.poi.edit.html index 7799d78..539182f 100755 --- a/views/d.poi.edit.html +++ b/views/d.poi.edit.html @@ -36,95 +36,150 @@