Exemple #1
0
function checkPSVersion()
{
    $upgrader = new Upgrader();
    return $upgrader->checkPSVersion();
}
    public function display()
    {
        global $cookie;
        $this->warnDomainName();
        $tab = get_class();
        $protocol = Tools::usingSecureMode() ? 'https' : 'http';
        $isoDefault = Language::getIsoById(intval(Configuration::get('PS_LANG_DEFAULT')));
        $isoUser = Language::getIsoById(intval($cookie->id_lang));
        $isoCountry = Country::getIsoById(Configuration::get('PS_COUNTRY_DEFAULT'));
        $currency = new Currency((int) Configuration::get('PS_CURRENCY_DEFAULT'));
        $employee = new Employee($cookie->id_employee);
        echo '<div>
		<h1>' . $this->l('Dashboard') . '</h1>
		<hr style="background-color: #812143;color: #812143;" />
		<br />';
        if (@ini_get('allow_url_fopen')) {
            $upgrade = new Upgrader();
            if ($update = $upgrade->checkPSVersion()) {
                echo '<div class="warning warn" style="margin-bottom:30px;"><h3>' . $this->l('New PrestaShop version available') . ' : <a style="text-decoration: underline;" href="' . $update['link'] . '" target="_blank">' . $this->l('Download') . '&nbsp;' . $update['name'] . '</a> !</h3></div>';
            }
        } else {
            echo '<p>' . $this->l('Update notification unavailable') . '</p>';
            echo '<p>&nbsp;</p>';
            echo '<p>' . $this->l('To receive PrestaShop update warnings, you need to activate the <b>allow_url_fopen</b> command in your <b>php.ini</b> config file.') . ' [<a href="http://www.php.net/manual/' . $isoUser . '/ref.filesystem.php">' . $this->l('more info') . '</a>]</p>';
            echo '<p>' . $this->l('If you don\'t know how to do that, please contact your host administrator !') . '</p><br>';
        }
        echo '</div>';
        if ($employee->bo_show_screencast) {
            echo '
			<div id="adminpresentation">
				<iframe src="' . $protocol . '://screencasts.prestashop.com/screencast.php?iso_lang=' . Tools::strtolower($isoUser) . '" style="border:none;width:100%;height:420px;" scrolling="no"></iframe>
				<div id="footer_iframe_home">
					<!--<a href="#">' . $this->l('View more video tutorials') . '</a>-->
					<input type="checkbox" id="screencast_dont_show_again"><label for="screencast_dont_show_again">' . $this->l('don\'t show again') . '</label>
				</div>
			</div>
			<script type="text/javascript">
			$(document).ready(function() {
				$(\'#screencast_dont_show_again\').click(function() {
					if ($(this).is(\':checked\'))
					{
						$.ajax({
							type: \'POST\',
							async: true,
							url: \'ajax.php?toggleScreencast\',
							success: function(data) {
								$(\'#adminpresentation\').slideUp(\'slow\');
							}
						});
					}
				});
			});
			</script>
			<div class="clear"></div><br />';
        }
        echo '
		<div id="column_left">
			<ul class="F_list clearfix">
				<li id="first_block">
					<h4><a href="index.php?tab=AdminCatalog&addcategory&token=' . Tools::getAdminTokenLite('AdminCatalog') . '">' . $this->l('New category') . '</a></h4>
					<p>' . $this->l('Create a new category and organize your products.') . '</p>
				</li>
				<li id="second_block">
					<h4><a href="index.php?tab=AdminCatalog&id_category=1&addproduct&token=' . Tools::getAdminTokenLite('AdminCatalog') . '">' . $this->l('New product') . '</a></h4>
					<p>' . $this->l('Fill up your catalog with new articles and attributes.') . '</p>
				</li>
				<li id="third_block">
					<h4><a href="index.php?tab=AdminStats&token=' . Tools::getAdminTokenLite('AdminStats') . '">' . $this->l('Statistics') . '</a></h4>
					<p>' . $this->l('Manage your activity with a thorough analysis of your e-shop.') . '</p>
				</li>
				<li id="fourth_block">
					<h4><a href="index.php?tab=AdminEmployees&addemployee&token=' . Tools::getAdminTokenLite('AdminEmployees') . '">' . $this->l('New employee') . '</a></h4>
					<p>' . $this->l('Add a new employee account and discharge a part of your duties of shop owner.') . '</p>
				</li>
			</ul>
			';
        $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow('
			SELECT SUM(o.`total_paid_real` / o.conversion_rate) as total_sales, COUNT(*) as total_orders
			FROM `' . _DB_PREFIX_ . 'orders` o
			WHERE o.valid = 1
			AND o.`invoice_date` BETWEEN \'' . date('Y-m') . '-01 00:00:00\' AND \'' . date('Y-m') . '-31 23:59:59\' ');
        $result2 = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow('
			SELECT COUNT(`id_customer`) AS total_registrations
			FROM `' . _DB_PREFIX_ . 'customer` c
			WHERE c.`date_add` BETWEEN \'' . date('Y-m') . '-01 00:00:00\' AND \'' . date('Y-m') . '-31 23:59:59\'');
        $result3 = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow('
			SELECT SUM(pv.`counter`) AS total_viewed
			FROM `' . _DB_PREFIX_ . 'page_viewed` pv
			LEFT JOIN `' . _DB_PREFIX_ . 'date_range` dr ON pv.`id_date_range` = dr.`id_date_range`
			LEFT JOIN `' . _DB_PREFIX_ . 'page` p ON pv.`id_page` = p.`id_page`
			LEFT JOIN `' . _DB_PREFIX_ . 'page_type` pt ON pt.`id_page_type` = p.`id_page_type`
			WHERE pt.`name` = \'product.php\'
			AND dr.`time_start` BETWEEN \'' . date('Y-m') . '-01 00:00:00\' AND \'' . date('Y-m') . '-31 23:59:59\'
			AND dr.`time_end` BETWEEN \'' . date('Y-m') . '-01 00:00:00\' AND \'' . date('Y-m') . '-31 23:59:59\'');
        $results = array_merge($result, array_merge($result2, $result3));
        echo '
			<div class="table_info">
				<h5><a href="index.php?tab=AdminStats&token=' . Tools::getAdminTokenLite('AdminStats') . '">' . $this->l('View more') . '</a> ' . $this->l('Monthly Statistics') . ' </h5>
				<table class="table_info_details">
					<tr class="tr_odd">
						<td class="td_align_left">
						' . $this->l('Sales') . '
						</td>
						<td>
							' . Tools::displayPrice($results['total_sales'], $currency) . '
						</td>
					</tr>
					<tr>
						<td class="td_align_left">
							' . $this->l('Total registrations') . '
						</td>
						<td>
							' . (int) $results['total_registrations'] . '
						</td>
					</tr>
					<tr class="tr_odd">
						<td class="td_align_left">
							' . $this->l('Total orders') . '
						</td>
						<td>
							' . (int) $results['total_orders'] . '
						</td>
					</tr>
					<tr>
						<td class="td_align_left">
							' . $this->l('Product pages viewed') . '
						</td>
						<td>
							' . (int) $results['total_viewed'] . '
						</td>
					</tr>
				</table>
			</div>
			';
        $all = Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('SELECT COUNT(*) FROM ' . _DB_PREFIX_ . 'customer_thread');
        $unread = (int) Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('SELECT COUNT(*) FROM `' . _DB_PREFIX_ . 'customer_thread` WHERE `status` = "open"');
        $pending = (int) Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('SELECT COUNT(*) FROM `' . _DB_PREFIX_ . 'customer_thread` WHERE `status` LIKE "%pending%"');
        $close = $all - ($unread + $pending);
        echo '
			<div class="table_info" id="table_info_last">
				<h5><a href="index.php?tab=AdminCustomerThreads&token=' . Tools::getAdminTokenLite('AdminCustomerThreads') . '">' . $this->l('View more') . '</a> ' . $this->l('Customers service') . '</h5>
				<table class="table_info_details">
					<tr class="tr_odd">
						<td class="td_align_left">
						' . $this->l('Thread unread') . '
						</td>
						<td>
							' . $unread . '
						</td>
					</tr>
					<tr>
						<td class="td_align_left">
							' . $this->l('Thread pending') . '
						</td>
						<td>
							' . $pending . '
						</td>
					</tr>
					<tr class="tr_odd">
						<td class="td_align_left">
							' . $this->l('Thread closed') . '
						</td>
						<td>
							' . $close . '
						</td>
					</tr>
					<tr>
						<td class="td_align_left">
							' . $this->l('Total thread') . '
						</td>
						<td>
							' . $all . '
						</td>
					</tr>
				</table>
			</div>

			<div id="table_info_large">
				<h5><a href="index.php?tab=AdminStats&token=' . Tools::getAdminTokenLite('AdminStats') . '">' . $this->l('View more') . '</a> <strong>' . $this->l('Statistics') . '</strong> / ' . $this->l('Sales of the week') . '</h5>
				<div id="stat_google">';
        define('PS_BASE_URI', __PS_BASE_URI__);
        $chart = new Chart();
        $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS('
			SELECT total_paid / conversion_rate as total_converted, invoice_date
			FROM ' . _DB_PREFIX_ . 'orders o
			WHERE valid = 1
			AND invoice_date BETWEEN \'' . date('Y-m-d', strtotime('-7 DAYS', time())) . ' 00:00:00\' AND \'' . date('Y-m-d H:i:s') . '\'');
        foreach ($result as $row) {
            $chart->getCurve(1)->setPoint(strtotime($row['invoice_date']), $row['total_converted']);
        }
        $chart->setSize(580, 170);
        $chart->setTimeMode(strtotime('-7 DAYS', time()), time(), 'd');
        $chart->getCurve(1)->setLabel($this->l('Sales +Tx') . ' (' . strtoupper($currency->iso_code) . ')');
        $chart->display();
        echo '	</div>
			</div>
			<table cellpadding="0" cellspacing="0" id="table_customer">
				<thead>
					<tr>
						<th class="order_id"><span class="first">' . $this->l('ID') . '</span></th>
						<th class="order_customer"><span>' . $this->l('Customer Name') . '</span></th>
						<th class="order_status"><span>' . $this->l('Status') . '</span></th>
						<th class="order_total"><span>' . $this->l('Total') . '</span></th>
						<th class="order_action"><span class="last">' . $this->l('Action') . '</span></th>
					<tr>
				</thead>
				<tbody>';
        $orders = Order::getOrdersWithInformations(10);
        $i = 0;
        foreach ($orders as $order) {
            $currency = Currency::getCurrency((int) $order['id_currency']);
            echo '
					<tr' . ($i % 2 ? ' id="order_line1"' : '') . '>
						<td class="order_td_first order_id">' . (int) $order['id_order'] . '</td>
						<td class="order_customer">' . Tools::htmlentitiesUTF8($order['firstname']) . ' ' . Tools::htmlentitiesUTF8($order['lastname']) . '</td>
						<td class="order_status">' . Tools::htmlentitiesUTF8($order['state_name']) . '</td>
						<td class="order_total">' . Tools::displayPrice((double) $order['total_paid'], $currency) . '</td>
						<td class="order_action">
							<a href="index.php?tab=AdminOrders&id_order=' . (int) $order['id_order'] . '&vieworder&token=' . Tools::getAdminTokenLite('AdminOrders') . '" title="' . $this->l('Details') . '"><img src="../img/admin/details.gif" alt="' . $this->l('See') . '" /></a>
						</td>
					</tr>
				';
            $i++;
        }
        echo '
				</tbody>
			</table>
		</div>
		<div id="column_right">
			<script type="text/javascript">
				$(document).ready(function() {
					$.ajax({
						url: "ajax.php",
						dataType: "json",
						data: "getAdminHomeElement",
						success: function(json) {
							if (json.screencast != \'NOK\')
								$(\'#adminpresentation\').fadeIn(\'slow\');
							else
								$(\'#adminpresentation\').fadeOut(\'slow\');

							$(\'#partner_preactivation\').fadeOut(\'slow\', function() {
								if (json.partner_preactivation != \'NOK\')
									$(\'#partner_preactivation\').html(json.partner_preactivation);
								else
									$(\'#partner_preactivation\').html(\'\');
								$(\'#partner_preactivation\').fadeIn(\'slow\');
							});

							$(\'#discover_prestashop\').fadeOut(\'slow\', function() {
								if (json.discover_prestashop != \'NOK\')
									$(\'#discover_prestashop\').html(json.discover_prestashop);
								else
									$(\'#discover_prestashop\').html(\'\');
								$(\'#discover_prestashop\').fadeIn(\'slow\');
							});
						},
						error: function(XMLHttpRequest, textStatus, errorThrown)
						{
							$(\'#adminpresentation\').fadeOut(\'slow\');
							$(\'#partner_preactivation\').fadeOut(\'slow\');
							$(\'#discover_prestashop\').fadeOut(\'slow\');
						}
					});
				});
			</script>
			<div id="partner_preactivation">
				<p class="center"><img src="../img/loader.gif" alt="" /> ' . translate('Loading...') . '</p>
			</div>
		';
        if (Tools::isSubmit('hideOptimizationTips')) {
            Configuration::updateValue('PS_HIDE_OPTIMIZATION_TIPS', 1);
        }
        $this->_displayOptimizationTips();
        echo '
			<div id="discover_prestashop">
				<p class="center"><img src="../img/loader.gif" alt="" /> ' . translate('Loading...') . '</p>
			</div>
		</div>
		<div class="clear"></div>';
        echo Module::hookExec('backOfficeHome');
    }
    public function display()
    {
        $this->_html .= '<script type="text/javascript">var jQueryVersionPS = parseInt($().jquery.replace(/\\./g, ""));</script>
		<script type="text/javascript" src="' . __PS_BASE_URI__ . 'modules/autoupgrade/js/jquery-1.6.2.min.js"></script>
		<script type="text/javascript">if (jQueryVersionPS >= 162) jq162 = jQuery.noConflict(true);</script>';
        /* PrestaShop demo mode */
        if (defined('_PS_MODE_DEMO_') && _PS_MODE_DEMO_) {
            echo '<div class="error">' . $this->l('This functionality has been disabled.') . '</div>';
            return;
        }
        if (!file_exists($this->autoupgradePath . DIRECTORY_SEPARATOR . 'ajax-upgradetab.php')) {
            echo '<div class="error">' . '<img src="../img/admin/warning.gif" /> ' . $this->l('[TECHNICAL ERROR] ajax-upgradetab.php is missing. Please reinstall or reset the module.') . '</div>';
            return false;
        }
        /* PrestaShop demo mode*/
        // in order to not use Tools class
        $upgrader = new Upgrader();
        preg_match('#([0-9]+\\.[0-9]+)(?:\\.[0-9]+){1,2}#', _PS_VERSION_, $matches);
        $upgrader->branch = $matches[1];
        $channel = $this->getConfig('channel');
        switch ($channel) {
            case 'archive':
                $upgrader->channel = 'archive';
                $upgrader->version_num = $this->getConfig('archive.version_num');
                break;
            case 'directory':
                $upgrader->channel = 'directory';
                $upgrader->version_num = $this->getConfig('directory.version_num');
                break;
            default:
                $upgrader->channel = $channel;
                if (isset($_GET['refreshCurrentVersion'])) {
                    // delete the potential xml files we saved in config/xml (from last release and from current)
                    $upgrader->clearXmlMd5File(_PS_VERSION_);
                    $upgrader->clearXmlMd5File($upgrader->version_num);
                    if ($this->getConfig('channel') == 'private' && !$this->getConfig('private_allow_major')) {
                        $upgrader->checkPSVersion(true, array('private', 'minor'));
                    } else {
                        $upgrader->checkPSVersion(true, array('minor'));
                    }
                    Tools14::redirectAdmin($this->currentIndex . '&conf=5&token=' . Tools14::getValue('token'));
                } else {
                    if ($this->getConfig('channel') == 'private' && !$this->getConfig('private_allow_major')) {
                        $upgrader->checkPSVersion(false, array('private', 'minor'));
                    } else {
                        $upgrader->checkPSVersion(false, array('minor'));
                    }
                }
        }
        $this->upgrader = $upgrader;
        $this->_html .= '<link type="text/css" rel="stylesheet" href="' . __PS_BASE_URI__ . 'modules/autoupgrade/css/styles.css" />';
        $this->_html .= '<div class="bootstrap" id="informationBlock">
            <div class="panel">
                <div class="panel-heading">
                  ' . $this->l('Welcome!') . '
                </div>
                <p>
                    ' . $this->l('With the PrestaShop 1-Click Upgrade module, upgrading your store to the latest version available has never been easier!') . '<br /><br />
                    <span style="color:#CC0000;font-weight:bold">' . $this->l('Please always perform a full manual backup of your files and database before starting any upgrade.') . '</span><br />
                    ' . $this->l('Double-check the integrity of your backup and that you can easily manually roll-back if necessary.') . '<br />
                    ' . $this->l('If you do not know how to proceed, ask your hosting provider.') . '
                </p>
            </div>
            </div>';
        /* Make sure the user has configured the upgrade options, or set default values */
        $configuration_keys = array('PS_AUTOUP_UPDATE_DEFAULT_THEME' => 1, 'PS_AUTOUP_CHANGE_DEFAULT_THEME' => 0, 'PS_AUTOUP_KEEP_MAILS' => 0, 'PS_AUTOUP_CUSTOM_MOD_DESACT' => 1, 'PS_AUTOUP_MANUAL_MODE' => 0, 'PS_AUTOUP_PERFORMANCE' => 1, 'PS_DISPLAY_ERRORS' => 0);
        foreach ($configuration_keys as $k => $default_value) {
            if (Configuration::get($k) == '') {
                Configuration::updateValue($k, $default_value);
            }
        }
        /* Checks/requirements and "Upgrade PrestaShop now" blocks */
        $this->_displayCurrentConfiguration();
        $this->_displayBlockUpgradeButton();
        $this->_displayComparisonBlock();
        $this->_displayBlockActivityLog();
        $this->_displayRollbackForm();
        $this->_html .= '<br/>';
        $this->_html .= '<form action="' . $this->currentIndex . '&amp;customSubmitAutoUpgrade=1&amp;token=' . $this->token . '" method="post" class="form-horizontal" enctype="multipart/form-data">';
        $this->_displayForm('backupOptions', $this->_fieldsBackupOptions, '<a href="#" name="backup-options" id="backup-options">' . $this->l('Backup Options') . '</a>', '', 'database_gear');
        $this->_displayForm('upgradeOptions', $this->_fieldsUpgradeOptions, '<a href="#" name="upgrade-options" id="upgrade-options">' . $this->l('Upgrade Options') . '</a>', '', 'prefs');
        $this->_html .= '</form>';
        $this->_html .= '<script type="text/javascript" src="' . __PS_BASE_URI__ . 'modules/autoupgrade/js/jquery.xml2json.js"></script>';
        $this->_html .= '<script type="text/javascript">' . $this->_getJsInit() . '</script>';
        echo $this->_html;
    }
    public function display()
    {
        if (isset($_GET['refreshCurrentVersion'])) {
            $upgrader = new Upgrader();
            $upgrader->checkPSVersion(true);
            $this->upgrader = $upgrader;
        }
        echo '<style>
.autoupgradeSteps div {  line-height: 30px; }
.upgradestep { margin-right: 5px;padding-left: 10px; padding-right: 5px;}
#upgradeNow.stepok, .autoupgradeSteps a.stepok { background-image: url("../img/admin/enabled.gif");background-position: left center;background-repeat: no-repeat;padding-left: 15px;}
#upgradeNow {-moz-border-bottom-colors: none;-moz-border-image: none;-moz-border-left-colors: none;-moz-border-right-colors: none;-moz-border-top-colors: none;border-color: #FFF6D3 #DFD5AF #DFD5AF #FFF6D3;border-right: 1px solid #DFD5AF;border-style: solid;border-width: 1px;color: #268CCD;font-size: medium;padding: 5px;}
.button-autoupgrade {-moz-border-bottom-colors: none;-moz-border-image: none;-moz-border-left-colors: none;-moz-border-right-colors: none;-moz-border-top-colors: none;border-color: #FFF6D3 #DFD5AF #DFD5AF #FFF6D3;border-right: 1px solid #DFD5AF;border-style: solid;border-width: 1px;color: #268CCD;font-size: medium;padding: 5px;}
.processing {border:2px outset grey;margin-top:1px;overflow: auto;}
#dbResultCheck{ padding-left:20px;}
#checkPrestaShopFilesVersion{margin-bottom:20px;}
#changedList ul{list-style-type:circle}
.changedFileList {margin-left:20px; padding-left:5px;}
.changedNotice li{color:grey;}
.changedImportant li{color:red;font-weight:bold}
</style>';
        $this->displayWarning($this->l('This function is experimental. It\'s highly recommended to make a backup of your files and database before starting the upgrade process.'));
        global $currentIndex;
        // update['name'] = version name
        // update['num'] = only the version
        // update['link'] = download link
        // @TODO
        $this->createCustomToken();
        if ($this->useSvn) {
            echo '<div class="error"><h1>' . $this->l('Unstable upgrade') . '</h1>
				<p class="warning">' . $this->l('Your current configuration indicate you want to upgrade your system from the unstable development branch, with no version number. If you upgrade, you will not be able to follow the official release process anymore') . '.</p>
				</div>';
        }
        $this->_displayUpgraderForm();
        echo '<br/>';
        $this->_displayRollbackForm();
        echo '<br/>';
        $this->_displayForm('autoUpgradeOptions', $this->_fieldsAutoUpgrade, '<a href="" name="options" id="options">' . $this->l('Options') . '</a>', '', 'prefs');
        // @todo manual upload with a form
        // We need jquery 1.6 for json
        echo '<script type="text/javascript">
			jq13 = jQuery.noConflict(true);
			</script>
			<script type="text/javascript" src="' . __PS_BASE_URI__ . 'modules/autoupgrade/jquery-1.6.2.min.js"></script>';
        echo '<script type="text/javascript" src="' . __PS_BASE_URI__ . 'modules/autoupgrade/jquery.xml2json.js"></script>';
        echo '<script type="text/javascript">' . $this->_getJsInit() . '</script>';
    }
    public function display()
    {
        // We need jquery 1.6 for json
        // do we ?
        echo '<script type="text/javascript">
		if (jQuery == "undefined")
			jq13 = jQuery.noConflict(true);
			</script>
		<script type="text/javascript" src="' . __PS_BASE_URI__ . 'modules/autoupgrade/jquery-1.6.2.min.js"></script>';
        $this->createCustomToken();
        /* PrestaShop demo mode */
        if (defined('_PS_MODE_DEMO_') && _PS_MODE_DEMO_) {
            echo '<div class="error">' . $this->l('This functionnality has been disabled.') . '</div>';
            return;
        }
        if (!file_exists($this->autoupgradePath . DIRECTORY_SEPARATOR . 'ajax-upgradetab.php')) {
            echo '<div class="error">' . '<img src="../img/admin/warning.gif" /> [TECHNICAL ERROR] ' . $this->l('ajax-upgradetab.php is missing. please reinstall or reset the module') . '</div>';
            return false;
        }
        /* PrestaShop demo mode*/
        // in order to not use Tools class
        if (isset($_GET['refreshCurrentVersion'])) {
            $upgrader = new Upgrader();
            $upgrader->checkPSVersion(true);
            // delete the potential xml files we saved in config/xml (from last release and from current)
            $upgrader->clearXmlMd5File(_PS_VERSION_);
            $upgrader->clearXmlMd5File($upgrader->version_num);
            $this->upgrader = $upgrader;
        }
        echo '<style>
.autoupgradeSteps div {  line-height: 30px; }
.upgradestep { margin-right: 5px;padding-left: 10px; padding-right: 5px;}
#upgradeNow.stepok, .autoupgradeSteps a.stepok { background-image: url("../img/admin/enabled.gif");background-position: left center;background-repeat: no-repeat;padding-left: 15px;}
#upgradeNow {-moz-border-bottom-colors: none;-moz-border-image: none;-moz-border-left-colors: none;-moz-border-right-colors: none;-moz-border-top-colors: none;border-color: #FFF6D3 #DFD5AF #DFD5AF #FFF6D3;border-right: 1px solid #DFD5AF;border-style: solid;border-width: 1px;color: #268CCD;font-size: medium;padding: 5px;}
.button-autoupgrade {-moz-border-bottom-colors: none;-moz-border-image: none;-moz-border-left-colors: none;-moz-border-right-colors: none;-moz-border-top-colors: none;border-color: #FFF6D3 #DFD5AF #DFD5AF #FFF6D3;border-right: 1px solid #DFD5AF;border-style: solid;border-width: 1px;color: #268CCD;font-size: medium;padding: 5px;}
.processing {border:2px outset grey;margin-top:1px;overflow: auto;}
#dbResultCheck{ padding-left:20px;}
#checkPrestaShopFilesVersion, #checkPrestaShopModifiedFiles{margin-bottom:20px;}
#changedList ul{list-style-type:circle}
.changedFileList {margin-left:20px; padding-left:5px;}
.changedNotice li{color:grey;}
.changedImportant li{color:red;font-weight:bold}
.upgradeDbError{background-color:red}
.upgradeDbOk{background-color:green}
.small_label{font-weight:normal;width:300px;float:none;text-align:left;padding:0}
</style>';
        $this->displayWarning($this->l('This function is experimental. It\'s highly recommended to make a backup of your files and database before starting the upgrade process.'));
        global $currentIndex;
        // update['name'] = version name
        // update['num'] = only the version
        // update['link'] = download link
        // @TODO
        if ($this->useSvn) {
            echo '<div class="error"><h1>' . $this->l('Unstable upgrade') . '</h1>
				<p class="warning">' . $this->l('Your current configuration indicate you want to upgrade your system from the unstable development branch, with no version number. If you upgrade, you will not be able to follow the official release process anymore') . '.</p>
				</div>';
        }
        $this->_displayUpgraderForm();
        echo '<br/>';
        $this->_displayRollbackForm();
        echo '<br/>';
        $this->_displayForm('autoUpgradeOptions', $this->_fieldsAutoUpgrade, '<a href="" name="options" id="options">' . $this->l('Options') . '</a>', '', 'prefs');
        // @todo manual upload with a form
        echo '<script type="text/javascript" src="' . __PS_BASE_URI__ . 'modules/autoupgrade/jquery.xml2json.js"></script>';
        echo '<script type="text/javascript">' . $this->_getJsInit() . '</script>';
    }
    public function display()
    {
        global $currentIndex;
        // We need jquery 1.6 for json
        // do we ?
        $this->_html .= '<script type="text/javascript">
		if (jQuery == "undefined")
			jq13 = jQuery.noConflict(true);
			</script>
		<script type="text/javascript" src="' . __PS_BASE_URI__ . 'modules/autoupgrade/jquery-1.6.2.min.js"></script>';
        /* PrestaShop demo mode */
        if (defined('_PS_MODE_DEMO_') && _PS_MODE_DEMO_) {
            echo '<div class="error">' . $this->l('This functionnality has been disabled.') . '</div>';
            return;
        }
        if (!file_exists($this->autoupgradePath . DIRECTORY_SEPARATOR . 'ajax-upgradetab.php')) {
            echo '<div class="error">' . '<img src="../img/admin/warning.gif" /> [TECHNICAL ERROR] ' . $this->l('ajax-upgradetab.php is missing. please reinstall or reset the module') . '</div>';
            return false;
        }
        /* PrestaShop demo mode*/
        // in order to not use Tools class
        $upgrader = new Upgrader();
        preg_match('#([0-9]+\\.[0-9]+)(?:\\.[0-9]+){1,2}#', _PS_VERSION_, $matches);
        $upgrader->branch = $matches[1];
        $channel = $this->getConfig('channel');
        switch ($channel) {
            case 'archive':
                $upgrader->channel = 'archive';
                $upgrader->version_num = $this->getConfig('archive.version_num');
                break;
            case 'directory':
                $upgrader->channel = 'directory';
                $upgrader->version_num = $this->getConfig('directory.version_num');
                break;
            default:
                $upgrader->channel = $channel;
                if (isset($_GET['refreshCurrentVersion'])) {
                    // delete the potential xml files we saved in config/xml (from last release and from current)
                    $upgrader->clearXmlMd5File(_PS_VERSION_);
                    $upgrader->clearXmlMd5File($upgrader->version_num);
                    if ($this->getConfig('channel') == 'private' && !$this->getConfig('private_allow_major')) {
                        $upgrader->checkPSVersion(true, array('private', 'minor'));
                    } else {
                        $upgrader->checkPSVersion(true, array('minor'));
                    }
                    Tools::redirectAdmin($currentIndex . '&conf=5&token=' . Tools::getValue('token'));
                } else {
                    if ($this->getConfig('channel') == 'private' && !$this->getConfig('private_allow_major')) {
                        $upgrader->checkPSVersion(false, array('private', 'minor'));
                    } else {
                        $upgrader->checkPSVersion(false, array('minor'));
                    }
                }
        }
        $this->upgrader = $upgrader;
        $this->_html .= '<style type="text/css">
fieldset{margin-top:10px}
.autoupgradeSteps div {  line-height: 30px; }
.upgradestep { margin-right: 5px;padding-left: 10px; padding-right: 5px;}
#upgradeNow.stepok, .autoupgradeSteps a.stepok { background-image: url("../img/admin/enabled.gif");background-position: left center;background-repeat: no-repeat;padding-left: 15px;}
#upgradeNow {-moz-border-bottom-colors: none;-moz-border-image: none;-moz-border-left-colors: none;-moz-border-right-colors: none;-moz-border-top-colors: none;border-color: #FFF6D3 #DFD5AF #DFD5AF #FFF6D3;border-right: 1px solid #DFD5AF;border-style: solid;border-width: 1px;color: #268CCD;font-size: medium;padding: 5px;}
.button-autoupgrade {-moz-border-bottom-colors: none;-moz-border-image: none;-moz-border-left-colors: none;-moz-border-right-colors: none;-moz-border-top-colors: none;border-color: #FFF6D3 #DFD5AF #DFD5AF #FFF6D3;border-right: 1px solid #DFD5AF;border-style: solid;border-width: 1px;color: #268CCD;display:inline-block;font-size: medium;margin:10px 0;padding: 5px;}
.processing {border:2px outset grey;margin-top:1px;overflow: auto;}
#infoStep {height:100px;width:300px}
#infoError {height:100px;width:550px}
#quickInfo {height:200px}
#upgradeResultCheck{ padding-left:20px;}
#checkPrestaShopFilesVersion, #checkPrestaShopModifiedFiles{margin-bottom:20px;}
#changedList ul{list-style-type:circle}
.changedFileList {margin-left:20px; padding-left:5px;}
.changedNotice li{color:grey;}
.changedImportant li{color:red;font-weight:bold}
.upgradeDbError{background-color:#FEEFB3}
.upgradeDbOk{background-color:#DFF2BF}
.small_label{font-weight:normal;width:300px;float:none;text-align:left;padding:0}
.blocOneClickUpgrade{width:530px;float:left}
.ocu-feature-list{margin:0;padding:0;list-style:none}
.ocu-feature-list li{background:url(../img/admin/enabled.gif) no-repeat; padding-left:20px;margin:0;}
</style>';
        $this->_html .= '
		<h1>' . $this->l('1-click Upgrade') . '</h1>
		<fieldset id="informationBlock" class="information" style="float: left; width: 30%;">
			<legend>' . $this->l('Welcome!') . '</legend>
			<p>' . $this->l('With the PrestaShop 1-click upgrade module, upgrading your store to the latest version available has never been easier!') . '<br /><br />
			<img src="../img/admin/warning.gif" alt=""/><strong>' . $this->l('This module is still in a "beta" version.') . '</strong><br /><br /><span style="color: #CC0000; font-weight: bold;">' . $this->l('Please always perform a full manual backup of your files and database before starting any upgrade.') . '</span><br />' . $this->l('Double-check the integrity of your backup and that you can easily manually roll-back if necessary.') . '<br />' . $this->l('If you don\'t know how to proceed, ask your hosting provider.') . '</p>			
		</fieldset>';
        /* Make sure the user has configured the upgrade options, or set default values */
        $configuration_keys = array('PS_AUTOUP_KEEP_DEFAULT_THEME' => 0, 'PS_AUTOUP_KEEP_MAILS' => 0, 'PS_AUTOUP_CUSTOM_MOD_DESACT' => 1, 'PS_AUTOUP_MANUAL_MODE' => 0, 'PS_AUTOUP_PERFORMANCE' => 1, 'PS_DISPLAY_ERRORS' => 0);
        foreach ($configuration_keys as $k => $default_value) {
            if (Configuration::get($k) == '') {
                Configuration::updateValue($k, $default_value);
            }
        }
        /* Checks/requirements and "Upgrade PrestaShop now" blocks */
        $this->_displayCurrentConfiguration();
        $this->_html .= '<div class="clear"></div>';
        $this->_displayBlockUpgradeButton();
        $this->_displayComparisonBlock();
        $this->_displayBlockActivityLog();
        $this->_displayRollbackForm();
        $this->_html .= '<br/>';
        $this->_html .= '<form action="' . $currentIndex . '&customSubmitAutoUpgrade=1&token=' . $this->token . '"
			method="post" enctype="multipart/form-data">';
        $this->_displayForm('backupOptions', $this->_fieldsBackupOptions, '<a href="#" name="backup-options" id="backup-options">' . $this->l('Backup Options') . '</a>', '', 'database_gear');
        $this->_displayForm('upgradeOptions', $this->_fieldsUpgradeOptions, '<a href="#" name="upgrade-options" id="upgrade-options">' . $this->l('Upgrade Options') . '</a>', '', 'prefs');
        $this->_html .= '</form>';
        $this->_html .= '<script type="text/javascript" src="' . __PS_BASE_URI__ . 'modules/autoupgrade/jquery.xml2json.js"></script>';
        $this->_html .= '<script type="text/javascript">' . $this->_getJsInit() . '</script>';
        echo $this->_html;
    }