public function deleteAction()
 {
     if ($this->request->isPost()) {
         $element = Documents::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);
     }
 }