/**
  * 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;
 }