/* Minification failed. Returning unminified contents.
(1,1): run-time error CSS1019: Unexpected token, found '"use strict"'
(2,8): run-time error CSS1030: Expected identifier, found 'controller('
(2,8): run-time error CSS1031: Expected selector, found 'controller('
(2,8): run-time error CSS1025: Expected comma or open brace, found 'controller('
(508,8): run-time error CSS1030: Expected identifier, found 'controller('
(508,8): run-time error CSS1031: Expected selector, found 'controller('
(508,8): run-time error CSS1025: Expected comma or open brace, found 'controller('
(540,8): run-time error CSS1030: Expected identifier, found 'factory('
(540,8): run-time error CSS1031: Expected selector, found 'factory('
(540,8): run-time error CSS1025: Expected comma or open brace, found 'factory('
(671,2): run-time error CSS1019: Unexpected token, found ')'
(672,1): run-time error CSS1019: Unexpected token, found '"use strict"'
(673,8): run-time error CSS1030: Expected identifier, found 'factory('
(673,8): run-time error CSS1031: Expected selector, found 'factory('
(673,8): run-time error CSS1025: Expected comma or open brace, found 'factory('
(824,1): run-time error CSS1019: Unexpected token, found '('
(824,2): run-time error CSS1019: Unexpected token, found 'function('
(824,11): run-time error CSS1019: Unexpected token, found ')'
(824,13): run-time error CSS1019: Unexpected token, found '{'
(825,5): run-time error CSS1019: Unexpected token, found '"use strict"'
(827,12): run-time error CSS1030: Expected identifier, found 'filter('
(827,12): run-time error CSS1031: Expected selector, found 'filter('
(827,12): run-time error CSS1025: Expected comma or open brace, found 'filter('
(836,6): run-time error CSS1019: Unexpected token, found ')'
(837,1): run-time error CSS1019: Unexpected token, found '}'
(837,2): run-time error CSS1019: Unexpected token, found ')'
(837,3): run-time error CSS1019: Unexpected token, found '('
(837,4): run-time error CSS1019: Unexpected token, found ')'
 */
"use strict";
sspApp.controller('public.productsearch.controller', ['$scope', '$compile', '$filter', '$modal', 'productsearchservice', 'productsearch', function ($scope, $compile, $filter, $modal, productsearchservice, productsearch) {

    // ++++++++++++++++++
    // +++ Properties +++
    // ++++++++++++++++++

    $scope.data = productsearch;

    $scope.totalProducts = 0;
    $scope.disableChapters = true;
    $scope.disableParagraphs = true;
    $scope.disableCategories = true;
    $scope.disableRefundingGroups = true;
    $scope.searchParameters = null;
    $scope.product = [];
    $scope.isProductSelected = false;

    // ++++++++++++++++++++
    // +++ Init Methods +++
    // ++++++++++++++++++++

    $scope.initSearch = function (searchType) {
        // Get applicable from last published decree
        productsearchservice.getLastPublishedDecree().success(function (data) {
            $scope.applicableDate = $.parseMVCDate(data);
        });

        $scope.searchParameters = null;
        productsearch.setSearchType(searchType);
        productsearch.initSearch();

        // Gets information for the simple search
        productsearchservice.getSimpleSearchParameters().then(function (response) {
            productsearch.setBases(response.data);
        });

        // Gets information for the advanced search
        if (productsearch.searchType === 'advanced') {
            productsearchservice.getAdvancedSearchParameters().then(function (response) {
                productsearch.setProductTypes(response.data.ProductTypes);
                productsearch.setProductCategories(response.data.ProductCategories);
                productsearch.setPharmaceuticalFormTypes(response.data.PharmaceuticalFormTypes);
                productsearch.setGalenicForms(response.data.GalenicForms);
                productsearch.setAdministrationWays(response.data.AdministrationWays);
                productsearch.setPackingTypes(response.data.PackingTypes);
                productsearch.setMultiplePrescriptionTypes(response.data.MultiplePrescriptionTypes);
                productsearch.setLegalBases(response.data.LegalBases);
            });
        }
    }

    $scope.hasSearchParameters = function () {
        return $scope.searchParameters != null;
    }

    $scope.resetSearch = function () {
        productsearch.initSearch();
        $scope.searchParameters = null;
        $scope.disableChapters = true;
        $scope.disableParagraphs = true;
        $scope.disableCategories = true;
        $scope.disableRefundingGroups = true;
    }

    // +++++++++++++++
    // +++ Methods +++
    // +++++++++++++++

    $scope.showLegalTextId = function (legalTextId, legalTextName) {
        $modal.open({
            templateUrl: 'showLegalTextContent',
            controller: 'public.productsearch.legalText.controller',
            windowClass: 'modal-extra-large',
            resolve: {
                legalTextId: function () {
                    return legalTextId;
                },
                legalTextName: function () {
                    return legalTextName;
                },
                productsearchservice: function () {
                    return productsearchservice;
                }
            }
        });
    };

    $scope.datePickers = {
        admissionDate: false
    };

    $scope.openCalendar = function ($event, which) {
        $event.preventDefault();
        $event.stopPropagation();
        $scope.datePickers[which] = true;
    };

    $scope.loadLegalBases = function (productType) {
        productsearchservice.getLegalBases(productType).then(function (response) {
            productsearch.setLegalBases(response.data);
            productsearch.search.legalBaseId = "";
            productsearch.search.chapterId = "";
            productsearch.search.paragraphId = "";
            productsearch.search.categoryId = "";
            productsearch.search.refundingGroupId = "";
            $scope.disableChapters = true;
            $scope.disableParagraphs = true;
            $scope.disableCategories = true;
            $scope.disableRefundingGroups = true;
        });
    }

    $scope.loadChaptersForRefundCondition = function (legalBaseId) {
        if (legalBaseId) {
            productsearchservice.getChaptersForRefundCondition(legalBaseId).then(function(response) {
                productsearch.setChapters(response.data);
                $scope.disableChapters = false;
            });
        }
    }

    $scope.loadParagraphsForRefundCondition = function (legalBaseId, chapterId) {
        $scope.disableParagraphs = true;
        productsearch.search.paragraphId = "";
        if (chapterId) {
            productsearchservice.getParagraphsForRefundCondition(legalBaseId, chapterId).then(function(response) {
                productsearch.setParagraphs(response.data);
                $scope.disableParagraphs = false;
            });
        }
    }

    $scope.loadCategoriesForRefundCondition = function (legalBaseId) {
        if (legalBaseId) {
            productsearchservice.getCategoriesForRefundCondition(legalBaseId).then(function(response) {
                productsearch.setCategories(response.data);
                $scope.disableCategories = false;
            });
        }
    }

    $scope.loadRefundingGroupsForRefundCondition = function (legalBaseId, categoryId) {
        $scope.disableRefundingGroups = true;
        productsearch.search.refundingGroupId = "";
        if (categoryId) {
            productsearchservice.getRefundingGroupsForRefundCondition(legalBaseId, categoryId).then(function(response) {
                productsearch.setRefundingGroups(response.data);
                $scope.disableRefundingGroups = false;
            });
        }
    }

    $scope.loadInformationForLegalBase = function (legalBaseId) {
        $scope.disableChapters = true;
        $scope.disableCategories = true;
        $scope.disableParagraphs = true;
        $scope.disableRefundingGroups = true;
        productsearch.search.chapterId = "";
        productsearch.search.paragraphId = "";
        productsearch.search.categoryId = "";
        productsearch.search.refundingGroupId = "";
        $scope.loadChaptersForRefundCondition(legalBaseId);
        $scope.loadCategoriesForRefundCondition(legalBaseId);
    }

    $scope.isAdvancedSearch = function () {
        return productsearch.searchType === "advanced";
    }

    // ATC Code auto-complete
    $scope.classificationItemTemplate = function (ul, item) {
        return $("<li>").attr("id", item.AtcCode).attr("data-value", item.AtcCode).text(item.AtcCode).appendTo(ul);
    }

    $scope.atcCodeSelected = function (item) {
        if (item == null) {
            productsearch.search.atcCode = null;
        } else {
            productsearch.search.atcCode = item.AtcCode;
        }
    }

    // Identification code auto-complete
    $scope.identificationCodeItemTemplate = function (ul, item) {
        return $("<li>").attr("id", item.value).attr("data-value", item.value).text(item.label).appendTo(ul);
    }

    $scope.identificationCodeSelected = function (item) {
        if (item == null) {
            productsearch.search.identificationCode = null;
        } else {
            productsearch.search.identificationCode = item.value;
        }
    }

    $scope.searchProducts = function () {
        if (productsearch.searchType === 'advanced') {
            var admissionDate = null;

            if (productsearch.search.admissionDate != null && productsearch.search.admissionDate !== "")
                admissionDate = productsearch.search.admissionDate;

            var advancedparameters = {
                productName: productsearch.search.productName,
                baseId: productsearch.search.baseId,
                firm: productsearch.search.firm,
                productTypeCodeType: productsearch.search.productTypeCodeType,
                productCategoryCodeType: productsearch.search.productCategoryCodeType,
                ctiExtended: productsearch.search.ctiExtended,
                productId: productsearch.search.productId,
                identificationCode: productsearch.search.identificationCode,
                atcCode: productsearch.search.atcCode,
                pharmaceuticalFormTypeId: productsearch.search.pharmaceuticalFormTypeId,
                galenicFormId: productsearch.search.galenicFormId,
                administrationCodeType: productsearch.search.administrationCodeType,
                packingTypeId: productsearch.search.packingTypeId,
                legalBaseId: productsearch.search.legalBaseId,
                chapterId: productsearch.search.chapterId,
                paragraphId: productsearch.search.paragraphId,
                categoryId: productsearch.search.categoryId,
                refundingGroupId: productsearch.search.refundingGroupId,
                multiplePrescriptionTypeCodeType: productsearch.search.multiplePrescriptionTypeCodeType,
                isForfait: productsearch.search.isForfait,
                admissionDate: admissionDate
            };

            fillProducts(getProductsAdvancedSearchSource, advancedparameters);
        } else {
            var simpleparameters = {
                productName: productsearch.search.productName,
                baseId: productsearch.search.baseId
            };
            fillProducts(getProductSimpleSearchSource, simpleparameters);
        }
    }

    function fillProducts(url, parameters) {
        $scope.searchParameters = parameters;
        $scope.url = url;
        var grid = '#productsOverview';
        if ($.fn.DataTable.isDataTable(grid)) {
            $(grid).DataTable().ajax.reload();
        } else {
            $(grid).dataTable({
                processing: true,
                serverSide: false,
                searching: false,
                ordering: true,
                info: false,
                paging: true,
                lengthChange: false,
                ajax: {
                    url: $scope.url,
                    dataType: "json",
                    type: "POST",
                    data: function (d) {
                        d.Parameters = $scope.searchParameters;
                    }
                },
                columns: [
                    { "data": "CtiExtended", "defaultContent": "" },
                    { "data": "ProductId", "defaultContent": "", "render": $.formatRizivCode },
                    { "data": "ProductName", "defaultContent": "" },
                    {
                        "data": "Packing",
                        "orderable": false,
                        "render": function (data, type, row) {
                            return "<span data-toggle='tooltip' data-placement='bottom' title='" + row.PackingTooltip + "'>" + data + "</span>";
                        }
                    },
                    {
                        "data": "Composition",
                        "orderable": false,
                        "render": function (data, type, row) {
                            return "<span data-toggle='tooltip' data-placement='bottom' title='" + row.CompositionTooltip + "'>" + data + "</span>";
                        }
                    }
                ],
                order: [[1, "asc"]],
                language: {
                    paginate: {
                        next: nextPage,
                        previous: previousPage
                    },
                    processing: processing,
                    zeroRecords: zeroRecords
                },
                "drawCallback": function () {
                    $('[data-toggle="tooltip"]').tooltip();
                }
            });

            $(grid).on('xhr.dt', function (e, settings, json, xhr) {
                if (json) {
                    if (json.message) {
                        alert(json.messageText);
                    }

                    $scope.totalProducts = json.data.length;
                } else {
                    $scope.totalProducts = 0;
                }

                $scope.$apply();
            });

            $('#productsOverview tbody').on('click', 'tr', function () {
                $(this).toggleClass('selected');
                var data = $('#productsOverview').DataTable().row(this).data();

                $scope.selectProduct(data.ProductId);
            });
        }
    }

    $scope.changeDisplayState = function () {
        $scope.isProductSelected = false;
    }

    $scope.setSearchProduct = function (product) {
        $scope.$apply(function () {
            $scope.searchProduct = product;
            $scope.searchProduct.Product.InamiCode = $.formatRizivCode($scope.searchProduct.Product.Id);
        });
    }

    $scope.selectProduct = function (productId) {
        $scope.$apply(function () {
            $scope.isProductSelected = true;
        });


        $('#priceTable').dataTable().fnDestroy();
        $('#priceTable').dataTable({
            processing: true,
            serverSide: false,
            searching: false,
            ordering: false,
            info: false,
            paging: true,
            lengthChange: false,
            ajax: {
                url: getPriceTableForProductSource,
                dataType: "json",
                type: "POST",
                data: function (d) {
                    d.ProductId = productId;
                }, dataSrc: function (json) {
                    $scope.setSearchProduct(json.data.Product);
                    return json.data.Prices;
                }
            },
            columns: [
                { "data": "IdentificationCode", "defaultContent": "", "width": "8%" },
                {
                    "data": "DeliveryDescription",
                    "render": function (data, type, row) {
                        if (type === 'display') {
                            if (row.DeliveryId == 1 || row.IsFactoryPrice) {
                                return data;
                            }
                            return '<span class="tooltip-link" data-toggle="tooltip" data-placement="bottom" title="' + row.DeliveryLongDescription + '">' + row.DeliveryDescription + '</span>';
                        }
                        return data;
                    },
                    "className": "dt-body-center"
                },
                { "data": "TarificationUnit", "defaultContent": "" },
                {
                    "data": "RefundConditionDescription",
                    "render": function (data, type, row) {
                        if (type === 'display') {
                            if (row.LegalTextId) {
                                data = data + ' <i class="glyphicon glyphicon-eye-open" data-toggle="tooltip" data-placement="bottom" title="' + eyeTitle + '" id="eye" name="eye" style="cursor: pointer;" ></i>';
                            }
                            if (row.HasRequestForms) {
                                data = data + ' <i class="glyphicon glyphicon-list-alt" data-toggle="tooltip" data-placement="bottom" title="' + formsTitle + '" id="forms" name="forms" style="cursor: pointer;"></i>';
                            }

                            return data;
                        }
                        return data;
                    },
                    "className": "dt-body-center"
                },
                { "data": "AttestModelDescription", "defaultContent": "" },
                {
                    "data": "RefundingGroupCode",
                    "render": function (data, type, row) {
                        if (type === 'display') {
                            if (row.IsFactoryPrice) {
                                return '';
                            }
                            return '<span class="tooltip-link" data-toggle="tooltip" data-placement="bottom" title="' + row.RefundingGroupDescription + '">' + '(' + row.RefundingCategory + ') ' + row.RefundingGroupCode + '</span>';
                        }
                        return data;
                    },
                    "className": "dt-body-center"
                },
                {
                    "data": "Code",
                    "defaultContent": "",
                    "render": function(data, type, row) {
                        if (type === 'display') {
                            return '<span class="tooltip-link" data-toggle="tooltip" data-placement="bottom" title="' + row.CodeToolTip + '">' + row.Code + '</span>';
                        }
                        return data;
                    }
                },
                {
                    "data": "Price", "defaultContent": "",
                    "render": function (data, type, row) {
                        var result = data;
                        if (type === 'display') {
                            if (row.IsPublic || row.IsFactoryPrice) {
                                result = $.formatNumber(2, '', data);
                            } else {
                                result = $.formatNumber(4, '', data);
                            }
                        }
                        return result;
                    }
                },
                {
                    "data": "RefundingBase", "defaultContent": "",
                    "render": function (data, type, row) {
                        var result = data;
                        if (type === 'display') {
                            if (row.IsPublic || row.IsFactoryPrice) {
                                result = $.formatNumber(2, '', data);
                            } else {
                                result = $.formatNumber(4, '', data);
                            }
                        }
                        return result;
                    }
                },
                {
                    "data": "VIPOPrice", "defaultContent": "",
                    "render": function (data, type, row) {
                        var result = data;
                        if (type === 'display') {
                            if (row.IsAmbulatory) {
                                if (row.IsReferenceRefundable) {
                                    result = $.formatNumber(4, '+', row.Supplement);
                                }
                            } else if (row.IsPublic) {
                                result = $.formatNumber(2, '', data);
                            } else if (row.IsRestHome) {
                                result = $.formatNumber(4, '', data);
                            }
                        }
                        return result;
                    }
                },
                {
                    "data": "ActivePrice", "defaultContent": "",
                    "render": function (data, type, row) {
                        var result = data;
                        if (type === 'display') {
                            if (row.IsAmbulatory) {
                                if (row.IsReferenceRefundable) {
                                    result = $.formatNumber(4, '+', row.Supplement);
                                }
                            } else if (row.IsPublic) {
                                result = $.formatNumber(2, '', data);
                            } else if (row.IsRestHome) {
                                result = $.formatNumber(4, '', data);
                            }
                        }
                        return result;
                    }
                }
            ],
            order: [[0, "desc"]],
            language: {
                paginate: {
                    next: nextPage,
                    previous: previousPage
                },
                processing: processing,
                zeroRecords: zeroRecords
            },
            "drawCallback": function () {
                $('[data-toggle="tooltip"]').tooltip();
            },
            rowCallback: function (row, data) {
                var eye = $('#eye', row);
                eye.unbind('click');
                eye.bind('click', function () { $scope.showLegalTextId(data.LegalTextId, data.RefundConditionDescription); });

                var forms = $('#forms', row);
                forms.unbind('click');
                forms.bind('click', function () { $scope.showRequestForms(data.RefundConditionId); });
            }
        });
    }

    $scope.showRequestForms = function(refundConditionId) {
        window.open(requestFormsSource + "?refundConditionId=" + refundConditionId, "_blank");
    }

    $scope.priceComparison = function() {
        window.open(priceComparisonSource + "?baseId=" + $scope.searchProduct.Product.BaseId, "_blank");
    }
}]);
sspApp.controller('public.productsearch.legalText.controller', ["$scope", "$timeout", "$filter", "$q", "$modalInstance", "productsearchservice", "legalTextId", "legalTextName", function ($scope, $timeout, $filter, $q, $modalInstance, productsearchservice, legalTextId, legalTextName) {
    $scope.legalTextName = legalTextName;

    function printElement(elem) {
        $('body').addClass('printing');
        var domClone = elem.cloneNode(true);

        var $printSection = document.getElementById("printSection");

        if (!$printSection) {
            var $printSection = document.createElement("div");
            $printSection.id = "printSection";
            document.body.appendChild($printSection);
        }

        $printSection.innerHTML = "";

        $printSection.appendChild(domClone);
    }

    productsearchservice.getLegalTextContent(legalTextId)
            .success(function (data) {
                $scope.legalTextContent = data;
                $timeout(function() {
                    printElement(document.getElementById("printmodel"));
                });
            });

    $scope.close = function () {
        $modalInstance.dismiss('cancel');
    }
}]);
sspApp.factory("productsearch", function () {

    // ++++++++++++++++++
    // +++ Properties +++
    // ++++++++++++++++++

    this.searchType = 'simple';
    this.search = {};

    this.bases = [];
    this.productTypes = [];
    this.productCategories = [];
    this.pharmaceuticalFormTypes = [];
    this.galenicForms = [];
    this.administrationWays = [];
    this.packingTypes = [];
    this.legalBases = [];
    this.chapters = [];
    this.paragraphs = [];
    this.categories = [];
    this.refundingGroups = [];
    this.multiplePrescriptionTypes = [];
    this.firms = [];

    // +++++++++++++++
    // +++ Methods +++
    // +++++++++++++++

    // Simple Search parameters
    this.initializeSimpleSearch = function() {
        this.search.productName = "";
        this.search.baseId = "";
    };

    // Advanced Search parameters
    this.initializeAdvancedSearch = function() {
        this.search.firm = "";
        this.search.productTypeCodeType = "";
        this.search.productCategoryCodeType = "";
        this.search.ctiExtended = "";
        this.search.productId = "";
        this.search.identificationCode = "";
        this.search.atcCode = "";
        this.search.pharmaceuticalFormTypeId = "";
        this.search.galenicFormId = "";
        this.search.administrationCodeType = "";
        this.search.packingTypeId = "";
        this.search.legalBaseId = "";
        this.search.chapterId = "";
        this.search.paragraphId = "";
        this.search.categoryId = "";
        this.search.refundingGroupId = "";
        this.search.multiplePrescriptionTypeCodeType = "";
        this.search.isForfait = "";
        this.search.admissionDate = "";
    };

    this.initSearch = function() {
        switch (this.searchType) {
        case 'simple':
            this.initializeSimpleSearch();
            break;
        case 'advanced':
            this.initializeSimpleSearch();
            this.initializeAdvancedSearch();
            break;
        default:
        }
    };

    this.setSearchType = function(searchType) {
        this.searchType = searchType;
    };

    this.setBases = function(bases) {
        this.bases = bases;
    };

    this.setProductTypes = function(productTypes) {
        this.productTypes = productTypes;
    };

    this.setProductCategories = function(productCategories) {
        this.productCategories = productCategories;
    };

    this.setPharmaceuticalFormTypes = function(pharmaceuticalFormTypes) {
        this.pharmaceuticalFormTypes = pharmaceuticalFormTypes;
    };

    this.setGalenicForms = function(galenicForms) {
        this.galenicForms = galenicForms;
    };

    this.setAdministrationWays = function(administrationWays) {
        this.administrationWays = administrationWays;
    };

    this.setPackingTypes = function(packingTypes) {
        this.packingTypes = packingTypes;
    };

    this.setLegalBases = function(legalBases) {
        this.legalBases = legalBases;
    };

    this.setChapters = function(chapters) {
        this.chapters = chapters;
    };

    this.setParagraphs = function(paragraphs) {
        this.paragraphs = paragraphs;
    };

    this.setCategories = function(categories) {
        this.categories = categories;
    };

    this.setRefundingGroups = function(refundingGroups) {
        this.refundingGroups = refundingGroups;
    };

    this.setFirms = function(firms) {
        this.firms = firms;
    }

    this.setMultiplePrescriptionTypes = function(multiplePrescriptionTypes) {
        this.multiplePrescriptionTypes = multiplePrescriptionTypes;
    };

    return this;
});
"use strict";
sspApp.factory("productsearchservice", ["$rootScope", "$http", function ($rootScope, $http) {
    var productsearchservice = {};

    // --------------
    // --- Search ---
    // --------------

    productsearchservice.getProductsSimpleSearch = function (parameters) {
        $http.get(getProductSimpleSearchSource, {
            params: {
                productName: parameters.productName,
                baseId: parameters.baseId
            }
        });
    };

    productsearchservice.getProductsAdvancedSearch = function (parameters) {
        $http.get(getProductsAdvancedSearchSource, {
            params: {
                firm: parameters.firm,
                productTypeCodeType: parameters.productTypeCodeType,
                productCategoryCodeType: parameters.productCategoryCodeType,
                ctiExtended: parameters.ctiExtended,
                productId: parameters.productId,
                identificationCode: parameters.identificationCode,
                ingredientId: parameters.ingredientId,
                atcCode: parameters.atcCode,
                pharmaceuticalFormTypeId: parameters.pharmaceuticalFormTypeId,
                galenicFormId: parameters.galenicFormId,
                administrationCodeType: parameters.administrationCodeType,
                packingTypeId: parameters.packingTypeId,
                legalBaseId: parameters.legalBaseId,
                chapterId: parameters.chapterId,
                paragraphId: parameters.paragraphId,
                refundingGroupId: parameters.refundingGroupId,
                multiplePrescriptionTypeCodeType: parameters.multiplePrescriptionTypeCodeType,
                isForfait: parameters.isForfait,
                isTemporary: parameters.isTemporary,
                admissionDate: parameters.admissionDate
            }
        });
    };

    productsearchservice.getSimpleSearchParameters = function () {
        return $http.get(getSimpleSearchParametersSource);
    }

    productsearchservice.getAdvancedSearchParameters = function () {
        return $http.get(getAdvancedSearchParametersSource);
    };

    // Auto-complete for AtcCodes
    productsearchservice.getClassificationUIItems = function (request, response) {
        $http.get(getClassificationsByAtcCodeSource, {
            params: {
                search: request.term
            }
        }).success(function (data) {
            return response(data);
        });
    };

    // Auto-complete for Identification codes
    productsearchservice.getIdentificationCodes = function (request, response) {
        if (request.term.length < 4) {
            return response(null);
        }

        $http.get(getIdentificationCodesSource, {
            params: {
                search: request.term
            }
        }).success(function (data) {
            return response(data);
        });

        return response(null);
    };

    productsearchservice.getProductDetails = function (productId) {
        return $http.get(getProductDetailsSource, {
            params: {
                ProductId: productId
            }
        });
    }

    productsearchservice.getLastPublishedDecree = function () {
        return $http.get(getLastPublishedDecreeSource);
    }

    // -----------------
    // --- Refunding ---
    // -----------------

    productsearchservice.getLegalBases = function (productTypeCodeType) {
        return $http.get(getLegalBasesSource, {
            params: {
                ProductTypeCodeType: productTypeCodeType
            }
        });
    };

    productsearchservice.getChaptersForRefundCondition = function (legalBaseId) {
        return $http.get(getChaptersForRefundConditionSource, {
            params: {
                LegalBaseId: legalBaseId
            }
        });
    };

    productsearchservice.getParagraphsForRefundCondition = function (legalBaseId, chapterId) {
        return $http.get(getParagraphsForRefundConditionSource, {
            params: {
                LegalBaseId: legalBaseId,
                ChapterId: chapterId
            }
        });
    };

    productsearchservice.getCategoriesForRefundCondition = function (legalBaseId) {
        return $http.get(getCategoriesForRefundConditionSource, {
            params: {
                LegalBaseId: legalBaseId
            }
        });
    };

    productsearchservice.getRefundingGroupsForRefundCondition = function (legalBaseId, categoryId) {
        return $http.get(getRefundingGroupsForRefundConditionSource, {
            params: {
                LegalBaseId: legalBaseId,
                CategoryId: categoryId
            }
        });
    };

    productsearchservice.getLegalTextContent = function (id) {
        return $http.get(getLegalTextContentSource, {
            params: {
                legalTextId: id
            }
        });
    };

    productsearchservice.getMultiplePrescriptionTypes = function () {
        return $http.get(getMultiplePrescriptionTypesSource);
    }

    return productsearchservice;
}]);
(function() {
    "use strict";

    sspApp.filter("mydate", function () {
        var re = /\\\/Date\(([0-9]*)\)\\\//;
        return function (x) {
            if (x) {
                return new Date(parseInt(x.substr(6)));
            }

            return undefined;
        };
    });
})();

