def view_expense_click(self): ''' ''' data=DataReport(self.droid) data.start_gui(self.cursor) self.droid.fullShow(self.xml_read) del data return
def fetch(): """Return the results of a data request based on the configuration UID, options include search, pagination and sorting""" req_data= request.get_json() report=get_data_report_config_from_post_uid() if None is not report: ds = DataReport(json=report,db_type=get_db_type()) results = ds.fetch(request=req_data,app=api) json_data = jsonpickle.encode(results, unpicklable=False) return json_data #json_string = json.dumps(results) #return json_string return "{msg:'Error'}"
def recap_recent_update_item(update, context): send_typing_state(update, context) df = DataReport.recap_as_dataframe(db.get_recap_recent_update()) date_recap = datetime.datetime.today().strftime('%Y-%m-%d') file_name = 'rekap item tanggal {}.xlsx'.format(date_recap) df.to_excel(file_name, index=False) context.bot.send_document(chat_id=update.effective_chat.id, document=open(file_name, 'rb'), filename=file_name)
def get_visualize_jenis(update, context): send_typing_state(update, context) data_counts = db.get_count_jenis_item() if not data_counts: context.bot.send_message(chat_id=update.effective_chat.id, text="data jenis tidak tidak ditemukan") else: file_name = DataReport.visualize_count_item(data_counts, 'Jenis', 'Rekap Jenis') context.bot.send_photo(chat_id=update.effective_chat.id, photo=open(file_name, 'rb'))
def config(): """Return the json encoded data report configuration for the provided post 'UID'""" report=get_data_report_config_from_post_uid() # TODO load from YAML and Load from DB #if None is report: # load_yaml(file) if None is not report: ds=DataReport(json=report,db_type=get_db_type()) json_data = jsonpickle.encode(ds, unpicklable=False) return json_data else: return "{msg:'Error'}"
def add_jenis_handler(update, context): respon_message = update.message.text.replace('/add_jenis', '').split(";") if len(respon_message) == 2: if DataReport.is_number(respon_message[1]): db.add_jenis(respon_message[0].strip(), respon_message[1].strip()) context.bot.send_message(chat_id=update.effective_chat.id, text="jenis berhasil ditambahkan") return context.bot.send_message( chat_id=update.effective_chat.id, text= "format yang anda masukkan salah pastikan format yang dimasukkan /add_jenis (spasi) " "(nama jenis);(durasi reminder) \nex: /add_jenis OPTICAL LISGHT SOURCE ; 6" )
def track_record(update, context): send_typing_state(update, context) serial_number = update.message.text.replace('/track_record', '').strip().upper() pd_id = db.get_product_id(serial_number) if pd_id is None: context.bot.send_message(chat_id=update.effective_chat.id, text="serial number tidak ditemukan") else: track_records = db.get_track_record(pd_id) if not track_records: context.bot.send_message( chat_id=update.effective_chat.id, text="serial number ditemukan namun belum memiliki track record" ) else: df = DataReport.recap_as_dataframe(track_records) date_recap = datetime.datetime.today().strftime('%Y-%m-%d') file_name = 'rekap track record {} tanggal {}.xlsx'.format( serial_number, date_recap) df.to_excel(file_name, index=False) context.bot.send_document(chat_id=update.effective_chat.id, document=open(file_name, 'rb'), filename=file_name)
def print_list(): db_data = database.load() print(DataReport( [('Title', 'title'), ('Course', 'course'), ('Due Date', 'due_date')], db_data['assignments']).ascii_table())
def add_new_item(update, context): user_id = int(update.message.from_user.id) respon_message = update.message.text.replace('/add_item', '').split(";") if db.is_user_id_already_register(user_id): if len(respon_message) == 5: sn = str(respon_message[0]).strip().upper() pn = str(respon_message[1]).strip().upper() merk_id = respon_message[2].strip() jenis_id = respon_message[3].strip() product_stated = str(respon_message[4]).strip().lower() if DataReport.is_number(merk_id) and DataReport.is_number( jenis_id): merk_id = int(merk_id) jenis_id = int(jenis_id) if not db.is_sn_exist(sn): list_id_m = db.get_id_merks() list_id_j = db.get_id_jenises() if (merk_id in list_id_m) and (jenis_id in list_id_j): if is_product_state_in_list(product_stated): user_id = db.get_user_id_by_telegram(user_id) db.add_new_item(sn, pn, merk_id, jenis_id, product_stated, user_id) context.bot.send_message( chat_id=update.effective_chat.id, text="penambahan item berhasil dilakukan") return else: context.bot.send_message( chat_id=update.effective_chat.id, text= "kondisi item tidak terdapat pada list lihat di /list_code" ) return else: context.bot.send_message( chat_id=update.effective_chat.id, text= "kode jenis atau kode merk tidak dikenali lihat di /list_code" ) return else: context.bot.send_message( chat_id=update.effective_chat.id, text="serial number sudah dipakai sebelumnya") return else: context.bot.send_message( chat_id=update.effective_chat.id, text= "pastikan kode merk dan jenis berupa angka lihat di /list_code" ) return else: context.bot.send_message( chat_id=update.effective_chat.id, text= "format yang dimasukkan salah pastikan format yang dimasukkan berupa \n" " /add_item serial_number ; nama_item ; kode_merk ; kode_jenis ; kondisi_item" ) return else: context.bot.send_message(chat_id=update.effective_chat.id, text="user anda belum terdaftar dalam sistem") return
def get_visualize_state(update, context): send_typing_state(update, context) file_name = DataReport.visualize_by_product_state( db.get_products_group_by_state()) context.bot.send_photo(chat_id=update.effective_chat.id, photo=open(file_name, 'rb'))
def on_display_click(self): data_obj=DataReport() data_report_tuple_list=data_obj.get_data_report(self.connection_obj,"2012-06-30") print data_report_tuple_list