Skip to content

Commit

Permalink
Merge pull request #1 from opencats/master
Browse files Browse the repository at this point in the history
Head Pull
  • Loading branch information
amaisonneuve committed Oct 21, 2015
2 parents 761df20 + 680806d commit 9266c7d
Show file tree
Hide file tree
Showing 11 changed files with 3,042 additions and 9 deletions.
74 changes: 74 additions & 0 deletions ajax/getCandidateIdByPhone.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
<?php
/*
* CATS
* AJAX Data Item Job Orders Interface
*
* Copyright (C) 2005 - 2007 Cognizo Technologies, Inc.
*
*
* The contents of this file are subject to the CATS Public License
* Version 1.1a (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.catsone.com/.
*
* Software distributed under the License is distributed on an "AS IS"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
* License for the specific language governing rights and limitations
* under the License.
*
* The Original Code is "CATS Standard Edition".
*
* The Initial Developer of the Original Code is Cognizo Technologies, Inc.
* Portions created by the Initial Developer are Copyright (C) 2005 - 2007
* (or from the year in which this file was created to the year 2007) by
* Cognizo Technologies, Inc. All Rights Reserved.
*
*
* $Id: getCandidateIdByPhone.php 3078 2007-09-21 20:25:28Z will $
*/

$interface = new SecureAJAXInterface();

include ('lib/Candidates.php');

if (!isset($_REQUEST['phone']))
{
die ('Invalid E-Mail address.');
}

$siteID = $interface->getSiteID();

$phone = $_REQUEST['phone'];

$candidates = new Candidates($siteID);

$output = "<data>\n";

$candidateID = $candidates->getIDByPhone($phone);

if ($candidateID == -1)
{
$output .=
" <candidate>\n" .
" <id>-1</id>\n" .
" </candidate>\n";
}
else
{
$candidateRS = $candidates->get($candidateID);

$output .=
" <candidate>\n" .
" <id>" . $candidateID . "</id>\n" .
" <name>" . $candidateRS['candidateFullName'] . "</name>\n" .
" </candidate>\n";
}
$output .=
"</data>\n";

/* Send back the XML data. */
$interface->outputXMLPage($output);

?>


12 changes: 10 additions & 2 deletions config.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
define('DATABASE_NAME', 'cats_dev');

/* Resfly.com Resume Import Services Enabled */
define('PARSING_ENABLED', true);
define('PARSING_ENABLED', false);

/* If you have an SSL compatible server, you can enable SSL for all of CATS. */
define('SSL_ENABLED', false);
Expand Down Expand Up @@ -121,6 +121,14 @@
/* AJAX Encoding. */
define('AJAX_ENCODING', 'UTF-8');

/* Insert BOM in the beginning of CSV file */
/* This is UTF-8 BOM, EF BB BF for UTF-8 */
define('INSERT_BOM_CSV_LENGTH', '3');
define('INSERT_BOM_CSV_1', '239');
define('INSERT_BOM_CSV_2', '187');
define('INSERT_BOM_CSV_3', '191');
define('INSERT_BOM_CSV_4', '');

/* Path to modules. */
define('MODULES_PATH', './modules/');

Expand Down Expand Up @@ -186,7 +194,7 @@
define('MAIL_MAILER', 1);

/* Sendmail Settings. You don't need to worry about this unless MAIL_MAILER
* is set to 1.
* is set to 2.
*/
define('MAIL_SENDMAIL_PATH', "/usr/sbin/sendmail");

Expand Down
71 changes: 71 additions & 0 deletions js/candidate.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,3 +100,74 @@ function onSubmitEmailInSystem()
}
}

function checkPhoneAlreadyInSystem(phone, sessionCookie)
{
if (phone == '')
{
return;
}

var http = AJAX_getXMLHttpObject();

/* Build HTTP POST data. */
var POSTData = '&phone=' + urlEncode(phone);

/* Anonymous callback function triggered when HTTP response is received. */
var callBack = function ()
{
if (http.readyState != 4)
{
return;
}

if (!http.responseXML)
{
var errorMessage = "An error occurred while receiving a response from the server.\n\n"
+ http.responseText;
/* alert(errorMessage); */
return;
}

var idNode = http.responseXML.getElementsByTagName('id').item(0);

if (idNode.firstChild.nodeValue != -1)
{
candidateIsAlreadyInSystem = true;
candidateIsAlreadyInSystemID = idNode.firstChild.nodeValue;
candidateIsAlreadyInSystemName = http.responseXML.getElementsByTagName('name').item(0).firstChild.nodeValue;

document.getElementById('candidateAlreadyInSystemName').innerHTML = candidateIsAlreadyInSystemName;
document.getElementById('candidateAlreadyInSystemTable').style.display = '';
}
else
{
candidateIsAlreadyInSystem = false;
document.getElementById('candidateAlreadyInSystemTable').style.display = 'none';
}
}

AJAX_callCATSFunction(
http,
'getCandidateIdByPhone',
POSTData,
callBack,
0,
sessionCookie,
false,
false
);
}

function onSubmitPhoneInSystem()
{
if (candidateIsAlreadyInSystem)
{
var agree=confirm("Warning: The candidate may already be in the system.\n\nAre you sure you want to add the candidate?");
if (agree)
return true ;
else
return false ;
}
}


2 changes: 1 addition & 1 deletion lib/CATSUtility.php
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ public static function getIndexName()
$indexParts = explode('.', $index);
if ($indexParts[0] == 'ajax')
{
return 'index' . $indexParts[1];
return 'index.' . $indexParts[1];
}

/* Older versions of apache sometimes don't concatinate script name by default. */
Expand Down
33 changes: 32 additions & 1 deletion lib/Candidates.php
Original file line number Diff line number Diff line change
Expand Up @@ -679,6 +679,36 @@ public function getIDByEmail($email)

return $rs['candidateID'];
}
public function getIDByPhone($phone)
{
$sql = sprintf(
"SELECT
candidate.candidate_id AS candidateID
FROM
candidate
WHERE
(
candidate.phone_home = %s
OR candidate.phone_cell = %s
OR candidate.phone_work = %s
)
AND
candidate.site_id = %s",
$this->_db->makeQueryString($phone),
$this->_db->makeQueryString($phone),
$this->_db->makeQueryString($phone),
$this->_siteID
);
$rs = $this->_db->getAssoc($sql);

if (empty($rs))
{
return -1;
}

return $rs['candidateID'];
}


/**
* Returns the number of candidates in the system. Useful
Expand Down Expand Up @@ -1156,7 +1186,8 @@ public function __construct($instanceName, $siteID, $parameters, $misc = 0)

'Work Phone' => array('select' => 'candidate.phone_work AS phoneWork',
'sortableColumn' => 'phoneWork',
'pagerWidth' => 80),
'pagerWidth' => 80,
'filter' => 'candidate.phone_work'),

'Address' => array('select' => 'candidate.address AS address',
'sortableColumn' => 'address',
Expand Down
17 changes: 17 additions & 0 deletions lib/DataGrid.php
Original file line number Diff line number Diff line change
Expand Up @@ -1470,6 +1470,23 @@ public function drawCSV()
header('Connection: close');
header('Content-Type: text/x-csv; name=export.csv');

if (defined('INSERT_BOM_CSV_LENGTH') && (INSERT_BOM_CSV_LENGTH > 0))
{
echo chr(INSERT_BOM_CSV_1);
if (INSERT_BOM_CSV_LENGTH > 1)
{
echo chr(INSERT_BOM_CSV_2);
}
if (INSERT_BOM_CSV_LENGTH > 2)
{
echo chr(INSERT_BOM_CSV_3);
}
if (INSERT_BOM_CSV_LENGTH > 3)
{
echo chr(INSERT_BOM_CSV_4);
}
}

echo $headerRow;

foreach ($this->_rs as $rowIndex => $row)
Expand Down
22 changes: 17 additions & 5 deletions modules/candidates/Add.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
<?php $URI = CATSUtility::getIndexName() . '?m=candidates&amp;a=add'; ?>
<?php endif; ?>

<form name="addCandidateForm" id="addCandidateForm" enctype="multipart/form-data" action="<?php echo($URI); ?>" method="post" onsubmit="return (checkAddForm(document.addCandidateForm) && onSubmitEmailInSystem());" autocomplete="off" enctype="multipart/form-data">
<form name="addCandidateForm" id="addCandidateForm" enctype="multipart/form-data" action="<?php echo($URI); ?>" method="post" onsubmit="return (checkAddForm(document.addCandidateForm) && onSubmitEmailInSystem() && onSubmitPhoneInSystem());" autocomplete="off" enctype="multipart/form-data">
<?php if ($this->isModal): ?>
<input type="hidden" name="jobOrderID" id="jobOrderID" value="<?php echo($this->jobOrderID); ?>" />
<?php endif; ?>
Expand Down Expand Up @@ -182,7 +182,7 @@
<label id="email2Label" for="email2">2nd E-Mail:</label>
</td>
<td class="tdData">
<input type="text" tabindex="4" name="email2" id="email2" class="inputbox" style="width: 150px" value="<?php if (isset($this->preassignedFields['email2'])) $this->_($this->preassignedFields['email2']); ?>" />
<input type="text" tabindex="4" name="email2" id="email2" class="inputbox" style="width: 150px" value="<?php if (isset($this->preassignedFields['email2'])) $this->_($this->preassignedFields['email2']); ?>" onchange="checkEmailAlreadyInSystem(this.value);" />
</td>
</tr>

Expand All @@ -200,7 +200,7 @@
<label id="phoneHomeLabel" for="phoneHome">Home Phone:</label>
</td>
<td class="tdData">
<input type="text" tabindex="6" name="phoneHome" id="phoneHome" class="inputbox" style="width: 150px;" value="<?php if (isset($this->preassignedFields['phoneHome'])) $this->_($this->preassignedFields['phoneHome']); ?>" />
<input type="text" tabindex="6" name="phoneHome" id="phoneHome" class="inputbox" style="width: 150px;" value="<?php if (isset($this->preassignedFields['phoneHome'])) $this->_($this->preassignedFields['phoneHome']); ?>" onchange="checkPhoneAlreadyInSystem(this.value);" />
<?php if ($this->isParsingEnabled): ?>
<?php if ($this->parsingStatus['parseLimit'] >= 0 && $this->parsingStatus['parseUsed'] >= $this->parsingStatus['parseLimit']): ?>
&nbsp;
Expand All @@ -219,7 +219,7 @@
<label id="phoneCellLabel" for="phoneCell">Cell Phone:</label>
</td>
<td class="tdData">
<input type="text" tabindex="7" name="phoneCell" id="phoneCell" class="inputbox" style="width: 150px;" value="<?php if (isset($this->preassignedFields['phoneCell'])) $this->_($this->preassignedFields['phoneCell']); ?>" />
<input type="text" tabindex="7" name="phoneCell" id="phoneCell" class="inputbox" style="width: 150px;" value="<?php if (isset($this->preassignedFields['phoneCell'])) $this->_($this->preassignedFields['phoneCell']); ?>" onchange="checkPhoneAlreadyInSystem(this.value);" />
</td>
</tr>

Expand All @@ -228,7 +228,7 @@
<label id="phoneWorkLabel" for="phoneWork">Work Phone:</label>
</td>
<td class="tdData">
<input type="text" tabindex="8" name="phoneWork" id="phoneWork" class="inputbox" style="width: 150px" value="<?php if (isset($this->preassignedFields['phoneWork'])) $this->_($this->preassignedFields['phoneWork']); ?>" />
<input type="text" tabindex="8" name="phoneWork" id="phoneWork" class="inputbox" style="width: 150px" value="<?php if (isset($this->preassignedFields['phoneWork'])) $this->_($this->preassignedFields['phoneWork']); ?>" onchange="checkPhoneAlreadyInSystem(this.value);" />
</td>
</tr>

Expand Down Expand Up @@ -520,6 +520,18 @@
<?php if(isset($this->preassignedFields['email']) || isset($this->preassignedFields['email1'])): ?>
checkEmailAlreadyInSystem(urlDecode("<?php if(isset($this->preassignedFields['email'])) echo(urlencode($this->preassignedFields['email'])); else if(isset($this->preassignedFields['email1'])) echo(urlencode($this->preassignedFields['email1'])); ?>"));
<?php endif; ?>
<?php if(isset($this->preassignedFields['email2']) || isset($this->preassignedFields['email2'])): ?>
checkEmailAlreadyInSystem(urlDecode("<?php if(isset($this->preassignedFields['email2'])) echo(urlencode($this->preassignedFields['email2'])); else if(isset($this->preassignedFields['email2'])) echo(urlencode($this->preassignedFields['email2'])); ?>"));
<?php endif; ?>
<?php if(isset($this->preassignedFields['phoneCell']) || isset($this->preassignedFields['phoneCell'])): ?>
checkEmailAlreadyInSystem(urlDecode("<?php if(isset($this->preassignedFields['phoneCell'])) echo(urlencode($this->preassignedFields['phoneCell'])); else if(isset($this->preassignedFields['phoneCell'])) echo(urlencode($this->preassignedFields['phoneCell'])); ?>"));
<?php endif; ?>
<?php if(isset($this->preassignedFields['phoneWork']) || isset($this->preassignedFields['phoneWork'])): ?>
checkEmailAlreadyInSystem(urlDecode("<?php if(isset($this->preassignedFields['phoneWork'])) echo(urlencode($this->preassignedFields['phoneWork'])); else if(isset($this->preassignedFields['phoneWork'])) echo(urlencode($this->preassignedFields['phoneWork'])); ?>"));
<?php endif; ?>
<?php if(isset($this->preassignedFields['phoneHome']) || isset($this->preassignedFields['phoneHome'])): ?>
checkEmailAlreadyInSystem(urlDecode("<?php if(isset($this->preassignedFields['phoneHome'])) echo(urlencode($this->preassignedFields['phoneHome'])); else if(isset($this->preassignedFields['phoneHome'])) echo(urlencode($this->preassignedFields['phoneHome'])); ?>"));
<?php endif; ?>
</script>
<?php if ($this->isModal): ?>
Expand Down
8 changes: 8 additions & 0 deletions optional-updates/latest-sphinx-search/README.MD
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Installation instructions for installing the latest Sphinx Search are here
https://github.com/opencats/OpenCATS/wiki/Latest-Sphinx-search

Please execute this AFTER a normal OpenCATS installation to update Sphinx.
Note: at some future point exisitng 'install Sphinx' instructions will be replaced with this verison in its entirety.

The attached sample files in this directory are the sample configuration files that are referred to in the above wiki article.

Loading

0 comments on commit 9266c7d

Please sign in to comment.