Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Insert Row numbers in Invoice
10-27-2016, 02:05 AM,
#1
Insert Row numbers in Invoice
How to Insert Row numbers in Invoice
I want to insert row numbers in invoice, as Sr.No for each item in invoice
I have tried to use salesorderdetails.orderlineno this suits my requirement, but he problem is -
When i insert the line -salesorderdetails.orderlineno in the SQL Query

// gather the invoice data

if($InvOrCredit=='Invoice') {
$sql = "SELECT debtortrans.trandate,
debtortrans.ovamount,
salesorderdetails.orderlineno
I get an SQL error saying unknown column in field list.

I tried -
$orderno = $myrow[orderno];

$result = DB_query("SELECT orderlineno
FROM salesorderdetails
WHERE orderno = " . $orderno );
$linecount = DB_fetch_array($result);
$orderlines = $Itemcount['orderlineno'];

this returns only one row from the salesorder I have four items in the order selected.

Result with echo statement- echo print_r( $linecount);
shows- Array ( [0] => 0 [orderlineno] => 0 )

how do I fetch all lines in order.

Please help
Thanks
Swaminathan
Reply
10-27-2016, 08:19 AM,
#2
RE: Insert Row numbers in Invoice
You can join the debtortrans table to the salesorderdetails table using debtortrans.order_=salesorderdetails.orderno

Thanks
Tim
Reply
10-28-2016, 01:05 AM, (This post was last modified: 10-28-2016, 01:08 AM by swaminathan.)
#3
RE: Insert Row numbers in Invoice
thanks
tried the following code-
$orderno = $myrow['orderno'];
$result=DB_query("SELECT salesorderdetails.orderlineno FROM salesorderdetails
INNER JOIN debtortrans
ON debtortrans.order_ = salesorderdetails.orderno
Where salesorderdetails.orderno =" .$orderno);

$myrow3 = DB_fetch_array($result);
$Orderlineno = $myrow3 ['orderlineno'] ;

echo print_r($Orderlineno) ;
But only one row fetched out of four in the invoice.
the same code fetches all the rows when run in PHPMyAdmin.
Thanks
Swaminathan
Reply
10-28-2016, 05:10 AM,
#4
RE: Insert Row numbers in Invoice
DB_fetch_array() fetches one row at a time, so you need:

while ($myrow3 = DB_fetch_array($result)) {
$Orderlineno = $myrow3 ['orderlineno'];
echo print_r($Orderlineno);
}

Hope that helps,
Tim
Reply
10-29-2016, 02:00 AM, (This post was last modified: 10-29-2016, 02:02 AM by swaminathan.)
#5
RE: Insert Row numbers in Invoice
Thanks
This works, but I now get only the last row number on all rows on the invoice table.

I have shifted the item code column to right and created space for the row number column
Thanks
Swaminathan
Reply
10-29-2016, 03:33 AM,
#6
RE: Insert Row numbers in Invoice
Can you share the code?
Reply
10-29-2016, 03:16 PM,
#7
RE: Insert Row numbers in Invoice
This is my code-
$orderno = $myrow['orderno'];
$result=DB_query("SELECT salesorderdetails.orderlineno FROM salesorderdetails
INNER JOIN debtortrans
ON debtortrans.order_ = salesorderdetails.orderno
Where salesorderdetails.orderno =" .$orderno);

while ($myrow3 = DB_fetch_array($result)) {
$Orderlineno = $myrow3 ['orderlineno'];

}

here with echo print_r($myrow3);
I get- Array ( [0] => 0 [orderlineno] => 0 ) 1Array ( [0] => 1 [orderlineno] => 1 ) 1Array ( [0] => 2 [orderlineno] => 2 ) 1Array ( [0] => 3 [orderlineno] => 3 )
I have 4 rows in this invoice.

with echo print_r($orderlineno);
I get- 01112131

but with-

$LeftOvers = $pdf->addTextWrap($Left_Margin,$YPos,71,$FontSize,$Orderlineno);// Print Row number.
only last row number- 3 is displayed on the invoice for all four rows

I guess the code is not in appropriate location.

is there a way to share the pdf invoice and PrintCustTransPortrait.php Files .
Thanks
Swaminathan
Reply
10-30-2016, 02:49 PM,
#8
RE: Insert Row numbers in Invoice
Tried this and now works fine
thank you
$RownumResult = DB_query("SELECT (orderlineno +1) AS srno
FROM salesorderdetails
INNER JOIN debtortrans
ON debtortrans.order_ = salesorderdetails.orderno
WHERE stkcode =" . $myrow2['stockid'] . "
AND salesorderdetails.orderno='" . $myrow['orderno'] . "'");
Thanks
Swaminathan
Reply
10-31-2016, 02:06 AM,
#9
RE: Insert Row numbers in Invoice
Glad it works for you Smile
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)