本文整理汇总了PHP中Validate::getErrors方法的典型用法代码示例。如果您正苦于以下问题:PHP Validate::getErrors方法的具体用法?PHP Validate::getErrors怎么用?PHP Validate::getErrors使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Validate
的用法示例。
在下文中一共展示了Validate::getErrors方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: index
function index()
{
if (!empty($_POST)) {
$check = new Check();
if (!empty($_FILES["img"]["name"])) {
$target_dir = "uploads/";
$target_file = $target_dir . basename($_FILES["img"]["name"]);
$filename = $check->checkInput($_FILES['img']['name']);
$filesize = filesize($target_file);
move_uploaded_file($_FILES["img"]["tmp_name"], $target_file);
} else {
$filename = '';
$filesize = '';
}
//Получаем данные методом пост
$name = $check->checkInput($_POST['name']);
$surname = $check->checkInput($_POST['surname']);
$email = $check->checkInput($_POST['email']);
$login = $check->checkInput($_POST['login']);
$pass = $check->checkInput($_POST['pass']);
$confirmpass = $check->checkInput($_POST['confirmpass']);
$age = $check->checkInput($_POST['age']);
//Создаем массив для валидации данных
$validateArr = array('name' => $name, 'surname' => $surname, 'email' => $email, 'login' => $login, 'password' => $pass, 'confirmpass' => $confirmpass, 'age' => $age, 'filename' => $filename, 'filesize' => $filesize);
$pdo = new Db();
//класс с конфигурацией базы данных
$db = $pdo->get();
$validate = new Validate($db);
$errors = $validate->getErrors($validateArr);
//Выявляем ошибки через валидатор
if (empty($errors)) {
try {
//Сохраняем пользователя посредством паттерна Data Mapper
$user = new User();
$user->name = $name;
$user->surname = $surname;
$user->email = $email;
$user->login = $login;
$user->password = md5($pass);
$user->age = $age;
$user->filename = $filename;
$mapper = new Mapper($db);
$mapper->save($user);
$this->user = $mapper->select($user);
$this->out('profile.php');
} catch (Exception $e) {
echo "Ошибка загрузки данных <br>" . $e->getMessage();
}
} else {
foreach ($errors as $error) {
$this->error = $error . "<br>";
}
$this->out('register.php');
}
} else {
$this->out('register.php');
}
}
示例2: createPage
function createPage($smarty)
{
if (Users::loggedIn()) {
Redirect::to('?page=profile');
}
if (Input::exists()) {
if (Input::get('action') === 'register') {
$validation = new Validate();
$validation->check($_POST, array_merge(Config::get('validation/register_info'), Config::get('validation/set_password')));
if ($validation->passed()) {
try {
Users::create(array('student_id' => Input::get('sid'), 'password' => Hash::hashPassword(Input::get('password')), 'permission_group' => 1, 'name' => Input::get('name'), 'email' => Input::get('email'), 'umail' => Input::get('sid') . '@umail.leidenuniv.nl', 'phone' => Phone::formatNumber(Input::get('phone')), 'joined' => DateFormat::sql()));
Users::login(Input::get('sid'), Input::get('password'));
Notifications::addSuccess('You have been succesfully registered!');
Redirect::to('?page=profile');
} catch (Exception $e) {
Notifications::addError($e->getMessage());
}
} else {
Notifications::addValidationFail($validation->getErrors());
}
}
if (Input::get('action') === 'login') {
$validation = new Validate();
$validation->check($_POST, Config::get('validation/login'));
if ($validation->passed()) {
$login = Users::login(Input::get('sid'), Input::get('password'), Input::getAsBool('remember'));
if ($login) {
Notifications::addSuccess('You have been logged in!');
Redirect::to('?page=profile');
} else {
Notifications::addValidationFail('Invalid student number or password.');
}
} else {
Notifications::addValidationFail($validation->getErrors());
}
}
}
$smarty->assign('remember', Input::getAsBool('remember'));
$smarty->assign('name', Input::get('name'));
$smarty->assign('sid', Input::get('sid'));
$smarty->assign('email', Input::get('email'));
$smarty->assign('phone', Input::get('phone'));
return $smarty;
}
示例3: checknum
function checknum()
{
extract($_REQUEST);
require_lib("validate");
$v = new Validate();
$v->isOk($topacc, "num", 4, 4, "Invalid Main Part.");
$v->isOk($accnum, "num", 3, 3, "Invalid Sub Part.");
/* is account number valid */
if ($v->isError()) {
$e = $v->getErrors();
if (count($e) == 2) {
$err = "Invalid account number.";
} else {
$err = $e[0]["msg"];
}
} else {
/* does account number exist */
$qry = new dbSelect("accounts", "core", grp(m("cols", "accname"), m("where", "topacc='{$topacc}' AND accnum='{$accnum}'"), m("limit", "1")));
$qry->run();
if (!isset($rslt)) {
$rslt = array();
}
if ($qry->num_rows($rslt) > 0) {
$accname = $qry->fetch_result();
$err = "Account number in use: {$accname}.";
} else {
if ($accnum != "000") {
$qry->setOpt(grp(m("where", "topacc='{$topacc}'")));
$qry->run();
if ($qry->num_rows() <= 0) {
$err = "Main Account doesn't exist.";
}
}
}
}
if (!isset($err)) {
$err = "<strong>Account number valid.</strong>";
} else {
$err = "<li class='err'>{$err}</li>";
}
return $err;
}
示例4: createPage
function createPage($smarty)
{
if (!Users::loggedIn()) {
Redirect::to('?page=login');
}
if (Input::exists()) {
if (Input::get('action') === 'logout') {
if (Users::loggedIn()) {
Users::logout();
Notifications::addSuccess('You have been logged out!');
Redirect::to('?page=login');
}
}
if (Input::get('action') === 'update_info') {
$validation = new Validate();
$validation->check($_POST, Config::get('validation/user_info'));
if ($validation->passed()) {
$data = array('name' => Input::get('name'), 'student_id' => Input::get('sid'), 'email' => Input::get('email'), 'phone' => Phone::formatNumber(Input::get('phone')));
if (Users::currentUser()->update($data)) {
Notifications::addSuccess('User information updated!');
} else {
Notifications::addError('Could not update user information.');
}
} else {
Notifications::addValidationFail($validation->getErrors());
}
}
if (Input::get('action') === 'update_pass') {
$validation = new Validate();
$validation->check($_POST, array_merge(Config::get('validation/set_password'), array('password_current' => array('name' => 'Current Password', 'required' => true, 'max' => 72))));
if ($validation->passed()) {
if (Hash::checkPassword(Input::get('password_current'), Users::currentData()->password)) {
if (Users::currentUser()->update(array('password' => Hash::hashPassword(Input::get('password'))))) {
Notifications::addSuccess('Password changed!');
} else {
Notifications::addError('Could not change password.');
}
} else {
Notifications::addValidationFail('Invalid current password.');
}
} else {
Notifications::addValidationFail($validation->getErrors());
}
}
if (Input::get('action') === 'update_googleAuth') {
$validation = new Validate();
$validation->check($_POST, array('authcode' => array('name' => 'Authorisation Code', 'required' => true)));
if ($validation->passed()) {
if (Calendar::setCredentials(Input::get('authcode'))) {
Notifications::addSuccess('Google Calendar API authorized!');
} else {
Notifications::addValidationFail('Could not authorize Google Calendar API.');
}
} else {
Notifications::addValidationFail($validation->getErrors());
}
}
if (Input::get('action') === 'update_calendarAssignmentsId') {
$validation = new Validate();
$validation->check($_POST, array('calid-ass' => array('name' => 'Assignments Calendar ID', 'required' => false), 'calid-ex' => array('name' => 'Exams Calendar ID', 'required' => false)));
if ($validation->passed()) {
$data = array('calendar_assignments' => Input::get('calid-ass'), 'calendar_exams' => Input::get('calid-ex'));
if (Users::currentUser()->update($data)) {
Notifications::addSuccess('Calendar ID\'s updated!');
} else {
Notifications::addValidationFail('Could not update calendar ID\'s.');
}
} else {
Notifications::addValidationFail($validation->getErrors());
}
}
if (Input::get('action') === 'delete_googleAuth') {
Calendar::deleteCredentials();
}
if (Input::get('action') === 'update_calendarAssignments' && Users::isEditor()) {
$assignments = DB::instance()->get(Users::safeSid() . "_assignments")->results();
foreach ($assignments as $assignment) {
Calendar::updateAssignment($assignment->id);
}
}
if (Input::get('action') === 'create_database') {
if (!UserTables::hasTables()) {
UserTables::createTables();
if (Users::isGuest()) {
Users::currentUser()->update(array('permission_group' => '2'));
}
}
}
}
if (!Calendar::isReady()) {
$smarty->assign('authUrl', Calendar::getAuthUrl());
}
$smarty->assign('authCode', Input::get('authcode'));
$smarty->assign('calid_ass', Users::currentData()->calendar_assignments);
$smarty->assign('calid_ex', Users::currentData()->calendar_exams);
$smarty->assign('name', Users::currentData()->name);
$smarty->assign('sid', Users::currentData()->student_id);
$smarty->assign('email', Users::currentData()->email);
$smarty->assign('phone', Users::currentData()->phone);
return $smarty;
//.........这里部分代码省略.........
示例5: confirm
function confirm($_POST)
{
# Get vars
extract($_POST);
if (isset($all)) {
return details($_POST);
}
# validate input
require_lib("validate");
$v = new validate();
$v->isOk($budname, "string", 1, 255, "Invalid Budget Name.");
$v->isOk($budfor, "string", 1, 20, "Invalid Budget for option.");
$v->isOk($budtype, "string", 1, 20, "Invalid Budget type.");
$v->isOk($fromprd, "string", 1, 20, "Invalid Budget period.");
$v->isOk($toprd, "string", 1, 20, "Invalid Budget period.");
if ($budfor == 'acc') {
if (isset($accids)) {
foreach ($accids as $akey => $accid) {
$v->isOk($accid, "num", 1, 50, "Invalid Account number.");
foreach ($amts[$accid] as $skey => $amtr) {
$v->isOk($amts[$accid][$skey], "float", 1, 20, "Invalid Budget amount.");
}
}
} else {
$v->isOk("#", "num", 0, 0, "Error : please select at least one account.");
}
} elseif ($budfor == 'cost') {
if (isset($ccids)) {
foreach ($ccids as $akey => $ccid) {
$v->isOk($ccid, "num", 1, 50, "Invalid Cost Center.");
foreach ($amts[$ccid] as $skey => $amtr) {
$v->isOk($amts[$ccid][$skey], "float", 1, 20, "Invalid Budget amount.");
}
}
} else {
$v->isOk("#", "num", 0, 0, "Error : please select at least one cost center.");
}
}
# display errors, if any
if ($v->isError()) {
$confirm = "";
$errors = $v->getErrors();
foreach ($errors as $e) {
$confirm .= "<li class=err>{$e['msg']}</li>";
}
return details($_POST, $confirm);
}
$ce = new Validate();
if (isset($ccids)) {
foreach ($ccids as $akey => $ccid) {
$tot = array_sum($amts[$ccid]);
$yr_tot = budgetTotalFromYear($ccid, "cost");
if (strlen($yr_tot) > 0 && $tot != $yr_tot) {
$ccRs = get("cubit", "*", "costcenters", "ccid", $ccid);
$cc = pg_fetch_array($ccRs);
$cc_name = "{$cc['centercode']} - {$cc['centername']}";
$ce->addError("", "Yearly budget amount of " . CUR . "{$yr_tot} doesn't\n\t\t\t\t\tmatch proposed total amount of " . CUR . "{$tot} for Cost Center: {$cc_name}.");
}
}
} else {
if (isset($accids)) {
foreach ($accids as $akey => $accid) {
$tot = array_sum($amts[$accid]);
$yr_tot = budgetTotalFromYear($accid, "acc");
if (strlen($yr_tot) > 0 && $tot != $yr_tot) {
$accRs = get("core", "*", "accounts", "accid", $accid);
$acc = pg_fetch_array($accRs);
$acc_name = "{$acc['topacc']}/{$acc['accnum']} - {$acc['accname']}";
$ce->addError("", "Yearly budget amount of " . CUR . "{$yr_tot} doesn't\n\t\t\t\t\tmatch proposed total amount of " . CUR . "{$tot} for Account: {$acc_name}.");
}
}
}
}
$mismatches = "";
if ($ce->isError()) {
$mm = $ce->getErrors();
foreach ($mm as $e) {
$mismatches .= "<li class=err>" . $e["msg"] . "</li>";
}
}
global $BUDFOR, $TYPES, $PERIODS;
$vbudfor = $BUDFOR[$budfor];
$vbudtype = $TYPES[$budtype];
$vfromprd = $PERIODS[$fromprd];
$vtoprd = $PERIODS[$toprd];
/* Toggle Options */
$list = "";
# budget for
if ($budfor == 'cost') {
$head = "<tr><th>Cost Centers</th>";
foreach ($ccids as $ckey => $ccid) {
$ccRs = get("cubit", "*", "costcenters", "ccid", $ccid);
$cc = pg_fetch_array($ccRs);
$list .= "<tr class='bg-odd'><td><input type=hidden name='ccids[{$cc['ccid']}]' value='{$cc['ccid']}'>{$cc['centercode']} - {$cc['centername']}</td>";
foreach ($amts[$ccid] as $sprd => $amtr) {
$amtr = sprint($amtr);
$list .= "<td align=right><input type=hidden name=amts[{$cc['ccid']}][{$sprd}] value='{$amtr}'>" . CUR . " {$amtr}</td>";
}
$list .= "</tr>";
}
//.........这里部分代码省略.........
示例6: escape
$salt = Hash::salt(32);
$email_code = md5(Input::get('username') . microtime());
try {
$user->create(['username' => Input::get('username'), 'password' => Hash::make(Input::get('password'), $salt), 'salt' => $salt, 'fullname' => strip_excess(Input::get('name')), 'email' => $email, 'profile_pic' => $profilePicDest]);
/*
* TODO: Email Activation Up and Running. V(1.0)
* $mail = new Email;
* $mail->sendGmailActivation(BASE_URL . 'activate/' . $email_code );
* */
Session::flash('success', 'You registered successfully!');
Redirect::to(BASE_URL);
} catch (Exception $e) {
die($e->getMessage());
}
} else {
foreach ($validate->getErrors() as $error) {
echo $error . '<br>';
}
}
}
}
?>
<form action="" method="post" enctype="multipart/form-data">
<div class="field">
<label for="username">Username</label>
<input type="text" name="username" id="username" value="<?php
echo escape(Input::get('username'));
?>
" autocomplete="off">
</div>
<div class="field">
示例7: templatePdf
function templatePdf($_POST)
{
extract($_POST);
global $set_mainFont;
$pdf =& new Cezpdf();
$pdf->selectFont($set_mainFont);
// Validate
require_lib("validate");
$v = new Validate();
foreach ($invids as $invid) {
$v->isOk($invid, "num", 1, 20, "Invalid invoice number.");
}
// Any errors?
if ($v->isError()) {
$err = "";
$errors = $v->getErrors();
foreach ($errors as $e) {
$err .= "<li class=error>{$e['msg']}</li>";
}
$OUTPUT = $confirm;
require "template.php";
}
$ai = 0;
foreach ($invids as $invid) {
if ($ai) {
$pdf->ezNewPage();
}
++$ai;
// Invoice info
db_conn("cubit");
$sql = "SELECT * FROM nons_invoices WHERE invid='{$invid}' AND DIV='" . USER_DIV . "'";
$invRslt = db_exec($sql) or errDie("Unable to retrieve invoice info.");
if (pg_num_rows($invRslt) == 0) {
return "<li class=err>Not found</li>";
}
$inv = pg_fetch_array($invRslt);
// Only needs to be blank, we're manually adding text
$heading = array(array(""));
// Company info ----------------------------------------------------------
db_conn("cubit");
$sql = "SELECT * FROM compinfo WHERE div='" . USER_DIV . "'";
$ciRslt = db_exec($sql) or errDie("Unable to retrieve company info from Cubit.");
$comp = pg_fetch_array($ciRslt);
$bnkData = qryBankAcct(cust_bank_id($inv["cusid"]));
$compinfo = array();
$compinfo[] = array($comp["addr1"], "{$comp['paddr1']}");
$compinfo[] = array($comp["addr2"], "{$comp['paddr2']}");
$compinfo[] = array($comp["addr3"], "{$comp['paddr3']}");
$compinfo[] = array($comp["addr4"], "{$comp['postcode']}");
$compinfo[] = array("<b>REG: </b>{$comp['regnum']}", "<b>{$bnkData['bankname']}</b>");
$compinfo[] = array("<b>VAT REG: </b>{$comp['vatnum']}", "<b>Branch: </b>{$bnkData['branchname']}");
$compinfo[] = array("<b>Tel:</b> {$comp['tel']}", "<b>Branch Code: </b>{$bnkData['branchcode']}");
$compinfo[] = array("<b>Fax:</b> {$comp['fax']}", "<b>Acc Num: </b>{$bnkData['accnum']}");
// Date ------------------------------------------------------------------
$date = array(array("<b>Date</b>"), array($inv['odate']));
// Document info ---------------------------------------------------------
db_conn('cubit');
$Sl = "SELECT * FROM settings WHERE constant='SALES'";
$Ri = db_exec($Sl) or errDie("Unable to get settings.");
$data = pg_fetch_array($Ri);
if ($data['value'] == "Yes") {
$sp = "<b>Sales Person: </b>{$inv['salespn']}";
} else {
$sp = "";
}
$docinfo = array(array("<b>Invoice No:</b> {$inv['invnum']}"), array("<b>Proforma Inv No:</b> {$inv['docref']}"), array("{$sp}"));
// Customer info ---------------------------------------------------------
if ($inv["cusid"] != 0) {
db_conn("cubit");
$sql = "SELECT * FROM customers WHERE cusnum='{$inv['cusid']}'";
$cusRslt = db_exec($sql) or errDie("Unable to retrieve customer information from Cubit.");
$cusData = pg_fetch_array($cusRslt);
} else {
$cusData["surname"] = $inv["cusname"];
$cusData["addr1"] = $inv["cusaddr"];
$cusData["paddr1"] = "";
$cusData["accno"] = "";
}
$cusinfo = array(array("<b>{$cusData['surname']}</b>"));
$cusaddr = explode("\n", $cusData['paddr1']);
foreach ($cusaddr as $v) {
$cusinfo[] = array(pdf_lstr($v, 40));
}
$cusinfo[] = array("<b>Account no: </b>{$cusData['accno']}");
$cusdaddr = array(array("<b>Physical Address:</b>"));
$cusaddr = explode("\n", $cusData['addr1']);
foreach ($cusaddr as $v) {
$cusdaddr[] = array(pdf_lstr($v, 40));
}
// Registration numbers --------------------------------------------------
$regnos = array(array("<b>VAT No:</b>", "<b>Order No:</b>"), array("{$inv['cusvatno']}", "{$inv['cordno']}"));
// Items display ---------------------------------------------------------
$items = array();
db_conn("cubit");
$sql = "SELECT * FROM nons_inv_items WHERE invid='{$invid}' AND DIV='" . USER_DIV . "'";
$stkdRslt = db_exec($sql);
while ($stkd = pg_fetch_array($stkdRslt)) {
// Check Tax Excempt
db_conn("cubit");
$sql = "SELECT zero FROM vatcodes WHERE id='{$stkd['vatex']}'";
//.........这里部分代码省略.........
示例8: genpdf
function genpdf($quoid)
{
global $_GET;
extract($_GET);
global $set_mainFont;
$showvat = TRUE;
$pdf =& new Cezpdf();
$pdf->selectFont($set_mainFont);
// Validate
require_lib("validate");
$v = new Validate();
$v->isOk($quoid, "num", 1, 20, "Invalid quote number.");
// Any errors?
if ($v->isError()) {
$err = "";
$errors = $v->getErrors();
foreach ($errors as $e) {
$err .= "<li class='err'>{$e['msg']}</li>";
}
$OUTPUT = $confirm;
require "../template.php";
}
// Invoice info
db_conn("cubit");
$sql = "SELECT * FROM quotes WHERE quoid='{$quoid}' AND DIV='" . USER_DIV . "'";
$invRslt = db_exec($sql) or errDie("Unable to retrieve quote info.");
if (pg_num_rows($invRslt) < 1) {
return "<li class='err'>Not found</li>";
}
$inv = pg_fetch_array($invRslt);
db_conn("cubit");
$sql = "SELECT symbol FROM currency WHERE fcid='{$inv['fcid']}'";
$curRslt = db_exec($sql) or errDie("Unable to retrieve currency from Cubit.");
$curr = pg_fetch_result($curRslt, 0);
if (!$curr) {
$curr = CUR;
}
// Check if stock was selected
db_conn("cubit");
$sql = "SELECT stkid FROM quote_items WHERE quoid='{$quoid}' AND DIV='" . USER_DIV . "'";
$cRslt = db_exec($sql) or errDie("Unable to retrieve quote info.");
if (pg_num_rows($cRslt) < 1) {
$error = "<li class='err'>Quote number <b>{$quoid}</b> has no items</li>";
$OUTPUT = $error;
}
// Only needs to be blank, we're manually adding text
$heading = array(array(""));
// Company info ----------------------------------------------------------
db_conn("cubit");
$sql = "SELECT * FROM compinfo WHERE div='" . USER_DIV . "'";
$ciRslt = db_exec($sql) or errDie("Unable to retrieve company info from Cubit.");
$comp = pg_fetch_array($ciRslt);
// Banking information ---------------------------------------------------
$bnkData = qryBankAcct(getdSetting("BANK_DET"));
$compinfo = array();
$compinfo[] = array($comp["addr1"], $comp["paddr1"]);
$compinfo[] = array(pdf_lstr($comp["addr2"], 35), pdf_lstr($comp["paddr2"], 35));
$compinfo[] = array(pdf_lstr($comp["addr3"], 35), pdf_lstr($comp["paddr3"], 35));
$compinfo[] = array(pdf_lstr($comp["addr4"], 35), "{$comp['postcode']}");
$compinfo[] = array("<b>REG: </b>{$comp['regnum']}", "<b>{$bnkData['bankname']}</b>");
$compinfo[] = array("<b>VAT REG: </b>{$comp['vatnum']}", "<b>Branch: </b>{$bnkData['branchname']}");
$compinfo[] = array("<b>Tel:</b> {$comp['tel']}", "<b>Branch Code: </b>{$bnkData['branchcode']}");
$compinfo[] = array("<b>Fax:</b> {$comp['fax']}", "<b>Acc Num: </b>{$bnkData['accnum']}");
// Date ------------------------------------------------------------------
$date = array(array("<b>Date</b>"), array($inv['odate']));
// Document info ---------------------------------------------------------
db_conn('cubit');
$Sl = "SELECT * FROM settings WHERE constant='SALES'";
$Ri = db_exec($Sl) or errDie("Unable to get settings.");
$data = pg_fetch_array($Ri);
db_conn('cubit');
$Sl = "SELECT * FROM settings WHERE constant='SALES'";
$Ri = db_exec($Sl) or errDie("Unable to get settings.");
$data = pg_fetch_array($Ri);
if ($data['value'] == "Yes") {
$sp = "<b>Sales Person: </b>{$inv['salespn']}";
} else {
$sp = "";
}
$docinfo = array(array("<b>Quote No:</b> {$inv['quoid']}"), array("<b>Proforma Inv No:</b> {$inv['docref']}"), array("<b>Sales Order No:</b> {$inv['ordno']}"), array("{$sp}"));
if (isset($salespn)) {
$docinfo[] = array("<b>Sales Person:</b> {$salespn}");
}
// Retrieve the customer information -------------------------------------
db_conn("cubit");
$sql = "SELECT * FROM customers WHERE cusnum='{$inv['cusnum']}'";
$cusRslt = db_exec($sql) or errDie("Unable to retrieve customer information from Cubit.");
$cusData = pg_fetch_array($cusRslt);
// Customer info ---------------------------------------------------------
$invoice_to = array(array(""));
$cusinfo = array(array("<b>{$inv['surname']}</b>"));
$cusaddr = explode("\n", $cusData['addr1']);
foreach ($cusaddr as $v) {
$cusinfo[] = array(pdf_lstr($v, 40));
}
$cusinfo[] = array("<b>Account no: </b>{$cusData['accno']}");
$cuspaddr = array(array("<b>Postal Address</b>"));
$paddr = explode("\n", $cusData["paddr1"]);
foreach ($paddr as $addr) {
$cuspaddr[] = array($addr);
//.........这里部分代码省略.........
示例9: confirm
function confirm($_POST)
{
# Get vars
foreach ($_POST as $key => $value) {
${$key} = $value;
}
# validate input
require_lib("validate");
$v = new validate();
$v->isOk($budid, "num", 1, 20, "Invalid Budget id.");
$v->isOk($budname, "string", 1, 255, "Invalid Budget Name.");
$v->isOk($budtype, "string", 1, 20, "Invalid Budget type.");
if ($budfor == 'acc') {
if (isset($accids)) {
foreach ($accids as $akey => $accid) {
$v->isOk($accid, "num", 1, 50, "Invalid Account number.");
foreach ($amts[$accid] as $skey => $amtr) {
$v->isOk($amts[$accid][$skey], "float", 1, 20, "Invalid Budget amount.");
}
}
} else {
$v->isOk("#", "num", 0, 0, "Error : please select at least one account.");
}
} elseif ($budfor == 'cost') {
if (isset($ccids)) {
foreach ($ccids as $akey => $ccid) {
$v->isOk($ccid, "num", 1, 50, "Invalid Cost Center.");
foreach ($amts[$ccid] as $skey => $amtr) {
$v->isOk($amts[$ccid][$skey], "float", 1, 20, "Invalid Budget amount.");
}
}
} else {
$v->isOk("#", "num", 0, 0, "Error : please select at least one cost center.");
}
}
# display errors, if any
if ($v->isError()) {
$confirm = "";
$errors = $v->getErrors();
foreach ($errors as $e) {
$confirm .= "<li class=err>" . $e["msg"];
}
return details($_POST, $confirm);
}
$ce = new Validate();
if (isset($accids)) {
foreach ($accids as $akey => $accid) {
$tot = $amts[$accid][BUDGET_YEARS_INDEX];
$mon_tot = budgetTotalFromMonth($accid, "acc");
if (strlen($mon_tot) > 0 && $tot != $mon_tot) {
$accRs = get("core", "*", "accounts", "accid", $accid);
$acc = pg_fetch_array($accRs);
$acc_name = "{$acc['topacc']}/{$acc['accnum']} - {$acc['accname']}";
$ce->addError("", "Monthly annual budget total of " . CUR . "{$mon_tot} doesn't\n\t\t\t\t\tmatch proposed total amount of " . CUR . "{$tot} for Account: {$accid} {$acc_name}.");
}
}
} else {
if (isset($ccids)) {
foreach ($ccids as $akey => $ccid) {
$tot = $amts[$ccid][BUDGET_YEARS_INDEX];
$mon_tot = budgetTotalFromMonth($ccid, "acc");
if (strlen($mon_tot) > 0 && $tot != $mon_tot) {
$ccRs = get("cubit", "*", "costcenters", "ccid", $ccid);
$cc = pg_fetch_array($ccRs);
$cc_name = "{$cc['centercode']} - {$cc['centername']}";
$ce->addError("", "Monthly annual budget total of " . CUR . "{$mon_tot} doesn't\n\t\t\t\t\tmatch proposed total amount of " . CUR . "{$tot} for Cost Center: {$cc_name}.");
}
}
}
}
$mismatches = "";
if ($ce->isError()) {
$mm = $ce->getErrors();
foreach ($mm as $e) {
$mismatches .= "<li class=err>" . $e["msg"] . "</li>";
}
}
# Query server
db_connect();
$sql = "SELECT * FROM budgets WHERE budid = '{$budid}'";
$budRslt = db_exec($sql) or errDie("Unable to retrieve Budgets from database.");
if (pg_numrows($budRslt) < 1) {
return "<li class=err> - Invalid Budget.";
}
$bud = pg_fetch_array($budRslt);
global $BUDFOR, $PERIODS, $TYPES, $YEARS;
$vbudfor = $BUDFOR[$bud['budfor']];
$vbudtype = $TYPES[$budtype];
$vfromyr = $YEARS[$bud['fromprd']];
$vtoyr = $YEARS[$bud['toprd']];
/* Toggle Options */
$list = "";
# budget for
if ($bud['budfor'] == 'cost') {
$head = "<tr><th>Cost Centers</th>";
foreach ($ccids as $ckey => $ccid) {
$ccRs = get("cubit", "*", "costcenters", "ccid", $ccid);
$cc = pg_fetch_array($ccRs);
$list .= "<tr class='bg-odd'><td><input type=hidden name=ccids[] value='{$cc['ccid']}'>{$cc['centercode']} - {$cc['centername']}</td>";
foreach ($amts[$ccid] as $sprd => $amtr) {
//.........这里部分代码省略.........
示例10: function
$app->get('/add', function () use($app) {
$main = '';
$add = 'active';
return $app['twig']->render('add.twig', array('main' => $main, 'add' => $add));
});
$app->post('/add', function () use($app) {
if (isset($_POST)) {
$check = new Check();
$name = $check->checkInput($_POST['name']);
$comment = $check->checkInput($_POST['comment']);
$pdo = new Db();
$db = $pdo->get();
$validate = new Validate($db);
$data = array('name' => $name, 'comment' => $comment);
$errors = $validate->getErrors($data);
if (!empty($errors)) {
$main = '';
$add = 'active';
return $app['twig']->render('add.twig', array('main' => $main, 'add' => $add, 'errors' => $errors, 'name' => $name, 'comment' => $comment));
} else {
$mapper = new Mapper($db);
$ip_address = $_SERVER['REMOTE_ADDR'];
$comments = new Comments();
$comments->name = $name;
$comments->comment = $comment;
$comments->ip_address = $ip_address;
$mapper->save($comments);
return $app->redirect('/GuestBook/');
}
}
示例11: gennonspdf
function gennonspdf($invid)
{
global $set_mainFont;
$showvat = TRUE;
$pdf =& new Cezpdf();
$pdf->selectFont($set_mainFont);
// Validate
require_lib("validate");
$v = new Validate();
$v->isOk($invid, "num", 1, 20, "Invalid invoice number.");
// Any errors?
if ($v->isError()) {
$err = "";
$errors = $v->getErrors();
foreach ($errors as $e) {
$err .= "<li class='err'>{$e['msg']}</li>";
}
$OUTPUT = $confirm;
require "../template.php";
}
// Invoice info
db_conn("cubit");
$sql = "SELECT * FROM nons_invoices WHERE invid='{$invid}' AND DIV='" . USER_DIV . "'";
$invRslt = db_exec($sql) or errDie("Unable to retrieve invoice info.");
//die ($sql);
if (pg_num_rows($invRslt) == 0) {
return "<li class='err'>Not found</li>";
}
$inv = pg_fetch_array($invRslt);
db_conn("cubit");
$sql = "SELECT symbol FROM currency WHERE fcid='{$inv['fcid']}'";
$curRslt = db_exec($sql) or errDie("Unable to retrieve currency from Cubit.");
$curr = pg_fetch_result($curRslt, 0);
if (!$curr) {
$curr = CUR;
}
// Only needs to be blank, we're manually adding text
$heading = array(array(""));
// Company info ----------------------------------------------------------
db_conn("cubit");
$sql = "SELECT * FROM compinfo WHERE div='" . USER_DIV . "'";
$ciRslt = db_exec($sql) or errDie("Unable to retrieve company info from Cubit.");
$comp = pg_fetch_array($ciRslt);
// $bnkData = qryBankAcct(getdSetting("BANK_DET"));
$bnkData = qryBankAcct($inv['bankid']);
$compinfo = array();
$compinfo[] = array(pdf_lstr($comp["addr1"], 35), pdf_lstr($comp["paddr1"], 35));
$compinfo[] = array(pdf_lstr($comp["addr2"], 35), pdf_lstr($comp["paddr2"], 35));
$compinfo[] = array(pdf_lstr($comp["addr3"], 35), pdf_lstr($comp["paddr3"], 35));
$compinfo[] = array(pdf_lstr($comp["addr4"], 35), "{$comp['postcode']}");
$compinfo[] = array("<b>REG: </b>{$comp['regnum']}", "<b>{$bnkData['bankname']}</b>");
$compinfo[] = array("<b>VAT REG: </b>{$comp['vatnum']}", "<b>Branch: </b>{$bnkData['branchname']}");
$compinfo[] = array("<b>Tel:</b> {$comp['tel']}", "<b>Branch Code: </b>{$bnkData['branchcode']}");
$compinfo[] = array("<b>Fax:</b> {$comp['fax']}", "<b>Acc Num: </b>{$bnkData['accnum']}");
// Date ------------------------------------------------------------------
$date = array(array("<b>Date</b>"), array($inv['odate']));
// Document info ---------------------------------------------------------
db_conn('cubit');
$Sl = "SELECT * FROM settings WHERE constant='SALES'";
$Ri = db_exec($Sl) or errDie("Unable to get settings.");
$data = pg_fetch_array($Ri);
if ($data['value'] == "Yes") {
$sp = "<b>Sales Person: </b>{$inv['salespn']}";
} else {
$sp = "";
}
// Customer info ---------------------------------------------------------
if ($inv["cusid"] != 0) {
db_conn("cubit");
$sql = "SELECT * FROM customers WHERE cusnum='{$inv['cusid']}'";
$cusRslt = db_exec($sql) or errDie("Unable to retrieve customer information from Cubit.");
$cusData = pg_fetch_array($cusRslt);
} else {
$cusData["surname"] = $inv["cusname"];
$cusData["addr1"] = $inv["cusaddr"];
$cusData["paddr1"] = $inv["cusaddr"];
$cusData["del_addr1"] = "";
$cusData["accno"] = "";
}
$docinfo = array(array("<b>Invoice No:</b> {$inv['invnum']}"), array("<b>Proforma Inv No:</b> {$inv['docref']}"), array("<b>Account no: </b>{$cusData['accno']}"), array("{$sp}"));
$invoice_to = array(array(""));
$cusinfo = array(array("<b>{$cusData['surname']}</b>"));
$cusaddr = explode("\n", $cusData['addr1']);
foreach ($cusaddr as $v) {
$cusinfo[] = array(pdf_lstr($v, 40));
}
// $cusinfo[] = array("<b>Account no: </b>$cusData[accno]");
$cuspaddr = array(array("<b>Postal Address</b>"));
$paddr = explode("\n", $cusData["paddr1"]);
foreach ($paddr as $addr) {
$cuspaddr[] = array("{$addr}");
}
$cusdaddr = array(array("<b>Delivery Address:</b>"));
$cusaddr = explode("\n", $cusData['del_addr1']);
foreach ($cusaddr as $v) {
$cusdaddr[] = array(pdf_lstr($v, 40));
}
// Registration numbers --------------------------------------------------
$regnos = array(array("<b>VAT No:</b>", "<b>Order No:</b>"), array("{$inv['cusvatno']}", "{$inv['cordno']}"));
// Items display ---------------------------------------------------------
//.........这里部分代码省略.........
示例12: testValidate
public function testValidate()
{
$this->assertSame(false, $this->validate->validate([], 'webmaster.recipe'));
$this->assertInstanceOf("Illuminate\\Support\\MessageBag", $this->validate->getErrors());
$this->assertSame(true, $this->validate->validate(['words' => 'testing'], 'search'));
}
示例13: posInvoices
function posInvoices($pdf)
{
extract($_GET);
global $set_mainFont;
$showvat = TRUE;
$pdf->selectFont($set_mainFont);
// Validate
require_lib("validate");
$v = new Validate();
$v->isOk($cusnum, "num", 1, 20, "Invalid customer number.");
// Any errors?
if ($v->isError()) {
$err = "";
$errors = $v->getErrors();
foreach ($errors as $e) {
$err .= "<li class=error>{$e['msg']}</li>";
}
$OUTPUT = $err;
require "../template.php";
}
// Invoice info
db_conn(PRD_DB);
$sql = "SELECT * FROM pinvoices WHERE cusnum='{$cusnum}' AND done='y' AND balance>0 AND DIV='" . USER_DIV . "'";
$invRslt = db_exec($sql) or errDie("Unable to retrieve invoice info.");
if (pg_num_rows($invRslt) < 1) {
return $pdf;
}
$num_rows = pg_num_rows($invRslt);
$curr_row = 1;
while ($inv = pg_fetch_array($invRslt)) {
$curr_row++;
// Check if stock was selected
db_conn(PRD_DB);
$sql = "SELECT stkid FROM pinv_items WHERE invid='{$inv['invid']}' AND DIV='" . USER_DIV . "'";
$cRslt = db_exec($sql) or errDie("Unable to retrieve invoice info.");
if (pg_num_rows($cRslt) < 1) {
$error = "<li class=err>Invoice number <b>{$inv['invid']}</b> has no items</li>";
$OUTPUT = $error;
}
// Only needs to be blank, we're manually adding text
$heading = array(array(""));
// Company info ----------------------------------------------------------
db_conn("cubit");
$sql = "SELECT * FROM compinfo WHERE div='" . USER_DIV . "'";
$ciRslt = db_exec($sql) or errDie("Unable to retrieve company info from Cubit.");
$comp = pg_fetch_array($ciRslt);
// Banking information ---------------------------------------------------
$sql = "SELECT value FROM set WHERE label='BANK_DET' AND div='" . USER_DIV . "'";
$srslt = db_exec($sql) or errDie("Unable to retrieve banking information from Cubit.");
$bankid = pg_fetch_result($srslt, 0);
// Select the default bank account if no accounts were found.
if (pg_num_rows($srslt) == 0) {
$bankid = 2;
}
db_conn("cubit");
$sql = "SELECT * FROM bankacct WHERE bankid='{$bankid}' AND div='" . USER_DIV . "'";
$bnkRslt = db_exec($sql) or errDie("Unable to retrieve the banking information from Cubit.");
$bnkData = pg_fetch_array($bnkRslt);
$compinfo = array();
$compinfo[] = array($comp["addr1"], $comp["paddr1"]);
$compinfo[] = array(pdf_lstr($comp["addr2"], 35), pdf_lstr($comp["paddr2"], 35));
$compinfo[] = array(pdf_lstr($comp["addr3"], 35), pdf_lstr($comp["paddr3"], 35));
$compinfo[] = array(pdf_lstr($comp["addr4"], 35), "{$comp['postcode']}");
$compinfo[] = array("<b>REG: </b>{$comp['regnum']}", "<b>{$bnkData['bankname']}</b>");
$compinfo[] = array("<b>VAT REG: </b>{$comp['vatnum']}", "<b>Branch: </b>{$bnkData['branchname']}");
$compinfo[] = array("<b>Tel:</b> {$comp['tel']}", "<b>Branch Code: </b>{$bnkData['branchcode']}");
$compinfo[] = array("<b>Fax:</b> {$comp['fax']}", "<b>Acc Num: </b>{$bnkData['accnum']}");
// Date ------------------------------------------------------------------
$date = array(array("<b>Date</b>"), array($inv['odate']));
// Document info ---------------------------------------------------------
db_conn('cubit');
$Sl = "SELECT * FROM settings WHERE constant='SALES'";
$Ri = db_exec($Sl) or errDie("Unable to get settings.");
$data = pg_fetch_array($Ri);
$docinfo = array(array("<b>Invoice No:</b> {$inv['invnum']}"), array("<b>Sales Order No:</b> {$inv['ordno']}"));
if (isset($salespn)) {
$docinfo[] = array("<b>Sales Person:</b> {$salespn}");
}
// Retrieve the customer information -------------------------------------
db_conn("cubit");
$sql = "SELECT * FROM customers WHERE cusnum='{$inv['cusnum']}'";
$cusRslt = db_exec($sql) or errDie("Unable to retrieve customer information from Cubit.");
$cusData = pg_fetch_array($cusRslt);
// Customer info ---------------------------------------------------------
$invoice_to = array(array(""));
$cusinfo = array(array("<b>{$inv['surname']}</b>"));
$cusaddr = explode("\n", $cusData['addr1']);
foreach ($cusaddr as $v) {
$cusinfo[] = array(pdf_lstr($v, 40));
}
$cusinfo[] = array("<b>Account no: </b>{$cusData['accno']}");
$cuspaddr = array(array("<b>Postal Address</b>"));
$paddr = explode("\n", $cusData["paddr1"]);
foreach ($paddr as $addr) {
$cuspaddr[] = array($addr);
}
$cusdaddr = array(array("<b>Delivery Address:</b>"));
$branchname = "Head Office";
$cusaddr = explode("\n", $cusData['addr1']);
$cusdaddr[] = array(pdf_lstr("Branch : {$branchname}", 30));
//.........这里部分代码省略.........
示例14: adminDeleteItem
public static function adminDeleteItem()
{
if (Users::isAdmin()) {
$validation = new Validate();
$validation->check($_POST, array('action' => array('name' => 'Action', 'required' => true, 'wildcard' => 'admin_item_delete'), 'table' => array('name' => 'Table Name', 'required' => true), 'id' => array('name' => 'Entry ID', 'required' => true)));
if ($validation->passed()) {
DB::instance()->delete(Input::get('table'), array("", "id", "=", Input::get('id')));
if (Input::get('table') === Users::safeSid() . '_assignments') {
Calendar::deleteAssignment(Input::get('id'));
}
Notifications::addSuccess('Entry deleted!');
Redirect::to('?page=home');
} else {
Notifications::addValidationFail($validation->getErrors());
}
} else {
Redirect::error(403);
}
}
示例15: invNoteDetails
function invNoteDetails($_GET)
{
extract($_GET);
global $set_mainFont;
$showvat = TRUE;
$pdf =& new Cezpdf();
$pdf->selectFont($set_mainFont);
// Validate
require_lib("validate");
$v = new Validate();
$v->isOk($invid, "num", 1, 20, "Invalid invoice number.");
$v->isOk($prd, "num", 1, 9, "Invalid period.");
// Any errors?
if ($v->isError()) {
$err = "";
$errors = $v->getErrors();
foreach ($errors as $e) {
$err .= "<li class='err'>{$e['msg']}</li>";
}
$confirm = "<p><input type='button' onClick='javascript.history.back();' value='« Correct Submission'></p>";
$OUTPUT = $confirm;
require "../template.php";
}
// Invoice info
db_conn($prd);
$sql = "SELECT * FROM inv_notes WHERE noteid='{$invid}' AND DIV='" . USER_DIV . "'";
$invRslt = db_exec($sql) or errDie("Unable to retrieve invoice info.");
if (pg_num_rows($invRslt) < 1) {
return "<li class='err'>Not found</li>";
}
$inv = pg_fetch_array($invRslt);
db_conn("cubit");
$sql = "SELECT symbol FROM currency WHERE fcid='{$inv['fcid']}'";
$curRslt = db_exec($sql) or errDie("Unable to retrieve currency from Cubit.");
$curr = pg_fetch_result($curRslt, 0);
if (!$curr) {
$curr = CUR;
}
// Check if stock was selected
db_conn("cubit");
$sql = "SELECT stkid FROM inv_items WHERE invid='{$invid}' AND DIV='" . USER_DIV . "'";
$cRslt = db_exec($sql) or errDie("Unable to retrieve invoice info.");
if (pg_num_rows($cRslt) < 1) {
$error = "<li class='err'>Invoice number <b>{$invid}</b> has no items</li>";
$OUTPUT = $error;
}
// Only needs to be blank, we're manually adding text
$heading = array(array(""));
// Company info ----------------------------------------------------------
db_conn("cubit");
$sql = "SELECT * FROM compinfo WHERE div='" . USER_DIV . "'";
$ciRslt = db_exec($sql) or errDie("Unable to retrieve company info from Cubit.");
$comp = pg_fetch_array($ciRslt);
// Banking information ---------------------------------------------------
// $bnkData = qryBankAcct(getdSetting("BANK_DET"));
$bnkData = qryBankAcct($inv['bankid']);
$compinfo = array();
$compinfo[] = array(pdf_lstr($comp["addr1"], 35), pdf_lstr($comp["paddr1"], 35));
$compinfo[] = array(pdf_lstr($comp["addr2"], 35), pdf_lstr($comp["paddr2"], 35));
$compinfo[] = array(pdf_lstr($comp["addr3"], 35), pdf_lstr($comp["paddr3"], 35));
$compinfo[] = array(pdf_lstr($comp["addr4"], 35), "{$comp['postcode']}");
$compinfo[] = array("<b>REG: </b>{$comp['regnum']}", "<b>{$bnkData['bankname']}</b>");
$compinfo[] = array("<b>VAT REG: </b>{$comp['vatnum']}", "<b>Branch: </b>{$bnkData['branchname']}");
$compinfo[] = array("<b>Tel:</b> {$comp['tel']}", "<b>Branch Code: </b>{$bnkData['branchcode']}");
$compinfo[] = array("<b>Fax:</b> {$comp['fax']}", "<b>Acc Num: </b>{$bnkData['accnum']}");
// Date ------------------------------------------------------------------
$date = array(array("<b>Date</b>"), array($inv['odate']));
// Document info ---------------------------------------------------------
db_conn('cubit');
$Sl = "SELECT * FROM cubit.settings WHERE constant='SALES'";
$Ri = db_exec($Sl) or errDie("Unable to get settings.");
$data = pg_fetch_array($Ri);
if ($data['value'] == "Yes") {
$sp = "<b>Sales Person: </b>{$inv['salespn']}";
} else {
$sp = "";
}
// Retrieve the customer information -------------------------------------
db_conn("cubit");
$sql = "SELECT * FROM customers WHERE cusnum='{$inv['cusnum']}'";
$cusRslt = db_exec($sql) or errDie("Unable to retrieve customer information from Cubit.");
$cusData = pg_fetch_array($cusRslt);
$docinfo = array(array("<b>Credit Note No:</b> {$inv['notenum']}"), array("<b>Invoice No:</b> {$inv['invnum']}"), array("<b>Sales Order No:</b> {$inv['ordno']}"), array("{$sp}"));
// Customer info ---------------------------------------------------------
$invoice_to = array(array(""));
$cusinfo = array(array("<b>{$inv['surname']}</b>"));
$addr1 = explode("\n", $cusData["addr1"]);
foreach ($addr1 as $addr) {
$cusinfo[] = array($addr);
}
$cuspaddr = array(array("<b>Postal Address</b>"));
$paddr = explode("\n", $cusData["paddr1"]);
foreach ($paddr as $addr) {
$cuspaddr[] = array($addr);
}
$cusdaddr = array(array("<b>Delivery Address:</b>"));
// Temp
// $inv["branch"] = 0;
if ($inv['branch'] == 0) {
$branchname = "Head Office";
//.........这里部分代码省略.........