Pages

Monday, November 1, 2010

Zend framework Controller

//sample controller programs

-------------------------------------------------

<?php

/**

 * Test Statistics controller to perform team realted actions

 */

class StatisticsController extends Zaah_Controller_Action{

    protected $teamID;

 

    protected $teamName;

 

    protected $teamCoach;

 

    protected $teamURL;

    /**

    * Controller init function to init required values 

    * Created:    Oct 07, 2011

    */ 

 

    public function init(){

        $request     = $this->getRequest();

        $this->teamID    =    $request->getParam('test_team_id');

        $this->teamName    =    $request->getParam('test_team_name');

        $this->teamCoach    =    $request->getParam('test_team_user_id');

        $this->teamURL    =    $request->getParam('test_team_url');

     

        $this->view->test_team_id    =    $this->teamID;

        $this->view->test_user_id        =    $this->getUser()->user_id;

     

        $this->view->teamURL    =    $this->teamURL;

        $this->view->teamID    =    $this->teamID; 

        $this->view->teamName    =    $this->teamName;

    }

 

    /**

    * Team dashboard action to player statistics home page 

    * Created:    Oct 07, 2011

    */

    public function indexAction(){     

        $aParams = $this->_request->getPost();

        $this->view->$aParams['playerID']=$aParams['hidplayerID'];

        $vSort    =    $aParams['hidSorting'];

     

        $this->view->addTestStatistics    =$this->view->url(array('page'=>$this->teamURL,'action'=>'addTest-statistics'),'global_routing');

        $this->view->teamID=$this->teamID;

          $teamID=$this->teamID;     

 

        $playerID=$aParams['hidplayerID'];

        $this->view->vPlayerid=$playerID;

     

        $oStatistics = new Statistics();

        //player details     

        $teamPlyrDet=$oStatistics->getPlayerDetails($teamID,$playerID);

        $this->view->teamName=$teamPlyrDet[0]['team_name']; 

        $this->view->playerName=$teamPlyrDet[0]['user_fname']."&nbsp;".$teamPlyrDet[0]['user_lname'];

     

         //latest and summary of statistics

        $this->view->vTeamFieldDet  = $oStatistics->getTeamFieldsDetails($teamID);

        $this->view->vPyrLstGameDet  = $oStatistics->getLatestGameDetails($teamID,$playerID);

        $this->view->vPyrGameDet  = $oStatistics->getGameDetails($teamID,$playerID,$vSort);         

    }

    /**

    * Function to retrive statistics score addTest form  

    * Created:    Oct 08, 2011

    * @return

    */     

    function addTestStatisticsAction(){     

        $oStatistics = new Statistics();

        $this->_helper->layout()->disableLayout();

        if ($this->getRequest()->isPost()){

            $aParams = $this->_request->getPost();

            $vTeamID    =    $aParams['teamid']?$aParams['teamid']:0;

            $vTeamName    =    $aParams['teamname']?$aParams['teamname']:'';

            $vPlayerId    =    $aParams['playerid']?$aParams['playerid']:'';

         

            $this->view->vTeamid=$vTeamID; 

            $this->view->vPlayerid=     $vPlayerId;

            $this->view->vTeamname=     $vTeamName;

          

            //Team based plyer details

            $this->view->vTeamPlyrDet=$oStatistics->getTeamPlayerDetails($vTeamID);

            //statistics socre table fields

            $this->view->vTeamFieldDet  = $oStatistics->getTeamFieldsDetails($vTeamID);                

        }         

    }

 

    /**

    * Function to store statistics values  

    * Created:    Oct 08, 2011

    * @return

    */     

    function addTestStatisticsDetailsAction(){     

        $oStatistics = new Statistics();

        $this->_helper->layout()->disableLayout();

        $this->_helper->viewRenderer->setNoRender(true);

        if ($this->getRequest()->isPost())

        {

            $aParams = $this->_request->getPost();         

            $res    =    $oStatistics->addTestStatistics($aParams);         

            return 1;

        }

    }

 

    /**

    * Function to retrive statistics score addTest form  

    * Created:    Oct 08, 2011

    * @return

    */     

    function editStatisticsAction(){     

        $oStatistics = new Statistics();

        $this->_helper->layout()->disableLayout();

        if ($this->getRequest()->isPost()){

            $aParams = $this->_request->getPost();

            $stst_id    =    $aParams['stst_id']?$aParams['stst_id']:0;

         

            $this->view->vstst_id=$stst_id; 

            $this->view->teamURL=$this->teamURL; 

         

          

            //plyer statistics details

            $this->view->vstcsDet=$oStatistics->getStatisticsDetails($stst_id); 

            $vTeamID=$this->view->vstcsDet[0]['stst_team_id'];         

            //Team based plyer details

            $this->view->vTeamPlyrDet=$oStatistics->getTeamPlayerDetails($vTeamID);

            //statistics socre table fields

            $this->view->vTeamFieldDet  = $oStatistics->getTeamFieldsDetails($vTeamID);                

        }         

    } 

 

    /**

    * Function to Update statistics values  

    * Created:    Oct 08, 2011

    * @return

    */     

    function updateStatisticsDetailsAction(){     

        $oStatistics = new Statistics();

        $this->_helper->layout()->disableLayout();

        $this->_helper->viewRenderer->setNoRender(true);

        if ($this->getRequest()->isPost())

        {

            $aParams = $this->_request->getPost();         

            $res    =    $oStatistics->updateStatistics($aParams);         

            return 1;

        }

    }

 

    /**

    * Function to Delete statistics values  

    * Created:    Oct 11, 2011

    * @return

    */     

    function deleteStatisticsDetailsAction(){     

        $oStatistics = new Statistics();

        $this->_helper->layout()->disableLayout();

        $this->_helper->viewRenderer->setNoRender(true);

        if ($this->getRequest()->isPost())

        {

            $aParams = $this->_request->getPost();         

            $res    =    $oStatistics->deleteStatistics($aParams);         

            return 1;

        }

    }

 

    /**

    * Function to Listing the Team names  

    * Created:    Oct 12, 2011

    * @return

    */ 

    function viewopponentsAction()

    {     

        $oStatistics = new Statistics();

        $this->_helper->layout()->disableLayout();

        $this->_helper->viewRenderer->setNoRender(true);

             

        $aParams = $this->_request->getParams();

        $part    =    $aParams['part']?$aParams['part']:0;

     

        //spliting team url and keys         

        $apart=explode("_c_",$part);

        $sportID=$apart[0];

         $searchKey=$apart[1];

         $searchcnt=count(str_split($searchKey));

 

        if($searchcnt>=3)

        {

            $res    =    $oStatistics->opponentlists($sportID,$searchKey);

            if(count($res)>=1)

            {     

                $result[0]="<i>Suggested Result</i>";         

                for($i=0;$i<count($res);$i++)

                { 

                    $j=$i+1;         

                    /* $result[$j]='<a target=_blank href='.$this->view->baseUrl().'/'.$res[$i]['rutr_url'].'/summary>'.$res[$i]['team_name'].'</a>'; */

                    $result[$j]=$res[$i]['team_name'];

                } 

            }

         

        $this->_helper->json($result);

        }

    } 

 

    /**

    * Function to addTest bulk statistics home page 

    * Created:    Oct 14, 2011

    */

    public function addTestBulkStatisticsAction(){ 

     

        $this->view->teamID=$this->teamID;

          $teamID=$this->teamID;

     

        $oStatistics = new Statistics();

        $oRoaster = new Roaster();

        //player details     

        $this->view->vPlayerDet=$oRoaster->getPlayersDetail($teamID);     

         //getting statistics (Team's sport based) Fields

        $this->view->vTeamFieldDet  = $oStatistics->getTeamFieldsDetails($teamID);          

    }



}

No comments:

Post a Comment