From c29e93cdcbef3035f3d920df0edcc5f66f08ccd7 Mon Sep 17 00:00:00 2001 From: Andrea Zagli Date: Tue, 4 Jun 2013 11:33:29 +0200 Subject: [PATCH] Aggiunta l'immagine all'ufficio (closes #648). --- data/organigramma/gui/organigramma.gui | 24 ++++++++ docs/DBChangelog | 5 ++ docs/organigramma.sql | 64 ++++++++++---------- src/ufficio.c | 82 ++++++++++++++++++++++++++ 4 files changed, 145 insertions(+), 30 deletions(-) diff --git a/data/organigramma/gui/organigramma.gui b/data/organigramma/gui/organigramma.gui index 2f162ff..9711975 100644 --- a/data/organigramma/gui/organigramma.gui +++ b/data/organigramma/gui/organigramma.gui @@ -9722,6 +9722,30 @@ False + + + True + False + 5 + + + + + + 5 + + + + + True + False + Immagine + + + 5 + False + + 2 diff --git a/docs/DBChangelog b/docs/DBChangelog index 8c2f7fc..af6291e 100644 --- a/docs/DBChangelog +++ b/docs/DBChangelog @@ -79,3 +79,8 @@ ALTER TABLE strutture ADD COLUMN immagine_percorso character varying(255) DEFAUL 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; + +ALTER TABLE uffici ADD COLUMN immagine_percorso character varying(255) DEFAULT ''; +ALTER TABLE uffici ADD COLUMN immagine_contenuto integer DEFAULT 0; +ALTER TABLE uffici ADD COLUMN immagine_file_data timestamp without time zone; +ALTER TABLE uffici ADD COLUMN immagine_file_dimensione bigint DEFAULT 0; diff --git a/docs/organigramma.sql b/docs/organigramma.sql index f0ba046..e82bdec 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 11:22:03 +-- Started on 2013-06-04 11:28:25 SET statement_timeout = 0; SET client_encoding = 'UTF8'; @@ -349,7 +349,11 @@ CREATE TABLE uffici ( nome character varying(100) DEFAULT ''::character varying, descrizione text DEFAULT ''::text, status character varying(1) DEFAULT ''::character varying, - id_uffici integer DEFAULT 0 + id_uffici integer DEFAULT 0, + 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 ); @@ -462,7 +466,7 @@ CREATE TABLE ufficio_stanze ( -- --- TOC entry 2014 (class 2606 OID 59289) +-- TOC entry 2017 (class 2606 OID 59289) -- Name: nodi_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- @@ -471,7 +475,7 @@ ALTER TABLE ONLY nodi -- --- TOC entry 2054 (class 2606 OID 61360) +-- TOC entry 2057 (class 2606 OID 61360) -- Name: persona_incarichi_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- @@ -480,7 +484,7 @@ ALTER TABLE ONLY persona_incarichi -- --- TOC entry 2044 (class 2606 OID 61305) +-- TOC entry 2047 (class 2606 OID 61305) -- Name: persona_nodi_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- @@ -489,7 +493,7 @@ ALTER TABLE ONLY persona_nodi -- --- TOC entry 2046 (class 2606 OID 61321) +-- TOC entry 2049 (class 2606 OID 61321) -- Name: persona_nodo_recapiti_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- @@ -498,7 +502,7 @@ ALTER TABLE ONLY persona_nodo_recapiti -- --- TOC entry 2040 (class 2606 OID 61279) +-- TOC entry 2043 (class 2606 OID 61279) -- Name: persona_recapiti_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- @@ -507,7 +511,7 @@ ALTER TABLE ONLY persona_recapiti -- --- TOC entry 2038 (class 2606 OID 61252) +-- TOC entry 2041 (class 2606 OID 61252) -- Name: persona_uffici_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- @@ -516,7 +520,7 @@ ALTER TABLE ONLY persona_uffici -- --- TOC entry 2042 (class 2606 OID 61294) +-- TOC entry 2045 (class 2606 OID 61294) -- Name: persona_ufficio_recapiti_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- @@ -525,7 +529,7 @@ ALTER TABLE ONLY persona_ufficio_recapiti -- --- TOC entry 2034 (class 2606 OID 61235) +-- TOC entry 2037 (class 2606 OID 61235) -- Name: persone_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- @@ -534,7 +538,7 @@ ALTER TABLE ONLY persone -- --- TOC entry 2048 (class 2606 OID 61328) +-- TOC entry 2051 (class 2606 OID 61328) -- Name: posizioni_economiche_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- @@ -543,7 +547,7 @@ ALTER TABLE ONLY posizioni_economiche -- --- TOC entry 2052 (class 2606 OID 61342) +-- TOC entry 2055 (class 2606 OID 61342) -- Name: profili_professionali_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- @@ -552,7 +556,7 @@ ALTER TABLE ONLY profili_professionali -- --- TOC entry 2058 (class 2606 OID 618188) +-- TOC entry 2061 (class 2606 OID 618188) -- Name: ruoli_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- @@ -561,7 +565,7 @@ ALTER TABLE ONLY ruoli -- --- TOC entry 2064 (class 2606 OID 626437) +-- TOC entry 2067 (class 2606 OID 626437) -- Name: struttura_allegati_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- @@ -570,7 +574,7 @@ ALTER TABLE ONLY struttura_allegati -- --- TOC entry 2062 (class 2606 OID 626378) +-- TOC entry 2065 (class 2606 OID 626378) -- Name: struttura_collegamenti_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- @@ -579,7 +583,7 @@ ALTER TABLE ONLY struttura_collegamenti -- --- TOC entry 2024 (class 2606 OID 59356) +-- TOC entry 2027 (class 2606 OID 59356) -- Name: struttura_indirizzi_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- @@ -588,7 +592,7 @@ ALTER TABLE ONLY struttura_indirizzi -- --- TOC entry 2022 (class 2606 OID 59339) +-- TOC entry 2025 (class 2606 OID 59339) -- Name: strutture_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- @@ -597,7 +601,7 @@ ALTER TABLE ONLY strutture -- --- TOC entry 2016 (class 2606 OID 59296) +-- TOC entry 2019 (class 2606 OID 59296) -- Name: tipi_nodo_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- @@ -606,7 +610,7 @@ ALTER TABLE ONLY tipi_nodo -- --- TOC entry 2050 (class 2606 OID 61335) +-- TOC entry 2053 (class 2606 OID 61335) -- Name: tipi_prestazione_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- @@ -615,7 +619,7 @@ ALTER TABLE ONLY tipi_prestazione -- --- TOC entry 2036 (class 2606 OID 61242) +-- TOC entry 2039 (class 2606 OID 61242) -- Name: tipi_rapporto_lavoro_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- @@ -624,7 +628,7 @@ ALTER TABLE ONLY tipi_rapporto_lavoro -- --- TOC entry 2018 (class 2606 OID 59303) +-- TOC entry 2021 (class 2606 OID 59303) -- Name: tipi_recapito_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- @@ -633,7 +637,7 @@ ALTER TABLE ONLY tipi_recapito -- --- TOC entry 2032 (class 2606 OID 61226) +-- TOC entry 2035 (class 2606 OID 61226) -- Name: titoli_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- @@ -642,7 +646,7 @@ ALTER TABLE ONLY titoli -- --- TOC entry 2020 (class 2606 OID 59321) +-- TOC entry 2023 (class 2606 OID 59321) -- Name: uffici_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- @@ -651,7 +655,7 @@ ALTER TABLE ONLY uffici -- --- TOC entry 2066 (class 2606 OID 626452) +-- TOC entry 2069 (class 2606 OID 626452) -- Name: ufficio_allegati_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- @@ -660,7 +664,7 @@ ALTER TABLE ONLY ufficio_allegati -- --- TOC entry 2060 (class 2606 OID 626366) +-- TOC entry 2063 (class 2606 OID 626366) -- Name: ufficio_collegamenti_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- @@ -669,7 +673,7 @@ ALTER TABLE ONLY ufficio_collegamenti -- --- TOC entry 2026 (class 2606 OID 59366) +-- TOC entry 2029 (class 2606 OID 59366) -- Name: ufficio_nodi_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- @@ -678,7 +682,7 @@ ALTER TABLE ONLY ufficio_nodi -- --- TOC entry 2028 (class 2606 OID 59408) +-- TOC entry 2031 (class 2606 OID 59408) -- Name: ufficio_orari_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- @@ -687,7 +691,7 @@ ALTER TABLE ONLY ufficio_orari -- --- TOC entry 2030 (class 2606 OID 59419) +-- TOC entry 2033 (class 2606 OID 59419) -- Name: ufficio_recapiti_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- @@ -696,7 +700,7 @@ ALTER TABLE ONLY ufficio_recapiti -- --- TOC entry 2056 (class 2606 OID 61430) +-- TOC entry 2059 (class 2606 OID 61430) -- Name: ufficio_stanze_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- @@ -704,7 +708,7 @@ ALTER TABLE ONLY ufficio_stanze ADD CONSTRAINT ufficio_stanze_pkey PRIMARY KEY (id); --- Completed on 2013-06-04 11:22:03 +-- Completed on 2013-06-04 11:28:25 -- -- PostgreSQL database dump complete diff --git a/src/ufficio.c b/src/ufficio.c index 0e93c6a..846da7d 100644 --- a/src/ufficio.c +++ b/src/ufficio.c @@ -21,6 +21,8 @@ #include #endif +#include + #include #include #include @@ -263,6 +265,8 @@ struct _OrganigrammaUfficioPrivate GtkTreeSelection *sel_collegamenti; GtkTreeSelection *sel_allegati; + SolipaAllegato *sallegato; + gint id; }; @@ -355,6 +359,16 @@ OrganigrammaUfficio "lstore_ufficio_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, "alignment4")), + solipa_allegato_get_widget (priv->sallegato)); + } + priv->sel_nodi = gtk_tree_view_get_selection (GTK_TREE_VIEW (gtk_builder_get_object (priv->commons->gtkbuilder, "treeview7"))); priv->sel_stanze = gtk_tree_view_get_selection (GTK_TREE_VIEW (gtk_builder_get_object (priv->commons->gtkbuilder, "treeview23"))); priv->sel_recapiti = gtk_tree_view_get_selection (GTK_TREE_VIEW (gtk_builder_get_object (priv->commons->gtkbuilder, "treeview6"))); @@ -565,6 +579,74 @@ organigramma_ufficio_salva (OrganigrammaUfficio *ufficio, gboolean chiudi) gtk_form_set_sensitive_by_name (priv->form, TRUE, "hbox2", "hbox19", "hbox4", "hbox9", "hbox21", "hbox24", 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 uffici" + " 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_ufficio_carica (ufficio); + } + 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