initial project

This commit is contained in:
2025-11-06 13:41:06 +08:00
commit 1b08727cb2
209 changed files with 31602 additions and 0 deletions
View File
@@ -0,0 +1,26 @@
<?php
namespace App\Database\Migrations;
use CodeIgniter\Database\Migration;
class CreateProductBrand extends Migration
{
public function up()
{
$this->forge->addField([
'product_brand_id' => ['type' => 'INT', 'unsigned' => true, 'auto_increment' => true],
'brand_name' => ['type' => 'VARCHAR', 'constraint' => '255'],
'created_at' => ['type' => 'DATETIME', 'null' => true],
'updated_at' => ['type' => 'DATETIME', 'null' => true],
'deleted_at' => ['type' => 'DATETIME', 'null' => true],
]);
$this->forge->addKey('product_brand_id', true);
$this->forge->createTable('product_brand');
}
public function down()
{
$this->forge->dropTable('product_brand');
}
}
@@ -0,0 +1,27 @@
<?php
namespace App\Database\Migrations;
use CodeIgniter\Database\Migration;
class CreateProductCategory extends Migration
{
public function up()
{
$this->forge->addField([
'product_category_id' => ['type' => 'INT', 'unsigned' => true, 'auto_increment' => true],
'category_name' => ['type' => 'VARCHAR', 'constraint' => '255'],
'created_at' => ['type' => 'DATETIME', 'null' => true],
'updated_at' => ['type' => 'DATETIME', 'null' => true],
'deleted_at' => ['type' => 'DATETIME', 'null' => true],
]);
$this->forge->addKey('product_category_id', true);
$this->forge->createTable('product_category');
}
public function down()
{
$this->forge->dropTable('product_category');
}
}
@@ -0,0 +1,27 @@
<?php
namespace App\Database\Migrations;
use CodeIgniter\Database\Migration;
class CreateProductDescription extends Migration
{
public function up()
{
$this->forge->addField([
'product_description_id' => ['type' => 'INT', 'unsigned' => true, 'auto_increment' => true],
'description' => ['type' => 'TEXT'],
'created_at' => ['type' => 'DATETIME', 'null' => true],
'updated_at' => ['type' => 'DATETIME', 'null' => true],
'deleted_at' => ['type' => 'DATETIME', 'null' => true],
]);
$this->forge->addKey('product_description_id', true);
$this->forge->createTable('product_description');
}
public function down()
{
$this->forge->dropTable('product_description');
}
}
@@ -0,0 +1,28 @@
<?php
namespace App\Database\Migrations;
use CodeIgniter\Database\Migration;
class CreateProductImei extends Migration
{
public function up()
{
$this->forge->addField([
'product_imei_id' => ['type' => 'INT', 'unsigned' => true, 'auto_increment' => true],
'aging_days' => ['type' => 'INT', 'null' => true],
'profit' => ['type' => 'DECIMAL', 'constraint' => '10,2', 'null' => true],
'created_at' => ['type' => 'DATETIME', 'null' => true],
'updated_at' => ['type' => 'DATETIME', 'null' => true],
'deleted_at' => ['type' => 'DATETIME', 'null' => true],
]);
$this->forge->addKey('product_imei_id', true);
$this->forge->createTable('product_imei');
}
public function down()
{
$this->forge->dropTable('product_imei');
}
}
@@ -0,0 +1,39 @@
<?php
namespace App\Database\Migrations;
use CodeIgniter\Database\Migration;
class CreateSupplierDetails extends Migration
{
public function up()
{
$this->forge->addField([
'supplier_id' => ['type' => 'INT', 'unsigned' => true, 'auto_increment' => true],
'supplier_name' => ['type' => 'VARCHAR', 'constraint' => '255'],
'supplier_ssm_no' => ['type' => 'VARCHAR', 'constraint' => '100', 'null' => true],
'supplier_TIN_no' => ['type' => 'VARCHAR', 'constraint' => '100', 'null' => true],
'supplier_phone_no'=> ['type' => 'VARCHAR', 'constraint' => '50', 'null' => true],
'supplier_email' => ['type' => 'VARCHAR', 'constraint' => '255', 'null' => true],
'supplier_address_1'=> ['type' => 'VARCHAR', 'constraint' => '255', 'null' => true],
'supplier_address_2'=> ['type' => 'VARCHAR', 'constraint' => '255', 'null' => true],
'supplier_address_3'=> ['type' => 'VARCHAR', 'constraint' => '255', 'null' => true],
'supplier_address_4'=> ['type' => 'VARCHAR', 'constraint' => '255', 'null' => true],
'poscode' => ['type' => 'VARCHAR', 'constraint' => '10', 'null' => true],
'town' => ['type' => 'VARCHAR', 'constraint' => '100', 'null' => true],
'state' => ['type' => 'VARCHAR', 'constraint' => '100', 'null' => true],
'country' => ['type' => 'VARCHAR', 'constraint' => '100', 'null' => true],
'person_in_charge' => ['type' => 'VARCHAR', 'constraint' => '255', 'null' => true],
'pic_phone_no' => ['type' => 'VARCHAR', 'constraint' => '50', 'null' => true],
'accounting_no' => ['type' => 'VARCHAR', 'constraint' => '100', 'null' => true],
]);
$this->forge->addKey('supplier_id', true);
$this->forge->createTable('supplier_details');
}
public function down()
{
$this->forge->dropTable('supplier_details');
}
}
@@ -0,0 +1,28 @@
<?php
namespace App\Database\Migrations;
use CodeIgniter\Database\Migration;
class CreateInvoiceItem extends Migration
{
public function up()
{
$this->forge->addField([
'invoice_item_id' => ['type' => 'INT', 'unsigned' => true, 'auto_increment' => true],
'product_id' => ['type' => 'INT', 'unsigned' => true],
'created_at' => ['type' => 'DATETIME', 'null' => true],
'updated_at' => ['type' => 'DATETIME', 'null' => true],
'deleted_at' => ['type' => 'DATETIME', 'null' => true],
]);
$this->forge->addKey('invoice_item_id', true);
$this->forge->addForeignKey('product_id', 'product', 'product_id', 'CASCADE', 'CASCADE');
$this->forge->createTable('invoice_item');
}
public function down()
{
$this->forge->dropTable('invoice_item');
}
}
@@ -0,0 +1,27 @@
<?php
namespace App\Database\Migrations;
use CodeIgniter\Database\Migration;
class CreatePlatform extends Migration
{
public function up()
{
$this->forge->addField([
'platform_id' => ['type' => 'INT', 'unsigned' => true, 'auto_increment' => true],
'platform_name'=> ['type' => 'VARCHAR', 'constraint' => 255],
'created_at' => ['type' => 'DATETIME', 'null' => true],
'updated_at' => ['type' => 'DATETIME', 'null' => true],
'deleted_at' => ['type' => 'DATETIME', 'null' => true],
]);
$this->forge->addKey('platform_id', true);
$this->forge->createTable('platform');
}
public function down()
{
$this->forge->dropTable('platform');
}
}
@@ -0,0 +1,39 @@
<?php
namespace App\Database\Migrations;
use CodeIgniter\Database\Migration;
class CreateProduct extends Migration
{
public function up()
{
$this->forge->addField([
'product_id' => ['type' => 'INT', 'unsigned' => true, 'auto_increment' => true],
'model_no' => ['type' => 'VARCHAR', 'constraint' => '255'],
'product_brand_id' => ['type' => 'INT', 'unsigned' => true],
'product_category_id' => ['type' => 'INT', 'unsigned' => true],
'product_description_id'=> ['type' => 'INT', 'unsigned' => true],
'siri_no_sequence' => ['type' => 'VARCHAR', 'constraint' => '255', 'null' => true],
'product_imei_id' => ['type' => 'INT', 'unsigned' => true, 'null' => true],
'supplier_id' => ['type' => 'INT', 'unsigned' => true],
'selling_price' => ['type' => 'DECIMAL', 'constraint' => '10,2', 'null' => true],
'created_at' => ['type' => 'DATETIME', 'null' => true],
'updated_at' => ['type' => 'DATETIME', 'null' => true],
'deleted_at' => ['type' => 'DATETIME', 'null' => true],
]);
$this->forge->addKey('product_id', true);
$this->forge->addForeignKey('product_brand_id', 'product_brand', 'product_brand_id', 'CASCADE', 'CASCADE');
$this->forge->addForeignKey('product_category_id', 'product_category', 'product_category_id', 'CASCADE', 'CASCADE');
$this->forge->addForeignKey('product_description_id', 'product_description', 'product_description_id', 'CASCADE', 'CASCADE');
$this->forge->addForeignKey('product_imei_id', 'product_imei', 'product_imei_id', 'SET NULL', 'CASCADE');
$this->forge->addForeignKey('supplier_id', 'supplier_details', 'supplier_id', 'CASCADE', 'CASCADE');
$this->forge->createTable('product');
}
public function down()
{
$this->forge->dropTable('product');
}
}
@@ -0,0 +1,29 @@
<?php
namespace App\Database\Migrations;
use CodeIgniter\Database\Migration;
class CreateStock extends Migration
{
public function up()
{
$this->forge->addField([
'stock_id' => ['type' => 'INT', 'unsigned' => true, 'auto_increment' => true],
'product_id' => ['type' => 'INT', 'unsigned' => true],
'stock_qty' => ['type' => 'INT', 'default' => 0],
'created_at' => ['type' => 'DATETIME', 'null' => true],
'updated_at' => ['type' => 'DATETIME', 'null' => true],
'deleted_at' => ['type' => 'DATETIME', 'null' => true],
]);
$this->forge->addKey('stock_id', true);
$this->forge->addForeignKey('product_id', 'product', 'product_id', 'CASCADE', 'CASCADE');
$this->forge->createTable('stock');
}
public function down()
{
$this->forge->dropTable('stock');
}
}
@@ -0,0 +1,27 @@
<?php
namespace App\Database\Migrations;
use CodeIgniter\Database\Migration;
class CreateBranchCategory extends Migration
{
public function up()
{
$this->forge->addField([
'branch_category_id' => ['type' => 'INT', 'unsigned' => true, 'auto_increment' => true],
'branch_category_name' => ['type' => 'VARCHAR', 'constraint' => 255],
'created_at' => ['type' => 'DATETIME', 'null' => true],
'updated_at' => ['type' => 'DATETIME', 'null' => true],
'deleted_at' => ['type' => 'DATETIME', 'null' => true],
]);
$this->forge->addKey('branch_category_id', true);
$this->forge->createTable('branch_category');
}
public function down()
{
$this->forge->dropTable('branch_category');
}
}
@@ -0,0 +1,44 @@
<?php
namespace App\Database\Migrations;
use CodeIgniter\Database\Migration;
class CreateCustomerDetails extends Migration
{
public function up()
{
$this->forge->addField([
'customer_id' => ['type' => 'INT', 'unsigned' => true, 'auto_increment' => true],
'company_name' => ['type' => 'VARCHAR', 'constraint' => 255, 'null' => true],
'company_ssm_no' => ['type' => 'VARCHAR', 'constraint' => 100, 'null' => true],
'DOB' => ['type' => 'DATE', 'null' => true],
'TIN_no' => ['type' => 'VARCHAR', 'constraint' => 100, 'null' => true],
'phone_no' => ['type' => 'VARCHAR', 'constraint' => 50, 'null' => true],
'email' => ['type' => 'VARCHAR', 'constraint' => 255, 'null' => true],
'address_1' => ['type' => 'VARCHAR', 'constraint' => 255, 'null' => true],
'address_2' => ['type' => 'VARCHAR', 'constraint' => 255, 'null' => true],
'address_3' => ['type' => 'VARCHAR', 'constraint' => 255, 'null' => true],
'address_4' => ['type' => 'VARCHAR', 'constraint' => 255, 'null' => true],
'poscode' => ['type' => 'VARCHAR', 'constraint' => 10, 'null' => true],
'town' => ['type' => 'VARCHAR', 'constraint' => 100, 'null' => true],
'state' => ['type' => 'VARCHAR', 'constraint' => 100, 'null' => true],
'country' => ['type' => 'VARCHAR', 'constraint' => 100, 'null' => true],
'membership_no' => ['type' => 'VARCHAR', 'constraint' => 100, 'null' => true],
'platform_id' => ['type' => 'INT', 'unsigned' => true, 'null' => true],
'membership_expiry' => ['type' => 'DATE', 'null' => true],
'created_at' => ['type' => 'DATETIME', 'null' => true],
'updated_at' => ['type' => 'DATETIME', 'null' => true],
'deleted_at' => ['type' => 'DATETIME', 'null' => true],
]);
$this->forge->addKey('customer_id', true);
$this->forge->addForeignKey('platform_id', 'platform', 'platform_id', 'SET NULL', 'CASCADE');
$this->forge->createTable('customer_details');
}
public function down()
{
$this->forge->dropTable('customer_details');
}
}
@@ -0,0 +1,41 @@
<?php
namespace App\Database\Migrations;
use CodeIgniter\Database\Migration;
class CreateInvoice extends Migration
{
public function up()
{
$this->forge->addField([
'invoice_id' => ['type' => 'INT', 'unsigned' => true, 'auto_increment' => true],
'invoice_no' => ['type' => 'VARCHAR', 'constraint' => 255],
'invoice_type_id' => ['type' => 'INT', 'unsigned' => true],
'invoice_item_id' => ['type' => 'INT', 'unsigned' => true],
'invoice_date' => ['type' => 'DATETIME', 'null' => true],
'customer_id' => ['type' => 'INT', 'unsigned' => true],
'customer_phone_no' => ['type' => 'VARCHAR', 'constraint' => 50, 'null' => true],
'customer_name' => ['type' => 'VARCHAR', 'constraint' => 255, 'null' => true],
'salesman_no' => ['type' => 'VARCHAR', 'constraint' => 50, 'null' => true],
'salesman_name' => ['type' => 'VARCHAR', 'constraint' => 255, 'null' => true],
'payment_method_id' => ['type' => 'INT', 'unsigned' => true],
'branch_id' => ['type' => 'INT', 'unsigned' => true, 'null' => true],
'created_at' => ['type' => 'DATETIME', 'null' => true],
'updated_at' => ['type' => 'DATETIME', 'null' => true],
'deleted_at' => ['type' => 'DATETIME', 'null' => true],
]);
$this->forge->addKey('invoice_id', true);
$this->forge->addForeignKey('invoice_type_id', 'invoice_type', 'invoice_type_id', 'CASCADE', 'CASCADE');
$this->forge->addForeignKey('invoice_item_id', 'invoice_item', 'invoice_item_id', 'CASCADE', 'CASCADE');
$this->forge->addForeignKey('customer_id', 'customer_details', 'customer_id', 'CASCADE', 'CASCADE');
$this->forge->addForeignKey('payment_method_id', 'payment_method', 'payment_method_id', 'CASCADE', 'CASCADE');
$this->forge->createTable('invoice');
}
public function down()
{
$this->forge->dropTable('invoice');
}
}
@@ -0,0 +1,27 @@
<?php
namespace App\Database\Migrations;
use CodeIgniter\Database\Migration;
class CreateInvoiceType extends Migration
{
public function up()
{
$this->forge->addField([
'invoice_type_id' => ['type' => 'INT', 'unsigned' => true, 'auto_increment' => true],
'type' => ['type' => 'VARCHAR', 'constraint' => 255],
'created_at' => ['type' => 'DATETIME', 'null' => true],
'updated_at' => ['type' => 'DATETIME', 'null' => true],
'deleted_at' => ['type' => 'DATETIME', 'null' => true],
]);
$this->forge->addKey('invoice_type_id', true);
$this->forge->createTable('invoice_type');
}
public function down()
{
$this->forge->dropTable('invoice_type');
}
}
@@ -0,0 +1,27 @@
<?php
namespace App\Database\Migrations;
use CodeIgniter\Database\Migration;
class CreatePaymentMethod extends Migration
{
public function up()
{
$this->forge->addField([
'payment_method_id' => ['type' => 'INT', 'unsigned' => true, 'auto_increment' => true],
'payment' => ['type' => 'VARCHAR', 'constraint' => 255],
'created_at' => ['type' => 'DATETIME', 'null' => true],
'updated_at' => ['type' => 'DATETIME', 'null' => true],
'deleted_at' => ['type' => 'DATETIME', 'null' => true],
]);
$this->forge->addKey('payment_method_id', true);
$this->forge->createTable('payment_method');
}
public function down()
{
$this->forge->dropTable('payment_method');
}
}
@@ -0,0 +1,43 @@
<?php
namespace App\Database\Migrations;
use CodeIgniter\Database\Migration;
class CreateBranchDetails extends Migration
{
public function up()
{
$this->forge->addField([
'branch_id' => ['type' => 'INT', 'unsigned' => true, 'auto_increment' => true],
'branch_name' => ['type' => 'VARCHAR', 'constraint' => 255],
'branch_category_id' => ['type' => 'INT', 'unsigned' => true],
'branch_bank' => ['type' => 'VARCHAR', 'constraint' => 255, 'null' => true],
'branch_bank_no' => ['type' => 'VARCHAR', 'constraint' => 255, 'null' => true],
'agreement_start' => ['type' => 'DATE', 'null' => true],
'agreement_end' => ['type' => 'DATE', 'null' => true],
'liscense_one' => ['type' => 'VARCHAR', 'constraint' => 255, 'null' => true],
'liscense_one_end' => ['type' => 'DATE', 'null' => true],
'liscense_two' => ['type' => 'VARCHAR', 'constraint' => 255, 'null' => true],
'liscense_two_end' => ['type' => 'DATE', 'null' => true],
'liscense_three' => ['type' => 'VARCHAR', 'constraint' => 255, 'null' => true],
'liscense_three_end' => ['type' => 'DATE', 'null' => true],
'invoice_id' => ['type' => 'INT', 'unsigned' => true, 'null' => true],
'letterhead_id' => ['type' => 'INT', 'unsigned' => true],
'created_at' => ['type' => 'DATETIME', 'null' => true],
'updated_at' => ['type' => 'DATETIME', 'null' => true],
'deleted_at' => ['type' => 'DATETIME', 'null' => true],
]);
$this->forge->addKey('branch_id', true);
$this->forge->addForeignKey('branch_category_id', 'branch_category', 'branch_category_id', 'CASCADE', 'CASCADE');
$this->forge->addForeignKey('invoice_id', 'invoice', 'invoice_id', 'SET NULL', 'CASCADE');
$this->forge->addForeignKey('letterhead_id', 'letterhead', 'letterhead_id', 'CASCADE', 'CASCADE');
$this->forge->createTable('branch_details');
}
public function down()
{
$this->forge->dropTable('branch_details');
}
}
@@ -0,0 +1,33 @@
<?php
namespace App\Database\Migrations;
use CodeIgniter\Database\Migration;
class CreateLetterhead extends Migration
{
public function up()
{
$this->forge->addField([
'letterhead_id' => ['type' => 'INT', 'unsigned' => true, 'auto_increment' => true],
'company_name' => ['type' => 'VARCHAR', 'constraint' => 255],
'company_ssm_no' => ['type' => 'VARCHAR', 'constraint' => 100, 'null' => true],
'address' => ['type' => 'TEXT', 'null' => true],
'complaint_no' => ['type' => 'VARCHAR', 'constraint' => 100, 'null' => true],
'complaint_email' => ['type' => 'VARCHAR', 'constraint' => 255, 'null' => true],
'TIN_no' => ['type' => 'VARCHAR', 'constraint' => 100, 'null' => true],
'logo' => ['type' => 'VARCHAR', 'constraint' => 255, 'null' => true],
'created_at' => ['type' => 'DATETIME', 'null' => true],
'updated_at' => ['type' => 'DATETIME', 'null' => true],
'deleted_at' => ['type' => 'DATETIME', 'null' => true],
]);
$this->forge->addKey('letterhead_id', true);
$this->forge->createTable('letterhead');
}
public function down()
{
$this->forge->dropTable('letterhead');
}
}
@@ -0,0 +1,28 @@
<?php
namespace App\Database\Migrations;
use CodeIgniter\Database\Migration;
class CreatePosition extends Migration
{
public function up()
{
$this->forge->addField([
'position_id' => ['type' => 'INT', 'unsigned' => true, 'auto_increment' => true],
'position_name' => ['type' => 'VARCHAR', 'constraint' => 255],
'permission' => ['type' => 'TEXT', 'null' => true],
'created_at' => ['type' => 'DATETIME', 'null' => true],
'updated_at' => ['type' => 'DATETIME', 'null' => true],
'deleted_at' => ['type' => 'DATETIME', 'null' => true],
]);
$this->forge->addKey('position_id', true);
$this->forge->createTable('position');
}
public function down()
{
$this->forge->dropTable('position');
}
}
@@ -0,0 +1,38 @@
<?php
namespace App\Database\Migrations;
use CodeIgniter\Database\Migration;
class CreateStaffDetails extends Migration
{
public function up()
{
$this->forge->addField([
'staff_id' => ['type' => 'INT', 'unsigned' => true, 'auto_increment' => true],
'employee_name' => ['type' => 'VARCHAR', 'constraint' => 255],
'email' => ['type' => 'VARCHAR', 'constraint' => 255, 'null' => true],
'phone_no' => ['type' => 'VARCHAR', 'constraint' => 50, 'null' => true],
'bank_name' => ['type' => 'VARCHAR', 'constraint' => 255, 'null' => true],
'bank_acc_no' => ['type' => 'VARCHAR', 'constraint' => 255, 'null' => true],
'resign_date' => ['type' => 'DATE', 'null' => true],
'position_id' => ['type' => 'INT', 'unsigned' => true],
'username' => ['type' => 'VARCHAR', 'constraint' => 100],
'password' => ['type' => 'VARCHAR', 'constraint' => 255],
'branch_id' => ['type' => 'INT', 'unsigned' => true],
'created_at' => ['type' => 'DATETIME', 'null' => true],
'updated_at' => ['type' => 'DATETIME', 'null' => true],
'deleted_at' => ['type' => 'DATETIME', 'null' => true],
]);
$this->forge->addKey('staff_id', true);
$this->forge->addForeignKey('position_id', 'position', 'position_id', 'CASCADE', 'CASCADE');
$this->forge->addForeignKey('branch_id', 'branch_details', 'branch_id', 'CASCADE', 'CASCADE');
$this->forge->createTable('staff_details');
}
public function down()
{
$this->forge->dropTable('staff_details');
}
}