ok
Direktori : /home2/selectio/www/lilyexpresslive/software/admin/ |
Current File : /home2/selectio/www/lilyexpresslive/software/admin/cargo-entry-edit-api.php |
<?php ob_start(); session_start(); include("inc/config.php"); if(isset($_POST['type']) && $_POST['type']=='get_client_customer'){ $client_id = $_POST['id']; $customer_id = $_POST['customer_id']; $statement = $pdo->prepare("SELECT * FROM tbl_customer where client_id='$client_id'"); $statement->execute(); $result = $statement->fetchAll(PDO::FETCH_ASSOC); $total = $statement->rowCount(); echo '<option value="">Select Customer</option>'; if($total!=0){ foreach ($result as $row) { if($row['cust_id']==$customer_id){ echo '<option value="'.$row['cust_id'].'" selected>'.$row['cust_name'].'('.$row['cust_code'].')</option>'; }else{ echo '<option value="'.$row['cust_id'].'" >'.$row['cust_name'].'('.$row['cust_code'].')</option>'; } } } else { echo '<option value="">Customer not available</option>'; } } if(isset($_POST['type']) && $_POST['type']=='update_cargo_entry'){ $valid = 1; if(empty($_POST['awb_no'])) { $valid = 0; $error_message .= 'AWB Number can not be empty..<br>'; } elseif(($_POST['awb_no']!=$_POST['old_awb_value'])) { $new_ref=$_POST['awb_no']; $statement = $pdo->prepare("SELECT * FROM pickup_entry WHERE ref_no=?"); $statement->execute(array($new_ref)); $total = $statement->rowCount(); if( $total ==0 ) { $new_awb=$new_ref; } else { $valid = 0; $error_message .= 'AWB Number already Exists..<br>'; } } else { $new_awb=$_POST['awb_no']; } if($valid==1) { $statement = $pdo->prepare("UPDATE pickup_entry SET ref_no=?,client_id=?,pincode=?,customer_id=?,address=?,city=?,state=?,phone=?,c_weight=?,a_weight=?,pics=?,gst_no=?,destination=?,created_at=?,content_desc=?,`e_way_bill_no`=?,`invoice_no`=?,`invoice_value`=?,length1=?,width1=?,height1=?,nob1=?,act_wt1=?,length2=?,width2=?,height2=?,nob2=?,act_wt2=?,length3=?,width3=?,height3=?,nob3=?,act_wt3=?,length4=?,width4=?,height4=?,nob4=?,act_wt4=?,length5=?,width5=?,height5=?,nob5=?,act_wt5=? WHERE id=?"); $result=$statement->execute(array($new_awb,$_POST['client_id'],$_POST['pincode'],$_POST['customer_id'],$_POST['address'],$_POST['city'],$_POST['state'],$_POST['phone'],$_POST['c_weight'],$_POST['a_weight'],$_POST['pics'],$_POST['gst_no'],$_POST['destination'],$_POST['created'],$_POST['content_desc'],$_POST['e_way_bill_number'],$_POST['invoice_no'],$_POST['invoice_value'],$_POST['length1'],$_POST['width1'],$_POST['height1'],$_POST['nob1'],$_POST['act_wt1'],$_POST['length2'],$_POST['width2'],$_POST['height2'],$_POST['nob2'],$_POST['act_wt2'],$_POST['length3'],$_POST['width3'],$_POST['height3'],$_POST['nob3'],$_POST['act_wt3'],$_POST['length4'],$_POST['width4'],$_POST['height4'],$_POST['nob4'],$_POST['act_wt4'],$_POST['length5'],$_POST['width5'],$_POST['height5'],$_POST['nob5'],$_POST['act_wt5'],$_POST['pickup_entry_id'])); } elseif($valid==0){ $result=0;} if($result==1) { $txt='Cargo Entry Updated Successfully..'; $error='1'; } else { $txt='Failed..'; $error='0'; } $datas[] = array('txt' => $txt, 'error' => $error,'awb_number'=>$_POST['pickup_entry_id']); echo json_encode($datas); } ?>