Refactor project structure

This commit is contained in:
Thilina Hasantha
2018-04-29 17:46:42 +02:00
parent 889baf124c
commit e3a7e18d9c
5513 changed files with 32 additions and 27 deletions

15
core/migrations/list.php Normal file
View File

@@ -0,0 +1,15 @@
<?php
$migrationList = [];
$migrationList[] = 'v20180417_210501_update_menu_names';
$migrationList[] = 'v20180325_210101_delete_leave_group_employee';
$migrationList[] = 'v20180317_210200_leave_rule_experience';
$migrationList[] = 'v20180305_210100_drop_si_hi_languages';
$migrationList[] = 'v20171126_200303_swift_mail';
$migrationList[] = 'v20171003_200302_payroll_meta_export';
$migrationList[] = 'v20171003_200301_add_deduction_group_payroll';
$migrationList[] = 'v20171001_200201_update_attendance_out';
$migrationList[] = 'v20170918_200000_add_attendance_image_out';
$migrationList[] = 'v20170908_200000_payroll_group';
$migrationList[] = 'v20170702_190500_add_attendance_image';
$migrationList[] = 'v20170310_190401_add_timesheet_changes';
$migrationList[] = 'v20161116_190001_unique_index_cron_name';

View File

@@ -0,0 +1,25 @@
<?php
namespace Classes\Migration;
class v20161116_190001_unique_index_cron_name extends AbstractMigration{
public function up(){
$sql = <<<'SQL'
Alter table Crons add unique key `KEY_Crons_name` (`name`);
SQL;
return $this->executeQuery($sql);
}
public function down(){
$sql = <<<'SQL'
Alter table Crons drop key `KEY_Crons_name`;
SQL;
return $this->executeQuery($sql);
}
}

View File

@@ -0,0 +1,24 @@
<?php
namespace Classes\Migration;
use Model\Setting;
class v20170310_190401_add_timesheet_changes extends AbstractMigration{
public function up(){
$setting = new Setting();
$setting->Load("name = ?", array('System: Time-sheet Entry Start and End time Required'));
if(empty($setting->id)){
$setting->name = 'System: Time-sheet Entry Start and End time Required';
$setting->value = 1;
$setting->description = 'Select 0 if you only need to store the time spend in time sheets';
$setting->meta = '["value", {"label":"Value","type":"select","source":[["1","Yes"],["0","No"]]}]';
$setting->Save();
}
}
public function down(){
}
}

View File

@@ -0,0 +1,38 @@
<?php
namespace Classes\Migration;
use Model\Setting;
class v20170702_190500_add_attendance_image extends AbstractMigration{
public function up(){
$setting = new Setting();
$setting->Load("name = ?", array('Attendance: Photo Attendance'));
if(empty($setting->id)){
$setting->name = 'Attendance: Photo Attendance';
$setting->value = 0;
$setting->description = 'Require submitting a photo using web cam when marking attendance';
$setting->meta = '["value", {"label":"Value","type":"select","source":[["1","Yes"],["0","No"]]}]';
$setting->Save();
}
$sql = <<<'SQL'
Alter table Attendance add column `image_in` longtext default null;
SQL;
return $this->executeQuery($sql);
}
public function down(){
$sql = <<<'SQL'
Alter table Attendance drop column `image_in`;
SQL;
return $this->executeQuery($sql);
}
}

View File

@@ -0,0 +1,25 @@
<?php
namespace Classes\Migration;
class v20170908_200000_payroll_group extends AbstractMigration{
public function up(){
$sql = <<<'SQL'
Alter table Payroll add COLUMN `deduction_group` bigint(20) DEFAULT NULL;
SQL;
return $this->executeQuery($sql);
}
public function down(){
$sql = <<<'SQL'
Alter table Payroll drop COLUMN `deduction_group`;
SQL;
return $this->executeQuery($sql);
}
}

View File

@@ -0,0 +1,22 @@
<?php
namespace Classes\Migration;
class v20170918_200000_add_attendance_image_out extends AbstractMigration{
public function up(){
$sql = <<<'SQL'
Alter table Attendance add column `image_out` longtext default null;
SQL;
return $this->executeQuery($sql);
}
public function down(){
$sql = <<<'SQL'
Alter table Attendance drop column `image_out`;
SQL;
return $this->executeQuery($sql);
}
}

View File

@@ -0,0 +1,23 @@
<?php
namespace Classes\Migration;
class v20171001_200201_update_attendance_out extends AbstractMigration{
public function up(){
$sql = <<<'SQL'
alter table Attendance modify column `out_time` datetime default NULL;
SQL;
return $this->executeQuery($sql);
}
public function down(){
$sql = <<<'SQL'
alter table Attendance modify column `out_time` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00';
SQL;
return $this->executeQuery($sql);
}
}

View File

@@ -0,0 +1,23 @@
<?php
namespace Classes\Migration;
class v20171003_200301_add_deduction_group_payroll extends AbstractMigration{
public function up(){
$sql = <<<'SQL'
alter table PayrollColumns add column `deduction_group` bigint(20) NULL;
SQL;
return $this->executeQuery($sql);
}
public function down(){
$sql = <<<'SQL'
alter table PayrollColumns drop column `deduction_group`;
SQL;
return $this->executeQuery($sql);
}
}

View File

@@ -0,0 +1,41 @@
<?php
namespace Classes\Migration;
class v20171003_200302_payroll_meta_export extends AbstractMigration{
public function up(){
$sql = <<<'SQL'
REPLACE INTO `Reports` (`name`, `details`, `parameters`, `query`, `paramOrder`, `type`,`report_group`,`output`) VALUES
('Payroll Meta Data Export', 'Export payroll module configurations',
'[\r\n[ "deduction_group", {"label":"Calculation Group","type":"select2","allow-null":false,"remote-source":["DeductionGroup","id","name"]}],\r\n[ "payroll", {"label":"Sample Payroll","type":"select2","allow-null":false,"remote-source":["Payroll","id","name"]}]]',
'PayrollDataExport',
'["deduction_group","payroll"]', 'Class','Payroll','JSON');
SQL;
$this->executeQuery($sql);
$sql = <<<'SQL'
INSERT INTO `DataImport` (`name`, `dataType`, `details`, `columns`, `updated`, `created`) VALUES
('Payroll Data Import', 'PayrollDataImporter', '', '[]', '2016-08-14 02:51:56', '2016-08-14 02:51:56');
SQL;
return $this->executeQuery($sql);
}
public function down(){
$sql = <<<'SQL'
delete from Reports where name = 'Payroll Meta Data Export';
SQL;
$this->executeQuery($sql);
$sql = <<<'SQL'
delete from DataImport where name = 'Attendance Data Import';
SQL;
return $this->executeQuery($sql);
}
}

View File

@@ -0,0 +1,26 @@
<?php
namespace Classes\Migration;
use Model\Setting;
class v20171126_200303_swift_mail extends AbstractMigration{
public function up(){
$setting = new Setting();
$setting->Load("name = ?", array('Email: Mode'));
if(!empty($setting->id)){
$setting->description = 'Update email sender';
$setting->meta = '["value", {"label":"Value","type":"select","source":[["SMTP","SMTP"],["Swift SMTP","Swift SMTP"],["PHP Mailer","PHP Mailer"],["SES","Amazon SES"]]}]';
$setting->Save();
}
return true;
}
public function down(){
return true;
}
}

View File

@@ -0,0 +1,35 @@
<?php
namespace Classes\Migration;
use Metadata\Common\Model\SupportedLanguage;
class v20180305_210100_drop_si_hi_languages extends AbstractMigration{
public function up(){
$supportedLanguage = new SupportedLanguage();
$supportedLanguage->Load('name = ?', array('si'));
$supportedLanguage->Delete();
$supportedLanguage = new SupportedLanguage();
$supportedLanguage->Load('name = ?', array('hi'));
$supportedLanguage->Delete();
return true;
}
public function down(){
$supportedLanguage = new SupportedLanguage();
$supportedLanguage->name = 'si';
$supportedLanguage->description = 'Sinhala';
$supportedLanguage->Save();
$supportedLanguage = new SupportedLanguage();
$supportedLanguage->name = 'hi';
$supportedLanguage->description = 'Hindi';
$supportedLanguage->Save();
return true;
}
}

View File

@@ -0,0 +1,26 @@
<?php
namespace Classes\Migration;
class v20180317_210200_leave_rule_experience extends AbstractMigration {
public function up(){
$sql = <<<'SQL'
alter table LeaveRules add column `exp_days` int(11) NULL;
SQL;
return $this->executeQuery($sql);
}
public function down(){
$sql = <<<'SQL'
alter table LeaveRules drop column `exp_days`;
SQL;
return $this->executeQuery($sql);
}
}
{
}

View File

@@ -0,0 +1,31 @@
<?php
namespace Classes\Migration;
class v20180325_210101_delete_leave_group_employee extends AbstractMigration{
public function up(){
$sql = <<<'SQL'
alter table LeaveGroupEmployees drop FOREIGN KEY `Fk_LeaveGroupEmployees_Employee`;
SQL;
$this->executeQuery($sql);
$sql = <<<'SQL'
alter table LeaveGroupEmployees drop index `LeaveGroupEmployees_employee`;
SQL;
$this->executeQuery($sql);
$sql = <<<'SQL'
alter table LeaveGroupEmployees add CONSTRAINT `Fk_LeaveGroupEmployees_Employee` FOREIGN KEY (`employee`) REFERENCES `Employees` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;
SQL;
return $this->executeQuery($sql);
}
public function down(){
$sql = <<<'SQL'
alter table LeaveGroupEmployees add UNIQUE KEY `LeaveGroupEmployees_employee` (`employee`);
SQL;
return $this->executeQuery($sql);
}
}

View File

@@ -0,0 +1,19 @@
<?php
namespace Classes\Migration;
class v20180417_210501_update_menu_names extends AbstractMigration{
public function up(){
$sql = <<<'SQL'
Update Settings set value = '1' where name = 'System: Reset Module Names';
SQL;
return $this->executeQuery($sql);
}
public function down(){
return true;
}
}