<?php

/*======================================================================*\
|| #################################################################### ||
|| # Drag'nDrop Shop 1.8                                              # ||
|| # ---------------------------------------------------------------- # ||
|| # Copyright 2014 JAKWEB All Rights Reserved.                       # ||
|| # This file may not be redistributed in whole or significant part. # ||
|| #   ----------- Drag'nDrop Shop IS NOT FREE SOFTWARE -----------   # ||
|| #                      http://www.jakweb.ch                        # ||
|| #################################################################### ||
\*======================================================================*/

// Check if the file is accessed only via index.php if not stop the script from running
if (!defined('JAK_ADMIN_PREVENT_ACCESS')) die('You cannot access this file directly.');

// Check if the user has access to this file
if (!JAK_USERID || !JAK_ADMINACCESS) jak_redirect(BASE_URL);

// The DB connections data
require_once '../class/class.export.php';

// All the tables we need for this plugin
$errors = array();
$jaktable = DB_PREFIX.'shop_order';

$result = $jakdb->query('SELECT id, name, email FROM '.$jaktable.' WHERE email != "" GROUP BY email ORDER BY id DESC');
if ($jakdb->affected_rows > 0) {
while ($row = $result->fetch_assoc()) {
        // collect each record into $_data
        $jakdata[] = $row;
    }
}

$CEMAIJAK_ALL = $jakdata;

if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    $defaults = $_POST;
    
    if (isset($defaults['export'])) {
    
        emailExport::createFile($jakdata);
    }
    
    
}

// Call the template
$template = 'emails.php';
?>