Ejemplo n.º 1
0
 function kardexValorizadoxProducto()
 {
     $idLast = (int) $_REQUEST['idproducto'];
     $mesInicial = !empty($_REQUEST['mesInicial']) ? $_REQUEST['mesInicial'] : 1;
     $mesFinal = !empty($_REQUEST['mesFinal']) ? $_REQUEST['mesFinal'] : 12;
     $ano = !empty($_REQUEST['ano']) ? $_REQUEST['ano'] : date('Y');
     $sunat = $_REQUEST['sunat'];
     $_REQUEST['fecha1oo'] = $fecha1;
     for ($x = 1; $x < $idLast; $x++) {
         $producto = new Producto();
         $movimiento = new Movimiento();
         $almacen = new Almacen();
         //		if ($_REQUEST['id']) {
         $dataBusqueda = $producto->buscarxID($x);
         $idalmacen = (int) $dataBusqueda[0]['idalmacen'];
         $dataAlmacen = $almacen->buscaAlmacen($idalmacen);
         $dataKardex = $movimiento->kardexValorizadoxProducto($x, $ano, $mesInicial, $mesFinal, $sunat);
         $total = count($dataKardex);
         if ($total > 0) {
             //                 echo"<h2>".$dataBusqueda[0]['nompro']."</h2></br>";
             //echo"<h2>".$dataAlmacen[0]['nomalm']."</h2></br>";
             echo "<table style='margin-bottom:0px'>";
             echo "<caption>";
             echo "<h2>Formato 13.1 : Registro de Inventario Permanente Valorizado</h2>";
             echo "</caption>";
             echo "<tr>";
             echo "<td style='width:30%;text-align: left;'>PERIODO : </td><td style='width:70%;text-align: left;'><label id='labelPeriodo'>" . $ano . "</td>";
             echo "</tr>";
             echo "<tr>";
             echo "<td style='width:30%;text-align: left;'>RUC : </td><td style='width:70%;text-align: left;'><label id='labelRuc'>" . $dataAlmacen[0]['rucalm'] . "</label></td>";
             echo "</tr>";
             echo "<tr>";
             echo "<td style='width:30%;text-align: left;'>RAZON SOCIAL : </td><td style='width:70%;text-align: left;'><label id='labelRazonSocial'>" . $dataAlmacen[0]['razsocalm'] . "</label></td>";
             echo "</tr>\n\t\t<tr>\n\t\t\t<td style='width:30%;text-align: left;'>ESTABLECIMIENTO : </td><td style='width:70%;text-align: left;'><label id='labelalmacen'>ALMACEN GENERAL</label></td>\n\t\t</tr>\n\t\t<tr>\n\t\t\t<td style='width:30%;text-align: left;'>CODIGO DE LA EXISTENCIA : </td><td style='width:70%;text-align: left;'><label id='labelCodigo'>" . $dataBusqueda[0]['codigopa'] . "</label></td>\n\t\t</tr>\n\t\t<tr>\n\t\t\t<td style='width:30%;text-align: left;'>TIPO : </td><td style='width:70%;text-align: left;'><label id='labelTipo'>MERCADERIAS</label></td>\n\t\t</tr>\n\t\t<tr>\n\t\t\t<td style='width:30%;text-align: left;'>DESCRIPCION : </td><td style='width:70%;text-align: left;'><label id='labelProducto'>" . $dataBusqueda[0]['nompro'] . "</label></td>\n\t\t</tr>\n\t\t<tr>\n\t\t\t<td style='width:30%;text-align: left;'>UNIDAD DE MEDIDA : </td><td style='width:70%;text-align: left;'><label id='labelUnidadMedida'>UNIDAD</label></td>\n\t\t</tr>\n\t\t<tr>\n\t\t\t<td style='width:30%;text-align: left;'>METODO DE VALUACION : </td><td style='width:70%;text-align: left;'><label id='labelMetodo'PROMEDIO MOVIL</label></td>\n\t\t</tr>";
             echo "</table>";
             echo "<table id='tblKardexValorizado'>";
             echo "<thead>";
             echo "<tr>";
             echo "<th rowspan='2' class='text-10'>Nro</th>";
             echo "<th rowspan='2' class='text-30'>Fecha</th>";
             echo "<th rowspan='2' class='text-30'>Tipo Doc</th>";
             echo "<th rowspan='2' class='text-30'>Serie</th>";
             echo "<th rowspan='2' class='text-30'>Núm</th>";
             echo "<th rowspan='2' class='text-30'>Tipo<br>Mov.</th>";
             echo "<th colspan=3>ENTRADAS </th>";
             echo "<th colspan=3>SALIDAS</th>";
             echo "<th colspan=3>SALDO FINAL</th>";
             echo "</tr>";
             echo "<tr>";
             echo "<td >Cantidad</td>";
             echo "<td>Costo<br>Unit. (S/.)</td>";
             echo "<td class='text-100'>Costo Total (S/.)</td>";
             echo "<td>Cantidad</td>";
             echo "<td>Costo<br>Unit. (S/.)</td>";
             echo "<td class='text-100'>Costo Total (S/.)</td>";
             echo "<th>Cantidad</th>";
             echo "<th>Costo<br>Uni. (S/.)</th>";
             echo "<th class='text-100'>Costo Total (S/.)</th>\t\t\t\t\t\t\t\t\n\t\t\t</tr>\t\n\t\t</thead>";
             $tecant = 0;
             $tecosto = 0;
             $tscant = 0;
             $tscosto = 0;
             $cont = 0;
             if ($dataKardex[0]['codigotipooperacion'] != 16) {
                 echo "<tr>";
                 echo "<td></td>";
                 echo "<td colspan='4'>Saldo Inicial</td>";
                 echo "<td>16</td>";
                 echo "<td></td>";
                 echo "<td></td>";
                 echo "<td></td>";
                 echo "<td></td>";
                 echo "<td></td>";
                 echo "<td></td>";
                 if ($dataKardex[0]['tipomovimiento'] == 1) {
                     $cantidad = round($dataKardex[0]['SaldoCantidad'] - round($dataKardex[0]['cantidad']));
                     if ($cantidad < 0) {
                         $cantidad = 0;
                     }
                 } else {
                     $cantidad = round($dataKardex[0]['SaldoCantidad'] + round($dataKardex[0]['cantidad']));
                 }
                 echo "<td>" . $cantidad . "</td>";
                 echo "<td>" . $dataKardex[0]['SaldoPrecio'] . "</td>";
                 echo "<td>" . round($dataKardex[0]['SaldoPrecio'] * $cantidad, 2) . "</td>";
                 echo "</tr>";
             }
             for ($i = 0; $i < $total; $i++) {
                 echo "<tr>";
                 if ($dataKardex[$i]['codigotipooperacion'] == 16) {
                     echo "<td></td>";
                     echo "<td colspan='4'>Saldo Inicial</td>";
                 } else {
                     $cont++;
                     echo "<td>" . $cont . "</td>";
                     echo "<td>" . $dataKardex[$i]['fechamovimiento'] . "</td>";
                     echo "<td>" . $dataKardex[$i]['codigotipodocumento'] . "</td>";
                     echo "<td>" . $dataKardex[$i]['serie'] . "</td>";
                     echo "<td>" . $dataKardex[$i]['ndocumento'] . "</td>";
                 }
                 $cantidad = $cantidad - $dataKardex[$i]['SalidaCantidad'];
                 echo "<td style='text-align:center'>" . $dataKardex[$i]['codigotipooperacion'] . "</td>";
                 echo "<td style='text-align:center'>" . $dataKardex[$i]['EntradaCantidad'] . "</td>";
                 echo "<td style='text-align:right'>" . (empty($dataKardex[$i]['EntradaPrecio']) ? '' : number_format($dataKardex[$i]['EntradaPrecio'], 2)) . "</td>";
                 echo "<td style='text-align:right'>" . (empty($dataKardex[$i]['EntradaCosto']) ? '' : number_format($dataKardex[$i]['EntradaCosto'], 2)) . "</td>";
                 echo "<td style='text-align:center'>" . $dataKardex[$i]['SalidaCantidad'] . "</td>";
                 echo "<td style='text-align:right'>" . (empty($dataKardex[$i]['SalidaPrecio']) ? '' : number_format($dataKardex[$i]['SalidaPrecio'], 2)) . "</td>";
                 echo "<td style='text-align:right'>" . (empty($dataKardex[$i]['SalidaCosto']) ? '' : number_format($dataKardex[$i]['SalidaCosto'], 2)) . "</td>";
                 echo "<td style='text-align:center'>" . $cantidad . "</td>";
                 echo "<td style='text-align:right'>" . (empty($dataKardex[$i]['SaldoPrecio']) ? '' : number_format($dataKardex[$i]['SaldoPrecio'], 2)) . "</td>";
                 echo "<td style='text-align:right'>" . (empty($dataKardex[$i]['SaldoCosto']) ? '' : number_format($dataKardex[$i]['SaldoCosto'], 2)) . "</td>";
                 echo "</tr>";
                 $tecant = $cantidad + $dataKardex[$i]['EntradaCantidad'];
                 $tecosto += $dataKardex[$i]['EntradaCosto'];
                 $tscant += $dataKardex[$i]['SalidaCantidad'];
                 $tscosto += $dataKardex[$i]['SalidaCosto'];
             }
             echo "<tr>";
             echo "<td colspan=6></td>";
             echo "<th style='text-align:center'>" . round($tecant) . "</td>";
             echo "<td></td>";
             echo "<th style='text-align:right'>" . number_format($tecosto, 2) . "</td>";
             echo "<th style='text-align:center'>" . round($tscant) . "</td>";
             echo "<td></td>";
             echo "<th style='text-align:right'>" . number_format($tscosto, 2) . "</td>";
             echo "<td colspan=3></td>";
             echo "</tr>";
             echo "</table>";
         }
         //		}
     }
     exit;
     $tecant = 0;
     $tecosto = 0;
     $tscant = 0;
     $tscosto = 0;
     $cont = 0;
     $cantidad = 0;
     if ($dataKardex[0]['codigotipooperacion'] != 16) {
         echo "<tr>";
         echo "<td></td>";
         echo "<td colspan='4'>Saldo Inicial</td>";
         echo "<td>16</td>";
         echo "<td></td>";
         echo "<td></td>";
         echo "<td></td>";
         echo "<td></td>";
         echo "<td></td>";
         echo "<td></td>";
         if ($dataKardex[0]['tipomovimiento'] == 1) {
             $cantidad = round($dataKardex[0]['SaldoCantidad'] - round($dataKardex[0]['cantidad']));
             if ($cantidad < 0) {
                 $cantidad = 0;
             }
         } else {
             //$cantidad=round($dataKardex[0]['SaldoCantidad']+round($dataKardex[0]['cantidad']));
             $cantidad = 461;
         }
         echo "<td>" . $cantidad . "</td>";
         echo "<td>" . $dataKardex[0]['SaldoPrecio'] . "</td>";
         echo "<td>" . round($dataKardex[0]['SaldoPrecio'] * $cantidad, 2) . "</td>";
         echo "</tr>";
     }
     for ($i = 0; $i < $total; $i++) {
         echo "<tr>";
         if ($dataKardex[$i]['codigotipooperacion'] == 16) {
             echo "<td></td>";
             echo "<td colspan='4'>Saldo Inicial</td>";
         } else {
             $cont++;
             echo "<td>" . $cont . "</td>";
             echo "<td>" . $dataKardex[$i]['fechamovimiento'] . "</td>";
             echo "<td>" . $dataKardex[$i]['codigotipodocumento'] . "</td>";
             echo "<td>" . $dataKardex[$i]['serie'] . "</td>";
             echo "<td>" . $dataKardex[$i]['ndocumento'] . "</td>";
         }
         $cantidad = $cantidad - $dataKardex[$i]['SalidaCantidad'];
         echo "<td style='text-align:center'>" . $dataKardex[$i]['codigotipooperacion'] . "</td>";
         echo "<td style='text-align:center'>" . $dataKardex[$i]['EntradaCantidad'] . "</td>";
         echo "<td style='text-align:right'>" . (empty($dataKardex[$i]['EntradaPrecio']) ? '' : number_format($dataKardex[$i]['EntradaPrecio'], 2)) . "</td>";
         echo "<td style='text-align:right'>" . (empty($dataKardex[$i]['EntradaCosto']) ? '' : number_format($dataKardex[$i]['EntradaCosto'], 2)) . "</td>";
         echo "<td style='text-align:center'>" . $dataKardex[$i]['SalidaCantidad'] . "</td>";
         echo "<td style='text-align:right'>" . (empty($dataKardex[$i]['SalidaPrecio']) ? '' : number_format($dataKardex[$i]['SalidaPrecio'], 2)) . "</td>";
         echo "<td style='text-align:right'>" . (empty($dataKardex[$i]['SalidaCosto']) ? '' : number_format($dataKardex[$i]['SalidaCosto'], 2)) . "</td>";
         echo "<td style='text-align:center'>" . $cantidad . "</td>";
         echo "<td style='text-align:right'>" . (empty($dataKardex[$i]['SaldoPrecio']) ? '' : number_format($dataKardex[$i]['SaldoPrecio'], 2)) . "</td>";
         echo "<td style='text-align:right'>" . (empty($dataKardex[$i]['SaldoCosto']) ? '' : number_format($dataKardex[$i]['SaldoCosto'], 2)) . "</td>";
         echo "</tr>";
         $tecant = $cantidad + $dataKardex[$i]['EntradaCantidad'];
         $tecosto += $dataKardex[$i]['EntradaCosto'];
         $tscant += $dataKardex[$i]['SalidaCantidad'];
         $tscosto += $dataKardex[$i]['SalidaCosto'];
     }
     echo "<tr>";
     echo "<td colspan=6></td>";
     echo "<th style='text-align:center'>" . round($tecant) . "</td>";
     echo "<td></td>";
     echo "<th style='text-align:right'>" . number_format($tecosto, 2) . "</td>";
     echo "<th style='text-align:center'>" . round($tscant) . "</td>";
     echo "<td></td>";
     echo "<th style='text-align:right'>" . number_format($tscosto, 2) . "</td>";
     echo "<td colspan=3></td>";
     echo "</tr>";
 }