[ Index ] |
PHP Cross Reference of vtigercrm-6.1.0 |
[Summary view] [Print] [Text view]
1 /*+*********************************************************************************** 2 * The contents of this file are subject to the vtiger CRM Public License Version 1.0 3 * ("License"); You may not use this file except in compliance with the License 4 * The Original Code is: vtiger CRM Open Source 5 * The Initial Developer of the Original Code is vtiger. 6 * Portions created by vtiger are Copyright (C) vtiger. 7 * All Rights Reserved. 8 *************************************************************************************/ 9 Settings_Workflows_Edit_Js("Settings_Workflows_Edit1_Js",{},{ 10 11 init : function() { 12 this.initialize(); 13 }, 14 /** 15 * Function to get the container which holds all the reports step1 elements 16 * @return jQuery object 17 */ 18 getContainer : function() { 19 return this.step1Container; 20 }, 21 22 /** 23 * Function to set the reports step1 container 24 * @params : element - which represents the reports step1 container 25 * @return : current instance 26 */ 27 setContainer : function(element) { 28 this.step1Container = element; 29 return this; 30 }, 31 32 /** 33 * Function to intialize the reports step1 34 */ 35 initialize : function(container) { 36 if(typeof container == 'undefined') { 37 container = jQuery('#workflow_step1'); 38 } 39 if(container.is('#workflow_step1')) { 40 this.setContainer(container); 41 }else{ 42 this.setContainer(jQuery('#workflow_step1')); 43 } 44 }, 45 46 submit : function(){ 47 var aDeferred = jQuery.Deferred(); 48 var form = this.getContainer(); 49 var formData = form.serializeFormData(); 50 var progressIndicatorElement = jQuery.progressIndicator({ 51 'position' : 'html', 52 'blockInfo' : { 53 'enabled' : true 54 } 55 }); 56 AppConnector.request(formData).then( 57 function(data) { 58 form.hide(); 59 progressIndicatorElement.progressIndicator({ 60 'mode' : 'hide' 61 }) 62 aDeferred.resolve(data); 63 }, 64 function(error,err){ 65 66 } 67 ); 68 return aDeferred.promise(); 69 }, 70 71 /** 72 * Function to register event for scheduled workflows UI 73 */ 74 registerEventForScheduledWorkflow : function() { 75 var thisInstance = this; 76 jQuery('input[name="execution_condition"]').on('click', function(e) { 77 var element = jQuery(e.currentTarget); 78 var scheduleBoxContainer = jQuery('#scheduleBox'); 79 if(element.is(':checked') && element.val() == '6') { //for scheduled workflows 80 scheduleBoxContainer.removeClass('hide'); 81 } else { 82 scheduleBoxContainer.addClass('hide'); 83 } 84 }); 85 app.registerEventForTimeFields('#schtime', true); 86 app.registerEventForDatePickerFields('#scheduleByDate', true); 87 88 jQuery('#annualDates').chosen(); 89 jQuery('#schdayofweek').chosen(); 90 jQuery('#schdayofmonth').chosen(); 91 92 var currentYear = new Date().getFullYear(); 93 jQuery('#annualDatePicker').datepick({autoSize: true, multiSelect:100,monthsToShow: [1,2], 94 minDate: '01/01/'+currentYear, maxDate: '12/31/'+currentYear, 95 yearRange: currentYear+':'+currentYear, 96 onShow : function() { 97 //Hack to remove the year 98 thisInstance.removeYearInAnnualWorkflow(); 99 }, 100 onSelect : function(dates) { 101 var datesInfo = []; 102 var values = []; 103 var html=''; 104 // reset the annual dates 105 var annualDatesEle = jQuery('#annualDates'); 106 thisInstance.updateAnnualDates(annualDatesEle); 107 for(index in dates) { 108 var date = dates[index]; 109 datesInfo.push({ 110 id:thisInstance.DateToYMD(date), 111 text:thisInstance.DateToYMD(date) 112 }); 113 values.push(thisInstance.DateToYMD(date)); 114 html += '<option selected value='+thisInstance.DateToYMD(date)+'>'+thisInstance.DateToYMD(date)+'</option>'; 115 } 116 annualDatesEle.append(html); 117 annualDatesEle.trigger("liszt:updated"); 118 } 119 }); 120 var annualDatesEle = jQuery('#annualDates'); 121 thisInstance.updateAnnualDates(annualDatesEle); 122 annualDatesEle.trigger("liszt:updated"); 123 }, 124 125 removeYearInAnnualWorkflow : function() { 126 setTimeout(function() { 127 var year = jQuery('.datepick-month.first').find('.datepick-month-year').get(1); 128 jQuery(year).hide(); 129 var monthHeaders = $('.datepick-month-header'); 130 jQuery.each(monthHeaders, function( key, ele ) { 131 var header = jQuery(ele); 132 var str = header.html().replace(/[\d]+/, ''); 133 header.html(str); 134 }); 135 },100); 136 }, 137 138 updateAnnualDates : function(annualDatesEle) { 139 annualDatesEle.html(''); 140 var annualDatesJSON = jQuery('#hiddenAnnualDates').val(); 141 if(annualDatesJSON) { 142 var hiddenDates = ''; 143 var annualDates = JSON.parse(annualDatesJSON); 144 for(j in annualDates) { 145 hiddenDates += '<option selected value='+annualDates[j]+'>'+annualDates[j]+'</option>'; 146 } 147 annualDatesEle.html(hiddenDates); 148 } 149 }, 150 151 DateToYMD : function (date) { 152 var year, month, day; 153 year = String(date.getFullYear()); 154 month = String(date.getMonth() + 1); 155 if (month.length == 1) { 156 month = "0" + month; 157 } 158 day = String(date.getDate()); 159 if (day.length == 1) { 160 day = "0" + day; 161 } 162 return year + "-" + month + "-" + day; 163 }, 164 165 registerEventForChangeInScheduledType : function() { 166 var thisInstance = this; 167 jQuery('#schtypeid').on('change', function(e){ 168 var element = jQuery(e.currentTarget); 169 var value = element.val(); 170 171 thisInstance.showScheduledTime(); 172 thisInstance.hideScheduledWeekList(); 173 thisInstance.hideScheduledMonthByDateList(); 174 thisInstance.hideScheduledSpecificDate(); 175 thisInstance.hideScheduledAnually(); 176 177 if(value == '1') { //hourly 178 thisInstance.hideScheduledTime(); 179 } else if(value == '3') { //weekly 180 thisInstance.showScheduledWeekList(); 181 } else if(value == '4') { //specific date 182 thisInstance.showScheduledSpecificDate(); 183 } else if(value == '5') { //monthly by day 184 thisInstance.showScheduledMonthByDateList(); 185 } else if(value == '7') { 186 thisInstance.showScheduledAnually(); 187 } 188 }); 189 }, 190 191 hideScheduledTime : function() { 192 jQuery('#scheduledTime').addClass('hide'); 193 }, 194 195 showScheduledTime : function() { 196 jQuery('#scheduledTime').removeClass('hide'); 197 }, 198 199 hideScheduledWeekList : function() { 200 jQuery('#scheduledWeekDay').addClass('hide'); 201 }, 202 203 showScheduledWeekList : function() { 204 jQuery('#scheduledWeekDay').removeClass('hide'); 205 }, 206 207 hideScheduledMonthByDateList : function() { 208 jQuery('#scheduleMonthByDates').addClass('hide'); 209 }, 210 211 showScheduledMonthByDateList : function() { 212 jQuery('#scheduleMonthByDates').removeClass('hide'); 213 }, 214 215 hideScheduledSpecificDate : function() { 216 jQuery('#scheduleByDate').addClass('hide'); 217 }, 218 219 showScheduledSpecificDate : function() { 220 jQuery('#scheduleByDate').removeClass('hide'); 221 }, 222 223 hideScheduledAnually : function() { 224 jQuery('#scheduleAnually').addClass('hide'); 225 }, 226 227 showScheduledAnually : function() { 228 jQuery('#scheduleAnually').removeClass('hide'); 229 }, 230 231 registerEvents : function(){ 232 var container = this.getContainer(); 233 234 //After loading 1st step only, we will enable the Next button 235 container.find('[type="submit"]').removeAttr('disabled'); 236 237 var opts = app.validationEngineOptions; 238 // to prevent the page reload after the validation has completed 239 opts['onValidationComplete'] = function(form,valid) { 240 //returns the valid status 241 return valid; 242 }; 243 opts['promptPosition'] = "bottomRight"; 244 container.validationEngine(opts); 245 246 this.registerEventForScheduledWorkflow(); 247 this.registerEventForChangeInScheduledType(); 248 249 250 } 251 });
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Fri Nov 28 20:08:37 2014 | Cross-referenced by PHPXref 0.7.1 |