SET default_with_oids = false;
+--
+-- Name: categorie; Type: TABLE; Schema: public; Owner: -
+--
+
+CREATE TABLE categorie (
+ id integer NOT NULL,
+ id_categorie integer DEFAULT 0,
+ descrizione character varying(255) DEFAULT ''::character varying,
+ status character varying(1) DEFAULT ''::character varying
+);
+
+
--
-- Name: segnalazioni; Type: TABLE; Schema: public; Owner: -
--
);
+--
+-- Name: categorie_pkey; Type: CONSTRAINT; Schema: public; Owner: -
+--
+
+ALTER TABLE ONLY categorie
+ ADD CONSTRAINT categorie_pkey PRIMARY KEY (id);
+
+
--
-- Name: segnalazioni_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
gchar *filename;
gchar *content;
+ guint id_categorie;
+ gchar *sql;
+ GdaDataModel *dm;
+ GdaDataModelIter *iter;
+ GString *categorie;
+
Commons *commons = (Commons *)user_data;
if (!get_is_logged (commons))
zak_cgi_session_set_value (commons->zcgi_session, "latitudine", g_value_get_string (zak_cgi_main_get_stdin_field (commons->zcgi_main, "lat")));
zak_cgi_session_set_value (commons->zcgi_session, "longitudine", g_value_get_string (zak_cgi_main_get_stdin_field (commons->zcgi_main, "lng")));
+ id_categorie = 0;
+ categorie = g_string_new ("");
+
+ sql = g_strdup_printf ("SELECT c.*,"
+ " CASE WHEN COALESCE ((SELECT c1.id FROM categorie AS c1 WHERE c1.id_categorie = c.id), 0) != 0 THEN TRUE ELSE FALSE END AS finale"
+ " FROM categorie AS c"
+ " WHERE c.status <> 'E'"
+ " AND c.id_categorie = %d",
+ id_categorie);
+ dm = gdaex_query (commons->gdaex, sql);
+ g_free (sql);
+ if (dm != NULL)
+ {
+ g_string_append_printf (categorie, "<ul>\n");
+
+ iter = gda_data_model_create_iter (dm);
+ while (gda_data_model_iter_move_next (iter))
+ {
+ g_string_append_printf (categorie,
+ "<li>%s</ul>\n",
+ gdaex_data_model_iter_get_field_value_stringify_at (iter, "descrizione"));
+ }
+
+ g_string_append_printf (categorie, "</ul>\n");
+
+ g_object_unref (dm);
+ }
+
+ env = ctpl_environ_new ();
+ ctpl_environ_push_string (env, "categorie", categorie->str);
+
filename = g_build_filename (commons->ctpldir, "index_category.ctpl", NULL);
- content = get_ctpl_filled (filename, NULL);
+ content = get_ctpl_filled (filename, env);
g_free (filename);
+ g_string_free (categorie, TRUE);
+
env = ctpl_environ_new ();
ctpl_environ_push_string (env, "head", "");
ctpl_environ_push_string (env, "body_tag", "");
gchar *filename;
gchar *content;
+ guint newid;
+ gchar *sql;
+
Commons *commons = (Commons *)user_data;
if (!get_is_logged (commons))
if (zak_cgi_main_is_post (commons->zcgi_main))
{
- guint newid;
- gchar *sql;
-
newid = gdaex_get_new_id(commons->gdaex, "segnalazioni", "id", NULL);
sql = g_strdup_printf ("INSERT INTO segnalazioni"