“We decided to make a
FAIR distribution of incoming calls,” the management said: “Every day of the month, calls will be made by DIFFERENT routes to managers. The schedule will be a month in advance. "
So, then once a month I will need to shovel the entire
Asterisk dialplan in accordance with the established scheme. Very happy ...
How it worked before.
All incoming calls receive secretaries and transfer to managers like:
exten => 555.1, Dial (SIP / 22 & SIP / 23 & SIP / 24 & SIP / 25)
those. at the same time everyone starts calling phones. Who first grabbed the phone - "that and sneakers."
But this scheme has ceased to like. Requested a random distribution sequence. Well, no question:
')
exten => 555,1, Set (variant = $ [RAND (1,5)])
exten => 555, n, Goto (n ($ {variant})
exten => 555, n (1), Dial (SIP / 22)
...
This design lasted almost a few months and no one complained. That's just the sales season began to subside and ... decided to change the sequence of calls. Like on Monday, first 22, then 25, then 23, etc.
I had to resort to constructions like GotoIFTime, and throw the sequence into groups by days of the week.
As a result, a couple of months everything was fine.
And now decided to make a schedule for each month! Well - we will simplify the procedure.
Decision.
To begin with, I built a tablet in the MySQL database of the form: Dat (date of the month) and variant (line with the sequence of manager sip numbers). It turned out something like "10/12/2011" - "2324252122"
Further, in order not to suffer, I made a view that returns an entry from the given table of the current day:
CREATE
VIEW `view_grafik`
AS
SELECT variant FROM grafik_work WHERE dat = CURDATE ();
There were trifles:
exten => s, n, MYSQL (Connect uid localhost asterisk 12345678 asterisk)
exten => s, n, MYSQL (Query result $ {uid} Select `variant` from view_grafik)
exten => s, n, MYSQL (Fetch row $ {result} variant)
exten => s, n, NoOp (- $ {row} - $ {variant})
exten => s, n, MYSQL (Disconnect $ {uid})
That is, the output in the
$ {variant} variable is the sequence itself. Not forgetting to check for the "emptiness" of a variable, we proceed to the challenge:
exten => s, n, Set (count = 0)
exten => s, n, While ($ [$ {count} <= 5])
exten => s, n, Set (begin = $ [$ {count} * 2]}
exten => s, n, Set (nomer = $ {variant: $ [$ {begin}]: 2})
exten => s, n, Dial (SIP / $ {nomer})
exten => s, n, Set (count = $ [$ {count} +1])
exten => s, n, EndWhile ()
Everything! It remains to fill out the
web-interface by the days of the month.
By the way.
Faced an interesting problem when solving. Pay attention to the construction:
$ {variant: $ [$ {begin}]: 2}.
It was originally a different kind:
$ {variant: $ {begin}: 2} , but ... I got this:
232425
2425
25
those. it seems to be correct, but the string did not consist of two numbers. That's only after the introduction of square quotes, everything began to work correctly.