<?php
if ( ! defined('ABSPATH') ) {
	exit;
}

/**
 * !! IMPORTANT !!
 *
 * Do not edit this file!
 * To create a new template, simply create a folder in your current theme folder called 'primer'.
 * You can then copy this file into the 'primer' folder and edit that copy.
 * This will ensure that your template files are not overwritten if/when you update the Primer Receipts plugin.
 *
 */

do_action( 'primer_before_receipt_display' ); ?>
<?php $last_page = times_html(); ?>
<!DOCTYPE html>
<html <?php language_attributes(); ?>>

<head>
	<title><?php wp_title() ?></title>
	<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
	<meta charset="<?php bloginfo( 'charset' ); ?>" />
    <meta name="robots" content="noindex, nofollow">
	<style>
        @page {
            size: a4 portrait;
            margin: 0px !important;
            padding: 0px !important;
        }

        @media print {
            html,
            body {
                width: 200mm;
                height: 290mm;
                -webkit-print-color-adjust:exact !important;
                print-color-adjust:exact !important;
            }
            .page {
                margin: 0px;
                border: initial;
                border-radius: initial;
                width: initial;
                min-height: initial;
                box-shadow: initial;
                background: initial;
                page-break-after: always;
            }
        }
        body {
            font-family: DejaVu Sans, sans-serif;
            margin: 0px;
        }

        .page {
            width: 210mm;
            height: 290mm;
            margin: 0px;
        }
        body {
            margin: 0px;
            padding: 0px;
        }

        .invoice-box {
            margin-left: 20px;
            margin-right: 20px;
            font-size: 10px;
            color: #555;
            height: 287mm;
           position: relative;
        }

        .qrcodeimg_container {
            min-width: 90px;
            max-width: 90px;
            margin: 0px;
            padding: 0 12px 0 0;
        }

        .total_td_block {
			width: 263px;
		}

        .total_td_block .totals_table {
            width: 255px;
		}

        .total_container {
            margin-top: 0px;
            border-radius: 5px;
            overflow: hidden;
            margin-bottom: 0px;
            margin-right: 2px;
        }

        .total_container>.totals {
            border: 3px solid #555555;
            background-color: #555;
            border-radius: 2px !important;
        }

        .total_container>.totals p {
            padding: 4px;
            margin: 0px;
            font-size: 12px;
			white-space: nowrap;
        }

        .totals_table {
            border-spacing: 0;
            border-collapse: collapse;
            border: 0;
        }

        .totals_table tr {
            padding: 16px;
            border: none;
        }

        .totals_table td {
            border: none;

        }

        .invoice-box table {
            width: 100%;
            text-align: left;

        }

        .invoice-box .information_table {
            margin-bottom: 4px;
        }

        .totals_table tr:first-child td:last-child {
            border-radius: 0px 3px 0px 0px !important;
        }

        .totals_table tr:last-child td:last-child {
            border-radius: 0px 0px 3px 0px !important;
        }

        .invoice-box table td {
            padding: 0px 1px 1px 1px;
        }

        .invoice-box table tr.top table td {
            padding: 10px 10px 10px 10px;
        }

        .invoice-box table tr.top table td.logo_container {
            font-size: 30px;
            width: 50%;
            color: #333
        }

        .invoice-box table tr.information table td {
            padding-bottom: 40px
        }

        .product_table .products td:last-child {
            border: none !important;
        }

        .main_info_table tr {
            border: 1px solid #ddd;
            font-weight: 700;
            text-align: center;
            text-transform: uppercase;
        }

        .invoice-box table tr.details td {
            padding-bottom: 10px;
        }

        .invoice-box table tr.item td {
            border-bottom: 1px solid #eee
        }

        .invoice-box table tr.item.last td {
            border-bottom: none
        }

        .invoice-box table tr.total td:nth-child(2) {
            border-top: 2px solid #eee;
            font-weight: 700
        }

        .products  {
            border-bottom: 1px solid #545454;
            border-right: none;
            text-align: center;
        }

        .products p {
            height: 24px;
            font-size: 12px;
            margin: 4px;
        }

        .product_table {
            border-collapse: collapse;
        }

        .product_table .products td {
            font-size: 10px;
            text-align: center;
            border-right: 1px solid #555;
            padding: 5px;
        }

        .product_table .heading td {
            font-size: 10px;
            text-align: center;
            border-right: 1px solid white;
        }

        .product_table .heading td:last-child {
            border-right: none;
        }

        .main_info_table .heading p {
            margin: 4px;
        }

        .product_container {
            margin: 0px 2px 0px 3px;
            border: 1px solid #555;
            border-radius: 4px;
            overflow: hidden;
            height: 37%;
        }

        .rtl {
            direction: rtl;
        }

        .rtl table {
            text-align: right
        }

        .rtl table tr td:nth-child(2) {
            text-align: left
        }

        .pol_number {
            float: right;
        }

        .heading {
            background-color: #555;
            color: white;
        }

        .heading>td {
            height: 4px;
        }

        .information {
            border: 1px solid #555;
            border-radius: 4px;
            padding: 1px;
        }

        .main_info {
            border: 1px solid #555;
            border-radius: 4px;
            overflow: hidden;
            margin: 0px 3px 4px 3px;
        }

        .skin {
            color: #555;
        }

        .table_tax{
            text-align: center;
            vertical-align: middle;
        }

        .bold {
            color: #555;
            font-weight: bold;
        }

        .footer_container {
            position: absolute;
            bottom: 30px;
            width: 100%;
            margin: auto;
            page-brealk-after: always;
        }

        .header_table td {
            border: none;
        }

        .issuer_container {
            text-align: center;
            margin-top: 6px;
            text-transform: uppercase;
        }

        .issuer_container .issuer_name {
            font-size: 14px;
            font-weight: bold;
        }

        .company_activity {
            font-style: italic;
        }

        .issuer_container p {
            margin: 0px;
            font-size: 10px;
        }

        .gemh_issuer_p {
            font-style: italic;
        }

        .information_table {
            margin-top: 1px;
            table-layout: fixed;
            width: 100%;
        }

        .information_table td {
            padding: 1px !important;
            border: none;
            font-size: 10px;
            overflow-wrap: break-word;
        }

        .code_head_td {
            width: 14%;
        }

        .description_head_td {
            width: 32%;
        }

        .price_head_td {
            width: 8%;
        }

        .vat_head_td {
            width: 8%;
        }

        .blank_row.bordered td {
            border-top: 1px solid white;
            background-color: white;
            max-height: 2px;
            height: 2px;
            line-height: 2px;
        }

        .text-right {
            text-align: right;
            margin-right: 20px;
            background-color: white;
            border: 1px solid #555 !important;
        }

        .text-left {
            background-color: #555;
            color: white;
        }

        .info_value {
            font-weight: bold;
        }

        .info_value_tax {
            float:left;
            font-weight: bold;
        }

        .cont_notation {
            border: 1px solid #555;
            padding: 8px;
            border-radius: 8px;
           overflow: hidden;
            overflow-wrap: break-word;
            margin-top: 10px;
            max-height: 150px;
            width: 260px;
            width: 260px;
        }

        .cont_signs {
			box-sizing: border-box;
			text-align: center;
        }

        .footer_table td {
            vertical-align: bottom;
        }

        .per_vat_totals_container {
            border: 1px solid #555;
            border-radius: 8px;
            margin-top: 10px;
            max-width: 280px;
        }

        .totals_per_vat th {
            width: 10%;
            color: #555;
            height: 5%;
            font-weight: bold;
        }

        .total_funny_box {
            width: 80px;
            height: 46px;
            background-color: #555;
            border: 1px solid white;
            border-radius: 0px 0px 8px 0px;
            position: absolute;
            bottom: 60px;
            right: -2px;
            z-index: -1;
            display: none;
        }

        .union_doc_sign {
            position: absolute;
            transform: translate(-5px, -50%) rotate(-90deg);
            left: -164px;
            bottom: 50%;
            font-size: 11px;
            margin: 0px;
        }

        .count_totals_container {
            padding: 4px;
            border: 1px solid #555;
            border-radius: 5px;
            max-height: 16px;
            overflow: hidden;
            margin-top: 10px;
            margin-bottom: 4px;
            margin-right: 2px;
        }

        .count_totals_container > span {
			vertical-align: middle;
            line-height: 18px;
            margin: 0px;
		}

        .count_total_prods {
            font-size: 16px;
            font-weight: bold;
			vertical-align: middle;
			float: right;
        }

        .cont_sign_left {
            float: left;
            text-align: center;
            width: 50%;
            font-size: 12px;
        }

        .cont_sign_right {
            float: right;
            text-align: center;
            width: 50%;
            font-size: 12px;
        }

        .fullname_sign {
            font-size: 9px;
        }

        .sign_hr {
            margin: 0px;
            width: 80%;
            margin-left: 10%
        }

        .finalprice p {
            font-weight: bold;
            font-size: 16px !important;
        }

        .information_td_left {
            width: 50%;
            font-size: 12px;
            overflow: hidden;
            height: auto;
        }

        .information_td_right {
            width: 50%;
            font-size: 12px;
            overflow: hidden;
            height: auto;
        }

        .uid_sign_bold{
            font-size: 12px;
            font-weight: bold;
        }

		.watermark_message {
			position: absolute;
            transform: translate(-5px, -30%) rotate(-45deg);
			left: 0;
			bottom: 25%;
            font-size: 222px;
            margin: 0;
            color: #cdcdcd;
			text-transform: uppercase;
			opacity: .7;
		}

        .paging {
            margin-top: 2px;
            float:right;
            font-size: 12px;
        }

        .table_titles {
            text-align: center;
            font-weight: bold;
            text-decoration: underline;
            margin: 1px 0px 1px 0px;
        }

        .link_sign {
            margin: 0px;
            padding-left: 5px;
        }

        .auth-code {
            padding-left: 5px;
        }

        .product-qr-code-img {
            border: 1px solid #555;
            border-radius: 8px;
        }

        table.main_info_table {
            width: 103% !important;
            padding: 1px !important;
            margin: -5px 20px 0px -15px !important;
        }

	</style>
</head>

<body style="font-family: 'DejaVu Sans', sans-serif;">
<?php //pagination for html according to product account
for($i =1; $i<=times_html(); $i++){?>
	<div class="page">
	<div class="invoice-box">
		<div class="top_table">
            <?php if(get_customer_country() == 'GR'){ ?>
            <div class="paging">Σελίδα:<?php echo esc_attr($i)?> από <?php echo esc_attr($last_page)?></div>
            <?php }else{?>
            <div class="paging">Page:<?php echo esc_attr($i)?> of <?php echo esc_attr($last_page)?></div>
            <?php } ?>
			<table>
				<tbody>
				<tr class="top">
					<td>
						<table class="header_table">
							<tr>
								<td class="logo_container"><?php primer_display_issuer_logo(); ?></td>

								<td class="issuer_container">
									<?php primer_display_issuer_container(); ?>
								</td>
							</tr>
						</table>
					</td>
				</tr>
				</tbody>
			</table>
			<div class="main_info">
				<table>
					<tbody>
					<tr>
						<td>
							<table class="main_info_table">
								<tbody>
								<?php primer_main_info_table_head(); ?>
								<?php primer_display_invoice_information(); ?>
								</tbody>
							</table>
						</td>
					</tr>
					</tbody>
				</table>
			</div>
			<?php
			$find_invoice_in_slug = '';
			$invoice_type = get_the_terms(get_the_ID(), 'receipt_status');
			if (is_array($invoice_type)) {
				$invoice_type_slug = $invoice_type[0]->slug;
				$invoice_type_name = explode('_', $invoice_type_slug);
                if(array_key_exists(1, $invoice_type_name)){
                    $find_invoice_in_slug = $invoice_type_name[1];
                }
			}

			if (isset($_GET['receipt']) || $find_invoice_in_slug !== 'receipt') { ?>
				<table class="information_table">
					<tbody>
					<tr>
						<td class="information_td_left">
							<div class="information left">
								<?php primer_display_left_customer_info(); ?>
							</div>
						</td>
						<td class="information_td_right">
							<div class="information right">
								<?php primer_display_right_customer_info(); ?>
							</div>
						</td>
					</tr>
					</tbody>
				</table>
                <script>
                    window.addEventListener("load", function() {
                        var rightInfoList = document.querySelectorAll('.information.right');
                        var leftInfoList = document.querySelectorAll('.information.left');

                        for (var i = 0; i < rightInfoList.length; i++) {
                            var leftInfo = leftInfoList[i];
                            var rightInfo = rightInfoList[i];

                            var leftInfoHeight = leftInfo.clientHeight;
                            var rightInfoHeight = rightInfo.clientHeight;

                            if (leftInfoHeight > rightInfoHeight) {
                                rightInfo.style.height = leftInfoHeight + 'px';
                            } else if (rightInfoHeight > leftInfoHeight) {
                                leftInfo.style.height = rightInfoHeight + 'px';
                            }
                        }
                    });
                </script>

            <?php } ?>
		</div>
		<div class="product_container">
			<table class="product_table">
				<?php primer_display_issuer_product_head(); ?>
				<?php primer_display_issuer_product($i,$last_page); ?>
			</table>
		</div>
		<div class="footer_container">
			<table class="footer_table">
				<tbody>
				<tr>
					<td style="width: 150px; overflow-wrap:break-word;">
                        <?php if($i == $last_page){ ?>
                        <div class="per_vat_totals_container">
                            <table class="totals_per_vat">
                                <?php primer_display_issuer_tax_total(); ?>
                            </table>
                        </div>
                        <?php } ?>
						<?php primer_display_issuer_comments(); ?>
					<td class="qrcodeimg_container">
						<div class="cont_signs">
                            <?php primer_get_generated_qr(); ?>
                        </div>
					</td>
					<td class="total_td_block">
                        <?php if($i == $last_page){ ?>
						<div class="count_totals_container">
							<span><?php primer_sum_unit_title(); ?></span> <span class="count_total_prods"><?php primer_sum_unit_count(); ?></span>
						</div>
                    <?php } ?>
						<div class="total_container">

							<?php primer_display_issuer_order_total_price($i,$last_page); ?>
						</div>
					</td>
				</tr>
				</tbody>
			</table>
			<p class="link_sign"> <span class="sender_sign">https://primer.gr/searchinvoice Provided by Primer Software P.C.</span></p>
            <p class="link_sign"> <span class="sender_sign">Άδεια ΥΠΑΗΕΣ: 2021_01_107Primer Software ΙΚΕ_001_ Primer MyData_V1_21012021</span></p>
			<p class="link_sign mydata_sign">
                <span class="uid_sign"> <?php  get_failure_message() ?></span>
				<span>UID:</span> <span class="uid_sign"><?php primer_invoice_uid(); ?></span>
                <span>Μ.ΑΡ.Κ.:</span> <span class="mark_sign"><?php primer_invoice_mark(); ?></span></p>
				<span class="auth-code">AUTHENTICATION CODE:</span> <span class="authcode_sign"><?php primer_invoice_authcode(); ?></span>
            </p>
        </div>


	</div>
		<?php primer_display_watermark(); ?>

</div>
<?php if($i != $last_page){ ?>
<div style="page-break-before: always !important;"></div>
<?php  } ?>
<?php  } ?>
</body>
</html>


