<!-- Begin breadcrumb -->
		<ol class="breadcrumb success rsaquo">
			<li><a href="dashboard.php"><i class="fa fa-home"></i></a></li>
			<li><a href="#">Reports</a></li>
			<li class="active">Invoice Number Report</li>
		</ol>
		

		<div class="panel panel-info">
		  <div class="panel-heading">
			<h3>Invoice Number Report</h3>
		  </div>
		  <div class="panel-body">
		<div class="the-box bg-primary no-border">
			<?php 
$sales = new sales();
$all_sales = $sales->get_all_sale();
//print_f($all_sales);
if (isset($_GET['bill'])) {
    if ($_GET['bill']) {
        $invoice_number = $_GET['bill'];
    } else {
        $invoice_number = NULL;
    }
    $results = $sales->get_sale_invoice_report($invoice_number);
    //print_f($results);
}
?>
	

	  		<form class="form-horizontal dashboardForm"  action="" method="get">
Beispiel #2
0
} elseif ($_SESSION['permission'] == 1) {
    header("location:index.php");
}
include 'templates/content_background.php';
include 'includes/modals.php';
//for the sale table for selling of the bike
if (isset($_POST['sell_button'])) {
    $numbers = $_POST['numbers'];
    $number_decrement = -1 * $_POST['numbers'];
    $bike_id = $_POST['bike_id'];
    $branch_id = $_SESSION['uid'];
    $BranchInvObj = new branch_inventory($number_decrement, $bike_id, $branch_id);
    $result_branch_inventory = $BranchInvObj->add_sub_inventory();
    //chek if the transaction is valid and perform operation
    if ($result_branch_inventory) {
        $SaleObj = new sales($numbers, $bike_id, $branch_id);
        $IsInsert = $SaleObj->add_sales();
        //var_dump($IsInsert);
        if ($IsInsert) {
            $_GET['sell_success'] = 1;
            ?>
                  
                        <script type="text/javascript">
                            $(document).ready(function() {
                            $(document).scrollTop( $("#sell_id").offset().top );  
                            });                 
                        </script>
            
<?php 
            $IsLimit = $BranchInvObj->limit('branch_inventory');
            //var_dump($IsLimit);
    if (file_exists($controller_root . '/php_classes/' . $class_name . '.php')) {
        $file_name = $controller_root . '/php_classes/' . $class_name . '.php';
        require_once $file_name;
    } else {
        throw new Exception("Class " . $class_name . " Not found");
    }
});
session_start();
if (isset($_SESSION['user_id']) and !empty($_SESSION['user_id']) and isset($_GET['user_id']) and !empty($_GET['user_id']) and $_SESSION['user_id'] === $_GET['user_id']) {
    if (isset($_POST['form_id']) and !empty($_POST['form_id'])) {
        $form_id = $_POST['form_id'];
        $tag = "ADD_FORM_DATA";
        if ($form_id == 1) {
            /// add sale
            if (isset($_POST['customer_id']) and isset($_POST['total']) and !empty($_POST['total']) and isset($_POST['net_amount']) and isset($_POST['tax_amount']) and isset($_POST['discount']) and isset($_POST['items']) and !empty($_POST['items'])) {
                $sale = new sales();
                $sale->customer_id = $_POST['customer_id'];
                $sale->amount = $_POST['total'];
                $sale->net_amount = $_POST['net_amount'];
                $sale->tax_amount = $_POST['tax_amount'];
                $sale->discount = $_POST['discount'];
                $user = new user();
                $user->id = $_SESSION['user_id'];
                $user->getUser();
                $sale->company_id = $user->company_id;
                $sales_items = array();
                foreach ($_POST['items'] as $sales_array_item) {
                    $sales_item = new sales_items();
                    $sales_item->item_id = $sales_array_item['id'];
                    $sales_item->quantity = $sales_array_item['quantity'];
                    $sales_item->rate = $sales_array_item['rate'];
    if (file_exists($controller_root . '/php_classes/' . $class_name . '.php')) {
        $file_name = $controller_root . '/php_classes/' . $class_name . '.php';
        require_once $file_name;
    } else {
        throw new Exception("Class " . $class_name . " Not found");
    }
});
session_start();
if (isset($_SESSION['user_id']) and !empty($_SESSION['user_id']) and isset($_GET['user_id']) and !empty($_GET['user_id']) and $_SESSION['user_id'] === $_GET['user_id']) {
    if (isset($_POST['form_id']) and !empty($_POST['form_id'])) {
        $form_id = $_POST['form_id'];
        $tag = "GET_FORM_DATA";
        if ($form_id == 2) {
            // sales
            if (isset($_POST['sale_id']) and !empty($_POST['sale_id'])) {
                $sale = new sales();
                $sale->id = $_POST['sale_id'];
                $result = $sale->getSale();
                if ($result) {
                    $user = new user();
                    $user->id = $_SESSION['user_id'];
                    $user->getUser();
                    if ($sale->company_id == $user->company_id) {
                        $message = "Sale Fetched successfuly";
                        $customer = new customer();
                        $customer->id = $sale->customer_id;
                        $customer->getCustomer();
                        $customer_name = $customer->customer_name . ' ( ' . $customer->id . ' ) ';
                        $items = array();
                        if (is_array($sale->getSalesItems()) and count($sale->getSalesItems())) {
                            foreach ($sale->getSalesItems() as $s_item) {
    if (file_exists($controller_root . '/php_classes/' . $class_name . '.php')) {
        $file_name = $controller_root . '/php_classes/' . $class_name . '.php';
        require_once $file_name;
    } else {
        throw new Exception("Class " . $class_name . " Not found");
    }
});
session_start();
if (isset($_SESSION['user_id']) and !empty($_SESSION['user_id']) and isset($_GET['user_id']) and !empty($_GET['user_id']) and $_SESSION['user_id'] === $_GET['user_id']) {
    if (isset($_POST['form_id']) and !empty($_POST['form_id'])) {
        $form_id = $_POST['form_id'];
        $tag = "UPDATE_FORM_DATA";
        if ($form_id == 2) {
            ///sales return
            if (isset($_POST['total']) and isset($_POST['sale_id']) and !empty($_POST['sale_id']) and isset($_POST['net_amount']) and isset($_POST['tax_amount']) and isset($_POST['discount']) and isset($_POST['items']) and !empty($_POST['items'])) {
                $sale = new sales();
                $sale->id = $_POST['sale_id'];
                $sale->getSale();
                $balance = $_POST['total'] - $sale->amount;
                $sale->amount = $_POST['total'];
                $sale->net_amount = $_POST['net_amount'];
                $sale->tax_amount = $_POST['tax_amount'];
                $sale->discount = $_POST['discount'];
                $sales_items_prev = $sale->getSalesItems();
                $sales_items_new = array();
                if (!($_POST['items'] == 'no_items')) {
                    foreach ($_POST['items'] as $sales_array_item) {
                        $sales_item = new sales_items();
                        $sales_item->item_id = $sales_array_item['id'];
                        $sales_item->quantity = $sales_array_item['quantity'];
                        $sales_item->rate = $sales_array_item['rate'];
Beispiel #6
0
								
								<div class="col-md-4">
									<div class="form-group noMarginBottom">
										<label for="p_supplier" class="col-sm-12">&nbsp;</label>
										<div class="col-sm-12">
											<button type="submit" class="btn btn-success btn-perspective pull-right" name="show_report">Show Report</button>
										</div>
								  	</div>
								</div>
								</form>
							<div class="clearfix"></div>
						</div><!-- Box Close -->

						<div class="the-box">
							<?php 
$sales = new sales();
$openingbalance = new openingbalance();
if (isset($_POST['show_report'])) {
    if ($_POST['person_name']) {
        $person_name = $_POST['person_name'];
    } else {
        $person_name = NULL;
    }
    if ($_POST['to_date']) {
        $date = $_POST['to_date'];
        $date = $sales->_date('Y-m-d H:i:s', $date);
    } else {
        $date = NULL;
    }
    $balance_date = $sales->_date('Y-m-d', $date);
    $results = $sales->get_sale_person_report($person_name, $date);
Beispiel #7
0
function get_form_html($form_id, $date)
{
    ob_start();
    ?>
    <div id="head_div" style="padding: 5px 0; background-color: #ECECEC;  color: #21ACD7;
         border-radius: 5px;margin-left: auto; text-align: center; ">
        DAY END REPORT OF 
        <input id="date_field" value="<?php 
    if ($date == 0) {
        $date = date('d/m/Y', time());
    }
    echo $date;
    ?>
" />
    </div>
    <div id="sales_items_table" style="margin-top: 10px; background-color:transparent;padding-bottom: 30px;">
        <style>
            div#purchace_items td{
                border: 1px solid #21ACD7;
            }
            div#purchace_items tbody td{
                padding: 5px 0 5px 5px;
            }
            div#purchace_items tbody td input,div#purchace_items tbody td select{
                padding: 0;
                border: 0;
                margin: 0;
                height: 100%;
                width: 100%;
                background-color: transparent;
            }
        </style>
        <div id="purchace_items" style="width: 100%; padding: 10px 0; color: #21ACD7;"> 
            <font>SALES ITEMS</font>
            <table id="sales_items_table" style="border-collapse: collapse; width: 100%; 
                   background-color: #fff; border-radius: 10px;  color: #21ACD7;  margin-top: 5px; margin-bottom: 20px;">
                <thead style="text-align: center;">
                    <tr>
                        <td style="width: 5%;">
                            #
                        </td>
                        <td>
                            ITEM
                        </td>
                        <td style="width: 15%;">
                            COUNT
                        </td>
                        <td style="width: 15%;">
                            TOTAL
                        </td>
                    </tr>
                </thead>
                <tbody style="padding-left: 3px; text-align: center; ">
                    <?php 
    $grand_total = 0;
    $total_count = 0;
    $user = new user();
    $user->id = $_SESSION['user_id'];
    $user->getUser();
    $shop = new company();
    $shop->id = $user->company_id;
    $shop->getCompany();
    $sale_item = new sales_items();
    $date = str_replace('/', '-', $date);
    $date = date('Y-m-d', strtotime($date));
    $sales_items = $sale_item->getOneDaysSaleItems($user->company_id, $date);
    $i = 0;
    if ($sales_items == NULL || sizeof($sales_items) == 0) {
        echo '<tr><td colspan="8"> No Sales Items Found </td></tr>';
    } else {
        foreach ($sales_items as $sales_item) {
            $grand_total = $grand_total + $sales_item->total;
            $total_count = $total_count + $sales_item->quantity;
            ?>
                        <tr>
                            <td style="text-align: center;">
                                <?php 
            echo ++$i;
            ?>
                            </td>
                            <?php 
            $item = new item();
            $item->id = $sales_item->item_id;
            $item->getItem();
            ?>
                            <td style="text-align: left;">
                                <?php 
            echo $item->item_name . ' ( ' . $item->item_code . ' )';
            ?>
                            </td>
                            <td>
                                <?php 
            echo number_format($sales_item->quantity, 3, '.', '');
            ?>
                            </td>
                            
                            <td id="tax">
                                <?php 
            echo number_format($sales_item->total, 2, '.', '');
            ?>
                            </td>
                        </tr>
                        <?php 
        }
    }
    ?>
                        <tr>
                            <td></td>
                            <td style="text-align: right;"> TOTAL </td>
                            <td><?php 
    echo number_format($total_count, 3, '.', '');
    ?>
</td>
                            <td><?php 
    echo number_format($grand_total, 2, '.', '');
    ?>
</td>
                        </tr>
                  </tbody>                               
            </table>
            <font>STATISTICS</font>
            <table id="sales_statistics_table" style="border-collapse: collapse; width: 100%; 
                   background-color: #fff; border-radius: 10px;  color: #21ACD7; margin-top: 5px; margin-bottom: 20px;">
                <thead style="text-align: center;">
                    <tr>
                            <td style="width: 5%;">
                                #
                            </td>
                            <td>
                                STATISTICS
                            </td>
                            <td style="width: 15%;">
                                COUNT
                            </td>
                            <td style="width: 15%;">
                                TOTAL TAX
                            </td>
                            <td style="width: 15%;">
                                TOTAL NET. AMOUNT
                            </td>
                            <td style="width: 15%;">
                                TOTAL DISCOUNT
                            </td>
                            <td style="width: 15%;">
                                TOTAL AMOUNT
                            </td>
                    </tr>
                </thead>
                <tbody style="text-align: center;">
                    <tr style="margin-top: 20px;">
                        <?php 
    $sale = new sales();
    $vals = $sale->getOneDaysSaleStatistics($user->company_id, $date);
    ?>
                            <td>1</td>
                            <td style="text-align: left;">SALES</td>
                            <td><?php 
    echo $vals['count'];
    ?>
</td>
                            <td><?php 
    echo number_format($vals['tax_amount'], 2, '.', '');
    ?>
</td>
                            <td><?php 
    echo number_format($vals['net_amount'], 2, '.', '');
    ?>
</td>
                            <td><?php 
    echo number_format($vals['discount'], 2, '.', '');
    ?>
</td>
                            <td><?php 
    echo number_format($vals['amount'], 2, '.', '');
    ?>
</td>
                    </tr>
                </tbody>                               
            </table>
            <font>TAX</font>
            <table id="sales_statistics_table" style="border-collapse: collapse; width: 100%; 
                   background-color: #fff; border-radius: 10px;  color: #21ACD7; margin-top: 5px;">
                <thead style="text-align: center;">
                    <tr>
                            <td style="width: 5%;">
                                #
                            </td>
                            <td>
                                TAX(%)
                            </td>
                            <td style="width: 20%;">
                                COUNT
                            </td>
                            <td style="width: 20%;">
                                TOTAL TAX
                            </td>
                    </tr>
                </thead>
                <tbody style="text-align: center;">
                    <?php 
    $total_tax = 0;
    $total_count = 0;
    $tax_category = new tax_category();
    $tax_categories = $tax_category->getTaxCategories();
    if (is_array($tax_categories) and count($tax_categories)) {
        $i = 0;
        foreach ($tax_categories as $tax_category) {
            ?>
                                <tr style="margin-top: 20px;">
                                    <?php 
            $tax_vals = $sale->getOneDayTaxDetails($user->company_id, $date, $tax_category->id);
            ?>
                                        <td><?php 
            echo ++$i;
            ?>
</td>
                                        <td style="text-align: left; padding-left: 10px;"><?php 
            echo $tax_category->tax_category_name;
            ?>
</td>
                                        <td><?php 
            echo number_format($tax_vals['count'], 0, '.', '');
            ?>
</td>
                                        <td><?php 
            echo number_format($tax_vals['tax'], 2, '.', '');
            ?>
</td>
                                </tr>                                
                            <?php 
            $total_tax += $tax_vals['tax'];
            $total_count += $tax_vals['count'];
        }
    }
    ?>
                    <tr style="margin-top: 20px;">
                        <td></td>
                        <td style="text-align: right; padding-right: 10px;">TOTAL</td>
                        <td><?php 
    echo number_format($total_count, 0, '.', '');
    ?>
</td>
                        <td><?php 
    echo number_format($total_tax, 2, '.', '');
    ?>
</td>
                    </tr>
                </tbody>                               
            </table>
        </div>
    </div>
    <script type="text/javascript">
        function load_day_end_report(){
            var date = $('input#date_field').val();
            get_form(24,
                        function(html, tools) {
                             $('div#form-body').html(html);
                             $('div#content-body-action-tools').html(tools);
                        }, function(message) {
                             $('font#section_heading').empty();
                             $('div#form-body').empty();
                             alert(message);
                        },
                        date);
        }
        function on_print_clicked() {
            var date = $('input#date_field').val();
            var header = '<font style="color:#21ACD7; font-size:24px; "><?php 
    echo $shop->company_name . " " . $shop->company_code;
    ?>
</font>'
                            +'<br/><font style="color:#21ACD7; font-size:20px; ">DAY END REPORT OF '+date+'</font>';
            $('div#print_container_header')
                    .html(header);
            var html = $('div#sales_items_table').html();
            $('div#print_container_body').html(html);  
            print();
            $('div#print_container_header').empty();
            $('div#print_container_body').empty();
            $('div#print_container_footer').empty();
        }
       function setup_datepicker(){
           $('input#date_field').datepick({
               minDate:'26/04/2015', 
               dateFormat:'dd/mm/yyyy',
               maxDate:'0',
               onSelect:function(){
                    load_day_end_report();
                }
           });
       }
       setup_datepicker();
    </script>

    <?php 
    $form = ob_get_clean();
    return $form;
}
Beispiel #8
0
</div>  

<!-- shows total sales information -->
<div id="myModal_report" class="modal fade" role="dialog">
    <div class="modal-dialog modal-lg">
        <!-- Modal content-->
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal">&times;</button>
                <h4 class="modal-title">SALES REPORT</h4>
            </div>
            <!-- contents of model here -->
            <div class="modal-body">
                <?php 
$db = database::getInstance();
$SalesObj = new sales();
$values = $SalesObj->transaction();
?>
                <!-- shows sales information -->

                <table class="table table-bordered">
                    <tr>
                        <th>SN</th>
                        <th>Branch name</th>
                        <th>Bike</th>
                        <th>Number Of Sales</th>
                    </tr>
                <?php 
$i = 1;
foreach ($values as $value) {
    echo <<<ABC
Beispiel #9
0
function editSale()
{
    $p = $_REQUEST["sid"];
    include "sales.php";
    $obj = new sales();
    if (!$obj->editSale($p)) {
        echo '{"result":0}';
    } else {
        echo '{"result":1}';
    }
}
Beispiel #10
0
function get_form_html($form_id, $id, $page, $limit, $adjacents)
{
    ob_start();
    $sale_obj = new sales();
    $user = new user();
    $user->id = $_SESSION['user_id'];
    $user->getUser();
    $count = $sale_obj->getLastThreeDaysSalesCount($user->company_id);
    if ($page == 1) {
        $start = 0;
        $head_message = "LAST {$limit} SALES OF LAST 3 DAYS";
    } else {
        $start = ($page - 1) * $limit;
        $head_message = "SALES {$start} TO " . ($start + $limit) . " SALES OF LAST 3 DAYS";
    }
    ?>
    <div id="head_div" style="padding: 5px 0; background-color: #ECECEC;  color: #21ACD7;
         border-radius: 5px;margin-left: auto; text-align: center; ">
        <?php 
    echo $head_message;
    ?>
    </div>
    <div style="margin-top: 10px; background-color:transparent;padding-bottom: 30px;">
        <style>
            div#purchace_items td,div#purchace_items th{
                border: 1px solid #21ACD7;
            }
            div#purchace_items tbody td{
                padding: 5px 0 5px 5px;
            }
            div#purchace_items tbody td input,div#purchace_items tbody td select{
                padding: 0;
                border: 0;
                margin: 0;
                height: 100%;
                width: 100%;
                background-color: transparent;
            }
        </style>
        <input type="text" id="search" placeholder="Enter Search Key here..." style="width: 100%; margin-left: 0px;" onkeyup="search()" />
        <style>
            img#search{
                position: relative;
                height: 20px;
                width: 20px;
                float: right;
                top: -29px;
                right: 10px;
            }
        </style>
        <img id="search" src="../ui/images/search.png" onclick="search()" />
        
        <div style="padding: 10px 0; background-color: transparent; 
             border-radius: 5px;margin-left: auto; text-align: center;overflow-x: auto; ">
             <?php 
    echo pagination($limit, $adjacents, $count, $page);
    ?>
        </div>
        
        <div id="purchace_items" style="width: 100%; padding: 10px 0; color: #21ACD7;">           
            <table id="items_table" style="border-collapse: collapse; width: 100%; 
                   background-color: #fff; border-radius: 10px;  color: #21ACD7;">
                <thead style="text-align: center;">
                    <tr  status="not_selected" >
                        <th>
                            #
                        </th>
                        <th>
                            ID
                        </th>
                        <th>
                            DATE &amp; TIME
                        </th>
                        <th>
                            CUSTOMER
                        </th>
                        <th style="">
                            DISCOUNT
                        </th>
                        <th style="">
                            TAX
                        </th>
                        <th style="">
                            NET. AMOUNT
                        </th>
                        <th style="">
                            TOTAL
                        </th>
                        <th style="">

                        </th>
                    </tr>
                </thead>
                <tbody style="padding-left: 3px; text-align: center; ">
                    <?php 
    $sales = $sale_obj->getLastThreeDaysSales($user->company_id, $start, $limit);
    $i = $start;
    if ($sales == NULL || sizeof($sales) == 0) {
        echo '<tr><td colspan="8"> No Sales Found </td></tr>';
    } else {
        foreach ($sales as $sale) {
            ?>
                        <tr id="<?php 
            echo $sale->id;
            ?>
" onclick="select_row(this)" status="not_selected" >
                            <td style="text-align: center;">
                                <?php 
            echo ++$i;
            ?>
                            </td>
                            <td>
                                <?php 
            echo $sale->id;
            ?>
                            </td>
                            <?php 
            $date = date('d/m/Y', strtotime($sale->sale_at) + 5.5 * 60 * 60);
            $time = date('h:m A', strtotime($sale->sale_at) + 5.5 * 60 * 60);
            ?>
                            <td id="date" date="<?php 
            echo $date;
            ?>
" time="<?php 
            echo $time;
            ?>
">
                                <?php 
            echo $date . ' - ' . $time;
            ?>
                            </td>
                            <?php 
            $customer = new customer();
            $customer->id = $sale->customer_id;
            $customer->getCustomer();
            ?>
                            <td id="customer" c_name="<?php 
            echo $customer->customer_name;
            ?>
" c_id="<?php 
            echo $customer->id;
            ?>
" >
                                <?php 
            echo $customer->customer_name . ' ( ID : ' . $customer->id . ' )';
            ?>
                            </td>
                            <td id="discount">
                                <?php 
            echo number_format($sale->discount, 2, '.', '');
            ?>
                            </td>
                            <td id="tax">
                                <?php 
            echo number_format($sale->tax_amount, 2, '.', '');
            ?>
                            </td>
                            <td id="net_amount">
                                <?php 
            echo number_format($sale->net_amount, 2, '.', '');
            ?>
                            </td>
                            <td id="total">
                                <?php 
            echo number_format($sale->amount, 2, '.', '');
            ?>
                            </td>
                            <td id="down_button" style="width: 20px;text-align: center; padding: 10px;">
                                <img id="toggle_button" style="width: 20px; height: 20px; cursor: pointer;"
                                     onclick="toggle_items_visibility(this)" src="../ui/images/down_arrow.png"/>
                                <img id="toggle_button" style="width: 20px; height: 20px; cursor: pointer; display: none;"
                                     onclick="toggle_items_visibility(this)" src="../ui/images/up_arrow.png"/>
                            </td>
                        </tr>
                        <tr style="display: none;" id="sale_items">
                            <td colspan="8" style="padding:0 0 20px 0;">
                                <table  id="sale_items" style="border-collapse: collapse; background-color: #c0effd; width: 80%; color: #21ACD7; float: right;">
                                    <thead>
                                    <tr>
                                        <th>
                                            ITEM
                                        </th>
                                        <th>
                                            QUANTITY
                                        </th>
                                        <th>
                                            RATE
                                        </th>
                                        <th>
                                            NET. AMOUNT
                                        </th>
                                        <th>
                                            DISCOUNT
                                        </th>
                                        <th>
                                            TAX
                                        </th>
                                        <th>
                                            TOTAL
                                        </th>
                                    </tr>
                                </thead>
                                    <tbody>
                                    <?php 
            if (is_array($sale->getSalesItems()) and count($sale->getSalesItems())) {
                foreach ($sale->getSalesItems() as $s_item) {
                    ?>
                                    <tr id="<?php 
                    echo $s_item->id;
                    ?>
">
                                        <?php 
                    $item = new item();
                    $item->id = $s_item->item_id;
                    $item->getItem();
                    ?>
                                            <td id="item" 
                                                item_name="<?php 
                    echo $item->item_name . ' - ' . $item->item_code;
                    ?>
"
                                                item_id="<?php 
                    echo $item->id;
                    ?>
">
                                                    <?php 
                    echo $item->item_name . ' - ' . $item->item_code;
                    ?>
                                            </td>
                                            <td id="quantity" val="<?php 
                    echo $s_item->quantity;
                    ?>
">
                                                <?php 
                    echo number_format($s_item->quantity, 3, '.', '');
                    ?>
                                            </td>
                                            <td id="rate" val="<?php 
                    echo $s_item->rate;
                    ?>
">
                                                <?php 
                    echo number_format($s_item->rate, 2, '.', '');
                    ?>
                                            </td>      
                                            <?php 
                    $tax_category = new tax_category();
                    $tax_category->id = $item->tax_category_id;
                    $tax_category->getTaxCategory();
                    $total = $s_item->quantity * $s_item->rate;
                    if ($total == 0) {
                        $discount_percent = 0;
                    } else {
                        $discount_percent = $s_item->discount * 100 / $total;
                    }
                    $total = $total - $s_item->discount;
                    ?>
                                        
                                            <td>
                                                <?php 
                    echo number_format($total - $s_item->tax, 2, '.', '');
                    ?>
                                            </td>  
                                            <td id="discount" val="<?php 
                    echo $s_item->discount;
                    ?>
" discount_percent="<?php 
                    echo $discount_percent;
                    ?>
">
                                                <?php 
                    echo number_format($s_item->discount, 2, '.', '');
                    ?>
                                            </td>
                                            <td id="tax" val="<?php 
                    echo $s_item->tax;
                    ?>
" tax_rate="<?php 
                    echo $tax_category->tax_percentage;
                    ?>
">
                                                <?php 
                    echo number_format($s_item->tax, 2, '.', '');
                    ?>
                                            </td>
                                            <td id="total" val="<?php 
                    echo $total;
                    ?>
">
                                                <?php 
                    echo number_format($total, 2, '.', '');
                    ?>
                                            </td>
                                        </tr>
                                        <?php 
                }
            } else {
                echo '<tr><td colspan="7">No item found</td></tr>';
            }
            ?>
                                        </tbody>
                                </table>
                            </td>
                        </tr>
                        <?php 
        }
    }
    ?>
                </tbody>                               
            </table>
        </div>
        
        <div style="padding: 10px 0; background-color: transparent; 
             border-radius: 5px;margin-left: auto; text-align: center;overflow-x: auto; ">
             <?php 
    echo pagination($limit, $adjacents, $count, $page);
    ?>
        </div>        
        
    </div>
    <script type="text/javascript">
        function on_edit_clicked(){
            var selected_row = $('tr[status="selected"]');
            var sale_items_table = selected_row.next('tr').find('table#sale_items');
            var sale_items = sale_items_table.find('tbody').children();
            var items = new Array();
            var i = 0;
            sale_items.each(function() {
                var item_name = $(this).find('td#item').attr('item_name');
                var item_id = $(this).find('td#item').attr('item_id');
                var id = $(this).attr('id');
                var quantity = $(this).find('td#quantity').attr('val');
                quantity = parseFloat(quantity).toFixed(3);
                var rate = $(this).find('td#rate').attr('val');
                rate = parseFloat(rate).toFixed(2);
                var tax = $(this).find('td#tax').attr('val');
                var tax_rate = $(this).find('td#tax').attr('tax_rate');
                var discount = $(this).find('td#discount').attr('val');
                var discount_percent = $(this).find('td#discount').attr('discount_percent');
                var total = $(this).find('td#total').attr('val');
                var item = {
                     id: id,
                     quantity: quantity,
                     rate: rate,
                     item_name: item_name,
                     item_id: item_id,
                     total: total,
                     discount:discount,
                     discount_percent:discount_percent,
                     tax_rate: tax_rate,
                     tax: tax
                }
                items[i++] = item;
             });
             var c_name = selected_row.find('td#customer').attr('c_name');
             var c_id = selected_row.find('td#customer').attr('c_id');
             var sale_id = selected_row.attr('id');
             var total = selected_row.find('td#total').html();
             total = parseFloat(total).toFixed(2);
             var total_tax = selected_row.find('td#tax').html();
             var total_discount = selected_row.find('td#discount').html();
             var date = selected_row.find('td#date').attr('date');
             var time = selected_row.find('td#date').attr('time');
             var net_total = selected_row.find('td#net_amount').html();
             get_form(2,  ///sales return invoice
                function (html, tools){
                    $('div#form-body').html(html);
                    $('div#content-body-action-tools').html(tools);
                    $('input#sale_id').val(sale_id);
                    var form = $('div#form-body').find('form.action_form');
                    form.attr('operation', 'update');
                    form.find('input#customer_id').val(c_name+' ( ID : '+c_id+' )');
                    form.find('input#customer_id').attr('disabled', 'true');
                    form.find('input#date_and_time').val(date + ' - ' + time);
                    form.find('input#date_and_time').attr('date', date);
                    form.find('input#date_and_time').attr('time', time);
                    $('table#items_table tbody').empty();
                    for(var i = 0; i<items.length; i++){
                        add_sale_item();
                        var row = $('table#items_table tbody tr:last-child');
                        var item = items[i];
                        row.find('input#item').attr('disabled', 'disabled');
                        row.find('input#item').val(item.item_name);
                        row.find('input#item').attr('item_id', item.item_id);
                        row.find('input#quantity').val(item.quantity);
                        row.find('input#quantity').attr('max', item.quantity);
                        row.find('input#rate').val(item.rate);
                        row.find('input#rate').attr('tax', item.tax_rate);
                        row.find('input#discount_percent').val(item.discount_percent);
                        row.find('input#total').val(item.total);
                        row.find('input#total').attr('tax', item.tax);
                        row.find('input#total').attr('discount', item.discount);
                        row.find('input#discount').val(item.discount);
                        row.attr('previous', true);
                    } 
                    form.find('span#total').html(total);
                    form.find('span#total').attr('tax', total_tax);
                    form.find('span#total').attr('discount', total_discount);
                    form.find('span#total_paid').html(total);
                    form.find('span#balance').html('0.00');
                    form.attr('sale_id', sale_id);
                    form.attr('customer_name', c_name);
                    form.attr('customer_id', c_id);
                },
                function (message){
                    $('font#section_heading').empty();
                    $('div#form-body').empty();
                    alert(message);
                }
             );
        }
        function on_print_clicked() {
            var selected_row = $('tr[status="selected"]');
            var sale_items_table = selected_row.next('tr').find('table#sale_items');
            var sale_items = sale_items_table.find('tbody').children();
            var items = new Array();
            var i = 0;
            sale_items.each(function() {
                var item_name = $(this).find('td#item').attr('item_name');
                var id = $(this).attr('id');
                var quantity = $(this).find('td#quantity').attr('val');
                var rate = $(this).find('td#rate').attr('val');
                var tax = $(this).find('td#tax').attr('val');
                var tax_rate = $(this).find('td#tax').attr('tax_rate');
                var discount = $(this).find('td#discount').attr('val');
                var total = $(this).find('td#total').attr('val');
                total = parseFloat(total);
                total = total.toFixed(2);
                var item = {
                     id: id,
                     quantity: quantity,
                     rate: rate,
                     item_name: item_name,
                     total: total,
                     discount:discount,
                     tax: tax,
                     tax_rate: tax_rate
                }
                items[i++] = item;
             });
             var c_name = selected_row.find('td#customer').attr('c_name');
             var c_id = selected_row.find('td#customer').attr('c_id');
             if(c_id == 0){
                 c_name = 'Not Regd.';
             }
             var sale_id = selected_row.attr('id');
             var total = selected_row.find('td#total').html();
             total = parseFloat(total);
             total = total.toFixed(2);
             var total_tax = selected_row.find('td#tax').html();
             total_tax = parseFloat(total_tax);
             total_tax = total_tax.toFixed(2);
             var total_discount = selected_row.find('td#discount').html();
             total_discount = parseFloat(total_discount);
             total_discount = total_discount.toFixed(2);
             var net_total = selected_row.find('td#net_amount').html();
             net_total = parseFloat(net_total);
             net_total = net_total.toFixed(2);
             var date = selected_row.find('td#date').attr('date');
             var time = selected_row.find('td#date').attr('time');
             var data = {
                  customer_id: c_id,
                  total: total,
                  net_amount: net_total,
                  tax_amount: total_tax,
                  discount:total_discount,
                  items: items,
                  date: date,
                  time: time
             }
             print_bill(data, c_name, sale_id);
        }
        function print_bill(data, customer_name, sale_id) {
                var html = '';
                html ='<img id="logo_bill" src="images/nutiez.png"/><br/><font id="print_container_header_company_adderss">Royal Piknik Traders LLP, 29/861</font>'
                        +'<br/><font id="print_container_header_company_adderss">Parayancheri, Calicut</font><br/><font id="print_container_header_company_adderss">'
                        +'Phone : 0495 2741095,+91 9388627725</font><br/><font id="print_container_header_company_adderss">The kerala value added tax rules 2005/ form no. 8</font>'
                        +'<br/><font id="print_container_header_company_adderss">Tin : 32110844692</font>'
                        +'<br/><font id="print_container_header_company_adderss">True Copy</font>';
                $('div#print_container_header').html(html);
                html = '';
   
                html = html + "<div<!-- style=\"padding:10px 0;\"><table style=\"float:right; font-size: 12px;\">"
                        +"<tr><td>Date</td><td>:</td><td style=\"text-align:right;\">" + data.date + "</td></tr>"
                        +"<tr><td>Time</td><td>:</td><td style=\"text-align:right;\">" + data.time + "</td></tr></table>";
                
                html = html + "<table style=\"font-size: 12px;\">"
                        +"<tr><td>Bill No.</td><td>:</td><td>" + sale_id + "</td></tr>"
                        +"<tr><td>Cust. ID</td><td>:</td><td>" + data.customer_id + "</td></tr>"
                        +"<tr><td>Cust. Name</td><td>:</td><td>" + customer_name + "</td></tr></table></div>";
                
                html = html + "<div style=\"border-top:1px dashed #000; margin:10px auto 0 auto;padding:0 0 10px 0;\">"
                        + "<table style=\"width:100%;font-size: 12px;\"><tr style=\"border-bottom: 1px solid #000; border-top: 1px solid #000;\">"
                        + "<td style=\"width:44%; border-bottom:1px dashed #000; padding-bottom:5px; margin-bottom:5px;\">Description</td>"
                        + "<td style=\"width:14%; border-bottom:1px dashed #000; padding-bottom:5px; margin-bottom:5px; text-align:right;\">Qty</td>"
                        + "<td style=\"width:14%; border-bottom:1px dashed #000; padding-bottom:5px; margin-bottom:5px; text-align:right;\">Rate</td>"
                        // + "<td style=\"width:15%; border-bottom:1px dashed #000; padding-bottom:5px; margin-bottom:5px; text-align:right;\">Amount</td>"
                        // + "<td style=\"width:10%; border-bottom:1px dashed #000; padding-bottom:5px; margin-bottom:5px; text-align:right;\">Tax</td>"
                        + "<td style=\"width:14%; border-bottom:1px dashed #000; padding-bottom:5px; margin-bottom:5px; text-align:right;\">Tax(%)</td>"
                        + "<td style=\"width:14%; border-bottom:1px dashed #000; padding-bottom:5px; margin-bottom:5px; text-align:right;\">Total</td></tr>";
                var i = 0;
                for (var key in data.items) {
                    var item = data.items[key];
                    html = html + "<tr><td>" + item.item_name + "</td>"
                            +"<td style=\"text-align:right;\">" + parseFloat(item.quantity).toFixed(3) + "</td>"
                            +"<td style=\"text-align:right;\">" + parseFloat(item.rate).toFixed(2) + "</td>"
                            //+"<td style=\"text-align:right;\">" + (parseFloat(item.total) - parseFloat(item.tax)) + "</td>"
//                            +"<td style=\"text-align:right;\">" + item.tax + "</td>"
                            +"<td style=\"text-align:right;\">" + item.tax_rate + "</td>"
                            +"<td style=\"text-align:right;\">" + parseFloat(item.total).toFixed(2) + "</td>"
                            +"</tr>";
                }
                html = html + "</table></div>";
                html = html + "<div style=\"border-top:1px dashed #000; padding:10px 0;\"><table style=\"margin-left: auto;font-size: 12px;\">";
                html = html + "<tr><td>Net. Amount</td><td style=\"margin:0 15;\">:</td><td style=\"text-align:right;\">" + data.net_amount + "</td></tr>";
                if(parseFloat(data.discount) > 0 ){
                    html = html + "<tr><td>Discount</td><td style=\"margin:0 15;\">:</td><td style=\"text-align:right;\">" + data.discount + "</td></tr>";
                }
                html = html + "<tr><td>Tax</td><td style=\"margin:0 15;\">:</td><td style=\"text-align:right;\">" + data.tax_amount + "</td></tr>";
                html = html + "<tr style=\"font-size:18px;\"><td><b>Total</b></td><td style=\"margin:0 15;\">:</td><td style=\"text-align:right;\"><b>" + data.total + "</b></td></tr>";
                html = html + "</table></div>";
//                console.log("Creating bill : " + html);
                $('div#print_container_body').html(html);
                html = '';
                html = '<font>Thank you for shoping</font><br/><font>Visit again...</font> ';
                $('div#print_container_footer').html(html);
                print();
                $('div#print_container_header').empty();
                $('div#print_container_body').empty();
                $('div#print_container_footer').empty();
            }
        function select_row(row) {
            var j_row = $(row);
            if(j_row.attr('status') == 'selected'){
                $('table#items_table tr').attr('status', 'not_selected');
                $('table#items_table tr').css('background-color', '#FFF');
                $('img#edit').css('display', 'none');
                $('img#edit_fade').css('display', 'block');
                $('img#print').css('display', 'none');
                $('img#print_fade').css('display', 'block');
            }else{            
                $('table#items_table tr').attr('status', 'not_selected');
                $('table#items_table tr').css('background-color', '#FFF');
                j_row.attr('status', 'selected');
                j_row.css('background-color', '#C0EFFD');
                $('img#edit').css('display', 'block');
                $('img#edit_fade').css('display', 'none');
                $('img#print').css('display', 'block');
                $('img#print_fade').css('display', 'none');
            }          
        }
        function toggle_items_visibility(down_button) {
            var row = $(down_button).closest('tr');
            row.next('tr').fadeToggle();
            row.find('img#toggle_button').toggle();
            
        }
        function search(){
            var search_key = $('input#search').val();
            if(search_key !== ''){                
                console.log("search key "+ search_key);
                searchTable(search_key);
            }else{
                $('#items_table tr').show();
                $('#items_table tr#sale_items').hide();
            }
        }
        function searchTable(inputVal)
        {
                var table = $('#items_table');
                table.find('tr').each(function(index, row)
                {
                    if($(row).attr('id')!=='sale_items'){
                        var allCells = $(row).find('td');
                        if(allCells.length > 0)
                        {
                                var found = false;
                                allCells.each(function(index, td)
                                {
                                        var regExp = new RegExp(inputVal, 'i');
                                        if(regExp.test($(td).text()))
                                        {
                                                found = true;
                                                return false;
                                        }
                                });
                                if(found == true)$(row).show();else $(row).hide();
                        }
                        
                        var items_row = $(row).next('tr');
                        var allCells = items_row.find('td');
                        if(allCells.length > 0)
                        {
                                var found = false;
                                allCells.each(function(index, td)
                                {
                                        var regExp = new RegExp(inputVal, 'i');
                                        if(regExp.test($(td).text()))
                                        {
                                                found = true;
                                                return false;
                                        }
                                });
                                if(found == true){
                                    $(row).show();
                                    items_row.show();
                                }else{
                                    items_row.hide();
                                }
                        }
                        
                    }
                });
        }        
        
        function set_pagination_listener(){          
            $('.pagination').on('click','.page-numbers',function(e){
                e.preventDefault();
                var page = $(this).attr('page');
                var id = 0;
                get_form(3,
                    function(html, tools) {
                        $('div#form-body').html(html);
                        $('div#content-body-action-tools').html(tools);
                    }, function(message) {
                        $('font#section_heading').empty();
                        alert(message);
                    },id
                    ,page
                );
                return false;
             }); 
        }
        set_pagination_listener();
    </script>

    <?php 
    $form = ob_get_clean();
    return $form;
}
Beispiel #11
0
function get_form_html($form_id, $date)
{
    ob_start();
    ?>
    <div id="head_div" style="padding: 5px 0; background-color: #ECECEC;  color: #21ACD7;
         border-radius: 5px;margin-left: auto; text-align: center; ">
        MONTHLY REPORT OF 
        <input id="year_field" value="<?php 
    if ($date == 0) {
        $year = date('Y', time());
    } else {
        $year = split('/', $date)[0];
    }
    echo $year;
    ?>
"  onchange="load_monthly_report()" style="width: 55px;" min="2015" max="2065" required />
        <select  id="month_field" onchange="load_monthly_report()" >
            <?php 
    if ($date == 0) {
        $month = date('m', time());
    } else {
        $month = split('/', $date)[1];
    }
    ?>
            <option <?php 
    if ($month == 1) {
        echo ' selected ';
    }
    ?>
 value="1">JANUARY</option>
            <option <?php 
    if ($month == 2) {
        echo ' selected ';
    }
    ?>
 value="2">FEBRUARY</option>
            <option <?php 
    if ($month == 3) {
        echo ' selected ';
    }
    ?>
 value="3">MARCH</option>
            <option <?php 
    if ($month == 4) {
        echo ' selected ';
    }
    ?>
 value="4">APRIL</option>
            <option <?php 
    if ($month == 5) {
        echo ' selected ';
    }
    ?>
 value="5">MAY</option>
            <option <?php 
    if ($month == 6) {
        echo ' selected ';
    }
    ?>
 value="6">JUNE</option>
            <option <?php 
    if ($month == 7) {
        echo ' selected ';
    }
    ?>
 value="7">JULY</option>
            <option <?php 
    if ($month == 8) {
        echo ' selected ';
    }
    ?>
 value="8">AUGUST</option>
            <option <?php 
    if ($month == 9) {
        echo ' selected ';
    }
    ?>
 value="9">SEPTEMBER</option>
            <option <?php 
    if ($month == 10) {
        echo ' selected ';
    }
    ?>
 value="10">OCTOBER</option>
            <option <?php 
    if ($month == 11) {
        echo ' selected ';
    }
    ?>
 value="11">NOVEMBER</option>
            <option <?php 
    if ($month == 12) {
        echo ' selected ';
    }
    ?>
 value="121">DECEMBER</option>
        </select>
    </div>
    <div id="content_table" style="margin-top: 10px; background-color:transparent;padding-bottom: 30px;">
        <style>
            div#purchace_items td{
                border: 1px solid #21ACD7;
            }
            div#purchace_items tbody td{
                padding: 5px 0 5px 5px;
            }
            div#purchace_items tbody td input,div#purchace_items tbody td select{
                padding: 0;
                border: 0;
                margin: 0;
                height: 100%;
                width: 100%;
                background-color: transparent;
            }
        </style>
        <div id="purchace_items" style="width: 100%; padding: 10px 0; color: #21ACD7;">           
            <table id="table" style="border-collapse: collapse; width: 100%; 
                   background-color: #fff; border-radius: 10px;  color: #21ACD7;">
                <thead style="text-align: center;">
                    <tr>
                        <td style="width: 5%;">
                            #
                        </td>
                        <td>
                            DESCRIPTION
                        </td>
                        <td style="width: 15%;">
                            INCOME
                        </td>
                        <td style="width: 15%;">
                            EXPENCE
                        </td>
                        <td style="width: 15%;">
                            BALANCE
                        </td>
                    </tr>
                </thead>
                <tbody style="padding-left: 3px; text-align: center; ">
                    <?php 
    $balance = 0;
    $income_total = 0;
    $expence_total = 0;
    $user = new user();
    $user->id = $_SESSION['user_id'];
    $user->getUser();
    $i = 0;
    if ($year < 2015 || $year > 2065 || $month < 1 || $month > 12) {
        echo '<tr><td colspan="8"> In Valid Month Found </td></tr>';
    } else {
        //$grand_total = $grand_total + $sales_item->total;
        ?>
                        <tr>
                            <td style="text-align: center;">
                                <?php 
        echo ++$i;
        ?>
                            </td>
                            <?php 
        $sale = new sales();
        $vals = $sale->getOneMonthsSaleSummary($user->company_id, $month, $year);
        ?>
                            <td style="text-align: left;">
                                Sales
                            </td>
                            <td>
                                <?php 
        echo number_format($vals['amount'], 2, '.', '');
        $income_total = $income_total + $vals['amount'];
        ?>
                            </td>
                            <td>
                            </td>                            
                            <td id="tax">
                                <?php 
        $balance = $income_total - $expence_total;
        echo number_format($balance, 2, '.', '');
        ?>
                            </td>
                        </tr>
                        <tr>
                            <td style="text-align: center;">
                                <?php 
        echo ++$i;
        ?>
                            </td>
                            <td style="text-align: left;">
                                Tax
                            </td>
                            <td>
                                
                            </td>
                            <td>
                                <?php 
        echo number_format($vals['tax_amount'], 2, '.', '');
        $expence_total = $expence_total + $vals['tax_amount'];
        ?>
                            </td>                            
                            <td id="tax">
                                <?php 
        $balance = $income_total - $expence_total;
        echo number_format($balance, 2, '.', '');
        ?>
                            </td>
                        </tr>
                        <tr>
                            <td style="text-align: center;">
                                <?php 
        echo ++$i;
        ?>
                            </td>
                            <?php 
        $purchace = new purchaces();
        $vals = $purchace->getOneMonthsPurchaceSummary($user->company_id, $month, $year);
        ?>
                            <td style="text-align: left;">
                                Purchaces
                            </td>
                            <td>
                            </td>
                            <td>
                                <?php 
        echo number_format($vals['amount'], 2, '.', '');
        $expence_total = $expence_total + $vals['amount'];
        ?>
                            </td>                            
                            <td id="tax">
                                <?php 
        $balance = $income_total - $expence_total;
        echo number_format($balance, 2, '.', '');
        ?>
                            </td>
                        </tr>
                        <tr>
                            <td style="text-align: center;">
                                <?php 
        echo ++$i;
        ?>
                            </td>
                            <?php 
        $expence = new expences();
        $vals = $expence->getOneMonthsExpenceSummary($user->company_id, $month, $year);
        ?>
                            <td style="text-align: left;">
                                Expences
                            </td>
                            <td>
                            </td>
                            <td>
                                <?php 
        echo number_format($vals['amount'], 2, '.', '');
        $expence_total = $expence_total + $vals['amount'];
        ?>
                            </td>                            
                            <td id="tax">
                                <?php 
        $balance = $income_total - $expence_total;
        echo number_format($balance, 2, '.', '');
        ?>
                            </td>
                        </tr>
                        <tr>
                            <td style="text-align: center;">
                                <?php 
        echo ++$i;
        ?>
                            </td>
                            <?php 
        $bank_deposit = new bank_deposits();
        $vals = $bank_deposit->getOneMonthsBankDepositsSummary($user->company_id, $month, $year);
        ?>
                            <td style="text-align: left;">
                                Bank Deposit
                            </td>
                            <td>
                            </td>
                            <td>
                                <?php 
        echo number_format($vals['amount'], 2, '.', '');
        $expence_total = $expence_total + $vals['amount'];
        ?>
                            </td>                            
                            <td id="tax">
                                <?php 
        $balance = $income_total - $expence_total;
        echo number_format($balance, 2, '.', '');
        ?>
                            </td>
                        </tr>
                        <?php 
    }
    ?>
                        <tr>
                            <td></td>
                            <td style="text-align: right;"> TOTAL </td>
                            <td><?php 
    echo number_format($income_total, 2, '.', '');
    ?>
</td>
                            <td><?php 
    echo number_format($expence_total, 2, '.', '');
    ?>
</td>
                            <td><?php 
    echo number_format($balance, 2, '.', '');
    ?>
</td>
                        </tr>
                  </tbody>                               
            </table>
            <?php 
    /* ?>
       <table id="sales_statistics_table" style="border-collapse: collapse; width: 100%; 
              background-color: #fff; border-radius: 10px;  color: #21ACD7; margin-top: 20px;">
           <thead style="text-align: center;">
               <tr>
                       <td style="width: 5%;">
                           #
                       </td>
                       <td>
                           STATISTICS
                       </td>
                       <td style="width: 15%;">
                           COUNT
                       </td>
                       <td style="width: 15%;">
                           TOTAL TAX
                       </td>
                       <td style="width: 15%;">
                           TOTAL NET. AMOUNT
                       </td>
                       <td style="width: 15%;">
                           TOTAL AMOUNT
                       </td>
               </tr>
           </thead>
           <tbody style="text-align: center;">
               <tr style="margin-top: 20px;">
                   <?php
                   $sale = new sales();
                   $vals = $sale->getOneDaysSaleStatistics($user->company_id, $date);
                   ?>
                       <td>1</td>
                       <td style="text-align: left;">SALES</td>
                       <td><?php echo $vals['count']; ?></td>
                       <td><?php echo number_format($vals['tax_amount'], 2, '.',''); ?></td>
                       <td><?php echo number_format($vals['net_amount'], 2, '.',''); ?></td>
                       <td><?php echo number_format($vals['amount'], 2, '.',''); ?></td>
               </tr>
           </tbody>                               
       </table>
       <?php */
    ?>
        </div>
    </div>
    <script type="text/javascript">
        function load_monthly_report(){
            var year = $('input#year_field').val();
            if(year<2015 || year>2065){
                alert('Enter a valid year !');
                return; 
            }
            var month = $('select#month_field').val();
            get_form(33,
                        function(html, tools) {
                             $('div#form-body').html(html);
                             $('div#content-body-action-tools').html(tools);
                        }, function(message) {
                             $('font#section_heading').empty();
                             $('div#form-body').empty();
                             alert(message);
                        },
                        year+'/'+month);
        }
        function on_print_clicked() {
            var year = $('input#year_field').val();
            var month = $('select#month_field option:selected').html();
            $('div#print_container_header')
                    .html('<font style="color:#21ACD7; font-size:20px; ">MONTHLY REPORT OF '+year+' '+month+'</font>');
            var html = $('div#content_table').html();
            $('div#print_container_body').html(html);  
            print();
            $('div#print_container_header').empty();
            $('div#print_container_body').empty();
            $('div#print_container_footer').empty();
        }
     </script>

    <?php 
    $form = ob_get_clean();
    return $form;
}
Beispiel #12
0
<?php

require_once 'common/init.php';
$form = array();
$form['bill_number'] = $bill_number;
$form['user_shift_number'] = $user_shift_number;
$form['user_terminal_point_number'] = $user_terminal_point_number;
$form['user_id'] = $_SESSION['user']->id;
$form['payment_mode'] = $_GET['payment_mode'];
// Sale Insert Disable for Main reason is first offers item and discounted prise final
// Report Print Section Completest
$sales = new sales();
$results = $sales->sale_insert($form);
if ($results) {
    //	echo 'Sucess';
} else {
    //	echo 'Error';
}
?>

<!DOCTYPE html>
<html>
<head>
	<meta charset="UTF-8">
	<title>Add Sale</title>
	<link href="assets/css/reset.css" rel="stylesheet">
	<link href="assets/css/general.css" rel="stylesheet">
	<link href="assets/css/bootstrap.css" rel="stylesheet">
	<link href="assets/css/bootstrap-theme.css" rel="stylesheet">
	<link href="assets/css/style.css" rel="stylesheet">
Beispiel #13
0
function get_form_html($form_id, $date)
{
    ob_start();
    ?>
    <div id="head_div" style="padding: 5px 0; background-color: #ECECEC;  color: #21ACD7;
         border-radius: 5px;margin-left: auto; text-align: center; ">
        SALES REPORT OF 
        <input id="date_field" value="<?php 
    if ($date == 0) {
        $date = date('d/m/Y', time());
    }
    echo $date;
    ?>
" />
    </div>
    <div style="margin-top: 10px; background-color:transparent;padding-bottom: 30px;">
        <style>
            div#purchace_items td{
                border: 1px solid #21ACD7;
            }
            div#purchace_items tbody td{
                padding: 5px 0 5px 5px;
            }
            div#purchace_items tbody td input,div#purchace_items tbody td select{
                padding: 0;
                border: 0;
                margin: 0;
                height: 100%;
                width: 100%;
                background-color: transparent;
            }
        </style>
        <div id="purchace_items" style="width: 100%; padding: 10px 0; color: #21ACD7;">           
            <table id="items_table" style="border-collapse: collapse; width: 100%; 
                   background-color: #fff; border-radius: 10px;  color: #21ACD7;">
                <thead style="text-align: center;">
                    <tr>
                        <td>
                            #
                        </td>
                        <td>
                            ID
                        </td>
                        <td>
                            DATE &amp; TIME
                        </td>
                        <td>
                            CUSTOMER
                        </td>
                        <td style="">
                            TAX
                        </td>
                        <td style="">
                            NET. AMOUNT
                        </td>
                        <td style="">
                            TOTAL
                        </td>
                        <td style="">

                        </td>
                    </tr>
                </thead>
                <tbody style="padding-left: 3px; text-align: center; ">
                    <?php 
    $sale_obj = new sales();
    $user = new user();
    $user->id = $_SESSION['user_id'];
    $user->getUser();
    $date = str_replace('/', '-', $date);
    $date = date('Y-m-d', strtotime($date));
    $sales = $sale_obj->getSalesOfADay($user->company_id, $date);
    $i = 0;
    if (is_array($sales) and count($sales) != 0) {
        foreach ($sales as $sale) {
            ?>
                        <tr id="<?php 
            echo $sale->id;
            ?>
" onclick="select_row(this)" status="not_selected"  >
                            <td style="text-align: center;">
                                <?php 
            echo ++$i;
            ?>
                            </td>
                            <td>
                                <?php 
            echo $sale->id;
            ?>
                            </td>
                            <?php 
            $date = date('d/m/Y', strtotime($sale->sale_at) + 5.5 * 60 * 60);
            $time = date('h:m A', strtotime($sale->sale_at) + 5.5 * 60 * 60);
            ?>
                            <td id="date" date="<?php 
            echo $date;
            ?>
" time="<?php 
            echo $time;
            ?>
">
                                <?php 
            echo $date . ' - ' . $time;
            ?>
                            </td>
                            <?php 
            $customer = new customer();
            $customer->id = $sale->customer_id;
            $customer->getCustomer();
            ?>
                            <td id="customer" c_name="<?php 
            echo $customer->customer_name;
            ?>
" c_id="<?php 
            echo $customer->id;
            ?>
" >
                                <?php 
            echo $customer->customer_name . ' ( ID : ' . $customer->id . ' )';
            ?>
                            </td>
                            <td id="tax">
                                <?php 
            echo $sale->tax_amount;
            ?>
                            </td>
                            <td id="net_amount">
                                <?php 
            echo $sale->net_amount;
            ?>
                            </td>
                            <td id="total">
                                <?php 
            echo $sale->amount;
            ?>
                            </td>
                            <td id="down_button" style="width: 20px;text-align: center; padding: 10px;">
                                <img id="toggle_button" style="width: 20px; height: 20px; cursor: pointer;"
                                     onclick="toggle_items_visibility(this)" src="../ui/images/down_arrow.png"/>
                                <img id="toggle_button" style="width: 20px; height: 20px; cursor: pointer; display: none;"
                                     onclick="toggle_items_visibility(this)" src="../ui/images/up_arrow.png"/>
                            </td>
                        </tr>
                        <tr style="display: none;">
                            <td colspan="8" style="padding:0 0 20px 0;">
                                <table  id="sale_items" style="border-collapse: collapse; background-color: #c0effd; width: 80%; color: #21ACD7; float: right;">
                                    <thead>
                                    <tr>
                                        <td>
                                            ITEM
                                        </td>
                                        <td>
                                            QUANTITY
                                        </td>
                                        <td>
                                            RATE
                                        </td>
                                        <td>
                                            NET. AMOUNT
                                        </td>
                                        <td>
                                            TAX
                                        </td>
                                        <td>
                                            TOTAL
                                        </td>
                                    </tr>
                                </thead>
                                    <tbody>
                                    <?php 
            if (is_array($sale->getSalesItems()) and count($sale->getSalesItems())) {
                foreach ($sale->getSalesItems() as $s_item) {
                    ?>
                                    <tr id="<?php 
                    echo $s_item->id;
                    ?>
">
                                        <?php 
                    $item = new item();
                    $item->id = $s_item->item_id;
                    $item->getItem();
                    ?>
                                            <td id="item" item_name="<?php 
                    echo $item->item_name;
                    ?>
"><?php 
                    echo $item->item_name . ' - ' . $item->item_code;
                    ?>
</td>
                                            <td id="quantity" val="<?php 
                    echo $s_item->quantity;
                    ?>
">
                                                <?php 
                    echo number_format($s_item->quantity, 3, '.', '');
                    ?>
                                            </td>
                                            <td id="rate" val="<?php 
                    echo $s_item->rate;
                    ?>
">
                                                <?php 
                    echo number_format($s_item->rate, 2, '.', '');
                    ?>
                                            </td>                                            
                                            <td>
                                                <?php 
                    echo number_format($s_item->quantity * $s_item->rate - $s_item->tax, 2, '.', '');
                    ?>
                                            </td>    
                                            <?php 
                    $tax_category = new tax_category();
                    $tax_category->id = $item->tax_category_id;
                    $tax_category->getTaxCategory();
                    ?>
                                            <td id="tax" val="<?php 
                    echo $s_item->tax;
                    ?>
" tax_rate="<?php 
                    echo $tax_category->tax_percentage;
                    ?>
">
                                                <?php 
                    echo number_format($s_item->tax, 2, '.', '');
                    ?>
                                            </td>
                                            <td id="total" val="<?php 
                    echo $s_item->quantity * $s_item->rate;
                    ?>
">
                                                <?php 
                    echo number_format($s_item->quantity * $s_item->rate, 2, '.', '');
                    ?>
                                            </td>
                                        </tr>
                                        <?php 
                }
            } else {
                echo '<tr><td colspan="6">No item found</td></tr>';
            }
            ?>
                                        </tbody>
                                </table>
                            </td>
                        </tr>
                        <?php 
        }
    } else {
        echo '<tr><td colspan="8"> No Sales Found </td></tr>';
    }
    ?>
                </tbody>                               
            </table>
        </div>
    </div>
    <script type="text/javascript">
        function load_sales_report(){
            var date = $('input#date_field').val();
            get_form(15,
                        function(html, tools) {
                             $('div#form-body').html(html);
                             $('div#content-body-action-tools').html(tools);
                        }, function(message) {
                             $('font#section_heading').empty();
                             $('div#form-body').empty();
                             alert(message);
                        },
                        date);
        }
        function toggle_items_visibility(down_button) {
            var row = $(down_button).closest('tr');
            row.next('tr').fadeToggle();
            row.find('img#toggle_button').toggle();
            
        }
        function on_print_clicked() {
            var selected_row = $('tr[status="selected"]');
            var sale_items_table = selected_row.next('tr').find('table#sale_items');
            var sale_items = sale_items_table.find('tbody').children();
            var items = new Array();
            var i = 0;
            sale_items.each(function() {
                var item_name = $(this).find('td#item').attr('item_name');
                var id = $(this).attr('id');
                var quantity = $(this).find('td#quantity').attr('val');
                var rate = $(this).find('td#rate').attr('val');
                var tax = $(this).find('td#tax').attr('val');
                var total = $(this).find('td#total').attr('val');
                total = parseFloat(total);
                total = total.toFixed(2);
                var item = {
                     id: id,
                     quantity: quantity,
                     rate: rate,
                     item_name: item_name,
                     total: total,
                     tax: tax
                }
                items[i++] = item;
             });
             var c_name = selected_row.find('td#customer').attr('c_name');
             var c_id = selected_row.find('td#customer').attr('c_id');
             if(c_id == 0){
                 c_name = 'Not Regd.';
             }
             var sale_id = selected_row.attr('id');
             var total = selected_row.find('td#total').html();
             total = parseFloat(total);
             total = total.toFixed(2);
             var total_tax = selected_row.find('td#tax').html();
             total_tax = parseFloat(total_tax);
             total_tax = total_tax.toFixed(2);
             var net_total = selected_row.find('td#net_amount').html();
             net_total = parseFloat(net_total);
             net_total = net_total.toFixed(2);             
             var date = selected_row.find('td#date').attr('date');
             var time = selected_row.find('td#date').attr('time');
             var data = {
                  customer_id: c_id,
                  total: total,
                  net_amount: net_total,
                  tax_amount: total_tax,
                  items: items,
                  date: date,
                  time: time
             }
             print_bill(data, c_name, sale_id);
        }
        function print_bill(data, customer_name, sale_id) {
                var html = '';
                html ='<img id="logo_bill" src="images/nutiez.png"/><br/><font id="print_container_header_company_adderss">Royal Piknik Traders LLP, 29/861</font>'
                        +'<br/><font id="print_container_header_company_adderss">Parayancheri, Calicut</font><br/><font id="print_container_header_company_adderss">'
                        +'Phone : 0495 2741095,+91 9388627725</font><br/><font id="print_container_header_company_adderss">The kerala value added tax rules 2005/ form no. 8</font>'
                        +'<br/><font id="print_container_header_company_adderss">Tin : 32110844692</font>'
                        +'<br/><font id="print_container_header_company_adderss">True Copy</font>';
                $('div#print_container_header').html(html);
                html = '';

                html = html + "<div<!-- style=\"padding:10px 0;\"><table style=\"float:right;font-size: 12px;\">"
                        +"<tr><td>Date</td><td>:</td><td style=\"text-align:right;\">" + data.date + "</td></tr>"
                        +"<tr><td>Time</td><td>:</td><td style=\"text-align:right;\">" + data.time + "</td></tr></table>";
                
                html = html + "<table style=\"font-size: 12px;\">"
                        +"<tr><td>Bill No.</td><td>:</td><td>" + sale_id + "</td></tr>"
                        +"<tr><td>Cust. ID</td><td>:</td><td>" + data.customer_id + "</td></tr>"
                        +"<tr><td>Cust. Name</td><td>:</td><td>" + customer_name + "</td></tr></table></div>";
                
                html = html + "<div style=\"border-top:1px dashed #000; margin:10px auto 0 auto;padding:0 0 10px 0;\">"
                        + "<table style=\"width:100%;font-size: 12px;\"><tr style=\"border-bottom: 1px solid #000; border-top: 1px solid #000;\">"
                        + "<td style=\"width:45%; border-bottom:1px dashed #000; padding-bottom:5px; margin-bottom:5px;\">Description</td>"
                        + "<td style=\"width:17%; border-bottom:1px dashed #000; padding-bottom:5px; margin-bottom:5px; text-align:right;\">Qty</td>"
                        + "<td style=\"width:17%; border-bottom:1px dashed #000; padding-bottom:5px; margin-bottom:5px; text-align:right;\">Rate</td>"
                        // + "<td style=\"width:15%; border-bottom:1px dashed #000; padding-bottom:5px; margin-bottom:5px; text-align:right;\">Amount</td>"
                        // + "<td style=\"width:10%; border-bottom:1px dashed #000; padding-bottom:5px; margin-bottom:5px; text-align:right;\">Tax</td>"
                        + "<td style=\"width:21%; border-bottom:1px dashed #000; padding-bottom:5px; margin-bottom:5px; text-align:right;\">Total</td></tr>";
                var i = 0;
                for (var key in data.items) {
                    var item = data.items[key];
                    html = html + "<tr><td>" + item.item_name + "</td>"
                            +"<td style=\"text-align:right;\">" + parseFloat(item.quantity).toFixed(3) + "</td>"
                            +"<td style=\"text-align:right;\">" + parseFloat(item.rate).toFixed(2) + "</td>"
                            //+"<td style=\"text-align:right;\">" + (parseFloat(item.total) - parseFloat(item.tax)) + "</td>"
//                            +"<td style=\"text-align:right;\">" + item.tax + "</td>"
                            +"<td style=\"text-align:right;\">" + parseFloat(item.total).toFixed(2) + "</td>"
                            +"</tr>";
                }
                html = html + "</table></div>";
                html = html + "<div style=\"border-top:1px dashed #000; padding:10px 0;\"><table style=\"margin-left: auto;font-size: 12px;\">";
                html = html + "<tr><td>Net. Amount</td><td style=\"margin:0 15;\">:</td><td style=\"text-align:right;\">" + data.net_amount + "</td></tr>";
                html = html + "<tr><td>Tax</td><td style=\"margin:0 15;\">:</td><td style=\"text-align:right;\">" + data.tax_amount + "</td></tr>";
                html = html + "<tr style=\"font-size:18px;\"><td><b>Total</b></td><td style=\"margin:0 15;\">:</td><td style=\"text-align:right;\"><b>" + data.total + "</b></td></tr>";
                html = html + "</table></div>";
//                console.log("Creating bill : " + html);
                $('div#print_container_body').html(html);
                html = '';
                html = '<font>Thank you for shoping</font><br/><font>Visit again...</font> ';
                $('div#print_container_footer').html(html);
                print();
                $('div#print_container_header').empty();
                $('div#print_container_body').empty();
                $('div#print_container_footer').empty();
            }
        function select_row(row) {
            var j_row = $(row);
            if(j_row.attr('status') == 'selected'){
                $('table#items_table tr').attr('status', 'not_selected');
                $('table#items_table tr').css('background-color', '#FFF');
                $('img#edit').css('display', 'none');
                $('img#edit_fade').css('display', 'block');
                $('img#print').css('display', 'none');
                $('img#print_fade').css('display', 'block');
            }else{            
                $('table#items_table tr').attr('status', 'not_selected');
                $('table#items_table tr').css('background-color', '#FFF');
                j_row.attr('status', 'selected');
                j_row.css('background-color', '#C0EFFD');
                $('img#edit').css('display', 'block');
                $('img#edit_fade').css('display', 'none');
                $('img#print').css('display', 'block');
                $('img#print_fade').css('display', 'none');
            }          
        }
        function setup_datepicker(){
           $('input#date_field').datepick({
               minDate:'26/04/2015', 
               dateFormat:'dd/mm/yyyy',
               maxDate:'0',
               onSelect:function(){
                    load_sales_report();
                }
           });
       }
       setup_datepicker();
    </script>

    <?php 
    $form = ob_get_clean();
    return $form;
}
Beispiel #14
0
function get_form_html($form_id, $date)
{
    ob_start();
    ?>
    <div id="head_div" style="padding: 5px 0; background-color: #ECECEC;  color: #21ACD7;
         border-radius: 5px;margin-left: auto; text-align: center; ">
        DAY END REPORT OF 
        <input id="date_field" value="<?php 
    if ($date == 0) {
        $date = date('d/m/Y', time());
    }
    echo $date;
    ?>
" />
    </div>
    <div id="sales_items_table" style="margin-top: 10px; background-color:transparent;padding-bottom: 30px;">
        <style>
            div#purchace_items td{
                border: 1px solid #21ACD7;
            }
            div#purchace_items tbody td{
                padding: 5px 0 5px 5px;
            }
            div#purchace_items tbody td input,div#purchace_items tbody td select{
                padding: 0;
                border: 0;
                margin: 0;
                height: 100%;
                width: 100%;
                background-color: transparent;
            }
        </style>
        <div id="purchace_items" style="width: 100%; padding: 10px 0; color: #21ACD7;">           
            <table id="sales_items_table" style="border-collapse: collapse; width: 100%; 
                   background-color: #fff; border-radius: 10px;  color: #21ACD7;">
                <thead style="text-align: center;">
                    <tr>
                        <td style="width: 5%;">
                            #
                        </td>
                        <td>
                            SHOP
                        </td>
                        <td style="width: 25%;">
                            INCOME (SALES)
                        </td>
                        <td style="width: 25%;">
                            EXPENSE (PURCHASE) 
                        </td>
                    </tr>
                </thead>
                <tbody style="padding-left: 3px; text-align: center; ">
                    <?php 
    $total_income = 0;
    $total_expense = 0;
    //                    $sale_item = new sales_items();
    //                    $user = new user();
    //                    $user->id = $_SESSION['user_id'];
    //                    $user->getUser();
    $date = str_replace('/', '-', $date);
    $date = date('Y-m-d', strtotime($date));
    $shop = new company();
    $shops = $shop->getCompanies();
    $i = 0;
    if (is_array($shops) and count($shops)) {
        foreach ($shops as $shop) {
            $sale = new sales();
            $sale_income_for_this_shop = $sale->getOneDaySaleIncome($shop->id, $date);
            $total_income += $sale_income_for_this_shop['amount'];
            $purchace = new purchaces();
            $purchace_expence_for_this_shop = $purchace->getOneDayPurchaseExpence($shop->id, $date);
            $total_expense += $purchace_expence_for_this_shop['amount'];
            ?>
                            <tr>
                                <td style="text-align: center;">
                                    <?php 
            echo ++$i;
            ?>
                                </td>
                                <td style="text-align: left;">
                                    <?php 
            echo $shop->company_name . ' - ' . $shop->company_code;
            ?>
                                </td>
                                <td>
                                    <?php 
            echo number_format($sale_income_for_this_shop['amount'], 2, '.', '');
            ?>
                                </td>

                                <td id="tax">
                                    <?php 
            echo number_format($purchace_expence_for_this_shop['amount'], 2, '.', '');
            ?>
                                </td>
                            </tr>
                            <?php 
        }
    } else {
        echo '<tr><td colspan="8"> No Shop Found </td></tr>';
    }
    ?>
                    <tr>
                        <td></td>
                        <td style="text-align: right;"> TOTAL </td>
                        <td><?php 
    echo number_format($total_income, 2, '.', '');
    ?>
</td>
                        <td><?php 
    echo number_format($total_expense, 2, '.', '');
    ?>
</td>
                    </tr>
                </tbody>                               
            </table>
        </div>
    </div>
    <script type="text/javascript">
        function load_day_end_report() {
            var date = $('input#date_field').val();
            get_form(40,
                    function(html, tools) {
                        $('div#form-body').html(html);
                        $('div#content-body-action-tools').html(tools);
                    }, function(message) {
                $('font#section_heading').empty();
                $('div#form-body').empty();
                alert(message);
            },
                    date);
        }
        function on_print_clicked() {
            var date = $('input#date_field').val();
            var header = '<font style="color:#21ACD7; font-size:20px; ">Nutiez</font>'
                            +'<br/><br/>'
                            +'<font style="color:#21ACD7; font-size:20px; ">BALANCE SHEET OF ' + date + '</font>';
            $('div#print_container_header')
                    .html(header);
            var html = $('div#sales_items_table').html();
            $('div#print_container_body').html(html);
            print();
            $('div#print_container_header').empty();
            $('div#print_container_body').empty();
            $('div#print_container_footer').empty();
        }
        function setup_datepicker() {
            $('input#date_field').datepick({
                minDate: '26/04/2015',
                dateFormat: 'dd/mm/yyyy',
                maxDate: '0',
                onSelect: function() {
                    load_day_end_report();
                }
            });
        }
        setup_datepicker();
    </script>

    <?php 
    $form = ob_get_clean();
    return $form;
}