<?php session_start();
include('accesscheck2.php');
require_once('Connections/courier.php'); 
require_once 'functions/functions.php';
mysql_select_db($database_courier, $courier);
$report_types = mysql_query("SELECT * FROM reports WHERE typeofrep='admin'");

$lens_types = mysql_query("SELECT DISTINCT(lens_name) FROM `lens_types` WHERE (parent_name = 'Glass' OR parent_name = 'Plastic')");
$lens_additions = mysql_query("SELECT DISTINCT(lens_name) FROM `lens_types` WHERE (parent_name = 'ADDITIONS')");
$lens_additions_extra = mysql_query("SELECT DISTINCT(lens_name) FROM `lens_types` WHERE (parent_name = 'EXTRA ADDITIONS')");


$lens_sphere = mysql_query("SELECT DISTINCT(od_sphere),os_sphere FROM `optical_examination`");
$lens_cylinder = mysql_query("SELECT DISTINCT(od_cylinder), os_cylinder FROM `optical_examination`");



 ?>
<div class="page-bar">
	<ul class="page-breadcrumb">
		<li>
			<i class="icon-home"></i>
			<a href="index.html">Home</a>
			<i class="fa fa-angle-right"></i>
		</li>
		<li>
			<span>Report Generation</span>
			<i class="fa fa-angle-right"></i>
		</li>
		<li>
			<span>Sales Report</span>
		</li>
	</ul>
	<div class="page-toolbar">
		<div class="btn-group pull-right">
			<button type="button" class="btn btn-fit-height grey-salt dropdown-toggle" data-toggle="dropdown" data-hover="dropdown" data-delay="1000" data-close-others="true"> Actions
				<i class="fa fa-angle-down"></i>
			</button>
			<ul class="dropdown-menu pull-right" role="menu">
				<li onclick="getstep('<?php echo $action; ?>');">
					<a href="#">
						<i class="icon-refresh"></i> Refresh</a>
					</li>
				</ul>
			</div>
		</div>
	</div>

	<div class="row">
		<div class="col-lg-12 col-md-12 col-xs-12 col-sm-12">
			<div class="portlet light ">
				<div class="portlet-title">
					<div class="caption">
						<span class="caption-subject bold uppercase font-dark">GENERAL SALES REPORT</span>
					</div>
				</div>
				<div class="portlet-body form">
					<form role="form" class="form-horizontal">
						<div class="form-body">
							<div class="row">
								<div class="col-lg-12 col-xs-12 col-md-12">
									<div class="col-md-6">
										<div class="form-group">
											<label class="col-md-3 control-label">Start Date</label>
											<div class="col-md-9">
												<input readonly="" required="" id="form_start_date" name="start_date" type="text" class="form-control date_time_picker" placeholder="Start Date">
											</div>
										</div>
										<div class="form-group">
											<label class="col-md-3 control-label">End Date</label>
											<div class="col-md-9">
												<input readonly="" required="" id="form_end_date" name="end_date" type="text" class="form-control date_time_picker" placeholder="End Date">
											</div>
										</div>

										<div class="form-group">
											<label class="col-md-3 control-label">Lens Type</label>
											<div class="col-md-9">
												<select class="form-control" name="lens_type" id="lens_type">
													<option value="">Please Select Lens</option>
													<?php while ($row = mysql_fetch_assoc($lens_types)) { ?>
														<option value="<?php echo $row['lens_name'] ?>"><?php echo $row['lens_name'] ?></option>
												 <?php } ?>
												</select>
											</div>
										</div>

										<div class="form-group">
											<label class="col-md-3 control-label">Lens Additions</label>
											<div class="col-md-9">
											<select class="form-control" name="lens_additions" id="lens_additions">
													<option value="">Select Lens Addition</option>
													<?php while ($row = mysql_fetch_assoc($lens_additions)) { ?>
														<option value="<?php echo $row['lens_name'] ?>"><?php echo $row['lens_name'] ?></option>
												 <?php } ?>
												</select>
											</div>
										</div>

                                        <div class="form-group">
                                            <label class="col-md-3 control-label">Eyes Type</label>
                                            <div class="col-md-9">
                                                <select class="form-control" name="eyes_type" id="eyes_type">
                                                    <option value="all">Both</option>
                                                    <option value="right">Right</option>
                                                    <option value="left">Left</option>

                                                </select>
                                            </div>
                                        </div>

										<div class="form-group" style="display: none">
											<label class="col-md-3 control-label">Extra Additions</label>
											<div class="col-md-9">
												<select class="form-control" name="lens_extra_additions" id="lens_extra_additions">
													<option value="">Select Extra Additions</option>
													<?php while ($row = mysql_fetch_assoc($lens_additions_extra)) { ?>
														<option value="<?php echo $row['lens_name'] ?>"><?php echo $row['lens_name'] ?></option>
												 <?php } ?>
												</select>
											</div>
										</div>

										<div class="form-group" style="display: none;">
											<label class="col-md-3 control-label"></label>
											<div class="col-md-9">
												<div class="row">
													<label class="col-md-2 control-label">Sphere</label>
													<div class="col-md-4">
														<select class="form-control" name="sphere" id="sphere">
													<option value=""></option>
													<?php while ($row = mysql_fetch_assoc($lens_sphere)) { ?>
														<option value="<?php echo $row['od_sphere']."@@".$row['os_sphere'] ?>"><?php echo strtoupper($row['od_sphere'].' '.'&'.' '.$row['os_sphere']) ?></option>
												 <?php } ?>
												</select>
													</div>

													<label class="col-md-2 control-label">Cylinder</label>
													<div class="col-md-4">
														<select class="form-control" name="cylinder" id="cylinder">
													<option value=""></option>
													<?php while ($row = mysql_fetch_assoc($lens_cylinder)) { ?>
														<option value="<?php echo $row['od_cylinder']."@@".$row['os_cylinder'] ?>"><?php echo $row['od_cylinder'].' '.'&'.' '.$row['os_cylinder'] ?></option>
												 <?php } ?>
												</select>
													</div>
												</div>
											</div>
										</div>

									</div>
									<div class="col-md-6">
										<div class="form-group">
											<label class="col-md-3 control-label">Report Type</label>
											<div class="col-md-9">
												<table class="table table-bordered table-striped">
													<tr>
														<td></td>
														<td>Report Name</td>
													</tr>
													<?php
													$i=1;
													while($row = mysql_fetch_assoc($report_types)){ ?>
														<tr>
															<td style="text-align: center;"><input <?php if($row['reportcode'] == 'rpmm'){ ?> onchange="getData('get_payment_status','POSMOMO','#payment_status')" <?php } ?> type="radio" name="report_type" value="<?php echo $row['reportcode'].'@@@'.$row['reportname']; ?>"></td>
															<td><?php echo $row['reportname']; ?></td>
														</tr>
														<?php $i++; } ?>
													</table>
												</div>
											</div>
										</div>

									</div>
								</div>

								<div class="row">
									<div class="col-lg-12 col-xs-12 col-md-12" style="display: none">
										<div class="col-md-6">
											<div class="form-group">
												<label class="col-md-3 control-label">Payment Method</label>
												<div class="col-md-9">
													<select name="payment_method" class="form-control" id="payment_method" onchange="if(this.value=='insurance'||this.value=='company'){ $('#insurance_company_wrapper').show(); getData('get_insurance_company',this.value,'#payment_status');}else{ $('#insurance_company_wrapper').hide(); }">
														<option selected="" value="all"> ALL </option>
														<option value="cash"> CASH </option>
														<option value="insurance"> INSURANCE </option>
														<option value="company"> COMPANY </option>
														<option value="staff"> STAFF </option>
													</select>
												</div>
											</div>
										</div>

										<div id="insurance_company_wrapper" class="col-md-6" style="display:none;">
											<div class="form-group">
												<label class="col-md-3 control-label">Insurance/Company</label>
												<div class="col-md-9">
													<select name="payment_status[]" multiple="multiple" class="form-control" id="payment_status" multiple="" style="height: 150px;">
														<option value="">Please Select Option</option>
													</select>
												</div>
											</div>
										</div>

									</div>
								</div>

							</div>
							<div class="form-actions">
								<div class="row">
									<div class="col-md-offset-3 col-md-9">
										<button type="submit" class="btn green" onclick="printReport('reports/print_admin_report.php');return false;">Print Report <i class="fa fa-print"></i> </button>
										<button type="reset" class="btn default">Reset Selection  <i class="fa fa-refresh"></i> </button>
									</div>
								</div>
							</div>
						</form>
					</div>
				</div>
			</div>
		</div>


