Advertisement
Guest User

Untitled

a guest
Dec 5th, 2011
203
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.86 KB | None | 0 0
  1. <?php
  2.  
  3. global $wpdb;
  4.  
  5. $wpdb->show_errors();
  6.  
  7. $webinar = "<a href=\"https://elitetraders.omnovia.com/\" target=\"_blank\">Live Cast</a>";
  8.  
  9. $section = $_POST['section'];
  10. $direction = $_POST['direction'];
  11. $code = $_POST['code'];
  12. $chart = $_POST['chart'];
  13. $price = $_POST['price'];
  14. $stop_loss = $_POST['stop'];
  15. $profit_target = $_POST['target'];
  16. $risk_summary = $_POST['risk'];
  17. $trade_review = $_POST['analysis'];
  18. $out_id = 4;
  19. $status_id = 1;
  20.  
  21. $pre = $_GET['pre'];
  22.  
  23. $type = $_GET['type'];
  24.  
  25. // Made redundant by testing
  26. //if ($pre) {
  27. //    pre_trade($code, $direction, $type, $webinar, $chart, $out_id, $price, $stop_loss, $profit_target, $risk_summary, $trade_review);
  28. //} else {
  29.  
  30. //  INSERT new trade as most recent
  31.     $recent_arr = array('trade_date' => 'NOW()', 'most_recent' => '1');    
  32.     $wpdb->insert('bu_trade', $recent_arr);
  33.  
  34. //  Get most recent trade, should be the one above
  35.     $recent_query = "SELECT * FROM bu_trade WHERE most_recent = 1";
  36.     $recent_trade = $wpdb->get_row($recent_query);
  37.  
  38. //  Get the variables to create the transaction  
  39.     $trade_date = $recent_trade->trade_date;
  40.     $trade_id = $recent_trade->trade_id;
  41.    
  42. //  Create array of values to be entered    
  43.     $new_trans_array = array(
  44.         'trade_id' => $trade_id,
  45.         'trans_date' => $trade_date,
  46.         'direction' => $direction,
  47.         'terminology' => $terminology,
  48.         'section_id' => $section,
  49.         'code_id' => $code,
  50.         'status_id' => $status_id,
  51.         'chart_id' => $chart,
  52.         'out_id' => $out_id,
  53.         'price' => $price,
  54.         'stop_loss' => $stop_loss,
  55.         'profit_target' => $profit_target,
  56.         'risk_summary' => $risk,
  57.         'trade_review' => $trade_review,
  58.         'trademe' => TRUE,
  59.         'webinar' => $webinar
  60.     );
  61.  
  62. //  Insert above array    
  63.     $wpdb->insert('bu_trade_transactions', $new_trans_array);
  64.    
  65. //     Get Trans_ID    
  66.        $trans_id = $wpdb->get_var($wpdb->prepare("SELECT trans_id FROM bu_trade_transactions WHERE trade_id='$trade_id' ORDER BY trans_id DESC LIMIT 1"));
  67.  
  68. //  If custom Code      
  69.     if ($code == '39') {
  70.         $other_name = $_POST['other_code_name'];
  71.         $other_code = $_POST['other_code_id'];
  72.        
  73.         $other_set = array(
  74.             'other_name' => $other_name,
  75.             'other_code' => $other_code
  76.         );
  77.        
  78.         $other_where = array(
  79.             'trans_id' => $trans_id
  80.         );
  81.  
  82.         $wpdb->update('bu_trade_transactions', $other_set);
  83.  
  84.     }
  85.  
  86. //  Reset most recent    
  87.     $reset_set = array(
  88.         'most_recent' => 0,
  89.         'trans_id' => $trans_id
  90.     );
  91.    
  92.     $reset_where = array(
  93.         'trade_id' => $trade_id
  94.     );
  95.    
  96.     $wpdb->update('bu_trade', $reset_set, $reset_where);
  97.    
  98. //  pass to table being displayed    
  99.     tm_table($trans_id, $trade_id);
  100. //}
  101.     $wpdp->flush();
  102. ?>
  103.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement