Ejemplo n.º 1
0
def cek_wo(bot, update):
    db_data = {}
    push = {}
    text = update.message.text
    user = update.message.from_user
    user_id = get_id(user.id)
    status_id = model.get_status_id(text)

    if text == "⬅️ Kembali":
        return bot_main.start(bot, update, db_data)
    wo_data = model.get_wo_teknisi(user_id, status_id)
    records = wo_data.fetchall()
    if wo_data.rowcount > 0:
        for row in records:
            db_data['TRACK_ID'] = row[18]
            db_data['ORDER_DATE'] = row[19]
            db_data['CUSTOMER_NAME'] = row[37]
            db_data['KCONTACT'] = row[21]
            db_data['ADDRESS_INSTALLATION'] = row[42]
            db_data['PACKAGE'] = row[43]
            db_data['CUSTOMER_PHONE'] = row[38]
            db_data['STO'] = row[52]
            if text == 'Assign Teknisi':
                keyboard = [[InlineKeyboardButton("UPDATE", callback_data=db_data['TRACK_ID'])]]
                reply_markup = InlineKeyboardMarkup(keyboard)
                update.message.reply_text('📋 <b>List WO</b>\n'
                                          "{}".format(bot_main.array_to_str(db_data)),
                                          parse_mode=ParseMode.HTML,
                                          reply_markup=reply_markup)
            else:
                push['TRACK_ID'] = row[18]
                push['SC'] = row[44]
                push['STATUS'] = row[54]
                push['TECHNICIAN_NAME'] = get_teknisi(row[25])
                push['CUSTOMER_NAME'] = row[37]
                push['CUSTOMER_PHONE'] = row[38]
                push['ADDRESS_INSTALLATION'] = row[42]
                update.message.reply_text('📋 <b>List WO</b>\n'
                                          "{}".format(bot_main.array_to_str(push)),
                                          parse_mode=ParseMode.HTML,
                                          reply_markup=ReplyKeyboardMarkup([['⬅️ Kembali']], one_time_keyboard=True,
                                                                           resize_keyboard=True))
        if text == 'Assign Teknisi':
            update.message.reply_text("📋 *List WO*\n\n Silahkan Pilih WO yang akan di update",
                                      parse_mode=ParseMode.MARKDOWN,
                                      reply_markup=ReplyKeyboardMarkup([['⬅️ Kembali']], one_time_keyboard=True,
                                                                       resize_keyboard=True))
    else:
        update.message.reply_text("Data Work Order tidak ditemukan",
                                  reply_markup=ReplyKeyboardMarkup([['⬅️ Kembali']], one_time_keyboard=True,
                                                                   resize_keyboard=True))
        bot_main.db.commit()
        return ConversationHandler.END
    bot_main.db.commit()
    return bot_main.PUSH_MAIN
Ejemplo n.º 2
0
def cek_myir(bot, update):
    data = {}
    text = update.message.text
    if text == "⬅️ Kembali":
        return bot_main.start(bot, update, data)
    data_ = str(rest_get_myir(text).text)
    json_ = json.loads(data_)

    if json_['code'] == 10:
        update.message.reply_text('Track ID Tidak ditemukan',
                                  reply_markup=ReplyKeyboardMarkup([['⬅️ Kembali']], one_time_keyboard=True,
                                                                   resize_keyboard=True))
        return ConversationHandler.END
    else:
        real_data = json_['data']
        data['Track ID'] = real_data['track_id']
        data['K-Contact'] = json_['data']['detail'][0]['x3']
        data['No. SC'] = real_data['scid']
        data['Tanggal Order'] = real_data['orderDate']
        data['Status'] = real_data['status_name']
        data['Nama Customer'] = real_data['user_name']
        data['Paket'] = real_data['name']
        data['Alamat Instalasi'] = json_['data']['address']['address']
        data['STO'] = json_['data']['data1']['sto']

        update.message.reply_text(
            "🔍 <b>Cek Track ID</b>\n"
            "{}".format(bot_main.array_to_str(data)), parse_mode=ParseMode.HTML,
            reply_markup=ReplyKeyboardMarkup([['⬅️ Kembali']], one_time_keyboard=True, resize_keyboard=True))
        return ConversationHandler.END
Ejemplo n.º 3
0
def approve_sales(bot, update, user_data):
    text = update.message.text
    if text == 'Ya':
        update.message.reply_text(
            "Terimakasih, akun anda akan segera kami aktivasi."
            "{}".format(bot_main.array_to_str(user_data)),
            parse_mode=ParseMode.HTML)
        activate_user(user_data)
    else:
        update.message.reply_text(
            "Silahkan ulangi registrasi dengan mengklik tombol /start")
    return ConversationHandler.END
Ejemplo n.º 4
0
def cek_sc(bot, update):
    data = {}
    text = update.message.text
    if text == "⬅️ Kembali":
        return bot_main.start(bot, update, data)
    data_ = str(rest_get_sc(text).text)
    json_ = json.loads(data_)

    if len(json_['data']) == 0:
        update.message.reply_text('SC Tidak ditemukan',
                                  reply_markup=ReplyKeyboardMarkup([['⬅️ Kembali']], one_time_keyboard=True,
                                                                   resize_keyboard=True))
        return ConversationHandler.END
    else:
        real_data = json_['data'][0]
        track_id = real_data['KCONTACT'].split(';')[1]
        data_track = str(rest_track_myir(track_id).text)
        json_track = json.loads(data_track)
        track_data = json_track['data'][0]

        data['No. SC'] = real_data['ORDER_ID']
        data['Tanggal Order'] = real_data['ORDER_DATE']
        data['Status Order'] = real_data['STATUS_RESUME']
        data['Message 1'] = track_data['MESSAGE1']
        data['Message 2'] = track_data['MESSAGE2']
        data['Tanggal PS'] = real_data['ORDER_DATE_PS']
        data['NCLI'] = real_data['NCLI']
        data['Nama Customer'] = real_data['CUSTOMER_NAME']
        data['Alamat Instalasi'] = real_data['INS_ADDRESS']
        data['Track ID'] = real_data['KCONTACT'].split(';')[1]
        data['No Inet'] = "-" if real_data['SPEEDY'] is None else real_data['SPEEDY'].split('~')[1]
        data['No Pots'] = real_data['POTS']
        data['Nama Alpro'] = real_data['LOC_ID']
        data['Witel'] = real_data['WITEL']
        data['STO'] = real_data['XS2']
        update.message.reply_text(
            "🔍 <b>Cek SC</b>\n"
            "{}".format(bot_main.array_to_str(data)), parse_mode=ParseMode.HTML,
            reply_markup=ReplyKeyboardMarkup([['⬅️ Kembali']], one_time_keyboard=True, resize_keyboard=True))
        return ConversationHandler.END
Ejemplo n.º 5
0
def cek_scbe(bot, update):
    db_data = {}
    push = {}
    date_check = 'A'
    text = update.message.text
    user = update.message.from_user
    user_id = get_id(user.id)
    if text == "⬅️ Kembali":
        return bot_main.start(bot, update, db_data)

    status_id = model.get_status_id(text)
    scbe_data = model.get_scbe(user_id, status_id)
    records = scbe_data.fetchall()
    if scbe_data.rowcount > 0:
        for row in records:
            db_data['TRACK_ID'] = row[25]
            db_data['ORDER_DATE'] = row[26]
            db_data['CUSTOMER_NAME'] = row[44]
            db_data['KCONTACT'] = row[28]
            db_data['ADDRESS_INSTALLATION'] = row[49]
            db_data['PACKAGE'] = row[50]
            db_data['CUSTOMER_PHONE'] = row[45]
            db_data['STO'] = row[23]
            db_data['DATE'] = row[31]
            date_check = 'B'
            if text == 'Not FU':
                date_check = 'C'
                keyboard = [[InlineKeyboardButton("ASSIGN WO", callback_data=db_data['TRACK_ID'])]]
                reply_markup = InlineKeyboardMarkup(keyboard)
                update.message.reply_text(
                    "🌐 <b>SCBE</b>\n"
                    "{}".format(bot_main.array_to_str(db_data)),
                    parse_mode=ParseMode.HTML, reply_markup=reply_markup)
            elif text == 'Kendala Pelanggan':
                if nowtime < db_data['DATE']:
                    date_check = 'C'
                    push['TRACK_ID'] = row[25]
                    push['SC'] = row[51]
                    push['KENDALA'] = row[57]
                    push['DETIL KENDALA'] = row[29]
                    push['TECHNICIAN_NAME'] = get_teknisi(row[32])
                    push['CUSTOMER_NAME'] = row[44]
                    push['CUSTOMER_PHONE'] = row[45]
                    push['ADDRESS_INSTALLATION'] = row[49]
                    update.message.reply_text(
                        "🌐 <b>SCBE</b>\n"
                        "{}".format(bot_main.array_to_str(push)),
                        parse_mode=ParseMode.HTML, reply_markup=ReplyKeyboardMarkup([['⬅️ Kembali']],
                                                                                    one_time_keyboard=True,
                                                                                    resize_keyboard=True))
            elif text == 'Kendala Teknis':
                if nowtime < db_data['DATE']:
                    date_check = 'C'
                    push['TRACK_ID'] = row[25]
                    push['SC'] = row[51]
                    push['KENDALA'] = row[57]
                    push['DETIL KENDALA'] = row[29]
                    push['TECHNICIAN_NAME'] = get_teknisi(row[32])
                    push['CUSTOMER_NAME'] = row[44]
                    push['CUSTOMER_PHONE'] = row[45]
                    push['ADDRESS_INSTALLATION'] = row[49]
                    update.message.reply_text(
                        "🌐 <b>SCBE</b>\n"
                        "{}".format(bot_main.array_to_str(push)),
                        parse_mode=ParseMode.HTML, reply_markup=ReplyKeyboardMarkup([['⬅️ Kembali']],
                                                                                    one_time_keyboard=True,
                                                                                    resize_keyboard=True))
            elif text == 'Assign Teknisi':
                date_check = 'C'
                push['TRACK_ID'] = row[25]
                push['SC'] = row[51]
                push['TECHNICIAN_NAME'] = get_teknisi(row[32])
                push['CUSTOMER_NAME'] = row[44]
                push['CUSTOMER_PHONE'] = row[45]
                push['ADDRESS_INSTALLATION'] = row[49]
                update.message.reply_text(
                    "🌐 <b>SCBE</b>\n"
                    "{}".format(bot_main.array_to_str(push)),
                    parse_mode=ParseMode.HTML, reply_markup=ReplyKeyboardMarkup([['⬅️ Kembali']],
                                                                                one_time_keyboard=True,
                                                                                resize_keyboard=True))
            elif text == 'Push PI':
                date_check = 'C'
                push['TRACK_ID'] = row[25]
                push['SC'] = row[51]
                push['TECHNICIAN_NAME'] = get_teknisi(row[32])
                push['CUSTOMER_NAME'] = row[44]
                push['CUSTOMER_PHONE'] = row[45]
                push['ADDRESS_INSTALLATION'] = row[49]
                update.message.reply_text(
                    "🌐 <b>SCBE</b>\n"
                    "{}".format(bot_main.array_to_str(push)),
                    parse_mode=ParseMode.HTML, reply_markup=ReplyKeyboardMarkup([['⬅️ Kembali']],
                                                                                one_time_keyboard=True,
                                                                                resize_keyboard=True))
            elif text == 'PI':
                if nowtime < db_data['DATE']:
                    date_check = 'C'
                    push['TRACK_ID'] = row[25]
                    push['SC'] = row[51]
                    push['TECHNICIAN_NAME'] = get_teknisi(row[32])
                    push['CUSTOMER_NAME'] = row[44]
                    push['CUSTOMER_PHONE'] = row[45]
                    push['ADDRESS_INSTALLATION'] = row[49]
                    update.message.reply_text(
                        "🌐 <b>SCBE</b>\n"
                        "{}".format(bot_main.array_to_str(push)),
                        parse_mode=ParseMode.HTML, reply_markup=ReplyKeyboardMarkup([['⬅️ Kembali']],
                                                                                    one_time_keyboard=True,
                                                                                    resize_keyboard=True))
            else:
                update.message.reply_text("Data SCBE tidak ditemukan",
                                          reply_markup=ReplyKeyboardMarkup([['⬅️ Kembali']], one_time_keyboard=True,
                                                                           resize_keyboard=True))
                bot_main.db.commit()
                return ConversationHandler.END
        if text == 'Not FU':
            update.message.reply_text("🌐 *SCBE*\n\n Silahkan Pilih WO yang akan di assign",
                                      parse_mode=ParseMode.MARKDOWN,
                                      reply_markup=ReplyKeyboardMarkup([['⬅️ Kembali']], one_time_keyboard=True,
                                                                       resize_keyboard=True))
        elif date_check == 'B':
            update.message.reply_text("Data SCBE tidak ditemukan",
                                      reply_markup=ReplyKeyboardMarkup([['⬅️ Kembali']], one_time_keyboard=True,
                                                                       resize_keyboard=True))
            bot_main.db.commit()
            return ConversationHandler.END

        bot_main.db.commit()
        return bot_main.GET_MYIR_WO
    else:
        update.message.reply_text("Data SCBE tidak ditemukan",
                                  reply_markup=ReplyKeyboardMarkup([['⬅️ Kembali']], one_time_keyboard=True,
                                                                   resize_keyboard=True))
        bot_main.db.commit()
        return ConversationHandler.END
Ejemplo n.º 6
0
def cek_order(bot, update):
    db_data = {}
    push = {}
    date_check = 'A'
    text = update.message.text
    user = update.message.from_user
    user_id = get_id(user.id)
    if text == "⬅️ Kembali":
        return bot_main.start(bot, update, db_data)

    status_id = model.get_status_id(text)
    order_data = model.get_order(user_id, status_id)
    records = order_data.fetchall()
    if order_data.rowcount > 0:
        for row in records:
            db_data['TRACK_ID'] = row[5]
            db_data['ORDER_DATE'] = row[6]
            db_data['CUSTOMER_NAME'] = row[24]
            db_data['KCONTACT'] = row[8]
            db_data['ADDRESS_INSTALLATION'] = row[29]
            db_data['PACKAGE'] = row[30]
            db_data['CUSTOMER_PHONE'] = row[25]
            db_data['STO'] = row[3]
            db_data['DATE'] = row[11]
            date_check = 'B'
            if text == 'Not FU':
                date_check = 'C'
                update.message.reply_text(
                    "📋 <b>List Order</b>\n"
                    "{}".format(bot_main.array_to_str(db_data)),
                    parse_mode=ParseMode.HTML, reply_markup=ReplyKeyboardMarkup([['⬅️ Kembali']],
                                                                                one_time_keyboard=True,
                                                                                resize_keyboard=True))
            elif text == 'Kendala Pelanggan':
                    date_check = 'C'
                    push['TRACK_ID'] = row[5]
                    push['SC'] = row[31]
                    push['KENDALA'] = row[37]
                    push['DETIL KENDALA'] = row[9]
                    push['TECHNICIAN_NAME'] = get_teknisi(row[12])
                    push['CUSTOMER_NAME'] = row[24]
                    push['CUSTOMER_PHONE'] = row[25]
                    push['ADDRESS_INSTALLATION'] = row[29]
                    update.message.reply_text(
                        "📋 <b>List Order</b>\n"
                        "{}".format(bot_main.array_to_str(push)),
                        parse_mode=ParseMode.HTML, reply_markup=ReplyKeyboardMarkup([['⬅️ Kembali']],
                                                                                    one_time_keyboard=True,
                                                                                    resize_keyboard=True))
            elif text == 'Kendala Teknis':
                    date_check = 'C'
                    push['TRACK_ID'] = row[5]
                    push['SC'] = row[31]
                    push['KENDALA'] = row[37]
                    push['DETIL KENDALA'] = row[9]
                    push['TECHNICIAN_NAME'] = get_teknisi(row[12])
                    push['CUSTOMER_NAME'] = row[24]
                    push['CUSTOMER_PHONE'] = row[25]
                    push['ADDRESS_INSTALLATION'] = row[29]
                    update.message.reply_text(
                        "📋 <b>List Order</b>\n"
                        "{}".format(bot_main.array_to_str(push)),
                        parse_mode=ParseMode.HTML, reply_markup=ReplyKeyboardMarkup([['⬅️ Kembali']],
                                                                                    one_time_keyboard=True,
                                                                                    resize_keyboard=True))
            elif text == 'Assign Teknisi':
                date_check = 'C'
                push['TRACK_ID'] = row[5]
                push['SC'] = row[31]
                push['TECHNICIAN_NAME'] = get_teknisi(row[12])
                push['CUSTOMER_NAME'] = row[24]
                push['CUSTOMER_PHONE'] = row[25]
                push['ADDRESS_INSTALLATION'] = row[29]
                update.message.reply_text(
                    "📋 <b>List Order</b>\n"
                    "{}".format(bot_main.array_to_str(push)),
                    parse_mode=ParseMode.HTML, reply_markup=ReplyKeyboardMarkup([['⬅️ Kembali']],
                                                                                one_time_keyboard=True,
                                                                                resize_keyboard=True))
            elif text == 'Push PI':
                date_check = 'C'
                push['TRACK_ID'] = row[5]
                push['SC'] = row[31]
                push['TECHNICIAN_NAME'] = get_teknisi(row[12])
                push['CUSTOMER_NAME'] = row[24]
                push['CUSTOMER_PHONE'] = row[25]
                push['ADDRESS_INSTALLATION'] = row[29]
                update.message.reply_text(
                    "📋 <b>List Order</b>\n"
                    "{}".format(bot_main.array_to_str(push)),
                    parse_mode=ParseMode.HTML, reply_markup=ReplyKeyboardMarkup([['⬅️ Kembali']],
                                                                                one_time_keyboard=True,
                                                                                resize_keyboard=True))
            elif text == 'PI':
                    date_check = 'C'
                    push['TRACK_ID'] = row[5]
                    push['SC'] = row[31]
                    push['TECHNICIAN_NAME'] = get_teknisi(row[12])
                    push['CUSTOMER_NAME'] = row[24]
                    push['CUSTOMER_PHONE'] = row[25]
                    push['ADDRESS_INSTALLATION'] = row[29]
                    update.message.reply_text(
                        "📋 <b>List Order</b>\n"
                        "{}".format(bot_main.array_to_str(push)),
                        parse_mode=ParseMode.HTML, reply_markup=ReplyKeyboardMarkup([['⬅️ Kembali']],
                                                                                    one_time_keyboard=True,
                                                                                    resize_keyboard=True))
            else:
                update.message.reply_text("Data SCBE tidak ditemukan",
                                          reply_markup=ReplyKeyboardMarkup([['⬅️ Kembali']], one_time_keyboard=True,
                                                                           resize_keyboard=True))
                bot_main.db.commit()
                return ConversationHandler.END
        if date_check == 'B':
            update.message.reply_text("Data Order tidak ditemukan",
                                      reply_markup=ReplyKeyboardMarkup([['⬅️ Kembali']], one_time_keyboard=True,
                                                                       resize_keyboard=True))
            bot_main.db.commit()
            return ConversationHandler.END

        bot_main.db.commit()
        return bot_main.GET_MYIR_WO
    else:
        update.message.reply_text("Data Order tidak ditemukan",
                                  reply_markup=ReplyKeyboardMarkup([['⬅️ Kembali']], one_time_keyboard=True,
                                                                   resize_keyboard=True))
        bot_main.db.commit()
        return ConversationHandler.END