<?php require "_header.php";
include "Numbers/Words.php"; ?>
<div id="main-report" align="center">

	<?php
	/*echo "<pre>";
   print_r($_SESSION);
   exit;*/
	if ($_SESSION['cCompany_id'] != "" && isset($_SESSION['cCompany_id'])) {
		$customer_id = Escape($_REQUEST["ID"]);


		if ($customer_id == '') {
			?>
			<script language="javascript" type="text/javascript">
				location.href = 'view-csc-customer.php';
			</script>
			<?php
		}
		$height = 300;
		$nw = new Numbers_Words();

		$agencyid = $_SESSION["cCompany_id"];

		$headerflag = $_REQUEST['headerflag'];

		$qry = " SELECT * from csc_customer
			where 1= 1 and 
			
			customer_id = $customer_id ";

		//$ObjagencymasterMgmt = new agencymasterMgmt(); ".$_REQUEST['nro_no']. "
		// echo $qry;
		$rs = dbQuery($qry);

		$count = dbRows($rs);

		$invoice = "UPDATE `csc_customer` SET `invoice_status` = 'Printed' WHERE `csc_customer`.`customer_id` = $customer_id";
		$rs1 = dbQuery($invoice);

		$j = 0;
		$custome_height = 240;
		///extract($row);
		ob_start();

		$i = 0;
		$sno = 1;
		$net_amount = 0;
		if ($count > 0) {
			$row = dbArray($rs);


			?>


			<?php if ($_SESSION['cCompany_id'] == 5) { ?>
				<span style="font-size:26px; font-weight:bold"><u>Aum Imagineering Pvt. Ltd.</u></span><br />
				<span style="font-size:14px;"><br />
					B/A/5, Gold Coin Complex,3rd Floor,<br />
					Jodhapur Cross Road,Satellite,<br />
					Ahmedabad – 380015,Gujarat – India <br />
				</span>
			<?php }


			$qry = "Select * from lms_customersupport,lms_supportexpenses 
                    Where
                        lms_customersupport.support_id=lms_supportexpenses.support_id
                    And
                   lms_customersupport.customer_id='" . $customer_id . "'";

			$finalout = dbQuery($qry);
			$finalrow = dbArray($finalout);

			//echo "ddd";
			?>



			<table width="100%" align="center">
				<tr align="center">
					<?php
					if ($row['gst_no'] != '') {
						?>
						<td style="border:none"><b>TAX INVOICE</b></td>
						<?php
					} else {
						?>
						<td style="border:none"><b>RETAIL INVOICE</b></td>
						<?php
					}
					?>
				</tr>
				<tr>
					<td>
						<table width="100%" class="report">
							<tr>
								<td>
									<table width="100%" class="report">
										<tr>

											<td width="50%" height="20%" style="vertical-align:top;font-size:10px">
												<table width="100%" style="border:none;">
													<tr>
														<td width="10%" style="border:none;"><img
																src="http://auminfosys.com/erp/images/aumlogo.png" />
														</td>
														<td style="border:none;vertical-align:top;font-size:8px">
															<b>AUM Imagineering Private Limited</b><br />
															602-603A, Shapath - 1, Opp Rajpath Club,</br>
															S.G.Highway, Ahmedabad - 380015</br>
															(O)079 40054004</br>
															GSTIN/UIN : 24AAJCA3252C1Z7</br>
															Company's PAN- AAJCA3252C</br>
															State Name : Gujarat. Code : 24</br>
															E-Mail:&nbsp;account@auminfosys.com


														</td>
													</tr>
												</table>
											</td>
											<td width="50%" style="vertical-align:text-top;">
												<table width="100%" class="report" height="60%">
													<tr>
														<td width="50%" height="5%" style="vertical-align:top;font-size:10px">
															Invoice No :<br /><b>
																<?php
																if ($row['gst_no'] != '') {
																	$len = strlen($finalrow['invoice_no']);
																	if ($len == 1) {
																		echo 'AICG/2627/T0000' . $finalrow['invoice_no'];
																	} else if ($len == 2) {
																		echo 'AICG/2627/T000' . $finalrow['invoice_no'];
																	} else if ($len == 3) {
																		echo 'AICG/2627/T00' . $finalrow['invoice_no'];
																	} else if ($len == 4) {
																		echo 'AICG/2627/T0' . $finalrow['invoice_no'];
																	} else if ($len == 5) {
																		echo 'AICG/2627/T' . $finalrow['invoice_no'];
																	}
																} else {

																	$len = strlen($finalrow['invoice_no']);
																	if ($len == 1) {
																		echo 'AICG/2627/R0000' . $finalrow['invoice_no'];
																	} else if ($len == 2) {
																		echo 'AICG/2627/R000' . $finalrow['invoice_no'];
																	} else if ($len == 3) {
																		echo 'AICG/2627/R00' . $finalrow['invoice_no'];
																	} else if ($len == 4) {
																		echo 'AICG/2627/R0' . $finalrow['invoice_no'];
																	} else if ($len == 5) {
																		echo 'AICG/2627/R' . $finalrow['invoice_no'];
																	}
																}
																?>
															</b>
														</td>
														<td width="50%" height="5%" style="vertical-align:top;font-size:10px">
															Dated :<br /> <?php
															$customerinvoice_date = date("d-m-Y", strtotime($finalrow['invoice_date']));
															if ($customerinvoice_date == '31/3/1900')
																echo '-';
															else
																echo $customerinvoice_date;

															?>
														</td>
													</tr>
													<tr>
														<td height="5%" style="vertical-align:top;font-size:10px">Buyer's Order
															No :<br /><b>
																<?php echo $row['order_no']; ?>
															</b></td>
														<td height="5%" style="vertical-align:top;font-size:10px">Mode/Terms of
															Payment<br /><b>&nbsp;</b></td>
													</tr>
													<tr>
														<td style="vertical-align:top;font-size:10px" height="5%">Despatch
															Document No.<br /><?php echo $finalrow['courier_no']; ?></td>
														<td style="vertical-align:top;font-size:10px" height="5%" width="50%">
															Despatched through<br /><?php echo $row['courier_company']; ?>
														</td>
													</tr>
												</table>
											</td>
										</tr>
										<tr>
											<td style="text-align:center;font-size:15px;" colspan="2">
												<b>For Technical/Warranty Support : 079-49068000 Ext. - 1
													AND 079 - 69268000.</b></br><b>E-mail: servico.mantratecapp.com</b>


												<!-- <b>
													तकनीकी सहायता के लिए: 079-49068000 एक्सटेंशन। - 1 और 079 - 69268000.
													सेवा और वारंटी सहायता के लिए: servico.mantratecapp.com
												</b> -->
											</td>
										</tr>

										<tr>
											<td height="100" width="50%" style="vertical-align:top;font-size:10px"><b>Buyer -
													Billing Address</b>
												<br />
												<?php echo "<b>" . $row['estore_name'] . " - " . $row['csc_id'] . "</b><br/>" . $row['vendor_name'] . "<br/>" . $row['address'] . "<br/>" . $row['district'] . ",&nbsp;&nbsp;" . $row['state'] . "</br> GSTIN/UIN : " . $row['gst_no'] . "</br> State Name : " . $row['state'] . "</br> Place of Supply : " . $row['state'];
												?>

											</td>
											<td height="100" width="50%" style="vertical-align:top;font-size:10px"><b>Buyer -
													Shipping Address</b>
												<br />
												<?php echo "<b>" . $row['estore_name'] . " - " . $row['csc_id'] . "</b><br/>" . $row['vendor_name'] . "<br/>" . $row['address1'] . "<br/>" . $row['district'] . ",&nbsp;&nbsp;" . $row['state'] . "</br> GSTIN/UIN : " . $row['gst_no'] . "</br> State Name : " . $row['state'] . "</br> Place of Supply : " . $row['state'] . "</br>Contact No:" . $row['estore_phoneno'];
												?>

											</td>
										</tr>

									</table>
								</td>
							</tr>
							<tr>
								<td width="100%" style="vertical-align:text-top">
									<table class="report" width="100%">
										<tr align="center">
											<td width="5%"><b>SR.</b>
											</td>
											<td width="45%"><b>Description of Goods</b>
											</td>

											<td width="10%"><b>HSN Code</b>
											</td>
											<td width="5%"><b>Quantity</b>
											</td>
											<td width="5%"><b>Rate</b>
											</td>
											<td width="5%"><b>Per</b>
											</td>
											<td width="5%"><b>Disc%</b>
											</td>
											<td width="15%"><b>Amount</b>
											</td>
										</tr>
										<?php
										$qry = "Select * from lms_customersupport,lms_supportexpenses 
                  
                 
                    Where
                        lms_customersupport.support_id=lms_supportexpenses.support_id
                    And
                   lms_customersupport.customer_id='" . $customer_id . "' group by lms_supportexpenses.support_id";

										$finalout = dbQuery($qry);
										while ($finalrow = dbArray($finalout)) {
											//print_r($finalrow); 
								
											?>
											<tr>
												<td style="text-align:center"><?php echo $sno; ?>
												</td>
												<?php
												if ($row['product_name'] == 'Combo (IRIS Scanner and Finger Print) Pack' || $row['product_name'] == 'Combo (IRIS Scanner and Finger Print) 1 Pack' || $row['product_name'] == 'COMBO (IRISScanner and FingerPrint) 1 pcs' || $row['product_name'] == 'COMBO_MFS110_IRIS100V2 1 Pack') {
													?>
													<td><b>Combo (MFS100V54 & MIS100V2)</b>
													</td>

													<td><b>84716050</b>
													</td>
													<td style="text-align:center"><?php echo $row["quantity"]; ?>
													</td>
													<?php
													$gst = round(($row['mrp'] * 100) / 118, 2);

													?>
													<td style="text-align:right"><?php echo round($gst, 2); ?>
													</td>
													<td><b></b>
													</td>
													<td><b></b>
													</td>
													<?php
													$totalamount = $row['quantity'] * $gst;
													?>
													<td style="text-align:right"><?php echo round($totalamount, 2); ?></td>
													<?php

												} else if ($row['product_name'] == 'COMBO_MFS110_IRIS100V2 1 Pack') {
													?>
														<td><b>Combo (MFS110 L1 & MIS100V2)</b>
														</td>

														<td><b>84716050</b>
														</td>
														<td style="text-align:center"><?php echo $row["quantity"]; ?>
														</td>
														<?php
														$gst = round(($row['mrp'] * 100) / 118, 2);

														?>
														<td style="text-align:right"><?php echo round($gst, 2); ?>
														</td>
														<td><b></b>
														</td>
														<td><b></b>
														</td>
														<?php
														$totalamount = $row['quantity'] * $gst;
														?>
														<td style="text-align:right"><?php echo round($totalamount, 2); ?></td>
													<?php

												} else if ($row['product_name'] == 'Finger Print Scanner MFS100V54 1pc' || $row['product_name'] == 'FingerPrint Scanner MFS100V54 1pc') {
													?>
															<td><b>MFS100V54</b>
															</td>

															<td><b>84716050</b>
															</td>
															<td style="text-align:center"><?php echo $row["quantity"]; ?>
															</td>
														<?php
														$gst = round(($row['mrp'] * 100) / 118, 2);

														?>
															<td style="text-align:right"><?php echo round($gst, 2); ?>
															</td>
															<td><b></b>
															</td>
															<td><b></b>
															</td>
														<?php
														$totalamount = $row['quantity'] * $gst;
														?>
															<td style="text-align:right"><?php echo round($totalamount, 2); ?></td>
													<?php

												} else if ($row['product_name'] == 'MFS110 L1 1 pcs') {
													?>
																<td><b>MFS110 L1</b>
																</td>

																<td><b>84716050</b>
																</td>
																<td style="text-align:center"><?php echo $row["quantity"]; ?>
																</td>
														<?php
														$gst = round(($row['mrp'] * 100) / 118, 2);

														?>
																<td style="text-align:right"><?php echo round($gst, 2); ?>
																</td>
																<td><b></b>
																</td>
																<td><b></b>
																</td>
														<?php
														$totalamount = $row['quantity'] * $gst;
														?>
																<td style="text-align:right"><?php echo round($totalamount, 2); ?></td>
													<?php

												} else if ($row['product_name'] == 'IRIS Scanner MIS100V2 1pc' || $row['product_name'] == 'IRIS Scanner MIS 100V2 1 pcs') {
													?>
																	<td><b>MIS100V2</b>
																	</td>

																	<td><b>84716050</b>
																	</td>
																	<td style="text-align:center"><?php echo $row["quantity"]; ?>
																	</td>
														<?php
														$gst = round(($row['mrp'] * 100) / 118, 2);

														?>
																	<td style="text-align:right"><?php echo round($gst, 2); ?>
																	</td>
																	<td><b></b>
																	</td>
																	<td><b></b>
																	</td>
														<?php
														$totalamount = $row['quantity'] * $gst;
														?>
																	<td style="text-align:right"><?php echo round($totalamount, 2); ?></td>
													<?php

												}
												?>
											</tr>

											<?php $sno++;
											$height = $height - 300;
										} ?>
										<!--<tr>
				<td >&nbsp;</td>
				<td >&nbsp;</td>
				<td >&nbsp;</td>
				<td >&nbsp;</td>
				<td style="text-align:right"><?php //echo number_format($totalproduct,2);
						?></td>
			</tr>-->

										<?php

										if ($row['state'] == 'Gujarat') {
											?>
											<tr>
												<td></td>
												<td style="text-align:right">CGST</td>
												<td></td>
												<td></td>
												<td style="text-align:right">9%</td>
												<td></td>
												<td></td>
												<?php $cgst = round((($totalamount * 9) / 100), 2); ?>
												<td style="text-align:right"><?php echo $cgst; ?></td>
											</tr>
											<tr>
												<td></td>
												<td style="text-align:right">SGST</td>

												<td></td>
												<td></td>
												<td style="text-align:right">9%</td>
												<td></td>
												<td></td>
												<?php $sgst = round((($totalamount * 9) / 100), 2); ?>
												<td style="text-align:right"><?php echo $sgst; ?></td>
											</tr>
											<tr>
												<td></td>
												<?php
												if ($row['state'] == 'Gujarat') {
													?>
													<td height="80px">
														<?php
												} else {
													?>
													<td height="100px">
														<?php
												}
												?>
													<table width="100%">
														<tr>
															<td
																style="border-bottom:none; border-right:none;border-top:none;padding-top:10px;">

																<?php if ($row['product_name'] == 'Combo (IRIS Scanner and Finger Print) Pack' || $row['product_name'] == 'Combo (IRIS Scanner and Finger Print) 1 Pack' || $row['product_name'] == 'COMBO (IRISScanner and FingerPrint) 1 pcs') {
																	?>

																	<?php $qry = "Select * from lms_customersupport,lms_supportexpenses 
                  
                 
                    Where
                        lms_customersupport.support_id=lms_supportexpenses.support_id
                    And
                   lms_customersupport.customer_id='" . $customer_id . "'";

																	$finalout = dbQuery($qry);
																	while ($finalrow = dbArray($finalout)) {
																		echo $finalrow['expenses'] . ' Serial No : ' . $finalrow['cost'] . ',';
																	}
																} else {
																	?>
																	Serial No :
																	<?php $qry = "Select * from lms_customersupport,lms_supportexpenses 
                  
                 
                    Where
                        lms_customersupport.support_id=lms_supportexpenses.support_id
                    And
                   lms_customersupport.customer_id='" . $customer_id . "'";
																	$counter = 0;
																	$finalout = dbQuery($qry);
																	while ($finalrow = dbArray($finalout)) {
																		if ($counter % 4 == 0) {
																			echo $finalrow['cost'] . ',</br>';
																		} else {
																			echo $finalrow['cost'] . ',';
																		}
																		$counter++;
																	}
																}
																?>
															</td>
														</tr>
													</table>
												</td>
												<td></td>
												<td></td>
												<td></td>
												<td></td>
												<td></td>
												<td></td>
											</tr>
											<?php
											$grandtotal = round(($cgst + $sgst + $totalamount), 0);
										} else {
											$igst = round(($totalamount * 18) / 100, 2);

											?>
											<tr>
												<td></td>
												<td style="text-align:right">IGST</td>
												<td></td>
												<td></td>
												<td style="text-align:right">18%</td>
												<td></td>
												<td></td>
												<td style="text-align:right"><?php echo $igst; ?></td>
											</tr>
											<tr>
												<td></td>
												<td height="100px">
													<table width="100%">
														<tr>
															<td
																style="border-bottom:none; border-right:none;border-top:none;padding-top:10px;">

																<?php

																if ($row['product_name'] == 'Combo (IRIS Scanner and Finger Print) Pack' || $row['product_name'] == 'Combo (IRIS Scanner and Finger Print) 1 Pack' || $row['product_name'] == 'COMBO (IRISScanner and FingerPrint) 1 pcs') {
																	?>

																	<?php $qry = "Select * from lms_customersupport,lms_supportexpenses 
                  
                 
                    Where
                        lms_customersupport.support_id=lms_supportexpenses.support_id
                    And
                   lms_customersupport.customer_id='" . $customer_id . "'";

																	$finalout = dbQuery($qry);
																	while ($finalrow = dbArray($finalout)) {
																		echo $finalrow['expenses'] . ' Serial No : ' . $finalrow['cost'] . ',';
																	}
																} else {
																	?>
																	Serial No :
																	<?php $qry = "Select * from lms_customersupport,lms_supportexpenses 
                  
                 
                    Where
                        lms_customersupport.support_id=lms_supportexpenses.support_id
                    And
                   lms_customersupport.customer_id='" . $customer_id . "'";
																	$counter = 0;
																	$finalout = dbQuery($qry);
																	while ($finalrow = dbArray($finalout)) {
																		if ($counter % 4 == 0) {
																			echo $finalrow['cost'] . ',</br>';
																		} else {
																			echo $finalrow['cost'] . ',';
																		}
																		$counter++;
																	}
																}
																?>
														</tr>
													</table>
												</td>
												<td></td>
												<td></td>
												<td></td>
												<td></td>
												<td></td>
												<td></td>
											</tr>

											<?php
											$grandtotal = round(($igst + $totalamount), 0);
										}
										$height = $height - 300;
										?>
										<!-- <tr style="height:<?php echo $height . "px" ?>">
				<td>&nbsp;</td>
				<td>&nbsp;</td>
				<td>&nbsp;</td>
				<td>&nbsp;</td>
				<td>&nbsp;</td>
				  <td>&nbsp;</td>
				<td>&nbsp;</td>
				  <td>&nbsp;</td>
				
			</tr> -->






										<tr>
											<td>&nbsp;
											</td>
											<td style="text-align:right">Total&nbsp;
											</td>
											<td>&nbsp;
											</td>
											<td>&nbsp;
											</td>
											<td>&nbsp;
											</td>
											<td>&nbsp;
											</td>
											<td>&nbsp;

											<td style="text-align:right"><b><?php echo round($grandtotal, 2); ?></b>
											</td>
										</tr>
									</table>
								</td>
							</tr>
							<tr>
								<td>
									<table width="100%">
										<tr>
											<td colspan="2" style="border-bottom:none; border-right:none;border-top:none">
												<table width="100%">
													<tr>
														<td align="left" width="90%"
															style="border-bottom:none; border-right:none;border-top:none">Amount
															Chargable (inwords)<br />
															<b><?php echo strtoupper($nw->toWords($grandtotal) . " Rupees Only"); ?></b>
														</td>
														<td align="right" width="10%"
															style="border-bottom:none; border-right:none;border-top:none">E. &
															O. E.
														</td>
													</tr>
												</table>
											</td>
										</tr>
										<tr>
											<td colspan="2">
												<?php if ($row['state'] == 'Gujarat') {
													?>

													<table width="100%">
														<tr>
															<td rowspan="2">HSN/SAC</td>
															<td rowspan="2">Texable Value</td>
															<td colspan="2">Central Tax</td>
															<td colspan="2">State Tax</td>
															<td rowspan="2">Total</td>
														</tr>
														<tr>


															<td>Rate</td>
															<td>Amount</td>
															<td>Rate</td>
															<td>Amount</td>

														</tr>
														<tr>
															<td>84716050</td>

															<td><?php echo $totalamount; ?></td>
															<td>9%</td>
															<td><?php echo $cgst; ?></td>
															<td>9%</td>
															<td><?php echo $sgst; ?></td>
															<td><?php echo round(($cgst + $sgst), 2); ?></td>
														</tr>
													</table>
													<?php
												} else {
													?>

													<table width="100%">
														<tr>
															<td rowspan="2">HSN Code</td>
															<td rowspan="2">Texable Value</td>
															<td colspan="2" style="text-align:center">Integrated Goods and Services
																Tax</td>
															<td rowspan="2">Total</td>
														</tr>
														<tr>


															<td>Rate</td>
															<td>Amount</td>


														</tr>
														<tr>
															<td>84716050</td>

															<td><?php echo $totalamount ?></td>
															<td>18%</td>
															<td><?php echo $igst; ?></td>
															<td><?php echo $igst; ?></td>
														</tr>
													</table>

													<?php
												}
												?>
											</td>
										</tr>

										<!--<tr >
					<td colspan="2" style="border-bottom:none; border-right:none;border-top:none">Remarks:<br/>
					Being Provided To Automation Syatem Erp Ref<br/>
					no:-606
					</td>
				</tr>-->
										<tr>
											<td width="50%" style="border-bottom:none; border-top:none" align="left">
												<u> <b>Terms & Condition:</b> </u>
												<div width="100%" style="vertical-align:top;font-size:10px" align="left">
													01. We declare that this invoice shows the actual price of the goods
													described and that all particulars are true and correct<br>
													02. Verify your "GSTIN" in our invoice after upload GST filing we are not
													revised your GST invoice.<br>
													03. 3 Years Warranty and 5 Years RD Service.Warranty and RD service will be provide by Manufacturer
												</div>
											</td>
											<td align="right" width="50%">
												<table width="100%" height="70">
													<tr>

														<td
															style="text-align:right; border-bottom:none; border-right:none;border-top:none">
															For Aum Imagineering Private Limited</td>
													</tr>
													<tr>
														<td style="border-bottom:none; border-right:none;border-top:none">&nbsp;
														</td>
													</tr>
													<tr>

														<td
															style="text-align:right ;border-bottom:none; border-right:none;border-top:none">
															<img src="http://auminfosys.com/erp/images/AUM Stamp.jpeg" />
															</br>Authorized Signatory</td>
													</tr>
												</table>
											</td>
										</tr>
									</table>
								</td>
							</tr>
						</table>
					</td>
				</tr>
				<tr>
					<td style="text-align:center">
						SUBJECT TO AHMEDABAD JURISDICTION<br />
						This is a Computer Genrated Invoice
					</td>
				</tr>

			</table>
		<?php }


		?>



		<?php
		$HtmlCode = ob_get_contents();
		ob_end_flush();
		$HtmlUrl = "customerbill-report-" . $_SESSION["cUserId"] . ".html";
		$HtmlPath = "report/" . $HtmlUrl;
		createHTMLReportPage($header_row_string, $HtmlUrl, $HtmlPath, $HtmlCode, true);
		?>
		<br />
		<br /><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">
			SetPageAction('PRINT');

			function SetPageAction(varAction) {

				if (varAction == "PRINT") {
					document.frm.action = "print/create-print.php";
					document.frm.submit();
				} else 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 "Session Expired";
	}
	?>

	<?php require "_footer.php"; ?>