";echo "here df exit";;exit; if(($transport_distance=="")||($transport_distance==NULL)){ @$transport_distance=$_REQUEST['td']; if($transport_distance==""){ exit("Unable to Proceed. Approximate Distance has to be entered"); } } if($debug=='y') { echo "
LNO 101 :".date('dMY His')."$gsp_base_url";; echo "
Basic Token : $gsp_access_token
"; echo "
API Token : $api_access_token
"; echo "
GSTIN: $co_gstin
"; echo "Contents :
"; echo '{ "action": "GENEWAYBILL", "data": { '.$doc_details.', '.$from_details.', '.$to_details.', '.$txn_details.', '.$value_details.', '.$transporter_details.', "itemList": ['.$item_data_details.'] } }

'; } //exit; //Generate $curl_3 = curl_init(); curl_setopt_array($curl_3, array( CURLOPT_URL => $gsp_base_url.'/ewb/enc/v1.03/ewayapi', CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => '', CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 0, CURLOPT_FOLLOWLOCATION => true, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => 'POST', CURLOPT_POSTFIELDS =>'{ "action": "GENEWAYBILL", "data": { '.$doc_details.', '.$from_details.', '.$to_details.', '.$txn_details.', '.$value_details.', '.$transporter_details.', "itemList": ['.$item_data_details.'] } }', CURLOPT_HTTPHEADER => array( 'Content-Type: application/json', 'gstin: '.$co_gstin.'', 'X-Connector-Auth-Token: l7xxba7aa16e968646b992298b377e955e7c:20180607093257:'.$co_gstin.'', 'action: GENEWAYBILL', 'Accept: application/json', 'Authorization: Bearer '.$api_access_token, 'X-Connector-Version: 1.2', 'X-Product-Version: 1.2' ), )); // echo "Apit $api_access_token"; $response_3 = curl_exec($curl_3); // var_dump($response_3);echo "
"; curl_close($curl_3); $Jresponse_3=json_decode($response_3); $ewb_status=$Jresponse_3->status; if($debug=='y'){ echo $response_3; } /* {"data":{"ewayBillDate":"13/03/2022 06:15:00 PM","ewayBillNo":301002808907,"alert":"The distance between the given pincodes are not available in the system., ","validUpto":"14/03/2022 11:59:00 PM"},"status":"1"} */ if($ewb_status=='0'){ //ERROR /*{"error":[{"errorCodes":"604","errorMsg":"E-way bill(s) are already generated for the same document number, you cannot generate again on same document number"}],"status":"0"}*/ $raw_error=$Jresponse_3->error; $error_codes=$raw_error[0]->errorCodes;; // if($error_codes=='604'){ // //already generated // //echo $raw_error[0]->errorMsg; // } echo $raw_error[0]->errorMsg; }elseif($ewb_status=='1'){ $data3=$Jresponse_3->data; $ewb_no=$data3->ewayBillNo; $ewb_date=$data3->ewayBillDate; $ewb_valid=$data3->validUpto; $q164="INSERT INTO [ewb_data] ([ewb_no],[ewb_date],[ewb_validity],[ewb_dtt],[inv_id],[inv_date],[inv_no],[tblprfx],[generate_dtt],[status]) VALUES ('$ewb_no','$ewb_date','$ewb_valid','".date('Y-m-d H:i:s')."','$inv_id','$inv_date_db','$inv_no_db','$tblprfx','".date('Y-m-d H:i:s')."','generated')"; // echo "
$q164;
"; $ins_ewb=sqlsrv_query($conn, $q164); $q152="UPDATE TOP (1) [SALES_H] SET [EWB_NO]='$ewb_no',[EWB_DATE]='$ewb_date',[EWB_VALIDITY]='$ewb_valid' WHERE [DOC_NO]='$inv_id'"; $upd_salesH=sqlsrv_query($conn, $q152); //QRC Generation include('php_qr_code/library/php_qr_code/qrlib.php'); // Include a library for PHP QR code //its a location where generated QR code can be stored. $qr_code_file_path = dirname(__FILE__).DIRECTORY_SEPARATOR.'qr_image'.DIRECTORY_SEPARATOR; $set_qr_code_path = 'qr_image/ewb/inv/'; // If directory is not created, the create a new directory if(!file_exists($qr_code_file_path)){ mkdir($qr_code_file_path); } //Set a file name of each generated QR code $filename = $qr_code_file_path.$inv_id.'.png'; $errorCorrectionLevel = "L"; $matrixPointSize = 2; $frm_link = $ewb_no; QRcode::png($frm_link, $filename, $errorCorrectionLevel, $matrixPointSize, 2); //!QRC Generation echo "Eway Bill No $ewb_no generated for Invoice No $inv_no_db. Valid till $ewb_valid
"; echo "QRCode Generated"; } ?>