/** * */ public function Confirm() { $auth = new Auth(); $shop = new ShoppingCart(); $user = $auth->id(); $myShop = $shop->all(); $objDetails = new DetalleCompra(); $total = 0; if (empty($myShop)) { return false; } foreach ($myShop as $key => $val) { $total += $val->precio * $val->cantidad; } $result_insert = $this->create($user, $total); if ($result_insert->success) { foreach ($myShop as $k => $v) { try { $objDetails->create($result_insert->id, $v->id_prod, $v->name, $v->cantidad, $v->precio, $v->talle, $v->color); //$stock = new TempStock(); //echo $stock->removeTempStock($user,$v->id_prod,$v->id_talle,$v->id_color,$v->type); } catch (Exception $e) { echo $e->getMessage(); } } $auth->restPoints($total); $auth->sumConsumed($total); $shop->removeAll(); return true; } }
/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate() { $model = new Compra(); $model->id_usuario = Yii::app()->session['userModel']->id_usuario; $this->performAjaxValidation($model, 'compra-form'); // var_dump($_POST['Compra']);die; if (isset($_POST['Compra'])) { $model->attributes = $_POST['Compra']; if ($model->save()) { foreach ($_POST as $key => $value) { if ("DetalleCompra_" == substr($key, 0, 14)) { $modelDetalle = new DetalleCompra(); $modelDetalle->id_compra = $model->id_compra; $modelDetalle->id_producto = $value['id_producto']; $modelDetalle->valor_unidad = $value['valor_unidad']; $modelDetalle->cantidad = $value['cantidad']; $modelDetalle->valor_total = $value['valor_total']; $modelDetalle->save(); } } $this->redirect(array('view', 'id' => $model->id_compra)); } } $this->render('create', array('model' => $model)); }
<?php /** @var DetalleCompraController $this */ /** @var DetalleCompra $model */ $this->breadcrumbs = array('Detalle Compras' => array('index'), $model->id_detalle); $this->menu = array(array('label' => Yii::t('AweCrud.app', 'Create') . ' ' . DetalleCompra::label(), 'icon' => 'plus', 'url' => array('create')), array('label' => Yii::t('AweCrud.app', 'Update'), 'icon' => 'pencil', 'url' => array('update', 'id' => $model->id_detalle)), array('label' => Yii::t('AweCrud.app', 'Delete'), 'icon' => 'trash', 'url' => '#', 'linkOptions' => array('submit' => array('delete', 'id' => $model->id_detalle), 'confirm' => Yii::t('AweCrud.app', 'Are you sure you want to delete this item?'))), array('label' => Yii::t('AweCrud.app', 'Manage'), 'icon' => 'list-alt', 'url' => array('admin'))); ?> <fieldset> <legend><?php echo Yii::t('AweCrud.app', 'View') . ' ' . DetalleCompra::label(); ?> <?php echo CHtml::encode($model); ?> </legend> <?php $this->widget('bootstrap.widgets.TbDetailView', array('data' => $model, 'attributes' => array('id_detalle', array('name' => 'id_compra', 'value' => $model->idCompra !== null ? CHtml::link($model->idCompra, array('/compra/view', 'id_compra' => $model->idCompra->id_compra)) . ' ' : null, 'type' => 'html'), array('name' => 'id_producto', 'value' => $model->idProducto !== null ? CHtml::link($model->idProducto, array('/producto/view', 'id_producto' => $model->idProducto->id_producto)) . ' ' : null, 'type' => 'html'), 'valor_unidad', 'cantidad', 'valor_total'))); ?> </fieldset>
<?php session_start(); ob_start(); require_once "../../libs.php"; foreach ($_POST['detalles'] as $key => $val) { /** * @param estado * @param id_detalle_producto */ DetalleCompra::upd($val, $key, (int) $_POST['remito']); } @header('Location: v_compras.php?activo=1&sub=c');
/** * 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 the ID of the model to be loaded */ public function loadModel($id, $modelClass = __CLASS__) { $model = DetalleCompra::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
private static function getInfoCompraById() { $details = new DetalleCompra(); $result = $details->allDetails(self::post("id")); print json_encode($result); }
<?php /** @var DetalleCompraController $this */ /** @var DetalleCompra $model */ $this->breadcrumbs = array('Detalle Compras'); $this->menu = array(array('label' => Yii::t('AweCrud.app', 'Create') . ' ' . DetalleCompra::label(), 'icon' => 'plus', 'url' => array('create')), array('label' => Yii::t('AweCrud.app', 'Manage'), 'icon' => 'list-alt', 'url' => array('admin'))); ?> <fieldset> <legend> <?php echo Yii::t('AweCrud.app', 'List'); ?> <?php echo DetalleCompra::label(2); ?> </legend> <?php $this->widget('bootstrap.widgets.TbListView', array('dataProvider' => $dataProvider, 'itemView' => '_view')); ?> </fieldset>
</div> <div class="span8"> <table class="table table-striped"> <thead> <tr> <td>Producto</td> <td>Valor Unitario</td> <td>Cantidad</td> <td>Valor Total</td> </tr> </thead> <tbody id="productos"> <tr class="productoRow"> <td> <?php echo $form->dropDownList(DetalleCompra::model(), 'id_producto', CHtml::listData(Producto::model()->findAll(), 'id_producto', Producto::representingColumn()), array('prompt' => Yii::t('AweApp', 'None'), 'class' => 'inputProducto', 'name' => 'DetalleCompra_1[id_producto]')); ?> </td> <td> <input class="span12 inputValorU" name="DetalleCompra_1[valor_unidad]" id="DetalleCompra_valor_unidad" type="number"> </td> <td> <input class="span12 inputCant" name="DetalleCompra_1[cantidad]" id="DetalleCompra_cantidad" type="number"> </td> <td> <input class="span12 inputValorT" name="DetalleCompra_1[valor_total]" id="DetalleCompra_valor_total" type="number"> </td> <td> <a href="" class="btn btn-mini btn-primary" id="add">+</a> <!-- <a href="" class="btn btn-mini btn-danger">x</a> --> </td>
<?php /** @var CompraController $this */ /** @var Compra $model */ $this->breadcrumbs = array('Compras' => array('index'), $model->id_compra); $this->menu = array(array('label' => Yii::t('AweCrud.app', 'Create') . ' ' . Compra::label(), 'icon' => 'plus', 'url' => array('create')), array('label' => Yii::t('AweCrud.app', 'Update'), 'icon' => 'pencil', 'url' => array('update', 'id' => $model->id_compra)), array('label' => Yii::t('AweCrud.app', 'Delete'), 'icon' => 'trash', 'url' => '#', 'linkOptions' => array('submit' => array('delete', 'id' => $model->id_compra), 'confirm' => Yii::t('AweCrud.app', 'Are you sure you want to delete this item?'))), array('label' => Yii::t('AweCrud.app', 'Manage'), 'icon' => 'list-alt', 'url' => array('admin')), array('label' => Yii::t('AweCrud.app', 'Productos'), 'icon' => 'list-alt', 'url' => Yii::app()->createUrl('SistenAdmin/DetalleCompra/create', array('id_compra' => $model->id_compra)))); ?> <fieldset> <legend><?php echo Yii::t('AweCrud.app', 'View') . ' ' . Compra::label(); ?> <?php echo CHtml::encode($model); ?> </legend> <?php $this->widget('bootstrap.widgets.TbDetailView', array('data' => $model, 'attributes' => array('id_compra', array('name' => 'id_proveedor', 'value' => $model->idProveedor !== null ? CHtml::link($model->idProveedor, array('/proveedor/view', 'id_proveedor' => $model->idProveedor->id_proveedor)) . ' ' : null, 'type' => 'html'), array('name' => 'id_usuario', 'value' => $model->idUsuario !== null ? CHtml::link($model->idUsuario, array('/usuario/view', 'id_usuario' => $model->idUsuario->id_usuario)) . ' ' : null, 'type' => 'html'), 'total_compra', 'fecha_compra', 'observaciones'))); ?> </fieldset> <?php $modelDetalle = DetalleCompra::model(); $modelDetalle->id_compra = $model->id_compra; $this->widget('bootstrap.widgets.TbGridView', array('id' => 'detalle-compra-grid', 'type' => 'striped condensed', 'dataProvider' => $modelDetalle->search(), 'filter' => $modelDetalle, 'columns' => array('id_detalle', array('name' => 'id_compra', 'value' => 'isset($data->idCompra) ? $data->idCompra : null', 'filter' => CHtml::listData(Compra::model()->findAll(), 'id_compra', Compra::representingColumn())), array('name' => 'id_producto', 'value' => 'isset($data->idProducto) ? $data->idProducto : null', 'filter' => CHtml::listData(Producto::model()->findAll(), 'id_producto', Producto::representingColumn())), 'valor_unidad', 'cantidad', 'valor_total')));
<?php /** @var DetalleCompraController $this */ /** @var DetalleCompra $model */ $this->breadcrumbs = array($model->label(2) => array('index'), Yii::t('app', $model->id_detalle) => array('view', 'id' => $model->id_detalle), Yii::t('AweCrud.app', 'Update')); $this->menu = array(array('label' => Yii::t('AweCrud.app', 'Delete'), 'icon' => 'trash', 'url' => '#', 'linkOptions' => array('submit' => array('delete', 'id' => $model->id_detalle), 'confirm' => Yii::t('AweCrud.app', 'Are you sure you want to delete this item?'))), array('label' => Yii::t('AweCrud.app', 'Manage'), 'icon' => 'list-alt', 'url' => array('admin'))); ?> <fieldset> <legend><?php echo Yii::t('AweCrud.app', 'Update') . ' ' . DetalleCompra::label(); ?> <?php echo CHtml::encode($model); ?> </legend> <?php echo $this->renderPartial('_form', array('model' => $model)); ?> </fieldset>
<?php ob_start(); session_start(); require_once '../../libs.php'; if ($_SESSION['logged_role'] != 1) { header('location: v_compras.php'); } $compra = new DetalleCompra(); $compra->refund((int) $_GET['id']); // header('location: v_compras.php?activo=1&sub=c'); // exit();
<?php session_start(); ob_start(); require_once "../../libs.php"; $collection = array(); $id = $_POST['id_compra']; $remito = $_POST['remito']; $detalles = $_POST['detalles']; foreach ($remito as $rem => $val) { array_push($collection, array("id" => $rem, "remito" => $val, "estado" => $detalles[$rem])); } foreach ($collection as $key => $val) { DetalleCompra::upd($val["id"], $val['estado'], $val['remito']); } @header('Location: v_compras.php?activo=1&sub=c');