{% trans_default_domain 'deal' %}
{% extends 'base_home.html.twig' %}
{% block title %}{{ 'details.title'|trans({'{ deal }': entity.title}) }}{% endblock %}
{% set resolutionsLabels = {
'360': 'SD 360p',
'480': 'SD 480p',
'540': 'SD 540p',
'720': 'HD 720p',
'1080': 'HD 1080p',
'2160': 'uHD 4K',
'2880': 'uHD 5K',
'4320': 'uHD 8K',
} %}
{% block content %}
{% set hasCredits = true %}
{% set hasDownloads = false %}
{% set creditsState = 'login' %}
{% if is_granted('ROLE_USER') %}
{% set minimalBid = entity.createMinimalBid(app.user) %}
{% if entity.isInFundingPhase %}
{% if is_granted('HAS_CREDITS', minimalBid) %}
{% set creditsState = 'ok' %}
{% else %}
{% set hasCredits = false %}
{% set creditsState = 'not-enough' %}
{% endif %}
{% elseif entity.isFundingComplete %}
{# also please note that isFinished means both "downloadable" and "refunded" #}
{% set creditsState = 'finished' %}
{% if is_granted(constant('App\\Security\\Voter\\Bid\\HasPurchasedVoter::ATTRIBUTE'), minimalBid) %}
{% set hasDownloads = true %}
{% else %}
{% set hasDownloads = false %}
{% endif %}
{% endif %}
{% endif %}
<div class="nk-content pt-md-3 min-vh-100 pb-3">
<div class="container">
<div class="row deal-details mb-5 enable-loading-delay">
<div class="col-12">
<div class="contribution-wrap d-flex flex-column align-center">
<div class="row mb-4">
<div class="col-12">
<h3 class="text-center">{{ entity.title }}</h3>
</div>
</div>
<div class="row">
<div class="col-12">
<div class="d-flex justify-center flex-wrap">
<div class="badge badge-outline-dark badge-lg badge-pill fw-normal mr-2 mb-2" data-toggle="tooltip" data-bs-placement="top" title="{{ 'details.type_badage_tooltip'|trans }}">
<span>{{ 'details.type_badage'|trans }}</span>
</div>
<div class="badge badge-outline-dark badge-lg badge-pill fw-normal mr-2 mb-2">
<span>{{ 'minute.plural'|trans({count: entity.videoFile.durationMinutes|number_format(2, ':')}, 'messages') }}</span>
</div>
{% if entity.additionalVideoFiles | length == 0 %}
<div class="badge badge-outline-dark badge-lg badge-pill fw-normal mr-2 mb-2">
<span>{{ resolutionsLabels[entity.videoFile.resolution]|default(entity.videoFile.height ~ 'p') }}</span>
</div>
<div class="badge badge-outline-dark badge-lg badge-pill fw-normal mr-2 mb-2">
<span>{{ entity.videoFile.fileSize // 1024 }} MB</span>
</div>
{% endif %}
</div>
</div>
</div>
</div>
</div>
</div>
<div class="row deal-details mb-4 enable-loading-delay">
<div class="col-12 col-xxl-8 offset-xxl-2 col-xl-10 offset-xl-1">
<div style="max-width: 745px; margin: 0 auto;">
<div class="js-deal-slider gallery-slider">
{% for galleryItem in entity.proposalGalleryImages %}
{% if galleryItem.trailer is defined and galleryItem.image is defined %}
<a href="{{ galleryItem.trailer.webPath | sindrive_protect }}" data-fancybox="video_vidcaps">
<div class="deal-trailer rounded mr-1 mr-md-2">
<span class="trailer-play-handle rounded-circle">
<i class="icon dp-icon-video"></i>
</span>
<img src="{{ galleryItem.image.webPath | sindrive_resize(752, 423) | sindrive_timed_protect }}" class="img-fluid rounded preview" alt="{{ entity.title }}">
</div>
</a>
{% else %}
<div class="deal-trailer rounded">
{% if galleryItem.image is defined %}
<div class="screencap-item mr-1 mr-md-2">
<a href="{{ galleryItem.image.webPath | sindrive_protect | sindrive_resize(1920) }}" data-fancybox="video_vidcaps">
<img class="preview" src="{{ galleryItem.image.webPath | sindrive_resize(752, 423) | sindrive_timed_protect }}" alt="{{ entity.title }}">
</a>
</div>
{% endif %}
</div>
{% endif %}
{% endfor %}
</div>
</div>
</div>
</div>
</div>
<div class="container">
<div class="deal-details content rounded mb-5 enable-loading-delay">
<div class="row">
<div class="col-12 col-lg-8 offset-lg-2">
{% if not entity.expired %}
{% include 'deal/Block/deal_perkGrid.html.twig' %}
{% elseif entity.isFundingComplete and hasDownloads %}
{% set videoFiles = is_granted('ROLE_USER') ? entity.getVideoFilesByUser(app.user) : [] %}
{% if videoFiles | length > 0 %}
<div class="row">
<div class="col-12">
<h4 class="text-center">
{{ 'details.headline_downloads'|trans }}
</h4>
</div>
</div>
<div class="row mb-3">
<div class="col-12">
<hr>
</div>
</div>
<div class="row mb-6" id="downloads">
<div class="col-12">
<div class="p-2 pr-lg-4">
<div class="row hide-xs bg-light rounded">
<div class="col-12 col-sm-4 p-2 pl-4">
<strong>File</strong>
</div>
<div class="col-2 p-2">
<strong>{{ 'details.file_table.head.runtime'|trans }}</strong>
</div>
<div class="col-2 p-2">
<strong>{{ 'details.file_table.head.resolution'|trans }}</strong>
</div>
<div class="col-4 p-2">
<strong>{{ 'details.file_table.head.file_size'|trans }}</strong>
</div>
</div>
{% for fileIndex, videoFile in videoFiles %}
<div class="row pt-1 pb-2 pb-sm-1 {% if not loop.last %}border-bottom{% endif %}">
<div class="col-12 col-sm-4 p-2 pl-0 pl-sm-4">
<div class="text-ellipsis w-80">
<span class="fw-bold">
{{ videoFile.name | clean_video_filename }}
</span>
</div>
</div>
<div class="col-4 col-sm-2 p-2">
{{ videoFile.durationMinutes|number_format(2, ':') }}
</div>
<div class="col-4 col-sm-2 p-2 text-center text-sm-left">
{{ resolutionsLabels[videoFile.resolution] | default(videoFile.height ~ 'p') }}
</div>
<div class="col-4 col-sm-2 p-2 text-right text-sm-left">
<span>
{{ videoFile.fileSize // 1024 }} MB
</span>
</div>
<div class="col-12 col-sm-2 p-2">
<div class="d-flex justify-content-between">
{% if is_granted('ROLE_USER') and entity.isFundingComplete %}
{% set path = url('deal_download', {'id': entity.stringId, 'fileIndex': fileIndex}) %}
<a href="{{ path }}" target="_blank" class="btn btn-primary w-100 justify-center">
<i class="dp-icon-downloads ml-2 mr-2"></i>
</a>
{% else %}
<span class="btn btn-light btn-dim disabled w-100 justify-center">
<i class="dp-icon-downloads ml-2 mr-2"></i>
</span>
{% endif %}
</div>
</div>
</div>
{% endfor %}
</div>
</div>
</div>
{% endif %}
{% endif %}
<div class="row mb-6">
<div class="col-12">
<div class="row">
<div class="col-12">
{% if entity.tags|length > 0 %}
<div class="row">
<div class="col-12">
<div class="d-flex justify-center flex-wrap">
{% for tag in entity.tags %}
<div class="badge badge-pill badge-light font-weight-normal text-dark mr-1 mb-2">
<span>{{ tag.name }}</span>
</div>
{% endfor %}
</div>
</div>
</div>
{% endif %}
</div>
</div>
<div class="row">
<div class="col-12">
<hr>
</div>
</div>
<div class="row mb-4">
<div class="col-12">
<div class="pr-lg-4">
<p>
{{ entity.description | raw }}
</p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
{% if is_granted('ROLE_USER') %}
{% set purchaseCredits = get_crud_action('App\\Controller\\Settings\\PurchaseCreditsController', {'deal_id': entity.stringId, 'returnUrl': app.request.requestUri}) %}
{% include 'settings/purchase_credits.html.twig' with purchaseCredits.params | merge({'reference': get_reference(entity), 'hasCredits': hasCredits}) %}
{% if (app.request.hasPreviousSession or app.session.started) and app.session.flashBag.get('contribution-success') %}
{% include 'partials/base_overlay.html.twig' with {
icon: 'dp-icon-heart',
title: 'details.purchase.success'|trans,
subtitle: ['details.purchase.success_subtitle'|trans]
} %}
{% endif %}
{% if not entity.expired and creditsState == 'ok'%}
<div class="d-none">
{{ render_crud_result('App\\Controller\\Deal\\PurchaseController', {'stringId': entity.stringId}) }}
</div>
{% endif %}
{% endif %}
{% include 'partials/flash_message_popup.html.twig' %}
{% endblock %}