Ejemplo n.º 1
0
 private function new_articulo()
 {
     /// desactivamos la plantilla HTML
     $this->template = FALSE;
     $art0 = new articulo();
     $art0->referencia = $_REQUEST['referencia'];
     if ($art0->exists()) {
         $this->results[] = $art0->get($_REQUEST['referencia']);
     } else {
         $art0->descripcion = $_REQUEST['descripcion'];
         $art0->set_impuesto($_REQUEST['codimpuesto']);
         $art0->set_pvp(floatval($_REQUEST['pvp']));
         $art0->costemedio = floatval($_REQUEST['coste']);
         $art0->preciocoste = floatval($_REQUEST['coste']);
         $art0->publico = isset($_POST['publico']);
         if ($_POST['codfamilia'] != '') {
             $art0->codfamilia = $_REQUEST['codfamilia'];
         }
         if ($_POST['codfabricante'] != '') {
             $art0->codfabricante = $_REQUEST['codfabricante'];
         }
         if ($_POST['refproveedor'] != '' and $_POST['refproveedor'] != $_POST['referencia']) {
             $art0->equivalencia = $_POST['refproveedor'];
         }
         if ($art0->save()) {
             $art0->coste = floatval($_POST['coste']);
             $art0->dtopor = 0;
             /// buscamos y guardamos el artículo del proveedor
             $ap = $this->articulo_prov->get_by($art0->referencia, $_POST['codproveedor'], $_POST['refproveedor']);
             if ($ap) {
                 $art0->coste = $ap->precio;
                 $art0->dtopor = $ap->dto;
             } else {
                 $ap = new articulo_proveedor();
                 $ap->codproveedor = $_POST['codproveedor'];
             }
             $ap->referencia = $art0->referencia;
             $ap->refproveedor = $_POST['refproveedor'];
             $ap->descripcion = $art0->descripcion;
             $ap->codimpuesto = $art0->codimpuesto;
             $ap->precio = floatval($_POST['coste']);
             /// pero solamente si tiene una refproveedor asignada
             if ($_POST['refproveedor'] != '') {
                 $ap->save();
             }
             $this->results[] = $art0;
         }
     }
     header('Content-Type: application/json');
     echo json_encode($this->results);
 }
Ejemplo n.º 2
0
 private function new_articulo()
 {
     /// desactivamos la plantilla HTML
     $this->template = FALSE;
     $art0 = new articulo();
     $art0->referencia = $_REQUEST['referencia'];
     if ($art0->exists()) {
         $this->results[] = $art0->get($_REQUEST['referencia']);
     } else {
         $art0->descripcion = $_REQUEST['descripcion'];
         $art0->set_impuesto($_REQUEST['codimpuesto']);
         $art0->set_pvp(floatval($_REQUEST['pvp']));
         if ($_REQUEST['codfamilia'] != '') {
             $art0->codfamilia = $_REQUEST['codfamilia'];
         }
         if ($_REQUEST['codfabricante'] != '') {
             $art0->codfabricante = $_REQUEST['codfabricante'];
         }
         if ($art0->save()) {
             $this->results[] = $art0;
         }
     }
     header('Content-Type: application/json');
     echo json_encode($this->results);
 }
Ejemplo n.º 3
0
<?php

ini_set('xdebug.var_display_max_depth', -1);
ini_set('xdebug.var_display_max_children', 256);
ini_set('xdebug.var_display_max_data', 1024);
require 'include/clases.php';
if (!(isset($_GET["id"]) && articulo::exists($_GET["id"]) || isset($_GET["sub"]) && articulo::exists(articulo::idSubToId($_GET["sub"])))) {
    header($_SERVER["SERVER_PROTOCOL"] . " 404 Not Found");
    exit("Item doesn't exist.");
    //ARTICULO NO EXISTE
}
if (false) {
    var_dump(articulo::get($_GET["id"]));
    exit;
}
?>

<html>
<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script src="js/jquery-1.11.1.min.js"></script>
    <meta name="viewport" content="width=device-width">
<!---<script src="https://code.jquery.com/jquery-1.10.2.js"></script>--->
     <script src="js/functions.js"></script>
     <script src="js/colors.js"></script>
    <script src="js/funciones.js"></script>
    <script src="js/perfilArt.js"></script>
    <script>
            $(document).ready(function(){
                if(!doesExist($('.subart[name=1]'))){