public function __invoke() { $today = $this->getDateInThePast(0); $oneWeekAgo = $this->getDateInThePast(7); $twoWeeksAgo = $this->getDateInThePast(14); $threeWeeksAgo = $this->getDateInThePast(21); $service = $this->adwords->getService('AdGroupService'); $selector = new \Selector(); $selector->predicates = [new \Predicate('Status', 'EQUALS', 'ENABLED'), new \Predicate('CampaignStatus', 'EQUALS', 'ENABLED')]; $selector->orderBy = new \OrderBy('ctr', 'ASCENDING'); $selector->paging = new \Paging(0, \AdWordsConstants::RECOMMENDED_PAGE_SIZE); do { $page = $service->get($selector); if (is_array($page->entries)) { foreach ($page->entries as $adGroup) { // Let's look at the trend of the ad group's CTR. $statsThreeWeeksAgo = $this->getStatsFor($adGroup, $threeWeeksAgo, $twoWeeksAgo); $statsTwoWeeksAgo = $this->getStatsFor($adGroup, $twoWeeksAgo, $oneWeekAgo); $statsLastWeek = $this->getStatsFor($adGroup, $oneWeekAgo, $today); // Week over week, the ad group is declining - record that! if ($statsLastWeek->getCtr() < $statsTwoWeeksAgo->getCtr() && $statsTwoWeeksAgo->getCtr() < $statsThreeWeeksAgo->getCtr()) { reportRows . push([adGroup . getCampaign() . getName(), adGroup . getName(), statsLastWeek . getCtr() * 100, statsLastWeek . getCost(), statsTwoWeeksAgo . getCtr() * 100, statsTwoWeeksAgo . getCost(), statsThreeWeeksAgo . getCtr() * 100, statsThreeWeeksAgo . getCost()]); } } } $selector->paging->startIndex += $selector->paging->numberResults; } while (!is_null($page->entries)); }
function getMaxCallTime($from, $to) { $customer = getCustomerByPhone($from); include_tariff($customer['tariffid']); $call_cost = getCost($from, $to, $customer['tariffid']); return floor($customer['balance'] / $call_cost['costPerUnit']) * $call_cost['unitSize']; }
if (!isset($tariffs[$tariff_id])) { include_tariff($tariff_id); if (!isset($tariffs[$tariff_id])) { $error['errors'][] = array('line' => $i, 'line_content' => $f_line, 'error' => 'Can\'t find tariff ' . $tariff_id . ' in tariff files.'); continue; } } // set call type $call_type = parseCallType($cdr['call_type']); if ($call_type === NULL) { die('Call type is not correct. Please use incoming or outgoing.' . PHP_EOL); } // generate unix timestamp $call_start = mktime($cdr['call_start_hour'], $cdr['call_start_min'], $cdr['call_start_sec'], $cdr['call_start_month'], $cdr['call_start_day'], $cdr['call_start_year']); // no payments for incoming call else calculate cost for call $call_cost = getCost($cdr['caller'], $cdr['callee'], $tariff_id); switch ($call_type) { case CALL_INCOMING: $price = 0; break; case CALL_OUTGOING: $price = round(ceil($cdr['time_answer_to_end'] / $call_cost['unitSize']) * $call_cost['costPerUnit'], 5); break; } // insert cdr record to database $DB->Execute("INSERT INTO\n\t\t\t\t\t\t\t\t\t\t\t voip_cdr (caller, callee, call_start_time, time_start_to_end, time_answer_to_end, price, status, type, voipaccountid)\n\t\t\t\t\t\t\t\t\t\t VALUES\n\t\t\t\t\t\t\t\t\t\t\t (?, ?, ?, ?, ?, ?, ?, ?, ?);", array($cdr['caller'], $cdr['callee'], $call_start, $cdr['time_start_to_end'], $cdr['time_answer_to_end'], $price, strtolower($cdr['call_status']), $call_type, $customer_list[$cdr['caller']]['voipaccountid'])); } else { $error['errors'][] = array('line' => $i, 'line_content' => $f_line, 'error' => $cdr_error); continue; } }
<div> <header> <h1>Rental Confirmation</h1> </header> <div id="wrapper"> <?php echo getname(); echo '<br />'; echo '<br />'; echo "Contact Info: "; echo '<br />'; echo '<br />'; echo getEmail(); echo '<br />'; echo '<br />'; echo 'Your total cost: $'; echo getCost(); ?> </div> <footer id="footer"> <hr /> <p> the information included on this page may not be correct, it was created in CST336 © Joshua Smith 2015</p> <img class="image-with border" src="../../../img/csumb-logo.png" alt="csumb logo" /> </footer> </div> </body> </html>
$max_comps = tableSize("computer_accessories"); $max_cloth = tableSize("clothing"); $types = array("book", "electronics", "computer_accessories", "clothing"); $map = array("book" => "Books", "electronics" => "Electronics", "computer_accessories" => "Computer Accessories", "clothing" => "Clothing"); $sizes = array("book" => $max_books, "electronics" => $max_elecs, "computer_accessories" => $max_comps, "clothing" => $max_cloth); $max_quant = 5; // not get order number for ($order_no = 1; $order_no <= 1000; $order_no++) { echo "doing {$order_no} <br />"; //$time="SELECT FROM_UNIXTIME(RAND() * (1351708200 - 1230748200) + 1230748200)"; $customer = rand(1, $max_custs); $quant = rand(1, $max_quant); $cost = 0; for ($j = 0; $j < $quant; $j++) { $prod = $types[rand(0, 3)]; $prodid = rand(0, $sizes[$prod] - 1); $prod_quant = rand(1, 3); $prod_cost = getCost($prod, $prodid); $cost += $prod_quant * $prod_cost; $query = "INSERT INTO bill_details values ({$order_no}, \"" . $map[$prod] . "\",{$prodid},{$prod_quant},{$prod_cost})"; echo $query . "<br />"; $result = mysql_query($query, $pconnect); } $query = "INSERT INTO billing values ({$order_no}, {$customer},{$cost},FROM_UNIXTIME(RAND() * (1351708200 - 1230748200) + 1230748200))"; $result = mysql_query($query, $pconnect); } ?> <?php mysql_close($pconnect); //update billing,(select @i:=@i+1 as ind,billing.bill_date as dt1 from billing order by bill_date) as tbl1 set bill_date=tbl1.dt1 where ID=tbl1.ind ;
$x = $row[id]; $str = getBuildStat(increases, $x); if ($str != "none") { $amt = getPlanetStat($str, $sid, $pid); if ($str == "maxcivs") { $amt /= 50; } echo '<tr><td></td> <td><a href="./pedia.php?id=' . $x . '">' . getBuildStat(name, $x) . '</a></td> <td>' . $amt . '</td> <td><a href="javascript:confirmBuilding(' . $x . ');">X</a></td> <td>' . getBuildStat(landcost, $x, $sid, $pid) . '</td> <td>' . getCost(civs, $x, $sid, $pid) . '</td> <td>' . getCost(steel, $x, $sid, $pid) . '</td> <td>' . getCost(cylite, $x, $sid, $pid) . '</td> <td>' . getCost(plexi, $x, $sid, $pid) . '</td> <td>' . calcBuildTime($x, $sid, $pid) . '</td> <td><a href="./build.php?id=' . $pid . '&bid=' . $x . '">Build</a></td> </tr>'; } else { if (!galaxyControlled($sid, $pid)) { echo '<tr><td></td> <td><a href="./pedia.php?id=' . $x . '">' . getBuildStat(name, $x) . '</a></td> <td>-</td> <td>-</td> <td>' . getBuildStat(landcost, $x, $sid, $pid) . '</td> <td>' . getBuildStat(civscost, $x) . '</td> <td>' . getBuildStat(steelcost, $x) . '</td> <td>' . getBuildStat(cylitecost, $x) . '</td> <td>' . getBuildStat(plexicost, $x) . '</td> <td>' . getBuildStat(buildtime, $x) . '</td>
{ while ($playerHitPoints > 0 && $bossHitPoints > 0) { // Player hits boss $bossHitPoints -= max(1, $playerDamage - $bossArmor); if ($bossHitPoints <= 0) { return true; } // Boss hits player $playerHitPoints -= max(1, $bossDamage - $playerArmor); if ($playerHitPoints <= 0) { return false; } } } $minGold = false; $maxGold = false; $hitpoints = 100; foreach ($combinations as $combination) { $cost = getCost($combination); $damage = getDamage($combination); $armor = getArmor($combination); if (willPlayerWin($hitpoints, $damage, $armor, $bossHitPoints, $bossDamage, $bossArmor)) { if (!$minGold || $cost < $minGold) { $minGold = $cost; } } elseif (!$maxGold || $cost > $maxGold) { $maxGold = $cost; } } echo 'The least amount of gold is ' . $minGold . PHP_EOL; echo 'You can spend ' . $maxGold . ' gold and still lose' . PHP_EOL;
function canAfford($stat, $bid, $sid, $pid) { if (getCost($stat, $bid, $sid, $pid) > getPlanetStat($stat, $sid, $pid)) { return false; } return true; }
$create_date = date("Y-m-d H:i:s"); $row1 = $db->getrow("select * from transfer where transfer_no = {$transfer_no}"); $sql2 = "select * from transdetail where transfer_no = {$transfer_no}\r\n\t\t\t\t\t\tand trans_qty>0"; $result2 = $db->query($sql2); if ($result2) { while ($row2 = $db->fetch_array($result2)) { //echo $row['acc_no']; $acc_no = $row2['acc_no']; $po_date = $row2['po_date']; $trans_qty = $row2['trans_qty']; $stockIn_no = $row2['stockIn_no']; //$sql = "select * from stockin where retailShop_no = $retailShop_no ". // "and acc_no = '$acc_no' and po_date = '$po_date'"; if ($row2['IMEI'] == null) { //acc $sql5 = "insert into stockin(poDetail_no,staff_no,acc_no,retailShop_no,po_date,iprice,ava_bal,rec_qty,rec_date,transDetail_no)" . "values(" . getPoDetailNoByStockIn($stockIn_no) . ", {$userno}, {$acc_no}, {$retailShop_no},'{$po_date}'," . getCost(getPoDetailNoByStockIn($stockIn_no)) . ",{$trans_qty},{$trans_qty},'{$create_date}'," . $row2['transDetail_no'] . ")"; echo $sql5; } else { //phone echo 2; $sql5 = "UPDATE phone SET retailShop_no={$retailShop_no} WHERE IMEI='" . $row2['IMEI'] . "' "; } $db->query("UPDATE transfer\r\n\t\t\t\t\t\t\t\t\t\t\t\tSET transState_no = '2', confirmBy='{$userLoginId}', receiveDate='{$create_date}'\r\n\t\t\t\t\t\t\t\t\t\t\t\tWHERE transfer_no ={$transfer_no}"); $db->query($sql5); } } break; case 'getTransList': $retailShop_list = get_retailshop_list(); $transfer_state = array(1 => '未收貨', 2 => '已收貨', 3 => '無效'); $shopno = '';