"old stable"

This commit is contained in:
Doug Le Tough 2017-10-22 09:01:42 +02:00
parent 954c1e7e10
commit 2e04a88d9a
4 changed files with 86 additions and 17 deletions

BIN
static/images/search.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 371 B

View File

@ -204,9 +204,6 @@ div.block {
border-top-style: solid;
border-top-width: 1px;
height: 20px;
/*
background-color: red;
*/
}
div.inner{
@ -241,17 +238,25 @@ div.block text.num{
div.inner text.edit, div.block text.edit {
background: url(../images/edit.png);
margin: 2px 0px 0px 20px;
}
div.inner text.trash {
background: url(../images/trash.png);
margin: 2px 0px 0px 20px;
}
div.block text.refresh {
background: url(../images/refresh.png);
margin: 2px 0px 0px 20px;
}
div.inner text.edit:hover, div.inner text.trash:hover, div.block text.refresh:hover {
div.block text.search {
background: url(../images/search.png);
margin-left: 275px;
}
div.inner text.edit:hover, div.inner text.trash:hover, div.block text.refresh:hover, div.block text.search:hover{
background-color: #FFB387;
cursor: pointer;
}
@ -265,11 +270,10 @@ div.inner text.edit {
background-repeat: no-repeat;
}
div.inner text.trash, div.inner text.edit, div.block text.refresh {
div.inner text.trash, div.inner text.edit, div.block text.refresh, div.block text.search {
width: 8px;
float:left;
height: 16px;
margin: 2px 0px 0px 20px;
border-radius: 2px;
background-repeat: no-repeat;
}
@ -338,8 +342,9 @@ div.margin_bottom {
}
div.block label.editable {
height: 18px;
height: 20px;
text-align: left;
vertical-align: middle;
padding: 0 4px 0 4px;
}
@ -352,7 +357,7 @@ div.block text.editable {
background-color: #FFFFFF;
border-style: solid;
border-width: 1px;
height: 18px;
height: 20px;
}
div.block select, div.block input {
@ -366,7 +371,7 @@ div.block select, div.block input {
border-width: 1px;
border-color: #555555;
color: #555555;
height: 18px;
height: 20px;
}
div.block input {

View File

@ -23,7 +23,65 @@
{% endblock %}
{% block content %}
<h3>Liste des composants</h3>
<!-- ----------------------------------------------------
Recherche
----------------------------------------------------- -->
<h3>Recherche:</h3>
<div class='block margin_bottom no_border'>
<label class='editable'>Référence (unique)</label>
<input
id='reference'
type='text'
class='editable'
onchange='javascript:search_componant(this, "text");'
maxlength='20'
title='Référence interne unique (max. 20)'
placeholder='Référence interne unique (max. 20)'
value='' />
</div>
<div class='block margin_bottom no_border'>
<label class='editable'>Désignation</label>
<input
id='designation'
type='text'
class='editable'
onchange='javascript:search_componant(this, "text");'
maxlength='50'
title='Désignation (max. 50)'
placeholder='Désignation (max. 50)'
value='' />
</div>
<div class='block margin_bottom no_border'>
<label class='editable'>Emplacement</label>
<input
id='place'
type='text'
class='editable'
onchange='javascript:search_componant(this, "text");'
maxlength='15'
title='Emplacement (max. 15)'
placeholder='Emplacement (max. 15)'
value='' />
</div>
<div class='block margin_bottom no_border'>
<label class='editable'>Fournisseur</label>
<select
id='provider_id'
onchange='javascript:search_componant(this, "numeric");'
title='Fournisseur'>
<option value='0' selected>Tous</option>
{% for prov in providers %}
<option value='prov.id'>{{ prov.name }}</option>
{% endfor %}
</select>
</div>
<div class='block margin_bottom no_border center'>
<text title='Rechercher' class='search' onclick='javascript:search_componant();'></text>
</div>
<!-- ----------------------------------------------------
Resultat
----------------------------------------------------- -->
<h3>Résultat</h3>
<div class='block' style='border-top-style: none;'>
<label onclick='document.location="/componants?offset={{ offset }}&s=reference&o={{ norder }}";'>Référence</label>
<label onclick='document.location="/componants?offset={{ offset }}&s=designation&o={{ norder }}";' class='border_left' style='width: 440px;'>Désignation</label>
@ -39,8 +97,8 @@
<text class='num border_left' style='width: 92px;'>{{ componant.quantity }}</text>
<text class='num border_right border_left' style='width: 152px;'>{{ componant.place }}</text>
<div class='inner' style='width: 95px;'>
<text class='edit' onclick='javascript:document.location="/componants/{{ componant.id }}"'></text>
<text class='trash' onclick='javascript:confirm_delete()?document.location="/componants/delete/{{ componant.id }}":false;'></text>
<text class='edit' title='Éditer' onclick='javascript:document.location="/componants/{{ componant.id }}"'></text>
<text class='trash' title='Supprimer' onclick='javascript:confirm_delete()?document.location="/componants/delete/{{ componant.id }}":false;'></text>
</div>
</div>
{% endfor %}

View File

@ -7,7 +7,7 @@ from flask_sqlalchemy import SQLAlchemy
app = Flask(__name__)
app.config.from_pyfile('config.py')
app.secret_key = app.config.get('446307a5f61c2bb810436b2ee0f903f2')
app.secret_key = '446307a5f61c2bb810436b2ee0f903f2'
app.debug = True
app.static_url_path='/static'
db = SQLAlchemy(app)
@ -61,7 +61,9 @@ def authenticate():
########################################################################
@app.route('/componants', methods=['GET', 'POST'])
def get_componants():
limit = 16
if not session or not session['plop']:
session['plop']='plip'
limit = 8
offset = 0
sort = 'reference'
order = 'asc'
@ -78,6 +80,7 @@ def get_componants():
offset = int(offset)
except ValueError:
offset = 0
providers = Stock_providers.query.order_by(Stock_providers.name).all()
row_count = db.session.query(Stock_componants.id).count()
page_count = int(math.ceil(row_count / float(limit)))
page = int(math.ceil(float(offset + 1) / float(limit)))
@ -95,6 +98,7 @@ def get_componants():
componants = Stock_componants.query.order_by(getattr(Stock_componants, sort).desc()).offset(offset).limit(limit).all()
return render_template('componants.html',
componants=componants,
providers = providers,
offset=offset,
nexthop=nexthop,
prevhop=prevhop,
@ -106,6 +110,7 @@ def get_componants():
@app.route('/componants/<componant_id>')
def get_componant(componant_id):
print session['plop']
try:
componant_id = int(componant_id)
except ValueError as e:
@ -236,8 +241,9 @@ def search_users():
return render_template('wip.html')
##############################################
def get_distinct(query):
# SQL
##############################################
def sql_get_distinct(query):
results = []
for result in query:
result = result[0]
@ -248,4 +254,4 @@ def get_distinct(query):
# Main #######################################
if __name__ == '__main__':
app.run()
app.run(host='0.0.0.0')