 |
vtiger The Honest Open Source CRM
|
| Previous topic :: Next topic |
| Author |
Message |
logz05
Joined: 26 Mar 2006
Posts: 30
|
| Posted: Wed Jul 05, 2006 7:43 am Post subject: Some hints and tips |
|
|
I am using 4.2.3 with Update 2.
This thread has about saved my bacon and I want o give back a few tips I have learnt in the pdf process.
1. How to get a field that is an INT(19) to show.
I want to have the potential number show on a Quote and the Sales Order. If you use the normal column_fields type code it simply does not show. (Not sure why but it doesn't :? )
So use the following in for example pdf_dataso.php:
Code: $add_query = "select * from salesorder where salesorderid=".$id;
$result = $adb->query($add_query);
$num_rows = $adb->num_rows($result);
if($num_rows == 1)
{
$potentialid = $adb->query_result($result,0,"potentialid");
}
You can then go further and pick up custom fields from the potential if you want.
Code: $add_query = "select * from potentialscf where potentialid=".$potentialid;
$result = $adb->query($add_query);
$num_rows = $adb->num_rows($result);
if($num_rows == 1)
{
$hours_day = $adb->query_result($result,0,"cf_608");
$liters_min = $adb->query_result($result,0,"cf_606");
}
2. How to make a check box do something useful.
Check box results come in as 1 or 0 so simply in for example the body.php you can soemthing like the following:
Code: // watermark based on status
// this is the postion of the watermark before the rotate
$waterMarkPositions=array("50","180");
// this is the rotate amount (todo)
$waterMarkRotate=array("45","50","180");
if ($status ==1) { $status="CHANGE ORDER"; }
else { $status = " "; }
$pdf->watermark( $status, $waterMarkPositions, $waterMarkRotate );
$bottom="130";
$top="80";
// blow a bubble around the table
$Bubble=array("10",$top,"170","$bottom");
$pdf->tableWrapper($Bubble);
3. Getting rid of the columns.
I did not want all the total and quantity columns - weird I know but....
so in the body.php do the following to just show the product name and another wide column to put other information such as totals or custom fields:
Code: // Each of these arrays needs to have matching keys
// "key" => "Length"
// total of columns needs to be 190 in order to fit the table
// correctly
// alignment of each column
$colsAlign=array( "Product Name" => "L",
"Description" => "L",
"Days" => "C",
"Details" => "R",
"Total" => "R" );
$prodTable=array("10","60");
$cols=array( "Product Name"=> 100,
"Details" => 90
);
$pdf->addCols( $cols,$prodTable,$bottom );
//$pdf->addLineFormat( $colsAlign);
.
4. I needed a different body for the PO than for the SO. So I just copied the body.php and renamed it as po_body.php and rename the file in CreatePDF.php and change the code to:
Code: $pdf->AddPage();
include("pdf_templates/po_header.php");
include("pdf_templates/po_body.php");
include("pdf_templates/po_footer.php");
$page_num++;
if (($endpage) && ($lastpage))
{
$pdf->AddPage();
include("pdf_templates/po_header.php");
include("pdf_templates/lastpage/po_body.php");
include("pdf_templates/lastpage/po_footer.php");
}
These may be really simple things, but for a poor hacker like me it took time to figure out - so hopefully it will have helped someone. |
|
| Back to top |
|
BrianLaughlin
Joined: 13 Dec 2005
Posts: 801
|
| Posted: Sun Jul 09, 2006 9:29 am Post subject: Some hints and tips |
|
|
Very kool logz05.
Looks worthy of a wiki post in the How To Section. :-)
Consider putting it there if you haven't already.
Take care, |
|
| Back to top |
|
edlentz
Joined: 18 Nov 2005
Posts: 514
Location: Midland, Mi.
|
| Posted: Wed Jul 12, 2006 6:34 pm Post subject: Re: Some hints and tips |
|
|
logz05
I commented out a couple of columns but my names for the Tax, total, etc went away. What to do now?
Thanks |
|
| Back to top |
|
logz05
Joined: 26 Mar 2006
Posts: 30
|
| Posted: Wed Jul 12, 2006 6:49 pm Post subject: Re: Some hints and tips |
|
|
Quote: I commented out a couple of columns but my names for the Tax, total, etc went away. What to do now?
Can you please post which lines you commented out and I'll take a look. :wink: |
|
| Back to top |
|
edlentz
Joined: 18 Nov 2005
Posts: 514
Location: Midland, Mi.
|
| Posted: Wed Jul 12, 2006 7:13 pm Post subject: Re: Some hints and tips |
|
|
Here's what i did in Red.
/* ************ Begin Table Setup ********************** */
// Each of these arrays needs to have matching keys
// "key" => "Length"
// total of columns needs to be 190 in order to fit the table
// correctly
// alignment of each column
$colsAlign=array( $current_module_strings['Product Name'] => "L",
$current_module_strings['Description'] => "L",
$current_module_strings['Qty'] => "C",
$current_module_strings['List Price'] => "R",
//$current_module_strings['Unit Price'] => "R",
$current_module_strings['Total'] => "R" );
$prodTable=array("10","60");
$cols=array( $current_module_strings['Product Name'] => 25,
$current_module_strings['Description'] => 80,
$current_module_strings['Qty'] => 10,
$current_module_strings['List Price'] => 25,
//$current_module_strings['Unit Price'] => 25,
$current_module_strings['Total'] => 25
);
$pdf->addCols( $cols,$prodTable,$bottom );
$pdf->addLineFormat( $colsAlign);
BTW how can I move the last line of the account shipping and billing addresses up or the start of the balloon for the customer name, valid, quoteid down a line or two?
Thanks alot! |
|
| Back to top |
|
logz05
Joined: 26 Mar 2006
Posts: 30
|
| Posted: Wed Jul 12, 2006 7:28 pm Post subject: Re: Some hints and tips |
|
|
Hi,
As it turns out you took the column that had all of those labels in it!
If you want to you keep it like that and simple paste in the variables elswhere:
Code: $totalBlockPositions=array( "10","180","70" );
$totalText="Sub Total: ".$price_subtotal."\nTax: ".$price_tax."\nTotal: ".$price_total;
$pdf->addTextBlock( "Price", $totalText ,$totalBlockPositions );
Quote: BTW how can I move the last line of the account shipping and billing addresses up or the start of the balloon for the customer name, valid, quoteid down a line or two?
These are handled in the header:
Code: // ************** Begin Addresses **************
// shipping Address
$shipLocation = array("10","43","90");
$shipText=$ship_street."\n".$ship_city.", ".$ship_state." ".$ship_code."\n".$ship_country;
//$pdf->addTextBlock( "Shipping Address:", $shipText, $shipLocation );
// billing Address
$billPositions = array("137","43","60");
$billText=$bill_street."\n".$bill_city.", ".$bill_state." ".$bill_code."\n".$bill_country;
//$pdf->addTextBlock("Billing Address:",$billText, $billPositions);
The ("10","43","90") are the "coordinates"
- 10 is the left/right
- 43 is the up/down
- 90 is the width of the field
Hope this helps |
|
| Back to top |
|
edlentz
Joined: 18 Nov 2005
Posts: 514
Location: Midland, Mi.
|
| Posted: Wed Jul 12, 2006 7:43 pm Post subject: Re: Some hints and tips |
|
|
Thanks!!
I'll give that a try |
|
| Back to top |
|
edlentz
Joined: 18 Nov 2005
Posts: 514
Location: Midland, Mi.
|
| Posted: Wed Jul 12, 2006 8:46 pm Post subject: Re: Some hints and tips |
|
|
Hey logs05
The price total is nice and I can get it over, but is there a way to leave the original Total, tax, grandtotal stuff where it was? Not that whay you provided wasn't fine I just liked the original look better.
Thanks! |
|
| Back to top |
|
logz05
Joined: 26 Mar 2006
Posts: 30
|
| Posted: Wed Jul 12, 2006 9:20 pm Post subject: Re: Some hints and tips |
|
|
You can try this:
In the pdf_data file:
Code: //getting the Product Data
$query="select products.productname,products.unit_price,products.product_description,soproductrel.* from soproductrel inner join products on products.productid=soproductrel.productid where salesorderid=".$id;
global $result;
$result = $adb->query($query);
$num_products=$adb->num_rows($result);
for($i=0;$i<$num_products;$i++) {
$product_name[$i]=$adb->query_result($result,$i,'productname');
$prod_description[$i]=$adb->query_result($result,$i,'product_description');
$product_id[$i]=$adb->query_result($result,$i,'productid');
$qty[$i]=$adb->query_result($result,$i,'quantity');
// NOTE this commented out
//$unit_price[$i]= $currency_symbol.number_format($adb->query_result($result,$i,'unit_price'),2,'.',',');
$list_price[$i]= $currency_symbol.number_format($adb->query_result($result,$i,'listprice'),2,'.',',');
$list_pricet[$i]= $adb->query_result($result,$i,'listprice');
$prod_totalt= $qty[$i]*$list_pricet[$i];
if(!preg_match("/\./",$prod_totalt))
$prod_totalt .=".00";
$prod_total[$i] = $currency_symbol.number_format($prod_totalt,2,'.',',');
$product_line[] = array( "Product Name" => $prod_description[$i],
"Description" => $prod_description[$i],
"Qty" => $qty[$i],
"List Price" => $list_price[$i],
// maintain same number of spaces as characters
" " => $unit_price[$i],
"Total" => $prod_total[$i]);
}
and in the body.php file
Code: /* ************ Begin Table Setup ********************** */
// Each of these arrays needs to have matching keys
// "key" => "Length"
// total of columns needs to be 190 in order to fit the table
// ojo si la pag es mas estrecho menos
// correctly
// alignment of each column
$colsAlign=array( $current_module_strings['Product Name'] => "L",
$current_module_strings['Description'] => "L",
$current_module_strings['Qty'] => "C",
$current_module_strings['List Price'] => "R",
// keep the length of the space the same as the pdf_date file
$current_module_strings[' '] => "R",
$current_module_strings['Total'] => "R" );
$prodTable=array("10","60");
$cols=array( $current_module_strings['Product Name'] => 25,
$current_module_strings['Description'] => 80,
$current_module_strings['Qty'] => 10,
$current_module_strings['List Price'] => 25,
// idem
$current_module_strings[' '] => 25,
$current_module_strings['Total'] => 25
);
$pdf->addCols( $cols,$prodTable,$bottom );
$pdf->addLineFormat( $colsAlign);
I haven't tried playing with my version as it is live and would mess up a bunch of orders. The positioning of the lines in body.php may need some teakinga round these lines:
Code: // These are the lines in-between the totals, remove if you want
// $x,$y,$length
//$lineData=array("150",$bottom+73,"49");
//$pdf->drawLine($lineData);
//$lineData=array("150",$lineData[1]-$pad,"49");
//$pdf->drawLine($lineData);
//$lineData=array("150",$lineData[1]-$pad,"49");
//$pdf->drawLine($lineData);
//$lineData=array("150",$lineData[1]-$pad,"49");
//$pdf->drawLine($lineData);
Keep playing - it is possible. |
|
| Back to top |
|
| |
|