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 update()
 {
     $customer_id = \Yoda\Request::getInt('customer_id');
     $amount = \Yoda\Request::getFloat('amount');
     try {
         $balance = new Didww\API2\Balance();
         $balance->setCustomerId($customer_id);
         $balance->changeBalance($amount);
         $this->setMessage($amount . ' points was added to customer ID #' . $customer_id);
     } catch (SoapFault $e) {
         $this->setMessage("Error: (" . $e->faultcode . ") " . $e->faultstring, 'danger');
         $this->redirect('index.php?controller=balance&action=add');
     } catch (Exception $e) {
         $this->setMessage($e->getMessage(), 'danger');
         $this->redirect('index.php?controller=balance&action=add');
     }
     $this->redirect('index.php?controller=customers');
 }