public function actionGuardarOrden()
 {
     $model = new OrdenPedido();
     //$model->personal_entrega_id = $_POST['OrdenPedido']['personal_entrega_id'];
     //$model->personal_recibe_id 	= $_POST['OrdenPedido']['personal_recibe_id'];
     $model->personal_entrega_id = 1;
     $model->personal_recibe_id = $_POST['personalRecibe'];
     $model->observacion = $_POST['observacion'];
     $model->fecha = date("Y-m-d H:i:s");
     if ($model->save()) {
         $eltotal = 0;
         for ($i = 0; $i <= $_POST['variable']; $i++) {
             //$x = $i+1;
             //
             if (isset($_POST['tipo_' . $i])) {
                 $detalleP = new OrdenPedidoDetalle();
                 $detalleP->orden_pedido_id = $model->id;
                 $detalleP->tipo_orden_pedido_id = $_POST['tipo_' . $i];
                 $detalleP->producto_id = $_POST['productos_' . $i];
                 $detalleP->area = $_POST['area_' . $i];
                 $detalleP->cantidad = $_POST['cantidad_' . $i];
                 $detalleP->save();
             }
         }
         $this->redirect(array('view', 'id' => $model->id));
     }
 }
Esempio n. 2
0
<div class="span2"></div>
</div>

<h3 class="text-center">Detalle de Pedido</h3>
<div class="row">
	<div class="span2"></div>
	<div class="span8">
		<table class="table table-striped">
			<tr>
				<th>Tipo</th>
				<th>Detalle</th>
				<th>Area</th>
				<th>Cantidad</th>
			</tr>
		<?php 
$elPedido = OrdenPedidoDetalle::model()->findAll("orden_pedido_id = {$model->id}");
?>
		<?php 
foreach ($elPedido as $el_pedido) {
    ?>
				<tr>
					
					<td><?php 
    echo $el_pedido->tipoOrdenPedido->tipo_corto;
    ?>
</td>
			
					<td><?php 
    echo $el_pedido->producto->nombre_producto;
    ?>
</td>
 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  * @param integer $id the ID of the model to be loaded
  * @return OrdenPedidoDetalle the loaded model
  * @throws CHttpException
  */
 public function loadModel($id)
 {
     $model = OrdenPedidoDetalle::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }