Ver Mensaje Individual
  #1 (permalink)  
Antiguo 06/04/2016, 00:45
Avatar de aviweb2015
aviweb2015
 
Fecha de Ingreso: abril-2016
Ubicación: venezuela
Mensajes: 215
Antigüedad: 8 años
Puntos: 1
guardar factura

como guardar esta factura he creado el formulario pero no me guarda
Código PHP:
Ver original
  1. <?php
  2.                
  3.                 $cnt = array();
  4.                 $products = array();
  5.                
  6.                 foreach($_POST as $key=>$value)
  7.                 {
  8.                     $key=(int)str_replace('_cnt','',$key);
  9.                
  10.                     $products[]=$key;
  11.                     $cnt[$key]=$value;
  12.                 }
  13.  
  14.                 $result = mysql_query("SELECT * FROM servicios WHERE id IN(".join($products,',').")");
  15.                
  16.                 if(!mysql_num_rows($result))
  17.                 {
  18.                     echo '<h1>Hubo un error con su orden!</h1>';
  19.                 }
  20.                 else
  21.                 {
  22.                     echo '<h1>Usted ordeno:</h1>';
  23.                    
  24.                     while($row=mysql_fetch_assoc($result))
  25.                     {
  26.  
  27.  
  28.  
  29. echo '<form class=col s12 action=order.php
  30. name=frmContacto method=POST>';
  31.  
  32.  
  33.  
  34. echo '<h2>'.$cnt[$row['id']].'&nbsp;&nbsp;&nbsp;'.$row['descripcion']." = ".$row['precio'].' Bsf</h2>';//lista de productos ordenados
  35.  
  36. @$total+=$cnt[$row['id']]*$row['precio'];// total de la venta
  37.  
  38.  
  39. }
  40.  
  41. echo '<h1>Total: Bsf '.$total.'</h1>';
  42.                
  43.                 }
  44.                 ?>
  45.                
  46.                
  47.  
  48.  
  49.          
  50.                 <div class="clear"></div>
  51.             </div>
  52.  
  53.         </div>
  54.        
  55.         <div class="bottom-container-border">
  56.         </div>
  57.  
  58.     </div>
  59.  
  60. </div>
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67. <div id="main-container">
  68.  
  69.     <div class="container">
  70.    
  71.         <span class="top-label">
  72.             <span class="label-txt">Preparar Orden</span>
  73.         </span>
  74.        
  75.         <div class="content-area">
  76.    
  77.             <div class="content">
  78.                
  79.  
  80.                
  81.  
  82.  
  83.  
  84. <input type=text placeholder='Buscar Cliente' autocomplete='off'
  85. title='BUSQUE POR NOMBRE O NÚMERO DE CÉDULA'
  86. style='background: white url(imagenes/lupa.png) no-repeat;
  87. background-position: 125px;' class='cajatexto2' id='inputString'
  88. name='idcliente' onKeyUp='lookup(this.value);' onBlur='fill();'>
  89. <div class='suggestionsBox' id='suggestions' style='display: none;'>
  90. <div class='suggestionList' id='autoSuggestionsList'>
  91. </div></div>
  92.  
  93.  
  94. <!-- fecha y numero de factura-->
  95. <div class='row'>
  96. <div class='input-field col s12 m2'><p class='blue-text text-darken-2'>Fecha:</p>
  97. <input type="text" name="fecha" value="<?php echo date("d/m/Y"); ?>"
  98. readonly="true"/>
  99. </div>
  100.  
  101. <div class='input-field col s12 m2'><p class='blue-text text-darken-2'>N° de Fact.</p>
  102. <input type="text" name='idfactura' readonly='readonly' value="
  103. <?php
  104. include("connect.php");
  105. $res=mysql_query("select * from factura_cliente");
  106. if($campo=mysql_fetch_array($res))
  107. {
  108. $codigo=mysql_num_rows($res)+1;
  109. echo $codigo=$codigo;
  110. }
  111. if(mysql_num_rows($res)==0)
  112. echo $codigo='1' ;
  113. ?>" >
  114.  
  115. </div>
  116.  
  117. <div class='input-field col s12 m4'><p class='blue-text text-darken-2'>Tipo de Organización.</p>
  118. <select select name="idcategorias" id="idcategorias"
  119. title="Disculpa, seleccione el Tipo de Organizacion!" required/>
  120. <option value=""  disabled selected>Seleccione</option>
  121. <?php
  122. include('conexion.php');
  123. $result = mysql_query("SELECT * FROM evento");
  124. while ($row=mysql_fetch_array($result)) {
  125. ?>
  126. <option value="<?php echo $row['descripcion'];?>">
  127. <?php echo $row['descripcion'];?> </option>
  128. <?php
  129. }
  130. mysql_close($link);
  131. ?>
  132. </select>
  133.  
  134. </div>
  135.  
  136. <div class='input-field col s12 m4'><p class='blue-text text-darken-2'>Numero de Personas.</p>
  137. <input id="icon_prefix" type="text" name="num_personas" autocomplete="off"
  138. title="Se Necesita el numero de Personas Asistir" required/>
  139.  
  140. </div>
  141. </div>
  142.  
  143.  
  144.  
  145. <button class="btn waves-effect blue-grey darken-4 left btn-medium"
  146. type="submit" name="guardar" value='Finalizar Compra'>Finalizar Compra</button>
  147.  
  148. </form>
  149.  <!--   fin busca el cliente-->
  150.  
  151.  
  152.  
  153.  
  154.  
  155.  
  156.  
  157.  
  158.          
  159.                 <div class="clear"></div>
  160.             </div>
  161.  
  162.         </div>
  163.        
  164.         <div class="bottom-container-border">
  165.         </div>
  166.  
  167.     </div>
  168.  
  169. </div>
  170.  
  171. </body>
  172. </html>
  173.  
  174.  
  175. <?php
  176. if (isset ($_POST['guardar'])){
  177. $id=$_REQUEST['id'];
  178. $idfactura=$_REQUEST['idfactura'];
  179. $idcliente=$_REQUEST['idcliente'];
  180. $fecha=$_REQUEST['fecha'];
  181. $idprodutos=$_REQUEST['idproductos'];
  182. $cantidad=$_REQUEST['cantidad'];
  183. $precio=$_REQUEST['precio'];
  184. $total=$_REQUEST['total'];
  185. $idcategorias=$_REQUEST['idcategorias'];
  186. $num_personas=$_REQUEST['num_personas'];
  187.  
  188. include("conexion.php");
  189.   $sql="SELECT * FROM factura_cliente WHERE id='$id'";
  190.   $res=mysql_query($sql,$link);
  191.   $nrows=mysql_num_rows($res);
  192.   if($nrows==0){
  193.  
  194. if (mysql_query("INSERT INTO factura_cliente (id,idfactura,idcliente,fecha,idproductos,cantidad,
  195. precio,total,idcategorias,num_personas) VALUES
  196. ('$id','$idfactura','$idcliente','$fecha','$idproductos','$cantidad',
  197.     '$precio','$total','$idcategorias','$num_personas')",$link));
  198.  
  199.  
  200. echo "<script>alert ('Orden Generada');</script>
  201. <META HTTP-EQUIV='REFRESH' CONTENT=0;URL=http:demo.php>";
  202.           }
  203.   else echo "<div class='registro'><script>alert ('Discule esta irden ya existe');</script>
  204.  <META HTTP-EQUIV='REFRESH' CONTENT=0;URL=http:demo.php></div>";
  205. }
  206. ?>
__________________
yoclens avilan