<?php require "_header.php";
error_reporting(1); ?>
<div id="main-report" align="center">
	<center>
		<h4>Customer Inquiery Report </h4>
	</center>
	<?php
	$customer_idhedden = Escape($_POST["customer_idhedden"]);
	if ($customer_idhedden != "") {
		?>
		<script language="javascript" type="text/javascript">
			location.href = 'report-customer-duepayment.php';
		</script>
		<?php
	} else if ($_SESSION['cCompany_id'] != "" && isset($_SESSION['cCompany_id'])) {
		$header_row_string = "Customer Inquiery  Report ";

		$total = 0;

		ob_start();
		$where = "";
		$hiddendist_code = Escape($_REQUEST["hiddendist_code"]);


		$startdate = Escape($_REQUEST["startdate"]);
		$enddate = Escape($_REQUEST["enddate"]);

		if ($hiddendist_code != "" && $hiddendist_code != "All") {
			$where = " and im.district_id='" . $hiddendist_code . "'";
		}

		$invoicid = "SELECT 	im.*,um.*,pm.* from lms_inquiry as im,lms_usermaster as um,lms_productmaster as pm where im.user_id=um.user_id and pm.product_id=im.product_ids  ";
		$invoicid = $invoicid . $where;


		if ($startdate != "From") {
			$startdate = DateConversion($startdate, "Y-m-d", "d/m/Y");
			$invoicid .= " AND im.appointmentdate >= '$startdate' ";
		}

		if ($enddate != "To") {
			$enddate = DateConversion($enddate, "Y-m-d", "d/m/Y");
			$invoicid .= " AND im.appointmentdate <= '$enddate' ";
		}


		//	$invoicid = $invoicid." order by lci.customerinvoice_no"; // lci.company_id='".$_SESSION['cCompany_id']."' and
		//echo $invoicid;
		$i = 1;
		$finalinvoiceid = dbQuery($invoicid);
		if (dbRows($finalinvoiceid) > 0) { ?>
				<table width="100%" class="report">
					<tr style="background-color:#CCC">
						<th width="3%" style="text-align:center">Sr No</th>
						<th width="20%" style="text-align:center">New Orgenization.</th>
						<th width="25%" style="text-align:center">Old Orgenization</th>
						<th width="25%" style="text-align:center">Product Name</th>
						<th width="6%" style="text-align:center">Contact</th>
						<th width="6%" style="text-align:center">Contact Person</th>

						<th width="8%" style="text-align:center">Inquiery Date</th>
						<th width="8%" style="text-align:center">Appointment Date</th>
						<th width="8%" style="text-align:center">Appointment Time</th>
						<th width="7%" style="text-align:center">User Name</th>
					</tr>
				<?php
				while ($row1 = dbArray($finalinvoiceid)) {
					?>

						<tr>

							<td style="text-align:center"> <?php echo $i++; ?> </td>
							<td style="text-align:center"> <?php echo $row1["inquierorg_name"]; ?> </td>

							<td style="text-align:center"><?php echo $row1["customer_id"]; ?></td>
							<td style="text-align:center"><?php echo $row1["product_name"]; ?></td>
							<td style="text-align:left"><?php echo $row1["inquier_mobileno"]; ?></td>
							<td style="text-align:left"><?php echo $row1["contactperson"]; ?></td>

							<td style="text-align:center"><?php echo date("d-m-Y", strtotime($row1['inquiry_date'])); ?></td>

							<th style="text-align:center"> <?php echo date("d-m-Y", strtotime($row1['appointmentdate'])); ?> </td>
							<td style="text-align:left"><?php echo $row1["appointmenttime"]; ?></td>
							<td style="text-align:left"><?php echo $row1["name"]; ?></td>
						</tr>

					<?php

				}

				?>

				</table>
				<?php

				$HtmlCode = ob_get_contents();
				ob_end_flush();

				$HtmlUrl = "report-form-customer-dueamount" . $_SESSION["cUserId"] . ".html";
				$HtmlPath = "report/" . $HtmlUrl;
				createHTMLReportPage($header_row_string, $HtmlUrl, $HtmlPath, $HtmlCode);

				?>
				<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>
				<br />
				<br />
			<?php
		} else {
			echo "<b>No Data Found </b>";
		}
	} else {
		echo "Session Expired";
	}
	?>
</div>
<?php
require "_footer.php"; ?>