<script type="text/javascript" src="modules/EcmReports/javascript/mzVatPurchases.js"></script>
<link rel="stylesheet" type="text/css" href="modules/EcmReports/css/SearchTable.css"/>
<script src="include/jQuery/tablesorter/jquery.tablesorter.min.js"></script>
<link class="theme" rel="stylesheet" href="include/jQuery/tablesorter/themes/blue/style.css">

<table id="tableMenu" cellspacing="0" cellpadding="0" border="0">
    <tbody>
    <tr>
        <td>
            <img src="themes/Sugar/images/EcmProducts.gif" style="margin-top: 3px; margin-right: 3px;" width="16" border="0" height="16">
        </td>
        <td>
            <h2 id="raport_name">Raport ilościowy zakupu</h2>
        </td>
    </tr>
</table>
<form action="index.php" method="get" name="ReportSalesByProduct">
    <input type="hidden" name="module" value="EcmReports" />
    <input type="hidden" name="action" value="mzVatPurchases"/>
    <input type="hidden" name="parentTab" value="Raporty" />
    <table style="width:100%" class="edit view" id="SearchTable">
        <tbody>
        <tr>
            <td>
                {$MOD.LBL_DATE_FROM}:
                <input id="date_from" name="date_from" type="text" maxlength="10" size="11" title="{$MOD.LBL_DATE_FROM}" value="{$date_from_value}">
                <img id="date_from_trigger" src="themes/default/images/jscalendar.gif">
            </td>
            <td rowspan='2'>
                <table>
                    <tr>
                        <td>
                            Grupa:
                        </td>
                        <td>
                            <select multiple name="product_group[]" title="{$MOD.TIP_MULTIPLE}" size="6">

                                {foreach from=$APP_LIST_STRINGS.ecmproducts_group_ks_dom key="key" item="item"}
                                    <option
                                            value="{$key}"
                                            {if @in_array($key, $PRODUCT_GROUP_SELECTED) } selected="true" {/if}>
                                        {$item}
                                    </option>
                                {/foreach}
                            </select>
                        </td>
                    </tr>
                </table>
            </td>
            <td rowspan='2'>
                <table>
                    <tr>
                        <td>
                         Grupa 2:
                        </td>
                        <td>
                            <select multiple name="product_group_2[]" title="{$MOD.TIP_MULTIPLE}" size="6">

                                {foreach from=$APP_LIST_STRINGS.ecmproducts_group2_ks_dom key="key" item="item"}
                                    <option
                                            value="{$key}"
                                            {if @in_array($key, $PRODUCT_GROUP_SELECTED_2) } selected="true" {/if}>
                                        {$item}
                                    </option>
                                {/foreach}
                            </select>
                        </td>
                    </tr>
                </table>
            </td>
            <td rowspan='2'>
                <table>
                    <tr>
                        <td>
                            {$MOD.LBL_STOCK}:
                        </td>
                        <td>
                            <select multiple name="stocks[]" title="{$MOD.TIP_MULTIPLE}" size="6">
                                {foreach from=$STOCK_LIST key="key" item="item"}
                                    <option
                                            value="{$key}"
                                            {if @in_array($key, $STOCK_SELECTED) } selected="true" {/if}>
                                        {$item}
                                    </option>
                                {/foreach}
                            </select>
                        </td>
                    </tr>
                </table>
                <br>
                <p>
                    Kategoria produktu:
                    <input type="hidden" id="product_category_id" name="product_category_id" value="{$PRODUCT_CATEGORY_ID}">
                    <input type="text" id="product_category_name" name="product_category_name" value="{$PRODUCT_CATEGORY_NAME}">
                    <button
                            type="button"
                            id="selectProduct"
                            value="{$APP.LBL_ADD_BUTTON}"
                            title="{$MOD.TIP_CHOOSE_ACCOUNT}">
                        <img src="{sugar_getimagepath file="id-ff-select.png"}">
                    </button>
                    <button
                            type="button"
                            id="clearProduct"
                            value="{$MOD.LBL_CLEAR}"
                            title="{$MOD.LBL_CLEAR}">
                        <img src="{sugar_getimagepath file='id-ff-clear.png'}">
                    </button>
                </p>
            </td>
            <td rowspan='2'>
                <table>
                    <tr>
                        <td>
                            Typ:
                        </td>
                        <td>
                            <select multiple name="account_type[]" title="{$MOD.TIP_MULTIPLE}" size="6">
                                {foreach from=$ACCOUNT_LIST key="key" item="item"}
                                    <option
                                            value="{$key}"
                                            {if @in_array($key, $ACCOUNT_SELECTED) } selected="true" {/if}>
                                        {$item}
                                    </option>
                                {/foreach}
                            </select>
                        </td>
                    </tr>
                </table>
            </td>
            <td rowspan='2'>
                <p>
                    Handlowiec:
                    {html_options id=trader name=trader[] multiple=true options=$TRADERS_LIST selected=$TRADER_SELECTED}

                </p><br>
                <p>
                    {$MOD.LBL_CONTRACTOR}:
                    <input type="hidden" id="account_id" name="account_id" value="{$ACCOUNT_ID}">
                    <input type="text" id="account_name" name="account_name" value="{$ACCOUNT_NAME}">
                    <button
                            type="button"
                            id="selectAccount"
                            value="{$APP.LBL_ADD_BUTTON}"
                            title="{$MOD.TIP_CHOOSE_ACCOUNT}">
                        <img src="{sugar_getimagepath file="id-ff-select.png"}">
                    </button>
                    <button
                            type="button"
                            id="clearAccount"
                            value="{$MOD.LBL_CLEAR}"
                            title="{$MOD.LBL_CLEAR}">
                        <img src="{sugar_getimagepath file='id-ff-clear.png'}">
                    </button>
                </p>
            </td>
        </tr>
        <tr>
            <td>	{$MOD.LBL_DATE_TO}:
                <input id="date_to" name="date_to" type="text" maxlength="10" size="11" title="{$MOD.LBL_DATE_TO}" value="{$date_to_value}">
                <img id="date_to_trigger" src="themes/default/images/jscalendar.gif">
            </td>
        </tr>
        </tbody>
    </table>
    <input class="button" name="submit" value="{$MOD.LBL_EXECUTE}" type="submit">
    <input class="button" name="clear" value="{$MOD.LBL_CLEAR}" type="button" onclick="location.href='index.php?module=EcmReports&action=mzVatPurchases';">
    <input id="pdf" class="button" name="pdf" value="PDF" type="button" onclick="generatePDF()">
    <!--     <input id="pdf" class="button" name="pdf" value="XLS" type="button" onclick="generateXLS()"> -->
</form>

<table id="myTable" class="tablesorter">
    <thead>
    <tr>
        <th class='sortby'>
            Indeks
        </th>
        <th class='sortby'>
            {$MOD.LBL_NAME}
        </th>
        <th width="10%" class='sortby'>
            {$MOD.LBL_QUANTITY}
        </th>
        <th width="5%" class='sortby'>
            {$MOD.LBL_JM}
        </th>
        <th width="10%" class='sortby'>
            Zakup Netto
        </th>
        <th width="10%" class='sortby'>
				Waga jedn. netto
			</th>
			<th width="10%" class='sortby'>
				Waga ogółem netto
			</th>
    </tr>
    </thead>
    <tbody>
    {foreach from=$DATA item=item key=item_name}
        {if $item.quantity eq 0}
        {else}

            <tr>
                <td >
                    {$item.code}
                </td>
                <td >
                    {$item.name}
                </td>
                <td class="quantity" style="text-align:right;">
                    {$item.quantity|number_format:2:",":""}
                </td>
                <td>
                    {$item.jm_name}
                </td>
                <td class="money" style="text-align:right;">
                    {$item.total_netto|number_format:2:",":"."}

                </td>
                <td class="" style="text-align:right;">
                    {$item.position_weight|number_format:6:",":""}
			</td>
			<td class="" style="text-align:right;">
                {$item.position_total_weight|number_format:6:",":""}
			</td>
            </tr>
        {/if}
    {/foreach}
    </tbody>
    <tfoot>
    <tr>
        <td colspan="2">
            {$MOD.LBL_SUMMARY}
        </td>
        <td colspan="1" class="money" style="text-align:right;">
            {$TOTAL3|number_format:2:",":""}
        </td>
        <td colspan="1">

        </td>
        <td class="money" style="text-align:right;">
            {$TOTAL|number_format:6:",":"."}
        </td>
        <td class="money">

			</td>
			<td class="money" style="text-align:right;">
                {$TOTAL4|number_format:6:",":""}
			</td>
    </tr>
    </tfoot>
</table>
