ajout changement statut devis
This commit is contained in:
@@ -18,8 +18,9 @@ pyramid.includes =
|
|||||||
pyramid_mailer
|
pyramid_mailer
|
||||||
pyramid_tm
|
pyramid_tm
|
||||||
|
|
||||||
|
|
||||||
sqlalchemy.url = mysql://phuoc:phuoc!@localhost/bddevfac?charset=utf8
|
sqlalchemy.url = mysql://phuoc:phuoc!@localhost/bddevfac?charset=utf8
|
||||||
|
#sqlalchemy.url = mysql://phuoc:phuoc!@192.168.1.17/bddevfac?charset=utf8
|
||||||
# sqlalchemy.url = mysql://phuoc:phuoc!@192.168.0.31/bddevfac?charset=utf8
|
# sqlalchemy.url = mysql://phuoc:phuoc!@192.168.0.31/bddevfac?charset=utf8
|
||||||
|
|
||||||
mondumas.admin_email = cao.thien-phuoc@orange.fr
|
mondumas.admin_email = cao.thien-phuoc@orange.fr
|
||||||
|
|||||||
@@ -1,228 +1,236 @@
|
|||||||
# -*- coding: utf8 -*-
|
# -*- coding: utf8 -*-
|
||||||
from sqlalchemy import text
|
from sqlalchemy import text
|
||||||
from sqlalchemy.ext.declarative import declarative_base
|
from sqlalchemy.ext.declarative import declarative_base
|
||||||
from sqlalchemy.orm import (
|
from sqlalchemy.orm import (
|
||||||
scoped_session,
|
scoped_session,
|
||||||
sessionmaker,
|
sessionmaker,
|
||||||
)
|
)
|
||||||
from zope.sqlalchemy import (
|
from zope.sqlalchemy import (
|
||||||
ZopeTransactionExtension,
|
ZopeTransactionExtension,
|
||||||
mark_changed
|
mark_changed
|
||||||
)
|
)
|
||||||
|
|
||||||
from datetime import *
|
from datetime import *
|
||||||
import transaction
|
import transaction
|
||||||
import os
|
import os
|
||||||
|
|
||||||
from ..views.default import (
|
from ..views.default import (
|
||||||
to_int,
|
to_int,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def execute_query(request, query, params):
|
def execute_query(request, query, params):
|
||||||
"""Execute query and mark session as changed"""
|
"""Execute query and mark session as changed"""
|
||||||
request.dbsession.execute(query, params)
|
request.dbsession.execute(query, params)
|
||||||
mark_changed(request.dbsession)
|
mark_changed(request.dbsession)
|
||||||
transaction.commit()
|
transaction.commit()
|
||||||
|
|
||||||
def get_devis_byName(request, societe, name):
|
def get_devis_byName(request, societe, name):
|
||||||
numero = to_int(name)
|
numero = to_int(name)
|
||||||
|
|
||||||
if numero > 0:
|
if numero > 0:
|
||||||
query = """SELECT date,'DE' AS TYPE, LPAD(no_id,6,'0') AS numero, nomcli, CONCAT(c_nom,'; ',c_adr,'; ',c_ville) AS chantier, COALESCE(totalht,0) AS montant, status, nosin, nopol, nochantier, web
|
query = """SELECT date,'DE' AS TYPE, LPAD(no_id,6,'0') AS numero, nomcli, CONCAT(c_nom,'; ',c_adr,'; ',c_ville) AS chantier, COALESCE(totalht,0) AS montant, status, nosin, nopol, nochantier, web
|
||||||
FROM devis WHERE societe=:societe AND no_id >=:name AND web = 'W' LIMIT 300;;""" % (societe, name)
|
FROM devis WHERE societe=:societe AND no_id >=:name AND web = 'W' LIMIT 300;;""" % (societe, name)
|
||||||
elif len(name) == 0:
|
elif len(name) == 0:
|
||||||
query = """SELECT date,'DE' AS TYPE, LPAD(no_id,6,'0') AS numero, nomcli, CONCAT(c_nom,'; ',c_adr,'; ',c_ville) AS chantier, COALESCE(totalht,0) AS montant, status, nosin, nopol, nochantier, web
|
query = """SELECT date,'DE' AS TYPE, LPAD(no_id,6,'0') AS numero, nomcli, CONCAT(c_nom,'; ',c_adr,'; ',c_ville) AS chantier, COALESCE(totalht,0) AS montant, status, nosin, nopol, nochantier, web
|
||||||
FROM devis WHERE societe=:societe AND web = 'W' ORDER BY no_id DESC LIMIT 300;"""
|
FROM devis WHERE societe=:societe AND web = 'W' ORDER BY no_id DESC LIMIT 300;"""
|
||||||
else:
|
else:
|
||||||
query = """(SELECT date,'DE' AS TYPE, LPAD(no_id,6,'0') AS numero, nomcli, CONCAT(c_nom,'; ',c_adr,'; ',c_ville) AS chantier, COALESCE(totalht,0) AS montant, status, nosin, nopol , nochantier, web
|
query = """(SELECT date,'DE' AS TYPE, LPAD(no_id,6,'0') AS numero, nomcli, CONCAT(c_nom,'; ',c_adr,'; ',c_ville) AS chantier, COALESCE(totalht,0) AS montant, status, nosin, nopol , nochantier, web
|
||||||
FROM devis WHERE societe=:societe AND c_nom LIKE ':name%' AND web = 'W' LIMIT 500)"""
|
FROM devis WHERE societe=:societe AND c_nom LIKE ':name%' AND web = 'W' LIMIT 500)"""
|
||||||
results = request.dbsession.execute(query, {'societe': societe, 'name': name}).fetchall()
|
results = request.dbsession.execute(query, {'societe': societe, 'name': name}).fetchall()
|
||||||
return results
|
return results
|
||||||
|
|
||||||
def get_devfac_by_no(request,nodossier):
|
def get_devfac_by_no(request,nodossier):
|
||||||
# lire devis, facture ou proforma
|
# lire devis, facture ou proforma
|
||||||
|
|
||||||
societe = nodossier[0:2]
|
societe = nodossier[0:2]
|
||||||
type_doc = nodossier[3:5]
|
type_doc = nodossier[3:5]
|
||||||
no_id = nodossier[5:]
|
no_id = nodossier[5:]
|
||||||
|
|
||||||
if type_doc == 'DE':
|
if type_doc == 'DE':
|
||||||
query = """
|
query = """
|
||||||
SELECT d.*, c.*, a.NOM as nom_cabinet, e.NOM as nom_expert FROM devis d
|
SELECT d.*, c.*, a.NOM as nom_cabinet, e.NOM as nom_expert FROM devis d
|
||||||
INNER JOIN clients c ON d.societe = c.societe and d.cd_cli = c.cd_cli
|
INNER JOIN clients c ON d.societe = c.societe and d.cd_cli = c.cd_cli
|
||||||
INNER JOIN p_cabinet a ON d.cabinet = a.code
|
INNER JOIN p_cabinet a ON d.cabinet = a.code
|
||||||
INNER JOIN p_experts e ON d.cabinet = e.code_cab and d.expert = e.code_exp
|
INNER JOIN p_experts e ON d.cabinet = e.code_cab and d.expert = e.code_exp
|
||||||
WHERE d.societe = :societe and d.no_id=:no_id;"""
|
WHERE d.societe = :societe and d.no_id=:no_id;"""
|
||||||
elif type_doc == 'FA':
|
elif type_doc == 'FA':
|
||||||
query = """
|
query = """
|
||||||
SELECT d.*, c.*, a.NOM as nom_cabinet, e.NOM as nom_expert FROM facture d
|
SELECT d.*, c.*, a.NOM as nom_cabinet, e.NOM as nom_expert FROM facture d
|
||||||
INNER JOIN clients c ON d.societe = c.societe and d.cd_cli = c.cd_cli
|
INNER JOIN clients c ON d.societe = c.societe and d.cd_cli = c.cd_cli
|
||||||
INNER JOIN p_cabinet a ON d.cabinet = a.code
|
INNER JOIN p_cabinet a ON d.cabinet = a.code
|
||||||
INNER JOIN p_experts e ON d.cabinet = e.code_cab and d.expert = e.code_exp
|
INNER JOIN p_experts e ON d.cabinet = e.code_cab and d.expert = e.code_exp
|
||||||
WHERE d.societe = :societe and d.no_id=:no_id;"""
|
WHERE d.societe = :societe and d.no_id=:no_id;"""
|
||||||
else:
|
else:
|
||||||
query = """
|
query = """
|
||||||
SELECT d.*, c.*, a.NOM as nom_cabinet, e.NOM as nom_expert FROM proforma d
|
SELECT d.*, c.*, a.NOM as nom_cabinet, e.NOM as nom_expert FROM proforma d
|
||||||
INNER JOIN clients c ON d.societe = c.societe and d.cd_cli = c.cd_cli
|
INNER JOIN clients c ON d.societe = c.societe and d.cd_cli = c.cd_cli
|
||||||
INNER JOIN p_cabinet a ON d.cabinet = a.code
|
INNER JOIN p_cabinet a ON d.cabinet = a.code
|
||||||
INNER JOIN p_experts e ON d.cabinet = e.code_cab and d.expert = e.code_exp
|
INNER JOIN p_experts e ON d.cabinet = e.code_cab and d.expert = e.code_exp
|
||||||
WHERE d.societe = :societe and d.no_id=:no_id;"""
|
WHERE d.societe = :societe and d.no_id=:no_id;"""
|
||||||
|
|
||||||
results = request.dbsession.execute(query, {'societe': societe, 'no_id': no_id}).first()
|
results = request.dbsession.execute(query, {'societe': societe, 'no_id': no_id}).first()
|
||||||
return results
|
return results
|
||||||
|
|
||||||
def get_devis_lig_by_no(request,nodossier):
|
def get_devis_lig_by_no(request,nodossier):
|
||||||
|
|
||||||
societe = nodossier[0:2]
|
societe = nodossier[0:2]
|
||||||
type_doc = nodossier[3:5]
|
type_doc = nodossier[3:5]
|
||||||
no_id = nodossier[5:]
|
no_id = nodossier[5:]
|
||||||
|
|
||||||
if type_doc == 'DE':
|
if type_doc == 'DE':
|
||||||
query = "SELECT * FROM devis_lig WHERE societe = :societe and no_id=:no_id;"
|
query = "SELECT * FROM devis_lig WHERE societe = :societe and no_id=:no_id;"
|
||||||
elif type_doc == 'FA':
|
elif type_doc == 'FA':
|
||||||
query = "SELECT * FROM facture_lig WHERE societe = :societe and no_id=:no_id;"
|
query = "SELECT * FROM facture_lig WHERE societe = :societe and no_id=:no_id;"
|
||||||
else:
|
else:
|
||||||
query = "SELECT * FROM proforma_lig WHERE societe = :societe and no_id=:no_id;"
|
query = "SELECT * FROM proforma_lig WHERE societe = :societe and no_id=:no_id;"
|
||||||
|
|
||||||
results = request.dbsession.execute(query, {'societe': societe, 'no_id': no_id}).fetchall()
|
results = request.dbsession.execute(query, {'societe': societe, 'no_id': no_id}).fetchall()
|
||||||
return results
|
return results
|
||||||
|
|
||||||
def get_devis_lignes_by_no(request, nodossier, nolig):
|
def get_devis_lignes_by_no(request, nodossier, nolig):
|
||||||
societe = nodossier[0:2]
|
societe = nodossier[0:2]
|
||||||
type_doc = nodossier[3:5]
|
type_doc = nodossier[3:5]
|
||||||
no_id = nodossier[5:]
|
no_id = nodossier[5:]
|
||||||
|
|
||||||
if nolig == '0':
|
if nolig == '0':
|
||||||
query = "SELECT * FROM devis_lignes WHERE societe = :societe and no_id=:no_id;"
|
query = "SELECT * FROM devis_lignes WHERE societe = :societe and no_id=:no_id;"
|
||||||
results = request.dbsession.execute(query, {'societe': societe, 'no_id': no_id}).fetchall()
|
results = request.dbsession.execute(query, {'societe': societe, 'no_id': no_id}).fetchall()
|
||||||
else:
|
else:
|
||||||
query = "SELECT * FROM devis_lignes WHERE societe = :societe and no_id=:no_id and nolig=:nolig;"
|
query = "SELECT * FROM devis_lignes WHERE societe = :societe and no_id=:no_id and nolig=:nolig;"
|
||||||
results = request.dbsession.execute(query, {'societe': societe, 'no_id': no_id, 'nolig': nolig}).first()
|
results = request.dbsession.execute(query, {'societe': societe, 'no_id': no_id, 'nolig': nolig}).first()
|
||||||
return results
|
return results
|
||||||
|
|
||||||
|
|
||||||
def insert_devis_from_dossier(request, nodossier, logged_in):
|
def insert_devis_from_dossier(request, nodossier, logged_in):
|
||||||
societe = nodossier[0:2]
|
societe = nodossier[0:2]
|
||||||
no_id = nodossier[3:]
|
no_id = nodossier[3:]
|
||||||
|
|
||||||
query = "CALL spINS_DEVIS_FROM_DOSSIER(:societe, 'DDW', :no_id, :logged_in);"
|
query = "CALL spINS_DEVIS_FROM_DOSSIER(:societe, 'DDW', :no_id, :logged_in);"
|
||||||
results = request.dbsession.execute(query,{'societe': societe, 'no_id': no_id, 'logged_in': logged_in}).first()
|
results = request.dbsession.execute(query,{'societe': societe, 'no_id': no_id, 'logged_in': logged_in}).first()
|
||||||
return results
|
return results
|
||||||
|
|
||||||
def get_devis_by_no(request,nodossier):
|
def get_devis_by_no(request,nodossier):
|
||||||
# lire devis, facture ou proforma
|
# lire devis, facture ou proforma
|
||||||
|
|
||||||
societe = nodossier[0:2]
|
societe = nodossier[0:2]
|
||||||
no_id = nodossier[5:]
|
no_id = nodossier[5:]
|
||||||
|
|
||||||
query = """
|
query = """
|
||||||
SELECT d.*, c.*, a.NOM as nom_cabinet, e.NOM as nom_expert FROM devis d
|
SELECT d.*, c.*, s.libelle, a.NOM as nom_cabinet, e.NOM as nom_expert FROM devis d
|
||||||
INNER JOIN clients c ON d.societe = c.societe and d.cd_cli = c.cd_cli
|
INNER JOIN clients c ON d.societe = c.societe and d.cd_cli = c.cd_cli
|
||||||
INNER JOIN p_cabinet a ON d.cabinet = a.code
|
INNER JOIN p_cabinet a ON d.cabinet = a.code
|
||||||
INNER JOIN p_experts e ON d.cabinet = e.code_cab and d.expert = e.code_exp
|
INNER JOIN p_experts e ON d.cabinet = e.code_cab and d.expert = e.code_exp
|
||||||
WHERE d.societe = :societe and d.no_id=:no_id;"""
|
INNER JOIN p_statuts s ON d.STATUS = s.code
|
||||||
|
WHERE d.societe = :societe and d.no_id=:no_id;"""
|
||||||
results = request.dbsession.execute(query, {'societe': societe, 'no_id': no_id}).first()
|
|
||||||
return results
|
results = request.dbsession.execute(query, {'societe': societe, 'no_id': no_id}).first()
|
||||||
|
return results
|
||||||
def get_facture_by_no(request,nodossier):
|
|
||||||
# lire facture
|
def get_facture_by_no(request,nodossier):
|
||||||
|
# lire facture
|
||||||
societe = nodossier[0:2]
|
|
||||||
no_id = nodossier[5:]
|
societe = nodossier[0:2]
|
||||||
|
no_id = nodossier[5:]
|
||||||
query = """
|
|
||||||
SELECT d.*, c.*, a.NOM as nom_cabinet, e.NOM as nom_expert FROM facture d
|
query = """
|
||||||
INNER JOIN clients c ON d.societe = c.societe and d.cd_cli = c.cd_cli
|
SELECT d.*, c.*, s.libelle, a.NOM as nom_cabinet, e.NOM as nom_expert FROM facture d
|
||||||
INNER JOIN p_cabinet a ON d.cabinet = a.code
|
INNER JOIN clients c ON d.societe = c.societe and d.cd_cli = c.cd_cli
|
||||||
INNER JOIN p_experts e ON d.cabinet = e.code_cab and d.expert = e.code_exp
|
INNER JOIN p_cabinet a ON d.cabinet = a.code
|
||||||
WHERE d.societe = :societe and d.no_id=:no_id;"""
|
INNER JOIN p_experts e ON d.cabinet = e.code_cab and d.expert = e.code_exp
|
||||||
|
INNER JOIN p_statuts s ON d.STATUS = s.code
|
||||||
results = request.dbsession.execute(query, {'societe': societe, 'no_id': no_id}).first()
|
WHERE d.societe = :societe and d.no_id=:no_id;"""
|
||||||
return results
|
|
||||||
|
results = request.dbsession.execute(query, {'societe': societe, 'no_id': no_id}).first()
|
||||||
def get_proforma_by_no(request,nodossier):
|
return results
|
||||||
# lire facture
|
|
||||||
|
def get_proforma_by_no(request,nodossier):
|
||||||
societe = nodossier[0:2]
|
# lire facture
|
||||||
no_id = nodossier[5:]
|
|
||||||
|
societe = nodossier[0:2]
|
||||||
query = """
|
no_id = nodossier[5:]
|
||||||
SELECT d.*, c.*, a.NOM as nom_cabinet, e.NOM as nom_expert FROM proforma d
|
|
||||||
INNER JOIN clients c ON d.societe = c.societe and d.cd_cli = c.cd_cli
|
query = """
|
||||||
INNER JOIN p_cabinet a ON d.cabinet = a.code
|
SELECT d.*, c.*, a.NOM as nom_cabinet, e.NOM as nom_expert FROM proforma d
|
||||||
INNER JOIN p_experts e ON d.cabinet = e.code_cab and d.expert = e.code_exp
|
INNER JOIN clients c ON d.societe = c.societe and d.cd_cli = c.cd_cli
|
||||||
WHERE d.societe = :societe and d.no_id=:no_id;"""
|
INNER JOIN p_cabinet a ON d.cabinet = a.code
|
||||||
|
INNER JOIN p_experts e ON d.cabinet = e.code_cab and d.expert = e.code_exp
|
||||||
results = request.dbsession.execute(query, {'societe': societe, 'no_id': no_id}).first()
|
WHERE d.societe = :societe and d.no_id=:no_id;"""
|
||||||
return results
|
|
||||||
|
results = request.dbsession.execute(query, {'societe': societe, 'no_id': no_id}).first()
|
||||||
def update_devis_ligne(request, nodossier, nolig, new_values):
|
return results
|
||||||
societe = nodossier[0:2]
|
|
||||||
no_id = nodossier[5:]
|
def update_devis_ligne(request, nodossier, nolig, new_values):
|
||||||
# formater les champs
|
societe = nodossier[0:2]
|
||||||
s = ''
|
no_id = nodossier[5:]
|
||||||
for param in new_values.keys():
|
# formater les champs
|
||||||
if s:
|
s = ''
|
||||||
s += ",%s=:%s" % (param, param)
|
for param in new_values.keys():
|
||||||
else:
|
if s:
|
||||||
s = "%s=:%s" % (param, param)
|
s += ",%s=:%s" % (param, param)
|
||||||
|
else:
|
||||||
if nolig == '0':
|
s = "%s=:%s" % (param, param)
|
||||||
query = "INSERT INTO devis_lignes SET %s" % s
|
|
||||||
else:
|
if nolig == '0':
|
||||||
new_values['societe'] = societe
|
query = "INSERT INTO devis_lignes SET %s" % s
|
||||||
new_values['no_id'] = no_id
|
else:
|
||||||
new_values['nolig'] = nolig
|
new_values['societe'] = societe
|
||||||
query = "UPDATE devis_lignes SET %s WHERE societe = :societe and no_id=:no_id and nolig = :nolig;" % s
|
new_values['no_id'] = no_id
|
||||||
# import pdb;pdb.set_trace()
|
new_values['nolig'] = nolig
|
||||||
execute_query(request, query, new_values)
|
query = "UPDATE devis_lignes SET %s WHERE societe = :societe and no_id=:no_id and nolig = :nolig;" % s
|
||||||
|
# import pdb;pdb.set_trace()
|
||||||
def sum_devis_totaux(request, nodossier):
|
execute_query(request, query, new_values)
|
||||||
societe = nodossier[0:2]
|
|
||||||
no_id = nodossier[5:]
|
def sum_devis_totaux(request, nodossier):
|
||||||
|
societe = nodossier[0:2]
|
||||||
query = """UPDATE devis SET totalht = (SELECT SUM(mtht) FROM devis_lignes WHERE societe=:societe AND no_id=:no_id),
|
no_id = nodossier[5:]
|
||||||
totaltva = ROUND(totalht * tauxtva / 100,2),
|
|
||||||
totalttc = totalht + totaltva
|
query = """UPDATE devis SET totalht = (SELECT SUM(mtht) FROM devis_lignes WHERE societe=:societe AND no_id=:no_id),
|
||||||
WHERE societe=:societe AND no_id=:no_id;"""
|
totaltva = ROUND(totalht * tauxtva / 100,2),
|
||||||
execute_query(request, query, {'societe': societe, 'no_id': no_id})
|
totalttc = totalht + totaltva
|
||||||
|
WHERE societe=:societe AND no_id=:no_id;"""
|
||||||
def delete_devis_ligne(request, nodossier, nolig):
|
execute_query(request, query, {'societe': societe, 'no_id': no_id})
|
||||||
societe = nodossier[0:2]
|
|
||||||
no_id = nodossier[5:]
|
def delete_devis_ligne(request, nodossier, nolig):
|
||||||
|
societe = nodossier[0:2]
|
||||||
query = "DELETE FROM devis_lignes WHERE societe = :societe and no_id=:no_id and nolig=%s;"
|
no_id = nodossier[5:]
|
||||||
execute_query(request, query, {'societe': societe, 'no_id': no_id})
|
|
||||||
|
query = "DELETE FROM devis_lignes WHERE societe = :societe and no_id=:no_id and nolig=%s;"
|
||||||
def move_devis_ligne(request, nodossier, nolig, move):
|
execute_query(request, query, {'societe': societe, 'no_id': no_id})
|
||||||
societe = nodossier[0:2]
|
|
||||||
no_id = nodossier[5:]
|
def move_devis_ligne(request, nodossier, nolig, move):
|
||||||
|
societe = nodossier[0:2]
|
||||||
# get max no ligne du devis
|
no_id = nodossier[5:]
|
||||||
query = "SELECT count(*) AS max_no FROM devis_lignes WHERE societe = :societe and no_id=:no_id;"
|
|
||||||
results = request.dbsession.execute(query, {'societe': societe, 'no_id': no_id}).first()
|
# get max no ligne du devis
|
||||||
max_no = results.max_no + 1
|
query = "SELECT count(*) AS max_no FROM devis_lignes WHERE societe = :societe and no_id=:no_id;"
|
||||||
|
results = request.dbsession.execute(query, {'societe': societe, 'no_id': no_id}).first()
|
||||||
step = 0
|
max_no = results.max_no + 1
|
||||||
if move == 'up':
|
|
||||||
# déplacement vers le haut
|
step = 0
|
||||||
if nolig > 1:
|
if move == 'up':
|
||||||
step = -1
|
# déplacement vers le haut
|
||||||
else:
|
if nolig > 1:
|
||||||
# déplacement vers le haut
|
step = -1
|
||||||
if nolig < max_no:
|
else:
|
||||||
step = +1
|
# déplacement vers le haut
|
||||||
|
if nolig < max_no:
|
||||||
if step != 0:
|
step = +1
|
||||||
# déplacer le suivant ou précédent vers la fin
|
|
||||||
query = """UPDATE devis_lignes SET nolig = :max_no WHERE societe = :societe and no_id=:no_id and nolig = :nolig + :step;"""
|
if step != 0:
|
||||||
execute_query(request, query, {'societe': societe, 'no_id': no_id, 'nolig': nolig, 'max_no': max_no, 'step': step})
|
# déplacer le suivant ou précédent vers la fin
|
||||||
# permuter avec le suivant ou précédent
|
query = """UPDATE devis_lignes SET nolig = :max_no WHERE societe = :societe and no_id=:no_id and nolig = :nolig + :step;"""
|
||||||
query = """UPDATE devis_lignes SET nolig = nolig + :step WHERE societe = :societe and no_id=:no_id and nolig = :nolig;"""
|
execute_query(request, query, {'societe': societe, 'no_id': no_id, 'nolig': nolig, 'max_no': max_no, 'step': step})
|
||||||
execute_query(request, query, {'societe': societe, 'no_id': no_id, 'nolig': nolig, 'step': step})
|
# permuter avec le suivant ou précédent
|
||||||
# remettre le précédent ou suivant à la place de la ligne déplacée
|
query = """UPDATE devis_lignes SET nolig = nolig + :step WHERE societe = :societe and no_id=:no_id and nolig = :nolig;"""
|
||||||
query = """UPDATE devis_lignes SET nolig = :nolig WHERE societe = :societe and no_id=:no_id and nolig = :max_no;"""
|
execute_query(request, query, {'societe': societe, 'no_id': no_id, 'nolig': nolig, 'step': step})
|
||||||
execute_query(request, query, {'societe': societe, 'no_id': no_id, 'nolig': nolig, 'max_no': max_no})
|
# remettre le précédent ou suivant à la place de la ligne déplacée
|
||||||
|
query = """UPDATE devis_lignes SET nolig = :nolig WHERE societe = :societe and no_id=:no_id and nolig = :max_no;"""
|
||||||
|
execute_query(request, query, {'societe': societe, 'no_id': no_id, 'nolig': nolig, 'max_no': max_no})
|
||||||
|
|
||||||
|
def update_devis_cloture(request, nodevis, status, logged_in):
|
||||||
|
societe = nodevis[0:2]
|
||||||
|
nochantier = int(nodevis[5:])
|
||||||
|
# met le montant regle à 1 centime pour terminé le dossier
|
||||||
|
query = "UPDATE devis SET STATUS = :status, USERMAJ = :logged_in WHERE societe=:societe AND no_id=:nochantier;"
|
||||||
|
execute_query(request, query, {'societe': societe, 'nochantier': nochantier, 'status': status, 'logged_in': logged_in})
|
||||||
@@ -30,13 +30,14 @@ def get_dossier_by_no(request,nodossier):
|
|||||||
societe = nodossier[0:2]
|
societe = nodossier[0:2]
|
||||||
no_id = nodossier[3:]
|
no_id = nodossier[3:]
|
||||||
query = """
|
query = """
|
||||||
SELECT d.*, a.NOM as nom_cabinet, e.NOM as nom_expert,
|
SELECT d.*, s.libelle, a.NOM as nom_cabinet, e.NOM as nom_expert,
|
||||||
c.QUALITE AS cli_QUALITE, c.NOM AS cli_NOM, c.ADRESSE AS cli_ADRESSE, c.ADRESSE2 AS cli_ADRESSE2, c.CP AS cli_CP, c.VILLE AS cli_VILLE,
|
c.QUALITE AS cli_QUALITE, c.NOM AS cli_NOM, c.ADRESSE AS cli_ADRESSE, c.ADRESSE2 AS cli_ADRESSE2, c.CP AS cli_CP, c.VILLE AS cli_VILLE,
|
||||||
c.TEL1 AS cli_TEL1, c.TEL2 AS cli_TEL2, c.TELP AS cli_TELP, c.FAX AS cli_FAX, c.NOMRESP AS cli_NOMRESP
|
c.TEL1 AS cli_TEL1, c.TEL2 AS cli_TEL2, c.TELP AS cli_TELP, c.FAX AS cli_FAX, c.NOMRESP AS cli_NOMRESP
|
||||||
FROM dem_devis d
|
FROM dem_devis d
|
||||||
INNER JOIN clients c ON d.societe = c.societe and d.cd_cli = c.cd_cli
|
INNER JOIN clients c ON d.societe = c.societe and d.cd_cli = c.cd_cli
|
||||||
INNER JOIN p_cabinet a ON d.cabinet = a.code
|
INNER JOIN p_cabinet a ON d.cabinet = a.code
|
||||||
INNER JOIN p_experts e ON d.cabinet = e.code_cab and d.expert = e.code_exp
|
INNER JOIN p_experts e ON d.cabinet = e.code_cab and d.expert = e.code_exp
|
||||||
|
INNER JOIN p_statuts s ON d.STATUS = s.code
|
||||||
where d.societe = '%s' and d.no_id=%s;""" % (societe, no_id);
|
where d.societe = '%s' and d.no_id=%s;""" % (societe, no_id);
|
||||||
results = request.dbsession.execute(query).first()
|
results = request.dbsession.execute(query).first()
|
||||||
return results
|
return results
|
||||||
@@ -329,6 +330,9 @@ def get_status_by_id(request, code):
|
|||||||
if code == '':
|
if code == '':
|
||||||
query = """SELECT * FROM p_statuts;"""
|
query = """SELECT * FROM p_statuts;"""
|
||||||
results = request.dbsession.execute(query,).fetchall()
|
results = request.dbsession.execute(query,).fetchall()
|
||||||
|
elif code == 'DE':
|
||||||
|
query = """SELECT * FROM p_statuts WHERE code >= 3;"""
|
||||||
|
results = request.dbsession.execute(query,).fetchall()
|
||||||
else:
|
else:
|
||||||
query = """SELECT * FROM p_statuts WHERE code = :code;"""
|
query = """SELECT * FROM p_statuts WHERE code = :code;"""
|
||||||
results = request.dbsession.execute(query, {'code': code}).first()
|
results = request.dbsession.execute(query, {'code': code}).first()
|
||||||
|
|||||||
@@ -1,99 +1,157 @@
|
|||||||
<metal:block use-macro="main_template">
|
<metal:block use-macro="main_template">
|
||||||
<div metal:fill-slot="content">
|
<div metal:fill-slot="content">
|
||||||
<br />
|
<br />
|
||||||
<!-- ENTETE -->
|
<!-- ENTETE -->
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<!-- CHANTIER -->
|
<!-- CHANTIER -->
|
||||||
<div class="col-md-6">
|
<div class="col-md-6">
|
||||||
<table class="table table-condensed">
|
<table class="table table-condensed">
|
||||||
<tr>
|
<tr>
|
||||||
<td><h4>CHANTIER</h4><h4 class="text-primary">${entete.societe}-${entete.nochantier}</h4>
|
<td><h4>CHANTIER</h4><h4 class="text-primary">${entete.societe}-${entete.nochantier}</h4>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<h4>${entete.C_QUALITE} ${entete.C_NOM}</h4>
|
<h4>${entete.C_QUALITE} ${entete.C_NOM}</h4>
|
||||||
${entete.C_ADR}<br />
|
${entete.C_ADR}<br />
|
||||||
<span tal:condition="entete.C_ADR2">${entete.C_ADR2}<br /></span>
|
<span tal:condition="entete.C_ADR2">${entete.C_ADR2}<br /></span>
|
||||||
${entete.C_CP} ${entete.C_VILLE}<br />
|
${entete.C_CP} ${entete.C_VILLE}<br />
|
||||||
${entete.C_EMAIL}
|
${entete.C_EMAIL}
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
Etage - Code<br />
|
Etage - Code<br />
|
||||||
Tél. domicile - prof.<br />
|
Tél. domicile - prof.<br />
|
||||||
Tél. mobile - fax
|
Tél. mobile - fax
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
${entete.C_ETAGE} - ${entete.C_CODE}<br />
|
${entete.C_ETAGE} - ${entete.C_CODE}<br />
|
||||||
${entete.C_TEL1} - ${entete.C_TEL2}<br />
|
${entete.C_TEL1} - ${entete.C_TEL2}<br />
|
||||||
${entete.C_TELP} - ${entete.C_FAX}
|
${entete.C_TELP} - ${entete.C_FAX}
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Mon compte -->
|
<!-- Mon compte -->
|
||||||
<div class="col-md-6 ${bg_color}">
|
<div class="col-md-6 ${bg_color}">
|
||||||
<table class="table table-condensed ">
|
<table class="table table-condensed ">
|
||||||
<tr>
|
<tr>
|
||||||
<td><h4>CLIENT</h4></td>
|
<td><h4>CLIENT</h4></td>
|
||||||
<td>
|
<td>
|
||||||
<h4>${entete.QUALITE} ${entete.NOM}</h4>
|
<h4>${entete.QUALITE} ${entete.NOM}</h4>
|
||||||
${entete.ADRESSE}<br />
|
${entete.ADRESSE}<br />
|
||||||
<span tal:condition="entete.ADRESSE2">${entete.ADRESSE2}<br /></span>
|
<span tal:condition="entete.ADRESSE2">${entete.ADRESSE2}<br /></span>
|
||||||
${entete.CP} ${entete.VILLE}<br />
|
${entete.CP} ${entete.VILLE}<br />
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
Responsable<br />
|
Responsable<br />
|
||||||
Tél. 1 - 2<br />
|
Tél. 1 - 2<br />
|
||||||
Tél. mobile - fax
|
Tél. mobile - fax
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
${entete.NOMRESP}<br />
|
${entete.NOMRESP}<br />
|
||||||
${entete.TEL1} - ${entete.TEL2}<br />
|
${entete.TEL1} - ${entete.TEL2}<br />
|
||||||
${entete.TELP} - ${entete.FAX}
|
${entete.TELP} - ${entete.FAX}
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
<h4>Statut : ${entete.STATUS}</h4>
|
<div class="col-md-6">
|
||||||
</div> <!-- row -->
|
<h4>Statut : ${entete.libelle}</h4>
|
||||||
<!-- ENTETE entete -->
|
<div tal:condition="type_doc=='DE'">
|
||||||
<table class="table table-bordered table-condensed">
|
<p>Dernière modif. le <b>${entete.DATEMAJ.strftime('%d/%m/%Y à %H:%M')}</b> par <b>${entete.USERMAJ}</b></p>
|
||||||
<tr class="well">
|
<p>
|
||||||
<th class="text-right">Total HT</th>
|
<a class="btn btn-warning" role="button" href="#"
|
||||||
<th class="text-right">Total TVA</th>
|
data-toggle="modal" data-target="#confirmCloture"><span class="glyphicon glyphicon-check"></span> Modif. statut</a>
|
||||||
<th class="text-right">Total TTC</th>
|
</p>
|
||||||
<th class="text-right">TVA</th>
|
</div>
|
||||||
</tr>
|
|
||||||
<tr>
|
</div>
|
||||||
<td class="text-right">${layout.to_euro(entete.TOTALHT)}</td>
|
</div> <!-- row -->
|
||||||
<td class="text-right">${layout.to_euro(entete.TOTALTVA)}</td>
|
<!-- ENTETE entete -->
|
||||||
<td class="text-right">${layout.to_euro(entete.TOTALTTC)}</td>
|
<table class="table table-bordered table-condensed">
|
||||||
<td class="text-right">${entete.TAUXTVA} %</td>
|
<tr class="well">
|
||||||
</tr>
|
<th class="text-right">Total HT</th>
|
||||||
</table>
|
<th class="text-right">Total TVA</th>
|
||||||
|
<th class="text-right">Total TTC</th>
|
||||||
<table class="table table-bordered table-condensed">
|
<th class="text-right">TVA</th>
|
||||||
<tr class="well">
|
</tr>
|
||||||
<th>Réf</th>
|
<tr>
|
||||||
<th>Désignation</th>
|
<td class="text-right">${layout.to_euro(entete.TOTALHT)}</td>
|
||||||
<th class="text-right">Qté</th>
|
<td class="text-right">${layout.to_euro(entete.TOTALTVA)}</td>
|
||||||
<th class="text-right">PU HT</th>
|
<td class="text-right">${layout.to_euro(entete.TOTALTTC)}</td>
|
||||||
<th class="text-right">Montant HT</th>
|
<td class="text-right">${entete.TAUXTVA} %</td>
|
||||||
<th></th>
|
</tr>
|
||||||
</tr>
|
</table>
|
||||||
<tr tal:repeat="detail details">
|
|
||||||
<td>${detail.REF}</td>
|
<table class="table table-bordered table-condensed">
|
||||||
<td>${detail.LIB}</td>
|
<tr class="well">
|
||||||
<td class="text-right">${layout.to_euro(detail.QTE)}</td>
|
<th>Réf</th>
|
||||||
<td class="text-right">${layout.to_euroz(detail.PRIXHT)}</td>
|
<th>Désignation</th>
|
||||||
<td class="text-right">${layout.to_euroz(detail.MTHT)}</td>
|
<th class="text-right">Qté</th>
|
||||||
<td class="text-center">${detail.USERMAJ}</td>
|
<th class="text-right">PU HT</th>
|
||||||
</tr>
|
<th class="text-right">Montant HT</th>
|
||||||
</table>
|
<th></th>
|
||||||
|
</tr>
|
||||||
</div>
|
<tr tal:repeat="detail details">
|
||||||
</metal:block>
|
<td>${detail.REF}</td>
|
||||||
|
<td>${detail.LIB}</td>
|
||||||
|
<td class="text-right">${layout.to_euro(detail.QTE)}</td>
|
||||||
|
<td class="text-right">${layout.to_euroz(detail.PRIXHT)}</td>
|
||||||
|
<td class="text-right">${layout.to_euroz(detail.MTHT)}</td>
|
||||||
|
<td class="text-center">${detail.USERMAJ}</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<!-- Modal : Confirmation CLOTURE -->
|
||||||
|
<div class="modal fade" id="confirmCloture" role="dialog" aria-labelledby="confirmClotureLabel" aria-hidden="true">
|
||||||
|
<div class="modal-dialog">
|
||||||
|
<div class="modal-content">
|
||||||
|
<div class="modal-header">
|
||||||
|
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||||||
|
<h4 class="modal-title">Clôturer le devis</h4>
|
||||||
|
</div>
|
||||||
|
<div class="modal-body">
|
||||||
|
<!-- The form is placed inside the body of modal -->
|
||||||
|
<form id="add_justif-form" class="form-horizontal" action="${url}" method="post">
|
||||||
|
<div class="form-group">
|
||||||
|
<p class="text-center"><b>Voulez-vous changer le status du devis ?</b></p>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<label class="control-label col-xs-4" for="status">Sélectionner le statut :</label>
|
||||||
|
<div class="col-xs-8">
|
||||||
|
<select class="form-control" id="status" name="status">
|
||||||
|
<div tal:repeat="item status">
|
||||||
|
<option tal:attributes="selected entete.STATUS==item.code and 'selected' or None">${item.code} | ${item.libelle}</option>
|
||||||
|
</div>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<br>
|
||||||
|
<div class="row">
|
||||||
|
<label class="control-label col-xs-4" for="motif">Motif :</label>
|
||||||
|
<div class="col-xs-8">
|
||||||
|
<input class="form-control" type="text" id="motif" name="motif" value=""
|
||||||
|
placeholder="65 caractères maximum"
|
||||||
|
data-fv-notempty="true"
|
||||||
|
data-fv-notempty-message="Veuillez remplir un motif"
|
||||||
|
data-fv-stringlength="true"
|
||||||
|
data-fv-stringlength-max="65"
|
||||||
|
data-fv-stringlength-message="65 caractères maximum"/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<br>
|
||||||
|
<div class="modal-footer">
|
||||||
|
<button type="button" class="btn btn-default" data-dismiss="modal">Annuler</button>
|
||||||
|
<button type="submit" class="btn btn-warning" name="form.close">Clôturer</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</metal:block>
|
||||||
|
|||||||
@@ -97,11 +97,11 @@
|
|||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-6">
|
<div class="col-md-6">
|
||||||
<h4>Statut : ${dossier.STATUS}</h4>
|
<h4>Statut : ${dossier.libelle}</h4>
|
||||||
<p>Dernière modif. le <b>${dossier.DATEMAJ.strftime('%d/%m/%Y à %H:%M')}</b> par <b>${dossier.USERMAJ}</b></p>
|
<p>Dernière modif. le <b>${dossier.DATEMAJ.strftime('%d/%m/%Y à %H:%M')}</b> par <b>${dossier.USERMAJ}</b></p>
|
||||||
<p>
|
<p>
|
||||||
<a class="btn btn-warning" role="button" href="#"
|
<a class="btn btn-warning" role="button" href="#"
|
||||||
data-toggle="modal" data-target="#confirmCloture"><span class="glyphicon glyphicon-check"></span> Clôturer dossier</a>
|
data-toggle="modal" data-target="#confirmCloture"><span class="glyphicon glyphicon-check"></span> Modif. statut dossier</a>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -70,6 +70,7 @@ def devis_create(request):
|
|||||||
def devis_view(request):
|
def devis_view(request):
|
||||||
nodevis = request.matchdict['nodevis']
|
nodevis = request.matchdict['nodevis']
|
||||||
societe = nodevis[0:2]
|
societe = nodevis[0:2]
|
||||||
|
logged_in = request.authenticated_userid.upper()
|
||||||
url = request.route_url("devis_view", nodevis=nodevis)
|
url = request.route_url("devis_view", nodevis=nodevis)
|
||||||
|
|
||||||
type_doc = nodevis[3:5]
|
type_doc = nodevis[3:5]
|
||||||
@@ -91,12 +92,34 @@ def devis_view(request):
|
|||||||
# select background color according to society
|
# select background color according to society
|
||||||
bg_color = "bg-%s" % societe
|
bg_color = "bg-%s" % societe
|
||||||
|
|
||||||
|
status = get_status_by_id(request, 'DE')
|
||||||
|
|
||||||
|
if 'form.close' in request.params:
|
||||||
|
status = request.params["status"]
|
||||||
|
motif = request.params["motif"]
|
||||||
|
|
||||||
|
code, libelle = status.split(' | ')
|
||||||
|
code = int(code)
|
||||||
|
|
||||||
|
nodossier = str(entete.societe) + '-' + str(entete.nochantier)
|
||||||
|
|
||||||
|
if type_doc == 'DE':
|
||||||
|
if code >= 10:
|
||||||
|
comment = 'Le devis est ' + libelle + ' : ' + motif
|
||||||
|
insert_suivi(request, nodossier, comment)
|
||||||
|
update_devis_cloture(request, nodevis, code, logged_in)
|
||||||
|
request.session.flash(u"Le statut du devis a été changé avec succès.", 'success')
|
||||||
|
return HTTPFound(url)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'page_title': page_title,
|
'page_title': page_title,
|
||||||
|
'url': url,
|
||||||
'nodevis': nodevis,
|
'nodevis': nodevis,
|
||||||
'entete': entete,
|
'entete': entete,
|
||||||
'details': details,
|
'details': details,
|
||||||
'bg_color': bg_color,
|
'bg_color': bg_color,
|
||||||
|
'status': status,
|
||||||
|
'type_doc': type_doc,
|
||||||
}
|
}
|
||||||
|
|
||||||
@view_config(route_name='devis_web', renderer='../templates/devis/devis_web.pt', permission='view')
|
@view_config(route_name='devis_web', renderer='../templates/devis/devis_web.pt', permission='view')
|
||||||
|
|||||||
Reference in New Issue
Block a user