Exemplo n.º 1
0
 public function saveCampaign(GCampaign $campaign)
 {
     $data = $campaign->getFullData();
     if ($data['LAST_VERSION'] == null) {
         $data['LAST_VERSION'] = 1;
         // Tambien controlado por trigger
     }
     echo var_dump($data);
     $id_campana = (int) $campaign->id_campana;
     if ($id_campana == 0) {
         $this->tableGateway->insert($data);
     } else {
         if ($this->getCampaign($id_campana)) {
             $this->tableGateway->update($data, array('ID_CAMPANA' => $id_campana));
         } else {
             //throw new \Exception("Could not find row $uid");
             return null;
         }
     }
 }
Exemplo n.º 2
0
 public function addAction()
 {
     $form = new CampaignForm();
     $user = $this->getUserTable()->getUserFromUserName($this->getUserLogued());
     $form->get('ID_SPONSOR')->setValue($user->uid);
     $request = $this->getRequest();
     if ($request->isPost()) {
         $campaign = new GCampaign();
         //$form->setInputFilter($campaign->getInputFilter());
         $form->setData($request->getPost());
         if ($form->isValid()) {
             $campaign->exchangeArray($form->getData());
             $campaign::getTableIO($this->getServiceLocator()->get('Zend\\Db\\Adapter\\Adapter'))->saveCampaign($campaign);
             // Redirect to list of albums
             $this->addInfoMessage(GeneralMessages::CAMPAIGN_ADD_OK);
             return $this->redirect()->toRoute('myaccount/campaign');
         } else {
             $this->addErrorMessage(GeneralMessages::FORM_ERROR);
             return $this->redirect()->toRoute('myaccount/campaign', array('action' => 'add'));
         }
     }
     return array('form' => $form);
 }
Exemplo n.º 3
0
 public static function getTableIO($adapter)
 {
     return new GCampaignTable(GCampaign::getTableGateway($adapter));
 }