# --------------------------------------------------------
# VERSION UPDATING
# --------------------------------------------------------
UPDATE `setting` set value='2.7.4 beta1' WHERE name='ClientExec Version';

# ----------------------------------------------------------
# BULK MAILER REQUIRES ADDITIONAL SPACE TO STORE ATTACHMENTS
# ----------------------------------------------------------
ALTER TABLE `email_queue` CHANGE `attachment` `attachment` LONGTEXT NOT NULL;

# --------------------------------------------------------
# FIX TO BUG SETTING AUTOPAYMENT=0 IN SIGNUP
# --------------------------------------------------------
UPDATE users SET autopayment=1 WHERE paymenttype IN ('authnet', 'bluepay', 'eprocessingnetwork', 'psigate');

# --------------------------------------------------------
# ENSURE PROPER DOMAIN FORMAT ALWAYS EXCEPT FOR SUBDOMAINS
# --------------------------------------------------------
DELETE FROM setting WHERE name = 'Ensure Proper Domain Format';

# --------------------------------------------------------
# ADDs NEW TAGS FOR THE INVOICE TEMPLATE SEND THROUGH EMAIL
# --------------------------------------------------------
UPDATE `help` SET `detail` = '[<font class=bodyhighlight>DATE</font>] Date payment is due.<br>[<font class=bodyhighlight>SENTDATE</font>] Date invoice was originally sent.<br>[<font class=bodyhighlight>CLIENTNAME</font>] <br>[<font class=bodyhighlight>CLIENTEMAIL</font>] <br>[<font class=bodyhighlight>INVOICENUMBER</font>]<br>[<font class=bodyhighlight>INVOICEDESCRIPTION</font>]<br>[<font class=bodyhighlight>TAX</font>]<br>[<font class=bodyhighlight>AMOUNT_EX_TAX</font>] The total price excluding taxes.<br>[<font class=bodyhighlight>AMOUNT</font>] The total price due.<br>[<font class=bodyhighlight>CLIENTAPPLICATIONURL</font>] URL to Client Exec.<br>[<font class=bodyhighlight>FORGOTPASSWORDURL</font>] URL to retrieve forgotten password.<BR>[<font class=bodyhighlight>COMPANYNAME</font>] <BR>[<font class=bodyhighlight>BILLINGEMAIL</font>] Email address for billing inquiries<br>[<font class=bodyhighlight>CUSTOMPROFILE_xxxx</font>]<br>where xxx is custom profile field name' WHERE `id` =2 LIMIT 1 ;

# --------------------------------------------------------
# NEW PACKAGE ADDONS FUNCTIONALITY
# --------------------------------------------------------
CREATE TABLE `packageaddon` (
    `id` INT NOT NULL AUTO_INCREMENT ,
    `package_id` INT NOT NULL ,
    `description` VARCHAR( 50 ) NOT NULL ,
    `plugin_var` VARCHAR( 50 ) NOT NULL ,
    PRIMARY KEY ( `id` )
) ENGINE=MyISAM;

CREATE TABLE `packageaddon_prices` (
    `id` int(11) NOT NULL auto_increment,
    `packageaddon_id` int(11) NOT NULL default '0',
    `sortkey` int(11) NOT NULL default '0',
    `detail` varchar(50) NOT NULL default '',
    `plugin_var_value` varchar(50) NOT NULL default '',
    `price0` float NOT NULL default '-1',
    `price1` float NOT NULL default '-1',
    `price1_force` smallint(6) NOT NULL default '0',
    `price3` float NOT NULL default '-1',
    `price3_force` smallint(6) NOT NULL default '0',
    `price6` float NOT NULL default '-1',
    `price6_force` tinyint(4) NOT NULL default '0',
    `price12` float NOT NULL default '-1',
    `price12_force` tinyint(4) NOT NULL default '0',
    PRIMARY KEY  (`id`)
) ENGINE=MyISAM;

CREATE TABLE `domain_packageaddon_prices` (
    `domain_id` int(11) NOT NULL default '0',
    `packageaddon_prices_id` int(11) NOT NULL default '0',
    `billing_cycle` tinyint(4) NOT NULL default '0',
    PRIMARY KEY  (`domain_id`,`packageaddon_prices_id`)
) ENGINE=MyISAM;

ALTER TABLE `recurringfee` ADD `packageaddon_prices_id` INT NOT NULL AFTER `billingtypeid` ;

INSERT INTO `billingtype` ( `id` , `name` , `description` , `detail` ) VALUES ('-4', 'Package add-on', 'Package add-on', 'Package add-on fee');


# -------------------------------------------------------------
# INSERTS NEW HELP ITEM FOR ADD ANNOUNCEMENT IN THE ADMIN MENU
# -------------------------------------------------------------
INSERT INTO `help` (`title` , `detail` , `linkwords` , `width` , `height` )VALUES ('Announcement Tags', '[<font class=bodyhighlight>CLIENTNAME</font>]<br> Includes name and last name<br>[<font class=bodyhighlight>FIRSTNAME</font>]<br> First name of the client<br>[<font class=bodyhighlight>LASTNAME</font>]<br> Last name of the client<br>[<font class=bodyhighlight>ORGANIZATION</font>]<br> Client`s Organization<br>[<font class=bodyhighlight>DATE</font>]<br> Actual Date<br>[<font class=bodyhighlight>COMPANYNAME</font>] <br> Company name', 'Click to view available tags', '240', '320');

# -------------------------------------------------------------
# INCREASE THE SHOW IN SIGNUP PACKAGE VARIABLE TO SMALLINT
# -------------------------------------------------------------
ALTER TABLE `package` CHANGE `showpackage` `showpackage` SMALLINT( 6 ) NOT NULL DEFAULT '1';

# -----------------------------------------------------------
# ALLOW ADMIN EMAIL CUSTOM FIELD
# -----------------------------------------------------------
INSERT INTO `customuserfields` VALUES (NULL, 'Receive Email Announcements', 16, 1, 2, 0, 0, 18, 1, 0, 1, 1, '');
