Allow fulfilled job orders to be cancelled #103

This commit is contained in:
Kendrick Chan 2018-04-24 23:57:45 +08:00
parent 23dbe7552c
commit aea22c7e11
3 changed files with 9 additions and 1 deletions

View file

@ -153,6 +153,7 @@ class JobOrderController extends BaseController
'set_map_coordinate' => true, 'set_map_coordinate' => true,
'preset_vehicle' => false, 'preset_vehicle' => false,
'ticket_table' => true, 'ticket_table' => true,
'cancel_button' => true,
]; ];
} }
@ -167,12 +168,14 @@ class JobOrderController extends BaseController
$params['ftags']['set_map_coordinate'] = false; $params['ftags']['set_map_coordinate'] = false;
$params['ftags']['invoice_edit'] = true; $params['ftags']['invoice_edit'] = true;
$params['ftags']['ticket_table'] = false; $params['ftags']['ticket_table'] = false;
$params['ftags']['cancel_button'] = false;
break; break;
case 'create_vehicle': case 'create_vehicle':
$params['ftags']['set_map_coordinate'] = false; $params['ftags']['set_map_coordinate'] = false;
$params['ftags']['invoice_edit'] = true; $params['ftags']['invoice_edit'] = true;
$params['ftags']['preset_vehicle'] = true; $params['ftags']['preset_vehicle'] = true;
$params['ftags']['ticket_table'] = false; $params['ftags']['ticket_table'] = false;
$params['ftags']['cancel_button'] = false;
break; break;
case 'open_edit': case 'open_edit':
$params['ftags']['invoice_edit'] = true; $params['ftags']['invoice_edit'] = true;

View file

@ -613,4 +613,9 @@ class JobOrder
{ {
return !$this->isClosed(); return !$this->isClosed();
} }
public function isCancelled()
{
return $this->status == JOStatus::CANCELLED;
}
} }

View file

@ -779,7 +779,7 @@
{% if mode != 'update-all' %} {% if mode != 'update-all' %}
<button type="submit" class="btn btn-success">{{ mode == 'update-fulfillment' ? 'Fulfill' : 'Submit' }}</button> <button type="submit" class="btn btn-success">{{ mode == 'update-fulfillment' ? 'Fulfill' : 'Submit' }}</button>
{% endif %} {% endif %}
{% if mode != 'create' and mode != 'create_vehicle' and is_granted('joborder.cancel') and obj.isOpen %} {% if ftags.set_map_coordinate and is_granted('joborder.cancel') and not obj.isCancelled %}
<a href="{{ url('jo_cancel', {'id': obj.getID}) }}" class="btn btn-danger btn-cancel-job-order">Cancel Job Order</button> <a href="{{ url('jo_cancel', {'id': obj.getID}) }}" class="btn btn-danger btn-cancel-job-order">Cancel Job Order</button>
{% endif %} {% endif %}
{% if mode != 'create' %} {% if mode != 'create' %}