Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion js/activity.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');

Expand Down
63 changes: 63 additions & 0 deletions lib/ActivityEntries.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down
2 changes: 1 addition & 1 deletion modules/candidates/Show.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,7 @@ use OpenCATS\UI\CandidateDuplicateQuickActionMenu;
<tr>
<th align="left" width="125">Date</th>
<th align="left" width="90">Type</th>
<th align="left" width="90">Entered</th>
<th align="left" width="90">Entered By</th>
<th align="left" width="250">Regarding</th>
<th align="left">Notes</th>
<?php if (!$this->isPopup): ?>
Expand Down
39 changes: 39 additions & 0 deletions modules/companies/CompaniesUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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']
Expand Down Expand Up @@ -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;

Expand Down
49 changes: 48 additions & 1 deletion modules/companies/Show.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
include_once('./vendor/autoload.php');
use OpenCATS\UI\QuickActionMenu;
?>
<?php TemplateUtility::printHeader('Company - '.$this->data['name'], array( 'js/sorttable.js', 'js/attachment.js')); ?>
<?php TemplateUtility::printHeader('Company - '.$this->data['name'], array( 'js/activity.js', 'js/sorttable.js', 'js/attachment.js')); ?>
<?php TemplateUtility::printHeaderBlock(); ?>
<?php TemplateUtility::printTabs($this->active); ?>
<div id="main">
Expand Down Expand Up @@ -402,6 +402,53 @@ use OpenCATS\UI\QuickActionMenu;
</a>
<?php endif; ?>
<!-- /CONTACT INFO -->

<br clear="all" />
<br />

<p class="note">Activity</p>
<table id="activityTable" class="sortable">
<tr>
<th align="left" width="125">Date</th>
<th align="left" width="90">Type</th>
<th align="left" width="140">Contact</th>
<th align="left" width="90">Entered By</th>
<th align="left" width="250">Regarding</th>
<th align="left">Notes</th>
<th align="left" width="40">Action</th>
</tr>

<?php foreach ($this->activityRS as $rowNumber => $activityData): ?>
<tr class="<?php TemplateUtility::printAlternatingRowClass($rowNumber); ?>">
<td align="left" valign="top" id="activityDate<?php echo($activityData['activityID']); ?>"><?php $this->_($activityData['dateCreated']); ?></td>
<td align="left" valign="top" id="activityType<?php echo($activityData['activityID']); ?>"><?php $this->_($activityData['typeDescription']); ?></td>
<td align="left" valign="top">
<?php if (!empty($activityData['contactID'])): ?>
<a href="<?php echo(CATSUtility::getIndexName()); ?>?m=contacts&amp;a=show&amp;contactID=<?php $this->_($activityData['contactID']); ?>">
<?php $this->_($activityData['contactFullName']); ?>
</a>
<?php else: ?>
<?php $this->_($activityData['contactFullName']); ?>
<?php endif; ?>
</td>
<td align="left" valign="top"><?php $this->_($activityData['enteredByAbbrName']); ?></td>
<td align="left" valign="top" id="activityRegarding<?php echo($activityData['activityID']); ?>"><?php $this->_($activityData['regarding']); ?></td>
<td align="left" valign="top" id="activityNotes<?php echo($activityData['activityID']); ?>"><?php $this->_($activityData['notes']); ?></td>
<td align="center">
<?php if ($this->getUserAccessLevel('contacts.editActivity') >= ACCESS_LEVEL_EDIT): ?>
<a href="#" id="editActivity<?php echo($activityData['activityID']); ?>" onclick="Activity_editEntry(<?php echo($activityData['activityID']); ?>, <?php echo($activityData['contactID']); ?>, <?php echo(DATA_ITEM_CONTACT); ?>, '<?php echo($this->sessionCookie); ?>'); return false;">
<img src="images/actions/edit.gif" width="16" height="16" alt="" class="absmiddle" border="0" title="Edit"/>
</a>
<?php endif; ?>
<?php if ($this->getUserAccessLevel('contacts.deleteActivity') >= ACCESS_LEVEL_EDIT): ?>
<a href="#" id="deleteActivity<?php echo($activityData['activityID']); ?>" onclick="Activity_deleteEntry(<?php echo($activityData['activityID']); ?>, '<?php echo($this->sessionCookie); ?>'); return false;">
<img src="images/actions/delete.gif" width="16" height="16" alt="" class="absmiddle" border="0" title="Delete"/>
</a>
<?php endif; ?>
</td>
</tr>
<?php endforeach; ?>
</table>
</div>
</div>

Expand Down
2 changes: 1 addition & 1 deletion modules/contacts/Show.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ use OpenCATS\UI\QuickActionMenu;
<tr>
<th align="left" width="125">Date</th>
<th align="left" width="90">Type</th>
<th align="left" width="90">Entered</th>
<th align="left" width="90">Entered By</th>
<th align="left" width="250">Regarding</th>
<th align="left">Notes</th>
<th align="left" width="40">Action</th>
Expand Down