Skip to content

Commit 944c706

Browse files
committed
Kanban /issues/592
1 parent 2070846 commit 944c706

18 files changed

+2106
-1117
lines changed

app/Http/Controllers/Workflow/QuotesController.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ public function index()
4040
//Quote data for chart
4141
$data['quotesDataRate'] = $this->quoteKPIService->getQuotesDataRate($CurentYear);
4242
//Quote data for chart
43-
$data['quoteMonthlyRecap'] = $this->quoteKPIService->getQuotesrMonthlyRecap($CurentYear);
43+
$data['quoteMonthlyRecap'] = $this->quoteKPIService->getQuoteMonthlyRecap($CurentYear);
44+
$data['quoteMonthlyRecapPreviousYear'] = $this->quoteKPIService->getQuoteMonthlyRecapPreviousYear($CurentYear);
4445

4546
return view('workflow/quotes-index')->with('data',$data);
4647
}

app/Livewire/LeadsIndex.php

Lines changed: 80 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace App\Livewire;
44

5+
use Carbon\Carbon;
56
use App\Models\User;
67
use Livewire\Component;
78
use Livewire\WithPagination;
@@ -22,7 +23,7 @@ class LeadsIndex extends Component
2223
public $sortAsc = true; // default sort direction
2324

2425
public $searchIdPriority = '';
25-
26+
public $userSelect = [];
2627
private $Leadslist;
2728

2829
public $id;
@@ -36,7 +37,8 @@ class LeadsIndex extends Component
3637
public $comment;
3738

3839
public $idCompanie = '';
39-
40+
public $statuses;
41+
4042
public function sortBy($field)
4143
{
4244
if ($this->sortField === $field) {
@@ -47,9 +49,16 @@ public function sortBy($field)
4749
$this->sortField = $field;
4850
}
4951

52+
5053
public function changeView($view)
5154
{
5255
$this->viewType = $view;
56+
session()->put('viewType', $view);
57+
}
58+
59+
public function updatingSearch()
60+
{
61+
$this->resetPage();
5362
}
5463

5564
// Validation Rules
@@ -62,6 +71,54 @@ public function changeView($view)
6271
'priority'=>'required',
6372
];
6473

74+
public function mount()
75+
{
76+
77+
$this->userSelect = User::select('id', 'name')->get();
78+
// Retrieve statuses and Leads
79+
$this->statuses = [
80+
[
81+
'id' => 1,
82+
'title' => __('general_content.new_trans_key'),
83+
'Leads' => Leads::with(['companie', 'contact'])
84+
->where('statu', 1)
85+
->get() // Keep Eloquent objects, no `toArray()`
86+
],
87+
[
88+
'id' => 2,
89+
'title' => __('general_content.assigned_trans_key'),
90+
'Leads' => Leads::with(['companie', 'contact'])
91+
->where('statu', 2)
92+
->get() // Keep Eloquent objects, no `toArray()`
93+
],
94+
[
95+
'id' => 3,
96+
'title' => __('general_content.in_progress_trans_key'),
97+
'Leads' => Leads::with(['companie', 'contact'])
98+
->where('statu', 3)
99+
->get() // Keep Eloquent objects, no `toArray()`
100+
],
101+
[
102+
'id' => 4,
103+
'title' => __('general_content.converted_trans_key'),
104+
'Leads' => Leads::with(['companie', 'contact'])
105+
->where('statu', 4)
106+
->where('updated_at', '>=', Carbon::now()->subHours(48))
107+
->get() // Keep Eloquent objects, no `toArray()`
108+
],
109+
[
110+
'id' => 5,
111+
'title' => __('general_content.lost_trans_key'),
112+
'Leads' => Leads::with(['companie', 'contact'])
113+
->where('statu', 5)
114+
->where('updated_at', '>=', Carbon::now()->subHours(48))
115+
->get() // Keep Eloquent objects, no `toArray()`
116+
]
117+
];
118+
119+
$this->viewType = session()->get('viewType', 'table');
120+
}
121+
65122
public function render()
66123
{
67124
if(is_numeric($this->idCompanie)){
@@ -108,4 +165,25 @@ public function storeLead(){
108165

109166
return redirect()->route('leads')->with('success', 'New lead add successfully');
110167
}
168+
169+
public function updateColumnOrder($order)
170+
{
171+
foreach ($order as $item) {
172+
// Update the order of the columns (statuses) if necessary
173+
//Leads::find($item['value'])->update(['statu_order' => $item['order']]);
174+
}
175+
176+
$this->mount(); // Reload data after update
177+
}
178+
179+
public function updateTaskOrder($groupOrder)
180+
{
181+
foreach ($groupOrder as $group) {
182+
foreach ($group['items'] as $item) {
183+
Leads::find($item['value'])->update(['statu' => $group['value']]);
184+
}
185+
}
186+
187+
$this->mount(); // Reload data after update
188+
}
111189
}

app/Livewire/OpportunitiesIndex.php

Lines changed: 78 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace App\Livewire;
44

5+
use Carbon\Carbon;
56
use App\Models\User;
67
use Livewire\Component;
78
use Illuminate\Support\Str;
@@ -15,6 +16,8 @@ class OpportunitiesIndex extends Component
1516
{
1617
use WithPagination;
1718
protected $paginationTheme = 'bootstrap';
19+
protected $listeners = ['changeView'];
20+
1821
public $viewType = 'table'; // Defaults to 'table'
1922

2023
public $search = '';
@@ -37,6 +40,7 @@ class OpportunitiesIndex extends Component
3740
public $comment;
3841

3942
public $idCompanie = '';
43+
public $statuses;
4044

4145
// Validation Rules
4246
protected $rules = [
@@ -62,16 +66,67 @@ public function sortBy($field)
6266
public function changeView($view)
6367
{
6468
$this->viewType = $view;
69+
session()->put('viewType', $view);
6570
}
6671

6772
public function updatingSearch()
6873
{
6974
$this->resetPage();
7075
}
71-
76+
7277
public function mount()
7378
{
7479
$this->userSelect = User::select('id', 'name')->get();
80+
// Retrieve statuses and opportunities
81+
$this->statuses = [
82+
[
83+
'id' => 1,
84+
'title' => __('general_content.new_trans_key'),
85+
'Opportunities' => Opportunities::with(['companie', 'contact'])
86+
->where('statu', 1)
87+
->get() // Keep Eloquent objects, no `toArray()`
88+
],
89+
[
90+
'id' => 2,
91+
'title' => __('general_content.quote_made_trans_key'),
92+
'Opportunities' => Opportunities::with(['companie', 'contact'])
93+
->where('statu', 2)
94+
->get() // Keep Eloquent objects, no `toArray()`
95+
],
96+
[
97+
'id' => 3,
98+
'title' => __('general_content.negotiation_trans_key'),
99+
'Opportunities' => Opportunities::with(['companie', 'contact'])
100+
->where('statu', 3)
101+
->get() // Keep Eloquent objects, no `toArray()`
102+
],
103+
[
104+
'id' => 4,
105+
'title' => __('general_content.closed_won_trans_key'),
106+
'Opportunities' => Opportunities::with(['companie', 'contact'])
107+
->where('statu', 4)
108+
->where('updated_at', '>=', Carbon::now()->subHours(48))
109+
->get() // Keep Eloquent objects, no `toArray()`
110+
],
111+
[
112+
'id' => 5,
113+
'title' => __('general_content.closed_lost_trans_key'),
114+
'Opportunities' => Opportunities::with(['companie', 'contact'])
115+
->where('statu', 5)
116+
->where('updated_at', '>=', Carbon::now()->subHours(48))
117+
->get() // Keep Eloquent objects, no `toArray()`
118+
],
119+
[
120+
'id' => 6,
121+
'title' => __('general_content.informational_trans_key'),
122+
'Opportunities' => Opportunities::with(['companie', 'contact'])
123+
->where('statu', 6)
124+
->where('updated_at', '>=', Carbon::now()->subHours(48))
125+
->get() // Keep Eloquent objects, no `toArray()`
126+
]
127+
];
128+
129+
$this->viewType = session()->get('viewType', 'table');
75130
}
76131

77132
public function render()
@@ -121,4 +176,26 @@ public function storeOpportunity(){
121176

122177
return redirect()->route('opportunities.show', ['id' => $OpportunityCreated->id])->with('success', 'Successfully created new opportunity');
123178
}
179+
180+
public function updateColumnOrder($order)
181+
{
182+
foreach ($order as $item) {
183+
// Update the order of the columns (statuses) if necessary
184+
//Opportunities::find($item['value'])->update(['statu_order' => $item['order']]);
185+
}
186+
187+
$this->mount(); // Reload data after update
188+
}
189+
190+
public function updateTaskOrder($groupOrder)
191+
{
192+
foreach ($groupOrder as $group) {
193+
foreach ($group['items'] as $item) {
194+
Opportunities::find($item['value'])->update(['statu' => $group['value']]);
195+
}
196+
}
197+
198+
$this->mount(); // Reload data after update
199+
}
200+
124201
}

app/Livewire/OrdersIndex.php

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace App\Livewire;
44

5+
use Carbon\Carbon;
56
use App\Models\User;
67
use Livewire\Component;
78
use App\Events\OrderCreated;
@@ -22,6 +23,10 @@ class OrdersIndex extends Component
2223
use WithPagination;
2324
protected $paginationTheme = 'bootstrap';
2425

26+
protected $listeners = ['changeView'];
27+
28+
public $viewType = 'table'; // Defaults to 'table'
29+
2530
public $search = '';
2631
public $sortField = 'created_at'; // default sorting field
2732
public $sortAsc = false; // default sort direction
@@ -47,6 +52,8 @@ class OrdersIndex extends Component
4752

4853
public $idCompanie = '';
4954

55+
public $statuses;
56+
5057
protected $orderService;
5158

5259
public function __construct()
@@ -93,6 +100,12 @@ public function sortBy($field)
93100
$this->sortField = $field;
94101
}
95102

103+
public function changeView($view)
104+
{
105+
$this->viewType = $view;
106+
session()->put('viewType', $view);
107+
}
108+
96109
public function updatingSearch()
97110
{
98111
$this->resetPage();
@@ -109,6 +122,55 @@ public function mount()
109122
$this->accounting_deliveries_id = $this->getDefaultId(AccountingDelivery::class);
110123

111124
$this->setOrderCodeAndLabel();
125+
126+
$this->statuses = [
127+
[
128+
'id' => 1,
129+
'title' => __('general_content.open_trans_key'),
130+
'Orders' => Orders::with(['companie', 'contact'])
131+
->where('statu', 1)
132+
->get() // Garder les objets Eloquent
133+
],
134+
[
135+
'id' => 2,
136+
'title' => __('general_content.in_progress_trans_key'),
137+
'Orders' => Orders::with(['companie', 'contact'])
138+
->where('statu', 2)
139+
->get() // Garder les objets Eloquent
140+
],
141+
[
142+
'id' => 3,
143+
'title' => __('general_content.delivered_trans_key'),
144+
'Orders' => Orders::with(['companie', 'contact'])
145+
->where('statu', 3)
146+
->where('updated_at', '>=', Carbon::now()->subHours(48))
147+
->get() // Garder les objets Eloquent
148+
],
149+
[
150+
'id' => 4,
151+
'title' => __('general_content.partly_delivered_trans_key'),
152+
'Orders' => Orders::with(['companie', 'contact'])
153+
->where('statu', 4)
154+
->where('updated_at', '>=', Carbon::now()->subHours(48))
155+
->get() // Garder les objets Eloquent
156+
],
157+
[
158+
'id' => 5,
159+
'title' => __('general_content.stopped_trans_key'),
160+
'Orders' => Orders::with(['companie', 'contact'])
161+
->where('statu', 5)
162+
->get() // Garder les objets Eloquent
163+
],
164+
[
165+
'id' => 6,
166+
'title' => __('general_content.canceled_trans_key'),
167+
'Orders' => Orders::with(['companie', 'contact'])
168+
->where('statu', 6)
169+
->get() // Garder les objets Eloquent
170+
]
171+
];
172+
173+
$this->viewType = session()->get('viewType', 'table');
112174
}
113175

114176
public function changeLabel()

0 commit comments

Comments
 (0)