<?php

    class GoogleTrackingCode {

        private $config;
        private $db;
        private $data = array();
        private $data_recurring = array();
        private $flag = true;
        private $load;
        private $registry;

        public function __construct($registry)
        {
            $this->config = $registry->get('config');
            $this->customer = $registry->get('customer');
            $this->session = $registry->get('session');
            $this->db = $registry->get('db');
            $this->weight = $registry->get('weight');
            $this->futuracalcularst = $registry->get('futuracalcularst');
            $this->ftrgeralregistry = new Ftr_geral_registry($registry);
            $this->load = $registry->get('load');
            $this->registry = $registry;


            if (!isset($this->session->data['cart']) || !is_array($this->session->data['cart'])) {
                $this->session->data['cart'] = array();
                $this->session->data['addQtd'] = array();
            }
        }

        public function __get($name)
        {
            return $this->registry->get($name);
        }

        public function getGATrackingCodes()
        {
            $this->load->dmodel('module/tracking_code');
            $this->load->type('tipocomum');
            $tracking_codes = $this->dmodel_module_tracking_code->getListEnabled();
            $google_analytics = [];

            foreach ($tracking_codes as $tracking_code) {
                if (isset($tracking_code['title']) && Type_GoogleAnalytics::getConstFromNickValue($tracking_code['title'])) {
                    array_push($google_analytics, Type_GoogleAnalytics::getConstFromNickValue($tracking_code['title']));
                }
            }

            return $google_analytics;
        }
    }
?>