{if $smarty.request.noframes==1}
<div class="popbox">
{/if}

<div class="header">{#Shop_title_orders#}</div>
<div class="subheaders">

{if $smarty.request.noframes!=1}
<form method="get">
  <table width="100%" border="0" cellpadding="2" cellspacing="0">
    <tr>
      <td width="100"><label for="lquery">{#Search#}</label></td>
      <td width="100"><input type="text" class="input" name="query" id="lquery" value="{$smarty.request.query|escape:html|stripslashes}" style="width:130px" /></td>
      <td width="100" align="right"><label for="SSelect">{#Shop_order_ostatus_l#}</label></td>
      <td><select id="SSelect" name="status" class="input" style="width:134px">
        <option id="s_n" value="0"></option>
        <option id="s_wait" value="wait" {if $smarty.request.status==wait}selected="selected" {/if}>{#Shop_order_status_wait#}</option>
        <option id="s_ok" value="ok" {if $smarty.request.status==ok}selected="selected" {/if}>{#Shop_order_status_ok#}</option>
        <option id="s_ok_send" value="oksend" {if $smarty.request.status==oksend}selected="selected" {/if}>{#Shop_order_status_oksend#}</option>
        <option id="s_progress" value="progress" {if $smarty.request.status==progress}selected="selected" {/if}>{#Shop_order_status_progress#}</option>
        <option id="s_failed" value="failed" {if $smarty.request.status==failed}selected="selected" {/if}>{#Shop_order_status_failed#}</option>
      </select></td>
    </tr>
    <tr>
      <td width="100"><label for="lZahlungsId">{#Shop_order_opaymentid#}</label></td>
      <td><select name="ZahlungsId" id="lZahlungsId" class="input" style="width:134px">
        <option value=""></option>
        
	  {foreach from=$payments item=p}
	  
        <option value="{$p.Id}" {if $smarty.request.zahlungsid==$p.Id}selected="selected"{/if}>{$p.Name|stripslashes}</option>
        
	  {/foreach}
	  
      </select></td>
      <td align="right"><label for="StartDate">{#Date_since#}</label></td>
      <td><input readonly style="width:100px" class="input" name="StartDate" id="StartDate" value="{if $smarty.request.StartDate==''}{$StartDate|date_format:"%d.%m.%Y"}{else}{$smarty.request.StartDate}{/if}" /></td>
    </tr>
	 <tr>
      <td width="100"><label for="lBetragVon">{#Shop_order_osummftill#}</label></td>
      <td nowrap="nowrap">
      <input name="BetragVon" id="lBetragVon" type="text" class="input" value="{$smarty.request.BetragVon}" maxlength="10" style="width:59px" />-
      <input name="BetragBis" type="text" class="input" value="{$smarty.request.BetragBis}" maxlength="10" style="width:59px"  /></td>
      <td align="right"><label for="EndDate">{#Date_till#}</label></td>
      <td><input readonly style="width:100px" class="input" name="EndDate" id="EndDate" value="{if $smarty.request.EndDate==''}{$smarty.now|date_format:"%d.%m.%Y"}{else}{$smarty.request.EndDate}{/if}" /></td>
	 </tr>
     <tr>
       <td width="100"><label for="lVersandId">{#Shop_order_oshipper_l#}</label></td>
       <td><select name="VersandId" id="lVersandId" class="input" style="width:134px">
         <option value=""></option>
         
        
	  {foreach from=$shipper item=v}
	  
        
         <option value="{$v.Id}" {if $smarty.request.versandid==$v.Id}selected="selected"{/if}>{$v.Name|stripslashes}</option>
         
        
	  {/foreach}
	  
      
       </select></td>
       <td align="right"><label for="llimit">{#DataRecords#}</label></td>
       <td><input type="text" class="input" name="limit" id="llimit" value="{$limit}" style="width:30px" />
         <span class="button_save_div">
         <input type="submit" class="button" value="{#Shop_order_osearch_s#}" />
         </span></td>
     </tr>
  </table>
 <div class="button_save_div">
 <input type="hidden" name="do" value="shop" />
	<input type="hidden" name="sub" value="orders" />
	<input type="hidden" name="SID" value="{$sess}" />
	<input type="hidden" name="search" value="1" />
	<input type="hidden" name="page" value="1" />
 </div>
</form>
{/if}
</div>

<table width="100%" border="0" cellspacing="0" cellpadding="3">

    <tr>
      <td class="headers" width="50"><a href="{$nav_string}&amp;order={$date_sort|default:'date_asc'}">{#Shop_order_onum#}</a></td>
      <td class="headers" width="100"><a href="{$nav_string}&amp;order={$ordernum_sort|default:'ordernum_asc'}">{#Shop_order_otransid#}</a></td>
      <td class="headers" width="80"><a href="{$nav_string}&amp;order={$summ_sort|default:'summ_desc'}">{#Shop_order_osumm#}</a></td>
      <td class="headers" width="70"><a href="{$nav_string}&amp;order={$date_sort|default:'date_asc'}">{#Shop_order_odate#}</a></td>
      <td class="headers" width="120"><a href="{$nav_string}&amp;order={$customer_sort|default:'customer_asc'}">{#Shop_order_ocustomer#}</a></td>
      <td width="50" class="headers"><a href="{$nav_string}&amp;order={$customerid_sort|default:'customerid_asc'}">{#Shop_order_ocnumber#}</a></td>
      <td width="90" class="headers"><a href="{$nav_string}&amp;order={$payment_sort|default:'payment_asc'}">{#Shop_order_opaymentid#}</a></td>
      <td width="90" class="headers"><a href="{$nav_string}&amp;order={$shipper_sort|default:'shipper_asc'}">{#Shop_order_oshipper#}</a></td>
	  <td width="10" valign="middle" class="headers" ><a href="{$nav_string}&amp;order={$status_sort|default:'status_asc'}">{#Shop_order_ostatus#}</a></td>
      <td width="20" class="headers" >&nbsp;</td>
    </tr>

{foreach from=$orders item=o name=orders}
  <tr class="{cycle name='orders' values='second,first'}">
    <td width="50">{$o->Id}</td>
    <td width="100"><a href="#" onclick="javascript:openOrder('?do=shop&amp;sub=edit_order&amp;id={$o->Id}&amp;noframes=1&status={$o->Status}');">{$o->TransaktionsNummer}</a></td>
    <td width="80">{$o->Betrag|numformat}</td>
    <td width="70" {popup sticky=$config_vars.POPSTICKY  text=$o->Datum|date_format:"%d/%m/%Y - %H:%I"}>{$o->Datum|date_format:"%d/%m/%y"}</td>
    <td width="120">
    {if $o->Benutzer!='0'}
    <a href="javascript:void(0);" onclick="popup('index.php?do=user&sub=edituser&user={$o->Benutzer}&noframes=1','UserEdit',980,750,1)">{$o->Rng_Nachname|koobispecialchars} {$o->Rng_Vorname|truncate:2:"."}</a>
    {else}
    {$o->Rng_Nachname|koobispecialchars} {$o->Rng_Vorname|truncate:2:"."} (g)
    {/if}
    </td>
    <td width="50">{if $o->Benutzer=='0'}&nbsp;{else}{$o->Benutzer}{/if}</td>
    <td width="90" {popup sticky=$config_vars.POPSTICKY  text=$o->payment}>{$o->payment|truncate:12:"."}</td>
      <td width="90" {popup sticky=$config_vars.POPSTICKY  text=$o->shipper}>{$o->shipper|truncate:12:"."}</td>
	  <td style="width:12px; text-align:center"><div class="shop_status_{$o->Status}">&nbsp;</div></td>
    <td align="center" nowrap="nowrap">
    <a {popup sticky=$config_vars.POPSTICKY  text=$config_vars.Shop_edit_order} href="javascript:void(0);" onclick="popup('?do=shop&amp;sub=edit_order&amp;id={$o->Id}&amp;noframes=1&status={$o->Status}','EditOrder',980,700,1);"><img src="{$imgpath}/edit.png" alt="" border="0" /></a>
	<a {popup sticky=$config_vars.POPSTICKY  text=$config_vars.Shop_edit_orderDownloads} href="javascript:void(0);" onclick="{if $o->Benutzer<1}alert('{#Shop_downloads_newufifalse#}');{else}popup('?do=shop&amp;sub=user_downloads&amp;user={$o->Benutzer}&amp;name={$o->Rng_Nachname|koobispecialchars}&amp;noframes=1','Downloads',980,750,1);{/if}"><img src="{$imgpath}/download{if !$o->hasESD}_none{/if}.png" alt="" border="0" /></a>
    {if $o->Benutzer<1}<a {popup sticky=$config_vars.POPSTICKY  text=$config_vars.Shop_convertGuestToUser} href="javascript:void(0);"  onclick="popup('index.php?do=user&sub=showusers&sub=convertguesttouser&order={$o->Id}&noframes=1','Convert',800,600,1);"><img src="{$imgpath}/convert_touser.png" alt="" border="0" /></a>{else}<img {popup sticky=$config_vars.POPSTICKY  text=$config_vars.Shop_convertGuestToUserN} src="{$imgpath}/convert_touser_no.png" alt="" border="0" />{/if}
    <a {popup sticky=$config_vars.POPSTICKY  text=$config_vars.Shop_cancel_order} href="javascript:void(0);" onclick="popup('?do=shop&amp;sub=cancel_order&amp;id={$o->Id}&amp;noframes=1','del',1,1,1);"><img src="{$imgpath}/delete.png" alt="" border="0" /></a>
    </td>
  </tr>
 {/foreach}
</table>

<div class="navi_div">{$pages}</div>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="220"><table border="0" cellpadding="1" cellspacing="0">
  <tr>
    <td width="20"><div class="shop_status_wait">&nbsp;</div></td>
    <td>{#Shop_order_status_wait#}</td>
  </tr>
  <tr>
    <td><div class="shop_status_ok">&nbsp;</div></td>
    <td>{#Shop_order_status_ok#}</td>
  </tr>
  <tr>
    <td><div class="shop_status_oksend">&nbsp;</div></td>
    <td>{#Shop_order_status_oksend#}</td>
  </tr>
  <tr>
    <td><div class="shop_status_progress">&nbsp;</div></td>
    <td>{#Shop_order_status_progress#}</td>
  </tr>
  <tr>
    <td><div class="shop_status_failed">&nbsp;</div></td>
    <td>{#Shop_order_status_failed#}</td>
  </tr>
</table></td>
<td width="200" valign="top">
{#Shop_order_olegend#}<br />
<br /></td>
<td width="300" valign="top" style="padding:0px">

{if $smarty.request.noframes!=1}
<fieldset>
<legend>{#Shop_order_oexport#}</legend>

<form method="post" action="{redir}&amp;export=1">
<label><input name="export_format" type="radio" value="csv" />CSV&nbsp;</label>
<label><input name="export_format" type="radio" value="text" />Text&nbsp;</label>
<label><input name="export_format" type="radio" value="html" checked="checked" />HTML&nbsp;</label>
<br />
{if perm('export_orders')}
  <input type="submit" class="button big" style="margin-bottom:0px" value="{#Shop_order_oexport_button#}" />
{else}
  <input type="button" onclick="alert('{#NoPerm#}');" class="button big" style="margin-bottom:0px"  value="{#Shop_order_oexport_button#}" />
{/if}
</form>
</fieldset>
{/if}
</td>
<td valign="top">&nbsp;</td>
</tr>
</table>

<br />

{if $smarty.request.noframes==1}
<hr noshade="noshade" size="1" />
<p align="center">
<input onclick="window.close();" type="button" class="button big" value="{#Close#}" />
</p>
</div>
{/if}


<script language="javascript" src="{$jspath}/calendar.js" type="text/javascript"></script>
<style type="text/css" media="screen,projection">
@import url({$csspath}/calendar.css);
</style>
<script type="text/javascript">
	jQuery(function($){ldelim}
	$.datepicker.setDefaults({ldelim}
	{include file="$incpath/other/calendar.conf.tpl"}
	{rdelim}); 
	$("#StartDate").attachDatepicker();
	$("#EndDate").attachDatepicker();
	{rdelim});
</script>