]> CyberLeo.Net >> Repos - Github/sugarcrm.git/blob - modules/Calls/CallFormBase.php
Release 6.4.4
[Github/sugarcrm.git] / modules / Calls / CallFormBase.php
1 <?php
2 if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
3 /*********************************************************************************
4  * SugarCRM Community Edition is a customer relationship management program developed by
5  * SugarCRM, Inc. Copyright (C) 2004-2012 SugarCRM Inc.
6  * 
7  * This program is free software; you can redistribute it and/or modify it under
8  * the terms of the GNU Affero General Public License version 3 as published by the
9  * Free Software Foundation with the addition of the following permission added
10  * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
11  * IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
12  * OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
13  * 
14  * This program is distributed in the hope that it will be useful, but WITHOUT
15  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16  * FOR A PARTICULAR PURPOSE.  See the GNU Affero General Public License for more
17  * details.
18  * 
19  * You should have received a copy of the GNU Affero General Public License along with
20  * this program; if not, see http://www.gnu.org/licenses or write to the Free
21  * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
22  * 02110-1301 USA.
23  * 
24  * You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
25  * SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
26  * 
27  * The interactive user interfaces in modified source and object code versions
28  * of this program must display Appropriate Legal Notices, as required under
29  * Section 5 of the GNU Affero General Public License version 3.
30  * 
31  * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
32  * these Appropriate Legal Notices must retain the display of the "Powered by
33  * SugarCRM" logo. If the display of the logo is not reasonably feasible for
34  * technical reasons, the Appropriate Legal Notices must display the words
35  * "Powered by SugarCRM".
36  ********************************************************************************/
37
38 /*********************************************************************************
39
40  * Description: Call Form Base
41  * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
42  * All Rights Reserved.
43  * Contributor(s): ______________________________________..
44  ********************************************************************************/
45
46 require_once('include/SugarObjects/forms/FormBase.php');
47
48 class CallFormBase extends FormBase {
49
50 function getFormBody($prefix, $mod='', $formname='',$cal_date='',$cal_time=''){
51 if(!ACLController::checkAccess('Calls', 'edit', true)){
52                 return '';
53         }
54 global $mod_strings;
55 $temp_strings = $mod_strings;
56 if(!empty($mod)){
57         global $current_language;
58         $mod_strings = return_module_language($current_language, $mod);
59 }
60 global $app_strings;
61 global $app_list_strings;
62 global $current_user;
63 global $theme;
64
65
66 $lbl_subject = $mod_strings['LBL_SUBJECT'];
67 // Unimplemented until jscalendar language files are fixed
68 // global $current_language;
69 // global $default_language;
70 // global $cal_codes;
71 // Unimplemented until jscalendar language files are fixed
72 // $cal_lang = (empty($cal_codes[$current_language])) ? $cal_codes[$default_language] : $cal_codes[$current_language];
73
74 global $timedate;
75 $cal_lang = "en";
76 $cal_dateformat = $timedate->get_cal_date_format();
77
78 $lbl_required_symbol = $app_strings['LBL_REQUIRED_SYMBOL'];
79 $lbl_date = $mod_strings['LBL_DATE'];
80 $lbl_time = $mod_strings['LBL_TIME'];
81 $ntc_date_format = $timedate->get_user_date_format();
82 $ntc_time_format = '('.$timedate->get_user_time_format().')';
83
84         $user_id = $current_user->id;
85 $default_status = $app_list_strings['call_status_default'];
86 $default_parent_type= $app_list_strings['record_type_default_key'];
87 $date = TimeDate::getInstance()->nowDb();
88 $default_date_start = $timedate->to_display_date($date,false);
89 $default_time_start = $timedate->to_display_time($date);
90 $time_ampm = $timedate->AMPMMenu($prefix,$default_time_start);
91 $lbl_save_button_title = $app_strings['LBL_SAVE_BUTTON_TITLE'];
92 $lbl_save_button_key = $app_strings['LBL_SAVE_BUTTON_KEY'];
93 $lbl_save_button_label = $app_strings['LBL_SAVE_BUTTON_LABEL'];
94         $form = <<<EOQ
95                         <form name="${formname}" onSubmit="return check_form('${formname}') "method="POST" action="index.php">
96                         <input type="hidden" name="${prefix}module" value="Calls">
97                         <input type="hidden" name="${prefix}action" value="Save">
98                                 <input type="hidden" name="${prefix}record" value="">
99                         <input type="hidden"  name="${prefix}direction" value="Outbound">
100                         <input type="hidden" name="${prefix}status" value="${default_status}">
101                         <input type="hidden" name="${prefix}parent_type" value="${default_parent_type}">
102                         <input type="hidden" name="${prefix}assigned_user_id" value='${user_id}'>
103                         <input type="hidden" name="${prefix}duration_hours" value="1">
104                         <input type="hidden" name="${prefix}duration_minutes" value="0">
105                         <input type="hidden" name="${prefix}user_id" value="${user_id}">
106
107                 <table cellspacing="1" cellpadding="0" border="0">
108 <tr>
109     <td colspan="2"><input type='radio' name='appointment' value='Call' class='radio' onchange='document.${formname}.module.value="Calls";' style='vertical-align: middle;' checked> <span scope="row">${mod_strings['LNK_NEW_CALL']}</span>
110 &nbsp;
111 &nbsp;
112 <input type='radio' name='appointment' value='Meeting' class='radio' onchange='document.${formname}.module.value="Meetings";'><span scope="row">${mod_strings['LNK_NEW_MEETING']}</span></td>
113 </tr>
114 <tr>
115     <td colspan="2"><span scope="row">$lbl_subject</span>&nbsp;<span class="required">$lbl_required_symbol</span></td>
116 </tr>
117 <tr><td valign=top><input name='${prefix}name' size='30' maxlength='255' type="text"></td>
118     <td><input name='${prefix}date_start' id='${formname}jscal_field' maxlength='10' type="hidden" value="${cal_date}"></td>
119     <td><input name='${prefix}time_start' type="hidden" maxlength='10' value="{$cal_time}"></td>
120
121                         <script type="text/javascript">
122 //              Calendar.setup ({
123 //                      inputField : "${formname}jscal_field", daFormat : "$cal_dateformat" ifFormat : "$cal_dateformat", showsTime : false, button : "${formname}jscal_trigger", singleClick : true, step : 1, weekNumbers:false
124 //              });
125                 </script>
126
127
128
129 EOQ;
130
131
132
133 $javascript = new javascript();
134 $javascript->setFormName($formname);
135 $javascript->setSugarBean(new Call());
136 $javascript->addRequiredFields($prefix);
137 $form .=$javascript->getScript();
138 $form .= "<td align=\"left\" valign=top><input title='$lbl_save_button_title' accessKey='$lbl_save_button_key' class='button' type='submit' name='button' value=' $lbl_save_button_label ' ></td></tr></table></form>";
139 $mod_strings = $temp_strings;
140 return $form;
141
142 }
143 function getFormHeader($prefix, $mod='', $title=''){
144         if(!ACLController::checkAccess('Calls', 'edit', true)){
145                 return '';
146         }
147         if(!empty($mod)){
148         global $current_language;
149         $mod_strings = return_module_language($current_language, $mod);
150 }else global $mod_strings;
151
152
153
154
155
156
157 if(!empty($title)){
158         $the_form = get_left_form_header($title);
159 }else{
160         $the_form = get_left_form_header($mod_strings['LBL_NEW_FORM_TITLE']);
161 }
162 $the_form .= <<<EOQ
163                 <form name="${prefix}CallSave" onSubmit="return check_form('${prefix}CallSave') "method="POST" action="index.php">
164                         <input type="hidden" name="${prefix}module" value="Calls">
165                         <input type="hidden" name="${prefix}action" value="Save">
166
167 EOQ;
168 return $the_form;
169 }
170 function getFormFooter($prefic, $mod=''){
171         if(!ACLController::checkAccess('Calls', 'edit', true)){
172                 return '';
173         }
174 global $app_strings;
175 global $app_list_strings;
176 $lbl_save_button_title = $app_strings['LBL_SAVE_BUTTON_TITLE'];
177 $lbl_save_button_label = $app_strings['LBL_SAVE_BUTTON_LABEL'];
178 $the_form = "   <p><input title='$lbl_save_button_title' class='button' type='submit' name='button' value=' $lbl_save_button_label ' ></p></form>";
179 $the_form .= get_left_form_footer();
180 $the_form .= get_validate_record_js();
181 return $the_form;
182 }
183
184 function getForm($prefix, $mod=''){
185         if(!ACLController::checkAccess('Calls', 'edit', true)){
186                 return '';
187         }
188 $the_form = $this->getFormHeader($prefix, $mod);
189 $the_form .= $this->getFormBody($prefix, $mod, "${prefix}CallSave");
190 $the_form .= $this->getFormFooter($prefix, $mod);
191
192 return $the_form;
193 }
194
195
196 function handleSave($prefix,$redirect=true,$useRequired=false) {
197
198
199         require_once('include/formbase.php');
200
201         global $current_user;
202         global $timedate;
203
204         //BUG 17418 MFH
205         if (isset($_POST[$prefix.'duration_hours'])){
206                 $_POST[$prefix.'duration_hours'] = trim($_POST[$prefix.'duration_hours']);
207         }
208
209         $focus = new Call();
210
211         if($useRequired && !checkRequired($prefix, array_keys($focus->required_fields))) {
212                 return null;
213         }
214     if ( !isset($_POST[$prefix.'reminder_checked']) or ($_POST[$prefix.'reminder_checked'] == 0)) {
215         $GLOBALS['log']->debug(__FILE__.'('.__LINE__.'): No reminder checked, resetting the reminder_time');
216         $_POST[$prefix.'reminder_time'] = -1;
217     }
218
219         if(!isset($_POST[$prefix.'reminder_time'])) {
220         $GLOBALS['log']->debug(__FILE__.'('.__LINE__.'): Getting the users default reminder time');
221                 $_POST[$prefix.'reminder_time'] = $current_user->getPreference('reminder_time');
222         }
223
224         $time_format = $timedate->get_user_time_format();
225     $time_separator = ":";
226     if(preg_match('/\d+([^\d])\d+([^\d]*)/s', $time_format, $match)) {
227        $time_separator = $match[1];
228     }
229
230         if(!empty($_POST[$prefix.'time_hour_start']) && empty($_POST[$prefix.'time_start'])) {
231                 $_POST[$prefix.'time_start'] = $_POST[$prefix.'time_hour_start']. $time_separator .$_POST[$prefix.'time_minute_start'];
232         }
233
234         if(isset($_POST[$prefix.'meridiem']) && !empty($_POST[$prefix.'meridiem'])) {
235                 $_POST[$prefix.'time_start'] = $timedate->merge_time_meridiem($_POST[$prefix.'time_start'],$timedate->get_time_format(), $_POST[$prefix.'meridiem']);
236         }
237
238         if(isset($_POST[$prefix.'time_start']) && strlen($_POST[$prefix.'date_start']) == 10) {
239            $_POST[$prefix.'date_start'] = $_POST[$prefix.'date_start'] . ' ' . $_POST[$prefix.'time_start'];
240         }
241
242         // retrieve happens here
243         $focus = populateFromPost($prefix, $focus);
244         if(!$focus->ACLAccess('Save')) {
245            ACLController::displayNoAccess(true);
246            sugar_cleanup(true);
247         }
248
249         //add assigned user and current user if this is the first time bean is saved
250         if(empty($focus->id) && !empty($_REQUEST['return_module']) && $_REQUEST['return_module'] =='Calls' && !empty($_REQUEST['return_action']) && $_REQUEST['return_action'] =='DetailView'){
251                 //if return action is set to detail view and return module to call, then this is from the long form, do not add the assigned user (only the current user)
252                 //The current user is already added to UI and we want to give the current user the option of opting out of meeting.
253                 if($current_user->id != $_POST['assigned_user_id']){
254                         $_POST['user_invitees'] .= ','.$_POST['assigned_user_id'].', ';
255                         $_POST['user_invitees'] = str_replace(',,', ',', $_POST['user_invitees']);
256                 }
257         }elseif (empty($focus->id) ){
258                 //this is not from long form so add assigned and current user automatically as there is no invitee list UI.
259                 //This call could be through an ajax call from subpanels or shortcut bar
260                 $_POST['user_invitees'] .= ','.$_POST['assigned_user_id'].', ';
261
262                 //add current user if the assigned to user is different than current user.
263                 if($current_user->id != $_POST['assigned_user_id']){
264                         $_POST['user_invitees'] .= ','.$current_user->id.', ';
265                 }
266
267                 //remove any double comma's introduced during appending
268             $_POST['user_invitees'] = str_replace(',,', ',', $_POST['user_invitees']);
269         }
270
271     if( (isset($_POST['isSaveFromDetailView']) && $_POST['isSaveFromDetailView'] == 'true') ||
272         (isset($_POST['is_ajax_call']) && !empty($_POST['is_ajax_call']) && !empty($focus->id))
273     ){
274         $focus->save(true);
275         $return_id = $focus->id;
276     }else{
277
278         if($focus->status == 'Held' && $this->isEmptyReturnModuleAndAction() && !$this->isSaveFromDCMenu()){
279                 //if we are closing the meeting, and the request does not have a return module AND return action set and it is not a save
280             //being triggered by the DCMenu (shortcut bar) then the request is coming from a dashlet or subpanel close icon and there is no
281             //need to process user invitees, just save the current values.
282                 $focus->save(true);
283             }else{
284                 ///////////////////////////////////////////////////////////////////////////
285                 ////    REMOVE INVITEE RELATIONSHIPS
286                 if(!empty($_POST['user_invitees'])) {
287                    $userInvitees = explode(',', trim($_POST['user_invitees'], ','));
288                 } else {
289                    $userInvitees = array();
290                 }
291
292                 // Calculate which users to flag as deleted and which to add
293                 $deleteUsers = array();
294                 $focus->load_relationship('users');
295                 // Get all users for the call
296                 $q = 'SELECT mu.user_id, mu.accept_status FROM calls_users mu WHERE mu.call_id = \''.$focus->id.'\'';
297                 $r = $focus->db->query($q);
298                 $acceptStatusUsers = array();
299                 while($a = $focus->db->fetchByAssoc($r)) {
300                           if(!in_array($a['user_id'], $userInvitees)) {
301                                  $deleteUsers[$a['user_id']] = $a['user_id'];
302                           } else {
303                              $acceptStatusUsers[$a['user_id']] = $a['accept_status'];
304                           }
305                 }
306
307                 if(count($deleteUsers) > 0) {
308                         $sql = '';
309                         foreach($deleteUsers as $u) {
310                         $sql .= ",'" . $u . "'";
311                         }
312
313                         $sql = substr($sql, 1);
314                         // We could run a delete SQL statement here, but will just mark as deleted instead
315                         $sql = "UPDATE calls_users set deleted = 1 where user_id in ($sql) AND call_id = '". $focus->id . "'";
316                         $focus->db->query($sql);
317                 }
318
319                 // Get all contacts for the call
320                 if(!empty($_POST['contact_invitees'])) {
321                    $contactInvitees = explode(',', trim($_POST['contact_invitees'], ','));
322                 } else {
323                    $contactInvitees = array();
324                 }
325
326                 $deleteContacts = array();
327                 $focus->load_relationship('contacts');
328                 $q = 'SELECT mu.contact_id, mu.accept_status FROM calls_contacts mu WHERE mu.call_id = \''.$focus->id.'\'';
329                 $r = $focus->db->query($q);
330                 $acceptStatusContacts = array();
331                 while($a = $focus->db->fetchByAssoc($r)) {
332                           if(!in_array($a['contact_id'], $contactInvitees)) {
333                                  $deleteContacts[$a['contact_id']] = $a['contact_id'];
334                           }     else {
335                                  $acceptStatusContacts[$a['contact_id']] = $a['accept_status'];
336                           }
337                 }
338
339                 if(count($deleteContacts) > 0) {
340                         $sql = '';
341                         foreach($deleteContacts as $u) {
342                                 $sql .= ",'" . $u . "'";
343                         }
344                         $sql = substr($sql, 1);
345                         // We could run a delete SQL statement here, but will just mark as deleted instead
346                         $sql = "UPDATE calls_contacts set deleted = 1 where contact_id in ($sql) AND call_id = '". $focus->id . "'";
347                         $focus->db->query($sql);
348                 }
349                 if(!empty($_POST['lead_invitees'])) {
350                    $leadInvitees = explode(',', trim($_POST['lead_invitees'], ','));
351                 } else {
352                    $leadInvitees = array();
353                 }
354
355                 // Calculate which leads to flag as deleted and which to add
356                 $deleteLeads = array();
357                 $focus->load_relationship('leads');
358                 // Get all leads for the call
359                 $q = 'SELECT mu.lead_id, mu.accept_status FROM calls_leads mu WHERE mu.call_id = \''.$focus->id.'\'';
360                 $r = $focus->db->query($q);
361                 $acceptStatusLeads = array();
362                 while($a = $focus->db->fetchByAssoc($r)) {
363                           if(!in_array($a['lead_id'], $leadInvitees)) {
364                                  $deleteLeads[$a['lead_id']] = $a['lead_id'];
365                           } else {
366                              $acceptStatusLeads[$a['user_id']] = $a['accept_status'];
367                           }
368                 }
369
370                 if(count($deleteLeads) > 0) {
371                         $sql = '';
372                         foreach($deleteLeads as $u) {
373                         // make sure we don't delete the assigned user
374                         if ( $u != $focus->assigned_user_id )
375                                 $sql .= ",'" . $u . "'";
376                         }
377                         $sql = substr($sql, 1);
378                         // We could run a delete SQL statement here, but will just mark as deleted instead
379                         $sql = "UPDATE calls_leads set deleted = 1 where lead_id in ($sql) AND call_id = '". $focus->id . "'";
380                         $focus->db->query($sql);
381                 }
382                 ////    END REMOVE
383                 ///////////////////////////////////////////////////////////////////////////
384
385
386                 ///////////////////////////////////////////////////////////////////////////
387                 ////    REBUILD INVITEE RELATIONSHIPS
388                 $focus->users_arr = array();
389                 $focus->users_arr = $userInvitees;
390                 $focus->contacts_arr = array();
391                 $focus->contacts_arr = $contactInvitees;
392                 $focus->leads_arr = array();
393                 $focus->leads_arr = $leadInvitees;
394                 if(!empty($_POST['parent_id']) && $_POST['parent_type'] == 'Contacts') {
395                         $focus->contacts_arr[] = $_POST['parent_id'];
396                 }
397                 if(!empty($_POST['parent_id']) && $_POST['parent_type'] == 'Leads') {
398                         $focus->leads_arr[] = $_POST['parent_id'];
399                 }
400                 // Call the Call module's save function to handle saving other fields besides
401                 // the users and contacts relationships
402             $focus->update_vcal = false;    // Bug #49195 : don't update vcal b/s related users aren't saved yet, create vcal cache below
403                 $focus->save(true);
404                 $return_id = $focus->id;
405
406                 // Process users
407                 $existing_users = array();
408                 if(!empty($_POST['existing_invitees'])) {
409                    $existing_users =  explode(",", trim($_POST['existing_invitees'], ','));
410                 }
411
412                 foreach($focus->users_arr as $user_id) {
413                     if(empty($user_id) || isset($existing_users[$user_id]) || isset($deleteUsers[$user_id])) {
414                                 continue;
415                         }
416
417                         if(!isset($acceptStatusUsers[$user_id])) {
418                                 $focus->load_relationship('users');
419                                 $focus->users->add($user_id);
420                         } else {
421                                 // update query to preserve accept_status
422                                 $qU  = 'UPDATE calls_users SET deleted = 0, accept_status = \''.$acceptStatusUsers[$user_id].'\' ';
423                                 $qU .= 'WHERE call_id = \''.$focus->id.'\' ';
424                                 $qU .= 'AND user_id = \''.$user_id.'\'';
425                                 $focus->db->query($qU);
426                         }
427                 }
428
429                 // Process contacts
430                 $existing_contacts =  array();
431                 if(!empty($_POST['existing_contact_invitees'])) {
432                    $existing_contacts =  explode(",", trim($_POST['existing_contact_invitees'], ','));
433                 }
434
435                 foreach($focus->contacts_arr as $contact_id) {
436                         if(empty($contact_id) || isset($existing_contacts[$contact_id]) || (isset($deleteContacts[$contact_id]) && $contact_id !=  $_POST['parent_id'])) {
437                                 continue;
438                         }
439
440                         if(!isset($acceptStatusContacts[$contact_id])) {
441                                 $focus->load_relationship('contacts');
442                             $focus->contacts->add($contact_id);
443                         } else {
444                                 // update query to preserve accept_status
445                                 $qU  = 'UPDATE calls_contacts SET deleted = 0, accept_status = \''.$acceptStatusContacts[$contact_id].'\' ';
446                                 $qU .= 'WHERE call_id = \''.$focus->id.'\' ';
447                                 $qU .= 'AND contact_id = \''.$contact_id.'\'';
448                                 $focus->db->query($qU);
449                         }
450                 }
451                 // Process leads
452                 $existing_leads =  array();
453                 if(!empty($_POST['existing_lead_invitees'])) {
454                    $existing_leads =  explode(",", trim($_POST['existing_lead_invitees'], ','));
455                 }
456
457                 foreach($focus->leads_arr as $lead_id) {
458                         if(empty($lead_id) || isset($existing_leads[$lead_id]) || (isset($deleteLeads[$lead_id]) && $lead_id !=  $_POST['parent_id'])) {
459                                 continue;
460                         }
461
462                         if(!isset($acceptStatusLeads[$lead_id])) {
463                                 $focus->load_relationship('leads');
464                             $focus->leads->add($lead_id);
465                         } else {
466                                 // update query to preserve accept_status
467                                 $qU  = 'UPDATE calls_leads SET deleted = 0, accept_status = \''.$acceptStatusLeads[$lead_id].'\' ';
468                                 $qU .= 'WHERE call_id = \''.$focus->id.'\' ';
469                                 $qU .= 'AND lead_id = \''.$lead_id.'\'';
470                                 $focus->db->query($qU);
471                         }
472                 }
473
474             // Bug #49195 : update vcal
475             vCal::cache_sugar_vcal($current_user);
476             
477                 // CCL - Comment out call to set $current_user as invitee
478                 //set organizer to auto-accept
479                 //$focus->set_accept_status($current_user, 'accept');
480
481                 ////    END REBUILD INVITEE RELATIONSHIPS
482                 ///////////////////////////////////////////////////////////////////////////
483             }
484     }
485         if (isset($_REQUEST['return_module']) && $_REQUEST['return_module'] == 'Home'){
486                 $_REQUEST['return_action'] = 'index';
487         handleRedirect('', 'Home');
488         }
489         else if($redirect) {
490                 handleRedirect($return_id, 'Calls');
491         } else {
492                 return $focus;
493         }
494
495 } // end handleSave();
496
497 function getWideFormBody ($prefix, $mod='', $formname='', $wide =true){
498         if(!ACLController::checkAccess('Calls', 'edit', true)){
499                 return '';
500         }
501 global $mod_strings;
502 $temp_strings = $mod_strings;
503 if(!empty($mod)){
504         global $current_language;
505         $mod_strings = return_module_language($current_language, $mod);
506 }
507 global $app_strings;
508 global $app_list_strings;
509 global $current_user;
510 global $theme;
511
512 $lbl_subject = $mod_strings['LBL_SUBJECT'];
513 // Unimplemented until jscalendar language files are fixed
514 // global $current_language;
515 // global $default_language;
516 // global $cal_codes;
517 // Unimplemented until jscalendar language files are fixed
518 // $cal_lang = (empty($cal_codes[$current_language])) ? $cal_codes[$default_language] : $cal_codes[$current_language];
519 $cal_lang = "en";
520
521
522 $lbl_required_symbol = $app_strings['LBL_REQUIRED_SYMBOL'];
523         $lbl_date = $mod_strings['LBL_DATE'];
524 $lbl_time = $mod_strings['LBL_TIME'];
525 global $timedate;
526 $ntc_date_format = '('.$timedate->get_user_date_format(). ')';
527 $ntc_time_format = '('.$timedate->get_user_time_format(). ')';
528 $cal_dateformat = $timedate->get_cal_date_format();
529
530         $user_id = $current_user->id;
531 $default_status = $app_list_strings['call_status_default'];
532 $default_parent_type= $app_list_strings['record_type_default_key'];
533 $date = TimeDate::getInstance()->nowDb();
534 $default_date_start = $timedate->to_display_date($date);
535 $default_time_start = $timedate->to_display_time($date,true);
536 $time_ampm = $timedate->AMPMMenu($prefix,$default_time_start);
537         $form = <<<EOQ
538                         <input type="hidden"  name="${prefix}direction" value="Outbound">
539                         <input type="hidden" name="${prefix}record" value="">
540                         <input type="hidden" name="${prefix}status" value="${default_status}">
541                         <input type="hidden" name="${prefix}parent_type" value="${default_parent_type}">
542                         <input type="hidden" name="${prefix}assigned_user_id" value='${user_id}'>
543                         <input type="hidden" name="${prefix}duration_hours" value="1">
544                         <input type="hidden" name="${prefix}duration_minutes" value="0">
545                         <input type="hidden" name="${prefix}user_id" value="${user_id}">
546
547                 <table cellspacing='0' cellpadding='0' border='0' width="100%">
548 <tr>
549 EOQ;
550
551 if($wide){
552 $form .= <<<EOQ
553 <td scope='row' width="20%"><input type='radio' name='appointment' value='Call' class='radio' checked> ${mod_strings['LNK_NEW_CALL']}</td>
554 <td scope='row' width="80%">${mod_strings['LBL_DESCRIPTION']}</td>
555 </tr>
556
557 <tr>
558 <td scope='row'><input type='radio' name='appointment' value='Meeting' class='radio'> ${mod_strings['LNK_NEW_MEETING']}</td>
559
560 <td rowspan='8' ><textarea name='Appointmentsdescription' cols='50' rows='5'></textarea></td>
561 </tr>
562 EOQ;
563 }else{
564                 $form .= <<<EOQ
565 <td scope='row' width="20%"><input type='radio' name='appointment' value='Call' class='radio' onchange='document.$formname.module.value="Calls";' checked> ${mod_strings['LNK_NEW_CALL']}</td>
566 </tr>
567
568 <tr>
569 <td scope='row'><input type='radio' name='appointment' value='Meeting' class='radio' onchange='document.$formname.module.value="Meetings";'> ${mod_strings['LNK_NEW_MEETING']}</td>
570 </tr>
571 EOQ;
572 }
573 $jscalenderImage = SugarThemeRegistry::current()->getImageURL('jscalendar.gif');
574 $form .=        <<<EOQ
575
576
577 <tr>
578 <td scope='row'>$lbl_subject&nbsp;<span class="required">$lbl_required_symbol</span></td>
579 </tr>
580
581 <tr>
582 <td ><input name='${prefix}name' maxlength='255' type="text"></td>
583 </tr>
584
585 <tr>
586 <td scope='row'>$lbl_date&nbsp;<span class="required">$lbl_required_symbol</span>&nbsp;<span class="dateFormat">$ntc_date_format</span></td>
587 </tr>
588 <tr>
589 <td ><input onblur="parseDate(this, '$cal_dateformat');" name='${prefix}date_start' size="12" id='${prefix}jscal_field' maxlength='10' type="text" value="${default_date_start}"> <!--not_in_theme!--><img src="{$jscalenderImage}" alt="{$app_strings['LBL_ENTER_DATE']}"  id="${prefix}jscal_trigger" align="absmiddle"></td>
590 </tr>
591
592 <tr>
593 <td scope='row'>$lbl_time&nbsp;<span class="required">$lbl_required_symbol</span>&nbsp;<span class="dateFormat">$ntc_time_format</span></td>
594 </tr>
595 <tr>
596 <td ><input name='${prefix}time_start' size="12" type="text" maxlength='5' value="{$default_time_start}">$time_ampm</td>
597 </tr>
598
599 </table>
600
601                 <script type="text/javascript">
602                 Calendar.setup ({
603                         inputField : "${prefix}jscal_field", daFormat : "$cal_dateformat", ifFormat : "$cal_dateformat", showsTime : false, button : "${prefix}jscal_trigger", singleClick : true, step : 1, weekNumbers:false
604                 });
605                 </script>
606 EOQ;
607
608
609 $javascript = new javascript();
610 $javascript->setFormName($formname);
611 $javascript->setSugarBean(new Call());
612 $javascript->addRequiredFields($prefix);
613 $form .=$javascript->getScript();
614 $mod_strings = $temp_strings;
615 return $form;
616
617 }
618
619
620
621 }
622 ?>