1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188
   | public function executeFiltre(sfWebRequest $request) {
        $sexM = $request->getParameter('sexeM');
        $sexF = $request->getParameter('sexeF');
        $ri = $request->getParameter('ri');
        $fr = $request->getParameter('fr');
        $hr = $request->getParameter('hr');
        $tab=array();
        $stadept = $request->getParameter('pt');
        $age = $request->getParameter('age');
        $deco= $request->getParameter('deco');
        $decn= $request->getParameter('decn');
        $sexe = $request->getParameter('sexe');
        $amico = $request->getParameter('AMICO');
        $psd= $request->getParameter('pdebut');
        $psf= $request->getParameter('pfin');
        $leftage = $request->getParameter('deage');
        $rightage = $request->getParameter('aage');
        $p = Doctrine::getTable('Patient')->createQuery('a');
        $q = $p->where('1 = 1');
        $this->tabj=array();
        $this->cnt= 0 ;
  //////////////////prost recap
         if(($psd!= "") &&($psf !=""))
                {
                 $leftpsa=$psd;
                 $rightpsa=$psf;
                 $ma = Doctrine::getTable('ProstateRecap')
		 ->createQuery('a')
                 ->where('a.psa >= ?',$leftpsa)
                 ->andWhere('a.psa < ?',$rightpsa)
		 ->execute();
                 $a=array('null');
                 foreach ($ma as $m)
                    {
                         $a[]=$m->getPatientId();
                    }
                     $this->tabj=array_merge($this->tabj,$a);
                     $this->padebut=$psd;
                     $this->pafin=$psf;
                     $this->cnt++;
                }
//////////////////////////////////////////////////////////////////////////////
        if ( ($ri != "") || ($fr != "") || ($hr != "") )
        { $tableau=array();
          if($ri != "")
          {
             $tableau[]=$ri ;
             $this->ria=$ri;
          }
          if($fr != "")
          {
              $tableau[]=$fr ;
              $this->fra=$fr;
          }
          if($hr != "")
          {
              $tableau[]=$hr ;
              $this->hra=$hr;
          }
            $maa = Doctrine::getTable('ProstateRecap')
                            ->createQuery('k')
                            ->whereIn('k.classification_amico ',$tableau )
                            ->execute();
            $ab = array('null');
 
            foreach ($maa as $m) {
                $ab[] = $m->getPatientId();
            }
             if( $this->cnt != 0)
             {
                $this->tabj=array_merge($this->tabj,$ab);
                $this->tabj = $this->array_doublon($this->tabj);
             }
             else
             {
                $this->tabj=array_merge($this->tabj,$ab);
             }
            $this->ami = $amico;
            $this->cnt++;
        }
/////////////////////////////////////////////////////////////////
        if ($stadept != "") {
            $anapaths = Doctrine::getTable('Anapath')->createQuery('b')->where('b.stade_pt =?', $stadept)->execute();
            $tablepatientid = array('null');
            foreach ($anapaths as $anapath) {
                $tablepatientid[] = $anapath->getPatientId();
            }
            if($this->cnt != 0)
            {
               $this->tabj=array_merge($this->tabj,$tablepatientid);
               $this->tabj = $this->array_doublon($this->tabj);
            }
            else
            {
               $this->tabj=array_merge($this->tabj,$tablepatientid);
            }
            $this->ptt = $stadept;
        }
/////////////////////////////////////////////////////////////////
        if (($leftage != "") && ($rightage !=""))
        {
            $q = $q->addwhere("DATEDIFF( CURDATE(),a.date_of_birth )/365.25 BETWEEN $leftage AND $rightage");
            $this->agedebut= $leftage;
            $this->agefin= $rightage;
        }
 ///////////////////////////// age
        if (($sexM != "") && ($sexF == ""))
        {
            $q = $q->addwhere('a.sex_id =?',$sexM);
            $this->sxM = $sexM;
        }
         if (($sexF != "") &&($sexM == ""))
        {
             $q = $q->addwhere('a.sex_id =?',$sexF);
             $this->sxF = $sexF;
            // $this->sex = $sexe;
        }
        if (($sexF != "") &&($sexM != ""))
        {
             $this->sxM = $sexM;
             $this->sxF = $sexF;
        }
 ///////////////////////////////////decede
       // if ($decede != "") {
            if (($deco !="") &&($decn ==""))
            {
                $q = $q->addwhere('a.date_of_death != ?', 'NULL');
                $this->do = 1;
            }
 
            else
            {
                if (($deco =="") &&($decn !=""))
                {
                     $q = $q->addwhere('a.date_of_death IS NULL');
                     $this->dn = 2;
                }
                else
                {
                   if (($deco !="") &&($decn !=""))
                   {
                      //$q = $q->addwhere('a.date_of_death != ?', 'NULL');
                       $this->do = 1;
                       $this->dn = 2;
                   }
                }
         $q = $q->whereIn('a.id',$this->tabj);
                }
   /////////////////////////////////////////////////////
       $this->patients = $q->execute();
       $this->getUser()->setAttribute("patientstable", $this->patients);
 
    }
    public function executeExcel(sfWebRequest $request)
    {   //$y=$request->getParameter($t);
        $this->executeFiltre($request);
 
        $stadept = $request->getParameter('pt');
       // die($stadept);
        $patients=$this->getUser()->getAttribute("patientstable");
        $file= fopen(sfConfig::get('sf_upload_dir')."/excel.xls", "w") or die ("can't open file.");
        $ptr = ftell($file);
 
      fputs($file,"Recherche de stade pt". "\r\n");
       foreach ($patients as $v) {
 
                fputs($file,$v->getFirstname(). "  " . $v->getName()." ". $v->getDateOfDeath() ." ".$v->getDateOfBirth(). "\r\n");
//           $ms=$ms."<td>". $v."</td>";
 
 
       }
 $f="/excel.xls" ;
 
    session_write_close();
 
    $this->getResponse()->clearHttpHeaders();
    $this->getResponse()->setContentType('application/force-download');
    $this->getResponse()->setHttpHeader('Content-Disposition', 'attachment; filename="' .$f.'"');
    $this->getResponse()->setHttpHeader('Content-Transfer-Encoding', 'binary');
    $this->getResponse()->setHttpHeader('Content-Length', $f);
    $this->getResponse()->setHttpHeader('Connection', 'close');
 
    $this->getResponse()->sendHttpHeaders();
 
    readfile(sfConfig::get('sf_upload_dir') ."/excel.xls");
     throw new sfStopException();
     $this->redirect("prostate_recap/filtre");
    } | 
Partager