<style type="text/css">
label {
	font-weight: 700;
}

.form-horizontal .form-group {
	margin-left: 0;
	margin-right: 0;
}
.report_view_th {
  background-color: #428bca;
  color: #fff !important;
  font-size: 14px;
}
</style>
<style type="text/css">
label {
	font-weight: 700;
}

.form-horizontal .form-group {
	margin-left: 0;
	margin-right: 0;
}
td {
	font-size: 13px;
}
.des_table td{
	padding:10px;
	border-bottom:1px solid #eee;
	vertical-align:top;
}
	.radio{
  float: left;
  margin-right: 10px !important;
  margin-top: -4px !important;
}
.accessories_header {
  border-bottom: 1px solid #a0a0a4;
  margin-bottom: 10px;
}
.accessories_header div {
  font-size: 14px;
  margin-left: -10px;
  margin-right: -10px;
}

.panel-heading{
	padding-left:15px;
	margin-bottom:15px;
	margin-top:10px;
	
}
.service_table {
  border: 1px solid #ccc;

}
.service_table td{
  border: 1px solid #ccc;
  padding: 5px !important;
}
.col-sm-3 {
  min-height: 180px !important;
}
</style>

	<?php $this->load->view("common/header"); ?>
	<!-- end: HEAD -->
       
		<!-- start: CSS REQUIRED FOR THIS PAGE ONLY -->
		<link rel="stylesheet" type="text/css" href="<?php echo asset_url(); ?>plugins/select2/select2.css" />
		<link rel="stylesheet" href="<?php echo asset_url(); ?>plugins/DataTables/media/css/DT_bootstrap.css" />
		<link href="<?php echo asset_url(); ?>plugins/bootstrap-modal/css/bootstrap-modal-bs3patch.css" rel="stylesheet" type="text/css"/>
		<link href="<?php echo asset_url(); ?>plugins/bootstrap-modal/css/bootstrap-modal.css" rel="stylesheet" type="text/css"/>
		<link rel="stylesheet" href="<?php echo asset_url(); ?>plugins/bootstrap-fileupload/bootstrap-fileupload.min.css">
		<link rel="stylesheet" href="<?php echo asset_url(); ?>plugins/select2/select2.css">


		<link rel="stylesheet" href="<?php echo asset_url(); ?>plugins/select2/select2.css">
		<link rel="stylesheet" href="<?php echo asset_url(); ?>plugins/datepicker/css/datepicker.css">
		<link rel="stylesheet" href="<?php echo asset_url(); ?>plugins/bootstrap-timepicker/css/bootstrap-timepicker.min.css">
		<link rel="stylesheet" href="<?php echo asset_url(); ?>plugins/bootstrap-daterangepicker/daterangepicker-bs3.css">
		<link rel="stylesheet" href="<?php echo asset_url(); ?>plugins/bootstrap-colorpicker/css/bootstrap-colorpicker.css">
		<link rel="stylesheet" href="<?php echo asset_url(); ?>plugins/jQuery-Tags-Input/jquery.tagsinput.css">
		<link rel="stylesheet" href="<?php echo asset_url(); ?>plugins/bootstrap-fileupload/bootstrap-fileupload.min.css">
		<link rel="stylesheet" href="<?php echo asset_url(); ?>plugins/summernote/build/summernote.css">
        
          <link rel="stylesheet" type="text/css" href="<?php echo asset_url(); ?>css/jquery.dataTables.css">
          
          
          
          


		<!-- end: CSS REQUIRED FOR THIS PAGE ONLY -->
	<!-- end: HEAD -->
	<!-- start: BODY -->
	<body>
		<!-- start: HEADER -->
		<div class="navbar navbar-inverse navbar-fixed-top">
			<!-- start: TOP NAVIGATION CONTAINER -->
			<div class="container">
				<div class="navbar-header">
					<!-- start: RESPONSIVE MENU TOGGLER -->
					<button data-target=".navbar-collapse" data-toggle="collapse" class="navbar-toggle" type="button">
						<span class="clip-list-2"></span>
					</button>
					<!-- end: RESPONSIVE MENU TOGGLER -->
					<!-- start: LOGO -->
					<?php $this->load->view("common/logo"); ?>
					<!-- end: LOGO -->
				</div>
				<div class="navbar-tools">
					<!-- start: TOP NAVIGATION MENU -->
				<?php $this->load->view("common/notifications.php"); ?>
					<!-- end: TOP NAVIGATION MENU -->
				</div>
			</div>
			<!-- end: TOP NAVIGATION CONTAINER -->
		</div>
		<!-- end: HEADER -->
		<!-- start: MAIN CONTAINER -->
		<div class="main-container">
			<div class="navbar-content">
				<!-- start: SIDEBAR -->
				<?php $this->load->view("common/navigation"); ?>
				<!-- end: SIDEBAR -->
			</div>
			<!-- start: PAGE -->
			<div class="main-content">
				<!-- end: SPANEL CONFIGURATION MODAL FORM -->
				<div class="container">
					<!-- start: PAGE HEADER -->
					<div class="row">
						<div class="col-sm-12">
							<!-- start: PAGE TITLE & BREADCRUMB -->
							<ol class="breadcrumb">
                            	<li>
									<a href="<?php echo base_url('dashboard'); ?>">
										 Dashboard 
									</a>
								</li>
								<li>
									<a href="<?php echo base_url('service'); ?>">
										Service
									</a>
								</li>
                               
								<li class="active">
									Reference ID <?php echo $service_id ?>
								</li>
								<li class="search-box">
									<form class="sidebar-search">
										<div class="form-group">
											<input type="text" placeholder="Start Searching...">
											<button class="submit">
												<i class="clip-search-3"></i>
											</button>
										</div>
									</form>
								</li>
							</ol>
							
								
                                <div class="">  
                               <?php  
							   $message = $this->session->flashdata('message');
							   if($message){ ?>
                               	<div class="alert alert-success">
									<button type="button" class="close" data-dismiss="alert">×</button>
<?php echo $message ?> </div>
                               		
                               <?php
                               }
							    ?>
                               
                                 
							</div>

                            
						</div>
					</div>
					<!-- end: PAGE HEADER -->
					<!-- start: PAGE CONTENT 
                    <!-- start grid -->
                    <div class="row">
						<div class="col-md-12">
                        <?php //print_r($service_details);?>
                        
							<!-- start: DYNAMIC TABLE PANEL -->
							<div class="panel panel-default">
								
									
									
									
                                
                                
                                
                                
                                
                                
								<div class="col-xs-12 panel-body">
                                
<div class="buttons">
<div class="btn-group btn-group-right" style="float:right;">

<!-- btn-group-justified-->
<!--<div class="btn-group"><a title="" class="tip btn btn-primary tip" data-target="#myModal" data-toggle="modal" href="#" data-original-title="Add Payment" id="modal_ajax_sales_payment_btn"><i class="fa fa-money"></i> <span class="hidden-sm hidden-xs">Add Payment</span></a></div>-->


 
</div>
</div> <!--buttons-->   

<div class="clearfix">&nbsp;</div>                             
                                
                                
									 
<div class="well well-sm ">                      

<div class="col-xs-4 border-right pull-right">

<div class="col-xs-10">
<h4 class="">Service Reference ID : <?php echo $service_details->service_reference_no;?></h4>
<p>Date: <?php echo date('d/M/Y', strtotime($service_details->service_datetime));?></p>




</div>
<div class="clearfix"></div>
</div>

<!--<div class="col-xs-4 border-right">

<div class="col-xs-10">
<h4 class=""><p>Product Details</p></h4>
<p>Name: <?php echo $service_details->product_name;?> (<?php echo $service_details->product_code;?>)</p>
<p>Serial Number: <?php echo $service_details->product_sn;?></p>
<p>Warranty: <?php if($service_details->service_warranty_available) echo 'Avalable'; else echo 'Not Avalable';?></p>
 <p>Nature of Work : <?php echo $service_details->nature_of_work;?></p>
</div>
<div class="clearfix"></div>
</div>-->

<div class="">
<div class="col-xs-4 border-right">
<div class="col-xs-10">
<h4 class=""><p>Customer Details</p></h4>
<p>Name: <?php echo $service_details->cus_name;?> , <?php echo $service_details->service_walking_cus_name;?></p>
<p>Address: <?php echo $service_details->cus_address;?></p>
<p>Phone Number: <?php echo $service_details->cus_phone;?> <?php echo $service_details->service_walking_cus_phone;?> </p>
 
</div>

<div class="clearfix"></div>
</div>


<div class="col-xs-4 border-right">
<div class="col-xs-10">
<?php 
//echo $service_details->supp_id;
$sup_mod=new Supplier_Model();
$sup_mod_dtls=$sup_mod->get_supplier_info($service_details->supp_id);
//print_r($sup_mod_dtls);
?>
<h4 class=""><p>Supper  Details</p></h4>
<?php if (!empty($service_details->supp_id)){ ?>
<p>Name: <?php echo $sup_mod_dtls['supp_company_name'];?></p>
<p>Address: <?php echo $sup_mod_dtls['supp_address'];?></p>
<p>Phone Number: <?php echo $sup_mod_dtls['supp_company_phone'];?></p>
<p>Email: <?php echo $sup_mod_dtls['supp_email'];?></p> 
<?php }?>
</div>
</div>

<div class="clearfix"></div>
</div>





<div class="clearfix"></div>
</div>

 <!--col-xs-4-->
 
 
 



<div class="col-xs-5">
<!--<input name="service_id" type="hidden" id="service_id" value="<?php echo $service_id ?>">
<input type="hidden" id="sale_type" name="sale_type" value="sale">-->


<div class="clearfix"></div>
</div> <!--col-xs-4"-->
<div class="clearfix"></div>



<div class="col-xs-12">


<div class="panel-heading" style="font-weight: 700;">Item Details</div>



<table width="100%" border="0" class="des_table">
  <tr>
    <td width="10%" >Item Name </td>
    <td width="5%" >:</td>
    <td width="30%" >
	<?php if ($service_details->service_type=='Repair'){
		echo $service_details->service_rep_item_name;
	}else {?>
	<?php echo $service_details->product_name;?> (<?php echo $service_details->product_code;?>) <?php }?></td>
    <td width="10%" >Serial Number:</td>
    <td width="5%" >:</td>
    <td width="30%" >
	<?php if ($service_details->service_type=='Repair'){
		echo $service_details->service_rep_item_sn;
	}else {?>
	<?php echo $service_details->product_sn;?><?php }?></td>
  </tr>
  <?php if ($service_details->service_type!='Repair'){?>
 <tr>
    <td width="10%" >Warranty</td>
    <td width="5%" >:</td>
    <td width="30%" ><?php echo $service_details->nature_of_work;?></td>
    <td width="10%" ></td>
    <td width="5%" ></td>
    <td width="30%" ></td>
  </tr><?php }?>
</table>
<br>


<!-- ..................-->

 <div class="col-sm-12"></div>
 
 
 <!-- item details start -->
  <div class="col-sm-12"></div>
 <?php 


	foreach($service_types as $rows){ ?>
	  <div class="col-sm-12"></div>  
	<div style="clear:both;"></div>
		<div class="panel-heading" style="font-weight: 700;"><?php echo $rows['mstserdtpe_name'] ?></div>
	<?php 
//
	foreach($service_details_items as $row){
	if($rows['mstserdtpe_id']==$row['mstserdtpe_id']){
		?>
	
		<div class="col-xs-3">

			<label style="margin-bottom:10px;">
				<input disabled <?php if(isset($service_details_select[$row['mstserdtl_id']])){echo 'checked';} ?> type="checkbox" class="radio" value="<?php echo $row['mstserdtl_id']; ?>" name="detail_item[<?php echo $row['mstserdtl_id']; ?>]" /><?php echo $row['mstserdtl_name']; ?>
			</label>

		</div> 
	
	

<?php } }	}
   ?>              

 
 <!-- end item details -->
 
 
 <?php 


	foreach($service_types as $rows){ ?>
	  <div class="col-sm-12"></div>  
	<div style="clear:both;"></div>
		<div class="panel-heading" style="font-weight: 700;"><?php echo $rows['mstserdtpe_name'] ?></div>
	<?php 
//
	foreach($service_details_items as $row){
	if($rows['mstserdtpe_id']==$row['mstserdtpe_id']){
		?>
	
		<div class="col-xs-3">

			<label style="margin-bottom:10px;">
				<input disabled <?php if(isset($service_details_select[$row['mstserdtl_id']])){echo 'checked';} ?> type="checkbox" class="radio" value="<?php echo $row['mstserdtl_id']; ?>" name="detail_item[<?php echo $row['mstserdtl_id']; ?>]" /><?php echo $row['mstserdtl_name']; ?>
			</label>

		</div> 
	
	

<?php } }	}
   ?>              




  
  

<!--End Accessories Attached-->

</div>



<!--service item details-->

<div class="col-xs-12">
<br>

 <div style="clear:both"></div> 
<div class="panel-heading" style="font-weight: 700;">Service Items</div>

<div class="service_table_wapper">
<?php 
$sale_id=0;
//get sale id by sale id
$mod_sales=new Sales_Model();
$sale_des=$mod_sales->get_sale_info_by_sale_id($service_id);
//print_r($sale_des);
if(!empty($sale_des)){
	$sale_id=$sale_des['sale_id'];
}

?>
<div class="btn col-xs-2 pull-right"><a href="<?php echo base_url("service/item_add/$service_id/$sale_id") ?>" title="" class="tip btn btn-primary" data-original-title="Print"><i class="clip-plus-circle"></i> <span class="hidden-sm hidden-xs">Add Service Items</span></a>
</div>
 <table width="100%" class="service_table">
     <tr>
         <td width="80%" align="center"><strong>Description</strong></td>
         <td align="center"><strong>Charge</strong></td>
     </tr>
  <?php 
		//print_r($sale_item_list);
        $tmpcount=0;
		$Subtotal=0;
		$sale_mod=new Sales_Model();
		$sale_item_list=$this->Sales_Model->get_sale_item_list_by_sale_id($sale_id);
		//echo '<pre>',print_r($sale_item_list);
		if(!empty($sale_item_list)){
        foreach ($sale_item_list as $row)
        {?>    
     <tr>
         <td>
			<?php 
				echo $row['product_name'];
				$w_des=$sale_mod->get_warranty_types_des_by_id($row['w_id']);
				//print_r($row);
				if($row['w_id']!=0){
					if($w_des['w_name']) echo "<br/> ".$w_des['w_name'];
				}			
				$sn_list=$sale_mod->get_sales_serial_by_id($row['sale_id'],$row['id']);
				//print_r($sn_list);
				if(!empty($sn_list)){
					echo "<br/> Serial No. ";
					foreach ($sn_list as $sn) { 
						echo "<br/> $sn->sis_number  ";
						//echo "<br/> $sn->product_w  ";
						if($sn->product_w!=0) echo "<br/>Warrant: $sn->product_w Days";
					
					}   
				}

		 
		 ?></td>
         <td align="right"><?php echo number_format($row['gross_total'], 2, '.', ',') ?></td>
     </tr>
     <?php }?>



	 



	 
     <tr>
         <td align="right"><strong>Net Total</strong></td>
         <td align="right"><strong><?php echo number_format($sale_total, 2, '.', ',') ?></strong></td>
     </tr>
     <tr>
         <td align="right">
		 <?php //echo $service_details->service_remark;?>
         Paid Amount
         </td>
         <td valign="top" align="right"><?php //echo $service_details->service_charge;?>
         
         <?php
		// print_r($service_payments_list);
		 $tot=0;
		 if(!empty($service_payments_list)){
		    foreach ($service_payments_list as $row){
				 $tot=$tot+$row->sale_pymnt_amount;
				?>
         <?php echo number_format($row->sale_pymnt_amount, 2, '.', ',') ?><br>

          <?php
			}
		   }?>
          
          
         </td>
     </tr>
     <tr>
         <td align="right"><strong>Total Paid</strong></td>
         <td align="right"><strong><?php echo number_format($tot, 2, '.', ',') ?></strong></td>
     </tr>
     <?php 
	 $balance_amount=$sale_total-$tot;
	 //if($balance_amount>0)
	 {
	 ?>
     <tr>
         <td align="right"><strong>Balance Amount</strong></td>
         <td align="right"><strong><?php echo number_format($balance_amount, 2, '.', ',') ?></strong></td>
     </tr>
     <?php }?>
      <?php }?>
 </table>

  </div>
</div>


<!--service item details-->

<div class="col-xs-12">
<br>

<!--<h4 class=""><p>Service Details</p></h4>-->

 <div style="clear:both"></div> 
<div class="panel-heading" style="font-weight: 700;">Service Details</div>

<hr/>
 
<table width="100%" border="0" class="des_table">
  <tr>
    <td width="10%" >Item Fault </td>
    <td width="5%" >:</td>
    <td width="30%" ><?php echo $service_details->nature_of_work;?></td>
    <td width="10%" >Remarks</td>
    <td width="5%" >:</td>
    <td width="30%" ><?php echo $service_details->service_remark;?></td>
  </tr>
  <tr>
    <td width="10%" >Estimate Amount </td>
    <td width="5%" >:</td>
    <td width="30%" ><?php echo $service_details->estimate_amount;?></td>
    <td width="10%" ></td>
    <td width="5%" ></td>
    <td width="30%" ></td>
  </tr>
    <tr>
    <td width="10%" >Service Charge</td>
    <td width="5%" >:</td>
    <td width="30%" ><?php echo $service_details->service_charge;?></td>
    <td width="10%" ></td>
    <td width="5%" ></td>
    <td width="30%" ></td>
  </tr> 
</table>


<!--<p>Item Fault : <?php echo $service_details->product_name;?> (<?php echo $service_details->product_code;?>)</p>
<p>Serial Number: <?php echo $service_details->product_sn;?></p>
<p>Warranty: <?php if($service_details->service_warranty_available) echo 'Avalable'; else echo 'Not Avalable';?></p>
 <p>Nature of Work : <?php echo $service_details->nature_of_work;?></p>
 -->
 
</div>



<div class="clearfix"></div>




<!-- payment list -->


<div class="clearfix"></div>
<br>
<div class="clearfix"></div>
<!-- end payment list-->



<!-- status ox -->
<form role="form" class="" id="update_req_status_form" action="#" method="post">
 <div class="footer-status-change">
<div class="col-md-12">
<br>
<input name="service_id" type="hidden" value="<?php echo $service_id;?>">
<div class="panel panel-default">
<div style="font-weight: 700;" class="panel-heading">Status</div>
<div class="panel-body">

<!--status start -->

<div class="col-sm-3">
<div class="form-group">
<?php //echo 'test:'.$service_details->requisitioned_status; ?>
<label> 	Prepared Status</label>
<?php { ?>
<select id="prepared_status" class="form-control" name="prepared_status">
<?php 

$sel_r='';
$sel_n='';
if(isset($service_details->prepared_status) && $service_details->prepared_status=='Prepared'){
$sel_r=' selected';
}
if(isset($service_details->prepared_status) && $service_details->prepared_status==0){
$sel_n=' selected';
}
//if(!$service_details->prepared_status)
{	
?> 

<option value="0"<?php echo $sel_n;?>>Pending</option>
<?php }?>

<option value="Prepared"<?php echo $sel_r; ?>>Prepared</option>
</select>
<?php 
}
//if (check_is_avalable_permission('prepared_permission'))
{ ?>
<?php 
//if(!$service_details->prepared_status)
{?>
<a href="#" class="btn btn-primary show-tab" id="update_po_status_btn" onClick="update_po_status_btn('prepared');" style="margin-top:10px"> Update Prepared Status </a><?php }?>
<?php }?> 
  <?php 
  if($service_details->prepared_status=='Prepared'){
	  echo '<br/>'.$service_details->prepared_status;
	  $ref_id = new User_Model();
	  $data['user_details']=$ref_id->get_user_info($service_details->prepared_user);
	 echo '<br/>By: '; 
	 echo $data['user_details']['user_first_name'].' '.$data['user_details']['user_last_name'];
	 if($service_details->prepared_date_time!='0000-00-00 00:00:00'){
		  echo "<br/>Date : ".site_date_time($service_details->prepared_date_time);
	 }
	 
  }
  ?>              
</div>
</div>

<!--status end-->


<div class="col-sm-3" style="display:none;">
	<div class="form-group">
		<label>Send to Service Center</label>
        
 <?php { ?>
<select id="send_to_sc_status" class="form-control" name="send_to_sc_status">
<?php 

$sel_r='';
$sel_n='';
if(isset($service_details->send_to_sc_status) && $service_details->send_to_sc_status=='Sent'){
$sel_r=' selected';
}
if(isset($service_details->send_to_sc_status) && $service_details->send_to_sc_status==0){
$sel_n=' selected';
}
//if(!$service_details->prepared_status)
{	
?> 

<option value="0"<?php echo $sel_n;?>>Pending</option>
<?php }?>

<option value="Sent"<?php echo $sel_r; ?>>Sent</option>
</select>
<?php 
}
//if (check_is_avalable_permission('prepared_permission'))
{ ?>
<?php 
//if(!$service_details->prepared_status)
{?>
<a href="#" class="btn btn-primary show-tab" id="update_po_status_btn" onClick="update_po_status_btn('send_to_sc_status');" style="margin-top:10px"> Update Status </a><?php }?>
<?php }?> 
  <?php 
  if($service_details->send_to_sc_status=='Sent'){
	  echo '<br/>'.$service_details->send_to_sc_status;
	  $ref_id = new User_Model();
	  $data['user_details']=$ref_id->get_user_info($service_details->send_to_sc_user);
	 echo '<br/>By: '; 
	 echo $data['user_details']['user_first_name'].' '.$data['user_details']['user_last_name'];
	 if($service_details->send_to_sc_date_time!='0000-00-00 00:00:00'){
		  echo "<br/>Date : ".site_date_time($service_details->send_to_sc_date_time);
	 }
	 
  }
	 
 
  ?>         
	</div>
</div>

<div class="col-sm-3" style="display:none;">
	<div class="form-group">
		<label>Reserved to Service Center</label>
 <?php { ?>
<select id="reserved_to_sc_status" class="form-control" name="reserved_to_sc_status">
<?php 

$sel_r='';
$sel_n='';
if(isset($service_details->reserved_to_sc_status) && $service_details->reserved_to_sc_status=='Reserved'){
$sel_r=' selected';
}
if(isset($service_details->reserved_to_sc_status) && $service_details->reserved_to_sc_status==0){
$sel_n=' selected';
}
//if(!$service_details->prepared_status)
{	
?> 

<option value="0"<?php echo $sel_n;?>>Pending</option>
<?php }?>

<option value="Reserved"<?php echo $sel_r; ?>>Reserved</option>
</select>
<?php 
}
//if (check_is_avalable_permission('prepared_permission'))
{ ?>
<?php 
//if(!$service_details->prepared_status)
{?>
<a href="#" class="btn btn-primary show-tab" id="update_po_status_btn" onClick="update_po_status_btn('reserved_to_sc_status');" style="margin-top:10px"> Update Status </a><?php }?>
<?php }?> 
  <?php 
  if($service_details->reserved_to_sc_status=='Reserved'){
	  echo '<br/>'.$service_details->reserved_to_sc_status;
	  $ref_id = new User_Model();
	  $data['user_details']=$ref_id->get_user_info($service_details->reserved_to_sc_user);
	 echo '<br/>By: '; 
	 echo $data['user_details']['user_first_name'].' '.$data['user_details']['user_last_name'];
	 if($service_details->reserved_to_sc_date_time!='0000-00-00 00:00:00'){
		  echo "<br/>Date : ".site_date_time($service_details->reserved_to_sc_date_time);
	 }
	 
  } 
  ?>        
        
	</div>
</div>

<!--Header Title-->
<div class="clearfix"></div>
<div <?php if($service_details->service_warranty_available=='1') echo 'style="display:none"';?>>
<div class="col-sm-12">
<div style="font-weight: 700;" class="panel-heading">Technician Status</div>
</div>
<!--Header Title-->

<div class="col-sm-3">
	<div class="form-group">
		<label>Hand over to Technician</label>
 <?php { ?>
<select id="hand_over_to_tech_status" class="form-control" name="hand_over_to_tech_status">
<?php 

$sel_r='';
$sel_n='';
if(isset($service_details->hand_over_to_tech_status) && $service_details->hand_over_to_tech_status=='Handed Over'){
$sel_r=' selected';
}
if(isset($service_details->hand_over_to_tech_status) && $service_details->hand_over_to_tech_status==0){
$sel_n=' selected';
}
//if(!$service_details->prepared_status)
{	
?> 

<option value="0"<?php echo $sel_n;?>>Pending</option>
<?php }?>

<option value="Handed Over"<?php echo $sel_r; ?>>Handed Over</option>
</select>
<br>
Technician<br>
<?php //print_r($technician_list);?>
<select id="hand_over_to_tech_id" class="form-control search-select" name="hand_over_to_tech_id">
<option value="">-- Select Technician--</option>
<?php 
foreach ($technician_list as $row)
{
$sel='';
if($service_details->hand_over_to_tech_id==$row->user_id){
	$sel='selected';
}
?>
<option value="<?php echo $row->user_id;?>" <?php echo $sel ?>>
<?php echo $row->user_username; ?></option>
<?php }   ?>
</select>
                      
<?php 
}
//if (check_is_avalable_permission('prepared_permission'))
{ ?>
<?php 
//if(!$service_details->prepared_status)
{?>
<a href="#" class="btn btn-primary show-tab" id="update_po_status_btn" onClick="update_po_status_btn('hand_over_to_tech_status');" style="margin-top:10px"> Update Status </a><?php }?>
<?php }?> 
  <?php 
  if($service_details->hand_over_to_tech_status=='Handed Over'){
	  echo '<br/>'.$service_details->hand_over_to_tech_status;
	  $ref_id = new User_Model();
	  $data['user_details']=$ref_id->get_user_info($service_details->hand_over_to_tech_user);
	 echo '<br/>By: '; 
	 echo $data['user_details']['user_first_name'].' '.$data['user_details']['user_last_name'];
	 if($service_details->hand_over_to_tech_date_time!='0000-00-00 00:00:00'){
		  echo "<br/>Date : ".site_date_time($service_details->hand_over_to_tech_date_time);
	 }
	 
  } 
  ?>        
        
	</div>
</div>

<div class="col-sm-3">
	<div class="form-group">
		<label>Return from Technician</label>
        <?php { ?>
<select id="return_from_tech_status" class="form-control" name="return_from_tech_status">
<?php 

$sel_r='';
$sel_n='';
if(isset($service_details->return_from_tech_status) && $service_details->return_from_tech_status=='Returned'){
$sel_r=' selected';
}
if(isset($service_details->return_from_tech_status) && $service_details->return_from_tech_status==0){
$sel_n=' selected';
}
//if(!$service_details->prepared_status)
{	
?> 

<option value="0"<?php echo $sel_n;?>>Pending</option>
<?php }?>

<option value="Returned"<?php echo $sel_r; ?>>Returned</option>
</select><br>
Note:<br>
<input value="<?php echo $service_details->return_from_tech_note;?>" name="return_from_tech_note" class="form-control" id="return_from_tech_note" type="text">
<?php 
}
//if (check_is_avalable_permission('prepared_permission'))
{ ?>
<?php 
//if(!$service_details->prepared_status)
{?>
<a href="#" class="btn btn-primary show-tab" id="update_po_status_btn" onClick="update_po_status_btn('return_from_tech_status');" style="margin-top:10px"> Update Status </a><?php }?>
<?php }?> 
  <?php 
  if($service_details->return_from_tech_status=='Returned'){
	  echo '<br/>'.$service_details->return_from_tech_status;
	  $ref_id = new User_Model();
	  $data['user_details']=$ref_id->get_user_info($service_details->return_from_tech_user);
	 echo '<br/>By: '; 
	 echo $data['user_details']['user_first_name'].' '.$data['user_details']['user_last_name'];
	 if($service_details->return_from_tech_date_time!='0000-00-00 00:00:00'){
		  echo "<br/>Date : ".site_date_time($service_details->return_from_tech_date_time);
	 }
	 
  } 
  ?> 
	</div>
</div>

</div>

<!--Send to Supplier Status Start -->
<div <?php if($service_details->service_warranty_available=='0') echo 'style="display:none"';?>>
<!--Header Title-->
<div class="clearfix"></div>
<div class="col-sm-12">
<div style="font-weight: 700;" class="panel-heading">Supplier Status</div>
</div>
<!--Header Title-->

<div class="col-sm-3">
<div class="form-group">
<?php //echo 'test:'.$service_details->requisitioned_status; ?>
<label> 	Send to Supplier Status</label>
<?php { ?>
<select id="snd_to_supp_status" class="form-control" name="snd_to_supp_status">
<?php 

$sel_r='';
$sel_n='';
if(isset($service_details->snd_to_supp_status) && $service_details->snd_to_supp_status=='Send to Supplier'){
$sel_r=' selected';
}
if(isset($service_details->snd_to_supp_status) && $service_details->snd_to_supp_status==0){
$sel_n=' selected';
}
//if(!$service_details->snd_to_supp_status)
{	
?> 

<option value="0"<?php echo $sel_n;?>>Pending</option>
<?php }?>

<option value="Send to Supplier"<?php echo $sel_r; ?>>Send to Supplier</option>
</select>
<?php 
}
//if (check_is_avalable_permission('snd_to_supp_permission'))
{ ?>
<?php 
//if(!$service_details->snd_to_supp_status)
{?>
<a href="#" class="btn btn-primary show-tab" id="update_po_status_btn" onClick="update_po_status_btn('snd_to_supp');" style="margin-top:10px"> Update Send to Supplier Status </a><?php }?>
<?php }?> 
  <?php 
  if($service_details->snd_to_supp_status=='Send to Supplier'){
	  echo '<br/>'.$service_details->snd_to_supp_status;
	  $ref_id = new User_Model();
	  $data['user_details']=$ref_id->get_user_info($service_details->snd_to_supp_user);
	 echo '<br/>By: '; 
	 echo $data['user_details']['user_first_name'].' '.$data['user_details']['user_last_name'];
	 if($service_details->snd_to_supp_date_time!='0000-00-00 00:00:00'){
		  echo "<br/>Date : ".site_date_time($service_details->snd_to_supp_date_time);
	 }
	 
  }
	 
 
  ?>              
</div>
</div>
</div>
<!--Send to Supplier Status End -->



<!--Ready Status Start -->

<div class="col-sm-3">
<div class="form-group">
<?php //echo 'test:'.$service_details->requisitioned_status; ?>
<label> 	Supplier Return Status</label>
<?php { ?>
<select id="ready_status" class="form-control" name="ready_status">
<?php 

$sel_r='';
$sel_n='';
if(isset($service_details->ready_status) && $service_details->ready_status=='Returned'){
$sel_r=' selected';
}
if(isset($service_details->ready_status) && $service_details->ready_status==0){
$sel_n=' selected';
}
//if(!$service_details->ready_status)
{	
?> 

<option value="0"<?php echo $sel_n;?>>Pending</option>
<?php }?>

<option value="Returned"<?php echo $sel_r; ?>>Returned</option>
</select>
<br>
Note:<br>
<input value="<?php echo $service_details->ready_note;?>" name="ready_note" class="form-control" id="ready_note" type="text">
















<?php 
}
//if (check_is_avalable_permission('ready_permission'))
{ ?>
<?php 
//if(!$service_details->ready_status)
{?>
<a href="#" class="btn btn-primary show-tab" id="update_po_status_btn" onClick="update_po_status_btn('ready');" style="margin-top:10px"> Update Ready Status </a><?php }?>
<?php }?> 
  <?php 
  if($service_details->ready_status=='Ready'){
	  echo '<br/>'.$service_details->ready_status;
	  $ref_id = new User_Model();
	  $data['user_details']=$ref_id->get_user_info($service_details->ready_user);
	 echo '<br/>By: '; 
	 echo $data['user_details']['user_first_name'].' '.$data['user_details']['user_last_name'];
	 if($service_details->ready_date_time!='0000-00-00 00:00:00'){
		  echo "<br/>Date : ".site_date_time($service_details->ready_date_time);
	 }
	 
  }
	 
 
  ?>              
</div>
</div>

<!--Ready Status End -->



<!--Header Title-->
<div class="clearfix"></div>
<div class="col-sm-12">
<div style="font-weight: 700;" class="panel-heading">Branch Status</div>
</div>
<!--Header Title-->

<div class="col-sm-3" style="display:none;">
	<div class="form-group">
		<label>Return to Branch</label>
<?php { ?>
<select id="return_to_branch_status" class="form-control" name="return_to_branch_status">
<?php 

$sel_r='';
$sel_n='';
if(isset($service_details->return_to_branch_status) && $service_details->return_to_branch_status=='Returned'){
$sel_r=' selected';
}
if(isset($service_details->return_to_branch_status) && $service_details->return_to_branch_status==0){
$sel_n=' selected';
}
//if(!$service_details->prepared_status)
{	
?> 

<option value="0"<?php echo $sel_n;?>>Pending</option>
<?php }?>

<option value="Returned"<?php echo $sel_r; ?>>Returned</option>
</select>
<?php 
}
//if (check_is_avalable_permission('prepared_permission'))
{ ?>
<?php 
//if(!$service_details->prepared_status)
{?>
<a href="#" class="btn btn-primary show-tab" id="update_po_status_btn" onClick="update_po_status_btn('return_to_branch_status');" style="margin-top:10px"> Update Status </a><?php }?>
<?php }?> 
  <?php 
  if($service_details->return_to_branch_status=='Returned'){
	  echo '<br/>'.$service_details->return_to_branch_status;
	  $ref_id = new User_Model();
	  $data['user_details']=$ref_id->get_user_info($service_details->return_to_branch_user);
	 echo '<br/>By: '; 
	 echo $data['user_details']['user_first_name'].' '.$data['user_details']['user_last_name'];
	 if($service_details->return_to_branch_date_time!='0000-00-00 00:00:00'){
		  echo "<br/>Date : ".site_date_time($service_details->return_to_branch_date_time);
	 }
	 
  } 
  ?>
	</div>
</div>



<div class="col-sm-3" style="display:none;">
	<div class="form-group">
		<label>Reserved to Branch</label>
        
        <?php { ?>
<select id="reserved_to_branch_status" class="form-control" name="reserved_to_branch_status">
<?php 

$sel_r='';
$sel_n='';
if(isset($service_details->reserved_to_branch_status) && $service_details->reserved_to_branch_status=='Reserved'){
$sel_r=' selected';
}
if(isset($service_details->reserved_to_branch_status) && $service_details->reserved_to_branch_status==0){
$sel_n=' selected';
}
//if(!$service_details->prepared_status)
{	
?> 

<option value="0"<?php echo $sel_n;?>>Pending</option>
<?php }?>

<option value="Reserved"<?php echo $sel_r; ?>>Reserved</option>
</select>
<?php 
}
//if (check_is_avalable_permission('prepared_permission'))
{ ?>
<?php 
//if(!$service_details->prepared_status)
{?>
<a href="#" class="btn btn-primary show-tab" id="update_po_status_btn" onClick="update_po_status_btn('reserved_to_branch_status');" style="margin-top:10px"> Update Status </a><?php }?>
<?php }?> 
  <?php 
  if($service_details->reserved_to_branch_status=='Reserved'){
	  echo '<br/>'.$service_details->reserved_to_branch_status;
	  $ref_id = new User_Model();
	  $data['user_details']=$ref_id->get_user_info($service_details->reserved_to_branch_user);
	 echo '<br/>By: '; 
	 echo $data['user_details']['user_first_name'].' '.$data['user_details']['user_last_name'];
	 if($service_details->reserved_to_branch_date_time!='0000-00-00 00:00:00'){
		  echo "<br/>Date : ".site_date_time($service_details->reserved_to_branch_date_time);
	 }
	 
  } 
  ?> 
	</div>
</div>




 <!--Hand Over Status Start -->

<div class="col-sm-3">
<div class="form-group">
<?php //echo 'test:'.$service_details->requisitioned_status; ?>
<label> 	Hand Over Status</label>
<?php { ?>
<select id="hand_over_status" class="form-control" name="hand_over_status">
<?php 

$sel_r='';
$sel_n='';
if(isset($service_details->hand_over_status) && $service_details->hand_over_status=='Hand Over'){
$sel_r=' selected';
}
if(isset($service_details->hand_over_status) && $service_details->hand_over_status==0){
$sel_n=' selected';
}
//if(!$service_details->hand_over_status)
{	
?> 

<option value="0"<?php echo $sel_n;?>>Pending</option>
<?php }?>

<option value="Hand Over"<?php echo $sel_r; ?>>Hand Over</option>
</select>
<?php 
}
//if (check_is_avalable_permission('hand_over_permission'))
{ ?>
<?php 
//if(!$service_details->hand_over_status)
{?>
<a href="#" class="btn btn-primary show-tab" id="update_po_status_btn" onClick="update_po_status_btn('hand_over');" style="margin-top:10px"> Update Hand Over Status </a><?php }?>
<?php }?> 
  <?php 
  if($service_details->hand_over_status=='Hand Over'){
	  echo '<br/>'.$service_details->hand_over_status;
	  $ref_id = new User_Model();
	  $data['user_details']=$ref_id->get_user_info($service_details->hand_over_user);
	 echo '<br/>Hand Over by: '; 
	 echo $data['user_details']['user_first_name'].' '.$data['user_details']['user_last_name'];
	 if($service_details->hand_over_date_time!='0000-00-00 00:00:00'){
		  echo "<br/>Date : ".site_date_time($service_details->hand_over_date_time);
	 }
	 
  }
	 
 
  ?>              
</div>
</div>




<!--Hand Over Status End -->
<?php 

//echo "Test:".$this->session->userdata('ss_group_id'); 

 ?>
<?php if($this->session->userdata('ss_group_id')==1){?>

<?php if(isset($service_details->ready_status) && $service_details->ready_status=='Returned'){?>
<!--Update Serial No box-->

<div style="clear:both; width:100%;">&nbsp;</div>
<div style="font-weight: 700;" class="panel-heading">Update Serial No</div>
<div class="col-sm-3">
<div class="form-group">
<?php //print_r($service_details); ?>

<label>New Serial No.</label>

<input value="<?php if(isset($service_details->product_sn_new) && $service_details->product_sn_new!='') echo $service_details->product_sn_new;?>" class="form-control" name="product_sn_new" type="text" id="product_sn_new">

<input value="<?php if(isset($service_details->service_rep_item_sn) && $service_details->service_rep_item_sn!='') echo $service_details->service_rep_item_sn;?>" class="form-control" name="product_sn" type="hidden" id="product_sn">

<br>

<a href="#" class="btn btn-primary show-tab" id="update_po_status_btn" onClick="update_po_status_btn('serial_no');" style="margin-top:10px"> Update Serial No</a>

</div>
</div>

<div class="col-sm-3">
<div class="form-group">


<label>Note</label>

<input value="<?php if(isset($service_details->product_sn_new_note) && $service_details->product_sn_new_note!='') echo $service_details->product_sn_new_note;?>"  class="form-control" name="product_sn_new_note" type="text" id="product_sn_new_note">



</div>
</div>
<?php }?>
<?php }?>
<!--End Serial No box-->




</div>
</div>
</div>
                        </div>
                        </form>
<!-- end status box -->





<!-- payment list -->

<div class="row">
<div class="col-xs-12">
<div class="table-responsive">
<table class="table items table-striped table-bordered table-condensed table-hover">
<thead>
<tr class="report_view_th">
<th>Date</th>
<th>Payment Reference</th>
<th>Paid by</th>
<th>Amount</th>
<th>Created by</th>
<th>Action</th>

</tr>
</thead>
<tbody>
<?php   foreach ($sale_payments_list as $row){?>
<tr>
<td><?php //echo display_date_time_format($row->sale_pymnt_date_time) ?>
<?php //if($row->sale_pymnt_added_date_time) echo 'Received Date: '.display_date_time_format($row->sale_pymnt_added_date_time); ?>
<?php if($row->sale_pymnt_paying_by=='Cash') echo '<br/>Received Date: '.display_date_time_format($row->sale_pymnt_date_time);  else  echo 'Received Date: '.display_date_time_format($row->sale_pymnt_added_date_time); ?>

<?php if($row->sale_pymnt_paying_by=='Cheque' || $row->sale_pymnt_paying_by=='Cheque_Return') echo '<br/>Cheque Realized Date: '.display_date_time_format($row->sale_pymnt_date_time); ?>
</td>
<td><?php 
														 echo $row->sale_pymnt_id;
														  if($row->sale_pymnt_ref_no) echo "<br/>Ref.: ".$row->sale_pymnt_ref_no;
														 if($row->sale_pymnt_cheque_no) echo "<br/>Cheque No.: ".$row->sale_pymnt_cheque_no;
														 if($row->sale_pymnt_note) echo "<br/>Note: ".$row->sale_pymnt_note;
														 
														 ?></td>
<td><?php echo $row->sale_pymnt_paying_by ?></td>
<td><?php echo number_format($row->sale_pymnt_amount, 2, '.', ',') ?> <?php 
 if($row->sale_pymnt_cheque_rtn_status ==1) echo " (Returned)";
 ?></td>
<td> <?php echo $row->user_first_name ?> (<?php echo $row->user_group_name ?>)</td>
<td>
<!--<button class="btn btn-warning" style="display:<?php
 if($row->sale_pymnt_paying_by == "Cheque" && $row->sale_pymnt_cheque_rtn_status == 0){}else echo "none"; ?>" onClick ="cheque_return_by_sp_id(<?php echo $row->sale_pymnt_id ?>)"><i class="fa fa-share"></i> Return </button>-->
 
 
 
 <?php
 //print_r(print_r($this->session->all_userdata()));
  if ($this->session->userdata('ss_group_id')==1)
 {  ?>
 <button class="btn btn-danger" onClick ="sale_pymnts_delete_by_sp_id(<?php echo $row->sale_pymnt_id ?>)"><i class="fa fa-trash-o"></i></button>
 <?php }?>
 
 
 <?php
  if ($this->session->userdata('ss_group_id')==1 && $row->sale_pymnt_cheque_rtn_status==0)
 {  ?>
 <button class="btn btn-warning" style="" onClick ="cheque_return_by_sp_id(<?php echo $row->sale_pymnt_id ?>)"><i class="fa fa-share"></i> Return </button>
 <?php }?>
 
 <?php if($row->sale_pymnt_cheque_rtn_status ==1) echo "<button class=\"btn btn-danger\">Returned</button>";?>
 
 </td>

</tr>
<?php }?>
</tbody>
</table>
</div>
</div>
</div>
<div class="clearfix"></div>
<br>
<div class="clearfix"></div>
<!-- end payment list-->


<div class="buttons">
<div class="btn-group btn-group-justified">


<!--<div class="btn-group"><a title="" class="tip btn btn-primary tip" data-target="#myModal" data-toggle="modal" href="#" data-original-title="Add Payment" id="modal_ajax_sales_payment_btn"><i class="fa fa-money"></i> <span class="hidden-sm hidden-xs">Add Payment</span></a></div>
-->
<!--<div class="btn-group"><a title="" class="tip btn btn-primary tip" data-target="#myModal" data-toggle="modal" href="http://sma.tecdiary.org/sales/add_payment/2" data-original-title="Add Payment"><i class="fa fa-money"></i> <span class="hidden-sm hidden-xs">View Payment</span></a></div>-->
<!--<div class="btn-group"><a title="" class="tip btn btn-primary tip" data-target="#myModal" data-toggle="modal" href="http://sma.tecdiary.org/sales/add_delivery/2" data-original-title="Add Delivery"><i class="fa fa-truck"></i> <span class="hidden-sm hidden-xs">Add Delivery</span></a></div>-->


<div class="btn-group" onClick="print_grn_barcode('<?php echo $service_id; ?>')"><a title="" class="tip btn btn-primary" data-original-title="Print"><i class="fa fa-print"></i> <span class="hidden-sm hidden-xs">Print Barcode</span></a>
</div>


<div class="btn-group"><a title="" class="tip btn btn-primary tip" data-target="#myModal" data-toggle="modal" href="#" data-original-title="Add Payment" id="modal_ajax_sales_payment_btn"><i class="fa fa-money"></i> <span class="hidden-sm hidden-xs">Add Payment</span></a></div>


<div class="btn-group" onClick="fbs_click('<?php echo $service_id; ?>')"><a title="" class="tip btn btn-primary" data-original-title="Print"><i class="fa fa-print"></i> <span class="hidden-sm hidden-xs">Print</span></a>
</div>

<!-- 
<div class="btn-group" onClick="fbs_click_invoice('<?php echo $service_id; ?>')"><a title="" class="tip btn btn-primary" data-original-title="Print"><i class="fa fa-print"></i> <span class="hidden-sm hidden-xs">Invoice Print</span></a>
</div> 
-->
 
</div>
</div> <!--buttons-->
                                     
                                   
								</div> <!--panel-body-->
							</div><!--panel-->
							
						</div> <!--col-md-12-->
					</div> <!--row-->

					
                    <!-- end grid -->
                    
					
			</div>
			<!-- end: PAGE -->
		</div>
		<!-- end: MAIN CONTAINER -->
		<!-- start: FOOTER -->
		<div class="footer clearfix">
			<div class="footer-inner">
				<?php echo date("Y");?> &copy;  System by sallelanka solutions. 
			</div>
			<div class="footer-items">
				<span class="go-top"><i class="clip-chevron-up"></i></span>
			</div>
		</div>
		<!-- end: FOOTER -->
		<!-- start: RIGHT SIDEBAR -->
		<!-- end: RIGHT SIDEBAR -->
		<div id="event-management" class="modal fade" tabindex="-1" data-width="760" style="display: none;">
			<div class="modal-dialog">
				<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">Event Management</h4>
					</div>
					<div class="modal-body"></div>
					<div class="modal-footer">
						<button type="button" data-dismiss="modal" class="btn btn-light-grey">
							Close
						</button>
						<button type="button" class="btn btn-danger remove-event no-display">
							<i class='fa fa-trash-o'></i> Delete Event
						</button>
						<button type='submit' class='btn btn-success save-event'>
							<i class='fa fa-check'></i> Save
						</button>
					</div>
				</div>
			</div>
		</div>

		<!-- 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: MAIN JAVASCRIPTS -->
		<?php $this->load->view("common/footer"); ?>
		<!-- end: MAIN JAVASCRIPTS -->
		
		<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>

  <input type="hidden" value="0" id="total_paymnt_tmp">
<input type="hidden" value="0" id="paid_tmp">   
<input name="sale_id" type="hidden" id="sale_id" value="<?php echo $service_id ?>">
<input type="hidden" id="sale_type" name="sale_type" value="service">   
  
        
		<!-- 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/jquery.maskedinput/src/jquery.maskedinput.js"></script>
		<script type="text/javascript" src="<?php echo asset_url(); ?>plugins/bootbox/bootbox.min.js"></script>
		<script type="text/javascript" src="<?php echo asset_url(); ?>plugins/jquery-mockjax/jquery.mockjax.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/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-lib/2.0.3/jquery.min.js"></script>
		<script type="text/javascript" language="javascript" src="<?php echo asset_url(); ?>js/jquery.dataTables.js"></script>

		<!-- end: JAVASCRIPTS REQUIRED FOR THIS PAGE ONLY -->
		<script>
function sale_pymnts_delete_by_sp_id(sid)
	{
		
		
		//bootbox.prompt("This is the default prompt!", function(result)
		//{
			 //console.log(result);
		//});
		
		var group_id = $('#user_id').val();
		var confm =	window.confirm("Delete This Payment ?");
	
		if(confm && group_id != 3){
      jQuery.ajax({
       type: "POST",
       url: "<?php echo base_url().'sales/sale_pymnts_delete_by_sp_id?sp_id='?>"+sid,
//       data: 'id='+id,
       cache: false,
       success: function(response)
       {
//		var price = $('#'+count).val();
//		var twoPlacedFloat = parseFloat(price).toFixed(2)
//		$('#'+count).val(twoPlacedFloat);
		displayNotice('page','Payment Deleted Successfully!!');
//		setTimeout(resetfun(),30000);

setTimeout(resetfun, 1000)
    	}
     });
	}
}



	function print_grn_barcode (product_id) {
				window.open('<?php echo base_url().'service/single_barcode'?>/'+product_id, 'sma_popup', 'width=900,height=600,scrollbars=yes,menubar=yes,status=no,resizable=yes,screenx=0,screeny=0');
			}
			
			
function resetfun(){
 this.location.reload();
}

//cheque return
function cheque_return_by_sp_id(sid)
	{
		var confm =	window.confirm("Return This Payment ?");
		if(confm){
       jQuery.ajax({
       type: "POST",
       url: "<?php echo base_url().'sales/cheque_return_by_sp_id?sp_id='?>"+sid,
       cache: false,
       success: function(response)
       {
			displayNotice('page','Cheque Returned Successfully!!');
			setTimeout(resetfun, 500)
    	}
     });
	}
}
//end cheque return
		
function update_po_status_btn(type) {
				$("#update_req_status_btn").prop("disabled", true);
	 var fields = $("#update_req_status_form").serialize();
	 $.post( "<?php echo base_url();?>service/update_service_status?type="+type, fields)
	.done(function( data ) {
		 
		  var obj = jQuery.parseJSON(data);
		   //alert(obj.error);
			if(obj.error==1){
				//$('.alert-success').hide();
				//$('.alert-danger').show();
				//$( ".errortxt" ).text( obj.disMsg );
				//bootbox.alert(obj.msg, function () {
                        
                  //  });
				  displayNotice('page','Error ! '+obj.disMsg);
			}
			if(obj.error==0){
				displayNotice('page','Status successfully updated!');
				
				//sendUrl='<?php echo base_url();?>loan/manage/'+obj.loan_id;
				//window.location.href = sendUrl;
				
				 $("#update_req_status_btn").prop("disabled", false);
		 		 $("#update_req_status_btn").val('Update Status');
				//clearForm();
				location.reload();
			}
			
	  });
	return false;
	
}		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
			jQuery(document).ready(function() {
				TableData.init();
				$("#hand_over_to_tech_id").select2();
				//Main.init();
				//TableData.init();
				//UIModals.init();

			});
			





		</script>
        
<script type="text/javascript" language="javascript" >



var j = jQuery.noConflict();
function loadGrid(){
	alert();
	j('#employee-grid').DataTable().ajax.reload();
}
	jQuery(document).ready(function() {
		var dataTable = j('#employee-grid').DataTable( {
			"processing": true,
			"serverSide": true,
			"ajax":{
				url :"sales/list_sales", // json datasource
				type: "post",  // method  , by default get
				error: function(){  // error handling
					j(".employee-grid-error").html("");
					j("#employee-grid").append('<tbody class="employee-grid-error"><tr><th colspan="3">No data found in the server</th></tr></tbody>');
					//$("#employee-grid_processing").css("display","none");
				}
			}
		} );
		
	} );
	

	



function fbs_click(id) {
	u=location.href;
	t=document.title;
	window.open('<?php echo base_url();?>service/service_print/'+id,'sharer','toolbar=0,status=0,width=626,height=700, left=10, top=10,scrollbars=yes');return false;
}

function fbs_click_invoice(id) {
	u=location.href;
	t=document.title;
	window.open('<?php echo base_url();?>service/service_print_invoice/'+id,'sharer','toolbar=0,status=0,width=626,height=700, left=10, top=10,scrollbars=yes');return false;
}



</script>
	</body>
	<!-- end: BODY -->
</html>