Наследование: extends CakeTestModel
 public function makeBid($loan_id)
 {
     $id = Auth::user()->id;
     $loan_app = LoanApp::where('loan_id', '=', $loan_id)->first();
     $bid_Id;
     if (!Bid::isMadeBefore($loan_id, $id)) {
         $bid = new Bid();
         $bid->user_id = $id;
         $bid->loan_id = $loan_id;
         $bid->bid_date = date('Y-m-d H:i:s');
         $bid->bid_amount = $loan_app->amount;
         /*$bid-> bid_term = $loan_app-> term;
         		$bid-> bid_rate = $loan_app-> pref_rate; */
         $bid->save();
         /*$bid_Id= $bid-> bid_id;*/
         /*$bid_acc = BidAccept::firstOrNew('where','=',$bid_Id);
         		$bid_acc -> loan_id = $loan_id;
         		$bid_acc -> accepte = 0;*/
         //update the loan weight
         $weight = $loan_app->evaluateWeight($id, $loan_id);
         $loan_app->save();
     }
     /*	$bid_acc = BidAccept::firstOrNew(array('bid_id'=>$bid_Id));
     		$bid_acc -> loan_id = $loan_id;
     		$bid_acc -> accepted = 0;
     		$bid_acc->save();*/
     /*$pdata = $profile->getProfile($id);   // method defined in its model
     		$fdata = $financial->getFinancialProfile($id); */
     // methd defined in its model
     return Redirect::route('lend');
 }
Пример #2
0
 public function testNotGreaterAfterBago()
 {
     $bagos = 1;
     $bide1 = new Bid(3, 1);
     $bide2 = new Bid(3, 2);
     $this->assertFalse($bide2->greaterThan($bide1, $bagos));
     $bide2 = new Bid(2, 1);
     $this->assertFalse($bide2->greaterThan($bide1, $bagos));
 }
 public function evaluateWeight($id, $loan_id)
 {
     $finance = FinancialProfile::where('user_id', '=', $id)->first();
     $count = LoanApp::where('user_id', '=', $id)->count();
     $loan_app = LoanApp::where('loan_id', '=', $loan_id)->first();
     $current_bids = Bid::where('loan_id', '=', $loan_id)->count();
     $amout = $loan_app->amount;
     $term = $loan_app->term;
     $rate = $loan_app->pref_rate;
     $residence = $finance->residence_status;
     $year_income = $finance->monthly_income * 12;
     $home_loan = $finance->home_loan;
     $car_loan = $finance->car_loan;
     $other_loan = $finance->other_loan;
     $expense = $finance->loan_repayment;
     $other_exp = $finance->other_expense;
     $house_owner = 0;
     if (strcmp($residence, 'Mortage') == 0 || strcmp($residence, 'noMortage') == 0) {
         $house_owner = 1;
     }
     $property = $finance->property;
     $vehicle = $finance->vehicle;
     $share = $finance->share;
     $other_property = $finance->others;
     $active_loan = $total_liab = $home_loan + $car_loan + $other_loan;
     $income_debt_ratio = $year_income / (1 + $count + $total_liab);
     $total_assests = $property + $vehicle + $share + $other_property;
     $disposable_income = $year_income - $total_liab;
     $sum = $rate + $house_owner + $total_assests + $income_debt_ratio + $current_bids + $disposable_income;
     $weight = pow($sum, 1 / 6);
     //$loan_app-> weight = $weight;
     return $weight;
 }
Пример #4
0
 public function buy($price)
 {
     $art->sold = 1;
     $art->sold_for = $art->price;
     $art->sold_to = Auth::user()->id;
     $art->save();
     Bid::where('art_id', $art_id)->delete();
     watchlist::where('art_id', $art_id)->delete();
 }
 public function updateProgress($loan_id, $bid_id)
 {
     $current_sum = Bid::where('loan_id', '=', $loan_id)->sum('bid_amount');
     $loan = loanApp::where('loan_id', '=', $loan_id)->get();
     $loan_amount = $loan->amount;
     $progress = $current_sum / $loan_amount;
     $loan->progress = $progress;
     $loan->save();
     return $progress;
 }
Пример #6
0
 public static function bid($attributes = array(), $project_id = false)
 {
     $faker = Faker\Factory::create();
     $p = $project_id ? Project::find($project_id) : Project::where_not_null('posted_to_fbo_at')->order_by(\DB::raw('RAND()'))->first();
     $v = Vendor::order_by(\DB::raw('RAND()'))->first();
     $prices = array();
     foreach (array_keys($p->deliverables) as $d) {
         $prices[$d] = rand(100, 10000);
     }
     $b = new Bid(array('project_id' => $p->id, 'approach' => $faker->paragraph, 'previous_work' => $faker->paragraph, 'employee_details' => "Adam Becker\n" . "Craig Collyer", 'prices' => $prices));
     $b->starred = rand(0, 1);
     $b->vendor_id = $v->id;
     $b->save();
     if (rand(0, 6) === 0) {
         $b->delete_by_vendor();
     } else {
         if (rand(0, 1) === 0) {
             $submitted_at = new \DateTime();
             $b->submitted_at = rand(0, 1) === 0 ? $submitted_at : null;
             $b->submit();
             // Dismiss 1/3 of the bids
             if (rand(0, 2) === 0) {
                 $b->dismiss(Bid::$dismissal_reasons[array_rand(Bid::$default_dismissal_reasons)], $faker->paragraph(2));
                 // Un-dismiss 1/2 of these
                 if (rand(0, 1) === 0) {
                     $b->undismiss();
                 }
             }
         }
     }
 }
Пример #7
0
Файл: home.php Проект: ajb/rfpez
 public function action_index()
 {
     if (Auth::check()) {
         if (Auth::user()->officer) {
             Session::reflash();
             return Redirect::to_route('my_projects');
         } else {
             Session::reflash();
             if (Auth::user()->vendor && Bid::where_vendor_id(Auth::vendor()->id)->count()) {
                 return Redirect::to_route('my_bids');
             } else {
                 return Redirect::to_route('projects');
             }
         }
     } else {
         $view = View::make('home.index_signed_out');
     }
     $this->layout->content = $view;
 }
Пример #8
0
 /**
  * Retorna true se este lance for maior que o lance informado ou maior que quantidade de bagos (aces)
  * já pedidos anteriormente.
  *
  * Um lance é maior se:
  * 1- A quantidade em bagos for maior que a já pedida anteriormente e maior que a metade 
  * (arrendodado para cima) da quantidade do lance informado;
  * 2- O valor for maior que a anterior;
  * 3- O valor for igual porem a quantidade;
  *
  **/
 public function greaterThan(Bid $bid, $aces = 0)
 {
     if ($this->value == 1 && $bid->getValue() > 1) {
         if ($this->quantity > $aces && $this->quantity > ceil($bid->getQuantity() / 2)) {
             return true;
         }
         return false;
     }
     if ($this->quantity > $bid->getQuantity()) {
         return true;
     }
     if ($this->quantity == $bid->getQuantity() && $this->value > $bid->getValue()) {
         return true;
     }
     return false;
 }
Пример #9
0
 public function action_index()
 {
     $view = View::make('reports.index');
     $all_days = array();
     $date = new \DateTime();
     $date->setTimestamp(1358488800);
     # 1/18/2013
     // $date->setTimestamp(1354320000); # 12/17/2013
     while ($date < new \DateTime()) {
         array_push($all_days, $date->format("Y-m-d"));
         $date = $date->modify("+1 day");
     }
     $signups = array();
     foreach (DB::query("SELECT COUNT(*) as count, DATE(created_at) as date FROM vendors GROUP BY DATE(created_at)") as $result) {
         $signups[$result->date] = $result->count;
     }
     $signups_per_day = array();
     $signups_per_day_flat = array();
     foreach ($all_days as $day) {
         $signups_per_day_flat[] = $signups_per_day[$day] = intval(@$signups[$day]) ?: 0;
     }
     $signups = array();
     foreach (DB::query("SELECT DATE(created_at) as date, duns FROM vendors") as $result) {
         if (!isset($signups[$result->date])) {
             $signups[$result->date] = array('new' => 0, 'old' => 0);
         }
         if ($result->duns) {
             $signups[$result->date]['old']++;
         } else {
             $signups[$result->date]['new']++;
         }
     }
     $num_signups = 0;
     $num_new = 0;
     $new_to_contracting = array();
     foreach ($all_days as $day) {
         if (isset($signups[$day])) {
             $num_signups += $signups[$day]['new'];
             $num_signups += $signups[$day]['old'];
             $num_new += $signups[$day]['new'];
         }
         $new_to_contracting[$day] = $num_signups == 0 ? 0 : $num_new / $num_signups;
     }
     $total_projects = 0;
     $total_bids = 0;
     $bids_per_project = array();
     foreach (DB::query("SELECT id, title, (SELECT COUNT(*) from bids where project_id = projects.id AND deleted_at IS NULL AND submitted_at IS NOT NULL) as bids from projects WHERE projects.posted_to_fbo_at IS NOT NULL") as $result) {
         array_push($bids_per_project, array('project_id' => $result->id, 'project_title' => $result->title, 'num_bids' => $result->bids));
         $total_projects++;
         $total_bids += $result->bids;
     }
     $avg_bids_per_project = $total_bids / $total_projects;
     $total_price_for_all = 0;
     $total_bids_in_all = 0;
     $total_prices = array();
     foreach (Bid::where_not_null('submitted_at')->get() as $bid) {
         if (!isset($total_prices[$bid->project_id])) {
             $total_prices[$bid->project_id] = array('num_bids' => 0, 'total_price' => 0);
         }
         $total_prices[$bid->project_id]['num_bids']++;
         $total_prices[$bid->project_id]['total_price'] += $bid->total_price_integer();
         $total_bids_in_all++;
         $total_price_for_all += $bid->total_price_integer();
     }
     $avg_prices = array();
     foreach (Project::where_not_null('posted_to_fbo_at')->get() as $project) {
         array_push($avg_prices, array('project_id' => $project->id, 'project_title' => $project->title, 'avg_price' => isset($total_prices[$project->id]) ? $total_prices[$project->id]['total_price'] / $total_prices[$project->id]['num_bids'] : 0));
     }
     $avg_price_total = $total_price_for_all / $total_bids_in_all;
     $view->total_signups = $num_signups;
     $view->total_new_to_contracting = $num_new;
     $view->signups_per_day = $signups_per_day;
     $view->signups_per_day_flat = $signups_per_day_flat;
     $view->new_to_contracting = $new_to_contracting;
     $view->bids_per_project = $bids_per_project;
     $view->avg_bids_per_project = $avg_bids_per_project;
     $view->avg_prices = $avg_prices;
     $view->avg_price_total = $avg_price_total;
     $this->layout->content = $view;
 }
Пример #10
0
        Decline bid from
        <span class="company-name"></span>
      </h3>
    </div>
    <div class="modal-body">
      <div class="alert alert-info"><?php 
echo __('r.bids.partials.dismiss_modal.optional_fields');
?>
</div>
      <div class="control-group">
        <label class="control-label">Reason Declined:</label>
        <div class="controls">
          <select name="reason">
            <option value="">-- Select a Reason --</option>
            <?php 
foreach (Bid::dismissal_reasons() as $reason) {
    ?>
              <option value="<?php 
    echo e($reason);
    ?>
"><?php 
    echo e($reason);
    ?>
</option>
            <?php 
}
?>
            <option value="Other">Other</option>
          </select>
          <input type="text" name="reason_other" />
        </div>
Пример #11
0
function ProjectTheme_my_account_payments_area_function()
{
    global $current_user, $wpdb, $wp_query;
    get_currentuserinfo();
    $uid = $current_user->ID;
    ?>

<div id="content" class="account-main-area">

            
            <?php 
    $pg = $_GET['pg'];
    if (!isset($pg)) {
        $pg = 'home';
    }
    global $wpdb;
    if ($_GET['pg'] == 'closewithdrawal') {
        $id = $_GET['id'];
        $s = "select * from " . $wpdb->prefix . "project_withdraw where id='{$id}' AND uid='{$uid}'";
        $r = $wpdb->get_results($s);
        if (count($r) == 1) {
            $row = $r[0];
            $amount = $row->amount;
            $cr = projectTheme_get_credits($uid);
            projectTheme_update_credits($uid, $cr + $amount);
            $s = "delete from " . $wpdb->prefix . "project_withdraw where id='{$id}' AND uid='{$uid}'";
            $wpdb->query($s);
            echo '<div class="">';
            echo sprintf(__('Request canceled! <a href="%s">Return to payments</a>.', 'ProjectTheme'), get_permalink(get_option('ProjectTheme_my_account_payments_id')));
            echo '</div>';
        }
    }
    if ($_GET['pg'] == 'releasepayment') {
        $id = $_GET['id'];
        $escrow = Escrow::get_by_field('id', $id);
        $bid = Bid::get_by_id($escrow->bid);
        $s = "select * from " . $wpdb->prefix . "project_escrow where id='{$id}' AND fromid='{$uid}'";
        $r = $wpdb->get_results($s);
        if (count($r) == 1 and $r[0]->released != 1) {
            $row = $r[0];
            $amount = $row->amount;
            $toid = $row->toid;
            $pid = $row->pid;
            $my_pst = get_post($pid);
            $projectTheme_get_winner_bid = projectTheme_get_winner_bid($pid);
            ProjectTheme_send_email_when_on_completed_project($pid, $projectTheme_get_winner_bid->uid, $projectTheme_get_winner_bid->bid);
            //-------------------------------------------------------------------------------
            $projectTheme_fee_after_paid = get_option('projectTheme_fee_after_paid');
            if (!empty($projectTheme_fee_after_paid)) {
                $deducted = $amount * ($projectTheme_fee_after_paid * 0.01);
            } else {
                $deducted = 0;
            }
            //-------------------------------------------------------------------------------
            $cr = projectTheme_get_credits($toid);
            projectTheme_update_credits($toid, $cr + $amount - $deducted);
            $reason = sprintf(__('Escrow payment received from <a href="%s">%s</a> for the project <a href="%s">%s</a>', 'ProjectTheme'), ProjectTheme_get_user_profile_link($current_user->ID), $current_user->user_login, get_permalink($my_pst->ID), $my_pst->post_title);
            projectTheme_add_history_log('1', $reason, $amount, $toid, $uid);
            if ($deducted > 0) {
                $reason = sprintf(__('Payment fee for project <a href="%s">%s</a>', 'ProjectTheme'), get_permalink($my_pst->ID), $my_pst->post_title);
            }
            projectTheme_add_history_log('0', $reason, $deducted, $toid);
            //-----------------------------
            $email = get_bloginfo('admin_email');
            $site_name = get_bloginfo('name');
            $usr = get_userdata($uid);
            $usr2 = get_userdata($toid);
            $subject = __("Money Escrow Completed", 'ProjectTheme');
            //$message = sprintf(__("You have released the escrow of: %s","ProjectTheme"), ProjectTheme_get_show_price($amount));
            //$message = sprintf(__('Escrow Payment completed, sent %s to <a href="%s">%s</a> for project <a href="%s">%s</a>','ProjectTheme'), $amount, ProjectTheme_get_user_profile_link($usr2->ID), $usr2->user_login, get_permalink($my_pst->ID), $my_pst->post_title);
            $message = sprintf(__('Escrow Payment completed, sent %s to %s for %s', 'ProjectTheme'), $amount, $usr2->user_login, $my_pst->post_title);
            ProjectTheme_send_email($usr->user_email, $subject, $message);
            //($usr->user_email, $subject , $message);
            //-----------------------------
            //$usr = get_userdata($toid);
            $reason = sprintf(__('Escrow Payment completed, sent to <a href="%s">%s</a> for project <a href="%s">%s</a>', 'ProjectTheme'), ProjectTheme_get_user_profile_link($usr2->ID), $usr2->user_login, get_permalink($my_pst->ID), $my_pst->post_title);
            projectTheme_add_history_log('0', $reason, $amount, $uid, $toid);
            $subject = __("Money Escrow Completed", "ProjectTheme");
            //$message = sprintf(__("You have received the amount of: %s","ProjectTheme"), ProjectTheme_get_show_price($amount));
            //$message = sprintf(__('Escrow Payment received $ %s, from <a href="%s">%s</a> for project <a href="%s">%s</a>','ProjectTheme'), $amount, ProjectTheme_get_user_profile_link($usr->ID), $usr->user_login, get_permalink($my_pst->ID), $my_pst->post_title);
            $message = sprintf(__('Escrow Payment received $ %s, from %s for project %s', 'ProjectTheme'), $amount, $usr->user_login, $my_pst->post_title);
            ProjectTheme_send_email($usr2->user_email, $subject, $message);
            //($usr->user_email, $subject , $message);
            //-----------------------------
            /*
             * Update bid and project meta
             */
            $tm = current_time('timestamp', 0);
            if (!empty($bid)) {
                Bid::update_meta_by_id($bid->id, 'paid', "1");
                Bid::update_meta_by_id($bid->id, 'paid_user_date', $tm);
                Project::update_postmeta($bid->pid, 'paid_user');
            } else {
                // for old projects
                update_post_meta($pid, 'paid_user', '1');
                update_post_meta($pid, 'paid_user_date', current_time('timestamp', 0));
            }
            $s = "update " . $wpdb->prefix . "project_escrow set released='1', releasedate='{$tm}' where id='{$id}'";
            $r = $wpdb->query($s);
        }
        echo __('Escrow completed! Redirecting...', 'ProjectTheme');
        echo '<br/><br/>';
        $url_redir = ProjectTheme_get_payments_page_url('transactions');
        //ProjectTheme_get_payments_page_url();
        echo '<meta http-equiv="refresh" content="2;url=' . $url_redir . '" />';
    }
    do_action('ProjectTheme_before_payments_in_payments');
    $ProjectTheme_enable_credits_wallet = get_option('ProjectTheme_enable_credits_wallet');
    if ($ProjectTheme_enable_credits_wallet != 'no') {
        if ($pg == 'home') {
            ?>
            
            
            
            <div class="my_box3">
            
            
            	<div class="box_title"><?php 
            _e("Finances", "ProjectTheme");
            ?>
</div>
            	<div class="box_content">
                
                
                
                <?php 
            $bal = projectTheme_get_credits($uid);
            echo '<span class="balance">' . __("Your Current Balance is", "ProjectTheme") . ": " . ProjectTheme_get_show_price($bal, 2) . "</span>";
            ?>
 
    
    
               
            </div>
            </div>
            
            <div class="clear10"></div>
            
            <div class="my_box3">
           
            
            	<div class="box_title"><?php 
            _e('What do you want to do ?', 'ProjectTheme');
            ?>
</div>
            	<div class="box_content">
                
                <ul class="cms_cms">
                <?php 
            if (ProjectTheme_is_user_business($uid)) {
                ?>
               <li> <a href="<?php 
                echo ProjectTheme_get_payments_page_url('deposit');
                ?>
" class="green_btn old_mm_k"><?php 
                _e('Deposit Money', 'ProjectTheme');
                ?>
</a>  </li>
              <?php 
            }
            ?>
              <li>  <a href="<?php 
            echo ProjectTheme_get_payments_page_url('makepayment');
            ?>
" class="green_btn old_mm_k"><?php 
            _e('Make Payment', 'ProjectTheme');
            ?>
</a> </li>
                
                <?php 
            if (ProjectTheme_is_user_business($uid)) {
                ?>
               <li> <a href="<?php 
                echo ProjectTheme_get_payments_page_url('escrow');
                ?>
" class="green_btn old_mm_k"><?php 
                _e('Deposit Escrow', 'ProjectTheme');
                ?>
</a> </li> 
                <?php 
            }
            ?>
                
               <li> <a href="<?php 
            echo ProjectTheme_get_payments_page_url('withdraw');
            ?>
" class="green_btn old_mm_k"><?php 
            _e('Withdraw Money', 'ProjectTheme');
            ?>
</a> </li> 
               <li> <a href="<?php 
            echo ProjectTheme_get_payments_page_url('transactions');
            ?>
" class="green_btn old_mm_k"><?php 
            _e('Transactions', 'ProjectTheme');
            ?>
</a></li>
               <!-- <li> <a href="<?php 
            echo ProjectTheme_get_payments_page_url('bktransfer');
            ?>
" class="green_btn old_mm_k"><?php 
            _e('Bank Transfer Details', 'ProjectTheme');
            ?>
</a>   </li>  -->
    
                  <?php 
            do_action('ProjectTheme_financial_buttons_main');
            ?>
              
              	</ul>
              
            </div>
            </div>
            
            <!-- ###################### -->
                        <div class="clear10"></div>
            
            <div class="my_box3">
            
            
            	<div class="box_title"><?php 
            _e('Pending Withdrawals', 'ProjectTheme');
            ?>
</div>
            	<div class="box_content">
               
                
         				<?php 
            global $wpdb;
            //----------------
            $s = "select * from " . $wpdb->prefix . "project_withdraw where done='0' and rejected!='1' AND uid='{$uid}' order by id desc";
            $r = $wpdb->get_results($s);
            if (count($r) == 0) {
                echo __('No withdrawals pending yet.', 'ProjectTheme');
            } else {
                echo '<table width="100%">';
                foreach ($r as $row) {
                    echo '<tr>';
                    echo '<td>' . date_i18n('d-M-Y H:i:s', $row->datemade) . '</td>';
                    echo '<td>' . ProjectTheme_get_show_price($row->amount) . '</td>';
                    echo '<td>' . $row->methods . '</td>';
                    echo '<td>' . $row->payeremail . '</td>';
                    echo '<td><a href="' . ProjectTheme_get_payments_page_url('closewithdrawal', $row->id) . '"
							class="green_btn block">' . __('Close Request', 'ProjectTheme') . '</a></td>';
                    echo '</tr>';
                }
                echo '</table>';
            }
            ?>
                  
               
            </div>
            </div>
            
            
             <div class="clear10"></div>
            
            <div class="my_box3">
            
            
            	<div class="box_title"><?php 
            _e('Rejected Withdrawals', 'ProjectTheme');
            ?>
</div>
            	<div class="box_content">
               
                
         				<?php 
            global $wpdb;
            //----------------
            $s = "select * from " . $wpdb->prefix . "project_withdraw where done='0' and rejected='1' AND uid='{$uid}' order by id desc";
            $r = $wpdb->get_results($s);
            if (count($r) == 0) {
                echo __('no withdrawals rejected yet.', 'ProjectTheme');
            } else {
                echo '<table width="100%">';
                foreach ($r as $row) {
                    echo '<tr>';
                    echo '<td>' . date_i18n('d-M-Y H:i:s', $row->datemade) . '</td>';
                    echo '<td>' . ProjectTheme_get_show_price($row->amount) . '</td>';
                    echo '<td>' . $row->methods . '</td>';
                    echo '<td>' . $row->payeremail . '</td>';
                    echo '<td> </td>';
                    echo '</tr>';
                }
                echo '</table>';
            }
            ?>
                  
               
            </div>
            </div>
            
            
           <!-- ###################### -->
                        <div class="clear10"></div>
            
            <div class="my_box3">
            
            
            	<div class="box_title"><?php 
            _e("Pending Incoming Payments", "ProjectTheme");
            ?>
</div>
            	<div class="box_content">
                
                
   				<?php 
            $s = "select * from " . $wpdb->prefix . "project_escrow where released='0' AND toid='{$uid}' order by id desc";
            $r = $wpdb->get_results($s);
            if (count($r) == 0) {
                echo __('No payments pending yet.', 'ProjectTheme');
            } else {
                echo '<table width="100%">';
                foreach ($r as $row) {
                    $post = get_post($row->pid);
                    $from = get_userdata($row->fromid);
                    echo '<tr>';
                    echo '<td>' . $from->user_login . '</td>';
                    echo '<td>' . $post->post_title . '</td>';
                    echo '<td>' . date_i18n('d-M-Y H:i:s', $row->datemade) . '</td>';
                    echo '<td>' . ProjectTheme_get_show_price($row->amount) . '</td>';
                    echo '</tr>';
                }
                echo '</table>';
            }
            ?>
                  
                
            </div>
            </div>
         
         
                    <!-- ###################### -->
                   
                   <?php 
            if (ProjectTheme_is_user_business($uid)) {
                ?>
                   
                        <div class="clear10"></div>
            
            <div class="my_box3">
            
            
            	<div class="box_title"><?php 
                _e('Pending Outgoing Payments', 'ProjectTheme');
                ?>
</div>
            	<div class="box_content">
                
                
      				<?php 
                $s = "select * from " . $wpdb->prefix . "project_escrow where released='0' AND fromid='{$uid}' order by id desc";
                $r = $wpdb->get_results($s);
                if (count($r) == 0) {
                    echo __('No payments pending yet.', 'ProjectTheme');
                } else {
                    echo '<table width="100%">';
                    echo '<tr>';
                    echo '<td><b>' . __('User', 'ProjectTheme') . '</b></td>';
                    echo '<td><b>' . __('Project', 'ProjectTheme') . '</b></td>';
                    echo '<td><b>' . __('Date', 'ProjectTheme') . '</b></td>';
                    echo '<td><b>' . __('Amount', 'ProjectTheme') . '</b></td>';
                    echo '<td><b>' . __('Options', 'ProjectTheme') . '</b></td>';
                    echo '</tr>';
                    foreach ($r as $row) {
                        $post = get_post($row->pid);
                        $from = get_userdata($row->toid);
                        echo '<tr>';
                        echo '<td><a href="' . ProjectTheme_get_user_profile_link($from->ID) . '">' . $from->user_login . '</a></td>';
                        echo '<td><a href="' . get_permalink($post->ID) . '">' . $post->post_title . '</a></td>';
                        echo '<td>' . date_i18n('d-M-Y H:i:s', $row->datemade) . '</td>';
                        echo '<td>' . ProjectTheme_get_show_price($row->amount) . '</td>';
                        echo '<td><a href="' . ProjectTheme_get_payments_page_url('releasepayment', $row->id) . '" class="green_btn  block">' . __('Release Payment', 'ProjectTheme') . '</a></td>';
                        echo '</tr>';
                    }
                    echo '</table>';
                }
                ?>
                  
               
            </div>
            </div> <?php 
            }
            ?>
        <?php 
        } elseif ($pg == 'escrow') {
            ?>
        
        
        <div class="my_box3">
           
            
            	<div class="box_title"><?php 
            _e('Make Escrow Payment', 'ProjectTheme');
            ?>
</div>
            	<div class="box_content">
              
                
                
                <?php 
            $bal = projectTheme_get_credits($uid);
            if (isset($_POST['escrowme'])) {
                $amount = $_POST['amount'];
                $projects = $_POST['projectss'];
                $bid_id = $_POST['bid_id'];
                /*$amount_and_ids = explode(',', $_POST['amount_and_ids']);
                		$amount = $amount_and_ids[0]*1;					*/
                if (!is_numeric($amount) || $amount <= 0) {
                    echo '<div class="newproject_error">' . __('Enter a valid amount.', 'ProjectTheme') . '</div>';
                } else {
                    if (empty($projects)) {
                        echo '<div class="newproject_error">' . __('Please choose a project.', 'ProjectTheme') . '</div>';
                    } else {
                        if ($bal < $amount) {
                            echo '<div class="newproject_error">' . __('Your balance is smaller than the amount requested.', 'ProjectTheme') . '</div>';
                        } else {
                            $post = get_post($projects);
                            //							$uid2   = get_post_meta($projects, "winner", true);
                            $bid = Bid::get_by_id($bid_id);
                            $uid2 = $bid->uid;
                            $tm = $_POST['tm'];
                            if (empty($tm)) {
                                $tm = current_time('timestamp', 0);
                            }
                            if ($post->post_author != $uid) {
                                $uid2 = $post->post_author;
                            }
                            $uid2 = $_POST['uids'];
                            //-----------------------
                            $email = get_bloginfo('admin_email');
                            $site_name = get_bloginfo('name');
                            $usr = get_userdata($uid);
                            $subject = __("Money Escrow Sent", "ProjectTheme");
                            $message = sprintf(__("You have placed in escrow the amount of: %s to user: \n\t\t\t\t\t\t\t<b>%s</b>", "ProjectTheme"), ProjectTheme_get_show_price($amount), $username);
                            //($usr->user_email, $subject , $message);
                            $s = "select * from " . $wpdb->prefix . "project_escrow where datemade='{$tm}' and fromid='{$uid}' AND bid='{$bid->id}'";
                            $rr = $wpdb->get_results($s);
                            if (count($rr) == 0) {
                                $s = "insert into " . $wpdb->prefix . "project_escrow (datemade, amount, fromid, toid, pid, bid) \n\t\t\t\t\t\t\t\tvalues('{$tm}','{$amount}','{$uid}','{$uid2}','{$projects}', '{$bid->id}')";
                                $wpdb->query($s);
                                // for logged in user, the user who sends
                                //======================================================
                                $cr = projectTheme_get_credits($uid);
                                projectTheme_update_credits($uid, $cr - $amount);
                            }
                            //======================================================
                            // for other user, the user who receives
                            //======================================================
                            $usr2 = get_userdata($uid2);
                            $subject = __("Money Escrow Received", "ProjectTheme");
                            $message = sprintf(__("You have received in escrow the amount of: \$ %s from user: <b>%s</b>", "ProjectTheme"), ProjectTheme_get_show_price($amount), $usr->user_login);
                            //($usr2->user_email, $subject , $message);
                            //======================================================
                            echo '<div class="saved_thing">' . __('Your payment has been sent. Redirecting...', 'ProjectTheme') . '</div>';
                            $url_redir = get_permalink(get_option('ProjectTheme_my_account_payments_id'));
                            echo '<meta http-equiv="refresh" content="2;url=' . $url_redir . '" />';
                        }
                    }
                }
            }
            $bal = projectTheme_get_credits($uid);
            echo '<span class="balance">' . sprintf(__('Your Current Balance is: %s', 'ProjectTheme'), ProjectTheme_get_show_price($bal)) . "</span>";
            echo '&nbsp; <a class="post_bid_btn" href="' . ProjectTheme_get_payments_page_url_redir('deposit') . '">' . __('Add More Credits', 'ProjectTheme') . '</a>';
            echo "<br/><br/>";
            ?>
                
                <script>
				
				function on_proj_sel()
				{
					var sel_value = jQuery("#my_proj_sel").val();
					
					$.post("<?php 
            bloginfo('siteurl');
            ?>
/?get_my_project_vl_thing=1", {queryString: ""+sel_value+""}, function(data){
						if(data.length >0) {
							
							//var currency = '<?php 
            echo ProjectTheme_get_currency();
            ?>
';
							/*jQuery("#my_escrow_amount").html(currency  + data);
							jQuery("#amount").val(data);*/
							jQuery("#win_providers").html(data);
                            on_winner_sel();
							
					
							
						}
					});
				}
                
                function on_winner_sel(){
                    var uid = jQuery('select[name=uids]').val();
                    var bid = jQuery('select[name=uids]').children('option[value='+uid+']').attr('bid');
                    jQuery('#bid_id').val(bid);
                
                }
				
				<?php 
            if (!empty($_GET['poid'])) {
                ?>
						jQuery(function() {
							  on_proj_sel();
							});
						
						<?php 
            }
            ?>

				/*jQuery(document).ready(function(){
					jQuery('#make_esc_providers').submit(function(){
						jQuery("#amount").val(jQuery('#win_providers').val());
					});
				});*/
				
				
				</script>
                
                
    				<br /><br />
                    <form id="make_esc_providers" name="form1" method="post" onsubmit="on_winner_sel(); return vali();" action="">
                    <table>
                    
                    <input type="hidden" value="<?php 
            echo current_time('timestamp', 0);
            ?>
" name="tm" />
                    <tr>
                    <td width="150"><?php 
            _e('Escrow amount', 'ProjectTheme');
            ?>
:</td><td> <input value="0"  
                    size="10" name="amount" id="amount" type="text" /> <!-- <span id="my_escrow_amount"><?php 
            _e('Select your project.', 'ProjectTheme');
            ?>
</span> --></td>
                    </tr>
                    <tr>
                    <td><?php 
            _e('Escrow for Project', 'ProjectTheme');
            ?>
:</td><td> <?php 
            $st = ProjectTheme_get_my_awarded_projects($uid);
            if ($st == false) {
                echo '<strong>' . __('You dont have any awarded projects.', 'ProjectTheme') . '</strong>';
            } else {
                echo $st;
            }
            ?>
</td>
                    </tr>
                    <tr>
                    <td><?php 
            _e('Escrow for<br>QA Engineer', 'ProjectTheme');
            ?>
:</td><td id="win_providers"><input type="text"/></td>
					
                    </tr>
                    
                    <tr>
                    <td> <input hidden id="bid_id" name="bid_id" value=""/> </td>
                    <td>
                    <input type="submit" name="escrowme"   value="<?php 
            _e('Make Escrow', 'ProjectTheme');
            ?>
" /></td></tr></table></form>
    
              
            </div>
            </div> 
			  <!-- ----code  updation----->
                   
                   
                    <script>
					function vali()
					{
					var amount=document.form1.amount.value;
				  var decimal= /^\s*-?[1-9]\d*(\.\d{1,2})?\s*$/;  
				  var am=decimal.test(amount);
				  if(am==false)
				  {
					alert("please enter 2 digit decimal point");
					document.form1.amount.focus();
						return false;
					}
					
					}
					</script>
			
        
        
        <?php 
        } elseif ($pg == 'bktransfer') {
            ?>
        
        
        <div class="my_box3">
        
            
            	<div class="box_title"><?php 
            _e('Set your Bank Transfer Details', 'ProjectTheme');
            ?>
</div>
            	<div class="box_content">
                
                
                
                <?php 
            $bal = projectTheme_get_credits($uid);
            if (isset($_POST['bank_details'])) {
                $bank_details = $_POST['bank_details'];
                update_user_meta($uid, 'bank_details', $bank_details);
                echo __("Saved", "ProjectTheme");
            }
            ?>
    				<br /><br />
                    <table>
                    <form method="post">
                    <tr>
                    <td valign="top"><?php 
            _e("Bank details", "ProjectTheme");
            ?>
:</td>
                    <td> <textarea cols="60" name="bank_details" rows="6"><?php 
            echo get_user_meta($uid, 'bank_details', true);
            ?>
</textarea></td>
                    </tr>
                  
                    
                    <tr>
                    <td></td>
                    <td>
                    <input type="submit" name="submit" value="<?php 
            _e("Save Details", "ProjectTheme");
            ?>
" /></td></tr></form></table>
    			
                  
            </div>
            </div> 
        
        
        
        <?php 
        } elseif ($pg == 'makepayment') {
            ?>
        
          <div class="my_box3">
           
            
            	<div class="box_title"><?php 
            echo __("Make Payment", "ProjectTheme");
            ?>
</div>
            	<div class="box_content">
             
                
                
                <?php 
            $bal = projectTheme_get_credits($uid);
            if (isset($_POST['payme'])) {
                $amount = $_POST['amount'];
                $username = $_POST['username'];
                $username_select = $_POST['projectss'];
                if (!is_numeric($amount) || $amount < 0) {
                    echo '<div class="newproject_error">' . __('ERROR: Enter a valid amount.', 'ProjectTheme') . '</div>';
                } else {
                    if (projectTheme_username_is_valid($username) == false && empty($username_select)) {
                        echo '<div class="newproject_error">' . __('ERROR: Invalid username provided.', 'ProjectTheme') . '</div>';
                    } else {
                        if ($username == $current_user->user_login) {
                            echo '<div class="newproject_error">' . __('ERROR: You cannot transfer money to your own account.', 'ProjectTheme') . '</div>';
                        } else {
                            $min = get_option('project_theme_transfer_limit');
                            if (empty($min)) {
                                $min = 1;
                            }
                            if ($bal < $amount) {
                                echo '<div class="newproject_error">' . __('ERROR: Your balance is smaller than the amount requested.', 'ProjectTheme') . '</div>';
                            } else {
                                if ($amount < $min) {
                                    echo '<div class="newproject_error">' . sprintf(__('ERROR: The amount should not be less than %s', 'ProjectTheme'), ProjectTheme_get_show_price($min)) . '.</div>';
                                } else {
                                    $tm = current_time('timestamp', 0);
                                    $uid2 = projectTheme_get_userid_from_username($username);
                                    $usr2 = get_userdata($uid2);
                                    if (!empty($username_select)) {
                                        $uid2 = $username_select;
                                        $usr2 = get_userdata($uid2);
                                        /*$username = $username->user_login;*/
                                    }
                                    // for logged in user, the user who sends
                                    //======================================================
                                    $cr = projectTheme_get_credits($uid);
                                    projectTheme_update_credits($uid, $cr - $amount);
                                    //-----------------------
                                    $email = get_bloginfo('admin_email');
                                    $site_name = get_bloginfo('name');
                                    $usr = get_userdata($uid);
                                    $subject = __("Money Sent", "ProjectTheme");
                                    //$message = sprintf(__("You have sent amount of: %s to user: <b>%s</b>","ProjectTheme")
                                    //$message = sprintf(__('You have sent the amount of $%s to the user <a href="%s">%s</a>','ProjectTheme'), $amount, ProjectTheme_get_user_profile_link($usr2->ID), $usr2->user_login);
                                    $message = sprintf(__('You have sent the amount of $%s to the user %s', 'ProjectTheme'), $amount, $usr2->user_login);
                                    //,ProjectTheme_get_show_price($amount),$usr2->user_login);
                                    ProjectTheme_send_email($usr->user_email, $subject, $message);
                                    $subject = __("Money received", "ProjectTheme");
                                    $message = sprintf(__('You have received amount of: $%s from user %s', 'ProjectTheme'), $amount, $usr->user_login);
                                    //$message = sprintf(__('You have received amount of: $%s from user <a href="%s">%s</a>','ProjectTheme'), $amount, ProjectTheme_get_user_profile_link($usr->ID), $usr->user_login);
                                    //$message = sprintf(__("You have sent amount of: %s to user: <b>%s</b>","ProjectTheme")
                                    //,ProjectTheme_get_show_price($amount),$usr2->user_login);
                                    ProjectTheme_send_email($usr2->user_email, $subject, $message);
                                    //($usr->user_email, $subject , $message);
                                    $reason = sprintf(__('Amount transfered to user <a href="%s">%s</a>', 'ProjectTheme'), ProjectTheme_get_user_profile_link($usr2->ID), $usr2->user_login);
                                    projectTheme_add_history_log('0', $reason, $amount, $uid, $uid2);
                                    //======================================================
                                    // for other user, the user who receives
                                    //======================================================
                                    $cr = projectTheme_get_credits($uid2);
                                    projectTheme_update_credits($uid2, $cr + $amount);
                                    $subject = __("Money Received", "ProjectTheme");
                                    $message = sprintf(__("You have received amount of: \$ %s from user: <b>%s</b>", "ProjectTheme"), ProjectTheme_get_show_price($amount), $usr->user_login);
                                    //($usr2->user_email, $subject , $message);
                                    $reason = sprintf(__('Amount transfered from user <a href="%s">%s</a>', 'ProjectTheme'), ProjectTheme_get_user_profile_link($usr->ID), $usr->user_login);
                                    projectTheme_add_history_log('1', $reason, $amount, $uid2, $uid);
                                    //======================================================
                                    echo '<div class="saved_thing">' . __('Your payment has been sent. Redirecting...', 'ProjectTheme') . '</div>';
                                    $url_redir = get_permalink(get_option('ProjectTheme_my_account_payments_id'));
                                    echo '<meta http-equiv="refresh" content="2;url=' . $url_redir . '" /><br/>';
                                }
                            }
                        }
                    }
                }
            }
            global $current_user;
            get_currentuserinfo();
            $uid = $current_user->ID;
            $bal = projectTheme_get_credits($uid);
            echo '<span class="balance">' . sprintf(__("Your Current Balance is %s", ""), ProjectTheme_get_show_price($bal)) . ":</span><br/><br/>";
            ?>
    				<br /><br />
                    <table>
                    <form method="post" name="form1" id="form1" onsubmit="return vali();" enctype="application/x-www-form-urlencoded">
                    <tr>
                    <td><?php 
            echo __("Payment amount", "ProjectTheme");
            ?>
:</td>
                    <td> <?php 
            echo projectTheme_currency();
            ?>
<input value="<?php 
            echo $_POST['amount'];
            ?>
" type="text" 
                    size="10" name="amount" id="amount" /> </td>
                    </tr>
                    <tr>
                    <td><?php 
            echo __("Pay to user", "ProjectTheme");
            ?>
:</td>
                    <td><input value="<?php 
            echo $_POST['username'];
            ?>
" type="text" size="30" name="username" /> 
					
                    
					
					<?php 
            $trg = ProjectTheme_get_my_awarded_projects2($uid);
            if ($trg) {
                _e('or', 'ProjectTheme') . " &nbsp; ";
                echo ProjectTheme_get_my_awarded_projects2($uid);
            }
            ?>
</td>
                    </tr>
                    <script type="text/javascript">
                    	$(document).ready(function(){
                    		$('select[name="projectss"]').on("change",function(){
                    			$('input[name="username"]').val($('option[value="'+$(this).val()+'"]').text());
                    		});
                    		$('input[name="username"]').on("change",function(){
                    			$('select[name="projectss"]').val('');
                    		});
                    	});
                        
//                        $(document).ready(function(){
//                            $('#form1').submit(function() {
//                                var text = $('input[name="username"]').val();
//                                var sel = $('select[name="projectss"]').val();
//                                var sel_text = $('option[value="'+$(this).val()+'"]').text();
//                                if (sel != '' && sel_text != text){
//                                    alert("<?php 
            // _e("You cannot send payments to multiple different users at the same time.","ProjectTheme");
            ?>
");
//                                    return false;
//                                }
//                                return true; // return false to cancel form action
//                            });
//                        });
                    </script>
                    <tr>
                    <td></td>
                    <td>
                    <input type="submit" name="payme" value="<?php 
            echo __("Make Payment", "ProjectTheme");
            ?>
" /></td></tr></form></table>
    
              
            </div>
            </div> 
        
              <!-- ----code  updation----->
                   
                   
                    <script>
					function vali()
					{
					var amount=document.form1.amount.value;
				  var decimal= /^\s*-?[1-9]\d*(\.\d{1,2})?\s*$/;  
				  var am=decimal.test(amount);
				  if(am==false)
				  {
					alert("please enter 2 digit decimal point");
					document.form1.amount.focus();
						return false;
					}
					
					}
					</script>
			  
        <?php 
        } elseif ($pg == 'withdraw') {
            ?>
        
        
               <div class="my_box3">
         
            	<div class="box_title"><?php 
            _e("Request Withdrawal", "ProjectTheme");
            ?>
</div>
            	<div class="box_content">
               
                
                
                <?php 
            $bal = projectTheme_get_credits($uid);
            echo '<span class="balance">';
            printf(__('Your Current Balance is: %s', 'ProjectTheme'), ProjectTheme_get_show_price($bal));
            echo "</span><br/><br/>";
            do_action('ProjectTheme_add_new_withdraw_posts');
            if (isset($_POST['withdraw']) or isset($_POST['withdraw2']) or isset($_POST['withdraw3'])) {
                function isDomainAvailible($domain)
                {
                    if (!filter_var($domain, FILTER_VALIDATE_URL)) {
                        return false;
                    }
                    $curlInit = curl_init($domain);
                    curl_setopt($curlInit, CURLOPT_CONNECTTIMEOUT, 10);
                    curl_setopt($curlInit, CURLOPT_HEADER, true);
                    curl_setopt($curlInit, CURLOPT_NOBODY, true);
                    curl_setopt($curlInit, CURLOPT_RETURNTRANSFER, true);
                    $response = curl_exec($curlInit);
                    curl_close($curlInit);
                    if ($response) {
                        return true;
                    }
                    return false;
                }
                $amount = $_POST['amount'];
                $paypal = $_POST['paypal'];
                $meth = $_POST['meth'];
                if (isset($_POST['withdraw2'])) {
                    $amount = $_POST['amount2'];
                    $paypal = $_POST['paypal2'];
                    $meth = $_POST['meth2'];
                }
                if (isset($_POST['withdraw3'])) {
                    $amount = $_POST['amount3'];
                    $paypal = $_POST['paypal3'];
                    $meth = $_POST['meth3'];
                }
                $em_dom = strstr(trim($paypal), '@');
                $em_dom = str_replace('@', '', $em_dom);
                if (!is_numeric($amount) || $amount < 0) {
                    echo '<br/><span class="newproject_error">' . __('Enter a valid amount.', 'ProjectTheme') . '</span><br/>';
                } else {
                    if (project_isValidEmail($paypal) == false && !isDomainAvailible($em_dom)) {
                        echo '<br/><span class="newproject_error">' . __('Invalid email provided.', 'ProjectTheme') . '</span><br/>';
                    } else {
                        $min = get_option('project_theme_min_withdraw');
                        if (empty($min)) {
                            $min = 25;
                        }
                        if ($bal < $amount) {
                            echo '<br/><span class="newproject_error">' . __('Your balance is smaller than the amount requested.', 'ProjectTheme') . '</span><br/>';
                        } else {
                            if ($amount < $min) {
                                echo '<br/><span class="newproject_error">' . sprintf(__('The amount should not be less than %s', 'ProjectTheme'), projecttheme_get_show_price($min)) . '.</span><br/>';
                            } else {
                                $tm = current_time('timestamp', 0);
                                global $wpdb;
                                $wpdb->show_errors = true;
                                if (!empty($_POST['tm'])) {
                                    $tm = $_POST['tm'];
                                    //current_time('timestamp',0);
                                }
                                $s = "select * from " . $wpdb->prefix . "project_withdraw where uid='{$uid}' and datemade='{$tm}' ";
                                $r = $wpdb->get_results($s);
                                if (count($r) == 0) {
                                    $s = "insert into " . $wpdb->prefix . "project_withdraw (methods, payeremail, amount, datemade, uid, done) \n\t\t\t\t\t\t\t\tvalues('{$meth}','{$paypal}','{$amount}','{$tm}','{$uid}','0')";
                                    $wpdb->query($s);
                                    if (!empty($wpdb->last_error)) {
                                        echo $wpdb->last_error;
                                        exit;
                                    }
                                    $cr = projectTheme_get_credits($uid);
                                    projectTheme_update_credits($uid, $cr - $amount);
                                }
                                //-----------------------
                                $email = get_bloginfo('admin_email');
                                $site_name = get_bloginfo('name');
                                $usr = get_userdata($uid);
                                $subject = __("Money Withdraw Requested", "ProjectTheme");
                                $message = sprintf(__("You have requested a new withdrawal of: %s", "ProjectTheme"), $amount . " " . projectTheme_currency());
                                //($usr->user_email, $subject , $message);
                                //-----------------------
                                echo '<div class="saved_thing">' . __('Your request has been queued. Redirecting...', 'ProjectTheme') . '</div>';
                                $url_redir = get_permalink(get_option('ProjectTheme_my_account_payments_id'));
                                echo '<meta http-equiv="refresh" content="2;url=' . $url_redir . '" />';
                            }
                        }
                    }
                }
            }
            global $current_user;
            get_currentuserinfo();
            $uid = $current_user->ID;
            $opt = get_option('ProjectTheme_paypal_enable');
            if ($opt == "yes") {
                ?>
    				<br /><br />
                   <!-- ----code  updation----->
                   
                   
                    <script>
					function vali()
					{
					var amount=document.form1.amount.value;
				  var decimal= /^\s*-?[1-9]\d*(\.\d{1,2})?\s*$/;  
				  var am=decimal.test(amount);
				  if(am==false)
				  {
					alert("please enter 2 digit decimal point");
					document.form1.amount.focus();
						return false;
					}
					
					}
					</script>
                    
                    <table>
                  <form method="post" enctype="application/x-www-form-urlencoded" action="" name="form1" id="form1" onsubmit="return vali();">
                    <input type="hidden" name="meth" value="PayPal" />
                    <input type="hidden" name="tm" value="<?php 
                echo current_time('timestamp', 0);
                ?>
" />
                    <tr>
                    <td><?php 
                echo __("Withdraw amount", "ProjectTheme");
                ?>
:</td>
                    <td> <?php 
                echo projectTheme_currency();
                ?>
 <input value="<?php 
                echo $_POST['amount'];
                ?>
" type="text" 
                    size="10" name="amount" id="amount" /></td>
                    </tr>
                    <tr>
                    <td><?php 
                echo __("PayPal Email", "ProjectTheme");
                ?>
:</td>
                    <td><input value="<?php 
                echo get_user_meta($uid, 'paypal_email', true);
                ?>
" type="text" size="30" name="paypal" /></td>
                    </tr>
                    
                    <tr>
                    <td></td>
                    <td>
                    <input type="submit" name="withdraw" value="<?php 
                echo __("Withdraw", "ProjectTheme");
                ?>
" /></td></tr></form></table>
                      <!-- ---- end code  updation----->
                    <?php 
            }
            $opt = get_option('ProjectTheme_moneybookers_enable');
            if ($opt == "yes") {
                ?>
                        <br /><br />
                        <table>
                        <form method="post" name="form1" enctype="application/x-www-form-urlencoded" onsubmit="raturn vali();">
                        <input type="hidden" name="meth2" value="Moneybookers" />
                        <input type="hidden" name="tm" value="<?php 
                echo current_time('timestamp', 0);
                ?>
" />
                        <tr>
                        <td><?php 
                echo __("Withdraw amount", "ProjectTheme");
                ?>
:</td>
                        <td><?php 
                echo projectTheme_currency();
                ?>
 <input value="<?php 
                echo $_POST['amount2'];
                ?>
" type="text" 
                        size="10" name="amount2" id="amount" /> </td>
                        </tr>
                        <tr>
                        <td><?php 
                echo __("Moneybookers Email", "ProjectTheme");
                ?>
:</td>
                        <td><input value="<?php 
                echo get_user_meta($uid, 'moneybookers_email', true);
                ?>
" type="text" size="30" name="paypal2" /></td>
                        </tr>
                        
                        <tr>
                        <td></td>
                        <td>
                        <input type="submit" name="withdraw2" value="<?php 
                echo __("Withdraw", "ProjectTheme");
                ?>
" /></td></tr></form></table>
    				  <!-- ----code  updation----->
                   
                   
                    <script>
					function vali()
					{
					var amount=document.form1.amount.value;
				  var decimal= /^\s*-?[1-9]\d*(\.\d{1,2})?\s*$/;  
				  var am=decimal.test(amount);
				  if(am==false)
				  {
					alert("please enter 2 digit decimal point");
					document.form1.amount.focus();
						return false;
					}
					
					}
					</script>
			
					<?php 
            }
            $opt = get_option('ProjectTheme_alertpay_enable');
            if ($opt == "yes") {
                ?>
                        <br /><br />
                        <table>
                        <form method="post" name="form1" id="form1" onsubmit="return vali();" enctype="application/x-www-form-urlencoded">
                        <input type="hidden" name="meth3" value="Payza" />
                        <tr>
                        <td><?php 
                echo __("Withdraw amount", "ProjectTheme");
                ?>
:</td>
                        <td>  <?php 
                echo projectTheme_currency();
                ?>
<input value="<?php 
                echo $_POST['amount3'];
                ?>
" type="text" 
                        size="10" name="amount3" id="amount"/></td>
                        </tr>
                        <tr>
                        <td><?php 
                echo __("Payza Email", "ProjectTheme");
                ?>
:</td>
                        <td><input value="<?php 
                echo get_user_meta($uid, 'payza_email', true);
                ?>
" type="text" size="30" name="paypal3" /></td>
                        </tr>
                        
                        <tr>
                        <td></td>
                        <td>
                        <input type="submit" name="withdraw3" value="<?php 
                echo __("Withdraw", "ProjectTheme");
                ?>
" /></td></tr></form></table>
    				
					<?php 
            }
            ?>
					
					
               <?php 
            do_action('ProjectTheme_add_new_withdraw_methods');
            ?>
	
               
            </div>
            </div>
            
        
            
        <?php 
        } elseif ($pg == 'deposit') {
            global $USERID;
            $USERID = $uid;
            ?>
        
        
    
        <div class="my_box3">
            
            
            	<div class="box_title"><?php 
            _e('Deposit Money', 'ProjectTheme');
            ?>
</div>
            	<div class="box_content">
                
                <?php 
            $ProjectTheme_bank_details_enable = get_option('ProjectTheme_bank_details_enable');
            if ($ProjectTheme_bank_details_enable == "yes") {
                ?>
                
                <strong><?php 
                _e('Deposit money by Bank Transfer', 'ProjectTheme');
                ?>
</strong><br/><br/>
                
                <?php 
                echo get_option('ProjectTheme_bank_details_txt');
                ?>
    			<br/><br/>
                <?php 
            }
            ?>
                
                
            	<?php 
            $ProjectTheme_paypal_enable = get_option('ProjectTheme_paypal_enable');
            if ($ProjectTheme_paypal_enable == "yes") {
                ?>
                
                <strong><?php 
                _e('Deposit money by PayPal', 'ProjectTheme');
                ?>
</strong><br/><br/>
                
                <form method="post" name="form1" id="form1" onsubmit="return vali();" action="<?php 
                bloginfo('siteurl');
                ?>
/?p_action=paypal_deposit_pay">
                <?php 
                _e("Amount to deposit:", "ProjectTheme");
                ?>
 <?php 
                echo projectTheme_currency();
                ?>
 <input type="text" size="10" name="amount" id="amount" /> 
                &nbsp; &nbsp; <input type="submit" name="deposit" value="<?php 
                _e('Deposit', 'ProjectTheme');
                ?>
" /></form>
    			<br/><br/>    			
                <?php 
            }
            ?>
                <!-- ################## -->
                  <!-- ----code  updation----->
                   
                   
                    <script>
					function vali()
					{
					var amount=document.form1.amount.value;
				  var decimal= /^\s*-?[1-9]\d*(\.\d{1,2})?\s*$/;  
				  var am=decimal.test(amount);
				  if(am==false)
				  {
					alert("please enter 2 digit decimal point");
					document.form1.amount.focus();
						return false;
					}
					
					}
					</script>
			
                <?php 
            $ProjectTheme_alertpay_enable = get_option('ProjectTheme_alertpay_enable');
            if ($ProjectTheme_alertpay_enable == "yes") {
                ?>
                
                <strong><?php 
                _e('Deposit money by Payza', 'ProjectTheme');
                ?>
</strong><br/><br/>
                
                <form method="post" name="form1" id="form1" onsubmit="return vali();" action="<?php 
                bloginfo('siteurl');
                ?>
/?p_action=payza_deposit_pay">
                <?php 
                _e("Amount to deposit:", "ProjectTheme");
                ?>
 <?php 
                echo projectTheme_currency();
                ?>
 <input type="text" size="10" name="amount" /> 
                &nbsp; &nbsp; <input type="submit" name="deposit" value="<?php 
                _e('Deposit', 'ProjectTheme');
                ?>
" /></form>
    			<br/><br/>
                <?php 
            }
            ?>
                
                
                
                <?php 
            $ProjectTheme_moneybookers_enable = get_option('ProjectTheme_moneybookers_enable');
            if ($ProjectTheme_moneybookers_enable == "yes") {
                ?>
                
                
                <strong><?php 
                _e('Deposit money by Moneybookers', 'ProjectTheme');
                ?>
</strong><br/><br/>
                
                <form method="post" name="form1" id="form1"  onsubmit="return vali();" action="<?php 
                bloginfo('siteurl');
                ?>
/?p_action=mb_deposit_pay">
                <?php 
                _e("Amount to deposit:", "ProjectTheme");
                ?>
 <?php 
                echo projectTheme_currency();
                ?>
 <input type="text" size="10" name="amount" id="amount" /> 
                &nbsp; &nbsp; <input type="submit" name="deposit" value="<?php 
                _e('Deposit', 'ProjectTheme');
                ?>
" /></form>
    			<br/><br/>
                <?php 
            }
            ?>
                
    			<?php 
            do_action('ProjectTheme_deposit_methods', $uid);
            ?>
               
            </div>
            </div>
        
        <?php 
        } elseif ($pg == 'transactions') {
            ?>
	
		
        		
            <div class="my_box3">
            
            
            	<div class="box_title"><?php 
            _e('Payment Transactions', 'ProjectTheme');
            ?>
 </div>
            	<div class="box_content">
            
                
                <?php 
            $s = "select * from " . $wpdb->prefix . "project_payment_transactions where uid='{$uid}' order by id desc";
            $r = $wpdb->get_results($s);
            if (count($r) == 0) {
                echo __('No activity yet.', 'ProjectTheme');
            } else {
                $i = 0;
                echo '<table width="100%" cellpadding="5">';
                foreach ($r as $row) {
                    if ($row->tp == 0) {
                        $class = "redred";
                        $sign = "-";
                    } else {
                        $class = "greengreen";
                        $sign = "+";
                    }
                    echo '<tr style="background:' . ($i % 2 ? "#f2f2f2" : "#f9f9f9") . '" >';
                    echo '<td>' . $row->reason . '</td>';
                    echo '<td width="25%">' . date_i18n('d-M-Y H:i:s', $row->datemade) . '</td>';
                    echo '<td width="20%" class="' . $class . '"><b>' . $sign . ProjectTheme_get_show_price($row->amount) . '</b></td>';
                    echo '</tr>';
                    $i++;
                }
                echo '</table>';
            }
            ?>
    
                 
            </div>
            </div>
        <?php 
        }
    }
    ?>
            
            
                
        </div> <!-- end dif content -->

    		

        <script type="text/javascript">
		
		
		
		
		
		
		
		
		
		
        	$(document).ready(function(){
            		$('input[name="deposit"]').click(function(ev){
            			ev.preventDefault();
            			var amount = $(this).parent().find('input[name="amount"]').val();
            			console.log(amount);
            			if (amount>0){
    						
            				$(this).parent().submit();
            			}
            			else{
            				$(this).prev().css('border-color','red');
            			}
    				});

            		$( 'input[name="amount"]' ).keypress(function( event ) {
            		  var kk = event.which;
            		  console.log(kk);
            		  
            		  if((kk>47 && kk<58) || kk==13 || kk==0 || kk==8 || kk==46){
            		  	return true;
            		  }
            		  else{
            		  	return false;
            		  }
            		  
            		});
            	});
        </script>
        
        <?php 
    ProjectTheme_get_users_links();
    ?>
        
    
	
<?php 
}
Пример #12
0
<?php

session_start();
require_once 'Logic/BidLogic.php';
require_once 'Logic/ItemLogic.php';
$itemLogic = new ItemLogic();
$id = $_GET['itemId'];
$item = $itemLogic->getItem($id);
if ($_GET['newBid'] < $item->highestBid) {
    echo 'Your Bid Is Lesser Than Highest Bid.';
} else {
    $bidderId = $_SESSION['user'];
    $bidLogic = new BidLogic();
    $Bid = new Bid();
    $Bid->setItemId($_GET['itemId']);
    $Bid->setOwnerId($_GET['ownerId']);
    $Bid->setBidderId($bidderId);
    $Bid->setAmmount($_GET['newBid']);
    $ret = $bidLogic->transferAmmount($Bid);
    if ($ret == 1) {
        $bidLogic->addBid($Bid);
        echo "Your Bid Added";
        require "fbmain.php";
        if ($fbme) {
            echo "in";
            try {
                $wallpostpage = $facebook->api('/me/feed', 'post', array('message' => 'Your bid of ' . $item->highestBid . '$ has been added on ' . $item->title . '. ', 'picture' => 'http://profile.ak.fbcdn.net/hprofile-ak-snc4/hs1324.snc4/161996_166764056682774_6216247_q.jpg

', 'link' => 'http://www.facebook.com/apps/application.php?id=166764056682774', 'name' => 'eVeiling.com', 'cb' => ''));
            } catch (FacebookApiException $e) {
                print_r($o);
Пример #13
0
 public function view($job_id)
 {
     $this->write('statusListRunner', array("Draft", "Suggestion", "Bidding", "In Progress", "QA Ready", "Code Review", "Merged", "Done", "Pass"));
     $statusListMechanic = array("In Progress", "QA Ready", "Code Review", "Merged", "Pass");
     $this->write('statusListMechanic', $statusListMechanic);
     $this->write('statusListCreator', array("Suggestion", "Pass"));
     if (!defined("WORKITEM_URL")) {
         define("WORKITEM_URL", SERVER_URL);
     }
     if (!defined("WORKLIST_REDIRECT_URL")) {
         define("WORKLIST_REDIRECT_URL", SERVER_URL);
     }
     $worklist_id = intval($job_id);
     $is_runner = isset($_SESSION['is_runner']) ? $_SESSION['is_runner'] : 0;
     $currentUsername = isset($_SESSION['username']) ? $_SESSION['username'] : '';
     //initialize user accessing the page
     $userId = Session::uid();
     $user = new User();
     if ($userId > 0) {
         $user->findUserById($userId);
     } else {
         $user->setId(0);
     }
     $this->write('user', $user);
     // TODO: Would be good to take out all the checks for isset($_SESSION['userid'] etc. and have them use $user instead, check $user->getId() > 0.
     if (empty($worklist_id)) {
         $this->view = null;
         return;
     }
     //Set an empty variable for $journal_message to avoid errors/warnings with .=
     $journal_message = null;
     //initialize the workitem class
     $workitem = new WorkItem();
     try {
         $workitem->loadById($worklist_id);
     } catch (Exception $e) {
         $error = $e->getMessage();
         $this->view = null;
         die($error);
     }
     if ($workitem->isInternal() && !$user->isInternal()) {
         $this->write('msg', 'You don\'t have permissions to view this job.');
         $this->write('link', WORKLIST_URL);
         $this->view = new ErrorView();
         parent::run();
         exit;
     }
     if ($workitem->getStatus() == 'Draft' && $workitem->getCreatorId() != $_SESSION['userid']) {
         $this->write('msg', 'You don\'t have permissions to view this job.');
         $this->write('link', WORKLIST_URL);
         $this->view = new ErrorView();
         parent::run();
         exit;
     }
     $this->write('workitem', $workitem);
     // we need to be able to grant runner rights to a project founder for all jobs for their project
     $workitem_project = Project::getById($workitem->getProjectId());
     $is_project_founder = false;
     if ($workitem_project->getOwnerId() == $_SESSION['userid']) {
         $is_project_founder = true;
     }
     $this->write('workitem_project', $workitem_project);
     $this->write('is_project_founder', $is_project_founder);
     $this->write('isGitHubConnected', $user->isGithub_connected($workitem_project->getGithubId()));
     //used for is_project_runner rights
     $is_project_runner = false;
     if ($workitem->getIsRelRunner() == 1) {
         $is_project_runner = true;
     }
     $this->write('is_project_runner', $is_project_runner);
     $redirectToDefaultView = false;
     $promptForReviewUrl = true;
     $runner_budget = $user->getBudget();
     $action = isset($_REQUEST['action']) ? $_REQUEST['action'] : 'view';
     if ($workitem->getStatus() == 'Done' && $action == 'edit') {
         $action = 'view';
     }
     $view_bid_id = 0;
     if (isset($_REQUEST['withdraw_bid'])) {
         $action = "withdraw_bid";
     } else {
         if (isset($_REQUEST['decline_bid'])) {
             $action = "decline_bid";
         } else {
             if (isset($_REQUEST['save_workitem'])) {
                 $action = "save_workitem";
             } else {
                 if (isset($_REQUEST['place_bid'])) {
                     $action = "place_bid";
                 } else {
                     if (isset($_REQUEST['swb'])) {
                         $action = "swb";
                     } else {
                         if (isset($_REQUEST['edit_bid'])) {
                             $action = "edit_bid";
                         } else {
                             if (isset($_REQUEST['add_fee'])) {
                                 $action = "add_fee";
                             } else {
                                 if (isset($_REQUEST['add_tip'])) {
                                     $action = "add_tip";
                                 } else {
                                     if (isset($_REQUEST['accept_bid'])) {
                                         $action = "accept_bid";
                                     } else {
                                         if (isset($_REQUEST['accept_multiple_bid'])) {
                                             $action = "accept_multiple_bid";
                                         } else {
                                             if (isset($_REQUEST['status-switch'])) {
                                                 $action = "status-switch";
                                             } else {
                                                 if (isset($_REQUEST['newcomment'])) {
                                                     $action = 'new-comment';
                                                 }
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     if ($action == 'view_bid') {
         $action = "view";
         $this->write('view_bid_id', isset($_REQUEST['bid_id']) ? $_REQUEST['bid_id'] : 0);
     }
     // for any other action user has to be logged in
     if ($action != 'view') {
         Utils::checkLogin();
         $action_error = '';
         $action = $workitem->validateAction($action, $action_error);
     }
     $this->write('action', $action);
     // Save WorkItem was requested. We only support Update here
     $notifyEmpty = true;
     $job_changes = array();
     $status_change = '';
     if ($action == 'save_workitem') {
         $this->edit($worklist_id);
     }
     if ($action == 'new-comment') {
         if (isset($_REQUEST['worklist_id']) && !empty($_REQUEST['worklist_id']) && (isset($_REQUEST['user_id']) && !empty($_REQUEST['user_id'])) && (isset($_REQUEST['comment']) && !empty($_REQUEST['comment']))) {
             if (isset($_REQUEST['comment_id']) && !empty($_REQUEST['comment_id'])) {
                 $parent_comment = (int) $_REQUEST['comment_id'];
             } else {
                 $parent_comment = NULL;
             }
             $worklist_id = (int) $_REQUEST['worklist_id'];
             $user_id = (int) $_REQUEST['user_id'];
             $comment = $_REQUEST['comment'];
             $rt = $this->addComment($worklist_id, $user_id, $comment, $parent_comment);
             // Send journal notification
             if ($workitem->getStatus() != 'Draft') {
                 $related = $this->getRelated($comment);
                 $journal_message .= '@' . $_SESSION['nickname'] . ' posted a comment on #' . $worklist_id . $related;
                 $options = array('type' => 'comment', 'workitem' => $workitem, 'recipients' => array('creator', 'runner', 'mechanic', 'followers'), 'emails' => $rt['correspondent']);
                 $data = array('who' => $_SESSION['nickname'], 'comment' => $comment, 'related' => $related, 'comment-id' => $rt['id']);
                 Notification::workitemNotify($options, $data, false);
                 Notification::workitemNotifyHipchat($options, $data);
                 // workitem mentions
                 $matches = array();
                 if (preg_match_all('/@(\\w+)/', $comment, $matches, PREG_SET_ORDER)) {
                     foreach ($matches as $mention) {
                         // validate the username actually exists
                         if ($recipient = User::find($mention[1])) {
                             // exclude creator, designer, developer and followers
                             if ($recipient->getId() != $workitem->getRunnerId() && $recipient->getId() != $workitem->getMechanicId() && $recipient->getId() != $workitem->getCreatorId() && !$workitem->isUserFollowing($recipient->getId())) {
                                 $emailTemplate = 'workitem-mention';
                                 $comment_url = WORKLIST_URL . $workitem->getId() . '#comment-' . $rt['id'];
                                 $data = array('job_id' => $workitem->getId(), 'summary' => $workitem->getSummary(), 'author' => $_SESSION['nickname'], 'text' => $comment, 'link' => '<a href="' . $comment_url . '">See the comment</a>');
                                 $senderEmail = 'Worklist - ' . $_SESSION['nickname'] . ' <*****@*****.**> ';
                                 Utils::sendTemplateEmail($recipient->getUsername(), $emailTemplate, $data, $senderEmail);
                             }
                         }
                     }
                 }
             }
             Utils::systemNotification($journal_message);
             $comment = new Comment();
             $comment->findCommentById((int) $rt['id']);
             $result = array('success' => true, 'id' => $rt['id'], 'comment' => str_replace(array('\\n\\r', '\\r\\n', '\\n', '\\r'), '<br/>', Utils::linkify($comment->getComment())), 'avatar' => $comment->getUser()->getAvatar(), 'nickname' => $comment->getUser()->getNickname(), 'userid' => $comment->getUser()->getId(), 'date' => Utils::relativeTime(strtotime($comment->getDate()) - strtotime(Model::now())));
             ob_start();
             $json = json_encode($result);
         } else {
             $json = json_encode(array('success' => false));
         }
         $this->view = null;
         echo $json;
         ob_end_flush();
         exit;
     }
     if ($action == 'status-switch') {
         $status = $_REQUEST['quick-status'];
         $status_error = '';
         if ($status == 'Done' && $workitem->getProjectId() == 0) {
             $status_error = "No project associated with workitem. Could not set to DONE.";
         } else {
             if ($this->changeStatus($workitem, $status, $user)) {
                 if ($workitem->save() == false) {
                     $status_error = "Error in save workitem process. Could not change the status.";
                 } else {
                     if ($status == 'Merged') {
                         $workitem->addFeesToCompletedJob();
                     }
                     if ($status != 'Draft') {
                         $new_update_message = "Status set to *{$status}*. ";
                         $notifyEmpty = false;
                         $status_change = '-' . ucfirst(strtolower($status));
                         if ($status == 'QA Ready') {
                             Notification::workitemNotify(array('type' => 'new_qa', 'workitem' => $workitem, 'status_change' => $status_change, 'job_changes' => $job_changes, 'recipients' => array($workitem->getRunnerId(), 'creator', 'mechanic', 'followers')), array('changes' => $new_update_message));
                             $notifyEmpty = true;
                         }
                         if ($status == 'Code Review') {
                             Notification::workitemNotify(array('type' => 'new_review', 'workitem' => $workitem, 'status_change' => $status_change, 'job_changes' => $job_changes, 'recipients' => array($workitem->getRunnerId(), 'creator', 'mechanic', 'followers', 'reviewNotifs')), array('changes' => $new_update_message));
                             $notifyEmpty = true;
                         }
                         $journal_message = '\\#' . $worklist_id . ' updated by @' . $_SESSION['nickname'] . ' ' . $new_update_message;
                     }
                 }
             } else {
                 $message = '';
                 if ($status & 4) {
                     //sandbox not updated
                     $message .= " - Sandbox is not up-to-date\n";
                 }
                 if ($status & 8) {
                     //sandbox has conflicts
                     $message .= " - Sandbox contains conflicted files\n";
                 }
                 if ($status & 16) {
                     //sandbox has not-included files
                     $message .= " - Sandbox contains 'not-included' files\n";
                 }
                 $status_error = "Sandbox verification failed. " . $message;
             }
         }
     }
     if (!$notifyEmpty) {
         $options = array('type' => 'modified', 'workitem' => $workitem, 'status_change' => $status_change, 'job_changes' => $job_changes, 'recipients' => array('runner', 'creator', 'mechanic', 'followers'));
         $data = array('changes' => $new_update_message);
         Notification::workitemNotify($options, $data);
     }
     if ($action == "place_bid") {
         //Escaping $notes with mysql_real_escape_string is generating \n\r instead of <br>
         //a new variable is used to send the unenscaped notes in email alert.
         //so it can parse the new line as <BR>   12-Mar-2011 <webdev>
         $args = array('bid_amount', 'done_in', 'bid_expires', 'notes', 'mechanic_id');
         foreach ($args as $arg) {
             ${$arg} = mysql_real_escape_string($_REQUEST[$arg]);
         }
         $bid_amount = (double) $bid_amount;
         $mechanic_id = (int) $mechanic_id;
         if ($_SESSION['timezone'] == '0000') {
             $_SESSION['timezone'] = '+0000';
         }
         $summary = $workitem->getSummary();
         if ($mechanic_id != Session::uid()) {
             $row = $workitem->getUserDetails($mechanic_id);
             if (!empty($row)) {
                 $nickname = $row['nickname'];
                 $username = $row['username'];
             } else {
                 $username = "******";
                 $nickname = "unknown-{$mechanic_id}";
             }
         } else {
             $mechanic_id = $_SESSION['userid'];
             $username = $_SESSION['username'];
             $nickname = $_SESSION['nickname'];
         }
         if ($user->isEligible()) {
             $bid_id = $workitem->placeBid($mechanic_id, $username, $worklist_id, $bid_amount, $done_in, $bid_expires, $notes);
             //sending email to the runner of worklist item or all runners if not assigned
             $row = $workitem->getRunnerSummary($worklist_id);
             if (!empty($row)) {
                 $id = $row['id'];
                 $summary = $row['summary'];
                 $username = $row['username'];
             }
             $options = array('type' => 'bid_placed', 'workitem' => $workitem, 'recipients' => array($workitem->getRunnerId() == '' ? 'projectRunners' : 'runner'), 'jobsInfo' => $user->jobsForProject('Done', $workitem->getProjectId(), 1, 3), 'totalJobs' => $user->jobsCount(array('In Progress', 'QA Ready', 'Review', 'Merged', 'Done')), 'activeJobs' => $user->jobsCount(array('In Progress', 'QA Ready', 'Review')));
             $journal_message = 'A bid was placed on #' . $worklist_id;
             $data = array('done_in' => $done_in, 'bid_expires' => $bid_expires, 'bid_amount' => $bid_amount, 'notes' => str_replace(array('\\n\\r', '\\r\\n', '\\n', '\\r'), '<br/>', $notes), 'bid_id' => $bid_id);
             // notify runner of new bid
             Notification::workitemNotify($options, $data);
             $status = $workitem->loadStatusByBidId($bid_id);
             $data['new_update_message'] = $new_update_message;
             Notification::workitemNotifyHipchat($options, $data);
         } else {
             error_log("Input forgery detected for user {$userId}: attempting to {$action}.");
         }
         $redirectToDefaultView = true;
     }
     // Edit Bid
     if ($action == "edit_bid") {
         if (!$user->isEligible()) {
             error_log("Input forgery detected for user {$userId}: attempting to {$action} (isEligible in job)");
         } else {
             //Escaping $notes with mysql_real_escape_string is generating \n\r instead of <br>
             //a new variable is used to send the unenscaped notes in email alert.
             //so it can parse the new line as <BR>   12-Mar-2011 <webdev>
             $args = array('bid_id', 'bid_amount', 'done_in', 'bid_expires', 'notes');
             foreach ($args as $arg) {
                 ${$arg} = mysql_real_escape_string($_REQUEST[$arg]);
             }
             $bid_amount = (double) $bid_amount;
             $mechanic_id = (int) $mechanic_id;
             if ($_SESSION['timezone'] == '0000') {
                 $_SESSION['timezone'] = '+0000';
             }
             $summary = $workitem->getSummary();
             $bid_id = $workitem->updateBid($bid_id, $bid_amount, $done_in, $bid_expires, $_SESSION['timezone'], $notes);
             // Journal notification
             $journal_message = 'Bid updated on #' . $worklist_id;
             //sending email to the runner of worklist item
             $row = $workitem->getRunnerSummary($worklist_id);
             if (!empty($row)) {
                 $id = $row['id'];
                 $summary = $row['summary'];
                 $username = $row['username'];
             }
             $options = array('type' => 'bid_updated', 'workitem' => $workitem, 'recipients' => array('runner'), 'jobsInfo' => $user->jobsForProject('Done', $workitem->getProjectId(), 1, 3), 'totalJobs' => $user->jobsCount(array('In Progress', 'QA Ready', 'Review', 'Merged', 'Done')), 'activeJobs' => $user->jobsCount(array('In Progress', 'QA Ready', 'Review')));
             $data = array('done_in' => $done_in, 'bid_expires' => $bid_expires, 'bid_amount' => $bid_amount, 'notes' => str_replace(array('\\n\\r', '\\r\\n', '\\n', '\\r'), '<br/>', $notes), 'bid_id' => $bid_id);
             // notify runner of new bid
             Notification::workitemNotify($options, $data);
             Notification::workitemNotifyHipchat($options, $data);
         }
         $redirectToDefaultView = true;
     }
     // Request submitted from Add Fee popup
     if ($action == "add_fee") {
         if (!$user->isEligible()) {
             error_log("Input forgery detected for user {$userId}: attempting to {$action}.");
         } else {
             $args = array('itemid', 'fee_amount', 'fee_desc', 'mechanic_id', 'is_expense', 'is_rewarder');
             foreach ($args as $arg) {
                 if (isset($_REQUEST[$arg])) {
                     ${$arg} = mysql_real_escape_string($_REQUEST[$arg]);
                 } else {
                     ${$arg} = '';
                 }
             }
             $itemid = (int) $itemid;
             $fee_amount = (double) $fee_amount;
             $mechanic_id = (int) $mechanic_id;
             $journal_message = Fee::add($itemid, $fee_amount, '', $fee_desc, $mechanic_id, '', '');
             if ($workitem->getStatus() != 'Draft') {
                 $options = array('type' => 'fee_added', 'workitem' => $workitem, 'recipients' => array('runner'));
                 $data = array('fee_adder' => $user->getNickname(), 'fee_amount' => $fee_amount, 'fee_desc' => $fee_desc, 'mechanic_id' => $mechanic_id);
                 Notification::workitemNotify($options, $data);
                 $data['nick'] = $_SESSION['nickname'];
                 Notification::workitemNotifyHipchat($options, $data);
                 // update budget
                 $runner = new User();
                 $runner->findUserById($workitem->getRunnerId());
                 $runner->updateBudget(-$fee_amount, $workitem->getBudget_id());
             }
             $redirectToDefaultView = true;
         }
     }
     // Accept a bid
     if ($action == 'accept_bid') {
         if (!isset($_REQUEST['bid_id']) || !isset($_REQUEST['budget_id'])) {
             $_SESSION['workitem_error'] = "Missing parameter to accept a bid!";
         } else {
             $bid_id = intval($_REQUEST['bid_id']);
             $budget_id = intval($_REQUEST['budget_id']);
             $budget = new Budget();
             if (!$budget->loadById($budget_id)) {
                 $_SESSION['workitem_error'] = "Invalid budget!";
             }
             $is_job_runner = $workitem->getRunnerId() == Session::uid();
             $is_assigned = $workitem->getAssigned_id() == Session::uid();
             // only runners can accept bids
             if ($is_project_runner || $is_job_runner || $is_assigned || $user->getIs_admin() == 1 && $is_runner && !$workitem->hasAcceptedBids() && $workitem->getStatus() == "Bidding") {
                 // query to get a list of bids (to use the current class rather than breaking uniformity)
                 // I could have done this quite easier with just 1 query and an if statement..
                 $bids = (array) $workitem->getBids($workitem->getId());
                 $exists = false;
                 foreach ($bids as $array) {
                     if ($array['id'] == $bid_id) {
                         $exists = true;
                         $bid_amount = $array["bid_amount"];
                         break;
                     }
                 }
                 if ($exists) {
                     $remainingFunds = $budget->getRemainingFunds();
                     if ($bid_amount <= $remainingFunds) {
                         $bid_info = $workitem->acceptBid($bid_id, $budget_id);
                         $budget->recalculateBudgetRemaining();
                         // Journal notification
                         $journal_message .= '@' . $_SESSION['nickname'] . " accepted {$bid_info['bid_amount']} from " . $bid_info['nickname'] . " on #" . $bid_info['worklist_id'] . " Status set to *In Progress*.";
                         $options = array('type' => 'bid_accepted', 'workitem' => $workitem, 'recipients' => array('mechanic', 'followers'));
                         // mail notification - including any data returned from acceptBid
                         Notification::workitemNotify($options, $bid_info);
                         $data = $bid_info;
                         $data['nick'] = $_SESSION['nickname'];
                         Notification::workitemNotifyHipchat($options, $data);
                         $bidder = new User();
                         $bidder->findUserById($bid_info['bidder_id']);
                         // Update Budget
                         $runner = new User();
                         $runner->findUserById($workitem->getRunnerId());
                         $runner->updateBudget(-$bid_amount, $workitem->getBudget_id());
                         // Send email to not accepted bidders
                         $this->sendMailToDiscardedBids($worklist_id);
                     } else {
                         $overBudget = money_format('%i', $bid_amount - $remainingFunds);
                         $_SESSION['workitem_error'] = "Failed to accept bid. Accepting this bid would make you " . $overBudget . " over your budget!";
                     }
                 } else {
                     $_SESSION['workitem_error'] = "Failed to accept bid, bid has been deleted!";
                 }
             } else {
                 if ($workitem->getIsRelRunner() || $workitem->getRunnerId() == $_SESSION['userid']) {
                     if ($workitem->hasAcceptedBids()) {
                         $_SESSION['workitem_error'] = "Failed to accept bid on task with an accepted bid!";
                     } else {
                         $_SESSION['workitem_error'] = "Accept Bid Failed, unknown task state!";
                     }
                 }
             }
         }
         $redirectToDefaultView = true;
     }
     // Accept Multiple  bid
     if ($action == 'accept_multiple_bid') {
         if (!isset($_REQUEST['budget_id'])) {
             $_SESSION['workitem_error'] = "Missing budget to accept a bid!";
         } else {
             $bid_id = $_REQUEST['chkMultipleBid'];
             $mechanic_id = $_REQUEST['mechanic'];
             $budget_id = intval($_REQUEST['budget_id']);
             $budget = new Budget();
             if (!$budget->loadById($budget_id)) {
                 $_SESSION['workitem_error'] = "Invalid budget!";
             }
             if (count($bid_id) > 0) {
                 //only runners can accept bids
                 if (($is_project_runner || $workitem->getRunnerId() == Session::uid() || $user->getIs_admin() == 1 && $is_runner) && !$workitem->hasAcceptedBids() && $workitem->getStatus() == "Bidding") {
                     $total = 0;
                     foreach ($bid_id as $bid) {
                         $currentBid = new Bid();
                         $currentBid->findBidById($bid);
                         $total = $total + $currentBid->getBid_amount();
                     }
                     $remainingFunds = $budget->getRemainingFunds();
                     if ($total <= $remainingFunds) {
                         foreach ($bid_id as $bid) {
                             $bids = (array) $workitem->getBids($workitem->getId());
                             $exists = false;
                             foreach ($bids as $array) {
                                 if ($array['id'] == $bid) {
                                     if ($array['bidder_id'] == $mechanic_id) {
                                         $is_mechanic = true;
                                     } else {
                                         $is_mechanic = false;
                                     }
                                     $exists = true;
                                     break;
                                 }
                             }
                             if ($exists) {
                                 $bid_info = $workitem->acceptBid($bid, $budget_id, $is_mechanic);
                                 // Journal notification
                                 $journal_message .= '@' . $_SESSION['nickname'] . " accepted {$bid_info['bid_amount']} from " . $bid_info['nickname'] . " " . ($is_mechanic ? ' as Developer ' : '') . "on #" . $bid_info['worklist_id'] . " Status set to *In Progress*.";
                                 // mail notification
                                 Notification::workitemNotify(array('type' => 'bid_accepted', 'workitem' => $workitem, 'recipients' => array('mechanic', 'followers')));
                             } else {
                                 $_SESSION['workitem_error'] = "Failed to accept bid, bid has been deleted!";
                             }
                         }
                         // Send email to not accepted bidders
                         $this->sendMailToDiscardedBids($worklist_id);
                         $runner = new User();
                         $runner->findUserById($workitem->getRunnerId());
                         $runner->updateBudget(-$total, $workitem->getBudget_id());
                     } else {
                         $overBudget = money_format('%i', $total - $remainingFunds);
                         $_SESSION['workitem_error'] = "Failed to accept bids. Accepting this bids would make you " . $overBudget . " over your budget!";
                     }
                 }
             }
         }
         $redirectToDefaultView = true;
     }
     //Withdraw a bid
     if ($action == "withdraw_bid") {
         if (isset($_REQUEST['bid_id'])) {
             $this->withdrawBid(intval($_REQUEST['bid_id']), $_REQUEST['withdraw_bid_reason']);
         } else {
             $fee_id = intval($_REQUEST['fee_id']);
             $res = mysql_query('SELECT f.bid_id, f.amount, w.runner_id FROM `' . FEES . '` AS f, ' . WORKLIST . ' AS w WHERE f.`id`=' . $fee_id . ' AND f.worklist_id = w.id');
             $fee = mysql_fetch_object($res);
             if ((int) $fee->bid_id !== 0) {
                 $this->withdrawBid($fee->bid_id, $_REQUEST['withdraw_bid_reason']);
             } else {
                 $this->deleteFee($fee_id);
             }
             // Update Runner's Budget
             $runner = new User();
             $runner->findUserById($fee->runner_id);
             $runner->updateBudget($fee->amount, $workitem->getBudget_id());
         }
         $redirectToDefaultView = true;
     }
     //Decline a bid
     if ($action == "decline_bid") {
         if (isset($_REQUEST['bid_id'])) {
             $this->withdrawBid(intval($_REQUEST['bid_id']), $_REQUEST['decline_bid_reason']);
         } else {
             $fee_id = intval($_REQUEST['fee_id']);
             $res = mysql_query('SELECT f.bid_id, f.amount, w.runner_id FROM `' . FEES . '` AS f, ' . WORKLIST . ' AS w WHERE f.`id`=' . $fee_id . ' AND f.worklist_id = w.id');
             $fee = mysql_fetch_object($res);
             if ((int) $fee->bid_id !== 0) {
                 $this->withdrawBid($fee->bid_id, $_REQUEST['decline_bid_reason']);
             } else {
                 $this->deleteFee($fee_id);
             }
             // Update Runner's Budget
             $runner = new User();
             $runner->findUserById($fee->runner_id);
             $runner->updateBudget($fee->amount, $workitem->getBudget_id());
         }
         $redirectToDefaultView = true;
     }
     // we have a Journal message, send it to Journal - except for DRAFTS
     if (isset($journal_message) && $workitem->getStatus() != 'Draft') {
         Utils::systemNotification($journal_message);
         //$postProcessUrl = WORKITEM_URL . $worklist_id . "?msg=" . $journal_message;
     }
     if ($redirectToDefaultView) {
         $this->redirect('./' . $worklist_id);
     }
     // handle the makeshift error I made..
     $erroneous = false;
     if (isset($_SESSION['workitem_error'])) {
         $erroneous = true;
         $the_errors = $_SESSION['workitem_error'];
         unset($_SESSION['workitem_error']);
         $this->write('erroneous', $erroneous);
         $this->write('the_errors', $the_errors);
     }
     // Process the request normally and display the page.
     //get workitem from db
     $worklist = $workitem->getWorkItem($worklist_id);
     $this->write('worklist', $worklist);
     //get bids
     $bids = $workitem->getBids($worklist_id);
     // get only those bids that have not expired, used to determine whether
     // runner can edit the job notes
     $this->write('activeBids', (array) $workitem->getBids($workitem->getId(), false));
     //Findout if the current user already has any bids.
     // Yes, it's a String instead of boolean to make it easy to use in JS.
     // Suppress names if not is_runner, or creator of Item. Still show if it's user's bid.
     $currentUserHasBid = "false";
     if (!empty($bids) && is_array($bids)) {
         foreach ($bids as &$bid) {
             if ($bid['email'] == $currentUsername) {
                 $currentUserHasBid = "true";
                 //break;
             }
             if (!($user->getId() == $bid['bidder_id'] || $user->isRunnerOfWorkitem($workitem) || $workitem->getIsRelRunner() && !$worklist['runner_id'])) {
                 if ($user->getIs_admin() == 0) {
                     $bid['nickname'] = '*name hidden*';
                     $bid['bid_amount'] = '***';
                     $bid['email'] = '********';
                     $bid['notes'] = '********';
                 }
             }
             $bid['bid_created'] = $this->convertTimezone($bid['unix_bid_created']);
             if ($bid['unix_bid_accepted'] > 0) {
                 $bid['bid_accepted'] = $this->convertTimezone($bid['unix_bid_accepted']);
             } else {
                 $bid['bid_accepted'] = '';
             }
             if ($bid['unix_done_full'] > 0 && !empty($bid['unix_done_full'])) {
                 $bid['unix_done_full'] = $this->convertTimezone($bid['unix_done_full']);
             } else {
                 $bid['unix_done_full'] = '';
             }
             // calculate Total Time to Complete
             if (isset($bid['unix_done_by']) && $bid['unix_done_by'] != 0) {
                 $timeToComplete = (int) $bid['unix_done_by'] - (int) $bid['unix_bid_created'];
                 if ($bid['unix_bid_accepted'] > 0) {
                     $timeElapsed = (int) $bid['unix_now'] - (int) $bid['unix_bid_accepted'];
                     $timeToComplete -= $timeElapsed;
                 }
                 $fullDays = floor($timeToComplete / (60 * 60 * 24));
                 $fullHours = floor(($timeToComplete - $fullDays * 60 * 60 * 24) / (60 * 60));
                 $fullMinutes = floor(($timeToComplete - $fullDays * 60 * 60 * 24 - $fullHours * 60 * 60) / 60);
                 $bid['time_to_complete'] = $fullDays . ($fullDays == 1 ? " day, " : " days, ") . $fullHours . ($fullHours == 1 ? " hour and " : " hours and ") . $fullMinutes . ($fullMinutes == 1 ? " minute." : " minutes.");
             } else {
                 $bid['time_to_complete'] = null;
             }
         }
     }
     // break reference to $bid
     unset($bid);
     //get fees
     $fees = $workitem->getFees($worklist_id);
     $this->write('fees', $fees);
     $user_id = isset($_SESSION['userid']) ? $_SESSION['userid'] : "";
     $is_runner = isset($_SESSION['is_runner']) ? $_SESSION['is_runner'] : 0;
     $is_admin = isset($_SESSION['is_admin']) ? $_SESSION['is_admin'] : 0;
     $is_payer = isset($_SESSION['is_payer']) ? $_SESSION['is_payer'] : 0;
     $creator_id = isset($worklist['creator_id']) ? $worklist['creator_id'] : 0;
     $mechanic_id = isset($worklist['mechanic_id']) ? $worklist['mechanic_id'] : 0;
     $runner_id = isset($worklist['runner_id']) ? $worklist['runner_id'] : 0;
     $status_error = '';
     $has_budget = 0;
     if (!empty($user_id)) {
         $user = new User();
         $user->findUserById($user_id);
         if ($user->getBudget() > 0) {
             $has_budget = 1;
         }
         // fee defaults to 0 for internal users
         $crFee = 0;
         if (!$user->isInternal()) {
             // otherwise, lookup reviewer fee on the Project
             $crFee = $this->getCRFee($workitem);
         }
         $this->write('crFee', $crFee);
     }
     $workitem = WorkItem::getById($worklist['id']);
     if ($worklist['project_id']) {
         $workitem_project = new Project($worklist['project_id']);
     }
     $projects = Project::getProjects();
     $allowEdit = false;
     $classEditable = "";
     if ($workitem->getIsRelRunner() && is_null($worklist['runner_id']) || $user->getIs_admin() == 1 && $is_runner || $creator_id == $user_id && $worklist['status'] == 'Suggestion' && is_null($worklist['runner_id']) || $runner_id == $user_id) {
         $allowEdit = true;
         if ($action != "edit") {
             $classEditable = " editable";
         }
     }
     $this->write('classEditable', $classEditable);
     $this->write('allowEdit', $allowEdit);
     $hideFees = false;
     if ($worklist['status'] == 'Bidding' || $worklist['status'] == 'Suggestion') {
         $hideFees = true;
     }
     $this->write('hideFees', $hideFees);
     $this->write('bids', $bids);
     $this->write('userHasCodeReviewRights', $this->hasCodeReviewRights($user_id, $workitem));
     $this->write('mechanic', $workitem->getUserDetails($worklist['mechanic_id']));
     $reviewer = new User();
     $reviewer->findUserById($workitem->getCReviewerId());
     $this->write('reviewer', $reviewer);
     $this->write('action_error', isset($action_error) ? $action_error : '');
     $this->write('comments', Comment::findCommentsForWorkitem($worklist['id']));
     $this->write('entries', $this->getTaskPosts($worklist['id']));
     $this->write('message', isset($message) ? $message : '');
     $this->write('currentUserHasBid', $currentUserHasBid);
     $this->write('has_budget', $has_budget);
     $this->write('promptForReviewUrl', $promptForReviewUrl);
     $this->write('status_error', $status_error);
     $this->write('{{userinfotoshow}}', isset($_REQUEST['userinfotoshow']) && isset($_SESSION['userid']) ? $_REQUEST['userinfotoshow'] : 0);
     $job_analytics = VisitQueryTools::visitQuery($worklist_id);
     $this->write('viewCount', $job_analytics['views']);
     $job_views = $job_analytics['views'] > 1 ? " views" : " view";
     $this->write('views', $job_views);
     parent::run();
 }
Пример #14
0
 public function makeBid(Bid $bid)
 {
     $lastBid = $this->getLastBid();
     if ($lastBid && $lastBid->getPrice() > $bid->getPrice()) {
         return false;
     }
     $this->bids[] = $bid;
 }
Пример #15
0
<?php

session_start();
if (empty($_SESSION['auth_id'])) {
    //'请先登入会员账号'
    $ret['status'] = 1;
    echo json_encode($ret);
    exit;
} else {
    include_once '/var/www/html/site/lib/config.php';
    include_once LIB_DIR . "/helpers.php";
    include_once LIB_DIR . "/router.php";
    include_once LIB_DIR . "/dbconnect.php";
    include_once LIB_DIR . "/ini.php";
    //$app = new AppIni;
    $c = new Bid();
    $c->home();
}
class Bid
{
    public $userid = '';
    //下标结账
    public function home()
    {
        global $db, $config, $router;
        // 初始化資料庫連結介面
        $db = new mysql($config["db"]);
        $db->connect();
        $router = new Router();
        $this->userid = empty($_SESSION['auth_id']) ? '' : $_SESSION['auth_id'];
        $ret['status'] = 0;
 public function deleteBid($bidId)
 {
     Bid::where('bid_id', '=', $bidId)->delete();
     return Redirect::to('mytransaction');
 }
Пример #17
0
if (isset($_POST['yes'])) {
    $tm = current_time('timestamp', 0);
    //		$mark_seller_accepted = get_post_meta($pid, 'mark_seller_accepted', true);
    $mark_seller_accepted = Bid::get_field_by_id($bid->id, 'mark_seller_accepted', true);
    if (empty($mark_seller_accepted)) {
        //			update_post_meta($pid, 'mark_seller_accepted',		"1");
        Bid::update_meta_by_id($bid->id, 'mark_seller_accepted', "1");
        Bid::update_meta_by_id($bid->id, 'mark_seller_accepted_date', $tm);
        /////my_edits
        //			update_post_meta($pid, 'closed',		"1");
        ////
        //			update_post_meta($pid, 'mark_seller_accepted_date',		$tm);
        //			update_post_meta($pid, 'outstanding',	"0");
        //			update_post_meta($pid, 'delivered',		"1");
        Bid::update_meta_by_id($bid->id, 'outstanding', "0");
        Bid::update_meta_by_id($bid->id, 'delivered', "1");
        //update postmeta project
        Project::update_postmeta($pid, 'mark_seller_accepted');
        Project::update_postmeta($pid, 'outstanding');
        Project::update_postmeta($pid, 'delivered');
        //------------------------------------------------------------------------------
        $projectTheme_get_winner_bid = projectTheme_get_winner_bid($pid);
        ProjectTheme_send_email_on_completed_project_to_bidder($pid, $projectTheme_get_winner_bid->uid);
        ProjectTheme_send_email_on_completed_project_to_owner($pid);
    }
    wp_redirect(get_permalink(get_option('ProjectTheme_my_account_outstanding_payments_id')));
    exit;
}
if (isset($_POST['no'])) {
    wp_redirect(get_permalink(get_option('ProjectTheme_my_account_awaiting_completion_id')));
    exit;
Пример #18
0
 public function current_bid_draft_from($vendor)
 {
     $bid = Bid::where('project_id', '=', $this->id)->where('vendor_id', '=', $vendor->id)->where_null('submitted_at')->first();
     return $bid ? $bid : false;
 }
Пример #19
0
Файл: bids.php Проект: ajb/rfpez
 public function action_mine()
 {
     $view = View::make('bids.mine');
     $view->bids = Bid::where_vendor_id(Auth::vendor()->id)->get();
     $this->layout->content = $view;
 }
Пример #20
0
    $wpdb->query($query);
    ProjectTheme_send_email_on_win_to_bidder($pid, $uid);
    ProjectTheme_send_email_on_win_to_owner($pid, $uid);
    // global $wpdb;
    // $s = "select distinct uid from ".$wpdb->prefix."project_bids where uid!='$uid' and pid='$pid'";
    // $r = $wpdb->get_results($s);
    // foreach($r as $row)
    // {
    // 	$looser = $row->uid;
    // 	ProjectTheme_send_email_on_win_to_loser($pid, $looser);
    // }
    //----------
    //update_post_meta($pid, 'winner', $uid);
    $query = "insert into wp_postmeta (post_id, meta_key, meta_value) values ({$pid}, 'winner', {$uid});";
    $wpdb->query($query);
    Bid::update_meta_by_id($bid->id, 'paid', "0");
    update_post_meta($pid, 'paid_user', "0");
    //}
    do_action('ProjectTheme_choose_winner', $pid);
    $projectTheme_enable_paypal_ad = get_option('projectTheme_enable_paypal_ad');
    if ($projectTheme_enable_paypal_ad == "yes") {
        wp_redirect(get_permalink(get_option('ProjectTheme_my_account_awaiting_completion_id')));
        exit;
    }
    //wp_redirect(get_permalink(get_option('ProjectTheme_my_account_page_id')));
    wp_redirect(get_permalink($pid));
    //get_permalink(get_option('ProjectTheme_my_account_page_id')));
    exit;
}
if (isset($_POST['no'])) {
    wp_redirect(get_permalink($pid));
Пример #21
0
Файл: bid.php Проект: ajb/rfpez
 public static function dismissal_reasons()
 {
     if (self::$dismissal_reasons !== false) {
         return self::$dismissal_reasons;
     }
     $raw_popular_reasons = DB::query("SELECT count(dismissal_reason) AS count, dismissal_reason\n                                  FROM bids\n                                  GROUP BY dismissal_reason\n                                  HAVING count(dismissal_reason) > 2");
     $reasons = array_map(function ($raw_popular_reason) {
         return $raw_popular_reason->dismissal_reason;
     }, $raw_popular_reasons);
     $returnArray = array_merge(self::$default_dismissal_reasons, $reasons);
     sort($returnArray);
     return self::$dismissal_reasons = $returnArray;
 }
Пример #22
0
    wp_redirect(get_bloginfo('siteurl'));
    exit;
}
//if($uid != $winner_bd->uid) { wp_redirect(get_bloginfo('siteurl')); exit; }
//---------------------------
if (isset($_POST['yes'])) {
    $tm = current_time('timestamp', 0);
    //		$mark_coder_delivered = get_post_meta($pid, 'mark_coder_delivered', true);
    $mark_coder_delivered = Bid::get_field_by_id($bid->id, 'mark_coder_delivered', $single = true);
    //		if(empty($mark_coder_delivered)) {
    if (empty($mark_coder_delivered) || $mark_coder_delivered != 1) {
        //			update_post_meta($pid, 'mark_coder_delivered', "1");
        //			update_post_meta($pid, 'mark_coder_delivered_date',	$tm);
        Bid::update_meta_by_id($bid->id, 'mark_coder_delivered', "1");
        //            Bid::update_meta_by_id($bid->id, 'delivered',	"1");
        Bid::update_meta_by_id($bid->id, 'mark_coder_delivered_date', $tm);
        ProjectTheme_send_email_on_delivered_project_to_bidder($pid, $uid);
        ProjectTheme_send_email_on_delivered_project_to_owner($pid);
        //update postmeta `mark_coder_delivered` (for project)
        Project::update_postmeta($pid, 'mark_coder_delivered');
    }
    wp_redirect(get_permalink(get_option('ProjectTheme_my_account_outstanding_projects_id')));
    exit;
}
if (isset($_POST['no'])) {
    wp_redirect(get_permalink(get_option('ProjectTheme_my_account_outstanding_projects_id')));
    exit;
}
//---------------------------------
get_header();
?>
Пример #23
0
function projectTheme_template_redirect()
{
    global $wp;
    global $wp_query, $post, $wp_rewrite;
    if (isset($_GET['_ad_delete_pid'])) {
        if (is_user_logged_in()) {
            $pid = $_GET['_ad_delete_pid'];
            $pstpst = get_post($pid);
            global $current_user;
            get_currentuserinfo();
            if ($pstpst->post_author == $current_user->ID or current_user_can('manage_options')) {
                wp_delete_post($_GET['_ad_delete_pid']);
                echo "done";
            }
        }
        exit;
    }
    if (isset($_GET['my_upload_of_project_files'])) {
        get_template_part('lib/upload_main/uploady2');
        die;
    }
    if (isset($_GET['my_upload_of_project_files_proj'])) {
        get_template_part('lib/upload_main/uploady5');
        die;
    }
    if (isset($_GET['my_upload_of_project_files2'])) {
        get_template_part('lib/upload_main/uploady');
        die;
    }
    if (isset($_GET['alert_ipn'])) {
        projectTheme_alert_pay_IPN();
        die;
    }
    if (isset($_GET['my_upload_of_project_files8'])) {
        get_template_part('lib/upload_main/uploady8');
        die;
    }
    if (isset($_GET['complete_paypal_escrow'])) {
        get_template_part('lib/gateways/complete_paypal_escrow');
        die;
    }
    if (isset($_GET['get_subcats_for_me'])) {
        $cat_id = $_POST['queryString'];
        if (empty($cat_id)) {
            echo " ";
        } else {
            $args2 = "orderby=name&order=ASC&hide_empty=0&parent=" . $cat_id;
            $sub_terms2 = get_terms('project_cat', $args2);
            if (count($sub_terms2) > 0) {
                $ret = '<select class="do_input_new" name="subcat">';
                $ret .= '<option value="">' . __('Select Subcategory', 'ProjectTheme') . '</option>';
                foreach ($sub_terms2 as $sub_term2) {
                    $sub_id2 = $sub_term2->term_id;
                    $ret .= '<option ' . ($selected == $sub_id2 ? "selected='selected'" : " ") . ' value="' . $sub_id2 . '">' . $sub_term2->name . '</option>';
                }
                $ret .= "</select>";
                echo $ret;
            }
        }
        die;
    }
    if (isset($_GET['get_locscats_for_me'])) {
        $cat_id = $_POST['queryString'];
        if (empty($cat_id)) {
            echo " ";
        } else {
            $args2 = "orderby=name&order=ASC&hide_empty=0&parent=" . $cat_id;
            $sub_terms2 = get_terms('project_location', $args2);
            if (count($sub_terms2) > 0) {
                $ret = '<select class="do_input_new" name="subloc" onchange="display_subcat3(this.value)">';
                $ret .= '<option value="">' . __('Select Sublocation', 'ProjectTheme') . '</option>';
                foreach ($sub_terms2 as $sub_term2) {
                    $sub_id2 = $sub_term2->term_id;
                    $ret .= '<option ' . ($selected == $sub_id2 ? "selected='selected'" : " ") . ' value="' . $sub_id2 . '">' . $sub_term2->name . '</option>';
                }
                $ret .= "</select>";
                echo $ret;
            }
        }
        die;
    }
    if (isset($_GET['set_image_for_term'])) {
        if (is_user_logged_in()) {
            $term_id = $_GET['term_id'];
            $attachment_id = $_GET['attachment_id'];
            update_post_meta($attachment_id, 'category_image', $term_id);
        }
        die;
    }
    //---------------------------
    if (isset($_GET['get_locscats_for_me2'])) {
        $cat_id = $_POST['queryString'];
        if (empty($cat_id)) {
            echo " ";
        } else {
            $args2 = "orderby=name&order=ASC&hide_empty=0&parent=" . $cat_id;
            $sub_terms2 = get_terms('project_location', $args2);
            if (count($sub_terms2) > 0) {
                $ret = '<select class="do_input_new" name="subloc2" >';
                $ret .= '<option value="">' . __('Select Sublocation', 'ProjectTheme') . '</option>';
                foreach ($sub_terms2 as $sub_term2) {
                    $sub_id2 = $sub_term2->term_id;
                    $ret .= '<option ' . ($selected == $sub_id2 ? "selected='selected'" : " ") . ' value="' . $sub_id2 . '">' . $sub_term2->name . '</option>';
                }
                $ret .= "</select>";
                echo $ret;
            }
        }
        die;
    }
    //---------------------------------------------------
    if (isset($_GET['redirect_search'])) {
        if ($_POST['redirect_search'] == "freelancers") {
            $_SESSION['tt_ss'] = 'freelancers';
            $string = "username="******"?" . $string);
            } else {
                wp_redirect($ProjectTheme_provider_search_page_id . "&" . $string);
            }
        } else {
            $_SESSION['tt_ss'] = 'projects';
            $string = "term=" . urlencode($_POST['input_text_serch']);
            $ProjectTheme_advanced_search_page_id = get_permalink(get_option('ProjectTheme_advanced_search_page_id'));
            $perm = ProjectTheme_using_permalinks();
            if ($perm == true) {
                wp_redirect($ProjectTheme_advanced_search_page_id . "?" . $string);
            } else {
                wp_redirect($ProjectTheme_advanced_search_page_id . "&" . $string);
            }
        }
        exit;
    }
    if (isset($_GET['get_my_project_vl_thing'])) {
        $pids = $_POST['queryString'];
        if ($pids == 0) {
            echo 0;
            die;
        }
        $ar = 1;
        $bids = Bid::get_by_pid_uid($pids, $uid = '', $single = false, $filters = array("winner='1'", "paid='0'", "outstanding='0'", "delivered='1'"));
        echo '<select name="uids" onchange="on_winner_sel();" required="">';
        foreach ($bids as $key => $bid) {
            $escrow = Escrow::get_by_field('bid', $bid->id);
            if (!isset($escrow)) {
                $user = get_userdata($bid->uid);
                echo '<option value="' . $bid->uid . '" bid="' . $bid->id . '">' . $user->user_login . '</option>';
            }
        }
        echo "</select>";
        //echo $bid->bid;
        die;
    }
    $my_pid = $post->ID;
    $parent = $post->post_parent;
    $paagee = $wp_query->query_vars['my_custom_page_type'];
    $p_action = $wp_query->query_vars['p_action'];
    $ProjectTheme_my_account_page_id = get_option('ProjectTheme_my_account_page_id');
    $ProjectTheme_post_new_page_id = get_option('ProjectTheme_post_new_page_id');
    $ProjectTheme_my_account_page_id = get_option('ProjectTheme_my_account_page_id');
    //-------------
    if (isset($_GET['redir1'])) {
        $_SESSION['redir1'] = $_GET['redir1'];
    }
    if (($parent == $ProjectTheme_my_account_page_id or $my_pid == get_option('ProjectTheme_my_account_milestones_id')) and !empty($my_pid)) {
        if (!is_user_logged_in()) {
            wp_redirect(ProjectTheme_login_url());
            exit;
        }
    }
    //-------------
    $ProjectTheme_enable_2_user_tp = get_option('ProjectTheme_enable_2_user_tp');
    if ($ProjectTheme_enable_2_user_tp == "yes" && $p_action != 'choose_user_tp') {
        if (is_user_logged_in()) {
            global $current_user;
            get_currentuserinfo();
            $user_tp = get_user_meta($current_user->ID, 'user_tp', true);
            if (empty($user_tp) && !current_user_can('level_10')) {
                wp_redirect(get_bloginfo('siteurl') . "/?p_action=choose_user_tp");
                exit;
            }
        }
    }
    if ($p_action == "payza_listing") {
        get_template_part('lib/gateways/payza_listing');
        die;
    }
    if (isset($_GET['notify_chained'])) {
        if ($_POST['status'] == "INCOMPLETE") {
            $trID = $_POST['tracking_id'];
            $trID = explode("_", $trID);
            $pid = $trID[0];
            update_post_meta($pid, 'outstanding', "1");
            //update_post_meta($pid, 'paid_user',"1");
            //update_post_meta($pid, "paid_user_date", current_time('timestamp',0));
            update_post_meta($pid, "adaptive_done", "started");
            $projectTheme_get_winner_bid = projectTheme_get_winner_bid($pid);
            ProjectTheme_send_email_on_escrow_project_to_bidder($pid, $projectTheme_get_winner_bid->uid, $_POST['amount']);
            ProjectTheme_send_email_on_escrow_project_to_owner($pid, $_POST['amount']);
            //$projectTheme_get_winner_bid = projectTheme_get_winner_bid($pid);
            //ProjectTheme_send_email_when_on_completed_project($pid, $projectTheme_get_winner_bid->uid, $projectTheme_get_winner_bid->bid);
        }
    }
    if (isset($_GET['return_chained'])) {
        $ret_id = $_GET['return_chained'];
        $pid_d = get_option('adaptive_payment_ID_thing_' . $ret_id);
        wp_redirect(get_permalink(get_option('ProjectTheme_my_account_awaiting_completion_id')));
        exit;
    }
    //------------
    if ($my_pid == $ProjectTheme_post_new_page_id) {
        if (!is_user_logged_in()) {
            wp_redirect(ProjectTheme_login_url() . '?redirect_to=' . urlencode(get_permalink($ProjectTheme_post_new_page_id)));
            exit;
        }
        global $current_user;
        get_currentuserinfo();
        if (!ProjectTheme_is_user_business($current_user->ID)) {
            wp_redirect(get_bloginfo('siteurl') . '?contr_error=1');
            /*wp_redirect(get_bloginfo('siteurl'));*/
            exit;
        }
        if (!isset($_GET['projectid'])) {
            $set_ad = 1;
        } else {
            $set_ad = 0;
        }
        if (!empty($_GET['projectid'])) {
            $my_main_post = get_post($_GET['projectid']);
            if ($my_main_post->post_author != $current_user->ID) {
                wp_redirect(get_bloginfo('siteurl'));
                exit;
            }
        }
        if ($set_ad == 1) {
            $pid = ProjectTheme_get_auto_draft($current_user->ID);
            wp_redirect(ProjectTheme_post_new_with_pid_stuff_thg($pid));
        }
        get_template_part('lib/post_new_post');
    }
    //-------------
    if ($my_pid == $ProjectTheme_my_account_page_id) {
        if (!is_user_logged_in()) {
            wp_redirect(ProjectTheme_login_url());
            exit;
        }
    }
    //----------------------------------------------------
    if ($p_action == "choose_user_tp") {
        get_template_part('lib/choose_user_tp');
        die;
    }
    if (isset($_GET['autosuggest'])) {
        get_template_part('autosuggest');
    }
    if ($p_action == "mark_delivered") {
        get_template_part('lib/my_account/mark_delivered');
        die;
    }
    if ($p_action == "work_timer") {
        get_template_part('lib/my_account/work_timer');
        die;
    }
    if ($p_action == "mark_completed") {
        get_template_part('lib/my_account/mark_completed');
        die;
    }
    if ($p_action == "mark_in_progress") {
        get_template_part('lib/my_account/mark_in_progress');
        die;
    }
    if ($p_action == "credits_listing") {
        get_template_part('lib/gateways/credits_listing');
        die;
    }
    if ($p_action == "relist_this_done") {
        get_template_part('lib/my_account/relist_this_done');
        die;
    }
    if ($p_action == "mb_listing_response") {
        get_template_part('lib/gateways/moneybookers_listing_response');
        die;
    }
    if ($p_action == "mb_listing") {
        get_template_part('lib/gateways/moneybookers_listing');
        die;
    }
    if ($p_action == "paypal_listing") {
        get_template_part('lib/gateways/paypal_listing');
        die;
    }
    if ($p_action == "pay_for_project_paypal") {
        get_template_part('lib/gateways/pay_for_project_paypal');
        die;
    }
    if ($p_action == "edit_project") {
        get_template_part('lib/my_account/edit_project');
        die;
    }
    if ($p_action == "rate_user") {
        get_template_part('lib/my_account/rate_user');
        die;
    }
    if ($p_action == "choose_winner") {
        get_template_part('lib/choose_winner');
        die;
    }
    if ($p_action == "group_winner") {
        get_template_part('lib/group_winner');
        die;
    }
    if ($p_action == "remove_provider") {
        get_template_part('lib/remove_provider');
        die;
    }
    if ($p_action == "user_profile") {
        get_template_part('lib/user-profile');
        die;
    }
    if ($p_action == "user_feedback") {
        get_template_part('lib/user-feedback');
        die;
    }
    if ($p_action == "delete_project") {
        get_template_part('lib/my_account/delete_project');
        die;
    }
    if ($p_action == "close_project") {
        get_template_part('lib/my_account/close_project');
        die;
    }
    if ($p_action == "repost_project") {
        get_template_part('lib/my_account/repost_project');
        die;
    }
    if ($p_action == "paypal_deposit_pay") {
        get_template_part('lib/gateways/paypal_deposit_pay');
        die;
    }
    if ($p_action == "payza_deposit_pay") {
        get_template_part('lib/gateways/payza_deposit_pay');
        die;
    }
    if ($p_action == "mb_deposit_response") {
        get_template_part('lib/gateways/mb_deposit_response');
        die;
    }
    if ($p_action == "mb_deposit_pay") {
        get_template_part('lib/gateways/mb_deposit_pay');
        die;
    }
    if ($paagee == "pay_projects_by_credits") {
        get_template_part('lib/pay-projects-by-credits');
        die;
    }
    if ($paagee == "show-all-categories") {
        get_template_part('lib/show-all-categories');
        die;
    }
    if ($paagee == "show-all-locations") {
        get_template_part('lib/show-all-locations');
        die;
    }
    if ($paagee == "post-new") {
        get_template_part('post-new');
        die;
    }
    if ($paagee == "pay_paypal") {
        get_template_part('lib/gateways/paypal');
        die;
    }
    if ($paagee == "advanced_search") {
        get_template_part('lib/advanced-search');
        die;
    }
    if ($paagee == "alert-pay-return") {
        get_template_part('lib/gateways/alert-pay-return');
        die;
    }
    if (isset($_GET['get_files_panel'])) {
        get_template_part('lib/get_files_panel');
        die;
    }
    if (isset($_GET['get_bidding_panel'])) {
        get_template_part('lib/bidding-panel');
        die;
    }
    if (isset($_GET['get_message_board'])) {
        get_template_part('lib/message-board');
        die;
    }
    if ($paagee == "all-blog-posts") {
        get_template_part('lib/blog');
        die;
    }
    if ($paagee == "all_featured_projects") {
        get_template_part('lib/all_featured_projects');
        die;
    }
    if ($paagee == "user_feedback") {
        get_template_part('lib/user-feedback');
        die;
    }
    if ($paagee == "buy_now") {
        get_template_part('lib/buy-now');
        die;
    }
    if ($paagee == "pay-for-project") {
        get_template_part('lib/gateways/paypal-project');
        die;
    }
    if ($paagee == "deposit_pay") {
        get_template_part('lib/gateways/deposit-pay');
        die;
    }
}
Пример #24
0
    ?>
" class="nice_link"><?php 
    _e("Repost", 'ProjectTheme');
    ?>
</a> 
            
                               
                  <?php 
    /* Add close button if available (winners count = 0 OR paid_user = 1) */
    ?>

                  <?php 
    if ($post->post_author == $uid) {
        $pid = get_the_ID();
        $paid_user = get_post_meta($pid, 'paid_user', true);
        $winners = Bid::get_field_by_pid($pid, 'winner', $single = false, array('winner=1'));
        if (count($winners) == 0 || $paid_user == 1) {
            ?>
                           <a href="<?php 
            bloginfo('siteurl');
            ?>
/?p_action=close_project&pid=<?php 
            the_ID();
            ?>
" class="orange_btn3"><?php 
            echo __("Close Project", "ProjectTheme");
            ?>
</a>
                          <?php 
        }
    }