From 8c7191a3b34d714700483af758ea667c8a027218 Mon Sep 17 00:00:00 2001 From: Andrea Zagli Date: Tue, 4 Jun 2013 11:27:26 +0200 Subject: [PATCH] Aggiunta l'immagine alla struttura (closes #672). --- data/organigramma/gui/organigramma.gui | 24 ++++++++ docs/DBChangelog | 5 ++ docs/organigramma.sql | 64 ++++++++++---------- src/struttura.c | 82 ++++++++++++++++++++++++++ 4 files changed, 145 insertions(+), 30 deletions(-) diff --git a/data/organigramma/gui/organigramma.gui b/data/organigramma/gui/organigramma.gui index 8890f89..2f162ff 100644 --- a/data/organigramma/gui/organigramma.gui +++ b/data/organigramma/gui/organigramma.gui @@ -5784,6 +5784,30 @@ False + + + True + False + 5 + + + + + + 3 + + + + + True + False + Immagine + + + 3 + False + + 2 diff --git a/docs/DBChangelog b/docs/DBChangelog index 4bc88a9..8c2f7fc 100644 --- a/docs/DBChangelog +++ b/docs/DBChangelog @@ -74,3 +74,8 @@ CREATE TABLE ufficio_allegati status character varying(1) DEFAULT ''::character varying, CONSTRAINT ufficio_allegati_pkey PRIMARY KEY (id) ); + +ALTER TABLE strutture ADD COLUMN immagine_percorso character varying(255) DEFAULT ''; +ALTER TABLE strutture ADD COLUMN immagine_contenuto integer DEFAULT 0; +ALTER TABLE strutture ADD COLUMN immagine_file_data timestamp without time zone; +ALTER TABLE strutture ADD COLUMN immagine_file_dimensione bigint DEFAULT 0; diff --git a/docs/organigramma.sql b/docs/organigramma.sql index 5f69c90..f0ba046 100644 --- a/docs/organigramma.sql +++ b/docs/organigramma.sql @@ -4,7 +4,7 @@ -- Dumped from database version 8.4.17 -- Dumped by pg_dump version 9.2.2 --- Started on 2013-06-04 10:53:26 +-- Started on 2013-06-04 11:22:03 SET statement_timeout = 0; SET client_encoding = 'UTF8'; @@ -263,7 +263,11 @@ CREATE TABLE strutture ( descrizione text DEFAULT ''::text, prefisso_centralino character varying(20) DEFAULT ''::character varying, interno_centralino character varying(10) DEFAULT ''::character varying, - status character varying(1) DEFAULT ''::character varying + status character varying(1) DEFAULT ''::character varying, + immagine_percorso character varying(255) DEFAULT ''::character varying, + immagine_contenuto integer DEFAULT 0, + immagine_file_data timestamp without time zone, + immagine_file_dimensione bigint DEFAULT 0 ); @@ -458,7 +462,7 @@ CREATE TABLE ufficio_stanze ( -- --- TOC entry 2011 (class 2606 OID 59289) +-- TOC entry 2014 (class 2606 OID 59289) -- Name: nodi_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- @@ -467,7 +471,7 @@ ALTER TABLE ONLY nodi -- --- TOC entry 2051 (class 2606 OID 61360) +-- TOC entry 2054 (class 2606 OID 61360) -- Name: persona_incarichi_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- @@ -476,7 +480,7 @@ ALTER TABLE ONLY persona_incarichi -- --- TOC entry 2041 (class 2606 OID 61305) +-- TOC entry 2044 (class 2606 OID 61305) -- Name: persona_nodi_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- @@ -485,7 +489,7 @@ ALTER TABLE ONLY persona_nodi -- --- TOC entry 2043 (class 2606 OID 61321) +-- TOC entry 2046 (class 2606 OID 61321) -- Name: persona_nodo_recapiti_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- @@ -494,7 +498,7 @@ ALTER TABLE ONLY persona_nodo_recapiti -- --- TOC entry 2037 (class 2606 OID 61279) +-- TOC entry 2040 (class 2606 OID 61279) -- Name: persona_recapiti_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- @@ -503,7 +507,7 @@ ALTER TABLE ONLY persona_recapiti -- --- TOC entry 2035 (class 2606 OID 61252) +-- TOC entry 2038 (class 2606 OID 61252) -- Name: persona_uffici_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- @@ -512,7 +516,7 @@ ALTER TABLE ONLY persona_uffici -- --- TOC entry 2039 (class 2606 OID 61294) +-- TOC entry 2042 (class 2606 OID 61294) -- Name: persona_ufficio_recapiti_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- @@ -521,7 +525,7 @@ ALTER TABLE ONLY persona_ufficio_recapiti -- --- TOC entry 2031 (class 2606 OID 61235) +-- TOC entry 2034 (class 2606 OID 61235) -- Name: persone_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- @@ -530,7 +534,7 @@ ALTER TABLE ONLY persone -- --- TOC entry 2045 (class 2606 OID 61328) +-- TOC entry 2048 (class 2606 OID 61328) -- Name: posizioni_economiche_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- @@ -539,7 +543,7 @@ ALTER TABLE ONLY posizioni_economiche -- --- TOC entry 2049 (class 2606 OID 61342) +-- TOC entry 2052 (class 2606 OID 61342) -- Name: profili_professionali_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- @@ -548,7 +552,7 @@ ALTER TABLE ONLY profili_professionali -- --- TOC entry 2055 (class 2606 OID 618188) +-- TOC entry 2058 (class 2606 OID 618188) -- Name: ruoli_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- @@ -557,7 +561,7 @@ ALTER TABLE ONLY ruoli -- --- TOC entry 2061 (class 2606 OID 626437) +-- TOC entry 2064 (class 2606 OID 626437) -- Name: struttura_allegati_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- @@ -566,7 +570,7 @@ ALTER TABLE ONLY struttura_allegati -- --- TOC entry 2059 (class 2606 OID 626378) +-- TOC entry 2062 (class 2606 OID 626378) -- Name: struttura_collegamenti_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- @@ -575,7 +579,7 @@ ALTER TABLE ONLY struttura_collegamenti -- --- TOC entry 2021 (class 2606 OID 59356) +-- TOC entry 2024 (class 2606 OID 59356) -- Name: struttura_indirizzi_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- @@ -584,7 +588,7 @@ ALTER TABLE ONLY struttura_indirizzi -- --- TOC entry 2019 (class 2606 OID 59339) +-- TOC entry 2022 (class 2606 OID 59339) -- Name: strutture_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- @@ -593,7 +597,7 @@ ALTER TABLE ONLY strutture -- --- TOC entry 2013 (class 2606 OID 59296) +-- TOC entry 2016 (class 2606 OID 59296) -- Name: tipi_nodo_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- @@ -602,7 +606,7 @@ ALTER TABLE ONLY tipi_nodo -- --- TOC entry 2047 (class 2606 OID 61335) +-- TOC entry 2050 (class 2606 OID 61335) -- Name: tipi_prestazione_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- @@ -611,7 +615,7 @@ ALTER TABLE ONLY tipi_prestazione -- --- TOC entry 2033 (class 2606 OID 61242) +-- TOC entry 2036 (class 2606 OID 61242) -- Name: tipi_rapporto_lavoro_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- @@ -620,7 +624,7 @@ ALTER TABLE ONLY tipi_rapporto_lavoro -- --- TOC entry 2015 (class 2606 OID 59303) +-- TOC entry 2018 (class 2606 OID 59303) -- Name: tipi_recapito_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- @@ -629,7 +633,7 @@ ALTER TABLE ONLY tipi_recapito -- --- TOC entry 2029 (class 2606 OID 61226) +-- TOC entry 2032 (class 2606 OID 61226) -- Name: titoli_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- @@ -638,7 +642,7 @@ ALTER TABLE ONLY titoli -- --- TOC entry 2017 (class 2606 OID 59321) +-- TOC entry 2020 (class 2606 OID 59321) -- Name: uffici_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- @@ -647,7 +651,7 @@ ALTER TABLE ONLY uffici -- --- TOC entry 2063 (class 2606 OID 626452) +-- TOC entry 2066 (class 2606 OID 626452) -- Name: ufficio_allegati_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- @@ -656,7 +660,7 @@ ALTER TABLE ONLY ufficio_allegati -- --- TOC entry 2057 (class 2606 OID 626366) +-- TOC entry 2060 (class 2606 OID 626366) -- Name: ufficio_collegamenti_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- @@ -665,7 +669,7 @@ ALTER TABLE ONLY ufficio_collegamenti -- --- TOC entry 2023 (class 2606 OID 59366) +-- TOC entry 2026 (class 2606 OID 59366) -- Name: ufficio_nodi_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- @@ -674,7 +678,7 @@ ALTER TABLE ONLY ufficio_nodi -- --- TOC entry 2025 (class 2606 OID 59408) +-- TOC entry 2028 (class 2606 OID 59408) -- Name: ufficio_orari_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- @@ -683,7 +687,7 @@ ALTER TABLE ONLY ufficio_orari -- --- TOC entry 2027 (class 2606 OID 59419) +-- TOC entry 2030 (class 2606 OID 59419) -- Name: ufficio_recapiti_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- @@ -692,7 +696,7 @@ ALTER TABLE ONLY ufficio_recapiti -- --- TOC entry 2053 (class 2606 OID 61430) +-- TOC entry 2056 (class 2606 OID 61430) -- Name: ufficio_stanze_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- @@ -700,7 +704,7 @@ ALTER TABLE ONLY ufficio_stanze ADD CONSTRAINT ufficio_stanze_pkey PRIMARY KEY (id); --- Completed on 2013-06-04 10:53:26 +-- Completed on 2013-06-04 11:22:03 -- -- PostgreSQL database dump complete diff --git a/src/struttura.c b/src/struttura.c index e2a7cf4..a602600 100644 --- a/src/struttura.c +++ b/src/struttura.c @@ -21,6 +21,8 @@ #include #endif +#include + #include #include #include @@ -155,6 +157,8 @@ struct _OrganigrammaStrutturaPrivate GtkTreeSelection *sel_collegamenti; GtkTreeSelection *sel_allegati; + SolipaAllegato *sallegato; + gint id; }; @@ -238,6 +242,16 @@ OrganigrammaStruttura "lstore_struttura_allegati", NULL); + priv->sallegato = solipa_allegato_new (commons->solipa); + if (priv->sallegato != NULL) + { + solipa_allegato_add_to_gtkform (priv->sallegato, priv->form, + "immagine_percorso", "immagine_file_data", "immagine_file_dimensione"); + solipa_allegato_con_salva_in_db (priv->sallegato, FALSE); + gtk_container_add (GTK_CONTAINER (gtk_builder_get_object (priv->commons->gtkbuilder, "alignment3")), + solipa_allegato_get_widget (priv->sallegato)); + } + g_signal_connect (priv->w, "delete-event", G_CALLBACK (organigramma_struttura_on_w_organigramma_struttura_delete_event), (gpointer)a); @@ -379,6 +393,74 @@ organigramma_struttura_salva (OrganigrammaStruttura *struttura, gboolean chiudi) gtk_form_set_sensitive_by_name (priv->form, TRUE, "hbox6", "hbox23", "hbox31", NULL); } + /* salvo l'atto_allegato nel db */ + /* devo utilizzare le funzioni native di postgres + * perché quelle di libgda non sembrano funzionare sotto windows */ + Oid oid; + const gchar *percorso; + + percorso = solipa_allegato_get_percorso (priv->sallegato); + + if (PQexec (priv->commons->pgcon, "BEGIN") == NULL) + { + if (priv->id == 0) + { + gtk_label_set_text (GTK_LABEL (priv->objects[LBL_ID]), ""); + } + + solipa_message_dialog (priv->w, + GTK_MESSAGE_WARNING, + GTK_BUTTONS_OK, + "Errore durante il salvataggio: allegato non importato nel database (impossibile aprire la transazione)."); + return; + } + + oid = lo_import (priv->commons->pgcon, percorso); + + if (oid > 0) + { + sql = g_strdup_printf ("UPDATE strutture" + " SET immagine_contenuto = %d," + " immagine_percorso = '%s'" + " WHERE id = %d", + oid, + gdaex_strescape (g_path_get_basename (percorso), NULL), + priv->id); + if (gdaex_execute (priv->commons->gdaex, sql) < 1) + { + g_free (sql); + + if (priv->id == 0) + { + gtk_label_set_text (GTK_LABEL (priv->objects[LBL_ID]), ""); + } + + solipa_message_dialog (priv->w, + GTK_MESSAGE_WARNING, + GTK_BUTTONS_OK, + "Errore durante il salvataggio."); + return; + } + g_free (sql); + + organigramma_struttura_carica (struttura); + } + else + { + if (priv->id == 0) + { + gtk_label_set_text (GTK_LABEL (priv->objects[LBL_ID]), ""); + } + + solipa_message_dialog (priv->w, + GTK_MESSAGE_WARNING, + GTK_BUTTONS_OK, + "Errore durante il salvataggio: allegato non importato nel database."); + return; + } + + PQexec (priv->commons->pgcon, "COMMIT"); + solipa_message_dialog (priv->w, GTK_MESSAGE_INFO, GTK_BUTTONS_OK, -- 2.49.0