<?php
/*
    *****************************************************************************
    * MEGA Digital Space - by MEGA Digital Studio                               *
    * ------------------------------------------------------------------------- *
    * CMS Website:  https://megadigital.space                                   *
    * License:  https://megadigital.space/license                               *
    * Owner:  Giorgi Basharuli                                                  *
    * Contact:  online@megadigital.studio                                       *
    * MEGA Digital Studio – Official Development Studio for MEGA Digital Space  *
    * Website:  https://megadigital.studio                                      *
    * ------------------------------------------------------------------------- *
    * Description: This file is a part of the MEGA Digital Space CMS system.    *
    * Unauthorized distribution, modification, or commercial use is strictly -  *
    * prohibited without prior written permission.                              *
    * ------------------------------------------------------------------------- *
    * Copyright (c) 2023-2025 MEGA Digital Studio.                              *
    * All rights reserved.                                                      *
    *****************************************************************************
*/

require_once(ENGINE_DIR . '/data/config.php');
function joinWidgetToObjectController()
{
    global $db_connect;

    if (!empty($_POST["widget_id"]) && !empty($_POST["object_name"]) && !empty($_POST["object_id"])) {

        $db_connect->insert("widget_objects", [
           "widget_id" => $_POST["widget_id"],
           "object_name" => $_POST["object_name"],
           "object_id" => $_POST["object_id"],
           "widget_name" => "payment_widgets",
        ]);

        header("location: ". $_SERVER["HTTP_REFERER"]);
    }

}


function deleteWidgetObjectRelationController()
{
    global $db_connect;
    if (!empty($_POST["widget_id"]) && !empty($_POST["object_id"])) {
        $db_connect->delete("widget_objects", ["object_id" => $_POST["object_id"], "widget_id" => $_POST["widget_id"]]);

        header("location: ". $_SERVER["HTTP_REFERER"]);
    }
}