Jump to content

Email report -I have the report but I don't know where to start


kat35601

Recommended Posts

I need to email this report but I don't know where to start

I have included the report code.

<html>
<head>
<title>Customer Load Report</title>
</head>
<body>
<h1>Customer Load Report</h1>

<?php
$custid=$_POST["Cust_ID"];
$connect =odbc_connect("removed");
if(!$connect) {
	exit("Connection Failed: " . $connect);
}

$sql="SELECT m1_DC.dbo.organizationlocations.cmlName
	,m1_DC.dbo.SalesOrders.OMPSHIPPINGMETHODID
	,m1_DC.dbo.SalesOrders.UOMPTRUCKNUMBER
	,m1_DC.dbo.SalesOrders.ompCustomerPO
	,m1_DC.dbo.SalesOrders.UOMPTOTALBOXCOUNT
	,m1_DC.dbo.SalesOrders.UOMPVOLUMETOTAL
	,m1_DC.dbo.organizationlocations.CMLADDRESSLINE1
	,m1_DC.dbo.organizationlocations.CMLADDRESSLINE2
	,m1_DC.dbo.organizationlocations.CMLCITY
	,m1_DC.dbo.organizationlocations.CMLSTATE
	 ,m1_DC.dbo.organizationlocations.CMLPOSTCODE
	,m1_DC.dbo.SalesOrders.OMPREQUESTEDSHIPDATE
	,m1_DC.dbo.SalesOrders.ompSalesOrderID
	,convert(varchar(10),m1_DC.dbo.SalesOrders.ompRequestedShipDate,110) as ShipDate
FROM m1_DC.dbo.SalesOrders
LEFT OUTER JOIN m1_DC.dbo.organizationlocations ON ompshiporganizationid = cmlorganizationid
	AND ompshiplocationid = cmllocationid
WHERE 
	m1_DC.dbo.SalesOrders.ompCustomerOrganizationID='$custid' and (ompOrderDate>=CONVERT(VARCHAR(10),DATEADD(day, -7, getdate()),110) or
	convert(varchar(10),m1_DC.dbo.SalesOrders.ompRequestedShipDate,110) >=getdate())";

	
	

$result =odbc_exec($connect,$sql);
if(!$result){
exit("Error in SQL");
}



$data= '';	

while (odbc_fetch_row($result)) {
		$cmlName=odbc_result($result,"cmlName");
	$ompCustomerPO=odbc_result($result,"ompCustomerPO");
	$UOMPTOTALBOXCOUNT=odbc_result($result,"UOMPTOTALBOXCOUNT");
	$UOMPVOLUMETOTAL=odbc_result($result,"UOMPVOLUMETOTAL");
	$CMLADDRESSLINE1=odbc_result($result,"CMLADDRESSLINE1");
	$CMLADDRESSLINE2=odbc_result($result,"CMLADDRESSLINE2");
	$CMLCITY=odbc_result($result,"CMLCITY");
	$CMLSTATE=odbc_result($result,"CMLSTATE");
	$CMLPOSTCODE=odbc_result($result,"CMLPOSTCODE");
	$ompSalesOrderID=odbc_result($result,"ompSalesOrderID");
	$ompRequestedShipDate=odbc_result($result,"ShipDate");

	





  	$data .=  "<td style='text-align:left' >     $ompCustomerPO</td>";
  	$data .=  "<td style='text-align:left'>     $UOMPTOTALBOXCOUNT</td>";
  	$data .=  "<td style='text-align:left'>	  $UOMPVOLUMETOTAL</td>";
  	$data .=  "<td style='text-align:left'>	  $CMLADDRESSLINE1</td>";
  	$data .=  "<td style='text-align:left'>	  $CMLADDRESSLINE2</td>";
  	$data .=  "<td style='text-align:left'>	  $CMLCITY</td>";
  	$data .=  "<td style='text-align:left'>	  $CMLSTATE</td>";
  	$data .=  "<td style='text-align:left'>	  $CMLPOSTCODE</td>";
  	$data .=  "<td style='text-align:left'>     $ompSalesOrderID</td>";
  		$data .=  "<td style='text-align:left'>    $ompRequestedShipDate</td></tr>";

	}
   echo "<table><tr>";
   echo "<th>PO</th>";
	echo "<th>Box_count</th>";
	echo "<th>Cubes</th>";
	echo "<th>ADDRESSLINE</th>";
	echo "<th>ADDRESS2</th>";
	echo "<th>CITY</th>";
	echo "<th>STATE</th>";
	echo "<th>ZIP</th>";
	echo "<th>Order_ID</th>";
	echo "<th>Ship Date</th></tr>";
	echo $data;
  

odbc_close($connect);
?>
</body>
</html>

If you want a PHP solution, you can look into Phpmailer.

 

Github: https://github.com/PHPMailer/PHPMailer

Sourceforge: http://sourceforge.net/projects/phpmailer/

 

You already have the data in variables. Create a nice formatted test html document with dummy vars. Then fill in that with variable data along with Phpmailer to email it in html format. Phpmailer will also allow you to attach files, in case you want to create your own document and just attach the report with or without fancy formatting. 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.