Guest User

gferer

a guest
Nov 25th, 2018
179
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.00 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. /** code **/
  11.  
  12. $sqlb="SELECT * FROM ecomexpress_awb";
  13. $resultb = $db_handle->runSelectQuery($sqlb);
  14.  
  15. $order_id='';
  16. $payment_type='';
  17.  
  18. if(isset($_POST['order_id']) && $_POST['order_id']!='')
  19. {
  20. $order_id = $_POST['order_id'];
  21. $payment_type=$_POST['payment_type'];
  22.  
  23.  
  24. $sqlg="SELECT * FROM do_order where payment_type='".$payment_type."'";
  25. $resultg = $db_handle->runSelectQuery($sqlg);
  26.  
  27. if($payment_type=="Cash on delivery")
  28. {
  29. $sqlc = "select * from ecomexpress_awb WHERE status='unused' AND awb_type='COD' limit 1";
  30. }
  31. else
  32. {
  33. $sqlc = "select * from ecomexpress_awb WHERE status='unused' AND awb_type='PPD' limit 1";
  34. }
  35.  
  36. $resultc = $db_handle->runSelectQuery($sqlc);
  37.  
  38. if(count($resultc)==1)
  39. {
  40. $sqle = "update ecomexpress_awb set orderid = '".$order_id."',status='used' WHERE awb ='".$resultc[0]['awb']."'";
  41. $resulte = $db_handle->runSelectQuery($sqle);
  42.  
  43. }
  44.  
  45. //add only field name
  46.  
  47. $sqlh="SELECT * FROM do_order where order_id='".$order_id."'";
  48. $resulth = $db_handle->runSelectQuery($sqlh);
  49.  
  50.  
  51. $data =
  52. array (
  53. 'XBkey' => 'QGfMthH1',
  54. 'VersionNumber' => 'V5',
  55. 'ManifestDetails' =>
  56. array (
  57. 'ManifestID' => '12320160729',
  58. 'OrderType' => ($payment_type == "Cash on delivery" ? "COD" : "Prepaid"),
  59. 'OrderNo' => $order_id,
  60. 'PaymentStatus' => ($payment_type == "Cash on delivery" ? "COD" : "Prepaid"),
  61. 'PickupVendor' => 'Outthinking',
  62. 'PickVendorPinCode' => '560043',
  63. 'CustomerName' => $resulth[0]['customer_name'],
  64. 'ZipCode' => '560043',
  65. 'CustomerAddressDetails' =>
  66. array (
  67. 0 =>
  68. array (
  69. 'Type' => 'Primary',
  70. 'Address' => $resulth[0]['customer_name'],
  71. ),
  72. ),
  73. 'CustomerMobileNumberDetails' =>
  74. array (
  75. 0 =>
  76. array (
  77. 'Type' => 'Primary',
  78. 'MobileNo' => $resulth[0]['phone_number'],
  79. ),
  80. ),
  81. 'RTOPinCode' => '400061',
  82. 'AirWayBillNO' => $resultc[0]['awb'],
  83. 'Quantity' => 1,
  84. 'PickupVendorCode' => 'M34',
  85. 'CollectibleAmount' => $resulth[0]['price'],
  86. 'DeclaredValue' => $resulth[0]['price'],
  87. 'GSTMultiSellerInfo' =>
  88. array (
  89. 0 =>
  90. array (
  91. 'ProductDesc' => 'Custom product',
  92. 'SellerName' => 'OUTTHINKING ELECTRONICS PVT LTD',
  93. 'SellerAddress' => 'No 28 2nd Floor,5th Main road, OMBR Layout Kasturinagar',
  94. 'SellerPincode' => 560043,
  95. 'InvoiceDate' => '13-10-2016', //orderdate
  96. ),
  97. ),
  98. ),
  99. );
  100.  
  101. $url = "http://114.143.206.69:803/StandardForwardStagingService.svc/AddManifestDetails";
  102.  
  103. $data = json_encode($data);
  104.  
  105. $headers = array("Content-Type: application/json");
  106. $curl = curl_init($url);
  107.  
  108. curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
  109. curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
  110. curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
  111. curl_setopt($curl, CURLOPT_POST, true);
  112. curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
  113. curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
  114. curl_setopt($curl, CURLOPT_VERBOSE, true);
  115.  
  116. $curl_response = curl_exec($curl);
  117. curl_close($curl);
  118. echo $curl_response ."\n";
  119. $res=json_decode($curl_response);
  120.  
  121. foreach ($res->curl_response as $values)
  122. {
  123.  
  124. if($values->ReturnMessage=='successful')
  125. {
  126. $usql="update do_order set tracking_id='".$resultc[0]['awb']."',shipping_name='xpress', where order_id='".$order_id."'";
  127.  
  128. $result=$db_handle->executeUpdate($usql);
  129. echo "1";die;
  130. }
  131. else
  132. {
  133. echo $values->ReturnMessage;die;
  134. }
  135. }
  136.  
  137. print_r($data);
  138. //print_r($res->curl_response);
  139.  
  140. }
  141.  
  142.  
  143.  
  144.  
  145.  
  146.  
  147.  
  148.  
  149.  
  150.  
  151.  
  152.  
  153. //$sqla = "update ecomexpress_awb status='assigned' WHERE awb=".$selectawb." AND order_id=". $postorderid;
  154. //$sqld = $db_handle->runSelectQuery($sqla);
  155.  
  156.  
  157.  
  158. ?>
Add Comment
Please, Sign In to add comment