@@ -46,121 +46,121 @@ |
||
46 | 46 | ********************************************************************************/ |
47 | 47 | |
48 | 48 | $viewdefs = array ( |
49 | - 'Prospects' => |
|
50 | - array ( |
|
49 | + 'Prospects' => |
|
50 | + array ( |
|
51 | 51 | 'QuickCreate' => |
52 | 52 | array ( |
53 | - 'templateMeta' => |
|
54 | - array ( |
|
53 | + 'templateMeta' => |
|
54 | + array ( |
|
55 | 55 | 'maxColumns' => '2', |
56 | 56 | 'widths' => |
57 | 57 | array ( |
58 | - 0 => |
|
59 | - array ( |
|
58 | + 0 => |
|
59 | + array ( |
|
60 | 60 | 'label' => '10', |
61 | 61 | 'field' => '30', |
62 | - ), |
|
63 | - 1 => |
|
64 | - array ( |
|
62 | + ), |
|
63 | + 1 => |
|
64 | + array ( |
|
65 | 65 | 'label' => '10', |
66 | 66 | 'field' => '30', |
67 | - ), |
|
67 | + ), |
|
68 | 68 | ), |
69 | - ), |
|
70 | - 'panels' => |
|
71 | - array ( |
|
69 | + ), |
|
70 | + 'panels' => |
|
71 | + array ( |
|
72 | 72 | 'LBL_PROSPECT_INFORMATION' => |
73 | 73 | array ( |
74 | - 0 => |
|
75 | - array ( |
|
76 | 74 | 0 => |
77 | 75 | array ( |
78 | - 'name' => 'first_name', |
|
76 | + 0 => |
|
77 | + array ( |
|
78 | + 'name' => 'first_name', |
|
79 | 79 | ), |
80 | 80 | 1 => |
81 | 81 | array ( |
82 | - 'name' => 'phone_work', |
|
82 | + 'name' => 'phone_work', |
|
83 | 83 | ), |
84 | - ), |
|
85 | - 1 => |
|
86 | - array ( |
|
84 | + ), |
|
85 | + 1 => |
|
86 | + array ( |
|
87 | 87 | 0 => |
88 | 88 | array ( |
89 | - 'name' => 'last_name', |
|
90 | - 'displayParams'=>array('required'=>true) |
|
89 | + 'name' => 'last_name', |
|
90 | + 'displayParams'=>array('required'=>true) |
|
91 | 91 | ), |
92 | 92 | 1 => |
93 | 93 | array ( |
94 | - 'name' => 'phone_mobile', |
|
94 | + 'name' => 'phone_mobile', |
|
95 | + ), |
|
95 | 96 | ), |
96 | - ), |
|
97 | - 2 => |
|
98 | - array ( |
|
97 | + 2 => |
|
98 | + array ( |
|
99 | 99 | 0 => |
100 | 100 | array ( |
101 | - 'name' => 'account_name', |
|
101 | + 'name' => 'account_name', |
|
102 | 102 | ), |
103 | 103 | 1 => |
104 | 104 | array ( |
105 | - 'name' => 'phone_fax', |
|
105 | + 'name' => 'phone_fax', |
|
106 | + ), |
|
106 | 107 | ), |
107 | - ), |
|
108 | - 3 => |
|
109 | - array ( |
|
108 | + 3 => |
|
109 | + array ( |
|
110 | 110 | 0 => |
111 | 111 | array ( |
112 | - 'name' => 'title', |
|
112 | + 'name' => 'title', |
|
113 | 113 | ), |
114 | 114 | 1 => |
115 | 115 | array ( |
116 | - 'name' => 'department', |
|
116 | + 'name' => 'department', |
|
117 | + ), |
|
117 | 118 | ), |
118 | - ), |
|
119 | - 4 => |
|
120 | - array ( |
|
119 | + 4 => |
|
120 | + array ( |
|
121 | 121 | 0 => |
122 | 122 | array ( |
123 | - 'name' => 'team_name', |
|
123 | + 'name' => 'team_name', |
|
124 | 124 | ), |
125 | 125 | 1 => |
126 | 126 | array ( |
127 | - 'name' => 'do_not_call', |
|
127 | + 'name' => 'do_not_call', |
|
128 | + ), |
|
128 | 129 | ), |
129 | - ), |
|
130 | - 5 => |
|
131 | - array ( |
|
130 | + 5 => |
|
131 | + array ( |
|
132 | 132 | 0 => |
133 | 133 | array ( |
134 | - 'name' => 'assigned_user_name', |
|
134 | + 'name' => 'assigned_user_name', |
|
135 | + ), |
|
135 | 136 | ), |
136 | - ), |
|
137 | 137 | ), |
138 | 138 | 'lbl_email_addresses' => |
139 | 139 | array ( |
140 | - 0 => |
|
141 | - array ( |
|
142 | 140 | 0 => |
143 | 141 | array ( |
144 | - 'name' => 'email1', |
|
142 | + 0 => |
|
143 | + array ( |
|
144 | + 'name' => 'email1', |
|
145 | + ), |
|
145 | 146 | ), |
146 | - ), |
|
147 | 147 | ), |
148 | 148 | 'LBL_ADDRESS_INFORMATION' => |
149 | 149 | array ( |
150 | - 0 => |
|
151 | - array ( |
|
152 | 150 | 0 => |
153 | 151 | array ( |
154 | - 'name' => 'primary_address_street', |
|
152 | + 0 => |
|
153 | + array ( |
|
154 | + 'name' => 'primary_address_street', |
|
155 | 155 | ), |
156 | 156 | 1 => |
157 | 157 | array ( |
158 | - 'name' => 'alt_address_street', |
|
158 | + 'name' => 'alt_address_street', |
|
159 | + ), |
|
159 | 160 | ), |
160 | - ), |
|
161 | 161 | ), |
162 | - ), |
|
162 | + ), |
|
163 | + ), |
|
163 | 164 | ), |
164 | - ), |
|
165 | 165 | ); |
166 | 166 | ?> |
@@ -42,10 +42,10 @@ discard block |
||
42 | 42 | |
43 | 43 | |
44 | 44 | $listViewDefs['Prospects'] = array( |
45 | - 'FULL_NAME' => array( |
|
46 | - 'width' => '20', |
|
47 | - 'label' => 'LBL_LIST_NAME', |
|
48 | - 'link' => true, |
|
45 | + 'FULL_NAME' => array( |
|
46 | + 'width' => '20', |
|
47 | + 'label' => 'LBL_LIST_NAME', |
|
48 | + 'link' => true, |
|
49 | 49 | 'related_fields' => array('first_name', 'last_name'), |
50 | 50 | 'orderBy' => 'last_name', |
51 | 51 | 'default' => true), |
@@ -65,11 +65,11 @@ discard block |
||
65 | 65 | 'label' => 'LBL_LIST_PHONE', |
66 | 66 | 'link' => false, |
67 | 67 | 'default' => true), |
68 | - 'DATE_ENTERED' => array ( |
|
69 | - 'type' => 'datetime', |
|
70 | - 'label' => 'LBL_DATE_ENTERED', |
|
71 | - 'width' => '10', |
|
72 | - 'default' => true, |
|
73 | - ), |
|
68 | + 'DATE_ENTERED' => array ( |
|
69 | + 'type' => 'datetime', |
|
70 | + 'label' => 'LBL_DATE_ENTERED', |
|
71 | + 'width' => '10', |
|
72 | + 'default' => true, |
|
73 | + ), |
|
74 | 74 | ); |
75 | 75 | ?> |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | */ |
44 | 44 | class Reminder extends Basic { |
45 | 45 | |
46 | - const UPGRADE_VERSION = '7.4.3'; |
|
46 | + const UPGRADE_VERSION = '7.4.3'; |
|
47 | 47 | |
48 | 48 | var $name; |
49 | 49 | |
@@ -51,19 +51,19 @@ discard block |
||
51 | 51 | var $module_dir = 'Reminders'; |
52 | 52 | var $object_name = 'Reminder'; |
53 | 53 | var $table_name = 'reminders'; |
54 | - var $tracker_visibility = false; |
|
54 | + var $tracker_visibility = false; |
|
55 | 55 | var $importable = false; |
56 | 56 | var $disable_row_level_security = true; |
57 | 57 | |
58 | 58 | var $popup; |
59 | 59 | var $email; |
60 | 60 | var $email_sent = false; |
61 | - var $timer_popup; |
|
62 | - var $timer_email; |
|
63 | - var $related_event_module; |
|
64 | - var $related_event_module_id; |
|
61 | + var $timer_popup; |
|
62 | + var $timer_email; |
|
63 | + var $related_event_module; |
|
64 | + var $related_event_module_id; |
|
65 | 65 | |
66 | - private static $remindersData = array(); |
|
66 | + private static $remindersData = array(); |
|
67 | 67 | |
68 | 68 | public function __construct() { |
69 | 69 | parent::Basic(); |
@@ -76,17 +76,17 @@ discard block |
||
76 | 76 | return false; |
77 | 77 | } |
78 | 78 | |
79 | - // ---- save and load remainders on EditViews |
|
79 | + // ---- save and load remainders on EditViews |
|
80 | 80 | |
81 | - /** |
|
82 | - * Save multiple reminders data from clients Meetings/Calls EditView. |
|
83 | - * Call this static function in save action. |
|
84 | - * |
|
85 | - * @param string $eventModule Event Bean module name (e.g. Meetings, Calls) |
|
86 | - * @param string $eventModuleId Event Bean GUID |
|
87 | - * @param string $remindersDataJson Remainders data as Json string from POST data. |
|
88 | - * @throws Exception throw an Exception if json format is invalid. |
|
89 | - */ |
|
81 | + /** |
|
82 | + * Save multiple reminders data from clients Meetings/Calls EditView. |
|
83 | + * Call this static function in save action. |
|
84 | + * |
|
85 | + * @param string $eventModule Event Bean module name (e.g. Meetings, Calls) |
|
86 | + * @param string $eventModuleId Event Bean GUID |
|
87 | + * @param string $remindersDataJson Remainders data as Json string from POST data. |
|
88 | + * @throws Exception throw an Exception if json format is invalid. |
|
89 | + */ |
|
90 | 90 | public static function saveRemindersDataJson($eventModule, $eventModuleId, $remindersDataJson) { |
91 | 91 | $reminderData = json_decode($remindersDataJson); |
92 | 92 | if(!json_last_error()) { |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | private static function saveRemindersData($eventModule, $eventModuleId, $remindersData) { |
101 | 101 | $savedReminderIds = array(); |
102 | 102 | foreach($remindersData as $reminderData) { |
103 | - if(isset($_POST['isDuplicate']) && $_POST['isDuplicate']) $reminderData->id = ''; |
|
103 | + if(isset($_POST['isDuplicate']) && $_POST['isDuplicate']) $reminderData->id = ''; |
|
104 | 104 | $reminderBean = BeanFactory::getBean('Reminders', $reminderData->id); |
105 | 105 | $reminderBean->popup = $reminderData->popup; |
106 | 106 | $reminderBean->email = $reminderData->email; |
@@ -123,18 +123,18 @@ discard block |
||
123 | 123 | } |
124 | 124 | } |
125 | 125 | } |
126 | - unset(self::$remindersData[$eventModule][$eventModuleId]); |
|
126 | + unset(self::$remindersData[$eventModule][$eventModuleId]); |
|
127 | 127 | } |
128 | 128 | |
129 | - /** |
|
130 | - * Load multiple reminders JSON data for related Event module EditViews. |
|
131 | - * Call this function in module display function. |
|
132 | - * |
|
133 | - * @param string $eventModule Related event module name (Meetings/Calls) |
|
134 | - * @param string $eventModuleId Related event GUID |
|
135 | - * @return string JSON string contains the remainders |
|
136 | - * @throws Exception |
|
137 | - */ |
|
129 | + /** |
|
130 | + * Load multiple reminders JSON data for related Event module EditViews. |
|
131 | + * Call this function in module display function. |
|
132 | + * |
|
133 | + * @param string $eventModule Related event module name (Meetings/Calls) |
|
134 | + * @param string $eventModuleId Related event GUID |
|
135 | + * @return string JSON string contains the remainders |
|
136 | + * @throws Exception |
|
137 | + */ |
|
138 | 138 | public static function loadRemindersDataJson($eventModule, $eventModuleId, $isDuplicate = false) { |
139 | 139 | $remindersData = self::loadRemindersData($eventModule, $eventModuleId, $isDuplicate); |
140 | 140 | $remindersDataJson = json_encode($remindersData); |
@@ -144,551 +144,551 @@ discard block |
||
144 | 144 | return $remindersDataJson; |
145 | 145 | } |
146 | 146 | |
147 | - /** |
|
148 | - * Load multiple reminders data for related Event module EditViews. |
|
149 | - * Call this function in module display function. |
|
150 | - * |
|
151 | - * @param string $eventModule Related event module name (Meetings/Calls) |
|
152 | - * @param string $eventModuleId Related event GUID |
|
153 | - * @return array contains the remainders |
|
154 | - * @throws Exception |
|
155 | - */ |
|
156 | - public static function loadRemindersData($eventModule, $eventModuleId, $isDuplicate = false) { |
|
157 | - if(!isset(self::$remindersData[$eventModule][$eventModuleId]) || !$eventModuleId || $isDuplicate) { |
|
158 | - $ret = array(); |
|
159 | - $reminders = BeanFactory::getBean('Reminders')->get_full_list("reminders.date_entered", "reminders.related_event_module = '$eventModule' AND reminders.related_event_module_id = '$eventModuleId'"); |
|
160 | - if ($reminders) { |
|
161 | - foreach ($reminders as $reminder) { |
|
162 | - $ret[] = array( |
|
163 | - 'id' => $isDuplicate ? null : $reminder->id, |
|
164 | - 'popup' => $reminder->popup, |
|
165 | - 'email' => $reminder->email, |
|
166 | - 'timer_popup' => $reminder->timer_popup, |
|
167 | - 'timer_email' => $reminder->timer_email, |
|
168 | - 'invitees' => Reminder_Invitee::loadRemindersInviteesData($reminder->id, $isDuplicate), |
|
169 | - ); |
|
170 | - } |
|
171 | - } |
|
172 | - self::$remindersData[$eventModule][$eventModuleId] = $ret; |
|
173 | - } |
|
174 | - return self::$remindersData[$eventModule][$eventModuleId]; |
|
175 | - } |
|
147 | + /** |
|
148 | + * Load multiple reminders data for related Event module EditViews. |
|
149 | + * Call this function in module display function. |
|
150 | + * |
|
151 | + * @param string $eventModule Related event module name (Meetings/Calls) |
|
152 | + * @param string $eventModuleId Related event GUID |
|
153 | + * @return array contains the remainders |
|
154 | + * @throws Exception |
|
155 | + */ |
|
156 | + public static function loadRemindersData($eventModule, $eventModuleId, $isDuplicate = false) { |
|
157 | + if(!isset(self::$remindersData[$eventModule][$eventModuleId]) || !$eventModuleId || $isDuplicate) { |
|
158 | + $ret = array(); |
|
159 | + $reminders = BeanFactory::getBean('Reminders')->get_full_list("reminders.date_entered", "reminders.related_event_module = '$eventModule' AND reminders.related_event_module_id = '$eventModuleId'"); |
|
160 | + if ($reminders) { |
|
161 | + foreach ($reminders as $reminder) { |
|
162 | + $ret[] = array( |
|
163 | + 'id' => $isDuplicate ? null : $reminder->id, |
|
164 | + 'popup' => $reminder->popup, |
|
165 | + 'email' => $reminder->email, |
|
166 | + 'timer_popup' => $reminder->timer_popup, |
|
167 | + 'timer_email' => $reminder->timer_email, |
|
168 | + 'invitees' => Reminder_Invitee::loadRemindersInviteesData($reminder->id, $isDuplicate), |
|
169 | + ); |
|
170 | + } |
|
171 | + } |
|
172 | + self::$remindersData[$eventModule][$eventModuleId] = $ret; |
|
173 | + } |
|
174 | + return self::$remindersData[$eventModule][$eventModuleId]; |
|
175 | + } |
|
176 | 176 | |
177 | - // ---- sending email reminders |
|
177 | + // ---- sending email reminders |
|
178 | 178 | |
179 | - /** |
|
180 | - * Sending multiple email reminders. |
|
181 | - * Call in EmainReminder and use original EmailRemainder class for sending. |
|
182 | - * |
|
183 | - * @param EmailReminder $emailReminder Caller EmailReminder |
|
184 | - * @param Administration $admin Administration module for EmailRemainder->sendReminders() function |
|
185 | - * @param boolean $checkDecline (optional) Send email if user accept status is not decline. Default is TRUE. |
|
186 | - */ |
|
187 | - public static function sendEmailReminders(EmailReminder $emailReminder, Administration $admin, $checkDecline = true) { |
|
179 | + /** |
|
180 | + * Sending multiple email reminders. |
|
181 | + * Call in EmainReminder and use original EmailRemainder class for sending. |
|
182 | + * |
|
183 | + * @param EmailReminder $emailReminder Caller EmailReminder |
|
184 | + * @param Administration $admin Administration module for EmailRemainder->sendReminders() function |
|
185 | + * @param boolean $checkDecline (optional) Send email if user accept status is not decline. Default is TRUE. |
|
186 | + */ |
|
187 | + public static function sendEmailReminders(EmailReminder $emailReminder, Administration $admin, $checkDecline = true) { |
|
188 | 188 | if($reminders = self::getUnsentEmailReminders()) { |
189 | 189 | foreach($reminders as $reminderId => $reminder) { |
190 | - $recipients = self::getEmailReminderInviteesRecipients($reminderId, $checkDecline); |
|
191 | - $eventBean = BeanFactory::getBean($reminder->related_event_module, $reminder->related_event_module_id); |
|
192 | - if ( $emailReminder->sendReminders($eventBean, $admin, $recipients) ) { |
|
193 | - $reminder->email_sent = 1; |
|
194 | - $reminder->save(); |
|
195 | - } |
|
190 | + $recipients = self::getEmailReminderInviteesRecipients($reminderId, $checkDecline); |
|
191 | + $eventBean = BeanFactory::getBean($reminder->related_event_module, $reminder->related_event_module_id); |
|
192 | + if ( $emailReminder->sendReminders($eventBean, $admin, $recipients) ) { |
|
193 | + $reminder->email_sent = 1; |
|
194 | + $reminder->save(); |
|
195 | + } |
|
196 | 196 | } |
197 | 197 | } |
198 | 198 | } |
199 | 199 | |
200 | - private static function getEmailReminderInviteesRecipients($reminderId, $checkDecline = true) { |
|
201 | - $emails = array(); |
|
202 | - $reminder = BeanFactory::getBean('Reminders', $reminderId); |
|
203 | - $eventModule = $reminder->related_event_module; |
|
204 | - $eventModuleId = $reminder->related_event_module_id; |
|
205 | - $event = BeanFactory::getBean($eventModule, $eventModuleId); |
|
206 | - if(!isset($event->status) || $event->status != 'Held') { |
|
207 | - $invitees = BeanFactory::getBean('Reminders_Invitees')->get_full_list('', "reminders_invitees.reminder_id = '$reminderId'"); |
|
208 | - foreach($invitees as $invitee) { |
|
209 | - $inviteeModule = $invitee->related_invitee_module; |
|
210 | - $inviteeModuleId = $invitee->related_invitee_module_id; |
|
211 | - $personBean = BeanFactory::getBean($inviteeModule, $inviteeModuleId); |
|
212 | - // The original email reminders check the accept_status field in related users/leads/contacts etc. and filtered these users who not decline this event. |
|
213 | - if($checkDecline && !self::isDecline($event, $personBean)) { |
|
214 | - if ( !empty($personBean->email1) ) { |
|
215 | - $arr = array( |
|
216 | - 'type' => $inviteeModule, |
|
217 | - 'name' => $personBean->full_name, |
|
218 | - 'email' => $personBean->email1, |
|
219 | - ); |
|
220 | - $emails[] = $arr; |
|
221 | - } |
|
222 | - } |
|
223 | - } |
|
224 | - } |
|
225 | - return $emails; |
|
226 | - } |
|
200 | + private static function getEmailReminderInviteesRecipients($reminderId, $checkDecline = true) { |
|
201 | + $emails = array(); |
|
202 | + $reminder = BeanFactory::getBean('Reminders', $reminderId); |
|
203 | + $eventModule = $reminder->related_event_module; |
|
204 | + $eventModuleId = $reminder->related_event_module_id; |
|
205 | + $event = BeanFactory::getBean($eventModule, $eventModuleId); |
|
206 | + if(!isset($event->status) || $event->status != 'Held') { |
|
207 | + $invitees = BeanFactory::getBean('Reminders_Invitees')->get_full_list('', "reminders_invitees.reminder_id = '$reminderId'"); |
|
208 | + foreach($invitees as $invitee) { |
|
209 | + $inviteeModule = $invitee->related_invitee_module; |
|
210 | + $inviteeModuleId = $invitee->related_invitee_module_id; |
|
211 | + $personBean = BeanFactory::getBean($inviteeModule, $inviteeModuleId); |
|
212 | + // The original email reminders check the accept_status field in related users/leads/contacts etc. and filtered these users who not decline this event. |
|
213 | + if($checkDecline && !self::isDecline($event, $personBean)) { |
|
214 | + if ( !empty($personBean->email1) ) { |
|
215 | + $arr = array( |
|
216 | + 'type' => $inviteeModule, |
|
217 | + 'name' => $personBean->full_name, |
|
218 | + 'email' => $personBean->email1, |
|
219 | + ); |
|
220 | + $emails[] = $arr; |
|
221 | + } |
|
222 | + } |
|
223 | + } |
|
224 | + } |
|
225 | + return $emails; |
|
226 | + } |
|
227 | 227 | |
228 | 228 | private static function getUnsentEmailReminders() { |
229 | 229 | global $db; |
230 | - $reminders = array(); |
|
231 | - $reminderBeans = BeanFactory::getBean('Reminders')->get_full_list('', "reminders.email = 1 AND reminders.email_sent = 0"); |
|
232 | - foreach($reminderBeans as $reminderBean) { |
|
233 | - $eventBean = BeanFactory::getBean($reminderBean->related_event_module, $reminderBean->related_event_module_id); |
|
234 | - $dateStart = $eventBean->date_start; |
|
235 | - $time = strtotime($db->fromConvert($dateStart,'datetime')); |
|
236 | - $dateStart = date(TimeDate::DB_DATETIME_FORMAT, $time); |
|
237 | - $remind_ts = $GLOBALS['timedate']->fromDb($db->fromConvert($dateStart,'datetime'))->modify("-{$reminderBean->timer_email} seconds")->ts; |
|
230 | + $reminders = array(); |
|
231 | + $reminderBeans = BeanFactory::getBean('Reminders')->get_full_list('', "reminders.email = 1 AND reminders.email_sent = 0"); |
|
232 | + foreach($reminderBeans as $reminderBean) { |
|
233 | + $eventBean = BeanFactory::getBean($reminderBean->related_event_module, $reminderBean->related_event_module_id); |
|
234 | + $dateStart = $eventBean->date_start; |
|
235 | + $time = strtotime($db->fromConvert($dateStart,'datetime')); |
|
236 | + $dateStart = date(TimeDate::DB_DATETIME_FORMAT, $time); |
|
237 | + $remind_ts = $GLOBALS['timedate']->fromDb($db->fromConvert($dateStart,'datetime'))->modify("-{$reminderBean->timer_email} seconds")->ts; |
|
238 | 238 | $now_ts = $GLOBALS['timedate']->getNow()->ts; |
239 | 239 | if ( $now_ts >= $remind_ts ) { |
240 | 240 | $reminders[$reminderBean->id] = $reminderBean; |
241 | 241 | } |
242 | - } |
|
242 | + } |
|
243 | 243 | return $reminders; |
244 | 244 | } |
245 | 245 | |
246 | - // ---- popup and alert reminders |
|
246 | + // ---- popup and alert reminders |
|
247 | 247 | |
248 | - /** |
|
249 | - * Show a popup and/or desktop notification alert for related users with related Event information. |
|
250 | - * Call in jsAlerts class and use original jsAlerts for show notifications. |
|
251 | - * |
|
252 | - * @global ??? $current_user |
|
253 | - * @global ??? $timedate |
|
254 | - * @global ??? $app_list_strings |
|
255 | - * @global ??? $db |
|
256 | - * @global ??? $sugar_config |
|
257 | - * @global ??? $app_strings |
|
258 | - * @param jsAlerts $alert caller jsAlerts object |
|
259 | - * @param boolean $checkDecline (optional) Send email if user accept status is not decline. Default is TRUE. |
|
260 | - * @return ??? |
|
261 | - */ |
|
262 | - public static function addNotifications(jsAlerts $alert, $checkDecline = true) { |
|
263 | - global $current_user, $timedate, $app_list_strings, $db, $sugar_config, $app_strings; |
|
264 | - |
|
265 | - if (empty($current_user->id)) { |
|
248 | + /** |
|
249 | + * Show a popup and/or desktop notification alert for related users with related Event information. |
|
250 | + * Call in jsAlerts class and use original jsAlerts for show notifications. |
|
251 | + * |
|
252 | + * @global ??? $current_user |
|
253 | + * @global ??? $timedate |
|
254 | + * @global ??? $app_list_strings |
|
255 | + * @global ??? $db |
|
256 | + * @global ??? $sugar_config |
|
257 | + * @global ??? $app_strings |
|
258 | + * @param jsAlerts $alert caller jsAlerts object |
|
259 | + * @param boolean $checkDecline (optional) Send email if user accept status is not decline. Default is TRUE. |
|
260 | + * @return ??? |
|
261 | + */ |
|
262 | + public static function addNotifications(jsAlerts $alert, $checkDecline = true) { |
|
263 | + global $current_user, $timedate, $app_list_strings, $db, $sugar_config, $app_strings; |
|
264 | + |
|
265 | + if (empty($current_user->id)) { |
|
266 | 266 | return; |
267 | - } |
|
267 | + } |
|
268 | 268 | |
269 | - //Create separate variable to hold timedate value |
|
269 | + //Create separate variable to hold timedate value |
|
270 | 270 | $alertDateTimeNow = $timedate->nowDb(); |
271 | 271 | |
272 | - // cn: get a boundary limiter |
|
273 | - $dateTimeMax = $timedate->getNow()->modify("+{$app_list_strings['reminder_max_time']} seconds")->asDb(); |
|
274 | - $dateTimeNow = $timedate->nowDb(); |
|
272 | + // cn: get a boundary limiter |
|
273 | + $dateTimeMax = $timedate->getNow()->modify("+{$app_list_strings['reminder_max_time']} seconds")->asDb(); |
|
274 | + $dateTimeNow = $timedate->nowDb(); |
|
275 | 275 | |
276 | - $dateTimeNow = $db->convert($db->quoted($dateTimeNow), 'datetime'); |
|
277 | - $dateTimeMax = $db->convert($db->quoted($dateTimeMax), 'datetime'); |
|
276 | + $dateTimeNow = $db->convert($db->quoted($dateTimeNow), 'datetime'); |
|
277 | + $dateTimeMax = $db->convert($db->quoted($dateTimeMax), 'datetime'); |
|
278 | 278 | |
279 | - // Original jsAlert used to a meeting integration. |
|
279 | + // Original jsAlert used to a meeting integration. |
|
280 | 280 | |
281 | - /////////////////////////////////////////////////////////////////////// |
|
282 | - //// MEETING INTEGRATION |
|
283 | - $meetingIntegration = null; |
|
284 | - if(isset($sugar_config['meeting_integration']) && !empty($sugar_config['meeting_integration'])) { |
|
285 | - if(!class_exists($sugar_config['meeting_integration'])) { |
|
286 | - require_once("modules/{$sugar_config['meeting_integration']}/{$sugar_config['meeting_integration']}.php"); |
|
287 | - } |
|
288 | - $meetingIntegration = new $sugar_config['meeting_integration'](); |
|
289 | - } |
|
290 | - //// END MEETING INTEGRATION |
|
291 | - /////////////////////////////////////////////////////////////////////// |
|
281 | + /////////////////////////////////////////////////////////////////////// |
|
282 | + //// MEETING INTEGRATION |
|
283 | + $meetingIntegration = null; |
|
284 | + if(isset($sugar_config['meeting_integration']) && !empty($sugar_config['meeting_integration'])) { |
|
285 | + if(!class_exists($sugar_config['meeting_integration'])) { |
|
286 | + require_once("modules/{$sugar_config['meeting_integration']}/{$sugar_config['meeting_integration']}.php"); |
|
287 | + } |
|
288 | + $meetingIntegration = new $sugar_config['meeting_integration'](); |
|
289 | + } |
|
290 | + //// END MEETING INTEGRATION |
|
291 | + /////////////////////////////////////////////////////////////////////// |
|
292 | 292 | |
293 | - $popupReminders = BeanFactory::getBean('Reminders')->get_full_list('', "reminders.popup = 1"); |
|
294 | - |
|
295 | - if($popupReminders) { |
|
296 | - foreach($popupReminders as $popupReminder) { |
|
297 | - $relatedEvent = BeanFactory::getBean($popupReminder->related_event_module, $popupReminder->related_event_module_id); |
|
298 | - if( $relatedEvent && |
|
299 | - (!isset($relatedEvent->status) || $relatedEvent->status == 'Planned') && |
|
300 | - (!isset($relatedEvent->date_start) || (strtotime($relatedEvent->date_start) >= strtotime(self::unQuoteTime($dateTimeNow)) && strtotime($relatedEvent->date_start) <= strtotime(self::unQuoteTime($dateTimeMax))) ) && |
|
301 | - (!$checkDecline || ($checkDecline && !self::isDecline($relatedEvent, BeanFactory::getBean('Users', $current_user->id)))) |
|
302 | - ) { |
|
303 | - // The original popup/alert reminders check the accept_status field in related users/leads/contacts etc. and filtered these users who not decline this event. |
|
304 | - $invitees = BeanFactory::getBean('Reminders_Invitees')->get_full_list('', "reminders_invitees.reminder_id = '{$popupReminder->id}' AND reminders_invitees.related_invitee_module_id = '{$current_user->id}'"); |
|
305 | - if($invitees) { |
|
306 | - foreach($invitees as $invitee) { |
|
307 | - // need to concatenate since GMT times can bridge two local days |
|
308 | - $timeStart = strtotime($db->fromConvert(isset($relatedEvent->date_start) ? $relatedEvent->date_start : date(TimeDate::DB_DATETIME_FORMAT), 'datetime')); |
|
309 | - $timeRemind = $popupReminder->timer_popup; |
|
310 | - $timeStart -= $timeRemind; |
|
311 | - |
|
312 | - $url = 'index.php?action=DetailView&module=' . $popupReminder->related_event_module . '&record=' . $popupReminder->related_event_module_id; |
|
313 | - $instructions = $app_strings['MSG_JS_ALERT_MTG_REMINDER_MEETING_MSG']; |
|
314 | - |
|
315 | - if($popupReminder->related_event_module == 'Meetings') { |
|
316 | - /////////////////////////////////////////////////////////////////// |
|
317 | - //// MEETING INTEGRATION |
|
318 | - if(!empty($meetingIntegration) && $meetingIntegration->isIntegratedMeeting($popupReminder->related_event_module_id)) { |
|
319 | - $url = $meetingIntegration->miUrlGetJsAlert((array) $popupReminder); |
|
320 | - $instructions = $meetingIntegration->miGetJsAlertInstructions(); |
|
321 | - } |
|
322 | - //// END MEETING INTEGRATION |
|
323 | - /////////////////////////////////////////////////////////////////// |
|
324 | - } |
|
293 | + $popupReminders = BeanFactory::getBean('Reminders')->get_full_list('', "reminders.popup = 1"); |
|
294 | + |
|
295 | + if($popupReminders) { |
|
296 | + foreach($popupReminders as $popupReminder) { |
|
297 | + $relatedEvent = BeanFactory::getBean($popupReminder->related_event_module, $popupReminder->related_event_module_id); |
|
298 | + if( $relatedEvent && |
|
299 | + (!isset($relatedEvent->status) || $relatedEvent->status == 'Planned') && |
|
300 | + (!isset($relatedEvent->date_start) || (strtotime($relatedEvent->date_start) >= strtotime(self::unQuoteTime($dateTimeNow)) && strtotime($relatedEvent->date_start) <= strtotime(self::unQuoteTime($dateTimeMax))) ) && |
|
301 | + (!$checkDecline || ($checkDecline && !self::isDecline($relatedEvent, BeanFactory::getBean('Users', $current_user->id)))) |
|
302 | + ) { |
|
303 | + // The original popup/alert reminders check the accept_status field in related users/leads/contacts etc. and filtered these users who not decline this event. |
|
304 | + $invitees = BeanFactory::getBean('Reminders_Invitees')->get_full_list('', "reminders_invitees.reminder_id = '{$popupReminder->id}' AND reminders_invitees.related_invitee_module_id = '{$current_user->id}'"); |
|
305 | + if($invitees) { |
|
306 | + foreach($invitees as $invitee) { |
|
307 | + // need to concatenate since GMT times can bridge two local days |
|
308 | + $timeStart = strtotime($db->fromConvert(isset($relatedEvent->date_start) ? $relatedEvent->date_start : date(TimeDate::DB_DATETIME_FORMAT), 'datetime')); |
|
309 | + $timeRemind = $popupReminder->timer_popup; |
|
310 | + $timeStart -= $timeRemind; |
|
311 | + |
|
312 | + $url = 'index.php?action=DetailView&module=' . $popupReminder->related_event_module . '&record=' . $popupReminder->related_event_module_id; |
|
313 | + $instructions = $app_strings['MSG_JS_ALERT_MTG_REMINDER_MEETING_MSG']; |
|
314 | + |
|
315 | + if($popupReminder->related_event_module == 'Meetings') { |
|
316 | + /////////////////////////////////////////////////////////////////// |
|
317 | + //// MEETING INTEGRATION |
|
318 | + if(!empty($meetingIntegration) && $meetingIntegration->isIntegratedMeeting($popupReminder->related_event_module_id)) { |
|
319 | + $url = $meetingIntegration->miUrlGetJsAlert((array) $popupReminder); |
|
320 | + $instructions = $meetingIntegration->miGetJsAlertInstructions(); |
|
321 | + } |
|
322 | + //// END MEETING INTEGRATION |
|
323 | + /////////////////////////////////////////////////////////////////// |
|
324 | + } |
|
325 | 325 | |
326 | - $meetingName = from_html(isset($relatedEvent->name) ? $relatedEvent->name : $app_strings['MSG_JS_ALERT_MTG_REMINDER_NO_EVENT_NAME']); |
|
327 | - $desc1 = from_html(isset($relatedEvent->description) ? $relatedEvent->description : $app_strings['MSG_JS_ALERT_MTG_REMINDER_NO_DESCRIPTION']); |
|
328 | - $location = from_html(isset($relatedEvent->location) ? $relatedEvent->location : $app_strings['MSG_JS_ALERT_MTG_REMINDER_NO_LOCATION']); |
|
326 | + $meetingName = from_html(isset($relatedEvent->name) ? $relatedEvent->name : $app_strings['MSG_JS_ALERT_MTG_REMINDER_NO_EVENT_NAME']); |
|
327 | + $desc1 = from_html(isset($relatedEvent->description) ? $relatedEvent->description : $app_strings['MSG_JS_ALERT_MTG_REMINDER_NO_DESCRIPTION']); |
|
328 | + $location = from_html(isset($relatedEvent->location) ? $relatedEvent->location : $app_strings['MSG_JS_ALERT_MTG_REMINDER_NO_LOCATION']); |
|
329 | 329 | |
330 | - $relatedToMeeting = $alert->getRelatedName($popupReminder->related_event_module, $popupReminder->related_event_module_id); |
|
330 | + $relatedToMeeting = $alert->getRelatedName($popupReminder->related_event_module, $popupReminder->related_event_module_id); |
|
331 | 331 | |
332 | - $description = empty($desc1) ? '' : $app_strings['MSG_JS_ALERT_MTG_REMINDER_AGENDA'].$desc1."\n"; |
|
333 | - $description = $description ."\n" .$app_strings['MSG_JS_ALERT_MTG_REMINDER_STATUS'] . (isset($relatedEvent->status) ? $relatedEvent->status : '') ."\n". $app_strings['MSG_JS_ALERT_MTG_REMINDER_RELATED_TO']. $relatedToMeeting; |
|
334 | - |
|
335 | - |
|
336 | - if(isset($relatedEvent->date_start)) { |
|
337 | - $time_dbFromConvert = $db->fromConvert($relatedEvent->date_start, 'datetime'); |
|
338 | - $time = $timedate->to_display_date_time($time_dbFromConvert); |
|
339 | - if(!$time) { |
|
340 | - $time = $relatedEvent->date_start; |
|
341 | - } |
|
342 | - if(!$time) { |
|
343 | - $time = $app_strings['MSG_JS_ALERT_MTG_REMINDER_NO_START_DATE']; |
|
344 | - } |
|
345 | - } |
|
346 | - else { |
|
347 | - $time = $app_strings['MSG_JS_ALERT_MTG_REMINDER_NO_START_DATE']; |
|
348 | - } |
|
349 | - |
|
350 | - // standard functionality |
|
351 | - $alert->addAlert($app_strings['MSG_JS_ALERT_MTG_REMINDER_MEETING'], $meetingName, |
|
352 | - $app_strings['MSG_JS_ALERT_MTG_REMINDER_TIME'].$time, |
|
353 | - $app_strings['MSG_JS_ALERT_MTG_REMINDER_LOC'].$location. |
|
354 | - $description. |
|
355 | - $instructions, |
|
356 | - $timeStart - strtotime($alertDateTimeNow), |
|
357 | - $url |
|
358 | - ); |
|
359 | - } |
|
360 | - } |
|
361 | - } |
|
362 | - } |
|
363 | - } |
|
364 | - } |
|
365 | - |
|
366 | - private static function unQuoteTime($timestr) { |
|
367 | - $ret = ''; |
|
368 | - for($i=0; $i<strlen($timestr); $i++) { |
|
369 | - if($timestr[$i]!="'") $ret .= $timestr[$i]; |
|
370 | - } |
|
371 | - return $ret; |
|
372 | - } |
|
332 | + $description = empty($desc1) ? '' : $app_strings['MSG_JS_ALERT_MTG_REMINDER_AGENDA'].$desc1."\n"; |
|
333 | + $description = $description ."\n" .$app_strings['MSG_JS_ALERT_MTG_REMINDER_STATUS'] . (isset($relatedEvent->status) ? $relatedEvent->status : '') ."\n". $app_strings['MSG_JS_ALERT_MTG_REMINDER_RELATED_TO']. $relatedToMeeting; |
|
334 | + |
|
335 | + |
|
336 | + if(isset($relatedEvent->date_start)) { |
|
337 | + $time_dbFromConvert = $db->fromConvert($relatedEvent->date_start, 'datetime'); |
|
338 | + $time = $timedate->to_display_date_time($time_dbFromConvert); |
|
339 | + if(!$time) { |
|
340 | + $time = $relatedEvent->date_start; |
|
341 | + } |
|
342 | + if(!$time) { |
|
343 | + $time = $app_strings['MSG_JS_ALERT_MTG_REMINDER_NO_START_DATE']; |
|
344 | + } |
|
345 | + } |
|
346 | + else { |
|
347 | + $time = $app_strings['MSG_JS_ALERT_MTG_REMINDER_NO_START_DATE']; |
|
348 | + } |
|
349 | + |
|
350 | + // standard functionality |
|
351 | + $alert->addAlert($app_strings['MSG_JS_ALERT_MTG_REMINDER_MEETING'], $meetingName, |
|
352 | + $app_strings['MSG_JS_ALERT_MTG_REMINDER_TIME'].$time, |
|
353 | + $app_strings['MSG_JS_ALERT_MTG_REMINDER_LOC'].$location. |
|
354 | + $description. |
|
355 | + $instructions, |
|
356 | + $timeStart - strtotime($alertDateTimeNow), |
|
357 | + $url |
|
358 | + ); |
|
359 | + } |
|
360 | + } |
|
361 | + } |
|
362 | + } |
|
363 | + } |
|
364 | + } |
|
365 | + |
|
366 | + private static function unQuoteTime($timestr) { |
|
367 | + $ret = ''; |
|
368 | + for($i=0; $i<strlen($timestr); $i++) { |
|
369 | + if($timestr[$i]!="'") $ret .= $timestr[$i]; |
|
370 | + } |
|
371 | + return $ret; |
|
372 | + } |
|
373 | 373 | |
374 | - // --- test for accept status decline is? |
|
374 | + // --- test for accept status decline is? |
|
375 | 375 | |
376 | - private static function isDecline(SugarBean $event, SugarBean $person) { |
|
377 | - return self::testEventPersonAcceptStatus($event, $person, 'decline'); |
|
378 | - } |
|
376 | + private static function isDecline(SugarBean $event, SugarBean $person) { |
|
377 | + return self::testEventPersonAcceptStatus($event, $person, 'decline'); |
|
378 | + } |
|
379 | 379 | |
380 | - private static function testEventPersonAcceptStatus(SugarBean $event, SugarBean $person, $acceptStatus = 'decline') { |
|
381 | - if($acceptStats = self::getEventPersonAcceptStatus($event, $person)) { |
|
382 | - $acceptStatusLower = strtolower($acceptStatus); |
|
383 | - foreach((array) $acceptStats as $acceptStat) { |
|
384 | - if(strtolower($acceptStat) == $acceptStatusLower) { |
|
385 | - return true; |
|
386 | - } |
|
387 | - } |
|
388 | - } |
|
389 | - return false; |
|
390 | - } |
|
380 | + private static function testEventPersonAcceptStatus(SugarBean $event, SugarBean $person, $acceptStatus = 'decline') { |
|
381 | + if($acceptStats = self::getEventPersonAcceptStatus($event, $person)) { |
|
382 | + $acceptStatusLower = strtolower($acceptStatus); |
|
383 | + foreach((array) $acceptStats as $acceptStat) { |
|
384 | + if(strtolower($acceptStat) == $acceptStatusLower) { |
|
385 | + return true; |
|
386 | + } |
|
387 | + } |
|
388 | + } |
|
389 | + return false; |
|
390 | + } |
|
391 | 391 | |
392 | - private static function getEventPersonAcceptStatus(SugarBean $event, SugarBean $person) { |
|
393 | - global $db; |
|
394 | - $rel_person_table_Key = "rel_{$person->table_name}_table"; |
|
395 | - $rel_person_table_Value = "{$event->table_name}_{$person->table_name}"; |
|
396 | - if(isset($event->$rel_person_table_Key) && $event->$rel_person_table_Key == $rel_person_table_Value) { |
|
397 | - $query = self::getEventPersonQuery($event, $person); |
|
398 | - $re = $db->query($query); |
|
399 | - $ret = array(); |
|
400 | - while($row = $db->fetchByAssoc($re) ) { |
|
401 | - if(!isset($row['accept_status'])) { |
|
402 | - return null; |
|
403 | - } |
|
404 | - $ret[] = $row['accept_status']; |
|
405 | - } |
|
406 | - return $ret; |
|
407 | - } |
|
408 | - return null; |
|
409 | - } |
|
410 | - |
|
411 | - private function upgradeEventPersonQuery(SugarBean $event, $person_table) { |
|
412 | - $eventIdField = strtolower($event->object_name).'_id'; |
|
413 | - $query = " |
|
392 | + private static function getEventPersonAcceptStatus(SugarBean $event, SugarBean $person) { |
|
393 | + global $db; |
|
394 | + $rel_person_table_Key = "rel_{$person->table_name}_table"; |
|
395 | + $rel_person_table_Value = "{$event->table_name}_{$person->table_name}"; |
|
396 | + if(isset($event->$rel_person_table_Key) && $event->$rel_person_table_Key == $rel_person_table_Value) { |
|
397 | + $query = self::getEventPersonQuery($event, $person); |
|
398 | + $re = $db->query($query); |
|
399 | + $ret = array(); |
|
400 | + while($row = $db->fetchByAssoc($re) ) { |
|
401 | + if(!isset($row['accept_status'])) { |
|
402 | + return null; |
|
403 | + } |
|
404 | + $ret[] = $row['accept_status']; |
|
405 | + } |
|
406 | + return $ret; |
|
407 | + } |
|
408 | + return null; |
|
409 | + } |
|
410 | + |
|
411 | + private function upgradeEventPersonQuery(SugarBean $event, $person_table) { |
|
412 | + $eventIdField = strtolower($event->object_name).'_id'; |
|
413 | + $query = " |
|
414 | 414 | SELECT * FROM {$event->table_name}_{$person_table} |
415 | 415 | WHERE |
416 | 416 | {$eventIdField} = '{$event->id}' AND |
417 | 417 | deleted = 0 |
418 | 418 | "; |
419 | - return $query; |
|
420 | - } |
|
421 | - |
|
422 | - private static function getEventPersonQuery(SugarBean $event, SugarBean $person) { |
|
423 | - $eventIdField = array_search($event->table_name, $event->relationship_fields); |
|
424 | - if(!$eventIdField) { |
|
425 | - $eventIdField = strtolower($event->object_name . '_id'); |
|
426 | - } |
|
427 | - $personIdField = strtolower($person->object_name) . '_id'; |
|
428 | - $query = " |
|
419 | + return $query; |
|
420 | + } |
|
421 | + |
|
422 | + private static function getEventPersonQuery(SugarBean $event, SugarBean $person) { |
|
423 | + $eventIdField = array_search($event->table_name, $event->relationship_fields); |
|
424 | + if(!$eventIdField) { |
|
425 | + $eventIdField = strtolower($event->object_name . '_id'); |
|
426 | + } |
|
427 | + $personIdField = strtolower($person->object_name) . '_id'; |
|
428 | + $query = " |
|
429 | 429 | SELECT * FROM {$event->table_name}_{$person->table_name} |
430 | 430 | WHERE |
431 | 431 | {$eventIdField} = '{$event->id}' AND |
432 | 432 | {$personIdField} = '{$person->id}' AND |
433 | 433 | deleted = 0 |
434 | 434 | "; |
435 | - return $query; |
|
436 | - } |
|
435 | + return $query; |
|
436 | + } |
|
437 | 437 | |
438 | - // --- user preferences as default values in reminders |
|
439 | - |
|
440 | - /** |
|
441 | - * Default values for Reminders from User Preferences |
|
442 | - * @return string JSON encoded default values |
|
443 | - * @throws Exception on json_encode error |
|
444 | - */ |
|
445 | - public static function loadRemindersDefaultValuesDataJson() { |
|
446 | - $ret = json_encode(self::loadRemindersDefaultValuesData()); |
|
447 | - if(!$ret && json_last_error()) { |
|
438 | + // --- user preferences as default values in reminders |
|
439 | + |
|
440 | + /** |
|
441 | + * Default values for Reminders from User Preferences |
|
442 | + * @return string JSON encoded default values |
|
443 | + * @throws Exception on json_encode error |
|
444 | + */ |
|
445 | + public static function loadRemindersDefaultValuesDataJson() { |
|
446 | + $ret = json_encode(self::loadRemindersDefaultValuesData()); |
|
447 | + if(!$ret && json_last_error()) { |
|
448 | 448 | throw new Exception(json_last_error_msg()); |
449 | 449 | } |
450 | - return $ret; |
|
451 | - } |
|
450 | + return $ret; |
|
451 | + } |
|
452 | 452 | |
453 | - /** |
|
454 | - * Default values for Reminders from User Preferences |
|
455 | - * @return array default values |
|
456 | - */ |
|
457 | - public static function loadRemindersDefaultValuesData() { |
|
458 | - global $current_user; |
|
459 | - |
|
460 | - $preferencePopupReminderTime = $current_user->getPreference('reminder_time'); |
|
461 | - $preferenceEmailReminderTime = $current_user->getPreference('email_reminder_time'); |
|
462 | - $preferencePopupReminderChecked = $current_user->getPreference('reminder_checked'); |
|
463 | - $preferenceEmailReminderChecked = $current_user->getPreference('email_reminder_checked'); |
|
464 | - |
|
465 | - return array( |
|
466 | - 'popup' => $preferencePopupReminderChecked, |
|
467 | - 'email' => $preferenceEmailReminderChecked, |
|
468 | - 'timer_popup' => $preferencePopupReminderTime, |
|
469 | - 'timer_email' => $preferenceEmailReminderTime, |
|
470 | - ); |
|
471 | - } |
|
472 | - |
|
473 | - // --- upgrade |
|
474 | - |
|
475 | - /** |
|
476 | - * Reminders upgrade, old reminders migrate to multiple-reminders. |
|
477 | - * @throws Exception unknown event type or any error |
|
478 | - */ |
|
479 | - public static function upgrade() { |
|
480 | - self::upgradeUserPreferences(); |
|
481 | - self::upgradeEventReminders('Calls'); |
|
482 | - self::upgradeEventReminders('Meetings'); |
|
483 | - self::upgradeRestoreReminders(); |
|
484 | - } |
|
485 | - |
|
486 | - private static function upgradeRestoreReminders() { |
|
487 | - if($reminders = BeanFactory::getBean('Reminders')->get_full_list('', 'reminders.deleted = 1')) { |
|
488 | - foreach($reminders as $reminder) { |
|
489 | - $reminder->deleted = 0; |
|
490 | - $reminder->save(); |
|
491 | - } |
|
492 | - } |
|
493 | - if($reminderInvitees = BeanFactory::getBean('Reminders_Invitees')->get_full_list('', 'reminders_invitees.deleted = 1')) { |
|
494 | - foreach($reminderInvitees as $invitee) { |
|
495 | - $invitee->deleted = 0; |
|
496 | - $invitee->save(); |
|
497 | - } |
|
498 | - } |
|
499 | - global $db; |
|
500 | - $q = "UPDATE reminders SET deleted = 0"; |
|
501 | - $db->query($q); |
|
502 | - $q = "UPDATE reminders_invitees SET deleted = 0"; |
|
503 | - $db->query($q); |
|
504 | - } |
|
505 | - |
|
506 | - private static function upgradeUserPreferences() { |
|
507 | - $users = User::getActiveUsers(); |
|
508 | - foreach($users as $user_id => $user_name) { |
|
509 | - $user = new User(); |
|
510 | - $user->retrieve($user_id); |
|
511 | - |
|
512 | - $preferencePopupReminderTime = $user->getPreference('reminder_time'); |
|
513 | - $preferenceEmailReminderTime = $user->getPreference('email_reminder_time'); |
|
514 | - |
|
515 | - $preferencePopupReminderChecked = $preferencePopupReminderTime > -1; |
|
516 | - $preferenceEmailReminderChecked = $preferenceEmailReminderTime > -1; |
|
517 | - $user->setPreference('reminder_checked', $preferencePopupReminderChecked); |
|
518 | - $user->setPreference('email_reminder_checked', $preferenceEmailReminderChecked); |
|
519 | - |
|
520 | - } |
|
521 | - } |
|
522 | - |
|
523 | - /** |
|
524 | - * @param string $eventModule 'Calls' or 'Meetings' |
|
525 | - */ |
|
526 | - private static function upgradeEventReminders($eventModule) { |
|
527 | - |
|
528 | - $eventBean = BeanFactory::getBean($eventModule); |
|
529 | - $events = BeanFactory::getBean($eventModule)->get_full_list('', "{$eventBean->table_name}.date_start > '2015-11-01 00:00:00' AND ({$eventBean->table_name}.reminder_time != -1 OR ({$eventBean->table_name}.email_reminder_time != -1 AND {$eventBean->table_name}.email_reminder_sent != 1))"); |
|
530 | - if ($events) { |
|
531 | - foreach ($events as $event) { |
|
532 | - |
|
533 | - $oldReminderPopupChecked = false; |
|
534 | - $oldReminderPopupTimer = null; |
|
535 | - if ($event->reminder_time != -1) { |
|
536 | - $oldReminderPopupChecked = true; |
|
537 | - $oldReminderPopupTimer = $event->reminder_time; |
|
538 | - } |
|
539 | - |
|
540 | - $oldReminderEmailChecked = false; |
|
541 | - $oldReminderEmailTimer = null; |
|
542 | - if ($event->email_reminder_time != -1) { |
|
543 | - $oldReminderEmailChecked = true; |
|
544 | - $oldReminderEmailTimer = $event->email_reminder_time; |
|
545 | - } |
|
546 | - |
|
547 | - $oldReminderEmailSent = $event->email_reminder_sent; |
|
548 | - |
|
549 | - if( ($oldInvitees = self::getOldEventInvitees($event)) && ($event->reminder_time != -1 || ($event->email_reminder_time != -1 && $event->email_reminder_sent != 1)) ) { |
|
550 | - |
|
551 | - self::migrateReminder( |
|
552 | - $eventModule, |
|
553 | - $event->id, |
|
554 | - $oldReminderPopupChecked, |
|
555 | - $oldReminderPopupTimer, |
|
556 | - $oldReminderEmailChecked, |
|
557 | - $oldReminderEmailTimer, |
|
558 | - $oldReminderEmailSent, |
|
559 | - $oldInvitees |
|
560 | - ); |
|
561 | - |
|
562 | - } |
|
563 | - } |
|
564 | - } |
|
565 | - |
|
566 | - } |
|
567 | - |
|
568 | - |
|
569 | - private static function getOldEventInvitees(SugarBean $event) { |
|
570 | - global $db; |
|
571 | - $ret = array(); |
|
572 | - $persons = array('users','contacts','leads'); |
|
573 | - foreach($persons as $person){ |
|
574 | - $query = self::upgradeEventPersonQuery($event, $person); |
|
575 | - $re = $db->query($query); |
|
576 | - while($row = $db->fetchByAssoc($re) ) { |
|
577 | - $ret[] = $row; |
|
578 | - } |
|
579 | - } |
|
580 | - return $ret; |
|
581 | - } |
|
582 | - |
|
583 | - /** |
|
584 | - * @param string $eventModule 'Calls' or 'Meetings' |
|
585 | - * @param string $eventModuleId |
|
586 | - * @param bool $oldReminderPopupChecked |
|
587 | - * @param int $oldReminderPopupTimer |
|
588 | - * @param bool $oldReminderEmailChecked |
|
589 | - * @param int $oldReminderEmailTimer |
|
590 | - * @param array $oldInvitees |
|
591 | - */ |
|
592 | - private static function migrateReminder($eventModule, $eventModuleId, $oldReminderPopupChecked, $oldReminderPopupTimer, $oldReminderEmailChecked, $oldReminderEmailTimer, $oldReminderEmailSent, $oldInvitees) { |
|
593 | - |
|
594 | - $reminder = BeanFactory::getBean('Reminders'); |
|
595 | - $reminder->popup = $oldReminderPopupChecked; |
|
596 | - $reminder->email = $oldReminderEmailChecked; |
|
597 | - $reminder->email_sent = $oldReminderEmailSent; |
|
598 | - $reminder->timer_popup = $oldReminderPopupTimer; |
|
599 | - $reminder->timer_email = $oldReminderEmailTimer; |
|
600 | - $reminder->related_event_module = $eventModule; |
|
601 | - $reminder->related_event_module_id = $eventModuleId; |
|
602 | - $reminder->save(); |
|
603 | - $reminderId = $reminder->id; |
|
604 | - self::migrateReminderInvitees($reminderId, $oldInvitees); |
|
605 | - |
|
606 | - self::removeOldReminder($eventModule, $eventModuleId); |
|
607 | - } |
|
608 | - |
|
609 | - private static function migrateReminderInvitees($reminderId, $invitees) { |
|
610 | - $ret = array(); |
|
611 | - foreach((array) $invitees as $invitee) { |
|
612 | - $newInvitee = BeanFactory::getBean('Reminders_Invitees'); |
|
613 | - $newInvitee->reminder_id = $reminderId; |
|
614 | - $newInvitee->related_invitee_module = self::getRelatedInviteeModuleFromInviteeArray($invitee); |
|
615 | - $newInvitee->related_invitee_module_id = self::getRelatedInviteeModuleIdFromInviteeArray($invitee); |
|
616 | - $newInvitee->save(); |
|
617 | - } |
|
618 | - return $ret; |
|
619 | - } |
|
620 | - |
|
621 | - private static function getRelatedInviteeModuleFromInviteeArray($invitee) { |
|
622 | - if(array_key_exists('user_id', $invitee)) { |
|
623 | - return 'Users'; |
|
624 | - } |
|
625 | - if(array_key_exists('lead_id', $invitee)) { |
|
626 | - return 'Leads'; |
|
627 | - } |
|
628 | - if(array_key_exists('contact_id', $invitee)) { |
|
629 | - return 'Contacts'; |
|
630 | - } |
|
631 | - // TODO:!!!! |
|
632 | - throw new Exception('Unknown invitee module type'); |
|
633 | - //return null; |
|
634 | - } |
|
635 | - |
|
636 | - private static function getRelatedInviteeModuleIdFromInviteeArray($invitee) { |
|
637 | - if(array_key_exists('user_id', $invitee)) { |
|
638 | - return $invitee['user_id']; |
|
639 | - } |
|
640 | - if(array_key_exists('lead_id', $invitee)) { |
|
641 | - return $invitee['lead_id']; |
|
642 | - } |
|
643 | - if(array_key_exists('contact_id', $invitee)) { |
|
644 | - return $invitee['contact_id']; |
|
645 | - } |
|
646 | - // TODO:!!!! |
|
647 | - throw new Exception('Unknown invitee type'); |
|
648 | - //return null; |
|
649 | - } |
|
650 | - |
|
651 | - /** |
|
652 | - * @param string $eventModule 'Calls' or 'Meetings' |
|
653 | - * @param string $eventModuleId |
|
654 | - */ |
|
655 | - private static function removeOldReminder($eventModule, $eventModuleId) { |
|
656 | - $event = BeanFactory::getBean($eventModule, $eventModuleId); |
|
657 | - $event->reminder_time = -1; |
|
658 | - $event->email_reminder_time = -1; |
|
659 | - $event->email_reminder_sent = 0; |
|
660 | - $event->save(); |
|
661 | - } |
|
662 | - |
|
663 | - // --- reminders list on detail views |
|
664 | - |
|
665 | - /** |
|
666 | - * Return a list of related reminders for specified event (Calls/Meetings). Call it from DetailViews. |
|
667 | - * @param SugarBean $event a Call or Meeting Bean |
|
668 | - * @return mixed|string|void output of list (html) |
|
669 | - * @throws Exception on json error in Remainders |
|
670 | - */ |
|
671 | - public static function getRemindersListView(SugarBean $event) { |
|
672 | - global $mod_strings, $app_list_strings; |
|
673 | - $tpl = new Sugar_Smarty(); |
|
674 | - $tpl->assign('MOD', $mod_strings); |
|
675 | - $tpl->assign('reminder_time_options', $app_list_strings['reminder_time_options']); |
|
676 | - $tpl->assign('remindersData', Reminder::loadRemindersData($event->module_name, $event->id)); |
|
677 | - $tpl->assign('remindersDataJson', Reminder::loadRemindersDataJson($event->module_name, $event->id)); |
|
678 | - $tpl->assign('remindersDefaultValuesDataJson', Reminder::loadRemindersDefaultValuesDataJson()); |
|
679 | - $tpl->assign('remindersDisabled', json_encode(true)); |
|
680 | - return $tpl->fetch('modules/Reminders/tpls/reminders.tpl'); |
|
681 | - } |
|
682 | - |
|
683 | - /* |
|
453 | + /** |
|
454 | + * Default values for Reminders from User Preferences |
|
455 | + * @return array default values |
|
456 | + */ |
|
457 | + public static function loadRemindersDefaultValuesData() { |
|
458 | + global $current_user; |
|
459 | + |
|
460 | + $preferencePopupReminderTime = $current_user->getPreference('reminder_time'); |
|
461 | + $preferenceEmailReminderTime = $current_user->getPreference('email_reminder_time'); |
|
462 | + $preferencePopupReminderChecked = $current_user->getPreference('reminder_checked'); |
|
463 | + $preferenceEmailReminderChecked = $current_user->getPreference('email_reminder_checked'); |
|
464 | + |
|
465 | + return array( |
|
466 | + 'popup' => $preferencePopupReminderChecked, |
|
467 | + 'email' => $preferenceEmailReminderChecked, |
|
468 | + 'timer_popup' => $preferencePopupReminderTime, |
|
469 | + 'timer_email' => $preferenceEmailReminderTime, |
|
470 | + ); |
|
471 | + } |
|
472 | + |
|
473 | + // --- upgrade |
|
474 | + |
|
475 | + /** |
|
476 | + * Reminders upgrade, old reminders migrate to multiple-reminders. |
|
477 | + * @throws Exception unknown event type or any error |
|
478 | + */ |
|
479 | + public static function upgrade() { |
|
480 | + self::upgradeUserPreferences(); |
|
481 | + self::upgradeEventReminders('Calls'); |
|
482 | + self::upgradeEventReminders('Meetings'); |
|
483 | + self::upgradeRestoreReminders(); |
|
484 | + } |
|
485 | + |
|
486 | + private static function upgradeRestoreReminders() { |
|
487 | + if($reminders = BeanFactory::getBean('Reminders')->get_full_list('', 'reminders.deleted = 1')) { |
|
488 | + foreach($reminders as $reminder) { |
|
489 | + $reminder->deleted = 0; |
|
490 | + $reminder->save(); |
|
491 | + } |
|
492 | + } |
|
493 | + if($reminderInvitees = BeanFactory::getBean('Reminders_Invitees')->get_full_list('', 'reminders_invitees.deleted = 1')) { |
|
494 | + foreach($reminderInvitees as $invitee) { |
|
495 | + $invitee->deleted = 0; |
|
496 | + $invitee->save(); |
|
497 | + } |
|
498 | + } |
|
499 | + global $db; |
|
500 | + $q = "UPDATE reminders SET deleted = 0"; |
|
501 | + $db->query($q); |
|
502 | + $q = "UPDATE reminders_invitees SET deleted = 0"; |
|
503 | + $db->query($q); |
|
504 | + } |
|
505 | + |
|
506 | + private static function upgradeUserPreferences() { |
|
507 | + $users = User::getActiveUsers(); |
|
508 | + foreach($users as $user_id => $user_name) { |
|
509 | + $user = new User(); |
|
510 | + $user->retrieve($user_id); |
|
511 | + |
|
512 | + $preferencePopupReminderTime = $user->getPreference('reminder_time'); |
|
513 | + $preferenceEmailReminderTime = $user->getPreference('email_reminder_time'); |
|
514 | + |
|
515 | + $preferencePopupReminderChecked = $preferencePopupReminderTime > -1; |
|
516 | + $preferenceEmailReminderChecked = $preferenceEmailReminderTime > -1; |
|
517 | + $user->setPreference('reminder_checked', $preferencePopupReminderChecked); |
|
518 | + $user->setPreference('email_reminder_checked', $preferenceEmailReminderChecked); |
|
519 | + |
|
520 | + } |
|
521 | + } |
|
522 | + |
|
523 | + /** |
|
524 | + * @param string $eventModule 'Calls' or 'Meetings' |
|
525 | + */ |
|
526 | + private static function upgradeEventReminders($eventModule) { |
|
527 | + |
|
528 | + $eventBean = BeanFactory::getBean($eventModule); |
|
529 | + $events = BeanFactory::getBean($eventModule)->get_full_list('', "{$eventBean->table_name}.date_start > '2015-11-01 00:00:00' AND ({$eventBean->table_name}.reminder_time != -1 OR ({$eventBean->table_name}.email_reminder_time != -1 AND {$eventBean->table_name}.email_reminder_sent != 1))"); |
|
530 | + if ($events) { |
|
531 | + foreach ($events as $event) { |
|
532 | + |
|
533 | + $oldReminderPopupChecked = false; |
|
534 | + $oldReminderPopupTimer = null; |
|
535 | + if ($event->reminder_time != -1) { |
|
536 | + $oldReminderPopupChecked = true; |
|
537 | + $oldReminderPopupTimer = $event->reminder_time; |
|
538 | + } |
|
539 | + |
|
540 | + $oldReminderEmailChecked = false; |
|
541 | + $oldReminderEmailTimer = null; |
|
542 | + if ($event->email_reminder_time != -1) { |
|
543 | + $oldReminderEmailChecked = true; |
|
544 | + $oldReminderEmailTimer = $event->email_reminder_time; |
|
545 | + } |
|
546 | + |
|
547 | + $oldReminderEmailSent = $event->email_reminder_sent; |
|
548 | + |
|
549 | + if( ($oldInvitees = self::getOldEventInvitees($event)) && ($event->reminder_time != -1 || ($event->email_reminder_time != -1 && $event->email_reminder_sent != 1)) ) { |
|
550 | + |
|
551 | + self::migrateReminder( |
|
552 | + $eventModule, |
|
553 | + $event->id, |
|
554 | + $oldReminderPopupChecked, |
|
555 | + $oldReminderPopupTimer, |
|
556 | + $oldReminderEmailChecked, |
|
557 | + $oldReminderEmailTimer, |
|
558 | + $oldReminderEmailSent, |
|
559 | + $oldInvitees |
|
560 | + ); |
|
561 | + |
|
562 | + } |
|
563 | + } |
|
564 | + } |
|
565 | + |
|
566 | + } |
|
567 | + |
|
568 | + |
|
569 | + private static function getOldEventInvitees(SugarBean $event) { |
|
570 | + global $db; |
|
571 | + $ret = array(); |
|
572 | + $persons = array('users','contacts','leads'); |
|
573 | + foreach($persons as $person){ |
|
574 | + $query = self::upgradeEventPersonQuery($event, $person); |
|
575 | + $re = $db->query($query); |
|
576 | + while($row = $db->fetchByAssoc($re) ) { |
|
577 | + $ret[] = $row; |
|
578 | + } |
|
579 | + } |
|
580 | + return $ret; |
|
581 | + } |
|
582 | + |
|
583 | + /** |
|
584 | + * @param string $eventModule 'Calls' or 'Meetings' |
|
585 | + * @param string $eventModuleId |
|
586 | + * @param bool $oldReminderPopupChecked |
|
587 | + * @param int $oldReminderPopupTimer |
|
588 | + * @param bool $oldReminderEmailChecked |
|
589 | + * @param int $oldReminderEmailTimer |
|
590 | + * @param array $oldInvitees |
|
591 | + */ |
|
592 | + private static function migrateReminder($eventModule, $eventModuleId, $oldReminderPopupChecked, $oldReminderPopupTimer, $oldReminderEmailChecked, $oldReminderEmailTimer, $oldReminderEmailSent, $oldInvitees) { |
|
593 | + |
|
594 | + $reminder = BeanFactory::getBean('Reminders'); |
|
595 | + $reminder->popup = $oldReminderPopupChecked; |
|
596 | + $reminder->email = $oldReminderEmailChecked; |
|
597 | + $reminder->email_sent = $oldReminderEmailSent; |
|
598 | + $reminder->timer_popup = $oldReminderPopupTimer; |
|
599 | + $reminder->timer_email = $oldReminderEmailTimer; |
|
600 | + $reminder->related_event_module = $eventModule; |
|
601 | + $reminder->related_event_module_id = $eventModuleId; |
|
602 | + $reminder->save(); |
|
603 | + $reminderId = $reminder->id; |
|
604 | + self::migrateReminderInvitees($reminderId, $oldInvitees); |
|
605 | + |
|
606 | + self::removeOldReminder($eventModule, $eventModuleId); |
|
607 | + } |
|
608 | + |
|
609 | + private static function migrateReminderInvitees($reminderId, $invitees) { |
|
610 | + $ret = array(); |
|
611 | + foreach((array) $invitees as $invitee) { |
|
612 | + $newInvitee = BeanFactory::getBean('Reminders_Invitees'); |
|
613 | + $newInvitee->reminder_id = $reminderId; |
|
614 | + $newInvitee->related_invitee_module = self::getRelatedInviteeModuleFromInviteeArray($invitee); |
|
615 | + $newInvitee->related_invitee_module_id = self::getRelatedInviteeModuleIdFromInviteeArray($invitee); |
|
616 | + $newInvitee->save(); |
|
617 | + } |
|
618 | + return $ret; |
|
619 | + } |
|
620 | + |
|
621 | + private static function getRelatedInviteeModuleFromInviteeArray($invitee) { |
|
622 | + if(array_key_exists('user_id', $invitee)) { |
|
623 | + return 'Users'; |
|
624 | + } |
|
625 | + if(array_key_exists('lead_id', $invitee)) { |
|
626 | + return 'Leads'; |
|
627 | + } |
|
628 | + if(array_key_exists('contact_id', $invitee)) { |
|
629 | + return 'Contacts'; |
|
630 | + } |
|
631 | + // TODO:!!!! |
|
632 | + throw new Exception('Unknown invitee module type'); |
|
633 | + //return null; |
|
634 | + } |
|
635 | + |
|
636 | + private static function getRelatedInviteeModuleIdFromInviteeArray($invitee) { |
|
637 | + if(array_key_exists('user_id', $invitee)) { |
|
638 | + return $invitee['user_id']; |
|
639 | + } |
|
640 | + if(array_key_exists('lead_id', $invitee)) { |
|
641 | + return $invitee['lead_id']; |
|
642 | + } |
|
643 | + if(array_key_exists('contact_id', $invitee)) { |
|
644 | + return $invitee['contact_id']; |
|
645 | + } |
|
646 | + // TODO:!!!! |
|
647 | + throw new Exception('Unknown invitee type'); |
|
648 | + //return null; |
|
649 | + } |
|
650 | + |
|
651 | + /** |
|
652 | + * @param string $eventModule 'Calls' or 'Meetings' |
|
653 | + * @param string $eventModuleId |
|
654 | + */ |
|
655 | + private static function removeOldReminder($eventModule, $eventModuleId) { |
|
656 | + $event = BeanFactory::getBean($eventModule, $eventModuleId); |
|
657 | + $event->reminder_time = -1; |
|
658 | + $event->email_reminder_time = -1; |
|
659 | + $event->email_reminder_sent = 0; |
|
660 | + $event->save(); |
|
661 | + } |
|
662 | + |
|
663 | + // --- reminders list on detail views |
|
664 | + |
|
665 | + /** |
|
666 | + * Return a list of related reminders for specified event (Calls/Meetings). Call it from DetailViews. |
|
667 | + * @param SugarBean $event a Call or Meeting Bean |
|
668 | + * @return mixed|string|void output of list (html) |
|
669 | + * @throws Exception on json error in Remainders |
|
670 | + */ |
|
671 | + public static function getRemindersListView(SugarBean $event) { |
|
672 | + global $mod_strings, $app_list_strings; |
|
673 | + $tpl = new Sugar_Smarty(); |
|
674 | + $tpl->assign('MOD', $mod_strings); |
|
675 | + $tpl->assign('reminder_time_options', $app_list_strings['reminder_time_options']); |
|
676 | + $tpl->assign('remindersData', Reminder::loadRemindersData($event->module_name, $event->id)); |
|
677 | + $tpl->assign('remindersDataJson', Reminder::loadRemindersDataJson($event->module_name, $event->id)); |
|
678 | + $tpl->assign('remindersDefaultValuesDataJson', Reminder::loadRemindersDefaultValuesDataJson()); |
|
679 | + $tpl->assign('remindersDisabled', json_encode(true)); |
|
680 | + return $tpl->fetch('modules/Reminders/tpls/reminders.tpl'); |
|
681 | + } |
|
682 | + |
|
683 | + /* |
|
684 | 684 | * @todo implenent it |
685 | 685 | */ |
686 | - public static function getRemindersListInlineEditView(SugarBean $event) { |
|
687 | - // TODO: getEditFieldHTML() function in InlineEditing.php:218 doesn't pass the Bean ID to this custom inline edit view function but we have to know which Bean are in the focus to editing. |
|
688 | - if(!$event->id) { |
|
689 | - throw new Exception("No GUID for edit."); |
|
690 | - } |
|
691 | - } |
|
686 | + public static function getRemindersListInlineEditView(SugarBean $event) { |
|
687 | + // TODO: getEditFieldHTML() function in InlineEditing.php:218 doesn't pass the Bean ID to this custom inline edit view function but we have to know which Bean are in the focus to editing. |
|
688 | + if(!$event->id) { |
|
689 | + throw new Exception("No GUID for edit."); |
|
690 | + } |
|
691 | + } |
|
692 | 692 | |
693 | 693 | } |
694 | 694 | ?> |
695 | 695 | \ No newline at end of file |
@@ -45,12 +45,12 @@ |
||
45 | 45 | require_once('include/formbase.php'); |
46 | 46 | if (!empty($_REQUEST['record'])) { |
47 | 47 | |
48 | - $document = new Document(); |
|
49 | - $document->retrieve($_REQUEST['record']); |
|
50 | - if (!empty($document->document_revision_id) && !empty($_REQUEST['get_latest_for_id'])) { |
|
51 | - $query="update linked_documents set document_revision_id='{$document->document_revision_id}', date_modified='".TimeDate::getInstance()->nowDb()."' where id ='{$_REQUEST['get_latest_for_id']}' "; |
|
52 | - $document->db->query($query); |
|
53 | - } |
|
48 | + $document = new Document(); |
|
49 | + $document->retrieve($_REQUEST['record']); |
|
50 | + if (!empty($document->document_revision_id) && !empty($_REQUEST['get_latest_for_id'])) { |
|
51 | + $query="update linked_documents set document_revision_id='{$document->document_revision_id}', date_modified='".TimeDate::getInstance()->nowDb()."' where id ='{$_REQUEST['get_latest_for_id']}' "; |
|
52 | + $document->db->query($query); |
|
53 | + } |
|
54 | 54 | } |
55 | 55 | handleRedirect(); |
56 | 56 | ?> |
@@ -1,6 +1,6 @@ |
||
1 | 1 | <?php |
2 | 2 | if(!defined('sugarEntry') || !sugarEntry) |
3 | - die('Not A Valid Entry Point'); |
|
3 | + die('Not A Valid Entry Point'); |
|
4 | 4 | /********************************************************************************* |
5 | 5 | * SugarCRM Community Edition is a customer relationship management program developed by |
6 | 6 | * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc. |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | if(!defined('sugarEntry') || !sugarEntry) |
3 | - die('Not A Valid Entry Point'); |
|
3 | + die('Not A Valid Entry Point'); |
|
4 | 4 | /********************************************************************************* |
5 | 5 | * SugarCRM Community Edition is a customer relationship management program developed by |
6 | 6 | * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc. |
@@ -45,71 +45,71 @@ discard block |
||
45 | 45 | // User is used to store Forecast information. |
46 | 46 | class Document extends File { |
47 | 47 | |
48 | - var $id; |
|
49 | - var $document_name; |
|
50 | - var $description; |
|
51 | - var $category_id; |
|
52 | - var $subcategory_id; |
|
53 | - var $status_id; |
|
54 | - var $status; |
|
55 | - var $created_by; |
|
56 | - var $date_entered; |
|
57 | - var $date_modified; |
|
58 | - var $modified_user_id; |
|
48 | + var $id; |
|
49 | + var $document_name; |
|
50 | + var $description; |
|
51 | + var $category_id; |
|
52 | + var $subcategory_id; |
|
53 | + var $status_id; |
|
54 | + var $status; |
|
55 | + var $created_by; |
|
56 | + var $date_entered; |
|
57 | + var $date_modified; |
|
58 | + var $modified_user_id; |
|
59 | 59 | var $assigned_user_id; |
60 | - var $active_date; |
|
61 | - var $exp_date; |
|
62 | - var $document_revision_id; |
|
63 | - var $filename; |
|
64 | - var $doc_type; |
|
65 | - |
|
66 | - var $img_name; |
|
67 | - var $img_name_bare; |
|
68 | - var $related_doc_id; |
|
69 | - var $related_doc_name; |
|
70 | - var $related_doc_rev_id; |
|
71 | - var $related_doc_rev_number; |
|
72 | - var $is_template; |
|
73 | - var $template_type; |
|
74 | - |
|
75 | - //additional fields. |
|
76 | - var $revision; |
|
77 | - var $last_rev_create_date; |
|
78 | - var $last_rev_created_by; |
|
79 | - var $last_rev_created_name; |
|
80 | - var $file_url; |
|
81 | - var $file_url_noimage; |
|
82 | - |
|
83 | - var $table_name = "documents"; |
|
84 | - var $object_name = "Document"; |
|
85 | - var $user_preferences; |
|
86 | - |
|
87 | - var $encodeFields = Array (); |
|
88 | - |
|
89 | - // This is used to retrieve related fields from form posts. |
|
90 | - var $additional_column_fields = Array ('revision'); |
|
91 | - |
|
92 | - var $new_schema = true; |
|
93 | - var $module_dir = 'Documents'; |
|
94 | - |
|
95 | - var $relationship_fields = Array( |
|
96 | - 'contract_id'=>'contracts', |
|
97 | - ); |
|
98 | - |
|
99 | - |
|
100 | - function Document() { |
|
101 | - parent :: File(); |
|
102 | - $this->setupCustomFields('Documents'); //parameter is module name |
|
103 | - $this->disable_row_level_security = false; |
|
104 | - } |
|
105 | - |
|
106 | - function save($check_notify = false) { |
|
60 | + var $active_date; |
|
61 | + var $exp_date; |
|
62 | + var $document_revision_id; |
|
63 | + var $filename; |
|
64 | + var $doc_type; |
|
65 | + |
|
66 | + var $img_name; |
|
67 | + var $img_name_bare; |
|
68 | + var $related_doc_id; |
|
69 | + var $related_doc_name; |
|
70 | + var $related_doc_rev_id; |
|
71 | + var $related_doc_rev_number; |
|
72 | + var $is_template; |
|
73 | + var $template_type; |
|
74 | + |
|
75 | + //additional fields. |
|
76 | + var $revision; |
|
77 | + var $last_rev_create_date; |
|
78 | + var $last_rev_created_by; |
|
79 | + var $last_rev_created_name; |
|
80 | + var $file_url; |
|
81 | + var $file_url_noimage; |
|
82 | + |
|
83 | + var $table_name = "documents"; |
|
84 | + var $object_name = "Document"; |
|
85 | + var $user_preferences; |
|
86 | + |
|
87 | + var $encodeFields = Array (); |
|
88 | + |
|
89 | + // This is used to retrieve related fields from form posts. |
|
90 | + var $additional_column_fields = Array ('revision'); |
|
91 | + |
|
92 | + var $new_schema = true; |
|
93 | + var $module_dir = 'Documents'; |
|
94 | + |
|
95 | + var $relationship_fields = Array( |
|
96 | + 'contract_id'=>'contracts', |
|
97 | + ); |
|
98 | + |
|
99 | + |
|
100 | + function Document() { |
|
101 | + parent :: File(); |
|
102 | + $this->setupCustomFields('Documents'); //parameter is module name |
|
103 | + $this->disable_row_level_security = false; |
|
104 | + } |
|
105 | + |
|
106 | + function save($check_notify = false) { |
|
107 | 107 | |
108 | 108 | if (empty($this->doc_type)) { |
109 | - $this->doc_type = 'Sugar'; |
|
110 | - } |
|
109 | + $this->doc_type = 'Sugar'; |
|
110 | + } |
|
111 | 111 | if (empty($this->id) || $this->new_with_id) |
112 | - { |
|
112 | + { |
|
113 | 113 | if (empty($this->id)) { |
114 | 114 | $this->id = create_guid(); |
115 | 115 | $this->new_with_id = true; |
@@ -135,12 +135,12 @@ discard block |
||
135 | 135 | |
136 | 136 | if(isset($this->file_ext)) |
137 | 137 | { |
138 | - $Revision->file_ext = $this->file_ext; |
|
138 | + $Revision->file_ext = $this->file_ext; |
|
139 | 139 | } |
140 | 140 | |
141 | 141 | if(isset($this->file_mime_type)) |
142 | 142 | { |
143 | - $Revision->file_mime_type = $this->file_mime_type; |
|
143 | + $Revision->file_mime_type = $this->file_mime_type; |
|
144 | 144 | } |
145 | 145 | |
146 | 146 | $Revision->doc_type = $this->doc_type; |
@@ -196,29 +196,29 @@ discard block |
||
196 | 196 | } |
197 | 197 | } |
198 | 198 | |
199 | - return parent :: save($check_notify); |
|
200 | - } |
|
201 | - function get_summary_text() { |
|
202 | - return "$this->document_name"; |
|
203 | - } |
|
199 | + return parent :: save($check_notify); |
|
200 | + } |
|
201 | + function get_summary_text() { |
|
202 | + return "$this->document_name"; |
|
203 | + } |
|
204 | 204 | |
205 | - function is_authenticated() { |
|
206 | - return $this->authenticated; |
|
207 | - } |
|
205 | + function is_authenticated() { |
|
206 | + return $this->authenticated; |
|
207 | + } |
|
208 | 208 | |
209 | - function fill_in_additional_list_fields() { |
|
210 | - $this->fill_in_additional_detail_fields(); |
|
211 | - } |
|
209 | + function fill_in_additional_list_fields() { |
|
210 | + $this->fill_in_additional_detail_fields(); |
|
211 | + } |
|
212 | 212 | |
213 | - function fill_in_additional_detail_fields() { |
|
214 | - global $theme; |
|
215 | - global $current_language; |
|
216 | - global $timedate; |
|
217 | - global $locale; |
|
213 | + function fill_in_additional_detail_fields() { |
|
214 | + global $theme; |
|
215 | + global $current_language; |
|
216 | + global $timedate; |
|
217 | + global $locale; |
|
218 | 218 | |
219 | - parent::fill_in_additional_detail_fields(); |
|
219 | + parent::fill_in_additional_detail_fields(); |
|
220 | 220 | |
221 | - $mod_strings = return_module_language($current_language, 'Documents'); |
|
221 | + $mod_strings = return_module_language($current_language, 'Documents'); |
|
222 | 222 | |
223 | 223 | if (!empty($this->document_revision_id)) { |
224 | 224 | |
@@ -234,7 +234,7 @@ discard block |
||
234 | 234 | //populate name |
235 | 235 | if(isset($this->document_name)) |
236 | 236 | { |
237 | - $this->name = $this->document_name; |
|
237 | + $this->name = $this->document_name; |
|
238 | 238 | } |
239 | 239 | |
240 | 240 | if(isset($row['filename']))$this->filename = $row['filename']; |
@@ -251,93 +251,93 @@ discard block |
||
251 | 251 | } |
252 | 252 | } |
253 | 253 | |
254 | - //set default file name. |
|
255 | - if (!empty ($img_name) && file_exists($img_name)) { |
|
256 | - $img_name = $img_name_bare; |
|
257 | - } else { |
|
258 | - $img_name = "def_image_inline"; //todo change the default image. |
|
259 | - } |
|
260 | - if($this->ACLAccess('DetailView')) { |
|
261 | - if(!empty($this->doc_type) && $this->doc_type != 'Sugar' && !empty($this->doc_url)) { |
|
254 | + //set default file name. |
|
255 | + if (!empty ($img_name) && file_exists($img_name)) { |
|
256 | + $img_name = $img_name_bare; |
|
257 | + } else { |
|
258 | + $img_name = "def_image_inline"; //todo change the default image. |
|
259 | + } |
|
260 | + if($this->ACLAccess('DetailView')) { |
|
261 | + if(!empty($this->doc_type) && $this->doc_type != 'Sugar' && !empty($this->doc_url)) { |
|
262 | 262 | $file_url= "<a href='".$this->doc_url."' target='_blank'>".SugarThemeRegistry::current()->getImage($this->doc_type.'_image_inline', 'border="0"',null,null,'.png',$mod_strings['LBL_LIST_VIEW_DOCUMENT'])."</a>"; |
263 | - } else { |
|
264 | - $file_url = "<a href='index.php?entryPoint=download&id={$this->document_revision_id}&type=Documents' target='_blank'>".SugarThemeRegistry::current()->getImage($img_name, 'border="0"', null,null,'.gif',$mod_strings['LBL_LIST_VIEW_DOCUMENT'])."</a>"; |
|
265 | - } |
|
263 | + } else { |
|
264 | + $file_url = "<a href='index.php?entryPoint=download&id={$this->document_revision_id}&type=Documents' target='_blank'>".SugarThemeRegistry::current()->getImage($img_name, 'border="0"', null,null,'.gif',$mod_strings['LBL_LIST_VIEW_DOCUMENT'])."</a>"; |
|
265 | + } |
|
266 | 266 | |
267 | - $this->file_url = $file_url; |
|
268 | - $this->file_url_noimage = "index.php?entryPoint=download&type=Documents&id={$this->document_revision_id}"; |
|
269 | - }else{ |
|
267 | + $this->file_url = $file_url; |
|
268 | + $this->file_url_noimage = "index.php?entryPoint=download&type=Documents&id={$this->document_revision_id}"; |
|
269 | + }else{ |
|
270 | 270 | $this->file_url = ""; |
271 | 271 | $this->file_url_noimage = ""; |
272 | - } |
|
272 | + } |
|
273 | 273 | |
274 | - //get last_rev_by user name. |
|
275 | - if (!empty ($row)) { |
|
276 | - $this->last_rev_created_name = $locale->getLocaleFormattedName($row['first_name'], $row['last_name']); |
|
274 | + //get last_rev_by user name. |
|
275 | + if (!empty ($row)) { |
|
276 | + $this->last_rev_created_name = $locale->getLocaleFormattedName($row['first_name'], $row['last_name']); |
|
277 | 277 | |
278 | - $this->last_rev_create_date = $timedate->to_display_date_time($this->db->fromConvert($row['rev_date'], 'datetime')); |
|
279 | - $this->last_rev_mime_type = $row['file_mime_type']; |
|
280 | - } |
|
278 | + $this->last_rev_create_date = $timedate->to_display_date_time($this->db->fromConvert($row['rev_date'], 'datetime')); |
|
279 | + $this->last_rev_mime_type = $row['file_mime_type']; |
|
280 | + } |
|
281 | 281 | |
282 | - global $app_list_strings; |
|
283 | - if(!empty($this->status_id)) { |
|
284 | - //_pp($this->status_id); |
|
285 | - $this->status = $app_list_strings['document_status_dom'][$this->status_id]; |
|
286 | - } |
|
282 | + global $app_list_strings; |
|
283 | + if(!empty($this->status_id)) { |
|
284 | + //_pp($this->status_id); |
|
285 | + $this->status = $app_list_strings['document_status_dom'][$this->status_id]; |
|
286 | + } |
|
287 | 287 | if (!empty($this->related_doc_id)) { |
288 | 288 | $this->related_doc_name = Document::get_document_name($this->related_doc_id); |
289 | 289 | $this->related_doc_rev_number = DocumentRevision::get_document_revision_name($this->related_doc_rev_id); |
290 | 290 | } |
291 | - } |
|
291 | + } |
|
292 | 292 | |
293 | - function list_view_parse_additional_sections(&$list_form/*, $xTemplateSection*/) { |
|
294 | - return $list_form; |
|
295 | - } |
|
293 | + function list_view_parse_additional_sections(&$list_form/*, $xTemplateSection*/) { |
|
294 | + return $list_form; |
|
295 | + } |
|
296 | 296 | |
297 | 297 | function create_export_query($order_by, $where, $relate_link_join='') |
298 | 298 | { |
299 | 299 | $custom_join = $this->getCustomJoin(true, true, $where); |
300 | 300 | $custom_join['join'] .= $relate_link_join; |
301 | - $query = "SELECT |
|
301 | + $query = "SELECT |
|
302 | 302 | documents.*"; |
303 | 303 | $query .= $custom_join['select']; |
304 | - $query .= " FROM documents "; |
|
304 | + $query .= " FROM documents "; |
|
305 | 305 | $query .= $custom_join['join']; |
306 | 306 | |
307 | - $where_auto = " documents.deleted = 0"; |
|
307 | + $where_auto = " documents.deleted = 0"; |
|
308 | 308 | |
309 | - if ($where != "") |
|
310 | - $query .= " WHERE $where AND ".$where_auto; |
|
311 | - else |
|
312 | - $query .= " WHERE ".$where_auto; |
|
309 | + if ($where != "") |
|
310 | + $query .= " WHERE $where AND ".$where_auto; |
|
311 | + else |
|
312 | + $query .= " WHERE ".$where_auto; |
|
313 | 313 | |
314 | - if ($order_by != "") |
|
315 | - $query .= " ORDER BY $order_by"; |
|
316 | - else |
|
317 | - $query .= " ORDER BY documents.document_name"; |
|
314 | + if ($order_by != "") |
|
315 | + $query .= " ORDER BY $order_by"; |
|
316 | + else |
|
317 | + $query .= " ORDER BY documents.document_name"; |
|
318 | 318 | |
319 | - return $query; |
|
320 | - } |
|
319 | + return $query; |
|
320 | + } |
|
321 | 321 | |
322 | - function get_list_view_data() { |
|
323 | - global $current_language; |
|
324 | - $app_list_strings = return_app_list_strings_language($current_language); |
|
322 | + function get_list_view_data() { |
|
323 | + global $current_language; |
|
324 | + $app_list_strings = return_app_list_strings_language($current_language); |
|
325 | 325 | |
326 | - $document_fields = $this->get_list_view_array(); |
|
326 | + $document_fields = $this->get_list_view_array(); |
|
327 | 327 | |
328 | 328 | $this->fill_in_additional_list_fields(); |
329 | 329 | |
330 | 330 | |
331 | - $document_fields['FILENAME'] = $this->filename; |
|
332 | - $document_fields['FILE_URL'] = $this->file_url; |
|
333 | - $document_fields['FILE_URL_NOIMAGE'] = $this->file_url_noimage; |
|
334 | - $document_fields['LAST_REV_CREATED_BY'] = $this->last_rev_created_name; |
|
335 | - $document_fields['CATEGORY_ID'] = empty ($this->category_id) ? "" : $app_list_strings['document_category_dom'][$this->category_id]; |
|
336 | - $document_fields['SUBCATEGORY_ID'] = empty ($this->subcategory_id) ? "" : $app_list_strings['document_subcategory_dom'][$this->subcategory_id]; |
|
331 | + $document_fields['FILENAME'] = $this->filename; |
|
332 | + $document_fields['FILE_URL'] = $this->file_url; |
|
333 | + $document_fields['FILE_URL_NOIMAGE'] = $this->file_url_noimage; |
|
334 | + $document_fields['LAST_REV_CREATED_BY'] = $this->last_rev_created_name; |
|
335 | + $document_fields['CATEGORY_ID'] = empty ($this->category_id) ? "" : $app_list_strings['document_category_dom'][$this->category_id]; |
|
336 | + $document_fields['SUBCATEGORY_ID'] = empty ($this->subcategory_id) ? "" : $app_list_strings['document_subcategory_dom'][$this->subcategory_id]; |
|
337 | 337 | $document_fields['NAME'] = $this->document_name; |
338 | - $document_fields['DOCUMENT_NAME_JAVASCRIPT'] = $GLOBALS['db']->quote($document_fields['DOCUMENT_NAME']); |
|
339 | - return $document_fields; |
|
340 | - } |
|
338 | + $document_fields['DOCUMENT_NAME_JAVASCRIPT'] = $GLOBALS['db']->quote($document_fields['DOCUMENT_NAME']); |
|
339 | + return $document_fields; |
|
340 | + } |
|
341 | 341 | |
342 | 342 | |
343 | 343 | /** |
@@ -348,45 +348,45 @@ discard block |
||
348 | 348 | * |
349 | 349 | * @param $id String The record id of the Document instance |
350 | 350 | */ |
351 | - function mark_relationships_deleted($id) |
|
351 | + function mark_relationships_deleted($id) |
|
352 | 352 | { |
353 | 353 | $this->load_relationships('revisions'); |
354 | - $revisions= $this->get_linked_beans('revisions','DocumentRevision'); |
|
355 | - |
|
356 | - if (!empty($revisions) && is_array($revisions)) { |
|
357 | - foreach($revisions as $key=>$version) { |
|
358 | - UploadFile::unlink_file($version->id,$version->filename); |
|
359 | - //mark the version deleted. |
|
360 | - $version->mark_deleted($version->id); |
|
361 | - } |
|
362 | - } |
|
363 | - |
|
364 | - } |
|
365 | - |
|
366 | - |
|
367 | - function bean_implements($interface) { |
|
368 | - switch ($interface) { |
|
369 | - case 'ACL' : |
|
370 | - return true; |
|
371 | - } |
|
372 | - return false; |
|
373 | - } |
|
374 | - |
|
375 | - //static function. |
|
376 | - function get_document_name($doc_id){ |
|
377 | - if (empty($doc_id)) return null; |
|
378 | - |
|
379 | - $db = DBManagerFactory::getInstance(); |
|
380 | - $query="select document_name from documents where id='$doc_id' and deleted=0"; |
|
381 | - $result=$db->query($query); |
|
382 | - if (!empty($result)) { |
|
383 | - $row=$db->fetchByAssoc($result); |
|
384 | - if (!empty($row)) { |
|
385 | - return $row['document_name']; |
|
386 | - } |
|
387 | - } |
|
388 | - return null; |
|
389 | - } |
|
354 | + $revisions= $this->get_linked_beans('revisions','DocumentRevision'); |
|
355 | + |
|
356 | + if (!empty($revisions) && is_array($revisions)) { |
|
357 | + foreach($revisions as $key=>$version) { |
|
358 | + UploadFile::unlink_file($version->id,$version->filename); |
|
359 | + //mark the version deleted. |
|
360 | + $version->mark_deleted($version->id); |
|
361 | + } |
|
362 | + } |
|
363 | + |
|
364 | + } |
|
365 | + |
|
366 | + |
|
367 | + function bean_implements($interface) { |
|
368 | + switch ($interface) { |
|
369 | + case 'ACL' : |
|
370 | + return true; |
|
371 | + } |
|
372 | + return false; |
|
373 | + } |
|
374 | + |
|
375 | + //static function. |
|
376 | + function get_document_name($doc_id){ |
|
377 | + if (empty($doc_id)) return null; |
|
378 | + |
|
379 | + $db = DBManagerFactory::getInstance(); |
|
380 | + $query="select document_name from documents where id='$doc_id' and deleted=0"; |
|
381 | + $result=$db->query($query); |
|
382 | + if (!empty($result)) { |
|
383 | + $row=$db->fetchByAssoc($result); |
|
384 | + if (!empty($row)) { |
|
385 | + return $row['document_name']; |
|
386 | + } |
|
387 | + } |
|
388 | + return null; |
|
389 | + } |
|
390 | 390 | } |
391 | 391 | |
392 | 392 | require_once('modules/Documents/DocumentExternalApiDropDown.php'); |
@@ -1,131 +1,131 @@ |
||
1 | 1 | <?php |
2 | 2 | $viewdefs ['Documents'] = |
3 | 3 | array ( |
4 | - 'EditView' => |
|
5 | - array ( |
|
4 | + 'EditView' => |
|
5 | + array ( |
|
6 | 6 | 'templateMeta' => |
7 | 7 | array ( |
8 | - 'form' => |
|
9 | - array ( |
|
8 | + 'form' => |
|
9 | + array ( |
|
10 | 10 | 'enctype' => 'multipart/form-data', |
11 | 11 | 'hidden' => |
12 | 12 | array ( |
13 | - 0 => '<input type="hidden" name="old_id" value="{$fields.document_revision_id.value}">', |
|
14 | - 1 => '<input type="hidden" name="contract_id" value="{$smarty.request.contract_id}">', |
|
13 | + 0 => '<input type="hidden" name="old_id" value="{$fields.document_revision_id.value}">', |
|
14 | + 1 => '<input type="hidden" name="contract_id" value="{$smarty.request.contract_id}">', |
|
15 | 15 | ), |
16 | - ), |
|
17 | - 'maxColumns' => '2', |
|
18 | - 'widths' => |
|
19 | - array ( |
|
16 | + ), |
|
17 | + 'maxColumns' => '2', |
|
18 | + 'widths' => |
|
19 | + array ( |
|
20 | 20 | 0 => |
21 | 21 | array ( |
22 | - 'label' => '10', |
|
23 | - 'field' => '30', |
|
22 | + 'label' => '10', |
|
23 | + 'field' => '30', |
|
24 | 24 | ), |
25 | 25 | 1 => |
26 | 26 | array ( |
27 | - 'label' => '10', |
|
28 | - 'field' => '30', |
|
27 | + 'label' => '10', |
|
28 | + 'field' => '30', |
|
29 | 29 | ), |
30 | - ), |
|
31 | - 'javascript' => '{sugar_getscript file="include/javascript/popup_parent_helper.js"} |
|
30 | + ), |
|
31 | + 'javascript' => '{sugar_getscript file="include/javascript/popup_parent_helper.js"} |
|
32 | 32 | {sugar_getscript file="cache/include/javascript/sugar_grp_jsolait.js"} |
33 | 33 | {sugar_getscript file="modules/Documents/documents.js"}', |
34 | - 'useTabs' => false, |
|
35 | - 'tabDefs' => |
|
36 | - array ( |
|
34 | + 'useTabs' => false, |
|
35 | + 'tabDefs' => |
|
36 | + array ( |
|
37 | 37 | 'LBL_DOCUMENT_INFORMATION' => |
38 | 38 | array ( |
39 | - 'newTab' => false, |
|
40 | - 'panelDefault' => 'expanded', |
|
39 | + 'newTab' => false, |
|
40 | + 'panelDefault' => 'expanded', |
|
41 | + ), |
|
41 | 42 | ), |
42 | - ), |
|
43 | 43 | ), |
44 | 44 | 'panels' => |
45 | 45 | array ( |
46 | - 'lbl_document_information' => |
|
47 | - array ( |
|
46 | + 'lbl_document_information' => |
|
47 | + array ( |
|
48 | 48 | 0 => |
49 | 49 | array ( |
50 | - 0 => |
|
51 | - array ( |
|
50 | + 0 => |
|
51 | + array ( |
|
52 | 52 | 'name' => 'filename', |
53 | 53 | 'displayParams' => |
54 | 54 | array ( |
55 | - 'onchangeSetFileNameTo' => 'document_name', |
|
55 | + 'onchangeSetFileNameTo' => 'document_name', |
|
56 | + ), |
|
56 | 57 | ), |
57 | - ), |
|
58 | - 1 => |
|
59 | - array ( |
|
58 | + 1 => |
|
59 | + array ( |
|
60 | 60 | 'name' => 'status_id', |
61 | 61 | 'label' => 'LBL_DOC_STATUS', |
62 | - ), |
|
62 | + ), |
|
63 | 63 | ), |
64 | 64 | 1 => |
65 | 65 | array ( |
66 | - 0 => 'document_name', |
|
67 | - 1 => |
|
68 | - array ( |
|
66 | + 0 => 'document_name', |
|
67 | + 1 => |
|
68 | + array ( |
|
69 | 69 | 'name' => 'revision', |
70 | 70 | 'customCode' => '<input name="revision" type="text" value="{$fields.revision.value}" {$DISABLED}>', |
71 | - ), |
|
71 | + ), |
|
72 | 72 | ), |
73 | 73 | 2 => |
74 | 74 | array ( |
75 | - 0 => |
|
76 | - array ( |
|
75 | + 0 => |
|
76 | + array ( |
|
77 | 77 | 'name' => 'template_type', |
78 | 78 | 'label' => 'LBL_DET_TEMPLATE_TYPE', |
79 | - ), |
|
80 | - 1 => |
|
81 | - array ( |
|
79 | + ), |
|
80 | + 1 => |
|
81 | + array ( |
|
82 | 82 | 'name' => 'is_template', |
83 | 83 | 'label' => 'LBL_DET_IS_TEMPLATE', |
84 | - ), |
|
84 | + ), |
|
85 | 85 | ), |
86 | 86 | 3 => |
87 | 87 | array ( |
88 | - 0 => |
|
89 | - array ( |
|
88 | + 0 => |
|
89 | + array ( |
|
90 | 90 | 'name' => 'active_date', |
91 | - ), |
|
92 | - 1 => 'exp_date', |
|
91 | + ), |
|
92 | + 1 => 'exp_date', |
|
93 | 93 | ), |
94 | 94 | 4 => |
95 | 95 | array ( |
96 | - 0 => 'category_id', |
|
97 | - 1 => 'subcategory_id', |
|
96 | + 0 => 'category_id', |
|
97 | + 1 => 'subcategory_id', |
|
98 | 98 | ), |
99 | 99 | 5 => |
100 | 100 | array ( |
101 | - 0 => |
|
102 | - array ( |
|
101 | + 0 => |
|
102 | + array ( |
|
103 | 103 | 'name' => 'description', |
104 | - ), |
|
104 | + ), |
|
105 | 105 | ), |
106 | 106 | 6 => |
107 | 107 | array ( |
108 | - 0 => |
|
109 | - array ( |
|
108 | + 0 => |
|
109 | + array ( |
|
110 | 110 | 'name' => 'related_doc_name', |
111 | 111 | 'customCode' => '<input name="related_document_name" type="text" size="30" maxlength="255" value="{$RELATED_DOCUMENT_NAME}" readonly><input name="related_doc_id" type="hidden" value="{$fields.related_doc_id.value}"/> <input title="{$APP.LBL_SELECT_BUTTON_TITLE}" type="{$RELATED_DOCUMENT_BUTTON_AVAILABILITY}" class="button" value="{$APP.LBL_SELECT_BUTTON_LABEL}" name="btn2" onclick=\'open_popup("Documents", 600, 400, "", true, false, {$encoded_document_popup_request_data}, "single", true);\'/>', |
112 | - ), |
|
113 | - 1 => |
|
114 | - array ( |
|
112 | + ), |
|
113 | + 1 => |
|
114 | + array ( |
|
115 | 115 | 'name' => 'related_doc_rev_number', |
116 | 116 | 'customCode' => '<select name="related_doc_rev_id" id="related_doc_rev_id" {$RELATED_DOCUMENT_REVISION_DISABLED}>{$RELATED_DOCUMENT_REVISION_OPTIONS}</select>', |
117 | - ), |
|
117 | + ), |
|
118 | 118 | ), |
119 | 119 | 7 => |
120 | 120 | array ( |
121 | - 0 => |
|
122 | - array ( |
|
121 | + 0 => |
|
122 | + array ( |
|
123 | 123 | 'name' => 'assigned_user_name', |
124 | 124 | 'label' => 'LBL_ASSIGNED_TO_NAME', |
125 | - ), |
|
125 | + ), |
|
126 | + ), |
|
126 | 127 | ), |
127 | - ), |
|
128 | 128 | ), |
129 | - ), |
|
129 | + ), |
|
130 | 130 | ); |
131 | 131 | ?> |
@@ -1,88 +1,88 @@ |
||
1 | 1 | <?php |
2 | 2 | $searchdefs ['Documents'] = |
3 | 3 | array ( |
4 | - 'layout' => |
|
5 | - array ( |
|
4 | + 'layout' => |
|
5 | + array ( |
|
6 | 6 | 'basic_search' => |
7 | 7 | array ( |
8 | - 0 => 'document_name', |
|
9 | - 1 => array ('name' => 'favorites_only','label' => 'LBL_FAVORITES_FILTER','type' => 'bool',), |
|
8 | + 0 => 'document_name', |
|
9 | + 1 => array ('name' => 'favorites_only','label' => 'LBL_FAVORITES_FILTER','type' => 'bool',), |
|
10 | 10 | ), |
11 | 11 | 'advanced_search' => |
12 | 12 | array ( |
13 | - 'document_name' => |
|
14 | - array ( |
|
13 | + 'document_name' => |
|
14 | + array ( |
|
15 | 15 | 'name' => 'document_name', |
16 | 16 | 'default' => true, |
17 | 17 | 'width' => '10%', |
18 | - ), |
|
19 | - 'status' => |
|
20 | - array ( |
|
18 | + ), |
|
19 | + 'status' => |
|
20 | + array ( |
|
21 | 21 | 'type' => 'varchar', |
22 | 22 | 'label' => 'LBL_DOC_STATUS', |
23 | 23 | 'width' => '10%', |
24 | 24 | 'default' => true, |
25 | 25 | 'name' => 'status', |
26 | - ), |
|
27 | - 'template_type' => |
|
28 | - array ( |
|
26 | + ), |
|
27 | + 'template_type' => |
|
28 | + array ( |
|
29 | 29 | 'type' => 'enum', |
30 | 30 | 'label' => 'LBL_TEMPLATE_TYPE', |
31 | 31 | 'width' => '10%', |
32 | 32 | 'default' => true, |
33 | 33 | 'name' => 'template_type', |
34 | - ), |
|
35 | - 'category_id' => |
|
36 | - array ( |
|
34 | + ), |
|
35 | + 'category_id' => |
|
36 | + array ( |
|
37 | 37 | 'name' => 'category_id', |
38 | 38 | 'default' => true, |
39 | 39 | 'width' => '10%', |
40 | - ), |
|
41 | - 'subcategory_id' => |
|
42 | - array ( |
|
40 | + ), |
|
41 | + 'subcategory_id' => |
|
42 | + array ( |
|
43 | 43 | 'name' => 'subcategory_id', |
44 | 44 | 'default' => true, |
45 | 45 | 'width' => '10%', |
46 | - ), |
|
47 | - 'assigned_user_id' => |
|
48 | - array ( |
|
46 | + ), |
|
47 | + 'assigned_user_id' => |
|
48 | + array ( |
|
49 | 49 | 'name' => 'assigned_user_id', |
50 | 50 | 'type' => 'enum', |
51 | 51 | 'label' => 'LBL_ASSIGNED_TO', |
52 | 52 | 'function' => |
53 | 53 | array ( |
54 | - 'name' => 'get_user_array', |
|
55 | - 'params' => |
|
56 | - array ( |
|
54 | + 'name' => 'get_user_array', |
|
55 | + 'params' => |
|
56 | + array ( |
|
57 | 57 | 0 => false, |
58 | - ), |
|
58 | + ), |
|
59 | 59 | ), |
60 | 60 | 'default' => true, |
61 | 61 | 'width' => '10%', |
62 | - ), |
|
63 | - 'active_date' => |
|
64 | - array ( |
|
62 | + ), |
|
63 | + 'active_date' => |
|
64 | + array ( |
|
65 | 65 | 'name' => 'active_date', |
66 | 66 | 'default' => true, |
67 | 67 | 'width' => '10%', |
68 | - ), |
|
69 | - 'exp_date' => |
|
70 | - array ( |
|
68 | + ), |
|
69 | + 'exp_date' => |
|
70 | + array ( |
|
71 | 71 | 'name' => 'exp_date', |
72 | 72 | 'default' => true, |
73 | 73 | 'width' => '10%', |
74 | - ), |
|
74 | + ), |
|
75 | + ), |
|
75 | 76 | ), |
76 | - ), |
|
77 | - 'templateMeta' => |
|
78 | - array ( |
|
77 | + 'templateMeta' => |
|
78 | + array ( |
|
79 | 79 | 'maxColumns' => '3', |
80 | 80 | 'maxColumnsBasic' => '4', |
81 | 81 | 'widths' => |
82 | 82 | array ( |
83 | - 'label' => '10', |
|
84 | - 'field' => '30', |
|
83 | + 'label' => '10', |
|
84 | + 'field' => '30', |
|
85 | + ), |
|
85 | 86 | ), |
86 | - ), |
|
87 | 87 | ); |
88 | 88 | ?> |
@@ -3,36 +3,36 @@ discard block |
||
3 | 3 | global $current_user; |
4 | 4 | $module_name = "Documents"; |
5 | 5 | $searchFields['Documents'] = array ( |
6 | - 'document_name' => |
|
7 | - array ( |
|
6 | + 'document_name' => |
|
7 | + array ( |
|
8 | 8 | 'query_type' => 'default', |
9 | - ), |
|
10 | - 'category_id' => |
|
11 | - array ( |
|
9 | + ), |
|
10 | + 'category_id' => |
|
11 | + array ( |
|
12 | 12 | 'query_type' => 'default', |
13 | 13 | 'options' => 'document_category_dom', |
14 | 14 | 'template_var' => 'CATEGORY_OPTIONS', |
15 | - ), |
|
16 | - 'subcategory_id' => |
|
17 | - array ( |
|
15 | + ), |
|
16 | + 'subcategory_id' => |
|
17 | + array ( |
|
18 | 18 | 'query_type' => 'default', |
19 | 19 | 'options' => 'document_subcategory_dom', |
20 | 20 | 'template_var' => 'SUBCATEGORY_OPTIONS', |
21 | - ), |
|
22 | - 'active_date' => |
|
23 | - array ( |
|
21 | + ), |
|
22 | + 'active_date' => |
|
23 | + array ( |
|
24 | 24 | 'query_type' => 'default', |
25 | - ), |
|
26 | - 'exp_date' => |
|
27 | - array ( |
|
25 | + ), |
|
26 | + 'exp_date' => |
|
27 | + array ( |
|
28 | 28 | 'query_type' => 'default', |
29 | - ), |
|
30 | - 'assigned_user_id' => |
|
31 | - array ( |
|
29 | + ), |
|
30 | + 'assigned_user_id' => |
|
31 | + array ( |
|
32 | 32 | 'query_type' => 'default', |
33 | - ), |
|
34 | - 'filename' => |
|
35 | - array ( |
|
33 | + ), |
|
34 | + 'filename' => |
|
35 | + array ( |
|
36 | 36 | 'query_type' => 'format', |
37 | 37 | 'operator' => 'subquery', |
38 | 38 | 'subquery' => 'SELECT document_revisions.id FROM document_revisions |
@@ -40,45 +40,45 @@ discard block |
||
40 | 40 | AND document_revisions.filename LIKE \'{0}\'', |
41 | 41 | 'db_field' => |
42 | 42 | array ( |
43 | - 0 => 'document_revision_id', |
|
43 | + 0 => 'document_revision_id', |
|
44 | 44 | ), |
45 | - ), |
|
46 | - 'range_date_entered' => |
|
47 | - array ( |
|
45 | + ), |
|
46 | + 'range_date_entered' => |
|
47 | + array ( |
|
48 | 48 | 'query_type' => 'default', |
49 | 49 | 'enable_range_search' => true, |
50 | 50 | 'is_date_field' => true, |
51 | - ), |
|
52 | - 'start_range_date_entered' => |
|
53 | - array ( |
|
51 | + ), |
|
52 | + 'start_range_date_entered' => |
|
53 | + array ( |
|
54 | 54 | 'query_type' => 'default', |
55 | 55 | 'enable_range_search' => true, |
56 | 56 | 'is_date_field' => true, |
57 | - ), |
|
58 | - 'end_range_date_entered' => |
|
59 | - array ( |
|
57 | + ), |
|
58 | + 'end_range_date_entered' => |
|
59 | + array ( |
|
60 | 60 | 'query_type' => 'default', |
61 | 61 | 'enable_range_search' => true, |
62 | 62 | 'is_date_field' => true, |
63 | - ), |
|
64 | - 'range_date_modified' => |
|
65 | - array ( |
|
63 | + ), |
|
64 | + 'range_date_modified' => |
|
65 | + array ( |
|
66 | 66 | 'query_type' => 'default', |
67 | 67 | 'enable_range_search' => true, |
68 | 68 | 'is_date_field' => true, |
69 | - ), |
|
70 | - 'start_range_date_modified' => |
|
71 | - array ( |
|
69 | + ), |
|
70 | + 'start_range_date_modified' => |
|
71 | + array ( |
|
72 | 72 | 'query_type' => 'default', |
73 | 73 | 'enable_range_search' => true, |
74 | 74 | 'is_date_field' => true, |
75 | - ), |
|
76 | - 'end_range_date_modified' => |
|
77 | - array ( |
|
75 | + ), |
|
76 | + 'end_range_date_modified' => |
|
77 | + array ( |
|
78 | 78 | 'query_type' => 'default', |
79 | 79 | 'enable_range_search' => true, |
80 | 80 | 'is_date_field' => true, |
81 | - ), |
|
81 | + ), |
|
82 | 82 | 'favorites_only' => array( |
83 | 83 | 'query_type'=>'format', |
84 | 84 | 'operator' => 'subquery', |