public function __construct() { parent::__construct(); // Insert our standard javascript and css into the head $document = JFactory::getDocument(); // Jquery validation $document->addStyleSheet(JURI::base() . "components/com_virtuemart/views/mds/tmpl/css/screen.css"); $document->addScript(JURI::base() . "components/com_virtuemart/views/mds/tmpl/js/jquery.validate.min.js"); // Date Time Picker $document->addStyleSheet(JURI::base() . "components/com_virtuemart/views/mds/tmpl/datetimepicker-master/jquery.datetimepicker.css"); $document->addScript(JURI::base() . "components/com_virtuemart/views/mds/tmpl/datetimepicker-master/jquery.datetimepicker.js"); // Our custom js and css $document->addScript(JURI::base() . "components/com_virtuemart/views/mds/tmpl/js/mds_collivery.js"); $document->addStyleSheet(JURI::base() . "components/com_virtuemart/views/mds/tmpl/css/mds_collivery.css"); // Our base url $document->addScriptDeclaration('base_url = "' . JURI::base() . '";'); // Load the database and execute our sql file $this->db = JFactory::getDBO(); // Get information of our plugin so we can pass it on to MDS Collivery for Logs $sel_query = "SELECT * FROM `#__extensions` where type = 'plugin' and element = 'mds_shipping' and folder = 'vmshipment';"; $this->db->setQuery($sel_query); $this->db->query(); $this->extension_id = $this->db->loadObjectList()[0]->extension_id; $this->app_name = $this->db->loadObjectList()[0]->extension_id; $this->app_info = json_decode($this->db->loadObjectList()[0]->manifest_cache); // Get our login information $config_query = "SELECT * FROM `#__mds_collivery_config` where id = 1;"; $this->db->setQuery($config_query); $this->db->query(); $this->password = $this->db->loadObjectList()[0]->password; $this->username = $this->db->loadObjectList()[0]->username; $this->risk_cover = $this->db->loadObjectList()[0]->risk_cover; $version = new JVersion(); require_once preg_replace('|com_installer|i', "", JPATH_COMPONENT_ADMINISTRATOR) . '/helpers/config.php'; $this->vm_version = VmConfig::getInstalledVersion(); $config = array('app_name' => $this->app_info->name, 'app_version' => $this->app_info->version, 'app_host' => "Joomla: " . $version->getShortVersion() . ' - Virtuemart: ' . VmConfig::getInstalledVersion(), 'app_url' => JURI::base(), 'user_email' => $this->username, 'user_password' => $this->password); // Use the MDS API Files require_once JPATH_PLUGINS . '/vmshipment/mds_shipping/Mds/Cache.php'; require_once JPATH_PLUGINS . '/vmshipment/mds_shipping/Mds/Collivery.php'; $this->collivery = new Mds\Collivery($config); // Get some information from the API $this->towns = $this->collivery->getTowns(); $this->services = $this->collivery->getServices(); $this->location_types = $this->collivery->getLocationTypes(); $this->addresses = $this->collivery->getAddresses(); $this->default_address_id = $this->collivery->getDefaultAddressId(); $this->default_contacts = $this->collivery->getContacts($this->default_address_id); $this->mds_services = $this->collivery->getServices(); // Class for converting lengths and weights require_once JPATH_PLUGINS . '/vmshipment/mds_shipping/UnitConvertor.php'; $this->converter = new UnitConvertor(); }