]> CyberLeo.Net >> Repos - Github/sugarcrm.git/blob - modules/Schedulers/views/view.edit.php
Release 6.5.0
[Github/sugarcrm.git] / modules / Schedulers / views / view.edit.php
1 <?php
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.
6  * 
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.
13  * 
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
17  * details.
18  * 
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
22  * 02110-1301 USA.
23  * 
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.
26  * 
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.
30  * 
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  ********************************************************************************/
37
38
39 require_once('include/MVC/View/views/view.edit.php');
40
41 class SchedulersViewEdit extends ViewEdit {
42         protected static $xtDays = array(
43                                 0 => 'MON',
44                                 1 => 'TUE',
45                                 2 => 'WED',
46                                 3 => 'THU',
47                                 4 => 'FRI',
48                                 5 => 'SAT',
49                                 6 => 'SUN');
50
51         public function __construct()
52         {
53                 parent::ViewEdit();
54                 $this->useForSubpanel = true;
55                 //$this->useModuleQuickCreateTemplate = true;
56         }
57         
58     /**
59          * @see SugarView::_getModuleTitleListParam()
60          */
61         protected function _getModuleTitleListParam()
62         {
63             global $mod_strings;
64
65         return "<a href='index.php?module=Schedulers&action=index'>".$mod_strings['LBL_MODULE_TITLE']."</a>";
66     }
67     
68
69     function display(){
70                 global $mod_strings;
71                 global $app_list_strings;
72
73                 // job functions
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::');
79                 }
80                 // interval
81                 if(!empty($this->bean->job_interval)) {
82                         $exInterval = explode("::", $this->bean->job_interval);
83                 } else {
84                         $exInterval = array('*','*','*','*','*');
85                 }
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]);
91
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");
97                         }
98                 } elseif(strpos($exInterval[4], ',')) {
99                         // 1,2,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");
106                                         }
107                                 } else {
108                                         $this->ss->assign(self::$xtDays[$days], "CHECKED");
109                                 }
110                         }
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");
115                         }
116                 } else {
117                         $this->ss->assign(self::$xtDays[$exInterval[4]], "CHECKED");
118                 }
119
120                 // Hours
121                 for($i=1; $i<=30; $i++) {
122                         $ints[$i] = $i;
123                 }
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] == '*') {
128                 // hours
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');
134                 // Minutes
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
141                 } else {
142                         $this->ss->assign('basic_interval', 12);
143                         $this->ss->assign('basic_period', 'hour');
144                         $this->bean->adv_interval = true;
145                 }
146                 if($this->bean->time_from || $this->bean->time_to) {
147                         $this->bean->adv_interval = true;
148                 }
149         
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":"");
153                 
154                 parent::display();
155         }
156 }