[Added RatingProfiles management in sip settings page Adrian Georgescu **20071107160023 Fixed name of domain table when thor is enabled ] hunk ./cdrlib.phtml 245 + dprint("Init OK"); + hunk ./cdrlib.phtml 1948 - dprint($query1); - dprint($query2); hunk ./cdrlib.phtml 1950 + dprint($query1); hunk ./cdrlib.phtml 1967 + dprint($query2); hunk ./cdrlib.phtml 2032 + dprint("cacheMonthlyUsage for $_account"); hunk ./cdrlib.phtml 2042 + dprint("Caller is not local"); hunk ./cdrlib_ser.phtml 5 - var $domain_table = "domain"; hunk ./cdrlib_ser.phtml 6 - var $enable_thor = false; hunk ./cdrlib_ser.phtml 1826 + dprint("LoadDomains()"); + hunk ./cdrlib_ser.phtml 1833 + if (strlen($this->DATASOURCES[$this->cdr_source]['enableThor'])) { + $this->domain_table = "sip_domains"; + } else { + $this->domain_table = "domain"; + } + hunk ./cdrlib_ser.phtml 1841 - //$log=sprintf("Loaded %d domains from memcache\n",count($this->localDomains)); - //print $log; - //syslog(LOG_NOTICE,$log); + $log=sprintf("Loaded %d domains from memcache\n",count($this->localDomains)); + dprint($log); + syslog(LOG_NOTICE,$log); hunk ./cdrlib_ser.phtml 1850 - $query=$query ." where domain = '$els[1]' "; + $query.=" where domain = '$els[1]' "; hunk ./cdrlib_ser.phtml 1853 - $query=$query ." where domain = '$fdomain' "; + $query.=" where domain = '$fdomain' "; hunk ./cdrlib_ser.phtml 1857 - return 0; + printf ("

Error: database error %s %s",$this->AccountsDB->Error,$query); + return false; hunk ./cdrlib_ser.phtml 1865 - $this->localDomains=explode(" ",$mc_value); + $this->localDomains=explode(" ",trim($mc_value)); hunk ./cdrlib_ser.phtml 1869 - //print $log; + dprint($log); hunk ./provisioning/sip_settings_lib.phtml 17 + var $soapClassRatingPort = 'WebService_NGNPro_RatingPort'; hunk ./provisioning/sip_settings_lib.phtml 293 + if (strlen($this->loginCredentials['ratingEngine'])) { + $this->ratingEngine=$this->loginCredentials['ratingEngine']; + } else if (strlen($this->soapEngines[$this->soapEngine]['ratingEngine'])) { + $this->ratingEngine=$this->soapEngines[$this->soapEngine]['ratingEngine']; + } else { + $this->ratingEngine=$this->soapEngine; + } + hunk ./provisioning/sip_settings_lib.phtml 362 + // rating + $this->SOAPurlRating = $this->soapEngines[$this->ratingEngine]['url']; + $this->SOAPloginRating = array( + "username" => $this->soapEngines[$this->ratingEngine]['username'], + "password" => $this->soapEngines[$this->ratingEngine]['password'], + "admin" => true, + "impersonate" => intval($this->reseller) + ); + + $this->SoapAuthRating = array('auth', $this->SOAPloginRating , 'urn:AGProjects:NGNPro', 0, ''); + $this->RatingPort = new $this->soapClassRatingPort($this->SOAPurlRating); + $this->RatingPort->setOpt('curl', CURLOPT_TIMEOUT, 5); + $this->RatingPort->setOpt('curl', CURLOPT_SSL_VERIFYPEER, 0); + $this->RatingPort->setOpt('curl', CURLOPT_SSL_VERIFYHOST, 0); + + if ($this->loginType == "admin" && $this->SOAPurlRating != $this->SOAPurl) { + printf ("
%s at %s as %s ",$this->soapClassRatingPort,$this->SOAPurlRating,$this->SOAPurlRating,$this->soapEngines[$this->ratingEngine]['username']); + } + hunk ./provisioning/sip_settings_lib.phtml 630 + dprint_r($result); hunk ./provisioning/sip_settings_lib.phtml 1420 - $this->showTimezones(); + $this->showTimezones('timezone',$this->timezone); hunk ./provisioning/sip_settings_lib.phtml 1615 + $this->showBillingProfiles(); hunk ./provisioning/sip_settings_lib.phtml 2311 + + $this->updateBillingProfiles(); + hunk ./provisioning/sip_settings_lib.phtml 3305 - function showTimezones() { + function showTimezones($name,$value) { hunk ./provisioning/sip_settings_lib.phtml 3310 - print "",$name); hunk ./provisioning/sip_settings_lib.phtml 3314 - if ($this->timezone==$buffer) { + if ($value==$buffer) { hunk ./provisioning/sip_settings_lib.phtml 4306 - hunk ./provisioning/sip_settings_lib.phtml 5369 - hunk ./provisioning/sip_settings_lib.phtml 5370 + function getBillingProfiles() { + // Get getBillingProfiles + if ($this->SOAPversion < 2) return true; + dprint("getBillingProfiles()"); + + $this->RatingPort->addHeader($this->SoapAuth); + $result = $this->RatingPort->getEntityProfiles("subscriber://".$this->account); + + if (PEAR::isError($result)) { + $error_msg = $result->getMessage(); + $error_fault= $result->getFault(); + $error_code = $result->getCode(); + if ($error_fault->detail->exception->errorcode != "4001") { + printf ("

Error (Rating): %s (%s): %s",$error_msg, $error_fault->detail->exception->errorcode,$error_fault->detail->exception->errorstring); + return false; + } + } + + $this->billingProfiles=$result; + //dprint_r($this->billingProfiles); + + } + + + function showBillingProfiles() { + if ($this->loginType != 'admin' && $this->loginType != 'reseller') { + return true; + } + + $this->getBillingProfiles(); + + $chapter=sprintf(_("Billing profiles")); + $this->showChapter($chapter); + + print " + + "; + print _("Profiles"); + printf (" + + + Weekday: + + Weekend: + + ", + $this->billingProfiles->profileWeekday, + $this->billingProfiles->profileWeekend + ); + + $this->showTimezones('profileTimezone',$this->billingProfiles->timezone); + + print " + + + "; + } + function updateBillingProfiles() { + if ($this->loginType != 'admin' && $this->loginType != 'reseller') { + return true; + } + + $this->RatingPort->addHeader($this->SoapAuth); + $result = $this->RatingPort->getEntityProfiles("subscriber://".$this->account); + + if (PEAR::isError($result)) { + $error_msg = $result->getMessage(); + $error_fault= $result->getFault(); + $error_code = $result->getCode(); + if ($error_fault->detail->exception->errorcode != "4001") { + printf ("

Error (Rating): %s (%s): %s",$error_msg, $error_fault->detail->exception->errorcode,$error_fault->detail->exception->errorstring); + return false; + } + } + + $this->billingProfiles=$result; + + $profiles=array("entity" =>'subscriber://'.$this->account , + "profileWeekday" => trim($_REQUEST['profileWeekday']), + "profileWeekend" => trim($_REQUEST['profileWeekend']), + "timezone" => trim($_REQUEST['profileTimezone']) + ); + + dprint_r($profiles); + + $this->RatingPort->addHeader($this->SoapAuth); + if ($this->billingProfiles->profileWeekday && !$profiles['profileWeekday']) { + // delete profile + $result = $this->RatingPort->deleteEntityProfiles('subscriber://'.$this->account); + if (PEAR::isError($result)) { + $error_msg = $result->getMessage(); + $error_fault= $result->getFault(); + $error_code = $result->getCode(); + if ($error_fault->detail->exception->errorcode != "4001") { + printf ("

Error (Rating): %s (%s): %s",$error_msg, $error_fault->detail->exception->errorcode,$error_fault->detail->exception->errorstring); + return false; + } + } + + } else if ($profiles['profileWeekday']) { + // update profile + + $result = $this->RatingPort->setEntityProfiles($profiles); + if (PEAR::isError($result)) { + $error_msg = $result->getMessage(); + $error_fault= $result->getFault(); + $error_code = $result->getCode(); + if ($error_fault->detail->exception->errorcode != "4001") { + printf ("

Error (Rating): %s (%s): %s",$error_msg, $error_fault->detail->exception->errorcode,$error_fault->detail->exception->errorstring); + return false; + } + } + + } else { + // do nothing + } + }