@model RadarWebDotNet.MVC.Areas.Comercial.ViewModels.PedidoViewModel
@{
    ViewBag.Title = "Pedido";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

<script>
    var a = @Html.Raw(Json.Encode(Model))
</script>

<ul class="breadcrumb" style="margin-bottom: 0">
    <li>Comercial<span class="divider">/</span></li>
    <li>Movimentos<span class="divider">/</span></li>
    <li class="active">Pedido</li>
    <div class="help-navbar-container">
        <a href="#" role="button" data-toggle="modal"  class="radar-help help-navbar-link" data-help="RadarWEB.htm" data-title="Tela Inicial - Pedidos - Movimentos"><i class="sprite-help-blue"></i></a>        
    </div>
</ul>
 
<br />

<div id="divErrors"  style="width: inherit;">
</div>

<ul id="myTab" class="nav nav-tabs" style="margin-bottom: 0">
    <li id="tabPrincipal" class="active"><a href="#principal" data-toggle="tab">Principal</a></li>
    <li id="tabItens" class=""><a href="#itens" data-toggle="tab">Itens</a></li>
    <li id="tabFaturamento" class=""><a href="#faturamento" data-toggle="tab">Faturamento</a></li>
    <li id="tabTransporte" class=""><a href="#transporte" data-toggle="tab">Transporte</a></li>
</ul>

<div class="form-horizontal">
    <div class="row row-fluid central">
        <div>
            <div id="cadastroCliente" class="tab-content">
                <!-- Aba Principal -->
                <div class="tab-pane fade  active in" id="principal">
                    <fieldset class="radar-nav-field">
                        <legend></legend>
                        <a href="#" role="button" data-toggle="modal" style="float: right" class="radar-help " data-help="RadarWEB.htm"  data-title="Pedido Aba Principal" hidden="hidden"><i class="sprite-help-blue help-aba-pedido"></i></a>
                        <div style="padding-top: 15px">
                            <div class="radar-row">
                                @{
                                    //if (Model.IsAlteracao)
                                    //{
                                    <div class="radar-control" id="controlNumeroPedido">
                                        <div class="control-group">
                                            <label class="control-label" style="width: 70px; text-align: left; white-space: nowrap;" for="fieldCodigoProprio">Nr. Pedido: </label>
                                            <div class="controls" style="float: left">
                                                @Html.TextBoxFor(m => m.Codigo, new {type = "text", id = "fieldCodigoProprio", maxlength = "11", style = "width: 85px; ", disabled = "disabled", @float = "left", })
                                                <span class="help-inline"></span>
                                            </div>
                                        </div>
                                    </div>
                                    //}
                                }
                                <div class="radar-control">
                                    <div class="control-group">
                                        <label class="control-label" style="width: 57px; text-align: left; white-space: nowrap;" for="inputDataEmissao">Emissão: </label>
                                        <div class="controls" style="float: left">
                                            @Html.TextBoxFor(m => m.DataEmissao, new {type = "text", id = "inputDataEmissao", maxlength = "10", style = "width: 80px;  font-family: sans-serif", datapermission = false})
                                            <span class="help-inline"></span>
                                        </div>
                                    </div>
                                </div>
                                <div class="radar-control">
                                    <div class="control-group">
                                        <label class="control-label" style="width: 33px; text-align: left; white-space: nowrap;" for="fieldCodigoFilial">Filial: </label>
                                        <div class="controls" style="float: left">
                                            @{
                                                if (Model.HabilitarFilial)
                                                {
                                                    @Html.TextBoxFor(m => m.CodigoFilial, new { id = "inputCodigoFilial", maxlength = "4", style = "width: 35px; " })
                                                    <a id="linkButtonModalFiliais" href="#modalFilial" role="button" data-toggle="modal" ><i class="icon-search"></i></a>                                                
                                                }
                                                else
                                                {
                                                    @Html.TextBoxFor(m => m.CodigoFilial, new { id = "inputCodigoFilial", maxlength = "4", style = "width: 35px; ", disabled = "disabled" })
                                                    <a id="linkButtonModalFiliais" href="#modalFilial" role="button" data-toggle="modal" hidden="hidden"><i class="icon-search"></i></a>                                                
                                                }
                                            }
                                            <span id="descriptionCodigoFilial" class="help-inline">@Model.DescricaoFilial</span>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div>
                            <div class="radar-row">
                                <div class="radar-control">
                                    <div class="control-group">
                                        <label class="control-label" style="width: 98px; text-align: left; white-space: nowrap;" for="fieldNomeRepresentante">Representante: </label>
                                        <div class="controls" style="float: left">
                                            <span id="fieldNomeRepresentante" class="help-inline">@Model.NomeRepresentante</span>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <fieldset>
                            <legend>Cliente</legend>
                            <div>
                                <div class="radar-row">
                                    <div class="radar-control">
                                        <div class="control-group">
                                            <label class="control-label" style="width: 114px; text-align: left; white-space: nowrap;" for="inputCodigoCliente">Cliente: </label>
                                            <div class="controls" style="float: left">
                                                @Html.TextBoxFor(m => m.CodigoCliente, new { type = "text", id = "inputCodigoCliente", maxlength = "14", style = "width: 115px; " })
                                                <a id="linkButtonModalClientes" href="#modalCliente" role="button" data-toggle="modal"><i class="icon-search"></i></a>
                                                <span id="descriptionCodigoCliente" class="help-inline">@Model.DescricaoCliente</span>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="radar-control">
                                        <div class="control-group">
                                            <label class="control-label" for="inputCep">CEP: </label>
                                            <div class="controls" style="float: left">
                                                @Html.TextBoxFor(m => m.CepCliente, new { id = "inputCep", type = "text", style = "width: 75px; ", disabled = "disabled" })
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div>
                                <div class="radar-row">
                                    <div class="radar-control">
                                        <div class="control-group">
                                            <label class="control-label" style="width: 114px; text-align: left; white-space: nowrap;" for="inputCodigoMunicipio">Município: </label>
                                            <div class="controls" style="float: left">
                                                @Html.TextBoxFor(m => m.CodigoMunicipio, new { type = "text", id = "inputCodigoMunicipio", maxlength = "8", style = "width: 65px; " })
                                                <a id="linkButtonModalMunicipios" href="#modalMunicipio" role="button" data-toggle="modal"><i class="icon-search"></i></a>
                                                <span id="descriptionCodigoMunicipio" class="help-inline">@Model.DescricaoMunicipio</span>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="radar-control">
                                        <div class="control-group">
                                            <label class="control-label" for="inputUf">UF: </label>
                                            <div class="controls" style="float: left">
                                                @Html.TextBoxFor(m => m.DescricaoUf, new { type = "text", id = "inputUf", maxlength = "2", style = "width: 18px; ", disabled = "disabled" })
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div>
                                <div class="radar-row">
                                    <div class="radar-control">
                                        <div class="control-group">
                                            <label class="control-label" style="width: 114px; text-align: left; white-space: nowrap;" for="inputLocalEntrega">Local de Entrega: </label>
                                            <div class="controls" style="float: left">
                                                @Html.TextBoxFor(m => m.LocalEntrega, new { type = "text", id = "inputLocalEntrega", maxlength = "90", style = "width: 400px; " })
                                            </div>
                                        </div>
                                    </div>
                                    <div class="radar-control">
                                        <div class="control-group">
                                            <label class="control-label" style="width: 57px; text-align: left; white-space: nowrap;" for="inputPrincipalDataEntrega">Entrega: </label>
                                            <div class="controls" style="float: left">
                                                @Html.TextBoxFor(m => m.DataEntrega, new { type = "text", id = "inputPrincipalDataEntrega", maxlength = "10", style = "width: 80px;  font-family: sans-serif" })
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </fieldset>
                        <div>
                            <div class="radar-row">
                                <div class="radar-control">
                                    <div class="control-group">
                                        <label class="control-label" style="width: 97px; text-align: left; white-space: nowrap;" for="inputCodigoOpComercial">Op Comerciais: </label>
                                        <div class="controls" style="float: left">
                                            @Html.TextBoxFor(m => m.CodigoOpComercial, new { type = "text", id = "inputCodigoOpComercial", maxlength = "20", style = "width: 160px;" })
                                            <a id="linkButtonModalOperacoesComerciais" href="#modalOpComercial" role="button" data-toggle="modal"><i class="icon-search"></i></a>
                                            <span id="descriptionCodigoOpComercial" class="help-inline">@Model.DescricaoOpComercial</span>
                                        </div>
                                    </div>
                                </div>
                                <div class="radar-control">
                                    <div class="control-group">
                                        <label class="control-label" for="inputCodigoCfop"  style="text-align: left; white-space: nowrap;" >CFOP: </label>
                                        <div class="controls" style="float: left">
                                            @{
                                                if (Model.HabilitarCfop)
                                                {
                                                    @Html.TextBoxFor(m => m.CodigoCfop, new { type = "text", id = "inputCodigoCfop", maxlength = "8", style = "width: 64px;", radarmask = "radar-cfop", @class = "masked", datapermission = Model.Permissoes.PodeAlteraCfop })
                                                    <a id="linkButtonModalCfops" href="#modalCfop" role="button" data-toggle="modal" datapermission="@Model.Permissoes.PodeAlteraCfop"><i class="icon-search"></i></a>
                                                }
                                                else
                                                {
                                                    @Html.TextBoxFor(m => m.CodigoCfop, new { type = "text", id = "inputCodigoCfop", maxlength = "8", style = "width: 64px;", radarmask = "radar-cfop", @class = "masked", disabled = "disabled", datapermission = Model.Permissoes.PodeAlteraCfop })
                                                    <a id="linkButtonModalCfops" href="#modalCfop" role="button" data-toggle="modal" disable="disable" datapermission="@Model.Permissoes.PodeAlteraCfop"><i class="icon-search"></i></a>
                                                }
                                                <span id="descriptionCodigoCfop" class="help-inline">@Model.DescricaoCfop</span>
                                            }
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div>
                            <div class="radar-row">
                                <div class="radar-control">
                                    <div class="control-group">
                                        <label class="control-label" style="width: 97px; text-align: left; white-space: nowrap;" for="fieldNumeroOrdemCompraCliente">Nr. OC Cliente: </label>
                                        <div class="controls" style="float: left">
                                            @Html.TextBoxFor(m => m.NumeroOrdemCompraCliente, new { type = "text", id = "fieldNumeroOrdemCompraCliente", maxlength = "15", style = "width: 300px; " })
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div>
                            <div class="radar-row">
                                <div class="radar-control">
                                    <div class="control-group">
                                        <label class="control-label" style="width: 97px; text-align: left; white-space: nowrap;" for="fieldObservacoes">Observações:</label>
                                        <div class="controls" style="float: left">
                                            @Html.TextAreaFor(m => m.Observacoes, new { id = "fieldObservacoes", maxlength = "2000", style = "width: 600px" })
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </fieldset>
                </div>
                <!-- Aba Itens -->
                <div class="tab-pane fade" id="itens">
                    <fieldset class="radar-nav-field" style="padding-bottom: 0; margin-bottom: 15px;">
                        <a href="#" role="button" data-toggle="modal" style="float: right" class="radar-help" data-help="RadarWEB.htm"  data-title="Pedido Aba Itens" hidden="hidden"><i class="sprite-help-blue  help-aba-pedido"></i></a>
                        <legend></legend>
                        <input type="hidden" id="fieldItemSequencial" />
                        <div style="padding-top: 15px">
                            <div class="radar-row">
                                <div class="radar-control">
                                    <div class="control-group">
                                        <label class="control-label" style="width: 81px; text-align: left; white-space: nowrap;" for="inputCodigoTabelaPrecos">Tab. Preços: </label>
                                        <div class="controls" style="float: left">
                                            @Html.TextBoxFor(m => m.CodigoTabelaPrecoProduto, new { id = "inputCodigoTabelaPrecos", maxlength = "10", style = "width: 25px", datapermission = Model.Permissoes.PodeAlterarTabelaPrecosPadrao })
                                            <a id="linkButtonModalTabelaPrecos" href="#modalTabPrecosProduto" role="button" data-toggle="modal" datapermission="@Model.Permissoes.PodeAlterarTabelaPrecosPadrao"><i class="icon-search"></i></a>
                                            <span id="descriptionCodigoTabelaPrecos" class="help-inline">@Model.DescricaoTabelaPrecoProduto</span>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div>
                            <div>
                                <fieldset style="padding: 0; border: none; margin-top: 40px; margin-bottom: 0px">
                                    <legend></legend>
                                    <div id="gridItens" style="height: 180px">
                                    </div>
                                </fieldset>
                            </div>
                            <div class="row row-fluid central">
                                <div class="span12">
                                    <fieldset>
                                        <legend>Produto</legend>
                                        <div>
                                            <div class="radar-row">
                                                <div class="radar-control">
                                                    <div class="control-group">
                                                        <label class="control-label" style="width: 91px; text-align: left; white-space: nowrap;" for="inputCodigoProduto">Código: </label>
                                                        <div class="controls" style="float: left">
                                                            <input type="text" id="inputCodigoProduto" maxlength="60" style="width: 100px;">
                                                            <input type="text" id="inputCodigoGrade1" maxlength="5" style="width: 30px;" disabled>
                                                            <input type="text" id="inputCodigoGrade2" maxlength="5" style="width: 30px;" disabled>
                                                            <input type="text" id="inputCodigoGrade3" maxlength="5" style="width: 30px;" disabled>
                                                            <a id="linkButtonModalProdutos" href="#modalProdutos" role="button" data-toggle="modal"><i class="icon-search"></i></a>
                                                            <a id="linkButtonModalGrade1" href="#modalGrade1" role="button" data-toggle="modal" hidden><i class="icon-search"></i></a>
                                                            <a id="linkButtonModalGrade2" href="#modalGrade2" role="button" data-toggle="modal" hidden><i class="icon-search"></i></a>
                                                            <a id="linkButtonModalGrade3" href="#modalGrade3" role="button" data-toggle="modal" hidden><i class="icon-search"></i></a>
                                                            <span id="descriptionCodigoProduto" class="help-inline"></span>
                                                            <span id="descriptionCodigoGrade1" class="help-inline"></span>
                                                            <span id="descriptionCodigoGrade2" class="help-inline"></span>
                                                            <span id="descriptionCodigoGrade3" class="help-inline"></span>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                        <div>
                                            <div class="radar-row">
                                                <div class="radar-control">
                                                    <div class="control-group">
                                                        <label class="control-label" style="width: 91px; text-align: left; white-space: nowrap;" for="fieldItemComplemento">Complemento:</label>
                                                        <div class="controls" style="float: left">
                                                            <textarea id="fieldItemComplemento" maxlength="1000" style="width: 512px; height: 15px; margin-left: 5px; padding-top: 2px; padding-bottom: 2px; padding-left: 3px; padding-right: 3px; resize: none; overflow: hidden;"></textarea>
                                                            <a onclick="(document.getElementById('textAreaProdutoComplemento').value = document.getElementById('fieldItemComplemento').value)()" id="linkButtonF4Complemento" href="#modalProdutoComplemento" role="button" data-toggle="modal"><i class="icon-pencil"></i></a>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                        <div>
                                            <div class="radar-row">
                                                <div class="radar-control">
                                                    <div class="control-group">
                                                        <label class="control-label" style="width: 91px; text-align: left; white-space: nowrap;" for="inputQuantidade">Quantidade:</label>
                                                        <div class="controls" style="float: left">
                                                            <input type="text" id="inputQuantidade" style="width: 100px;" disabled="disabled" radarmask="radar-valor-8-4-R" class="masked">
                                                        </div>
                                                    </div>
                                                </div>
                                                <div class="radar-control">
                                                    <div class="control-group">
                                                        <label class="control-label" style="width: 91px; text-align: left; white-space: nowrap;" for="inputValorUnitario">Vlr. Unitário:</label>
                                                        <div class="controls" style="float: left">
                                                            <input type="text" id="inputValorUnitario" maxlength="25" style="width: 100px;" radarmask="radar-valor-16-2-R" class="masked" disabled="disabled" datapermission="@Model.Permissoes.PodeAlterarSugestaoValorUnitario">
                                                        </div>
                                                    </div>
                                                </div>
                                                <div class="radar-control">
                                                    <div class="control-group">
                                                        <label class="control-label" style="width: 91px; text-align: left; white-space: nowrap;" for="inputDescontoUnitario">Desc. Unitário:</label>
                                                        <div class="controls" style="float: left">
                                                            <input type="text" id="inputDescontoUnitario" maxlength="13" style="width: 100px;" radarmask="radar-valor-16-2-R" class="masked" disabled="disabled" datapermission="@Model.Permissoes.PodeConcederDescontoItens">
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                        <div>
                                            <div class="radar-row">
                                                <div class="radar-control">
                                                    <div class="control-group">
                                                        <label class="control-label" style="width: 91px; text-align: left; white-space: nowrap;" for="inputValorAliquotaIcms">Alíq. ICMS:</label>
                                                        <div class="controls" style="float: left">
                                                            <div class="input-append">
                                                                <input type="text" id="inputValorAliquotaIcms" maxlength="5" style="width: 73px;" radarmask="radar-valor-2-2-R" class="masked" datapermission="@Model.Permissoes.PodeAlterarSugestoesTributariasRW">
                                                                <span class="add-on" style="height:  11px; line-height: 15px">%</span>
                                                            </div>
                                                        </div>
                                                    </div>
                                                </div>
                                                <div class="radar-control">
                                                    <div class="control-group">
                                                        <label class="control-label" style="width: 91px; text-align: left; white-space: nowrap;" for="inputValorAliquotaIpi">Alíq. IPI:</label>
                                                        <div class="controls" style="float: left">
                                                            <div class="input-append">
                                                                <input type="text" id="inputValorAliquotaIpi" maxlength="5" style="width: 73px;" radarmask="radar-valor-2-2-R" class="masked" datapermission="@Model.Permissoes.PodeAlterarSugestoesTributariasRW">
                                                                <span class="add-on" style="height:  11px; line-height: 15px">%</span>
                                                            </div>
                                                        </div>
                                                    </div>
                                                </div>
                                                <div class="radar-control">
                                                    <div class="control-group">
                                                        <label class="control-label" style="width: 91px; text-align: left; white-space: nowrap;" for="inputValorAliquotaIcmsSt">Alíq. ICMS/ST:</label>
                                                        <div class="controls" style="float: left">
                                                            <div class="input-append">
                                                                <input type="text" id="inputValorAliquotaIcmsSt" maxlength="5" style="width: 73px;" radarmask="radar-valor-2-2-R" class="masked" datapermission="@Model.Permissoes.PodeAlterarSugestoesTributariasRW">
                                                                <span class="add-on" style="height:  11px; line-height: 15px">%</span>
                                                            </div>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                        <div>
                                            <div class="radar-row">
                                                <div class="radar-control">
                                                    <div class="control-group">
                                                        <label class="control-label" style="width: 91px; text-align: left; white-space: nowrap;" for="inputNumeroOc">Núm. OC:</label>
                                                        <div class="controls" style="float: left">
                                                            <input type="text" id="inputNumeroOc" maxlength="15" style="width: 100px;">
                                                        </div>
                                                    </div>
                                                </div>

                                                <div class="radar-control">
                                                    <div class="control-group">
                                                        <label class="control-label" style="width: 141px; text-align: left; white-space: nowrap;" for="inputItemPed">Item Ped.:</label>
                                                        <div class="controls" style="float: left">
                                                            <input type="text" id="inputItemPed" maxlength="6" style="width: 50px;">
                                                        </div>
                                                    </div>
                                                </div>

                                                <div class="radar-control">
                                                    <div class="control-group">
                                                        <label class="control-label" style="width: 91px; text-align: left; white-space: nowrap;" for="inputDataEntrega">Data Entrega:</label>
                                                        <div class="controls" style="float: left">
                                                            <input type="text" id="inputDataEntrega" maxlength="10" style="width: 100px;">
                                                        </div>
                                                    </div>
                                                </div>
                                                <div class="radar-control">
                                                    <div class="control-group">
                                                        <label class="control-label" for="inputLivreCobranca">Livre de Cobrança:</label>
                                                        <div class="controls" style="float: left">
                                                            @{
                                                                WriteLiteral("<input type='checkbox' id='inputLivreCobranca' datapermission='" + Model.Permissoes.PodeAtivarCheckLivreCobranca + "'>");    
                                                            }
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                        <input id="buttonAdicionarItem" type="button" value="Adicionar" class="btn btn-inverse btn-small" />
                                        <input id="buttonAlterarItem" type="button" value="Alterar" class="btn btn-inverse btn-small" disabled="disabled"/>
                                        <input id="buttonRemoverItem" type="button" value="Remover" class="btn btn-inverse btn-small" disabled="disabled" />
                                    </fieldset>
                                </div>
                            </div>
                        </div>
                    </fieldset>
                </div>
                <!-- Aba Faturamento -->
                <div class="tab-pane fade" id="faturamento">
                    <fieldset class="radar-nav-field">
                        <legend></legend>
                        <a href="#" role="button" data-toggle="modal" style="float: right" class="radar-help " data-help="RadarWEB.htm"  data-title="Pedido Aba Faturamento" hidden="hidden"><i class="sprite-help-blue  help-aba-pedido"></i></a>
                        <div style="padding-top: 15px">
                            <div class="radar-row">
                                <div class="radar-control">
                                    <div class="control-group">
                                        <label class="control-label" style="width: 97px; text-align: left; white-space: nowrap;" for="fieldValorTotalProdutos">Total Produtos:</label>
                                        <div class="controls" style="float: left">
                                            @Html.TextBoxFor(m => m.ValorTotalProdutos, new { type = "text", id = "fieldValorTotalProdutos", style = "width: 100px;", disabled = "disabled", radarmask = "radar-valor-12-2-R", @class = "masked"})
                                        </div>
                                    </div>
                                </div>
                                <div class="radar-control">
                                    <div class="control-group">
                                        <label class="control-label" style="width: 97px; text-align: left; white-space: nowrap;" for="fieldValorTotalDesconto">Desconto:</label>
                                        <div class="controls" style="float: left">
                                            @Html.TextBoxFor(m => m.ValorTotalDesconto, new { type = "text", id = "fieldValorTotalDesconto", style = "width: 100px; ", radarmask = "radar-valor-12-2-R", @class = "masked", datapermission=Model.Permissoes.PodeConcederDescontoTotais })
                                        </div>
                                    </div>
                                </div>
                                <div class="radar-control">
                                    <div class="control-group">
                                        <label class="control-label" style="width: 97px; text-align: left; white-space: nowrap;" for="fieldSelectTiposCobrancas">Tipo cobrança:</label>
                                        <div class="controls" style="float: left">
                                            @if (!Model.IsAlert)
                                            {
                                                <input type="text" id="fieldSelectTiposCobrancas" value="@Model.IdTipoCobranca"/>
                                            }
                                            else
                                            {
                                                <input type="text" id="fieldSelectTiposCobrancas" value="@Model.IdTipoCobranca" disabled="disabled"/>   
                                            }
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <fieldset>
                            <legend>Condições</legend>
                            <div>
                                <div class="radar-row">
                                    <div class="radar-control">
                                        <div class="control-group">
                                            <label class="control-label" style="width: 146px; text-align: left; white-space: nowrap;" for="fieldSelectCondicaoPagamento">Condição pagamento:</label>
                                            <div class="controls" style="float: left">
                                                @if (!Model.IsAlert && Model.Permissoes.PodeAlterarCondicaoPagamentoSugerida)
                                                {
                                                    <input type="text" id="fieldSelectCondicaoPagamento" value="@Model.IdCondicaoPagamento"/>
                                                }
                                                else
                                                {
                                                    <input type="text" id="fieldSelectCondicaoPagamento" value="@Model.IdCondicaoPagamento" disabled="disabled"/>   
                                                }
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <fieldset style="padding: 0; border: none; margin-top: 30px">
                                <legend></legend>
                                <div style="padding-top: 15px">
                                    <div id="gridParcelas" style="height: 170px">
                                    </div>
                                </div>
                            </fieldset>
                            <div>
                                <div class="radar-row">
                                    <div class="radar-control">
                                        <div class="control-group">
                                            <label class="control-label" style="width: 74px; text-align: left; white-space: nowrap;" for="inputFaturamentoParcela">Parcela:</label>
                                            <div class="controls" style="float: left">
                                                <input type="text" id="inputFaturamentoParcela" maxlength="3" style="width: 25px;" disabled="disabled">
                                            </div>
                                        </div>
                                    </div>
                                    <div class="radar-control">
                                        <div class="control-group">
                                            <label class="control-label" style="width: 74px; text-align: left; white-space: nowrap;" for="inputDataVencimento">Vencimento:</label>
                                            <div class="controls" style="float: left">
                                                <input type="text" id="inputDataVencimento" style="width: 100px;">
                                            </div>
                                        </div>
                                    </div>
                                    <div class="radar-control">
                                        <div class="control-group">
                                            <label class="control-label" style="text-align: left; white-space: nowrap;" for="inputFaturamentoValor">Valor:</label>
                                            <div class="controls" style="float: left">
                                                <input type="text" id="inputFaturamentoValor" maxlength="17" style="width: 135px;" radarmask="radar-valor-10-2-R" class="masked">
                                            </div>
                                        </div>
                                    </div>
                                    <div class="radar-control hide" id="idFaturamentoValorAcrescimoOuDesconto">
                                        <div class="control-group">
                                            <label id="labelFaturamentoValorAcrescimoOuDesconto" class="control-label" style="text-align: left; white-space: nowrap;"></label>
                                            <div class="controls" style="float: left">
                                                <input type="text" id="inputFaturamentoValorAcrescimoOuDesconto" maxlength="17" style="width: 135px;" radarmask="radar-valor-10-2-R" class="masked" disabled>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div>
                                <div class="radar-row">
                                    <div class="radar-control">
                                        <div class="control-group">
                                            <label class="control-label" style="width: 80px; text-align: left; white-space: nowrap;" for="selectFormaPagamento">Forma Pgto:</label>
                                            <div class="controls" style="float: left">
                                                @if (!Model.IsAlert)
                                                {
                                                    <input id="selectFormaPagamento" type="text" value="0" disabled="disabled"/> 
                                                }
                                            </div>
                                        </div>
                                    </div>
                                    <div class="radar-control">
                                        <div class="control-group">
                                            <label class="control-label" style="width: 30px; text-align: left; white-space: nowrap;" for="fieldObservacao" style="padding-right: 48px">Obs:</label>
                                            <div class="controls" style="float: left">
                                                <input type="text" id="inputObservacao" maxlength="50" style="width: 471px;">
                                            </div>
                                        </div>
                                    </div>
                                </div>
                                <div class="radar-row">
                                    <div class="radar-control">
                                        <div class="control-group">
                                            <input id="buttonAlteraParcela" type="button" value="Alterar" class="btn btn-inverse btn-small" disabled="disabled"/>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </fieldset>
                        <div>
                            <div class="radar-row">
                                <div class="radar-control">
                                    <div class="control-group">
                                        <label class="control-label" for="fieldValorTotalIpi">Valor Total IPI:</label>
                                        <div class="controls" style="float: left">
                                            @Html.TextBoxFor(m => m.ValorTotalIpi, new { type = "text", id = "fieldValorTotalIpi", maxlength = "13", style = "width: 105px; ", radarmask = "radar-valor-10-2-R", @class = "masked", disabled = "disabled" })
                                        </div>
                                    </div>
                                </div>
                                <div class="radar-control">
                                    <div class="control-group">
                                        <label class="control-label" for="fieldValorTotalAPagar">Valor Total à Pagar:</label>
                                        <div class="controls" style="float: left">
                                            @Html.TextBoxFor(m => m.ValorTotalAPagar, new { type = "text", id = "fieldValorTotalAPagar", style = "width: 100px; ", radarmask = "radar-valor-12-2-R", @class = "masked", disabled = "disabled" })
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>

                    </fieldset>
                </div>
                <!-- Aba Transporte -->
                <div class="tab-pane fade" id="transporte">
                    <fieldset class="radar-nav-field">
                        <legend></legend>
                        <a href="#" role="button" data-toggle="modal" style="float: right" class="radar-help  " data-help="RadarWEB.htm"  data-title="Pedido Aba Transporte" hidden="hidden"><i class="sprite-help-blue help-aba-pedido"></i></a>
                        <fieldset>
                            <legend>Dados do Transporte</legend>
                            <div>
                                <div class="radar-row">
                                    <div class="radar-control">
                                        <div class="control-group">
                                            <label class="control-label" style="width: 110px; text-align: left; white-space: nowrap;" for="fieldSelectQuemTransporta">Frete por Conta:</label>
                                            <div class="controls" style="float: left">
                                                @if (!Model.IsAlert)
                                                {
                                                    <input type="text" id="fieldSelectQuemTransporta" value="@Model.QuemTransporta.GetHashCode()"/>
                                                }
                                                else
                                                {
                                                    <input type="text" id="fieldSelectQuemTransporta" value="@Model.QuemTransporta.GetHashCode()" disabled="disabled"/>   
                                                }
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div>
                                <div class="radar-row">
                                    <div class="radar-control">
                                        <div class="control-group">
                                            <label class="control-label" style="width: 105px; text-align: left; white-space: nowrap;" for="inputCodigoTransportadora">Transportadora:</label>
                                            <div class="controls" style="float: left">
                                                @Html.TextBoxFor(m => m.CodigoTransportadora, new { type = "text", id = "inputCodigoTransportadora", maxlength = "10", style = "width: 80px; " })
                                                <a id="linkButtonModalTransportadora" href="#modalTransportadora" role="button" data-toggle="modal"><i class="icon-search"></i></a>
                                                <span id="descriptionCodigoTransportadora" class="help-inline">@Model.DescricaoTransportadora</span>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div>
                                <div class="radar-row">
                                    <div class="radar-control">
                                        <div class="control-group">
                                            <label class="control-label" style="width: 110px; text-align: left; white-space: nowrap;" for="fieldSelectViaTransporte">Via Transporte:</label>
                                            <div class="controls" style="float: left">
                                                @if (!Model.IsAlert)
                                                {
                                                    <input type="text" id="fieldSelectViaTransporte" value="@Model.ViaTransporte.GetHashCode()"/>
                                                }
                                                else
                                                {
                                                    <input type="text" id="fieldSelectViaTransporte" value="@Model.ViaTransporte.GetHashCode()" disabled="disabled"/>
                                                }
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>

                        </fieldset>
                        <fieldset>
                            <legend>Redespacho</legend>
                            <div>
                                <div class="radar-row">
                                    <div class="radar-control">
                                        <div class="control-group">
                                            <label class="control-label" style="width: 105px; text-align: left; white-space: nowrap;" for="inputCodigoTransportadoraRedespacho">Transportadora:</label>
                                            <div class="controls" style="float: left">
                                                @Html.TextBoxFor(m => m.CodigoTransportadoraRedespacho, new { id = "inputCodigoTransportadoraRedespacho", type = "text", maxlength = "10", style = "width: 80px; " })
                                                <a id="linkButtonModalTransportadoraRedespacho" href="#modalTransportadoraRedespacho" role="button" data-toggle="modal"><i class="icon-search"></i></a>
                                                <span id="descriptionCodigoTransportadoraRedespacho" class="help-inline">@Model.DescricaoTransportadoraRedespacho</span>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </fieldset>
                        <fieldset>
                            <legend>Volumes</legend>
                            <div>
                                <div class="radar-row">
                                    <div class="radar-control">
                                        <div class="control-group">
                                            <label class="control-label" style="width: 148px; text-align: left; white-space: nowrap;" for="fieldQuantidadeTotalVolumes">Quantidade Total:</label>
                                            <div class="controls" style="float: left">
                                                @Html.TextBoxFor(m => m.QuantidadeTotalVolumes, new { type = "text", id = "fieldQuantidadeTotalVolumes", maxlength = "14", style = "width: 120px; ", radarmask = "radar-valor-14-0-R", @class="masked" })
                                            </div>
                                        </div>
                                    </div>
                                    <div class="radar-control">
                                        <div class="control-group">
                                            <label class="control-label" style="width: 148px; text-align: left; white-space: nowrap;" for="fieldEspecie">Espécie:</label>
                                            <div class="controls" style="float: left">
                                                @Html.TextBoxFor(m => m.Especie, new { type = "text", id = "fieldEspecie", maxlength = "60", style = "width: 120px; " })
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div>
                                <div class="radar-row">
                                    <div class="radar-control">
                                        <div class="control-group">
                                            <label class="control-label" style="width: 148px; text-align: left; white-space: nowrap;" for="fieldMarca">Marca:</label>
                                            <div class="controls" style="float: left">
                                                @Html.TextBoxFor(m => m.Marca, new { type = "text", id = "fieldMarca", maxlength = "60", style = "width: 120px; " })
                                            </div>
                                        </div>
                                    </div>
                                    <div class="radar-control">
                                        <div class="control-group">
                                            <label class="control-label" style="width: 148px; text-align: left; white-space: nowrap;" for="fieldNumeroInicial">Número Inicial:</label>
                                            <div class="controls" style="float: left">
                                                @Html.TextBoxFor(m => m.NumeroInicial, new { type = "text", id = "fieldNumeroInicial", maxlength = "20", style = "width: 120px; " })
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div>
                                <div class="radar-row">
                                    <div class="radar-control">
                                        <div class="control-group">
                                            <label class="control-label" style="width: 148px; text-align: left; white-space: nowrap;" for="fieldPesoBruto">Peso Bruto Total(kg):</label>
                                            <div class="controls" style="float: left">
                                                @Html.TextBoxFor(m => m.PesoBruto, new { type = "text", id = "fieldPesoBruto", maxlength = "19", style = "width: 120px; ", radarmask = "radar-valor-14-4-R", @class="masked" })

                                            </div>
                                        </div>
                                    </div>
                                    <div class="radar-control">
                                        <div class="control-group">
                                            <label class="control-label" style="width: 148px; text-align: left; white-space: nowrap;" for="fieldPesoLiquido">Peso Líquido Total(kg):</label>
                                            <div class="controls" style="float: left">
                                                @Html.TextBoxFor(m => m.PesoLiquido, new { type = "text", id = "fieldPesoLiquido", maxlength = "19", style = "width: 120px; " , radarmask = "radar-valor-14-4-R", @class="masked"})
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </fieldset>
                    </fieldset>
                </div>
            </div>

            @using (Html.BeginForm("ReportPdf", "Movimentos", FormMethod.Get, new { target = "_new"} ))
            {
                WriteLiteral("<input id='buttonSalvarPedido' type='button' value='OK' class='btn btn-inverse btn-small' style='width: 75px' datapermission='" + Model.Permissoes.PodeAlterarPedido + "'/>");
                <a id="linkButtonSalvarPedido" href="#dialogModal" role="button" data-toggle="modal" hidden="hidden"></a>            
                <a id="buttonCancelarAlteracaoPedido" href="#dialogModal" role="button" class="btn btn-inverse btn-small" style="width: 75px" data-toggle="modal">Cancelar</a>            
                <a id="buttonNovoPedido" href="#dialogModal" role="button" class="btn btn-inverse btn-small" style="width: 75px" data-toggle="modal">Novo Pedido</a>
                
                if (Model.IsAlteracao)
                {
                    <button id="buttonGeneratePdfPedido" class="btn btn-inverse btn-small" style="width: 80px" type="submit">Gerar PDF</button>
                }
                else
                {
                    <button id="buttonGeneratePdfPedido" class="btn btn-inverse btn-small" style="width: 80px" type="submit" disabled>Gerar PDF</button>
                }
            }
        </div>
    </div>
</div>

<div id="modalProdutoComplemento" class="modal hide fade" tabindex="-2" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-header">
        <button type='button' class='close' data-dismiss='modal' aria-hidden='true'>&times;</button>
        <h4>Complemento</h4>
    </div>
    <div class="modal-body">
        <div>
            <textarea id="textAreaProdutoComplemento" maxlength="1000" style="width: 95%; height: 290px"></textarea>
            <input onclick="(document.getElementById('fieldItemComplemento').value = document.getElementById('textAreaProdutoComplemento').value)()" type="button" value="OK" class="btn btn-inverse btn-small pull-right" style="width: 80px" data-dismiss="modal" aria-hidden="true">
        </div>
    </div>
</div>

<div id="modalDiv"></div>

<script type="text/javascript">
    $(document).ready(function () {
        var params = {
            User: @{ WriteLiteral(Json.Encode(Model.User)); },
            IsAlert : false,
            Message: "",
            PodeSerAlterado: true,
            Pedido: @{ WriteLiteral(Json.Encode(Model)); }
        };

        @if (Model.IsAlert)
        {
            WriteLiteral("\tparams.IsAlert = true;\r\n");
            WriteLiteral(string.Format("\tparams.Message = '{0}';\r\n", Model.Message.Replace("\r", "").Replace("\n", "")));
        }

        @if (!Model.PodeSerAlterado)
        {
            WriteLiteral("\tparams.PodeSerAlterado = false;\r\n"); 
        }

        Radar.Web.PedidoMain(params);
    });
</script>