Lantture core

WPTurbo » Snippets » Lantture core
0

Created with:

Custom snippet Generator

Visibility: 

public

Creator: Odair Ferreira

Customize with WPTurbo AI
X

Add Snippet To Project

New Project
Add To Existing Project
				<?php
/**
 * Plugin Name: Lantture Core (SaaS Engine)
 * Plugin URI:  https://lantture.com
 * Description: Motor principal do Ecossistema SaaS Lantture. Gerencia Bancos de Dados, Segurança e Infraestrutura Zero Receptionist.
 * Version:     1.0.0
 * Author:      Odair Ferreira Barbosa
 * Text Domain: lantture-core
 */

if (!defined('ABSPATH')) {
    exit;
}

define('LANTTURE_CORE_VERSION', '1.0.0');
define('LANTTURE_CORE_DIR', plugin_dir_path(__FILE__));

add_action('init', 'lt_core_register_databases');

function lt_core_register_databases() {
    if (!get_role('profissional_equipe')) {
        add_role('profissional_equipe', 'Profissional da Equipe', ['read' => true]);
    }

    $cpts = [
        'lt_agendamento'    => 'Agendamentos (Matriz)',
        'lt_espera'         => 'Lista de Espera',
        'lt_cliente'        => 'Clientes Locais',
        'lt_servico'        => 'Catálogo de Serviços',
        'lt_recurso'        => 'Recursos e Salas',
        'lt_pacote_cliente' => 'Pacotes Vendidos',
        'lt_produto'        => 'Estoque e Insumos',
        'lt_ficha_custo'    => 'Fichas Técnicas',
        'lt_fornecedor'     => 'Fornecedores',
        'lt_transacao'      => 'Transações Financeiras'
    ];

    foreach ($cpts as $slug => $name) {
        if (!post_type_exists($slug)) {
            register_post_type($slug, [
                'label'    => $name,
                'public'   => false,
                'show_ui'  => true,
                'supports' => ['title', 'custom-fields']
            ]);
        }
    }
}

register_activation_hook(__FILE__, 'lt_core_activate_plugin');

function lt_core_activate_plugin() {
    lt_core_register_databases();
    flush_rewrite_rules();

    global $wpdb;
    $table_name = $wpdb->prefix . 'agendamentos_salao';
    $charset_collate = $wpdb->get_charset_collate();

    $sql = "CREATE TABLE $table_name (
        id mediumint(9) NOT NULL AUTO_INCREMENT,
        nome_cliente varchar(100) NOT NULL,
        whatsapp varchar(20) NOT NULL,
        servico_id varchar(100) NOT NULL,
        profissional_id int(11) NOT NULL,
        data_agendamento date NOT NULL,
        hora_inicio time NOT NULL,
        hora_fim time NOT NULL,
        status enum('pendente', 'confirmado', 'checkin', 'cancelado') DEFAULT 'pendente' NOT NULL,
        PRIMARY KEY  (id),
        KEY data_agendamento (data_agendamento)
    ) $charset_collate;";

    require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
    dbDelta($sql);

    if(get_option('lt_mod_financeiro') === false) update_option('lt_mod_financeiro', 'on');
    if(get_option('lt_mod_estoque') === false) update_option('lt_mod_estoque', 'on');
    if(get_option('lt_mod_radar') === false) update_option('lt_mod_radar', 'on');
    if(get_option('lt_mod_whatsapp') === false) update_option('lt_mod_whatsapp', 'on');
}
			

Register an account to save your snippets or go Pro to get more features.