Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#question Add item price in details view of Detailed Receiving's Report #3974

Open
7 tasks done
minamagdy1995 opened this issue Apr 23, 2024 · 3 comments
Open
7 tasks done

Comments

@minamagdy1995
Copy link

minamagdy1995 commented Apr 23, 2024

This is a question in a customization of a specific report "Detailed receiving's report" of which i want help. you can find the details at the end.

Background information

IMPORTANT: If you choose to ignore this issue report template, your issue will be closed as we cannot help without the requested information.

Please make sure you tick (add an x between the square brackets with no spaces) the following check boxes:

  • Reporting an issue of an unmodified OSPOS installation
  • Checked open and closed issues and no similar issue was already reported (please make sure you searched!)
  • Read README, WHATS_NEW, INSTALL.md and UPGRADE
  • Read the FAQ for any known install and/or upgrade gotchas (in specific PHP extensions installed)
  • Read the wiki
  • Executed any database upgrade scripts if an upgrade pre 3.0.0 (e.g. database/2.4_to_3.0.sql)
  • Aware the installation code that GitHub master is for developers only and therefore not complete nor stable.

Installation information

  • OSPOS version is: 3.3.9
  • OSPOS git commit hash is: c00ff2
  • PHP version is:
  • MySQL or MariaDB version is:
  • OS and version is: win 10 22H2 (Os Build: 19045.4291)
  • WebServer is: Xampp
  • Selected language is: English
  • (If applicable) Docker installation:
  • (If applicable) Installation package for the LAMP/LEMP stack is:

Issue / Bug / Question / New Feature

Please write your issue here. If a bug, please make sure to provide as much information as possible including configuration settings (e.g. Decimals set, Tax mode), language and steps to reproduce the bug.

MY QUESTION

he wanted to customize a specific report "Detailed receiving's report with all time date range" inorder to show the cost price of each item and i customized the report accordingly via the reports.php file in application/controllers but the column does not show the price which i cannot find a solution to can you please help. attached below is the image of the report and the function from reports.php file.

Report IMAGE

image

REPORTS.PHP FILE

public function detailed_receivings($start_date, $end_date, $receiving_type, $location_id = 'all')
{
	$definition_names = $this->Attribute->get_definitions_by_flags(Attribute::SHOW_IN_RECEIVINGS);

	$inputs = array('start_date' => $start_date, 'end_date' => $end_date, 'receiving_type' => $receiving_type, 'location_id' => $location_id, 'definition_ids' => array_keys($definition_names));

	$this->load->model('reports/Detailed_receivings');
	$model = $this->Detailed_receivings;

	$model->create($inputs);

	$columns = $model->getDataColumns();
	$columns['details'] = array_merge($columns['details'], $definition_names);

	$headers = $this->xss_clean($columns);
	$report_data = $model->getData($inputs);

	$summary_data = array();
	$details_data = array();

	$show_locations = $this->xss_clean($this->Stock_location->multiple_locations());

	foreach($report_data['summary'] as $key => $row)
	{
		$summary_data[] = $this->xss_clean(array(
			'id' => $row['receiving_id'],
			'receiving_time' => to_datetime(strtotime($row['receiving_time'])),
			'quantity' => to_quantity_decimals($row['items_purchased']),
			'employee_name' => $row['employee_name'],
			'supplier_name' => $row['supplier_name'],
			'total' => to_currency($row['total']),
			'profit' => to_currency($row['profit']),
			'payment_type' => $row['payment_type'],
			'reference' => $row['reference'],
			'comment' => $row['comment'],
			'edit' => anchor('receivings/edit/' . $row['receiving_id'], '<span class="glyphicon glyphicon-edit"></span>',
				array('class' => 'modal-dlg print_hide', 'data-btn-delete' => $this->lang->line('common_delete'), 'data-btn-submit' => $this->lang->line('common_submit'), 'title' => $this->lang->line('receivings_update'))
			)
		));

		foreach($report_data['details'][$key] as $drow)
		{
			$quantity_purchased = $drow['receiving_quantity'] > 1 ? to_quantity_decimals($drow['quantity_purchased']) . ' x ' . to_quantity_decimals($drow['receiving_quantity']) : to_quantity_decimals($drow['quantity_purchased']);
			if($show_locations)
			{
				$quantity_purchased .= ' [' . $this->Stock_location->get_location_name($drow['item_location']) . ']';
			}

			$attribute_values = expand_attribute_values($definition_names, $drow);

			$details_data[$row['receiving_id']][] = $this->xss_clean(array_merge(array(
				$drow['item_number'],
				$drow['name'],
				$drow['category'],
				$quantity_purchased,
				$item['price'],
				to_currency($drow['total']),
				($drow['discount_type'] == PERCENT)? $drow['discount'].'%':to_currency($drow['discount'])), $attribute_values));
		}
	}

	$data = array(
		'title' => $this->lang->line('reports_detailed_receivings_report'),
		'subtitle' => $this->_get_subtitle_report(array('start_date' => $start_date, 'end_date' => $end_date)),
		'headers' => $headers,
		'editable' => 'receivings',
		'summary_data' => $summary_data,
		'details_data' => $details_data,
		'overall_summary_data' => $this->xss_clean($model->getSummaryData($inputs))
	);

	$this->load->view('reports/tabular_details', $data);
}
@minamagdy1995
Copy link
Author

Could someone please tell me what i have to do and i will do it.

I know that you guys have read my issue.

@minamagdy1995 minamagdy1995 changed the title Add item price in details view of Detailed Receiving's Report #question Add item price in details view of Detailed Receiving's Report May 7, 2024
@jekkos
Copy link
Member

jekkos commented May 9, 2024

Hi for now we only accept submissions on ci4 branch of the code, as a lot was changed since the upgrade. Ideally you make it work against that version and then send a PR.

@jekkos
Copy link
Member

jekkos commented May 9, 2024

can you change the variable $item[price] to $drow[price]?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants