"; $gam=sqlsrv_query($conn,$q72); while($gar=sqlsrv_fetch_array($gam,SQLSRV_FETCH_ASSOC)) { $buyer_name=$gar["DRCR_NAME"]; $gamres=sqlsrv_query($conn, "SELECT * FROM [CUS_SUP_ADDRESS_D] WHERE [DRCR_CODE]='$account_id' AND [SL_NO]='$delivery_to'"); while($gamr=sqlsrv_fetch_array($gamres,SQLSRV_FETCH_ASSOC)) { $address1=$gamr["ADD1"].$gamr["ADD2"]; $address2=$gamr["ADD3"].$gamr["ADD4"]; $address3=$gamr["ADD5"]; $city=$gamr["LOCATION"]; $pin=$gamr["PINCODE"]; $phone1=$gamr["PHONE_NO"]; // $phone2=$gamr["phone2"]; $mob1=$gamr["MOBILE_NO"]; // $mob2=$gamr["mob2"]; $gstin=$gamr["GST_NO"]; $temp_sup_type=$gamr["GST"]; if($temp_sup_type=='A'){$sup_type="B2B";} elseif($temp_sup_type=="C"){$sup_type="EXPWP";} elseif($temp_sup_type=="I"){$sup_type="EXPWOP";} elseif($temp_sup_type=="D"){$sup_type="SEZWP";} elseif($temp_sup_type=="K"){$sup_type="SEZWOP";} elseif($temp_sup_type=="J"){$sup_type="DEXP";} if(strtoupper($gstin)!="URP"){ $buyer_state_code=substr($gstin,0,2); }else{ $buyer_state_code=96; // For Exports } //$buyer_state_code=substr($gstin,0,2); } } $buyerDtls=' "gstin": "'.$gstin.'", "lglNm": "'.$buyer_name.'", "trdNm": "'.$buyer_name.'", "addr1": "'.$address1.'", "addr2": "'.$address2.'", "loc": "'.$city.'", "pin": "'.$pin.'", "stcd": "'.$buyer_state_code.'", "pos": "'.$buyer_state_code.'", "ph": "'.$phone1.'", "em": "test@einv.com" '; $docDtls=' "typ": "INV", "no": "'.$inv_no_db.'", "dt": "'.$inv_date.'" '; $filecontents.="=====sellerDtls=====\n".$sellerDtls."\n
iid $temp_item_id $temp_vat_code $temp_item_unit"; //$temp_item_unit=$mysqli->result($gitdet,0,"unit"); // if($tt==0){} if($tt>0){ $itemList.=","; } $tt++; $temp_line=sprintf('%01.2f',($temp_qty*$temp_rate)); $temp_tax_amt=sprintf('%01.2f',(($temp_qty*$temp_rate)-$temp_disc_amt)*$temp_tax_per/100)); $sub_total=$sub_total+$temp_line; $ald=sprintf('%01.2f',($temp_line-$temp_disc_amt)); $tot_ald+=$ald; //$ald=sprintf('%01.2f',$ald); $tot_tax_amt=$tot_tax_amt+$temp_tax_amt; $tot_discount=$tot_discount+$temp_disc_amt; $l_st=$ald+$temp_tax_amt; $tot_st=$tot_st+$l_st; if(strtoupper($temp_srvce_chk)=='SR'){$isServc="Y";}else{$isServc="N";} $tot_cgst_amt+=$cgst_amt;; $tot_sgst_amt+=$sgst_amt; $tot_igst_amt+=$igst_amt;; // $totItemVal=sprintf('%01.2f',(($temp_qty*$temp_rate)+($temp_qty*$temp_rate*$temp_tax_per/100)+$other_charges-$temp_disc_amt)); $totItemVal=sprintf('%01.2f',(($temp_qty*$temp_rate)+$temp_tax_amt+$other_charges-$temp_disc_amt)); $itemList.='{ "slNo": "'.$tt.'", "prdDesc": "'.ucwords(strtolower($temp_item_name)).'", "isServc": "'.$isServc.'", "hsnCd": "'.$temp_vat_code.'", "qty": "'.sprintf('%01.3f',$temp_qty).'", "unit": "'.strtoupper($temp_item_unit).'", "unitPrice": "'.$temp_rate.'", "totAmt": "'.(sprintf('%01.2f',$ald)).'", "discount": "'.sprintf('%01.2f',$temp_disc_amt).'", "assAmt": "'.(sprintf('%01.2f',$ald)-sprintf('%01.2f',$temp_disc_amt)).'", "gstRt": "'.sprintf('%01.2f',$temp_tax_per).'", "igstAmt": "'.sprintf('%01.2f',$igst_amt).'", "cgstAmt":"'.sprintf('%01.2f',$cgst_amt).'", "sgstAmt":"'.sprintf('%01.2f',$sgst_amt).'", "cesRt": 0, "cesAmt": 0, "cesNonAdvlAmt": 0, "stateCesRt": 0, "stateCesAmt": 0, "stateCesNonAdvlAmt": 0, "othChrg": "'.sprintf('%01.2f',$other_charges).'", "totItemVal":"'.$totItemVal.'" }'; } $filecontents.="=====itemList=====\n".$itemList."\n