]> saetta.ns0.it Git - albonline/be/commitdiff
Controllo della data inizio pubblicazione all'albo.
authorAndrea Zagli <azagli@libero.it>
Sat, 23 Feb 2013 15:20:00 +0000 (16:20 +0100)
committerAndrea Zagli <azagli@libero.it>
Sat, 23 Feb 2013 15:20:00 +0000 (16:20 +0100)
src/atti.c

index af5f4804bcfe2053106e2f4318f4dba7a6c6f357..3e1826762a6b0dfe100421425ffb084b0d7ec35a 100644 (file)
@@ -619,15 +619,43 @@ atti_on_btn_pubblica_clicked (GtkButton *button,
 
        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_atti), &iter,
+                                           COL_ID, &id,
+                                           -1);
+
+                       sql = g_strdup_printf ("SELECT id FROM atti"
+                                              " WHERE id = %d"
+                                              " AND pubblicazione_inizio_data >= CURRENT_DATE",
+                                              id);
+                       dm = gdaex_query (priv->commons->gdaex, sql);
+                       g_free (sql);
+                       if (dm != NULL)
+                               {
+                                       if (gda_data_model_get_n_rows (dm) < 1)
+                                               {
+                                                       solipa_message_dialog (GTK_WIDGET (gtk_builder_get_object (priv->commons->gtkbuilder, "w_main")),
+                                                                              GTK_MESSAGE_WARNING,
+                                                                              GTK_BUTTONS_OK,
+                                                                              "La data inizio pubblicazione non è valida.");
+                                                       return;
+                                               }
+                                       g_object_unref (dm);
+                               }
+                       else
+                               {
+                                       solipa_message_dialog (GTK_WIDGET (gtk_builder_get_object (priv->commons->gtkbuilder, "w_main")),
+                                                              GTK_MESSAGE_WARNING,
+                                                              GTK_BUTTONS_OK,
+                                                              "La data inizio pubblicazione non è valida.");
+                                       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 pubblicare l'atto selezionato?") == GTK_RESPONSE_YES)
                                {
-                                       gtk_tree_model_get (GTK_TREE_MODEL (priv->lstore_atti), &iter,
-                                                           COL_ID, &id,
-                                                           -1);
-
                                        newid = 0;
                                        sql = g_strdup_printf ("SELECT COALESCE(MAX(id), 0) FROM registro");
                                        dm = gdaex_query (priv->commons->gdaex, sql);