/********************************************************************************* * SugarCRM Community Edition is a customer relationship management program developed by * SugarCRM, Inc. Copyright (C) 2004-2012 SugarCRM Inc. * * This program is free software; you can redistribute it and/or modify it under * the terms of the GNU Affero General Public License version 3 as published by the * Free Software Foundation with the addition of the following permission added * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK * IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY * OF NON INFRINGEMENT OF THIRD PARTY RIGHTS. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more * details. * * You should have received a copy of the GNU Affero General Public License along with * this program; if not, see http://www.gnu.org/licenses or write to the Free * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA * 02110-1301 USA. * * You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road, * SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com. * * The interactive user interfaces in modified source and object code versions * of this program must display Appropriate Legal Notices, as required under * Section 5 of the GNU Affero General Public License version 3. * * In accordance with Section 7(b) of the GNU Affero General Public License version 3, * these Appropriate Legal Notices must retain the display of the "Powered by * SugarCRM" logo. If the display of the logo is not reasonably feasible for * technical reasons, the Appropriate Legal Notices must display the words * "Powered by SugarCRM". ********************************************************************************/ var CAL={};CAL.slot_height=14;CAL.dropped=0;CAL.records_openable=true;CAL.moved_from_cell="";CAL.deleted_id="";CAL.deleted_module="";CAL.tmp_header="";CAL.disable_creating=false;CAL.record_editable=false;CAL.shared_users={};CAL.shared_users_count=0;CAL.script_evaled=false;CAL.editDialog=false;CAL.settingsDialog=false;CAL.sharedDialog=false;CAL.basic={};CAL.basic.items={};CAL.update_dd=new YAHOO.util.CustomEvent("update_dd");CAL.dd_registry=new Object();CAL.resize_registry=new Object();CAL.print=false;CAL.dom=YAHOO.util.Dom;CAL.get=YAHOO.util.Dom.get;CAL.query=YAHOO.util.Selector.query;CAL.arrange_slot=function(cell_id){if(!cell_id) return;cellElm=document.getElementById(cell_id);if(cellElm){var total_height=0;var prev_i=0;var first=1;var top=0;var height=0;var cnt=0;var child_cnt=cellElm.childNodes.length;for(var i=0;i20) return;var depth=level;if(el!=null){if(level==1){ol_group={};ol_group.items=new Array();} ol_group.items.push({id:el.id,level:level});affected_items.push(el.id);} for(var i=start;i=slot_count) break;if(typeof slots[i].childNodes!='undefined'&&typeof slots[i].childNodes[0]!='undefined'){var pos=0;if(i==start){var node=slots[i].childNodes[0];while(node.nextSibling&&CAL.contains(affected_items,node.id)){node=node.nextSibling;pos++;}} var current=slots[i].childNodes[pos];var slots_takes=parseInt(current.getAttribute('duration_coef'));if(CAL.contains(affected_items,current.id)) continue;if(pos==0){var slot_id=current.parentNode.id;if(!CAL.contains(affected_slots,slot_id)) affected_slots.push(slot_id);} if(slots_takes>0){var k=find_overlapping(current,i,i+slots_takes,level+1,ol_group);if(k>depth) depth=k;}}} if(level==1){ol_group.depth=depth;ol.push(ol_group);} return depth;} function insert_empty_items(el,count,to_end){var slot=el.parentNode;for(var i=0;i0){if(node==this) return;else node=node.parentNode;i--;} CAL.get(el.id).style.zIndex='';CAL.disable_creating=false;});CAL.clear_additional_details(params.id);return el;} CAL.make_draggable=function(id,type){var border;var prefix;var id_prefix;border="cal-grid";if(type=="basic"){if(CAL.view!="month"&&CAL.view!="shared") border="cal-multiday-bar";prefix="basic_";id_prefix="b_";}else{if(CAL.view!="month") border="cal-scrollable";prefix="";id_prefix="t_";} var dd=new YAHOO.util.DDCAL(id,prefix+"cal",{isTarget:false,cont:border});CAL.dd_registry[id]=dd;dd.onInvalidDrop=function(e){if(type=="basic"){CAL.basic.populate_grid();CAL.fit_grid();}else{CAL.arrange_slot(this.el.parentNode.getAttribute("id"));if(CAL.dropped==0){this.el.childNodes[0].innerHTML=CAL.tmp_header;}} CAL.records_openable=true;CAL.disable_creating=false;} dd.onMouseDown=function(e){YAHOO.util.DDM.mode=YAHOO.util.DDM.POINT;YAHOO.util.DDM.clickPixelThresh=20;} dd.onMouseUp=function(e){YAHOO.util.DDM.mode=YAHOO.util.DDM.INTERSECT;YAHOO.util.DDM.clickPixelThresh=3;} dd.startDrag=function(x,y){this.el=document.getElementById(this.id);this.el.style.zIndex=5;CAL.dropped=0;CAL.records_openable=false;CAL.disable_creating=true;CAL.tmp_header=this.el.childNodes[0].innerHTML;CAL.moved_from_cell=this.el.parentNode.id;this.setDelta(2,2);} dd.endDrag=function(x,y){this.el=document.getElementById(this.id);this.el.style.zIndex="";var nodes=CAL.query("#cal-grid div."+prefix+"slot");CAL.each(nodes,function(i,v){YAHOO.util.Dom.removeClass(nodes[i],"slot_active");});} dd.onDragDrop=function(e,id){var slot=document.getElementById(id);YAHOO.util.Dom.removeClass(slot,"slot_active");if(CAL.dropped) return;CAL.dropped=1;this.el.style.position="relative";this.el.style.cssFloat="none";if(type=="advanced"){if(CAL.view!='shared'){var box_id=this.id;var slot_id=id;var ex_slot_id=CAL.moved_from_cell;CAL.move_activity(box_id,slot_id,ex_slot_id);}else{var record=this.el.getAttribute("record");var tid=id;var tar=tid.split("_");var timestamp=tar[1];var tid=CAL.moved_from_cell;var tar=tid.split("_");var ex_timestamp=tar[1];for(i=0;i7.5) remainder=(-1)*(15-remainder);duration=duration-remainder;var duration_hours=parseInt(duration / 60);var duration_minutes=duration%60;var new_size=(duration / CAL.t_step)*(CAL.slot_height+1)-1;var el=CAL.get(elm_id);if(el){el.style.zIndex='';el.style.height=new_size+"px";CAL.arrange_slot(slot.id);var nodes=CAL.query("#cal-grid div.act_item");CAL.each(nodes,function(i,v){nodes[i].style.zIndex='';});var duration_coef=duration / CAL.t_step;el.setAttribute("duration_coef",duration_coef);if(duration_coef<1.75) el.childNodes[1].style.display="none";else el.childNodes[1].style.display="";var callback={success:function(o){try{res=eval("("+o.responseText+")");}catch(err){alert(CAL.lbl_error_saving);ajaxStatus.hideStatus();return;} if(res.access=='yes'){CAL.update_vcal();CAL.clear_additional_details(el.getAttribute("record"));CAL.arrange_column(slot.parentNode);CAL.update_dd.fire();ajaxStatus.hideStatus();CAL.disable_creating=false;CAL.records_openable=true;}}};ajaxStatus.showStatus(SUGAR.language.get('app_strings','LBL_SAVING'));var url="index.php?module=Calendar&action=Resize&sugar_body_only=true";var data={"current_module":el.getAttribute("module_name"),"record":el.getAttribute("record"),"duration_hours":duration_hours,"duration_minutes":duration_minutes};YAHOO.util.Connect.asyncRequest('POST',url,callback,CAL.toURI(data));}});} CAL.destroy_ui=function(id){if(CAL.items_resizable&&typeof CAL.resize_registry[id]!="undefined"){CAL.resize_registry[id].destroy();delete CAL.resize_registry[id];} if(CAL.items_draggable&&typeof CAL.dd_registry[id]!="undefined") CAL.dd_registry[id].unreg();delete CAL.dd_registry[id];} CAL.basic.remove=function(item){if(typeof CAL.basic.items[item.user_id]=='undefined') CAL.basic.items[item.user_id]=new Object();delete CAL.basic.items[item.user_id][item.record];} CAL.basic.add=function(item){if(typeof CAL.basic.items[item.user_id]=='undefined') CAL.basic.items[item.user_id]=new Object();CAL.basic.items[item.user_id][item.record]=item;} CAL.basic.populate_grid=function(){var nodes=CAL.query("#cal-grid .cal-basic .col .act_item");CAL.each(nodes,function(i,v){nodes[i].parentNode.removeChild(nodes[i]);});var users_arr=new Array();if(CAL.view!="shared"){users_arr.push(CAL.current_user_id);}else{CAL.each(CAL.shared_users,function(i,v){users_arr.push(i);});} for(ui=0;uipos) pos=equalizer[d];} for(d=from;dmax_pos) max_pos=pos;var item=CAL.basic.items[user_id][portion[i].id];var slot=CAL.get("b_"+portion[i].from+suffix);if(slot){var time_start=item.time_start;if(item.ts_start1){CAL.basic.add(item);return;} var head_text=CAL.get_header_text(item.type,item.time_start,item.name,item.record);var time_cell=item.timestamp-item.timestamp%(CAL.t_step*60);var duration_coef;if(item.module_name=='Tasks'){duration_coef=1;}else{if((item.duration_minutes "+text;return start_text;} CAL.cut_record=function(id){var el=CAL.get(id);if(!el) return;var duration_coef=el.getAttribute("duration_coef");real_celcount=CAL.cells_per_day;var celpos=0;var s=el.parentNode;while(s.previousSibling){celpos++;s=s.previousSibling;} celpos=celpos+1;if(real_celcount-celpos-duration_coef<0) duration_coef=real_celcount-celpos+1;el.style.height=parseInt((CAL.slot_height+1)*duration_coef-1)+"px";} CAL.init_edit_dialog=function(params){CAL.editDialog=false;var rd=CAL.get("cal-edit");var content=CAL.get("edit-dialog-content");if(CAL.dashlet&&rd){document.getElementById("content").appendChild(rd);} rd.style.width=params.width+"px";content.style.height=params.height+"px";content.style.overflow="auto";content.style.padding="0";CAL.editDialog=new YAHOO.widget.Dialog("cal-edit",{draggable:true,visible:false,modal:true,close:true,y:1,zIndex:10});var listeners=new YAHOO.util.KeyListener(document,{keys:27},{fn:function(){CAL.editDialog.cancel();}});CAL.editDialog.cfg.queueProperty("keylisteners",listeners);CAL.editDialog.cancelEvent.subscribe(function(e,a,o){CAL.close_edit_dialog();});rd.style.display="block";CAL.editDialog.render();rd.style.overflow="auto";rd.style.overflowX="hidden";rd.style.outline="0 none";rd.style.height="auto";} CAL.open_edit_dialog=function(params){document.getElementById("form_content").innerHTML="";CAL.editDialog.center();CAL.editDialog.show();var nodes=CAL.query("#cal-tabs li a");CAL.each(nodes,function(i,v){YAHOO.util.Event.on(nodes[i],'click',function(){CAL.select_tab(this.getAttribute("tabname"));});});stay_on_tab=false if(typeof params!="undefined"&&typeof params.stay_on_tab!="undefined"&¶ms.stay_on_tab) stay_on_tab=true;if(!stay_on_tab){var nodes_li=CAL.query("#cal-tabs li");CAL.each(nodes_li,function(j,v){CAL.dom.removeClass(nodes_li[j],"selected");if(j==0) CAL.dom.addClass(nodes_li[j],"selected");});var nodes=CAL.query(".yui-nav");CAL.each(nodes,function(i,v){nodes[i].style.overflowX="visible";});}} CAL.close_edit_dialog=function(){CAL.reset_edit_dialog();} CAL.remove_edit_dialog=function(){var rd_c=CAL.get("cal-edit_c");if(rd_c){rd_c.parentNode.removeChild(rd_c);}} CAL.reset_edit_dialog=function(){var e;document.forms["CalendarEditView"].elements["current_module"].value="Meetings";CAL.get("radio_call").removeAttribute("disabled");CAL.get("radio_meeting").removeAttribute("disabled");CAL.get("radio_call").checked=false;CAL.get("radio_meeting").checked=true;CAL.get("send_invites").value="";if(e=CAL.get("record")) e.value="";if(e=CAL.get("list_div_win")) e.style.display="none";if(typeof SugarWidgetSchedulerSearch.hideCreateForm!='undefined') SugarWidgetSchedulerSearch.hideCreateForm();$("#scheduler .schedulerInvitees").css("display","");$("#create-invitees-title").css("display","");$("#create-invitees-buttons").css("display","");if(CAL.enable_repeat){CAL.reset_repeat_form();} CAL.GR_update_focus("Meetings","");CAL.select_tab("cal-tab-1");QSFieldsArray=new Array();QSProcessedFieldsArray=new Array();} CAL.reset_repeat_form=function(){document.forms['CalendarRepeatForm'].reset();var fields=['type','interval','count','until','dow'];CAL.each(fields,function(i,field){CAL.get('repeat_'+field).value="";});toggle_repeat_type();CAL.get("repeat_parent_id").value="";CAL.get("edit_all_recurrences").value="";CAL.get("edit_all_recurrences_block").style.display="none";CAL.get("cal-repeat-block").style.display="none";} CAL.select_tab=function(tid){var nodes_li=CAL.query("#cal-tabs li");CAL.each(nodes_li,function(j,v){CAL.dom.removeClass(nodes_li[j],"selected");});CAL.dom.addClass(CAL.get(tid+"-link").parentNode,"selected");var nodes=CAL.query("#cal-tabs .yui-content");CAL.each(nodes,function(i,v){nodes[i].style.display="none";});var nodes=CAL.query("#cal-tabs #"+tid);CAL.each(nodes,function(i,v){nodes[i].style.display="block";});} CAL.fill_repeat_data=function(){if(CAL.enable_repeat&&(CAL.get("current_module").value=="Meetings"||CAL.get("current_module").value=="Calls")){if(repeat_type=document.forms['CalendarRepeatForm'].repeat_type.value){document.forms['CalendarEditView'].repeat_type.value=repeat_type;document.forms['CalendarEditView'].repeat_interval.value=document.forms['CalendarRepeatForm'].repeat_interval.value;if(document.getElementById("repeat_count_radio").checked){document.forms['CalendarEditView'].repeat_count.value=document.forms['CalendarRepeatForm'].repeat_count.value;document.forms['CalendarEditView'].repeat_until.value="";}else{document.forms['CalendarEditView'].repeat_until.value=document.forms['CalendarRepeatForm'].repeat_until.value;document.forms['CalendarEditView'].repeat_count.value="";} if(repeat_type=='Weekly'){var repeat_dow="";for(var i=0;i<7;i++) if(CAL.get("repeat_dow_"+i).checked) repeat_dow+=i.toString();CAL.get("repeat_dow").value=repeat_dow;}}}} CAL.fill_repeat_tab=function(data){if(!CAL.enable_repeat) return;if(typeof data.repeat_parent_id!="undefined"){CAL.get("cal-repeat-block").style.display="none";CAL.get("edit_all_recurrences_block").style.display="";CAL.get("edit_all_recurrences").value="";CAL.get("repeat_parent_id").value=data.repeat_parent_id;return;} CAL.get("cal-repeat-block").style.display="";var repeat_type="";var set_default_repeat_until=true;if(typeof data.repeat_type!="undefined"){repeat_type=data.repeat_type;document.forms['CalendarRepeatForm'].repeat_type.value=data.repeat_type;document.forms['CalendarRepeatForm'].repeat_interval.value=data.repeat_interval;if(data.repeat_count!=''&&data.repeat_count!=0){document.forms['CalendarRepeatForm'].repeat_count.value=data.repeat_count;CAL.get("repeat_count_radio").checked=true;CAL.get("repeat_until_radio").checked=false;}else{document.forms['CalendarRepeatForm'].repeat_until.value=data.repeat_until;CAL.get("repeat_until_radio").checked=true;CAL.get("repeat_count_radio").checked=false;set_default_repeat_until=false;} if(data.repeat_type=="Weekly"){var arr=data.repeat_dow.split("");CAL.each(arr,function(i,d){CAL.get("repeat_dow_"+d).checked=true;});} CAL.get("cal-repeat-block").style.display="";CAL.get("edit_all_recurrences_block").style.display="none";toggle_repeat_type();} CAL.get("edit_all_recurrences").value="true";if(typeof data.current_dow!="undefined"&&repeat_type!="Weekly") CAL.get("repeat_dow_"+data.current_dow).checked=true;if(typeof data.default_repeat_until!="undefined"&&set_default_repeat_until) CAL.get("repeat_until_input").value=data.default_repeat_until;} CAL.repeat_tab_handle=function(module_name){if(!CAL.enable_repeat) return;CAL.reset_repeat_form();if(module_name=="Meetings"||module_name=="Calls"){CAL.get("tab_repeat").style.display="";}else{CAL.get("tab_repeat").style.display="none";} clear_all_errors();toggle_repeat_type();} CAL.GR_update_user=function(user_id){var callback={success:function(o){res=eval(o.responseText);GLOBAL_REGISTRY.focus.users_arr_hash=undefined;}};var data={"users":user_id};var url="index.php?module=Calendar&action=GetGRUsers&sugar_body_only=true";YAHOO.util.Connect.asyncRequest('POST',url,callback,CAL.toURI(data));} CAL.GR_update_focus=function(module,record){if(record==""){GLOBAL_REGISTRY["focus"]={"module":module,users_arr:[],fields:{"id":"-1"}};SugarWidgetScheduler.update_time();}else{var callback={success:function(o){res=eval(o.responseText);SugarWidgetScheduler.update_time();if(CAL.record_editable){CAL.enable_buttons();}}};var url='index.php?module=Calendar&action=GetGR&sugar_body_only=true&type='+module+'&record='+record;YAHOO.util.Connect.asyncRequest('POST',url,callback,false);}} CAL.toggle_settings=function(){var sd=CAL.get("settings_dialog");if(!CAL.settingsDialog){CAL.settingsDialog=new YAHOO.widget.Dialog("settings_dialog",{fixedcenter:true,draggable:false,visible:false,modal:true,close:true});var listeners=new YAHOO.util.KeyListener(document,{keys:27},{fn:function(){CAL.settingsDialog.cancel();}});CAL.settingsDialog.cfg.queueProperty("keylisteners",listeners);} CAL.settingsDialog.cancelEvent.subscribe(function(e,a,o){CAL.get("form_settings").reset();});sd.style.display="block";CAL.settingsDialog.render();CAL.settingsDialog.show();} CAL.fill_invitees=function(){CAL.get("user_invitees").value="";CAL.get("contact_invitees").value="";CAL.get("lead_invitees").value="";CAL.each(GLOBAL_REGISTRY['focus'].users_arr,function(i,v){var field_name="";if(v.module=="User") field_name="user_invitees";if(v.module=="Contact") field_name="contact_invitees";if(v.module=="Lead") field_name="lead_invitees";var str=CAL.get(field_name).value;CAL.get(field_name).value=str+v.fields.id+",";});} CAL.repeat_type_selected=function(){var rt;if(rt=CAL.get("repeat_type")){if(rt.value=='Weekly'){var nodes=CAL.query(".weeks_checks_div");CAL.each(nodes,function(i,v){nodes[i].style.display="block";});}else{var nodes=CAL.query(".weeks_checks_div");CAL.each(nodes,function(i,v){nodes[i].style.display="none";});} if(rt.value==''){CAL.get("repeat_interval").setAttribute("disabled","disabled");CAL.get("repeat_end_date").setAttribute("disabled","disabled");}else{CAL.get("repeat_interval").removeAttribute("disabled");CAL.get("repeat_end_date").removeAttribute("disabled");}}} CAL.load_form=function(module_name,record,edit_all_recurrences){CAL.disable_creating=true;var e;var to_open=true;if(module_name=="Tasks") to_open=false;if(to_open&&CAL.records_openable){CAL.get("form_content").style.display="none";CAL.disable_buttons();CAL.get("title-cal-edit").innerHTML=CAL.lbl_loading;CAL.repeat_tab_handle(module_name);ajaxStatus.showStatus(SUGAR.language.get('app_strings','LBL_LOADING'));params={};if(edit_all_recurrences) params={stay_on_tab:true};CAL.open_edit_dialog(params);CAL.get("record").value="";if(!edit_all_recurrences) edit_all_recurrences="";var callback={success:function(o){try{res=eval("("+o.responseText+")");}catch(err){alert(CAL.lbl_error_loading);CAL.editDialog.cancel();ajaxStatus.hideStatus();return;} if(res.access=='yes'){var fc=document.getElementById("form_content");CAL.script_evaled=false;fc.innerHTML=''+res.html;if(!CAL.script_evaled){SUGAR.util.evalScript(res.html);} CAL.get("record").value=res.record;CAL.get("current_module").value=res.module_name;var mod_name=res.module_name;if(mod_name=="Meetings") CAL.get("radio_meeting").checked=true;if(mod_name=="Calls") CAL.get("radio_call").checked=true;if(res.edit==1){CAL.record_editable=true;}else{CAL.record_editable=false;} CAL.get("radio_call").setAttribute("disabled","disabled");CAL.get("radio_meeting").setAttribute("disabled","disabled");eval(res.gr);SugarWidgetScheduler.update_time();if(CAL.record_editable){CAL.enable_buttons();} CAL.get("form_content").style.display="";if(typeof res.repeat!="undefined"){CAL.fill_repeat_tab(res.repeat);} CAL.get("title-cal-edit").innerHTML=CAL.lbl_edit;ajaxStatus.hideStatus();CAL.get("btn-save").focus();setTimeout(function(){if(!res.edit){$("#scheduler .schedulerInvitees").css("display","none");$("#create-invitees-buttons").css("display","none");$("#create-invitees-title").css("display","none");} enableQS(false);disableOnUnloadEditView();},500);}else alert(CAL.lbl_error_loading);},failure:function(){alert(CAL.lbl_error_loading);}};var url="index.php?module=Calendar&action=QuickEdit&sugar_body_only=true";var data={"current_module":module_name,"record":record,"edit_all_recurrences":edit_all_recurrences};YAHOO.util.Connect.asyncRequest('POST',url,callback,CAL.toURI(data));}} CAL.edit_all_recurrences=function(){var record=CAL.get("record").value;if(CAL.get("repeat_parent_id").value!=""){record=CAL.get("repeat_parent_id").value;CAL.get("repeat_parent_id").value="";} var module=CAL.get("current_module").value;if(record!=""){CAL.load_form(module,record,true);}} CAL.remove_shared=function(record_id,edit_all_recurrences){if(typeof edit_all_recurrences=="undefined") edit_all_recurrences=false;var e;var arr=new Array();if(CAL.enable_repeat&&edit_all_recurrences){var nodes=CAL.query("div.act_item[repeat_parent_id='"+record_id+"']");CAL.each(nodes,function(i,v){var record=nodes[i].getAttribute("record");if(!CAL.contains(arr,record)) arr.push(record);nodes[i].parentNode.removeChild(nodes[i]);CAL.destroy_ui(nodes[i].id);});} CAL.each(CAL.shared_users,function(user_id,v){if(e=CAL.get(record_id+'____'+v)){CAL.destroy_ui(e.id);e.parentNode.removeChild(e);} CAL.basic.remove({record:record_id,user_id:user_id});CAL.each(arr,function(i,id){CAL.basic.remove({record:id,user_id:user_id});});});} CAL.add_item=function(item){var edit_all_recurrences=false;if(typeof item.edit_all_recurrences!="undefined"&&item.edit_all_recurrences=='true') edit_all_recurrences=true;if(CAL.view!='shared'){var arr=new Array();if(CAL.enable_repeat&&edit_all_recurrences){var nodes=CAL.query("div.act_item[repeat_parent_id='"+item.record+"']");CAL.each(nodes,function(i,v){var record=nodes[i].getAttribute("record");if(!CAL.contains(arr,record)) arr.push(record);nodes[i].parentNode.removeChild(nodes[i]);});} CAL.each(arr,function(i,id){CAL.basic.remove({record:id,user_id:CAL.current_user_id});});CAL.add_item_to_grid(item);var record_id=item.record;if(CAL.enable_repeat&&typeof item.repeat!="undefined"){CAL.each(item.repeat,function(j,r){var clone=CAL.clone(item);clone.record=r.id;clone.timestamp=r.timestamp;clone.ts_start=r.ts_start;clone.ts_end=r.ts_end;clone.repeat_parent_id=record_id;CAL.add_item_to_grid(clone);});}}else{CAL.remove_shared(item.record,edit_all_recurrences);record_id=item.record;CAL.each(item.users,function(i,user_id){item.user_id=user_id;CAL.add_item_to_grid(item);if(CAL.enable_repeat&&typeof item.repeat!="undefined"){CAL.each(item.repeat,function(j,r){var clone=CAL.clone(item);clone.record=r.id;clone.timestamp=r.timestamp;clone.ts_start=r.ts_start;clone.ts_end=r.ts_end;clone.repeat_parent_id=record_id;CAL.add_item_to_grid(clone);});}});} CAL.arrange_advanced();CAL.basic.populate_grid();CAL.fit_grid();} CAL.move_activity=function(box_id,slot_id,ex_slot_id){var u,s;if(u=CAL.get(box_id)){if(s=CAL.get(slot_id)){s.appendChild(u);CAL.destroy_ui(box_id);CAL.arrange_column(document.getElementById(slot_id).parentNode);CAL.arrange_column(document.getElementById(ex_slot_id).parentNode);CAL.update_dd.fire();CAL.cut_record(box_id);var start_text=CAL.get_header_text(CAL.act_types[u.getAttribute('module_name')],s.getAttribute('time'),' ... ',u.getAttribute('record'));var date_field="date_start";if(u.getAttribute('module_name')=="Tasks") date_field="date_due";u.setAttribute(date_field,s.getAttribute("datetime"));u.childNodes[0].childNodes[1].innerHTML=start_text;}}} CAL.change_activity_type=function(mod_name){if(typeof CAL.current_params.module_name!="undefined") if(CAL.current_params.module_name==mod_name) return;var e,user_name,user_id,date_start;CAL.get("title-cal-edit").innerHTML=CAL.lbl_loading;document.forms["CalendarEditView"].elements["current_module"].value=mod_name;CAL.current_params.module_name=mod_name;QSFieldsArray=new Array();QSProcessedFieldsArray=new Array();CAL.load_create_form(CAL.current_params);} CAL.load_create_form=function(params){CAL.disable_buttons();ajaxStatus.showStatus(SUGAR.language.get('app_strings','LBL_LOADING'));CAL.repeat_tab_handle(CAL.current_params.module_name);var callback={success:function(o){try{res=eval("("+o.responseText+")");}catch(err){alert(CAL.lbl_error_loading);CAL.editDialog.cancel();ajaxStatus.hideStatus();return;} if(res.access=='yes'){var fc=document.getElementById("form_content");CAL.script_evaled=false;fc.innerHTML=''+res.html;if(!CAL.script_evaled){SUGAR.util.evalScript(res.html);} CAL.get("record").value="";CAL.get("current_module").value=res.module_name;var mod_name=res.module_name;if(res.edit==1){CAL.record_editable=true;}else{CAL.record_editable=false;} CAL.get("title-cal-edit").innerHTML=CAL.lbl_create_new;if(typeof res.repeat!="undefined"){CAL.fill_repeat_tab(res.repeat);} CAL.enable_buttons();setTimeout(function(){SugarWidgetScheduler.update_time();enableQS(false);disableOnUnloadEditView();},500);ajaxStatus.hideStatus();}else{alert(CAL.lbl_error_loading);ajaxStatus.hideStatus();}},failure:function(){alert(CAL.lbl_error_loading);ajaxStatus.hideStatus();}};var url="index.php?module=Calendar&action=QuickEdit&sugar_body_only=true";var data={"current_module":params.module_name,"assigned_user_id":params.user_id,"assigned_user_name":params.user_name,"date_start":params.date_start};YAHOO.util.Connect.asyncRequest('POST',url,callback,CAL.toURI(data));} CAL.full_form=function(){var e=document.createElement('input');e.setAttribute('type','hidden');e.setAttribute('name','module');e.value=CAL.get('current_module').value;CAL.get('form_content').parentNode.appendChild(e);var e=document.createElement('input');e.setAttribute('type','hidden');e.setAttribute('name','action');e.value='EditView';CAL.get('form_content').parentNode.appendChild(e);document.forms['CalendarEditView'].action="index.php";document.forms['CalendarEditView'].full_form="true";document.forms['CalendarEditView'].submit();} CAL.disable_buttons=function(){CAL.get("btn-save").setAttribute("disabled","disabled");CAL.get("btn-send-invites").setAttribute("disabled","disabled");CAL.get("btn-delete").setAttribute("disabled","disabled");CAL.get("btn-full-form").setAttribute("disabled","disabled");if(CAL.enable_repeat){CAL.get("btn-edit-all-recurrences").setAttribute("disabled","disabled");CAL.get("btn-remove-all-recurrences").setAttribute("disabled","disabled");}} CAL.enable_buttons=function(){CAL.get("btn-save").removeAttribute("disabled");CAL.get("btn-send-invites").removeAttribute("disabled");if(CAL.get("record").value!="") CAL.get("btn-delete").removeAttribute("disabled");CAL.get("btn-full-form").removeAttribute("disabled");if(CAL.enable_repeat){CAL.get("btn-edit-all-recurrences").removeAttribute("disabled");CAL.get("btn-remove-all-recurrences").removeAttribute("disabled");}} CAL.dialog_create=function(cell){var e,user_id,user_name;CAL.get("title-cal-edit").innerHTML=CAL.lbl_loading;CAL.open_edit_dialog();CAL.disable_buttons();var module_name=CAL.get("current_module").value;if(CAL.view=='shared'){parentWithUserValues=$('div[user_id][user_name]');user_name=parentWithUserValues.attr('user_name');user_id=parentWithUserValues.attr('user_id');CAL.GR_update_user(user_id);}else{user_id=CAL.current_user_id;user_name=CAL.current_user_name;CAL.GR_update_user(CAL.current_user_id);} var params={'module_name':module_name,'user_id':user_id,'user_name':user_name,'date_start':cell.getAttribute("datetime")};CAL.current_params=params;CAL.load_create_form(CAL.current_params);} CAL.dialog_save=function(){CAL.disable_buttons();ajaxStatus.showStatus(SUGAR.language.get('app_strings','LBL_SAVING'));if(CAL.get("send_invites").value=="1"){CAL.get("title-cal-edit").innerHTML=CAL.lbl_sending;}else{CAL.get("title-cal-edit").innerHTML=CAL.lbl_saving;} CAL.fill_invitees();CAL.fill_repeat_data();var callback={success:function(o){try{res=eval("("+o.responseText+")");}catch(err){alert(CAL.lbl_error_saving);CAL.editDialog.cancel();ajaxStatus.hideStatus();return;} if(res.access=='yes'){if(typeof res.limit_error!="undefined"){var alert_msg=CAL.lbl_repeat_limit_error;alert(alert_msg.replace("\$limit",res.limit));CAL.get("title-cal-edit").innerHTML=CAL.lbl_edit;ajaxStatus.hideStatus();CAL.enable_buttons();return;} CAL.add_item(res);CAL.editDialog.cancel();CAL.update_vcal();ajaxStatus.hideStatus();}else{alert(CAL.lbl_error_saving);ajaxStatus.hideStatus();}},failure:function(){alert(CAL.lbl_error_saving);ajaxStatus.hideStatus();}};var url="index.php?module=Calendar&action=SaveActivity&sugar_body_only=true";YAHOO.util.Connect.setForm(CAL.get("CalendarEditView"));YAHOO.util.Connect.asyncRequest('POST',url,callback,false);} CAL.remove_all_recurrences=function(){if(confirm(CAL.lbl_confirm_remove_all_recurring)){if(CAL.get("repeat_parent_id").value!=''){CAL.get("record").value=CAL.get("repeat_parent_id").value;} CAL.get("edit_all_recurrences").value=true;CAL.dialog_remove();}} CAL.dialog_remove=function(){CAL.deleted_id=CAL.get("record").value;CAL.deleted_module=CAL.get("current_module").value;var remove_all_recurrences=CAL.get("edit_all_recurrences").value;var isRecurrence=false;if(CAL.enable_repeat){if(CAL.get("repeat_parent_id").value!=''){var isRecurrence=true;}else{if(document.CalendarRepeatForm.repeat_type.value!=''){var isRecurrence=true;}}} var callback={success:function(o){try{res=eval("("+o.responseText+")");}catch(err){alert(CAL.lbl_error_saving);CAL.editDialog.cancel();ajaxStatus.hideStatus();return;} var e,cell_id;if(e=CAL.get(CAL.deleted_id)) cell_id=e.parentNode.id;if(CAL.view=='shared'){if(remove_all_recurrences&&isRecurrence){CAL.refresh();}else{CAL.remove_shared(CAL.deleted_id,remove_all_recurrences);}}else{if(e=CAL.get(CAL.deleted_id)){e.parentNode.removeChild(e);CAL.destroy_ui(CAL.deleted_id);} CAL.basic.remove({record:CAL.deleted_id,user_id:CAL.current_user_id});if(CAL.enable_repeat&&remove_all_recurrences&&isRecurrence){CAL.refresh();}} CAL.records_openable=true;CAL.disable_creating=false;CAL.arrange_advanced();CAL.basic.populate_grid();CAL.fit_grid();},failure:function(){alert(CAL.lbl_error_saving);}};var data={"current_module":CAL.deleted_module,"record":CAL.deleted_id,"remove_all_recurrences":remove_all_recurrences};var url="index.php?module=Calendar&action=Remove&sugar_body_only=true";YAHOO.util.Connect.asyncRequest('POST',url,callback,CAL.toURI(data));CAL.editDialog.cancel();} CAL.refresh=function(){var callback={success:function(o){try{var activities=eval("("+o.responseText+")");}catch(err){alert(CAL.lbl_error_saving);ajaxStatus.hideStatus();return;} CAL.each(activities,function(i,v){CAL.add_item_to_grid(activities[i]);});CAL.arrange_advanced();CAL.basic.populate_grid();CAL.fit_grid();CAL.update_dd.fire();}} var data={"view":CAL.view,"year":CAL.year,"month":CAL.month,"day":CAL.day};var url="index.php?module=Calendar&action=getActivities&sugar_body_only=true";YAHOO.util.Connect.asyncRequest('POST',url,callback,CAL.toURI(data));CAL.clear();} CAL.clear=function(){CAL.basic.items={};var nodes=CAL.query("#cal-grid div.act_item");CAL.each(nodes,function(i,v){nodes[i].parentNode.removeChild(nodes[i]);});} CAL.show_additional_details=function(id){var obj=CAL.get(id);var record=obj.getAttribute("record");var module_name=obj.getAttribute("module_name");SUGAR.util.getAdditionalDetails(module_name,record,'div_'+id,true);return;} CAL.clear_additional_details=function(id){if(typeof SUGAR.util.additionalDetailsCache[id]!="undefined") SUGAR.util.additionalDetailsCache[id]=undefined;if(typeof SUGAR.util.additionalDetailsCalls[id]!="undefined") SUGAR.util.additionalDetailsCalls[id]=undefined;} CAL.toggle_shared_edit=function(){var sd=CAL.get("shared_cal_edit");if(!CAL.sharedDialog){CAL.sharedDialog=new YAHOO.widget.Dialog("shared_cal_edit",{fixedcenter:true,draggable:false,visible:false,modal:true,close:true});var listeners=new YAHOO.util.KeyListener(document,{keys:27},{fn:function(){CAL.sharedDialog.cancel();}});CAL.sharedDialog.cfg.queueProperty("keylisteners",listeners);} CAL.sharedDialog.cancelEvent.subscribe(function(e,a,o){});sd.style.display="block";CAL.sharedDialog.render();CAL.sharedDialog.show();} CAL.goto_date_call=function(){var date_string=CAL.get("goto_date").value;var date_arr=[];date_arr=date_string.split("/");window.location.href="index.php?module=Calendar&view="+CAL.view+"&day="+date_arr[1]+"&month="+date_arr[0]+"&year="+date_arr[2];} CAL.check_forms=function(){if(!(check_form('CalendarEditView')&&cal_isValidDuration())){CAL.select_tab("cal-tab-1");return false;} if(CAL.enable_repeat&&CAL.get("edit_all_recurrences").value!=""){lastSubmitTime=lastSubmitTime-2001;if(!check_form('CalendarRepeatForm')){CAL.select_tab("cal-tab-3");return false;}} return true;} CAL.toURI=function(a){t=[];for(x in a){if(!(a[x].constructor.toString().indexOf('Array')==-1)){for(i in a[x]) t.push(x+"[]="+encodeURIComponent(a[x][i]));}else t.push(x+"="+encodeURIComponent(a[x]));} return t.join("&");} CAL.each=function(object,callback){if(typeof object=="undefined") return;var name,i=0,length=object.length,isObj=(length===undefined)||(typeof(object)==="function");if(isObj){for(name in object){if(callback.call(object[name],name,object[name])===false){break;}}}else{for(;i