diff --git a/app/Helpers/ProjectNamingSchema.php b/app/Helpers/ProjectNamingSchema.php new file mode 100644 index 0000000..322a51b --- /dev/null +++ b/app/Helpers/ProjectNamingSchema.php @@ -0,0 +1,47 @@ +validate([ - 'reference' => 'required|string|max:255', + 'reference' => 'required|string|max:12', 'name' => 'required|string|max:255', 'description' => 'nullable|string', 'status' => 'required|in:Activo,Inactivo', diff --git a/app/Livewire/ProjectShow.php b/app/Livewire/ProjectShow.php index 4801173..8e4836b 100644 --- a/app/Livewire/ProjectShow.php +++ b/app/Livewire/ProjectShow.php @@ -167,7 +167,7 @@ class ProjectShow extends Component 'file_path' => $file->store("projects/{$this->project->id}/documents"), 'project_id' => $this->project->id, // Asegurar que se envía 'folder_id' => $this->currentFolder?->id, - //'user_id' => Auth::id(), + 'user_id' => Auth::id(), //'status' => 'active' // Añadir si tu modelo lo requiere ]); } @@ -242,4 +242,9 @@ class ProjectShow extends Component { return view('livewire.project.show'); } + + public function generateProjectCode(array $fields): string + { + return \App\Helpers\ProjectNamingSchema::generate($fields); + } } diff --git a/app/Models/Document.php b/app/Models/Document.php index a160ea9..3fd66e5 100644 --- a/app/Models/Document.php +++ b/app/Models/Document.php @@ -21,7 +21,15 @@ class Document extends Model 'project_id', // Asegurar que está en fillable 'folder_id', 'user_id', - 'status' + 'status', + 'revision', + 'version', + 'discipline', + 'document_type', + 'issuer', + 'entry_date', + 'current_version_id', + 'code', ]; diff --git a/database/migrations/2025_04_22_112354_update_projects.php b/database/migrations/2025_04_22_112354_update_projects.php index 1092b9c..0c0fd02 100644 --- a/database/migrations/2025_04_22_112354_update_projects.php +++ b/database/migrations/2025_04_22_112354_update_projects.php @@ -12,6 +12,7 @@ return new class extends Migration public function up(): void { Schema::table('projects', function (Blueprint $table) { + $table->string('reference', 12)->nullable()->after('id')->uniqidue(); $table->string('status')->nullable(); $table->string('project_image_path')->nullable(); $table->string('address')->nullable(); @@ -33,6 +34,7 @@ return new class extends Migration public function down(): void { Schema::table('documents', function (Blueprint $table) { + $table->dropColumn('reference'); $table->dropColumn('status'); $table->dropColumn('project_image_path'); $table->dropColumn('address'); diff --git a/database/migrations/2025_05_22_141314_add_fields_to_project.php b/database/migrations/2025_05_22_141314_add_fields_to_project.php deleted file mode 100644 index 42ca373..0000000 --- a/database/migrations/2025_05_22_141314_add_fields_to_project.php +++ /dev/null @@ -1,28 +0,0 @@ -string('reference')->nullable()->after('id')->uniqidue(); - }); - } - - /** - * Reverse the migrations. - */ - public function down(): void - { - Schema::table('projects', function (Blueprint $table) { - $table->dropColumn('reference'); - }); - } -}; diff --git a/database/migrations/2025_10_24_000001_add_fields_to_documents_table.php b/database/migrations/2025_10_24_000001_add_fields_to_documents_table.php new file mode 100644 index 0000000..ed05511 --- /dev/null +++ b/database/migrations/2025_10_24_000001_add_fields_to_documents_table.php @@ -0,0 +1,34 @@ +string('code')->before('name'); + $table->string('revision')->nullable(); + $table->string('version')->nullable(); + $table->string('discipline')->nullable(); + $table->string('document_type')->nullable(); + $table->string('issuer')->nullable(); + $table->date('entry_date')->nullable(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('documents', function (Blueprint $table) { + $table->dropColumn(['code', 'revision', 'version', 'discipline', 'document_type', 'issuer', 'entry_date']); + }); + } +}; \ No newline at end of file diff --git a/docs/ISO19650_Naming_Convention.md b/docs/ISO19650_Naming_Convention.md new file mode 100644 index 0000000..26aa0c4 --- /dev/null +++ b/docs/ISO19650_Naming_Convention.md @@ -0,0 +1,93 @@ +# ISO 19650 Project Naming Convention + +## Overview +This document outlines the naming convention for projects based on the ISO 19650 standard. The naming convention ensures consistency, clarity, and compliance with industry standards. + +## Naming Fields +The naming convention consists of the following fields: + +| Field | Definition | Requirement | Length | +|--------------------|---------------------------------------------------------------------------|-------------------|--------------| +| **Proyecto** | Identificador del expediente, contrato o proyecto | Requerido | 2-12 | +| **Creador** | Organización creadora del documento | Requerido | 3-6 | +| **Volumen o Sistema** | Agrupaciones, áreas o tramos representativos en los que se fragmenta el proyecto | Requerido | 2-3 | +| **Nivel o Localización** | Localización dentro de un Volumen o Sistema | Requerido | 3 | +| **Tipo de Documento** | Tipología de documento, entregable o auxiliar | Requerido | 3 | +| **Disciplina** | Ámbito al que se corresponde el documento | Requerido | 3 | +| **Número** | Enumerador de partes | Requerido | 3 | +| **Descripción** | Texto que describe el documento y su contenido | Opcional | Sin límite | +| **Estado** | Situación, temporal o definitiva, del documento | Opcional/Metadato | 2 | +| **Revisión** | Versión del documento | Opcional/Metadato | 4 | + +## Field Details + +### Proyecto +- **Definition**: Identifies the project, contract, or file. +- **Requirement**: Required +- **Length**: 2-12 characters + +### Creador +- **Definition**: Organization responsible for creating the document. +- **Requirement**: Required +- **Length**: 3-6 characters + +### Volumen o Sistema +- **Definition**: Representative groupings, areas, or sections of the project. +- **Requirement**: Required +- **Length**: 2-3 characters + +### Nivel o Localización +- **Definition**: Location within a Volume or System. +- **Requirement**: Required +- **Length**: 3 characters + +### Tipo de Documento +- **Definition**: Document type, deliverable, or auxiliary. +- **Requirement**: Required +- **Length**: 3 characters + +### Disciplina +- **Definition**: Scope to which the document corresponds. +- **Requirement**: Required +- **Length**: 3 characters + +### Número +- **Definition**: Part enumerator. +- **Requirement**: Required +- **Length**: 3 characters + +### Descripción +- **Definition**: Text describing the document and its content. +- **Requirement**: Optional +- **Length**: Unlimited + +### Estado +- **Definition**: Temporary or definitive status of the document. +- **Requirement**: Optional/Metadata +- **Length**: 2 characters + +### Revisión +- **Definition**: Document version. +- **Requirement**: Optional/Metadata +- **Length**: 4 characters + +## Example +A sample project name following this convention: +``` +PRJ001-ORG01-V01-L01-DOC-ARC-001-Description-ST-0001 +``` +Where: +- **PRJ001**: Project identifier +- **ORG01**: Creator organization +- **V01**: Volume +- **L01**: Level +- **DOC**: Document type +- **ARC**: Discipline +- **001**: Part number +- **Description**: Description of the document +- **ST**: Status +- **0001**: Revision + +## Notes +- All fields marked as "Required" must be included. +- Optional fields can be omitted if not applicable. \ No newline at end of file diff --git a/docs/ProjectNamingCodeGenerator.md b/docs/ProjectNamingCodeGenerator.md new file mode 100644 index 0000000..fee5904 --- /dev/null +++ b/docs/ProjectNamingCodeGenerator.md @@ -0,0 +1,80 @@ +# Project Naming Code Generator + +## Overview +The `ProjectNamingSchema` class provides a utility to generate project names based on the ISO 19650 naming convention. This ensures consistency and compliance with industry standards. + +## Installation +Ensure the `ProjectNamingSchema` class is located in the `App\Helpers` namespace. No additional installation steps are required. + +## Usage +To generate a project name, use the `generate` method of the `ProjectNamingSchema` class. This method accepts an associative array of fields and returns the generated project name. + +### Example +```php +use App\Helpers\ProjectNamingSchema; + +$fields = [ + 'project' => 'PRJ001', + 'creator' => 'ORG01', + 'volume' => 'V01', + 'level' => 'L01', + 'documentType' => 'DOC', + 'discipline' => 'ARC', + 'number' => '1', + 'description' => 'Description', + 'status' => 'ST', + 'revision' => '1', +]; + +$projectName = ProjectNamingSchema::generate($fields); + +// Output: PRJ001-ORG01-V01-L01-DOC-ARC-001-Description-ST-0001 +``` + +## Fields +The following fields are supported: + +| Field | Definition | Requirement | Length | +|--------------------|---------------------------------------------------------------------------|-------------------|--------------| +| **project** | Identifies the project, contract, or file. | Required | 2-12 | +| **creator** | Organization responsible for creating the document. | Required | 3-6 | +| **volume** | Representative groupings, areas, or sections of the project. | Required | 2-3 | +| **level** | Location within a Volume or System. | Required | 3 | +| **documentType** | Document type, deliverable, or auxiliary. | Required | 3 | +| **discipline** | Scope to which the document corresponds. | Required | 3 | +| **number** | Part enumerator. | Required | 3 | +| **description** | Text describing the document and its content. | Optional | Unlimited | +| **status** | Temporary or definitive status of the document. | Optional | 2 | +| **revision** | Document version. | Optional | 4 | + +## Validation +The `generate` method validates that all required fields are provided. If any required field is missing, an `InvalidArgumentException` is thrown. + +### Example +```php +$fields = [ + 'creator' => 'ORG01', + 'volume' => 'V01', + 'level' => 'L01', + 'documentType' => 'DOC', + 'discipline' => 'ARC', + 'number' => '1', +]; + +try { + $projectName = ProjectNamingSchema::generate($fields); +} catch (InvalidArgumentException $e) { + echo $e->getMessage(); // Output: The field 'project' is required. +} +``` + +## Testing +Unit tests for the `ProjectNamingSchema` class are located in the `tests/Unit/ProjectNamingSchemaTest.php` file. Run the tests using the following command: + +```bash +vendor\bin\pest --filter ProjectNamingSchemaTest +``` + +## Notes +- All fields marked as "Required" must be included. +- Optional fields can be omitted if not applicable. \ No newline at end of file diff --git a/resources/views/livewire/project/show.blade copy.php b/resources/views/livewire/project/show.blade copy.php new file mode 100644 index 0000000..0f2f226 --- /dev/null +++ b/resources/views/livewire/project/show.blade copy.php @@ -0,0 +1,506 @@ +
+ {{ $project->reference }} +
+| {{ $label }} | ++ {{ $project->$field ?? 'N/A' }} + | +
N/A
' !!} +|
+
+
+
+
+
+
+ Nombre
+
+ |
+
+ + + | ||||||||
|---|---|---|---|---|---|---|---|---|---|
| + | ++ + | ++ {{ $document->versions_count }} + | ++ {{ $document->updated_at->diffForHumans() }} + | +
+ |
+ + {{ $document->revision }} + | ++ {{ $document->discipline }} + | ++ {{ $document->document_type }} + | ++ {{ $document->issuer }} + | ++ {{ $document->entry_date }} + | +
| + No se encontraron documentos en esta carpeta + | +|||||||||
Ingresa el nombre de la nueva carpeta
+{{ $message }}
+ @enderror ++ {{ $currentFolder ? "Carpeta destino: {$currentFolder->name}" : "Carpeta raíz del proyecto" }} +
++ Arrastra archivos aquí o haz clic para seleccionar +
++ Formatos soportados: PDF, DOCX, XLSX, JPG, PNG (Máx. 10MB) +
+| Nombre - javi | -Versiones | -Última Actualización | -Estado | +
+
+
+
+
+ |
+ + NOMBRE + | + ++ | ||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| - | + | {{ $document->versions_count }} | -+ | {{ $document->updated_at->diffForHumans() }} | -+ |
|
+ + {{ $document->revision }} + | ++ {{ $document->discipline }} + | ++ {{ $document->document_type }} + | ++ {{ $document->issuer }} + | ++ {{ $document->entry_date }} + | |
| + | No se encontraron documentos en esta carpeta | |||||||||||