ok
Direktori : /home2/selectio/public_html/lilyexpresslive/software/admin/ |
Current File : /home2/selectio/public_html/lilyexpresslive/software/admin/delivery_bulk_upload_status.php |
<?php require_once('header.php'); $clientId=$_SESSION['user']['id']; $clientLocation=$_SESSION['user']['location']; /*Initially Array Variable Start*/ $success_awb=array(); $success_old_status=array(); $success_new_status=array(); $success_status_date=array(); $success_date=array(); $success_customer_name=array(); $success_mobile_number=array(); $failed_awb=array(); $failed_old_status=array(); $failed_new_status=array(); $failed_date=array(); $failed_status_date=array(); $failed_customer_name=array(); $failed_mobile_number=array(); $status =array(); $failed_status=array(); $new_status=""; $error_msg=""; $status_dates=""; $pickup_entry_id=""; $c_status=""; $u_status=""; $remarks=""; $receiver_names=""; $receiver_mobiles=""; $reasons=""; /*Initially Array Variable End*/ $type_name="AWB "; if(isset($_POST["Import"])){ try{ $filename=$_FILES["file"]["tmp_name"]; $failed_count=0; if($_FILES["file"]["size"] > 0) { $file = fopen($filename, "r"); $ri=0; $j=0; while (($emapData = fgetcsv($file, 10000, ",")) !== FALSE) { if($emapData==''){ break; } if($ri>0 && $emapData!=''){ $error_msg=""; /******************** Select Pincode Details **************************/ $awb_value=$emapData[0]; $statement = $pdo->prepare("SELECT * FROM `pickup_entry` WHERE ref_no=?"); $statement->execute(array($awb_value)); $rowcount = $statement->rowCount(); $response = $statement->fetchAll(PDO::FETCH_ASSOC); foreach($response as $res) { $id=$res['id']; $c_status=$res['status']; if($c_status=="picked") { $status_code=2; } else if($c_status=="manifest") { $status_code=3; } else if($c_status=="In Transit") { $status_code=4; } else if($c_status=="Received at destination") { $status_code=5; } else if($c_status=="Out for delivery") { $status_code=6; } else if($c_status=="Delivered") { $status_code=7; } else if($c_status=="Undelivery") { $status_code=8; } else if($c_status=="Return To Origin") { $status_code=9; } else { $status_code=0; } } if($rowcount>0) { date_default_timezone_set('Asia/Kolkata'); $created_at = date('Y-m-d', time()); // Change the line below to your timezone! if($emapData[2]=="") { date_default_timezone_set('Asia/Kolkata'); $created_at = date('Y-m-d h:i:s', time()); $error_msg.="<br> Row Number $rowcount Status Updated Date Required..."; } else { $given=$emapData[2]; $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; } } if(is_numeric($emapData[1]) && $emapData[1]>1) { if($emapData[1]>$status_code) { $pickup_entry_id=$id; $unique_status[]=$emapData[1]; if($emapData[1]==2) { $u_status='picked'; } elseif($emapData[1]==3) { $u_status='manifest'; } elseif($emapData[1]==4) { $u_status='In Transit'; } elseif($emapData[1]==5) { $u_status='Received at destination'; } elseif($emapData[1]==6) { $u_status='Out for delivery'; } elseif($emapData[1]==7) { $u_status='Delivered'; } elseif($emapData[1]==8) { $u_status='Undelivery'; } elseif($emapData[1]==9) { $u_status='Return To Origin'; } else { $u_status='null'; } if($emapData[3]==''){ $receiver_names=''; }else{ $receiver_names=$emapData[3]; } if($emapData[4]==''){ $receiver_mobiles=''; }else{ $receiver_mobiles=$emapData[4]; } if($emapData[6]==''){ $reasons=''; }else{ $reasons=$emapData[6]; } if($emapData[7]==''){ $remarks=''; }else{ $remarks=$emapData[7]; } } else if($emapData[1]==7 && $status_code==8) { $pickup_entry_id=$id; $unique_status[]=$emapData[1]; if($emapData[1]==7) { $u_status='Delivered'; } elseif($emapData[1]==8) { $u_status='Undelivery'; } else { $u_status='null'; } if($emapData[3]==''){ $receiver_names=''; }else{ $receiver_names=$emapData[3]; } if($emapData[4]==''){ $receiver_mobiles=''; }else{ $receiver_mobiles=$emapData[4]; } if($emapData[6]==''){ $reasons=''; }else{ $reasons=$emapData[6]; } if($emapData[7]==''){ $remarks=''; }else{ $remarks=$emapData[7]; } } else { if($emapData[1]==2) { $new_status="Picked"; } elseif($emapData[1]==3) { $new_status="Manifest"; } elseif($emapData[1]==4) { $new_status="In Transit"; } elseif($emapData[1]==5) { $new_status="Received at Destination"; } elseif($emapData[1]==6) { $new_status="Out for Delivery"; } elseif($emapData[1]==7) { $new_status="Delivered"; } elseif($emapData[1]==8) { $new_status="Undelivery"; } elseif($emapData[1]==9) { $new_status='Return To Origin'; } else { $new_status=""; } $error_msg.="<br> $type_name Number $awb_value Current Status: $c_status New Status:$new_status In-valid Status..."; } } else { $error_msg.="<br> $type_name Number $awb_value having Invalid Status Code..."; } if($emapData[5]=="" && $u_status=='Delivered') { date_default_timezone_set('Asia/Kolkata'); $status_dates = $created_at; $error_msg.="<br> Row Number $rowcount Status Delivery Date Required..."; } else if($u_status=='Delivered') { $given=$emapData[2]; $len=strlen($given); if($len==10){ $date=date_create_from_format("d-m-Y",$given); $created= date_format($date,"Y-m-d"); $status_dates= $created; }elseif($len==8) { $date=date_create_from_format("d-m-y",$given); $created= date_format($date,"Y-m-d"); $status_dates= $created; } }else{ $status_dates=$created_at; } } else { $error_msg.="<br> AWB Number $awb_value is Invalid..."; } /*Insert Query Start*/ if($error_msg=="") { ////error_log('Bulk Upload Status : Awb No :'.$awb_value.' Delivery date :'.$status_dates .' Status Date :'.$created_at.' Statu name :'.$u_status); $statement1 = $pdo->prepare("UPDATE pickup_entry SET status='$u_status',last_updated_status_date='$created_at',delivered_date='$status_dates' WHERE id='$pickup_entry_id'"); $statement1->execute(); $statement1 = $pdo->prepare("INSERT INTO tbl_tracking (pickup_entry_id,user_id,location,status,description,remark,receiver_name,receiver_mobile,relation,reason,delivery_date,created_at) VALUES ($pickup_entry_id,$clientId,'$clientLocation','$u_status','','$remarks','$receiver_names','$receiver_mobiles','','$reasons','$status_dates','$created_at')"); $result= $statement1->execute(); if($result) { $status[]='Success'; $success_awb[]=$awb_value; $success_old_status[]=$c_status; $success_new_status[]=$u_status; $success_status_date[]=$status_dates; $success_date[]=$created_at; $success_customer_name[]=$receiver_names; $success_mobile_number[]=$receiver_mobiles; } else { $failed_status[]='Failed'; $failed_awb[]=$awb_value; $failed_old_status[]=$c_status; $failed_new_status[]=$new_status; $failed_status_date[]=$status_dates; $failed_date[]=$created_at; $failed_customer_name[]=$receiver_names; $failed_mobile_number[]=$receiver_mobiles; } } else { $failed_status[]=$error_msg; $failed_awb[]=$awb_value; $failed_old_status[]=$c_status; $failed_new_status[]=$new_status; $failed_status_date[]=$status_dates; $failed_date[]=$created_at; $failed_customer_name[]=$receiver_names; $failed_mobile_number[]=$receiver_mobiles; } /*Insert Query End*/ } $ri++; } fclose($file); if(count($success_awb)>0){?> <center><h3>Back to Delivery   <a href="delivery.php" class="btn btn-success btn-md">Back</a></h3><br> Success Record Details</center> <div class="alert alert-success alert-dismissible" style='margin-left: 2%;margin-right: 2%;overflow:scroll;'> <table class="table table-responsive" > <tr class="table-success"> <th>S.No</th> <th>AWB Number</th> <th>Old Status</th> <th>Updated Status</th> <th>Date</th> <th>Receiver Name</th> <th>Receiver Mobile</th> <th>Delivery Date</th> <th>Status</th> </tr> <tbody> <?php $k=0; foreach($success_awb as $pid) { ?> <tr class="table-active"> <td><?php echo $k+1 ?></td> <td><?php echo $success_awb[$k] ;?></td> <td><?php echo $success_old_status[$k] ;?></td> <td><?php echo $success_new_status[$k] ?></td> <td><?php echo $success_date[$k] ?></td> <td><?php echo $success_customer_name[$k] ?></td> <td><?php echo $success_mobile_number[$k] ?></td> <td><?php echo $success_status_date[$k] ?></td> <td><?php echo $status[$k] ?></td> </tr> <?php $k++; } ?> </tbody> </table></center> <?php } if(count($failed_awb)>0){?> <center><h3>Back to Delivery   <a href="delivery.php" class="btn btn-success btn-md">Back</a></h3><br> Failed Record Details</center> <div class="alert alert-danger alert-dismissible" style='margin-left: 2%;margin-right: 2%;overflow:scroll;'> <table class="table table-responsive" > <tr class="table-success"> <th>S.No</th> <th>AWB Number</th> <th>Old Status</th> <th>Updated Status</th> <th>Receiver Name</th> <th>Receiver Mobile</th> <th>Delivery Date</th> <th>Status</th> </tr> <tbody> <?php $k=0; foreach($failed_awb as $pid) { ?> <tr class="table-active"> <td><?php echo $k+1 ?></td> <td><?php echo $failed_awb[$k] ;?></td> <td><?php echo $failed_old_status[$k] ;?></td> <td><?php echo $failed_new_status[$k] ?></td> <td><?php echo $failed_customer_name[$k] ?></td> <td><?php echo $failed_mobile_number[$k] ?></td> <td><?php echo $failed_status_date[$k] ?></td> <td><?php echo $failed_status[$k] ?></td> </tr> <?php $k++; } ?> </tbody> </table></center> <?php } } } catch(Exception $e) { echo "<center><h3>Back to Status Bulk Upload   <a href='delivery_bulk_upload.php' class='btn btn-success btn-md'>Back</a></h3></center>"; echo "<div class='alert alert-danger alert-dismissible' style='margin-left: 2%;margin-right: 2%;margin-top: 22%;'>"; echo '<center>Message: ' .$e->getMessage(); echo '<br>Error found in uploaded CSV file.Please follow the bulk upload terms and conditions</center>'; echo '</div>'; } } ?> <?php require_once('footer.php'); ?>