/
ricercapermanenza_no.rb
367 lines (347 loc) · 12 KB
/
ricercapermanenza_no.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
#require 'stamparicgen'
def ricercapermanenza
mricgen = Gtk::Window.new("Ricerca capi presenti")
mricgen.window_position=(Gtk::Window::POS_CENTER_ALWAYS)
boxricgenv = Gtk::VBox.new(false, 0)
boxricgen1 = Gtk::HBox.new(false, 5)
boxricgen2 = Gtk::HBox.new(false, 5)
boxricgen3 = Gtk::HBox.new(false, 5)
boxricgen4 = Gtk::HBox.new(false, 5)
boxricgen5 = Gtk::HBox.new(false, 5)
boxricgen6 = Gtk::HBox.new(false, 5)
boxricgenv.pack_start(boxricgen1, false, false, 5)
boxricgenv.pack_start(boxricgen2, false, false, 5)
boxricgenv.pack_start(boxricgen3, false, false, 5)
boxricgenv.pack_start(boxricgen4, false, false, 5)
boxricgenv.pack_start(boxricgen5, false, false, 5)
boxricgenv.pack_start(boxricgen6, false, false, 5)
mricgen.add(boxricgenv)
# anni = Gtk::ListStore.new(Integer)
# arranni = [(@giorno.strftime("%Y").to_i), (@giorno.strftime("%Y").to_i) -1, (@giorno.strftime("%Y").to_i) -2]
# arranni.each do |a|
# iter = anni.append
# iter[0] = a
# end
# comboanno = Gtk::ComboBox.new(anni)
# renderer1 = Gtk::CellRendererText.new
# comboanno.pack_start(renderer1,false)
# comboanno.set_attributes(renderer1, :text => 0)
# comboanno.active=(0)
# labelanno = Gtk::Label.new("Seleziona l'anno:")
# boxricgen1.pack_start(labelanno, false, false, 5)
# boxricgen1.pack_start(comboanno, false, false, 0)
# labeldoc = Gtk::Label.new("Documento:")
# boxricgen2.pack_start(labeldoc, false, false, 5)
# doctutti = Gtk::RadioButton.new("Tutti")
# doctutti.active=(true)
# tipodoc = "T"
# doctutti.signal_connect("toggled") {
# if doctutti.active?
# tipodoc="T"
# end
# }
# boxricgen2.pack_start(doctutti, false, false, 5)
# mod4 = Gtk::RadioButton.new(doctutti, "Modello 4")
# mod4.signal_connect("toggled") {
# if mod4.active?
# tipodoc="M"
# end
# }
# boxricgen2.pack_start(mod4, false, false, 5)
# certsan = Gtk::RadioButton.new(doctutti, "Certificato sanitario")
# certsan.signal_connect("toggled") {
# if certsan.active?
# tipodoc="C"
# end
# }
# boxricgen2.pack_start(certsan, false, false, 5)
# docentry = GTK::Entry.new
labelmovimento = Gtk::Label.new("Tipo di movimento:")
boxricgen3.pack_start(labelmovimento, false, false, 5)
movtutti = Gtk::RadioButton.new("Tutti")
movtutti.active=(true)
tipomov = "T"
movtutti.signal_connect("toggled") {
if movtutti.active?
tipomov="T"
end
}
boxricgen3.pack_start(movtutti, false, false, 5)
movingr = Gtk::RadioButton.new(movtutti, "Ingresso")
movingr.signal_connect("toggled") {
if movingr.active?
tipomov="I"
end
}
boxricgen3.pack_start(movingr, false, false, 5)
movusc = Gtk::RadioButton.new(movtutti, "Uscita")
movusc.signal_connect("toggled") {
if movusc.active?
tipomov="U"
end
}
boxricgen3.pack_start(movusc, false, false, 5)
labelinizio = Gtk::Label.new("Da:")
boxricgen4.pack_start(labelinizio, false, false, 5)
datainizio = Gtk::Entry.new
datainizio.max_length=(6)
boxricgen4.pack_start(datainizio, false, false, 5)
labelfine = Gtk::Label.new("A:")
boxricgen4.pack_start(labelfine, false, false, 5)
datafine = Gtk::Entry.new
datafine.max_length=(6)
boxricgen4.pack_start(datafine, false, false, 5)
=begin
labelcercain = Gtk::Label.new("Cerca in:")
boxricgen5.pack_start(labelcercain, false, false, 5)
movimento = Gtk::RadioButton.new("Tabella Movimenti")
movimento.active=(true)
cercain = "M"
movimento.signal_connect("toggled") {
if movimento.active?
cercain="M"
end
}
boxricgen5.pack_start(movimento, false, false, 5)
registro = Gtk::RadioButton.new(movimento, "Tabella Registro")
registro.signal_connect("toggled") {
if registro.active?
cercain="R"
end
}
boxricgen5.pack_start(registro, false, false, 5)
=end
bottcerca = Gtk::Button.new("Cerca")
boxricgen6.pack_start(bottcerca, false, false, 5)
bottcerca.signal_connect("clicked") {
# errore = 0
=begin
if selcc != "" and selcc != "6"
condcc = "and callcenter_id = '#{selcc}'"
#puts condcc
else
condcc = ""
end
if @seltype != ""
condtype = "and type_id = '#{@seltype}'"
#puts condtype
else
condtype = ""
end
if @selconf.to_s != ""
condconf = "and intext = '#{@selconf}'"
#puts condconf
else
condconf = ""
end
if @selfond.to_s != ""
condfond = "and fondato = '#{@selfond}'"
else
condfond = ""
end
@grievances = Grievance.where("id > ? #{condcc} #{condtype} #{condconf} #{condfond}", "0").order("callcenter_id, id desc") #.paginate(:page => params[:page], :per_page => 10)
end
=end
=begin
if cercain == "M"
puts "Movimento"
# if tipodoc == "M"
# querydoc = "and mod4 LIKE %#{docentry.text}"
# elsif tipodoc == "C"
# querydoc = "and certsan LIKE %#{docentry.text}"
=end
# if tipomov == "I"
# querymov = ""
# else
# querymov = "and tipouscita IS NOT NULL"
# end
if tipomov == "U"
querymov = "and tipouscita IS NOT NULL"
ordinamento = "datauscita, mod4usc, id"
else
querymov = ""
ordinamento = "dataingresso, id"
end
if tipomov == "I"
orientamento = "portait"
else
orientamento = "landscape"
end
#=begin
begin
if datainizio.text != ""# and tipomov == "I"
inizioingl = datainizio.text[4,2] + datainizio.text[2,2] + datainizio.text[0,2]
inizioingl = Time.parse("#{inizioingl}").strftime("%Y")[0,2] + inizioingl
inizioita = inizioingl.to_date.strftime("%d/%m/%Y")
if tipomov == "I"
queryinizio = "and dataingresso >= '#{inizioingl}'"
elsif tipomov == "U"
queryinizio = "and datauscita >= '#{inizioingl}'"
else
queryinizio = "and (dataingresso >= '#{inizioingl}' or datauscita >= '#{inizioingl}')"
end
else
queryinizio = ""
inizioita = ""
end
if datafine.text != ""# and tipomov == "I"
fineingl = datafine.text[4,2] + datafine.text[2,2] + datafine.text[0,2]
fineingl = Time.parse("#{fineingl}").strftime("%Y")[0,2] + fineingl
fineita = fineingl.to_date.strftime("%d/%m/%Y")
if tipomov == "I"
queryfine = "and dataingresso <= '#{fineingl}'"
elsif tipomov == "U"
queryfine = "and datauscita <= '#{fineingl}'"
else
queryfine = "and (dataingresso <= '#{fineingl}' or datauscita <= '#{fineingl}')"
end
else
queryfine = ""
fineita = ""
end
#=end
selmov = Registros.find(:all, :conditions => ["relaz_id = ? #{querymov} #{queryinizio} #{queryfine}", "#{@stallaoper.id}"], :order => "#{ordinamento}")
#selmov = Animals.find(:all, :conditions => ["relaz_id = ? #{querymov} #{queryinizio} #{queryfine}", "#{@stallaoper.id}"])
#selmov = Animals.find(:all, :from => "animals", :conditions => ["relaz_id= ? and marca LIKE ?", "#{@stallaoper.id}", "%#{visricercaentry.text}%"])
#puts selmov.length
#riempimento2
#vismovimenti2(selmov, inizioingl, fineingl)
visregistro2(selmov, inizioita, fineita, orientamento)
=begin
else
puts "Registro"
end
=end
rescue Exception => errore
#puts errore
Errore.avviso(mricgen, "Controllare le date.")
end
}
bottchiudi = Gtk::Button.new( "Chiudi" )
bottchiudi.signal_connect("clicked") {
mricgen.destroy
}
boxricgen6.pack_start(bottchiudi, false, false, 0)
=begin
stampauscnv = Gtk::Button.new("Stampa registro di scarico")
boxricgenv.pack_start(stampauscnv, false, false, 5)
stamparicgen = Gtk::Button.new("Stampa registro nuovo")
boxricgenv.pack_start(stamparicgen, false, false, 5)
stampaingrnv.signal_connect("clicked") {
#rel = Relazs.find(:first, :conditions => "id = '#{@stallaoper.id}'")
if Registros.find(:first, :conditions => ["contatori_id= ? and YEAR(dataingresso) = ?", "#{@stallaoper.contatori_id}", "#{comboanno.active_iter[0]}"]) == nil
Conferma.conferma(mricgen, "Nessun capo presente.")
else
#conto = Registros.find(:first, :conditions => ["contatori_id= ? and YEAR(dataingresso) = ?", "#{@stallaoper.contatori_id}", "#{comboanno.active_iter[0]}"])
#puts conto.class
#puts conto
registroingrnv(comboanno)
end
}
stampauscnv.signal_connect("clicked") {
#rel = Relazs.find(:first, :conditions => "id = '#{@stallaoper.id}'")
if Registros.find(:first, :conditions => ["contatori_id= ? and tipouscita != 'null' and YEAR(datauscita) = ?", "#{@stallaoper.contatori_id}", "#{comboanno.active_iter[0]}"], :order => ["datauscita, id"]) == nil
Conferma.conferma(mricgen, "Nessun capo presente.")
else
registrouscnv(comboanno)
end
}
stamparicgen.signal_connect("clicked") {
#rel = Relazs.find(:first, :conditions => "id = '#{@stallaoper.id}'")
if Registros.find(:first, :conditions => ["contatori_id= ? and tipouscita != 'null' and YEAR(datauscita) = ?", "#{@stallaoper.contatori_id}", "#{comboanno.active_iter[0]}"], :order => ["dataingresso, id"]) == nil
Conferma.conferma(mricgen, "Nessun capo presente.")
else
registronv(comboanno)
end
}
=end
mricgen.show_all
end
=begin
def registroingrnv(comboanno)
foglio = PDF::Writer.new(:paper => "A4") # , :font_size => 5)
foglio.select_font("Helvetica")
foglio.open_object do |testa|
foglio.save_state
dimcar = 8
x = foglio.margin_x_middle
y = foglio.absolute_top_margin
z = foglio.absolute_left_margin
w = foglio.absolute_right_margin
testo = "<b>Registro non vidimato di carico della stalla #{@stallaoper.stalle.cod317} di #{@stallaoper.ragsoc.ragsoc}</b>"
boh = foglio.text_width(testo, dimcar) / 2.0
q = foglio.absolute_top_margin - (dimcar * 1.5)
m = x - boh
foglio.add_text(m, y, testo, dimcar)
spostapagina = x + 36
foglio.start_page_numbering(w-20, foglio.absolute_bottom_margin, 8, nil, "pag. <PAGENUM> di <TOTALPAGENUM>")
foglio.restore_state
foglio.close_object
foglio.add_object(testa, :all_pages)
end
foglio.margins_mm(15, 10, 10)
tabella = PDF::SimpleTable.new
tabella.show_lines = :all
tabella.show_headings = true
tabella.orientation = :right
tabella.position = :left
tabella.shade_rows = :none
tabella.split_rows = true
tabella.font_size = 8
tabella.heading_font_size = 8
tabella.width = 550
tabella.minimum_space = 10
tabella.column_order.push(*%w(prog marca razza sesso madre nc nascita ingresso prov))
tabella.columns["prog"] = PDF::SimpleTable::Column.new("prog") { |col|
col.heading = "Numero ordine"
col.width = 40
}
tabella.columns["marca"] = PDF::SimpleTable::Column.new("marca") { |col|
col.heading = "Marchio di identificazione"
col.width = 90
}
tabella.columns["razza"] = PDF::SimpleTable::Column.new("razza") { |col|
col.heading = "Razza"
col.width = 35
}
tabella.columns["sesso"] = PDF::SimpleTable::Column.new("sesso") { |col|
col.heading = "Sesso"
col.width = 35
}
tabella.columns["madre"] = PDF::SimpleTable::Column.new("madre") { |col|
col.heading = "Codice della madre"
col.width = 90
}
tabella.columns["nc"] = PDF::SimpleTable::Column.new("nc") { |col|
col.heading = "Nato / acquisto"
col.width = 40
}
tabella.columns["nascita"] = PDF::SimpleTable::Column.new("nascita") { |col|
col.heading = "Data di nascita"
col.width = 55
}
tabella.columns["ingresso"] = PDF::SimpleTable::Column.new("ingresso") { |col|
col.heading = "Data di ingresso"
col.width = 55
}
tabella.columns["prov"] = PDF::SimpleTable::Column.new("prov") { |col|
col.heading = "Provenienza"
}
data = Array.new
#rel = Relazs.find(:first, :conditions => "id = '#{@stallaoper.id}'")
selcapi = Registros.find(:all, :conditions => ["contatori_id= ? and YEAR(dataingresso) = ?", "#{@stallaoper.contatori_id}", "#{comboanno.active_iter[0]}"], :order => ["dataingresso, id"])
selcapi.each do |i, index|
data << {"prog" => "#{i.progressivo.to_s}", "marca" => "#{i.marca}", "razza" => "#{i.razza}", "sesso" => "#{i.sesso}", "madre" => "#{i.madre}", "nc" => "#{i.tipoingresso}", "nascita" => "#{i.datanascita.strftime("%d/%m/%Y")}", "ingresso" => "#{i.dataingresso.strftime("%d/%m/%Y")}", "prov" => "#{i.provenienza}"}
end
tabella.data.replace data
tabella.render_on(foglio)
foglio.save_as("#{@dir}/ricgen/registro_ingressonv.pdf")
if @sistema == "linux"
system("evince #{@dir}/ricgen/registro_ingressonv.pdf")
else
# foglio.save_as('.\ricgen\registro_ingressonv.pdf')
# @shell.ShellExecute('./ricgen/registro_ingressonv.pdf', '', '', 'open', 3)
@shell.ShellExecute('.\ricgen\registro_ingressonv.pdf', '', '', 'open', 3)
end
end
=end