public static function bonus($m_id = false) { SALE::pyramid($m_id); list($data) = self::$group; unset($data[0]); foreach ($data as $level => $cate) { $level_total = pow(2, $level); unset($member_count, $createdate); foreach ($cate as $sub_member) { $member_count[] = count($sub_member); # 取得會員創建時間 foreach ($sub_member as $memberRow) { $createdate[] = $memberRow["createdate"]; } } $member_total = array_sum($member_count); # 取得同階層總會員數 if ($level_total == $member_total) { $level_done[$level] = true; # 取得會員最晚創建時間 rsort($createdate); list($level_time[$level]) = $createdate; } } # 所有累計獎金 $bonus = self::bonus_count($level_done, $level_time); # 扣除已經發送獎金 $rsnum = CRUD::dataFetch('grant', array('m_id' => $m_id)); if (!empty($rsnum)) { foreach (CRUD::$data as $key => $row) { $granted_array[] = $row["granted"]; } $granted = array_sum($granted_array); return $bonus - $granted; } else { return $bonus; } }
?> </p> Quantity:<form method="post" class="form-inline"> <select name="quantity" class="form-control"> <option>1</option> <option>2</option> <option>3</option> <option>4</option> <option>5</option> </select> <button type="submit" name="purchase" class="btn btn-default" style="margin-left: 80px;">Purchase</button> </form> </div> <?php if (isset($_POST['purchase'])) { $sale = new SALE(); $stmt = $sale->runQuery("SELECT * FROM sale WHERE user_id=" . $userRow['user_id'] . " and ticket_id=" . $_GET['tid']); $stmt->execute(); $saleRow = $stmt->fetch(PDO::FETCH_OBJ); if ($saleRow) { $sale->update($userRow['user_id'], $_GET['tid'], $_POST['quantity']); echo "Updated: " . $ticketRow->name; } else { $sale->register($userRow['user_id'], $ticketRow->ticket_id, $_POST['quantity']); echo "Purchased: " . $ticketRow->name; } } } ?>
<label class="h5">Hi! : <?php print $userRow['user_name']; ?> </label> <hr /> <?php if (!isset($_GET['tid'])) { ?> <p class="h4">TicketInventory</p><hr /> <table class="table table-striped"> <tr><td>TicketID</td><td>IssuedDate</td><td>Quantity</td></tr> <?php $sale = new SALE(); $stmt = $sale->runQuery("SELECT * FROM sale WHERE user_id=:user_id"); $stmt->bindparam(":user_id", $user_id); $stmt->execute(); while ($saleRow = $stmt->fetch(PDO::FETCH_OBJ)) { ?> <tr><td><?php echo $saleRow->ticket_id; ?> </td><td><a href="?tid=<?php echo $saleRow->ticket_id; ?> "><?php echo $saleRow->date; ?> </a></td><td><?php
private static function granted() { VIEW::assignGlobal(array("VALUE_DATE_OPTION" => self::granted_timer_select($_POST['date']), "VALUE_M_ID_OPTION" => self::granted_member_select($_POST['m_id']))); if (!empty($_POST['m_id'])) { $sk['m_id'] = $_POST['m_id']; } if (!empty($_POST['date'])) { $sk['date'] = $_POST["date"]; } $rsnum = CRUD::dataFetch('grant', $sk, false, array($_POST["date"] => 'desc')); if (!empty($rsnum)) { $dataRow = CRUD::$data; VIEW::newBlock("TAG_GRANT_BLOCK"); foreach ($dataRow as $key => $row) { CRUD::dataFetch('member', array('m_id' => $row["m_id"])); list($m_row) = CRUD::$data; VIEW::newBlock("TAG_GRANT_LIST"); VIEW::assign(array("VALUE_NUMBER" => ++$i, "VALUE_ACCOUNT" => $m_row["account"], "VALUE_NAME" => $m_row["name"], "VALUE_LEVEL" => SALE::member_level($m_row), "VALUE_GRANTED" => $row["granted"])); } } else { VIEW::newBlock("TAG_NONE"); } }