public function calculateRegisteredMembersByBranch($node, $branches, $dateStart, $dateEnd) {
    $query = $this->connection->select('openy_campaign_member', 'cm');
    $query->leftJoin('openy_campaign_member_campaign', 'mc', 'mc.member = cm.id');
    $query->addExpression('COUNT(cm.id)', 'count_id');
    $query->fields('cm', ['branch']);
    $query->condition('cm.branch', $branches, 'IN');
    $query->condition('mc.campaign', $node->id(), '=');
    $query->condition('mc.created', [$dateStart, $dateEnd], 'BETWEEN');
    $query->groupBy('cm.branch');

    $result = $query->execute()->fetchAllAssoc('branch');

    return $result;
  }
public function calculateRegisteredMembersByBranch($node, $branches, $dateStart, $dateEnd) {
    $query = $this->connection->select('openy_campaign_member', 'cm');
    $query->leftJoin('openy_campaign_member_campaign', 'mc', 'mc.member = cm.id');
    $query->addExpression('COUNT(cm.id)', 'count_id');
    $query->fields('cm', ['branch']);
    $query->condition('cm.branch', $branches, 'IN');
    $query->condition('mc.campaign', $node->id(), '=');
    $query->condition('mc.created', [$dateStart, $dateEnd], 'BETWEEN');
    $query->groupBy('cm.branch');

    $result = $query->execute()->fetchAllAssoc('branch');

    return $result;
  }
public function calculateRegisteredMembersByBranch ( $ node , $ branches , $ dateStart , $ dateEnd ) { $ query = $ this -> connection -> select ( 'openy_campaign_member' , 'cm' ) ; $ query -> leftJoin ( 'openy_campaign_member_campaign' , 'mc' , 'mc.member = cm.id' ) ; $ query -> addExpression ( 'COUNT(cm.id)' , 'count_id' ) ; $ query -> fields ( 'cm' , [ 'branch' ] ) ; $ query -> condition ( 'cm.branch' , $ branches , 'IN' ) ; $ query -> condition ( 'mc.campaign' , $ node -> id ( ) , '=' ) ; $ query -> condition ( 'mc.created' , [ $ dateStart , $ dateEnd ] , 'BETWEEN' ) ; $ query -> groupBy ( 'cm.branch' ) ; $ result = $ query -> execute ( ) -> fetchAllAssoc ( 'branch' ) ; return $ result ; }
Get Count of registered users by branches for campaign.

@param $node
@param $branches
@param $dateStart
@param $dateEnd

@return mixed
Get Count of registered users by branches for campaign .