<h1 class="h4 main-panel-title">{'printOrderHeading'|translate}</h1>
<div class="row bottom-space m-b-2">
   <div class="col-md-4">
       {block "print-order-head-button"}
      {if $body.data.id}
      <a
         href="{path('kupshop_admin_emailattachment_adminattachment', ['id_order' => $body.data.id, 'type' => 'order_summary'])}"
       target="printCenter" class="btn btn-primary btn-block">
         <span class="glyphicon glyphicon-print"></span>&nbsp;&nbsp;{'actionPrintRecap'|translate:'orders'}
      </a>
      {/if}
   </div>
   <div class="col-md-4">
      <a
         href="{path('kupshop_admin_emailattachment_adminattachment', ['id_order' => $body.data.id, 'type' => 'order_invoice'])}"
      target="printCenter" class="btn btn-primary btn-block">
         <span class="glyphicon glyphicon-print"></span>&nbsp;&nbsp;{'actionPrintOrder'|translate:'orders'}
      </a>
       {/block}
   </div>
   {if $module.INVOICES && $dbcfg.generate_invoices == 'Y'}
   <div class="col-md-4">
      {if is_null($order->getInvoiceNo())}
         <button name="acn" value="generateInvoiceNo" {if $body.duplicate || !$order->isActive()}disabled{/if}
                 class="btn btn-block btn-danger {if $body.duplicate || !$order->isActive()}disabled{else}confirm{/if}"
                 title="Vygenerovat fakturu">Vygenerovat fakturu
         </button>
      {else}
         <label>Faktura {$order->getInvoiceNo()}</label>
      {/if}
   </div>
   {/if}
</div>
{block "balikobot-print"}
   {if findModule('balikonos', 'provider') == 'balikobot'}
      <h1 class="h4 main-panel-title">Balíkobot - tisk štítku</h1>
      {$deliveryType = $order->getDeliveryType()}

      {if $deliveryType && $deliveryType->getDelivery()}
         {$deliveryId = $deliveryType->getDelivery()->id}
      {else}
         {$deliveryId = null}
      {/if}
      {if !empty($dbcfg.balikobot.delivery_type[$deliveryId].carrier)}
         <div class="row bottom-space m-b-3">
            <label class="col-xs-3 col-sm-1 control-label">Pozice</label>
            <div class="col-xs-3 col-sm-2 text-center">
               {if $dbcfg.balikobot.delivery_type[$deliveryId].carrier == "zasilkovna"}
                  {print_select name="data[data][balikobot][position]" var=[1=>1,2=>2,3=>3,4=>4,5=>5,6=>6,7=>7,8=>8] selected=[1=>1]}
               {elseif $dbcfg.balikobot.delivery_type[$deliveryId].carrier == "intime"}
                  {print_select name="data[data][balikobot][position]" var=[1=>1,2=>2,3=>3,4=>4,5=>5,6=>6,7=>7,8=>8] selected=[1=>1]}
               {elseif $dbcfg.balikobot.delivery_type[$deliveryId].carrier == "pbh"}
                  {print_select name="data[data][balikobot][position]" var=[1=>1,2=>2,3=>3,4=>4,5=>5,6=>6,7=>7,8=>8,9=>9] selected=[1=>1]}
               {else}
                  {print_select name="data[data][balikobot][position]" var=[1=>1,2=>2,3=>3,4=>4] selected=[1=>1]}
               {/if}
            </div>

            <label class="col-xs-3 col-sm-1 control-label">Balíků</label>
            <div class="col-xs-3 col-sm-2 text-center">
               <div class="input-group">
                  <input name="data[data][balikobot][packages]" class="form-control input-sm" type="number" min="1" value="{$body.custom_data.balikobot.packages|default:1}">
                  <div class="input-group-btn">
                     <span class="btn btn-sm">ks</span>
                  </div>
               </div>
            </div>

            <div class="col-xs-3 col-sm-6">
               {$balikobot = $view->getBalikobot()}
               {if $balikobot}
                  {$balik = reset($balikobot)}
               {/if}
               {if $balik && $balik.close < 2}
                  {* existuje neodeslany balik - je mozne ho Odebrat z Balíkobota nebo Vytisknout štítek *}
                  <button name="acn" value="deleteFromBalikobot" class="btn btn-sm btn-danger"><span class="glyphicon glyphicon-trash"></span> Odebrat z Balíkobota</button>
                  <button name="acn" value="printExistingTicket" class="btn btn-sm btn-success"><span class="glyphicon glyphicon-print"></span> Vytisknout štítek</button>
               {else}
                  {* neexistuje zadny balik nebo vsechny baliky uz byly odeslane - je mozne Nahrát a vytisknout štítek (novy) *}
                  <button name="acn" value="sendToBalikobot" class="btn btn-sm btn-primary"><span class="glyphicon glyphicon-send"></span> Nahrát do Balíkobota</button>
                  <button name="acn" value="printTicket" class="btn btn-sm btn-success"><span class="glyphicon glyphicon-print"></span> Nahrát a vytisknout štítek</button>
               {/if}
               {if $balikobot}
                  {* Zobrazit balíky - seznam vsech baliku dane objednavky *}
                  <a class="btn btn-sm btn-primary" target="" href="javascript:nw('list', 'BalikobotSubmittedOrders', 'orderId={$order->id}')"><span class="glyphicon glyphicon-list"></span> Zobrazit balíky</a>
               {/if}
            </div>
         </div>

         {if count($dbcfg.balikobot.users) > 1}
            <div class="row m-b-3">
               <label class="col-xs-3 col-sm-1 control-label">Svozové místo</label>
               <div class="col-xs-3 col-sm-5">
                  <select class="selecter" name="data[data][balikobot][user]">
                     {foreach $dbcfg.balikobot.users as $user}
                        <option value="{$user.user}">{$user.name}</option>
                     {/foreach}
                  </select>
               </div>
            </div>
         {/if}

         <div class="row bottom-space m-b-3">
            <label class="col-xs-3 col-sm-1 control-label two-lines">Poznámka dopravci</label>
            <div class="col-xs-3 col-sm-5 text-center">
               <input name="data[data][balikobot][note]" class="form-control input-sm" placeholder="Poznámka..." type="text" maxlength="50" value="{$body.custom_data.balikobot.note}">
               <span class="help-block" style="text-align:left"><span class="charCounter" rel="data[data][balikobot][note]"></span></span>
            </div>

            <label class="col-xs-3 col-sm-2 control-label">ČP Velikost</label>
            <div class="col-xs-3 col-sm-2 text-center">
               {print_select name="data[data][balikobot][size]" var=['' => 'Výchozí', 'S' => 'S', 'M' => 'M', 'L' => 'L', 'XL' => 'XL'] selected=$body.custom_data.balikobot.size}
            </div>
         </div>
      {/if}
   {/if}
{/block}

<h1 class="h4 main-panel-title">Tiskové sestavy</h1>

<div class="row">
   <div class="col-md-3">
      <div class="panel panel-default">
         <div class="panel-heading">
            <h3 class="panel-title">Objednávka <span class="glyphicon glyphicon-print pull-right"></span></h3>
         </div>
         <div class="panel-body">
            {foreach from=$body.printSetOffer.common item=txt key=key}
               <div>
                  <a href="launch.php?s=printCenter.php&amp;type=order&amp;set={$key}&amp;ID={$body.data.id}&IDo={$body.data.id}"
                     target="printCenter" class="btn btn-link">{$txt}</a>
               </div>
            {/foreach}
            {*<div>*}
            {*<a href="launch.php?s=printCenter.php&amp;type=order&amp;set=InvoiceForeign&amp;ID={$body.data.id}&amp;template=invoiceSimple"*}
            {*target="printCenter" class="btn btn-link">Běžný daňový doklad</a>*}
            {*</div>*}

            <div>
               {block "pos-print-button"}
               <a href="launch.php?s=printCenter.php&type=order&set=POS&ID={$body.data.id}&template=POSInvoice"
                  target="printCenter" class="btn btn-link">Pokladní daňový doklad</a>
               {/block}
            </div>

            <div>
               <a href="launch.php?s=printCenter.php&type=order&set=POS&ID={$body.data.id}&template=POSVydejka"
                  target="printCenter" class="btn btn-link">Pokladní výdejka</a>
            </div>

            <div>
               <a href="launch.php?s=printCenter.php&amp;type=order&amp;set=InvoiceForeign&amp;ID={$body.data.id}&amp;template=invoiceProforma"
                  target="printCenter" class="btn btn-link">Zálohová faktura v HTML (stará)</a>
            </div>
            <div>
               <a href="launch.php?s=printCenter.php&type=order&set=order&ID={$body.data.id}"
                  target="printCenter" class="btn btn-link">Objednávka v HTML (stará)</a>
            </div>
            <div>
               <a href="launch.php?s=printCenter.php&type=orderPicking&set=order&template=orderViewprintPickingList.tpl&ID={$body.data.id}"
                  target="printCenter" class="btn btn-link">Vychystávací list</a>
            </div>

            {if $module.WAREHOUSE && isDevelopment()}
               <div>
                  <a href="launch.php?s=printCenter.php&type=order&set=POS&ID={$body.data.id}&template=warehouse"
                     target="printCenter" class="btn btn-link">FAKTURA S POZICEMI</a>
               </div>
            {/if}

            {block "order-print-addon"}{/block} {* custom položky, např. druhá faktura na nejlevnejsi-kotoucky.cz *}
         </div>
      </div>
   </div>
   <div class="col-md-3">
      <div class="panel panel-default">
         <div class="panel-heading">
            <h3 class="panel-title">Přílohy <span class="glyphicon glyphicon-print pull-right"></span></h3>
         </div>
         <div class="panel-body">
            {foreach $view->getPrintAttachments() as $type => $name}
               <div>
                  <a href="{if $body.data.id}{path('kupshop_admin_emailattachment_adminattachment', ['id_order' => $body.data.id, 'type' => $type])}{/if}"
                     target="printCenter" class="btn btn-link">{$name}</a>
               </div>
            {/foreach}
         </div>
      </div>
   </div>
   <div class="col-md-3">
      <div class="panel panel-default">
         <div class="panel-heading">
            <h3 class="panel-title">Produkty <span class="glyphicon glyphicon-print pull-right"></span></h3>
         </div>
         <div class="panel-body">
            {foreach from=$body.printSetOffer.products item=txt key=key}
               <div>
                  <a href="launch.php?s=printCenter.php&amp;type=product&amp;set={$key}&amp;IDo={$body.data.id}&amp;by=ean"
                     target="printCenter" class="btn btn-link">{$txt}</a>
               </div>
            {/foreach}
         </div>
      </div>
   </div>
</div>
