def customer_coordinate(update, context): user = update.message.from_user user_location = update.message.location location = str(user_location.latitude) + ", " + str( user_location.longitude) context.user_data['CUSTOMER_COORDINATE'] = location sql = " insert into valdat_migrate values (NULL,'" + data_json[ 'ORDER_ID'] + "','" + context.user_data['CEK_IN_MIGRATE'] + "','" + context.user_data[ 'NO_TELP_MIGRATE'] + "','" + context.user_data['NO_INET_MIGRATE'] + "','" + context.user_data[ 'CUSTOMER_NAME'] + "','" + context.user_data[ 'CUSTOMER_ADDRESS'] + "','" + context.user_data[ 'CEK_STO_MIGRATE'] + "','" + context.user_data[ 'ODP_MIGRATE'] + "','" + context.user_data['PORT'] + "','" + context.user_data[ 'DC_LENGTH'] + "','" + context.user_data[ 'QR_CODE_MIGRATE'] + "','" + context.user_data[ 'SN_ONT'] + "','" + context.user_data[ 'SN_STB'] + "','" + context.user_data[ 'TECHNICIAN_NAME'] + "','" + context.user_data[ 'MITRA'] + "','" + context.user_data[ 'TAG_ODP_MIGRATE'] + "','" + context.user_data[ 'CUSTOMER_COORDINATE'] + "',NULL,1,1,'" + context.user_data[ 'NO_HP'] + "') " print(sql) cursor = db_conn.query(sql) db_conn.comit() update.message.reply_text("Data \n" "{}".format(list_data(context.user_data))) update.message.reply_text("Terimakasih Data Telah Tersimpan", reply_markup=ReplyKeyboardRemove()) return ConversationHandler.END
def qrcode_dropcore(update, context): user = update.message.from_user context.user_data['QRCODE_DROPCORE'] = update.message.text sql = " insert into valdat_omset values (NULL,NULL,NULL,'" + context.user_data[ 'CEK_IN_OMSET'] + "','" + context.user_data[ 'OLD_PORT'] + "','" + context.user_data[ 'NEW_PORT'] + "','" + context.user_data[ 'OLD_ODP'] + "','" + context.user_data[ 'NEW_ODP'] + "','" + context.user_data[ 'NO_TELP'] + "','" + context.user_data[ 'NO_INTERNET'] + "','" + context.user_data[ 'QRCODE_DROPCORE'] + "',1,NULL,NULL,NULL)" print(sql) cursor = db_conn.query(sql) db_conn.comit() #context.user_data['CEK_IN_OMSET'] = "✔" #context.user_data['OLD_PORT'] = "✔" #context.user_data['NEW_PORT'] = "✔" #context.user_data['OLD_ODP'] = "✔" #context.user_data['NEW_ODP'] = "✔" #context.user_data['NO_INTERNET'] = "✔" #context.user_data['NO_TELP'] = "✔" #context.user_data['QRCODE_DROPCORE'] = "✔" update.message.reply_text("Data \n" "{}".format(list_data(context.user_data))) update.message.reply_text("Terimakasih Data Telah Tersimpan", reply_markup=ReplyKeyboardRemove()) return ConversationHandler.END
def port_expand(update, context): user = update.message.from_user context.user_data['PORT_EXPAND'] = update.message.text sql = " insert into valdat_expand values (NULL,NULL,NULL,'" + context.user_data[ 'CEK_STO'] + "','" + context.user_data['ODP_REAL'] + "','" + data_json[ 'ORDER_ID'] + "','" + context.user_data[ 'IN_NUMBER'] + "','" + context.user_data[ 'OLD_CAPACITY'] + "','" + context.user_data[ 'NEW_CAPACITY'] + "','" + context.user_data[ 'ODP_COORDINATE'] + "',1,1,'" + context.user_data[ 'QRCODE_PORT'] + "',1,NULL,NULL,1,'" + context.user_data[ 'PORT_EXPAND'] + "')" print(sql) cursor = db_conn.query(sql) db_conn.comit() #context.user_data['SC_NUMBER'] = "✔" #context.user_data['IN_NUMBER'] = "✔" #context.user_data['CEK_STO'] = "✔" #context.user_data['ODP_REAL'] = "✔" #context.user_data['OLD_CAPACITY'] = "✔" #context.user_data['NEW_CAPACITY'] = "✔" #context.user_data['ODP_COORDINATE'] = "✔" #context.user_data['QRCODE_PORT'] = "✔" #context.user_data['PORT_EXPAND'] = "✔" update.message.reply_text("Data \n" "{}".format(list_data(context.user_data))) update.message.reply_text("Terimakasih Data Telah Tersimpan", reply_markup=ReplyKeyboardRemove()) return ConversationHandler.END
def queryTemplate(x): (name, query) = x result = db.query(query) macro = r"\def\{}{{{}\xspace}}".format(name, result[0][0]) print(macro, flush=True) print("{} = {}".format(name, result[0][0]), flush=True, file=sys.stderr) return macro
def sales_lokasi_pelanggan(update, context): # global data, pathmedia user = update.message.from_user user_location = update.message.location location = str(user_location.latitude) + ", " + str( user_location.longitude) context.user_data['data']['TAG LOKASI PELANGGAN'] = location db_conn.connect() sql = ( " insert into valdat_sales (track_id,k_contact,no_sc,tanggal_order,status,nama_customer,paket,alamat_instalasi,sto,foto_rumah_pelanggan,tag_lokasi_pelanggan) values ('" + context.user_data['data']['TRACK ID'] + "','" + context.user_data['data']['K-CONTACT'] + "','" + context.user_data['data']['NO SC'] + "','" + context.user_data['data']['TANGGAL ORDER'] + "','" + context.user_data['data']['STATUS MYIR'] + "','" + context.user_data['data']['NAMA CUSTOMER'] + "','" + context.user_data['data']['PAKET'] + "','" + context.user_data['data']['ALAMAT INSTALASI'] + "','" + context.user_data['data']['STO'] + "','" + context.user_data['data']['FOTO RUMAH PELANGGAN'] + "','" + context.user_data['data']['TAG LOKASI PELANGGAN'] + "') ") print(sql) cursor = db_conn.query(sql) db_conn.comit() #pandaiman sales_id = cursor.lastrowid sql = ( " insert into valdat_evidence (url,category_id,sales_id) values ('" + context.user_data['data']['FOTO RUMAH PELANGGAN'] + "'," + str(1) + "," + str(sales_id) + ") ") print(sql) cursor = db_conn.query(sql) db_conn.comit() #pandaiman context.user_data['data']['FOTO RUMAH PELANGGAN'] = " ✔️ " context.user_data['data']['TAG LOKASI PELANGGAN'] = " ✔️ " update.message.reply_text("Data \n" "{}".format(list_data( context.user_data['data']))) update.message.reply_text("Terimakasih Data Telah Tersimpan", reply_markup=ReplyKeyboardRemove()) return ConversationHandler.END
def getValue(q): return db.query(q)[0][0]
def foto_odp(update, context): # global pathmedia user = update.message.from_user photo_file = update.message.photo[-1].get_file() path = context.user_data['pathmedia'] + '/psb_{}_foto-odp.jpg'.format( context.user_data['data']['No. SC']) photo_file.download(path) context.user_data['data']['FOTO ODP'] = path # insert to valdat_psb db_conn.connect() sql = ( "insert into valdat_psb (redaman,ps_date,report_date,assigned_hd_date,sc,telegram_chat_id,telegram_username,no_voice,no_internet,sid,customer_name,customer_address,datel,sto,odp_wo,odp_real,odp_port,dc_length,qrcode_dropcore,sn_ont,sn_stb,odp_coordinate,customer_coordinate,status,status_dava,message_id)" + "values (" + context.user_data['data']['REDAMAN'] + ",'" + str(date.today()) + "','" + str(date.today()) + "','" + str(date.today()) + "','" + context.user_data['data']['No. SC'] + "',NULL,NULL,'" + context.user_data['data']['No TELP'] + "','" + context.user_data['data']['No INET'] + "',NULL,'" + context.user_data['data']['PELANGGAN'] + "','" + context.user_data['data']['ALAMAT'] + "',NULL,'" + context.user_data['data']['STO'] + "','" + context.user_data['data']['ODP WO'] + "','" + context.user_data['data']['ODP REAL'] + "','" + context.user_data['data']['PORT'] + "','" + context.user_data['data']['panjang DC'] + "','" + context.user_data['data']['QR CODE'] + "','" + context.user_data['data']['SN ONT'] + "','" + context.user_data['data']['MAC STB'] + "','" + context.user_data['data']['TAG ODP'] + "','" + context.user_data['data']['TAG PELANGGAN'] + "',NULL,NULL,NULL) ") print(sql) cursor = db_conn.query(sql) db_conn.comit() # insert to valdat_psb media = [] media.append(context.user_data['data']['FOTO RUMAH PELANGGAN']) media.append(context.user_data['data']['FOTO PETUGAS & PELANGGAN']) media.append(context.user_data['data']['FOTO PETUGAS & LAYANAN']) media.append(context.user_data['data']['FOTO HASIL REDAMAN']) media.append(context.user_data['data']['FOTO ONT & STB']) media.append(context.user_data['data']['FOTO ODP']) psb_id = cursor.lastrowid for x in media: sql = ( " insert into valdat_evidence (url,category_id,psb_id) values ('" + str(x) + "'," + str(1) + "," + str(psb_id) + ") ") print(sql) cursor = db_conn.query(sql) db_conn.comit() context.user_data['data']['FOTO RUMAH PELANGGAN'] = " ✔️ " context.user_data['data']['FOTO PETUGAS & PELANGGAN'] = " ✔️ " context.user_data['data']['FOTO PETUGAS & LAYANAN'] = " ✔️ " context.user_data['data']['FOTO HASIL REDAMAN'] = " ✔️ " context.user_data['data']['FOTO ONT & STB'] = " ✔️ " context.user_data['data']['FOTO ODP'] = " ✔️ " update.message.reply_text("Data \n" "{}".format(list_data( context.user_data['data']))) update.message.reply_text("Terimakasih Data Telah Tersimpan", reply_markup=ReplyKeyboardRemove()) #save kombinasi list_im1 = ([ context.user_data['pathmedia'] + '/psb_{}_rumah_pelanggan.jpg'.format( context.user_data['data']['No. SC']), context.user_data['pathmedia'] + '/psb_{}_petugas-dengan-pelanggan.jpg'.format( context.user_data['data']['No. SC']), context.user_data['pathmedia'] + '/psb_{}_petugas-dengan-layanan.jpg'.format( context.user_data['data']['No. SC']) ]) list_im2 = ([ context.user_data['pathmedia'] + '/psb_{}_rumah_pelanggan.jpg'.format( context.user_data['data']['No. SC']), context.user_data['pathmedia'] + '/psb_{}_petugas-dengan-pelanggan.jpg'.format( context.user_data['data']['No. SC']), context.user_data['pathmedia'] + '/psb_{}_petugas-dengan-layanan.jpg'.format( context.user_data['data']['No. SC']) ]) imgs1 = [Image.open(i) for i in list_im1] imgs2 = [Image.open(i) for i in list_im2] # pick the image which is the smallest, and resize the others to match it (can be arbitrary image shape here) min_shape = sorted([(np.sum(i.size), i.size) for i in imgs1])[0][1] imgs_comb1 = np.hstack((np.asarray(i.resize(min_shape)) for i in imgs1)) imgs_comb2 = np.hstack((np.asarray(i.resize(min_shape)) for i in imgs2)) imgs = ([imgs_comb1, imgs_comb2]) # for a vertical stacking it is simple: use vstack imgs_comb = np.vstack((np.asarray(i) for i in imgs)) imgs_comb = Image.fromarray(imgs_comb) imgs_comb.save( context.user_data['pathmedia'] + '/psb_{}_kombinasi.jpg'.format(context.user_data['data']['No. SC']), 'JPEG') return ConversationHandler.END