PageRenderTime 175ms CodeModel.GetById 99ms app.highlight 54ms RepoModel.GetById 3ms app.codeStats 0ms

/src/proveedores.c

#
C | 610 lines | 393 code | 114 blank | 103 comment | 40 complexity | 9399f1e0f5fae6cbed75fa1bcda9c479 MD5 | raw file
Possible License(s): GPL-2.0
  1/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4;
  2   c-indentation-style: gnu -*- */
  3/*proveedores.c
  4 *
  5 *    Copyright (C) 2004,2008 Rizoma Tecnologia Limitada <info@rizoma.cl>
  6 *
  7 *    This file is part of rizoma.
  8 *
  9 *    Rizoma is free software; you can redistribute it and/or modify
 10 *    it under the terms of the GNU General Public License as published by
 11 *    the Free Software Foundation; either version 2 of the License, or
 12 *    (at your option) any later version.
 13 *
 14 *    This program is distributed in the hope that it will be useful,
 15 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 16 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 17 *    GNU General Public License for more details.
 18 *
 19 *    You should have received a copy of the GNU General Public License
 20 *    along with this program; if not, write to the Free Software
 21 *    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 22 */
 23
 24#include<gtk/gtk.h>
 25#include<stdlib.h>
 26
 27#include<string.h>
 28
 29#include"tipos.h"
 30
 31#include"postgres-functions.h"
 32#include"printing.h"
 33
 34#include"compras.h"
 35#include"credito.h"
 36#include"errors.h"
 37#include"utils.h"
 38
 39GtkWidget *rut;
 40GtkWidget *razon;
 41GtkWidget *direccion;
 42GtkWidget *comuna;
 43GtkWidget *ciudad;
 44GtkWidget *fono;
 45GtkWidget *fax;
 46GtkWidget *web;
 47GtkWidget *contacto;
 48GtkWidget *email;
 49GtkWidget *fono_directo;
 50GtkWidget *giro;
 51
 52GtkWidget *compras_totales;
 53GtkWidget *contrib_total;
 54GtkWidget *contrib_proyect;
 55GtkWidget *inci_compras;
 56GtkWidget *stock_valorizado;
 57GtkWidget *merma_uni;
 58GtkWidget *merma_porc;
 59GtkWidget *ventas_totales;
 60GtkWidget *contrib_agreg;
 61GtkWidget *inci_ventas;
 62GtkWidget *total_pen_fact;
 63GtkWidget *indice_t;
 64
 65
 66GtkWidget *search_entry;
 67
 68GtkTreeStore *proveedores_store;
 69
 70/**
 71 * Es llamada cuando el boton "btn_prov_search" es presionado (signal click).
 72 * 
 73 * Esta funcion llama a una consulta de sql que a su vez llama a la funcion
 74 * buscar_proveedor(), esta retorna al o a los proveedores, segun por los
 75 * parametros que se ingreso. Despues este o estos los agrega a la tree_view
 76 * correspondiente.
 77 *
 78 * @param widget the widget that emited the signal
 79 * @param data the user data
 80 *
 81 */
 82
 83void
 84BuscarProveedor (GtkWidget *widget, gpointer data)
 85{
 86  GtkWidget *aux_widget;
 87  GtkTreeIter iter;
 88  GtkListStore *store;
 89  PGresult *res;
 90  gint tuples, i;
 91  gchar *str_axu;
 92  gchar *q;
 93  gchar *string;
 94
 95  aux_widget = GTK_WIDGET(gtk_builder_get_object(builder, "entry_prov_search"));
 96  string = g_strdup (gtk_entry_get_text (GTK_ENTRY (aux_widget)));
 97
 98  /*consulta de sql que llama a la funcion que retorna a el o los
 99    proveedores, dependiendo de los datos de entrada*/
100  q = g_strdup_printf ("SELECT rut, dv, nombre, giro, contacto, lapso_reposicion "
101                       "FROM buscar_proveedor('%%%s%%')",
102                       string);
103  res = EjecutarSQL (q);
104  g_free (q);
105
106  tuples = PQntuples (res);
107
108
109  aux_widget = GTK_WIDGET(gtk_builder_get_object(builder, "treeview_prov_search"));
110  store = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(aux_widget)));
111  gtk_list_store_clear (store);
112
113  /* se agrega al proveedor al tree view y sus datos*/
114  for (i = 0; i < tuples; i++)
115    {
116      str_axu = g_strconcat(PQvaluebycol (res, i, "rut"),
117                            PQvaluebycol (res, i, "dv"), NULL);
118      gtk_list_store_append (store, &iter);
119      gtk_list_store_set (store, &iter,
120                          0, str_axu,
121                          1, PQvaluebycol (res, i, "nombre"),
122                          2, PQvaluebycol (res, i, "giro"),
123                          3, PQvaluebycol (res, i, "contacto"),
124                          -1);
125      g_free (str_axu);
126    }
127}
128
129/**
130 * Es llamada por la funcion "AddProveedor()".
131 * 
132 * Esta funcion agrega al proveedor a la lista (tree view) de la busqueda de proveedores.
133 *
134 */
135
136void
137ListarProveedores (void)
138{
139  GtkWidget *treeview;
140  GtkListStore *store;
141  PGresult *res;
142  gint tuples, i;
143  GtkTreeIter iter;
144  gchar *str_axu;
145
146  res = EjecutarSQL ("SELECT rut, dv, nombre, giro, contacto FROM buscar_proveedor('%') ORDER BY nombre ASC");
147
148  tuples = PQntuples (res);
149  treeview = GTK_WIDGET(gtk_builder_get_object(builder, "treeview_prov_search"));
150  store = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(treeview)));
151
152  gtk_list_store_clear (store);
153
154  for (i = 0; i < tuples; i++)
155    {
156      str_axu = g_strconcat(PQvaluebycol(res, i, "rut"), PQvaluebycol(res, i, "dv"), NULL);
157      gtk_list_store_append (store, &iter);
158      gtk_list_store_set (store, &iter,
159                          0, str_axu,
160                          1, PQvaluebycol (res, i, "nombre"),
161                          2, PQvaluebycol (res, i, "giro"),
162                          3, PQvaluebycol (res, i, "contacto"),
163                          -1);
164      g_free (str_axu);
165    }
166}
167
168
169
170/**
171 * Es llamada cuando se selecciona un proveedor de la lista
172 * "treeview_prov_search".
173 * 
174 * Esta funcionagrega la informacion del proveedor a los
175 * respectivos campos de texto (entry)
176 *
177 * @param selection the row data
178 * @param data the user data
179 *
180 */
181
182void
183LlenarDatosProveedor (GtkTreeSelection *selection,
184                      gpointer           user_data)
185{
186  GtkWidget *widget;
187  GtkTreeView *tree_view;
188  GtkListStore *store;
189  PGresult *res;
190  GtkTreeIter iter;
191  gchar *rut_proveedor;
192  gchar *aux, *q;
193  gint largo;
194
195  tree_view = gtk_tree_selection_get_tree_view(selection);
196  store = GTK_LIST_STORE(gtk_tree_view_get_model(tree_view));
197
198  if (gtk_tree_selection_get_selected (selection, NULL, &iter) == FALSE)
199    return;
200
201  gtk_tree_model_get (GTK_TREE_MODEL (store), &iter,
202                      0, &rut_proveedor,
203                      -1);
204
205  largo = strlen (rut_proveedor);
206  aux = g_strndup (rut_proveedor, largo-1);
207
208  /* consulta de sql que llama a funcion select_proveedor, que dado el id de
209     este devuelve la informacion del mismo*/
210  
211  q = g_strdup_printf ("SELECT * FROM select_proveedor(%s)", aux);
212  res = EjecutarSQL (q);
213  g_free (q);
214  g_free (aux);
215  //g_strfreev(aux);
216
217  if ((res == NULL) || (PQntuples (res) == 0))
218    return;
219
220  widget = GTK_WIDGET(gtk_builder_get_object(builder, "entry_prov_name"));
221  gtk_entry_set_text (GTK_ENTRY (widget), PQvaluebycol (res, 0, "nombre"));
222
223  q = g_strconcat(PQvaluebycol (res, 0, "rut"), PQvaluebycol (res, 0, "dv"), NULL);  
224  widget = GTK_WIDGET(gtk_builder_get_object(builder, "lbl_prov_rut"));
225  gtk_label_set_text (GTK_LABEL (widget), formato_rut (q));
226  g_free (q);
227
228  widget = GTK_WIDGET(gtk_builder_get_object(builder, "entry_prov_addr"));
229  gtk_entry_set_text (GTK_ENTRY (widget), PQvaluebycol (res, 0, "direccion"));
230
231  widget = GTK_WIDGET(gtk_builder_get_object(builder, "entry_prov_city"));
232  gtk_entry_set_text (GTK_ENTRY (widget), PQvaluebycol (res, 0, "ciudad"));
233
234  widget = GTK_WIDGET(gtk_builder_get_object(builder, "entry_prov_comuna"));
235  gtk_entry_set_text (GTK_ENTRY (widget), PQvaluebycol (res, 0, "comuna"));
236
237  widget = GTK_WIDGET(gtk_builder_get_object(builder, "entry_prov_phone"));
238  gtk_entry_set_text (GTK_ENTRY (widget), PQvaluebycol (res, 0, "telefono"));
239
240  widget = GTK_WIDGET(gtk_builder_get_object(builder, "entry_prov_web"));
241  gtk_entry_set_text (GTK_ENTRY (widget), PQvaluebycol (res, 0, "web"));
242
243  widget = GTK_WIDGET(gtk_builder_get_object(builder, "entry_prov_contact"));
244  gtk_entry_set_text (GTK_ENTRY (widget), PQvaluebycol (res, 0, "contacto"));
245
246  widget = GTK_WIDGET(gtk_builder_get_object(builder, "entry_prov_mail"));
247  gtk_entry_set_text (GTK_ENTRY (widget), PQvaluebycol (res, 0, "email"));
248
249  widget = GTK_WIDGET(gtk_builder_get_object(builder, "entry_prov_giro"));
250  gtk_entry_set_text (GTK_ENTRY (widget), PQvaluebycol (res, 0, "giro"));
251
252  widget = GTK_WIDGET(gtk_builder_get_object(builder, "entry_lap_rep"));
253  gtk_entry_set_text (GTK_ENTRY (widget), PQvaluebycol (res, 0, "lapso_reposicion"));
254}
255
256/**
257 * Es llamada por la funcion "AddProveedor()".
258 * 
259 * Esta funcion cierra la ventana de "wnd_addprovider".
260 *
261 * @param widget the widget that emited the signal
262 * @param data the user data
263 *
264 */
265
266void
267CloseAgregarProveedorWindow (GtkWidget *widget, gpointer user_data)
268{
269  GtkWidget *window;
270
271  window = GTK_WIDGET(gtk_builder_get_object(builder, "wnd_addprovider"));
272
273  gtk_window_set_transient_for(GTK_WINDOW(window), NULL);
274
275  gtk_widget_hide(window);
276
277}
278
279/**
280 * Es llamada cuando el boton "btn_prov_ad" es presionado (signal click).
281 * 
282 * Esta funcion verifica que todos los campos de proveedor sean correctamente
283 * rellenados y luego llama a la funcion "AddProveedorToDB()" que registra al
284 * proveedor en la base de datos.
285 *
286 * @param widget the widget that emited the signal
287 * @param data the user data
288 *
289 */
290
291void
292AgregarProveedor (GtkWidget *widget, gpointer user_data)
293{
294  GtkWidget *aux_widget;
295  GtkWidget *wnd;
296  gchar *str_rut;
297  gchar *rut_c;
298  gchar *rut_ver;
299  gchar *nombre_c;
300  gchar *direccion_c;
301  gchar *ciudad_c;
302  gchar *comuna_c;
303  gchar *telefono_c;
304  gchar *email_c;
305  gchar *web_c;
306  gchar *contacto_c;
307  gchar *giro_c;
308
309  wnd = GTK_WIDGET(gtk_builder_get_object(builder, "wnd_addprovider"));
310
311  aux_widget = GTK_WIDGET(gtk_builder_get_object(builder, "entry_addprov_rut"));
312  rut_c = g_strdup (gtk_entry_get_text (GTK_ENTRY (aux_widget)));
313
314  aux_widget = GTK_WIDGET(gtk_builder_get_object(builder, "entry_addprov_dv"));
315  rut_ver = g_strdup (gtk_entry_get_text (GTK_ENTRY (aux_widget)));
316
317  aux_widget = GTK_WIDGET(gtk_builder_get_object(builder, "entry_addprov_name"));
318  nombre_c = g_strdup (gtk_entry_get_text (GTK_ENTRY (aux_widget)));
319
320  aux_widget = GTK_WIDGET(gtk_builder_get_object(builder, "entry_addprov_addr"));
321  direccion_c = g_strdup (gtk_entry_get_text (GTK_ENTRY (aux_widget)));
322
323  aux_widget = GTK_WIDGET(gtk_builder_get_object(builder, "entry_addprov_city"));
324  ciudad_c = g_strdup (gtk_entry_get_text (GTK_ENTRY (aux_widget)));
325
326  aux_widget = GTK_WIDGET(gtk_builder_get_object(builder, "entry_addprov_comuna"));
327  comuna_c = g_strdup (gtk_entry_get_text (GTK_ENTRY (aux_widget)));
328
329  aux_widget = GTK_WIDGET(gtk_builder_get_object(builder, "entry_addprov_phone"));
330  telefono_c = g_strdup (gtk_entry_get_text (GTK_ENTRY (aux_widget)));
331
332  aux_widget = GTK_WIDGET(gtk_builder_get_object(builder, "entry_addprov_email"));
333  email_c = g_strdup (gtk_entry_get_text (GTK_ENTRY (aux_widget)));
334
335  aux_widget = GTK_WIDGET(gtk_builder_get_object(builder, "entry_addprov_web"));
336  web_c = g_strdup (gtk_entry_get_text (GTK_ENTRY (aux_widget)));
337
338  aux_widget = GTK_WIDGET(gtk_builder_get_object(builder, "entry_addprov_contact"));
339  contacto_c = g_strdup (gtk_entry_get_text (GTK_ENTRY (aux_widget)));
340
341  aux_widget = GTK_WIDGET(gtk_builder_get_object(builder, "entry_addprov_giro"));
342  giro_c = g_strdup (gtk_entry_get_text (GTK_ENTRY (aux_widget)));
343
344
345  if (g_strcmp0 (rut_c, "") == 0)
346    {
347      ErrorMSG (wnd, "Debe Escribir el rut completo");
348      return;
349    }
350  else if (g_strcmp0 (rut_ver, "") == 0)
351    {
352      ErrorMSG (wnd, "Debe ingresar el digito verificador del rut");
353      return;
354    }
355  else if ((GetDataByOne
356            (g_strdup_printf ("SELECT * FROM proveedor WHERE rut=%s", rut_c))) != NULL)
357    {
358      ErrorMSG (wnd, "Ya existe un proveedor con el mismo rut");
359      return;
360    }
361  else if (g_strcmp0 (nombre_c, "") == 0)
362    {
363      ErrorMSG (wnd, "Debe escribir el nombre del proveedor");
364      return;
365    }
366  else if (g_strcmp0 (direccion_c, "") == 0)
367    {
368      ErrorMSG (wnd, "Debe escribir la direccion");
369      return;
370    }
371  else if (g_strcmp0 (comuna_c, "") == 0)
372    {
373      ErrorMSG (wnd, "Debe escribir la comuna");
374      return;
375    }
376  else if (g_strcmp0 (telefono_c, "") == 0)
377    {
378      ErrorMSG (wnd, "Debe escribir el telefono");
379      return;
380    }
381  else if (g_strcmp0 (giro_c, "") == 0)
382    {
383      ErrorMSG (wnd, "Debe escribir el giro");
384      return;
385    }
386
387  if (VerificarRut (rut_c, rut_ver) != TRUE)
388    {
389      ErrorMSG (wnd, "El rut no es valido!");
390      return;
391    }
392
393  if (atoi(telefono_c) == 0)
394    {
395      ErrorMSG (wnd, "Debe ingresar solo números en el campo telefono");
396      return;
397    }
398
399  CloseAgregarProveedorWindow (NULL, user_data);
400
401  str_rut = g_strdup_printf ("%s-%s", rut_c, rut_ver);
402  AddProveedorToDB (str_rut, nombre_c, direccion_c, ciudad_c, comuna_c, telefono_c, email_c, web_c, contacto_c, giro_c);
403  g_free (str_rut);
404  //ListarProveedores (); <- this does not correspond
405
406}
407
408/**
409 * Es llamada cuando el boton "btn_prov_ad" es presionado (signal click).
410 * 
411 * Esta funcion visualiza la ventana para agregar un proveedor y sus
412 * respectivos entry para llenar con los campos de este.
413 *
414 * @param widget the widget that emited the signal
415 * @param data the user data
416 *
417 */
418
419void
420AgregarProveedorWindow (GtkWidget *widget, gpointer user_data)
421{
422  GtkWidget *aux_widget;
423
424  aux_widget = GTK_WIDGET(gtk_builder_get_object(builder, "entry_addprov_rut"));
425  gtk_entry_set_text(GTK_ENTRY(aux_widget), "");
426
427  aux_widget = GTK_WIDGET(gtk_builder_get_object(builder, "entry_addprov_dv"));
428  gtk_entry_set_text(GTK_ENTRY(aux_widget), "");
429
430  aux_widget = GTK_WIDGET(gtk_builder_get_object(builder, "entry_addprov_name"));
431  gtk_entry_set_text(GTK_ENTRY(aux_widget), "");
432
433  aux_widget = GTK_WIDGET(gtk_builder_get_object(builder, "entry_addprov_addr"));
434  gtk_entry_set_text(GTK_ENTRY(aux_widget), "");
435
436  aux_widget = GTK_WIDGET(gtk_builder_get_object(builder, "entry_addprov_comuna"));
437  gtk_entry_set_text(GTK_ENTRY(aux_widget), "");
438
439  aux_widget = GTK_WIDGET(gtk_builder_get_object(builder, "entry_addprov_city"));
440  gtk_entry_set_text(GTK_ENTRY(aux_widget), "");
441
442  aux_widget = GTK_WIDGET(gtk_builder_get_object(builder, "entry_addprov_phone"));
443  gtk_entry_set_text(GTK_ENTRY(aux_widget), "");
444
445  aux_widget = GTK_WIDGET(gtk_builder_get_object(builder, "entry_addprov_email"));
446  gtk_entry_set_text(GTK_ENTRY(aux_widget), "");
447
448  aux_widget = GTK_WIDGET(gtk_builder_get_object(builder, "entry_addprov_web"));
449  gtk_entry_set_text(GTK_ENTRY(aux_widget), "");
450
451  aux_widget = GTK_WIDGET(gtk_builder_get_object(builder, "entry_addprov_contact"));
452  gtk_entry_set_text(GTK_ENTRY(aux_widget), "");
453
454  aux_widget = GTK_WIDGET(gtk_builder_get_object(builder, "entry_addprov_giro"));
455  gtk_entry_set_text(GTK_ENTRY(aux_widget), "");
456
457  aux_widget = GTK_WIDGET(gtk_builder_get_object(builder, "wnd_addprovider"));
458  gtk_window_set_transient_for(GTK_WINDOW(aux_widget),
459                               GTK_WINDOW(gtk_widget_get_toplevel(widget)));
460  gtk_window_set_modal (GTK_WINDOW(aux_widget), TRUE);
461  gtk_widget_show (aux_widget);
462}
463
464/**
465 * Es llamada cuando el boton "btn_prov_save" es presionado (signal click).
466 * 
467 * Esta funcion carga los datos llenados con los datos del proveedor y luego
468 * llama a la funcion "SetModificacionesProveedor() que actualiza los datos
469 * de este en la base de datos.
470 */
471
472void
473ModificarProveedor (void)
474{
475  GtkWidget *widget;
476  gchar *rut_c;
477  gchar *nombre_c;
478  gchar *direccion_c;
479  gchar *comuna_c;
480  gchar *ciudad_c;
481  gchar *fono_c;
482  gchar *web_c;
483  gchar *contacto_c;
484  gchar *email_c;
485  gchar *giro_c;
486  gchar *lap_rep_c;
487
488  widget = GTK_WIDGET (gtk_builder_get_object (builder, "lbl_prov_rut"));
489  rut_c = CutPoints (g_strdup (gtk_label_get_text (GTK_LABEL (widget))));
490
491  widget = GTK_WIDGET(gtk_builder_get_object(builder, "entry_prov_name"));
492  nombre_c = g_strdup(gtk_entry_get_text (GTK_ENTRY (widget)));
493
494  widget = GTK_WIDGET(gtk_builder_get_object(builder, "entry_prov_addr"));
495  direccion_c = g_strdup(gtk_entry_get_text (GTK_ENTRY (widget)));
496
497  widget = GTK_WIDGET(gtk_builder_get_object(builder, "entry_prov_comuna"));
498  comuna_c = g_strdup(gtk_entry_get_text (GTK_ENTRY (widget)));
499
500  widget = GTK_WIDGET(gtk_builder_get_object(builder, "entry_prov_city"));
501  ciudad_c = g_strdup(gtk_entry_get_text (GTK_ENTRY (widget)));
502
503  widget = GTK_WIDGET(gtk_builder_get_object(builder, "entry_prov_phone"));
504  fono_c = g_strdup(gtk_entry_get_text (GTK_ENTRY (widget)));
505
506  widget = GTK_WIDGET(gtk_builder_get_object(builder, "entry_prov_web"));
507  web_c = g_strdup(gtk_entry_get_text (GTK_ENTRY (widget)));
508
509  widget = GTK_WIDGET(gtk_builder_get_object(builder, "entry_prov_contact"));
510  contacto_c = g_strdup(gtk_entry_get_text (GTK_ENTRY (widget)));
511
512  widget = GTK_WIDGET(gtk_builder_get_object(builder, "entry_prov_mail"));
513  email_c = g_strdup(gtk_entry_get_text (GTK_ENTRY (widget)));
514
515  widget = GTK_WIDGET(gtk_builder_get_object(builder, "entry_prov_giro"));
516  giro_c = g_strdup(gtk_entry_get_text (GTK_ENTRY (widget)));
517
518  widget = GTK_WIDGET(gtk_builder_get_object(builder, "entry_lap_rep"));
519  lap_rep_c = g_strdup(gtk_entry_get_text (GTK_ENTRY (widget)));
520
521  gint respuesta = SetModificacionesProveedor (rut_c, nombre_c, direccion_c, comuna_c, ciudad_c, fono_c,
522					       web_c, contacto_c, email_c, giro_c, lap_rep_c);
523  widget = GTK_WIDGET(gtk_builder_get_object(builder, "statusbar"));
524  if (respuesta == 0)
525    statusbar_push (GTK_STATUSBAR(widget), "El proveedor ha sido actualizado exitosamente", 3000);
526  else if (respuesta == -1)
527    statusbar_push (GTK_STATUSBAR(widget), "Error: Lapso Reposición debe ser un valor numérico y mayor a cero", 3000);
528}
529
530/**
531 * Es llamada por la funcion "compras_win()"[compras.c] 
532 * 
533 * Esta funcion visualiza los nombres de cada columna del tree view de
534 * proveedores, y los datos para poder exportarlos a Gnumeric.
535 *
536 */
537
538void
539proveedores_box ()
540{
541  GtkWidget *proveedores_tree;
542  GtkListStore *store;
543  GtkTreeSelection *selection;
544  GtkWidget *button;
545  GtkCellRenderer *renderer;
546  GtkTreeViewColumn *column;
547  Print *proveedores_print;
548
549  proveedores_print = (Print *) g_malloc0 (sizeof (Print));
550
551  //setup the gtktreeview and all the necesary objects
552  store = gtk_list_store_new (4,
553                              G_TYPE_STRING,
554                              G_TYPE_STRING,
555                              G_TYPE_STRING,
556                              G_TYPE_STRING);
557
558  proveedores_tree = GTK_WIDGET(gtk_builder_get_object(builder, "treeview_prov_search"));
559  gtk_tree_view_set_model(GTK_TREE_VIEW(proveedores_tree), GTK_TREE_MODEL(store));
560  selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(proveedores_tree));
561
562  g_signal_connect (G_OBJECT (selection), "changed",
563                    G_CALLBACK (LlenarDatosProveedor), NULL);
564
565  renderer = gtk_cell_renderer_text_new ();
566  column = gtk_tree_view_column_new_with_attributes ("Rut", renderer,
567                                                     "text", 0,
568                                                     NULL);
569  gtk_tree_view_append_column (GTK_TREE_VIEW (proveedores_tree), column);
570  gtk_tree_view_column_set_resizable (column, FALSE);
571  gtk_tree_view_column_set_cell_data_func (column, renderer, control_rut, (gpointer)0, NULL);
572
573  renderer = gtk_cell_renderer_text_new ();
574  column = gtk_tree_view_column_new_with_attributes ("Proveedor", renderer,
575                                                     "text", 1,
576                                                     NULL);
577  gtk_tree_view_append_column (GTK_TREE_VIEW (proveedores_tree), column);
578  gtk_tree_view_column_set_resizable (column, FALSE);
579  gtk_tree_view_column_set_expand (column, TRUE);
580
581  renderer = gtk_cell_renderer_text_new ();
582  column = gtk_tree_view_column_new_with_attributes ("Giro", renderer,
583                                                     "text", 2,
584                                                     NULL);
585  gtk_tree_view_append_column (GTK_TREE_VIEW (proveedores_tree), column);
586  gtk_tree_view_column_set_resizable (column, FALSE);
587  gtk_tree_view_column_set_expand (column, TRUE);
588
589  renderer = gtk_cell_renderer_text_new ();
590  column = gtk_tree_view_column_new_with_attributes ("Contacto", renderer,
591                                                     "text", 3,
592                                                     NULL);
593  gtk_tree_view_append_column (GTK_TREE_VIEW (proveedores_tree), column);
594  gtk_tree_view_column_set_resizable (column, FALSE);
595
596  button = GTK_WIDGET(gtk_builder_get_object(builder, "btn_prov_print"));
597
598  proveedores_print->tree = GTK_TREE_VIEW (proveedores_tree);
599  proveedores_print->title = "Lista de Proveedores";
600  proveedores_print->name = "proveedores";
601  proveedores_print->date_string = NULL;
602  proveedores_print->cols[0].name = "Nombre";
603  proveedores_print->cols[0].num = 0;
604  proveedores_print->cols[1].name = "Rut";
605  proveedores_print->cols[1].num = 1;
606  proveedores_print->cols[2].name = NULL;
607
608  g_signal_connect (G_OBJECT (button), "clicked",
609                    G_CALLBACK (PrintTree), (gpointer)proveedores_print);
610}