<?php
/* Module descriptor for Scrap */

include_once DOL_DOCUMENT_ROOT . "/core/modules/DolibarrModules.class.php";

class modScrap extends DolibarrModules
{
    public function __construct($db)
    {
        global $langs;

        $this->db = $db;

        // Module identity
        $this->numero = 123456; // Use a unique number >100000
        $this->rights_class = 'scrap';
        $this->family = "technic"; // or 'products', 'crm', etc.
        $this->name = "scrap";     // Same as directory name
        $this->description = "Module for managing scrap items and costs";
        $this->version = '1.0.0';
        $this->const_name = 'MAIN_MODULE_SCRAP'; // Important: matches folder name
        $this->editor_name = 'YourName';
        $this->editor_url = 'https://yourwebsite.com';
        $this->picto = 'generic'; // Or custom icon

        // Dependencies (if needed)
        $this->depends = array("modProduct", "modStock");
        $this->requiredby = array();
        $this->conflictwith = array();
        $this->langfiles = array("scrap@scrap");

        // Data directories to create
        $this->dirs = array("/scrap/temp");

        // Config pages (optional)
        $this->config_page_url = array("admin/scrap_setup.php@scrap");

        // Module is always enabled (set to 0 if you want it to be disabled by default)
        $this->always_enabled = 0;

        // Icon for the module
        $this->module_parts = array();

        // Add menus
        $this->menu = array();

        // Rights (if needed)
        $this->rights = array();
        $r = 0;

        $this->rights[$r][0] = 123456; // ID
        $this->rights[$r][1] = 'Read scrap records';
        $this->rights[$r][2] = 'r';
        $this->rights[$r][3] = 1;
        $this->rights[$r][4] = 'read';
        $r++;

        $this->rights[$r][0] = 123457; // ID
        $this->rights[$r][1] = 'Create/modify scrap records';
        $this->rights[$r][2] = 'w';
        $this->rights[$r][3] = 1;
        $this->rights[$r][4] = 'write';
        $r++;
    }

    /**
     * Init module: create database structures, constants, etc.
     */
    public function init($options = '')
    {
        $sql = array();

        // Load SQL file to create tables
        $this->_load_tables('/scrap/sql/');

        return $this->_init($sql, $options);
    }

    /**
     * Remove module: delete tables, constants, etc.
     */
    public function remove($options = '')
    {
        $sql = array();

        return $this->_remove($sql, $options);
    }
}

