-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathorder.py
More file actions
57 lines (48 loc) · 1.93 KB
/
order.py
File metadata and controls
57 lines (48 loc) · 1.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
""" Окно создания/выбора заказа """
import json
from tkinter import *
from asterisk.ami import *
from config import asterisk_conf
""" get extension of client registered with same IP - do not work over NAT """
def initiate_call(callerid, ext, phone):
global asterisk_conf
print("CALL:", callerid, ext, phone.get())
client = AMIClient(address=asterisk_conf["address"], port=asterisk_conf["port"])
client.login(username=asterisk_conf["username"], secret=asterisk_conf["secret"])
action = SimpleAction('Originate',
Channel = "Local/"+ext+"@from-internal-auto",
Context = 'call-out',
Exten = phone.get(),
Priority = 1,
WaitTime = 15,
Callerid = callerid)
print(action)
stat = client.send_action(action)
print(stat.response)
def fix_rus(event):
print(event)
if event.char=="\x16" and event.keysym!='v':
print("paste")
event.widget.event_generate("<<Paste>>")
print("ok")
def order_window(shop, shop_ph, eid):
global asterisk_conf
print("dial window", shop, shop_ph, eid)
ow = Toplevel()
s = Label(ow, text=shop)
s.pack()
# get all orders for selected shop
call_fr = Frame(ow)
ph_l = Label(call_fr, text="Телефон клиента:")
ph_l.pack(side=LEFT)
ph_entry = Entry(call_fr)
ph_entry.pack(side=LEFT)
call_fr.pack()
dial_cmd = lambda c=shop_ph, e=asterisk_conf['ext'], p=ph_entry: initiate_call(c, e, p)
dial_cmd2 = lambda _, c=shop_ph, e=asterisk_conf['ext'], p=ph_entry: initiate_call(c, e, p)
c = Button(ow, text="Звонок", command=dial_cmd)
ow.bind("<Return>", dial_cmd2)
ow.bind("<Key>", fix_rus)
# ow.bind("<Control-М>", lambda _: ow.)
c.pack()
ph_entry.focus()