From 32c39322aee31e0498064bca0ac41dc3d02ee685 Mon Sep 17 00:00:00 2001 From: Nicolas Bally Date: Sun, 4 Dec 2011 20:34:00 +0100 Subject: [PATCH] version imprimable --- app/assets/stylesheets/print.css.scss | 66 ++++++++++++++++++ .../admin/prescriptions_controller.rb | 6 ++ app/views/admin/prescriptions/_show.html.haml | 12 +++- app/views/admin/prescriptions/print.html.haml | 37 ++++++++++ config/routes.rb | 1 + .../images/iconic/gray_light/print_16x16.png | Bin 0 -> 583 bytes 6 files changed, 119 insertions(+), 3 deletions(-) create mode 100644 app/assets/stylesheets/print.css.scss create mode 100644 app/views/admin/prescriptions/print.html.haml create mode 100644 vendor/assets/images/iconic/gray_light/print_16x16.png diff --git a/app/assets/stylesheets/print.css.scss b/app/assets/stylesheets/print.css.scss new file mode 100644 index 0000000..8b66955 --- /dev/null +++ b/app/assets/stylesheets/print.css.scss @@ -0,0 +1,66 @@ + + +body{ + font-family:arial; + +} +#pdf_prescription{ + a{ + text-decoration:none; + color:black; + display: inline-block; + background: #3c74a8; + background: -webkit-gradient(linear, 0% 100%, 0% 0%, from(rgb(239,242,242)), to(rgb(255,255,255))); + background: -moz-linear-gradient(bottom, rgb(239,242,242), rgb(255,255,255)); + box-shadow: rgba(0,0,0, 0.4) 0px 0px 3px; + -moz-box-shadow: rgba(0,0,0, 0.4) 0px 0px 3px; + -webkit-box-shadow: rgba(0,0,0, 0.4) 0px 0px 3px; + border: none; + -moz-border-radius: 20px; + -webkit-border-radius: 20px; + border-radius: 20px; + color: RGB(46,46,46); + + + + + padding: 5px 15px; + margin:30px 5px 0px 5px; + font-weight:normal; + + + } + +} + +.notes{ +padding:5px; +margin:5px; +font-size:15px; +border:1px solid #ffd148; +} +h2{ + .tel{ + float:right; + } + +} +#ship_info{ + border:1px solid #49bd22; + + height:16px; + + + padding:10px; + +} +.file{ + text-align:center; + img{ + + + } +} +.done{ + padding:5px; +} diff --git a/app/controllers/admin/prescriptions_controller.rb b/app/controllers/admin/prescriptions_controller.rb index 7138745..1ba8700 100644 --- a/app/controllers/admin/prescriptions_controller.rb +++ b/app/controllers/admin/prescriptions_controller.rb @@ -22,6 +22,12 @@ class Admin::PrescriptionsController < ApplicationController @prescription.read = true @prescription.save end + + def print + + @prescription = Prescription.find(params[:id]) + render :layout => false + end def delete end diff --git a/app/views/admin/prescriptions/_show.html.haml b/app/views/admin/prescriptions/_show.html.haml index c043d59..72c2d14 100644 --- a/app/views/admin/prescriptions/_show.html.haml +++ b/app/views/admin/prescriptions/_show.html.haml @@ -19,9 +19,11 @@ -if @prescription.file? -if @prescription.is_pdf? #pdf_prescription=link_to "Cette ordonnance est au format pdf. Cliquez-ici pour la visualiser.", @prescription.file.url, :target => "_blank" + -else - =image_tag @prescription.file.url, :style => "width:100%;" - =link_to "Cliquez-ici pour télécharger image dans une nouvelle fenêtre.", @prescription.file.url, :target => "_blank" + =image_tag @prescription.file.url, :style => "max-width:100%;max-height:100%;" + + =link_to "Cliquez-ici pour télécharger l'image dans une nouvelle fenêtre.", @prescription.file.url, :target => "_blank" @@ -45,4 +47,8 @@ =f.datetime_select :delivery_at, :order => [:day, :month, :year, :hour, :minute ] =f.submit "Sauvegarder" - .delete= link_to i(:trash_stroke, :gray_light), admin_prescription_path(@prescription), :confirm => 'Voulez-vous vraiment supprimer cette commande ?', :method => :delete + .delete + + = link_to i(:trash_stroke, :gray_light), admin_prescription_path(@prescription), :confirm => 'Voulez-vous vraiment supprimer cette commande ?', :method => :delete +    + =link_to i(:print, :gray_light), print_admin_prescription_path(@prescription), :target => "_blank" diff --git a/app/views/admin/prescriptions/print.html.haml b/app/views/admin/prescriptions/print.html.haml new file mode 100644 index 0000000..0904e47 --- /dev/null +++ b/app/views/admin/prescriptions/print.html.haml @@ -0,0 +1,37 @@ +!!! +%html{:lang => "fr"} + %head + %meta{:"http-equiv" => "content-type" ,:content =>"text/html;charset=UTF-8" } + %title="Impression ordonnance" + + + = stylesheet_link_tag 'print', :media => "all" + + + %body + + + + -if @prescription.done + #ship_info + La livraison est prévu le + =l @prescription.delivery_at + %h2 + .tel= @prescription.tel + =@prescription.name + .date=l @prescription.created_at + + + -if @prescription.notes? + .notes + =simple_format @prescription.notes + + .file + + -if @prescription.file? + -if @prescription.is_pdf? + #pdf_prescription=link_to "Annexe : scan au format pdf", @prescription.file.url, :target => "_blank" + + -else + =image_tag @prescription.file.url, :style => "max-width:100%;max-height:100%;" + \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index e1fc187..531f19f 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -99,6 +99,7 @@ Pharma::Application.routes.draw do get :done get :undone get :file + get :print end end diff --git a/vendor/assets/images/iconic/gray_light/print_16x16.png b/vendor/assets/images/iconic/gray_light/print_16x16.png new file mode 100644 index 0000000000000000000000000000000000000000..20d9a0ea5703527d33a6734e6ff614c2c68e2c9c GIT binary patch literal 583 zcmV-N0=WH&P)&dtMVh7z1_L^sP69kCl}h^}!WNzY8?lIBfXgCsK21|K8jZZx z`anc3vYl_hB|tgnY?35T4R8&3p_IC3jNxxkO5wd{I2@i9-~_P8KcbW(%Q7p#5_rIW zpp^0kXaWy`FTeoU2ke%551a(Lz?sb;z4wyG^#Qm5yajY2Lh`i-ZUT1-=VC-8^WFm- z108Iz?-Z?D(?3;hcLDhT*i?Y|>~naL)a3uvjd} zvaDEpw73zGGzfxMz@D}CQ|@MSZ>rTQVHg%QFM-d1ch0Fwr81t+=g*=j+WOY-0{}e* VsocbIL%9F|002ovPDHLkV1nN~^Ev