public function indexAction()
 {
     $this->_helper->layout->setLayout('full');
     $event_id = $this->_getParam('id');
     if ($this->getRequest()->isGet()) {
         $proxy = new SxCms_Event_DataMapper();
         $event = $proxy->getEventById($event_id);
     }
     if ($this->getRequest()->isPost()) {
         $proxy = new SxCms_Event_DataMapper();
         $event = $proxy->getEventById($event_id);
         $subscription = array();
         $errors = array();
         foreach ($event->getFields() as $field) {
             if (!$this->_getParam($field->getName())) {
                 $errors[$field->getName()] = $field->getLabel();
             }
             $subscription[$field->getName()] = $this->_getParam($field->getName());
         }
         if (sizeof($errors) == 0) {
             $Subscription = new SxCms_Event_Subscription();
             $Subscription->setEventId($event_id);
             if ($event->isValidateIntern()) {
                 $Subscription->setStatus(0);
                 $sub_id = $Subscription->save();
             } else {
                 $Subscription->setStatus(1);
                 $sub_id = $Subscription->save();
                 $Subscription->sendConfirmation();
             }
             foreach ($event->getFields() as $field) {
                 if ($field->getType() == 'checkbox') {
                     $value = implode(';', $this->_getParam($field->getName()));
                 } else {
                     $value = $this->_getParam($field->getName());
                 }
                 $SubF = new SxCms_Event_Subscription_Field();
                 $SubF->setSubscriptionId($sub_id)->setFieldId($field->getId())->setName($field->getName())->setValue($value);
                 $SubF->save();
             }
             $this->view->result = true;
         } else {
             $this->view->errors = $errors;
         }
         $this->view->subscription = $subscription;
     }
     $mapperSub = new SxCms_Event_Subscription_DataMapper();
     $subscriptions = $mapperSub->getSubscriptionsForEvent($event_id);
     $now = strtotime(date('Y-m-d'));
     if (count($subscriptions) >= $event->getSubscriptionMax() || strtotime($event->getDateEnd()) < $now || strtotime($event->getDateStart()) > $now) {
         $event->setSubscriptionAllow(false);
     }
     $this->view->subscriptions = $subscriptions;
     $this->view->event = $event;
     $this->getResponse()->setHeader('Last-Modified', $event->getDateStart("%a, %d %b %Y %H:%I%S GMT"));
 }
 public function deleteAction()
 {
     SxCms_Acl::requireAcl('event', 'event.delete');
     $event_id = $this->_getParam('id');
     $proxy = new SxCms_Event_DataMapper();
     $this->_event = $proxy->getEventById($event_id);
     $this->_event->delete();
     $flashMessenger = $this->_helper->getHelper('FlashMessenger');
     $flashMessenger->addMessage($this->admin_tmx->_('eventdeleted'));
     $this->_helper->redirector->gotoSimple('index', 'event');
 }
Exemple #3
0
 public function save()
 {
     $db = Zend_Registry::get('db');
     $config = Zend_Registry::get('config');
     $identity = Zend_Auth::getInstance()->getIdentity();
     /* save event */
     $eventData = array('subscription_allow' => $this->isSubscriptionAllow(), 'subscription_max' => (int) $this->getSubscriptionMax(), 'notify_email' => $this->getNotifyEmail(), 'date_start' => $this->getDateStart('%Y-%m-%d'), 'date_end' => $this->getDateEnd('%Y-%m-%d'), 'datetime_event' => $this->getDateEvent('%Y-%m-%d') . ' ' . $this->getTimeEvent('%H:%M:%S'), 'location' => $this->getLocation(), 'remember_days' => $this->getRememberDays(), 'confirmation_link' => $this->isConfirmationLink(), 'validate_intern' => $this->isValidateIntern());
     if ($this->getId() === false) {
         $event_id = $db->insert('Event', $eventData);
         $event_id = $db->lastInsertId();
     } else {
         $event_id = $this->getId();
         $db->update('Event', $eventData, 'event_id = ' . $event_id);
     }
     /* save tsl */
     $eventTsl = array('event_id' => $event_id, 'title' => $this->getTitle(), 'description' => $this->getDescription(), 'mail_remember' => $this->getMailRemember(), 'mail_confirmation' => $this->getMailConfirmation());
     if ($this->getId() === false) {
         /*** Events hetzelfde NL/FR ***/
         /*foreach ($config->system->language as $lng => $slng) {
         	 $eventTsl['language'] = $lng;
         	 $db->insert('EventTsl', $eventTsl);
         	 }*/
         /*** Events verschillend NL/FR ***/
         $system = new Zend_Session_Namespace('System');
         $eventTsl['language'] = $system->lng;
         $db->insert('EventTsl', $eventTsl);
     } else {
         $db->update('EventTsl', $eventTsl, 'event_id = ' . $this->getId() . ' AND language = \'' . $this->getLanguage() . '\'');
     }
     /* save fields */
     $tmpEvent = SxCms_Event_DataMapper::getEventById($this->getId());
     foreach ($tmpEvent->getFields() as $field) {
         $field->delete();
     }
     if ($this->getId() === false) {
         $lngs = $config->system->language;
     } else {
         $lngs[$this->getLanguage()] = null;
     }
     foreach ($lngs as $lng => $slng) {
         foreach ($this->getFields() as $field) {
             $field->setEventId($event_id);
             $field->setLanguage($lng);
             $field->save();
         }
     }
 }
 public function exportAction()
 {
     SxCms_Acl::requireAcl('subscriptions', 'subscription.export');
     $event_id = $this->_getParam('id');
     $eventMapper = new SxCms_Event_DataMapper();
     $event = $eventMapper->getEventById($event_id);
     $subProxy = new SxCms_Event_Subscription_DataMapper();
     $subscriptions = $subProxy->getValidSubscriptionsForEvent($event_id);
     $fieldProxy = new SxCms_Event_Field_DataMapper();
     $fields = $fieldProxy->getFieldsByEvent($event_id);
     $objPHPExcel = new PHPExcel();
     $objPHPExcel->createSheet("Event Subsciptions");
     $objPHPExcel->setActiveSheetIndex(0);
     $objPHPSheet = $objPHPExcel->getActiveSheet();
     $objPHPSheet->setCellValueByColumnAndRow(0, 1, $this->admin_tmx->_('subscriptionsforevent') . $event->getTitle());
     $i = 0;
     foreach ($fields as $field) {
         $objPHPSheet->setCellValueByColumnAndRow($i, 2, $field->getLabel());
         $i++;
     }
     $j = 3;
     foreach ($subscriptions as $subscription) {
         $i = 0;
         foreach ($fields as $field) {
             $objPHPSheet->setCellValueByColumnAndRow($i, $j, $subscription[$field->getName()]);
             $i++;
         }
         $j++;
     }
     $file = "sub_" . date("d_m_Y") . ".xls";
     header("Pragma: public");
     header("Expires: 0");
     header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
     header("Content-Type: application/force-download");
     header("Content-Type: application/octet-stream");
     header("Content-Type: application/download");
     header("Content-Disposition: attachment; filename={$file}");
     header("Content-Transfer-Encoding: binary");
     error_reporting(0);
     $objWriter = new PHPExcel_Writer_Excel5($objPHPExcel);
     $objWriter->setTempDir(APPLICATION_ROOT . '/tmp');
     $objWriter->save("php://output");
     die;
 }