def display(): ts = data.Display_store.query.first() sli = data.Slides_c.query.first() ex_functions.mse() if data.Slides.query.count() > 0: ss = data.Slides.query.order_by(data.Slides.id.desc()) else: ss = None if data.Display_store.query.first().audio == "true": audio = 1 else: audio = 0 if data.Display_store.query.first().announce != "false": audio_2 = 1 else: audio_2 = 0 return render_template("display.html", ss=ss, sli=sli, audio=audio, audio_2=audio_2, ts=ts, slides=data.Slides.query, tv=ts.tmp, ptitle="Display Screen", anr=ts.anr, vid=data.Vid.query.first())
def slide_r(f_id): ex_functions.mse() if current_user.role_id != 1: flash(get_lang(0), "danger") return redirect(url_for('core.root')) if data.Slides.query.count() <= 0: flash(get_lang(34), "danger") return redirect(url_for('cust_app.slideshow')) if data.Vid.query.first().enable == 1: flash(get_lang(31), 'danger') return redirect(url_for('cust_app.video')) if f_id == 00: for a in data.Slides.query: if a is not None: db.session.delete(a) db.session.commit() flash(get_lang(35), "info") return redirect(url_for('cust_app.slideshow')) mf = data.Slides.query.filter_by(id=f_id).first() if mf is not None: db.session.delete(mf) db.session.commit() flash(get_lang(35), "info") return redirect(url_for('cust_app.slideshow')) else: flash(get_lang(34), "danger") return redirect(url_for('core.root'))
def slide_c(): ex_functions.mse() if current_user.role_id != 1: flash(get_lang(0), "danger") return redirect(url_for('core.root')) if data.Vid.query.first().enable == 1: flash(get_lang(31), 'danger') return redirect(url_for('cust_app.video')) form = forms.Slide_c() if session.get('lang') == 'AR': form = forms.Slide_c_ar() sc = data.Slides_c.query.first() if form.validate_on_submit(): sc.rotation = form.rotation.data sc.navigation = form.navigation.data sc.effect = form.effect.data sc.status = form.status.data db.session.add(sc) db.session.commit() flash(get_lang(33), "info") return redirect(url_for("cust_app.slide_c")) form.rotation.data = sc.rotation form.navigation.data = sc.navigation form.effect.data = sc.effect form.status.data = sc.status return render_template("slide_settings.html", form=form, navbar="#snb2", hash="#ss2", ptitle="Slideshow settings", dropdown="#dropdown-lvl3", vtrue=data.Vid.query.first().enable, strue=data.Slides_c.query.first().status)
def slideshow(): ex_functions.mse() if current_user.role_id != 1: flash(get_lang(0), "danger") return redirect(url_for('core.root')) if data.Vid.query.first().enable == 1: flash(get_lang(31), 'danger') return redirect(url_for('cust_app.video')) page = request.args.get('page', 1, type=int) if page > int(data.Slides.query.count() / 10) + 1: flash(get_lang(4), 'danger') return redirect(url_for('cust_app.slideshow')) pagination = data.Slides.query.paginate(page, per_page=10, error_out=False) return render_template( "slideshow.html", len=len, navbar="#snb2", sli=data.Slides_c.query.first(), mmm=data.Slides.query, slides=pagination.items, pagination=pagination, sm=data.Slides.query.filter(data.Slides.ikey != 0).count(), ptitle="All slides", hash="#ss1", dropdown="#dropdown-lvl3", vtrue=data.Vid.query.first().enable, strue=data.Slides_c.query.first().status)
def ticket(): if os.name == 'nt': from win_printer import listpp lll = listpp() else: lll = listp() ex_functions.mse() if current_user.role_id != 1: flash(get_lang(0), 'danger') return redirect(url_for('core.root')) form = forms.Printer_f(lll) if session.get('lang') == "AR": form = forms.Printer_f_ar(lll) tc = data.Touch_store.query.first() pr = data.Printer.query.first() if form.validate_on_submit(): if form.kind.data == 1: tc.n = True pr.value = form.value.data pr.active = False db.session.add(tc) db.session.add(pr) else: if form.printers.data == "00": flash(get_lang(19), 'danger') return redirect(url_for('cust_app.ticket')) f = form.printers.data pr.product = f if os.name != 'nt': f = f.split('_') pr.vendor = f[0] pr.product = f[1] pr.in_ep = int(f[2]) pr.out_ep = int(f[3]) tc.n = False pr.active = True pr.langu = form.langu.data pr.value = form.value.data db.session.add(tc) db.session.add(pr) db.session.commit() flash(get_lang(27), 'info') return redirect(url_for('cust_app.ticket')) if tc.n: form.kind.data = 1 else: form.kind.data = 2 form.printers.data = pr.vendor + '_' + pr.product form.printers.data += '_' + str(pr.in_ep) + '_' + str(pr.out_ep) form.langu.data = pr.langu form.value.data = pr.value return render_template('ticket.html', navbar='#snb2', ptitle='Tickets', vtrue=data.Vid.query.first().enable, strue=data.Slides_c.query.first().status, form=form, hash='#da7')
def customize(): ex_functions.mse() if current_user.role_id != 1: flash(get_lang(0), "danger") return redirect(url_for('core.root')) return render_template("customize.html", ptitle="Customization", navbar="#snb2", vtrue=data.Vid.query.first().enable, strue=data.Slides_c.query.first().status)
def slide_a(): ex_functions.mse() if current_user.role_id != 1: flash(get_lang(0), "danger") return redirect(url_for('core.root')) if data.Vid.query.first().enable == 1: flash(get_lang(31), 'danger') return redirect(url_for('cust_app.video')) form = forms.Slide_a() if session.get('lang') == 'AR': form = forms.Slide_a_ar() if form.validate_on_submit(): if form.background.data == 00: bb = form.bgcolor.data else: bb = data.Media.query.filter_by(id=form.background.data).first() if bb is None: flash(get_lang(4), "danger") return redirect(url_for("cust_app.slide_a")) bb = bb.name ss = data.Slides() ss.title = form.title.data ss.hsize = form.hsize.data ss.hcolor = form.hcolor.data ss.hfont = form.hfont.data ss.hbg = form.hbg.data ss.subti = form.subti.data ss.tsize = form.tsize.data ss.tcolor = form.tcolor.data ss.tfont = form.tfont.data ss.tbg = form.tbg.data ss.bname = bb ss.ikey = form.background.data db.session.add(ss) db.session.commit() flash(get_lang(32), "info") return redirect(url_for("cust_app.slideshow")) return render_template("slide_add.html", ptitle="Add Slide ", form=form, navbar="#snb2", hash=1, dropdown='#dropdown-lvl3', vtrue=data.Vid.query.first().enable, strue=data.Slides_c.query.first().status)
def video(): ex_functions.mse() if current_user.role_id != 1: flash(get_lang(0), 'danger') return redirect(url_for('core.root')) if data.Slides_c.query.first().status == 1: flash(get_lang(28), 'danger') return redirect(url_for('cust_app.slide_c')) form = forms.Video() if session.get('lang') == "AR": form = forms.Video_ar() vdb = data.Vid.query.first() if form.validate_on_submit(): if form.video.data == 00: vdb.enable = 2 vdb.vkey = 00 else: vdb.vkey = form.video.data vdb.enable = form.enable.data mname = data.Media.query.filter_by(id=form.video.data).first() vdb.vname = mname.name data.Display_store.query.first().vkey = form.video.data data.Media.query.filter_by(id=form.video.data).first().used = True vdb.ar = form.ar.data vdb.controls = form.controls.data vdb.mute = form.mute.data db.session.add(vdb) db.session.commit() flash(get_lang(29), 'info') return redirect(url_for('cust_app.video')) if vdb is not None: form.video.data = vdb.vkey form.enable.data = vdb.enable form.ar.data = vdb.ar form.controls.data = vdb.controls form.mute.data = vdb.mute return render_template('video.html', ptitle='Video settings', navbar='#snb2', hash='#da5', form=form, vtrue=data.Vid.query.first().enable, strue=data.Slides_c.query.first().status)
def touch(a): d = False if a == 1: d = True form = forms.Touch_name() if session.get('lang') == "AR": form = forms.Touch_name_ar() ex_functions.mse() ts = data.Touch_store.query.filter_by(id=0).first() if data.Task.query.count() > 0: t = data.Task.query.order_by(data.Task.timestamp) else: t = 0 tnumber = False if data.Printer.query.first().value == 2: tnumber = True return render_template("touch.html", ts=ts, tasks=t, tnumber=tnumber, ptitle="Touch Screen", form=form, a=ts.tmp, d=d)
def serial(t_id): ex_functions.mse() form = forms.Touch_name() if session.get('lang') == "AR": form = forms.Touch_name_ar() tsk = data.Task.query.filter_by(id=t_id).first() if tsk is None: flash(get_lang(4), "danger") return redirect(url_for("core.root")) # Fix: to allow non users to generate tickets # if current_user.role_id == 3: # flash(get_lang(18), # "danger") # return redirect(url_for('core.root')) # if current_user.role_id == 3 and tsk.office_id != data.Operators.query.filter_by(id=current_user.id).first().office_id: # flash(get_lang(18), # "danger") # return redirect(url_for('core.root')) if not form.validate_on_submit() and data.Touch_store.query.first().n: ts = data.Touch_store.query.filter_by(id=0).first() tnumber = False if data.Printer.query.first().value == 2: tnumber = True return render_template("touch.html", title=ts.title, tnumber=tnumber, ts=ts, done=False, bgcolor=ts.bgcolor, ptitle="Touch Screen - Enter name ", a=4, dire='multimedia/', form=form) nm = form.name.data n = False if nm is None else True o_id = data.Task.query.filter_by(id=t_id).first().office_id ln = data.Serial.query.filter_by(office_id=o_id).order_by( data.Serial.timestamp.desc()).first().number sr = data.Serial.query.filter_by(number=ln + 1, office_id=o_id, task_id=t_id).first() if sr is None: if n: db.session.add(data.Serial(ln + 1, o_id, t_id, nm, n)) else: db.session.add(data.Serial(ln + 1, o_id, t_id, None, False)) # adding printer support q = data.Printer.query.first() ppt = data.Task.query.filter_by(id=t_id).first() oot = data.Office.query.filter_by(id=o_id).first() tnum = data.Serial.query.filter_by(office_id=o_id, p=False).count() cuticket = data.Serial.query.filter_by(office_id=o_id, p=False).first() tnum -= 1 langu = data.Printer.query.first().langu # to solve Linux printer permissions if os.name == 'nt': # to solve windows shared printers import win_printer from pythoncom import CoInitialize as coli coli() chk = win_printer.check_win_p() chl = len(win_printer.listpp()) if chl >= 1 and chk is True: if langu == 'ar': win_printer.printwin_ar( q.product, oot.prefix + '.' + str(ln + 1), oot.prefix + str(oot.name), tnum, ppt.name, oot.prefix + '.' + str(cuticket.number)) else: win_printer.printwin(q.product, oot.prefix + '.' + str(ln + 1), oot.prefix + str(oot.name), tnum, ppt.name, oot.prefix + '.' + str(cuticket.number), lang=langu) p = True else: p = None else: # To Fix 1: Fail safe drivers. [FIXED] try: p = ppp.assign(int(q.vendor), int(q.product), int(q.in_ep), int(q.out_ep)) except Exception: p = None if p is None: flash(get_lang(19), 'danger') flash(get_lang(20), "info") if os.name == 'nt': flash(get_lang(57), "info") elif platform == "linux" or platform == "linux2": flash(get_lang(58), "info") return redirect(url_for('cust_app.ticket')) if os.name != 'nt': if langu == 'ar': ppp.printit_ar(p, oot.prefix + '.' + str(ln + 1), oot.prefix + str(oot.name), tnum, u'' + ppt.name, oot.prefix + '.' + str(cuticket.number)) else: ppp.printit(p, oot.prefix + '.' + str(ln + 1), oot.prefix + str(oot.name), tnum, u'' + ppt.name, oot.prefix + '.' + str(cuticket.number), lang=langu) db.session.commit() else: flash(get_lang(4), 'danger') return redirect(url_for('core.root')) for a in range(data.Waiting.query.count(), 11): for b in data.Serial.query.filter_by(p=False).order_by( data.Serial.timestamp): if data.Waiting.query.filter_by(office_id=b.office_id, number=b.number, task_id=b.task_id).first() is None: db.session.add( data.Waiting(b.number, b.office_id, b.task_id, nm, n)) db.session.commit() return redirect(url_for("core.touch", a=1))
def touchscreen_c(stab): if current_user.role_id != 1: flash(get_lang(0), "danger") return redirect(url_for('core.root')) form = forms.Touch_c() if session.get('lang') == 'AR': form = forms.Touch_c_ar() ex_functions.mse() if stab not in range(0, 6): flash(get_lang(4), "danger") return redirect(url_for('core.root')) touch_s = data.Touch_store.query.first() if form.validate_on_submit(): touch_s.tmp = form.touch.data touch_s.title = form.title.data touch_s.hsize = form.hsize.data touch_s.hcolor = form.hcolor.data touch_s.hbg = form.hbg.data touch_s.mbg = form.mbg.data touch_s.tsize = form.tsize.data touch_s.tcolor = form.tcolor.data touch_s.msize = form.msize.data touch_s.mcolor = form.mcolor.data touch_s.mduration = form.mduration.data touch_s.hfont = form.hfont.data touch_s.tfont = form.tfont.data touch_s.mfont = form.mfont.data touch_s.message = form.message.data bg = form.background.data if bg == 00: touch_s.bgcolor = form.bcolor.data touch_s.ikey = None else: touch_s.bgcolor = data.Media.query.filter_by( id=form.background.data).first().name data.Media.query.filter_by( id=form.background.data).first().used = True touch_s.ikey = form.background.data au = form.naudio.data if au == 00: touch_s.audio = "false" touch_s.akey = None else: touch_s.audio = data.Media.query.filter_by( id=form.naudio.data).first().name data.Media.query.filter_by(id=form.naudio.data).first().used = True touch_s.akey = form.naudio.data db.session.add(touch_s) db.session.commit() flash(get_lang(42), "info") return redirect(url_for("cust_app.touchscreen_c", stab=0)) form.touch.data = touch_s.tmp form.title.data = touch_s.title form.hsize.data = touch_s.hsize form.hcolor.data = touch_s.hcolor form.hbg.data = touch_s.hbg form.mbg.data = touch_s.mbg form.tsize.data = touch_s.tsize form.tcolor.data = touch_s.tcolor form.msize.data = touch_s.msize form.mcolor.data = touch_s.mcolor form.mduration.data = touch_s.mduration form.hfont.data = touch_s.hfont form.tfont.data = touch_s.tfont form.mfont.data = touch_s.mfont form.message.data = touch_s.message if touch_s.bgcolor[:3] == "rgb": form.bcolor.data = touch_s.bgcolor form.background.data = 00 else: form.background.data = touch_s.ikey if touch_s.audio == "false": form.naudio.data = 00 else: form.naudio.data = touch_s.akey return render_template("touch_screen.html", ptitle="Touch Screen customize", navbar="#snb2", form=form, dropdown='#dropdown-lvl1', hash=stab, vtrue=data.Vid.query.first().enable, strue=data.Slides_c.query.first().status)
def displayscreen_c(stab): if current_user.role_id != 1: flash(get_lang(0), "danger") return redirect(url_for('core.root')) ex_functions.mse() form = forms.Display_c() if session.get('lang') == 'AR': form = forms.Display_c_ar() if stab not in range(1, 9): flash(get_lang(4), "danger") return redirect(url_for('core.root')) touch_s = data.Display_store.query.filter_by(id=0).first() if form.validate_on_submit(): touch_s.tmp = form.display.data touch_s.title = form.title.data touch_s.hsize = form.hsize.data touch_s.hcolor = form.hcolor.data touch_s.hbg = form.hbg.data touch_s.tsize = form.tsize.data touch_s.tcolor = form.tcolor.data touch_s.h2size = form.h2size.data touch_s.h2color = form.h2color.data touch_s.ssize = form.ssize.data touch_s.scolor = form.scolor.data touch_s.mduration = form.mduration.data touch_s.hfont = form.hfont.data touch_s.tfont = form.tfont.data touch_s.h2font = form.h2font.data touch_s.sfont = form.sfont.data touch_s.mduration = form.mduration.data touch_s.rrate = form.rrate.data touch_s.announce = form.announce.data touch_s.anr = form.anr.data touch_s.anrt = form.anrt.data touch_s.effect = form.effect.data touch_s.repeats = form.repeats.data bg = form.background.data if bg == 00: touch_s.bgcolor = form.bgcolor.data touch_s.ikey = None else: touch_s.bgcolor = data.Media.query.filter_by( id=form.background.data).first().name data.Media.query.filter_by( id=form.background.data).first().used = True db.session.commit() touch_s.ikey = form.background.data au = form.naudio.data if au == 00: touch_s.audio = "false" touch_s.akey = None else: touch_s.audio = data.Media.query.filter_by( id=form.naudio.data).first().name data.Media.query.filter_by(id=form.naudio.data).first().used = True db.session.commit() touch_s.akey = form.naudio.data db.session.add(touch_s) db.session.commit() flash(get_lang(41), "info") # Adding autoreload to display screen session['autoref'] = 1 return redirect(url_for("cust_app.displayscreen_c", stab=1)) form.display.data = touch_s.tmp form.title.data = touch_s.title form.hsize.data = touch_s.hsize form.hcolor.data = touch_s.hcolor form.hbg.data = touch_s.hbg form.tsize.data = touch_s.tsize form.tcolor.data = touch_s.tcolor form.h2size.data = touch_s.h2size form.h2color.data = touch_s.h2color form.ssize.data = touch_s.ssize form.scolor.data = touch_s.scolor form.mduration.data = touch_s.mduration form.hfont.data = touch_s.hfont form.tfont.data = touch_s.tfont form.h2font.data = touch_s.h2font form.sfont.data = touch_s.sfont form.mduration.data = touch_s.mduration form.rrate.data = touch_s.rrate form.announce.data = touch_s.announce form.anr.data = touch_s.anr form.anrt.data = touch_s.anrt form.effect.data = touch_s.effect form.repeats.data = touch_s.repeats if touch_s.bgcolor[:3] == "rgb": form.bgcolor.data = touch_s.bgcolor form.background.data = 00 else: form.background.data = touch_s.ikey if touch_s.audio == "false": form.naudio.data = 00 else: form.naudio.data = touch_s.akey return render_template("display_screen.html", form=form, ptitle="Display Screen customize", navbar="#snb2", hash=stab, dropdown='#dropdown-lvl2', vtrue=data.Vid.query.first().enable, strue=data.Slides_c.query.first().status)
def multimedia(aa): # Number of files limit nofl = 300 # size folder limit in MB sfl = 2000 # Fix limited upload folder size if current_user.role_id != 1: flash(get_lang(0), "danger") return redirect(url_for('core.root')) ex_functions.mse() dire = r_path('static/multimedia/') pf = data.Media.query.order_by(data.Media.id.desc()).first() if pf is not None: pf = pf.name if aa == 0: # Fix limited upload folder size # if int(ex_functions.getFolderSize(dire)) >= sfl: # flash(get_lang(36) + str(sfl) + "MB", # "danger") # return redirect(url_for('cust_app.multimedia', aa=1)) if data.Media.query.count() >= nofl: flash(get_lang(37) + str(nofl), "danger") return redirect(url_for('cust_app.multimedia', aa=1)) else: flash(get_lang(38), "success") elif aa != 1: flash(get_lang(4), "danger") return redirect(url_for("core.root")) mmm = data.Media.query page = request.args.get('page', 1, type=int) if page > int(data.Media.query.count() / 10) + 1: flash(get_lang(4), 'danger') return redirect(url_for('cust_app.multimedia', aa=1)) pagination = data.Media.query.paginate(page, per_page=10, error_out=False) form = forms.Multimedia() if session.get('lang') == "AR": form = forms.Multimedia_ar() if mmm.count() >= 1: from sqlalchemy.sql import or_ for me in mmm: if os.path.isfile(dire + me.name): dl = [ data.Display_store.query.filter( or_(data.Display_store.ikey == me.id, data.Display_store.akey == me.id)).first(), data.Touch_store.query.filter( or_(data.Touch_store.ikey == me.id, data.Touch_store.akey == me.id)).first(), data.Slides.query.filter_by(ikey=me.id).first(), data.Vid.query.filter_by(vkey=me.id).first() ] me.used = False for d in dl: if d is not None: me.used = True break db.session.add(me) db.session.commit() else: if me.img or me.audio or me.vid: for t in [ data.Touch_store, data.Display_store, data.Slides ]: t = t.query.filter_by( or_(data.Display_store.ikey == me.id, data.Display_store.vkey == me.id)).first() if me.img or me.vid and t is not None: if me.img: t.ikey = None if me.vid: t.vid = None if t != data.Slides: t.bgcolor = "bg-danger" else: t.bgname = "bg-danger" db.session.add(t) ttt = t.query.filter_by(akey=me.id).first() if me.audio and ttt is not None: if t != data.Slides: t.akey = None t.audio = "false" db.session.add(t) db.session.delete(me) db.session.commit() if form.validate_on_submit(): ff = form.mf.data ffn = secure_filename(ff.filename) dc = data.Media.query.count() # FIX ISUUE Remove folder size limitation # if int(ex_functions.getFolderSize(dire)) >= sfl or dc >= nofl: # return redirect(url_for('cust_app.multimedia', aa=1)) e = ffn[-3:len(ffn)] if e in mdal[0]: files.save(request.files['mf'], name=ffn) if imghdr.what(dire + ffn) is None: os.remove(dire + ffn) return redirect(url_for("cust_app.multimedia", aa=1)) db.session.add(data.Media(False, False, True, False, ffn)) db.session.commit() return redirect(url_for("cust_app.multimedia", aa=1)) elif e in mdal[1]: files.save(request.files['mf'], name=ffn) if sndhdr.what(dire + ffn) is None: os.remove(dire + ffn) return redirect(url_for("cust_app.multimedia", aa=1)) db.session.add(data.Media(False, True, False, False, ffn)) db.session.commit() return redirect(url_for("cust_app.multimedia", aa=1)) elif e in mdal[2]: files.save(request.files['mf'], name=ffn) db.session.add(data.Media(True, False, False, False, ffn)) db.session.commit() return redirect(url_for("cust_app.multimedia", aa=1)) else: flash(get_lang(4), "danger") return redirect(url_for("cust_app.multimedia", aa=1)) return render_template("multimedia.html", ptitle="Multimedia", navbar="#snb2", form=form, hash="#da1", mmm=mmm, len=len, ml=mdal, mmmp=pagination.items, pagination=pagination, tc=data.Touch_store.query, sl=data.Slides.query, dc=data.Display_store.query, fs=int(ex_functions.getFolderSize(dire)), nofl=nofl, sfl=sfl, vtrue=data.Vid.query.first().enable, strue=data.Slides_c.query.first().status)
def create_db(app): # Creating all non-existing tables with app.app_context(): db.create_all() db.session.commit() mse()