Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- let reader = new FileReader();
- let strBuffer = "";
- let sber_deals = null;
- let crm_deals = [];
- function processFiles(files) {
- let file = files[0];
- reader.readAsText(file);
- }
- reader.onload = function (e) {
- strBuffer = e.target.result;
- };
- function loadData() {
- //взять только оплаченные по определенному способу оплаты
- crm_deals.forEach(data => data.filter(deal => parser.check_payment_methods(get_user_field(deal, 'Способ оплаты'))));
- if (strBuffer == "")
- alert("Файл не загружен");
- else
- sber_deals = parser.get_deals(strBuffer);
- modify(sber_deals, crm_deals, parser);
- }
- function application () {
- }
- application.prototype.displayErrorMessage = function(message) {
- $('#deal-list').html(message);
- $('#deal-sum').html(message);
- }
- application.prototype.displayCurrentUser = function(selector) {
- BX24.callMethod('user.current', {}, function(result){
- $(selector).html(result.data().NAME + ' ' + result.data().LAST_NAME);
- });
- }
- application.prototype.displayUserClosedDeals = function (idUser) {
- var curapp = this;
- BX24.callMethod(
- "crm.deal.list",
- {
- order: { "DATE_CREATE": "ASC" },
- filter: { "ASSIGNED_BY_ID": idUser },
- select: [ "TITLE", "OPPORTUNITY", "DATE_CREATE", "COMPANY_ID", "UF_*" ]
- },
- function(result)
- {
- if (result.error()) {
- curapp.displayErrorMessage('К сожалению, произошла ошибка получения сделок. Попробуйте повторить отчет позже');
- console.error(result.error());
- }
- else
- {
- let data = result.data();
- let requisites = null;
- BX24.callMethod(
- "crm.requisite.list",
- {
- select: [ "ID", "NAME", "RQ_INN", "RQ_COMPANY_NAME"]
- },
- function(result)
- {
- if(result.error())
- console.error(result.error());
- else
- {
- //console.dir(result.data());
- requisites = result.data();
- if(result.more())
- result.next();
- }
- }
- );
- data.forEach(deal => {
- let id = deal.COMPANY_ID;
- if (id != 0) {
- BX24.callMethod(
- "crm.company.get",
- { id: id },
- function(result)
- {
- if(result.error())
- console.error(result.error());
- else
- {
- //console.dir(result.data());
- requisites.forEach( requisite => {
- if (requisite.RQ_COMPANY_NAME == result.data().TITLE)
- console.log(requisite.RQ_INN);//сюда надо
- });
- }
- }
- );
- }
- });
- //взять неоплаченные сделки
- data = data.filter(deal => get_user_field(deal, 'Оплата') == VALUES_PAYS[config.payment_status]);
- //взять сделки за последние Х дней
- data = data.filter(deal => is_day_in_delta(config.days_count, deal.DATE_CREATE));
- crm_deals.push(data);
- if (result.more())
- result.next();
- }
- }
- );
- }
- // create our application
- app = new application();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement