<?php
session_start();
include("../include/config.php");
include("../include/functions.php"); 
include("../include/simpleimage.php");
validate_admin();
   
if($_REQUEST['order_id']!=''){ ?>
<?php $storesarrays = array();
                                $stores = $obj->query("select distinct(storeid) from tbl_order_shopper where order_id='" .$_REQUEST['order_id']. "'");
                                while ($resstores = $obj->fetchNextObject($stores)) {
                                    $storesarrays[] = $resstores->storeid;
                                }
                                $storesarrays = array_values(array_unique($storesarrays));
                                $storearrcount = count($storesarrays);
								
				$ship_state = getFieldWhere('ship_state', 'tbl_order', 'id', $_REQUEST['order_id']);
								 
								?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title><?php echo SITE_TITLE; ?></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta content="width=device-width, initial-scale=1" name="viewport" />
<link href="css/admin.css" rel="stylesheet" type="text/css" />
<script src="//code.jquery.com/jquery-1.11.1.min.js"></script>
<link href="//netdna.bootstrapcdn.com/bootstrap/3.0.3/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css">
<script src="//netdna.bootstrapcdn.com/bootstrap/3.0.3/js/bootstrap.min.js"></script>

<style>
h4 {
	font-size:14px;
}
.col-xs-12.col-sm-5.col-md-2.myselect.userremaks {
    font-size: 11px;
    font-weight: bold;
	
}
span.glyphicon.glyphicon-eye-open.view-remarks b {
    position: relative;
    left: 2px;
    top: -3px;
}
img.checkmark {
    width: 10px;
    position: absolute;
    left: -1px;
    top: 12px;
}
.panel-body {
    padding: 5px 5px;
}
.grop {
    margin: 8px 0px;
}

.myselect {
    margin-top: 0px;
}
.panel-info>.panel-heading {
    color: #fff;
    background-color: #333;
    border-color: #ddd;
}
.panel-heading  .panel-title h5 {
	margin:0px;
}

.panel-body.content-body .row {
    border-bottom: 1px solid #ddd;
    margin: 0px;
    padding: 10px 0px;
}
span.glyphicon.glyphicon-eye-open.view-remarks {
    display: inline;
    cursor: pointer;
    margin-left: 5px;
}
#prod-loader {
    position: fixed;
    top: 0;
    left: 0;
    height: 100%;
    width: 100%;
    /* cursor: not-allowed; */
    opacity: 0.9;
    z-index: 99;
    text-align: center;
    display: none;
    margin: auto;
}
div#viewpreviousremarks .modal-body {
    display: table;
}
.ajax-loader {
    z-index: 99;
    height: 100%;
    width: 100%;
    background: #fff url(https://www.quicklly.com/images/Quicklly-Logo_300X200.gif) center no-repeat;
}
select.availabilty {
    padding: 5px;
    background: #fff;
    border: 1px solid;
    border: 1px solid #ddd;
    border-radius: 4px;
    display: inline;
}
.panel-body h4 small {
    color: #000;
    font-weight: 600;
	line-height: 19px;
}
.col-xs-1.mycheck input[type="checkbox"] {
    margin-top: 13px;
}
h4.product-name {
    
}
select.allmark {
    display: inline;
    padding: 5px;
    border: 1px solid #444;
    background: #fff;
    border-radius: 4px;
	margin-left: 10px;
}
button#submitall {
    background: #000;
    color: #fff;
    padding: 5px 11px;
    border: none;
    border-radius: 4px;
    display: none;
}
 .back-to-order-list  {
	font-size: 15px;
    font-weight: bold;
    color: #333;
    padding: 17px 0px;
    /* margin: 20px 0px; */
    line-height: 40px;
}
@media (min-width: 320px) and (max-width: 768px) {
	select.availabilty {
    float: right;
   }
.myselect {
    margin-top: 0px;
}
.pqtty {
    margin-top: 3px;
}

span.glyphicon.glyphicon-eye-open.view-remarks {
    margin-right: 20px;
    margin-top: 0px;
    float: left;
}	
.row.topcustomerinfo h4.product-name {
    font-size: 11px;
}	
.col-xs-12.col-sm-5.col-md-2.myselect.userremaks {
    font-size: 11px;
    font-weight: bold;
	margin-top:10px;
	text-align: center;
	
}
}

</style>
</head>
<body>

<div id="prod-loader" style="display: none;"> <div class="ajax-loader"></div></div>
<script>
$("#prod-loader").show();
</script>

<div class="container">
	<div class="row">
		<div class="col-xs-12">
		<a class="back-to-order-list" href="order-list.php">Back to Order List</a>
		<div class="row topcustomerinfo">
						<div class="col-xs-6 col-md-4">
						
							<h4 class="product-name"><strong>Order Id:</strong>  <?php echo $_REQUEST['order_id'];?></h4>
							
							
						</div>
						<div class="col-xs-6 col-md-4">
						
							<h4 class="product-name"><strong>Name: </strong> <?php echo getFieldWhere('ship_fname', 'tbl_order', 'id', $_REQUEST['order_id']);?></h4>
							
							
						</div>
						
						<div class="col-xs-12 col-md-4">
							<h4 class="product-name"><strong>Phone: </strong> <?php echo getFieldWhere('ship_mobile', 'tbl_order', 'id', $_REQUEST['order_id']);?> <strong>Email: </strong> <?php echo getFieldWhere('ship_email', 'tbl_order', 'id', $_REQUEST['order_id']);?> </h4>
						</div>
						
					</div>
		<?php if($storearrcount>0){?>
			<div class="panel panel-info">
			<div class="panel-body tophead">
					<div class="row">
						<div class="col-xs-12 col-md-12">
						<label><input  onclick='checkall(this)' type="checkbox" name="checkall">&nbsp;Select All</label>
						<select class="allmark" style="display:none;">
						<option value="">Bulk Action</option>
							<option value="Available">Available</option>
							
							
						</select>
						<button type="button" id="submitall">Submit</button>
							
							
							
						</div>
						<div class="col-xs-4 col-md-4">
						
							<h4 class="product-name"><strong>Item</strong></h4>
							
							
						</div>
						<div class="col-xs-3 col-md-1">
							<h4 class="product-name"><strong>Qty</strong></h4>
						</div>
						<div class="col-xs-5 col-md-2">
							<h4 class="product-name"><strong>Subtotal</strong></h4>
						</div>
						
						<div class="col-xs-3 col-md-3 hidden-xs">
							<h4 class="product-name"><strong>Status</strong></h4>
						</div>
						<div class="col-xs-3 col-md-2 hidden-xs">
							<h4 class="product-name"><strong>User Remarks</strong></h4>
						</div>
						
					</div>
					</div>
				<?php  for ($x = 0; $x < $storearrcount; $x++) {
								
								 $StoreArr = $obj->query("select storename,storeid from stores where  storeid='$storesarrays[$x]'");
								 $StoreInfo= $obj->fetchNextObject($StoreArr);
								 ?>	
				<div class="panel-heading">
					<div class="panel-title">
						<div class="row">
							<div class="col-xs-12">
								<h5><span class="glyphicon glyphicon-shopping-cart"></span><?php echo $StoreInfo->storename;?></h5>
							</div>
							
						</div>
					</div>
				</div>
				<div class="panel-body content-body">
				
				 <?php 
               
				 $itmesArr = $obj->query("select * from tbl_order_shopper as a where a.order_id='" . $_REQUEST['order_id']. "' and a.storeid='$storesarrays[$x]'");
				 
                               while ($resultItem = $obj->fetchNextObject($itmesArr)) {
																 
												$bg_color = '';
												$sf_product = '';
				                if(trim($ship_state) == 'NY')
				                {
													$productPrice = $obj->query("SELECT id FROM `tbl_productprice` WHERE `product_id` = ".$resultItem->product_id);
				                  $resultPrice = $obj->fetchNextObject($productPrice);
				                
													$store_front_quantity = check_storefront_stock($resultPrice->id);
													
													if($store_front_quantity > 0){
														$bg_color = 'background-color:#ffffa7';
														$sf_product = ' - QGo';
													}
												}
								   
								   ?>
										
													
					<div class="row">
					
						<div class="col-xs-1 mycheck" style="display:none;"><input type="checkbox" name="check[]" data-rstoreid="<?php echo $resultItem->replaced_product_storeid;?>"  data-oid="<?php echo $resultItem->order_id;?>" data-pid="<?php echo $resultItem->product_id;?>" data-status="<?php if($resultItem->status) { echo $resultItem->status; } else { echo 'Available';}?>" data-rpname="<?php if($resultItem->replaced_product) { echo $resultItem->replaced_product; }?>" data-rprice="<?php if($resultItem->replaced_product_price) { echo $resultItem->replaced_product_price; }?>" data-rsize="<?php if($resultItem->replaced_product_size) { echo $resultItem->replaced_product_size; }?>" data-remarks="<?php if($resultItem->remarks) { echo $resultItem->remarks; }?>" data-currentcheck="no" disabled='disabled'>
						</div>
						<div class="col-xs-4" style="<?=$bg_color;?>">
							
							<h4><small><?php if($resultItem->shopper_status==1) {?><img class="checkmark" src="images/check_green.png"><?php } ?><?php echo $resultItem->product_name . ' ' . $resultItem->size . $resultItem->size_type.$sf_product;?></small></h4>
						</div>
						<div class="col-xs-3 col-md-1">
							<h4 class="product-name"><strong><?php echo $resultItem->qty;?></strong></h4>
						</div>
						<div class="col-xs-5 col-md-2 pqtty">
							<h4 class="product-name"><strong><?php echo $website_currency_symbol . number_format($resultItem->price * $resultItem->qty, 2);?></strong></h4>
						</div>
						<div class="col-xs-12 col-sm-5 col-md-3 myselect">
							<select class="availabilty">
							<option <?php if($resultItem->status=='Available'){ echo "selected";}?> value="Available" data-rstoreid="<?php echo $resultItem->replaced_product_storeid;?>"  data-oid="<?php echo $resultItem->order_id;?>" data-pid="<?php echo $resultItem->product_id;?>" data-status="<?php if($resultItem->status) { echo $resultItem->status; } else { echo 'Available';}?>" data-rpname="<?php if($resultItem->replaced_product) { echo $resultItem->replaced_product; }?>" data-rprice="<?php if($resultItem->replaced_product_price) { echo $resultItem->replaced_product_price; }?>" data-rqty="<?php if($resultItem->replaced_product_qty) { echo $resultItem->replaced_product_qty; }?>" data-rsize="<?php if($resultItem->replaced_product_size) { echo $resultItem->replaced_product_size; }?>" data-remarks="<?php if($resultItem->remarks) { echo $resultItem->remarks; }?>">Available</option>
							<option <?php if($resultItem->status=='Full Replacement'){ echo "selected";}?> value="Full Replacement" data-rstoreid="<?php echo $resultItem->replaced_product_storeid;?>"  data-oid="<?php echo $resultItem->order_id;?>" data-pid="<?php echo $resultItem->product_id;?>" data-status="<?php if($resultItem->status) { echo $resultItem->status; } else { echo 'Available';}?>" data-rpname="<?php if($resultItem->replaced_product) { echo $resultItem->replaced_product; }?>" data-rprice="<?php if($resultItem->replaced_product_price) { echo $resultItem->replaced_product_price; }?>" data-rqty="<?php if($resultItem->replaced_product_qty) { echo $resultItem->replaced_product_qty; }?>" data-rsize="<?php if($resultItem->replaced_product_size) { echo $resultItem->replaced_product_size; }?>" data-remarks="<?php if($resultItem->remarks) { echo $resultItem->remarks; }?>">Full Replacement</option>
							<option <?php if($resultItem->status=='Partial Replacement'){ echo "selected";}?>  value="Partial Replacement" data-rstoreid="<?php echo $resultItem->replaced_product_storeid;?>"  data-oid="<?php echo $resultItem->order_id;?>" data-pid="<?php echo $resultItem->product_id;?>" data-status="<?php if($resultItem->status) { echo $resultItem->status; } else { echo 'Available';}?>" data-rpname="<?php if($resultItem->replaced_product) { echo $resultItem->replaced_product; }?>" data-rprice="<?php if($resultItem->replaced_product_price) { echo $resultItem->replaced_product_price; }?>" data-rqty="<?php if($resultItem->replaced_product_qty) { echo $resultItem->replaced_product_qty; }?>" data-rsize="<?php if($resultItem->replaced_product_size) { echo $resultItem->replaced_product_size; }?>" data-remarks="<?php if($resultItem->remarks) { echo $resultItem->remarks; }?>">Partial Replacement</option>
							<option <?php if($resultItem->status=='No Replacement'){ echo "selected";}?>  value="No Replacement" data-rstoreid="<?php echo $resultItem->replaced_product_storeid;?>"  data-oid="<?php echo $resultItem->order_id;?>" data-pid="<?php echo $resultItem->product_id;?>" data-status="<?php if($resultItem->status) { echo $resultItem->status; } else { echo 'Available';}?>" data-rpname="<?php if($resultItem->replaced_product) { echo $resultItem->replaced_product; }?>" data-rprice="<?php if($resultItem->replaced_product_price) { echo $resultItem->replaced_product_price; }?>" data-rqty="<?php if($resultItem->replaced_product_qty) { echo $resultItem->replaced_product_qty; }?>" data-rsize="<?php if($resultItem->replaced_product_size) { echo $resultItem->replaced_product_size; }?>" data-remarks="<?php if($resultItem->remarks) { echo $resultItem->remarks; }?>">No Replacement</option>
							</select>
							<?php 
							$rstorename='';
							if($resultItem->replaced_product_storeid > 0) {
								
								$rstorename=getFieldWhere('storename', 'stores', 'storeid', $resultItem->replaced_product_storeid);
							}?>
						<?php if($resultItem->remarks || $resultItem->replaced_product || $resultItem->replaced_product_size || $resultItem->replaced_product_qty) { ?>
							<span title="View remarks" data-viewremarks="<?php echo $resultItem->remarks;?>" data-viewpname="<?php echo $resultItem->replaced_product;?>" data-viewprice="<?php echo $resultItem->replaced_product_price;?>" data-viewsize="<?php echo $resultItem->replaced_product_size;?>" data-viewqty="<?php echo $resultItem->replaced_product_qty;?>" data-rstorename="<?php echo $rstorename;?>"  class="glyphicon glyphicon-eye-open view-remarks btn btn-default btn-sm"><b>view</b></span>
							<?php }?>
						</div>
						<div class="col-xs-12 col-sm-5 col-md-2 myselect userremaks">
						<?php echo $resultItem->user_replacement_remarks;?>
						</div>
					</div>
					<?php } ?>
				
					</div>
				<?php } ?>					
			
					
				
				
			</div>
		<?php } else {?>
		<h3 class="text-center">No item found for this order id</h3>
		<?php } ?>
		</div>
	</div>
</div>
<!-- Modal For Remarks-->
<div class="modal fade" id="ChangeitemPopup" tabindex="-1" role="dialog" 
     aria-labelledby="myModalLabel" aria-hidden="true" data-backdrop="static" data-keyboard="false">
    <div class="modal-dialog">
        <div class="modal-content">
            <!-- Modal Header -->
            <div class="modal-header">
                <button  type="button" class="close" 
                   data-dismiss="modal">
                       <span aria-hidden="true">&times;</span>
                       <span class="sr-only">Close</span>
                </button>
                <h4 class="modal-title" id="myModalLabel">
                    Update Item
                </h4>
            </div>
            <!-- Modal Body -->
            <div class="modal-body">
                
                <form class="form-horizontal" role="form">
				<input type="hidden" id="oid" name="oid" value="<?php echo $_REQUEST['order_id'];?>">
				<input type="hidden" id="rqty" name="rqty" value="">
				<input type="hidden" id="pid" name="pid" value="">
				<input type="hidden" id="cstatus" name="cstatus" value="">
				
				
				<div class="form-group">
                    <div class="col-sm-12">
                    <select class="form-control"  name="storename" id="storename">
                     <option id="defaltval" value="">Select Store(*)</option>
					 <?php
					$orderid=$_REQUEST['order_id'];
					 $zip=getFieldWhere('ship_pincode', 'tbl_order', 'id', $orderid);
					 
					 $storelist = $obj->query("SELECT DISTINCT(a.storeid),b.storename from tbl_store_zip as a left join stores as b on a.storeid=b.storeid where a.store_status=1 and a.zip='$zip' and a.status=1 and b.status=1");
                                while ($storeres = $obj->fetchNextObject($storelist)) {?>
                               
                              
					 <option value="<?php  echo $storeres->storeid;?>"><?php  echo $storeres->storename;?></option>
					  <?php  }?>
					 
	                 </select>
                    
                  </div>
				  </div>
                  <div class="form-group">
                   
                    <div class="col-sm-6 col-xs-6">
                         
						<input type="text" class="form-control grop"  id="productname" required placeholder="Product Name">
                    </div>
                  
                   
                    <div class="col-sm-6 col-xs-6">
                         
						<input type="number" class="form-control grop"  id="productprice" required placeholder="Product Price">
                    </div>
					<div class="col-sm-6 col-xs-6">
                         
						<input type="text" class="form-control grop"  id="productsize" required placeholder="Product Size">
                    </div>
					<div class="col-sm-6 col-xs-6">
					<select class="form-control grop"  name="productqty" id="productqty">
                     <option id="defaltval1" value="">Select Qty</option>
					 <<option value="0">0</option>
                        <option value="1">1</option>
                        <option value="2">2</option>
                        <option value="3">3</option>
                        <option value="4">4</option>
                        <option value="5">5</option>
                        <option value="6">6</option>
                        <option value="7">7</option>
                        <option value="8">8</option>
                        <option value="9">9</option>
                        <option value="10">10</option>
                        <option value="11">11</option>
                        <option value="12">12</option>
                        <option value="13">13</option>
                        <option value="14">14</option>
                        <option value="15">15</option>
                        <option value="16">16</option>
                        <option value="17">17</option>
                        <option value="18">18</option>
                        <option value="19">19</option>
                        <option value="20">20</option>
					 </select>
                         
                    </div>
                  </div>
				  <div class="form-group">
                    
                    <div class="col-sm-12">
                        <label  class="control-label" id="enterremarks" 
                              for="inputEmail3">Enter substitute(*)</label>
						<textarea class="form-control" rows="3" id="remarks" required></textarea>
                    </div>
                  </div>
                  <div class="form-group">
                    <div class="col-sm-12">
                      <button type="button" class="btn btn-default" id="saveremarks">Save</button>
                    </div>
                  </div>
                </form>

            </div>
        </div>
    </div>
</div>
<!-- Model For View Remarks-->
<div class="modal fade" id="viewpreviousremarks" tabindex="-1" role="dialog" 
     aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <!-- Modal Header -->
            <div class="modal-header">
                <button  type="button" class="close" 
                   data-dismiss="modal">
                       <span aria-hidden="true">&times;</span>
                       <span class="sr-only">Close</span>
                </button>
                <h4 class="modal-title" id="myModalLabel">
                    View Detail
                </h4>
            </div>
            <!-- Modal Body -->
            <div class="modal-body">
                
              
                   
                    <div class="col-sm-12">
					<p id="viewstorename"><p>
					   <p id="viewproductname"><p>
					   <p id="viewprice"><p>
					   <p id="viewsize"><p>
					   <p id="viewqty"><p>
                       <p id="viewpremks"><p>
                    </div>
          

            </div>
        </div>
    </div>
</div>
<script>
function checkall(cb) { 
if(cb.checked==true){
	
$('.allmark').show();
var ele=document.getElementsByName('check[]');  
                for(var i=0; i<ele.length; i++){  
                    if(ele[i].type=='checkbox')  
                        ele[i].checked=true;
					    ele[i].disabled=false;
                } 
} else {
	$('.allmark').hide();
    $('#submitall').hide();	
	 var ele=document.getElementsByName('check[]');  
                for(var i=0; i<ele.length; i++){  
                    if(ele[i].type=='checkbox')  
                        ele[i].checked=false;
                         ele[i].disabled=true;					
                      
                }  
}				
}

$('.allmark').on('change', function() {
var bulkstatus = $(this).val();
if(bulkstatus!=''){
	$('#submitall').show();
	
} else {
	$('#submitall').hide();
}

})

$('.view-remarks').on('click', function() {
	var viewremarks = $(this).data("viewremarks");
	var viewpname = $(this).data("viewpname");
	var viewprice = $(this).data("viewprice");
	var viewsize = $(this).data("viewsize");
	var viewqty = $(this).data("viewqty");
	var viewstorename = $(this).data("rstorename");
	
	if(viewstorename==''){
		$("#viewstorename").html('');
	} else {
		$("#viewstorename").html("<strong>Store Name: </strong>"+viewstorename);
	}
	if(viewremarks==''){
		$("#viewpremks").html('');
	} else {
		$("#viewpremks").html("<strong>Remarks: </strong>"+viewremarks);
	}
	if(viewpname==''){
		$("#viewproductname").html('');
	} else {
		$("#viewproductname").html("<strong>Product Name: </strong>"+viewpname);
	}
	if(viewprice==''){
		$("#viewprice").html('');
	} else {
		$("#viewprice").html("<strong>Price: </strong>"+viewprice);
	}
	if(viewsize==''){
		$("#viewsize").html('');
	} else {
		$("#viewsize").html("<strong>Size: </strong>"+viewsize);
	}
	if(viewqty==''){
		$("#viewqty").html('');
	} else {
		$("#viewqty").html("<strong>Qty: </strong>"+viewqty);
	}
	
	$("#viewpreviousremarks").modal('show');
})
$('#submitall').on('click', function() {
	if (confirm('Are you sure you want to perform Bulk Action?')) {
		  $("#prod-loader").show();
	var arr=[];
	var oid='<?php echo $_REQUEST['order_id'];?>';
	var status = $('.allmark').val();
	var remarks='';
	var rpname='';
	var rprice='';
	var rsize='';
	var rqty='';
	var rqty='';
	var rstoreid='';
             $.each($("input[name='check[]']:checked"), function(){            
                   
					
			
	                var pid = $(this).data("pid");
	               
					arr.push( 
					{'pid': pid,'rstoreid': rstoreid, 'status': status, 'remarks': remarks, 'rpname': rpname, 'rprice':rprice, 'rsize': rsize, 'rqty': rqty});
					
            }); 
			savedata(oid,arr);
		
	}
	
})

$('.availabilty').on('change', function() {
	var arr=[];
	   var status = $(this).val();
	   var storeid = $(this).find(':selected').data("rstoreid");
	   var pid = $(this).find(':selected').data("pid");
	   var rsize = $(this).find(':selected').data("rsize");
	   var rsizetype = $(this).find(':selected').data("rsizetype");
	   var rpname = $(this).find(':selected').data("rpname");
	   var rprice = $(this).find(':selected').data("rprice");
	   var rremarks = $(this).find(':selected').data("remarks");
	   var rqty = $(this).find(':selected').data("rqty");
	   var oid='<?php echo $_REQUEST['order_id'];?>';
	   if(status=='Full Replacement'){
		   $('#defaltval').text('Select Store');
		   $('#enterremarks').text('Enter substitute');
	   } else {
		    $('#defaltval').text('Select Store(*)');
		    $('#enterremarks').text('Enter substitute(*)');
	   }
	   
	   
	    if(status=='Partial Replacement' || status=='Full Replacement'){
        if(storeid>0)
		{
			$('#storename').val(storeid);
		} else {
			$('#storename').val('');
		}	
			
	    $('#pid').val(pid);	
        $('#productqty').val(rqty);			
        $('#remarks').val(rremarks);
		$("#productname").val(rpname);
	    $("#productprice").val(rprice);
	    $("#productsize").val(rsize);
		$("#cstatus").val(status);
		
        $("#ChangeitemPopup").modal('show');
	
		
	} else {
		var remarksa='';
	var rpnamea='';
	var rpricea='';
	var rsizea='';
	var rqtya='';
	var rstoreida='';
	 $("#prod-loader").show();
	  arr.push( 
					{'pid': pid,'rstoreid': rstoreida, 'status': status, 'remarks': remarksa, 'rpname': rpnamea, 'rprice':rpricea, 'rsize': rsizea, 'rqty': rqtya});
					console.log(oid);
					
			  savedata(oid,arr);
	}
	  
    });
	
$("#saveremarks").click(function(){
	var arr=[];
	var remarks=$('#remarks').val();
	var productstorename=$('#storename').val();
	var status=$('#cstatus').val();
	var productname=$('#productname').val();
	var productprice=$('#productprice').val();
	var productsize=$('#productsize').val();
	var pid=$('#pid').val();
	var oid=$('#oid').val();
	var productqty= $('#productqty').val();
	if(status=='Full Replacement'){
		$("#prod-loader").show();
			
			  arr.push( 
					{'pid': pid,'rstoreid': productstorename, 'status': status, 'remarks': remarks, 'rpname': productname, 'rprice':productprice, 'rsize': productsize, 'rqty': productqty});
			 $("#ChangeitemPopup").modal('hide');
			 $(".mycheck").removeClass("myactive");
		      savedata(oid,arr);
	} else {
		 if(remarks!='' && productstorename!=''){
			$("#prod-loader").show();
			  arr.push( 
					{'pid': pid,'rstoreid': productstorename, 'status': status, 'remarks': remarks, 'rpname': productname, 'rprice':productprice, 'rsize': productsize, 'rqty': productqty});
			 $("#ChangeitemPopup").modal('hide');
			 $(".mycheck").removeClass("myactive");
		      savedata(oid,arr);
			
		  }  else {
			alert('Please enter the required fields');
			
		}
	}
       
				
	   });	
function savedata(oid,deataildata){
	 if(oid!='') {
                $.ajax(

                        {

                            url: "ajax-save-shopper-data.php",

                            data: {action: 'savedata', oid: oid, deataildata: deataildata},

                            success: function (data) {

                               
								$("#prod-loader").hide();
								location.reload();

                            }

                        }

                );
	 }
}
	$("#prod-loader").hide();
</script>
						

		
</body>
</html>
<?php } ?>
