<?php

/**
 * @version            $Id$
 * @package            ARTIO Booking
 * @copyright        Copyright (C) 2010 ARTIO s.r.o.. All rights reserved.
 * @author            ARTIO s.r.o., http://www.artio.net
 * @license        GNU/GPL http://www.gnu.org/copyleft/gpl.html
 * @link            http://www.artio.net Official website
 */
defined('_JEXEC') or die('Restricted access');

/* @var $this BookingModelUpgrade */

require_once dirname(__FILE__) . '/reinstall.php';

$db = JFactory::getDbo();

$db->setQuery('SHOW FIELDS FROM #__booking_email WHERE Field = ' . $db->quote('pdf'));
if (!$db->loadObject()) {
    $this->_addSQL('ALTER TABLE #__booking_email ADD pdf TEXT NOT NULL AFTER sms');
}

$db->setQuery('SHOW FIELDS FROM #__booking_reservation_items WHERE Field = ' . $db->quote('period_rtype_id'));
if (!$db->loadObject()) {
    $this->_addSQL('ALTER TABLE #__booking_reservation_items ADD period_rtype_id INT NOT NULL');
}

$db->setQuery('SHOW FIELDS FROM #__booking_reservation_items WHERE Field = ' . $db->quote('period_price_id'));
if (!$db->loadObject()) {
    $this->_addSQL('ALTER TABLE #__booking_reservation_items ADD period_price_id INT NOT NULL');
}