public function indexAction()
 {
     $form = new WebservicexForm();
     $form->get('submit')->setValue('Add');
     $request = $this->getRequest();
     if ($request->isPost()) {
         $service = new Webservicex();
         $form->setInputFilter($service->getInputFilter());
         $form->setData($request->getPost());
         if ($form->isValid()) {
             $service->exchangeArray($form->getData());
             //     $this->getContactTable()->saveContact($service);
             $soapcall = new Soapclient();
             $this->soap_options = array('soap_version' => SOAP_1_2, 'compression' => SOAP_COMPRESSION_ACCEPT);
             $client = $soapcall->Soap_Connect($this->soap_url, $this->soap_options);
             $options = array('FromCurrency' => $request->getPost("fromcurrency"), 'ToCurrency' => $request->getPost("tocurrency"));
             $results = $soapcall->Webservicex_SOAP_ConversionRate($client, $options);
             $RateResult = $results->ConversionRateResult;
             if (is_float($RateResult)) {
                 $RateResult = $RateResult;
             } else {
                 $RateResult = "No results";
             }
             // Return values to view
             $results = array('value' => array('fromcurrency' => $request->getPost("fromcurrency"), 'tocurrency' => $request->getPost("tocurrency"), 'rate' => $RateResult));
             // Redirect to list of albums
             //return $this->redirect()->toRoute('webservicex');
             return new ViewModel(array('form' => $form, 'Values' => $results));
         }
     }
     return array('form' => $form);
 }
 public function indexAction()
 {
     $form = new KowabungaForm();
     $form->get('submit')->setValue('Add');
     $request = $this->getRequest();
     if (!$this->client) {
         $soapcall = new Soapclient();
         $this->soap_options = array('soap_version' => SOAP_1_2, 'compression' => SOAP_COMPRESSION_ACCEPT);
         $this->client = $soapcall->Soap_Connect($this->soap_url, $this->soap_options);
     }
     // Before Submitting we can get some info on values from the SOAP server.
     // Get the latest updated time
     if (!$this->last_update) {
         $return = $soapcall->Kowabunga_SOAP_GetLastUpdateDate($this->client, false);
         $this->last_update = $return->GetLastUpdateDateResult;
     }
     if ($request->isPost()) {
         $service = new Kowabunga();
         $form->setInputFilter($service->getInputFilter());
         $form->setData($request->getPost());
         if ($form->isValid()) {
             $service->exchangeArray($form->getData());
             $array = array("CurrencyFrom" => $request->getPost("fromcurrency"), "CurrencyTo" => $request->getPost("tocurrency"), "RateDate" => $request->getPost("ratedate"), "Amount" => $request->getPost("amount"));
             $return = $soapcall->Kowabunga_SOAP_GetConversionAmount($this->client, $array);
             // Will return as value not as array
             //print_r($return);
             if (isset($return->GetConversionAmountResult)) {
                 $this->amount = $return->GetConversionAmountResult;
             } else {
                 $this->amount = "No amount results";
             }
             $array = array("CurrencyFrom" => $request->getPost("fromcurrency"), "CurrencyTo" => $request->getPost("tocurrency"), "RateDate" => $request->getPost("ratedate"));
             $return = $soapcall->Kowabunga_SOAP_GetConversionRate($this->client, $array);
             // Will return as value not as array
             $this->rate = $return->GetConversionRateResult;
             if (isset($return->GetConversionRateResult)) {
                 $this->rate = $return->GetConversionRateResult;
             } else {
                 $this->rate = "No rate results";
             }
             // Return values to view
             $results = array('value' => array('fromcurrency' => $request->getPost("fromcurrency"), 'tocurrency' => $request->getPost("tocurrency"), 'ratedate' => $request->getPost("ratedate"), 'dateupdate' => $this->last_update, 'postamount' => $request->getPost("amount"), 'amount' => $this->amount, 'rate' => $this->rate));
             // Redirect to list of albums
             //return $this->redirect()->toRoute('webservicex');
             return new ViewModel(array('form' => $form, 'Values' => $results));
         }
     }
     $results = array('value' => array('dateupdate' => $this->last_update));
     return array('form' => $form, 'Values' => $results);
 }