Share it

Bookmark and Share

Translate

Wednesday, February 27, 2013

0 Calculate Last week signup in SocialEngine Group


First create a new field in group membership table 
field name:creation_date 
type:timestamp 
default:CURRENT_TIMESTAMP
 
  Use the following code in controller 

       $subject=Engine_Api::_()->core()->getSubject('group');
       $this->view->subject=$subject;
       $oUser = new User_Model_DbTable_Users();
       $groupId = (int) $this->_getParam('id');

       //calculate lastweek joined members count
       $oSignups                    = new Group_Model_DbTable_Membership();
       $lastWeekSignups             = $oSignups->getSignups($groupId,date('Y-m-d'));
       $this->view->lastweeksignups = count($lastWeekSignups);

Use the code in model

      $oneWeekAgo  = strtotime ( '-1 week' , strtotime ($date));
      $oneWeekdate =  date ( 'Y-m-j G:i:s' , $oneWeekAgo );
     
      $oAdapter   = $this->getAdapter();
      $sSelect    = $oAdapter->select();
      $sSelect->from($this->_name,'user_id AS id');
      $sSelect->where('active = ?', 1);
      $sSelect->where('resource_approved = ?', 1);
      $sSelect->where('resource_id = ?', $groupId);
      if($date != ''):
      $sSelect->where('creation_date > ?',$oneWeekdate);
      endif;
      $aResult    = $oAdapter->fetchAll($sSelect);
      $aIds    = array();
      foreach ($aResult as $aVal) {
      $aIds[]    = $aVal['id'];
      }
      return $aIds;

0 comments:

Post a Comment

Thanks for your valuable Comment

 

TechnoTipworld- Tips,Tricks,Technology Copyright © 2011 - |- Template created by O Pregador - |- Powered by Blogger Templates