ok

Mini Shell

Direktori : /home2/selectio/www/lilyexpresslive/software/admin/
Upload File :
Current File : /home2/selectio/www/lilyexpresslive/software/admin/pod_upload.php

<?php require_once('header.php');?>

<?php
if(isset($_POST['Import'])) {
   
	$valid = 1;
$clientId=0;
$clientLocation="";
	if(empty($_POST['awb_no'])) {
		$valid = 0;
		$error_message .= 'AWB No can not be empty<br>';
		$awb='';
	}else{
	$awb=$_POST['awb_no'];
	}
	$awb_type=$_POST['awb_type'];
	$pod_type=$_POST['pod_type'];

 
	                        $statement = $pdo->prepare("SELECT * FROM pickup_entry where $awb_type='$awb'");
							$statement->execute();
							$result = $statement->fetchAll(PDO::FETCH_ASSOC);
						    $total = $statement->rowCount();
                            if($total>0)
                            {
                                foreach($result as $res)
                                {
                                    $res_id=$res['id'];
                                    $clientLocation=$res['destination'];
                                    $clientId=$res['client_id'];
                                }
                               
                            }
                            else
                            {
                                $valid=0;
                                $error_message .= 'AWB No Does not Exist<br>'; 
                            }
                            
                            $statement = $pdo->prepare("SELECT * FROM tbl_pod where awb_no='$awb' and pod_type=$pod_type");
							$statement->execute();
							$result = $statement->fetchAll(PDO::FETCH_ASSOC);
						    $total = $statement->rowCount();
                            if($total>0)
                            {
                                $valid=0;
                                $error_message .= 'This AWB No is Already POD Uploaded<br>';
                               
                            }
                            
    if($valid==1)
    {
        if($pod_type==1)
        {
            $img_type='p';
        }
         elseif($pod_type==2)
        {
            $img_type='d';
        }
        
        $path = $_FILES['pod_file1']['name'];
             if($path!=''){
		    $path_tmp = $_FILES['pod_file1']['tmp_name'];  
            $ext = pathinfo( $path, PATHINFO_EXTENSION );
		    $file_name = basename( $path, '.' . $ext );
		    $final_name1 = $awb.'-'.$img_type.'-1'.'.'.$ext;
		    move_uploaded_file( $path_tmp, 'img/POD/'.$final_name1 );
             }else
           {
               $final_name1='';
           }
            $path = $_FILES['pod_file2']['name'];
             if($path!=''){
		    $path_tmp = $_FILES['pod_file2']['tmp_name'];  
            $ext = pathinfo( $path, PATHINFO_EXTENSION );
		    $file_name = basename( $path, '.' . $ext );
		    $final_name2 = $awb.'-'.$img_type.'-2'.'.'.$ext;
		    move_uploaded_file( $path_tmp, 'img/POD/'.$final_name2 );
             }else
           {
               $final_name2='';
           }
            $path = $_FILES['pod_file3']['name'];
             if($path!=''){
		    $path_tmp = $_FILES['pod_file3']['tmp_name'];  
            $ext = pathinfo( $path, PATHINFO_EXTENSION );
		    $file_name = basename( $path, '.' . $ext );
		    $final_name3 = $awb.'-'.$img_type.'-3'.'.'.$ext;
		    move_uploaded_file( $path_tmp, 'img/POD/'.$final_name3 );
             }else
           {
               $final_name3='';
           }
            $path = $_FILES['pod_file4']['name'];
             if($path!=''){
		    $path_tmp = $_FILES['pod_file4']['tmp_name'];  
            $ext = pathinfo( $path, PATHINFO_EXTENSION );
		    $file_name = basename( $path, '.' . $ext );
		    $final_name4 = $awb.'-'.$img_type.'-4'.'.'.$ext;
		    move_uploaded_file( $path_tmp, 'img/POD/'.$final_name4 );
             }else
           {
               $final_name4='';
           }
            $path = $_FILES['pod_file5']['name'];
             if($path!=''){
		    $path_tmp = $_FILES['pod_file5']['tmp_name'];  
            $ext = pathinfo( $path, PATHINFO_EXTENSION );
		    $file_name = basename( $path, '.' . $ext );
		    $final_name5 = $awb.'-'.$img_type.'-5'.'.'.$ext;
		    move_uploaded_file( $path_tmp, 'img/POD/'.$final_name5 );
             }else
           {
               $final_name5='';
           }
        
    
		$statement = $pdo->prepare("INSERT INTO tbl_pod (awb_id,awb_no,awb_type,url_1,url_2,url_3,url_4,url_5,pod_type,type,client_id,location) VALUES (?,?,?,?,?,?,?,?,?,?,?,?)");
		$statement->execute(array($res_id,$awb,$awb_type,$final_name1,$final_name2,$final_name3,$final_name4,$final_name5,$pod_type,'image',$clientId,$clientLocation));
			
		$success_message = 'POD Upload is Done Successfully!';

		unset($_POST['awb_no']);
		unset($_POST['awb_type']);
		
    }
	
}
?>



<section class="content-header">
    <div class="row">
		<div class="col-md-6" style="text-align: left;">
			<h4><i class="fa fa-info-circle"></i> POD Upload</h4>
		</div>
		<div class="col-md-6" style="text-align: left;">
	        <a href="list_pod.php" class="btn btn-danger btn-sm">List All</a>
	    </div>
	</div>
</section>

<section class="content">
	<div class="row">
		<div class="col-md-12">

			<?php if($error_message): ?>
			<div class="callout callout-danger">
				<p>
					<?php echo $error_message; ?>
				</p>
			</div>
			<?php endif; ?>

			<?php if($success_message): ?>
			<div class="callout callout-success">
				<p><?php echo $success_message; ?></p>
			</div>
			<?php endif; ?>

			<form class="form-horizontal" action="" method="post" enctype="multipart/form-data">
				<div >
					<div class="box-body">
							    	<div class="form-group">
							<label for="" class="col-sm-2 control-label">AWB No Type <span>*</span></label>
							<div class="col-sm-6">
								<select class="form-control" name="awb_type" id="awb_type">
							        <option value="ref_no">AWB NO</option>
							    </select>
							</div>
						</div>
					    	<div class="form-group">
							<label for="" class="col-sm-2 control-label"><span id='awb_txt'> AWB No:</span> <span>*</span></label>
							<div class="col-sm-6">
								<input type="text" autocomplete="off" class="form-control" id="awb_no" name="awb_no" value="<?php if(isset($_POST['awb_no'])){echo $_POST['awb_no'];} ?>">
							</div>
							<div class="col-sm-4">
							    <span id="ncheck2"></span><i id='fa_icon'></i>
							</div>
						</div>
						<div class="form-group">
							<label for="" class="col-sm-2 control-label">POD Type <span>*</span></label>
							<div class="col-sm-6">
							    <select class="form-control" name="pod_type" >
							        <!--<option value="0">Select Type</option>-->
							        <option value="2">Delivery POD</option>
							        <option value="1">Pickup POD</option>
							    </select>
							</div>
						</div>
						<div class="form-group">
							<label for="" class="col-sm-2 control-label">POD FILE - 1<span>*</span></label>
							<div class="col-sm-9" style="padding-top:5px">
								<input type="file" name="pod_file1">(Only IMG Format)
							</div>
						</div>
						<div class="form-group">
							<label for="" class="col-sm-2 control-label">POD FILE - 2</label>
							<div class="col-sm-9" style="padding-top:5px">
								<input type="file" name="pod_file2">(Only IMG Format)
							</div>
						</div>
						<div class="form-group">
							<label for="" class="col-sm-2 control-label">POD FILE - 3</label>
							<div class="col-sm-9" style="padding-top:5px">
								<input type="file" name="pod_file3">(Only IMG Format)
							</div>
						</div>
						<div class="form-group">
							<label for="" class="col-sm-2 control-label">POD FILE - 4</label>
							<div class="col-sm-9" style="padding-top:5px">
								<input type="file" name="pod_file4">(Only IMG Format)
							</div>
						</div>
						<div class="form-group">
							<label for="" class="col-sm-2 control-label">POD FILE - 5</label>
							<div class="col-sm-9" style="padding-top:5px">
								<input type="file" name="pod_file5">(Only IMG Format)
							</div>
						</div>
						<div class="form-group">
							<label for="" class="col-sm-2 control-label"></label>
							<div class="col-sm-6">
								<button type="submit" id='submit_btn' class="btn btn-success pull-left" name="Import">Submit</button>
							</div>
						</div>
					</div>
				</div>
			</form>
		</div>
	</div>

</section>

<script>
$(document).ready(function(){
      $("#awb_type").change(function(){
              var awb=$(this).val();
             if(awb=='cscs_awb')
             {
                 $('#awb_txt').text('CSCS AWB NO:');
             }
             else if(awb=='3pl_awb')
             {
                 $('#awb_txt').text('3PL AWB NO:');
             }
             else if(awb=='ref_no')
             {
                 $('#awb_txt').text('REF NO:');
             }
             get_data();
            });
      $("#awb_no").keyup(function(){
             get_data();
            });
            
            
            function get_data()
            {
              var awb=$('#awb_no').val();
              var awb_type=$('#awb_type').val();
              $.ajax({
                  type:'POST',
                  url:'get_unique_awb1.php',
                  data:{awb:awb,type:'pod',awb_type:awb_type},
                   dataType: 'json',
                    beforeSend: function() {
                        $("#ncheck2").text(''); 
                        // setting a timeout
                        $('#fa_icon').addClass('fa fa-spinner fa-spin');
                    },
                  success:function(response){
                      $("#fa_icon").removeClass("fa fa-spinner fa-spin");
                      if(response[0]['error']=='0')
                      {
                          $("#ncheck2").css('color','green'); 
                         $("#ncheck2").text(response[0]['txt']); 
                         $("#submit_btn").prop('disabled', false);
                         
                      }
                      else
                      {
                          $("#ncheck2").css('color','red'); 
                         $("#ncheck2").text(response[0]['txt']);
                         $("#submit_btn").prop('disabled', true);
                      }
                  }
                });
            }
            
});
</script>


<?php require_once('footer.php'); ?>

Zerion Mini Shell 1.0