Knowledgebase: Tutorials
[QODBC-POS] Sample Code for Creating to SalesReceipt using PHP
Posted by Jack - QODBC Support on 29 August 2017 07:42 AM
|
|
Sample Code for Creating to SalesReceipt using PHPSample Application:Please click here to download Sample Code. Please refer below steps for using an application for Creating to SalesReceipt using PHP. Run application. You need to insert CustomerListId, Comments, Cashier, SalesReceiptType, Item ListID, Quantity, Rate & Amount, which you want to enter, and click on the "InsertSalesReceiptItem" button. New SalesReceipt created. Result in QuickBooks POS. Note: Modify/Append existing SalesReceipt feature is not supported by QuickBooks SDK, so it is unavailable through QODBC POS. Application Source Code:<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html> <head> <title>QODBC PHP Script To Display SQL Results</title> </head> <body topmargin="3" leftmargin="3" marginheight="0" marginwidth="0" bgcolor="#ffffff" link="#000066" vlink="#000000" alink="#0000ff" text="#000000"> <table> <tr> <td> SalesReceiptItem <form name="frmItemLine" id="frmItemLine" method="post"> <table> <tr> <td>Enter CustomerListId</td> <td><input type="text" name="txtcustomerName" id="txtcustomerName"/></td> </tr> <tr> <td>Enter Comments</td> <td><input type="text" name="txtComments" id="txtComments"/></td> </tr> <tr> <td>Enter Cashier Name</td> <td><input type="text" name="txtCashierName" id="txtCashierName"/></td> </tr> <tr> <td>Enter SalesReceipt Type</td> <td> <input type="text" name="txtSalesReceiptType" id="txtSalesReceiptType"/></td> </tr> <tr> <td> Enter SalesReceipt ItemListID</td> <td> <input type="text" name="txtItemName" id="txtItemName"/></td> </tr> <tr> <td>Enter Quantity</td> <td> <input type="text" name="txtQuantity" id="txtQuantity"/></td> </tr> <tr> <td>Enter Item Price</td> <td><input type="text" name="txtItemPrice" id="txtItemPrice"/></td> </tr> <tr> <td>Enter Tender Amount</td> <td><input type="text" name="txtTenderAmount" id="txtTenderAmount"/></td> </tr> <tr> <td colspan="2"><center><input type="submit" name="btnItemLine" id="btnItemLine" value="Insert SalesReceiptItem" /></center></td> </tr> </table> </form> </td> </tr> </table> </body> </html> <?php if(isset($_POST['btnItemLine'])) { $customerName= $_POST['txtcustomerName']; $comments = $_POST['txtComments']; $cashierName = $_POST['txtCashierName']; $salesReceiptType = $_POST['txtSalesReceiptType']; $itemName = $_POST['txtItemName']; $quantity = $_POST['txtQuantity']; $itemPrice = $_POST['txtItemPrice']; $tenderAmount = $_POST['txtTenderAmount']; if($customerName == "" ) { echo '<script language="javascript">'; echo 'alert("Enter CustomerName")'; echo '</script>'; } else if($comments == "" ) { echo '<script language="javascript">'; echo 'alert("Enter Comments")'; echo '</script>'; } else if($cashierName == "" ) { echo '<script language="javascript">'; echo 'alert("Enter CashierName")'; echo '</script>'; } else if($salesReceiptType == "" ) { echo '<script language="javascript">'; echo 'alert("Enter SalesReceipt Type")'; echo '</script>'; } else if($itemName == "" ) { echo '<script language="javascript">'; echo 'alert("Enter Item listId")'; echo '</script>'; } else if($quantity == "" ) { echo '<script language="javascript">'; echo 'alert("Enter quantity")'; echo '</script>'; } else if($itemPrice == "" ) { echo '<script language="javascript">'; echo 'alert("Enter itemPrice")'; echo '</script>'; } else if($tenderAmount == "" ) { echo '<script language="javascript">'; echo 'alert("Enter tenderAmount")'; echo '</script>'; } else { set_time_limit(120); $oConnect = odbc_connect("QuickBooks POS Data QRemote", "", ""); $sSQL = "Insert Into SalesReceiptItem (CustomerListId, Comments, Cashier, SalesReceiptType, SalesReceiptItemListId, SalesReceiptItemQty, SalesReceiptItemPrice, TenderCash01TenderAmount) Values ('$customerName','$comments','$cashierName','$salesReceiptType','$itemName',$quantity,$itemPrice,$tenderAmount)"; $oResult = odbc_exec($oConnect, $sSQL); $query="sp_lastInsertID SalesReceiptItem"; //$query="select @@identity"; $result = odbc_exec($oConnect, $query); odbc_result($result, 1); $result1 = odbc_field_name ( $result , 1 ); $resultcount = odbc_fetch_row($result); $item_val = odbc_result($result, "LastInsertId"); $sSQL = "SELECT CustomerListId, Comments, Cashier, SalesReceiptType, SalesReceiptItemListId,SalesReceiptItemDesc1,SalesReceiptItemQty, SalesReceiptItemPrice, TenderCash01TenderAmount FROM SalesReceiptItem where TxnID='$item_val'"; //echo $sSQL; #Perform the query $oResult = odbc_exec($oConnect, $sSQL); $lFldCnt = 0; $lFieldCount = odbc_num_fields($oResult); //print("$lFieldCount"); print("<table border=\"1\">"); print("<th>Line No.</th>\n"); while ($lFldCnt < $lFieldCount) { $lFldCnt++; $sFieldName = odbc_field_name($oResult, $lFldCnt); print("<th>$sFieldName</th>\n"); } $lRecCnt = 0; #Fetch the data from the database while(odbc_fetch_row($oResult)) { $lRecCnt++; print(" <tr>\n"); print(" <td>$lRecCnt</td>\n"); $lFldCnt = 0; $lFieldCount = odbc_num_fields($oResult); while ($lFldCnt < $lFieldCount) { $lFldCnt++; $sFieldValue = trim(odbc_result($oResult, $lFldCnt)); If ($sFieldValue == "") { print("<td> </td>\n"); } else { print("<td valign=\"Top\">$sFieldValue</td>\n"); } } print("</tr>\n"); } print("</table>"); odbc_close($oConnect); } } ?> | |
|
Comments (0)