Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- include_once ('dbconn.php');
- //$store_id = intval($_SESSION["store_id"]);
- $is_new = intval($_SESSION["is_new"]);
- $name = $_SESSION["user_full_name"];
- $group_id = $_SESSION["customer_id"];
- if ( $_SESSION['auth_type'] == 'SYS-ADMIN')
- $query = "select DISTINCT sm.* from store_master sm INNER JOIN view_stocktake_master vsm ON vsm.store_id = sm.id order by vsm.stock_date desc";
- //print_r($_SESSION);
- else
- $query = "select * from store_master where customer_id = '$group_id' order by store_name desc";
- //echo $query;
- $retval = f_select_query($query, $datarows);
- $store_id = 0;
- if ($retval == -1 )
- {
- $connected = false;
- }
- if ($is_new == 1)
- {
- }
- $rowcount = count($datarows);
- //echo $query;
- //print_r ($datarows);
- ?>
- <script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
- <div id="this_form_id" class="container-fluid box-grid " >
- <div class="row">
- <div class="col-sm-2 col-xs-12">
- <div class="homepage_blocks">
- <div class="container-fluid content_container" >
- <div class="row">
- <div class="title clearfix">
- <span class="text-primary">List of Stores </span><br>
- </div>
- <?
- //echo $group_id;
- for ($counter = 0; $counter< $rowcount; $counter++)
- {
- $store_id1 = $datarows[$counter]->id;
- $query1 = "select * from view_stocktake_master where store_id = $store_id1 order by stock_date desc limit 1";
- //echo $query1;
- $retval = f_select_query($query1, $datarows1);
- $query2 = "select id from view_stocktake_master where store_id = $store_id1 order by stock_date desc limit 1";
- $retval = f_read_column('id', $query2, $stocktake_id);
- $query3 = "select sum((quantity * unit_of_measure) + quantity_units) as total_quantity, sum((quantity * full_cost) + (quantity_units * unit_cost)) as total_cost from stocktake_details where stocktake_id = $stocktake_id and location_id in (select id from stocktake_locations where is_completed = 1 and stocktake_id = $stocktake_id)";
- $retval = f_select_query($query3, $datarows3);
- //print_r ($datarows3);
- //print_r ($datarows1);
- if ($datarows3[0]->total_cost == 0)
- { ?>
- <div class="col-lg-12 col-md-1 col-sm-1 col-xs-1 stat-container" id ="stores">
- <div class="dashboard-stat red-stat " >
- <div class="visual" id="<? echo $datarows[$counter]->id; ?>">
- </div>
- <div class="details " id="<? echo $datarows[$counter]->id; ?>">
- <div style="text-align: center; margin-top: 7px; font-size: 10px;" class="more" id="<? echo $datarows[$counter]->id; ?>">
- <? echo $datarows[$counter]->store_name; ?>
- </div>
- <div style="text-align: center; margin-top: 7px; font-size: 12px;" class="desc" id="<? echo $datarows[$counter]->id; ?>">
- Date: <? echo $datarows1[0]->stock_date_str; ?></br> Cost: €<? echo number_format($datarows3[0]->total_cost,2); ?>
- </div>
- </div>
- </div>
- </div> <?
- }
- else
- {
- ?>
- <div class="col-lg-12 col-md-1 col-sm-1 col-xs-1 stat-container" id ="stores">
- <div class="dashboard-stat blue-stat " >
- <div class="visual" id="<? echo $datarows[$counter]->id; ?>">
- </div>
- <div class="details " id="<? echo $datarows[$counter]->id; ?>">
- <div style="text-align: center; margin-top: 7px; font-size: 10px;" class="more" id="<? echo $datarows[$counter]->id; ?>">
- <? echo $datarows[$counter]->store_name; ?>
- </div>
- <div style="text-align: center; margin-top: 7px; font-size: 12px;" class="desc" id="<? echo $datarows[$counter]->id; ?>">
- Date: <? echo $datarows1[0]->stock_date_str; ?></br> Cost: €<? echo number_format($datarows3[0]->total_cost,2); ?>
- </div>
- </div>
- </div>
- </div>
- <?php
- }
- }
- ?>
- </div>
- </div>
- </div>
- </div>
- <div class="col-sm-10 col-xs-12" id="tableDiv">
- <div class="homepage_blocks" id="leaderBoard">
- <div class="container-fluid content_container" >
- <div class="row">
- <div class="title clearfix">
- <span class="text-primary">Leader Board </span><br>
- </div>
- </div>
- </div>
- <table style=' height:10px; margin: 0 auto; width: 1150px;' id="tbl_leader_board" class="table table-fixed table-striped table-bordered datalist" cellspacing="0">
- <thead>
- <tr >
- <th style='width:8%;'> Date </th>
- <th style='width:15%;'> Store Name </th>
- <th style='width:8%;'> City </th>
- <th style='width:10%;'> Opening Stock </th>
- <th style='width:6%;'> Wastage </th>
- <th style='width:6%;'> Purchases </th>
- <th style='width:6%;'> Sales </th>
- <th style='width:10%;'> Closing Stock </th>
- <th style='width:7%;'> GP (%) </th>
- <th style='width:11%;'> Previous GP (%) </th>
- </tr>
- </thead>
- <tbody>
- <?
- for ($counter = 0; $counter< $rowcount; $counter++)
- {
- $store_id1 = $datarows[$counter]->id;
- $store_name = $datarows[$counter]->store_name;
- $store_city = $datarows[$counter]->location_city;
- $query = "select id AS stocktake_id, stock_date_str as stock_date FROM view_stocktake_master WHERE store_id = '$store_id1' ORDER BY stocktake_id DESC LIMIT 1";
- //echo $query;
- $retval = f_read_column('stocktake_id', $query, $stocktake_id);
- $retval = f_read_column('stock_date', $query, $stock_date);
- $query_total_cost = "select sum(`stocktake_details`.`quantity_units` * `stocktake_details`.`unit_cost`) AS `total_cost`
- from `stocktake_details` INNER JOIN stocktake_locations on stocktake_details.location_id = stocktake_locations.id where `stocktake_details`.`stocktake_id` = '$stocktake_id'
- AND stocktake_locations.stocktake_id = '$stocktake_id' and stocktake_locations.is_completed != 0 group by stocktake_locations.stocktake_id";
- $retval = f_read_column('total_cost', $query_total_cost, $closing_stock);
- if ($closing_stock == "0.00")
- {
- $query = "select id AS stocktake_id, stock_date_str as stock_date FROM view_stocktake_master WHERE store_id = '$store_id1' AND stock_date < DATE(NOW()) ORDER BY stocktake_id DESC LIMIT 1";
- $retval = f_read_column('stocktake_id', $query, $stocktake_id);
- $retval = f_read_column('stock_date', $query, $stock_date);
- $query_total_cost = "select sum(`stocktake_details`.`quantity_units` * `stocktake_details`.`unit_cost`) AS `total_cost`
- from `stocktake_details` INNER JOIN stocktake_locations on stocktake_details.location_id = stocktake_locations.id where `stocktake_details`.`stocktake_id` = '$stocktake_id'
- AND stocktake_locations.stocktake_id = '$stocktake_id' and stocktake_locations.is_completed != 0 group by stocktake_locations.stocktake_id";
- $retval = f_read_column('total_cost', $query_total_cost, $closing_stock);
- $query_total_purchases = "select sum(`store_purchases`.`cost_value`) AS `total_purchases` from `store_purchases` where `store_purchases`.`stocktake_id` = '$stocktake_id' ;";
- $retval = f_read_column('total_purchases', $query_total_purchases, $purchases);
- $query_total_wastage = "select sum(`store_wastage`.`wastage_amount`) AS `total_wastage` from `store_wastage` where `store_wastage`.`stocktake_id` = '$stocktake_id'; ";
- $retval = f_read_column('total_wastage', $query_total_wastage, $wastage);
- $query_total_sales = "select sum(`store_sales`.`sale_at_cost`) AS `total_sales` from `store_sales` where `store_sales`.`stocktake_id` = '$stocktake_id'; ";
- $retval = f_read_column('total_sales', $query_total_sales,$sales);
- $query_total_labour = "select sum(`labour_costs`.`cost`) AS `total_labour` from `labour_costs` where `labour_costs`.`stocktake_id` = '$stocktake_id'; ";
- $retval = f_read_column('total_labour', $query_total_labour,$labour);
- $query = "select id from view_stocktake_master where store_id = $store_id1 AND id < '$stocktake_id' order by stock_date desc limit 1";
- $retval = f_read_column('id', $query, $stocktake_id_prev);
- $query_total_opening = "select sum(`stocktake_details`.`quantity_units` * `stocktake_details`.`unit_cost`) AS `total_cost`
- from `stocktake_details` INNER JOIN stocktake_locations on stocktake_details.location_id = stocktake_locations.id where `stocktake_details`.`stocktake_id` = '$stocktake_id_prev'
- AND stocktake_locations.stocktake_id = '$stocktake_id_prev' and stocktake_locations.is_completed != 0 group by stocktake_locations.stocktake_id LIMIT 1";
- $retval = f_read_column('total_cost', $query_total_opening, $opening_stock);
- }
- else {
- $query_total_purchases = "select sum(`store_purchases`.`cost_value`) AS `total_purchases` from `store_purchases` where `store_purchases`.`stocktake_id` = '$stocktake_id' ;";
- $retval = f_read_column('total_purchases', $query_total_purchases, $purchases);
- $query_total_wastage = "select sum(`store_wastage`.`wastage_amount`) AS `total_wastage` from `store_wastage` where `store_wastage`.`stocktake_id` = '$stocktake_id'; ";
- $retval = f_read_column('total_wastage', $query_total_wastage, $wastage);
- $query_total_sales = "select sum(`store_sales`.`sale_at_cost`) AS `total_sales` from `store_sales` where `store_sales`.`stocktake_id` = '$stocktake_id'; ";
- $retval = f_read_column('total_sales', $query_total_sales,$sales);
- $query_total_labour = "select sum(`labour_costs`.`cost`) AS `total_labour` from `labour_costs` where `labour_costs`.`stocktake_id` = '$stocktake_id'; ";
- $retval = f_read_column('total_labour', $query_total_labour,$labour);
- $query = "select id from view_stocktake_master where store_id = $store_id1 AND id < '$stocktake_id' order by stock_date desc limit 1";
- $retval = f_read_column('id', $query, $stocktake_id_prev);
- $query_total_opening = "select sum(`stocktake_details`.`quantity_units` * `stocktake_details`.`unit_cost`) AS `total_cost`
- from `stocktake_details` INNER JOIN stocktake_locations on stocktake_details.location_id = stocktake_locations.id where `stocktake_details`.`stocktake_id` = '$stocktake_id_prev'
- AND stocktake_locations.stocktake_id = '$stocktake_id_prev' and stocktake_locations.is_completed != 0 group by stocktake_locations.stocktake_id LIMIT 1";
- $retval = f_read_column('total_cost', $query_total_opening, $opening_stock);
- }
- if ($sales == '')
- $sales = 0;
- if ($purchases == '')
- $purchases = 0;
- if ($wastage == '')
- $wastage = 0;
- if ($labour == '')
- $labour = 0;
- if ($opening_stock == '')
- {
- $opening_stock = 0;
- }
- $query = "select include_labour FROM store_master where id = $store_id1 ;";
- $retval = f_read_column('include_labour', $query, $include_labour);
- $query = "select include_wastage FROM store_master where id = $store_id1 ;";
- $retval = f_read_column('include_wastage', $query, $include_waste);
- if ($include_waste == 1 && $include_labour == 0)
- $consumption_cost = $opening_stock + $purchases + $wastage - $closing_stock;
- else if ($include_waste == 0 && $include_labour == 1)
- $consumption_cost = $opening_stock + $purchases + $labour - $closing_stock;
- else if ($include_waste == 0 && $include_labour == 0)
- $consumption_cost = $opening_stock + $purchases - $closing_stock;
- else
- $consumption_cost = $opening_stock + $purchases + $wastage + $labour - $closing_stock;
- $gp = $sales - $consumption_cost;
- if($gp == 0)
- $gp_per = 0;
- else
- $gp_per = ($gp/$sales) * 100;
- if ($gp_per < 0 || $gp_per == INF)
- $gp_per = 0;
- if ($wastage == NULL)
- $wastage = 0;
- if ($purchases == NULL)
- $purchases = 0;
- if ($sales == NULL)
- $sales = 0;
- $gp_per_displ = number_format($gp_per,2);
- echo "<tr> ";
- echo "<td class='details-control' style='text-align:center'>$stock_date</td>";
- echo "<td style='text-align:center'>$store_name</td>";
- echo "<td style='text-align:center'>$store_city</td>";
- echo "<td style='text-align:center'>$global_currency_sign ".number_format($opening_stock,2)."</td>";
- echo "<td style='text-align:center'>$global_currency_sign ".number_format($wastage,2)."</td>";
- echo "<td style='text-align:center'>$global_currency_sign ".number_format($purchases,2)."</td>";
- echo "<td style='text-align:center'>$global_currency_sign ".number_format($sales,2)."</td>";
- echo "<td style='text-align:center'>$global_currency_sign ".number_format($closing_stock,2)."</td>";
- $query_total_cost = "select sum(`stocktake_details`.`quantity_units` * `stocktake_details`.`unit_cost`) AS `total_cost`
- from `stocktake_details` INNER JOIN stocktake_locations on stocktake_details.location_id = stocktake_locations.id where `stocktake_details`.`stocktake_id` = '$stocktake_id_prev'
- AND stocktake_locations.stocktake_id = '$stocktake_id_prev' and stocktake_locations.is_completed != 0 group by stocktake_locations.stocktake_id";
- $retval = f_read_column('total_cost', $query_total_cost, $closing_stock);
- $query_total_purchases = "select sum(`store_purchases`.`cost_value`) AS `total_purchases` from `store_purchases` where `store_purchases`.`stocktake_id` = '$stocktake_id_prev' ;";
- $retval = f_read_column('total_purchases', $query_total_purchases, $purchases);
- $query_total_wastage = "select sum(`store_wastage`.`wastage_amount`) AS `total_wastage` from `store_wastage` where `store_wastage`.`stocktake_id` = '$stocktake_id_prev'; ";
- $retval = f_read_column('total_wastage', $query_total_wastage, $wastage);
- $query_total_sales = "select sum(`store_sales`.`sale_at_cost`) AS `total_sales` from `store_sales` where `store_sales`.`stocktake_id` = '$stocktake_id_prev'; ";
- $retval = f_read_column('total_sales', $query_total_sales,$sales);
- $query_total_labour = "select sum(`labour_costs`.`cost`) AS `total_labour` from `labour_costs` where `labour_costs`.`stocktake_id` = '$stocktake_id_prev'; ";
- $retval = f_read_column('total_labour', $query_total_labour,$labour);
- $query = "select id from view_stocktake_master where store_id = $store_id1 AND id < '$stocktake_id_prev' order by stock_date desc limit 1";
- $retval = f_read_column('id', $query, $stocktake_id_prev_prev);
- $query_total_opening = "select sum(`stocktake_details`.`quantity_units` * `stocktake_details`.`unit_cost`) AS `total_cost`
- from `stocktake_details` INNER JOIN stocktake_locations on stocktake_details.location_id = stocktake_locations.id where `stocktake_details`.`stocktake_id` = '$stocktake_id_prev_prev'
- AND stocktake_locations.stocktake_id = '$stocktake_id_prev_prev' and stocktake_locations.is_completed != 0 group by stocktake_locations.stocktake_id LIMIT 1";
- $retval = f_read_column('total_cost', $query_total_opening, $opening_stock);
- if ($sales == '')
- $sales = 0;
- if ($purchases == '')
- $purchases = 0;
- if ($wastage == '')
- $wastage = 0;
- if ($labour == '')
- $labour = 0;
- if ($opening_stock == '')
- {
- $opening_stock = 0;
- }
- $query = "select include_labour FROM store_master where id = $store_id1 ;";
- $retval = f_read_column('include_labour', $query, $include_labour);
- $query = "select include_wastage FROM store_master where id = $store_id1 ;";
- $retval = f_read_column('include_wastage', $query, $include_waste);
- if ($include_waste == 1 && $include_labour == 0)
- $consumption_cost = $opening_stock + $purchases + $wastage - $closing_stock;
- else if ($include_waste == 0 && $include_labour == 1)
- $consumption_cost = $opening_stock + $purchases + $labour - $closing_stock;
- else if ($include_waste == 0 && $include_labour == 0)
- $consumption_cost = $opening_stock + $purchases - $closing_stock;
- else
- $consumption_cost = $opening_stock + $purchases + $wastage + $labour - $closing_stock;
- $gp = $sales - $consumption_cost;
- if($gp == 0)
- $gp_per = 0;
- else
- $gp_per = ($gp/$sales) * 100;
- if ($gp_per < 0 || $gp_per == INF)
- $gp_per = 0;
- if ($wastage == NULL)
- $wastage = 0;
- if ($purchases == NULL)
- $purchases = 0;
- if ($sales == NULL)
- $sales = 0;
- $gp_per_displ_prev = number_format($gp_per,2);
- if ($gp_per_displ > $gp_per_displ_prev)
- echo "<td style='text-align:center'>".$gp_per_displ."% <i class='fa fa-arrow-up fa-md' style='color:green'></i></td>";
- else
- echo "<td style='text-align:center'>".$gp_per_displ."% <i class='fa fa-arrow-down fa-md' style='color:red'></i></td>";
- echo "<td style='text-align:center'>".$gp_per_displ_prev."%</td>";
- echo "</tr> ";
- $query1 = "select id AS stocktake_id, stock_date_str as stock_date FROM view_stocktake_master WHERE store_id = '$store_id1' AND id < $stocktake_id ORDER BY stocktake_id DESC LIMIT 3";
- $retval = f_select_query($query1, $datarows1);
- $rowCountNew = count($datarows1);
- for ($counter1 = 0; $counter1< $rowCountNew; $counter1++)
- {
- $stocktake_id = $datarows1[$counter1]->stocktake_id;
- $stock_date = $datarows1[$counter1]->stock_date;
- //echo $stocktake_id . '<br/>';
- $query_total_cost = "select sum(`stocktake_details`.`quantity_units` * `stocktake_details`.`unit_cost`) AS `total_cost`
- from `stocktake_details` INNER JOIN stocktake_locations on stocktake_details.location_id = stocktake_locations.id where `stocktake_details`.`stocktake_id` = '$stocktake_id'
- AND stocktake_locations.stocktake_id = '$stocktake_id' and stocktake_locations.is_completed != 0 group by stocktake_locations.stocktake_id";
- $retval = f_read_column('total_cost', $query_total_cost, $closing_stock);
- if ($closing_stock == "0.00")
- {
- $query = "select id AS stocktake_id, stock_date_str as stock_date FROM view_stocktake_master WHERE store_id = '$store_id1' AND stock_date < DATE(NOW()) ORDER BY stocktake_id DESC LIMIT 1";
- $retval = f_read_column('stocktake_id', $query, $stocktake_id);
- $retval = f_read_column('stock_date', $query, $stock_date);
- $query_total_cost = "select sum(`stocktake_details`.`quantity_units` * `stocktake_details`.`unit_cost`) AS `total_cost`
- from `stocktake_details` INNER JOIN stocktake_locations on stocktake_details.location_id = stocktake_locations.id where `stocktake_details`.`stocktake_id` = '$stocktake_id'
- AND stocktake_locations.stocktake_id = '$stocktake_id' and stocktake_locations.is_completed != 0 group by stocktake_locations.stocktake_id";
- $retval = f_read_column('total_cost', $query_total_cost, $closing_stock);
- $query_total_purchases = "select sum(`store_purchases`.`cost_value`) AS `total_purchases` from `store_purchases` where `store_purchases`.`stocktake_id` = '$stocktake_id' ;";
- $retval = f_read_column('total_purchases', $query_total_purchases, $purchases);
- $query_total_wastage = "select sum(`store_wastage`.`wastage_amount`) AS `total_wastage` from `store_wastage` where `store_wastage`.`stocktake_id` = '$stocktake_id'; ";
- $retval = f_read_column('total_wastage', $query_total_wastage, $wastage);
- $query_total_sales = "select sum(`store_sales`.`sale_at_cost`) AS `total_sales` from `store_sales` where `store_sales`.`stocktake_id` = '$stocktake_id'; ";
- $retval = f_read_column('total_sales', $query_total_sales,$sales);
- $query_total_labour = "select sum(`labour_costs`.`cost`) AS `total_labour` from `labour_costs` where `labour_costs`.`stocktake_id` = '$stocktake_id'; ";
- $retval = f_read_column('total_labour', $query_total_labour,$labour);
- $query = "select id from view_stocktake_master where store_id = $store_id1 AND id < '$stocktake_id' order by stock_date desc limit 1";
- $retval = f_read_column('id', $query, $stocktake_id_prev);
- $query_total_opening = "select sum(`stocktake_details`.`quantity_units` * `stocktake_details`.`unit_cost`) AS `total_cost`
- from `stocktake_details` INNER JOIN stocktake_locations on stocktake_details.location_id = stocktake_locations.id where `stocktake_details`.`stocktake_id` = '$stocktake_id_prev'
- AND stocktake_locations.stocktake_id = '$stocktake_id_prev' and stocktake_locations.is_completed != 0 group by stocktake_locations.stocktake_id LIMIT 1";
- $retval = f_read_column('total_cost', $query_total_opening, $opening_stock);
- }
- else {
- $query_total_purchases = "select sum(`store_purchases`.`cost_value`) AS `total_purchases` from `store_purchases` where `store_purchases`.`stocktake_id` = '$stocktake_id' ;";
- $retval = f_read_column('total_purchases', $query_total_purchases, $purchases);
- $query_total_wastage = "select sum(`store_wastage`.`wastage_amount`) AS `total_wastage` from `store_wastage` where `store_wastage`.`stocktake_id` = '$stocktake_id'; ";
- $retval = f_read_column('total_wastage', $query_total_wastage, $wastage);
- $query_total_sales = "select sum(`store_sales`.`sale_at_cost`) AS `total_sales` from `store_sales` where `store_sales`.`stocktake_id` = '$stocktake_id'; ";
- $retval = f_read_column('total_sales', $query_total_sales,$sales);
- $query_total_labour = "select sum(`labour_costs`.`cost`) AS `total_labour` from `labour_costs` where `labour_costs`.`stocktake_id` = '$stocktake_id'; ";
- $retval = f_read_column('total_labour', $query_total_labour,$labour);
- $query = "select id from view_stocktake_master where store_id = $store_id1 AND id < '$stocktake_id' order by stock_date desc limit 1";
- $retval = f_read_column('id', $query, $stocktake_id_prev);
- $query_total_opening = "select sum(`stocktake_details`.`quantity_units` * `stocktake_details`.`unit_cost`) AS `total_cost`
- from `stocktake_details` INNER JOIN stocktake_locations on stocktake_details.location_id = stocktake_locations.id where `stocktake_details`.`stocktake_id` = '$stocktake_id_prev'
- AND stocktake_locations.stocktake_id = '$stocktake_id_prev' and stocktake_locations.is_completed != 0 group by stocktake_locations.stocktake_id LIMIT 1";
- $retval = f_read_column('total_cost', $query_total_opening, $opening_stock);
- }
- if ($sales == '')
- $sales = 0;
- if ($purchases == '')
- $purchases = 0;
- if ($wastage == '')
- $wastage = 0;
- if ($labour == '')
- $labour = 0;
- if ($opening_stock == '')
- {
- $opening_stock = 0;
- }
- $query = "select include_labour FROM store_master where id = $store_id1 ;";
- $retval = f_read_column('include_labour', $query, $include_labour);
- $query = "select include_wastage FROM store_master where id = $store_id1 ;";
- $retval = f_read_column('include_wastage', $query, $include_waste);
- if ($include_waste == 1 && $include_labour == 0)
- $consumption_cost = $opening_stock + $purchases + $wastage - $closing_stock;
- else if ($include_waste == 0 && $include_labour == 1)
- $consumption_cost = $opening_stock + $purchases + $labour - $closing_stock;
- else if ($include_waste == 0 && $include_labour == 0)
- $consumption_cost = $opening_stock + $purchases - $closing_stock;
- else
- $consumption_cost = $opening_stock + $purchases + $wastage + $labour - $closing_stock;
- $gp = $sales - $consumption_cost;
- if($gp == 0)
- $gp_per = 0;
- else
- $gp_per = ($gp/$sales) * 100;
- if ($gp_per < 0 || $gp_per == INF)
- $gp_per = 0;
- if ($wastage == NULL)
- $wastage = 0;
- if ($purchases == NULL)
- $purchases = 0;
- if ($sales == NULL)
- $sales = 0;
- $gp_per_displ = number_format($gp_per,2);
- echo "<tr style='display:none;'> ";
- echo "<td style='text-align:center'>$stock_date</td>";
- echo "<td style='text-align:center'>$store_name</td>";
- echo "<td style='text-align:center'>$store_city</td>";
- echo "<td style='text-align:center'>$global_currency_sign ".number_format($opening_stock,2)."</td>";
- echo "<td style='text-align:center'>$global_currency_sign ".number_format($wastage,2)."</td>";
- echo "<td style='text-align:center'>$global_currency_sign ".number_format($purchases,2)."</td>";
- echo "<td style='text-align:center'>$global_currency_sign ".number_format($sales,2)."</td>";
- echo "<td style='text-align:center'>$global_currency_sign ".number_format($closing_stock,2)."</td>";
- $query_total_cost = "select sum(`stocktake_details`.`quantity_units` * `stocktake_details`.`unit_cost`) AS `total_cost`
- from `stocktake_details` INNER JOIN stocktake_locations on stocktake_details.location_id = stocktake_locations.id where `stocktake_details`.`stocktake_id` = '$stocktake_id_prev'
- AND stocktake_locations.stocktake_id = '$stocktake_id_prev' and stocktake_locations.is_completed != 0 group by stocktake_locations.stocktake_id";
- $retval = f_read_column('total_cost', $query_total_cost, $closing_stock);
- $query_total_purchases = "select sum(`store_purchases`.`cost_value`) AS `total_purchases` from `store_purchases` where `store_purchases`.`stocktake_id` = '$stocktake_id_prev' ;";
- $retval = f_read_column('total_purchases', $query_total_purchases, $purchases);
- $query_total_wastage = "select sum(`store_wastage`.`wastage_amount`) AS `total_wastage` from `store_wastage` where `store_wastage`.`stocktake_id` = '$stocktake_id_prev'; ";
- $retval = f_read_column('total_wastage', $query_total_wastage, $wastage);
- $query_total_sales = "select sum(`store_sales`.`sale_at_cost`) AS `total_sales` from `store_sales` where `store_sales`.`stocktake_id` = '$stocktake_id_prev'; ";
- $retval = f_read_column('total_sales', $query_total_sales,$sales);
- $query_total_labour = "select sum(`labour_costs`.`cost`) AS `total_labour` from `labour_costs` where `labour_costs`.`stocktake_id` = '$stocktake_id_prev'; ";
- $retval = f_read_column('total_labour', $query_total_labour,$labour);
- $query = "select id from view_stocktake_master where store_id = $store_id1 AND id < '$stocktake_id_prev' order by stock_date desc limit 1";
- $retval = f_read_column('id', $query, $stocktake_id_prev_prev);
- $query_total_opening = "select sum(`stocktake_details`.`quantity_units` * `stocktake_details`.`unit_cost`) AS `total_cost`
- from `stocktake_details` INNER JOIN stocktake_locations on stocktake_details.location_id = stocktake_locations.id where `stocktake_details`.`stocktake_id` = '$stocktake_id_prev_prev'
- AND stocktake_locations.stocktake_id = '$stocktake_id_prev_prev' and stocktake_locations.is_completed != 0 group by stocktake_locations.stocktake_id LIMIT 1";
- $retval = f_read_column('total_cost', $query_total_opening, $opening_stock);
- if ($sales == '')
- $sales = 0;
- if ($purchases == '')
- $purchases = 0;
- if ($wastage == '')
- $wastage = 0;
- if ($labour == '')
- $labour = 0;
- if ($opening_stock == '')
- {
- $opening_stock = 0;
- }
- $query = "select include_labour FROM store_master where id = $store_id1 ;";
- $retval = f_read_column('include_labour', $query, $include_labour);
- $query = "select include_wastage FROM store_master where id = $store_id1 ;";
- $retval = f_read_column('include_wastage', $query, $include_waste);
- if ($include_waste == 1 && $include_labour == 0)
- $consumption_cost = $opening_stock + $purchases + $wastage - $closing_stock;
- else if ($include_waste == 0 && $include_labour == 1)
- $consumption_cost = $opening_stock + $purchases + $labour - $closing_stock;
- else if ($include_waste == 0 && $include_labour == 0)
- $consumption_cost = $opening_stock + $purchases - $closing_stock;
- else
- $consumption_cost = $opening_stock + $purchases + $wastage + $labour - $closing_stock;
- $gp = $sales - $consumption_cost;
- if($gp == 0)
- $gp_per = 0;
- else
- $gp_per = ($gp/$sales) * 100;
- if ($gp_per < 0 || $gp_per == INF)
- $gp_per = 0;
- if ($wastage == NULL)
- $wastage = 0;
- if ($purchases == NULL)
- $purchases = 0;
- if ($sales == NULL)
- $sales = 0;
- $gp_per_displ_prev = number_format($gp_per,2);
- if ($gp_per_displ > $gp_per_displ_prev)
- echo "<td style='text-align:center'>".$gp_per_displ."% <i class='fa fa-arrow-up fa-md' style='color:green'></i></td>";
- else
- echo "<td style='text-align:center'>".$gp_per_displ."% <i class='fa fa-arrow-down fa-md' style='color:red'></i></td>";
- echo "<td style='text-align:center'>".$gp_per_displ_prev."%</td>";
- echo "</tr> ";
- }
- }
- ?>
- </tbody>
- </table>
- </div>
- </div>
- <div class="col-sm-5 col-xs-12" id="currentDiv" style="display: none;">
- <div class="homepage_blocks " id="current">
- <?php include_once('home_stocktake_locations_list_group.php'); ?>
- </div>
- </div>
- <div class="col-sm-5 col-xs-12" id="previousDiv" style="display: none;">
- <div class="homepage_blocks" id="graph"> </div>
- <div class="homepage_blocks" id="previous">
- </div>
- </div>
- </div>
- </div>
- <script type="text/javascript" >
- $(document).ready(function() {
- table = $('#tbl_leader_board').DataTable( {
- stateSave: true,
- "bFilter" : true,
- "responsive" : true,
- "aLengthMenu": [[ 50, 75, -1], [ 50, 75, "All"]],
- "iDisplayLength": 50,
- "order": [[ 8, "desc" ]]
- });
- $('#tbl_leader_board tbody').on('click', 'td.details-control', function () {
- var tr = $(this).closest('tr');
- tr.css('display','block');
- });
- });
- $(document.body).on('click', '.details', function(event)
- {
- // $(this) = your current element that clicked.
- // additional code
- $("#tableDiv").hide();
- $("#currentDiv").css('display','block');
- $("#previousDiv").css('display','block');
- var id = event.target.id;
- //alert(id);
- //alert($(this));
- _formurl = "home_stocktake_locations_list_group.php";
- _formdata = {'store_id' : id};
- _formurl2 = "home_stocktake_list.php";
- _formurl3 = "home_sales_graph.php";
- $.ajax({
- type: "GET",
- url: _formurl,
- data: _formdata,
- success: function(xhrResponse)
- {
- $('#current').html(xhrResponse);
- var rowCount = $('#locations').length;
- row_count = parseInt(rowCount) ;
- },
- error: function(XMLHttpRequest, textStatus, errorThrown)
- {
- $('#alert_msg').html(errorThrown);
- $('#alert_msg').fadeIn( "slow");
- }
- });
- $.ajax({
- type: "GET",
- url: _formurl3,
- data: _formdata,
- success: function(xhrResponse)
- {
- $('#graph').html(xhrResponse);
- var rowCount = $('#sales_graph').length;
- row_count = parseInt(rowCount) ;
- },
- error: function(XMLHttpRequest, textStatus, errorThrown)
- {
- $('#alert_msg').html(errorThrown);
- $('#alert_msg').fadeIn( "slow");
- }
- });
- $.ajax({
- type: "GET",
- url: _formurl2,
- data: _formdata,
- success: function(xhrResponse)
- {
- $('#previous').html(xhrResponse);
- var rowCount = $('#dd_home_stocktake').length;
- row_count = parseInt(rowCount) ;
- },
- error: function(XMLHttpRequest, textStatus, errorThrown)
- {
- $('#alert_msg').html(errorThrown);
- $('#alert_msg').fadeIn( "slow");
- }
- });
- });
- $(document.body).on('click', '.visual', function(event)
- {
- $("#tableDiv").hide();
- $("#currentDiv").css('display','block');
- $("#previousDiv").css('display','block');
- // $(this) = your current element that clicked.
- // additional code
- var id = event.target.id;
- //alert(id);
- //alert($(this));
- _formurl = "home_stocktake_locations_list_group.php";
- _formdata = {'store_id' : id};
- _formurl2 = "home_stocktake_list.php";
- _formurl3 = "home_sales_graph.php";
- $.ajax({
- type: "GET",
- url: _formurl,
- data: _formdata,
- success: function(xhrResponse)
- {
- $('#current').html(xhrResponse);
- var rowCount = $('#locations').length;
- row_count = parseInt(rowCount) ;
- },
- error: function(XMLHttpRequest, textStatus, errorThrown)
- {
- $('#alert_msg').html(errorThrown);
- $('#alert_msg').fadeIn( "slow");
- }
- });
- $.ajax({
- type: "GET",
- url: _formurl3,
- data: _formdata,
- success: function(xhrResponse)
- {
- $('#graph').html(xhrResponse);
- var rowCount = $('#sales_graph').length;
- row_count = parseInt(rowCount) ;
- },
- error: function(XMLHttpRequest, textStatus, errorThrown)
- {
- $('#alert_msg').html(errorThrown);
- $('#alert_msg').fadeIn( "slow");
- }
- });
- $.ajax({
- type: "GET",
- url: _formurl2,
- data: _formdata,
- success: function(xhrResponse)
- {
- $('#previous').html(xhrResponse);
- var rowCount = $('#dd_home_stocktake').length;
- row_count = parseInt(rowCount) ;
- },
- error: function(XMLHttpRequest, textStatus, errorThrown)
- {
- $('#alert_msg').html(errorThrown);
- $('#alert_msg').fadeIn( "slow");
- }
- });
- });
- $(document.body).on('click', '.desc', function(event)
- {
- $("#tableDiv").hide();
- $("#currentDiv").css('display','block');
- $("#previousDiv").css('display','block');
- // $(this) = your current element that clicked.
- // additional code
- var id = event.target.id;
- //alert(id);
- //alert($(this));
- _formurl = "home_stocktake_locations_list_group.php";
- _formdata = {'store_id' : id};
- _formurl2 = "home_stocktake_list.php";
- _formurl3 = "home_sales_graph.php";
- $.ajax({
- type: "GET",
- url: _formurl,
- data: _formdata,
- success: function(xhrResponse)
- {
- $('#current').html(xhrResponse);
- var rowCount = $('#locations').length;
- row_count = parseInt(rowCount) ;
- },
- error: function(XMLHttpRequest, textStatus, errorThrown)
- {
- $('#alert_msg').html(errorThrown);
- $('#alert_msg').fadeIn( "slow");
- }
- });
- $.ajax({
- type: "GET",
- url: _formurl3,
- data: _formdata,
- success: function(xhrResponse)
- {
- $('#graph').html(xhrResponse);
- var rowCount = $('#sales_graph').length;
- row_count = parseInt(rowCount) ;
- },
- error: function(XMLHttpRequest, textStatus, errorThrown)
- {
- $('#alert_msg').html(errorThrown);
- $('#alert_msg').fadeIn( "slow");
- }
- });
- $.ajax({
- type: "GET",
- url: _formurl2,
- data: _formdata,
- success: function(xhrResponse)
- {
- $('#previous').html(xhrResponse);
- var rowCount = $('#dd_home_stocktake').length;
- row_count = parseInt(rowCount) ;
- },
- error: function(XMLHttpRequest, textStatus, errorThrown)
- {
- $('#alert_msg').html(errorThrown);
- $('#alert_msg').fadeIn( "slow");
- }
- });
- });
- $(document.body).on('click', '.more', function(event)
- {
- $("#tableDiv").hide();
- $("#currentDiv").css('display','block');
- $("#previousDiv").css('display','block');
- // $(this) = your current element that clicked.
- // additional code
- var id = event.target.id;
- //alert(id);
- //alert($(this));
- _formurl = "home_stocktake_locations_list_group.php";
- _formurl2 = "home_stocktake_list.php";
- _formurl3 = "home_sales_graph.php";
- _formdata = {'store_id' : id};
- $.ajax({
- type: "GET",
- url: _formurl,
- data: _formdata,
- success: function(xhrResponse)
- {
- $('#current').html(xhrResponse);
- var rowCount = $('#locations').length;
- row_count = parseInt(rowCount) ;
- },
- error: function(XMLHttpRequest, textStatus, errorThrown)
- {
- $('#alert_msg').html(errorThrown);
- $('#alert_msg').fadeIn( "slow");
- }
- });
- $.ajax({
- type: "GET",
- url: _formurl3,
- data: _formdata,
- success: function(xhrResponse)
- {
- $('#graph').html(xhrResponse);
- var rowCount = $('#sales_graph').length;
- row_count = parseInt(rowCount) ;
- },
- error: function(XMLHttpRequest, textStatus, errorThrown)
- {
- $('#alert_msg').html(errorThrown);
- $('#alert_msg').fadeIn( "slow");
- }
- });
- $.ajax({
- type: "GET",
- url: _formurl2,
- data: _formdata,
- success: function(xhrResponse)
- {
- $('#previous').html(xhrResponse);
- var rowCount = $('#dd_home_stocktake').length;
- row_count = parseInt(rowCount) ;
- },
- error: function(XMLHttpRequest, textStatus, errorThrown)
- {
- $('#alert_msg').html(errorThrown);
- $('#alert_msg').fadeIn( "slow");
- }
- });
- });
- $(document.body).on('click', '.desc', function(event)
- {
- $("#tableDiv").hide();
- $("#currentDiv").css('display','block');
- $("#previousDiv").css('display','block');
- // $(this) = your current element that clicked.
- // additional code
- var id = event.target.id;
- //alert(id);
- //alert($(this));
- _formurl = "home_stocktake_locations_list_group.php";
- _formurl2 = "home_stocktake_list.php";
- _formurl3 = "home_sales_graph.php";
- _formdata = {'store_id' : id};
- $.ajax({
- type: "GET",
- url: _formurl,
- data: _formdata,
- success: function(xhrResponse)
- {
- $('#current').html(xhrResponse);
- var rowCount = $('#locations').length;
- row_count = parseInt(rowCount) ;
- },
- error: function(XMLHttpRequest, textStatus, errorThrown)
- {
- $('#alert_msg').html(errorThrown);
- $('#alert_msg').fadeIn( "slow");
- }
- });
- $.ajax({
- type: "GET",
- url: _formurl3,
- data: _formdata,
- success: function(xhrResponse)
- {
- $('#graph').html(xhrResponse);
- var rowCount = $('#sales_graph').length;
- row_count = parseInt(rowCount) ;
- },
- error: function(XMLHttpRequest, textStatus, errorThrown)
- {
- $('#alert_msg').html(errorThrown);
- $('#alert_msg').fadeIn( "slow");
- }
- });
- $.ajax({
- type: "GET",
- url: _formurl2,
- data: _formdata,
- success: function(xhrResponse)
- {
- $('#previous').html(xhrResponse);
- var rowCount = $('#dd_home_stocktake').length;
- row_count = parseInt(rowCount) ;
- },
- error: function(XMLHttpRequest, textStatus, errorThrown)
- {
- $('#alert_msg').html(errorThrown);
- $('#alert_msg').fadeIn( "slow");
- }
- });
- });
- </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement