Post by jgw1 » Fri Aug 02, 2013 6:42 am

Right I am modifying a support ticket system so that the ticket conversation thread includes any order history comments. I have successfully modified the extension so that the order comments are returned from the database.

I have filled in the fields that are missing from the array for each respective call (see below).

The two function calls outputs are merged as data['messages'] and display correctly on the front end. However what I want to do is sort the comments from the two functions by the field 'created' so that they appear in order.

Any help? I got to this point and an evenings playing has go me knowwhere.

Code: Select all

$results = $this->model_ticket_message->getOrderHistories(1, 1, 10);
      		
		foreach ($results as $result) {
        	$this->data['messages'][] = array(
				'status'     => $result['status'],
				'content'    => nl2br($result['comment']),
        		'created' => $result['date_added'],
				'is_user' => 0,
				'order_history' => 1
        	);
      	}
			
		$results  = $this->model_ticket_message->getMessages( array('filter_ticket' => $ticket_id) );
		
		foreach ($results as $result) {
        	$this->data['messages'][] = array(
				'status'     => '',
				'content'    => nl2br($result['content']),
        		'created' => $result['created'],
				'is_user' => $result['is_user'],
				'order_history' => 0
        	);
      	}
Last edited by Johnathan on Sun Aug 04, 2013 4:58 am, edited 1 time in total.
Reason: Retitled to accurately describe the topic

New member

Posts

Joined
Tue Apr 20, 2010 5:22 pm

Post by butte » Fri Aug 02, 2013 7:20 am

Try asking the extension's author.

Guru Member

Posts

Joined
Wed Mar 20, 2013 6:58 am

Post by ogun » Fri Aug 02, 2013 9:12 am

If you can't get hold of them for some reason then this might get you towards a solution:

http://stackoverflow.com/a/2627688

Active Member

Posts

Joined
Tue Aug 14, 2007 6:04 am

Post by pprmkr » Fri Aug 02, 2013 1:52 pm

Edit the query in model_ticket_message->getMessages and add:

Code: Select all

 ORDER BY created ASC
or

Code: Select all

 ORDER BY created DESC
ASC = ascending
DESC = descending

User avatar
Active Member

Posts

Joined
Sat Jan 08, 2011 11:05 pm
Location - Netherlands

Post by Qphoria » Fri Aug 02, 2013 8:05 pm

Make a post with a bullshit topic like this again and I will ban your account

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by jgw1 » Sat Aug 03, 2013 3:18 am

It is not a bullshit thread.

I have two arrays returned from two queries to the database. They are then incorporated into a multidimensional row and used in the .tpl file. I would like to know how to sort the mulitdimensional array by one of the values.

The two separate returned queries are both sorted in the sql call but they aren't reordered when I put them in the multidimensional array.

I could contact the extension seller, but since I am customising their module they are in no obligation to help me.

New member

Posts

Joined
Tue Apr 20, 2010 5:22 pm

Post by Qphoria » Sat Aug 03, 2013 3:53 am

I said "Topic" not "thread".
"This is a Juicy one" is a misleading title. Make a title that summarizes the issue.

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by jgw1 » Sat Aug 03, 2013 4:02 am

Well it would help if you said that from the start rather that use profanity.

New member

Posts

Joined
Tue Apr 20, 2010 5:22 pm

Post by Qphoria » Sat Aug 03, 2013 4:42 am

jgw1 wrote:Well it would help if you said that from the start rather that use profanity.
I did say "topic" from the start.

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by ase618 » Sat Aug 03, 2013 6:13 am

lol

artisantool.co
Don't forget to add [SOLVED] to your Thread Title (first post), if your issue is solved.


Active Member

Posts

Joined
Sun Jul 29, 2012 9:59 pm
Who is online

Users browsing this forum: No registered users and 19 guests