 Index: Smarty/templates/Inventory/InventoryActions.tpl
===================================================================
--- Smarty/templates/Inventory/InventoryActions.tpl	(revisione 57)
+++ Smarty/templates/Inventory/InventoryActions.tpl	(copia locale)
@@ -91,9 +91,15 @@
 	   <!-- PO Actions ends -->
 
 	{elseif $MODULE eq 'SalesOrder'}
+
+
+
+
+
 	   <!-- SO Actions starts -->
 	   <tr>
 		<td align="left" style="padding-left:10px;">
+
 			<a href="javascript: document.DetailView.module.value='Invoice'; document.DetailView.action.value='EditView'; document.DetailView.return_module.value='SalesOrder'; document.DetailView.return_action.value='DetailView'; document.DetailView.return_id.value='{$ID}'; document.DetailView.record.value='{$ID}'; document.DetailView.convertmode.value='sotoinvoice'; document.DetailView.submit();" class="webMnu"><img src="{$IMAGE_PATH}actionGenerateInvoice.gif" hspace="5" align="absmiddle" border="0"/></a>
 			<a href="javascript: document.DetailView.module.value='Invoice'; document.DetailView.action.value='EditView'; document.DetailView.return_module.value='SalesOrder'; document.DetailView.return_action.value='DetailView'; document.DetailView.return_id.value='{$ID}'; document.DetailView.record.value='{$ID}'; document.DetailView.convertmode.value='sotoinvoice'; document.DetailView.submit();" class="webMnu">{$APP.LBL_CREATE_BUTTON_LABEL} {$APP.Invoice}</a> 
 		</td>
@@ -114,6 +120,19 @@
 	   -->
 	   <!-- SO Actions ends -->
 
+
+
+
+
+
+
+
+
+
+
+
+
+
 	{elseif $MODULE eq 'Quotes'}
 	   <!-- Quotes Actions starts -->
 	   <tr>
@@ -167,6 +186,7 @@
 
 	{if $MODULE eq 'SalesOrder'}
 		{assign var=export_pdf_action value="CreateSOPDF"}
+		{assign var=export_pdf_action2 value="CreateSOPDF2"}
 	{else}
 		{assign var=export_pdf_action value="CreatePDF"}
 	{/if}
@@ -174,10 +194,34 @@
    <tr>
 	<td align="left" style="padding-left:10px;">
 		<a href="index.php?module={$MODULE}&action={$export_pdf_action}&return_module={$MODULE}&return_action=DetailView&record={$ID}&return_id={$ID}" class="webMnu"><img src="{$IMAGE_PATH}actionGeneratePDF.gif" hspace="5" align="absmiddle" border="0"/></a>
+
                 <a href="index.php?module={$MODULE}&action={$export_pdf_action}&return_module={$MODULE}&return_action=DetailView&record={$ID}&return_id={$ID}" class="webMnu">{$APP.LBL_EXPORT_TO_PDF}</a>
 	</td>
+</tr>
+
+
+
+
+
+
+<!--Written by Dolce Stefano-->
+<tr>
+<td align="left" style="padding-left:10px;">
+		<a href="index.php?module={$MODULE}&action={$export_pdf_action2}&return_module={$MODULE}&return_action=DetailView&record={$ID}&return_id={$ID}" class="webMnu"><img src="{$IMAGE_PATH}actionGeneratePDF.gif" hspace="5" align="absmiddle" border="0"/></a>
+
+                <a href="index.php?module={$MODULE}&action={$export_pdf_action2}&return_module={$MODULE}&return_action=DetailView&record={$ID}&return_id={$ID}" class="webMnu">Esporta DDT</a>
+	</td>
    </tr>
 
+
+
+
+
+
+
+
+
+
 {if $MODULE eq 'Invoice'}
 <!-- Added to give link to  send Invoice PDF through mail -->
  <tr>
Index: modules/SalesOrder/CreateSOPDF2.php
===================================================================
--- modules/SalesOrder/CreateSOPDF2.php	(revisione 0)
+++ modules/SalesOrder/CreateSOPDF2.php	(revisione 0)
@@ -0,0 +1,267 @@
+<?php
+/*********************************************************************************
+** The contents of this file are subject to the vtiger CRM Public License Version 1.0
+ * ("License"); You may not use this file except in compliance with the License
+ * The Original Code is:  vtiger CRM Open Source
+ * The Initial Developer of the Original Code is vtiger.
+ * Portions created by vtiger are Copyright (C) vtiger.
+ * All Rights Reserved.
+ *
+ ********************************************************************************/
+
+
+require('include/tcpdf/pdf.php');
+require_once('include/tcpdf/pdfconfig.php');
+require_once('modules/SalesOrder/SalesOrder.php');
+require_once('include/database/PearDatabase.php');
+
+global $adb,$app_strings,$current_user;
+
+$sql="select vtiger_currency_info.currency_symbol from vtiger_currency_info inner join vtiger_users on vtiger_users.currency_id =vtiger_currency_info.id where vtiger_users.id=?";
+$result = $adb->pquery($sql, array($current_user->id));
+$currency_symbol = $adb->query_result($result,0,'currency_symbol');
+
+// would you like and end page?  1 for yes 0 for no
+$endpage="1";
+
+$id = $_REQUEST['record'];
+//retreiving the vtiger_invoice info
+$focus = new SalesOrder();
+$focus->retrieve_entity_info($_REQUEST['record'],"SalesOrder");
+$focus->apply_field_security();
+$account_name = getAccountName($focus->column_fields[account_id]);
+
+
+//Written by Dolce Stefano
+$querycf="select * from vtiger_salesordercf where salesorderid=$id";
+$esegui_querycf=mysql_query($querycf);
+while($rullo=mysql_fetch_array($esegui_querycf))
+{
+$tipologia=$rullo['cf_460'];
+$causale=$rullo['cf_454'];
+$ncolli=$rullo['cf_456'];
+$trasportoamezzo=$rullo['cf_462'];
+$dataritiro=$rullo['cf_458'];
+}
+
+
+
+////////////////////////
+
+
+// **************** BEGIN POPULATE DATA ********************
+// populate data
+if($focus->column_fields["quote_id"] != '')
+	$quote_name = getQuoteName($focus->column_fields["quote_id"]);
+else
+	$quote_name = '';
+$po_name = $focus->column_fields["purchaseorder"];
+$subject = $focus->column_fields["subject"];
+
+$valid_till = $focus->column_fields["duedate"];
+$valid_till = getDisplayDate($valid_till);
+$bill_street = $focus->column_fields["bill_street"];
+$bill_city = $focus->column_fields["bill_city"];
+$bill_state = $focus->column_fields["bill_state"];
+$bill_code = $focus->column_fields["bill_code"];
+$bill_country = $focus->column_fields["bill_country"];
+$contact_name =getContactName($focus->column_fields["contact_id"]);
+
+$ship_street = $focus->column_fields["ship_street"];
+$ship_city = $focus->column_fields["ship_city"];
+$ship_state = $focus->column_fields["ship_state"];
+$ship_code = $focus->column_fields["ship_code"];
+$ship_country = $focus->column_fields["ship_country"];
+
+$conditions = from_html($focus->column_fields["terms_conditions"]);
+$description = from_html($focus->column_fields["description"]);
+$status = $focus->column_fields["sostatus"];
+
+// Company information
+$add_query = "select * from vtiger_organizationdetails";
+$result = $adb->pquery($add_query, array());
+$num_rows = $adb->num_rows($result);
+
+if($num_rows > 0)
+{
+	$org_name = $adb->query_result($result,0,"organizationname");
+	$org_address = $adb->query_result($result,0,"address");
+	$org_city = $adb->query_result($result,0,"city");
+	$org_state = $adb->query_result($result,0,"state");
+	$org_country = $adb->query_result($result,0,"country");
+	$org_code = $adb->query_result($result,0,"code");
+	$org_phone = $adb->query_result($result,0,"phone");
+	$org_fax = $adb->query_result($result,0,"fax");
+	$org_website = $adb->query_result($result,0,"website");
+
+	$logo_name = $adb->query_result($result,0,"logoname");
+}
+
+//Population of Product Details - Starts
+
+//we can cut and paste the following lines in a file and include that file here is enough. For that we have to put a new common file. we will do this later
+//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']
+
+//get the Associated Products for this Invoice
+$focus->id = $focus->column_fields["record_id"];
+$associated_products = getAssociatedProducts("SalesOrder",$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'];
+
+//getting the Net Total
+$price_subtotal = number_format($final_details["hdnSubTotal"],2,'.',',');
+
+//Final discount amount/percentage
+$discount_amount =$final_details["discount_amount_final"];
+$discount_percent =$final_details["discount_percentage_final"];
+
+if($discount_amount != "")
+	$price_discount = number_format($discount_amount,2,'.',',');
+else if($discount_percent != "")
+{
+	//This will be displayed near Discount label - used in include/fpdf/templates/body2.php
+	$final_price_discount_percent = "(".number_format($discount_percent,2,'.',',')." %)";
+	$price_discount = number_format((($discount_percent*$final_details["hdnSubTotal"])/100),2,'.',',');
+}
+else
+	$price_discount = "0.00";
+
+//Adjustment
+$price_adjustment = number_format($final_details["adjustment"],2,'.',',');
+//Grand Total
+$price_total = number_format($final_details["grandTotal"],2,'.',',');
+
+
+
+//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];
+        //aded for 5.0.3 pdf changes
+        $product_code[$i] = $associated_products[$i]['hdnProductcode'.$i];
+	
+	$taxable_total = $qty[$i]*$list_pricet[$i]-$discount_total[$i];
+
+	$producttotal = $taxable_total;
+	$total_taxes = '0.00';
+	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;
+		}
+		$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 Code"] = $product_code[$i];
+	$product_line[$j]["Product Name"] = decode_html($product_name[$i]);
+	$product_line[$j]["Qty"] = $qty[$i];
+	$product_line[$j]["Qty2"] = $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>';
+
+
+//Population of Product Details - Ends
+
+
+// ************************ END POPULATE DATA ***************************8
+
+$page_num='1';
+$pdf = new PDF( 'P', 'mm', 'A4' );
+$pdf->Open();
+
+$num_pages=ceil(($num_products/$products_per_page));
+
+
+$current_product=0;
+for($l=0;$l<$num_pages;$l++)
+{
+	$line=array();
+	if($num_pages == $page_num)
+		$lastpage=0;
+
+	while($current_product != $page_num*$products_per_page)
+	{
+		$line[]=$product_line[$current_product];
+		$current_product++;
+	}
+
+	$pdf->AddPage();
+	include("modules/SalesOrder/pdf_templates2/header.php");
+	include("include/tcpdf/templates/body2.php");
+
+	//if bottom > 145 then we skip the Description and T&C in every page and display only in lastpage
+	//if you want to display the description and T&C in each page then set the display_desc_tc='true' and bottom <= 145 in pdfconfig.php
+	if($display_desc_tc == 'true')
+	if($bottom <= 145)
+	{
+		include("modules/SalesOrder/pdf_templates2/footer.php");
+	}
+
+	$page_num++;
+
+	if (($endpage) && ($lastpage))
+	{
+		$pdf->AddPage();
+		include("modules/SalesOrder/pdf_templates2/header.php");
+		include("modules/SalesOrder/pdf_templates2/lastpage/body.php");
+		include("modules/SalesOrder/pdf_templates2/lastpage/footer.php");
+	}
+}
+
+
+$pdf->Output('DDT.pdf','D'); //added file name to make it work in IE, also forces the download giving the user the option to save
+
+exit();
+?>
Index: modules/SalesOrder/pdf_templates2/lastpage/body.php
===================================================================
--- modules/SalesOrder/pdf_templates2/lastpage/body.php	(revisione 0)
+++ modules/SalesOrder/pdf_templates2/lastpage/body.php	(revisione 0)
@@ -0,0 +1,66 @@
+<?php
+/*********************************************************************************
+** The contents of this file are subject to the vtiger CRM Public License Version 1.0
+ * ("License"); You may not use this file except in compliance with the License
+ * The Original Code is:  vtiger CRM Open Source
+ * The Initial Developer of the Original Code is vtiger.
+ * Portions created by vtiger are Copyright (C) vtiger.
+ * All Rights Reserved.
+ *
+ ********************************************************************************/
+
+/*
+// Fun with watermarks :)
+$waterMarkPositions=array("60","110");
+$waterMarkRotate=array("0","0","0");
+$pdf->watermark( $app_strings["Thank You"], $waterMarkPositions, $waterMarkRotate );
+$waterMarkPositions=array("30","130");
+$pdf->watermark( $app_strings["For Your Business"], $waterMarkPositions, $waterMarkRotate );
+
+// blowing bubbles
+$Bubble=array("10","80","170","4");
+$pdf->addBubble("", "", $Bubble);
+
+$Bubble=array("168","131","12");
+//$pdf->addBubbleBlock("Neat Look", "For A", $Bubble);
+$Bubble=array("10","131","12");
+//$pdf->addBubbleBlock("The Corners", "Line Up", $Bubble);
+*/
+
+/* ************* Begin Totals ************************** */
+/*
+$totalBlock=array("59","135");
+$names=array($app_strings["Subtotal"],$app_strings["Tax"],$app_strings["Adjustment"],$app_strings["Total"]);
+$totals=array($price_subtotal,$price_salestax,$price_adjustment,$price_total);
+$pdf->addTotalsRec($names,$totals,$totalBlock);
+*/
+/* ************* End Totals *************************** */
+
+/*
+// lets add an image :)
+$imageBlock=array("15","95","8","8");
+$pdf->addImage( "sale.jpeg", $imageBlock);
+$imageBlock=array("185","95","8","8");
+$pdf->addImage( "sale.jpeg", $imageBlock);
+
+// descriptions that change sizes!
+$descc=count(explode("\n",$description));
+$condc=count(explode("\n",$conditions));
+if( (strlen($description) > 256) || (strlen($conditions) > 256) || $condc >6 || $descc > 6 )
+        $num=255;
+else
+        $num=150;
+*/
+/* **************** Begin Description ****************** */
+/*
+$descBlock=array("10","160","53", $num);
+$pdf->addDescBlock($description, $app_strings["Description"], $descBlock);
+
+
+$termBlock=array("107","160","53", $num);
+$pdf->addDescBlock($conditions, $app_strings["Terms & Conditions"], $termBlock);
+*/
+/* ************** End Terms *********************** */
+
+
+?>
Index: modules/SalesOrder/pdf_templates2/lastpage/footer.php
===================================================================
--- modules/SalesOrder/pdf_templates2/lastpage/footer.php	(revisione 0)
+++ modules/SalesOrder/pdf_templates2/lastpage/footer.php	(revisione 0)
@@ -0,0 +1,60 @@
+<?php
+/*********************************************************************************
+** The contents of this file are subject to the vtiger CRM Public License Version 1.0
+ * ("License"); You may not use this file except in compliance with the License
+ * The Original Code is:  vtiger CRM Open Source
+ * The Initial Developer of the Original Code is vtiger.
+ * Portions created by vtiger are Copyright (C) vtiger.
+ * All Rights Reserved.
+ *
+ ********************************************************************************/
+/*
+
+
+// draw a broken line
+$width=3;
+$area=216;
+$pad=2;
+
+for ($i=10;$i<200;$i++) {
+	$linePos=array($i,$area,$width);
+	$pdf->drawLine($linePos);
+	$i = (($i+$width)+$pad)-1;
+}
+
+
+// company addy
+if($org_phone != '')
+$phone="\n".$app_strings["Phone"].":    ".$org_phone;	
+if($org_fax != '')
+  $fax ="\n".$app_strings["Fax"].":        ".$org_fax;	
+$companyBlockPositions=array( "10","220","60" );
+$companyText=$org_address."\n".$org_city.", ".$org_state." ".$org_code." ".$org_country." ".$phone." ".$fax."\n".$org_website ;
+$pdf->addTextBlock( $org_name, $companyText ,$companyBlockPositions );
+
+
+// billing Address
+$billPositions = array("85","235","60");
+if(trim($bill_street)!='')
+	$billText = $bill_street."\n";
+if(trim($bill_city) !='')
+	$billText .= $bill_city.", ";
+if(trim($bill_state)!='' || trim($bill_code)!= '')
+	$billText .= $bill_state." ".$bill_code."\n";
+
+	$billText .=$bill_country;
+$pdf->addTextBlock($app_strings["Billing Address"].":",$billText, $billPositions);
+
+// totals
+$totalBlock=array("145","235","10", "110");
+$totalText=$app_strings["Subtotal"].":      ".$price_subtotal."\n".
+	   $app_strings["Tax"].":              ".$price_salestax."\n".
+	   $app_strings["Adjustment"].":  ".$price_adjustment."\n".
+	   $app_strings["Total"].":            ".$price_total;
+$pdf->addDescBlock($totalText, $app_strings["Total Due"], $totalBlock);
+
+$blurbBlock=array("10","265","150", "60");
+$blockText=$app_strings["Detach_Info"];
+$pdf->addDescBlock($blockText, $app_strings["Instructions"], $blurbBlock);
+*/
+?>
Index: modules/SalesOrder/pdf_templates2/footer.php
===================================================================
--- modules/SalesOrder/pdf_templates2/footer.php	(revisione 0)
+++ modules/SalesOrder/pdf_templates2/footer.php	(revisione 0)
@@ -0,0 +1,55 @@
+<?php
+/*********************************************************************************
+** The contents of this file are subject to the vtiger CRM Public License Version 1.0
+ * ("License"); You may not use this file except in compliance with the License
+ * The Original Code is:  vtiger CRM Open Source
+ * The Initial Developer of the Original Code is vtiger.
+ * Portions created by vtiger are Copyright (C) vtiger.
+ * All Rights Reserved.
+ *
+ ********************************************************************************/
+
+
+define('USD',"$");
+define('EURO', chr(128) );
+
+$desc=explode("\n",$description);
+$cond=explode("\n",$conditions);
+
+$num=230;
+$poBubble=array("10","220","60");
+$testo1="Trasporto a mezzo: ".$trasportoamezzo;
+$pdf->addTextBlock("", $testo1, $poBubble);
+$poBubble=array("10","230","60");
+$testo2="Numero colli: "."".$ncolli;
+$pdf->addTextBlock("",$testo2 , $poBubble);
+$testo3="Data ritiro: ".$dataritiro;
+$poBubble=array("10","240","60");
+$pdf->addTextBlock("",$testo3 , $poBubble);
+$testo4="Firma del conducente: ______________________________";
+$poBubble=array("100","220","100");
+$pdf->addTextBlock("",$testo4 , $poBubble);
+$testo5="Firma del vettore: _________________________________";
+$poBubble=array("100","230","100");
+$pdf->addTextBlock("",$testo5 , $poBubble);
+$testo6="Firma del destinatario: ____________________________";
+$poBubble=array("100","240","100");
+$pdf->addTextBlock("",$testo5 , $poBubble);
+/* **************** Begin Description ****************** */
+/*
+$descBlock=array("10",$top,"53", $num);
+$pdf->addDescBlock($description, $app_strings["Description"], $descBlock);
+*/
+/* ************** End Description *********************** */
+
+
+
+/* **************** Begin Terms ****************** */
+/*
+$termBlock=array("107",$top,"53", $num);
+$pdf->addDescBlock($conditions, $app_strings["Terms & Conditions"], $termBlock);
+*/
+/* ************** End Terms *********************** */
+
+
+?>
Index: modules/SalesOrder/pdf_templates2/header.php
===================================================================
--- modules/SalesOrder/pdf_templates2/header.php	(revisione 0)
+++ modules/SalesOrder/pdf_templates2/header.php	(revisione 0)
@@ -0,0 +1,159 @@
+<?php
+/*********************************************************************************
+** The contents of this file are subject to the vtiger CRM Public License Version 1.0
+ * ("License"); You may not use this file except in compliance with the License
+ * The Original Code is:  vtiger CRM Open Source
+ * The Initial Developer of the Original Code is vtiger.
+ * Portions created by vtiger are Copyright (C) vtiger.
+ * All Rights Reserved.
+ *
+ ********************************************************************************/
+/************************************************************
+ *
+ * Modificato da Dolce Stefano per.ind.dolce@gmail.com s.dolce@studiosynthesis.biz
+ *
+*************************************************************/
+define('USD',"$");
+define('EURO', chr(128) );
+
+// ************** Begin company information *****************
+$imageBlock=array("10","3","0","0");
+$pdf->addImage( $logo_name, $imageBlock);
+
+// x,y,width
+if($org_phone != '')
+  $phone ="\n".$app_strings['Phone'].":".$org_phone;
+$companyBlockPositions=array( "10","23","62" );
+$companyText=$org_address."\n".$org_city.", ".$org_state." ".$org_code." ".$org_country." ".$phone."\n".$org_website;
+$pdf->addTextBlock( $org_name, $companyText ,$companyBlockPositions );
+
+// ************** End company information *******************
+
+// title
+/*
+$titleBlock=array("140","7");
+$pdf->title( $app_strings['SalesOrder'],"", $titleBlock );
+*/
+// vtiger_invoice number block
+/////////////////oriz///vert///
+
+
+/*
+$soBubble=
+$pdf->addBubbleBlock($quote_name,$app_strings["Quote Name"], $soBubble);
+
+$poBubble=array("99","17","20");
+$pdf->addBubbleBlock($subject, $app_strings["Subject"], $poBubble);
+
+/*
+// page number
+$pageBubble=array("140","17",0);
+$pdf->addBubbleBlock($page_num, $app_strings["Page"], $pageBubble);
+*/
+// ************* Begin Top-Right Header ***************
+//Modificato da Dolce Stefano
+// title
+$titleBlock=array("120","9");
+
+$pdf->addTextBlock2( "DOCUMENTO DI TRASPORTO","", $titleBlock );
+/*
+$soBubble=array("161","17","20");
+$pdf->addBubbleBlock($quote_name,$app_strings["Quote Name"], $soBubble);
+*/
+
+$issueBlock=array("130","20");
+$pdf->addTextBlock("", "Data: ".getDisplayDate(date("Y-m-d")),$issueBlock);
+
+
+$invBlock=array("130","25","20");
+$pdf->addTextBlock("", "Numero: ".$id,$invBlock);
+
+
+
+
+$testo1="Ordine vendita: ".$subject;
+$poBubble=array("130","30");
+$pdf->addTextBlock("", $testo1, $poBubble);
+
+$testo3="Data Ordine di vendita: ".$valid_till;
+$poBubble=array("130","35");
+$pdf->addTextBlock("", $testo3, $poBubble);
+
+$testo4="Tipologia: ".$tipologia;
+$poBubble=array("130","40");
+$pdf->addTextBlock("", $testo4, $poBubble);
+
+
+$testo2="Causale del trasporto: ".$causale;
+$poBubble=array("130","45","150");
+$pdf->addTextBlock("", $testo2, $poBubble);
+/*
+// page number
+$pageBubble=array("140","17",0);
+$pdf->addBubbleBlock($page_num, $app_strings["Page"], $pageBubble);
+*/
+// ************** End Top-Right Header *****************
+
+
+
+// ************** Begin Addresses **************
+
+// shipping Address(indirizzo di spedizione)
+$shipLocation = array("10","55","61");
+$shipText =$account_name."\n";
+if(trim($ship_street)!='')
+	$shipText .= $ship_street."\n";
+if(trim($ship_city) !='')
+	$shipText .= $ship_city.", ";
+if(trim($ship_state)!='' || trim($ship_code)!= '')
+	$shipText .= $ship_state." ".$ship_code."\n";
+
+	$shipText .=$ship_country;
+
+
+$pdf->addTextBlock( "Destinatario".':', $shipText, $shipLocation );
+/*
+// billing Address(inidirizzo di fatturazione)
+$billPositions = array("10","51","61");
+if(trim($bill_street)!='')
+	$billText = $bill_street."\n";
+if(trim($bill_city) !='')
+	$billText .= $bill_city.", ";
+if(trim($bill_state)!='' || trim($bill_code)!= '')
+	$billText .= $bill_state." ".$bill_code."\n";
+
+	$billText .=$bill_country;
+$pdf->addTextBlock($app_strings["Billing Address"].':',$billText, $billPositions);
+*/
+// ********** End Addresses ******************
+
+
+
+/*  ******** Begin Invoice Data ************************ */ 
+//DATA DI FATTURAZIONE
+// issue date block
+
+/*
+// due date block
+$dueBlock=array("81","52");
+$pdf->addRecBlock($valid_till, $app_strings["Due Date"],$dueBlock);
+*/
+/*
+// terms block
+$termBlock=array("10","55");
+$pdf->addRecBlock("DESTINATARIO  ".$account_name, "", $termBlock);
+*/
+/*
+// Contact Name block
+$conBlock=array("79","67");
+$pdf->addRecBlock($contact_name, $app_strings["Contact Name"],$conBlock);
+*/
+
+
+
+
+/* ************ End Invoice Data ************************ */
+
+
+
+?>
Index: include/tcpdf/templates/body2.php
===================================================================
--- include/tcpdf/templates/body2.php	(revisione 0)
+++ include/tcpdf/templates/body2.php	(revisione 0)
@@ -0,0 +1,82 @@
+<?php
+// watermark based on status
+// this is the postion of the watermark before the rotate
+/*$waterMarkPositions=array("30","180");
+// this is the rotate amount (todo)
+$waterMarkRotate=array("45","50","180");
+$pdf->watermark( $status, $waterMarkPositions, $waterMarkRotate );*/ //Inserisce la scritta di sfondo (es.approved)
+
+include("include/fpdf/pdfconfig.php");
+
+// blow a bubble around the table
+$rect=array("10",$body_top,"170","$bottom");
+$pdf->tableWrapper($rect);
+
+/* ************ 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
+//
+$prodTable=array("10","60");
+//added for value field allignment
+//contains the x angle starting point of the value field
+//$space=array("4"=>"191","5"=>"189","6"=>"187","7"=>"186","8"=>"184","9"=>"182","10"=>"180","11"=>"179","12"=>"177","13"=>"175");
+//if taxtype is individual
+if($focus->column_fields["hdnTaxType"] == "individual")
+{
+	$colsAlign["Product Name"] = "L";
+	//$colsAlign["Description"] = "L";
+	$colsAlign["Qty2"] = "L";
+	//$colsAlign["Price"] = "R";
+	//$colsAlign["Discount"] = "R";
+	//$colsAlign["Tax"] = "R";
+	//$colsAlign["Total"] = "R";
+	$cols["Product Code"] = "90";
+	$cols["Product Name"] = "60";
+	$cols["Qty2"] = "55";
+	//$cols["Price"] = "22";
+	//$cols["Discount"] = "15";
+	//$cols["Tax"] = "20";
+	//	$cols["Total"] = "20";
+}
+else
+{
+	//if taxtype is group
+	$colsAlign["Product Name"] = "L";
+	//$colsAlign["Description"] = "L";
+	$colsAlign["Qty2"] = "R";
+	//$colsAlign["Price"] = "R";
+	//$colsAlign["Discount"] = "R";
+	//$colsAlign["Total"] = "R";
+	$cols["Product Code"] = "75";
+	$cols["Product Name"] = "55";
+	$cols["Qty2"] = "55";
+	//$cols["Price"] = "30";
+	//$cols["Discount"] = "20";
+	//$cols["Total"] = "20";
+}
+
+
+$pdf->addCols( $cols,$prodTable,$bottom);
+$pdf->addLineFormat( $colsAlign);
+
+/* ************** End Table Setup *********************** */
+
+
+
+/* ************* Begin Product Population *************** */
+$ppad=3;
+$y    = $body_top+10;
+
+for($i=0;$i<count($line);$i++)
+{
+	$size = $pdf->addProductLine( $y, $line[$i] );
+	$y   += $size+$ppad;
+}
+
+/* ******************* End product population ********* */
+
+
+
+?>
Index: include/tcpdf/pdf.php
===================================================================
--- include/tcpdf/pdf.php	(revisione 57)
+++ include/tcpdf/pdf.php	(copia locale)
@@ -165,6 +165,18 @@
 	$this->MultiCell( $positions[2], 4, $text);
 }
 
+function addTextBlock2( $title,$text,$positions )
+{
+	$r1  = $positions[0];
+	$y1  = $positions[1];
+	$this->SetXY( $r1, $y1);
+	$this->SetFont( "Helvetica", "B", 15);
+	$this->Cell( $positions[2], 4,$title);
+	$this->SetXY( $r1, $y1+4);
+	$this->SetFont( "Helvetica", "", 10);
+	$this->MultiCell( $positions[2], 4, $text);
+}
+
 function tableWrapper($position)
 {
 	$r1  = $position[0];
Index: include/utils/utils.php
===================================================================
--- include/utils/utils.php	(revisione 57)
+++ include/utils/utils.php	(copia locale)
@@ -882,7 +882,7 @@
 
 	if(is_string($string))
 	{
-		if($action != 'CustomView' && $action != 'Export' && $action != $ajax_action && $action != 'LeadConvertToEntities' && $action != 'CreatePDF' && $action != 'ConvertAsFAQ' && $_REQUEST['module'] != 'Dashboard' && $action != 'CreateSOPDF' && $action != 'SendPDFMail' && (!isset($_REQUEST['submode'])) )
+		if($action != 'CustomView' && $action != 'Export' && $action != $ajax_action && $action != 'LeadConvertToEntities' && $action != 'CreatePDF' && $action != 'ConvertAsFAQ' && $_REQUEST['module'] != 'Dashboard' && $action != 'CreateSOPDF'  && $action != 'CreateSOPDF2' && $action != 'SendPDFMail' && (!isset($_REQUEST['submode'])) )
 		{
 			$doconvert = true;
 		}
Index: include/utils/EditViewUtils.php
===================================================================
--- include/utils/EditViewUtils.php	(revisione 57)
+++ include/utils/EditViewUtils.php	(copia locale)
@@ -1633,7 +1633,7 @@
 		$product_Detail[$i]['hdnProductId'.$i] = $hdnProductId;
 		$product_Detail[$i]['productName'.$i]= from_html($productname);
 		/* Added to fix the issue Product Pop-up name display*/
-		if($_REQUEST['action'] == 'CreateSOPDF' || $_REQUEST['action'] == 'CreatePDF' || $_REQUEST['action'] == 'SendPDFMail')
+		if($_REQUEST['action'] == 'CreateSOPDF'||$_REQUEST['action'] == 'CreateSOPDF2' || $_REQUEST['action'] == 'CreatePDF' || $_REQUEST['action'] == 'SendPDFMail')
 			$product_Detail[$i]['productName'.$i]= htmlspecialchars($product_Detail[$i]['productName'.$i]);
 		$product_Detail[$i]['hdnProductcode'.$i] = $hdnProductcode;
 		$product_Detail[$i]['productDescription'.$i]= from_html($productdescription);

