} if ($_POST["add"]) { $_POST["product"] or alloc_error("You must enter a Product."); $_POST["companyDetails"] or alloc_error("You must enter the Company Details."); $_POST["fromTfID"] or alloc_error("You must enter the Source TF."); $_POST["quantity"] or $_POST["quantity"] = 1; config::get_config_item("mainTfID") or alloc_error("You must configure the Finance Tagged Fund on the Setup -> Finance screen."); if ($_POST["amount"] === "") { alloc_error("You must enter the Price."); } $_POST["amount"] = $_POST["amount"] * $_POST["quantity"]; $transaction = new transaction(); $transactionID && $transaction->set_id($_POST["transactionID"]); $transaction->read_globals(); // check we have permission to make the transaction if (!$transaction->have_perm(PERM_CREATE)) { alloc_error("You do not have permission to create transactions for that Source TF."); } if (!count($TPL["message"])) { $transaction->set_value("transactionType", "expense"); $transaction->set_value("expenseFormID", $expenseForm->get_id()); $transaction->set_value("tfID", config::get_config_item("mainTfID")); $transaction->save(); } else { $transaction_to_edit = $transaction; } } if ($_POST["edit"] && $_POST["expenseFormID"] && $_POST["transactionID"]) { $transaction_to_edit->set_id($_POST["transactionID"]); $transaction_to_edit->select(); $TPL["transactionID"] = $_POST["transactionID"];