2 if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
3 /*********************************************************************************
4 * SugarCRM is a customer relationship management program developed by
5 * SugarCRM, Inc. Copyright (C) 2004-2011 SugarCRM Inc.
7 * This program is free software; you can redistribute it and/or modify it under
8 * the terms of the GNU Affero General Public License version 3 as published by the
9 * Free Software Foundation with the addition of the following permission added
10 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
11 * IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
12 * OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
14 * This program is distributed in the hope that it will be useful, but WITHOUT
15 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
19 * You should have received a copy of the GNU Affero General Public License along with
20 * this program; if not, see http://www.gnu.org/licenses or write to the Free
21 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
24 * You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
25 * SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
27 * The interactive user interfaces in modified source and object code versions
28 * of this program must display Appropriate Legal Notices, as required under
29 * Section 5 of the GNU Affero General Public License version 3.
31 * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
32 * these Appropriate Legal Notices must retain the display of the "Powered by
33 * SugarCRM" logo. If the display of the logo is not reasonably feasible for
34 * technical reasons, the Appropriate Legal Notices must display the words
35 * "Powered by SugarCRM".
36 ********************************************************************************/
38 /*********************************************************************************
41 ********************************************************************************/
46 $focus = new Scheduler();
47 $focus->retrieve($_REQUEST['record']);
50 // deal with empty values
51 if(!empty($_REQUEST['date_end']) && !empty($_REQUEST['time_hour_end']) && !empty($_REQUEST['time_minute_end']) ) {
52 $date_time_end = $_REQUEST['date_end']." ".str_pad($_REQUEST['time_hour_end'],2,'0',STR_PAD_LEFT).":".str_pad($_REQUEST['time_minute_end'],2,'0',STR_PAD_LEFT).$_REQUEST['time_end_meridiem'];
56 if( (!empty($_REQUEST['time_hour_from']) || $_REQUEST['time_hour_from'] == '0' ) && (!empty($_REQUEST['time_minute_from']) || $_REQUEST['time_minute_from'] == '0' ) ) {
57 $time_from = str_pad($_REQUEST['time_hour_from'],2,'0',STR_PAD_LEFT).":".str_pad($_REQUEST['time_minute_from'],2,'0',STR_PAD_LEFT);
58 if(!empty($_REQUEST['time_from_meridiem'])) {
59 $time_from .= $_REQUEST['time_from_meridiem'];
64 if( (!empty($_REQUEST['time_hour_to']) || $_REQUEST['time_hour_to'] == '0') && (!empty($_REQUEST['time_minute_to']) || $_REQUEST['time_minute_to'] == '0') ) {
65 $time_to = str_pad($_REQUEST['time_hour_to'],2,'0',STR_PAD_LEFT).":".str_pad($_REQUEST['time_minute_to'],2,'0',STR_PAD_LEFT);
66 if(!empty($_REQUEST['time_to_meridiem'])) {
67 $time_to .= $_REQUEST['time_to_meridiem'];
72 $date_time_start = $_REQUEST['date_start']." ".str_pad($_REQUEST['time_hour_start'],2,'0',STR_PAD_LEFT).":".str_pad($_REQUEST['time_minute_start'],2,'0',STR_PAD_LEFT);
73 if(!empty($_REQUEST['time_start_meridiem'])) {
74 $date_time_start .= $_REQUEST['time_start_meridiem'];
76 if(empty($_REQUEST['catch_up'])) {
82 $focus->date_time_start = $date_time_start;
83 $focus->date_time_end = $date_time_end;
84 $focus->time_from = $time_from;
85 $focus->time_to = $time_to;
86 $focus->status = $_REQUEST['status'];
87 $focus->name = $_REQUEST['name'];
89 ///////////////////////////////////////////////////////////////////////////////
91 if($_REQUEST['use_adv'] == 'false') {
93 $xtDays = array(0 => 'mon',
101 if( (isset($_REQUEST['mon']) && $_REQUEST['mon'] == 'true') &&
102 (isset($_REQUEST['tue']) && $_REQUEST['tue'] == 'true') &&
103 (isset($_REQUEST['wed']) && $_REQUEST['wed'] == 'true') &&
104 (isset($_REQUEST['thu']) && $_REQUEST['thu'] == 'true') &&
105 (isset($_REQUEST['fri']) && $_REQUEST['fri'] == 'true') &&
106 (isset($_REQUEST['sat']) && $_REQUEST['sat'] == 'true') &&
107 (isset($_REQUEST['sun']) && $_REQUEST['sun'] == 'true') ) {
108 $_REQUEST['day_of_week'] = '*';
111 foreach($xtDays as $k => $day) {
112 if(isset($_REQUEST[$day]) && $_REQUEST[$day] == 'true') {
113 if($day_string != '') {
119 $_REQUEST['day_of_week'] = $day_string;
123 if($_REQUEST['basic_period'] == 'min') {
124 $_REQUEST['mins'] = '*/'.$_REQUEST['basic_interval'];
125 $_REQUEST['hours'] = '*';
127 $_REQUEST['hours'] = '*/'.$_REQUEST['basic_interval'];
128 $_REQUEST['mins'] = '0';
132 //// END USE_ADV override
133 ///////////////////////////////////////////////////////////////////////////////
135 $focus->job_interval = $_REQUEST['mins']."::".$_REQUEST['hours']."::".$_REQUEST['day_of_month']."::".$_REQUEST['months']."::".$_REQUEST['day_of_week'];
140 // deal with job types
142 if ( ($_REQUEST['job_function'] == '') && ($_REQUEST['job_url'] == '' || $_REQUEST['job_url'] == 'http://') ) {
143 $GLOBALS['log']->fatal('Scheduler save did not get a job_url or job_function');
144 } elseif ( ($_REQUEST['job_function'] != '') && ($_REQUEST['job_url'] != '' && $_REQUEST['job_url'] != 'http://') ) {
145 $GLOBALS['log']->fatal('Scheduler got both a job_url and job_function');
148 if ( ($_REQUEST['job_function'] != '') && ($_REQUEST['job_url'] == '' || $_REQUEST['job_url'] == 'http://') ) {
149 $focus->job = $_REQUEST['job_function'];
150 } elseif ( ($_REQUEST['job_function'] == '') && ($_REQUEST['job_url'] != '' && $_REQUEST['job_url'] != 'http://') ) { // url
151 $focus->job = 'url::'.$_REQUEST['job_url'];
152 } // url wins if both passed
154 // save should refresh ALL jobs
156 $return_id = $focus->id;
159 if(isset($_REQUEST['return_module']) && $_REQUEST['return_module'] != "") $return_module = $_REQUEST['return_module'];
160 else $return_module = "Schedulers";
161 if(isset($_REQUEST['return_action']) && $_REQUEST['return_action'] != "") $return_action = $_REQUEST['return_action'];
162 else $return_action = "DetailView";
163 if(isset($_REQUEST['return_id']) && $_REQUEST['return_id'] != "") $return_id = $_REQUEST['return_id'];
164 if(!empty($_REQUEST['edit'])) {
169 $GLOBALS['log']->debug("Saved record with id of ".$return_id);
171 header("Location: index.php?action=$return_action&module=$return_module&record=$return_id&$edit");