]> saetta.ns0.it Git - solipa/organigramma/commitdiff
Aggiunti gli allegati all'ufficio (closes #651).
authorAndrea Zagli <a.zagli@comune.scandicci.fi.it>
Tue, 4 Jun 2013 09:17:45 +0000 (11:17 +0200)
committerAndrea Zagli <a.zagli@comune.scandicci.fi.it>
Tue, 4 Jun 2013 09:17:45 +0000 (11:17 +0200)
data/organigramma/form/Makefile.am
data/organigramma/form/ufficio_allegato.form [new file with mode: 0644]
data/organigramma/gui/organigramma.gui
docs/DBChangelog
docs/organigramma.sql
libreria/Makefile.am
src/Makefile.am
src/ufficio.c
src/ufficioallegato.c [new file with mode: 0644]
src/ufficioallegato.h [new file with mode: 0644]

index a65dbd485a115e0f0368a619a8d804a4753df908..913a690cc10cf90cad4f3894085c81047974938f 100644 (file)
@@ -22,6 +22,7 @@ form_DATA = \
             tipo_recapito.form \
             titolo.form \
             ufficio.form \
+            ufficio_allegato.form \
             ufficio_collegamento.form \
             ufficio_nodo.form \
             ufficio_orario.form \
diff --git a/data/organigramma/form/ufficio_allegato.form b/data/organigramma/form/ufficio_allegato.form
new file mode 100644 (file)
index 0000000..63e8b7e
--- /dev/null
@@ -0,0 +1,38 @@
+<?xml version="1.0"?>
+<gtkform>
+
+       <table>ufficio_allegati</table>
+
+       <widget type="label" name="label193" label="label192">
+               <field type="integer" name="id">
+                       <is-key>t</is-key>
+                       <auto-increment>t</auto-increment>
+               </field>
+       </widget>
+
+       <widget type="label" name="label199">
+               <field type="integer" name="id_uffici" />
+       </widget>
+
+       <widget type="entry" name="entry56" label="label197">
+               <field type="text" name="titolo">
+                       <obligatory>t</obligatory>
+               </field>
+       </widget>
+
+       <widget type="entry" name="entry54" label="label194">
+               <field type="text" name="descrizione" />
+       </widget>
+
+       <widget type="entry" name="entry55" label="label196">
+               <field type="datetime" name="data_documento">
+                       <datetime-type>date</datetime-type>
+                       <display-format>%d/%m/%Y</display-format>
+               </field>
+       </widget>
+
+       <widget type="textview" name="textview21" label="label195">
+               <field type="text" name="note" />
+       </widget>
+
+</gtkform>
index 2227fb5845c71f5d87a484b6e241c590ff9ed56d..8890f89e56aba64fb9b3a076986d81b8e4cfe7bd 100644 (file)
       <column type="gchararray"/>
     </columns>
   </object>
+  <object class="GtkListStore" id="lstore_ufficio_allegati">
+    <columns>
+      <!-- column-name id -->
+      <column type="guint"/>
+      <!-- column-name titolo -->
+      <column type="gchararray"/>
+      <!-- column-name descrizione -->
+      <column type="gchararray"/>
+      <!-- column-name percorso -->
+      <column type="gchararray"/>
+      <!-- column-name contenuto -->
+      <column type="guint"/>
+    </columns>
+  </object>
   <object class="GtkListStore" id="lstore_ufficio_collegamenti">
     <columns>
       <!-- column-name id -->
                     <property name="tab_fill">False</property>
                   </packing>
                 </child>
+                <child>
+                  <object class="GtkHBox" id="hbox24">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="border_width">5</property>
+                    <property name="spacing">5</property>
+                    <child>
+                      <object class="GtkScrolledWindow" id="scrolledwindow49">
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <property name="hscrollbar_policy">automatic</property>
+                        <property name="vscrollbar_policy">automatic</property>
+                        <property name="shadow_type">etched-in</property>
+                        <child>
+                          <object class="GtkTreeView" id="treeview28">
+                            <property name="visible">True</property>
+                            <property name="can_focus">True</property>
+                            <property name="model">lstore_ufficio_allegati</property>
+                            <property name="headers_clickable">False</property>
+                            <property name="rules_hint">True</property>
+                            <property name="search_column">0</property>
+                            <child>
+                              <object class="GtkTreeViewColumn" id="treeviewcolumn48">
+                                <property name="title">Titolo</property>
+                                <child>
+                                  <object class="GtkCellRendererText" id="cellrenderertext59"/>
+                                  <attributes>
+                                    <attribute name="text">1</attribute>
+                                  </attributes>
+                                </child>
+                              </object>
+                            </child>
+                            <child>
+                              <object class="GtkTreeViewColumn" id="treeviewcolumn49">
+                                <property name="title">Descrizione</property>
+                                <child>
+                                  <object class="GtkCellRendererText" id="cellrenderertext60"/>
+                                  <attributes>
+                                    <attribute name="text">2</attribute>
+                                  </attributes>
+                                </child>
+                              </object>
+                            </child>
+                          </object>
+                        </child>
+                      </object>
+                      <packing>
+                        <property name="expand">True</property>
+                        <property name="fill">True</property>
+                        <property name="position">0</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkVButtonBox" id="vbuttonbox16">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="spacing">5</property>
+                        <property name="layout_style">start</property>
+                        <child>
+                          <object class="GtkButton" id="button198">
+                            <property name="label">gtk-new</property>
+                            <property name="visible">True</property>
+                            <property name="can_focus">True</property>
+                            <property name="receives_default">True</property>
+                            <property name="use_stock">True</property>
+                          </object>
+                          <packing>
+                            <property name="expand">False</property>
+                            <property name="fill">False</property>
+                            <property name="position">0</property>
+                          </packing>
+                        </child>
+                        <child>
+                          <object class="GtkButton" id="button199">
+                            <property name="label">gtk-edit</property>
+                            <property name="visible">True</property>
+                            <property name="can_focus">True</property>
+                            <property name="receives_default">True</property>
+                            <property name="use_stock">True</property>
+                          </object>
+                          <packing>
+                            <property name="expand">False</property>
+                            <property name="fill">False</property>
+                            <property name="position">1</property>
+                          </packing>
+                        </child>
+                        <child>
+                          <object class="GtkButton" id="button200">
+                            <property name="label">gtk-delete</property>
+                            <property name="visible">True</property>
+                            <property name="can_focus">True</property>
+                            <property name="receives_default">True</property>
+                            <property name="use_stock">True</property>
+                          </object>
+                          <packing>
+                            <property name="expand">False</property>
+                            <property name="fill">False</property>
+                            <property name="position">2</property>
+                          </packing>
+                        </child>
+                        <child>
+                          <object class="GtkButton" id="button201">
+                            <property name="label">gtk-open</property>
+                            <property name="visible">True</property>
+                            <property name="can_focus">True</property>
+                            <property name="receives_default">True</property>
+                            <property name="use_stock">True</property>
+                          </object>
+                          <packing>
+                            <property name="expand">False</property>
+                            <property name="fill">False</property>
+                            <property name="position">3</property>
+                          </packing>
+                        </child>
+                      </object>
+                      <packing>
+                        <property name="expand">False</property>
+                        <property name="fill">True</property>
+                        <property name="position">1</property>
+                      </packing>
+                    </child>
+                  </object>
+                  <packing>
+                    <property name="position">4</property>
+                  </packing>
+                </child>
+                <child type="tab">
+                  <object class="GtkLabel" id="label200">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="label" translatable="yes">Allegati</property>
+                  </object>
+                  <packing>
+                    <property name="position">4</property>
+                    <property name="tab_fill">False</property>
+                  </packing>
+                </child>
               </object>
               <packing>
                 <property name="right_attach">2</property>
       </object>
     </child>
   </object>
+  <object class="GtkWindow" id="w_ufficio_allegato">
+    <property name="can_focus">False</property>
+    <property name="title" translatable="yes">Allegato - Organigramma</property>
+    <property name="modal">True</property>
+    <property name="window_position">center-on-parent</property>
+    <property name="default_width">480</property>
+    <property name="destroy_with_parent">True</property>
+    <child>
+      <object class="GtkVBox" id="vbox29">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="border_width">5</property>
+        <property name="spacing">5</property>
+        <child>
+          <object class="GtkTable" id="table28">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="n_rows">7</property>
+            <property name="n_columns">2</property>
+            <property name="column_spacing">5</property>
+            <property name="row_spacing">5</property>
+            <child>
+              <placeholder/>
+            </child>
+            <child>
+              <object class="GtkLabel" id="label192">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="xalign">0</property>
+                <property name="label" translatable="yes">ID</property>
+              </object>
+              <packing>
+                <property name="x_options">GTK_FILL</property>
+                <property name="y_options">GTK_FILL</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkLabel" id="label193">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="xalign">0</property>
+                <property name="label" translatable="yes">lbl_id</property>
+              </object>
+              <packing>
+                <property name="left_attach">1</property>
+                <property name="right_attach">2</property>
+                <property name="y_options">GTK_FILL</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkLabel" id="label194">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="xalign">0</property>
+                <property name="label" translatable="yes">Descrizione</property>
+              </object>
+              <packing>
+                <property name="top_attach">2</property>
+                <property name="bottom_attach">3</property>
+                <property name="x_options">GTK_FILL</property>
+                <property name="y_options">GTK_FILL</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkEntry" id="entry54">
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="max_length">255</property>
+                <property name="invisible_char">●</property>
+                <property name="activates_default">True</property>
+                <property name="invisible_char_set">True</property>
+                <property name="primary_icon_activatable">False</property>
+                <property name="secondary_icon_activatable">False</property>
+                <property name="primary_icon_sensitive">True</property>
+                <property name="secondary_icon_sensitive">True</property>
+              </object>
+              <packing>
+                <property name="left_attach">1</property>
+                <property name="right_attach">2</property>
+                <property name="top_attach">2</property>
+                <property name="bottom_attach">3</property>
+                <property name="y_options">GTK_FILL</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkLabel" id="label195">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="xalign">0</property>
+                <property name="yalign">0</property>
+                <property name="label" translatable="yes">Note</property>
+              </object>
+              <packing>
+                <property name="top_attach">4</property>
+                <property name="bottom_attach">5</property>
+                <property name="x_options">GTK_FILL</property>
+                <property name="y_options">GTK_FILL</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkScrolledWindow" id="scrolledwindow48">
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="hscrollbar_policy">automatic</property>
+                <property name="vscrollbar_policy">automatic</property>
+                <property name="shadow_type">etched-in</property>
+                <child>
+                  <object class="GtkTextView" id="textview21">
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                  </object>
+                </child>
+              </object>
+              <packing>
+                <property name="left_attach">1</property>
+                <property name="right_attach">2</property>
+                <property name="top_attach">4</property>
+                <property name="bottom_attach">5</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkLabel" id="label196">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="xalign">0</property>
+                <property name="label" translatable="yes">Data documento</property>
+              </object>
+              <packing>
+                <property name="top_attach">3</property>
+                <property name="bottom_attach">4</property>
+                <property name="x_options">GTK_FILL</property>
+                <property name="y_options">GTK_FILL</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkEntry" id="entry55">
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="max_length">10</property>
+                <property name="invisible_char">●</property>
+                <property name="activates_default">True</property>
+                <property name="invisible_char_set">True</property>
+                <property name="primary_icon_activatable">False</property>
+                <property name="secondary_icon_activatable">False</property>
+                <property name="primary_icon_sensitive">True</property>
+                <property name="secondary_icon_sensitive">True</property>
+              </object>
+              <packing>
+                <property name="left_attach">1</property>
+                <property name="right_attach">2</property>
+                <property name="top_attach">3</property>
+                <property name="bottom_attach">4</property>
+                <property name="y_options">GTK_FILL</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkLabel" id="label197">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="xalign">0</property>
+                <property name="label" translatable="yes">Titolo</property>
+              </object>
+              <packing>
+                <property name="top_attach">1</property>
+                <property name="bottom_attach">2</property>
+                <property name="x_options">GTK_FILL</property>
+                <property name="y_options">GTK_FILL</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkEntry" id="entry56">
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="max_length">255</property>
+                <property name="invisible_char">●</property>
+                <property name="activates_default">True</property>
+                <property name="invisible_char_set">True</property>
+                <property name="primary_icon_activatable">False</property>
+                <property name="secondary_icon_activatable">False</property>
+                <property name="primary_icon_sensitive">True</property>
+                <property name="secondary_icon_sensitive">True</property>
+              </object>
+              <packing>
+                <property name="left_attach">1</property>
+                <property name="right_attach">2</property>
+                <property name="top_attach">1</property>
+                <property name="bottom_attach">2</property>
+                <property name="y_options">GTK_FILL</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkFrame" id="frame4">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="label_xalign">0</property>
+                <child>
+                  <object class="GtkAlignment" id="alignment2">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="border_width">5</property>
+                    <child>
+                      <placeholder/>
+                    </child>
+                  </object>
+                </child>
+                <child type="label">
+                  <object class="GtkLabel" id="label198">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="label" translatable="yes">&lt;b&gt;File&lt;/b&gt;</property>
+                    <property name="use_markup">True</property>
+                  </object>
+                </child>
+              </object>
+              <packing>
+                <property name="right_attach">2</property>
+                <property name="top_attach">5</property>
+                <property name="bottom_attach">6</property>
+                <property name="y_options">GTK_FILL</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkLabel" id="label199">
+                <property name="can_focus">False</property>
+                <property name="label" translatable="yes">lbl_id_uffici</property>
+              </object>
+              <packing>
+                <property name="left_attach">1</property>
+                <property name="right_attach">2</property>
+                <property name="top_attach">6</property>
+                <property name="bottom_attach">7</property>
+                <property name="x_options">GTK_FILL</property>
+                <property name="y_options">GTK_FILL</property>
+              </packing>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">True</property>
+            <property name="fill">True</property>
+            <property name="position">0</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkHButtonBox" id="hbuttonbox38">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="spacing">5</property>
+            <property name="layout_style">end</property>
+            <child>
+              <object class="GtkButton" id="button195">
+                <property name="label">gtk-cancel</property>
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="receives_default">True</property>
+                <property name="use_stock">True</property>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">False</property>
+                <property name="position">0</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkButton" id="button196">
+                <property name="label">gtk-save</property>
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="can_default">True</property>
+                <property name="has_default">True</property>
+                <property name="receives_default">True</property>
+                <property name="use_stock">True</property>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">False</property>
+                <property name="position">1</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkButton" id="button197">
+                <property name="label" translatable="yes">Salva e _chiudi</property>
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="receives_default">True</property>
+                <property name="use_underline">True</property>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">False</property>
+                <property name="position">2</property>
+              </packing>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">True</property>
+            <property name="position">1</property>
+          </packing>
+        </child>
+      </object>
+    </child>
+  </object>
   <object class="GtkWindow" id="w_ufficio_collegamento">
     <property name="can_focus">False</property>
     <property name="title" translatable="yes">Collegamento - Organigramma</property>
index 7d9c688fb8fdf900811efabe3867a3edb8f87e6c..4bc88a9cd12a2a19b1ddf7bd67b102b37fa06573 100644 (file)
@@ -58,3 +58,19 @@ CREATE TABLE struttura_allegati
        status character varying(1) DEFAULT ''::character varying,
        CONSTRAINT struttura_allegati_pkey PRIMARY KEY (id)
 );
+
+CREATE TABLE ufficio_allegati
+(
+       id integer NOT NULL,
+       id_uffici integer,
+       titolo character varying(255) DEFAULT ''::character varying,
+       descrizione character varying DEFAULT ''::bpchar,
+       data_documento date,
+       note text DEFAULT ''::text,
+       percorso character varying(255) DEFAULT ''::character varying,
+       contenuto integer,
+       data_file timestamp without time zone,
+       dimensione_file bigint,
+       status character varying(1) DEFAULT ''::character varying,
+       CONSTRAINT ufficio_allegati_pkey PRIMARY KEY (id)
+);
index baafaad629cad6c12613be8f43928d0e158b8946..5f69c90bc64ce2be409ca846f60996b74f6b2d1a 100644 (file)
@@ -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:50:35
+-- Started on 2013-06-04 10:53:26
 
 SET statement_timeout = 0;
 SET client_encoding = 'UTF8';
@@ -14,7 +14,7 @@ SET client_min_messages = warning;
 SET escape_string_warning = off;
 
 --
--- TOC entry 558 (class 2612 OID 16386)
+-- TOC entry 563 (class 2612 OID 16386)
 -- Name: plpgsql; Type: PROCEDURAL LANGUAGE; Schema: -; Owner: -
 --
 
@@ -349,6 +349,26 @@ CREATE TABLE uffici (
 );
 
 
+--
+-- TOC entry 166 (class 1259 OID 626440)
+-- Name: ufficio_allegati; Type: TABLE; Schema: public; Owner: -
+--
+
+CREATE TABLE ufficio_allegati (
+    id integer NOT NULL,
+    id_uffici integer,
+    titolo character varying(255) DEFAULT ''::character varying,
+    descrizione character varying DEFAULT ''::bpchar,
+    data_documento date,
+    note text DEFAULT ''::text,
+    percorso character varying(255) DEFAULT ''::character varying,
+    contenuto integer,
+    data_file timestamp without time zone,
+    dimensione_file bigint,
+    status character varying(1) DEFAULT ''::character varying
+);
+
+
 --
 -- TOC entry 163 (class 1259 OID 626355)
 -- Name: ufficio_collegamenti; Type: TABLE; Schema: public; Owner: -
@@ -438,7 +458,7 @@ CREATE TABLE ufficio_stanze (
 
 
 --
--- TOC entry 2001 (class 2606 OID 59289)
+-- TOC entry 2011 (class 2606 OID 59289)
 -- Name: nodi_pkey; Type: CONSTRAINT; Schema: public; Owner: -
 --
 
@@ -447,7 +467,7 @@ ALTER TABLE ONLY nodi
 
 
 --
--- TOC entry 2041 (class 2606 OID 61360)
+-- TOC entry 2051 (class 2606 OID 61360)
 -- Name: persona_incarichi_pkey; Type: CONSTRAINT; Schema: public; Owner: -
 --
 
@@ -456,7 +476,7 @@ ALTER TABLE ONLY persona_incarichi
 
 
 --
--- TOC entry 2031 (class 2606 OID 61305)
+-- TOC entry 2041 (class 2606 OID 61305)
 -- Name: persona_nodi_pkey; Type: CONSTRAINT; Schema: public; Owner: -
 --
 
@@ -465,7 +485,7 @@ ALTER TABLE ONLY persona_nodi
 
 
 --
--- TOC entry 2033 (class 2606 OID 61321)
+-- TOC entry 2043 (class 2606 OID 61321)
 -- Name: persona_nodo_recapiti_pkey; Type: CONSTRAINT; Schema: public; Owner: -
 --
 
@@ -474,7 +494,7 @@ ALTER TABLE ONLY persona_nodo_recapiti
 
 
 --
--- TOC entry 2027 (class 2606 OID 61279)
+-- TOC entry 2037 (class 2606 OID 61279)
 -- Name: persona_recapiti_pkey; Type: CONSTRAINT; Schema: public; Owner: -
 --
 
@@ -483,7 +503,7 @@ ALTER TABLE ONLY persona_recapiti
 
 
 --
--- TOC entry 2025 (class 2606 OID 61252)
+-- TOC entry 2035 (class 2606 OID 61252)
 -- Name: persona_uffici_pkey; Type: CONSTRAINT; Schema: public; Owner: -
 --
 
@@ -492,7 +512,7 @@ ALTER TABLE ONLY persona_uffici
 
 
 --
--- TOC entry 2029 (class 2606 OID 61294)
+-- TOC entry 2039 (class 2606 OID 61294)
 -- Name: persona_ufficio_recapiti_pkey; Type: CONSTRAINT; Schema: public; Owner: -
 --
 
@@ -501,7 +521,7 @@ ALTER TABLE ONLY persona_ufficio_recapiti
 
 
 --
--- TOC entry 2021 (class 2606 OID 61235)
+-- TOC entry 2031 (class 2606 OID 61235)
 -- Name: persone_pkey; Type: CONSTRAINT; Schema: public; Owner: -
 --
 
@@ -510,7 +530,7 @@ ALTER TABLE ONLY persone
 
 
 --
--- TOC entry 2035 (class 2606 OID 61328)
+-- TOC entry 2045 (class 2606 OID 61328)
 -- Name: posizioni_economiche_pkey; Type: CONSTRAINT; Schema: public; Owner: -
 --
 
@@ -519,7 +539,7 @@ ALTER TABLE ONLY posizioni_economiche
 
 
 --
--- TOC entry 2039 (class 2606 OID 61342)
+-- TOC entry 2049 (class 2606 OID 61342)
 -- Name: profili_professionali_pkey; Type: CONSTRAINT; Schema: public; Owner: -
 --
 
@@ -528,7 +548,7 @@ ALTER TABLE ONLY profili_professionali
 
 
 --
--- TOC entry 2045 (class 2606 OID 618188)
+-- TOC entry 2055 (class 2606 OID 618188)
 -- Name: ruoli_pkey; Type: CONSTRAINT; Schema: public; Owner: -
 --
 
@@ -537,7 +557,7 @@ ALTER TABLE ONLY ruoli
 
 
 --
--- TOC entry 2051 (class 2606 OID 626437)
+-- TOC entry 2061 (class 2606 OID 626437)
 -- Name: struttura_allegati_pkey; Type: CONSTRAINT; Schema: public; Owner: -
 --
 
@@ -546,7 +566,7 @@ ALTER TABLE ONLY struttura_allegati
 
 
 --
--- TOC entry 2049 (class 2606 OID 626378)
+-- TOC entry 2059 (class 2606 OID 626378)
 -- Name: struttura_collegamenti_pkey; Type: CONSTRAINT; Schema: public; Owner: -
 --
 
@@ -555,7 +575,7 @@ ALTER TABLE ONLY struttura_collegamenti
 
 
 --
--- TOC entry 2011 (class 2606 OID 59356)
+-- TOC entry 2021 (class 2606 OID 59356)
 -- Name: struttura_indirizzi_pkey; Type: CONSTRAINT; Schema: public; Owner: -
 --
 
@@ -564,7 +584,7 @@ ALTER TABLE ONLY struttura_indirizzi
 
 
 --
--- TOC entry 2009 (class 2606 OID 59339)
+-- TOC entry 2019 (class 2606 OID 59339)
 -- Name: strutture_pkey; Type: CONSTRAINT; Schema: public; Owner: -
 --
 
@@ -573,7 +593,7 @@ ALTER TABLE ONLY strutture
 
 
 --
--- TOC entry 2003 (class 2606 OID 59296)
+-- TOC entry 2013 (class 2606 OID 59296)
 -- Name: tipi_nodo_pkey; Type: CONSTRAINT; Schema: public; Owner: -
 --
 
@@ -582,7 +602,7 @@ ALTER TABLE ONLY tipi_nodo
 
 
 --
--- TOC entry 2037 (class 2606 OID 61335)
+-- TOC entry 2047 (class 2606 OID 61335)
 -- Name: tipi_prestazione_pkey; Type: CONSTRAINT; Schema: public; Owner: -
 --
 
@@ -591,7 +611,7 @@ ALTER TABLE ONLY tipi_prestazione
 
 
 --
--- TOC entry 2023 (class 2606 OID 61242)
+-- TOC entry 2033 (class 2606 OID 61242)
 -- Name: tipi_rapporto_lavoro_pkey; Type: CONSTRAINT; Schema: public; Owner: -
 --
 
@@ -600,7 +620,7 @@ ALTER TABLE ONLY tipi_rapporto_lavoro
 
 
 --
--- TOC entry 2005 (class 2606 OID 59303)
+-- TOC entry 2015 (class 2606 OID 59303)
 -- Name: tipi_recapito_pkey; Type: CONSTRAINT; Schema: public; Owner: -
 --
 
@@ -609,7 +629,7 @@ ALTER TABLE ONLY tipi_recapito
 
 
 --
--- TOC entry 2019 (class 2606 OID 61226)
+-- TOC entry 2029 (class 2606 OID 61226)
 -- Name: titoli_pkey; Type: CONSTRAINT; Schema: public; Owner: -
 --
 
@@ -618,7 +638,7 @@ ALTER TABLE ONLY titoli
 
 
 --
--- TOC entry 2007 (class 2606 OID 59321)
+-- TOC entry 2017 (class 2606 OID 59321)
 -- Name: uffici_pkey; Type: CONSTRAINT; Schema: public; Owner: -
 --
 
@@ -627,7 +647,16 @@ ALTER TABLE ONLY uffici
 
 
 --
--- TOC entry 2047 (class 2606 OID 626366)
+-- TOC entry 2063 (class 2606 OID 626452)
+-- Name: ufficio_allegati_pkey; Type: CONSTRAINT; Schema: public; Owner: -
+--
+
+ALTER TABLE ONLY ufficio_allegati
+    ADD CONSTRAINT ufficio_allegati_pkey PRIMARY KEY (id);
+
+
+--
+-- TOC entry 2057 (class 2606 OID 626366)
 -- Name: ufficio_collegamenti_pkey; Type: CONSTRAINT; Schema: public; Owner: -
 --
 
@@ -636,7 +665,7 @@ ALTER TABLE ONLY ufficio_collegamenti
 
 
 --
--- TOC entry 2013 (class 2606 OID 59366)
+-- TOC entry 2023 (class 2606 OID 59366)
 -- Name: ufficio_nodi_pkey; Type: CONSTRAINT; Schema: public; Owner: -
 --
 
@@ -645,7 +674,7 @@ ALTER TABLE ONLY ufficio_nodi
 
 
 --
--- TOC entry 2015 (class 2606 OID 59408)
+-- TOC entry 2025 (class 2606 OID 59408)
 -- Name: ufficio_orari_pkey; Type: CONSTRAINT; Schema: public; Owner: -
 --
 
@@ -654,7 +683,7 @@ ALTER TABLE ONLY ufficio_orari
 
 
 --
--- TOC entry 2017 (class 2606 OID 59419)
+-- TOC entry 2027 (class 2606 OID 59419)
 -- Name: ufficio_recapiti_pkey; Type: CONSTRAINT; Schema: public; Owner: -
 --
 
@@ -663,7 +692,7 @@ ALTER TABLE ONLY ufficio_recapiti
 
 
 --
--- TOC entry 2043 (class 2606 OID 61430)
+-- TOC entry 2053 (class 2606 OID 61430)
 -- Name: ufficio_stanze_pkey; Type: CONSTRAINT; Schema: public; Owner: -
 --
 
@@ -671,7 +700,7 @@ ALTER TABLE ONLY ufficio_stanze
     ADD CONSTRAINT ufficio_stanze_pkey PRIMARY KEY (id);
 
 
--- Completed on 2013-06-04 10:50:35
+-- Completed on 2013-06-04 10:53:26
 
 --
 -- PostgreSQL database dump complete
index 998fbdb074952c51567f24a546f9565e2690d1d8..98856b2c25920cdc9ef196e9d6d5d720b7adf822 100644 (file)
@@ -53,6 +53,7 @@ liborganigramma_la_SOURCES = \
                 ../src/titolo.c \
                 ../src/uffici.c \
                 ../src/ufficio.c \
+                ../src/ufficioallegato.c \
                 ../src/ufficiocollegamento.c \
                 ../src/ufficionodo.c \
                 ../src/ufficioorario.c \
@@ -95,6 +96,7 @@ liborganigramma_include_HEADERS = \
                 ../src/titolo.h \
                 ../src/uffici.h \
                 ../src/ufficio.h \
+                ../src/ufficioallegato.h \
                 ../src/ufficiocollegamento.h \
                 ../src/ufficionodo.h \
                 ../src/ufficioorario.h \
index a8962e15f41e6373fc2943c869a18cd2344ac79d..95a1226cc7ce292994c665cdbede9659bc1e3710 100644 (file)
@@ -98,6 +98,8 @@ organigramma_SOURCES = \
                 uffici.h \
                 ufficio.c \
                 ufficio.h \
+                ufficioallegato.c \
+                ufficioallegato.h \
                 ufficiocollegamento.c \
                 ufficiocollegamento.h \
                 ufficionodo.c \
index 5abc96e66fd28f0141b5ea05bb36d8d1b9fda012..0e93c6a689b171896d7903f5273d41cca62a3165 100644 (file)
@@ -34,6 +34,7 @@
 #include "ufficiorecapito.h"
 #include "ufficiostanza.h"
 #include "ufficiocollegamento.h"
+#include "ufficioallegato.h"
 
 static void organigramma_ufficio_class_init (OrganigrammaUfficioClass *klass);
 static void organigramma_ufficio_init (OrganigrammaUfficio *ufficio);
@@ -47,12 +48,14 @@ static void organigramma_ufficio_carica_recapiti (OrganigrammaUfficio *ufficio);
 static void organigramma_ufficio_carica_orari (OrganigrammaUfficio *ufficio);
 static void organigramma_ufficio_carica_persone (OrganigrammaUfficio *ufficio);
 static void organigramma_ufficio_carica_collegamenti (OrganigrammaUfficio *ufficio);
+static void organigramma_ufficio_carica_allegati (OrganigrammaUfficio *ufficio);
 
 static void organigramma_ufficio_nodo_modifica (OrganigrammaUfficio *ufficio);
 static void organigramma_ufficio_stanza_modifica (OrganigrammaUfficio *ufficio);
 static void organigramma_ufficio_recapito_modifica (OrganigrammaUfficio *ufficio);
 static void organigramma_ufficio_orario_modifica (OrganigrammaUfficio *ufficio);
 static void organigramma_ufficio_collegamento_modifica (OrganigrammaUfficio *ufficio);
+static void organigramma_ufficio_allegato_modifica (OrganigrammaUfficio *ufficio);
 
 static gboolean organigramma_ufficio_conferma_chiusura (OrganigrammaUfficio *ufficio);
 
@@ -70,23 +73,30 @@ static void organigramma_ufficio_on_stanza_aggiornato (gpointer instance, gpoint
 static void organigramma_ufficio_on_recapito_aggiornato (gpointer instance, gpointer user_data);
 static void organigramma_ufficio_on_orario_aggiornato (gpointer instance, gpointer user_data);
 static void organigramma_ufficio_on_collegamento_aggiornato (gpointer instance, gpointer user_data);
+static void organigramma_ufficio_on_allegato_aggiornato (gpointer instance, gpointer user_data);
 
-static void organigramma_ufficio_on_organigramma_ufficio_selezionato (gpointer instance, guint id, gpointer user_data);
+static void organigramma_ufficio_on_ufficio_selezionato (gpointer instance, guint id, gpointer user_data);
+static void organigramma_ufficio_on_struttura_selezionato (gpointer instance, guint id, gpointer user_data);
 
-static void organigramma_ufficio_on_organigramma_ufficio_pulisci (GtkEntry *entry,
+static void organigramma_ufficio_on_ufficio_pulisci (GtkEntry *entry,
                           GtkEntryIconPosition icon_pos,
                           GdkEvent *event,
                           gpointer user_data);
-static void organigramma_ufficio_on_btn_organigramma_ufficio_clicked (GtkButton *button,
+static void organigramma_ufficio_on_btn_ufficio_clicked (GtkButton *button,
+                      gpointer user_data);
+static void organigramma_ufficio_on_btn_struttura_clicked (GtkButton *button,
                       gpointer user_data);
 
+static void organigramma_ufficio_on_ufficio_selezionato (gpointer instance, guint id, gpointer user_data);
 static void organigramma_ufficio_on_struttura_selezionato (gpointer instance, guint id, gpointer user_data);
 
-static gboolean organigramma_ufficio_on_w_organigramma_ufficio_delete_event (GtkWidget *widget,
+static gboolean organigramma_ufficio_on_w_ufficio_delete_event (GtkWidget *widget,
                                GdkEvent *event,
                                gpointer user_data);
 
-static void organigramma_ufficio_on_btn_organigramma_struttura_clicked (GtkButton *button,
+static void organigramma_ufficio_on_btn_ufficio_clicked (GtkButton *button,
+                      gpointer user_data);
+static void organigramma_ufficio_on_btn_struttura_clicked (GtkButton *button,
                       gpointer user_data);
 
 static void organigramma_ufficio_on_btn_nodo_nuovo_clicked (GtkButton *button,
@@ -146,6 +156,19 @@ static void organigramma_ufficio_on_trv_collegamenti_row_activated (GtkTreeView
                                              GtkTreeViewColumn *column,
                                              gpointer user_data);
 
+static void organigramma_ufficio_on_btn_allegato_nuovo_clicked (GtkButton *button,
+                                    gpointer user_data);
+static void organigramma_ufficio_on_btn_allegato_modifica_clicked (GtkButton *button,
+                                    gpointer user_data);
+static void organigramma_ufficio_on_btn_allegato_elimina_clicked (GtkButton *button,
+                                    gpointer user_data);
+static void organigramma_ufficio_on_btn_allegato_apri_clicked (GtkButton *button,
+                                    gpointer user_data);
+static void organigramma_ufficio_on_trv_allegati_row_activated (GtkTreeView *tree_view,
+                                             GtkTreePath *tree_path,
+                                             GtkTreeViewColumn *column,
+                                             gpointer user_data);
+
 static void organigramma_ufficio_on_btn_annulla_clicked (GtkButton *button,
                                     gpointer user_data);
 static void organigramma_ufficio_on_btn_salva_clicked (GtkButton *button,
@@ -163,7 +186,8 @@ enum
        LSTORE_RECAPITI,
        LSTORE_ORARI,
        LSTORE_PERSONE,
-       LSTORE_COLLEGAMENTI
+       LSTORE_COLLEGAMENTI,
+       LSTORE_ALLEGATI
 };
 
 enum
@@ -211,6 +235,15 @@ enum
        COLLEGAMENTI_COL_INDIRIZZO
 };
 
+enum
+{
+       ALLEGATI_COL_ID,
+       ALLEGATI_COL_TITOLO,
+       ALLEGATI_COL_DESCRIZIONE,
+       ALLEGATI_COL_PERCORSO,
+       ALLEGATI_COL_CONTENUTO
+};
+
 typedef struct _OrganigrammaUfficioPrivate OrganigrammaUfficioPrivate;
 struct _OrganigrammaUfficioPrivate
        {
@@ -228,6 +261,7 @@ struct _OrganigrammaUfficioPrivate
                GtkTreeSelection *sel_orari;
                GtkTreeSelection *sel_persone;
                GtkTreeSelection *sel_collegamenti;
+               GtkTreeSelection *sel_allegati;
 
                gint id;
        };
@@ -293,6 +327,7 @@ OrganigrammaUfficio
                                                       "|lstore_ufficio_orari"
                                                       "|lstore_ufficio_persone"
                                                       "|lstore_ufficio_collegamenti"
+                                                      "|lstore_ufficio_allegati"
                                                       "|w_ufficio",
                                                       "|",
                                                       -1),
@@ -317,6 +352,7 @@ OrganigrammaUfficio
                                                      "lstore_ufficio_orari",
                                                      "lstore_ufficio_persone",
                                                      "lstore_ufficio_collegamenti",
+                                                     "lstore_ufficio_allegati",
                                                      NULL);
 
        priv->sel_nodi = gtk_tree_view_get_selection (GTK_TREE_VIEW (gtk_builder_get_object (priv->commons->gtkbuilder, "treeview7")));
@@ -325,17 +361,18 @@ OrganigrammaUfficio
        priv->sel_orari = gtk_tree_view_get_selection (GTK_TREE_VIEW (gtk_builder_get_object (priv->commons->gtkbuilder, "treeview10")));
        priv->sel_persone = gtk_tree_view_get_selection (GTK_TREE_VIEW (gtk_builder_get_object (priv->commons->gtkbuilder, "treeview24")));
        priv->sel_collegamenti = gtk_tree_view_get_selection (GTK_TREE_VIEW (gtk_builder_get_object (priv->commons->gtkbuilder, "treeview25")));
+       priv->sel_allegati = gtk_tree_view_get_selection (GTK_TREE_VIEW (gtk_builder_get_object (priv->commons->gtkbuilder, "treeview28")));
 
        g_signal_connect (priv->w,
-                         "delete-event", G_CALLBACK (organigramma_ufficio_on_w_organigramma_ufficio_delete_event), (gpointer)a);
+                         "delete-event", G_CALLBACK (organigramma_ufficio_on_w_ufficio_delete_event), (gpointer)a);
 
        g_signal_connect (gtk_builder_get_object (priv->commons->gtkbuilder, "entry48"),
-                         "icon-press", G_CALLBACK (organigramma_ufficio_on_organigramma_ufficio_pulisci), (gpointer)a);
+                         "icon-press", G_CALLBACK (organigramma_ufficio_on_ufficio_pulisci), (gpointer)a);
        g_signal_connect (gtk_builder_get_object (priv->commons->gtkbuilder, "button164"),
-                         "clicked", G_CALLBACK (organigramma_ufficio_on_btn_organigramma_ufficio_clicked), (gpointer)a);
+                         "clicked", G_CALLBACK (organigramma_ufficio_on_btn_ufficio_clicked), (gpointer)a);
 
        g_signal_connect (gtk_builder_get_object (priv->commons->gtkbuilder, "button31"),
-                         "clicked", G_CALLBACK (organigramma_ufficio_on_btn_organigramma_struttura_clicked), (gpointer)a);
+                         "clicked", G_CALLBACK (organigramma_ufficio_on_btn_struttura_clicked), (gpointer)a);
 
        g_signal_connect (G_OBJECT (gtk_builder_get_object (priv->commons->gtkbuilder, "button28")),
                          "clicked", G_CALLBACK (organigramma_ufficio_on_btn_nodo_nuovo_clicked), (gpointer)a);
@@ -384,6 +421,17 @@ OrganigrammaUfficio
        g_signal_connect (G_OBJECT (gtk_builder_get_object (priv->commons->gtkbuilder, "treeview25")),
                          "row-activated", G_CALLBACK (organigramma_ufficio_on_trv_collegamenti_row_activated), (gpointer)a);
 
+       g_signal_connect (G_OBJECT (gtk_builder_get_object (priv->commons->gtkbuilder, "button198")),
+                         "clicked", G_CALLBACK (organigramma_ufficio_on_btn_allegato_nuovo_clicked), (gpointer)a);
+       g_signal_connect (G_OBJECT (gtk_builder_get_object (priv->commons->gtkbuilder, "button199")),
+                         "clicked", G_CALLBACK (organigramma_ufficio_on_btn_allegato_modifica_clicked), (gpointer)a);
+       g_signal_connect (G_OBJECT (gtk_builder_get_object (priv->commons->gtkbuilder, "button200")),
+                         "clicked", G_CALLBACK (organigramma_ufficio_on_btn_allegato_elimina_clicked), (gpointer)a);
+       g_signal_connect (G_OBJECT (gtk_builder_get_object (priv->commons->gtkbuilder, "button201")),
+                         "clicked", G_CALLBACK (organigramma_ufficio_on_btn_allegato_apri_clicked), (gpointer)a);
+       g_signal_connect (G_OBJECT (gtk_builder_get_object (priv->commons->gtkbuilder, "treeview28")),
+                         "row-activated", G_CALLBACK (organigramma_ufficio_on_trv_allegati_row_activated), (gpointer)a);
+
        g_signal_connect (gtk_builder_get_object (priv->commons->gtkbuilder, "button29"),
                          "clicked", G_CALLBACK (organigramma_ufficio_on_btn_annulla_clicked), (gpointer)a);
        g_signal_connect (gtk_builder_get_object (priv->commons->gtkbuilder, "button30"),
@@ -401,7 +449,7 @@ OrganigrammaUfficio
 
                        gtk_form_set_as_origin (priv->form);
 
-                       gtk_form_set_sensitive_by_name (priv->form, FALSE, "hbox2", "hbox19", "hbox4", "hbox9", "hbox21", "hbox22", NULL);
+                       gtk_form_set_sensitive_by_name (priv->form, FALSE, "hbox2", "hbox19", "hbox4", "hbox9", "hbox21", "hbox22", "hbox24", NULL);
                }
        else
                {
@@ -424,6 +472,8 @@ OrganigrammaUfficio
                        gtk_widget_set_sensitive (GTK_WIDGET (gtk_builder_get_object (commons->gtkbuilder, "button151")), FALSE);
                        gtk_widget_set_sensitive (GTK_WIDGET (gtk_builder_get_object (commons->gtkbuilder, "button177")), FALSE);
                        gtk_widget_set_sensitive (GTK_WIDGET (gtk_builder_get_object (commons->gtkbuilder, "button179")), FALSE);
+                       gtk_widget_set_sensitive (GTK_WIDGET (gtk_builder_get_object (commons->gtkbuilder, "button198")), FALSE);
+                       gtk_widget_set_sensitive (GTK_WIDGET (gtk_builder_get_object (commons->gtkbuilder, "button200")), FALSE);
                }
 
        return a;
@@ -476,6 +526,7 @@ organigramma_ufficio_carica (OrganigrammaUfficio *ufficio)
                        organigramma_ufficio_carica_orari (ufficio);
                        organigramma_ufficio_carica_persone (ufficio);
                        organigramma_ufficio_carica_collegamenti (ufficio);
+                       organigramma_ufficio_carica_allegati (ufficio);
                }
 }
 
@@ -511,7 +562,7 @@ organigramma_ufficio_salva (OrganigrammaUfficio *ufficio, gboolean chiudi)
                        if (priv->id == 0)
                                {
                                        priv->id = strtol (gtk_label_get_text (GTK_LABEL (priv->objects[LBL_ID])), NULL, 10);
-                                       gtk_form_set_sensitive_by_name (priv->form, TRUE, "hbox2", "hbox19", "hbox4", "hbox9", "hbox21", NULL);
+                                       gtk_form_set_sensitive_by_name (priv->form, TRUE, "hbox2", "hbox19", "hbox4", "hbox9", "hbox21", "hbox24", NULL);
                                }
 
                        solipa_message_dialog (priv->w,
@@ -782,6 +833,50 @@ organigramma_ufficio_carica_collegamenti (OrganigrammaUfficio *ufficio)
                }
 }
 
+static void
+organigramma_ufficio_carica_allegati (OrganigrammaUfficio *organigramma_ufficio)
+{
+       GtkListStore *lstore;
+       GtkTreeIter iter;
+       GdaDataModel *dm;
+
+       gchar *sql;
+
+       gint rows;
+       gint row;
+
+       OrganigrammaUfficioPrivate *priv = ORGANIGRAMMA_UFFICIO_GET_PRIVATE (organigramma_ufficio);
+
+       lstore = GTK_LIST_STORE (priv->objects[LSTORE_ALLEGATI]);
+       gtk_list_store_clear (lstore);
+
+       sql = g_strdup_printf ("SELECT aa.id, aa.titolo, aa.descrizione,"
+                         " aa.percorso, aa.contenuto"
+                         " FROM ufficio_allegati AS aa"
+                         " WHERE aa.status <> 'E' AND aa.id_uffici = %d"
+                         " ORDER BY aa.titolo, aa.descrizione",
+                         priv->id);
+       dm = gdaex_query (priv->commons->gdaex, sql);
+       g_free (sql);
+       if (dm != NULL)
+               {
+                       rows = gda_data_model_get_n_rows (dm);
+                       for (row = 0; row < rows; row++)
+                               {
+                                       gtk_list_store_append (lstore, &iter);
+                                       gtk_list_store_set (lstore, &iter,
+                                                           ALLEGATI_COL_ID, gdaex_data_model_get_field_value_integer_at (dm, row, "id"),
+                                                           ALLEGATI_COL_TITOLO, gdaex_data_model_get_field_value_stringify_at (dm, row, "titolo"),
+                                                           ALLEGATI_COL_DESCRIZIONE, gdaex_data_model_get_field_value_stringify_at (dm, row, "descrizione"),
+                                                           ALLEGATI_COL_PERCORSO, gdaex_data_model_get_field_value_stringify_at (dm, row, "percorso"),
+                                                           ALLEGATI_COL_CONTENUTO, gdaex_data_model_get_field_value_integer_at (dm, row, "contenuto"),
+                                                           -1);
+                               }
+
+                       g_object_unref (dm);
+               }
+}
+
 static void
 organigramma_ufficio_nodo_modifica (OrganigrammaUfficio *ufficio)
 {
@@ -952,6 +1047,40 @@ organigramma_ufficio_collegamento_modifica (OrganigrammaUfficio *organigramma_uf
                }
 }
 
+static void
+organigramma_ufficio_allegato_modifica (OrganigrammaUfficio *organigramma_ufficio)
+{
+       GtkTreeIter iter;
+       guint id;
+
+       OrganigrammaUfficioPrivate *priv = ORGANIGRAMMA_UFFICIO_GET_PRIVATE (organigramma_ufficio);
+
+       if (gtk_tree_selection_get_selected (priv->sel_allegati, NULL, &iter))
+               {
+                       GtkWidget *w;
+
+                       gtk_tree_model_get (GTK_TREE_MODEL (priv->objects[LSTORE_ALLEGATI]), &iter,
+                                           ALLEGATI_COL_ID, &id,
+                                           -1);
+
+                       OrganigrammaUfficioAllegato *c = organigramma_ufficio_allegato_new (priv->commons, id, 0);
+
+                       g_signal_connect (G_OBJECT (c), "aggiornato",
+                                         G_CALLBACK (organigramma_ufficio_on_allegato_aggiornato), (gpointer)organigramma_ufficio);
+
+                       w = organigramma_ufficio_allegato_get_widget (c);
+                       gtk_window_set_transient_for (GTK_WINDOW (w), GTK_WINDOW (priv->w));
+                       gtk_widget_show (w);
+               }
+       else
+               {
+                       solipa_message_dialog (priv->w,
+                                              GTK_MESSAGE_WARNING,
+                                              GTK_BUTTONS_OK,
+                                              "Occorre prima selezionare un allegato.");
+               }
+}
+
 static void
 organigramma_ufficio_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec)
 {
@@ -1004,7 +1133,7 @@ organigramma_ufficio_conferma_chiusura (OrganigrammaUfficio *ufficio)
 
 /* CALLBACK */
 static void
-organigramma_ufficio_on_organigramma_ufficio_selezionato (gpointer instance, guint id, gpointer user_data)
+organigramma_ufficio_on_ufficio_selezionato (gpointer instance, guint id, gpointer user_data)
 {
        OrganigrammaUfficio *f = (OrganigrammaUfficio *)user_data;
        OrganigrammaUfficioPrivate *priv = ORGANIGRAMMA_UFFICIO_GET_PRIVATE (f);
@@ -1013,7 +1142,7 @@ organigramma_ufficio_on_organigramma_ufficio_selezionato (gpointer instance, gui
 }
 
 static void
-organigramma_ufficio_on_organigramma_ufficio_pulisci (GtkEntry *entry,
+organigramma_ufficio_on_ufficio_pulisci (GtkEntry *entry,
                           GtkEntryIconPosition icon_pos,
                           GdkEvent *event,
                           gpointer user_data)
@@ -1076,8 +1205,14 @@ organigramma_ufficio_on_collegamento_aggiornato (gpointer instance, gpointer use
        organigramma_ufficio_carica_collegamenti ((OrganigrammaUfficio *)user_data);
 }
 
+static void
+organigramma_ufficio_on_allegato_aggiornato (gpointer instance, gpointer user_data)
+{
+       organigramma_ufficio_carica_allegati ((OrganigrammaUfficio *)user_data);
+}
+
 static gboolean
-organigramma_ufficio_on_w_organigramma_ufficio_delete_event (GtkWidget *widget,
+organigramma_ufficio_on_w_ufficio_delete_event (GtkWidget *widget,
                                GdkEvent *event,
                                gpointer user_data)
 {
@@ -1085,7 +1220,7 @@ organigramma_ufficio_on_w_organigramma_ufficio_delete_event (GtkWidget *widget,
 }
 
 static void
-organigramma_ufficio_on_btn_organigramma_ufficio_clicked (GtkButton *button,
+organigramma_ufficio_on_btn_ufficio_clicked (GtkButton *button,
                       gpointer user_data)
 {
        GtkWidget *w;
@@ -1097,7 +1232,7 @@ organigramma_ufficio_on_btn_organigramma_ufficio_clicked (GtkButton *button,
        OrganigrammaUffici *c = organigramma_uffici_new (priv->commons, TRUE);
 
        g_signal_connect (G_OBJECT (c), "selezionato",
-                         G_CALLBACK (organigramma_ufficio_on_organigramma_ufficio_selezionato), user_data);
+                         G_CALLBACK (organigramma_ufficio_on_ufficio_selezionato), user_data);
 
        w = organigramma_uffici_get_widget (c);
        gtk_window_set_transient_for (GTK_WINDOW (w), GTK_WINDOW (priv->w));
@@ -1105,7 +1240,7 @@ organigramma_ufficio_on_btn_organigramma_ufficio_clicked (GtkButton *button,
 }
 
 static void
-organigramma_ufficio_on_btn_organigramma_struttura_clicked (GtkButton *button,
+organigramma_ufficio_on_btn_struttura_clicked (GtkButton *button,
                       gpointer user_data)
 {
        GtkWidget *w;
@@ -1541,6 +1676,159 @@ organigramma_ufficio_on_trv_collegamenti_row_activated (GtkTreeView *tree_view,
        organigramma_ufficio_collegamento_modifica ((OrganigrammaUfficio *)user_data);
 }
 
+static void
+organigramma_ufficio_on_btn_allegato_nuovo_clicked (GtkButton *button,
+                                    gpointer user_data)
+{
+       GtkWidget *w;
+
+       OrganigrammaUfficio *organigramma_ufficio = (OrganigrammaUfficio *)user_data;
+       OrganigrammaUfficioPrivate *priv = ORGANIGRAMMA_UFFICIO_GET_PRIVATE (organigramma_ufficio);
+
+       OrganigrammaUfficioAllegato *c = organigramma_ufficio_allegato_new (priv->commons, 0, priv->id);
+
+       g_signal_connect (G_OBJECT (c), "aggiornato",
+                         G_CALLBACK (organigramma_ufficio_on_allegato_aggiornato), user_data);
+
+       w = organigramma_ufficio_allegato_get_widget (c);
+       gtk_window_set_transient_for (GTK_WINDOW (w), GTK_WINDOW (priv->w));
+       gtk_widget_show (w);
+
+}
+
+static void
+organigramma_ufficio_on_btn_allegato_modifica_clicked (GtkButton *button,
+                                    gpointer user_data)
+{
+       organigramma_ufficio_allegato_modifica ((OrganigrammaUfficio *)user_data);
+}
+
+static void
+organigramma_ufficio_on_btn_allegato_elimina_clicked (GtkButton *button,
+                                    gpointer user_data)
+{
+       GtkTreeIter iter;
+       guint id;
+
+       OrganigrammaUfficio *organigramma_ufficio = (OrganigrammaUfficio *)user_data;
+       OrganigrammaUfficioPrivate *priv = ORGANIGRAMMA_UFFICIO_GET_PRIVATE (organigramma_ufficio);
+
+       if (gtk_tree_selection_get_selected (priv->sel_allegati, NULL, &iter))
+               {
+                       if (solipa_message_dialog (priv->w,
+                                                  GTK_MESSAGE_QUESTION,
+                                                  GTK_BUTTONS_YES_NO,
+                                                  "Sicuro di voler eliminare l'allegato selezionato?") == GTK_RESPONSE_YES)
+                               {
+                                       gtk_tree_model_get (GTK_TREE_MODEL (priv->objects[LSTORE_ALLEGATI]), &iter,
+                                                           ALLEGATI_COL_ID, &id,
+                                                           -1);
+
+                                       gdaex_execute (priv->commons->gdaex,
+                                                      g_strdup_printf ("UPDATE ufficio_allegati SET status = 'E' WHERE id = %d", id));
+
+                                       organigramma_ufficio_carica_allegati (organigramma_ufficio);
+                               }
+               }
+       else
+               {
+                       solipa_message_dialog (priv->w,
+                                              GTK_MESSAGE_WARNING,
+                                              GTK_BUTTONS_OK,
+                                              "Occorre prima selezionare un allegato.");
+               }
+}
+
+static void
+organigramma_ufficio_on_btn_allegato_apri_clicked (GtkButton *button,
+                                        gpointer user_data)
+{
+       GtkTreeIter iter;
+       const gchar *percorso;
+       guint id;
+
+       gchar *sql;
+
+       OrganigrammaUfficio *organigramma_ufficio = (OrganigrammaUfficio *)user_data;
+       OrganigrammaUfficioPrivate *priv = ORGANIGRAMMA_UFFICIO_GET_PRIVATE (organigramma_ufficio);
+
+       if (gtk_tree_selection_get_selected (priv->sel_allegati, NULL, &iter))
+               {
+                       gtk_tree_model_get (GTK_TREE_MODEL (priv->objects[LSTORE_ALLEGATI]), &iter,
+                                           ALLEGATI_COL_ID, &id,
+                                           -1);
+
+                       /* devo utilizzare le funzioni native di postgres
+                        * perché quelle di libgda non sembrano funzionare sotto windows */
+                       GError *error;
+                       GdaDataModel *dm;
+                       gchar *filename_orig;
+                       gchar *filename_tmp;
+                       gint fin;
+
+                       sql = g_strdup_printf ("SELECT percorso, contenuto FROM ufficio_allegati WHERE id = %d", id);
+                       dm = gdaex_query (priv->commons->gdaex, sql);
+                       g_free (sql);
+                       if (dm != NULL && gda_data_model_get_n_rows (dm) > 0)
+                               {
+                                       filename_orig = g_path_get_basename (gdaex_data_model_get_field_value_stringify_at (dm, 0, "percorso"));
+
+                                       error = NULL;
+                                       fin = g_file_open_tmp (g_strdup_printf ("organigramma-XXXXXX-%s",
+                                                                               filename_orig),
+                                                              &filename_tmp, &error);
+                                       if (fin < 1 || error != NULL)
+                                               {
+                                                       solipa_message_dialog (priv->w,
+                                                                              GTK_MESSAGE_WARNING,
+                                                                              GTK_BUTTONS_OK,
+                                                                              g_strdup_printf ("Errore nell'apertura dell'allegato: %s",
+                                                                                               error != NULL && error->message != NULL ? error->message : "nessun dettaglio"));
+                                                       close (fin);
+                                                       return;
+                                               }
+                                       close (fin);
+
+#ifdef G_OS_WIN32
+                       filename_tmp = g_strjoinv ("\\", g_strsplit (filename_tmp, "/", -1));
+#endif
+
+                                       PQexec (priv->commons->pgcon, "BEGIN");
+
+                                       lo_export (priv->commons->pgcon,
+                                                  gdaex_data_model_get_field_value_integer_at (dm, 0, "contenuto"),
+                                                  filename_tmp);
+
+                                       PQexec (priv->commons->pgcon, "COMMIT");
+
+                                       solipa_allegato_apri_allegato (GTK_WINDOW (priv->w), filename_tmp);
+                               }
+                       else
+                               {
+                                       solipa_message_dialog (priv->w,
+                                                              GTK_MESSAGE_WARNING,
+                                                              GTK_BUTTONS_OK,
+                                                              "Occorre prima selezionare un allegato.");
+                               }
+               }
+       else
+               {
+                       solipa_message_dialog (priv->w,
+                                              GTK_MESSAGE_WARNING,
+                                              GTK_BUTTONS_OK,
+                                              "Occorre prima selezionare un allegato.");
+               }
+}
+
+static void
+organigramma_ufficio_on_trv_allegati_row_activated (GtkTreeView *tree_view,
+                                         GtkTreePath *tree_path,
+                                         GtkTreeViewColumn *column,
+                                         gpointer user_data)
+{
+       organigramma_ufficio_allegato_modifica ((OrganigrammaUfficio *)user_data);
+}
+
 static void
 organigramma_ufficio_on_btn_annulla_clicked (GtkButton *button,
                         gpointer user_data)
diff --git a/src/ufficioallegato.c b/src/ufficioallegato.c
new file mode 100644 (file)
index 0000000..c47bcf2
--- /dev/null
@@ -0,0 +1,446 @@
+/* 
+ * Copyright (C) 2013 Andrea Zagli <azagli@libero.it>
+ *
+ * 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
+ *
+ */
+
+#include <libpq-fe.h>
+
+#include <libsolipa/libsolipa.h>
+#include <libautoz/autoz.h>
+#include <libgtkform/form.h>
+
+#include "ufficioallegato.h"
+
+static void organigramma_ufficio_allegato_class_init (OrganigrammaUfficioAllegatoClass *klass);
+static void organigramma_ufficio_allegato_init (OrganigrammaUfficioAllegato *organigramma_ufficio_allegato);
+
+static void organigramma_ufficio_allegato_carica (OrganigrammaUfficioAllegato *organigramma_ufficio_allegato);
+static void organigramma_ufficio_allegato_salva (OrganigrammaUfficioAllegato *organigramma_ufficio_allegato, gboolean chiudi);
+
+static gboolean organigramma_ufficio_allegato_conferma_chiusura (OrganigrammaUfficioAllegato *organigramma_ufficio_allegato);
+
+static void organigramma_ufficio_allegato_set_property (GObject *object,
+                                     guint property_id,
+                                     const GValue *value,
+                                     GParamSpec *pspec);
+static void organigramma_ufficio_allegato_get_property (GObject *object,
+                                     guint property_id,
+                                     GValue *value,
+                                     GParamSpec *pspec);
+
+static gboolean organigramma_ufficio_allegato_on_w_organigramma_ufficio_allegato_delete_event (GtkWidget *widget,
+                               GdkEvent *event,
+                               gpointer user_data);
+
+static void organigramma_ufficio_allegato_on_btn_annulla_clicked (GtkButton *button,
+                                    gpointer user_data);
+static void organigramma_ufficio_allegato_on_btn_salva_clicked (GtkButton *button,
+                                  gpointer user_data);
+static void organigramma_ufficio_allegato_on_btn_salvachiudi_clicked (GtkButton *button,
+                                  gpointer user_data);
+
+#define ORGANIGRAMMA_UFFICIO_ALLEGATO_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), TYPE_ORGANIGRAMMA_UFFICIO_ALLEGATO, OrganigrammaUfficioAllegatoPrivate))
+
+enum
+{
+       LBL_ID,
+       LBL_ID_UFFICI
+};
+
+typedef struct _OrganigrammaUfficioAllegatoPrivate OrganigrammaUfficioAllegatoPrivate;
+struct _OrganigrammaUfficioAllegatoPrivate
+       {
+               OrganigrammaCommons *commons;
+
+               GtkForm *form;
+
+               GtkWidget *w;
+               SolipaAllegato *sallegato;
+
+               GObject **objects;
+
+               gint id;
+       };
+
+G_DEFINE_TYPE (OrganigrammaUfficioAllegato, organigramma_ufficio_allegato, G_TYPE_OBJECT)
+
+static void
+organigramma_ufficio_allegato_class_init (OrganigrammaUfficioAllegatoClass *klass)
+{
+       GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+       g_type_class_add_private (object_class, sizeof (OrganigrammaUfficioAllegatoPrivate));
+
+       object_class->set_property = organigramma_ufficio_allegato_set_property;
+       object_class->get_property = organigramma_ufficio_allegato_get_property;
+
+       /**
+        * OrganigrammaUfficioAllegato::aggiornato:
+        * @organigramma_ufficio_allegato:
+        *
+        */
+       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
+organigramma_ufficio_allegato_init (OrganigrammaUfficioAllegato *organigramma_ufficio_allegato)
+{
+       OrganigrammaUfficioAllegatoPrivate *priv = ORGANIGRAMMA_UFFICIO_ALLEGATO_GET_PRIVATE (organigramma_ufficio_allegato);
+}
+
+/**
+ * organigramma_ufficio_allegato_new:
+ * @commons:
+ * @id:
+ * @id_strutture:
+ *
+ * Returns: the newly created #OrganigrammaUfficioAllegato object.
+ */
+OrganigrammaUfficioAllegato
+*organigramma_ufficio_allegato_new (OrganigrammaCommons *commons, guint id, guint id_strutture)
+{
+       GError *error;
+       AutozIResource *ires1;
+
+       OrganigrammaUfficioAllegato *a = ORGANIGRAMMA_UFFICIO_ALLEGATO (g_object_new (organigramma_ufficio_allegato_get_type (), NULL));
+
+       OrganigrammaUfficioAllegatoPrivate *priv = ORGANIGRAMMA_UFFICIO_ALLEGATO_GET_PRIVATE (a);
+
+       priv->commons = commons;
+
+       error = NULL;
+       gtk_builder_add_objects_from_file (priv->commons->gtkbuilder, priv->commons->guifile,
+                                          g_strsplit ("w_ufficio_allegato", "|", -1),
+                                          &error);
+       if (error != NULL)
+               {
+                       g_warning ("Errore: %s.", error->message);
+                       return NULL;
+               }
+
+       priv->form = gtk_form_new ();
+       g_object_set (priv->form, "gdaex", priv->commons->gdaex, NULL);
+       gtk_form_load_from_file (priv->form, g_build_filename (priv->commons->formdir, "ufficio_allegato.form", NULL), priv->commons->gtkbuilder);
+
+       g_object_set (priv->form, "gdaex", priv->commons->gdaex, NULL);
+
+       priv->w = GTK_WIDGET (gtk_builder_get_object (priv->commons->gtkbuilder, "w_ufficio_allegato"));
+
+       priv->objects = gtk_form_get_objects_by_name (priv->form,
+                                                     "label193",
+                                                     "label199",
+                                                     NULL);
+
+       priv->sallegato = solipa_allegato_new (commons->solipa);
+       if (priv->sallegato != NULL)
+               {
+                       solipa_allegato_add_to_gtkform (priv->sallegato, priv->form,
+                                                       "percorso", "data_file", "dimensione_file");
+                       solipa_allegato_con_salva_in_db (priv->sallegato, FALSE);
+                       gtk_container_add (GTK_CONTAINER (gtk_builder_get_object (priv->commons->gtkbuilder, "alignment2")),
+                                          solipa_allegato_get_widget (priv->sallegato));
+               }
+
+       g_signal_connect (priv->w,
+                         "delete-event", G_CALLBACK (organigramma_ufficio_allegato_on_w_organigramma_ufficio_allegato_delete_event), (gpointer)a);
+
+       g_signal_connect (gtk_builder_get_object (priv->commons->gtkbuilder, "button195"),
+                         "clicked", G_CALLBACK (organigramma_ufficio_allegato_on_btn_annulla_clicked), (gpointer)a);
+       g_signal_connect (gtk_builder_get_object (priv->commons->gtkbuilder, "button196"),
+                         "clicked", G_CALLBACK (organigramma_ufficio_allegato_on_btn_salva_clicked), (gpointer)a);
+       g_signal_connect (gtk_builder_get_object (priv->commons->gtkbuilder, "button197"),
+                         "clicked", G_CALLBACK (organigramma_ufficio_allegato_on_btn_salvachiudi_clicked), (gpointer)a);
+
+       gtk_form_clear (priv->form);
+
+       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_UFFICI]), g_strdup_printf ("%d", id_strutture));
+
+                       if (priv->sallegato != NULL)
+                               {
+                                       solipa_allegato_set_salva_in_db (priv->sallegato, TRUE);
+                               }
+
+                       gtk_form_set_as_origin (priv->form);
+               }
+       else
+               {
+                       gtk_label_set_text (GTK_LABEL (priv->objects[LBL_ID]), g_strdup_printf ("%d", priv->id));
+                       organigramma_ufficio_allegato_carica (a);
+               }
+
+       ires1 = autoz_get_resource_from_id (priv->commons->autoz, "organigramma_rw");
+       if (!autoz_is_allowed (priv->commons->autoz, priv->commons->role_utente, ires1, FALSE))
+               {
+                       gtk_widget_set_sensitive (GTK_WIDGET (gtk_builder_get_object (commons->gtkbuilder, "button196")), FALSE);
+                       gtk_widget_set_sensitive (GTK_WIDGET (gtk_builder_get_object (commons->gtkbuilder, "button197")), FALSE);
+               }
+
+       return a;
+}
+
+/**
+ * organigramma_ufficio_allegato_get_widget:
+ * @organigramma_ufficio_allegato:
+ *
+ */
+GtkWidget
+*organigramma_ufficio_allegato_get_widget (OrganigrammaUfficioAllegato *organigramma_ufficio_allegato)
+{
+       OrganigrammaUfficioAllegatoPrivate *priv = ORGANIGRAMMA_UFFICIO_ALLEGATO_GET_PRIVATE (organigramma_ufficio_allegato);
+
+       return priv->w;
+}
+
+/* PRIVATE */
+static void
+organigramma_ufficio_allegato_carica (OrganigrammaUfficioAllegato *organigramma_ufficio_allegato)
+{
+       OrganigrammaUfficioAllegatoPrivate *priv = ORGANIGRAMMA_UFFICIO_ALLEGATO_GET_PRIVATE (organigramma_ufficio_allegato);
+
+       if (gtk_form_fill_from_table (priv->form))
+               {
+                       solipa_allegato_set_salva_in_db (priv->sallegato, TRUE);
+               }
+}
+
+static void
+organigramma_ufficio_allegato_salva (OrganigrammaUfficioAllegato *organigramma_ufficio_allegato, gboolean chiudi)
+{
+       gchar *sql;
+       GtkWidget *dialog;
+
+       OrganigrammaUfficioAllegatoClass *klass = ORGANIGRAMMA_UFFICIO_ALLEGATO_GET_CLASS (organigramma_ufficio_allegato);
+
+       OrganigrammaUfficioAllegatoPrivate *priv = ORGANIGRAMMA_UFFICIO_ALLEGATO_GET_PRIVATE (organigramma_ufficio_allegato);
+
+       if (!gtk_form_check (priv->form, (priv->id != 0), 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_free (sql);
+
+                       g_signal_emit (organigramma_ufficio_allegato, klass->aggiornato_signal_id, 0);
+
+                       gtk_form_set_as_origin (priv->form);
+
+                       if (priv->id == 0)
+                               {
+                                       priv->id = strtol (gtk_label_get_text (GTK_LABEL (priv->objects[LBL_ID])), NULL, 10);
+                               }
+
+                       /* salvo l'organigramma_ufficio_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 ufficio_allegati "
+                                                              " SET contenuto = %d,"
+                                                              " 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_allegato_carica (organigramma_ufficio_allegato);
+                               }
+                       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,
+                                              "Salvataggio eseguito con successo.");
+
+                       if (chiudi)
+                               {
+                                       gtk_widget_destroy (priv->w);
+                                       g_object_unref (organigramma_ufficio_allegato);
+                               }
+               }
+       else
+               {
+                       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.");
+               }
+}
+
+static void
+organigramma_ufficio_allegato_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec)
+{
+       OrganigrammaUfficioAllegato *organigramma_ufficio_allegato = ORGANIGRAMMA_UFFICIO_ALLEGATO (object);
+       OrganigrammaUfficioAllegatoPrivate *priv = ORGANIGRAMMA_UFFICIO_ALLEGATO_GET_PRIVATE (organigramma_ufficio_allegato);
+
+       switch (property_id)
+               {
+                       default:
+                               G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+                               break;
+               }
+}
+
+static void
+organigramma_ufficio_allegato_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec)
+{
+       OrganigrammaUfficioAllegato *organigramma_ufficio_allegato = ORGANIGRAMMA_UFFICIO_ALLEGATO (object);
+       OrganigrammaUfficioAllegatoPrivate *priv = ORGANIGRAMMA_UFFICIO_ALLEGATO_GET_PRIVATE (organigramma_ufficio_allegato);
+
+       switch (property_id)
+               {
+                       default:
+                               G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+                               break;
+               }
+}
+
+static gboolean
+organigramma_ufficio_allegato_conferma_chiusura (OrganigrammaUfficioAllegato *organigramma_ufficio_allegato)
+{
+       gboolean ret;
+
+       OrganigrammaUfficioAllegatoPrivate *priv = ORGANIGRAMMA_UFFICIO_ALLEGATO_GET_PRIVATE (organigramma_ufficio_allegato);
+
+       ret = TRUE;
+       if (gtk_form_is_changed (priv->form))
+               {
+                       if (solipa_message_dialog (priv->w,
+                                                  GTK_MESSAGE_QUESTION,
+                                                  GTK_BUTTONS_YES_NO,
+                                                  "Sicuro di voler chiudere senza salvare?") == GTK_RESPONSE_NO)
+                               {
+                                       ret = FALSE;
+                               }
+               }
+
+       return ret;
+}
+
+/* CALLBACK */
+static gboolean
+organigramma_ufficio_allegato_on_w_organigramma_ufficio_allegato_delete_event (GtkWidget *widget,
+                               GdkEvent *event,
+                               gpointer user_data)
+{
+       return !organigramma_ufficio_allegato_conferma_chiusura ((OrganigrammaUfficioAllegato *)user_data);
+}
+
+static void
+organigramma_ufficio_allegato_on_btn_annulla_clicked (GtkButton *button,
+                                 gpointer user_data)
+{
+       OrganigrammaUfficioAllegato *allegato = (OrganigrammaUfficioAllegato *)user_data;
+
+       OrganigrammaUfficioAllegatoPrivate *priv = ORGANIGRAMMA_UFFICIO_ALLEGATO_GET_PRIVATE (allegato);
+
+       if (organigramma_ufficio_allegato_conferma_chiusura (allegato)) gtk_widget_destroy (priv->w);
+}
+
+static void
+organigramma_ufficio_allegato_on_btn_salva_clicked (GtkButton *button,
+                      gpointer user_data)
+{
+       organigramma_ufficio_allegato_salva ((OrganigrammaUfficioAllegato *)user_data, FALSE);
+}
+
+static void
+organigramma_ufficio_allegato_on_btn_salvachiudi_clicked (GtkButton *button,
+                      gpointer user_data)
+{
+       organigramma_ufficio_allegato_salva ((OrganigrammaUfficioAllegato *)user_data, TRUE);
+}
diff --git a/src/ufficioallegato.h b/src/ufficioallegato.h
new file mode 100644 (file)
index 0000000..45385fa
--- /dev/null
@@ -0,0 +1,65 @@
+/* 
+ * Copyright (C) 2013 Andrea Zagli <azagli@libero.it>
+ *
+ * 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 __ORGANIGRAMMA_UFFICIO_ALLEGATO_H__
+#define __ORGANIGRAMMA_UFFICIO_ALLEGATO_H__
+
+#include <glib.h>
+#include <glib-object.h>
+
+#include <gtk/gtk.h>
+
+#include "commons.h"
+
+G_BEGIN_DECLS
+
+
+#define TYPE_ORGANIGRAMMA_UFFICIO_ALLEGATO                 (organigramma_ufficio_allegato_get_type ())
+#define ORGANIGRAMMA_UFFICIO_ALLEGATO(obj)                 (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_ORGANIGRAMMA_UFFICIO_ALLEGATO, OrganigrammaUfficioAllegato))
+#define ORGANIGRAMMA_UFFICIO_ALLEGATO_CLASS(klass)         (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_ORGANIGRAMMA_UFFICIO_ALLEGATO, OrganigrammaUfficioAllegatoClass))
+#define IS_ORGANIGRAMMA_UFFICIO_ALLEGATO(obj)              (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_ORGANIGRAMMA_UFFICIO_ALLEGATO))
+#define IS_ORGANIGRAMMA_UFFICIO_ALLEGATO_CLASS(klass)      (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_ORGANIGRAMMA_UFFICIO_ALLEGATO))
+#define ORGANIGRAMMA_UFFICIO_ALLEGATO_GET_CLASS(obj)       (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_ORGANIGRAMMA_UFFICIO_ALLEGATO, OrganigrammaUfficioAllegatoClass))
+
+
+typedef struct _OrganigrammaUfficioAllegato OrganigrammaUfficioAllegato;
+typedef struct _OrganigrammaUfficioAllegatoClass OrganigrammaUfficioAllegatoClass;
+
+struct _OrganigrammaUfficioAllegato
+       {
+               GObject parent;
+       };
+
+struct _OrganigrammaUfficioAllegatoClass
+       {
+               GObjectClass parent_class;
+
+               guint aggiornato_signal_id;
+       };
+
+GType organigramma_ufficio_allegato_get_type (void) G_GNUC_CONST;
+
+OrganigrammaUfficioAllegato *organigramma_ufficio_allegato_new (OrganigrammaCommons *commons, guint id, guint id_uffici);
+
+GtkWidget *organigramma_ufficio_allegato_get_widget (OrganigrammaUfficioAllegato *organigramma_ufficio_allegato);
+
+
+G_END_DECLS
+
+#endif /* __ORGANIGRAMMA_UFFICIO_ALLEGATO_H__ */