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

Update to 0.0.4 #15

Merged
merged 5 commits into from
Mar 9, 2016
Merged
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
82 changes: 65 additions & 17 deletions app/Http/Controllers/Syndie/ContractController.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,33 @@

use App\Models\SyndieContract;
use App\Models\SyndieContractComment;
use Yajra\Datatables\Datatables;

class ContractController extends Controller
{
public function index(Request $request)
{


return view('syndie.contract.index');
}

public function getContractData(Request $request)
{
// $forms = ServerForm::select(['form_id','id', 'name', 'department']);
$contracts = SyndieContract::select(['contract_id', 'title', 'contractee_name', 'status']);
//For contract mods: Show all contracts
if ($request->user()->can('contract_moderate')) {
$contracts = SyndieContract::all();

} else //For normal users: Show all contracts that have a status of open, assigned, completed, confirmed or that they own
{
$contracts = SyndieContract::whereIn('status', ['open', 'assigned', 'completed', 'confirmed'])->OrWhere('contractee_id', '=', $request->user()->user_id)->get();
$contracts->whereIn('status', ['open', 'assigned', 'completed', 'confirmed'])->OrWhere('contractee_id', '=', $request->user()->user_id)->get();
}

return view('syndie.contract.index', ['contracts' => $contracts]);
return Datatables::of($contracts)
->editColumn('title', '<b><a href="{{route(\'syndie.contracts.show\',[\'contract\'=>$contract_id])}}">{{$title}}</a></b>')
->editColumn('contractee_name', '<i>{{$contractee_name}}</i>')
->make();
}

public function getAdd()
Expand Down Expand Up @@ -93,7 +106,31 @@ public function show($contract)

public function getEdit(Request $request, $contract)
{
return "Edit: " . $contract;
$SyndieContract = SyndieContract::find($contract);

//Check if the user is the contract owner or a moderator
if ($request->user()->cannot('contract_moderate' && $request->user()->user_id != $SyndieContract->contractee_id)) {
abort(502,"You do not have the permission to edit the contract");
}

return view('syndie.contract.edit', ['contract' => $SyndieContract]);
}

public function postEdit(Request $request, $contract)
{
$SyndieContract = SyndieContract::find($contract);

//Check if the user is the contract owner or a moderator
if ($request->user()->cannot('contract_moderate' && $request->user()->user_id != $SyndieContract->contractee_id)) {
abort(502,"You do not have the permission to edit the contract");
}

$SyndieContract->title = $request->input('title');
$SyndieContract->description = $request->input('description');
$SyndieContract->save();

return redirect()->route('syndie.contracts.show',['contract'=>$SyndieContract->contract_id]);

}

public function approve(Request $request, $contract)
Expand All @@ -110,8 +147,10 @@ public function approve(Request $request, $contract)
$SystemComment->commentor_id = 0;
$SystemComment->commentor_name = "System";
$SystemComment->title = "Contract Approved";
$SystemComment->comment = "The contract has been approved by a contract moderator.
Contractors are now able to see it in the contract overview.";
$SystemComment->comment =
"The contract has been approved by a contract moderator.

Contractors are now able to see it in the contract overview.";
$SystemComment->type = 'ic';
$SystemComment->save();

Expand Down Expand Up @@ -141,8 +180,7 @@ public function confirm(Request $request, $comment)

$SyndieContract = SyndieContract::find($SyndieComment->contract_id);
//Check if contract is completed
if($SyndieContract->status !== "completed")
{
if ($SyndieContract->status !== "completed") {
return redirect()->route('syndie.contracts.show', ['contract' => $SyndieComment->contract_id])->withErrors(array('You can not confirm a contract as complented when no completion report has been posted'));
}

Expand All @@ -162,9 +200,12 @@ public function confirm(Request $request, $comment)
$SystemComment->commentor_id = 0;
$SystemComment->commentor_name = "System";
$SystemComment->title = "Contract Confirmed as Completed";
$SystemComment->comment = "The contractee has confirmed that the contract has been completed by the contractor.
The funds have been transfered to the contractor.
Thank you for choosing our Contract Service.";
$SystemComment->comment =
"The contractee has confirmed that the contract has been completed by the contractor.

The funds have been transfered to the contractor.

Thank you for choosing our Contract Service.";
$SystemComment->type = 'ic';
$SystemComment->save();

Expand All @@ -178,8 +219,7 @@ public function reopen(Request $request, $comment)
$SyndieContract = SyndieContract::find($SyndieComment->contract_id);

//Check if contract is completed
if($SyndieContract->status !== "completed")
{
if ($SyndieContract->status !== "completed") {
return redirect()->route('syndie.contracts.show', ['contract' => $SyndieComment->contract_id])->withErrors(array('You can not reopen a contract when no completion report has been posted'));
}

Expand All @@ -199,9 +239,12 @@ public function reopen(Request $request, $comment)
$SystemComment->commentor_id = 0;
$SystemComment->commentor_name = "System";
$SystemComment->title = "Contract Reopened";
$SystemComment->comment = "The contractee has rejected the completion report.
The contract has been reopened.
The contractee is expected to provide a explanation, why the completion report is not satisfying";
$SystemComment->comment =
"The contractee has rejected the completion report.

The contract has been reopened.

The contractee is expected to provide a explanation, why the completion report is not satisfying";
$SystemComment->type = 'ic';
$SystemComment->save();
}
Expand Down Expand Up @@ -234,7 +277,7 @@ public function addMessage($contract, Request $request)
//User can not specify a name and can use only the following message types: 'ic'=>'IC Comment','ooc' => 'OOC Comment','mod-author'=>'MOD-Author PM'
$commentor_name = $SyndieContract->contractee_name;

$useable = array('ic', 'ic-cancel','ooc', 'mod-author');
$useable = array('ic', 'ic-cancel', 'ooc', 'mod-author');
if (!in_array($type, $useable)) {
return redirect()->route('syndie.contracts.show', ['contract' => $contract])->withErrors(array('You are not authorized to use this message type'));
}
Expand All @@ -246,6 +289,11 @@ public function addMessage($contract, Request $request)
}
}

//Check if the message type is ooc or mod-author or mod-ooc, then set the author name to the users form username
if (in_array($type, array('ooc', 'mod-author', 'mod-ooc'))) {
$commentor_name = $request->user()->username;
}

// Post the comment
$SyndieContractComment = new SyndieContractComment();
$SyndieContractComment->contract_id = $SyndieContract->contract_id;
Expand Down
5 changes: 3 additions & 2 deletions app/Http/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,14 @@
route::post('/add', ['as' => 'syndie.contracts.add.post', 'uses'=>'Syndie\ContractController@postAdd']);
Route::get('/{contract}/show', ['as' => 'syndie.contracts.show', 'uses'=>'Syndie\ContractController@show']);
Route::get('/{contract}/edit', ['as' => 'syndie.contracts.edit.get', 'uses'=>'Syndie\ContractController@getEdit']);
Route::post('/{contract}/edit', ['as' => 'syndie.contracts.edit.post', 'uses'=>'Syndie\ContractController@postEdit']);
Route::get('/{contract}/approve', ['as' => 'syndie.contracts.approve', 'uses'=>'Syndie\ContractController@approve']); //Mod Approve the contract
Route::get('/{contract}/reject', ['as' => 'syndie.contracts.reject', 'uses'=>'Syndie\ContractController@reject']); //Mod Reject the contract
Route::post('/{contract}/addmessage',['as' => 'syndie.contracts.addmessage', 'uses'=>'Syndie\ContractController@addMessage']); //Add message to contract
Route::get('/{comment}/confirm', ['as' => 'syndie.contracts.confirm', 'uses'=>'Syndie\ContractController@confirm']); //Confirm Completion of the Contract
Route::get('/{comment}/reopen', ['as' => 'syndie.contracts.reopen', 'uses'=>'Syndie\ContractController@reopen']); // Reopen the contract
Route::get('/{comment}/reopen', ['as' => 'syndie.contracts.reopen', 'uses'=>'Syndie\ContractController@reopen']); // Reopen the contract
Route::get('/{comment}/delete',['as' => 'syndie.contracts.delete', 'uses'=>'Syndie\ContractController@deleteMessage']); //Delete a comment
Route::get('/{comment}/delete',['as' => 'syndie.contracts.deletemessage', 'uses'=>'Syndie\ContractController@deleteMessage']); //Delete a comment
Route::get('/data',['as' => 'syndie.contracts.data', 'uses'=>'Syndie\ContractController@getContractData']);
});
});

Expand Down
4 changes: 2 additions & 2 deletions resources/views/admin/form/index.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

<div class="panel-body">
@can('admin_forms_edit')<p><a href="{{route('admin.form.add.post')}}" class="btn btn-info" role="button">Add new Form</a></p>@endcan()
<table id="users-table" class="table table-condensed">
<table id="forms-table" class="table table-condensed">
<thead>
<tr>
<th>ID</th>
Expand All @@ -51,7 +51,7 @@
<script src="{{ asset('/assets/js/datatables.bootstrap.js') }}"></script>
<script>
$(function() {
$('#users-table').DataTable({
$('#forms-table').DataTable({
processing: true,
serverSide: true,
ajax: '{{ route('admin.form.data') }}'
Expand Down
4 changes: 2 additions & 2 deletions resources/views/layouts/app.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@

<!-- Branding Image -->
<a class="navbar-brand" href="{{ url('/') }}">
Aurora Webinterface
Aurora WI
</a>
</div>

Expand Down Expand Up @@ -147,7 +147,7 @@

<footer>
<div class="footer navbar-fixed-bottom">
<small><p class="text-muted">Aurora Webinterface &copy; 2016 by Werner Maisl - Licensed under the AGPL - Version 0.0.3</p></small>
<small><p class="text-muted">Aurora Webinterface &copy; 2016 by Werner Maisl - Licensed under the AGPL - Version 0.0.4</p></small>
</div>
</footer>

Expand Down
4 changes: 4 additions & 0 deletions resources/views/syndie/contract/add.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@


<div class="panel-body">
<div class="alert alert-success">
<a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a>
You can use Markdown to in the description field
</div>
{{ Form::open(array('route' => 'syndie.contracts.add.post','method' => 'post')) }}

{{Form::token()}}
Expand Down
42 changes: 42 additions & 0 deletions resources/views/syndie/contract/edit.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{{--Copyright (c) 2016 "Werner Maisl"--}}

{{--This file is part of the Aurora Webinterface--}}

{{--The Aurora Webinterface is free software: you can redistribute it and/or modify--}}
{{--it under the terms of the GNU Affero General Public License as--}}
{{--published by the Free Software Foundation, either version 3 of the--}}
{{--License, or (at your option) any later version.--}}

{{--This program is distributed in the hope that it will be useful,--}}
{{--but WITHOUT ANY WARRANTY; without even the implied warranty of--}}
{{--MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the--}}
{{--GNU Affero General Public License for more details.--}}

{{--You should have received a copy of the GNU Affero General Public License--}}
{{--along with this program. If not, see <http://www.gnu.org/licenses/>.<!DOCTYPE html>--}}

@extends('layouts.app')

@section('content')
<div class="container">
<div class="row">
<div class="col-md-10 col-md-offset-1">
<div class="panel panel-default">
<div class="panel-heading">Edit Contract: <b>{{$contract->title}}</b></div>

<div class="panel-body">
{{Form::model($contract, array('route' => array('syndie.contracts.edit.post', $contract->contract_id),'method' => 'post')) }}
{{Form::token()}}

{{Form::bsText('title')}}
{{Form::bsTextArea('description')}}

{{Form::submit('Submit', array('class'=>'btn btn-default'))}}

{{ Form::close() }}
</div>
</div>
</div>
</div>
</div>
@endsection
42 changes: 25 additions & 17 deletions resources/views/syndie/contract/index.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@

@extends('layouts.app')

@section('styles')
<link href="{{ asset('/assets/css/datatables.bootstrap.css') }}" rel="stylesheet">
@endsection

@section('content')
<div class="container">
<div class="row">
Expand All @@ -25,29 +29,33 @@
<div class="panel-heading">Contract Overview</div>

<div class="panel-body">
<table class="table table-striped">
<table id="contract-table" class="table table-condensed">
<thead>
<tr>
<th>#</th>
<th>Title</th>
<th>Contractee Name</th>
<th>Status</th>
</tr>
<tr>
<th>#</th>
<th>Title</th>
<th>Contractee Name</th>
<th>Status</th>
</tr>
</thead>
<tbody>
@foreach($contracts as $contract)
<tr>
<td width="10px">{{$contract->contract_id}}</td>
<td><a href="{{route('syndie.contracts.show',['contract'=>$contract->contract_id])}}"><b>{{$contract->title}}</b></a></td>
<td><i>{{$contract->contractee_name}}</i></td>
<td>@include("components.syndiecontractstatus")</td>
</tr>
@endforeach
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
@endsection

@section('javascripts')
<script src="{{ asset('/assets/js/jquery.dataTables.min.js') }}"></script>
<script src="{{ asset('/assets/js/datatables.bootstrap.js') }}"></script>
<script>
$(function() {
$('#contract-table').DataTable({
processing: true,
serverSide: true,
ajax: '{{ route('syndie.contracts.data') }}'
});
});
</script>
@endsection
Loading