Exemplo n.º 1
0
    /**
     * @return array Get list of browser "plugins" (javascript, media player, etc.)
     */
    private function getEquipment()
    {
        $sql = 'SELECT DISTINCT g.*
				FROM `' . _DB_PREFIX_ . 'connections` c 
				LEFT JOIN `' . _DB_PREFIX_ . 'guest` g ON g.`id_guest` = c.`id_guest`
				WHERE c.`date_add` BETWEEN ' . ModuleGraph::getDateBetween() . '
					' . Shop::addSqlRestriction(false, 'c');
        $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->query($sql);
        $calcArray = array('jsOK' => 0, 'jsKO' => 0, 'javaOK' => 0, 'javaKO' => 0, 'wmpOK' => 0, 'wmpKO' => 0, 'qtOK' => 0, 'qtKO' => 0, 'realOK' => 0, 'realKO' => 0, 'flashOK' => 0, 'flashKO' => 0, 'directorOK' => 0, 'directorKO' => 0);
        while ($row = Db::getInstance(_PS_USE_SQL_SLAVE_)->nextRow($result)) {
            if (!$row['javascript']) {
                ++$calcArray['jsKO'];
                continue;
            }
            ++$calcArray['jsOK'];
            $row['windows_media'] ? ++$calcArray['wmpOK'] : ++$calcArray['wmpKO'];
            $row['real_player'] ? ++$calcArray['realOK'] : ++$calcArray['realKO'];
            $row['adobe_flash'] ? ++$calcArray['flashOK'] : ++$calcArray['flashKO'];
            $row['adobe_director'] ? ++$calcArray['directorOK'] : ++$calcArray['directorKO'];
            $row['sun_java'] ? ++$calcArray['javaOK'] : ++$calcArray['javaKO'];
            $row['apple_quicktime'] ? ++$calcArray['qtOK'] : ++$calcArray['qtKO'];
        }
        if (!$calcArray['jsOK']) {
            return false;
        }
        $equip = array('Windows Media Player' => $calcArray['wmpOK'] / ($calcArray['wmpOK'] + $calcArray['wmpKO']), 'Real Player' => $calcArray['realOK'] / ($calcArray['realOK'] + $calcArray['realKO']), 'Apple Quicktime' => $calcArray['qtOK'] / ($calcArray['qtOK'] + $calcArray['qtKO']), 'Sun Java' => $calcArray['javaOK'] / ($calcArray['javaOK'] + $calcArray['javaKO']), 'Adobe Flash' => $calcArray['flashOK'] / ($calcArray['flashOK'] + $calcArray['flashKO']), 'Adobe Shockwave' => $calcArray['directorOK'] / ($calcArray['directorOK'] + $calcArray['directorKO']));
        arsort($equip);
        return $equip;
    }
Exemplo n.º 2
0
    function hookAdminStatsModules()
    {
        $result = Db::getInstance()->ExecuteS($this->_query . ModuleGraph::getDateBetween() . $this->_query2);
        $this->_html = '<fieldset class="width3"><legend><img src="../modules/' . $this->name . '/logo.gif" /> ' . $this->displayName . '</legend>';
        if ($result and sizeof($result)) {
            $table = '<div style="overflow-y: scroll; height: 600px;">
			<table class="table" border="0" cellspacing="0" cellspacing="0">
			<thead>
				<tr><th style="width:400px;">' . $this->l('Keywords') . '</th>
				<th style="width:50px; text-align: right">' . $this->l('Occurences') . '</th></tr>
			</thead><tbody>';
            foreach ($result as $index => $row) {
                $keyword =& $row['keyword'];
                $occurences =& $row['occurences'];
                $table .= '<tr><td>' . $keyword . '</td><td style="text-align: right">' . $occurences . '</td></tr>';
            }
            $table .= '</tbody></table></div>';
            $this->_html .= '<center>' . ModuleGraph::engine(array('type' => 'pie')) . '</center><br class="clear" />' . $table;
        } else {
            $this->_html .= '<p><strong>' . $this->l('No keyword searched for more than once found') . '</strong></p>';
        }
        $this->_html .= '</fieldset><br class="clear" />
		<fieldset class="width3"><legend><img src="../img/admin/comment.gif" /> ' . $this->l('Guide') . '</legend>
			<h2>' . $this->l('Identify external search engines keywords') . '</h2>
			<p>' . $this->l('There are many ways to find a website, but one of the most common is to find it with a search engine. Identifying the most "visitor-making" keywords entered by your new visitors is really important, it allows you to see which product you have to put in front if you want more visitors and customers.') . '</p><br />
			<h3>' . $this->l('How does it work?') . '</h2>
			<p>' . $this->l('When a visitors comes to your website, the server knows its previous location. This module parses this URL and finds the keywords in it. Currently, it manages the following search engines:') . '<b> Google, AOL, Yandex, Ask, NHL, Yahoo, Baidu, Lycos, Exalead, Live, Voila</b> ' . $this->l('and') . ' <b>Altavista</b>. ' . $this->l('Soon it will be possible to add dynamically new search engine and to contribute to this module!') . '</p><br />
		</fieldset>';
        return $this->_html;
    }
Exemplo n.º 3
0
    public function hookAdminStatsModules($params)
    {
        $totalVisits = $this->getTotalVisits();
        $totalGuests = $this->getTotalGuests();
        $this->_html = '
		<fieldset class="width3"><legend><img src="../modules/' . $this->name . '/logo.gif" /> ' . $this->displayName . '</legend>
			<p><center>
				<img src="../img/admin/down.gif" />' . $this->l('A visit correspond to the coming of an internet user on your shop. Until the end of his session, only one visit is counted.') . '
				' . $this->l('A visitor is an unknown person - who has not registered or logged on - surfing on your shop. A visitor can come and visit your shop many times.') . '
			</center></p>
			<div style="margin-top:20px"></div>
			<p>' . $this->l('Total visits:') . ' ' . $totalVisits . '</p>
			<p>' . $this->l('Total visitors:') . ' ' . $totalGuests . '</p>
			' . ($totalVisits ? ModuleGraph::engine(array('layers' => 2, 'type' => 'line', 'option' => 3)) . '<br /><br />' : '') . '
		</fieldset>
		<br class="clear" />
		<fieldset class="width3"><legend><img src="../img/admin/comment.gif" /> ' . $this->l('Guide') . '</legend>
				<h2>' . $this->l('Determine the interest of a visit') . '</h2>
				' . $this->l('Visitors\' evolution graph strongly looks like to the visits\' graph, but provides an additional information: <strong>Do your visitors come back?</strong>') . '<br />
				<ul>
					<li>' . $this->l('if this is the case, congratulations, your website is well-thought-out and undeniably pleases.') . '</li>
					<li>' . $this->l('Otherwise, the conclusion is not so simple. The problem can be esthetic or ergonomic, or else the offer not sufficient. It\'s also possible that these visitors mistakenly came here, without particular interest for your shop; this phenomenon often happens with the search engines.') . '</li>
				</ul>
				' . $this->l('This information is mostly qualitative: you have to determin the interest of a disjointed visit.') . '<br />
		</fieldset>';
        return $this->_html;
    }
Exemplo n.º 4
0
    public function hookAdminStatsModules($params)
    {
        $equipment = $this->getEquipment();
        $this->_html = '
		<fieldset class="width3"><legend><img src="../modules/' . $this->name . '/logo.gif" /> ' . $this->displayName . '</legend>
			<center>
				<p><img src="../img/admin/down.gif" />' . $this->l('Determine the percentage of web browser used by your customers.') . '</p>
				' . ModuleGraph::engine(array('type' => 'pie', 'option' => 'wb')) . '<br /><br />
				<p><img src="../img/admin/down.gif" />' . $this->l('Determine the percentage of operating systems used by your customers.') . '</p>
				' . ModuleGraph::engine(array('type' => 'pie', 'option' => 'os')) . '';
        if ($equipment) {
            $this->_html .= '<table class="table space" border="0" cellspacing="0" cellpadding="0">
			<tr><th style="width: 200px">' . $this->l('Plug-ins') . '</th><th></th></tr>';
            foreach ($equipment as $name => $value) {
                $this->_html .= '<tr><td>' . $name . '</td><td>' . number_format(100 * $value, 2) . '%</td></tr>';
            }
            $this->_html .= '</table>';
        }
        $this->_html .= '
			</center>
		</fieldset><br />
		<fieldset class="width3"><legend><img src="../img/admin/comment.gif" /> ' . $this->l('Guide') . '</legend>
		<h2>' . $this->l('Ensure that your website is accessible to all') . '</h2>
			<p>
				' . $this->l('When managing Websites, it is important to keep track of software used by visitors in order to be sure that the site displays the same way for everyone, and PrestaShop was built in order to be compatible with most recent Web browsers and computer operating systems (OS). However, because you may end up adding advanced features to your Website or even modify the core PrestaShop code, these additions may not be accessible by everyone. That is why it is a good idea to keep tabs on the percentage of users for each type of software before adding or changing something that only a limited number of users will be able to access.') . '
			</p><br />
			
		</fieldset>';
        return $this->_html;
    }
Exemplo n.º 5
0
    public function hookAdminStatsModules($params)
    {
        $totalRegistrations = $this->getTotalRegistrations();
        $totalBlocked = $this->getBlockedVisitors();
        $totalBuyers = $this->getFirstBuyers();
        $this->_html = '
		<fieldset class="width3"><legend><img src="../modules/' . $this->name . '/logo.gif" /> ' . $this->displayName . '</legend>
			<p>
				' . $this->l('Visitors who have stopped at the registering step:') . ' ' . intval($totalBlocked) . ($totalRegistrations ? ' (' . number_format(100 * $totalBlocked / ($totalRegistrations + $totalBlocked), 2) . '%)' : '') . '<br />
				' . $this->l('Visitors who have placed an order directly after the registration:') . ' ' . intval($totalBuyers) . ($totalRegistrations ? ' (' . number_format(100 * $totalBuyers / $totalRegistrations, 2) . '%)' : '') . '
			</p>
			<p>' . $this->l('Total customer accounts:') . ' ' . $totalRegistrations . '</p>
			<center>' . ModuleGraph::engine(array('type' => 'line')) . '</center>
		</fieldset><br />
		<fieldset class="width3"><legend><img src="../img/admin/comment.gif" /> ' . $this->l('Guide') . '</legend>
			<h2>' . $this->l('Number of customer accounts created') . '</h2>
			<p>' . $this->l('The total number of accounts created is not in itself important information. However, it is interesting to analyze the number created over time. This will indicate whether or not things are on the right track.') . '</p>
			<br /><h3>' . $this->l('How to act on the registrations\' evolution?') . '</h3>
			<p>
				' . $this->l('If you let your shop run without changing anything, the number of customer registrations should stay stable or slightly decline.') . '
				' . $this->l('A significant increase or decrease shows that there has probably been a change to your shop; therefore, you have to identify it in order to backtrack if this change makes the number of registrations decrease, or continue with it if it is advantageous.') . '<br />
				' . $this->l('Here\'s a summary of what can affect the creation of customer accounts:') . '
				<ul>
					<li>' . $this->l('An advertising campaign can attract a greater number of visitors. An increase in customer accounts which will ensue, which will depend on their \\"quality\\": well-targeted advertising can be more effective than large-scale advertising.') . '</li>
					<li>' . $this->l('Specials, sales, or contests create greater attention and curiosity, not only keeping your shop lively but also increasing its traffic. This way, you can push impulsive buyers to take the plunge.') . '</li>
					<li>' . $this->l('Design and user-friendliness are more important than ever: an ill-chosen or hard-to-follow graphical theme can turn off visitors. You have to strike the right balance between an innovative design and letting visitors move around easily. Proper spelling and clarity also inspire more customer confidence in your shop.') . '</li>
				</ul>
			</p><br />
		</fieldset>';
        return $this->_html;
    }
Exemplo n.º 6
0
    function hookAdminStatsModules()
    {
        $result = Db::getInstance()->ExecuteS($this->_query . ModuleGraph::getDateBetween() . $this->_query2);
        $this->_html = '
		<fieldset class="width3"><legend><img src="../modules/' . $this->name . '/logo.gif" /> ' . $this->displayName . '</legend>';
        $table = '<div style="overflow-y: scroll; height: 600px;">
		<table class="table" border="0" cellspacing="0" cellspacing="0">
		<thead>
			<tr>
				<th style="width:400px;">' . $this->l('keywords') . '</th>
				<th style="width:50px; text-align: right">' . $this->l('Occurences') . '</th>
				<th style="width:50px; text-align: right">' . $this->l('Results') . '</th>
			</tr>
		</thead><tbody>';
        foreach ($result as $row) {
            $table .= '<tr>
				<td>' . $row['keywords'] . '</td>
				<td style="text-align: right">' . $row['occurences'] . '</td>
				<td style="text-align: right">' . $row['total'] . '</td>
			</tr>';
        }
        $table .= '</tbody></table></div>';
        if (sizeof($result)) {
            $this->_html .= '<center>' . ModuleGraph::engine(array('type' => 'pie')) . '</center><br class="clear" />' . $table;
        } else {
            $this->_html .= '<p><strong>' . $this->l('No keywords searched more than once found.') . '</strong></p>';
        }
        $this->_html .= '</fieldset>';
        return $this->_html;
    }
Exemplo n.º 7
0
    public function hookAdminStatsModules($params)
    {
        $totalVisits = $this->getTotalVisits();
        $totalGuests = $this->getTotalGuests();
        if (Tools::getValue('export')) {
            $this->csvExport(array('layers' => 2, 'type' => 'line', 'option' => 3));
        }
        $this->_html = '
		<fieldset class="width3"><legend><img src="../modules/' . $this->name . '/logo.gif" /> ' . $this->displayName . '</legend>
			<p><center>
				<img src="../img/admin/down.gif" />' . $this->l('A visit corresponds to an internet user coming to your shop. Until the end of their session, only one visit is counted.') . '
				' . $this->l('A visitor is an unknown person, who has not registered or logged on, surfing on your shop. A visitor can come and visit your shop many times.') . '
			</center></p>
			<div style="margin-top:20px"></div>
			<p>' . $this->l('Total visits:') . ' ' . $totalVisits . '</p>
			<p>' . $this->l('Total visitors:') . ' ' . $totalGuests . '</p>
			' . ($totalVisits ? ModuleGraph::engine(array('layers' => 2, 'type' => 'line', 'option' => 3)) . '<p><a href="' . $_SERVER['REQUEST_URI'] . '&export=1"><img src="../img/admin/asterisk.gif" />' . $this->l('CSV Export') . '</a></p>' : '') . '
			
		</fieldset>
		<br class="clear" />
		<fieldset class="width3"><legend><img src="../img/admin/comment.gif" /> ' . $this->l('Guide') . '</legend>
				<h2>' . $this->l('Determine the interest of a visit') . '</h2>
				' . $this->l('The visitors\' evolution graph strongly resembles the visits\' graph, but provides additional information:') . '<br />
				<ul>
					<li>' . $this->l('If this is the case, congratulations, your website is well planned and pleasing.') . '</li>
					<li>' . $this->l('Otherwise, the conclusion is not so simple. The problem can be aesthetic or ergonomic, or else the offer is not sufficient. It is also possible that these visitors mistakenly came here without particular interest for your shop; this phenomenon often happens with the search engines.') . '</li>
				</ul>
				' . $this->l('This information is mostly qualitative: you have to determine the interest of a disjointed visit.') . '<br />
		</fieldset>';
        return $this->_html;
    }
    public function hookAdminStatsModules($params)
    {
        $this->_html = '<fieldset class="width3"><legend><img src="../modules/' . $this->name . '/logo.gif" /> ' . $this->displayName . '</legend>';
        if (sizeof(Customer::getCustomers())) {
            if (Tools::getValue('export')) {
                if (Tools::getValue('exportType') == 'gender') {
                    $this->csvExport(array('type' => 'pie', 'option' => 'gender'));
                } elseif (Tools::getValue('exportType') == 'age') {
                    $this->csvExport(array('type' => 'pie', 'option' => 'age'));
                } elseif (Tools::getValue('exportType') == 'country') {
                    $this->csvExport(array('type' => 'pie', 'option' => 'country'));
                } elseif (Tools::getValue('exportType') == 'currency') {
                    $this->csvExport(array('type' => 'pie', 'option' => 'currency'));
                } elseif (Tools::getValue('exportType') == 'language') {
                    $this->csvExport(array('type' => 'pie', 'option' => 'language'));
                }
            }
            $this->_html .= '
			
				<center><p><img src="../img/admin/down.gif" />' . $this->l('Gender distribution allows you to determine the percentage of men and women among your customers.') . '</p>
				' . ModuleGraph::engine(array('type' => 'pie', 'option' => 'gender')) . '<br /></center>
				<p><a href="' . $_SERVER['REQUEST_URI'] . '&export=1&exportType=gender"><img src="../img/admin/asterisk.gif" />' . $this->l('CSV Export') . '</a></p>
				<br class="clear" /><br />
				<center><p><img src="../img/admin/down.gif" />' . $this->l('Age ranges allows you to determine in which age range your customers are.') . '</p>
				' . ModuleGraph::engine(array('type' => 'pie', 'option' => 'age')) . '<br /></center>
				<p><a href="' . $_SERVER['REQUEST_URI'] . '&export=1&exportType=age"><img src="../img/admin/asterisk.gif" />' . $this->l('CSV Export') . '</a></p><br /><br />
				<center><p><img src="../img/admin/down.gif" />' . $this->l('Country distribution allows you to determine in which part of the world your customers are shopping from.') . '</p>
				' . ModuleGraph::engine(array('type' => 'pie', 'option' => 'country')) . '<br /></center>
				<p><a href="' . $_SERVER['REQUEST_URI'] . '&export=1&exportType=country"><img src="../img/admin/asterisk.gif" />' . $this->l('CSV Export') . '</a></p><br /><br />
				<center><p><img src="../img/admin/down.gif" />' . $this->l('Currency ranges allows you to determine which currencies your customers are using.') . '</p>
				' . ModuleGraph::engine(array('type' => 'pie', 'option' => 'currency')) . '<br /></center>
				<p><a href="' . $_SERVER['REQUEST_URI'] . '&export=1&exportType=currency"><img src="../img/admin/asterisk.gif" />' . $this->l('CSV Export') . '</a></p><br /><br />
				<center><p><img src="../img/admin/down.gif" />' . $this->l('Language distribution allows you to determine the general languages your customers are using on your shop.') . '</p>
				' . ModuleGraph::engine(array('type' => 'pie', 'option' => 'language')) . '<br /></center>
				<p><a href="' . $_SERVER['REQUEST_URI'] . '&export=1&exportType=language"><img src="../img/admin/asterisk.gif" />' . $this->l('CSV Export') . '</a></p>
			</center>';
        } else {
            $this->_html .= '<p>' . $this->l('No customers registered yet.') . '</p>';
        }
        $this->_html .= '
		</fieldset><br />
		<fieldset class="width3"><legend><img src="../img/admin/comment.gif" /> ' . $this->l('Guide') . '</legend>
			<h2>' . $this->l('Target your audience') . '</h2>
			<p>
				' . $this->l('In order for each message to have an impact, you need to know to whom it should be addressed.') . '
				' . $this->l('Addressing the right audience is essential for choosing the right tools to win them over.') . '
				' . $this->l('It is best to limit action to a group or groups of clients.') . '
				' . $this->l('Registered customer information allows you to accurately define the typical customer profile so that you can adapt your specials to various criteria.') . '
			</p><br />
			<p>
				' . $this->l('You should use this information to increase your sales by') . '
				<ul>
					<li class="bullet">' . $this->l('launching ad campaigns addressed to specific customers who might be interested in a particular offer at specific dates and times.') . '</li>
					<li class="bullet">' . $this->l('Contacting a group of clients by e-mail / newsletter.') . '</li>
				</ul>
			</p><br />
		</fieldset>';
        return $this->_html;
    }
    public function getTotalGuests()
    {
        $sql = 'SELECT COUNT(DISTINCT c.`id_guest`)
				FROM `' . _DB_PREFIX_ . 'connections` c
				WHERE c.`date_add` BETWEEN ' . ModuleGraph::getDateBetween() . '
					' . Shop::addSqlRestriction(false, 'c');
        return Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql);
    }
Exemplo n.º 10
0
    private function getTotals()
    {
        $result1 = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow('
		SELECT COUNT(*) as customers
		FROM `' . _DB_PREFIX_ . 'customer` c
		WHERE c.`newsletter_date_add` BETWEEN ' . ModuleGraph::getDateBetween());
        $result2 = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow('
		SELECT COUNT(*) as visitors
		FROM ' . _DB_PREFIX_ . 'newsletter n
		WHERE n.`newsletter_date_add` BETWEEN ' . ModuleGraph::getDateBetween());
        return array('customers' => $result1['customers'], 'visitors' => $result2['visitors'], 'both' => $result1['customers'] + $result2['visitors']);
    }
Exemplo n.º 11
0
    public function getFirstBuyers()
    {
        $sql = 'SELECT COUNT(DISTINCT o.`id_customer`) as buyers
				FROM `' . _DB_PREFIX_ . 'orders` o
				LEFT JOIN `' . _DB_PREFIX_ . 'guest` g ON o.id_customer = g.id_customer
				LEFT JOIN `' . _DB_PREFIX_ . 'connections` c ON c.id_guest = g.id_guest
				WHERE o.`date_add` BETWEEN ' . ModuleGraph::getDateBetween() . '
					' . Shop::addSqlRestriction(Shop::SHARE_ORDER, 'o') . '
					AND o.valid = 1
					AND ABS(TIMEDIFF(o.date_add, c.date_add)+0) < 120000';
        $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($sql);
        return $result['buyers'];
    }
Exemplo n.º 12
0
    public function getTotalViewed($id_product)
    {
        $date_between = ModuleGraph::getDateBetween();
        $sql = 'SELECT SUM(pv.`counter`) AS total
				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\'
					' . Shop::addSqlRestriction(false, 'pv') . '
					AND p.`id_object` = ' . (int) $id_product . '
					AND dr.`time_start` BETWEEN ' . $date_between . '
					AND dr.`time_end` BETWEEN ' . $date_between;
        $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($sql);
        return isset($result['total']) ? $result['total'] : 0;
    }
Exemplo n.º 13
0
    private function getTotals()
    {
        $sql = 'SELECT COUNT(*) as customers
				FROM `' . _DB_PREFIX_ . 'customer`
				WHERE 1
					' . Shop::addSqlRestriction(Shop::SHARE_CUSTOMER) . '
					AND `newsletter_date_add` BETWEEN ' . ModuleGraph::getDateBetween();
        $result1 = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($sql);
        $sql = 'SELECT COUNT(*) as visitors
				FROM ' . _DB_PREFIX_ . 'newsletter
				WHERE 1
				   ' . Shop::addSqlRestriction() . '
					AND `newsletter_date_add` BETWEEN ' . ModuleGraph::getDateBetween();
        $result2 = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($sql);
        return array('customers' => $result1['customers'], 'visitors' => $result2['visitors'], 'both' => $result1['customers'] + $result2['visitors']);
    }
Exemplo n.º 14
0
    public function hookAdminStatsModules()
    {
        $websites = $this->getOrigins(ModuleGraph::getDateBetween());
        if (Tools::getValue('export')) {
            if (Tools::getValue('exportType') == 'top') {
                $this->csvExport(array('type' => 'pie'));
            }
        }
        $this->_html = '<div class="blocStats"><h2 class="icon-' . $this->name . '"><span></span>' . $this->l('Origin') . '</h2>';
        if (count($websites)) {
            $this->_html .= '
			<p><img src="../img/admin/down.gif" />' . $this->l('Here we break down the 10 most popular referral websites that call customers to your e-store.') . '</p>
			<div>' . $this->engine(array('type' => 'pie')) . '</div><br />
			<p><a class="button export-csv" href="' . Tools::safeOutput($_SERVER['REQUEST_URI']) . '&export=1&exportType=top"><span>' . $this->l('CSV Export') . '</span></a></p><br />
			
			<table class="table " border="0" cellspacing="0" cellspacing="0">
				<tr>
					<th style="width:400px;">' . $this->l('Origin') . '</th>
					<th style="width:50px; text-align: right">' . $this->l('Total') . '</th>
				</tr>';
            foreach ($websites as $website => $total) {
                $this->_html .= '<tr>
					<td>' . (!strstr($website, ' ') ? '<a href="' . Tools::getProtocol() . $website . '">' : '') . $website . (!strstr($website, ' ') ? '</a>' : '') . '</td><td style="text-align: right">' . $total . '</td>
				</tr>';
            }
            $this->_html .= '</table></div>';
        } else {
            $this->_html .= '<p><strong>' . $this->l('Direct links only') . '</strong></p>';
        }
        $this->_html .= '</div><br />
		<div class="blocStats"><h2 class="icon-guide"><span></span>' . $this->l('Guide') . '</h2>
		<h2>' . $this->l('What is a referral website?') . '</h2>
			<p>
				' . $this->l('When visiting a webpage, the referrer is the URL of the previous webpage from which a link was followed.') . '<br />
				' . $this->l('A referrer enables you to know which keywords visitors use in search engines when browsing for your online store.') . '<br /><br />
				' . $this->l('A referrer can be:') . '
				<ul>
					<li class="bullet">' . $this->l('Someone who posts a link to your shop.') . '</li>
					<li class="bullet">' . $this->l('A partner who has agreed to a link exchange in order to attract new customers.') . '</li>
				</ul>
			</p>
		</div>';
        return $this->_html;
    }
Exemplo n.º 15
0
    function hookAdminStatsModules()
    {
        $websites = $this->getOrigins(ModuleGraph::getDateBetween());
        if (Tools::getValue('export')) {
            if (Tools::getValue('exportType') == 'top') {
                $this->csvExport(array('type' => 'pie'));
            }
        }
        $this->_html = '<fieldset class="width3"><legend><img src="../modules/' . $this->name . '/logo.gif" /> ' . $this->l('Origin') . '</legend>';
        if (sizeof($websites)) {
            $this->_html .= '
			<center><p><img src="../img/admin/down.gif" />' . $this->l('Here is the percentage of the 10 most popular referrer websites by which visitors went through to get to your shop.') . '</p>
			' . ModuleGraph::engine(array('type' => 'pie')) . '</center>
			<p><a href="' . Tools::safeOutput($_SERVER['REQUEST_URI']) . '&export=1&exportType=top"><img src="../img/admin/asterisk.gif" />' . $this->l('CSV Export') . '</a></p><br /><br />
			<div style="overflow-y: scroll; height: 600px;">
			<center>
			<table class="table " border="0" cellspacing="0" cellspacing="0">
				<tr>
					<th style="width:400px;">' . $this->l('Origin') . '</th>
					<th style="width:50px; text-align: right">' . $this->l('Total') . '</th>
				</tr>';
            foreach ($websites as $website => $total) {
                $this->_html .= '<tr><td>' . (!strstr($website, ' ') ? '<a href="' . Tools::getProtocol() . $website . '">' : '') . $website . (!strstr($website, ' ') ? '</a>' : '') . '</td><td style="text-align: right">' . $total . '</td></tr>';
            }
            $this->_html .= '</table></center></div>';
        } else {
            $this->_html .= '<p><strong>' . $this->l('Direct links only') . '</strong></p>';
        }
        $this->_html .= '</fieldset><br />
		<fieldset class="width3"><legend><img src="../img/admin/comment.gif" /> ' . $this->l('Guide') . '</legend>
		<h2>' . $this->l('What is a referrer website?') . '</h2>
			<p>
				' . $this->l('When visiting a webpage, the referrer is the URL of the previous webpage from which a link was followed.') . '<br />
				' . $this->l('A referrer enables you to know which keywords are entered by visitors in search engines when getting to your shop and allows you to optimize web promotion.') . '<br /><br />
				' . $this->l('A referrer can be:') . '
				<ul>
					<li class="bullet">' . $this->l('Someone who put a link on their website for your shop') . '</li>
					<li class="bullet">' . $this->l('A partner with whom you made a link exchange in order to bring in sales or attract new customers') . '</li>
				</ul>
			</p>
		</fieldset>';
        return $this->_html;
    }
Exemplo n.º 16
0
    protected function getData($layers)
    {
        $stateQuery = '';
        if (intval($this->_option)) {
            $stateQuery = 'AND (SELECT oh.id_order_state FROM `' . _DB_PREFIX_ . 'order_history` oh WHERE o.id_order = oh.id_order ORDER BY oh.date_add DESC, oh.id_order_history DESC LIMIT 1) = ' . intval($this->_option);
        }
        $this->_titles['main'] = $this->l('Percentage of orders by carrier');
        $result = Db::getInstance()->ExecuteS('
		SELECT c.name, COUNT(DISTINCT o.`id_order`) as total
		FROM `' . _DB_PREFIX_ . 'carrier` c
		LEFT JOIN `' . _DB_PREFIX_ . 'orders` o ON o.id_carrier = c.id_carrier
		WHERE o.`date_add` BETWEEN ' . ModuleGraph::getDateBetween() . '
		' . $stateQuery . '
		GROUP BY c.`id_carrier`');
        foreach ($result as $row) {
            $this->_values[] = $row['total'];
            $this->_legend[] = $row['name'];
        }
    }
Exemplo n.º 17
0
    public function hookAdminStatsModules()
    {
        if (Tools::getValue('export')) {
            $this->csvExport(array('type' => 'pie'));
        }
        $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($this->query . ModuleGraph::getDateBetween() . $this->query_group_by);
        $this->html = '
		<div class="panel-heading">
			' . $this->displayName . '
		</div>';
        $table = '
		<table class="table">
			<thead>
				<tr>
					<th><span class="title_box active">' . $this->l('Keywords') . '</span></th>
					<th><span class="title_box active">' . $this->l('Occurrences') . '</span></th>
					<th><span class="title_box active">' . $this->l('Results') . '</span></th>
				</tr>
			</thead>
			<tbody>';
        foreach ($result as $row) {
            if (Tools::strlen($row['keywords']) >= Configuration::get('PS_SEARCH_MINWORDLEN')) {
                $table .= '<tr>
					<td>' . $row['keywords'] . '</td>
					<td>' . $row['occurences'] . '</td>
					<td>' . $row['total'] . '</td>
				</tr>';
            }
        }
        $table .= '
			</tbody>
		</table>';
        if (count($result)) {
            $this->html .= '<div>' . $this->engine(array('type' => 'pie')) . '</div>
							<a class="btn btn-default" href="' . Tools::safeOutput($_SERVER['REQUEST_URI']) . '&export=1">
								<i class="icon-cloud-upload"></i> ' . $this->l('CSV Export') . '
							</a>' . $table;
        } else {
            $this->html .= '<p>' . $this->l('Cannot find any keywords that have been searched for more than once.') . '</p>';
        }
        return $this->html;
    }
Exemplo n.º 18
0
    private function getPages()
    {
        $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS('
		SELECT http_referer, request_uri, COUNT(*) as nb
		FROM `' . _DB_PREFIX_ . 'pagenotfound` p
		WHERE p.date_add BETWEEN ' . ModuleGraph::getDateBetween() . '
		GROUP BY http_referer, request_uri');
        $pages = array();
        foreach ($result as $row) {
            $row['http_referer'] = parse_url($row['http_referer'], PHP_URL_HOST) . parse_url($row['http_referer'], PHP_URL_PATH);
            if (!isset($row['http_referer']) or empty($row['http_referer'])) {
                $row['http_referer'] = '--';
            }
            if (!isset($pages[$row['request_uri']])) {
                $pages[$row['request_uri']] = array('nb' => 0);
            }
            $pages[$row['request_uri']][$row['http_referer']] = $row['nb'];
            $pages[$row['request_uri']]['nb'] += $row['nb'];
        }
        uasort($pages, 'pnfSort');
        return $pages;
    }
Exemplo n.º 19
0
    public function hookAdminStatsModules()
    {
        $websites = $this->getOrigins(ModuleGraph::getDateBetween());
        if (Tools::getValue('export')) {
            if (Tools::getValue('exportType') == 'top') {
                $this->csvExport(array('type' => 'pie'));
            }
        }
        $this->_html = '<div class="panel-heading">' . $this->l('Origin') . '</div>';
        if (count($websites)) {
            $this->_html .= '
			<div class="alert alert-info">
				' . $this->l('In the tab, we break down the 10 most popular referral websites that bring customers to your online store.') . '
			</div>
			<h4>' . $this->l('Guide') . '</h4>
			<div class="alert alert-warning">
				<h4>' . $this->l('What is a referral website?') . '</h4>
				<p>
					' . $this->l('The referrer is the URL of the previous webpage from which a link was followed by the visitor.') . '<br />
					' . $this->l('A referrer also enables you to know which keywords visitors use in search engines when browsing for your online store.') . '<br /><br />
					' . $this->l('A referrer can be:') . '
				</p>
				<ul>
					<li>' . $this->l('Someone who posts a link to your shop.') . '</li>
					<li>' . $this->l('A partner who has agreed to a link exchange in order to attract new customers.') . '</li>
				</ul>
			</div>
			<div class="row row-margin-bottom">
				<div class="col-lg-12">
					<div class="col-lg-8">
						' . $this->engine(array('type' => 'pie')) . '
					</div>
					<div class="col-lg-4">
						<a href="' . Tools::safeOutput($_SERVER['REQUEST_URI'] . '&export=1&exportType=top') . '" class="btn btn-default">
							<i class="icon-cloud-upload"></i> ' . $this->l('CSV Export') . '
						</a>
					</div>
				</div>
			</div>
			<table class="table">
				<thead>
					<tr>
						<th><span class="title_box active">' . $this->l('Origin') . '</span></th>
						<th><span class="title_box active">' . $this->l('Total') . '</span></th>
					</tr>
				</thead>
				<tbody>';
            foreach ($websites as $website => $total) {
                $this->_html .= '
					<tr>
						<td>' . (!strstr($website, ' ') ? '<a href="' . Tools::getProtocol() . $website . '">' : '') . $website . (!strstr($website, ' ') ? '</a>' : '') . '</td><td>' . $total . '</td>
					</tr>';
            }
            $this->_html .= '
				</tbody>
			</table>';
        } else {
            $this->_html .= '<p>' . $this->l('Direct links only') . '</p>';
        }
        return $this->_html;
    }
Exemplo n.º 20
0
    private function getStatesData()
    {
        $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
		SELECT osl.`name`, COUNT(oh.`id_order`) as total
		FROM `' . _DB_PREFIX_ . 'order_state` os
		LEFT JOIN `' . _DB_PREFIX_ . 'order_state_lang` osl ON (os.`id_order_state` = osl.`id_order_state` AND osl.`id_lang` = ' . (int) $this->getLang() . ')
		LEFT JOIN `' . _DB_PREFIX_ . 'order_history` oh ON os.`id_order_state` = oh.`id_order_state`
		LEFT JOIN `' . _DB_PREFIX_ . 'orders` o ON o.`id_order` = oh.`id_order`
		' . ((int) $this->id_country ? 'LEFT JOIN `' . _DB_PREFIX_ . 'address` a ON o.id_address_delivery = a.id_address' : '') . '
		WHERE oh.`id_order_history` = (
			SELECT ios.`id_order_history`
			FROM `' . _DB_PREFIX_ . 'order_history` ios
			WHERE ios.`id_order` = oh.`id_order`
			ORDER BY ios.`date_add` DESC, oh.`id_order_history` DESC
			LIMIT 1
		)
		' . ((int) $this->id_country ? 'AND a.id_country = ' . (int) $this->id_country : '') . '
		AND o.`date_add` BETWEEN ' . ModuleGraph::getDateBetween() . '
		GROUP BY oh.`id_order_state`');
        foreach ($result as $row) {
            $this->_values[] = $row['total'];
            $this->_legend[] = $row['name'];
        }
    }
Exemplo n.º 21
0
 public function postProcess()
 {
     global $currentIndex;
     if ($this->enableCalendar()) {
         $calendarTab = new AdminStats();
         $calendarTab->postProcess();
     }
     if (Tools::isSubmit('submitSettings')) {
         if ($this->tabAccess['edit'] === '1') {
             if (Configuration::updateValue('TRACKING_DIRECT_TRAFFIC', (int) Tools::getValue('tracking_dt'))) {
                 Tools::redirectAdmin($currentIndex . '&conf=4&token=' . Tools::getValue('token'));
             }
         }
     }
     if (ModuleGraph::getDateBetween() != Configuration::get('PS_REFERRERS_CACHE_LIKE') or Tools::isSubmit('submitRefreshCache')) {
         Referrer::refreshCache();
     }
     if (Tools::isSubmit('submitRefreshIndex')) {
         Referrer::refreshIndex();
     }
     return parent::postProcess();
 }
Exemplo n.º 22
0
 public static function getDateBetween($employee = null)
 {
     if ($employee = ModuleGraph::getEmployee($employee)) {
         return ' \'' . $employee->stats_date_from . ' 00:00:00\' AND \'' . $employee->stats_date_to . ' 23:59:59\' ';
     }
     return ' \'' . date('Y-m') . '-01 00:00:00\' AND \'' . date('Y-m-t') . ' 23:59:59\' ';
 }
Exemplo n.º 23
0
    private function getRealCA()
    {
        global $cookie;
        $employee = new Employee($cookie->id_employee);
        if ((int) $cookie->stats_id_zone) {
            $join = ' LEFT JOIN `' . _DB_PREFIX_ . 'address` a ON o.id_address_invoice = a.id_address LEFT JOIN `' . _DB_PREFIX_ . 'country` co ON co.id_country = a.id_country';
            $where = ' AND co.id_zone = ' . (int) $cookie->stats_id_zone . ' ';
        }
        $ca = array();
        $ca['cat'] = Db::getInstance()->ExecuteS('
		SELECT SUM(od.`product_price` * od.`product_quantity` / o.conversion_rate) as orderSum, COUNT(*) AS orderQty, cl.name, AVG(od.`product_price` / o.conversion_rate) as priveAvg
		FROM `' . _DB_PREFIX_ . 'orders` o
		LEFT JOIN `' . _DB_PREFIX_ . 'order_detail` od ON o.id_order = od.id_order
		LEFT JOIN `' . _DB_PREFIX_ . 'product` p ON p.id_product = od.product_id
		LEFT JOIN `' . _DB_PREFIX_ . 'category_lang` cl ON (p.id_category_default = cl.id_category AND cl.id_lang = ' . (int) $cookie->id_lang . ')
		' . ((int) $cookie->stats_id_zone ? $join : '') . '
		WHERE o.valid = 1
		AND o.`invoice_date` BETWEEN ' . ModuleGraph::getDateBetween() . '
		' . ((int) $cookie->stats_id_zone ? $where : '') . '
		GROUP BY p.id_category_default');
        uasort($ca['cat'], 'statsforecast_sort');
        $langValues = '';
        $languages = Db::getInstance()->ExecuteS('SELECT id_lang, iso_code FROM `' . _DB_PREFIX_ . 'lang` WHERE active = 1');
        foreach ($languages as $language) {
            $langValues .= 'SUM(IF(o.id_lang = ' . (int) $language['id_lang'] . ', total_products / o.conversion_rate, 0)) as ' . pSQL($language['iso_code']) . ',';
        }
        $langValues = rtrim($langValues, ',');
        $ca['lang'] = Db::getInstance()->getRow('
		SELECT ' . $langValues . '
		FROM `' . _DB_PREFIX_ . 'orders` o
		WHERE o.valid = 1
		AND o.`invoice_date` BETWEEN ' . ModuleGraph::getDateBetween());
        arsort($ca['lang']);
        $ca['langprev'] = Db::getInstance()->getRow('
		SELECT ' . $langValues . '
		FROM `' . _DB_PREFIX_ . 'orders` o
		WHERE o.valid = 1
		AND ADDDATE(o.`invoice_date`, interval 30 day) BETWEEN \'' . $employee->stats_date_from . ' 00:00:00\' AND \'' . min(date('Y-m-d H:i:s'), $employee->stats_date_to . ' 23:59:59') . '\'');
        $ca['payment'] = Db::getInstance()->ExecuteS('
		SELECT module, SUM(total_products / o.conversion_rate) as total, COUNT(*) as nb, AVG(total_products / o.conversion_rate) as cart
		FROM `' . _DB_PREFIX_ . 'orders` o
		' . ((int) $cookie->stats_id_zone ? $join : '') . '
		WHERE o.valid = 1
		AND o.`invoice_date` BETWEEN ' . ModuleGraph::getDateBetween() . '
		' . ((int) $cookie->stats_id_zone ? $where : '') . '
		GROUP BY o.module
		ORDER BY total DESC');
        $ca['zones'] = Db::getInstance()->ExecuteS('
		SELECT z.name, SUM(o.total_products / o.conversion_rate) as total, COUNT(*) as nb
		FROM `' . _DB_PREFIX_ . 'orders` o
		LEFT JOIN `' . _DB_PREFIX_ . 'address` a ON o.id_address_invoice = a.id_address
		LEFT JOIN `' . _DB_PREFIX_ . 'country` c ON c.id_country = a.id_country
		LEFT JOIN `' . _DB_PREFIX_ . 'zone` z ON z.id_zone = c.id_zone
		WHERE o.valid = 1
		AND o.`invoice_date` BETWEEN ' . ModuleGraph::getDateBetween() . '
		GROUP BY c.id_zone
		ORDER BY total DESC');
        $ca['currencies'] = Db::getInstance()->ExecuteS('
		SELECT cu.name, SUM(o.total_products / o.conversion_rate) as total, COUNT(*) as nb
		FROM `' . _DB_PREFIX_ . 'orders` o
		LEFT JOIN `' . _DB_PREFIX_ . 'currency` cu ON o.id_currency = cu.id_currency
		' . ((int) $cookie->stats_id_zone ? $join : '') . '
		WHERE o.valid = 1
		AND o.`invoice_date` BETWEEN ' . ModuleGraph::getDateBetween() . '
		' . ((int) $cookie->stats_id_zone ? $where : '') . '
		GROUP BY o.id_currency
		ORDER BY total DESC');
        $ca['ventil'] = Db::getInstance()->getRow('
		SELECT SUM(total_products / o.conversion_rate) as total, COUNT(*) AS nb
		FROM `' . _DB_PREFIX_ . 'orders` o
		WHERE o.valid = 1
		AND o.`invoice_date` BETWEEN ' . ModuleGraph::getDateBetween());
        $ca['attributes'] = Db::getInstance()->ExecuteS('
		SELECT /*pac.id_attribute,*/ agl.name as gname, al.name as aname, COUNT(*) as total
		FROM ' . _DB_PREFIX_ . 'orders o
		LEFT JOIN ' . _DB_PREFIX_ . 'order_detail od ON o.id_order = od.id_order
		INNER JOIN ' . _DB_PREFIX_ . 'product_attribute_combination pac ON od.product_attribute_id = pac.id_product_attribute
		INNER JOIN ' . _DB_PREFIX_ . 'attribute a ON pac.id_attribute = a.id_attribute
		INNER JOIN ' . _DB_PREFIX_ . 'attribute_group_lang agl ON (a.id_attribute_group = agl.id_attribute_group AND agl.id_lang = ' . (int) $cookie->id_lang . ')
		INNER JOIN ' . _DB_PREFIX_ . 'attribute_lang al ON (a.id_attribute = al.id_attribute AND al.id_lang = ' . (int) $cookie->id_lang . ')
		WHERE o.valid = 1
		AND o.`invoice_date` BETWEEN ' . ModuleGraph::getDateBetween() . '
		GROUP BY pac.id_attribute');
        return $ca;
    }
Exemplo n.º 24
0
    public function hookAdminStatsModules()
    {
        if (Tools::isSubmit('submitCheckup')) {
            $confs = array('CHECKUP_DESCRIPTIONS_LT', 'CHECKUP_DESCRIPTIONS_GT', 'CHECKUP_IMAGES_LT', 'CHECKUP_IMAGES_GT', 'CHECKUP_SALES_LT', 'CHECKUP_SALES_GT', 'CHECKUP_STOCK_LT', 'CHECKUP_STOCK_GT');
            foreach ($confs as $confname) {
                Configuration::updateValue($confname, (int) Tools::getValue($confname));
            }
            echo '<div class="conf confirm"> ' . $this->l('Configuration updated') . '</div>';
        }
        if (Tools::isSubmit('submitCheckupOrder')) {
            $this->context->cookie->checkup_order = (int) Tools::getValue('submitCheckupOrder');
            echo '<div class="conf confirm"> ' . $this->l('Configuration updated') . '</div>';
        }
        if (!isset($this->context->cookie->checkup_order)) {
            $this->context->cookie->checkup_order = 1;
        }
        $db = Db::getInstance(_PS_USE_SQL_SLAVE_);
        $employee = Context::getContext()->employee;
        $prop30 = (strtotime($employee->stats_date_to . ' 23:59:59') - strtotime($employee->stats_date_from . ' 00:00:00')) / 60 / 60 / 24 / 30;
        // Get languages
        $sql = 'SELECT l.*
				FROM ' . _DB_PREFIX_ . 'lang l' . Shop::addSqlAssociation('lang', 'l');
        $languages = $db->executeS($sql);
        $array_colors = array(0 => '<img src="../modules/' . $this->name . '/img/red.png" alt="' . $this->l('Bad') . '" />', 1 => '<img src="../modules/' . $this->name . '/img/orange.png" alt="' . $this->l('Average') . '" />', 2 => '<img src="../modules/' . $this->name . '/img/green.png" alt="' . $this->l('Good') . '" />');
        $token_products = Tools::getAdminToken('AdminProducts' . (int) Tab::getIdFromClassName('AdminProducts') . (int) Context::getContext()->employee->id);
        $divisor = 4;
        $totals = array('products' => 0, 'active' => 0, 'images' => 0, 'sales' => 0, 'stock' => 0);
        foreach ($languages as $language) {
            $divisor++;
            $totals['description_' . $language['iso_code']] = 0;
        }
        $order_by = 'p.id_product';
        if ($this->context->cookie->checkup_order == 2) {
            $order_by = 'pl.name';
        } else {
            if ($this->context->cookie->checkup_order == 3) {
                $order_by = 'nbSales DESC';
            }
        }
        // Get products stats
        $sql = 'SELECT p.id_product, product_shop.active, pl.name, (
					SELECT COUNT(*)
					FROM ' . _DB_PREFIX_ . 'image i
					' . Shop::addSqlAssociation('image', 'i') . '
					WHERE i.id_product = p.id_product
				) as nbImages, (
					SELECT SUM(od.product_quantity)
					FROM ' . _DB_PREFIX_ . 'orders o
					LEFT JOIN ' . _DB_PREFIX_ . 'order_detail od ON o.id_order = od.id_order
					WHERE od.product_id = p.id_product
						AND o.invoice_date BETWEEN ' . ModuleGraph::getDateBetween() . '
						' . Shop::addSqlRestriction(Shop::SHARE_ORDER, 'o') . '
				) as nbSales,
				IFNULL(stock.quantity, 0) as stock
				FROM ' . _DB_PREFIX_ . 'product p
				' . Shop::addSqlAssociation('product', 'p') . '
				' . Product::sqlStock('p', 0) . '
				LEFT JOIN ' . _DB_PREFIX_ . 'product_lang pl
					ON (p.id_product = pl.id_product AND pl.id_lang = ' . (int) $this->context->language->id . Shop::addSqlRestrictionOnLang('pl') . ')
				ORDER BY ' . $order_by;
        $result = $db->executeS($sql);
        if (!$result) {
            return $this->l('No product was found.');
        }
        $array_conf = array('DESCRIPTIONS' => array('name' => $this->l('Descriptions'), 'text' => $this->l('chars (without HTML)')), 'IMAGES' => array('name' => $this->l('Images'), 'text' => $this->l('images')), 'SALES' => array('name' => $this->l('Sales'), 'text' => $this->l('orders / month')), 'STOCK' => array('name' => $this->l('Available quantity for sale'), 'text' => $this->l('items')));
        $this->html = '
		<div class="panel-heading">' . $this->displayName . '
		</div>
		<form action="' . Tools::safeOutput(AdminController::$currentIndex . '&token=' . Tools::getValue('token') . '&module=' . $this->name) . '" method="post" class="checkup form-horizontal">
			<table class="table checkup">
				<thead>
					<tr>
						<th></th>
						<th><span class="title_box active">' . $array_colors[0] . ' ' . $this->l('Not enough') . '</span></th>
						<th><span class="title_box active">' . $array_colors[2] . ' ' . $this->l('Alright') . '</span></th>
					</tr>
				</thead>';
        foreach ($array_conf as $conf => $translations) {
            $this->html .= '
				<tbody>
					<tr>
						<td>
							<label class="control-label col-lg-12">' . $translations['name'] . '</label>
						</td>
						<td>
							<div class="row">
								<div class="col-lg-11 input-group">
									<span class="input-group-addon">' . $this->l('Less than') . '</span>
									<input type="text" name="CHECKUP_' . $conf . '_LT" value="' . Tools::safeOutput(Tools::getValue('CHECKUP_' . $conf . '_LT', Configuration::get('CHECKUP_' . $conf . '_LT'))) . '" />
									<span class="input-group-addon">' . $translations['text'] . '</span>
								 </div>
							 </div>
						</td>
						<td>
							<div class="row">
								<div class="col-lg-12 input-group">
									<span class="input-group-addon">' . $this->l('Greater than') . '</span>
									<input type="text" name="CHECKUP_' . $conf . '_GT" value="' . Tools::safeOutput(Tools::getValue('CHECKUP_' . $conf . '_GT', Configuration::get('CHECKUP_' . $conf . '_GT'))) . '" />
									<span class="input-group-addon">' . $translations['text'] . '</span>
								 </div>
							 </div>
						</td>
					</tr>
				</tbody>';
        }
        $this->html .= '</table>
			<button type="submit" name="submitCheckup" class="btn btn-default pull-right">
				<i class="icon-save"></i> ' . $this->l('Save') . '
			</button> 
		</form>
		<form action="' . Tools::safeOutput(AdminController::$currentIndex . '&token=' . Tools::getValue('token') . '&module=' . $this->name) . '" method="post" class="form-horizontal alert">
			<div class="row">
				<div class="col-lg-12">
					<label class="control-label pull-left">' . $this->l('Order by') . '</label>
					<div class="col-lg-3">
						<select name="submitCheckupOrder" onchange="this.form.submit();">
							<option value="1">' . $this->l('ID') . '</option>
							<option value="2" ' . ($this->context->cookie->checkup_order == 2 ? 'selected="selected"' : '') . '>' . $this->l('Name') . '</option>
							<option value="3" ' . ($this->context->cookie->checkup_order == 3 ? 'selected="selected"' : '') . '>' . $this->l('Sales') . '</option>
						</select>
					</div>
				</div>
			</div>
		</form>
		<div style="overflow-x:auto">
		<table class="table checkup2">
			<thead>
				<tr>
					<th><span class="title_box active">' . $this->l('ID') . '</span></th>
					<th><span class="title_box active">' . $this->l('Item') . '</span></th>
					<th class="center"><span class="title_box active">' . $this->l('Active') . '</span></th>';
        foreach ($languages as $language) {
            $this->html .= '<th><span class="title_box active">' . $this->l('Desc.') . ' (' . Tools::strtoupper($language['iso_code']) . ')</span></th>';
        }
        $this->html .= '
					<th class="center"><span class="title_box active">' . $this->l('Images') . '</span></th>
					<th class="center"><span class="title_box active">' . $this->l('Sales') . '</span></th>
					<th class="center"><span class="title_box active">' . $this->l('Available quantity for sale') . '</span></th>
					<th class="center"><span class="title_box active">' . $this->l('Global') . '</span></th>
				</tr>
			</thead>
			<tbody>';
        foreach ($result as $row) {
            $totals['products']++;
            $scores = array('active' => $row['active'] ? 2 : 0, 'images' => $row['nbImages'] < Configuration::get('CHECKUP_IMAGES_LT') ? 0 : ($row['nbImages'] > Configuration::get('CHECKUP_IMAGES_GT') ? 2 : 1), 'sales' => $row['nbSales'] * $prop30 < Configuration::get('CHECKUP_SALES_LT') ? 0 : ($row['nbSales'] * $prop30 > Configuration::get('CHECKUP_SALES_GT') ? 2 : 1), 'stock' => $row['stock'] < Configuration::get('CHECKUP_STOCK_LT') ? 0 : ($row['stock'] > Configuration::get('CHECKUP_STOCK_GT') ? 2 : 1));
            $totals['active'] += (int) $scores['active'];
            $totals['images'] += (int) $scores['images'];
            $totals['sales'] += (int) $scores['sales'];
            $totals['stock'] += (int) $scores['stock'];
            $descriptions = $db->executeS('
				SELECT l.iso_code, pl.description
				FROM ' . _DB_PREFIX_ . 'product_lang pl
				LEFT JOIN ' . _DB_PREFIX_ . 'lang l
					ON pl.id_lang = l.id_lang
				WHERE id_product = ' . (int) $row['id_product'] . Shop::addSqlRestrictionOnLang('pl'));
            foreach ($descriptions as $description) {
                if (isset($description['iso_code']) && isset($description['description'])) {
                    $row['desclength_' . $description['iso_code']] = Tools::strlen(strip_tags($description['description']));
                }
                if (isset($description['iso_code'])) {
                    $scores['description_' . $description['iso_code']] = $row['desclength_' . $description['iso_code']] < Configuration::get('CHECKUP_DESCRIPTIONS_LT') ? 0 : ($row['desclength_' . $description['iso_code']] > Configuration::get('CHECKUP_DESCRIPTIONS_GT') ? 2 : 1);
                    $totals['description_' . $description['iso_code']] += $scores['description_' . $description['iso_code']];
                }
            }
            $scores['average'] = array_sum($scores) / $divisor;
            $scores['average'] = $scores['average'] < 1 ? 0 : ($scores['average'] > 1.5 ? 2 : 1);
            $this->html .= '
				<tr>
					<td>' . $row['id_product'] . '</td>
					<td><a href="' . Tools::safeOutput('index.php?tab=AdminProducts&updateproduct&id_product=' . $row['id_product'] . '&token=' . $token_products) . '">' . Tools::substr($row['name'], 0, 42) . '</a></td>
					<td class="center">' . $array_colors[$scores['active']] . '</td>';
            foreach ($languages as $language) {
                if (isset($row['desclength_' . $language['iso_code']])) {
                    $this->html .= '<td class="center">' . (int) $row['desclength_' . $language['iso_code']] . ' ' . $array_colors[$scores['description_' . $language['iso_code']]] . '</td>';
                } else {
                    $this->html .= '<td>0 ' . $array_colors[0] . '</td>';
                }
            }
            $this->html .= '
					<td class="center">' . (int) $row['nbImages'] . ' ' . $array_colors[$scores['images']] . '</td>
					<td class="center">' . (int) $row['nbSales'] . ' ' . $array_colors[$scores['sales']] . '</td>
					<td class="center">' . (int) $row['stock'] . ' ' . $array_colors[$scores['stock']] . '</td>
					<td class="center">' . $array_colors[$scores['average']] . '</td>
				</tr>';
        }
        $this->html .= '</tbody>';
        $totals['active'] = $totals['active'] / $totals['products'];
        $totals['active'] = $totals['active'] < 1 ? 0 : ($totals['active'] > 1.5 ? 2 : 1);
        $totals['images'] = $totals['images'] / $totals['products'];
        $totals['images'] = $totals['images'] < 1 ? 0 : ($totals['images'] > 1.5 ? 2 : 1);
        $totals['sales'] = $totals['sales'] / $totals['products'];
        $totals['sales'] = $totals['sales'] < 1 ? 0 : ($totals['sales'] > 1.5 ? 2 : 1);
        $totals['stock'] = $totals['stock'] / $totals['products'];
        $totals['stock'] = $totals['stock'] < 1 ? 0 : ($totals['stock'] > 1.5 ? 2 : 1);
        foreach ($languages as $language) {
            $totals['description_' . $language['iso_code']] = $totals['description_' . $language['iso_code']] / $totals['products'];
            $totals['description_' . $language['iso_code']] = $totals['description_' . $language['iso_code']] < 1 ? 0 : ($totals['description_' . $language['iso_code']] > 1.5 ? 2 : 1);
        }
        $totals['average'] = array_sum($totals) / $divisor;
        $totals['average'] = $totals['average'] < 1 ? 0 : ($totals['average'] > 1.5 ? 2 : 1);
        $this->html .= '
			<tfoot>
				<tr>
					<th colspan="2"></th>
					<th class="center"><span class="title_box active">' . $this->l('Active') . '</span></th>';
        foreach ($languages as $language) {
            $this->html .= '<th class="center"><span class="title_box active">' . $this->l('Desc.') . ' (' . Tools::strtoupper($language['iso_code']) . ')</span></th>';
        }
        $this->html .= '
					<th class="center"><span class="title_box active">' . $this->l('Images') . '</span></th>
					<th class="center"><span class="title_box active">' . $this->l('Sales') . '</span></th>
					<th class="center"><span class="title_box active">' . $this->l('Available quantity for sale') . '</span></th>
					<th class="center"><span class="title_box active">' . $this->l('Global') . '</span></th>
				</tr>
				<tr>
					<td colspan="2"></td>
					<td class="center">' . $array_colors[$totals['active']] . '</td>';
        foreach ($languages as $language) {
            $this->html .= '<td class="center">' . $array_colors[$totals['description_' . $language['iso_code']]] . '</td>';
        }
        $this->html .= '
					<td class="center">' . $array_colors[$totals['images']] . '</td>
					<td class="center">' . $array_colors[$totals['sales']] . '</td>
					<td class="center">' . $array_colors[$totals['stock']] . '</td>
					<td class="center">' . $array_colors[$totals['average']] . '</td>
				</tr>
			</tfoot>
		</table></div>';
        return $this->html;
    }
Exemplo n.º 25
0
    public function hookAdminStatsModules($params)
    {
        global $cookie, $currentIndex;
        $id_category = (int) Tools::getValue('id_category');
        $currency = new Currency(Configuration::get('PS_CURRENCY_DEFAULT'));
        if (Tools::getValue('export')) {
            if (!Tools::getValue('exportType')) {
                $this->csvExport(array('layers' => 2, 'type' => 'line', 'option' => '42'));
            }
        }
        $this->_html = '<fieldset class="width3"><legend><img src="../modules/' . $this->name . '/logo.gif" /> ' . $this->displayName . '</legend>';
        if ($id_product = (int) Tools::getValue('id_product')) {
            if (Tools::getValue('export')) {
                if (Tools::getValue('exportType') == 1) {
                    $this->csvExport(array('layers' => 2, 'type' => 'line', 'option' => '1-' . $id_product));
                } elseif (Tools::getValue('exportType') == 2) {
                    $this->csvExport(array('type' => 'pie', 'option' => '3-' . $id_product));
                }
            }
            $product = new Product($id_product, false, (int) $cookie->id_lang);
            $totalBought = $this->getTotalBought($product->id);
            $totalSales = $this->getTotalSales($product->id);
            $totalViewed = $this->getTotalViewed($product->id);
            $this->_html .= '<h3>' . $product->name . ' - ' . $this->l('Details') . '</h3>
			<p>' . $this->l('Total bought:') . ' ' . $totalBought . '</p>
			<p>' . $this->l('Sales (-Tx):') . ' ' . Tools::displayprice($totalSales, $currency) . '</p>
			<p>' . $this->l('Total viewed:') . ' ' . $totalViewed . '</p>
			<p>' . $this->l('Conversion rate:') . ' ' . number_format($totalViewed ? $totalBought / $totalViewed : 0, 2) . '</p>
			<center>' . ModuleGraph::engine(array('layers' => 2, 'type' => 'line', 'option' => '1-' . $id_product)) . '</center>
			<br />
			<p><a href="' . $_SERVER['REQUEST_URI'] . '&export=1&exportType=1"><img src="../img/admin/asterisk.gif" />' . $this->l('CSV Export') . '</a></p>';
            if ($hasAttribute = $product->hasAttributes() and $totalBought) {
                $this->_html .= '<h3 class="space">' . $this->l('Attribute sales distribution') . '</h3><center>' . ModuleGraph::engine(array('type' => 'pie', 'option' => '3-' . $id_product)) . '</center><br />
			<p><a href="' . $_SERVER['REQUEST_URI'] . '&export=1&exportType=2"><img src="../img/admin/asterisk.gif" />' . $this->l('CSV Export') . '</a></p><br />';
            }
            if ($totalBought) {
                $sales = $this->getSales($id_product, $cookie->id_lang);
                $this->_html .= '<br class="clear" />
				<h3>' . $this->l('Sales') . '</h3>
				<div style="overflow-y: scroll; height: ' . min(400, (count($sales) + 1) * 32) . 'px;">
				<table class="table" border="0" cellspacing="0" cellspacing="0">
				<thead>
					<tr>
						<th>' . $this->l('Date') . '</th>
						<th>' . $this->l('Order') . '</th>
						<th>' . $this->l('Customer') . '</th>
						' . ($hasAttribute ? '<th>' . $this->l('Attribute') . '</th>' : '') . '
						<th>' . $this->l('Qty') . '</th>
						<th>' . $this->l('Price') . '</th>
					</tr>
				</thead><tbody>';
                $tokenOrder = Tools::getAdminToken('AdminOrders' . (int) Tab::getIdFromClassName('AdminOrders') . (int) $cookie->id_employee);
                $tokenCustomer = Tools::getAdminToken('AdminCustomers' . (int) Tab::getIdFromClassName('AdminCustomers') . (int) $cookie->id_employee);
                foreach ($sales as $sale) {
                    $this->_html .= '
					<tr>
						<td>' . Tools::displayDate($sale['date_add'], (int) $cookie->id_lang, false) . '</td>
						<td align="center"><a href="?tab=AdminOrders&id_order=' . $sale['id_order'] . '&vieworder&token=' . $tokenOrder . '">' . (int) $sale['id_order'] . '</a></td>
						<td align="center"><a href="?tab=AdminCustomers&id_customer=' . $sale['id_customer'] . '&viewcustomer&token=' . $tokenCustomer . '">' . (int) $sale['id_customer'] . '</a></td>
						' . ($hasAttribute ? '<td>' . $sale['product_name'] . '</td>' : '') . '
						<td>' . (int) $sale['product_quantity'] . '</td>
						<td>' . Tools::displayprice($sale['total'], $currency) . '</td>
					</tr>';
                }
                $this->_html .= '</tbody></table></div>';
                $crossSelling = $this->getCrossSales($id_product, $cookie->id_lang);
                if (count($crossSelling)) {
                    $this->_html .= '<br class="clear" />
					<h3>' . $this->l('Cross Selling') . '</h3>
					<div style="overflow-y: scroll; height: 200px;">
					<table class="table" border="0" cellspacing="0" cellspacing="0">
					<thead>
						<tr>
							<th>' . $this->l('Product name') . '</th>
							<th>' . $this->l('Quantity sold') . '</th>
							<th>' . $this->l('Average price') . '</th>
						</tr>
					</thead><tbody>';
                    $tokenProducts = Tools::getAdminToken('AdminCatalog' . (int) Tab::getIdFromClassName('AdminCatalog') . (int) $cookie->id_employee);
                    foreach ($crossSelling as $selling) {
                        $this->_html .= '
						<tr>
							<td ><a href="?tab=AdminCatalog&id_product=' . (int) $selling['id_product'] . '&addproduct&token=' . $tokenProducts . '">' . $selling['pname'] . '</a></td>
							<td align="center">' . (int) $selling['pqty'] . '</td>
							<td align="right">' . Tools::displayprice($selling['pprice'], $currency) . '</td>
						</tr>';
                    }
                    $this->_html .= '</tbody></table></div>';
                }
            }
        } else {
            $categories = Category::getCategories((int) $cookie->id_lang, true, false);
            $this->_html .= '
			<label>' . $this->l('Choose a category') . '</label>
			<div class="margin-form">
				<form action="" method="post" id="categoriesForm">
					<select name="id_category" onchange="$(\'#categoriesForm\').submit();">
						<option value="0">' . $this->l('All') . '</option>';
            foreach ($categories as $category) {
                $this->_html .= '<option value="' . $category['id_category'] . '"' . ($id_category == $category['id_category'] ? ' selected="selected"' : '') . '>' . $category['name'] . '</option>';
            }
            $this->_html .= '
					</select>
				</form>
			</div>
			<div class="clear space"></div>
			' . $this->l('Click on a product to access its statistics.') . '
			<div class="clear space"></div>
			<h2>' . $this->l('Products available') . '</h2>
			<div style="overflow-y: scroll; height: 600px;">
			<table class="table" border="0" cellspacing="0" cellspacing="0">
			<thead>
				<tr>
					<th>' . $this->l('Ref.') . '</th>
					<th>' . $this->l('Name') . '</th>
					<th>' . $this->l('Stock') . '</th>
				</tr>
			</thead><tbody>';
            foreach ($this->getProducts($cookie->id_lang) as $product) {
                $this->_html .= '<tr><td>' . $product['reference'] . '</td><td><a href="' . $currentIndex . '&token=' . Tools::getValue('token') . '&module=' . $this->name . '&id_product=' . $product['id_product'] . '">' . $product['name'] . '</a></td><td>' . $product['quantity'] . '</td></tr>';
            }
            $this->_html .= '</tbody></table><br /></div><br />
				<a href="' . $_SERVER['REQUEST_URI'] . '&export=1"><img src="../img/admin/asterisk.gif" />' . $this->l('CSV Export') . '</a><br />';
        }
        $this->_html .= '</fieldset><br />
		<fieldset class="width3"><legend><img src="../img/admin/comment.gif" /> ' . $this->l('Guide') . '</legend>
		<h2>' . $this->l('Number of purchases compared to number of viewings') . '</h2>
			<p>
				' . $this->l('After choosing a category and selecting a product, informational graphs will appear. Then, you will be able to analyze them.') . '
				<ul>
					<li class="bullet">' . $this->l('If you notice that a product is successful and often purchased, but viewed infrequently, you should put it more prominently on your webshop front-office.') . '</li>
					<li class="bullet">' . $this->l('On the other hand, if a product has many viewings but is not often purchased, we advise you to check or modify this product\'s information, description and photography again.') . '
					</li>
				</ul>
			</p>
		</fieldset>';
        return $this->_html;
    }
Exemplo n.º 26
0
    public function display()
    {
        global $cookie;
        $currency = Currency::getCurrency(Configuration::get('PS_CURRENCY_DEFAULT'));
        $language = Language::getLanguage(intval($cookie->id_lang));
        $iso = $language['iso_code'];
        $dateBetween = ModuleGraph::getDateBetween();
        $sales = self::getSales($dateBetween);
        $carts = self::getCarts($dateBetween);
        $records = self::getRecords($dateBetween);
        echo '
		<div style="float: left">';
        $this->displayCalendar();
        $this->displayMenu(false);
        $this->displayEngines();
        $this->displaySearch();
        echo '
		</div>
		<div style="float: left; margin-left: 40px;">
			<fieldset class="width3"><legend><img src="../img/admin/tab-stats.gif" /> ' . $this->l('Help') . '</legend>
				<p>' . $this->l('Use the calendar on the left to select the time period.') . '</p>
				<p>' . $this->l('All available statistic modules are displayed in the Navigation list beneath the calendar.') . '</p>
				<p>' . $this->l('In the Settings sub-tab, you can also customize the Stats tab to fit your needs and resources, change the graph rendering engine, and adjust the database settings.') . '</p>
			</fieldset>
			<br /><br />
			<fieldset class="width3"><legend><img src="../img/admin/___info-ca.gif" style="vertical-align: middle" /> ' . $this->l('Sales') . '</legend>
				<table>
					<tr><td style="font-weight: bold">' . $this->l('Total placed orders') . '</td><td style="padding-left: 20px">' . $sales['orders'] . '</td></tr>
					<tr><td style="font-weight: bold">' . $this->l('Total products sold') . '</td><td style="padding-left: 20px">' . $sales['products'] . '</td></tr>
				</table>
				<table cellspacing="0" cellpadding="0" class="table space">
					<tr>
						<th style="width: 150px"></th>
						<th style="width: 180px; text-align: center; font-weight: bold">' . $this->l('total paid with tax') . '</th>
						<th style="width: 220px; text-align: center; font-weight: bold">' . $this->l('total products not incl. tax') . '</th>
					</tr>
					<tr>
						<th style="font-weight: bold">' . $this->l('Sales turnover') . '</th>
						<td align="right">' . Tools::displayPrice($sales['ttc'], $currency) . '</td>
						<td align="right">' . Tools::displayPrice($sales['ht'], $currency) . '</td>
					</tr>
					<tr>
						<th style="font-weight: bold">' . $this->l('Largest order') . '</th>
						<td align="right">' . Tools::displayPrice($sales['maxttc'], $currency) . '</td>
						<td align="right">' . Tools::displayPrice($sales['maxht'], $currency) . '</td>
					</tr>
					<tr>
						<th style="font-weight: bold">' . $this->l('Smallest order') . '</th>
						<td align="right">' . Tools::displayPrice($sales['minttc'], $currency) . '</td>
						<td align="right">' . Tools::displayPrice($sales['minht'], $currency) . '</td>
					</tr>
				</table>
			</fieldset>
			<br /><br />
			<fieldset class="width3"><legend><img src="../img/admin/products.gif" style="vertical-align: middle" /> ' . $this->l('Carts') . '</legend>
				<table cellspacing="0" cellpadding="0" class="table">
					<tr>
						<th style="width: 150px"></th>
						<th style="width: 180px; text-align: center; font-weight: bold">' . $this->l('Products total all tax inc.') . '</th>
					</tr>
					<tr>
						<th style="font-weight: bold">' . $this->l('Average cart') . '</th>
						<td align="right">' . Tools::displayPrice($carts['average'], $currency) . '</td>
					</tr>
					<tr>
						<th style="font-weight: bold">' . $this->l('Largest cart') . '</th>
						<td align="right">' . Tools::displayPrice($carts['highest'], $currency) . '</td>
					</tr>
					<tr>
						<th style="font-weight: bold">' . $this->l('Smallest cart') . '</th>
						<td align="right">' . Tools::displayPrice($carts['lowest'], $currency) . '</td>
					</tr>
				</table>
			</fieldset>';
        if (strtolower($cookie->stats_granularity) != 'd' and $records and is_array($records)) {
            echo '
			<br /><br />
			<fieldset class="width3"><legend><img src="../img/admin/medal.png" style="vertical-align: middle" />' . $this->l('Records') . '</legend>
				<table cellspacing="0" cellpadding="0" class="table">
					<tr>
						<th style="width: 150px"></th>
						<th style="width: 100px; text-align: center; font-weight: bold">' . $this->l('date') . '</th>
						<th style="width: 120px; text-align: center; font-weight: bold">' . $this->l('with tax') . '</th>
						<th style="width: 180px; text-align: center; font-weight: bold">' . $this->l('only products not incl. tax') . '</th>
					</tr>';
            if (strtolower($cookie->stats_granularity) == 'y') {
                echo '
					<tr>
						<th style="font-weight: bold">' . $this->l('Best month') . '</th>
						<td align="right">' . $this->displayDate($records['bestmonth']['date'], $iso) . '</td>
						<td align="right">' . Tools::displayPrice($records['bestmonth']['totalttc'], $currency) . '</td>
						<td align="right">' . Tools::displayPrice($records['bestmonth']['totalht'], $currency) . '</td>
					</tr>
					<tr>
						<th style="font-weight: bold">' . $this->l('Worst month') . '</th>
						<td align="right">' . $this->displayDate($records['worstmonth']['date'], $iso) . '</td>
						<td align="right">' . Tools::displayPrice($records['worstmonth']['totalttc'], $currency) . '</td>
						<td align="right">' . Tools::displayPrice($records['worstmonth']['totalht'], $currency) . '</td>
					</tr>';
            }
            echo '
					<tr>
						<th style="font-weight: bold">' . $this->l('Best day') . '</th>
						<td align="right">' . $this->displayDate($records['bestday']['date'], $iso) . '</td>
						<td align="right">' . Tools::displayPrice($records['bestday']['totalttc'], $currency) . '</td>
						<td align="right">' . Tools::displayPrice($records['bestday']['totalht'], $currency) . '</td>
					</tr>
					<tr>
						<th style="font-weight: bold">' . $this->l('Worst day') . '</th>
						<td align="right">' . $this->displayDate($records['worstday']['date'], $iso) . '</td>
						<td align="right">' . Tools::displayPrice($records['worstday']['totalttc'], $currency) . '</td>
						<td align="right">' . Tools::displayPrice($records['worstday']['totalht'], $currency) . '</td>
					</tr>
				</table>
			</fieldset>';
        }
        echo '
		</div>
		<div class="clear"></div>';
    }
Exemplo n.º 27
0
    protected function getData($layers)
    {
        $state_query = '';
        if ((int) $this->option) {
            $state_query = 'AND (
				SELECT oh.id_order_state FROM `' . _DB_PREFIX_ . 'order_history` oh
				WHERE o.id_order = oh.id_order
				ORDER BY oh.date_add DESC, oh.id_order_history DESC
				LIMIT 1) = ' . (int) $this->option;
        }
        $this->_titles['main'] = $this->l('Percentage of orders listed by carrier.');
        $sql = 'SELECT c.name, COUNT(DISTINCT o.`id_order`) as total
				FROM `' . _DB_PREFIX_ . 'carrier` c
				LEFT JOIN `' . _DB_PREFIX_ . 'orders` o ON o.id_carrier = c.id_carrier
				WHERE o.`date_add` BETWEEN ' . ModuleGraph::getDateBetween() . '
					' . Shop::addSqlRestriction(Shop::SHARE_ORDER, 'o') . '
					' . $state_query . '
				GROUP BY c.`id_carrier`';
        $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql);
        foreach ($result as $row) {
            $this->_values[] = $row['total'];
            $this->_legend[] = $row['name'];
        }
    }
Exemplo n.º 28
0
 /**
  * Refresh cache data of referrer statistics in referrer_shop table
  *
  * @param array $referrers
  * @param int $employee
  * @return true
  */
 public static function refreshCache($referrers = null, $employee = null)
 {
     if (!$referrers || !is_array($referrers)) {
         $referrers = Db::getInstance()->executeS('SELECT id_referrer FROM ' . _DB_PREFIX_ . 'referrer');
     }
     foreach ($referrers as $row) {
         $referrer = new Referrer($row['id_referrer']);
         foreach (Shop::getShops(true, null, true) as $shop_id) {
             if (!$referrer->isAssociatedToShop($shop_id)) {
                 continue;
             }
             $stats_visits = $referrer->getStatsVisits(null, $employee);
             $registrations = $referrer->getRegistrations(null, $employee);
             $stats_sales = $referrer->getStatsSales(null, $employee);
             Db::getInstance()->update('referrer_shop', array('cache_visitors' => (int) $stats_visits['uniqs'], 'cache_visits' => (int) $stats_visits['visits'], 'cache_pages' => (int) $stats_visits['pages'], 'cache_registrations' => (int) $registrations, 'cache_orders' => (int) $stats_sales['orders'], 'cache_sales' => number_format($stats_sales['sales'], 2, '.', ''), 'cache_reg_rate' => $stats_visits['uniqs'] ? $registrations / $stats_visits['uniqs'] : 0, 'cache_order_rate' => $stats_visits['uniqs'] ? $stats_sales['orders'] / $stats_visits['uniqs'] : 0), 'id_referrer = ' . (int) $referrer->id . ' AND id_shop = ' . (int) $shop_id);
         }
     }
     Configuration::updateValue('PS_REFERRERS_CACHE_LIKE', ModuleGraph::getDateBetween($employee));
     Configuration::updateValue('PS_REFERRERS_CACHE_DATE', date('Y-m-d H:i:s'));
     return true;
 }
Exemplo n.º 29
0
    public function hookAdminStatsModules()
    {
        if (Tools::isSubmit('submitSEK')) {
            Configuration::updateValue('SEK_FILTER_KW', trim(Tools::getValue('SEK_FILTER_KW')));
            Configuration::updateValue('SEK_MIN_OCCURENCES', (int) Tools::getValue('SEK_MIN_OCCURENCES'));
            Tools::redirectAdmin('index.php?tab=AdminStats&token=' . Tools::getValue('token') . '&module=' . $this->name);
        }
        if (Tools::getValue('export')) {
            $this->csvExport(array('type' => 'pie'));
        }
        $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($this->_query . ModuleGraph::getDateBetween() . $this->_query2);
        $total = count($result);
        $this->html = '<div class="blocStats"><h2 class="icon-' . $this->name . '"><span></span>' . $this->displayName . '</h2>
		<p>' . ($total == 1 ? sprintf($this->l('%d keyword matches your query.'), $total) : sprintf($this->l('%d keywords match your query.'), $total)) . '</p>';
        if ($result && $total) {
            $table = '
			<div style="overflow-y: scroll; height: 600px;">
			<table class="table" border="0" cellspacing="0" cellspacing="0">
			<thead>
				<tr><th style="width:400px;">' . $this->l('Keywords') . '</th>
				<th style="width:50px; text-align: right">' . $this->l('Occurrences') . '</th></tr>
			</thead><tbody>';
            foreach ($result as $index => $row) {
                $keyword =& $row['keyword'];
                $occurences =& $row['occurences'];
                $table .= '<tr><td>' . $keyword . '</td><td style="text-align: right">' . $occurences . '</td></tr>';
            }
            $table .= '</tbody></table></div>';
            $this->html .= '<div>' . $this->engine(array('type' => 'pie')) . '</div>
			<br/>
			<p><a href="' . Tools::safeOutput($_SERVER['REQUEST_URI']) . '&export=1&exportType=language"><img src="../img/admin/asterisk.gif" />' . $this->l('CSV Export') . '</a></p><br/>
			<form action="' . Tools::htmlentitiesUTF8($_SERVER['REQUEST_URI']) . '" method="post">
				' . $this->l('Filter by keyword') . ' <input type="text" name="SEK_FILTER_KW" value="' . Tools::htmlentitiesUTF8(Configuration::get('SEK_FILTER_KW')) . '" />
				' . $this->l('and min occurrences') . ' <input type="text" name="SEK_MIN_OCCURENCES" value="' . (int) Configuration::get('SEK_MIN_OCCURENCES') . '" />
				<input type="submit" class="button" name="submitSEK" value="' . $this->l('   Apply   ') . '" />
			</form>
			<br/>' . $table;
        } else {
            $this->html .= '<p><strong>' . $this->l('No keywords') . '</strong></p>';
        }
        $this->html .= '</div><br/>
		<div class="blocStats"><h2 class="icon-guide"><span></span>' . $this->l('Guide') . '</h2>
			<h2>' . $this->l('Identify external search engines\' keywords') . '</h2>
			<p>' . $this->l('One of the most common ways of finding a website through a search engine.') . $this->l('Identifying the most popular keywords entered by your new visitors allows you to see which products you should put in front if you want to attract more visitors and potential customers.') . '
			</p><br />
			<h3>' . $this->l('How does it work?') . '</h2>
			<p>' . $this->l('When a visitor comes to your website, the server notes their previous location. This module parses the URL and finds the keywords in it.') . sprintf($this->l('Currently, it manages the following search engines: %1$s and %2$s.'), '<b>Google, AOL, Yandex, Ask, NHL, Yahoo, Baidu, Lycos, Exalead, Live, Voila</b>', '<b>Altavista</b>') . $this->l('Soon it will be possible to dynamically add new search engines and contribute to this module.') . '</p><br />
		</div>';
        return $this->html;
    }
Exemplo n.º 30
0
 public function getDate()
 {
     return ModuleGraph::getDateBetween($this->_employee);
 }