ok

Mini Shell

Direktori : /home2/selectio/public_html/lilyexpresslive/software/admin/
Upload File :
Current File : /home2/selectio/public_html/lilyexpresslive/software/admin/get_unique_awb.php

<?php 
ob_start();
session_start();
include("inc/config.php");

date_default_timezone_set('Asia/Kolkata');
$date = date("Y-m-d");
if(isset($_POST['awb'])){ $awb = $_POST['awb']; }
$type = $_POST['type'];
                    
                          if($type=='easyEdit'){
                              $success=array();
                              $awb_id=array();
                              $nop=array();
                              $awb_id = $_POST['awb_id'];
                              $nop = $_POST['nop'];
                              $update_date = $_POST['update_day'];
                              $clientId=$_POST['user_id'];
                              $clientLocation=$_POST['user_location'];
                              $i=0;
                              
                                $statement = $pdo->prepare("SELECT MAX(read_count) as readCount FROM `pickup_entry`");
    							$statement->execute();
    							$get_data = $statement->fetchAll(PDO::FETCH_ASSOC);
    							foreach($get_data as $data)
    							{
    							    $readCount=$data['readCount'];
    							}
    							if($readCount=='' || empty($readCount)){ $readCount=1; }
    							
    							
                              foreach($awb_id as $id)
                              {
                                  $readCount=$readCount+1;;
                                  
                                $state = $pdo->prepare("SELECT * FROM `pickup_entry` WHERE id='$id'");
							    $state->execute(); 
							    $get_data = $state->fetchAll(PDO::FETCH_ASSOC);
							  foreach($get_data as $get)
                              {
                                  $ref=$get['ref_no'];
                                  $c_nop=$get['pics'];
                              }
							   if(!is_numeric($c_nop) || empty($c_nop)){ $c_nop=0; }
                                  
                                $statement = $pdo->prepare("SELECT * FROM `pickup_entry` WHERE id=?");
    							$statement->execute(array($id));
    							$get_data = $statement->fetchAll(PDO::FETCH_ASSOC);
    							foreach($get_data as $data)
    							{
    							    $c_status=$data['status'];
    							}
    							
                                
                                if($c_status=='pending')
                                {
                                    $statement = $pdo->prepare("UPDATE `pickup_entry` set pics=?,status=?,read_status=?,read_count=?,created_at=?,last_updated_status_date=?,delivered_date=? WHERE id=?");
    							    $result=$statement->execute(array($nop[$i],'picked',0,$readCount,$update_date[$i],$update_date[$i],$update_date[$i],$id));
    							    
    							    $statement = $pdo->prepare("INSERT INTO tbl_tracking (pickup_entry_id,user_id,location,status,description,remark,created_at) VALUES(?,?,?,?,?,?,?)");
    	                            $statement->execute(array($id,$clientId,$clientLocation,'picked','Entry Successfully Picked','Material Safe...',$update_date[$i]));
                                }
                                else{
                                    $statement = $pdo->prepare("UPDATE `pickup_entry` set pics=?,read_status=?,read_count=?,created_at=? WHERE id=?");
    							    $result=$statement->execute(array($nop[$i],0,$readCount,$update_date[$i],$id));
                                }
                                
                                
    							
    							if($result){
    							    
    							    $success[]="For AWB-".$ref." No.of Pieces Changed From ".$c_nop." to ".$nop[$i]." Successfully"; 
    							    
    							}
    							$i++;
                              }
							if($result)
							{
							    $txt='AWB Number is already taken';
							    $error='1';
							}
							else
							{
							    $txt='AWB Number is available';
							    $error='0';
							}
                            
                            }
                            if($type=='awb_no'){
                        	$statement = $pdo->prepare("SELECT * FROM `pickup_entry` WHERE ref_no='".$awb."'");
                        	$r="SELECT * FROM `pickup_entry` WHERE ref_no='".$awb."'";
                        //	error_log("SELECT * FROM `pickup_entry` WHERE ref_no='$awb'");
							$statement->execute();
							$result = $statement->fetchAll(PDO::FETCH_ASSOC);
							$count = $statement->rowCount();
							if($count>0 || $awb=="0")
							{
							    $txt=$count.'AWB Number is already taken:'.$r;
							    $error='1';
							}
							else
							{
							    $txt='AWB Number is available';
							    $error='0';
							}
                            
                            }
                             if($type=='dpcode'){
                        	$statement = $pdo->prepare("SELECT * FROM `tbl_customer` WHERE cust_code='$awb'");
							$statement->execute();
							$result = $statement->fetchAll(PDO::FETCH_ASSOC);
							$count = $statement->rowCount();
							if($count>0)
							{
							    $txt='DP Code is already taken';
							    $error='1';
							}
							else
							{
							    $txt='DP Code is available';
							    $error='0';
							}
                            
                            }
                            
                        if($type=='easyEdit'){
                            $datas[] = array('txt' => $txt, 'error' => $error,'msg'=>$success);
                        }else{
                              $datas[] = array('txt' => $txt, 'error' => $error);}
                              
                         echo json_encode($datas);     
                         
?>

Zerion Mini Shell 1.0