<?php


class OfferHelper extends controller{


	


	public function calculateOfferRating($offer_id)


    {


        $rating = 0;


        // get driver data from summery


        $summery = $this->loadModel("OfferReportModel")->retriveDataById("id_offer",$offer_id);


        if(is_array($summery))


        {


            if($summery['total_users_rates'] > 0)


            {


                $rating = round(($summery['star1_count'] + $summery['star2_count'] * 2 + $summery['star3_count'] * 3 + $summery['star4_count'] * 4 + $summery['star5_count'] * 5) / $summery['total_users_rates'],2);


            }


        }


        return $rating;


    }


}


?> 