Skip to content
Merged
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 modules/candidates/AddActivityChangeStatusModal.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,8 @@
<div id="activityNoteDiv" style="margin-top: 4px;">
<span id="addActivitySpanA">Activity Type</span><br />
<select id="activityTypeID" name="activityTypeID" class="inputbox" style="width: 150px; margin-bottom: 4px;">
<option selected="selected" value="<?php echo(ACTIVITY_CALL); ?>">Call</option>
<option selected="selected" value="">-- Select --</option>
<option value="<?php echo(ACTIVITY_CALL); ?>">Call</option>
<option value="<?php echo(ACTIVITY_CALL_TALKED); ?>">Call (Talked)</option>
<option value="<?php echo(ACTIVITY_CALL_LVM); ?>">Call (LVM)</option>
<option value="<?php echo(ACTIVITY_CALL_MISSED); ?>">Call (Missed)</option>
Expand Down
17 changes: 11 additions & 6 deletions modules/candidates/CandidatesUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -3037,13 +3037,20 @@ private function _addActivityChangeStatus($isJobOrdersMode, $regardingID,

if ($this->isChecked('addActivity', $_POST))
{
/* Bail out if we don't have a valid job order ID. */
if (!$this->isOptionalIDValid('activityTypeID', $_POST))
if (!$this->isRequiredIDValid('activityTypeID', $_POST))
{
CommonErrors::fatalModal(COMMONERROR_BADINDEX, $this, 'Invalid activity type ID.');
$this->fatalModal('You must select an activity type.');
}

$activityTypeID = $_POST['activityTypeID'];
$activityTypeID = (int) $_POST['activityTypeID'];
$activityEntries = new ActivityEntries($this->_siteID);
$activityTypes = $activityEntries->getTypes();
if (ResultSetUtility::findRowByColumnValue(
$activityTypes, 'typeID', $activityTypeID
) === false)
{
CommonErrors::fatalModal(COMMONERROR_BADINDEX, $this, 'Invalid activity type ID.');
}

$activityNote = $this->getTrimmedInput('activityNote', $_POST);

Expand All @@ -3063,7 +3070,6 @@ private function _addActivityChangeStatus($isJobOrdersMode, $regardingID,
}

/* Add the activity entry. */
$activityEntries = new ActivityEntries($this->_siteID);
$activityID = $activityEntries->add(
$candidateID,
DATA_ITEM_CANDIDATE,
Expand All @@ -3072,7 +3078,6 @@ private function _addActivityChangeStatus($isJobOrdersMode, $regardingID,
$this->_userID,
$regardingID
);
$activityTypes = $activityEntries->getTypes();
$activityTypeDescription = ResultSetUtility::getColumnValueByIDValue(
$activityTypes, 'typeID', $activityTypeID, 'type'
);
Expand Down
54 changes: 38 additions & 16 deletions modules/candidates/activityvalidator.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,16 @@
/*
* CATS
* OpenCATS
* Candidates Form Validation
*
* Copyright (C) 2005 - 2007 Cognizo Technologies, Inc.
* All rights reserved.
*
* $Id: activityvalidator.js 2336 2007-04-14 22:01:51Z will $
*/

function checkActivityForm(form)
{
var errorMessage = '';
var errorMessage = "";

errorMessage += checkActivityType();

Check warning on line 10 in modules/candidates/activityvalidator.js

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

modules/candidates/activityvalidator.js#L10

'checkActivityType' was used before it was defined.
errorMessage += checkEventTitle();

if (errorMessage != '')
if (errorMessage != "")
{
alert("Form Error:\n" + errorMessage);
return false;
Expand All @@ -23,27 +19,53 @@
return true;
}

function checkActivityType()
{
var errorMessage = "";

var addActivity = document.getElementById("addActivity").checked;
if (!addActivity)
{
return "";
}

var fieldValue = document.getElementById("activityTypeID").value;
var fieldLabel = document.getElementById("addActivitySpanA");
if (fieldValue == "")
{
errorMessage = " - You must select an activity type.\n";

fieldLabel.style.color = "#ff0000";
}
else
{
fieldLabel.style.color = "#000";
}

return errorMessage;
}

function checkEventTitle()
{
var errorMessage = '';
var errorMessage = "";

scheduleEvent = document.getElementById('scheduleEvent').checked;
var scheduleEvent = document.getElementById("scheduleEvent").checked;
if (!scheduleEvent)
{
return '';
return "";
}

fieldValue = document.getElementById('title').value;
fieldLabel = document.getElementById('titleLabel');
if (fieldValue == '')
var fieldValue = document.getElementById("title").value;
var fieldLabel = document.getElementById("titleLabel");
if (fieldValue == "")
{
errorMessage = " - You must enter an event title.\n";

fieldLabel.style.color = '#ff0000';
fieldLabel.style.color = "#ff0000";
}
else
{
fieldLabel.style.color = '#000';
fieldLabel.style.color = "#000";
}

return errorMessage;
Expand Down
5 changes: 3 additions & 2 deletions modules/contacts/AddActivityScheduleEventModal.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
window.CATSUserDateFormat = '<?php echo($_SESSION['CATS']->isDateDMY() ? 'DD-MM-YY' : 'MM-DD-YY'); ?>';
</script>

<form name="logActivityForm" id="logActivityForm" action="<?php echo(CATSUtility::getIndexName()); ?>?m=contacts&amp;a=addActivityScheduleEvent<?php if($this->onlyScheduleEvent): ?>&amp;onlyScheduleEvent=true<?php endif; ?>" method="post" autocomplete="off">
<form name="logActivityForm" id="logActivityForm" action="<?php echo(CATSUtility::getIndexName()); ?>?m=contacts&amp;a=addActivityScheduleEvent<?php if($this->onlyScheduleEvent): ?>&amp;onlyScheduleEvent=true<?php endif; ?>" method="post" onsubmit="return checkActivityForm(document.logActivityForm);" autocomplete="off">
<input type="hidden" name="postback" id="postback" value="postback" />
<input type="hidden" id="contactID" name="contactID" value="<?php echo($this->contactID); ?>" />

Expand Down Expand Up @@ -41,7 +41,8 @@
<div id="activityNoteDiv" style="margin-top: 4px;">
<span id="addActivitySpanA">Activity Type</span><br />
<select id="activityTypeID" name="activityTypeID" class="inputbox" style="width: 150px; margin-bottom: 4px;">
<option selected="selected" value="<?php echo(ACTIVITY_CALL); ?>">Call</option>
<option selected="selected" value="">-- Select --</option>
<option value="<?php echo(ACTIVITY_CALL); ?>">Call</option>
<option value="<?php echo(ACTIVITY_CALL_TALKED); ?>">Call (Talked)</option>
<option value="<?php echo(ACTIVITY_CALL_LVM); ?>">Call (LVM)</option>
<option value="<?php echo(ACTIVITY_CALL_MISSED); ?>">Call (Missed)</option>
Expand Down
17 changes: 11 additions & 6 deletions modules/contacts/ContactsUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -1346,20 +1346,26 @@ private function _addActivityScheduleEvent($regardingID, $directoryOverride = ''

if ($this->isChecked('addActivity', $_POST))
{
/* Bail out if we don't have a valid job order ID. */
if (!$this->isOptionalIDValid('activityTypeID', $_POST))
if (!$this->isRequiredIDValid('activityTypeID', $_POST))
{
CommonErrors::fatalModal(COMMONERROR_BADINDEX, $this, 'Invalid activity type ID.');
$this->fatalModal('You must select an activity type.');
}

$activityTypeID = $_POST['activityTypeID'];
$activityTypeID = (int) $_POST['activityTypeID'];
$activityEntries = new ActivityEntries($this->_siteID);
$activityTypes = $activityEntries->getTypes();
if (ResultSetUtility::findRowByColumnValue(
$activityTypes, 'typeID', $activityTypeID
) === false)
{
CommonErrors::fatalModal(COMMONERROR_BADINDEX, $this, 'Invalid activity type ID.');
}

$activityNote = $this->getSanitisedInput('activityNote', $_POST);

$activityNote = htmlspecialchars($activityNote);

/* Add the activity entry. */
$activityEntries = new ActivityEntries($this->_siteID);
$activityID = $activityEntries->add(
$contactID,
DATA_ITEM_CONTACT,
Expand All @@ -1368,7 +1374,6 @@ private function _addActivityScheduleEvent($regardingID, $directoryOverride = ''
$this->_userID,
$regardingID
);
$activityTypes = $activityEntries->getTypes();
$activityTypeDescription = ResultSetUtility::getColumnValueByIDValue(
$activityTypes, 'typeID', $activityTypeID, 'type'
);
Expand Down
72 changes: 72 additions & 0 deletions modules/contacts/activityvalidator.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
/*
* OpenCATS
* Contacts Form Validation
*/

function checkActivityForm(form)

Check warning on line 6 in modules/contacts/activityvalidator.js

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

modules/contacts/activityvalidator.js#L6

'checkActivityForm' is defined but never used.
{
var errorMessage = "";

errorMessage += checkActivityType();

Check warning on line 10 in modules/contacts/activityvalidator.js

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

modules/contacts/activityvalidator.js#L10

'checkActivityType' was used before it was defined.
errorMessage += checkEventTitle();

Check warning on line 11 in modules/contacts/activityvalidator.js

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

modules/contacts/activityvalidator.js#L11

'checkEventTitle' was used before it was defined.

if (errorMessage != "")
{
alert("Form Error:\n" + errorMessage);
return false;
}

return true;
}

function checkActivityType()
{
var errorMessage = "";

var addActivity = document.getElementById("addActivity").checked;
if (!addActivity)
{
return "";
}

var fieldValue = document.getElementById("activityTypeID").value;
var fieldLabel = document.getElementById("addActivitySpanA");
if (fieldValue == "")
{
errorMessage = " - You must select an activity type.\n";

fieldLabel.style.color = "#ff0000";
}
else
{
fieldLabel.style.color = "#000";
}

return errorMessage;
}

function checkEventTitle()
{
var errorMessage = "";

var scheduleEvent = document.getElementById("scheduleEvent").checked;
if (!scheduleEvent)
{
return "";
}

var fieldValue = document.getElementById("title").value;
var fieldLabel = document.getElementById("titleLabel");
if (fieldValue == "")
{
errorMessage = " - You must enter an event title.\n";

fieldLabel.style.color = "#ff0000";
}
else
{
fieldLabel.style.color = "#000";
}

return errorMessage;
}
3 changes: 2 additions & 1 deletion test/features/activities.feature
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Feature: Activities
And I follow "Log an Activity"
And I wait for the activity note box to appear
And I switch to the iframe "popupInner"
And I select "Call" from "activityTypeID"
And fill in "activityNote" with "Call Gandalf"
And press "Save"
And press "Close"
Expand All @@ -22,4 +23,4 @@ Feature: Activities
And I should see "Call Gandalf"
And I should see "Yesterday"
And I should see "Today"
And I should see "Last week"
And I should see "Last week"
Loading