*

mwindey

  • *****
  • 478 posts
Not able to delete auction when finished
« on: February 12, 2024, 04:43:30 PM »
In admin i am not able to delete finished auctions. Link delete refreshes page.... Also a warning in apache saying [Mon Feb 12 16:28:36.461707 2024] [lsapi:warn] [pid 105584:tid 140072942647040] [client 2a02:1811:b055:6200:8d6b:eb35:198c:382d:53092] [host ***.be] Backend log: PHP Warning:  Undefined variable $user_id in /home/u44173p136925/domains/***be/public_html/oc-content/plugins/auction/functions.php on line 2402\n, referer: https://***.be/auctions/auctions

*

MB Themes

Re: Not able to delete auction when finished
« Reply #1 on: February 12, 2024, 04:58:44 PM »
@MWINDEY
thanks both will be fixed in next update.
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

*

mwindey

  • *****
  • 478 posts
Re: Not able to delete auction when finished
« Reply #2 on: February 12, 2024, 05:18:46 PM »
@MB Themes,

Super, looking forward to it.... Thanks for this great plugin it is magnificent  :P

*

mwindey

  • *****
  • 478 posts
Re: Not able to delete auction when finished
« Reply #3 on: February 12, 2024, 09:53:42 PM »
@MB Themes,

Updated but still not possible to delete auctions in admin area by clicking the garbage can. The page renews but it is not deleting item.

*

MB Themes

Re: Not able to delete auction when finished
« Reply #4 on: February 13, 2024, 08:16:50 AM »
Well you cannot het update that is not yet released  ;D
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

*

mwindey

  • *****
  • 478 posts
Re: Not able to delete auction when finished
« Reply #5 on: February 23, 2024, 04:07:43 PM »
Well ok...I thought it was an update i did fom 1.0.4 to 1.0.5 at that time but nevermind  :D ...
I do have one suggestion... While you are working on the update, is it also possible to place a link in the active classifieds to start an auction or is this rather template dependent?

*

mwindey

  • *****
  • 478 posts
Re: Not able to delete auction when finished
« Reply #6 on: February 25, 2024, 08:57:14 PM »
For epsilon i created the link in user-items page to start the auction from there...probably works on other themes also
Code: [Select]
<?php if (function_exists('act_header_link_hook')) { ?>
<form class="act-form nocsrf" method="POST" name="act-form" action="" enctype="multipart/form-data">
    <input type="hidden" name="action" value="createauction">
    <input type="hidden" name="actItemId" id="actItemId" value="<?php echo osc_item_id(); ?>">
<button type="button" class="act-btn act-btn-primary" onclick="confirmStartAuction(this)">Start auction</button>
</form>
<script>
function confirmStartAuction(button) {
    var confirmation = confirm("If you proceed, the auction will start immediately and become active. You are required to adjust the auction settings immediately after starting. Note: You are obligated to sell the item to the highest bidder. Are you sure you want to proceed?");
    if (confirmation) {
        startAuction(button);
    } else {
        alert("Auction has been canceled");
    }
}
function startAuction(button) {
    var itemId = button.parentElement.querySelector("#actItemId").value;
    if (itemId !== "") {
        window.location.href = "<?php echo osc_route_url('act-create-item-auction', array('createItemId' => '')); ?>" + itemId;
    }
}
</script>
<?php ?>

*

MB Themes

Re: Not able to delete auction when finished
« Reply #7 on: February 26, 2024, 08:25:11 AM »
@mwindey
We do not have hook for buttons on user items.
Besides that you should also check if auction is eligible for start ;)
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

*

mwindey

  • *****
  • 478 posts
Re: Not able to delete auction when finished
« Reply #8 on: February 26, 2024, 09:29:09 PM »
Ok so i ceated a hook and when starting an auction it points to auction-edit page so that if osclass pay is required before activation it does not start.
Same as on the auction page itself.... Button to select/deselect in admin area was added.

Few steps to follow and it works.

step1: In user-items.php from THEME find:

Code: [Select]
<a class="delete" onclick="return confirm('<?php echo osc_esc_js(__('Are you sure you want to delete this listing? This action cannot be undone.''epsilon')); ?>')" href="<?php echo osc_item_delete_url(); ?>"><i class="fas fa-trash"></i> <?php _e('Delete''epsilon'); ?></a>
Underneath add:

Code: [Select]
<div class="auction">
<script>
    function startAuctionFromItemPage(itemId) {
        var firstConfirmation = confirm(<?php echo json_encode(__('If you proceed, the auction will start immediately and become active. You are required to adjust the auction settings immediately after starting. Note: You are obligated to sell the item to the highest bidder. Are you sure you want to proceed?''epsilon')); ?>);

        if (firstConfirmation) {
            var secondConfirmation = confirm(<?php echo json_encode(__('IMPORTANT: Please do not forget to set the duration and price for your auction after clicking on \'Proceed\', otherwise the auction will become active and will be offered at the lowest price. Are you sure you want to proceed?''epsilon')); ?>);

            if (secondConfirmation) {
                startAuction(itemId);
            } else {
                alert(<?php echo json_encode(__('Auction has been canceled''epsilon')); ?>);
            }
        } else {
            alert(<?php echo json_encode(__('Auction has been canceled''epsilon')); ?>);
        }
    }

    function startAuction(itemId) {
        if (itemId !== "") {
            window.location.href = <?php echo json_encode(osc_route_url('act-create-item-auction', array('createItemId' => ''))); ?> + itemId;
        }
    }
</script>

<?php 
    
if (function_exists('act_item_link_hook') && act_item_link_hook() == 1) { 
        
osc_add_hook('item_links''act_item_link_hook');
    } 
?>

</div>

step2 THEME CSS / file style.css search for:  USER ITEMS and underneath add:

Code: [Select]
.start-auction-btn { padding: 6px 8px; margin: 6px 6px 0 0; border-radius: 6px; background: #00bdd6; color: #fff; font-size: 13px; font-weight: 600; line-height: 1.2; box-shadow: 0 0 0 1px rgb(59 73 223 / 30%) inset; text-decoration: none; cursor: pointer; transition: background 0.2s, color 0.2s;}
.start-auction-btn:hover { background: #2f3ab2; color: #fff;}

Step3: SELECT PLUGIN AUCTION MAP / index.php from AUCTION plugin find:

Code: [Select]
osc_set_preference('hook_header_links', 1, 'plugin-auction', 'BOOLEAN');
Underneath that line add:
Code: [Select]
osc_set_preference('hook_item_links', 1, 'plugin-auction', 'BOOLEAN');

Step4: In functions.php from plugin find:

Code: [Select]
osc_add_hook('header_links', 'act_header_link_hook');

Underneath add:
Code: [Select]
// ADD AUCTION LINK IN USER ITEMS
function act_item_link_hook() {
  if(act_param('hook_item_links') == 1) {
     echo '<button type="button" class="start-auction-btn act" onclick="startAuctionFromItemPage(' . osc_item_id() . ')">' . __('Start Auction', 'auction') . '</button>';
  }
}

Step5: in admin/configure.php  from  AUCTION plugin find:

Code: [Select]
$hook_header_links = mb_param_update('hook_header_links', 'plugin_action', 'check', 'plugin-auction');

Underneath that line add:

Code: [Select]
$hook_item_links = mb_param_update('hook_item_links', 'plugin_action', 'check', 'plugin-auction');

In the same file find:

Code: [Select]
        <div class="mb-row">
          <label for="hook_header_links" class=""><span><?php _e('Add Auctions Button to Header''auction'); ?></span></label>
          <input name="hook_header_links" id="hook_header_links" type="checkbox" class="element-slide" <?php echo ($hook_header_links == 'checked' ''); ?> />
         
          <div class="mb-explain">
            <div class="mb-line"><?php _e('When enabled, button to search page with auctions only is added to header. Require Osclass Hooks 8.2 support.''auction'); ?></div>
          </div>
        </div>
       
       
        <hr/>

Underneath that line add:

Code: [Select]
        <div class="mb-row">
          <label for="hook_item_links" class=""><span><?php _e('Add Auctions Button to User items''auction'); ?></span></label>
          <input name="hook_item_links" id="hook_item_links" type="checkbox" class="element-slide" <?php echo ($hook_item_links == 'checked' ''); ?> />
         
          <div class="mb-explain">
            <div class="mb-line"><?php _e('When enabled, button to initialize auction is added to user active items. Require Osclass Hooks 8.2 support.''auction'); ?></div>
          </div>
        </div>
       
       
        <hr/>

Your done  ;)



« Last Edit: February 27, 2024, 09:26:04 PM by mwindey »

*

MB Themes

Re: Not able to delete auction when finished
« Reply #9 on: February 27, 2024, 09:38:30 AM »
Cool  ???
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

*

mwindey

  • *****
  • 478 posts
Re: Not able to delete auction when finished
« Reply #10 on: February 27, 2024, 02:59:36 PM »
@MB Themes

I also added the delete option in admin and looks like this is the solution...Tested and works for me.... Can you please double check this?
complete file admin/auction_edit

Code: [Select]
<?php
// Check if deleteId parameter is present
$deleteId Params::getParam('deleteId');
if(
$deleteId 0) {
    
// Create an instance of ModelACT
    
$modelACT = new ModelACT();
    
// Retrieve the deleteId parameter again
    
$deleteId Params::getParam('deleteId');
    if(
$deleteId 0) {
        
// Call deleteAuction function with the deleteId as argument
        
$result $modelACT->deleteAuction($deleteId);
        
        if(
$result) {
            
// Add success message if auction is successfully deleted
            
osc_add_flash_ok_message(__('Auction successfully deleted.''auction'), 'admin');

            
// Redirect to prevent the rest of the code from executing
            
header('Location:' osc_admin_base_url(true) . '?page=plugins&action=renderplugin&file=auction/admin/auction.php');
            exit;
        } else {
            
// Add error message if an error occurred while deleting the auction
            
osc_add_flash_error_message(__('An error occurred while deleting the auction.''auction'), 'admin');
        }
    }
}

// Check if editId parameter is present
$id Params::getParam('editId');
if(
$id <= 0) {
    
// Add flash message for invalid auction ID and redirect to appropriate page
    
osc_add_flash_ok_message(__('Invalid auction ID''auction'), 'admin');
    
header('Location:' osc_admin_base_url(true) . '?page=plugins&action=renderplugin&file=auction/admin/auction.php');
    exit;
}

// Retrieve auction data
$auction ModelACT::newInstance()->getAuction($id); 

// Check if the auction should not be closed, deactivated, etc.
$chk act_check_auction($auction);

// If auction found and changed
if($chk !== false && $chk !== true) {
    
$auction ModelACT::newInstance()->getAuction($id);
}

// Retrieve item data
$item Item::newInstance()->findByPrimaryKey($auction['fk_i_item_id']); 

// Set title
$title sprintf(__('Auction #%s: %s''auction'), $id, ((isset($item['s_title']) && $item['s_title'] <> '') ? $item['s_title'] : __('Item removed''auction')));
act_menu($title);

// Create links for submenu
$links = array();
$links[] = array('file' => '_auction_edit_bids.php''icon' => 'fa-gavel''title' => __('User Action Bids''auction'));
$links[] = array('file' => '_auction_edit_watchlist.php''icon' => 'fa-bell''title' => __('Watchlist Users''auction'));
$links[] = array('file' => '_auction_edit_notifications.php''icon' => 'fa-envelope''title' => __('User Notifications''auction'));
$links[] = array('file' => '_auction_edit_logs.php''icon' => 'fa-database''title' => __('Auction History (Logs)''auction'));
$links[] = array('file' => '_auction_edit_settings.php''icon' => 'fa-wrench''title' => __('Auction Settings''auction'));

// Show submenu
$file act_submenu('auction_edit.php'$linksParams::getParam('go_to_file'), '&editId=' $id);
require_once 
$file;
?>

« Last Edit: February 28, 2024, 09:05:42 PM by mwindey »

*

Sparky

  • ***
  • 89 posts
Re: Not able to delete auction when finished
« Reply #11 on: March 08, 2024, 04:41:28 PM »
Same issue with not being able to delete item from hot auction list after finished. I am assuming some updates are still in the works for this plugin.

*

mwindey

  • *****
  • 478 posts
Re: Not able to delete auction when finished
« Reply #12 on: March 08, 2024, 06:18:07 PM »
@Sparky,

If you Change the file to my solution it works perfectly.
Code: [Select]
<?php
// Check if deleteId parameter is present
$deleteId Params::getParam('deleteId');
if(
$deleteId 0) {
    
// Create an instance of ModelACT
    
$modelACT = new ModelACT();
    
// Retrieve the deleteId parameter again
    
$deleteId Params::getParam('deleteId');
    if(
$deleteId 0) {
        
// Call deleteAuction function with the deleteId as argument
        
$result $modelACT->deleteAuction($deleteId);
        
        if(
$result) {
            
// Add success message if auction is successfully deleted
            
osc_add_flash_ok_message(__('Auction successfully deleted.''auction'), 'admin');

            
// Redirect to prevent the rest of the code from executing
            
header('Location:' osc_admin_base_url(true) . '?page=plugins&action=renderplugin&file=auction/admin/auction.php');
            exit;
        } else {
            
// Add error message if an error occurred while deleting the auction
            
osc_add_flash_error_message(__('An error occurred while deleting the auction.''auction'), 'admin');
        }
    }
}

// Check if editId parameter is present
$id Params::getParam('editId');
if(
$id <= 0) {
    
// Add flash message for invalid auction ID and redirect to appropriate page
    
osc_add_flash_ok_message(__('Invalid auction ID''auction'), 'admin');
    
header('Location:' osc_admin_base_url(true) . '?page=plugins&action=renderplugin&file=auction/admin/auction.php');
    exit;
}

// Retrieve auction data
$auction ModelACT::newInstance()->getAuction($id); 

// Check if the auction should not be closed, deactivated, etc.
$chk act_check_auction($auction);

// If auction found and changed
if($chk !== false && $chk !== true) {
    
$auction ModelACT::newInstance()->getAuction($id);
}

// Retrieve item data
$item Item::newInstance()->findByPrimaryKey($auction['fk_i_item_id']); 

// Set title
$title sprintf(__('Auction #%s: %s''auction'), $id, ((isset($item['s_title']) && $item['s_title'] <> '') ? $item['s_title'] : __('Item removed''auction')));
act_menu($title);

// Create links for submenu
$links = array();
$links[] = array('file' => '_auction_edit_bids.php''icon' => 'fa-gavel''title' => __('User Action Bids''auction'));
$links[] = array('file' => '_auction_edit_watchlist.php''icon' => 'fa-bell''title' => __('Watchlist Users''auction'));
$links[] = array('file' => '_auction_edit_notifications.php''icon' => 'fa-envelope''title' => __('User Notifications''auction'));
$links[] = array('file' => '_auction_edit_logs.php''icon' => 'fa-database''title' => __('Auction History (Logs)''auction'));
$links[] = array('file' => '_auction_edit_settings.php''icon' => 'fa-wrench''title' => __('Auction Settings''auction'));

// Show submenu
$file act_submenu('auction_edit.php'$linksParams::getParam('go_to_file'), '&editId=' $id);
require_once 
$file;
?>


*

Sparky

  • ***
  • 89 posts
Re: Not able to delete auction when finished
« Reply #13 on: March 09, 2024, 02:15:18 PM »
When can we expect an update @MB.

Thank you @mwindey , but I will wait for an update.