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