<?php 
    if(!isset($permissions['customers']['customers-limit-changes'])
    || isset($permissions['customers']['customers-limit-changes'])
    && $permissions['customers']['customers-limit-changes'] == 0) redirect('admin/dashboard');	
?>
<script src="<?php echo site_url(); ?>assets/js/plugin/datatables1_10_7/jquery.dataTables.min.js"></script>
<script src="<?php echo site_url(); ?>assets/js/plugin/datatables/dataTables.colReorder.min.js"></script>
<script src="<?php echo site_url(); ?>assets/js/plugin/datatables/dataTables.colVis.min.js"></script>
<script src="<?php echo site_url(); ?>assets/js/plugin/datatables/dataTables.tableTools.min.js"></script>
<script src="<?php echo site_url(); ?>assets/js/plugin/datatables/dataTables.bootstrap.min.js"></script>
<script src="<?php echo site_url(); ?>assets/js/plugin/datatable-responsive/datatables.responsive.min.js"></script>
<script src="//cdn.datatables.net/buttons/1.6.1/js/dataTables.buttons.min.js" crossorigin="anonymous"></script>
<script src="//cdn.datatables.net/buttons/1.6.1/js/buttons.flash.min.js" crossorigin="anonymous"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/jszip/3.1.3/jszip.min.js" crossorigin="anonymous"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.53/pdfmake.min.js" crossorigin="anonymous"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.53/vfs_fonts.js" crossorigin="anonymous"></script>
<script src="//cdn.datatables.net/buttons/1.6.1/js/buttons.html5.min.js" crossorigin="anonymous"></script>
<script src="//cdn.datatables.net/buttons/1.6.1/js/buttons.print.min.js" crossorigin="anonymous"></script>
<script src="//cdn.datatables.net/buttons/1.6.1/js/buttons.colVis.min.js" crossorigin="anonymous"></script>
<div id="main" role="main">
	<div id="content">
	    <div class="row">
			<div class="col-lg-12">
				<h1 class="page-title txt-color-blueDark">
					<i class="fa fa-arrow-circle-right fa-fw "></i>
                    <?php echo $this->lang->line('oblego'); ?>
					<span>
                    <?php echo $this->lang->line('all_updates'); ?>
					</span>
				</h1>
				<br/><br/>
			</div>
		</div>
	    <div class="row">
	        <div class="col-lg-9">
	            <div class="row">
	                <div class="col-lg-9">
        	            <div class="row">
        	                <form method="POST" action="<?php echo site_url(); ?>admin/customers/limitChanges">
            	                <div class="col-lg-2">
            	                    <div class="form-group">
                                        <input type="text" class="form-control datepicker" name="from_date" id="from_date" value="<?php echo date('d/m/Y', strtotime($date_from)); ?>" autocomplete="OFF" placeholder=" <?php echo $this->lang->line('from_date'); ?>
">
                                    </div>
            	                </div>
            	                <div class="col-lg-2">
            	                    <div class="form-group">
                                        <input type="text" class="form-control datepicker" name="to_date" id="to_date" value="<?php echo date('d/m/Y', strtotime($date_to)); ?>" autocomplete="OFF" placeholder="<?php echo $this->lang->line('to_date'); ?>">
                                    </div>
            	                </div>
            	                <div class="col-lg-2">
            	                    <button type="submit" class="btn btn-success">
                                    <?php echo $this->lang->line('search'); ?>
            	                    </button>
            	                </div>
        	                </form>
        	            </div>
        	            <br/><br/><br/><br/>
        	       </div>
	                <div class="col-lg-12">
                        <div class="table-responsive">
        					<table id="dt_basic2" class="table table-striped table-bordered table-hover smart-form">
        						<thead>
        							<th>#</th>
        							<th> <?php echo $this->lang->line('customer'); ?></th>
        							<th><?php echo $this->lang->line('user'); ?></th>
        							<th><?php echo $this->lang->line('credit'); ?></th>
        							<th><?php echo $this->lang->line('sum'); ?></th>
        							<th><?php echo $this->lang->line('oblego_before'); ?></th>
        							<th><?php echo $this->lang->line('oblego_after'); ?></th>        						
        							<th><?php echo $this->lang->line('date'); ?></th>
        						</thead>
        						<tbody>
                                <?php foreach($limits as $limit){ ?>
        							<tr>
        							    <td><?php echo $limit->id; ?></td>
        							    <td><?php echo getCustomerName($limit->customerId); ?></td>
                                        <td><?php echo getUserName($limit->userId); ?></td>
                                        <td>
                                            <?php if( $limit->app == 'cards_limit' ){ ?>
                                                <?php echo $this->lang->line('cards'); ?>
                                            <?php }else if( $limit->app == 'creditPPLimit' ){ ?>
                                                טעינות
                                            <?php }else{ ?>
                                                השכרות
                                            <?php }; ?>
                                        </td>
                                        <td>
                                            <?php if( $limit->type == 'credit' ){ ?>
                                                <?php echo $limit->total; ?>
                                            <?php }else{ ?>
                                                <?php echo number_format($limit->total *-1, 2); ?>
                                            <?php }; ?>
                                        </td>
                                        <td><?php echo $limit->limitBefore; ?></td>
                                        <td><?php echo $limit->limitAfter; ?></td>
                                        <td><?php echo date('d/m/Y H:i', strtotime($limit->dateCreation)); ?></td>
        							</tr>
                                <?php } ?>
        						</tbody>
        					</table>
        				</div>
        	       </div>
	            </div>
	        </div>
	  
	           <div class="row">
	               <div class="col-lg-12">
    					<div class="well well-sm txt-color-white" style="background-color: #3b9ff3;">
    						<p class="font-lg txt-color-white"><i class="fa fa-md fa-money" style="margin: 3% 0 0 5%;"></i>
        						<span class="fixMinus">
        						    <?php echo number_format($sum['credits'], 2); ?>
        						</span>
    						</p>
                            <p class="font-lg txt-color-white">סה"כ הגבלות השכרות</p>
    					</div>
	               </div>
	               
	               <div class="col-lg-12">
    					<div class="well well-sm txt-color-white" style="background-color: #009688;">
    						<p class="font-lg txt-color-white"><i class="fa fa-md fa-money" style="margin: 3% 0 0 5%;"></i>
        						<span class="fixMinus">
        						    <?php echo number_format($sum['creditPPLimit'], 2); ?>
        						</span>
    						</p>
                            <p class="font-lg txt-color-white">סה"כ הגבלות טעינות</p>
    					</div>
	               </div>
	               
	               <div class="col-lg-12">
    					<div class="well well-sm txt-color-white" style="background-color: #FF5722;">
    						<p class="font-lg txt-color-white"><i class="fa fa-md fa-money" style="margin: 3% 0 0 5%;"></i>
        						<span class="fixMinus">
        						    <?php echo number_format($sum['cards_limit'], 2); ?>
        						</span>
    						</p>
                            <p class="font-lg txt-color-white">סה"כ הגבלות כרטיסים</p>
    					</div>
	               </div>
	               
	               <div class="col-lg-12">
    					<div class="well well-sm txt-color-white" style="background-color: #d60f00;">
    						<p class="font-lg txt-color-white"><i class="fa fa-md fa-money" style="margin: 3% 0 0 5%;"></i>
        						<span class="fixMinus">
        						    <?php echo number_format($sum['credits'] + $sum['creditPPLimit'] + $sum['cards_limit'], 2); ?>
        						</span>
    						</p>
                            <p class="font-lg txt-color-white">סה"כ הגבלות</p>
    					</div>
	               </div>
	           </div>
	       </div>
        </div>
    </div>
</div>
<style>
  .dt-buttons{
    float: left;
    text-align: right;
  }

  .dt-button {
    background: transparent;
    border: 1px solid #a90329;
    padding: 5px;
    padding-right: 20px;
    padding-left: 20px;
    font-weight: bold;
    border-radius: 25px;
    color: #a90329;
  }

  .dt-button-collection .dt-button {
        background: #ffffff;
        float: right;
        opacity: 0.5;
    }

    .dt-button-collection {
        margin-top: 7px;
        position: absolute;
        z-index: 9999;
        background: #0000007a;
        width: 140%;
        right: 100px;
        padding: 7px;
        border-radius: 25px;
    }

    button.dt-button.buttons-columnVisibility.active {
        background: white;
        opacity: 1;
    }
    
    td.api_result_td {
        cursor:pointer;
        max-width: 120px!important;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    @media only screen and (max-width: 479px) and (min-width: 320px){
        .dt-toolbar {
            margin-top: 50px;
        }
        .dt-buttons.col-sm-6.col-xs-12.hidden-xs {
            display: block !Important;
        }
        button.dt-button.buttons-excel.buttons-html5 {
            margin-left: 80px;
        }
    }
</style>
<script type="text/javascript">
	$(document).ready(function(){
		var oTbl1 = $('#dt_basic2').DataTable({
            "sDom": "<'dt-toolbar'<'col-xs-12 col-sm-6'f><'dt-buttons col-sm-6 col-xs-12 hidden-xs'l>r>"+
            "t"+
            "<'dt-toolbar-footer'<'col-sm-6 col-xs-12 hidden-xs'i><'col-xs-12 col-sm-6'p>>",
			"buttons": [ 'excelHtml5'],
            "processing": false,
            "bStateSave": false,
			"dom": 'Bfrtip',
			"order": [[ 0, "desc" ]],
            "pagingType": "full_numbers",
            "lengthMenu": [ [10, 25, 50, -1], [10, 25, 50, "הכל"] ],
			"pageLength": 10,
			"sPaginationType": "full_numbers",
			"iDisplayLength": 10,
            "oLanguage": {
                "sProcessing":   "מעבד...",
                "sZeroRecords":  "לא נמצאו רשומות מתאימות",
                "sInfo": "_START_ עד _END_ מתוך _TOTAL_ רשומות" ,
                "sInfoEmpty":    "0 עד 0 מתוך 0 רשומות",
                "sInfoFiltered": "(מסונן מסך _MAX_  רשומות)",
                "sInfoPostFix":  "",
                "sUrl":          "",
                "oPaginate": {
                    "sFirst":    "ראשון",
                    "sPrevious": "קודם",
                    "sNext":     "הבא",
                    "sLast":     "אחרון"
                }
            },
            orderCellsTop: true,
        	fixedHeader: true,
        	columnDefs: [{
              target: 7,
              type: 'datetime-moment'
            }]
		});
		oTbl1.buttons().container().appendTo( '.dataTables_filter' );
        $('input[aria-controls="dt_basic2"]').attr('placeholder', 'חיפוש...');
        $('#dt_basic2_info').css('float', 'left').parent().css('float', 'left');
        $('.dataTables_paginate ').parent().css('float', 'right');
        $('.dataTables_paginate ').css('text-align', 'right');
        
        $(".datepicker").datepicker({
            dateFormat: 'dd/mm/yy',
            prevText: '<i class="fa fa-chevron-right"></i>',
            nextText: '<i class="fa fa-chevron-left"></i>',
        });
	});
</script>













