Jump to content

Please Help me with little math usig php/MySQL read this post


wajdan

Recommended Posts

Once upon a time needed help on March 12, 2008 this community helped me, I am still a learner tried to help back but all the problems posted here beyond my skills to solve them so I kept quiet.  and Now I need help once again hope I will get it done.

 

Its PHPPOS developed in Codeigniter This code below is from application\controllers\inventory_summary.php file

 

<?php
require_once("report.php");
class Inventory_summary extends Report
{
function __construct()
{
	parent::__construct();
}

public function getDataColumns()
{
	return array($this->lang->line('reports_item_name'), $this->lang->line('reports_item_number'), $this->lang->line('reports_description'), $this->lang->line('reports_count'), $this->lang->line('reports_reorder_level'));
}

public function getData(array $inputs)
{
	$this->db->select('name, item_number, quantity, reorder_level, description');
	$this->db->from('items');
	$this->db->where('deleted', 0);	
	$this->db->order_by('name');

	return $this->db->get()->result_array();

}

public function getSummaryData(array $inputs)
{
	return array();
}
}
?>

 

And this partial code below  is from application\controllers\report.php file

 

 

function inventory_summary($export_excel=0)
  {
    $this->load->model('reports/Inventory_summary');
    $model = $this->Inventory_summary;
    $tabular_data = array();
    $report_data = $model->getData(array());
    foreach($report_data as $row)
    {
      $tabular_data[] = array($row['name'], $row['item_number'], $row['description'], $row['quantity'], $row['reorder_level']);
    }

    $data = array(
      "title" => $this->lang->line('reports_inventory_summary_report'),
      "subtitle" => '',
      "headers" => $model->getDataColumns(),
      "data" => $tabular_data,
      "summary_data" => $model->getSummaryData(array()),
      "export_excel" => $export_excel
    );

    $this->load->view("reports/tabular",$data);  
  }
  
}
?>

 

Together they get the job done as follow:

 

 

 

Item Name Item Number Description Count Reorder Level  (Count is quantity in stock)

Item 1                  0002            xyz                    5                  3

Item 2                  0s00            xyz                    5                  3

Item 3                  0005            xyz                    5                  3

Item 4                  0006            xyz                    5                  3

 

 

The output I want need to be like this:

 

Item Name Item Number Description cost price        Count     Reorder Level

Item 1                  0002            xyz                      250                5                  3

Item 2                  0s00            xyz                      120                5                  3

Item 3                  0005            xyz                      300                5                  3

Item 4                  0006            xyz                      500                5                  3

                                                                                   

                                                Total Stock Value  5850  Total Count 20  <-- this doesn't require any formation just needs to be at bottom of all the queries  like shown here.

         

 

This is what I want mainly >>>>>>>>>>  Total Stock Value (cost price * count foreach and then sum of all results ) and  sum of all count

 

 

cost price table and column is different than one used above in the code which is:

 

databse table is ' receivings_items '

Column is 'item_cost_price'

 

example php code to fetch is :

 

 

$sql = "SELECT `item_cost_price` FROM `receivings_items`"; 

 

config.php contains all the connection variables to MySQL

 

 

 

Please Help me  :-\

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.