[Vtigercrm-commits] [vtiger-commits] r9289 - in /vtigercrm/trunk: include/fpdf/pdf.php include/fpdf/templates/body.php modules/Invoice/CreatePDF.php
vtigercrm-commits at vtiger.fosslabs.com
vtigercrm-commits at vtiger.fosslabs.com
Tue Sep 5 11:46:29 EDT 2006
Author: saraj
Date: Tue Sep 5 09:46:21 2006
New Revision: 9289
Log:
* Modified to display the Product and Tax details for Invoice
Modified:
vtigercrm/trunk/include/fpdf/pdf.php
vtigercrm/trunk/include/fpdf/templates/body.php
vtigercrm/trunk/modules/Invoice/CreatePDF.php
Modified: vtigercrm/trunk/include/fpdf/pdf.php
==============================================================================
--- vtigercrm/trunk/include/fpdf/pdf.php (original)
+++ vtigercrm/trunk/include/fpdf/pdf.php Tue Sep 5 09:46:21 2006
@@ -305,14 +305,16 @@
break;
case 'Qty':
case 'Price':
- case 'Tax':
if($taxtype == "individual")
$this->Line( $colX, $y1, $colX, (($y1+$y2)-37));
else
$this->Line( $colX, $y1, $colX, (($y1+$y2)-43));
break;
default:
- $this->Line( $colX, $y1, $colX, ($y1+$y2));
+ if($taxtype == "individual" && $lib == 'Discount')
+ $this->Line( $colX, $y1, $colX, (($y1+$y2)-37));
+ else
+ $this->Line( $colX, $y1, $colX, ($y1+$y2));
break;
}
}
Modified: vtigercrm/trunk/include/fpdf/templates/body.php
==============================================================================
--- vtigercrm/trunk/include/fpdf/templates/body.php (original)
+++ vtigercrm/trunk/include/fpdf/templates/body.php Tue Sep 5 09:46:21 2006
@@ -24,13 +24,15 @@
$colsAlign["Description"] = "L";
$colsAlign["Qty"] = "R";
$colsAlign["Price"] = "R";
+ $colsAlign["Discount"] = "R";
$colsAlign["Tax"] = "R";
$colsAlign["Total"] = "R";
$cols["Product Name"] = "25";
- $cols["Description"] = "80";
- $cols["Qty"] = "15";
+ $cols["Description"] = "70";
+ $cols["Qty"] = "10";
$cols["Price"] = "25";
+ $cols["Discount"] = "15";
$cols["Tax"] = "20";
$cols["Total"] = "25";
} else {
@@ -38,12 +40,14 @@
$colsAlign["Description"] = "L";
$colsAlign["Qty"] = "R";
$colsAlign["Price"] = "R";
+ $colsAlign["Discount"] = "R";
$colsAlign["Total"] = "R";
$cols["Product Name"] = "25";
- $cols["Description"] = "80";
- $cols["Qty"] = "20";
+ $cols["Description"] = "70";
+ $cols["Qty"] = "15";
$cols["Price"] = "30";
+ $cols["Discount"] = "20";
$cols["Total"] = "30";
}
@@ -76,77 +80,77 @@
if($focus->column_fields["hdnTaxType"] != "individual") {
- $lineData=array("115",$bottom+37,"84");
+ $lineData=array("105",$bottom+37,"94");
$pdf->drawLine($lineData);
- $data= $app_strings['LBL_NET_TOTAL'].": ".$price_subtotal."";
- $pdf->SetXY( 119 , 168 );
+ $data= $app_strings['LBL_NET_TOTAL'].": ".$price_subtotal."";
+ $pdf->SetXY( 105 , 168 );
$pdf->SetFont( "Helvetica", "", 10);
- $pdf->MultiCell(119, 4, $data);
+ $pdf->MultiCell(110, 4, $data);
- $lineData=array("115",$bottom+43,"84");
+ $lineData=array("105",$bottom+43,"94");
$pdf->drawLine($lineData);
- $data= $app_strings['LBL_DISCOUNT'].": ".$price_discount."";
- $pdf->SetXY( 119 , 174 );
+ $data= $app_strings['LBL_DISCOUNT'].": ".$price_discount."";
+ $pdf->SetXY( 105 , 174 );
$pdf->SetFont( "Helvetica", "", 10);
- $pdf->MultiCell(119, 4, $data);
+ $pdf->MultiCell(110, 4, $data);
- $lineData=array("115",$bottom+49,"84");
+ $lineData=array("105",$bottom+49,"94");
$pdf->drawLine($lineData);
- $data= $app_strings['LBL_TAX'].": ".$price_salestax."";
- $pdf->SetXY( 119 , 180 );
+ $data= $app_strings['LBL_TAX'].": ($group_total_tax_percent %) ".$price_salestax."";
+ $pdf->SetXY( 105 , 180 );
$pdf->SetFont( "Helvetica", "", 10);
- $pdf->MultiCell(119, 4, $data);
+ $pdf->MultiCell(110, 4, $data);
- $lineData=array("115",$bottom+55,"84");
+ $lineData=array("105",$bottom+55,"94");
$pdf->drawLine($lineData);
- $data = $app_strings['LBL_SHIPPING_AND_HANDLING_CHARGES'].": ".$price_shipping;
- $pdf->SetXY( 119 , 186 );
+ $data = $app_strings['LBL_SHIPPING_AND_HANDLING_CHARGES'].": ".$price_shipping;
+ $pdf->SetXY( 105 , 186 );
$pdf->SetFont( "Helvetica", "", 10);
- $pdf->MultiCell(119, 4, $data);
+ $pdf->MultiCell(110, 4, $data);
} else {
- $lineData=array("115",$bottom+43,"84");
+ $lineData=array("105",$bottom+43,"94");
$pdf->drawLine($lineData);
- $data= $app_strings['LBL_NET_TOTAL'].": ".$price_subtotal."";
- $pdf->SetXY( 119 , 174 );
+ $data= $app_strings['LBL_NET_TOTAL'].": ".$price_subtotal."";
+ $pdf->SetXY( 105 , 174 );
$pdf->SetFont( "Helvetica", "", 10);
- $pdf->MultiCell(119, 4, $data);
+ $pdf->MultiCell(110, 4, $data);
- $lineData=array("115",$bottom+49,"84");
+ $lineData=array("105",$bottom+49,"94");
$pdf->drawLine($lineData);
- $data= $app_strings['LBL_DISCOUNT'].": ".$price_discount."";
- $pdf->SetXY( 119 , 180 );
+ $data= $app_strings['LBL_DISCOUNT'].": ".$price_discount."";
+ $pdf->SetXY( 105 , 180 );
$pdf->SetFont( "Helvetica", "", 10);
- $pdf->MultiCell(119, 4, $data);
+ $pdf->MultiCell(110, 4, $data);
- $lineData=array("115",$bottom+55,"84");
+ $lineData=array("105",$bottom+55,"94");
$pdf->drawLine($lineData);
- $data = $app_strings['LBL_SHIPPING_AND_HANDLING_CHARGES'].": ".$price_shipping;
- $pdf->SetXY( 119 , 186 );
+ $data = $app_strings['LBL_SHIPPING_AND_HANDLING_CHARGES'].": ".$price_shipping;
+ $pdf->SetXY( 105 , 186 );
$pdf->SetFont( "Helvetica", "", 10);
- $pdf->MultiCell(119, 4, $data);
+ $pdf->MultiCell(110, 4, $data);
}
-$lineData=array("115",$bottom+61,"84");
+$lineData=array("105",$bottom+61,"94");
$pdf->drawLine($lineData);
-$data = $app_strings['LBL_TAX_FOR_SHIPPING_AND_HANDLING'].": ".$price_shipping_tax;
-$pdf->SetXY( 119 , 192 );
+$data = $app_strings['LBL_TAX_FOR_SHIPPING_AND_HANDLING'].": ($sh_tax_percent %) ".$price_shipping_tax;
+$pdf->SetXY( 105 , 192 );
$pdf->SetFont( "Helvetica", "", 10);
-$pdf->MultiCell(119, 4, $data);
+$pdf->MultiCell(110, 4, $data);
-$lineData=array("115",$bottom+67,"84");
+$lineData=array("105",$bottom+67,"94");
$pdf->drawLine($lineData);
-$data = $app_strings['LBL_ADJUSTMENT'].": ".$price_adjustment;
-$pdf->SetXY( 119 , 198 );
+$data = $app_strings['LBL_ADJUSTMENT'].": ".$price_adjustment;
+$pdf->SetXY( 105 , 198 );
$pdf->SetFont( "Helvetica", "", 10);
-$pdf->MultiCell(119, 4, $data);
+$pdf->MultiCell(110, 4, $data);
-$lineData=array("115",$bottom+73,"84");
+$lineData=array("105",$bottom+73,"94");
$pdf->drawLine($lineData);
-$data = $app_strings['LBL_GRAND_TOTAL'].": ".$price_total;
-$pdf->SetXY( 119 , 204 );
+$data = $app_strings['LBL_GRAND_TOTAL'].":(in $currency_symbol) ".$price_total;
+$pdf->SetXY( 105 , 204 );
$pdf->SetFont( "Helvetica", "", 10);
-$pdf->MultiCell(119, 4, $data);
+$pdf->MultiCell(110, 4, $data);
/* ************** End Totals *********************** */
Modified: vtigercrm/trunk/modules/Invoice/CreatePDF.php
==============================================================================
--- vtigercrm/trunk/modules/Invoice/CreatePDF.php (original)
+++ vtigercrm/trunk/modules/Invoice/CreatePDF.php Tue Sep 5 09:46:21 2006
@@ -78,90 +78,113 @@
$logo_name = $adb->query_result($result,0,"logoname");
}
-//getting the Total Array
-$price_subtotal = $currency_symbol.number_format($focus->column_fields["hdnSubTotal"],2,'.',',');
-$price_salestax = $focus->column_fields["txtTax"]."%";
-if($price_salestax != "")
- $price_salestax = $currency_symbol."0.00";
-
+
+
+
+
+//NOTE : Removed currency symbols and added with Grand Total text. it is enough to show the currency symbol in one place
+
+//we can also get the NetTotal, Final Discount Amount/Percent, Adjustment and GrandTotal from the array $associated_products[1]['final_details']
+
+//getting the Net Total
+$price_subtotal = number_format($focus->column_fields["hdnSubTotal"],2,'.',',');
+
+//Final discount amount/percentage
$discount_amount = $focus->column_fields["hdnDiscountAmount"];
$discount_percent = $focus->column_fields["hdnDiscountPercent"];
-$price_shipping = $currency_symbol.number_format($focus->column_fields["hdnS_H_Amount"],2,'.',',');
-if($price_shipping > 0 || price_shipping == "")
- $price_shipping = $currency_symbol."0.00";
-
-$q = "SELECT * FROM vtiger_inventoryshippingrel WHERE id='".$focus->column_fields["record_id"]."'";
-$shrs = $adb->query($q);
-$shtax1 = $adb->query_result($shrs,'0','shtax1');
-$shtax2 = $adb->query_result($shrs,'0','shtax2');
-$shtax3 = $adb->query_result($shrs,'0','shtax3');
-if($shtax1 != "")
- $price_shipping_tax = number_format($shtax1,2,'.',',')."%";
-if($shtax2 != "")
- $price_shipping_tax = number_format($shtax2,2,'.',',')."%";
-if($shtax3 != "")
- $price_shipping_tax = number_format($shtax3,2,'.',',')."%";
-
-
if($discount_amount != "")
- $price_discount = $currency_symbol.number_format($discount_amount,2,'.',',');
+ $price_discount = number_format($discount_amount,2,'.',',');
else if($discount_percent != "")
$price_discount = $discount_percent."%";
else
- $price_discount = $currency_symbol."0.00";
-
-
-$price_adjustment = $currency_symbol.number_format($focus->column_fields["txtAdjustment"],2,'.',',');
-$price_total = $currency_symbol.number_format($focus->column_fields["hdnGrandTotal"],2,'.',',');
-
-//getting the Product Data
-$query="select vtiger_products.productname, vtiger_products.productid, vtiger_products.unit_price, vtiger_products.product_description, vtiger_inventoryproductrel.* from vtiger_inventoryproductrel inner join vtiger_products on vtiger_products.productid=vtiger_inventoryproductrel.productid where id=".$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');
-
- $unit_price[$i]= $currency_symbol.number_format($adb->query_result($result,$i,'unit_price'),2,'.',',');
- $list_price[$i]= $currency_symbol.number_format(StripLastZero($adb->query_result($result,$i,'listprice')),2,'.',',');
- $list_pricet[$i]= $adb->query_result($result,$i,'listprice');
- $prod_total[$i]= $qty[$i]*$list_pricet[$i];
-
+ $price_discount = "0.00";
+
+//Adjustment
+$price_adjustment = number_format($focus->column_fields["txtAdjustment"],2,'.',',');
+//Grand Total
+$price_total = number_format($focus->column_fields["hdnGrandTotal"],2,'.',',');
+
+
+//get the Associated Products for this Invoice
+$focus->id = $focus->column_fields["record_id"];
+$associated_products = getAssociatedProducts("Invoice",$focus);
+$num_products = count($associated_products);
+
+//This $final_details array will contain the final total, discount, Group Tax, S&H charge, S&H taxes and adjustment
+$final_details = $associated_products[1]['final_details'];
+
+//To calculate the group tax amount
+if($final_details['taxtype'] == 'group')
+{
+ $group_tax_total = $final_details['tax_totalamount'];
+ $price_salestax = number_format($group_tax_total,2,'.',',');
+
+ $group_total_tax_percent = '0.00';
+ $group_tax_details = $final_details['taxes'];
+ for($i=0;$i<count($group_tax_details);$i++)
+ {
+ $group_total_tax_percent = $group_total_tax_percent+$group_tax_details[$i]['percentage'];
+ }
+}
+
+//S&H amount
+$sh_amount = $final_details['shipping_handling_charge'];
+$price_shipping = number_format($sh_amount,2,'.',',');
+
+//S&H taxes
+$sh_tax_details = $final_details['sh_taxes'];
+$sh_tax_percent = '0.00';
+for($i=0;$i<count($sh_tax_details);$i++)
+{
+ $sh_tax_percent = $sh_tax_percent + $sh_tax_details[$i]['percentage'];
+}
+$sh_tax_amount = $final_details['shtax_totalamount'];
+$price_shipping_tax = number_format($sh_tax_amount,2,'.',',');
+
+
+//This is to get all prodcut details as row basis
+for($i=1,$j=$i-1;$i<=$num_products;$i++,$j++)
+{
+ $product_name[$i] = $associated_products[$i]['productName'.$i];
+ $prod_description[$i] = $associated_products[$i]['productDescription'.$i];
+ $product_id[$i] = $associated_products[$i]['hdnProductId'.$i];
+ $qty[$i] = $associated_products[$i]['qty'.$i];
+ $unit_price[$i] = number_format($associated_products[$i]['unitPrice'.$i],2,'.',',');
+ $list_price[$i] = number_format($associated_products[$i]['listPrice'.$i],2,'.',',');
+ $list_pricet[$i] = $associated_products[$i]['listPrice'.$i];
+ $discount_total[$i] = $associated_products[$i]['discountTotal'.$i];
+
+ $taxable_total = $qty[$i]*$list_pricet[$i]-$discount_total[$i];
+
+ $producttotal = $taxable_total;
$total_taxes = '0.00';
- if($focus->column_fields["hdnTaxType"] == "individual") {
- $q = "SELECT * FROM vtiger_inventoryproductrel WHERE id='".$focus->column_fields["record_id"]."' AND productid='".$product_id[$i]."'";
- $trs = $adb->query($q);
- $tax1 = $adb->query_result($trs,'0','tax1');
- $tax2 = $adb->query_result($trs,'0','tax2');
- $tax3 = $adb->query_result($trs,'0','tax3');
- $taxable_total = ($adb->query_result($trs,'0','listprice') * $adb->query_result($trs,'0','quantity'));
-
- if($tax1 != "" && $tax1 > 0) {
- $total_taxes = (($taxable_total*$tax1)/100);
- $prod_total[$i] = ($prod_total[$i]+$total_taxes);
+ if($focus->column_fields["hdnTaxType"] == "individual")
+ {
+ $total_tax_percent = '0.00';
+ //This loop is to get all tax percentage and then calculate the total of all taxes
+ for($tax_count=0;$tax_count<count($associated_products[$i]['taxes']);$tax_count++)
+ {
+ $tax_percent = $associated_products[$i]['taxes'][$tax_count]['percentage'];
+ $total_tax_percent = $total_tax_percent+$tax_percent;
+ $tax_amount = (($taxable_total*$tax_percent)/100);
+ $total_taxes = $total_taxes+$tax_amount;
}
- if($tax2 != "" && $tax2 > 0) {
- $total_taxes = (($taxable_total*$tax2)/100);
- $prod_total[$i] = ($prod_total[$i]+$total_taxes);
- }
- if($tax3 != "" && $tax3 > 0) {
- $total_taxes = (($taxable_total*$tax3)/100);
- $prod_total[$i] = ($prod_total[$i]+$total_taxes);
- }
- $product_line[$i]["Tax"] = $total_taxes."%";
- }
- $product_line[$i]["Product Name"] = $product_name[$i];
- $product_line[$i]["Description"] = $prod_description[$i];
- $product_line[$i]["Qty"] = $qty[$i];
- $product_line[$i]["Price"] = $list_price[$i];
- $product_line[$i]["Total"] = $currency_symbol.number_format($prod_total[$i],"2",".",",");
-}
-
+ $producttotal = $taxable_total+$total_taxes;
+ $product_line[$j]["Tax"] = number_format($total_taxes,2,'.',',')."\n ($total_tax_percent %) ";
+ }
+ $prod_total[$i] = number_format($producttotal,2,'.',',');
+
+ $product_line[$j]["Product Name"] = $product_name[$i];
+ $product_line[$j]["Description"] = $prod_description[$i];
+ $product_line[$j]["Qty"] = $qty[$i];
+ $product_line[$j]["Price"] = $list_price[$i];
+ $product_line[$j]["Discount"] = $discount_total[$i];
+ $product_line[$j]["Total"] = $prod_total[$i];
+}
+
+//echo '<pre>Product Details ==>';print_r($product_line);echo '</pre>';
+//echo '<pre>';print_r($associated_products);echo '</pre>';
// ************************ END POPULATE DATA ***************************8
More information about the vtigercrm-commits
mailing list