Files
DigitalSignage/controllers/dss_form_input_controller.py
T
2026-07-23 08:54:44 +02:00

485 lines
33 KiB
Python
Executable File

# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
import os
import os.path
import base64
import logging
import werkzeug
import datetime
import json
from odoo.addons.portal.controllers import portal
from odoo.http import request,Controller, route
from werkzeug.wrappers import Response
from ..models.dss_contract import dsscontracts
from odoo import fields, http, _
_logger = logging.getLogger(__name__)
#class WebContractsInput(Controller):
class CustomerPortal(portal.CustomerPortal):
@route(['/eingabe'],type='http', auth='user', website=True, csrf=False)
def web_form(self, **kwargs):
_logger.info("inside: start web_form")
return request.render("website.eingabe-phase1")
@route(['/my/invoiceinput'],type='http', auth='user', website=True, csrf=False)
def ad_portal_my_documents(self, page=1, date_begin=None, date_end=None, sortby=None, filterby=None, search=None, search_in='all', groupby='none', **kwargs):
values = super()._prepare_home_portal_values({})
user = request.env.user
Attachment = request.env['dss.contracts'].sudo()
domain = [('contract_state', '=', 39),
('contract_creator', '=', user.id),
('web_contract_input_notfinished','=',True)]
documents = Attachment.search(domain)
grouped_documents = []
if documents:
grouped_documents = [documents]
values.update({
'grouped_documents': grouped_documents,
'documents': documents.sudo(),
'username':user.name,
'page_name': 'Kundenvertraege',
'base_url': http.request.env["ir.config_parameter"].sudo().get_param("web.base.url"),
'default_url': '/my/invoiceinput'
})
return request.render("DigitalSignage.portal_my_invoiceinput", values)
@route(['/eingabe/start'],type='http', auth='user', website=True, csrf=False)
def changeScreenView(self, **kwargs):
_logger.info("inside start: start changeScreenTemplateView" + str(request.params)+' --'+str(kwargs)+' --'+str(request.httprequest.data))
name = kwargs.get('websideusername')
user_id = request.env.user
projekt_id = kwargs.get('project')
project = request.env['dss.projects'].search([('id','=',int(projekt_id))],limit=1)
project.reservedkdnr=str(project.reservedkdnr)+';'+str(project.lastkdnr+1)
project.lastkdnr=project.lastkdnr+1
tempid = str(project.projectid) + str(user_id.id).zfill(2) + str(project.lastkdnr).zfill(2)
tempname = tempid + '_Vertrag'
contract_name = str(tempid)+' - Vertrag ' + str(project.lastkdnr).zfill(2)
contract_id = str(project.projectid) + str(project.lastrealkdnr).zfill(2)
grundsystem_webinput_template=project.web_input_template
felder = request.env['dss.advertisefields'].search(['&','|',('contract','=',False),('isblocked','=',False),('project','=',project.id)])
comptyps = request.env['dss.company.type'].search([])
fo =""
for feld in felder:
fo = fo+"<option value=''>"+feld.feldname+"</option>"
ctn = ""
for comptyp in comptyps:
ctn = ctn+"<option value='"+comptyp.uuid+"'>"+comptyp.Firmetyp_name+"</option>"
if not grundsystem_webinput_template:
grundsystem_webinput_template = project.grundsystem_webinput_template
if not grundsystem_webinput_template:
return request.render("website.eingabe-phase2-notemplate",{'websideusername':name,'user_id':str(user_id.id)})
else:
new_contract = request.env['dss.contracts'].create({'project_id':project.projectid,'project':project.id,'client_id':str(project.lastkdnr).zfill(2),'contract_auto_id':str(tempid),'contract_auto_name':str(tempname),'contract_state':39,'contract_name':contract_name,'web_contract_input_notfinished':True,'contract_creator':int(user_id.id)})
contract_data_id=new_contract.id
formdata = {
'websideusername':name,
'user_id':str(user_id.id),
'projectid':str(project.projectid),
'project':str(projekt_id),
'contract_id':str(contract_id),
'kd_id':str(str(project.lastrealkdnr).zfill(2)),
'web_contract_paysum_gfx':'249',
'contract_data_id':str(contract_data_id),
'company_type_options':str(ctn),
'client_short_company_type_options':str(ctn),
'feldoptions':fo,
'lastschrift': 'off',
'satzmail': 'off',
'rgmail': 'off',
'kamail': 'off',
'satzgiven': 'off',
'showimage' : project.grundsystem_webinput_showimage_url
}
_logger.info("inside start: "+str(name)+'--'+str(projekt_id)+'--'+str(grundsystem_webinput_template))
return request.render("website."+grundsystem_webinput_template,formdata)
@route(['/eingabe/continue'],type='http', auth='user', website=True, csrf=False)
def inputcontinue(self, **kwargs):
_logger.info("inside continue: " + str(request.params)+' --'+str(kwargs)+' --'+str(request.httprequest.data))
user_id = request.env.user
contract = request.env['dss.contracts'].search([('uuid','=',kwargs.get('uuid'))],limit=1)
project = contract.project
_logger.info("inside continue: "+str(contract.contract_auto_name)+'--'+str(project.id))
grundsystem_webinput_template=project.web_input_template
if not grundsystem_webinput_template:
grundsystem_webinput_template = project.grundsystem_webinput_template
_logger.info("inside continue: "+str(contract.contract_auto_name)+'--'+str(project.id)+'--'+str(grundsystem_webinput_template)+'--'+str(str(contract.client_short_company_type.uuid)))
felder = request.env['dss.advertisefields'].search(['&','|',('contract','=',False),('isblocked','=',False),('project','=',project.id)])
comptyps = request.env['dss.company.type'].search([])
fo =""
sfeld =""
ctn = ""
for feld in felder:
fo = fo+"<option value=''>"+feld.feldname+"</option>"
for feld in contract.werbe_feld_selected:
sfeld = sfeld+feld.auto_feldname+", "
for comptyp in comptyps:
ctn = ctn+"<option value='"+comptyp.uuid+"' "+("selected" if comptyp.uuid == contract.client_short_company_type.uuid else "")+">"+comptyp.Firmetyp_name+"</option>"
evtlcontract_id = str(contract.project.projectid) + str(contract.project.lastrealkdnr).zfill(2)
evtlcontract_name = str(evtlcontract_id)+'_'+str(contract.client_short_company) if contract.client_short_company else str(contract.client_short_name)+' '+str(contract.client_short_vorname)
olddata = {
'user_id':str(user_id),
'projectid':str(project.projectid),
'project':str(project.id),
'company_type_options':str(ctn),
'contract_id':str(evtlcontract_id),
'client_short_company':str(contract.client_short_company) if contract.client_short_company else '',
'client_short_company_type':str(contract.client_short_company_type.uuid),
'client_short_company_type_options':str(ctn) ,
'client_short_strasse':str(contract.client_short_strasse) if contract.client_short_strasse else '',
'client_short_plz':str(contract.client_short_plz) if contract.client_short_plz else '',
'client_short_telefon':str(contract.client_short_telefon) if contract.client_short_telefon else '',
'client_short_email':str(contract.client_short_email) if contract.client_short_email else '',
'client_short_rgemail':str(contract.client_short_rgemail) if contract.client_short_rgemail else '',
'client_short_ort':str(contract.client_short_ort) if contract.client_short_ort else '',
'client_short_mobil':str(contract.client_short_mobil) if contract.client_short_mobil else '',
'client_short_website':str(contract.client_short_website) if contract.client_short_website else '',
'client_short_vorname':str(contract.client_short_vorname) if contract.client_short_vorname else '',
'client_short_name':str(contract.client_short_name) if contract.client_short_name else '',
'web_contract_paysum_lz':contract.web_contract_paysum_lz if contract.web_contract_paysum_lz else '0',
'web_contract_paysum_all':contract.web_contract_paysum_all if contract.web_contract_paysum_all else '0',
'web_contract_paysum_gfx':contract.web_contract_paysum_gfx if contract.web_contract_paysum_gfx else '0',
'web_contract_full_duration':contract.main_runtime if contract.main_runtime else '0',
'web_contract_spot_count':contract.split_runtime_count if contract.split_runtime_count else '0',
'web_contract_spot_duration':contract.split_runtime_time if contract.split_runtime_time else '0',
'web_tv_reach_PLZ':contract.tv_reach_PLZ if contract.tv_reach_PLZ else '',
'web_ads_last_date_start_planed':contract.web_contract_start_planed if contract.web_contract_start_planed else '',
'web_ads_last_date_remove_planed':contract.web_contract_remove_planed if contract.web_contract_remove_planed else '',
'web_bande_spieltage':contract.web_bande_spieltage if contract.web_bande_spieltage else '',
'contract_data_id':str(contract.id),
'runtime_m':contract.runtime_m if contract.runtime_m else '60',
'lastschrift': 'on' if contract.web_contract_is_lastschrift else 'off',
'zahlsonst': contract.web_constract_zahlstonst if contract.web_constract_zahlstonst else '',
'feldoptions':fo,
'feldselected':sfeld if sfeld else '',
'kd_id':evtlcontract_name,
'ort': contract.web_contract_sign_ort if contract.web_contract_sign_ort else '',
'namevorname': contract.web_contract_sign_name if contract.web_contract_sign_name else '',
'bic': contract.client_short_BIC if contract.client_short_BIC else '',
'iban': contract.client_short_IBAN if contract.client_short_IBAN else '',
'kapay': contract.web_contract_kapayment_info if contract.web_contract_kapayment_info else '',
'alpay': contract.web_contract_alpayment_info if contract.web_contract_alpayment_info else '',
'sonder_0': contract.web_contract_sonder_0 if contract.web_contract_sonder_0 else '',
'sonder_1': contract.web_contract_sonder_1 if contract.web_contract_sonder_1 else '',
'sonder_2': contract.web_contract_sonder_2 if contract.web_contract_sonder_2 else '',
'satzmail': 'on' if contract.web_contract_satzmail else 'off',
'rgmail': 'on' if contract.web_contract_rgmail else 'off' ,
'kamail': 'on' if contract.web_contract_kamail else 'off',
'satzgiven': 'on' if contract.web_contract_satzgiven else 'off',
'web_ads_count_per_year2': contract.ads_count_perYear2 if contract.ads_count_perYear2 else '0',
'contract_auto_extend' : 'on' if contract.contract_auto_extend else 'off',
'contract_auto_extend_time': contract.contract_auto_extend_time if contract.contract_auto_extend_time else '0',
'web_contract_cancel_date': contract.contract_cancel_date.strftime("%d.%m.%Y") if contract.contract_cancel_date else '',
'edited': "1" # damit im Template erkannt wird, dass es sich um eine Fortsetzung handelt und nicht um einen neuen Vertrag
}
return request.render("website."+grundsystem_webinput_template, olddata)
@route(['/eingabe/upload'],type='http', auth='user', website=True, csrf=False)
def inputcontinueupload(self, **kwargs):
_logger.info("inside upload continue : " + str(request.params)+' --'+str(kwargs)+' --'+str(request.httprequest.data))
user_id = request.env.user
contract = request.env['dss.contracts'].search([('uuid','=',kwargs.get('uuid'))],limit=1)
contract_id = kwargs.get('contract_id')
contract_data_id = contract.id
kd_id = kwargs.get('kd_id')
#contract = self.setcontract(request.env['dss.contracts'].search([('id','=',contract_data_id)],limit=1),kwargs)
uploads=request.env['dss.mediatypes'].search([('weboptionupload_show','=',True)])
return request.render("website.eingabe-phase3-upload",{'user_id':str(user_id),'contract_id':str(contract_id),'kd_id':str(kd_id),'contract_data_id':str(contract_data_id),'uploadfiles':uploads})
@route(['/eingabe/finish'],type='http', auth='user', website=True, csrf=False)
def finish_contract(self, **kwargs):
_logger.info("inside: start changeScreenTemplateView" + str(request.params)+' --'+str(kwargs)+' --'+str(request.httprequest.data))
uuid = kwargs.get('uuid')
contract = request.env['dss.contracts'].search([('uuid','=',uuid)],limit=1)
_logger.info("inside finish_contract: "+str(contract.id)+'--'+str(contract.contract_auto_id)+'--'+str(uuid))
if not contract.web_contract_input_finished:
if contract.project.lostkdnr:
if len(contract.project.lostkdnr)>0:
nextnr = contract.project.lostkdnr.split(',')[0]
contract.project.lostkdnr = ','.join(contract.project.lostkdnr.split(',')[1:])
else:
contract.project.lastrealkdnr += 1
nextnr = str(contract.project.lastrealkdnr).zfill(2)
else:
contract.project.lastrealkdnr += 1
nextnr = str(contract.project.lastrealkdnr).zfill(2)
contract_id = str(contract.project.projectid) + str(nextnr)
contract.contract_id = str(nextnr)
contract.client_id = str(nextnr)
contract.contract_auto_id = contract_id
contract.contract_name = str(contract.client_short_company) if contract.client_short_company else str(contract.client_short_name)+' '+str(contract.client_short_vorname)
contract.contract_auto_name=str(contract_id)+'_'+str(contract.client_short_company) if contract.client_short_company else str(contract.client_short_name)+' '+str(contract.client_short_vorname)
dsscontracts.tokampagne(contract)
contract.web_contract_input_finished = True
contract.web_contract_rejected = False
contract.web_contract_input_notfinished=False
return request.render("website.eingabe-finished",{'contract':contract,'contract_auto_id':contract.contract_auto_id})
@route(['/eingabe/cancel'],type='http', auth='user', website=True, csrf=False)
def cancel_contract(self, **kwargs):
_logger.info("inside: start cancelcontract" + str(request.params)+' --'+str(kwargs)+' --'+str(request.httprequest.data))
uuid = kwargs.get('uuid')
contract = request.env['dss.contracts'].search([('uuid','=',uuid)],limit=1)
_logger.info("inside finish_contract: "+str(contract.id)+'--'+str(contract.contract_auto_id)+'--'+str(uuid))
contract.unlink()
return request.render("website.eingabe-finished-delete",{'contract_auto_id':''})
def setcontract(self,contract,kwargs):
projekt_id = kwargs.get('project')
contract.client_short_company = kwargs.get('client_short_company') if kwargs.get('client_short_company') else ''
contract.client_short_company_type = request.env['dss.company.type'].search([('uuid','=',kwargs.get('client_short_company_type'))],limit=1) if kwargs.get('client_short_company_type') else ''
contract.client_short_vorname = kwargs.get('client_short_vorname') if kwargs.get('client_short_vorname') else ''
contract.client_short_name = kwargs.get('client_short_name') if kwargs.get('client_short_name') else ''
contract.client_short_telefon = kwargs.get('client_short_telefon') if kwargs.get('client_short_telefon') else ''
contract.client_short_email = kwargs.get('client_short_email') if kwargs.get('client_short_email') else ''
contract.client_short_rgemail = kwargs.get('client_short_rgemail') if kwargs.get('client_short_rgemail') else ''
contract.client_short_strasse = kwargs.get('client_short_strasse') if kwargs.get('client_short_strasse') else ''
contract.client_short_plz = kwargs.get('client_short_plz') if kwargs.get('client_short_plz') else ''
contract.client_short_ort = kwargs.get('client_short_ort') if kwargs.get('client_short_ort') else ''
contract.client_short_mobil = kwargs.get('client_short_mobil') if kwargs.get('client_short_mobil') else ''
contract.client_short_website = kwargs.get('client_short_website') if kwargs.get('client_short_website') else ''
contract.runtimesystem = "M"
try:
laufzeit = int(kwargs.get('contract_time'))
except:
laufzeit = 60
contract.runtime_m = laufzeit if laufzeit > 0 else kwargs.get('runtime_m') if laufzeit == -1 else 60
contract.web_contract_paysum_lz = kwargs.get('web_contract_paysum_lz') if kwargs.get('web_contract_paysum_lz') else 0.0
contract.web_contract_paysum_gfx = kwargs.get('web_contract_paysum_gfx') if kwargs.get('web_contract_paysum_gfx') else 0.0
contract.web_contract_paysum_all = kwargs.get('web_contract_paysum_all') if kwargs.get('web_contract_paysum_all') else 0.0
contract.web_contract_sign_datum = kwargs.get('Datum') if kwargs.get('Datum') else ''
contract.web_contract_sign_ort = kwargs.get('Ort') if kwargs.get('Ort') else ''
contract.web_contract_sign_name = kwargs.get('NameVorname') if kwargs.get('NameVorname') else ''
contract.client_short_BIC = kwargs.get('bic') if kwargs.get('bic') else ''
contract.client_short_IBAN = kwargs.get('iban') if kwargs.get('iban') else ''
contract.web_contract_is_lastschrift = True if kwargs.get('lastschrift') else False
contract.web_constract_zahlstonst = kwargs.get('zahlsonst') if kwargs.get('zahlsonst') else ''
contract.work_state_info = kwargs.get('sonder_2') if kwargs.get('sonder_2') else ''
contract.web_contract_kapayment_info = kwargs.get('kapay') if kwargs.get('kapay') else ''
contract.web_contract_alpayment_info = kwargs.get('alpay') if kwargs.get('alpay') else ''
contract.web_contract_satzmail = True if kwargs.get('satzmail') else False
contract.web_contract_satzgiven = True if kwargs.get('satzgiven') else False
contract.web_contract_rgmail = True if kwargs.get('rgmail') else False
contract.web_contract_kamail = True if kwargs.get('kamail') else False
contract.web_contract_sonder_0 = kwargs.get('sonder_0') if kwargs.get('sonder_0') else ''
contract.web_contract_sonder_1 = kwargs.get('sonder_1') if kwargs.get('sonder_1') else ''
contract.web_contract_sonder_2 = kwargs.get('sonder_2') if kwargs.get('sonder_2') else ''
contract.main_runtime = kwargs.get('web_contract_full_duration') if kwargs.get('web_contract_full_duration') else '0'
contract.split_runtime_count = kwargs.get('web_contract_spot_count') if kwargs.get('web_contract_spot_count') else '0'
contract.split_runtime_time = kwargs.get('web_contract_spot_duration') if kwargs.get('web_contract_spot_duration') else '0'
contract.ads_count_perYear2 = kwargs.get('web_ads_count_per_year2') if kwargs.get('web_ads_count_per_year2') else '0'
contract.tv_reach_PLZ = kwargs.get('web_tv_reach_PLZ') if kwargs.get('web_tv_reach_PLZ') else ''
contract.web_contract_start_planed = kwargs.get('web_ads_last_date_start_planed') if kwargs.get('web_ads_last_date_start_planed') else ''
contract.web_contract_remove_planed = kwargs.get('web_ads_last_date_remove_planed') if kwargs.get('web_ads_last_date_remove_planed') else ''
contract.web_bande_spieltage = kwargs.get('web_bande_spieltage') if kwargs.get('web_bande_spieltage') else ''
contract.contract_auto_extend = True if kwargs.get('contract_auto_extend') else False
contract.contract_auto_extend_time = kwargs.get('contract_auto_extend_time') if kwargs.get('contract_auto_extend_time') else '0'
cancel_date = kwargs.get('web_contract_cancel_date') if kwargs.get('web_contract_cancel_date') else ''
if cancel_date:
try:
datetime.datetime.strptime(cancel_date, "%Y-%m-%d")
contract.contract_cancel_date = cancel_date
except ValueError:
try:
converted_date = datetime.datetime.strptime(cancel_date, "%d.%m.%Y").strftime("%Y-%m-%d")
contract.contract_cancel_date = converted_date
except ValueError:
contract.contract_cancel_date = ''
else:
contract.contract_cancel_date = ''
try:
contract.contract_date = datetime.datetime.strptime(contract.web_contract_sign_datum, "%d.%m.%Y").date()
except:
# ignore error and do not set date if format is wrong
pass
gesamts = kwargs.get('sonder_0') if kwargs.get('sonder_0') else ''
gesamts = gesamts+' //// '+kwargs.get('sonder_1') if kwargs.get('sonder_1') else ''
contract.remark = gesamts
wfields = kwargs.get('werbefeld') if kwargs.get('werbefeld') else ''
wfarray = wfields.split(',') if wfields else []
contract.werbe_feld_selected = [(6, 0, [])]
for wfa in wfarray:
if wfa:
if '_' in wfa:
wfa = wfa.split('_')[1]
wfaid = request.env['dss.advertisefields'].search([('feldname','=',wfa.strip()),('project','=',contract.project.id)],limit=1)
_logger.info("inside update : "+str(projekt_id)+'/'+str(contract.project.id)+'--'+str(wfields)+'--'+str(wfa.strip()+'--'+str(wfaid)))
if wfaid:
contract.werbe_feld_selected = [(4, wfaid.id)]
else:
wfaid = request.env['dss.advertisefields'].create({'feldname':wfa.strip(),'project':contract.project.id,'auto_feldname':str(str(contract.project.projectid)+'_'+wfa.strip())})
if wfaid:
contract.werbe_feld_selected = [(4, wfaid.id)]
return contract
@route(['/eingabe/submit_lcdtouch'],type='http', auth='user', website=True, csrf=False)
def submit_lcdtouch(self, **kwargs):
_logger.info("inside: start changeScreenTemplateView" + str(request.params)+' --'+str(kwargs)+' --'+str(request.httprequest.data))
name = kwargs.get('websideusername')
projekt_id = kwargs.get('project')
projectid = kwargs.get('projectid')
user_id = kwargs.get('user_id')
contract_id = kwargs.get('contract_id')
kd_id = kwargs.get('kd_id')
contract_data_id = kwargs.get('contract_data_id')
_logger.info("inside: "+str(name)+'--'+str(projekt_id)+'--'+str(kd_id)+'--'+str(contract_id)+'--'+str(contract_data_id)+'--'+str(projectid)+'--'+str(kwargs.get('kamail')))
contract = self.setcontract(request.env['dss.contracts'].search([('id','=',contract_data_id)],limit=1),kwargs)
uploads=request.env['dss.mediatypes'].search([('weboptionupload_show','=',True)])
return request.render("website.eingabe-phase3-upload",{'websideusername':name,'user_id':str(user_id),'projectid':str(projectid),'project':str(projekt_id),'contract_id':str(contract_id),'kd_id':str(kd_id),'contract_data_id':str(contract_data_id),'uploadfiles':uploads})
@route(['/eingabe/submit_save'],type='json', auth='user', methods=['POST'], csrf=True)
def submit_save(self, **kwargs):
_logger.info("inside: Save Received Data " + str(request.params)+' --'+str(kwargs)+' --'+str(request.httprequest.data))
kwargs = json.loads(request.httprequest.data.decode('utf-8'))
_logger.info("inside: Save Received Data " + str(request.params)+' --'+str(kwargs)+' --'+str(request.httprequest.data))
name = kwargs.get('websideusername')
projekt_id = kwargs.get('project')
projectid = kwargs.get('projectid')
user_id = kwargs.get('user_id')
contract_id = kwargs.get('contract_id')
contract_data_id = kwargs.get('contract_data_id')
kd_id = kwargs.get('kd_id')
contract = self.setcontract(request.env['dss.contracts'].search([('id','=',contract_data_id)],limit=1),kwargs)
_logger.info("inside: Save Received Data "+str(name)+'--'+str(projekt_id)+'--'+str(kd_id)+'--'+str(contract_id)+'--'+str(contract_data_id))
output = {
'results':{
'code':200,
'message':'OK'
}
}
return json.dumps(output)
@route(['/eingabe/submit_all'],type='http', auth='user', website=True, csrf=False)
def submit_kfz(self, **kwargs):
_logger.info("inside: start changeScreenTemplateView" + str(request.params)+' --'+str(kwargs)+' --'+str(request.httprequest.data))
name = kwargs.get('websideusername')
projekt_id = kwargs.get('project')
projectid = kwargs.get('projectid')
user_id = kwargs.get('user_id')
contract_id = kwargs.get('contract_id')
contract_data_id = kwargs.get('contract_data_id')
kd_id = kwargs.get('kd_id')
contract = self.setcontract(request.env['dss.contracts'].search([('id','=',contract_data_id)],limit=1),kwargs)
_logger.info("inside: "+str(name)+'--'+str(projekt_id)+'--'+str(kd_id)+'--'+str(contract_id)+'--'+str(contract_data_id))
uploads=request.env['dss.mediatypes'].search([('weboptionupload_show','=',True)])
return request.render("website.eingabe-phase3-upload",{'websideusername':name,'user_id':str(user_id),'projectid':str(projectid),'project':str(projekt_id),'contract_id':str(contract_id),'kd_id':str(kd_id),'contract_data_id':str(contract_data_id),'uploadfiles':uploads})
@route(['/eingabe/submit_stream'],type='http', auth='user', website=True, csrf=False)
def submit_stream(self, **kwargs):
_logger.info("inside: start changeScreenTemplateView" + str(request.params)+' --'+str(kwargs)+' --'+str(request.httprequest.data))
name = kwargs.get('websideusername')
projekt_id = kwargs.get('project')
projectid = kwargs.get('projectid')
user_id = kwargs.get('user_id')
contract_id = kwargs.get('contract_id')
kd_id = kwargs.get('kd_id')
a=2
contract_data_id = kwargs.get('contract_data_id')
contract = self.setcontract(request.env['dss.contracts'].search([('id','=',contract_data_id)],limit=1),kwargs)
_logger.info("inside: "+str(name)+'--'+str(projekt_id)+'--'+str(kd_id)+'--'+str(contract_id)+'--'+str(contract_data_id))
return request.render("website.eingabe-phase3-upload",{'websideusername':name,'user_id':str(user_id),'projectid':str(projectid),'project':str(projekt_id),'contract_id':str(contract_id),'kd_id':str(kd_id),'contract_data_id':str(contract_data_id)})
@route(['/eingabe/submit_upload'],type='http', auth='user', website=True, csrf=False)
def submit_upload(self, **kwargs):
_logger.info("inside: start changeScreenTemplateView" + str(request.params)+' --'+str(kwargs)+' --'+str(request.httprequest.data))
name = kwargs.get('websideusername')
projekt_id = kwargs.get('project')
projectid = kwargs.get('projectid')
user_id = kwargs.get('user_id')
contract_id = kwargs.get('contract_id')
kd_id = kwargs.get('kd_id')
filetype = kwargs.get('filetype')
file = kwargs.get('filename')
b64file = base64.b64encode(file.read())
contract_data_id = kwargs.get('contract_data_id')
contract=request.env['dss.contracts'].search([('id','=',contract_data_id)],limit=1)
if filetype=="1":
_logger.info("inside: set Contract "+str(b64file))
contract.scan_vertrag=b64file
_logger.info("inside: "+str(name)+'--'+str(projekt_id)+'--'+str(kd_id)+'--'+str(contract_id)+'--'+str(contract_data_id)+'--'+str(file)+'---'+str(b64file))
return request.render("website.eingabe-phase4-finish",{'websideusername':name,'user_id':str(user_id),'projectid':str(projectid),'project':str(projekt_id),'contract_id':str(contract_id),'kd_id':str(kd_id),'contract_data_id':str(contract_data_id)})
@route(['/eingabe/submit_finish'],type='http', auth='user', website=True, csrf=False)
def submit_finish(self, **kwargs):
_logger.info("inside: start changeScreenTemplateView" + str(request.params)+' --'+str(kwargs)+' --'+str(request.httprequest.data))
name = kwargs.get('websideusername')
projekt_id = kwargs.get('project')
projectid = kwargs.get('projectid')
user_id = kwargs.get('user_id')
contract_id = kwargs.get('contract_id')
kd_id = kwargs.get('kd_id')
contract_data_id = kwargs.get('contract_data_id')
submit_finish = kwargs.get('submit')
_logger.info("inside finish : "+str(name)+'--'+str(projekt_id)+'--'+str(kd_id)+'--'+str(contract_id)+'--'+str(contract_data_id)+'--'+str(submit_finish))
if submit_finish == 'Eingabe beenden':
return self.ad_portal_my_documents(self, **kwargs)
if submit_finish == 'Neuen Vertrag im gleichen Projekt':
return self.changeScreenView(**kwargs)
if submit_finish == 'Neuen Vertrag in anderen Projekt':
return self.ad_portal_my_documents(self, **kwargs)
@route(['/xrechnungin'],type='http', auth='public', website=True, csrf=False)
def Xrechnungask(self, **kwargs):
project = request.env['x_dss.tempkd'].search([('x_guid','=',request.params.get('token'))],limit=1)
if not project:
return request.render("website.xrechnung",{'requestid':request.params.get('token'),'errorstyle':'display:block','contentstyle':'display:none'})
else :
mobile = '' if (not project.x_mobil) or (project.x_mobil == 'False') else project.x_mobil
telefon = '' if (not project.x_telefon) or (project.x_telefon == 'False') else project.x_telefon
email = '' if (not project.x_Email) or (project.x_Email == 'False') else project.x_Email
return request.render("website.xrechnung",{'requestid':request.params.get('token'),'errorstyle':'display:none','contentstyle':'display:block','kdid':project.id,'kdnr':project.x_kdnr,'name':project.x_name,'email':email,'telefon':telefon,'mobil':mobile,'rgemail':project.x_rgemail,'leitweg':project.x_leitwegid})
@route(['/xrechnung/submit'],type='http', auth='public', website=True, csrf=False)
def Xrechnungssubmit(self, **kwargs):
_logger.info("inside: start changeScreenTemplateView" + str(request.params)+' --'+str(kwargs)+' -- #'+str(request.httprequest.data)+'#')
kunden_id = kwargs.get('kdid')
client = request.env['x_dss.tempkd'].search([('id','=',kunden_id)],limit=1)
if client:
if client.x_guid == kwargs.get('requestid'):
if client.x_kdnr == kwargs.get('kdnr'):
orgclientt=request.env['x_dss.tempkd'].search([('x_kdnr','=',client.x_kdnr)])
if kwargs.get('rgemail')=='':
orgclientt.write({'x_rgemail': kwargs.get('email')})
else:
orgclientt.write({'x_rgemail': kwargs.get('rgemail')})
orgclientt.write({'x_leitwegid': kwargs.get('leitweg')})
orgclientt.write({'x_finished': True})
# orgclient=request.env['dss.contracts'].search([('contract_auto_id','=',client.x_kdnr)])
# if orgclient:
# if kwargs.get('rgemail')=='':
# orgclient.write({'client_short_rgemail': kwargs.get('email')})
# else:
# orgclient.write({'client_short_rgemail': kwargs.get('rgemail')})
# orgclient.write({'client_short_mobil': kwargs.get('mphone')})
# orgclient.write({'client_short_leitwegid': kwargs.get('leitweg')})
# if orgclient.client_short_email != kwargs.get('email'):
# orgclient.write({'client_short_email': kwargs.get('email')})
# if orgclient.client_short_telefon != kwargs.get('phone'):
# orgclient.write({'client_short_telefon': kwargs.get('phone')})
# if orgclient.client:
# org_contact_client=orgclient.client
# org_contact_client.rgemail = orgclient.client_short_rgemail
# org_contact_client.email = orgclient.client_short_email
# org_contact_client.leitwegid = orgclient.client_short_leitwegid
# org_contact_client.mobil = orgclient.client_short_mobil
# return request.redirect('/danke-xrechnung')
# else :
# errorcode='EF004'
return request.redirect('/danke-xrechnung')
else : errorcode='EF003-'+str(kwargs.get('kdnr'))
else : errorcode='EF002'
else : errorcode='EF001-'+str(kwargs.get('kdid'))
return request.render('website.error-xrechnung',{'error':errorcode})