2 if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
3 /*********************************************************************************
4 * SugarCRM Community Edition is a customer relationship management program developed by
5 * SugarCRM, Inc. Copyright (C) 2004-2012 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 ********************************************************************************/
39 require_once('include/MVC/View/views/view.edit.php');
41 class SchedulersViewEdit extends ViewEdit {
42 protected static $xtDays = array(
51 public function __construct()
54 $this->useForSubpanel = true;
55 //$this->useModuleQuickCreateTemplate = true;
59 * @see SugarView::_getModuleTitleListParam()
61 protected function _getModuleTitleListParam()
65 return "<a href='index.php?module=Schedulers&action=index'>".$mod_strings['LBL_MODULE_TITLE']."</a>";
71 global $app_list_strings;
74 $this->bean->job_function = $this->bean->job;
75 $this->ss->assign('JOB', $this->bean->job);
76 if(substr($this->bean->job, 0, 5) == "url::") {
77 $this->bean->job_url = substr($this->bean->job, 5);
78 $this->ss->assign('JOB', 'url::');
81 if(!empty($this->bean->job_interval)) {
82 $exInterval = explode("::", $this->bean->job_interval);
84 $exInterval = array('*','*','*','*','*');
86 $this->ss->assign('mins', $exInterval[0]);
87 $this->ss->assign('hours', $exInterval[1]);
88 $this->ss->assign('day_of_month', $exInterval[2]);
89 $this->ss->assign('months', $exInterval[3]);
90 $this->ss->assign('day_of_week', $exInterval[4]);
92 // Handle cron weekdays
93 if($exInterval[4] == '*') {
94 $this->ss->assign('ALL', "CHECKED");
95 foreach(self::$xtDays as $day) {
96 $this->ss->assign($day, "CHECKED");
98 } elseif(strpos($exInterval[4], ',')) {
100 $exDays = explode(',', trim($exInterval[4]));
101 foreach($exDays as $days) {
102 if(strpos($days, '-')) {
103 $exDaysRange = explode('-', $days);
104 for($i=$exDaysRange[0]; $i<=$exDaysRange[1]; $i++) {
105 $this->ss->assign(self::$xtDays[$days], "CHECKED");
108 $this->ss->assign(self::$xtDays[$days], "CHECKED");
111 } elseif(strpos($exInterval[4], '-')) {
112 $exDaysRange = explode('-', $exInterval[4]);
113 for($i=$exDaysRange[0]; $i<=$exDaysRange[1]; $i++) {
114 $this->ss->assign(self::$xtDays[$i], "CHECKED");
117 $this->ss->assign(self::$xtDays[$exInterval[4]], "CHECKED");
121 for($i=1; $i<=30; $i++) {
124 $this->bean->adv_interval = false;
125 $this->ss->assign('basic_intervals', $ints);
126 $this->ss->assign('basic_periods', $app_list_strings['scheduler_period_dom']);
127 if($exInterval[0] == '*' && $exInterval[1] == '*') {
129 } elseif(strpos($exInterval[1], '*/') !== false && $exInterval[0] == '0') {
130 // we have a "BASIC" type of hour setting
131 $exHours = explode('/', $exInterval[1]);
132 $this->ss->assign('basic_interval', $exInterval[1]);
133 $this->ss->assign('basic_period', 'hour');
135 } elseif(strpos($exInterval[0], '*/') !== false && $exInterval[1] == '*' ) {
136 // we have a "BASIC" type of min setting
137 $exMins = explode('/', $exInterval[0]);
138 $this->ss->assign('basic_interval', $exMins[1]);
139 $this->ss->assign('basic_period', 'min');
140 // we've got an advanced time setting
142 $this->ss->assign('basic_interval', 12);
143 $this->ss->assign('basic_period', 'hour');
144 $this->bean->adv_interval = true;
146 if($this->bean->time_from || $this->bean->time_to) {
147 $this->bean->adv_interval = true;
150 $this->ss->assign("adv_interval", $this->bean->adv_interval?"true":"false");
151 $this->ss->assign("adv_visibility", $this->bean->adv_interval?"":"display: none");
152 $this->ss->assign("basic_visibility", $this->bean->adv_interval?"display: none":"");