From f642a13b07d3a4eb6c3ea50ad1d328257b6b90cd Mon Sep 17 00:00:00 2001 From: Andrea Zagli Date: Thu, 14 Oct 2010 17:17:33 +0200 Subject: [PATCH] Gestione incarichi delle persone. --- data/organigramma/form/Makefile.am | 1 + data/organigramma/form/persona_incarico.form | 81 +++++ data/organigramma/gui/organigramma.gui | 4 +- docs/organigramma.sql | 206 ++++++----- src/Makefile.am | 2 + src/persona.c | 221 +++++++++++- src/personaincarico.c | 349 +++++++++++++++++++ src/personaincarico.h | 65 ++++ 8 files changed, 837 insertions(+), 92 deletions(-) create mode 100644 data/organigramma/form/persona_incarico.form create mode 100644 src/personaincarico.c create mode 100644 src/personaincarico.h diff --git a/data/organigramma/form/Makefile.am b/data/organigramma/form/Makefile.am index 6256aef..942fd34 100644 --- a/data/organigramma/form/Makefile.am +++ b/data/organigramma/form/Makefile.am @@ -3,6 +3,7 @@ formdir = $(datadir)/$(PACKAGE)/form form_DATA = \ nodo.form \ persona.form \ + persona_incarico.form \ persona_nodo.form \ persona_nodo_recapito.form \ persona_recapito.form \ diff --git a/data/organigramma/form/persona_incarico.form b/data/organigramma/form/persona_incarico.form new file mode 100644 index 0000000..91042c9 --- /dev/null +++ b/data/organigramma/form/persona_incarico.form @@ -0,0 +1,81 @@ + + + + persona_incarichi
+ + + + t + t + + + + + + + + + + + + + + + 0 + + SELECT id, nome FROM tipi_rapporto_lavoro WHERE status <> 'E' ORDER BY nome + + + + + + + 0 + + SELECT id, nome FROM posizioni_economiche WHERE status <> 'E' ORDER BY nome + + + + + + + 0 + + SELECT id, nome FROM tipi_prestazione WHERE status <> 'E' ORDER BY nome + + + + + + + 0 + + SELECT id, nome FROM profili_professionali WHERE status <> 'E' ORDER BY nome + + + + + + + + date + %d/%m/%Y + + + + + + date + %d/%m/%Y + + + + + + + + + + + +
diff --git a/data/organigramma/gui/organigramma.gui b/data/organigramma/gui/organigramma.gui index f2d7bf2..d1ef4b3 100644 --- a/data/organigramma/gui/organigramma.gui +++ b/data/organigramma/gui/organigramma.gui @@ -6147,7 +6147,7 @@ - + Incarico - Gestione organigramma True center-on-parent @@ -6180,7 +6180,7 @@ True True - 50 + 20 diff --git a/docs/organigramma.sql b/docs/organigramma.sql index 6a2405f..5029981 100644 --- a/docs/organigramma.sql +++ b/docs/organigramma.sql @@ -4,7 +4,7 @@ -- Dumped from database version 8.4.4 -- Dumped by pg_dump version 9.0.0 --- Started on 2010-10-14 16:40:21 +-- Started on 2010-10-14 17:07:58 SET statement_timeout = 0; SET client_encoding = 'UTF8'; @@ -14,7 +14,7 @@ SET client_min_messages = warning; SET escape_string_warning = off; -- --- TOC entry 356 (class 2612 OID 16386) +-- TOC entry 359 (class 2612 OID 16386) -- Name: plpgsql; Type: PROCEDURAL LANGUAGE; Schema: -; Owner: - -- @@ -26,8 +26,8 @@ SET search_path = public, pg_catalog; SET default_with_oids = false; -- --- TOC entry 1543 (class 1259 OID 59279) --- Dependencies: 1841 1842 1843 3 +-- TOC entry 1546 (class 1259 OID 59279) +-- Dependencies: 1845 1846 1847 3 -- Name: nodi; Type: TABLE; Schema: public; Owner: - -- @@ -42,8 +42,30 @@ CREATE TABLE nodi ( -- --- TOC entry 1559 (class 1259 OID 61295) --- Dependencies: 1891 1892 1893 1894 3 +-- TOC entry 1567 (class 1259 OID 61344) +-- Dependencies: 1912 1913 1914 1915 1916 1917 1918 1919 1920 3 +-- Name: persona_incarichi; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE persona_incarichi ( + id integer NOT NULL, + id_persone integer DEFAULT 0, + matricola character varying(20) DEFAULT ''::character varying, + id_tipi_rapporto_lavoro integer DEFAULT 0, + id_posizioni_economiche integer DEFAULT 0, + id_tipi_prestazione integer DEFAULT 0, + id_profili_professionali integer DEFAULT 0, + da_data date, + a_data date, + descrizione text DEFAULT ''::text, + note text DEFAULT ''::text, + status character varying(1) DEFAULT ''::character varying +); + + +-- +-- TOC entry 1562 (class 1259 OID 61295) +-- Dependencies: 1895 1896 1897 1898 3 -- Name: persona_nodi; Type: TABLE; Schema: public; Owner: - -- @@ -59,8 +81,8 @@ CREATE TABLE persona_nodi ( -- --- TOC entry 1560 (class 1259 OID 61307) --- Dependencies: 1895 1896 1897 1898 1899 1900 1901 3 +-- TOC entry 1563 (class 1259 OID 61307) +-- Dependencies: 1899 1900 1901 1902 1903 1904 1905 3 -- Name: persona_nodo_recapiti; Type: TABLE; Schema: public; Owner: - -- @@ -77,8 +99,8 @@ CREATE TABLE persona_nodo_recapiti ( -- --- TOC entry 1557 (class 1259 OID 61266) --- Dependencies: 1878 1879 1880 1881 1882 1883 3 +-- TOC entry 1560 (class 1259 OID 61266) +-- Dependencies: 1882 1883 1884 1885 1886 1887 3 -- Name: persona_recapiti; Type: TABLE; Schema: public; Owner: - -- @@ -94,8 +116,8 @@ CREATE TABLE persona_recapiti ( -- --- TOC entry 1556 (class 1259 OID 61243) --- Dependencies: 1876 1877 3 +-- TOC entry 1559 (class 1259 OID 61243) +-- Dependencies: 1880 1881 3 -- Name: persona_uffici; Type: TABLE; Schema: public; Owner: - -- @@ -111,8 +133,8 @@ CREATE TABLE persona_uffici ( -- --- TOC entry 1558 (class 1259 OID 61280) --- Dependencies: 1884 1885 1886 1887 1888 1889 1890 3 +-- TOC entry 1561 (class 1259 OID 61280) +-- Dependencies: 1888 1889 1890 1891 1892 1893 1894 3 -- Name: persona_ufficio_recapiti; Type: TABLE; Schema: public; Owner: - -- @@ -129,8 +151,8 @@ CREATE TABLE persona_ufficio_recapiti ( -- --- TOC entry 1554 (class 1259 OID 61227) --- Dependencies: 1870 1871 1872 1873 3 +-- TOC entry 1557 (class 1259 OID 61227) +-- Dependencies: 1874 1875 1876 1877 3 -- Name: persone; Type: TABLE; Schema: public; Owner: - -- @@ -145,8 +167,8 @@ CREATE TABLE persone ( -- --- TOC entry 1561 (class 1259 OID 61322) --- Dependencies: 1902 1903 3 +-- TOC entry 1564 (class 1259 OID 61322) +-- Dependencies: 1906 1907 3 -- Name: posizioni_economiche; Type: TABLE; Schema: public; Owner: - -- @@ -158,8 +180,8 @@ CREATE TABLE posizioni_economiche ( -- --- TOC entry 1563 (class 1259 OID 61336) --- Dependencies: 1906 1907 3 +-- TOC entry 1566 (class 1259 OID 61336) +-- Dependencies: 1910 1911 3 -- Name: profili_professionali; Type: TABLE; Schema: public; Owner: - -- @@ -171,8 +193,8 @@ CREATE TABLE profili_professionali ( -- --- TOC entry 1549 (class 1259 OID 59346) --- Dependencies: 1857 1858 1859 3 +-- TOC entry 1552 (class 1259 OID 59346) +-- Dependencies: 1861 1862 1863 3 -- Name: struttura_indirizzi; Type: TABLE; Schema: public; Owner: - -- @@ -187,8 +209,8 @@ CREATE TABLE struttura_indirizzi ( -- --- TOC entry 1547 (class 1259 OID 59327) --- Dependencies: 1851 1852 1853 1854 1855 3 +-- TOC entry 1550 (class 1259 OID 59327) +-- Dependencies: 1855 1856 1857 1858 1859 3 -- Name: strutture; Type: TABLE; Schema: public; Owner: - -- @@ -203,8 +225,8 @@ CREATE TABLE strutture ( -- --- TOC entry 1544 (class 1259 OID 59290) --- Dependencies: 1844 1845 3 +-- TOC entry 1547 (class 1259 OID 59290) +-- Dependencies: 1848 1849 3 -- Name: tipi_nodo; Type: TABLE; Schema: public; Owner: - -- @@ -216,8 +238,8 @@ CREATE TABLE tipi_nodo ( -- --- TOC entry 1562 (class 1259 OID 61329) --- Dependencies: 1904 1905 3 +-- TOC entry 1565 (class 1259 OID 61329) +-- Dependencies: 1908 1909 3 -- Name: tipi_prestazione; Type: TABLE; Schema: public; Owner: - -- @@ -229,8 +251,8 @@ CREATE TABLE tipi_prestazione ( -- --- TOC entry 1555 (class 1259 OID 61236) --- Dependencies: 1874 1875 3 +-- TOC entry 1558 (class 1259 OID 61236) +-- Dependencies: 1878 1879 3 -- Name: tipi_rapporto_lavoro; Type: TABLE; Schema: public; Owner: - -- @@ -242,8 +264,8 @@ CREATE TABLE tipi_rapporto_lavoro ( -- --- TOC entry 1545 (class 1259 OID 59297) --- Dependencies: 1846 1847 3 +-- TOC entry 1548 (class 1259 OID 59297) +-- Dependencies: 1850 1851 3 -- Name: tipi_recapito; Type: TABLE; Schema: public; Owner: - -- @@ -255,8 +277,8 @@ CREATE TABLE tipi_recapito ( -- --- TOC entry 1553 (class 1259 OID 61219) --- Dependencies: 1867 1868 1869 3 +-- TOC entry 1556 (class 1259 OID 61219) +-- Dependencies: 1871 1872 1873 3 -- Name: titoli; Type: TABLE; Schema: public; Owner: - -- @@ -269,8 +291,8 @@ CREATE TABLE titoli ( -- --- TOC entry 1546 (class 1259 OID 59311) --- Dependencies: 1848 1849 1850 3 +-- TOC entry 1549 (class 1259 OID 59311) +-- Dependencies: 1852 1853 1854 3 -- Name: uffici; Type: TABLE; Schema: public; Owner: - -- @@ -284,8 +306,8 @@ CREATE TABLE uffici ( -- --- TOC entry 1550 (class 1259 OID 59357) --- Dependencies: 1860 1861 3 +-- TOC entry 1553 (class 1259 OID 59357) +-- Dependencies: 1864 1865 3 -- Name: ufficio_nodi; Type: TABLE; Schema: public; Owner: - -- @@ -299,8 +321,8 @@ CREATE TABLE ufficio_nodi ( -- --- TOC entry 1551 (class 1259 OID 59399) --- Dependencies: 1862 1863 3 +-- TOC entry 1554 (class 1259 OID 59399) +-- Dependencies: 1866 1867 3 -- Name: ufficio_orari; Type: TABLE; Schema: public; Owner: - -- @@ -327,8 +349,8 @@ CREATE TABLE ufficio_orari ( -- --- TOC entry 1552 (class 1259 OID 59409) --- Dependencies: 1864 1865 1866 3 +-- TOC entry 1555 (class 1259 OID 59409) +-- Dependencies: 1868 1869 1870 3 -- Name: ufficio_recapiti; Type: TABLE; Schema: public; Owner: - -- @@ -344,8 +366,8 @@ CREATE TABLE ufficio_recapiti ( -- --- TOC entry 1548 (class 1259 OID 59340) --- Dependencies: 1856 3 +-- TOC entry 1551 (class 1259 OID 59340) +-- Dependencies: 1860 3 -- Name: vie; Type: TABLE; Schema: public; Owner: - -- @@ -356,8 +378,8 @@ CREATE TABLE vie ( -- --- TOC entry 1909 (class 2606 OID 59289) --- Dependencies: 1543 1543 +-- TOC entry 1922 (class 2606 OID 59289) +-- Dependencies: 1546 1546 -- Name: nodi_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- @@ -366,8 +388,18 @@ ALTER TABLE ONLY nodi -- --- TOC entry 1941 (class 2606 OID 61305) --- Dependencies: 1559 1559 +-- TOC entry 1964 (class 2606 OID 61360) +-- Dependencies: 1567 1567 +-- Name: persona_incarichi_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY persona_incarichi + ADD CONSTRAINT persona_incarichi_pkey PRIMARY KEY (id); + + +-- +-- TOC entry 1954 (class 2606 OID 61305) +-- Dependencies: 1562 1562 -- Name: persona_nodi_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- @@ -376,8 +408,8 @@ ALTER TABLE ONLY persona_nodi -- --- TOC entry 1943 (class 2606 OID 61321) --- Dependencies: 1560 1560 +-- TOC entry 1956 (class 2606 OID 61321) +-- Dependencies: 1563 1563 -- Name: persona_nodo_recapiti_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- @@ -386,8 +418,8 @@ ALTER TABLE ONLY persona_nodo_recapiti -- --- TOC entry 1937 (class 2606 OID 61279) --- Dependencies: 1557 1557 +-- TOC entry 1950 (class 2606 OID 61279) +-- Dependencies: 1560 1560 -- Name: persona_recapiti_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- @@ -396,8 +428,8 @@ ALTER TABLE ONLY persona_recapiti -- --- TOC entry 1935 (class 2606 OID 61252) --- Dependencies: 1556 1556 +-- TOC entry 1948 (class 2606 OID 61252) +-- Dependencies: 1559 1559 -- Name: persona_uffici_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- @@ -406,8 +438,8 @@ ALTER TABLE ONLY persona_uffici -- --- TOC entry 1939 (class 2606 OID 61294) --- Dependencies: 1558 1558 +-- TOC entry 1952 (class 2606 OID 61294) +-- Dependencies: 1561 1561 -- Name: persona_ufficio_recapiti_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- @@ -416,8 +448,8 @@ ALTER TABLE ONLY persona_ufficio_recapiti -- --- TOC entry 1931 (class 2606 OID 61235) --- Dependencies: 1554 1554 +-- TOC entry 1944 (class 2606 OID 61235) +-- Dependencies: 1557 1557 -- Name: persone_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- @@ -426,8 +458,8 @@ ALTER TABLE ONLY persone -- --- TOC entry 1945 (class 2606 OID 61328) --- Dependencies: 1561 1561 +-- TOC entry 1958 (class 2606 OID 61328) +-- Dependencies: 1564 1564 -- Name: posizioni_economiche_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- @@ -436,8 +468,8 @@ ALTER TABLE ONLY posizioni_economiche -- --- TOC entry 1949 (class 2606 OID 61342) --- Dependencies: 1563 1563 +-- TOC entry 1962 (class 2606 OID 61342) +-- Dependencies: 1566 1566 -- Name: profili_professionali_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- @@ -446,8 +478,8 @@ ALTER TABLE ONLY profili_professionali -- --- TOC entry 1921 (class 2606 OID 59356) --- Dependencies: 1549 1549 +-- TOC entry 1934 (class 2606 OID 59356) +-- Dependencies: 1552 1552 -- Name: struttura_indirizzi_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- @@ -456,8 +488,8 @@ ALTER TABLE ONLY struttura_indirizzi -- --- TOC entry 1917 (class 2606 OID 59339) --- Dependencies: 1547 1547 +-- TOC entry 1930 (class 2606 OID 59339) +-- Dependencies: 1550 1550 -- Name: strutture_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- @@ -466,8 +498,8 @@ ALTER TABLE ONLY strutture -- --- TOC entry 1911 (class 2606 OID 59296) --- Dependencies: 1544 1544 +-- TOC entry 1924 (class 2606 OID 59296) +-- Dependencies: 1547 1547 -- Name: tipi_nodo_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- @@ -476,8 +508,8 @@ ALTER TABLE ONLY tipi_nodo -- --- TOC entry 1947 (class 2606 OID 61335) --- Dependencies: 1562 1562 +-- TOC entry 1960 (class 2606 OID 61335) +-- Dependencies: 1565 1565 -- Name: tipi_prestazione_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- @@ -486,8 +518,8 @@ ALTER TABLE ONLY tipi_prestazione -- --- TOC entry 1933 (class 2606 OID 61242) --- Dependencies: 1555 1555 +-- TOC entry 1946 (class 2606 OID 61242) +-- Dependencies: 1558 1558 -- Name: tipi_rapporto_lavoro_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- @@ -496,8 +528,8 @@ ALTER TABLE ONLY tipi_rapporto_lavoro -- --- TOC entry 1913 (class 2606 OID 59303) --- Dependencies: 1545 1545 +-- TOC entry 1926 (class 2606 OID 59303) +-- Dependencies: 1548 1548 -- Name: tipi_recapito_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- @@ -506,8 +538,8 @@ ALTER TABLE ONLY tipi_recapito -- --- TOC entry 1929 (class 2606 OID 61226) --- Dependencies: 1553 1553 +-- TOC entry 1942 (class 2606 OID 61226) +-- Dependencies: 1556 1556 -- Name: titoli_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- @@ -516,8 +548,8 @@ ALTER TABLE ONLY titoli -- --- TOC entry 1915 (class 2606 OID 59321) --- Dependencies: 1546 1546 +-- TOC entry 1928 (class 2606 OID 59321) +-- Dependencies: 1549 1549 -- Name: uffici_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- @@ -526,8 +558,8 @@ ALTER TABLE ONLY uffici -- --- TOC entry 1923 (class 2606 OID 59366) --- Dependencies: 1550 1550 +-- TOC entry 1936 (class 2606 OID 59366) +-- Dependencies: 1553 1553 -- Name: ufficio_nodi_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- @@ -536,8 +568,8 @@ ALTER TABLE ONLY ufficio_nodi -- --- TOC entry 1925 (class 2606 OID 59408) --- Dependencies: 1551 1551 +-- TOC entry 1938 (class 2606 OID 59408) +-- Dependencies: 1554 1554 -- Name: ufficio_orari_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- @@ -546,8 +578,8 @@ ALTER TABLE ONLY ufficio_orari -- --- TOC entry 1927 (class 2606 OID 59419) --- Dependencies: 1552 1552 +-- TOC entry 1940 (class 2606 OID 59419) +-- Dependencies: 1555 1555 -- Name: ufficio_recapiti_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- @@ -556,8 +588,8 @@ ALTER TABLE ONLY ufficio_recapiti -- --- TOC entry 1919 (class 2606 OID 59345) --- Dependencies: 1548 1548 +-- TOC entry 1932 (class 2606 OID 59345) +-- Dependencies: 1551 1551 -- Name: vie_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- @@ -565,7 +597,7 @@ ALTER TABLE ONLY vie ADD CONSTRAINT vie_pkey PRIMARY KEY (id); --- Completed on 2010-10-14 16:40:22 +-- Completed on 2010-10-14 17:07:58 -- -- PostgreSQL database dump complete diff --git a/src/Makefile.am b/src/Makefile.am index e3939e9..fbd890f 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -21,6 +21,8 @@ organigramma_SOURCES = \ persona.h \ persone.c \ persone.h \ + personaincarico.c \ + personaincarico.h \ personanodo.c \ personanodo.h \ personanodorecapito.c \ diff --git a/src/persona.c b/src/persona.c index 69f8d72..8971d0e 100644 --- a/src/persona.c +++ b/src/persona.c @@ -21,6 +21,7 @@ #include #include "persona.h" +#include "personaincarico.h" #include "personanodo.h" #include "personanodorecapito.h" #include "personaufficio.h" @@ -33,13 +34,16 @@ static void persona_init (Persona *persona); static void persona_carica (Persona *persona); static void persona_salva (Persona *persona); +static void persona_carica_incarichi (Persona *persona); static void persona_carica_nodi (Persona *persona); static void persona_carica_nodo_recapiti (Persona *persona); static void persona_carica_uffici (Persona *persona); static void persona_carica_ufficio_recapiti (Persona *persona); static void persona_carica_recapiti (Persona *persona); -static void persona_ufficio_nodo_modifica (Persona *persona); +static void persona_incarico_modifica (Persona *persona); +static void persona_nodo_modifica (Persona *persona); +static void persona_nodo_recapito_modifica (Persona *persona); static void persona_ufficio_modifica (Persona *persona); static void persona_ufficio_recapito_modifica (Persona *persona); static void persona_recapito_modifica (Persona *persona); @@ -55,6 +59,7 @@ static void persona_get_property (GObject *object, GValue *value, GParamSpec *pspec); +static void persona_on_incarico_aggiornato (gpointer instance, gpointer user_data); static void persona_on_nodo_aggiornato (gpointer instance, gpointer user_data); static void persona_on_nodo_recapito_aggiornato (gpointer instance, gpointer user_data); static void persona_on_ufficio_aggiornato (gpointer instance, gpointer user_data); @@ -65,6 +70,17 @@ static gboolean persona_on_w_persona_delete_event (GtkWidget *widget, GdkEvent *event, gpointer user_data); +static void persona_on_btn_incarico_nuovo_clicked (GtkButton *button, + gpointer user_data); +static void persona_on_btn_incarico_modifica_clicked (GtkButton *button, + gpointer user_data); +static void persona_on_btn_incarico_elimina_clicked (GtkButton *button, + gpointer user_data); +static void persona_on_trv_incarichi_row_activated (GtkTreeView *tree_view, + GtkTreePath *tree_path, + GtkTreeViewColumn *column, + gpointer user_data); + static void persona_on_btn_nodo_nuovo_clicked (GtkButton *button, gpointer user_data); static void persona_on_btn_nodo_modifica_clicked (GtkButton *button, @@ -134,6 +150,7 @@ static void persona_on_btn_salva_clicked (GtkButton *button, enum { LBL_ID, + LSTORE_INCARICHI, LSTORE_NODI, LSTORE_NODO_RECAPITI, LSTORE_UFFICI, @@ -141,6 +158,14 @@ enum LSTORE_RECAPITI }; +enum +{ + INCARICHI_COL_ID, + INCARICHI_COL_DA_DATA, + INCARICHI_COL_A_DATA, + INCARICHI_COL_DESCRIZIONE +}; + enum { NODI_COL_ID, @@ -190,6 +215,7 @@ struct _PersonaPrivate GObject **objects; + GtkTreeSelection *sel_incarichi; GtkTreeSelection *sel_nodi; GtkTreeSelection *sel_nodo_recapiti; GtkTreeSelection *sel_uffici; @@ -255,6 +281,7 @@ Persona gtk_builder_add_objects_from_file (priv->commons->gtkbuilder, priv->commons->guifile, g_strsplit (g_strconcat ( "lstore_titoli" + "|lstore_persona_incarichi" "|lstore_persona_nodi" "|lstore_persona_nodo_recapiti" "|lstore_persona_uffici" @@ -276,6 +303,7 @@ Persona priv->objects = gtk_form_get_objects_by_name (priv->form, "label67", + "lstore_persona_incarichi", "lstore_persona_nodi", "lstore_persona_nodo_recapiti", "lstore_persona_uffici", @@ -286,6 +314,7 @@ Persona g_signal_connect (priv->w, "delete-event", G_CALLBACK (persona_on_w_persona_delete_event), (gpointer *)a); + priv->sel_incarichi = gtk_tree_view_get_selection (GTK_TREE_VIEW (gtk_builder_get_object (priv->commons->gtkbuilder, "treeview16"))); priv->sel_nodi = gtk_tree_view_get_selection (GTK_TREE_VIEW (gtk_builder_get_object (priv->commons->gtkbuilder, "treeview13"))); priv->sel_nodo_recapiti = gtk_tree_view_get_selection (GTK_TREE_VIEW (gtk_builder_get_object (priv->commons->gtkbuilder, "treeview14"))); priv->sel_uffici = gtk_tree_view_get_selection (GTK_TREE_VIEW (gtk_builder_get_object (priv->commons->gtkbuilder, "treeview11"))); @@ -297,6 +326,15 @@ Persona g_signal_connect (priv->sel_uffici, "changed", G_CALLBACK (persona_on_uffici_sel_changed), (gpointer)a); + g_signal_connect (G_OBJECT (gtk_builder_get_object (priv->commons->gtkbuilder, "button79")), + "clicked", G_CALLBACK (persona_on_btn_incarico_nuovo_clicked), (gpointer *)a); + g_signal_connect (G_OBJECT (gtk_builder_get_object (priv->commons->gtkbuilder, "button80")), + "clicked", G_CALLBACK (persona_on_btn_incarico_modifica_clicked), (gpointer *)a); + g_signal_connect (G_OBJECT (gtk_builder_get_object (priv->commons->gtkbuilder, "button81")), + "clicked", G_CALLBACK (persona_on_btn_incarico_elimina_clicked), (gpointer *)a); + g_signal_connect (G_OBJECT (gtk_builder_get_object (priv->commons->gtkbuilder, "treeview16")), + "row-activated", G_CALLBACK (persona_on_trv_incarichi_row_activated), (gpointer *)a); + g_signal_connect (G_OBJECT (gtk_builder_get_object (priv->commons->gtkbuilder, "button70")), "clicked", G_CALLBACK (persona_on_btn_nodo_nuovo_clicked), (gpointer *)a); g_signal_connect (G_OBJECT (gtk_builder_get_object (priv->commons->gtkbuilder, "button71")), @@ -385,6 +423,7 @@ persona_carica (Persona *persona) if (gtk_form_fill_from_table (priv->form)) { + persona_carica_incarichi (persona); persona_carica_nodi (persona); persona_carica_nodo_recapiti (persona); persona_carica_uffici (persona); @@ -457,6 +496,46 @@ persona_salva (Persona *persona) } } +static void +persona_carica_incarichi (Persona *persona) +{ + gchar *sql; + GdaDataModel *dm; + guint row; + guint rows; + + PersonaPrivate *priv = PERSONA_GET_PRIVATE (persona); + + gtk_list_store_clear (GTK_LIST_STORE (priv->objects[LSTORE_INCARICHI])); + + sql = g_strdup_printf ("SELECT pi.id, pi.da_data, pi.a_data, pi.descrizione" + " FROM persona_incarichi AS pi" + " WHERE pi.id_persone = %d" + " AND pi.status <> 'E'" + " ORDER BY pi.da_data, pi.a_data, pi.descrizione", + priv->id); + dm = gdaex_query (priv->commons->gdaex, sql); + if (dm != NULL) + { + GtkTreeIter iter; + + rows = gda_data_model_get_n_rows (dm); + for (row = 0; row < rows; row++) + { + gtk_list_store_append (GTK_LIST_STORE (priv->objects[LSTORE_INCARICHI]), &iter); + gtk_list_store_set (GTK_LIST_STORE (priv->objects[LSTORE_INCARICHI]), &iter, + INCARICHI_COL_ID, gdaex_data_model_get_field_value_integer_at (dm, row, "id"), + INCARICHI_COL_DA_DATA, gtk_form_field_datetime_get_str_from_tm (gdaex_data_model_get_field_value_tm_at (dm, row, "da_data"), "%d/%m/%Y"), + INCARICHI_COL_A_DATA, gtk_form_field_datetime_get_str_from_tm (gdaex_data_model_get_field_value_tm_at (dm, row, "a_data"), "%d/%m/%Y"), + INCARICHI_COL_DESCRIZIONE, gdaex_data_model_get_field_value_stringify_at (dm, row, "descrizione"), + -1); + } + + g_object_unref (dm); + } + g_free (sql); +} + static void persona_carica_nodi (Persona *persona) { @@ -473,7 +552,8 @@ persona_carica_nodi (Persona *persona) " FROM persona_nodi AS pu INNER JOIN nodi AS u ON pu.id_nodi = u.id" " INNER JOIN tipi_nodo AS tn ON u.id_tipi_nodo = tn.id" " WHERE pu.id_persone = %d" - " AND pu.status <> 'E'", + " AND pu.status <> 'E'" + " ORDER BY pu.da_data, pu.a_data, tn.nome, u.nome", priv->id); dm = gdaex_query (priv->commons->gdaex, sql); if (dm != NULL) @@ -566,7 +646,8 @@ persona_carica_uffici (Persona *persona) " FROM persona_uffici AS pu INNER JOIN uffici AS u ON" " pu.id_uffici = u.id" " WHERE pu.id_persone = %d" - " AND pu.status <> 'E'", + " AND pu.status <> 'E'" + " ORDER BY pu.da_data, pu.a_data, u.nome", priv->id); dm = gdaex_query (priv->commons->gdaex, sql); if (dm != NULL) @@ -682,6 +763,44 @@ persona_carica_recapiti (Persona *persona) g_free (sql); } +static void +persona_incarico_modifica (Persona *persona) +{ + GtkTreeIter iter; + GtkWidget *dialog; + + PersonaPrivate *priv = PERSONA_GET_PRIVATE (persona); + + if (gtk_tree_selection_get_selected (priv->sel_incarichi, NULL, &iter)) + { + guint id; + GtkWidget *w; + + gtk_tree_model_get (GTK_TREE_MODEL (priv->objects[LSTORE_INCARICHI]), &iter, + INCARICHI_COL_ID, &id, + -1); + + PersonaIncarico *a = persona_incarico_new (priv->commons, id, 0); + + g_signal_connect (G_OBJECT (a), "aggiornato", + G_CALLBACK (persona_on_incarico_aggiornato), (gpointer)persona); + + w = persona_incarico_get_widget (a); + gtk_window_set_transient_for (GTK_WINDOW (w), GTK_WINDOW (priv->w)); + gtk_widget_show (w); + } + else + { + dialog = gtk_message_dialog_new (GTK_WINDOW (priv->w), + GTK_DIALOG_DESTROY_WITH_PARENT, + GTK_MESSAGE_WARNING, + GTK_BUTTONS_OK, + "Occorre prima selezionare un incarico."); + gtk_dialog_run (GTK_DIALOG (dialog)); + gtk_widget_destroy (dialog); + } +} + static void persona_nodo_modifica (Persona *persona) { @@ -970,6 +1089,15 @@ persona_conferma_chiusura (Persona *persona) } /* CALLBACK */ +static void +persona_on_incarico_aggiornato (gpointer instance, gpointer user_data) +{ + Persona *persona = (Persona *)user_data; + PersonaClass *klass = PERSONA_GET_CLASS (persona); + + persona_carica_incarichi (persona); +} + static void persona_on_nodo_aggiornato (gpointer instance, gpointer user_data) { @@ -1023,6 +1151,93 @@ persona_on_w_persona_delete_event (GtkWidget *widget, return !persona_conferma_chiusura ((Persona *)user_data); } +static void +persona_on_btn_incarico_nuovo_clicked (GtkButton *button, + gpointer user_data) +{ + GtkWidget *w; + + Persona *persona = (Persona *)user_data; + + PersonaPrivate *priv = PERSONA_GET_PRIVATE (persona); + + PersonaIncarico *a = persona_incarico_new (priv->commons, 0, priv->id); + + g_signal_connect (G_OBJECT (a), "aggiornato", + G_CALLBACK (persona_on_incarico_aggiornato), (gpointer)persona); + + w = persona_incarico_get_widget (a); + gtk_window_set_transient_for (GTK_WINDOW (w), GTK_WINDOW (priv->w)); + gtk_widget_show (w); +} + +static void +persona_on_btn_incarico_modifica_clicked (GtkButton *button, + gpointer user_data) +{ + persona_incarico_modifica ((Persona *)user_data); +} + +static void +persona_on_btn_incarico_elimina_clicked (GtkButton *button, + gpointer user_data) +{ + GtkTreeIter iter; + GtkWidget *dialog; + guint risp; + + Persona *persona = (Persona *)user_data; + + PersonaClass *klass = PERSONA_GET_CLASS (persona); + PersonaPrivate *priv = PERSONA_GET_PRIVATE (persona); + + if (gtk_tree_selection_get_selected (priv->sel_incarichi, NULL, &iter)) + { + dialog = gtk_message_dialog_new (GTK_WINDOW (priv->w), + GTK_DIALOG_DESTROY_WITH_PARENT, + GTK_MESSAGE_QUESTION, + GTK_BUTTONS_YES_NO, + "Sicuro di voler eliminare l'incarico selezionato?"); + risp = gtk_dialog_run (GTK_DIALOG (dialog)); + if (risp == GTK_RESPONSE_YES) + { + guint id; + + gtk_tree_model_get (GTK_TREE_MODEL (priv->objects[LSTORE_INCARICHI]), &iter, + INCARICHI_COL_ID, &id, + -1); + + gdaex_execute (priv->commons->gdaex, + g_strdup_printf ("UPDATE persona_incarichi" + " SET status = 'E'" + " WHERE id = %d", + id)); + + persona_carica_incarichi (persona); + } + gtk_widget_destroy (dialog); + } + else + { + dialog = gtk_message_dialog_new (GTK_WINDOW (priv->w), + GTK_DIALOG_DESTROY_WITH_PARENT, + GTK_MESSAGE_WARNING, + GTK_BUTTONS_OK, + "Occorre prima selezionare un incarico."); + gtk_dialog_run (GTK_DIALOG (dialog)); + gtk_widget_destroy (dialog); + } +} + +static void +persona_on_trv_incarichi_row_activated (GtkTreeView *tree_view, + GtkTreePath *tree_path, + GtkTreeViewColumn *column, + gpointer user_data) +{ + persona_incarico_modifica ((Persona *)user_data); +} + static void persona_on_btn_nodo_nuovo_clicked (GtkButton *button, gpointer user_data) diff --git a/src/personaincarico.c b/src/personaincarico.c new file mode 100644 index 0000000..bcef0ea --- /dev/null +++ b/src/personaincarico.c @@ -0,0 +1,349 @@ +/* + * Copyright (C) 2009 Andrea Zagli + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#ifdef HAVE_CONFIG_H + #include +#endif + +#include + +#include "personaincarico.h" +#include "nodi.h" + +static void persona_incarico_class_init (PersonaIncaricoClass *klass); +static void persona_incarico_init (PersonaIncarico *persona_incarico); + +static void persona_incarico_carica (PersonaIncarico *persona_incarico); +static void persona_incarico_salva (PersonaIncarico *persona_incarico); + +static gboolean persona_incarico_conferma_chiusura (PersonaIncarico *persona_incarico); + +static void persona_incarico_set_property (GObject *object, + guint property_id, + const GValue *value, + GParamSpec *pspec); +static void persona_incarico_get_property (GObject *object, + guint property_id, + GValue *value, + GParamSpec *pspec); + +static gboolean persona_incarico_on_w_persona_incarico_delete_event (GtkWidget *widget, + GdkEvent *event, + gpointer user_data); + +static void persona_incarico_on_btn_annulla_clicked (GtkButton *button, + gpointer user_data); +static void persona_incarico_on_btn_salva_clicked (GtkButton *button, + gpointer user_data); + + +#define PERSONA_INCARICO_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), TYPE_PERSONA_INCARICO, PersonaIncaricoPrivate)) + +enum +{ + LBL_ID, + LBL_ID_PERSONE +}; + +typedef struct _PersonaIncaricoPrivate PersonaIncaricoPrivate; +struct _PersonaIncaricoPrivate + { + Commons *commons; + + GtkForm *form; + + GtkWidget *w; + + GObject **objects; + + guint id; + }; + +G_DEFINE_TYPE (PersonaIncarico, persona_incarico, G_TYPE_OBJECT) + +static void +persona_incarico_class_init (PersonaIncaricoClass *klass) +{ + GObjectClass *object_class = G_OBJECT_CLASS (klass); + + g_type_class_add_private (object_class, sizeof (PersonaIncaricoPrivate)); + + object_class->set_property = persona_incarico_set_property; + object_class->get_property = persona_incarico_get_property; + + /** + * PersonaIncarico::aggiornato: + * @persona_incarico: + * + */ + klass->aggiornato_signal_id = g_signal_new ("aggiornato", + G_TYPE_FROM_CLASS (object_class), + G_SIGNAL_RUN_LAST, + 0, + NULL, + NULL, + g_cclosure_marshal_VOID__VOID, + G_TYPE_NONE, + 0); +} + +static void +persona_incarico_init (PersonaIncarico *persona_incarico) +{ + PersonaIncaricoPrivate *priv = PERSONA_INCARICO_GET_PRIVATE (persona_incarico); +} + +/** + * persona_incarico_new: + * @commons: + * @id: + * @id_persone: + * + * Returns: the newly created #PersonaIncarico object. + */ +PersonaIncarico +*persona_incarico_new (Commons *commons, guint id, guint id_persone) +{ + GError *error; + + PersonaIncarico *a = PERSONA_INCARICO (g_object_new (persona_incarico_get_type (), NULL)); + + PersonaIncaricoPrivate *priv = PERSONA_INCARICO_GET_PRIVATE (a); + + priv->commons = commons; + + error = NULL; + + gtk_builder_add_objects_from_file (priv->commons->gtkbuilder, priv->commons->guifile, + g_strsplit ( + "lstore_tipi_rapporto_lavoro" + "|lstore_posizioni_economiche" + "|lstore_tipi_prestazione" + "|lstore_profili_professionali" + "|w_persona_incarico", "|", -1), + &error); + if (error != NULL) + { + g_fprintf (stderr, "Errore: %s\n", error->message); + return NULL; + } + + priv->form = gtk_form_new (); + g_object_set (G_OBJECT (priv->form), "gdaex", priv->commons->gdaex, NULL); + gtk_form_load_from_file (priv->form, g_build_filename (priv->commons->formdir, "persona_incarico.form", NULL), priv->commons->gtkbuilder); + + priv->w = GTK_WIDGET (gtk_builder_get_object (priv->commons->gtkbuilder, "w_persona_incarico")); + + priv->objects = gtk_form_get_objects_by_name (priv->form, + "label129", + "label130", + NULL); + + g_signal_connect (priv->w, + "delete-event", G_CALLBACK (persona_incarico_on_w_persona_incarico_delete_event), (gpointer *)a); + + g_signal_connect (G_OBJECT (gtk_builder_get_object (priv->commons->gtkbuilder, "button98")), + "clicked", G_CALLBACK (persona_incarico_on_btn_annulla_clicked), (gpointer *)a); + g_signal_connect (G_OBJECT (gtk_builder_get_object (priv->commons->gtkbuilder, "button99")), + "clicked", G_CALLBACK (persona_incarico_on_btn_salva_clicked), (gpointer *)a); + + priv->id = id; + if (priv->id == 0) + { + gtk_label_set_text (GTK_LABEL (priv->objects[LBL_ID]), ""); + gtk_label_set_text (GTK_LABEL (priv->objects[LBL_ID_PERSONE]), g_strdup_printf ("%d", id_persone)); + + gtk_form_set_as_origin (priv->form); + } + else + { + gtk_label_set_text (GTK_LABEL (priv->objects[LBL_ID]), g_strdup_printf ("%d", priv->id)); + + persona_incarico_carica (a); + } + + return a; +} + +/** + * persona_incarico_get_widget: + * @persona_incarico: + * + */ +GtkWidget +*persona_incarico_get_widget (PersonaIncarico *persona_incarico) +{ + PersonaIncaricoPrivate *priv = PERSONA_INCARICO_GET_PRIVATE (persona_incarico); + + return priv->w; +} + +/* PRIVATE */ +static void +persona_incarico_carica (PersonaIncarico *persona_incarico) +{ + gchar *sql; + GdaDataModel *dm; + + PersonaIncaricoPrivate *priv = PERSONA_INCARICO_GET_PRIVATE (persona_incarico); + + if (gtk_form_fill_from_table (priv->form)) + { + } +} + +static void +persona_incarico_salva (PersonaIncarico *persona_incarico) +{ + gchar *sql; + GtkWidget *dialog; + + PersonaIncaricoClass *klass = PERSONA_INCARICO_GET_CLASS (persona_incarico); + + PersonaIncaricoPrivate *priv = PERSONA_INCARICO_GET_PRIVATE (persona_incarico); + + if (!gtk_form_check (priv->form, FALSE, NULL, TRUE, priv->w, TRUE)) + { + return; + } + + if (priv->id == 0) + { + sql = gtk_form_get_sql (priv->form, GTK_FORM_SQL_INSERT); + } + else + { + sql = gtk_form_get_sql (priv->form, GTK_FORM_SQL_UPDATE); + } + + if (gdaex_execute (priv->commons->gdaex, sql) == 1) + { + g_signal_emit (persona_incarico, klass->aggiornato_signal_id, 0); + + if (priv->id == 0) + { + priv->id = strtol (gtk_label_get_text (GTK_LABEL (priv->objects[LBL_ID])), NULL, 10); + } + + gtk_form_set_as_origin (priv->form); + + dialog = gtk_message_dialog_new (GTK_WINDOW (priv->w), + GTK_DIALOG_DESTROY_WITH_PARENT, + GTK_MESSAGE_INFO, + GTK_BUTTONS_OK, + "Salvataggio eseguito con successo."); + gtk_dialog_run (GTK_DIALOG (dialog)); + gtk_widget_destroy (dialog); + } + else + { + dialog = gtk_message_dialog_new (GTK_WINDOW (priv->w), + GTK_DIALOG_DESTROY_WITH_PARENT, + GTK_MESSAGE_WARNING, + GTK_BUTTONS_OK, + "Errore durante il salvataggio."); + gtk_dialog_run (GTK_DIALOG (dialog)); + gtk_widget_destroy (dialog); + } +} + +static void +persona_incarico_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec) +{ + PersonaIncarico *persona_incarico = PERSONA_INCARICO (object); + + PersonaIncaricoPrivate *priv = PERSONA_INCARICO_GET_PRIVATE (persona_incarico); + + switch (property_id) + { + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + break; + } +} + +static void +persona_incarico_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec) +{ + PersonaIncarico *persona_incarico = PERSONA_INCARICO (object); + + PersonaIncaricoPrivate *priv = PERSONA_INCARICO_GET_PRIVATE (persona_incarico); + + switch (property_id) + { + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + break; + } +} + +static gboolean +persona_incarico_conferma_chiusura (PersonaIncarico *persona_incarico) +{ + GtkWidget *dialog; + + gboolean ret; + + PersonaIncaricoPrivate *priv = PERSONA_INCARICO_GET_PRIVATE (persona_incarico); + + ret = TRUE; + + if (gtk_form_is_changed (priv->form)) + { + dialog = gtk_message_dialog_new (GTK_WINDOW (priv->w), + GTK_DIALOG_DESTROY_WITH_PARENT, + GTK_MESSAGE_QUESTION, + GTK_BUTTONS_YES_NO, + "Sicuro di voler chiudere senza salvare?"); + if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_NO) + { + ret = FALSE; + } + gtk_widget_destroy (dialog); + } + + return ret; +} + +/* CALLBACK */ +static gboolean +persona_incarico_on_w_persona_incarico_delete_event (GtkWidget *widget, + GdkEvent *event, + gpointer user_data) +{ + return !persona_incarico_conferma_chiusura ((PersonaIncarico *)user_data); +} + +static void +persona_incarico_on_btn_annulla_clicked (GtkButton *button, + gpointer user_data) +{ + PersonaIncarico *persona_incarico = (PersonaIncarico *)user_data; + + PersonaIncaricoPrivate *priv = PERSONA_INCARICO_GET_PRIVATE (persona_incarico); + + if (persona_incarico_conferma_chiusura (persona_incarico)) gtk_widget_destroy (priv->w); +} + +static void +persona_incarico_on_btn_salva_clicked (GtkButton *button, + gpointer user_data) +{ + persona_incarico_salva ((PersonaIncarico *)user_data); +} diff --git a/src/personaincarico.h b/src/personaincarico.h new file mode 100644 index 0000000..914ea2a --- /dev/null +++ b/src/personaincarico.h @@ -0,0 +1,65 @@ +/* + * Copyright (C) 2009 Andrea Zagli + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#ifndef __PERSONA_INCARICO_H__ +#define __PERSONA_INCARICO_H__ + +#include +#include + +#include + +#include "commons.h" + +G_BEGIN_DECLS + + +#define TYPE_PERSONA_INCARICO (persona_incarico_get_type ()) +#define PERSONA_INCARICO(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_PERSONA_INCARICO, PersonaIncarico)) +#define PERSONA_INCARICO_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_PERSONA_INCARICO, PersonaIncaricoClass)) +#define IS_PERSONA_INCARICO(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_PERSONA_INCARICO)) +#define IS_PERSONA_INCARICO_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_PERSONA_INCARICO)) +#define PERSONA_INCARICO_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_PERSONA_INCARICO, PersonaIncaricoClass)) + + +typedef struct _PersonaIncarico PersonaIncarico; +typedef struct _PersonaIncaricoClass PersonaIncaricoClass; + +struct _PersonaIncarico + { + GObject parent; + }; + +struct _PersonaIncaricoClass + { + GObjectClass parent_class; + + guint aggiornato_signal_id; + }; + +GType persona_incarico_get_type (void) G_GNUC_CONST; + +PersonaIncarico *persona_incarico_new (Commons *commons, guint id, guint id_persone); + +GtkWidget *persona_incarico_get_widget (PersonaIncarico *persona_incarico); + + +G_END_DECLS + +#endif /* __PERSONA_INCARICO_H__ */ -- 2.49.0