/********************************************************************************* * SugarCRM Community Edition is a customer relationship management program developed by * SugarCRM, Inc. Copyright (C) 2004-2011 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". ********************************************************************************/ ////////////////////////////////////////////////// // class: SugarWidgetListView // widget to display a list view // ////////////////////////////////////////////////// SugarClass.inherit("SugarWidgetListView","SugarClass"); function SugarWidgetListView() { this.init(); } SugarWidgetListView.prototype.init = function() { } SugarWidgetListView.prototype.load = function(parentNode) { this.parentNode = parentNode; this.display(); } SugarWidgetListView.prototype.display = function() { if(typeof GLOBAL_REGISTRY['result_list'] == 'undefined') { this.display_loading(); return; } var div = document.getElementById('list_div_win'); div.style.display = 'block'; //div.style.height='125px'; var html = ''; html += ''; html += ''; html += ''; html += ''; html += ''; html += ''; html += ''; //var html = '
 '+GLOBAL_REGISTRY['meeting_strings']['LBL_NAME']+''+GLOBAL_REGISTRY['meeting_strings']['LBL_EMAIL']+''+GLOBAL_REGISTRY['meeting_strings']['LBL_PHONE']+' 
'; for(var i=0;i'; html += ''; html += ''; html += ''; html += ''; html += ''; html += ''; } html += '
'+bean.fields.full_name+''+bean.fields.email1+''+bean.fields.phone_work+''; // hidden = 'hidden'; hidden = 'visible'; if(!disabled) { // hidden = 'visible'; } html += ''; html += '
'; this.parentNode.innerHTML = html; } SugarWidgetListView.prototype.display_loading = function() { } ////////////////////////////////////////////////// // class: SugarWidgetSchedulerSearch // widget to display the meeting scheduler search box // ////////////////////////////////////////////////// SugarClass.inherit("SugarWidgetSchedulerSearch","SugarClass"); function SugarWidgetSchedulerSearch() { this.init(); } SugarWidgetSchedulerSearch.prototype.init = function() { this.form_id = 'scheduler_search'; GLOBAL_REGISTRY['widget_element_map'] = new Object(); GLOBAL_REGISTRY['widget_element_map'][this.form_id] = this; } SugarWidgetSchedulerSearch.prototype.load = function(parentNode) { this.parentNode = parentNode; this.display(); } SugarWidgetSchedulerSearch.submit = function(form) { //construct query obj: var conditions = new Array(); if(form.search_first_name.value != '') { conditions[conditions.length] = {"name":"first_name","op":"starts_with","value":form.search_first_name.value} } if(form.search_last_name.value != '') { conditions[conditions.length] = {"name":"last_name","op":"starts_with","value":form.search_last_name.value} } if(form.search_email.value != '') { conditions[conditions.length] = {"name":"email1","op":"starts_with","value":form.search_email.value} } var query = {"modules":["Users","Contacts" ,"Leads" ],"group":"and","field_list":['id','full_name','email1','phone_work'],"conditions":conditions}; global_request_registry[req_count] = [this,'display']; req_id = global_rpcClient.call_method('query',query); global_request_registry[req_id] = [ GLOBAL_REGISTRY['widget_element_map'][form.id],'refresh_list']; } SugarWidgetSchedulerSearch.prototype.refresh_list = function(rslt) { GLOBAL_REGISTRY['result_list'] = rslt['list']; this.list_view.display(); } SugarWidgetSchedulerSearch.prototype.display = function() { var html ='

'+GLOBAL_REGISTRY['meeting_strings']['LBL_ADD_INVITEE']+'

'; html +=''; html += '
'; html += '
'; html += '' html += ''; //html += '
'; html += ''; html += ''; html += ''; //html += '
      
'; html += '
'; html += ''; html += '
'; // append the list_view as the third row of the outside table this.parentNode.innerHTML += html; var div = document.createElement('div'); div.setAttribute('id','list_div_win'); div.style.overflow = 'auto'; div.style.width = '100%'; div.style.height= '100%'; div.style.display = 'none'; this.parentNode.appendChild(div); this.list_view = new SugarWidgetListView(); this.list_view.load(div); } ////////////////////////////////////////////////// // class: SugarWidgetScheduler // widget to display the meeting scheduler // ////////////////////////////////////////////////// SugarClass.inherit("SugarWidgetScheduler","SugarClass"); function SugarWidgetScheduler() { this.init(); } SugarWidgetScheduler.prototype.init = function() { //var row = new SugarWidgetScheduleAttendees(); //row.load(this); } SugarWidgetScheduler.prototype.load = function(parentNode) { this.parentNode = parentNode; this.display(); } SugarWidgetScheduler.fill_invitees = function(form) { for(var i=0;i'; html += ''; html += ''; html += ''; html += ''; html += ''; for(var i=0;i < (this.timeslots.length/this.segments); i++) { var hours = this.timeslots[i*this.segments].date_obj.getHours(); var am_pm = ''; if(time_reg_format.indexOf('A') >= 0 || time_reg_format.indexOf('a') >= 0) { am_pm = "AM"; if(hours > 12) { am_pm = "PM"; hours -= 12; } if(hours == 12) { am_pm = "PM"; } if(hours == 0) { hours = 12; am_pm = "AM"; } if(time_reg_format.indexOf('a') >= 0) { am_pm = am_pm.toLowerCase(); } if(hours != 0 && hours != 12 && i != 0) { am_pm = ""; } } var form_hours = hours+time_separator+"00"; html += ''; } html += ''; html += ''; html += '

'+ top_date +'

 '+form_hours+am_pm+' 
'; if ( this.parentNode.childNodes.length < 1 ) this.parentNode.innerHTML += '
' + html + '
'; else this.parentNode.childNodes[0].innerHTML = html; var thetable = "schedulerTable"; if(typeof (GLOBAL_REGISTRY) == 'undefined') { return; } //set the current user (as event-coordinator) so that they can be added to invitee list //only IF the first removed flag has not been set AND this is a new record if((typeof (GLOBAL_REGISTRY.focus.users_arr) == 'undefined' || GLOBAL_REGISTRY.focus.users_arr.length == 0) && document.forms[form_name].record.value =='' && typeof(GLOBAL_REGISTRY.FIRST_REMOVE)=='undefined') { GLOBAL_REGISTRY.focus.users_arr = [ GLOBAL_REGISTRY.current_user ]; } if(typeof GLOBAL_REGISTRY.focus.users_arr_hash == 'undefined') { GLOBAL_REGISTRY.focus.users_arr_hash = new Object(); } // append attendee rows for(var i=0;i < GLOBAL_REGISTRY.focus.users_arr.length;i++) { var row = new SugarWidgetScheduleRow(this.timeslots); row.focus_bean = GLOBAL_REGISTRY.focus.users_arr[i]; GLOBAL_REGISTRY.focus.users_arr_hash[ GLOBAL_REGISTRY.focus.users_arr[i]['fields']['id']] = GLOBAL_REGISTRY.focus.users_arr[i]; row.load(thetable); } } SugarWidgetSchedulerAttendees.form_add_attendee = function (list_row) { if(typeof (GLOBAL_REGISTRY.result_list[list_row]) != 'undefined' && typeof(GLOBAL_REGISTRY.focus.users_arr_hash[ GLOBAL_REGISTRY.result_list[list_row].fields.id]) == 'undefined') { GLOBAL_REGISTRY.focus.users_arr[ GLOBAL_REGISTRY.focus.users_arr.length ] = GLOBAL_REGISTRY.result_list[list_row]; } GLOBAL_REGISTRY.scheduler_attendees_obj.display(); } ////////////////////////////////////////////////// // class: SugarWidgetScheduleRow // widget to display each row in the scheduler // ////////////////////////////////////////////////// SugarClass.inherit("SugarWidgetScheduleRow","SugarClass"); function SugarWidgetScheduleRow(timeslots) { this.init(timeslots); } SugarWidgetScheduleRow.prototype.init = function(timeslots) { this.timeslots = timeslots; } SugarWidgetScheduleRow.prototype.load = function (thetableid) { this.thetableid = thetableid; var self = this; vcalClient = new SugarVCalClient(); if(typeof (GLOBAL_REGISTRY['freebusy_adjusted']) == 'undefined' || typeof (GLOBAL_REGISTRY['freebusy_adjusted'][this.focus_bean.fields.id]) == 'undefined') { global_request_registry[req_count] = [this,'display']; vcalClient.load(this.focus_bean.fields.id,req_count); req_count++; } else { this.display(); } } SugarWidgetScheduleRow.prototype.display = function() { SUGAR.util.doWhen("document.getElementById('" + this.thetableid + "') != null", function(){ var tr; this.thetable = document.getElementById(this.thetableid); if(typeof (this.element) != 'undefined') { if (this.element.parentNode != null) this.thetable.deleteRow(this.element.rowIndex); tr = document.createElement('tr'); this.thetable.appendChild(tr); } else { tr = this.thetable.insertRow(this.thetable.rows.length); } tr.className = "schedulerAttendeeRow"; td = document.createElement('td'); tr.appendChild(td); //insertCell(tr.cells.length); // icon + full name td.scope = 'row'; var img = ' '; td.innerHTML = img; td.innerHTML = td.innerHTML; if (this.focus_bean.fields.full_name) td.innerHTML += ' ' + this.focus_bean.fields.full_name; else td.innerHTML += ' ' + this.focus_bean.fields.name; // add freebusy tds here: this.add_freebusy_nodes(tr); // delete button var td = document.createElement('td'); tr.appendChild(td); //var td = tr.insertCell(tr.cells.length); td.className = 'schedulerAttendeeDeleteCell'; td.noWrap = true; //CCL - Remove check to disallow removal of assigned user or current user //if ( GLOBAL_REGISTRY.focus.fields.assigned_user_id != this.focus_bean.fields.id && GLOBAL_REGISTRY.current_user.fields.id != this.focus_bean.fields.id) { td.innerHTML = ' ' + ''+ GLOBAL_REGISTRY['meeting_strings']['LBL_REMOVE'] +' ' + GLOBAL_REGISTRY['meeting_strings']['LBL_REMOVE'] +''; //} this.element = tr; this.element_index = this.thetable.rows.length - 1; }, null, this); } SugarWidgetScheduleRow.deleteRow = function(bean_id) { // can't delete organizer /* if(GLOBAL_REGISTRY.focus.users_arr.length == 1 || GLOBAL_REGISTRY.focus.fields.assigned_user_id == bean_id) { return; } */ for(var i=0;is for freebusy display within a row SugarWidgetScheduleRow.prototype.add_freebusy_nodes = function(tr,attendee) { var hours = 9; var segments = 4; var html = ''; var is_loaded = false; if(typeof GLOBAL_REGISTRY['freebusy_adjusted'] != 'undefined' && typeof GLOBAL_REGISTRY['freebusy_adjusted'][this.focus_bean.fields.id] != 'undefined') { is_loaded = true; } for(var i=0;i < this.timeslots.length; i++) { var td = document.createElement('td'); tr.appendChild(td); //var td = tr.insertCell(tr.cells.length); td.innerHTML = ' '; if(typeof(this.timeslots[i]['is_start']) != 'undefined') { td.className = 'schedulerSlotCellStartTime'; } if(typeof(this.timeslots[i]['is_end']) != 'undefined') { td.className = 'schedulerSlotCellEndTime'; } if(is_loaded) { // iftheres a freebusy stack in this slice if( typeof(GLOBAL_REGISTRY['freebusy_adjusted'][this.focus_bean.fields.id][this.timeslots[i].hash]) != 'undefined') { td.style.backgroundColor="#4D5EAA"; if(td.className == 'schedulerSlotCellStartTime') { fb_limit = 1; if(typeof(GLOBAL_REGISTRY.focus.orig_users_arr_hash) != 'undefined' && typeof(GLOBAL_REGISTRY.focus.orig_users_arr_hash[this.focus_bean.fields.id]) != 'undefined') { fb_limit = 2; } if( GLOBAL_REGISTRY['freebusy_adjusted'][this.focus_bean.fields.id][this.timeslots[i].hash] >= fb_limit) { td.style.backgroundColor="#AA4D4D"; } else { td.style.backgroundColor="#4D5EAA"; } } } } } }