<!-- BEGIN {$smarty.template} -->

{literal}
<script type="text/javascript">

function confirm_delete(quot_id)
{
if (window.confirm('{/literal}{t}Are you sure you want to delete this quotation?{/t} {$quotInfo.quot_number}/{$quotInfo.quot_date}  ({$quotInfo.quot_endsum|phpaga_formatamount} {$quotInfo.curr_name}){literal}')) {
location.href = 'quotation.php?id='+quot_id+'&action={/literal}{$smarty.const.ACTION_DELETE}{literal}';
}

}

    $(document).ready(function() {
        $("#tab_container").tabs();

        $("#quottoinv").dialog({
                autoOpen: false,
                modal: true,
                buttons: {
                    "{/literal}{t}Create invoice{/t}{literal}": function() {
                       $('#quot_to_bill').submit(); 
                        $(this).dialog( "close" );
                    },
                    Cancel: function() {
                        $(this).dialog( "close" );
                    }
                },
                close: function() {
                }
        });
        $('#quottoinv_btn').click(function() { $( "#quottoinv" ).dialog( "open" ); });

        $("#printbill").dialog({
                autoOpen: false,
                modal: true,
                buttons: {
                    "{/literal}{t}Open{/t}{literal}": function() {
                       $('#pdf_download').val('0');
                       $('#bill_print_form').submit(); 
                        $(this).dialog( "close" );
                    },
                    "{/literal}{t}Download{/t}{literal}": function() {
                       $('#pdf_download').val('1');
                       $('#bill_print_form').submit(); 
                        $(this).dialog( "close" );
                    },
                    Cancel: function() {
                        $(this).dialog( "close" );
                    }
                },
                close: function() {
                }
        });
        $('#export_pdf').click(function() { $( "#printbill" ).dialog( "open" ); });
    });
</script>
{/literal}

<div id="printbill" title="{t}PDF{/t}: {t}Quotation{/t} {$quotInfo.quot_number|wash}/{$quotInfo.quot_date|wash}">
    <form action="quotation_pdf.php" method="get" id="bill_print_form">
        <input type="hidden" name="id" value="{$quotInfo.quot_id}">
        <input type="hidden" name="download" value="0" id="pdf_download" />

        <h2>{t}Print options{/t}</h2>
        <input type="checkbox" class="cbox" name="letterhead" id="letterhead" value="1" {if $smarty.const.PHPAGA_PDF_PRINT_LETTERHEAD_DEFAULT}checked="checked"{/if}><label for="letterhead">{t}Print letterhead{/t}</label>
    </form>
</div>

<div id="quottoinv" title="{t}Quotation to invoice{/t}">
    <form action="add_bill.php" method="get" id="quot_to_bill">
        <input type="hidden" name="id" value="{$quotInfo.quot_id}">
        <input type="hidden" name="action" value="{$smarty.const.ACTION_FROMQUOTATION}">

        <label for="getquotnum">{t}Use the quotation number as invoice number?{/t}</label>
        <input type="checkbox" name="getquotnum" id="getquotnum" value="1">
    </form>
</div>

<h2>{t}Quotation{/t} {$quotInfo.quot_number|wash}/{$quotInfo.quot_date|wash}</h2>

<div class="actions">
    {if $perm_quotations}
    [ <a class="ptr" onclick="confirm_delete({$quotInfo.quot_id});">{t}Delete{/t}</a> |
    <a href="add_quotation.php?id={$quotInfo.quot_id}&amp;action={$smarty.const.ACTION_CLONE}">{t}Clone{/t}</a> |
    <a id="quottoinv_btn" href="#">{t}Create invoice{/t}</a> |
    <a href="add_project.php?id={$quotInfo.quot_id}&amp;action={$smarty.const.ACTION_FROMQUOTATION}">{t}Create project{/t}</a> |
    {/if}
    <a id="export_pdf" href="#">{t}Print to PDF{/t}</a> ]
</div>

<div id="tab_container">

    <ul class="tab_items">
        <li><a href="#quot-details">{t}Quotation{/t}</a></li>
    </ul>

    <div id="quot-details" class="tab_content">
        <div class="floatcontainer">
            <table class="detail flleft" cellspacing="0">

                <caption><em>{t}Quotation{/t} {$quotInfo.quot_number|wash}/{$quotInfo.quot_date|wash}</em>

                </caption>

                <tr>
                    <th>{t}Quotation nr.{/t}: </th>
                    <td> {$quotInfo.quot_number|wash} </td>
                    <th> {t}Quotation date{/t}: </th>
                    <td> {$quotInfo.quot_date|wash|date_format:$smarty.const.PHPAGA_DATEFORMAT_SHORT} </td>
                </tr>
                <tr>
                    <th> {t}Quotation type{/t}: </th>
                    <td> {$quotInfo.bmt_description|wash} </td>
                    <th> {t}Term of payment{/t}: </th>
                    <td> {$quotInfo.quot_payterm|wash|default:"&nbsp;"} </td>
                </tr>
                <tr>
                    <th>{t}Company{/t}: </th>
                    <td colspan="3">{$quotInfo.cpn_name|wash}</td>
                </tr>
                <tr>
                    <th> {t}Contact person{/t}: </th>
                    <td colspan="3"> {$quotInfo.quot_person_recipient|wash|default:"&nbsp;"} </td>
                </tr>
                <tr>
                    <th> {t}Additional information{/t}: </th>
                    <td colspan="3"> {$quotInfo.quot_additional_line|wash|default:"&nbsp;"} </td>
                </tr>
                <tr>
                    <th>{t}Details{/t}: </th>
                    <td colspan="3">
                        <table class="billdetailstable" cellspacing="0">
                            {section name=details loop=$quotInfo.quot_details}
                            <tr>
                                {if $quotInfo.quot_details[details].text eq ""}
                                <td class="btext">&nbsp;</td>
                                {else}
                                <td class="bdesc"> {$quotInfo.quot_details[details].text|wash} </td>
                                {/if}
                                {if $quotInfo.quot_details[details].amount eq ""}
                                <td class="bamount">&nbsp;</td>
                                {else}
                                <td class="bnumber"> {$quotInfo.quot_details[details].amount} </td>
                                {/if}
                            </tr>
                            {/section}
                        </table>
                    </td>
                </tr>
            </table>

            <table class="flleft" cellspacing="0">
                <caption><em>{t}Line items{/t}</em></caption>
                <thead>
                    <tr>
                        <th> {t}Product code{/t} </th>
                        <th> {t}Description{/t} </th>
                        <th class="time"> {t}Qty./Hours{/t} </th>
                        <th class="number"> {t}Net price{/t} </th>
                    </tr>
                </thead>
                <tbody>
                    {section name=lit loop=$quotInfo.lineitems}
                    <tr>
                        <td> {$quotInfo.lineitems[lit].lit_prodcode|default:"&nbsp;"} </td>
                        <td class="datawrap"> {$quotInfo.lineitems[lit].lit_desc|wash|nl2br|default:"&nbsp;"} </td>
                        <td class="time"> {$quotInfo.lineitems[lit].lit_qty|wash|default:"&nbsp;"} </td>
                        <td class="number lr"> {$config.MONETARY_SYMBOL}{$quotInfo.lineitems[lit].lit_netprice|wash|phpaga_formatamount|default:"&nbsp;"} </td>
                    </tr>
                    {/section}
                </tbody>
            </table>

        </div>
        <div class="spacer"></div>
    </div>
</div>

<!-- END {$smarty.template} -->
