From 7c71034ea590f4b132f97402e83a0ec44b8ffa25 Mon Sep 17 00:00:00 2001 From: Trodrige Date: Sat, 26 May 2018 11:31:09 +0100 Subject: [PATCH 01/26] Adding migrations and models for report generator tables --- ...3827_create_draggable_components_table.php | 49 +++++++++++++++++++ ..._25_203256_create_report_formats_table.php | 43 ++++++++++++++++ .../Entities/DraggableComponent.php | 26 ++++++++++ .../ReportGenerator/Entities/ReportFormat.php | 26 ++++++++++ composer.lock | 20 ++++---- ...05_18_085927_create_list_options_table.php | 49 +++++++++++++++++++ 6 files changed, 203 insertions(+), 10 deletions(-) create mode 100644 Modules/ReportGenerator/Database/Migrations/2018_05_22_153827_create_draggable_components_table.php create mode 100644 Modules/ReportGenerator/Database/Migrations/2018_05_25_203256_create_report_formats_table.php create mode 100644 Modules/ReportGenerator/Entities/DraggableComponent.php create mode 100644 Modules/ReportGenerator/Entities/ReportFormat.php create mode 100644 database/migrations/2018_05_18_085927_create_list_options_table.php diff --git a/Modules/ReportGenerator/Database/Migrations/2018_05_22_153827_create_draggable_components_table.php b/Modules/ReportGenerator/Database/Migrations/2018_05_22_153827_create_draggable_components_table.php new file mode 100644 index 0000000..b5065db --- /dev/null +++ b/Modules/ReportGenerator/Database/Migrations/2018_05_22_153827_create_draggable_components_table.php @@ -0,0 +1,49 @@ + (2018) + * + * @return void + */ + public function up() + { + Schema::create('draggable_components', function (Blueprint $table) { + $table->increments('id')->comment = "This will identify each component with a unique integer."; + $table->string('option_id', 255)->comment = "All draggable components have an ID."; + $table->boolean('is_default')->default(1)->comment = "0 -> False, 1 -> True."; + $table->string('user', 255)->default('default')->comment = "The user who created the component. This will be 'default' for components that come with the module."; + $table->string('title', 255)->comment = "This is the text on the component that end users see."; + $table->integer('order', 0)->comment = "The order in which components appear in the list."; + $table->boolean('active')->default(1)->comment = "0 -> False, 1 -> True whether the component should be active or not."; + $table->json('notes', 255)->comment = "This stores the fields that the component relates to in the database."; + $table->boolean('toggle_sort')->default(0)->comment = "0 -> False (Descending), 1 -> True (Ascending)."; + $table->boolean('toggle_display')->default(0)->comment = "0 -> False, 1 -> True. Display field if checked (1), and no if unchecked (0)."; + + $table->timestamps(); + + // $table->foreign('userID')->references('id')->on('users')->onDelete('cascade'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('draggable_components'); + } +} diff --git a/Modules/ReportGenerator/Database/Migrations/2018_05_25_203256_create_report_formats_table.php b/Modules/ReportGenerator/Database/Migrations/2018_05_25_203256_create_report_formats_table.php new file mode 100644 index 0000000..d71c8dd --- /dev/null +++ b/Modules/ReportGenerator/Database/Migrations/2018_05_25_203256_create_report_formats_table.php @@ -0,0 +1,43 @@ + (2018) + * + * @return void + */ + public function up() + { + Schema::create('report_formats', function (Blueprint $table) { + $table->increments('id')->comment = "This will identify each component with a unique integer."; + $table->string('user', 255)->default('default')->comment = "The user who created the report format. This will be 'default' for components that come with the module."; + $table->string('title', 255)->comment = "This is the report name e.g Patient List."; + $table->string('system_feature', 255)->comment = "The system feature under which the report belongs."; + $table->text('description')->comment = "This describes the report format briefly."; + $table->json('draggable_components_id')->comment = "This stores the id of all the components that belong to this report format"; + + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('report_formats'); + } +} diff --git a/Modules/ReportGenerator/Entities/DraggableComponent.php b/Modules/ReportGenerator/Entities/DraggableComponent.php new file mode 100644 index 0000000..caff176 --- /dev/null +++ b/Modules/ReportGenerator/Entities/DraggableComponent.php @@ -0,0 +1,26 @@ + 'array' + ]; + + /** + * The connection name for the model. + * TODO + * @var string + */ + //protected $connection = 'connection-name'; +} diff --git a/Modules/ReportGenerator/Entities/ReportFormat.php b/Modules/ReportGenerator/Entities/ReportFormat.php new file mode 100644 index 0000000..e1efd1a --- /dev/null +++ b/Modules/ReportGenerator/Entities/ReportFormat.php @@ -0,0 +1,26 @@ + 'array' + ]; + + /** + * The connection name for the model. + * TODO + * @var string + */ + //protected $connection = 'connection-name'; +} diff --git a/composer.lock b/composer.lock index 6eb62fa..ab4943f 100644 --- a/composer.lock +++ b/composer.lock @@ -370,16 +370,16 @@ }, { "name": "laravel/tinker", - "version": "v1.0.6", + "version": "v1.0.7", "source": { "type": "git", "url": "https://github.com/laravel/tinker.git", - "reference": "b22fe905fcefdffae76b011e27c7ac09e07e052b" + "reference": "e3086ee8cb1f54a39ae8dcb72d1c37d10128997d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/tinker/zipball/b22fe905fcefdffae76b011e27c7ac09e07e052b", - "reference": "b22fe905fcefdffae76b011e27c7ac09e07e052b", + "url": "https://api.github.com/repos/laravel/tinker/zipball/e3086ee8cb1f54a39ae8dcb72d1c37d10128997d", + "reference": "e3086ee8cb1f54a39ae8dcb72d1c37d10128997d", "shasum": "" }, "require": { @@ -429,20 +429,20 @@ "laravel", "psysh" ], - "time": "2018-04-16T12:10:37+00:00" + "time": "2018-05-17T13:42:07+00:00" }, { "name": "league/flysystem", - "version": "1.0.44", + "version": "1.0.45", "source": { "type": "git", "url": "https://github.com/thephpleague/flysystem.git", - "reference": "168dbe519737221dc87d17385cde33073881fd02" + "reference": "a99f94e63b512d75f851b181afcdf0ee9ebef7e6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/thephpleague/flysystem/zipball/168dbe519737221dc87d17385cde33073881fd02", - "reference": "168dbe519737221dc87d17385cde33073881fd02", + "url": "https://api.github.com/repos/thephpleague/flysystem/zipball/a99f94e63b512d75f851b181afcdf0ee9ebef7e6", + "reference": "a99f94e63b512d75f851b181afcdf0ee9ebef7e6", "shasum": "" }, "require": { @@ -513,7 +513,7 @@ "sftp", "storage" ], - "time": "2018-04-06T09:58:14+00:00" + "time": "2018-05-07T08:44:23+00:00" }, { "name": "monolog/monolog", diff --git a/database/migrations/2018_05_18_085927_create_list_options_table.php b/database/migrations/2018_05_18_085927_create_list_options_table.php new file mode 100644 index 0000000..391ba70 --- /dev/null +++ b/database/migrations/2018_05_18_085927_create_list_options_table.php @@ -0,0 +1,49 @@ + (2018) + * @return void + */ + public function up() + { + Schema::create('list_options', function (Blueprint $table) { + $table->increments('id')->comment = "Primary Key. Autoincrement."; + $table->string('list_id', 31)->comment = "List Id."; + $table->string('option_id', 31)->comment = "Id for list item."; + $table->string('title', 255)->comment = "The title of the component."; + $table->integer('seq', 0)->comment = "The order in which the components appear in the list."; + $table->boolean('is_default')->default(0)->comment = "0 -> False, 1 -> True."; + $table->float('option_value', 8, 2)->default(0)->comment = ""; + $table->string('mapping', 31)->comment = ""; + $table->string('notes', 255)->comment = "This stores the meaning or usefulness of the component."; + $table->string('codes', 255)->comment = ""; + $table->boolean('toggle_setting_1')->default(0)->comment = "0 -> False, 1 -> True."; + $table->boolean('toggle_setting_2')->default(0)->comment = "0 -> False, 1 -> True."; + $table->boolean('activity')->default(1)->comment = "0 -> False, 1 -> True whether the component should be active or not."; + $table->string('subtype', 31)->comment = ""; + + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('list_options'); + } +} From 3db8a1bd43529b57d45527befe404bfb1ce48140 Mon Sep 17 00:00:00 2001 From: Trodrige Date: Mon, 28 May 2018 14:13:22 +0100 Subject: [PATCH 02/26] An attempt to add Factories and seeders for the report generator. Added a report generator table connection --- .env.example | 5 + ...3827_create_draggable_components_table.php | 2 +- ..._25_203256_create_report_formats_table.php | 2 +- .../Seeders/DraggableComponentTableSeeder.php | 25 +++ .../Seeders/ReportFormatTableSeeder.php | 25 +++ .../Seeders/ReportGeneratorDatabaseSeeder.php | 3 +- .../factories/DraggableComponentFactory.php | 29 +++ .../factories/ReportFormatFactory.php | 26 +++ .../Entities/DraggableComponent.php | 13 +- .../ReportGenerator/Entities/ReportFormat.php | 13 +- Modules/ReportGenerator/install.txt | 6 + composer.lock | 189 ++++++++++++------ config/database.php | 17 ++ 13 files changed, 282 insertions(+), 73 deletions(-) create mode 100644 Modules/ReportGenerator/Database/Seeders/DraggableComponentTableSeeder.php create mode 100644 Modules/ReportGenerator/Database/Seeders/ReportFormatTableSeeder.php create mode 100644 Modules/ReportGenerator/Database/factories/DraggableComponentFactory.php create mode 100644 Modules/ReportGenerator/Database/factories/ReportFormatFactory.php create mode 100644 Modules/ReportGenerator/install.txt diff --git a/.env.example b/.env.example index 668c06f..3959f3f 100644 --- a/.env.example +++ b/.env.example @@ -12,6 +12,11 @@ DB_DATABASE=homestead DB_USERNAME=homestead DB_PASSWORD=secret +DB_REPORT_GENERATOR_HOST=127.0.0.1 +DB_REPORT_GENERATOR_DATABASE=homestead +DB_REPORT_GENERATOR_USERNAME=homestead +DB_REPORT_GENERATOR_PASSWORD=secret + BROADCAST_DRIVER=log CACHE_DRIVER=file SESSION_DRIVER=file diff --git a/Modules/ReportGenerator/Database/Migrations/2018_05_22_153827_create_draggable_components_table.php b/Modules/ReportGenerator/Database/Migrations/2018_05_22_153827_create_draggable_components_table.php index b5065db..4be500b 100644 --- a/Modules/ReportGenerator/Database/Migrations/2018_05_22_153827_create_draggable_components_table.php +++ b/Modules/ReportGenerator/Database/Migrations/2018_05_22_153827_create_draggable_components_table.php @@ -19,7 +19,7 @@ class CreateDraggableComponentsTable extends Migration */ public function up() { - Schema::create('draggable_components', function (Blueprint $table) { + Schema::connection('mysql_report_generator')->create('draggable_components', function (Blueprint $table) { $table->increments('id')->comment = "This will identify each component with a unique integer."; $table->string('option_id', 255)->comment = "All draggable components have an ID."; $table->boolean('is_default')->default(1)->comment = "0 -> False, 1 -> True."; diff --git a/Modules/ReportGenerator/Database/Migrations/2018_05_25_203256_create_report_formats_table.php b/Modules/ReportGenerator/Database/Migrations/2018_05_25_203256_create_report_formats_table.php index d71c8dd..d45b3ba 100644 --- a/Modules/ReportGenerator/Database/Migrations/2018_05_25_203256_create_report_formats_table.php +++ b/Modules/ReportGenerator/Database/Migrations/2018_05_25_203256_create_report_formats_table.php @@ -19,7 +19,7 @@ class CreateReportFormatsTable extends Migration */ public function up() { - Schema::create('report_formats', function (Blueprint $table) { + Schema::connection('mysql_report_generator')->create('report_formats', function (Blueprint $table) { $table->increments('id')->comment = "This will identify each component with a unique integer."; $table->string('user', 255)->default('default')->comment = "The user who created the report format. This will be 'default' for components that come with the module."; $table->string('title', 255)->comment = "This is the report name e.g Patient List."; diff --git a/Modules/ReportGenerator/Database/Seeders/DraggableComponentTableSeeder.php b/Modules/ReportGenerator/Database/Seeders/DraggableComponentTableSeeder.php new file mode 100644 index 0000000..486d0b4 --- /dev/null +++ b/Modules/ReportGenerator/Database/Seeders/DraggableComponentTableSeeder.php @@ -0,0 +1,25 @@ + + * */ + +namespace Modules\ReportGenerator\Database\Seeders; + +use Illuminate\Database\Seeder; +use Illuminate\Database\Eloquent\Model; + +class DraggableComponentTableSeeder extends Seeder +{ + /** + * Run the database seeds. + * + * @return void + */ + public function run() + { + Model::unguard(); + factory("../../". Entities\DraggableComponent::class, 25)->create(); + // $this->call("OthersTableSeeder"); + } +} diff --git a/Modules/ReportGenerator/Database/Seeders/ReportFormatTableSeeder.php b/Modules/ReportGenerator/Database/Seeders/ReportFormatTableSeeder.php new file mode 100644 index 0000000..23e8e50 --- /dev/null +++ b/Modules/ReportGenerator/Database/Seeders/ReportFormatTableSeeder.php @@ -0,0 +1,25 @@ + + * */ + +//namespace Modules\ReportGenerator\Database\Seeders; + +use Illuminate\Database\Seeder; +use Illuminate\Database\Eloquent\Model; + +class ReportFormatTableSeeder extends Seeder +{ + /** + * Run the database seeds. + * + * @return void + */ + public function run() + { + Model::unguard(); + factory(Modules\ReportGenerator\Entities\ReportFormat::class, 25)->create(); + // $this->call("OthersTableSeeder"); + } +} diff --git a/Modules/ReportGenerator/Database/Seeders/ReportGeneratorDatabaseSeeder.php b/Modules/ReportGenerator/Database/Seeders/ReportGeneratorDatabaseSeeder.php index db21959..0bbf967 100644 --- a/Modules/ReportGenerator/Database/Seeders/ReportGeneratorDatabaseSeeder.php +++ b/Modules/ReportGenerator/Database/Seeders/ReportGeneratorDatabaseSeeder.php @@ -15,7 +15,8 @@ class ReportGeneratorDatabaseSeeder extends Seeder public function run() { Model::unguard(); - + $this->call(DraggableComponentTableSeeder::class); + $this->call(ReportFormatTableSeeder::class); // $this->call("OthersTableSeeder"); } } diff --git a/Modules/ReportGenerator/Database/factories/DraggableComponentFactory.php b/Modules/ReportGenerator/Database/factories/DraggableComponentFactory.php new file mode 100644 index 0000000..0054de4 --- /dev/null +++ b/Modules/ReportGenerator/Database/factories/DraggableComponentFactory.php @@ -0,0 +1,29 @@ + +| +*/ + +use Faker\Generator as Faker; + +$factory->define(Model::class, function (Faker $faker) { + +$booleanValue = array(true, false); + + return [ + 'option_id' => str_random(10)->unique(), + 'is_default' => $booleanValue[array_rand($booleanValue, 1)], + 'user' => $faker->name, + 'title' => $faker->sentence($nbWords = 3, $variableNbWords = true), + 'order' => $faker->number(2), + 'active' => $booleanValue[array_rand($booleanValue, 1)], + 'notes' => $faker->words($nb = 3, $asText = false), + 'toggle_sort' => $booleanValue[array_rand($booleanValue, 1)], + 'toggle_display' => $booleanValue[array_rand($booleanValue, 1)], + ]; +}); diff --git a/Modules/ReportGenerator/Database/factories/ReportFormatFactory.php b/Modules/ReportGenerator/Database/factories/ReportFormatFactory.php new file mode 100644 index 0000000..117f85e --- /dev/null +++ b/Modules/ReportGenerator/Database/factories/ReportFormatFactory.php @@ -0,0 +1,26 @@ + +| +*/ + +use Faker\Generator as Faker; + +$factory->define(Model::class, function (Faker $faker) { + + // Get all draggable_components_ids in draggable_components table + $draggable_components_ids = Entities\DraggableComponent::all()->pluck('id')->toArray(); + + return [ + 'user' => $faker->name, + 'title' => $faker->sentence($nbWords = 3, $variableNbWords = true), + 'system_feature' => $faker->sentence($nbWords = 3, $variableNbWords = true), + 'description' => $faker->text($maxNbChars = 100), + 'draggable_components_id' => $faker->randomElement($draggable_components_ids), + ]; +}); diff --git a/Modules/ReportGenerator/Entities/DraggableComponent.php b/Modules/ReportGenerator/Entities/DraggableComponent.php index caff176..e16027a 100644 --- a/Modules/ReportGenerator/Entities/DraggableComponent.php +++ b/Modules/ReportGenerator/Entities/DraggableComponent.php @@ -1,4 +1,13 @@ +| +*/ namespace Modules\ReportGenerator\Entities; @@ -18,9 +27,9 @@ class DraggableComponent extends Model ]; /** - * The connection name for the model. + * The database connection name for DraggableComponent model. * TODO * @var string */ - //protected $connection = 'connection-name'; + protected $connection = 'mysql_report_generator'; } diff --git a/Modules/ReportGenerator/Entities/ReportFormat.php b/Modules/ReportGenerator/Entities/ReportFormat.php index e1efd1a..1ad4d14 100644 --- a/Modules/ReportGenerator/Entities/ReportFormat.php +++ b/Modules/ReportGenerator/Entities/ReportFormat.php @@ -1,4 +1,13 @@ +| +*/ namespace Modules\ReportGenerator\Entities; @@ -18,9 +27,9 @@ class ReportFormat extends Model ]; /** - * The connection name for the model. + * The database connection name for ReportFormat model. * TODO * @var string */ - //protected $connection = 'connection-name'; + protected $connection = 'mysql_report_generator'; } diff --git a/Modules/ReportGenerator/install.txt b/Modules/ReportGenerator/install.txt new file mode 100644 index 0000000..3adbba0 --- /dev/null +++ b/Modules/ReportGenerator/install.txt @@ -0,0 +1,6 @@ +Under constant updates + +1. Create your own .env file from the .env.example fill +2. Edit the database variables as for your report generator database connection. +3. Create a new database with the database name you specified in DB_REPORT_GENERATOR_DATABASE +4. Run php artisan module:seed ReportGenerator diff --git a/composer.lock b/composer.lock index ab4943f..74561a7 100644 --- a/composer.lock +++ b/composer.lock @@ -639,16 +639,16 @@ }, { "name": "nesbot/carbon", - "version": "1.27.0", + "version": "1.29.0", "source": { "type": "git", "url": "https://github.com/briannesbitt/Carbon.git", - "reference": "ef81c39b67200dcd7401c24363dcac05ac3a4fe9" + "reference": "b1cc4493fafb1b1402d50474fe6305e0558c6829" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/briannesbitt/Carbon/zipball/ef81c39b67200dcd7401c24363dcac05ac3a4fe9", - "reference": "ef81c39b67200dcd7401c24363dcac05ac3a4fe9", + "url": "https://api.github.com/repos/briannesbitt/Carbon/zipball/b1cc4493fafb1b1402d50474fe6305e0558c6829", + "reference": "b1cc4493fafb1b1402d50474fe6305e0558c6829", "shasum": "" }, "require": { @@ -683,7 +683,7 @@ "datetime", "time" ], - "time": "2018-04-23T09:02:57+00:00" + "time": "2018-05-24T13:09:20+00:00" }, { "name": "nikic/php-parser", @@ -902,16 +902,16 @@ }, { "name": "psy/psysh", - "version": "v0.9.3", + "version": "v0.9.4", "source": { "type": "git", "url": "https://github.com/bobthecow/psysh.git", - "reference": "79c280013cf0b30fa23f3ba8bd3649218075adf4" + "reference": "4d969a0e08e1e05e7207c07cb4207017ecc9a331" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/bobthecow/psysh/zipball/79c280013cf0b30fa23f3ba8bd3649218075adf4", - "reference": "79c280013cf0b30fa23f3ba8bd3649218075adf4", + "url": "https://api.github.com/repos/bobthecow/psysh/zipball/4d969a0e08e1e05e7207c07cb4207017ecc9a331", + "reference": "4d969a0e08e1e05e7207c07cb4207017ecc9a331", "shasum": "" }, "require": { @@ -923,9 +923,9 @@ "symfony/var-dumper": "~2.7|~3.0|~4.0" }, "require-dev": { + "bamarni/composer-bin-plugin": "^1.2", "hoa/console": "~2.15|~3.16", - "phpunit/phpunit": "~4.8.35|~5.0|~6.0|~7.0", - "symfony/finder": "~2.1|~3.0|~4.0" + "phpunit/phpunit": "~4.8.35|~5.0|~6.0|~7.0" }, "suggest": { "ext-pcntl": "Enabling the PCNTL extension makes PsySH a lot happier :)", @@ -970,7 +970,7 @@ "interactive", "shell" ], - "time": "2018-04-18T12:32:50+00:00" + "time": "2018-05-22T06:48:07+00:00" }, { "name": "ramsey/uuid", @@ -1108,16 +1108,16 @@ }, { "name": "symfony/console", - "version": "v3.4.9", + "version": "v3.4.11", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "5b1fdfa8eb93464bcc36c34da39cedffef822cdf" + "reference": "36f83f642443c46f3cf751d4d2ee5d047d757a27" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/5b1fdfa8eb93464bcc36c34da39cedffef822cdf", - "reference": "5b1fdfa8eb93464bcc36c34da39cedffef822cdf", + "url": "https://api.github.com/repos/symfony/console/zipball/36f83f642443c46f3cf751d4d2ee5d047d757a27", + "reference": "36f83f642443c46f3cf751d4d2ee5d047d757a27", "shasum": "" }, "require": { @@ -1173,20 +1173,20 @@ ], "description": "Symfony Console Component", "homepage": "https://symfony.com", - "time": "2018-04-30T01:22:56+00:00" + "time": "2018-05-16T08:49:21+00:00" }, { "name": "symfony/css-selector", - "version": "v3.4.9", + "version": "v3.4.11", "source": { "type": "git", "url": "https://github.com/symfony/css-selector.git", - "reference": "519a80d7c1d95c6cc0b67f686d15fe27c6910de0" + "reference": "d2ce52290b648ae33b5301d09bc14ee378612914" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/css-selector/zipball/519a80d7c1d95c6cc0b67f686d15fe27c6910de0", - "reference": "519a80d7c1d95c6cc0b67f686d15fe27c6910de0", + "url": "https://api.github.com/repos/symfony/css-selector/zipball/d2ce52290b648ae33b5301d09bc14ee378612914", + "reference": "d2ce52290b648ae33b5301d09bc14ee378612914", "shasum": "" }, "require": { @@ -1226,20 +1226,20 @@ ], "description": "Symfony CssSelector Component", "homepage": "https://symfony.com", - "time": "2018-03-19T22:32:39+00:00" + "time": "2018-05-16T12:49:49+00:00" }, { "name": "symfony/debug", - "version": "v3.4.9", + "version": "v3.4.11", "source": { "type": "git", "url": "https://github.com/symfony/debug.git", - "reference": "1b95888cfd996484527cb41e8952d9a5eaf7454f" + "reference": "b28fd73fefbac341f673f5efd707d539d6a19f68" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/debug/zipball/1b95888cfd996484527cb41e8952d9a5eaf7454f", - "reference": "1b95888cfd996484527cb41e8952d9a5eaf7454f", + "url": "https://api.github.com/repos/symfony/debug/zipball/b28fd73fefbac341f673f5efd707d539d6a19f68", + "reference": "b28fd73fefbac341f673f5efd707d539d6a19f68", "shasum": "" }, "require": { @@ -1282,11 +1282,11 @@ ], "description": "Symfony Debug Component", "homepage": "https://symfony.com", - "time": "2018-04-30T16:53:52+00:00" + "time": "2018-05-16T14:03:39+00:00" }, { "name": "symfony/event-dispatcher", - "version": "v3.4.9", + "version": "v3.4.11", "source": { "type": "git", "url": "https://github.com/symfony/event-dispatcher.git", @@ -1349,16 +1349,16 @@ }, { "name": "symfony/finder", - "version": "v3.4.9", + "version": "v3.4.11", "source": { "type": "git", "url": "https://github.com/symfony/finder.git", - "reference": "bd14efe8b1fabc4de82bf50dce62f05f9a102433" + "reference": "472a92f3df8b247b49ae364275fb32943b9656c6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/finder/zipball/bd14efe8b1fabc4de82bf50dce62f05f9a102433", - "reference": "bd14efe8b1fabc4de82bf50dce62f05f9a102433", + "url": "https://api.github.com/repos/symfony/finder/zipball/472a92f3df8b247b49ae364275fb32943b9656c6", + "reference": "472a92f3df8b247b49ae364275fb32943b9656c6", "shasum": "" }, "require": { @@ -1394,20 +1394,20 @@ ], "description": "Symfony Finder Component", "homepage": "https://symfony.com", - "time": "2018-04-04T05:07:11+00:00" + "time": "2018-05-16T08:49:21+00:00" }, { "name": "symfony/http-foundation", - "version": "v3.4.9", + "version": "v3.4.11", "source": { "type": "git", "url": "https://github.com/symfony/http-foundation.git", - "reference": "edc43b1a50402bb06b5111eb86b275c87a93e373" + "reference": "a7b5fc605d1c215cea1122359044b1e682eb70c0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/http-foundation/zipball/edc43b1a50402bb06b5111eb86b275c87a93e373", - "reference": "edc43b1a50402bb06b5111eb86b275c87a93e373", + "url": "https://api.github.com/repos/symfony/http-foundation/zipball/a7b5fc605d1c215cea1122359044b1e682eb70c0", + "reference": "a7b5fc605d1c215cea1122359044b1e682eb70c0", "shasum": "" }, "require": { @@ -1448,20 +1448,20 @@ ], "description": "Symfony HttpFoundation Component", "homepage": "https://symfony.com", - "time": "2018-04-30T01:05:13+00:00" + "time": "2018-05-25T11:07:31+00:00" }, { "name": "symfony/http-kernel", - "version": "v3.4.9", + "version": "v3.4.11", "source": { "type": "git", "url": "https://github.com/symfony/http-kernel.git", - "reference": "280fcedbcb3dabcc467a9c1734054af61928fe4f" + "reference": "3dac45df55ee0c5134c457a730cd68e2a2ce0445" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/http-kernel/zipball/280fcedbcb3dabcc467a9c1734054af61928fe4f", - "reference": "280fcedbcb3dabcc467a9c1734054af61928fe4f", + "url": "https://api.github.com/repos/symfony/http-kernel/zipball/3dac45df55ee0c5134c457a730cd68e2a2ce0445", + "reference": "3dac45df55ee0c5134c457a730cd68e2a2ce0445", "shasum": "" }, "require": { @@ -1469,7 +1469,8 @@ "psr/log": "~1.0", "symfony/debug": "~2.8|~3.0|~4.0", "symfony/event-dispatcher": "~2.8|~3.0|~4.0", - "symfony/http-foundation": "^3.4.4|^4.0.4" + "symfony/http-foundation": "^3.4.4|^4.0.4", + "symfony/polyfill-ctype": "~1.8" }, "conflict": { "symfony/config": "<2.8", @@ -1536,7 +1537,62 @@ ], "description": "Symfony HttpKernel Component", "homepage": "https://symfony.com", - "time": "2018-04-30T19:27:02+00:00" + "time": "2018-05-25T13:16:28+00:00" + }, + { + "name": "symfony/polyfill-ctype", + "version": "v1.8.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-ctype.git", + "reference": "7cc359f1b7b80fc25ed7796be7d96adc9b354bae" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/7cc359f1b7b80fc25ed7796be7d96adc9b354bae", + "reference": "7cc359f1b7b80fc25ed7796be7d96adc9b354bae", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.8-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Polyfill\\Ctype\\": "" + }, + "files": [ + "bootstrap.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + }, + { + "name": "Gert de Pagter", + "email": "BackEndTea@gmail.com" + } + ], + "description": "Symfony polyfill for ctype functions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "ctype", + "polyfill", + "portable" + ], + "time": "2018-04-30T19:57:29+00:00" }, { "name": "symfony/polyfill-mbstring", @@ -1658,16 +1714,16 @@ }, { "name": "symfony/process", - "version": "v3.4.9", + "version": "v3.4.11", "source": { "type": "git", "url": "https://github.com/symfony/process.git", - "reference": "4b7d64e852886319e93ddfdecff0d744ab87658b" + "reference": "4cbf2db9abcb01486a21b7a059e03a62fae63187" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/process/zipball/4b7d64e852886319e93ddfdecff0d744ab87658b", - "reference": "4b7d64e852886319e93ddfdecff0d744ab87658b", + "url": "https://api.github.com/repos/symfony/process/zipball/4cbf2db9abcb01486a21b7a059e03a62fae63187", + "reference": "4cbf2db9abcb01486a21b7a059e03a62fae63187", "shasum": "" }, "require": { @@ -1703,20 +1759,20 @@ ], "description": "Symfony Process Component", "homepage": "https://symfony.com", - "time": "2018-04-03T05:22:50+00:00" + "time": "2018-05-16T08:49:21+00:00" }, { "name": "symfony/routing", - "version": "v3.4.9", + "version": "v3.4.11", "source": { "type": "git", "url": "https://github.com/symfony/routing.git", - "reference": "9deb375986f5d1f37283d8386716d26985a0f4b6" + "reference": "e382da877f5304aabc12ec3073eec430670c8296" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/routing/zipball/9deb375986f5d1f37283d8386716d26985a0f4b6", - "reference": "9deb375986f5d1f37283d8386716d26985a0f4b6", + "url": "https://api.github.com/repos/symfony/routing/zipball/e382da877f5304aabc12ec3073eec430670c8296", + "reference": "e382da877f5304aabc12ec3073eec430670c8296", "shasum": "" }, "require": { @@ -1781,20 +1837,20 @@ "uri", "url" ], - "time": "2018-04-12T09:01:03+00:00" + "time": "2018-05-16T12:49:49+00:00" }, { "name": "symfony/translation", - "version": "v3.4.9", + "version": "v3.4.11", "source": { "type": "git", "url": "https://github.com/symfony/translation.git", - "reference": "d4af50f46cd8171fd5c1cdebdb9a8bbcd8078c6c" + "reference": "7047f725e35eab768137c677f8c38e4a2a8e38fb" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/translation/zipball/d4af50f46cd8171fd5c1cdebdb9a8bbcd8078c6c", - "reference": "d4af50f46cd8171fd5c1cdebdb9a8bbcd8078c6c", + "url": "https://api.github.com/repos/symfony/translation/zipball/7047f725e35eab768137c677f8c38e4a2a8e38fb", + "reference": "7047f725e35eab768137c677f8c38e4a2a8e38fb", "shasum": "" }, "require": { @@ -1849,11 +1905,11 @@ ], "description": "Symfony Translation Component", "homepage": "https://symfony.com", - "time": "2018-04-30T01:22:56+00:00" + "time": "2018-05-21T10:06:52+00:00" }, { "name": "symfony/var-dumper", - "version": "v3.4.9", + "version": "v3.4.11", "source": { "type": "git", "url": "https://github.com/symfony/var-dumper.git", @@ -3398,20 +3454,21 @@ }, { "name": "symfony/yaml", - "version": "v3.4.9", + "version": "v3.4.11", "source": { "type": "git", "url": "https://github.com/symfony/yaml.git", - "reference": "033cfa61ef06ee0847e056e530201842b6e926c3" + "reference": "c5010cc1692ce1fa328b1fb666961eb3d4a85bb0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/yaml/zipball/033cfa61ef06ee0847e056e530201842b6e926c3", - "reference": "033cfa61ef06ee0847e056e530201842b6e926c3", + "url": "https://api.github.com/repos/symfony/yaml/zipball/c5010cc1692ce1fa328b1fb666961eb3d4a85bb0", + "reference": "c5010cc1692ce1fa328b1fb666961eb3d4a85bb0", "shasum": "" }, "require": { - "php": "^5.5.9|>=7.0.8" + "php": "^5.5.9|>=7.0.8", + "symfony/polyfill-ctype": "~1.8" }, "conflict": { "symfony/console": "<3.4" @@ -3452,7 +3509,7 @@ ], "description": "Symfony Yaml Component", "homepage": "https://symfony.com", - "time": "2018-04-08T08:21:29+00:00" + "time": "2018-05-03T23:18:14+00:00" }, { "name": "webmozart/assert", diff --git a/config/database.php b/config/database.php index cab5d06..7b27e31 100644 --- a/config/database.php +++ b/config/database.php @@ -39,6 +39,7 @@ 'prefix' => '', ], + # Primary database connection 'mysql' => [ 'driver' => 'mysql', 'host' => env('DB_HOST', '127.0.0.1'), @@ -54,6 +55,22 @@ 'engine' => null, ], + # ReportGenerator database connection + 'mysql_report_generator' => [ + 'driver' => 'mysql', + 'host' => env('DB_REPORT_GENERATOR_HOST', '127.0.0.1'), + 'port' => env('DB_PORT', '3306'), + 'database' => env('DB_REPORT_GENERATOR_DATABASE', 'forge'), + 'username' => env('DB_REPORT_GENERATOR_USERNAME', 'forge'), + 'password' => env('DB_REPORT_GENERATOR_PASSWORD', ''), + 'unix_socket' => env('DB_SOCKET', ''), + 'charset' => 'utf8mb4', + 'collation' => 'utf8mb4_unicode_ci', + 'prefix' => '', + 'strict' => true, + 'engine' => null, + ], + 'pgsql' => [ 'driver' => 'pgsql', 'host' => env('DB_HOST', '127.0.0.1'), From b62f74a5b2ba74b70cdeff4b86f6be62ec390437 Mon Sep 17 00:00:00 2001 From: Trodrige Date: Mon, 4 Jun 2018 21:11:36 +0100 Subject: [PATCH 03/26] Added the junction table for report format and draggable component relationship. Updated instructions --- Documentation/instructions.txt | 7 +-- Documentation/librereportgenerator.sql | 49 +++++++++++++++++++ ...3827_create_draggable_components_table.php | 14 ++++-- ..._25_203256_create_report_formats_table.php | 15 +++--- ...raggable_component_report_format_table.php | 44 +++++++++++++++++ .../Entities/DraggableComponent.php | 11 +++++ .../ReportGenerator/Entities/ReportFormat.php | 12 +++++ .../Controllers/ReportGeneratorController.php | 20 +++++++- 8 files changed, 157 insertions(+), 15 deletions(-) create mode 100644 Documentation/librereportgenerator.sql create mode 100644 Modules/ReportGenerator/Database/Migrations/2018_06_04_083903_create_draggable_component_report_format_table.php diff --git a/Documentation/instructions.txt b/Documentation/instructions.txt index 061aa90..5f72c11 100644 --- a/Documentation/instructions.txt +++ b/Documentation/instructions.txt @@ -37,9 +37,9 @@ Instructions: 5. Navigate to lh-ehr-laravel-port directory 'cd lh-ehr-laravel-port' -6. Add you .env file by running this command: 'cp .env.example .env' +6. Add your .env file by running this command: 'cp .env.example .env' -7. Add your .env file to .gitignore filename. // It is already, just check! +7. Add your .env file to .gitignore filename. // It is already there, just check! 8. Generate key for your application by running the command below 'php artisan key:generate' @@ -57,7 +57,8 @@ Instructions: 'php artisan migrate' 12. You can seed the database width - 'php artisan db:seed' + 'php artisan db:seed' // This shouldn't work for now. + If seeding fails, then use the librereportgenerator.sql file in this directory to import sample data. 13. Start the application by running the command below in the terminal: 'php artisan serve' diff --git a/Documentation/librereportgenerator.sql b/Documentation/librereportgenerator.sql new file mode 100644 index 0000000..748eeae --- /dev/null +++ b/Documentation/librereportgenerator.sql @@ -0,0 +1,49 @@ +SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO"; +SET time_zone = "+00:00"; +-- +-- Use this file to seed the Report generator for now. +-- +-- Database: `librereportgenerator` +-- +-- -------------------------------------------------------- +-- +-- Dumping data for table `draggable_components` +-- +INSERT INTO `draggable_components` (`id`, `option_id`, `is_default`, `user`, `title`, `order`, `active`, `notes`, `toggle_sort`, `toggle_display`, `created_at`, `updated_at`) VALUES +(1, 'pfullname', 1, 'default', 'Patient Fullname', 5, 1, 'patient_data:fname|mname|lname', 0, 0, NULL, NULL), +(2, 'plfname', 1, 'default', 'Patient Last Firstname', 10, 1, 'patient_data:lname|fname', 0, 0, NULL, NULL), +(3, 'pflname', 1, 'default', 'Patient First Lastname', 15, 1, 'patient_data:fname|lname', 0, 0, NULL, NULL), +(4, 'preversedname', 1, 'default', 'Patient Full reversed name', 20, 1, 'patient_data:lname|mname|fname', 0, 0, NULL, NULL), +(5, 'pfmname', 1, 'default', 'Patient First Middlename', 25, 1, 'patient_data:fname|mname', 0, 0, NULL, NULL), +(6, 'pid', 1, 'default', 'Patient Id', 30, 1, 'patient_data:id', 0, 0, NULL, NULL), +(7, 'pstreet', 1, 'default', 'Patient Street', 35, 1, 'patient_data:street', 0, 0, NULL, NULL), +(8, 'pcity', 1, 'default', 'Patient First Lastname', 40, 1, 'patient_data:city', 0, 0, NULL, NULL), +(9, 'pstate', 1, 'default', 'Patient Full reversed name', 45, 1, 'patient_data:lname|mname|fname', 0, 0, NULL, NULL), +(10, 'pstreetcity', 1, 'default', 'Patient Street City', 50, 1, 'patient_data:street|city', 0, 0, NULL, NULL), +(11, 'pcitystate', 1, 'default', 'Patient City State', 55, 1, 'patient_data:city|state', 0, 0, NULL, NULL), +(12, 'pstreetcitystate', 1, 'default', 'Patient Street City State', 60, 1, 'patient_data:street|city|state', 0, 0, NULL, NULL), +(13, 'ppcode', 1, 'default', 'Patient Postal Code', 65, 1, 'patient_data:postal_code', 0, 0, NULL, NULL), +(14, 'poccupation', 1, 'default', 'Patient Occupation', 70, 1, 'patient_data:occupation', 0, 0, NULL, NULL), +(15, 'pemail', 1, 'default', 'Patient Email', 75, 1, 'patient_data:email', 0, 0, NULL, NULL), +(16, 'pphone', 1, 'default', 'Patient Phone Contact', 80, 1, 'patient_data:phone_contact', 0, 0, NULL, NULL), +(17, 'planguage', 1, 'default', 'Patient Language', 85, 1, 'patient_data:language', 0, 0, NULL, NULL), +(18, 'pregdate', 1, 'default', 'Patient Register date', 90, 1, 'patient_data:regdate', 0, 0, NULL, NULL), +(19, 'psex', 1, 'default', 'Patient Sex', 95, 1, 'patient_data:sex', 0, 0, NULL, NULL), +(20, 'pemailphone', 1, 'default', 'Patient Email Phone', 100, 1, 'patient_data:email|phone_contact', 0, 0, NULL, NULL), +(21, 'pidfullname', 1, 'default', 'Patient PID Fullname', 105, 1, 'patient_data:id|fname|mname|lname', 0, 0, NULL, NULL), +(22, 'pdob', 1, 'default', 'Patient Date of birth', 110, 1, 'patient_data:DOB', 0, 0, NULL, NULL), +(23, 'pss', 1, 'default', 'Patient SS', 115, 1, 'patient_data:ss', 0, 0, NULL, NULL), +(24, 'pstatus', 1, 'default', 'Patient Status', 120, 1, 'patient_data:status', 0, 0, NULL, NULL), +(25, 'preferrer', 1, 'default', 'Patient Referrer', 125, 1, 'patient_data:referrer', 0, 0, NULL, NULL), +(26, 'pstatussex', 1, 'default', 'Patient Status Sex', 130, 1, 'patient_data:status|sex', 0, 0, NULL, NULL), +(27, 'pidnamecontact', 1, 'default', 'Patient ID Name Contact', 135, 1, 'patient_data:id|fname|mname|phone_contact|email', 0, 0, NULL, NULL), +(28, 'pidnameAddress', 1, 'default', 'Patient ID Name Address', 140, 1, 'patient_data:id|fname|mname|street|city|state|postal_code', 0, 0, NULL, NULL), +(29, 'poccupationmonthlyincome', 1, 'default', 'Patient Occupation Monthly Income', 145, 1, 'patient_data:occupation|monthly_income', 0, 0, NULL, NULL), +(30, 'psexstatusfamilysize', 1, 'default', 'Patient Sex Status Family Size', 150, 1, 'patient_data:sex|status|family_size', 0, 0, NULL, NULL); + +-- -------------------------------------------------------- + +-- +-- Dumping data for table `report_formats` +-- + diff --git a/Modules/ReportGenerator/Database/Migrations/2018_05_22_153827_create_draggable_components_table.php b/Modules/ReportGenerator/Database/Migrations/2018_05_22_153827_create_draggable_components_table.php index 4be500b..a78fa8c 100644 --- a/Modules/ReportGenerator/Database/Migrations/2018_05_22_153827_create_draggable_components_table.php +++ b/Modules/ReportGenerator/Database/Migrations/2018_05_22_153827_create_draggable_components_table.php @@ -1,4 +1,12 @@ + */ use Illuminate\Support\Facades\Schema; use Illuminate\Database\Schema\Blueprint; @@ -8,10 +16,6 @@ class CreateDraggableComponentsTable extends Migration { /** * Run the migrations. - * This file creates draggable_components for the report-generator. - * This is close to the list_options table, but this one if for the report generator module. - * - * TODO Link this table to users table in order to keep track of user adding or editing a component. * * @author Tigpezeghe Rodrige K. (2018) * @@ -27,7 +31,7 @@ public function up() $table->string('title', 255)->comment = "This is the text on the component that end users see."; $table->integer('order', 0)->comment = "The order in which components appear in the list."; $table->boolean('active')->default(1)->comment = "0 -> False, 1 -> True whether the component should be active or not."; - $table->json('notes', 255)->comment = "This stores the fields that the component relates to in the database."; + $table->string('notes', 1000)->comment = "This stores the fields that the component relates to in the database."; $table->boolean('toggle_sort')->default(0)->comment = "0 -> False (Descending), 1 -> True (Ascending)."; $table->boolean('toggle_display')->default(0)->comment = "0 -> False, 1 -> True. Display field if checked (1), and no if unchecked (0)."; diff --git a/Modules/ReportGenerator/Database/Migrations/2018_05_25_203256_create_report_formats_table.php b/Modules/ReportGenerator/Database/Migrations/2018_05_25_203256_create_report_formats_table.php index d45b3ba..bf05701 100644 --- a/Modules/ReportGenerator/Database/Migrations/2018_05_25_203256_create_report_formats_table.php +++ b/Modules/ReportGenerator/Database/Migrations/2018_05_25_203256_create_report_formats_table.php @@ -1,5 +1,12 @@ + */ use Illuminate\Support\Facades\Schema; use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Migrations\Migration; @@ -8,10 +15,6 @@ class CreateReportFormatsTable extends Migration { /** * Run the migrations. - * This file creates draggable_components for the report-generator. - * This is close to the list_options table, but this one if for the report generator module. - * - * TODO Link this table to users table in order to keep track of user adding or editing a component. * * @author Tigpezeghe Rodrige K. (2018) * @@ -25,7 +28,7 @@ public function up() $table->string('title', 255)->comment = "This is the report name e.g Patient List."; $table->string('system_feature', 255)->comment = "The system feature under which the report belongs."; $table->text('description')->comment = "This describes the report format briefly."; - $table->json('draggable_components_id')->comment = "This stores the id of all the components that belong to this report format"; + //$table->string('draggable_components_id', 1000)->comment = "This stores the id of all the components that belong to this report format"; $table->timestamps(); }); diff --git a/Modules/ReportGenerator/Database/Migrations/2018_06_04_083903_create_draggable_component_report_format_table.php b/Modules/ReportGenerator/Database/Migrations/2018_06_04_083903_create_draggable_component_report_format_table.php new file mode 100644 index 0000000..075e144 --- /dev/null +++ b/Modules/ReportGenerator/Database/Migrations/2018_06_04_083903_create_draggable_component_report_format_table.php @@ -0,0 +1,44 @@ + + */ + +use Illuminate\Support\Facades\Schema; +use Illuminate\Database\Schema\Blueprint; +use Illuminate\Database\Migrations\Migration; + +class CreateDraggableComponentReportFormatTable extends Migration +{ + /** + * Run the migrations. + * + * @author Tigpezeghe Rodrige K. (2018) + * + * @return void + */ + public function up() + { + Schema::connection('mysql_report_generator')->create('draggable_component_report_format', function (Blueprint $table) { + $table->increments('id')->comment = "Primary key."; + $table->integer('draggable_component_id')->unsigned()->comment = "Used to access the draggable_components."; + $table->foreign('draggable_component_id')->references('id')->on('draggable_components'); + $table->integer('report_format_id')->unsigned()->comment = "Ussed to access the report_formats."; + $table->foreign('report_format_id')->references('id')->on('report_formats'); + + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('draggable_component_report_format'); + } +} diff --git a/Modules/ReportGenerator/Entities/DraggableComponent.php b/Modules/ReportGenerator/Entities/DraggableComponent.php index e16027a..37f24a9 100644 --- a/Modules/ReportGenerator/Entities/DraggableComponent.php +++ b/Modules/ReportGenerator/Entities/DraggableComponent.php @@ -12,6 +12,7 @@ namespace Modules\ReportGenerator\Entities; use Illuminate\Database\Eloquent\Model; +use Modules\ReportGenerator\Entities\ReportFormat as ReportFormat; class DraggableComponent extends Model { @@ -32,4 +33,14 @@ class DraggableComponent extends Model * @var string */ protected $connection = 'mysql_report_generator'; + + /** + * The report formats that belong to the Draggable component. + * + * @return Response + */ + public function report_formats() + { + return $this->belongsToMany('ReportFormat')->withTimestamps(); + } } diff --git a/Modules/ReportGenerator/Entities/ReportFormat.php b/Modules/ReportGenerator/Entities/ReportFormat.php index 1ad4d14..2860dd3 100644 --- a/Modules/ReportGenerator/Entities/ReportFormat.php +++ b/Modules/ReportGenerator/Entities/ReportFormat.php @@ -12,6 +12,7 @@ namespace Modules\ReportGenerator\Entities; use Illuminate\Database\Eloquent\Model; +use Modules\ReportGenerator\Entities\DraggableComponent as DraggableComponent; class ReportFormat extends Model { @@ -32,4 +33,15 @@ class ReportFormat extends Model * @var string */ protected $connection = 'mysql_report_generator'; + + /** + * The draggable components that belong to the Report Format. + * + * @return Response + */ + public function draggable_components() + { + return $this->belongsToMany('DraggableComponent')->withTimestamps(); + } + } diff --git a/Modules/ReportGenerator/Http/Controllers/ReportGeneratorController.php b/Modules/ReportGenerator/Http/Controllers/ReportGeneratorController.php index f0363fc..6d3b361 100644 --- a/Modules/ReportGenerator/Http/Controllers/ReportGeneratorController.php +++ b/Modules/ReportGenerator/Http/Controllers/ReportGeneratorController.php @@ -1,4 +1,13 @@ +| +*/ namespace Modules\ReportGenerator\Http\Controllers; @@ -6,6 +15,8 @@ use Illuminate\Http\Response; use Illuminate\Routing\Controller; +use Modules\ReportGenerator\Entities\DraggableComponent as DraggableComponent; + class ReportGeneratorController extends Controller { /** @@ -14,7 +25,14 @@ class ReportGeneratorController extends Controller */ public function index() { - return view('reportgenerator::index'); + $draggableComponents = DraggableComponent::all(); + + foreach ($draggableComponents as $draggableComponent) { + print_r($draggableComponent->title); + echo '
'; + } + + //return view('reportgenerator::index'); } /** From ff73094affd58616ad6fea0258839357145a217f Mon Sep 17 00:00:00 2001 From: Trodrige Date: Wed, 6 Jun 2018 06:24:04 +0100 Subject: [PATCH 04/26] display draggable components --- .../Controllers/ReportGeneratorController.php | 6 ++-- .../Resources/views/index.blade.php | 35 +++++-------------- public/assets/css/master.css | 15 +++++++- public/assets/js/master.js | 8 +++-- 4 files changed, 32 insertions(+), 32 deletions(-) diff --git a/Modules/ReportGenerator/Http/Controllers/ReportGeneratorController.php b/Modules/ReportGenerator/Http/Controllers/ReportGeneratorController.php index 6d3b361..cf9ce6a 100644 --- a/Modules/ReportGenerator/Http/Controllers/ReportGeneratorController.php +++ b/Modules/ReportGenerator/Http/Controllers/ReportGeneratorController.php @@ -27,12 +27,14 @@ public function index() { $draggableComponents = DraggableComponent::all(); - foreach ($draggableComponents as $draggableComponent) { + return view('reportgenerator::index')->with('draggableComponents', $draggableComponents); + + /* foreach ($draggableComponents as $draggableComponent) { print_r($draggableComponent->title); echo '
'; } - //return view('reportgenerator::index'); + return view('reportgenerator::index'); */ } /** diff --git a/Modules/ReportGenerator/Resources/views/index.blade.php b/Modules/ReportGenerator/Resources/views/index.blade.php index 6ccdb5e..45ff03e 100644 --- a/Modules/ReportGenerator/Resources/views/index.blade.php +++ b/Modules/ReportGenerator/Resources/views/index.blade.php @@ -81,7 +81,7 @@
-

Why am I stil empty?

+

Why am I still empty?

@@ -96,31 +96,14 @@

Frequently used columns

-
-

I am one

-

I am two

-

I am three

-

I am four

-
-
-

I am five

-

I am six

-

I am seven

-

I am eight

-
-
-

All columns that concern reports

-
-

I am one

-

I am two

-

I am three

-

I am four

-
-
-

I am five

-

I am six

-

I am seven

-

I am eight

+
+ @foreach ($draggableComponents as $draggableComponent) +
+

+ {{ $draggableComponent->title }} +

+
+ @endforeach
diff --git a/public/assets/css/master.css b/public/assets/css/master.css index f7fbd22..9193311 100644 --- a/public/assets/css/master.css +++ b/public/assets/css/master.css @@ -6,7 +6,7 @@ text-align: center; } -#draggable{ +.draggable{ max-width: 24.5%; height: 50px; border: 1px solid lightgrey; @@ -19,3 +19,16 @@ margin-top: -7px; margin-bottom: -7px; } +#draggable-column { + /* overflow: auto; */ + height: 500px; +} + +/*Wrap and break the draggable components' titles*/ +.wordwrap { + padding: 3px; + width: 130px; + word-break: break-all; + word-wrap: break-word; + overflow: hidden; +} diff --git a/public/assets/js/master.js b/public/assets/js/master.js index 77a314e..81eea4e 100644 --- a/public/assets/js/master.js +++ b/public/assets/js/master.js @@ -1,15 +1,17 @@ $( function(){ - $('.col-sm-3').draggable({ + $('.col-sm-2').draggable({ addClasses: true }); - var addClasses = $('.col-sm-3').draggable("option", "addClasses"); + var addClasses = $('.col-sm-2').draggable("option", "addClasses"); $('#second').droppable({ drop: function(event, ui){ $(this) .addClass('ui-state-highlight') + .css('background-color', '#fd7e14') .find('p') - .html("Dropped " + $(ui.draggable).attr("id")); + .html("Dropped " + $(ui.draggable).attr("id")) + .html(); $(ui.draggable).addClass('ui-state-highlight'); //$(ui.draggable).draggable('disable'); console.log('Dragged: ' + $(ui.draggable).attr("id")); From eae39842b10d84d0cc17dcfe320df751f547e4ea Mon Sep 17 00:00:00 2001 From: Trodrige Date: Mon, 11 Jun 2018 10:24:15 +0100 Subject: [PATCH 05/26] Getting the option IDs of selected components --- .../Controllers/ReportGeneratorController.php | 22 +++-- Modules/ReportGenerator/Http/routes.php | 4 + .../Resources/views/index.blade.php | 6 +- .../Resources/views/layouts/master.blade.php | 2 +- .../Resources/views/report.blade.php | 9 +++ app/Providers/AppServiceProvider.php | 3 +- public/assets/css/master.css | 18 ++++- public/assets/js/master.js | 81 ++++++++++++++----- 8 files changed, 112 insertions(+), 33 deletions(-) create mode 100644 Modules/ReportGenerator/Resources/views/report.blade.php diff --git a/Modules/ReportGenerator/Http/Controllers/ReportGeneratorController.php b/Modules/ReportGenerator/Http/Controllers/ReportGeneratorController.php index cf9ce6a..ca34f22 100644 --- a/Modules/ReportGenerator/Http/Controllers/ReportGeneratorController.php +++ b/Modules/ReportGenerator/Http/Controllers/ReportGeneratorController.php @@ -1,7 +1,7 @@ with('draggableComponents', $draggableComponents); + } - /* foreach ($draggableComponents as $draggableComponent) { - print_r($draggableComponent->title); - echo '
'; - } - - return view('reportgenerator::index'); */ + /** + * Show the generated report. + * @return Response + */ + public function getComponents() + { + $option_ids = Input::get($option_ids); // returns an array + // use ids to get the draggable components notes + // use notes to get the table columns + // send the data to the view + //return view('reportgenerator::report')->with('ids', $option_ids); + return url('reportgenerator/showReport'); } /** diff --git a/Modules/ReportGenerator/Http/routes.php b/Modules/ReportGenerator/Http/routes.php index a3d07fd..6009005 100644 --- a/Modules/ReportGenerator/Http/routes.php +++ b/Modules/ReportGenerator/Http/routes.php @@ -3,4 +3,8 @@ Route::group(['middleware' => 'web', 'prefix' => 'reportgenerator', 'namespace' => 'Modules\ReportGenerator\Http\Controllers'], function() { Route::get('/', 'ReportGeneratorController@index'); + + Route::get('/generate', 'ReportGeneratorController@getComponents'); + + Route::get('/showReport', 'ReportGeneratorController@showReport'); }); diff --git a/Modules/ReportGenerator/Resources/views/index.blade.php b/Modules/ReportGenerator/Resources/views/index.blade.php index 45ff03e..d9d3b98 100644 --- a/Modules/ReportGenerator/Resources/views/index.blade.php +++ b/Modules/ReportGenerator/Resources/views/index.blade.php @@ -1,5 +1,7 @@ @extends('reportgenerator::layouts.master') +@section('title', 'Report Generator') + @section('content')