示例#1
0
function raisedbystudent($uid, &$tvc)
{
    $w1vendortotal = 0;
    $w2vendortotal = 0;
    $w3vendortotal = 0;
    $trk = dbGetObj("select * from tracking where user_id={$uid}");
    $pro = dbGetObj("select * from progress where user_id={$uid}");
    $wk = getfld("week", "users", "where id={$uid}");
    $errors = 0;
    $space = "    ";
    if ($wk > 1) {
        $w1vendorcost = $trk->w1cost;
        $w1vendortotal = 0;
        $w1multiplier = 0;
        if ($w1vendorcost > 0) {
            $w1vendor = $trk->w1vendor;
            $w1vendortotal = 25000;
            //Max amount a vendor can raise
            //determine how much of the max amount the vendor actually raised
            $vnum = getvnum(1, $w1vendor, $w1vendorcost);
            if ($vnum == 1) {
                $w1multiplier = 1.0;
            } else {
                if ($vnum == 2) {
                    $w1multiplier = 0.75;
                } else {
                    if ($vnum == 3) {
                        $w1multiplier = 0.5;
                    } else {
                        if ($vnum == 4) {
                            $w1multiplier = 0.25;
                        } else {
                            $errors++;
                            rerr("tsk1: student id={$uid} {$space} w1vendor=\"{$w1vendor}\" {$space} w1vendorcost={$w1vendorcost}");
                            $w1multiplier = 0.625;
                        }
                    }
                }
            }
            //Determine the adjusted vendortotal
            $w1vendortotal *= $w1multiplier;
            $w1vendortotal -= $w1vendorcost;
        }
        //Dock them for hiring an extra vendor
        if (substr($pro->w1nlc_utt, 0, 1) == "c") {
            $w1vendortotal -= 3000;
        }
    }
    if ($wk > 2) {
        $w2vendorcost = $trk->w2cost;
        $w2vendortotal = 0;
        $w2multiplier = 0;
        if ($w2vendorcost > 0) {
            $w2vendor = $trk->w2vendor;
            $w2vendortotal = 50000;
            //Max amount a vendor can raise
            $vnum = getvnum(2, $w2vendor, $w2vendorcost);
            if ($vnum == 1) {
                $w2multiplier = 1.0;
            } else {
                if ($vnum == 2) {
                    $w2multiplier = 0.75;
                } else {
                    if ($vnum == 3) {
                        $w2multiplier = 0.5;
                    } else {
                        if ($vnum == 4) {
                            $w2multiplier = 0.25;
                        } else {
                            $errors++;
                            rerr("tsk2: student id={$uid} {$space} w2vendor=\"{$w2vendor}\" {$space} w2vendorcost={$w2vendorcost}");
                            $w2multiplier = 0.625;
                        }
                    }
                }
            }
            //Determine the adjusted vendortotal
            $w2vendortotal *= $w2multiplier;
            $w2vendortotal -= $w2vendorcost;
        }
        //Dock them for getting insurance
        if (substr($pro->w2nlc_utt, 0, 1) == "c") {
            $w2vendortotal -= 1500;
        }
    }
    if ($wk > 3) {
        $w3vendorcost = $trk->w3cost;
        $w3vendortotal = -12500;
        $w3vendor = $trk->w3vendor;
        if (substr($w3vendor, 0, 7) == "Ramblin") {
            $w3vendor = substr($w3vendor, 0, 7);
        }
        //if($w3vendor != null)
        //p("$uid - w3vendor = $w3vendor");
        //else
        //p("w3vendor = null");
        if ($w3vendor != "" && $w3vendor != null) {
            $vnum = getvnum(3, $w3vendor, $w3vendorcost);
            // p("  vnum = $vnum");
            if ($vnum < 4) {
                $w3vendortotal = -8000;
                // Arrested wrong vendor
            } else {
                if ($vnum == 4) {
                    $w3vendortotal = 0;
                    // Arrested the correct vendor
                } else {
                    $errors++;
                    rerr("tsk3: student id={$uid} {$space} w3vendor=\"{$w3vendor}'\" {$space} w3vendorcost={$w3vendorcost}");
                }
            }
            //p("&emsp w3vendortotal = $w3vendortotal");
            //p("");
        }
        //Dock them for hiring an assistant
        if (substr($pro->w3nlc_utt, 0, 1) == "c") {
            $w3vendortotal -= 1500;
        }
        dbexec("update tracking set w3cost={$w3vendortotal} where user_id={$uid}");
    }
    // Test Calculation
    /*if(($w1vendortotal+$w2vendortotal+$w3vendortotal) > 0){
    		p("$uid - w1raised = $w1vendortotal - w2raised = $w2vendortotal - w3raised = $w3vendortotal");
    		p("Total = ".($w1vendortotal+$w2vendortotal+$w3vendortotal));
    		}*/
    // ===========================
    $raised = $w1vendortotal + $w2vendortotal + $w3vendortotal;
    dbExec("update tracking set raisedmoney={$raised}, errors={$errors} where user_id=" . $uid);
    setvar($uid, 'RAISED', $raised);
    dbExec("update results set raised={$raised} where uid={$uid}");
    $tvc = $w1vendorcost + $w2vendorcost;
    // xxx currently not used ?
    if ($w1vendor == "") {
        $w1vendor = "no one";
    }
    if ($w2vendor == "") {
        $w2vendor = "no one";
    }
    if ($w3vendor == "") {
        $w3vendor = "no one";
    }
    return $raised;
}
示例#2
0
			e = null;
		else
			e.style.display = "";
		last = e;
		//document.location = "#"+id;
	}



</script>

<?php 
$action = rt("action");
$group_id = rt("group_id");
if ($action == "weekadvance") {
    $o = dbGetObj("select * from groups where id={$group_id} and teacher_code={$teacher_code}");
    $cw = $o->week;
    $nw = $cw + 1;
    if ($nw > $config["week"]) {
        $nw = $config["week"];
    }
    dbg("group_id={$group_id} teacher_code={$teacher_code} cw={$cw} nw={$nw}");
    $sql = "update users\n\t\t\t\tset week={$nw}\n\t\t\t\twhere\n\t\t\t\t\tteacher_code={$teacher_code}\n\t\t\t\t\tand\n\t\t\t\t\tgroup_id={$group_id}\n\t\t\t\t";
    dbExec($sql);
    $sql = "update groups\n\t\t\t\tset week={$nw}\n\t\t\t\twhere\n\t\t\t\t\tteacher_code={$teacher_code}\n\t\t\t\t\tand\n\t\t\t\t\tid={$group_id}\n\t\t\t\t";
    dbExec($sql);
    jmp("?#team{$group_id}");
}
?>

<style>