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

$return['success'] = false;

$oid = $_REQUEST['oid'];
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 offer_userid=".$usr['id']." LIMIT 1")->fetch();

  if($offer['offer_id'] > 0) {
    $db->delete($db_projects_offers, 'offer_id='.$offer['offer_id']);
    $db->update($db_projects, array('item_offerscount' => ($offer['item_offerscount'] - 1)), 'item_id='.$offer['item_id']);

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

?>
