Advertisement
Guest User

poftim

a guest
Jul 23rd, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.69 KB | None | 0 0
  1. <script>
  2. $('._givePP').on('click', () => {
  3. swal.mixin({
  4. input: 'text',
  5. confirmButtonText: 'Next &rarr;',
  6. showCancelButton: true,
  7. progressSteps: ['r', 'n']
  8. }).queue([
  9. {
  10. title: 'Reason',
  11. text: 'Please insert the reason here'
  12. },
  13. {
  14. title: 'set premium points',
  15. input: 'number',
  16. text: 'Please insert number of premium ponts here.'
  17. }
  18. ]).then((result) => {
  19. if (result.value) {
  20. $.ajax({
  21. url: '<?php echo Config::$_PAGE_URL; ?>api/profile/<?php echo Config::$_url[1]; ?>', // aici pui pagina ta..
  22. type: 'POST',
  23. data: {
  24. _dapepe: true,
  25. cdata: {
  26. id: <?php echo $data->id; ?>,
  27. forName: '<?php echo Config::getData('users', 'name', $data->id); ?>',
  28. userName: '<?php echo Config::getData('users', 'name', $_SESSION['user']); ?>',
  29. userID: '<?php echo Config::getData('users', 'id', $_SESSION['user']); ?>'
  30. },
  31. data: JSON.stringify( result.value )
  32. },
  33. success: function (c) {
  34. c = JSON.parse(c);
  35. swal({type: c.type, text: c.text});
  36. }
  37.  
  38. });
  39. }
  40. })
  41. });
  42. </script>
  43.  
  44.  
  45. ///si in page.a.php]
  46.  
  47. if(isset($_POST['_dapepe'])) {
  48. $data = json_decode($_POST['data']);
  49. $cdata = $_POST['cdata'];
  50. if(empty($data[0]) && empty($data[1])) { echo json_encode(['type' => 'error', 'text' => 'Ai lasat campuri necompleteate']); return; }
  51. $textt = ''.$cdata['forName'].' i s-au adaugat puncte premium ('.$data[1].') de la administratorul '.$cdata['userName'].' cu motivul: '.$data[0].'.';
  52. $q = Config::$g_con->prepare('INSERT INTO `panel_logs` (`text`,`UserID`) VALUES (?, ?)');
  53. $q->execute(array($textt,$cdata['id']));
  54. $q = Config::$g_con->prepare('UPDATE `users` SET `GoldPoints` = `GoldPoints` + ? WHERE `id` = ?');
  55. $q->execute(array($data[1],$cdata['id']));
  56. $q = Config::$g_con->prepare('INSERT INTO `actions` (`actionid`, `byid`, `byName`, `giverid`, `giverName`, `actiontime`, `reason`, `value`) VALUES (?,?,?,?,?,?,?,?)');
  57. $q->execute([5, $cdata['userID'], $cdata['userName'], $cdata['id'], $cdata['forName'],0, $data[0],$data[1]]);
  58. echo json_encode(['type' => 'success', 'text' => 'Functia a fost executata cu succes.']);
  59. return;
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement