[Added export balance history from SIP prepaid page Adrian Georgescu **20090428080445 HTML changes ] hunk ./library/ngnpro_client.php 6844 - var $remote_engine_name='dns_engine_remote'; + var $remote_engine_name = 'dns_engine_remote'; hunk ./library/ngnpro_client.php 6846 - var $typeFilter = false; - var $default_ttl = 3600; - var $fancy = false; + var $typeFilter = false; + var $default_ttl = 3600; + var $fancy = false; hunk ./library/ngnpro_client.php 7076 + $_name=trim($_REQUEST['name_filter']); + + if (strlen($_name) && !strstr($_name,'.') && !strstr($_name,'%')) $_name.='%'; + hunk ./library/ngnpro_client.php 7084 - 'name' => trim($_REQUEST['name_filter']), + 'name' => $_name, hunk ./library/ngnpro_client.php 7093 - 'name' => trim($_REQUEST['name_filter']), + 'name' => $_name, hunk ./library/ngnpro_client.php 10336 - hunk ./library/sip_settings.php 134 + var $balance_history = array(); hunk ./library/sip_settings.php 746 + $this->showAboveTabs(); hunk ./library/sip_settings.php 748 + $this->showUnderTabs(); hunk ./library/sip_settings.php 1500 + function showAboveTabs() { + } + hunk ./library/sip_settings.php 1529 + function showUnderTabs() { + } + + hunk ./library/sip_settings.php 3404 + function getBalanceHistory() { + $this->SipPort->addHeader($this->SoapAuth); + + $result = $this->SipPort->getCreditHistory($this->sipId,20); + + if (PEAR::isError($result)) { + $error_msg = $result->getMessage(); + $error_fault= $result->getFault(); + $error_code = $result->getCode(); + if ($error_fault->detail->exception->errorcode != "2000") { + printf ("

Error (SipPort): %s (%s): %s",$error_msg, $error_fault->detail->exception->errorcode,$error_fault->detail->exception->errorstring); + } + } + + $this->balance_history=$result->entries; + } + hunk ./library/sip_settings.php 3422 + $this->getBalanceHistory(); + hunk ./library/sip_settings.php 3454 - dprint("showBalanceHistory"); hunk ./library/sip_settings.php 3456 - $result = $this->SipPort->getCreditHistory($this->sipId,20); + $result = $this->SipPort->getCreditHistory($this->sipId,50); hunk ./library/sip_settings.php 3467 - if (is_array($result->entries)) { - foreach ($result->entries as $_line) { - $found++; - print " - - $found - $_line->date - $_line->action - $_line->number - $_line->value - $_line->balance - - "; - } + foreach ($this->balance_history as $_line) { + if (!$_line->value) continue; + $found++; + print " + + $found + $_line->date + $_line->action + $_line->number + $_line->value + $_line->balance + + "; hunk ./library/sip_settings.php 3488 + print "

pageURL&tab=prepaid&export=1 target=_new>Export history to CSV file"; hunk ./library/sip_settings.php 3491 + + function exportBalanceHistory() { + Header("Content-type: text/csv"); + $h=sprintf("Content-Disposition: inline; filename=%s-prepaid-history.csv",$this->account); + Header($h); + + $this->getBalanceHistory(); + + $this->SipPort->addHeader($this->SoapAuth); + + $result = $this->SipPort->getCreditHistory($this->sipId,100); + + if (PEAR::isError($result)) { + $error_msg = $result->getMessage(); + $error_fault= $result->getFault(); + $error_code = $result->getCode(); + if ($error_fault->detail->exception->errorcode != "2000") { + printf ("

Error (SipPort): %s (%s): %s",$error_msg, $error_fault->detail->exception->errorcode,$error_fault->detail->exception->errorstring); + } + } + + printf ("Id,Account,Date,Action,Description,Transaction value,Final balance\n"); + foreach ($this->balance_history as $_line) { + if (!$_line->value) continue; + $found++; + printf ("%s,%s,%s,%s,%s,%s,%s\n",$found,$this->account,$_line->date,$_line->action,$_line->number,$_line->value,$_line->balance); + } + } hunk ./sip_settings.phtml 31 -$action = $_REQUEST['action']; -$export = $_REQUEST['export']; - hunk ./sip_settings.phtml 56 -if (!$export) { +if (!$_REQUEST['export']) { hunk ./sip_settings.phtml 73 -if ($action=="Save settings") { +if ($_REQUEST['action']=="Save settings") { hunk ./sip_settings.phtml 87 -} else if ($action=="set barring prefixes") { +} else if ($_REQUEST['action']=="set barring prefixes") { hunk ./sip_settings.phtml 89 -} else if ($action=="set presence") { +} else if ($_REQUEST['action']=="set presence") { hunk ./sip_settings.phtml 91 -} else if ($action=="set reject members") { +} else if ($_REQUEST['action']=="set reject members") { hunk ./sip_settings.phtml 93 -} else if ($action=="set accept rules") { +} else if ($_REQUEST['action']=="set accept rules") { hunk ./sip_settings.phtml 95 -} else if ($action=="set aliases") { +} else if ($_REQUEST['action']=="set aliases") { hunk ./sip_settings.phtml 97 -} else if ($action=="Send settings") { +} else if ($_REQUEST['action']=="Send settings") { hunk ./sip_settings.phtml 99 -} else if ($tab=="phonebook" && $export) { +} else if ($_REQUEST['tab']=="phonebook" && $_REQUEST['export']) { hunk ./sip_settings.phtml 101 +} else if ($_REQUEST['tab']=="prepaid" && $_REQUEST['export']) { + $SIPSettings->exportBalanceHistory(); hunk ./sip_settings.phtml 105 -if (!$export) { +if (!$_REQUEST['export']) {