
<?php
    require 'conexion.php';
    require_once('functions.php');
	include(HEADER_TEMPLATE); 
    
	$id_pedido = $_GET['id'];
    
?>

            <div class="row">
				<h3 style="text-align:center">Adiciona Grade - PEDIDO: <?php echo $id_pedido; ?></h3>
			</div>
			
			<form name="gradePedido" method="POST" action="grade_grava.php" autocomplete="off">

                <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" />
               
                <div class="container">  
                    <br />  
                    <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_grava.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" 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" 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" 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" 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" 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" 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" 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" 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" 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" 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" 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" 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' id="tituloc2" name="tituloc2">  
                                   </td>  
                                   <td>  
                                        <input type="text" size ="3" width="1" maxlength="3"  style="text-align:center;" id="tdc2" name="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" 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" 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" 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" 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" 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" 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" 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" 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" 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" 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' id="tituloc3" name="tituloc3">  
                                   </td>  
                                   <td>  
                                        <input type="text" size ="3" width="1" maxlength="3"  style="text-align:center;" id="tdc3" name="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" 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" 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" 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" 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" 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" 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" 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" 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" 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" 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 class="row">                
                            <div class="form-group">
                                <div class="col-xs-6 col-xs-offset-3 col-sm-4 col-sm-offset-0">
                                    <a href="pedido_index.php" class="btn btn-primary">Voltar</a>
                                    <button type="submit" class="btn btn-danger">GRAVA GRADE</button>
                                </div>
                            </div>
                        </div>

                </div>            
            </form>  

 
<script language='JavaScript'>
function soma() 
{
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>



<?php include(FOOTER_TEMPLATE); ?>       
  
