# -*- encoding : utf-8 -*- class Admin::PVolucompteursController < ApplicationController layout "admin" before_action :auth_admin before_action :admin_space def admin_space @admin_space = "tournees" end def new @p_ship_tour_truck = PShipTourTruck.find(params[:p_ship_tour_truck_id]) @p_ship_tour= @p_ship_tour_truck.p_ship_tour i = 0.0 last_volucompteur = PVolucompteur.where(:p_truck_id => @p_ship_tour_truck.p_truck_id).order("end_vol DESC").first i = last_volucompteur.end_vol if last_volucompteur if @p_ship_tour_truck.p_volucompteurs.count == 0 and !@p_ship_tour_truck.remorque @p_volucompteur = PVolucompteur.new(:p_ship_tour_truck => @p_ship_tour_truck, :start_vol => i, :p_truck_id => @p_ship_tour_truck.p_truck_id) else render :inline => "ERREUR" end end def edit @p_volucompteur = PVolucompteur.find(params[:id]) @p_ship_tour_truck = @p_volucompteur.p_ship_tour_truck @p_ship_tour= @p_ship_tour_truck.p_ship_tour end def create @p_volucompteur = PVolucompteur.new(params.require(:p_volucompteur).permit!) @p_ship_tour_truck = @p_volucompteur.p_ship_tour_truck @p_ship_tour= @p_ship_tour_truck.p_ship_tour if @p_volucompteur.save else render action: "new" end end def update @p_volucompteur = PVolucompteur.find(params[:id]) @p_ship_tour_truck = @p_volucompteur.p_ship_tour_truck @p_ship_tour= @p_ship_tour_truck.p_ship_tour if @p_volucompteur.update_attributes(params.require(:p_volucompteur).permit!) else render action: "edit" end end def destroy #@p_volucompteur = PVolucompteur.find(params[:id]) #@p_volucompteur.destroy end end