Example #1
0
File: app.py Project: kikutou/tenso
def customer():

    customers = Customer(app).getCustomers()

    return render_template('customer.html',
                           title=unicode("顾客信息", 'utf-8'),
                           customersData=customers)
Example #2
0
File: app.py Project: kikutou/tenso
def outboxInboxSelectConfirm():

    if request.method == 'POST':
        inboxId = request.form['inbox_id']
        customerId = request.form['customer_id']

        data = {'status': 1}

        result = Inbox(app).saveInboxData(int(inboxId), data)
        if result:
            return redirect("outboxIndex?id=" + inboxId + '&customer_id=' +
                            customerId)
        else:
            error = '入库箱选择失败'

    else:

        inboxId = request.args.get('id')
        customerId = request.args.get('customer_id')

    customer = Customer(app).getCustomer(int(customerId))

    inboxData = Inbox(app).getInboxData(int(inboxId))

    if inboxData['status'] == 1:
        return redirect("outboxIndex?customer_id=" + customerId)

    return render_template('outboxInboxSelectConfirm.html',
                           title=unicode("入库箱选择确认", 'utf-8'),
                           customer=customer,
                           inboxData=inboxData)
Example #3
0
File: app.py Project: kikutou/tenso
def outboxCustomerSelect():

    customers = Customer(app).getCustomers()

    return render_template('outboxCustomerSelect.html',
                           title=unicode("出库箱信息-顾客选择", 'utf-8'),
                           data=customers)
Example #4
0
def customer():
    if 'customer' not in request.json:
        response = jsonify(message='Fields customer are mandatory')
        response.status_code = 400
        return response
    conn = mysql.connect()
    cursor = conn.cursor()
    customer = request.json["customer"]
    c_c = Customer.check_customers(cursor, customer)
    if (c_c == True):
        Customer.send_customer_to_db(cursor, customer, conn)
        return jsonify({'status': 'request done'})
    else:
        return jsonify({'status': 'request failed'})
    cursor.close()
    conn.close()
Example #5
0
File: app.py Project: kikutou/tenso
def adminCustomerEdit():

    error = None
    if request.method == 'POST':

        customer = request.form['id']

        name = request.form['name']
        real_name = request.form['real_name']
        address = request.form['address']
        telephone1 = request.form['telephone1']
        telephone2 = request.form['telephone2']
        email = request.form['email']
        id_card_no = request.form['id_card_no']
        company_name = request.form['company_name']
        company_address = request.form['company_address']
        company_telephone = request.form['company_telephone']
        data = {
            'name': name,
            'real_name': real_name,
            'address': address,
            'telephone1': telephone1,
            'telephone2': telephone2,
            'email': email,
            'id_card_no': id_card_no,
            'company_name': company_name,
            'company_address': company_address,
            'company_telephone': company_telephone
        }

        result = Customer(app).updateCustomer(data, int(customer))
        if result:
            flash('顾客信息更新成功')
            return redirect('/adminCustomer')
        else:
            error = '顾客信息更新失败'
    else:

        customer_id = request.args.get('id')

        customer = Customer(app).getCustomer(int(customer_id))

    return render_template('adminCustomerEdit.html',
                           title=unicode('顾客信息编辑', 'utf-8'),
                           customer=customer,
                           error=error)
Example #6
0
File: app.py Project: kikutou/tenso
def adminCustomerAdd():

    error = None
    if request.method == 'POST':

        name = request.form['name']
        real_name = request.form['real_name']
        address = request.form['address']
        telephone1 = request.form['telephone1']
        telephone2 = request.form['telephone2']
        email = request.form['email']
        id_card_no = request.form['id_card_no']
        company_name = request.form['company_name']
        company_address = request.form['company_address']
        company_telephone = request.form['company_telephone']
        data = {
            'name': name,
            'real_name': real_name,
            'address': address,
            'telephone1': telephone1,
            'telephone2': telephone2,
            'email': email,
            'id_card_no': id_card_no,
            'company_name': company_name,
            'company_address': company_address,
            'company_telephone': company_telephone
        }

        result = Customer(app).insertCustomer(data)
        if result:
            flash('顾客信息更新成功')
            return redirect('/adminCustomer')
        else:
            error = '顾客信息更新失败'

    customers = Customer(app).getCustomers()
    staffs = Staff(app).getStaffs()

    return render_template('adminCustomerAdd.html',
                           title=unicode('顾客信息追加', 'utf-8'),
                           customers=customers,
                           staffs=staffs,
                           error=error)
Example #7
0
File: app.py Project: kikutou/tenso
def adminCustomer():

    error = None

    customer = Customer(app).getCustomers()
    if customer == 0:
        error = "can not found the customer datas!"

    return render_template('adminCustomerList.html',
                           title=unicode("客户管理", 'utf-8'),
                           error=error,
                           viewCustomer=customer)
Example #8
0
File: app.py Project: kikutou/tenso
def adminOutboxEdit():

    error = None
    if request.method == 'POST':

        outboxId = request.form['id']

        customer_id = request.form['customer_id']
        staff_id = request.form['staff_id']
        name = request.form['name']
        memo = request.form['memo']
        length = request.form['length']
        width = request.form['width']
        height = request.form['height']
        weight = request.form['weight']
        status = request.form['status']
        data = {
            'name': name,
            'memo': memo,
            'length': length,
            'width': width,
            'height': height,
            'weight': weight,
            'customer_id': customer_id,
            'staff_id': staff_id,
            'status': status
        }

        result = Outbox(app).saveOutboxData(int(outboxId), data)
        if result:
            flash('出库箱更新成功')
            return redirect('/adminOutbox')
        else:
            error = '出库箱更新失败'
    else:

        outboxId = request.args.get('id')

    outboxData = Outbox(app).getOutboxData(int(outboxId))
    customers = Customer(app).getCustomers()
    staffs = Staff(app).getStaffs()

    return render_template('adminOutboxEdit.html',
                           title=unicode('出库箱追加', 'utf-8'),
                           customers=customers,
                           staffs=staffs,
                           outbox=outboxData,
                           error=error)
Example #9
0
File: app.py Project: kikutou/tenso
def outboxInfo():

    error = None

    outboxId = request.args.get('id')
    source = request.args.get('source')

    outbox = Outbox(app).getOutboxData(int(outboxId))

    customerId = outbox['customer_id']

    customer = Customer(app).getCustomer(int(customerId))

    relOutItems = RelOutItem(app).getRelOutItems({'out_box_id': outboxId})

    items = []

    for key, relOutItem in relOutItems.items():
        itemId = relOutItem['item_id']
        itemNum = relOutItem['item_num']

        item = Item(app).getItem(int(itemId))
        itemNameJp = item['jp_name']
        itemNameEn = item['en_name']
        itemNameCn = item['cn_name']
        itemPrice = item['unit_price']
        jancode = item['jan_code']

        data = {
            'id': itemId,
            'item_num': itemNum,
            'jp_name': itemNameJp,
            'en_name': itemNameEn,
            'cn_name': itemNameCn,
            'jan_code': jancode,
            'unit_price': itemPrice
        }

        items.append(data)

    return render_template('outboxInfo.html',
                           title=unicode("出库箱详细", 'utf-8'),
                           error=error,
                           outbox=outbox,
                           customer=customer,
                           items=items,
                           source=source)
Example #10
0
File: app.py Project: kikutou/tenso
def inboxIndex():

    id = request.args.get('id')
    customer = Customer(app).getCustomer(int(id))

    inboxData = Inbox(app).getInboxesByCustomerId(int(id))

    inboxData = {
        key: record
        for key, record in inboxData.iteritems()
        if record['status'] == 0 or record['status'] == 1
    }

    return render_template('inboxIndex.html',
                           title=unicode("入库箱信息", 'utf-8'),
                           customer=customer,
                           inboxData=inboxData)
Example #11
0
File: app.py Project: kikutou/tenso
def outboxInboxSelect():

    customerId = request.args.get('id')

    customer = Customer(app).getCustomer(int(customerId))

    inboxData = Inbox(app).getInboxesByCustomerId(int(customerId))

    inboxData = {
        key: record
        for key, record in inboxData.iteritems()
        if record['status'] == 0 or record['status'] == 1
    }

    return render_template('outboxInboxSelect.html',
                           title=unicode("选择入库箱", 'utf-8'),
                           customer=customer,
                           inboxData=inboxData)
Example #12
0
File: app.py Project: kikutou/tenso
def outboxIndex():

    customerId = request.args.get('customer_id')

    customer = Customer(app).getCustomer(int(customerId))

    inboxArray = Inbox(app).getInboxDatas({'status': 1})

    outboxData = Outbox(app).getOutboxesByCustomerId(int(customerId))
    outboxData = {
        key: record
        for key, record in outboxData.iteritems()
        if record['status'] == 0 or record['status'] == 1
    }

    return render_template('outboxIndex.html',
                           title=unicode("出库箱信息", 'utf-8'),
                           customer=customer,
                           inboxArray=inboxArray,
                           outboxData=outboxData)
Example #13
0
File: app.py Project: kikutou/tenso
def adminInboxAdd():

    error = None
    if request.method == 'POST':

        customer_id = request.form['customer_id']
        staff_id = request.form['staff_id']
        name = request.form['name']
        memo = request.form['memo']
        length = request.form['length']
        width = request.form['width']
        height = request.form['height']
        weight = request.form['weight']
        status = request.form['status']
        data = {
            'name': name,
            'memo': memo,
            'length': length,
            'width': width,
            'height': height,
            'weight': weight,
            'customer_id': customer_id,
            'staff_id': staff_id,
            'status': status
        }

        result = Inbox(app).addInbox(data)
        if result:
            flash('入库箱更新成功')
            return redirect('/adminInbox')
        else:
            error = '入库箱更新失败'

    customers = Customer(app).getCustomers()
    staffs = Staff(app).getStaffs()

    return render_template('adminInboxAdd.html',
                           title=unicode('入库箱追加', 'utf-8'),
                           customers=customers,
                           staffs=staffs,
                           error=error)
Example #14
0
File: app.py Project: kikutou/tenso
def itemAddSuccess():

    error = None

    if request.method == 'POST':
        inboxId = request.form['inbox_id']
        outboxId = request.form['outbox_id']

        if inboxId and not outboxId:
            Inbox(app).saveInboxData(int(inboxId), {'status': 2})
        elif not inboxId and outboxId:
            Outbox(app).saveOutboxData(int(outboxId), {'status': 1})
        else:
            error = '未知错误'

    inboxes = Inbox(app).getInboxDatas({
        'status': 1,
        'staff_id': session.get('staff_id')
    })

    if inboxes:
        inbox = inboxes[0]
        customerId = inbox['customer_id']
        customer = Customer(app).getCustomer(int(customerId))
        if not customer:
            error = '没有找到相应的顾客信息'

    outboxes = Outbox(app).getOutboxDatas({
        'status': 0,
        'staff_id': session.get('staff_id')
    })

    return render_template('itemAddSuccess.html',
                           title=unicode("货物添加成功", 'utf-8'),
                           error=error,
                           inboxes=inboxes,
                           customer=customer,
                           outboxes=outboxes)
Example #15
0
File: app.py Project: kikutou/tenso
def customerDelete():

    error = None

    if request.method == 'POST':
        id = request.form['id']

        data = {'delete_flag': 1}

        result = Customer(app).updateCustomer(data, int(id))
        if result:
            flash(unicode('顾客删除成功', 'utf-8'))
            return redirect("customer")
        else:
            error = unicode('顾客删除失败', 'utf-8')

    else:

        id = request.args.get('id')

    return render_template('customerDelete.html',
                           title=unicode("确定删除", 'utf-8'),
                           id=id,
                           error=error)
Example #16
0
File: app.py Project: kikutou/tenso
def removeItem():

    error = None

    if request.method == 'POST':
        srcOutbox = request.form['src_outbox']
        desOutbox = request.form['des_outbox']
        itemId = request.form['item_id']
        num = request.form['number']
        '''
        ①移動する数目をチェックする
        ②元のoutboxから、数目を更新
            全部移動する場合、元のレコードを削除
            一部移動する場合、数目を更新する
        ③移動先のoutboxの数目を更新
            すでにある場合、数目を増加して、更新する
            なければ、新規追加

        '''
        #①移動する数目をチェックする
        relOutItem = RelOutItem(app).getRelOutItem({
            'out_box_id': srcOutbox,
            'item_id': itemId
        })
        oldNum = relOutItem['item_num']
        if int(num) > int(oldNum):
            error = '移动数目不正确,请重新输入'

        if not error:
            #②元のoutboxから、数目を更新
            if int(num) == int(oldNum):
                RelOutItem(app).saveRelOutItem(int(relOutItem['id']),
                                               {'delete_flag': 1})
            else:
                leftNum = int(oldNum) - int(num)
                RelOutItem(app).saveRelOutItem(int(relOutItem['id']),
                                               {'item_num': leftNum})

            #移動先のoutboxの数目を更新
            desRelOutItem = RelOutItem(app).getRelOutItem({
                'out_box_id': desOutbox,
                'item_id': itemId
            })
            if desRelOutItem:
                #すでにある場合、数目を増加して、更新する
                newNum = int(desRelOutItem['item_num']) + int(num)
                RelOutItem(app).saveRelOutItem(int(desRelOutItem['id']),
                                               {'item_num': newNum})
            else:
                data = {
                    'check_time':
                    datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S'),
                    'out_box_id':
                    desOutbox,
                    'item_id':
                    itemId,
                    'item_num':
                    num
                }
                RelOutItem(app).addRelOutItem(data)

            flash('货物移动成功')

            return redirect('/outboxInfo?id=' + srcOutbox)

    customerId = request.args.get('customer_id')
    outboxId = request.args.get('outbox_id')
    itemId = request.args.get('item_id')

    customer = Customer(app).getCustomer(int(customerId))
    outbox = Outbox(app).getOutboxData(int(outboxId))
    item = Item(app).getItem(int(itemId))
    relOutItem = RelOutItem(app).getRelOutItems({
        'out_box_id': outboxId,
        'item_id': item['id']
    })

    outboxes = Outbox(app).getOutboxDatas({
        'status': 0,
        'staff_id': session.get('staff_id'),
        'customer_id': customerId
    })

    return render_template('removeItem.html',
                           title=unicode("出库箱详细", 'utf-8'),
                           error=error,
                           outbox=outbox,
                           customer=customer,
                           item=item,
                           relOutItem=relOutItem,
                           outboxes=outboxes)
Example #17
0
File: app.py Project: kikutou/tenso
def customerEdit():

    error = None

    if request.method == 'POST':

        id = request.form['id']

        name = request.form['name']
        real_name = request.form['real_name']
        address = request.form['address']
        telephone1 = request.form['telephone1']
        telephone2 = request.form['telephone2']
        email = request.form['email']
        company_name = request.form['company_name']
        company_address = request.form['company_address']
        company_telephone = request.form['company_telephone']
        try:
            if request.form['id_confirmed_flag']:
                id_confirmed_flag = 1

        except:
            id_confirmed_flag = 0

        id_card_no = request.form['id_card_no']

        data = {
            'name': name,
            'real_name': real_name,
            'address': address,
            'telephone1': telephone1,
            'telephone2': telephone2,
            'email': email,
            'company_name': company_name,
            'company_address': company_address,
            'company_telephone': company_telephone,
            'id_confirmed_flag': id_confirmed_flag,
            'id_card_no': id_card_no,
        }

        now_time = datetime.datetime.now().strftime("%Y%m%d%H%M%S")

        id_card_pic_front = request.files['id_card_pic_front']
        id_card_pic_back = request.files['id_card_pic_back']

        if id_card_pic_front and allowed_file(id_card_pic_front.filename):
            filename = secure_filename(id_card_pic_front.filename)
            save_file_name = now_time + '_id_card_pic_front_' + filename
            data['id_card_pic_front'] = "/static/img/" + save_file_name
            id_card_pic_front.save(
                os.path.join(app.config['UPLOAD_FOLDER'], save_file_name))

        if id_card_pic_back and allowed_file(id_card_pic_back.filename):
            filename = secure_filename(id_card_pic_back.filename)
            save_file_name = now_time + '_id_card_pic_back_' + filename
            data['id_card_pic_back'] = "/static/img/" + save_file_name
            id_card_pic_back.save(
                os.path.join(app.config['UPLOAD_FOLDER'], save_file_name))

        result = Customer(app).updateCustomer(data, int(id))

        if result:
            flash(unicode('顾客编辑成功', 'utf-8'))
            return redirect("customer")
        else:
            error = unicode('顾客编辑失败', 'utf-8')

    else:
        id = request.args.get('id')

    customer = Customer(app).getCustomer(int(id))

    return render_template('customerAdd.html',
                           title=unicode("顾客信息", 'utf-8'),
                           data=customer,
                           error=error)
Example #18
0
def booking():
    if not request.json["customer"] or not request.json["hotels"] or not request.json["rooms"] \
            or not request.json["booking_order"] or not request.json["booking_order_info"] or not request.json["equipment"] \
            or not request.json["booking_order_equipment"] or not request.json["cost_modulation"]:
        response = jsonify(
            message=
            'Fields customer, hotels, rooms, booking_order, booking_order_info, equipment, booking_order_equipment, cost_modulation are mandatory'
        )
        response.status_code = 400
        return response
    #connection to mysql
    conn = mysql.connect()
    cursor = conn.cursor()

    #request.json to object
    customer = request.json["customer"]
    hotels = request.json["hotels"]
    booking_order = request.json['booking_order']
    rooms = request.json['rooms']
    booking_order_info = request.json['booking_order_info']
    booking_order_equipment = request.json['booking_order_equipment']
    equipment = request.json['equipment']
    cost_modulation = request.json['cost_modulation']

    c_c = Customer.check_not_customers(cursor, customer)
    if c_c == True:
        Customer.send_customer_to_db(cursor, customer, conn)
    id_customer = Customer.get_customer_id(cursor, customer)
    c_h = Hotel.check_hotels(cursor, hotels)
    if c_h == True:
        return jsonify({'status': 'no hotel found, take again your booking'})
    id_hotel = Hotel.get_id_hotel(cursor, hotels)
    '''c_b_o = BookingOrder.check_not_booking_order(cursor, booking_order, id_customer)
    print("ici")
    print(c_b_o)
    if c_b_o == True:
        print("in it")'''
    BookingOrder.send_booking_order(id_customer, booking_order, cursor, conn)

    id_booking_order = BookingOrder.get_id_booking_order(
        cursor, booking_order, id_customer)
    id_rooms = Rooms.get_id_rooms(cursor, rooms, id_hotel)
    c_b_o_i = BookingOrderInfo.check_not_booking_order_info(id_rooms, cursor)
    if c_b_o_i == True:
        BookingOrderInfo.send_booking_order_info(id_booking_order, id_rooms,
                                                 booking_order_info, cursor,
                                                 conn)
    print(id_hotel)
    print(equipment)
    id_equipment = Equipment.get_id_equipment(cursor, equipment, id_hotel)
    c_b_o_e = BookingOrderEquipment.check_not_booking_order_equipment(
        cursor, id_equipment)
    if c_b_o_e == True:
        BookingOrderEquipment.send_booking_order_equipment(
            id_booking_order, id_equipment, booking_order_equipment, cursor,
            conn)

    id_booking_order_info = BookingOrderInfo.get_id_booking_order_info(
        cursor, id_booking_order)
    id_booking_order_equipment = BookingOrderEquipment.get_id_booking_order_equipment(
        cursor, id_booking_order)
    CostModulation.reduction_compute(cursor, cost_modulation, id_hotel,
                                     id_rooms, conn, id_booking_order)

    #sending email
    Email.send_confirmation_email(cursor, id_customer, id_hotel,
                                  id_booking_order, id_booking_order_info,
                                  id_booking_order_equipment)

    cursor.close()
    conn.close()
    return "end"