Implementazione ricerca atti nel registro dell'albo.
atto.form \
attoallegato.form \
tipoatto.form \
- trovaatti.form
+ trovaatti.form \
+ trovaregistro.form
EXTRA_DIST = $(form_DATA)
--- /dev/null
+<?xml version="1.0"?>
+<gtkform>
+
+ <widget type="entry" name="entry12" label="label23">
+ <field type="text" name="numero">
+ </field>
+ </widget>
+
+ <widget type="decoder" name="gtkformdecoder3" label="label18">
+ <decoder>
+ <sql>
+ SELECT descrizione FROM tipi_atto WHERE id = ##key0::gint
+ </sql>
+ </decoder>
+ <field type="integer" name="id_tipi_atto">
+ </field>
+ </widget>
+
+ <widget type="entry" name="entry15" label="label26">
+ <field type="text" name="oggetto">
+ </field>
+ </widget>
+
+ <widget type="decoder" name="gtkformdecoder5" label="label19">
+ <decoder>
+ <sql>
+ SELECT nome FROM uffici WHERE id = ##key0::gint
+ </sql>
+ </decoder>
+ <field type="integer" name="id_uffici">
+ </field>
+ </widget>
+
+ <widget type="entry" name="entry13" label="label24">
+ <field type="datetime" name="ricezione_da_data">
+ <datetime-type>date</datetime-type>
+ <display-format>%d/%m/%Y</display-format>
+ </field>
+ </widget>
+
+ <widget type="entry" name="entry14" label="label25">
+ <field type="datetime" name="ricezione_a_data">
+ <datetime-type>date</datetime-type>
+ <display-format>%d/%m/%Y</display-format>
+ </field>
+ </widget>
+
+ <widget type="entry" name="entry10" label="label20">
+ <field type="datetime" name="pubblicazione_da_data">
+ <datetime-type>date</datetime-type>
+ <display-format>%d/%m/%Y</display-format>
+ </field>
+ </widget>
+
+ <widget type="entry" name="entry11" label="label22">
+ <field type="datetime" name="pubblicazione_a_data">
+ <datetime-type>date</datetime-type>
+ <display-format>%d/%m/%Y</display-format>
+ </field>
+ </widget>
+
+</gtkform>
<property name="position">2</property>
</packing>
</child>
+ <child>
+ <object class="GtkButton" id="button19">
+ <property name="label" translatable="yes">_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">3</property>
+ </packing>
+ </child>
<child>
<object class="GtkButton" id="button8">
<property name="label" translatable="yes">_Esporta</property>
<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>
<child>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
- <property name="position">6</property>
+ <property name="position">7</property>
</packing>
</child>
</object>
gpointer user_data);
static void atti_on_btn_elimina_clicked (GtkButton *button,
gpointer user_data);
+static void atti_on_btn_pubblica_clicked (GtkButton *button,
+ gpointer user_data);
static void atti_on_trv_atti_row_activated (GtkTreeView *tree_view,
GtkTreePath *tree_path,
GtkTreeViewColumn *column,
"clicked", G_CALLBACK (atti_on_btn_modifica_clicked), (gpointer)a);
g_signal_connect (gtk_builder_get_object (priv->commons->gtkbuilder, "button6"),
"clicked", G_CALLBACK (atti_on_btn_elimina_clicked), (gpointer)a);
+ g_signal_connect (gtk_builder_get_object (priv->commons->gtkbuilder, "button19"),
+ "clicked", G_CALLBACK (atti_on_btn_pubblica_clicked), (gpointer)a);
g_signal_connect (gtk_builder_get_object (priv->commons->gtkbuilder, "treeview1"),
"row-activated", G_CALLBACK (atti_on_trv_atti_row_activated), (gpointer)a);
guint gival;
GDateTime *gdtval;
+ gboolean pubblicazione;
+
gchar *sql_where;
gchar *sql;
gtk_list_store_clear (priv->lstore_atti);
+ pubblicazione = FALSE;
+
sql_where = g_strdup ("");
if (priv->parametri_ricerca != NULL)
gval = (GValue *)g_hash_table_lookup (priv->parametri_ricerca, "pubblicazione_da_data");
if (gval != NULL && (gdtval = (GDateTime *)g_value_get_pointer (gval)) != NULL)
{
+ pubblicazione = TRUE;
sql_where = g_strconcat (sql_where, " AND a.pubblicazione_inizio_data >= '",
g_date_time_format (gdtval, "%F"),
"'",
gval = (GValue *)g_hash_table_lookup (priv->parametri_ricerca, "pubblicazione_a_data");
if (gval != NULL && (gdtval = (GDateTime *)g_value_get_pointer (gval)) != NULL)
{
+ pubblicazione = TRUE;
sql_where = g_strconcat (sql_where, " AND a.pubblicazione_fine_data <= '",
g_date_time_format (gdtval, "%F"),
"'",
}
}
+ if (!pubblicazione)
+ {
+ sql_where = g_strconcat (sql_where, " AND r.id IS NULL",
+ NULL);
+ }
+
sql = g_strdup_printf ("SELECT a.id, a.numero,"
" ta.descrizione AS tipo_atto,"
" a.oggetto,"
" a.pubblicazione_fine_data"
" FROM atti AS a"
" INNER JOIN tipi_atto AS ta ON a.id_tipi_atto = ta.id"
+ " LEFT JOIN registro AS r ON a.id = r.id_atti"
" WHERE a.status <> 'E'"
"%s"
" ORDER BY a.id",
}
}
+static void
+atti_on_btn_pubblica_clicked (GtkButton *button,
+ gpointer user_data)
+{
+ GtkTreeIter iter;
+ gint id;
+
+ gchar *sql;
+ GdaDataModel *dm;
+ guint newid;
+
+ Atti *atti = (Atti *)user_data;
+ AttiPrivate *priv = ATTI_GET_PRIVATE (atti);
+
+ if (gtk_tree_selection_get_selected (priv->selection, NULL, &iter))
+ {
+ 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);
+ 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, 1, CURRENT_TIMESTAMP)",
+ newid, id);
+ gdaex_execute (priv->commons->gdaex, sql);
+ g_free (sql);
+
+ atti_carica (atti);
+ }
+ }
+ 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
atti_on_trv_atti_row_activated (GtkTreeView *tree_view,
GtkTreePath *tree_path,
COL_ID_ATTI
};
+gchar *azioni[] = {"Pubblicato", "Respinto", "Depubblicato", "Ratificato"};
+
typedef struct _RegistroPrivate RegistroPrivate;
struct _RegistroPrivate
{
" INNER JOIN tipi_atto AS ta ON a.id_tipi_atto = ta.id"
" WHERE a.status <> 'E'"
"%s"
- " ORDER BY a.id",
+ " ORDER BY r.id DESC",
sql_where);
dm = gdaex_query (priv->commons->gdaex, sql);
g_free (sql_where);
COL_DATA_RICEZIONE, solipa_gdatetime_format (gdaex_data_model_get_field_value_gdatetime_at (dm, row, "ricezione_data"), "%d/%m/%Y"),
COL_DATA_INIZIO_PUBBLICAZIONE, solipa_gdatetime_format (gdaex_data_model_get_field_value_gdatetime_at (dm, row, "pubblicazione_inizio_data"), "%d/%m/%Y"),
COL_DATA_FINE_PUBBLICAZIONE, solipa_gdatetime_format (gdaex_data_model_get_field_value_gdatetime_at (dm, row, "pubblicazione_fine_data"), "%d/%m/%Y"),
- COL_AZIONE, gdaex_data_model_get_field_value_stringify_at (dm, row, "azione"),
+ COL_AZIONE, azioni[gdaex_data_model_get_field_value_integer_at (dm, row, "azione") - 1],
COL_AZIONE_DATA, solipa_gdatetime_format (gdaex_data_model_get_field_value_gdatetime_at (dm, row, "azione_data"), "%d/%m/%Y %H.%M.%S"),
-1);
GtkWidget *w;
gtk_tree_model_get (GTK_TREE_MODEL (priv->lstore_registro), &iter,
- COL_ID, &id,
+ COL_ID_ATTI, &id,
-1);
Atto *c = atto_new (priv->commons, id);
g_signal_connect (priv->w,
"key-release-event", G_CALLBACK (trova_registro_on_key_release_event), (gpointer)a);
- g_object_set (gtk_builder_get_object (priv->commons->gtkbuilder, "gtkformdecoder15"),
+ g_object_set (gtk_builder_get_object (priv->commons->gtkbuilder, "gtkformdecoder5"),
"gdaex", priv->commons->organigramma_commons->gdaex,
NULL);
- g_signal_connect (gtk_builder_get_object (priv->commons->gtkbuilder, "gtkformdecoder4"),
+ g_signal_connect (gtk_builder_get_object (priv->commons->gtkbuilder, "gtkformdecoder3"),
"btn-browse-clicked", G_CALLBACK (trova_registro_on_btn_tipo_atto_clicked), (gpointer)a);
- g_signal_connect (gtk_builder_get_object (priv->commons->gtkbuilder, "gtkformdecoder15"),
+ g_signal_connect (gtk_builder_get_object (priv->commons->gtkbuilder, "gtkformdecoder5"),
"btn-browse-clicked", G_CALLBACK (trova_registro_on_btn_ufficio_clicked), (gpointer)a);
- g_signal_connect (gtk_builder_get_object (priv->commons->gtkbuilder, "button20"),
+ g_signal_connect (gtk_builder_get_object (priv->commons->gtkbuilder, "button11"),
"clicked", G_CALLBACK (trova_registro_on_btn_pulisci_clicked), (gpointer)a);
- g_signal_connect (gtk_builder_get_object (priv->commons->gtkbuilder, "button21"),
+ g_signal_connect (gtk_builder_get_object (priv->commons->gtkbuilder, "button12"),
"clicked", G_CALLBACK (trova_registro_on_btn_annulla_clicked), (gpointer)a);
- g_signal_connect (gtk_builder_get_object (priv->commons->gtkbuilder, "button22"),
+ g_signal_connect (gtk_builder_get_object (priv->commons->gtkbuilder, "button18"),
"clicked", G_CALLBACK (trova_registro_on_btn_ok_clicked), (gpointer)a);
gtk_form_clear (priv->form);
TrovaRegistro *a = (TrovaRegistro *)user_data;
TrovaRegistroPrivate *priv = TROVA_REGISTRO_GET_PRIVATE (a);
- gtk_form_widget_set_value_stringify (gtk_form_get_form_widget_from_name (priv->form, "gtkformdecoder4"),
+ gtk_form_widget_set_value_stringify (gtk_form_get_form_widget_from_name (priv->form, "gtkformdecoder3"),
g_strdup_printf ("%d", id));
}
TrovaRegistro *a = (TrovaRegistro *)user_data;
TrovaRegistroPrivate *priv = TROVA_REGISTRO_GET_PRIVATE (a);
- gtk_form_widget_set_value_stringify (gtk_form_get_form_widget_from_name (priv->form, "gtkformdecoder15"),
+ gtk_form_widget_set_value_stringify (gtk_form_get_form_widget_from_name (priv->form, "gtkformdecoder5"),
g_strdup_printf ("%d", id));
}
{
TrovaRegistroPrivate *priv = TROVA_REGISTRO_GET_PRIVATE ((TrovaRegistro *)user_data);
- gtk_button_clicked (GTK_BUTTON (gtk_builder_get_object (priv->commons->gtkbuilder, "button21")));
+ gtk_button_clicked (GTK_BUTTON (gtk_builder_get_object (priv->commons->gtkbuilder, "button12")));
return TRUE;
}