$i_payment_type = get_isset($i_payment_type); if ($i_payment_type == 1) { $status = 1; } else { $status = 2; } $i_code = get_isset($i_code); $tanggal = date("Y-m-d"); //$get_item_name = get_item_name($i_item_id); $data = "'',\n\t\t\t\t\t'{$i_date}', \n\t\t\t\t\t'0', \n\t\t\t\t\t'0',\n\t\t\t\t\t'0',\n\t\t\t\t\t'0',\n\t\t\t\t\t'{$i_supplier}',\n\t\t\t\t\t'{$i_branch_id}',\n\t\t\t\t\t'{$i_payment_type}',\n\t\t\t\t\t'{$status}',\n\t\t\t\t\t'{$tanggal}',\n\t\t\t\t\t'{$i_code}'\n\t\t\t"; //echo $data; create($data); $data_id = mysql_insert_id(); // simpan jurnal $harga_total = get_total($data_id); create_journal($data_id, "purchase.php?page=form&id=", 2, $harga_total['total'], $i_code, '', $i_branch_id); //add_stock($i_item_id, $i_branch_id, $i_qty); update_detail($data_id, $_SESSION['user_id']); $query_item = select_detail_tmp($data_id); while ($row_item = mysql_fetch_array($query_item)) { //echo $row_item['transaction_production_detail_id']; //Minus stock $select_stock = select_stock($row_item['branch_id'], $row_item['item_id']); $stock_plus = $select_stock['item_stock_qty'] + $row_item['purchase_detail_qty']; //echo $stock_plus; update_stock($row_item['branch_id'], $row_item['item_id'], $stock_plus); } header("Location: purchase.php?page=list&did=1"); break; case 'edit': extract($_POST);
} else { $query = mysql_query("select * \n\t\t\t\t\t\t\t\tfrom transactions_tmp a\n\t\t\t\t\t\t\t\twhere a.table_id = '{$table_id}'\n\t\t\t\t\t\t\t\t"); // simpan transaksi while ($row = mysql_fetch_array($query)) { // create settlement $get_discount_type = get_discount_type($row['member_id']); if ($total_discount > 0 && $get_discount_type == 2) { update_settlement($total_discount, $row['member_id']); } $data = "'',\n\t\t\t\t\t'{$table_id}',\n\t\t\t\t\t'{$branch_id}',\n\t\t\t\t\t'" . $row['member_id'] . "',\n\t\t\t\t\t'" . $row['transaction_date'] . "', \n\t\t\t\t\t'" . $data_total . "',\n\t\t\t\t\t'" . $i_discount . "',\n\t\t\t\t\t'" . $i_grand_total . "',\n\t\t\t\t\t'" . $i_payment . "',\n\t\t\t\t\t'" . $i_change . "',\n\t\t\t\t\t'" . $i_payment_method . "',\n\t\t\t\t\t'" . $i_bank_id . "',\n\t\t\t\t\t'" . $row['user_id'] . "',\n\t\t\t\t\t'" . $i_bank_account . "',\n\t\t\t\t\t'" . $row['transaction_code'] . "',\n\t\t\t\t\t'" . $row['customer_number'] . "',\n\t\t\t\t\t'" . $row['tot_id'] . "',\n\t\t\t\t\t'" . $i_discount_persen . "'\n\t\t\t\t\t\n\t\t\t"; // simpan transaksi create_config("transactions", $data); $transaction_id = mysql_insert_id(); $get_table_name = get_table_name($table_id); // simpan jurnal create_journal($transaction_id, "", 1, $i_grand_total, "Meja " . $get_table_name, $i_bank_id, $_SESSION['branch_id']); $query_detail = mysql_query("select * \n\t\t\t\t\t\t\t\tfrom transaction_tmp_details a\n\t\t\t\t\t\t\t\twhere a.transaction_id = '" . $row['transaction_id'] . "'\n\t\t\t\t\t\t\t\t"); while ($row_detail = mysql_fetch_array($query_detail)) { // simpan transaksi detail $data_detail = "'',\n\t\t\t\t\t\t\t\t\t'{$transaction_id}',\n\t\t\t\t\t\t\t\t\t'" . $row_detail['menu_id'] . "',\n\t\t\t\t\t\t\t\t\t'" . $row_detail['transaction_detail_original_price'] . "',\n\t\t\t\t\t\t\t\t\t'" . $row_detail['transaction_detail_margin_price'] . "',\n\t\t\t\t\t\t\t\t\t'" . $row_detail['transaction_detail_price'] . "',\n\t\t\t\t\t\t\t\t\t'" . $row_detail['transaction_detail_price_discount'] . "',\n\t\t\t\t\t\t\t\t\t'" . $row_detail['transaction_detail_grand_price'] . "',\n\t\t\t\t\t\t\t\t\t'" . $row_detail['transaction_detail_qty'] . "',\n\t\t\t\t\t\t\t\t\t'" . $row_detail['transaction_detail_total'] . "',\n\t\t\t\t\t\t\t\t\t'" . $row_detail['transaction_detail_compliment_status'] . "'\n\t\t\t\t\t\t\t\t\t"; create_config("transaction_details", $data_detail); $query_item = mysql_query("select *\n\t\t\t\t\t\t\t\tfrom menu_recipes a\n\t\t\t\t\t\t\t\twhere a.menu_id = '" . $row_detail['menu_id'] . "'\n\t\t\t\t\t\t\t\t"); while ($row_item = mysql_fetch_array($query_item)) { // update stok bahan $new_stock = $row_detail['transaction_detail_qty'] * $row_item['item_qty']; update_stock($branch_id, $row_item['item_id'], $new_stock); } } // hapus tmp delete_tmp($table_id); // hapus widget_tmp