]> saetta.ns0.it Git - albonline/be/commitdiff
Depubblicazione dell'atto dell'albo.
authorAndrea Zagli <azagli@libero.it>
Sat, 23 Feb 2013 16:47:00 +0000 (17:47 +0100)
committerAndrea Zagli <azagli@libero.it>
Sat, 23 Feb 2013 16:47:00 +0000 (17:47 +0100)
data/messi/gui/messi.gui
src/registro.c

index 19e1555845cb294bf04a570b00357dd8599078c3..971a5353b5f7d64916a772b12c54d569ec41dca1 100644 (file)
                 <property name="position">1</property>
               </packing>
             </child>
+            <child>
+              <object class="GtkButton" id="button24">
+                <property name="label" translatable="yes">De_pubblica</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>
             <child>
               <object class="GtkButton" id="button14">
                 <property name="label" translatable="yes">_Esporta</property>
               <packing>
                 <property name="expand">False</property>
                 <property name="fill">False</property>
-                <property name="position">2</property>
+                <property name="position">3</property>
               </packing>
             </child>
             <child>
               <packing>
                 <property name="expand">False</property>
                 <property name="fill">False</property>
-                <property name="position">3</property>
+                <property name="position">4</property>
               </packing>
             </child>
             <child>
               <packing>
                 <property name="expand">False</property>
                 <property name="fill">False</property>
-                <property name="position">4</property>
+                <property name="position">5</property>
               </packing>
             </child>
             <child>
               <packing>
                 <property name="expand">False</property>
                 <property name="fill">False</property>
-                <property name="position">5</property>
+                <property name="position">6</property>
               </packing>
             </child>
           </object>
index 249befb6f1c3d201b46ef414b9418da49148a13b..5a359b3d52cabaf36f5ccc59f341f615d1bd16ab 100644 (file)
@@ -57,6 +57,8 @@ static void registro_on_btn_apri_clicked (GtkButton *button,
                       gpointer user_data);
 static void registro_on_btn_ratifica_clicked (GtkButton *button,
                                     gpointer user_data);
+static void registro_on_btn_depubblica_clicked (GtkButton *button,
+                                    gpointer user_data);
 static void registro_on_trv_registro_row_activated (GtkTreeView *tree_view,
                                              GtkTreePath *tree_path,
                                              GtkTreeViewColumn *column,
@@ -186,6 +188,8 @@ Registro
                          "clicked", G_CALLBACK (registro_on_btn_apri_clicked), (gpointer)a);
        g_signal_connect (gtk_builder_get_object (priv->commons->gtkbuilder, "button23"),
                          "clicked", G_CALLBACK (registro_on_btn_ratifica_clicked), (gpointer)a);
+       g_signal_connect (gtk_builder_get_object (priv->commons->gtkbuilder, "button24"),
+                         "clicked", G_CALLBACK (registro_on_btn_depubblica_clicked), (gpointer)a);
        g_signal_connect (gtk_builder_get_object (priv->commons->gtkbuilder, "treeview2"),
                          "row-activated", G_CALLBACK (registro_on_trv_registro_row_activated), (gpointer)a);
 
@@ -627,6 +631,91 @@ registro_on_btn_ratifica_clicked (GtkButton *button,
                }
 }
 
+static void
+registro_on_btn_depubblica_clicked (GtkButton *button,
+                        gpointer user_data)
+{
+       GtkTreeIter iter;
+       guint id;
+       guint azione;
+       gchar *pubblicazione_fine_data;
+       GDateTime *gdt_oggi;
+       GDateTime *gdt_pubblicazione_fine_data;
+
+       gchar *sql;
+       GdaDataModel *dm;
+       guint newid;
+
+       Registro *registro = (Registro *)user_data;
+       RegistroPrivate *priv = REGISTRO_GET_PRIVATE (registro);
+
+       if (gtk_tree_selection_get_selected (priv->selection, NULL, &iter))
+               {
+                       /* controllo che le date siano corrette */
+                       gtk_tree_model_get (GTK_TREE_MODEL (priv->lstore_registro), &iter,
+                                           COL_ID_ATTI, &id,
+                                           COL_AZIONE_ID, &azione,
+                                           COL_DATA_FINE_PUBBLICAZIONE, &pubblicazione_fine_data,
+                                           -1);
+
+                       gdt_oggi = g_date_time_new_now_local ();
+                       gdt_pubblicazione_fine_data = gtk_form_field_datetime_get_gdatetime_from_str (pubblicazione_fine_data, "%d/%m/%Y");
+
+                       if (azione != AZIONE_PUBBLICATO)
+                               {
+                                       solipa_message_dialog (GTK_WIDGET (gtk_builder_get_object (priv->commons->gtkbuilder, "w_main")),
+                                                              GTK_MESSAGE_WARNING,
+                                                              GTK_BUTTONS_OK,
+                                                              "L'atto selezionato non è depubblicabile.");
+                                       return;
+                               }
+                       if (g_date_time_compare (gdt_pubblicazione_fine_data, gdt_oggi) < 0)
+                               {
+                                       solipa_message_dialog (GTK_WIDGET (gtk_builder_get_object (priv->commons->gtkbuilder, "w_main")),
+                                                              GTK_MESSAGE_WARNING,
+                                                              GTK_BUTTONS_OK,
+                                                              "Non è possibile depubblicare un atto già defisso.");
+                                       return;
+                               }
+
+                       if (solipa_message_dialog (GTK_WIDGET (gtk_builder_get_object (priv->commons->gtkbuilder, "w_main")),
+                                                  GTK_MESSAGE_QUESTION,
+                                                  GTK_BUTTONS_YES_NO,
+                                                  "Sicuro di voler depubblicare l'atto selezionato?") == GTK_RESPONSE_YES)
+                               {
+                                       newid = 0;
+                                       sql = g_strdup_printf ("SELECT COALESCE(MAX(id), 0) FROM registro");
+                                       dm = gdaex_query (priv->commons->gdaex, sql);
+                                       g_free (sql);
+                                       if (dm != NULL)
+                                               {
+                                                       if (gda_data_model_get_n_rows (dm) > 0)
+                                                               {
+                                                                       newid = gdaex_data_model_get_value_integer_at (dm, 0, 0);
+                                                               }
+                                                       g_object_unref (dm);
+                                               }
+                                       newid++;
+
+                                       sql = g_strdup_printf ("INSERT INTO registro"
+                                                              " (id, id_atti, azione, azione_data)"
+                                                              " VALUES (%d, %d, %d, CURRENT_TIMESTAMP)",
+                                                              newid, id, AZIONE_DEPUBBLICATO);
+                                       gdaex_execute (priv->commons->gdaex, sql);
+                                       g_free (sql);
+
+                                       registro_carica (registro);
+                               }
+               }
+       else
+               {
+                       solipa_message_dialog (priv->selezione ? priv->widget : GTK_WIDGET (gtk_builder_get_object (priv->commons->gtkbuilder, "w_main")),
+                                              GTK_MESSAGE_WARNING,
+                                              GTK_BUTTONS_OK,
+                                              "Occorre prima selezionare un atto.");
+               }
+}
+
 static void
 registro_on_trv_registro_row_activated (GtkTreeView *tree_view,
                                              GtkTreePath *tree_path,