Advertisement
Guest User

Untitled

a guest
Sep 4th, 2018
1,106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 26.02 KB | None | 0 0
  1. <?php
  2. include_once ('dbconn.php');
  3. //$store_id =   intval($_SESSION["store_id"]);
  4. $is_new     =   intval($_SESSION["is_new"]);
  5. $name       =   $_SESSION["user_full_name"];
  6. $group_id   =   $_SESSION["customer_id"];
  7. if ( $_SESSION['auth_type'] == 'SYS-ADMIN')
  8.     $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";
  9. //print_r($_SESSION);
  10. else
  11.     $query          =   "select * from store_master where customer_id = '$group_id' order by store_name desc";
  12. //echo $query;
  13. $retval         =   f_select_query($query, $datarows);
  14. $store_id = 0;
  15. if ($retval == -1 )
  16. {
  17.     $connected = false;
  18.  
  19. }
  20.  
  21.  
  22. if ($is_new == 1)
  23. {
  24.  
  25. }
  26. $rowcount =  count($datarows);
  27. //echo $query;
  28. //print_r ($datarows);
  29. ?>
  30. <script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
  31. <div id="this_form_id" class="container-fluid box-grid " >
  32.     <div class="row">
  33.  
  34.     <div class="col-sm-2 col-xs-12">
  35.     <div class="homepage_blocks">
  36.     <div class="container-fluid content_container" >
  37.     <div class="row">
  38.     <div class="title clearfix">
  39.         <span class="text-primary">List of Stores </span><br>
  40.     </div>
  41.  
  42.     <?
  43.     //echo $group_id;
  44. for ($counter = 0; $counter< $rowcount; $counter++)
  45. {
  46.     $store_id1 = $datarows[$counter]->id;
  47.     $query1             =   "select * from view_stocktake_master where store_id = $store_id1  order by stock_date desc limit 1";
  48.     //echo $query1;
  49.     $retval         =   f_select_query($query1, $datarows1);
  50.  
  51.     $query2             =   "select id from view_stocktake_master where store_id = $store_id1 order by stock_date desc limit 1";
  52.  
  53.     $retval         =   f_read_column('id', $query2, $stocktake_id);
  54.  
  55.     $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)";
  56.  
  57.     $retval     =   f_select_query($query3, $datarows3);
  58.  
  59. //print_r ($datarows3);
  60. //print_r ($datarows1);
  61. if ($datarows3[0]->total_cost == 0)
  62. { ?>
  63.     <div class="col-lg-12 col-md-1 col-sm-1 col-xs-1 stat-container" id ="stores">
  64.             <div class="dashboard-stat red-stat " >
  65.                 <div class="visual" id="<? echo $datarows[$counter]->id; ?>">
  66.  
  67.                 </div>
  68.                 <div class="details " id="<? echo $datarows[$counter]->id; ?>">
  69.                     <div style="text-align: center; margin-top: 7px; font-size: 10px;" class="more" id="<? echo $datarows[$counter]->id; ?>">
  70.                          <? echo $datarows[$counter]->store_name; ?>
  71.                     </div>
  72.                     <div style="text-align: center; margin-top: 7px; font-size: 12px;" class="desc" id="<? echo $datarows[$counter]->id; ?>">
  73.                     Date:   <? echo $datarows1[0]->stock_date_str; ?></br> Cost: €<? echo number_format($datarows3[0]->total_cost,2); ?>
  74.                     </div>
  75.                 </div>
  76.  
  77.             </div>
  78.         </div> <?
  79. }
  80. else
  81. {
  82. ?>
  83.     <div class="col-lg-12 col-md-1 col-sm-1 col-xs-1 stat-container" id ="stores">
  84.             <div class="dashboard-stat blue-stat " >
  85.                 <div class="visual" id="<? echo $datarows[$counter]->id; ?>">
  86.  
  87.                 </div>
  88.                 <div class="details " id="<? echo $datarows[$counter]->id; ?>">
  89.                     <div style="text-align: center; margin-top: 7px; font-size: 10px;" class="more" id="<? echo $datarows[$counter]->id; ?>">
  90.                          <? echo $datarows[$counter]->store_name; ?>
  91.                     </div>
  92.                     <div style="text-align: center; margin-top: 7px; font-size: 12px;" class="desc" id="<? echo $datarows[$counter]->id; ?>">
  93.                     Date:   <? echo $datarows1[0]->stock_date_str; ?></br> Cost: €<? echo number_format($datarows3[0]->total_cost,2); ?>
  94.                     </div>
  95.                 </div>
  96.  
  97.             </div>
  98.         </div>
  99.  
  100.             <?php
  101. }
  102. }
  103.             ?>
  104. </div>
  105. </div>
  106. </div>
  107. </div>
  108. <div class="col-sm-10 col-xs-12" id="tableDiv">
  109.  
  110.             <div class="homepage_blocks" id="leaderBoard">
  111.             <div class="container-fluid content_container" >
  112.             <div class="row">
  113.             <div class="title clearfix">
  114.                 <span class="text-primary">Leader Board </span><br>
  115.             </div>
  116.             </div>
  117.             </div>
  118.             <table style=' height:10px; margin: 0 auto; width: 1150px;' id="tbl_leader_board" class="table table-fixed table-striped table-bordered datalist"  cellspacing="0">
  119.             <thead>
  120.  
  121.                         <tr >
  122.                             <th style='width:8%;'> Date </th>
  123.                              <th style='width:15%;'> Store Name  </th>
  124.                              <th style='width:8%;'> City </th>
  125.                              <th style='width:10%;'> Opening Stock </th>
  126.                              <th style='width:6%;'> Wastage </th>
  127.                              <th style='width:6%;'> Purchases </th>
  128.                             <th style='width:6%;'> Sales </th>
  129.                             <th style='width:10%;'> Closing Stock </th>
  130.                             <th style='width:7%;'> GP (%) </th>
  131.                             <th style='width:11%;'> Previous GP (%) </th>
  132.                          </tr>
  133.  
  134.                 </thead>
  135.  
  136.                 <tbody>
  137.                 <?
  138.                     for ($counter = 0; $counter< $rowcount; $counter++)
  139.                     {
  140.                         $store_id1 = $datarows[$counter]->id;
  141.                         $store_name = $datarows[$counter]->store_name;
  142.                         $store_city = $datarows[$counter]->location_city;
  143.  
  144.                         $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";
  145.                         //echo $query;
  146.                         $retval         =   f_read_column('stocktake_id', $query, $stocktake_id);
  147.                         $retval         =   f_read_column('stock_date', $query, $stock_date);
  148.  
  149.                         $query_total_cost = "select sum(`stocktake_details`.`quantity_units` * `stocktake_details`.`unit_cost`) AS `total_cost`
  150.                              from `stocktake_details` INNER JOIN stocktake_locations on stocktake_details.location_id = stocktake_locations.id where `stocktake_details`.`stocktake_id` = '$stocktake_id'
  151.                              AND stocktake_locations.stocktake_id = '$stocktake_id' and stocktake_locations.is_completed != 0 group by stocktake_locations.stocktake_id";
  152.                         $retval         =   f_read_column('total_cost', $query_total_cost, $closing_stock);
  153.  
  154.                         if ($closing_stock == "0.00")
  155.                         {
  156.                             $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";
  157.                             $retval         =   f_read_column('stocktake_id', $query, $stocktake_id);
  158.                             $retval         =   f_read_column('stock_date', $query, $stock_date);
  159.  
  160.                             $query_total_cost = "select sum(`stocktake_details`.`quantity_units` * `stocktake_details`.`unit_cost`) AS `total_cost`
  161.                                  from `stocktake_details` INNER JOIN stocktake_locations on stocktake_details.location_id = stocktake_locations.id where `stocktake_details`.`stocktake_id` = '$stocktake_id'
  162.                                  AND stocktake_locations.stocktake_id = '$stocktake_id' and stocktake_locations.is_completed != 0 group by stocktake_locations.stocktake_id";
  163.                             $retval         =   f_read_column('total_cost', $query_total_cost, $closing_stock);
  164.  
  165.                              $query_total_purchases = "select sum(`store_purchases`.`cost_value`) AS `total_purchases` from `store_purchases` where `store_purchases`.`stocktake_id` = '$stocktake_id' ;";
  166.                              $retval        =   f_read_column('total_purchases', $query_total_purchases, $purchases);
  167.  
  168.                              $query_total_wastage = "select sum(`store_wastage`.`wastage_amount`) AS `total_wastage` from `store_wastage` where `store_wastage`.`stocktake_id` = '$stocktake_id'; ";
  169.                              $retval        =   f_read_column('total_wastage', $query_total_wastage, $wastage);
  170.  
  171.                              $query_total_sales = "select sum(`store_sales`.`sale_at_cost`) AS `total_sales` from `store_sales` where `store_sales`.`stocktake_id` = '$stocktake_id'; ";
  172.                              $retval        =   f_read_column('total_sales', $query_total_sales,$sales);
  173.  
  174.                              $query_total_labour = "select sum(`labour_costs`.`cost`) AS `total_labour` from `labour_costs` where `labour_costs`.`stocktake_id` = '$stocktake_id'; ";
  175.                              $retval        =   f_read_column('total_labour', $query_total_labour,$labour);
  176.  
  177.                              $query             =   "select id from view_stocktake_master where store_id = $store_id1 AND id < '$stocktake_id' order by stock_date desc limit 1";
  178.                              $retval        =   f_read_column('id', $query, $stocktake_id_prev);
  179.  
  180.                              $query_total_opening = "select sum(`stocktake_details`.`quantity_units` * `stocktake_details`.`unit_cost`) AS `total_cost`
  181.                                                  from `stocktake_details` INNER JOIN stocktake_locations on stocktake_details.location_id = stocktake_locations.id where `stocktake_details`.`stocktake_id` = '$stocktake_id_prev'
  182.                                                  AND stocktake_locations.stocktake_id = '$stocktake_id_prev' and stocktake_locations.is_completed != 0 group by stocktake_locations.stocktake_id LIMIT 1";
  183.                              $retval        =   f_read_column('total_cost', $query_total_opening, $opening_stock);
  184.                         }
  185.                         else {
  186.  
  187.                              $query_total_purchases = "select sum(`store_purchases`.`cost_value`) AS `total_purchases` from `store_purchases` where `store_purchases`.`stocktake_id` = '$stocktake_id' ;";
  188.                              $retval        =   f_read_column('total_purchases', $query_total_purchases, $purchases);
  189.  
  190.                              $query_total_wastage = "select sum(`store_wastage`.`wastage_amount`) AS `total_wastage` from `store_wastage` where `store_wastage`.`stocktake_id` = '$stocktake_id'; ";
  191.                              $retval        =   f_read_column('total_wastage', $query_total_wastage, $wastage);
  192.  
  193.                              $query_total_sales = "select sum(`store_sales`.`sale_at_cost`) AS `total_sales` from `store_sales` where `store_sales`.`stocktake_id` = '$stocktake_id'; ";
  194.                              $retval        =   f_read_column('total_sales', $query_total_sales,$sales);
  195.  
  196.                              $query_total_labour = "select sum(`labour_costs`.`cost`) AS `total_labour` from `labour_costs` where `labour_costs`.`stocktake_id` = '$stocktake_id'; ";
  197.                              $retval        =   f_read_column('total_labour', $query_total_labour,$labour);
  198.  
  199.                              $query             =   "select id from view_stocktake_master where store_id = $store_id1 AND id < '$stocktake_id' order by stock_date desc limit 1";
  200.                              $retval        =   f_read_column('id', $query, $stocktake_id_prev);
  201.  
  202.                              $query_total_opening = "select sum(`stocktake_details`.`quantity_units` * `stocktake_details`.`unit_cost`) AS `total_cost`
  203.                                                  from `stocktake_details` INNER JOIN stocktake_locations on stocktake_details.location_id = stocktake_locations.id where `stocktake_details`.`stocktake_id` = '$stocktake_id_prev'
  204.                                                  AND stocktake_locations.stocktake_id = '$stocktake_id_prev' and stocktake_locations.is_completed != 0 group by stocktake_locations.stocktake_id LIMIT 1";
  205.                              $retval        =   f_read_column('total_cost', $query_total_opening, $opening_stock);
  206.                         }
  207.  
  208.                          if ($sales == '')
  209.                              $sales = 0;
  210.                          if ($purchases == '')
  211.                              $purchases = 0;
  212.                          if ($wastage == '')
  213.                              $wastage = 0;
  214.                          if ($labour == '')
  215.                              $labour = 0;
  216.  
  217.                          if ($opening_stock == '')
  218.                          {
  219.                              $opening_stock = 0;
  220.                          }
  221.  
  222.                         $query          =   "select include_labour FROM store_master where id = $store_id1 ;";
  223.                         $retval         =   f_read_column('include_labour', $query, $include_labour);
  224.  
  225.                         $query          =   "select include_wastage FROM store_master where id = $store_id1 ;";
  226.                         $retval         =   f_read_column('include_wastage', $query, $include_waste);
  227.  
  228.                         if ($include_waste == 1 && $include_labour == 0)
  229.                             $consumption_cost = $opening_stock + $purchases + $wastage  - $closing_stock;
  230.                         else if ($include_waste == 0 && $include_labour == 1)
  231.                             $consumption_cost = $opening_stock + $purchases  + $labour - $closing_stock;
  232.                         else if ($include_waste == 0 && $include_labour == 0)
  233.                             $consumption_cost = $opening_stock + $purchases - $closing_stock;
  234.                         else
  235.                             $consumption_cost = $opening_stock + $purchases + $wastage + $labour - $closing_stock;
  236.  
  237.                           $gp = $sales - $consumption_cost;
  238.  
  239.                          if($gp == 0)
  240.                             $gp_per = 0;
  241.                          else
  242.                              $gp_per = ($gp/$sales) * 100;
  243.  
  244.                           if ($gp_per < 0 || $gp_per == INF)
  245.                              $gp_per = 0;
  246.  
  247.                           if ($wastage == NULL)
  248.                              $wastage = 0;
  249.  
  250.                           if ($purchases == NULL)
  251.                              $purchases = 0;
  252.  
  253.                          if ($sales == NULL)
  254.                              $sales = 0;
  255.  
  256.                          $gp_per_displ = number_format($gp_per,2);
  257.  
  258.                         echo "<tr> ";
  259.                         echo "<td style='text-align:center'>$stock_date</td>";
  260.                         echo "<td style='text-align:center'>$store_name</td>";
  261.                         echo "<td style='text-align:center'>$store_city</td>";
  262.                         echo "<td style='text-align:center'>$global_currency_sign ".number_format($opening_stock,2)."</td>";
  263.                         echo "<td style='text-align:center'>$global_currency_sign ".number_format($wastage,2)."</td>";
  264.                         echo "<td style='text-align:center'>$global_currency_sign ".number_format($purchases,2)."</td>";
  265.                         echo "<td style='text-align:center'>$global_currency_sign ".number_format($sales,2)."</td>";
  266.                         echo "<td style='text-align:center'>$global_currency_sign ".number_format($closing_stock,2)."</td>";
  267.  
  268.                         $query_total_cost = "select sum(`stocktake_details`.`quantity_units` * `stocktake_details`.`unit_cost`) AS `total_cost`
  269.                              from `stocktake_details` INNER JOIN stocktake_locations on stocktake_details.location_id = stocktake_locations.id where `stocktake_details`.`stocktake_id` = '$stocktake_id_prev'
  270.                              AND stocktake_locations.stocktake_id = '$stocktake_id_prev' and stocktake_locations.is_completed != 0 group by stocktake_locations.stocktake_id";
  271.                             $retval         =   f_read_column('total_cost', $query_total_cost, $closing_stock);
  272.  
  273.                             $query_total_purchases = "select sum(`store_purchases`.`cost_value`) AS `total_purchases` from `store_purchases` where `store_purchases`.`stocktake_id` = '$stocktake_id_prev' ;";
  274.                              $retval        =   f_read_column('total_purchases', $query_total_purchases, $purchases);
  275.  
  276.                              $query_total_wastage = "select sum(`store_wastage`.`wastage_amount`) AS `total_wastage` from `store_wastage` where `store_wastage`.`stocktake_id` = '$stocktake_id_prev'; ";
  277.                              $retval        =   f_read_column('total_wastage', $query_total_wastage, $wastage);
  278.  
  279.                              $query_total_sales = "select sum(`store_sales`.`sale_at_cost`) AS `total_sales` from `store_sales` where `store_sales`.`stocktake_id` = '$stocktake_id_prev'; ";
  280.                              $retval        =   f_read_column('total_sales', $query_total_sales,$sales);
  281.  
  282.                              $query_total_labour = "select sum(`labour_costs`.`cost`) AS `total_labour` from `labour_costs` where `labour_costs`.`stocktake_id` = '$stocktake_id_prev'; ";
  283.                              $retval        =   f_read_column('total_labour', $query_total_labour,$labour);
  284.  
  285.                              $query             =   "select id from view_stocktake_master where store_id = $store_id1 AND id < '$stocktake_id_prev' order by stock_date desc limit 1";
  286.                              $retval        =   f_read_column('id', $query, $stocktake_id_prev_prev);
  287.  
  288.                              $query_total_opening = "select sum(`stocktake_details`.`quantity_units` * `stocktake_details`.`unit_cost`) AS `total_cost`
  289.                                                  from `stocktake_details` INNER JOIN stocktake_locations on stocktake_details.location_id = stocktake_locations.id where `stocktake_details`.`stocktake_id` = '$stocktake_id_prev_prev'
  290.                                                  AND stocktake_locations.stocktake_id = '$stocktake_id_prev_prev' and stocktake_locations.is_completed != 0 group by stocktake_locations.stocktake_id LIMIT 1";
  291.                              $retval        =   f_read_column('total_cost', $query_total_opening, $opening_stock);
  292.                               if ($sales == '')
  293.                              $sales = 0;
  294.                          if ($purchases == '')
  295.                              $purchases = 0;
  296.                          if ($wastage == '')
  297.                              $wastage = 0;
  298.                          if ($labour == '')
  299.                              $labour = 0;
  300.  
  301.                          if ($opening_stock == '')
  302.                          {
  303.                              $opening_stock = 0;
  304.                          }
  305.  
  306.                         $query          =   "select include_labour FROM store_master where id = $store_id1 ;";
  307.                         $retval         =   f_read_column('include_labour', $query, $include_labour);
  308.  
  309.                         $query          =   "select include_wastage FROM store_master where id = $store_id1 ;";
  310.                         $retval         =   f_read_column('include_wastage', $query, $include_waste);
  311.  
  312.                         if ($include_waste == 1 && $include_labour == 0)
  313.                             $consumption_cost = $opening_stock + $purchases + $wastage  - $closing_stock;
  314.                         else if ($include_waste == 0 && $include_labour == 1)
  315.                             $consumption_cost = $opening_stock + $purchases  + $labour - $closing_stock;
  316.                         else if ($include_waste == 0 && $include_labour == 0)
  317.                             $consumption_cost = $opening_stock + $purchases - $closing_stock;
  318.                         else
  319.                             $consumption_cost = $opening_stock + $purchases + $wastage + $labour - $closing_stock;
  320.  
  321.                           $gp = $sales - $consumption_cost;
  322.  
  323.                          if($gp == 0)
  324.                             $gp_per = 0;
  325.                          else
  326.                              $gp_per = ($gp/$sales) * 100;
  327.  
  328.                           if ($gp_per < 0 || $gp_per == INF)
  329.                              $gp_per = 0;
  330.  
  331.                           if ($wastage == NULL)
  332.                              $wastage = 0;
  333.  
  334.                           if ($purchases == NULL)
  335.                              $purchases = 0;
  336.  
  337.                          if ($sales == NULL)
  338.                              $sales = 0;
  339.  
  340.                          $gp_per_displ_prev = number_format($gp_per,2);
  341.                         if ($gp_per_displ > $gp_per_displ_prev)
  342.                             echo "<td style='text-align:center'>".$gp_per_displ."% <i class='fa fa-arrow-up fa-md' style='color:green'></i></td>";
  343.                         else
  344.                             echo "<td style='text-align:center'>".$gp_per_displ."% <i class='fa fa-arrow-down fa-md' style='color:red'></i></td>";
  345.                          echo "<td style='text-align:center'>".$gp_per_displ_prev."%</td>";
  346.                         echo "</tr> ";
  347.                        
  348.                        
  349.                     }
  350.                 ?>
  351.                 </tbody>
  352.  
  353.                 </table>
  354.             </div>
  355.  
  356. </div>
  357. <div class="col-sm-5 col-xs-12" id="currentDiv" style="display: none;">
  358.             <div class="homepage_blocks " id="current">
  359.                 <?php include_once('home_stocktake_locations_list_group.php'); ?>
  360.             </div>
  361.         </div>
  362. <div class="col-sm-5 col-xs-12" id="previousDiv" style="display: none;">
  363.             <div class="homepage_blocks" id="graph"> </div>
  364.             <div class="homepage_blocks" id="previous">
  365.             </div>
  366.         </div>
  367. </div>
  368. </div>
  369. <script type="text/javascript" >
  370. $(document).ready(function() {
  371. table = $('#tbl_leader_board').DataTable( {
  372.    stateSave: true,
  373.    "bFilter" : true,
  374.     "responsive" : true,
  375.     "aLengthMenu": [[ 50, 75, -1], [ 50, 75, "All"]],
  376.     "iDisplayLength": 50,
  377.     "order": [[ 8, "desc" ]]
  378. });
  379. });
  380. $(document.body).on('click', '.details', function(event)
  381.     {
  382.     //  $(this) = your current element that clicked.
  383.     // additional code
  384.     $("#tableDiv").hide();
  385.     $("#currentDiv").css('display','block');
  386.     $("#previousDiv").css('display','block');
  387.     var id = event.target.id;
  388.     //alert(id);
  389.     //alert($(this));
  390.         _formurl    =   "home_stocktake_locations_list_group.php";
  391.         _formdata   =   {'store_id' : id};
  392.         _formurl2   =   "home_stocktake_list.php";
  393.         _formurl3   =   "home_sales_graph.php";
  394.         $.ajax({
  395.  
  396.          type: "GET",
  397.           url: _formurl,
  398.           data: _formdata,
  399.          success: function(xhrResponse)
  400.          {
  401.             $('#current').html(xhrResponse);
  402.             var rowCount = $('#locations').length;
  403.             row_count = parseInt(rowCount) ;
  404.           },
  405.           error: function(XMLHttpRequest, textStatus, errorThrown)
  406.           {
  407.             $('#alert_msg').html(errorThrown);
  408.             $('#alert_msg').fadeIn( "slow");
  409.  
  410.           }
  411.     });
  412.     $.ajax({
  413.  
  414.          type: "GET",
  415.           url: _formurl3,
  416.           data: _formdata,
  417.          success: function(xhrResponse)
  418.          {
  419.             $('#graph').html(xhrResponse);
  420.             var rowCount = $('#sales_graph').length;
  421.             row_count = parseInt(rowCount) ;
  422.           },
  423.           error: function(XMLHttpRequest, textStatus, errorThrown)
  424.           {
  425.             $('#alert_msg').html(errorThrown);
  426.             $('#alert_msg').fadeIn( "slow");
  427.  
  428.           }
  429.     });
  430.     $.ajax({
  431.  
  432.          type: "GET",
  433.           url: _formurl2,
  434.           data: _formdata,
  435.          success: function(xhrResponse)
  436.          {
  437.             $('#previous').html(xhrResponse);
  438.             var rowCount = $('#dd_home_stocktake').length;
  439.             row_count = parseInt(rowCount) ;
  440.           },
  441.           error: function(XMLHttpRequest, textStatus, errorThrown)
  442.           {
  443.             $('#alert_msg').html(errorThrown);
  444.             $('#alert_msg').fadeIn( "slow");
  445.  
  446.           }
  447.     });
  448.  
  449. });
  450. $(document.body).on('click', '.visual', function(event)
  451.     {
  452.         $("#tableDiv").hide();
  453.     $("#currentDiv").css('display','block');
  454.     $("#previousDiv").css('display','block');
  455.     //  $(this) = your current element that clicked.
  456.     // additional code
  457.     var id = event.target.id;
  458.     //alert(id);
  459.     //alert($(this));
  460.             _formurl    =   "home_stocktake_locations_list_group.php";
  461.         _formdata   =   {'store_id' : id};
  462.         _formurl2   =   "home_stocktake_list.php";
  463.         _formurl3   =   "home_sales_graph.php";
  464.         $.ajax({
  465.  
  466.          type: "GET",
  467.           url: _formurl,
  468.           data: _formdata,
  469.          success: function(xhrResponse)
  470.          {
  471.             $('#current').html(xhrResponse);
  472.             var rowCount = $('#locations').length;
  473.             row_count = parseInt(rowCount) ;
  474.           },
  475.           error: function(XMLHttpRequest, textStatus, errorThrown)
  476.           {
  477.             $('#alert_msg').html(errorThrown);
  478.             $('#alert_msg').fadeIn( "slow");
  479.  
  480.           }
  481.     });
  482.     $.ajax({
  483.  
  484.          type: "GET",
  485.           url: _formurl3,
  486.           data: _formdata,
  487.          success: function(xhrResponse)
  488.          {
  489.             $('#graph').html(xhrResponse);
  490.             var rowCount = $('#sales_graph').length;
  491.             row_count = parseInt(rowCount) ;
  492.           },
  493.           error: function(XMLHttpRequest, textStatus, errorThrown)
  494.           {
  495.             $('#alert_msg').html(errorThrown);
  496.             $('#alert_msg').fadeIn( "slow");
  497.  
  498.           }
  499.     });
  500.     $.ajax({
  501.  
  502.          type: "GET",
  503.           url: _formurl2,
  504.           data: _formdata,
  505.          success: function(xhrResponse)
  506.          {
  507.             $('#previous').html(xhrResponse);
  508.             var rowCount = $('#dd_home_stocktake').length;
  509.             row_count = parseInt(rowCount) ;
  510.           },
  511.           error: function(XMLHttpRequest, textStatus, errorThrown)
  512.           {
  513.             $('#alert_msg').html(errorThrown);
  514.             $('#alert_msg').fadeIn( "slow");
  515.  
  516.           }
  517.     });
  518.  
  519. });
  520. $(document.body).on('click', '.desc', function(event)
  521.     {
  522.         $("#tableDiv").hide();
  523.     $("#currentDiv").css('display','block');
  524.     $("#previousDiv").css('display','block');
  525.     //  $(this) = your current element that clicked.
  526.     // additional code
  527.     var id = event.target.id;
  528.     //alert(id);
  529.     //alert($(this));
  530.             _formurl    =   "home_stocktake_locations_list_group.php";
  531.         _formdata   =   {'store_id' : id};
  532.         _formurl2   =   "home_stocktake_list.php";
  533.         _formurl3   =   "home_sales_graph.php";
  534.         $.ajax({
  535.  
  536.          type: "GET",
  537.           url: _formurl,
  538.           data: _formdata,
  539.          success: function(xhrResponse)
  540.          {
  541.             $('#current').html(xhrResponse);
  542.             var rowCount = $('#locations').length;
  543.             row_count = parseInt(rowCount) ;
  544.           },
  545.           error: function(XMLHttpRequest, textStatus, errorThrown)
  546.           {
  547.             $('#alert_msg').html(errorThrown);
  548.             $('#alert_msg').fadeIn( "slow");
  549.  
  550.           }
  551.     });
  552.     $.ajax({
  553.  
  554.          type: "GET",
  555.           url: _formurl3,
  556.           data: _formdata,
  557.          success: function(xhrResponse)
  558.          {
  559.             $('#graph').html(xhrResponse);
  560.             var rowCount = $('#sales_graph').length;
  561.             row_count = parseInt(rowCount) ;
  562.           },
  563.           error: function(XMLHttpRequest, textStatus, errorThrown)
  564.           {
  565.             $('#alert_msg').html(errorThrown);
  566.             $('#alert_msg').fadeIn( "slow");
  567.  
  568.           }
  569.     });
  570.     $.ajax({
  571.  
  572.          type: "GET",
  573.           url: _formurl2,
  574.           data: _formdata,
  575.          success: function(xhrResponse)
  576.          {
  577.             $('#previous').html(xhrResponse);
  578.             var rowCount = $('#dd_home_stocktake').length;
  579.             row_count = parseInt(rowCount) ;
  580.           },
  581.           error: function(XMLHttpRequest, textStatus, errorThrown)
  582.           {
  583.             $('#alert_msg').html(errorThrown);
  584.             $('#alert_msg').fadeIn( "slow");
  585.  
  586.           }
  587.     });
  588.  
  589. });
  590. $(document.body).on('click', '.more', function(event)
  591.     {
  592.         $("#tableDiv").hide();
  593.     $("#currentDiv").css('display','block');
  594.     $("#previousDiv").css('display','block');
  595.     //  $(this) = your current element that clicked.
  596.     // additional code
  597.     var id = event.target.id;
  598.     //alert(id);
  599.     //alert($(this));
  600.             _formurl    =   "home_stocktake_locations_list_group.php";
  601.             _formurl2   =   "home_stocktake_list.php";
  602.             _formurl3   =   "home_sales_graph.php";
  603.         _formdata   =   {'store_id' : id};
  604.         $.ajax({
  605.  
  606.          type: "GET",
  607.           url: _formurl,
  608.           data: _formdata,
  609.          success: function(xhrResponse)
  610.          {
  611.             $('#current').html(xhrResponse);
  612.             var rowCount = $('#locations').length;
  613.             row_count = parseInt(rowCount) ;
  614.           },
  615.           error: function(XMLHttpRequest, textStatus, errorThrown)
  616.           {
  617.             $('#alert_msg').html(errorThrown);
  618.             $('#alert_msg').fadeIn( "slow");
  619.  
  620.           }
  621.     });
  622.     $.ajax({
  623.  
  624.          type: "GET",
  625.           url: _formurl3,
  626.           data: _formdata,
  627.          success: function(xhrResponse)
  628.          {
  629.             $('#graph').html(xhrResponse);
  630.             var rowCount = $('#sales_graph').length;
  631.             row_count = parseInt(rowCount) ;
  632.           },
  633.           error: function(XMLHttpRequest, textStatus, errorThrown)
  634.           {
  635.             $('#alert_msg').html(errorThrown);
  636.             $('#alert_msg').fadeIn( "slow");
  637.  
  638.           }
  639.     });
  640.     $.ajax({
  641.  
  642.          type: "GET",
  643.           url: _formurl2,
  644.           data: _formdata,
  645.          success: function(xhrResponse)
  646.          {
  647.             $('#previous').html(xhrResponse);
  648.             var rowCount = $('#dd_home_stocktake').length;
  649.             row_count = parseInt(rowCount) ;
  650.           },
  651.           error: function(XMLHttpRequest, textStatus, errorThrown)
  652.           {
  653.             $('#alert_msg').html(errorThrown);
  654.             $('#alert_msg').fadeIn( "slow");
  655.  
  656.           }
  657.     });
  658.  
  659. });
  660.  
  661. $(document.body).on('click', '.desc', function(event)
  662.     {
  663.         $("#tableDiv").hide();
  664.     $("#currentDiv").css('display','block');
  665.     $("#previousDiv").css('display','block');
  666.     //  $(this) = your current element that clicked.
  667.     // additional code
  668.     var id = event.target.id;
  669.     //alert(id);
  670.     //alert($(this));
  671.             _formurl    =   "home_stocktake_locations_list_group.php";
  672.             _formurl2   =   "home_stocktake_list.php";
  673.             _formurl3   =   "home_sales_graph.php";
  674.         _formdata   =   {'store_id' : id};
  675.         $.ajax({
  676.  
  677.          type: "GET",
  678.           url: _formurl,
  679.           data: _formdata,
  680.          success: function(xhrResponse)
  681.          {
  682.             $('#current').html(xhrResponse);
  683.             var rowCount = $('#locations').length;
  684.             row_count = parseInt(rowCount) ;
  685.           },
  686.           error: function(XMLHttpRequest, textStatus, errorThrown)
  687.           {
  688.             $('#alert_msg').html(errorThrown);
  689.             $('#alert_msg').fadeIn( "slow");
  690.  
  691.           }
  692.     });
  693.     $.ajax({
  694.  
  695.          type: "GET",
  696.           url: _formurl3,
  697.           data: _formdata,
  698.          success: function(xhrResponse)
  699.          {
  700.             $('#graph').html(xhrResponse);
  701.             var rowCount = $('#sales_graph').length;
  702.             row_count = parseInt(rowCount) ;
  703.           },
  704.           error: function(XMLHttpRequest, textStatus, errorThrown)
  705.           {
  706.             $('#alert_msg').html(errorThrown);
  707.             $('#alert_msg').fadeIn( "slow");
  708.  
  709.           }
  710.     });
  711.     $.ajax({
  712.  
  713.          type: "GET",
  714.           url: _formurl2,
  715.           data: _formdata,
  716.          success: function(xhrResponse)
  717.          {
  718.             $('#previous').html(xhrResponse);
  719.             var rowCount = $('#dd_home_stocktake').length;
  720.             row_count = parseInt(rowCount) ;
  721.           },
  722.           error: function(XMLHttpRequest, textStatus, errorThrown)
  723.           {
  724.             $('#alert_msg').html(errorThrown);
  725.             $('#alert_msg').fadeIn( "slow");
  726.  
  727.           }
  728.     });
  729.  
  730. });
  731. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement