<?php
require_once DIR_CORE.'couriers-'.DB_TYPE.'.php';
require_once DIR_CORE.'couriers-admin.php';
require_once DIR_CORE.'couriers.php';

require_once DIR_CORE.'orders-'.DB_TYPE.'.php';
require_once DIR_CORE.'orders-admin.php';
require_once DIR_CORE.'orders.php';

require_once DIR_CORE.'products-'.DB_TYPE.'.php';
require_once DIR_CORE.'products.php';

if( $a == 'List' ){

  if( isset( $sOption ) ){
    if( $sOption == 'del' )
      $content .= $tpl->tbHtml( 'messages.tpl', 'DELETED_SHORT' );
  }

  if( !isset( $iStatus ) )
    $iStatus = null;

  $sSelectStatus = throwOrderStatusSelect( $iStatus );

  $content .= $tpl->tbHtml( 'orders_list.tpl', 'HEAD' );
  $sOrdersList = listOrders( 'orders_list.tpl' );
  $content .= !empty( $sOrdersList ) ? $sOrdersList : $tpl->tbHtml( 'orders_list.tpl', 'NOT_FOUND' );
}
elseif( $a == 'Delete' && isset( $iOrder ) && is_numeric( $iOrder ) ){
  delOrder( $iOrder );
  header( 'Location: '.$_SERVER['PHP_SELF'].'?p='.$aActions['g'].'List&sOption=del' );
  exit;
}
elseif( $a == 'More' && isset( $iOrder ) && is_numeric( $iOrder ) ){

  if( isset( $sOption ) ){
    $content .= $tpl->tbHtml( 'messages.tpl', 'SAVED_SHORT' );    
  }  

  delOrderMass( );

  if( isset( $sOption ) && $sOption == 'save' ){
    saveOrderStatus( $iOrder, $iStatus );
    header( 'Location: '.$_SERVER['PHP_SELF'].'?p='.$aActions['g'].'More&sOption=&iOrder='.$iOrder );
    exit;
  }
  else{
    $aData = throwOrder( $iOrder );
    if( isset( $aData ) && is_array( $aData ) ){
      $sStatusSelect      = throwOrderStatusSelect( $aData['iStatus'] );

      require DIR_CONFIG.'lang_'.$aData['sLang'].'.php';
      $sBasketList = listBasket( $iOrder, 'orders_details.tpl' );
      if( !empty( $sBasketList ) ){
        $aData['fSummary'] = tPrice( $aData['fCourierPrice'] + $aList['fSummary'] );
        $aData['sSummary'] = changePriceFormat( $aData['fSummary'] );
        $sBasketList .= $tpl->tbHtml( 'orders_details.tpl', 'COURIER' );
      }
      else
        $sBasketList = $tpl->tbHtml( 'orders_details.tpl', 'NOT_FOUND' );

      require DB_CONFIG_LANG;

      $content .= $tpl->tbHtml( 'orders_details.tpl', 'SHOW' );
    }
    else
      $content .= $tpl->tbHtml( 'messages.tpl', 'NOT_EXISTS' );
  }
}
?>