            <div class="row">
				<h3 style="text-align:center">PEDIDO: <?php echo $id; ?></h3>
			</div>
			
			<form name="gradePedido" method="POST" action="" autocomplete="off" onload="soma()">

                <input type="hidden" id="ativo" name="ativo" value="1" />
                <input type="hidden" id="id_pedido" name="id_pedido" value="<?php echo $id_pedido; ?>" />
                <input type="hidden" id="dir" name="dir" value="1" />
                <input type="hidden" id="obs_grade" name="obs_grade" value="" />
               
                <div class="container">  
                <a href="#collapse1" data-toggle="collapse">detalhes do Pedido</a>
                <div id="collapse1" class="collapse">
                    <div class="row">    
                        <div class="form-group col-md-2">
                            <label for="dtcadastro">Cadastro Pedido</label>
                            <input type="date" class="form-control" name="dtcadastro" id="dtcadastro" value="<?php echo $row['dtcadastro'] ?>" readonly="readonly">
                        </div>

                        <div class="form-group col-md-1">
                            <label for="idpiloto">Lacre</label>
                            <input type="text" class="form-control" name="id_piloto" id="id_piloto" value="<?php echo $row['id_piloto'] ?>" readonly="readonly">
                        </div>

                        <div class="form-group col-md-2">
                            <label for="nr_pedido">Nr Pedido</label>
                            <input type="number" class="form-control" id="nr_pedido" name="nr_pedido" value="<?php echo $row['nr_pedido'] ?>" readonly="readonly">
                        </div>
                        
                        <div class="form-group col-md-3">
                            <label for="revista">Revista</label>
                            <input type="text" class="form-control" id="revista" name="revista" value="<?php echo $row['revista'] ?>" readonly="readonly">
                        </div>

                        <div class="form-group col-md-4">
                            <label for="popular_name">Cliente</label> 
                            <input type="text" class="form-control" id="popular_name" name="popular_name" value="<?php echo $row['popular_name'] ?>" readonly="readonly">
                        </div>
                    </div>
                    <div class="row">
                           
                        <div class="form-group col-md-2">
                            <label for="referencia">Referência</label>
                            <input type="text" class="form-control" id="referencia" name="referencia" value="<?php echo $row['referencia'] ?>" readonly="readonly">
                        </div>

                        <div class="form-group col-md-2">
                            <label for="descricao">Descrição</label>
                            <input type="text" class="form-control" id="descricao" name="descricao" value="<?php echo $row['descricao'] ?>" readonly="readonly">
                        </div>

                        <div class="form-group col-md-2">
                            <label for="modelo">Modelo</label>
                            <input type="text" class="form-control" id="modelo" name="modelo" value="<?php echo $row['modelo'] ?>" readonly="readonly">
                        </div>

                        <div class="form-group col-md-2">
                            <label for="modelagem">Modelagem</label>
                            <input type="text" class="form-control" id="modelagem" name="modelagem" value="<?php echo $row['modelagem'] ?>" readonly="readonly">
                        </div>

                        <div class="form-group col-md-4">
                            <label for="tecido">Tecido</label>
                            <input type="text" class="form-control" id="tecido" name="tecido" value="<?php echo $row['tecido'] ?>" readonly="readonly">
                        </div>
                                            
                    </div>

                    <div class="row">

                            <div class="form-group col-md-2">
                                <label for="data_pre">Data Pré</label>
                                <input type="date" class="form-control" id="data_pre" name="data_pre" value="<?php echo $row['data_pre'] ?>" readonly="readonly">
                            </div>                        
                        
                            <div class="form-group col-md-2">
                              <label for="dtpedido">Data do Pedido</label>
                                <input type="date" class="form-control" id="data_pedido" name="data_pedido" value="<?php echo $row['data_pedido'] ?>" readonly="readonly">                          
                            </div>
                            
                            <div class="form-group col-md-2">
                              <label for="dtentrega">Data da Entrega</label>
                                <input type="date" class="form-control" id="data_entrega" name="data_entrega" value="<?php echo $row['data_entrega'] ?>" readonly="readonly">                          
                            </div>
                            
                            <div class="form-group col-md-2">
                                <label for="qtd">Quantidade</label>
                                <input type="number" class="form-control" id="quantidade" name="quantidade" value="<?php echo $row['quantidade'] ?>" readonly="readonly">
                            </div>

         
                            <div class="form-group col-sm-4 control-label">
                                <label for="obs">Observações do PEDIDO</label>
                                <div class="">
                                    <textarea name="obs" class="form-control" rows="1" cols="48" readonly="readonly" ><?php echo $row['obsPed']?></textarea>
                                </div>
                            </div>
                    </div>

                </div>
                    <?php
                    $sql = "SELECT grade.*, companies.popular_name, pedidos.*, pedidos.obs AS obsPed FROM pedidos INNER JOIN companies on companies.id = pedidos.nr_company LEFT JOIN grade ON grade.id_pedido = pedidos.id WHERE grade.id_pedido = '$id' and grade.dir = '1'";
                    $resultado = $mysqli->query($sql);
                    $row = $resultado->fetch_array(MYSQLI_ASSOC);
                    ?>     
                    
                    <input type="hidden" id="ativo" name="ativo" value="1" />
                    <input type="hidden" id="id" name="id" value="<?php echo $id; ?>" />
                    <input type="hidden" id="dir" name="dir" value="1" />
                    <input type="hidden" id="obs_grade" name="obs_grade" value="" />
                
                    
                    <div class="table-responsive">  
                        <table id="gradePedidoz" class="table table-striped table-condensed table-bordered">  
                            <thead>  
                                <tr style="background-color: #d3d3d3" align="center">  
                                    <td width="10%">NOME</td>  
                                    <td>32</td>  
                                    <td>34</td>  
                                    <td>36</td>  
                                    <td>38</td>  
                                    <td>40</td>  
                                    <td>42</td>  
                                    <td>44</td>  
                                    <td>46</td>  
                                    <td>48</td>  
                                    <td>50</td>  
                                    <td>52</td>  
                                    <td>SUBTOTAL</td>  
                                </tr>  
                            </thead>  

                            <form name="gradePedido" method="POST" action="grade_update.php" autocomplete="off">
                            
                               <tr align="center" style="font-weight:bold">  
                                   <td width="10%">
                                   
                                        <input type="text" size ="15" width="1" maxlength="15" id="tituloc1" name="tituloc1" value="<?php echo $row['tituloc1'] ?>" style='text-transform:uppercase' required autofocus>  
                                   </td>  
                                   <td>  
                                        <input type="text" size ="3" width="1" maxlength="3"  style="text-align:center;" id="tdc1" name="tdc1" value="<?php echo $row['tdc1'] ?>" onkeypress='return SomenteNumero(event)' onBlur="soma()">  
                                   </td>  
                                   <td> 
                                        <input type="text" size ="3" width="1" maxlength="3" style="text-align:center;" id="tqc1" name="tqc1" value="<?php echo $row['tqc1'] ?>" onkeypress='return SomenteNumero(event)' onBlur="soma();">  
                                   </td>  
                                   <td>  
                                        <input type="text" size ="3" width="1" maxlength="3" style="text-align:center;" id="tsc1" name="tsc1" value="<?php echo $row['tsc1'] ?>" onkeypress='return SomenteNumero(event)' onBlur="soma();">  
                                   </td>  
                                   <td>  
                                        <input type="text" size ="3" width="1" maxlength="3" style="text-align:center;" id="toc1" name="toc1" value="<?php echo $row['toc1'] ?>" onkeypress='return SomenteNumero(event)' onBlur="soma();">
                                   </td>  
                                   <td>  
                                        <input type="text" size ="3" width="1" maxlength="3" style="text-align:center;" id="quc1" name="quc1" value="<?php echo $row['quc1'] ?>" onkeypress='return SomenteNumero(event)' onBlur="soma();">
                                   </td>  
                                   <td>  
                                        <input type="text" size ="3" width="1" maxlength="3" style="text-align:center;" id="qdc1" name="qdc1" value="<?php echo $row['qdc1'] ?>" onkeypress='return SomenteNumero(event)' onBlur="soma();">
                                   </td>  
                                   <td>  
                                        <input type="text" size ="3" width="1" maxlength="3" style="text-align:center;" id="qqc1" name="qqc1" value="<?php echo $row['qqc1'] ?>" onkeypress='return SomenteNumero(event)' onBlur="soma();">  
                                   </td>  
                                   <td>  
                                        <input type="text" size ="3" width="1" maxlength="3" style="text-align:center;" id="qsc1" name="qsc1" value="<?php echo $row['qsc1'] ?>" onkeypress='return SomenteNumero(event)' onBlur="soma();">  
                                   </td>  
                                   <td>  
                                        <input type="text" size ="3" width="1" maxlength="3" style="text-align:center;" id="qoc1" name="qoc1" value="<?php echo $row['qoc1'] ?>" onkeypress='return SomenteNumero(event)' onBlur="soma();">  
                                   </td>  
                                   <td>  
                                        <input type="text" size ="3" width="1" maxlength="3" style="text-align:center;" id="cic1" name="cic1" value="<?php echo $row['cic1'] ?>" onkeypress='return SomenteNumero(event)' onBlur="soma();">
                                   </td>  
                                   <td>  
                                        <input type="text" size ="3" width="1" maxlength="3" style="text-align:center;" id="cdc1" name="cdc1" value="<?php echo $row['cdc1'] ?>" onkeypress='return SomenteNumero(event)' onBlur="soma();">  
                                   </td>  
                                   <td>  
                                        <input type="text" size ="3" width="1" maxlength="3" style="text-align:center;" id="subtotalc1" name="subtotalc1" readonly="readonly">  
                                   </td>     
                               </tr>  
                               <tr align="center" style="font-weight:bold">  
                                   <td width="10%">
                                        <input type="text" size ="15" width="1" maxlength="15" style='text-transform:uppercase' value="<?php echo $row['tituloc2'] ?>" id="tituloc2" name="tituloc2">  
                                   </td>  
                                   <td>  
                                        <input type="text" size ="3" width="1" maxlength="3"  style="text-align:center;" id="tdc2" name="tdc2" value="<?php echo $row['tdc2'] ?>" onkeypress='return SomenteNumero(event)' onBlur="soma()">  
                                   </td>  
                                   <td> 
                                        <input type="text" size ="3" width="1" maxlength="3" style="text-align:center;" id="tqc2" name="tqc2" value="<?php echo $row['tqc2'] ?>" onkeypress='return SomenteNumero(event)' onBlur="soma();">  
                                   </td>  
                                   <td>  
                                        <input type="text" size ="3" width="1" maxlength="3" style="text-align:center;" id="tsc2" name="tsc2" value="<?php echo $row['tsc2'] ?>" onkeypress='return SomenteNumero(event)' onBlur="soma();">  
                                   </td>  
                                   <td>  
                                        <input type="text" size ="3" width="1" maxlength="3" style="text-align:center;" id="toc2" name="toc2" value="<?php echo $row['toc2'] ?>" onkeypress='return SomenteNumero(event)' onBlur="soma();">
                                   </td>  
                                   <td>  
                                        <input type="text" size ="3" width="1" maxlength="3" style="text-align:center;" id="quc2" name="quc2" value="<?php echo $row['quc2'] ?>" onkeypress='return SomenteNumero(event)' onBlur="soma();">
                                   </td>  
                                   <td>  
                                        <input type="text" size ="3" width="1" maxlength="3" style="text-align:center;" id="qdc2" name="qdc2" value="<?php echo $row['qdc2'] ?>" onkeypress='return SomenteNumero(event)' onBlur="soma();">
                                   </td>  
                                   <td>  
                                        <input type="text" size ="3" width="1" maxlength="3" style="text-align:center;" id="qqc2" name="qqc2" value="<?php echo $row['qqc2'] ?>" onkeypress='return SomenteNumero(event)' onBlur="soma();">  
                                   </td>  
                                   <td>  
                                        <input type="text" size ="3" width="1" maxlength="3" style="text-align:center;" id="qsc2" name="qsc2" value="<?php echo $row['qsc2'] ?>" onkeypress='return SomenteNumero(event)' onBlur="soma();">  
                                   </td>  
                                   <td>  
                                        <input type="text" size ="3" width="1" maxlength="3" style="text-align:center;" id="qoc2" name="qoc2" value="<?php echo $row['qoc2'] ?>" onkeypress='return SomenteNumero(event)' onBlur="soma();">  
                                   </td>  
                                   <td>  
                                        <input type="text" size ="3" width="1" maxlength="3" style="text-align:center;" id="cic2" name="cic2" value="<?php echo $row['cic2'] ?>" onkeypress='return SomenteNumero(event)' onBlur="soma();">
                                   </td>  
                                   <td>  
                                        <input type="text" size ="3" width="1" maxlength="3" style="text-align:center;" id="cdc2" name="cdc2" value="<?php echo $row['cdc2'] ?>" onkeypress='return SomenteNumero(event)' onBlur="soma();">  
                                   </td>  
                                   <td>  
                                        <input type="text" size ="3" width="1" maxlength="3" style="text-align:center;" id="subtotalc2" name="subtotalc2" readonly="readonly">  
                                   </td>     
                               </tr>  
                               <tr align="center" style="font-weight:bold">  
                                   <td width="10%">
                                        <input type="text" size ="15" width="1" maxlength="15" style='text-transform:uppercase' value="<?php echo $row['tituloc3'] ?>" id="tituloc3" name="tituloc3">  
                                   </td>  
                                   <td>  
                                        <input type="text" size ="3" width="1" maxlength="3"  style="text-align:center;" id="tdc3" name="tdc3" value="<?php echo $row['tdc3'] ?>" onkeypress='return SomenteNumero(event)' onBlur="soma()">  
                                   </td>  
                                   <td> 
                                        <input type="text" size ="3" width="1" maxlength="3" style="text-align:center;" id="tqc3" name="tqc3" value="<?php echo $row['tqc3'] ?>" onkeypress='return SomenteNumero(event)' onBlur="soma();">  
                                   </td>  
                                   <td>  
                                        <input type="text" size ="3" width="1" maxlength="3" style="text-align:center;" id="tsc3" name="tsc3" value="<?php echo $row['tsc3'] ?>" onkeypress='return SomenteNumero(event)' onBlur="soma();">  
                                   </td>  
                                   <td>  
                                        <input type="text" size ="3" width="1" maxlength="3" style="text-align:center;" id="toc3" name="toc3" value="<?php echo $row['toc3'] ?>" onkeypress='return SomenteNumero(event)' onBlur="soma();">
                                   </td>  
                                   <td>  
                                        <input type="text" size ="3" width="1" maxlength="3" style="text-align:center;" id="quc3" name="quc3" value="<?php echo $row['quc3'] ?>" onkeypress='return SomenteNumero(event)' onBlur="soma();">
                                   </td>  
                                   <td>  
                                        <input type="text" size ="3" width="1" maxlength="3" style="text-align:center;" id="qdc3" name="qdc3" value="<?php echo $row['qdc3'] ?>" onkeypress='return SomenteNumero(event)' onBlur="soma();">
                                   </td>  
                                   <td>  
                                        <input type="text" size ="3" width="1" maxlength="3" style="text-align:center;" id="qqc3" name="qqc3" value="<?php echo $row['qqc3'] ?>" onkeypress='return SomenteNumero(event)' onBlur="soma();">  
                                   </td>  
                                   <td>  
                                        <input type="text" size ="3" width="1" maxlength="3" style="text-align:center;" id="qsc3" name="qsc3" value="<?php echo $row['qsc3'] ?>" onkeypress='return SomenteNumero(event)' onBlur="soma();">  
                                   </td>  
                                   <td>  
                                        <input type="text" size ="3" width="1" maxlength="3" style="text-align:center;" id="qoc3" name="qoc3" value="<?php echo $row['qoc3'] ?>" onkeypress='return SomenteNumero(event)' onBlur="soma();">  
                                   </td>  
                                   <td>  
                                        <input type="text" size ="3" width="1" maxlength="3" style="text-align:center;" id="cic3" name="cic3" value="<?php echo $row['cic3'] ?>" onkeypress='return SomenteNumero(event)' onBlur="soma();">
                                   </td>  
                                   <td>  
                                        <input type="text" size ="3" width="1" maxlength="3" style="text-align:center;" id="cdc3" name="cdc3" value="<?php echo $row['cdc3'] ?>" onkeypress='return SomenteNumero(event)' onBlur="soma();">  
                                   </td>  
                                   <td>  
                                        <input type="text" size ="3" width="1" maxlength="3" style="text-align:center;" id="subtotalc3" name="subtotalc3" readonly="readonly">  
                                   </td>     
                               </tr>  
                               
                               <tr align="center" style="background-color: #d3d3d3">  
                                   <td width="10%">
                                    Soma Futura
                                   </td>  
                                   <td>  
                                        <input type="text" size ="3" width="1" maxlength="3"  style="text-align:center;" id="somatdc" name="somatdc" readonly="readonly">  
                                   </td>  
                                   <td> 
                                        <input type="text" size ="3" width="1" maxlength="3"  style="text-align:center;" id="somatqc" name="somatqc" readonly="readonly">  
                                   </td>  
                                   <td>  
                                        <input type="text" size ="3" width="1" maxlength="3"  style="text-align:center;" id="somatsc" name="somatsc" readonly="readonly">  
                                   </td>  
                                   <td>  
                                        <input type="text" size ="3" width="1" maxlength="3"  style="text-align:center;" id="somatoc" name="somatoc" readonly="readonly">  
                                   </td>  
                                   <td>  
                                        <input type="text" size ="3" width="1" maxlength="3"  style="text-align:center;" id="somaquc" name="somaquc" readonly="readonly">  
                                   </td>  
                                   <td>  
                                        <input type="text" size ="3" width="1" maxlength="3"  style="text-align:center;" id="somaqdc" name="somaqdc" readonly="readonly">  
                                   </td>  
                                   <td>  
                                        <input type="text" size ="3" width="1" maxlength="3"  style="text-align:center;" id="somaqqc" name="somaqqc" readonly="readonly">  
                                   </td>  
                                   <td>  
                                        <input type="text" size ="3" width="1" maxlength="3"  style="text-align:center;" id="somaqsc" name="somaqsc" readonly="readonly">  
                                   </td>  
                                   <td>  
                                        <input type="text" size ="3" width="1" maxlength="3"  style="text-align:center;" id="somaqoc" name="somaqoc" readonly="readonly">  
                                   </td>  
                                   <td>  
                                        <input type="text" size ="3" width="1" maxlength="3"  style="text-align:center;" id="somacic" name="somacic" readonly="readonly">  
                                   </td>  
                                   <td>  
                                        <input type="text" size ="3" width="1" maxlength="3"  style="text-align:center;" id="somacdc" name="somacdc" readonly="readonly">  
                                   </td>  
                                   <td>  
                                        <input type="text" size ="3" width="1" maxlength="3"  style="text-align:center;" id="somageralc" name="somageralc" readonly="readonly">  
                                   </td>     
                               </tr>                                   
                            </form>
                        </table>
                    </div>  

                </div>            
            </form>  

<script type="text/javascript">
window.onload = function()
{
   soma();
}
</script>   

<script language='JavaScript'>
function soma() 
{
    var tdc1 = "<?php echo $row["tdc1"]; ?>";
    var tqc1 = "<?php echo $row["tqc1"]; ?>";
    gradePedido.somatdc.value =  (eval(tdc1) - eval(tqc1))
    
gradePedido.subtotalc1.value = (gradePedido.tdc1.value*1) + (gradePedido.tqc1.value*1) + (gradePedido.tsc1.value*1) + (gradePedido.toc1.value*1) + (gradePedido.quc1.value*1) + (gradePedido.qdc1.value*1) + (gradePedido.qqc1.value*1) + (gradePedido.qsc1.value*1) + (gradePedido.qoc1.value*1) + (gradePedido.cic1.value*1) + (gradePedido.cdc1.value*1)
gradePedido.subtotalc2.value = (gradePedido.tdc2.value*1) + (gradePedido.tqc2.value*1) + (gradePedido.tsc2.value*1) + (gradePedido.toc2.value*1) + (gradePedido.quc2.value*1) + (gradePedido.qdc2.value*1) + (gradePedido.qqc2.value*1) + (gradePedido.qsc2.value*1) + (gradePedido.qoc2.value*1) + (gradePedido.cic2.value*1) + (gradePedido.cdc2.value*1)
gradePedido.subtotalc3.value = (gradePedido.tdc3.value*1) + (gradePedido.tqc3.value*1) + (gradePedido.tsc3.value*1) + (gradePedido.toc3.value*1) + (gradePedido.quc3.value*1) + (gradePedido.qdc3.value*1) + (gradePedido.qqc3.value*1) + (gradePedido.qsc3.value*1) + (gradePedido.qoc3.value*1) + (gradePedido.cic3.value*1) + (gradePedido.cdc3.value*1)

gradePedido.somatdc.value = (gradePedido.tdc1.value*1) + (gradePedido.tdc2.value*1) + (gradePedido.tdc3.value*1)
gradePedido.somatqc.value = (gradePedido.tqc1.value*1) + (gradePedido.tqc2.value*1) + (gradePedido.tqc3.value*1)
gradePedido.somatsc.value = (gradePedido.tsc1.value*1) + (gradePedido.tsc2.value*1) + (gradePedido.tsc3.value*1)
gradePedido.somatoc.value = (gradePedido.toc1.value*1) + (gradePedido.toc2.value*1) + (gradePedido.toc3.value*1)
gradePedido.somaquc.value = (gradePedido.quc1.value*1) + (gradePedido.quc2.value*1) + (gradePedido.quc3.value*1)
gradePedido.somaqdc.value = (gradePedido.qdc1.value*1) + (gradePedido.qdc2.value*1) + (gradePedido.qdc3.value*1)
gradePedido.somaqqc.value = (gradePedido.qqc1.value*1) + (gradePedido.qqc2.value*1) + (gradePedido.qqc3.value*1)
gradePedido.somaqsc.value = (gradePedido.qsc1.value*1) + (gradePedido.qsc2.value*1) + (gradePedido.qsc3.value*1)
gradePedido.somaqoc.value = (gradePedido.qoc1.value*1) + (gradePedido.qoc2.value*1) + (gradePedido.qoc3.value*1)
gradePedido.somacic.value = (gradePedido.cic1.value*1) + (gradePedido.cic2.value*1) + (gradePedido.cic3.value*1)
gradePedido.somacdc.value = (gradePedido.cdc1.value*1) + (gradePedido.cdc2.value*1) + (gradePedido.cdc3.value*1)

gradePedido.somageralc.value = 
(gradePedido.somatdc.value*1) + (gradePedido.somatqc.value*1) + (gradePedido.somatsc.value*1) + (gradePedido.somatoc.value*1) + 
(gradePedido.somaquc.value*1) + (gradePedido.somaqdc.value*1) + (gradePedido.somaqqc.value*1) + (gradePedido.somaqsc.value*1) + 
(gradePedido.somaqoc.value*1) + (gradePedido.somacic.value*1) + (gradePedido.somacdc.value*1)
}

</script>

<script language='JavaScript'>
function SomenteNumero(e){
    var tecla=(window.event)?event.keyCode:e.which;   
    if((tecla>47 && tecla<58)) return true;
    else{
    	if (tecla==8 || tecla==0) return true;
	else  return false;
    }
}
</script>
