Skip to content

Commit a2f8301

Browse files
committed
1 parent 3b3b41c commit a2f8301

File tree

9 files changed

+444
-5
lines changed

9 files changed

+444
-5
lines changed

app/Http/Controllers/Workflow/QuotesController.php

Lines changed: 46 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@
1010
use App\Http\Controllers\Controller;
1111
use App\Services\CustomFieldService;
1212
use App\Services\QuoteCalculatorService;
13+
use App\Models\Workflow\QuoteProjectEstimate;
1314
use App\Http\Requests\Workflow\UpdateQuoteRequest;
15+
use App\Http\Requests\Workflow\ProjectEstimateRequest;
1416

1517
class QuotesController extends Controller
1618
{
@@ -65,8 +67,7 @@ public function show(Quotes $id)
6567
$TotalServicePrice = $QuoteCalculatorService->getTotalPriceByService();
6668
list($previousUrl, $nextUrl) = $this->getNextPrevious(new Quotes(), $id->id);
6769
$CustomFields = $this->customFieldService->getCustomFieldsWithValues('quote', $id->id);
68-
69-
70+
$projectEstimate = QuoteProjectEstimate::where('quotes_id', $id->id)->first();
7071
return view('workflow/quotes-show', [
7172
'Quote' => $id,
7273
'CompanieSelect' => $CompanieSelect,
@@ -85,6 +86,7 @@ public function show(Quotes $id)
8586
'previousUrl' => $previousUrl,
8687
'nextUrl' => $nextUrl,
8788
'CustomFields' => $CustomFields,
89+
'projectEstimate' => $projectEstimate,
8890
]);
8991
}
9092

@@ -109,4 +111,46 @@ public function update(UpdateQuoteRequest $request)
109111

110112
return redirect()->route('quotes.show', ['id' => $Quote->id])->with('success', 'Successfully updated quote');
111113
}
114+
115+
public function saveProjectEstimate(ProjectEstimateRequest $request, $quoteId)
116+
{
117+
// Récupérer les données validées
118+
$validated = $request->validated();
119+
120+
// Recherche ou création d'une nouvelle estimation de projet
121+
$projectEstimate = QuoteProjectEstimate::where('quotes_id', $quoteId)->first();
122+
123+
// Si l'estimation de projet n'existe pas, on en crée une nouvelle
124+
if (!$projectEstimate) {
125+
$projectEstimate = new QuoteProjectEstimate();
126+
$projectEstimate->quotes_id = $quoteId; // Assigne le quote_id à la nouvelle instance
127+
}
128+
129+
// Mises à jour des champs avec les valeurs soumises dans le formulaire
130+
$projectEstimate->show_client_requirements_on_pdf = $request->has('show_client_requirements_on_pdf') ? 1 : 2;
131+
$projectEstimate->show_layout_on_pdf = $request->has('show_layout_on_pdf') ? 1 : 2;
132+
$projectEstimate->show_materials_on_pdf = $request->has('show_materials_on_pdf') ? 1 : 2;
133+
$projectEstimate->show_logistics_on_pdf = $request->has('show_logistics_on_pdf') ? 1 : 2;
134+
$projectEstimate->show_contractors_on_pdf = $request->has('show_contractors_on_pdf') ? 1 : 2;
135+
$projectEstimate->show_waste_on_pdf = $request->has('show_waste_on_pdf') ? 1 : 2;
136+
$projectEstimate->show_taxes_on_pdf = $request->has('show_taxes_on_pdf') ? 1 : 2;
137+
$projectEstimate->show_options_on_pdf = $request->has('show_options_on_pdf') ? 1 : 2;
138+
$projectEstimate->show_insurance_on_pdf = $request->has('show_insurance_on_pdf') ? 1 : 2;
139+
140+
// Sauvegarde des données validées dans l'estimation de projet
141+
$projectEstimate->fill($validated); // Mise à jour des champs avec les données validées
142+
143+
if ($projectEstimate->exists) {
144+
// Mise à jour de l'estimation existante
145+
$projectEstimate->save();
146+
} else {
147+
// Création d'une nouvelle estimation si elle n'existe pas encore
148+
$projectEstimate->save();
149+
}
150+
151+
152+
// Redirection après l'enregistrement
153+
return redirect()->route('quotes.show', ['id' => $quoteId])
154+
->with('success', __('Estimation de projet enregistrée avec succès.'));
155+
}
112156
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<?php
2+
3+
namespace App\Http\Requests\Workflow;
4+
5+
use Illuminate\Foundation\Http\FormRequest;
6+
7+
class ProjectEstimateRequest extends FormRequest
8+
{
9+
/**
10+
* Determine if the user is authorized to make this request.
11+
*/
12+
public function authorize(): bool
13+
{
14+
return true;
15+
}
16+
17+
/**
18+
* Get the validation rules that apply to the request.
19+
*
20+
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
21+
*/
22+
public function rules(): array
23+
{
24+
return [
25+
'client_requirements' => 'nullable|string',
26+
'layout_plan' => 'nullable|string',
27+
'materials_finishes' => 'nullable|string',
28+
'logistics' => 'nullable|string',
29+
'logistics_cost' => 'nullable|numeric',
30+
'coordination_with_contractors' => 'nullable|string',
31+
'contractors_cost' => 'nullable|numeric',
32+
'waste_management' => 'nullable|string',
33+
'waste_management_cost' => 'nullable|numeric',
34+
'taxes_and_fees' => 'nullable|string',
35+
'taxes_cost' => 'nullable|numeric',
36+
'work_start_date' => 'nullable|date',
37+
'work_end_date' => 'nullable|date',
38+
'contingency_days' => 'nullable|integer',
39+
'options_variants' => 'nullable|string',
40+
'insurance_liability' => 'nullable|string',
41+
'insurance_cost' => 'nullable|numeric',
42+
];
43+
}
44+
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<?php
2+
3+
namespace App\Models\Workflow;
4+
5+
use App\Models\Workflow\Quotes;
6+
use Illuminate\Database\Eloquent\Model;
7+
8+
class QuoteProjectEstimate extends Model
9+
{
10+
protected $fillable = [
11+
'quotes_id',
12+
'client_requirements',
13+
'show_client_requirements_on_pdf',
14+
'layout_plan',
15+
'layout_improvements',
16+
'show_layout_on_pdf',
17+
'materials_finishes',
18+
'show_materials_on_pdf',
19+
'logistics',
20+
'logistics_cost',
21+
'show_logistics_on_pdf',
22+
'coordination_with_contractors',
23+
'contractors_cost',
24+
'show_contractors_on_pdf',
25+
'waste_management',
26+
'waste_management_cost',
27+
'show_waste_on_pdf',
28+
'taxes_and_fees',
29+
'taxes_cost',
30+
'show_taxes_on_pdf',
31+
'work_start_date',
32+
'work_end_date',
33+
'contingency_days',
34+
'options_variants',
35+
'show_options_on_pdf',
36+
'insurance_liability',
37+
'insurance_cost',
38+
'show_insurance_on_pdf',
39+
'revision_clause',
40+
'show_revision_clause_on_pdf',
41+
'warranty_clause',
42+
'show_warranty_clause_on_pdf',
43+
'professional_presentation',
44+
'show_presentation_on_pdf'
45+
];
46+
47+
public function quote()
48+
{
49+
return $this->belongsTo(Quotes::class, 'quotes_id');
50+
}
51+
}
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
<?php
2+
3+
use Illuminate\Database\Migrations\Migration;
4+
use Illuminate\Database\Schema\Blueprint;
5+
use Illuminate\Support\Facades\Schema;
6+
7+
return new class extends Migration
8+
{
9+
/**
10+
* Run the migrations.
11+
*/
12+
public function up(): void
13+
{
14+
Schema::create('quote_project_estimates', function (Blueprint $table) {
15+
$table->id();
16+
$table->integer('quotes_id');
17+
// Analyse des Besoins du Client
18+
$table->text('client_requirements')->nullable();
19+
$table->boolean('show_client_requirements_on_pdf')->default(false);
20+
21+
// Plan d'Agencement
22+
$table->string('layout_plan')->nullable();
23+
$table->text('layout_improvements')->nullable();
24+
$table->boolean('show_layout_on_pdf')->default(false);
25+
26+
// Matériaux et Finitions
27+
$table->text('materials_finishes')->nullable();
28+
$table->boolean('show_materials_on_pdf')->default(false);
29+
30+
// Logistique et Livraison
31+
$table->text('logistics')->nullable();
32+
$table->decimal('logistics_cost', 10, 2)->nullable();
33+
$table->boolean('show_logistics_on_pdf')->default(false);
34+
35+
// Coordination avec d'autres Entrepreneurs
36+
$table->text('coordination_with_contractors')->nullable();
37+
$table->decimal('contractors_cost', 10, 2)->nullable();
38+
$table->boolean('show_contractors_on_pdf')->default(false);
39+
40+
// Gestion des Déchets
41+
$table->text('waste_management')->nullable();
42+
$table->decimal('waste_management_cost', 10, 2)->nullable();
43+
$table->boolean('show_waste_on_pdf')->default(false);
44+
45+
// Taxes et Frais Additionnels
46+
$table->text('taxes_and_fees')->nullable();
47+
$table->decimal('taxes_cost', 10, 2)->nullable();
48+
$table->boolean('show_taxes_on_pdf')->default(false);
49+
50+
// Échéancier de Travail
51+
$table->date('work_start_date')->nullable();
52+
$table->date('work_end_date')->nullable();
53+
$table->integer('contingency_days')->nullable();
54+
55+
// Options et Variantes
56+
$table->text('options_variants')->nullable();
57+
$table->boolean('show_options_on_pdf')->default(false);
58+
59+
// Assurance et Responsabilité
60+
$table->text('insurance_liability')->nullable();
61+
$table->decimal('insurance_cost', 10, 2)->nullable();
62+
$table->boolean('show_insurance_on_pdf')->default(false);
63+
64+
// Clause de Révision
65+
$table->text('revision_clause')->nullable();
66+
$table->boolean('show_revision_clause_on_pdf')->default(false);
67+
68+
// Clause de Garantie
69+
$table->text('warranty_clause')->nullable();
70+
$table->boolean('show_warranty_clause_on_pdf')->default(false);
71+
72+
// Présentation Professionnelle
73+
$table->string('professional_presentation')->nullable();
74+
$table->boolean('show_presentation_on_pdf')->default(false);
75+
76+
$table->timestamps();
77+
});
78+
}
79+
80+
/**
81+
* Reverse the migrations.
82+
*/
83+
public function down(): void
84+
{
85+
Schema::dropIfExists('quotes_project_estimates');
86+
}
87+
};

resources/lang/en/general_content.php

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@
170170
'margin_trans_key' => 'Margin',
171171
'mask_time_trans_key' => 'Mask time',
172172
'capacity_trans_key' => 'Capacity',
173+
'hour_capacity_week_trans_key' => 'Hour capacity by week',
173174
'etat_trans_key' => 'Etat',
174175
'cost_trans_key' => 'Unit Cost',
175176
'due_date_trans_key' => 'Due date',
@@ -278,6 +279,7 @@
278279

279280
'quote_info_trans_key' => 'Quote info',
280281
'quote_line_trans_key' => 'Quote lines',
282+
'construction_site_trans_key' => 'Construction site/layout',
281283
'guest_page_trans_key' => 'Guest page',
282284
'lines_import_trans_key' => 'Lines Import',
283285

@@ -657,7 +659,28 @@
657659
'set_csv_col_trans_key' => 'set CSV col number',
658660
'choose_csv_trans_key' => 'Choose a .csv file...',
659661
'csv_quote_info_trans_key' => 'The unit value are defined in the methods section and the value of the default VAT are defined in the accounting section. If there is no discount column, the default value will be 0 %.',
660-
662+
'client_requirement_trans_key' => 'Client Requirements',
663+
'show_client_requirements_on_pdf_trans_key'=> 'Show Client Requirements on PDF',
664+
'layout_plan_trans_key' => 'Layout Plan',
665+
'show_layout_on_pdf_trans_key' => 'Show Layout plan on PDF',
666+
'materials_finishes_trans_key' => 'Materials and Finishes',
667+
'show_materials_on_pdf_trans_key' => 'Show Materials and Finishes on PDF',
668+
'logistics_trans_key' => 'Logistics',
669+
'logistics_cost_trans_key' => 'Logistics cost',
670+
'show_logistics_on_pdf_trans_key' => 'Show Logistics on PDF',
671+
'coordination_with_contractors_trans_key' => 'Coordination with contractors',
672+
'contractors_cost_trans_key' => 'Contractors cost',
673+
'show_contractors_on_pdf_trans_key' => 'Show contractors coordination on PDF',
674+
'waste_management_trans_key' => 'Waste management',
675+
'waste_management_cost_trans_key' => 'Waste management cost',
676+
'show_waste_on_pdf_trans_key' => 'Show waste management on PDF',
677+
'taxes_and_fees_trans_key' => 'Additional taxes and fees',
678+
'taxes_cost_trans_key' => 'Taxes cost',
679+
'show_taxes_on_pdf_trans_key' => 'Show taxes on PDF',
680+
'work_start_date_trans_key' => 'Work start date',
681+
'work_end_date_trans_key' => 'Work end date',
682+
'contingency_days_trans_key' => 'Contingency (days)',
683+
661684
//ORDERS
662685
'orders_trans_key' => 'Orders',
663686
'orders_list_trans_key' => 'Orders list',

resources/lang/fr/general_content.php

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@
169169
'hourly_rate_trans_key' => 'Taux horaire',
170170
'margin_trans_key' => 'Marge',
171171
'mask_time_trans_key' => 'Temps masqué',
172+
'hour_capacity_week_trans_key' => 'Capacité d\'heure par semaine',
172173
'capacity_trans_key' => 'Capacité',
173174
'etat_trans_key' => 'Etat',
174175
'cost_trans_key' => 'Coût',
@@ -278,6 +279,7 @@
278279

279280
'quote_info_trans_key' => 'Information du devis',
280281
'quote_line_trans_key' => 'Ligne du devis',
282+
'construction_site_trans_key' => 'Chantier/agencement',
281283
'guest_page_trans_key' => 'Page publique',
282284
'lines_import_trans_key' => 'Importation de lignes',
283285

@@ -657,7 +659,28 @@
657659
'set_csv_col_trans_key' => 'Choisir numéro de colonne CSV',
658660
'choose_csv_trans_key' => 'Choisir un fichier csv ...',
659661
'csv_quote_info_trans_key' => 'La valeur unitaire est définie dans la section méthodes et la valeur de la TVA par défaut est définie dans la section comptabilité. S\'il n\'y a pas de colonne de remise, la valeur par défaut sera 0 %.',
660-
662+
'client_requirement_trans_key' => 'Exigences du client',
663+
'show_client_requirements_on_pdf_trans_key'=> 'Afficher les exigences du client sur le PDF',
664+
'layout_plan_trans_key' => 'Plan de mise en page',
665+
'show_layout_on_pdf_trans_key' => 'Afficher le plan de mise en page sur le PDF',
666+
'materials_finishes_trans_key' => 'Matériaux et Finitions',
667+
'show_materials_on_pdf_trans_key' => 'Afficher les matériaux et finitions sur le PDF',
668+
'logistics_trans_key' => 'Logistique',
669+
'logistics_cost_trans_key' => 'Coût de la logistique',
670+
'show_logistics_on_pdf_trans_key' => 'Afficher la logistique sur le PDF',
671+
'coordination_with_contractors_trans_key' => 'Coordination avec les entrepreneurs',
672+
'contractors_cost_trans_key' => 'Coût des entrepreneurs',
673+
'show_contractors_on_pdf_trans_key' => 'Afficher la coordination des entrepreneurs sur le PDF',
674+
'waste_management_trans_key' => 'Gestion des déchets',
675+
'waste_management_cost_trans_key' => 'Coût de la gestion des déchets',
676+
'show_waste_on_pdf_trans_key' => 'Afficher la gestion des déchets sur le PDF',
677+
'taxes_and_fees_trans_key' => 'Taxes et Frais Additionnels',
678+
'taxes_cost_trans_key' => 'Coût des taxes',
679+
'show_taxes_on_pdf_trans_key' => 'Afficher les taxes sur le PDF',
680+
'work_start_date_trans_key' => 'Date de début des travaux',
681+
'work_end_date_trans_key' => 'Date de fin des travaux',
682+
'contingency_days_trans_key' => 'Marge de manœuvre (jours)',
683+
661684
//ORDERS
662685
'orders_trans_key' => 'Commandes',
663686
'orders_list_trans_key' => 'Liste des commandes',

resources/views/methods/methods-ressources.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@
218218
data-on-color="teal" checked/>
219219
</div>
220220
<div class="form-group">
221-
<label for="capacity">Hour capacity by week</label>
221+
<label for="capacity">{{__('general_content.hour_capacity_week_trans_key') }}</label>
222222
<div class="input-group">
223223
<div class="input-group-prepend">
224224
<span class="input-group-text"><i class="fas fa-stopwatch"></i></span>

0 commit comments

Comments
 (0)