public function exportMembersShirts() { $app = JFactory::getApplication(); $service_id = $app->input->get('service_id', null); $model = new EstivoleModelMembers(); $modelDaytime = new EstivoleModelDaytime(); $modelService = new EstivoleModelService(); $service = $modelService->getItem($service_id); $service_name = $service->service_name != '' ? $service->service_name : 'Tous les membres'; $this->members = $model->getTotalItemsForExport(); for ($i = 0; $i < count($this->members); $i++) { $this->members[$i]->member_daytimes = $modelDaytime->getMemberDaytimes($this->members[$i]->member_id, $this->calendars[0]->calendar_id); } // Create new PHPExcel object $objPHPExcel = new PHPExcel(); // Set document properties $objPHPExcel->getProperties()->setCreator("Estivale Open Air")->setLastModifiedBy("Estivole")->setTitle("Export Estivole")->setSubject("Export des bénévoles Estivole"); // Add some data $objPHPExcel->setActiveSheetIndex(0)->setCellValue("A1", "Plan de travail Estivale Open Air - Bénévoles"); // $this->state = $this->get('State'); // $this->filter_services = $this->state->get('filter.services_members'); $objPHPExcel->getActiveSheet()->setCellValue("A2", "Export membres \"" . $service_name . "\""); // // Miscellaneous glyphs, UTF-8 $objPHPExcel->getActiveSheet()->setCellValue("A4", "Nom")->setCellValue("B4", "Email")->setCellValue("C4", "Téléphone")->setCellValue("D4", "Nbre t-shirts")->setCellValue("E4", "Taille t-shirts"); // Rename worksheet $objPHPExcel->getActiveSheet()->setTitle("Export"); $cellCounter = 5; // Add data for ($i = 0; $i < count($this->members); $i++) { $userId = $this->members[$i]->user_id; $userProfileEstivole = EstivoleHelpersUser::getProfileEstivole($userId); $userProfile = JUserHelper::getProfile($userId); $user = JFactory::getUser($userId); $objPHPExcel->getActiveSheet()->setCellValue("A" . ($cellCounter + 1), $userProfileEstivole->profilestivole['lastname'] . ' ' . $userProfileEstivole->profilestivole['firstname'])->setCellValue("B" . ($cellCounter + 1), $user->email)->setCellValueExplicit("C" . ($cellCounter + 1), $userProfile->profile['phone'], PHPExcel_Cell_DataType::TYPE_STRING)->setCellValue("D" . ($cellCounter + 1), round(count($this->members[$i]->member_daytimes) / 2))->setCellValue("E" . ($cellCounter + 1), $userProfileEstivole->profilestivole['tshirtsize']); $cellCounter++; } // Redirect output to a client’s web browser (Excel2007) header("Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); header("Content-Disposition: attachment;filename=\"01simple.xlsx\""); header("Cache-Control: max-age=0"); // If you"re serving to IE 9, then the following may be needed header("Cache-Control: max-age=1"); // If you"re serving to IE over SSL, then the following may be needed header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); // always modified header("Cache-Control: cache, must-revalidate"); // HTTP/1.1 header("Pragma: public"); // HTTP/1.0 $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, "Excel2007"); $objWriter->save("php://output"); exit; }
function display($tpl = null) { $app = JFactory::getApplication(); $this->state = $this->get('State'); //retrieve task list from model $model = new EstivoleModelMembers(); $this->members = $model->listItems(); EstivoleHelpersEstivole::addSubmenu('members'); $this->sidebar = JHtmlSidebar::render(); $this->addToolbar(); //display return parent::display($tpl); }
function display($tpl = null) { $app = JFactory::getApplication(); $this->state = $this->get('State'); $this->pagination = $this->get('Pagination'); $this->searchterms = $this->state->get('filter.search'); $this->campingPlace = $this->state->get('filter.campingPlace'); $this->services_members = $this->state->get('filter.services_members'); $this->user = JFactory::getUser(); $this->limitstart = $this->state->get('limitstart'); //retrieve task list from model $model = new EstivoleModelMembers(); $this->members = $model->listItems(); $this->totalMembersM = $model->getTotalItems('M'); $this->totalMembersF = $model->getTotalItems('F'); $modelCalendars = new EstivoleModelCalendars(); $modelDaytime = new EstivoleModelDaytime(); $this->calendars = $modelCalendars->listItems(); for ($i = 0; $i < count($this->members); $i++) { $this->members[$i]->member_daytimes = $modelDaytime->getMemberDaytimes($this->members[$i]->member_id, $this->calendars[0]->calendar_id); } for ($i = 0; $i < count($this->totalMembersM); $i++) { $this->totalMembersM[$i]->member_daytimes = $modelDaytime->getMemberDaytimesForTshirt($this->totalMembersM[$i]->member_id, $this->calendars[0]->calendar_id); $this->totalShirtsM += ceil(count($this->totalMembersM[$i]->member_daytimes) / 2); $this->totalMembersM[$i]->member_daytimes = $modelDaytime->getMemberDaytimesForPolo($this->totalMembersM[$i]->member_id, $this->calendars[0]->calendar_id); $this->totalPolosM += ceil(count($this->totalMembersM[$i]->member_daytimes) / 2); } for ($i = 0; $i < count($this->totalMembersF); $i++) { $this->totalMembersF[$i]->member_daytimes = $modelDaytime->getMemberDaytimesForTshirt($this->totalMembersF[$i]->member_id, $this->calendars[0]->calendar_id); $this->totalShirtsF += ceil(count($this->totalMembersF[$i]->member_daytimes) / 2); $this->totalMembersF[$i]->member_daytimes = $modelDaytime->getMemberDaytimesForPolo($this->totalMembersF[$i]->member_id, $this->calendars[0]->calendar_id); $this->totalPolosF += ceil(count($this->totalMembersF[$i]->member_daytimes) / 2); } EstivoleHelpersEstivole::addSubmenu('members'); $this->sidebar = JHtmlSidebar::render(); $this->addToolbar(); //display return parent::display($tpl); }