protected function get_restrictions() { $restrictions = array(); if (!$this->admin_mode) { $restrictions['affiliate'] = $_SESSION['affiliate_id']; } if ($this->date_restriction != '') { $restrictions['start'] = Database::format_date($_GET['start']); $restrictions['end'] = Database::format_date($_GET['end']); } if ($this->id_restriction != '') { $restrictions['id'] = $this->id; } return $restrictions; }
public static function format_date_time($date) { $matches = array(); $result = preg_match('/^([0-9]{8})([0-9]{2})([0-9]{2})([0-9]{2})$/', $date, $matches); return Database::format_date($matches[1]) . ' ' . $matches[2] . ':' . $matches[3] . ':' . $matches[4]; }
General Public License for more details. You should have received a copy of the GNU General Public License along with Affiliates For All. If not, see <http://www.gnu.org/licenses/>. */ $admin_required = TRUE; require_once '../lib/bootstrap.php'; $db = new Database(); $stmt = $db->get_pdo()->prepare('select id, paypal, local_username, ( select sum(commission) from orders where orders.affiliate=affiliates.id and orders.status in (\'refund\', \'refunded\', \'shipped\') and orders.date_entered < :date + interval 1 day ) as commission, ( select sum(amount) from payments where payments.affiliate=affiliates.id ) as already_paid from affiliates'); $date = Database::format_date($_GET['end']); $stmt->execute(array('date' => $date)); $rows = $stmt->fetchAll(); header('Content-Type: text/plain'); foreach ($rows as $row) { $amount = sprintf('%2.2f', $row[3] - $row[4]); $id = preg_replace('/[^A-Za-z0-9]/', '', $row[2]); if (strlen($id) > 15) { $id = substr($id, 0, 15); } if ($amount > 0) { echo "{$row[1]}\t{$amount}\t{$currency_code}\taff_{$row[0]}_{$id}\t" . "Your affiliate commission to {$date}. Thank you.\n"; } }