Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Created migration for the project stages #3663

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions Modules/Project/Entities/ProjectStages.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

namespace Modules\Project\Entities;

use Illuminate\Database\Eloquent\Model;

class ProjectStages extends Model
{
protected $table = 'project_old_stages';
protected $guarded = [];
protected $fillables = ['project_id', 'stage_name', 'status', 'created_at', 'updated_at', 'comments'];

public function project()
{
return $this->belongsTo(Project::class, 'project_id', 'id');
}
}
14 changes: 14 additions & 0 deletions Modules/Project/Entities/ProjectStagesListing.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

namespace Modules\Project\Entities;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class ProjectStagesListing extends Model
{
use HasFactory;
protected $table = 'project_stages_listing';
protected $guarded = [];
protected $fillables = ['name', 'created_at', 'updated_at'];
}
23 changes: 22 additions & 1 deletion Modules/Project/Http/Controllers/ProjectController.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use Modules\Project\Entities\ProjectContract;
use Modules\Project\Http\Requests\ProjectRequest;
use Modules\Project\Rules\ProjectNameExist;
use Modules\Project\Entities\ProjectStages;

class ProjectController extends Controller
{
Expand Down Expand Up @@ -210,4 +211,24 @@ private function getContractData(Project $project)
'contractName' => $contractName,
];
}
}

public function addStage(Request $request)
{
$request->validate([
'project_id' => 'required|integer|exists:projects,id',
'stage_name' => 'required|string',
'comment' => 'nullable|string',
'status' => 'nullable|string',
]);

ProjectStages::create([
'project_id' => $request->project_id,
'stage_name' => $request->stage_name,
'comments' => $request->comment,
'status' => $request->status ?? 'pending',
]);

return response()->json(['success' => 'Stage added successfully!']);
}

}
152 changes: 152 additions & 0 deletions Modules/Project/Resources/assets/sass/app.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@

.checkbox-wrapper-19 {
box-sizing: border-box;
--background-color: #fff;
--checkbox-height: 15px;
}

@-moz-keyframes dothabottomcheck-19 {
0% {
height: 0;
}
100% {
height: calc(var(--checkbox-height) / 2);
}
}

@-webkit-keyframes dothabottomcheck-19 {
0% {
height: 0;
}
100% {
height: calc(var(--checkbox-height) / 2);
}
}

@keyframes dothabottomcheck-19 {
0% {
height: 0;
}
100% {
height: calc(var(--checkbox-height) / 2);
}
}

@keyframes dothatopcheck-19 {
0% {
height: 0;
}
50% {
height: 0;
}
100% {
height: calc(var(--checkbox-height) * 1.2);
}
}

@-webkit-keyframes dothatopcheck-19 {
0% {
height: 0;
}
50% {
height: 0;
}
100% {
height: calc(var(--checkbox-height) * 1.2);
}
}

@-moz-keyframes dothatopcheck-19 {
0% {
height: 0;
}
50% {
height: 0;
}
100% {
height: calc(var(--checkbox-height) * 1.2);
}
}

.checkbox-wrapper-19 input[type=checkbox] {
display: none;
}

.checkbox-wrapper-19 .check-box {
height: var(--checkbox-height);
width: var(--checkbox-height);
background-color: transparent;
border: calc(var(--checkbox-height) * .1) solid #000;
border-radius: 5px;
position: relative;
display: inline-block;
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
box-sizing: border-box;
-moz-transition: border-color ease 0.2s;
-o-transition: border-color ease 0.2s;
-webkit-transition: border-color ease 0.2s;
transition: border-color ease 0.2s;
cursor: pointer;
}
.checkbox-wrapper-19 .check-box::before,
.checkbox-wrapper-19 .check-box::after {
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
box-sizing: border-box;
position: absolute;
height: 0;
width: calc(var(--checkbox-height) * .2);
background-color: #34b93d;
display: inline-block;
-moz-transform-origin: left top;
-ms-transform-origin: left top;
-o-transform-origin: left top;
-webkit-transform-origin: left top;
transform-origin: left top;
border-radius: 5px;
content: " ";
-webkit-transition: opacity ease 0.5;
-moz-transition: opacity ease 0.5;
transition: opacity ease 0.5;
}
.checkbox-wrapper-19 .check-box::before {
top: calc(var(--checkbox-height) * .72);
left: calc(var(--checkbox-height) * .41);
box-shadow: 0 0 0 calc(var(--checkbox-height) * .05) var(--background-color);
-moz-transform: rotate(-135deg);
-ms-transform: rotate(-135deg);
-o-transform: rotate(-135deg);
-webkit-transform: rotate(-135deg);
transform: rotate(-135deg);
}
.checkbox-wrapper-19 .check-box::after {
top: calc(var(--checkbox-height) * .37);
left: calc(var(--checkbox-height) * .05);
-moz-transform: rotate(-45deg);
-ms-transform: rotate(-45deg);
-o-transform: rotate(-45deg);
-webkit-transform: rotate(-45deg);
transform: rotate(-45deg);
}

.checkbox-wrapper-19 input[type=checkbox]:checked + .check-box,
.checkbox-wrapper-19 .check-box.checked {
border-color: #34b93d;
}
.checkbox-wrapper-19 input[type=checkbox]:checked + .check-box::after,
.checkbox-wrapper-19 .check-box.checked::after {
height: calc(var(--checkbox-height) / 2);
-moz-animation: dothabottomcheck-19 0.2s ease 0s forwards;
-o-animation: dothabottomcheck-19 0.2s ease 0s forwards;
-webkit-animation: dothabottomcheck-19 0.2s ease 0s forwards;
animation: dothabottomcheck-19 0.2s ease 0s forwards;
}
.checkbox-wrapper-19 input[type=checkbox]:checked + .check-box::before,
.checkbox-wrapper-19 .check-box.checked::before {
height: calc(var(--checkbox-height) * 1.2);
-moz-animation: dothatopcheck-19 0.4s ease 0s forwards;
-o-animation: dothatopcheck-19 0.4s ease 0s forwards;
-webkit-animation: dothatopcheck-19 0.4s ease 0s forwards;
animation: dothatopcheck-19 0.4s ease 0s forwards;
}
1 change: 1 addition & 0 deletions Modules/Project/Resources/views/layouts/master.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@
@endsection

@section('css_scripts')
<link href="{{ mix('/css/project.css') }}" rel="stylesheet">
@endsection
98 changes: 98 additions & 0 deletions Modules/Project/Resources/views/project-stages.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
<div class="card-header d-flex mb-4" data-toggle="collapse" data-target="#project-stages" >
<h4>Project Stages</h4>
<span class ="arrow ml-auto">&#9660;</span>
</div>
<div class="collapse" id="project-stages">
<div>
<div class="fz-36" id="toggle-form">
<i class="fa fa-plus mr-1"></i>
Add
</div>
<form id="stage-form" method="POST" class="d-none">
@csrf
<div>
<label>
<span>Stage</span>
<input type="text" name="stage_name" required>
</label>
</div>
<div>
<label>
<span>Comment</span>
<input type="text" name="comment">
</label>
</div>
<div>
<div class="checkbox-wrapper-19">
<input type="checkbox" name="status" value="completed" id="cbtest-19" />
<label for="cbtest-19" class="check-box">
</label>
</div>
<div>
<input type="hidden" name="project_id" value="{{ $project->id }}">
</div>
<button type="submit">Add</button>
</form>
</div>

<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script>
$(document).ready(function() {
// Toggle form visibility when the + button is clicked
$('#toggle-form').on('click', function() {
$('#stage-form').toggleClass('d-none');
});

// Handle form submission
$('#stage-form').on('submit', function(e) {
e.preventDefault();

// Perform the first AJAX request to add the stage listing
const projectId = $('input[name="project_id"]').val();
const stageName = $('input[name="stage_name"]').val();
const comment = $('input[name="comment"]').val();
const status = $('input[name="status"]').is(':checked') ? 'completed' : 'pending';

// Perform the second AJAX request to add the project stage
$.ajax({
url: '{{ route('projects.add-stage') }}',
method: 'POST',
data: {
_token: '{{ csrf_token() }}',
project_id: projectId,
stage_name: stageName,
comment: comment,
status: status
},
success: function(response) {
alert('Stage added successfully!');
$('#stage-form').toggleClass('d-none'); // Hide the form after successful submission
},
error: function(xhr) {
alert('Error adding stage.');
}
});
});
});
</script>

<!-- <table class="table">
<thead>
<tr>
<th class="w-50p" scope="col">File</th>
<th scope="col">Start Date</th>
<th scope="col">End Date</th>
</tr>
</thead>
<tbody>
@foreach ($project->projectContracts as $contract)
<tr>
<td> <a href="{{ route('pdf.show', $contract->first()) }}"
target="_blank">{{ basename($contract->contract_file_path) }}</a></td>
<td>{{ optional($project->start_date)->format('d M Y') ?? '-' }}</td>
<td>{{ optional($project->end_date)->format('d M Y') ?? '-' }}</td>
</tr>
@endforeach
</tbody>
</table> -->
</div>
6 changes: 4 additions & 2 deletions Modules/Project/Resources/views/show.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@
</div>
<br>
@can('finance_reports.view')
<div class="card-header d-flex mb-4" data-toggle="collapse" data-target="#contract-history" >
<div class="card-header d-flex" data-toggle="collapse" data-target="#contract-history" >
<h4>Contract History</h4>
<span class ="arrow ml-auto">&#9660;</span>
</div>
Expand All @@ -320,7 +320,9 @@
</table>
</div>
<br>
<br>
@endcan
@include('project::project-stages');
<br>
<br>
@endsection

3 changes: 3 additions & 0 deletions Modules/Project/Routes/web.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,7 @@
Route::post('/project-fte-export', 'ProjectController@projectFTEExport')->name('project.fte.export');
Route::get('/project-resource', 'ProjectController@projectResource')->name('project.resource-requirement');
//Route::get('/', 'ProjectController@edit')->name('project.edit');

Route::post('/projects/add-stage-listing', 'ProjectController@addStageListing')->name('projects.add-stage-listing');
Route::post('/projects/add-stage', 'ProjectController@addStage')->name('projects.add-stage');
});
Loading
Loading