$payment->setTime(dateInput($_POST["day"] . " " . $_POST["time"])); $payment->setPhonenumber($_POST["phone"]); $payment->setName($_POST["name"]); $payment->setAccount(rand(1000, 9999)); $payment->setStatus(Payment::STATUS_COMPLETED); $payment->setAmount($amount); $payment->setPostBalance($amount); $payment->update(); print "Payment created"; } } } ////////////////////////////////////////////////////////////////////////////// // display the page $slow->assign(array("DAY" => date("d-m-Y"), "TIME" => date("H:s"))); $slow->parse(); $slow->slowPrint(); function numberInput($input) { $input = trim($input); $amount = 0; if (preg_match("/^[0-9,]+\$/", $input)) { $amount = 100 * (int) str_replace(',', '', $input); } elseif (preg_match("/^[0-9,]+\\.[0-9]\$/", $input)) { $amount = 10 * (int) str_replace(array('.', ','), '', $input); } elseif (preg_match("/^[0-9,]*\\.[0-9][0-9]\$/", $input)) { $amount = (int) str_replace(array('.', ','), '', $input); } else { $amount = (int) $input; } return $amount;
require_once "Database.php"; require_once "SlowTemplate.php"; require_once "WebUtility.php"; require_once "Payment.php"; require_once "PaymentFactory.php"; $slow = new SlowTemplate('template'); $slow->setTemplateFile('home2.tpl'); session_start(); ////////////////////////////////////////////////////////////////////////////// // handle the submission if ($_SERVER["REQUEST_METHOD"] == 'POST') { if ($_POST['__VIEWSTATE'] == $_SESSION['VIEWSTATE']) { } } ////////////////////////////////////////////////////////////////////////////// // display the page $view = WebUtility::viewstate(1476); $_SESSION['VIEWSTATE'] = $view; // Tariff's $tariffs = array('MFI Tariff 4', 'Unkown'); // page size $pagesizes = array(20, 50, 100, 500); // Search results $results = PaymentFactory::factoryAll(); foreach ($results as $result) { $slow->assign(array("RECEIPT" => $result->getReciept(), "TIME" => date("Y-m-d H:i:s", $result->getTime()), "DESCRIPTION" => "Payment received from " . $result->getPhonenumber() . " - " . $result->getName() . " Acc. " . $result->getAccount(), "STATUS" => "Completed", "AMOUNT" => number_format($result->getAmount(), 2, '.', ''), "BALANCE" => number_format($result->getPostBalance(), 2, '.', ''), "HASH" => "b142222a-59ab-2ef6-8e52-a027ca4edb21")); $slow->parse("Result"); } $slow->assign(array("VIEWSTATE" => $view, "ORGANISATION" => "MpesaPi", "USERNAME" => "Test Testson", "LOGIN_TIME" => date("Y-m-d H:i:s"), "LAST_LOGIN_TIME" => date("Y-m-d H:i:s"), "ACCOUNT_NUMBER" => '32943321-11', "TARIFF" => $tariffs[1], "SEARCH_FROM" => date("Y-m-d H:i:s"), "SEARCH_FROM_DAY" => date("Y-m-d"), "SEARCH_FROM_TIME" => "00:00", "SEARCH_UNTIL" => date("Y-m-d H:i:s"), "SEARCH_UNTIL_DAY" => date("Y-m-d"), "SEARCH_UNTIL_TIME" => "23:59", "PAGE_SIZE_INDEX" => "0", "PAGE_SIZE" => $pagesizes[0], "CHECKED_ALL" => 'checked="checked"', "CHECKED_DECLINED" => '', "CHECKED_CANCELLED" => '', "CHECKED_EXPIRED" => '', "CHECKED_PENDING" => '', "CHECKED_COMPLETED" => '', "BALANCE_UPDATED" => date("Y-m-d H:i:s"), "CURRENT_BALANCE" => " 0.00", "UNCLEARED_FUNDS" => " 0.00", "RESERVED_FUNDS" => " 0.00", "AVAILABLE_FUNDS" => " 0.00")); $slow->parse(); $slow->slowPrint();