From 5613f39ce545c15eb3344c444314626e11f8cc7c Mon Sep 17 00:00:00 2001 From: Troels Liebe Bentsen Date: Wed, 1 Oct 2014 02:46:35 +0200 Subject: [PATCH] Start working on TimeSheet feature --- .../2014_09_30_103529_add_timesheets.php | 137 ++++++++++++++++++ app/models/TimeSheet.php | 7 + 2 files changed, 144 insertions(+) create mode 100644 app/database/migrations/2014_09_30_103529_add_timesheets.php create mode 100755 app/models/TimeSheet.php diff --git a/app/database/migrations/2014_09_30_103529_add_timesheets.php b/app/database/migrations/2014_09_30_103529_add_timesheets.php new file mode 100644 index 0000000000..b2eb453dcf --- /dev/null +++ b/app/database/migrations/2014_09_30_103529_add_timesheets.php @@ -0,0 +1,137 @@ +increments('id'); + $t->unsignedInteger('user_id'); + $t->unsignedInteger('account_id')->index(); + $t->timestamps(); + $t->softDeletes(); + + $t->string('name'); + $t->string('description'); + + $t->foreign('user_id')->references('id')->on('users')->onDelete('cascade'); + $t->foreign('account_id')->references('id')->on('accounts'); + + $t->unique( array('account_id','name') ); + }); + + Schema::create('project_codes', function($t) { + $t->increments('id'); + $t->unsignedInteger('user_id'); + $t->unsignedInteger('account_id')->index(); + $t->unsignedInteger('project_id'); + $t->timestamps(); + $t->softDeletes(); + + $t->string('name'); + $t->string('description'); + + $t->foreign('user_id')->references('id')->on('users')->onDelete('cascade'); + $t->foreign('account_id')->references('id')->on('accounts'); + $t->foreign('project_id')->references('id')->on('projects')->onDelete('cascade'); + + $t->unique( array('account_id','name') ); + }); + + + Schema::create('timesheets', function($t) { + $t->increments('id'); + $t->unsignedInteger('user_id'); + $t->unsignedInteger('account_id')->index(); + $t->timestamps(); + $t->softDeletes(); + + $t->dateTime('start_date'); + $t->dateTime('end_date'); + $t->float('discount'); + + $t->decimal('hours'); + + $t->foreign('user_id')->references('id')->on('users')->onDelete('cascade'); + $t->foreign('account_id')->references('id')->on('accounts'); + + $t->unsignedInteger('public_id'); + $t->unique( array('account_id','public_id') ); + }); + + Schema::create('timesheet_events', function($t) { + $t->increments('id'); + $t->unsignedInteger('user_id'); + $t->unsignedInteger('account_id')->index(); + $t->unsignedInteger('timesheet_source_id'); + $t->unsignedInteger('timesheet_id')->nullable()->index(); + $t->unsignedInteger('project_id')->nullable()->index(); + $t->unsignedInteger('project_code_id')->nullable()->index(); + $t->timestamps(); + $t->softDeletes(); + + $t->string('summary'); + $t->string('uid'); + $t->text('description'); + $t->string('location'); + $t->string('owner'); + + $t->dateTime('start_date'); + $t->dateTime('end_date'); + $t->decimal('hours'); + $t->float('discount'); + + $t->timeStamp('org_created_at'); + $t->timeStamp('org_updated_at'); + $t->string('org_start_date_timezone'); + $t->string('org_end_date_timezone'); + $t->text('org_data'); + + $t->foreign('account_id')->references('id')->on('accounts'); + $t->foreign('user_id')->references('id')->on('users')->onDelete('cascade'); + $t->foreign('timesheet_source_id')->references('id')->on('timesheets')->onDelete('cascade'); + + $t->unique( array('timesheet_source_id', 'uid') ); + }); + + Schema::create('timesheet_sources', function($t) { + $t->increments('id'); + $t->unsignedInteger('user_id'); + $t->unsignedInteger('account_id')->index(); + $t->timestamps(); + $t->softDeletes(); + + $t->string('name'); + $t->string('url'); + $t->enum('type', array('ical', 'googlexml')); + $t->string('owner'); + + $t->foreign('account_id')->references('id')->on('accounts'); + $t->foreign('user_id')->references('id')->on('users')->onDelete('cascade'); + }); + + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::drop('projects'); + Schema::drop('project_codes'); + Schema::drop('timesheets'); + Schema::drop('timesheet_events'); + Schema::drop('timesheet_sources'); + } + +} diff --git a/app/models/TimeSheet.php b/app/models/TimeSheet.php new file mode 100755 index 0000000000..03d0b11ad7 --- /dev/null +++ b/app/models/TimeSheet.php @@ -0,0 +1,7 @@ +