{* Smarty *}

{literal}
<script type="text/javascript">
//<![CDATA[
$(function() {
  tableToGrid("#PurchaseView", {
    caption:'Планируемые закупки',
    colModel: [
      {name: "purchase_name", width:120, align:"left", sortable: false},
      {name: "purchase_datetill", width:60, align:"right", sortable: false},
      {name: "purchase_price", width:85, align:"right", sortable: false},
      {name: "purchase_quantity", width:45, align:"right", sortable: false},
      {name: "purchase_value", width:90, align:"right", sortable: false}
    ],
    width:"auto",
    height:"auto"
  });
});
//]]>
</script>
{/literal}

{foreach $ArrPurchase as $val}
  {if $val@first}
    {$VarTotal=0}
<table id="PurchaseView">
  <thead>
    <tr>
      <th id="purchase_name">Наименование</th>
      <th id="purchase_datetill">Дата</th>
      <th id="purchase_price">Цена</th>
      <th id="purchase_quantity">Кол-во</th>
      <th id="purchase_value">Стоимость</th>
    </tr>
  </thead>
  <tbody>
  {/if}
    <tr>
      <td><!--a target="_blank" class="ui-state-default" href="/{$MS_SP->Sp_PathTop}/PoInformation.php?po_id={$val.po_id}"-->{$val.purchase_name}<!--/a--></td>
      <td>{$val.purchase_datetill|date_format:"%d.%m.%Y"}</td>
      <td>{$val.purchase_price|number_format:"0":"":" "}</td>
      <td>{$val.purchase_quantity}</td>
      <td>{$val.purchase_price|number_format:"0":"":" "}</td>
    </tr>
    {$VarTotal=$VarTotal+$val.purchase_price}
    {$VarTotally=$VarTotally+$val.purchase_value}
  {if $val@last}
    <tr>
      <td></td>
      <td></td>
      <td><div style="font-weight: bold;">Всего: {$VarTotal|number_format:"0":"":" "}</div></td>
      <td></td>
      <td><div style="font-weight: bold;">Всего: {$VarTotally|number_format:"0":"":" "}</div></td>
    </tr>
  </tbody>
</table>
  {/if}
{/foreach}