function Generate($level) { $type = rand(2, 5); // number of candle types $mult = rand(2, 4); // number of each type $candles = $type * $mult; // total number of candles $days = $type; // number of pulls $colors = ['piros', 'sárga', 'kék', 'zöld', 'lila']; shuffle($colors); // // Original exercise // $type = 3; // $mult = 2; // $colors = ['piros', 'lila', 'narancssárga']; // $candles = $type*$mult; // $days = $type; $question = 'Zsófi a gyertyák öntéséhez ' . NumText($type) . ' különböző fajta „varázskanócot” használ. Mindegyik fajta „varázskanóc” fehér színű, de meggyújtáskor (a benne lévő anyagtól függően) az egyik fajta ' . $colors[0] . ', a másik ' . $colors[1] . ($type >= 3 ? ', a harmadik ' . $colors[2] : '') . ($type >= 4 ? ', a negyedik ' . $colors[3] : '') . ($type >= 5 ? ', az ötödik ' . $colors[4] : '') . ' lánggal ég. Zsófi hétfőn egy dobozba tesz $' . $candles . '$ darab gyertyát, mind ' . The($type) . ' ' . NumText($type) . ' fajtából ' . NumText($mult) . '-' . NumText($mult) . ' darabot. Keddtől kezdve minden nap véletlenszerűen kivesz egy gyertyát a dobozból, és meggyújtja. Számítsa ki annak a valószínűségét, hogy Zsófi az első ' . NumText($days) . ' nap ' . NumText($days) . ' különböző színű lánggal égő gyertyát gyújt meg!'; $total_options = range($candles, $candles - $days + 1); $total = fact($candles, $candles - $days + 1); $choices = array_fill(0, $days, $mult); $good = fact($type) * pow($mult, $days); $page[] = '(Ha az azonos színű lánggal égőket megkülönböztetjük egymástól, akkor) Zsófi összesen $' . implode('\\cdot', $total_options) . '=' . round2($total) . '$-féleképpen választhatja ki az első ' . NumText($days) . ' gyertyát. Ez lesz az <span class="label label-info">összes</span> esetek száma.'; $page[] = 'A ' . NumText($type) . 'féle szín sorrendje $' . $type . '!=' . fact($type) . '$-féle lehet.'; $page[] = 'Egy adott színsorrend esetén $' . implode('\\cdot', $choices) . '=' . pow($mult, $days) . '$ választási lehetőség van.'; $page[] = 'Ezért a <span class="label label-info">kedvező</span> esetek száma $' . fact($type) . '\\cdot' . pow($mult, $days) . '=' . round2($good) . '$.'; $page[] = 'A keresett valószínűség a kedvező és összes esetek hányadosa, azaz <span class="label label-success">$\\frac{' . round2($good) . '}{' . round2($total) . '}$</span>.'; $hints[] = $page; $correct = [$good, $total]; $solution = '$\\frac{' . $good . '}{' . $total . '}$'; return array('question' => $question, 'correct' => $correct, 'solution' => $solution, 'hints' => $hints, 'type' => 'fraction'); }
function Generate($level) { if ($level <= 3) { $base = rand(2, 3); $result = rand(5, 10); } elseif ($level <= 6) { $base = rand(4, 5); $result = rand(10, 15); } else { $base = rand(6, 7); $result = rand(15, 20); } // // Original exercise // $base = 2; // $result = 10; $question = 'Oldja meg a következő egyenletet a valós számok halmazán! Válaszát három tizedesjegyre kerekítve adja meg!$$' . $base . '^x=' . $result . '$$'; $exponent1 = log10($result) / log10($base); $exponent2 = round2($exponent1, 5); $correct = round2($exponent1, 3); $solution = '$' . $correct . '$'; $page[] = 'Vegyük mindkét oldal $10$-es alapú logaritmusát:$$\\log_{10}\\left(' . $base . '^x\\right)=\\log_{10}' . $result . '$$'; $page[] = '<div class="alert alert-info"><strong>Logaritmus azonossága:</strong><br />Hatvány logaritmusa egyenlő az alap logaritmusának és a kitevőnek a szorzatával:$$\\log_ab^k=k\\cdot\\log_ab$$</div>'; $page[] = 'Az azonosság felhasználásával át tudjuk írni a baloldali kifejezést:$$x\\cdot\\log_{10}' . $base . '=\\log_{10}' . $result . '$$'; $hints[] = $page; $page = []; $page[] = 'Osszuk el mindkét oldalt $\\log_{10}' . $base . '$-' . With($base) . '!$$x=\\frac{\\log_{10}' . $result . '}{\\log_{10}' . $base . '}\\approx' . $exponent2 . '$$'; $page[] = '<b>Megjegyzés</b>: a számológépen a tízes alapú logaritmust a <b>log</b> gomb jelöli:<div class="text-center"><kbd>' . $result . '</kbd> <kbd>log</kbd> <kbd>÷</kbd> <kbd>' . $base . '</kbd> <kbd>log</kbd> <kbd>=</kbd></div>'; $page[] = 'A megoldás három tizedesjegyre kerekített értéke <span class="label label-success">$' . $correct . '$</span>.'; $hints[] = $page; return array('question' => $question, 'correct' => $correct, 'solution' => $solution, 'hints' => $hints); }
function Generate($level) { $q_no = rand(4, 8); $opts_no = rand(2, 5); $ppl = rand(7, 13); $opts_text = range(chr(65), chr(65 + $opts_no - 1)); $max_points = $ppl * $q_no; $points = rand(1, floor($max_points / 5)) * 5; $rand = rand(1, 2); // // Original exercise // $q_no = 6; // $opts_no = 3; // $ppl = 10; // $points = 35; // $rand = 1; if ($rand == 1) { $type = 'jó'; $rate = $points / $max_points; $correct = round($points / $max_points * 360); } else { $type = 'rossz'; $rate = 1 - $points / $max_points; $correct = round((1 - $points / $max_points) * 360); } $question = 'Egy ' . NumText($q_no) . 'kérdéses tesztben minden kérdésnél a megadott ' . NumText($opts_no) . ' lehetőség (' . StringArray($opts_text, 'és') . ') közül kellett kiválasztani a helyes választ. A tesztet ' . NumText($ppl) . ' diák írta meg. A teszt értékelésekor minden helyes válaszra $1$ pont, helytelen válaszra pedig $0$ pont jár. Tudjuk, hogy a ' . NumText($ppl) . ' diák összesen $' . $points . '$ pontot szerzett. Ha az összes jó és az összes rossz válasz számából kördiagramot készítünk, mekkora körcikk szemlélteti a ' . $type . ' válaszok számát? <i>(Válaszát egész fokokra kerekítve adja meg!)</i>' . $this->PieChart(); $solution = '$' . $correct . '°$'; $page[] = 'Ha minden diák minden kérdésre jól válaszolt volna, összesen $' . $ppl . '\\cdot' . $q_no . '=' . $max_points . '$ pontot szerzett volna.'; $page[] = 'A ' . NumText($ppl) . ' diák összesen $' . $points . '$ pontot szerzett, ezért a jó válaszok száma $' . $points . '$, a rossz válaszok száma pedig $' . strval($max_points - $points) . '$.'; $page[] = 'A ' . $type . ' válaszok aránya: $$\\frac{' . ($type == 'jó' ? $points : $max_points - $points) . '}{' . $max_points . '}' . (round1($rate) == $rate ? '=' : '\\approx') . round2($rate) . '$$'; $page[] = 'Ezért a kördiagramon a ' . $type . ' válaszokhoz tartozó körcikk nagysága egész fokokra kerekítve $\\frac{' . ($type == 'jó' ? $points : $max_points - $points) . '}{' . $max_points . '}\\cdot360°' . ($rate * 360 == $correct ? '=' : '\\approx') . '$<span class="label label-success">$' . $correct . '$</span>$°$.' . $this->PieChart($correct); $hints[] = $page; return array('question' => $question, 'correct' => $correct, 'solution' => $solution, 'hints' => $hints, 'labels' => ['right' => '$°$']); }
function Generate($level) { $start = rand(4 * $level, 5 * $level) * 100; $end = rand(1 * $level, 3 * $level) * 100; $rate = rand(75, 95) / 100; // // Original exercise // $start = 3600; // $end = 900; // $rate = 0.854; $x = (log($end) / log(10) - log($start) / log(10)) / (log($rate) / log(10)); $correct = 2014 + ceil($x); $question = 'Egy $2014$ végén készült előrejelzés szerint az Indiában élő tigrisek $t$ száma az elkövetkező években (az egyes évek végén) megközelítőleg a következő összefüggés szerint alakul: $t(x) = ' . $start . ' \\cdot ' . round2($rate, 3) . '^x$, ahol $x$ a $2014$ óta eltelt évek számát jelöli. Melyik évben várható, hogy a tigrisek száma $' . $end . '$ alá csökken?'; $page[] = 'A feladat lényegében azt kérdi, hogy melyik az az $x$, amit ha behelyettesítünk a képletbe, $' . $end . '$-' . By($end) . ' kisebb lesz az eredmény.'; $page[] = 'Írjuk fel ezt az egyenlőtlenséget:$$' . $start . '\\cdot ' . round2($rate, 3) . '^x<' . $end . '$$'; $page[] = 'Osszuk el mindkét oldalt $' . $start . '$-' . With($start) . ':$$' . round2($rate, 3) . '^x<\\frac{' . $end . '}{' . $start . '}$$'; $page[] = 'Vegyük mindkét oldal $10$-es alapú logaritmusát:$$\\lg\\left(' . round2($rate, 3) . '^x\\right)<\\lg\\left(\\frac{' . $end . '}{' . $start . '}\\right)$$'; $hints[] = $page; $page = []; $page[] = '<div class="alert alert-info"><strong>Logaritmus azonosság:</strong><br />Egy hányados logaritmusát úgy kapjuk meg, hogy a számláló logaritmusából kivonjuk a nevező logaritmusát:$$\\lg\\left(\\frac{a}{b}\\right)=\\lg a - \\lg b$$</div>'; $page[] = 'A fenti azonosságot felhasználva írjuk a jobb oldalt:$$\\lg\\left(' . round2($rate, 3) . '^x\\right)<\\lg' . $end . '-\\lg' . $start . '$$'; $hints[] = $page; $page = []; $page[] = '<div class="alert alert-info"><strong>Logaritmus azonosság:</strong><br />Ha egy hatványnak vesszük a logaritmusát, akkor a kitevőt a kifejezés elé írhatjuk:$$\\lg\\left(a^b\\right)=b\\cdot\\lg a$$</div>'; $page[] = 'A fenti azonosságot felhasználva írjuk az $x$-et a bal oldali kifejezés elé:$$x\\cdot\\lg' . round2($rate, 3) . '<\\lg' . $end . '-\\lg' . $start . '$$'; $page[] = 'Osszuk el mindkét oldalt $\\lg' . round2($rate, 3) . '$-' . With(round($rate * 1000)) . '!<div class="alert alert-danger"><b>Figyelem!</b><br />Az $1$-nél kisebb számok logaritmusa <b>negatív</b> lesz, ezért a relációs jel iránya megfordul!$$x>\\frac{\\lg' . $end . '-\\lg' . $start . '}{\\lg' . round2($rate, 3) . '}\\approx{' . round2($x) . '}$$</div>'; $page[] = 'A fenti kifejezés azt jelenti, hogy a $2014$ után legalább $' . ceil($x) . '$ évnek kell eltelnie ahhoz, hogy a tigrisek száma $' . $end . '$ alá csökkenjen, vagyis a megoldás $2014+' . ceil($x) . '=$<span class="label label-success">$' . $correct . '$</span>.'; $hints[] = $page; $solution = '$' . $correct . '$'; return array('question' => $question, 'correct' => $correct, 'solution' => $solution, 'hints' => $hints); }
function Generate($level) { $year_diff = rand($level, 2 * $level); $year2 = 2014 + $year_diff; $tiger1 = rand($level, 5 * $level) * 100; $rate1 = rand(750, 950) / 1000; // // Original exercise // $year_diff = 2; // $year2 = 2014 + $year_diff; // $tiger1 = 3600; // $rate1 = 0.854; $rate2 = round1(pow($rate1, $year_diff), 3); $rate2_percent = round1(100 * $rate2, 0); $tiger2 = round($tiger1 * $rate2); $question = 'Egy $2014$ végén készült előrejelzés szerint az Indiában élő tigrisek $t$ száma az elkövetkező években (az egyes évek végén) megközelítőleg a következő összefüggés szerint alakul: $t(x) = ' . $tiger1 . ' \\cdot ' . round2($rate1, 3) . '^x$, ahol $x$ a $2014$ óta eltelt évek számát jelöli. Számítsa ki, hogy az előrejelzés alapján $' . $year2 . '$ végére hány százalékkal csökken a tigrisek száma a $2014$-es év végi adathoz képest! <i>(A megoldást egészekre kerekítve adja meg!)</i>'; $page[] = '<b>1. megoldás:</b> Ha az $x$ helyére $0$-t írunk, megkapjuk a tigrisek számát $2014$-ben:$$t(0)=' . $tiger1 . '\\cdot' . round2($rate1, 3) . '^0=' . $tiger1 . '\\cdot1=' . $tiger1 . '$$'; $page[] = '$2014$ és $' . $year2 . '$ között összesen $' . $year2 . '-2014=' . $year_diff . '$ év telik el.'; $page[] = 'Ezért ha az $x$ helyére $' . $year_diff . '$-' . Dativ($year_diff) . ' írunk, megkapjuk, hogy az előrejelzés szerint $' . $year2 . '$-' . In($year2) . ' hány tigris lesz:' . '$$t(' . $year_diff . ')=' . $tiger1 . '\\cdot' . round2($rate1, 3) . '^{' . $year_diff . '}' . ($rate2_percent == 100 * $rate2 ? '=' : '\\approx') . $tiger1 . '\\cdot' . round2($rate2, 3) . ($tiger1 * $rate2 == $tiger2 ? '=' : '\\approx') . $tiger2 . '$$'; $page[] = 'Osszuk el a $t(' . $year_diff . ')$-' . Dativ($year_diff) . ' elosztjuk $t(0)$-lal:' . '$$\\frac{t(' . $year_diff . ')}{t(0)}=\\frac{' . round2($tiger2, 0) . '}{' . $tiger1 . '}\\approx' . round2($rate2, 3) . ($rate2_percent == 100 * $rate2 ? '=' : '\\approx') . $rate2_percent . '\\%$$'; $page[] = 'Ez azt jelenti, hogy $' . $year2 . '$-' . In($year2) . ' a tigrisek száma $2014$-hez képest csak $' . $rate2_percent . '\\%$ lesz, vagyis a számuk $100\\%-' . $rate2_percent . '\\%=$<span class="label label-success">$' . strval(100 - $rate2_percent) . '$</span>$\\%$-kal csökken.'; $hints[] = $page; $page = []; $page[] = '<b>2. megoldás:</b> A tigrisek száma minden évben az előző évinek $' . round2($rate1, 3) . '$-' . Times2($rate1 * 1000) . ' változik.'; $page[] = 'Ekkor $' . $year_diff . '$ év alatt a változás $' . round2($rate1, 3) . '^' . $year_diff . ($rate2_percent == $rate2 * 100 ? '=' : '\\approx') . round2($rate2, 3) . ($rate2_percent == 100 * $rate2 ? '=' : '\\approx') . $rate2_percent . '\\%$ lesz.'; $page[] = 'Azaz, a tigrisek száma $100\\%-' . $rate2_percent . '\\%=$<span class="label label-success">$' . strval(100 - $rate2_percent) . '$</span>$\\%$-kal csökken.'; $hints[] = $page; $correct = 100 - $rate2_percent; $solution = '$' . $correct . '$'; return array('question' => $question, 'correct' => $correct, 'solution' => $solution, 'labels' => ['right' => '$\\%$'], 'hints' => $hints); }
function Hints($angle, $length, $correct) { $hints[][] = 'Rajzoljuk fel az $\\overrightarrow{AB}$ és $\\overrightarrow{AC}$ vektorokat (nem kell, hogy valósághű legyen az ábra):' . $this->Vectors($angle, $length, 0); $hints[][] = 'Az $\\overrightarrow{AB}-\\overrightarrow{AC}$ vektor a $C$ pontból a $B$-be megy. Ekkor az $ABC$ egy egyenlő szárú háromszög, aminek két oldala $' . $length . '-' . $length . '$ egység, és a közbezárt szög $' . $angle . '°$:' . $this->Vectors($angle, $length, 1); $page[] = 'Ha egy háromszög két oldalát ($a$ és $b$) és a közbezárt szöget ($\\alpha$) ismerjük, akkor a harmadik oldal hosszát a <b>koszinusz-tétel</b> segítségével tudjuk kiszámolni:$$c=\\sqrt{a^2+b^2-2\\cdot a\\cdot b\\cdot\\cos\\alpha}$$'; $page[] = 'Most az $a=b=' . $length . '$, és $\\alpha=' . $angle . '°$. Ekkor a harmadik oldal hossza:$$\\begin{eqnarray}' . '|\\overrightarrow{AB}-\\overrightarrow{AC}|&=&\\sqrt{' . $length . '^2+' . $length . '^2-2\\cdot ' . $length . '\\cdot ' . $length . '\\cdot\\cos' . $angle . '°}\\\\' . ' &=&\\sqrt{' . strval(2 * pow($length, 2)) . '-' . strval(2 * pow($length, 2)) . '\\cdot\\cos' . $angle . '°}\\end{eqnarray}$$'; $page[] = 'Ennek a két tizedesjegyre kerekített értéke, vagyis a vektor hossza: <span class="label label-success">$' . round2($correct) . '$</span> egység.'; $hints[] = $page; return $hints; }
function Hints($a, $b, $c, $area) { $sides = 6; $triangle = sqrt(3) * pow($b, 2) / 4; $T_bottom = $sides * $triangle; $page[] = '<b>1. lépés:</b> Számoljuk ki az alaplap területét!'; $page[] = 'Az alaplap $' . $sides . '$ db $' . $b . '\\,\\text{cm}$ oldalú szabályos háromszögből áll.' . $this->Bottom($b); $hints[] = $page; $page = []; $page[] = 'Számoljuk ki egy háromszög területét!' . $this->Bottom($b, 1); $hints[] = $page; $page = []; $page[] = '<div class="alert alert-info"><strong>Háromszög területe:</strong><br />Ha egy háromszög oldala $a$, a hozzá tartozó magasság $m_a$, akkor a területe:$$T_{\\triangle}=\\frac{a\\cdot m_a}{2}$$<b>Szabályos háromszög magassága</b><br />Ha egy szabályos háromszög oldala $a$, akkor a magassága $$m_a=\\frac{\\sqrt{3}}{2}\\cdot a$$</div>'; $page[] = 'Jelen esetben $a=7$, ezért:$$\\begin{eqnarray}T_{\\triangle}=\\frac{a\\cdot m_a}{2}&=&\\frac{' . $b . '\\cdot\\left(\\frac{\\sqrt{3}}{2}\\cdot' . $b . '\\right)}{2} \\\\ &=&\\frac{\\sqrt{3}\\cdot' . strval(pow($b, 2)) . '}{4}\\\\ &\\approx&' . round2($triangle) . '\\,\\text{cm}^2\\end{eqnarray}$$'; $page[] = 'Tehát az alaplap területe$$T_{\\text{alaplap}}=' . $sides . '\\cdot T_{\\triangle}=' . $sides . '\\cdot' . round2($triangle) . '\\approx' . round2($T_bottom) . '\\,\\text{cm}^2$$'; $hints[] = $page; $page = []; $page[] = '<b>2. lépés:</b> Számoljuk ki az oldallapok területét!'; $page[] = 'A doboznak mind a $' . $sides . '$ oldala egy szimmetrikus trapéz, aminek az alapjai $' . $a . '$ ill. $' . $b . '\\,\\text{cm}$, oldalai pedig $' . $c . '\\,\\text{cm}$ hosszúak.' . $this->Side($a, $b, $c); $hints[] = $page; $page = []; $page[] = 'Az alsó oldalt mérjük rá a felsőre, és nézzük meg, hány centi marad jobb és baloldalon:' . $this->Side($a, $b, $c, 1); $hints[] = $page; $d = ($a - $b) / 2; $e = pow($c, 2) - pow($d, 2); $m = sqrt($e); $page = []; $page[] = 'Ekkor a jobb és a bal oldalon egy olyan derékszögű háromszöget kaptunk, aminek az átfogója $' . $c . '\\,\\text{cm}$, az egyik befogója pedig $' . $d . '\\,\\text{cm}$.' . $this->Side($a, $b, $c, 2); $page[] = 'A másik befogót ($x$) - ami egyben a trapéz magassága - Pitagorasz-tétellel tudjuk kiszámolni:$$\\begin{eqnarray} x^2+' . $d . '^2&=&' . $c . '^2\\\\ x^2+' . strval(pow($d, 2)) . '&=&' . strval(pow($c, 2)) . '\\\\ x^2&=&' . $e . '\\\\ x&=&\\sqrt{' . $e . '}\\\\ x&' . (round1($m) == $m ? '=' : '\\approx') . '&' . round2($m) . '\\end{eqnarray}$$'; $hints[] = $page; $T_side = ($a + $b) / 2 * $m; $T_all = $T_bottom + $sides * $T_side; $page = []; $page[] = '<div class="alert alert-info"><strong>Trapéz területe:</strong><br />Ha egy trapéz két párhuzamos oldala $a$ és $c$, és magassága $m$, akkor a területe:$$T=\\frac{a+c}{2}\\cdot m$$</div>'; $page[] = 'Egy oldal területe:$$T=\\frac{' . $a . '+' . $b . '}{2}\\cdot' . strval(round2($m)) . '=' . round2($T_side) . '$$'; $page[] = 'Mivel összesen $' . $sides . '$ oldal van, ezért az oldallapok összterülete:$$T_{\\text{oldallapok}}=' . $sides . '\\cdot' . round2($T_side) . '=' . round2($sides * $T_side) . '$$'; $page[] = 'Ekkor egy virágtartó doboz összterülete:$$\\begin{eqnarray}T_{\\text{össz}}&=&T_{\\text{alaplap}}+T_{\\text{oldallapok}}\\\\ &\\approx&' . round2($T_bottom) . '+' . round2($sides * $T_side) . '=' . round2($T_all) . '\\end{eqnarray}$$'; $hints[] = $page; $pieces = $area * 10000 / $T_all; $page = []; $page[] = 'A gép $1$ kg alapanyagból $' . round2($area) . '\\,\\text{m}^2$ felületet képes készíteni, ami összesen $' . round2($area) . '\\cdot10000=' . round2($area * 10000) . '\\,\\text{cm}^2$.'; $page[] = 'Számoljuk ki, hogy $1$ kg anyagból hány doboz készíthető:$$\\frac{' . round2($area * 10000) . '}{' . round2($T_all) . '}\\approx' . round2($pieces) . '$$'; $page[] = 'Tehát $1$ kg alapanyagból <span class="label label-success">$' . floor($pieces) . '$</span> darab doboz készíthető.'; $hints[] = $page; return array($hints, floor($pieces)); }
function Generate($level) { $m = pow(-1, rand(1, 2)) * rand(1, 2); $b = rand(-5, 5); $A[0] = pow(-1, rand(1, 2)) * rand(1, 10); // Ax != 0 $A[1] = $A[0] * $m + $b; $B[0] = -$A[0]; $B[1] = $B[0] * $m + $b; // // Original exercise // $A = [-3,-1]; // $B = [3,7]; // $m = ($A[1]-$B[1])/($A[0]-$B[0]); // $b = $A[1] - $A[0]*$m; // print_r('m='.$m.', b='.$b.'<br />'); // print_r('A('.$A[0].';'.$A[1].'), B('.$B[0].';'.$B[1].') <br />'); $mfrac['nom'] = ($B[1] - $A[1]) / gcd($B[1] - $A[1], $B[0] - $A[0]); $mfrac['denum'] = ($B[0] - $A[0]) / gcd($B[1] - $A[1], $B[0] - $A[0]); $question = 'Írja fel a hozzárendelési utasítását annak a lineáris függvénynek, mely $' . ($A[0] < 0 ? '(' . $A[0] . ')' : $A[0]) . '$-' . To($A[0]) . ' $' . ($A[1] < 0 ? '(' . $A[1] . ')' : $A[1]) . '$-' . Dativ($A[1]) . ' és $' . ($B[0] < 0 ? '(' . $B[0] . ')' : $B[0]) . '$-' . To($B[0]) . ' $' . ($B[1] < 0 ? '(' . $B[1] . ')' : $B[1]) . '$-' . Dativ($B[1]) . ' rendel! (A hozzárendelési utasítást $x\\mapsto mx+b$ alakban adja meg!)'; $page[] = 'A hozzárendelés egy $y=mx+b$ alakú lineáris függvény lesz.'; $page[] = 'A függvény $' . ($A[0] < 0 ? '(' . $A[0] . ')' : $A[0]) . '$-' . To($A[0]) . ' $' . ($A[1] < 0 ? '(' . $A[1] . ')' : $A[1]) . '$-' . Dativ($A[1]) . ' rendel, azaz:$$' . $A[1] . '=' . $A[0] . '\\cdot m+b$$'; $page[] = 'Továbbá azt is tudjuk, hogy $' . ($B[0] < 0 ? '(' . $B[0] . ')' : $B[0]) . '$-' . To($B[0]) . ' $' . ($B[1] < 0 ? '(' . $B[1] . ')' : $B[1]) . '$-' . Dativ($B[1]) . ' rendel, azaz:$$' . $B[1] . '=' . $B[0] . '\\cdot m+b$$'; $hints[] = $page; $page = []; $page[] = '$$\\begin{eqnarray} I.\\quad& ' . $A[1] . '&=&' . $A[0] . '\\cdot m+b\\\\ II.\\quad& ' . $B[1] . '&=&' . $B[0] . '\\cdot m+b \\end{eqnarray}$$ Vonjuk ki az első egyenletből a másodikat! Ekkor a $b$-s tagok kiesnek:$$\\begin{eqnarray} ' . $A[1] . (-$B[1] < 0 ? '' : '+') . strval(-$B[1]) . '&=&(' . $A[0] . (-$B[0] < 0 ? '' : '+') . strval(-$B[0]) . ')\\cdot m+b-b\\\\ ' . strval($A[1] - $B[1]) . '&=&' . strval($A[0] - $B[0]) . '\\cdot m\\\\ \\frac{' . strval($A[1] - $B[1]) . '}{' . strval($A[0] - $B[0]) . '}&=&m\\\\ \\end{eqnarray}$$'; $page[] = 'Tehát az $m$ értéke <span class="label label-success">$' . (round($m) == $m ? $m : '\\frac{' . $mfrac['nom'] . '}{' . $mfrac['denum'] . '}') . '$</span>.'; $hints[] = $page; $page = []; $page[] = '$$\\begin{eqnarray} I.\\quad& ' . $A[1] . '&=&' . $A[0] . '\\cdot m+b\\\\ II.\\quad& ' . $B[1] . '&=&' . $B[0] . '\\cdot m+b \\end{eqnarray}$$ Most adjuk össze a két egyenletet! Ekkor az $m$-es tagok esnek ki:$$\\begin{eqnarray} ' . $A[1] . ($B[1] < 0 ? '' : '+') . $B[1] . '&=&(' . $A[0] . ($B[0] < 0 ? '' : '+') . $B[0] . ')\\cdot m+b+b\\\\ ' . strval($A[1] + $B[1]) . '&=&2\\cdot b\\\\ \\frac{' . strval($A[1] + $B[1]) . '}{2}&=&b\\\\ \\end{eqnarray}$$'; $page[] = 'Tehát a $b$ értéke <span class="label label-success">$' . $b . '$</span>.'; $hints[] = $page; $correct = [round1($m), $b]; $solution = '$m=' . round2($m) . '\\quad b=' . $b . '$'; return array('question' => $question, 'correct' => $correct, 'type' => 'array', 'solution' => $solution, 'hints' => $hints, 'labels' => ['$m$', '$b$']); }
function Generate($level) { $q_no = rand(5, 7); $opts_no = rand(2, 4); // // Original exercise // $q_no = 6; // $opts_no = 3; $opts_text = range(chr(65), chr(65 + $opts_no - 1)); $prob = 1 - pow(($opts_no - 1) / $opts_no, $q_no); $question = 'Egy ' . NumText($q_no) . 'kérdéses tesztben minden kérdésnél a megadott ' . NumText($opts_no) . ' lehetőség (' . StringArray($opts_text, 'és') . ') közül kellett kiválasztani a helyes választ. Az egyik diák nem készült fel a tesztre, válaszait tippelve, véletlenszerűen adja meg. Mekkora valószínűséggel lesz legalább egy jó válasza a tesztben? <i>(Válaszát két tizedesjegyre kerekítve adja meg!)</i>'; $page[] = 'Annak a valószínűsége, hogy egy válasz hibás: $$\\frac{' . strval($opts_no - 1) . '}{' . $opts_no . '}$$'; $page[] = 'Annak a valószínűsége, hogy mind ' . The($q_no) . ' ' . NumText($q_no) . ' válasz hibás: $$\\left(\\frac{' . strval($opts_no - 1) . '}{' . $opts_no . '}\\right)^{' . $q_no . '}$$'; $page[] = 'Annak a valószínűsége, hogy legalább az egyik válasz jó: $$1-\\left(\\frac{' . strval($opts_no - 1) . '}{' . $opts_no . '}\\right)^{' . $q_no . '}\\approx' . round2($prob, 4) . '$$'; $page[] = 'Ennek a két tizedesjegyre kerekített értéke <span class="label label-success">$' . round2($prob) . '$</span>.'; $hints[] = $page; $correct = round1($prob, 2); $solution = '$' . round2($prob, 2) . '$'; return array('question' => $question, 'correct' => $correct, 'solution' => $solution, 'hints' => $hints); }
function Generate($level) { $flower = rand($level, 2 * $level); $all = $flower + rand(1, 2); $p = rand(80, 95) / 100; // // Original exercise // $flower = 8; // $all = 10; // $p = 0.91; $question = 'A kertészetben a sok virághagymának csak egy része hajt ki: $' . round2($p) . '$ annak a valószínűsége, hogy egy elültetett virághagyma kihajt. Számítsa ki annak a valószínűségét, hogy $' . $all . '$ darab elültetett virághagyma közül legalább $' . $flower . '$ kihajt! Válaszát három tizedesjegyre kerekítve adja meg!'; $text = 'Ha $' . $all . '$ virághagyma közül legalább $' . $flower . '$ hajt ki, az azt jelenti, hogy '; for ($i = $flower; $i <= $all; $i++) { $text .= '$' . $i . '$'; if ($i == $all - 1) { $text .= ' vagy '; } elseif ($i == $all - 2) { $text .= ', '; } } $text .= ' virághagyma hajt ki.'; $page[] = $text; $page[] = 'Vizsgáljuk meg ezeket az eseteket külön-külön!'; $hints[] = $page; $order = 1; for ($i = $flower; $i <= $all; $i++) { $p_i = binomial_coeff($all, $i) * pow($p, $i) * pow(1 - $p, $all - $i); $page = []; $page[] = '<b>' . $order . '. eset:</b> $' . $all . '$ virághagyma közül $' . $i . '$ hajt ki.'; $page[] = '$' . $all . '$ virághagyma közül $' . $i . '$-' . Dativ($i) . ' összesen ${' . $all . '\\choose ' . $i . '}$-féleképpen lehet kiválasztani.'; $page[] = 'Annak a valószínűsége, hogy ' . The($i) . ' $' . $i . '$ hagyma kihajt: $' . round2($p, 4) . '^{' . $i . '}$.'; $page[] = 'Annak a valószínűsége, hogy ' . The($all - $i) . ' $' . strval($all - $i) . '$ hagyma nem hajt ki: $(1-' . round2($p, 4) . ')^{' . strval($all - $i) . '}$.'; $page[] = 'Így ennek az esetnek a valószínűsége összesen:$${' . $all . '\\choose ' . $i . '}\\cdot' . round2($p, 4) . '^{' . $i . '}\\cdot(1-' . round2($p, 4) . ')^{' . strval($all - $i) . '}\\approx' . round2($p_i, 4) . '$$'; $hints[] = $page; $p_all1[] = round1($p_i, 4); $p_all2[] = round2($p_i, 4); $order++; } $hints[][] = 'A keresett valószínűség tehát $' . implode('+', $p_all2) . '=' . round2(array_sum($p_all1), 5) . '$, aminek a három tizedesjegyre kerekített értéke <span class="label label-success">$' . round2(array_sum($p_all1), 3) . '$</span>.'; $correct = round1(array_sum($p_all1), 3); $solution = '$' . $correct . '$'; return array('question' => $question, 'correct' => $correct, 'solution' => $solution, 'hints' => $hints); }
function Generate($level) { $A = rand(2, 3); $B = rand(2, 5); $C = 12 - $A - $B; // // Original exercise // $A = 5; // $B = 4; // $C = 3; $question = 'Az öttusa lovaglás számában egy akadálypályán tizenkét különböző akadályt kell a versenyzőnek átugratnia. Egy akadály a nehézsége alapján három csoportba sorolható: $A$, $B$ vagy $C$ típusú. Ádám a verseny előtti bemelegítéskor először ' . The($A) . ' ' . NumText($A) . ' darab $A$, majd ' . The($B) . ' ' . NumText($B) . ' darab $B$, végül ' . The($C) . ' ' . NumText($C) . ' darab $C$ típusú akadályon ugrat át, mindegyiken pontosan egyszer. Bemelegítéskor az egyes akadálytípusokon belül a sorrend szabadon megválasztható. Számítsa ki, hogy a bemelegítés során hányféle sorrendben ugrathatja át Ádám a tizenkét akadályt!'; $correct = fact($A) * fact($B) * fact($C); $solution = '$' . round2($correct, 0) . '$'; $type = 'int'; $page[] = 'Az $A$ típusú akadályok lehetséges sorrendjeinek a száma $' . $A . '!=' . fact($A) . '$.'; $page[] = 'A $B$ típusú akadályok lehetséges sorrendjeinek a száma $' . $B . '!=' . fact($B) . '$.'; $page[] = 'A $C$ típusú akadályok lehetséges sorrendjeinek a száma $' . $C . '!=' . fact($C) . '$.'; $page[] = 'A $12$ akadály lehetséges sorrendjeinek a száma ezek szorzata.'; $page[] = 'Tehát Ádám összesen $' . fact($A) . '\\cdot' . fact($B) . '\\cdot' . fact($C) . '=$<span class="label label-success">$' . round2($correct, 0) . '$</span> különböző sorrendben ugrathatja át a tizenkét akadályt.'; $hints[] = $page; return array('question' => $question, 'correct' => $correct, 'solution' => $solution, 'type' => $type, 'hints' => $hints); }
function Hints($start, $increase, $years, $percent) { $months = $years * 12; $sum1 = (2 * $start + ($months - 1) * $increase) / 2 * $months; $page[] = 'Az I. ajánlatban Péter havi fizetései egy $' . round2($increase, 0) . '$ differenciájú számtani sorozat egymást követő tagjai, ahol a sorozat első tagja $' . round2($start, 0) . '$.'; $page[] = 'Péter ' . NumText($years) . ' év alatt összesen $' . $years . '\\cdot12=' . $months . '$ fizetést kap.'; $page[] = 'Ez azt jelenti, hogy a számtani sorozat első $' . $months . '$ tagjának összegét kell kiszámolni.'; $page[] = '$$S_{' . $months . '}=\\frac{2\\cdot' . round2($start, 0) . '+' . strval($months - 1) . '\\cdot' . round2($increase, 0) . '}{2}\\cdot' . $months . '=' . round2($sum1, 0) . '\\,\\text{Ft}$$'; $page[] = 'Tehát ha Péter az I. ajánlatot választja, összesen $' . round2($sum1, 0) . '\\,\\text{Ft}$-ot kap.'; $hints[] = $page; $page = []; $ratio = 1 + $percent / 100; $sum2 = round1($start * (pow($ratio, $months) - 1) / ($ratio - 1)); $page[] = 'Az II. ajánlatban Péter havi fizetései egy $' . round2($ratio, 2) . '$ hányadosú mértani sorozat egymást követő tagjai, ahol a sorozat első tagja $' . round2($start, 0) . '$.'; $page[] = 'Az összjövedelem kiszámításához itt is a sorozat első $' . $months . '$ tagjának összegét kell meghatározni.'; $page[] = '$$S_{' . $months . '}\'=' . round2($start, 0) . '\\cdot\\frac{' . round2($ratio, 2) . '^{' . $months . '}-1}{' . round2($ratio, 2) . '-1}\\approx' . round2($sum2, 0) . '\\,\\text{Ft}$$'; $page[] = 'Tehát ha Péter a II. ajánlatot választja, összesen $' . round2($sum2, 0) . '\\,\\text{Ft}$-ot kap.'; $page[] = 'Mivel $' . round2($sum1, 0) . ($sum1 > $sum2 ? '>' : '<') . round2($sum2, 0) . '$, ezért Péternek ' . ($sum1 > $sum2 ? 'az' : 'a') . ' <span class="label label-success">' . ($sum1 > $sum2 ? 'I.' : 'II.') . ' ajánlatot</span> célszerű választani.'; $correct = $sum1 > $sum2 ? 0 : 1; $hints[] = $page; return array($hints, $correct); }
function Hints($pyramid_base, $pyramid_side, $cube_edge) { $cube_volume = pow($cube_edge, 3); $m_triangle = sqrt(pow($pyramid_side, 2) - pow($pyramid_base / 2, 2)); $m_pyramid = sqrt(pow($m_triangle, 2) - pow($pyramid_base / 2, 2)); $pyramid_volume = 1 / 3 * pow($pyramid_base, 2) * $m_pyramid; $pieces = $cube_volume / $pyramid_volume; $page[] = 'Számoljuk ki az oldallap magasságát ($m_{\\triangle}$) Pitagorasz-tétellel: $$\\begin{eqnarray} m_{\\triangle}^2+\\left(\\frac{' . $pyramid_base . '}{2}\\right)^2&=&' . $pyramid_side . '^2\\\\ m_{\\triangle}^2&=&' . $pyramid_side . '^2-\\left(\\frac{' . $pyramid_base . '}{2}\\right)^2\\\\ m_{\\triangle}&=&\\sqrt{' . $pyramid_side . '^2-\\left(\\frac{' . $pyramid_base . '}{2}\\right)^2} \\end{eqnarray}$$ A műveletet elvégezve azt kapjuk, hogy $m_{\\triangle}' . (round($m_triangle) == $m_triangle ? '=' : '\\approx') . round2($m_triangle) . '\\,\\text{cm}$.' . $this->Pyramid($pyramid_base, $pyramid_side, 1); $hints[] = $page; $page = []; $page[] = 'Számoljuk ki a gúla magasságát ($m$) Pitagorasz-tétellel: $$\\begin{eqnarray} m^2+\\left(\\frac{' . $pyramid_base . '}{2}\\right)^2&=&m_{\\triangle}^2\\\\ m^2&=&m_{\\triangle}^2-\\left(\\frac{' . $pyramid_base . '}{2}\\right)^2\\\\ m&=&\\sqrt{m_{\\triangle}^2-\\left(\\frac{' . $pyramid_base . '}{2}\\right)^2}\\\\ m&=&\\sqrt{' . round2($m_triangle) . '^2-' . round2($pyramid_base / 2) . '^2} \\end{eqnarray}$$ A műveletet elvégezve azt kapjuk, hogy $m' . (round($m_pyramid) == $m_pyramid ? '=' : '\\approx') . round2($m_pyramid) . '\\,\\text{cm}$.' . $this->Pyramid($pyramid_base, $pyramid_side, 2); $hints[] = $page; $page = []; $page[] = '<div class="alert alert-info"><b>Gúla térfogata</b><br />Ha egy gúla alapterülete $T_a$, és magassága $m$, akkor a térfogata:$$V=\\frac{1}{3}\\cdot T_a\\cdot m$$</div>'; $page[] = 'Jelen esetben alap egy $' . $pyramid_base . '\\,\\text{cm}$ oldalú négyzet, aminek a területe:$$T_a=' . $pyramid_base . '\\cdot' . $pyramid_base . '=' . pow($pyramid_base, 2) . '\\,\\text{cm}^2$$'; $page[] = 'Ezt a fenti képletbe behelyettesítve:$$V=\\frac{1}{3}\\cdot ' . pow($pyramid_base, 2) . '\\cdot' . round2($m_pyramid) . '\\approx' . round2($pyramid_volume) . '\\,\\text{cm}^3$$'; $page[] = 'Tehát egy darab gyertya térfogata $$V_{gyertya}\\approx' . round2($pyramid_volume) . '\\,\\text{cm}^3$$'; $hints[] = $page; $page = []; $page[] = 'Egy $' . $cube_edge . '\\,\\text{cm}$ oldalú kocka térfogata:$$V_{kocka}=' . $cube_edge . '\\cdot' . $cube_edge . '\\cdot' . $cube_edge . '=' . $cube_volume . '\\,\\text{cm}^3$$'; $page[] = 'Számoljuk ki, hogy egy kockából hány gyertya készíthető:$$\\frac{V_{kocka}}{V_{gyertya}}=\\frac{' . round2($cube_volume) . '}{' . round2($pyramid_volume) . '}\\approx' . round2($pieces) . '$$'; $page[] = 'Tehát egy kockából alapanyagból legfeljebb <span class="label label-success">$' . floor($pieces) . '$</span> darab doboz készíthető.'; $hints[] = $page; return array($hints, floor($pieces)); }
function Generate($level) { $AC = rand($level, 2 * $level); $BC = rand($level, 2 * $level); if ($AC == $BC && rand(1, 3) < 3) { while ($AC == $BC) { $BC = rand($level, 2 * $level); } } // // Original exercise // $AC = 6; // $BC = 8; $question = 'Az $ABC$ derékszögű háromszög $AC$ befogója $' . $AC . '$ cm, $BC$ befogója $' . $BC . '$ cm hosszú. Számítsa ki az $ABC$ háromszög hegyesszögeinek nagyságát legalább két tizedesjegy pontossággal!'; $alpha = toDeg(atan($AC / $BC)); $beta = toDeg(atan($BC / $AC)); $correct = array(round1($alpha), round1($beta)); $labels = array('$\\alpha$', '$\\beta$'); $solution = '$\\alpha=' . round2($alpha) . '°$ és $\\beta=' . round2($beta) . '°$.'; $hints[][] = 'Rajzoljunk egy derékszögű háromszöget:' . $this->Triangle(); $hints[][] = 'Tudjuk, hogy az $\\textcolor{blue}{AC}$ befogó $' . $AC . '$ cm hosszú:' . $this->Triangle(['AC'], [$AC], ['blue']); $hints[][] = 'Tudjuk, hogy az $\\textcolor{green}{BC}$ befogó $' . $BC . '$ cm hosszú:' . $this->Triangle(['AC', 'BC'], [$AC, $BC], ['blue', 'green']); $page[] = 'Tudjuk, hogy az $\\alpha$ szög <b>tangense</b> egyenlő a távolabbi és a közelebbi befogó hányadosával:' . '$$\\tan\\alpha=\\frac{\\textcolor{blue}{AC}}{\\textcolor{green}{BC}}=' . '\\frac{\\textcolor{blue}{' . $AC . '}}{\\textcolor{green}{' . $BC . '}}' . '$$'; $page[] = 'Az $\\alpha$ szöget megkapjuk, ha a hányados <b>arkusz tangensét</b> vesszük (ami a tangens függvény inverze), és az eredményt két tizedesjegyre kerekítjük:$$\\alpha=\\arctan\\frac{\\textcolor{blue}{' . $AC . '}}{\\textcolor{green}{' . $BC . '}}\\approx' . round2($alpha) . '°$$'; $page[] = '<b>Megjegyzés</b>: az eredményt a következőképpen lehet kiszámolni számológéppel: <ol> <li>Állítsuk be a gépet <b>DEG</b> módba (ha még nem tettük):<br /><kbd>MODE</kbd> <kbd>DEG</kbd></li> <li>Az arkusz tangenst a <b>tan<sup>-1</sup></b> gomb segítségével lehet kiszámolni:<br />' . '<kbd>' . $AC . '</kbd> <kbd>÷</kbd> <kbd>' . $BC . '</kbd> <kbd>=</kbd> <kbd>Shift</kbd> <kbd>tan<sup>-1</sup></kbd> <kbd>=</kbd></li> </ol>'; $page[] = 'Tehát az $\\alpha$ szög <span class="label label-success">$' . round2($alpha) . '°$</span>.'; $hints[] = $page; $page = []; $page[] = 'Mivel a háromszög belső szögeinek összege $180°$, ezért a $\\beta$ szöget már könnyen ki lehet számolni:$$\\beta=180°-90°-' . round2($alpha) . '°$$'; $page[] = 'Tehát a $\\beta$ szög <span class="label label-success">$' . round2($beta) . '°$</span>.'; $hints[] = $page; return array('question' => $question, 'correct' => $correct, 'solution' => $solution, 'hints' => $hints, 'labels' => $labels, 'type' => 'array'); }
end_table(); echo "</td></tr>"; end_table(); } echo "<center>"; if ($_SESSION['View']->so_type == 1) { display_note(_("This Sales Order is used as a Template."), 0, 0, "class='currentfg'"); } display_heading2(_("Line Details")); start_table(TABLESTYLE, "colspan=9 width=95%"); $th = array(_("Item Code"), _("Item Description"), _("Quantity"), _("Unit"), _("Price"), _("Discount"), _("Total"), _("Quantity Delivered")); table_header($th); $k = 0; //row colour counter foreach ($_SESSION['View']->line_items as $stock_item) { $line_total = round2($stock_item->quantity * $stock_item->price * (1 - $stock_item->discount_percent), user_price_dec()); alt_table_row_color($k); label_cell($stock_item->stock_id); label_cell($stock_item->item_description); $dec = get_qty_dec($stock_item->stock_id); qty_cell($stock_item->quantity, false, $dec); label_cell($stock_item->units); amount_cell($stock_item->price); amount_cell($stock_item->discount_percent * 100); amount_cell($line_total); qty_cell($stock_item->qty_done, false, $dec); end_row(); } label_row(_("Shipping"), price_format($_SESSION['View']->freight_cost), "align=right colspan=6", "nowrap align=right", 1); $sub_tot = $_SESSION['View']->get_items_total() + $_SESSION['View']->freight_cost; $display_sub_tot = price_format($sub_tot);
function print_po() { global $path_to_root, $show_po_item_codes; include_once $path_to_root . "/reporting/includes/pdf_report.inc"; $from = $_POST['PARAM_0']; $to = $_POST['PARAM_1']; $currency = $_POST['PARAM_2']; $email = $_POST['PARAM_3']; $comments = $_POST['PARAM_4']; $orientation = $_POST['PARAM_5']; if (!$from || !$to) { return; } $orientation = $orientation ? 'L' : 'P'; $dec = user_price_dec(); $cols = array(4, 60, 225, 300, 340, 385, 450, 515); // $headers in doctext.inc $aligns = array('left', 'left', 'left', 'right', 'left', 'right', 'right'); $params = array('comments' => $comments); $cur = get_company_Pref('curr_default'); if ($email == 0) { $rep = new FrontReport(_('PURCHASE ORDER'), "PurchaseOrderBulk", user_pagesize(), 9, $orientation); } if ($orientation == 'L') { recalculate_cols($cols); } for ($i = $from; $i <= $to; $i++) { $myrow = get_po($i); $baccount = get_default_bank_account($myrow['curr_code']); $params['bankaccount'] = $baccount['id']; if ($email == 1) { $rep = new FrontReport("", "", user_pagesize(), 9, $orientation); $rep->title = _('PURCHASE ORDER'); $rep->filename = "PurchaseOrder" . $i . ".pdf"; } $rep->SetHeaderType('Header2'); $rep->currency = $cur; $rep->Font(); $rep->Info($params, $cols, null, $aligns); $contacts = get_supplier_contacts($myrow['supplier_id'], 'order'); $rep->SetCommonData($myrow, null, $myrow, $baccount, ST_PURCHORDER, $contacts); $rep->NewPage(); $result = get_po_details($i); $SubTotal = 0; $items = $prices = array(); while ($myrow2 = db_fetch($result)) { $data = get_purchase_data($myrow['supplier_id'], $myrow2['item_code']); if ($data !== false) { if ($data['supplier_description'] != "") { $myrow2['description'] = $data['supplier_description']; } if ($data['suppliers_uom'] != "") { $myrow2['units'] = $data['suppliers_uom']; } if ($data['conversion_factor'] != 1) { $myrow2['unit_price'] = round2($myrow2['unit_price'] * $data['conversion_factor'], user_price_dec()); $myrow2['quantity_ordered'] = round2($myrow2['quantity_ordered'] / $data['conversion_factor'], user_qty_dec()); } } $Net = round2($myrow2["unit_price"] * $myrow2["quantity_ordered"], user_price_dec()); $prices[] = $Net; $items[] = $myrow2['item_code']; $SubTotal += $Net; $dec2 = 0; $DisplayPrice = price_decimal_format($myrow2["unit_price"], $dec2); $DisplayQty = number_format2($myrow2["quantity_ordered"], get_qty_dec($myrow2['item_code'])); $DisplayNet = number_format2($Net, $dec); if ($show_po_item_codes) { $rep->TextCol(0, 1, $myrow2['item_code'], -2); $rep->TextCol(1, 2, $myrow2['description'], -2); } else { $rep->TextCol(0, 2, $myrow2['description'], -2); } $rep->TextCol(2, 3, sql2date($myrow2['delivery_date']), -2); $rep->TextCol(3, 4, $DisplayQty, -2); $rep->TextCol(4, 5, $myrow2['units'], -2); $rep->TextCol(5, 6, $DisplayPrice, -2); $rep->TextCol(6, 7, $DisplayNet, -2); $rep->NewLine(1); if ($rep->row < $rep->bottomMargin + 15 * $rep->lineHeight) { $rep->NewPage(); } } if ($myrow['comments'] != "") { $rep->NewLine(); $rep->TextColLines(1, 5, $myrow['comments'], -2); } $DisplaySubTot = number_format2($SubTotal, $dec); $rep->row = $rep->bottomMargin + 15 * $rep->lineHeight; $doctype = ST_PURCHORDER; $rep->TextCol(3, 6, _("Sub-total"), -2); $rep->TextCol(6, 7, $DisplaySubTot, -2); $rep->NewLine(); $tax_items = get_tax_for_items($items, $prices, 0, $myrow['tax_group_id'], $myrow['tax_included'], null); $first = true; foreach ($tax_items as $tax_item) { if ($tax_item['Value'] == 0) { continue; } $DisplayTax = number_format2($tax_item['Value'], $dec); $tax_type_name = $tax_item['tax_type_name']; if ($myrow['tax_included']) { if (isset($alternative_tax_include_on_docs) && $alternative_tax_include_on_docs == 1) { if ($first) { $rep->TextCol(3, 6, _("Total Tax Excluded"), -2); $rep->TextCol(6, 7, number_format2($sign * $tax_item['net_amount'], $dec), -2); $rep->NewLine(); } $rep->TextCol(3, 6, $tax_type_name, -2); $rep->TextCol(6, 7, $DisplayTax, -2); $first = false; } else { $rep->TextCol(3, 7, _("Included") . " " . $tax_type_name . _("Amount") . ": " . $DisplayTax, -2); } } else { $SubTotal += $tax_item['Value']; $rep->TextCol(3, 6, $tax_type_name, -2); $rep->TextCol(6, 7, $DisplayTax, -2); } $rep->NewLine(); } $rep->NewLine(); $DisplayTotal = number_format2($SubTotal, $dec); $rep->Font('bold'); $rep->TextCol(3, 6, _("TOTAL PO"), -2); $rep->TextCol(6, 7, $DisplayTotal, -2); $words = price_in_words($SubTotal, ST_PURCHORDER); if ($words != "") { $rep->NewLine(1); $rep->TextCol(1, 7, $myrow['curr_code'] . ": " . $words, -2); } $rep->Font(); if ($email == 1) { $myrow['DebtorName'] = $myrow['supp_name']; if ($myrow['reference'] == "") { $myrow['reference'] = $myrow['order_no']; } $rep->End($email); } } if ($email == 0) { $rep->End(); } }
$input_error = 1; } if ($input_error == 0) { $periods = input_num('periods'); $per = $periods - 1; $date = $date_ = get_post('date_'); $freq = get_post('freq'); $lastdate = $freq == 1 ? add_days($date_, 7 * $per) : ($freq == 2 ? add_days($date_, 14 * $per) : ($freq == 3 ? add_months($date_, $per) : add_months($date_, 3 * $per))); if (!is_date_in_fiscalyears($lastdate, false)) { display_error(_("Some of the period dates are outside the fiscal year. Create a new fiscal year first!")); set_focus('date_'); $input_error = 1; } if ($input_error == 0) { $amount = input_num('amount'); $am = round2($amount / $periods, user_price_dec()); if ($am * $periods != $amount) { $am0 = $am + $amount - $am * $periods; } else { $am0 = $am; } if (get_post('memo_') != "") { $memo = $_POST['memo_']; } else { $memo = sprintf(_("Accruals for %s"), $amount); } if (isset($_POST['go'])) { begin_transaction(); } else { start_table(TABLESTYLE); $dim = get_company_pref('use_dimension');
function handle_commit_order() { $cart =& $_SESSION['PO']; if (can_commit()) { copy_to_cart(); if ($cart->trans_type != ST_PURCHORDER) { // for direct grn/invoice set same dates for lines as for whole document foreach ($cart->line_items as $line_no => $line) { $cart->line_items[$line_no]->req_del_date = $cart->orig_order_date; } } if ($cart->order_no == 0) { // new po/grn/invoice /*its a new order to be inserted */ $ref = $cart->reference; if ($cart->trans_type != ST_PURCHORDER) { $cart->reference = 'auto'; begin_transaction(); // all db changes as single transaction for direct document } $order_no = add_po($cart); new_doc_date($cart->orig_order_date); $cart->order_no = $order_no; if ($cart->trans_type == ST_PURCHORDER) { unset($_SESSION['PO']); meta_forward($_SERVER['PHP_SELF'], "AddedID={$order_no}"); } //Direct GRN if ($cart->trans_type == ST_SUPPRECEIVE) { $cart->reference = $ref; } if ($cart->trans_type != ST_SUPPINVOICE) { $cart->Comments = $cart->reference; } //grn does not hold supp_ref foreach ($cart->line_items as $key => $line) { $cart->line_items[$key]->receive_qty = $line->quantity; } $grn_no = add_grn($cart); if ($cart->trans_type == ST_SUPPRECEIVE) { commit_transaction(); // save PO+GRN unset($_SESSION['PO']); meta_forward($_SERVER['PHP_SELF'], "AddedGRN={$grn_no}"); } // Direct Purchase Invoice $inv = new supp_trans(ST_SUPPINVOICE); $inv->Comments = $cart->Comments; $inv->supplier_id = $cart->supplier_id; $inv->tran_date = $cart->orig_order_date; $inv->due_date = $cart->due_date; $inv->reference = $ref; $inv->supp_reference = $cart->supp_ref; $inv->tax_included = $cart->tax_included; $supp = get_supplier($cart->supplier_id); $inv->tax_group_id = $supp['tax_group_id']; $inv->ov_amount = $inv->ov_gst = $inv->ov_discount = 0; $total = 0; foreach ($cart->line_items as $key => $line) { $inv->add_grn_to_trans($line->grn_item_id, $line->po_detail_rec, $line->stock_id, $line->item_description, $line->receive_qty, 0, $line->receive_qty, $line->price, $line->price, true, get_standard_cost($line->stock_id), ''); $inv->ov_amount += round2($line->receive_qty * $line->price, user_price_dec()); } $inv->tax_overrides = $cart->tax_overrides; if (!$inv->tax_included) { $taxes = $inv->get_taxes($inv->tax_group_id, 0, false); foreach ($taxes as $taxitem) { $total += isset($taxitem['Override']) ? $taxitem['Override'] : $taxitem['Value']; } } $inv->ex_rate = $cart->ex_rate; $inv_no = add_supp_invoice($inv); commit_transaction(); // save PO+GRN+PI // FIXME payment for cash terms. (Needs cash account selection) unset($_SESSION['PO']); meta_forward($_SERVER['PHP_SELF'], "AddedPI={$inv_no}"); } else { // order modification $order_no = update_po($cart); unset($_SESSION['PO']); meta_forward($_SERVER['PHP_SELF'], "AddedID={$order_no}&Updated=1"); } } }
function print_invoices() { global $path_to_root, $alternative_tax_include_on_docs, $suppress_tax_rates, $no_zero_lines_amount; include_once $path_to_root . "/reporting/includes/pdf_report.inc"; $from = $_POST['PARAM_0']; $to = $_POST['PARAM_1']; $currency = $_POST['PARAM_2']; $email = $_POST['PARAM_3']; $pay_service = $_POST['PARAM_4']; $comments = $_POST['PARAM_5']; $customer = $_POST['PARAM_6']; $orientation = $_POST['PARAM_7']; if (!$from || !$to) { return; } $orientation = $orientation ? 'L' : 'P'; $dec = user_price_dec(); $fno = explode("-", $from); $tno = explode("-", $to); $from = min($fno[0], $tno[0]); $to = max($fno[0], $tno[0]); $cols = array(4, 40, 60, 100, 200, 250, 300, 320, 400, 450, 500); // $headers in doctext.inc $aligns = array('left', 'left', 'left', 'left', 'right', 'right', 'right', 'right', 'right', 'right', 'right'); //$params = array('comments' => $comments); $cur = get_company_Pref('curr_default'); $company_data = get_company_prefs(); if ($email == 0) { $rep = new FrontReport(_('INVOICE'), "InvoiceBulk", user_pagesize(), 9, $orientation); } if ($orientation == 'L') { recalculate_cols($cols); } for ($i = $from; $i <= $to; $i++) { if (!exists_customer_trans(ST_SALESINVOICE, $i)) { continue; } $sign = 1; $myrow = get_customer_trans($i, ST_SALESINVOICE); if ($customer && $myrow['debtor_no'] != $customer) { continue; } $baccount = get_default_bank_account($myrow['curr_code']); $params['bankaccount'] = $baccount['id']; $branch = get_branch($myrow["branch_code"]); $sales_order = get_sales_order_header($myrow["order_"], ST_SALESORDER); if ($email == 1) { $rep = new FrontReport("", "", user_pagesize(), 9, $orientation); //$rep->title = _('INVOICE'); $rep->filename = "Invoice" . $myrow['reference'] . ".pdf"; } $rep->SetHeaderType(0); $rep->currency = $cur; $rep->Font(); $rep->Info(null, $cols, null, $aligns); //$contacts = get_branch_contacts($branch['branch_code'], 'invoice', $branch['debtor_no'], true); //$baccount['payment_service'] = $pay_service; $salesman = get_imc_code($branch['branch_code']); $pay_term = get_payment_terms($myrow['payment_terms']); $branch_data = get_branch_accounts($myrow['branch_code']); $dt = get_discount($branch_data['sales_discount_account'], $myrow['type'], $myrow['trans_no']); $invoice_no = get_custom_no($myrow['trans_no'], $myrow['type']); $contact = getContactPerson($myrow['salesman'], $myrow['debtor_no'], $branch['branch_code']); $rep->NewPage(); $result = get_customer_trans_details(ST_SALESINVOICE, $i); $SubTotal = 0; $rep->NewLine(8); $rep->TextCol(2, 7, _("CHARGE INVOICE # " . $invoice_no)); $rep->TextCol(8, 9, $myrow['TranDate']); $rep->NewLine(); $rep->TextCol(2, 7, $branch['br_name']); if ($dt != 0) { //$display_bulk_discount = (($sub_total - $myrow['Total']) / $sub_total) * 100; $tot = $myrow['Total'] + $dt; $dscnt = ($tot - $myrow['Total']) / $tot * 100; //$dscnt = ($dt / $myrow['Total']) * 100; $significant = strlen(substr(strrchr($dscnt, "."), 1)); if ($significant > 2) { $rep->TextCol(7, 9, floor($dscnt) . "%"); } else { $rep->TextCol(7, 9, $dscnt . "%"); } } $rep->NewLine(); $rep->TextCol(2, 7, $branch['branch_ref']); $rep->TextCol(8, 9, $salesman); $rep->NewLine(); $rep->TextCol(2, 6, $contact); if ($pay_term['terms'] == 'Cash Only') { $rep->TextCol(8, 9, $pay_term['terms']); } else { $rep->TextCol(7, 10, $pay_term['terms']); } $rep->NewLine(); $oldrow = $rep->row; $newrow = $rep->row; $rep->TextColLines(2, 6, $branch['br_address'], -2); $rep->row = $oldrow; $rep->NewLine(5); $rep->Font('bold'); //$rep->Line($rep->row + 10); //$rep->TextCol(2,5, _("Item Description")); //$rep->TextCol(5,6, _("Quantity")); //$rep->TextCol(7,8, _("Unit Price")); //$rep->TextCol(9,10, _("Total Amount")); //$rep->Line($rep->row - 4); $rep->NewLine(2); $rep->Font(); while ($myrow2 = db_fetch($result)) { if ($myrow2["quantity"] == 0) { continue; } $Net = round2($sign * ((1 - $myrow2["discount_percent"]) * $myrow2["unit_price"] * $myrow2["quantity"]), user_price_dec()); $Net2 = round2($sign * ($myrow2["unit_price"] * $myrow2["quantity"]), user_price_dec()); $SubTotal += $Net; $DisplayPrice = number_format2($myrow2["unit_price"], $dec); $DisplayQty = number_format2($sign * $myrow2["quantity"], get_qty_dec($myrow2['stock_id'])); $DisplayNet = number_format2($Net, $dec); $dNet = number_format2($Net2, $dec); /*if ($myrow2["discount_percent"]==0) $DisplayDiscount =""; else $DisplayDiscount = number_format2($myrow2["discount_percent"]*100,user_percent_dec()) . "%";*/ //if ($myrow["ov_discount"]==0) // $DisplayDiscount =""; //else //$DisplayDiscount = number_format2($myrow["ov_discount"]/$myrow["ov_amount"] * 100,user_percent_dec()) . "%"; //$rep->TextCol(0, 3, $myrow2['stock_id'], -2); $oldrow = $rep->row; $rep->TextColLines(0, 5, $myrow2['StockDescription'], -2); $newrow = $rep->row; $rep->row = $oldrow; if ($Net != 0.0 || !is_service($myrow2['mb_flag']) || !isset($no_zero_lines_amount) || $no_zero_lines_amount == 0) { $rep->TextCol(5, 6, $DisplayQty . " " . $myrow2['units']); //$rep->TextCol(5, 6, $myrow2['units'], -2); $rep->TextCol(7, 8, $DisplayPrice, -2); //$rep->TextCol(5, 6, $DisplayDiscount, -2); $rep->TextCol(8, 10, $dNet, -2); } $rep->row = $newrow; //$rep->NewLine(1); if ($rep->row < $rep->bottomMargin + 15 * $rep->lineHeight) { $rep->NewPage(); } } $memo = get_comments_string(ST_SALESINVOICE, $i); if ($memo != "") { $rep->NewLine(); $rep->TextColLines(1, 5, $memo, -2); } $DisplayNet = number_format2($SubTotal, $dec); $DisplaySubTot = number_format2($SubTotal, $dec); $DisplayFreight = number_format2($sign * $myrow["ov_freight"], $dec); $DisplayTots = number_format2($myrow['Total'], $dec); $DisplayDiscount = number_format2($SubTotal - $myrow['Total'], $dec); $rep->row = $rep->bottomMargin + 30 * $rep->lineHeight; $doctype = ST_SALESINVOICE; $rep->NewLine(); $rep->Font('bold'); $rep->TextCol(9, 10, $DisplayNet, -2); $rep->NewLine(); //$rep->TextCol(8, 9, _("Less discount: ")); $rep->TextCol(9, 10, $DisplayDiscount, -2); $rep->NewLine(); //$rep->TextCol(8, 9, _("Net Amount : "), -2); $rep->TextCol(9, 10, $DisplayTots, -2); $rep->NewLine(); /*$tax_items = get_trans_tax_details(ST_SALESINVOICE, $i); $first = true; while ($tax_item = db_fetch($tax_items)) { if ($tax_item['amount'] == 0) continue; $DisplayTax = number_format2($sign*$tax_item['amount'], $dec); if (isset($suppress_tax_rates) && $suppress_tax_rates == 1) $tax_type_name = $tax_item['tax_type_name']; else $tax_type_name = $tax_item['tax_type_name']." (".$tax_item['rate']."%) "; if ($tax_item['included_in_price']) { if (isset($alternative_tax_include_on_docs) && $alternative_tax_include_on_docs == 1) { if ($first) { $rep->TextCol(3, 6, _("Total Tax Excluded"), -2); $rep->TextCol(6, 7, number_format2($sign*$tax_item['net_amount'], $dec), -2); $rep->NewLine(); } $rep->TextCol(3, 6, $tax_type_name, -2); $rep->TextCol(6, 7, $DisplayTax, -2); $first = false; } else $rep->TextCol(3, 7, _("Included") . " " . $tax_type_name . _("Amount") . ": " . $DisplayTax, -2); } else { $rep->TextCol(3, 6, $tax_type_name, -2); $rep->TextCol(6, 7, $DisplayTax, -2); } $rep->NewLine(); } $rep->NewLine(); $DisplayTotal = number_format2($sign*($myrow["ov_freight"] + $myrow["ov_gst"] + $myrow["ov_amount"]+$myrow["ov_freight_tax"]),$dec);*/ //$rep->Font('bold'); //$rep->TextCol(3, 6, _("TOTAL INVOICE"), - 2); //$rep->TextCol(6, 7, $DisplayTotal, -2); //$words = price_in_words($myrow['Total'], ST_SALESINVOICE); //if ($words != "") //{ // $rep->NewLine(1); // $rep->TextCol(1, 7, $myrow['curr_code'] . ": " . $words, - 2); //} //$rep->Font(); if ($email == 1) { $rep->End($email); } } if ($email == 0) { $rep->End(); } }
function print_sales_orders() { global $path_to_root, $print_as_quote, $no_zero_lines_amount; include_once $path_to_root . "/reporting/includes/pdf_report.inc"; $from = $_POST['PARAM_0']; $to = $_POST['PARAM_1']; $currency = $_POST['PARAM_2']; $email = $_POST['PARAM_3']; $print_as_quote = $_POST['PARAM_4']; $comments = $_POST['PARAM_5']; $orientation = $_POST['PARAM_6']; if (!$from || !$to) { return; } $orientation = $orientation ? 'L' : 'P'; $dec = user_price_dec(); $cols = array(4, 60, 225, 300, 325, 385, 450, 515); // $headers in doctext.inc $aligns = array('left', 'left', 'right', 'left', 'right', 'right', 'right'); $params = array('comments' => $comments); $cur = get_company_Pref('curr_default'); if ($email == 0) { if ($print_as_quote == 0) { $rep = new FrontReport(_("SALES ORDER"), "SalesOrderBulk", user_pagesize(), 9, $orientation); } else { $rep = new FrontReport(_("QUOTE"), "QuoteBulk", user_pagesize(), 9, $orientation); } } if ($orientation == 'L') { recalculate_cols($cols); } for ($i = $from; $i <= $to; $i++) { $myrow = get_sales_order_header($i, ST_SALESORDER); $baccount = get_default_bank_account($myrow['curr_code']); $params['bankaccount'] = $baccount['id']; $branch = get_branch($myrow["branch_code"]); if ($email == 1) { $rep = new FrontReport("", "", user_pagesize(), 9, $orientation); if ($print_as_quote == 1) { $rep->title = _('QUOTE'); $rep->filename = "Quote" . $i . ".pdf"; } else { $rep->title = _("SALES ORDER"); $rep->filename = "SalesOrder" . $i . ".pdf"; } } else { $rep->title = $print_as_quote == 1 ? _("QUOTE") : _("SALES ORDER"); } $rep->SetHeaderType('Header2'); $rep->currency = $cur; $rep->Font(); $rep->Info($params, $cols, null, $aligns); $contacts = get_branch_contacts($branch['branch_code'], 'order', $branch['debtor_no'], true); $rep->SetCommonData($myrow, $branch, $myrow, $baccount, ST_SALESORDER, $contacts); $rep->NewPage(); $result = get_sales_order_details($i, ST_SALESORDER); $SubTotal = 0; $items = $prices = array(); while ($myrow2 = db_fetch($result)) { $Net = round2((1 - $myrow2["discount_percent"]) * $myrow2["unit_price"] * $myrow2["quantity"], user_price_dec()); $prices[] = $Net; $items[] = $myrow2['stk_code']; $SubTotal += $Net; $DisplayPrice = number_format2($myrow2["unit_price"], $dec); $DisplayQty = number_format2($myrow2["quantity"], get_qty_dec($myrow2['stk_code'])); $DisplayNet = number_format2($Net, $dec); if ($myrow2["discount_percent"] == 0) { $DisplayDiscount = ""; } else { $DisplayDiscount = number_format2($myrow2["discount_percent"] * 100, user_percent_dec()) . "%"; } $rep->TextCol(0, 1, $myrow2['stk_code'], -2); $oldrow = $rep->row; $rep->TextColLines(1, 2, $myrow2['description'], -2); $newrow = $rep->row; $rep->row = $oldrow; if ($Net != 0.0 || !is_service($myrow2['mb_flag']) || !isset($no_zero_lines_amount) || $no_zero_lines_amount == 0) { $rep->TextCol(2, 3, $DisplayQty, -2); $rep->TextCol(3, 4, $myrow2['units'], -2); $rep->TextCol(4, 5, $DisplayPrice, -2); $rep->TextCol(5, 6, $DisplayDiscount, -2); $rep->TextCol(6, 7, $DisplayNet, -2); } $rep->row = $newrow; //$rep->NewLine(1); if ($rep->row < $rep->bottomMargin + 15 * $rep->lineHeight) { $rep->NewPage(); } } if ($myrow['comments'] != "") { $rep->NewLine(); $rep->TextColLines(1, 5, $myrow['comments'], -2); } $DisplaySubTot = number_format2($SubTotal, $dec); $DisplayFreight = number_format2($myrow["freight_cost"], $dec); $rep->row = $rep->bottomMargin + 15 * $rep->lineHeight; $doctype = ST_SALESORDER; $rep->TextCol(3, 6, _("Sub-total"), -2); $rep->TextCol(6, 7, $DisplaySubTot, -2); $rep->NewLine(); $rep->TextCol(3, 6, _("Shipping"), -2); $rep->TextCol(6, 7, $DisplayFreight, -2); $rep->NewLine(); $DisplayTotal = number_format2($myrow["freight_cost"] + $SubTotal, $dec); if ($myrow['tax_included'] == 0) { $rep->TextCol(3, 6, _("TOTAL ORDER EX VAT"), -2); $rep->TextCol(6, 7, $DisplayTotal, -2); $rep->NewLine(); } $tax_items = get_tax_for_items($items, $prices, $myrow["freight_cost"], $myrow['tax_group_id'], $myrow['tax_included'], null); $first = true; foreach ($tax_items as $tax_item) { if ($tax_item['Value'] == 0) { continue; } $DisplayTax = number_format2($tax_item['Value'], $dec); $tax_type_name = $tax_item['tax_type_name']; if ($myrow['tax_included']) { if (isset($alternative_tax_include_on_docs) && $alternative_tax_include_on_docs == 1) { if ($first) { $rep->TextCol(3, 6, _("Total Tax Excluded"), -2); $rep->TextCol(6, 7, number_format2($sign * $tax_item['net_amount'], $dec), -2); $rep->NewLine(); } $rep->TextCol(3, 6, $tax_type_name, -2); $rep->TextCol(6, 7, $DisplayTax, -2); $first = false; } else { $rep->TextCol(3, 7, _("Included") . " " . $tax_type_name . " " . _("Amount") . ": " . $DisplayTax, -2); } } else { $SubTotal += $tax_item['Value']; $rep->TextCol(3, 6, $tax_type_name, -2); $rep->TextCol(6, 7, $DisplayTax, -2); } $rep->NewLine(); } $rep->NewLine(); $DisplayTotal = number_format2($myrow["freight_cost"] + $SubTotal, $dec); $rep->Font('bold'); $rep->TextCol(3, 6, _("TOTAL ORDER VAT INCL."), -2); $rep->TextCol(6, 7, $DisplayTotal, -2); $words = price_in_words($myrow["freight_cost"] + $SubTotal, ST_SALESORDER); if ($words != "") { $rep->NewLine(1); $rep->TextCol(1, 7, $myrow['curr_code'] . ": " . $words, -2); } $rep->Font(); if ($email == 1) { $rep->End($email); } } if ($email == 0) { $rep->End(); } }
function print_invoices() { global $path_to_root, $alternative_tax_include_on_docs, $suppress_tax_rates, $no_zero_lines_amount; include_once $path_to_root . "/reporting/includes/pdf_report.inc"; $from = $_POST['PARAM_0']; $to = $_POST['PARAM_1']; $currency = $_POST['PARAM_2']; $email = $_POST['PARAM_3']; $pay_service = $_POST['PARAM_4']; $comments = $_POST['PARAM_5']; $customer = $_POST['PARAM_6']; $orientation = $_POST['PARAM_7']; if (!$from || !$to) { return; } $orientation = $orientation ? 'L' : 'P'; $dec = user_price_dec(); $fno = explode("-", $from); $tno = explode("-", $to); $from = min($fno[0], $tno[0]); $to = max($fno[0], $tno[0]); $cols = array(-15, 10, 30, 50, 80, 240, 300, 340, 360, 400); // $headers in doctext.inc $aligns = array('right', 'left', 'left', 'left', 'left', 'left', 'right', 'right', 'right', 'right'); $params = array('comments' => $comments); $cur = get_company_Pref('curr_default'); if ($email == 0) { $rep = new FrontReport(_('INVOICE'), "InvoiceBulk", user_pagesize(), 9, $orientation); } if ($orientation == 'L') { recalculate_cols($cols); } for ($i = $from; $i <= $to; $i++) { if (!exists_customer_trans(ST_SALESINVOICE, $i)) { continue; } $sign = 1; $myrow = get_customer_trans($i, ST_SALESINVOICE); if ($customer && $myrow['debtor_no'] != $customer) { continue; } $baccount = get_default_bank_account($myrow['curr_code']); $params['bankaccount'] = $baccount['id']; $branch = get_branch($myrow["branch_code"]); $salesm = get_salesman_name($branch['salesman']); $sales_order = get_sales_order_header($myrow["order_"], ST_SALESORDER); if ($email == 1) { $rep = new FrontReport("", "", user_pagesize(), 9, $orientation); $rep->title = _('INVOICE'); $rep->filename = "Invoice" . $myrow['reference'] . ".pdf"; } $rep->SetHeaderType(0); $rep->currency = $cur; $rep->Font(); $rep->Info(null, $cols, null, $aligns); $contacts = get_branch_contacts($branch['branch_code'], 'invoice', $branch['debtor_no'], true); $baccount['payment_service'] = $pay_service; $rep->SetCommonData($myrow, $branch, $sales_order, $baccount, ST_SALESINVOICE, $contacts); $rep->NewPage(); $result = get_customer_trans_details(ST_SALESINVOICE, $i); $SubTotal = 0; $invoice_no = get_custom_no($myrow['trans_no'], ST_SALESINVOICE); $rep->NewLine(5); $rep->TextCol(2, 5, $branch['br_name']); $rep->TextCol(7, 9, $myrow['TranDate']); $rep->NewLine(); $rep->TextCol(2, 10, $branch['br_address']); $rep->TextCol(7, 9, "SI - " . $invoice_no); $rep->NewLine(); $rep->TextCol(0, 2, "Contact: "); $rep->TextCol(2, 5, $contacts["name"] . $contacts["name2"]); $rep->TextCol(6, 9, "IMC: " . $salesm); $rep->NewLine(); $rep->TextCol(2, 5, ""); $rep->NewLine(); $rep->TextCol(2, 5, ""); $rep->NewLine(3); //$rep->NewLine(2); $ent = 0; while ($myrow2 = db_fetch($result)) { if ($myrow2["quantity"] == 0) { continue; } $Net = round2($sign * ((1 - $myrow2["discount_percent"]) * $myrow2["unit_price"] * $myrow2["quantity"]), user_price_dec()); $SubTotal += $Net; $DisplayPrice = number_format2($myrow2["unit_price"], 2); $DisplayQty = number_format2($sign * $myrow2["quantity"], get_qty_dec($myrow2['stock_id'])); $DisplayNet = number_format2($Net, 2); if ($myrow2["discount_percent"] == 0) { $DisplayDiscount = ""; } else { $DisplayDiscount = number_format2($myrow2["discount_percent"] * 100, 2) . "%"; } //$rep->TextCol(3, 4, $myrow2['stock_id'], -2); $oldrow = $rep->row; $rep->TextColLines(4, 6, $myrow2['StockDescription'], -2); $newrow = $rep->row; $rep->row = $oldrow; $ent++; if ($Net != 0.0 || !is_service($myrow2['mb_flag']) || !isset($no_zero_lines_amount) || $no_zero_lines_amount == 0) { $rep->TextCol(2, 3, $DisplayQty, -2); $rep->TextCol(3, 4, $myrow2['units'], -2); $rep->TextCol(6, 7, $DisplayPrice, -2); $rep->TextCol(7, 9, $DisplayNet, -2); } $rep->row = $newrow; //$rep->NewLine(1); if ($rep->row < $rep->bottomMargin + 15 * $rep->lineHeight) { $rep->NewPage(); } } $memo = get_comments_string(ST_SALESINVOICE, $i); if ($memo != "") { $rep->NewLine(); $rep->TextColLines(1, 5, $memo, -2); } $DisplaySubTot = $SubTotal; $rep->NewLine(8 - $ent); $doctype = ST_SALESINVOICE; $tot = $sign * ($myrow["ov_freight"] + $myrow["ov_gst"] + $myrow["ov_amount"] + $myrow["ov_freight_tax"]); if ($tot != $SubTotal) { $discount = $SubTotal * ($myrow['bulk_discount'] / 100); } $rep->AmountCol(7, 9, $DisplaySubTot, 2); $rep->NewLine(); if ($myrow['bulk_discount'] != 0) { $rep->TextCol(5, 7, "Less Discount: " . $myrow['bulk_discount'] . "%"); } $rep->AmountCol(7, 9, $discount, 2); $rep->NewLine(); $DisplayTotal = $sign * ($myrow["ov_freight"] + $myrow["ov_gst"] + $myrow["ov_amount"] + $myrow["ov_freight_tax"]); $rep->Font('bold'); $rep->AmountCol(7, 9, $DisplayTotal, 2); } if ($email == 0) { $rep->End(); } }
function Trapez($bottom, $top, $side, $progress = 0) { $width = 350; $height = 250; $paddingX_top = 110; $paddingX_bottom = 20; $paddingY = 50; $radius = 40; $Ax = $paddingX_bottom; $Ay = $height - $paddingY; $Bx = $width - $paddingX_bottom; $By = $height - $paddingY; $Cx = $width - $paddingX_top; $Cy = $paddingY; $Dx = $paddingX_top; $Dy = $paddingY; $Ex = $paddingX_top; $Ey = $height - $paddingY; $Fx = $width - $paddingX_top; $Fy = $height - $paddingY; $svg = '<div class="img-question text-center"> <svg width="' . $width . '" height="' . $height . '">'; // Sides $svg .= DrawLine($Ax, $Ay, $Bx, $By, 'black', 2); $svg .= DrawLine($Bx, $By, $Cx, $Cy, 'black', 2); $svg .= DrawLine($Cx, $Cy, $Dx, $Dy, 'black', 2); $svg .= DrawLine($Dx, $Dy, $Ax, $Ay, 'black', 2); // Nodes $svg .= DrawText($Ax - 13, $Ay, '$A$', 12); $svg .= DrawText($Bx + 13, $By, '$B$', 12); $svg .= DrawText($Cx + 13, $Cy, '$C$', 12); $svg .= DrawText($Dx - 13, $Dy, '$D$', 12); // Arcs $svg .= DrawArc($Ax, $Ay, $Bx, $By, $Dx, $Dy, $radius); $svg .= DrawArc($Bx, $By, $Cx, $Cy, $Ax, $Ay, $radius); $svg .= DrawArc($Cx, $Cy, $Dx, $Dy, $Bx, $By, $radius); $svg .= DrawArc($Dx, $Dy, $Ax, $Ay, $Cx, $Cy, $radius); // Lengths $svg .= DrawText(($Ax + $Bx) / 2, ($Ay + $By) / 2 + 17, '$' . $bottom . '$', 12); $svg .= DrawText(($Bx + $Cx) / 2 + 15, ($By + $Cy) / 2 - 5, '$' . round2($side) . '$', 12); $svg .= DrawText(($Cx + $Dx) / 2 + 5, ($Cy + $Dy) / 2 - 5, '$' . $top . '$', 12); $svg .= DrawText(($Dx + $Ax) / 2 - 15, ($Dy + $Ay) / 2 - 5, '$' . round2($side) . '$', 12); $svg .= '</svg></div>'; return $svg; }
function print_trial_balance() { global $path_to_root; global $pdeb, $pcre, $cdeb, $ccre, $tdeb, $tcre, $pbal, $cbal, $tbal; $dim = get_company_pref('use_dimension'); $dimension = $dimension2 = 0; $from = $_POST['PARAM_0']; $to = $_POST['PARAM_1']; $zero = $_POST['PARAM_2']; $balances = $_POST['PARAM_3']; if ($dim == 2) { $dimension = $_POST['PARAM_4']; $dimension2 = $_POST['PARAM_5']; $comments = $_POST['PARAM_6']; $orientation = $_POST['PARAM_7']; $destination = $_POST['PARAM_8']; } else { if ($dim == 1) { $dimension = $_POST['PARAM_4']; $comments = $_POST['PARAM_5']; $orientation = $_POST['PARAM_6']; $destination = $_POST['PARAM_7']; } else { $comments = $_POST['PARAM_4']; $orientation = $_POST['PARAM_5']; $destination = $_POST['PARAM_6']; } } if ($destination) { include_once $path_to_root . "/reporting/includes/excel_report.inc"; } else { include_once $path_to_root . "/reporting/includes/pdf_report.inc"; } $orientation = $orientation ? 'L' : 'P'; $dec = user_price_dec(); $cols2 = array(0, 50, 190, 310, 430, 530); //-------------0--1---2----3----4----5-- $headers2 = array('', '', _('Brought Forward'), _('This Period'), _('Balance')); $aligns2 = array('left', 'left', 'left', 'left', 'left'); $cols = array(0, 50, 150, 210, 270, 330, 390, 450, 510, 570); //------------0--1---2----3----4----5----6----7----8-- $headers = array(_('Account'), _('Account Name'), _('Debit'), _('Credit'), _('Debit'), _('Credit'), _('Debit'), _('Credit')); $aligns = array('left', 'left', 'right', 'right', 'right', 'right', 'right', 'right'); if ($dim == 2) { $params = array(0 => $comments, 1 => array('text' => _('Period'), 'from' => $from, 'to' => $to), 2 => array('text' => _('Dimension') . " 1", 'from' => get_dimension_string($dimension), 'to' => ''), 3 => array('text' => _('Dimension') . " 2", 'from' => get_dimension_string($dimension2), 'to' => '')); } else { if ($dim == 1) { $params = array(0 => $comments, 1 => array('text' => _('Period'), 'from' => $from, 'to' => $to), 2 => array('text' => _('Dimension'), 'from' => get_dimension_string($dimension), 'to' => '')); } else { $params = array(0 => $comments, 1 => array('text' => _('Period'), 'from' => $from, 'to' => $to)); } } $rep = new FrontReport(_('Trial Balance'), "TrialBalance", user_pagesize(), 9, $orientation); if ($orientation == 'L') { recalculate_cols($cols); recalculate_cols($cols2); } $rep->Font(); $rep->Info($params, $cols, $headers, $aligns, $cols2, $headers2, $aligns2); $rep->NewPage(); $classresult = get_account_classes(false); while ($class = db_fetch($classresult)) { $rep->Font('bold'); $rep->TextCol(0, 1, $class['cid']); $rep->TextCol(1, 4, $class['class_name']); $rep->Font(); $rep->NewLine(); //Get Account groups/types under this group/type with no parents $typeresult = get_account_types(false, $class['cid'], -1); while ($accounttype = db_fetch($typeresult)) { display_type($accounttype["id"], $accounttype["name"], $dec, $rep, $from, $to, $zero, $balances, $dimension, $dimension2); } $rep->NewLine(); } $rep->Line($rep->row); $rep->NewLine(); $rep->Font('bold'); if ($balances == 0) { $rep->TextCol(0, 2, _("Total")); $rep->AmountCol(2, 3, $pdeb, $dec); $rep->AmountCol(3, 4, $pcre, $dec); $rep->AmountCol(4, 5, $cdeb, $dec); $rep->AmountCol(5, 6, $ccre, $dec); $rep->AmountCol(6, 7, $tdeb, $dec); $rep->AmountCol(7, 8, $tcre, $dec); $rep->NewLine(); } $rep->TextCol(0, 2, _("Ending Balance")); if ($pbal >= 0.0) { $rep->AmountCol(2, 3, $pbal, $dec); } else { $rep->AmountCol(3, 4, abs($pbal), $dec); } if ($cbal >= 0.0) { $rep->AmountCol(4, 5, $cbal, $dec); } else { $rep->AmountCol(5, 6, abs($cbal), $dec); } if ($tbal >= 0.0) { $rep->AmountCol(6, 7, $tbal, $dec); } else { $rep->AmountCol(7, 8, abs($tbal), $dec); } $rep->NewLine(); $rep->Line($rep->row + 10); if (($pbal = round2($pbal, $dec)) != 0.0 && $dimension == 0 && $dimension2 == 0) { $rep->NewLine(2); $rep->Font(); $rep->TextCol(0, 8, _("The Opening Balance is not in balance, probably due to a non closed Previous Fiscalyear.")); } $rep->End(); }
function t_cpl($r, $wrap = true, $emp = true) { return currencies_span(round2(empty($r['lead']) ? 0 : $r['price'] / $r['lead']), $wrap); }
if ($limited_to > 0) { ?> <th>Повторные</th><?php } ?> <th>LP CTR</th><th>Ушло на офферы</th><th>Продаж</th><th>Конверсия</th><th>Доход</th><th>Затраты</th><th>Прибыль</th><th>ROI</th> </tr> </thead> <tbody> <?php foreach ($data as $r) { if (!$limited_to and !$r['out']) { continue; } $profit = $r['income'] - $r['price']; $roi = round($profit / $r['price'] * 100, 1); $conversion = round2($r['sale'] / $r['cnt'] * 100); $follow = round($r['out'] / $r['cnt'] * 100, 1); $repeated = $r['cnt'] - $r['unique']; if ($repeated < 0) { $repeated = 0; } $repeated = round($repeated / $r['cnt'] * 100, 1); echo '<tr><td nowrap=""><a href="?act=reports&type=targetreport&subtype=daily&limited_to=' . $r['id'] . '&group_by=campaign_name">' . $r['name'] . '</a></td><td>' . $r['cnt'] . '</td> ' . ($limited_to > 0 ? '<td>' . $repeated . '%</td>' : '') . '<td>' . $follow . '%</td><td>' . $r['out'] . '</td><td>' . $r['sale'] . '</td><td>' . $conversion . '%</td><td>' . $r['income'] . '</td><td>' . $r['price'] . '</td><td>' . $profit . '</td><td>' . $roi . '%</td></tr>'; } ?> </tbody> </table> </div> </div>
end_table(1); // outer table $result = get_customer_trans_details(ST_SALESINVOICE, $trans_id); start_table(TABLESTYLE, "width=95%"); if (db_num_rows($result) > 0) { $th = array(_("Item Code"), _("Item Description"), _("Quantity"), _("Unit"), _("Price"), _("Discount %"), _("Total")); table_header($th); $k = 0; //row colour counter $sub_total = 0; while ($myrow2 = db_fetch($result)) { if ($myrow2["quantity"] == 0) { continue; } alt_table_row_color($k); $value = round2((1 - $myrow2["discount_percent"]) * $myrow2["unit_price"] * $myrow2["quantity"], user_price_dec()); $sub_total += $value; if ($myrow2["discount_percent"] == 0) { $display_discount = ""; } else { $display_discount = percent_format($myrow2["discount_percent"] * 100) . "%"; } label_cell($myrow2["stock_id"]); label_cell($myrow2["StockDescription"]); qty_cell($myrow2["quantity"], false, get_qty_dec($myrow2["stock_id"])); label_cell($myrow2["units"], "align=right"); amount_cell($myrow2["unit_price"]); label_cell($display_discount, "nowrap align=right"); amount_cell($value); end_row(); }
function print_invoices() { global $path_to_root, $alternative_tax_include_on_docs, $suppress_tax_rates, $no_zero_lines_amount; include_once $path_to_root . "/reporting/includes/pdf_report.inc"; $from = $_POST['PARAM_0']; $to = $_POST['PARAM_1']; $currency = $_POST['PARAM_2']; $email = $_POST['PARAM_3']; $pay_service = $_POST['PARAM_4']; $comments = $_POST['PARAM_5']; $orientation = $_POST['PARAM_6']; $TotalDiscount = 0; if (!$from || !$to) { return; } $orientation = $orientation ? 'L' : 'P'; $dec = user_price_dec(); $fno = explode("-", $from); $tno = explode("-", $to); $from = min($fno[0], $tno[0]); $to = max($fno[0], $tno[0]); $cols = array(4, 60, 225, 300, 325, 385, 450, 515); // $headers in doctext.inc $aligns = array('left', 'left', 'right', 'left', 'right', 'right', 'right'); $params = array('comments' => $comments); $cur = get_company_Pref('curr_default'); if ($email == 0) { $rep = new FrontReport(_('INVOICE'), "InvoiceBulk", user_pagesize(), 9, $orientation); } if ($orientation == 'L') { recalculate_cols($cols); } for ($i = $from; $i <= $to; $i++) { if (!exists_customer_trans(ST_SALESINVOICE, $i)) { continue; } $sign = 1; $myrow = get_customer_trans($i, ST_SALESINVOICE); $transId = get_payment_id($i); $urrow = get_customer_trans($transId['trans_no_from'], ST_CUSTPAYMENT); $baccount = get_default_bank_account($myrow['curr_code']); $params['bankaccount'] = $baccount['id']; $branch = get_branch($myrow["branch_code"]); $sales_order = get_sales_order_header($myrow["order_"], ST_SALESORDER); if ($email == 1) { $rep = new FrontReport("", "", user_pagesize(), 9, $orientation); $rep->title = _('INVOICE'); $rep->filename = "Invoice" . $myrow['reference'] . ".pdf"; } $rep->SetHeaderType('Header2'); $rep->currency = $cur; $rep->Font(); $rep->Info($params, $cols, null, $aligns); $contacts = get_branch_contacts($branch['branch_code'], 'invoice', $branch['debtor_no'], true); $baccount['payment_service'] = $pay_service; $rep->SetCommonData($myrow, $branch, $sales_order, $baccount, ST_SALESINVOICE, $contacts); $rep->NewPage(); $result = get_customer_trans_details(ST_SALESINVOICE, $i); // print_r($result); $SubTotal = 0; while ($myrow2 = db_fetch($result)) { if ($myrow2["quantity"] == 0) { continue; } $Net = round2($sign * ((1 - $myrow2["discount_percent"]) * $myrow2["unit_price"] * $myrow2["quantity"]), user_price_dec()); $SubTotal += $Net; $DisplayPrice = number_format2($myrow2["unit_price"], $dec); $DisplayQty = number_format2($sign * $myrow2["quantity"], get_qty_dec($myrow2['stock_id'])); $DisplayNet = number_format2($Net, $dec); if ($myrow2["discount_percent"] == 0) { $DisplayDiscount = 0; } else { $DisplayDiscount = number_format2($myrow2["discount_percent"] * 100, user_percent_dec()) . "%"; } $rep->fontSize += 5; $rep->TextCol(0, 1, $myrow2['stock_id'], -2); $oldrow = $rep->row; $rep->TextColLines(1, 5, $myrow2['StockDescription'], -2); $newrow = $rep->row; $rep->row = $oldrow; if ($Net != 0.0 || !is_service($myrow2['mb_flag']) || !isset($no_zero_lines_amount) || $no_zero_lines_amount == 0) { //$rep->TextCol(2, 3, $DisplayQty, -2); //$rep->TextCol(3, 4, $myrow2['units'], -2); $rep->TextCol(5, 6, $DisplayPrice, -2); //$rep->TextCol(5, 6, $DisplayDiscount, -2); $rep->TextCol(6, 7, $DisplayNet, -2); $TotalDiscount += $DisplayPrice * ($DisplayDiscount / 100); } $rep->row = $newrow; //$rep->NewLine(1); if ($rep->row < $rep->bottomMargin + 15 * $rep->lineHeight) { $rep->NewPage(); } $rep->fontSize -= 5; } $memo = get_comments_string(ST_SALESINVOICE, $i); if ($memo != "") { $rep->NewLine(); $rep->TextColLines(1, 5, $memo, -2); } $DisplaySubTot = number_format2($SubTotal, $dec); $DisplayFreight = number_format2($sign * $myrow["ov_freight"], $dec); //$customer_record = get_customer_details($myrow['reference']); $rep->row = $rep->bottomMargin + 15 * $rep->lineHeight; $doctype = ST_SALESINVOICE; $rep->fontSize += 4; $rep->TextCol(3, 6, _("Total: "), -2); $rep->TextCol(6, 7, $DisplaySubTot + $TotalDiscount, -2); //$rep->TextCol(6, 7, $DisplaySubTot, -2); $rep->NewLine(); if ($TotalDiscount > 0 || $urrow['ov_discount'] > 0) { $rep->TextCol(3, 6, _("Discount(s)") . ": ", -2); $rep->TextCol(6, 7, '(' . ($TotalDiscount + $urrow['ov_discount']) . ')', -2); $rep->NewLine(); } // if($urrow['ov_discount']>0) // { // $rep->TextCol(3, 6, _("Cash Discount") . ": ", -2); // $rep->TextCol(6, 7, '('.$urrow['ov_discount'].')', -2); // $rep->NewLine(); // } $rep->TextCol(3, 6, _("Sub-total"), -2); $rep->TextCol(6, 7, $DisplaySubTot - $urrow['ov_discount'], -2); $rep->NewLine(); $rep->TextCol(3, 6, _("Paid"), -2); $rep->TextCol(6, 7, $transId['amt'], -2); $rep->NewLine(); $rep->TextCol(3, 6, _("Due"), -2); $rep->TextCol(6, 7, $DisplaySubTot - $urrow['ov_discount'] - $transId['amt'], -2); $rep->NewLine(); $tax_items = get_trans_tax_details(ST_SALESINVOICE, $i); $first = true; while ($tax_item = db_fetch($tax_items)) { if ($tax_item['amount'] == 0) { continue; } $DisplayTax = number_format2($sign * $tax_item['amount'], $dec); if (isset($suppress_tax_rates) && $suppress_tax_rates == 1) { $tax_type_name = $tax_item['tax_type_name']; } else { $tax_type_name = $tax_item['tax_type_name'] . " (" . $tax_item['rate'] . "%) "; } // if($TotalDiscount>0){ // $rep->TextCol(3, 7, _("Total Discount") . ": " . $TotalDiscount.'+'.$urrow['ov_discount'], -2); // $rep->NewLine(); // } if ($tax_item['included_in_price']) { if (isset($alternative_tax_include_on_docs) && $alternative_tax_include_on_docs == 1) { if ($first) { $rep->TextCol(3, 6, _("Total Tax Excluded"), -2); $rep->TextCol(6, 7, number_format2($sign * $tax_item['net_amount'], $dec), -2); $rep->NewLine(); } $rep->TextCol(3, 6, $tax_type_name, -2); $rep->TextCol(6, 7, $DisplayTax, -2); $first = false; } //else // $rep->TextCol(3, 7, _("Included") . " " . $tax_type_name . _("Amount") . ": " . $DisplayTax, -2); } else { $rep->TextCol(3, 6, $tax_type_name, -2); $rep->TextCol(6, 7, $DisplayTax, -2); } $rep->NewLine(); } $rep->NewLine(); $DisplayTotal = number_format2($sign * ($myrow["ov_freight"] + $myrow["ov_gst"] + $myrow["ov_amount"] + $myrow["ov_freight_tax"]), $dec); $rep->Font('bold'); $rep->TextCol(3, 6, _("TOTAL INVOICE"), -2); $rep->TextCol(6, 7, $DisplayTotal - $urrow['ov_discount'], -2); //$words = price_in_words($myrow['Total'], ST_SALESINVOICE); $words = price_in_words($transId['amt'], 0); // $words =$myrow['Total']; if ($words != "") { $rep->NewLine(1); $rep->TextCol(1, 7, $myrow['curr_code'] . ": " . $words, -2); } $rep->fontSize -= 4; $rep->Font(); if ($email == 1) { $rep->End($email); } } if ($email == 0) { $rep->End(); } }
function print_customer_balances() { global $path_to_root, $systypes_array; $from = $_POST['PARAM_0']; $to = $_POST['PARAM_1']; $fromcust = $_POST['PARAM_2']; $show_balance = $_POST['PARAM_3']; $currency = $_POST['PARAM_4']; $no_zeros = $_POST['PARAM_5']; $comments = $_POST['PARAM_6']; $orientation = $_POST['PARAM_7']; $destination = $_POST['PARAM_8']; if ($destination) { include_once $path_to_root . "/reporting/includes/excel_report.inc"; } else { include_once $path_to_root . "/reporting/includes/pdf_report.inc"; } $orientation = $orientation ? 'L' : 'P'; if ($fromcust == ALL_TEXT) { $cust = _('All'); } else { $cust = get_customer_name($fromcust); } $dec = user_price_dec(); if ($currency == ALL_TEXT) { $convert = true; $currency = _('Balances in Home Currency'); } else { $convert = false; } if ($no_zeros) { $nozeros = _('Yes'); } else { $nozeros = _('No'); } $cols = array(0, 100, 130, 190, 250, 320, 385, 450, 515); $headers = array(_('Trans Type'), _('#'), _('Date'), _('Due Date'), _('Charges'), _('Credits'), _('Allocated'), _('Outstanding')); if ($show_balance) { $headers[7] = _('Balance'); } $aligns = array('left', 'left', 'left', 'left', 'right', 'right', 'right', 'right'); $params = array(0 => $comments, 1 => array('text' => _('Period'), 'from' => $from, 'to' => $to), 2 => array('text' => _('Customer'), 'from' => $cust, 'to' => ''), 3 => array('text' => _('Currency'), 'from' => $currency, 'to' => ''), 4 => array('text' => _('Suppress Zeros'), 'from' => $nozeros, 'to' => '')); $rep = new FrontReport(_('Customer Balances'), "CustomerBalances", user_pagesize(), 9, $orientation); if ($orientation == 'L') { recalculate_cols($cols); } $rep->Font(); $rep->Info($params, $cols, $headers, $aligns); $rep->NewPage(); $grandtotal = array(0, 0, 0, 0); $sql = "SELECT debtor_no, name, curr_code FROM " . TB_PREF . "debtors_master "; if ($fromcust != ALL_TEXT) { $sql .= "WHERE debtor_no=" . db_escape($fromcust); } $sql .= " ORDER BY name"; $result = db_query($sql, "The customers could not be retrieved"); while ($myrow = db_fetch($result)) { if (!$convert && $currency != $myrow['curr_code']) { continue; } $accumulate = 0; $rate = $convert ? get_exchange_rate_from_home_currency($myrow['curr_code'], Today()) : 1; $bal = get_open_balance($myrow['debtor_no'], $from, $convert); $init[0] = $init[1] = 0.0; $init[0] = round2(abs($bal['charges'] * $rate), $dec); $init[1] = round2(Abs($bal['credits'] * $rate), $dec); $init[2] = round2($bal['Allocated'] * $rate, $dec); if ($show_balance) { $init[3] = $init[0] - $init[1]; $accumulate += $init[3]; } else { $init[3] = round2($bal['OutStanding'] * $rate, $dec); } $res = get_transactions($myrow['debtor_no'], $from, $to); if ($no_zeros && db_num_rows($res) == 0) { continue; } $rep->fontSize += 2; $rep->TextCol(0, 2, $myrow['name']); if ($convert) { $rep->TextCol(2, 3, $myrow['curr_code']); } $rep->fontSize -= 2; $rep->TextCol(3, 4, _("Open Balance")); $rep->AmountCol(4, 5, $init[0], $dec); $rep->AmountCol(5, 6, $init[1], $dec); $rep->AmountCol(6, 7, $init[2], $dec); $rep->AmountCol(7, 8, $init[3], $dec); $total = array(0, 0, 0, 0); for ($i = 0; $i < 4; $i++) { $total[$i] += $init[$i]; $grandtotal[$i] += $init[$i]; } $rep->NewLine(1, 2); $rep->Line($rep->row + 4); if (db_num_rows($res) == 0) { $rep->NewLine(1, 2); continue; } while ($trans = db_fetch($res)) { if ($no_zeros && floatcmp($trans['TotalAmount'], $trans['Allocated']) == 0) { continue; } $rep->NewLine(1, 2); $rep->TextCol(0, 1, $systypes_array[$trans['type']]); $rep->TextCol(1, 2, $trans['reference']); $rep->DateCol(2, 3, $trans['tran_date'], true); if ($trans['type'] == ST_SALESINVOICE) { $rep->DateCol(3, 4, $trans['due_date'], true); } $item[0] = $item[1] = 0.0; if ($trans['type'] == ST_CUSTCREDIT || $trans['type'] == ST_CUSTPAYMENT || $trans['type'] == ST_BANKDEPOSIT) { $trans['TotalAmount'] *= -1; } if ($trans['TotalAmount'] > 0.0) { $item[0] = round2(abs($trans['TotalAmount']) * $rate, $dec); $rep->AmountCol(4, 5, $item[0], $dec); $accumulate += $item[0]; } else { $item[1] = round2(Abs($trans['TotalAmount']) * $rate, $dec); $rep->AmountCol(5, 6, $item[1], $dec); $accumulate -= $item[1]; } $item[2] = round2($trans['Allocated'] * $rate, $dec); $rep->AmountCol(6, 7, $item[2], $dec); if ($trans['type'] == ST_SALESINVOICE || $trans['type'] == ST_BANKPAYMENT) { $item[3] = $item[0] + $item[1] - $item[2]; } else { $item[3] = $item[0] - $item[1] + $item[2]; } if ($show_balance) { $rep->AmountCol(7, 8, $accumulate, $dec); } else { $rep->AmountCol(7, 8, $item[3], $dec); } for ($i = 0; $i < 4; $i++) { $total[$i] += $item[$i]; $grandtotal[$i] += $item[$i]; } if ($show_balance) { $total[3] = $total[0] - $total[1]; } } $rep->Line($rep->row - 8); $rep->NewLine(2); $rep->TextCol(0, 3, _('Total')); for ($i = 0; $i < 4; $i++) { $rep->AmountCol($i + 4, $i + 5, $total[$i], $dec); } $rep->Line($rep->row - 4); $rep->NewLine(2); } $rep->fontSize += 2; $rep->TextCol(0, 3, _('Grand Total')); $rep->fontSize -= 2; if ($show_balance) { $grandtotal[3] = $grandtotal[0] - $grandtotal[1]; } for ($i = 0; $i < 4; $i++) { $rep->AmountCol($i + 4, $i + 5, $grandtotal[$i], $dec); } $rep->Line($rep->row - 4); $rep->NewLine(); $rep->End(); }
function print_deliveries() { global $path_to_root, $packing_slip, $alternative_tax_include_on_docs, $suppress_tax_rates, $no_zero_lines_amount; include_once $path_to_root . "/reporting/includes/pdf_report.inc"; $from = $_POST['PARAM_0']; $to = $_POST['PARAM_1']; $email = $_POST['PARAM_2']; $packing_slip = $_POST['PARAM_3']; $comments = $_POST['PARAM_4']; $orientation = $_POST['PARAM_5']; if (!$from || !$to) { return; } $orientation = $orientation ? 'L' : 'P'; $dec = user_price_dec(); $fno = explode("-", $from); $tno = explode("-", $to); $from = min($fno[0], $tno[0]); $to = max($fno[0], $tno[0]); $cols = array(4, 60, 225, 300, 325, 385, 450, 515); // $headers in doctext.inc $aligns = array('left', 'left', 'right', 'left', 'right', 'right', 'right'); $params = array('comments' => $comments); $cur = get_company_Pref('curr_default'); if ($email == 0) { if ($packing_slip == 0) { $rep = new FrontReport(_('DELIVERY'), "DeliveryNoteBulk", user_pagesize(), 9, $orientation); } else { $rep = new FrontReport(_('PACKING SLIP'), "PackingSlipBulk", user_pagesize(), 9, $orientation); } } if ($orientation == 'L') { recalculate_cols($cols); } for ($i = $from; $i <= $to; $i++) { if (!exists_customer_trans(ST_CUSTDELIVERY, $i)) { continue; } $myrow = get_customer_trans($i, ST_CUSTDELIVERY); $branch = get_branch($myrow["branch_code"]); $sales_order = get_sales_order_header($myrow["order_"], ST_SALESORDER); // ? if ($email == 1) { $rep = new FrontReport("", "", user_pagesize(), 9, $orientation); if ($packing_slip == 0) { $rep->title = _('DELIVERY NOTE'); $rep->filename = "Delivery" . $myrow['reference'] . ".pdf"; } else { $rep->title = _('PACKING SLIP'); $rep->filename = "Packing_slip" . $myrow['reference'] . ".pdf"; } } $rep->SetHeaderType('Header2'); $rep->currency = $cur; $rep->Font(); $rep->Info($params, $cols, null, $aligns); $contacts = get_branch_contacts($branch['branch_code'], 'delivery', $branch['debtor_no'], true); $rep->SetCommonData($myrow, $branch, $sales_order, '', ST_CUSTDELIVERY, $contacts); $rep->NewPage(); $result = get_customer_trans_details(ST_CUSTDELIVERY, $i); $SubTotal = 0; while ($myrow2 = db_fetch($result)) { if ($myrow2["quantity"] == 0) { continue; } $Net = round2((1 - $myrow2["discount_percent"]) * $myrow2["unit_price"] * $myrow2["quantity"], user_price_dec()); $SubTotal += $Net; $DisplayPrice = number_format2($myrow2["unit_price"], $dec); $DisplayQty = number_format2($myrow2["quantity"], get_qty_dec($myrow2['stock_id'])); $DisplayNet = number_format2($Net, $dec); if ($myrow2["discount_percent"] == 0) { $DisplayDiscount = ""; } else { $DisplayDiscount = number_format2($myrow2["discount_percent"] * 100, user_percent_dec()) . "%"; } $rep->TextCol(0, 1, $myrow2['stock_id'], -2); $oldrow = $rep->row; $rep->TextColLines(1, 2, $myrow2['StockDescription'], -2); $newrow = $rep->row; $rep->row = $oldrow; if ($Net != 0.0 || !is_service($myrow2['mb_flag']) || !isset($no_zero_lines_amount) || $no_zero_lines_amount == 0) { $rep->TextCol(2, 3, $DisplayQty, -2); $rep->TextCol(3, 4, $myrow2['units'], -2); if ($packing_slip == 0) { $rep->TextCol(4, 5, $DisplayPrice, -2); $rep->TextCol(5, 6, $DisplayDiscount, -2); $rep->TextCol(6, 7, $DisplayNet, -2); } } $rep->row = $newrow; //$rep->NewLine(1); if ($rep->row < $rep->bottomMargin + 15 * $rep->lineHeight) { $rep->NewPage(); } } $memo = get_comments_string(ST_CUSTDELIVERY, $i); if ($memo != "") { $rep->NewLine(); $rep->TextColLines(1, 5, $memo, -2); } $DisplaySubTot = number_format2($SubTotal, $dec); $DisplayFreight = number_format2($myrow["ov_freight"], $dec); $rep->row = $rep->bottomMargin + 15 * $rep->lineHeight; $doctype = ST_CUSTDELIVERY; if ($packing_slip == 0) { $rep->TextCol(3, 6, _("Sub-total"), -2); $rep->TextCol(6, 7, $DisplaySubTot, -2); $rep->NewLine(); $rep->TextCol(3, 6, _("Shipping"), -2); $rep->TextCol(6, 7, $DisplayFreight, -2); $rep->NewLine(); $tax_items = get_trans_tax_details(ST_CUSTDELIVERY, $i); $first = true; while ($tax_item = db_fetch($tax_items)) { if ($tax_item['amount'] == 0) { continue; } $DisplayTax = number_format2($tax_item['amount'], $dec); if (isset($suppress_tax_rates) && $suppress_tax_rates == 1) { $tax_type_name = $tax_item['tax_type_name']; } else { $tax_type_name = $tax_item['tax_type_name'] . " (" . $tax_item['rate'] . "%) "; } if ($tax_item['included_in_price']) { if (isset($alternative_tax_include_on_docs) && $alternative_tax_include_on_docs == 1) { if ($first) { $rep->TextCol(3, 6, _("Total Tax Excluded"), -2); $rep->TextCol(6, 7, number_format2($tax_item['net_amount'], $dec), -2); $rep->NewLine(); } $rep->TextCol(3, 6, $tax_type_name, -2); $rep->TextCol(6, 7, $DisplayTax, -2); $first = false; } else { $rep->TextCol(3, 7, _("Included") . " " . $tax_type_name . _("Amount") . ": " . $DisplayTax, -2); } } else { $rep->TextCol(3, 6, $tax_type_name, -2); $rep->TextCol(6, 7, $DisplayTax, -2); } $rep->NewLine(); } $rep->NewLine(); $DisplayTotal = number_format2($myrow["ov_freight"] + $myrow["ov_freight_tax"] + $myrow["ov_gst"] + $myrow["ov_amount"], $dec); $rep->Font('bold'); $rep->TextCol(3, 6, _("TOTAL DELIVERY INCL. VAT"), -2); $rep->TextCol(6, 7, $DisplayTotal, -2); $words = price_in_words($myrow['Total'], ST_CUSTDELIVERY); if ($words != "") { $rep->NewLine(1); $rep->TextCol(1, 7, $myrow['curr_code'] . ": " . $words, -2); } $rep->Font(); } if ($email == 1) { $rep->End($email); } } if ($email == 0) { $rep->End(); } }
function print_grn_valuation() { global $path_to_root; $from = $_POST['PARAM_0']; $to = $_POST['PARAM_1']; $comments = $_POST['PARAM_2']; $orientation = $_POST['PARAM_3']; $destination = $_POST['PARAM_4']; if ($destination) { include_once $path_to_root . "/reporting/includes/excel_report.inc"; } else { include_once $path_to_root . "/reporting/includes/pdf_report.inc"; } $orientation = $orientation ? 'L' : 'P'; $dec = user_price_dec(); $cols = array(0, 75, 225, 260, 295, 330, 370, 410, 455, 515); $headers = array(_('Stock ID'), _('Description'), _('PO No'), _('GRN') . "#", _('Inv') . "#", _('Qty'), _('Inv Price'), _('PO Price'), _('Total')); $aligns = array('left', 'left', 'left', 'left', 'left', 'right', 'right', 'right', 'right'); $params = array(0 => $comments, 1 => array('text' => _('Period'), 'from' => $from, 'to' => $to)); $rep = new FrontReport(_('GRN Valuation Report'), "GRNValuationReport", user_pagesize(), 9, $orientation); if ($orientation == 'L') { recalculate_cols($cols); } $rep->Font(); $rep->Info($params, $cols, $headers, $aligns); $rep->NewPage(); $res = getTransactions($from, $to); $total = $qtotal = $grandtotal = 0.0; $stock_id = ''; while ($trans = db_fetch($res)) { if ($stock_id != $trans['item_code']) { if ($stock_id != '') { $rep->Line($rep->row - 4); $rep->NewLine(2); $rep->TextCol(0, 3, _('Total')); $rep->AmountCol(5, 6, $qtotal, $qdec); $rep->AmountCol(8, 9, $total, $dec); $rep->NewLine(); $total = $qtotal = 0; } $stock_id = $trans['item_code']; } $curr = get_supplier_currency($trans['supplier_id']); $rate = get_exchange_rate_from_home_currency($curr, sql2date($trans['delivery_date'])); $trans['std_cost_unit'] *= $rate; $rep->NewLine(); $rep->TextCol(0, 1, $trans['item_code']); $rep->TextCol(1, 2, $trans['description']); $rep->TextCol(2, 3, $trans['order_no']); $qdec = get_qty_dec($trans['item_code']); $rep->TextCol(3, 4, $trans['batch_no']); if ($trans['quantity_inv']) { $suppinv = getSuppInvDetails($trans['grn_item_id']); while ($inv = db_fetch($suppinv)) { $inv['inv_price'] *= $rate; $rep->TextCol(4, 5, $inv['inv_no']); $rep->AmountCol(5, 6, $inv['inv_qty'], $qdec); $rep->AmountCol(6, 7, $inv['inv_price'], $dec); $rep->AmountCol(7, 8, $trans['std_cost_unit'], $dec); $amt = round2($inv['inv_qty'] * $inv['inv_price'], $dec); $rep->AmountCol(8, 9, $amt, $dec); $rep->NewLine(); $total += $amt; $qtotal += $inv['inv_qty']; $grandtotal += $amt; } } if ($trans['qty_recd'] - $trans['quantity_inv'] != 0) { $rep->TextCol(4, 5, "--"); $rep->AmountCol(5, 6, $trans['qty_recd'] - $trans['quantity_inv'], $qdec); $rep->AmountCol(7, 8, $trans['unit_price'], $dec); $amt = round2(($trans['qty_recd'] - $trans['quantity_inv']) * $trans['unit_price'], $dec); $rep->AmountCol(8, 9, $amt, $dec); $total += $amt; $qtotal += $trans['qty_recd'] - $trans['quantity_inv']; $grandtotal += $amt; } else { $rep->NewLine(-1); } } if ($stock_id != '') { $rep->Line($rep->row - 4); $rep->NewLine(2); $rep->TextCol(0, 3, _('Total')); $rep->AmountCol(5, 6, $qtotal, $qdec); $rep->AmountCol(8, 9, $total, $dec); $rep->Line($rep->row - 4); $rep->NewLine(2); $rep->TextCol(0, 7, _('Grand Total')); $rep->AmountCol(8, 9, $grandtotal, $dec); } $rep->Line($rep->row - 4); $rep->NewLine(); $rep->End(); }