Guest User

fffff

a guest
Nov 26th, 2018
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.01 KB | None | 0 0
  1. <?php
  2. ini_set('display_errors', 1);
  3. ini_set('display_startup_errors', 1);
  4. error_reporting(E_ALL);
  5. mysqli_report(MYSQLI_REPORT_ALL & ~MYSQLI_REPORT_INDEX);
  6.  
  7. require_once("dbcontroller.php");
  8. $db_handle = new DBController();
  9.  
  10. $order_id='';
  11. $payment_type='';
  12.  
  13. if(isset($_POST['order_id']) && $_POST['order_id']!='')
  14. {
  15. $order_id = $_POST['order_id'];
  16. $payment_type=$_POST['payment_type'];
  17. if($payment_type=="Cash on delivery")
  18. {
  19. $awbtype='COD';
  20. }
  21. else
  22. {
  23. $awbtype='PPD';
  24. }
  25. $sqlg="SELECT order_id , payment_type , customer_name , phone_number, price , order_date FROM do_order where payment_type='".$payment_type."'";
  26. $resultg = $db_handle->runSelectQuery($sqlg);
  27. $sqlc = "select awb_id , awb , orderid , status, awb_type FROM ecomexpress_awb WHERE status='unused' AND awb_type='".$awbtype."' limit 1";
  28. $resultc = $db_handle->runSelectQuery($sqlc);
  29.  
  30. if(count($resultc)==1)
  31. {
  32. $sqle = "update ecomexpress_awb set orderid = '".$order_id."',status='used' WHERE awb ='".$resultc[0]['awb']."'";
  33. $resulte = $db_handle->runSelectQuery($sqle);
  34. }
  35.  
  36. $sqlh="SELECT order_id , payment_type , customer_name , phone_number, price , order_date, address FROM do_order where order_id='".$order_id."'";
  37. $resulth = $db_handle->runSelectQuery($sqlh);
  38.  
  39. $address=explode(",",$resulth['address']);
  40. $countadd=count($address);
  41. $pincode=$address[$countadd-1];
  42.  
  43.  
  44. $data =
  45. array (
  46. 'XBkey' => 'QG6MthH1',
  47. 'VersionNumber' => 'V5',
  48. 'ManifestDetails' =>
  49. array (
  50. 'ManifestID' => date("Ymd"),
  51. 'OrderType' => ($payment_type == "Cash on delivery" ? "COD" : "Prepaid"),
  52. 'OrderNo' => $order_id,
  53. 'PaymentStatus' => ($payment_type == "Cash on delivery" ? "COD" : "Prepaid"),
  54. 'PickupVendor' => 'Outthinking',
  55. 'PickVendorPinCode' => '560043',
  56. 'CustomerName' => $resulth[0]['customer_name'],
  57. 'ZipCode' => $pincode,
  58. 'CustomerAddressDetails' =>
  59. array (
  60. 0 =>
  61. array (
  62. 'Type' => 'Primary',
  63. 'Address' => $resulth[0]['customer_name'],
  64. ),
  65. ),
  66. 'CustomerMobileNumberDetails' =>
  67. array (
  68. 0 =>
  69. array (
  70. 'Type' => 'Primary',
  71. 'MobileNo' => $resulth[0]['phone_number'],
  72. ),
  73. ),
  74. 'RTOPinCode' => '560043',
  75. 'AirWayBillNO' => $resultc[0]['awb'],
  76. 'Quantity' => 1,
  77. 'PickupVendorCode' => '560043',
  78. 'CollectibleAmount' => ($payment_type == "Cash on delivery" ? $resulth[0]['price'] : 0),
  79. 'DeclaredValue' => $resulth[0]['price'],
  80. 'GSTMultiSellerInfo' =>
  81. array (
  82. 0 =>
  83. array (
  84. 'ProductDesc' => 'Custom product',
  85. 'SellerName' => ' PVT LTD',
  86. 'SellerAddress' => 'No 28 2nd Floor,5th Main road, ',
  87. 'SellerPincode' => 560043,
  88. 'InvoiceDate' => date("d-m-Y", strtotime($resulth[0]['order_date']))
  89. ),
  90. ),
  91. ),
  92. );
  93.  
  94. $url = "http://114.143.206.69:803/StandardForwardStagingService.svc/AddManifestDetails";
  95.  
  96. $data = json_encode($data);
  97.  
  98. $headers = array("Content-Type: application/json");
  99. $curl = curl_init($url);
  100.  
  101. curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
  102. curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
  103. curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
  104. curl_setopt($curl, CURLOPT_POST, true);
  105. curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
  106. curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
  107. curl_setopt($curl, CURLOPT_VERBOSE, true);
  108.  
  109. $curl_response = curl_exec($curl);
  110. curl_close($curl);
  111. echo $curl_response ."\n";
  112. $res=json_decode($curl_response);
  113.  
  114. if($res->AddManifestDetails[0]->ReturnMessage=='successful')
  115. {
  116. $sqli="update do_order set tracking_id='".$resultc[0]['awb']."',shipping_name='xpress' where order_id='".$order_id."'";
  117. $resulti=$db_handle->executeUpdate($sqli);
  118.  
  119. $sqlj = "update ecomexpress_awb set orderid = '".$order_id."',status='assigned' WHERE awb ='".$resultc[0]['awb']."'";
  120. $resultj = $db_handle->runSelectQuery($sqlj);
  121. }
  122. else
  123. {
  124. echo $values->ReturnMessage;
  125. }
  126.  
  127. print_r($data);
  128.  
  129. }
  130.  
  131.  
  132.  
  133. ?>
Add Comment
Please, Sign In to add comment