<?php $this->view("includes/Inc_pagehead");?>
<!-- Page Styles Goes Here-->
<style>
.m-invoice-2 .m-invoice__wrapper .m-invoice__body table thead tr th {
  color: #000000;
}
.m-invoice-2 .m-invoice__wrapper .m-invoice__body table tbody tr td {
  color: #404040;
}
.item_table td{
  padding: .75rem !important;
}
.item_table th{
  white-space: nowrap;
  padding: .75rem !important;
}
.table thead th {
  border-top: <?php echo $this->config->item('Quotation_table_border')?>px solid black !important;
}
.table thead th {
  border: <?php echo $this->config->item('Quotation_table_border')?>px solid black !important;
}
.table tbody td {
  border: <?php echo $this->config->item('Quotation_table_border')?>px solid #d8d7d7;
}
.payment-table tbody td{
  border-top: 1px solid #d8d7d7 !important;
}
.m-invoice-2 .m-invoice__wrapper .m-invoice__head .m-invoice__container.m-invoice__container--centered {
  width: 90%;
}
.m-invoice-2 .m-invoice__wrapper .m-invoice__body.m-invoice__body--centered {
  width: 90%;
  padding: 0px !important;
}
.m-invoice-2 .m-invoice__wrapper .m-invoice__body table thead tr th {
  padding: 1.1rem -0.5rem 0.1rem 0.5rem !important;
  font-size: 13px!important;
}
.m-invoice-2 .m-invoice__wrapper .m-invoice__body table tbody tr td {
  padding: 0.4rem 0.5rem 0.5rem 0.5rem !important;
  font-size: 13px!important;
  font-weight:normal;
}

@media print
{
  body * {
    visibility: hidden;
  }
  .m-portlet__body * {
    visibility: visible;
    overflow: visible !important;
  }
  .table-bordered td{
    /* padding: .75rem !important; */
  }
  .table-bordered th{
    white-space: nowrap;
    /* padding: .75rem !important; */
  }
  .table-bordered .table thead th {
    border-top: <?php echo $this->config->item('Quotation_table_border')?>px solid black !important;
  }
  .table-bordered .table thead th {
    border: <?php echo $this->config->item('Quotation_table_border')?>px solid black !important;
  }
  .table.table-striped thead th {
    border: <?php echo $this->config->item('Quotation_table_border')?>px solid #f4f5f8 !important;
  }
  .m-invoice-2 .m-invoice__wrapper .m-invoice__head .m-invoice__container.m-invoice__container--centered {
    width: 92% !important;
  }
  .m-invoice-2 .m-invoice__wrapper .m-invoice__body.m-invoice__body--centered {
    width: 92% !important;
  }
  .m-invoice-2 .m-invoice__wrapper .m-invoice__body.m-invoice__body--centered {
    padding-top: 0rem !important;
  }
  .m-invoice__items_row{
    padding-left: 0px !important;padding-right: 0px !important;
  }
  .m-invoice__container{
    width: 92% !important;
  }
  .m-content{
    padding: 0px !important;
  }
  #print_view {
    margin-top: -20%;
  }
  #print, .print_hide_div
  {
    display: none !important;
  }
  .m-portlet .m-portlet__head {
    /* display: none !important;
    height: 0px !important; */
  }
  body.m-content--skin-light2 {
    background-color: white !important;
  }

}

@media print {

  .m-invoice__subtitle{
    font-size: 13px!important;
  }
  .m-portlet__head{
    height: 0px !important;
  }
  .m-content{
    padding: 0px !important;
  }
  .page-header, .page-header-space {
    height: <?php echo $this->config->item('Quotation_header_height') ?>;
  }
  .page-footer, .page-footer-space {
    height: <?php echo $this->config->item('Quotation_footer_height') ?>;
  }
  .page-footer {
    position: fixed;
    bottom: 0;
    width: 100%;
    display:block !important;
  }
  .page-header {
    position: fixed;
    top: 0mm;
    width: 100%;
    display:block !important;
  }
  .page {
    page-break-after: always;
  }

  @page {
    margin: 9mm;
    size: A4;
  }
  thead {display: table-header-group;}
  tfoot {display: table-footer-group;}
  button {display: none;}
  body {margin: 0;}

}
@media (max-width: 768px){
  .m-invoice-2 .m-invoice__wrapper .m-invoice__head .m-invoice__container .m-invoice__items .m-invoice__item {
    display: table-cell !important;
    padding-bottom: .3rem;
  }
  .m-invoice-2 .m-invoice__wrapper .m-invoice__head .m-invoice__container.m-invoice__container--centered {
    padding: 0 !important;
  }
}
.total_text{
  font-weight: 600!important;
}



</style>
<?php $this->view("includes/Inc_navigation");?>
<div class="m-grid__item m-grid__item--fluid m-wrapper">
  <!-- BEGIN: Subheader -->
  <div class="m-subheader ">
    <div class="d-flex align-items-center">
      <div class="mr-auto">
        <h3 class="m-subheader__title m-subheader__title--separator">
          Sales Quotation
        </h3>
        <ul class="m-subheader__breadcrumbs m-nav m-nav--inline">
          <li class="m-nav__item m-nav__item--home">
            <a href="#" class="m-nav__link m-nav__link--icon">
              <i class="m-nav__link-icon la la-home"></i>
            </a>
          </li>
          <li class="m-nav__separator">
            -
          </li>
          <li class="m-nav__item">
            <a href="<?php echo base_url().'dashboard'?>" class="m-nav__link">
              <span class="m-nav__link-text">
                Home
              </span>
            </a>
          </li>
          <li class="m-nav__separator">
            -
          </li>
          <li class="m-nav__item">
            <a href="<?php echo base_url().'sales_quotation' ?>" class="m-nav__link">
              <span class="m-nav__link-text">
                Sales Quotation
              </span>
            </a>
          </li>
        </ul>
      </div>
      <div>
      </div>
    </div>
  </div>
  <!-- END: Subheader -->
  <div class="m-content">
    <div class="m-portlet m-portlet--full-height">
      <div class="m-portlet__head">
        <div class="m-portlet__head-caption">
          <div class="m-portlet__head-title">
            <h3 class="m-portlet__head-text">
              Quotation No: <?php
              if($this->config->item('Quotation_sales_quotation_no_manual')==1){
                echo $quotation_data->quotation_no_suffix;
              }else{
                if($quotation_data->quotation_prefix!=''){
                  $quotation_data->quotation_prefix = $quotation_data->quotation_prefix."-";
                }
                if($quotation_data->quotation_no_prefix!=''){
                  $quotation_data->quotation_prefix = $quotation_data->quotation_no_prefix;
                }
                $quotation_data->quotation_no = sprintf("%04d", $quotation_data->quotation_no);
                echo '#'.$quotation_data->quotation_prefix.$quotation_data->quotation_no.$quotation_data->quotation_no_suffix;
              }
              ?>
            </h3>
          </div>
        </div>
        <div class="m-portlet__head-tools" >
          <?php if($quotation_data->approval_status==1){?>
            <?php if($this->config->item('app_module_work_order') == 1){?>
              <a href="<?php echo base_url().'work_order/add?quotation_id='.$quotation_data->quotation_id?>" style="margin-left: 5px;margin-right: 5px" class="btn m-btn--gradient-from-success m-btn--gradient-to-danger  m-btn  m-btn--icon m-btn--air m-btn--pill">
                <span>
                  <i class="fa fa-plus-circle"></i>
                  <span>
                    Create Work Order
                  </span>
                </span>
              </a>
            <?php } ?>
          <?php } ?>
          <a style="margin-left: 5px;margin-right: 5px"  id="btn_print_sales_quotation" class="btn m-btn--gradient-from-warning m-btn--gradient-to-danger  m-btn  m-btn--icon m-btn--air m-btn--pill">
            <span>
              <i class="la la-print"></i>
              <span>
                Print Quotation
              </span>
            </span>
          </a>
          <a href="<?php echo base_url().'sales_quotation/add?clone='.$quotation_data->quotation_id?>" style="margin-left: 5px;margin-right: 5px" class="btn m-btn--gradient-from-info m-btn--gradient-to-focus  m-btn  m-btn--icon m-btn--air m-btn--pill">
            <span>
              <i class="fa fa-copy"></i>
              <span>
                Clone Quotation
              </span>
            </span>
          </a>
          <?php if($this->session->userdata('user_role')=='admin' || $this->session->userdata('user_role')=='general_manager' || ($this->session->userdata('user_id')==$quotation_data->created_by) ){ ?>
            <a href="<?php echo base_url().'sales_quotation/edit/'.$quotation_data->quotation_id?>" style="margin-left: 5px;margin-right: 5px" class="btn m-btn--gradient-from-focus m-btn--gradient-to-danger  m-btn  m-btn--icon m-btn--air m-btn--pill">
              <span>
                <i class="fa fa-edit"></i>
                <span>
                  Edit Quotation
                </span>
              </span>
            </a>
          <?php } ?>
          <?php if($quotation_data->approval_status!=1 && ($this->session->userdata('user_role')=='admin' || $this->session->userdata('user_role')=='general_manager')){?>
            <a style="margin-left: 5px;margin-right: 5px" href="#quotation_approve_modal" data-toggle="modal" class="btn m-btn--gradient-from-danger m-btn--gradient-to-info  m-btn  m-btn--icon m-btn--air m-btn--pill">
              <span>
                <i class="la la-check-circle"></i>
                <span>
                  Approve/Reject
                </span>
              </span>
            </a>
          <?php } ?>
        </div>
      </div>

      <div class="m-portlet__body m-portlet__body--no-padding" id="print_view">
        <div class="row print_hide_div">
          <div class="col-lg-2"></div>
          <div class="col-lg-8" style="margin-top: 20px;font-size:20px !important">
            <?php if($quotation_data->approval_status==1){?>
              <div class="m-alert m-alert--icon m-alert--icon-solid m-alert--outline alert alert-success fade show" role="alert">
                <div class="m-alert__icon">
                  <i class="fa fa-check-circle"></i>
                  <span></span>
                </div>
                <div class="m-alert__text">
                  <strong>Quotation Approved!</strong> <br/><?php echo $quotation_data->approval_remarks ?>
                </div>
              </div>
            <?php }elseif($quotation_data->approval_status==2){?>
              <div class="m-alert m-alert--icon m-alert--icon-solid m-alert--outline alert alert-danger fade show" role="alert">
                <div class="m-alert__icon">
                  <i class="fa fa-times-circle"></i>
                  <span></span>
                </div>
                <div class="m-alert__text">
                  <strong>Quotation Rejected!</strong> <br/><?php echo $quotation_data->approval_remarks ?>
                </div>
              </div>
            <?php }else{ ?>
              <div class="m-alert m-alert--icon m-alert--icon-solid m-alert--outline alert alert-warning fade show" role="alert">
                <div class="m-alert__icon">
                  <i class="flaticon-exclamation-1"></i>
                  <span></span>
                </div>
                <div class="m-alert__text">
                  <strong>Quotation Approval Pending!</strong>
                </div>
              </div>
            <?php } ?>
          </div>
        </div>
        <div class="page-header" style="display:none">
          <?php if($this->config->item('quotation_header')!=''){ ?>
            <img class="letter_head_img" style="width: 100%;" src="<?php echo base_url().'uploads/company/'.$this->config->item('quotation_header')?>" />
          <?php } ?>
        </div>
        <div class="page-footer" style="display:none">
          <?php if($this->config->item('quotation_footer')!=''){ ?>
            <img class="letter_head_img" style="width: 100%;" src="<?php echo base_url().'uploads/company/'.$this->config->item('quotation_footer')?>" />
          <?php } ?>
        </div>
        <table>
          <thead>
            <tr>
              <td>
                <div class="page-header-space">&nbsp;</div>
              </td>
            </tr>
          </thead>
          <tbody>
            <tr>
              <td>
                <div class="print_hide_div">
                  <?php if($this->config->item('quotation_header')!=''){ ?>
                    <img class="letter_head_img" style="width: 100%;" src="<?php echo base_url().'uploads/company/'.$this->config->item('quotation_header')?>" />
                  <?php } ?>
                </div>
                <div class="page" style="line-height: 16px;">
                  <div class="m-invoice-2" style="padding-bottom: 20px">
                    <div  class="m-invoice__wrapper">
                      <div class="m-invoice__head" >
                        <div class="m-invoice__container m-invoice__container--centered">
                          <div  style="padding-top: 0px;padding-bottom: 0.3rem;text-align:center">
                            <a href="#" style="color:black">
                              <h5>QUOTATION</h5>
                            </a>
                          </div>
                          <div class="print_hide_div">
                            <?php if($quotation_data->enquiry_id!=0){?>
                              <div class="m-alert m-alert--icon m-alert--icon-solid m-alert--outline alert alert-info alert-dismissible fade show" role="alert">
                                <div class="m-alert__icon">
                                  <i class="fa fa-check-circle"></i>
                                  <span></span>
                                </div>
                                <div class="m-alert__text">
                                  <strong>Sales Quotation Created From Enquiry <a href="<?php echo base_url().'enquiries/profile/'.$quotation_data->enquiry_id ?>">#<?php echo $quotation_data->enquiry_id?></a></strong>
                                </div>
                              </div>
                            <?php } ?>
                          </div>
                          <?php
                          $to_address = nl2br($quotation_data->c_customer_name.'<br/>'.$quotation_data->customer_location);
                          if($quotation_data->state_name!=''){
                            $to_address .= nl2br('<br/>'.$quotation_data->state_name);
                          }
                          if($this->config->item('Quotation_header_type')!=2){
                            if($quotation_data->c_customer_phone!=''){ $to_address .= "<br/>Phone: ".$quotation_data->c_customer_phone;}
                          }
                          ?>
                          <div class="row" class="m-invoice__items_row" style="padding: 1rem 1rem 1rem 1rem !important;border-top: 1px solid #ebedf2;">
                            <div class="m-invoice__items" style="border:none !important">
                              <div class="m-invoice__item">
                                <span class="m-invoice__subtitle">TO: </span>
                                <span class="m-invoice__text" style="font-weight:600"><?= $to_address; ?></span>
                              </div>
                              <div class="m-invoice__item" style="text-align: right">
                                <?php if($this->config->item('Quotation_header_type')!=2){?>
                                  <span class="m-invoice__subtitle">QUOTATION NO : <?php if($this->config->item('Quotation_sales_quotation_no_manual')==1){ echo $quotation_data->quotation_no_suffix; }else{ echo '#'.$quotation_data->quotation_prefix.$quotation_data->quotation_no.$quotation_data->quotation_no_suffix;} ?></span>
                                <?php }else{ ?>
                                  <span class="m-invoice__subtitle">QUOTE NO : <?php if($this->config->item('Quotation_sales_quotation_no_manual')==1){ echo $quotation_data->quotation_no_suffix; }else{ echo '#'.$quotation_data->quotation_prefix.$quotation_data->quotation_no.$quotation_data->quotation_no_suffix;} ?></span>
                                <?php } ?>
                                <span class="m-invoice__subtitle">DATE : <?php echo date('d-m-Y',strtotime($quotation_data->date))?></span>
                                <?php if($quotation_data->reference_no!=''){?>
                                  <span class="m-invoice__subtitle">REFERENCE NO : <?php echo $quotation_data->reference_no ?></span>
                                <?php } ?>
                                <?php if($quotation_data->expiry_date!='0000-00-00'){?>
                                  <span class="m-invoice__subtitle">VALID UPTO : <?php echo date('d-m-Y',strtotime($quotation_data->expiry_date)) ?></span>
                                <?php } ?>
                              </div>
                            </div>
                            <div class="m-invoice__items" style="border:none !important;margin-top:10px">
                              <?php if($this->config->item('Quotation_header_type')!=2){?>
                                <div class="m-invoice__item" style="text-align: left">
                                  <span class="m-invoice__subtitle">PROJECT NAME : <?php echo $quotation_data->project_name ?></span>
                                  <span class="m-invoice__text"></span>
                                </div>
                              <?php } ?>
                              <?php if($this->config->item('Quotation_header_type')==2){?>
                                <div class="m-invoice__item" style="text-align:right;max-width:40%;word-wrap: break-word;">
                                  <span class="m-invoice__subtitle">SUBJECT : <span style="font-weight:400;margin-bottom:0px"><?php echo $quotation_data->quotation_subject ?></span></span>
                                  <span class="m-invoice__text" ><?php echo $quotation_data->quotation_description ?></span>
                                </div>
                              <?php } ?>
                            </div>
                            <?php if($this->config->item('Quotation_header_type')!=2){?>
                              <div class="m-invoice__items" style="border:none !important;margin-top:0px">
                                <?php if(!empty($enquiry_data) && $enquiry_data->enq_contact_person!=''){?>
                                  <div class="m-invoice__item">
                                    <span class="m-invoice__subtitle">KIND ATTN : <label style="font-weight:400;margin-bottom:0px"><?php echo $enquiry_data->enq_contact_person?></label></span>
                                    <?php if($enquiry_data->enq_contact_person_mobile!=''){?>
                                      <span class="m-invoice__subtitle"><label style="font-weight:400">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : <?php echo $enquiry_data->enq_contact_person_mobile?></label></span>
                                    <?php } ?>
                                  </div>
                                <?php }elseif($quotation_data->contact_person!=''){?>
                                  <div class="m-invoice__item">
                                    <span class="m-invoice__subtitle">KIND ATTN : <label style="font-weight:400;margin-bottom:0px"><?php echo $quotation_data->contact_person?></label></span>
                                  </div>
                                <?php } ?>
                              </div>
                              <div class="m-invoice__items" style="border:none !important;margin-top:0px">
                                <div class="m-invoice__item">
                                  <span class="m-invoice__subtitle">SUBJECT : <label style="font-weight:400;margin-bottom:0px"><?php echo $quotation_data->quotation_subject ?></label></span>
                                  <?php if($this->config->item('Quotation_print_template')!=3){?>
                                    <span class="m-invoice__text"  style="margin-top:5px"><?php echo $quotation_data->quotation_description ?></span>
                                  <?php } ?>
                                </div>
                              </div>
                            <?php } ?>
                          </div>

                        </div>
                      </div>
                      <?php if($this->config->item('Quotation_print_template')==3){?>
                        <div class="m-invoice__head" >
                          <div class="m-invoice__container m-invoice__container--centered">
                            <div class="row" class="m-invoice__items_row" style="padding: 1rem 1rem 1rem 1rem !important;">
                              <div class="m-invoice__items" style="border:none !important;margin-top:0px">
                                <div class="m-invoice__item">
                                  <span class="m-invoice__text"  style="margin-top:5px;font-size: 16px;line-height: 20px;">
                                    <p>Dear Sir,</p>
                                    <p>We thank you very much for inviting us to submit our Proposal. In this regard,<?= $this->config->item('company_name')?>
                                      is pleased to submit the quotation based on your Enquiry.</p>
                                      <p><?= $this->config->item('company_name')?> appreciates this opportunity to provide this quotation and look forward to
                                        receiving your positive response.</p>
                                        <p>Should you require for any further information or clarification, please contact the undersigned on
                                          Mobile <strong><?= $this->config->item('mobile_no')?>. </strong></p>
                                          <br/><p>Thanking you and assuring you of our best attention at all times.</p>
                                          <br/><p>Yours Sincerely</p><br/>
                                          <?php echo $quotation_data->prepared_by_name ?>
                                        </p>
                                      </span>
                                    </div>
                                  </div>
                                </div>
                              </div>
                            </div>
                            <div class="m-invoice__body m-invoice__body--centered">
                              <div class="end_footer">
                                <table style="width:100%">
                                  <tr>
                                    <td>
                                      <?php if($this->config->item('quotation_bottom')!=''){ ?>
                                        <img class="letter_head_img" style="max-width: 1000px;" src="<?php echo base_url().'uploads/company/'.$this->config->item('quotation_bottom')?>" />
                                      <?php } ?>
                                      <h6>For : <?= $this->config->item('company_name')?></h6>
                                    </td>
                                  </tr>
                                </table>
                              </div>
                            </div>
                          </div>
                        </div>
                      </div>
                      <div class="page" style="line-height: 16px;">
                        <div class="m-invoice-2" style="padding-bottom: 20px">
                          <div  class="m-invoice__wrapper">
                            <div class="m-invoice__head" >
                              <div class="m-invoice__container m-invoice__container--centered">
                                <div class="row" class="m-invoice__items_row" style="padding: 1rem 1rem 1rem 1rem !important;">
                                  <div class="m-invoice__items" style="border:none !important;margin-top:0px">
                                    <div class="m-invoice__item">
                                      <span class="m-invoice__text"  style="margin-top:5px"><?php echo $quotation_data->quotation_description ?></span>
                                    </div>
                                  </div>
                                </div>
                              </div>
                            </div>
                          <?php } ?>
                          <div class="m-invoice__body m-invoice__body--centered" style="min-height: 200px;padding:0px !important">
                            <div class="table-responsive">
                              <table class="table m-table  item_table">
                                <thead>
                                  <tr style="">
                                    <th width="5%" style="text-align:left;font-size:13px!important;background-color:black !important;color:white">Sr.<br/>No.</th>
                                    <th style="word-wrap: break-word;text-align:left;font-size:13px!important;background-color:black !important;color:white;text-align: left">Description</th>
                                    <th width="8%" style="text-align:center;;font-size:13px!important;background-color:black !important;color:white">Qty</th>
                                    <th width="7%" style="text-align:center;font-size:13px!important;background-color:black !important;color:white">Units</th>
                                    <?php if($this->config->item('Quotation_rate_type')=='supply_installation'){?>
                                      <th width="10%" style="text-align:right;font-size:13px!important;background-color:black !important;color:white">Supply<br/>Rate</th>
                                      <th width="10%" style="text-align:right;font-size:13px!important;background-color:black !important;color:white">Supply<br/>Amount</th>
                                      <th width="10%" style="text-align:right;font-size:13px!important;background-color:black !important;color:white">Install.<br/>Rate</th>
                                      <th width="10%" style="text-align:right;font-size:13px!important;background-color:black !important;color:white">Install.<br/>Amount</th>
                                    <?php }else{ ?>
                                      <th width="10%" style="text-align:right;font-size:13px!important;background-color:black !important;color:white">Unit Rate</th>
                                      <th width="18%" style="text-align:right;font-size:13px!important;background-color:black !important;color:white">Total Amount</th>
                                    <?php } ?>

                                  </tr>
                                </thead>
                                <tbody id="item_body">
                                  <?php
                                  if($this->config->item('Quotation_rate_type')=='supply_installation'){
                                    $colspan=7;
                                  }else{
                                    $colspan=5;
                                  }
                                  $supply_rate = $installation_rate = 0;
                                  if(sizeof($work_types)>0){
                                    $item_no = 1;
                                    foreach ($work_types as $key => $value) { ?>
                                      <tr>
                                        <td style="background-color:#ededed !important"><?php echo $item_no?></td>
                                        <td colspan="<?php echo $colspan?>" style="background-color:#ededed !important;text-align:left;font-weight:600"><?php echo $value['type_name']?></td>
                                      </tr>
                                      <?php
                                      foreach ($value['descriptions'] as $key22 => $value22) {?>
                                        <tr>
                                          <td></td>
                                          <td style="text-align: left"><?php echo $value22->description?></td>
                                          <td></td>
                                          <td></td>
                                          <td style="white-space: nowrap;"></td>
                                          <?php if($this->config->item('Quotation_rate_type')=='supply_installation'){?>
                                            <td style="white-space: nowrap;"></td>
                                            <td style="white-space: nowrap;"></td>
                                          <?php } ?>
                                          <td style="white-space: nowrap;"></td>
                                        </tr>
                                        <?php
                                      }
                                      $item_subno = 1;
                                      foreach ($value['items'] as $key2 => $value2) {?>
                                        <tr>
                                          <td><?php echo $item_no.".".$item_subno?></td>
                                          <td style="text-align: left"><?php echo $value2->description?></td>
                                          <td style="text-align: center"><?php echo $value2->quantity?></td>
                                          <td style="text-align: center"><?php echo $value2->unit_name?></td>
                                          <td style="white-space: nowrap;"><?php echo $this->config->item('currency_format')->formatCurrency($value2->unit_price,$this->config->item('Currency_currency_shortname'));?></td>
                                          <?php if($this->config->item('Quotation_rate_type')=='supply_installation'){?>
                                            <td style="white-space: nowrap;"><?php echo $this->config->item('currency_format')->formatCurrency($value2->unit_price*$value2->quantity,$this->config->item('Currency_currency_shortname'));?></td>
                                            <td style="white-space: nowrap;"><?php echo $this->config->item('currency_format')->formatCurrency($value2->unit_price_2,$this->config->item('Currency_currency_shortname'));?></td>
                                            <td style="white-space: nowrap;"><?php echo $this->config->item('currency_format')->formatCurrency($value2->unit_price_2*$value2->quantity,$this->config->item('Currency_currency_shortname'));?></td>
                                          <?php }else{ ?>
                                            <td style="white-space: nowrap;"><?php echo $this->config->item('currency_format')->formatCurrency($value2->total_amount,$this->config->item('Currency_currency_shortname'));?></td>
                                          <?php } ?>
                                        </tr>
                                        <?php
                                        $item_subno++;
                                        $supply_rate += $value2->unit_price*$value2->quantity;
                                        $installation_rate += $value2->unit_price_2*$value2->quantity;
                                      }
                                      $item_no++;
                                    }
                                  }else{
                                    $n = 1;
                                    foreach($items_data as $row): ?>
                                    <tr>
                                      <td><?php echo $n++?></td>
                                      <td style="text-align: left"><?php echo $row->description?></td>
                                      <td><?php echo $row->quantity?></td>
                                      <td><?php echo $row->unit_name?></td>
                                      <td style="white-space: nowrap;"><?php echo $this->config->item('currency_format')->formatCurrency($row->unit_price,$this->config->item('Currency_currency_shortname'));?></td>
                                      <td style="white-space: nowrap;"><?php echo $this->config->item('currency_format')->formatCurrency($row->total_amount,$this->config->item('Currency_currency_shortname'));?></td>
                                    </tr>
                                  <?php endforeach;
                                }

                                ?>
                                <?php if($this->config->item('Quotation_rate_type')=='supply_installation'){?>
                                  <tr>
                                    <td colspan="<?php echo $colspan?>" style="border-bottom: <?php echo $this->config->item('Quotation_table_border')?>px solid #c5c5c5;text-align:right"><span class="total_text" style="text-align: right;font-weight: 300;margin-right: 2%;color: #000;white-space:nowrap">TOTAL SUPPLY AMOUNT :</span></td>
                                    <td  class="total_text" style="border-bottom: <?php echo $this->config->item('Quotation_table_border')?>px solid #c5c5c5"> <?php echo $this->config->item('currency_format')->formatCurrency($supply_rate,$this->config->item('Currency_currency_shortname'));?></td>
                                  </tr>
                                  <tr>
                                    <td colspan="<?php echo $colspan?>" style="border-bottom: <?php echo $this->config->item('Quotation_table_border')?>px solid #c5c5c5;text-align:right"><span class="total_text" style="text-align: right;font-weight: 300;margin-right: 2%;color: #000;white-space:nowrap">TOTAL INSTALLATION AMOUNT :</span></td>
                                    <td  class="total_text" style="border-bottom: <?php echo $this->config->item('Quotation_table_border')?>px solid #c5c5c5"> <?php echo $this->config->item('currency_format')->formatCurrency($installation_rate,$this->config->item('Currency_currency_shortname'));?></td>
                                  </tr>
                                <?php } ?>
                                <tr>
                                  <td colspan="<?php echo $colspan?>" style="border-bottom: <?php echo $this->config->item('Quotation_table_border')?>px solid #c5c5c5;text-align:right"><span class="total_text" style="text-align: right;font-weight: 300;margin-right: 2%;color: #000;white-space:nowrap">SUB TOTAL :</span></td>
                                  <td  class=" total_text" style="border-bottom: <?php echo $this->config->item('Quotation_table_border')?>px solid #c5c5c5"> <?php echo $this->config->item('currency_format')->formatCurrency($quotation_data->quotation_total_amount,$this->config->item('Currency_currency_shortname'));?></td>
                                </tr>
                                <?php if($quotation_data->quotation_discount_amount!=0){?>
                                  <tr>
                                    <td colspan="<?php echo $colspan?>" class="total_text" style="border-bottom: <?php echo $this->config->item('Quotation_table_border')?>px solid #c5c5c5;text-align:right"><span class="total_text" style="text-align: right;font-weight: 300;margin-right: 2%;color: #000;white-space:nowrap">DISCOUNT :</span></td>
                                    <td  class=" total_text" style="border-bottom: <?php echo $this->config->item('Quotation_table_border')?>px solid #c5c5c5"> <?php echo $this->config->item('currency_format')->formatCurrency($quotation_data->quotation_discount_amount,$this->config->item('Currency_currency_shortname'));?></td>
                                  </tr>
                                <?php } ?>
                                <?php if($quotation_data->tax_percentage!=0){?>
                                  <tr>
                                    <td colspan="<?php echo $colspan?>" class="total_text" style="border-bottom: <?php echo $this->config->item('Quotation_table_border')?>px solid #c5c5c5;text-align:right"><span class="total_text" style="text-align: right;font-weight: 300;margin-right: 2%;color: #000;white-space:nowrap"><?php echo $quotation_data->tax_percentage?>% <?php echo $this->config->item('Tax_tax_name')?> AMOUNT :</span></td>
                                    <td  class=" total_text" style="border-bottom: <?php echo $this->config->item('Quotation_table_border')?>px solid #c5c5c5"> <?php echo $this->config->item('currency_format')->formatCurrency($quotation_data->quotation_tax_amount,$this->config->item('Currency_currency_shortname'));?></td>
                                  </tr>
                                <?php } ?>
                                <?php if($quotation_data->tax_percentage!=0 || $quotation_data->quotation_discount_amount!=0){?>
                                  <tr>
                                    <td colspan="<?php echo $colspan?>" class="total_text" style="border-bottom: <?php echo $this->config->item('Quotation_table_border')?>px solid #c5c5c5;text-align:right"><span class="total_text" style="text-align: right;font-weight: 300;margin-right: 2%;color: #000;white-space:nowrap">NET QUOTATION AMOUNT :</span></td>
                                    <td  class=" total_text" style="border-bottom: <?php echo $this->config->item('Quotation_table_border')?>px solid #c5c5c5"> <?php echo $this->config->item('currency_format')->formatCurrency($quotation_data->quotation_net_total,$this->config->item('Currency_currency_shortname'));?></td>
                                  </tr>
                                <?php } ?>
                                <tr>
                                  <td colspan="<?php echo $colspan+1?>" class="total_text" style="border-bottom: <?php echo $this->config->item('Quotation_table_border')?>px solid #c5c5c5;text-align:right"><span class="total_text" style="text-align: right;font-weight: 300;color: #000;white-space:nowrap;text-transform: uppercase;">IN WORDS : <?php echo $quotation_data->receivable_amount_in_words ?></span></td>
                                </tr>
                              </tbody>
                            </table>
                          </div>
                        </div>
                        <div class="m-invoice-2">
                          <div class="m-invoice__wrapper">
                            <div class="m-invoice__head" >
                            </div>
                            <div class="m-invoice__body m-invoice__body--centered">
                              <div style="margin-bottom: 30px;">
                                <?php echo nl2br($quotation_data->quotation_notes) ?>
                              </div>
                              <?php if($this->config->item('Quotation_print_template')!=3){?>
                                <?php if($this->config->item('Quotation_bottom_type')==1){ ?>
                                  <div class="end_footer">
                                    <table style="width:100%">
                                      <tr>
                                        <td>
                                          <h6>Prepared By</h6>
                                          <h6><?php echo $quotation_data->prepared_by_name ?></h6>
                                        </td>
                                        <td>
                                          <h6>Thanking You</h6>
                                          <h6>For : <?= $this->config->item('company_name')?></h6>
                                        </td>
                                      </tr>
                                      <tr>
                                        <td>
                                          <?php if($this->config->item('quotation_bottom')!=''){ ?>
                                            <img class="letter_head_img" style="max-width: 1000px;" src="<?php echo base_url().'uploads/company/'.$this->config->item('quotation_bottom')?>" />
                                          <?php } ?>
                                        </td>
                                      </tr>
                                    </table>
                                  </div>
                                <?php } ?>
                              <?php } ?>
                            </div>
                            <?php
                            $terms = unserialize($quotation_data->terms_and_conditions);
                            if($terms!='' && $terms!=null) {
                              $title=0;
                              foreach ($terms as $key => $value5) {
                                if(isset($value5['title']) && $value5['title']!=''){
                                  $title=1;
                                }
                              }?>
                              <br/>

                              <div class="m-invoice__body m-invoice__body--centered">
                                <div style="background: white;border: 4px solid #f7f7fa;padding: 20px;margin: 0px;padding-bottom: 0px;">
                                  <div class="m-section" style="margin: 0px 0 10px 0;">
                                    <h3 class="m-section__heading" style="padding: 0px;margin: 0px;padding-bottom: 15px">Terms & Conditions</h3>
                                    <table class="table table-striped m-table" >
                                      <thead>
                                        <?php
                                        $count = sizeof($terms);
                                        $i = 1;
                                        foreach ($terms as $key => $value5) {
                                          ?>
                                          <tr>
                                            <th style="text-align: left !important;width:6%;padding:1rem 0.5rem 0.5rem 0.5rem !important;vertical-align:top"><?php echo $i ?></th>
                                            <?php if($title==1){?>
                                              <th style="width:30%;text-align: left !important;padding:1rem 0.5rem 0.5rem 0.5rem !important;vertical-align:top"><?php echo $value5['title'] ?></th>
                                            <?php } ?>
                                            <th style="text-align: left !important;padding:1rem 0.5rem 0.5rem 0.5rem !important;vertical-align:top"><?php echo nl2br($value5['description']) ?></th>
                                          </tr>
                                          <?php $i++;
                                        }
                                        ?>
                                      </thead>
                                      <tbody>

                                      </tbody>
                                    </table>
                                  </div>
                                </div>
                              </div>

                            <?php }?>
                            <?php if($this->config->item('Quotation_print_template')!=3){?>
                              <?php if($this->config->item('Quotation_bottom_type')==2){ ?>
                                <div class="m-invoice__body m-invoice__body--centered">
                                  <div class="end_footer">
                                    <table style="width:100%">
                                      <tr>
                                        <td>
                                          <h6>Thanking You</h6>
                                          <h6>For : <?= $this->config->item('company_name')?></h6>
                                        </td>
                                      </tr>
                                      <tr>
                                        <td>
                                          <h6>Prepared By</h6>
                                          <h6><?php echo $quotation_data->prepared_by_name ?></h6>
                                        </td>
                                      </tr>
                                      <tr>
                                        <td>
                                          <?php if($this->config->item('quotation_bottom')!=''){ ?>
                                            <img class="letter_head_img" style="max-width: 1000px;" src="<?php echo base_url().'uploads/company/'.$this->config->item('quotation_bottom')?>" />
                                          <?php } ?>
                                        </td>
                                      </tr>
                                    </table>
                                  </div>
                                </div>
                              <?php } ?>
                              <?php if($this->config->item('Quotation_bottom_type')==3){ ?>
                                <div class="m-invoice__body m-invoice__body--centered">
                                  <div class="end_footer">
                                    <table style="width:100%">
                                      <tr>
                                        <td style="width:80%"></td>
                                        <td>
                                          <?php if($this->config->item('quotation_bottom')!=''){ ?>
                                            <img class="letter_head_img" style="max-height: 120px;max-width: 1000px;" src="<?php echo base_url().'uploads/company/'.$this->config->item('quotation_bottom')?>" />
                                          <?php } ?>
                                          <h6>Thank You</h6>
                                        </td>
                                      </tr>
                                    </table>
                                  </div>
                                </div>
                              <?php } ?>
                            <?php } ?>
                          </div>
                        </div>
                      </div>
                    </div>
                  </div>
                  <div class="print_hide_div">
                    <?php if($this->config->item('quotation_footer')!=''){ ?>
                      <img class="letter_head_img" style="width: 100%;" src="<?php echo base_url().'uploads/company/'.$this->config->item('quotation_footer')?>" />
                    <?php } ?>
                  </div>
                </td>
              </tr>
            </tbody>
            <tfoot>
              <tr>
                <td>
                  <div class="page-footer-space">&nbsp;</div>
                </td>
              </tr>
            </tfoot>
          </table>

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

<div class="modal fade" tabindex="-1" id="quotation_approve_modal" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
  <div class="modal-dialog " role="document">
    <form autocomplete="off" method="post" data-modal-id="quotation_approve_modal" id="form_quotation_approve" action="<?php echo base_url() . 'sales_quotation/approve' ?>" class="form-horizontal">
      <div class="modal-content">
        <div class="alert alert-info" role="alert" style="margin-bottom: 0px">
          <button type="button" class="close" data-dismiss="modal"></button>
          <br />
          <h4 class="alert-heading">Warning! Please Confirm Your Action</h4>
          <br />
          <div class="alert m-alert--default" role="alert" style="margin-bottom: 10px">
            <div class="form-group m-form__group">
              <label for="user_name" style="color: black">Approval Status</label>
              <div class="m-radio-inline" style="padding-top: 10px;">
                <label class="m-radio m-radio--solid m-radio--state-success">
                  <input required type="radio" class="form_fields_radio" name="quotation_approval_status" value="1"> Approved
                  <span></span>
                </label>
                <label class="m-radio m-radio--solid m-radio--state-danger">
                  <input type="radio" class="form_fields_radio" name="quotation_approval_status" value="2"> Rejected
                  <span></span>
                </label>
              </div>
              <span class="m-form__help"></span>
            </div>
            <div class="form-group m-form__group">
              <label for="user_name">
                Remarks
              </label>
              <div class="input-group m-input-group m-input-group--pill m-input-group--air">
                <textarea type="text" rows="3" name="remarks" id="quotation_approval_remarks" class="form-control m-input form_quotation_approve_fields" placeholder="Remarks " aria-describedby="basic-addon1"></textarea>
              </div>
              <span class="m-form__help"></span>
            </div>
          </div>
          <p>
            <button class="btn btn-danger form_submit_btn" type="submit" name="submit">Confirm & Proceed</button>
            <button type="button" class="btn btn-primary modal-dismiss" data-dismiss="modal">Cancel</button>
          </p>
          <input type="hidden" name="quotation_id" id="quotation_id_appoval" value="<?php echo $quotation_data->quotation_id?>">
        </div>
      </div>
    </form>
  </div>
</div>

<!-- end:: Body -->
<!-- begin::Footer -->

<?php $this->view("includes/Inc_footer");?>
<!-- end::Footer -->

<!-- end:: Page -->

<?php $this->view("includes/Inc_sidebar");?>
<?php $this->view("includes/Inc_scripts");?>

<!--begin::Page Snippets -->
<script>

$("#sales_quotation_menu").addClass('m-menu__item--active m-menu__item--open');
$("#sales_quotation_menu_2").addClass('m-menu__item--active');
$("#page_title").text("Sales Quotation - <?php echo $quotation_data->quotation_prefix."-".$quotation_data->quotation_no.$quotation_data->quotation_no_suffix; ?>")

$('#btn_print_sales_quotation').click(function(e){
  $(".print_hide_div").html("");
  //   var quotation_id = "<?php // echo $quotation_data->quotation_id?>";
  //   myWindow = window.open('<?php // echo base_url().'sales_quotation/profile/print/'?>'+quotation_id,'newwindow','width=1200,height=700');
  //   myWindow.document.close();
  //   myWindow.focus();
  window.print();
});

$(".form_submit_btn").click(function (e) {

  e.preventDefault();
  var a = $(this),
  l = $(this).closest("form"),
  action = l.attr('action');
  var form_id = l.attr('id');
  l.validate({
    rules: {
      "salary": {
        number: !0
      },
    }, invalidHandler: function (e, r) {
      var i = $("#" + form_id + "_msg");
      i.removeClass("m--hide").show(), mUtil.scrollTo(i, -200)
    }, submitHandler: function (e) {
    }
  }), l.valid() && (a.addClass("m-loader m-loader--right m-loader--light").attr("disabled", !0),
  l.ajaxSubmit({
    url: action,
    success: function (e, t, r, s) {
      var modal_id = l.attr('data-modal-id');
      var form_type = l.attr('data-form-type');
      $("#" + form_id + "_msg").addClass("m--hide");
      // Block UI
      mApp.blockPage({
        overlayColor: "#000000",
        type: "loader",
        range: "success",
        message: "Please wait..."
      }), setTimeout(function () {
        mApp.unblockPage()
      }, 2e3);
      var obj = $.parseJSON(e);
      if (obj.status == 1) {
        a.removeClass("m-loader m-loader--right m-loader--light").attr("disabled", !1);
        toastr[obj.flashdata_type](obj.flashdata_msg, obj.flashdata_title);
        location.reload();

      } else {
        a.removeClass("m-loader m-loader--right m-loader--light").attr("disabled", !1);
        toastr[obj.flashdata_type](obj.flashdata_msg, obj.flashdata_title);
      }
      if (obj == null) {
        setTimeout(function () {
          a.removeClass("m-loader m-loader--right m-loader--light").attr("disabled", !1);
          toastr["warning"]("Your Attempt is Timed Out. Please Try Again.", "Timed Out");
        }, 2e4)
      }
    },error: function() {
      a.removeClass("m-loader m-loader--right m-loader--light").attr("disabled", !1);
      toastr["error"]("Sorry. There Has Been Some Error Occurred. Please Try Again.", "Error");
    }
  })
)
})
</script>
