<?php

// Configuration
require_once('../../config.php');
// Startup
require_once(DIR_SYSTEM . 'startup.php');
// Application Classes
require_once(DIR_SYSTEM . 'library/customer.php');
require_once(DIR_SYSTEM . 'library/currency.php');
require_once(DIR_SYSTEM . 'library/tax.php');
require_once(DIR_SYSTEM . 'library/weight.php');
require_once(DIR_SYSTEM . 'library/length.php');
require_once(DIR_SYSTEM . 'library/cart.php');
// Registry
$registry = new Registry();
// Loader
$loader = new Loader($registry);
$registry->set('load', $loader);
// Config
$config = new Config();
$registry->set('config', $config);
// Database 
$db = new DB(DB_DRIVER, DB_HOSTNAME, DB_USERNAME, DB_PASSWORD, DB_DATABASE);
$registry->set('db', $db);
// Settings
$query = $db->query("SELECT * FROM `".DB_PREFIX."setting`");
foreach ($query->rows as $setting) {
	$config->set($setting['key'], $setting['value']);
}
foreach ($query->row as $key => $value) {
	$config->set('config_' . $key, $value);
}
$db->query("CREATE TABLE IF NOT EXISTS `".DB_PREFIX."order_cielo` (
  `idCielo` int(10) NOT NULL AUTO_INCREMENT,
  `idOrder` int(10) NOT NULL,
  `totalOrder` float(10,2) NOT NULL,
  `totalPaid` float(10,2) NOT NULL,
  `ccMethod` varchar(20) NOT NULL,
  `numParcelas` int(10) NOT NULL,
  `tidCielo` varchar(30) NOT NULL,
  `lrCielo` varchar(5) NOT NULL,
  `statusCielo` int(10) NOT NULL,
  `cpfCustomer` varchar(15) NOT NULL,
  `telCustomer` varchar(15) NOT NULL,
  `dateOrder` varchar(35) NOT NULL,
  PRIMARY KEY (`idCielo`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;");
?>