コード例 #1
0
 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);
     }
 }
コード例 #2
0
 public function updateAction()
 {
     if ($this->request->isPost()) {
         $time = time();
         $usergroup = Usergroups::findFirstByUid($this->request->getPost('usergroup'));
         $filename = $this->littlehelpers->saveFile($this->request->getUploadedFiles(), $time, $usergroup);
         $clippingUid = $this->dispatcher->getParam("uid") ? $this->dispatcher->getParam("uid") : 0;
         $clipping = Clippingsoverview::findFirstByUid($clippingUid);
         $clipping->assign(array('cruser_id' => $this->session->get('auth')['uid'], 'usergroup' => $this->request->getPost('usergroup'), 'tstamp' => $this->littlehelpers->processDate($this->request->getPost('tstamp')), 'crdate' => $time, 'overviewyear' => $this->request->getPost('overviewyear'), 'overviewmonth' => $this->request->getPost('overviewmonth'), 'filelink' => $filename));
         if (!$clipping->update()) {
             $this->flashSession->error($clipping->getMessages());
         } else {
             $this->response->redirect('backend/' . $this->view->language . '/clippingsoverview/update/' . $clipping->uid . '/');
             $this->flashSession->success($this->translate('successUpdate'));
             $this->view->disable();
         }
     } else {
         $clippingUid = $this->dispatcher->getParam("uid") ? $this->dispatcher->getParam("uid") : 0;
         $clipping = Clippingsoverview::findFirstByUid($clippingUid);
         $usergroup = Usergroups::findFirstByUid($clipping->usergroup);
         $this->view->setVar('usergroup', $usergroup);
         $this->view->setVar('clipping', $clipping);
     }
 }