function mostrar_transacciones($fecha_inicio, $fecha_fin, $user) { $database = new DB(); //$fecha=fechaplusweek($fecha); $total_pagos = ceil($total / $abono); echo "\n\n\t\t\t\t\t<div>\n\t\t\t\t\t\t<table class=\"table table-condensed striped\" width=100% >\n\t\t\t\t\t\t\t <thead>\n\t\t\t\t\t\t\t\t <tr>\n\t\t\t\t\t\t\t\t\t <th style='text-align:right'>Id</th>\n\t\t\t\t\t\t\t\t\t <th style='text-align:center'>Fecha</th>\n\t\t\t\t\t\t\t\t\t <th style='text-align:center'>Movimiento</th>\n\t\t\t\t\t\t\t\t\t <th style='text-align:center'>Total</th>\n\t\t\t\t\t\t\t\t\t <th style='text-align:center'>Cliente</th>\n\t\t\t\t\t\t\t\t </tr>\n\t\t\t\t\t\t\t </thead>\n\t\t\t\t\t\t\t <tbody>"; $fecha_inicio_bd = $fecha_inicio; $fecha_fin_bd = $fecha_fin; $query = "SELECT * from movimiento,tipomov,admin,cliente\n\t\twhere movimiento.tipomov_id=tipomov.tipomov_id AND movimiento.admin_id=admin.admin_id AND (movimiento.tipomov_id=1 OR movimiento.tipomov_id=13 or movimiento.tipomov_id=14)\n AND movimiento.cliente_id=cliente.cliente_id AND cliente.empresa_id=0"; if ($fecha_inicio) { $query .= " AND fecha>='{$fecha_inicio_bd}' AND fecha<='{$fecha_fin_bd} 23:59:59' "; } if ($user) { $query .= " AND movimiento.admin_id={$user} "; } $query .= " ORDER BY fecha DESC"; $results = $database->get_results($query); foreach ($results as $item) { $vendedor = $item['nombre'] . " " . $item['apellidop']; echo "<tr><td style='text-align:right' width=30 >" . $item['movimiento_id'] . "</td>\n\t\t\t\t\t\t<td style='text-align:center'><span class='hidden-desktop'>" . fechamysqltous($item['fecha']) . "</span><a class='hidden-print' href=/index.php?data=estadisticas&op=ventas&fi=" . fechamysqltous($fecha_inicio) . "&hi={$hi}&ff=" . fechamysqltous($fecha_fin) . "&hf={$hf}&fid=" . $item['factura_id'] . ">" . fechamysqltomx($item['fecha'], "letra") . "</a></td>\n\t\t\t\t\t\t\t<td style='text-align:center'>" . $item['tipomov'] . "\n\t\t\t\t\t\t\t<br></td>\n\t\t\t\t\t\t\t<td style='text-align:right'>\$ " . dinero($item['cantidad'] + $item['iva']) . "</td>\n\t\t\t\t\t\t\t<td style='text-align:right'>" . $vendedor; echo " </td></tr>"; $n++; } echo " </tbody>\n\t\t</table> "; //echo "Pagos Atrazados: ".$pagos_atrazados; echo "</div>"; }
function autocupon($factura_id) { $database = new DB(); $query = "SELECT cantidad,sku,cupontipo_id,fecha_fin,compra_minima from cupones where factura_id='{$factura_id}'"; list($cantidad, $cupon_sku, $cupontipo_id, $fecha_fin, $compra_minima) = $database->get_row($query); if ($cantidad) { echo "<table width=310 style='border:2px dotted black'>"; echo "<tr><td align=center>CUPON</td></tr>"; echo "<tr><td align=center>BUENO POR</td></tr>"; echo "<tr><td align=center><font size=+3><b>\$ " . dinero($cantidad) . " MX<b></font></td></tr>"; echo "<tr><td align=center>Compra Minima: \$ " . dinero($compra_minima) . " MX</td></tr>"; echo "<tr><td align=center><font size=-1>Valido hasta: " . fechamysqltomx($fecha_fin, "letra") . "</center></font></td></tr>"; echo "<tr><td align=center> <img width=310 src=\"barcode.php?text=" . $cupon_sku . "\" alt=\"barcode\" /></td></tr>"; echo "<tr><td align=center><font size=-1>Promocion no reembolsable en efectivo, ni combinable con otras promociones\n o cupones. <br>No aplica con productos en LIQUIDACION</font></td></tr>"; echo "</table>"; return $cupon_sku; } else { return ""; } }
function movimientos($cliente_id, $saldo) { $database = new DB(); $fecha_hoy = date("Y-m-d H:i:s"); $fecha = fechaminusmonth($fecha_hoy, 3); $query = "SELECT sum(cantidad) FROM cliente,movimiento,admin,tipomov \n\t\twhere movimiento.cliente_id={$cliente_id} AND movimiento.tipomov_id=tipomov.tipomov_id AND movimiento.cliente_id=cliente.cliente_id \n\t\tAND movimiento.admin_id=admin.admin_id AND fecha >= '{$fecha}' AND tipomov.tmov=1 ORDER BY movimiento.fecha ASC limit 100"; list($total_abonos) = $database->get_row($query); $query = "SELECT sum(cantidad) FROM cliente,movimiento,admin,tipomov \n\t\twhere movimiento.cliente_id={$cliente_id} AND movimiento.tipomov_id=tipomov.tipomov_id AND movimiento.cliente_id=cliente.cliente_id \n\t\tAND movimiento.admin_id=admin.admin_id AND fecha >= '{$fecha}' AND tipomov.tmov=0 ORDER BY movimiento.fecha ASC limit 100"; list($total_cargos) = $database->get_row($query); $query = "SELECT factura_id,fecha, cantidad, tipomov.tipomov,tmov, admin.nombre,total_ultimo FROM cliente,movimiento,admin,tipomov \n\t\twhere movimiento.cliente_id={$cliente_id} AND movimiento.tipomov_id=tipomov.tipomov_id AND movimiento.cliente_id=cliente.cliente_id \n\t\tAND movimiento.admin_id=admin.admin_id AND fecha >= '{$fecha}' ORDER BY movimiento.fecha ASC limit 100"; $saldo = $saldo + $total_cargos - $total_abonos; $results = $database->get_results($query); $i = 0; foreach ($results as $row) { if ($row['tmov'] == 0 || $row['tmov'] == 1) { $i += 1; if ($row['tmov'] == 0) { $saldo -= $row['cantidad']; } if ($row['tmov'] == 1) { $saldo += $row['cantidad']; } echo "<tr >\n\t\t\t<td align=right><font > {$i} </td>\n\t\t\t<td><a class=\"hidden-print\" href=\"/index.php?data=clientes&op=factura&fid=" . $row['factura_id'] . "\">" . $row['fecha'] . "<a>\n\t\t\t\t<a class=\"visible-print\" >" . fechamysqltomx($row['fecha'], 1) . "<a>\n\t\t\t </td>"; if ($row['tmov'] == 0) { echo "<td align=center>---</td>\n\t\t\t\t<td align=right> <font >" . $row['cantidad'] . " </td>"; } if ($row['tmov'] == 1) { echo "\n\t\t\t\t<td align=right> <font >" . $row['cantidad'] . " </td>\n\t\t\t\t<td align=center>---</td>"; } $row['admin_id'] = isset($row['admin_id']) ? $row['admin_id'] : ''; echo "<td><font ><b>" . dinero($saldo) . "</td>\n\t\t\t<td><font >" . $row['tipomov'] . "</td>"; "<td hidden> <font >" . $row['admin_id'] . "</td>"; echo "</tr>"; } } }
if ($bulk) { $query .= " AND bulk={$bulk}"; } $results = $database->get_results($query); echo "<table>"; foreach ($results as $row) { echo "<tr><td>"; switch ($row['cupontipo_id']) { case 1: echo "\$ " . dinero($row['cantidad']) . " MX"; break; case 2: echo $row['cantidad'] . " %"; break; } echo ",*" . strtoupper($row['sku']) . "*," . fechamysqltomx($row['fecha_ini'], "letra") . "," . fechamysqltomx($row['fecha_fin'], "letra"); echo ",\$ " . dinero($row['compra_minima']) . " MX<td><tr>"; } echo "</table>"; } if ($location) { header($location); } function generar_cupones($cuid, $cuantos, $admin_id, $fecha_ini, $fecha_fin) { $array = isset($array) ? $array : ""; $database = new DB(); echo $query = "SELECT cupon_id,cantidad,cupontipo_id,compra_minima FROM cupon WHERE cupon_id='{$cuid}' limit 1"; list($cupon_id, $cantidad, $cupontipo_id, $compra_minima) = $database->get_row($query); $query = "SELECT sku FROM cupones ORDER BY sku DESC limit 1"; list($sku) = $database->get_row($query);
<div class="text"><br> <span>$ <?php echo dinero($row['cantidad']); ?> MX</span> <br> COMPRA MINIMA: $ <?php echo dinero($row['compra_minima']); ?> MX <br> <?php if ($row['fecha_ini'] <= date("Y-m-d")) { echo "<h2>Vence: " . fechamysqltomx($row['fecha_fin'], "letra") . "</h2>"; } else { echo "<h2>Vigencia " . fechamysqltomx($row['fecha_ini'], "letra") . " al " . fechamysqltomx($row['fecha_fin'], "letra") . "</h2>"; } ?> </div> <div class="footer"> <?php echo "<img width=320 src=\"barcode_cupon.php?text=" . $row['sku'] . "\" alt=\"barcode\" />"; ?> Terminos y condiciones al reverso. </div> </div> </div> <?php
</div><!--/span--> <div class="row-fluid condensed"> <?php $fecha_limite = fechaminusmonth(date("Y-m-d"), 3); ?> <div class="box span6"> <div class="box-header"> <h2><i class="halflings-icon align-justify"></i><span class="break"></span>Movimientos desde <?php echo fechamysqltomx($fecha_limite, "letra"); ?> </h2> <div class="box-icon"> <a href="#" class="btn-setting"><i class="halflings-icon wrench"></i></a> <a href="#" class="btn-minimize"><i class="halflings-icon chevron-up"></i></a> <a href="#" class="btn-close"><i class="halflings-icon remove"></i></a> </div> </div> <div class="box-content"> <table class="table table-striped"> <thead> <tr> <th>ID</th> <th>Fecha</th>
<!--td><a href=index.php?data=clientes&op=detalles&cid=<?php echo $row['cupon']; ?> ><?php echo strtoupper($row['cupon']); ?> </a></td--> <td class="center"><?php echo $row['sku']; ?> </td> <td class="center"><?php echo fechamysqltomx($row['fecha_ini'], "letra"); ?> <br><?php echo fechamysqltomx($row['fecha_fin'], "letra"); ?> </td> <?php if ($row['cupontipo_id'] == 1) { echo "<td class=\"center\">\$ " . dinero($row['cantidad']) . " MX"; } else { echo "<td class=\"center\"> " . dinero($row['cantidad']) . " %"; } echo "<br>CM: \$ " . dinero($row['compra_minima']) . " </td>"; if ($activo) { echo "<td><i class=\"icon-check\"></i></td>"; } else {
function plandepagos($total, $fecha, $abono, $saldo) { //$fecha=fechaplusweek($fecha); $total_pagos = ceil($total / $abono); echo "\n\t\t\t\t\t<div class=\"box-header\">\n\t\t\t\t\t\t<h2></span>Plan de Pagos</h2>\n\t\t\t\t\t\t<div class=\"box-icon\">\n\t\t\t\t\t\t\t<a href=\"#\" class=\"btn-setting\"><i class=\"halflings-icon wrench\"></i></a>\n\t\t\t\t\t\t\t<a href=\"#\" class=\"btn-minimize\"><i class=\"halflings-icon chevron-up\"></i></a>\n\t\t\t\t\t\t\t<a href=\"#\" class=\"btn-close\"><i class=\"halflings-icon remove\"></i></a>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</div>\n\t\t\t\t\t<div>\n\t\t\t\t\t\t<table class=\"table table-condensed striped\" width=100%>\n\t\t\t\t\t\t\t <thead>\n\t\t\t\t\t\t\t\t <tr>\n\t\t\t\t\t\t\t\t\t <th style='text-align:right'>Num</th>\n\t\t\t\t\t\t\t\t\t <th style='text-align:center'>Vence</th>\n\t\t\t\t\t\t\t\t\t <th style='text-align:right'>Abono</th>\n\t\t\t\t\t\t\t\t\t <th style='text-align:right'>Saldo</th>\n\t\t\t\t\t\t\t\t\t <th></th> \n\t\t\t\t\t\t\t\t </tr>\n\t\t\t\t\t\t\t </thead> \n\t\t\t\t\t\t\t <tbody>"; $c = isset($c) ? $c : '0'; echo "<tr ><td style='text-align:right'>" . $c . "</td>\n\t\t\t<td style='text-align:center'> " . fechamysqltomx($fecha, 1) . "</td>\n\t\t\t<td style='text-align:right'>----</td>\n\t\t\t<td style='text-align:right'>" . dinero($total) . "</td>\n\t\t\t<td style='text-align:right'><font color=gray> </td></tr>"; $c = 1; $pagos_atrazados = 0; //$total-=$abono; $saldo_temp = $total - $saldo; for ($i = 1; $i < $total_pagos; $i++) { $fecha = fechaplusweek($fecha); if ($saldo_temp > $abono) { $ultimo = $abono; } else { $ultimo = $saldo_temp; } if ($total >= $saldo + $abono) { $atributo_begin = "<s>"; $atributo_end = "</s>"; } else { $atributo_begin = $atributo_end = ""; if ($ultimo < $saldo && $fecha < date("Y-m-d")) { $atributo_begin = "<font color=red><b><i>"; $atributo_end = "</i></b></font>"; $pagos_atrazados += 1; } else { $atributo_begin = $atributo_end = ""; } } echo "<tr><td style='text-align:right'>" . $c . "</td>\n\t\t\t<td style='text-align:center'>{$atributo_begin}" . fechamysqltomx($fecha, 1) . "{$atributo_end}</td>\n\t\t\t<td style='text-align:right'> {$atributo_begin}" . dinero($abono) . "{$atributo_end} </td>\n\t\t\t<td style='text-align:right'>" . dinero($total - $abono) . "</td>\n\t\t\t<td style='text-align:right'><font color=gray>{$atributo_begin}" . dinero($ultimo) . "{$atributo_end}</font> </td></tr>"; $total = $total - $abono; $c++; if ($saldo_temp <= $abono) { $saldo_temp = 0; } if ($saldo_temp > $abono) { $saldo_temp = $saldo_temp - $abono; } } if ($total) { $abono = $total; $total = 0; echo "<tr ><td style='text-align:right'>" . $c . "</td>\n\t\t\t<td style='text-align:center'> " . fechamysqltomx(fechaplusweek($fecha), 1) . "</td>\n\t\t\t<td style='text-align:right'>" . dinero($abono) . "</td>\n\t\t\t<td style='text-align:right'>" . dinero($total) . "</td>\n\t\t\t<td style='text-align:right'><font color=gray> " . dinero($ultimo) . " </td></tr>"; } echo " </tbody>\n\t\t</table> "; //echo "Pagos Atrazados: ".$pagos_atrazados; echo "</div>"; }
echo "<tr><td ><center><b><span style='font-size:12pt'>Valido: " . fechamysqltomx($fecha_ini, "letra") . " - " . fechamysqltomx($fecha_fin, "letra") . "</span></B></center></td></tr>"; if ($fecha_fin < date("Y-m-d")) { echo "<tr><td><center><span class=\"label label-important\">EXPIRADO</span></B></center></td></tr>"; } // else echo "<tr><td><center><b>Valido: ".fechamysqltomx($fecha_ini,"letra")." - ".fechamysqltomx($fecha_fin,"letra")."</B></center></td></tr>"; if (strtotime(date("Y-m-d")) < strtotime($fecha_ini)) { echo "<tr bgcolor=yellow><td ><center>Error Fecha: Todavia no se puede usar</center></td></tr>"; } if (!$activo) { echo "<tr bgcolor=yellow><td ><center>Status: Sin Activar</center></td></tr>"; } if ($cliente_id) { echo "<tr bgcolor=yellow><td ><center>Solo Aplica en VENTAS DE CONTADO</center></td></tr>"; } if ($usado) { echo "<tr><td > <center><span class=\"label label-important\">Usado el: " . fechamysqltomx($fecha_uso, "letra") . "</span><center></td></tr>"; } echo "</table><br>"; if (count($_SESSION['cart']) > 0 && dinero($total_contado) >= dinero($compra_minima)) { echo "<a href='/index.php?data=pos' class='btn' data-dismiss='modal'>CANCELAR</a> "; if (strtotime($fecha_fin) >= strtotime(date("Y-m-d")) && strtotime(date("Y-m-d")) >= strtotime($fecha_ini) && !$cliente_id && !$usado && $activo) { echo "<a href='/functions/cart.php?func=apply_cupon&cupon_sku={$sku}' class=\"btn btn-primary\" >APLICAR</a>"; } } echo "</center>"; } else { echo "no existe"; } break; default: ////////////////**************** descripcion del producto marcado***************//////////////////
list($abonos) = $database->get_row($query); $query = "SELECT sum(cantidad) as total from movimiento,cliente\n\twhere movimiento.tipomov_id=1 AND fecha>='" . $fecha_inicio . "' AND fecha<='" . $fecha_final . " 23:59:59'\n AND movimiento.cliente_id=cliente.cliente_id AND cliente.empresa_id<>0 AND cliente.empresa_id<>2"; list($abonos_nomina) = $database->get_row($query); $query = "SELECT sum(cantidad) as total from movimiento\n\twhere movimiento.tipomov_id=13 AND fecha>='" . $fecha_inicio . "' AND fecha<='" . $fecha_final . " 23:59:59'"; list($enganche) = $database->get_row($query); $query = "SELECT sum(total) as total from pedido\n\twhere fecha_orden>='" . $fecha_inicio . "' AND fecha_orden<='" . $fecha_final . " 23:59:59'"; list($pedidos_andrea) = $database->get_row($query); $query = "SELECT sum(cantidad) as total from pedido_movimiento\n\twhere pedido_movimiento.tipomov_id=14 AND fecha>='" . $fecha_inicio . "' AND fecha<='" . $fecha_final . " 23:59:59'"; list($anticipos_andrea) = $database->get_row($query); ?> <table class="table table-condensed"> <thead> <tr> <th colspan=2 style="text-align:center">Periodo <?php echo fechamysqltomx($fecha_inicio, "letra") . " - " . fechamysqltomx($fecha_final, "letra"); ?> </th> </tr> </thead> <tbody> <tr><td>Ingresos Netos</td><td style="text-align:right"><?php echo dinero($total); ?> </td></tr> <tr><td>Ventas Credito</td><td style="text-align:right"><?php echo dinero($ventas_credito); ?>
echo "<tr><td><br><center><h1 ><b>\$ " . dinero($cantidad) . " MX </b></h1></center></td></tr>"; break; } echo "<tr><td><center><b>Compra Minima: " . dinero($compra_minima) . "</B></center></td></tr>"; echo "<tr><td><center><b>Valido: " . fechamysqltomx($fecha_ini, "letra") . " - " . fechamysqltomx($fecha_fin, "letra") . "</B></center></td></tr>"; if ($fecha_fin < date("Y-m-d")) { echo "<tr><td><br><center><span class=\"label label-important\">EXPIRADO</span></B></center></td></tr>"; } // else echo "<tr><td><center><b>Valido: ".fechamysqltomx($fecha_ini,"letra")." - ".fechamysqltomx($fecha_fin,"letra")."</B></center></td></tr>"; if (strtotime(date("Y-m-d")) < strtotime($fecha_ini)) { echo "<tr bgcolor=yellow><td ><center>Error Fecha: Todavia no se puede usar</center></td></tr>"; } if (!$activo) { echo "<tr bgcolor=yellow><td ><center>Status: Sin Activar</center></td></tr>"; } if ($usado) { echo "<tr><td> <center>{$cupontipo_id} Usado el: <center></td></tr>"; } echo "<tr><td><center>Hoy es " . fechamysqltomx(date("Y-m-d"), "letra") . "</td></tr>"; echo "</table><br><br>"; echo "<a href='/index.php?data=pos' class='btn' data-dismiss='modal'>CANCELAR</a> "; if ($fecha_fin >= date("Y-m-d") && strtotime(date("Y-m-d")) <= strtotime($fecha_ini)) { echo "<a href='/functions/cart.php?func=apply_cupon&cupon_sku={$sku}' class=\"btn btn-primary\" >APLICAR</a>"; } echo "</center>"; } else { echo "no existe"; } ?>