Example #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;
}
Example #2
0
<?php

include_once "dbg.php";
include_once "db.php";
dbg("dbdb: {$dbdb}");
include_once "lib.php";
$dbg = true;
$sql = "select user_id from tracking\n\t\t\twhere \n\t\t\t\t(\n\t\t\t\t\t(w1cost > 0 and w1vendor = '')\n\t\t\t\t\tor\n\t\t\t\t\t(w2cost > 0 and w2vendor = '')\n\t\t\t\t\tor\n\t\t\t\t\t(w3cost > 0 and w3vendor = '')\n\t\t\t\t)\n\t\t\t\tand\n\t\t\t\t(\n\t\t\t\t\t(select count(id) from users where\n\t\t\t\t\t\tid = user_id\n\t\t\t\t\t\tand\n\t\t\t\t\t\tactive=1\n\t\t\t\t\t\tand\n\t\t\t\t\t\tuser_type='s'\n\t\t\t\t\t\tand\n\t\t\t\t\t\tmodified > '2008-02-18 00:00:00') > 0\n\t\t\t\t)\n\t\t\t";
$rs = dbExec($sql);
while (!$rs->EOF) {
    $o = $rs->FetchNextobj();
    $id = $o->id;
    if (getfld("count(id)", "users", "where active=1 and user_type='s'") > 0) {
        echo "{$id}\n";
    }
}
?>

Example #3
0
 $num++;
 if (trim($v) == "") {
     continue;
 }
 preg_match("|VALUES .([0-9]+),|", $v, $m);
 $id = $m[1];
 // 773176656E646F72203D2034
 // --31------------------34
 //echo "user_id=$id\n";
 $user = getuser($id);
 $trk = gettrk($id);
 $perc = "??";
 //(int)(($num * 100) / $tot);
 // 350,000
 $gid = $user->group_id;
 $rm = getfld("raisedmoney", "groups", "where id={$gid}");
 if ($rm > 350000) {
     $rm = $rm . " !!!!!";
 }
 //echo "-- $num: $perc% user_id=$id ".$user->first_name." ".$user->last_name." gid=$gid rm=$rm\n";
 foreach (array(1, 2, 3, 4) as $w) {
     $cost = "w" . $w . "cost";
     $vndr = "w" . $w . "vendor";
     if (($trk->{$cost} > 0 || $w == 4) && $trk->{$vndr} == '') {
         preg_match("|773({$w})76656e646f72203d203([0-4])|", $v, $m);
         $week = $m[1];
         if ($m[2] == 0 && $week != 4) {
             echo "-- ### VENDOR NUM FOR WEEK {$week} IS 0 ###\n";
         }
         $vendor = vendor_name($user->class, $m[2], $w);
         if ($m[2] != 0) {
Example #4
0
function uid4sid($sid)
{
    return getfld("u_id", "auth_users", "where sid=\"{$sid}\"");
}
Example #5
0
<?php 
$t = new Table("x");
$t->set("Num");
$t->set("School Code");
$t->set("User ID");
$t->set("Last");
$t->set("First");
$t->set("Teacher Code");
$t->set("Teacher Name");
$t->set("Teacher Email");
$t->nextrow();
$tcodes = array();
$num = 1;
foreach ($list as $o) {
    $tid = getfld("id", "users", "where teacher_code=" . $o->teacher_code . " and user_type='t'");
    $temail = getfld("email", "users", "where teacher_code=" . $o->teacher_code . " and user_type='t'");
    if (!isset($tcodes[$temail])) {
        $tcodes[$temail] = 1;
    }
    $t->set($num);
    $t->set($o->school_code);
    $t->set("<a href='a_support.php?user_id=" . $o->id . "'>" . $o->id . "</a>");
    $t->set("<a href='a_support.php?userqry=" . $o->last_name . "'>" . $o->last_name . "</a>");
    $t->set("<a href='a_support.php?userqry=" . $o->first_name . "'>" . $o->first_name . "</a>");
    $t->set($o->teacher_code);
    $t->set("<a href='a_support.php?user_id={$tid}'>" . teacher_name_given_code($o->teacher_code)) . "</a>";
    $t->set("<a href='mailto:{$temail}'>{$temail}</a>");
    $t->nextrow();
    $num++;
}
$t->dump();
Example #6
0
		margin-bottom: 100px;
	}
</style>




<div id=cntnt>

<?php 
if ($email == "") {
    $email = rt("email");
}
$brd = rt("brd");
if ($email != "") {
    $c = getfld("count(id)", "users", "where\n\t\tactive=1\n\t\tand\n\t\tuser_type='t'\n\t\tand\n\t\t(email='{$email}' or email2='{$email}' or emailit='{$email}')\n\t\t");
    dbg("c={$c}");
    if ($c == 0) {
        // xxx notify no such email?
        $email = "";
    }
}
/*
if($email == "")
{
	?>
	<strong class="heading_copy">Virtual Team Challenge Message Boards</strong>

	<p>
	When a teacher registers with the system, he or she enters
	an email address for themselves as well as their IT Department.