Post by Sokonomi » Mon Dec 25, 2017 5:22 pm

Most of my customers order under a company or club name,
and finding back a company or clubs order history is a massive PITA..

Is there a way to expand the field filters a little bit?
Anyone wanna make a quick tenner? :P

Active Member

Posts

Joined
Sun Sep 30, 2012 4:52 am

Post by straightlight » Mon Dec 25, 2017 9:50 pm

No OC version posted. However, on the latest release, in your admin/controller/extension/report/sale_order.php file,

find:

Code: Select all

if (isset($this->request->get['filter_group'])) {
			$filter_group = $this->request->get['filter_group'];
		} else {
			$filter_group = 'week';
		}
add above:

Code: Select all

if (isset($this->request->get['filter_company'])) {
			$filter_company = $this->request->get['filter_company'];
		} else {
			$filter_company = '';
		}
Then, find:

Code: Select all

'filter_group'           => $filter_group,
add above:

Code: Select all

'filter_company'           => $filter_company,
Then, find:

Code: Select all

if (isset($this->request->get['filter_group'])) {
			$url .= '&filter_group=' . $this->request->get['filter_group'];
		}
add above:

Code: Select all

if (isset($this->request->get['filter_company'])) {
			$url .= '&filter_company=' . $this->request->get['filter_company'];
		}
Then, find:

Code: Select all

$data['filter_group'] = $filter_group;
add above:

Code: Select all

$data['filter_company'] = $filter_company;
In admin/model/extension/report/sale.php file,

find all instances of:

Code: Select all

if (!empty($data['filter_date_end'])) {
look at the date_added field below. If it contains: o. at the front, then above the instances of $data['filter_date_end'] from the above code statement, add it like this:

Code: Select all

if (!empty($data['filter_company'])) {
			$sql .= " AND DATE(o.company) <= '" . $this->db->escape((string)$data['filter_company']) . "'";
		}
If no o. is found at the front, add it like this:

Code: Select all

if (!empty($data['filter_company'])) {
			$sql .= " AND DATE(company) <= '" . $this->db->escape((string)$data['filter_company']) . "'";
		}
		
In admin/language/<your_language_code>/extension/report/sale_order.php file,

add at the bottom:

Code: Select all

$_['entry_company'] = 'Company';
In your admin/view/template/extension/report/sale_order_info.twig file,

find:

Code: Select all

<div class="form-group">
          <label class="control-label" for="input-group">{{ entry_group }}</label>
add above:

Code: Select all

<div class="form-group">
                      <label class="col-sm-2 control-label" for="input-company">{{ entry_company }</label>
                      <div class="col-sm-10">
                        <input type="text" name="filter_company" value="{{ filter_company ? filter_company }}" placeholder="{{ entry_company }}" id="input-company" class="form-control"/>
                      </div>
                    </div>
(You can also place its position the way you like)

Then, find:

Code: Select all

var filter_group = $('select[name=\'filter_group\']').val();
add above:

Code: Select all

var filter_company = $('input[name=\'filter_company\']').val();

if (filter_company) {
		url += '&filter_company=' + encodeURIComponent(filter_company);
	}
This should do it.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

User avatar
Active Member

Posts

Joined
Sun May 11, 2014 2:04 pm

Post by Sokonomi » Thu Mar 23, 2023 11:13 pm

Thanks for necromancing a 5 year old topic. :crazy:
Your answer also doesn't suit the request; I wanted to sort customers, not products.
I already ended up paying someone 5 years ago to write a plugin for me anyway.

Active Member

Posts

Joined
Sun Sep 30, 2012 4:52 am
Who is online

Users browsing this forum: No registered users and 59 guests