protected function private_core() { $this->almacen = new almacen(); $this->pais = new pais(); /// ¿El usuario tiene permiso para eliminar en esta página? $this->allow_delete = $this->user->allow_delete_on(__CLASS__); if (isset($_POST['scodalmacen'])) { $al0 = $this->almacen->get($_POST['scodalmacen']); if (!$al0) { $al0 = new almacen(); $al0->codalmacen = $_POST['scodalmacen']; } $al0->nombre = $_POST['snombre']; $al0->codpais = $_POST['scodpais']; $al0->provincia = $_POST['sprovincia']; $al0->poblacion = $_POST['spoblacion']; $al0->direccion = $_POST['sdireccion']; $al0->codpostal = $_POST['scodpostal']; $al0->telefono = $_POST['stelefono']; $al0->fax = $_POST['sfax']; $al0->contacto = $_POST['scontacto']; if ($al0->save()) { $this->new_message("Almacén " . $al0->codalmacen . " guardado correctamente."); } else { $this->new_error_msg("¡Imposible guardar el almacén!"); } } else { if (isset($_GET['delete'])) { $al0 = $this->almacen->get($_GET['delete']); if ($al0) { if (!$this->user->admin) { $this->new_error_msg("Solo un administrador puede eliminar un almacén."); } else { if ($al0->delete()) { $this->new_message("Almacén " . $al0->codalmacen . " eliminado correctamente"); } else { $this->new_error_msg("¡Imposible eliminar el almacén!"); } } } else { $this->new_error_msg("¡Almacén no encontrado!"); } } } }
protected function process() { $this->almacen = new almacen(); $this->pais = new pais(); $this->buttons[] = new fs_button('b_nuevo_almacen', 'Nuevo'); if (isset($_POST['scodalmacen'])) { $al0 = $this->almacen->get($_POST['scodalmacen']); if (!$al0) { $al0 = new almacen(); $al0->codalmacen = $_POST['scodalmacen']; } $al0->nombre = $_POST['snombre']; $al0->codpais = $_POST['scodpais']; $al0->provincia = $_POST['sprovincia']; $al0->poblacion = $_POST['spoblacion']; $al0->direccion = $_POST['sdireccion']; $al0->codpostal = $_POST['scodpostal']; $al0->telefono = $_POST['stelefono']; $al0->fax = $_POST['sfax']; $al0->contacto = $_POST['scontacto']; if ($al0->save()) { $this->new_message("Almacén " . $al0->codalmacen . " guardado correctamente."); } else { $this->new_error_msg("¡Imposible guardar el almacén!"); } } else { if (isset($_GET['delete'])) { $al0 = $this->almacen->get($_GET['delete']); if ($al0) { if ($al0->delete()) { $this->new_message("Almacén " . $al0->codalmacen . " eliminado correctamente"); } else { $this->new_error_msg("¡Imposible eliminar el almacén!"); } } else { $this->new_error_msg("¡Almacén no encontrado!"); } } } }
<?php // <editor-fold defaultstate="collapsed" desc="php"> require '../../includes/constants.php'; $usuario = new usuario(); $usuario->confirmar_miembro(); $almacen = new almacen(); $resultado = array("suceed" => false); if (isset($_GET['id'])) { $resultado = $almacen->borrar($_GET['id']); } // </editor-fold> ?> <!DOCTYPE html> <html lang="es"> <head> <meta charset="utf-8"> <title><?php echo TITULO; ?> </title> <meta name="description" content=""> <meta name="author" content=""> <!-- Le HTML5 shim, for IE6-8 support of HTML elements --> <!--[if lt IE 9]> <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script> <![endif]--> <!-- Le styles --> <link href="<?php
protected function private_core() { $almacen = new almacen(); $this->pais = new pais(); /// ¿El usuario tiene permiso para eliminar en esta página? $this->allow_delete = $this->user->allow_delete_on(__CLASS__); if (isset($_POST['scodalmacen'])) { $al0 = $almacen->get($_POST['scodalmacen']); if (!$al0) { $al0 = new almacen(); $al0->codalmacen = $_POST['scodalmacen']; } $al0->nombre = $_POST['snombre']; $al0->codpais = $_POST['scodpais']; $al0->provincia = $_POST['sprovincia']; $al0->poblacion = $_POST['spoblacion']; $al0->direccion = $_POST['sdireccion']; $al0->codpostal = $_POST['scodpostal']; $al0->telefono = $_POST['stelefono']; $al0->fax = $_POST['sfax']; $al0->contacto = $_POST['scontacto']; if ($al0->save()) { $this->new_message("Almacén " . $al0->codalmacen . " guardado correctamente."); } else { $this->new_error_msg("¡Imposible guardar el almacén!"); } } else { if (isset($_GET['delete'])) { $al0 = $almacen->get($_GET['delete']); if ($al0) { if (!$this->user->admin) { $this->new_error_msg("Solo un administrador puede eliminar un almacén."); } else { if ($al0->delete()) { $this->new_message("Almacén " . $al0->codalmacen . " eliminado correctamente"); } else { $this->new_error_msg("¡Imposible eliminar el almacén!"); } } } else { $this->new_error_msg("¡Almacén no encontrado!"); } } else { /// ¿Guardamos las opciones avanzadas? $guardar = FALSE; foreach ($GLOBALS['config2'] as $i => $value) { if (isset($_POST[$i])) { $GLOBALS['config2'][$i] = $_POST[$i]; $guardar = TRUE; } } if ($guardar) { $file = fopen('tmp/' . FS_TMP_NAME . 'config2.ini', 'w'); if ($file) { foreach ($GLOBALS['config2'] as $i => $value) { if (is_numeric($value)) { fwrite($file, $i . " = " . $value . ";\n"); } else { fwrite($file, $i . " = '" . $value . "';\n"); } } fclose($file); } $this->new_message('Datos guardados correctamente.'); } } } $this->almacenes = $almacen->all(); /// si hay más de un almacén activamos el soporte multi-almacén en los listados $fsvar = new fs_var(); if (count($this->almacenes) > 1) { $fsvar->simple_save('multi_almacen', TRUE); } else { $fsvar->simple_delete('multi_almacen'); } }
private function test_tablas() { $recargar = FALSE; if ($this->informe['offset'] == 0) { /// comprobamos la tabla familias if ($this->db->table_exists('familias')) { $data = $this->db->select("SELECT * FROM familias WHERE madre IS NOT NULL AND madre NOT IN (SELECT codfamilia FROM familias);"); if ($data) { foreach ($data as $d) { $familia = new familia($d); $familia->madre = NULL; $familia->save(); } } } /// comprobamos la tabla de articulos de proveedor if ($this->db->table_exists('articulosprov')) { $this->db->exec("DELETE FROM articulosprov WHERE codproveedor NOT IN (SELECT codproveedor FROM proveedores);"); } $recargar = TRUE; $this->informe['offset'] += 1; } else { if ($this->informe['offset'] == 1) { /// comprobamos la tabla de articulos de proveedor if ($this->db->table_exists('articulosprov')) { $this->db->exec("UPDATE articulosprov SET refproveedor = referencia WHERE refproveedor IS NULL;"); } $recargar = TRUE; $this->informe['offset'] += 1; } else { if ($this->informe['offset'] == 2) { /// comprobamos la tabla de stock if ($this->db->table_exists('stocks')) { /** * Esta consulta produce un error si no hay datos erroneos, pero da igual */ $this->db->exec("DELETE FROM stocks s WHERE NOT EXISTS " . "(SELECT referencia FROM articulos a WHERE a.referencia = s.referencia);"); } $recargar = TRUE; $this->informe['offset'] += 1; } else { if ($this->informe['offset'] == 3) { /// comprobamos la tabla de regulaciones de stock if ($this->db->table_exists('lineasregstocks')) { $this->db->exec("DELETE FROM lineasregstocks WHERE idstock NOT IN (SELECT idstock FROM stocks);"); } $recargar = TRUE; $this->informe['offset'] += 1; } else { if ($this->informe['offset'] == 4) { /// eliminamos los elementos de contabilidad que apuntan a ejercicios que no existen $tablas = array('co_gruposepigrafes', 'co_epigrafes', 'co_cuentas', 'co_subcuentas'); foreach ($tablas as $tabla) { $this->db->exec("DELETE FROM " . $tabla . " WHERE codejercicio NOT IN (SELECT codejercicio FROM ejercicios);"); } /// comprobamos la tabla de subcuentas de proveedores if ($this->db->table_exists('co_subcuentasprov')) { $this->db->exec("DELETE FROM co_subcuentasprov WHERE codproveedor NOT IN (SELECT codproveedor FROM proveedores);"); } /// comprobamos la tabla de direcciones de proveedores if ($this->db->table_exists('dirproveedores')) { $this->db->exec("DELETE FROM dirproveedores WHERE codproveedor NOT IN (SELECT codproveedor FROM proveedores);"); } /// comprobamos la tabla de subcuentas de clientes if ($this->db->table_exists('co_subcuentascli')) { $this->db->exec("DELETE FROM co_subcuentascli WHERE codcliente NOT IN (SELECT codcliente FROM clientes);"); } /// comprobamos la tabla de direcciones de clientes if ($this->db->table_exists('dirclientes')) { $this->db->exec("DELETE FROM dirclientes WHERE codcliente NOT IN (SELECT codcliente FROM clientes);"); } $recargar = TRUE; $this->informe['offset'] += 1; } else { if ($this->informe['offset'] == 5) { /// comprobamos la tabla de epigrafes if ($this->db->table_exists('co_epigrafes')) { $this->db->exec("UPDATE co_epigrafes SET idgrupo = NULL WHERE idgrupo NOT IN (SELECT idgrupo FROM co_gruposepigrafes);"); } $recargar = TRUE; $this->informe['offset'] += 1; } else { if ($this->informe['offset'] == 6) { $almacen = new almacen(); if (!$almacen->all()) { $this->db->exec($almacen->install()); } $divisa = new divisa(); if (!$divisa->all()) { $this->db->exec($divisa->install()); } $formap = new forma_pago(); if (!$formap->all()) { $this->db->exec($formap->install()); } $pais = new pais(); if (!$pais->all()) { $this->db->exec($pais->install()); } $serie = new serie(); if (!$serie->all()) { $this->db->exec($serie->install()); } $recargar = TRUE; $this->informe['offset'] += 1; } else { /// comprobamos la tabla de articulos de proveedor if ($this->db->table_exists('articulosprov')) { /// buscamos duplicados $data = $this->db->select("SELECT codproveedor,refproveedor,COUNT(*) as count FROM articulosprov GROUP BY codproveedor,refproveedor HAVING COUNT(*) > 1;"); if ($data) { foreach ($data as $d) { $sql = "SELECT * FROM articulosprov WHERE codproveedor = " . $this->empresa->var2str($d['codproveedor']) . " AND refproveedor = " . $this->empresa->var2str($d['refproveedor']) . ";"; $data2 = $this->db->select($sql); if ($data2) { $this->db->exec("DELETE FROM articulosprov WHERE id = " . $this->empresa->var2str($data2[1]['id']) . ";"); } } $recargar = TRUE; $this->informe['offset'] += 1; } } } } } } } } } if (!$recargar) { if ($this->informe['all']) { $this->informe['model'] = 'asiento'; } else { $this->informe['model'] = 'fin'; } $this->informe['offset'] = 0; } }
private function test_tablas() { $recargar = FALSE; if ($this->informe['offset'] == 0) { /// comprobamos la tabla familias if ($this->db->table_exists('familias')) { $data = $this->db->select("SELECT * FROM familias WHERE madre IS NOT NULL AND madre NOT IN (SELECT codfamilia FROM familias);"); if ($data) { foreach ($data as $d) { $familia = new familia($d); $familia->madre = NULL; $familia->save(); } } } /// comprobamos la tabla de articulos de proveedor if ($this->db->table_exists('articulosprov')) { $this->db->exec("DELETE FROM articulosprov WHERE codproveedor NOT IN (SELECT codproveedor FROM proveedores);"); } $recargar = TRUE; $this->informe['offset'] += 1; } else { if ($this->informe['offset'] == 1) { /// comprobamos la tabla de articulos de proveedor if ($this->db->table_exists('articulosprov')) { $this->db->exec("UPDATE articulosprov SET refproveedor = referencia WHERE refproveedor IS NULL;"); } $recargar = TRUE; $this->informe['offset'] += 1; } else { if ($this->informe['offset'] == 2) { /// comprobamos la tabla de stock if ($this->db->table_exists('stocks')) { $this->db->exec("DELETE FROM stocks s WHERE NOT EXISTS (SELECT referencia FROM articulos a WHERE a.referencia = s.referencia);"); } $recargar = TRUE; $this->informe['offset'] += 1; } else { if ($this->informe['offset'] == 3) { /// comprobamos la tabla de regulaciones de stock if ($this->db->table_exists('lineasregstocks')) { $this->db->exec("DELETE FROM lineasregstocks WHERE idstock NOT IN (SELECT idstock FROM stocks);"); } $recargar = TRUE; $this->informe['offset'] += 1; } else { if ($this->informe['offset'] == 4) { /// comprobamos la tabla de subcuentas de proveedores if ($this->db->table_exists('co_subcuentasprov')) { $this->db->exec("DELETE FROM co_subcuentasprov WHERE codproveedor NOT IN (SELECT codproveedor FROM proveedores);"); } /// comprobamos la tabla de direcciones de proveedores if ($this->db->table_exists('dirproveedores')) { $this->db->exec("DELETE FROM dirproveedores WHERE codproveedor NOT IN (SELECT codproveedor FROM proveedores);"); } /// comprobamos la tabla de subcuentas de clientes if ($this->db->table_exists('co_subcuentascli')) { $this->db->exec("DELETE FROM co_subcuentascli WHERE codcliente NOT IN (SELECT codcliente FROM clientes);"); } /// comprobamos la tabla de direcciones de clientes if ($this->db->table_exists('dirclientes')) { $this->db->exec("DELETE FROM dirclientes WHERE codcliente NOT IN (SELECT codcliente FROM clientes);"); } $recargar = TRUE; $this->informe['offset'] += 1; } else { if ($this->informe['offset'] == 5) { $almacen = new almacen(); if (!$almacen->all()) { $this->db->exec($almacen->install()); } $divisa = new divisa(); if (!$divisa->all()) { $this->db->exec($divisa->install()); } $formap = new forma_pago(); if (!$formap->all()) { $this->db->exec($formap->install()); } $pais = new pais(); if (!$pais->all()) { $this->db->exec($pais->install()); } $serie = new serie(); if (!$serie->all()) { $this->db->exec($serie->install()); } $recargar = TRUE; $this->informe['offset'] += 1; } else { /// comprobamos la tabla de articulos de proveedor if ($this->db->table_exists('articulosprov')) { /// buscamos duplicados $data = $this->db->select("SELECT codproveedor,refproveedor,COUNT(*) as count FROM articulosprov GROUP BY codproveedor,refproveedor HAVING COUNT(*) > 1;"); if ($data) { foreach ($data as $d) { $data2 = $this->db->select("SELECT * FROM articulosprov WHERE codproveedor = '" . $d['codproveedor'] . "' AND refproveedor = '" . $d['refproveedor'] . "';"); if ($data2) { $this->db->exec("DELETE FROM articulosprov WHERE id = " . $this->empresa->var2str($data2[1]['id']) . ";"); } } $recargar = TRUE; $this->informe['offset'] += 1; } } } } } } } } if (!$recargar) { if ($this->informe['all']) { $this->informe['model'] = 'asiento'; } else { $this->informe['model'] = 'fin'; } $this->informe['offset'] = 0; } }
<?php // <editor-fold defaultstate="collapsed" desc="php"> require '../../includes/constants.php'; $usuario = new usuario(); $usuario->confirmar_miembro(); $almacen = new almacen(); $producto = new producto(); $almacenes = $almacen->listarPorEmpresa($_SESSION['usuario']['empresa_id']); $productos = $producto->listar(); // <editor-fold defaultstate="collapsed" desc="Orden de Compra"> if (isset($_POST['procesar'])) { $resultado = $almacen->ordenDeCompra($_POST['producto'], $_POST['cantidad'], $_POST['costo'], $_POST['almacen_id']); // </editor-fold> } // </editor-fold> ?> <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title><?php echo TITULO; ?> - Orden de Compra</title> <meta name="description" content=""> <meta name="author" content=""> <!-- Le HTML5 shim, for IE6-8 support of HTML elements --> <!--[if lt IE 9]> <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
<?php include_once 'includes/constants.php'; $almacen = new almacen(); $productos_faltantes = $almacen->verificar_existencias(); // <editor-fold defaultstate="collapsed" desc="Recibos Semanales"> function recibosSemanales($plazo) { $n = 0; $fecha_inicio = time(); $fecha_inicio = strtotime('Next Friday', time()); $fecha_fin = strtotime("+" . $plazo . "month", $fecha_inicio); echo "Fecha Inicio: " . date('d-m-Y', $fecha_inicio) . "<br>"; echo "Fecha Fin: " . date('d-m-Y', $fecha_fin); while ($fecha_inicio < $fecha_fin) { echo "<br>" . date('d-m-Y', $fecha_inicio); $fecha_inicio = strtotime("+1 week", $fecha_inicio); echo "<br>Menor."; $n++; } echo "<br>" . $n . " recibos generados."; } // </editor-fold> // <editor-fold defaultstate="collapsed" desc="Recibos Quincenales"> function recibosQuincenales($plazo, $tipo_quincena) { $n = 0; $fecha_inicio = time(); $q1 = $tipo_quincena == 3 ? '10' : '15'; $q2 = $tipo_quincena == 3 ? '25' : 't'; //$fecha_inicio = strtotime(time());
<?php // <editor-fold defaultstate="collapsed" desc="php"> require '../../includes/constants.php'; $usuario = new usuario(); $usuario->confirmar_miembro(); $almacen = new almacen(); $resultado = array("suceed" => false); if (isset($_POST['submit'])) { $data = $_POST; unset($data['submit']); $resultado = $almacen->actualizar($_POST['id'], $data); } elseif (isset($_GET['id'])) { $registro = $almacen->ver($_GET['id']); } // </editor-fold> ?> <!DOCTYPE html> <html lang="es"> <head> <meta charset="utf-8"> <title><?php echo TITULO; ?> </title> <meta name="description" content=""> <meta name="author" content=""> <!-- Le HTML5 shim, for IE6-8 support of HTML elements --> <!--[if lt IE 9]> <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
public function nombre() { $al0 = new \almacen(); $almacen = $al0->get($this->codalmacen); if ($almacen) { $this->nombre = $almacen->nombre; } return $this->nombre; }
function detalle() { $id = $_REQUEST['id']; if (empty($_REQUEST['id'])) { $id = $_REQUEST['IDOV']; } $dataGuia = $this->AutoLoadModel("OrdenVenta"); $idTipoCambio = $dataGuia->BuscarCampoOVxId($id, "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']; $detalle = new detalleOrdenVenta(); $almacen = new almacen(); $datos = $detalle->listaDetalleOrdenVenta($id); $numero = 1; $totalGeneral = 0; foreach ($datos as $data) { $dataAlmacen = $almacen->buscaAlmacen($data['idalmacen']); $total = $data['cantdespacho'] * $data['preciofinal']; echo '<tr>'; echo '<td class="center">' . $numero . '</td>'; echo '<td>' . $data['codigopa'] . '</td>'; echo '<td>' . $data['nompro'] . '</td>'; echo '<td>' . $dataAlmacen[0]['codigoalmacen'] . '</td>'; echo '<td class="center">' . $data['cantsolicitada'] . '</td>'; echo '<td class="center bold">' . $data['cantaprobada'] . '</td>'; echo '<td class="center bold">' . $data['cantdespacho'] . '</td>'; echo '<td class="center">' . $simboloMoneda . ' ' . number_format($data['preciosolicitado'], 2) . '</td>'; echo '<td class="center bold">' . $simboloMoneda . ' ' . number_format($data['precioaprobado'], 2) . '</td>'; echo '<td class="center">' . $simboloMoneda . ' ' . number_format($data['preciofinal'], 2) . '</td>'; echo '<td class="right">' . $simboloMoneda . ' ' . number_format($total, 2) . '</td>'; echo "</tr>"; $numero += 1; $totalGeneral += $total; } echo '<tr class="bold"><td colspan="10" class="right">TOTAL:</td><td class="right">' . $simboloMoneda . ' ' . number_format($totalGeneral, 2) . '</td></tr>'; echo "<script>" . "\$('#txtObservacionVentas').val('" . $datos[0]['mventas'] . "');" . "\$('#txtObservacionCobranzas').val('" . $datos[0]['mcobranzas'] . "');" . "\$('#txtObservacionCreditos').val('" . $datos[0]['mcreditos'] . "');" . "</script>"; }
<?php // <editor-fold defaultstate="collapsed" desc="php"> require '../../includes/constants.php'; $usuario = new usuario(); $usuario->confirmar_miembro(); $almacen = new almacen(); $resultado = array("suceed" => false); if (isset($_POST['submit'])) { $data = $_POST; unset($data['submit']); $resultado = $almacen->insertar($data); } // </editor-fold> ?> <!DOCTYPE html> <html lang="es"> <head> <meta charset="utf-8"> <title><?php echo TITULO; ?> </title> <meta name="description" content=""> <meta name="author" content=""> <!-- Le HTML5 shim, for IE6-8 support of HTML elements --> <!--[if lt IE 9]> <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script> <![endif]-->
protected function private_core() { /// ¿El usuario tiene permiso para eliminar en esta página? $this->allow_delete = $this->user->allow_delete_on(__CLASS__); $almacen = new almacen(); $this->almacenes = $almacen->all(); $articulo = new articulo(); $this->familia = new familia(); $this->fabricante = new fabricante(); $this->impuesto = new impuesto(); $this->tarifa = new tarifa(); $this->transferencia_stock = new transferencia_stock(); /** * Si hay alguna extensión de tipo config y texto no_tab_tarifas, * desactivamos la pestaña tarifas. */ $this->mostrar_tab_tarifas = TRUE; foreach ($this->extensions as $ext) { if ($ext->type == 'config' and $ext->text == 'no_tab_tarifas') { $this->mostrar_tab_tarifas = FALSE; break; } } if (isset($_POST['codtarifa'])) { /// crear/editar tarifa $tar0 = $this->tarifa->get($_POST['codtarifa']); if (!$tar0) { $tar0 = new tarifa(); $tar0->codtarifa = $_POST['codtarifa']; } $tar0->nombre = $_POST['nombre']; $tar0->aplicar_a = $_POST['aplicar_a']; $tar0->set_x(floatval($_POST['dtopor'])); $tar0->set_y(floatval($_POST['inclineal'])); $tar0->mincoste = isset($_POST['mincoste']); $tar0->maxpvp = isset($_POST['maxpvp']); if ($tar0->save()) { $this->new_message("Tarifa guardada correctamente."); } else { $this->new_error_msg("¡Imposible guardar la tarifa!"); } } else { if (isset($_GET['delete_tarifa'])) { /// eliminar tarifa $tar0 = $this->tarifa->get($_GET['delete_tarifa']); if ($tar0) { if ($tar0->delete()) { $this->new_message("Tarifa " . $tar0->codtarifa . " eliminada correctamente.", TRUE); } else { $this->new_error_msg("¡Imposible eliminar la tarifa!"); } } else { $this->new_error_msg("¡La tarifa no existe!"); } } else { if (isset($_POST['referencia']) and isset($_POST['codfamilia']) and isset($_POST['codimpuesto'])) { /// nuevo artículo $this->save_codimpuesto($_POST['codimpuesto']); $art0 = $articulo->get($_POST['referencia']); if ($art0) { $this->new_error_msg('Ya existe el artículo <a href="' . $art0->url() . '">' . $art0->referencia . '</a>'); } else { if ($_POST['referencia'] == '') { $articulo->referencia = $articulo->get_new_referencia(); } else { $articulo->referencia = $_POST['referencia']; } $articulo->descripcion = $_POST['descripcion']; $articulo->nostock = isset($_POST['nostock']); if ($_POST['codfamilia'] != '') { $articulo->codfamilia = $_POST['codfamilia']; } if ($_POST['codfabricante'] != '') { $articulo->codfabricante = $_POST['codfabricante']; } $articulo->set_impuesto($_POST['codimpuesto']); if (isset($_POST['coniva'])) { $articulo->set_pvp_iva(floatval($_POST['pvp'])); } else { $articulo->set_pvp(floatval($_POST['pvp'])); } if ($articulo->save()) { header('location: ' . $articulo->url()); } else { $this->new_error_msg("¡Error al crear el articulo!"); } } } else { if (isset($_GET['delete'])) { /// eliminar artículo $art = $articulo->get($_GET['delete']); if ($art) { if ($art->delete()) { $this->new_message("Articulo " . $art->referencia . " eliminado correctamente.", TRUE); } else { $this->new_error_msg("¡Error al eliminarl el articulo!"); } } } else { if (isset($_POST['origen'])) { /// nueva transferencia de stock $this->transferencia_stock->usuario = $this->user->nick; $this->transferencia_stock->codalmaorigen = $_POST['origen']; $this->transferencia_stock->codalmadestino = $_POST['destino']; if ($this->transferencia_stock->save()) { $this->new_message('Datos guardados correctamente.'); header('Location: ' . $this->transferencia_stock->url()); } else { $this->new_error_msg('Error al guardar los datos.'); } } else { if (isset($_GET['delete_transf'])) { $transf = $this->transferencia_stock->get($_GET['delete_transf']); if ($transf) { $ok = TRUE; /// eliminamos las líneas $ltf = new linea_transferencia_stock(); foreach ($ltf->all_from_transferencia($transf->idtrans) as $lin) { if ($lin->delete()) { /// movemos el stock $art = $articulo->get($lin->referencia); if ($art) { $art->sum_stock($transf->codalmadestino, 0 - $lin->cantidad); $art->sum_stock($transf->codalmaorigen, $lin->cantidad); } } else { $this->new_error_msg('Error al eliminar la línea con referencia ' . $lin->referencia); $ok = FALSE; } } if ($ok) { if ($transf->delete()) { $this->new_message('Transferencia eliminada correctamente.'); } else { $this->new_error_msg('Error al eliminar la transferencia.'); } } } else { $this->new_error_msg('Transferencia no encontrada.'); } } } } } } } /// obtenemos los datos para la búsqueda $this->offset = 0; if (isset($_REQUEST['offset'])) { $this->offset = intval($_REQUEST['offset']); } $this->b_codalmacen = ''; if (isset($_REQUEST['b_codalmacen'])) { $this->b_codalmacen = $_REQUEST['b_codalmacen']; } $this->b_codfamilia = ''; if (isset($_REQUEST['b_codfamilia'])) { $this->b_codfamilia = $_REQUEST['b_codfamilia']; } $this->b_codfabricante = ''; if (isset($_REQUEST['b_codfabricante'])) { $this->b_codfabricante = $_REQUEST['b_codfabricante']; } $this->b_constock = isset($_REQUEST['b_constock']); $this->b_bloqueados = isset($_REQUEST['b_bloqueados']); $this->b_publicos = isset($_REQUEST['b_publicos']); $this->b_codtarifa = ''; if (isset($_REQUEST['b_codtarifa'])) { $this->b_codtarifa = $_REQUEST['b_codtarifa']; setcookie('b_codtarifa', $this->b_codtarifa, time() + FS_COOKIES_EXPIRE); } else { if (isset($_COOKIE['b_codtarifa'])) { $this->b_codtarifa = $_COOKIE['b_codtarifa']; } } $this->b_orden = 'refmin'; if (isset($_REQUEST['b_orden'])) { $this->b_orden = $_REQUEST['b_orden']; setcookie('ventas_articulos_orden', $this->b_orden, time() + FS_COOKIES_EXPIRE); } else { if (isset($_COOKIE['ventas_articulos_orden'])) { $this->b_orden = $_COOKIE['ventas_articulos_orden']; } } $this->b_url = $this->url() . "&query=" . $this->query . "&b_codfabricante=" . $this->b_codfabricante . "&b_codalmacen=" . $this->b_codalmacen . "&b_codfamilia=" . $this->b_codfamilia . "&b_codtarifa=" . $this->b_codtarifa; if ($this->b_constock) { $this->b_url .= '&b_constock=TRUE'; } if ($this->b_bloqueados) { $this->b_url .= '&b_bloqueados=TRUE'; } if ($this->b_publicos) { $this->b_url .= '&b_publicos=TRUE'; } $this->search_articulos(); }
/** * esta función se ejecuta si el usuario ha hecho login, * a efectos prácticos, este es el constructor */ protected function process() { /// ¿El usuario tiene permiso para eliminar en esta página? $this->allow_delete = $this->user->allow_delete_on(__CLASS__); //Cargo el modelo de la caja y la selecciono $this->caja_model = new cajas_general(); //Cargo el modelo de los movimientos $this->cajamov_model = new cajas_general_mov(); //Conseguimos el agente $this->agente = $this->user->get_agente(); if ($_GET['id'] != '') { $this->cajaid = $_GET['id']; $caja = $this->caja_model->get($this->cajaid); if ($caja) { //Compruebo si la caja esta o no Abierta $this->cajaopen = $caja->abierta(); //Consultamos almacenes existentes $almacenes = new almacen(); $this->almacen = $almacenes->get($caja->codalmacen); /* ********** // MODAL APUNTE * ********** */ if (isset($_REQUEST['idapunte'])) { $this->apunte = $this->cajamov_model->get($_REQUEST['idapunte']); // VISUALIZAR MODAL APUNTE if (isset($_POST['ajax'])) { $this->template = 'ajax_apunte'; } /* ********** // MODAL EDITAR APUNTE * ********** */ if (isset($_POST['importe'])) { if ($this->apunte->concepto == 'Apertura de Caja') { $this->resultados = $this->cajamov_model->get_all($this->cajaid); $this->new_error_msg('OJO! Apunte inicial: NO EDITABLE...'); return; } $this->apunte->concepto = $_POST['concepto']; $this->apunte->apunte = floatval($_POST['importe']); $this->apunte->caja_id = $this->cajaid; $this->apunte->codagente = $this->agente->codagente; if ($this->apunte->save()) { $this->new_message('Apunte EDITADO correctamente.'); $this->new_log_msg('Apunte Nº ' . $_REQUEST['idapunte'] . ' de la CAJA Nº ' . $this->cajaid . ' EDITADO correctamente.'); } else { $this->new_error_msg('Imposible EDITAR apunte Nº ' . $_REQUEST['idapunte']); } } } else { if (isset($_GET['delete'])) { /* ********** // ELIMINAMOS APUNTE * ********** */ $apunte = $this->cajamov_model->get($_GET['delete']); if ($apunte) { if ($apunte->concepto == 'Apertura de Caja') { $this->resultados = $this->cajamov_model->get_all($this->cajaid); $this->new_error_msg('OJO! Apunte incicial: NO se puede eliminar'); return; } if ($apunte->delete()) { $this->new_message('Apunte ' . $_GET['delete'] . ' eliminado correctamente.'); $this->new_log_msg('Apunte Nº ' . $_GET['delete'] . ' de la CAJA Nº ' . $this->cajaid . ' eliminado correctamente.'); } else { $this->new_error_msg('Error al eliminar el apunte ' . $_GET['delete']); } } else { $this->new_error_msg('Apunte ' . $_GET['delete'] . ' no encontrado.'); } } else { if (isset($_POST['ingreso']) and $_POST['ingreso'] > 0) { /* ********** // CREAMOS APUNTE INGRESO POSITIVO * ********** */ $this->cajamov_model->concepto = $_POST['nota']; $this->cajamov_model->apunte = floatval($_POST['ingreso']); $this->cajamov_model->caja_id = $this->cajaid; $this->cajamov_model->codagente = $this->agente->codagente; if ($this->cajamov_model->save()) { $this->new_message('Ingreso apuntado correctamente.'); } else { $this->new_error_msg('Imposible guardar el ingreso.'); } } else { if (isset($_POST['pago']) and $_POST['pago'] > 0) { /* ********** // CREAMOS APUNTE PAGO CONVERTIMOS A NEGATIVO * ********** */ $this->cajamov_model->concepto = $_POST['nota']; $apunte = floatval($_POST['pago']); $this->cajamov_model->apunte = $apunte *= -1; $this->cajamov_model->caja_id = $this->cajaid; $this->cajamov_model->codagente = $this->agente->codagente; if ($this->cajamov_model->save()) { $this->new_message('Pago apuntado correctamente.'); } else { $this->new_error_msg('Imposible guardar el pago.'); } } } } } $this->tipo = FALSE; if (isset($_REQUEST['tipo'])) { if ($_REQUEST['tipo'] == 'ingresos') { $this->tipo = 'ingresos'; $this->resultados = $this->cajamov_model->ingresos($this->cajaid); } else { if ($_REQUEST['tipo'] == 'pagos') { $this->tipo = 'pagos'; $this->resultados = $this->cajamov_model->pagos($this->cajaid); } } } else { $this->resultados = $this->cajamov_model->get_all($this->cajaid); } } else { $this->new_error_msg('Caja no existe, ha sido eliminada anteriormente !', 'cajamov'); } } else { $this->new_error_msg('Caja NO seleccionada correctamente!', 'cajamov'); } }
<?php // <editor-fold defaultstate="collapsed" desc="Traspaso"> require '../../includes/constants.php'; $producto = new producto(); $almacen = new almacen(); $usuario = new usuario(); $usuario->confirmar_miembro(); $almacenes = $almacen->listarPorEmpresa($_SESSION['usuario']['empresa_id']); if (isset($_GET['producto']) && isset($_GET['almacen'])) { $mi_almacen = $almacen->ver($_GET['almacen']); $mi_producto = $producto->ver($_GET['producto']); $existencia = $almacen->dame_query("select cantidad from producto_almacen where producto_id=" . $mi_producto['data'][0]['id'] . " and almacen_id=" . $mi_almacen['data'][0]['id']); if (count($existencia['data'] > 0)) { $existencia = (int) $existencia['data'][0]['cantidad']; } } else { //TODO cargar listado de almacenes y de productos //TODO Procesar selección del usuario via ajax en sesión //TODO crear pantalla de confirmación de productos //TODO traspaso masivo } if (isset($_POST['traspasar'])) { $resultado = $almacen->traspasar($_POST['producto_id'], $_POST['almacen_origen'], $_POST['almacen_id'], $_POST['cantidad']); } // </editor-fold> ?> <!DOCTYPE html> <html> <head> <meta charset="utf-8">
public function stats_almacenes($tabla = 'facturasprov') { $stats = array(); $al0 = new almacen(); $sql = "select codalmacen,sum(totaleuros) as total from " . $tabla . " group by codalmacen order by total desc;"; $data = $this->db->select($sql); if ($data) { foreach ($data as $d) { $alma = $al0->get($d['codalmacen']); if ($alma) { $stats[] = array('txt' => $alma->nombre, 'total' => round(abs($this->euro_convert(floatval($d['total']))), FS_NF0)); } else { $stats[] = array('txt' => $d['codalmacen'], 'total' => round(abs($this->euro_convert(floatval($d['total']))), FS_NF0)); } } } return $stats; }
/** * esta función se ejecuta si el usuario ha hecho login, * a efectos prácticos, este es el constructor */ protected function private_core() { $this->busqueda = array('contenido' => '', 'filtro_almacen' => '', 'desde' => '', 'hasta' => '', 'orden' => 'fecha'); /// ¿El usuario tiene permiso para eliminar en esta página? $this->allow_delete = $this->user->allow_delete_on(__CLASS__); //Consultamos almacenes existentes $almacenes = new almacen(); $this->almacenes = $almacenes->all(); //Conseguimos el agente $this->agente = $this->user->get_agente(); //cargamos nuestro modelo vacio de tabla caja general $this->recogidas_model = new cajas_general(); //Cargo el modelo de los movimientos $this->cajamov_model = new cajas_general_mov(); /************ // BUSCAR CAJA * ********** */ if (isset($_POST['filtro_almacen'])) { $this->busqueda['filtro_almacen'] = $_POST['filtro_almacen']; $this->busqueda['desde'] = $_POST['desde']; $this->busqueda['hasta'] = $_POST['hasta']; $this->resultado = $this->recogidas_model->search($this->busqueda['filtro_almacen'], $this->busqueda['desde'], $this->busqueda['hasta']); return; } elseif (isset($_POST['almacen'])) { /************ // ABRIR CAJA * ********** */ if ($this->recogidas_model->disponible($_POST['almacen'])) { $this->recogidas_model->codalmacen = $_POST['almacen']; $this->recogidas_model->d_inicio = floatval($_POST['d_inicio']); $this->recogidas_model->codagente = $this->agente->codagente; if ($this->recogidas_model->save()) { //Genero una primera linea de entrada en la caja $this->cajamov_model->concepto = 'Apertura de Caja'; $this->cajamov_model->apunte = floatval($_POST['d_inicio']); $this->cajamov_model->caja_id = $this->recogidas_model->id; $this->cajamov_model->codagente = $this->agente->codagente; if ($this->cajamov_model->save()) { $this->new_message("Caja iniciada con " . $this->show_numero($this->recogidas_model->d_inicio, 2) . ' €'); } } else { $this->new_error_msg("¡Imposible guardar los datos de caja!"); } } else { $this->new_error_msg("¡Caja ya abierta para este Almacen!"); } } else { if (isset($_GET['delete'])) { /* * *********** // ELIMINAR CAJA * ********** */ $caja2 = $this->recogidas_model->get($_GET['delete']); if ($caja2) { //OK, ahora eliminamos todos sus apuntes $this->cajamov_model->delete_all($caja2->id); //Y ahora eliminamos if ($caja2->delete()) { $this->new_log_msg('Caja Nº ' . $_GET['delete'] . ' y apuntes eliminados correctamente...'); $this->new_message("Caja y Apuntes eliminados correctamente."); } else { $this->new_error_msg("¡Imposible eliminar la caja!"); } } else { $this->new_error_msg("Caja no encontrada."); } } else { if (isset($_POST['cierre'])) { /* * *********** // CERRAR CAJA * ********** */ $caja2 = $this->recogidas_model->get($_POST['cierre']); if ($caja2) { $saldo = $this->cajamov_model->apuntes_suma($caja2->id); $contado = floatval($_POST['d_fin']); $descuadre = round($contado - $saldo, 2); $caja2->f_fin = Date('d-m-Y H:i:s'); $caja2->d_fin = floatval($_POST['d_fin']); $caja2->descuadre = $descuadre; $caja2->codagente_fin = $this->agente->codagente; $caja2->apuntes = $this->cajamov_model->apuntes_contar($caja2->id); if ($caja2->save()) { $this->new_message("Caja cerrada correctamente."); //Si hay descuadre lo aviso y genero linea en su caja if ($descuadre != 0) { //Genero una linea del descuadre en la caja $this->cajamov_model->concepto = 'Descuadre en Caja'; $this->cajamov_model->apunte = $descuadre; $this->cajamov_model->caja_id = $caja2->id; $this->cajamov_model->codagente = $this->agente->codagente; if ($this->cajamov_model->save()) { $this->new_advice('DESCUADRE: Se ha anotado un apunte con el descuadre de la Caja Nº ' . $caja2->id); } } } else { $this->new_error_msg("¡Imposible cerrar la caja!"); } } else { $this->new_error_msg("Caja no encontrada."); } } } } $this->offset = 0; if (isset($_GET['offset'])) { $this->offset = intval($_GET['offset']); } $this->resultado = $this->recogidas_model->get_all_offset($this->offset); }
public function nombre_almacen() { $almacen = new almacen(); return $almacen->get($this->codalmacen); }