Added fairly trading org field and change org transactions to show

purchases not sales
This commit is contained in:
Tom Bloor 2018-01-02 19:57:12 +00:00
parent e29badb59d
commit 725bebb00b
4 changed files with 39 additions and 1 deletions

View file

@ -41,6 +41,7 @@ sub add_org_submit {
$validation->optional('postcode')->postcode;
$validation->optional('pending');
$validation->optional('is_local');
$validation->optional('is_fair');
if ( $validation->has_error ) {
$c->flash( error => 'The validation has failed' );
@ -60,6 +61,7 @@ sub add_org_submit {
submitted_by_id => $c->current_user->id,
pending => defined $validation->param('pending') ? 0 : 1,
is_local => $validation->param('is_local'),
is_fair => $validation->param('is_fair'),
},
type => 'organisation',
});
@ -78,7 +80,7 @@ sub add_org_submit {
sub valid_read {
my $c = shift;
my $valid_org = $c->schema->resultset('Organisation')->find( $c->param('id') );
my $transactions = $valid_org->entity->sales->search(
my $transactions = $valid_org->entity->purchases->search(
undef, {
page => $c->param('page') || 1,
rows => 10,
@ -109,6 +111,7 @@ sub valid_edit {
$validation->required('postcode')->postcode;
$validation->optional('pending');
$validation->optional('is_local');
$validation->optional('is_fair');
$validation->optional('is_lis');
$validation->optional('is_esta');
@ -129,6 +132,7 @@ sub valid_edit {
postcode => $validation->param('postcode'),
pending => defined $validation->param('pending') ? 0 : 1,
is_local => $validation->param('is_local'),
is_fair => $validation->param('is_fair'),
});
$valid_org->entity->update_or_create_related( 'associations', {
lis => $validation->param('is_lis'),

View file

@ -55,6 +55,24 @@
<input id="pending" type="checkbox" name="pending" value="0">
</div>
</div>
<div class="form-group row">
<label for="local" class="col-md-4 col-form-label">Is Local</label>
<div class="col-md-8">
<select id="local" class="form-control" name="is_local">
<option value="0"<%= !$valid_org->is_local ? '' : ' selected' %>>Non Local</option>
<option value="1"<%= $valid_org->is_local ? ' selected' : '' %>>Local</option>
</select>
</div>
</div>
<div class="form-group row">
<label for="local" class="col-md-4 col-form-label">Is Fairly Traded</label>
<div class="col-md-8">
<select id="local" class="form-control" name="is_fair">
<option value="0"<%= !$valid_org->is_fair ? '' : ' selected' %>>Non Fairly Traded</option>
<option value="1"<%= $valid_org->is_fair ? ' selected' : '' %>>Fairly Traded</option>
</select>
</div>
</div>
<div class="form-group row">
<div class="ml-auto col-sm-10">
<button class="btn btn-success" type="submit">Save Changes To Organisation</button>

View file

@ -38,6 +38,13 @@
% } else {
<span class="badge badge-secondary">Non Local Org</span>
% }
% if ( !defined $org_result->is_fair ) {
<span class="badge badge-danger">Fair Trading Status Not Set</span>
% } elsif ( $org_result->is_fair ) {
<span class="badge badge-success">Fairly Trading Org</span>
% } else {
<span class="badge badge-secondary">Non Fairly Trading Org</span>
% }
</div>
</a>
% }

View file

@ -126,6 +126,15 @@ function initMap() {
</select>
</div>
</div>
<div class="form-group row">
<label for="local" class="col-md-4 col-form-label">Is Fairly Traded</label>
<div class="col-md-8">
<select id="local" class="form-control" name="is_fair">
<option value="0"<%= !$valid_org->is_fair ? '' : ' selected' %>>Non Fairly Traded</option>
<option value="1"<%= $valid_org->is_fair ? ' selected' : '' %>>Fairly Traded</option>
</select>
</div>
</div>
<div class="form-group row">
<div class="ml-auto col-md-8">
<button class="btn btn-success btn-block" type="submit">Save Changes To Organisation</button>