зеркало из https://github.com/mozilla/oldpto.git
No longer showing number of hours of pto taken as associated with Full Day/Half Day as not all locations work 8 hours. Changed up some backend export functionality to increase efficiency for payroll.
This commit is contained in:
Родитель
35253289f7
Коммит
edc6e3c589
2
auth.php
2
auth.php
|
@ -2,6 +2,8 @@
|
|||
require_once('config.php');
|
||||
|
||||
$connection = ldap_connect($ldap["host"], $ldap["port"]);
|
||||
ldap_start_tls($connection);
|
||||
|
||||
if (!ldap_bind($connection, $LDAP_BIND_USER, $LDAP_BIND_PASS)) {
|
||||
echo "LDAP connection failed";
|
||||
die;
|
||||
|
|
|
@ -12,7 +12,7 @@ class Filtering {
|
|||
'id', 'person', 'added', 'hours', 'hours_daily', 'start', 'end', 'details'
|
||||
);
|
||||
public static $aLdapFields = array(
|
||||
'givenname', 'sn', 'physicaldeliveryofficename', 'mail'
|
||||
'givenname', 'sn', 'primaryofficecountry', 'primaryofficecity', 'mail', 'employeenumber'
|
||||
);
|
||||
|
||||
/************************ PRIVATE *************************/
|
||||
|
@ -99,7 +99,7 @@ class Filtering {
|
|||
|
||||
$aFilteredRecords = array();
|
||||
foreach ($aRecords as $aRecord) {
|
||||
if ($sCountry && $sCountry != strtolower($aRecord['country'])) { continue; }
|
||||
if ($sCountry && $sCountry != strtolower($aRecord['primaryofficecountry'])) { continue; }
|
||||
if ($sFirstName && stristr($aRecord['first_name'], $sFirstName) === FALSE) { continue; }
|
||||
if ($sLastName && stristr($aRecord['last_name'], $sLastName ) === FALSE) { continue; }
|
||||
$aFilteredRecords[] = $aRecord;
|
||||
|
@ -122,24 +122,26 @@ class Filtering {
|
|||
|
||||
foreach ($aLdapRecords as $sMail=>$aLdapRecord) {
|
||||
$sMail = strtolower($sMail);
|
||||
if (isset($aLdapRecord['physicaldeliveryofficename'])) {
|
||||
list($sCity, $sCountry) = explode(':::', $aLdapRecord['physicaldeliveryofficename']);
|
||||
} else {
|
||||
$sCity = NULL;
|
||||
$sCountry = NULL;
|
||||
}
|
||||
$sCountry = null;
|
||||
$sCity = null;
|
||||
if(isset($aLdapRecord['primaryofficecountry'])){
|
||||
$sCountry = $aLdapRecord['primaryofficecountry'];
|
||||
}
|
||||
$sorted_ldap[$sMail] = array(
|
||||
'first_name' => $aLdapRecord['givenname'],
|
||||
'last_name' => $aLdapRecord['sn'],
|
||||
'city' => $sCity,
|
||||
'country' => $sCountry
|
||||
'employeenumber' => $aLdapRecord['employeenumber'],
|
||||
'primaryofficecountry' => $sCountry
|
||||
);
|
||||
}
|
||||
|
||||
// Loop over all mysql records, merge in the $sorted_ldap data and append to aRecords
|
||||
foreach ($aMysqlRecords as $aMysqlRecord) {
|
||||
$sMail = strtolower($aMysqlRecord['person']);
|
||||
$ldap_contact = $sorted_ldap[$sMail];
|
||||
$ldap_contact = null;
|
||||
if($sorted_ldap[$sMail]){
|
||||
$ldap_contact = $sorted_ldap[$sMail];
|
||||
}
|
||||
if ($ldap_contact) {
|
||||
$aRecords[] = array(
|
||||
'id' => $aMysqlRecord['id'],
|
||||
|
@ -147,17 +149,16 @@ class Filtering {
|
|||
'start_date' => $aMysqlRecord['start'],
|
||||
'end_date' => $aMysqlRecord['end'],
|
||||
'filed_date' => $aMysqlRecord['added'],
|
||||
'pto_hours' => $aMysqlRecord['hours'],
|
||||
'details' => $aMysqlRecord['details'],
|
||||
'pto_hours' => $aMysqlRecord['hours'],
|
||||
'first_name' => $ldap_contact['first_name'],
|
||||
'last_name' => $ldap_contact['last_name'],
|
||||
'city' => $ldap_contact['city'],
|
||||
'country' => $ldap_contact['country'],
|
||||
'hours_daily'=> $aMysqlRecord['hours_daily']
|
||||
'primaryofficecountry' => $ldap_contact['primaryofficecountry'],
|
||||
'hours_daily'=> $aMysqlRecord['hours_daily'],
|
||||
'employeenumber'=> $ldap_contact['employeenumber']
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return self::_filterRecords($aRecords);
|
||||
}
|
||||
|
||||
|
@ -165,9 +166,8 @@ class Filtering {
|
|||
$aLdapRecords = self::_getLdapRecords();
|
||||
$aCountries = array();
|
||||
foreach ($aLdapRecords as $aRecord) {
|
||||
if (isset($aRecord['physicaldeliveryofficename'])) {
|
||||
list($sCity, $sCountry) = explode(':::', $aRecord['physicaldeliveryofficename']);
|
||||
if (!trim($sCountry)) { continue; }
|
||||
if (isset($aRecord['primaryofficecountry'])) {
|
||||
$sCountry = $aRecord['primaryofficecountry'];
|
||||
$aCountries[$sCountry] = $sCountry;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -112,9 +112,9 @@
|
|||
<th width="50px">Hours</th>
|
||||
<th width="80px">Start</th>
|
||||
<th width="80px">End</th>
|
||||
<th width="1%">City</th>
|
||||
<th width="50px">Country</th>
|
||||
<th width="15%">Details</th>
|
||||
<th width="15%">Employee ID</th>
|
||||
<th width="50px">Edit</th>
|
||||
<th width="50px">View hours</th>
|
||||
</tr>
|
||||
|
|
|
@ -20,7 +20,6 @@ $conn = @mysql_connect($mysql['host'], $mysql['user'], $mysql['password'])
|
|||
|
||||
$query = "select
|
||||
added,
|
||||
hours,
|
||||
start,
|
||||
end,
|
||||
details
|
||||
|
@ -67,7 +66,6 @@ include './templates/header.php';
|
|||
<thead>
|
||||
<tr>
|
||||
<th class='datetime'>Added</th>
|
||||
<th class='hours'>Hours</th>
|
||||
<th class='datetime'>Start</th>
|
||||
<th class='datetime'>End</th>
|
||||
<th>Details</th>
|
||||
|
|
11
output.inc
11
output.inc
|
@ -31,9 +31,9 @@ function output_json($data, $from, $to, $send_headers=TRUE) {
|
|||
$aRecord['pto_hours'],
|
||||
date('Y-m-d', $aRecord['start_date']),
|
||||
date('Y-m-d', $aRecord['end_date']),
|
||||
str_replace(' ', ' ', $aRecord['city']),
|
||||
$aRecord['country'],
|
||||
$aRecord['primaryofficecountry'],
|
||||
$aRecord['details'],
|
||||
$aRecord['employeenumber'],
|
||||
$sEditLink,
|
||||
$sViewHoursDailyLink
|
||||
);
|
||||
|
@ -78,8 +78,12 @@ function output_csv($data, $from, $to, $send_headers=TRUE) {
|
|||
'Start Date',
|
||||
'End Date',
|
||||
'Filed Date',
|
||||
'Details',
|
||||
'PTO Hours',
|
||||
'Details'
|
||||
'First Name',
|
||||
'Last Name',
|
||||
'Country',
|
||||
'Employee ID',
|
||||
);
|
||||
$sFields = '';
|
||||
for ($n=0; $n<count($aFields); $n++) {
|
||||
|
@ -89,6 +93,7 @@ function output_csv($data, $from, $to, $send_headers=TRUE) {
|
|||
foreach ($data as $aRecord) {
|
||||
$aFormattedRecord = array();
|
||||
foreach ($aRecord as $sKey=>$sValue) {
|
||||
if($sKey == "hours_daily") {continue;}
|
||||
switch ($sKey) {
|
||||
case 'start_date':
|
||||
case 'end_date':
|
||||
|
|
|
@ -44,8 +44,9 @@ function generate_report($results, $from_time, $to_time) {
|
|||
}
|
||||
|
||||
$fields = LIMITED_FIELDS;
|
||||
$queryString = "SELECT $fields FROM pto $conditions ORDER BY added DESC;";
|
||||
$query = mysql_query(
|
||||
"SELECT $fields FROM pto $conditions ORDER BY added DESC;"
|
||||
$queryString
|
||||
);
|
||||
$running = array();
|
||||
$results = array();
|
||||
|
@ -63,7 +64,7 @@ function generate_report($results, $from_time, $to_time) {
|
|||
$key = $person;
|
||||
$row["sn"] = $user_cache[$key]["sn"][0];
|
||||
$row["givenName"] = $user_cache[$key]["givenname"][0];
|
||||
$row["location"] = $user_cache[$key]["physicaldeliveryofficename"][0];
|
||||
$row["location"] = $user_cache[$key]["primaryofficecountry"][0];
|
||||
$results[] = $row;
|
||||
}
|
||||
|
||||
|
|
|
@ -31,15 +31,10 @@ if ($aErrors) {
|
|||
<?php endforeach; ?>
|
||||
|
||||
<div id="screen2">
|
||||
<p>Please specify amount of PTO hours for each day:</p>
|
||||
<div id="date_discriminator_panel">
|
||||
<h5 id="date_discriminator_hours">24</h5>
|
||||
<div>Hours of PTO</div>
|
||||
<br />
|
||||
<input type="submit" value="Submit" />
|
||||
</div>
|
||||
<p>Please specify amount of PTO you will take off for each of the following day(s):</p>
|
||||
<div id="date_discriminator">
|
||||
</div>
|
||||
<input type="submit" value="Submit" />
|
||||
</div>
|
||||
|
||||
</form>
|
||||
|
@ -137,7 +132,7 @@ if ($aErrors) {
|
|||
var oInputs = $.SPAN({'id' : sTime},
|
||||
$.SPAN({'class': 'date_selector'},
|
||||
$.LABEL({'for' : 'date8_' + sTime},
|
||||
'Full day (8hrs)'
|
||||
'Full day'
|
||||
),
|
||||
$.NBSP,
|
||||
oInputFullDay = $.INPUT(oInputFullDayParams)
|
||||
|
@ -147,7 +142,7 @@ if ($aErrors) {
|
|||
|
||||
$.SPAN({'class': 'date_selector'},
|
||||
$.LABEL({'for' : 'date4_' + sTime},
|
||||
'Half day (4hrs)'
|
||||
'Half day'
|
||||
),
|
||||
$.NBSP,
|
||||
oInputHalfDay = $.INPUT(oInputHalfDayParams)
|
||||
|
@ -155,16 +150,6 @@ if ($aErrors) {
|
|||
|
||||
' ',
|
||||
|
||||
$.SPAN({'class': 'date_selector'},
|
||||
$.LABEL({'for' : 'date0_' + sTime},
|
||||
'Work day (0hrs)'
|
||||
),
|
||||
$.NBSP,
|
||||
oInputEmptyDay = $.INPUT(oInputEmptyDayParams)
|
||||
),
|
||||
|
||||
' ',
|
||||
|
||||
$.SPAN({'id' : 'init_' + sTime, 'class' : 'init'}, nValue),
|
||||
$.SPAN({'id' : 'change_' + sTime, 'class' : 'change'}, '')
|
||||
);
|
||||
|
@ -213,7 +198,6 @@ if ($aErrors) {
|
|||
if (!oTarget || !oTarget.parentNode) { return; }
|
||||
var sTime = oTarget.parentNode.parentNode.id;
|
||||
var sChange = oTarget.value - $('#init_' + sTime).html();
|
||||
$('#change_' + sTime).html('(Change: ' + sChange + ' hours)');
|
||||
}
|
||||
|
||||
function _updateHoursDaily() {
|
||||
|
|
Загрузка…
Ссылка в новой задаче