RSS

LuxCal Forum

The place for questions, suggestions and news about the LuxCal Event Calendar

User:   Password:   Remember Me?   
LuxCal Forum / General / Support / Sort all day events in Alphabetical Order
Posted:  17 Sep 2015 22:27
I have users that are using the fabulous LuxCal Calendar (current MySql edition) as a type of "bulletin board" for an employee's whereabouts on a given day. There are multiple entries and they are placed in a specific order (Alphabetical). However, once the item is edited, it moves in the date field and is no longer in Alphabetical order. How can I make sort in Alphabetical order as the default.

Thank you for an amazing product.
Posted:  18 Sep 2015 09:16   Last Edited By: Roel B.
Hi there,
The sorting of events is done on a "per day" basis by the "sortEvt" function on line 33 of the common/retrieve.php file.
So if you would change line 33 of retrieve.php from . . .

function sortEvt($a, $b) { return strcmp(str_pad($a['sti'],5).$a['seq'], str_pad($b['sti'],5).$b['seq']); }

into . . .

function sortEvt($a, $b) { return strcmp($a['tit'], $b['tit']); }

then in all views per day the events will be shown in alphabetical order (sorted on event title).

This is probably not what you are looking for. If you want something else, please give me more details.
Roel
Posted:  18 Sep 2015 15:11
Thank you for your prompt reply!

Yes, this is close. But, just having the event sorted according to the order it was entered would suffice.

For instance, on a holiday such as Christmas, if you enter Christmas on that day and then enter another item or name the "Christmas" moves within the day field and is no longer at the top.

I guess what I'm asking is when entering items is it possible to make them stay in the order you entered them. Again, this should apply only to events that are flagged as an "all day event".

Thank you, I hope that helps.
Posted:  18 Sep 2015 21:02
Hey you said alphabetical in your first post ohmy
Ok, no hard feelings.

Here we go:
Change line 33 of retrieve.php from . . .

function sortEvt($a, $b) { return strcmp(str_pad($a['sti'],5).$a['seq'], str_pad($b['sti'],5).$b['seq']); }

into . . .

function sortEvt($a,$b) {
    $orderIn = (strcmp($a['adt'],$b['adt']) < 0) ? '0' : '2';
    return strcmp(str_pad($a['sti'],5).'1', str_pad($b['sti'],5).$orderIn);
}


then in all views per day the allday events will be shown in the order they are entered.
Roel
Posted:  19 Sep 2015 02:52
Thank you very much! That's perfect! thump_up

Yes, I said Alphabetical, but then the users changed the spec on me. I'm sure you have encountered similar! smile

Thank you again for your excellent product and support!
Posted:  21 Sep 2015 22:03
Well, almost perfect. sad

A user pointed out to me today that when changing an event from one with a start and end time to an all day event or vice versa will cause that event to jump to the top or randomly insert itself in between other events.

Thank you for your time and patience with these requests, maybe they could be incorporated in the next release as a choice in the settings area.
Posted:  21 Sep 2015 22:27
I discovered the users were entering the events in reverse order to get the last item entered to appear at the top and assigning the "all day"  event and have it repeat...then they are going in and editing just the occurrence of the event and modifying, that's when it jumps around. They want any item entered in a particular order to stay in that order regardless of what editing they do on the event.

I'm not sure it is even possible to do what they are asking!
Posted:  22 Sep 2015 22:16   Last Edited By: Roel B.
You will have to explain to me in detail what your users want, or what they don't like ohmy
With the above modification of the sortEvt function, all all-day events are always sorted on the "date/time the event was added to the calendar" in descending order (last entered at the top).
When an event with a start time, is edited and changed into an all-day event, it will of course jump from the list of events with a start time to the list of all-day events (which list is always at the top), but it will be correctly sorted in the list of all-day events.
When you modify a single occurrence of a repeating event, it will keep exactly the same "date/time entered to the calendar" as the repeating event, so it will be displayed just before or just after the original repeating event.

The only thing I can think of is that your users would like a changed occurrence of a repeating  event, to be considered a new event and consequently displayed at the top of the list.

Detailed examples please of what it should do and/or what goes wrong.
Roel
Posted:  18 Oct 2016 16:29   Last Edited By: Roel B.
Did things change in the new release, sorting alpha with :
function sortEvt($a, $b) { return strcmp($a['tit'], $b['tit']); }
seems to work on some events but not all, or is there something else doing sorting that i'm not seeing?  If I rem the function (//) it looks like things sort somewhat by the length of time the event has listed?
Posted:  18 Oct 2016 18:47
Hi there,

No there is no other sorting.
When you are sorting on "title", could you give me an example when it doesn't sort all events.
Could it be a lower/uppercase problem?
Maybe you should do:

function sortEvt($a, $b) { return strcmp(strtolower($a['tit']), strtolower($b['tit'])); }

Roel
Posted:  18 Oct 2016 20:10
Well I have a title with; Brian Karen Adams; ven = Brian; cid = offsite; sti=9am eti=10am
tit=Bert Water; ven=Bert; cid=vendor meeting; sti=10:30am eti=11:30am
tit=Bert J: test; ven=Bert; cid=appointment; sti=12pm eti=3pm
tit=Brian J  Michael & Nancy; ven=Brian; cid=appointment; sti=4:30pm eti=6:pm
These are in the first column (top to bottom) in that order, then to the right:
tit=Bert Show; ven=Bert; cid=Schedule; sti=9am eti=6pm
Now to the right again:
tit=Brian Helen Cleveland Install; ven=Brian; cid=offsite appointment; sti=10:30am eti=2pm
tit=Mary W Lunch; ven=Mary; cid=Lunch; sti=2pm eti=3pm
now to the right again:
tit=Nancy K  Paul Wick; ven=Nancy; cid=appointment; sti=10am eti=11:30am
tit=Brian J Lunch; ven=Brian; cid=Lunch; sti=12pm eti=1pm
tit=Jennifer Lunch; ven=Jennifer; cid=Lunch; sti=1pm sti=2pm
Now to the right again;
tit=Brian J: Showroom; ven=Brian; cid=schedule; sti=9am eti=6pm
Many more to the right but you get the idea, now what I'm using to sort is function sortEvt($a, $b) { return strcmp(strtolower($a['tit']), strtolower($b['tit'])); }
The only thing you maynot see is the lunch and schedule catagories repeat.  My goal was to have all the Berts on the left, followed by Brian, Jennifer, etc below and to the right.  This is all being done in the Day view.