|
|
|
@ -142,16 +142,18 @@ class TKController extends BaseController
|
|
|
|
|
|
|
|
|
|
if($data['selectedBranch'] != null && $data['attFromTo'] != null)
|
|
|
|
|
{
|
|
|
|
|
$data['attendanceLog'] = (new RawAttLogModel())->where(['log_date >='=>$data['attFrom'], 'log_date <='=>$data['attTo']])->findAll();
|
|
|
|
|
$data['attendanceLog'] = (new RawAttLogModel())->where(['branch_code' => $data['selectedBranch'], 'log_date >='=>$data['attFrom'], 'log_date <='=>$data['attTo']])->findAll();
|
|
|
|
|
|
|
|
|
|
$attLogHTMLTable = new \CodeIgniter\View\Table();
|
|
|
|
|
$attLogHTMLTable->setTemplate(MiscLib::adminLTETableTemplate());
|
|
|
|
|
|
|
|
|
|
// tblAttLog ID should be initialize in view under JS
|
|
|
|
|
$attLogHTMLTable->setTemplate(MiscLib::adminLTEDataTable1Template('tblAttLog'));
|
|
|
|
|
|
|
|
|
|
if($data['attendanceLog'] == null)
|
|
|
|
|
$data['tblAttLog'] = '<p>No attendance log found.</p>';
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
$attLogHTMLTable->addRow('Employee ID', 'Log Date', 'Log Time', 'In/Out', 'Branch');
|
|
|
|
|
$attLogHTMLTable->setHeading('Employee ID', 'Log Date', 'Log Time', 'In/Out', 'Branch');
|
|
|
|
|
foreach($data['attendanceLog'] as $attLog)
|
|
|
|
|
{
|
|
|
|
|
$attLogHTMLTable->addRow($attLog->company_issued_id, $attLog->log_date, $attLog->log_time, ($attLog->log_type) ? 'Out' : 'In', $attLog->branch_code);
|
|
|
|
@ -182,33 +184,84 @@ class TKController extends BaseController
|
|
|
|
|
|
|
|
|
|
if($fileHandle)
|
|
|
|
|
{
|
|
|
|
|
while (($line = fgets($fileHandle)) !== false)
|
|
|
|
|
$lineCounter = 0;
|
|
|
|
|
$fileInfo = MiscLib::getAttFileInfo($name);
|
|
|
|
|
|
|
|
|
|
if($fileInfo['code'] == "AGL")
|
|
|
|
|
{
|
|
|
|
|
if(trim($line) == '') continue;
|
|
|
|
|
|
|
|
|
|
// Create DateTime objects for comparison
|
|
|
|
|
$dateFromFile = Time::createFromFormat('Y-m-d', substr($line, 10, 10));
|
|
|
|
|
$attFrom = Time::createFromFormat('Y-m-d', $attendanceFrom);
|
|
|
|
|
$attTo = Time::createFromFormat('Y-m-d', $attendanceTo);
|
|
|
|
|
|
|
|
|
|
// Check if the date from file falls within the specified range
|
|
|
|
|
if ($dateFromFile < $attFrom || $dateFromFile > $attTo) continue;
|
|
|
|
|
|
|
|
|
|
$batchRawAttLog[] = [
|
|
|
|
|
'company_issued_id' => trim(substr($line, 0, 9)),
|
|
|
|
|
'log_date' => substr($line, 10, 10),
|
|
|
|
|
'log_time' => substr($line, 21, 8),
|
|
|
|
|
'ucol1' => substr($line, 30, 1),
|
|
|
|
|
'log_type' => substr($line, 32, 1),
|
|
|
|
|
'ucol2' => substr($line, 34, 1),
|
|
|
|
|
'ucol3' => substr($line, 36, 1),
|
|
|
|
|
'branch_code' => $selectedBranch,
|
|
|
|
|
'att_from' => $attendanceFrom,
|
|
|
|
|
'att_to' => $attendanceTo,
|
|
|
|
|
'created_at' => Time::now(),
|
|
|
|
|
'created_by' => auth()->user()->employee_id,
|
|
|
|
|
];
|
|
|
|
|
// 1182 2019-10-29 10:32:41 1 0 1 0
|
|
|
|
|
while (($line = fgets($fileHandle)) !== false)
|
|
|
|
|
{
|
|
|
|
|
if($lineCounter < $fileInfo['skipcount'])
|
|
|
|
|
{
|
|
|
|
|
$lineCounter++;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$lineData = explode("\t", $line);
|
|
|
|
|
$dateTime = explode(' ', $lineData[6]);
|
|
|
|
|
|
|
|
|
|
// Create DateTime objects for comparison
|
|
|
|
|
$dateFromFile = Time::createFromFormat('m/d/Y', $dateTime[0]);
|
|
|
|
|
$attFrom = Time::createFromFormat('Y-m-d', $attendanceFrom);
|
|
|
|
|
$attTo = Time::createFromFormat('Y-m-d', $attendanceTo);
|
|
|
|
|
|
|
|
|
|
// Check if the date from file falls within the specified range
|
|
|
|
|
if ($dateFromFile < $attFrom || $dateFromFile > $attTo) {
|
|
|
|
|
$lineCounter++;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$batchRawAttLog[] = [
|
|
|
|
|
'company_issued_id' => trim(substr($line, 8, 4)),
|
|
|
|
|
'log_date' => $dateFromFile,
|
|
|
|
|
'log_time' => $dateTime[1],
|
|
|
|
|
'log_type' => (trim(substr($line, 38, 2)) == "23") ? 0 : 1,
|
|
|
|
|
'branch_code' => $selectedBranch,
|
|
|
|
|
'att_from' => $attendanceFrom,
|
|
|
|
|
'att_to' => $attendanceTo,
|
|
|
|
|
'created_at' => Time::now(),
|
|
|
|
|
'created_by' => auth()->user()->employee_id,
|
|
|
|
|
];
|
|
|
|
|
//54325 3 1372 3 26 12/30/2023 22:00:21
|
|
|
|
|
|
|
|
|
|
$lineCounter++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if($fileInfo['code'] == "ATTLOG")
|
|
|
|
|
{
|
|
|
|
|
while (($line = fgets($fileHandle)) !== false)
|
|
|
|
|
{
|
|
|
|
|
if($lineCounter < $fileInfo['skipcount'])
|
|
|
|
|
{
|
|
|
|
|
$lineCounter++;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Create DateTime objects for comparison
|
|
|
|
|
$dateFromFile = Time::createFromFormat('Y-m-d', substr($line, 10, 10));
|
|
|
|
|
$attFrom = Time::createFromFormat('Y-m-d', $attendanceFrom);
|
|
|
|
|
$attTo = Time::createFromFormat('Y-m-d', $attendanceTo);
|
|
|
|
|
|
|
|
|
|
// Check if the date from file falls within the specified range
|
|
|
|
|
if ($dateFromFile < $attFrom || $dateFromFile > $attTo) {
|
|
|
|
|
$lineCounter++;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$batchRawAttLog[] = [
|
|
|
|
|
'company_issued_id' => trim(substr($line, 0, 9)),
|
|
|
|
|
'log_date' => substr($line, 10, 10),
|
|
|
|
|
'log_time' => substr($line, 21, 8),
|
|
|
|
|
'log_type' => substr($line, 32, 1),
|
|
|
|
|
'branch_code' => $selectedBranch,
|
|
|
|
|
'att_from' => $attendanceFrom,
|
|
|
|
|
'att_to' => $attendanceTo,
|
|
|
|
|
'created_at' => Time::now(),
|
|
|
|
|
'created_by' => auth()->user()->employee_id,
|
|
|
|
|
];
|
|
|
|
|
// 1182 2019-10-29 10:32:41 1 0 1 0
|
|
|
|
|
$lineCounter++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fclose($fileHandle);
|
|
|
|
|