callshop modules installation

this assume you have a working version of callshop modules on old server ,you want to copy or install on new server.

1. install asteriskon new server, you also need asterisk-addons to enable mysql realtime support
I normally use asterisk-1.4.18.1.tar.gz ,
asterisk-addons-1.4.7.tar.gz

when you build asterisk-addons ,make sure res_mysql is included, chan_ooh323 excluded(we don't support h323) .to make sure res_mysql is included
you may need yum install mysql-devel to install mysql include and lib files


2. transfer asterisk-related config files (including subdirectories) from old server to new server

/etc/asterisk
/var/lib/asterisk/agi-bin

3.transfer web files
normally under /var/www/html or /var/www/vhosts/default/htdocs from old server to new server

they're

  • /callshopadmin ( you may rename the directory name)
    clear template cache and make it writeable to apache server
    cd "callshopadmin web directory"
    chmod -R 777 templates_c/*

  • /callshop
  • make csv_bin writeable
    cd "callshop web directory"
    chmod -R 777 csv_bin
    chmod -R 777 csv_bin/*

  • /operator

4. dump mysql data files from old server to new server
on old server
mysqldump -uroot -p callshop >callshopdb.csv
then transfer the callshopdb.csv to new server ,and

first create database callshopdb,username: callshopuser
GRANT ALL PRIVILEGES ON callshopdb.* TO 'callshopuser'@'localhost' IDENTIFIED BY 'callshoppwd' WITH GRANT OPTION;
GRANT ALL PRIVILEGES ON callshopdb.* TO 'callshopuser'@'localhost.localdomain' IDENTIFIED BY 'callshoppwd' WITH GRANT OPTION;

create DATABASE if not exists `callshopdb`;

mysql -uroot -p -Dcallshopdb < callshopdb.csv

don't forget create one store procedure "gen_csinvoice" on new database

delimiter |
CREATE PROCEDURE `gen_csinvoice`(IN idcard int,IN cid varchar(32), IN idcallarray varchar(240),IN excidcallarray varchar(240),IN totalcosts decimal(10,3))
sproc:begin declare invoiceid int; update cc_call set checkedout =1 where checkedout=0 and src=cid ; update monitor_calls set sessionbill = 0.0 where callerid=cid ; delete from monitor_calls where callerid=cid and status='hangup' ; insert into jy_invoice(id_card,cid,costs) values(idcard,cid,totalcosts); set invoiceid = last_insert_id(); insert into jy_invoice_call(id_invoice,destination,callednum,sessiontime,sessionbill,calltime) select invoiceid,destination,calledstation,sessiontime,cssessionbill,starttime from cc_call where find_in_set(id ,idcallarray) >0 ; update cc_call set checkedout =2 where checkedout=0 and find_in_set(id ,excidcallarray) >0; end |

5. if you change database username ,pwd ,then you also need change in following files
/etc/asterisk/a2billing.conf
[database]
hostname = localhost
user = XXXXXX
password = XXXXX
dbname = XXXXX
dbtype = mysql

/etc/asterisk/res_mysql.conf
[general]
dbhost = XXXX
dbname = XXXXX
dbuser = XXXXX
dbpass = XXXXX
dbport = 3306
dbsock = XXXXX

under callshop web directory
includes/config.php

// DB Access
$cfg['db']['host'] = 'localhost'; // Hostname
$cfg['db']['user'] = 'XXXX'; // User
$cfg['db']['pwd'] = 'XXXXX'; // Password
$cfg['db']['base'] = 'XXXX'; // DB

under operator web directory
amfphp/services/callshop/Callshop.php
function Callshop(){
mysql_connect("XXXXX", "XXXXX","XXXX");
mysql_select_db("XXXXX");

mysql_query("SET NAMES UTF8");
}

note you need reboot asterisk or reload asterisk to make your changes working