Jump to content

Chrisj

Members
  • Content Count

    369
  • Joined

  • Last visited

  • Days Won

    1

Chrisj last won the day on October 19 2014

Chrisj had the most liked content!

Community Reputation

1 Neutral

About Chrisj

  • Rank
    Advanced Member

Profile Information

  • Gender
    Not Telling

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. Chrisj

    help with charge formula

    Thanks again for your reply/suggestion, but I don't know how to code that in particular
  2. Chrisj

    help with charge formula

    I believe I have it working now: $charge = ( $video_cost *0.50 ); if ($wallet >= $amout) { $new_wallet = (string)($wallet - $amout); $db->startTransaction(); $inserted_records = 0; foreach ($id_array as $id) { $video_id = (int)PT_Secure($id); // get video data $video = $db->where('id', $id)->getOne(T_VIDEOS); $video_cost_new = $video->video_play_price?$video->video_play_price:$video_cost; $uploader_amount = ( $video_cost_new *0.50 ); Can you help me with some code that would set the default price as a minimum , so the uploader can't set a price below the default price?
  3. Chrisj

    help with charge formula

    Hi, Thanks again. "try the following" where?
  4. Chrisj

    help with charge formula

    Thanks for your reply. I added: echo('$video_play_price: '.$video_play_price.PHP_EOL); echo('$charge: '.$charge.PHP_EOL); echo('$amout: '.$amout.PHP_EOL); $uploader_amount = $video_play_price - $charge; $uploader_amount = $amout - $charge; exit; to the end of the file. Then added this: display_errors = on to the php.ini file, but don't see anything displayed. Any additional help will be welcomed.
  5. Chrisj

    help with charge formula

    Yes, I've tried this without success: $amout = 0; foreach ($id_array as $id) { $video_id = (int)PT_Secure($id); // get video data $video = $db->where('id', $id)->getOne(T_VIDEOS); $amout += $video->video_play_price?$video->video_play_price:$video_cost; } $charge = ( $amout *0.50 ); if ($wallet >= $amout) { $new_wallet = (string)($wallet - $amout); $db->startTransaction(); $inserted_records = 0; foreach ($id_array as $id) { $video_id = (int)PT_Secure($id); $uploader_amount = $amout - $charge;
  6. Chrisj

    help with charge formula

    Can anyone else help me with this coding, please?
  7. Chrisj

    help with charge formula

    Thank you for your reply, but the code you describe, I don't see it and how it works. I understand, but I can't put it in code that you're suggesting
  8. Chrisj

    help with charge formula

    Thank you again. Yes, what I'm trying to change is the amount that uploaders are credited which is calculated as half of $video_cost which is the default price. Yes, "if they set their video with a custom price of half the default price, they would get 100% of the cost and the site would get nothing", so I need to set default price as minimum somehow. "already have an example: the earlier code that was calculating the total for all the videos to play", yes, but I don't know how or where to put that modified example, I didn't write this code, and my knowledge (as you can tell) is limited. any additional direction will be welcomed.
  9. Chrisj

    help with charge formula

    Yes, initially for testing purposes "the uploader only gets half the default video price and your site keeps the rest". Regarding "that would mean the uploader is setting a price for you that doesn't affect what they get", if they raise the price they get a bigger 50%, right? Currently, the uploader sets the price but isn't getting 50% "do the same thing when crediting the uploader", can you give me an example, please?
  10. Chrisj

    help with charge formula

    Thanks for your replies. Yes, "$uploader_amount is supposed to be how much the uploader of each video to view gets for the view, and originally is the default video amount minus $charge". The uploader can now optionally change the default price, and I believe it is this line: $amout += $video->video_play_price?$video->video_play_price:$video_cost; I'm trying to get it so when the default price is changed, and a purchase is made, $uploader_amount should then be how much the uploader of each video to view gets for the view, not the default video amount minus $charge, but new video price amount minus $charge. These two attempts were unsuccessful: $uploader_amount = $video_play_price - $charge; $uploader_amount = $amout - $charge; any additional help will be appreciated.
  11. Chrisj

    help with charge formula

    This code, that I didn't write, but am trying to modify, generates the cost of a video purchase. One line (line 32) is a formula , I believe for setting a purchase price amount: $amout += $video->video_play_price?$video->video_play_price:$video_cost; Another line (line 50) is a formula for deducting to create another amount: $uploader_amount = $video_cost - $charge; I think line 50 is correct except for I don't think $video_cost in the final price, but I'm no expert at reading this code. I tried this without success: $uploader_amount = $video_play_price - $charge; Here is the full code, any help with line 50, will be appreciated. <?php if (IS_LOGGED == false) { $data = array('status' => 400, 'error' => 'Not logged in'); echo json_encode($data); exit(); } if (!empty($_POST['id'])) { if (!is_array($_POST['id'])) { $id_array[] = $_POST['id']; } else { $id_array = $_POST['id']; } // get cost video $db->where('name', 'video_play_price'); $db_cost = $db->getOne('config'); $video_cost = (float)$db_cost->value; $count_video = count($id_array); $user_id = $user->id; $wallet = (float)str_replace(',', '', $user->wallet); $amout = 0; foreach ($id_array as $id) { $video_id = (int)PT_Secure($id); // get video data $video = $db->where('id', $id)->getOne(T_VIDEOS); $amout += $video->video_play_price?$video->video_play_price:$video_cost; } // $amout = $video_cost * $count_video; $charge = ( $video_cost *0.50 ); if ($wallet >= $amout) { $new_wallet = (string)($wallet - $amout); $db->startTransaction(); $inserted_records = 0; foreach ($id_array as $id) { $video_id = (int)PT_Secure($id); $uploader_amount = $video_cost - $charge; // get video data $video = $db->where('id', $id)->getOne(T_VIDEOS); // add data to paid table $insert_buy = $db->insert('u_paid_videos', [ 'id_user' => $user_id, 'id_video' => $video_id, 'session_key' => $_SESSION['session_key'], 'video_play_price' => (string)$video_cost, 'video_title' => $video->title, 'user_id_uploaded' => $video->user_id, //'up_credit'=>$video_cost, 'up_credit'=>$uploader_amount, ]); if ($insert_buy) { $inserted_records++; } //add wallet users' video $userwallet = $db->where('id', $video->user_id)->getOne(T_USERS); //$videouserwallet = $userwallet->wallet+$video_cost; $videouserwallet = $userwallet->wallet+$uploader_amount; $db->where('id', $video->user_id); $update_wallet = $db->update(T_USERS, [ // 'wallet' => $videouserwallet, 'wallet' => number_format($videouserwallet, 2, '.', ''), ]); } $db->where('id', $user_id); $update_wallet = $db->update(T_USERS, [ 'wallet' => $new_wallet, ]); if (($inserted_records == $count_video) && $update_wallet) { $db->commit(); echo json_encode([ 'status' => 200 ]); exit(); } else { $db->rollback(); echo json_encode([ 'status' => 400, 'error' => 'Buy process error' ]); exit(); } } else { echo json_encode([ 'status' => 400, 'error_num' => 1, 'error' => 'Not enough money' ]); exit(); } } else { echo json_encode([ 'status' => 400, 'error' => 'Bad Request, Invalid or missing parameter' ]); exit(); }
  12. I am purchasing a web script and will be installing it on my host server where I have two domain accounts, and the domains are resolved to the server.I asked the developer if I decided to change the domain name, at some point after install, what I could do, and was told to make the change it the config.php file. After I make that change, and I make the changes needed in WHM/cPanel, besides copying the db over, what else would need to be done to have a complete domain change?
  13. Thanks again. How do I "onclick events for View buttons have to be reassigned ", would it be a modification to the code I posted in my initial request here?
  14. I received help with this, and that helper is not currently available. But I'm guessing it has to do with the script.js file and this portion of it: function PT_MultipleBuyVideo() { var checked = getSelectedVideos(); if (!checked) { return false; } swal({ title: "", type: "info", html:"Simply proceed to purchase " + countSelectedVideos() + " videos", showCancelButton: true, cancelButtonText: "Close", customClass: 'sweetalert-lg', confirmButtonText:'Proceed' }).then(function(){ $.ajax({ url: PT_Ajax_Requests_File() + 'aj/buy-video', type: 'POST', dataType: 'json', data: {id:checked}, }).done(function(data){ if (data.status == 200) { for (var i = 0; i < checked.length; i++) { var button = $("button[data-action='multiple_select_button'][data-id='" + checked[i] + "']") buttonMultipleSelectingStyle(button, 'purchased'); } swal({ title: "Success", type: "success", html:"", showCancelButton: true, cancelButtonText: "Close", customClass: 'sweetalert-lg', confirmButtonText:'Go To Video(s)' }).then(function(){ window.location.href='/paid-list'; }); } else { if (data.error_num == 1) { swal( 'Error!', 'Not enough money', 'error' ); } else { swal( 'Error!', 'Something went wrong. Please try again later!', 'error' ); } } }).fail(function() { swal( 'Error!', 'Something went wrong. Please try again later!', 'error' ); }) }); } function buttonMultipleBuy(command) { var button = $("button[data-action='multuple-buy-video']"); if (command == 'hide') { button.hide(); } else if (command == 'show') { button.show(); } } buttonMultipleBuy('hide'); $("button[data-action='multiple_select_button']").click(function(){ if ($(this).attr('data-selected') == 1) { // uncheck buttonMultipleSelectingStyle($(this), 'uncheck'); } else { // check buttonMultipleSelectingStyle($(this), 'check'); } if (countSelectedVideos()) { buttonMultipleBuy('show'); } else { buttonMultipleBuy('hide'); } }); function countSelectedVideos() { var checked = 0; $("button[data-action='multiple_select_button']").each(function(i){ if ($(this).attr('data-selected') == 1) { checked++; } }); return checked; } function getSelectedVideos() { var checked = []; $("button[data-action='multiple_select_button']").each(function(i){ if ($(this).attr('data-selected') == 1) { checked.push($(this).attr('data-id')); } }); return checked; } function buttonMultipleSelectingStyle(button, action) { if (action == 'check') { button.attr('data-selected', 1); button.css('backgroundColor', '#FF4500'); button.html('Selected'); } else if (action == 'uncheck') { button.attr('data-selected', 0); button.css('backgroundColor', '#04abf2'); button.html('View'); } else if (action == 'purchased') { button.attr('data-selected', 0); button.css('backgroundColor', '#04abf2'); button.html('Purchased'); button.attr('disabled', 'disabled'); } } Any additional help is appreciated
×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.