<html>
    <head>
        <title><?php echo $b_header['title']; ?></title>
        <link href="<?php echo base_url(); ?>assets/vendors/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet" media="all">
    
   
    <style>
            @media print
            {
                * {-webkit-print-color-adjust:exact;}
                @page {margin:0in 0.18in 0in 0in; }
                .super_container
                {
                    page-break-after: always;
                    margin-top:0.25in;
                    position:relative;
                    width:100vw;
                    height:710px;
                }
            }
            body {margin: 0.25in 0.25in 0.63in 0.25in; box-sizing:border-box;width:100vw; height:100vh;padding-bottom:0.63in;}
            *{margin:0;padding:0;font-family:calibri;}
            .clear:after{content:"";clear:both;display:block;}
            .left{float:left;}
            .right{float:right;}
            .wd-10{width:10%;}
            .wd-20{width:20%;}
            .wd-30{width:30%;}
            .wd-40{width:40%;}
            .wd-50{width:50%;}
            .wd-60{width:60%;}
            .wd-70{width:70%;}
            .wd-80{width:80%;}
            .wd-90{width:90%;}
            .wd-100{width:100%;}
            .wd-15{width:15%;}
            .wd-25{width:25%;}
            .wd-35{width:35%;}
            .wd-45{width:45%;}
            .wd-55{width:55%;}
            .wd-65{width:65%;}
            .wd-75{width:75%;}
            .wd-85{width:85%;}
            .wd-95{width:95%;}
            .wd-100{width:100%;}
            .title{font-size:35px;}
            .super_container
            {
                margin-bottom:200px;
                position:relative;
                width:100vw;
                height:710px;
            }
            .wrapper{
                border:4px transparent #18a05e;
                
                outline-offset: 5px;
                box-sizing: border-box;
                padding:5px;
            }
            .super_wrapper
            {
                position:absolute;
                top:0;
                left:0;
                width:100%;
                z-index:120;
                margin:0;
                padding:0;
            }
            /*.watermark*/
            /*{*/
            /*    height:200px;*/
            /*    width:300px;*/
            /*    margin:auto;*/
            /*    padding-top:50px;*/
            /*    padding-left:100px;*/
            /*    opacity:0.1;*/
            /*    background:url("<?php echo base_url().$b_header['logo1']; ?>");*/
            /*    background-size:100% 100%;*/
            /*}*/
            /*.watermark_wrapper*/
            /*{*/
            /*    height:470px;*/
            /*    width:100%;*/
            /*    margin-top:50px;*/
            /*    display:inline-flex;*/
            /*    display:-webkit-inline-flex;*/
            /* }*/
            .wrapper.left2{
                width: calc(90vw);
                margin-right: 20px;
                margin-left: 20px;
            }
            h1,h2,h3{
                color:#5A7BC1;
                font-family:calibri;
                text-align:center;
            }
            .boxed{color:#000000;width:80%;margin:0 auto;}
            .header{
                width:100%;
                border-bottom:4px solid #5A7BC1;            
            }
            .body{
                padding:10px;
            }
            .row{
                width:100%;
                margin: 0px auto;  
            }
            .text-center{text-align:center;}
            .bold{font-weight:bold;}
            .b-u-l{
                border-bottom: 1px solid #000;
                height:inherit;
            }
            .x-small{
                font-size: 12px;
            }
            .x-x-small{
                font-size: 9px;
            }
            .page_break{
                width: 100vw;
                height: 100vh;
                padding: 10px 0px;
                box-sizing: border-box;
            }
            .tbl1
            {
                border: 1px solid #000;
                text-align:center;
                width:100%;
                min-height:20px;
            }
            th{
                border: 1px solid #000;
                  border-right: 0px;
                border-bottom: 0px; 
                background-color:#ccccb3; 
                padding: 3px !important;
            }
            td{
                border: 1px solid #000;
                text-align: left;
                  border-right: 0px;
                border-bottom: 0px; 
                padding: 2px !important;
            }
            .normal{
                font-weight: normal !important;
            }
            .text-right{
                text-align: right !important;
            }
            .text-left{
                text-align: left !important;
            }
            .margin-a{margin: 30px auto 0px auto;}
        </style>
    </head>
    <body >
<?php 
    $tmp_sal=0;
      $prev_inc=$this->db->select('sum(amount) as amount')
                         ->from('increments')
                         ->where('bothid',$employee['empid'])
                          ->where('month <',$month)
                          ->where('refrence',$refrence)
                          ->where('is_del',0)
                          ->get()->row_array()['amount'];
       if(!empty($prev_inc))
     {
       $tmp_sal=$employee['salery']+$prev_inc;
     }else
     {
        $tmp_sal=$employee['salery']; 
                                             }
?>
        <div class="super_container">
        <div class="container-fluid">
          <div class="row header">
              <div class="wd-100 clear">
                                <div class=" text-left left ">
                                    <img src="<?php echo base_url().$b_header['logo1']; ?>" style="width:50px;height:50px;">
                                </div>
                                <div class=" text-left right ">
                                    <img src="<?php echo base_url().$b_header['logo2']; ?>" style="width:50px;height:50px;">
                                </div>
                                <div>
                                    <center><h3><?php echo $b_header['title']; ?></h3></center>
                                    <center><h3 style="color:#000 !important;"><i><?php echo $b_header['tagline']; ?></i></h3></center>
                                    <center><i><h3 style="color:#000 !important;font-weight:normal;"><?php echo $b_header['short_address']; ?></h3></i></center>
                                    <center><h3 class="boxed" style="margin-top:0px !important;font-size:23px;">Salary Slip</h3></center>
                                </div>
                            </div>
          </div>
<hr/>

                        <div class="row form-horizontal">
                            <div class="col-md-7 col-sm-7 col-xs-7">
                                <div class="">
                                    <p class="col-md-2 col-sm-2 col-xs-3"><strong>Pay Slip #</strong></p>
                                    <p class="col-md-10 col-sm-10 col-xs-9"><?php echo $invoice; ?></p>
                                </div>
                                <div class="">
                                    <p class="col-md-2 col-sm-2 col-xs-3"><strong>Name</strong></p>
                                    <p class="col-md-10 col-sm-10 col-xs-9"><?php echo $employee['firstname']." ".$employee['lastname']; ?></p>
                                </div>
                                <div class="">
                                    <p class="col-md-2 col-sm-2 col-xs-3"><strong>ID</strong></p>
                                    <p class="col-md-10 col-sm-10 col-xs-9"><?php echo $employee['cnic']; ?></p>
                                </div>
                                <div class="">
                                    <p class="col-md-2 col-sm-2 col-xs-3"><strong>Contact</strong></p>
                                    <p class="col-md-10 col-sm-10 col-xs-9"><?php echo $employee['contact']; ?></p>
                                </div>
                            </div>
                            <div class="col-md-4 col-sm-5 col-xs-5">
                                <div class="">
                                    <strong class="control-label col-md-7 col-sm-8 col-xs-7">Pay Period</strong>
                                    <p class="col-md-4 col-sm-4 col-xs-5"><?php echo date("F - Y",strtotime($month)); ?></p>
                                </div>
                                <div class="">
                                    <strong class="control-label col-md-8 col-sm-8 col-xs-7">Create Date</strong>
                                    <p class="col-md-4 col-sm-4 col-xs-5"><?php echo $create_date; ?></p>
                                </div>
                            </div>
                        </div>
                              
                        <table class="tbl1">
                            <thead>
                                <tr>
                                    <th>#</th>
                                    <th>Name</th>
                                    <th>Amount</th>
                                </tr>
                            </thead>
                            <tbody>
                                <?php $i=1; $net=$tmp_sal;//$net=$employee['salery']; ?>
                                <tr>
                                    <td><?php echo $i++; ?></td>
                                    <td>Basic Salary</td>
                                    <td>+ <?php  echo $tmp_sal;//$employee['salery']; ?></td>
                                </tr>
                                <!--Advance Ammount start-->
    <?php $provd_ret=$this->sm->provident_ret($employee['empid'],$refrence,$month);  ?>
                      <tr><td> <?php echo $i++; ?></td><td>
                      <?php echo "Return Provident Fund";?></td>
                      <td>+ <?php
                            if($provd_ret>0)
                            { 
                              echo $provd_ret; 
                              //$gros-=$adv;  
                             }
                             else
                             {
                             echo "0";
                             }?>
                             </td>
                             <?php $net+=$provd_ret;?></tr>
<!--End dvance Ammount-->

                            <?php 
                            if(!empty($allonce)){                             
                                foreach($allonce as $all)
                                { 
                $am=$this->sm->getallonce_ammount2($employee['salery'],$employee['empid'],$refrence,$all['id']);?>
                                <tr>
                                <td><?php echo $i++ ?> </td>
                                <td><?php echo $all['name']?></td>
                                <td>
                                + <?php if($am>0)
                                {
                                    echo $am;
                                    }
                                else
                                { 
                                echo "0";
                                } ?>
                                </td>    
                                    <?php $net+=$am;?>
                                </tr>
                           
                            <?php } 
                            }
                            
                            //Loan
                            
                             if(!empty($loan_def)){
                                
                                foreach($loan_def as $dloan)
                                {  
                                $pai=$this->sm->getloan_ammount2($employee['salery'],$employee['empid'],$refrence,$dloan['id'],$month);
                                 ?>
                                <tr><td> <?php echo $i++;?> </td>
                                <td>
                                <?php echo $dloan['name'] ?>
                                </td>
                                <td>- <?php 
                                if($pai>0){
                               // $iid=$dloan['id'];
                                // $this->session->set_userdata('loan_id',$pai);
                               $this->session->set_userdata('paid_loan',$pai);
                                echo $pai;
                                }else{
                                 echo "0";
                                 }  
                                 ?>
                                 </td>    
                                <?php $net-=$pai?>
                                </tr>
                            <?php } 
                            }?>
                            <?php
                            //End Loan
                            if(!empty($deduction_def)){
                                
                                foreach($deduction_def as $dedu)
                                {  
                                $pai=$this->sm->getdeduct_ammount2($employee['salery'],$employee['empid'],$refrence,$dedu['id'],$month);
                                 ?>
                                <tr><td> <?php echo $i++;?> </td>
                                <td>
                                <?php echo $dedu['name'] ?>
                                </td>
                                <td>- <?php 
                                if($pai>0){
                                echo $pai;
                                }else{
                                 echo "0";
                                 }  
                                 ?>
                                 </td>    
                                <?php $net-=$pai?>
                                </tr>
                            <?php } 
                            }?>

                            <!--personal expense start-->
    <?php 
     if(!empty($personal_exp)){
                        foreach ($personal_exp as $key => $all)
                         { 
                         $pai2=$this->sm->personal_exp($employee['empid'],$refrence,$all['id'],$month);  
                         ?>
                         <tr> <td><?php echo $i++; ?></td>
                          <td>
                                <?php echo $all['name'] ?>
                                </td>
                                <td>- <?php
                            if($pai2>0){ 
                              echo $pai2; 
                              //$gros-=$pai2;  
                             } else{
                             echo "0";
                             } 
                               ?> 
                               </td> 
                               <?php $net-=$pai2?></tr>
                        <?php } }?>                   

<!--End personal expense-->

<!--Advance Ammount start-->
    <?php $provd=$this->sm->provident($employee['salery'],$employee['empid'],$refrence,$month);  ?>
                      <tr><td> <?php echo $i++; ?></td><td>
                      <?php echo "Provident Fund";?></td>
                      <td>- <?php
                            if($provd>0)
                            { 
                              echo $provd; 
                              //$gros-=$adv;  
                             }
                             else
                             {
                             echo "0";
                             }?>
                             </td>
                             <?php $net-=$provd?></tr>
<!--End dvance Ammount-->

<!--Advance Ammount start-->
    <?php $adv=$this->sm->advance($employee['empid'],$refrence,$month);  ?>
                      <tr><td> <?php echo $i++; ?></td><td>
                      <?php echo "Advance";?></td>
                      <td>- <?php
                            if($adv>0)
                            { 
                              echo $adv; 
                              //$gros-=$adv;  
                             }
                             else
                             {
                             echo "0";
                             }?>
                             </td>
                             <?php $net-=$adv?></tr>
<!--End dvance Ammount-->



                                <!--<tr>
                                    
                                <td>-->
                                    <?php 
                                   // echo $i++; 
                                    ?>
                                   <!-- </td><td>Increment</td><td>+--> 
                                    <?php
                                    //$inc=$this->sm->getincrement($employee['empid'],$refrence,$month); if($inc>0){echo $inc;}else{ echo "0";}  ?>
                                   <!-- </td> -->  
                                    <?php 
                                   // $net+=$inc; 
                                    ?>
                               <!-- </tr>-->
                           
                            </tbody>
                        </table>
                        <div class="form-horizontal form-label-left">
                            
                            <div class="row">
                                <div class="col-md-4 col-sm-4 col-xs-4 col-md-offset-8 col-sm-offset-8 col-xs-offset-8">
                                    <div class="ln-solid"></div>
                                    <div class="row">
                                        <div class="col-md-6 col-sm-6 col-xs-12">
                                            <h4>Basic Salary</h2>
                                        </div>
                                        <div class="col-md-6 col-sm-6 col-xs-12">
                                            <p><input id="salary" type="number" name="salary" class="form-control" readonly="readonly" value="<?php echo $tmp_sal;//$employee['salery']; ?>" min="0"></p>
                                        </div>
                                    </div>
                                    <div class="row">
                                        <div class="col-md-6 col-sm-6 col-xs-12">
                                            <h4>Net Salary</h4>
                                        </div>
                                        <div class="col-md-6 col-sm-6 col-xs-12">
                                            <p><input id="net" type="number" name="net" class="form-control" readonly="readonly" min="0" value="<?php echo $net; ?>"></p>
                                        </div>
                                    </div>
                                   
                                </div>
                            </div>
                        </div>
                    </div>
            
        <!-- /page content -->


    <!-- jQuery -->
    <script src="<?php echo base_url(); ?>assets/vendors/jquery/dist/jquery.min.js"></script>
   
    <script>
        $(function(){
            var total = $("#total").val();
            var net = $("#net").val();
            <?php //if($invoice['status']==0)
           // {
            ?>
            if(total <= 0)
            {
                $("#total").val(0);
                $("#net").val(0);
                $("#remaining").val(0);
                $("#recieved").val(0);
                $("#advance").val(Math.abs(net));
            }else{
                $("#remaining").val(net);
            }
            <?php
            // }
             ?>
            
            $(document).on("keyup","#recieved",function(){
                var val = parseInt($(this).val());
                var ret = parseInt($("#net").val()) - val;
                if(ret <= 0)
                {
                $("#remaining").val('0');
                $("#advance").val(Math.abs(ret));
                }else{
                $("#remaining").val(ret);
                $("#advance").val('0');
                }
            });
        });
    </script>
  <script>window.print();</script>

  </body>
</html>
