Skip to content

Commit 5500129

Browse files
committed
Change /issues/507
1 parent 5489a81 commit 5500129

File tree

9 files changed

+203
-152
lines changed

9 files changed

+203
-152
lines changed

app/Http/Controllers/Planning/GanttController.php

Lines changed: 52 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class GanttController extends Controller
1515
/**
1616
* @return \Illuminate\Contracts\View\View
1717
*/
18-
public function index()
18+
public function index(Request $request)
1919
{
2020
$countTaskNullDate = Task::whereNull('end_date')
2121
->whereNotNull('order_lines_id')
@@ -24,72 +24,63 @@ public function index()
2424
->orWhere('tasks.type', 7);
2525
})
2626
->count();
27-
return view('workflow/gantt-index', compact('countTaskNullDate'));
27+
28+
$OrderLineList = OrderLines::orderby('created_at', 'desc')->get();
29+
30+
31+
$orderLineId = $request->input('order_line_id');
32+
33+
return view('workflow/gantt-index', compact('countTaskNullDate', 'OrderLineList', 'orderLineId'));
2834
}
2935

3036
/**
3137
* @return \Illuminate\Http\JsonResponse
3238
*/
33-
public function get(){
39+
public function getTasksByOrderLine($order_lines_id)
40+
{
3441

35-
$Orders = Orders::select('orders.id', DB::raw('orders.code as text'), DB::raw("0 AS duration"), DB::raw("0 as progress"), 'orders.validity_date AS end_date', DB::raw("0 as parent"))
36-
->where('orders.statu', '=', 1)
37-
->Orwhere('orders.statu', '=', 2)
38-
->orderBy('orders.validity_date')
39-
->get()->map(function($tag){
40-
return [
41-
'id' => $tag->id,
42-
'text' => $tag->text,
43-
'duration' => $tag->duration,
44-
'progress' => $tag->progress,
45-
'end_date' => $tag->end_date,
46-
'parent' => $tag->parent,
47-
];
48-
});
42+
// Récupérer la ligne de commande
43+
$orderLine = OrderLines::find($order_lines_id);
4944

50-
$OrderLines = OrderLines::select(DB::raw('CONCAT(\'l_\',order_lines.id) AS id_tempo'), DB::raw('CONCAT(order_lines.code, \' \', order_lines.label) as text'), DB::raw("0 AS duration"), DB::raw("0 as progress"), 'order_lines.internal_delay AS end_date', DB::raw('order_lines.orders_id as parent'))
51-
->join('orders', 'order_lines.orders_id', '=', 'orders.id')
52-
->where('orders.statu', '=', 1)
53-
->Orwhere('orders.statu', '=', 2)
54-
->orderBy('order_lines.internal_delay')
55-
->get()->map(function($tag){
56-
return [
57-
'id' => $tag->id_tempo,
58-
'text' => $tag->text,
59-
'duration' => $tag->duration,
60-
'progress' => $tag->progress,
61-
'end_date' => $tag->end_date,
62-
'parent' => $tag->parent,
63-
];
64-
});
65-
$merge = $Orders->merge($OrderLines);
66-
67-
$tasks = Task::select('tasks.id', DB::raw('CONCAT(\'#\',tasks.id, \' \', tasks.label) as text'), DB::raw("(tasks.qty * tasks.unit_time + tasks.seting_time) AS duration"), 'tasks.end_date AS end_date', DB::raw('CONCAT(\'l_\',tasks.order_lines_id) as parent'), DB::raw("methods_services.color as color"))
68-
->join('order_lines', 'tasks.order_lines_id', '=', 'order_lines.id')
69-
->join('orders', 'order_lines.orders_id', '=', 'orders.id')
70-
->join('methods_services', 'tasks.methods_services_id', '=', 'methods_services.id')
71-
->whereNotNull('tasks.order_lines_id')
72-
->where(function (Builder $query) {
73-
return $query->where('tasks.type', 1)
74-
->orWhere('tasks.type', 7);
75-
})
76-
->where('orders.statu', 1)
77-
->Orwhere('orders.statu', '=', 2)
78-
->orderBy('tasks.end_date')
79-
->get()->map(function($tag){
80-
return [
81-
'id' => $tag->id,
82-
'text' => $tag->text,
83-
'duration' => $tag->duration,
84-
'end_date' => $tag->end_date,
85-
'parent' => $tag->parent,
86-
'color' => $tag->color,
87-
];
88-
});
89-
$merge = $merge->merge($tasks);
90-
91-
return response()->json([
92-
"data" => $merge,
93-
]);
45+
// Ajouter la ligne de commande comme première "tâche"
46+
$formattedTasks[] = [
47+
'id' => 'order_line_' . $orderLine->id,
48+
'label' => '#' . $orderLine->label,
49+
'resource' => 'Order Line',
50+
'start_date' => $orderLine->created_at ? new \DateTime($orderLine->created_at) : null,
51+
'end_date' => $orderLine->delivery_date ? new \DateTime($orderLine->delivery_date) : null,
52+
'duration' => null, // Optionnel, si vous avez besoin de la durée
53+
'progress' => $orderLine->getAveragePercentProgressTaskAttribute(),
54+
'dependencies' => null,
55+
];
56+
57+
// Récupérer les tâches liées à un order_lines_id
58+
$tasks = Task::where('order_lines_id', $order_lines_id)
59+
->where(function (Builder $query) {
60+
return $query->where('tasks.type', 1)
61+
->orWhere('tasks.type', 7);
62+
})
63+
->orderBy('ordre', 'asc')
64+
->get();
65+
66+
$previousTaskId = 'order_line_' . $orderLine->id; // La première tâche dépend de la ligne de commande
67+
68+
// Ajouter les tâches en les reliant correctement
69+
foreach ($tasks as $task) {
70+
$formattedTasks[] = [
71+
'id' => $task->id,
72+
'label' => '#'. $task->id .' - '. $task->label,
73+
'resource' => $task->service ? $task->service->name : null,
74+
'start_date' => $task->start_date ? new \DateTime($task->start_date) : null,
75+
'end_date' => $task->end_date ? new \DateTime($task->end_date) : null,
76+
'duration' => $task->TotalTime(),
77+
'progress' => $task->progress(),
78+
'dependencies' => $previousTaskId, // Dépend de la tâche précédente
79+
];
80+
81+
$previousTaskId = $task->id; // Mettre à jour l'ID de la tâche précédente pour la prochaine itération
82+
}
83+
84+
return response()->json(['data' => $formattedTasks]);
9485
}
9586
}

app/Livewire/TaskCalculationDate.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,6 @@ public function calculateDate()
113113
$endDate = date("Y-m-d H:i:s", $DatetimeLine-$totalTaskLineTime);
114114
$UpdateTask = Task::find($Task->id);
115115
$UpdateTask->end_date = $endDate;
116-
$UpdateTask->save();
117116

118117
$this->progressDateLog .= '<li>End date : '. $endDate .' updated for task #'. $Task->id .'</li>';
119118

@@ -134,6 +133,11 @@ public function calculateDate()
134133

135134
//now we add time in sec
136135
$totalTaskLineTime += ($Task->TotalTime()+$addfirsthour+$addTime)*3600;
136+
137+
$startDate = date("Y-m-d H:i:s", $DatetimeLine-$totalTaskLineTime);
138+
$UpdateTask->start_date = $startDate;
139+
$UpdateTask->save();
140+
137141
$order = $Task->order_lines_id;
138142

139143
$this->countTaskCalculateDate += 1;

app/Models/Planning/Task.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ class Task extends Model
5757
'diameter',
5858
'diameter_oversize',
5959
'to_schedule',
60+
'start_date',
6061
'end_date',
6162
'not_recalculate',
6263
'material',

config/adminlte.php

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -524,7 +524,7 @@
524524
],
525525
['header' => 'settings_trans_key'],
526526
[
527-
'text' => 'Setting times',
527+
'text' => 'settings_time_trans_key',
528528
'icon' => 'fas fa-user-clock',
529529
'url' => 'times',
530530
'can' => ['settings-time-menu'],
@@ -812,21 +812,6 @@
812812
],
813813
],
814814
],
815-
'dhtmlxGantt ' => [
816-
'active' => true,
817-
'files' => [
818-
[
819-
'type' => 'css',
820-
'asset' => true,
821-
'location' => '//cdn.dhtmlx.com/gantt/edge/dhtmlxgantt.css',
822-
],
823-
[
824-
'type' => 'js',
825-
'asset' => true,
826-
'location' => '//cdn.dhtmlx.com/gantt/edge/dhtmlxgantt.js',
827-
],
828-
],
829-
],
830815

831816

832817
],
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
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+
* @return void
13+
*/
14+
public function up()
15+
{
16+
Schema::table('tasks', function (Blueprint $table) {
17+
$table->dateTime('start_date')->nullable()->before('end_date');
18+
});
19+
}
20+
21+
/**
22+
* Reverse the migrations.
23+
*
24+
* @return void
25+
*/
26+
public function down()
27+
{
28+
Schema::table('tasks', function (Blueprint $table) {
29+
$table->dropColumn('start_date');
30+
});
31+
}
32+
};

resources/views/products/StockLocationProduct-show.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@
228228
</x-slot>
229229
<option value="null">{{ __('general_content.select_order_line_trans_key') }}</option>
230230
@foreach ($OrderLineList as $item)
231-
<option value="{{ $item->id }}">#{{ $item->id }} - {{ $item->Order->code }}</option>
231+
<option value="{{ $item->id }}">#{{ $item->id }} {{ $item->label }} - {{ $item->Order->code }}</option>
232232
@endforeach
233233
</x-adminlte-select2>
234234
</div>

0 commit comments

Comments
 (0)