<!-- start ajax model -->

<div id="ajax-modal" class="modal fade" data-backdrop="static" data-keyboard="false" tabindex="-1" style="display: none;"></div>
<!-- end ajax model --> 
<!-- start popup box-->
<div class="modal fade" id="myModal4" tabindex="-1" role="dialog" aria-hidden="true">
  <div class="modal-content">
    <div class="modal-header">
      <button type="button" class="close" data-dismiss="modal" aria-hidden="true"> &times; </button>
      <h4 class="modal-title">Confirm</h4>
    </div>
    <div class="modal-body">
      <p id="label"> </p>
    </div>
    <div class="modal-footer">
      <input id="sel_id" type="hidden"/>
      <input id="page" type="hidden"/>
      <input id="popup_type" type="hidden"/>
      <button aria-hidden="true" data-dismiss="modal" class="btn btn-default"> Close </button>
      <button id="conirm" class="btn btn-default" data-dismiss="modal"> Confirm </button>
    </div>
  </div>
</div>
</div>
<!-- end pop upbox--> 
<!-- start: MAIN JAVASCRIPTS --> 
<!--[if lt IE 9]>
		<script src="<?php //echo asset_url(); ?>plugins/respond.min.js"></script>
		<script src="<?php //echo asset_url(); ?>plugins/excanvas.min.js"></script>
		<script type="text/javascript" src="<?php //echo asset_url(); ?>plugins/jQuery-lib/1.10.2/jquery.min.js"></script>
		<![endif]--> 
<!--[if gte IE 9]><!--> 
<script src="<?php echo asset_url(); ?>plugins/jQuery-lib/2.0.3/jquery.min.js"></script> 
<script src="<?php echo asset_url(); ?>plugins/bootstrap/js/bootstrap.min.js"></script> 
<script src="<?php echo asset_url(); ?>plugins/bootstrap-hover-dropdown/bootstrap-hover-dropdown.min.js"></script> 


<script src="<?php echo asset_url(); ?>js/moment-with-locales.js"></script> 
<script src="<?php echo asset_url(); ?>/plugins/bootstrap-datepicker/js/bootstrap-datepicker.js"></script> 

<script type="text/javascript" src="<?php echo asset_url(); ?>js/bootbox.min.js"></script> 
<script type="text/javascript" src="<?php echo asset_url(); ?>js/accounting.js"></script> 
<script type="text/javascript" src="<?php echo asset_url(); ?>js/accounting.min.js"></script>
<script src="<?php echo asset_url(); ?>plugins/bootstrap-modal/js/bootstrap-modal.js"></script> 
<script src="<?php echo asset_url(); ?>plugins/bootstrap-modal/js/bootstrap-modalmanager.js"></script> 
 <script src="<?php echo asset_url(); ?>js/ui-modals.js"></script> 
<script src="<?php echo asset_url(); ?>js/main.js"></script> 

<script src="<?php echo asset_url(); ?>plugins/select2/select2.min.js"></script> 
<script src="<?php echo asset_url(); ?>plugins/jquery-validation/dist/jquery.validate.min.js"></script> 
<script src="<?php echo asset_url(); ?>plugins/gritter/js/jquery.gritter.min.js"></script>
<!--<![endif]--> 


<?php /*?>
<script src="<?php echo asset_url(); ?>plugins/jquery-ui/jquery-ui-1.10.2.custom.min.js"></script> 
<script src="<?php echo asset_url(); ?>plugins/bootstrap/js/bootstrap.min.js"></script> 
<script src="<?php echo asset_url(); ?>plugins/bootstrap-hover-dropdown/bootstrap-hover-dropdown.min.js"></script> 
<script src="<?php echo asset_url(); ?>plugins/blockUI/jquery.blockUI.js"></script> 
<script src="<?php echo asset_url(); ?>plugins/iCheck/jquery.icheck.min.js"></script> 
<script src="<?php echo asset_url(); ?>plugins/perfect-scrollbar/src/jquery.mousewheel.js"></script> 
<script src="<?php echo asset_url(); ?>plugins/perfect-scrollbar/src/perfect-scrollbar.js"></script> 
<script src="<?php echo asset_url(); ?>plugins/less/less-1.5.0.min.js"></script> 
<script src="<?php echo asset_url(); ?>plugins/jquery-cookie/jquery.cookie.js"></script> 
<script src="<?php echo asset_url(); ?>plugins/bootstrap-colorpalette/js/bootstrap-colorpalette.js"></script> 
<script src="<?php echo asset_url(); ?>js/main.js"></script> 
<script src="<?php echo asset_url(); ?>plugins/bootstrap-modal/js/bootstrap-modal.js"></script> 
<script src="<?php echo asset_url(); ?>plugins/bootstrap-modal/js/bootstrap-modalmanager.js"></script> 
<script src="<?php echo asset_url(); ?>js/ui-modals.js"></script> 
<script src="<?php echo asset_url(); ?>plugins/bootstrap-fileupload/bootstrap-fileupload.min.js"></script> 
<script src="<?php echo asset_url(); ?>plugins/select2/select2.min.js"></script> 
<script src="<?php echo asset_url(); ?>plugins/jquery-validation/dist/jquery.validate.min.js"></script> 
<script type="text/javascript" src="<?php echo asset_url(); ?>plugins/DataTables/media/js/jquery.dataTables.min.js"></script> 
<script type="text/javascript" src="<?php echo asset_url(); ?>plugins/DataTables/media/js/DT_bootstrap.js"></script> 
<script src="<?php echo asset_url(); ?>js/table-data.js"></script> 
<script src="<?php echo asset_url(); ?>plugins/gritter/js/jquery.gritter.min.js"></script> 
<script type="text/javascript" src="<?php echo asset_url(); ?>js/jquery.dataTables.min.js"></script> 
<script type="text/javascript" src="<?php echo asset_url(); ?>js/dataTables.bootstrap.min.js"></script> 
<script src="<?php echo asset_url(); ?>js/jquery-ui.js" ></script> 
<script src="<?php echo asset_url(); ?>js/moment-with-locales.js"></script> 
<script type="text/javascript" src="<?php echo asset_url(); ?>js/bootstrap-datetimepicker.js"></script> 
<script type="text/javascript" src="<?php echo asset_url(); ?>js/bootbox.min.js"></script> 
<script type="text/javascript" src="<?php echo asset_url(); ?>js/accounting.js"></script> 
<script type="text/javascript" src="<?php echo asset_url(); ?>js/accounting.min.js"></script> 



<!-- start: JAVASCRIPTS REQUIRED FOR THIS PAGE ONLY --> 

<script src="<?php echo asset_url(); ?>/plugins/jquery-inputlimiter/jquery.inputlimiter.1.3.1.min.js"></script> 
<script src="<?php echo asset_url(); ?>/plugins/autosize/jquery.autosize.min.js"></script> 
<script src="<?php echo asset_url(); ?>/plugins/jquery.maskedinput/src/jquery.maskedinput.js"></script> 
<script src="<?php echo asset_url(); ?>/plugins/jquery-maskmoney/jquery.maskMoney.js"></script> 
<script src="<?php echo asset_url(); ?>/plugins/bootstrap-datepicker/js/bootstrap-datepicker.js"></script> 
<script src="<?php echo asset_url(); ?>/plugins/bootstrap-timepicker/js/bootstrap-timepicker.min.js"></script> 
<script src="<?php echo asset_url(); ?>/plugins/bootstrap-daterangepicker/moment.min.js"></script> 
<script src="<?php echo asset_url(); ?>/plugins/bootstrap-daterangepicker/daterangepicker.js"></script> 
<script src="<?php echo asset_url(); ?>/plugins/bootstrap-colorpicker/js/bootstrap-colorpicker.js"></script> 
<script src="<?php echo asset_url(); ?>/plugins/bootstrap-colorpicker/js/commits.js"></script> 
<script src="<?php echo asset_url(); ?>/plugins/jQuery-Tags-Input/jquery.tagsinput.js"></script> 
<script src="<?php echo asset_url(); ?>/plugins/bootstrap-fileupload/bootstrap-fileupload.min.js"></script> 
<script src="<?php echo asset_url(); ?>/plugins/summernote/build/summernote.min.js"></script> 
<script src="<?php echo asset_url(); ?>/plugins/ckeditor/ckeditor.js"></script> 
<script src="<?php echo asset_url(); ?>/plugins/ckeditor/adapters/jquery.js"></script> 
<script src="<?php echo asset_url(); ?>/js/form-elements.js"></script> 



<?php */?>
<script type="text/javascript" src="<?php echo asset_url(); ?>js/jquery.dataTables.min.js"></script> 
<script type="text/javascript" src="<?php echo asset_url(); ?>js/dataTables.bootstrap.min.js"></script> 











<script type="text/javascript">

			jQuery(document).ready(function() {
				Main.init();
				UIModals.init();
				$(".search-select").select2({
				            allowClear: true
				        });
				$('.date-picker').datepicker({
            		autoclose: true
        		});
			});
			
			//category model load event
            var $modal = $('#ajax-modal');
            $('a#modal_ajax_demo_btn').on('click', function () {
                // create the backdrop and wait for next modal to be triggered
                $('body').modalmanager('loading');
                setTimeout(function () {
                    $modal.load('<?php echo base_url("product_category/add_category"); ?>', '', function () { 
                        $modal.modal();
                    });
                }, 1000);
            });

            //sub category model load event
            $('a#modal_ajax_demo_btn1').on('click', function () {
                // create the backdrop and wait for next modal to be triggered
                $('body').modalmanager('loading');
                setTimeout(function () {
                    $modal.load('<?php echo base_url("product_category/add_subcategory"); ?>', '', function () {
                        $modal.modal();

				        $(".search-select").select2({
				            allowClear: true
				        });
                    });
                }, 1000);
            });


			//category model load event
           // var $modal = $('#ajax-modal');
            $('a#modal_ajax_customers_btn').on('click', function () {
				
                // create the backdrop and wait for next modal to be triggered
                $('body').modalmanager('loading');
                setTimeout(function () {
                    $modal.load('<?php echo base_url("customers/create_customers?btn_id=cus_id"); ?>', '', function () {
                        $modal.modal();
                    });
                }, 1000);
            });
			
			
			
			 $('a#modal_ajax_customers_btn_garanter').on('click', function () {
				var cus_type=2;
                // create the backdrop and wait for next modal to be triggered
                $('body').modalmanager('loading');
                setTimeout(function () {
                    $modal.load('<?php echo base_url("customers/create_customers?btn_id=g_cus_id"); ?>', '', function () {
                        $modal.modal();
                    });
                }, 1000);
            });
			
			

			//category model load event
           // var $modal = $('#ajax-modal');
            $('a#modal_ajax_suppliers_btn').on('click', function () {
                // create the backdrop and wait for next modal to be triggered
                $('body').modalmanager('loading');
                setTimeout(function () {
                    $modal.load('<?php echo base_url("suppliers/create_supplier"); ?>', '', function () {
                        $modal.modal();
                    });
                }, 1000);
            });

			//category model load event
           // var $modal = $('#ajax-modal');
            $('a#modal_ajax_tax_rates_btn').on('click', function () {
                // create the backdrop and wait for next modal to be triggered
                $('body').modalmanager('loading');
                setTimeout(function () {
                    $modal.load('<?php echo base_url("tax_rates/add_tax_rates"); ?>', '', function () {
                        $modal.modal();
                    });
                }, 1000);
            });
			
			//service model load event
            $('a#modal_ajax_service_btn').on('click', function () {
                // create the backdrop and wait for next modal to be triggered
                $('body').modalmanager('loading');
                setTimeout(function () {
                    $modal.load('<?php echo base_url("service/add"); ?>', '', function () {
                        $modal.modal();
                    });
                }, 1000);
            });
			
			


            //category model load event
            var $modal = $('#ajax-modal');
            $('a#modal_ajax_locations_btn').on('click', function () {
                // create the backdrop and wait for next modal to be triggered
                $('body').modalmanager('loading');
                setTimeout(function () {
                    $modal.load('<?php echo base_url("locations/create_location"); ?>', '', function () {
                        $modal.modal();
                    });
                }, 1000);
            });
			
			//sales payment model load event
            var $modal = $('#ajax-modal');
            $('a#modal_ajax_sales_payment_btn').on('click', function () {
                // create the backdrop and wait for next modal to be triggered
                //var sale_type = 'none';
				var bkng_id=$('#bkng_id').val();
                
                $('body').modalmanager('loading');
                setTimeout(function () {
                    $modal.load('<?php echo base_url("booking/payments/");?>/'+bkng_id, '', function () {
                        $modal.modal();
						$('#sale_pymnt_amount').focus(); 
                    });
                }, 1000);
            });
            
			//technician model load event
			var $modal = $('#ajax-modal');
            $('a#modal_ajax_technician_btn').on('click', function () {
				
                // create the backdrop and wait for next modal to be triggered
                $('body').modalmanager('loading');
                setTimeout(function () {
                    $modal.load('<?php echo base_url("technician/add"); ?>', '', function () {
                        $modal.modal();
                    });
                }, 1000);
            });
			
			//salary model load event
			var $modal = $('#ajax-modal');
            $('a#modal_ajax_salary_btn').on('click', function () {
				
                // create the backdrop and wait for next modal to be triggered
                $('body').modalmanager('loading');
                setTimeout(function () {
                    $modal.load('<?php echo base_url("salary/add"); ?>', '', function () {
                        $modal.modal();
						$(".technician_id").select2({
				            allowClear: true
				        });
                    });
                }, 1000);
            });
			
			
			//expenses model load event
			var $modal = $('#ajax-modal');
            $('a#modal_ajax_expenses_btn').on('click', function () {
				
                // create the backdrop and wait for next modal to be triggered
                $('body').modalmanager('loading');
                setTimeout(function () {
                    $modal.load('<?php echo base_url("expenses/add"); ?>', '', function () {
                        $modal.modal();
						$(".technician_id").select2({
				            allowClear: true
				        });
                    });
                }, 1000);
            });			
			
            function set_message (title,text) {
                    $.gritter.add({
                    // (string | mandatory) the heading of the notification
                    title: title,
                    // (string | mandatory) the text inside the notification
                    text: text,
                    // (string | optional) the image to display on the left
                    sticky: false,
                    // (int | optional) the time you want it to be alive for before fading out
                    time: ''
                });
            }

        //notification
            function displayNotice(page,msg){
                //alert();
                $.gritter.add({
                // (string | mandatory) the heading of the notification
                title: 'Notice!',
                // (string | mandatory) the text inside the notification
                text: msg,
                // (string | optional) the image to display on the left
                image: '',
                // (bool | optional) if you want it to fade out on its own or just sit there
                sticky: false,
                // (int | optional) the time you want it to be alive for before fading out
                time: ''
            });
            return false;
            }
//common function
function is_numeric(mixed_var){var whitespace=" \n\r\t\f\x0b\xa0\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u200b\u2028\u2029\u3000";return(typeof mixed_var==='number'||(typeof mixed_var==='string'&&whitespace.indexOf(mixed_var.slice(-1))===-
1))&&mixed_var!==''&&!isNaN(mixed_var);}

function formatDecimal(x){
    return parseFloat(parseFloat(x).toFixed(2));
}

			
function changeColectedStatus(id,sta,type){
				 //  alert(id);
	   var fld_id='collected_'+id;
	  // alert(sta);
	  paymnt_id=id;
	  if(sta){
		  status=1;
	  }else {
		  status=0;
	  }

			$.post( "<?php echo base_url();?>loan/change_collected_status", {paymnt_id:paymnt_id, status:status, type:type})
	  .done(function( data ) {
		
	  	var obj = jQuery.parseJSON(data);
		 if (obj.status==0) 
		{
		
		}		  
	   if (obj.status==1) 
		{
			var type_name='';
			if(type=='collected'){
			type_name='Collected';
		}
		if(type=='deposited'){
			type_name='Deposited';
		}
		if(type=='returned'){
			type_name='Returned';
		}
		
	   if(sta){
		   displayNotice('Payment','Payment '+type_name);
    	 // Code in the case checkbox is checked.
		} else {
			displayNotice('Payment','Deleted Payment '+type_name+ ' Status');
		  // alert('no');
     		// Code in the case checkbox is NOT checked.
		}
		}
		});
	   return false;
	   
   }
		</script> 
<!-- end: MAIN JAVASCRIPTS --> 
