|
@@ -1,28 +1,31 @@
|
|
-function report_phonecall(reporting){
|
|
|
|
|
|
+function report_crmtask(reporting){
|
|
"use strict";
|
|
"use strict";
|
|
|
|
|
|
var instance = openerp;
|
|
var instance = openerp;
|
|
|
|
|
|
- reporting.ReportPhoneCallWidget = reporting.Base.extend({
|
|
|
|
- template:'ReportPhoneCall',
|
|
|
|
|
|
+ reporting.ReportCrmTaskWidget = reporting.Base.extend({
|
|
|
|
+ template:'ReportCrmTask',
|
|
Crm: [],
|
|
Crm: [],
|
|
- CrmPhone: [],
|
|
|
|
|
|
+ CrmTask: [],
|
|
content:[],
|
|
content:[],
|
|
rowsData :[],
|
|
rowsData :[],
|
|
modules:[],
|
|
modules:[],
|
|
events:{
|
|
events:{
|
|
'click #toolbar > button' : 'clickOnAction',
|
|
'click #toolbar > button' : 'clickOnAction',
|
|
- 'click #volver_btn' : 'volver',
|
|
|
|
'click #X' : 'factSearch',
|
|
'click #X' : 'factSearch',
|
|
'click #A' : 'factSearch',
|
|
'click #A' : 'factSearch',
|
|
'click #B' : 'factSearch',
|
|
'click #B' : 'factSearch',
|
|
'click #C' : 'factSearch',
|
|
'click #C' : 'factSearch',
|
|
'click #D' : 'factSearch',
|
|
'click #D' : 'factSearch',
|
|
'click #Z' : 'factSearch',
|
|
'click #Z' : 'factSearch',
|
|
-
|
|
|
|
'click #Y' : 'factSearch',
|
|
'click #Y' : 'factSearch',
|
|
|
|
+ 'click #done' : 'factSearch',
|
|
|
|
+ 'click #cancel' : 'factSearch',
|
|
|
|
+ 'click #pending' : 'factSearch',
|
|
|
|
+ 'click #current-type' : 'factSearch',
|
|
|
|
+ 'click #W' : 'factSearch',
|
|
'click #customer' : 'factSearch',
|
|
'click #customer' : 'factSearch',
|
|
-
|
|
|
|
|
|
+ 'click #task' : 'factSearch',
|
|
'change #from' : 'factSearch',
|
|
'change #from' : 'factSearch',
|
|
'change #to' : 'factSearch',
|
|
'change #to' : 'factSearch',
|
|
'click-row.bs.table #table ' : 'clickAnalysisDetail',
|
|
'click-row.bs.table #table ' : 'clickAnalysisDetail',
|
|
@@ -96,28 +99,28 @@ function report_phonecall(reporting){
|
|
clickAnalysisDetail: function(e, row, $element, field){
|
|
clickAnalysisDetail: function(e, row, $element, field){
|
|
if (field == 'partner'){
|
|
if (field == 'partner'){
|
|
this.do_action({
|
|
this.do_action({
|
|
- name:"CRM Llamadas",
|
|
|
|
|
|
+ name:"Registro de Cliente",
|
|
type: 'ir.actions.act_window',
|
|
type: 'ir.actions.act_window',
|
|
- res_model: "crm.phonecall",
|
|
|
|
|
|
+ res_model: "res.partner",
|
|
views: [[false,'form']],
|
|
views: [[false,'form']],
|
|
target: 'new',
|
|
target: 'new',
|
|
- domain: [['id','=', row.id]],
|
|
|
|
|
|
+ domain: [['id','=', row.partner_id]],
|
|
context: {},
|
|
context: {},
|
|
flags: {'form': {'action_buttons': false, 'options': {'mode': 'view'}}},
|
|
flags: {'form': {'action_buttons': false, 'options': {'mode': 'view'}}},
|
|
- res_id: row.id,
|
|
|
|
|
|
+ res_id: row.partner_id,
|
|
});
|
|
});
|
|
}
|
|
}
|
|
- if (field === 'opportunity_id'){
|
|
|
|
|
|
+ if (field === 'activity'){
|
|
this.do_action({
|
|
this.do_action({
|
|
- name:"Registro",
|
|
|
|
|
|
+ name:"Registro de Tareas",
|
|
type: 'ir.actions.act_window',
|
|
type: 'ir.actions.act_window',
|
|
- res_model: "crm.lead",
|
|
|
|
|
|
+ res_model: "crm.task",
|
|
views: [[false,'form']],
|
|
views: [[false,'form']],
|
|
target: 'new',
|
|
target: 'new',
|
|
- domain: [['id','=', row.partner_id]],
|
|
|
|
|
|
+ domain: [['id','=', row.id]],
|
|
context: {},
|
|
context: {},
|
|
flags: {'form': {'action_buttons': false, 'options': {'mode': 'view'}}},
|
|
flags: {'form': {'action_buttons': false, 'options': {'mode': 'view'}}},
|
|
- res_id: row.partner_id,
|
|
|
|
|
|
+ res_id: row.id,
|
|
});
|
|
});
|
|
}
|
|
}
|
|
|
|
|
|
@@ -130,9 +133,16 @@ function report_phonecall(reporting){
|
|
self.modules = modules;
|
|
self.modules = modules;
|
|
return modules;
|
|
return modules;
|
|
}).then(function(modules){
|
|
}).then(function(modules){
|
|
- return self.fetchCrmPhone();
|
|
|
|
- }).then(function(CrmPhone) {
|
|
|
|
- self.CrmPhone = CrmPhone;
|
|
|
|
|
|
+ return self.fetchCrmTask();
|
|
|
|
+ }).then(function(CrmTask) {
|
|
|
|
+ self.CrmTask = CrmTask;
|
|
|
|
+ return self.fetchTaskType();
|
|
|
|
+ }).then(function (TaskType) {
|
|
|
|
+ self.TaskType = TaskType;
|
|
|
|
+ self.$el.find('#current-type').append('<option value="9999999">Todas los tipos</option>');
|
|
|
|
+ _.each(TaskType,function(item){
|
|
|
|
+ self.$el.find('#current-type').append('<option value="' + item.id + '">' + item.name + '</option>');
|
|
|
|
+ });
|
|
return self.fetchCrm();
|
|
return self.fetchCrm();
|
|
}).then(function (Crm) {
|
|
}).then(function (Crm) {
|
|
self.Crm = Crm;
|
|
self.Crm = Crm;
|
|
@@ -140,6 +150,7 @@ function report_phonecall(reporting){
|
|
}).then(function(ResPartner){
|
|
}).then(function(ResPartner){
|
|
self.ResPartner = ResPartner;
|
|
self.ResPartner = ResPartner;
|
|
self.search();
|
|
self.search();
|
|
|
|
+ self.searchTaskType();
|
|
return self.BuildTable();
|
|
return self.BuildTable();
|
|
});
|
|
});
|
|
},
|
|
},
|
|
@@ -192,16 +203,28 @@ function report_phonecall(reporting){
|
|
}
|
|
}
|
|
},
|
|
},
|
|
|
|
|
|
- fetchCrmPhone: function () {
|
|
|
|
|
|
+ fetchCrmTask: function () {
|
|
var self = this;
|
|
var self = this;
|
|
var defer = $.Deferred();
|
|
var defer = $.Deferred();
|
|
- var modules = self.checkModel('crm');
|
|
|
|
|
|
+ var modules = self.checkModel('eiru_crm');
|
|
if (modules.length <= 0){
|
|
if (modules.length <= 0){
|
|
- self.showMensaje('crm');
|
|
|
|
|
|
+ self.showMensaje('eiru_crm');
|
|
return defer;
|
|
return defer;
|
|
}
|
|
}
|
|
- var CrmPhone = new instance.web.Model('crm.phonecall');
|
|
|
|
- CrmPhone.query(['id', 'partner_id', 'name', 'date', 'opportunity_id', 'partner_mobile', 'user_id', 'state']).filter([['active', '=', true]]).all().then(function(results){
|
|
|
|
|
|
+ var CrmTask = new instance.web.Model('crm.task');
|
|
|
|
+ CrmTask.query(['id', 'partner_id', 'name', 'date_create', 'description', 'opportunity_id', 'task_type_id', 'user_id', 'state','date_action_next']).filter([['active', '=', true]]).all().then(function(results){
|
|
|
|
+ defer.resolve(results);
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ return defer;
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ fetchTaskType: function () {
|
|
|
|
+ var self = this;
|
|
|
|
+ var defer = $.Deferred();
|
|
|
|
+
|
|
|
|
+ var TaskType = new instance.web.Model('crm.task.type');
|
|
|
|
+ TaskType.query(['id', 'name']).filter([['active', '=', true]]).all().then(function(results){
|
|
defer.resolve(results);
|
|
defer.resolve(results);
|
|
});
|
|
});
|
|
|
|
|
|
@@ -237,13 +260,41 @@ function report_phonecall(reporting){
|
|
});
|
|
});
|
|
},
|
|
},
|
|
|
|
|
|
- getCrmPhone: function (id) {
|
|
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ getCrmTask: function (id) {
|
|
var self = this;
|
|
var self = this;
|
|
- return _.filter(self.CrmPhone,function (item) {
|
|
|
|
|
|
+ return _.filter(self.CrmTask,function (item) {
|
|
return item.id == id;
|
|
return item.id == id;
|
|
});
|
|
});
|
|
},
|
|
},
|
|
|
|
|
|
|
|
+ searchTaskType: function () {
|
|
|
|
+ var self = this;
|
|
|
|
+ var results = self.TaskType;
|
|
|
|
+ results = _.map(results, function (item) {
|
|
|
|
+ return {
|
|
|
|
+ label: item.id + '-'+ item.name,
|
|
|
|
+ value: item.id + '-'+ item.name
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ self.$('#task').autocomplete({
|
|
|
|
+ source: results,
|
|
|
|
+ minLength:0,
|
|
|
|
+ search: function(event, ui) {
|
|
|
|
+ if (!(self.$('#task').val())){
|
|
|
|
+ self.factSearch();
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ close: function( event, ui ) {
|
|
|
|
+ self.factSearch();
|
|
|
|
+ },
|
|
|
|
+ select: function(event, ui) {
|
|
|
|
+ self.factSearch();
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ },
|
|
|
|
+
|
|
search: function () {
|
|
search: function () {
|
|
var self = this;
|
|
var self = this;
|
|
var results = self.ResPartner;
|
|
var results = self.ResPartner;
|
|
@@ -270,38 +321,44 @@ function report_phonecall(reporting){
|
|
});
|
|
});
|
|
},
|
|
},
|
|
|
|
|
|
- // volver
|
|
|
|
- volver: function(){
|
|
|
|
- this.$el.find('#volver_btn').empty();
|
|
|
|
- this.$el.find('.bootstrap-table').show({
|
|
|
|
- effect: 'drop',
|
|
|
|
- direction: 'down',
|
|
|
|
- duration: 200,
|
|
|
|
- });
|
|
|
|
- },
|
|
|
|
-
|
|
|
|
BuildTable: function(){
|
|
BuildTable: function(){
|
|
var self = this;
|
|
var self = this;
|
|
- var crmphone = self.CrmPhone;
|
|
|
|
|
|
+ var crmtask = self.CrmTask;
|
|
var invoice;
|
|
var invoice;
|
|
var Crm;
|
|
var Crm;
|
|
|
|
+ var taskType;
|
|
|
|
+ var stage;
|
|
var data = [];
|
|
var data = [];
|
|
|
|
|
|
- _.each(crmphone, function(item){
|
|
|
|
|
|
+ _.each(crmtask, function(item){
|
|
|
|
|
|
- invoice = self.getCrmPhone(item.id).shift();
|
|
|
|
- Crm = self.getCrm(item.id);
|
|
|
|
|
|
+ if(item.state=='pending'){
|
|
|
|
+ stage = 'Pendiente'
|
|
|
|
+ }else{
|
|
|
|
+ if(item.state=='done'){
|
|
|
|
+ stage = 'Realizado'
|
|
|
|
+ }else{
|
|
|
|
+ stage = 'Cancelado'
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
|
|
|
|
+ invoice = self.getCrmTask(item.id).shift();
|
|
|
|
+ Crm = self.getCrm(item.id);
|
|
|
|
+ // taskType = self.getTaskType(item.task_type_id);
|
|
|
|
|
|
data.push({
|
|
data.push({
|
|
id : item.id,
|
|
id : item.id,
|
|
opportunity_id : self.valorNull(item.opportunity_id),
|
|
opportunity_id : self.valorNull(item.opportunity_id),
|
|
- partner: self.valorNull(Crm.partner_id),
|
|
|
|
- description: self.valorNull(item.name),
|
|
|
|
- create_date: moment(item.date).format("DD/MM/YYYY"),
|
|
|
|
- date: moment(item.date).format("YYYY-MM-DD"),
|
|
|
|
|
|
+ partner: self.valorNull(item.partner_id[1]),
|
|
|
|
+ description: self.valorNull(item.description),
|
|
|
|
+ activity: self.valorNull(item.name),
|
|
|
|
+ create_date: moment(item.date_create).format("DD/MM/YYYY"),
|
|
|
|
+ date: moment(item.date_create).format("YYYY-MM-DD"),
|
|
user: item.user_id[1],
|
|
user: item.user_id[1],
|
|
- stage: item.state,
|
|
|
|
|
|
+ task_type_id: item.task_type_id[0],
|
|
|
|
+ next_date: moment(item.date_action_next).format("DD/MM/YYYY"),
|
|
|
|
+ task_name: item.task_type_id[1],
|
|
|
|
+ stage: stage,
|
|
partner_id : item.partner_id[0]
|
|
partner_id : item.partner_id[0]
|
|
});
|
|
});
|
|
});
|
|
});
|
|
@@ -315,26 +372,29 @@ function report_phonecall(reporting){
|
|
var yesterday = moment().add(-1, 'days').format('YYYY-MM-DD');
|
|
var yesterday = moment().add(-1, 'days').format('YYYY-MM-DD');
|
|
var month = moment().format('YYYY-MM');
|
|
var month = moment().format('YYYY-MM');
|
|
var last_month = moment().add(-1, 'months').format('YYYY-MM');
|
|
var last_month = moment().add(-1, 'months').format('YYYY-MM');
|
|
|
|
+ var desde = this.$el.find('#from').val();
|
|
|
|
+ var hasta = this.$el.find('#to').val();
|
|
var partner= this.$el.find('#partner').val().split('-');
|
|
var partner= this.$el.find('#partner').val().split('-');
|
|
|
|
+ var task= this.$el.find('#current_task').val().split('-');
|
|
var content = self.content;
|
|
var content = self.content;
|
|
if ($('#A').is(":checked")){
|
|
if ($('#A').is(":checked")){
|
|
content = _.filter(content, function (inv){
|
|
content = _.filter(content, function (inv){
|
|
- return moment(inv.date).format('YYYY-MM-DD') == today;
|
|
|
|
|
|
+ return moment(inv.date_create).format('YYYY-MM-DD') == today;
|
|
});
|
|
});
|
|
}
|
|
}
|
|
if ($('#B').is(":checked")){
|
|
if ($('#B').is(":checked")){
|
|
content = _.filter(content, function (inv){
|
|
content = _.filter(content, function (inv){
|
|
- return moment(inv.date).format('YYYY-MM-DD') == yesterday;
|
|
|
|
|
|
+ return moment(inv.date_create).format('YYYY-MM-DD') == yesterday;
|
|
});
|
|
});
|
|
}
|
|
}
|
|
if ($('#C').is(":checked")){
|
|
if ($('#C').is(":checked")){
|
|
content = _.filter(content, function (inv){
|
|
content = _.filter(content, function (inv){
|
|
- return moment(inv.date).format('YYYY-MM') == month;
|
|
|
|
|
|
+ return moment(inv.date_create).format('YYYY-MM') == month;
|
|
});
|
|
});
|
|
}
|
|
}
|
|
if ($('#D').is(":checked")){
|
|
if ($('#D').is(":checked")){
|
|
content = _.filter(content, function (inv){
|
|
content = _.filter(content, function (inv){
|
|
- return moment(inv.date).format('YYYY-MM') == last_month;
|
|
|
|
|
|
+ return moment(inv.date_create).format('YYYY-MM') == last_month;
|
|
});
|
|
});
|
|
}
|
|
}
|
|
if ($('#Z').is(":checked")){
|
|
if ($('#Z').is(":checked")){
|
|
@@ -355,30 +415,33 @@ function report_phonecall(reporting){
|
|
$('#datepicker').css('display','none');
|
|
$('#datepicker').css('display','none');
|
|
}
|
|
}
|
|
|
|
|
|
- this.$el.find('#volver_btn').append(selector);
|
|
|
|
- this.$el.find('.bootstrap-table').hide({
|
|
|
|
- effect: 'drop',
|
|
|
|
- direction: 'up',
|
|
|
|
- duration: 200,
|
|
|
|
- complete: function () {
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
- this.$el.find('#toolbar').hide({
|
|
|
|
- effect: 'drop',
|
|
|
|
- direction: 'up',
|
|
|
|
- duration: 200,
|
|
|
|
- complete: function () {
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
-
|
|
|
|
-
|
|
|
|
if (partner != ""){
|
|
if (partner != ""){
|
|
content = _.filter(content, function(inv){
|
|
content = _.filter(content, function(inv){
|
|
return inv.partner_id == partner[0];
|
|
return inv.partner_id == partner[0];
|
|
});
|
|
});
|
|
}
|
|
}
|
|
|
|
+ if (task != ""){
|
|
|
|
+ content = _.filter(content, function(inv){
|
|
|
|
+ return inv.task_type_id == task[0];
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if ($('#pending').is(":checked")){
|
|
|
|
+ content = _.filter(content, function (inv){
|
|
|
|
+ return inv.stage == 'Pendiente';
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ if ($('#done').is(":checked")){
|
|
|
|
+ content = _.filter(content, function (inv){
|
|
|
|
+ return inv.stage == 'Realizado';
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ if ($('#cancel').is(":checked")){
|
|
|
|
+ content = _.filter(content, function (inv){
|
|
|
|
+ return inv.stage == 'Cancelado';
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+
|
|
self.loadTable(content)
|
|
self.loadTable(content)
|
|
},
|
|
},
|
|
|
|
|
|
@@ -436,12 +499,14 @@ function report_phonecall(reporting){
|
|
pdfDoc.autoTable(getColumns, rows, {
|
|
pdfDoc.autoTable(getColumns, rows, {
|
|
styles: { overflow: 'linebreak', fontSize: 8, columnWidth: 'wrap'},
|
|
styles: { overflow: 'linebreak', fontSize: 8, columnWidth: 'wrap'},
|
|
columnStyles: {
|
|
columnStyles: {
|
|
- opportunity_id : {columnWidth: '8px'},
|
|
|
|
|
|
+ create_date : {columnWidth: '8px'},
|
|
partner : {columnWidth: '8px'},
|
|
partner : {columnWidth: '8px'},
|
|
|
|
+ activity : {columnWidth: '8px'},
|
|
|
|
+ user : {columnWidth: '8px'},
|
|
description : {columnWidth: '8px'},
|
|
description : {columnWidth: '8px'},
|
|
- date : {columnWidth: '8px'},
|
|
|
|
- stage : {columnWidth: '8px'},
|
|
|
|
- user : {columnWidth: '8px'}
|
|
|
|
|
|
+ task_name: {columnWidth: '8px'},
|
|
|
|
+ stage : {columnWidth: '8px'}
|
|
|
|
+
|
|
},
|
|
},
|
|
margin: { top: 16, horizontal: 7},
|
|
margin: { top: 16, horizontal: 7},
|
|
|
|
|
|
@@ -449,7 +514,7 @@ function report_phonecall(reporting){
|
|
pdfDoc.setFontSize(12);
|
|
pdfDoc.setFontSize(12);
|
|
pdfDoc.setFontStyle('bold');
|
|
pdfDoc.setFontStyle('bold');
|
|
pdfDoc.setTextColor(40);
|
|
pdfDoc.setTextColor(40);
|
|
- pdfDoc.text('Histórico de llamadas de crm ', data.settings.margin.left, 10);
|
|
|
|
|
|
+ pdfDoc.text('Histórico de Tareas CRM ', data.settings.margin.left, 10);
|
|
|
|
|
|
if(desde.length > 0 || hasta.length > 0){
|
|
if(desde.length > 0 || hasta.length > 0){
|
|
var fecha='';
|
|
var fecha='';
|
|
@@ -480,7 +545,7 @@ function report_phonecall(reporting){
|
|
if (typeof pdfDoc.putTotalPages === 'function') {
|
|
if (typeof pdfDoc.putTotalPages === 'function') {
|
|
pdfDoc.putTotalPages(totalPagesExp);
|
|
pdfDoc.putTotalPages(totalPagesExp);
|
|
}
|
|
}
|
|
- pdfDoc.save('Histórico de llamadas crm.pdf')
|
|
|
|
|
|
+ pdfDoc.save('Histórico de Tareas CRM.pdf')
|
|
},
|
|
},
|
|
});
|
|
});
|
|
}
|
|
}
|