<?php
require_once("../special/spl.class.Special.php");
require_once('swift/swift_required.php'); 
require_once('../classes/b2b.class.dbConnect.php');
require_once('../classes/b2b.class.dbQuery.php');
require_once('../classes/b2b.class.BusiLogic.php');

$DBName = isset($_SESSION['DBName']) ? $_SESSION['DBName'] : 'b2b_solar_sc';
$objDBConnect	= new DBConnect($DBName);
$objDBQuery		= new DBQuery($objDBConnect);
$classBusiLogic	= new BusiLogic($objDBQuery, $DBName);
$classSpecial	= new SpecialClass($objDBQuery, $DBName, $classBusiLogic);
// create new PDF document
include("PHPPDF/mpdf.php");
$mpdf=new mPDF('','A4',10,'',5,3,10,10,9,9, 'P'); 


$mpdf->useAdobeCJK = true;		// Default setting in config.php
						// You can set this to false if you have defined other CJK fonts

$mpdf->SetAutoFont(AUTOFONT_ALL);	//	AUTOFONT_CJK | AUTOFONT_THAIVIET | AUTOFONT_RTL | AUTOFONT_INDIC	// AUTOFONT_ALL
						// () = default ALL, 0 turns OFF (default initially)

$CustomerCd = $_GET['CustomerCd'];	
$Year = $_GET['Year'];	
$Month = $_GET['Month'];	
$Date = $_GET['Date'];	
$AEDAllotment_Id = $_GET['AEDAllotment_Id'];	
	
$listData = $classBusiLogic->getDealerSubdealerAEDAllocation($CustomerCd, $Year, $Month, $AEDAllotment_Id);


$HeadingRowStyleFirst = '';
$HeadingRowStyleOther = '';
$RowStyleFirst = '';
$RowStyleOther = '';

$HeadingRowStyleFirst = 'Style="font-size: 12px; font-weight: bold;border-bottom:1px solid grey;border-left:1px solid grey;border-right:1px solid grey;"';
$HeadingRowStyleOther = 'Style="font-size: 12px; font-weight: bold;border-bottom:1px solid grey;border-right:1px solid grey;"';

$RowStyleFirst = 'Style="font-size: 10px; font-weight: bold;border-bottom:1px solid grey;border-left:1px solid grey;border-right:1px solid grey;"';
$RowStyleOther = 'Style="font-size: 10px; font-weight: bold;border-bottom:1px solid grey;border-right:1px solid grey;"';

$html_str .='<table border="0" width="700px" cellspacing="0" cellpadding="0" align="center">
				  <tr>
					<td class="pageHeading" align="center" style="background-color:#B1E0E0;width:100%;font-size:18px;font:weight:bold;">Total AED  Planning </td>
				  </tr>
				  <tr>
					<td align="right"><b>Date & Time : '. date('d-m-Y H:i:s') .'</b></td>
				  </tr>
				  <tr>
					<td valign="top" width="70%">
						<table style="border:1px solid black;" width="1000px" cellspacing="0" cellpadding="0">
							<tr style="background-color: #AFAFAF;">
								<td '.$HeadingRowStyleFirst.' align="center" rowspan="2" width="30px">S No.</td>
								<td '.$HeadingRowStyleFirst.' align="center" rowspan="2" width="270px">Dealer Name</td>
								<td '.$HeadingRowStyleOther.' align="center" colspan="4" width="280px">Supreme AED</td>
								<td '.$HeadingRowStyleOther.' align="center" colspan="3" width="210px">Solar AED</td>
								<td '.$HeadingRowStyleOther.' align="center" colspan="3" width="210px">Total AED</td>
								</tr>
							<tr style="background-color: #AFAFAF;">
								<td '.$HeadingRowStyleOther.' align="center" width="70px">AED 1.5</td>
								<td '.$HeadingRowStyleOther.' align="center" width="70px">AED 1.5 US</td>
								<td '.$HeadingRowStyleOther.' align="center" width="70px">AED 1.8</td>
								<td '.$HeadingRowStyleOther.' align="center" width="70px">AED 3.0</td>
								<td '.$HeadingRowStyleOther.' align="center" width="70px">AED 1.5</td>
								<td '.$HeadingRowStyleOther.' align="center" width="70px">AED 1.8</td>
								<td '.$HeadingRowStyleOther.' align="center" width="70px">AED 3.0</td>
								<td '.$HeadingRowStyleOther.' align="center" width="70px">AED 1.5</td>
								<td '.$HeadingRowStyleOther.' align="center" width="70px">AED 1.8</td>
								<td '.$HeadingRowStyleOther.' align="center" width="70px">AED 3.0</td>
							
							</tr>';
							$rowcnt = 0;
							$Dsrno = 1;
								$CustomerCd 					=	$listData[0]['CustomerCd'];	
								$Dealer_Name	 				=	$listData[0]['Dealer_Name'];	
								$Customer_SupremeAED15_Date		= 	$classBusiLogic->convertDate($listData[0]['Customer_SupremeAED15_Date'], False, 1);	
								$Customer_SupremeAED15_Qty 		= 	($listData[0]['Customer_SupremeAED15_Qty']) ? $listData[0]['Customer_SupremeAED15_Qty'] : "" ;	
								$Customer_SupremeAED15US_Date	= 	$classBusiLogic->convertDate($listData[0]['Customer_SupremeAED15US_Date'], False, 1);	
								$Customer_SupremeAED15US_Qty 	= 	($listData[0]['Customer_SupremeAED15US_Qty']) ? $listData[0]['Customer_SupremeAED15US_Qty'] : "" ;
								$Customer_SupremeAED18_Date		= 	$classBusiLogic->convertDate($listData[0]['Customer_SupremeAED18_Date'], False, 1);	
								$Customer_SupremeAED18_Qty 		= 	($listData[0]['Customer_SupremeAED18_Qty']) ? $listData[0]['Customer_SupremeAED18_Qty'] : "" ;
								$Customer_SupremeAED30_Date		= 	$classBusiLogic->convertDate($listData[0]['Customer_SupremeAED30_Date'], False, 1);	
								$Customer_SupremeAED30_Qty 		= 	($listData[0]['Customer_SupremeAED30_Qty'])? $listData[0]['Customer_SupremeAED30_Qty'] : "" ;
								$Customer_SolarAED15_Date 		=  	$classBusiLogic->convertDate($listData[0]['Customer_SolarAED15_Date'], False, 1);
								$Customer_SolarAED15_Qty	 	= 	($listData[0]['Customer_SolarAED15_Qty']) ? $listData[0]['Customer_SolarAED15_Qty'] : "" ;
								$Customer_SolarAED18_Date	 	=  	$classBusiLogic->convertDate($listData[0]['Customer_SolarAED18_Date'], False, 1);
								$Customer_SolarAED18_Qty	 	= 	($listData[0]['Customer_SolarAED18_Qty']) ? $listData[0]['Customer_SolarAED18_Qty'] : "" ;
								$Customer_SolarAED30_Date	 	=  	$classBusiLogic->convertDate($listData[0]['Customer_SolarAED30_Date'], False, 1);
								$Customer_SolarAED30_Qty	 	= 	($listData[0]['Customer_SolarAED30_Qty']) ? $listData[0]['Customer_SolarAED30_Qty'] : "" ;
						
								$Customer_SupremeAED15_ReserveQty_Open	 	= 	($listData[0]['Customer_SupremeAED15_ReserveQty_Open']) ? $listData[0]['Customer_SupremeAED15_ReserveQty_Open'] : "" ;
								$Customer_SupremeAED15US_ReserveQty_Open	= 	($listData[0]['Customer_SupremeAED15US_ReserveQty_Open']) ? $listData[0]['Customer_SupremeAED15US_ReserveQty_Open'] : "" ;
								$Customer_SupremeAED18_ReserveQty_Open	 	= 	($listData[0]['Customer_SupremeAED18_ReserveQty_Open']) ? $listData[0]['Customer_SupremeAED18_ReserveQty_Open'] : "" ;
								$Customer_SupremeAED30_ReserveQty_Open	 	= 	($listData[0]['Customer_SupremeAED30_ReserveQty_Open']) ? $listData[0]['Customer_SupremeAED30_ReserveQty_Open'] : "" ;
								$Customer_SolarAED15_ReserveQty_Open	 	= 	($listData[0]['Customer_SolarAED15_ReserveQty_Open']) ? $listData[0]['Customer_SolarAED15_ReserveQty_Open'] : "" ;
								$Customer_SolarAED18_ReserveQty_Open	 	= 	($listData[0]['Customer_SolarAED18_ReserveQty_Open']) ? $listData[0]['Customer_SolarAED18_ReserveQty_Open'] : "" ;
								$Customer_SolarAED30_ReserveQty_Open	 	= 	($listData[0]['Customer_SolarAED30_ReserveQty_Open']) ? $listData[0]['Customer_SolarAED30_ReserveQty_Open'] : "" ;
						
								
								$totalAED15	=	($Customer_SupremeAED15_Qty + $Customer_SupremeAED15US_Qty + $Customer_SolarAED15_Qty) ? ($Customer_SupremeAED15_Qty + $Customer_SupremeAED15US_Qty + $Customer_SolarAED15_Qty) : '';
								$totalAED18	=	($Customer_SupremeAED18_Qty + $Customer_SolarAED18_Qty) ? ($Customer_SupremeAED18_Qty + $Customer_SolarAED18_Qty) : '';
								$totalAED30 =	($Customer_SupremeAED30_Qty + $Customer_SolarAED30_Qty) ? ($Customer_SupremeAED30_Qty + $Customer_SolarAED30_Qty) : '';

						$html_str .= '<tr>
									<td '.$RowStyleFirst.' width="30px">'.$Dsrno.'</td>
									<td '.$RowStyleOther.' width="270px">'.strtoupper($Dealer_Name).'</td>
									<td '.$RowStyleOther.' width="70px" align="center">'.$Customer_SupremeAED15_Qty.'</td>
									<td '.$RowStyleOther.' width="70px" align="center">'.$Customer_SupremeAED15US_Qty.'</td>
									<td '.$RowStyleOther.' width="70px" align="center">'.$Customer_SupremeAED18_Qty.'</td>
									<td '.$RowStyleOther.' width="70px" align="center">'.$Customer_SupremeAED30_Qty.'</td>
									<td '.$RowStyleOther.' width="70px" align="center">'.$Customer_SolarAED15_Qty.'</td>
									<td '.$RowStyleOther.' width="70px" align="center">'.$Customer_SolarAED18_Qty.'</td>
									<td '.$RowStyleOther.' width="70px" align="center">'.$Customer_SolarAED30_Qty.'</td>
									<td '.$RowStyleOther.' width="70px" align="center">'.($totalAED15).'</td>
									<td '.$RowStyleOther.' width="70px" align="center">'.($totalAED18).'</td>
									<td '.$RowStyleOther.' width="70px" align="center">'.($totalAED30).'</td>
									
									
							</tr>';
						$html_str .= '<tr>
									<td '.$RowStyleFirst.' width="30px"></td>
									<td '.$RowStyleOther.' align="center" width="270px">Reserve Stock</td>
									<td '.$RowStyleOther.' width="70px" align="center">'.$Customer_SupremeAED15_ReserveQty_Open.'</td>
									<td '.$RowStyleOther.' width="70px" align="center">'.$Customer_SupremeAED15US_ReserveQty_Open.'</td>
									<td '.$RowStyleOther.' width="70px" align="center">'.$Customer_SupremeAED18_ReserveQty_Open.'</td>
									<td '.$RowStyleOther.' width="70px" align="center">'.$Customer_SupremeAED30_ReserveQty_Open.'</td>
									<td '.$RowStyleOther.' width="70px" align="center">'.$Customer_SolarAED15_ReserveQty_Open.'</td>
									<td '.$RowStyleOther.' width="70px" align="center">'.$Customer_SolarAED18_ReserveQty_Open.'</td>
									<td '.$RowStyleOther.' width="70px" align="center">'.$Customer_SolarAED30_ReserveQty_Open.'</td>
									<td '.$RowStyleOther.' ></td> <td '.$RowStyleOther.' ></td> <td '.$RowStyleOther.' ></td>
							</tr>';
								$total_Cus_SupremeAED15_Qty = $Customer_SupremeAED15_Qty + $Customer_SupremeAED15_ReserveQty_Open;
								$total_Cus_SupremeAED15US_Qty = $Customer_SupremeAED15US_Qty + $Customer_SupremeAED15US_ReserveQty_Open;
								$total_Cus_SupremeAED18_Qty = $Customer_SupremeAED18_Qty + $Customer_SupremeAED18_ReserveQty_Open;
								$total_Cus_SupremeAED30_Qty = $Customer_SupremeAED30_Qty + $Customer_SupremeAED30_ReserveQty_Open;
								$total_Cus_SolarAED15_Qty = $Customer_SolarAED15_Qty + $Customer_SolarAED15_ReserveQty_Open;
								$total_Cus_SolarAED18_Qty = $Customer_SolarAED18_Qty + $Customer_SolarAED18_ReserveQty_Open;
								$total_Cus_SolarAED30_Qty = $Customer_SolarAED30_Qty + $Customer_SolarAED30_ReserveQty_Open;
						$html_str .= '<tr>
									<td '.$RowStyleFirst.' width="30px"></td>
									<td '.$RowStyleOther.' align="center" width="270px">Total Stock</td>
									<td '.$RowStyleOther.' width="70px" align="center">'.($Customer_SupremeAED15_Qty + $Customer_SupremeAED15_ReserveQty_Open).'</td>
									<td '.$RowStyleOther.' width="70px" align="center">'.($Customer_SupremeAED15US_Qty + $Customer_SupremeAED15US_ReserveQty_Open).'</td>
									<td '.$RowStyleOther.' width="70px" align="center">'.($Customer_SupremeAED18_Qty + $Customer_SupremeAED18_ReserveQty_Open).'</td>
									<td '.$RowStyleOther.' width="70px" align="center">'.($Customer_SupremeAED30_Qty + $Customer_SupremeAED30_ReserveQty_Open).'</td>
									<td '.$RowStyleOther.' width="70px" align="center">'.($Customer_SolarAED15_Qty + $Customer_SolarAED15_ReserveQty_Open).'</td>
									<td '.$RowStyleOther.' width="70px" align="center">'.($Customer_SolarAED15_Qty + $Customer_SolarAED18_ReserveQty_Open).'</td>
									<td '.$RowStyleOther.' width="70px" align="center">'.($Customer_SolarAED15_Qty + $Customer_SolarAED30_ReserveQty_Open).'</td>
									<td '.$RowStyleOther.' ></td> <td '.$RowStyleOther.' ></td> <td '.$RowStyleOther.' ></td>
								</tr>';
								
								$Dsrno++;
							
						$html_str .= '</table>
					</td>
				</tr>
			</table><br/>';	

$html_str .='<table border="0" width="700px" cellspacing="0" cellpadding="0" align="center">
				  <tr>
					<td class="pageHeading" align="center" style="background-color:#B1E0E0;width:100%;font-size:18px;font:weight:bold;">Subdealers AED Planning</td>
				  </tr>
				  <tr>
					<td valign="top" width="70%">
						<table style="border:1px solid black;" width="1000px" cellspacing="0" cellpadding="0">
							<tr style="background-color: #AFAFAF;">
								<td '.$HeadingRowStyleFirst.' align="center" rowspan="2" width="30px">S No.</td>
								<td '.$HeadingRowStyleFirst.' align="center" rowspan="2" width="270px">Subdealer Name</td>
								<td '.$HeadingRowStyleOther.' align="center" colspan="4" width="400px">Supreme AED</td>
								<td '.$HeadingRowStyleOther.' align="center" colspan="3" width="300px">Solar AED</td>
								</tr>
							<tr style="background-color: #AFAFAF;">
								<td '.$HeadingRowStyleOther.' align="center" width="100px">AED 1.5</td>
								<td '.$HeadingRowStyleOther.' align="center" width="100px">AED 1.5 US</td>
								<td '.$HeadingRowStyleOther.' align="center" width="100px">AED 1.8</td>
								<td '.$HeadingRowStyleOther.' align="center" width="100px">AED 3.0</td>
								<td '.$HeadingRowStyleOther.' align="center" width="100px">AED 1.5</td>
								<td '.$HeadingRowStyleOther.' align="center" width="100px">AED 1.8</td>
								<td '.$HeadingRowStyleOther.' align="center" width="100px">AED 3.0</td>
								
							</tr>';
							$rowcnt = 0;
							$srno = 1;
							$total_supremeAED15= 0;
							$total_supremeAED15US= 0;
							$total_supremeAED18= 0;
							$total_supremeAED30= 0;
							$total_solarAED15= 0;
							$total_solarAED18= 0;
							$total_solarAED30= 0;
							
							foreach($listData as $curRow){
								$SubdealerCd 				=	$curRow['SubdealerCd'];	
								$Subdealer_Name 			=	$curRow['subdealer_Name'];	
								$Subdealer_SupremeAED15_Date	= 	$classBusiLogic->convertDate($curRow['Subdealer_SupremeAED15_Date'], False, 1);	
								$Subdealer_SupremeAED15_Qty 	= 	($curRow['Subdealer_SupremeAED15_Qty']) ? $curRow['Subdealer_SupremeAED15_Qty'] : "";	
								$Subdealer_SupremeAED15US_Date	= 	$classBusiLogic->convertDate($curRow['Subdealer_SupremeAED15US_Date'], False, 1);	
								$Subdealer_SupremeAED15US_Qty 	= 	($curRow['Subdealer_SupremeAED15US_Qty'] ) ? $curRow['Subdealer_SupremeAED15US_Qty'] : "";	
								$Subdealer_SupremeAED18_Date	= 	$classBusiLogic->convertDate($curRow['Subdealer_SupremeAED18_Date'], False, 1);	
								$Subdealer_SupremeAED18_Qty 	= 	($curRow['Subdealer_SupremeAED18_Qty']) ? $curRow['Subdealer_SupremeAED18_Qty'] : "";	
								$Subdealer_SupremeAED30_Date	= 	$classBusiLogic->convertDate($curRow['Subdealer_SupremeAED30_Date'], False, 1);	
								$Subdealer_SupremeAED30_Qty 	= 	($curRow['Subdealer_SupremeAED30_Qty']) ? $curRow['Subdealer_SupremeAED30_Qty'] : "";	
								$Subdealer_SolarAED15_Date 	=  	$classBusiLogic->convertDate($curRow['Subdealer_SolarAED15_Date'], False, 1);
								$Subdealer_SolarAED15_Qty	 	= 	($curRow['Subdealer_SolarAED15_Qty'] ) ? $curRow['Subdealer_SolarAED15_Qty'] : "";	
						 	 	$Subdealer_SolarAED18_Date 	=  	$classBusiLogic->convertDate($curRow['Subdealer_SolarAED18_Date'], False, 1);
								$Subdealer_SolarAED18_Qty	 	= 	($curRow['Subdealer_SolarAED18_Qty'] ) ?  $curRow['Subdealer_SolarAED18_Qty'] : "" ;	
						 	 	$Subdealer_SolarAED30_Date 	=  	$classBusiLogic->convertDate($curRow['Subdealer_SolarAED30_Date'], False, 1);
								$Subdealer_SolarAED30_Qty	 	= ($curRow['Subdealer_SolarAED30_Qty'] ) ? $curRow['Subdealer_SolarAED30_Qty'] : "";	
						 	 	
								$Subdealer_MobileNo = $curRow['SubdealerMobileNo'];
								
							$return1 = $classBusiLogic->SMSAlertSubdealerSupremeAEDAllocation($Dealer_Name, $Subdealer_Name, $Subdealer_SupremeAED15_Date,
							$Subdealer_SupremeAED15_Qty, $Subdealer_SupremeAED15US_Date, $Subdealer_SupremeAED15US_Qty, $Subdealer_SupremeAED18_Date
							, $Subdealer_SupremeAED18_Qty, $Subdealer_SupremeAED30_Date, $Subdealer_SupremeAED30_Qty, $Subdealer_MobileNo);
							
							$return2 = $classBusiLogic->SMSAlertSubdealerSolarAEDAllocation($Dealer_Name, $Subdealer_Name, $Subdealer_SolarAED15_Date, $Subdealer_SolarAED15_Qty
							, $Subdealer_SolarAED18_Date, $Subdealer_SolarAED18_Qty, $Subdealer_SolarAED30_Date, $Subdealer_SolarAED30_Qty, $Subdealer_MobileNo);
								
								
							$html_str .= '<tr align="right">
									<td '.$RowStyleFirst.' width="30px"  align="center">'.$srno.'</td>
									<td '.$RowStyleOther.' width="270px" align="left">'.strtoupper($Subdealer_Name).'</td>
									<td '.$RowStyleOther.' width="50px" >'.$Subdealer_SupremeAED15_Qty .'</td>
									<td '.$RowStyleOther.' width="50px" >'.$Subdealer_SupremeAED15US_Qty.'</td>
									<td '.$RowStyleOther.' width="60px" >'.$Subdealer_SupremeAED18_Qty.'</td>
									<td '.$RowStyleOther.' width="60px" >'.$Subdealer_SupremeAED30_Qty.'</td>
									<td '.$RowStyleOther.' width="60px" >'.$Subdealer_SolarAED15_Qty.'</td>
									<td '.$RowStyleOther.' width="50px" >'.$Subdealer_SolarAED18_Qty.'</td>
									<td '.$RowStyleOther.' width="50px" >'.$Subdealer_SolarAED30_Qty.'</td>
								</tr>';
								$srno++;
								$total_supremeAED15		= ($total_supremeAED15+$Subdealer_SupremeAED15_Qty) ? $total_supremeAED15+$Subdealer_SupremeAED15_Qty : "";
								$total_supremeAED15US	= ($total_supremeAED15US+$Subdealer_SupremeAED15US_Qty) ? $total_supremeAED15US+$Subdealer_SupremeAED15US_Qty : "";
								$total_supremeAED18		= ($total_supremeAED18+$Subdealer_SupremeAED18_Qty) ? $total_supremeAED18+$Subdealer_SupremeAED18_Qty : "";
								$total_supremeAED30		= ($total_supremeAED30+$Subdealer_SupremeAED30_Qty) ? $total_supremeAED30+$Subdealer_SupremeAED30_Qty : "";
								$total_solarAED15		= ($total_solarAED15+$Subdealer_SolarAED15_Qty) ? $total_solarAED15+$Subdealer_SolarAED15_Qty : "";
								$total_solarAED18		= ($total_solarAED18+$Subdealer_SolarAED18_Qty) ? $total_solarAED18+$Subdealer_SolarAED18_Qty : "";
								$total_solarAED30		= ($total_solarAED30+$Subdealer_SolarAED30_Qty) ? $total_solarAED30+$Subdealer_SolarAED30_Qty : "";
							}
							$html_str .= '<tr  align="right" style="background-color:#ffccff;">
									<td '.$RowStyleFirst.' width="40px"></td>
									<td '.$RowStyleOther.' align="center" width="300px">Total</td>
									<td '.$RowStyleOther.' width="100px" >'.$total_supremeAED15.'</td>
									<td '.$RowStyleOther.' width="100px" >'.$total_supremeAED15US.'</td>
									<td '.$RowStyleOther.' width="100px" >'.$total_supremeAED18.'</td>
									<td '.$RowStyleOther.' width="100px" >'.$total_supremeAED30.'</td>
									<td '.$RowStyleOther.' width="100px" >'.$total_solarAED15.'</td>
									<td '.$RowStyleOther.' width="100px" >'.$total_solarAED18.'</td>
									<td '.$RowStyleOther.' width="100px" >'.$total_solarAED30.'</td>
								</tr>';
									/*$remainSupremeAED15 = ($Customer_SupremeAED15_Qty-$total_supremeAED15)? ($Customer_SupremeAED15_Qty-$total_supremeAED15): "";
									$remainSupremeAED15US = ($Customer_SupremeAED15US_Qty-$total_supremeAED15US)? ($Customer_SupremeAED15US_Qty-$total_supremeAED15US) : "";
									$remainSupremeAED18 = ($Customer_SupremeAED18_Qty-$total_supremeAED18) ? ($Customer_SupremeAED18_Qty-$total_supremeAED18) : "";
									$remainSupremeAED30 = ($Customer_SupremeAED30_Qty-$total_supremeAED30) ? ($Customer_SupremeAED30_Qty-$total_supremeAED30) : "";
									$remainSolarAED15 = ($Customer_SolarAED15_Qty-$total_solarAED15) ? ($Customer_SolarAED15_Qty-$total_solarAED15) : "";
									$remainSolarAED18 = ($Customer_SolarAED18_Qty-$total_solarAED18) ? ($Customer_SolarAED18_Qty-$total_solarAED18) : "";
									$remainSolarAED30 = ($Customer_SolarAED30_Qty-$total_solarAED30) ? ($Customer_SolarAED30_Qty-$total_solarAED30) : "";
									*/
									
									$remainSupremeAED15 = ($total_Cus_SupremeAED15_Qty-$total_supremeAED15)? ($total_Cus_SupremeAED15_Qty-$total_supremeAED15): "";
									$remainSupremeAED15US = ($total_Cus_SupremeAED15US_Qty-$total_supremeAED15US)? ($total_Cus_SupremeAED15US_Qty-$total_supremeAED15US) : "";
									$remainSupremeAED18 = ($total_Cus_SupremeAED18_Qty-$total_supremeAED18) ? ($total_Cus_SupremeAED18_Qty-$total_supremeAED18) : "";
									$remainSupremeAED30 = ($total_Cus_SupremeAED30_Qty-$total_supremeAED30) ? ($total_Cus_SupremeAED30_Qty-$total_supremeAED30) : "";
									$remainSolarAED15 = ($total_Cus_SolarAED15_Qty-$total_solarAED15) ? ($total_Cus_SolarAED15_Qty-$total_solarAED15) : "";
									$remainSolarAED18 = ($total_Cus_SolarAED18_Qty-$total_solarAED18) ? ($total_Cus_SolarAED18_Qty-$total_solarAED18) : "";
									$remainSolarAED30 = ($total_Cus_SolarAED30_Qty-$total_solarAED30) ? ($total_Cus_SolarAED30_Qty-$total_solarAED30) : "";
									
							$html_str .= '<tr  align="right" style="background-color:#ffccff;">
									<td '.$RowStyleFirst.' width="40px"></td>
									<td '.$RowStyleOther.' align="center" width="300px">Reserve Stock</td>
									<td '.$RowStyleOther.' width="100px" >'.($remainSupremeAED15) .'</td>
									<td '.$RowStyleOther.' width="100px" >'.($remainSupremeAED15US).'</td>
									<td '.$RowStyleOther.' width="100px" >'.($remainSupremeAED18).'</td>
									<td '.$RowStyleOther.' width="100px" >'.($remainSupremeAED30).'</td>
									<td '.$RowStyleOther.' width="100px" >'.($remainSolarAED15).'</td>
									<td '.$RowStyleOther.' width="100px" >'.($remainSolarAED18).'</td>
									<td '.$RowStyleOther.' width="100px" >'.($remainSolarAED30).'</td>
								</tr>';	
							
						$html_str .= '</table>
					</td>
				</tr>
			</table>';	
		//if(count($listData)==0){	
		//$html_str .= '<table id="tblHeading" width="100%" cellspacing="0" cellpadding="6" border="0"><tr><td><b>No phone record exist!!!!</b></td></tr></table>';
	//	}
		$mpdf->AddPages('P');
		$mpdf->setHTMLFooter('<div align="center"><b>{PAGENO} / {nbpg}</b></div>') ;
		$mpdf->setHTMLFooter('<div align="center"><b><i>{PAGENO} / {nbpg}</i></b></div>','E') ;
		$mpdf->WriteHTML($html_str);
//print_r($listData);
$filename = "Dealer_Subdealer_AED_Planning ";
$Date = date('d-m-Y');
$filename = $filename.$Date.'.pdf';

$EmailIdarr = Explode(';', $listData[0]['CustomerEmailId']);
	$EmailId='';
foreach($EmailIdarr as $email){
	$EmailId .=$email;
}

$EmailId = rtrim($EmailId, ',');

//echo $EmailId;
//->setTo(array('rahul@solargroup.com', 'r.somani@solargroup.com'))

//echo $html_str;

$content = $mpdf->Output("", "S");

$html_message = '<p>Dear '.$Dealer_Name.', <br><br>Based on the allocation update provided by you to our Subdealer Representative please find attached reference data sheet.
				<br>
				<br><br>Thank You<br>Customer Service Department';
$mailer = new Swift_Mailer(new Swift_MailTransport()); // Create new instance of SwiftMailer  
$message = Swift_Message::newInstance()  
			->setSubject('AED Planning '.$Date) // Message subject  
			//->setTo(array( 'websupport@solargroup.com')) // Array of people to send to 
			->setTo(array("$EmailId")) // Array of people to send to 
			->setBcc(array('solartrade@solargroup.com', 'tsm3@solargroup.com')) // Array of people to send to 
			->setFrom(array('infob2b@solargroup.com' => 'InfoB2B@SolarExplosives')) // From:  
			->setBody($html_message, 'text/html') // Attach that HTML message from earlier  
			->attach(Swift_Attachment::newInstance($content, $filename, 'application/pdf')); // Attach the generated PDF from earlier  
  
// Send the email, and show user message  
if ($mailer->send($message))  {
	echo "<script type='text/javascript'> alert('Mail Sent Successfully!!!!'); 	window.location.href='../index.php?action=viewDealerSubdealerAEDAllocation' ; </script>";
//	echo "<script type='text/javascript'> alert('Mail Sent Successfully!!!!'); 	 </script>";
}else  {
	echo "<script type='text/javascript'> alert('Mail Not Sent Please Check the Connection!!!!'); window.location.href='../index.php?action=viewDealerSubdealerAEDAllocation' ;  </script>";
}
//$content = $mpdf->Output("", "S");

//============================================================+
// END OF FILE
//============================================================+
?>
