<?php $this->view("includes/Inc_pagehead");?>
<!-- Page Styles Goes Here-->
<style>
.item_table td{
  padding: .75rem !important;
}
.item_table th{
  white-space: nowrap;
  padding: .75rem !important;
}
.table thead th {
  border-top: 2px solid #f4f5f8 !important;
}
.payment-table tbody td{
  border-top: 2px solid #f4f5f8 !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%;
}
@media print
{
  #print, .print_hide_div
  {
    display: none !important;
  }
}
@media print {
  html, body, div, span, applet, object, iframe, td, tr, blockquote, pre, a, abbr, acronym, address, big, cite, code, del, dfn, em, font, ins, kbd, q, s, samp, small, strike, strong, sub, sup, tt, var, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td {
    font-size: 15pt !important;  }
    h1.entry-title {
      font-size: 15pt !important;
    }
  }
  @media print { tr.bg_S { background-color: rgb(224, 224, 224) !important; -webkit-print-color-adjust: exact; } } @media print { .bg_S th { background-color: rgb(224, 224, 224) !important; } }
  @media print { tr.bg_H { background-color: rgb(224, 224, 224) !important; -webkit-print-color-adjust: exact; } } @media print { .bg_H th { background-color: rgb(224, 224, 224) !important; } }
  @media print { tr.bg_L { background-color: #7f7f7f !important; -webkit-print-color-adjust: exact; } } @media print { .bg_L th { background-color: #7f7f7f !important; } }
  @media print { tr.bg_N { background-color: rgba(94, 94, 94, 0.52) !important; -webkit-print-color-adjust: exact; } } @media print { .bg_N th { background-color: rgba(94, 94, 94, 0.52) !important; } }

  .quotation { font-family:calibri; font-size:15px; text-align:left; font-style:normal; height:60px; text-align:justify; line-height:26px;}
  @font-face {
    font-family: calibri;
    src: url(calibri.ttf);
  }
  form div {
    font-family: calibri;
  }
</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">
          Work Order
        </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().'work_order' ?>" class="m-nav__link">
              <span class="m-nav__link-text">
                Work Order
              </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">Work Order -  <a href="javascript:;">#<?php echo $order_data->workorder_prefix.'-'.$order_data->order_no ?></a></h3>
          </div>
        </div>
        <div class="m-portlet__head-tools" >

          <a style="margin-left: 5px;margin-right: 5px" id="btn_print_work_order" 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 Work Order
              </span>
            </span>
          </a>
        </div>
      </div>

      <div class="m-portlet__body m-portlet__body--no-padding">
        <form autocomplete="off" id="form_work_order_add" data-form-type="invoice_create" method="post" action="<?php echo base_url()?>invoices/update" enctype="multipart/form-data" class="m-form m-form--fit m-form--state m-form--label-align-right " >
          <div class="row">

          </div>
          <table width="100%" border="0" style="font-weight:600">
            <tr>
              <td><img src="<?php echo base_url()."uploads/quotation_workorder/".$order_data->workorder_header ?>" border="0" /></td>
            </tr>
            <tr>
              <td>
                <table width="85%" border="0" align="center" >
                  <tr>
                    <td colspan="3" rowspan="3"><img src="<?php echo base_url()."uploads/quotation_workorder/".$order_data->workorder_logo ?>" height="200" /></td>
                    <td width="22%" rowspan="3">&nbsp;</td>
                    <td colspan="2" align="center" valign="baseline">&nbsp;</td>
                  </tr>
                  <tr>
                    <td height="137" colspan="2" align="center" valign="baseline">&nbsp;</td>
                  </tr>
                  <tr>
                    <td colspan="2" align="center" valign="baseline"><span style="font-size:28px;">WORK ORDER</span></td>
                  </tr>
                  <tr>
                    <td colspan="3">&nbsp;</td>
                    <td colspan="3"></td>
                  </tr>
                  <tr>
                    <td width="19%">Customer Name </td>
                    <td width="1%">:</td>
                    <td width="23%">Mr. <?php echo $order_data->customer_name ?></td>
                    <td colspan="3" rowspan="3"><table width="100%" border="0">
                      <tr>
                        <td width="44%">Work Order Number</td>
                        <td width="4%">:</td>
                        <td width="52%">#<?php echo $order_data->workorder_prefix.'-'.$order_data->order_no ?></td>
                      </tr>
                      <tr>
                        <td>Quotation No</td>
                        <td>:</td>
                        <td>#<?php echo $order_data->quotation_prefix.'-'.$order_data->quotation_no ?></td>
                      </tr>
                      <tr>
                        <td>Work Order Date</td>
                        <td>:</td>
                        <td><?php echo date('d-m-Y',strtotime($order_data->order_date)) ?></td>
                      </tr>
                      <tr>
                        <td>Project Start Date</td>
                        <td>:</td>
                        <td><?php echo date('d-m-Y',strtotime($order_data->project_start_date)) ?></td>
                      </tr>
                    </table></td>
                  </tr>
                  <tr>
                    <td>Address</td>
                    <td>: </td>
                    <td><?php echo nl2br($order_data->customer_address) ?></td>
                  </tr>
                  <tr>
                    <td>State</td>
                    <td>:</td>
                    <td><?php echo $order_data->state ?></td>
                  </tr>
                  <tr>
                    <td>&nbsp;</td>
                    <td>&nbsp;</td>
                    <td>&nbsp;</td>
                    <td colspan="3">&nbsp;</td>
                  </tr>
                  <tr>
                    <td colspan="6" align="center" valign="middle"><span style="font-size:26px;">QUOTED PRICE</span></td>
                  </tr>
                  <tr>
                    <td colspan="6" align="center" valign="middle">&nbsp;</td>
                  </tr>
                  <tr>
                    <td  colspan="6" align="center" valign="middle"><table  bordercolor="#000000" width="100%" border="0" cellpadding="0" cellspacing="1">
                      <tr style="border: 1px solid black;" >
                        <td style="color:#FFF;border:1px solid #666666 !important" width="26%" align="center" valign="middle" bgcolor="#666666">AREA</td>
                        <td style="color:#FFF;border:1px solid #666666 !important" width="18%" align="center" valign="middle" bgcolor="#666666">APPROX/<BR >SQUARE FEET</td>
                          <td style="color:#FFF;border:1px solid #666666 !important" width="18%" align="center" valign="middle" bgcolor="#666666">AMOUNT<BR>PER SQ.FT</td>
                            <td style="color:#FFF;border:1px solid #666666 !important" width="19%" align="center" valign="middle" bgcolor="#666666">TOTAL <BR>
                              AMOUNT <BR> <span style="font-size:12px;">( EXCLUDING GST )</span> </td>
                                <td style="color:#FFF;border:1px solid #666666 !important" width="19%" align="center" valign="middle" bgcolor="#666666">WARRANTY</td>
                              </tr>
                              <?php foreach ($items_data as $key => $value) { ?>
                                <tr style="border:1px solid #666666 !important">
                                  <td style="border:1px solid #666666 !important" height="40" align="center" valign="middle" bgcolor="#ffc20e">&nbsp;<?php echo $value->area_type ?></td>
                                  <td style="border:1px solid #666666 !important" align="center" valign="middle" bgcolor="#ffc20e">&nbsp;<?php echo nl2br($value->quantity) ?></td>
                                  <td  style="border:1px solid #666666 !important" align="center" valign="middle" bgcolor="#ffc20e">&nbsp;<?php echo $value->unit_price ?></td>
                                  <td  style="border:1px solid #666666 !important" align="center" valign="middle" bgcolor="#ffc20e">&nbsp;<?php echo $value->total_price ?></td>
                                  <td  style="border:1px solid #666666 !important"align="center" valign="middle" bgcolor="#ffc20e">&nbsp;<?php echo nl2br($value->warranty) ?></td>
                                </tr>
                              <?php } ?>
                              <tr style="border:1px solid #666666 !important">
                                <td style="border:1px solid #666666 !important" height="40" align="center" valign="middle" bgcolor="#ffc20e">&nbsp;</td>
                                <td style="border:1px solid #666666 !important" align="center" valign="middle" bgcolor="#ffc20e">&nbsp;</td>
                                <td style="border:1px solid #666666 !important"  align="center" valign="middle" bgcolor="#ffc20e">&nbsp;</td>
                                <td style="border:1px solid #666666 !important"  align="center" valign="middle" bgcolor="#ffc20e">&nbsp;</td>
                                <td style="border:1px solid #666666 !important" align="center" valign="middle" bgcolor="#ffc20e">&nbsp;</td>
                              </tr>
                              <?php if($order_data->tax_percent!=0){?>
                              <tr style="border:1px solid #666666 !important">
                                <td style="border:1px solid #666666 !important;color:#FFF" height="40" colspan="3" align="center" valign="middle" style="" bgcolor="#666666">TOTAL TAXABLE</td>
                                <td style="border:1px solid #666666 !important;color:#FFF" align="center" valign="middle" bgcolor="#666666"><?php echo $order_data->grand_total_amount-$order_data->discount_amount ?></td>
                                <td style="border:1px solid #666666 !important" align="center" valign="middle" bgcolor="#ffc20e">&nbsp;</td>
                              </tr>
                              <tr style="border:1px solid #666666 !important">
                                <td style="border:1px solid #666666 !important;color:#FFF;border-top: 1.5px solid #ffffff !important;" height="40" colspan="3" align="center" valign="middle" style="" bgcolor="#666666"><?php echo $this->config->item('Tax_tax_name')?> AMOUNT @ <?php echo $order_data->tax_percentage ?>%</td>
                                <td style="border:1px solid #666666 !important;color:#FFF;border-top: 1.5px solid #ffffff !important;" align="center" valign="middle" bgcolor="#666666"><?php echo $order_data->tax_amount ?></td>
                                <td style="border:1px solid #666666 !important;border-top: 1.5px solid #ffffff !important;" align="center" valign="middle" bgcolor="#ffc20e">&nbsp;</td>
                              </tr>
                              <tr style="border:1px solid #666666 !important">
                                <td style="border:1px solid #666666 !important;color:#FFF;border-top: 1.5px solid #ffffff !important;" height="40" colspan="3" align="center" valign="middle" style="" bgcolor="#666666">NET TOTAL</td>
                                <td style="border:1px solid #666666 !important;color:#FFF;border-top: 1.5px solid #ffffff !important;" align="center" valign="middle" bgcolor="#666666"><?php echo $order_data->total_order_amount ?></td>
                                <td style="border:1px solid #666666 !important;border-top: 1.5px solid #ffffff !important;" align="center" valign="middle" bgcolor="#ffc20e">&nbsp;</td>
                              </tr>
                            <?php }else{ ?>
                              <tr style="border:1px solid #666666 !important">
                                <td style="border:1px solid #666666 !important;color:#FFF" height="40" colspan="3" align="center" valign="middle" style="" bgcolor="#666666">TOTAL</td>
                                <td style="border:1px solid #666666 !important;color:#FFF" align="center" valign="middle" bgcolor="#666666"><?php echo $order_data->total_order_amount ?> + GST</td>
                                <td style="border:1px solid #666666 !important" align="center" valign="middle" bgcolor="#ffc20e">&nbsp;</td>
                              </tr>
                            <?php } ?>
                            </table></td>
                          </tr>
                          <tr>
                            <td colspan="6" align="center" valign="middle">&nbsp;</td>
                          </tr>
                          <tr>
                            <td colspan="6" align="center" valign="middle">&nbsp;</td>
                          </tr>
                        </table>
                        <table width="100%" border="0">
                          <tr>
                            <td colspan="5"><img src="<?php echo base_url()."uploads/quotation_workorder/".$order_data->workorder_footer?>" width="100%" /></td>
                          </tr>
                          <tr>
                            <td colspan="5">&nbsp;</td>
                          </tr>
                          <tr>
                            <td>&nbsp;</td>
                            <td><img src="<?php echo base_url()."uploads/quotation_workorder/".$order_data->workorder_logo?>" width="200" /></td>
                            <td>&nbsp;</td>
                            <td>&nbsp;</td>
                            <td>&nbsp;</td>
                          </tr>
                          <tr>
                            <td colspan="5">&nbsp;</td>
                          </tr>
                          <tr>
                            <td colspan="5" align="center" valign="middle"><span style="font-size:26px;">PAYMENT SCHEDULE</span></td>
                          </tr>
                          <tr>
                            <td colspan="5"><table width="100%" border="0">
                              <tr>
                                <td width="9%" height="33" align="center" valign="middle" bgcolor="#ffc20e">Sl No.</td>
                                <td width="31%" align="center" valign="middle" bgcolor="#ffc20e">PARTICULARS</td>
                                <td width="15%" align="center" valign="middle" bgcolor="#ffc20e">AMOUNT</td>
                                <td width="45%" align="center" valign="middle" bgcolor="#ffc20e">DETAILED REMARKS</td>
                              </tr>
                              <?php
                              $payment_schedule = unserialize($order_data->payment_schedule);
                              if($payment_schedule!='' && $payment_schedule!=null) {
                                $payment_schedule_count = sizeof($payment_schedule);
                                $i = 1;
                                ?>
                                <?php foreach ($payment_schedule as $key => $value) { ?>
                                  <tr>
                                    <td height="35" align="center" valign="middle"><?= $key+1 ?></td>
                                    <td align="center" valign="middle"><?= nl2br($value['particulars']) ?></td>
                                    <td align="center" valign="middle"><?= $value['amount'] ?></td>
                                    <td align="center" valign="middle"><?= nl2br($value['remarks']) ?></td>
                                  </tr>
                                <?php }
                              }?>

                              <tr>
                                <td height="35" align="center" valign="middle">&nbsp;</td>
                                <td align="center" valign="middle">&nbsp;</td>
                                <td align="center" valign="middle">&nbsp;</td>
                                <td align="center" valign="middle">&nbsp;</td>
                              </tr>
                              <tr>
                                <td height="35" align="center" valign="middle">&nbsp;</td>
                                <td align="center" valign="middle">&nbsp;</td>
                                <td align="center" valign="middle">&nbsp;</td>
                                <td align="center" valign="middle">&nbsp;</td>
                              </tr>
                            </table></td>
                          </tr>
                          <tr>
                            <td colspan="5">&nbsp;</td>
                          </tr>
                          <tr>
                            <td colspan="5">Kindly Transfer advance amount <br /> to the below mentioned account</td>
                          </tr>
                          <tr>
                            <td colspan="5">&nbsp;</td>
                          </tr>
                          <tr>
                            <td colspan="5"><table width="100%" border="0">
                              <tr>
                                <td width="25%">COMPANY NAME</td>
                                <td width="2%">:</td>
                                <td width="30%"><?php echo $order_data->company_name ?></td>
                                <td width="43%">&nbsp;</td>
                              </tr>
                              <tr>
                                <td>BANK NAME</td>
                                <td>:</td>
                                <td><?php echo $order_data->bank_name ?> </td>
                                <td rowspan="4"><table width="100%" border="0">
                                  <tr>
                                    <td><strong>SITE COORDINATOR</strong></td>
                                  </tr>
                                  <tr>
                                    <td><?php
                                    if(is_numeric($order_data->site_coordinator)){
                                      echo ($order_data->site_coordinator_name);
                                    }else{
                                      echo nl2br($order_data->site_coordinator);
                                    } ?></td>
                                  </tr>
                                </table></td>
                              </tr>
                              <tr>
                                <td>ACCOUNT NUMBER</td>
                                <td>:</td>
                                <td><?php echo $order_data->bank_account_no ?></td>
                              </tr>
                              <tr>
                                <td><?= $this->config->item('bank_ifsc_name')?> CODE</td>
                                <td>:</td>
                                <td><?php echo $order_data->bank_ifsc ?></td>
                              </tr>
                              <tr>
                                <td>BRANCH </td>
                                <td>:</td>
                                <td><?php echo $order_data->bank_branch ?></td>
                              </tr>
                            </table></td>
                          </tr>
                          <tr>
                            <td colspan="5">&nbsp;</td>
                          </tr>
                          <tr>
                            <td colspan="5"><img src="<?php echo base_url()."uploads/quotation_workorder/".$order_data->workorder_footer?>" width="100%" /></td>
                          </tr>
                          <tr>
                            <td colspan="5">&nbsp;</td>
                          </tr>
                          <tr>
                            <td colspan="5">&nbsp;</td>
                          </tr>
                          <tr>
                            <td colspan="5"><img src="<?php echo base_url()."uploads/quotation_workorder/".$order_data->workorder_logo?>" width="200" /></td>
                          </tr>
                          <tr>
                            <td colspan="5">&nbsp;</td>
                          </tr>
                          <tr>
                            <td colspan="5"><table width="85%" border="0" align="center" style="text-align:justify;">
                              <tr>
                                <td colspan="4" align="center" valign="middle"><strong style="text-decoration:underline; font-size:20px;">THIS WORK ORDER INCLUDES THE CONDITION NOTED</strong></td>
                              </tr>
                              <tr>
                                <td>&nbsp;</td>
                                <td>&nbsp;</td>
                                <td>&nbsp;</td>
                                <td>&nbsp;</td>
                              </tr>
                              <tr>
                                <td align="center" valign="middle">&nbsp;</td>
                                <td colspan="3" class="quotation">
                                  <?php
                                  $terms = unserialize($order_data->terms_and_conditions);
                                  if($terms!='' && $terms!=null) {
                                    $count = sizeof($terms);
                                    $i = 1;
                                    ?>
                                    <ul>
                                      <?php foreach ($terms as $key => $value) { ?>
                                        <li><?= nl2br($value['description']) ?></li>
                                      <?php } ?>
                                    </ul>
                                  <?php } ?>
                                </td>
                              </tr>
                              <tr>
                                <td align="center" valign="middle">&nbsp;</td>
                                <td colspan="3" class="quotation">&nbsp;</td>
                              </tr>
                            </table></td>
                          </tr>
                          <tr>
                            <td colspan="5">&nbsp;</td>
                          </tr>
                          <tr>
                            <td colspan="5"><img src="<?php echo base_url()."uploads/quotation_workorder/".$order_data->workorder_footer?>" width="100%" /></td>
                          </tr>
                        </table></td>
                      </tr>
                    </table>
                  </form>
                </div>
              </div>
            </div>
          </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>

        $("#work_order_menu").addClass('m-menu__item--active m-menu__item--open');
        $("#work_order_menu_2").addClass('m-menu__item--active');

        $("#page_title").text("Work Order - #<?php echo $order_data->order_id.' ['.$order_data->customer_name.']'?>");
        $('#btn_print_work_order').click(function(e){
          var order_id = "<?php echo $order_data->order_id?>";
          myWindow = window.open('<?php echo base_url().'work_order/profile/print/'?>'+order_id,'newwindow','width=1200,height=700');
          myWindow.document.close();
          myWindow.focus();
          myWindow.print();
        });

        </script>
        <script>

        $(".form_submit_btn_4").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: {
              "new_paid_amount": {
                required: !0,
                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",
                state: "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);
                $("#"+modal_id).modal('toggle');
                $("."+form_id+"_fields").val("");
                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>
