<?xml version="1.0"?>
-<gtkform>
-
- <table>persona_incarichi</table>
-
- <widget type="label" name="label129">
- <field type="integer" name="id">
- <is-key>t</is-key>
- <auto-increment>t</auto-increment>
- </field>
- </widget>
-
- <widget type="label" name="label130">
- <field type="integer" name="id_persone">
- </field>
- </widget>
-
- <widget type="entry" name="entry34" label="label127">
- <field type="text" name="matricola">
- </field>
- </widget>
-
- <widget type="decoder" name="gtkformdecoder2" label="label133">
- <decoder>
- <sql>
- SELECT a.nome
- FROM tipi_rapporto_lavoro AS a
- WHERE a.id = ##key0::gint
- </sql>
- </decoder>
- <field type="integer" name="id_tipi_rapporto_lavoro">
- </field>
- </widget>
-
- <widget type="decoder" name="gtkformdecoder5" label="label134">
- <decoder>
- <sql>
- SELECT a.nome
- FROM posizioni_economiche AS a
- WHERE a.id = ##key0::gint
- </sql>
- </decoder>
- <field type="integer" name="id_posizioni_economiche">
- </field>
- </widget>
-
- <widget type="decoder" name="gtkformdecoder4" label="label135">
- <decoder>
- <sql>
- SELECT a.nome
- FROM tipi_prestazione AS a
- WHERE a.id = ##key0::gint
- </sql>
- </decoder>
- <field type="integer" name="id_tipi_prestazione">
- </field>
- </widget>
-
- <widget type="decoder" name="gtkformdecoder3" label="label136">
- <decoder>
- <sql>
- SELECT a.nome
- FROM profili_professionali AS a
- WHERE a.id = ##key0::gint
- </sql>
- </decoder>
- <field type="integer" name="id_profili_professionali">
- </field>
- </widget>
-
- <widget type="entry" name="entry35" label="label131">
- <field type="datetime" name="da_data">
- <datetime-type>date</datetime-type>
- <display-format>%d/%m/%Y</display-format>
- <obligatory>t</obligatory>
- </field>
- </widget>
-
- <widget type="entry" name="entry36" label="label132">
- <field type="datetime" name="a_data">
- <datetime-type>date</datetime-type>
- <display-format>%d/%m/%Y</display-format>
- </field>
- </widget>
-
- <widget type="textview" name="textview15" label="label144">
- <field type="text" name="descrizione">
- <obligatory>t</obligatory>
- </field>
- </widget>
-
- <widget type="textview" name="textview14" label="label128">
- <field type="text" name="note" />
- </widget>
-
-</gtkform>
+<zakform>
+ <element type="zak_form_gtk_form_element_label">
+ <name>id</name>
+ <type>integer</type>
+ <is-key>TRUE</is-key>
+ <widget>label129</widget>
+ </element>
+ <element type="zak_form_gtk_form_element_label">
+ <name>id_persone</name>
+ <type>integer</type>
+ <widget>label130</widget>
+ </element>
+ <element type="zak_form_gtk_form_element_entry">
+ <name>matricola</name>
+ <type>string</type>
+ <label>label127</label>
+ <widget>entry34</widget>
+ </element>
+ <element type="zak_form_gtk_form_element_decoder">
+ <name>id_tipi_rapporto_lavoro</name>
+ <type>integer</type>
+ <label>label133</label>
+ <widget>zakgtkdecoder11</widget>
+ </element>
+ <element type="zak_form_gtk_form_element_decoder">
+ <name>id_posizioni_economiche</name>
+ <type>integer</type>
+ <label>label134</label>
+ <widget>zakgtkdecoder12</widget>
+ </element>
+ <element type="zak_form_gtk_form_element_decoder">
+ <name>id_tipi_prestazione</name>
+ <type>integer</type>
+ <label>label135</label>
+ <widget>zakgtkdecoder13</widget>
+ </element>
+ <element type="zak_form_gtk_form_element_decoder">
+ <name>id_profili_professionali</name>
+ <type>integer</type>
+ <label>label136</label>
+ <widget>zakgtkdecoder14</widget>
+ </element>
+ <element type="zak_form_gtk_form_element_entry">
+ <name>da_data</name>
+ <type>datetime</type>
+ <label>label131</label>
+ <widget>entry35</widget>
+ <format>%d/%m/%Y</format>
+ <validator type="zak_form_element_validator_notempty"/>
+ <validator type="zak_form_element_validator_date">%d/%m/%Y</validator>
+ </element>
+ <element type="zak_form_gtk_form_element_entry">
+ <name>a_data</name>
+ <type>datetime</type>
+ <label>label132</label>
+ <widget>entry36</widget>
+ <format>%d/%m/%Y</format>
+ <validator type="zak_form_element_validator_date">%d/%m/%Y</validator>
+ </element>
+ <element type="zak_form_gtk_form_element_textview">
+ <name>descrizione</name>
+ <type>string</type>
+ <label>label144</label>
+ <widget>textview15</widget>
+ <validator type="zak_form_element_validator_notempty"/>
+ </element>
+ <element type="zak_form_gtk_form_element_textview">
+ <name>note</name>
+ <type>string</type>
+ <label>label128</label>
+ <widget>textview14</widget>
+ </element>
+ <validator type="zak_form_validator_compare_date" type_comp="lt" element1="da_data" format1="%d/%m/%Y" element2="a_data" format2="%d/%m/%Y"></validator>
+</zakform>
#include <glib/gprintf.h>
#include <libzakautho/autoz.h>
-#include <libgtkform/form.h>
-#include <libgtkformui/gtkformdecoder.h>
+#include <libzakgtkdecoder/libzakgtkdecoder.h>
+#include <libzakform/libzakform.h>
+#include <libzakformgtk/libzakformgtk.h>
+#include <libzakformgdaex/libzakformgdaex.h>
+#include <libzakformgtkdecoder/libzakformgtkdecoder.h>
#include <libsolipa/utils.h>
#include "personaincarico.h"
static void organigramma_persona_incarico_on_posizione_economica_selezionato (gpointer instance, guint id, gpointer user_data);
static void organigramma_persona_incarico_on_tipo_prestazione_selezionato (gpointer instance, guint id, gpointer user_data);
static void organigramma_persona_incarico_on_profilo_professionale_selezionato (gpointer instance, guint id, gpointer user_data);
+static gchar *organigramma_persona_incarico_on_tipo_rapporto_lavoro_decode (gpointer instance, gchar *key, gpointer user_data);
+static gchar *organigramma_persona_incarico_on_posizione_economica_decode (gpointer instance, gchar *key, gpointer user_data);
+static gchar *organigramma_persona_incarico_on_tipo_prestazione_decode (gpointer instance, gchar *key, gpointer user_data);
+static gchar *organigramma_persona_incarico_on_profilo_professionale_decode (gpointer instance, gchar *key, gpointer user_data);
static void organigramma_persona_incarico_on_btn_ricerca_tipo_rapporto_lavoro_clicked (GtkButton *button,
gpointer user_data);
{
OrganigrammaCommons *commons;
- GtkForm *form;
+ ZakFormGtkForm *form;
+ ZakFormGdaexProvider *form_provider;
GtkWidget *w;
return NULL;
}
- priv->form = gtk_form_new ();
- g_object_set (G_OBJECT (priv->form), "gdaex", priv->commons->gdaex, NULL);
- gtk_form_load_from_file (priv->form, g_build_filename (priv->commons->formdir, "persona_incarico.form", NULL), priv->commons->gtkbuilder);
+ priv->form = zak_form_gtk_form_new ();
+ zak_form_gtk_form_set_gtkbuilder (priv->form, priv->commons->gtkbuilder);
+ zak_form_form_load_from_file (ZAK_FORM_FORM (priv->form), g_build_filename (priv->commons->formdir, "persona_incarico.form", NULL));
+
+ priv->form_provider = zak_form_gdaex_provider_new (priv->commons->gdaex, "persona_incarichi");
priv->w = GTK_WIDGET (gtk_builder_get_object (priv->commons->gtkbuilder, "w_persona_incarico"));
- priv->objects = gtk_form_get_objects_by_name (priv->form,
+ priv->objects = zak_form_gtk_form_get_gobjects_by_name (priv->form,
"label129",
"label130",
NULL);
g_signal_connect (priv->w,
"delete-event", G_CALLBACK (organigramma_persona_incarico_on_w_organigramma_persona_incarico_delete_event), (gpointer)a);
- g_signal_connect (gtk_builder_get_object (priv->commons->gtkbuilder, "gtkformdecoder2"),
+ g_signal_connect (gtk_builder_get_object (priv->commons->gtkbuilder, "zakgtkdecoder11"),
"btn-browse-clicked", G_CALLBACK (organigramma_persona_incarico_on_btn_ricerca_tipo_rapporto_lavoro_clicked), (gpointer)a);
- g_signal_connect (gtk_builder_get_object (priv->commons->gtkbuilder, "gtkformdecoder5"),
+ g_signal_connect (gtk_builder_get_object (priv->commons->gtkbuilder, "zakgtkdecoder12"),
"btn-browse-clicked", G_CALLBACK (organigramma_persona_incarico_on_btn_ricerca_posizione_economica_clicked), (gpointer)a);
- g_signal_connect (gtk_builder_get_object (priv->commons->gtkbuilder, "gtkformdecoder4"),
+ g_signal_connect (gtk_builder_get_object (priv->commons->gtkbuilder, "zakgtkdecoder13"),
"btn-browse-clicked", G_CALLBACK (organigramma_persona_incarico_on_btn_ricerca_tipo_prestazione_clicked), (gpointer)a);
- g_signal_connect (gtk_builder_get_object (priv->commons->gtkbuilder, "gtkformdecoder3"),
+ g_signal_connect (gtk_builder_get_object (priv->commons->gtkbuilder, "zakgtkdecoder14"),
"btn-browse-clicked", G_CALLBACK (organigramma_persona_incarico_on_btn_ricerca_profilo_professionale_clicked), (gpointer)a);
+ g_signal_connect (gtk_builder_get_object (priv->commons->gtkbuilder, "zakgtkdecoder11"),
+ "decode", G_CALLBACK (organigramma_persona_incarico_on_tipo_rapporto_lavoro_decode), (gpointer)a);
+ g_signal_connect (gtk_builder_get_object (priv->commons->gtkbuilder, "zakgtkdecoder12"),
+ "decode", G_CALLBACK (organigramma_persona_incarico_on_posizione_economica_decode), (gpointer)a);
+ g_signal_connect (gtk_builder_get_object (priv->commons->gtkbuilder, "zakgtkdecoder13"),
+ "decode", G_CALLBACK (organigramma_persona_incarico_on_tipo_prestazione_decode), (gpointer)a);
+ g_signal_connect (gtk_builder_get_object (priv->commons->gtkbuilder, "zakgtkdecoder14"),
+ "decode", G_CALLBACK (organigramma_persona_incarico_on_profilo_professionale_decode), (gpointer)a);
g_signal_connect (G_OBJECT (gtk_builder_get_object (priv->commons->gtkbuilder, "button98")),
"clicked", G_CALLBACK (organigramma_persona_incarico_on_btn_annulla_clicked), (gpointer)a);
g_signal_connect (G_OBJECT (gtk_builder_get_object (priv->commons->gtkbuilder, "button158")),
"clicked", G_CALLBACK (organigramma_persona_incarico_on_btn_salvaechiudi_clicked), (gpointer)a);
+ zak_form_form_clear (ZAK_FORM_FORM (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_PERSONE]), g_strdup_printf ("%d", id_persone));
- gtk_form_set_as_origin (priv->form);
+ zak_form_form_set_as_original (ZAK_FORM_FORM (priv->form));
}
else
{
static void
organigramma_persona_incarico_carica (OrganigrammaPersonaIncarico *organigramma_persona_incarico)
{
- gchar *sql;
- GdaDataModel *dm;
-
OrganigrammaPersonaIncaricoPrivate *priv = ORGANIGRAMMA_PERSONA_INCARICO_GET_PRIVATE (organigramma_persona_incarico);
- if (gtk_form_fill_from_table (priv->form))
+ if (zak_form_form_load (ZAK_FORM_FORM (priv->form), ZAK_FORM_IPROVIDER (priv->form_provider)))
{
}
}
static void
organigramma_persona_incarico_salva (OrganigrammaPersonaIncarico *organigramma_persona_incarico, gboolean chiudi)
{
- gchar *sql;
+ gboolean success;
OrganigrammaPersonaIncaricoClass *klass = ORGANIGRAMMA_PERSONA_INCARICO_GET_CLASS (organigramma_persona_incarico);
OrganigrammaPersonaIncaricoPrivate *priv = ORGANIGRAMMA_PERSONA_INCARICO_GET_PRIVATE (organigramma_persona_incarico);
- if (!gtk_form_check (priv->form, FALSE, NULL, TRUE, priv->w, TRUE))
+ if (!zak_form_gtk_form_is_valid (priv->form, priv->w))
{
return;
}
+ success = FALSE;
+
if (priv->id == 0)
{
- sql = gtk_form_get_sql (priv->form, GTK_FORM_SQL_INSERT);
+ guint new_id;
+
+ new_id = gdaex_get_new_id (priv->commons->gdaex,
+ "persona_incarichi",
+ "id",
+ NULL);
+
+ gtk_label_set_text (GTK_LABEL (priv->objects[LBL_ID]), g_strdup_printf ("%d", new_id));
+
+ success = zak_form_form_insert (ZAK_FORM_FORM (priv->form), ZAK_FORM_IPROVIDER (priv->form_provider));
}
else
{
- sql = gtk_form_get_sql (priv->form, GTK_FORM_SQL_UPDATE);
+ success = zak_form_form_update (ZAK_FORM_FORM (priv->form), ZAK_FORM_IPROVIDER (priv->form_provider));
}
- if (gdaex_execute (priv->commons->gdaex, sql) == 1)
+ if (success)
{
g_signal_emit (organigramma_persona_incarico, klass->aggiornato_signal_id, 0);
priv->id = strtol (gtk_label_get_text (GTK_LABEL (priv->objects[LBL_ID])), NULL, 10);
}
- gtk_form_set_as_origin (priv->form);
+ zak_form_form_set_as_original (ZAK_FORM_FORM (priv->form));
solipa_message_dialog (priv->w,
GTK_MESSAGE_INFO,
ret = TRUE;
- if (gtk_form_is_changed (priv->form))
+ if (zak_form_form_is_changed (ZAK_FORM_FORM (priv->form)))
{
if (solipa_message_dialog (priv->w,
GTK_MESSAGE_QUESTION,
OrganigrammaPersonaIncaricoPrivate *priv = ORGANIGRAMMA_PERSONA_INCARICO_GET_PRIVATE (ia);
- gtk_form_widget_set_value_stringify (gtk_form_get_form_widget_from_name (priv->form, "gtkformdecoder2"),
+ zak_gtk_decoder_set_key (ZAK_GTK_DECODER (gtk_builder_get_object (priv->commons->gtkbuilder, "zakgtkdecoder11")),
g_strdup_printf ("%d", id));
}
OrganigrammaPersonaIncaricoPrivate *priv = ORGANIGRAMMA_PERSONA_INCARICO_GET_PRIVATE (ia);
- gtk_form_widget_set_value_stringify (gtk_form_get_form_widget_from_name (priv->form, "gtkformdecoder5"),
+ zak_gtk_decoder_set_key (ZAK_GTK_DECODER (gtk_builder_get_object (priv->commons->gtkbuilder, "zakgtkdecoder12")),
g_strdup_printf ("%d", id));
}
OrganigrammaPersonaIncaricoPrivate *priv = ORGANIGRAMMA_PERSONA_INCARICO_GET_PRIVATE (ia);
- gtk_form_widget_set_value_stringify (gtk_form_get_form_widget_from_name (priv->form, "gtkformdecoder4"),
+ zak_gtk_decoder_set_key (ZAK_GTK_DECODER (gtk_builder_get_object (priv->commons->gtkbuilder, "zakgtkdecoder13")),
g_strdup_printf ("%d", id));
}
OrganigrammaPersonaIncaricoPrivate *priv = ORGANIGRAMMA_PERSONA_INCARICO_GET_PRIVATE (ia);
- gtk_form_widget_set_value_stringify (gtk_form_get_form_widget_from_name (priv->form, "gtkformdecoder3"),
+ zak_gtk_decoder_set_key (ZAK_GTK_DECODER (gtk_builder_get_object (priv->commons->gtkbuilder, "zakgtkdecoder14")),
g_strdup_printf ("%d", id));
}
+static gchar
+*organigramma_persona_incarico_on_tipo_rapporto_lavoro_decode (gpointer instance, gchar *key, gpointer user_data)
+{
+ GString *ret;
+ gchar *sql;
+ GdaDataModel *dm;
+
+ OrganigrammaPersonaIncarico *f = (OrganigrammaPersonaIncarico *)user_data;
+ OrganigrammaPersonaIncaricoPrivate *priv = ORGANIGRAMMA_PERSONA_INCARICO_GET_PRIVATE (f);
+
+ ret = g_string_new ("");
+
+ sql = g_strdup_printf ("SELECT nome"
+ " FROM tipi_rapporto_lavoro"
+ " WHERE id = %d",
+ strtol (key, NULL, 10));
+ dm = gdaex_query (priv->commons->gdaex, sql);
+ g_free (sql);
+ if (!gdaex_data_model_is_empty (dm))
+ {
+ g_string_append (ret, gdaex_data_model_get_value_stringify_at (dm, 0, 0));
+ }
+
+ return ret->str;
+}
+
+static gchar
+*organigramma_persona_incarico_on_posizione_economica_decode (gpointer instance, gchar *key, gpointer user_data)
+{
+ GString *ret;
+ gchar *sql;
+ GdaDataModel *dm;
+
+ OrganigrammaPersonaIncarico *f = (OrganigrammaPersonaIncarico *)user_data;
+ OrganigrammaPersonaIncaricoPrivate *priv = ORGANIGRAMMA_PERSONA_INCARICO_GET_PRIVATE (f);
+
+ ret = g_string_new ("");
+
+ sql = g_strdup_printf ("SELECT nome"
+ " FROM posizioni_economiche"
+ " WHERE id = %d",
+ strtol (key, NULL, 10));
+ dm = gdaex_query (priv->commons->gdaex, sql);
+ g_free (sql);
+ if (!gdaex_data_model_is_empty (dm))
+ {
+ g_string_append (ret, gdaex_data_model_get_value_stringify_at (dm, 0, 0));
+ }
+
+ return ret->str;
+}
+
+static gchar
+*organigramma_persona_incarico_on_tipo_prestazione_decode (gpointer instance, gchar *key, gpointer user_data)
+{
+ GString *ret;
+ gchar *sql;
+ GdaDataModel *dm;
+
+ OrganigrammaPersonaIncarico *f = (OrganigrammaPersonaIncarico *)user_data;
+ OrganigrammaPersonaIncaricoPrivate *priv = ORGANIGRAMMA_PERSONA_INCARICO_GET_PRIVATE (f);
+
+ ret = g_string_new ("");
+
+ sql = g_strdup_printf ("SELECT nome"
+ " FROM tipi_prestazione"
+ " WHERE id = %d",
+ strtol (key, NULL, 10));
+ dm = gdaex_query (priv->commons->gdaex, sql);
+ g_free (sql);
+ if (!gdaex_data_model_is_empty (dm))
+ {
+ g_string_append (ret, gdaex_data_model_get_value_stringify_at (dm, 0, 0));
+ }
+
+ return ret->str;
+}
+
+static gchar
+*organigramma_persona_incarico_on_profilo_professionale_decode (gpointer instance, gchar *key, gpointer user_data)
+{
+ GString *ret;
+ gchar *sql;
+ GdaDataModel *dm;
+
+ OrganigrammaPersonaIncarico *f = (OrganigrammaPersonaIncarico *)user_data;
+ OrganigrammaPersonaIncaricoPrivate *priv = ORGANIGRAMMA_PERSONA_INCARICO_GET_PRIVATE (f);
+
+ ret = g_string_new ("");
+
+ sql = g_strdup_printf ("SELECT nome"
+ " FROM profili_professionali"
+ " WHERE id = %d",
+ strtol (key, NULL, 10));
+ dm = gdaex_query (priv->commons->gdaex, sql);
+ g_free (sql);
+ if (!gdaex_data_model_is_empty (dm))
+ {
+ g_string_append (ret, gdaex_data_model_get_value_stringify_at (dm, 0, 0));
+ }
+
+ return ret->str;
+}
+
static void
organigramma_persona_incarico_on_btn_ricerca_tipo_rapporto_lavoro_clicked (GtkButton *button,
gpointer user_data)