{% extends '@Public/common/general-layout.html.twig' %}
{% set user = campaign.user %}
{% set profile = user.profile %}
{% set share_text = generate_share_text(user)|trans %}
{% set page_url = url(constant('FMT\\Application\\Controller\\Common\\CampaignController::ROUTE_VIEW'), {id: campaign.id}) %}
{% set avatar = asset(get_user_avatar(user)) %}
{% set fb_share_link = generate_share_link({'u': page_url,}, 'fb') %}
{% set tw_share_link = generate_share_link({'url': page_url, 'text': share_text}, 'tw') %}
{% set endDate = campaign.endDate ? campaign.endDate|textual_month_format : 'fmt.widgets.campaign.header.not_set'|trans %}
{% set page_dicription = 'fmt.widgets.campaign.header.goal'|trans({'%price%': campaign.estimatedCost|price}) %}
{% set page_dicription = page_dicription ~ ' ' ~ 'fmt.widgets.campaign.header.ends'|trans({'%date%': endDate}) %}
{% set page_dicription = page_dicription ~ ' ' ~ 'fmt.widgets.campaign.header.progress'|trans({'%percent%': campaign.percentOfFunded|percent}) %}
{% block meta %}
{% include '@Public/common/campaign/_sharing_meta.html.twig' %}
{% endblock meta %}
{% block content %}
<section class="content campaign">
{% include '@Public/common/campaign/_paused_banner.html.twig' with {campaign: campaign} %}
<div class="row">
<div class="col-md-8">
{% include '@Public/components/campaign/studentInfoFull.html.twig' %}
</div>
<div class="col-md-4">
{% include '@Public/components/campaign/widget.html.twig' with {showAllBooks: true} %}
<div class="share-buttons-box">
{% if is_granted(constant('FMT\\Application\\Voter\\CampaignVoter::CAN_SHARE_FB'), campaign) %}
<a href="{{ fb_share_link }}"
class="btn btn-primary facebook-button share-button"
role="button"
target="_blank"
data-social="share"
>
<i class="fa fa-facebook-official"></i> {{ 'fmt.widgets.campaign.social.facebook'|trans }}
</a>
{% endif %}
{% if is_granted(constant('FMT\\Application\\Voter\\CampaignVoter::CAN_SHARE_TW'), campaign) %}
<a href="{{ tw_share_link }}"
class="btn btn-info twitter-button share-button"
role="button"
target="_blank"
data-social="share"
>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512" style="margin-bottom: -3px; fill: #fff; display: inline-block; height: 16px;">
<path d="M64 32C28.7 32 0 60.7 0 96V416c0 35.3 28.7 64 64 64H384c35.3 0 64-28.7 64-64V96c0-35.3-28.7-64-64-64H64zm297.1 84L257.3 234.6 379.4 396H283.8L209 298.1 123.3 396H75.8l111-126.9L69.7 116h98l67.7 89.5L313.6 116h47.5zM323.3 367.6L153.4 142.9H125.1L296.9 367.6h26.3z"/>
</svg>
{{ 'fmt.widgets.campaign.social.twitter'|trans }}
</a>
{% endif %}
</div>
</div>
</div>
<div class="box box-primary books-box books-box-view">
<div class="box-header with-border">
<div class="row">
<div class="col-xs-12 col-sm-10 margin-bottom-10">
<h3 class="box-title">
{{ 'fmt.campaign.textbooks.title'|trans }}
{% if campaign.endDate|date('U') < "now"|date('U') %}
<small>Campaign has ended.</small>
{% else %}
<small>{{ 'fmt.campaign.textbooks.title_small'|trans }}</small>
{% endif %}
</h3>
</div>
<div class="col-xs-2">
<div class="pull-right box-tools">
{% if is_granted(constant('FMT\\Application\\Voter\\CampaignVoter::CAN_FUND'), campaign) and
campaign.isActive and (userIsNotStudent or user.id == activeUserId or app.user == null) %}
<a class="btn btn-primary btn-sm btn-fix-text fmt-lightgreen" href="{{ donate_user_link(user) }}">
{{ campaign|fund_student_name|trans({'%name%': campaign.user.profile.firstName}) }}
</a>
{% endif %}
</div>
</div>
</div>
</div>
<div class="box-body">
<div class="table-responsive no-padding">
<table class="table table-striped">
<thead>
<tr>
<th style="width: 10px">#</th>
<th>{{ 'fmt.campaign.textbooks.table.header.title'|trans }}</th>
<th class="mobile-hide">Item Number</th>
<th class="text-right">{{ 'fmt.campaign.textbooks.table.header.cost'|trans }}</th>
<th class="text-right">{{ 'fmt.campaign.textbooks.table.header.tax'|trans }}</th>
</tr>
</thead>
<tbody>
{% for key, book in campaign.books %}
{{ include('@Public/components/campaign/bookRow.html.twig', {'item': book, 'key': key + 1}) }}
{% endfor %}
</tbody>
{% if is_granted(constant('FMT\\Application\\Voter\\CampaignVoter::CAN_SEE_SUMMARY'), campaign) %}
<tfoot class="summary">
<!--
<tr>
<td></td>
<td colspan="3" class="mobile-hide"></td>
<td class="text-right">{{ 'fmt.campaign.textbooks.table.footer.shipping'|trans }}: {{ campaign.shippingName }}</td>
<td class="text-right">{{ campaign.estimatedShipping|price }}</td>
</tr>
<tr>
<td></td>
<td colspan="3" class="mobile-hide"></td>
<td class="text-right">{{ 'fmt.campaign.textbooks.table.footer.tax'|trans }}</td>
<td data-field="estimated-tax" class="text-right">{{ campaign.estimatedTax|price }}</td>
<td></td>
</tr>
-->
<tr>
<td colspan="3" class="mobile-hide"></td>
<td colspan="2" class="text-right">{{ 'fmt.campaign.textbooks.table.footer.total'|trans }}</td>
<td class="text-right">{{ campaign.estimatedCost|price }}</td>
</tr>
<!--
<tr>
<td></td>
<td colspan="3" class="mobile-hide"></td>
<td class="text-right">{{ 'fmt.campaign.textbooks.table.footer.purchased'|trans }}</td>
<td class="text-right">{{ campaign.purchasedTotal|price }}</td>
</tr>
<tr>
<td></td>
<td colspan="3" class="mobile-hide"></td>
<td class="text-right">{{ 'fmt.campaign.textbooks.table.footer.funded'|trans }}</td>
<td class="text-right">{{ campaign.fundedTotal|price }}</td>
</tr>
-->
<tr>
<td colspan="3" class="mobile-hide"></td>
<td colspan="2" class="text-right">{{ 'fmt.campaign.textbooks.table.footer.remaining'|trans }}</td>
<td class="text-right">{{ campaign.allowedDonateAmount|price }}</td>
</tr>
<!--
<tr>
<td></td>
<td colspan="3" class="mobile-hide"></td>
<td colspan="3"><small>{{ 'fmt.campaign.textbooks.table.note.shipping'|trans|raw }}</small></td>
</tr>
-->
</tfoot>
{% endif %}
</table>
</div>
</div>
</div>
</section>
{% endblock content %}
{% block footer_scripts %}
{# TODO recheck template#}
{{ encore_entry_script_tags('common.campaign.view') }}
{{ encore_entry_script_tags('common.campaign.view_cart') }}
{% endblock footer_scripts %}