static public function checkClientExistance () { $id = mysql_real_escape_string($_POST['client']); if(!$id) return('Should choose client'); if(!count(ClientCollection::getClients($id))) return('Should choose client'); if(!count(CustodyCollection::getAccountsForClient($id))) return('This client has no custody accounts... add custody accounts first!'); return false; }
loginAdmin(); if(!loggedAdmin()) header('location: index.php'); $transaction = new TransactionCollection(); $clients = ClientCollection::getClients(); $isins = IsinCollection::getIsins(); $collection = new SecurityCollection(); $isinCollection = new IsinCollection; $accounts = CustodyCollection::getAccountsForClientByTransactionId(mysql_real_escape_string($_GET['id'])); if(exist($_POST['button'])) { $result = TransactionCollection::updateTransaction(); } else { TransactionCollection::loadTransaction(); $result = array(); } include("$templates/menu.php"); $clients = ClientCollection::getClients(); $isins = IsinCollection::getIsins(); include("$templates/transaction_edit.php"); include("$templates/footer.php"); ?>
static public function verifyFields() { foreach($_POST as $key=>$value) $_POST[$key] = mysql_real_escape_string($value); $errors=''; $fields = array('client','aname'); $fieldsObligatory = array('client','aname'); $errorMessage = array('Client','Account name'); $result = array(); foreach($fieldsObligatory as $key=>$field): if(!exist($_POST[$field])) $result[] = $errorMessage[$key]; endforeach; if(trim($_POST['client'])) if(!ClientCollection::getClients(trim($_POST['client']))) die('Database error: not existant client.. please apply admin'); return $result; }
static public function verifyFields() { foreach($_POST as $key=>$value) $_POST[$key] = mysql_real_escape_string($value); $errors=''; $fields = array('currency','client','aname','amount','credit','valuec','debit','valued'); $fieldsDates = array('valuec','valued'); $fieldsNumbers= array('amount','credit','debit'); $fieldsObligatory = array('currency','client','aname','amount'); $errorMessage = array('Currency','Client','Account name','Amount'); $errorMessageDates= array('Credit date (should be YYYY-MM-DD)','Debit date (should be YYYY-MM-DD)'); $errorMessageNumbers= array('Amount should be number','Credit should be number','Debit should be number'); $result = array(); foreach($fieldsObligatory as $key=>$field): if(!exist($_POST[$field])) $result[] = $errorMessage[$key]; endforeach; foreach($fieldsDates as $key=>$field) if(trim($_POST[$field])) if(trim($_POST[$field]) !== '0000-00-00') if((!preg_match("/[0-9]{4}-[0-9]{2}-[0-9]{2}$/", $_POST[$field]))||(strtotime(trim($_POST[$field]))<1)) $result[] = $errorMessageDates[$key]; foreach($fieldsNumbers as $key=>$field) if(trim($_POST[$field])) if(!preg_match("/^[\d]{0,8}$/", $_POST[$field])) $result[] = $errorMessageNumbers[$key]; if(trim($_POST['client'])) if(!ClientCollection::getClients(trim($_POST['client']))) die('Database error: not existant client.. please apply admin'); if(trim($_POST['currency'])) if(!CurrencyCollection::getCurrencies(trim($_POST['currency']))) die('Database error: not existant currency.. please apply admin'); return $result; }