<?php

namespace App\Controllers\Front;

use CodeIgniter\Controller;
use App\Controllers\BaseController;

class FrontPages extends BaseController
{
   
    public function initController($request, $response, $logger)
    {
        parent::initController($request, $response, $logger);
        $this->data['posts'] = $this->postsModel->getAllPostsForHome();
        $this->data['menu'] = generate_menu('main-menu');
    }

    
	
	

    //Member Benefits Page
	public function memberBenefitsPage()
	{	
		$post = $this->postsModel->showSinglePost(13);
        $postId = $post->id; // Dams post ID

        //Meta info for pages
        $title = $post->title.' Uganda Committee on Large Dams (UCOLD)';
        $description = $post->metadesc;
        $keywords = $post->metakey.', UCOLD Uganda, Uganda Committee on Large Dams, ICOLD member, dam safety Uganda';

        //Getting Hits & Saving them.
        $id = $post->id;
        $current_hits = $post->hits;
        $new_hits = $current_hits + 1;
        $this->postsModel->update($id, ['hits'=>$new_hits]);

        // Get blocks ordered
        $blocks = $this->postblocksModel
            ->where('post_id', $postId)
            ->orderBy('ordering', 'ASC')
            ->findAll();

        // Group by block_type for easier access
        $grouped = [];
        foreach ($blocks as $block) {
            $grouped[$block['block_type']][] = $block;
        }

        // For blocks with children
        $stats = isset($grouped['stats'][0]) 
            ? $this->postblockitemsModel->where('block_id', $grouped['stats'][0]['id'])->findAll()
            : [];

        $cards = isset($grouped['cards'][0]) 
            ? $this->postblockitemsModel->where('block_id', $grouped['cards'][0]['id'])->findAll()
            : [];
        $keyAreas = isset($grouped['cards'][1]) 
            ? $this->postblockitemsModel->where('block_id', $grouped['cards'][1]['id'])->findAll()
            : [];

        $gallery = isset($grouped['gallery'][0]) 
            ? $this->postblockitemsModel->where('block_id', $grouped['gallery'][0]['id'])->findAll()
            : [];

        // Pass to view
        $data = [
            'title'             => $title,
            'description'       => $description,
            'keywords'          => $keywords,
            'post'              => $post,
            'blocks'            => $grouped,
            'stats'             => $stats,
            'cards'             => $cards,
            'keyAreas'          => $keyAreas,
        ];
        return view('website/pages/membership_benefits', $data);
	}
	
    //Single Services Page
	public function singleServicesPage($service)
	{	
		$s = $this->postsModel->getSinglePost($service);
		$expectedServices = [2,3,4,5,6,7];
		if(!in_array($s->id, $expectedServices)){
			return redirect()->to(previous_url());
		}
		
		$this->data['title'] = $s->title.' | Uganda Committee on Large Dams';
        $this->data['title'] = 'Uganda Committee on Large Dams | Career Planning, CV Assessment & Review, Skills & Career Pathway, Admission Assistance, Ugandaa Schools';
        $this->data['description']= 'Uganda Committee on Large Dams, under Academic Guidance Media Limited, is a leading career development hub in Uganda, East Africa, dedicated to empowering students and professionals at every stage of their academic and career journey';
        $this->data['keywords']= 'Career Guidance, Academic Guidance Media, Early Career Planning, Mid Career Planning, Graduates, CV Assessment & Review, skills & Career patheway, Admission Assistance, Personality Development, Uganda career guidance, UNEB, Ministry of Education Uganda, Kampala schools, World, Africa';
		$this->data['service'] = $s;
		
		return view('website/pages/services', $this->data);
	}
	
/**===========================================================================
* Directory
*==============================================================================*/
    public function directoryPage($start = 0)
	{
		$this->data['title'] = 'Directory | Uganda Committee on Large Dams -  Career Planning, CV Assessment & Review, Skills & Career Pathway, Admission Assistance, Ugandaa Schools';
        $this->data['description']= 'Uganda Committee on Large Dams, under Academic Guidance Media Limited, is a leading career development hub in Uganda, East Africa, dedicated to empowering students and professionals at every stage of their academic and career journey';
        $this->data['keywords']= 'Career Guidance, Academic Guidance Media, Early Career Planning, Mid Career Planning, Graduates, CV Assessment & Review, skills & Career patheway, Admission Assistance, Personality Development, Uganda career guidance, UNEB, Ministry of Education Uganda, Kampala schools, World, Africa';

        $this->data['categories'] = $this->directorycategoryModel->getCategoriesWithDirectories();
        $this->data['directories'] = $this->directoryModel->getAllHomeDirectories($start, 20);
        $this->data['featured'] = $this->directoryModel->getAllFeaturedDirectories();
        $this->data['categoriesMenu'] = $this->directorycategoryModel->getMasterCategoriesWithSubcategories();
        $this->data['subcategoriesMenu'] = $this->directorycategoryModel->getSubCategoriesFromMaster();
		
		return view('website/pages/directory//directory-page', $this->data);
	}

    //Get & Display more Directories
    public function displayDirectories($start = 0)
    {
        $data['directories'] = $this->directoryModel->getAllHomeDirectories($start, 20);
        return view('website/pages/directory/home-directories', $data);
    }

    public function searchDirectoryResultsPage()
    {
        $this->data['title'] = 'Search Directory | Uganda Committee on Large Dams -  Career Planning, CV Assessment & Review, Skills & Career Pathway, Admission Assistance, Ugandaa Schools';
        $this->data['description']= 'Uganda Committee on Large Dams, under Academic Guidance Media Limited, is a leading career development hub in Uganda, East Africa, dedicated to empowering students and professionals at every stage of their academic and career journey';
        $this->data['keywords']= 'Career Guidance, Academic Guidance Media, Early Career Planning, Mid Career Planning, Graduates, CV Assessment & Review, skills & Career patheway, Admission Assistance, Personality Development, Uganda career guidance, UNEB, Ministry of Education Uganda, Kampala schools, World, Africa';
        
        $searchTerm = $this->request->getPost('search');

        $this->data['categories'] = $this->directorycategoryModel->getCategoriesWithDirectories();
        $this->data['featured'] = $this->directoryModel->getAllFeaturedDirectories();
        $this->data['categoriesMenu'] = $this->directorycategoryModel->getMasterCategoriesWithSubcategories();
        $this->data['subcategoriesMenu'] = $this->directorycategoryModel->getSubCategoriesFromMaster();

        $directoryResults = $this->directoryModel->searchDirectories($searchTerm);
        $categoryResults = $this->directorycategoryModel->searchCategories($searchTerm);

        $this->data['directoryResults'] =  $directoryResults;
        $this->data['categoryResults'] = $categoryResults;

        return view('website/pages/directory/search_results', $this->data);
    }
    //Single product page
    public function singleDirectoryPage($seg1 = false, $seg2 = false, $seg3 = false)
    {
        $oneDirectory = $this->directoryModel->singleDirectoryMember($seg3);
        $this->data['title'] = $oneDirectory->title.' - '.$oneDirectory->master_category.','.$oneDirectory->category_name .' Directory | Uganda Committee on Large Dams';
        $this->data['description']= 'Uganda Committee on Large Dams, under Academic Guidance Media Limited, is a leading career development hub in Uganda, East Africa, dedicated to empowering students and professionals at every stage of their academic and career journey';
        $this->data['keywords']= 'Career Guidance, Academic Guidance Media, Early Career Planning, Mid Career Planning, Graduates, CV Assessment & Review, skills & Career patheway, Admission Assistance, Personality Development, Uganda career guidance, UNEB, Ministry of Education Uganda, Kampala schools, World, Africa';
        $data['bcrumb'] = $oneDirectory->title;
        $data['pageImage'] = $oneDirectory->logo;

        $this->data['singleDirectory'] = $oneDirectory;
        $this->data['gallery'] = $this->directorygalleryModel->getDirectoryPhotos($oneDirectory->id);
        $this->data['docs']    = $this->directorydownloadsModel->getDirectoryDocuments($oneDirectory->id);
        $data['uniqueId'] = $this->generateUniqueId();

        //Master Categories & its Sub Categories
        $this->data['categoriesMenu'] = $this->directorycategoryModel->getMasterCategoriesWithSubcategories();
        $this->data['subcategoriesMenu'] = $this->directorycategoryModel->getSubCategoriesFromMaster();


        return View('website/pages/directory//single-directory', $this->data);
    }

    //Sub Category Page
    public function subDirectoryCategoryPage($seg1 = false, $category = false, $start = 0)
    {
        $subCategory = $this->directoryModel->getSingleSubCategory($category);
        $this->data['title'] = $subCategory->category_name . ' - ' . $subCategory->master_category .' - Uganda Committee on Large Dams';
        $this->data['description']= 'Uganda Committee on Large Dams, under Academic Guidance Media Limited, is a leading career development hub in Uganda, East Africa, dedicated to empowering students and professionals at every stage of their academic and career journey';
        $this->data['keywords']= 'Career Guidance, Academic Guidance Media, Early Career Planning, Mid Career Planning, Graduates, CV Assessment & Review, skills & Career patheway, Admission Assistance, Personality Development, Uganda career guidance, UNEB, Ministry of Education Uganda, Kampala schools, World, Africa';
        $this->data['bcrumb'] = $subCategory->category_name;
       

        $this->data['subCategory'] = $this->directoryModel->getSingleSubCategory($category);
        $this->data['uniqueId'] = $this->generateUniqueId();
        

        $directoryCount = $this->directoryModel->countSubCategoryDirectories($category);
        if ($directoryCount <= 40) {
            $this->data['categoryDirectories'] = $this->directoryModel->getSingleSubCategoryDirectories($category, $start, 20);
        } else {
            $this->data['categoryDirectories'] = $this->directoryModel->getSingleSubCategoryDirectories($category, 20, 20);
        }

        //Master Categories & its Sub Categories
        $this->data['categoriesMenu'] = $this->directorycategoryModel->getMasterCategoriesWithSubcategories();
        $this->data['subcategoriesMenu'] = $this->directorycategoryModel->getSubCategoriesFromMaster();
        
        session()->set('category', $category);
        
        return View('website/pages/directory//sub-category', $this->data);
    }
    
    // Show directoryz in sub category, in 20 product interval
    public function showSubCategoryDirectoryz($start = 0)
    {
        $category = session()->get('category'); 
        $data['categoryDirectories'] = $this->directoryModel->getSingleSubCategoryDirectories($category, $start, 20);
        
        return View('website/pages/directory//sub-category_directoryz', $data);
    }
    
    //Main Category Directory
    public function mainDirectoryCategoryPage($category = false, $start = 0)
    {
        $mainCategory = $this->directoryModel->getSingleMainCategory($category);
        $this->data['title'] = $mainCategory->master_category .' - Uganda Committee on Large Dams';
        $this->data['description']= 'Uganda Committee on Large Dams, under Academic Guidance Media Limited, is a leading career development hub in Uganda, East Africa, dedicated to empowering students and professionals at every stage of their academic and career journey';
        $this->data['keywords']= 'Career Guidance, Academic Guidance Media, Early Career Planning, Mid Career Planning, Graduates, CV Assessment & Review, skills & Career patheway, Admission Assistance, Personality Development, Uganda career guidance, UNEB, Ministry of Education Uganda, Kampala schools, World, Africa';
        $this->data['bcrumb'] = $mainCategory->master_category;

        $this->data['mainCategory'] = $this->directoryModel->getSingleMainCategory($category);
        $this->data['categoryDirectories'] = $this->directoryModel->getSingleMainCategoryDirectories($category, 20, 20);
        $this->data['uniqueId'] = $this->generateUniqueId();

        //Master Categories & its Sub Categories
        $this->data['categoriesMenu'] = $this->directorycategoryModel->getMasterCategoriesWithSubcategories();
        $this->data['subcategoriesMenu'] = $this->directorycategoryModel->getSubCategoriesFromMaster();
        
        session()->set('main_category', $category);
        
        return View('website/pages/directory/main-category', $this->data);
    }
    
    // Show products in main category, in 20 product interval
    public function showMainCategoryProductz($start = 0)
    {
        $category = session()->get('main_category');

        $data['categoryProducts'] = $this->productsModel->getSingleMainCategorySellerProducts($category, $start, 20);
        
        return View('website/pages/directory/main_category_directoryz', $data);
    }

/**===========================================================================
* DAMs PAGES
*==============================================================================*/
    public function damsPageTemplate($id)
    {
        $post = $this->postsModel->showSinglePost($id);
        $postId = $post->id; // Dams post ID

        //Meta info for pages
        $title = $post->title.','. $post->category. 'Uganda Committee on Large Dams (UCOLD)';
        $description = $post->metadesc;
        $keywords = $post->metakey.', UCOLD Uganda, Uganda Committee on Large Dams, ICOLD member, dam safety Uganda';

        //var_dump($post->title);
        //Getting Hits & Saving them.
        $id = $post->id;
        $current_hits = $post->hits;
        $new_hits = $current_hits + 1;
        $this->postsModel->update($id, ['hits'=>$new_hits]);

        // Get blocks ordered
        $blocks = $this->postblocksModel
            ->where('post_id', $postId)
            ->orderBy('ordering', 'ASC')
            ->findAll();

        // Group by block_type for easier access
        $grouped = [];
        foreach ($blocks as $block) {
            $grouped[$block['block_type']][] = $block;
        }

        // For blocks with children
        $stats = isset($grouped['stats'][0]) 
            ? $this->postblockitemsModel->where('block_id', $grouped['stats'][0]['id'])->findAll()
            : [];

        $cards = isset($grouped['cards'][0]) 
            ? $this->postblockitemsModel->where('block_id', $grouped['cards'][0]['id'])->findAll()
            : [];

        $gallery = isset($grouped['gallery'][0]) 
            ? $this->postblockitemsModel->where('block_id', $grouped['gallery'][0]['id'])->findAll()
            : [];

        // Pass to view
        $data = [
            'title'=> $title,
            'description' => $description,
            'keywords' => $keywords,
            'post' => $post,
            'blocks' => $grouped,
            'stats' => $stats,
            'cards' => $cards,
            'gallery' => $gallery,
        ];
        return view('website/pages/dams_template', $data);
    }

/**===========================================================================
* TEAM PAGES
*==============================================================================*/
    public function teamPageTemplate($category)
    {
        $cat = $this->teamcategoryModel->getSingleTeamCategory($category);
        $team = $this->teamModel->getTeamMembersInCategory($category);

        //Meta info for pages
        $title = $cat->name. ' Uganda Committee on Large Dams (UCOLD)';
        $description = 'UCOLD advances safe and sustainable dam engineering in Uganda as ICOLD’s 101st member. Promoting innovation, stakeholder collaboration, and global best practices for water resources management.';
        $keywords = 'UCOLD Uganda, Uganda Committee on Large Dams, ICOLD member, dam safety Uganda, sustainable water resources, Ugandan dams, UEGCL, Ministry of Water Uganda, dam engineering Africa';

        // Pass to view
        $data = [
            'title'         => $title,
            'description'   => $description,
            'keywords'      => $keywords,
            'category'      => $cat,
            'teamMembers'   => $this->teamModel->getTeamMembersInCategory($category),
        ];
        return view('website/pages/team_template', $data);
    }

/**===========================================================================
* PAGES
*=============================================================================*/
	public function singleNewsBlogPage()
	{	
		
		$this->data['title'] = 'News & Blog | Uganda Committee on Large Dams';
        $description = 'UCOLD advances safe and sustainable dam engineering in Uganda as ICOLD’s 101st member. Promoting innovation, stakeholder collaboration, and global best practices for water resources management.';
        $keywords = 'UCOLD Uganda, Uganda Committee on Large Dams, ICOLD member, dam safety Uganda, sustainable water resources, Ugandan dams, UEGCL, Ministry of Water Uganda, dam engineering Africa';
		$this->data['news'] = $this->postsModel->getAllPostsForNewsBlog();
		
		return view('website/pages/all-news', $this->data);
	}
	
	//Single Post
    public function singlePost($seg1 = false, $seg2 = false)
    {
        $seo = $this->postsModel->showSinglePost($seg2);
        //Meta info for pages
        $this->data['title'] = $seo->title.','. $seo->category. 'Uganda Committee on Large Dams';
        $this->data['description']= $seo->metadesc;
        $this->data['keywords']= $seo->metakey.', Uganda Committee on Large Dams, under Academic Guidance Media Limited';

        //Getting Hits & Saving them.
        $id = $seo->id;
        $current_hits = $seo->hits;
        $new_hits = $current_hits + 1;
        $this->postsModel->update($id, ['hits'=>$new_hits]);

        $this->data['singlePost'] = $this->postsModel->showSinglePost($seg2);
        $this->data['tags'] = $this->posttagsModel->getPostTags($seg2);
        $this->data['relatedPosts'] = $this->postsModel->getRelatedPostsForSinglePage($seg2);

        //Block Post

        // Merge all block arrays into a single array
        $allBlocks = $this->postblocksModel->getSingleBlockPost($id);
        $this->data['blockData'] = $allBlocks;

        log_hit($this->request, $this); //logs hits on this website page.
        return view('website/posts/single-post', $this->data);
    }
	
	//Main Posts Category
    public function mainCategory($category = false, $start = 0)
    {
        //$mc = $this->postsModel->getSingleMainCategory($category);
        $mc = $this->postscategoryModel->getSingleCategory($category);
    
        $this->data['title'] = $mc->name .' - Your ICT Magazine';
        $this->data['tagline']= "Embracing the ICT World";
        $this->data['description']= 'Embrace the world of ICT with expert tips and stay up-to-date with the latest tech news at Your ICT Magazine.  Your ultimate destination for all things technology';
        $this->data['keywords']= 'ICT, New technologies, Websites, Hardware/Gadgets, Software/App, Systems, Network, Ecommerce, Apps, Software, Security, cloud computing, games, World, Africa';

        $this->data['frontBanners'] = $this->bannersModel->getBanner();
        $this->data['posts'] = $this->postsModel->getSingleMainCategoryPosts($category, $start, 10);
        //$this->data['singleCat'] = $this->postsModel->getSingleMainCategory($category);
        $this->data['singleCat'] = $this->postscategoryModel->getSingleCategory($category);
        $this->data['categories'] = $this->postsModel->listSubCategoriesInMainCat($category);
        $this->data['tags'] = $this->posttagsModel->getTagsInPosts();

        log_hit($this->request, $this); //logs hits on this website page.
        session()->set('category', $category);
        return view('website/posts/main_category', $this->data);
    }

    // Show posts in sub category, in 20 product interval
    public function showMainCategoryPostz($start = 0)
    {
        $category = session()->get('category');

        $data['posts'] = $this->postsModel->getSingleMainCategoryPosts($category, $start, 10);
        return View('website/home/main_category_posts', $data);
    }

    //Sub Posts Category
    public function subCategory($seg1 = false, $category = false, $start = 0)
    {
        $mc = $this->postsModel->getSingleSubCategory($category);
        $this->data['title'] =  ' - Your ICT Magazine';
        $this->data['tagline']= "Embracing the ICT World";
        $this->data['description']= 'Embrace the world of ICT with expert tips and stay up-to-date with the latest tech news at Your ICT Magazine.  Your ultimate destination for all things technology';
        $this->data['keywords']= 'ICT, New technologies, Websites, Hardware/Gadgets, Software/App, Systems, Network, Ecommerce, Apps, Software, Security, cloud computing, games, World, Africa';

        $this->data['frontBanners'] = $this->bannersModel->getBanner();
        $this->data['posts'] = $this->postsModel->getSingleSubCategoryPosts($category, $start, 10);
        $this->data['singleCat'] = $this->postsModel->getSingleSubCategory($category);
        $this->data['categories'] = $this->postsModel->listSubCategoriesInMainCat($seg1);
        $this->data['tags'] = $this->posttagsModel->getTagsInPosts();

        log_hit($this->request, $this); //logs hits on this website page.
        session()->set('category', $category);
        return view('website/posts/sub_category', $this->data);
    }

    // Show posts in sub category, in 20 product interval
    public function showSubCategoryPostz($start = 0)
    {
        $category = session()->get('category');

        $data['posts'] = $this->postsModel->getSingleSubCategoryPosts($category, $start, 10);
        
        return View('website/home/main_category_posts', $data);
    }

    //Show Posts in same Tag
    public function tagPosts($tag)
    {
        $t = $this->posttagsModel->getSingleTagsInPosts($tag);
        $this->data['title'] = $t->tag_name.' Tag - Your ICT Magazine';
        $this->data['tagline']= "Embracing the ICT World";
        $this->data['description']= 'Embrace the world of ICT with expert tips and stay up-to-date with the latest tech news at Your ICT Magazine.  Your ultimate destination for all things technology';
        $this->data['keywords']= 'ICT, New technologies, Websites, Hardware/Gadgets, Software/App, Systems, Network, Ecommerce, Apps, Software, Security, cloud computing, games, World, Africa';

        $this->data['singleTag'] = $this->posttagsModel->getSingleTagsInPosts($tag);
        $this->data['tags'] = $this->posttagsModel->getTagsInPosts();
        $this->data['posts'] = $this->posttagsModel->getSingleTagsAllPosts($tag);

        log_hit($this->request, $this); //logs hits on this website page.
        return view('website/posts/tag_posts', $this->data);
    }

/**===========================================================================
* Member Registration
*=========================================================================*/

    public function registerMember()
    {
        $this->data['title'] = "Online UCOLD Member Registration";
        $this->data['description']= 'Uganda Committee on Large Dams (UCOLD) is Uganda’s national chapter of the International Commission on Large Dams (ICOLD), inaugurated in 2019 to promote excellence in dam engineering and water resources management.';
        $this->data['keywords']= 'UCOLD Uganda, Uganda Committee on Large Dams, ICOLD member, dam safety Uganda, sustainable water resources, Ugandan dams, UEGCL, Ministry of Water Uganda, dam engineering Africa';
        
        
        return view('website/pages/register', $this->data);
    }
	
/**=======================================================================
* Publications / Downloads
*=========================================================================*/

    public function allDownloadsPage()
    {
        $data['title'] = "Publications | UCOLD - Uganda Committee on Large Dams";
        $data['description']= 'Uganda Committee on Large Dams (UCOLD) is Uganda’s national chapter of the International Commission on Large Dams (ICOLD), inaugurated in 2019 to promote excellence in dam engineering and water resources management.';
        $data['keywords']= 'UCOLD Uganda, Uganda Committee on Large Dams, ICOLD member, dam safety Uganda, sustainable water resources, Ugandan dams, UEGCL, Ministry of Water Uganda, dam engineering Africa';
        
        $data['downloads'] = $this->downloadsModel->forHomePage();
        $data['download_categories'] = $this->downloadscategoryModel->getAll();
        $data['downloadCat'] = Null;
        
        
        return view('website/pages/downloads_template', $data);
    }
    
    public function singleDownloadsCat($category)
    {
        $data['title'] = "Publications | UCOLD - Uganda Committee on Large Dams";
        $data['description']= 'Uganda Committee on Large Dams (UCOLD) is Uganda’s national chapter of the International Commission on Large Dams (ICOLD), inaugurated in 2019 to promote excellence in dam engineering and water resources management.';
        $data['keywords']= 'UCOLD Uganda, Uganda Committee on Large Dams, ICOLD member, dam safety Uganda, sustainable water resources, Ugandan dams, UEGCL, Ministry of Water Uganda, dam engineering Africa';
        
        $access = 'Public';
        $data['downloads'] = $this->downloadsModel->getDownloadsPerCategoryPerAccess($access, $category);
        $data['download_categories'] = $this->downloadscategoryModel->getAll();
        $data['downloadCat'] = $this->downloadscategoryModel->where('id', $category)->orWhere('alias', $category)->first($category);
        
        
        return view('website/pages/downloads_template', $data);
    }

    public function downloadPublication($id)
    {
        // Get the file info from database
        $doc = $this->downloadsModel->find($id);
        
        if (!$doc) {
            return redirect()->back()->with('error', 'File not found');
        }
    
        // Track the download
        $this->saveDownloadsHits($id);
        
        // Force download
        return redirect()->to($doc['file']);
    }
    
    protected function saveDownloadsHits($id = null)
    {
        // If called via POST (alternative method)
        $id = $id ?? $this->request->getPost('id');
        
        if (!$id) {
            return false;
        }
    
        $doc = $this->downloadsModel->find($id);
        
        if ($doc) {
            $new_hits = $doc['hits'] + 1;
            $this->downloadsModel->update($id, ['hits' => $new_hits]);
            return true;
        }
        
        return false;
    }
    
/**===========================================================================
* PAGES
*=============================================================================*/
	public function alleventsPage()
	{	
		
		$this->data['title'] = 'Events | Uganda Committee on Large Dams - Upcoming Conferences & Workshops';
        $description = 'Explore upcoming UCOLD events, conferences, and workshops on dam safety, hydropower development, and water resources management in Uganda. Join Uganda\'s leading dam engineering experts.';
        $keywords = 'UCOLD Uganda, Uganda Committee on Large Dams, ICOLD member, dam safety Uganda, sustainable water resources, Ugandan dams, UEGCL, Ministry of Water Uganda, dam engineering Africa';
        
		$this->data['events'] = $this->eventsModel->getOnlyOngoingUpcomingEvents();
		
		return view('website/pages/events_template', $this->data);
	}    
    
    public function singleEventsPage($event)
    {
        $single = $this->eventsModel->getSingleEvent($event);
        $this->data['title'] = $single->event_name.' Events | Uganda Committee on Large Dams (UCOLD)';
        $description = 'Explore upcoming UCOLD events, conferences, and workshops on dam safety, hydropower development, and water resources management in Uganda. Join Uganda\'s leading dam engineering experts.';
        $keywords = 'UCOLD Uganda, Uganda Committee on Large Dams, ICOLD member, dam safety Uganda, sustainable water resources, Ugandan dams, UEGCL, Ministry of Water Uganda, dam engineering Africa';
        
		$this->data['events'] = $this->eventsModel->getOnlyOngoingUpcomingEvents();
		$this->data['singleEvent'] = $single;
		
		return view('website/pages/single_event', $this->data);
        
    }
    
    
}