Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <script>
- $('._givePP').on('click', () => {
- swal.mixin({
- input: 'text',
- confirmButtonText: 'Next →',
- showCancelButton: true,
- progressSteps: ['r', 'n']
- }).queue([
- {
- title: 'Reason',
- text: 'Please insert the reason here'
- },
- {
- title: 'set premium points',
- input: 'number',
- text: 'Please insert number of premium ponts here.'
- }
- ]).then((result) => {
- if (result.value) {
- $.ajax({
- url: '<?php echo Config::$_PAGE_URL; ?>api/profile/<?php echo Config::$_url[1]; ?>', // aici pui pagina ta..
- type: 'POST',
- data: {
- _dapepe: true,
- cdata: {
- id: <?php echo $data->id; ?>,
- forName: '<?php echo Config::getData('users', 'name', $data->id); ?>',
- userName: '<?php echo Config::getData('users', 'name', $_SESSION['user']); ?>',
- userID: '<?php echo Config::getData('users', 'id', $_SESSION['user']); ?>'
- },
- data: JSON.stringify( result.value )
- },
- success: function (c) {
- c = JSON.parse(c);
- swal({type: c.type, text: c.text});
- }
- });
- }
- })
- });
- </script>
- ///si in page.a.php]
- if(isset($_POST['_dapepe'])) {
- $data = json_decode($_POST['data']);
- $cdata = $_POST['cdata'];
- if(empty($data[0]) && empty($data[1])) { echo json_encode(['type' => 'error', 'text' => 'Ai lasat campuri necompleteate']); return; }
- $textt = ''.$cdata['forName'].' i s-au adaugat puncte premium ('.$data[1].') de la administratorul '.$cdata['userName'].' cu motivul: '.$data[0].'.';
- $q = Config::$g_con->prepare('INSERT INTO `panel_logs` (`text`,`UserID`) VALUES (?, ?)');
- $q->execute(array($textt,$cdata['id']));
- $q = Config::$g_con->prepare('UPDATE `users` SET `GoldPoints` = `GoldPoints` + ? WHERE `id` = ?');
- $q->execute(array($data[1],$cdata['id']));
- $q = Config::$g_con->prepare('INSERT INTO `actions` (`actionid`, `byid`, `byName`, `giverid`, `giverName`, `actiontime`, `reason`, `value`) VALUES (?,?,?,?,?,?,?,?)');
- $q->execute([5, $cdata['userID'], $cdata['userName'], $cdata['id'], $cdata['forName'],0, $data[0],$data[1]]);
- echo json_encode(['type' => 'success', 'text' => 'Functia a fost executata cu succes.']);
- return;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement