<?php

require "_header.php";


$email_ids != "";
$order_no = ($_REQUEST['order_no'] != "") ? $_REQUEST['order_no'] : 0;
$product_name = $_REQUEST['product_hidden'];
$import_date = $_REQUEST['import_date'];
$courier_company = $_REQUEST['courier_hidden'];
$startdate = DateConversion($import_date, "Y-m-d", "d/m/Y");

if ($order_no == 0 ) {
	header("Location: csc-address.php");

}
ob_start(); ?>
<div id="main-report" align="center">



	<?php


	$cond1 = "";
	$cond2 = "";
	$cond = "";
	if ($order_no != "" && $order_no != 0) {
		$cond .= " AND order_no IN( '$order_no' )";
	}
	if ($product_name != "") {
		$cond .= " AND product_name LIKE '%$product_name%'";
	}
	if ($import_date != "") {
		$cond .= " AND import_date ='$startdate'";
	}
	if ($courier_company != "") {
		$cond .= " AND courier_company ='$courier_company'";
	}

	//	$cond .= " AND order_no IN('DZ1642117980','DL1642419485','DB1641525368','DG1641042058','DQ1642310817','DF1641883512')";
	//	$cond .= " AND product_name = 'Combo (IRIS Scanner and Finger Print) Pack'";	
	//	$cond .= " AND invoice_status = 'Pending'";	
	//	$cond .= " AND quantity = '14'";	
	$sql = "SELECT * FROM csc_customer  WHERE 1=1  
					";
	$sql .= $cond;

//  echo $sql;
	
	$result = dbQuery($sql);
	$srno = 1;
	$temp = "";
	$page_break = 1;
	if (dbRows($result) > 0) {
		?>
		<table cellpadding="0" cellspacing="0" align="center" width="100%" style="border: 0px;" style="border: none;">
			<tr>
				<?php
				while ($row = dbArray($result)) {
					$Duplicate = "SELECT Count(*) as Duplicate FROM csc_customer WHERE import_date ='$startdate' AND order_no = '{$row['order_no']}'";
					$run = dbArray(dbQuery($Duplicate));
					$DupliCount = $run['Duplicate'];
					?>
					<td width="40%" style="border: none;">
						<table cellpadding="0" cellspacing="0" width="30%" class="report" style="border: 0px;"
							style="border: none;">
							<?php if ($row['courier_company'] != 'Shree Maruti Courier' and $row['courier_company'] != 'Professional Courier' and $row['courier_company'] != 'Delhivery') {
								?>
								<tr align="left" style="border: 0px;">
									<td style="border: 0px;">
										<div style="height:20px;width:350px;border:solid 2px black;">
											<font size="3"><b>Speed Post - BNPL ID: 3000062737</b></font>
										</div>
									</td>
								</tr>
								<tr align="left" style="border: 0px;    line-height: 12px;">
									<td style="border: 0px;">&nbsp;</td>
								</tr>
								<?php
							}
							?>
							<tr align="left" style="border: 0px;">
								<td style="border: 0px;"><b>
										<font size="3">To/Receiver/प्राप्तकर्ता/લેનાર <?php
										$str = " -";
										 if($row['gst_no'] != ""){
											$str .= "(G)";
										 }
										 if($DupliCount > 1){
											$str .= "(D)";
										 }
										 if($str == " -"){
											$str = "";
										 }
										 echo $str;
										 ?>
										</font>
									</b></td>
							</tr>
							<tr align="left" style="border: 0px;    line-height: 12px;">
								<td style="border: 0px;">&nbsp;</td>
							</tr>
							<tr align="left" style="border: 0px;">
								<td style="border: 0px;"><b>
										<font size="2"><?php echo $row['estore_name']; ?></font>
									</b></td>
							</tr>
							<tr align="left" style="border: 0px;">
								<td style="border: 0px;"><b>
										<font size="2"><?php echo $row['vendor_name']; ?></font>
									</b></td>
							</tr>

							<tr align="left" style="border: 0px;">
								<td style="border: 0px;"><b>
										<font size="2"><?php echo $row['address1'] ?></font>
									</b></td>
							</tr>
							<tr align="left" style="border: 0px;">
								<td style="border: 0px;"><b>
										<font size="2">District - <?php echo $row['district'] ?></font>


									</b></td>
							</tr>
							<tr align="left" style="border: 0px;">
								<td style="border: 0px;"><b>
										<font size="2">State - <?php echo $row['state'] ?></font>
									</b></td>
							</tr>
							<tr align="left" style="border: 0px;">
								<td style="border: 0px;"><b>
										<font size="2">Contact Number -
											<?php echo $row['estore_phoneno'] ?>/<?php echo $row['alternate_number'] ?>
										</font>
									</b></td>
							</tr>
							<tr align="left" style="border: 0px;">
								<td style="border: 0px;"><b>
										<font size="2">Order Id - <?php echo $row['order_no'] ?> -
											<?php echo substr($row['product_name'], 0, 1) . ' - ' . $row['quantity']; ?>
										</font>
									</b></td>
							</tr>
							<?php $orderno = $row['order_no'];
							$barcode = $orderno; ?>
							<tr align="left" style="border: 0px;">
								<td height="20px" style="border: 0px;">
									<?php echo "<img src='$SiteBaseUrl/bc.php?barcode=" . $barcode . "&width=410&height=58' alt='barcode' />"; ?>
								</td>
							</tr>
							<tr style="border: 0px ">
								<td style="border: 0px;padding-top:15px;"><b>
										<font size="3">From/Sender/भेजनार/મોકલનાર</font>
									</b></td>
							</tr>
							<tr align="left" style="border: 0px;    line-height: 12px;">
								<td style="border: 0px;">&nbsp;</td>
							</tr>
							<tr style="border: 0px;">
								<td style="border: 0px;">
									<font size="2">Aum Imagineering Pvt Ltd.</font>
								</td>
							</tr>
							<tr style="border: 0px;">
								<td style="border: 0px;">
									<font size="2">602-603A, Shapth-1, S.G. Highway,</font>
								</td>
							</tr>
							<tr style="border: 0px;">
								<td style="border: 0px;">
									<font size="2">Opp.Rajpath Club, Ahmedabad-380015</font>
								</td>
							</tr>
							<tr style="border: 0px;">
								<td style="border: 0px;">
									<font size="2">State - Gujarat </font>
								</td>
							</tr>
							<tr style="border: 0px;">
								<td style="border: 0px;">
									<font size="2">Phone No - 079-40054004 </font>
								</td>
							</tr>
							<tr style="border: 0px;">
								<td height="20px" style="border: 0px;"></td>
							</tr>
						</table>


						<?php
						if ($page_break % 2 == 0) {
							?>
						</td>

					</tr>
				</table>
				<div style="page-break-after:always;">&nbsp;</div>
				<table cellpadding="0" cellspacing="0" align="center" width="100%" style="border: 0px;">
					<?php
						} else {
							?>
					</td>
					<td width="10%">&nbsp;</td>
					<?php
						}
						$page_break++;

				}

				?>
			</tr>
		</table>

		<?php
		$HtmlCode = ob_get_contents();
		ob_end_flush();
		$HtmlUrl = "detail-list-" . $_SESSION["eUserId"] . ".html";
		$HtmlPath = "report/" . $HtmlUrl;
		createHTMLReportPage($header_row_string, $HtmlUrl, $HtmlPath, $HtmlCode, false); ?>
		<br />
		<form name="frm" id="frm" action="" method="post">
			<input type="hidden" name="txtFile" id="txtFile" value="<?php echo $HtmlUrl; ?>" />
			<input type="button" name="btnPdf" id="btnPdf" value="Print" onClick="SetPageAction('PRINT');" />
			<input type="button" name="btnPdf" id="btnPdf" value="Create PDF" onclick="SetPageAction('PDF');" />
			<input type="button" name="btnHtml" id="btnHtml" value="Create HTML" onClick="SetPageAction('HTML');" />
			<input type="button" name="btnWord" id="btnWord" value="Create WORD" onClick="SetPageAction('WORD');" />
			<input type="button" name="btnExcel" id="btnExcel" value="Create EXCEL" onClick="SetPageAction('Excel');" />
		</form>
		<script language="javascript" type="text/javascript">
			function SetPageAction(varAction) {
				if (varAction == "PRINT") {
					document.frm.action = "print/create-print.php";
					document.frm.target = "_blank";
					document.frm.submit();
				}
				if (varAction == "PDF") {
					document.frm.action = "convertpdf/create-pdf.php";
					document.frm.target = "_blank";
					document.frm.submit();
				}
				else if (varAction == "HTML") {
					document.frm.action = "<?php echo $HtmlPath; ?>";
					document.frm.target = "_blank";
					document.frm.submit();
				}
				else if (varAction == "WORD") {
					document.frm.action = "convertword/create-word.php";
					document.frm.target = "_blank";
					document.frm.submit();
				}
				else if (varAction == "Excel") {
					document.frm.action = "convertword/create-excel.php";
					document.frm.target = "_blank";
					document.frm.submit();
				}
			}
		</script>
		<?php
	} else {
		echo "No Records found.";
	}




	?>
	<br /><br /><br />
</div>
<?php require "_footer.php"; ?>