Exemple #1
0
 function fill_in_additional_detail_fields()
 {
     global $theme;
     global $current_language;
     global $timedate;
     global $app_list_strings;
     $this->uploadfile = $this->filename;
     $mod_strings = return_module_language($current_language, $this->object_name);
     global $img_name;
     global $img_name_bare;
     if (!$this->file_ext) {
         $img_name = SugarThemeRegistry::current()->getImageURL(strtolower($this->file_ext) . "_image_inline.gif");
         $img_name_bare = strtolower($this->file_ext) . "_image_inline";
     }
     //set default file name.
     if (!empty($img_name) && file_exists($img_name)) {
         $img_name = $img_name_bare;
     } else {
         $img_name = "def_image_inline";
         //todo change the default image.
     }
     $this->file_url_noimage = basename(UploadFile::get_url($this->filename, $this->id));
     if (!empty($this->status_id)) {
         $this->status = $app_list_strings['document_status_dom'][$this->status_id];
     }
 }
Exemple #2
0
 /**
  * @see SugarBean::fill_in_additional_detail_fields()
  */
 public function fill_in_additional_detail_fields()
 {
     global $app_list_strings;
     global $img_name;
     global $img_name_bare;
     $this->uploadfile = $this->filename;
     // Bug 41453 - Make sure we call the parent method as well
     parent::fill_in_additional_detail_fields();
     if (!$this->file_ext) {
         $img_name = SugarThemeRegistry::current()->getImageURL(strtolower($this->file_ext) . "_image_inline.gif");
         $img_name_bare = strtolower($this->file_ext) . "_image_inline";
     }
     //set default file name.
     if (!empty($img_name) && file_exists($img_name)) {
         $img_name = $img_name_bare;
     } else {
         $img_name = "def_image_inline";
         //todo change the default image.
     }
     $this->file_url_noimage = basename(UploadFile::get_url($this->filename, $this->id));
     if (!empty($this->status_id)) {
         $this->status = $app_list_strings['document_status_dom'][$this->status_id];
     }
 }
Exemple #3
0
 function fill_in_additional_detail_fields()
 {
     global $theme;
     global $current_language;
     global $timedate;
     global $locale;
     parent::fill_in_additional_detail_fields();
     $mod_strings = return_module_language($current_language, 'Documents');
     $query = "SELECT filename,revision,file_ext FROM document_revisions WHERE id='{$this->document_revision_id}'";
     $result = $this->db->query($query);
     $row = $this->db->fetchByAssoc($result);
     //popuplate filename
     if (isset($row['filename'])) {
         $this->filename = $row['filename'];
     }
     //$this->latest_revision = $row['revision'];
     if (isset($row['revision'])) {
         $this->revision = $row['revision'];
     }
     //populate the file url.
     //image is selected based on the extension name <ext>_icon_inline, extension is stored in document_revisions.
     //if file is not found then default image file will be used.
     global $img_name;
     global $img_name_bare;
     if (!empty($row['file_ext'])) {
         $img_name = SugarThemeRegistry::current()->getImageURL(strtolower($row['file_ext']) . "_image_inline.gif");
         $img_name_bare = strtolower($row['file_ext']) . "_image_inline";
     }
     //set default file name.
     if (!empty($img_name) && file_exists($img_name)) {
         $img_name = $img_name_bare;
     } else {
         $img_name = "def_image_inline";
         //todo change the default image.
     }
     if ($this->ACLAccess('DetailView')) {
         $this->file_url = "<a href='index.php?entryPoint=download&id=" . basename(UploadFile::get_url($this->filename, $this->document_revision_id)) . "&type=Documents' target='_blank'>" . SugarThemeRegistry::current()->getImage($img_name, 'alt="' . $mod_strings['LBL_LIST_VIEW_DOCUMENT'] . '"  border="0"') . "</a>";
         $this->file_url_noimage = basename(UploadFile::get_url($this->filename, $this->document_revision_id));
     } else {
         $this->file_url = "";
         $this->file_url_noimage = "";
     }
     //get last_rev_by user name.
     $query = "SELECT first_name,last_name, document_revisions.date_entered as rev_date FROM users, document_revisions WHERE users.id = document_revisions.created_by and document_revisions.id = '{$this->document_revision_id}'";
     $result = $this->db->query($query, true, "Eror fetching user name: ");
     $row = $this->db->fetchByAssoc($result);
     if (!empty($row)) {
         $this->last_rev_created_name = $locale->getLocaleFormattedName($row['first_name'], $row['last_name']);
         $this->last_rev_create_date = $timedate->to_display_date_time($row['rev_date']);
     }
     global $app_list_strings;
     if (!empty($this->status_id)) {
         //_pp($this->status_id);
         $this->status = $app_list_strings['document_status_dom'][$this->status_id];
     }
     $this->related_doc_name = Document::get_document_name($this->related_doc_id);
     $this->related_doc_rev_number = DocumentRevision::get_document_revision_name($this->related_doc_rev_id);
     $this->save_file = basename($this->file_url_noimage);
 }
 function fill_in_additional_detail_fields()
 {
     global $theme;
     global $current_language;
     parent::fill_in_additional_detail_fields();
     $mod_strings = return_module_language($current_language, 'Documents');
     //find the document name and current version.
     $query = "SELECT document_name, revision, document_revision_id FROM documents, document_revisions where documents.id = '{$this->document_id}' AND document_revisions.id = documents.document_revision_id";
     $result = $this->db->query($query, true, "Error fetching document details...:");
     $row = $this->db->fetchByAssoc($result);
     if ($row != null) {
         $this->document_name = $row['document_name'];
         $this->latest_revision = $row['revision'];
         $this->latest_revision_id = $row['document_revision_id'];
     }
     //populate the file url.
     //image is selected based on the extension name <ext>_image_inline, extension is stored in document_revisions.
     //if file is not found then default image file will be used.
     global $img_name;
     global $img_name_bare;
     if (!empty($this->file_ext)) {
         $img_name = SugarThemeRegistry::current()->getImageURL("{$this->file_ext}_image_inline.gif");
         $img_name_bare = "{$this->file_ext}_image_inline";
     }
     //set default file name.
     if (!empty($img_name) && file_exists($img_name)) {
         $img_name = $img_name_bare;
     } else {
         $img_name = "def_image_inline";
         //todo change the default image.
     }
     if ($this->ACLAccess('DetailView')) {
         $this->file_url = "<a href='" . UploadFile::get_url($this->filename, $this->id) . "' target='_blank'>" . SugarThemeRegistry::current()->getImage($img_name, 'alt="' . $mod_strings['LBL_LIST_VIEW_DOCUMENT'] . '"  border="0"') . "</a>";
     } else {
         $this->file_url = "";
     }
 }
Exemple #5
0
 /**
  *
  */
 function process_page()
 {
     global $focus;
     global $mod_strings;
     global $app_strings;
     global $app_list_strings;
     global $currentModule;
     global $odd_bg;
     global $even_bg;
     global $timedate;
     $history_list = array();
     if (!empty($_REQUEST['record'])) {
         $result = $focus->retrieve($_REQUEST['record']);
         if ($result == null) {
             sugar_die($app_strings['ERROR_NO_RECORD']);
         }
     }
     $activitiesRels = array('tasks' => 'Task', 'meetings' => 'Meeting', 'calls' => 'Call', 'emails' => 'Email', 'notes' => 'Note');
     //Setup the arrays to store the linked records.
     foreach ($activitiesRels as $relMod => $beanName) {
         $varname = "focus_" . $relMod . "_list";
         ${$varname} = array();
     }
     foreach ($focus->get_linked_fields() as $field => $def) {
         if ($focus->load_relationship($field)) {
             $relTable = $focus->{$field}->getRelatedTableName();
             if (in_array($relTable, array_keys($activitiesRels))) {
                 $varname = "focus_" . $relTable . "_list";
                 ${$varname} = sugarArrayMerge(${$varname}, $focus->get_linked_beans($field, $activitiesRels[$relTable]));
             }
         }
     }
     foreach ($focus_tasks_list as $task) {
         $sort_date_time = '';
         if (empty($task->date_due) || $task->date_due == '0000-00-00') {
             $date_due = '';
         } else {
             $date_due = $task->date_due;
         }
         if ($task->status != "Not Started" && $task->status != "In Progress" && $task->status != "Pending Input") {
             $history_list[] = array('name' => $task->name, 'id' => $task->id, 'type' => "Task", 'direction' => '', 'module' => "Tasks", 'status' => $task->status, 'parent_id' => $task->parent_id, 'parent_type' => $task->parent_type, 'parent_name' => $task->parent_name, 'contact_id' => $task->contact_id, 'contact_name' => $task->contact_name, 'date_modified' => $date_due, 'description' => $this->getTaskDetails($task), 'date_type' => $app_strings['DATA_TYPE_DUE'], 'sort_value' => strtotime($task->fetched_row['date_due'] . ' GMT'));
         } else {
             $open_activity_list[] = array('name' => $task->name, 'id' => $task->id, 'type' => "Task", 'direction' => '', 'module' => "Tasks", 'status' => $task->status, 'parent_id' => $task->parent_id, 'parent_type' => $task->parent_type, 'parent_name' => $task->parent_name, 'contact_id' => $task->contact_id, 'contact_name' => $task->contact_name, 'date_due' => $date_due, 'description' => $this->getTaskDetails($task), 'date_type' => $app_strings['DATA_TYPE_DUE']);
         }
     }
     // end Tasks
     foreach ($focus_meetings_list as $meeting) {
         if (empty($meeting->contact_id) && empty($meeting->contact_name)) {
             $meeting_contacts = $meeting->get_linked_beans('contacts', 'Contact');
             if (!empty($meeting_contacts[0]->id) && !empty($meeting_contacts[0]->name)) {
                 $meeting->contact_id = $meeting_contacts[0]->id;
                 $meeting->contact_name = $meeting_contacts[0]->name;
             }
         }
         if ($meeting->status != "Planned") {
             $history_list[] = array('name' => $meeting->name, 'id' => $meeting->id, 'type' => "Meeting", 'direction' => '', 'module' => "Meetings", 'status' => $meeting->status, 'parent_id' => $meeting->parent_id, 'parent_type' => $meeting->parent_type, 'parent_name' => $meeting->parent_name, 'contact_id' => $meeting->contact_id, 'contact_name' => $meeting->contact_name, 'date_modified' => $meeting->date_start, 'description' => $this->formatDescription($meeting->description), 'date_type' => $app_strings['DATA_TYPE_START'], 'sort_value' => strtotime($meeting->fetched_row['date_start'] . ' GMT'));
         } else {
             $open_activity_list[] = array('name' => $meeting->name, 'id' => $meeting->id, 'type' => "Meeting", 'direction' => '', 'module' => "Meetings", 'status' => $meeting->status, 'parent_id' => $meeting->parent_id, 'parent_type' => $meeting->parent_type, 'parent_name' => $meeting->parent_name, 'contact_id' => $meeting->contact_id, 'contact_name' => $meeting->contact_name, 'date_due' => $meeting->date_start, 'description' => $this->formatDescription($meeting->description), 'date_type' => $app_strings['DATA_TYPE_START']);
         }
     }
     // end Meetings
     foreach ($focus_calls_list as $call) {
         if (empty($call->contact_id) && empty($call->contact_name)) {
             $call_contacts = $call->get_linked_beans('contacts', 'Contact');
             if (!empty($call_contacts[0]->id) && !empty($call_contacts[0]->name)) {
                 $call->contact_id = $call_contacts[0]->id;
                 $call->contact_name = $call_contacts[0]->name;
             }
         }
         if ($call->status != "Planned") {
             $history_list[] = array('name' => $call->name, 'id' => $call->id, 'type' => "Call", 'direction' => $call->direction, 'module' => "Calls", 'status' => $call->status, 'parent_id' => $call->parent_id, 'parent_type' => $call->parent_type, 'parent_name' => $call->parent_name, 'contact_id' => $call->contact_id, 'contact_name' => $call->contact_name, 'date_modified' => $call->date_start, 'description' => $this->formatDescription($call->description), 'date_type' => $app_strings['DATA_TYPE_START'], 'sort_value' => strtotime($call->fetched_row['date_start'] . ' GMT'));
         } else {
             $open_activity_list[] = array('name' => $call->name, 'id' => $call->id, 'direction' => $call->direction, 'type' => "Call", 'module' => "Calls", 'status' => $call->status, 'parent_id' => $call->parent_id, 'parent_type' => $call->parent_type, 'parent_name' => $call->parent_name, 'contact_id' => $call->contact_id, 'contact_name' => $call->contact_name, 'date_due' => $call->date_start, 'description' => $this->formatDescription($call->description), 'date_type' => $app_strings['DATA_TYPE_START']);
         }
     }
     // end Calls
     foreach ($focus_emails_list as $email) {
         if (empty($email->contact_id) && empty($email->contact_name)) {
             $email_contacts = $email->get_linked_beans('contacts', 'Contact');
             if (!empty($email_contacts[0]->id) && !empty($email_contacts[0]->name)) {
                 $email->contact_id = $email_contacts[0]->id;
                 $email->contact_name = $email_contacts[0]->name;
             }
         }
         $history_list[] = array('name' => $email->name, 'id' => $email->id, 'type' => "Email", 'direction' => '', 'module' => "Emails", 'status' => '', 'parent_id' => $email->parent_id, 'parent_type' => $email->parent_type, 'parent_name' => $email->parent_name, 'contact_id' => $email->contact_id, 'contact_name' => $email->contact_name, 'date_modified' => $email->date_start . " " . $email->time_start, 'description' => $this->getEmailDetails($email), 'date_type' => $app_strings['DATA_TYPE_SENT'], 'sort_value' => strtotime($email->fetched_row['date_sent'] . ' GMT'));
     }
     //end Emails
     // Bug 46439 'No email archived when clicking on View Summary' (All condition)
     if (method_exists($focus, 'get_unlinked_email_query')) {
         $queryArray = $focus->get_unlinked_email_query(array('return_as_array' => 'true'));
         $query = $queryArray['select'];
         $query .= $queryArray['from'];
         if (!empty($queryArray['join_tables'])) {
             foreach ($queryArray['join_tables'] as $join_table) {
                 if ($join_table != '') {
                     $query .= ', ' . $join_table . ' ';
                 }
             }
         }
         $query .= $queryArray['join'];
         $query .= $queryArray['where'];
         $emails = new Email();
         $focus_unlinked_emails_list = $emails->process_list_query($query, 0);
         $focus_unlinked_emails_list = $focus_unlinked_emails_list['list'];
         foreach ($focus_unlinked_emails_list as $email) {
             $email->retrieve($email->id);
             $history_list[] = array('name' => $email->name, 'id' => $email->id, 'type' => "Email", 'direction' => '', 'module' => "Emails", 'status' => '', 'parent_id' => $email->parent_id, 'parent_type' => $email->parent_type, 'parent_name' => $email->parent_name, 'contact_id' => $email->contact_id, 'contact_name' => $email->contact_name, 'date_modified' => $email->date_start . " " . $email->time_start, 'description' => $this->getEmailDetails($email), 'date_type' => $app_strings['DATA_TYPE_SENT'], 'sort_value' => strtotime($email->fetched_row['date_sent'] . ' GMT'));
         }
     }
     //end Unlinked Emails
     foreach ($focus_notes_list as $note) {
         $history_list[] = array('name' => $note->name, 'id' => $note->id, 'type' => "Note", 'direction' => '', 'module' => "Notes", 'status' => '', 'parent_id' => $note->parent_id, 'parent_type' => $note->parent_type, 'parent_name' => $note->parent_name, 'contact_id' => $note->contact_id, 'contact_name' => $note->contact_name, 'date_modified' => $note->date_modified, 'description' => $this->formatDescription($note->description), 'date_type' => $app_strings['DATA_TYPE_MODIFIED'], 'sort_value' => strtotime($note->fetched_row['date_modified'] . ' GMT'));
         if (!empty($note->filename)) {
             $count = count($history_list);
             $count--;
             $history_list[$count]['filename'] = $note->filename;
             $history_list[$count]['fileurl'] = UploadFile::get_url($note->filename, $note->id);
         }
     }
     // end Notes
     $xtpl = new XTemplate('modules/Activities/Popup_picker.html');
     $xtpl->assign('MOD', $mod_strings);
     $xtpl->assign('APP', $app_strings);
     insert_popup_header();
     //output header
     echo "<table width='100%' cellpadding='0' cellspacing='0'><tr><td>";
     echo getClassicModuleTitle($focus->module_dir, array(translate('LBL_MODULE_NAME', $focus->module_dir), $focus->name), false);
     echo "</td><td align='right' class='moduleTitle'>";
     echo "<A href='javascript:print();' class='utilsLink'><img src='" . SugarThemeRegistry::current()->getImageURL("print.gif") . "' width='13' height='13' alt='" . $app_strings['LNK_PRINT'] . "' border='0' align='absmiddle'></a>&nbsp;<A href='javascript:print();' class='utilsLink'>" . $app_strings['LNK_PRINT'] . "</A>\n";
     echo "</td></tr></table>";
     $oddRow = true;
     if (count($history_list) > 0) {
         $history_list = array_csort($history_list, 'sort_value', SORT_DESC);
     }
     foreach ($history_list as $activity) {
         $activity_fields = array('ID' => $activity['id'], 'NAME' => $activity['name'], 'MODULE' => $activity['module'], 'CONTACT_NAME' => $activity['contact_name'], 'CONTACT_ID' => $activity['contact_id'], 'PARENT_TYPE' => $activity['parent_type'], 'PARENT_NAME' => $activity['parent_name'], 'PARENT_ID' => $activity['parent_id'], 'DATE' => $activity['date_modified'], 'DESCRIPTION' => $activity['description'], 'DATE_TYPE' => $activity['date_type']);
         if (empty($activity['direction'])) {
             $activity_fields['TYPE'] = $app_list_strings['activity_dom'][$activity['type']];
         } else {
             $activity_fields['TYPE'] = $app_list_strings['call_direction_dom'][$activity['direction']] . ' ' . $app_list_strings['activity_dom'][$activity['type']];
         }
         switch ($activity['type']) {
             case 'Call':
                 $activity_fields['STATUS'] = $app_list_strings['call_status_dom'][$activity['status']];
                 break;
             case 'Meeting':
                 $activity_fields['STATUS'] = $app_list_strings['meeting_status_dom'][$activity['status']];
                 break;
             case 'Task':
                 $activity_fields['STATUS'] = $app_list_strings['task_status_dom'][$activity['status']];
                 break;
         }
         if (isset($activity['location'])) {
             $activity_fields['LOCATION'] = $activity['location'];
         }
         if (isset($activity['filename'])) {
             $activity_fields['ATTACHMENT'] = "<a href='index.php?entryPoint=download&id=" . $activity['id'] . "&type=Notes' target='_blank'>" . SugarThemeRegistry::current()->getImage("attachment", "alt='" . $activity['filename'] . "' border='0' align='absmiddle'") . "</a>";
         }
         if (isset($activity['parent_type'])) {
             $activity_fields['PARENT_MODULE'] = $activity['parent_type'];
         }
         $xtpl->assign("ACTIVITY", $activity_fields);
         $xtpl->assign("ACTIVITY_MODULE_PNG", SugarThemeRegistry::current()->getImage($activity_fields['MODULE'] . '', 'border="0" alt="' . $activity_fields['NAME'] . '"'));
         if ($oddRow) {
             //todo move to themes
             $xtpl->assign("ROW_COLOR", 'oddListRow');
             $xtpl->assign("BG_COLOR", $odd_bg);
         } else {
             //todo move to themes
             $xtpl->assign("ROW_COLOR", 'evenListRow');
             $xtpl->assign("BG_COLOR", $even_bg);
         }
         $oddRow = !$oddRow;
         if (!empty($activity_fields['DESCRIPTION'])) {
             $xtpl->parse("history.row.description");
         }
         $xtpl->parse("history.row");
         // Put the rows in.
     }
     $xtpl->parse("history");
     $xtpl->out("history");
     insert_popup_footer();
 }
    $xtpl->assign("PARENT_MODULE", $focus->parent_type);
}
$xtpl->assign("CREATED_BY", $focus->created_by_name);
$xtpl->assign("MODIFIED_BY", $focus->modified_by_name);
$xtpl->assign("PARENT_NAME", $focus->parent_name);
$xtpl->assign("PARENT_ID", $focus->parent_id);
$xtpl->assign("NAME", $focus->name);
$xtpl->assign("DATE_MODIFIED", $focus->date_modified);
$xtpl->assign("DATE_ENTERED", $focus->date_entered);
global $current_user;
if (is_admin($current_user) && $_REQUEST['module'] != 'DynamicLayout' && !empty($_SESSION['editinplace'])) {
    $xtpl->assign("ADMIN_EDIT", "<a href='index.php?action=index&module=DynamicLayout&from_action=" . $_REQUEST['action'] . "&from_module=" . $_REQUEST['module'] . "&record=" . $_REQUEST['record'] . "'>" . get_image($image_path . "EditLayout", "border='0' alt='Edit Layout' align='bottom'") . "</a>");
}
if (isset($focus->filename) && $focus->filename != '') {
    global $sugar_config;
    $save_file = urlencode(basename(UploadFile::get_url($focus->filename, $focus->id)));
    $file_path = UploadFile::get_file_path($focus->filename, $focus->id);
    $display = false;
    if (file_exists($file_path)) {
        $display = true;
        $xtpl->assign("FILELINK", "<a href='download.php?id=" . $save_file . "&type=Notes' class='tabDetailViewDFLink'>" . $focus->filename . "</a>&nbsp");
    }
    if ($display) {
        $xtpl->assign("SAVE_FILE", $save_file);
        $xtpl->assign("FILE_NAME", $focus->filename);
    }
}
$xtpl->assign("DESCRIPTION", nl2br(url2html($focus->description)));
$xtpl->parse("main.open_source");
$detailView->processListNavigation($xtpl, "NOTE", $offset);
// adding custom fields:
 function get_list_view_data()
 {
     $note_fields = $this->get_list_view_array();
     global $app_list_strings, $focus, $action, $currentModule, $mod_strings, $sugar_config;
     $this->_create_proper_name_field();
     if (isset($this->parent_type)) {
         $note_fields['PARENT_MODULE'] = $this->parent_type;
     }
     if (!isset($this->filename) || $this->filename != '') {
         $file_path = UploadFile::get_file_path($this->filename, $this->id);
         if (file_exists($file_path)) {
             $save_file = urlencode(basename(UploadFile::get_url($this->filename, $this->id)));
             $note_fields['FILENAME'] = $this->filename;
             $note_fields['FILE_URL'] = "index.php?entryPoint=download&id=" . $save_file . "&type=Notes";
         }
     }
     if (isset($this->contact_name)) {
         $note_fields['CONTACT_NAME'] = $this->contact_name;
     }
     global $current_language;
     $mod_strings = return_module_language($current_language, 'Notes');
     $note_fields['STATUS'] = $mod_strings['LBL_NOTE_STATUS'];
     return $note_fields;
 }
 function get_list_view_data()
 {
     $note_fields = $this->get_list_view_array();
     global $app_list_strings, $focus, $action, $currentModule, $mod_strings, $sugar_config;
     $note_fields["DATE_MODIFIED"] = substr($note_fields["DATE_MODIFIED"], 0, 10);
     if (isset($this->parent_type)) {
         $note_fields['PARENT_MODULE'] = $this->parent_type;
     }
     if (!isset($this->filename) || $this->filename != '') {
         $file_path = UploadFile::get_file_path($this->filename, $this->id);
         if (file_exists($file_path)) {
             $save_file = urlencode(basename(UploadFile::get_url($this->filename, $this->id)));
             $note_fields['FILENAME'] = $this->filename;
             $note_fields['FILE_URL'] = "download.php?id=" . $save_file . "&type=Notes";
         }
     }
     global $current_language;
     $mod_strings = return_module_language($current_language, 'Notes');
     $note_fields['STATUS'] = $mod_strings['LBL_NOTE_STATUS'];
     return $note_fields;
 }
$xtpl->assign("MOD", $mod_strings);
$xtpl->assign("APP", $app_strings);
if (isset($_REQUEST['return_module'])) {
    $xtpl->assign("RETURN_MODULE", $_REQUEST['return_module']);
}
if (isset($_REQUEST['return_action'])) {
    $xtpl->assign("RETURN_ACTION", $_REQUEST['return_action']);
}
if (isset($_REQUEST['return_id'])) {
    $xtpl->assign("RETURN_ID", $_REQUEST['return_id']);
}
$xtpl->assign("THEME", $theme);
$xtpl->assign("IMAGE_PATH", $image_path);
$xtpl->assign("PRINT_URL", "index.php?" . $GLOBALS['request_string']);
$focus->fill_document_name_revision($focus->document_id);
$xtpl->assign("ID", $focus->id);
$xtpl->assign("DOCUMENT_NAME", $focus->name);
$xtpl->assign("CURRENT_REVISION", $focus->latest_revision);
$xtpl->assign("CHANGE_LOG", $focus->change_log);
$created_user = new User();
$created_user->retrieve($focus->created_by);
$xtpl->assign("CREATED_BY", $created_user->first_name . ' ' . $created_user->last_name);
$xtpl->assign("DATE_CREATED", $focus->date_entered);
$xtpl->assign("REVISION", $focus->revision);
$xtpl->assign("FILENAME", $focus->filename);
$xtpl->assign("FILE_NAME", $focus->filename);
$xtpl->assign("SAVE_FILE", $focus->id);
$xtpl->assign("FILE_URL", UploadFile::get_url($focus->filename, $focus->id));
$xtpl->assign("GRIDLINE", $gridline);
$xtpl->parse("main");
$xtpl->out("main");
Exemple #10
0
}
//rof
$merge_array['ids'] = $ids;
$dataDir = getcwd() . '/' . sugar_cached('MergedDocuments/');
if (!file_exists($dataDir)) {
    sugar_mkdir($dataDir);
}
srand((double) microtime() * 1000000);
$mTime = microtime();
$dataFileName = 'sugardata' . $mTime . '.php';
write_array_to_file('merge_array', $merge_array, $dataDir . $dataFileName);
//Save the temp file so we can remove when we are done
$_SESSION['MAILMERGE_TEMP_FILE_' . $mTime] = $dataDir . $dataFileName;
$site_url = $sugar_config['site_url'];
//$templateFile = $site_url . '/' . UploadFile::get_upload_url($document);
$templateFile = $site_url . '/' . UploadFile::get_url(from_html($document->filename), $document->id);
$dataFile = $dataFileName;
$redirectUrl = 'index.php?action=index&step=5&module=MailMerge&mtime=' . $mTime;
$startUrl = 'index.php?action=index&module=MailMerge&reset=true';
$relModule = trim($relModule);
$contents = "SUGARCRM_MAIL_MERGE_TOKEN#{$templateFile}#{$dataFile}#{$module}#{$relModule}";
$rtfFileName = 'sugartokendoc' . $mTime . '.doc';
$fp = sugar_fopen($dataDir . $rtfFileName, 'w');
fwrite($fp, $contents);
fclose($fp);
$_SESSION['mail_merge_file_location'] = sugar_cached('MergedDocuments/') . $rtfFileName;
$_SESSION['mail_merge_file_name'] = $rtfFileName;
$xtpl->assign("MAILMERGE_FIREFOX_URL", $site_url . '/' . $GLOBALS['sugar_config']['cache_dir'] . 'MergedDocuments/' . $rtfFileName);
$xtpl->assign("MAILMERGE_START_URL", $startUrl);
$xtpl->assign("MAILMERGE_TEMPLATE_FILE", $templateFile);
$xtpl->assign("MAILMERGE_DATA_FILE", $dataFile);
$attachments = '';
if (!empty($focus->id) || !empty($_REQUEST['record']) && $_REQUEST['type'] == 'forward') {
    $focusId = empty($focus->id) ? $_REQUEST['record'] : $focus->id;
    $note = new Note();
    $where = "notes.parent_id='{$focusId}' AND notes.filename IS NOT NULL";
    $notes_list = $note->get_full_list("", $where, true);
    if (!isset($notes_list)) {
        $notes_list = array();
    }
    for ($i = 0; $i < count($notes_list); $i++) {
        $the_note = $notes_list[$i];
        if (empty($the_note->filename)) {
            continue;
        }
        $attachments .= '<input type="checkbox" name="remove_attachment[]" value="' . $the_note->id . '"> ' . $app_strings['LNK_REMOVE'] . '&nbsp;&nbsp;';
        $attachments .= '<a href="' . UploadFile::get_url($the_note->filename, $the_note->id) . '" target="_blank">' . $the_note->filename . '</a><br>';
    }
}
$attJs = '<script type="text/javascript">';
$attJs .= 'var file_path = "' . $sugar_config['site_url'] . '/' . $sugar_config['upload_dir'] . '";';
$attJs .= 'var lnk_remove = "' . $app_strings['LNK_REMOVE'] . '";';
$attJs .= '</script>';
$xtpl->assign('ATTACHMENTS', $attachments);
$xtpl->assign('ATTACHMENTS_JAVASCRIPT', $attJs);
////	END ATTACHMENTS
///////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
////	DOCUMENTS
$popup_request_data = array('call_back_function' => 'document_set_return', 'form_name' => 'EditView', 'field_to_name_array' => array('id' => 'related_doc_id', 'document_name' => 'related_document_name'));
$json = getJSONobj();
$xtpl->assign('encoded_document_popup_request_data', $json->encode($popup_request_data));
 /**
  * Returns the history.
  *
  * @param $api
  * @param $args
  * @return array|mixed
  */
 public function getHistory($api, $args)
 {
     global $app_strings;
     global $app_list_strings;
     global $timedate;
     $history_list = array();
     $focus = BeanFactory::getBean($args['module'], $args['id']);
     $activitiesRels = array('tasks' => 'Task', 'meetings' => 'Meeting', 'calls' => 'Call', 'emails' => 'Email', 'notes' => 'Note');
     //Setup the arrays to store the linked records.
     foreach ($activitiesRels as $relMod => $beanName) {
         $varname = "focus_" . $relMod . "_list";
         ${$varname} = array();
     }
     foreach ($focus->get_linked_fields() as $field => $def) {
         if ($focus->load_relationship($field)) {
             $relTable = $focus->{$field}->getRelatedTableName();
             if (in_array($relTable, array_keys($activitiesRels))) {
                 $varname = "focus_" . $relTable . "_list";
                 ${$varname} = sugarArrayMerge(${$varname}, $focus->get_linked_beans($field, $activitiesRels[$relTable], array(), 0, 100));
             }
         }
     }
     foreach ($focus_tasks_list as $task) {
         $sort_date_time = '';
         if (empty($task->date_due) || $task->date_due == '0000-00-00') {
             $date_due = '';
         } else {
             $date_due = $task->date_due;
         }
         if ($task->status != "Not Started" && $task->status != "In Progress" && $task->status != "Pending Input") {
             $ts = '';
             if (!empty($task->fetched_row['date_due'])) {
                 //tasks can have an empty date due field
                 $ts = $timedate->fromDb($task->fetched_row['date_due'])->ts;
             }
             $history_list[] = array('name' => $task->name, 'id' => $task->id, 'type' => "Task", 'direction' => '', 'module' => "Tasks", 'status' => $task->status, 'parent_id' => $task->parent_id, 'parent_type' => $task->parent_type, 'parent_name' => $task->parent_name, 'contact_id' => $task->contact_id, 'contact_name' => $task->contact_name, 'date_modified' => $date_due, 'description' => $this->getTaskDetails($task), 'date_type' => $app_strings['DATA_TYPE_DUE'], 'sort_value' => $ts);
         } else {
             $open_activity_list[] = array('name' => $task->name, 'id' => $task->id, 'type' => "Task", 'direction' => '', 'module' => "Tasks", 'status' => $task->status, 'parent_id' => $task->parent_id, 'parent_type' => $task->parent_type, 'parent_name' => $task->parent_name, 'contact_id' => $task->contact_id, 'contact_name' => $task->contact_name, 'date_due' => $date_due, 'description' => $this->getTaskDetails($task), 'date_type' => $app_strings['DATA_TYPE_DUE']);
         }
     }
     // end Tasks
     foreach ($focus_meetings_list as $meeting) {
         if (empty($meeting->contact_id) && empty($meeting->contact_name)) {
             $meeting_contacts = $meeting->get_linked_beans('contacts', 'Contact', array(), 0, 100);
             if (!empty($meeting_contacts[0]->id) && !empty($meeting_contacts[0]->name)) {
                 $meeting->contact_id = $meeting_contacts[0]->id;
                 $meeting->contact_name = $meeting_contacts[0]->name;
             }
         }
         if ($meeting->status != "Planned") {
             $history_list[] = array('name' => $meeting->name, 'id' => $meeting->id, 'type' => "Meeting", 'direction' => '', 'module' => "Meetings", 'status' => $meeting->status, 'parent_id' => $meeting->parent_id, 'parent_type' => $meeting->parent_type, 'parent_name' => $meeting->parent_name, 'contact_id' => $meeting->contact_id, 'contact_name' => $meeting->contact_name, 'date_modified' => $meeting->date_start, 'description' => $this->formatDescription($meeting->description), 'date_type' => $app_strings['DATA_TYPE_START'], 'sort_value' => $timedate->fromDb($meeting->fetched_row['date_start'])->ts);
         } else {
             $open_activity_list[] = array('name' => $meeting->name, 'id' => $meeting->id, 'type' => "Meeting", 'direction' => '', 'module' => "Meetings", 'status' => $meeting->status, 'parent_id' => $meeting->parent_id, 'parent_type' => $meeting->parent_type, 'parent_name' => $meeting->parent_name, 'contact_id' => $meeting->contact_id, 'contact_name' => $meeting->contact_name, 'date_due' => $meeting->date_start, 'description' => $this->formatDescription($meeting->description), 'date_type' => $app_strings['DATA_TYPE_START']);
         }
     }
     // end Meetings
     foreach ($focus_calls_list as $call) {
         if (empty($call->contact_id) && empty($call->contact_name)) {
             $call_contacts = $call->get_linked_beans('contacts', 'Contact', array(), 0, 100);
             if (!empty($call_contacts[0]->id) && !empty($call_contacts[0]->name)) {
                 $call->contact_id = $call_contacts[0]->id;
                 $call->contact_name = $call_contacts[0]->name;
             }
         }
         if ($call->status != "Planned") {
             $history_list[] = array('name' => $call->name, 'id' => $call->id, 'type' => "Call", 'direction' => $call->direction, 'module' => "Calls", 'status' => $call->status, 'parent_id' => $call->parent_id, 'parent_type' => $call->parent_type, 'parent_name' => $call->parent_name, 'contact_id' => $call->contact_id, 'contact_name' => $call->contact_name, 'date_modified' => $call->date_start, 'description' => $this->formatDescription($call->description), 'date_type' => $app_strings['DATA_TYPE_START'], 'sort_value' => $timedate->fromDb($call->fetched_row['date_start'])->ts);
         } else {
             $open_activity_list[] = array('name' => $call->name, 'id' => $call->id, 'direction' => $call->direction, 'type' => "Call", 'module' => "Calls", 'status' => $call->status, 'parent_id' => $call->parent_id, 'parent_type' => $call->parent_type, 'parent_name' => $call->parent_name, 'contact_id' => $call->contact_id, 'contact_name' => $call->contact_name, 'date_due' => $call->date_start, 'description' => $this->formatDescription($call->description), 'date_type' => $app_strings['DATA_TYPE_START']);
         }
     }
     // end Calls
     foreach ($focus_emails_list as $email) {
         if (empty($email->contact_id) && empty($email->contact_name)) {
             $email_contacts = $email->get_linked_beans('contacts', 'Contact', array(), 0, 100);
             if (!empty($email_contacts[0]->id) && !empty($email_contacts[0]->name)) {
                 $email->contact_id = $email_contacts[0]->id;
                 $email->contact_name = $email_contacts[0]->name;
             }
         }
         $ts = '';
         if (!empty($email->fetched_row['date_sent'])) {
             //emails can have an empty date sent field
             $ts = $timedate->fromDb($email->fetched_row['date_sent'])->ts;
         }
         $history_list[] = array('name' => $email->name, 'id' => $email->id, 'type' => "Email", 'direction' => '', 'module' => "Emails", 'status' => '', 'parent_id' => $email->parent_id, 'parent_type' => $email->parent_type, 'parent_name' => $email->parent_name, 'contact_id' => $email->contact_id, 'contact_name' => $email->contact_name, 'date_modified' => $email->date_start . " " . $email->time_start, 'description' => $this->getEmailDetails($email), 'date_type' => $app_strings['DATA_TYPE_SENT'], 'sort_value' => $ts);
     }
     //end Emails
     // Bug 46439 'No email archived when clicking on View Summary' (All condition)
     if (method_exists($focus, 'get_unlinked_email_query')) {
         $queryArray = $focus->get_unlinked_email_query(array('return_as_array' => 'true'));
         $query = $queryArray['select'];
         $query .= $queryArray['from'];
         if (!empty($queryArray['join_tables'])) {
             foreach ($queryArray['join_tables'] as $join_table) {
                 if ($join_table != '') {
                     $query .= ', ' . $join_table . ' ';
                 }
             }
         }
         $query .= $queryArray['join'];
         $query .= $queryArray['where'];
         $emails = BeanFactory::getBean('Emails');
         $focus_unlinked_emails_list = $emails->process_list_query($query, 0);
         $focus_unlinked_emails_list = $focus_unlinked_emails_list['list'];
         foreach ($focus_unlinked_emails_list as $email) {
             $email->retrieve($email->id);
             $history_list[] = array('name' => $email->name, 'id' => $email->id, 'type' => "Email", 'direction' => '', 'module' => "Emails", 'status' => '', 'parent_id' => $email->parent_id, 'parent_type' => $email->parent_type, 'parent_name' => $email->parent_name, 'contact_id' => $email->contact_id, 'contact_name' => $email->contact_name, 'date_modified' => $email->date_start . " " . $email->time_start, 'description' => $this->getEmailDetails($email), 'date_type' => $app_strings['DATA_TYPE_SENT'], 'sort_value' => strtotime($email->fetched_row['date_sent'] . ' GMT'));
         }
     }
     //end Unlinked Emails
     foreach ($focus_notes_list as $note) {
         if ($note->ACLAccess('view')) {
             $history_list[] = array('name' => $note->name, 'id' => $note->id, 'type' => "Note", 'direction' => '', 'module' => "Notes", 'status' => '', 'parent_id' => $note->parent_id, 'parent_type' => $note->parent_type, 'parent_name' => $note->parent_name, 'contact_id' => $note->contact_id, 'contact_name' => $note->contact_name, 'date_modified' => $note->date_modified, 'description' => $this->formatDescription($note->description), 'date_type' => $app_strings['DATA_TYPE_MODIFIED'], 'sort_value' => strtotime($note->fetched_row['date_modified'] . ' GMT'));
             if (!empty($note->filename)) {
                 $count = count($history_list);
                 $count--;
                 $history_list[$count]['filename'] = $note->filename;
                 $history_list[$count]['fileurl'] = UploadFile::get_url($note->filename, $note->id);
             }
         }
     }
     // end Notes
     $oddRow = true;
     $result = array();
     if (count($history_list) > 0) {
         $history_list = array_csort($history_list, 'sort_value', SORT_DESC);
     }
     foreach ($history_list as $activity) {
         $activity_fields = array('ID' => $activity['id'], 'NAME' => $activity['name'], 'MODULE' => $activity['module'], 'CONTACT_NAME' => $activity['contact_name'], 'CONTACT_ID' => $activity['contact_id'], 'PARENT_TYPE' => $activity['parent_type'], 'PARENT_NAME' => $activity['parent_name'], 'PARENT_ID' => $activity['parent_id'], 'DATE' => $activity['date_modified'], 'DESCRIPTION' => $activity['description'], 'DATE_TYPE' => $activity['date_type']);
         if (empty($activity['direction'])) {
             $activity_fields['TYPE'] = $app_list_strings['activity_dom'][$activity['type']];
         } else {
             $activity_fields['TYPE'] = $app_list_strings['call_direction_dom'][$activity['direction']] . ' ' . $app_list_strings['activity_dom'][$activity['type']];
         }
         switch ($activity['type']) {
             case 'Call':
                 $activity_fields['STATUS'] = $app_list_strings['call_status_dom'][$activity['status']];
                 break;
             case 'Meeting':
                 $activity_fields['STATUS'] = $app_list_strings['meeting_status_dom'][$activity['status']];
                 break;
             case 'Task':
                 $activity_fields['STATUS'] = $app_list_strings['task_status_dom'][$activity['status']];
                 break;
         }
         if (isset($activity['location'])) {
             $activity_fields['LOCATION'] = $activity['location'];
         }
         if (isset($activity['filename'])) {
             $activity_fields['ATTACHMENT'] = "<a href='index.php?entryPoint=download&id=" . $activity['id'] . "&type=Notes' target='_blank'>" . SugarThemeRegistry::current()->getImage("attachment", "border='0' align='absmiddle'", null, null, '.gif', $activity['filename']) . "</a>";
         }
         if (isset($activity['parent_type'])) {
             $activity_fields['PARENT_MODULE'] = $activity['parent_type'];
         }
         $result[] = $activity;
     }
     if (isset($focus->name)) {
         $name = $focus->name;
     } else {
         if ($focus->full_name) {
             $name = $focus->full_name;
         }
     }
     $response = array('module_key' => $focus->module_name, 'name' => $name, 'history' => $result);
     return $response;
 }
 function fill_in_additional_detail_fields()
 {
     global $theme;
     global $current_language;
     global $timedate;
     $mod_strings = return_module_language($current_language, 'Documents');
     $query = "SELECT filename,revision,file_ext FROM document_revisions WHERE id='{$this->document_revision_id}'";
     $result = $this->db->query($query);
     $row = $this->db->fetchByAssoc($result);
     //popuplate filename
     $this->filename = $row['filename'];
     $this->latest_revision = $row['revision'];
     //populate the file url.
     //image is selected based on the extension name <ext>_icon_inline, extension is stored in document_revisions.
     //if file is not found then default image file will be used.
     global $img_name;
     global $img_name_bare;
     if (!empty($row['file_ext'])) {
         $img_name = "themes/" . $theme . "/images/{$row['file_ext']}_image_inline.gif";
         $img_name_bare = "{$row['file_ext']}_image_inline";
     }
     //set default file name.
     if (!empty($img_name) && file_exists($img_name)) {
         $img_name = $img_name_bare;
     } else {
         $img_name = "def_image_inline";
         //todo change the default image.
     }
     $this->file_url = "<a href='download.php?id=" . basename(UploadFile::get_url($this->filename, $this->document_revision_id)) . "&type=Documents' target='_blank'>" . get_image('themes/' . $theme . '/images/' . $img_name, 'alt="' . $mod_strings['LBL_LIST_VIEW_DOCUMENT'] . '"  border="0"') . "</a>";
     $this->file_url_noimage = basename(UploadFile::get_url($this->filename, $this->document_revision_id));
     //get last_rev_by user name.
     $query = "SELECT first_name,last_name, document_revisions.date_entered as rev_date FROM users, document_revisions WHERE users.id = document_revisions.created_by and document_revisions.id = '{$this->document_revision_id}'";
     $result = $this->db->query($query, true, "Eror fetching user name: ");
     $row = $this->db->fetchByAssoc($result);
     if (!empty($row)) {
         $this->last_rev_created_name = $row['first_name'] . ' ' . $row['last_name'];
         $this->last_rev_create_date = $timedate->to_display_date_time($row['rev_date']);
     }
 }
 /**
  *
  */
 function process_page()
 {
     global $theme;
     global $focus;
     global $mod_strings;
     global $app_strings;
     global $app_list_strings;
     global $currentModule;
     global $odd_bg;
     global $even_bg;
     global $image_path;
     $theme_path = "themes/" . $theme . "/";
     $image_path = 'themes/' . $theme . '/images/';
     require_once $theme_path . 'layout_utils.php';
     $history_list = array();
     if (!empty($_REQUEST['record'])) {
         $result = $focus->retrieve($_REQUEST['record']);
         if ($result == null) {
             sugar_die($app_strings['ERROR_NO_RECORD']);
         }
     }
     if ($focus->object_name == "ProjectTask" || $focus->object_name == "Project") {
         $focus_tasks_list = array();
     } else {
         $focus_tasks_list = $focus->get_linked_beans('tasks', 'Task');
     }
     $focus_meetings_list = $focus->get_linked_beans('meetings', 'Meeting');
     $focus_calls_list = $focus->get_linked_beans('calls', 'Call');
     $focus_emails_list = $focus->get_linked_beans('emails', 'Email');
     $focus_notes_list = $focus->get_linked_beans('notes', 'Note');
     foreach ($focus_tasks_list as $task) {
         if ($task->date_due == '0000-00-00') {
             $date_due = '';
         } else {
             $date_due = $task->date_due;
         }
         if ($task->status != "Not Started" && $task->status != "In Progress" && $task->status != "Pending Input") {
             $history_list[] = array('name' => $task->name, 'id' => $task->id, 'type' => "Task", 'direction' => '', 'module' => "Tasks", 'status' => $task->status, 'parent_id' => $task->parent_id, 'parent_type' => $task->parent_type, 'parent_name' => $task->parent_name, 'contact_id' => $task->contact_id, 'contact_name' => $task->contact_name, 'date_modified' => $date_due, 'description' => $this->getTaskDetails($task), 'date_type' => 'Due:');
         } else {
             $open_activity_list[] = array('name' => $task->name, 'id' => $task->id, 'type' => "Task", 'direction' => '', 'module' => "Tasks", 'status' => $task->status, 'parent_id' => $task->parent_id, 'parent_type' => $task->parent_type, 'parent_name' => $task->parent_name, 'contact_id' => $task->contact_id, 'contact_name' => $task->contact_name, 'date_due' => $date_due, 'description' => $this->getTaskDetails($task), 'date_type' => 'Due:');
         }
     }
     // end Tasks
     foreach ($focus_meetings_list as $meeting) {
         if ($meeting->status != "Planned") {
             $history_list[] = array('name' => $meeting->name, 'id' => $meeting->id, 'type' => "Meeting", 'direction' => '', 'module' => "Meetings", 'status' => $meeting->status, 'parent_id' => $meeting->parent_id, 'parent_type' => $meeting->parent_type, 'parent_name' => $meeting->parent_name, 'contact_id' => $meeting->contact_id, 'contact_name' => $meeting->contact_name, 'date_modified' => $meeting->date_start, 'description' => $this->formatDescription($meeting->description), 'date_type' => 'Start:');
         } else {
             $open_activity_list[] = array('name' => $meeting->name, 'id' => $meeting->id, 'type' => "Meeting", 'direction' => '', 'module' => "Meetings", 'status' => $meeting->status, 'parent_id' => $meeting->parent_id, 'parent_type' => $meeting->parent_type, 'parent_name' => $meeting->parent_name, 'contact_id' => $meeting->contact_id, 'contact_name' => $meeting->contact_name, 'date_due' => $meeting->date_start, 'description' => $this->formatDescription($meeting->description), 'date_type' => 'Start:');
         }
     }
     // end Meetings
     foreach ($focus_calls_list as $call) {
         if ($call->status != "Planned") {
             $history_list[] = array('name' => $call->name, 'id' => $call->id, 'type' => "Call", 'direction' => $call->direction, 'module' => "Calls", 'status' => $call->status, 'parent_id' => $call->parent_id, 'parent_type' => $call->parent_type, 'parent_name' => $call->parent_name, 'contact_id' => $call->contact_id, 'contact_name' => $call->contact_name, 'date_modified' => $call->date_start, 'description' => $this->formatDescription($call->description), 'date_type' => 'Start:');
         } else {
             $open_activity_list[] = array('name' => $call->name, 'id' => $call->id, 'direction' => $call->direction, 'type' => "Call", 'module' => "Calls", 'status' => $call->status, 'parent_id' => $call->parent_id, 'parent_type' => $call->parent_type, 'parent_name' => $call->parent_name, 'contact_id' => $call->contact_id, 'contact_name' => $call->contact_name, 'date_due' => $call->date_start, 'description' => $this->formatDescription($call->description), 'date_type' => 'Start:');
         }
     }
     // end Calls
     foreach ($focus_emails_list as $email) {
         $history_list[] = array('name' => $email->name, 'id' => $email->id, 'type' => "Email", 'direction' => '', 'module' => "Emails", 'status' => '', 'parent_id' => $email->parent_id, 'parent_type' => $email->parent_type, 'parent_name' => $email->parent_name, 'contact_id' => $email->contact_id, 'contact_name' => $email->contact_name, 'date_modified' => $email->date_start . " " . $email->time_start, 'description' => $this->getEmailDetails($email), 'date_type' => 'Sent:');
     }
     //end Emails
     foreach ($focus_notes_list as $note) {
         $history_list[] = array('name' => $note->name, 'id' => $note->id, 'type' => "Note", 'direction' => '', 'module' => "Notes", 'status' => '', 'parent_id' => $note->parent_id, 'parent_type' => $note->parent_type, 'parent_name' => $note->parent_name, 'contact_id' => $note->contact_id, 'contact_name' => $note->contact_name, 'date_modified' => $note->date_modified, 'description' => $this->formatDescription($note->description), 'date_type' => 'Modified:');
         if (!empty($note->filename)) {
             $count = count($history_list);
             $count--;
             $history_list[$count]['filename'] = $note->filename;
             $history_list[$count]['fileurl'] = UploadFile::get_url($note->filename, $note->id);
         }
     }
     // end Notes
     $xtpl = new XTemplate('modules/Activities/Popup_picker.html');
     $xtpl->assign('THEME', $theme);
     $xtpl->assign('MOD', $mod_strings);
     $xtpl->assign('APP', $app_strings);
     insert_popup_header($theme);
     //output header
     echo "<table width='100%' cellpadding='0' cellspacing='0'><tr><td>";
     echo get_module_title($focus->module_dir, $focus->module_dir . ": " . $focus->name, false);
     echo "</td><td align='right' class='moduleTitle'>";
     echo "<A href='javascript:print();' class='utilsLink'><img src='" . $image_path . "print.gif' width='13' height='13' alt='" . $app_strings['LNK_PRINT'] . "' border='0' align='absmiddle'></a>&nbsp;<A href='javascript:print();' class='utilsLink'>" . $app_strings['LNK_PRINT'] . "</A>\n";
     echo "</td></tr></table>";
     $oddRow = true;
     if (count($history_list) > 0) {
         $history_list = array_csort($history_list, 'date_modified', SORT_DESC);
     }
     foreach ($history_list as $activity) {
         $activity_fields = array('ID' => $activity['id'], 'NAME' => $activity['name'], 'MODULE' => $activity['module'], 'CONTACT_NAME' => $activity['contact_name'], 'CONTACT_ID' => $activity['contact_id'], 'PARENT_TYPE' => $activity['parent_type'], 'PARENT_NAME' => $activity['parent_name'], 'PARENT_ID' => $activity['parent_id'], 'DATE' => $activity['date_modified'], 'DESCRIPTION' => $activity['description'], 'DATE_TYPE' => $activity['date_type']);
         if (empty($activity['direction'])) {
             $activity_fields['TYPE'] = $app_list_strings['activity_dom'][$activity['type']];
         } else {
             $activity_fields['TYPE'] = $app_list_strings['call_direction_dom'][$activity['direction']] . ' ' . $app_list_strings['activity_dom'][$activity['type']];
         }
         switch ($activity['type']) {
             case 'Call':
                 $activity_fields['STATUS'] = $app_list_strings['call_status_dom'][$activity['status']];
                 break;
             case 'Meeting':
                 $activity_fields['STATUS'] = $app_list_strings['meeting_status_dom'][$activity['status']];
                 break;
             case 'Task':
                 $activity_fields['STATUS'] = $app_list_strings['task_status_dom'][$activity['status']];
                 break;
         }
         if (isset($activity['location'])) {
             $activity_fields['LOCATION'] = $activity['location'];
         }
         if (isset($activity['filename'])) {
             $activity_fields['ATTACHMENT'] = "<a href='" . $activity['fileurl'] . "' target='_blank'>" . get_image($image_path . "attachment", "alt='" . $activity['filename'] . "' border='0' align='absmiddle'") . "</a>";
         }
         if (isset($activity['parent_type'])) {
             $activity_fields['PARENT_MODULE'] = $activity['parent_type'];
         }
         $xtpl->assign("ACTIVITY", $activity_fields);
         $xtpl->assign("ACTIVITY_MODULE_PNG", get_image($image_path . $activity_fields['MODULE'] . '', 'border="0" alt="' . $activity_fields['NAME'] . '"'));
         if ($oddRow) {
             //todo move to themes
             $xtpl->assign("ROW_COLOR", 'oddListRow');
             $xtpl->assign("BG_COLOR", $odd_bg);
         } else {
             //todo move to themes
             $xtpl->assign("ROW_COLOR", 'evenListRow');
             $xtpl->assign("BG_COLOR", $even_bg);
         }
         $oddRow = !$oddRow;
         $xtpl->parse("history.row");
         // Put the rows in.
     }
     $xtpl->parse("history");
     $xtpl->out("history");
     insert_popup_footer();
 }
Exemple #15
0
 /**
  *
  */
 function process_page()
 {
     global $focus;
     global $mod_strings;
     global $app_strings;
     global $app_list_strings;
     global $currentModule;
     global $odd_bg;
     global $even_bg;
     global $timedate;
     $history_list = array();
     if (!empty($_REQUEST['record'])) {
         $result = $focus->retrieve($_REQUEST['record']);
         if ($result == null) {
             sugar_die($app_strings['ERROR_NO_RECORD']);
         }
     }
     $activitiesRels = array('tasks' => 'Task', 'meetings' => 'Meeting', 'calls' => 'Call', 'emails' => 'Email', 'notes' => 'Note');
     //Setup the arrays to store the linked records.
     foreach ($activitiesRels as $relMod => $beanName) {
         $varname = "focus_" . $relMod . "_list";
         ${$varname} = array();
     }
     foreach ($focus->get_linked_fields() as $field => $def) {
         if ($focus->load_relationship($field)) {
             $relTable = $focus->{$field}->getRelatedTableName();
             if (in_array($relTable, array_keys($activitiesRels))) {
                 $varname = "focus_" . $relTable . "_list";
                 ${$varname} = sugarArrayMerge(${$varname}, $focus->get_linked_beans($field, $activitiesRels[$relTable]));
             }
         }
     }
     foreach ($focus_tasks_list as $task) {
         $sort_date_time = '';
         if ($task->date_due == '0000-00-00') {
             $date_due = '';
         } else {
             $date_due = $task->date_due;
         }
         if (!empty($task->date_due) and !empty($task->time_due)) {
             $sort_date_time = $timedate->to_db_date_time($task->date_due, $task->time_due);
             $sort_date_time = implode(' ', $sort_date_time);
             // kbrill - Bug #16714
             //$sort_date_time=$timedate->handle_offset($sort_date_time,'Y-m-d H:i:s',true);
         }
         if ($task->status != "Not Started" && $task->status != "In Progress" && $task->status != "Pending Input") {
             $history_list[] = array('name' => $task->name, 'id' => $task->id, 'type' => "Task", 'direction' => '', 'module' => "Tasks", 'status' => $task->status, 'parent_id' => $task->parent_id, 'parent_type' => $task->parent_type, 'parent_name' => $task->parent_name, 'contact_id' => $task->contact_id, 'contact_name' => $task->contact_name, 'date_modified' => $date_due, 'description' => $this->getTaskDetails($task), 'date_type' => $app_strings['DATA_TYPE_DUE'], 'sort_value' => $sort_date_time);
         } else {
             $open_activity_list[] = array('name' => $task->name, 'id' => $task->id, 'type' => "Task", 'direction' => '', 'module' => "Tasks", 'status' => $task->status, 'parent_id' => $task->parent_id, 'parent_type' => $task->parent_type, 'parent_name' => $task->parent_name, 'contact_id' => $task->contact_id, 'contact_name' => $task->contact_name, 'date_due' => $date_due, 'description' => $this->getTaskDetails($task), 'date_type' => $app_strings['DATA_TYPE_DUE']);
         }
     }
     // end Tasks
     foreach ($focus_meetings_list as $meeting) {
         if ($meeting->status != "Planned") {
             $sort_date_time = '';
             if (!empty($meeting->date_start) and !empty($meeting->time_start)) {
                 $sort_date_time = $timedate->to_db_date_time($meeting->date_start, $meeting->time_start);
                 $sort_date_time = implode(' ', $sort_date_time);
                 // kbrill - Bug #16714
                 //$sort_date_time=$timedate->handle_offset($sort_date_time,'Y-m-d H:i:s',true);
             }
             $history_list[] = array('name' => $meeting->name, 'id' => $meeting->id, 'type' => "Meeting", 'direction' => '', 'module' => "Meetings", 'status' => $meeting->status, 'parent_id' => $meeting->parent_id, 'parent_type' => $meeting->parent_type, 'parent_name' => $meeting->parent_name, 'contact_id' => $meeting->contact_id, 'contact_name' => $meeting->contact_name, 'date_modified' => $meeting->date_start, 'description' => $this->formatDescription($meeting->description), 'date_type' => $app_strings['DATA_TYPE_START'], 'sort_value' => $sort_date_time);
         } else {
             $open_activity_list[] = array('name' => $meeting->name, 'id' => $meeting->id, 'type' => "Meeting", 'direction' => '', 'module' => "Meetings", 'status' => $meeting->status, 'parent_id' => $meeting->parent_id, 'parent_type' => $meeting->parent_type, 'parent_name' => $meeting->parent_name, 'contact_id' => $meeting->contact_id, 'contact_name' => $meeting->contact_name, 'date_due' => $meeting->date_start, 'description' => $this->formatDescription($meeting->description), 'date_type' => $app_strings['DATA_TYPE_START']);
         }
     }
     // end Meetings
     foreach ($focus_calls_list as $call) {
         if ($call->status != "Planned") {
             $sort_date_time = '';
             if (!empty($call->date_start) and !empty($call->time_start)) {
                 $sort_date_time = $timedate->to_db_date_time($call->date_start, $call->time_start);
                 $sort_date_time = implode(' ', $sort_date_time);
                 // kbrill - Bug #16714
                 //$sort_date_time=$timedate->handle_offset($sort_date_time,'Y-m-d H:i:s',true);
             } elseif (!empty($call->date_start) && empty($call->time_start)) {
                 //jc - Bug#19862
                 //for some reason the calls module does not populate the time_start variable in
                 //this case, so the date_start attribute contains the information we need
                 //to determine where in the history this call belongs.
                 //using swap_formats to get from the format '03/31/2008 09:45pm' to the format
                 //'2008-03-31 09:45:00'
                 $sort_date_time = $timedate->swap_formats($call->date_start, $timedate->get_date_time_format(), $timedate->get_db_date_time_format());
             }
             $history_list[] = array('name' => $call->name, 'id' => $call->id, 'type' => "Call", 'direction' => $call->direction, 'module' => "Calls", 'status' => $call->status, 'parent_id' => $call->parent_id, 'parent_type' => $call->parent_type, 'parent_name' => $call->parent_name, 'contact_id' => $call->contact_id, 'contact_name' => $call->contact_name, 'date_modified' => $call->date_start, 'description' => $this->formatDescription($call->description), 'date_type' => $app_strings['DATA_TYPE_START'], 'sort_value' => $sort_date_time);
         } else {
             $open_activity_list[] = array('name' => $call->name, 'id' => $call->id, 'direction' => $call->direction, 'type' => "Call", 'module' => "Calls", 'status' => $call->status, 'parent_id' => $call->parent_id, 'parent_type' => $call->parent_type, 'parent_name' => $call->parent_name, 'contact_id' => $call->contact_id, 'contact_name' => $call->contact_name, 'date_due' => $call->date_start, 'description' => $this->formatDescription($call->description), 'date_type' => $app_strings['DATA_TYPE_START']);
         }
     }
     // end Calls
     foreach ($focus_emails_list as $email) {
         $sort_date_time = '';
         if (!empty($email->date_start) and !empty($email->time_start)) {
             $sort_date_time = $timedate->to_db_date_time($email->date_start, $email->time_start);
             $sort_date_time = implode(' ', $sort_date_time);
             // kbrill - Bug #16714
             //$sort_date_time=$timedate->handle_offset($sort_date_time,'Y-m-d H:i:s',true);
         }
         $history_list[] = array('name' => $email->name, 'id' => $email->id, 'type' => "Email", 'direction' => '', 'module' => "Emails", 'status' => '', 'parent_id' => $email->parent_id, 'parent_type' => $email->parent_type, 'parent_name' => $email->parent_name, 'contact_id' => $email->contact_id, 'contact_name' => $email->contact_name, 'date_modified' => $email->date_start . " " . $email->time_start, 'description' => $this->getEmailDetails($email), 'date_type' => $app_strings['DATA_TYPE_SENT'], 'sort_value' => $sort_date_time);
     }
     //end Emails
     foreach ($focus_notes_list as $note) {
         if (!empty($note->date_modified)) {
             $sort_date_time = $timedate->swap_formats($note->date_modified, $timedate->get_date_time_format(), $timedate->get_db_date_time_format());
         }
         $history_list[] = array('name' => $note->name, 'id' => $note->id, 'type' => "Note", 'direction' => '', 'module' => "Notes", 'status' => '', 'parent_id' => $note->parent_id, 'parent_type' => $note->parent_type, 'parent_name' => $note->parent_name, 'contact_id' => $note->contact_id, 'contact_name' => $note->contact_name, 'date_modified' => $note->date_modified, 'description' => $this->formatDescription($note->description), 'date_type' => $app_strings['DATA_TYPE_MODIFIED'], 'sort_value' => $sort_date_time);
         if (!empty($note->filename)) {
             $count = count($history_list);
             $count--;
             $history_list[$count]['filename'] = $note->filename;
             $history_list[$count]['fileurl'] = UploadFile::get_url($note->filename, $note->id);
         }
     }
     // end Notes
     $xtpl = new XTemplate('modules/Activities/Popup_picker.html');
     $xtpl->assign('MOD', $mod_strings);
     $xtpl->assign('APP', $app_strings);
     insert_popup_header();
     //output header
     echo "<table width='100%' cellpadding='0' cellspacing='0'><tr><td>";
     echo get_module_title($focus->module_dir, translate('LBL_MODULE_NAME', $focus->module_dir) . ": " . $focus->name, false);
     echo "</td><td align='right' class='moduleTitle'>";
     echo "<A href='javascript:print();' class='utilsLink'><img src='" . SugarThemeRegistry::current()->getImageURL("print.gif") . "' width='13' height='13' alt='" . $app_strings['LNK_PRINT'] . "' border='0' align='absmiddle'></a>&nbsp;<A href='javascript:print();' class='utilsLink'>" . $app_strings['LNK_PRINT'] . "</A>\n";
     echo "</td></tr></table>";
     $oddRow = true;
     if (count($history_list) > 0) {
         $history_list = array_csort($history_list, 'sort_value', SORT_DESC);
     }
     foreach ($history_list as $activity) {
         $activity_fields = array('ID' => $activity['id'], 'NAME' => $activity['name'], 'MODULE' => $activity['module'], 'CONTACT_NAME' => $activity['contact_name'], 'CONTACT_ID' => $activity['contact_id'], 'PARENT_TYPE' => $activity['parent_type'], 'PARENT_NAME' => $activity['parent_name'], 'PARENT_ID' => $activity['parent_id'], 'DATE' => $activity['date_modified'], 'DESCRIPTION' => $activity['description'], 'DATE_TYPE' => $activity['date_type']);
         if (empty($activity['direction'])) {
             $activity_fields['TYPE'] = $app_list_strings['activity_dom'][$activity['type']];
         } else {
             $activity_fields['TYPE'] = $app_list_strings['call_direction_dom'][$activity['direction']] . ' ' . $app_list_strings['activity_dom'][$activity['type']];
         }
         switch ($activity['type']) {
             case 'Call':
                 $activity_fields['STATUS'] = $app_list_strings['call_status_dom'][$activity['status']];
                 break;
             case 'Meeting':
                 $activity_fields['STATUS'] = $app_list_strings['meeting_status_dom'][$activity['status']];
                 break;
             case 'Task':
                 $activity_fields['STATUS'] = $app_list_strings['task_status_dom'][$activity['status']];
                 break;
         }
         if (isset($activity['location'])) {
             $activity_fields['LOCATION'] = $activity['location'];
         }
         if (isset($activity['filename'])) {
             $activity_fields['ATTACHMENT'] = "<a href='index.php?entryPoint=download&id=" . $activity['id'] . "&type=Notes' target='_blank'>" . SugarThemeRegistry::current()->getImage("attachment", "alt='" . $activity['filename'] . "' border='0' align='absmiddle'") . "</a>";
         }
         if (isset($activity['parent_type'])) {
             $activity_fields['PARENT_MODULE'] = $activity['parent_type'];
         }
         $xtpl->assign("ACTIVITY", $activity_fields);
         $xtpl->assign("ACTIVITY_MODULE_PNG", SugarThemeRegistry::current()->getImage($activity_fields['MODULE'] . '', 'border="0" alt="' . $activity_fields['NAME'] . '"'));
         if ($oddRow) {
             //todo move to themes
             $xtpl->assign("ROW_COLOR", 'oddListRow');
             $xtpl->assign("BG_COLOR", $odd_bg);
         } else {
             //todo move to themes
             $xtpl->assign("ROW_COLOR", 'evenListRow');
             $xtpl->assign("BG_COLOR", $even_bg);
         }
         $oddRow = !$oddRow;
         $xtpl->parse("history.row");
         // Put the rows in.
     }
     $xtpl->parse("history");
     $xtpl->out("history");
     insert_popup_footer();
 }
Exemple #16
0
    if ($call->status != "Planned") {
        $history_list[] = array('name' => $call->name, 'id' => $call->id, 'type' => "Call", 'direction' => $call->direction, 'module' => "Calls", 'status' => $call->status, 'parent_id' => $call->parent_id, 'parent_type' => $call->parent_type, 'parent_name' => $call->parent_name, 'contact_id' => $call->contact_id, 'contact_name' => $call->contact_name, 'date_modified' => $call->date_modified);
    } else {
        $open_activity_list[] = array('name' => $call->name, 'id' => $call->id, 'direction' => $call->direction, 'type' => "Call", 'module' => "Calls", 'status' => $call->status, 'parent_id' => $call->parent_id, 'parent_type' => $call->parent_type, 'parent_name' => $call->parent_name, 'contact_id' => $call->contact_id, 'contact_name' => $call->contact_name, 'date_due' => $call->date_start);
    }
}
foreach ($focus_emails_list as $email) {
    $history_list[] = array('name' => $email->name, 'id' => $email->id, 'type' => "Email", 'direction' => '', 'module' => "Emails", 'status' => '', 'parent_id' => $email->parent_id, 'parent_type' => $email->parent_type, 'parent_name' => $email->parent_name, 'contact_id' => $email->contact_id, 'contact_name' => $email->contact_name, 'date_modified' => $email->date_start . " " . $email->time_start);
}
foreach ($focus_notes_list as $note) {
    $history_list[] = array('name' => $note->name, 'id' => $note->id, 'type' => "Note", 'direction' => '', 'module' => "Notes", 'status' => '', 'parent_id' => $note->parent_id, 'parent_type' => $note->parent_type, 'parent_name' => $note->parent_name, 'contact_id' => $note->contact_id, 'contact_name' => $note->contact_name, 'date_modified' => $note->date_modified);
    if (!empty($note->filename)) {
        $count = count($history_list);
        $count--;
        $history_list[$count]['filename'] = $note->filename;
        $history_list[$count]['fileurl'] = UploadFile::get_url($note->filename, $note->id);
    }
}
if ($currentModule == 'Contacts') {
    $xtpl = new XTemplate('modules/Activities/SubPanelViewContacts.html');
    $xtpl->assign("CONTACT_ID", $focus->id);
} else {
    $xtpl = new XTemplate('modules/Activities/SubPanelView.html');
}
$xtpl->assign("DELETE_INLINE_PNG", SugarThemeRegistry::current()->getImage('delete_inline', 'align="absmiddle" alt="' . $app_strings['LNK_DELETE'] . '" border="0"'));
$xtpl->assign("EDIT_INLINE_PNG", SugarThemeRegistry::current()->getImage('edit_inline', 'align="absmiddle" alt="' . $app_strings['LNK_EDIT'] . '" border="0"'));
$xtpl->assign("MOD", $current_module_strings);
$xtpl->assign("APP", $app_strings);
$button = "<form border='0' action='index.php' method='post' name='form' id='form'>\n";
$button .= "<input type='hidden' name='module'>\n";
$button .= "<input type='hidden' name='type'>\n";
$GLOBALS['log']->info("Document revision edit view");
$xtpl = new XTemplate('modules/DocumentRevisions/EditView.html');
$xtpl->assign("MOD", $mod_strings);
$xtpl->assign("APP", $app_strings);
if (isset($_REQUEST['return_module'])) {
    $xtpl->assign("RETURN_MODULE", $_REQUEST['return_module']);
}
if (isset($_REQUEST['return_action'])) {
    $xtpl->assign("RETURN_ACTION", $_REQUEST['return_action']);
}
if (isset($_REQUEST['return_id'])) {
    $xtpl->assign("RETURN_ID", $_REQUEST['return_id']);
}
$xtpl->assign("THEME", $theme);
$xtpl->assign("IMAGE_PATH", $image_path);
$xtpl->assign("PRINT_URL", "index.php?" . $GLOBALS['request_string']);
$xtpl->assign("JAVASCRIPT", get_set_focus_js() . get_validate_record_document_revision_js());
$focus->fill_document_name_revision($_REQUEST['return_id']);
$xtpl->assign("ID", $focus->id);
$xtpl->assign("DOCUMENT_NAME", $_REQUEST['document_name']);
$xtpl->assign("CURRENT_REVISION", $_REQUEST['document_revision']);
$xtpl->assign("FILE_URL", UploadFile::get_url($_REQUEST['document_filename'], $_REQUEST['document_revision_id']));
$xtpl->parse("main");
$xtpl->out("main");
//implements required fields check based on the required fields list defined in the bean.
require_once 'include/javascript/javascript.php';
$javascript = new javascript();
$javascript->setFormName('DocumentRevisionEditView');
$javascript->setSugarBean($focus);
$javascript->addAllFields('');
echo $javascript->getScript();
Exemple #18
0
    $smarty->assign("RETURN_MODULE", $_REQUEST['return_module']);
}
if (isset($_REQUEST['return_action'])) {
    $smarty->assign("RETURN_ACTION", $_REQUEST['return_action']);
}
if (isset($_REQUEST['return_id'])) {
    $smarty->assign("RETURN_ID", $_REQUEST['return_id']);
}
$smarty->assign("THEME", $theme);
$smarty->assign("IMAGE_PATH", $image_path);
//$smarty->assign("PRINT_URL", "phprint.php?jt=".session_id().$GLOBALS['request_string']);
$smarty->assign("ID", $focus->id);
$category = getParentTab();
$smarty->assign("CATEGORY", $category);
if (isset($focus->filename) && $focus->filename != '') {
    $fileurl = "<a href=\"" . UploadFile::get_url($focus->filename, $focus->id) . "\" target=\"_blank\">" . $focus->filename . "</a>";
    $smarty->assign("FILELINK", $fileurl);
}
$smarty->assign("SINGLE_MOD", 'Note');
if (isPermitted($module, "EditView", $_REQUEST['record']) == 'yes') {
    $smarty->assign("EDIT", "permitted");
    $smarty->assign("EDIT_PERMISSION", "yes");
} else {
    $smarty->assign("EDIT_PERMISSION", "no");
}
$check_button = Button_Check($module);
$smarty->assign("CHECK", $check_button);
if (isPermitted($module, "Create", $_REQUEST['record']) == 'yes') {
    $smarty->assign("EDIT_DUPLICATE", "permitted");
}
if (isPermitted($module, "Delete", $_REQUEST['record']) == 'yes') {