Ejemplo n.º 1
0
 function create()
 {
     $countryIso = \Yoda\Request::getString('country_iso');
     $customer_id = \Yoda\Request::getInt('customer_id');
     $city_id = \Yoda\Request::getInt('city_id');
     $period = \Yoda\Request::getInt('period');
     $autorenew = \Yoda\Request::getBool('autorenew');
     $pbxwwForm = \Yoda\Request::getInt('pbxww_form');
     $prepaid_funds = \Yoda\Request::getFloat('prepaid_funds');
     $order = new Didww\API2\Order();
     $order->setCustomerId($customer_id);
     $order->setCountryIso($countryIso);
     $order->setPeriod($period);
     if ($pbxwwForm) {
         $mapping = new Didww\API2\Mapping\PBXww();
     } else {
         $map_type = \Yoda\Request::getString('map_type');
         $map_proto = \Yoda\Request::getString('map_proto');
         $host = \Yoda\Request::getString('host');
         $map_details = \Yoda\Request::getString('map_details');
         switch ($map_type) {
             case 'gtalk':
                 $mapping = new Didww\API2\Mapping\Gtalk($map_details);
                 break;
             case 'pstn':
                 $mapping = new Didww\API2\Mapping\PSTN($map_details);
                 break;
             case 'voip':
                 switch ($map_proto) {
                     case 'sip':
                         $mapping = new Didww\API2\Mapping\SIP($host, $map_details);
                         break;
                     case 'h323':
                         $mapping = new Didww\API2\Mapping\H323($host, $map_details);
                         break;
                     case 'iax':
                         $mapping = new Didww\API2\Mapping\IAX($host, $map_details);
                         break;
                     default:
                 }
                 break;
             case 'pbxww':
                 $mapping = new Didww\API2\Mapping\PBXww();
                 break;
             default:
                 break;
         }
     }
     $order->setMapData($mapping);
     $order->setCityId($city_id);
     $order->setAutorenewEnable($autorenew);
     $order->setPrepaidFunds($prepaid_funds);
     try {
         $did_number = $order->createNumber();
         $this->setMessage('DID #' . $did_number->getNumber() . ' was purchased successfully');
     } catch (SoapFault $e) {
         $this->setMessage('Error: (' . $e->faultcode . ') ' . $e->faultstring, 'danger');
     }
     $this->redirect($pbxwwForm ? 'index.php?controller=orders&action=add&customer_id=' . $customer_id . '&pbxww_form=1' : 'index.php?controller=customers');
 }
Ejemplo n.º 2
0
 function login()
 {
     $userName = \Yoda\Request::getString('username');
     $password = \Yoda\Request::getString('password');
     $testMode = \Yoda\Request::getBool('test_mode');
     try {
         APIHelper::setupClient($userName, $password, $testMode);
         $details = new ApiDetails();
     } catch (SoapFault $e) {
         $this->redirect('index.php?controller=authorize', 'Error: (' . $e->faultcode . ') ' . $e->faultstring, 'error');
     } catch (Exception $e) {
         $this->redirect('index.php?controller=authorize', $e->getMessage(), 'error');
     }
     $_SESSION['username'] = $userName;
     $_SESSION['resellerKey'] = $password;
     $_SESSION['isTestMode'] = $testMode;
     $_SESSION['reseller_id'] = $details->getResellerId();
     $this->redirect('index.php');
 }