Esempio n. 1
0
    def set_data_for(self, main_date):

        try:
            on, end = main_date.current.current
        except:
            on, end = main_date.current
        on = datetime(on.year, on.month, on.day, 0, 0, 0)
        end = datetime(end.year, end.month, end.day, 23, 59, 59)
        reports = []
        this_periode_rpt = Reports.select().where(Reports.date >= on,
                                                  Reports.date <= end)
        for store in Store.select().order_by(Store.name):
            if ([(i) for i in this_periode_rpt.where(Reports.store << [store, ])] == []):
                continue
            cpt = 0
            for prod in Product.select().order_by(Product.name):
                if ([(i) for i in this_periode_rpt.where(Reports.store == store,
                                                         Reports.product << [prod, ])] == []):
                    continue
                dict_store = {}
                repts = this_periode_rpt.where(
                    Reports.store == store, Reports.product == prod)
                dict_store["store"] = store.name if cpt < 1 else ""
                dict_store["product"] = prod.name
                dict_store["sum_qty_in"] = repts.select(
                    peewee.fn.SUM(Reports.qty_use)).where(Reports.type_ == Reports.E).scalar()
                dict_store["sum_qty_out"] = repts.select(
                    peewee.fn.SUM(Reports.qty_use)).where(Reports.type_ == Reports.S).scalar()
                cpt += 1
                reports.append(dict_store)

        self.data = [(rep.get('store'), rep.get('product'), rep.get('sum_qty_in'),
                      rep.get('sum_qty_out')) for rep in reports]
Esempio n. 2
0
def stores_list():
    # create column called 'num' to count how many warehouse is under the given store
    stores = Store.select(Store.name, Store.store_id,
                          fn.COUNT(Warehouse.store_id).alias('count')).join(
                              Warehouse, JOIN.LEFT_OUTER).group_by(
                                  Store.store_id).order_by(Store.name)
    return render_template('stores.html', stores=stores)
Esempio n. 3
0
def destroy_store(store_id):
    store_list = Store.select()

    if request.method == "POST":
        store = Store.get_by_id(store_id)
        flash(f"Closed {store.name}.")
        store.delete_instance()
        return redirect(url_for('index_stores'))
    else:
        return render_template('stores.html', store_list=store_list)
Esempio n. 4
0
def store_info(store_number):
	if request.method == 'POST':
		new_store_name = request.form['new_store_name']
		Store.update({Store.name: new_store_name}).where(Store.id == store_number)
		return redirect(url_for('store/index'))
	else:
		store_id = Store.select().where(Store.id == store_number)
		num_of_wh = True
		for store in store_id:
			num_of_wh = len(list(store.warehouses))
		return render_template('store_page.html', store_id=store_id, num_of_wh=num_of_wh)
def warehouse_create():
    warehouse_location = request.form.get('warehouse_location')
    store_id = request.form.get('store_id')
    warehouse = Warehouse(location=warehouse_location, store=store_id)

    if warehouse.save():
        flash(f"Added Warehouse: {warehouse_location}")
        return redirect(url_for('warehouse_new'))
        #redirect back to the GET app.route('warehouse/new/) to re-render the whole form again#
    else:
        flash('Store already has a warehouse')
        return render_template('warehouse.html', stores=Store.select())
Esempio n. 6
0
def lastes_reports():
    list_rep = []
    for store in Store.select():
        for prod in Product.select():
            try:
                list_rep.append(Reports.filter(deleted=False, store=store,
                                               product=prod)
                                       .order_by(Reports.date.desc()).get())
            except Exception as e:
                # print(e)
                pass
    return list_rep
Esempio n. 7
0
    def refresh_(self, idd):

        self.prod = Product.get(id=idd)
        rest_by_store = ""

        for store in Store.select():
            remaining, nbr_parts = store.get_remaining_and_nb_parts(self.prod)

            if remaining < 10:
                color_style = 'color: DarkGreen'
            if remaining <= 5:
                color_style = 'color: LightCoral'
            if remaining <= 2:
                color_style = 'color: red; text-decoration: blink'
            if remaining >= 10:
                color_style = 'color: LimeGreen;'
            color_style = color_style + \
                "; border:3px solid green; font-size: 15px"
            if Store.select().count() == 1:
                rest_by_store += """ <p><strong style='{color_style}'> {remaining} </strong><i>pièces</i></p>
                """.format(color_style=color_style, remaining=remaining)
            else:
                rest_by_store += """<li> {store}: <strong style='{color_style}'>
                    {nbr_parts} </strong><i>pièces</i> <b>{remaining} </b><i>carton</i>
                    </li>""".format(store=store.name, color_style=color_style, remaining=remaining,
                                    nbr_parts=nbr_parts * remaining)
        width = height = 50
        if self.prod.image_link:
            self.image_btt.setText("Zoom")
            width = 200
            height = 100

        self.info_box.setText(u"""<h2>{name}</h2>
            <h4>Quantité restante:</h4>
            <ul>{remaining}</ul>
            """.format(name=self.prod.name,
                       remaining=rest_by_store))
        self.image.setText("""<img src="{image}" width='{width}'
            height='{height}'>""".format(image=self.prod.image_link,
                                         width=width, height=height))
Esempio n. 8
0
def warehouse():
	if request.method == 'POST':
		store = request.form['store_list']
		location = request.form['warehouse_location']
		new_warehouse = Warehouse.create(location=location, store=store)
		new_warehouse.save()
		flash("Warehouse created", "success")
		return redirect(url_for('warehouse'))
	else:
		# result = Store.select(Store.name, fn.COUNT(Warehouse.store.id == Store.id)).join(Warehouse).group_by(Store.name).where(Store.id == Warehouse.store.id)
		warehouse_list = Warehouse.select()
		store_list = Store.select()
		return render_template('warehouse.html', warehouse_list=warehouse_list, store_list=store_list)
Esempio n. 9
0
    def popup(self, pos):
        row = self.selectionModel().selection().indexes()[0].row()
        if (len(self.data) - 1) < row:
            return False

        self.store = Store.select().where(
            Store.name == self.data[row][0]).get()
        menu = QMenu()
        menu.addAction(QIcon(u"{}edit.png".format(Config.img_cmedia)),
                       u"modifier", lambda: self.prod_edit(self.store))
        menu.addAction(QIcon("{}del.png".format(Config.img_cmedia)),
                       u"supprimer", lambda: self.prod_del(self.store))

        self.action = menu.exec_(self.mapToGlobal(pos))
Esempio n. 10
0
def store():
	# form = forms.Store()
	# store_list = Store.select()
	store_list = Store.select()
	payload = []
	for store in store_list:
		new_object = {
			"store_name": store.name,
			"num": len(list(store.warehouses))
		}
		payload.append(new_object)
	if request.method == 'POST':
		# How to post a success message from form submission if not using flash but using bootstrap under 'store.html' line 5
		# breakpoint()
		new_store = Store(name=request.form['store_name'])
		new_store.save()
		flash("Store created", "success")
		return redirect(url_for('store'), store_list)
	else:
		return render_template('store.html', payload=payload)
Esempio n. 11
0
def shop_index():
    all_stores = Store.select() 
    # store_names = []
    # store_warehouse = []
    # store_details = []
    # store_id = []
    # for i in all_stores: 
    #     arr = [0]
    #     # store_names.append(i.name)
    #     stores_instance = Store.get_by_id(i.id)
    #     for j in stores_instance.warehouses: 
    #         arr.append(j)
    #     store_warehouse.append(len(arr)-1)

    # for j in range(len(store_names)):
    #     store_details.append({store_names[j]: store_warehouse[j]})

    # for k in all_stores:
    #     store_id.append(k.id)

    return render_template('view_all.html', all_stores = all_stores)
Esempio n. 12
0
    def refresh_(self, idd):

        self.prod = Product.get(id=idd)
        self.nameLabel.setText((u"<h4>Article:</h4>"))
        self.name.setText(u"<h6>{name}</h6>".format(name=self.prod.name.title()))
        rest_by_store = ""

        for store in Store.select():
            remaining, nbr_parts = store.get_remaining_and_nb_parts(self.prod)

            if remaining < 10:
                color_style = 'color: DarkGreen'
            if remaining <= 5:
                color_style = 'color: LightCoral'
            if remaining <= 2:
                color_style = 'color: red; text-decoration: blink'
            if remaining >= 10:
                color_style = 'color: LimeGreen;'
            color_style = color_style + "; border:3px solid green; font-size: 15px"

            rest_by_store += u"<div> {store}: <strong style='{color_style}'>" \
                             u" {remaining} </strong> ({nbr_parts} pièces)"\
                             u"</div>".format(store=store.name,
                                              color_style=color_style,
                                              remaining=remaining,
                                              nbr_parts=nbr_parts)

        self.store.setText(u"<h4><u>Quantité restante</u>:</h4> \
                           {remaining}</ul>".format(remaining=rest_by_store))

        self.imagelabel.setText(u"<b>Pas d'image<b>")
        self.image.setStyleSheet("")
        if self.prod.image_link:
            self.imagelabel.setText(u"<b><u>Image</u></b>")
            self.image.setStyleSheet("background: url({image})"
                                     " no-repeat scroll 20px 110px #CCCCCC;"
                                     "width: 55px".format(image=self.prod.image_link))
Esempio n. 13
0
def warehouse_new():
    stores = Store.select()  # to render all store in select options
    return render_template("warehouse_new.html", stores=stores)
Esempio n. 14
0
def multi_store(self):
    return Store.select().count() > 1
Esempio n. 15
0
def index_stores():
    sname = Store.select()
    return render_template('index_stores.html', sname=sname)
Esempio n. 16
0
def warehouse(): 
   store = Store.select()
   return render_template('warehouse.html',store=store)
Esempio n. 17
0
def store_show():
    stores = Store.select()
    warehouses = Warehouse.select()
    return render_template('stores.html', stores=stores, warehouses = warehouses)
Esempio n. 18
0
def warehouse_new():
    stores = Store.select(
    )  # PUT IN HERE AS NEED TO RENDER TEMPLATE, NOT IN WAREHOUSE HTML
    return render_template('warehouse.html', stores=stores)
Esempio n. 19
0
def store_select():
    stores = Store.select()
    warehouse = Warehouse.select()
    return render_template('list_stores.html',
                           stores=stores,
                           warehouse=warehouse)
def stores():
    return render_template('liststores.html',
                           stores=Store.select(),
                           warehouse=Warehouse.select())
Esempio n. 21
0
 def set_data_for(self):
     self.data = [(mag.name, mag.stock_maxi)
                  for mag in Store.select().order_by(Store.id.desc())]
Esempio n. 22
0
def warehouse_new():
    stores = Store.select()
    return render_template('warehouse.html', stores=stores)
Esempio n. 23
0
def show():
    stores = Store.select()
    # stores= Store.select(Store, Warehouse, pw.fn.COUNT(Warehouse.id).filter(Warehouse.store_id == Store.id).alias("w_count")).join(Warehouse, join_type="left outer").group_by(Warehouse.id, Store.id).order_by(Store.id)
    return render_template('store.html', stores=stores)
Esempio n. 24
0
def index():
    all_stores = Store.select()
    return render_template('home.html', stores=all_stores)
Esempio n. 25
0
def show_warehouse():
    stores = Store.select()
    return render_template('warehouse.html', stores=stores)
Esempio n. 26
0
def store_display():
    stores = Store.select()
    return render_template('stores.html', stores=stores)
Esempio n. 27
0
def new_warehouse():
    sname = Store.select()
    # JUST RENDERS WAREHOUSE>HTML
    # pass down sname variable that contains all store names to warehouse.html
    return render_template('warehouse.html', sname=sname)
Esempio n. 28
0
def store():
    store_list = Store.select()
    return render_template('store.html', store_list=store_list)
Esempio n. 29
0
def stores():
    stores = Store.select().order_by(Store.id)
    return render_template('stores.html', stores=stores)
Esempio n. 30
0
def warehouse():
    query = Store.select()
    return render_template('warehouse.html', stores = query )
Esempio n. 31
0
def warehouse():
    stores = Store.select()  #passing stores from the database into the site
    return render_template('warehouse.html', stores=stores)
Esempio n. 32
0
def index_stores():
    store_list = Store.select().order_by(Store.id.asc())
    return render_template('stores.html', store_list=store_list)
Esempio n. 33
0
def show_stores():
    stores = Store.select()  #passing stores from the database into
    warehouses = Warehouse.select()
    return render_template('stores.html', stores=stores, warehouses=warehouses)
Esempio n. 34
0
def new_warehouse():
    store_list = Store.select()
    return render_template('warehouse.html', store_list=store_list)
Esempio n. 35
0
def show_store_list():
    all_store = Store.select()
    return render_template('all-store.html', all_store=all_store)
Esempio n. 36
0
def stores():
    stores = Store.select().order_by(Store.id)
    warehouses = Warehouse.get()
    return render_template('stores.html', stores=stores, warehouses=warehouses)
Esempio n. 37
0
def store_index():
    stores = Store.select()
    return render_template('store_index.html', stores=stores)