<?php
/*
# ---------------------------------------------------------
# ALLOW TO HAVE SUBJECT TEMPLATES FOR EVERY EMAIL TEMPLATE
# ---------------------------------------------------------
*/

$query3 = "SELECT value FROM `setting` WHERE name = 'plugin_rebiller_E-mail Subject'";
$result3 = mysql_query($query3) or die("ERROR in query: $query3");
list($value3) = mysql_fetch_row($result3);
$value3 = mysql_real_escape_string($value3);
$insert3 = "INSERT INTO `setting` SET id=NULL, name = 'Overdue Invoice Subject Template', value = '$value3', description = 'Email subject template used when notifying customer of outstanding invoices using the Invoice Reminder service. You may use tags', `type`=7,isrequired =1,istruefalse =0,istextarea =0,isfromoptions =0,myorder =5,helpid =2,plugin =0, ispassword =0,ishidden =0";
mysql_query($insert3) or die("ERROR in query: $insert3");

$query4 = "SELECT value FROM `setting` WHERE name = 'plugin_batchnotifier_E-mail Subject'";
$result4 = mysql_query($query4) or die("ERROR in query: $query4");
list($value4) = mysql_fetch_row($result4);
$value4 = mysql_real_escape_string($value4);
$insert4 = "INSERT INTO `setting` SET id=NULL, name = 'Batch Invoice Notification Subject Template', value = '$value4', description = 'Subject Template for the email sent to clients by the upcoming batch invoice notifier service. You may use tags', `type`=7,isrequired =1,istruefalse =0,istextarea =0,isfromoptions =0,myorder =7,helpid =2,plugin =0, ispassword =0,ishidden =0";
mysql_query($insert4) or die("ERROR in query: $insert4");

$query5 = "SELECT value FROM `setting` WHERE name = 'plugin_expiringcc_E-mail Subject'";
$result5 = mysql_query($query5) or die("ERROR in query: $query5");
list($value5) = mysql_fetch_row($result5);
$value5 = mysql_real_escape_string($value5);
$insert5 = "INSERT INTO `setting` SET id=NULL, name = 'Expiring CC Subject Template', value = '$value5', description = 'Subject Template for the email sent to clients by the expiring credit card notifier service. You may use tags', `type`=7,isrequired =1,istruefalse =0,istextarea =0,isfromoptions =0,myorder =9,helpid =10,plugin =0, ispassword =0,ishidden =0";
mysql_query($insert5) or die("ERROR in query: $insert5");

$query6 = "SELECT value FROM `setting` WHERE name = 'Company Name'";
$result6 = mysql_query($query6) or die("ERROR in query: $query6");
list($value6) = mysql_fetch_row($result6);
$value6 = mysql_real_escape_string($value6);
$insert6 = "INSERT INTO `setting` (id, name, value, description, type, isrequired, istruefalse, istextarea, isfromoptions, myorder, helpid, plugin, ispassword, ishidden) VALUES (NULL, 'Recommend Us Subject Template', '$value6', 'Subject Template used to allow your clients to recommend your services to both their associates and friends. You may use tags', 7, 0, 0, 0, 0, 11, 3, 0, 0, 0)";
mysql_query($insert6) or die("ERROR in query: $insert6");



/*
# ---------------------------------------------------------
# DOMAIN PACKAGE ADD-ONS PRICES NOW STORES THE NEXT BILLING DATE
# ---------------------------------------------------------
*/

$query7 = "ALTER TABLE `domain_packageaddon_prices` ADD COLUMN `nextbilldate` DATE default NULL";
mysql_query($query7) or die("ERROR in query: $query7");

$query8 = "SELECT packageaddon_prices_id, appliestoid, nextbilldate FROM recurringfee WHERE billingtypeid=-4";
$result8 = mysql_query($query8) or die("ERROR in query: $query8");
while (list($packageaddon_prices_id, $appliestoid, $nextbilldate) = mysql_fetch_row($result8)) {
    $query9 = "UPDATE domain_packageaddon_prices SET nextbilldate = '$nextbilldate' WHERE domain_id = '$appliestoid' AND packageaddon_prices_id = '$packageaddon_prices_id'";
    mysql_query($query9) or die("ERROR in query: $query9");
}


/*
# ---------------------------------------------------------
# ENSURE THAT THE TWO DASHBOARD GRAPHS ARE POPULATED
# ---------------------------------------------------------
*/
$query10 = "SELECT * FROM `report` WHERE `name`='monthly_signup_rate_and_percentage-account_&_packages.php'";
$result10 = mysql_query($query10) or die("ERROR in query: $query10");
if (!mysql_num_rows($result10)) {
    $query11 = "INSERT INTO `report` VALUES ('monthly_signup_rate_and_percentage-account_&_packages.php', 1, 0, 1)";
    $result11 = mysql_query($query11) or die("ERROR in query: $query11");
}

$query12 = "SELECT * FROM `report` WHERE `name`='trouble_tickets_opened-support.php'";
$result12 = mysql_query($query12) or die("ERROR in query: $query12");
if (!mysql_num_rows($result12)) {
    $query13 = "INSERT INTO `report` VALUES ('trouble_tickets_opened-support.php', 1, 0, 1)";
    $result13 = mysql_query($query13) or die("ERROR in query: $query13");
}


?>
