<?php session_start();
include('accesscheck2.php');
require_once('Connections/courier.php'); 
require_once 'functions/functions.php';

mysql_select_db($database_courier, $courier);

//PAYMENT OPTION
$payment_mode = mysql_query("SELECT DISTINCT pay_by FROM cashier_payments");
if($_SESSION['security'] == 'MEDICAL OFFICER'){
    $report_types = mysql_query("SELECT * FROM reports WHERE typeofrep='salesreport' AND reportcode='clov' reportorder asc");
}else{
    $report_types = mysql_query("SELECT * FROM reports WHERE typeofrep='salesreport' order by reportorder asc");   
}

?>
<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">SALES REPORT GENERATION</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>
                                <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>
                       
                       <?php if($_SESSION['security'] !='MEDICAL OFFICER'){ ?>
                        <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">Payment Method</label>
                                        <div class="col-md-9">
                                            <select name="payment_method[]" class="form-control" id="payment_method" multiple="" style="height: 150px;" onchange="getData('get_payment_status',this.value,'#payment_status')">
                                                <option selected="" value="cash"> CASH </option>
                                                <option value="gratis"> GRATIS </option>
                                                <option value="credit sales"> CREDIT SALES </option>
                                                <option value="insurance"> INSURANCE </option>
                                                <option value="company"> COMPANY </option>
                                            </select>
                                        </div>
                                    </div>
                                </div>
                                
                                 <div class="col-md-6">
                                    <div class="form-group">
                                        <label class="col-md-3 control-label">Payment Status</label>
                                        <div class="col-md-9">
                                            <select name="payment_status[]" class="form-control" id="payment_status" multiple="multiple" style="height: 150px;">
                                                <option value="Paid"> Paid </option>
                                                <option value="Owing"> Owing </option>
                                                <?php
                                                while($row = mysql_fetch_assoc($payment_mode)){ ?>
                                                    <option class="cash_payment_option" style="display:none;" value="<?php echo $row['pay_by'];?>"><?php echo strtoupper($row['pay_by']);?></option>
                                               <?php } ?>
                                            </select>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                     <?php } ?>

                    </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_sales_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>


