예제 #1
0
 public function executeGInformes(sfWebRequest $request)
 {
     $this->setLayout('gestio');
     $this->IDS = $this->getUser()->getSessionPar('idS');
     $this->POTVEURE = array(1 => true);
     //$this->POTVEURE = array(1=>UsuarisPeer::canSeeComptabilitat($this->getUser()->getSessionPar('idU')));
     $this->accio = $request->getParameter('accio');
     $this->getUser()->addLogAction('inside', 'gInformes');
     if ($request->hasParameter('BGENERADOC')) {
         $this->accio = 'RESUM_ACTIVITATS';
     }
     if ($request->hasParameter('BGENERAXML')) {
         $this->accio = 'RESUM_ACTIVITATS';
     }
     if ($request->hasParameter('BGENERACSV')) {
         $this->accio = 'RESUM_ACTIVITATS';
     }
     switch ($this->accio) {
         case 'MAT_DIA_PAG':
             $this->MODE = $request->getParameter('mode_pagament');
             $this->DADES = array();
             foreach (MatriculesPeer::getMatriculesPagadesDia($this->MODE, $this->IDS) as $OM) {
                 $OU = $OM->getUsuaris();
                 $OC = $OM->getCursos();
                 $this->DADES[$OM->getIdmatricules()]['DATA'] = $OM->getDatainscripcio('d/m/Y');
                 $this->DADES[$OM->getIdmatricules()]['IMPORT'] = $OM->getPagat();
                 $this->DADES[$OM->getIdmatricules()]['DNI'] = $OU->getDni();
                 $this->DADES[$OM->getIdmatricules()]['NOM'] = $OU->getNomComplet();
                 $this->DADES[$OM->getIdmatricules()]['CURS'] = $OC->getCodi();
                 $this->DADES[$OM->getIdmatricules()]['HORA'] = $OM->getDatainscripcio('H:i');
                 $this->DADES[$OM->getIdmatricules()]['ORDER'] = $OM->getTpvOperacio();
                 $this->DADES[$OM->getIdmatricules()]['ESTAT'] = $OM->getEstat();
                 $this->DADES[$OM->getIdmatricules()]['ESTATS'] = $OM->getEstatString();
                 $this->DADES[$OM->getIdmatricules()]['PAGAMENT'] = $OM->getTpagamentString();
             }
             break;
             //Treu un resum de les activitats aplicant-hi les etiquetes corresponents
         //Treu un resum de les activitats aplicant-hi les etiquetes corresponents
         case 'RESUM_ACTIVITATS':
             $RP = $request->getParameter('informe_activitats');
             $this->FACTIVITATS = new InformeActivitatsForm(null, array('IDS' => $this->IDS));
             $this->FACTIVITATS->bind($RP);
             if ($request->hasParameter('BGENERADOC')) {
                 $this->LOA = ActivitatsPeer::getLlistatWord($this->FACTIVITATS, $this->IDS, true, false);
             } elseif ($request->hasParameter('BGENERACSV')) {
                 $this->LOH = ActivitatsPeer::getLlistatWord($this->FACTIVITATS, $this->IDS, false, true);
                 $nom = OptionsPeer::getString('SF_WEBSYSROOT', $this->IDS) . 'tmp/' . $this->IDS . 'NEWS.csv';
                 $file = fopen($nom, 'w');
                 foreach ($this->LOH as $OH) {
                     $OA = $OH->getActivitats();
                     $LE = $OH->getArrayEspais();
                     foreach ($LE as $OE) {
                         if ($OE->getEspaiid() == 2 || $OE->getEspaiid() == 4 || $OE->getEspaiid() == 19 || $OE->getEspaiid() == 5) {
                             $pis = "P1";
                         } elseif ($OE->getEspaiid() > 9 && $OE->getEspaiid() < 16) {
                             $pis = "P2";
                         } else {
                             $pis = "PB";
                         }
                         if (stripos($OE->getNom(), "Fita") > 0) {
                             $Nom_espai = "Sala Domènech Fita";
                         } elseif (stripos($OE->getNom(), "A+B") > 0) {
                             $Nom_espai = "Sala d'exposicions";
                         } else {
                             $Nom_espai = $OE->getNom();
                         }
                         fputcsv($file, array($OA->getTmig(), $OH->getDia('d/m/Y'), $OH->getHoraInici('H:i'), $Nom_espai, $pis, $OA->getOrganitzador()), ",", "\"");
                     }
                 }
                 fclose($file);
                 $response = sfContext::getInstance()->getResponse();
                 $response->setContentType('text/plain');
                 $response->setHttpHeader('Content-Disposition', 'attachment; filename="Agenda.csv');
                 $response->setHttpHeader('Content-Length', filesize($nom));
                 $response->setContent(file_get_contents($nom, false));
                 $response->sendHttpHeaders();
                 $response->sendContent();
                 throw new sfStopException();
             } elseif ($request->hasParameter('BGENERAXML')) {
                 $this->setLayout(null);
                 $this->setTemplate(null);
                 $LOH = ActivitatsPeer::getLlistatWord($this->FACTIVITATS, $this->IDS, false);
                 //Creem l'objecte XML
                 $i = 1;
                 $document = "<document>\n";
                 foreach ($LOH as $OH) {
                     $OA = $OH->getActivitats();
                     $LE = $OH->getArrayEspais();
                     $document .= "<caixa>\n";
                     $document .= "  <data_inicial>" . $OA->getPrimerHorari()->getDia('Y-m-d') . "</data_inicial>\n";
                     $document .= "  <data_fi>" . $OA->getUltimHorari()->getDia('Y-m-d') . "</data_fi>\n";
                     $document .= "  <tipus_activitat>" . $OA->getNomTipusActivitat() . "</tipus_activitat>\n";
                     $document .= "  <cicle>" . $OA->getCicles()->getTmig() . "</cicle>\n";
                     $document .= "  <tipologia>" . $OA->getCategories() . "</tipologia>\n";
                     $document .= "  <importancia>" . $OA->getImportancia() . "</importancia>\n";
                     $document .= "  <titol>" . $OA->getTmig() . "</titol>\n";
                     $document .= "  <text>" . strip_tags(html_entity_decode($OA->getDmig())) . "</text>\n";
                     $document .= "  <url>" . $this->getController()->genUrl('@web_menu_click_activitat?idCicle=' . $OA->getCiclesCicleid() . '&idActivitat=' . $OA->getActivitatid() . '&titol=' . $OA->getNomForUrl(), true) . "</url>\n";
                     $document .= "  <hora_inici>" . $OH->getHorainici("H.i") . "</hora_inici>\n";
                     $document .= "  <hora_fi>" . $OH->getHorafi("H.i") . "</hora_fi>\n";
                     $document .= "  <espais>" . implode(",", $LE) . "</espais>\n";
                     $document .= "  <organitzador>" . html_entity_decode($OA->getOrganitzador()) . "</organitzador>\n";
                     $document .= "  <info_practica>" . strip_tags(html_entity_decode($OA->getInfopractica())) . "</info_practica>\n";
                     $document .= "  <url_img_s>http://www.hospici.cat/images/activitats/A-" . $OA->getActivitatid() . "-M.jpg</url_img_s>\n";
                     $document .= "  <url_img_m>http://www.hospici.cat/images/activitats/A-" . $OA->getActivitatid() . "-L.jpg</url_img_m>\n";
                     $document .= "  <url_img_l>http://www.hospici.cat/images/activitats/A-" . $OA->getActivitatid() . "-XL.jpg</url_img_l>\n";
                     $document .= "</caixa>\n";
                 }
                 $document .= "</document>\n";
                 $nom = OptionsPeer::getString('SF_WEBSYSROOT', $this->IDS) . 'tmp/' . $this->IDS . 'NEWS.txt';
                 fwrite(fopen($nom, 'w'), $document);
                 $response = sfContext::getInstance()->getResponse();
                 $response->setContentType('text/plain');
                 $response->setHttpHeader('Content-Disposition', 'attachment; filename="News.txt');
                 $response->setHttpHeader('Content-Length', filesize($nom));
                 $response->setContent(file_get_contents($nom, false));
                 $response->sendHttpHeaders();
                 $response->sendContent();
                 throw new sfStopException();
             }
             break;
             //Mostra les activitats a quatre mesos vista que estan marcats com a publicables per web.
         //Mostra les activitats a quatre mesos vista que estan marcats com a publicables per web.
         case 'CONTINGUT_WEB':
             //Carrego les activitats
             $dia = date('d');
             $mes = date('m');
             $any = date('Y');
             $inici = mktime(0, 0, 0, $mes, $dia, $any);
             $fi = mktime(0, 0, 0, $mes + 5, $dia, $any);
             $LLISTAT_ACTIVITATS_WEB = array();
             $LOH = HorarisPeer::cerca(null, null, $inici, $fi, null, $this->IDS);
             foreach ($LOH as $id => $OH) {
                 $OA = $OH->getActivitats();
                 //Si és una activitat correcta... la consultem.
                 if ($OA instanceof Activitats) {
                     $id = $OA->getActivitatid();
                     //Si es pot publicar al web
                     if (!isset($LLISTAT_ACTIVITATS_WEB[$id]) && $OA->getPublicaweb()) {
                         $LLISTAT_ACTIVITATS_WEB[$id]['OA'] = $OA;
                         $LLISTAT_ACTIVITATS_WEB[$id]['text'] = strlen($OA->getTmig()) > 5;
                         $LLISTAT_ACTIVITATS_WEB[$id]['desc'] = strlen($OA->getDmig()) > 5;
                         $LLISTAT_ACTIVITATS_WEB[$id]['img_m'] = file_exists(getcwd() . '/images/activitats/A-' . $id . '-M.jpg');
                         $LLISTAT_ACTIVITATS_WEB[$id]['img_l'] = file_exists(getcwd() . '/images/activitats/A-' . $id . '-L.jpg');
                         $LLISTAT_ACTIVITATS_WEB[$id]['img_xl'] = file_exists(getcwd() . '/images/activitats/A-' . $id . '-XL.jpg');
                         $LLISTAT_ACTIVITATS_WEB[$id]['nivell'] = $OA->getImportancia();
                     } else {
                         $LLISTAT_ACTIVITATS_WEB[$id]['OA'] = $OA;
                         $LLISTAT_ACTIVITATS_WEB[$id]['text'] = strlen($OA->getTmig()) > 5;
                         $LLISTAT_ACTIVITATS_WEB[$id]['desc'] = strlen($OA->getDmig()) > 5;
                         $LLISTAT_ACTIVITATS_WEB[$id]['img_m'] = file_exists(getcwd() . '/images/activitats/A-' . $id . '-M.jpg');
                         $LLISTAT_ACTIVITATS_WEB[$id]['img_l'] = file_exists(getcwd() . '/images/activitats/A-' . $id . '-L.jpg');
                         $LLISTAT_ACTIVITATS_WEB[$id]['img_xl'] = file_exists(getcwd() . '/images/activitats/A-' . $id . '-XL.jpg');
                         $LLISTAT_ACTIVITATS_WEB[$id]['nivell'] = $OA->getImportancia();
                     }
                 }
             }
             $this->LLISTAT_ACTIVITATS_WEB = $LLISTAT_ACTIVITATS_WEB;
             break;
     }
 }