<?php
defined('COT_CODE') or die('Wrong URL');

$return['oview'] = 0;

$oid = cot_import('oid', 'G', 'INT');
if($oid > 0 && $usr['id'] > 0) {
  require_once cot_incfile('projects', 'module');

  $offer = $db->query("SELECT * FROM $db_projects_offers as o LEFT JOIN $db_projects as p ON o.offer_pid=p.item_id WHERE offer_id=".$oid." AND item_userid=".$usr['id']." LIMIT 1")->fetch();

  if($offer['offer_id'] > 0) {
    $oview = ($offer['offer_view'] == 2 ? 1 : 2);
    $db->update($db_projects_offers, array('offer_view' => $oview), 'offer_id='.$offer['offer_id']);

    $return['oview'] = $oview;

    $return['success'] = true;
  }
}

?>
