Ajout d'un attribut couleur pour chaque groupe d'article pour les graphiques
[bilio:bilio.git] / src / configuration.rb
1 # coding: utf-8
2
3 class Configuration_box < Gtk::VBox
4
5         def initialize window, dial=false
6         
7                 super(false, 3)
8                 
9                 set_border_width 10
10                                 
11                 @window = window
12                 @login = window.login
13                 @dial = dial
14                 @chemin_config = "../configuration.yaml"
15                 
16                 @valider = Gtk::Button.new
17                 hboxvalider = Gtk::HBox.new false, 2
18                 hboxvalider.add Gtk::Image.new( "./resources/icons/ok.png" )
19                 hboxvalider.add Gtk::Label.new "Valider"
20                 @valider.add hboxvalider
21                 @annuler = Gtk::Button.new
22                 hboxannuler = Gtk::HBox.new false, 2
23                 hboxannuler.add Gtk::Image.new( "./resources/icons/cancel.png" )
24                 hboxannuler.add Gtk::Label.new "Annuler"
25                 @annuler.add hboxannuler
26                 
27                 agencement
28                 
29                 @valider.signal_connect( "clicked" ) { validate }
30                 @annuler.signal_connect( "clicked" ) { quit }
31         
32         end
33         
34         def agencement
35         
36                 vbox = Gtk::VBox.new false, 3
37                 @frame = Gtk::Frame.new
38                 @frame.label = "Configuration"
39                 vbox.pack_start( @frame, true, true, 3 )
40                 
41                 vbox_corps = Gtk::VBox.new false, 3
42                 @frame.add vbox_corps
43                 vbox_corps.pack_start( notebook, true, true, 3 )                
44                 
45                 hbox3 = Gtk::HBox.new false, 2
46                 align1 = Gtk::Alignment.new 1, 1, 0, 0
47                 hbox3.pack_start( @annuler, true, true, 3 )
48                 hbox3.pack_start( @valider, true, true, 3 )
49                 align1.add hbox3
50                 
51                 vbox.pack_start( align1, false, false, 3 ) unless @dial
52                 
53                 self.add vbox
54         
55         end
56         
57         def notebook
58                 
59                 # Conteneurs
60                 notebook = Gtk::Notebook.new
61                 
62                 # Agencement du notebook
63                 notebook.append_page societe, Gtk::Label.new("Société")
64                 notebook.append_page groupe_article, Gtk::Label.new("Groupes d'articles")
65                 notebook.append_page tarifs, Gtk::Label.new("Tarifs")
66                 notebook.append_page ged, Gtk::Label.new("GED")
67
68                 # Renvoie
69                 notebook
70                 
71         end
72         
73         def societe
74                 # Objets        
75                 @soc_nom = Gtk::Entry.new
76                 @soc_adresse = Gtk::TextView.new
77                 @soc_capital = Gtk::Entry.new
78                 @soc_tel = Gtk::Entry.new
79                 @soc_fax = Gtk::Entry.new
80                 @soc_mail = Gtk::Entry.new
81                 @soc_site = Gtk::Entry.new
82                 @soc_siret = Gtk::Entry.new
83                 @soc_rcs = Gtk::Entry.new
84                 @soc_naf = Gtk::Entry.new
85                 @soc_status = Gtk::Entry.new
86                 @soc_logo = Gtk::Image.new
87                 visite_site = Gtk::Button.new
88                 logo_btn = Gtk::Button.new "..."
89                 
90                 # Conteneurs
91                 table_info = Gtk::Table.new 2, 4, false
92                 scroll_info = Gtk::ScrolledWindow.new
93                 hbox_compte = Gtk::HBox.new false, 2
94                 
95                 # Les labels
96                 label_nom = Gtk::Alignment.new 0, 0.5, 0, 0
97                 label_nom.add Gtk::Label.new "Nom de la société :"
98                 label_adresse = Gtk::Alignment.new 0, 0.5, 0, 0
99                 label_adresse.add Gtk::Label.new "Adresse :"
100                 label_capital = Gtk::Alignment.new 0, 0.5, 0, 0
101                 label_capital.add Gtk::Label.new "Capital de :"
102                 label_tel = Gtk::Alignment.new 0, 0.5, 0, 0
103                 label_tel.add Gtk::Label.new "Tél. :"
104                 label_fax = Gtk::Alignment.new 0, 0.5, 0, 0
105                 label_fax.add Gtk::Label.new "Fax. :"
106                 label_mail = Gtk::Alignment.new 0, 0.5, 0, 0
107                 label_mail.add Gtk::Label.new "Email :"
108                 label_site = Gtk::Alignment.new 0, 0.5, 0, 0
109                 label_site.add Gtk::Label.new "Site web :"
110                 label_siret = Gtk::Alignment.new 0, 0.5, 0, 0
111                 label_siret.add Gtk::Label.new "SIRET :"
112                 label_rcs = Gtk::Alignment.new 0, 0.5, 0, 0
113                 label_rcs.add Gtk::Label.new "RCS :"
114                 label_naf = Gtk::Alignment.new 0, 0.5, 0, 0
115                 label_naf.add Gtk::Label.new "NAF :"
116                 label_status = Gtk::Alignment.new 0, 0.5, 0, 0
117                 label_status.add Gtk::Label.new "Status :"
118                 label_logo = Gtk::Alignment.new 0, 0.5, 0, 0
119                 label_logo.add Gtk::Label.new "Logo :"
120                 
121                 # Propriétés des objets
122                 scroll_info.set_policy Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC
123                 scroll_info.shadow_type = Gtk::SHADOW_NONE
124                 visite_site.image = Gtk::Image.new "resources/icons/internet.png"
125                 visite_site.signal_connect("clicked") { naviguer unless @soc_site.text.empty? }
126                 visite_site.tooltip_text = "Visiter le site"
127                 logo_btn.signal_connect("clicked") { nouveau_logo }
128                 
129                 # Agencement du conteneur Informations
130                 i=0
131                 table_info.attach( label_status , 0, 1, i, i+1, Gtk::FILL, Gtk::FILL, 5, 5 )
132                 table_info.attach( @soc_status, 1, 3, i, i+1, Gtk::EXPAND|Gtk::FILL, Gtk::FILL, 5, 5 )
133                 
134                 i+=1
135                 table_info.attach( label_nom , 0, 1, i, i+1, Gtk::FILL, Gtk::FILL, 5, 5 )
136                 table_info.attach( @soc_nom, 1, 3, i, i+1, Gtk::EXPAND|Gtk::FILL, Gtk::FILL, 5, 5 )
137                 
138                 i+=1
139                 table_info.attach( label_adresse , 0, 1, i, i+1, Gtk::FILL, Gtk::FILL, 5, 5 )
140                 table_info.attach( @soc_adresse, 1, 3, i, i+1, Gtk::EXPAND|Gtk::FILL, Gtk::FILL, 5, 5 )
141                 
142                 i+=1
143                 table_info.attach( label_tel , 0, 1, i, i+1, Gtk::FILL, Gtk::FILL, 5, 5 )
144                 table_info.attach( @soc_tel, 1, 3, i, i+1, Gtk::EXPAND|Gtk::FILL, Gtk::FILL, 5, 5 )
145                 
146                 i+=1
147                 table_info.attach( label_fax , 0, 1, i, i+1, Gtk::FILL, Gtk::FILL, 5, 5 )
148                 table_info.attach( @soc_fax, 1, 3, i, i+1, Gtk::EXPAND|Gtk::FILL, Gtk::FILL, 5, 5 )
149                 
150                 i+=1
151                 table_info.attach( label_mail , 0, 1, i, i+1, Gtk::FILL, Gtk::FILL, 5, 5 )
152                 table_info.attach( @soc_mail, 1, 3, i, i+1, Gtk::EXPAND|Gtk::FILL, Gtk::FILL, 5, 5 )
153                 
154                 i+=1
155                 table_info.attach( label_site , 0, 1, i, i+1, Gtk::FILL, Gtk::FILL, 5, 5 )
156                 table_info.attach( @soc_site, 1, 2, i, i+1, Gtk::EXPAND|Gtk::FILL, Gtk::FILL, 5, 5 )
157                 table_info.attach( visite_site, 2, 3, i, i+1, Gtk::FILL, Gtk::FILL, 5, 5 )
158                 
159                 i+=1
160                 table_info.attach( label_siret , 0, 1, i, i+1, Gtk::FILL, Gtk::FILL, 5, 5 )
161                 table_info.attach( @soc_siret, 1, 3, i, i+1, Gtk::EXPAND|Gtk::FILL, Gtk::FILL, 5, 5 )
162                 
163                 i+=1
164                 table_info.attach( label_rcs , 0, 1, i, i+1, Gtk::FILL, Gtk::FILL, 5, 5 )
165                 table_info.attach( @soc_rcs, 1, 3, i, i+1, Gtk::EXPAND|Gtk::FILL, Gtk::FILL, 5, 5 )
166                 
167                 i+=1
168                 table_info.attach( label_naf , 0, 1, i, i+1, Gtk::FILL, Gtk::FILL, 5, 5 )
169                 table_info.attach( @soc_naf, 1, 3, i, i+1, Gtk::EXPAND|Gtk::FILL, Gtk::FILL, 5, 5 )
170                 
171                 i+=1
172                 table_info.attach( label_capital , 0, 1, i, i+1, Gtk::FILL, Gtk::FILL, 5, 5 )
173                 table_info.attach( @soc_capital, 1, 3, i, i+1, Gtk::EXPAND|Gtk::FILL, Gtk::FILL, 5, 5 )
174                 
175                 i+=1
176                 table_info.attach( label_logo , 0, 1, i, i+1, Gtk::FILL, Gtk::FILL, 5, 5 )
177                 table_info.attach( @soc_logo, 1, 2, i, i+1, Gtk::EXPAND|Gtk::FILL, Gtk::FILL, 5, 5 )
178                 table_info.attach( logo_btn, 2, 3, i, i+1, Gtk::FILL, Gtk::FILL, 5, 5 )
179                 
180                 scroll_info.add_with_viewport table_info
181                 
182                 scroll_info
183         end
184         
185         def groupe_article
186                 
187                 groupe_model = Gtk::TreeStore.new(Integer, String, Integer)
188                 @groupe = Gtk::TreeView.new groupe_model
189                 
190                 @groupe.signal_connect ("button-release-event") { |tree,event|
191                         # Gestion du clic droit sur une ligne
192                         if event.kind_of? Gdk::EventButton and event.button == 3
193                                 npath = @groupe.get_path_at_pos(event.x, event.y)
194                                 if !npath.nil? 
195                                         @groupe.set_cursor(npath[0], nil, false)
196                                         menu_groupe                                     
197                                 end
198                         end
199                 }
200                 
201                 renderer_left = Gtk::CellRendererText.new
202                 renderer_left.xalign = 0
203                 
204                 col = Gtk::TreeViewColumn.new("Groupes", renderer_left, :text => 1)
205                 col.resizable = true
206                 col.expand = true
207                 @groupe.append_column(col)
208                 
209                 col = Gtk::TreeViewColumn.new("Nb articles", renderer_left, :text => 2)
210                 col.resizable = true
211                 @groupe.append_column(col)
212                 
213                 scroll = Gtk::ScrolledWindow.new
214         scroll.set_policy(Gtk::POLICY_AUTOMATIC,Gtk::POLICY_AUTOMATIC)
215         
216         scroll.add_with_viewport @groupe
217         
218         scroll
219         
220         end
221         
222         def tarifs
223                 
224                 groupe_model = Gtk::TreeStore.new(Integer, String, Integer, String)
225                 @tarif = Gtk::TreeView.new groupe_model
226                 
227                 @tarif.signal_connect ("button-release-event") { |tree,event|
228                         # Gestion du clic droit sur une ligne
229                         if event.button.eql?(3)
230                                 npath = @tarif.get_path_at_pos(@tarif.pointer[0], @tarif.pointer[1]-30)
231                                 if !npath.nil? 
232                                         @tarif.set_cursor(npath[0], nil, false)
233                                         #menu_tarif                                     
234                                 end
235                         end
236                 }
237                 
238                 renderer_left = Gtk::CellRendererText.new
239                 renderer_left.xalign = 0
240                 
241                 col = Gtk::TreeViewColumn.new("Tarifs", renderer_left, :text => 1)
242                 col.resizable = true
243                 col.expand = true
244                 col.sort_column_id = 1
245                 @tarif.append_column(col)
246                 
247                 col = Gtk::TreeViewColumn.new("Marge (%)", renderer_left, :text => 3)
248                 col.resizable = true
249                 col.sort_column_id = 3
250                 @tarif.append_column(col)
251                 
252                 col = Gtk::TreeViewColumn.new("Nb tiers", renderer_left, :text => 2)
253                 col.resizable = true
254                 col.sort_column_id = 2
255                 @tarif.append_column(col)
256                 
257                 scroll = Gtk::ScrolledWindow.new
258         scroll.set_policy(Gtk::POLICY_AUTOMATIC,Gtk::POLICY_AUTOMATIC)
259         
260         scroll.add_with_viewport @tarif
261         
262         scroll
263         
264         end
265         
266         def ged
267                 
268                 conf = @window.config_db.conf
269                 
270                 scroll = Gtk::ScrolledWindow.new
271         scroll.set_policy(Gtk::POLICY_AUTOMATIC,Gtk::POLICY_AUTOMATIC)
272         
273         table = Gtk::Table.new 10, 2, false
274                 
275                 i = 0
276                 # Le chemin vers les documents
277                 label_chemin_documents = Gtk::Alignment.new 0, 0.5, 0, 0
278                 label_chemin_documents.add Gtk::Label.new("Chemin vers les documents:")
279                 @chemin_documents = Gtk::Entry.new
280                 @chemin_documents.text = conf["chemin_documents"].to_s unless conf.nil?
281                 table.attach( label_chemin_documents, 0, 1, i, i+1, Gtk::FILL, Gtk::FILL, 2, 2 )        
282                 table.attach( @chemin_documents, 1, 2, i, i+1, Gtk::EXPAND|Gtk::FILL, Gtk::FILL, 2, 2 )
283                 filechooserbt = Gtk::Button.new
284                 filechooserbt.image = Gtk::Image.new( "./resources/icons/add.png" )
285                 filechooserbt.signal_connect("clicked"){ }
286                 table.attach( filechooserbt, 2, 3, i, i+1, Gtk::FILL, Gtk::FILL, 2, 2 )
287                 
288                 
289                 i += 1
290                 # Le scanner
291                 label_scanner = Gtk::Alignment.new 0, 0.5, 0, 0
292                 label_scanner.add Gtk::Label.new("Adresse du scanner:")
293                 @scanner = Gtk::Entry.new
294                 @scanner.text = conf["scanner"].to_s unless conf.nil?
295                 table.attach( label_scanner, 0, 1, i, i+1, Gtk::FILL, Gtk::FILL, 2, 2 ) 
296                 table.attach( @scanner, 1, 2, i, i+1, Gtk::EXPAND|Gtk::FILL, Gtk::FILL, 2, 2 )
297                 
298                 i += 1
299                 # La résolution du scanner
300                 label_resolution = Gtk::Alignment.new 0, 0.5, 0, 0
301                 label_resolution.add Gtk::Label.new("Résolution du scanner (en dpi):")
302                 @resolution = Gtk::Entry.new
303                 @resolution.text = conf["resolution"].to_s unless conf.nil?
304                 table.attach( label_resolution, 0, 1, i, i+1, Gtk::FILL, Gtk::FILL, 2, 2 )      
305                 table.attach( @resolution, 1, 2, i, i+1, Gtk::EXPAND|Gtk::FILL, Gtk::FILL, 2, 2 )
306                 
307                 scroll.add_with_viewport table
308         
309         scroll
310         
311         end
312         
313         def refresh
314         
315                 refresh_societe
316                 refresh_ged
317                 refresh_groupe
318                 refresh_tarif
319         
320         end
321         
322         def refresh_societe
323                 @societe = Societe.first
324                 @soc_nom.text = @societe.nom.to_s
325                 @soc_adresse.buffer.text = @societe.adresse.to_s
326                 @soc_capital.text = @societe.capital.to_s
327                 @soc_tel.text = @societe.tel.to_s
328                 @soc_fax.text = @societe.fax.to_s
329                 @soc_mail.text = @societe.mail.to_s
330                 @soc_site.text = @societe.site.to_s
331                 @soc_siret.text = @societe.siret.to_s
332                 @soc_rcs.text = @societe.rcs.to_s
333                 @soc_naf.text = @societe.naf.to_s
334                 @soc_status.text = @societe.status.to_s
335                 @soc_capital.text = @societe.capital.to_s
336                 societe = Societe.first
337                 logo = @window.config_db.conf["chemin_documents"]+"/societe/"+societe.logo
338                 @soc_logo.file = logo if File.exist?(logo)
339         end
340         
341         def refresh_groupe
342                 
343                 @groupe.model.clear
344                 
345                 groupesp = Articlegroupe.where(:parent_id => 0).order(:designation)
346                 
347                 if groupesp then
348                         active_iter = nil
349                         groupesp.each do |gr|
350                                 iter = @groupe.model.append nil
351                                 iter[0] = gr.id
352                                 iter[1] = gr.designation        
353                                 articles = Article.where(:articlegroupe_id => gr.id)    
354                                 iter[2] = articles.count
355                                 groupese = Articlegroupe.where("parent_id=? AND id<>?", gr.id, 0).order(:designation)                                           
356                                 if groupese then
357                                         groupese.each do |gr2|
358                                                 iter2 = @groupe.model.append iter
359                                                 iter2[0] = gr2['id'].to_i
360                                                 iter2[1] = gr2['designation']
361                                                 articles = Article.where(:articlegroupe_id => gr2.id)   
362                                                 iter2[2] = articles.count
363                                         end
364                                 else
365                                         @window.message_erreur groupese.error
366                                 end
367                         end
368                 else
369                         @window.message_erreur groupesp.error
370                 end
371                 
372         end
373         
374         def refresh_tarif
375                 
376                 @tarif.model.clear
377                 
378                 tarifs = Tarif.where(:vente => true).order(:id)
379                 
380                 if tarifs then
381                         active_iter = nil
382                         tarifs.each do |t|
383                                 iter = @tarif.model.append nil
384                                 iter[0] = t.id
385                                 iter[1] = t.designation 
386                                 iter[3] = "%.2f" % t.marge
387                                 tiers = Tiers.where(:tarif_id => t.id)  
388                                 iter[2] = tiers.count
389                         end
390                 else
391                         @window.message_erreur tarifs.error
392                 end
393                 
394         end
395         
396         def refresh_ged
397                 @chemin_documents.text = @window.config_db.conf["chemin_documents"].to_s
398                 @scanner.text = @window.config_db.conf["scanner"].to_s
399                 @resolution.text = @window.config_db.conf["resolution"].to_s
400         end
401         
402         def menu_groupe
403         
404                 add_tb = Gtk::MenuItem.new "Ajouter un groupe"
405                 add_tb.signal_connect( "activate" ) { 
406                         dial_add = DialGroupe.new @window
407                         dial_add.run { |response| 
408                                 if response.eql?(-5)
409                                         if !dial_add.designation.text.empty?
410                                                 designation = dial_add.designation.text
411                                                 parent_id = dial_add.parent.model.get_value(dial_add.parent.active_iter,0)
412                                                 couleur = dial_add.couleur.text
413                                                 Articlegroupe.create :designation => designation, :parent_id => parent_id, :couleur => couleur
414                                                 refresh_groupe
415                                                 @window.liste_articles.remplir_groupe
416                                         end
417                                 end
418                                 dial_add.destroy                        
419                         }               
420                 }
421                 
422                 modifier_tb = Gtk::MenuItem.new "Modifier le groupe"
423                 modifier_tb.signal_connect( "activate" ) { 
424                         id = @groupe.model.get_value( @groupe.selection.selected, 0 )
425                         dial_add = DialGroupe.new @window, id
426                         dial_add.run { |response| 
427                                 if response.eql?(-5)
428                                         if !dial_add.designation.text.empty?
429                                                 designation = dial_add.designation.text
430                                                 parent_id = dial_add.parent.model.get_value(dial_add.parent.active_iter,0)
431                                                 couleur = dial_add.couleur.text
432                                                 gr = Articlegroupe.find(id) 
433                                                 gr.designation = designation
434                                                 gr.parent_id = parent_id
435                                                 gr.couleur = couleur
436                                                 gr.save
437                                                 refresh_groupe
438                                                 @window.liste_articles.remplir_groupe
439                                         end
440                                 end
441                                 dial_add.destroy                        
442                         }               
443                 }
444                 
445                 suppr_tb = Gtk::MenuItem.new "Supprimer le groupe"
446                 suppr_tb.signal_connect( "activate" ) { 
447                         suppr_groupe                            
448                 }
449                 
450                 menu = Gtk::Menu.new
451                 menu.append add_tb
452                 menu.append modifier_tb
453                 menu.append suppr_tb
454                 menu.show_all
455                 menu.popup(nil, nil, 0, 0)
456                 
457         end
458         
459         def suppr_groupe
460                 suppr = false
461                         
462                 dialog = Gtk::MessageDialog.new(@window, 
463                                 Gtk::Dialog::DESTROY_WITH_PARENT,
464                                 Gtk::MessageDialog::QUESTION,
465                                 Gtk::MessageDialog::BUTTONS_YES_NO,
466                                 "Voulez-vous réellement supprimer ce groupe ?")
467                 response = dialog.run
468                 case response
469                   when Gtk::Dialog::RESPONSE_YES
470                         suppr = true
471                 end 
472                 dialog.destroy
473                 
474                 if suppr
475                         id = @groupe.model.get_value( @groupe.selection.selected, 0 )
476                         articles = Article.where(:articlegroupe_id => id)
477                         if articles.count.eql?(0)
478                                 gr = Articlegroupe.where(:parent_id => id)
479                                 if gr.count.eql?(0)
480                                         Articlegroupe.delete(id)
481                                         refresh_groupe
482                                         @window.liste_articles.remplir_groupe
483                                 else
484                                         @window.message_erreur "Ce groupe ne peut pas être supprimé car au moins un sous-groupe y est rattaché."
485                                 end
486                         else
487                                 @window.message_erreur "Ce groupe ne peut pas être supprimé car au moins un article y est rattaché."
488                         end
489                 end
490         end
491         
492         def validate quitter=true
493                 
494                 res = false
495                 if !@soc_nom.text.empty? then
496                         
497                         res = save_societe
498                         
499                         save_ged if res
500                         
501                         if res then
502                                 quit if quitter
503                         else
504                                 @window.message_erreur res.error
505                         end
506                 else
507                         @window.message_erreur "Vous devez saisir au moins un nom pour votre société !"
508                         res = false
509                 end
510                 return res
511         end
512         
513         def save_societe
514                 
515                 @societe = Societe.first
516                 @societe.nom = @soc_nom.text
517                 @societe.adresse = @soc_adresse.buffer.text
518                 @societe.capital = @soc_capital.text
519                 @societe.tel = @soc_tel.text
520                 @societe.fax = @soc_fax.text
521                 @societe.mail = @soc_mail.text
522                 @societe.site = @soc_site.text
523                 @societe.siret = @soc_siret.text
524                 @societe.rcs = @soc_rcs.text
525                 @societe.naf = @soc_naf.text
526                 @societe.status = @soc_status.text
527                 @societe.capital = @soc_capital.text.to_i
528                 
529                 res = @societe.save
530                 
531                 res
532         end
533         
534         def save_ged
535                 @window.config_db.conf["chemin_documents"] = @chemin_documents.text
536                 @window.config_db.conf["scanner"] = @scanner.text
537                 @window.config_db.conf["resolution"] = @resolution.text
538                 File.open(@chemin_config, 'w') do |out|
539                         YAML.dump(@window.config_db.conf, out)
540                 end
541         end
542         
543         def naviguer
544                 
545                 if !@soc_site.text.include?("http://")
546                         @soc_site.text = "http://" + @soc_site.text
547                 end
548                 
549                 if RUBY_PLATFORM.include?("linux") then 
550                         system "xdg-open #{@soc_site.text}" 
551                 else
552                         if RUBY_PLATFORM.include?("mingw") then 
553                                 # TODO
554                         else
555                                 
556                         end
557                 end
558         end
559         
560         def nouveau_logo
561                 dialog = Gtk::FileChooserDialog.new("Open File",
562                                                                  @window,
563                                                                  Gtk::FileChooser::ACTION_OPEN,
564                                                                  nil,
565                                                                  [Gtk::Stock::CANCEL, Gtk::Dialog::RESPONSE_CANCEL],
566                                                                  [Gtk::Stock::OPEN, Gtk::Dialog::RESPONSE_ACCEPT])
567                 filtre = Gtk::FileFilter.new
568                 filtre.add_pattern("*.png")
569                 dialog.filter = filtre
570                 if dialog.run == Gtk::Dialog::RESPONSE_ACCEPT
571                         fichier = dialog.filename
572                         chemin_dossier = "#{@window.config_db.conf["chemin_documents"]}/societe/"
573                         chemin = "#{chemin_dossier}#{File.basename(fichier)}"
574                         # on créer les dossiers si ils n'existent pas déjà
575                         Dir.mkdir(chemin_dossier) unless File.directory?(chemin_dossier)
576                         # on fait la copie de fichier
577                         FileUtils.cp fichier, chemin
578                         # Puis on créé une entrée en base de donnée pour la ged
579                         @soc_logo.file = chemin
580                         # Enfin on enregistre le choix dans la base de données
581                         societe = Societe.first
582                         societe.logo = File.basename(fichier)
583                         societe.save
584                 end
585                 dialog.destroy
586         end
587         
588         def quit
589         
590                 @window.tableau_bord.refresh
591                 @window.affiche @window.tableau_bord
592         
593         end
594         
595 end