diff --git a/boxoffice/extapi/__init__.py b/boxoffice/extapi/__init__.py index 0b12fe22..5b70eaaf 100644 --- a/boxoffice/extapi/__init__.py +++ b/boxoffice/extapi/__init__.py @@ -1,3 +1,4 @@ # -*- coding: utf-8 -*- from .razorpay import * +from .razorpay_status import * diff --git a/boxoffice/extapi/razorpay.py b/boxoffice/extapi/razorpay.py index d7da02e4..88523585 100644 --- a/boxoffice/extapi/razorpay.py +++ b/boxoffice/extapi/razorpay.py @@ -1,27 +1,12 @@ # -*- coding: utf-8 -*- import requests -from coaster.utils import LabeledEnum -from baseframe import __ +from baseframe import __, localize_timezone from boxoffice import app +from boxoffice.models import OnlinePayment, PaymentTransaction, TRANSACTION_TYPE # Don't use a trailing slash -base_url = 'https://api.razorpay.com/v1/payments' - -__all__ = ['RAZORPAY_PAYMENT_STATUS', 'capture_payment'] - - -class RAZORPAY_PAYMENT_STATUS(LabeledEnum): - """ - Reflects payment statuses as specified in - https://docs.razorpay.com/docs/return-objects - """ - CREATED = (0, __("Created")) - AUTHORIZED = (1, __("Authorized")) - CAPTURED = (2, __("Captured")) - #: Only fully refunded payments. - REFUNDED = (3, __("Refunded")) - FAILED = (4, __("Failed")) +base_url = 'https://api.razorpay.com/v1' def capture_payment(paymentid, amount): @@ -29,7 +14,7 @@ def capture_payment(paymentid, amount): Attempts to capture the payment, from Razorpay """ verify_https = False if app.config.get('VERIFY_RAZORPAY_HTTPS') is False else True - url = '{base_url}/{paymentid}/capture'.format(base_url=base_url, paymentid=paymentid) + url = '{base_url}/payments/{paymentid}/capture'.format(base_url=base_url, paymentid=paymentid) # Razorpay requires the amount to be in paisa and of type integer resp = requests.post(url, data={'amount': int(amount * 100)}, auth=(app.config['RAZORPAY_KEY_ID'], app.config['RAZORPAY_KEY_SECRET']), verify=verify_https) @@ -40,7 +25,91 @@ def refund_payment(paymentid, amount): """ Sends a POST request to Razorpay, to initiate a refund """ - url = '{base_url}/{paymentid}/refund'.format(base_url=base_url, paymentid=paymentid) + url = '{base_url}/payments/{paymentid}/refund'.format(base_url=base_url, paymentid=paymentid) # Razorpay requires the amount to be in paisa and of type integer resp = requests.post(url, data={'amount': int(amount * 100)}, auth=(app.config['RAZORPAY_KEY_ID'], app.config['RAZORPAY_KEY_SECRET'])) return resp + +def get_settlements(date_range): + url = '{base_url}/settlements/report/combined'.format(base_url=base_url) + resp = requests.get(url, + params={'year': date_range['year'], 'month': date_range['month']}, + auth=(app.config['RAZORPAY_KEY_ID'], app.config['RAZORPAY_KEY_SECRET'])) + return resp.json() + +def get_settled_transactions(date_range, tz=None): + if not tz: + tz = app.config['TIMEZONE'] + settled_transactions = get_settlements(date_range) + headers = ['settlement_id', 'transaction_type', 'order_id', 'payment_id', 'refund_id', + 'item_collection', 'description', 'base_amount', 'discounted_amount', + 'final_amount', 'order_paid_amount', 'transaction_date', 'settled_at', + 'razorpay_fees', 'order_amount', 'credit', 'debit', + 'receivable_amount', 'settlement_amount', 'buyer_fullname'] + # Nested list of dictionaries consisting of transaction details + rows = [] + external_transaction_msg = u"Transaction external to Boxoffice. Credited directly to Razorpay?" + + for settled_transaction in settled_transactions: + if settled_transaction['type'] == 'settlement': + rows.append({ + 'settlement_id': settled_transaction['entity_id'], + 'settlement_amount': settled_transaction['amount'], + 'settled_at': settled_transaction['settled_at'], + 'transaction_type': settled_transaction['type'] + }) + elif settled_transaction['type'] == 'payment': + payment = OnlinePayment.query.filter_by(pg_paymentid=settled_transaction['entity_id']).one_or_none() + if payment: + order = payment.order + rows.append({ + 'settlement_id': settled_transaction['settlement_id'], + 'transaction_type': settled_transaction['type'], + 'order_id': order.id, + 'payment_id': settled_transaction['entity_id'], + 'razorpay_fees': settled_transaction['fee'], + 'transaction_date': localize_timezone(order.paid_at, tz), + 'credit': settled_transaction['credit'], + 'buyer_fullname': order.buyer_fullname, + 'item_collection': order.item_collection.title + }) + for line_item in order.initial_line_items: + rows.append({ + 'settlement_id': settled_transaction['settlement_id'], + 'payment_id': settled_transaction['entity_id'], + 'order_id': order.id, + 'item_collection': order.item_collection.title, + 'description': line_item.item.title, + 'base_amount': line_item.base_amount, + 'discounted_amount': line_item.discounted_amount, + 'final_amount': line_item.final_amount + }) + else: + # Transaction outside of Boxoffice + rows.append({ + 'settlement_id': settled_transaction['settlement_id'], + 'payment_id': settled_transaction['entity_id'], + 'credit': settled_transaction['credit'], + 'description': external_transaction_msg + }) + elif settled_transaction['type'] == 'refund': + payment = OnlinePayment.query.filter_by(pg_paymentid=settled_transaction['payment_id']).one() + refund = PaymentTransaction.query.filter(PaymentTransaction.online_payment == payment, + PaymentTransaction.transaction_type == TRANSACTION_TYPE.REFUND, + PaymentTransaction.pg_refundid == settled_transaction['entity_id'] + ).one() + order = refund.order + rows.append({ + 'settlement_id': settled_transaction['settlement_id'], + 'refund_id': settled_transaction['entity_id'], + 'payment_id': settled_transaction['payment_id'], + 'transaction_type': settled_transaction['type'], + 'order_id': order.id, + 'razorpay_fees': settled_transaction['fee'], + 'debit': settled_transaction['debit'], + 'buyer_fullname': order.buyer_fullname, + 'description': refund.refund_description, + 'amount': refund.amount, + 'item_collection': order.item_collection.title + }) + return (headers, rows) diff --git a/boxoffice/extapi/razorpay_status.py b/boxoffice/extapi/razorpay_status.py new file mode 100644 index 00000000..fb2cb7ad --- /dev/null +++ b/boxoffice/extapi/razorpay_status.py @@ -0,0 +1,18 @@ +# -*- coding: utf-8 -*- + +from baseframe import __ +from coaster.utils import LabeledEnum + +__all__ = ['RAZORPAY_PAYMENT_STATUS'] + +class RAZORPAY_PAYMENT_STATUS(LabeledEnum): + """ + Reflects payment statuses as specified in + https://docs.razorpay.com/docs/return-objects + """ + CREATED = (0, __("Created")) + AUTHORIZED = (1, __("Authorized")) + CAPTURED = (2, __("Captured")) + #: Only fully refunded payments. + REFUNDED = (3, __("Refunded")) + FAILED = (4, __("Failed")) diff --git a/boxoffice/models/line_item.py b/boxoffice/models/line_item.py index 6bce0003..313592e8 100644 --- a/boxoffice/models/line_item.py +++ b/boxoffice/models/line_item.py @@ -21,7 +21,7 @@ class LINE_ITEM_STATUS(LabeledEnum): #: A line item can be made void by the system to invalidate #: a line item. Eg: a discount no longer applicable on a line item as a result of a cancellation VOID = (3, __("Void")) - + TRANSACTION = {CONFIRMED, VOID, CANCELLED} LineItemTuple = namedtuple('LineItemTuple', ['item_id', 'id', 'base_amount', 'discount_policy_id', 'discount_coupon_id', 'discounted_amount', 'final_amount']) @@ -66,7 +66,8 @@ class LineItem(BaseMixin, db.Model): """ __tablename__ = 'line_item' __uuid_primary_key__ = True - __table_args__ = (db.UniqueConstraint('customer_order_id', 'line_item_seq'),) + __table_args__ = (db.UniqueConstraint('customer_order_id', 'line_item_seq'), + db.UniqueConstraint('previous_id')) # line_item_seq is the relative number of the line item per order. line_item_seq = db.Column(db.Integer, nullable=False) @@ -78,6 +79,12 @@ class LineItem(BaseMixin, db.Model): item_id = db.Column(None, db.ForeignKey('item.id'), nullable=False, index=True, unique=False) item = db.relationship(Item, backref=db.backref('line_items', cascade='all, delete-orphan')) + previous_id = db.Column(None, db.ForeignKey('line_item.id'), nullable=True, index=True, unique=True) + previous = db.relationship('LineItem', + primaryjoin='line_item.c.id==line_item.c.previous_id', + backref=db.backref('revision', uselist=False), + remote_side='LineItem.id') + discount_policy_id = db.Column(None, db.ForeignKey('discount_policy.id'), nullable=True, index=True, unique=False) discount_policy = db.relationship('DiscountPolicy', backref=db.backref('line_items')) @@ -325,6 +332,11 @@ def get_confirmed_line_items(self): Order.get_confirmed_line_items = property(get_confirmed_line_items) +def initial_line_items(self): + return LineItem.query.filter(LineItem.order == self, LineItem.previous == None, LineItem.status.in_(LINE_ITEM_STATUS.TRANSACTION)) +Order.initial_line_items = property(initial_line_items) + + def get_from_item(cls, item, qty, coupon_codes=[]): """ Returns a list of (discount_policy, discount_coupon) tuples diff --git a/boxoffice/models/payment.py b/boxoffice/models/payment.py index b9fea4cb..fcbfff5d 100644 --- a/boxoffice/models/payment.py +++ b/boxoffice/models/payment.py @@ -5,9 +5,9 @@ from decimal import Decimal from coaster.utils import LabeledEnum, isoweek_datetime from isoweek import Week -from baseframe import __ +from baseframe import __, localize_timezone from boxoffice.models import db, BaseMixin, Order, ORDER_STATUS, MarkdownColumn, ItemCollection -from ..extapi import RAZORPAY_PAYMENT_STATUS +from ..extapi.razorpay_status import RAZORPAY_PAYMENT_STATUS __all__ = ['OnlinePayment', 'PaymentTransaction', 'CURRENCY', 'CURRENCY_SYMBOL', 'TRANSACTION_TYPE'] @@ -35,7 +35,7 @@ class OnlinePayment(BaseMixin, db.Model): order = db.relationship(Order, backref=db.backref('online_payments', cascade='all, delete-orphan')) # Payment id issued by the payment gateway - pg_paymentid = db.Column(db.Unicode(80), nullable=False) + pg_paymentid = db.Column(db.Unicode(80), nullable=False, unique=True) # Payment status issued by the payment gateway pg_payment_status = db.Column(db.Integer, nullable=False) confirmed_at = db.Column(db.DateTime, nullable=True) @@ -74,6 +74,8 @@ class PaymentTransaction(BaseMixin, db.Model): internal_note = db.Column(db.Unicode(250), nullable=True) refund_description = db.Column(db.Unicode(250), nullable=True) note_to_user = MarkdownColumn('note_to_user', nullable=True) + # Refund id issued by the payment gateway + pg_refundid = db.Column(db.Unicode(80), nullable=True, unique=True) def get_refund_transactions(self): diff --git a/boxoffice/static/css/app.css b/boxoffice/static/css/app.css index fd6ff250..c4b9e8d1 100644 --- a/boxoffice/static/css/app.css +++ b/boxoffice/static/css/app.css @@ -673,6 +673,10 @@ input.icon-placeholder { display: inline; } } +p.settlements-month-widget { + margin-top: 10px; +} + .org-header { text-align: center; margin: 0 auto 15px; diff --git a/boxoffice/static/css/dist/admin_bundle.css b/boxoffice/static/css/dist/admin_bundle.css index cbdf5047..39d79539 100644 --- a/boxoffice/static/css/dist/admin_bundle.css +++ b/boxoffice/static/css/dist/admin_bundle.css @@ -1 +1 @@ -.daterangepicker.single .calendar,.daterangepicker.single .ranges,.ranges{float:none}.c3 svg{font:10px sans-serif;-webkit-tap-highlight-color:transparent}.c3 line,.c3 path{fill:none;stroke:#000}.c3 text{-webkit-user-select:none;-moz-user-select:none;user-select:none}.c3-bars path,.c3-event-rect,.c3-legend-item-tile,.c3-xgrid-focus,.c3-ygrid{shape-rendering:crispEdges}.c3-chart-arc path{stroke:#fff}.c3-chart-arc text{fill:#fff;font-size:13px}.c3-grid line{stroke:#aaa}.c3-grid text{fill:#aaa}.c3-xgrid,.c3-ygrid{stroke-dasharray:3 3}.c3-text.c3-empty{fill:gray;font-size:2em}.c3-line{stroke-width:1px}.c3-circle._expanded_{stroke-width:1px;stroke:#fff}.c3-selected-circle{fill:#fff;stroke-width:2px}.c3-bar{stroke-width:0}.c3-bar._expanded_{fill-opacity:.75}.c3-target.c3-focused{opacity:1}.c3-target.c3-focused path.c3-line,.c3-target.c3-focused path.c3-step{stroke-width:2px}.c3-target.c3-defocused{opacity:.3!important}.c3-region{fill:#4682b4;fill-opacity:.1}.c3-brush .extent{fill-opacity:.1}.c3-legend-item{font-size:12px}.c3-legend-item-hidden{opacity:.15}.c3-legend-background{opacity:.75;fill:#fff;stroke:#d3d3d3;stroke-width:1}.c3-title{font:14px sans-serif}.c3-tooltip-container{z-index:10}.c3-tooltip{border-collapse:collapse;border-spacing:0;background-color:#fff;empty-cells:show;-webkit-box-shadow:7px 7px 12px -9px #777;-moz-box-shadow:7px 7px 12px -9px #777;box-shadow:7px 7px 12px -9px #777;opacity:.9}.c3-tooltip tr{border:1px solid #CCC}.c3-tooltip th{background-color:#aaa;font-size:14px;padding:2px 5px;text-align:left;color:#FFF}.c3-tooltip td{font-size:13px;padding:3px 6px;background-color:#fff;border-left:1px dotted #999}.c3-tooltip td>span{display:inline-block;width:10px;height:10px;margin-right:6px}.c3-tooltip td.value{text-align:right}.c3-area{stroke-width:0;opacity:.2}.c3-chart-arcs-title{dominant-baseline:middle;font-size:1.3em}.c3-chart-arcs .c3-chart-arcs-background{fill:#e0e0e0;stroke:none}.c3-chart-arcs .c3-chart-arcs-gauge-unit{fill:#000;font-size:16px}.c3-chart-arcs .c3-chart-arcs-gauge-max,.c3-chart-arcs .c3-chart-arcs-gauge-min{fill:#777}.c3-chart-arc .c3-gauge-value{fill:#000}.daterangepicker{position:absolute;color:inherit;background-color:#fff;border-radius:4px;width:278px;padding:4px;margin-top:1px;top:100px;left:20px}.daterangepicker:after,.daterangepicker:before{position:absolute;display:inline-block;content:''}.daterangepicker:before{top:-7px;border-right:7px solid transparent;border-left:7px solid transparent;border-bottom:7px solid #ccc}.daterangepicker:after{top:-6px;border-right:6px solid transparent;border-bottom:6px solid #fff;border-left:6px solid transparent}.daterangepicker.opensleft:before{right:9px}.daterangepicker.opensleft:after{right:10px}.daterangepicker.openscenter:after,.daterangepicker.openscenter:before{left:0;right:0;width:0;margin-left:auto;margin-right:auto}.daterangepicker.opensright:before{left:9px}.daterangepicker.opensright:after{left:10px}.daterangepicker.dropup{margin-top:-5px}.daterangepicker.dropup:before{top:initial;bottom:-7px;border-bottom:initial;border-top:7px solid #ccc}.daterangepicker.dropup:after{top:initial;bottom:-6px;border-bottom:initial;border-top:6px solid #fff}.daterangepicker.dropdown-menu{max-width:none;z-index:3001}.daterangepicker.show-calendar .calendar{display:block}.daterangepicker .calendar{display:none;max-width:270px;margin:4px}.daterangepicker .calendar.single .calendar-table{border:none}.daterangepicker .calendar td,.daterangepicker .calendar th{white-space:nowrap;text-align:center;min-width:32px}.daterangepicker .calendar-table{border:1px solid #fff;padding:4px;border-radius:4px;background-color:#fff}.daterangepicker table{width:100%;margin:0}.daterangepicker td,.daterangepicker th{text-align:center;width:20px;height:20px;border-radius:4px;border:1px solid transparent;white-space:nowrap;cursor:pointer}.daterangepicker td.available:hover,.daterangepicker th.available:hover{background-color:#eee;border-color:transparent;color:inherit}.daterangepicker td.week,.daterangepicker th.week{font-size:80%;color:#ccc}.daterangepicker td.off,.daterangepicker td.off.end-date,.daterangepicker td.off.in-range,.daterangepicker td.off.start-date{background-color:#fff;border-color:transparent;color:#999}.daterangepicker td.in-range{background-color:#ebf4f8;border-color:transparent;color:#000;border-radius:0}.daterangepicker td.start-date{border-radius:4px 0 0 4px}.daterangepicker td.end-date{border-radius:0 4px 4px 0}.daterangepicker td.start-date.end-date{border-radius:4px}.daterangepicker td.active,.daterangepicker td.active:hover{background-color:#357ebd;border-color:transparent;color:#fff}.daterangepicker th.month{width:auto}.daterangepicker option.disabled,.daterangepicker td.disabled{color:#999;cursor:not-allowed;text-decoration:line-through}.daterangepicker select.monthselect,.daterangepicker select.yearselect{font-size:12px;padding:1px;height:auto;margin:0;cursor:default}.daterangepicker select.monthselect{margin-right:2%;width:56%}.daterangepicker select.yearselect{width:40%}.daterangepicker select.ampmselect,.daterangepicker select.hourselect,.daterangepicker select.minuteselect,.daterangepicker select.secondselect{width:50px;margin-bottom:0}.daterangepicker .input-mini{border:1px solid #ccc;border-radius:4px;color:#555;height:30px;line-height:30px;display:block;vertical-align:middle;margin:0 0 5px;padding:0 6px 0 28px;width:100%}.daterangepicker .input-mini.active{border:1px solid #08c;border-radius:4px}.daterangepicker .daterangepicker_input{position:relative}.daterangepicker .daterangepicker_input i{position:absolute;left:8px;top:8px}.daterangepicker.rtl .input-mini{padding-right:28px;padding-left:6px}.daterangepicker.rtl .daterangepicker_input i{left:auto;right:8px}.daterangepicker .calendar-time{text-align:center;margin:5px auto;line-height:30px;position:relative;padding-left:28px}.daterangepicker .calendar-time select.disabled{color:#ccc;cursor:not-allowed}.ranges{font-size:11px;margin:4px;text-align:left}.ranges ul{list-style:none;margin:0 auto;padding:0;width:100%}.ranges li{font-size:13px;background-color:#f5f5f5;border:1px solid #f5f5f5;border-radius:4px;color:#08c;padding:3px 12px;margin-bottom:8px;cursor:pointer}.ranges li.active,.ranges li:hover{background-color:#08c;border:1px solid #08c;color:#fff}@media (min-width:564px){.daterangepicker.ltr .calendar.right .calendar-table,.daterangepicker.rtl .calendar.left .calendar-table{border-left:none;border-top-left-radius:0;border-bottom-left-radius:0}.daterangepicker.ltr .calendar.left .calendar-table,.daterangepicker.rtl .calendar.right .calendar-table{border-right:none;border-top-right-radius:0;border-bottom-right-radius:0}.daterangepicker{width:auto}.daterangepicker .ranges ul{width:160px}.daterangepicker.single .ranges ul{width:100%}.daterangepicker.single .calendar.left{clear:none}.daterangepicker.single.ltr .calendar,.daterangepicker.single.ltr .ranges{float:left}.daterangepicker.single.rtl .calendar,.daterangepicker.single.rtl .ranges{float:right}.daterangepicker.ltr{direction:ltr;text-align:left}.daterangepicker.ltr .calendar.left{clear:left;margin-right:0}.daterangepicker.ltr .calendar.right{margin-left:0}.daterangepicker.ltr .calendar.left .calendar-table,.daterangepicker.ltr .left .daterangepicker_input{padding-right:12px}.daterangepicker.ltr .calendar,.daterangepicker.ltr .ranges{float:left}.daterangepicker.rtl{direction:rtl;text-align:right}.daterangepicker.rtl .calendar.left{clear:right;margin-left:0}.daterangepicker.rtl .calendar.right{margin-right:0}.daterangepicker.rtl .calendar.left .calendar-table,.daterangepicker.rtl .left .daterangepicker_input{padding-left:12px}.daterangepicker.rtl .calendar,.daterangepicker.rtl .ranges{text-align:right;float:right}}@media (min-width:730px){.daterangepicker .ranges{width:auto}.daterangepicker.ltr .ranges{float:left}.daterangepicker.rtl .ranges{float:right}.daterangepicker .calendar.left{clear:none!important}}#nprogress{pointer-events:none}#nprogress .bar{background:#29d;position:fixed;z-index:1031;top:0;left:0;width:100%;height:2px}#nprogress .peg{display:block;position:absolute;right:0;width:100px;height:100%;box-shadow:0 0 10px #29d,0 0 5px #29d;opacity:1;-webkit-transform:rotate(3deg) translate(0,-4px);-ms-transform:rotate(3deg) translate(0,-4px);transform:rotate(3deg) translate(0,-4px)}#nprogress .spinner{display:block;position:fixed;z-index:1031;top:15px;right:15px}#nprogress .spinner-icon{width:18px;height:18px;box-sizing:border-box;border:2px solid transparent;border-top-color:#29d;border-left-color:#29d;border-radius:50%;-webkit-animation:nprogress-spinner .4s linear infinite;animation:nprogress-spinner .4s linear infinite}.nprogress-custom-parent{overflow:hidden;position:relative}.nprogress-custom-parent #nprogress .bar,.nprogress-custom-parent #nprogress .spinner{position:absolute}@-webkit-keyframes nprogress-spinner{0%{-webkit-transform:rotate(0)}100%{-webkit-transform:rotate(360deg)}}@keyframes nprogress-spinner{0%{transform:rotate(0)}100%{transform:rotate(360deg)}} \ No newline at end of file +.daterangepicker.single .calendar,.daterangepicker.single .ranges,.ranges{float:none}.c3 svg{font:10px sans-serif;-webkit-tap-highlight-color:transparent}.c3 line,.c3 path{fill:none;stroke:#000}.c3 text{-webkit-user-select:none;-moz-user-select:none;user-select:none}.c3-bars path,.c3-event-rect,.c3-legend-item-tile,.c3-xgrid-focus,.c3-ygrid{shape-rendering:crispEdges}.c3-chart-arc path{stroke:#fff}.c3-chart-arc text{fill:#fff;font-size:13px}.c3-grid line{stroke:#aaa}.c3-grid text{fill:#aaa}.c3-xgrid,.c3-ygrid{stroke-dasharray:3 3}.c3-text.c3-empty{fill:grey;font-size:2em}.c3-line{stroke-width:1px}.c3-circle._expanded_{stroke-width:1px;stroke:#fff}.c3-selected-circle{fill:#fff;stroke-width:2px}.c3-bar{stroke-width:0}.c3-bar._expanded_{fill-opacity:1;fill-opacity:.75}.c3-target.c3-focused{opacity:1}.c3-target.c3-focused path.c3-line,.c3-target.c3-focused path.c3-step{stroke-width:2px}.c3-target.c3-defocused{opacity:.3!important}.c3-region{fill:#4682b4;fill-opacity:.1}.c3-brush .extent{fill-opacity:.1}.c3-legend-item{font-size:12px}.c3-legend-item-hidden{opacity:.15}.c3-legend-background{opacity:.75;fill:#fff;stroke:#d3d3d3;stroke-width:1}.c3-title{font:14px sans-serif}.c3-tooltip-container{z-index:10}.c3-tooltip{border-collapse:collapse;border-spacing:0;background-color:#fff;empty-cells:show;-webkit-box-shadow:7px 7px 12px -9px #777;-moz-box-shadow:7px 7px 12px -9px #777;box-shadow:7px 7px 12px -9px #777;opacity:.9}.c3-tooltip tr{border:1px solid #ccc}.c3-tooltip th{background-color:#aaa;font-size:14px;padding:2px 5px;text-align:left;color:#fff}.c3-tooltip td{font-size:13px;padding:3px 6px;background-color:#fff;border-left:1px dotted #999}.c3-tooltip td>span{display:inline-block;width:10px;height:10px;margin-right:6px}.c3-tooltip td.value{text-align:right}.c3-area{stroke-width:0;opacity:.2}.c3-chart-arcs-title{dominant-baseline:middle;font-size:1.3em}.c3-chart-arcs .c3-chart-arcs-background{fill:#e0e0e0;stroke:none}.c3-chart-arcs .c3-chart-arcs-gauge-unit{fill:#000;font-size:16px}.c3-chart-arcs .c3-chart-arcs-gauge-max,.c3-chart-arcs .c3-chart-arcs-gauge-min{fill:#777}.c3-chart-arc .c3-gauge-value{fill:#000}.c3-chart-arc.c3-target g path,.c3-chart-arc.c3-target.c3-focused g path{opacity:1}.daterangepicker{position:absolute;color:inherit;background-color:#fff;border-radius:4px;width:278px;padding:4px;margin-top:1px;top:100px;left:20px}.daterangepicker:after,.daterangepicker:before{position:absolute;display:inline-block;content:''}.daterangepicker:before{top:-7px;border-right:7px solid transparent;border-left:7px solid transparent;border-bottom:7px solid #ccc}.daterangepicker:after{top:-6px;border-right:6px solid transparent;border-bottom:6px solid #fff;border-left:6px solid transparent}.daterangepicker.opensleft:before{right:9px}.daterangepicker.opensleft:after{right:10px}.daterangepicker.openscenter:after,.daterangepicker.openscenter:before{left:0;right:0;width:0;margin-left:auto;margin-right:auto}.daterangepicker.opensright:before{left:9px}.daterangepicker.opensright:after{left:10px}.daterangepicker.dropup{margin-top:-5px}.daterangepicker.dropup:before{top:initial;bottom:-7px;border-bottom:initial;border-top:7px solid #ccc}.daterangepicker.dropup:after{top:initial;bottom:-6px;border-bottom:initial;border-top:6px solid #fff}.daterangepicker.dropdown-menu{max-width:none;z-index:3001}.daterangepicker.show-calendar .calendar{display:block}.daterangepicker .calendar{display:none;max-width:270px;margin:4px}.daterangepicker .calendar.single .calendar-table{border:none}.daterangepicker .calendar td,.daterangepicker .calendar th{white-space:nowrap;text-align:center;min-width:32px}.daterangepicker .calendar-table{border:1px solid #fff;padding:4px;border-radius:4px;background-color:#fff}.daterangepicker table{width:100%;margin:0}.daterangepicker td,.daterangepicker th{text-align:center;width:20px;height:20px;border-radius:4px;border:1px solid transparent;white-space:nowrap;cursor:pointer}.daterangepicker td.available:hover,.daterangepicker th.available:hover{background-color:#eee;border-color:transparent;color:inherit}.daterangepicker td.week,.daterangepicker th.week{font-size:80%;color:#ccc}.daterangepicker td.off,.daterangepicker td.off.end-date,.daterangepicker td.off.in-range,.daterangepicker td.off.start-date{background-color:#fff;border-color:transparent;color:#999}.daterangepicker td.in-range{background-color:#ebf4f8;border-color:transparent;color:#000;border-radius:0}.daterangepicker td.start-date{border-radius:4px 0 0 4px}.daterangepicker td.end-date{border-radius:0 4px 4px 0}.daterangepicker td.start-date.end-date{border-radius:4px}.daterangepicker td.active,.daterangepicker td.active:hover{background-color:#357ebd;border-color:transparent;color:#fff}.daterangepicker th.month{width:auto}.daterangepicker option.disabled,.daterangepicker td.disabled{color:#999;cursor:not-allowed;text-decoration:line-through}.daterangepicker select.monthselect,.daterangepicker select.yearselect{font-size:12px;padding:1px;height:auto;margin:0;cursor:default}.daterangepicker select.monthselect{margin-right:2%;width:56%}.daterangepicker select.yearselect{width:40%}.daterangepicker select.ampmselect,.daterangepicker select.hourselect,.daterangepicker select.minuteselect,.daterangepicker select.secondselect{width:50px;margin-bottom:0}.daterangepicker .input-mini{border:1px solid #ccc;border-radius:4px;color:#555;height:30px;line-height:30px;display:block;vertical-align:middle;margin:0 0 5px;padding:0 6px 0 28px;width:100%}.daterangepicker .input-mini.active{border:1px solid #08c;border-radius:4px}.daterangepicker .daterangepicker_input{position:relative}.daterangepicker .daterangepicker_input i{position:absolute;left:8px;top:8px}.daterangepicker.rtl .input-mini{padding-right:28px;padding-left:6px}.daterangepicker.rtl .daterangepicker_input i{left:auto;right:8px}.daterangepicker .calendar-time{text-align:center;margin:5px auto;line-height:30px;position:relative;padding-left:28px}.daterangepicker .calendar-time select.disabled{color:#ccc;cursor:not-allowed}.ranges{font-size:11px;margin:4px;text-align:left}.ranges ul{list-style:none;margin:0 auto;padding:0;width:100%}.ranges li{font-size:13px;background-color:#f5f5f5;border:1px solid #f5f5f5;border-radius:4px;color:#08c;padding:3px 12px;margin-bottom:8px;cursor:pointer}.ranges li.active,.ranges li:hover{background-color:#08c;border:1px solid #08c;color:#fff}@media (min-width:564px){.daterangepicker.ltr .calendar.right .calendar-table,.daterangepicker.rtl .calendar.left .calendar-table{border-left:none;border-top-left-radius:0;border-bottom-left-radius:0}.daterangepicker.ltr .calendar.left .calendar-table,.daterangepicker.rtl .calendar.right .calendar-table{border-right:none;border-top-right-radius:0;border-bottom-right-radius:0}.daterangepicker{width:auto}.daterangepicker .ranges ul{width:160px}.daterangepicker.single .ranges ul{width:100%}.daterangepicker.single .calendar.left{clear:none}.daterangepicker.single.ltr .calendar,.daterangepicker.single.ltr .ranges{float:left}.daterangepicker.single.rtl .calendar,.daterangepicker.single.rtl .ranges{float:right}.daterangepicker.ltr{direction:ltr;text-align:left}.daterangepicker.ltr .calendar.left{clear:left;margin-right:0}.daterangepicker.ltr .calendar.right{margin-left:0}.daterangepicker.ltr .calendar.left .calendar-table,.daterangepicker.ltr .left .daterangepicker_input{padding-right:12px}.daterangepicker.ltr .calendar,.daterangepicker.ltr .ranges{float:left}.daterangepicker.rtl{direction:rtl;text-align:right}.daterangepicker.rtl .calendar.left{clear:right;margin-left:0}.daterangepicker.rtl .calendar.right{margin-right:0}.daterangepicker.rtl .calendar.left .calendar-table,.daterangepicker.rtl .left .daterangepicker_input{padding-left:12px}.daterangepicker.rtl .calendar,.daterangepicker.rtl .ranges{text-align:right;float:right}}@media (min-width:730px){.daterangepicker .ranges{width:auto}.daterangepicker.ltr .ranges{float:left}.daterangepicker.rtl .ranges{float:right}.daterangepicker .calendar.left{clear:none!important}}#nprogress{pointer-events:none}#nprogress .bar{background:#29d;position:fixed;z-index:1031;top:0;left:0;width:100%;height:2px}#nprogress .peg{display:block;position:absolute;right:0;width:100px;height:100%;box-shadow:0 0 10px #29d,0 0 5px #29d;opacity:1;-webkit-transform:rotate(3deg) translate(0,-4px);-ms-transform:rotate(3deg) translate(0,-4px);transform:rotate(3deg) translate(0,-4px)}#nprogress .spinner{display:block;position:fixed;z-index:1031;top:15px;right:15px}#nprogress .spinner-icon{width:18px;height:18px;box-sizing:border-box;border:2px solid transparent;border-top-color:#29d;border-left-color:#29d;border-radius:50%;-webkit-animation:nprogress-spinner .4s linear infinite;animation:nprogress-spinner .4s linear infinite}.nprogress-custom-parent{overflow:hidden;position:relative}.nprogress-custom-parent #nprogress .bar,.nprogress-custom-parent #nprogress .spinner{position:absolute}@-webkit-keyframes nprogress-spinner{0%{-webkit-transform:rotate(0)}100%{-webkit-transform:rotate(360deg)}}@keyframes nprogress-spinner{0%{transform:rotate(0)}100%{transform:rotate(360deg)}} \ No newline at end of file diff --git a/boxoffice/static/js/dist/admin_bundle.js b/boxoffice/static/js/dist/admin_bundle.js index 0bac3cab..b358b322 100644 --- a/boxoffice/static/js/dist/admin_bundle.js +++ b/boxoffice/static/js/dist/admin_bundle.js @@ -22,5 +22,5 @@ if("select"===t.name)return t}while(t=t.parent)}function Lr(t){var e,n,i,r,a,o,s this.ref=r=e.r,this.callback=n,this.unresolved=[],(a=au(i,r,o))?this.base=a:this.baseResolver=new Of(this,r,function(t){s.base=t,s.baseResolver=null,s.bubble()}),this.members=e.m.map(function(t){return new qf(t,s,o)}),this.ready=!0,this.bubble()};Xf.prototype={getKeypath:function(){var t=this.members.map(Nn);return!t.every(Fn)||this.baseResolver?null:this.base.join(t.join("."))},bubble:function(){this.ready&&!this.baseResolver&&this.callback(this.getKeypath())},unbind:function(){this.members.forEach(q)},rebind:function(t,e){var n;if(this.base){var i=this.base.replace(t,e);i&&i!==this.base&&(this.base=i,n=!0)}this.members.forEach(function(i){i.rebind(t,e)&&(n=!0)}),n&&this.bubble()},forceResolution:function(){this.baseResolver&&(this.base=T(this.ref),this.baseResolver.unbind(),this.baseResolver=null),this.members.forEach(jn),this.bubble()}};var $f=Xf,Qf=Gn,Zf=Yn,Kf=Hn,Jf={getValue:Df,init:Qf,resolve:Zf,rebind:Kf},tp=function(t){this.type=zc,Jf.init(this,t)};tp.prototype={update:function(){this.node.data=void 0==this.value?"":this.value},resolve:Jf.resolve,rebind:Jf.rebind,detach:Cf,unbind:Mf,render:function(){return this.node||(this.node=document.createTextNode(n(this.value))),this.node},unrender:function(t){t&&e(this.node)},getValue:Jf.getValue,setValue:function(t){var e;this.keypath&&(e=this.root.viewmodel.wrapped[this.keypath.str])&&(t=e.get()),s(t,this.value)||(this.value=t,this.parentFragment.bubble(),this.node&&du.addView(this))},firstNode:function(){return this.node},toString:function(t){var e=""+n(this.value);return t?Ae(e):e}};var ep=tp,np=zn,ip=Bn,rp=Un,ap=Wn,op=qn,sp=Xn,up=$n,cp=Qn,lp=Zn,hp=function(t,e){Jf.rebind.call(this,t,e)},dp=Jn,fp=ti,pp=hi,gp=di,mp=fi,vp=mi,yp=function(t){this.type=Uc,this.subtype=this.currentSubtype=t.template.n,this.inverted=this.subtype===bl,this.pElement=t.pElement,this.fragments=[],this.fragmentsToCreate=[],this.fragmentsToRender=[],this.fragmentsToUnrender=[],t.template.i&&(this.indexRefs=t.template.i.split(",").map(function(t,e){return{n:t,t:0===e?"k":"i"}})),this.renderedFragments=[],this.length=0,Jf.init(this,t)};yp.prototype={bubble:np,detach:ip,find:rp,findAll:ap,findAllComponents:op,findComponent:sp,findNextNode:up,firstNode:cp,getIndexRef:function(t){if(this.indexRefs)for(var e=this.indexRefs.length;e--;){var n=this.indexRefs[e];if(n.n===t)return n}},getValue:Jf.getValue,shuffle:lp,rebind:hp,render:dp,resolve:Jf.resolve,setValue:fp,toString:pp,unbind:gp,unrender:mp,update:vp};var _p,xp,bp=yp,wp=vi,Sp=yi,Tp=_i,kp=xi,Ap={};try{ls("table").innerHTML="foo"}catch(t){_p=!0,xp={TABLE:['',"
"],THEAD:['',"
"],TBODY:['',"
"],TR:['',"
"],SELECT:['"]}}var Cp=function(t,e,n){var i,r,a,o,s,u=[];if(null!=t&&""!==t){for(_p&&(r=xp[e.tagName])?(i=bi("DIV"),i.innerHTML=r[0]+t+r[1],i=i.querySelector(".x"),"SELECT"===i.tagName&&(a=i.options[i.selectedIndex])):e.namespaceURI===is.svg?(i=bi("DIV"),i.innerHTML=''+t+"",i=i.querySelector(".x")):(i=bi(e.tagName),i.innerHTML=t,"SELECT"===i.tagName&&(a=i.options[i.selectedIndex]));o=i.firstChild;)u.push(o),n.appendChild(o);if("SELECT"===e.tagName)for(s=u.length;s--;)u[s]!==a&&(u[s].selected=!1)}return u},Pp=wi,Ep=Ti,Mp=ki,Dp=Ai,Lp=Ci,Op=Pi,Rp=function(t){this.type=Bc,Jf.init(this,t)};Rp.prototype={detach:wp,find:Sp,findAll:Tp,firstNode:kp,getValue:Jf.getValue,rebind:Jf.rebind,render:Ep,resolve:Jf.resolve,setValue:Mp,toString:Dp,unbind:Mf,unrender:Lp,update:Op};var Ip,Vp,Np,Fp,jp=Rp,Gp=function(){this.parentFragment.bubble()},Yp=Ei,Hp=function(t){return this.node?hs(this.node,t)?this.node:this.fragment&&this.fragment.find?this.fragment.find(t):void 0:null},zp=function(t,e){e._test(this,!0)&&e.live&&(this.liveQueries||(this.liveQueries=[])).push(e),this.fragment&&this.fragment.findAll(t,e)},Bp=function(t,e){this.fragment&&this.fragment.findAllComponents(t,e)},Up=function(t){if(this.fragment)return this.fragment.findComponent(t)},Wp=Mi,qp=Di,Xp=Li,$p=/^true|on|yes|1$/i,Qp=/^[0-9]+$/,Zp=function(t,e){var n,i,r;return r=e.a||{},i={},n=r.twoway,void 0!==n&&(i.twoway=0===n||$p.test(n)),n=r.lazy,void 0!==n&&(0!==n&&Qp.test(n)?i.lazy=parseInt(n):i.lazy=0===n||$p.test(n)),i},Kp=Oi;Ip="altGlyph altGlyphDef altGlyphItem animateColor animateMotion animateTransform clipPath feBlend feColorMatrix feComponentTransfer feComposite feConvolveMatrix feDiffuseLighting feDisplacementMap feDistantLight feFlood feFuncA feFuncB feFuncG feFuncR feGaussianBlur feImage feMerge feMergeNode feMorphology feOffset fePointLight feSpecularLighting feSpotLight feTile feTurbulence foreignObject glyphRef linearGradient radialGradient textPath vkern".split(" "),Vp="attributeName attributeType baseFrequency baseProfile calcMode clipPathUnits contentScriptType contentStyleType diffuseConstant edgeMode externalResourcesRequired filterRes filterUnits glyphRef gradientTransform gradientUnits kernelMatrix kernelUnitLength keyPoints keySplines keyTimes lengthAdjust limitingConeAngle markerHeight markerUnits markerWidth maskContentUnits maskUnits numOctaves pathLength patternContentUnits patternTransform patternUnits pointsAtX pointsAtY pointsAtZ preserveAlpha preserveAspectRatio primitiveUnits refX refY repeatCount repeatDur requiredExtensions requiredFeatures specularConstant specularExponent spreadMethod startOffset stdDeviation stitchTiles surfaceScale systemLanguage tableValues targetX targetY textLength viewBox viewTarget xChannelSelector yChannelSelector zoomAndPan".split(" "),Np=function(t){for(var e={},n=t.length;n--;)e[t[n].toLowerCase()]=t[n];return e},Fp=Np(Ip.concat(Vp));var Jp=function(t){var e=t.toLowerCase();return Fp[e]||e},tg=function(t,e){var n,i;if(-1===(n=e.indexOf(":"))||"xmlns"===(i=e.substr(0,n)))t.name=t.element.namespace!==is.html?Jp(e):e;else if(e=e.substring(n+1),t.name=Jp(e),t.namespace=is[i.toLowerCase()],t.namespacePrefix=i,!t.namespace)throw'Unknown namespace ("'+i+'")'},eg=Ri,ng=Ii,ig=Vi,rg=Ni,ag={"accept-charset":"acceptCharset",accesskey:"accessKey",bgcolor:"bgColor",class:"className",codebase:"codeBase",colspan:"colSpan",contenteditable:"contentEditable",datetime:"dateTime",dirname:"dirName",for:"htmlFor","http-equiv":"httpEquiv",ismap:"isMap",maxlength:"maxLength",novalidate:"noValidate",pubdate:"pubDate",readonly:"readOnly",rowspan:"rowSpan",tabindex:"tabIndex",usemap:"useMap"},og=Fi,sg=Gi,ug=Yi,cg=Hi,lg=zi,hg=Bi,dg=Ui,fg=Wi,pg=qi,gg=Xi,mg=$i,vg=Qi,yg=Zi,_g=Ki,xg=Ji,bg=function(t){this.init(t)};bg.prototype={bubble:Kp,init:ng,rebind:ig,render:rg,toString:og,unbind:sg,update:xg};var wg,Sg=bg,Tg=function(t,e){var n,i,r=[];for(n in e)"twoway"!==n&&"lazy"!==n&&e.hasOwnProperty(n)&&(i=new Sg({element:t,name:n,value:e[n],root:t.root}),r[n]=i,"value"!==n&&r.push(i));return(i=r.value)&&r.push(i),r};"undefined"!=typeof document&&(wg=ls("div"));var kg=function(t,e){this.element=t,this.root=t.root,this.parentFragment=t.parentFragment,this.attributes=[],this.fragment=new d_({root:t.root,owner:this,template:[e]})};kg.prototype={bubble:function(){this.node&&this.update(),this.element.bubble()},rebind:function(t,e){this.fragment.rebind(t,e)},render:function(t){this.node=t,this.isSvg=t.namespaceURI===is.svg,this.update()},unbind:function(){this.fragment.unbind()},update:function(){var t,e,n=this;t=this.fragment.toString(),e=tr(t,this.isSvg),this.attributes.filter(function(t){return er(e,t)}).forEach(function(t){n.node.removeAttribute(t.name)}),e.forEach(function(t){n.node.setAttribute(t.name,t.value)}),this.attributes=e},toString:function(){return this.fragment.toString()}};var Ag=kg,Cg=function(t,e){return e?e.map(function(e){return new Ag(t,e)}):[]},Pg=function(t){var e,n,i,r;if(this.element=t,this.root=t.root,this.attribute=t.attributes[this.name||"value"],e=this.attribute.interpolator,e.twowayBinding=this,n=e.keypath){if("}"===n.str.slice(-1))return m("Two-way binding does not work with expressions (`%s` on <%s>)",e.resolver.uniqueString,t.name,{ractive:this.root}),!1;if(n.isSpecial)return m("Two-way binding does not work with %s",e.resolver.ref,{ractive:this.root}),!1}else{g("The %s being used for two-way binding is ambiguous, and may cause unexpected results. Consider initialising your data to eliminate the ambiguity",e.template.r?"'"+e.template.r+"' reference":"expression",{ractive:this.root}),e.resolver.forceResolution(),n=e.keypath}this.attribute.isTwoway=!0,this.keypath=n,i=this.root.viewmodel.get(n),void 0===i&&this.getInitialValue&&void 0!==(i=this.getInitialValue())&&this.root.viewmodel.set(n,i),(r=nr(t))&&(this.resetValue=i,r.formBindings.push(this))};Pg.prototype={handleChange:function(){var t=this;du.start(this.root),this.attribute.locked=!0,this.root.viewmodel.set(this.keypath,this.getValue()),du.scheduleTask(function(){return t.attribute.locked=!1}),du.end()},rebound:function(){var t,e,n;e=this.keypath,n=this.attribute.interpolator.keypath,e!==n&&(V(this.root._twowayBindings[e.str],this),this.keypath=n,t=this.root._twowayBindings[n.str]||(this.root._twowayBindings[n.str]=[]),t.push(this))},unbind:function(){}},Pg.extend=function(t){var e,n=this;return e=function(t){Pg.call(this,t),this.init&&this.init()},e.prototype=_s(n.prototype),i(e.prototype,t),e.extend=Pg.extend,e};var Eg,Mg=Pg,Dg=ir;Eg=Mg.extend({getInitialValue:function(){return""},getValue:function(){return this.element.node.value},render:function(){var t,e=this.element.node,n=!1;this.rendered=!0,t=this.root.lazy,!0===this.element.lazy?t=!0:!1===this.element.lazy?t=!1:u(this.element.lazy)?(t=!1,n=+this.element.lazy):u(t||"")&&(n=+t,t=!1,this.element.lazy=n),this.handler=n?ar:Dg,e.addEventListener("change",Dg,!1),t||(e.addEventListener("input",this.handler,!1),e.attachEvent&&e.addEventListener("keyup",this.handler,!1)),e.addEventListener("blur",rr,!1)},unrender:function(){var t=this.element.node;this.rendered=!1,t.removeEventListener("change",Dg,!1),t.removeEventListener("input",this.handler,!1),t.removeEventListener("keyup",this.handler,!1),t.removeEventListener("blur",rr,!1)}});var Lg=Eg,Og=Lg.extend({getInitialValue:function(){return this.element.fragment?this.element.fragment.toString():""},getValue:function(){return this.element.node.innerHTML}}),Rg=Og,Ig=or,Vg={},Ng=Mg.extend({name:"checked",init:function(){this.siblings=Ig(this.root._guid,"radio",this.element.getAttribute("name")),this.siblings.push(this)},render:function(){var t=this.element.node;t.addEventListener("change",Dg,!1),t.attachEvent&&t.addEventListener("click",Dg,!1)},unrender:function(){var t=this.element.node;t.removeEventListener("change",Dg,!1),t.removeEventListener("click",Dg,!1)},handleChange:function(){du.start(this.root),this.siblings.forEach(function(t){t.root.viewmodel.set(t.keypath,t.getValue())}),du.end()},getValue:function(){return this.element.node.checked},unbind:function(){V(this.siblings,this)}}),Fg=Ng,jg=Mg.extend({name:"name",init:function(){this.siblings=Ig(this.root._guid,"radioname",this.keypath.str),this.siblings.push(this),this.radioName=!0},getInitialValue:function(){if(this.element.getAttribute("checked"))return this.element.getAttribute("value")},render:function(){var t=this.element.node;t.name="{{"+this.keypath.str+"}}",t.checked=this.root.viewmodel.get(this.keypath)==this.element.getAttribute("value"),t.addEventListener("change",Dg,!1),t.attachEvent&&t.addEventListener("click",Dg,!1)},unrender:function(){var t=this.element.node;t.removeEventListener("change",Dg,!1),t.removeEventListener("click",Dg,!1)},getValue:function(){var t=this.element.node;return t._ractive?t._ractive.value:t.value},handleChange:function(){this.element.node.checked&&Mg.prototype.handleChange.call(this)},rebound:function(t,e){var n;Mg.prototype.rebound.call(this,t,e),(n=this.element.node)&&(n.name="{{"+this.keypath.str+"}}")},unbind:function(){V(this.siblings,this)}}),Gg=jg,Yg=Mg.extend({name:"name",getInitialValue:function(){return this.noInitialValue=!0,[]},init:function(){var t,e;this.checkboxName=!0,this.siblings=Ig(this.root._guid,"checkboxes",this.keypath.str),this.siblings.push(this),this.noInitialValue&&(this.siblings.noInitialValue=!0),this.siblings.noInitialValue&&this.element.getAttribute("checked")&&(t=this.root.viewmodel.get(this.keypath),e=this.element.getAttribute("value"),t.push(e))},unbind:function(){V(this.siblings,this)},render:function(){var t,e,n=this.element.node;t=this.root.viewmodel.get(this.keypath),e=this.element.getAttribute("value"),a(t)?this.isChecked=L(t,e):this.isChecked=t==e,n.name="{{"+this.keypath.str+"}}",n.checked=this.isChecked,n.addEventListener("change",Dg,!1),n.attachEvent&&n.addEventListener("click",Dg,!1)},unrender:function(){var t=this.element.node;t.removeEventListener("change",Dg,!1),t.removeEventListener("click",Dg,!1)},changed:function(){var t=!!this.isChecked;return this.isChecked=this.element.node.checked,this.isChecked===t},handleChange:function(){this.isChecked=this.element.node.checked,Mg.prototype.handleChange.call(this)},getValue:function(){return this.siblings.filter(sr).map(ur)}}),Hg=Yg,zg=Mg.extend({name:"checked",render:function(){var t=this.element.node;t.addEventListener("change",Dg,!1),t.attachEvent&&t.addEventListener("click",Dg,!1)},unrender:function(){var t=this.element.node;t.removeEventListener("change",Dg,!1),t.removeEventListener("click",Dg,!1)},getValue:function(){return this.element.node.checked}}),Bg=zg,Ug=Mg.extend({getInitialValue:function(){var t,e,n,i,r=this.element.options;if(void 0===this.element.getAttribute("value")&&(e=t=r.length,t)){for(;e--;)if(r[e].getAttribute("selected")){n=r[e].getAttribute("value"),i=!0;break}if(!i)for(;++ethis.end?(this.step&&this.step(1),this.complete&&this.complete(1),!1):(e=t-this.start,n=this.easing(e/this.duration),this.step&&this.step(n),!0))},stop:function(){this.abort&&this.abort(),this.running=!1}};var Dm,Lm,Om,Rm,Im,Vm,Nm,Fm,jm=Mm,Gm=new RegExp("^-(?:"+as.join("|")+")-"),Ym=function(t){return t.replace(Gm,"")},Hm=new RegExp("^(?:"+as.join("|")+")([A-Z])"),zm=function(t){return t?(Hm.test(t)&&(t="-"+t),t.replace(/[A-Z]/g,function(t){return"-"+t.toLowerCase()})):""},Bm={},Um={};Jo?(Lm=ls("div").style,function(){void 0!==Lm.transition?(Om="transition",Rm="transitionend",Im=!0):void 0!==Lm.webkitTransition?(Om="webkitTransition",Rm="webkitTransitionEnd",Im=!0):Im=!1}(),Om&&(Vm=Om+"Duration",Nm=Om+"Property",Fm=Om+"TimingFunction"),Dm=function(t,e,n,i,r){setTimeout(function(){var a,o,s,u,c;u=function(){o&&s&&(t.root.fire(t.name+":end",t.node,t.isIntro),r())},a=(t.node.namespaceURI||"")+t.node.tagName,t.node.style[Nm]=i.map(Cm).map(zm).join(","),t.node.style[Fm]=zm(n.easing||"linear"),t.node.style[Vm]=n.duration/1e3+"s",c=function(e){var n;n=i.indexOf(Tm(Ym(e.propertyName))),-1!==n&&i.splice(n,1),i.length||(t.node.removeEventListener(Rm,c,!1),s=!0,u())},t.node.addEventListener(Rm,c,!1),setTimeout(function(){for(var r,l,h,d,f,p=i.length,m=[];p--;)d=i[p],r=a+d,Im&&!Um[r]&&(t.node.style[Cm(d)]=e[d],Bm[r]||(l=t.getStyle(d),Bm[r]=t.getStyle(d)!=e[d],Um[r]=!Bm[r],Um[r]&&(t.node.style[Cm(d)]=l))),Im&&!Um[r]||(void 0===l&&(l=t.getStyle(d)),h=i.indexOf(d),-1===h?g("Something very strange happened with transitions. Please raise an issue at https://github.com/ractivejs/ractive/issues - thanks!",{node:t.node}):i.splice(h,1),f=/[^\d]*$/.exec(e[d])[0],m.push({name:Cm(d),interpolator:Rs(parseFloat(l),parseFloat(e[d])),suffix:f}));m.length?new jm({root:t.root,duration:n.duration,easing:Tm(n.easing||""),step:function(e){var n,i;for(i=m.length;i--;)n=m[i],t.node.style[n.name]=n.interpolator(e)+n.suffix},complete:function(){o=!0,u()}}):o=!0,i.length||(t.node.removeEventListener(Rm,c,!1),s=!0,u())},0)},n.delay||0)}):Dm=null;var Wm,qm,Xm,$m,Qm,Zm=Dm;if("undefined"!=typeof document){if(Wm="hidden",Qm={},Wm in document)Xm="";else for($m=as.length;$m--;)qm=as[$m],(Wm=qm+"Hidden")in document&&(Xm=qm);void 0!==Xm?(document.addEventListener(Xm+"visibilitychange",Yr),Yr()):("onfocusout"in document?(document.addEventListener("focusout",Hr),document.addEventListener("focusin",zr)):(window.addEventListener("pagehide",Hr),window.addEventListener("blur",Hr),window.addEventListener("pageshow",zr),window.addEventListener("focus",zr)),Qm.hidden=!1)}var Km,Jm,tv,ev=Qm;Jo?(Jm=window.getComputedStyle||null.getComputedStyle,Km=function(t,e,n){var i,r=this;if(4===arguments.length)throw new Error("t.animateStyle() returns a promise - use .then() instead of passing a callback");return ev.hidden?(this.setStyle(t,e),tv||(tv=iu.resolve())):("string"==typeof t?(i={},i[t]=e):(i=t,n=e),n||(m('The "%s" transition does not supply an options object to `t.animateStyle()`. This will break in a future version of Ractive. For more info see https://github.com/RactiveJS/Ractive/issues/340',this.name),n=this),new iu(function(t){var e,a,o,s,u,c;if(!n.duration)return r.setStyle(i),void t();for(e=Object.keys(i),a=[],o=Jm(r.node),{},u=e.length;u--;)c=e[u],s=o[Cm(c)],"0px"===s&&(s=0),s!=i[c]&&(a.push(c),r.node.style[Cm(c)]=s);if(!a.length)return void t();Zm(r,i,n,a,t)}))}):Km=null;var nv=Km,iv=function(t,e){return"number"==typeof t?t={duration:t}:"string"==typeof t?t="slow"===t?{duration:600}:"fast"===t?{duration:200}:{duration:400}:t||(t={}),r({},t,e)},rv=Br,av=function(t,e,n){this.init(t,e,n)};av.prototype={init:Sm,start:rv,getStyle:Pm,setStyle:Em,animateStyle:nv,processParams:iv};var ov,sv,uv=av,cv=Wr;ov=function(){var t=this.node,e=this.fragment.toString(!1);if(window&&window.appearsToBeIELessEqual8&&(t.type="text/css"),t.styleSheet)t.styleSheet.cssText=e;else{for(;t.hasChildNodes();)t.removeChild(t.firstChild);t.appendChild(document.createTextNode(e))}},sv=function(){this.node.type&&"text/javascript"!==this.node.type||g("Script tag was updated. This does not cause the code to be re-evaluated!",{ractive:this.root}),this.node.text=this.fragment.toString(!1)};var lv=function(){var t,e;return this.template.y?"":(t="<"+this.template.e,t+=this.attributes.map(Kr).join("")+this.conditionalAttributes.map(Kr).join(""),"option"===this.name&&Qr(this)&&(t+=" selected"),"input"===this.name&&Zr(this)&&(t+=" checked"),t+=">","textarea"===this.name&&void 0!==this.getAttribute("value")?t+=Ae(this.getAttribute("value")):void 0!==this.getAttribute("contenteditable")&&(t+=this.getAttribute("value")||""),this.fragment&&(e="script"!==this.name&&"style"!==this.name,t+=this.fragment.toString(e)),ph.test(this.template.e)||(t+=""),t)},hv=Jr,dv=ta,fv=function(t){this.init(t)};fv.prototype={bubble:Gp,detach:Yp,find:Hp,findAll:zp,findAllComponents:Bp,findComponent:Up,findNextNode:Wp,firstNode:qp,getAttribute:Xp,init:bm,rebind:wm,render:cv,toString:lv,unbind:hv,unrender:dv};var pv=fv,gv=/^\s*$/,mv=/^\s*/,vv=function(t){var e,n,i,r;return e=t.split("\n"),n=e[0],void 0!==n&&gv.test(n)&&e.shift(),i=I(e),void 0!==i&&gv.test(i)&&e.pop(),r=e.reduce(na,null),r&&(t=e.map(function(t){return t.replace(r,"")}).join("\n")),t},yv=ia,_v=function(t,e){return e?t.split("\n").map(function(t,n){return n?e+t:t}).join("\n"):t},xv=function(t){var e,n;e=this.parentFragment=t.parentFragment,this.root=e.root,this.type=$c,this.index=t.index,this.name=t.template.r,this.rendered=!1,this.fragment=this.fragmentToRender=this.fragmentToUnrender=null,Jf.init(this,t),this.keypath||((n=yv(this.root,this.name,e))?(Mf.call(this),this.isNamed=!0,this.setTemplate(n)):m('Could not find template for partial "%s"',this.name))};xv.prototype={bubble:function(){this.parentFragment.bubble()},detach:function(){return this.fragment.detach()},find:function(t){return this.fragment.find(t)},findAll:function(t,e){return this.fragment.findAll(t,e)},findComponent:function(t){return this.fragment.findComponent(t)},findAllComponents:function(t,e){return this.fragment.findAllComponents(t,e)},firstNode:function(){return this.fragment.firstNode()},findNextNode:function(){return this.parentFragment.findNextNode(this)},getPartialName:function(){return this.isNamed&&this.name?this.name:void 0===this.value?this.name:this.value},getValue:function(){return this.fragment.getValue()},rebind:function(t,e){this.isNamed||Kf.call(this,t,e),this.fragment&&this.fragment.rebind(t,e)},render:function(){return this.docFrag=document.createDocumentFragment(),this.update(),this.rendered=!0,this.docFrag},resolve:Jf.resolve,setValue:function(t){var e;void 0!==t&&t===this.value||(void 0!==t&&(e=yv(this.root,""+t,this.parentFragment)),!e&&this.name&&(e=yv(this.root,this.name,this.parentFragment))&&(Mf.call(this),this.isNamed=!0),e||m('Could not find template for partial "%s"',this.name,{ractive:this.root}),this.value=t,this.setTemplate(e||[]),this.bubble(),this.rendered&&du.addView(this))},setTemplate:function(t){this.fragment&&(this.fragment.unbind(),this.rendered&&(this.fragmentToUnrender=this.fragment)),this.fragment=new d_({template:t,root:this.root,owner:this,pElement:this.parentFragment.pElement}),this.fragmentToRender=this.fragment},toString:function(t){var e,n,i,r;return e=this.fragment.toString(t),(n=this.parentFragment.items[this.index-1])&&1===n.type?(i=n.text.split("\n").pop(),(r=/^\s+$/.exec(i))?_v(e,r[0]):e):e},unbind:function(){this.isNamed||Mf.call(this),this.fragment&&this.fragment.unbind()},unrender:function(t){this.rendered&&(this.fragment&&this.fragment.unrender(t),this.rendered=!1)},update:function(){var t,e;this.fragmentToUnrender&&(this.fragmentToUnrender.unrender(!0),this.fragmentToUnrender=null),this.fragmentToRender&&(this.docFrag.appendChild(this.fragmentToRender.render()),this.fragmentToRender=null),this.rendered&&(t=this.parentFragment.getNode(),e=this.parentFragment.findNextNode(this),t.insertBefore(this.docFrag,e))}};var bv,wv,Sv,Tv=xv,kv=ua,Av=ca,Cv=new Js("detach"),Pv=la,Ev=ha,Mv=da,Dv=fa,Lv=pa,Ov=ga,Rv=function(t,e,n,i){var r=t.root,a=t.keypath;i?r.viewmodel.smartUpdate(a,e,i):r.viewmodel.mark(a)},Iv=[],Vv=["pop","push","reverse","shift","sort","splice","unshift"];Vv.forEach(function(t){xs(Iv,t,{value:function(){for(var e=arguments.length,n=Array(e),i=0;i component has a default `el` property; it has been disregarded",t.name),l=u;l;){if(l.owner.type===el){h=l.owner.container;break}l=l.parent}return n&&Object.keys(n).forEach(function(e){var i,r,o=n[e];if("string"==typeof o)i=_d(o),p[e]=i?i.value:o;else if(0===o)p[e]=!0;else{if(!a(o))throw new Error("erm wut");fo(o)?(m[e]={origin:t.root.viewmodel,keypath:void 0},r=ho(t,o[0],function(t){t.isSpecial?d?s.set(e,t.value):(p[e]=t.value,delete m[e]):d?s.viewmodel.mappings[e].resolve(t):m[e].keypath=t})):r=new Fy(t,o,function(t){d?s.set(e,t):p[e]=t}),v.push(r)}}),s=_s(e.prototype),Ny(s,{el:null,append:!0,data:p,partials:o,magic:c.magic||e.defaults.magic,modifyArrays:c.modifyArrays,adapt:c.adapt},{parent:c,component:t,container:h,mappings:m,inlinePartials:f,cssIds:u.cssIds}),d=!0,t.resolvers=v,s},Gy=po,Yy=function(t){var e,n;for(e=t.root;e;)(n=e._liveComponentQueries["_"+t.name])&&n.push(t.instance),e=e.parent},Hy=mo,zy=vo,By=yo,Uy=_o,Wy=xo,qy=new Js("teardown"),Xy=wo,$y=function(t,e){this.init(t,e)};$y.prototype={detach:Av,find:Pv,findAll:Ev,findAllComponents:Mv,findComponent:Dv,findNextNode:Lv,firstNode:Ov,init:Hy,rebind:zy,render:By,toString:Uy,unbind:Wy,unrender:Xy};var Qy=$y,Zy=function(t){this.type=Qc,this.value=t.template.c};Zy.prototype={detach:Cf,firstNode:function(){return this.node},render:function(){return this.node||(this.node=document.createComment(this.value)),this.node},toString:function(){return"\x3c!--"+this.value+"--\x3e"},unrender:function(t){t&&this.node.parentNode.removeChild(this.node)}};var Ky=Zy,Jy=function(t){var e,n;this.type=el,this.container=e=t.parentFragment.root,this.component=n=e.component,this.container=e,this.containerFragment=t.parentFragment,this.parentFragment=n.parentFragment;var i=this.name=t.template.n||"",r=e._inlinePartials[i];r||(g('Could not find template for partial "'+i+'"',{ractive:t.root}),r=[]),this.fragment=new d_({owner:this,root:e.parent,template:r,pElement:this.containerFragment.pElement}),a(n.yielders[i])?n.yielders[i].push(this):n.yielders[i]=[this],du.scheduleTask(function(){if(n.yielders[i].length>1)throw new Error("A component template can only have one {{yield"+(i?" "+i:"")+"}} declaration at a time")})};Jy.prototype={detach:function(){return this.fragment.detach()},find:function(t){return this.fragment.find(t)},findAll:function(t,e){return this.fragment.findAll(t,e)},findComponent:function(t){return this.fragment.findComponent(t)},findAllComponents:function(t,e){return this.fragment.findAllComponents(t,e)},findNextNode:function(){return this.containerFragment.findNextNode(this)},firstNode:function(){return this.fragment.firstNode()},getValue:function(t){return this.fragment.getValue(t)},render:function(){return this.fragment.render()},unbind:function(){this.fragment.unbind()},unrender:function(t){this.fragment.unrender(t),V(this.component.yielders[this.name],this)},rebind:function(t,e){this.fragment.rebind(t,e)},toString:function(){return this.fragment.toString()}};var t_=Jy,e_=function(t){this.declaration=t.template.a};e_.prototype={init:Ps,render:Ps,unrender:Ps,teardown:Ps,toString:function(){return""}};var n_=e_,i_=So,r_=ko,a_=Ao,o_=Co,s_=Mo,u_=Lo,c_=function(t){this.init(t)};c_.prototype={bubble:gf,detach:mf,find:vf,findAll:yf,findAllComponents:_f,findComponent:xf,findNextNode:bf,firstNode:wf,getArgsList:Tf,getNode:kf,getValue:Af,init:i_,rebind:r_,registerIndexRef:function(t){var e=this.registeredIndexRefs;-1===e.indexOf(t)&&e.push(t)},render:a_,toString:o_,unbind:s_,unregisterIndexRef:function(t){var e=this.registeredIndexRefs;e.splice(e.indexOf(t),1)},unrender:u_};var l_,h_,d_=c_,f_=Oo,p_=["template","partials","components","decorators","events"],g_=new Js("reset"),m_=function(t,e){function n(e,i,r){r&&r.partials[t]||e.forEach(function(e){e.type===$c&&e.getPartialName()===t&&i.push(e),e.fragment&&n(e.fragment.items,i,r),a(e.fragments)?n(e.fragments,i,r):a(e.items)?n(e.items,i,r):e.type===tl&&e.instance&&n(e.instance.fragment.items,i,e.instance),e.type===Xc&&(a(e.attributes)&&n(e.attributes,i,r),a(e.conditionalAttributes)&&n(e.conditionalAttributes,i,r))})}var i,r=[];return n(this.fragment.items,r),this.partials[t]=e,i=du.start(this,!0),r.forEach(function(e){e.value=void 0,e.setValue(t)}),du.end(),i},v_=Ro,y_=pc("reverse"),__=Io,x_=pc("shift"),b_=pc("sort"),w_=pc("splice"),S_=No,T_=Fo,k_=new Js("teardown"),A_=Go,C_=Yo,P_=Ho,E_=new Js("unrender"),M_=pc("unshift"),D_=zo,L_=new Js("update"),O_=Bo,R_={add:qs,animate:yu,detach:xu,find:wu,findAll:Du,findAllComponents:Lu,findComponent:Ou,findContainer:Ru,findParent:Iu,fire:ju,get:Gu,insert:Hu,merge:Bu,observe:ac,observeOnce:oc,off:cc,on:lc,once:hc,pop:gc,push:mc,render:wc,reset:f_,resetPartial:m_,resetTemplate:v_,reverse:y_,set:__,shift:x_,sort:b_,splice:w_,subtract:S_,teardown:T_,toggle:A_,toHTML:C_,toHtml:C_,unrender:P_,unshift:M_,update:D_,updateModel:O_},I_=function(t,e,n){return n||Wo(t,e)?function(){var n,i="_super"in this,r=this._super;return this._super=e,n=t.apply(this,arguments),i&&(this._super=r),n}:t},V_=qo,N_=Zo,F_=function(t){var e,n,i={};return t&&(e=t._ractive)?(i.ractive=e.root,i.keypath=e.keypath.str,i.index={},(n=jf(e.proxy.parentFragment))&&(i.index=jf.resolve(n)),i):i};l_=function(t){if(!(this instanceof l_))return new l_(t);Ny(this,t)},h_={DEBUG:{writable:!0,value:!0},DEBUG_PROMISES:{writable:!0,value:!0},extend:{value:N_},getNodeInfo:{value:F_},parse:{value:zd},Promise:{value:iu},svg:{value:rs},magic:{value:ns},VERSION:{value:"0.7.3"},adaptors:{writable:!0,value:{}},components:{writable:!0,value:{}},decorators:{writable:!0,value:{}},easing:{writable:!0,value:cs},events:{writable:!0,value:{}},interpolators:{writable:!0,value:Vs},partials:{writable:!0,value:{}},transitions:{writable:!0,value:{}}},bs(l_,h_),l_.prototype=i(R_,us),l_.prototype.constructor=l_,l_.defaults=l_.prototype;if("function"!=typeof Date.now||"function"!=typeof String.prototype.trim||"function"!=typeof Object.keys||"function"!=typeof Array.prototype.indexOf||"function"!=typeof Array.prototype.forEach||"function"!=typeof Array.prototype.map||"function"!=typeof Array.prototype.filter||"undefined"!=typeof window&&"function"!=typeof window.addEventListener)throw new Error("It looks like you're attempting to use Ractive.js in an older browser. You'll need to use one of the 'legacy builds' in order to continue - see http://docs.ractivejs.org/latest/legacy-builds for more information.");var j_=l_;return j_})},{}],20:[function(t,e,n){function i(t){var e;if("SELECT"===t.nodeName)t.focus(),e=t.value;else if("INPUT"===t.nodeName||"TEXTAREA"===t.nodeName){var n=t.hasAttribute("readonly");n||t.setAttribute("readonly",""),t.select(),t.setSelectionRange(0,t.value.length),n||t.removeAttribute("readonly"),e=t.value}else{t.hasAttribute("contenteditable")&&t.focus();var i=window.getSelection(),r=document.createRange();r.selectNodeContents(t),i.removeAllRanges(),i.addRange(r),e=i.toString()}return e}e.exports=i},{}],21:[function(t,e,n){function i(){}i.prototype={on:function(t,e,n){var i=this.e||(this.e={});return(i[t]||(i[t]=[])).push({fn:e,ctx:n}),this},once:function(t,e,n){function i(){r.off(t,i),e.apply(n,arguments)}var r=this;return i._=e,this.on(t,i,n)},emit:function(t){var e=[].slice.call(arguments,1),n=((this.e||(this.e={}))[t]||[]).slice(),i=0,r=n.length;for(i;i=0&&a0?0:s-1;return arguments.length<3&&(r=n[o?o[u]:u],u+=t),e(n,i,r,o,u,s)}}function i(t){return function(e,n,i){n=w(n,i);for(var r=C(e),a=t>0?0:r-1;a>=0&&a0?o=a>=0?a:Math.max(a+s,o):s=a>=0?Math.min(a+1,s):a+s+1;else if(n&&a&&s)return a=n(i,r),i[a]===r?a:-1;if(r!==r)return a=e(d.call(i,o,s),x.isNaN),a>=0?a+o:-1;for(a=t>0?o:s-1;a>=0&&a=0&&e<=A};x.each=x.forEach=function(t,e,n){e=b(e,n);var i,r;if(P(t))for(i=0,r=t.length;i=0},x.invoke=function(t,e){var n=d.call(arguments,2),i=x.isFunction(e);return x.map(t,function(t){var r=i?e:t[e];return null==r?r:r.apply(t,n)})},x.pluck=function(t,e){return x.map(t,x.property(e))},x.where=function(t,e){return x.filter(t,x.matcher(e))},x.findWhere=function(t,e){return x.find(t,x.matcher(e))},x.max=function(t,e,n){var i,r,a=-1/0,o=-1/0;if(null==e&&null!=t){t=P(t)?t:x.values(t);for(var s=0,u=t.length;sa&&(a=i)}else e=w(e,n),x.each(t,function(t,n,i){((r=e(t,n,i))>o||r===-1/0&&a===-1/0)&&(a=t,o=r)});return a},x.min=function(t,e,n){var i,r,a=1/0,o=1/0;if(null==e&&null!=t){t=P(t)?t:x.values(t);for(var s=0,u=t.length;si||void 0===n)return 1;if(ne?(o&&(clearTimeout(o),o=null),s=c,a=t.apply(i,r),o||(i=r=null)):o||!1===n.trailing||(o=setTimeout(u,l)),a}},x.debounce=function(t,e,n){var i,r,a,o,s,u=function(){var c=x.now()-o;c=0?i=setTimeout(u,e-c):(i=null,n||(s=t.apply(a,r),i||(a=r=null)))};return function(){a=this,r=arguments,o=x.now();var c=n&&!i;return i||(i=setTimeout(u,e)),c&&(s=t.apply(a,r),a=r=null),s}},x.wrap=function(t,e){return x.partial(e,t)},x.negate=function(t){return function(){return!t.apply(this,arguments)}},x.compose=function(){var t=arguments,e=t.length-1;return function(){for(var n=e,i=t[e].apply(this,arguments);n--;)i=t[n].call(this,i);return i}},x.after=function(t,e){return function(){if(--t<1)return e.apply(this,arguments)}},x.before=function(t,e){var n;return function(){return--t>0&&(n=e.apply(this,arguments)),t<=1&&(e=null),n}},x.once=x.partial(x.before,2);var L=!{toString:null}.propertyIsEnumerable("toString"),O=["valueOf","isPrototypeOf","toString","propertyIsEnumerable","hasOwnProperty","toLocaleString"];x.keys=function(t){if(!x.isObject(t))return[];if(m)return m(t);var e=[];for(var n in t)x.has(t,n)&&e.push(n);return L&&a(t,e),e},x.allKeys=function(t){if(!x.isObject(t))return[];var e=[];for(var n in t)e.push(n);return L&&a(t,e),e},x.values=function(t){for(var e=x.keys(t),n=e.length,i=Array(n),r=0;r":">",'"':""","'":"'","`":"`"},V=x.invert(I),N=function(t){var e=function(e){return t[e]},n="(?:"+x.keys(t).join("|")+")",i=RegExp(n),r=RegExp(n,"g");return function(t){return t=null==t?"":""+t,i.test(t)?t.replace(r,e):t}};x.escape=N(I),x.unescape=N(V),x.result=function(t,e,n){var i=null==t?void 0:t[e];return void 0===i&&(i=n),x.isFunction(i)?i.call(t):i};var F=0;x.uniqueId=function(t){var e=++F+"";return t?t+e:e},x.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};var j=/(.)^/,G={"'":"'","\\":"\\","\r":"r","\n":"n","\u2028":"u2028","\u2029":"u2029"},Y=/\\|'|\r|\n|\u2028|\u2029/g,H=function(t){return"\\"+G[t]};x.template=function(t,e,n){!e&&n&&(e=n),e=x.defaults({},e,x.templateSettings);var i=RegExp([(e.escape||j).source,(e.interpolate||j).source,(e.evaluate||j).source].join("|")+"|$","g"),r=0,a="__p+='";t.replace(i,function(e,n,i,o,s){return a+=t.slice(r,s).replace(Y,H),r=s+e.length,n?a+="'+\n((__t=("+n+"))==null?'':_.escape(__t))+\n'":i?a+="'+\n((__t=("+i+"))==null?'':__t)+\n'":o&&(a+="';\n"+o+"\n__p+='"),e}),a+="';\n",e.variable||(a="with(obj||{}){\n"+a+"}\n"),a="var __t,__p='',__j=Array.prototype.join,print=function(){__p+=__j.call(arguments,'');};\n"+a+"return __p;\n";try{var o=new Function(e.variable||"obj","_",a)}catch(t){throw t.source=a,t}var s=function(t){return o.call(this,t,x)};return s.source="function("+(e.variable||"obj")+"){\n"+a+"}",s},x.chain=function(t){var e=x(t);return e._chain=!0,e};var z=function(t,e){return t._chain?x(e).chain():e};x.mixin=function(t){x.each(x.functions(t),function(e){var n=x[e]=t[e];x.prototype[e]=function(){var t=[this._wrapped];return h.apply(t,arguments),z(this,n.apply(x,t))}})},x.mixin(x),x.each(["pop","push","reverse","shift","sort","splice","unshift"],function(t){var e=u[t];x.prototype[t]=function(){var n=this._wrapped;return e.apply(n,arguments),"shift"!==t&&"splice"!==t||0!==n.length||delete n[0],z(this,n)}}),x.each(["concat","join","slice"],function(t){var e=u[t];x.prototype[t]=function(){return z(this,e.apply(this._wrapped,arguments))}}),x.prototype.value=function(){return this._wrapped},x.prototype.valueOf=x.prototype.toJSON=x.prototype.value,x.prototype.toString=function(){return""+this._wrapped},"function"==typeof define&&define.amd&&define("underscore",[],function(){return x})}).call(this)},{}],23:[function(t,e,n){!function(t,e,n){var i={messages:{required:"The %s field is required.",matches:"The %s field does not match the %s field.",default:"The %s field is still set to default, please change.",valid_email:"The %s field must contain a valid email address.",valid_emails:"The %s field must contain all valid email addresses.",min_length:"The %s field must be at least %s characters in length.",max_length:"The %s field must not exceed %s characters in length.",exact_length:"The %s field must be exactly %s characters in length.",greater_than:"The %s field must contain a number greater than %s.",less_than:"The %s field must contain a number less than %s.",alpha:"The %s field must only contain alphabetical characters.",alpha_numeric:"The %s field must only contain alpha-numeric characters.",alpha_dash:"The %s field must only contain alpha-numeric characters, underscores, and dashes.",numeric:"The %s field must contain only numbers.",integer:"The %s field must contain an integer.",decimal:"The %s field must contain a decimal number.",is_natural:"The %s field must contain only positive numbers.",is_natural_no_zero:"The %s field must contain a number greater than zero.",valid_ip:"The %s field must contain a valid IP.",valid_base64:"The %s field must contain a base64 string.",valid_credit_card:"The %s field must contain a valid credit card number.",is_file_type:"The %s field must contain only %s files.",valid_url:"The %s field must contain a valid URL.",greater_than_date:"The %s field must contain a more recent date than %s.",less_than_date:"The %s field must contain an older date than %s.",greater_than_or_equal_date:"The %s field must contain a date that's at least as recent as %s.",less_than_or_equal_date:"The %s field must contain a date that's %s or older."},callback:function(t){}},r=/^(.+?)\[(.+)\]$/,a=/^[0-9]+$/,o=/^\-?[0-9]+$/,s=/^\-?[0-9]*\.?[0-9]+$/,u=/^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/,c=/^[a-z]+$/i,l=/^[a-z0-9]+$/i,h=/^[a-z0-9_\-]+$/i,d=/^[0-9]+$/i,f=/^[1-9][0-9]*$/i,p=/^((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){3}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})$/i,g=/[^a-zA-Z0-9\/\+=]/i,m=/^[\d\-\s]+$/,v=/^((http|https):\/\/(\w+:{0,1}\w*@)?(\S+)|)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?$/,y=/\d{4}-\d{1,2}-\d{1,2}/,_=function(t,e,n){this.callback=n||i.callback,this.errors=[],this.fields={},this.form=this._formByNameOrNode(t)||{},this.messages={},this.handlers={},this.conditionals={};for(var r=0,a=e.length;r0)||"radio"!==t[0].type&&"checkbox"!==t[0].type)return t[e];for(n=0,elementLength=t.length;n0?i[0].type:i.type,n.value=x(i,"value"),n.checked=x(i,"checked"),n.depends&&"function"==typeof n.depends?n.depends.call(this,n)&&this._validateField(n):n.depends&&"string"==typeof n.depends&&this.conditionals[n.depends]?this.conditionals[n.depends].call(this,n)&&this._validateField(n):this._validateField(n))}return"function"==typeof this.callback&&this.callback(this.errors,t),this.errors.length>0&&(t&&t.preventDefault?t.preventDefault():event&&(event.returnValue=!1)),!0},_.prototype._validateField=function(t){var e,n,a=t.rules.split("|"),o=t.rules.indexOf("required"),s=!t.value||""===t.value||void 0===t.value;for(e=0,ruleLength=a.length;e=parseInt(e,10)},max_length:function(t,e){return!!a.test(e)&&t.value.length<=parseInt(e,10)},exact_length:function(t,e){return!!a.test(e)&&t.value.length===parseInt(e,10)},greater_than:function(t,e){return!!s.test(t.value)&&parseFloat(t.value)>parseFloat(e)},less_than:function(t,e){return!!s.test(t.value)&&parseFloat(t.value)=0;a--){var o=r.charAt(a);n=parseInt(o,10),i&&(n*=2)>9&&(n-=9),e+=n,i=!i}return e%10==0},is_file_type:function(t,e){if("file"!==t.type)return!0;var n=t.value.substr(t.value.lastIndexOf(".")+1),i=e.split(","),r=!1,a=0,o=i.length;for(a;ai},less_than_date:function(t,e){var n=this._getValidDate(t.value),i=this._getValidDate(e);return!(!i||!n)&&n=i},less_than_or_equal_date:function(t,e){var n=this._getValidDate(t.value),i=this._getValidDate(e);return!(!i||!n)&&n<=i}},t.FormValidator=_}(window,document),void 0!==e&&e.exports&&(e.exports=FormValidator)},{}],24:[function(t,e,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});n.DiscountPolicyTemplate='\n
\n

{{ icTitle }}

\n
\n \n {{#searchText}}{{/}}\n
\n
\n \n
\n {{#if showAddPolicyForm}}\n
\n \n

Add a new discount policy

\n
\n
\n
\n \n \n \n {{#newDiscountPolicy.errormsg.title}}

{{ newDiscountPolicy.errormsg.title }}

{{/}}\n
\n\n
\n

What type of discount?

\n \n \n
\n\n {{#if newDiscountPolicy.is_price_based == 0}}\n
\n

How is this discount going to be availed?

\n \n \n
\n {{/if}}\n\n {{#if newDiscountPolicy.is_price_based == 1}}\n
\n \n \n \n {{#newDiscountPolicy.errormsg.amount}}

{{ newDiscountPolicy.errormsg.amount }}

{{/}}\n
\n
\n
\n

Special price start date

\n \n \n {{#newDiscountPolicy.errormsg.start_at}}

{{ newDiscountPolicy.errormsg.start_at }}

{{/}}\n
\n
\n

Special price end date

\n \n \n {{#newDiscountPolicy.errormsg.end_at}}

{{ newDiscountPolicy.errormsg.end_at }}

{{/}}\n
\n
\n
\n

What is the discount for?

\n \n {{#newDiscountPolicy.errormsg.items}}

{{ newDiscountPolicy.errormsg.items }}

{{/}}\n
\n {{else}}\n
\n \n \n \n {{#newDiscountPolicy.errormsg.percentage}}

{{ newDiscountPolicy.errormsg.percentage }}

{{/}}\n
\n

What is the discount for?

\n
\n \n {{#newDiscountPolicy.errormsg.items}}

{{ newDiscountPolicy.errormsg.items }}

{{/}}\n
\n {{/if}}\n\n {{#if newDiscountPolicy.discount_type == 0}}\n
\n \n \n \n {{#newDiscountPolicy.errormsg.item_quantity_min}}

{{ newDiscountPolicy.errormsg.item_quantity_min }}

{{/}}\n
\n

For Automatic discounts, minimum number of tickets user needs to buy to avail this discount.
e.g. Automatic discount to be applied for a booking of 5 conference tickets or more, we would have to set this field to 5

\n {{else}}\n
\n \n \n \n {{#newDiscountPolicy.errormsg.discount_code_base}}

{{ newDiscountPolicy.errormsg.discount_code_base }}

{{/}}\n
\n

Discount code base is for generating coupons in bulk
e.g. \'hasgeek-volunteer\'

\n\n
\n \n \n \n {{#newDiscountPolicy.errormsg.bulk_coupon_usage_limit}}

{{ newDiscountPolicy.errormsg.bulk_coupon_usage_limit }}

{{/}}\n
\n

Specify the number of times each bulk coupon can be used

\n {{/if}}\n\n \n\n
\n \n \n
\n

{{{ newDiscountPolicy.errorMsg }}}

\n \n
\n
\n {{/if}}\n\n {{#if discountPolicies}}\n
\n {{#discountPolicies}}\n
\n
\n

{{ title }}

\n
\n {{#if !showPolicyForm && !showCouponForm}}{{/if}}\n
\n
\n
\n {{#if !showPolicyForm && !showCouponForm}}\n
\n

Discount type:

\n

{{ discount_type }}

\n\n {{#if is_price_based}}\n

Discounted price:

\n

{{ formatToIndianRupee(price_details.amount) }}

\n {{else}}\n

Discount rate:

\n

{{ percentage }}%

\n {{/if}}\n\n {{#if discount_type == "Automatic"}}\n

Minimum number of a particular item that needs to be
bought for this discount to apply:

\n

{{ item_quantity_min }}

\n {{else}}\n {{#if discount_code_base}}\n

Discount code base:

\n

{{ discount_code_base }}

\n {{/if}}\n

Number of times each bulk coupon can be used:

\n

{{ bulk_coupon_usage_limit }}

\n {{/if}}\n\n {{#if dp_items}}\n

This discount policy applies to:

\n
    \n {{#dp_items:item}}\n
  1. {{ dp_items[item].title }}
  2. \n {{/}}\n
\n {{/if}}\n\n {{#if discount_type == "Coupon based"}}\n \n \n

{{{ loadingCouponErrorMsg }}}

\n {{/if}}\n
\n {{elseif showPolicyForm}}\n
\n

Edit

\n
\n \n
\n \n \n \n {{#errormsg.title}}

{{ errormsg.title }}

{{/}}\n
\n\n {{#if is_price_based}}\n \n {{#price_details}}\n
\n \n \n \n {{#errormsg.amount}}

{{ errormsg.amount }}

{{/}}\n
\n
\n

Price start date

\n \n \n {{#errormsg.start_at}}

{{ errormsg.start_at }}

{{/}}\n
\n
\n

Price end date

\n \n \n {{#errormsg.end_at}}

{{ errormsg.end_at }}

{{/}}\n
\n\n {{/}}\n {{else}}\n \n
\n \n \n \n {{#errormsg.percentage}}

{{ errormsg.percentage }}

{{/}}\n
\n\n {{/if}}\n\n {{#if discount_type == "Automatic"}}\n \n
\n \n \n \n {{#errormsg.item_quantity_min}}

{{ errormsg.item_quantity_min }}

{{/}}\n
\n {{else}}\n \n
\n \n \n \n {{#errormsg.discount_code_base}}

{{ errormsg.discount_code_base }}

{{/}}\n
\n

Discount coupon prefix is for generating bulk coupons
Eg:- \'hasgeek-volunteer\'

\n
\n \n \n \n {{#errormsg.bulk_coupon_usage_limit}}

{{ errormsg.item_quantity_min }}

{{/}}\n
\n

Specify the number of times each bulk coupon can be used

\n {{/if}}\n\n

What is the discount for?

\n
\n \n {{#errormsg.items}}

{{ errormsg.items }}

{{/}}\n
\n\n \n\n
\n \n \n
\n

{{{ errorMsg }}}

\n \n
\n {{elseif showCouponForm}}\n
\n

Generate coupon

\n
\n
\n \n \n \n {{#errormsg.count}}

{{ errormsg.count }}

{{/}}\n
\n\n {{#if count == 1}}\n
\n \n \n \n
\n

e.g. rootconf17speaker, kilter17mediapass

\n
\n \n \n \n {{#errormsg.usage_limit}}

{{ errormsg.usage_limit }}

{{/}}\n
\n {{/if}}\n\n \n\n
\n \n \n
\n

{{{ generateCouponErrorMsg }}}

\n \n
\n {{/if}}\n
\n\n \n\n \n\n
\n {{/}}\n {{#if paginated}}\n
\n \n
\n {{/if}}\n
\n {{else}}\n

Currently no discount policies.

\n {{/if}}\n
\n'},{}],25:[function(t,e,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0}) -;n.OrderTemplate='\n
\n

{{ icTitle }}

\n {{#if orders}}\n
\n \n
\n
\n \n \n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n {{#orders:order}}\n \n \n \n \n \n \n \n \n \n \n \n \n \n {{#show_order}}\n
\n \n

Order Invoice No: {{invoice_no}}

\n
\n {{#line_items:line_item}}\n
\n
\n
\n

{{ title }}

\n
\n
\n
\n
\n

id: {{ id }}

\n

Base amount: {{ formatToIndianRupee(base_amount) }}

\n

Discounted amount: {{ formatToIndianRupee(discounted_amount) }}

\n

Final amount: {{ formatToIndianRupee(final_amount) }}

\n {{#discount_policy}}

Discount policy: {{ discount_policy }}{{/}}\n {{#discount_coupon}}

Discount coupon: {{ discount_coupon }}{{/}}\n {{#cancelled_at}}

Cancelled at: {{ formatDateTime(cancelled_at) }}

{{/}}\n {{#assignee_details}}\n

Fullname: {{ fullname }}

\n

Email: {{ email }}

\n

Phone: {{ phone }}

\n {{#details:key }}\n

{{ key }}: {{ . }}

\n {{/}}\n {{else}}\n

Not assigned

\n {{/}}\n {{#cancel_ticket_url && !cancelled_at}}\n

\n \n

\n

{{cancel_error}}

\n {{/}}\n
\n
\n
\n {{/}}\n
\n
\n {{/show_order}}\n {{/orders}}\n \n
#Receipt No.Buyer nameBuyer emailBuyer phoneAmountDateOrder idTransaction statusViewDetails

{{ invoice_no }}

{{ buyer_fullname }}

{{ buyer_email }}

{{ buyer_phone }}

{{ formatToIndianRupee(amount) }}

{{ formatDateTime(order_date) }}

{{ id }}

\n

\n {{#if amount === 0}}\n Free order\n {{else}}\n Paid order\n {{/if}}\n

\n

Line Items {{#if loading}}{{/if}}

\n

\n View Receipt\n View Assignee details\n

\n
\n
\n {{else}}\n

Currently no orders.

\n {{/if}}\n
\n'},{}],26:[function(t,e,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});n.OrgReportTemplate='\n
\n

{{ orgTitle }}

\n
\n
\n

Download reports

\n
\n
\n
\n
\n
\n

Report type

\n \n
\n
\n Download\n
\n
\n
\n
\n
\n
\n'},{}],27:[function(t,e,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});n.ReportTemplate='\n
\n

{{ icTitle }}

\n
\n
\n

Download reports

\n
\n
\n
\n
\n
\n

Report type

\n \n
\n
\n Download\n
\n
\n
\n
\n
\n
\n'},{}],28:[function(t,e,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});n.IndexTemplate='\n
\n
\n

Organizations

\n {{#orgs:org}}\n
\n
\n {{#title}}\n

{{ title }}

\n {{/title}}\n
\n
\n
\n \n

Organization id

\n

{{id}}

\n {{#details:k,v}}\n {{#if k !== \'logo\'}}\n

{{k}}

\n
{{{details[k]}}}
\n {{/if}}\n {{/details}}\n

Contact email

\n
{{contact_email}}
\n \n {{#infoMsg}}\n

{{ infoMsg }}

\n {{/}}\n
\n
\n {{/orgs}}\n
\n
\n'},{}],29:[function(t,e,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});n.TableTemplate='\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n {{#categories}}{{# { category: . } }}\n {{#category.items:index}}\n \n {{#if !index}}\n \n {{/if}}\n \n \n \n \n \n \n {{#if current_price !== "No active price"}}\n \n {{else}}\n \n {{/if}}\n \n \n {{/category.items}}\n {{/}}{{/categories}}\n \n \n \n \n \n \n \n
Category#TicketAvailableSoldFreeCancelledCurrent PriceNet Sales
{{ category.title }}{{ index + 1 }}{{ title }}{{ available }}{{ sold }} {{ free }} {{ cancelled }}{{ formatToIndianRupee(current_price) }}{{ current_price }}{{ formatToIndianRupee(net_sales) }}
Tickets booked{{ totalSelected }}
\n
\n
\n';n.AggChartTemplate='\n
\n
\n
\n
\n';n.ItemCollectionTemplate='\n
\n

{{ icTitle }}

\n
\n
\n
\n
\n

\n
\n
\n

Net sales

\n

{{ formatToIndianRupee(net_sales) }}

\n
\n
\n
\n
\n
\n
\n

\n
\n
\n

Today\'s sales

\n

{{ formatToIndianRupee(today_sales) }}

\n
\n
\n
\n
\n
\n
\n {{#if sales_delta > 0 }}\n

\n {{elseif sales_delta < 0 }}\n

\n {{else}}\n

\n {{/if}}\n
\n
\n

Sales since yesterday

\n

{{ sales_delta }}%

\n
\n
\n
\n
\n \n \n
\n'},{}],30:[function(t,e,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});n.orgTemplate='\n
\n

{{ orgTitle }}

\n {{#item_collections:item_collection}}\n
\n
\n {{#title}}\n

{{ title }}

\n {{/title}}\n
\n
\n
\n

Item collection id

\n

{{id}}

\n

Item collection description

\n
{{{description_html}}}
\n \n {{#infoMsg}}\n

{{ infoMsg }}

\n {{/}}\n
\n
\n {{/item_collections}}\n
\n'},{}],31:[function(t,e,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});n.SideBarTemplate='\n {{^sidebarHide}}\n \n
\n
\n {{#sidebarItems}}\n {{#url}}\n {{ title }}\n {{/}}\n {{/sidebarItems}}\n
\n
\n {{/}}\n'},{}],32:[function(t,e,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var i=t("../models/util.js"),r=i.Util,a=i.fetch,o=i.post,s=i.scrollToElement,u=i.getFormParameters,c=i.getCsrfToken,l=i.updateBrowserHistory,h=i.urlFor,d=i.setPageTitle,f=t("../templates/admin_discount_policy.html.js").DiscountPolicyTemplate,p=t("./sidebar.js").SideBarView,g={render:function(){var t=void 0===arguments[0]?{}:arguments[0],e=t.org_name,n=t.search,i=t.page,g=t.size,m=void 0;m=n?h("search",{scope_ns:"o",scope_id:e,resource:"discount_policy",root:!0,search:n,page:i,size:g}):h("index",{scope_ns:"o",scope_id:e,resource:"discount_policy",root:!0,page:i,size:g});var v={showForm:!0,hideForm:!1,showLoader:!0,hideLoader:!1,priceBasedDiscount:1,couponBasedDiscount:1,usageCount:1,empty:""};a({url:m}).done(function(t){var i=t.org_title,m=t.discount_policies,y=t.currency_symbol,x=t.total_pages,b=t.paginated,w=t.current_page,S=new Ractive({el:"#main-content-area",template:f,data:{orgName:e,orgTitle:i,discountPolicies:m,currency_symbol:y,paginated:b,totalPages:x,currentPage:w,size:20,showAddPolicyForm:!1,newDiscountPolicy:"",searchText:n,eventUrl:"",formValidationConfig:[{name:"title",rules:"required|max_length[250]"},{name:"is_price_based",rules:"required"},{name:"discount_type",rules:"required"},{name:"discount_code_base",rules:"required|max_length[20]"},{name:"bulk_coupon_usage_limit",rules:"required|numeric"},{name:"item_quantity_min",rules:"required|numeric"},{name:"amount",rules:"required|numeric"},{name:"start_at",rules:"required"},{name:"end_at",rules:"required"},{name:"percentage",rules:"required|numeric"},{name:"items",rules:"required"}],getDiscountedItems:function(t){return t.map(function(t){return t.id}).join(",")},getCsrfToken:function(t){var e=function(){return t.apply(this,arguments)};return e.toString=function(){return t.toString()},e}(function(){return c()}),formatToIndianRupee:function(t){return r.formatToIndianRupee(t)}},refresh:function(){var t=void 0===arguments[0]?"":arguments[0],n=void 0===arguments[1]?"":arguments[1],i=void 0===arguments[2]?"":arguments[2],r=void 0;r=t?h("search",{scope_ns:"o",scope_id:e,resource:"discount_policy",root:!0,search:t,page:n,size:i||S.get("size")}):h("index",{scope_ns:"o",scope_id:e,resource:"discount_policy",root:!0,page:n,size:i||S.get("size")}),NProgress.start(),a({url:r}).done(function(t){S.set({discountPolicies:t.discount_policies,paginated:t.paginated,totalPages:t.total_pages,currentPage:t.current_page,pages:_.range(1,t.total_pages+1)}),NProgress.done(),l(r)}),s("#"+S.el.id)},paginate:function(t,e){t.original.preventDefault(),S.refresh(this.get("searchText"),e,g)},clearSearchField:function(){S.set("searchText",v.empty)},addFormFields:function(t,n){if(t){var i=void 0,r=void 0,a=void 0;if(n){var o=S.get(n+".id");i="#add-item-"+o,r="#start-date-"+o,a="#end-date-"+o}else i="#add-item",r="#start-date",a="#end-date";$(i).select2({minimumInputLength:3,placeholder:{id:"-1",title:"Search tickets"},ajax:{url:h("index",{scope_ns:"o",scope_id:e,resource:"items",root:!0}),dataType:"json",data:function(t){return{search:t.term}},processResults:function(t){return{results:t.result.items}}},escapeMarkup:function(t){return t},templateResult:function(t){return"

"+t.title+"

"},templateSelection:function(t){return t.title}}),$(r).daterangepicker({singleDatePicker:!0,showDropdowns:!0,timePicker:!0,timePicker24Hour:!0,opens:"left",locale:{format:"YYYY-MM-DD H:mm"}}),$(a).daterangepicker({singleDatePicker:!0,showDropdowns:!0,timePicker:!0,timePicker24Hour:!0,opens:"left",locale:{format:"YYYY-MM-DD H:mm"}})}else{var s=void 0;if(n){s="#add-items-"+S.get(n+".id")}else s="#add-items";$(s).select2({minimumInputLength:3,multiple:!0,placeholder:"Search tickets",ajax:{url:h("index",{scope_ns:"o",scope_id:e,resource:"items",root:!0}),dataType:"json",data:function(t){return{search:t.term}},processResults:function(t){return{results:t.result.items}}},escapeMarkup:function(t){return t},templateResult:function(t){return"

"+t.title+"

"},templateSelection:function(t){return t.title}})}},showNewPolicyForm:function(t){S.set({showAddPolicyForm:v.showForm,"newDiscountPolicy.is_price_based":v.priceBasedDiscount,"newDiscountPolicy.discount_type":v.couponBasedDiscount}),S.addFormFields(S.get("newDiscountPolicy.is_price_based"))},onPolicyChange:function(t){S.set("newDiscountPolicy.is_price_based",parseInt(t.node.value,10)),S.addFormFields(S.get("newDiscountPolicy.is_price_based"))},onPolicyTypeChange:function(t){S.set("newDiscountPolicy.discount_type",t.node.value)},addNewPolicy:function(t){var n=new FormValidator("adding-new-policy-form",S.get("formValidationConfig"),function(t,n){if(n.preventDefault(),S.set("newDiscountPolicy.errormsg",v.empty),t.length>0)S.set("newDiscountPolicy.errormsg."+t[0].name,t[0].message);else{S.set({"newDiscountPolicy.errorMsg":v.empty,"newDiscountPolicy.creatingPolicy":v.showLoader});o({url:h("new",{scope_ns:"o",scope_id:e,resource:"discount_policy",root:!0}),data:u("#new-policy-form")}).done(function(t){S.set({discountPolicies:[t.result.discount_policy],searchText:S.get("newDiscountPolicy.title"),"newDiscountPolicy.creatingPolicy":v.hideLoader,newDiscountPolicy:v.empty}),S.hideNewPolicyForm()}).fail(function(t){var e=v.empty;if(4===t.readyState)if(500===t.status)e="Internal Server Error";else{var n=t.responseJSON.errors;for(var i in n)e+="

"+n[i]+"

"}else e="Unable to connect. Please try again.";S.set({"newDiscountPolicy.creatingPolicy":v.hideLoader,"newDiscountPolicy.errorMsg":e})})}});n.setMessage("required","Please fill out the this field"),n.setMessage("numeric","Please enter a numberic value")},hideNewPolicyForm:function(t){S.set("showAddPolicyForm",v.hideForm)},showEditPolicyForm:function(t){var e=t.keypath;S.set(e+".showPolicyForm",v.showForm),S.set(e+".errormsg",v.empty),S.addFormFields(S.get(e+".is_price_based"),e)},editPolicy:function(t){var e=t.keypath,n=t.context.id,i="edit-policy-form-"+n,r=new FormValidator(i,S.get("formValidationConfig"),function(t,i){if(i.preventDefault(),S.set(e+".errormsg",v.empty),t.length>0)S.set(e+".errormsg."+t[0].name,t[0].message);else{S.set(e+".editingPolicy",v.showLoader);var r="#policy-form-"+n;o({url:h("edit",{resource:"discount_policy",id:n,root:!0}),data:u(r)}).done(function(t){S.set(e+".editingPolicy",v.hideLoader),S.set(e,t.result.discount_policy),S.set(e+".showPolicyForm",v.hideForm),s("#dp-"+n)}).fail(function(t){var n=v.empty;if(4===t.readyState)if(500===t.status)n="Internal Server Error";else{var i=t.responseJSON.errors;for(var r in i)n+="

"+i[r]+"

"}else n="Unable to connect. Please try again.";S.set(e+".editingPolicy",v.hideLoader),S.set(e+".errorMsg",n)})}});r.setMessage("required","Please fill out the this field"),r.setMessage("numeric","Please enter a numberic value")},hideEditPolicyForm:function(t){var e=t.keypath;S.set(e+".showPolicyForm",v.hideForm)},showCouponForm:function(t){var e=t.keypath;S.set(e+".count",v.usageCount),S.set(e+".showCouponForm",v.showForm)},generateCoupon:function(t){var e=t.keypath,n=t.context.id,i=[{name:"count",rules:"required|numeric"},{name:"usage_limit",rules:"required|numeric"}],r="generate-coupon-form-"+n;new FormValidator(r,i,function(t,i){if(i.preventDefault(),S.set(e+".errormsg",v.empty),t.length>0)S.set(e+".errormsg."+t[0].name,t[0].message);else{var r="#new-coupon-"+n;S.set(e+".generatingCoupon",v.showLoader),S.set(e+".generateCouponErrorMsg",v.empty),o({url:h("new",{scope_ns:"discount_policy",scope_id:n,resource:"coupons",root:!0}),data:u(r)}).done(function(t){S.set(e+".coupons",t.result.coupons),S.set(e+".generatingCoupon",v.hideLoader),S.set("eventUrl",v.empty),$("#generated-coupons-"+n).modal("show"),new Clipboard(".copy-coupons")}).fail(function(t){var n=v.empty;if(4===t.readyState)if(500===t.status)n="Internal Server Error";else{var i=t.responseJSON.errors;for(var r in i)n+="

"+i[r]+"

"}else n="Unable to connect. Please try again.";S.set(e+".generatingCoupon",v.hideLoader),S.set(e+".generateCouponErrorMsg",n)})}}).setMessage("required","Please fill out the this field")},hideCouponForm:function(t){var e=t.keypath;S.set(e+".showCouponForm",v.hideForm)},getCouponList:function(t){t.original.preventDefault();var e=t.keypath,n=t.context.id;S.set(e+".loadingCoupons",v.showLoader),S.set(e+".loadingCouponErrorMsg",v.empty),a({url:h("index",{scope_ns:"discount_policy",scope_id:n,resource:"coupons",root:!0}),contentType:"application/json"}).done(function(t){S.set(e+".coupons",t.result.coupons),S.set(e+".loadingCoupons",v.hideLoader),$("#list-coupons-"+n).modal("show"),$("#coupons-list-"+n).footable(),new Clipboard(".copy-coupons-list")}).fail(function(t){var n=v.empty;n=4===t.readyState?"Internal Server Error":"Unable to connect. Please try again.",S.set(e+".loadingCoupons",v.hideLoader),S.set(e+".loadingCouponErrorMsg",n)})},oncomplete:function(){var t,e="";S.observe("searchText",function(n,i){n!==e&&(n.length>2?(window.clearTimeout(t),e=n,t=window.setTimeout(function(){S.refresh(n)},1e3)):0===n.length&&S.refresh())}),S.set("pages",_.range(1,S.get("totalPages")+1))}});p.render("discount-policies",{org_name:e,org_title:i}),d("Discount policies",i),NProgress.done(),window.addEventListener("popstate",function(t){NProgress.configure({showSpinner:!1}).start()})})}};n.DiscountPolicyView=g},{"../models/util.js":4,"../templates/admin_discount_policy.html.js":24,"./sidebar.js":40}],33:[function(t,e,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var i=t("../models/util.js"),r=i.Util,a=i.fetch,o=i.post,s=i.scrollToElement,u=i.urlFor,c=i.setPageTitle,l=t("../templates/admin_order.html.js").OrderTemplate,h=t("./sidebar.js").SideBarView,d={render:function(){var t=void 0===arguments[0]?{}:arguments[0],e=t.ic_id;a({url:u("index",{scope_ns:"ic",scope_id:e,resource:"orders",root:!0})}).done(function(t){var n=t.org_name,i=t.org_title,d=t.ic_title,f=t.orders,p=new Ractive({el:"#main-content-area",template:l,data:{icTitle:d,orders:f,formatDateTime:function(t){return r.formatDateTime(t)},formatToIndianRupee:function(t){return r.formatToIndianRupee(t)}}});h.render("orders",{org_name:n,org_title:i,ic_id:e,ic_title:d}),c("Orders",d),NProgress.done(),$("#orders-table").footable({breakpoints:{phone:600,tablet:768,desktop:1200,largescreen:1900}}),$("#orders-table").on("footable_filtering",function(t){var e=$("#filter-status").find(":selected").val();e&&e.length>0&&(t.filter+=t.filter&&t.filter.length>0?" "+e:e,t.clear=!t.filter)}),$("#filter-status").change(function(t){t.preventDefault(),$("#orders-table").trigger("footable_filter",{filter:$("#filter").val()})}),$("#search-form").on("keypress",function(t){if(13==t.which)return!1}),$("#orders-table").on("keydown",function(t){if(27==t.which)return p.set("orders.*.show_order",!1),!1}),p.on("showOrder",function(t){p.set("orders.*.show_order",!1),p.set(t.keypath+".loading",!0),NProgress.configure({showSpinner:!1}).start();var e=t.context.id;a({url:u("view",{resource:"order",id:e,root:!0})}).done(function(e){p.set(t.keypath+".line_items",e.line_items),p.set(t.keypath+".show_order",!0),NProgress.done(),p.set(t.keypath+".loading",!1);var n="#"+p.el.id;s(n)})}),p.on("hideOrder",function(t){p.set(t.keypath+".show_order",!1)}),p.on("cancelTicket",function(t,e){window.confirm("Are you sure you want to cancel this ticket?")&&(p.set(t.keypath+".cancel_error",""),p.set(t.keypath+".cancelling",!0),o({url:t.context.cancel_ticket_url}).done(function(e){p.set(t.keypath+".cancelled_at",e.result.cancelled_at),p.set(t.keypath+".cancelling",!1)}).fail(function(e){var n=void 0;n=4===e.readyState?500===e.status?"Server Error":JSON.parse(e.responseText).error_description:"Unable to connect. Please try again later.",p.set(t.keypath+".cancel_error",n),p.set(t.keypath+".cancelling",!1)}))}),window.addEventListener("popstate",function(t){NProgress.configure({showSpinner:!1}).start()})})}};n.OrderView=d},{"../models/util.js":4,"../templates/admin_order.html.js":25,"./sidebar.js":40}],34:[function(t,e,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var i=t("../models/util.js"),r=i.fetch,a=i.urlFor,o=i.setPageTitle,s=t("../templates/admin_org_report.html.js").OrgReportTemplate,u=t("./sidebar.js").SideBarView,c={render:function(){var t=void 0===arguments[0]?{}:arguments[0],e=t.org_name;r({url:a("index",{resource:"reports",scope_ns:"o",scope_id:e,root:!0})}).done(function(t){var n=t.org_title;new Ractive({el:"#main-content-area",template:s,data:{orgTitle:n,reportType:"invoices",reportsUrl:function(){var t=this.get("reportType");return a("index",{resource:t,scope_ns:"o",scope_id:e,ext:"csv",root:!0})},reportsFilename:function(){return e+"_"+this.get("reportType")+".csv"}}});u.render("org_reports",{org_name:e,org_title:n}),o("Organization reports",n),NProgress.done(),window.addEventListener("popstate",function(t){NProgress.configure({showSpinner:!1}).start()})})}};n.OrgReportView=c},{"../models/util.js":4,"../templates/admin_org_report.html.js":26,"./sidebar.js":40}],35:[function(t,e,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var i=t("../models/util.js"),r=i.fetch,a=i.urlFor,o=i.setPageTitle,s=t("../templates/admin_report.html.js").ReportTemplate,u=t("./sidebar.js").SideBarView,c={render:function(){var t=void 0===arguments[0]?{}:arguments[0],e=t.ic_id;r({url:a("index",{resource:"reports",scope_ns:"ic",scope_id:e,root:!0})}).done(function(t){var n=t.org_name,i=t.org_title,r=t.ic_name,c=t.ic_title;new Ractive({el:"#main-content-area",template:s,data:{icName:r,icTitle:c,reportType:"tickets",reportsUrl:function(){var t=this.get("reportType");return a("index",{resource:t,scope_ns:"ic",scope_id:e,ext:"csv",root:!0})},reportsFilename:function(){return this.get("icName")+"_"+this.get("reportType")+".csv"}}});u.render("reports",{org_name:n,org_title:i,ic_id:e,ic_title:c}),o("Reports",c),NProgress.done(),window.addEventListener("popstate",function(t){NProgress.configure({showSpinner:!1}).start()})})}};n.ReportView=c},{"../models/util.js":4,"../templates/admin_report.html.js":27,"./sidebar.js":40}],36:[function(t,e,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var i=t("../models/util.js"),r=i.fetch,a=i.urlFor,o=i.setPageTitle,s=(t("../models/index.js").IndexModel,t("../templates/index.html.js").IndexTemplate),u=t("./sidebar.js").SideBarView,c={render:function(){r({url:a("index",{root:!0})}).then(function(t){var e=t.orgs,n=new Ractive({el:"#main-content-area",template:s,data:{orgs:e}});u.hide(),o("Admin"),NProgress.done(),n.on("navigate",function(t,e){NProgress.configure({showSpinner:!1}).start(),eventBus.trigger("navigate",t.context.url)})}),window.addEventListener("popstate",function(t){NProgress.configure({showSpinner:!1}).start()})}};n.IndexView=c},{"../models/index.js":2,"../models/util.js":4,"../templates/index.html.js":28,"./sidebar.js":40}],37:[function(t,e,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var i=t("../models/util.js"),r=i.Util,a=i.fetch,o=i.urlFor,s=i.setPageTitle,u=t("../templates/item_collection.html.js"),c=u.TableTemplate,l=u.AggChartTemplate,h=u.ItemCollectionTemplate,d=t("./sidebar.js").SideBarView,f=Ractive.extend({isolated:!1,template:c,onItemsSelected:function(t,e){var n=this.parent.get("totalSelected");t.node.checked?this.parent.set("totalSelected",n+t.context[e]):this.parent.set("totalSelected",n-t.context[e])}}),p=Ractive.extend({template:l,format_columns:function(){var t=this.parent.get("date_item_counts"),e=this.parent.get("categories").reduce(function(t,e){return t.concat(e.items)},[]),n=this.parent.get("date_sales"),i=["x"],r={},a=["sales"] -;for(var o in t)!function(o){i.push(o),a.push(n[o]),e.forEach(function(e){r[e.id]||(r[e.id]=[]),t[o].hasOwnProperty(e.id)?r[e.id].push(t[o][e.id]):r[e.id].push(0)})}(o);var s=[i];return e.forEach(function(t){s.push([t.title].concat(r[t.id]))}),s.push(a),s},oncomplete:function(){var t=this,e=this.format_columns(),n=_.without(_.map(e,_.first),"x","sales");this.chart=c3.generate({data:{x:"x",columns:this.format_columns(),type:"bar",types:{sales:"line"},groups:[n],axes:{sales:"y2"}},bar:{width:{ratio:.5}},axis:{x:{type:"timeseries",tick:{format:"%d-%m"},label:"Date"},y:{label:"No. of tickets"},y2:{show:!0,label:"Sales"}}}),this.parent.on("data_update",function(){t.chart.load({columns:t.format_columns()})})}}),g={render:function(){var t=void 0===arguments[0]?{}:arguments[0],e=t.ic_id;a({url:o("view",{resource:"ic",id:e,root:!0})}).done(function(t){var n=t.org_name,i=t.org_title,a=t.ic_title,o=t.categories,u=t.date_item_counts,c=t.date_sales,l=t.today_sales,g=t.net_sales,m=t.sales_delta;new Ractive({el:"#main-content-area",template:h,data:{icTitle:a,categories:o,date_item_counts:u,date_sales:c,net_sales:g,sales_delta:m,today_sales:l,totalSelected:0,formatToIndianRupee:function(t){return r.formatToIndianRupee(t)}},components:{TableComponent:f,AggChartComponent:p}});d.render("dashboard",{org_name:n,org_title:i,ic_id:e,ic_title:a}),s(a),NProgress.done(),window.addEventListener("popstate",function(t){NProgress.configure({showSpinner:!1}).start()})})}};n.ItemCollectionView=g},{"../models/util.js":4,"../templates/item_collection.html.js":29,"./sidebar.js":40}],38:[function(t,e,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var i=t("../models/util.js"),r=i.fetch,a=i.urlFor,o=i.setPageTitle,s=t("../templates/org.html.js").orgTemplate,u=t("./sidebar.js").SideBarView,c={render:function(){var t=void 0===arguments[0]?{}:arguments[0],e=t.org_name;r({url:a("view",{resource:"o",id:e,root:!0})}).then(function(t){var n=(t.id,t.org_title),i=t.item_collections,r=new Ractive({el:"#main-content-area",template:s,data:{orgName:e,orgTitle:n,item_collections:i}});u.render("org",{org_name:e,org_title:n}),o(n),NProgress.done(),r.on("navigate",function(t,e){NProgress.configure({showSpinner:!1}).start(),eventBus.trigger("navigate",t.context.url)})}),window.addEventListener("popstate",function(t){NProgress.configure({showSpinner:!1}).start()})}};n.OrgView=c},{"../models/util.js":4,"../templates/org.html.js":30,"./sidebar.js":40}],39:[function(t,e,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var i=t("./index.js").IndexView,r=t("./org.js").OrgView,a=t("./admin_org_report.js").OrgReportView,o=t("./admin_discount_policy.js").DiscountPolicyView,s=t("./item_collection.js").ItemCollectionView,u=t("./admin_order.js").OrderView,c=t("./admin_report.js").ReportView,l=Backbone.Router.extend({url_root:"/admin/",routes:{"":"index","o/:org_name":"org","o/:org_name/reports":"org_report","o/:org_name/discount_policy":"discount_policy","o/:org_name/discount_policy?:params":"discount_policy","ic/:ic_id":"item_collection","ic/:ic_id/orders":"order","ic/:ic_id/reports":"report"},index:function(){i.render()},org:function(t){r.render({org_name:t})},org_report:function(t){a.render({org_name:t})},discount_policy:function(t){var e=void 0===arguments[1]?{}:arguments[1],n=e.search,i=e.page,r=e.size;o.render({org_name:t,search:n,page:i,size:r})},item_collection:function(t){s.render({ic_id:t})},order:function(t){u.render({ic_id:t})},report:function(t){c.render({ic_id:t})},_extractParameters:function(t,e){var n=t.exec(e).slice(1);if(n[n.length-1]){var i=n[n.length-1].split("&"),r={};i.forEach(function(t){if(t){var e=t.split("=");r[e[0]]=e[1]}}),n[n.length-1]=r}return n}});n.Router=l},{"./admin_discount_policy.js":32,"./admin_order.js":33,"./admin_org_report.js":34,"./admin_report.js":35,"./index.js":36,"./item_collection.js":37,"./org.js":38}],40:[function(t,e,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var i=t("../models/sidebar.js").SideBarModel,r=t("../templates/sidebar.html.js").SideBarTemplate,a={init:function(t,e){this.on=!0,this.ractive=new Ractive({el:"#sidebar",template:r,data:{sidebarMobileOn:!1,sidebarItems:i.getItems(e),activeItem:t,sidebarHide:!1},toggle:function(t){t.original.preventDefault(),this.set("sidebarMobileOn",!this.get("sidebarMobileOn"))},navigate:function(t){t.context.view!==this.get("activeItem")&&(NProgress.configure({showSpinner:!1}).start(),eventBus.trigger("navigate",t.context.url))}})},render:function(t,e){this.on?this.ractive.set({sidebarItems:i.getItems(e),activeItem:t,sidebarHide:!1,sidebarMobileOn:!1}):this.init(t,e)},hide:function(){this.on&&this.ractive.set("sidebarHide",!0)}};n.SideBarView=a},{"../models/sidebar.js":3,"../templates/sidebar.html.js":31}]},{},[1]); \ No newline at end of file +;n.OrderTemplate='\n
\n

{{ icTitle }}

\n {{#if orders}}\n
\n \n
\n
\n \n \n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n {{#orders:order}}\n \n \n \n \n \n \n \n \n \n \n \n \n \n {{#show_order}}\n
\n \n

Order Invoice No: {{invoice_no}}

\n
\n {{#line_items:line_item}}\n
\n
\n
\n

{{ title }}

\n
\n
\n
\n
\n

id: {{ id }}

\n

Base amount: {{ formatToIndianRupee(base_amount) }}

\n

Discounted amount: {{ formatToIndianRupee(discounted_amount) }}

\n

Final amount: {{ formatToIndianRupee(final_amount) }}

\n {{#discount_policy}}

Discount policy: {{ discount_policy }}{{/}}\n {{#discount_coupon}}

Discount coupon: {{ discount_coupon }}{{/}}\n {{#cancelled_at}}

Cancelled at: {{ formatDateTime(cancelled_at) }}

{{/}}\n {{#assignee_details}}\n

Fullname: {{ fullname }}

\n

Email: {{ email }}

\n

Phone: {{ phone }}

\n {{#details:key }}\n

{{ key }}: {{ . }}

\n {{/}}\n {{else}}\n

Not assigned

\n {{/}}\n {{#cancel_ticket_url && !cancelled_at}}\n

\n \n

\n

{{cancel_error}}

\n {{/}}\n
\n
\n
\n {{/}}\n
\n
\n {{/show_order}}\n {{/orders}}\n \n
#Receipt No.Buyer nameBuyer emailBuyer phoneAmountDateOrder idTransaction statusViewDetails

{{ invoice_no }}

{{ buyer_fullname }}

{{ buyer_email }}

{{ buyer_phone }}

{{ formatToIndianRupee(amount) }}

{{ formatDateTime(order_date) }}

{{ id }}

\n

\n {{#if amount === 0}}\n Free order\n {{else}}\n Paid order\n {{/if}}\n

\n

Line Items {{#if loading}}{{/if}}

\n

\n View Receipt\n View Assignee details\n

\n
\n
\n {{else}}\n

Currently no orders.

\n {{/if}}\n
\n'},{}],26:[function(t,e,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});n.OrgReportTemplate='\n
\n

{{ orgTitle }}

\n
\n
\n

Download reports

\n
\n
\n
\n
\n
\n

Report type

\n \n {{#if reportType == "settlements"}}\n

\n \n

\n {{/if}}\n
\n
\n Download\n
\n
\n
\n
\n
\n
\n'},{}],27:[function(t,e,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});n.ReportTemplate='\n
\n

{{ icTitle }}

\n
\n
\n

Download reports

\n
\n
\n
\n
\n
\n

Report type

\n \n
\n
\n Download\n
\n
\n
\n
\n
\n
\n'},{}],28:[function(t,e,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});n.IndexTemplate='\n
\n
\n

Organizations

\n {{#orgs:org}}\n
\n
\n {{#title}}\n

{{ title }}

\n {{/title}}\n
\n
\n
\n \n

Organization id

\n

{{id}}

\n {{#details:k,v}}\n {{#if k !== \'logo\'}}\n

{{k}}

\n
{{{details[k]}}}
\n {{/if}}\n {{/details}}\n

Contact email

\n
{{contact_email}}
\n \n {{#infoMsg}}\n

{{ infoMsg }}

\n {{/}}\n
\n
\n {{/orgs}}\n
\n
\n'},{}],29:[function(t,e,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});n.TableTemplate='\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n {{#categories}}{{# { category: . } }}\n {{#category.items:index}}\n \n {{#if !index}}\n \n {{/if}}\n \n \n \n \n \n \n {{#if current_price !== "No active price"}}\n \n {{else}}\n \n {{/if}}\n \n \n {{/category.items}}\n {{/}}{{/categories}}\n \n \n \n \n \n \n \n
Category#TicketAvailableSoldFreeCancelledCurrent PriceNet Sales
{{ category.title }}{{ index + 1 }}{{ title }}{{ available }}{{ sold }} {{ free }} {{ cancelled }}{{ formatToIndianRupee(current_price) }}{{ current_price }}{{ formatToIndianRupee(net_sales) }}
Tickets booked{{ totalSelected }}
\n
\n
\n';n.AggChartTemplate='\n
\n
\n
\n
\n';n.ItemCollectionTemplate='\n
\n

{{ icTitle }}

\n
\n
\n
\n
\n

\n
\n
\n

Net sales

\n

{{ formatToIndianRupee(net_sales) }}

\n
\n
\n
\n
\n
\n
\n

\n
\n
\n

Today\'s sales

\n

{{ formatToIndianRupee(today_sales) }}

\n
\n
\n
\n
\n
\n
\n {{#if sales_delta > 0 }}\n

\n {{elseif sales_delta < 0 }}\n

\n {{else}}\n

\n {{/if}}\n
\n
\n

Sales since yesterday

\n

{{ sales_delta }}%

\n
\n
\n
\n
\n \n \n
\n'},{}],30:[function(t,e,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});n.orgTemplate='\n
\n

{{ orgTitle }}

\n {{#item_collections:item_collection}}\n
\n
\n {{#title}}\n

{{ title }}

\n {{/title}}\n
\n
\n
\n

Item collection id

\n

{{id}}

\n

Item collection description

\n
{{{description_html}}}
\n \n {{#infoMsg}}\n

{{ infoMsg }}

\n {{/}}\n
\n
\n {{/item_collections}}\n
\n'},{}],31:[function(t,e,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});n.SideBarTemplate='\n {{^sidebarHide}}\n \n
\n
\n {{#sidebarItems}}\n {{#url}}\n {{ title }}\n {{/}}\n {{/sidebarItems}}\n
\n
\n {{/}}\n'},{}],32:[function(t,e,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var i=t("../models/util.js"),r=i.Util,a=i.fetch,o=i.post,s=i.scrollToElement,u=i.getFormParameters,c=i.getCsrfToken,l=i.updateBrowserHistory,h=i.urlFor,d=i.setPageTitle,f=t("../templates/admin_discount_policy.html.js").DiscountPolicyTemplate,p=t("./sidebar.js").SideBarView,g={render:function(){var t=void 0===arguments[0]?{}:arguments[0],e=t.org_name,n=t.search,i=t.page,g=t.size,m=void 0;m=n?h("search",{scope_ns:"o",scope_id:e,resource:"discount_policy",root:!0,search:n,page:i,size:g}):h("index",{scope_ns:"o",scope_id:e,resource:"discount_policy",root:!0,page:i,size:g});var v={showForm:!0,hideForm:!1,showLoader:!0,hideLoader:!1,priceBasedDiscount:1,couponBasedDiscount:1,usageCount:1,empty:""};a({url:m}).done(function(t){var i=t.org_title,m=t.discount_policies,y=t.currency_symbol,x=t.total_pages,b=t.paginated,w=t.current_page,S=new Ractive({el:"#main-content-area",template:f,data:{orgName:e,orgTitle:i,discountPolicies:m,currency_symbol:y,paginated:b,totalPages:x,currentPage:w,size:20,showAddPolicyForm:!1,newDiscountPolicy:"",searchText:n,eventUrl:"",formValidationConfig:[{name:"title",rules:"required|max_length[250]"},{name:"is_price_based",rules:"required"},{name:"discount_type",rules:"required"},{name:"discount_code_base",rules:"required|max_length[20]"},{name:"bulk_coupon_usage_limit",rules:"required|numeric"},{name:"item_quantity_min",rules:"required|numeric"},{name:"amount",rules:"required|numeric"},{name:"start_at",rules:"required"},{name:"end_at",rules:"required"},{name:"percentage",rules:"required|numeric"},{name:"items",rules:"required"}],getDiscountedItems:function(t){return t.map(function(t){return t.id}).join(",")},getCsrfToken:function(t){var e=function(){return t.apply(this,arguments)};return e.toString=function(){return t.toString()},e}(function(){return c()}),formatToIndianRupee:function(t){return r.formatToIndianRupee(t)}},refresh:function(){var t=void 0===arguments[0]?"":arguments[0],n=void 0===arguments[1]?"":arguments[1],i=void 0===arguments[2]?"":arguments[2],r=void 0;r=t?h("search",{scope_ns:"o",scope_id:e,resource:"discount_policy",root:!0,search:t,page:n,size:i||S.get("size")}):h("index",{scope_ns:"o",scope_id:e,resource:"discount_policy",root:!0,page:n,size:i||S.get("size")}),NProgress.start(),a({url:r}).done(function(t){S.set({discountPolicies:t.discount_policies,paginated:t.paginated,totalPages:t.total_pages,currentPage:t.current_page,pages:_.range(1,t.total_pages+1)}),NProgress.done(),l(r)}),s("#"+S.el.id)},paginate:function(t,e){t.original.preventDefault(),S.refresh(this.get("searchText"),e,g)},clearSearchField:function(){S.set("searchText",v.empty)},addFormFields:function(t,n){if(t){var i=void 0,r=void 0,a=void 0;if(n){var o=S.get(n+".id");i="#add-item-"+o,r="#start-date-"+o,a="#end-date-"+o}else i="#add-item",r="#start-date",a="#end-date";$(i).select2({minimumInputLength:3,placeholder:{id:"-1",title:"Search tickets"},ajax:{url:h("index",{scope_ns:"o",scope_id:e,resource:"items",root:!0}),dataType:"json",data:function(t){return{search:t.term}},processResults:function(t){return{results:t.result.items}}},escapeMarkup:function(t){return t},templateResult:function(t){return"

"+t.title+"

"},templateSelection:function(t){return t.title}}),$(r).daterangepicker({singleDatePicker:!0,showDropdowns:!0,timePicker:!0,timePicker24Hour:!0,opens:"left",locale:{format:"YYYY-MM-DD H:mm"}}),$(a).daterangepicker({singleDatePicker:!0,showDropdowns:!0,timePicker:!0,timePicker24Hour:!0,opens:"left",locale:{format:"YYYY-MM-DD H:mm"}})}else{var s=void 0;if(n){s="#add-items-"+S.get(n+".id")}else s="#add-items";$(s).select2({minimumInputLength:3,multiple:!0,placeholder:"Search tickets",ajax:{url:h("index",{scope_ns:"o",scope_id:e,resource:"items",root:!0}),dataType:"json",data:function(t){return{search:t.term}},processResults:function(t){return{results:t.result.items}}},escapeMarkup:function(t){return t},templateResult:function(t){return"

"+t.title+"

"},templateSelection:function(t){return t.title}})}},showNewPolicyForm:function(t){S.set({showAddPolicyForm:v.showForm,"newDiscountPolicy.is_price_based":v.priceBasedDiscount,"newDiscountPolicy.discount_type":v.couponBasedDiscount}),S.addFormFields(S.get("newDiscountPolicy.is_price_based"))},onPolicyChange:function(t){S.set("newDiscountPolicy.is_price_based",parseInt(t.node.value,10)),S.addFormFields(S.get("newDiscountPolicy.is_price_based"))},onPolicyTypeChange:function(t){S.set("newDiscountPolicy.discount_type",t.node.value)},addNewPolicy:function(t){var n=new FormValidator("adding-new-policy-form",S.get("formValidationConfig"),function(t,n){if(n.preventDefault(),S.set("newDiscountPolicy.errormsg",v.empty),t.length>0)S.set("newDiscountPolicy.errormsg."+t[0].name,t[0].message);else{S.set({"newDiscountPolicy.errorMsg":v.empty,"newDiscountPolicy.creatingPolicy":v.showLoader});o({url:h("new",{scope_ns:"o",scope_id:e,resource:"discount_policy",root:!0}),data:u("#new-policy-form")}).done(function(t){S.set({discountPolicies:[t.result.discount_policy],searchText:S.get("newDiscountPolicy.title"),"newDiscountPolicy.creatingPolicy":v.hideLoader,newDiscountPolicy:v.empty}),S.hideNewPolicyForm()}).fail(function(t){var e=v.empty;if(4===t.readyState)if(500===t.status)e="Internal Server Error";else{var n=t.responseJSON.errors;for(var i in n)e+="

"+n[i]+"

"}else e="Unable to connect. Please try again.";S.set({"newDiscountPolicy.creatingPolicy":v.hideLoader,"newDiscountPolicy.errorMsg":e})})}});n.setMessage("required","Please fill out the this field"),n.setMessage("numeric","Please enter a numberic value")},hideNewPolicyForm:function(t){S.set("showAddPolicyForm",v.hideForm)},showEditPolicyForm:function(t){var e=t.keypath;S.set(e+".showPolicyForm",v.showForm),S.set(e+".errormsg",v.empty),S.addFormFields(S.get(e+".is_price_based"),e)},editPolicy:function(t){var e=t.keypath,n=t.context.id,i="edit-policy-form-"+n,r=new FormValidator(i,S.get("formValidationConfig"),function(t,i){if(i.preventDefault(),S.set(e+".errormsg",v.empty),t.length>0)S.set(e+".errormsg."+t[0].name,t[0].message);else{S.set(e+".editingPolicy",v.showLoader);var r="#policy-form-"+n;o({url:h("edit",{resource:"discount_policy",id:n,root:!0}),data:u(r)}).done(function(t){S.set(e+".editingPolicy",v.hideLoader),S.set(e,t.result.discount_policy),S.set(e+".showPolicyForm",v.hideForm),s("#dp-"+n)}).fail(function(t){var n=v.empty;if(4===t.readyState)if(500===t.status)n="Internal Server Error";else{var i=t.responseJSON.errors;for(var r in i)n+="

"+i[r]+"

"}else n="Unable to connect. Please try again.";S.set(e+".editingPolicy",v.hideLoader),S.set(e+".errorMsg",n)})}});r.setMessage("required","Please fill out the this field"),r.setMessage("numeric","Please enter a numberic value")},hideEditPolicyForm:function(t){var e=t.keypath;S.set(e+".showPolicyForm",v.hideForm)},showCouponForm:function(t){var e=t.keypath;S.set(e+".count",v.usageCount),S.set(e+".showCouponForm",v.showForm)},generateCoupon:function(t){var e=t.keypath,n=t.context.id,i=[{name:"count",rules:"required|numeric"},{name:"usage_limit",rules:"required|numeric"}],r="generate-coupon-form-"+n;new FormValidator(r,i,function(t,i){if(i.preventDefault(),S.set(e+".errormsg",v.empty),t.length>0)S.set(e+".errormsg."+t[0].name,t[0].message);else{var r="#new-coupon-"+n;S.set(e+".generatingCoupon",v.showLoader),S.set(e+".generateCouponErrorMsg",v.empty),o({url:h("new",{scope_ns:"discount_policy",scope_id:n,resource:"coupons",root:!0}),data:u(r)}).done(function(t){S.set(e+".coupons",t.result.coupons),S.set(e+".generatingCoupon",v.hideLoader),S.set("eventUrl",v.empty),$("#generated-coupons-"+n).modal("show"),new Clipboard(".copy-coupons")}).fail(function(t){var n=v.empty;if(4===t.readyState)if(500===t.status)n="Internal Server Error";else{var i=t.responseJSON.errors;for(var r in i)n+="

"+i[r]+"

"}else n="Unable to connect. Please try again.";S.set(e+".generatingCoupon",v.hideLoader),S.set(e+".generateCouponErrorMsg",n)})}}).setMessage("required","Please fill out the this field")},hideCouponForm:function(t){var e=t.keypath;S.set(e+".showCouponForm",v.hideForm)},getCouponList:function(t){t.original.preventDefault();var e=t.keypath,n=t.context.id;S.set(e+".loadingCoupons",v.showLoader),S.set(e+".loadingCouponErrorMsg",v.empty),a({url:h("index",{scope_ns:"discount_policy",scope_id:n,resource:"coupons",root:!0}),contentType:"application/json"}).done(function(t){S.set(e+".coupons",t.result.coupons),S.set(e+".loadingCoupons",v.hideLoader),$("#list-coupons-"+n).modal("show"),$("#coupons-list-"+n).footable(),new Clipboard(".copy-coupons-list")}).fail(function(t){var n=v.empty;n=4===t.readyState?"Internal Server Error":"Unable to connect. Please try again.",S.set(e+".loadingCoupons",v.hideLoader),S.set(e+".loadingCouponErrorMsg",n)})},oncomplete:function(){var t,e="";S.observe("searchText",function(n,i){n!==e&&(n.length>2?(window.clearTimeout(t),e=n,t=window.setTimeout(function(){S.refresh(n)},1e3)):0===n.length&&S.refresh())}),S.set("pages",_.range(1,S.get("totalPages")+1))}});p.render("discount-policies",{org_name:e,org_title:i}),d("Discount policies",i),NProgress.done(),window.addEventListener("popstate",function(t){NProgress.configure({showSpinner:!1}).start()})})}};n.DiscountPolicyView=g},{"../models/util.js":4,"../templates/admin_discount_policy.html.js":24,"./sidebar.js":40}],33:[function(t,e,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var i=t("../models/util.js"),r=i.Util,a=i.fetch,o=i.post,s=i.scrollToElement,u=i.urlFor,c=i.setPageTitle,l=t("../templates/admin_order.html.js").OrderTemplate,h=t("./sidebar.js").SideBarView,d={render:function(){var t=void 0===arguments[0]?{}:arguments[0],e=t.ic_id;a({url:u("index",{scope_ns:"ic",scope_id:e,resource:"orders",root:!0})}).done(function(t){var n=t.org_name,i=t.org_title,d=t.ic_title,f=t.orders,p=new Ractive({el:"#main-content-area",template:l,data:{icTitle:d,orders:f,formatDateTime:function(t){return r.formatDateTime(t)},formatToIndianRupee:function(t){return r.formatToIndianRupee(t)}}});h.render("orders",{org_name:n,org_title:i,ic_id:e,ic_title:d}),c("Orders",d),NProgress.done(),$("#orders-table").footable({breakpoints:{phone:600,tablet:768,desktop:1200,largescreen:1900}}),$("#orders-table").on("footable_filtering",function(t){var e=$("#filter-status").find(":selected").val();e&&e.length>0&&(t.filter+=t.filter&&t.filter.length>0?" "+e:e,t.clear=!t.filter)}),$("#filter-status").change(function(t){t.preventDefault(),$("#orders-table").trigger("footable_filter",{filter:$("#filter").val()})}),$("#search-form").on("keypress",function(t){if(13==t.which)return!1}),$("#orders-table").on("keydown",function(t){if(27==t.which)return p.set("orders.*.show_order",!1),!1}),p.on("showOrder",function(t){p.set("orders.*.show_order",!1),p.set(t.keypath+".loading",!0),NProgress.configure({showSpinner:!1}).start();var e=t.context.id;a({url:u("view",{resource:"order",id:e,root:!0})}).done(function(e){p.set(t.keypath+".line_items",e.line_items),p.set(t.keypath+".show_order",!0),NProgress.done(),p.set(t.keypath+".loading",!1);var n="#"+p.el.id;s(n)})}),p.on("hideOrder",function(t){p.set(t.keypath+".show_order",!1)}),p.on("cancelTicket",function(t,e){window.confirm("Are you sure you want to cancel this ticket?")&&(p.set(t.keypath+".cancel_error",""),p.set(t.keypath+".cancelling",!0),o({url:t.context.cancel_ticket_url}).done(function(e){p.set(t.keypath+".cancelled_at",e.result.cancelled_at),p.set(t.keypath+".cancelling",!1)}).fail(function(e){var n=void 0;n=4===e.readyState?500===e.status?"Server Error":JSON.parse(e.responseText).error_description:"Unable to connect. Please try again later.",p.set(t.keypath+".cancel_error",n),p.set(t.keypath+".cancelling",!1)}))}),window.addEventListener("popstate",function(t){NProgress.configure({showSpinner:!1}).start()})})}};n.OrderView=d},{"../models/util.js":4,"../templates/admin_order.html.js":25,"./sidebar.js":40}],34:[function(t,e,n){"use strict";var i=function(t,e){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t)){for(var n,i=[],r=t[Symbol.iterator]();!(n=r.next()).done&&(i.push(n.value),!e||i.length!==e););return i}throw new TypeError("Invalid attempt to destructure non-iterable instance")};Object.defineProperty(n,"__esModule",{value:!0});var r=t("../models/util.js"),a=r.fetch,o=r.urlFor,s=r.setPageTitle,u=t("../templates/admin_org_report.html.js").OrgReportTemplate,c=t("./sidebar.js").SideBarView,l={render:function(){var t=void 0===arguments[0]?{}:arguments[0],e=t.org_name;a({url:o("index",{resource:"reports",scope_ns:"o",scope_id:e,root:!0})}).done(function(t){var n=t.org_title,r=t.siteadmin,a=new Date,l=a.getFullYear(),h=a.getMonth()+1;console.log(r);new Ractive({el:"#main-content-area",template:u,data:{orgTitle:n,reportType:"invoices",monthYear:l+"-"+h,siteadmin:r,reportsUrl:function(){var t=this.get("reportType"),n=o("index",{resource:t,scope_ns:"o",scope_id:e,ext:"csv",root:!0});if("settlements"===t){var r=void 0,a=void 0,s=this.get("monthYear").split("-"),u=i(s,2);return r=u[0],a=u[1],n+"?year="+r+"&month="+a}return n},reportsFilename:function(){return"settlements"===this.get("reportType")?e+"_"+this.get("reportType")+"_"+this.get("monthYear")+".csv":e+"_"+this.get("reportType")+".csv"}}});c.render("org_reports",{org_name:e,org_title:n}),s("Organization reports",n),NProgress.done(),window.addEventListener("popstate",function(t){NProgress.configure({showSpinner:!1}).start()})})}};n.OrgReportView=l},{"../models/util.js":4,"../templates/admin_org_report.html.js":26,"./sidebar.js":40}],35:[function(t,e,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var i=t("../models/util.js"),r=i.fetch,a=i.urlFor,o=i.setPageTitle,s=t("../templates/admin_report.html.js").ReportTemplate,u=t("./sidebar.js").SideBarView,c={render:function(){var t=void 0===arguments[0]?{}:arguments[0],e=t.ic_id;r({url:a("index",{resource:"reports",scope_ns:"ic",scope_id:e,root:!0})}).done(function(t){var n=t.org_name,i=t.org_title,r=t.ic_name,c=t.ic_title;new Ractive({el:"#main-content-area",template:s,data:{icName:r,icTitle:c,reportType:"tickets",reportsUrl:function(){var t=this.get("reportType");return a("index",{resource:t,scope_ns:"ic",scope_id:e,ext:"csv",root:!0})},reportsFilename:function(){return this.get("icName")+"_"+this.get("reportType")+".csv"}}});u.render("reports",{org_name:n,org_title:i,ic_id:e,ic_title:c}),o("Reports",c),NProgress.done(),window.addEventListener("popstate",function(t){NProgress.configure({showSpinner:!1}).start()})})}};n.ReportView=c},{"../models/util.js":4,"../templates/admin_report.html.js":27,"./sidebar.js":40}],36:[function(t,e,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var i=t("../models/util.js"),r=i.fetch,a=i.urlFor,o=i.setPageTitle,s=(t("../models/index.js").IndexModel,t("../templates/index.html.js").IndexTemplate),u=t("./sidebar.js").SideBarView,c={render:function(){r({url:a("index",{root:!0})}).then(function(t){var e=t.orgs,n=new Ractive({el:"#main-content-area",template:s,data:{orgs:e}});u.hide(),o("Admin"),NProgress.done(),n.on("navigate",function(t,e){NProgress.configure({showSpinner:!1}).start(),eventBus.trigger("navigate",t.context.url)})}), +window.addEventListener("popstate",function(t){NProgress.configure({showSpinner:!1}).start()})}};n.IndexView=c},{"../models/index.js":2,"../models/util.js":4,"../templates/index.html.js":28,"./sidebar.js":40}],37:[function(t,e,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var i=t("../models/util.js"),r=i.Util,a=i.fetch,o=i.urlFor,s=i.setPageTitle,u=t("../templates/item_collection.html.js"),c=u.TableTemplate,l=u.AggChartTemplate,h=u.ItemCollectionTemplate,d=t("./sidebar.js").SideBarView,f=Ractive.extend({isolated:!1,template:c,onItemsSelected:function(t,e){var n=this.parent.get("totalSelected");t.node.checked?this.parent.set("totalSelected",n+t.context[e]):this.parent.set("totalSelected",n-t.context[e])}}),p=Ractive.extend({template:l,format_columns:function(){var t=this.parent.get("date_item_counts"),e=this.parent.get("categories").reduce(function(t,e){return t.concat(e.items)},[]),n=this.parent.get("date_sales"),i=["x"],r={},a=["sales"];for(var o in t)!function(o){i.push(o),a.push(n[o]),e.forEach(function(e){r[e.id]||(r[e.id]=[]),t[o].hasOwnProperty(e.id)?r[e.id].push(t[o][e.id]):r[e.id].push(0)})}(o);var s=[i];return e.forEach(function(t){s.push([t.title].concat(r[t.id]))}),s.push(a),s},oncomplete:function(){var t=this,e=this.format_columns(),n=_.without(_.map(e,_.first),"x","sales");this.chart=c3.generate({data:{x:"x",columns:this.format_columns(),type:"bar",types:{sales:"line"},groups:[n],axes:{sales:"y2"}},bar:{width:{ratio:.5}},axis:{x:{type:"timeseries",tick:{format:"%d-%m"},label:"Date"},y:{label:"No. of tickets"},y2:{show:!0,label:"Sales"}}}),this.parent.on("data_update",function(){t.chart.load({columns:t.format_columns()})})}}),g={render:function(){var t=void 0===arguments[0]?{}:arguments[0],e=t.ic_id;a({url:o("view",{resource:"ic",id:e,root:!0})}).done(function(t){var n=t.org_name,i=t.org_title,a=t.ic_title,o=t.categories,u=t.date_item_counts,c=t.date_sales,l=t.today_sales,g=t.net_sales,m=t.sales_delta;new Ractive({el:"#main-content-area",template:h,data:{icTitle:a,categories:o,date_item_counts:u,date_sales:c,net_sales:g,sales_delta:m,today_sales:l,totalSelected:0,formatToIndianRupee:function(t){return r.formatToIndianRupee(t)}},components:{TableComponent:f,AggChartComponent:p}});d.render("dashboard",{org_name:n,org_title:i,ic_id:e,ic_title:a}),s(a),NProgress.done(),window.addEventListener("popstate",function(t){NProgress.configure({showSpinner:!1}).start()})})}};n.ItemCollectionView=g},{"../models/util.js":4,"../templates/item_collection.html.js":29,"./sidebar.js":40}],38:[function(t,e,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var i=t("../models/util.js"),r=i.fetch,a=i.urlFor,o=i.setPageTitle,s=t("../templates/org.html.js").orgTemplate,u=t("./sidebar.js").SideBarView,c={render:function(){var t=void 0===arguments[0]?{}:arguments[0],e=t.org_name;r({url:a("view",{resource:"o",id:e,root:!0})}).then(function(t){var n=(t.id,t.org_title),i=t.item_collections,r=new Ractive({el:"#main-content-area",template:s,data:{orgName:e,orgTitle:n,item_collections:i}});u.render("org",{org_name:e,org_title:n}),o(n),NProgress.done(),r.on("navigate",function(t,e){NProgress.configure({showSpinner:!1}).start(),eventBus.trigger("navigate",t.context.url)})}),window.addEventListener("popstate",function(t){NProgress.configure({showSpinner:!1}).start()})}};n.OrgView=c},{"../models/util.js":4,"../templates/org.html.js":30,"./sidebar.js":40}],39:[function(t,e,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var i=t("./index.js").IndexView,r=t("./org.js").OrgView,a=t("./admin_org_report.js").OrgReportView,o=t("./admin_discount_policy.js").DiscountPolicyView,s=t("./item_collection.js").ItemCollectionView,u=t("./admin_order.js").OrderView,c=t("./admin_report.js").ReportView,l=Backbone.Router.extend({url_root:"/admin/",routes:{"":"index","o/:org_name":"org","o/:org_name/reports":"org_report","o/:org_name/discount_policy":"discount_policy","o/:org_name/discount_policy?:params":"discount_policy","ic/:ic_id":"item_collection","ic/:ic_id/orders":"order","ic/:ic_id/reports":"report"},index:function(){i.render()},org:function(t){r.render({org_name:t})},org_report:function(t){a.render({org_name:t})},discount_policy:function(t){var e=void 0===arguments[1]?{}:arguments[1],n=e.search,i=e.page,r=e.size;o.render({org_name:t,search:n,page:i,size:r})},item_collection:function(t){s.render({ic_id:t})},order:function(t){u.render({ic_id:t})},report:function(t){c.render({ic_id:t})},_extractParameters:function(t,e){var n=t.exec(e).slice(1);if(n[n.length-1]){var i=n[n.length-1].split("&"),r={};i.forEach(function(t){if(t){var e=t.split("=");r[e[0]]=e[1]}}),n[n.length-1]=r}return n}});n.Router=l},{"./admin_discount_policy.js":32,"./admin_order.js":33,"./admin_org_report.js":34,"./admin_report.js":35,"./index.js":36,"./item_collection.js":37,"./org.js":38}],40:[function(t,e,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var i=t("../models/sidebar.js").SideBarModel,r=t("../templates/sidebar.html.js").SideBarTemplate,a={init:function(t,e){this.on=!0,this.ractive=new Ractive({el:"#sidebar",template:r,data:{sidebarMobileOn:!1,sidebarItems:i.getItems(e),activeItem:t,sidebarHide:!1},toggle:function(t){t.original.preventDefault(),this.set("sidebarMobileOn",!this.get("sidebarMobileOn"))},navigate:function(t){t.context.view!==this.get("activeItem")&&(NProgress.configure({showSpinner:!1}).start(),eventBus.trigger("navigate",t.context.url))}})},render:function(t,e){this.on?this.ractive.set({sidebarItems:i.getItems(e),activeItem:t,sidebarHide:!1,sidebarMobileOn:!1}):this.init(t,e)},hide:function(){this.on&&this.ractive.set("sidebarHide",!0)}};n.SideBarView=a},{"../models/sidebar.js":3,"../templates/sidebar.html.js":31}]},{},[1]); \ No newline at end of file diff --git a/boxoffice/static/js/templates/admin_org_report.html.js b/boxoffice/static/js/templates/admin_org_report.html.js index 3a6400c6..320510e4 100644 --- a/boxoffice/static/js/templates/admin_org_report.html.js +++ b/boxoffice/static/js/templates/admin_org_report.html.js @@ -12,7 +12,15 @@ export const OrgReportTemplate = `

Report type

+ {{#if reportType == "settlements"}} +

+ +

+ {{/if}}
Download diff --git a/boxoffice/static/js/views/admin_org_report.js b/boxoffice/static/js/views/admin_org_report.js index 311d800c..de152036 100644 --- a/boxoffice/static/js/views/admin_org_report.js +++ b/boxoffice/static/js/views/admin_org_report.js @@ -7,26 +7,43 @@ export const OrgReportView = { render: function({org_name}={}) { fetch({ url: urlFor('index', {resource: 'reports', scope_ns: 'o', scope_id: org_name, root: true}) - }).done(({org_title}) => { + }).done(({org_title, siteadmin}) => { // Initial render + let currentDate = new Date(); + let currentYear = currentDate.getFullYear(); + // month starts from 0 + let currentMonth = currentDate.getMonth() + 1; let reportComponent = new Ractive({ el: '#main-content-area', template: OrgReportTemplate, data: { orgTitle: org_title, reportType: "invoices", + monthYear: `${currentYear}-${currentMonth}`, + siteadmin: siteadmin, reportsUrl: function() { let reportType = this.get('reportType'); - return urlFor('index', { + let url = urlFor('index', { resource: reportType, scope_ns: 'o', scope_id: org_name, ext: 'csv', root: true }); + if (reportType === 'settlements') { + let year, month; + [year, month] = this.get('monthYear').split('-'); + return `${url}?year=${year}&month=${month}`; + } else { + return url; + } }, reportsFilename: function() { - return org_name + '_' + this.get('reportType') + '.csv'; + if (this.get('reportType') === 'settlements'){ + return `${org_name}_${this.get('reportType')}_${this.get('monthYear')}.csv`; + } else { + return `${org_name}_${this.get('reportType')}.csv`; + } } } }); diff --git a/boxoffice/static/sass/_layout.sass b/boxoffice/static/sass/_layout.sass index 1e33de05..a6bcc902 100644 --- a/boxoffice/static/sass/_layout.sass +++ b/boxoffice/static/sass/_layout.sass @@ -567,3 +567,6 @@ input.icon-placeholder border-bottom: 2px solid padding-bottom: 5px display: inline + +p.settlements-month-widget + margin-top: 10px diff --git a/boxoffice/views/admin_report.py b/boxoffice/views/admin_report.py index abe30d7c..cad2f5d3 100644 --- a/boxoffice/views/admin_report.py +++ b/boxoffice/views/admin_report.py @@ -1,13 +1,14 @@ # -*- coding: utf-8 -*- -from flask import jsonify +from flask import jsonify, request, g, abort from .. import app, lastuser from coaster.views import load_models, render_with from baseframe import localize_timezone, get_locale from boxoffice.models import Organization, ItemCollection, LineItem, INVOICE_STATUS -from boxoffice.views.utils import check_api_access, csv_response +from boxoffice.views.utils import check_api_access, csv_response, api_error from babel.dates import format_datetime -from datetime import datetime +from datetime import datetime, date +from ..extapi.razorpay import get_settled_transactions def jsonify_report(data_dict): @@ -28,7 +29,7 @@ def admin_report(item_collection): def jsonify_org_report(data_dict): - return jsonify(org_title=data_dict['organization'].title) + return jsonify(org_title=data_dict['organization'].title, siteadmin=data_dict['siteadmin']) @app.route('/admin/o//reports') @@ -38,7 +39,7 @@ def jsonify_org_report(data_dict): (Organization, {'name': 'org_name'}, 'organization'), permission='org_admin') def admin_org_report(organization): - return dict(organization=organization) + return dict(organization=organization, siteadmin=lastuser.has_permission('siteadmin')) @app.route('/admin/ic//tickets.csv') @@ -169,3 +170,20 @@ def row_handler(row): return dict_row return csv_response(headers, rows, row_type='dict', row_handler=row_handler) + + +@app.route('/admin/o//settlements.csv') +@lastuser.requires_permission('siteadmin') +@load_models( + (Organization, {'name': 'org_name'}, 'organization')) +def settled_transactions(organization): + year = int(request.args.get('year')) + month = int(request.args.get('month')) + try: + date(year, month, 1) + except (ValueError, TypeError): + return api_error(message='Invalid year/month', + status_code=403, + errors=['invalid_date']) + headers, rows = get_settled_transactions({'year': year, 'month': month}, g.user.timezone) + return csv_response(headers, rows, row_type='dict') diff --git a/boxoffice/views/order.py b/boxoffice/views/order.py index b8785ba2..f4eb5788 100644 --- a/boxoffice/views/order.py +++ b/boxoffice/views/order.py @@ -445,7 +445,7 @@ def regenerate_line_item(order, original_line_item, updated_line_item_tup, line_ else: coupon = None - return LineItem(order=order, item=item, discount_policy=policy, + return LineItem(order=order, item=item, discount_policy=policy, previous=original_line_item, status=LINE_ITEM_STATUS.CONFIRMED, line_item_seq=line_item_seq, discount_coupon=coupon, @@ -507,8 +507,9 @@ def process_line_item_cancellation(line_item): payment = OnlinePayment.query.filter_by(order=line_item.order, pg_payment_status=RAZORPAY_PAYMENT_STATUS.CAPTURED).one() rp_resp = razorpay.refund_payment(payment.pg_paymentid, refund_amount) if rp_resp.status_code == 200: + rp_refund = rp_resp.json() db.session.add(PaymentTransaction(order=order, transaction_type=TRANSACTION_TYPE.REFUND, - online_payment=payment, amount=refund_amount, currency=CURRENCY.INR, refunded_at=func.utcnow(), + pg_refundid=rp_refund['id'], online_payment=payment, amount=refund_amount, currency=CURRENCY.INR, refunded_at=func.utcnow(), refund_description='Refund: {line_item_title}'.format(line_item_title=line_item.item.title))) else: raise PaymentGatewayError("Cancellation failed for order - {order} with the following details - {msg}".format(order=order.id, @@ -557,8 +558,9 @@ def process_partial_refund_for_order(order, form_dict): pg_payment_status=RAZORPAY_PAYMENT_STATUS.CAPTURED).one() rp_resp = razorpay.refund_payment(payment.pg_paymentid, requested_refund_amount) if rp_resp.status_code == 200: + rp_refund = rp_resp.json() transaction = PaymentTransaction(order=order, transaction_type=TRANSACTION_TYPE.REFUND, - online_payment=payment, currency=CURRENCY.INR, + online_payment=payment, currency=CURRENCY.INR, pg_refundid=rp_refund['id'], refunded_at=func.utcnow()) form.populate_obj(transaction) db.session.add(transaction) diff --git a/migrations/versions/171fcb171759_add_previous_to_line_item.py b/migrations/versions/171fcb171759_add_previous_to_line_item.py new file mode 100644 index 00000000..8b035871 --- /dev/null +++ b/migrations/versions/171fcb171759_add_previous_to_line_item.py @@ -0,0 +1,27 @@ +"""add_previous_to_line_item + +Revision ID: 171fcb171759 +Revises: 81f30d00706f +Create Date: 2017-10-24 18:40:39.183620 + +""" + +# revision identifiers, used by Alembic. +revision = '171fcb171759' +down_revision = '81f30d00706f' + +from alembic import op +import sqlalchemy as sa +from sqlalchemy.dialects import postgresql +import sqlalchemy_utils + +def upgrade(): + op.add_column('line_item', sa.Column('previous_id', sqlalchemy_utils.types.uuid.UUIDType(), nullable=True)) + op.create_index(op.f('ix_line_item_previous_id'), 'line_item', ['previous_id'], unique=True) + op.create_foreign_key('line_item_id_fkey', 'line_item', 'line_item', ['previous_id'], ['id']) + + +def downgrade(): + op.drop_constraint('line_item_id_fkey', 'line_item', type_='foreignkey') + op.drop_index(op.f('ix_line_item_previous_id'), table_name='line_item') + op.drop_column('line_item', 'previous_id') diff --git a/migrations/versions/66b67130c901_retroactively_migrate_previous_id_for_.py b/migrations/versions/66b67130c901_retroactively_migrate_previous_id_for_.py new file mode 100644 index 00000000..d2ea7a7b --- /dev/null +++ b/migrations/versions/66b67130c901_retroactively_migrate_previous_id_for_.py @@ -0,0 +1,107 @@ +"""retroactively_migrate_previous_id_for_line_item + +Revision ID: 66b67130c901 +Revises: 171fcb171759 +Create Date: 2017-10-26 14:50:18.859247 + +""" + +# revision identifiers, used by Alembic. +revision = '66b67130c901' +down_revision = '171fcb171759' + +from collections import OrderedDict +from alembic import op +import sqlalchemy as sa +from sqlalchemy.dialects import postgresql +from sqlalchemy.sql import table, column +import sqlalchemy_utils +from boxoffice.models.order import ORDER_STATUS +from boxoffice.models.line_item import LINE_ITEM_STATUS + + + +def find_nearest_timestamp(lst, timestamp): + if not lst: + return None + nearest_ts = min(lst, key=lambda ts: abs(ts-timestamp).total_seconds()) + if abs(nearest_ts - timestamp).total_seconds() < 1: + return nearest_ts + +def set_previous_keys_for_line_items(line_items): + timestamped_line_items = OrderedDict() + + # Assemble the `timestamped_line_items` dictionary with the timestamp at which the line items were created + # as the key, and the line items that were created at that time as the value (as a list) + # Some line items may have been created a few milliseconds later, so the nearest timestamp + # with a tolerance level of one second is searched for + for line_item in line_items: + ts_key = find_nearest_timestamp(timestamped_line_items.keys(), line_item.created_at) or line_item.created_at + if not timestamped_line_items.get(ts_key): + timestamped_line_items[ts_key] = [] + timestamped_line_items[ts_key].append({ + 'id': line_item.id, + 'status': line_item.status, + 'item_id': line_item.item_id, + 'previous_id': None + }) + + # The previous line item for a line item, is a line item that has an earlier timestamp with a void status + # with the same item_id. Find it and set it + used_line_item_ids = set() + for idx, (timestamp, line_item_dicts) in enumerate(timestamped_line_items.items()[1:]): + # 0th timestamps are root line items, so they're skipped since + # they don't need their `previous_id` to be updated + for li_dict in timestamped_line_items[timestamp]: + # timestamped_line_items.keys()[idx] and not timestamped_line_items.keys()[idx-1] + # because the timestamped_line_items.items() list is enumerated from index 1 + previous_li_dict = [previous_li_dict + for previous_li_dict in timestamped_line_items[timestamped_line_items.keys()[idx]] + if previous_li_dict['item_id'] == li_dict['item_id'] + and previous_li_dict['id'] not in used_line_item_ids + and previous_li_dict['status'] == LINE_ITEM_STATUS.VOID + ][0] + li_dict['previous_id'] = previous_li_dict['id'] + used_line_item_ids.add(previous_li_dict['id']) + + return [li_dict for li_dicts in timestamped_line_items.values() for li_dict in li_dicts] + +order_table = table('customer_order', + column('id', sqlalchemy_utils.types.uuid.UUIDType()), + column('status', sa.Integer())) + +line_item_table = table('line_item', + column('id', sqlalchemy_utils.types.uuid.UUIDType()), + column('customer_order_id', sqlalchemy_utils.types.uuid.UUIDType()), + column('item_id', sqlalchemy_utils.types.uuid.UUIDType()), + column('previous_id', sqlalchemy_utils.types.uuid.UUIDType()), + column('status', sa.Integer()), + column('created_at', sa.Boolean())) + +def upgrade(): + conn = op.get_bind() + orders = conn.execute(sa.select([order_table.c.id]).where(order_table.c.status.in_(ORDER_STATUS.TRANSACTION)).select_from(order_table)) + for order_id in [order.id for order in orders]: + line_items = conn.execute(sa.select([line_item_table.c.id, + line_item_table.c.item_id, + line_item_table.c.status, + line_item_table.c.created_at + ]).where(line_item_table.c.customer_order_id == order_id).order_by("created_at").select_from(line_item_table)) + updated_line_item_dicts = set_previous_keys_for_line_items(line_items) + for updated_line_item_dict in updated_line_item_dicts: + if updated_line_item_dict['previous_id']: + conn.execute(sa.update(line_item_table).where( + line_item_table.c.id == updated_line_item_dict['id'] + ).values(previous_id=updated_line_item_dict['previous_id'])) + + +def downgrade(): + conn = op.get_bind() + orders = conn.execute(sa.select([order_table.c.id]).where(order_table.c.status.in_(ORDER_STATUS.TRANSACTION)).select_from(order_table)) + for order_id in [order.id for order in orders]: + line_items = conn.execute(sa.select([line_item_table.c.id]).where( + line_item_table.c.customer_order_id == order_id).order_by("created_at").select_from(line_item_table)) + for line_item in line_items: + conn.execute(sa.update(line_item_table).where( + line_item_table.c.id == line_item.id + ).values(previous_id=None)) diff --git a/migrations/versions/81f30d00706f_add_pg_refundid_to_transaction.py b/migrations/versions/81f30d00706f_add_pg_refundid_to_transaction.py new file mode 100644 index 00000000..03bd8140 --- /dev/null +++ b/migrations/versions/81f30d00706f_add_pg_refundid_to_transaction.py @@ -0,0 +1,26 @@ +"""add_pg_refundid_to_transaction + +Revision ID: 81f30d00706f +Revises: 1a22f5035244 +Create Date: 2017-10-19 03:39:48.608087 + +""" + +# revision identifiers, used by Alembic. +revision = '81f30d00706f' +down_revision = '1a22f5035244' + +from alembic import op +import sqlalchemy as sa +from sqlalchemy.dialects import postgresql + +def upgrade(): + op.add_column('payment_transaction', sa.Column('pg_refundid', sa.Unicode(length=80), nullable=True)) + op.create_index(op.f('ix_online_payment_pg_paymentid'), 'online_payment', ['pg_paymentid'], unique=True) + op.create_index(op.f('ix_payment_transaction_pg_refundid'), 'payment_transaction', ['pg_refundid'], unique=True) + + +def downgrade(): + op.drop_index(op.f('ix_payment_transaction_pg_refundid'), table_name='payment_transaction') + op.drop_index(op.f('ix_online_payment_pg_paymentid'), table_name='online_payment') + op.drop_column('payment_transaction', 'pg_refundid')