| 1 |
<?php
|
| 2 |
// $Id: $
|
| 3 |
function accommodation_install() {
|
| 4 |
|
| 5 |
switch ($GLOBALS['db_type']) {
|
| 6 |
case 'pgsql':
|
| 7 |
case 'mysql':
|
| 8 |
case 'mysqli':
|
| 9 |
db_query("CREATE TABLE {accommodation_availability} (
|
| 10 |
aid int(10) unsigned NOT NULL auto_increment,
|
| 11 |
bid int(10) unsigned NOT NULL default '0',
|
| 12 |
iid int(10) unsigned NOT NULL default '0',
|
| 13 |
date date NOT NULL default '0000-00-00',
|
| 14 |
price decimal(10,2) default NULL,
|
| 15 |
min_nights int(4) NOT NULL default '0',
|
| 16 |
status tinyint(4) default '0',
|
| 17 |
reserved_date datetime NOT NULL default '0000-00-00 00:00:00',
|
| 18 |
PRIMARY KEY (aid),
|
| 19 |
KEY date (date),
|
| 20 |
KEY bid (bid),
|
| 21 |
KEY iid (iid)
|
| 22 |
) /*!40100 DEFAULT CHARACTER SET utf8 */;");
|
| 23 |
db_query("CREATE TABLE {accommodation_bed_types} (
|
| 24 |
bed_id int(10) unsigned NOT NULL auto_increment,
|
| 25 |
name varchar(20) NOT NULL default '',
|
| 26 |
PRIMARY KEY (bed_id)
|
| 27 |
) /*!40100 DEFAULT CHARACTER SET utf8 */;");
|
| 28 |
db_query("CREATE TABLE {accommodation_inventory} (
|
| 29 |
iid int(10) unsigned NOT NULL auto_increment,
|
| 30 |
bid int(10) unsigned NOT NULL default '0',
|
| 31 |
unit_id int(10) unsigned NOT NULL default '0',
|
| 32 |
name varchar(20) NOT NULL default '',
|
| 33 |
PRIMARY KEY (iid),
|
| 34 |
KEY bid (bid),
|
| 35 |
KEY unit_id (unit_id)
|
| 36 |
) /*!40100 DEFAULT CHARACTER SET utf8 */;");
|
| 37 |
db_query("CREATE TABLE {accommodation_price} (
|
| 38 |
price int(10) unsigned NOT NULL,
|
| 39 |
display_name varchar(45) NOT NULL default '',
|
| 40 |
operator varchar(45) NOT NULL default '',
|
| 41 |
PRIMARY KEY (price)
|
| 42 |
) /*!40100 DEFAULT CHARACTER SET utf8 */;");
|
| 43 |
db_query("CREATE TABLE {accommodation_types} (
|
| 44 |
accommodation_id int(10) unsigned NOT NULL auto_increment,
|
| 45 |
name varchar(45) NOT NULL default '',
|
| 46 |
displayname varchar(45) NOT NULL default '',
|
| 47 |
weight INTEGER NOT NULL default 0,
|
| 48 |
PRIMARY KEY (accommodation_id),
|
| 49 |
UNIQUE KEY(name)
|
| 50 |
) /*!40100 DEFAULT CHARACTER SET utf8 */;");
|
| 51 |
db_query("CREATE TABLE {accommodation_units} (
|
| 52 |
nid int(10) unsigned NOT NULL default '0',
|
| 53 |
bid int(10) unsigned NOT NULL default '0',
|
| 54 |
utype varchar(20) NOT NULL default '',
|
| 55 |
occupancy tinyint(2) NOT NULL default '0',
|
| 56 |
bathrooms tinyint(2) NOT NULL default '0',
|
| 57 |
checkin text NOT NULL,
|
| 58 |
PRIMARY KEY (nid,bid)
|
| 59 |
) /*!40100 DEFAULT CHARACTER SET utf8 */;");
|
| 60 |
break;
|
| 61 |
}
|
| 62 |
|
| 63 |
// Notify of changes
|
| 64 |
if(function_exists('ec_mail_reset_to_defaults')){
|
| 65 |
require_once(drupal_get_path('module', 'ec_mail') . '/ec_mail.module');
|
| 66 |
// include the install's own module so that the constants are defined.
|
| 67 |
require_once(drupal_get_path('module', 'accommodation') .'/accommodation.module');
|
| 68 |
ec_mail_reset_to_defaults(array(ECMAIL_TYPE_CONFIRMATION));
|
| 69 |
}
|
| 70 |
drupal_set_message(t('Accommodation module was successfully installed with default options'));
|
| 71 |
|
| 72 |
}
|
| 73 |
|
| 74 |
/**
|
| 75 |
* Updates to ecommerce tables for booking engine
|
| 76 |
*/
|
| 77 |
function accommodation_update_1() {
|
| 78 |
$items = array();
|
| 79 |
$items[] = update_sql("ALTER TABLE {ec_address} ADD phone2 varchar(45) NOT NULL default ''");
|
| 80 |
$items[] = update_sql("ALTER TABLE {ec_address} ADD email2 varchar(45) NOT NULL default ''");
|
| 81 |
$items[] = update_sql("ALTER TABLE {ec_address} ADD GST varchar(45) NOT NULL default ''");
|
| 82 |
return $items;
|
| 83 |
}
|
| 84 |
|
| 85 |
function accommodation_update_2() {
|
| 86 |
$items = array();
|
| 87 |
$items[] = update_sql("ALTER TABLE {ec_transaction_product} ADD last_notify INTEGER UNSIGNED NOT NULL default 0");
|
| 88 |
$items[] = update_sql("ALTER TABLE {ec_transaction_product} DROP PRIMARY KEY");
|
| 89 |
$items[] = update_sql("ALTER TABLE {ec_transaction_product} ADD PRIMARY KEY(txnid, nid, last_notify)");
|
| 90 |
return $items;
|
| 91 |
}
|
| 92 |
|
| 93 |
function accommodation_update_3() {
|
| 94 |
$items = array();
|
| 95 |
$items[] = update_sql("ALTER TABLE {accommodation_types} ADD weight INTEGER NOT NULL default 0");
|
| 96 |
return $items;
|
| 97 |
}
|
| 98 |
|
| 99 |
function accommodation_update_4() {
|
| 100 |
$items = array();
|
| 101 |
$items[] = update_sql("ALTER TABLE {accommodation_types} DROP COLUMN term_id");
|
| 102 |
return $items;
|
| 103 |
}
|
| 104 |
|
| 105 |
function accommodation_update_5() {
|
| 106 |
$items = array();
|
| 107 |
$items[] = update_sql("ALTER TABLE {accommodation_types} ADD UNIQUE KEY(name)");
|
| 108 |
return $items;
|
| 109 |
}
|
| 110 |
|
| 111 |
function accommodation_update_6() {
|
| 112 |
$items = array();
|
| 113 |
$items[] = update_sql("ALTER TABLE {ec_transaction} ADD request TEXT NOT NULL");
|
| 114 |
return $items;
|
| 115 |
}
|
| 116 |
|
| 117 |
function accommodation_update_7() {
|
| 118 |
$items = array();
|
| 119 |
$items[] = update_sql("ALTER TABLE {accommodation_inventory} ADD INDEX unit_id(unit_id)");
|
| 120 |
return $items;
|
| 121 |
}
|
| 122 |
|
| 123 |
function accommodation_update_8() {
|
| 124 |
$items = array();
|
| 125 |
$items[] = update_sql("ALTER TABLE {ec_transaction_product} ADD item_status INTEGER UNSIGNED NOT NULL default 0");
|
| 126 |
return $items;
|
| 127 |
}
|
| 128 |
|
| 129 |
function accommodation_update_9() {
|
| 130 |
$items = array();
|
| 131 |
$items[] = update_sql("ALTER TABLE {ec_transaction_product} ADD dataid INTEGER UNSIGNED NOT NULL default 0");
|
| 132 |
return $items;
|
| 133 |
}
|
| 134 |
|
| 135 |
function accommodation_update_10() {
|
| 136 |
$items = array();
|
| 137 |
$items[] = update_sql("ALTER TABLE {ec_transaction_address} ADD phone varchar(45) NOT NULL default ''");
|
| 138 |
return $items;
|
| 139 |
}
|
| 140 |
|
| 141 |
function accommodation_update_11(){
|
| 142 |
$items = array();
|
| 143 |
module_rebuild_cache();
|
| 144 |
return $items;
|
| 145 |
}
|
| 146 |
|
| 147 |
function accommodation_update_12(){
|
| 148 |
$items = array();
|
| 149 |
require_once(drupal_get_path('module', 'ec_mail') . '/ec_mail.module');
|
| 150 |
// include the install's own module so that the constants are defined.
|
| 151 |
require_once(drupal_get_path('module', 'accommodation') .'/accommodation.module');
|
| 152 |
ec_mail_reset_to_defaults(array(ECMAIL_TYPE_CONFIRMATION));
|
| 153 |
return $items;
|
| 154 |
}
|
| 155 |
|
| 156 |
function accommodation_update_13() {
|
| 157 |
$items = array();
|
| 158 |
$items[] = update_sql("ALTER TABLE {accommodation_units} ADD checkin TEXT NOT NULL default ''");
|
| 159 |
return $items;
|
| 160 |
}
|
| 161 |
|
| 162 |
function accommodation_update_14() {
|
| 163 |
$items = array();
|
| 164 |
menu_rebuild();
|
| 165 |
return $items;
|
| 166 |
}
|