diff --git a/js/activity.js b/js/activity.js index 3824c8e23..01dba26ce 100755 --- a/js/activity.js +++ b/js/activity.js @@ -224,7 +224,8 @@ function Activity_editEntry(activityID, dataItemID, dataItemType, sessionCookie) /* Create the cell that will contain the edit form. */ var editTD = document.createElement('td'); - editTD.setAttribute('colspan', '6'); + var columnCount = editRow.cells.length; + editTD.setAttribute('colspan', columnCount.toString()); editTD.setAttribute('valign', 'top'); editTD.setAttribute('align', 'left'); diff --git a/lib/ActivityEntries.php b/lib/ActivityEntries.php index aae547979..5d4fccd0b 100755 --- a/lib/ActivityEntries.php +++ b/lib/ActivityEntries.php @@ -492,6 +492,69 @@ public function getAllByDataItem($dataItemID, $dataItemType) return $this->_db->getAllAssoc($sql); } + /** + * Returns all activity entries for contacts belonging to a company. + * + * @param integer Company ID. + * @return resultset Activity entries data. + */ + public function getAllByCompany($companyID) + { + $sql = sprintf( + "SELECT + activity.activity_id AS activityID, + activity.data_item_id AS dataItemID, + activity.joborder_id AS jobOrderID, + activity.notes AS notes, + DATE_FORMAT( + activity.date_created, '%%m-%%d-%%y (%%h:%%i %%p)' + ) AS dateCreated, + activity.date_created AS dateCreatedSort, + activity.type AS type, + activity_type.short_description AS typeDescription, + entered_by_user.first_name AS enteredByFirstName, + entered_by_user.last_name AS enteredByLastName, + contact.contact_id AS contactID, + contact.first_name AS contactFirstName, + contact.last_name AS contactLastName, + IF( + ISNULL(joborder.title), + 'General', + CONCAT(joborder.title, ' (', company.name, ')') + ) AS regarding, + joborder.title AS regardingJobTitle, + company.name AS regardingCompanyName + FROM + activity + LEFT JOIN user AS entered_by_user + ON activity.entered_by = entered_by_user.user_id + LEFT JOIN activity_type + ON activity.type = activity_type.activity_type_id + LEFT JOIN joborder + ON activity.joborder_id = joborder.joborder_id + LEFT JOIN company + ON joborder.company_id = company.company_id + INNER JOIN contact + ON activity.data_item_id = contact.contact_id + WHERE + contact.company_id = %s + AND + activity.data_item_type = %s + AND + activity.site_id = %s + AND + contact.site_id = %s + ORDER BY + dateCreatedSort ASC", + $this->_db->makeQueryInteger($companyID), + $this->_db->makeQueryInteger(DATA_ITEM_CONTACT), + $this->_db->makeQueryInteger($this->_siteID), + $this->_db->makeQueryInteger($this->_siteID) + ); + + return $this->_db->getAllAssoc($sql); + } + /** * Returns all activity types and their descriptions. * diff --git a/modules/candidates/Show.tpl b/modules/candidates/Show.tpl index 92ca84f4e..7058aabdf 100755 --- a/modules/candidates/Show.tpl +++ b/modules/candidates/Show.tpl @@ -586,7 +586,7 @@ use OpenCATS\UI\CandidateDuplicateQuickActionMenu; Date Type - Entered + Entered By Regarding Notes isPopup): ?> diff --git a/modules/companies/CompaniesUI.php b/modules/companies/CompaniesUI.php index 59c5f6435..311e4b3ec 100755 --- a/modules/companies/CompaniesUI.php +++ b/modules/companies/CompaniesUI.php @@ -33,6 +33,7 @@ include_once(LEGACY_ROOT . '/lib/Companies.php'); include_once(LEGACY_ROOT . '/lib/Contacts.php'); include_once(LEGACY_ROOT . '/lib/JobOrders.php'); +include_once(LEGACY_ROOT . '/lib/ActivityEntries.php'); include_once(LEGACY_ROOT . '/lib/Attachments.php'); include_once(LEGACY_ROOT . '/lib/Export.php'); include_once(LEGACY_ROOT . '/lib/ListEditor.php'); @@ -414,6 +415,42 @@ private function show() } } + $activityEntries = new ActivityEntries($this->_siteID); + $activityRS = $activityEntries->getAllByCompany($companyID); + if (!empty($activityRS)) + { + foreach ($activityRS as $rowIndex => $row) + { + if (empty($activityRS[$rowIndex]['notes'])) + { + $activityRS[$rowIndex]['notes'] = '(No Notes)'; + } + + if (empty($activityRS[$rowIndex]['jobOrderID']) || + empty($activityRS[$rowIndex]['regarding'])) + { + $activityRS[$rowIndex]['regarding'] = 'General'; + } + + $activityRS[$rowIndex]['enteredByAbbrName'] = StringUtility::makeInitialName( + $activityRS[$rowIndex]['enteredByFirstName'], + $activityRS[$rowIndex]['enteredByLastName'], + false, + LAST_NAME_MAXLEN + ); + + $activityRS[$rowIndex]['contactFullName'] = trim( + $activityRS[$rowIndex]['contactFirstName'] . ' ' . + $activityRS[$rowIndex]['contactLastName'] + ); + + if ($activityRS[$rowIndex]['contactFullName'] == '') + { + $activityRS[$rowIndex]['contactFullName'] = '(Unknown Contact)'; + } + } + } + /* Add an MRU entry. */ $_SESSION['CATS']->getMRU()->addEntry( DATA_ITEM_COMPANY, $companyID, $data['name'] @@ -442,10 +479,12 @@ private function show() $this->_template->assign('extraFieldRS', $extraFieldRS); $this->_template->assign('isShortNotes', $isShortNotes); $this->_template->assign('jobOrdersRS', $jobOrdersRS); + $this->_template->assign('activityRS', $activityRS); $this->_template->assign('contactsRS', $contactsRS); $this->_template->assign('contactsRSWC', $contactsRSWC); $this->_template->assign('privledgedUser', $privledgedUser); $this->_template->assign('companyID', $companyID); + $this->_template->assign('sessionCookie', $_SESSION['CATS']->getCookie()); if (!eval(Hooks::get('CLIENTS_SHOW'))) return; diff --git a/modules/companies/Show.tpl b/modules/companies/Show.tpl index ff6100d6a..f470ba5b0 100755 --- a/modules/companies/Show.tpl +++ b/modules/companies/Show.tpl @@ -2,7 +2,7 @@ include_once('./vendor/autoload.php'); use OpenCATS\UI\QuickActionMenu; ?> -data['name'], array( 'js/sorttable.js', 'js/attachment.js')); ?> +data['name'], array( 'js/activity.js', 'js/sorttable.js', 'js/attachment.js')); ?> active); ?>
@@ -402,6 +402,53 @@ use OpenCATS\UI\QuickActionMenu; + +
+
+ +

Activity

+ + + + + + + + + + + + activityRS as $rowNumber => $activityData): ?> + + + + + + + + + + +
DateTypeContactEntered ByRegardingNotesAction
_($activityData['dateCreated']); ?>_($activityData['typeDescription']); ?> + + + _($activityData['contactFullName']); ?> + + + _($activityData['contactFullName']); ?> + + _($activityData['enteredByAbbrName']); ?>_($activityData['regarding']); ?>_($activityData['notes']); ?> + getUserAccessLevel('contacts.editActivity') >= ACCESS_LEVEL_EDIT): ?> + + + + + getUserAccessLevel('contacts.deleteActivity') >= ACCESS_LEVEL_EDIT): ?> + + + + +
diff --git a/modules/contacts/Show.tpl b/modules/contacts/Show.tpl index 603b3c354..ec38b46d9 100755 --- a/modules/contacts/Show.tpl +++ b/modules/contacts/Show.tpl @@ -265,7 +265,7 @@ use OpenCATS\UI\QuickActionMenu; Date Type - Entered + Entered By Regarding Notes Action