public function deleteAction()
 {
     if ($this->request->isPost()) {
         $element = Projecttypes::findFirstByUid($this->request->getPost('uid'));
         $element->deleted = 1;
         $element->save();
     }
 }
 public function indexAction()
 {
     if ($this->request->isPost()) {
         $result = $this->getData();
         $output = json_encode($result, true);
         die($output);
     } else {
         $currentyear = $this->littlehelpers->getCurrentYear();
         $projects = Projects::find(array("conditions" => "deleted=0  AND usergroup=?1", "bind" => array(1 => $this->session->get('auth')['usergroup'])));
         $topics = array();
         foreach ($projects as $project) {
             array_push($topics, $project->topic);
         }
         $clippingoverviews = Clippingsoverview::find(array('conditions' => 'deleted = 0 AND hidden = 0 AND usergroup = ?1 AND overviewyear = ?2', 'bind' => array(1 => $this->session->get('auth')['usergroup'], 2 => date('Y'))));
         $overviewArray = array();
         $monthmap = array(1 => 'Januar', 2 => 'Februar', 3 => 'März', 4 => 'April', 5 => 'Mai', 6 => 'Juni', 7 => 'Juli', 8 => 'August', 9 => 'September', 10 => 'Oktober', 11 => 'November', 12 => 'Dezember');
         foreach ($clippingoverviews as $overview) {
             $overviewArray[$overview->overviewyear][$monthmap[$overview->overviewmonth]] = $overview->filelink;
         }
         $publishableprojecttypes = \reportingtool\Models\Projecttypes::find(array('conditions' => 'deleted=0 AND hidden =0 AND publishable=1'));
         $mediumtypes = Mediumtypes::find(array('conditions' => 'deleted=0 AND hidden=0'));
         $clippingstotal = array();
         $clippingstotalTotal = 0;
         $typecount = 0;
         foreach ($mediumtypes as $mediumtype) {
             $add = 0;
             if ($typecount < 2) {
                 $add = 1000000;
             }
             $clAdd = 0;
             if ($typecount < 2) {
                 $clAdd = 6;
             }
             $clippingobj = new Clippings();
             $stuff = $clippingobj->countMediumtypeClippings($mediumtype->uid);
             $clippingstotalTotal += $stuff->clippingscount;
             $clippingstotal[$mediumtype->uid]['clippingscount'] = number_format($stuff->clippingscount + $clAdd, 0, ",", ".");
             $clippingstotal[$mediumtype->uid]['mediumreach'] = number_format($stuff->mediumreach + $add, 0, ",", ".");
         }
         $lead = \reportingtool\Models\Documents::findFirst(array('conditions' => 'usergroup = ?1', 'bind' => array(1 => $this->session->get('auth')['usergroup'])));
         $topics = array_unique($topics);
         $this->view->setVar('leads', $lead->title);
         $this->view->setVar('total', number_format($clippingstotalTotal, 0, ",", "."));
         $this->view->setVar('mediumtypes', $mediumtypes);
         $this->view->setVar('clippingstotal', $clippingstotal);
         $this->view->setVar('topics', $topics);
         $this->view->setVar('projects', $projects);
         $this->view->setVar('overviewarray', $overviewArray);
         $this->view->setVar('publishableprojecttypes', $publishableprojecttypes);
     }
 }
 public function updateAction()
 {
     if ($this->request->isPost()) {
         $result = $this->getClippingData();
         $output = json_encode($result, true);
         die($output);
     } else {
         $projectUid = $this->dispatcher->getParam("uid") ? $this->dispatcher->getParam("uid") : 0;
         $project = Projects::findFirstByUid($projectUid);
         $projecttypes = Projecttypes::find(array('conditions' => 'deleted=0 AND hidden=0'));
         $ptypesArr = array();
         foreach ($projecttypes as $projecttype) {
             $ptypesArr[$projecttype->uid] = $projecttype->title;
         }
         $documents = $project->getDocuments(array('contidions' => 'deleted = 0 AND hidden = 0', 'order' => 'crdate DESC'));
         $this->view->setVar('document', count($documents) > 0 ? $documents[0]->filelink : '');
         $this->view->setVar('project', $project);
         $this->view->setVar('ptypesarr', $ptypesArr);
         $this->view->setVar('projectstates', array('in Vorbereitung', 'in Abstimmung', 'live', 'abgeschlossen'));
         $this->view->setVar('projectstate', $project->getProjectstates(array('conditions' => 'deleted=0 AND hidden=0 AND active=1'))[0]);
     }
 }
 public function requestInitialize($controllerName)
 {
     $this->view->setTemplateAfter('main');
     $this->view->setVars(array('version' => $this->config->application->version));
     if ($this->config->application->debug) {
         $baseUrl = $this->config->application->development->baseUri;
     } else {
         $baseUrl = $this->config->application->production->baseUri;
     }
     /**
      * Docs path and CDN url
      */
     $lang = $this->getUriParameter('language');
     $lang = $lang ? $lang : 'de';
     /**
      * Find the languages available
      */
     $languages = $this->config->languages;
     $languagesAvailable = '';
     $selected = '';
     $url = $this->request->getScheme() . '://' . $this->request->getHttpHost() . $baseUrl;
     $uri = $this->router->getRewriteUri();
     foreach ($languages as $key => $value) {
         $selected = $key == $lang ? " selected='selected'" : '';
         $href = $url . str_replace("/{$lang}", "{$key}", $uri);
         $languagesAvailable .= "<option value='{$href}'{$selected}>{$value}</option>";
     }
     $projectTypes = Projecttypes::find(array('conditions' => 'deleted = 0 AND hidden = 0', 'order' => 'tstamp ASC'));
     $mediumtypes = Mediumtypes::find(array('conditions' => 'deleted = 0 AND hidden = 0'));
     $this->lang = $lang;
     $this->view->setVar('mediumtypes', $mediumtypes);
     $this->view->setVar('projecttypes', $projectTypes);
     $this->view->setVar('controller', $controllerName);
     $this->view->setVar('language', $this->lang);
     $this->view->setVar('baseurl', $baseUrl);
     $this->view->setVar('languages_available', $languagesAvailable);
     $this->host = 'http://' . $_SERVER['SERVER_NAME'];
     $this->view->setVar('host', $this->host);
 }