This commit is contained in:
@@ -3,9 +3,12 @@
|
||||
namespace App\Models;
|
||||
|
||||
use CodeIgniter\Model;
|
||||
use App\Models\Concerns\SchoolYearAutoFillTrait;
|
||||
|
||||
class AdditionalChargeModel extends Model
|
||||
{
|
||||
use SchoolYearAutoFillTrait;
|
||||
|
||||
protected $table = 'additional_charges';
|
||||
protected $primaryKey = 'id';
|
||||
protected $returnType = 'array';
|
||||
@@ -28,7 +31,7 @@ class AdditionalChargeModel extends Model
|
||||
protected $validationRules = [
|
||||
'parent_id' => 'permit_empty|integer',
|
||||
'invoice_id' => 'permit_empty|integer',
|
||||
'school_year' => 'required|string|max_length[20]',
|
||||
'school_year' => 'required|string|max_length[9]',
|
||||
'semester' => 'required|string|max_length[20]',
|
||||
'charge_type' => 'required|in_list[add,deduct]',
|
||||
'title' => 'required|string|min_length[2]|max_length[255]',
|
||||
|
||||
@@ -3,9 +3,12 @@
|
||||
namespace App\Models;
|
||||
|
||||
use CodeIgniter\Model;
|
||||
use App\Models\Concerns\SchoolYearAutoFillTrait;
|
||||
|
||||
class AdminNotificationSubjectModel extends Model
|
||||
{
|
||||
use SchoolYearAutoFillTrait;
|
||||
|
||||
protected $table = 'admin_notification_subjects';
|
||||
protected $primaryKey = 'id';
|
||||
protected $returnType = 'array';
|
||||
@@ -15,7 +18,12 @@ class AdminNotificationSubjectModel extends Model
|
||||
'subject',
|
||||
'created_at',
|
||||
'updated_at',
|
||||
'school_year',
|
||||
];
|
||||
protected $validationRules = [
|
||||
'school_year' => 'required|string|max_length[9]',
|
||||
];
|
||||
|
||||
|
||||
protected $useTimestamps = true;
|
||||
protected $createdField = 'created_at';
|
||||
|
||||
@@ -3,9 +3,12 @@
|
||||
namespace App\Models;
|
||||
|
||||
use CodeIgniter\Model;
|
||||
use App\Models\Concerns\SchoolYearAutoFillTrait;
|
||||
|
||||
class AttendanceDataModel extends Model
|
||||
{
|
||||
use SchoolYearAutoFillTrait;
|
||||
|
||||
protected $table = 'attendance_data';
|
||||
protected $primaryKey = 'id';
|
||||
protected $useAutoIncrement = true;
|
||||
@@ -42,7 +45,7 @@ class AttendanceDataModel extends Model
|
||||
'is_notified' => 'required|in_list[no,yes]',
|
||||
'date' => 'required|valid_date[Y-m-d]',
|
||||
'semester' => 'required',
|
||||
'school_year' => 'required',
|
||||
'school_year' => 'required|string|max_length[9]',
|
||||
];
|
||||
/**
|
||||
* Retrieve attendance by class and section for a specific date.
|
||||
|
||||
@@ -3,9 +3,12 @@
|
||||
namespace App\Models;
|
||||
|
||||
use CodeIgniter\Model;
|
||||
use App\Models\Concerns\SchoolYearAutoFillTrait;
|
||||
|
||||
class AttendanceDayModel extends Model
|
||||
{
|
||||
use SchoolYearAutoFillTrait;
|
||||
|
||||
protected $table = 'attendance_day';
|
||||
protected $primaryKey = 'id';
|
||||
protected $returnType = 'array';
|
||||
@@ -28,6 +31,10 @@ class AttendanceDayModel extends Model
|
||||
'created_at',
|
||||
'updated_at',
|
||||
];
|
||||
protected $validationRules = [
|
||||
'school_year' => 'required|string|max_length[9]',
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* Legacy helper kept for compatibility.
|
||||
|
||||
@@ -3,9 +3,12 @@
|
||||
namespace App\Models;
|
||||
|
||||
use CodeIgniter\Model;
|
||||
use App\Models\Concerns\SchoolYearAutoFillTrait;
|
||||
|
||||
class AttendanceRecordModel extends Model
|
||||
{
|
||||
use SchoolYearAutoFillTrait;
|
||||
|
||||
protected $table = 'attendance_record';
|
||||
protected $primaryKey = 'id';
|
||||
protected $allowedFields = [
|
||||
@@ -22,6 +25,10 @@ class AttendanceRecordModel extends Model
|
||||
'created_at',
|
||||
'updated_at'
|
||||
];
|
||||
protected $validationRules = [
|
||||
'school_year' => 'required|string|max_length[9]',
|
||||
];
|
||||
|
||||
|
||||
protected $useTimestamps = true;
|
||||
protected $createdField = 'created_at';
|
||||
|
||||
@@ -3,10 +3,13 @@
|
||||
namespace App\Models;
|
||||
|
||||
use CodeIgniter\Model;
|
||||
use App\Models\Concerns\SchoolYearAutoFillTrait;
|
||||
use CodeIgniter\I18n\Time;
|
||||
|
||||
class AttendanceTrackingModel extends Model
|
||||
{
|
||||
use SchoolYearAutoFillTrait;
|
||||
|
||||
protected $table = 'attendance_tracking';
|
||||
protected $primaryKey = 'id';
|
||||
protected $useAutoIncrement = true;
|
||||
@@ -24,6 +27,10 @@ class AttendanceTrackingModel extends Model
|
||||
'school_year',
|
||||
'note',
|
||||
];
|
||||
protected $validationRules = [
|
||||
'school_year' => 'required|string|max_length[9]',
|
||||
];
|
||||
|
||||
|
||||
protected $useTimestamps = true;
|
||||
protected $createdField = 'created_at';
|
||||
|
||||
@@ -3,9 +3,12 @@
|
||||
namespace App\Models;
|
||||
|
||||
use CodeIgniter\Model;
|
||||
use App\Models\Concerns\SchoolYearAutoFillTrait;
|
||||
|
||||
class BadgePrintLogModel extends Model
|
||||
{
|
||||
use SchoolYearAutoFillTrait;
|
||||
|
||||
protected $table = 'badge_print_logs';
|
||||
protected $primaryKey = 'id';
|
||||
protected $useTimestamps = false;
|
||||
@@ -19,6 +22,10 @@ class BadgePrintLogModel extends Model
|
||||
'class_section_name',
|
||||
'copies',
|
||||
];
|
||||
protected $validationRules = [
|
||||
'school_year' => 'required|string|max_length[9]',
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* Insert a batch of print logs. Swallows errors if table is missing.
|
||||
|
||||
@@ -3,9 +3,12 @@
|
||||
namespace App\Models;
|
||||
|
||||
use CodeIgniter\Model;
|
||||
use App\Models\Concerns\SchoolYearAutoFillTrait;
|
||||
|
||||
class BelowSixtyDecisionModel extends Model
|
||||
{
|
||||
use SchoolYearAutoFillTrait;
|
||||
|
||||
protected $table = 'below_sixty_decisions';
|
||||
protected $primaryKey = 'id';
|
||||
|
||||
@@ -17,6 +20,10 @@ class BelowSixtyDecisionModel extends Model
|
||||
'notes',
|
||||
'decided_by',
|
||||
];
|
||||
protected $validationRules = [
|
||||
'school_year' => 'required|string|max_length[9]',
|
||||
];
|
||||
|
||||
|
||||
protected $useTimestamps = true;
|
||||
protected $createdField = 'created_at';
|
||||
|
||||
@@ -3,9 +3,12 @@
|
||||
namespace App\Models;
|
||||
|
||||
use CodeIgniter\Model;
|
||||
use App\Models\Concerns\SchoolYearAutoFillTrait;
|
||||
|
||||
class CalendarModel extends Model
|
||||
{
|
||||
use SchoolYearAutoFillTrait;
|
||||
|
||||
protected $table = 'calendar_events';
|
||||
protected $primaryKey = 'id';
|
||||
protected ?bool $hasEventTypeColumn = null;
|
||||
@@ -22,6 +25,10 @@ class CalendarModel extends Model
|
||||
'notify_teacher',
|
||||
'no_school'
|
||||
];
|
||||
protected $validationRules = [
|
||||
'school_year' => 'required|string|max_length[9]',
|
||||
];
|
||||
|
||||
|
||||
protected $useTimestamps = true;
|
||||
protected $createdField = 'created_at';
|
||||
|
||||
@@ -3,9 +3,12 @@
|
||||
namespace App\Models;
|
||||
|
||||
use CodeIgniter\Model;
|
||||
use App\Models\Concerns\SchoolYearAutoFillTrait;
|
||||
|
||||
class CertificateRecordModel extends Model
|
||||
{
|
||||
use SchoolYearAutoFillTrait;
|
||||
|
||||
protected $table = 'certificate_records';
|
||||
protected $primaryKey = 'id';
|
||||
protected $useTimestamps = true;
|
||||
@@ -22,6 +25,10 @@ class CertificateRecordModel extends Model
|
||||
'issued_by',
|
||||
'issued_at',
|
||||
];
|
||||
protected $validationRules = [
|
||||
'school_year' => 'required|string|max_length[9]',
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* Generates the next certificate number for a given school year.
|
||||
|
||||
@@ -3,17 +3,25 @@
|
||||
namespace App\Models;
|
||||
|
||||
use CodeIgniter\Model;
|
||||
use App\Models\Concerns\SchoolYearAutoFillTrait;
|
||||
|
||||
class ClassModel extends Model
|
||||
{
|
||||
use SchoolYearAutoFillTrait;
|
||||
|
||||
protected $table = 'classes'; // The table name
|
||||
protected $primaryKey = 'id'; // The correct primary key for the classes table
|
||||
|
||||
// Fields that are allowed to be manipulated.
|
||||
protected $allowedFields = [
|
||||
'class_name',
|
||||
'schedule',
|
||||
'capacity'
|
||||
]; // Fields that are allowed to be manipulated
|
||||
'capacity',
|
||||
'school_year',
|
||||
];
|
||||
protected $validationRules = [
|
||||
'school_year' => 'required|string|max_length[9]',
|
||||
];
|
||||
|
||||
protected $useTimestamps = false;
|
||||
|
||||
|
||||
@@ -2,11 +2,19 @@
|
||||
namespace App\Models;
|
||||
|
||||
use CodeIgniter\Model;
|
||||
use App\Models\Concerns\SchoolYearAutoFillTrait;
|
||||
|
||||
class ClassPrepAdjustmentModel extends Model
|
||||
{
|
||||
use SchoolYearAutoFillTrait;
|
||||
|
||||
protected $table = 'class_prep_adjustments';
|
||||
protected $allowedFields = [
|
||||
'class_section_id', 'item_name', 'adjustment', 'adjustable', 'created_at'
|
||||
'class_section_id', 'item_name', 'adjustment', 'adjustable', 'created_at',
|
||||
'school_year',
|
||||
];
|
||||
protected $validationRules = [
|
||||
'school_year' => 'required|string|max_length[16]',
|
||||
];
|
||||
|
||||
}
|
||||
|
||||
@@ -3,9 +3,12 @@
|
||||
namespace App\Models;
|
||||
|
||||
use CodeIgniter\Model;
|
||||
use App\Models\Concerns\SchoolYearAutoFillTrait;
|
||||
|
||||
class ClassPreparationLogModel extends Model
|
||||
{
|
||||
use SchoolYearAutoFillTrait;
|
||||
|
||||
protected $table = 'class_preparation_log';
|
||||
protected $primaryKey = 'id';
|
||||
protected $allowedFields = [
|
||||
@@ -13,6 +16,11 @@ class ClassPreparationLogModel extends Model
|
||||
'class_section',
|
||||
'prep_data',
|
||||
'created_at',
|
||||
'school_year',
|
||||
];
|
||||
protected $validationRules = [
|
||||
'school_year' => 'required|string|max_length[9]',
|
||||
];
|
||||
|
||||
public $useTimestamps = false;
|
||||
}
|
||||
|
||||
@@ -3,9 +3,12 @@
|
||||
namespace App\Models;
|
||||
|
||||
use CodeIgniter\Model;
|
||||
use App\Models\Concerns\SchoolYearAutoFillTrait;
|
||||
|
||||
class ClassProgressAttachmentModel extends Model
|
||||
{
|
||||
use SchoolYearAutoFillTrait;
|
||||
|
||||
protected $table = 'class_progress_attachments';
|
||||
protected $primaryKey = 'id';
|
||||
protected $returnType = 'array';
|
||||
@@ -16,6 +19,11 @@ class ClassProgressAttachmentModel extends Model
|
||||
'mime_type',
|
||||
'file_size',
|
||||
'created_at',
|
||||
'school_year',
|
||||
];
|
||||
protected $validationRules = [
|
||||
'school_year' => 'required|string|max_length[9]',
|
||||
];
|
||||
|
||||
protected $useTimestamps = false;
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace App\Models;
|
||||
|
||||
use CodeIgniter\Model;
|
||||
use App\Models\Concerns\SchoolYearAutoFillTrait;
|
||||
|
||||
/**
|
||||
* Weekly class progress reports (one row per subject per week).
|
||||
@@ -15,6 +16,8 @@ use CodeIgniter\Model;
|
||||
*/
|
||||
class ClassProgressReportModel extends Model
|
||||
{
|
||||
use SchoolYearAutoFillTrait;
|
||||
|
||||
protected $table = 'class_progress_reports';
|
||||
protected $primaryKey = 'id';
|
||||
protected $returnType = 'array';
|
||||
@@ -51,7 +54,7 @@ class ClassProgressReportModel extends Model
|
||||
protected $validationRules = [
|
||||
'class_section_id' => 'required|integer',
|
||||
'teacher_id' => 'required|integer',
|
||||
'school_year' => 'permit_empty|string|max_length[9]',
|
||||
'school_year' => 'required|string|max_length[9]',
|
||||
'week_start' => 'required|valid_date[Y-m-d]',
|
||||
'week_end' => 'required|valid_date[Y-m-d]',
|
||||
'subject' => 'required|string|max_length[160]',
|
||||
|
||||
@@ -2,9 +2,12 @@
|
||||
namespace App\Models;
|
||||
|
||||
use CodeIgniter\Model;
|
||||
use App\Models\Concerns\SchoolYearAutoFillTrait;
|
||||
|
||||
class ClassSectionModel extends Model
|
||||
{
|
||||
use SchoolYearAutoFillTrait;
|
||||
|
||||
protected $table = 'classSection'; // Correct table name
|
||||
protected $primaryKey = 'id'; // Specify the primary key field
|
||||
|
||||
@@ -14,7 +17,12 @@ class ClassSectionModel extends Model
|
||||
'class_section_name',
|
||||
'created_at',
|
||||
'updated_at',
|
||||
'school_year',
|
||||
];
|
||||
protected $validationRules = [
|
||||
'school_year' => 'required|string|max_length[9]',
|
||||
];
|
||||
|
||||
|
||||
protected $useTimestamps = true;
|
||||
protected $createdField = 'created_at';
|
||||
|
||||
@@ -3,9 +3,12 @@
|
||||
namespace App\Models;
|
||||
|
||||
use CodeIgniter\Model;
|
||||
use App\Models\Concerns\SchoolYearAutoFillTrait;
|
||||
|
||||
class CompetitionClassWinnerModel extends Model
|
||||
{
|
||||
use SchoolYearAutoFillTrait;
|
||||
|
||||
protected $table = 'competition_class_winners';
|
||||
protected $primaryKey = 'id';
|
||||
|
||||
@@ -20,7 +23,12 @@ class CompetitionClassWinnerModel extends Model
|
||||
'prize_4',
|
||||
'prize_5',
|
||||
'prize_6',
|
||||
'school_year',
|
||||
];
|
||||
protected $validationRules = [
|
||||
'school_year' => 'required|string|max_length[9]',
|
||||
];
|
||||
|
||||
|
||||
protected $useTimestamps = true;
|
||||
protected $createdField = 'created_at';
|
||||
|
||||
@@ -3,9 +3,12 @@
|
||||
namespace App\Models;
|
||||
|
||||
use CodeIgniter\Model;
|
||||
use App\Models\Concerns\SchoolYearAutoFillTrait;
|
||||
|
||||
class CompetitionModel extends Model
|
||||
{
|
||||
use SchoolYearAutoFillTrait;
|
||||
|
||||
protected $table = 'competitions';
|
||||
protected $primaryKey = 'id';
|
||||
protected $useSoftDeletes = true;
|
||||
@@ -26,6 +29,10 @@ class CompetitionModel extends Model
|
||||
'locked_by',
|
||||
'created_by',
|
||||
];
|
||||
protected $validationRules = [
|
||||
'school_year' => 'required|string|max_length[9]',
|
||||
];
|
||||
|
||||
|
||||
protected $useTimestamps = true;
|
||||
protected $createdField = 'created_at';
|
||||
|
||||
@@ -3,9 +3,12 @@
|
||||
namespace App\Models;
|
||||
|
||||
use CodeIgniter\Model;
|
||||
use App\Models\Concerns\SchoolYearAutoFillTrait;
|
||||
|
||||
class CompetitionScoreModel extends Model
|
||||
{
|
||||
use SchoolYearAutoFillTrait;
|
||||
|
||||
protected $table = 'competition_scores';
|
||||
protected $primaryKey = 'id';
|
||||
|
||||
@@ -15,7 +18,12 @@ class CompetitionScoreModel extends Model
|
||||
'class_section_id',
|
||||
'score',
|
||||
'notes',
|
||||
'school_year',
|
||||
];
|
||||
protected $validationRules = [
|
||||
'school_year' => 'required|string|max_length[9]',
|
||||
];
|
||||
|
||||
|
||||
protected $useTimestamps = true;
|
||||
protected $createdField = 'created_at';
|
||||
|
||||
@@ -3,9 +3,12 @@
|
||||
namespace App\Models;
|
||||
|
||||
use CodeIgniter\Model;
|
||||
use App\Models\Concerns\SchoolYearAutoFillTrait;
|
||||
|
||||
class CompetitionWinnerModel extends Model
|
||||
{
|
||||
use SchoolYearAutoFillTrait;
|
||||
|
||||
protected $table = 'competition_winners';
|
||||
protected $primaryKey = 'id';
|
||||
|
||||
@@ -17,7 +20,12 @@ class CompetitionWinnerModel extends Model
|
||||
'score',
|
||||
'prize_amount',
|
||||
'created_at',
|
||||
'school_year',
|
||||
];
|
||||
protected $validationRules = [
|
||||
'school_year' => 'required|string|max_length[9]',
|
||||
];
|
||||
|
||||
|
||||
protected $useTimestamps = false;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,178 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Concerns;
|
||||
|
||||
trait SchoolYearAutoFillTrait
|
||||
{
|
||||
public function insert($row = null, bool $returnID = true)
|
||||
{
|
||||
if (isset($this->tempData['data'])) {
|
||||
if ($row === null) {
|
||||
$row = $this->tempData['data'];
|
||||
} else {
|
||||
$row = array_merge($this->tempData['data'], $this->transformDataToArray($row, 'insert'));
|
||||
}
|
||||
|
||||
$this->escape = $this->tempData['escape'] ?? [];
|
||||
$this->tempData = [];
|
||||
}
|
||||
|
||||
return parent::insert($this->withDefaultSchoolYear($row), $returnID);
|
||||
}
|
||||
|
||||
public function insertBatch(?array $set = null, ?bool $escape = null, int $batchSize = 100, bool $testing = false)
|
||||
{
|
||||
if (is_array($set)) {
|
||||
foreach ($set as $index => $row) {
|
||||
$set[$index] = $this->withDefaultSchoolYear($row);
|
||||
}
|
||||
}
|
||||
|
||||
return parent::insertBatch($set, $escape, $batchSize, $testing);
|
||||
}
|
||||
|
||||
protected function withDefaultSchoolYear($row)
|
||||
{
|
||||
if (! is_array($row)) {
|
||||
return $row;
|
||||
}
|
||||
|
||||
if ($this->hasNonEmptySchoolYear($row)) {
|
||||
return $row;
|
||||
}
|
||||
|
||||
$schoolYear = $this->deriveSchoolYearForRow($row) ?? $this->currentSchoolYearName();
|
||||
if ($schoolYear !== '') {
|
||||
$row['school_year'] = $schoolYear;
|
||||
}
|
||||
|
||||
return $row;
|
||||
}
|
||||
|
||||
protected function deriveSchoolYearForRow(array $row): ?string
|
||||
{
|
||||
foreach (['school_year_from', 'school_year_to', 'previous_school_year'] as $field) {
|
||||
$value = trim((string)($row[$field] ?? ''));
|
||||
if ($this->isValidSchoolYear($value)) {
|
||||
return $value;
|
||||
}
|
||||
}
|
||||
|
||||
foreach (['source_school_year_id', 'target_school_year_id', 'school_year_id'] as $field) {
|
||||
$id = (int)($row[$field] ?? 0);
|
||||
if ($id <= 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$year = $this->schoolYearNameById($id);
|
||||
if ($year !== null) {
|
||||
return $year;
|
||||
}
|
||||
}
|
||||
|
||||
$batchId = (int)($row['closing_batch_id'] ?? 0);
|
||||
if ($batchId > 0) {
|
||||
return $this->schoolYearNameByClosingBatchId($batchId);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private function hasNonEmptySchoolYear(array $row): bool
|
||||
{
|
||||
return array_key_exists('school_year', $row) && trim((string)$row['school_year']) !== '';
|
||||
}
|
||||
|
||||
private function currentSchoolYearName(): string
|
||||
{
|
||||
try {
|
||||
if ($this->db->tableExists('school_years')) {
|
||||
$row = $this->db->table('school_years')
|
||||
->select('name')
|
||||
->where('status', 'active')
|
||||
->orderBy('id', 'DESC')
|
||||
->get(1)
|
||||
->getRowArray();
|
||||
|
||||
$name = trim((string)($row['name'] ?? ''));
|
||||
if ($this->isValidSchoolYear($name)) {
|
||||
return $name;
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->db->tableExists('configuration')) {
|
||||
foreach (['school_year', 'current_school_year'] as $key) {
|
||||
$row = $this->db->table('configuration')
|
||||
->select('config_value')
|
||||
->where('config_key', $key)
|
||||
->orderBy('id', 'DESC')
|
||||
->get(1)
|
||||
->getRowArray();
|
||||
|
||||
$value = trim((string)($row['config_value'] ?? ''));
|
||||
if ($this->isValidSchoolYear($value)) {
|
||||
return $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (\Throwable) {
|
||||
return $this->calendarYearFallback();
|
||||
}
|
||||
|
||||
return $this->calendarYearFallback();
|
||||
}
|
||||
|
||||
private function schoolYearNameById(int $id): ?string
|
||||
{
|
||||
try {
|
||||
if (! $this->db->tableExists('school_years')) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$row = $this->db->table('school_years')
|
||||
->select('name')
|
||||
->where('id', $id)
|
||||
->get(1)
|
||||
->getRowArray();
|
||||
|
||||
$name = trim((string)($row['name'] ?? ''));
|
||||
|
||||
return $this->isValidSchoolYear($name) ? $name : null;
|
||||
} catch (\Throwable) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private function schoolYearNameByClosingBatchId(int $id): ?string
|
||||
{
|
||||
try {
|
||||
if (! $this->db->tableExists('school_year_closing_batches')) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$row = $this->db->table('school_year_closing_batches')
|
||||
->select('school_year')
|
||||
->where('id', $id)
|
||||
->get(1)
|
||||
->getRowArray();
|
||||
|
||||
$year = trim((string)($row['school_year'] ?? ''));
|
||||
|
||||
return $this->isValidSchoolYear($year) ? $year : null;
|
||||
} catch (\Throwable) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private function calendarYearFallback(): string
|
||||
{
|
||||
$year = (int) date('Y');
|
||||
|
||||
return $year . '-' . ($year + 1);
|
||||
}
|
||||
|
||||
private function isValidSchoolYear(string $value): bool
|
||||
{
|
||||
return preg_match('/^\d{4}-\d{4}$/', $value) === 1;
|
||||
}
|
||||
}
|
||||
@@ -4,9 +4,12 @@
|
||||
namespace App\Models;
|
||||
|
||||
use CodeIgniter\Model;
|
||||
use App\Models\Concerns\SchoolYearAutoFillTrait;
|
||||
|
||||
class ContactUsModel extends Model
|
||||
{
|
||||
use SchoolYearAutoFillTrait;
|
||||
|
||||
protected $table = 'contactus';
|
||||
protected $primaryKey = 'id';
|
||||
protected $useAutoIncrement = true;
|
||||
@@ -20,7 +23,8 @@ class ContactUsModel extends Model
|
||||
'subject',
|
||||
'message',
|
||||
'created_at',
|
||||
'updated_at'
|
||||
'updated_at',
|
||||
'school_year',
|
||||
];
|
||||
|
||||
// Timestamps (set manually or use auto timestamps below)
|
||||
@@ -33,6 +37,7 @@ class ContactUsModel extends Model
|
||||
'reciever_id' => 'required|integer',
|
||||
'subject' => 'required|string|max_length[255]',
|
||||
'message' => 'required|string',
|
||||
'school_year' => 'required|string|max_length[9]',
|
||||
];
|
||||
|
||||
protected $validationMessages = [];
|
||||
|
||||
@@ -4,9 +4,12 @@
|
||||
namespace App\Models;
|
||||
|
||||
use CodeIgniter\Model;
|
||||
use App\Models\Concerns\SchoolYearAutoFillTrait;
|
||||
|
||||
class CurrentFlagModel extends Model
|
||||
{
|
||||
use SchoolYearAutoFillTrait;
|
||||
|
||||
protected $table = 'current_flag';
|
||||
protected $primaryKey = 'id';
|
||||
protected $allowedFields = [
|
||||
@@ -28,6 +31,10 @@ class CurrentFlagModel extends Model
|
||||
'created_at',
|
||||
'updated_at'
|
||||
];
|
||||
protected $validationRules = [
|
||||
'school_year' => 'required|string|max_length[9]',
|
||||
];
|
||||
|
||||
|
||||
// Fields that are allowed to be inserted or updated
|
||||
|
||||
|
||||
@@ -3,9 +3,12 @@
|
||||
namespace App\Models;
|
||||
|
||||
use CodeIgniter\Model;
|
||||
use App\Models\Concerns\SchoolYearAutoFillTrait;
|
||||
|
||||
class DiscountUsageModel extends Model
|
||||
{
|
||||
use SchoolYearAutoFillTrait;
|
||||
|
||||
protected $table = 'discount_usages';
|
||||
protected $primaryKey = 'id';
|
||||
|
||||
@@ -30,7 +33,8 @@ class DiscountUsageModel extends Model
|
||||
'voucher_id' => 'required|is_natural_no_zero',
|
||||
'invoice_id' => 'required|is_natural_no_zero',
|
||||
'user_id' => 'permit_empty|is_natural_no_zero',
|
||||
'used_at' => 'valid_date'
|
||||
'used_at' => 'valid_date',
|
||||
'school_year' => 'required|string|max_length[9]',
|
||||
];
|
||||
|
||||
protected $validationMessages = [
|
||||
|
||||
@@ -2,9 +2,12 @@
|
||||
namespace App\Models;
|
||||
|
||||
use CodeIgniter\Model;
|
||||
use App\Models\Concerns\SchoolYearAutoFillTrait;
|
||||
|
||||
class DiscountVoucherModel extends Model
|
||||
{
|
||||
use SchoolYearAutoFillTrait;
|
||||
|
||||
protected $table = 'discount_vouchers';
|
||||
protected $primaryKey = 'id';
|
||||
|
||||
@@ -38,7 +41,8 @@ class DiscountVoucherModel extends Model
|
||||
'valid_from' => 'permit_empty|valid_date[Y-m-d]',
|
||||
'valid_until' => 'permit_empty|valid_date[Y-m-d]',
|
||||
'is_active' => 'in_list[0,1]',
|
||||
'description' => 'permit_empty|string|max_length[1000]', // <-- NEW
|
||||
'description' => 'permit_empty|string|max_length[1000]', // <-- NEW,
|
||||
'school_year' => 'required|string|max_length[9]',
|
||||
];
|
||||
|
||||
protected $validationMessages = [
|
||||
|
||||
@@ -3,9 +3,12 @@
|
||||
namespace App\Models;
|
||||
|
||||
use CodeIgniter\Model;
|
||||
use App\Models\Concerns\SchoolYearAutoFillTrait;
|
||||
|
||||
class EarlyDismissalSignatureModel extends Model
|
||||
{
|
||||
use SchoolYearAutoFillTrait;
|
||||
|
||||
protected $table = 'early_dismissal_signatures';
|
||||
protected $primaryKey = 'id';
|
||||
protected $useAutoIncrement = true;
|
||||
@@ -28,7 +31,7 @@ class EarlyDismissalSignatureModel extends Model
|
||||
protected $validationRules = [
|
||||
'report_date' => 'required|valid_date[Y-m-d]',
|
||||
'filename' => 'required|string',
|
||||
'school_year' => 'permit_empty|string',
|
||||
'school_year' => 'required|string|max_length[9]',
|
||||
'semester' => 'permit_empty|string',
|
||||
];
|
||||
}
|
||||
|
||||
@@ -3,9 +3,12 @@
|
||||
namespace App\Models;
|
||||
|
||||
use CodeIgniter\Model;
|
||||
use App\Models\Concerns\SchoolYearAutoFillTrait;
|
||||
|
||||
class EnrollmentModel extends Model
|
||||
{
|
||||
use SchoolYearAutoFillTrait;
|
||||
|
||||
protected $table = 'enrollments';
|
||||
protected $primaryKey = 'id';
|
||||
|
||||
@@ -32,7 +35,7 @@ class EnrollmentModel extends Model
|
||||
'student_id' => 'required|integer',
|
||||
'class_section_id' => 'permit_empty|integer',
|
||||
'parent_id' => 'required|integer',
|
||||
'school_year' => 'required|string|max_length[25]',
|
||||
'school_year' => 'required|string|max_length[9]',
|
||||
'enrollment_date' => 'required|valid_date',
|
||||
'withdrawal_date' => 'permit_empty|valid_date',
|
||||
'is_withdrawn' => 'permit_empty|in_list[0,1]',
|
||||
@@ -56,7 +59,7 @@ class EnrollmentModel extends Model
|
||||
'school_year' => [
|
||||
'required' => 'School year is required',
|
||||
'string' => 'School year must be a string',
|
||||
'max_length' => 'School year must not exceed 25 characters',
|
||||
'max_length' => 'School year must not exceed 9 characters',
|
||||
],
|
||||
'enrollment_date' => [
|
||||
'required' => 'Enrollment date is required',
|
||||
|
||||
@@ -3,9 +3,12 @@
|
||||
namespace App\Models;
|
||||
|
||||
use CodeIgniter\Model;
|
||||
use App\Models\Concerns\SchoolYearAutoFillTrait;
|
||||
|
||||
class EventChargesModel extends Model
|
||||
{
|
||||
use SchoolYearAutoFillTrait;
|
||||
|
||||
protected $table = 'event_charges';
|
||||
protected $primaryKey = 'id';
|
||||
|
||||
@@ -32,6 +35,10 @@ class EventChargesModel extends Model
|
||||
'created_at',
|
||||
'updated_at'
|
||||
];
|
||||
protected $validationRules = [
|
||||
'school_year' => 'required|string|max_length[9]',
|
||||
];
|
||||
|
||||
|
||||
protected $useTimestamps = true;
|
||||
protected $createdField = 'created_at';
|
||||
|
||||
@@ -3,9 +3,12 @@
|
||||
namespace App\Models;
|
||||
|
||||
use CodeIgniter\Model;
|
||||
use App\Models\Concerns\SchoolYearAutoFillTrait;
|
||||
|
||||
class EventModel extends Model
|
||||
{
|
||||
use SchoolYearAutoFillTrait;
|
||||
|
||||
protected $table = 'events';
|
||||
protected $primaryKey = 'id';
|
||||
|
||||
@@ -22,6 +25,10 @@ class EventModel extends Model
|
||||
'created_at',
|
||||
'updated_at'
|
||||
];
|
||||
protected $validationRules = [
|
||||
'school_year' => 'required|string|max_length[9]',
|
||||
];
|
||||
|
||||
|
||||
protected $useTimestamps = true;
|
||||
protected $createdField = 'created_at';
|
||||
|
||||
@@ -3,9 +3,12 @@
|
||||
namespace App\Models;
|
||||
|
||||
use CodeIgniter\Model;
|
||||
use App\Models\Concerns\SchoolYearAutoFillTrait;
|
||||
|
||||
class ExamDraftModel extends Model
|
||||
{
|
||||
use SchoolYearAutoFillTrait;
|
||||
|
||||
protected $table = 'exam_drafts';
|
||||
protected $primaryKey = 'id';
|
||||
protected $returnType = 'array';
|
||||
@@ -65,6 +68,7 @@ class ExamDraftModel extends Model
|
||||
'author_id' => 'if_exist|is_natural_no_zero',
|
||||
'class_section_id' => 'if_exist|is_natural_no_zero',
|
||||
'version' => 'if_exist|is_natural_no_zero',
|
||||
'school_year' => 'required|string|max_length[9]',
|
||||
];
|
||||
|
||||
protected $validationMessages = [
|
||||
|
||||
@@ -3,9 +3,12 @@
|
||||
namespace App\Models;
|
||||
|
||||
use CodeIgniter\Model;
|
||||
use App\Models\Concerns\SchoolYearAutoFillTrait;
|
||||
|
||||
class ExamModel extends Model
|
||||
{
|
||||
use SchoolYearAutoFillTrait;
|
||||
|
||||
protected $table = 'exams';
|
||||
protected $primaryKey = 'id';
|
||||
protected $useAutoIncrement = true;
|
||||
@@ -18,6 +21,10 @@ class ExamModel extends Model
|
||||
'school_year',
|
||||
'created_at'
|
||||
];
|
||||
protected $validationRules = [
|
||||
'school_year' => 'required|string|max_length[9]',
|
||||
];
|
||||
|
||||
|
||||
// Timestamps
|
||||
protected $useTimestamps = true;
|
||||
|
||||
@@ -3,9 +3,12 @@
|
||||
namespace App\Models;
|
||||
|
||||
use CodeIgniter\Model;
|
||||
use App\Models\Concerns\SchoolYearAutoFillTrait;
|
||||
|
||||
class ExpenseModel extends Model
|
||||
{
|
||||
use SchoolYearAutoFillTrait;
|
||||
|
||||
protected $table = 'expenses';
|
||||
protected $primaryKey = 'id';
|
||||
|
||||
@@ -32,7 +35,8 @@ class ExpenseModel extends Model
|
||||
protected $updatedField = 'updated_at';
|
||||
|
||||
protected $validationRules = [
|
||||
// Add your validation rules here as needed
|
||||
// Add your validation rules here as needed,
|
||||
'school_year' => 'required|string|max_length[9]',
|
||||
];
|
||||
|
||||
public function getReimbursedExpensesWithDetails(array $filters = [])
|
||||
|
||||
@@ -3,9 +3,12 @@
|
||||
namespace App\Models;
|
||||
|
||||
use CodeIgniter\Model;
|
||||
use App\Models\Concerns\SchoolYearAutoFillTrait;
|
||||
|
||||
class FinalExamModel extends Model
|
||||
{
|
||||
use SchoolYearAutoFillTrait;
|
||||
|
||||
protected $table = 'final_exam';
|
||||
protected $primaryKey = 'id';
|
||||
protected $useAutoIncrement = true;
|
||||
@@ -38,7 +41,8 @@ class FinalExamModel extends Model
|
||||
protected $deletedField = 'deleted_at';
|
||||
|
||||
// Validation
|
||||
protected $validationRules = [];
|
||||
protected $validationRules = [ 'school_year' => 'required|string|max_length[9]',
|
||||
];
|
||||
protected $validationMessages = [];
|
||||
protected $skipValidation = false;
|
||||
protected $cleanValidationRules = true;
|
||||
|
||||
@@ -3,9 +3,12 @@
|
||||
namespace App\Models;
|
||||
|
||||
use CodeIgniter\Model;
|
||||
use App\Models\Concerns\SchoolYearAutoFillTrait;
|
||||
|
||||
class FinalScoreModel extends Model
|
||||
{
|
||||
use SchoolYearAutoFillTrait;
|
||||
|
||||
protected $table = 'final_score';
|
||||
protected $primaryKey = 'id';
|
||||
protected $useAutoIncrement = true;
|
||||
@@ -23,6 +26,10 @@ class FinalScoreModel extends Model
|
||||
'created_at',
|
||||
'updated_at'
|
||||
];
|
||||
protected $validationRules = [
|
||||
'school_year' => 'required|string|max_length[9]',
|
||||
];
|
||||
|
||||
|
||||
// Function to get the final exam score for a specific student, semester, and school year
|
||||
public function getFinalExamScore($studentId, $semester, $schoolYear)
|
||||
|
||||
@@ -3,9 +3,12 @@
|
||||
namespace App\Models;
|
||||
|
||||
use CodeIgniter\Model;
|
||||
use App\Models\Concerns\SchoolYearAutoFillTrait;
|
||||
|
||||
class FlagModel extends Model
|
||||
{
|
||||
use SchoolYearAutoFillTrait;
|
||||
|
||||
protected $table = 'flag';
|
||||
protected $primaryKey = 'id';
|
||||
protected $allowedFields = [
|
||||
@@ -27,4 +30,8 @@ class FlagModel extends Model
|
||||
'created_at',
|
||||
'updated_at'
|
||||
];
|
||||
protected $validationRules = [
|
||||
'school_year' => 'required|string|max_length[9]',
|
||||
];
|
||||
|
||||
}
|
||||
|
||||
@@ -3,9 +3,12 @@
|
||||
namespace App\Models;
|
||||
|
||||
use CodeIgniter\Model;
|
||||
use App\Models\Concerns\SchoolYearAutoFillTrait;
|
||||
|
||||
class GradingLockModel extends Model
|
||||
{
|
||||
use SchoolYearAutoFillTrait;
|
||||
|
||||
protected $table = 'grading_locks';
|
||||
protected $primaryKey = 'id';
|
||||
protected $returnType = 'array';
|
||||
@@ -20,6 +23,10 @@ class GradingLockModel extends Model
|
||||
'created_at',
|
||||
'updated_at',
|
||||
];
|
||||
protected $validationRules = [
|
||||
'school_year' => 'required|string|max_length[9]',
|
||||
];
|
||||
|
||||
|
||||
public function getLock(int $classSectionId, string $semester, string $schoolYear): ?array
|
||||
{
|
||||
|
||||
@@ -3,9 +3,12 @@
|
||||
namespace App\Models;
|
||||
|
||||
use CodeIgniter\Model;
|
||||
use App\Models\Concerns\SchoolYearAutoFillTrait;
|
||||
|
||||
class HomeworkModel extends Model
|
||||
{
|
||||
use SchoolYearAutoFillTrait;
|
||||
|
||||
protected $table = 'homework';
|
||||
protected $primaryKey = 'id';
|
||||
protected $useAutoIncrement = true;
|
||||
@@ -40,7 +43,8 @@ class HomeworkModel extends Model
|
||||
protected $deletedField = 'deleted_at';
|
||||
|
||||
// Validation
|
||||
protected $validationRules = [];
|
||||
protected $validationRules = [ 'school_year' => 'required|string|max_length[9]',
|
||||
];
|
||||
protected $validationMessages = [];
|
||||
protected $skipValidation = false;
|
||||
protected $cleanValidationRules = true;
|
||||
|
||||
@@ -3,9 +3,12 @@
|
||||
namespace App\Models;
|
||||
|
||||
use CodeIgniter\Model;
|
||||
use App\Models\Concerns\SchoolYearAutoFillTrait;
|
||||
|
||||
class InventoryCategoryModel extends Model
|
||||
{
|
||||
use SchoolYearAutoFillTrait;
|
||||
|
||||
protected $table = 'inventory_categories';
|
||||
protected $primaryKey = 'id';
|
||||
protected $returnType = 'array';
|
||||
@@ -19,7 +22,12 @@ class InventoryCategoryModel extends Model
|
||||
'grade_max',
|
||||
'created_at',
|
||||
'updated_at',
|
||||
'school_year',
|
||||
];
|
||||
protected $validationRules = [
|
||||
'school_year' => 'required|string|max_length[9]',
|
||||
];
|
||||
|
||||
|
||||
public function optionsForType(string $type): array
|
||||
{
|
||||
|
||||
@@ -3,9 +3,12 @@
|
||||
namespace App\Models;
|
||||
|
||||
use CodeIgniter\Model;
|
||||
use App\Models\Concerns\SchoolYearAutoFillTrait;
|
||||
|
||||
class InventoryItemModel extends Model
|
||||
{
|
||||
use SchoolYearAutoFillTrait;
|
||||
|
||||
protected $table = 'inventory_items';
|
||||
protected $primaryKey = 'id';
|
||||
|
||||
@@ -38,6 +41,7 @@ protected $table = 'inventory_items';
|
||||
'needs_repair_qty',
|
||||
'need_replace_qty',
|
||||
'cannot_find_qty',
|
||||
'school_year',
|
||||
];
|
||||
|
||||
|
||||
@@ -46,5 +50,6 @@ protected $table = 'inventory_items';
|
||||
'name' => 'required|min_length[2]',
|
||||
'quantity' => 'permit_empty|integer',
|
||||
'unit_price' => 'permit_empty|decimal',
|
||||
'school_year' => 'required|string|max_length[16]',
|
||||
];
|
||||
}
|
||||
|
||||
@@ -3,9 +3,12 @@
|
||||
namespace App\Models;
|
||||
|
||||
use CodeIgniter\Model;
|
||||
use App\Models\Concerns\SchoolYearAutoFillTrait;
|
||||
|
||||
class InventoryMovementModel extends Model
|
||||
{
|
||||
use SchoolYearAutoFillTrait;
|
||||
|
||||
protected $table = 'inventory_movements';
|
||||
protected $primaryKey = 'id';
|
||||
protected $returnType = 'array';
|
||||
@@ -16,4 +19,8 @@ class InventoryMovementModel extends Model
|
||||
'semester','school_year',
|
||||
'performed_by','teacher_id','student_id','class_section_id',
|
||||
];
|
||||
protected $validationRules = [
|
||||
'school_year' => 'required|string|max_length[9]',
|
||||
];
|
||||
|
||||
}
|
||||
|
||||
@@ -3,9 +3,12 @@
|
||||
namespace App\Models;
|
||||
|
||||
use CodeIgniter\Model;
|
||||
use App\Models\Concerns\SchoolYearAutoFillTrait;
|
||||
|
||||
class InvoiceEventModel extends Model
|
||||
{
|
||||
use SchoolYearAutoFillTrait;
|
||||
|
||||
protected $table = 'invoice_event';
|
||||
protected $primaryKey = 'id';
|
||||
|
||||
@@ -20,6 +23,10 @@ class InvoiceEventModel extends Model
|
||||
'created_at',
|
||||
'updated_at'
|
||||
];
|
||||
protected $validationRules = [
|
||||
'school_year' => 'required|string|max_length[9]',
|
||||
];
|
||||
|
||||
|
||||
protected $useTimestamps = true;
|
||||
protected $createdField = 'created_at';
|
||||
|
||||
@@ -3,9 +3,12 @@
|
||||
namespace App\Models;
|
||||
|
||||
use CodeIgniter\Model;
|
||||
use App\Models\Concerns\SchoolYearAutoFillTrait;
|
||||
|
||||
class InvoiceModel extends Model
|
||||
{
|
||||
use SchoolYearAutoFillTrait;
|
||||
|
||||
protected $table = 'invoices';
|
||||
protected $primaryKey = 'id';
|
||||
protected $returnType = 'array';
|
||||
@@ -40,6 +43,7 @@ class InvoiceModel extends Model
|
||||
'issue_date' => 'required|valid_date[Y-m-d H:i:s]',
|
||||
'due_date' => 'permit_empty|valid_date[Y-m-d H:i:s]',
|
||||
'status' => 'required|string|max_length[50]',
|
||||
'school_year' => 'required|string|max_length[9]',
|
||||
];
|
||||
|
||||
|
||||
|
||||
@@ -3,9 +3,12 @@
|
||||
namespace App\Models;
|
||||
|
||||
use CodeIgniter\Model;
|
||||
use App\Models\Concerns\SchoolYearAutoFillTrait;
|
||||
|
||||
class InvoiceStudentListModel extends Model
|
||||
{
|
||||
use SchoolYearAutoFillTrait;
|
||||
|
||||
// Specify the table name
|
||||
protected $table = 'invoice_students_list';
|
||||
|
||||
@@ -21,8 +24,13 @@ class InvoiceStudentListModel extends Model
|
||||
'school_id',
|
||||
'enrolled',
|
||||
'created_at',
|
||||
'updated_at'
|
||||
'updated_at',
|
||||
'school_year',
|
||||
];
|
||||
protected $validationRules = [
|
||||
'school_year' => 'required|string|max_length[9]',
|
||||
];
|
||||
|
||||
|
||||
// Enable auto-incrementing primary key
|
||||
protected $useAutoIncrement = true;
|
||||
|
||||
@@ -3,9 +3,12 @@
|
||||
namespace App\Models;
|
||||
|
||||
use CodeIgniter\Model;
|
||||
use App\Models\Concerns\SchoolYearAutoFillTrait;
|
||||
|
||||
class IpAttemptModel extends Model
|
||||
{
|
||||
use SchoolYearAutoFillTrait;
|
||||
|
||||
protected $table = 'ip_attempts';
|
||||
protected $primaryKey = 'id';
|
||||
|
||||
@@ -13,7 +16,8 @@ class IpAttemptModel extends Model
|
||||
'ip_address',
|
||||
'attempts',
|
||||
'last_attempt_at',
|
||||
'blocked_until'
|
||||
'blocked_until',
|
||||
'school_year',
|
||||
];
|
||||
|
||||
// Automatically handle timestamps
|
||||
@@ -26,7 +30,8 @@ class IpAttemptModel extends Model
|
||||
'ip_address' => 'required|valid_ip|max_length[45]',
|
||||
'attempts' => 'required|integer',
|
||||
'last_attempt_at' => 'required|valid_date',
|
||||
'blocked_until' => 'permit_empty|valid_date'
|
||||
'blocked_until' => 'permit_empty|valid_date',
|
||||
'school_year' => 'required|string|max_length[20]',
|
||||
];
|
||||
|
||||
// Method to get IP attempt data by IP address
|
||||
|
||||
@@ -3,9 +3,12 @@
|
||||
namespace App\Models;
|
||||
|
||||
use CodeIgniter\Model;
|
||||
use App\Models\Concerns\SchoolYearAutoFillTrait;
|
||||
|
||||
class LateSlipLogModel extends Model
|
||||
{
|
||||
use SchoolYearAutoFillTrait;
|
||||
|
||||
protected $table = 'late_slip_logs';
|
||||
protected $primaryKey = 'id';
|
||||
protected $useTimestamps = false; // we control printed_at explicitly
|
||||
@@ -22,6 +25,10 @@ class LateSlipLogModel extends Model
|
||||
'printed_by',
|
||||
'printed_at',
|
||||
];
|
||||
protected $validationRules = [
|
||||
'school_year' => 'required|string|max_length[9]',
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* Best-effort insert of a single late slip print log.
|
||||
|
||||
@@ -3,9 +3,12 @@
|
||||
namespace App\Models;
|
||||
|
||||
use CodeIgniter\Model;
|
||||
use App\Models\Concerns\SchoolYearAutoFillTrait;
|
||||
|
||||
class LoginActivityModel extends Model
|
||||
{
|
||||
use SchoolYearAutoFillTrait;
|
||||
|
||||
protected $table = 'login_activity';
|
||||
protected $primaryKey = 'id';
|
||||
protected $allowedFields = [
|
||||
@@ -17,8 +20,13 @@ class LoginActivityModel extends Model
|
||||
'user_agent',
|
||||
'semester',
|
||||
'created_at',
|
||||
'updated_at'
|
||||
'updated_at',
|
||||
'school_year',
|
||||
];
|
||||
protected $validationRules = [
|
||||
'school_year' => 'required|string|max_length[9]',
|
||||
];
|
||||
|
||||
|
||||
protected $useTimestamps = true;
|
||||
protected $createdField = 'created_at';
|
||||
|
||||
@@ -3,9 +3,12 @@
|
||||
namespace App\Models;
|
||||
|
||||
use CodeIgniter\Model;
|
||||
use App\Models\Concerns\SchoolYearAutoFillTrait;
|
||||
|
||||
class ManualPaymentModel extends Model
|
||||
{
|
||||
use SchoolYearAutoFillTrait;
|
||||
|
||||
protected $table = 'manual_payments';
|
||||
protected $allowedFields = [
|
||||
'invoice_number',
|
||||
@@ -16,6 +19,10 @@ class ManualPaymentModel extends Model
|
||||
'semester',
|
||||
'school_year',
|
||||
'created_at'];
|
||||
protected $validationRules = [
|
||||
'school_year' => 'required|string|max_length[9]',
|
||||
];
|
||||
|
||||
|
||||
protected $useTimestamps = false;
|
||||
}
|
||||
|
||||
@@ -3,9 +3,12 @@
|
||||
namespace App\Models;
|
||||
|
||||
use CodeIgniter\Model;
|
||||
use App\Models\Concerns\SchoolYearAutoFillTrait;
|
||||
|
||||
class MessageModel extends Model
|
||||
{
|
||||
use SchoolYearAutoFillTrait;
|
||||
|
||||
protected $table = 'messages';
|
||||
protected $primaryKey = 'id';
|
||||
|
||||
@@ -21,8 +24,13 @@ class MessageModel extends Model
|
||||
'priority',
|
||||
'attachment',
|
||||
'status',
|
||||
'semester'
|
||||
'semester',
|
||||
'school_year',
|
||||
];
|
||||
protected $validationRules = [
|
||||
'school_year' => 'required|string|max_length[9]',
|
||||
];
|
||||
|
||||
|
||||
protected $useTimestamps = false; // Since you're manually handling date fields
|
||||
protected $returnType = 'array';
|
||||
|
||||
@@ -3,9 +3,12 @@
|
||||
namespace App\Models;
|
||||
|
||||
use CodeIgniter\Model;
|
||||
use App\Models\Concerns\SchoolYearAutoFillTrait;
|
||||
|
||||
class MidtermExamModel extends Model
|
||||
{
|
||||
use SchoolYearAutoFillTrait;
|
||||
|
||||
protected $table = 'midterm_exam';
|
||||
protected $primaryKey = 'id';
|
||||
protected $useAutoIncrement = true;
|
||||
@@ -39,7 +42,8 @@ class MidtermExamModel extends Model
|
||||
protected $deletedField = 'deleted_at';
|
||||
|
||||
// Validation
|
||||
protected $validationRules = [];
|
||||
protected $validationRules = [ 'school_year' => 'required|string|max_length[9]',
|
||||
];
|
||||
protected $validationMessages = [];
|
||||
protected $skipValidation = false;
|
||||
protected $cleanValidationRules = true;
|
||||
|
||||
@@ -3,9 +3,12 @@
|
||||
namespace App\Models;
|
||||
|
||||
use CodeIgniter\Model;
|
||||
use App\Models\Concerns\SchoolYearAutoFillTrait;
|
||||
|
||||
class MissingScoreOverrideModel extends Model
|
||||
{
|
||||
use SchoolYearAutoFillTrait;
|
||||
|
||||
protected $table = 'missing_score_overrides';
|
||||
protected $primaryKey = 'id';
|
||||
protected $returnType = 'array';
|
||||
@@ -22,6 +25,10 @@ class MissingScoreOverrideModel extends Model
|
||||
'created_at',
|
||||
'updated_at',
|
||||
];
|
||||
protected $validationRules = [
|
||||
'school_year' => 'required|string|max_length[9]',
|
||||
];
|
||||
|
||||
|
||||
public function getOverridesMap(int $classSectionId, string $semester, string $schoolYear, string $itemType): array
|
||||
{
|
||||
|
||||
@@ -3,9 +3,12 @@
|
||||
namespace App\Models;
|
||||
|
||||
use CodeIgniter\Model;
|
||||
use App\Models\Concerns\SchoolYearAutoFillTrait;
|
||||
|
||||
class NotificationModel extends Model
|
||||
{
|
||||
use SchoolYearAutoFillTrait;
|
||||
|
||||
protected $table = 'notifications';
|
||||
protected $primaryKey = 'id';
|
||||
protected $allowedFields = [
|
||||
@@ -20,8 +23,13 @@ class NotificationModel extends Model
|
||||
'expires_at',
|
||||
'sent_at',
|
||||
'scheduled_at',
|
||||
'deleted_at'
|
||||
'deleted_at',
|
||||
'school_year',
|
||||
];
|
||||
protected $validationRules = [
|
||||
'school_year' => 'required|string|max_length[20]',
|
||||
];
|
||||
|
||||
protected $useTimestamps = true;
|
||||
protected $createdField = 'created_at';
|
||||
protected $updatedField = 'updated_at';
|
||||
|
||||
@@ -3,9 +3,12 @@
|
||||
namespace App\Models;
|
||||
|
||||
use CodeIgniter\Model;
|
||||
use App\Models\Concerns\SchoolYearAutoFillTrait;
|
||||
|
||||
class ParentAttendanceReportModel extends Model
|
||||
{
|
||||
use SchoolYearAutoFillTrait;
|
||||
|
||||
protected $table = 'parent_attendance_reports';
|
||||
protected $primaryKey = 'id';
|
||||
protected $useAutoIncrement = true;
|
||||
@@ -36,7 +39,7 @@ class ParentAttendanceReportModel extends Model
|
||||
'arrival_time' => 'permit_empty|regex_match[/^\d{2}:\d{2}(:\d{2})?$/]',
|
||||
'dismiss_time' => 'permit_empty|regex_match[/^\d{2}:\d{2}(:\d{2})?$/]',
|
||||
'semester' => 'permit_empty|string',
|
||||
'school_year' => 'permit_empty|string',
|
||||
'school_year' => 'required|string|max_length[9]',
|
||||
'status' => 'permit_empty|in_list[new,seen,processed]',
|
||||
];
|
||||
|
||||
|
||||
@@ -3,9 +3,12 @@
|
||||
namespace App\Models;
|
||||
|
||||
use CodeIgniter\Model;
|
||||
use App\Models\Concerns\SchoolYearAutoFillTrait;
|
||||
|
||||
class ParentMeetingScheduleModel extends Model
|
||||
{
|
||||
use SchoolYearAutoFillTrait;
|
||||
|
||||
protected $table = 'parent_meeting_schedules';
|
||||
protected $primaryKey = 'id';
|
||||
|
||||
@@ -23,6 +26,10 @@ class ParentMeetingScheduleModel extends Model
|
||||
'status',
|
||||
'created_by',
|
||||
];
|
||||
protected $validationRules = [
|
||||
'school_year' => 'required|string|max_length[9]',
|
||||
];
|
||||
|
||||
|
||||
protected $useTimestamps = true;
|
||||
protected $createdField = 'created_at';
|
||||
|
||||
@@ -3,9 +3,12 @@
|
||||
namespace App\Models;
|
||||
|
||||
use CodeIgniter\Model;
|
||||
use App\Models\Concerns\SchoolYearAutoFillTrait;
|
||||
|
||||
class ParentNotificationModel extends Model
|
||||
{
|
||||
use SchoolYearAutoFillTrait;
|
||||
|
||||
protected $table = 'parent_notifications';
|
||||
protected $primaryKey = 'id';
|
||||
protected $useTimestamps = true;
|
||||
@@ -16,6 +19,10 @@ class ParentNotificationModel extends Model
|
||||
'student_id','code','incident_date','channel','to_address','subject',
|
||||
'status','response','semester','school_year'
|
||||
];
|
||||
protected $validationRules = [
|
||||
'school_year' => 'required|string|max_length[9]',
|
||||
];
|
||||
|
||||
|
||||
public function hasSent(int $studentId, string $code, string $incidentYmd, string $channel='email', ?string $to=null): bool
|
||||
{
|
||||
|
||||
@@ -3,9 +3,12 @@
|
||||
namespace App\Models;
|
||||
|
||||
use CodeIgniter\Model;
|
||||
use App\Models\Concerns\SchoolYearAutoFillTrait;
|
||||
|
||||
class ParticipationModel extends Model
|
||||
{
|
||||
use SchoolYearAutoFillTrait;
|
||||
|
||||
protected $table = 'participation';
|
||||
protected $primaryKey = 'id';
|
||||
protected $useAutoIncrement = true;
|
||||
@@ -39,7 +42,8 @@ class ParticipationModel extends Model
|
||||
protected $deletedField = 'deleted_at';
|
||||
|
||||
// Validation
|
||||
protected $validationRules = [];
|
||||
protected $validationRules = [ 'school_year' => 'required|string|max_length[9]',
|
||||
];
|
||||
protected $validationMessages = [];
|
||||
protected $skipValidation = false;
|
||||
protected $cleanValidationRules = true;
|
||||
|
||||
@@ -3,9 +3,12 @@
|
||||
namespace App\Models;
|
||||
|
||||
use CodeIgniter\Model;
|
||||
use App\Models\Concerns\SchoolYearAutoFillTrait;
|
||||
|
||||
class PaymentErrorModel extends Model
|
||||
{
|
||||
use SchoolYearAutoFillTrait;
|
||||
|
||||
protected $table = 'payment_error'; // The DB table
|
||||
protected $primaryKey = 'id'; // Primary key
|
||||
|
||||
@@ -28,7 +31,8 @@ class PaymentErrorModel extends Model
|
||||
'wrong_paid_amount' => 'required|decimal',
|
||||
'payment_id' => 'required|integer',
|
||||
'invoice_id' => 'required|integer',
|
||||
'parent_id' => 'required|integer'
|
||||
'parent_id' => 'required|integer',
|
||||
'school_year' => 'required|string|max_length[9]',
|
||||
];
|
||||
|
||||
}
|
||||
|
||||
@@ -4,10 +4,13 @@ namespace App\Models;
|
||||
|
||||
use CodeIgniter\Database\ConnectionInterface;
|
||||
use CodeIgniter\Model;
|
||||
use App\Models\Concerns\SchoolYearAutoFillTrait;
|
||||
use CodeIgniter\Validation\ValidationInterface;
|
||||
|
||||
class PaymentModel extends Model
|
||||
{
|
||||
use SchoolYearAutoFillTrait;
|
||||
|
||||
protected $table = 'payments';
|
||||
protected $primaryKey = 'id';
|
||||
protected $returnType = 'array';
|
||||
@@ -69,7 +72,7 @@ class PaymentModel extends Model
|
||||
'transaction_id' => 'permit_empty|max_length[100]',
|
||||
'payment_method' => 'required|in_list[cash,check,card]',
|
||||
'payment_date' => 'required|valid_date',
|
||||
'school_year' => 'permit_empty|max_length[20]',
|
||||
'school_year' => 'required|string|max_length[9]',
|
||||
'status' => 'required|max_length[50]',
|
||||
'check_file' => 'permit_empty|max_length[255]',
|
||||
'check_number' => 'permit_empty|max_length[100]',
|
||||
|
||||
@@ -3,9 +3,12 @@
|
||||
namespace App\Models;
|
||||
|
||||
use CodeIgniter\Model;
|
||||
use App\Models\Concerns\SchoolYearAutoFillTrait;
|
||||
|
||||
class PaymentNotificationLogModel extends Model
|
||||
{
|
||||
use SchoolYearAutoFillTrait;
|
||||
|
||||
protected $table = 'payment_notification_logs';
|
||||
protected $primaryKey = 'id';
|
||||
protected $returnType = 'array';
|
||||
@@ -29,6 +32,10 @@ class PaymentNotificationLogModel extends Model
|
||||
'created_at',
|
||||
'sent_at',
|
||||
];
|
||||
protected $validationRules = [
|
||||
'school_year' => 'required|string|max_length[9]',
|
||||
];
|
||||
|
||||
|
||||
protected $useTimestamps = false;
|
||||
|
||||
|
||||
@@ -3,9 +3,12 @@
|
||||
namespace App\Models;
|
||||
|
||||
use CodeIgniter\Model;
|
||||
use App\Models\Concerns\SchoolYearAutoFillTrait;
|
||||
|
||||
class PaymentTransactionModel extends Model
|
||||
{
|
||||
use SchoolYearAutoFillTrait;
|
||||
|
||||
protected $table = 'payment_transactions'; // Table name
|
||||
protected $primaryKey = 'id'; // Primary key
|
||||
|
||||
@@ -32,7 +35,7 @@ class PaymentTransactionModel extends Model
|
||||
'payment_method' => 'required|string|max_length[50]',
|
||||
'payment_status' => 'required|string|max_length[50]',
|
||||
'semester' => 'permit_empty|string|max_length[30]',
|
||||
'school_year' => 'permit_empty|string|max_length[9]',
|
||||
'school_year' => 'required|string|max_length[9]',
|
||||
];
|
||||
|
||||
// Custom error messages
|
||||
|
||||
@@ -3,9 +3,12 @@
|
||||
namespace App\Models;
|
||||
|
||||
use CodeIgniter\Model;
|
||||
use App\Models\Concerns\SchoolYearAutoFillTrait;
|
||||
|
||||
class PlacementBatchModel extends Model
|
||||
{
|
||||
use SchoolYearAutoFillTrait;
|
||||
|
||||
protected $table = 'placement_batches';
|
||||
protected $primaryKey = 'id';
|
||||
|
||||
@@ -17,6 +20,10 @@ class PlacementBatchModel extends Model
|
||||
'created_at',
|
||||
'updated_at',
|
||||
];
|
||||
protected $validationRules = [
|
||||
'school_year' => 'required|string|max_length[9]',
|
||||
];
|
||||
|
||||
|
||||
protected $useTimestamps = true;
|
||||
protected $createdField = 'created_at';
|
||||
|
||||
@@ -3,9 +3,12 @@
|
||||
namespace App\Models;
|
||||
|
||||
use CodeIgniter\Model;
|
||||
use App\Models\Concerns\SchoolYearAutoFillTrait;
|
||||
|
||||
class PlacementLevelModel extends Model
|
||||
{
|
||||
use SchoolYearAutoFillTrait;
|
||||
|
||||
protected $table = 'placement_levels';
|
||||
protected $primaryKey = 'id';
|
||||
|
||||
@@ -16,7 +19,12 @@ class PlacementLevelModel extends Model
|
||||
'updated_by',
|
||||
'created_at',
|
||||
'updated_at',
|
||||
'school_year',
|
||||
];
|
||||
protected $validationRules = [
|
||||
'school_year' => 'required|string|max_length[20]',
|
||||
];
|
||||
|
||||
|
||||
protected $useTimestamps = true;
|
||||
protected $createdField = 'created_at';
|
||||
|
||||
@@ -3,9 +3,12 @@
|
||||
namespace App\Models;
|
||||
|
||||
use CodeIgniter\Model;
|
||||
use App\Models\Concerns\SchoolYearAutoFillTrait;
|
||||
|
||||
class PlacementScoreModel extends Model
|
||||
{
|
||||
use SchoolYearAutoFillTrait;
|
||||
|
||||
protected $table = 'placement_scores';
|
||||
protected $primaryKey = 'id';
|
||||
|
||||
@@ -17,7 +20,12 @@ class PlacementScoreModel extends Model
|
||||
'updated_by',
|
||||
'created_at',
|
||||
'updated_at',
|
||||
'school_year',
|
||||
];
|
||||
protected $validationRules = [
|
||||
'school_year' => 'required|string|max_length[9]',
|
||||
];
|
||||
|
||||
|
||||
protected $useTimestamps = true;
|
||||
protected $createdField = 'created_at';
|
||||
|
||||
@@ -3,9 +3,12 @@
|
||||
namespace App\Models;
|
||||
|
||||
use CodeIgniter\Model;
|
||||
use App\Models\Concerns\SchoolYearAutoFillTrait;
|
||||
|
||||
class PrintRequestModel extends Model
|
||||
{
|
||||
use SchoolYearAutoFillTrait;
|
||||
|
||||
protected $table = 'print_requests';
|
||||
protected $primaryKey = 'id';
|
||||
protected $useAutoIncrement = true;
|
||||
@@ -31,7 +34,8 @@ class PrintRequestModel extends Model
|
||||
protected $updatedField = 'updated_at';
|
||||
|
||||
// Validation
|
||||
protected $validationRules = [];
|
||||
protected $validationRules = [ 'school_year' => 'required|string|max_length[9]',
|
||||
];
|
||||
protected $validationMessages = [];
|
||||
protected $skipValidation = false;
|
||||
protected $cleanValidationRules = true;
|
||||
|
||||
@@ -3,9 +3,12 @@
|
||||
namespace App\Models;
|
||||
|
||||
use CodeIgniter\Model;
|
||||
use App\Models\Concerns\SchoolYearAutoFillTrait;
|
||||
|
||||
class ProjectModel extends Model
|
||||
{
|
||||
use SchoolYearAutoFillTrait;
|
||||
|
||||
protected $table = 'project';
|
||||
protected $primaryKey = 'id';
|
||||
protected $useAutoIncrement = true;
|
||||
@@ -23,6 +26,10 @@ class ProjectModel extends Model
|
||||
'created_at',
|
||||
'updated_at'
|
||||
];
|
||||
protected $validationRules = [
|
||||
'school_year' => 'required|string|max_length[9]',
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* Calculate the average project score for a given student, semester, and school year.
|
||||
|
||||
@@ -3,9 +3,12 @@
|
||||
namespace App\Models;
|
||||
|
||||
use CodeIgniter\Model;
|
||||
use App\Models\Concerns\SchoolYearAutoFillTrait;
|
||||
|
||||
class PromotionQueueModel extends Model
|
||||
{
|
||||
use SchoolYearAutoFillTrait;
|
||||
|
||||
protected $table = 'promotion_queue';
|
||||
protected $primaryKey = 'id';
|
||||
|
||||
@@ -20,7 +23,12 @@ class PromotionQueueModel extends Model
|
||||
'created_at',
|
||||
'updated_at',
|
||||
'updated_by',
|
||||
'school_year',
|
||||
];
|
||||
protected $validationRules = [
|
||||
'school_year' => 'required|string|max_length[9]',
|
||||
];
|
||||
|
||||
|
||||
protected $useTimestamps = true;
|
||||
protected $createdField = 'created_at';
|
||||
@@ -32,6 +40,8 @@ class PromotionQueueModel extends Model
|
||||
return false;
|
||||
}
|
||||
|
||||
$data['school_year'] = (string)($data['school_year'] ?? $data['school_year_from'] ?? $data['school_year_to']);
|
||||
|
||||
$existing = $this->where('student_id', (int)$data['student_id'])
|
||||
->where('school_year_to', (string)$data['school_year_to'])
|
||||
->first();
|
||||
@@ -43,4 +53,3 @@ class PromotionQueueModel extends Model
|
||||
return (bool) $this->insert($data);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,9 +3,12 @@
|
||||
namespace App\Models;
|
||||
|
||||
use CodeIgniter\Model;
|
||||
use App\Models\Concerns\SchoolYearAutoFillTrait;
|
||||
|
||||
class QuizModel extends Model
|
||||
{
|
||||
use SchoolYearAutoFillTrait;
|
||||
|
||||
protected $table = 'quiz';
|
||||
protected $primaryKey = 'id';
|
||||
protected $useAutoIncrement = true;
|
||||
@@ -40,7 +43,8 @@ class QuizModel extends Model
|
||||
protected $deletedField = 'deleted_at';
|
||||
|
||||
// Validation
|
||||
protected $validationRules = [];
|
||||
protected $validationRules = [ 'school_year' => 'required|string|max_length[9]',
|
||||
];
|
||||
protected $validationMessages = [];
|
||||
protected $skipValidation = false;
|
||||
protected $cleanValidationRules = true;
|
||||
|
||||
@@ -3,9 +3,12 @@
|
||||
namespace App\Models;
|
||||
|
||||
use CodeIgniter\Model;
|
||||
use App\Models\Concerns\SchoolYearAutoFillTrait;
|
||||
|
||||
class RefundModel extends Model
|
||||
{
|
||||
use SchoolYearAutoFillTrait;
|
||||
|
||||
protected $table = 'refunds';
|
||||
protected $primaryKey = 'id';
|
||||
|
||||
@@ -30,6 +33,10 @@ class RefundModel extends Model
|
||||
'check_nbr',
|
||||
'check_file'
|
||||
];
|
||||
protected $validationRules = [
|
||||
'school_year' => 'required|string|max_length[9]',
|
||||
];
|
||||
|
||||
|
||||
protected $useTimestamps = true;
|
||||
protected $createdField = 'created_at';
|
||||
|
||||
@@ -3,9 +3,12 @@
|
||||
namespace App\Models;
|
||||
|
||||
use CodeIgniter\Model;
|
||||
use App\Models\Concerns\SchoolYearAutoFillTrait;
|
||||
|
||||
class ReimbursementBatchAdminFileModel extends Model
|
||||
{
|
||||
use SchoolYearAutoFillTrait;
|
||||
|
||||
protected $table = 'reimbursement_batch_admin_files';
|
||||
protected $primaryKey = 'id';
|
||||
protected $allowedFields = [
|
||||
@@ -15,6 +18,11 @@ class ReimbursementBatchAdminFileModel extends Model
|
||||
'original_filename',
|
||||
'uploaded_at',
|
||||
'uploaded_by',
|
||||
'school_year',
|
||||
];
|
||||
protected $validationRules = [
|
||||
'school_year' => 'required|string|max_length[9]',
|
||||
];
|
||||
|
||||
protected $useTimestamps = false;
|
||||
}
|
||||
|
||||
@@ -3,9 +3,12 @@
|
||||
namespace App\Models;
|
||||
|
||||
use CodeIgniter\Model;
|
||||
use App\Models\Concerns\SchoolYearAutoFillTrait;
|
||||
|
||||
class ReimbursementBatchItemModel extends Model
|
||||
{
|
||||
use SchoolYearAutoFillTrait;
|
||||
|
||||
protected $table = 'reimbursement_batch_items';
|
||||
protected $primaryKey = 'id';
|
||||
protected $allowedFields = [
|
||||
@@ -19,6 +22,10 @@ class ReimbursementBatchItemModel extends Model
|
||||
'school_year',
|
||||
'semester',
|
||||
];
|
||||
protected $validationRules = [
|
||||
'school_year' => 'required|string|max_length[9]',
|
||||
];
|
||||
|
||||
|
||||
protected $useTimestamps = false;
|
||||
}
|
||||
|
||||
@@ -3,9 +3,12 @@
|
||||
namespace App\Models;
|
||||
|
||||
use CodeIgniter\Model;
|
||||
use App\Models\Concerns\SchoolYearAutoFillTrait;
|
||||
|
||||
class ReimbursementBatchModel extends Model
|
||||
{
|
||||
use SchoolYearAutoFillTrait;
|
||||
|
||||
protected $table = 'reimbursement_batches';
|
||||
protected $primaryKey = 'id';
|
||||
protected $allowedFields = [
|
||||
@@ -20,6 +23,10 @@ class ReimbursementBatchModel extends Model
|
||||
'semester',
|
||||
'yearly_batch_number',
|
||||
];
|
||||
protected $validationRules = [
|
||||
'school_year' => 'required|string|max_length[9]',
|
||||
];
|
||||
|
||||
|
||||
protected $useTimestamps = false;
|
||||
}
|
||||
|
||||
@@ -3,9 +3,12 @@
|
||||
namespace App\Models;
|
||||
|
||||
use CodeIgniter\Model;
|
||||
use App\Models\Concerns\SchoolYearAutoFillTrait;
|
||||
|
||||
class ReimbursementModel extends Model
|
||||
{
|
||||
use SchoolYearAutoFillTrait;
|
||||
|
||||
protected $table = 'reimbursements';
|
||||
protected $primaryKey = 'id';
|
||||
protected $allowedFields = [
|
||||
@@ -23,5 +26,9 @@ class ReimbursementModel extends Model
|
||||
'reimbursement_method',
|
||||
'batch_number'
|
||||
];
|
||||
protected $validationRules = [
|
||||
'school_year' => 'required|string|max_length[9]',
|
||||
];
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -3,9 +3,12 @@
|
||||
namespace App\Models;
|
||||
|
||||
use CodeIgniter\Model;
|
||||
use App\Models\Concerns\SchoolYearAutoFillTrait;
|
||||
|
||||
class ReportCardAcknowledgementModel extends Model
|
||||
{
|
||||
use SchoolYearAutoFillTrait;
|
||||
|
||||
protected $table = 'report_card_acknowledgements';
|
||||
protected $primaryKey = 'id';
|
||||
protected $allowedFields = [
|
||||
@@ -20,6 +23,10 @@ class ReportCardAcknowledgementModel extends Model
|
||||
'created_at',
|
||||
'updated_at',
|
||||
];
|
||||
protected $validationRules = [
|
||||
'school_year' => 'required|string|max_length[9]',
|
||||
];
|
||||
|
||||
protected $useTimestamps = true;
|
||||
protected $createdField = 'created_at';
|
||||
protected $updatedField = 'updated_at';
|
||||
|
||||
@@ -3,9 +3,12 @@
|
||||
namespace App\Models;
|
||||
|
||||
use CodeIgniter\Model;
|
||||
use App\Models\Concerns\SchoolYearAutoFillTrait;
|
||||
|
||||
class SchoolYearClosingBatchModel extends Model
|
||||
{
|
||||
use SchoolYearAutoFillTrait;
|
||||
|
||||
protected $table = 'school_year_closing_batches';
|
||||
protected $primaryKey = 'id';
|
||||
protected $returnType = 'array';
|
||||
@@ -25,5 +28,10 @@ class SchoolYearClosingBatchModel extends Model
|
||||
'completed_at',
|
||||
'failed_at',
|
||||
'failure_message',
|
||||
'school_year',
|
||||
];
|
||||
protected $validationRules = [
|
||||
'school_year' => 'required|string|max_length[9]',
|
||||
];
|
||||
|
||||
}
|
||||
|
||||
@@ -3,9 +3,12 @@
|
||||
namespace App\Models;
|
||||
|
||||
use CodeIgniter\Model;
|
||||
use App\Models\Concerns\SchoolYearAutoFillTrait;
|
||||
|
||||
class SchoolYearClosingItemModel extends Model
|
||||
{
|
||||
use SchoolYearAutoFillTrait;
|
||||
|
||||
protected $table = 'school_year_closing_items';
|
||||
protected $primaryKey = 'id';
|
||||
protected $returnType = 'array';
|
||||
@@ -22,5 +25,10 @@ class SchoolYearClosingItemModel extends Model
|
||||
'target_adjustment_id',
|
||||
'status',
|
||||
'error_message',
|
||||
'school_year',
|
||||
];
|
||||
protected $validationRules = [
|
||||
'school_year' => 'required|string|max_length[9]',
|
||||
];
|
||||
|
||||
}
|
||||
|
||||
@@ -3,9 +3,12 @@
|
||||
namespace App\Models;
|
||||
|
||||
use CodeIgniter\Model;
|
||||
use App\Models\Concerns\SchoolYearAutoFillTrait;
|
||||
|
||||
class SchoolYearTransitionLogModel extends Model
|
||||
{
|
||||
use SchoolYearAutoFillTrait;
|
||||
|
||||
protected $table = 'school_year_transition_logs';
|
||||
protected $primaryKey = 'id';
|
||||
protected $returnType = 'array';
|
||||
@@ -19,5 +22,10 @@ class SchoolYearTransitionLogModel extends Model
|
||||
'performed_by',
|
||||
'metadata_json',
|
||||
'created_at',
|
||||
'school_year',
|
||||
];
|
||||
protected $validationRules = [
|
||||
'school_year' => 'required|string|max_length[9]',
|
||||
];
|
||||
|
||||
}
|
||||
|
||||
@@ -3,9 +3,12 @@
|
||||
namespace App\Models;
|
||||
|
||||
use CodeIgniter\Model;
|
||||
use App\Models\Concerns\SchoolYearAutoFillTrait;
|
||||
|
||||
class ScoreCommentModel extends Model
|
||||
{
|
||||
use SchoolYearAutoFillTrait;
|
||||
|
||||
protected $table = 'score_comments';
|
||||
protected $primaryKey = 'id';
|
||||
|
||||
@@ -21,6 +24,10 @@ class ScoreCommentModel extends Model
|
||||
'commented_by',
|
||||
'created_at'
|
||||
];
|
||||
protected $validationRules = [
|
||||
'school_year' => 'required|string|max_length[9]',
|
||||
];
|
||||
|
||||
|
||||
public $timestamps = false; // because we're using MySQL's default timestamp
|
||||
}
|
||||
|
||||
@@ -3,9 +3,12 @@
|
||||
namespace App\Models;
|
||||
|
||||
use CodeIgniter\Model;
|
||||
use App\Models\Concerns\SchoolYearAutoFillTrait;
|
||||
|
||||
class SemesterScoreModel extends Model
|
||||
{
|
||||
use SchoolYearAutoFillTrait;
|
||||
|
||||
protected $table = 'semester_scores';
|
||||
protected $primaryKey = 'id';
|
||||
protected $allowedFields = [
|
||||
@@ -26,6 +29,10 @@ class SemesterScoreModel extends Model
|
||||
'semester',
|
||||
'school_year'
|
||||
];
|
||||
protected $validationRules = [
|
||||
'school_year' => 'required|string|max_length[9]',
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* Insert or update a semester score record
|
||||
@@ -34,6 +41,8 @@ class SemesterScoreModel extends Model
|
||||
|
||||
public function upsert(array $data): bool
|
||||
{
|
||||
$data = $this->withDefaultSchoolYear($data);
|
||||
|
||||
// First check if record exists
|
||||
$existing = $this->where([
|
||||
'student_id' => $data['student_id'],
|
||||
@@ -50,4 +59,4 @@ public function upsert(array $data): bool
|
||||
return $this->insert($data) !== false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,9 +3,12 @@
|
||||
namespace App\Models;
|
||||
|
||||
use CodeIgniter\Model;
|
||||
use App\Models\Concerns\SchoolYearAutoFillTrait;
|
||||
use Config\Services;
|
||||
class StaffAttendanceModel extends Model
|
||||
{
|
||||
use SchoolYearAutoFillTrait;
|
||||
|
||||
protected $table = 'staff_attendance';
|
||||
protected $primaryKey = 'id';
|
||||
protected $returnType = 'array';
|
||||
@@ -25,6 +28,10 @@ class StaffAttendanceModel extends Model
|
||||
'created_by',
|
||||
'updated_by',
|
||||
];
|
||||
protected $validationRules = [
|
||||
'school_year' => 'required|string|max_length[9]',
|
||||
];
|
||||
|
||||
|
||||
protected $useTimestamps = true;
|
||||
protected $createdField = 'created_at';
|
||||
|
||||
@@ -3,9 +3,12 @@
|
||||
namespace App\Models;
|
||||
|
||||
use CodeIgniter\Model;
|
||||
use App\Models\Concerns\SchoolYearAutoFillTrait;
|
||||
|
||||
class StaffModel extends Model
|
||||
{
|
||||
use SchoolYearAutoFillTrait;
|
||||
|
||||
protected $table = 'staff';
|
||||
protected $primaryKey = 'id';
|
||||
protected $useAutoIncrement = true;
|
||||
@@ -22,8 +25,13 @@ class StaffModel extends Model
|
||||
'role_name',
|
||||
'active_role',
|
||||
'created_at',
|
||||
'updated_at'
|
||||
'updated_at',
|
||||
'school_year',
|
||||
];
|
||||
protected $validationRules = [
|
||||
'school_year' => 'required|string|max_length[9]',
|
||||
];
|
||||
|
||||
|
||||
protected $useTimestamps = false; // Managed manually in controller
|
||||
|
||||
@@ -51,7 +59,7 @@ class StaffModel extends Model
|
||||
return false;
|
||||
}
|
||||
|
||||
unset($data['school_year'], $data['status']);
|
||||
unset($data['status']);
|
||||
|
||||
$existing = $this->where('user_id', $data['user_id'])->first();
|
||||
|
||||
|
||||
@@ -4,9 +4,12 @@ namespace App\Models;
|
||||
|
||||
use CodeIgniter\Database\BaseBuilder;
|
||||
use CodeIgniter\Model;
|
||||
use App\Models\Concerns\SchoolYearAutoFillTrait;
|
||||
|
||||
class StudentClassModel extends Model
|
||||
{
|
||||
use SchoolYearAutoFillTrait;
|
||||
|
||||
protected $table = 'student_class';
|
||||
protected $primaryKey = 'id';
|
||||
protected $returnType = 'array';
|
||||
@@ -32,7 +35,7 @@ class StudentClassModel extends Model
|
||||
protected $validationRules = [
|
||||
'student_id' => 'required|integer',
|
||||
'class_section_id'=> 'permit_empty|integer',
|
||||
'school_year' => 'required|max_length[20]',
|
||||
'school_year' => 'required|string|max_length[9]',
|
||||
'is_event_only' => 'permit_empty|in_list[0,1]',
|
||||
'updated_by' => 'permit_empty|integer',
|
||||
];
|
||||
|
||||
@@ -3,9 +3,12 @@
|
||||
namespace App\Models;
|
||||
|
||||
use CodeIgniter\Model;
|
||||
use App\Models\Concerns\SchoolYearAutoFillTrait;
|
||||
|
||||
class StudentDecisionModel extends Model
|
||||
{
|
||||
use SchoolYearAutoFillTrait;
|
||||
|
||||
protected $table = 'student_decisions';
|
||||
protected $primaryKey = 'id';
|
||||
|
||||
@@ -19,6 +22,10 @@ class StudentDecisionModel extends Model
|
||||
'notes',
|
||||
'generated_by',
|
||||
];
|
||||
protected $validationRules = [
|
||||
'school_year' => 'required|string|max_length[9]',
|
||||
];
|
||||
|
||||
|
||||
protected $useTimestamps = true;
|
||||
protected $createdField = 'created_at';
|
||||
|
||||
@@ -3,9 +3,12 @@
|
||||
namespace App\Models;
|
||||
|
||||
use CodeIgniter\Model;
|
||||
use App\Models\Concerns\SchoolYearAutoFillTrait;
|
||||
|
||||
class StudentSectionDistributionDraftModel extends Model
|
||||
{
|
||||
use SchoolYearAutoFillTrait;
|
||||
|
||||
protected $table = 'student_section_distribution_drafts';
|
||||
protected $primaryKey = 'id';
|
||||
protected $returnType = 'array';
|
||||
@@ -27,6 +30,10 @@ class StudentSectionDistributionDraftModel extends Model
|
||||
'created_at',
|
||||
'updated_at',
|
||||
];
|
||||
protected $validationRules = [
|
||||
'school_year' => 'required|string|max_length[20]',
|
||||
];
|
||||
|
||||
|
||||
protected $useTimestamps = true;
|
||||
protected $createdField = 'created_at';
|
||||
|
||||
@@ -3,9 +3,12 @@
|
||||
namespace App\Models;
|
||||
|
||||
use CodeIgniter\Model;
|
||||
use App\Models\Concerns\SchoolYearAutoFillTrait;
|
||||
|
||||
class TeacherClassModel extends Model
|
||||
{
|
||||
use SchoolYearAutoFillTrait;
|
||||
|
||||
protected $table = 'teacher_class';
|
||||
protected $primaryKey = 'id';
|
||||
protected $allowedFields = [
|
||||
|
||||
@@ -3,9 +3,12 @@
|
||||
namespace App\Models;
|
||||
|
||||
use CodeIgniter\Model;
|
||||
use App\Models\Concerns\SchoolYearAutoFillTrait;
|
||||
|
||||
class TeacherSubmissionNotificationHistoryModel extends Model
|
||||
{
|
||||
use SchoolYearAutoFillTrait;
|
||||
|
||||
protected $table = 'teacher_submission_notification_history';
|
||||
protected $primaryKey = 'id';
|
||||
protected $allowedFields = [
|
||||
@@ -19,5 +22,9 @@ class TeacherSubmissionNotificationHistoryModel extends Model
|
||||
'semester',
|
||||
'sent_at',
|
||||
];
|
||||
protected $validationRules = [
|
||||
'school_year' => 'required|string|max_length[9]',
|
||||
];
|
||||
|
||||
protected $useTimestamps = false;
|
||||
}
|
||||
|
||||
@@ -3,9 +3,12 @@
|
||||
namespace App\Models;
|
||||
|
||||
use CodeIgniter\Model;
|
||||
use App\Models\Concerns\SchoolYearAutoFillTrait;
|
||||
|
||||
class UserNotificationModel extends Model
|
||||
{
|
||||
use SchoolYearAutoFillTrait;
|
||||
|
||||
protected $table = 'user_notifications';
|
||||
protected $primaryKey = 'id';
|
||||
|
||||
@@ -14,8 +17,13 @@ class UserNotificationModel extends Model
|
||||
'user_id',
|
||||
'is_read',
|
||||
'delivered',
|
||||
'delivered_at'
|
||||
'delivered_at',
|
||||
'school_year',
|
||||
];
|
||||
protected $validationRules = [
|
||||
'school_year' => 'required|string|max_length[20]',
|
||||
];
|
||||
|
||||
|
||||
protected $useTimestamps = false;
|
||||
}
|
||||
@@ -1,9 +1,12 @@
|
||||
<?php namespace App\Models;
|
||||
|
||||
use CodeIgniter\Model;
|
||||
use App\Models\Concerns\SchoolYearAutoFillTrait;
|
||||
|
||||
class WhatsappGroupLinkModel extends Model
|
||||
{
|
||||
use SchoolYearAutoFillTrait;
|
||||
|
||||
protected $table = 'whatsapp_group_links';
|
||||
protected $primaryKey = 'id';
|
||||
protected $returnType = 'array';
|
||||
@@ -14,6 +17,10 @@ class WhatsappGroupLinkModel extends Model
|
||||
'invite_link',
|
||||
'active',
|
||||
];
|
||||
protected $validationRules = [
|
||||
'school_year' => 'required|string|max_length[9]',
|
||||
];
|
||||
|
||||
protected $useTimestamps = true; // requires created_at / updated_at columns
|
||||
|
||||
private ?bool $hasSchoolYearColumn = null;
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
<?php namespace App\Models;
|
||||
|
||||
use CodeIgniter\Model;
|
||||
use App\Models\Concerns\SchoolYearAutoFillTrait;
|
||||
|
||||
class WhatsappGroupMembershipModel extends Model
|
||||
{
|
||||
use SchoolYearAutoFillTrait;
|
||||
|
||||
protected $table = 'whatsapp_group_memberships';
|
||||
protected $primaryKey = 'id';
|
||||
protected $returnType = 'array';
|
||||
@@ -17,6 +20,10 @@ class WhatsappGroupMembershipModel extends Model
|
||||
'verified_by',
|
||||
'verified_at',
|
||||
];
|
||||
protected $validationRules = [
|
||||
'school_year' => 'required|string|max_length[9]',
|
||||
];
|
||||
|
||||
protected $useTimestamps = true; // created_at, updated_at
|
||||
|
||||
/**
|
||||
|
||||
@@ -3,9 +3,12 @@
|
||||
namespace App\Models;
|
||||
|
||||
use CodeIgniter\Model;
|
||||
use App\Models\Concerns\SchoolYearAutoFillTrait;
|
||||
|
||||
class WhatsappInviteLogModel extends Model
|
||||
{
|
||||
use SchoolYearAutoFillTrait;
|
||||
|
||||
protected $table = 'whatsapp_invites_log';
|
||||
protected $primaryKey = 'id';
|
||||
protected $useAutoIncrement = true;
|
||||
@@ -21,6 +24,7 @@ class WhatsappInviteLogModel extends Model
|
||||
'status',
|
||||
'error_message',
|
||||
'sent_at',
|
||||
'school_year',
|
||||
];
|
||||
|
||||
protected $useTimestamps = false; // we handle sent_at manually
|
||||
@@ -34,6 +38,7 @@ class WhatsappInviteLogModel extends Model
|
||||
'status' => 'required|max_length[20]',
|
||||
'class_section_id' => 'permit_empty|integer',
|
||||
'link_id' => 'permit_empty|integer',
|
||||
'school_year' => 'required|string|max_length[9]',
|
||||
];
|
||||
|
||||
protected $validationMessages = [];
|
||||
|
||||
Reference in New Issue
Block a user