function update($id, $data) { $id = urldecode($id); $this->db->where($this->primary_key, $id); $data['checkin_date'] = format_sql_date($data['checkin_date']); return $this->db->update($this->table_name, $data); }
<?php require_once '../_includes/connection.php'; require_once '../_includes/functions.php'; require_once '../blog/_includes/session.php'; require_once 'functions.php'; confirm_logged_in(4); $form = TRUE; $date1 = format_sql_date($_POST[month], $_POST[day]); global $connection; if (isset($_POST[expense])) { if ($_POST[type] != 2) { $query = "UPDATE expenses SET\n type = {$_POST['type']},\n num_months = '{$_POST[num_months]}',\n item = '{$_POST[item]}',\n due_date = '{$date1}',\n total_exp = '{$_POST[total_exp]}'\n WHERE id = '{$_POST[id]}'"; } else { $query = "UPDATE expenses SET\n type = {$_POST['type']},\n num_months = '{$_POST[num_months]}',\n item = '{$_POST[item]}',\n due_date = '{$date1}',\n daily_amt = '{$_POST[total_exp]}'\n WHERE id = '{$_POST[id]}'"; } $result = mysql_query($query, $connection); if ($result) { redirect_to("index.php"); } } if (isset($_POST[check_book])) { $clean_type = mysql_prep($_POST['type']); $clean_clear = mysql_prep($_POST['cleared']); $clean_expense = mysql_prep($_POST['expense']); $clean_exp_id = mysql_prep($_POST['expense_id']); $clean_amount = mysql_prep($_POST['amount']); $query2 = "UPDATE check_book SET\n date = '{$date1}',\n type = '{$_POST['type']}',\n expense = '{$_POST['expense']}',\n expense_id = '{$_POST['expense_id']}',\n cleared = '{$_POST['cleared']}',\n amount = '{$_POST['amount']}'\n WHERE id = '{$_POST['id']}'"; if (mysql_query($query2, $connection)) { redirect_to("index.php"); }
global $connection; $query = "INSERT INTO "; $query .= " check_book ("; $query .= " expense, expense_id, amount, type, cleared, date"; $query .= ")VALUES("; $query .= "'{$_POST[expense]}', '{$_POST[expense_id]}', '{$_POST[amount]}', '{$_POST[type]}', '{$_POST[cleared]}', '{$date1}')"; if (mysql_query($query, $connection)) { $msg = "query was a success!"; } if ($_POST['redirect'] == 1) { redirect_to("index.php?updated=1"); } } if (isset($_POST['add_exp'])) { //performs the ADD query for expenses $date1 = format_sql_date($_POST['month'], $_POST['day']); global $connection; if ($_POST['type'] == 2) { $query = "INSERT INTO "; $query .= " expenses ("; $query .= "item, type, num_months, due_date, daily_amt"; $query .= ")VALUES("; $query .= "'{$_POST[item]}', '{$_POST[type]}', '{$_POST[num_months]}', '{$date1}', '{$_POST[total_exp]}')"; } else { $query = "INSERT INTO "; $query .= " expenses ("; $query .= "item, type, num_months, due_date, total_exp"; $query .= ")VALUES("; $query .= "'{$_POST[item]}', '{$_POST[type]}', '{$_POST[num_months]}', '{$date1}', '{$_POST[total_exp]}')"; } if (mysql_query($query, $connection)) {
{ list($month, $day, $year) = explode("/", $sheet_date); return "20" . $year . "-" . $month . "-" . $day; } function money2float($money_string) { $money_float = str_replace("\$", "", $money_string); $money_float = str_replace(",", "", $money_float); return $money_float; } if (file_exists($import_file)) { $fp = fopen($import_file, "r"); $i = 0; $total = 0; while ($fields = fgetcsv($fp)) { $i++; $do_expense_import->newRecord(); $do_expense_import->category = $fields[0]; $do_expense_import->debit_date = format_sql_date($fields[1]); $do_expense_import->description = $fields[3]; $do_expense_import->payment_method = $fields[4]; $do_expense_import->amount = money2float($fields[5]); $do_expense_import->add(); $total += money2float($fields[5]); $this->setLog("\n insert with: " . $do_expense_import->getSqlQuery()); } } $this->setLog("\n imported a total of: " . $total); $disp = new Display($goto); $disp->addParam("message", "Import completed"); $this->setDisplayNext($disp);