diff --git a/app/ClassLib/MiscLib.php b/app/ClassLib/MiscLib.php
index 679879d..4b2631d 100644
--- a/app/ClassLib/MiscLib.php
+++ b/app/ClassLib/MiscLib.php
@@ -18,6 +18,15 @@ class MiscLib
return $template;
}
+ public static function adminLTEDataTable1Template($tableID)
+ {
+ $template = [
+ 'table_open' => '
'
+ ];
+
+ return $template;
+ }
+
public static function adminLTEDataTableTemplate($tableID)
{
$template = [
@@ -33,4 +42,23 @@ class MiscLib
return ($key !== false) ? $data[$key] : null;
}
+
+ public static function getAttFileInfo($name)
+ {
+ $fileInfo = [];
+
+ $name = strtolower($name);
+
+ if(str_contains($name, 'agl'))
+ $fileInfo = ['code'=>'AGL',
+ 'skipcount'=>2];
+ else if(str_contains($name, 'attlog'))
+ $fileInfo = ['code'=>'ATTLOG',
+ 'skipcount'=>1];
+ else
+ $fileInfo = ['code'=>'ATTLOG',
+ 'skipcount'=>1];
+
+ return $fileInfo;
+ }
}
\ No newline at end of file
diff --git a/app/Controllers/TKController.php b/app/Controllers/TKController.php
index 65f286e..f681266 100644
--- a/app/Controllers/TKController.php
+++ b/app/Controllers/TKController.php
@@ -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'] = 'No attendance log found.
';
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);
diff --git a/app/Database/Migrations/2024-11-09-035938_RemoveUColonRawAttLog.php b/app/Database/Migrations/2024-11-09-035938_RemoveUColonRawAttLog.php
new file mode 100644
index 0000000..2f9ed1b
--- /dev/null
+++ b/app/Database/Migrations/2024-11-09-035938_RemoveUColonRawAttLog.php
@@ -0,0 +1,45 @@
+forge->dropColumn('raw_att_log', $fields);
+ }
+
+ public function down()
+ {
+ $fields = [
+ 'ucol1' => [
+ 'type' => 'VARCHAR',
+ 'constraint' => 2,
+ 'null' => true,
+ 'after' => 'log_time'
+ ],
+ 'ucol2' => [
+ 'type' => 'VARCHAR',
+ 'constraint' => 2,
+ 'null' => true,
+ 'after' => 'log_type'
+ ],
+ 'ucol3' => [
+ 'type' => 'VARCHAR',
+ 'constraint' => 2,
+ 'null' => true,
+ 'after' => 'ucol2'
+ ],
+ ];
+
+ $this->forge->addColumn('raw_att_log', $fields);
+ }
+}
diff --git a/app/Entities/RawAttLog.php b/app/Entities/RawAttLog.php
index 7f9a1bb..d6bb5c2 100644
--- a/app/Entities/RawAttLog.php
+++ b/app/Entities/RawAttLog.php
@@ -10,10 +10,7 @@ class RawAttLog extends Entity
'company_issue_id' => null,
'log_date' => null,
'log_time' => null,
- 'ucol1' => null,
'log_type' => null,
- 'ucol2' => null,
- 'ucol3' => null,
'branch_code' => null,
'att_from' => null,
'att_to' => null,
diff --git a/app/Models/RawAttLogModel.php b/app/Models/RawAttLogModel.php
index 7e75cbf..3e40ca7 100644
--- a/app/Models/RawAttLogModel.php
+++ b/app/Models/RawAttLogModel.php
@@ -15,10 +15,7 @@ class RawAttLogModel extends Model
protected $allowedFields = ['company_issued_id',
'log_date',
'log_time',
- 'ucol1',
'log_type',
- 'ucol2',
- 'ucol3',
'branch_code',
'att_from',
'att_to',];
diff --git a/app/Views/timekeeping/attsummaryview.php b/app/Views/timekeeping/attsummaryview.php
index 636aad1..724f597 100644
--- a/app/Views/timekeeping/attsummaryview.php
+++ b/app/Views/timekeeping/attsummaryview.php
@@ -8,6 +8,11 @@
= $this->section('css') ?>
+
+
+
+
+
= $this->endSection() ?>
@@ -133,7 +138,7 @@
Summary is saved already. If captured data is erronous, delete the saved data and recapture again.
-
+
Employee ID |
@@ -177,8 +182,25 @@
= $this->section('js') ?>
+
+
+
+
+
+
+
+
+
+
+
+
+