1 /*********************************************************************************
2 * SugarCRM Community Edition is a customer relationship management program developed by
3 * SugarCRM, Inc. Copyright (C) 2004-2012 SugarCRM Inc.
5 * This program is free software; you can redistribute it and/or modify it under
6 * the terms of the GNU Affero General Public License version 3 as published by the
7 * Free Software Foundation with the addition of the following permission added
8 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
9 * IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
10 * OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
12 * This program is distributed in the hope that it will be useful, but WITHOUT
13 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
14 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
17 * You should have received a copy of the GNU Affero General Public License along with
18 * this program; if not, see http://www.gnu.org/licenses or write to the Free
19 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
22 * You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
23 * SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
25 * The interactive user interfaces in modified source and object code versions
26 * of this program must display Appropriate Legal Notices, as required under
27 * Section 5 of the GNU Affero General Public License version 3.
29 * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
30 * these Appropriate Legal Notices must retain the display of the "Powered by
31 * SugarCRM" logo. If the display of the logo is not reasonably feasible for
32 * technical reasons, the Appropriate Legal Notices must display the words
33 * "Powered by SugarCRM".
34 ********************************************************************************/
38 function checkFormPre(formId) {
39 validateCronInterval(formId);
40 var noError = check_form(formId);
50 function validateCronInterval(formId) {
51 var fieldIsValid = function(value, min, max) {
52 var inRange = function(value, min, max) {
53 return (value >= min && value <= max);
59 //Check for interval syntax
60 var result = /^\*\/(\d+)$/.exec(value);
61 if (result && result[0] && inRange(result[1], min, max)) {
64 //Check for ranges/lists
65 var sets = value.split(',');
67 for (var i = 0; i < sets.length; i++) {
68 result = /^(\d+)(-(\d+))?$/.exec(sets[i])
69 if (!result || !result[0] || !inRange(result[1], min, max) || (result[3] && !inRange(result[3], min, max))) {
76 mins: {min:0, max:59},
77 hours: {min:0, max:23},
78 day_of_month: {min:1, max:31},
79 months: {min:1, max:12},
80 day_of_week: {min:0, max:7}
83 for (field in cronFields) {
84 removeFromValidate(formId, field);
85 if (document[formId][field] && !fieldIsValid(document[formId][field].value, cronFields[field].min, cronFields[field].max)) {
87 addToValidate(formId, field, 'error', true, "{$MOD.ERR_CRON_SYNTAX}");
89 addToValidate(formId, field, 'verified', true, "{$MOD.ERR_CRON_SYNTAX}");
95 function toggleAdv(onlyAdv) {
96 var thisForm = document.getElementById("EditView");
97 var crontab = document.getElementById("crontab");
98 var simple = document.getElementById("simple");
99 var adv = document.getElementById("advTable");
100 var use = document.getElementById("use_adv");
102 if(crontab.style.display == "none" || onlyAdv == 'true') { // show advanced
103 crontab.style.display = "";
104 adv.style.display = "";
105 simple.style.display = "none";
108 crontab.style.display = "none";
109 adv.style.display = "none";
110 simple.style.display = "";
114 for(i=0; i<thisForm.elements.length; i++) {
115 if(thisForm.elements[i].disabled) {
116 thisForm.elements[i].disabled = false;
122 var toggle = document.getElementById("all");
123 var m = document.getElementById("mon");
124 var t = document.getElementById("tue");
125 var w = document.getElementById("wed");
126 var h = document.getElementById("thu");
127 var f = document.getElementById("fri");
128 var s = document.getElementById("sat");
129 var u = document.getElementById("sun");
151 function updateVisibility()
153 if($('#adv_interval').is(':checked')) {
154 $('#job_interval_advanced').parent().parent().show();
155 $('#job_interval_basic').parent().parent().hide();
156 $('#LBL_ADV_OPTIONS').show();
158 $('#job_interval_advanced').parent().parent().hide();
159 $('#job_interval_basic').parent().parent().show();
160 $('#LBL_ADV_OPTIONS').hide();
164 function initScheduler(){
165 if(typeof(adv_interval) != "undefined" && adv_interval){
166 $('#adv_interval').prop("checked", true);
170 $('#EditView_tabs').ready(function() {
174 $('#adv_interval').ready(function() {$('#adv_interval').click(updateVisibility); });