Ejemplo n.º 1
0
def items2():
    title = "Items at Aitken's Electrical"
    form2 = searchData(request.form)
    form3 = contactForm(request.form)
    if form3.submit3.data:
        return redirect('sendMail')
    return render_template('items.html', title=title, form2=form2, form3=form3)
Ejemplo n.º 2
0
def lightingTrunking():
    title = "Lighting Trunking Systems at Aitken's Electrical"
    if g.username:
        return render_template('adminDash.html', username=g.username)
    else:
        form2 = searchData(request.form)
        form3 = contactForm(request.form)
        if form3.submit3.data:
            return redirect('sendMail')
        return render_template('lightingTrunking.html',
                               title=title,
                               form2=form2,
                               form3=form3)
Ejemplo n.º 3
0
def stockist():
    title = "Stockist Page for Aitken's Electrical"
    if g.username:
        return render_template('adminDash.html', username=g.username)
    else:
        form3 = contactForm(request.form)
        form2 = searchData(request.form)
        form = stockistForm(request.form)
        if form3.submit3.data:
            return redirect('sendMail')
        if request.method == 'POST':
            conn = sqlite3.connect('static/data.sqlite')
            c = conn.cursor()
            searchedData = form2.searchData.data
            search = (
                '''SELECT DISTINCT item_name FROM items WHERE item_name LIKE ?'''
            )
            c.execute(search, ['%' + searchedData + '%'])
            rows = c.fetchall()
            if rows:

                for row in rows:
                    print(row)
                    print(rows)
                    results = rows
                    return render_template('search.html',
                                           title=title,
                                           results=results,
                                           form=form,
                                           form2=form2,
                                           form3=form3)
            else:
                error = "Sorry there are no results"
                return render_template('search.html',
                                       title=title,
                                       error=error,
                                       form=form,
                                       form2=form2,
                                       form3=form3)
        return render_template('stockist.html',
                               title=title,
                               form=form,
                               form2=form2,
                               form3=form3)
Ejemplo n.º 4
0
def ChannelSupport():
    title = "Channel Support Systems at Aitken's Electrical"
    form2 = searchData(request.form)
    form3 = contactForm(request.form)
    if form3.submit3.data:
        return redirect('sendMail')
    conn = sqlite3.connect('static/data.sqlite')

    c = conn.cursor()
    search = (
        '''SELECT DISTINCT item_name, model_ref, ImageName FROM items WHERE item_category LIKE ?'''
    )
    c.execute(search, ['Channel Support'])
    heads = c.fetchall()
    print(heads)
    if heads:
        for head in heads:

            print(head)
            c.execute(
                'SELECT DISTINCT item_name, model_number, model_ref, measurement1, value1, measurement2, value2, ImageName FROM items WHERE item_category LIKE (?)',
                (('Channel Support'), ))
            rows = c.fetchall()
            for row in rows:

                results = rows
            return render_template('channelSupport.html',
                                   heads=heads,
                                   results=results,
                                   title=title,
                                   form2=form2,
                                   form3=form3)
    else:
        error = "Sorry there are no results"
        return render_template('channelSupport.html',
                               title=title,
                               error=error,
                               form2=form2,
                               form3=form3)
Ejemplo n.º 5
0
def page_not_found(e):
    form2 = searchData(request.form)
    form3 = contactForm(request.form)
    return render_template('404.html', form3=form3, form2=form2), 404
Ejemplo n.º 6
0
def inspectItem(data):
    form2 = searchData(request.form)
    form3 = contactForm(request.form)
    if form3.submit3.data:
        return redirect('sendMail')
    title = "Aitken's Electrical Item Information"
    conn = sqlite3.connect('static/data.sqlite')
    c = conn.cursor()

    c.execute('SELECT * FROM items WHERE ImageName LIKE (?)', (data, ))
    rows = c.fetchall()
    for row in rows:
        print('here')
        results = rows
        display = "Block"
        measurement = (row[3], row[5], row[7], row[9])
        print(measurement)
        if measurement[1] == "None" or measurement[1] == "":
            display = "none"
            print(display)
        if measurement[2] == "None" or measurement[2] == "":
            display2 = "none"
            print(display2)
        if measurement[3] == "None" or measurement[3] == "":
            display3 = "none"
            print(display3)
            return render_template("inspectItem.html",
                                   display=display,
                                   display2=display2,
                                   display3=display3,
                                   itemName=row[0],
                                   modRef=row[2],
                                   itemRef=row[1],
                                   measurement=measurement,
                                   title=title,
                                   imageRow=row[12],
                                   form2=form2,
                                   form3=form3,
                                   results=results)

    if request.method == 'POST':
        conn = sqlite3.connect('static/data.sqlite')
        c = conn.cursor()
        searchedData = form2.searchData.data
        search = ('''SELECT * FROM items WHERE item_name LIKE (?)''')
        c.execute(search, ['%' + searchedData + '%'])
        rows = c.fetchall()
        if rows:

            for row in rows:
                print(row)
                print(rows)
                results = rows
                return render_template('search.html',
                                       results=results,
                                       title=title,
                                       form3=form3,
                                       form2=form2)
        else:
            error = "Sorry there are no results"
            return render_template('search.html',
                                   error=error,
                                   title=title,
                                   form3=form3,
                                   form2=form2)
    return render_template("inspectItem.html",
                           itemName=data,
                           title=title,
                           form3=form3,
                           form2=form2)
Ejemplo n.º 7
0
def items(search):
    search = search
    print(search)
    title = "Aitken's Electrical Item Results"
    form2 = searchData(request.form)
    form = viewItems(request.form)
    form3 = contactForm(request.form)
    if form3.submit3.data:
        return redirect('sendMail')

    conn = sqlite3.connect('static/data.sqlite')
    c = conn.cursor()

    c.execute(
        'SELECT DISTINCT item_name, ImageName, item_category FROM items WHERE item_category LIKE (?)',
        (search, ))
    rows = c.fetchall()
    if rows:
        for row in rows:
            print(rows)
            results = rows
            return render_template('items.html',
                                   title=title,
                                   heading=row[2],
                                   results=results,
                                   form2=form2,
                                   form3=form3,
                                   form=form)
    else:
        flash("There has been an error, please try again")
        return render_template('items.html',
                               title=title,
                               form2=form2,
                               form3=form3,
                               form=form)

    if request.method == 'POST':
        conn = sqlite3.connect('static/data.sqlite')
        c = conn.cursor()
        searchedData = form2.searchData.data
        search = (
            '''SELECT DISTINCT item_name, ImageName FROM items WHERE item_name LIKE ?'''
        )
        c.execute(search, ['%' + searchedData + '%'])
        rows = c.fetchall()
        if rows:

            for row in rows:
                print(row)
                print(rows)
                results = rows
                return render_template('search.html',
                                       title=title,
                                       results=results,
                                       form3=form3,
                                       form2=form2,
                                       form=form)
        else:
            error = "Sorry there are no results"
            return render_template('search.html',
                                   title=title,
                                   error=error,
                                   form3=form3,
                                   form2=form2,
                                   form=form)
    else:
        flash("There has been an error, please try again")
        return render_template('items.html',
                               form2=form2,
                               title=title,
                               form3=form3,
                               form=form)