<link href="<?php echo base_url() ?>public/css/style.bundle_front.css"
      rel="stylesheet" type="text/css" />
<link href="<?php echo base_url() ?>public/css/custom_css.css"
      rel="stylesheet" type="text/css" />
<style>
    .label {
        border-radius: 0%;
        width: 100%;
        font-weight: bold;
        font-size: 11px;
    }
    .first_ele{
        text-align: left;
    }
    .last_ele{
        text-align: right;
    }
    .rtl .first_ele{
        text-align: right;
    }
    .rtl .last_ele{
        text-align: left;
    }
    .rtl .table{
        text-align: right;
    }
    .first_notes{
        float: left;
    }
    .last_notes{
        float: right;
    }
    .rtl .first_notes{
        float: right;
        text-align: right;
    }
    .rtl .last_notes{
        float: left;
        text-align: right;
    }
    .rtl{
        direction: rtl;
    }
    .f-18{
        font-size: 18px;
    }
    .f-16{
        font-size: 16px;
    }
    .f-15{
        font-size: 15px;
    }
    .table_header{
        color: #464E5F !important;
        font-size: 17px !important;
    }
    body{
        font-family: Almarai !important;
    }
    .comment{
        width: 20%;
    }
</style>
<?php
if ($this->session->userdata('language') == "english") {
    $language_set = "arabic";
} else {
    $language_set = "english";
}
?>
<div class="card card-custom overflow-hidden <?= $language_set == 'english' ? 'rtl' : '' ?>" >
    <div class="card-body p-0">
        <!-- begin: Invoice-->
        <!-- begin: Invoice header-->
        <div class="row justify-content-center py-8 px-8 py-md-27 px-md-0">
            <div class="col-md-9">
                <div class="d-flex justify-content-between pb-10 pb-md-20 flex-column flex-md-row">
                    <h1 class="display-4 font-weight-boldest mb-10"><?= strtoupper($this->lang->line('invoice')) ?></h1>
                    <div class="d-flex flex-column align-items-md-end px-0">
                        <!--begin::Logo-->
                        <a href="#" class="mb-5">
                            <img style="width: 100px" src="<?= base_url() ?>public/upload/userimage/<?= $this->config->item('invoice_logo') ?>" alt="" />
                        </a>
                        <!--end::Logo-->
                        <span class="d-flex flex-column align-items-md-end opacity-70">
                            <span><?php echo $this->config->item('company_address') ?></span>
                            <span><?php echo $this->config->item('company_email') ?></span>
                            <span><?php echo $this->lang->line('phone') ?><?php echo $this->config->item('company_mobile') ?></span>
                        </span>
                    </div>
                </div>
                <div class="border-bottom w-100"></div>
                <div class="d-flex justify-content-between pt-6">
                    <div class="d-flex flex-column flex-root first_ele">
                        <span class="font-weight-bolder mb-2"><?= $this->lang->line('data') ?></span>
                        <span class="opacity-70"><?= date('M d, Y', strtotime($show['date_now'])) ?></span>
                    </div>
                    <div class="d-flex flex-column flex-root text-center">
                        <span class="font-weight-bolder mb-2"><?= $this->lang->line('invoice_num') ?></span>
                        <span class="opacity-70">INV <?= str_pad($show['id_orders'], 6, "0", STR_PAD_LEFT); ?></span>
                    </div>
                    <div class="d-flex flex-column flex-root last_ele">
                        <span class="font-weight-bolder mb-2"><?= $this->lang->line('invoice_to') ?></span>
                        <span class="opacity-70"><?= $show['username'] ?> <br /><?= $show2['phone'] ?></span>
                    </div>
                </div>
            </div>
        </div>
        <!-- end: Invoice header-->
        <!-- begin: Invoice body-->
        <div class="row justify-content-center py-8 px-8 py-md-10 px-md-0">
            <div class="col-md-9">
                <div class="table-responsive">
                    <table class="table">
                        <thead>
                            <tr>
                                <th class="pl-0 text-muted text-uppercase table_header"><?= $this->lang->line('product') ?></th>
                                <th
                                    class="text-right text-muted text-uppercase table_header eshtraq"><?= $this->lang->line('start-date') ?></th>
                                <th
                                    class="text-right text-muted text-uppercase table_header eshtraq"><?= $this->lang->line('end-date') ?></th>

                                <th
                                    class="text-right pr-0 text-muted text-uppercase qu table_header"><?= $this->lang->line('quantity') ?></th>
                                <th
                                    class="text-right pr-0 text-muted text-uppercase table_header"><?= $this->lang->line('the-amount') ?></th>
                                <th
                                    class="text-right pr-0 text-muted text-uppercase discount table_header"><?= $this->lang->line('discount') ?></th>
                                <th
                                    class="text-right pr-0 text-muted text-uppercase table_header comment"><?= $this->lang->line('comment') ?></th>
                            </tr>
                        </thead>
                        <tbody>
                            <?php
                            $qu = $discount = $eshtraq = $comment = FALSE;
                            foreach ($producer as $value) {
                                ?>
                                <tr class="font-weight-boldest font-size-lg">
                                    <td class="pl-0 pt-7 f-15"><?= $sett->inv_lang == 0 ? $value->prod_name_en : $value->prod_name_ar ?></td>
                                    <?php
                                    if ($value->start_date) {
                                        $eshtraq = TRUE;
                                        ?>
                                        <td class="text-right pt-7"><?= date('d/m/Y', strtotime($value->start_date)) ?></td>
                                    <?php } ?>
                                    <?php
                                    if ($value->expiry_date) {
                                        $eshtraq = TRUE;
                                        ?>
                                        <td class="text-right pt-7"><?= date('d/m/Y', strtotime($value->expiry_date)) ?></td>
                                    <?php } ?>
                                    <?php
                                    if ($value->quantity != 0) {
                                        $qu = TRUE;
                                        ?>
                                        <td class="pr-0 pt-7 text-right f-15"><?= $value->quantity ?></td>
                                    <?php } ?>
                                    <td class="text-danger pr-0 pt-7 text-right f-15"><?= $value->payment ?> <?= $sett->inv_currency ?></td>
                                    <?php
                                    if ($value->discount) {
                                        $discount = TRUE;
                                        ?>
                                        <td class="pr-0 pt-7 text-right f-15"><?= $value->discount ?> <?= $sett->inv_currency ?></td>
                                    <?php } ?>
                                    <?php
                                    if ($value->comment) {
                                        $comment = TRUE;
                                        ?>
                                        <td class="pr-0 pt-7 text-right"><?= $value->comment ?></td>
                                    <?php } ?>

                                </tr>
                            <?php } ?>
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
        <!-- end: Invoice body-->
        <!-- begin: Invoice footer-->
        <div
            class="row justify-content-center bg-gray-100 py-8 px-8 py-md-10 px-md-0"
            style="margin: 0px">
            <div class="col-md-9">
                <div
                    class="d-flex justify-content-between flex-column flex-md-row font-size-lg">
                    <div class="d-flex flex-column mb-10 mb-md-0">
                        <div class="font-weight-bolder font-size-lg mb-3 f-18"><?php echo $this->lang->line('payment-status') ?></div>
                        <div class="d-flex justify-content-between mb-3">
                            <?php
                            if ($show['paid'] == '')
                                echo $this->lang->line('not-paid');

                            if ($show['paid'] == '1')
                                echo '<span class="label f-15">' . $this->lang->line('payment-is-made') . '</span>';
                            if ($show['paid'] == '3')
                                echo '<span class="label f-15">' . $this->lang->line('complimentary') . '</span>';
                            if ($show['paid'] == '4')
                                echo '<span class="label f-15">' . $this->lang->line('retriever') . '</span>';
                            ?>
                        </div>

                    </div>
                    <div class="d-flex flex-column text-md-right">
                        <span class="font-size-lg font-weight-bolder mb-1 f-18"><?= $this->lang->line('total_amount') ?> </span>
                        <span class="font-size-h2 font-weight-boldest text-danger mb-1"
                              style="text-align: center"><?= $price ? round($price->total_price, 3) : '' ?> <?= $sett->inv_currency ?></span>
                      <!-- <span>Taxes Included</span>  -->
                    </div>


                </div>
            </div>
        </div>

        <table class="table table-bordered table-hover table-striped">
            <tr>
                <td colspan="1"><?= $this->lang->line('region') ?></td>
                <td colspan="7"><?= $show['region'] ?></td>
            </tr>
            <tr>
                <td><?= $this->lang->line('block') ?></td>
                <td><?= $show['blocks'] ?></td>

                <td><?= $this->lang->line('street') ?></td>
                <td><?= $show['street'] ?></td>

                <td><?= $this->lang->line('jadah') ?></td>
                <td><?= $show['jadah'] ?></td>

                <td><?= $this->lang->line('floor') ?></td>
                <td><?= $show['floor'] ?></td>
            </tr>
            <tr>
                <td><?= $this->lang->line('door-number') ?></td>
                <td><?= $show['blocks'] ?></td>

                <td><?= $this->lang->line('door-number') ?></td>
                <td><?= $show['door_no'] ?></td>

                <td colspan="1"><?= $this->lang->line('address-link') ?></td>
                <td colspan="3"><?= $show['address_link'] ?></td>
            </tr>
        </table>

        <div class="row justify-content-center py-8 px-8 py-md-10 px-md-0"
             style="margin: 0px;padding-bottom: 0rem !important;">
            <div class="col-md-9">
                <div class="col-md-5 first_notes" >
                    <div class="font-weight-bolder font-size-lg mb-3 f-18"><?php echo $this->lang->line('terms-and-conditions') ?></div>
                    <div class="d-flex justify-content-between mb-3">
                        <?= $sett->inv_lang == 1 ? $sett->inv_footer_ar : $sett->inv_footer ?>
                    </div>
                </div>
                <div class="col-md-5 last_notes" >
                    <div class="font-weight-bolder font-size-lg mb-3 f-18"><?php echo $this->lang->line('notes') ?></div>
                    <div class="d-flex justify-content-between mb-3">
                        <?= $show['note'] ?>
                    </div>
                </div>
            </div>
        </div>
        <!-- end: Invoice footer-->
        <!-- begin: Invoice action-->
        <div class="row justify-content-center py-8 px-8 py-md-10 px-md-0"
             style="margin: 0px">
            <div class="col-md-9">
                <div class="d-flex justify-content-between">
                    <!-- <button type="button"
                            class="btn btn-light-primary font-weight-bold"
                            onclick="window.print();">Download Invoice</button>  
                     <button type="button" class="btn btn-primary font-weight-bold"
                            onclick="window.print();">Print Invoice</button> -->
                </div>
            </div>
        </div>
        <!-- end: Invoice action-->
        <!-- end: Invoice-->
    </div>
</div>

<?php $this->load->view('site/footer_2') ?>
<script type="text/javascript">
<?php if (!$qu) { ?>
        $(".qu").hide();
<?php } ?>
<?php if (!$discount) { ?>
        $(".discount").hide();
<?php } ?>
<?php if (!$eshtraq) { ?>
        $(".eshtraq").hide();
<?php } ?>
<?php if (!$comment) { ?>
        $(".comment").hide();
<?php } ?>
    setTimeout(function () {
        window.print();
        window.close();
    }
    , 2000)
</script>
