<?php

/**
 * [BEGIN_COT_EXT]
 * Hooks=projects.offers.loop
 * [END_COT_EXT]
 */

defined('COT_CODE') or die('Wrong URL.');

$reviews_cnt = array(
  'pos' => 0,
  'neg' => 0
);

if($mdata['type'] == 'offer_prd' && $mdata['pid'] > 0) {
  require_once cot_incfile('reviews', 'plug');
  $reviews_cnt = array(
    'pos' => $db->query("SELECT COUNT(*) FROM $db_reviews WHERE item_score=1 AND item_area='market' AND item_type='review' AND item_mcode=".$item['item_id'])->fetchColumn(),
    'neg' => $db->query("SELECT COUNT(*) FROM $db_reviews WHERE item_score=0 AND item_area='market' AND item_type='review' AND item_mcode=".$item['item_id'])->fetchColumn()
  );
}

$t->assign(array(
  'OFFER_ROW_PRD_REVIEWS_CNT_POS' => $reviews_cnt['pos'],
  'OFFER_ROW_PRD_REVIEWS_CNT_NEG' => $reviews_cnt['neg'],
));

?>