Esempio n. 1
0
 /**
  * Remove a Carrier
  */
 public function removeAction()
 {
     $this->view->breadcrumb = Snep_Breadcrumb::renderPath(array($this->view->translate("Carrier"), $this->view->translate("Delete")));
     $id = $this->_request->getParam('id');
     // Reset all values
     $data = array('ta' => 0, 'tf' => 0, 'active' => 0);
     $manager = new Snep_Carrier_Manager();
     $manager->save($id, $data);
     $this->_redirect($this->getRequest()->getControllerName());
 }
Esempio n. 2
0
 /**
  * Edit Billing
  */
 public function editAction()
 {
     $this->view->breadcrumb = Snep_Breadcrumb::renderPath(array($this->view->translate("Carrier"), $this->view->translate("Edit")));
     $this->view->url = $this->getFrontController()->getBaseUrl() . '/' . $this->getRequest()->getControllerName();
     $db = Zend_Registry::get('db');
     $id = $this->_request->getParam("id");
     $_carriers = Snep_Carrier_Manager::getAll();
     foreach ($_carriers as $_carrier) {
         $carriers[$_carrier['codigo']] = $_carrier['nome'];
     }
     $this->view->carriers = $carriers;
     $this->view->Carrier = Snep_Billing_Manager::get($id);
     $this->view->billingValues = Snep_Billing_Manager::getBillingValues($id);
     $_estado = Snep_Billing_Manager::getStates();
     foreach ($_estado as $estado) {
         if ($estado['cod'] == $this->view->Carrier['estado']) {
             $this->view->billingState = $estado;
         }
     }
     /* Snep_Form
              *
             $this->view->objSelectBox = "billing";
             $xml = new Zend_Config_Xml( "modules/default/formsbilling.xml" );
             $objCarrier = Snep_Billing_Manager::get($id);        
             $form = new Snep_Form( $xml );
             $form->setAction( $this->getFrontController()->getBaseUrl() .'/'. $this->getRequest()->getControllerName() . '/edit');
     
             $carrier = $form->getElement('carrier');
             $carrier->addDecorator('HtmlTag', array('tag' => 'div', 'id' => 'leftForm', 'openOnly' => true, 'placement' => Zend_Form_Decorator_Abstract::PREPEND ));
             $carrier->setLabel( $this->view->translate('Operadora') );
             
             $_carriers = Snep_Carrier_Manager::getAll();
             if($_carriers) {
                 foreach($_carriers as $_carrier) {
                     $carriers[$_carrier['codigo']] = $_carrier['nome'];
                 }
                 $carrier->setMultiOptions( $carriers );
                 $carrier->setAttrib('disable', true);
                 $carrier->setValue($objCarrier['operadora']);
             }else{
                 $carrier->setDescription( $this->view->translate('Não existem operadoras.') );
                 $carrier->setAttrib('disable', true);
             }
     
             $country = $form->getElement('country');
             $country->setLabel( $this->view->translate('País') );
             $country->setValue($objCarrier['pais']);
             $country->setAttrib('disable', true);
     
             $_states = Snep_Billing_Manager::getStates();
             foreach($_states as $state) {
                 $states[$state['cod']] = $state['name'];
             }        
             $state = $form->getElement('state');
             $state->setLabel( $this->view->translate('Estado') );
             $state->setMultiOptions($states);
             $state->setValue($objCarrier['estado']);
             $state->setAttrib('disable', true);
     
             $city = $form->getElement('city');
             $city->setLabel( $this->view->translate('Cidade') );
             $city->setMultiOptions( Snep_Billing_Manager::getCity($objCarrier['estado']) );
             $city->setValue($objCarrier['cidade']);
             $city->setAttrib('disable', true);
     
             $country_code = $form->getElement('country_code');
             $country_code->setLabel( $this->view->translate('Code País') );
             $country_code->setValue($objCarrier['ddi']);
             $country_code->setAttrib('readonly', true);
     
             $city_code = $form->getElement('city_code');
             $city_code->setLabel( $this->view->translate('Code Cidade') );
             $city_code->setValue($objCarrier['ddd']);
             $city_code->setAttrib('readonly', true);
     
             $prefix = $form->getElement('prefix');
             $prefix->setLabel( $this->view->translate('Prefixo') );
             $prefix->setValue($objCarrier['prefixo']);
             $prefix->addDecorator('HtmlTag', array('tag' => 'div', 'id' => 'selectActions', 'closeOnly' => true, 'placement' => Zend_Form_Decorator_Abstract::APPEND));
             $prefix->setAttrib('readonly', true);
     
             $form->removeElement('tbf');
             $form->removeElement('tbc');
             $formId = new Zend_Form_Element_Hidden('id');
             $formId->setValue($id);
     
             $billingValues = Snep_Billing_Manager::getBillingValues($id);
     
             $form->BillingValues($billingValues);
             
             $form->addElement($formId);
             $form->setButtom();
              *
              */
     if ($this->_request->getPost()) {
         //$form_isValid = $form->isValid($_POST);
         //$dados = $this->_request->getParams();
         if (isset($_POST['action'])) {
             foreach ($_POST['action'] as $ida => $num) {
                 if ($num < count($this->view->billingValues)) {
                     $values = array('data' => $_POST['data'][$num], 'vcel' => $_POST['vcel'][$num], 'vfix' => $_POST['vfix'][$num]);
                     Snep_Billing_Manager::editBilling($id, $values);
                 } else {
                     $values = array('data' => $_POST['data'][$num], 'vcel' => $_POST['vcel'][$num], 'vfix' => $_POST['vfix'][$num]);
                     Snep_Billing_Manager::addBilling($id, $values);
                 }
             }
         }
         $this->_redirect($this->getRequest()->getControllerName() . '/edit/id/' . $id);
         /*
                         if($form_isValid) {
                             Snep_Carrier_Manager::edit($dados);
                             if($dados['box_add']) {
                                 
                                 Snep_Carrier_Manager::clearCostCenter($dados['id']);
         
                                 foreach($dados['box_add'] as $costCenter) {
                                     Snep_Carrier_Manager::setCostCenter( $dados['id'], $costCenter );
                                 }
                             }                    
                             $this->_redirect( $this->getRequest()->getControllerName() );  
                         }
                         * */
     }
 }