<?php
include('../headertop.php');
include('../datepicker.php');
include('../db.php');

/*
accounting folder:
addexpense,
addexpense2
viewexpenses
viewexpense

assets/img folder:
printericon.jpg image 

dashboard folder:
index.php

root folder:
template.php

*/

$disp = '';
$pagetitle = 'View Expense';

if(!isset($_REQUEST['id']))
{
$disp .= 'Please select an expense first';
include('../template.php');
exit;
}

$id = $_REQUEST['id'];

$q = "select * from expenses where id='$id'";
$res = mysqli_query($dbcon,$q) or die(mysqli_error($dbcon));

if(mysqli_num_rows($res)<1)
{
$disp .= 'No expense found with this id';
include('../template.php');
exit;
}

$row = mysqli_fetch_array($res);

$qproj = "select * from project where type='ct'";
$qwork = "select * from work_type";

$rproj = mysqli_query($dbcon,$qproj) or die(mysqli_error($dbcon));
$rwork = mysqli_query($dbcon,$qwork) or die(mysqli_error($dbcon));

if($row['payment_method'] == 'cheque')
$payment_details = 'Cheque No: '.$row['payment_details'];
else
$payment_details = $row['payment_details'];

if(isset($_REQUEST['sm']))
$disp .= '<div class="smdiv">'.$_REQUEST['sm'].'</div>';
else
$disp .= '<div class="smdiv">View Expense Details</div>';


 
$disp .= '<div class="row">
                <div class="col-md-12">
                    <!-- Advanced Tables -->
                    <div class="panel panel-default">
                        <div class="panel-heading">
                             View Expense Details
                        </div>
                        <div class="panel-body">
                            <div class="table-responsive">
                                <table class="table table-striped table-bordered table-hover" id="dataTables-example">
                                    <tbody>
									<tr><th>Work Type *</th><td>'.$row['work_type'].'</td></tr>
									<Tr><th>Amount *:</th><td>'.$row['amount'].'</td></tr>
									<tr><th>Date *: </th><td>'.$row['date'].'</td></tr>
									<tr><th>Name *: </th><td>'.$row['name'].'</td></tr>
									<tr><th>Particulars *: </th><td>'.$row['particulars'].'</td></tr>
									<tr><th>Payment Method: </th><td>'.$row['payment_method'].'</td></tr>
									<tr><th>Payment Details: </th><td>'.$payment_details.'</td></tr>
									<tr><th>Receipt:</th><td><a href="../'.$row['rcptphoto'].'" target=_blank><img src="../'.$row['rcptphoto'].'" style="width:100px;height:100px;"></a>
									</tbody>
									</table>
									
									</div>
                            
                        </div>
                    </div>
                    <!--End Advanced Tables -->
                </div>
            </div>';
									
									
include('../header.php');
include('../template.php');
			?>