Skip to content

Commit 652b08b

Browse files
committed
project setup from converted prospect
1 parent 5b3c207 commit 652b08b

17 files changed

+153
-393
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<?php
2+
3+
namespace Modules\Project\Emails;
4+
5+
use Illuminate\Bus\Queueable;
6+
use Illuminate\Mail\Mailable;
7+
use Illuminate\Queue\SerializesModels;
8+
9+
class EffortsheetSetupMail extends Mailable
10+
{
11+
use Queueable;
12+
use SerializesModels;
13+
14+
public $project;
15+
public $emails = [];
16+
17+
/**
18+
* Create a new message instance.
19+
*
20+
* @return void
21+
*/
22+
public function __construct($project, array $emails)
23+
{
24+
$this->project = $project;
25+
$this->emails = $emails;
26+
}
27+
28+
/**
29+
* Build the message.
30+
*
31+
* @return $this
32+
*/
33+
public function build()
34+
{
35+
$mail = $this->subject("Project Effortsheet Setup Request: {$this->project->name}")
36+
->from(config('mail.from.address'))
37+
->to($this->emails['infrasupport_email'])
38+
->cc($this->emails['key_account_manager'])
39+
->view('project::mail.effortsheet-setup-email')
40+
->with([
41+
'project' => $this->project,
42+
]);
43+
44+
return $mail;
45+
}
46+
}

Modules/Project/Http/Controllers/ProjectController.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,10 @@ public function index()
4545
*/
4646
public function create()
4747
{
48+
$projectData = session('projectData', []);
4849
$clients = $this->service->getClients($status = 'all');
4950

50-
return view('project::create')->with('clients', $clients);
51+
return view('project::create')->with(['clients' => $clients, 'projectData' => $projectData]);
5152
}
5253

5354
/**

Modules/Project/Http/Requests/ProjectRequest.php

+2
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ public function rules()
4545
'start_date' => 'nullable|date',
4646
'end_date' => 'nullable|date',
4747
'is_amc' => 'nullable',
48+
'send_mail_to_infra' => 'nullable',
4849
];
4950
break;
5051

@@ -64,6 +65,7 @@ public function rules()
6465
'start_date' => 'nullable|date',
6566
'end_date' => 'nullable|date',
6667
'is_amc' => 'nullable',
68+
'send_mail_to_infra' => 'nullable',
6769
];
6870
break;
6971

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<div>
2+
<style>
3+
.line {
4+
line-height: 1px;
5+
}
6+
</style>
7+
8+
<p>Hi Infrastructure Support Team,</p>
9+
10+
<p>This is to put a request to set up a project folder and its effortsheet. Please find the necessary details below:</p>
11+
12+
<ul>
13+
<li><strong>Project Name:</strong> {{ $project->name }}</li>
14+
<li><strong>Client Name:</strong> {{ $project->client->name ?? 'N/A' }}</li>
15+
<li><strong>Billing Type:</strong> {{ Str::of($project->type)->replace('-', ' ')->title() }}</li>
16+
<li><strong>Due Date:</strong> {{ now()->format('d M Y') }}</li>
17+
</ul>
18+
19+
<p>We've copied the key account manager in the email thread. Once processed, please share the link on this thread. If you come across any queries or need assistance with details, please drop an email here.</p>
20+
21+
<br>
22+
<p class="line">Best,</p>
23+
<p class="line">Portal Team</p>
24+
<p class="line">ColoredCow</p>
25+
</div>

Modules/Project/Resources/views/subviews/create-project-details.blade.php

+8-5
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
1+
12
<div id="create_project_details_form">
23
<div class="card-body">
34
<input type="hidden" name="create_project" value="create_project">
45
<div class="form-row">
56
<div class="form-group col-md-5">
67
<label for="name" class="field-required">Name</label>
78
<input type="text" class="form-control" name="name" id="name" placeholder="Enter project name"
8-
required="required" value="{{ old('name') }}">
9+
required="required" value="{{ old('name', $projectData['project_name'] ?? '') }}">
910
</div>
1011
<div class="form-group offset-md-1 col-md-5">
1112
<label for="client_id" class="field-required">Client</label>
1213
<select name="client_id" id="client_id" class="form-control" required="required">
1314
<option value="">Select client</option>
1415
@foreach ($clients as $client)
15-
<option value="{{ $client->id }}" {{ old('client_id') == $client->id ? 'selected' : '' }}>{{ $client->name }}</option>
16+
<option value="{{ $client->id }}" {{ old('client_id', $projectData['client_id'] ?? '') == $client->id ? 'selected' : '' }}>{{ $client->name }}</option>
1617
@endforeach
1718
</select>
1819
</div>
@@ -22,7 +23,7 @@
2223
<label for="status" class="field-required">Status</label>
2324
<select name="status" id="status" class="form-control" required="required">
2425
@foreach (config('project.status') as $key => $display_name)
25-
<option value="{{ $key }}" {{ old('status') == $key ? 'selected' : '' }}>{{ $display_name }}</option>
26+
<option value="{{ $key }}" {{ old('status', $projectData['status'] ?? '') == $key ? 'selected' : '' }}>{{ $display_name }}</option>
2627
@endforeach
2728
</select>
2829
</div>
@@ -82,19 +83,21 @@
8283
<div class="form-group offset-md-1 col-md-5">
8384
<input type="checkbox" id="isamc" name="is_amc" value="true">
8485
<label for="is_amc">AMC</label><br>
86+
<input type="checkbox" id="send_mail_to_infra" name="send_mail_to_infra" value="true">
87+
<label for="is_amc">Notify Infrasupport to Create Effortsheet</label><br>
8588
</div>
8689
</div>
8790
<br>
8891
<div class="form-row">
8992
<div class="form-group col-md-5" v-if="projectType !== 'non-billable'">
9093
<label for="total_estimated_hours">{{ __('Total Estimated Hours') }}</label>
9194
<input type="number" class="form-control" name="total_estimated_hours" id="total_estimated_hours"
92-
placeholder="Enter total estimated hours" value="{{ old('total_estimated_hours') }}">
95+
placeholder="Enter total estimated hours" value="{{ old('total_estimated_hours', $projectData['total_estimated_hours'] ?? '') }}">
9396
</div>
9497
</div>
9598
</div>
9699
<div class="card-footer">
97-
<button type="button" class="btn btn-primary mb-10" id="save-btn-action">Create</button>
100+
<button type="button" class="btn btn-primary" id="save-btn-action">Create</button>
98101
</div>
99102
</div>
100103

Modules/Project/Services/ProjectService.php

+17
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use Carbon\CarbonPeriod;
88
use Illuminate\Support\Arr;
99
use Illuminate\Support\Facades\Auth;
10+
use Illuminate\Support\Facades\Mail;
1011
use Illuminate\Support\Facades\Storage;
1112
use Maatwebsite\Excel\Facades\Excel;
1213
use Modules\Client\Entities\Client;
@@ -24,8 +25,11 @@
2425
use Modules\Project\Entities\ProjectTeamMember;
2526
use Modules\Project\Entities\ProjectTeamMembersEffort;
2627
use Modules\Project\Exports\ProjectFTEExport;
28+
use Modules\Project\Emails\EffortsheetSetupMail;
2729
use Modules\User\Entities\User;
2830

31+
32+
2933
class ProjectService implements ProjectServiceContract
3034
{
3135
public function index(array $data = [])
@@ -103,6 +107,19 @@ public function store($data)
103107
]
104108
);
105109
}
110+
111+
112+
113+
114+
if(isset($data['send_mail_to_infra']) && $data['send_mail_to_infra']) {
115+
// ToDo: Make infra email fetched from ENV
116+
$emails = [
117+
'key_account_manager' => $project->keyAccountManager->email,
118+
'infrasupport_email' => '[email protected]'
119+
];
120+
121+
Mail::send(new EffortsheetSetupMail($project, $emails));
122+
}
106123

107124
$project->client->update(['status' => 'active']);
108125
$this->saveOrUpdateProjectContract($data, $project);

Modules/Prospect/Http/Controllers/ProspectController.php

+21
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,19 @@ public function edit($id)
106106
public function update(Request $request, Prospect $prospect)
107107
{
108108
$data = $this->service->update($request, $prospect);
109+
if ($request->input('action') === 'update_create_project') {
110+
111+
$totalEstimatedHours = $this->getTotalEstimatedHoursForProject($prospect);
112+
$projectData = [
113+
'project_name' => $prospect->project_name,
114+
'client_id' => $prospect->client_id,
115+
'status' => 'active',
116+
'total_estimated_hours' => $totalEstimatedHours ?? null,
117+
118+
];
119+
120+
return redirect()->route('project.create')->with('projectData', $projectData);
121+
}
109122

110123
return $data;
111124
}
@@ -133,4 +146,12 @@ public function insightsUpdate(Request $request, $id)
133146

134147
return redirect()->route('prospect.show', $id)->with('status', 'Prospect Insights updated successfully!');
135148
}
149+
150+
public function getTotalEstimatedHoursForProject($prospectData)
151+
{
152+
$projectBudget = $prospectData->budget;
153+
$clientServiceRates = Client::find($prospectData->client_id)->billingDetails->service_rates;
154+
155+
return $projectBudget / $clientServiceRates;
156+
}
136157
}

Modules/Prospect/Http/Requests/ProspectRequest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public function rules()
2727
'proposal_link' => 'nullable|url',
2828
'currency' => 'nullable',
2929
'client_id' => 'nullable|exists:clients,id',
30-
'project_name' => 'nullable',
30+
'project_name' => 'required',
3131
];
3232
}
3333

Modules/Prospect/Resources/assets/js/app.js

+24
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,24 @@ const CUSTOMER_TYPES = {
33
EXISTING: "existing",
44
DORMANT: "dormant"
55
};
6+
7+
const PROPOSAL_STATUS = {
8+
PENDING: "pending",
9+
DISCUSSION_ONGOING: "discussions-ongoing",
10+
CONVERTED: "converted",
11+
REJECTED: "rejected",
12+
CLIENT_UNRESPONSIVE: "client-unresponsive",
13+
FINAL_DECISION_PENDING: "final-decision-pending"
14+
};
15+
616
document.addEventListener("DOMContentLoaded", function () {
717
const customerTypeField = document.getElementById("customer_type");
818
const orgNameTextField = document.getElementById("org_name_text_field");
919
const orgNameSelectField = document.getElementById("org_name_select_field");
1020
const orgNameTextInput = document.getElementById("org_name");
1121
const orgNameSelectInput = document.getElementById("org_name_select");
22+
const proposalStatus = document.getElementById("proposal_status");
23+
const updateAndCreateProjectButton = document.getElementById("update_create_project_button");
1224

1325
function toggleOrgNameField() {
1426
if (customerTypeField.value === CUSTOMER_TYPES.NEW) {
@@ -32,7 +44,19 @@ document.addEventListener("DOMContentLoaded", function () {
3244
}
3345
}
3446

47+
function toggleUpdateAndCreateProjectButton() {
48+
if(proposalStatus.value === PROPOSAL_STATUS.CONVERTED) {
49+
console.log("converted");
50+
updateAndCreateProjectButton.classList.remove("d-none");
51+
} else {
52+
console.log("not converted");
53+
updateAndCreateProjectButton.classList.add("d-none");
54+
}
55+
}
56+
3557
toggleOrgNameField();
58+
toggleUpdateAndCreateProjectButton();
3659

3760
customerTypeField.addEventListener("change", toggleOrgNameField);
61+
proposalStatus.addEventListener("change", toggleUpdateAndCreateProjectButton);
3862
});

Modules/Prospect/Resources/views/create.blade.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@
5656
</div>
5757

5858
<div class="form-group offset-md-1 col-md-5" id="org_name_text_field">
59-
<label for="project_name">Project Name</label>
60-
<input type="text" class="form-control" name="project_name" id="project_name"
59+
<label class="field-required" for="project_name">Project Name</label>
60+
<input type="text" required="required" class="form-control" name="project_name" id="project_name"
6161
placeholder="Enter Project Name" value="{{ old('project_name') }}">
6262
</div>
6363
</div>

Modules/Prospect/Resources/views/subviews/edit-prospect-details.blade.php

+4-3
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@
4949
</select>
5050
</div>
5151
<div class="form-group offset-md-1 col-md-5" id="org_name_text_field">
52-
<label for="project_name">Project Name</label>
53-
<input type="text" class="form-control" name="project_name" id="project_name"
52+
<label class="field-required" for="project_name">Project Name</label>
53+
<input type="text" class="form-control" required="required" name="project_name" id="project_name"
5454
placeholder="Enter Project Name" value="{{ $prospect->project_name }}">
5555
</div>
5656
</div>
@@ -122,7 +122,8 @@
122122
</div>
123123
</div>
124124
<div class="card-footer">
125-
<button type="submit" class="btn btn-primary">Update</button>
125+
<button type="submit" name="action" value="update" class="btn btn-primary">Update</button>
126+
<button type="submit" name="action" id="update_create_project_button" value="update_create_project" class="btn ml-3 d-none btn-primary">Update and Create Project</button>
126127
</div>
127128
</form>
128129
</div>

0 commit comments

Comments
 (0)