$objPHPExcel->setActiveSheetIndex(0)->setCellValue('A1', 'Készítette:')->setCellValue('B1', $admin_username);
         $objPHPExcel->setActiveSheetIndex(0)->setCellValue('A2', 'Dátum:')->setCellValue('B2', $date_created);
         $objPHPExcel->setActiveSheetIndex(0)->setCellValue('A3', 'Riport intervallum:')->setCellValue('B3', $from_date)->setCellValue('C3', $to_date);
         $objPHPExcel->setActiveSheetIndex(0)->setCellValue('A5', 'Felhasználónév')->setCellValue('B5', 'Foglalás dátuma')->setCellValue('C5', 'Pálya')->setCellValue('D5', 'Összeg');
         $objPHPExcel->getActiveSheet()->getStyle("A1:A3")->getFont()->setBold(true);
         $objPHPExcel->getActiveSheet()->getStyle("A5:D5")->getFont()->setBold(true);
         $row = 6;
         foreach ($reservations as $res) {
             $objPHPExcel->getActiveSheet()->setCellValue('A' . $row, $res->username)->setCellValue('B' . $row, $res->add_date)->setCellValue('C' . $row, $res->timeunit->court->name)->setCellValue('D' . $row, $res->price);
             $row++;
         }
         $objPHPExcel->getActiveSheet()->setCellValue('A' . $row, 'Összesen:')->setCellValue('C' . $row, $ret['reservationsCount'] . ' db')->setCellValue('D' . $row, $ret['reservationsIncome'] . ' Ft');
         $objPHPExcel->getActiveSheet()->getStyle("A" . $row . ":D" . $row)->getFont()->setBold(true);
         $objPHPExcel->getActiveSheet()->getStyle("C" . $row . ":D" . $row)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT);
         $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
         $rnd = STRING::Random(10);
         $bfn = 'report_' . $date_created_fn . '.xlsx';
         $fn = 'reports/' . $bfn;
         $objWriter->save($fn);
         header('Content-disposition: filename="' . $bfn . '"');
         header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
         echo file_get_contents($fn);
     } else {
         header("Access-Control-Allow-Origin: *");
         header('Content-Type: application/json');
         echo json_encode($ret);
     }
 } else {
     header("Access-Control-Allow-Origin: *");
     header('Content-Type: application/json');
     echo json_encode($ret);
Ejemplo n.º 2
0
    public function save()
    {
        if ($this->valid !== true) {
            throw new UserNotValid("Please call is_valid() before saving!");
        }
        global $DB;
        if ($this->reg_date == "") {
            $this->activation_key = @STRING::Random(8);
        }
        $sql = '
				INSERT INTO users
				(`username`,`password`,`full_name`,`email`,`phone`,`birthday`,`discount`,`status`,`activation_key`,`reg_date`)
				VALUES(:username,MD5(:password),:full_name,:email,:phone,:birthday,0,0,:activation_key,NOW())
				ON DUPLICATE KEY UPDATE full_name=:full_name, phone=:phone, birthday=:birthday, discount=:discount
			';
        $sth = $DB->prepare($sql);
        $sth->bindParam(':username', $this->username, PDO::PARAM_STR);
        $sth->bindParam(':password', $this->password, PDO::PARAM_STR);
        $sth->bindParam(':full_name', $this->full_name, PDO::PARAM_STR);
        $sth->bindParam(':email', $this->email, PDO::PARAM_STR);
        $sth->bindParam(':phone', $this->phone, PDO::PARAM_STR);
        $sth->bindParam(':birthday', $this->birthday, PDO::PARAM_STR);
        $sth->bindParam(':discount', $this->discount, PDO::PARAM_STR);
        $sth->bindParam(':activation_key', $this->activation_key, PDO::PARAM_STR);
        $sth->execute();
    }