<?php

/**
 *
 * INDEXU
 * Copyright(C), Nicecoder, 2000-2006, All Rights Reserved.
 *
 * INDEXU(tm) is protected by Indonesia and International copyright laws.
 * Unauthorized use or distribution of INDEXU(tm) is strictly prohibited,
 * violators will be prosecuted. To obtain a license for using INDEXU(tm),
 * please register at Nicecoder home page at http://www.nicecoder.com
 *
 * Author:
 *    Dody Rachmat Wicaksono (dody@nicecoder.com)
 *    M. Zuber (zubby@nicecoder.com)
 *
 */
 
  /*===================================================
    main
  ===================================================*/

  include "application.php";

  RunPreFilter(__FILE__);

  if (empty($m) && empty($id) && empty($res)) {
    RunPostFilter(__FILE__);
  }

  if ($res == 'ok') {
    DisplayTemplate($theme_path . "payment_ok.html");
    RunPostFilter(__FILE__);
  }

  $query      = "select * from idx_invoice_config";
  $result     = $dbConn->execute($query);
  $company    = $result->Fields('company');

  $query      = "select * from idx_invoice where invoice_id = '$id'";
  $result     = $dbConn->execute($query);
  $total      = $result->Fields('total');
  $invoice_id = $result->Fields('invoice_id');
  
  $item_name  = "{$company}, Payment Invoice #{$invoice_id}";
  $custom     = "novar&novar&{$invoice_id}";

  $notify_url = $site_url . "/payment/{$m}.check-invoice.php";
  $return_url = $site_url . "/paynow.php?res=ok&s=invoice";
  $cancel_url = $site_url . "/invoice.php?id={$invoice_id}";

  if (empty($invoice_id)) {
    RunPostFilter(__FILE__);
  }

  // route to selected payment system
  include "payment/" . $m . ".inc.php";
  include "payment/" . $m . ".php";

  RunPostFilter(__FILE__);

?>