mmsc_app/app/views/admin/p_stats/index.html.haml
Nicolas Bally a6aa1f6074 Initial
2020-05-25 11:40:11 +02:00

229 lines
6.9 KiB
Plaintext

%p
%center
-date = (Date.today - 2.year).beginning_of_month
-while date < Date.today
-Date.today.beginning_of_month
-Date.today.end_of_month
=link_to raw("#{l(date, :format => '%B')}&nbsp;#{date.year}"), admin_p_stats_path(:start => date, :stop => date.end_of_month)
="-"
-date = date + 1.month
.qi_row
.qi_pannel.qi_plain.padding
=form_tag "", :method => "get", :remote => false, :onsubmit => "set_busy();" do
.row.qi_cancel_margins
.col-xs-4
.input-group
=text_field_tag :start, params[:start],:class => "form-control datepicker", :placeholder => "Début"
%span.input-group-addon.btn{:onclick => "$(this).prev('input').val('');"}
=ic(:times)
.col-xs-4
.input-group
=text_field_tag :stop, params[:stop],:class => "form-control datepicker", :placeholder => "Fin"
%span.input-group-addon.btn{:onclick => "$(this).prev('input').val('');"}
=ic(:times)
.col-xs-2
=submit_tag "filtrer", :class => "btn btn-default", :style => "margin-bottom: 10px;"
%p
-if @start and @stop
=link_to "< Mois précédent","?start=#{CGI.escape((@start - 1.month).beginning_of_month.strftime('%d/%m/%Y'))}&stop=#{CGI.escape((@stop - 1.month).end_of_month.strftime('%d/%m/%Y'))}", :class => "btn btn-default"
-if @start and @stop
=link_to "Mois suivant >","?start=#{CGI.escape((@start + 1.month).beginning_of_month.strftime('%d/%m/%Y'))}&stop=#{CGI.escape((@stop + 1.month).end_of_month.strftime('%d/%m/%Y'))}", :class => "btn btn-default"
%p
-if @start and @stop
=link_to "< Année précédente","?start=#{CGI.escape((@start - 1.year).beginning_of_month.strftime('%d/%m/%Y'))}&stop=#{CGI.escape((@stop - 1.year).end_of_month.strftime('%d/%m/%Y'))}", :class => "btn btn-default"
-if @start and @stop
=link_to "Année suivante >","?start=#{CGI.escape((@start + 1.year).beginning_of_month.strftime('%d/%m/%Y'))}&stop=#{CGI.escape((@stop + 1.year).end_of_month.strftime('%d/%m/%Y'))}", :class => "btn btn-default"
%hr
%h2
=#raw("#{l(@start_at, :format => '%B %Y')}")
%table.table
%tr
%td{:style => "width:50%;"}
=l @start
%td{:style => "width:50%;"}
=l @stop
%p
Nombre de commandes finalisées :
=orders_ok = @finished.count
-if false
%table
-@finished.each do |ps|
%tr
%td
=ps.a_ok_total
%td
=ps.a_total_cost_ok
%br
%strong=number_to_percentage ((@finished.count*100)/@p_customer_sheets.count), :precision => 2 if @p_customer_sheets.count > 0
%p
Nombre de commandes non finalisées :
=orders_not_ok = (@p_customer_sheets.count - @finished.count)
%p
CA HT :
%strong=number_to_currency @finished.sum(:a_ok_total)
-if @sans_marges.count > 0
%p{:style => "color:red;"}
Attention : le calcul des marges est faussé car certaines factures fournisseurs semblent ne pas être saisies, et donc certaines commandes n'ont pas pu être attribuées.
%p
Coût estimé HT :
-cout = @finished.sum(:a_total_cost_ok)
%strong=number_to_currency cout
%p
Marge estimée HT :
-marge = @finished.sum(:a_ok_total) - @finished.sum(:a_total_cost_ok)
%strong=number_to_currency(marge)
%br
%strong=number_to_percentage ((@finished.sum(:a_ok_total) - @finished.sum(:a_total_cost_ok))/@finished.sum(:a_ok_total)*100), :precision => 2 if @finished.sum(:a_ok_total) > 0.0
%div{:style => "width:350px;display:inline-block;"}
<canvas id="ordersChart" width="400" height="400"></canvas>
:javascript
var myPieChart = new Chart("ordersChart",{
type: 'pie',
data: {
labels: ["Finalisées", "Non finalisées"],
datasets: [{
label: '# of Votes',
data: [#{orders_ok},#{orders_not_ok}],
backgroundColor: [
'#4BC0C0',
'#FF6384',
],
borderColor: [
'white',
'white',
],
borderWidth: 2
}]
},
options: {
title: {
display: true,
text: 'Finalisation des commandes'
}
}
// options: options
});
%div{:style => "width:350px;display:inline-block;"}
<canvas id="margeChart" width="400" height="400"></canvas>
:javascript
var myPieChart = new Chart("margeChart",{
type: 'pie',
data: {
labels: ["Marge", "Cout"],
datasets: [{
label: '# of Votes',
data: [#{marge},#{cout}],
backgroundColor: [
'#4BC0C0',
'#FF6384',
],
borderColor: [
'white',
'white',
],
borderWidth: 2
}]
},
options: {
title: {
display: true,
text: 'Marges'
}
}
// options: options
});
-if false
<canvas id="myChart" width="400" height="200"></canvas>
:javascript
var ctx = document.getElementById("myChart");
var myChart = new Chart(ctx, {
type: 'bar',
data: {
labels: ["Red", "Blue", "Yellow", "Green", "Purple", "Orange"],
datasets: [{
label: '# of Votes',
data: [12, 19, 3, 5, 2, 3],
backgroundColor: [
'rgba(255, 99, 132, 0.2)',
'rgba(54, 162, 235, 0.2)',
'rgba(255, 206, 86, 0.2)',
'rgba(75, 192, 192, 0.2)',
'rgba(153, 102, 255, 0.2)',
'rgba(255, 159, 64, 0.2)'
],
borderColor: [
'rgba(255,99,132,1)',
'rgba(54, 162, 235, 1)',
'rgba(255, 206, 86, 1)',
'rgba(75, 192, 192, 1)',
'rgba(153, 102, 255, 1)',
'rgba(255, 159, 64, 1)'
],
borderWidth: 0
}]
},
options: {
scales: {
yAxes: [{
ticks: {
beginAtZero:true
}
}]
}
}
});