Add event handler for checkbox changes to manage refresh button state
- Implemented a new event listener for checkboxes with class 'g-checkbox'. - The listener updates the state of the '.multi-refresh' button based on the checked status of the checkbox. - Ensured that the refresh button is enabled or disabled appropriately when checkboxes are checked or unchecked.
This commit is contained in:
@@ -666,40 +666,57 @@ class GlobelusFirms
|
||||
{
|
||||
global $mdb, $globelus_settings;
|
||||
|
||||
$last_refresh = \front\factory\GlobelusAdverts::last_refresh($advert_id);
|
||||
$refresh_diff = \S::date_diff( date('Y-m-d H:i:s', strtotime($last_refresh)), date('Y-m-d H:i:s'), 60 * 60 * 24 );
|
||||
$advert = \front\factory\GlobelusAdverts::advert_details( $advert_id );
|
||||
|
||||
if ( $refresh_diff >= 1 and $points = \front\factory\GlobelusFirms::get_firm_points($user_id) >= $globelus_settings['pkt-odswiezenie-ogloszenia'])
|
||||
if ( $advert['disabled_by_admin'] )
|
||||
return [
|
||||
'result' => false,
|
||||
'msg' => '<p>Ogłoszenie <b>' . \front\factory\GlobelusAdverts::advert_title( $advert_id ) . '<\/b> zostało zablokowane przez administratora.</p>'
|
||||
];
|
||||
|
||||
if ( !$advert['visible'] )
|
||||
return [
|
||||
'result' => false,
|
||||
'msg' => '<p>Ogłoszenie <b>' . \front\factory\GlobelusAdverts::advert_title( $advert_id ) . '<\/b> nie jest widoczne.</p>'
|
||||
];
|
||||
|
||||
$points = \front\factory\GlobelusFirms::get_firm_points( $user_id );
|
||||
|
||||
if ( $points < $globelus_settings['pkt-odswiezenie-ogloszenia'] )
|
||||
{
|
||||
$mdb->update('globelus_users', ['points[-]' => $globelus_settings['pkt-odswiezenie-ogloszenia']], ['id' => $user_id]);
|
||||
$mdb->insert('globelus_points_history', [
|
||||
'user_id' => $user_id,
|
||||
'points' => $globelus_settings['pkt-odswiezenie-ogloszenia'],
|
||||
'event_type' => 3
|
||||
]);
|
||||
|
||||
if ($mdb->update('globelus_adverts', [
|
||||
'last_refresh' => date('Y-m-d H:i:s'),
|
||||
'refresh_count[+]' => 1
|
||||
], [
|
||||
'AND' => [
|
||||
'id' => $advert_id,
|
||||
'user_id' => $user_id
|
||||
]
|
||||
]))
|
||||
{
|
||||
\S::log($user_id, __METHOD__, [0 => ['points' => $points, 'advert_id' => $advert_id, 'refresh_diff' => $refresh_diff]]);
|
||||
return [
|
||||
'result' => true,
|
||||
'msg' => '<p>Ogłoszenie <b>' . \front\factory\GlobelusAdverts::advert_title($advert_id) . '<\/b> zostało odświeżone.</p>'
|
||||
];
|
||||
}
|
||||
return [
|
||||
'result' => false,
|
||||
'msg' => '<p>Nie masz wystarczającej ilości punktów, aby odświeżyć ogłoszenie <b>' . \front\factory\GlobelusAdverts::advert_title( $advert_id ) . '<\/b>.</p>'
|
||||
];
|
||||
}
|
||||
|
||||
return [
|
||||
'result' => true,
|
||||
'msg' => '<p>Ogłoszenie <b>' . \front\factory\GlobelusAdverts::advert_title($advert_id) . '<\/b> nie mogło zostać odświeżone.</p>'
|
||||
];
|
||||
|
||||
$last_refresh = \front\factory\GlobelusAdverts::last_refresh( $advert_id );
|
||||
$refresh_diff = \S::date_diff( date('Y-m-d H:i:s', strtotime($last_refresh)), date('Y-m-d H:i:s'), 60 * 60 * 24 );
|
||||
|
||||
if ( $refresh_diff < 1 )
|
||||
{
|
||||
return [
|
||||
'result' => false,
|
||||
'msg' => '<p>Ogłoszenie <b>' . \front\factory\GlobelusAdverts::advert_title( $advert_id ) . '<\/b> może być odświeżone raz na dobę.</p>'
|
||||
];
|
||||
}
|
||||
|
||||
$mdb -> update( 'globelus_users', [ 'points[-]' => $globelus_settings['pkt-odswiezenie-ogloszenia'] ], [ 'id' => $user_id] );
|
||||
$mdb -> insert( 'globelus_points_history', [
|
||||
'user_id' => $user_id,
|
||||
'points' => $globelus_settings['pkt-odswiezenie-ogloszenia'],
|
||||
'event_type' => 3
|
||||
] );
|
||||
|
||||
if ( $mdb -> update( 'globelus_adverts', [ 'last_refresh' => date('Y-m-d H:i:s'), 'refresh_count[+]' => 1 ], [ 'AND' => [ 'id' => $advert_id, 'user_id' => $user_id ] ] ) )
|
||||
{
|
||||
\S::log($user_id, __METHOD__, [0 => ['points' => $points, 'advert_id' => $advert_id, 'refresh_diff' => $refresh_diff]]);
|
||||
return [
|
||||
'result' => true,
|
||||
'msg' => '<p>Ogłoszenie <b>' . \front\factory\GlobelusAdverts::advert_title($advert_id) . '<\/b> zostało odświeżone.</p>'
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
public static function advert_extend($advert_id, $user_id)
|
||||
|
||||
Reference in New Issue
Block a user