mobile scheduler recurring

The ‘event preview’ template can be found at [url]Formatting Labels, Dates, Styles Scheduler Docs, but I want to add my custom field to there for recurring event enable version. If I use that template for creating recurring event, the start time and end time in ‘event preview’ are not displayed correctly. I can not manage how to deal with event_length and the start time in order to get the end time of an event.

Can I have the template for an event in the ‘event preview’ screen for recurring version? Thanks!!!

Your prompt reply will be greatly appreciated :mrgreen:

Hello,

The selected_event template in recurring view has different definition. Please open dhxscheduler_mobile_rec_debug.js lines 15786-15806:

scheduler.templates.selected_event_old = scheduler.templates.selected_event;
scheduler.templates.selected_event = function(ev){

};

You should define scheduler.templates.selected_event based on template described in our docs, then call the lines that I mentioned above. Let me know if you need a demo.

May I have a demo, for example, adding a location field in the recurring event.

I met another problem when I add a new event without title(text).

part of code in .php

function validate_field($action){
        if($action->get_value("text")=="")
        $action->invalid();
} 

$scheduler->event->attach("beforeProcessing", "set_defaults");
$scheduler->event->attach("beforeInsert","validate_field");
$scheduler->event->attach("beforeUpdate","validate_field");
$scheduler->event->attach("beforeProcessing","delete_related");
$scheduler->event->attach("afterProcessing","insert_related");
$scheduler->render_table("event","event_id","start_date,end_date,text,allDay,rec_type,event_pid,event_length,details,location,user_create,user_involve,flag,color");

I suppose it will do nothing in both database and display on the web. In fact, it did not insert into database but it still display on the web. Any suggestion so that it will automatically not display the event on the web without refreshing the page manually?

forget to update of my last request of demo

May I have a demo, for example, adding a location field in the recurring event.
I have used a dull method to do that(copy and paste), no need to prepare a demo for me now. Thanks.

But I am still stunk on the display problem…

It would be better to set validation rules on client:

scheduler.config.form_rules["text"] = function(value,obj){ return value }

In case of server-side validation you can set onDBError event handler. For example:

dhx.dp($$("scheduler")).attachEvent("onDBError",function(response,request){ if(request.operation == "insert"){ $$("scheduler").remove(response.sid) } return true; })

It is awesome! This helps me a lot.
Thanks so much, Alexandra!

Regards,
samson

Sorry, I have a follow up question. Now, I show all the events which related to the user. Meanwhile, the events could be edited only if the event is created by the current user.

I validate the user by checking the session userid with a column named “user_create” in database.

[code]function check_authority($action){
global $scheduler;
$status = $action->get_status();
// check the event is created by the user so that the user can update or delete.
if ( $status == “delete” || $status == “update”){
$uid = $_SESSION[‘uid’];
$event_id =$action->get_value(“event_id”);
$result1 = mysql_query(“SELECT * FROM event WHERE (event_id = '” . $event_id . “') and (user_create = '” . $uid . “')”);
if (mysql_num_rows($result1) == 0){
$action->set_response_attribute(“details”,“authority”);
$action->invalid();
}
}

$scheduler->event->attach(“beforeProcessing”,“validate_field”);[/code]

However, I got a problem using the onDBError event handler.

dhx.dp($$("scheduler")).attachEvent("onDBError",function(response,request){ if(request.operation == "insert" || request.operation == "update"|| request.operation == "delete"){ $$("scheduler").remove(response.sid) } return true; })

Once a user who is not authorized and try to edit and save the change, the firebug shows something like below. (TypeError: request is undefined )

Any suggestion to fix it?

check for “inserted” as well as “insert”

The regular scheduler and mobile scheduler are different in what they send as the type.

Thanks for your advice, btex!

Unfortunately, the same error is still here. I still do not know how to fix it. :frowning:

Try to disable DataProcessor before calling “remove” method:

dhx.dp($$("scheduler")).attachEvent("onDBError",function(response,request){ if(request.operation == "insert" || request.operation == "update"|| request.operation == "delete"){ this.off(); $$("scheduler").remove(response.sid); this.on(); } });

Thanks, the error message does not display now.

If I tried to delete a event which is not authorized to do, it triggered the onDBError function and back to a blank selected event page. However, when I back to list view, the selected item is disappeared unless I reload the page (The affected event remains there after reload).

Sorry that I have longwinded questions…

it triggered the onDBError function and back to a blank selected event page. However, when I back to list view, the selected item is disappeared unless I reload the page

You removed the event on client and did not send the request to the server. So, the behavior is correct.
Please explain in detail what you want to achieve. It is not clear.

Maybe I take some screen dump for explanation.

The event “Testing 1234” is an event which is created by someone else. Therefore, suppose the user does not have the right to edit this. Since this is a meeting event, the current involved in this event so it will be displayed.

However, the user still can go into event detail page and press edit button to go to edit page. For example, change the title to be “Testing 12345678” and press save button.

It shows up the alert. Also, you can see the background have no details of the event and is blank. (which I do not expect like this)

After click “ok” and press button back to list view. This event is disappeared. In other words, the event is not shown on the list view any more.

Then I reload the whole page and the event will display correctly on the list view again.


Since my application is designed to run in the mobile application. The user cannot refresh the page. So it will cause a problem for the user. I would like to know how can it displays correctly without refreshing the page.

I hope it can display the detail after popup the alert instead of a blank detail page. And when the user click back button, the event will still on the list and displayed correctly.

I believe that after the user . it sets $action to be “invalid” during the checking in check_authority function before “update” on the server side. And it triggered the onDBError event handler as well as popup the alert. But I am frustrated why the event is still disappear after these procedures.

I am not good at coding, hope u can give any advice. Thanks a lot.


Attached the snippet coding for easier reference.
client-side

dhx.dp($$("scheduler")).attachEvent("onDBError",function(response,request){ if(request.operation == "insert" || request.operation == "update"|| request.operation == "delete"){ this.off(); $$("scheduler").remove(response.sid); this.on(); } if(response.details == "authority"){ dhx.alert("This action is not authorized."); } return true; })

server-side

[code]function check_authority($action){
global $scheduler;
$status = $action->get_status();
// check the event is created by the user so that the user can update or delete.
if ( $status == “delete” || $status == “update”){
$uid = $_SESSION[‘uid’];
$event_id =$action->get_value(“event_id”);
$result3 = mysql_query(“SELECT * FROM event WHERE (event_id = '” .$scheduler->sql->escape($action->get_id()). “') and (user_create = '” . $uid . “')”);
if (mysql_num_rows($result3) == 0){
$action->set_response_attribute(“details”,“authority”);
$action->invalid();
}
}

$mainSQL = "SELECT * FROM event WHERE user_involve = ".$_SESSION[‘uid’];
$scheduler->event->attach(“beforeProcessing”, “check_authority”);
$scheduler->event->attach(“beforeProcessing”,“insert”);
$scheduler->event->attach(“beforeProcessing”,“update”);
$scheduler->event->attach(“beforeProcessing”,“delete”);
$scheduler->render_table($mainSQL, “event_id”, “start_date,end_date,text,eventType,invitee,allDay,rec_type,event_pid,event_length,details,location,user_create,user_involve,flag,color,event_fid,event_id,x,y”);
[/code]

Attached also the db log

====================================
Log started, 27/03/2013 10:41:41

DataProcessor object initialized
1364390412388_id => 1364390412388
1364390412388_start_date => 2013-03-27 22:00
1364390412388_end_date => 2013-03-27 23:00
1364390412388_text => Testing 12345678
1364390412388_eventType => 1
1364390412388_invitee => test1,test2
1364390412388_allDay => 0
1364390412388_rec_type =>
1364390412388_event_pid => 0
1364390412388_event_length => 0
1364390412388_details =>
1364390412388_location =>
1364390412388_user_create => 1
1364390412388_user_involve => 3
1364390412388_flag => 0
1364390412388_color =>
1364390412388_event_fid => 57
1364390412388_event_id => 1364390412388
1364390412388_x => 0.000000
1364390412388_y => 0.000000
1364390412388__pid_time => 0
1364390412388_set_location => Use Map
1364390412388_endRepeat =>
1364390412388_!nativeeditor_status => update
ids => 1364390412388

Row data [1364390412388]
event_id => 1364390412388
start_date => 2013-03-27 22:00
end_date => 2013-03-27 23:00
text => Testing 12345678
eventType => 1
invitee => test1,test2
allDay => 0
rec_type =>
event_pid => 0
event_length => 0
details =>
location =>
user_create => 1
user_involve => 3
flag => 0
color =>
event_fid => 57
x => 0.000000
y => 0.000000
_pid_time => 0
set_location => Use Map
endRepeat =>
!nativeeditor_status => update

Edit operation finished
0 => action:invalid; sid:1364390412388; tid:1364390412388;

Done in 0.0042040348052979s

Hello,

doesn’t readonly property for events solve the problem ? In my opinion, it would be better if “delete” and “edit” buttons were not shown for the events created by other users.

If for some reasons you want to show “edit” button for a non-authorized user, you can set a validation rule for text field. There you can check whether the user is logged in. The validation rule should return true or false value. For example

scheduler.config.form_rules.text = function(value,obj){ if(checkUser()) return true dhx.alert("this action is not authorized!"); return false; }

Hi, Alexandra

That’s a good suggestion!! Thanks for your advice :slight_smile:

Regards,
samson