protected function process()
 {
     $this->show_fs_toolbar = FALSE;
     $this->familia = new familia();
     if (isset($_POST['ncodfamilia'])) {
         $fam = new familia();
         $fam->codfamilia = $_POST['ncodfamilia'];
         $fam->descripcion = $_POST['ndescripcion'];
         if ($fam->save()) {
             Header('location: ' . $fam->url());
         } else {
             $this->new_error_msg("¡Imposible guardar la familia!");
         }
     } else {
         if (isset($_GET['delete'])) {
             $fam = new familia();
             $fam->codfamilia = $_GET['delete'];
             if ($fam->delete()) {
                 $this->new_message("Familia " . $_GET['delete'] . " eliminada correctamente");
             } else {
                 $this->new_error_msg("¡Imposible eliminar la familia " . $_GET['delete'] . "!");
             }
         }
     }
     if ($this->query != '') {
         $this->resultados = $this->familia->search($this->query);
     } else {
         $this->resultados = $this->familia->all();
     }
 }
Beispiel #2
0
 public static function getInstance()
 {
     if (!self::$_instance instanceof self) {
         self::$_instance = new self();
     }
     return self::$_instance;
 }
Beispiel #3
0
 protected function process()
 {
     $this->familia = new familia();
     $this->madre = NULL;
     if (isset($_REQUEST['madre'])) {
         $this->madre = $_REQUEST['madre'];
     }
     if (isset($_POST['ncodfamilia'])) {
         $fam = $this->familia->get($_POST['ncodfamilia']);
         if ($fam) {
             $this->new_error_msg('La familia <a href="' . $fam->url() . '">' . $fam->codfamilia . '</a> ya existe.');
         } else {
             $fam = new familia();
             $fam->codfamilia = $_POST['ncodfamilia'];
             $fam->descripcion = $_POST['ndescripcion'];
             $fam->madre = $this->madre;
             if ($fam->save()) {
                 Header('location: ' . $fam->url());
             } else {
                 $this->new_error_msg("¡Imposible guardar la familia!");
             }
         }
     } else {
         if (isset($_GET['delete'])) {
             $fam = $this->familia->get($_GET['delete']);
             if ($fam) {
                 if ($fam->delete()) {
                     $this->new_message("Familia " . $_GET['delete'] . " eliminada correctamente");
                 } else {
                     $this->new_error_msg("¡Imposible eliminar la familia " . $_GET['delete'] . "!");
                 }
             } else {
                 $this->new_error_msg("Familia " . $_GET['delete'] . " no encontrada.");
             }
         }
     }
     if ($this->query != '') {
         $this->resultados = $this->familia->search($this->query);
     } else {
         $this->resultados = $this->familia->madres();
         $this->share_extensions();
     }
 }
Beispiel #4
0
 protected function process()
 {
     /// ¿El usuario tiene permiso para eliminar en esta página?
     $this->allow_delete = $this->user->allow_delete_on(__CLASS__);
     $this->familia = FALSE;
     if (isset($_REQUEST['cod'])) {
         $fam = new familia();
         $this->familia = $fam->get($_REQUEST['cod']);
     }
     $this->madre = FALSE;
     if ($this->familia) {
         $this->page->title = $this->familia->codfamilia;
         if (isset($_POST['cod'])) {
             $this->familia->descripcion = $_POST['descripcion'];
             $this->familia->madre = NULL;
             if (isset($_POST['madre'])) {
                 if ($_POST['madre'] != '---') {
                     $this->familia->madre = $_POST['madre'];
                 }
             }
             if ($this->familia->save()) {
                 $this->new_message("Datos modificados correctamente");
             } else {
                 $this->new_error_msg("Imposible modificar los datos.");
             }
         }
         $this->offset = 0;
         if (isset($_GET['offset'])) {
             $this->offset = intval($_GET['offset']);
         }
         $this->madre = $this->familia->get($this->familia->madre);
         $this->articulos = $this->familia->get_articulos($this->offset);
     } else {
         $this->new_error_msg("Familia no encontrada.");
     }
 }
Beispiel #5
0
        break;
    case 'GuardarFamiliar':
        $f = new familia();
        $f->id = $_POST['id'];
        $f->dni = $_SESSION['dni'];
        $f->provincia = $_POST['provincia'];
        $f->nombre = $_POST['nombre'];
        $f->sexo = $_POST['sexo'];
        $f->direccion = $_POST['direccion'];
        $f->localidad = $_POST['localidad'];
        $f->parentesco = $_POST['parentesco'];
        //$f->foto= $_POST['foto'];
        if ($_POST['id'] > 0) {
            $cantidad = $f->ModificarFamiliares();
        } else {
            $cantidad = $f->InsertarFamiliares();
        }
        echo $cantidad;
        break;
    case 'BorrarFamiliar':
        $f = new familia();
        $f->id = $_POST['id'];
        $f->BorrarFamiliares();
        break;
    case 'TraerFamiliar':
        $resultado = familia::TraerUnFamiliar($_POST['id']);
        echo json_encode($resultado);
    default:
        # code...
        break;
}
Beispiel #6
0
<?php

require 'familia.php';
$fam = familia::getInstance();
$fam->setCodigo($_POST['codigofa']);
$fam->setDescripcion($_POST['descripcionfa']);
if (!$fam->guardar()) {
    echo "hey ya ese codigo existe";
} else {
    die("Felicidades has guardado una familia");
}
 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;
     }
 }
Beispiel #8
0
function actualizarPreciosVentaAlmacenxSubFamilia($idsubfam, $md, $mc, $tipocosto, $descuento)
{
    $subfam = new familia();
    $subfam->LoadSub($idsubfam);
    $idsubfamilia = $subfam->get("IdSubFamilia");
    $idfamilia = $subfam->get("IdFamilia");
    $IdLocal = getSesionDato("IdTienda");
    $mu_gral = getSesionDato("MargenUtilidad");
    $dto_gral = getSesionDato("DescuentoTienda");
    $cop_ipto = getSesionDato("COPImpuesto");
    $sql = "SELECT IdProducto,IdSubFamilia,Costo\n          FROM ges_productos \n          WHERE  ges_productos.IdSubFamilia = '{$idsubfamilia}' \n          AND    ges_productos.IdFamilia = '{$idfamilia}' \n          AND    ges_productos.Eliminado = 0 \n          AND    ges_productos.Servicio = 0 ";
    $res = query($sql);
    while ($row = Row($res)) {
        $UC = $row["Costo"];
        // Ultimo Costo
        $IdProducto = $row["IdProducto"];
        $sql1 = "SELECT CostoUnitario, PrecioVenta, PrecioVentaCorporativo,\n              Impuesto,CostoOperativo \n              FROM ges_almacenes \n              WHERE  ges_almacenes.IdProducto = '{$IdProducto}' \n              AND    ges_almacenes.IdLocal = '{$IdLocal}'";
        $row1 = queryrow($sql1);
        $CP = $row1["CostoUnitario"];
        $PVD = $row1["PrecioVenta"];
        $PVC = $row1["PrecioVentaCorporativo"];
        $COP = $cop_ipto == 1 ? 0 : $row1["CostoOperativo"];
        $Impuesto = $row1["Impuesto"];
        // Calculado nuevos precios
        $descuento = $descuento == 0 ? $dto_gral : $descuento;
        $DSTO = $descuento / 100;
        $Costo = $tipocosto == 'CP' ? $CP : $UC;
        $md = $md == 0 ? $mu_gral : $md;
        $MUD = ($Costo + $COP) * ($md / 100);
        $PV1 = $Costo + $COP + $MUD;
        if ($md != 0) {
            $PVD = $PV1 + $PV1 * ($Impuesto / 100);
            $PVD = $cop_ipto == 1 ? $PV1 + $COP + ($PV1 + $COP) * ($Impuesto / 100) : $PVD;
            $PVD = round($PVD, 1);
            $PVD = FormatPreciosTPV($PVD);
            $PVDD = round($PVD - $MUD * $DSTO, 1);
            $PVDD = FormatPreciosTPV($PVDD);
            actualizarPreciosVentaxSubFamilia($IdProducto, $PVD, $PVDD, $IdLocal, 'VD');
        }
        $mc = $mc == 0 ? $mu_gral : $mc;
        $MUC = ($Costo + $COP) * ($mc / 100);
        $PV2 = $Costo + $COP + $MUC;
        if ($mc != 0) {
            $PVC = $PV2 + $PV2 * ($Impuesto / 100);
            $PVC = $cop_ipto == 1 ? $PV2 + $COP + ($PV2 + $COP) * ($Impuesto / 100) : $PVC;
            $PVC = round($PVC, 1);
            $PVC = FormatPreciosTPV($PVC);
            $PVCD = round($PVC - $MUC * $DSTO, 1);
            $PVCD = FormatPreciosTPV($PVCD);
            actualizarPreciosVentaxSubFamilia($IdProducto, $PVC, $PVCD, $IdLocal, 'VC');
        }
    }
}
Beispiel #9
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;
     }
 }
Beispiel #10
0
 /**
  * Devuelve la familia del artículo.
  * @return familia
  */
 public function get_familia()
 {
     if (is_null($this->codfamilia)) {
         return FALSE;
     } else {
         $fam = new \familia();
         return $fam->get($this->codfamilia);
     }
 }
Beispiel #11
0
 /**
  * Devuelve la familia del artículo.
  * @return familia
  */
 public function get_familia()
 {
     $fam = new familia();
     return $fam->get($this->codfamilia);
 }
Beispiel #12
0
 function formModificarSubfamilia($action, $mud, $muc, $dsto, $tipocosto)
 {
     $ot = getTemplate("ModificarSubFamilia");
     if (!$ot) {
         return false;
     }
     //$comboidiomas = genComboIdiomas($this->get("IdIdioma"));
     //$comboperfiles = genComboPerfiles($this->get("IdPerfil"));
     $xcheck = $mud != 'MUD' ? 'checked="checked"' : '';
     $xmutc = $mud != 'MUD' ? 'visible' : 'hidden';
     $xcp = $tipocosto == 'CP' ? 'selected' : '';
     $xuc = $tipocosto == 'UC' ? 'selected' : '';
     $xmud = $mud != 'MUD' ? CleanFloat($mud) : $this->get("MargenUtilidadVD");
     $xmuc = $muc != 'MUC' ? CleanFloat($muc) : $this->get("MargenUtilidadVC");
     $xdsto = $dsto != 'DSTO' ? CleanFloat($dsto) : $this->get("Descuento");
     $xlist = ListaProductosxSubFamilia($this->get("IdFamilia"), $this->get("IdSubFamilia"), $xmud, $xmuc, $xdsto, $tipocosto);
     $oFam = new familia();
     $oFam->Load($this->get("IdFamilia"));
     $NomFamilia = $oFam->get("Familia");
     $cambios = array("tTitulo" => _("Modificando ") . $NomFamilia . "/" . $this->get("SubFamilia"), "tSubFamilia" => _("Nombre"), "vSubFamilia" => $this->get("SubFamilia"), "vIdFamilia" => $this->get("IdFamilia"), "tMargenUtilidadVD" => _("Margen de Utilidad VP"), "vMargenUtilidadVD" => $xmud, "tMargenUtilidadVC" => _("Margen de Utilidad VC"), "vMargenUtilidadVC" => $xmuc, "tDescuento" => _("Descuento"), "vDescuento" => $xdsto, "vLista" => $xlist, "vIdBase" => $this->getId(), "vRecalcular" => $xcheck, "vCP" => $xcp, "vUC" => $xuc, "vMUTC" => $xmutc, "action" => $action, "HIDDENDATA" => Hidden("id", $this->getId()) . Hidden("IdFamilia", $this->get("IdFamilia")));
     return $ot->makear($cambios);
 }
Beispiel #13
0
<?php

require_once "clases/AccesoDatos.php";
require_once "clases/familia.php";
if (isset($_SESSION['dni'])) {
    $arrayVotos = familia::TraerFamiliares();
    echo "<h2> Bienvenido Usuario Dni Nº:  " . $_SESSION['dni'] . "</h2>";
    ?>

<table class="table"  style="background-color: beige;">
	<thead>
		<tr>
			<th>Editar</th>
			<th>Borrar</th>
			<th>Ver</th>
			<th>Dni</th>
			<th>Provincia</th>
			<th>Nombre</th>
			<th>Sexo</th>
			<th>Direccion</th>
			<th>Localidad</th>
			<th>Parentesco</th>
			
			<th>Id</th>

		</tr>
	</thead>
	<tbody>

		<?php 
    foreach ($arrayVotos as $f) {
Beispiel #14
0
<?php

require '../db/conf.php';
require '../db/familia.php';
require '../db/laboratorio.php';
$bd = Db::getInstance();
$classFamilia = familia::getInstance();
$clasLaboratorio = laboratorio::getInstance();
 protected function private_core()
 {
     /// ¿El usuario tiene permiso para eliminar en esta página?
     $this->allow_delete = $this->user->allow_delete_on(__CLASS__);
     $this->share_extensions();
     $familia = new familia();
     $this->tarifa = new tarifa();
     $this->tarifa_s = FALSE;
     if (isset($_GET['importar'])) {
         $this->importar_tarifas();
     } else {
         if (isset($_POST['codtarifa'])) {
             if ($_POST['codtarifa'] == '') {
                 /// Nueva tarifa de familia
                 $tar0 = new tarifa();
                 $tar0->codtarifa = $tar0->get_new_codigo();
             } else {
                 $tar0 = $this->tarifa->get($_POST['codtarifa']);
                 if (!$tar0) {
                     $tar0 = new tarifa();
                     $tar0->codtarifa = $_POST['codtarifa'];
                 }
             }
             if (isset($_POST['madre'])) {
                 $tar0->madre = $_POST['madre'];
                 $tar0->codfamilia = $_POST['codfamilia'];
                 $tar0->nombre = 'Familia ?';
                 $fam = $familia->get($_POST['codfamilia']);
                 if ($fam) {
                     $tar0->nombre = $fam->descripcion;
                 }
             } else {
                 if (isset($_POST['nombre'])) {
                     $tar0->nombre = $_POST['nombre'];
                 }
             }
             $tar0->margen = $_POST['aplicar_a'] == 'coste';
             $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'])) {
                 $tar0 = $this->tarifa->get($_GET['delete_tarifa']);
                 if ($tar0) {
                     if ($tar0->delete()) {
                         $this->new_message("Tarifa borrada correctamente.");
                     } else {
                         $this->new_error_msg("¡Imposible borrar la tarifa!");
                     }
                 } else {
                     $this->new_error_msg("¡La tarifa no existe!");
                 }
             }
         }
     }
     if (isset($_REQUEST['cod'])) {
         $this->tarifa_s = $this->tarifa->get($_REQUEST['cod']);
     }
     if ($this->tarifa_s) {
         $this->template = 'ventas_tarifa';
         $this->tarifas_familias = $this->tarifa->all_from_tarifa($this->tarifa_s->codtarifa);
         $this->familias_no = array();
         foreach ($familia->all() as $fam) {
             $encontrada = FALSE;
             foreach ($this->tarifas_familias as $tar) {
                 if ($tar->codfamilia == $fam->codfamilia) {
                     $encontrada = TRUE;
                     break;
                 }
             }
             if (!$encontrada) {
                 $this->familias_no[] = $fam;
             }
         }
     }
 }
Beispiel #16
0
function BorrarSubFamilia($id)
{
    $oFamilia = new familia();
    if ($oFamilia->LoadSub($id)) {
        $nombre = $oFamilia->get("SubFamilia");
        //echo gas("Aviso",_("Sub familia $nombre borrado"));
        $oFamilia->MarcarEliminado();
        return true;
    } else {
        //	echo gas("Aviso",_("No se ha podido borrar el familia"));
        return false;
    }
}
 protected function process()
 {
     $this->ppage = $this->page->get('ventas_familias');
     $this->articulo = new articulo();
     $this->ready = TRUE;
     $this->error = FALSE;
     if (isset($_GET['fam'])) {
         $familia = new familia();
         $this->familia = $familia->get($_GET['fam']);
     } else {
         if (isset($_POST['fam'])) {
             $familia = new familia();
             $this->familia = $familia->get($_POST['fam']);
         }
     }
     if ($this->cache->error()) {
         $this->new_error_msg('Memcache está deshabilitado y es necesario para continuar. ' . $this->cache->error_msg());
     } else {
         if ($this->familia) {
             if (isset($_POST['archivo'])) {
                 if (is_uploaded_file($_FILES['farchivo']['tmp_name'])) {
                     if (!file_exists("tmp/familias")) {
                         mkdir("tmp/familias");
                     } else {
                         if (file_exists("tmp/familias/" . $this->familia->codfamilia . '.csv')) {
                             unlink("tmp/familias/" . $this->familia->codfamilia . '.csv');
                         }
                     }
                     copy($_FILES['farchivo']['tmp_name'], "tmp/familias/" . $this->familia->codfamilia . '.csv');
                     /// limpiamos la cache
                     $this->cache->delete('family_data_' . $this->familia->codfamilia);
                     /// nos guardamos la configuración
                     $this->family_data = new family_data($this->familia->codfamilia);
                     $this->family_data->set_impuesto($_POST['impuesto']);
                     $this->family_data->sufijo = $_POST['sufijo'];
                     $this->family_data->num_articulos = $this->articulo->count($this->familia->codfamilia);
                     if (isset($_POST['con_iva'])) {
                         $this->family_data->con_iva = TRUE;
                     }
                     if (isset($_POST['pvp_max'])) {
                         $this->family_data->pvp_max = TRUE;
                     }
                     if (isset($_POST['bloquear'])) {
                         $this->family_data->bloquear = TRUE;
                     }
                     if (isset($_POST['nnuevos'])) {
                         $this->family_data->no_nuevos = TRUE;
                     }
                     $this->save_family_data();
                 } else {
                     $this->new_error_msg("¡Imposible cargar el archivo!");
                 }
             }
             if (file_exists("tmp/familias/" . $this->familia->codfamilia . ".csv")) {
                 if (isset($_GET['cancelar'])) {
                     $this->cache->delete('family_data_' . $this->familia->codfamilia);
                     unlink("tmp/familias/" . $this->familia->codfamilia . '.csv');
                     header("location: " . $this->familia->url());
                 } else {
                     $this->family_data = $this->get_family_data();
                 }
                 if (isset($_GET['action'])) {
                     $this->family_data->set_action($_GET['action']);
                 }
                 if ($this->family_data->action == 'test') {
                     $this->test_csv_file();
                     if ($this->ready) {
                         if ($this->error) {
                             $this->new_error_msg('Comprobación fallida.');
                         } else {
                             $this->new_message("Comprobación finalizada. Pulsa el botón <b>procesar</b> para comenzar.");
                             $this->buttons[] = new fs_button_img('b_start', 'Procesar', 'play.png', $this->url() . '&action=start');
                         }
                     } else {
                         $this->new_message("Comprobando ... " . $this->family_data->lineas_procesadas . "/" . $this->family_data->lineas);
                         $this->buttons[] = new fs_button_img('b_pause_import', 'Pausar', 'pause.png');
                     }
                     $this->buttons[] = new fs_button_img('b_cancelar', 'Cancelar', 'remove.png', $this->url() . '&cancelar=TRUE', TRUE);
                 } else {
                     if ($this->family_data->action == 'start') {
                         $this->csv2articulos();
                         if ($this->ready) {
                             if ($this->error) {
                                 $this->new_message("Proceso fallido.");
                             } else {
                                 $this->new_message("Proceso finalizado.");
                             }
                         } else {
                             $this->new_message("Procesando ... " . $this->family_data->lineas_procesadas . "/" . $this->family_data->lineas);
                             $this->buttons[] = new fs_button_img('b_pause_import', 'Pausar', 'pause.png');
                             $this->buttons[] = new fs_button_img('b_cancelar', 'Cancelar', 'remove.png', $this->url() . '&cancelar=TRUE', TRUE);
                         }
                     }
                 }
             } else {
                 $this->new_error_msg("¡No se ha encontrado el archivo " . $this->familia->codfamilia . ".csv!\n               Comprueba los permisos de la carpeta facturascripts/tmp/familias");
             }
         } else {
             $this->new_error_msg("¡Ninguna familia seleccionada!");
         }
     }
 }
 protected function private_core()
 {
     $this->share_extension();
     if (isset($_REQUEST["cat"])) {
         switch ($_REQUEST["cat"]) {
             case "fam":
                 if (isset($_REQUEST["cod"])) {
                     $this->codFamilia = $this->db->escape_string($_REQUEST["cod"]);
                 }
                 $catf = new autoventas_familia();
                 if (isset($_REQUEST["action"])) {
                     switch ($_REQUEST["action"]) {
                         case 1:
                             // Actualitzem dades
                             $catf->nombre = $this->db->escape_string($_REQUEST["fam_nombre"]);
                             $catf->descripcion = $this->db->escape_string($_REQUEST["fam_descripcion"]);
                             if (isset($_REQUEST["fam_visible"])) {
                                 $catf->visible = 1;
                             } else {
                                 $catf->visible = 0;
                             }
                             $catf->codigo = $this->codFamilia;
                             $catf->save();
                             break;
                         case 2:
                             // Pugem foto
                             $imagen = $this->guarda_foto_familia($this->codFamilia);
                             if ($imagen) {
                                 $this->familia = $catf->load_data($this->codFamilia);
                                 $catf->codigo = $this->familia["codigo"];
                                 $catf->nombre = $this->familia["nombre"];
                                 $catf->descripcion = $this->familia["descripcion"];
                                 $catf->visible = $this->familia["visible"];
                                 $catf->imagen = $imagen;
                                 $catf->save();
                                 $this->new_message("Imagen subida correctamente : {$imagen}");
                             }
                             break;
                         case 3:
                             // Borrem foto
                             if ($this->borra_foto($this->codFamilia)) {
                                 $this->new_message("Imagen borrada correctamente");
                                 $this->familia = $catf->load_data($this->codFamilia);
                                 $catf->codigo = $this->familia["codigo"];
                                 $catf->nombre = $this->familia["nombre"];
                                 $catf->descripcion = $this->familia["descripcion"];
                                 $catf->visible = $this->familia["visible"];
                                 $catf->imagen = "";
                                 $catf->save();
                             } else {
                                 $this->new_error_msg("Hubo un problema a la hora de borrar la imagen");
                             }
                             break;
                         default:
                             $this->new_error_msg("Autoventas: Código de accion desconocido");
                     }
                 } else {
                     $catf->codigo = $this->codFamilia;
                     if (!$catf->exists()) {
                         // No existeix, afegim les dades que tenim per defecte.
                         $fam = new familia();
                         $f1 = $fam->get($this->codFamilia);
                         $catf->codigo = $f1->codfamilia;
                         $catf->nombre = $f1->codfamilia;
                         $catf->descripcion = $f1->descripcion;
                         $catf->visible = 1;
                         $catf->imagen = "";
                         $catf->save();
                     }
                 }
                 $this->familia = $catf->load_data($this->codFamilia);
                 $this->template = "autoventas_familias";
                 break;
             case "firma":
                 if (isset($_REQUEST["tipo"])) {
                     $this->tipo = $_REQUEST["tipo"];
                     $this->id = (int) $_REQUEST["id"];
                     switch ($this->tipo) {
                         case "albaran":
                             if (isset($_REQUEST["action"])) {
                                 $accion = $_REQUEST["action"];
                             } else {
                                 $accion = "";
                             }
                             require_model("albaran_cliente.php");
                             $a = new albaran_cliente();
                             $b = $a->get($this->id);
                             $numero2 = $b->numero2;
                             $path = "images/autoventas/firmas";
                             switch ($accion) {
                                 case "sincroniza":
                                     $op = new autoventas_opcionesdb();
                                     $opciones = new autoventas_opcionesdb($op->load());
                                     $url = $opciones->url . "/images/autoventas/firmas/{$numero2}.jpg";
                                     if (@get_headers($url)[0] == 'HTTP/1.1 404 Not Found') {
                                         $this->new_error_msg('El archivo de firma no existe.');
                                     } else {
                                         $archivo = file_get_contents($url);
                                         if ($archivo) {
                                             file_put_contents($path . "/" . $numero2 . ".jpg", $archivo);
                                         }
                                     }
                                     break;
                                 case "borra":
                                     if (file_exists($path . "/{$numero2}.jpg")) {
                                         unlink($path . "/{$numero2}.jpg");
                                     }
                                     break;
                                 default:
                             }
                             if (!file_exists($path)) {
                                 if (!mkdir($path, 0777, TRUE)) {
                                     $this->new_error_msg('Error al crear la carpeta images/autoventas/familias.');
                                 }
                             }
                             if (!file_exists($path . "/{$numero2}.jpg")) {
                                 $this->firmaUrl = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAASwAAAEsCAMAAABOo35HAAAACXBIWXMAAAsTAAALEwEAmpwYAAAKT2lDQ1BQaG90b3Nob3AgSUNDIHByb2ZpbGUAAHjanVNnVFPpFj333vRCS4iAlEtvUhUIIFJCi4AUkSYqIQkQSoghodkVUcERRUUEG8igiAOOjoCMFVEsDIoK2AfkIaKOg6OIisr74Xuja9a89+bN/rXXPues852zzwfACAyWSDNRNYAMqUIeEeCDx8TG4eQuQIEKJHAAEAizZCFz/SMBAPh+PDwrIsAHvgABeNMLCADATZvAMByH/w/qQplcAYCEAcB0kThLCIAUAEB6jkKmAEBGAYCdmCZTAKAEAGDLY2LjAFAtAGAnf+bTAICd+Jl7AQBblCEVAaCRACATZYhEAGg7AKzPVopFAFgwABRmS8Q5ANgtADBJV2ZIALC3AMDOEAuyAAgM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64j8bWm5bAZDzX/G22jX9w7ZtSfvMd0ith5v27dA9b92nycttTdjx+eO9Nj+Yr8WJZS/A+g6QdfHFlQWU2jBEASzAAizA+qMLZkN4FmABFmABFgpmQ3gWYAEWYAEWCmABFmABFmABFgpgARZgARZgARYKYAEWYAEWYAEWCmABFmABFmABFgpgARZgARZgARYKYAEWYAEWYAEWCmABFmABFmABFgpgARZgARZgARYKYAHWY8q/AwC5r4fHLh7jqQAAAABJRU5ErkJggg==";
                                 $this->firmaSolicitar = 1;
                             } else {
                                 $this->firmaUrl = "{$path}/{$numero2}.jpg";
                                 $this->firmaSolicitar = 0;
                             }
                             break;
                         case "pedido":
                             if (isset($_REQUEST["action"])) {
                                 $accion = $_REQUEST["action"];
                             } else {
                                 $accion = "";
                             }
                             require_model("pedido_cliente.php");
                             $a = new pedido_cliente();
                             $b = $a->get($this->id);
                             $numero2 = $b->numero2;
                             $path = "images/autoventas/firmas";
                             switch ($accion) {
                                 case "sincroniza":
                                     $op = new autoventas_opcionesdb();
                                     $opciones = new autoventas_opcionesdb($op->load());
                                     $url = $opciones->url . "/images/autoventas/firmas/{$numero2}.jpg";
                                     if (@get_headers($url)[0] == 'HTTP/1.1 404 Not Found') {
                                         $this->new_error_msg('El archivo de firma no existe.');
                                     } else {
                                         $archivo = file_get_contents($url);
                                         if ($archivo) {
                                             file_put_contents($path . "/" . $numero2 . ".jpg", $archivo);
                                         }
                                     }
                                     break;
                                 case "borra":
                                     if (file_exists($path . "/{$numero2}.jpg")) {
                                         unlink($path . "/{$numero2}.jpg");
                                     }
                                     break;
                                 default:
                             }
                             if (!file_exists($path)) {
                                 if (!mkdir($path, 0777, TRUE)) {
                                     $this->new_error_msg('Error al crear la carpeta images/autoventas/familias.');
                                 }
                             }
                             if (!file_exists($path . "/{$numero2}.jpg")) {
                                 $this->firmaUrl = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAASwAAAEsCAMAAABOo35HAAAACXBIWXMAAAsTAAALEwEAmpwYAAAKT2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/3MzDmi7lFa+qFbdf6e+VSCfbXI6XvKs6JDtpNiR/NRx51gLliGl4ZhdeaQ+UgjkLBA9NhHFl9wrLS+B47VdY/wrPKp90xXOak+fKTBxevQSybQ1FJLcnxpPuo2CSzGtYzQWbzCsbxEy3L5GJ8Mx7j9wnbnW997kWNlREENSzEZOvEkwXoWuyTlcmkDo+/0j6d4x+K/gZWFoTwK+QTB1HhW5pXDnkkb0mIX/HXQmumDOwOrub4f3DN44Cbqlvl+NgS+ZtLoPaHudnsQLJW+dzX6zrkWr+/R/x/6nhgasWOdgqXR97FK3zlYucUOn3MseueXGROfk+Wq1noW+e/yzhNM9wqV7KWWD6NEK1lt5s7EK9f49VfGs3w5QYo64j8bWm5bAZDzX/G22jX9w7ZtSfvMd0ith5v27dA9b92nycttTdjx+eO9Nj+Yr8WJZS/A+g6QdfHFlQWU2jBEASzAAizA+qMLZkN4FmABFmABFgpmQ3gWYAEWYAEWCmABFmABFmABFgpgARZgARZgARYKYAEWYAEWYAEWCmABFmABFmABFgpgARZgARZgARYKYAEWYAEWYAEWCmABFmABFmABFgpgARZgARZgARYKYAHWY8q/AwC5r4fHLh7jqQAAAABJRU5ErkJggg==";
                                 $this->firmaSolicitar = 1;
                             } else {
                                 $this->firmaUrl = "{$path}/{$numero2}.jpg";
                                 $this->firmaSolicitar = 0;
                             }
                             break;
                         default:
                             $this->new_error_msg("Autoventas: Tipo de documento desconocido");
                     }
                 }
                 $this->template = "autoventas_firma";
                 break;
             case "imprimir":
                 $this->albaran = FALSE;
                 $this->cliente = FALSE;
                 $this->pedido = FALSE;
                 $this->impuesto = new impuesto();
                 /// obtenemos los datos de configuración de impresión
                 $this->impresion = array('print_ref' => '1', 'print_dto' => '1', 'print_alb' => '0', 'print_formapago' => '1');
                 $fsvar = new fs_var();
                 $this->impresion = $fsvar->array_get($this->impresion, FALSE);
                 $this->logo = FALSE;
                 if (file_exists('tmp/' . FS_TMP_NAME . 'logo.png')) {
                     $this->logo = 'tmp/' . FS_TMP_NAME . 'logo.png';
                 } else {
                     if (file_exists('tmp/' . FS_TMP_NAME . 'logo.jpg')) {
                         $this->logo = 'tmp/' . FS_TMP_NAME . 'logo.jpg';
                     }
                 }
                 if (isset($_REQUEST['albaran']) and isset($_REQUEST['id'])) {
                     $alb = new albaran_cliente();
                     $this->albaran = $alb->get($_REQUEST['id']);
                     if ($this->albaran) {
                         $cliente = new cliente();
                         $this->cliente = $cliente->get($this->albaran->codcliente);
                     }
                     if (isset($_POST['email'])) {
                         $this->enviar_email('albaran');
                     } else {
                         $this->generar_pdf_albaran();
                     }
                 } else {
                     if (isset($_REQUEST['pedido']) and isset($_REQUEST['id'])) {
                         require_model("pedido_cliente.php");
                         $fac = new pedido_cliente();
                         $this->pedido = $fac->get($_REQUEST['id']);
                         if ($this->pedido) {
                             $cliente = new cliente();
                             $this->cliente = $cliente->get($this->pedido->codcliente);
                         }
                         if (isset($_POST['email'])) {
                             $this->enviar_email('pedido');
                         } else {
                             $this->generar_pdf_pedido();
                         }
                     }
                 }
                 break;
             default:
                 $this->new_error_msg('Autoventas: Error categoría desconocida');
         }
     } else {
         $this->new_error_msg('Autoventas: Error sin categoría');
     }
 }