function valorunico() { $descuento = new Descuento(); $id = $_REQUEST['id']; $data = $descuento->buscarxid($id); echo json_encode($data); }
function cargar() { $desc = new Descuento(); $desc->setIdDescuento($_POST["id"]); $desc->setCantidad($_POST["cant"]); return $desc; }
function DetalleGuiaMadre() { $idGuia = $_REQUEST['id']; $dataGuia = $this->AutoLoadModel("OrdenVenta"); $idTipoCambio = $dataGuia->BuscarCampoOVxId($idGuia, "IdTipoCambioVigente"); //PREGUNTAR SI ACTUAL O AL ELEGIDO EN LA COMPRA $TipoCambio = $this->AutoLoadModel("TipoCambio"); $dataTipoCambio = $TipoCambio->consultaDatosTCVigentexTCElegido($idTipoCambio); $simboloMoneda = $dataTipoCambio[0]['simbolo']; $TC_PrecioVenta = $dataTipoCambio[0]['venta']; $detalleOrdenVenta = new detalleOrdenVenta(); $descuento = new Descuento(); $dataDescuento = $descuento->listadoTotal(); for ($i = 0; $i < count($dataDescuento); $i++) { $dscto[$dataDescuento[$i]['id']] = $dataDescuento[$i]['valor']; } $data = $detalleOrdenVenta->listaDetalleOrdenVentaGuia($idGuia); $total = 0; echo "<tr><th colspan=8><h3>DETALLE DE PRODUCTOS DE LA ORDEN DE PEDIDO (No incluye Gastos Adicionales)</h3></th></tr>"; echo "\t<tr>\n\t\t\t\t\t<th>Cant.</th>\n\t\t\t\t\t<th>U.Med.</th>\n\t\t\t\t\t<th>Código.</th>\n\t\t\t\t\t<th>Descripción.</th>\n\t\t\t\t\t<th>Precio</th>\n\t\t\t\t\t<th>%Descto.</th>\n\t\t\t\t\t<th>P/Neto.</th>\n\t\t\t\t\t<th>Monto.</th>\n\t\t\t\t</tr>"; $cantidad = count($data); for ($i = 0; $i < $cantidad; $i++) { $precioneto = number_format($data[$i]['precioaprobado'] * (1 - $data[$i]['descuentoaprobadovalor']), 2); $precioTotal = $data[$i]['preciofinal'] * $data[$i]['cantdespacho']; $total += $precioTotal; echo "<tr>"; echo '<td>' . $data[$i]['cantdespacho'] . '</td>'; echo '<td>' . $data[$i]['unidadmedida'] . '</td>'; echo '<td>' . $data[$i]['codigopa'] . '</td>'; echo '<td>' . $data[$i]['nompro'] . '</td>'; echo '<td>' . ' ' . $simboloMoneda . ' ' . number_format($data[$i]['precioaprobado'], 2) . '</td>'; echo '<td>' . $dscto[$data[$i]['descuentoaprobado']] . '</td>'; echo '<td style="text-align:right;">' . ' ' . $simboloMoneda . ' ' . number_format($data[$i]['preciofinal'], 2) . '</td>'; echo '<td style="text-align:right;">' . ' ' . $simboloMoneda . ' ' . number_format($precioTotal, 2) . '</td>'; echo "</tr>"; } echo '<tr style="color:#f00">'; echo '<td colspan="7" class="right bold"> Total a Pagar </td>'; echo '<td class="right">' . '<input type="text" id="txtTotal" value="' . ' ' . $simboloMoneda . ' ' . number_format($total, 2) . '" class="text-100 right" readonly>' . '</td>'; echo "</tr>"; echo '<tr><td colspan="8" style="background:white;"> </td></tr>'; for ($i = 0; $i < $cantidad; $i++) { if ($data[$i]['serie'] != "") { echo "<tr>"; echo '<th>' . $data[$i]['codigopa'] . '</th>'; echo '<th>SERIES: </th>'; echo '<td colspan="6">' . $data[$i]['serie'] . '</td>'; echo "</tr>"; } } }
function buscar() { if (!empty($_REQUEST['idvalor'])) { $idProducto = $_REQUEST['idvalor']; } else { $idProducto = $_REQUEST['id']; $descuento = new Descuento(); $dscto = $descuento->buscarxid($_REQUEST['parameters'][1]); } $marca = $this->AutoLoadModel('marca'); $unidad = $this->AutoLoadModel('unidadmedida'); $almacen = $this->AutoLoadModel('almacen'); $producto = new Producto(); $data = $producto->buscaProductoOrdenCompra($idProducto); if ($data[0]['unidadmedida']) { $unidadMedida = $unidad->buscaUnidadMedida($data[0]['unidadmedida']); } if ($data[0]['idalmacen']) { $dataAlmacen = $almacen->buscaAlmacen($data[0]['idalmacen']); } $empaque = $this->empaque(); $dataMarca = $marca->listado(); for ($i = 0; $i < count($dataMarca); $i++) { if (!empty($data[0]['idmarca']) && $data[0]['idmarca'] == $dataMarca[$i]['idmarca']) { $data[0]['idmarca'] = $dataMarca[$i]['nombre']; } } /*echo '{ "codigo":"'.$data[0]['codigopa'].'", "idproducto":"'.$data[0]['idproducto'].'", "foto":"'.$data[0]['imagen'].'", "nompro":"'.str_replace('"', '\"', $data[0]['nompro']).'", "nomemp":"'.$empaque[($data[0]['empaque'])].'", "marca":"'.$data[0]['idmarca'].'", "nomum":"'.$unidadMedida[($data[0]['unidadmedida'])].'", "fob":"'.$data[0]['fob'].'", "preciolista":"'.$data[0]['preciolista'].'", "descuentosolicitado":"'.$dscto[0]['dunico'].'", "descuentovalor":"'.$dscto[0]['valor'].'", "stockactual":"'.$data[0]['stockdisponible'].'" }';*/ //$dataJson['codigo']=$data[0]['codigopa']; $dataRespuesta['codigo'] = $data[0]['codigopa']; $dataRespuesta['nompro'] = str_replace('"', '\\"', $data[0]['nompro']); $dataRespuesta['idproducto'] = $data[0]['idproducto']; $dataRespuesta['foto'] = empty($data[0]['imagen']) ? "" : $data[0]['imagen']; $dataRespuesta['marca'] = empty($data[0]['idmarca']) ? "" : $data[0]['idmarca']; $dataRespuesta['nomum'] = empty($unidadMedida[0]['codigo']) ? "" : $unidadMedida[0]['codigo']; $dataRespuesta['codigoalmacen'] = empty($dataAlmacen[0]['codigoalmacen']) ? "" : $dataAlmacen[0]['codigoalmacen']; $dataRespuesta['fob'] = empty($data[0]['fob']) ? "" : $data[0]['fob']; $dataRespuesta['preciolista'] = empty($data[0]['preciolista']) ? "" : $data[0]['preciolista']; $dataRespuesta['preciolistadolares'] = empty($data[0]['preciolistadolares']) ? "" : $data[0]['preciolistadolares']; $dataRespuesta['preciocosto'] = empty($data[0]['preciocosto']) ? "" : $data[0]['preciocosto']; $dataRespuesta['descuentosolicitado'] = empty($dscto[0]['dunico']) ? "0" : $dscto[0]['dunico']; $dataRespuesta['descuentovalor'] = empty($dscto[0]['valor']) ? "" : $dscto[0]['valor']; $dataRespuesta['stockactual'] = empty($data[0]['stockdisponible']) ? "" : $data[0]['stockdisponible']; echo json_encode($dataRespuesta); }
function generaFactura() { $pdf = $this->AutoLoadModel('pdf'); $ordenventa = $this->AutoLoadModel('documento'); $EnLetras = new EnLetras(); $meses = array("", "Enero", "Febrero", "Marzo", "Abril", "Mayo", "Junio", "Julio", "Agosto", "Septiembre", "Octubre", "Noviembre", "Diciembre"); $cobro = $this->AutoLoadModel('ordencobro'); $idDoc = $_REQUEST['id']; $buscaFactura = $ordenventa->buscaDocumento($idDoc, ""); if (!empty($_REQUEST['id']) && !empty($buscaFactura) && $_REQUEST['id'] > 0 && $buscaFactura[0]['nombredoc'] == 1 && $buscaFactura[0]['esAnulado'] != 1) { //obtemos la condicion y tiempo de credito //obtemos los porcenajes y modo que fue facturado $porcentaje = $buscaFactura[0]['porcentajefactura']; $modo = $buscaFactura[0]['modofactura']; $numeroFactura = $buscaFactura[0]['numdoc']; $serieFactura = str_pad($buscaFactura[0]['serie'], 3, '0', STR_PAD_LEFT); //buscamos la guia de remision que le pertenece en caso que lo hubiera $filtro = "nombredoc=4"; $dataGuia = $ordenventa->buscadocumentoxordenventaPrimero($buscaFactura[0]['idordenventa'], $filtro); $numeroRelacionado = $dataGuia[0]['numdoc']; $tipodocumentorelacionado = $dataGuia[0]['nombredoc']; //Grabamos en //*********************// $dataFactura = $pdf->buscarxOrdenVenta($buscaFactura[0]['idordenventa']); $dataFactura[0]['numeroRelacionado'] = $numeroRelacionado; $dataFactura[0]['numeroFactura'] = $numeroFactura; $dataFactura[0]['serieFactura'] = $serieFactura; $dataFactura[0]['fecha'] = date('d/m/Y'); $dataFactura[0]['referencia'] = 'VEN: ' . $dataFactura[0]['idvendedor'] . ' DC: ' . $dataFactura[0]['codigov']; $data = $pdf->buscarDetalleOrdenVenta($buscaFactura[0]['idordenventa']); $dataCobro = $pdf->buscarOrdenCompraxId($buscaFactura[0]['idordenventa']); if ($dataCobro[0]['escontado'] == 1 && $dataCobro[0]['escredito'] == 0 && $dataCobro[0]['esletras'] == 0) { $dataFactura[0]['condicion'] = 'CONTADO'; } elseif ($dataCobro[0]['escredito'] == 1 && $dataCobro[0]['esletras'] == 0) { $dataFactura[0]['condicion'] = 'CREDITO'; } elseif ($dataCobro[0]['esletras'] == 1) { $dataFactura[0]['condicion'] = 'LETRAS'; //$dataFactura[0]['fechavencimiento']=$pdf->listaDetalleOrdenCompraxId($dataCobro[0]['idordencobro'],3); } $descuento = new Descuento(); $dataDescuento = $descuento->listadoTotal(); for ($i = 0; $i < count($dataDescuento); $i++) { $dscto[$dataDescuento[$i]['id']] = $dataDescuento[$i]['valor']; } $cantidad = count($data); $dataN = array(); $total = 0; $cont = 0; for ($i = 0; $i < $cantidad; $i++) { if ($porcentaje != "") { if ($modo == 1) { $precio = $data[$i]['preciofinal']; $data[$i]['preciofinal'] = $precio * $porcentaje / 100; $cantidadP = $data[$i]['cantdespacho'] - $data[$i]['cantdevuelta']; $data[$i]['cantdespacho'] = $cantidadP; } elseif ($modo == 2) { $cantidadP = $data[$i]['cantdespacho'] - $data['cantdevuelta']; $data[$i]['cantdespacho'] = $cantidadP * $porcentaje / 100; } else { $data[$i]['cantdespacho'] = $data[$i]['cantdespacho'] - $data[$i]['cantdevuelta']; } } else { $data[$i]['cantdespacho'] = $data[$i]['cantdespacho'] - $data[$i]['cantdevuelta']; } if ($data[$i]['cantdespacho'] > 0) { $dataN[$cont]['cantdespacho'] = $data[$i]['cantdespacho']; $dataN[$cont]['preciofinal'] = $data[$i]['preciofinal']; $dataN[$cont]['nompro'] = $data[$i]['nompro']; $dataN[$cont]['codigopa'] = $data[$i]['codigopa']; $cont++; } } echo ''; $cantidadDocumentos = 0; $maximoItem = $this->configIni("MaximoItem", "Factura"); if ($cont % $maximoItem == 0) { $cantidadDocumentos = $cont / $maximoItem; } elseif ($cont % $maximoItem != 0) { $cantidadDocumentos = floor($cont / $maximoItem) + 1; } //acutalizamos Documento que ya fue impreso,numero Relacionado y su tipo $dataV['esimpreso'] = 1; $dataV['CantidadDocumentos'] = $cantidadDocumentos; $dataV['numerorelacionado'] = $numeroRelacionado; $dataV['tipoDocumentoRelacionado'] = $tipodocumentorelacionado; $filtro = "iddocumento='" . $idDoc . "'"; $exitoE = $ordenventa->actualizarDocumento($dataV, $filtro); $datos['hojas'] = $cantidadDocumentos; $datos['maximoItem'] = $maximoItem; $datos['Factura'] = $dataFactura; $datos['DetalleFactura'] = $dataN; $datos['letras'] = $EnLetras; $datos['mes'] = $meses[date('n')]; $this->view->show('/documento/generaFactura.phtml', $datos); } }
/** * 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 Descuento the loaded model * @throws CHttpException */ public function loadModel($id) { $model = Descuento::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
<?php echo $form->labelEx($model, 'idAlumno');?> <?php echo $form->dropDownList($model,'idAlumno',CHtml::listData(Alumno::model()->findAll(array('order'=>'idAlumno')),'idAlumno', 'nombreCompleto'),array('empty'=>'Seleccionar..' ));?> <?php echo $form->labelEx($model, 'Cuenta');?> <?php echo $form->dropDownList($model,'idCuenta',CHtml::listData(Persona::model()->findAll(array('order'=>'idPersona')),'idPersona', 'apellido', 'nombre'),array('empty'=>'Seleccionar..' ));?> <?php echo $form->datepickerRow($model,'fechaInicio',array('options'=>array(),'htmlOptions'=>array('class'=>'span5')),array('prepend'=>'<i class="icon-calendar"></i>','append'=>'Click on Month/Year at top to select a different year or type in (mm/dd/yyyy).')); ?> <?php echo $form->datepickerRow($model,'fechaFin',array('options'=>array(),'htmlOptions'=>array('class'=>'span5')),array('prepend'=>'<i class="icon-calendar"></i>','append'=>'Click on Month/Year at top to select a different year or type in (mm/dd/yyyy).')); ?> <?php echo $form->textFieldRow($model,'motivoBaja',array('class'=>'span5','maxlength'=>100)); ?> <?php echo $form->labelEx($model,'idCurso'); ?> <?php echo $form->dropDownList($model,'idCurso',CHtml::listData(Curso::model()->findAll(array('order'=>'idCurso')),'idCurso', 'descripcion'),array('empty'=>'Seleccionar..' ));?> <?php echo $form->labelEx($model,'Descuento'); ?> <?php echo $form->dropDownList($model,'idDescuento',CHtml::listData(Descuento::model()->findAll(array('order'=>'idDescuento')),'idDescuento', 'descripcion'),array('empty'=>'Seleccionar..' ));?> <?php echo $form->textFieldRow($model,'ciclo',array('maxlength'=>5)); ?> <div class="form-actions"> <?php $this->widget('bootstrap.widgets.TbButton', array( 'buttonType'=>'submit', 'type'=>'primary', 'label'=>$model->isNewRecord ? 'Crear' : 'Guardar', )); ?> </div> <?php $this->endWidget(); ?>
function listaProductosGuiaRecuperado() { $idGuia = $_REQUEST['id']; $dataGuia = $this->AutoLoadModel("OrdenVenta"); $idTipoCambio = $dataGuia->BuscarCampoOVxId($idGuia, "IdTipoCambioVigente"); //PREGUNTAR SI ACTUAL O AL ELEGIDO EN LA COMPRA $TipoCambio = $this->AutoLoadModel("TipoCambio"); $dataTipoCambio = $TipoCambio->consultaDatosTCVigentexTCElegido($idTipoCambio); $simboloMoneda = $dataTipoCambio[0]['simbolo']; $TC_PrecioVenta = $dataTipoCambio[0]['venta']; $porcentaje = $_REQUEST['porcentaje']; $modo = $_REQUEST['modo']; $detalleOrdenVenta = new detalleOrdenVenta(); $data = $detalleOrdenVenta->listaDetalleOrdenVenta($idGuia); $total = 0; $descuento = new Descuento(); $almacen = new Almacen(); $dataDescuento = $descuento->listado(); $dataAlmacen = $almacen->listado(); $cantidadDescuento = count($dataDescuento); $cantidadAlmacen = count($dataAlmacen); $cantidadDetalles = count($data); for ($i = 0; $i < $cantidadDescuento; $i++) { $dscto[$dataDescuento[$i]['id']] = $dataDescuento[$i]['valor']; } for ($x = 0; $x < $cantidadAlmacen; $x++) { $dataAlmacen[$x]['importe'] = 0; } $varTotal = 0; for ($i = 0; $i < $cantidadDetalles; $i++) { echo "<tr>"; $data[$i]['cantporcentaje'] = $data[$i]['cantdespacho'] - $data[$i]['cantdevuelta']; if ($porcentaje != "") { if ($modo == 1) { $precio = $data[$i]['preciofinal']; $data[$i]['preciofinal'] = $precio * $porcentaje / 100; $precioneto = round($data[$i]['preciofinal'], 2); $data[$i]['cantporcentaje'] = $data[$i]['cantdespacho'] - $data[$i]['cantdevuelta']; } elseif ($modo == 2) { $precioneto = round($data[$i]['preciofinal'], 2); $cantidad = $data[$i]['cantdespacho'] - $data[$i]['cantdevuelta']; $data[$i]['cantporcentaje'] = round($cantidad * $porcentaje / 100, 2); } else { $precioneto = round($data[$i]['preciofinal'], 2); } } if (ceil($data[$i]['cantporcentaje']) == $data[$i]['cantporcentaje']) { $data[$i]['color'] = 'style="background:#E0EDFF"'; } else { $data[$i]['color'] = 'style="background:red"'; } for ($x = 0; $x < $cantidadAlmacen; $x++) { if ($dataAlmacen[$x]['idalmacen'] == $data[$i]['idalmacen']) { $subtotal = $data[$i]['preciofinal'] * $data[$i]['cantporcentaje']; $dataAlmacen[$x]['importe'] += $subtotal; $varTotal += $subtotal; } } $precioTotal = $precioneto * $data[$i]['cantporcentaje']; //$precioTotal=(($data[$i]['precioaprobado'])*($data[$i]['cantaprobada'])-($data[$i]['tdescuentoaprovado'])); echo '<td>' . $data[$i]['codigov'] . '</td>'; echo '<td>' . $data[$i]['nompro'] . '</td>'; echo '<td>' . $data[$i]['cantdespacho'] . '</td>'; echo '<td>' . $data[$i]['cantdevuelta'] . '</td>'; echo '<td ' . $data[$i]['color'] . '>' . $data[$i]['cantporcentaje'] . '</td>'; echo '<td>' . $simboloMoneda . ' ' . number_format($data[$i]['preciolista2'], 2) . '</td>'; echo '<td>' . $dscto[$data[$i]['descuentosolicitado']] . '</td>'; echo '<td>' . $simboloMoneda . ' ' . number_format($precioneto, 2) . '</td>'; echo '<td>' . $simboloMoneda . ' ' . number_format($precioTotal, 2) . '</td>'; echo "</tr>"; $total += $precioTotal; } echo '<tr style="color:#f00">'; echo '<td colspan="8" class="right bold" style="text-align:right;"> Precio de Venta<br> I.G.V.<br> Total a Pagar </td>'; echo '<td class="right">' . $simboloMoneda . ' ' . number_format($total / 1.18, 2) . '<br>' . $simboloMoneda . ' ' . number_format($total - $total / 1.18, 2) . '<br>' . $simboloMoneda . ' ' . number_format($total, 2) . '</td>'; echo "</tr>.<input type='hidden' name='Factura[montoigv]' value='" . number_format($total - $total / 1.18, 2) . "'>"; echo "</tr>.<input type='hidden' name='Factura[montofacturado]' value='" . $total . "'>"; echo "<tr><td colspan='9'><table>"; echo '<th>Empresa</th><th>Importe (' . $simboloMoneda . ' )</th><th>Porcentaje (%)</th>'; for ($x = 0; $x < $cantidadAlmacen; $x++) { if ($dataAlmacen[$x]['importe'] != 0) { $valor = $dataAlmacen[$x]['importe'] / $varTotal * 100; echo "<tr><td>" . $dataAlmacen[$x]['razsocalm'] . "</td><td>" . number_format($dataAlmacen[$x]['importe'], 2) . "</td><td>" . round($valor, 2) . "</td></tr>"; } } echo "</table></td></tr>"; }
public function getMenuDescuentos() { return CHtml::listData(Descuento::model()->findAll(), "id", "porcentaje", "descripcion"); }