ok

Mini Shell

Direktori : /home2/selectio/www/lilyexpresslive/software/admin/emergency-code/
Upload File :
Current File : /home2/selectio/www/lilyexpresslive/software/admin/emergency-code/delivery-date-update-status.php

<?php 
require_once('../inc/config.php');
//echo "hi";
if(isset($_POST["Import"])){
 try{
    // echo "hi1";
		$filename=$_FILES["file"]["tmp_name"];
		if($_FILES["file"]["size"] > 0)
		 {
		    // echo "hi2";
		  	$file = fopen($filename, "r");
		  	$ri=0; $j=0; $query=''; $d_dates=array();$d_dates_ids=array();$d_ids=0;
	         while (($emapData = fgetcsv($file, 500, ",")) !== FALSE)
	         {
	            // echo "hi3".$emapData[0];
	             if($emapData==''){
	                 break;
	             }
	             if($ri>0 && $emapData!=''){
	                 $awb_value=$emapData[0];
	                    //echo "hi4";
	                    $statement = $pdo->prepare("SELECT *,(select delivery_date from tbl_tracking WHERE pickup_entry_id=pickup_entry.id order by t_id desc LIMIT 1) as delivered_date
	                    ,(select status from tbl_tracking WHERE pickup_entry_id=pickup_entry.id order by t_id desc LIMIT 1) as tracking_status
	                    FROM `pickup_entry` WHERE ref_no=?");
                        $statement->execute(array($awb_value));
                        $rowcount = $statement->rowCount();
                        $response = $statement->fetchAll(PDO::FETCH_ASSOC);
                        if($rowcount==1){
                            $pickup_entry_id=$response[0]['id'];
                            $ddate=$response[0]['delivered_date'];
                            $tracking_status=$response[0]['tracking_status'];
                            
                            $given=$emapData[1];
                                            $len=strlen($given);
                                            if($len==10){
                                            $date=date_create_from_format("d-m-Y",$given);
                                            $created= date_format($date,"Y-m-d");
                                             $created_at= $created;
                                            }elseif($len==8)
                                            {
                                            $date=date_create_from_format("d-m-y",$given);
                                            $created= date_format($date,"Y-m-d");
                                             $created_at= $created;
                                            }
                                            
                           /*$statement1 = $pdo->prepare("UPDATE tbl_tracking SET delivery_date='$created_at' WHERE pickup_entry_id='$pickup_entry_id' and status='Delivered'");
                           $result=$statement1->execute();
                           
                            if($result){
                                echo "***-Sucess";
                            }else{
                                echo "***-Failed";
                            }*/
                           
                           if($created_at!=$ddate){
                               /*if (in_array($created_at, $d_dates))
                               {
                                   $d_dates[$d_ids]=$created_at;
                                   $d_dates_ids[$d_ids]=$d_dates_ids[$d_ids].",".$pickup_entry_id;
                               }else{
                                   $d_dates[]=$created_at;
                                   $d_dates_ids[]=$pickup_entry_id;
                                   $d_ids++;
                               }*/
                               
                                // echo "UPDATE tbl_tracking SET delivery_date='$created_at' WHERE pickup_entry_id='$pickup_entry_id' and status='Delivered'-----Awb Number:".$awb_value."--olds Date:".$ddate."--tracking_status:".$tracking_status."Udate Date:".$created_at."<br>";
                            $query.="<br>UPDATE tbl_tracking SET delivery_date='$created_at' WHERE pickup_entry_id='$pickup_entry_id' and status='Delivered';";
                            
                           }else{
                               echo "<br>".$awb_value.'Status Updated';
                               //echo "-----Awb Number:".$awb_value."--olds Date:".$ddate."--tracking_status:".$tracking_status."Udate Date:".$created_at."<br>";
                           }
                           
                          
                           
                                        
                        }
                        else{
                            echo "<br>Dublicate Ref Numbsa:".$awb_value;
                        }
                       
	             }
	             $ri++;
	         }
	         echo "<br><br>Final Query: <br>".$query;
	         
	         /*$f=0;
	         foreach($d_dates as $d){
	             echo "<br>".$d."---".$d_dates_ids[$f];
	             $f++;
	         }*/
	         
		 }
		
 }
 catch(Exception $e){echo "eroor".$e;}
}

?>

Zerion Mini Shell 1.0