예제 #1
0
 function clientevistaglobal()
 {
     if ($_REQUEST['idcliente']) {
         $id = $_REQUEST['idcliente'];
         $ordenventa = new OrdenVenta();
         $data['data'] = $ordenventa->listaOrdenVentaxIdCliente($id);
         $data['nroOrdenes'] = count($data['data']);
     } else {
         $data['data'] = "";
     }
     $this->view->show("/cliente/clientevistaglobal.phtml", $data);
 }
예제 #2
0
 function listaOrdenesxIdCliente()
 {
     $id = $_REQUEST['id'];
     $ordenventa = new OrdenVenta();
     $ordenGasto = $this->AutoLoadModel('ordengasto');
     $data = $ordenventa->listaOrdenVentaxIdCliente($id);
     $nroOrdenes = count($data);
     if ($nroOrdenes > 0) {
         $montoTotal = 0;
         $montoPagado = 0;
         $montoDevuelto = 0;
         $saldo = 0;
         for ($i = 0; $i < $nroOrdenes; $i++) {
             $montoGuia = $ordenGasto->totalGuia($data[$i]['idordenventa']);
             $TipoCambio = $this->AutoLoadModel("TipoCambio");
             $dataTipoCambio = $TipoCambio->consultaDatosTCVigentexTCElegido($data[$i]['IdTipoCambioVigente']);
             $simboloMoneda = $dataTipoCambio[0]['simbolo'];
             $TC_PrecioVenta = $dataTipoCambio[0]['venta'];
             $acumulaxIdMoneda[$simboloMoneda]['Simbolo'] = $simboloMoneda;
             $acumulaxIdMoneda[$simboloMoneda]['MontoTotal'] += $montoGuia;
             $acumulaxIdMoneda[$simboloMoneda]['montoDevuelto'] += $data[$i]['importedevolucion'];
             $acumulaxIdMoneda[$simboloMoneda]['montoPagado'] += $data[$i]['importepagado'];
             $acumulaxIdMoneda[$simboloMoneda]['saldo'] += $montoGuia - $data[$i]['importepagado'];
             // $montoTotal+=$montoGuia;
             // $montoDevuelto+=$data[$i]['importedevolucion'];
             // $montoPagado+=$data[$i]['importepagado'];
             // $deuda=($montoGuia-$data[$i]['importepagado']);
             // $saldo+=$deuda;
             echo "<tr>";
             echo "<td>" . $data[$i]['codigov'] . "<input type='hidden' value='" . $data[$i]['codigov'] . "' class='codigov'></td>";
             echo "<td>" . $data[$i]['fordenventa'] . "</td>";
             if ($data[$i]['desaprobado'] == 1) {
                 echo "<td>Desaprobado</td>";
             } else {
                 echo "<td>" . $data[$i]['fechadespacho'] . "</td>";
             }
             echo "<td>" . $data[$i]['fechavencimiento'] . "</td>";
             echo "<td>" . $data[$i]['vendedor'] . "</td>";
             echo "<td>" . $simboloMoneda . "  " . number_format($montoGuia, 2) . "</td>";
             echo "<td>" . $simboloMoneda . "  " . number_format($data[$i]['importepagado'] - $data[$i]['importedevolucion'], 2) . "</td>";
             echo "<td>" . $simboloMoneda . "  " . number_format($data[$i]['importedevolucion'], 2) . "</td>";
             echo "<td>" . $simboloMoneda . "  " . number_format($montoGuia - $data[$i]['importepagado'], 2) . "</td>";
             echo "<td>" . $data[$i]['situacion'] . "</td>";
             echo "<td>" . $data[$i]['fechaCancelado'] . "</td>";
             echo "<td><a href=\"/ordencobro/buscarDetalleOrdenCobro/" . $data[$i]['idordenventa'] . "\" class=\"btnVerDetalleOrden\">Ver Programacion</a><br><a href='/ordenventa/DetalleGuiaMadre/" . $data[$i]['idordenventa'] . "' class='btnDetalleProducto' >Ver Productos</a></td>";
             //echo "<td><a href=\"/ordencobro/detalleOrdenCobroVistaGlobal/".$data[$i]['idordenventa']."\" class=\"btnVerDetalleOrden\">Ver Detalle</a></td>";
             echo "</tr>";
         }
         echo "<tr><th colspan=4> </th><th>Acumulado en  S/.  :</th><th>" . number_format($acumulaxIdMoneda['S/.']['MontoTotal'], 2) . "</th><th>" . number_format($acumulaxIdMoneda['S/.']['montoPagado'], 2) . "</th><th>" . number_format($acumulaxIdMoneda['S/.']['montoDevuelto'], 2) . "</th><th>" . number_format($acumulaxIdMoneda['S/.']['saldo'], 2) . "</th><th></th><th></th></tr>";
         # code...
         echo "<tr><th colspan=4> </th><th>Acumulado en  US \$ :</th><th>" . number_format($acumulaxIdMoneda['US $']['MontoTotal'], 2) . "</th><th>" . number_format($acumulaxIdMoneda['US $']['montoPagado'], 2) . "</th><th>" . number_format($acumulaxIdMoneda['US $']['montoDevuelto'], 2) . "</th><th>" . number_format($acumulaxIdMoneda['US $']['saldo'], 2) . "</th><th></th><th></th></tr>";
         # code...
     } else {
         echo "<tr>";
         echo "<td colspan=\"11\">No se encontraron ordenes de venta</td>";
         echo "</tr>";
     }
     //echo json_encode($data);
 }
예제 #3
0
 function regOrdenSalida()
 {
     if (!$_REQUEST['idOrdenVenta']) {
         $ordenVenta = new OrdenVenta();
         $opciones = new general();
         $actorrol = new actorrol();
         $url = "/" . $_REQUEST['url'];
         $data['Despachador'] = $actorrol->actoresxRol(30);
         $data['Verificador'] = $actorrol->actoresxRol(31);
         $data['Opcion'] = $opciones->buscaOpcionexurl($url);
         $data['Modulo'] = $opciones->buscaModulosxurl($url);
         $data['ordenVenta'] = $ordenVenta->pedidoxaprobar(5);
         $data['FormaPago'] = $this->formaPago();
         $this->view->show("/almacen/regordenpedido.phtml", $data);
     } else {
         $id = $_REQUEST['idOrdenVenta'];
         $dataOrdenVenta = $_REQUEST['Orden'];
         $ordenVenta = new OrdenVenta();
         $exito1 = $ordenVenta->actualizaOrdenVenta($dataOrdenVenta, $id);
         if ($exito1) {
             //grabamos las series
             $detOrden = $this->AutoLoadModel('detalleordenventa');
             $detalleOrdenVenta = $_REQUEST['DetalleOrdenVenta'];
             $cantidad = count($detalleOrdenVenta);
             for ($i = 0; $i < $cantidad; $i++) {
                 $data['serie'] = $detalleOrdenVenta[$i]['serie'];
                 $exito2 = $detOrden->actualizar($detalleOrdenVenta[$i]['iddetalleordenventa'], $data);
             }
             //graba el tiempo que demoro ser confirmado
             $ordenVentaDuracion = new ordenventaduracion();
             $DDA = $ordenVentaDuracion->listaOrdenVentaDuracion($id, "credito");
             $dataDuracion['idordenventa'] = $id;
             $intervalo = $this->date_diff(date('Y-m-d H:i:s', strtotime($DDA[0]['fechacreacion'])), date('Y-m-d H:i:s'));
             $dataDuracion['tiempo'] = $intervalo;
             if (empty($DDA[0]['fechacreacion'])) {
                 $dataDuracion['tiempo'] = 'indefinido';
             }
             $dataDuracion['referencia'] = 'despacho';
             $exitoN = $ordenVentaDuracion->grabaOrdenVentaDuracion($dataDuracion);
             //actualiza ordenventa su duracion total
             $DDAT = $ordenVentaDuracion->listaOrdenVentaDuracion($id, "creacion");
             $fechaInicio = $DDAT[0]['fechacreacion'];
             if (empty($fechaInicio)) {
                 $dt = $ordenVenta->buscaOrdenVenta($id);
                 $fechaInicio = $dt[0]['fechacreacion'];
             }
             $intervalo2 = $this->date_diff(date('Y-m-d H:i:s', strtotime($fechaInicio)), date('Y-m-d H:i:s'));
             $DOV['tiempoduracion'] = $intervalo2;
             $exitoN2 = $ordenVenta->actualizaOrdenVenta($DOV, $id);
             $ruta['ruta'] = "/almacen/regOrdenSalida";
             $this->view->show("ruteador.phtml", $ruta);
         }
     }
 }
예제 #4
0
 function ventas()
 {
     $idLinea = $_REQUEST['linea'];
     $idVendedor = $_REQUEST['vendedor'];
     $fInicial = $_REQUEST['fechaInicial'];
     $fFinal = $_REQUEST['fechaFinal'];
     $ordenVenta = new OrdenVenta();
     $data = $ordenVenta->listadoReporteVentas($idLinea, $idVendedor, $fInicial, $fFinal);
     $cantidadData = count($data);
     $pdf = new PDF_Mc_Table("L", "mm", "A4");
     $titulos = array('Fecha', 'Orden de Venta', 'Cliente', 'Importe', 'Saldo', 'Condicion', 'Vendedor', 'Vencimiento');
     $columnas = array('fordenventa', 'codigov', 'razonsocial', 'importeordencobro', 'importedoc', 'condicion', 'vendedor', 'fvencimiento');
     $ancho = array(20, 28, 75, 20, 18, 21, 70, 27);
     $orientacion = array('C', 'C', '', 'R', 'R', 'C', '', 'C');
     $pdf->_titulo = "Reporte de Ventas";
     $pdf->AddPage();
     $relleno = true;
     $pdf->SetFillColor(202, 232, 234);
     $pdf->SetTextColor(12, 78, 139);
     $pdf->SetDrawColor(12, 78, 139);
     $pdf->SetLineWidth(0.3);
     $pdf->SetFont('Helvetica', 'B', 8);
     $pdf->fill($relleno);
     //un arreglo con su medida  a lo ancho
     $pdf->SetWidths($ancho);
     //un arreglo con alineacion de cada celda
     $pdf->SetAligns($orientacion);
     for ($i = 0; $i < count($titulos); $i++) {
         $pdf->Cell($ancho[$i], 7, $titulos[$i], 1, 0, 'C', true);
     }
     $pdf->Ln();
     $pdf->SetFillColor(224, 235, 255);
     $pdf->SetTextColor(0);
     $pdf->SetFont('');
     for ($i = 0; $i < $cantidadData; $i++) {
         $fila = array($data[$i]['fordenventa'], $data[$i]['codigov'], utf8_decode($data[$i]['razonsocial']), $data[$i]['importeordencobro'], $data[$i]['importedoc'], $data[$i]['condicion'], utf8_decode($data[$i]['vendedor']), $data[$i]['fvencimiento']);
         $pdf->Row($fila);
         $relleno = !$relleno;
         $pdf->fill($relleno);
     }
     $pdf->AliasNbPages();
     $pdf->Output();
 }
예제 #5
0
 function misordenes()
 {
     $ordenVenta = new OrdenVenta();
     $datos['ordenVenta'] = $ordenVenta->listarxvendedor($_SESSION['idactor']);
     $this->view->show('/vendedor/misordenes.phtml', $datos);
 }
예제 #6
0
 function verificarCobro()
 {
     $idOrdenVenta = $_REQUEST['idOrdenVenta'];
     //$idOrdenVenta=$_REQUEST['id'];
     $ordencobro = new OrdenCobro();
     $ordenventa = new OrdenVenta();
     $dataOrdenCobro = $ordencobro->buscaxFiltro("idordenventa='{$idOrdenVenta}' and situacion='Pendiente'");
     if (empty($dataOrdenCobro)) {
         $data['situacion'] = "cancelado";
         $data['fechaCancelado'] = date('Y-m-d');
         $exito = $ordenventa->actualizaOrdenVenta($data, $idOrdenVenta);
         echo $exito;
     } else {
         $data['situacion'] = "Pendiente";
         $data['fechaCancelado'] = null;
         $exito = $ordenventa->actualizaOrdenVenta($data, $idOrdenVenta);
         echo $exito;
         echo $cantidadOrdenCobro;
     }
 }
예제 #7
0
 function listaordenes()
 {
     $ordenVenta = new OrdenVenta();
     $data['ordenVenta'] = $ordenVenta->listaOrdenesGeneral();
     $data['FormaPago'] = $this->formaPago();
     $this->view->show("/ventas/ordenesgeneral.phtml", $data);
 }
예제 #8
0
 function letras()
 {
     if (count($_REQUEST) == 6) {
         $this->view->show("/reporte/letras.phtml");
     } else {
         $ordenventa = new OrdenVenta();
         $idcliente = $_REQUEST['id'];
         $dordenventa = $ordenventa->listadoOrdenVentaxidcliente2($idcliente);
         $total = count($dordenventa);
         $cuenta = array();
         $indice = 0;
         for ($i = 0; $i < $total; $i++) {
             $saldo = $ordenventa->saldoxidordenventa($dordenventa[$i]['idordenventa']);
             $fvencimiento = $ordenventa->ultimafechaxidordenventa($dordenventa[$i]['idordenventa']);
             $cuenta[$indice]['codigov'] = $dordenventa[$i]['codigov'];
             $cuenta[$indice]['importeov'] = number_format($dordenventa[$i]['importeov'], 4);
             $cuenta[$indice]['idcondicionletra'] = $dordenventa[$i]['idcondicionletra'];
             $cuenta[$indice]['situacion'] = $saldo > 0 ? 'PENDIENTE' : 'CANCELADO';
             $cuenta[$indice]['fvencimiento'] = $fvencimiento;
             $cuenta[$indice]['saldo'] = number_format($saldo, 4);
             $cuenta[$indice]['importedoc'] = "";
             $cuenta[$indice]['formacobro'] = "";
             $cuenta[$indice]['situacionc'] = "";
             $cuenta[$indice]['fvencimientoc'] = "";
             $indice += 1;
             $dcuenta = $ordenventa->cuentasxidordenventa($dordenventa[$i]['idordenventa']);
             $total2 = count($dcuenta);
             for ($j = 0; $j < $total2; $j++) {
                 if ($dcuenta[$j]['formacobro'] == 3) {
                     $cuenta[$indice]['codigov'] = $dordenventa[$i]['codigov'];
                     $cuenta[$indice]['importeov'] = "";
                     $cuenta[$indice]['idcondicionletra'] = "";
                     $cuenta[$indice]['situacion'] = "";
                     $cuenta[$indice]['fvencimiento'] = "";
                     $cuenta[$indice]['saldo'] = "";
                     $cuenta[$indice]['importedoc'] = number_format($dcuenta[$j]['importedoc'], 4);
                     $cuenta[$indice]['formacobro'] = $dcuenta[$j]['formacobro'] == 1 ? 'CONTADO' : ($dcuenta[$j]['formacobro'] == 4 ? 'LETRA' : 'CREDITO');
                     $cuenta[$indice]['situacionc'] = $dcuenta[$j]['situacion'] == 0 ? 'PENDIENTE' : ($dcuenta[$j]['situacion'] == 1 ? 'CANCELADO' : 'DESDOBLADO');
                     $cuenta[$indice]['fvencimientoc'] = $dcuenta[$j]['fvencimiento'];
                     $indice += 1;
                 }
             }
         }
         $objeto = $this->formatearparakui($cuenta);
         header("Content-type: application/json");
         //echo "{\"data\":" .json_encode($objeto). "}";
         echo json_encode($objeto);
     }
 }
예제 #9
0
 function aprobarPedido()
 {
     if (!isset($_REQUEST['idOrden'])) {
         $orden = new OrdenVenta();
         $data['ordenVenta'] = $orden->pedidoxaprobar(2);
         $data['FormaPago'] = $this->formaPago();
         $this->view->show("cobranza/aprobarpedido.phtml", $data);
     } else {
         $id = $_REQUEST['idOrden'];
         $estadoOrden = $_REQUEST['estadoOrden'];
         $dataOrdenVenta = $_REQUEST['Orden'];
         $ordenVenta = new OrdenVenta();
         $producto = new Producto();
         $dataOrdenVenta['vbcobranzas'] = $estadoOrden;
         if ($estadoOrden == 2) {
             $dataOrdenVenta['desaprobado'] = 1;
         }
         $productos = $_REQUEST['Producto'];
         $cantidadProducto = count($productos);
         $exito1 = $ordenVenta->actualizaOrdenVenta($dataOrdenVenta, $id);
         if ($exito1) {
             if ($estadoOrden == 2) {
                 for ($i = 0; $i < $cantidadProducto; $i++) {
                     //buscamos producto
                     $idproducto = $productos[$i]['idproducto'];
                     $dataProducto = $producto->buscaProductoxId($idproducto);
                     $stockdisponibleA = $dataProducto[0]['stockdisponible'];
                     $stockdisponibleN = $stockdisponibleA + $productos[$i]['cantaprobada'];
                     $dataNuevo['stockdisponible'] = $stockdisponibleN;
                     //actualizamos es stockdisponible
                     $exitoP = $producto->actualizaProducto($dataNuevo, $idproducto);
                 }
             }
             $ordenVentaDuracion = new ordenventaduracion();
             $DDA = $ordenVentaDuracion->listaOrdenVentaDuracion($id, "ventas");
             $dataDuracion['idordenventa'] = $id;
             $intervalo = $this->date_diff(date('Y-m-d H:i:s', strtotime($DDA[0]['fechacreacion'])), date('Y-m-d H:i:s'));
             $dataDuracion['tiempo'] = $intervalo;
             $dataDuracion['referencia'] = 'cobranza';
             if (empty($DDA[0]['fechacreacion'])) {
                 $dataDuracion['tiempo'] = 'indefinido';
             }
             $exito3 = $ordenVentaDuracion->grabaOrdenVentaDuracion($dataDuracion);
             $ruta['ruta'] = "/cobranza/aprobarpedido";
             $this->view->show("ruteador.phtml", $ruta);
         }
     }
 }
예제 #10
0
 function generaLetras()
 {
     $NumeroOrdenVenta = $_REQUEST['ordenVenta'];
     $condicionLetras = $_REQUEST['condicionLetras'];
     $ordenVenta = new OrdenVenta();
     $dataOrdenVenta = $ordenVenta->buscarxid($NumeroOrdenVenta);
     $dataCondicionLetras = $this->buscaCondicionLetra($condicionLetras);
     $arrayCondicionLetras = explode("/", $dataCondicionLetras);
     $actualDate = date("d-m-Y");
     for ($i = 0; $i < $condicionLetras; $i++) {
         echo "<tr>";
         echo "<td>" . ($i + 1) . "</td>";
         echo "<td>" . date("d-m-Y", strtotime("{$actualDate} + " . $arrayCondicionLetras[$i] . " day")) . "</td>";
         echo "<td>" . number_format($dataOrdenVenta[0]['importe'] / $condicionLetras, 2) . "</td>";
         echo "<tr>";
     }
 }