<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>Chandrani Pearls Gold Billing</title>
<link rel="icon" type="image/jpg" href="dist/img/favicon.png?v=2">
  <!-- Google Font: Source Sans Pro -->
  <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,400i,700&display=fallback">
  
  <!-- DataTables -->
  <link rel="stylesheet" href="plugins/datatables-bs4/css/dataTables.bootstrap4.min.css">
  <link rel="stylesheet" href="plugins/datatables-responsive/css/responsive.bootstrap4.min.css">
  <link rel="stylesheet" href="plugins/datatables-buttons/css/buttons.bootstrap4.min.css">
  <!-- Theme style -->
  <link rel="stylesheet" href="dist/css/adminlte.min.css">
  <link rel="stylesheet" href="dist/css/custom.css">
  
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.14.1/themes/base/jquery-ui.min.css" />
	<!--<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/fancybox/2.1.5/jquery.fancybox.css" />-->
	<script src="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.14.1/jquery-ui.min.js"></script>
	
	<!--<script src="https://cdnjs.cloudflare.com/ajax/libs/fancybox/2.1.5/jquery.fancybox.pack.js"></script>-->
	

<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fancyapps/ui@5.0/dist/fancybox/fancybox.css"/>
	
	
  <style>
  
.fancybox__content{
padding:10px;    
}  
  
  
#tooltip
{
    text-align: center;
    color: #FFF;
    background: #777777;
    position: absolute;
    z-index: 100;
    padding: 8px 15px;
	font-size:12px;
	font-family: 'Roboto', sans-serif;
}
 
    #tooltip:after /* triangle decoration */
    {
        width: 0;
        height: 0;
        border-left: 10px solid transparent;
        border-right: 10px solid transparent;
        border-top: 10px solid #777777;
        content: '';
        position: absolute;
        left: 50%;
        bottom: -10px;
        margin-left: -10px;
    }
 
        #tooltip.top:after
        {
            border-top-color: transparent;
            border-bottom: 10px solid #777777;
            top: -20px;
            bottom: auto;
        }
 
        #tooltip.left:after
        {
            left: 10px;
            margin: 0;
        }
 
        #tooltip.right:after
        {
            right: 10px;
            left: auto;
            margin: 0;
        }
.fulldiv {
    float: left;
    width: 100%;
    height: 100%;
    top: 0;
    bottom: 0;
    background-color: rgba(38, 53, 68, 0.80);
    background: rgba(38, 53, 68, 0.80);
    z-index: 1500;
    position: fixed;
}
	  .message_maindiv_new {
    width: 430px;
    height: auto;
    margin: 0px auto;
}
	  .message_div_new {
    float: left;
    width: 100%;
    height: auto;
    padding: 3%;
    background-color: #FFFFFF;
    margin-top: 300px;
}
	  .message_title {
    float: left;
    width: 100%;
    height: auto;
    text-align: center;
    font-size: 20px;
    color: #000000;
    margin-bottom: 20px;
    text-transform: capitalize;
	  }
	  
	  .bg-maroon{
	  background-color:#d5042d !important;
	  }
	  


        .col-sm-12 {
        -ms-flex: 0 0 100%;
        flex: 0 0 100%;
        max-width: 100%;
        font-size: 13px;
    }


    th{

        font-size: 13px;

        
    }

button:focus{

outline: none;

}


</style>
<script>
$( function()
{
    var targets = $( '[rel~=tooltip]' ),
        target  = false,
        tooltip = false,
        title   = false;
 
    targets.bind( 'mouseenter', function()
    {
        target  = $( this );
        tip     = target.attr( 'title' );
        tooltip = $( '<div id="tooltip"></div>' );
 
        if( !tip || tip == '' )
            return false;
 
        target.removeAttr( 'title' );
        tooltip.css( 'opacity', 0 )
               .html( tip )
               .appendTo( 'body' );
 
        var init_tooltip = function()
        {
            if( $( window ).width() < tooltip.outerWidth() * 1.5 )
                tooltip.css( 'max-width', $( window ).width() / 2 );
            else
                tooltip.css( 'max-width', 340 );
 
            var pos_left = target.offset().left + ( target.outerWidth() / 2 ) - ( tooltip.outerWidth() / 2 ),
                pos_top  = target.offset().top - tooltip.outerHeight() - 20;
 
            if( pos_left < 0 )
            {
                pos_left = target.offset().left + target.outerWidth() / 2 - 20;
                tooltip.addClass( 'left' );
            }
            else
                tooltip.removeClass( 'left' );
 
            if( pos_left + tooltip.outerWidth() > $( window ).width() )
            {
                pos_left = target.offset().left - tooltip.outerWidth() + target.outerWidth() / 2 + 20;
                tooltip.addClass( 'right' );
            }
            else
                tooltip.removeClass( 'right' );
 
            if( pos_top < 0 )
            {
                var pos_top  = target.offset().top + target.outerHeight();
                tooltip.addClass( 'top' );
            }
            else
                tooltip.removeClass( 'top' );
 
            tooltip.css( { left: pos_left, top: pos_top } )
                   .animate( { top: '+=10', opacity: 1 }, 50 );
        };
 
        init_tooltip();
        $( window ).resize( init_tooltip );
 
        var remove_tooltip = function()
        {
            tooltip.animate( { top: '-=10', opacity: 0 }, 50, function()
            {
                $( this ).remove();
            });
 
            target.attr( 'title', tip );
        };
 
        target.bind( 'mouseleave', remove_tooltip );
        tooltip.bind( 'click', remove_tooltip );
    });
});
</script>

<script>

  function close_fancy_list()
  {
  	
  	$('#dispatchdiv_msg').hide();
  }


function CheckFSToDispatch(per)
{
   var Order_No=per 
   
   
     $('#Insuff_Order_No').val('');
     $("#stn_dis_btn").prop('disabled', true);
	 
	
      //alert(1);
  
   
   $.ajax({
			url:'ajx-check-stn-final-stock.php',
			type:'post',
			data:'Order_No='+Order_No,
			success:function(f)
			{
				//alert(f);
				if(f!='')
				{
					//alert(22);
					$('#DispStockOutCode').text(f);
					$('#dispatchdiv_msg').show();
					$('#Insuff_Order_No').val(Order_No);
					$("#stn_dis_btn").prop('disabled', false);
				}
				else{
					
					
					
					StnDispatch(Order_No);
				}
			
			}
	})


}
function StnDispatch(per)
{
   var Order_No=per 
   
   
   
     $("#stn_dis_btn").prop('disabled', true);
	 
	
   //alert(1);
  
   
   $.ajax({
			url:'ajx_stn_dispatch.php',
			type:'post',
			data:'Order_No='+Order_No,
			success:function(f)
			{
				alert('Successfully dispathed');
				window.location.reload();
			
			}
	})


}
function CancelStn(per)
{

  var Order_No=per 
  
  
   Swal.fire({
                title: 'Are you sure?',
                text: 'Are you sure you want to cancel this STN',
                icon: 'warning',
                showCancelButton: true,
                confirmButtonText: 'Yes, continue',
                cancelButtonText: 'No, cancel',
                toast: false, // Toast is not ideal for confirmations
                position: 'center',
				}).then((result) => {
					if (result.isConfirmed) {
						//console.log('User confirmed to continue.');
						// Add your logic for confirmation here
						
						
						
						 $.ajax({
								url:'ajx_dispatched-stn_cancel.php',
								type:'post',
								data:'Order_No='+Order_No,
								success:function(f)
								{
									
									
									
										Swal.fire({
										icon: 'success', // Sets the icon to success
										title: 'Submission Successful!',
										text: 'Successfully Cancelled',
										width: '450px',
										showConfirmButton: true,
										confirmButtonText: 'OK'
									}).then(function() {
									  
										window.location.reload();
									  
									});
										
									
									
								
								}
						   })
								
						
						
					
						
					} else {
						//console.log('User canceled.');
						// Add your logic for cancellation here
						 //$("#stn_dis_btn").prop('disabled', false);
					}
				});

      

}

function RemoveStockOutProduct()
{
	  var Order_No=$('#Insuff_Order_No').val();
	  
	  if(Order_No!='')
	  {
	     $('#dispatchdiv_msg').hide();
		
		 $.ajax({
				url:'ajx-remove-stn-stock-out-product.php',
				type:'post',
				async:false,
				data:'Order_No='+Order_No,
				success:function(f)
				{
					StnDispatch(Order_No);
				
				}
		})
	  }
	  else{
		  
		  alert("Some error occurred. Please try again");
	  }

		
}
</script>
	
	</head>
	<body class="hold-transition sidebar-mini">
	
	

		
		
<div class="wrapper">
  <!-- Navbar -->
    <?php include ("topheader.php"); ?>
  <!-- /.navbar -->
  <!-- Main Sidebar Container -->
    <?php include ("sidemenu.php"); ?>
  <!-- Content Wrapper. Contains page content -->
  <div class="content-wrapper">
    <!-- Content Header (Page header) -->
    <section class="content-header">
        <div class="container-fluid">
            <div class="row mb-2">
                <div class="col-sm-6">
                    <h1></h1>
                </div>
                <div class="col-sm-6">
                    
                </div>
            </div>
        </div>
    </section>
    <!-- Main content -->
    <section class="content">
      <div class="container-fluid">
        <div class="row">
			<div class="col-12">
      <div class="card">
                        <div class="card-header">
        <h4>Completed Gold STN
            <!-- <button type="button" class="btn btn-custom" style="float: right; background-color: #ffd700; color: #062e50;" data-toggle="modal" data-target="#ratemodal"><i class="fa-solid fa-circle-plus fa-beat"></i> ADD RATE</button> -->
        </h4>
    </div>

                        <div class="card-body">





<table id="example1" class="table table-bordered table-striped" >
   <thead>

<tr>



<th>SLN</th>

<th>Dealer Code</th>

<th>Order No</th>

<th>Indent Date</th>

<th>Quantity</th>

<th>Net Total</th>

<th>Consignment Stn</th>

<th>Status</th>
</tr>

</thead>

<tbody>



<?php

if($_REQUEST['from-date']!='')
{
$From_Date=date('Y-m-d',strtotime($_REQUEST['from-date']));	
}
else
{
$From_Date=date('Y-m-d');
}
if($_REQUEST['to-date']!='')
{
$To_Date=date('Y-m-d',strtotime($_REQUEST['to-date']));	
}
else
{
$To_Date=date('Y-m-d');
}
$Start=$From_Date." "."00:00:00";
$End=$To_Date." "."23:59:59";

//$condition="Order_No!='' and Dealer_Code!='' and Total_Quantity>0 and Status!='Dispatched' and Status!='Cancel'";

//$condition="Order_No!='' and Status='Dispatched' and Dispatched_Date between '".$Start."' and '".$End."'";
$condition="Order_No!='' and Status='Dispatched'";
//$condition="Order_No!='' and Status='Dispatched'";

if($_REQUEST['dealer']!='')
	{
		$condition.=" and Dealer_Code='".$_REQUEST['dealer']."'";
	}

$condition.=" order by SLN desc";

$Get_Dealers_Stock=$Mainclass->Fetch_multiple_data('gold_indent_master','*',$condition);

/*if($Get_Dealers_Stock>0)

{	*/

$i=1;

foreach($Get_Dealers_Stock as $stock)

	{

    
	if($stock['Ref_Order_No']=='')
	{
?>

<tr>

<th scope="row"><?php echo $i;?></th>

<td><?php echo $stock['Dealer_Code'];?></td>

<td><?php echo $stock['Order_No'];?></td>

<td><?php echo date('d-M-y',strtotime($stock['Indent_Date']));?></td>

<td><?php echo $stock['Total_Quantity'];?></td>

<td><?php echo $stock['Net_Total'];?></td>

<td>
<?php 
if($stock['Consignment_Stn']==1)
{
	echo "Yes";
}
else{
	
	echo "No";
}
?>
</td>

<td>
 <?php
	
		 if($stock['Status']=="Dispatched")
		 {
		 ?>
         
        
		 <a data-fancybox data-type="iframe" data-width="830"
  data-height="830" href="print-gatepass.php?Order_No=<?php echo $stock['Order_No']; ?>" style="text-decoration:none;">
         <input class="btn btn-primary m-b-0" type="button" style="margin-right:15px; padding: 3px 14px; font-size:13px;" value="Print Gate Pass" name="gate-pass"></a> 
         <?php
		 }
		 else{
		 ?>
		
         <input class="btn btn-primary m-b-0" type="button" style="margin-right:15px; padding: 3px 14px; font-size:13px;cursor:default;background-color:#999;border-color:#999" value="Print Gate Pass" name="gate-pass">
		 <?php
		 }
		 
		 if($stock['Status']=="Dispatched")
		 {
		 ?>
			 
         
         
        
		  <a data-fancybox data-type="iframe" data-width="1050"
  data-height="830" href="print-stn.php?Order_No=<?php echo $stock['Order_No']; ?>" style="text-decoration:none;">
         <input class="btn btn-primary m-b-0" type="button" style="margin-right:15px; padding: 3px 14px; font-size:13px;" value="Print STN" name="stn"></a>   
        <?php
        }
        else
        {
		?>
		 
         <input class="btn btn-primary m-b-0" type="button" style="margin-right:15px; padding: 3px 14px; font-size:13px;cursor:default;background-color:#999;border-color:#999" value="Print STN" name="stn">  
		<?php
		}
          if($stock['Challan_Status']!="Received")
		 {		
        ?>		  
            

      
         <input class="btn btn-primary m-b-0" type="button" style="margin-right:15px; padding: 3px 14px; font-size:13px;" value="Cancel STN" name="stn" onclick="CancelStn('<?php echo $stock['Order_No']; ?>')">
		 
		 <?php
		 }
		 ?>
		 
		 <!--<a href="stn-item-summary.php?Order_No=<?php echo $stock['Order_No']; ?>" class="various5" data-fancybox-type="iframe" style="text-decoration:none;">
         <input class="btn btn-primary m-b-0" type="button" style="margin-right:15px; padding: 3px 14px; font-size:13px;" value="View STN Summary" name="stn"></a>  --> 

</td>

</tr>

<?php

$i++;
}

}

/*}

else

{

?>

<tr><td colspan="8" style="text-align:center; font-weight:bold; color:#FF0000;"> No Order Found!</td></tr>

<?php

}
*/
?>



</tbody>

</table>


<input type="hidden" name="count" id="count" value="<?php echo $i-1?>">
                        </div>
                    </div> 
				</div>
            <!-- /.card -->
			</div>
			<!--/.row-->    
        
      </div>
      <!-- /.container-fluid -->
    </section>
    <!-- /.content -->
  </div>
  <!-- /.content-wrapper -->
   <?php include ("footer.php"); ?>
  <!-- Control Sidebar -->
  <aside class="control-sidebar control-sidebar-dark">
    <!-- Control sidebar content goes here -->
  </aside>
  <!-- /.control-sidebar -->
</div>
<!-- ./wrapper -->
<!-- jQuery -->
<script src='https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js'></script>
<!-- Bootstrap 4 -->
<script src="plugins/bootstrap/js/bootstrap.bundle.min.js"></script>
<!-- DataTables  & Plugins -->
<script src="plugins/datatables/jquery.dataTables.min.js"></script>
<script src="plugins/datatables-bs4/js/dataTables.bootstrap4.min.js"></script>
<script src="plugins/datatables-responsive/js/dataTables.responsive.min.js"></script>
<script src="plugins/datatables-responsive/js/responsive.bootstrap4.min.js"></script>
<script src="plugins/datatables-buttons/js/dataTables.buttons.min.js"></script>
<script src="plugins/datatables-buttons/js/buttons.bootstrap4.min.js"></script>
<script src="plugins/jszip/jszip.min.js"></script>
<script src="plugins/pdfmake/pdfmake.min.js"></script>
<script src="plugins/pdfmake/vfs_fonts.js"></script>
<script src="plugins/datatables-buttons/js/buttons.html5.min.js"></script>
<script src="plugins/datatables-buttons/js/buttons.print.min.js"></script>
<script src="plugins/datatables-buttons/js/buttons.colVis.min.js"></script>
<!-- AdminLTE App -->
<script src="dist/js/adminlte.min.js"></script>
<!-- AdminLTE for demo purposes -->
<script src="dist/js/demo.js"></script>
<!-- Page specific script -->

	 <script src="https://cdn.jsdelivr.net/npm/@fancyapps/ui@5.0/dist/fancybox/fancybox.umd.js"></script>
	 
<script>
    
    Fancybox.bind("[data-fancybox]", {
  // Optionally disable "compact" mode
  // compact: false,

 
});
</script>	 
	 
	 
<script>
  $(function () {
    $("#example1").DataTable({
      "responsive": true,
      "lengthChange": false,
      "autoWidth": false,
      "searching": true,
      "scrollX": true, // Enable horizontal scroll
      //"buttons": ["copy", "csv", "excel", "pdf", "print", "colvis"]
    }).buttons().container().appendTo('#example1_wrapper .col-md-6:eq(0)');

    $('#example2').DataTable({
      "paging": true,
      "lengthChange": false,
      "searching": false,
      "ordering": true,
      "info": true,
      "autoWidth": false,
      "responsive": true,
      "scrollX": true, // Enable horizontal scroll
      "columnDefs": [
        { "width": "25%", "targets": 2 }, // Set width for the third column
      ]
    });
  });
  
 
$(document).ready(function() {



	$(".various").fancybox({



		maxWidth	: 500,



		maxHeight	: 450,



		fitToView	: true,



		width		: '100%',



		height		: '100%',



		autoSize	: false,



		closeClick	: false,



		openEffect	: 'none',



		closeEffect	: 'none',



		



	});



});

 
</script>
	<script>
    /*ClassicEditor
        .create( document.querySelector( '#responsibility' ) )
        .catch( error => {
            console.error( error );
        } );*/
		var myEditor;

    ClassicEditor
        .create( document.querySelector( '#responsibility' ) )
        .then( editor => {
            console.log( 'Editor was initialized', editor );
            myEditor = editor;
        } )
        .catch( err => {
            console.error( err.stack );
        } );
    
</script>
	<script>
		function close_modal()
  {
    $(':input').val('');
    $('#ratemodal').modal('hide');
    $(':input').css('border-color','');
  }	
  

  
		</script>	
	
<script>

function update_igi(per){
    
var SLN = per;
var igi_no = $('#igi_no'+SLN).val(); 
var org = $('#org'+SLN).val(); 
var hm_no = $('#hm_no'+SLN).val(); 

    if (igi_no=="" || org=="") {
        Swal.fire({
            icon: 'warning',
            title: 'Check Again!',
            text: "Please provide information in all the required fields.",
            width: '450px',
            background: '#045b62',
            color: '#fff',
            confirmButtonText: 'Ok',
            confirmButtonColor: "#013033",
            showConfirmButton: true,
        });
        return false;
    }





    
$.ajax({
url:'ajax-update-igi-hm.php',
type:'POST',
data:{SLN:SLN,igi_no:igi_no,hm_no:hm_no,org:org},
success:function(f){

Swal.fire({
icon: 'success',
title: 'Success',
text: 'IGI No and Hallmark No added successfully',
width: '450px',
showConfirmButton:false,
timer:3000,
}).then(function() {
window.location.href="add_product_igi.php";
});

}
});



}
	

	
function open_igi_modal(per){
	
$('#product_modal').modal('show');	
	
$.ajax({
url:'ajax-igi-form.php',
type:'POST',
data:{Barcode:per},
success:function(f){
	
$('#product_data').html(f);
	
}
});
	
}	
	


		</script>		
		
		
		
	<!-- Start Add Modal -->
<div class="modal fade" id="product_modal" tabindex="-1" aria-labelledby="product_modal" aria-hidden="true" >
    <div class="modal-dialog" >
      <div class="modal-content">
        <div class="modal-header">
          <h5 class="modal-title" id="product_modal">Add IGI No</h5>
          <button type="button" class="close" data-dismiss="modal" aria-label="Close" onclick="close_modal()">
            <span aria-hidden="true">&times;</span>
          </button>
        </div>
                    
        <div class="modal-body" id="product_data" style="background:#fff ">

			
			
        </div>
		  
<!--
        <div class="modal-footer">
          <button type="button" class="btn btn-default" data-dismiss="modal" onclick="close_modal()">Close</button>
        </div>
-->
    
      </div>
    </div>
  </div>
  <!---End Add Modal-->

		
		
		
		
</body>
</html>