Skip to main content

Quick Start Guide

Get Pro Stock Tool operational in just a few minutes by following these simple steps.
1

Install Prerequisites

Ensure you have the required software installed:
  • PHP 7.4 or higher with MySQLi extension
  • MySQL 5.7 or higher
  • Web Server (Apache, Nginx, or PHP built-in server)
  • Modern web browser (Chrome, Firefox, Safari, or Edge)
Verify PHP installation:
php --version
php -m | grep mysqli
Verify MySQL installation:
mysql --version
2

Clone or Download the Project

Download the Pro Stock Tool source code:
# Clone from repository (if using Git)
git clone <repository-url> Pro-Stock-Tool
cd Pro-Stock-Tool
Or download and extract the ZIP file to your web server directory.
Place the project in your web server’s document root (e.g., /var/www/html for Apache or htdocs for XAMPP).
3

Create the Database

Create the MySQL database and tables:
mysql -u root -p
Then execute the following SQL:
CREATE DATABASE prostocktool;
USE prostocktool;

-- Create warehouses table
CREATE TABLE bodegas (
  id INT AUTO_INCREMENT PRIMARY KEY,
  nombre VARCHAR(100) NOT NULL UNIQUE,
  descripcion TEXT,
  fecha_creacion DATETIME DEFAULT CURRENT_TIMESTAMP,
  fecha_actualizacion DATETIME DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP
);

-- Create categories table
CREATE TABLE categorias (
  id INT AUTO_INCREMENT PRIMARY KEY,
  nombre VARCHAR(50) NOT NULL UNIQUE,
  descripcion VARCHAR(200),
  color VARCHAR(7) DEFAULT '#2e6df6',
  estado VARCHAR(20) DEFAULT 'ACTIVO',
  fecha_creacion DATETIME DEFAULT CURRENT_TIMESTAMP,
  fecha_actualizacion DATETIME DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP
);

-- Create subcategories table
CREATE TABLE subcategorias (
  id INT AUTO_INCREMENT PRIMARY KEY,
  nombre VARCHAR(50) NOT NULL,
  descripcion VARCHAR(200),
  categoria_id INT NOT NULL,
  fecha_creacion DATETIME DEFAULT CURRENT_TIMESTAMP,
  fecha_actualizacion DATETIME DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP,
  FOREIGN KEY (categoria_id) REFERENCES categorias(id) ON DELETE CASCADE
);

-- Create parameters table
CREATE TABLE parametros (
  id INT AUTO_INCREMENT PRIMARY KEY,
  codigo VARCHAR(10) NOT NULL UNIQUE,
  nombre VARCHAR(50) NOT NULL UNIQUE,
  descripcion TEXT,
  color VARCHAR(7) DEFAULT '#4a90e2',
  fecha_creacion DATETIME DEFAULT CURRENT_TIMESTAMP,
  fecha_actualizacion DATETIME DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP
);

-- Create suppliers table
CREATE TABLE proveedores (
  id INT AUTO_INCREMENT PRIMARY KEY,
  nif VARCHAR(20),
  nombre VARCHAR(100) NOT NULL,
  contacto VARCHAR(100),
  email VARCHAR(100),
  telefono VARCHAR(20),
  direccion TEXT,
  ciudad VARCHAR(100),
  web VARCHAR(200),
  terminos INT,
  parametro_id INT,
  fecha_creacion DATETIME DEFAULT CURRENT_TIMESTAMP,
  fecha_actualizacion DATETIME DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP,
  FOREIGN KEY (parametro_id) REFERENCES parametros(id) ON DELETE SET NULL
);

-- Create users table
CREATE TABLE usuarios (
  id INT AUTO_INCREMENT PRIMARY KEY,
  email VARCHAR(100) NOT NULL UNIQUE,
  nombre VARCHAR(100) NOT NULL,
  identidad VARCHAR(20) NOT NULL UNIQUE,
  password VARCHAR(255) NOT NULL,
  creado_en DATETIME DEFAULT CURRENT_TIMESTAMP
);

-- Create products table (placeholder)
CREATE TABLE productos (
  id INT AUTO_INCREMENT PRIMARY KEY,
  nombre VARCHAR(100) NOT NULL,
  bodega_id INT,
  categoria_id INT,
  parametro_id INT,
  fecha_creacion DATETIME DEFAULT CURRENT_TIMESTAMP,
  FOREIGN KEY (bodega_id) REFERENCES bodegas(id),
  FOREIGN KEY (categoria_id) REFERENCES categorias(id),
  FOREIGN KEY (parametro_id) REFERENCES parametros(id)
);
The schema above includes referential integrity with foreign key constraints to maintain data consistency.
4

Configure Database Connection

Update the database connection settings in database/conexion.php:
database/conexion.php
<?php

$host = "localhost";
$user = "root";           // Change to your MySQL username
$pass = "";                // Change to your MySQL password
$db = "prostocktool";

$conn = new mysqli($host, $user, $pass, $db);
if ($conn->connect_errno) {
    http_response_code(500);
    echo json_encode(["error" => "Error de conexión a la base de datos"]);
    exit;
}
?>
Production Security: Never use root with an empty password in production. Create a dedicated database user with limited privileges.
5

Start the Web Server

Start your web server. If using PHP’s built-in server:
cd Pro-Stock-Tool
php -S localhost:8000
For XAMPP/WAMPP users, ensure Apache and MySQL services are running.
6

Access the Application

Open your browser and navigate to:
http://localhost:8000/login.html
Or if using Apache:
http://localhost/Pro-Stock-Tool/login.html
You should see the registration/login page.

First Steps

Once installed, here’s what to do next:

1. Create Your First User

Register a new user account:
// Registration API endpoint
POST http://localhost/Pro-Stock-Tool/database/registro.php

// Request body
{
  "email": "[email protected]",
  "nombre": "John Doe",
  "identidad": "1234567890",
  "contrasena": "securepassword123"
}
Or use the registration form at /login.html.
Password Requirements: Passwords must be at least 6 characters long. They are hashed using bcrypt before storage.

2. Create a Warehouse

Create your first warehouse using the API:
const API_URL = 'http://localhost/Pro-Stock-Tool/database/bodega.php';

const response = await fetch(API_URL, {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    nombre: 'Main Warehouse',
    descripcion: 'Primary storage facility'
  })
});

const data = await response.json();
console.log(data);
// { success: true, id: 1, message: 'Bodega creada exitosamente' }

3. Add Product Categories

Organize your inventory with categories:
const response = await fetch('http://localhost/Pro-Stock-Tool/database/categorias.php', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    nombre: 'Electronics',
    descripcion: 'Electronic devices and components',
    color: '#2e6df6',
    estado: 'ACTIVO'
  })
});

const data = await response.json();
// { success: true, id: 1, message: 'Categoría creada exitosamente' }

4. Add Suppliers

Register your suppliers:
const response = await fetch('http://localhost/Pro-Stock-Tool/database/proveedores.php', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    nif: 'B12345678',
    nombre: 'Tech Supplies Inc.',
    contacto: 'Jane Smith',
    email: '[email protected]',
    telefono: '+1-555-0123',
    direccion: '123 Tech Street',
    ciudad: 'San Francisco',
    web: 'https://techsupplies.com',
    terminos: 30
  })
});

const data = await response.json();
// { success: true, id: 1, message: 'Proveedor creado' }

Testing the API

Verify everything is working by testing the warehouse endpoint:
curl -X GET http://localhost/Pro-Stock-Tool/database/bodega.php
Expected response:
{
  "success": true,
  "data": [
    {
      "id": "1",
      "nombre": "Main Warehouse",
      "descripcion": "Primary storage facility"
    }
  ]
}

Common Issues

If you see “Error de conexión a la base de datos”:
  1. Verify MySQL is running: sudo service mysql status
  2. Check credentials in database/conexion.php
  3. Ensure the database prostocktool exists
  4. Verify MySQLi extension is enabled: php -m | grep mysqli
The API includes CORS headers by default. If you still get CORS errors:
  1. Ensure you’re accessing via the same protocol (http/https)
  2. Check that the API URL matches your server configuration
  3. Verify the CORS headers in the PHP files are not being stripped by your server
  1. Verify the file path is correct
  2. Ensure your web server is configured to serve PHP files
  3. Check that mod_rewrite is enabled (for Apache)
  4. Verify file permissions allow reading
  1. Check for PHP errors: enable error display in php.ini
  2. Look at the browser Network tab for the actual response
  3. Verify JSON data is being sent with correct Content-Type header
  4. Check for UTF-8 encoding issues

Next Steps

Detailed Installation

Learn about advanced installation options and production deployment

API Reference

Explore the complete API documentation for all endpoints

Configuration

Configure advanced settings and customize the application

Features

Discover all the features and capabilities of Pro Stock Tool

Build docs developers (and LLMs) love