        <!DOCTYPE html>
        <html lang="en">


        <!-- Mirrored from edumin.dexignlab.com/xhtml/add-departments.html by HTTrack Website Copier/3.x [XR&CO'2014], Tue, 17 Nov 2020 13:56:15 GMT -->
        <head>
        	
        	<meta charset="utf-8">
            <meta http-equiv="X-UA-Compatible" content="IE=edge">
            <meta name="viewport" content="width=device-width,initial-scale=1">
            <title>Rizwan </title>
        	<!-- Favicon icon -->
            <link rel="icon" type="image/png" sizes="16x16" href="<?php echo base_url();?>assets/images/favicon.png">
            <link rel="stylesheet" href="<?php echo base_url();?>assets/vendor/bootstrap-select/dist/css/bootstrap-select.min.css">
            <link rel="stylesheet" href="<?php echo base_url();?>assets/css/style.css">
        	<!-- Pick date -->
            <link rel="stylesheet" href="<?php echo base_url();?>assets/vendor/pickadate/themes/default.css">
            <link rel="stylesheet" href="<?php echo base_url();?>assets/vendor/pickadate/themes/default.date.css">
             <link href="<?php echo base_url();?>assets/vendor/datatables/css/jquery.dataTables.min.css" rel="stylesheet">
            <!-- Custom Stylesheet -->
             

        </head>

        <body>

            <!--*******************
                Preloader start
            ********************-->
                <div id="preloader">
                <div class="sk-three-bounce">
                    <div class="sk-child sk-bounce1"></div>
                    <div class="sk-child sk-bounce2"></div>
                    <div class="sk-child sk-bounce3"></div>
                </div>
            </div>
            <!--*******************
                Preloader end
            ********************-->

            <!--**********************************
                Main wrapper start
            ***********************************-->
            <div id="main-wrapper">

              <?php  $this->load->view('header'); ?>
        		
                <!--**********************************
                    Content body start
                ***********************************-->
                <div class="content-body">
                    <!-- row -->
                    <div class="container-fluid">
        				    
                        <div class="row page-titles mx-0">
                            <div class="col-sm-6 p-md-0">
                                <div class="welcome-text">
                                    <h4><img class="mr-3 rounded-circle" alt="image" width="50" src="<?php echo base_url('assets/images/profile/'.images($this->uri->segment(3))); ?>"> <?php echo fullname($this->uri->segment(3)); ?></h4>
                                </div>
                            </div>
                            <div class="col-sm-6 p-md-0 justify-content-sm-end mt-2 mt-sm-0 d-flex">
                                <ol class="breadcrumb">
                                    <li class="breadcrumb-item"><a href="index.html">Home</a></li>
                                    <li class="breadcrumb-item active"><a href="javascript:void(0);">Daily Sheet</a></li>
                                    <li class="breadcrumb-item active"><a href="javascript:void(0);">Add Daily Sheet</a></li>
                                </ol>
                            </div>
                        </div>
        				
        				<div class="row">


                        <div class="col-12">
                            <div class="card">
                
                                    <div class="card-body">
                                          <?php if($this->session->flashdata('daily_danger')){ ?>
                                            <div class="alert alert-danger solid " style='text-align:center;'><?php echo $this->session->flashdata('daily_danger'); ?></div>
                                        <?php } ?>
                                         <div id='daily_danger' class='alert alert-danger solid' style='display:none;width: 25%;'></div>
                                        <div class="table-responsive">
                                            <table id="example5"   class="display" style="min-width: 800">
                                                <thead>
                                                    <tr>
                                                        <th>IN Date</th>
                                                        <th>Tap IN</th>
                                                        <th>Out Date</th>
                                                        
                                                        <th>Tap OUT</th>
                                                        <th>Status</th>
                                                         <th>Action</th>                                                     
                                                    </tr>
                                                </thead>
                                                <tbody>
                                                 <?php if(!empty($get_daily_sheet)){ ?>   
                                                    <?php foreach ($get_daily_sheet as $get_daily_sheets) { ?>
                                                        
                                                    <tr>
                                                        
                                                        
                                                        <td><?php
                                                        $newDate = date("d-m-Y", strtotime($get_daily_sheets['date']));  
                                                        echo  $newDate;
                                                       ?></td>

                                                       <td><?php
                                                         
                                                       echo $get_daily_sheets['tap_in'];
                                                        
                                                        ?></td>

                                                       <td><?php
                                                        
                                                       
                                                        $date_out = date("d-m-Y", strtotime($get_daily_sheets['date_out']));  
                                                        echo  $date_out;
                                                       ?></td>

                                                       
                                                        <td><?php
                                                         
                                                         echo $get_daily_sheets['tap_out'];
                                                                                                               
                                                        ?></td>
                                                       <td>
                                                           <?php  

                                                           
                                                            //Tap in////
                                                            $new_tapin = date('H:i', strtotime(@$get_daily_sheets['tap_in']));
                                                            $new_tapins = strtotime ($new_tapin);
                                                            //$total_tapin = $new_tapin+15;
                                                            ///Emp tap in/////
                                                            $emp_tapin = get_emp_time($get_daily_sheets['emp_id']);
                                                            $emp_tap_in = date('H:i', strtotime(@$emp_tapin));
                                                            $emp_time = strtotime ($emp_tap_in);
                                                            //$total_emp =  $emp_time;
                                                            //echo $total_emp; echo "=="; echo $new_tapins;
                                                            if($new_tapins > $emp_time){ ?>

                                                               <span class="badge badge-danger">Late</span>
                                                            <?php }else{ ?>

                                                               <span class="badge badge-success">On Time</span>
                                                             <?php } ?>
                                                            

                                                       </td>
                                                        

                                                        <td>
                                                            <?php if($get_daily_sheets['in_out_id']==NULL) {?>
                                                       <button type="button" class="btn btn-primary" data-toggle="modal" data-target=".bd-example-modal-lg" onclick="add_details('<?php echo $get_daily_sheets['id']; ?>');">Add Details</button>
                                                   <?php }else{ ?>
                                                       <button type="button" class="badge badge-warning" data-toggle="modal" data-target=".bd-example-modal-lg1" onclick="view_ot_advance('<?php  echo $get_daily_sheets['id']; ?>')">View</button>

                                                       <a href="<?php echo base_url('Admin/edit_get_daily_sheet/'.$get_daily_sheets['id']); ?>" class="btn btn-sm btn-primary"><i class="la la-pencil"></i></a>
                                                        <?php } ?>
                                                            </td> 

                                                    </tr>

                                                    <?php } ?>


                                                   <?php } ?>
                                                </tbody>
                                            </table>
                                        </div>


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

                <div class="modal fade bd-example-modal-lg" tabindex="-1" role="dialog" aria-hidden="true">
                                        <div class="modal-dialog modal-lg">
                                            <div class="modal-content">
                                                <div class="modal-header">
                                                  
                                                    <button type="button" class="close" data-dismiss="modal"><span>&times;</span>
                                                    </button>
                                                </div>
                                                <div class="modal-body">
                                              
                                            <div class="col-xl-12 col-xxl-12 col-sm-12">
                                                <div class="card">
                                                    <div class="card-header">
                                                 <h5 class="card-title">Details</h5>
                                                    </div>
                                                   
                                                   <div class="card-body" id="add_details">
                                              
                                                    </div>
                                                </div>
                                            </div>



                                                </div>
                                                <div class="modal-footer">
                              
                                                <div class="modal-footer">
                                                    <button type="button" class="btn btn-danger" data-dismiss="modal">Close</button>
                                                 
                                                </div>
                                            </div>
                                        </div>
                                    </div>
            
                                  </div>
                <!--**********************************
                    Content body end
                ***********************************-->


                 <div class="modal fade bd-example-modal-lg1" tabindex="-1" role="dialog" aria-hidden="true">
                                        <div class="modal-dialog modal-lg">
                                            <div class="modal-content">
                                                <div class="modal-header">
                                                  
                                                    <button type="button" class="close" data-dismiss="modal"><span>&times;</span>
                                                    </button>
                                                </div>
                                                <div class="modal-body">
                                              
                                            <div class="col-xl-12 col-xxl-12 col-sm-12">
                                                <div class="card">
                                                    <div class="card-header">
                                                 <h5 class="card-title">Details Advance / Over Time</h5>
                                                    </div>
                                                   
                                                   <div class="card-body" id="details">
                                              
                                                    </div>
                                                </div>
                                            </div>



                                                </div>
                                                <div class="modal-footer">
                              
                                                <div class="modal-footer">
                                                    <button type="button" class="btn btn-danger" data-dismiss="modal">Close</button>
                                                 
                                                </div>
                                            </div>
                                        </div>
                                    </div>
            
                                  </div>


                <!--**********************************
                    Footer start
                ***********************************-->
                <div class="footer">
                    <div class="copyright">
                        <p>Copyright © Designed &amp; Developed by  2020</p>
                    </div>
                </div>
                <!--**********************************
                    Footer end
                ***********************************-->

        		<!--**********************************
                   Support ticket button start
                ***********************************-->

                <!--**********************************
                   Support ticket button end
                ***********************************-->


            </div>
            <script src="<?php echo base_url();?>assets/js/jjquery.min.js"></script>
                <style>
                .redborder{
                    border:1px solid red;
                }
                </style>





           <script type='text/javascript'>
            
           


             $("#status").change(function() {

                
    
                var status =  this.value;
               if(status ==0)
                {
                    $( "#time_in" ).prop( "disabled", true );
                    $( "#ot" ).prop( "disabled", true );
                    $( "#advance" ).prop( "disabled", true );
                    $( "#out_time" ).prop( "disabled", true );


                }else{

                        $( "#time_in" ).prop( "disabled", false );
                        $( "#ot" ).prop( "disabled", false );
                         $( "#advance" ).prop( "disabled", false );
                         $( "#out_time" ).prop( "disabled", false );

                }
    });

             $("#empolyee_id").change(function() {

                
    
                var empolyee =  this.value;
               
                $.ajax({
                            type:'POST',
                            url:'<?php echo base_url('admin/get_empolyees_data'); ?>',
                            data:{empolyee:empolyee},
                            dataType:'json',
                            success:function(data){
                            
                                  //  $('#salaries').val(data.salary);
                                   $('.salaries').val(data[0].salary);
                                    $('.depart').val(data[0].depart);
                                      
                                  
                            },
                            error:function(data){console.log(data.responseText);}
                        });

    });

        $("#self_life_start").keyup(function() {

          var self_life = $('#self_life').val();
         var self_life_start = $('#self_life_start').val();
           var total = self_life-self_life_start;
         var output=parseInt(total).toLocaleString(); 
          $('#self_life_remain').val(output);
        });



                
         var sheet = $('#add_sheet');   
    
        sheet.on('submit',function(e){


        e.preventDefault();
        
        var add_sheet = sheet.serialize();
         var emp_id = $('#emp_id').val();
            
            $.ajax({
                type:'POST',
                url:'<?php echo base_url('Admin/daily_work_sheet'); ?>',
                data:add_sheet,
                dataType:'json',
                success:function(data){
                    console.log('first'+data.status);
                    if(data.status === 'true'){
                        console.log('second'+data.status);
                        $('#sheet_success').show().html('added Successfully');
                        setTimeout(function() {
                                    window.location.reload(); } );
                        //setTimeout(function(){location.href='<?php //echo base_url('Admin/daily_work_sheet/'); ?>'+emp_id} , 2000);
                    }else{
                        console.log('third'+data);          
                    }
                },
                error:function(data){console.log(data.responseText);}
            });
       // }
    });

            function delete_data(id) { 
                var id = id;
                 if (confirm('Are you sure you want to Delete.?')) {
                  var emp_id = $('#emp_id').val();
                 $.ajax({
                        type:'POST',
                        url:'<?php echo base_url('Admin/delete_daily_sheet/'); ?>'+id,
                        data:id,
                        dataType:'json',
                        success:function(data){
                            console.log('first'+data.status);
                            
                                console.log('second'+data.status);
                                //debugger;
                                $('#daily_danger').show().html('Record Deleted Successfully');
                                setTimeout(function() {
                                    window.location.reload(); }  );
                              //setTimeout(function(){location.href='<?php //echo base_url('Admin/daily_work_sheet/'); ?>'+emp_id} , 2000);

                            
                        },
                        error:function(data){console.log(data.responseText);}
                    });
                 }
                } 


                

               function add_details(id) { 
                  var id =  id;
                  //alert(id);

                  $.ajax({
                            type:'POST',
                            url:'<?php echo base_url('Admin/get_form_ad_ot'); ?>',
                            data:{id:id},
                            dataType:'json',
                            success:function(data){
                                //console.log('first'+data.status);
                                //if(data.status === 'true'){
                                 $('#add_details').show().html(data.html);
                                   //$('#bom_details').show(data);
                               /* }else{
                                    //console.log('third'+data);          
                                }*/
                            },
                            error:function(data){console.log(data.responseText);}
                        });
                   
                    } 


                    
                function view_ot_advance(id) { 
                  var id =  id;
                  //alert(id);

                  $.ajax({
                            type:'POST',
                            url:'<?php echo base_url('Admin/view_ot_advance'); ?>',
                            data:{id:id},
                            dataType:'json',
                            success:function(data){
                                //console.log('first'+data.status);
                                //if(data.status === 'true'){
                                 $('#details').show().html(data.html);
                                   //$('#bom_details').show(data);
                               /* }else{
                                    //console.log('third'+data);          
                                }*/
                            },
                            error:function(data){console.log(data.responseText);}
                        });
                   
                    } 


                 function btnExport_monthly()
        {
            
            var tab_text="<table border='2px'><tr bgcolor='#ebebeb'>";
            var textRange; var j=0;
            tab = document.getElementById('example5'); // id of table

            for(j = 0 ; j < tab.rows.length ; j++) 
            {     
                tab_text=tab_text+tab.rows[j].innerHTML+"</tr>";
                //tab_text=tab_text+"</tr>";
            }

            tab_text=tab_text+"</table>";
            tab_text= tab_text.replace(/<A[^>]*>|<\/A>/g, "");//remove if u want links in your table
            tab_text= tab_text.replace(/<img[^>]*>/gi,""); // remove if u want images in your table
            tab_text= tab_text.replace(/<input[^>]*>|<\/input>/gi, ""); // reomves input params


            var ua = window.navigator.userAgent;
            var msie = ua.indexOf("MSIE "); 

            if (msie > 0 || !!navigator.userAgent.match(/Trident.*rv\:11\./))      // If Internet Explorer
            {
                txtArea2.document.open("txt/html","replace");
                txtArea2.document.write(tab_text);
                txtArea2.document.close();
                txtArea2.focus(); 
                sa=txtArea2.document.execCommand("SaveAs",true,"Generation_School_Report");
            }  
            else                 //other browser not tested on IE 11
                sa = window.open('data:application/vnd.ms-excel,' + encodeURIComponent(tab_text));  

            return (sa);
        }
            
            </script>   

               <?php  $this->load->view('footer'); ?>
                
        </body>

        <!-- Mirrored from edumin.dexignlab.com/xhtml/add-departments.html by HTTrack Website Copier/3.x [XR&CO'2014], Tue, 17 Nov 2020 13:56:15 GMT -->
        </html>