def new_tuning_page(): title = 'Nova personalização' default = None database = DatabaseAdapter() edit_id = request.args.get('tunning_id') if edit_id: title = 'Editar personalização' default = { 'tunning_id': edit_id, 'customer': request.args.get('customer'), 'vehicle': request.args.get('vehicle'), 'date': request.args.get('date'), 'quotas': request.args.get('quotas'), 'value': request.args.get('value'), 'services_details': database.select_custom_sql('tunnings_service_details', where_value=str(edit_id)), 'parts_details': database.select_custom_sql('tunnings_part_details', where_value=str(edit_id)) } # Combo box customers = database.select_all('clientes', 'cpf', 'nome') skills = database.select_all('especialidade', '*') auto_parts = database.select_all('pecas', 'cod_peca', 'valor', 'descricao') database.close() return render_template('new_tuning.html', title=title, combo_box_customers=customers, combo_box_skills=skills, combo_box_parts=auto_parts, default=default)
def query_combo_function(): table = request.args.get('table') column = request.args.get('column') pkey = request.args.get('pkey') database = DatabaseAdapter() combo_values = database.select_all(table, pkey, column) database.close() template = get_table_template(table) new_value_label = f'Inserir {table}' return render_template(template, combo_box=combo_values, new_value=new_value_label)
def mechanics_page(): database = DatabaseAdapter() combo_values = database.select_all('especialidade', '*') new_value = 'Inserir especialidade' mechanics = database.select_all_joined( from_table='mecanicos m', join_table='especialidade e', on='cod_especialidade', how='left', columns=['cod_mecanico', 'm.nome', 'e.nome', 'm.cod_especialidade']) database.close() return render_template('mechanics.html', title='Mecânicos', rows=mechanics, combo_box=combo_values, new_value=new_value)
def vehicles_customers_page(): database = DatabaseAdapter() # Combo box1 vehicles_models = database.select_all_joined( from_table='modelo md', join_table='marcas mc', on='cod_marca', columns=['cod_modelo', "mc.descricao || ' ' || md.descricao"]) # Combo box2 customers = database.select_all('clientes', 'cpf', 'nome') vehicles = database.select_custom_sql("vehicles_customers") database.close() return render_template('vehicles_customers.html', title='Veículos proprietários', rows=vehicles, combo_box1=vehicles_models, combo_box2=customers)
def models_page(): database = DatabaseAdapter() combo_values = database.select_all('marcas', '*') new_value_label = 'Inserir marca' vehicles_models = database.select_all_joined( from_table='modelo md', join_table='marcas mc', on='cod_marca', how='left', columns=[ 'cod_modelo', 'md.descricao', 'tipo', 'motor', 'ano_modelo', 'e_importado', 'mc.cod_marca', 'mc.descricao' ]) database.close() return render_template('vehicles_models.html', title='Modelos', rows=vehicles_models, combo_box=combo_values, new_value=new_value_label)
def services_page(): database = DatabaseAdapter() combo_values = database.select_all('especialidade', '*') new_value = 'Inserir especialidade' services = database.select_all_joined(from_table='servicos s', join_table='especialidade e', on='cod_especialidade', how='left', columns=[ 'cod_servico', 's.descricao', 'valor', 'e.nome', 's.cod_especialidade' ]) database.close() return render_template('services.html', title='Serviços', rows=services, combo_box=combo_values, new_value=new_value)
def general_system_features_function(): database = DatabaseAdapter() result, projects = database.select_all('projetos', '*') database.close() return render_template('general_system_features.html', rows=projects)
def customers_page(): database = DatabaseAdapter() customers = database.select_all('clientes', '*') database.close() return render_template('customers.html', title='Clientes', rows=customers)