-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
64a0ac1
commit 28999c3
Showing
13 changed files
with
1,725 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
package SL::Controller::POS; | ||
|
||
use strict; | ||
use parent qw(SL::Controller::Base); | ||
|
||
use SL::Controller::Order; | ||
|
||
use SL::Model::Record; | ||
use SL::DB::ValidityToken; | ||
use SL::DB::Order::TypeData qw(:types); | ||
|
||
use SL::Locale::String qw(t8); | ||
|
||
use Rose::Object::MakeMethods::Generic | ||
( | ||
'scalar --get_set_init' => [ qw( | ||
order_controller order | ||
) ] | ||
); | ||
|
||
# add a new point of sales order | ||
# it's a sales order with a diffrent form | ||
sub action_add { | ||
my ($self) = @_; | ||
$::form->{type} = SALES_ORDER_TYPE(); | ||
|
||
$self->order(SL::Model::Record->update_after_new($self->order)); | ||
|
||
$self->order_controller->pre_render(); | ||
$self->pre_render(); | ||
|
||
if (!$::form->{form_validity_token}) { | ||
$::form->{form_validity_token} = SL::DB::ValidityToken->create(scope => SL::DB::ValidityToken::SCOPE_ORDER_SAVE())->token; | ||
} | ||
|
||
$self->render( | ||
'pos/form', | ||
title => t8('Point of Sales'), | ||
%{$self->{template_args}} | ||
); | ||
} | ||
|
||
sub action_edit_order_item_row_point_of_sales_dialog { | ||
my ($self) = @_; | ||
|
||
my $item; | ||
my $temp_item_id = $::form->{item_id}; | ||
foreach my $idx (0 .. (scalar @{$::form->{orderitem_ids}} - 1)) { | ||
if ($::form->{orderitem_ids}->[$idx] eq $temp_item_id) { | ||
$item = $self->order->items->[$idx]; | ||
last; | ||
} | ||
} | ||
die "cound not find item with item with id $temp_item_id" unless $item; | ||
|
||
$self->render( | ||
'pos/_edit_order_item_row_point_of_sales_dialog', { layout => 0 }, | ||
popup_dialog => 1, | ||
popup_js_delete_row_function => "kivi.POS.delete_order_item_row_point_of_sales('$temp_item_id')", | ||
popup_js_close_function => '$("#edit_order_item_row_point_of_sales_dialog").dialog("close")', | ||
popup_js_assign_function => "kivi.POS.assign_edit_order_item_row_point_of_sales('$temp_item_id')", | ||
ITEM => $item | ||
); | ||
} | ||
|
||
# | ||
# helpers | ||
# | ||
|
||
sub pre_render { | ||
my ($self) = @_; | ||
|
||
$::request->{layout}->use_javascript("${_}.js") for qw( | ||
kivi.POS | ||
); | ||
|
||
# remove actionbar from order_controller | ||
for my $bar ($::request->layout->get('actionbar')) { | ||
$bar->actions([]); | ||
} | ||
} | ||
|
||
sub order { | ||
my $self = shift @_; | ||
$self->order_controller->order(@_); | ||
} | ||
|
||
# | ||
# intits | ||
# | ||
|
||
sub init_order_controller { | ||
my ($self) = @_; | ||
SL::Controller::Order->new(); | ||
} | ||
|
||
1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/* ------------------------------------------------------------- */ | ||
/* POS (pos.less) */ | ||
/* ------------------------------------------------------------- */ | ||
|
||
|
||
|
||
// ------------------------------------------------------------ | ||
// General page layout | ||
// ------------------------------------------------------------ | ||
|
||
.pos_wrapper{ | ||
border: solid blue; | ||
position: relative; | ||
height: 85vh; | ||
} | ||
|
||
// pos_content | ||
|
||
.pos_content{ | ||
margin-right: 600px; | ||
border: thin solid red; | ||
} | ||
|
||
// left_content | ||
|
||
.left_input{ | ||
float:left; | ||
padding-right: 3em; | ||
} | ||
|
||
// buttons | ||
|
||
.buttons{ | ||
position: absolute; | ||
right: 0px; | ||
top: 0px; | ||
|
||
width: 600px; | ||
border: thin solid green; | ||
} | ||
|
||
.container_pos_left{ | ||
display: grid; | ||
grid-template-columns: 1fr 1fr; | ||
column-gap: 10px; | ||
row-gap: 15px; | ||
} | ||
|
||
.pos_button{ | ||
height: 50px; | ||
border: solid green !important; | ||
text-align: center; | ||
line-height: 50px; | ||
padding: 0 !important; | ||
display: inline-block; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
namespace('kivi.POS', function(ns) { | ||
ns.delete_order_item_row_point_of_sales = function(item_id) { | ||
var row = $('#item_' + item_id).parents("tbody").first(); | ||
$(row).remove(); | ||
|
||
$('#edit_order_item_row_point_of_sales_dialog').dialog('close'); | ||
kivi.Order.renumber_positions(); | ||
kivi.Order.recalc_amounts_and_taxes(); | ||
}; | ||
|
||
|
||
ns.edit_order_item_row_point_of_sales = function(item_id) { | ||
|
||
var data = $('#order_form').serializeArray(); | ||
data.push({ name: 'item_id', value: item_id }); | ||
|
||
kivi.popup_dialog({ | ||
url: 'controller.pl?action=POS/edit_order_item_row_point_of_sales_dialog', | ||
data: data, | ||
id: 'edit_order_item_row_point_of_sales_dialog', | ||
load: function() {kivi.reinit_widgets(); kivi.Order.init_row_handlers() }, | ||
dialog: { | ||
title: kivi.t8('Edit row'), | ||
width: 800, | ||
height: 650 | ||
} | ||
}); | ||
}; | ||
|
||
ns.assign_edit_order_item_row_point_of_sales = function(item_id) { | ||
var row = $('#item_' + item_id).parents("tbody").first(); | ||
|
||
var discount = $('#item_discount_as_percent').val(); | ||
$(row).find('[name="discount_as_percent"]').html(discount); | ||
$(row).find('[name="order.orderitems[].discount_as_percent"]').val(discount); | ||
|
||
// TODO | ||
// var salesman_id = 0; | ||
// $(row).find('[name="order.orderitems[].salesman_id"]'); | ||
|
||
|
||
$('#edit_order_item_row_point_of_sales_dialog').dialog('close'); | ||
kivi.Order.recalc_amounts_and_taxes(); | ||
} | ||
|
||
}); |
Oops, something went wrong.