Explorar o código

commit inicial

Rodney Elpidio Enciso Arias %!s(int64=6) %!d(string=hai) anos
achega
b984138bc4

+ 3 - 0
__init__.py

@@ -0,0 +1,3 @@
+# -*- coding: utf-8 -*-
+import controllers
+import models

BIN=BIN
__init__.pyc


+ 23 - 0
__openerp__.py

@@ -0,0 +1,23 @@
+# -*- coding: utf-8 -*-
+{
+    'name': "Eiru Reports - OdontoImagen",
+    'author': "Eiru",
+    'category': 'report',
+    'version': '0.1',
+    'depends': [
+        'base',
+        'product',
+        'account',
+        'stock',
+        'eiru_assets',
+    ],
+    'qweb': [
+        'static/src/xml/*.xml',
+        'static/src/reports/*.xml'
+    ],
+    'data': [
+        'templates.xml',
+        'views/actions.xml',
+        'views/menus.xml',
+    ],
+}

+ 2 - 0
controllers.py

@@ -0,0 +1,2 @@
+# -*- coding: utf-8 -*-
+from openerp import http

BIN=BIN
controllers.pyc


+ 468 - 0
models.py

@@ -0,0 +1,468 @@
+# -*- coding: utf-8 -*-
+
+from openerp import models, fields, api
+
+class AccountInvoice(models.Model):
+	_inherit = 'account.invoice'
+
+	############################################################
+	#	ACCOUNT INVOICE
+	############################################################
+
+	@api.model
+	def getAccountInvoice(self,domain):
+		AccountInvoice = self.env['account.invoice'].search(domain)
+		decimal_precision = self.env['decimal.precision'].precision_get('Account')
+		values = []
+		for invoice in AccountInvoice:
+			values.append({
+				'id': invoice.id,
+				'type': invoice.type,
+				'state': invoice.state,
+				'number': invoice.number,
+				'journal_id': [
+					invoice.journal_id.id,
+					invoice.journal_id.name
+				],
+				'invoice_currency': [
+					invoice.currency_id.id,
+					invoice.currency_id.name,
+					invoice.currency_id.rate
+				],
+				'company_currency': [
+					invoice.company_id.currency_id.id,
+					invoice.company_id.currency_id.name,
+					invoice.company_id.currency_id.rate
+				],
+				'date_invoice': invoice.date_invoice,
+				'partner_id': [
+					invoice.partner_id.id,
+					invoice.partner_id.name,
+					invoice.partner_id.ruc,
+				],
+				'supplier_invoice_number': invoice.supplier_invoice_number,
+				'user_id': [
+					invoice.user_id.id,
+					invoice.user_id.name
+				],
+                'period_id': [
+                	invoice.period_id.id,
+                	invoice.period_id.name
+                ],
+                'amount_untaxed': invoice.amount_untaxed,
+                'residual': invoice.residual,
+                'amount_tax': invoice.amount_tax,
+				'amount_total': invoice.amount_total,
+				'amount_untaxed_currency': invoice.amount_untaxed * (invoice.company_id.currency_id.rate / invoice.currency_id.rate),
+				'residual_currency': invoice.residual * (invoice.company_id.currency_id.rate / invoice.currency_id.rate),
+				'amount_tax_currency': invoice.amount_tax * (invoice.company_id.currency_id.rate / invoice.currency_id.rate),
+				'amount_total_currency': invoice.amount_total * (invoice.company_id.currency_id.rate / invoice.currency_id.rate),
+			})
+
+		return values
+
+	############################################################
+	#	POS ORDER
+	############################################################
+
+	@api.model
+	def getPosOrder(self,domain):
+		PosOrder = self.env['pos.order'].search(domain)
+		decimal_precision = self.env['decimal.precision'].precision_get('Account')
+		values = []
+		for order in PosOrder:
+			values.append({
+				'id': order.id,
+				'name': order.name,
+				'date_order': order.date_order,
+				'pricelist_id':[
+					order.pricelist_id.id,
+					order.pricelist_id.name,
+				],
+				'partner_id': [
+					order.partner_id.id,
+					order.partner_id.name,
+					order.partner_id.ruc,
+				],
+				'user_id': [
+					order.user_id.id,
+					order.user_id.name
+				],
+				'order_currency': [
+					order.pricelist_id.currency_id.id,
+					order.pricelist_id.currency_id.name,
+					order.pricelist_id.currency_id.rate
+				],
+				'company_currency': [
+					order.company_id.currency_id.id,
+					order.company_id.currency_id.name,
+					order.company_id.currency_id.rate
+				],
+                'amount_tax': order.amount_tax,
+                'amount_total': order.amount_total,
+				'amount_tax_currency': order.amount_tax * (order.company_id.currency_id.rate / order.pricelist_id.currency_id.rate),
+				'amount_total_currency': order.amount_total * (order.company_id.currency_id.rate / order.pricelist_id.currency_id.rate),
+			})
+
+		return values
+
+class AccountInvoiceLine(models.Model):
+	_inherit = 'account.invoice.line'
+
+	############################################################
+	#	ACCOUNT INVOICE LINE
+	############################################################
+
+	@api.model
+	def getAccountInvoiceLine(self,domain):
+		AccountInvoiceLine = self.env['account.invoice.line'].search(domain)
+		decimal_precision = self.env['decimal.precision'].precision_get('Account')
+		values = []
+		for line in AccountInvoiceLine:
+			values.append({
+				'id': line.id,
+				'invoice_id':line.invoice_id.id,
+				'number':line.invoice_id.number,
+				'supplier_invoice_number':line.invoice_id.supplier_invoice_number,
+				'date_invoice': line.invoice_id.date_invoice,
+				'user_id': [
+					line.invoice_id.user_id.id,
+					line.invoice_id.user_id.name,
+				],
+				'partner_id': [
+					line.invoice_id.partner_id.id,
+					line.invoice_id.partner_id.name,
+				],
+				'product_id': [
+					line.product_id.id,
+					line.product_id.display_name,
+					line.product_id.categ_id.complete_name,
+				],
+				'price_unit': line.price_unit,
+				'price_subtotal': line.price_subtotal,
+				'quantity': line.quantity,
+				'company_currency':[
+					line.invoice_id.company_id.currency_id.id,
+					line.invoice_id.company_id.currency_id.name,
+					line.invoice_id.company_id.currency_id.rate,
+				],
+				'invoice_currency':[
+					line.invoice_id.currency_id.id,
+					line.invoice_id.currency_id.name,
+					line.invoice_id.currency_id.rate,
+				],
+				'price_unit_currency': round(line.price_unit * (line.invoice_id.company_id.currency_id.rate / line.invoice_id.currency_id.rate),decimal_precision),
+				'price_subtotal_currency': round(line.price_subtotal * (line.invoice_id.company_id.currency_id.rate / line.invoice_id.currency_id.rate),decimal_precision),
+				'tax_currency': round((line.price_unit * (line.invoice_id.company_id.currency_id.rate / line.invoice_id.currency_id.rate) * line.quantity) - line.price_subtotal * (line.invoice_id.company_id.currency_id.rate / line.invoice_id.currency_id.rate),decimal_precision),
+				'amount_currency': round((line.quantity * line.price_unit) * (line.invoice_id.company_id.currency_id.rate / line.invoice_id.currency_id.rate),decimal_precision),
+			})
+
+		return values
+
+	############################################################
+	#	POS ORDER LINE
+	############################################################
+
+	@api.model
+	def getPosOrderLine(self,domain):
+		PosOrderLine = self.env['pos.order.line'].search(domain)
+		decimal_precision = self.env['decimal.precision'].precision_get('Account')
+		values = []
+		for line in PosOrderLine:
+			values.append({
+				'id': line.id,
+				'order_id': [
+					line.order_id.id,
+					line.order_id.name
+				],
+				'product_id': [
+					line.product_id.id,
+					line.product_id.display_name,
+				],
+				'qty': line.qty,
+				'create_date': line.create_date,
+				'user_id': [
+					line.order_id.user_id.id,
+					line.order_id.user_id.name
+				],
+				'partner_id': [
+					line.order_id.partner_id.id,
+					line.order_id.partner_id.name
+				],
+				'company_currency':[
+					line.order_id.company_id.currency_id.id,
+					line.order_id.company_id.currency_id.name,
+					line.order_id.company_id.currency_id.rate,
+				],
+				'order_currency':[
+					line.order_id.pricelist_id.currency_id.id,
+					line.order_id.pricelist_id.currency_id.name,
+					line.order_id.pricelist_id.currency_id.rate,
+				],
+				'price_unit': line.price_unit,
+				'price_subtotal': line.price_subtotal,
+				'price_subtotal_incl': line.price_subtotal_incl,
+				'price_unit_currency': round(line.price_unit * (line.order_id.company_id.currency_id.rate / line.order_id.pricelist_id.currency_id.rate),decimal_precision),
+				'price_subtotal_currency': round(line.price_subtotal * (line.order_id.company_id.currency_id.rate / line.order_id.pricelist_id.currency_id.rate),decimal_precision),
+				'price_subtotal_incl_currency': round(line.price_subtotal_incl * (line.order_id.company_id.currency_id.rate / line.order_id.pricelist_id.currency_id.rate),decimal_precision),
+				# 'amount_currency': round(line.price_subtotal_incl * (line.order_id.company_id.currency_id.rate / line.order_id.pricelist_id.currency_id.rate),decimal_precision)
+			})
+
+		return values
+
+class AccountJournal(models.Model):
+	_inherit = 'account.journal'
+
+	@api.model
+	def getAccountJournal(self,domain):
+		AccountJournal = self.env['account.journal'].search(domain)
+		values = []
+		for journal in AccountJournal:
+			values.append({
+				'id': journal.id,
+				'name': journal.name,
+				'store_ids': [
+					journal.store_ids.id,
+				],
+				'company_id': [
+					journal.company_id.id,
+					journal.company_id.name
+				],
+			})
+
+		return values
+
+class ResCompany(models.Model):
+	_inherit = 'res.company'
+
+	@api.model
+	def getResCompany(self,domain):
+		ResCompany = self.env['res.company'].search(domain)
+		values = []
+		for company in ResCompany:
+			values.append({
+				'id': company.id,
+				'name': company.name,
+				'currency_id': [
+					company.currency_id.id,
+					company.currency_id.name,
+				],
+				'company_ruc': company.partner_id.ruc,
+				'phone': company.phone,
+				'logo': company.logo,
+			})
+
+		return values
+
+class ResCurrency(models.Model):
+	_inherit = 'res.currency'
+
+	@api.model
+	def getResCurrency(self,domain):
+		ResCurrency = self.env['res.currency'].search(domain)
+		values = []
+		for currency in ResCurrency:
+			values.append({
+				'id': currency.id,
+				'name': currency.name,
+				'symbol': currency.symbol,
+				'rate_silent': currency.rate_silent,
+				'base': currency.base,
+				'decimal_separator': currency.decimal_separator,
+				'decimal_places': currency.decimal_places,
+				'thousands_separator': currency.thousands_separator,
+				'symbol_position': currency.symbol_position,
+			})
+
+		return values
+
+class ResPartner(models.Model):
+	_inherit = 'res.partner'
+
+	@api.model
+	def getResPartnerMedic(self,domain):
+		ResPartner = self.env['res.partner'].search(domain)
+		values = []
+		for partner in ResPartner:
+			values.append({
+				'id': partner.id,
+				'name': partner.name,
+				'ruc': partner.ruc,
+				'street': partner.street,
+				'city': partner.city,
+				'phone': partner.phone,
+				'mobile': partner.mobile,
+				'email': partner.email,
+				'property_product_pricelist': partner.property_product_pricelist.name,
+				'property_product_pricelist_purchase': partner.property_product_pricelist_purchase.name,
+				'credit': partner.credit,
+				'debit': partner.debit,
+				'supplier': partner.supplier,
+				'is_medic': partner.is_medic,
+				'medic': [
+					partner.medic.id,
+					partner.medic.name,
+				],
+			})
+
+		return values
+
+class ProductProduct(models.Model):
+	_inherit = 'product.product'
+
+	############################################################
+	#	PRODUCT PRODUCT
+	############################################################
+
+	@api.model
+	def getProductProduct(self,domain):
+		ProductProduct = self.env['product.product'].search(domain)
+		values = []
+		for product in ProductProduct:
+			attributeValuesLines = map(lambda x: x.id, product.attribute_value_ids)
+			attributeIDS = []
+			for arttIds in self.env['product.attribute.value'].search([('id', 'in', attributeValuesLines)]):
+				attributeIDS.append(arttIds.attribute_id.id)
+
+			try:
+				brand = product.product_brand_id.id
+			except:
+				brand = ''
+
+			values.append({
+				'id': product.id,
+				'name': product.name,
+				'display_name': product.display_name,
+				'standard_price': product.standard_price,
+				'lst_price': product.lst_price,
+				'categ_id': {
+					'id': product.categ_id.id,
+					'name': product.categ_id.name,
+					'complete_name': product.categ_id.complete_name,
+				},
+				'product_brand_id': brand,
+				'atribute_value_ids': attributeValuesLines,
+				'attribute_ids': attributeIDS
+			})
+
+		return values
+
+	############################################################
+	#	PRODUCT BRAND
+	############################################################
+
+	@api.model
+	def getProductBrand(self,domain):
+		ProductBrand = self.env['product.brand'].search(domain)
+		values = []
+		for brand in ProductBrand:
+			values.append({
+				'id': brand.id,
+				'name': brand.name,
+			})
+
+		return values
+
+class ProductCategory(models.Model):
+	_inherit = 'product.category'
+
+	@api.model
+	def getProductCategory(self,domain):
+		ProductCategory = self.env['product.category'].search(domain)
+		values = []
+		for category in ProductCategory:
+			values.append({
+				'id': category.id,
+				'name': category.name,
+				'display_name': category.display_name,
+				'parent_id': [
+					category.parent_id.id,
+					category.parent_id.name,
+				],
+			})
+
+		return values
+
+class ProductAttribute(models.Model):
+	_inherit = 'product.attribute'
+
+	@api.model
+	def getProductAttribute(self,domain):
+		ProductAttribute = self.env['product.attribute'].search(domain)
+		values = []
+		for attribute in ProductAttribute:
+			values.append({
+				'id': attribute.id,
+				'name': attribute.name,
+			})
+
+		return values
+
+class ProductAttributeValue(models.Model):
+	_inherit = 'product.attribute.value'
+
+	@api.model
+	def getProductAttributeValue(self,domain):
+		ProductAttributeValue = self.env['product.attribute.value'].search(domain)
+		values = []
+		for value in ProductAttributeValue:
+			values.append({
+				'id': value.id,
+				'name': value.name,
+				'attribute_id': [
+					value.attribute_id.id,
+					value.attribute_id.name,
+				],
+			})
+
+		return values
+
+class StockLocation(models.Model):
+	_inherit = 'stock.location'
+
+	@api.model
+	def getStockLocation(self,domain):
+		StockLocation = self.env['stock.location'].search(domain)
+		values = []
+		for location in StockLocation:
+			values.append({
+				'id': location.id,
+				'name': location.name,
+				'display_name': location.display_name,
+				'company_id': [
+					location.company_id.id,
+					location.company_id.name,
+				],
+				'store_id': [
+					location.store_id.id,
+					location.store_id.name,
+				],
+				'usage': location.usage,
+			})
+
+		return values
+
+class StockQuant(models.Model):
+	_inherit = 'stock.quant'
+
+	@api.model
+	def getStockQuant(self,domain):
+		StockQuant = self.env['stock.quant'].search(domain)
+		values = []
+		for quant in StockQuant:
+			values.append({
+				'id': quant.id,
+				'name': quant.name,
+				'display_name': quant.display_name,
+				'location_id': [
+					quant.location_id.id,
+					quant.location_id.name,
+				],
+				'product_id': [
+					quant.product_id.id,
+					quant.product_id.name,
+				],
+				'qty': quant.qty,
+			})
+
+		return values

BIN=BIN
models.pyc


BIN=BIN
static/description/icon.png


+ 274 - 0
static/src/js/chart.js

@@ -0,0 +1,274 @@
+function chart(reporting) {
+    "use strict";
+
+    var model = openerp;
+
+    reporting.ReportChartWidget = reporting.Base.extend({
+        BuildLineChart: function (label,data,CurrencyBase) {
+            var self = this;
+            Chart.scaleService.updateScaleDefaults('linear', {
+                ticks: {
+                    callback: function(tick) {
+                        return tick.toLocaleString('de-DE');
+                    }
+                }
+            });
+            Chart.defaults.global.tooltips.callbacks.label = function(tooltipItem, data) {
+                var dataset = data.datasets[tooltipItem.datasetIndex];
+                var datasetLabel = dataset.label || '';
+                return datasetLabel +  dataset.data[tooltipItem.index].toLocaleString('de-DE');
+            };
+            var chart = new Chart($(".reporting-chart"), {
+                type: 'line',
+                data: {
+                    labels: label,
+                    datasets: [
+                        {
+                            label: false,
+                            data: data,
+                            backgroundColor: '#bbdefb',
+                            borderColor: '#0288d1',
+                            borderWidth: 1,
+                            fill: true,
+                        }
+                    ]
+                },
+                options: {
+                    responsive: true,
+                    responsiveAnimationDuration:10,
+                    maintainAspectRatio:false,
+                    title: {
+                        display: false,
+                    },
+                    hover: {
+                        mode: 'nearest',
+                        intersect: true
+                    },
+                    legend: {
+                       display: false,
+                    },
+                    layout: {
+                        padding: {
+                            top: 0,
+                            bottom: 0,
+                            left : 0,
+                            rigth: 0,
+                        }
+                    },
+                    events: ['click'],
+                    tooltips: {
+                        callbacks: {
+                            label: function(tooltipItem, data) {
+                                var label = data.datasets[tooltipItem.datasetIndex].label || '';
+
+                                if (label) {
+                                    label += ': ';
+                                }
+                                label += accounting.formatMoney(tooltipItem.yLabel, CurrencyBase.symbol, CurrencyBase.decimal_places, CurrencyBase.thousands_separator, CurrencyBase.decimal_separator);
+                                return label;
+                            }
+                        }
+                    }
+                }
+            });
+        },
+        fetchBarChart: function (data,CurrencyBase,label,body) {
+            var self = this;
+            var rank = 10;
+            var item;
+            // var label = [];
+            // var body = [];
+            //
+            // for (var i = 0; i < rank; i++) {
+            //     if (data[i]){
+            //         item = data[i];
+            //     }else{
+            //         item = {};
+            //         item.product = "N/A";
+            //         item.amount = 0;
+            //     }
+            //     label.push(item.product.trim());
+            //     body.push(item.amount);;
+            // }
+
+            Chart.scaleService.updateScaleDefaults('linear', {
+              ticks: {
+                callback: function(tick) {
+                    return tick.toLocaleString('de-DE');
+                }
+              }
+            });
+            Chart.defaults.global.tooltips.callbacks.label = function(tooltipItem, data) {
+                var dataset = data.datasets[tooltipItem.datasetIndex];
+                var datasetLabel = dataset.label || '';
+                return datasetLabel +  dataset.data[tooltipItem.index].toLocaleString('de-DE');
+            };
+
+            var coloR = [];
+            coloR.push('#1976d2');
+            coloR.push('#e53935');
+            coloR.push('#9575cd');
+            coloR.push('#009688');
+            coloR.push('#43a047');
+            coloR.push('#cddc39');
+            coloR.push('#f9a825');
+            coloR.push('#ff5722');
+            coloR.push('#6d4c41');
+            coloR.push('#ffff00');
+
+            var chart = new Chart($(".reporting-chart"), {
+                type: 'horizontalBar',
+                data: {
+                    labels: label,
+                    datasets: [
+                        {
+                            label: false,
+                            data: body,
+                            backgroundColor: coloR,
+                            fill: true,
+                        }
+                    ]
+                },
+                options: {
+                    responsive: true,
+                    responsiveAnimationDuration:10,
+                    maintainAspectRatio:false,
+                    title: {
+                        display: false,
+                    },
+                    hover: {
+                        mode: 'nearest',
+                        intersect: true
+                    },
+                    legend: {
+                       display: false,
+                    },
+                    layout: {
+                        padding: {
+                            top: 0,
+                            bottom: 0,
+                            left : 0,
+                            rigth: 0,
+                        }
+                    },
+                    tooltips: {
+                        callbacks: {
+                            label: function(tooltipItem, data) {
+                                var label = data.datasets[tooltipItem.datasetIndex].label || '';
+
+                                if (label) {
+                                    label += ': ';
+                                }
+                                label += accounting.formatMoney(tooltipItem.xLabel, CurrencyBase.symbol, CurrencyBase.decimal_places, CurrencyBase.thousands_separator, CurrencyBase.decimal_separator);
+                                return label;
+                            }
+                        }
+                    },
+                    events: ['click'],
+                }
+            });
+        },
+        fetchPieChart: function (data,CurrencyBase,label,body) {
+            var self = this;
+            // var rank = 9;
+            // var item;
+            // var label = [];
+            // var body = [];
+            //
+            // var amount_total = _.reduce(_.map(data, function (map) {
+            //     return map.amount
+            // }), function (meno,num) {
+            //     return meno + num
+            // }, 0);
+            //
+            // for (var i = 0; i < rank; i++) {
+            //     if (data[i]){
+            //         item = data[i];
+            //     }else{
+            //         item = {};
+            //         item.product = "N/A";
+            //         item.amount = 0;
+            //     }
+            //     label.push(item.product.trim());
+            //     body.push((item.amount/amount_total)*100);
+            // }
+            //
+            // var num = 0;
+            // for (var i = 9; i < data.length; i++) {
+            //     num += data[i].amount;
+            // }
+            //
+            // if(num > 0){
+            //     label.push('Otros productos');
+            //     body.push((num/amount_total)*100);
+            // }
+
+            var coloR = [];
+            coloR.push('#1976d2');
+            coloR.push('#e53935');
+            coloR.push('#9575cd');
+            coloR.push('#009688');
+            coloR.push('#43a047');
+            coloR.push('#cddc39');
+            coloR.push('#f9a825');
+            coloR.push('#ff5722');
+            coloR.push('#6d4c41');
+            coloR.push('#ffff00');
+
+            var chart = new Chart($(".reporting-pie-chart"), {
+                type: 'pie',
+                data: {
+                    labels: label,
+                    datasets: [
+                        {
+                            label: false,
+                            data: body,
+                            backgroundColor: coloR,
+                            fill: true,
+                        }
+                    ]
+                },
+
+                options: {
+                    responsive: true,
+                    responsiveAnimationDuration:10,
+                    maintainAspectRatio:false,
+                    hover: {
+                        mode: 'nearest',
+                        intersect: true
+                    },
+                    legend: {
+                       position: 'right',
+                    },
+                    layout: {
+                        padding: {
+                            top: 0,
+                            bottom: 0,
+                            left : 0,
+                            rigth: 0,
+                        }
+                    },
+                    tooltips: {
+                        callbacks: {
+                            label: function(tooltipItem, data) {
+                                var label = data.datasets[tooltipItem.datasetIndex].label || '';
+                                if (label) {
+                                    label += ': ';
+                                }
+                                label += accounting.formatMoney(data.datasets[0].data[tooltipItem.index],{
+                                    symbol: "%",
+                                    format: "%v%s",
+                                    precision: 2,
+                                    thousand: ".",
+                                    decimal: ","
+                                });
+                                return label;
+                            }
+                        }
+                    },
+                    events: ['click'],
+                }
+            });
+        },
+    });
+}

+ 40 - 0
static/src/js/datepicker.js

@@ -0,0 +1,40 @@
+function datepicker(reporting) {
+    "use strict";
+
+    var model = openerp;
+
+    reporting.ReportDatePickerWidget = reporting.Base.extend({
+        fecthFecha: function() {
+            var to;
+            var dateFormat1 = "mm/dd/yy",
+            from = $( "#from" )
+            .datepicker({
+                dateFormat: "dd/mm/yy",
+                changeMonth: true,
+                numberOfMonths: 1,
+            })
+            .on( "change", function() {
+                to.datepicker( "option", "minDate", getDate(this), "dd/mm/yyyy");
+            });
+            to = $( "#to" ).datepicker({
+                dateFormat: "dd/mm/yy",
+                defaultDate: "+7d",
+                changeMonth: true,
+                numberOfMonths: 1,
+            })
+            .on( "change", function() {
+                from.datepicker( "option", "maxDate", getDate(this));
+            });
+            function getDate( element ) {
+                var fechaSel =element.value.split('/');
+                var date;
+                try {
+                    date = $.datepicker.parseDate( dateFormat1, (fechaSel[1]+"/"+fechaSel[0]+"/"+fechaSel[2]));
+                } catch( error ) {
+                    date = null;
+                }
+                return date;
+            }
+        },
+    });
+}

+ 18 - 0
static/src/js/main.js

@@ -0,0 +1,18 @@
+openerp.eiru_reports_odontoimagen = function (instance) {
+    "use strict";
+
+    var reporting = instance.eiru_reports_odontoimagen;
+
+    reporting_base(instance,reporting);
+
+    try {
+        pdf(reporting);
+        chart(reporting);
+        datepicker(reporting);
+        report_doctor_ranking(reporting);
+    } catch (e) {
+        // ignorar error
+    }
+
+    instance.web.client_actions.add('eiru_reports_odontoimagen.doctor_ranking_action', 'instance.eiru_reports_odontoimagen.ReportDoctorRankingWidget');
+}

+ 397 - 0
static/src/js/pdf.js

@@ -0,0 +1,397 @@
+function pdf(reporting) {
+    "use strict";
+
+    var model = openerp;
+
+    reporting.ReportPdfWidget = reporting.Base.extend({
+        drawPDF: function (getColumns,row,ResCompany,pdf_title,pdf_type,pdf_name,pdf_columnStyles) {
+            var self = this;
+            var base64Img = 'data:image/png;base64,' + ResCompany.logo;
+            var hoy = moment().format('DD/MM/YYYY');
+            var totalPagesExp = "{total_pages_count_string}";
+            var pdfDoc = new jsPDF(pdf_type);
+            console.log(getColumns);
+            pdfDoc.autoTable(getColumns, row, {
+                // showHeader: 'firstPage',
+                theme: 'grid',
+                styles: {
+                    overflow: 'linebreak',
+                    columnWidth: 'auto',
+                    fontSize: 7,
+                },
+                headerStyles: {
+                    fillColor: [76, 133, 248],
+                    fontSize: 9
+                },
+                columnStyles: pdf_columnStyles,
+                margin: { top: 20, horizontal: 7},
+                addPageContent: function (data) {
+                    pdfDoc.addImage(base64Img, 'png', 7, 2, 0, 15);
+                    if(pdf_type == 'l'){
+                        pdfDoc.setFontSize(12);
+                        pdfDoc.setFontStyle('bold');
+                        pdfDoc.setTextColor(40);
+                        pdfDoc.text(pdf_title,130,10);
+                    }else{
+                        pdfDoc.setFontSize(12);
+                        pdfDoc.setFontStyle('bold');
+                        pdfDoc.setTextColor(40);
+                        pdfDoc.text(pdf_title,80,10);
+                    }
+                    pdfDoc.setFontSize(9);
+                    pdfDoc.setFontStyle('normal');
+                    pdfDoc.setTextColor(40)
+                    pdfDoc.text(pdfDoc.internal.pageSize.getWidth() - 55, 14," Fecha de Expedición: " + hoy);
+
+                    /*===========
+                        FOOTER
+                    ===========*/
+                    var str = "Página " + data.pageCount;
+                    if (typeof pdfDoc.putTotalPages === 'function') {
+                        str = str + " de " + totalPagesExp;
+                    }
+                    pdfDoc.setFontSize(9);
+                    pdfDoc.setFontStyle('bold');
+                    pdfDoc.setTextColor(40);
+                    var pageHeight = pdfDoc.internal.pageSize.height || pdfDoc.internal.pageSize.getHeight();
+                    pdfDoc.text(str, pdfDoc.internal.pageSize.getWidth() - 55, pageHeight - 5);
+                }
+            });
+            if (typeof pdfDoc.putTotalPages === 'function') {
+                pdfDoc.putTotalPages(totalPagesExp);
+            }
+            row.pop();
+            if(model.printer_bridge){
+                var data = pdfDoc.output('datauristring');
+                model.printer_bridge.print(data);
+                return;
+            }
+            pdfDoc.save(pdf_name + hoy + '.pdf');
+        },
+
+        drawSaleJournalPDF: function (getColumns,row,ResCompany,pdf_title,pdf_type,pdf_name,pdf_columnStyles,desde,hasta) {
+            var self = this;
+            var base64Img = 'data:image/png;base64,' + ResCompany.logo;
+            var hoy = moment().format('DD/MM/YYYY');
+            var totalPagesExp = "{total_pages_count_string}";
+            var pdfDoc = new jsPDF(pdf_type);
+
+            /*
+            ==============================================
+                PRIMERA COLUMNA
+            ==============================================
+            */
+
+            // Title
+            pdfDoc.setFontSize(15);
+            pdfDoc.setFontStyle('bold');
+            pdfDoc.setTextColor(40);
+            pdfDoc.text(pdf_title,7,10);
+
+            // DEL
+            pdfDoc.setFontSize(10);
+            pdfDoc.setFontStyle('normal');
+            pdfDoc.setTextColor(40);
+            pdfDoc.text('DEL: ' + desde,7,20);
+
+            // AL
+            pdfDoc.setFontSize(10);
+            pdfDoc.setFontStyle('normal');
+            pdfDoc.setTextColor(40);
+            pdfDoc.text('AL: ' + hasta ,7,24);
+
+            /*
+            ==============================================
+                SEGUNDA COLUMNA
+            ==============================================
+            */
+
+            // CODIGO DESDE
+            pdfDoc.setFontSize(10);
+            pdfDoc.setFontStyle('normal');
+            pdfDoc.setTextColor(40);
+            pdfDoc.text('Código Desde: ' + 1 ,50,20);
+
+            // CODIGO HASTA
+            pdfDoc.setFontSize(10);
+            pdfDoc.setFontStyle('normal');
+            pdfDoc.setTextColor(40);
+            pdfDoc.text('Código Hasta: ' + (row.length - 1),50,24);
+
+            /*
+            ==============================================
+                QUINTA COLUMNA
+            ==============================================
+            */
+
+            // Empresa
+            pdfDoc.setFontSize(10);
+            pdfDoc.setFontStyle('normal');
+            pdfDoc.setTextColor(40);
+            pdfDoc.text('Empresa: ' + ResCompany.name ,100,20);
+
+            // RUC
+            pdfDoc.setFontSize(10);
+            pdfDoc.setFontStyle('normal');
+            pdfDoc.setTextColor(40);
+            pdfDoc.text('R.U.C: ' + ResCompany.company_ruc ,100,24);
+
+            /*
+            ==============================================
+                CREACION DEL PDF
+            ==============================================
+            */
+
+            pdfDoc.autoTable(getColumns, row, {
+                showHeader: 'false',
+                theme: 'grid',
+
+                drawRow: function (row, data) {
+                    if(pdf_type == "l"){
+                        if (row.index === 0) {
+                            pdfDoc.setTextColor(40);
+                            pdfDoc.setFontSize(8);
+                            pdfDoc.setFontStyle('bold');
+                            // Documento
+                            pdfDoc.rect(data.settings.margin.left, row.y, 52, 8, 'S');
+                            // Clientes
+                            pdfDoc.rect(59, row.y, 72, 8, 'S');
+                            // Total de Ventas
+                            pdfDoc.rect(131, row.y, 162, 8, 'S');
+                            pdfDoc.autoTableText("DOCUMENTO", 33, row.y + row.height / 2, {
+                                halign: 'center',
+                                valign: 'middle'
+                            });
+                            pdfDoc.autoTableText("CLIENTES", 95, row.y + row.height / 2, {
+                                halign: 'center',
+                                valign: 'middle'
+                            });
+                            pdfDoc.autoTableText("TOTAL DE VENTAS", 210, row.y + row.height / 2, {
+                                halign: 'center',
+                                valign: 'middle'
+                            });
+                            // NUM
+                            pdfDoc.rect(data.settings.margin.left, row.y + 8, 31, 8, 'S');
+                            pdfDoc.autoTableText("NUM", 22, row.y + row.height / 2 + 8, {
+                                halign: 'center',
+                                valign: 'middle'
+                            });
+                            // FECHA
+                            pdfDoc.rect(38, row.y + 8, 21, 8, 'S');
+                            pdfDoc.autoTableText("FECHA", 47, row.y + row.height / 2 + 8, {
+                                halign: 'center',
+                                valign: 'middle'
+                            });
+                            // RAZON SOCIAL
+                            pdfDoc.rect(59, row.y + 8, 52, 8, 'S');
+                            pdfDoc.autoTableText("RAZON SOCIAL", 83, row.y + row.height / 2 + 8, {
+                                halign: 'center',
+                                valign: 'middle'
+                            });
+                            // RUC
+                            pdfDoc.rect(111, row.y + 8, 20, 8, 'S');
+                            pdfDoc.autoTableText("RUC", 120, row.y + row.height / 2 + 8, {
+                                halign: 'center',
+                                valign: 'middle'
+                            });
+                            // GRAVADAS
+                            pdfDoc.rect(131, row.y + 8, 28, 8, 'S');
+                            pdfDoc.autoTableText("GRAVADAS", 145, row.y + row.height / 2 + 8, {
+                                halign: 'center',
+                                valign: 'middle'
+                            });
+                            // %
+                            pdfDoc.rect(159, row.y + 8, 9, 8, 'S');
+                            pdfDoc.autoTableText("%", 163, row.y + row.height / 2 + 8, {
+                                halign: 'center',
+                                valign: 'middle'
+                            });
+                            // IMPUESTOS
+                            pdfDoc.rect(168, row.y + 8, 25, 8, 'S');
+                            pdfDoc.autoTableText("IMPUESTOS", 180, row.y + row.height / 2 + 8, {
+                                halign: 'center',
+                                valign: 'middle'
+                            });
+                            // EXENTAS
+                            pdfDoc.rect(193, row.y + 8, 30, 8, 'S');
+                            pdfDoc.autoTableText("EXENTAS", 209, row.y + row.height / 2 + 8, {
+                                halign: 'center',
+                                valign: 'middle'
+                            });
+                            // Ret IVA
+                            pdfDoc.rect(223, row.y + 8, 20, 8, 'S');
+                            pdfDoc.autoTableText("Ret IVA", 232, row.y + row.height / 2 + 8, {
+                                halign: 'center',
+                                valign: 'middle'
+                            });
+                            // Ret Renta
+                            pdfDoc.rect(243, row.y + 8, 20, 8, 'S');
+                            pdfDoc.autoTableText("Ret RENTA", 253, row.y + row.height / 2 + 8, {
+                                halign: 'center',
+                                valign: 'middle'
+                            });
+                            // TOTAL
+                            pdfDoc.rect(263, row.y + 8, 30, 8, 'S');
+                            pdfDoc.autoTableText("TOTAL", 276, row.y + row.height / 2 + 8, {
+                                halign: 'center',
+                                valign: 'middle'
+                            });
+                            data.cursor.y += 16;
+                        };
+                    }else{
+                        if (row.index === 0) {
+                            pdfDoc.setTextColor(40);
+                            pdfDoc.setFontSize(8);
+                            pdfDoc.setFontStyle('bold');
+                            // Documento
+                            pdfDoc.rect(data.settings.margin.left, row.y, 43, 8, 'S');
+                            // Clientes
+                            pdfDoc.rect(50, row.y, 53, 8, 'S');
+                            // Total de Ventas
+                            pdfDoc.rect(103, row.y, 100, 8, 'S');
+                            pdfDoc.autoTableText("DOCUMENTO", 29, row.y + row.height / 2, {
+                                halign: 'center',
+                                valign: 'middle'
+                            });
+                            pdfDoc.autoTableText("CLIENTES", 77, row.y + row.height / 2, {
+                                halign: 'center',
+                                valign: 'middle'
+                            });
+                            pdfDoc.autoTableText("TOTAL DE VENTAS",148, row.y + row.height / 2, {
+                                halign: 'center',
+                                valign: 'middle'
+                            });
+                            // NUM
+                            pdfDoc.setFontSize(6);
+                            pdfDoc.rect(data.settings.margin.left, row.y + 8, 27, 8, 'S');
+                            pdfDoc.autoTableText("NUM", 21, row.y + row.height / 2 + 8, {
+                                halign: 'center',
+                                valign: 'middle'
+                            });
+                            // FECHA
+                            pdfDoc.rect(34, row.y + 8, 16, 8, 'S');
+                            pdfDoc.autoTableText("FECHA", 42, row.y + row.height / 2 + 8, {
+                                halign: 'center',
+                                valign: 'middle'
+                            });
+                            // RAZON SOCIAL
+                            pdfDoc.rect(50, row.y + 8, 35, 8, 'S');
+                            pdfDoc.autoTableText("RAZON SOCIAL", 68, row.y + row.height / 2 + 8, {
+                                halign: 'center',
+                                valign: 'middle'
+                            });
+                            // RUC
+                            pdfDoc.rect(85, row.y + 8, 18, 8, 'S');
+                            pdfDoc.autoTableText("RUC", 95, row.y + row.height / 2 + 8, {
+                                halign: 'center',
+                                valign: 'middle'
+                            });
+                            // GRAVADAS
+                            pdfDoc.rect(103, row.y + 8, 20, 8, 'S');
+                            pdfDoc.autoTableText("GRAVADAS", 113, row.y + row.height / 2 + 8, {
+                                halign: 'center',
+                                valign: 'middle'
+                            });
+                            // %
+                            pdfDoc.rect(123, row.y + 8, 5, 8, 'S');
+                            pdfDoc.autoTableText("%", 126, row.y + row.height / 2 + 8, {
+                                halign: 'center',
+                                valign: 'middle'
+                            });
+                            // IMPUESTOS
+                            pdfDoc.rect(128, row.y + 8, 15, 8, 'S');
+                            pdfDoc.autoTableText("IMPUESTOS", 136, row.y + row.height / 2 + 8, {
+                                halign: 'center',
+                                valign: 'middle'
+                            });
+                            // EXENTAS
+                            pdfDoc.rect(143, row.y + 8, 20, 8, 'S');
+                            pdfDoc.autoTableText("EXENTAS", 152, row.y + row.height / 2 + 8, {
+                                halign: 'center',
+                                valign: 'middle'
+                            });
+                            // Ret IVA
+                            pdfDoc.rect(163, row.y + 8, 10, 8, 'S');
+                            pdfDoc.autoTableText("Ret", 168, row.y + row.height / 2 + 8, {
+                                halign: 'center',
+                                valign: 'middle'
+                            });
+                            pdfDoc.autoTableText("IVA", 168, row.y + row.height / 2 + 10, {
+                                halign: 'center',
+                                valign: 'middle'
+                            });
+                            // Ret Renta
+                            pdfDoc.rect(173, row.y + 8, 10, 8, 'S');
+                            pdfDoc.autoTableText("Ret", 179, row.y + row.height / 2 + 8, {
+                                halign: 'center',
+                                valign: 'middle'
+                            });
+                            pdfDoc.autoTableText("RENTA", 178, row.y + row.height / 2 + 10, {
+                                halign: 'center',
+                                valign: 'middle'
+                            });
+                            // TOTAL
+                            pdfDoc.rect(183, row.y + 8, 20, 8, 'S');
+                            pdfDoc.autoTableText("TOTAL", 192, row.y + row.height / 2 + 8, {
+                                halign: 'center',
+                                valign: 'middle'
+                            });
+                            data.cursor.y += 16;
+                        };
+                    }
+                },
+
+                drawCell: function(cell, data) {
+                    var rows = data.table.rows;
+                    if (data.row.index == rows.length - 1) {
+                        pdfDoc.setFillColor(200, 200, 255);
+                    }
+                },
+
+                styles: {
+                    overflow: 'linebreak',
+                    columnWidth: 'auto',
+                    fontSize: 7,
+                },
+                headerStyles: {
+                    fillColor: [76, 133, 248],
+                    fontSize: 9
+                },
+
+                columnStyles: pdf_columnStyles,
+                margin: { top: 28, horizontal: 7},
+
+                addPageContent: function (data) {
+                    /*===========
+                        FOOTER
+                    ===========*/
+                    var str = "Página " + data.pageCount;
+                    if (typeof pdfDoc.putTotalPages === 'function') {
+                        str = str + " de " + totalPagesExp;
+                    }
+                    pdfDoc.setFontSize(9);
+                    pdfDoc.setFontStyle('bold');
+                    pdfDoc.setTextColor(40);
+                    var pageHeight = pdfDoc.internal.pageSize.height || pdfDoc.internal.pageSize.getHeight();
+                    pdfDoc.text(str, pdfDoc.internal.pageSize.getWidth() - 55, pageHeight - 5);
+                }
+            });
+
+            pdfDoc.setFontSize(9);
+            pdfDoc.setFontStyle('bold');
+            pdfDoc.setTextColor(40);
+            pdfDoc.text('Listado concluido', 7, pdfDoc.autoTable.previous.finalY + 5);
+
+            if (typeof pdfDoc.putTotalPages === 'function') {
+                pdfDoc.putTotalPages(totalPagesExp);
+            }
+            row.pop();
+            if(model.printer_bridge){
+                var data = pdfDoc.output('datauristring');
+                model.printer_bridge.print(data);
+                return;
+            }
+            pdfDoc.save(pdf_name + hoy + '.pdf');
+        },
+    });
+}

+ 22 - 0
static/src/js/reporting_base.js

@@ -0,0 +1,22 @@
+function reporting_base (instance, widget) {
+    "use strict";
+
+    widget.Base = instance.Widget.extend({
+
+        position: 0,
+
+        init: function (parent, position) {
+            this._super(parent);
+            this.position = position || this.position;
+        },
+        start: function () {
+            
+        },
+        getPosition: function () {
+            return this.position;
+        },
+        setPosition: function (position) {
+            this.position = position;
+        }
+    });
+}

+ 989 - 0
static/src/js/reports/report_doctor_ranking.js

@@ -0,0 +1,989 @@
+function report_doctor_ranking(reporting){
+    "use strict";
+
+    var model = openerp;
+
+    reporting.ReportDoctorRankingWidget = reporting.Base.extend({
+        template: 'ReportDoctorRanking',
+        rowsData :[],
+        content :[],
+        modules: ['product_brand','point_of_sale'],
+
+        events:{
+            'click #toolbar > button' : 'clickOnAction',
+            'click #generate' : 'fetchGenerate',
+            'click-row.bs.table #table' : 'clickAnalysisDetail',
+            'change #current-company' : 'updateSelections',
+            'change #current-attribute' : 'updateAttributeSelections',
+            'change #current-store' : 'updateJournalSelections',
+            'change #current-date' : 'ShowDateRange',
+        },
+
+        init : function(parent){
+            this._super(parent);
+        },
+
+        start: function () {
+            var table = this.$el.find('#table');
+            table.bootstrapTable({data : self.rowsData});
+            var date = new model.eiru_reports.ReportDatePickerWidget(self);
+            date.fecthFecha();
+            this.fetchInitial();
+        },
+
+        valorNull:function(dato){
+            var valor = "";
+            if (dato){
+                valor = dato;
+            }
+            return valor;
+        },
+
+        checkModel : function(model){
+            var self = this;
+            return _.filter(self.IrModuleModule,function(item){
+                return item.name === model
+            });
+        },
+
+        ShowDateRange : function(){
+            var self = this;
+            var date = self.$el.find('#current-date').val();
+            if(date == 'range'){
+                self.$el.find('.datepicker').css('display','block');
+            }
+            if(date != 'range'){
+                self.$el.find('.datepicker').css('display','none');
+            }
+
+        },
+
+        clickAnalysisDetail: function(e, row, $element,field){
+            if (field == 'product'){
+                this.do_action({
+                    name:"Producto",
+                    type: 'ir.actions.act_window',
+                    res_model: "product.product",
+                    views: [[false,'form']],
+                    target: 'new',
+                    domain: [['id','=', row.id]],
+                    context: {},
+                    flags: {'form': {'action_buttons': false, 'options': {'mode': 'view'}}},
+                    res_id: row.id,
+                });
+            }
+            e.stopImmediatePropagation();
+        },
+
+        fetchInitial: function () {
+            var self = this;
+            self.fecthIrModuleModule().then(function (IrModuleModule) {
+                return IrModuleModule;
+            }).then(function(IrModuleModule) {
+                self.IrModuleModule = IrModuleModule;
+                return self.fetchResUser();
+            }).then(function (ResUser) {
+                self.ResUser = ResUser;
+                self.fecthCheckType();
+                return self.fetchResCompany();
+            }).then(function(ResCompany){
+                self.ResCompany = ResCompany;
+                if(ResCompany.length > 1){
+                    self.$el.find('#current-company').append('<option value="9999999">Todas las empresas</option>');
+                    _.each(ResCompany,function(item){
+                        self.$el.find('#current-company').append('<option value="' + item.id + '">' + item.name + '</option>');
+                    });
+                }else{
+                    self.$el.find('.company').css('display','none');
+                }
+                return self.fetchResStore();
+            }).then(function(ResStore){
+                self.ResStore = ResStore;
+                if(ResStore.length > 1){
+                    self.$el.find('#current-store').append('<option value="9999999">Todas las sucursales</option>');
+                    _.each(ResStore,function(item){
+                        self.$el.find('#current-store').append('<option value="' + item.id + '">' + item.name + '</option>');
+                    });
+                }else{
+                    self.$el.find('.store').css('display','none');
+                }
+                return self.fetchAccountJournal();
+            }).then(function(AccountJournal){
+                self.AccountJournal = AccountJournal;
+                if(AccountJournal.length > 1){
+                    self.$el.find('#current-journal').append('<option value="9999999">Todas las facturas</option>');
+                    _.each(AccountJournal,function(item){
+                        self.$el.find('#current-journal').append('<option value="' + item.id + '">' + item.name + '</option>');
+                    });
+                }else{
+                    self.$el.find('.journal').css('display','none');
+                }
+                return self.fetchAccountPeriod();
+            }).then(function(AccountPeriod){
+                self.AccountPeriod = AccountPeriod;
+                self.$el.find('#current-period').append('<option value="9999999">Todas los periodos</option>');
+                _.each(AccountPeriod,function(item){
+                    self.$el.find('#current-period').append('<option value="' +  item.id + '">' + item.name + '</option>');
+                });
+                return self.fetchResCurrency();
+            }).then(function(ResCurrency){
+                self.ResCurrency = ResCurrency;
+            });
+            self.$el.find('#generate').css('display','inline');
+            return;
+        },
+
+        fetchGenerate: function () {
+            var self = this;
+            self.$el.find('.search-form').block({
+                message: null,
+                overlayCSS: {
+                    backgroundColor: '#FAFAFA'
+                }
+            });
+            self.$el.find('.report-form').block({
+                message: null,
+                overlayCSS: {
+                    backgroundColor: '#FAFAFA'
+                }
+            });
+
+            this.fetchAccountInvoice().then(function(AccountInvoice) {
+                return AccountInvoice;
+            }).then(function (AccountInvoice) {
+                self.AccountInvoice = AccountInvoice;
+                return self.fetchPosOrder();
+            }).then(function (PosOrder){
+                self.PosOrder = PosOrder;
+                return self.fetchResPartner();
+            }).then(function (ResPartner){
+                self.ResPartner = ResPartner;
+                return self.BuildTable();
+            });
+        },
+
+        /*=====================================================================
+            IR MODULE
+        =====================================================================*/
+        fecthIrModuleModule: function(){
+            var self = this;
+            var defer = $.Deferred();
+            var fields = ['name','id'];
+            var domain=[['state','=','installed'],['name','in',self.modules]];
+            var IrModuleModule = new model.web.Model('ir.module.module');
+            IrModuleModule.query(fields).filter(domain).all().then(function(results){
+                defer.resolve(results);
+            })
+            return defer;
+        },
+
+        /*=====================================================================
+            Check type
+        =====================================================================*/
+        fecthCheckType: function(){
+            var self = this;
+            var modules = self.checkModel('point_of_sale');
+            if(modules.length == 0){
+                self.$el.find('.type').css('display','none');
+            }
+        },
+
+        /*=====================================================================
+            USER
+        =====================================================================*/
+        fetchResUser: function() {
+            var self = this;
+            var defer = $.Deferred();
+            var fields = ['id','name','store_id'];
+            var domain = [['id','=',self.session.uid]];
+            var ResUser = new model.web.Model('res.users');
+            ResUser.query(fields).filter(domain).all().then(function (results) {
+                defer.resolve(results);
+            });
+            return defer;
+        },
+
+        /*====================================================================
+            RES COMPANY
+        ====================================================================*/
+        fetchResCompany: function(){
+            var self = this;
+            var defer = $.Deferred();
+            var currency = new model.web.Model('res.company');
+            var field=['id','name','currency_id','logo'];
+            currency.query(field).filter().all().then(function(results){
+                defer.resolve(results);
+            });
+            return defer;
+        },
+
+        /*====================================================================
+            RES STORE
+        ====================================================================*/
+        fetchResStore: function(){
+            var self = this;
+            var defer = $.Deferred();
+            var field = ['id','name','company_id'];
+            var ResStore = new model.web.Model('res.store');
+            ResStore.query(field).all().then(function(results){
+                defer.resolve(results);
+            });
+            return defer;
+        },
+
+        /*====================================================================
+            ACCOUNT JOURNAL
+        ====================================================================*/
+        fetchAccountJournal: function(){
+            var self = this;
+            var domain = [['active','=',true],['type','=','sale']];
+            var AccountJournal = new model.web.Model('account.journal');
+            return AccountJournal.call('getAccountJournal',[domain], {
+                context: new model.web.CompoundContext()
+            });
+        },
+
+        /*=====================================================================
+            ACCOUNT PERIOD
+        =====================================================================*/
+        fetchAccountPeriod: function () {
+            var self = this;
+            var defer = $.Deferred();
+            var domain = [['special','=',false]];
+            var field =['id', 'name', 'date_start','date_stop','company_id'];
+            var AccountPeriod = new model.web.Model('account.period');
+            AccountPeriod.query(field).filter(domain).all().then(function (results) {
+                defer.resolve(results);
+            });
+            return defer;
+        },
+
+        /*====================================================================
+            RES CURRENCY
+        ====================================================================*/
+        fetchResCurrency : function(){
+            var self = this;
+            var defer = $.Deferred();
+            var fields = ['id','name', 'symbol', 'rate_silent', 'base', 'decimal_separator', 'decimal_places', 'thousands_separator', 'symbol_position'];
+            var domain = [['active', '=', true]];
+            var ResCurrency = new model.web.Model('res.currency');
+            ResCurrency.query(fields).filter(domain).all().then(function(results) {
+                defer.resolve(results);
+            });
+            return defer;
+        },
+
+        /*====================================================================
+            ACCOUNT INVOICE
+        ====================================================================*/
+        fetchAccountInvoice: function () {
+            var self = this;
+            var store = self.$el.find('#current-store').val();
+            var period = self.$el.find('#current-period').val();
+            var company = self.$el.find('#current-company').val();
+            var journal = self.$el.find('#current-journal').val();
+            var date = self.$el.find('#current-date').val();
+            var desde = self.$el.find('#from').val();
+            var hasta = self.$el.find('#to').val();
+
+            if(store && store != 9999999){
+                var journal_ids = _.map(_.filter(self.AccountJournal,function (item) {
+                    return item.store_ids == store;
+                }), function(map){
+                    return map.id;
+                });
+            }else{
+                var journal_ids = _.flatten(_.map(self.AccountJournal, function (item) {
+                    return item.id;
+                }));
+            }
+
+            var domain = [
+                ['state', 'in',['open','paid']],
+                ['type', '=', 'out_invoice'],
+                ['journal_id','in',journal_ids],
+            ];
+
+            if(company && company != 9999999){
+                domain.push(['company_id','=',parseInt(company)]);
+            }
+
+            if(journal && journal != 9999999){
+                domain.push(['journal_id','=',parseInt(journal)]);
+            }
+
+            if(period && period != 9999999){
+                domain.push(['period_id','=',parseInt(period)]);
+            }
+
+            if(date && date != 9999999){
+
+                if(desde){
+                    var date = desde.split('/')
+                    date = (date[2]+"-"+date[1]+"-"+date[0]);
+                    domain.push(['date_invoice','>=',date]);
+                }
+
+                if(hasta){
+                    var date = hasta.split('/')
+                    date = (date[2]+"-"+date[1]+"-"+date[0]);
+                    domain.push(['date_invoice','<=',date]);
+                }
+
+                if(date == 'today'){
+                    var today = moment().format('YYYY-MM-DD');
+                    domain.push(['date_invoice','=',today]);
+                }
+
+                if(date == 'yesterday'){
+                    var yesterday = moment().add(-1,'days').format('YYYY-MM-DD');
+                    domain.push(['date_invoice','=',yesterday]);
+                }
+
+                if(date == 'currentMonth'){
+                    var currentMonth = moment().format('YYYY-MM');
+                    domain.push(['date_invoice','like',currentMonth]);
+                }
+
+                if(date == 'lastMonth'){
+                    var lastMonth = moment().add(-1,'months').format('YYYY-MM');
+                    domain.push(['date_invoice','like',lastMonth]);
+                }
+            }
+
+            var AccountInvoice = new model.web.Model('account.invoice');
+            return AccountInvoice.call('getAccountInvoice',[domain], {
+                context: new model.web.CompoundContext()
+            });
+        },
+
+        /*====================================================================
+            POS ORDER
+        ====================================================================*/
+        /*
+            TO DO
+            **************************************************
+            Mejorar los filtros de fechas en el modelo POS ORDER - Actualmente
+            es necesario filtrar al momento de hacer la consulta para reducir
+            la carga de la consulta y la segunda vez que se filtra es para
+            analizar los datos con la zona horaria.
+        */
+        fetchPosOrder: function () {
+            var self = this;
+            var defer = $.Deferred();
+            var type = $('#current-type').val();
+            var modules = self.checkModel('point_of_sale');
+            if (type && modules.length > 0){
+                if(type != 'sale'){
+                    var store = self.$el.find('#current-store').val();
+                    var company = self.$el.find('#current-company').val();
+                    var journal = self.$el.find('#current-journal').val();
+                    var date = self.$el.find('#current-date').val();
+                    var desde = self.$el.find('#from').val();
+                    var hasta = self.$el.find('#to').val();
+
+                    if(store && store != 9999999){
+                        var journal_ids = _.map(_.filter(self.AccountJournal,function (item) {
+                            return item.store_ids == store;
+                        }), function(map){
+                            return map.id;
+                        });
+                    }else{
+                        var journal_ids = _.flatten(_.map(self.AccountJournal, function (item) {
+                            return item.id;
+                        }));
+                    }
+
+                    var domain = [
+                        ['state', 'not in',['draft','cancel']],
+                        ['sale_journal','in',journal_ids],
+                    ];
+
+                    if(company && company != 9999999){
+                        domain.push(['company_id','=',parseInt(company)]);
+                    }
+
+                    if(journal && journal != 9999999){
+                        domain.push(['sale_journal','=',parseInt(journal)]);
+                    }
+
+                    if(date && date != 9999999){
+
+                        if(desde){
+                            var date = desde.split('/')
+                            date = (date[2]+"-"+date[1]+"-"+date[0]);
+                            domain.push(['date_order','>=',date]);
+                        }
+
+                        if(hasta){
+                            var date = hasta.split('/')
+                            date = (date[2]+"-"+date[1]+"-"+date[0]);
+                            domain.push(['date_order','<=',date]);
+                        }
+
+                        if(date == 'today'){
+                            var today = moment().format('YYYY-MM-DD 00:00:00');
+                            domain.push(['date_order','>=',today]);
+                        }
+
+                        if(date == 'yesterday'){
+                            var yesterday = moment().add(-1,'days').format('YYYY-MM-DD 00:00:00');
+                            domain.push(['date_order','>=',yesterday]);
+                        }
+
+                        if(date == 'currentMonth'){
+                            var currentMonth = moment().format('YYYY-MM');
+                            domain.push(['date_order','like',currentMonth]);
+                        }
+
+                        if(date == 'lastMonth'){
+                            var lastMonth = moment().add(-1,'months').format('YYYY-MM');
+                            domain.push(['date_order','like',lastMonth]);
+                        }
+                    }
+                    var PosOrder = new model.web.Model('account.invoice');
+                    return PosOrder.call('getPosOrder',[domain], {
+                        context: new model.web.CompoundContext()
+                    });
+                }
+            }else{
+                var PosOrder = [];
+                return PosOrder;
+            }
+        },
+
+        /*====================================================================
+            RES PARTNER
+        ====================================================================*/
+        fetchResPartner: function(){
+            var self = this;
+            var domain = [['active','=',true]];
+            var ResPartner = new model.web.Model('res.partner');
+            return ResPartner.call('getResPartnerMedic',[domain], {
+                context: new model.web.CompoundContext()
+            });
+        },
+
+        /*====================================================================
+            UPDATE SELECTIONS
+        ====================================================================*/
+        updateSelections: function () {
+            var self = this;
+            var company = self.$el.find('#current-company').val();
+            if(company != 9999999){
+                /*===================
+                    STORE SELECTION
+                ===================*/
+                var store = self.$el.find('#current-store').empty();
+                self.$el.find('#current-store').append('<option value="9999999">Todas las sucursales</option>');
+                _.each(self.ResStore,function(item){
+                    if(parseFloat(company) == item.company_id[0]){
+                        self.$el.find('#current-store').append('<option value="' + item.id + '">' + item.name + '</option>');
+                    }
+                });
+                /*====================
+                    PERIOD SELECTION
+                ====================*/
+                var period = self.$el.find('#current-period').empty();
+                self.$el.find('#current-period').append('<option value="9999999">Todos los periodos</option>');
+                _.each(self.AccountPeriod,function(item){
+                    if(parseFloat(company) == item.company_id[0]){
+                        self.$el.find('#current-period').append('<option value="' + item.id + '">' + item.name + '</option>');
+                    }
+                });
+            }else{
+                /*===================
+                    STORE SELECTION
+                ===================*/
+                var store = self.$el.find('#current-store').empty();
+                self.$el.find('#current-store').append('<option value="9999999">Todas las sucursales</option>');
+                _.each(self.ResStore,function(item){
+                    self.$el.find('#current-store').append('<option value="' + item.id + '">' + item.name + '</option>');
+                });
+                /*====================
+                    PERIOD SELECTION
+                ====================*/
+                var period = self.$el.find('#current-period').empty();
+                self.$el.find('#current-period').append('<option value="9999999">Todas los periodos</option>');
+                _.each(self.AccountPeriod,function(item){
+                    self.$el.find('#current-period').append('<option value="' + item.id + '">' + item.name + '</option>');
+                });
+            }
+        },
+
+        updateAttributeSelections: function () {
+            var self = this;
+            var attribute = self.$el.find('#current-attribute').val();
+            if(attribute != 9999999){
+                /*=============================
+                    ATTRIBUTE VALUE SELECTION
+                =============================*/
+                var attribute_value = self.$el.find('#current-attribute-value').empty();
+                self.$el.find('#current-attribute-value').append('<option value="9999999">Todos los valores de atributos</option>');
+                _.each(self.ProductAttributeValue,function(item){
+                    if(parseFloat(attribute) == item.attribute_id[0]){
+                        self.$el.find('#current-attribute-value').append('<option value="' + item.id + '">' + item.name + '</option>');
+                    }
+                });
+            }else{
+                /*=============================
+                    ATTRIBUTE VALUE SELECTION
+                =============================*/
+                var attribute_value = self.$el.find('#current-attribute-value').empty();
+                self.$el.find('#current-attribute-value').append('<option value="9999999">Todos los valores de atributos</option>');
+                _.each(self.ProductAttributeValue,function(item){
+                    self.$el.find('#current-attribute-value').append('<option value="' + item.id + '">' + item.name + '</option>');
+                });
+            }
+        },
+
+        updateJournalSelections: function () {
+            var self = this;
+            var store = self.$el.find('#current-store').val();
+            if(store != 9999999){
+                /*=============================
+                    ACCOUNT JOURNAL SELECTION
+                =============================*/
+                var journal = self.$el.find('#current-journal').empty();
+                self.$el.find('#current-journal').append('<option value="9999999">Todas las facturas</option>');
+                _.each(self.AccountJournal,function(item){
+                    if(parseFloat(store) == item.store_ids){
+                        self.$el.find('#current-journal').append('<option value="' + item.id + '">' + item.name + '</option>');
+                    }
+                });
+            }else{
+                /*=============================
+                    ACCOUNT JOURNAL SELECTION
+                =============================*/
+                var journal = self.$el.find('#current-journal').empty();
+                self.$el.find('#current-journal').append('<option value="9999999">Todas las facturas</option>');
+                _.each(self.AccountJournal,function(item){
+                    self.$el.find('#current-journal').append('<option value="' + item.id + '">' + item.name + '</option>');
+                });
+            }
+        },
+
+        /*====================================================================
+            GET RES COMPANY
+        ====================================================================*/
+        getResCompany: function (id) {
+            var self = this;
+            return _.filter(self.ResCompany,function (item) {
+                return item.id == id;
+            })
+        },
+
+        /*====================================================================
+            GET RES CURRENCY BASE
+        ====================================================================*/
+        getResCurrency: function (id) {
+            var self = this;
+            return _.filter(self.ResCurrency,function (item) {
+                return item.id === id;
+            })
+        },
+
+        /*====================================================================
+            GET POS ORDER LINE
+        ====================================================================*/
+        getPosOrder: function (id) {
+            var self = this;
+            var content = []
+            var period = self.$el.find('#current-period').val();
+            var date = self.$el.find('#current-date').val();
+            var desde = self.$el.find('#from').val();
+            var hasta = self.$el.find('#to').val();
+            var partner_ids = _.map(_.filter(self.ResPartner,function (item) {
+                return item.medic[0] === id;
+            }), function(map){
+                return map.id;
+            });
+            content = _.flatten(_.filter(self.PosOrder,function (item) {
+                return _.contains(partner_ids, item.partner_id[0]);
+            }));
+
+            /*
+            =================================================
+                FILTRAR PERIODO
+            =================================================
+            */
+            if(period && period != 9999999){
+                var periodo = _.flatten(_.filter(self.AccountPeriod,function (item) {
+                    return item.id == period;
+                }));
+                content = _.flatten(_.filter(content,function (item) {
+                    var utc = moment.utc(item.date_order,'YYYY-MM-DD h:mm:ss A');
+                    return moment(utc._d).format('YYYY-MM') === moment(periodo[0].date_start).format('YYYY-MM');
+                }));
+            }
+            /*
+            =================================================
+                FILTRAR POR FECHAS
+            =================================================
+            */
+            if(date && date != 9999999){
+
+                if(desde){
+                    var date = desde.split('/')
+                    date = (date[2]+"-"+date[1]+"-"+date[0]);
+                    content = _.flatten(_.filter(content,function (item) {
+                        var utc = moment.utc(item.date_order,'YYYY-MM-DD h:mm:ss A');
+                        return moment(utc._d).format('YYYY-MM-DD') >= date;
+                    }));
+                }
+
+                if(hasta){
+                    var date = hasta.split('/')
+                    date = (date[2]+"-"+date[1]+"-"+date[0]);
+                    content = _.flatten(_.filter(content,function (item) {
+                        var utc = moment.utc(item.date_order,'YYYY-MM-DD h:mm:ss A');
+                        return moment(utc._d).format('YYYY-MM-DD') <= date;
+                    }));
+                }
+
+                if(date == 'today'){
+                    var today = moment().format('YYYY-MM-DD');
+                    content = _.flatten(_.filter(content,function (item) {
+                        var utc = moment.utc(item.date_order,'YYYY-MM-DD h:mm:ss A');
+                        return moment(utc._d).format('YYYY-MM-DD') == today;
+                    }));
+                }
+
+                if(date == 'yesterday'){
+                    var yesterday = moment().add(-1,'days').format('YYYY-MM-DD');
+                    content = _.flatten(_.filter(content,function (item) {
+                        var utc = moment.utc(item.date_order,'YYYY-MM-DD h:mm:ss A');
+                        return moment(utc._d).format('YYYY-MM-DD') == yesterday;
+                    }));
+                }
+
+                if(date == 'currentMonth'){
+                    var currentMonth = moment().format('YYYY-MM');
+                    content = _.flatten(_.filter(content,function (item) {
+                        var utc = moment.utc(item.date_order,'YYYY-MM-DD h:mm:ss A');
+                        return moment(utc._d).format('YYYY-MM') == currentMonth;
+                    }));
+                }
+
+                if(date == 'lastMonth'){
+                    var lastMonth = moment().add(-1,'months').format('YYYY-MM');
+                    content = _.flatten(_.filter(content,function (item) {
+                        var utc = moment.utc(item.date_order,'YYYY-MM-DD h:mm:ss A');
+                        return moment(utc._d).format('YYYY-MM') == lastMonth;
+                    }));
+
+                }
+            }
+
+            return content;
+        },
+
+        /*====================================================================
+            GET ACCOUNT INVOICE
+        ====================================================================*/
+        getAccountInvoice: function (id) {
+            var self = this;
+            var partner_ids = _.map(_.filter(self.ResPartner,function (item) {
+                return item.medic[0] === id;
+            }), function(map){
+                return map.id;
+            });
+            return  _.flatten(_.filter(self.AccountInvoice,function (item) {
+                return _.contains(partner_ids, item.partner_id[0]);
+            }));
+        },
+
+        /*====================================================================
+            GET RES DOCTOR
+        ====================================================================*/
+        getResDoctor: function () {
+            var self = this;
+            var content = self.ResPartner;
+            content = _.filter(content,function (item) {
+                return item.is_medic
+            });
+            return content;
+        },
+
+        /*====================================================================
+            BUILD
+        ====================================================================*/
+        BuildTable: function(){
+            var self = this;
+            var data = [];
+            var ResDoctor = self.getResDoctor();
+            console.log(self);
+            var type = $('#current-type').val();
+            var company = $('#current-company').val();
+            if(company && company != 9999999){
+                var ResCompany = self.getResCompany(company).shift();
+                var CurrencyBase = self.getResCurrency(ResCompany.currency_id[0]).shift();
+            }else{
+                var CurrencyBase = self.getResCurrency(self.ResCompany[0].currency_id[0]).shift();
+            };
+            /*
+            ==========================================
+                RECORRER DOCTORES
+            ==========================================
+            */
+            _.each(ResDoctor,function(item) {
+                var AccountInvoice = self.getAccountInvoice(item.id);
+                var PosOrder = self.getPosOrder(item.id);
+                var info = [];
+                /*
+                ==========================================
+                    ACCOUNT INVOICE
+                ==========================================
+                */
+                var invoice_amount = 0;
+                if(type == 'sale' || type == 9999999){
+                    if(AccountInvoice.length > 0){
+                        /*
+                        ==========================================
+                            AMOUNT TOTAL
+                        ==========================================
+                        */
+                        invoice_amount = _.reduce(_.map(AccountInvoice, function (map) {
+                            return map.amount_total_currency
+                        }), function (meno,num) {
+                            return meno + num
+                        }, 0);
+                    }
+                    _.each(AccountInvoice,function(index) {
+                        info.push({
+                            number: index.number,
+                            date: moment(index.date_invoice).format('DD/MM/YYYY'),
+                            customer: index.partner_id[1],
+                            amount: accounting.formatMoney(index.amount_total_currency,'',CurrencyBase.decimal_places, CurrencyBase.thousands_separator, CurrencyBase.decimal_separator),
+                        });
+                    });
+
+                }
+                /*
+                ==========================================
+                    POS ORDER
+                ==========================================
+                */
+                var pos_amount = 0;
+                if(PosOrder.length > 0){
+                    /*
+                    ==========================================
+                        AMOUNT TOTAL
+                    ==========================================
+                    */
+                    pos_amount = _.reduce(_.map(PosOrder, function (map) {
+                        return map.amount_total_currency
+                    }), function (meno,num) {
+                        return meno + num
+                    }, 0);
+                    _.each(PosOrder,function(index) {
+                        var utc = moment.utc(index.date_order,'YYYY-MM-DD h:mm:ss A');
+                        info.push({
+                            number: index.name,
+                            date: moment(utc._d).format('DD/MM/YYYY'),
+                            customer: index.partner_id[1],
+                            amount: accounting.formatMoney(index.amount_total_currency,'',CurrencyBase.decimal_places, CurrencyBase.thousands_separator, CurrencyBase.decimal_separator),
+                        });
+                    });
+                }
+
+                var amount = invoice_amount + pos_amount;
+
+                if(amount > 0){
+                    data.push({
+                        id: item.id,
+                        medic: item.name,
+                        qty_total: accounting.formatNumber((PosOrder.length + AccountInvoice.length),0,'.',','),
+                        total_amount: accounting.formatMoney(pos_amount, '', CurrencyBase.decimal_places, CurrencyBase.thousands_separator, CurrencyBase.decimal_separator),
+                        /*
+                        ================================
+                        VALORES SIN FORMATEAR
+                        ================================
+                        */
+                        qty: (PosOrder.length + AccountInvoice.length),
+                        amount: pos_amount,
+                        /*
+                        ================================
+                            TOTAL FOOTER CONFIGURATION
+                        ================================
+                        */
+                        decimal_places : CurrencyBase.decimal_places,
+                        thousands_separator: CurrencyBase.thousands_separator,
+                        decimal_separator: CurrencyBase.decimal_separator,
+                        /*
+                        ================================
+                        DATA
+                        ================================
+                        */
+                        info: info,
+                    });
+                }
+            });
+            data.sort(function(a, b) {
+                return b.amount - a.amount
+            });
+            self.content = data;
+            self.loadTable(data);
+            self.CallCharts(data,CurrencyBase);
+        },
+        /*
+        ======================================================================
+            LLAMAR LOS GRAFICOS
+        ======================================================================
+        */
+        CallCharts: function(data,CurrencyBase){
+            var self = this;
+            /*
+            ================================================
+            GRAFICO DE BARRAS
+            ================================================
+            */
+            var BarChart = new model.eiru_reports.ReportChartWidget(self);
+            var rank = 10;
+            var item;
+            var label = [];
+            var body = [];
+            for (var i = 0; i < rank; i++) {
+                if (data[i]){
+                    item = data[i];
+                }else{
+                    item = {};
+                    item.medic = "N/A";
+                    item.amount = 0;
+                }
+                label.push(item.medic.trim());
+                body.push(item.amount);
+            }
+            BarChart.fetchBarChart(data,CurrencyBase,label,body);
+
+            /*
+            ================================================
+            GRAFICO CIRCULAR
+            ================================================
+            */
+            var PieChart = new model.eiru_reports.ReportChartWidget(self);
+            var rank = 9;
+            var item;
+            var label = [];
+            var body = [];
+            var amount_total = _.reduce(_.map(data, function (map) {
+                return map.amount
+            }), function (meno,num) {
+                return meno + num
+            }, 0);
+            for (var i = 0; i < rank; i++) {
+                if (data[i]){
+                    item = data[i];
+                }else{
+                    item = {};
+                    item.medic = "N/A";
+                    item.amount = 0;
+                }
+                label.push(item.medic.trim());
+                body.push((item.amount/amount_total)*100);
+            }
+            var num = 0;
+            for (var i = 9; i < data.length; i++) {
+                num += data[i].amount;
+            }
+            if(num > 0){
+                label.push('Otros Doctores');
+                body.push((num/amount_total)*100);
+            }
+            PieChart.fetchPieChart(data,CurrencyBase,label,body);
+
+            self.$el.find('.report-form').css('display','block');
+            self.$el.find('.search-form').unblock();
+            self.$el.find('.report-form').unblock();
+        },
+
+        /*====================================================================
+            LOAD BOOTSTRAP TABLE
+        ====================================================================*/
+        loadTable:function(rowsTable){
+            var self = this;
+            self.rowsData = rowsTable;
+            var table = this.$el.find('#table');
+            table.bootstrapTable('load', rowsTable);
+        },
+
+        /*====================================================================
+            PRINT PDF
+        ====================================================================*/
+        clickOnAction: function (e) {
+            var self = this;
+            var ResCompany;
+            var action = this.$el.find(e.target).val();
+            var company = $('#current-company').val();
+            if(company && company != 9999999){
+                ResCompany = self.getResCompany(company).shift();
+                var CurrencyBase = self.getResCurrency(ResCompany.currency_id[0]).shift();
+            }else{
+                ResCompany = self.ResCompany[0];
+                var CurrencyBase = self.getResCurrency(self.ResCompany[0].currency_id[0]).shift();
+            }
+            var getColumns=[];
+            var rows=[];
+            var table = this.$el.find("#table");
+            var column = table.bootstrapTable('getVisibleColumns');
+            var row = table.bootstrapTable('getData');
+
+            var qty = _.reduce(_.map(row, function (map) {
+                return map.qty;
+            }), function (memo, num) {
+                return memo + num;
+            });
+
+            var amount = _.reduce(_.map(row, function (map) {
+                return map.amount;
+            }), function (memo, num) {
+                return memo + num;
+            });
+
+            row.push({
+                medic: 'Totales',
+                qty_total: qty,
+                total_amount: accounting.formatMoney(amount, '', CurrencyBase.decimal_places, CurrencyBase.thousands_separator, CurrencyBase.decimal_separator),
+            })
+
+            if (action === 'pdf') {
+                var data = _.map(column, function (val){ return val.field});
+                _.each(_.map(column,function(val){
+                    return val}), function(item){
+                    getColumns.push([{
+                        title: item.title,
+                        dataKey: item.field
+                    }]);
+                });
+                /*
+                ============================================================
+                    CONFIGURACION DEL PDF
+                ============================================================
+                */
+                var pdf_title = 'Ranking de Doctores';
+                var pdf_type = '';
+                var pdf_name = 'ranking_de_doctores';
+                var pdf_columnStyles =  {
+                    product :{halign:'left'},
+                    qty_total :{columnWidth: 30, halign:'right'},
+                    total_amount:{columnWidth: 30, halign:'right'},
+                };
+                /*
+                ============================================================
+                    LLAMAR FUNCION DE IMPRESION
+                ============================================================
+                */
+                var pdf = new model.eiru_reports.ReportPdfWidget(self);
+                pdf.drawPDF(
+                    _.flatten(getColumns),
+                    row,
+                    ResCompany,
+                    pdf_title,
+                    pdf_type,
+                    pdf_name,
+                    pdf_columnStyles,
+                );
+            }
+        },
+    });
+}

+ 177 - 0
static/src/reports/report_doctor_ranking.xml

@@ -0,0 +1,177 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<template xml:space="preserve">
+    <t t-name="ReportDoctorRanking">
+        <div class="report_view">
+            <div class="reporting_page_header">
+                <h1 class="report_title">Ranking de Doctores</h1>
+            </div>
+            <div class="container search-form" style="border-bottom:1px solid #eee; width:95%;">
+                <div class="row">
+                    <div class="col-lg-3 company filter-style">
+                        <label>Empresa</label>
+                        <select id="current-company" class="form-control form-control-sm"></select>
+                    </div>
+                    <div class="col-lg-3 store filter-style">
+                        <label>Sucursal</label>
+                        <select id="current-store" class="form-control form-control-sm">
+                        </select>
+                    </div>
+                    <div class="col-lg-3 journal filter-style">
+                        <label>Factura</label>
+                        <select id="current-journal" class="form-control form-control-sm">
+                        </select>
+                    </div>
+                    <div class="col-lg-3 type filter-style">
+                        <label>Tipo de Venta</label>
+                        <select id="current-type" class="form-control form-control-sm">
+                            <option value="9999999">Todos los Tipos</option>
+                            <option value="tpv">Terminal</option>
+                            <option value="sale">Normal</option>
+                        </select>
+                    </div>
+                    <div class="col-lg-3 filter-style">
+                        <label>Periodo</label>
+                        <select id="current-period" class="form-control form-control-sm">
+                        </select>
+                    </div>
+                    <div class="col-lg-3 filter-style">
+                        <label>Fechas</label>
+                        <select id="current-date" class="form-control form-control-sm">
+                            <option value="9999999">Sin fechas</option>
+                            <option value="today">Hoy</option>
+                            <option value="yesterday">Ayer</option>
+                            <option value="currentMonth">Mes Actual</option>
+                            <option value="lastMonth">Mes Pasado</option>
+                            <option value="range">Busqueda Avanzada</option>
+                        </select>
+                    </div>
+                </div>
+                <div class="row" >
+                    <div class="datepicker" style="display:none;">
+                        <div class="col-lg-3 filter-style col-md-offset-3">
+                            <div class="input-group">
+                                <span class="input-group-addon" id="basic-addon1">Desde</span>
+                                <input type="text" id="from" class="form-control" aria-describedby="basic-addon1"/>
+                            </div>
+                        </div>
+                        <div class="col-lg-3 filter-style">
+                            <div class="input-group">
+                                <span class="input-group-addon" id="basic-addon1">Hasta</span>
+                                <input type="text" id="to" class="form-control" aria-describedby="basic-addon1"/>
+                            </div>
+                        </div>
+                    </div>
+                </div>
+                <div class="row">
+                    <div class="text-center" style="padding-top:20px;">
+                        <a id="generate" type="button" class="btn btn-danger" aria-label="Left Align" style="color:#fff;display:none;">
+                          Generar
+                        </a>
+                    </div>
+                    <br/>
+                </div>
+            </div>
+
+            <div class="report-form" style="display:none;">
+                <div class="chart-container center-block" style="padding-top:20px; height:300px; padding-bottom:20px;">
+                    <canvas class="reporting-chart"></canvas>
+                </div>
+                <div class="chart-container center-block" style="padding-top:20px; height:300px; padding-bottom:20px;">
+                    <canvas class="reporting-pie-chart"></canvas>
+                </div>
+                <div id="toolbar">
+                    <button class="oe_button oe_form_button oe_highlight" value="pdf">PDF</button>
+                </div>
+                <div class="container" style="width:95%;">
+                    <table id="table"
+                        data-pagination="true"
+                        data-toggle="table"
+                        data-toolbar="#toolbar"
+                        data-show-columns="true"
+                        data-height="auto"
+                        data-classes="table table-condensed  table-no-bordered"
+                        data-row-style="rowStyle"
+                        data-search="true"
+                        data-show-export="true"
+                        data-show-toggle="true"
+                        data-pagination-detail-h-align="left"
+                        data-show-footer="true"
+                        data-footer-style="footerStyle"
+                        data-buttons-class="oe_button oe_form_button oe_highlight"
+                        data-show-pagination-switch="true"
+                        data-page-size="10"
+                        data-search-on-enter-key="true"
+                        data-undefined-text=" "
+                        data-detail-view="true"
+                        data-detail-formatter="detailFormatter"
+                        >
+                        <thead style="background:none;">
+                            <tr>
+                                <th data-field="medic" data-align="left">Nombre</th>
+                                <th data-field="qty_total" data-align="right" data-footer-formatter="qtyFormatter">Cantidad</th>
+                                <th data-field="total_amount" data-align="right" data-footer-formatter="totalFormatter" data-width="20%">Valor</th>
+                            </tr>
+                        </thead>
+                    </table>
+                </div>
+            </div>
+            <script>
+
+                function detailFormatter(index, row) {
+                    var html = [];
+                    html.push('<div class="container" style="padding:30px;">');
+                    html.push('<div class="panel panel-default">');
+                    html.push('<table class="table table-condensed table-no-bordered">');
+                    if(row.info.length > 0){
+                        _.each(row.info,function(item) {
+                            html.push('<tr><td>' + item.number + '</td><td>' + item.date + '</td><td>' + item.customer + '</td><td>' + item.amount + '</td></tr>');
+                        });
+                    }
+                    html.push('</table>');
+                    html.push('</div>');
+                    html.push('</div>');
+                    return html.join('');
+                }
+
+                <!--
+                    TOTAL
+                -->
+                function totalFormatter(rowsTable) {
+                    var decimal_places = 0;
+                    var thousands_separator = '.';
+                    var decimal_separator = ',';
+                    if(rowsTable.length > 0){
+                        decimal_places = rowsTable[0].decimal_places;
+                        thousands_separator = rowsTable[0].thousands_separator;
+                        decimal_separator = rowsTable[0].decimal_separator;
+                    }
+                    var amount =  _.reduce(_.map(rowsTable,function(item){
+                        return (item.amount);
+                    }), function(memo, num){
+                    return memo + num; },0)
+                    return accounting.formatNumber(amount,decimal_places,thousands_separator,decimal_separator);
+                }
+                <!--
+                    TOTAL
+                -->
+                function qtyFormatter(rowsTable) {
+                    var quantity =  _.reduce(_.map(rowsTable,function(item){
+                        return (item.qty);
+                    }), function(memo, num){
+                    return memo + num; },0)
+                    return accounting.formatNumber(quantity,0,'.',',');
+                }
+                <!--
+                    FOOTER STYLE
+                -->
+                function footerStyle(row, index) {
+                    return {
+                        css: {
+                          "font-weight": "bold"
+                        }
+                    };
+                };
+            </script>
+        </div>
+    </t>
+</template>

+ 11 - 0
static/src/xml/eiru_reporting.xml

@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<template xml:space="preserve">
+    <t t-name="EiruReport">
+        <t t-call="EiruReportingBase">
+            <div class="oe_form_sheetbg">
+                
+            </div>
+        </t>
+    </t>
+</template>

+ 13 - 0
static/src/xml/eiru_reporting_base.xml

@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<template xml:space="preserve">
+    <t t-name="EiruReportingBase">
+        <div class="oe_form_container">
+            <div class="oe_form">
+                <div class="">
+                    <t t-raw="0" />
+                </div>
+            </div>
+        </div>
+    </t>
+</template>

+ 24 - 0
templates.xml

@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<openerp>
+    <data>
+        <template id="eiru_reports_odontoimagen_assets" inherit_id="eiru_assets.assets">
+            <xpath expr="." position="inside">
+
+                <!-- configuration < main > -->
+                <script type="text/javascript" src="/eiru_reports_odontoimagen/static/src/js/main.js" />
+                <script type="text/javascript" src="/eiru_reports_odontoimagen/static/src/js/reporting_base.js" />
+                <script type="text/javascript" src="/eiru_reports_odontoimagen/static/src/js/pdf.js" />
+                <script type="text/javascript" src="/eiru_reports_odontoimagen/static/src/js/chart.js" />
+                <script type="text/javascript" src="/eiru_reports_odontoimagen/static/src/js/datepicker.js" />
+
+                <script type="text/javascript" src="/eiru_reports_odontoimagen/static/src/js/reports/report_doctor_ranking.js"/>
+
+            </xpath>
+        </template>
+
+        <record id="eiru_reports_action" model="ir.actions.client">
+            <field name="name">Eiru Reports OdontoImagen</field>
+            <field name="tag">eiru_reports_odontoimagen.action_report</field>
+        </record>
+    </data>
+</openerp>

+ 11 - 0
views/actions.xml

@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<openerp>
+	<data>
+
+		<record id="doctor_ranking_action" model="ir.actions.client">
+            <field name="name">Ranking de doctores</field>
+            <field name="tag">eiru_reports_odontoimagen.doctor_ranking_action</field>
+        </record>
+
+    </data>
+</openerp>

+ 17 - 0
views/menus.xml

@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<openerp>
+    <data>
+
+        <menuitem id="welcome_odontoimagen_parent_menu"
+            name="Doctores"
+            parent="eiru_reports.eiru_reports_main_menu"
+            sequence="30"/>
+
+        <menuitem id="doctor_ranking_menu"
+            parent="welcome_odontoimagen_parent_menu"
+            name="Ranking de doctores"
+            action="doctor_ranking_action"
+            sequence="3"/>
+
+    </data>
+</openerp>