
<?php $this->load->view('site/layout'); ?>
<link href="<?php echo base_url() ?>public/css/style.bundle_front.css"
      rel="stylesheet" type="text/css" />
      <?php $this->load->view('site/navbar'); ?>
<style>
    .label {
        border-radius: 0%;
        width: 100%;
        font-weight: bold;
        font-size: 12px;
    }
    .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;
    }
    .comment{
        width: 20%;
    }
    .step_txt{
        margin-top: 5px;
        display: block;
    }
    .step_container{
        padding-left: 0px;
        padding-right: 0px;
    }
    .step{
        padding: 14px;
        border: #ccc solid 1px;
        border-radius: 50%;
        width: 100%;
        /*margin: 0px 4%;*/
    }
    .order_progress{
        margin-left: 12.5%;
        margin-right: 0px;
    }
    .rtl .order_progress{
        margin-right: 12.5%;
        margin-left: 0px;
    }
    .fa-2-5x{
        font-size: 2.4rem;
    }
    .col-1 hr{
        margin-top: 50px;
    }
    .active i,.active .step_txt{
        color: #1bc5bd;
    }
    .active,.active hr{
        border-color: #1bc5bd;
    }
</style>
<div
    class="kt-content  kt-grid__item kt-grid__item--fluid kt-grid kt-grid--hor"
    id="kt_content">

    <!-- begin:: Content Head -->
    <div class="kt-subheader  kt-grid__item" id="kt_subheader">
        <div class="kt-container  kt-container--fluid ">
            <div class="kt-subheader__main">
                <h3 class="kt-subheader__title">
                    <a href="<?php echo base_url() ?>Dashboard/"><?php echo $this->lang->line('dashboard'); ?></a>
                </h3>
                <span class="kt-subheader__separator kt-subheader__separator--v"></span>
                <span class="kt-subheader__desc"><?php echo $this->lang->line('invoices'); ?></span>
            </div>

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

<div
    class="kt-container  kt-container--fluid  kt-grid__item kt-grid__item--fluid"
    style="margin-bottom: 40px">
    <div class="card card-custom overflow-hidden">
        <div class="card-body p-0">
            <!-- begin: Invoice-->
            <!-- begin: Invoice header-->
            <?php
            if (get_license_per('order_status')) {
                $order_status = array('waiting' => 'fas fa-hourglass-half', 'preparing' => 'fas fa-box-open',
                    'ready_for_deliver' => 'fas fa-boxes', 'delivering' => 'fas fa-truck', 'delivered' => 'fas fa-people-carry',
                    'canceled' => 'fas fa-times-circle');
                ?>

                <div class="row mt-10 order_progress">
                    <?php
                    $i = 0;
                    foreach ($order_status as $txt => $icon) {
                        $active_status = order_was_in_status($show['id_orders'], $i);
                        if (($i == 4 && $show['order_status'] == 5) || ($i == 5 && $show['order_status'] != 5)) {
                            $i++;
                            continue;
                        }
                        if ($i != 0) {
                            ?>
                            <div class="col-1 <?= $active_status ? 'active' : '' ?>"><hr/></div>
                        <?php } ?>
                        <div class="col-1 step_container">
                            <div class='step text-center <?= $active_status || $i == 0 ? 'active' : '' ?>'>
                                <i class="<?= $icon ?> fa-2-5x"></i>
                                <span class="step_txt"><?= $this->lang->line($txt) ?></span>
                            </div>
                            <?php if ($active_status) { ?>
                                <div class="text-center mt-2">
                                    <span><?= adjust_timezone($active_status->date) ?></span><br/>
                                    <span><?= $active_status->name ? $active_status->name : $active_status->driver_name ?></span>
                                </div>
                            <?php } else if ($i == 0) { ?>
                                <div class="text-center mt-2">
                                    <span><?= adjust_timezone($show['date']) ?></span><br/>
                                    <span><?= $show['created_by_name'] ?></span>
                                </div>
                            <?php } ?>
                        </div>
                        <?php
                        $i++;
                    }
                    ?>
                </div>
            <?php } ?>

            <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>
                            <span class="opacity-70"><?= $show['delivery_type'] == 0 ? $this->lang->line('direct_recieve') : $this->lang->line('home_delivery') ?></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>
            <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 font-weight-bold text-muted text-uppercase"><?= $this->lang->line('product') ?></th>
                                    <th class="text-right font-weight-bold text-muted text-uppercase addition"><?= $this->lang->line('additions') ?></th>
                                    <th
                                        class="text-right font-weight-bold text-muted text-uppercase eshtraq"><?= $this->lang->line('start-date') ?></th>
                                    <th
                                        class="text-right font-weight-bold text-muted text-uppercase eshtraq"><?= $this->lang->line('end-date') ?></th>
                                    <th
                                        class="text-right pr-0 font-weight-bold text-muted text-uppercase qu"><?= $this->lang->line('quantity') ?></th>

                                    <th
                                        class="text-right pr-0 font-weight-bold text-muted text-uppercase"><?= $this->lang->line('the-amount') ?></th>
                                    <th
                                        class="text-right pr-0 font-weight-bold text-muted text-uppercase discount"><?= $this->lang->line('discount') ?></th>
                                    <th
                                        class="text-right pr-0 font-weight-bold text-muted text-uppercase comment"><?= $this->lang->line('comment') ?></th>
                                </tr>
                            </thead>
                            <tbody>
                                <?php
                                $qu = $discount = $eshtraq = $comment = $additions = FALSE;
                                foreach ($producer as $value) {
                                    ?>
                                    <tr class="font-weight-boldest font-size-lg">
                                        <td class="pl-0 pt-7"><?= $sett->inv_lang == 0 ? $value->prod_name_en : $value->prod_name_ar ?></td>
                                        <?php
                                        if (isset($value->additions)) {
                                            $additions = TRUE;
                                            ?>
                                            <td><?= $value->additions ?></td>
                                        <?php } ?>
                                        <?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"><?= $value->quantity ?></td>
                                        <?php } ?>
                                        <td class="text-danger pr-0 pt-7 text-right"><?= $value->payment ?> <?= $sett->inv_currency ?></td>
                                        <?php
                                        if ($value->discount) {
                                            $discount = TRUE;
                                            ?>
                                            <td class="pr-0 pt-7 text-right"><?= $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>

            <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"><?php echo $this->lang->line('payment-status') ?></div>
                            <div class="d-flex justify-content-between mb-3">
                                <?php
                                if ($show['paid'] == 2)
                                    echo $this->lang->line('not-paid');

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

                        </div>
                        <div class="d-flex flex-column mb-10 mb-md-0">
                            <div class="font-weight-bolder font-size-lg mb-3"><?php echo $this->lang->line('payment_method') ?></div>
                            <div class="d-flex justify-content-between mb-3">
                                <?php $payment_method = array('cash', 'Knit', 'Visa/Master', 'link') ?>
                                <?= $this->lang->line($payment_method[$show['payment_method']]) ? $this->lang->line($payment_method[$show['payment_method']]) : $payment_method[$show['payment_method']] ?>
                            </div>
                        </div>
                        <div class="d-flex flex-column mb-10 mb-md-0 text-right">
                            <div class="font-weight-bolder font-size-lg mb-3"><?php echo $this->lang->line('payment_time') ?></div>
                            <div class="d-flex justify-content-between mb-3 text-center">
                                <?= $show['payment_time'] ? str_replace(' ', '<br/>', $show['payment_time']) : '---' ?>
                            </div>
                        </div>
                        <div class="d-flex flex-column text-md-right">
                            <span class="font-size-lg font-weight-bolder mb-1"><?= $this->lang->line('total_amount') ?></span>
                            <span class="font-size-h2 font-weight-boldest text-danger mb-1"
                                  style="text-align: center"><?= $price ? $price->total_price : '' ?> <?= $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_address') ?></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('building_num') ?></td>
                    <td><?= $show['building_num'] ?></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"><?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"><?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>
</div>

<?php $this->load->view('site/footer_2') ?>
<script>
<?php if (!$qu) { ?>
        $(".qu").hide();
<?php } ?>
<?php if (!$discount) { ?>
        $(".discount").hide();
<?php } ?>
<?php if (!$eshtraq) { ?>
        $(".eshtraq").hide();
<?php } ?>
<?php if (!$comment) { ?>
        $(".comment").hide();
<?php } ?>
<?php if (!$additions) { ?>
        $(".addition").hide();
<?php } ?>

</script>
