i didn't implement it yet, but this is the basic outline
I’m providing a replacement to payphones in a number of boarding schools, where every student gets a card, which can then be refilled with vouchers……
I need a setup where I can do an installation, and then let the rest be run by a non tech person.
1. I’m using realtime for voicemail,
2. I want a directory of voice mail boxes, at each school
3. I want students to be able to turn on or off their voicemail using a IVR
4. disable voicemail when account falls below a certain balance
i'll be using siftachs code to turn on or off the voicemail
Update data base;
mysql -u a2billinguser -pa2billing mya2billing
alter table cc_subscription_fee add column vmplaces int(11);
alter table cc_card add column vmplaces int(11);
create voicemail_users as oulined by siftach
create table
CREATE TABLE `vm_places` (
`id` int(11) NOT NULL auto_increment,
`placename` varchar(50) NOT NULL default '',
`context` varchar(50) NOT NULL default '',
`stamp` timestamp(14) NOT NULL,
PRIMARY KEY (`id`),
) TYPE=MyISAM;
2. change UI
Vi var/www/html/A2Billing_UI/Public/form_data/ FG_var_card.inc
In the first statement, add, 'voicemail', ‘vmplaces’ before 'sip_buddy'. It should similar to this:
getpost_ifset(array('id', 'username', 'useralias', 'uipass', 'credit', 'language', 'tariff', 'id_didgroup', 'id_campaign', 'callback', 'activated','simultaccess', 'currency','typepaid', 'creditlimit', 'lastname', 'firstname', 'email', 'address','city', 'state', 'country', 'zipcode', 'phone', 'fax', 'inuse', 'cid', 'runservice', 'firstusedate','expirationdate', 'enableexpire', 'expiredays', 'voicemail', ‘vmplaces, 'sip_buddy', 'iax_buddy','popup_select', 'vat', 'autorefill', 'initialbalance'));
Locate this line:
$HD_Form -> AddEditElement (gettext("SIP ACCOUNT"),
Add this before it:
$HD_Form -> AddEditElement (gettext("VOICEMAIL"),
"voicemail",
'1',
"RADIOBUTTON",
"",
"",
gettext("Choose if you want to enable voicemail"),
"" , "", "" , "Yes :1, - No:0", "", "" , "", gettext("Enable voicemail"));
$HD_Form -> AddEditElement (gettext("vm_places"),
"vmplaces",
"",
"SELECT",
"", "", "",
"sql",
"vm_places",
"placename, id",
"", "", "%1", "", "", "", '<OPTION value="-1" selected>'.gettext("NOT DEFINED").'</OPTION>' );
After the last AddEditElement command you should find the FieldEditElement command, add 'voicemail', ‘vmplaces’ to it, again before sip_buddy. It should look similar to this:
$HD_Form -> FieldEditElement ('username, useralias, uipass, credit, language, tariff, id_didgroup, id_campaign,'.
'callback, activated, activatedbyuser, simultaccess, currency, runservice, autorefill, initialbalance, typepaid, creditlimit, firstusedate, enableexpire,'
'expirationdate, expiredays, vat, lastname, firstname, email, address, city, state, country, zipcode, phone,'.
'fax, voicemail, vmplaces, sip_buddy, iax_buddy, inuse');
Do the same thing to:
A2Billing_UI/Public/form_data/ FG_var_subscription.inc
The thing I didn’t get into the UI is adding each place
So im using:
insert into vm_places (placename, context) values ('placename', 'context');
You need to remember to associate 2 subscriptions to each place – one that has voicemail, and one that doesn’t.
Cront Jobs
5 * * * * /etc/asterisk/crona2b.sh
create crona2b.sh that contains the following job
mysql -u a2billinguser -pa2billing mya2billing < /etc/asterisk/voicemail_users.sql
voicemail_users.sql contains
this updates the realtime database every five min
truncate table voicemail_users;
insert into voicemail_users(customer_id,context,mailbox,password,fullname,pager)
select cc_card.id,vm_places.context,cc_card.id,cc_card.username,concat(cc_card.lastname,' ',cc_card.firstname),cc_card.email from cc_card, vm_places, where cc_card.voicemail=1 AND cc_card.credit >=1 AND cc_card.vmplaces=vm_places.id;
this checks if voicemail was enabled/disabled and adjusts billing accordingly
replace into cc_card(id, subscription)
select cc_card.id, cc_subscription_fee.id from cc_card, cc_subscription_fee, vm_places where cc_card.voicemail=1 and cc_card.voicemail=cc_subscription_fee.voicemail and cc_subscription_fee.vmplaces=vm_places.id;
replace into cc_card(id, subscription)
select cc_card.id, cc_subscription_fee.id from cc_card, cc_subscription_fee, vm_places where cc_card.voicemail=0 and cc_card.voicemail=cc_subscription_fee.voicemail and cc_subscription_fee.vmplaces=vm_places.id;
i think this is basically it - i'm implementing it over the next few weeks, and will keep you posted.
i'm wondering where i edit the "generate cards", (i didn't find it under form_data) to be able to generate cards that are associated with a specific school
--- edit ----
i'm thinking of writing an AGI, which will be passed a variable(which will be different at each location---the vmplaces id), and associate a card with a school (after confimation), but i need help with this - my PHP skills are at best mediocre.
also i think the cron to disable voicemail should be run once a month, that way voicemail is sold on a monthly basis (the subscription cron should charge daily - at a fraction) ... i will need to modify the query to look something like this:
truncate table voicemail_users;
insert into voicemail_users(customer_id,context,mailbox,password,fullname,pager)
select cc_card.id,vm_places.context,cc_card.id,cc_card.username,concat(cc_card.lastname,' ',cc_card.firstname),cc_card.email from cc_card, vm_places,cc_subscription_fee where cc_subscription_fee.voicemail=1 AND cc_card.credit >=1 AND cc_card.vmplaces=vm_places.id and cc_subsription_fee.vmplaces=vm_places.id;
i didn't debug this last query yet -
i'd love any feedback or ideas
thanks
yosef (yossel) m.
|