- content_for :title do Achats de %i - if @item #{@item.name} - elsif @user #{@user.username} - content_for :toolbar do - if @item = link_to new_for_users_admin_item_purchases_path(@item), class: 'btn btn-success' do %i.fa.fa-plus Ajouter un achat pour un groupe de membres = link_to t('links.back'), admin_items_path, class: 'btn btn-default' - elsif @user = link_to new_admin_user_purchase_path(@user), class: 'btn btn-success' do %i.fa.fa-plus Ajouter un achat = link_to t('links.back'), admin_users_path, class: 'btn btn-default' %table.table.table-striped %tr - if @item %th{colspan: 2} Membre - else %th= Item.human_attribute_name(:name) %th= Item.human_attribute_name(:description) %th Status %th Nombre de téléchargements %th - @purchases.each do |purchase| %tr - if @item %td{colspan: 2}= purchase.user.username - elsif @user %td= purchase.item.name %td= truncate_item_description(purchase.item.description) %td - if purchase - if purchase.active? - if purchase.downloads_count == 0 .text-success Actif - else .text-success Actif pour encore #{distance_of_time_in_words(purchase.active_time_remaining)} - else .text-warning Expiré %td= purchase.downloads_count %td.actions - if purchase.active? = button_to expire_admin_purchase_path(purchase), class: 'btn btn-danger', data: {confirm: t('links.are_you_sure')} do %i.fa.fa-download = t('links.expire') - else = button_to activate_admin_purchase_path(purchase), class: 'btn btn-warning', data: {confirm: t('links.are_you_sure')} do %i.fa.fa-download = t('links.activate') = link_to admin_purchase_path(purchase), method: :delete, 'data-confirm' => t('links.are_you_sure'), class: 'btn btn-danger' do %i.fa.fa-times = t('links.delete')