Add unlock processor and assignor feature for job order #14

This commit is contained in:
Kendrick Chan 2018-02-27 06:21:43 +08:00
parent 84b57d82d6
commit 6cd6fccb8c
7 changed files with 65 additions and 3 deletions

View file

@ -187,8 +187,12 @@ access_keys:
label: Incoming
- id: jo_proc.list
label: Processing
- id: jo_proc.unlock
label: Processing Unlock
- id: jo_assign.list
label: Assigning
- id: jo_assign.unlock
label: Assigning Unlock
- id: jo_fulfill.list
label: Fulfillment

View file

@ -84,4 +84,14 @@ jo_fulfill_submit:
jo_search:
path: /job-order/search
controller: App\Controller\JobOrderController::getJobOrders
methods: [GET]
methods: [GET]
jo_proc_unlock:
path: /job-order/{id}/unlock/processor
controller: App\Controller\JobOrderController::unlockProcessor
methods: [GET]
jo_assign_unlock:
path: /job-order/{id}/unlock/assignor
controller: App\Controller\JobOrderController::unlockAssignor
methods: [GET]

View file

@ -278,6 +278,7 @@ class JobOrderController extends BaseController
$tier_name = 'Processing';
$rows_route = 'jo_proc_rows';
$edit_route = 'jo_proc_form';
$unlock_route = 'jo_proc_unlock';
$jo_status = JOStatus::PENDING;
break;
case 'assign':
@ -285,6 +286,7 @@ class JobOrderController extends BaseController
$tier_name = 'Assigning';
$rows_route = 'jo_assign_rows';
$edit_route = 'jo_assign_form';
$unlock_route = 'jo_assign_unlock';
$jo_status = JOStatus::RIDER_ASSIGN;
break;
case 'fulfill':
@ -311,6 +313,7 @@ class JobOrderController extends BaseController
'name' => $tier_name,
'rows_route' => $rows_route,
'edit_route' => $edit_route,
'unlock_route' => $unlock_route,
'jo_status' => $jo_status
];
}
@ -436,6 +439,7 @@ class JobOrderController extends BaseController
// add crud urls
$row['meta']['update_url'] = $this->generateUrl($tier_params['edit_route'], ['id' => $row['id']]);
$row['meta']['unlock_url'] = $this->generateUrl($tier_params['unlock_route'], ['id' => $row['id']]);
$rows[] = $row;
}
@ -1094,4 +1098,39 @@ class JobOrderController extends BaseController
'invoice' => $invoice
]);
}
public function unlockProcessor($id)
{
$this->denyAccessUnlessGranted('jo_proc.unlock', null, 'No access.');
// clear lock
$em = $this->getDoctrine()->getManager();
$jo = $em->getRepository(JobOrder::class)->find($id);
if ($jo == null)
return $this->redirectToRoute('jo_proc');
$jo->setProcessedBy(null);
$em->flush();
// redirect to list
return $this->redirectToRoute('jo_proc');
}
public function unlockAssignor($id)
{
$this->denyAccessUnlessGranted('jo_assign.unlock', null, 'No access.');
// clear lock
$em = $this->getDoctrine()->getManager();
$jo = $em->getRepository(JobOrder::class)->find($id);
if ($jo == null)
return $this->redirectToRoute('jo_assign');
$jo->setAssignedBy(null);
$em->flush();
// redirect to list
return $this->redirectToRoute('jo_assign');
}
}

View file

@ -288,7 +288,7 @@ class JobOrder
return $this->created_by;
}
public function setAssignedBy(User $assigned_by)
public function setAssignedBy(User $assigned_by = null)
{
$this->assigned_by = $assigned_by;
return $this;
@ -299,7 +299,7 @@ class JobOrder
return $this->assigned_by;
}
public function setProcessedBy(User $user)
public function setProcessedBy(User $user = null)
{
$this->processed_by = $user;
return $this;

View file

@ -109,6 +109,10 @@
overflow: 'visible',
template: function (row, index, datatable) {
var actions = '<a href="' + row.meta.update_url + '" class="m-portlet__nav-link btn m-btn m-btn--hover-accent m-btn--icon m-btn--icon-only m-btn--pill btn-edit" title="View / Edit"><i class="la la-edit"></i></a>';
{% if is_granted('jo_assign.unlock') %}
actions += '<a href="' + row.meta.unlock_url + '" class="m-portlet__nav-link btn m-btn m-btn--hover-accent m-btn--icon m-btn--icon-only m-btn--pill btn-edit" title="Unlock"><i class="fa fa-unlock"></i></a>';
{% endif %}
return actions;
},

View file

@ -105,6 +105,10 @@
overflow: 'visible',
template: function (row, index, datatable) {
var actions = '<a href="' + row.meta.update_url + '" class="m-portlet__nav-link btn m-btn m-btn--hover-accent m-btn--icon m-btn--icon-only m-btn--pill btn-edit" title="View / Edit"><i class="la la-edit"></i></a>';
{% if is_granted('jo_proc.unlock') %}
actions += '<a href="' + row.meta.unlock_url + '" class="m-portlet__nav-link btn m-btn m-btn--hover-accent m-btn--icon m-btn--icon-only m-btn--pill btn-edit" title="Unlock"><i class="fa fa-unlock"></i></a>';
{% endif %}
return actions;
},

View file

@ -105,6 +105,7 @@
overflow: 'visible',
template: function (row, index, datatable) {
var actions = '<a href="' + row.meta.update_url + '" class="m-portlet__nav-link btn m-btn m-btn--hover-accent m-btn--icon m-btn--icon-only m-btn--pill btn-edit" title="View / Edit"><i class="la la-edit"></i></a>';
actions += '<a href="' + row.meta.unlock_url + '" class="m-portlet__nav-link btn m-btn m-btn--hover-accent m-btn--icon m-btn--icon-only m-btn--pill btn-edit" title="View / Edit"><i class="la la-edit"></i></a>';
return actions;
},