function getSavingsDiffTestnames($bCss, $testname1, $testname2) { $query = "select testnameid from spritemetestnames where testname = '{$testname1}';"; $testnameid1 = doSimpleQuery($query); $query = "select testnameid from spritemetestnames where testname = '{$testname2}';"; $testnameid2 = doSimpleQuery($query); if (!testnameid1 || !$testnameid2) { return; } $query1 = "select createdate, url, id, sd from spritemesavings where testnameid={$testnameid1} group by url;"; $result1 = doQuery($query1); $sHtml = ""; if ($bCss) { $sHtml .= <<<OUTPUT <style> .savingstable TH { padding: 0; color: #333; backgmyround: #CCC; font-weight: bold; } .savingstable TD { padding: 2px 8px 2px 8px; color: #333; backgmyround: #FFF; } TD.surl { padding-right: 0; } TD.sreqs { text-align: right; padding-right: 16px; padding-left: 0; } TD.ssize { text-align: right; padding-right: 8px; } TH.ssize { padding-left: 8px; padding-right: 8px; } TD.avg { backgmyround: #FFF; font-weight: bold; text-decoration: none; border-bottom: 1px solid; } </style> OUTPUT; } $sHtml .= "<table class=savingstable border=0 cellspacing=0 cellpadding=0>\n" . "<tr> <th></th> <th></th> <th class=sreqs>requests<br>eliminated</th> <th class=ssize>bytes<br>saved</th> <th class=sreqs>requests<br>eliminated</th> <th class=ssize>bytes<br>saved</th> </tr>\n"; $cntr = 0; $totalImages1 = 0; $totalDelta1 = 0; $totalImages2 = 0; $totalDelta2 = 0; $sRows = ""; while ($row1 = mysql_fetch_assoc($result1)) { $url = $row1['url']; $id1 = $row1['id']; $sd1 = $row1['sd']; $query2 = "select createdate, url, id, sd from spritemesavings where testnameid={$testnameid2} and url='{$url}' limit 1;"; $result2 = doQuery($query2); $url2 = ""; $id2 = $sd2 = 0; while ($row2 = mysql_fetch_assoc($result2)) { $url2 = $row2['url']; // use this as a flag $id2 = $row2['id']; $sd2 = $row2['sd']; break; } mysql_free_result($result2); if ($url2) { $sRows .= "<tr>" . "<td class=sdate>" . date("H:i", $row1['createdate']) . "</td>" . "<td class=surl><a class=ahover href='" . $row1['url'] . "' target='_blank'>" . shortenUrl($url) . "</a></td>" . "<td class=sreqs>{$id1}</td>" . "<td class=ssize>" . myround($sd1 / 1000) . " K</td>" . "<td class=sreqs style='" . ($id2 > $id1 ? "color: #0A0" : ($id2 < $id1 ? "color: #C00" : "")) . "'>{$id2}</td>" . "<td class=ssize style='" . ($sd2 > $sd1 ? "color: #0A0" : ($sd2 < $sd1 ? "color: #C00" : "")) . "'>" . myround($sd2 / 1000) . " K</td>" . "</tr>\n"; $cntr++; $totalImages1 += $id1; $totalDelta1 += $sd1; $totalImages2 += $id2; $totalDelta2 += $sd2; } } mysql_free_result($result1); if ($cntr) { $sHtml .= "<tr>" . "<td class=avg></td>" . "<td class=avg style='text-align: right;'>AVERAGE SAVINGS</td>" . "<td class='sreqs avg'>" . intval($totalImages1 / $cntr + 0.5) . "</td>" . "<td class='ssize avg'>" . intval($totalDelta1 / ($cntr * 1000) + 0.5) . " K</td>" . "<td class='sreqs avg'>" . intval($totalImages2 / $cntr + 0.5) . "</td>" . "<td class='ssize avg'>" . intval($totalDelta2 / ($cntr * 1000) + 0.5) . " K</td>" . "</tr>\n" . $sRows . "<tr> <th></th> <th></th> <th class=sreqs>requests<br>eliminated</th> <th class=ssize>bytes<br>saved</th> <th class=sreqs>requests<br>eliminated</th> <th class=ssize>bytes<br>saved</th> </tr>\n"; } $sHtml .= "</table>\n"; return $sHtml; }
function wyswietlKilka(array $a) { echo "<form method='GET'><table class='ramka'>"; //Wyswietlanie loga echo "<tr><td></td>"; foreach ($a as $k) { $l = $k->logo; echo "<td colspan = '2'><img src='{$l}'/></td>"; } echo "</tr>"; wiersza("P³aci pracodawca<br/><b>(prawdziwe brutto)</b>", $a, 'pBrutto'); wierszWyniki("Koszty pracodawcy ZUS ", 'pracod', $a, 0); wiersza("Brutto", $a, 'brutto'); wierszWyniki("Sk³adki na ZUS i PIT ", 'pracow', $a, 1); wiersza("Netto", $a, 'netto', '', 'z³ ', rozwiniecie('netto')); echo "<tbody class='rozwiniecie' id='netto'>"; wierszp("umowa o pracê", "<input type='text' name='netto' value='{$a[0]->netto}'/> z³"); wierszp("inne umowy", "bêd± wkrótce :)"); //wierszp("widok", "<select name='widok'><option value='domyslny'>domy¶lny</option><option value='pelny'>pe³ny</option><option value='zwarty'>zwarty</option></select>"); wierszp("", "<input type='submit' value='zmieñ'/>"); echo "</tbody>"; wierszWyniki("", "dodatkowe", $a, 2); wierszPrzerwa(); //echo "<tbody class='naglowek'>"; wiersz2pA("Przyk³adowe wydatki:", "koszt", "w tym<br/>podatki", count($a)); //echo "</tbody>"; wierszLinia(); foreach ($a[0]->wydatki as $key => $wyd) { wiersz2wydatki($wyd->nazwa, $a, $key); } wiersz2a("Oszczêdno¶ci", $a, 'oszczednosci', 'oszczPod'); wierszLinia(); wiersz2a("RAZEM:", $a, 'wydatkiSuma', 'wydatkiPod'); wierszPrzerwa(); wiersza("<b>Prawdziwe netto</b>", $a, 'pNetto'); wiersza("Suma podatków, op³at, itp.", $a, 'sumaPodatkow'); wiersza(" procentowo", $a, 'procentPodatkow', '', '%'); // Wykresy echo "<tr><td></td>"; $i = 0; foreach ($a as $k) { $l = $k->logo; $i++; echo "<td colspan = '2'><div class='wykres' id='id{$i}'></div></td>"; $pr = myround($k->procentPodatkow); $gr = $k->grupyProcentowo; //$pr = myround($gr['Pañstwo']); if (isset($gr['Korporacje'])) { $pr1 = myround($gr['Korporacje']); } else { $pr1 = 0; } if (isset($gr['Zmarnowane'])) { $pr2 = myround($gr['Zmarnowane']); } else { $pr2 = 0; } if (isset($gr['Prywatny ubezpieczyciel'])) { $pr3 = myround($gr['Prywatny ubezpieczyciel']); } else { $pr3 = 0; } echo "<script> drawChart('id{$i}', {$pr}, {$pr1}, {$pr2}, {$pr3}); </script>"; //$parms = $k->getGoogleChartParams(); //$echo "<script> drawChart2('id$i', '$parms'); </script>"; } echo "</tr>"; wiersza0("Miesiêczny zysk", $a, 'zysk'); wiersza0("Za swoje wynagrodzenie kupisz", $a, 'ilePWiecej', '', '% wiêcej', '', 'o '); echo "</table></form>"; echo "<div class='komentarz' id='komentarz'></div>"; }
function obnizenie($funkcja, $procent, $procentDotyczy, &$kwota, $nazwa, $komentarz = '', $pelnaKwota) { global $indexObnizenie, $indexPodwyzszenie, $doWypisania, $noweKoszty; $tekst = ''; $za = ''; $k = $funkcja($kwota, $procent * $procentDotyczy / 10000, $tekst, $za); $r = $kwota - $k; $kw = round($kwota, 0); $kk = round($k, 0); $prC = 100 * (1 - $k / $kwota); $kwota = $k; $sumaPod = 1 - $kwota / $pelnaKwota; $sumaPod *= 100; $sumaPod = round($sumaPod, 1); $prC = round($prC, 1); $kom = "<h3>{$nazwa}</h3><p>{$komentarz}</p><p>"; $procent = round($procent, 1); if ($procent < 0) { $procent = -$procent; $k = -$k; $prC = -$prC; if ($indexPodwyzszenie < 2) { $doWypisania .= "<tr><th>podwy¿szenie cen</th><th>efektywny wzrost</th>"; $doWypisania .= "<th>kwota</th><th>Ca³kowity spadek</th>"; $doWypisania .= "</tr>"; } $indexPodwyzszenie++; $indexObnizenie++; $tekstZaw = '¦rednio bêdziemy mieæ koszty'; } else { if ($indexObnizenie < 2) { $doWypisania .= "<tr><th>obni¿enie cen</th><th>efektywny spadek</th>"; $doWypisania .= "<th>kwota</th><th>Ca³kowity spadek</th>"; $doWypisania .= "</tr>"; } $indexObnizenie++; $tekstZaw = '¦rednio mamy zawy¿one koszty o'; } if ($noweKoszty) { $tekstZaw = 'Poniesiemy koszty równe oko³o'; } $p = $procentDotyczy * $procent; $procentDotyczy = myround($procentDotyczy); if ($za == ' z³') { $procent = round($procent, 0); $prC = $p = round($p, 0); $kom .= "{$tekstZaw} {$procentDotyczy} razy {$procent} z³ czyli <b>{$p} z³</b>"; } else { if ($procentDotyczy > 99) { if (!$noweKoszty) { $kom .= "¦rednio kupowane przez nas produkty maj± "; } else { $kom .= "¦rednio kupowane przez nas produkty bêd± mieæ "; } } else { $kom .= "Oko³o <b>{$procentDotyczy}%</b> kupowanych przez nas produktów ma "; } $kom .= "zwiêkszon± cenê o <b>{$procent}{$za}</b>"; } $kom .= "</p><p>{$tekst}</p>"; $mouse = "onmouseover=\"pokarze('id{$indexObnizenie}')\""; $doWypisania .= "<tr><td {$mouse}>- {$nazwa}: </td><td {$mouse}>{$prC}{$za}</td>"; $doWypisania .= "<td {$mouse} class='kwota'><b>{$kk} z³</b></td><td {$mouse}>{$sumaPod}%</td>"; $doWypisania .= "<td style='visibility:hidden;position:absolute' id='id{$indexObnizenie}'>{$kom}</td></tr>"; return $sumaPod; }
function getGoogleChartParams() { $str = '[[\'Task\', \'Percentage\'],'; $sep = ''; $sum = 0; foreach ($this->grupyProcentowo as $key => $procent) { $sum += $procent; $p = myround($procent); $str .= "{$sep}['{$key}', {$p}]"; $sep = ','; } $sum = myround(100 - $sum); $str .= "{$sep}['Obywatel', {$sum}]"; $str .= ']'; return $str; }