示例#1
0
def login():
    configuration = config.Config()

    if request.method == 'POST':
        User.log_in_user(request.form)
        return redirect(url_for('index'))

    return render_template('authentication/login.html', configuration=configuration)
示例#2
0
文件: users.py 项目: gadc1996/cali
def search():
    configuration = config.Config()
    if request.method == 'POST':
        users = User.get_filtered_users(request.form)
    else:
        users = User.get_all_users()

    return render_template('users/search.html', users=users, configuration=configuration)
示例#3
0
文件: users.py 项目: gadc1996/cali
def create():
    configuration = config.Config()
    if request.method == 'POST':
        user = User(request.form)
        if user.is_valid():
            user.create_user()
            Alert.raise_success_alert('User Created')

    return render_template('users/create.html', configuration=configuration)
示例#4
0
文件: users.py 项目: gadc1996/cali
def update(id):
    configuration = config.Config()
    if request.method == 'POST':
        user = User(request.form)
        user.update_user(id)
        Alert.raise_success_alert('User Updated')

    else:
        user = User.get_user_by_id(id)

    return render_template('users/update.html', user=user, configuration=configuration)
示例#5
0
    def __init__(self, iterable):
        self.userId = iterable['user_id']
        self.clientId = iterable['client_id']
        self.discount = iterable['Discount']
        self.totalArticles = iterable['total_articles']
        self.operationType = iterable['operation_type']
        self.creditTime = iterable['creditTime']

        self.total = Sale._get_total(iterable)
        self.branchId = Sale._get_branch_id(iterable)
        self.recivedCash = Sale._get_recived_cash(iterable)
        self.payMethodId = Sale._get_pay_method_id(iterable)

        self.id = self._get_id()
        self.date = self._get_date()
        self.payMethod = self._get_pay_method()
        self.change = self._get_change()

        self.user = User.get_username_by_id(self.userId)
        self.client = Client.get_name_by_id(self.clientId)
示例#6
0
    def create_txt_report(salesList, salesInformation):
        with open(f'cali/static/reports/sale_report.txt', 'w+') as ticket:
            ticket.write('\n\n     Cali Boutique \n')
            ticket.write('Ave. de la Cantera 9119 \n')
            ticket.write('Plaza Poniente 2do piso. \n')
            ticket.write('(614)184-1424 \n')
            ticket.write('Reporte de Ventas \n')
            ticket.write('------------------------- \n')

            ticket.write(f'Fecha: {salesInformation["date"]} \n')
            ticket.write(
                f'Ventas Totales: {salesInformation["total sales"]} \n')
            ticket.write(f'Ingreso Total: {salesInformation["total"]} \n')
            ticket.write(
                f'Ventas en Efectivo: {salesInformation["cash sales"]} \n')
            ticket.write(
                f'Total Ventas En Efectivo: {salesInformation["total cash sales"]} \n'
            )
            ticket.write(
                f'Ventas Con Tarjeta: {salesInformation["credit card sales"]} \n'
            )
            ticket.write(
                f'Total Ventas Con Tarjeta: {salesInformation["total credit card sales"]} \n'
            )

            ticket.write('------------------------- \n')
            ticket.write('Ventas \n')
            ticket.write('Id|Usuario|Cliente|Fecha|Total \n')

            for sale in salesList:
                user = User.get_user_by_id(sale['user_id'])
                client = Client.get_client_by_id(sale['client_id'])
                ticket.write(
                    f'{sale["id"]}|{user["username"]}|{client["name"]}|{sale["date"]}|{sale["total"]} \n'
                )

            ticket.write('\n\n\n\n')
            return
示例#7
0
    def create_report(salesList, salesInformation):
        pageHeight = (len(salesList) * 10) + 250
        pageWidth = 200
        padding = 20

        c = canvas.Canvas(f'cali/static/reports/sale_report.pdf',
                          pagesize=(pageWidth, pageHeight),
                          bottomup=0)

        c.translate(pageWidth / 2, 20)
        c.setFont('Helvetica-Bold', 8)
        c.drawCentredString(0, 0, 'Cali Boutique')
        c.drawCentredString(0, 10, 'Ave. de la Cantera 9119')
        c.drawCentredString(0, 20, 'Plaza Poniente 2do piso.')
        c.drawCentredString(0, 30, '(614)184-1424')
        c.translate(0, 50)

        c.drawCentredString(0, 0, 'Reporte de Ventas')
        c.drawCentredString(
            0, 10,
            '------------------------------------------------------------')

        c.translate(padding - pageWidth / 2, 20)
        c.drawString(0, 0, f'Fecha: {salesInformation["date"]}')
        c.drawString(0, 10,
                     f'Ventas Totales: {salesInformation["total sales"]}')
        c.drawString(0, 20, f'Ingreso Total: {salesInformation["total"]}')
        c.drawString(0, 30,
                     f'Ventas en Efectivo: {salesInformation["cash sales"]}')
        c.drawString(
            0, 40,
            f'Total Ventas En Efectivo: {salesInformation["total cash sales"]}'
        )
        c.drawString(
            0, 50,
            f'Ventas Con Tarjeta: {salesInformation["credit card sales"]}')
        c.drawString(
            0, 60,
            f'Total Ventas Con Tarjeta: {salesInformation["total credit card sales"]}'
        )

        c.translate(-padding + pageWidth / 2, 80)
        c.drawCentredString(0, 0, 'Ventas')
        c.drawCentredString(
            0, 10,
            '------------------------------------------------------------')

        c.translate(+padding - pageWidth / 2, 20)
        c.drawString(0, 0, 'Id')
        c.drawString(10, 0, f'| Usuario')
        c.drawString(50, 0, f'| Cliente')
        c.drawString(90, 0, f'| Fecha')
        c.drawString(140, 0, f'|  Total')

        for sale in salesList:
            user = User.get_user_by_id(sale['user_id'])
            client = Client.get_client_by_id(sale['client_id'])

            c.translate(0, 10)
            c.drawString(0, 0, f'{sale["id"]}')
            c.drawString(10, 0, f'| {user["username"]} ')
            c.drawString(50, 0, f'| {client["name"]}')
            c.drawString(90, 0, f'| {sale["date"]}')
            c.drawString(140, 0, f'| ${sale["total"]}')

        c.translate(-padding + pageWidth / 2, 0)
        c.drawCentredString(
            0, 10,
            '------------------------------------------------------------')
        c.showPage()
        c.save()
        return
示例#8
0
def load_logged_in_user():
    user_id = session.get('user_id')
    if user_id is None:
        g.user = None
    else:
        g.user = User.get_user_by_id(user_id)
示例#9
0
文件: users.py 项目: gadc1996/cali
def delete(id):
    User.delete_user(id)
    return redirect(url_for('users.search'))