<th>Code</th> <th>Stock</th> <th>Sale Price</th> </tr> </thead> <tbody id="tbodyid"> <?php $mysql_q = "SELECT item_id, item_name, item_detail, item_saleprice\n\t\t\t\t\t\t\tFROM items\n\t\t\t\t\t\t\tORDER BY item_id DESC"; $query_res = $dbhi->query($mysql_q) or die($dbhi->error); while ($row = $query_res->fetch_assoc()) { $i_id = $row['item_id']; $i_name = $row['item_name']; $i_detail = $row['item_detail']; $i_saleprice = clean_num($row['item_saleprice']); $stock_info = get_stock_info($i_id, $dbhi); $i_costprice = get_costprice($i_id, $dbhi); $i_costcode = price2code($i_costprice); $i_stocknumber = $stock_info['total_purchase'] - $stock_info['total_sale']; echo "\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td>\n\t\t\t\t\t\t\t#<div style='display: inline' name='iid_editable[]'>{$i_id}</div>\n\t\t\t\t\t\t</td>\n\t\t\t\t\t\t<td>\n\t\t\t\t\t\t\t<b><a name='i_link[]' href='transactions.php?iid={$i_id}'>\n\t\t\t\t\t\t\t\t<div name='inm_disp[]'>{$i_name}</div>\n\t\t\t\t\t\t\t\t<input style='display: none' name='inm_editable[]' value='{$i_name}'/>\n\t\t\t\t\t\t\t\t<input type='hidden' name='link_space[]' value='transactions.php?iid={$i_id}'/>\n\t\t\t\t\t\t\t</a></b>\n\t\t\t\t\t\t\t<div style='font-size:0.9em'>{$i_detail}</div>\n\t\t\t\t\t\t</td>\n\t\t\t\t\t\t<td title='{$i_costprice}'>\n\t\t\t\t\t\t\t{$i_costcode}\n\t\t\t\t\t\t</td>\n\t\t\t\t\t\t<td title='" . $stock_info['total_purchase'] . "|" . $stock_info['total_sale'] . "|" . $stock_info['total_credit'] . "'>\n\t\t\t\t\t\t\t{$i_stocknumber}\n\t\t\t\t\t\t</td>\n\t\t\t\t\t\t<td>\n\t\t\t\t\t\t\t{$Currency}\n\t\t\t\t\t\t\t<div style='display: inline' id='editable_{$i_id}'>{$i_saleprice}</div>\n\t\t\t\t\t\t\t<input style='display: none' id='editbox_{$i_id}' size='4' value='{$i_saleprice}' type='text' />\n\t\t\t\t\t\t</td>\n\t\t\t\t\t</tr>\n\t\t\t\t\t"; } ?> </tbody> </table> </center> <!-- <div id="div_add_g" title="Add Group"> <form method="post" action="<?php
$first = 1; foreach ($terms as $term) { if ($first == 1) { $mysql_q = $mysql_q . " WHERE ( item_name LIKE '%{$term}%'"; } else { $mysql_q = $mysql_q . " AND item_name LIKE '%{$term}%'"; } $first = 0; } $mysql_q = $mysql_q . ")"; // $first=1; // foreach ($terms as $term) { // if ( $first == 1) // $mysql_q = $mysql_q." OR ( group_name LIKE '%$term%'"; // else // $mysql_q = $mysql_q." AND group_name LIKE '%$term%'"; // $first=0; // } // $mysql_q = $mysql_q.")"; } $q_result = $dbhi->query($mysql_q); if ($q_result->num_rows > 0) { while ($row = $q_result->fetch_assoc()) { $costprice = get_costprice($row['item_id'], $dbhi); $stock_info = get_stock_info($row['item_id'], $dbhi); $stock_num = $stock_info['total_purchase'] - $stock_info['total_sale'] - $stock_info['total_credit']; $data[] = array('label' => "<a>" . "#" . $row['item_id'] . " " . $row['item_name'] . "<span style='font-size:0.9em'>" . " (" . price2code($costprice) . "|" . clean_num($stock_num) . ")" . "</span>" . "<div style='font-size:0.8em'>" . $row['item_detail'] . "</div>" . "</a>", 'group' => $row['group_name'], 'detail' => $row['item_detail'], 'value' => $row['item_name'], 'id' => $row['item_id'], 'saleprice' => clean_num($row['item_saleprice']), 'costprice' => $costprice); } } echo json_encode($data); flush();
if (!isset($_GET['iid'])) { die("_GET[iid] not found"); } include_once 'config.php'; // MYSQL Connection and Database Selection $dbhi = new mysqli($mysql_host, $mysql_user, $mysql_pass, $mysql_database); if (mysqli_connect_errno()) { die('Could not connect to mysql: ' . mysqli_connect_errno()); } // ItemID from GET $current_itemid = $_GET['iid']; $current_iteminfo = get_item_info($current_itemid, $dbhi); $current_itemname = $current_iteminfo['name']; $current_itemsaleprice = $current_iteminfo['sale_price']; $current_itemdetail = $current_iteminfo['detail']; $current_stockinfo = get_stock_info($current_itemid, $dbhi); $current_totalsale = $current_stockinfo['total_sale']; $current_totalpurchase = $current_stockinfo['total_purchase']; // If addform is posted, insert values in database if (!empty($_POST['t_date_val']) && (!empty($_POST['tinvoiceno']) || $_POST['trans_t'] == 'Purchase') && $_POST['tuprice'] > 0 && $_POST['tqty'] > 0) { echo 'hellooo'; if ($_POST['trans_t'] == 'Sale') { $sql_q = "INSERT INTO sale_transactions\n\t\t\t\t\t\t\t\t( sale_trans_id, date, item_id, invoice_no, uprice, qty, amount_received, comments, timestamp )\n\t\t\t\t\t\tVALUES (\n\t\t\t\t\t\t\t\t'',\n\t\t\t\t\t\t\t\t'" . $_POST['t_date_val'] . "',\n\t\t\t\t\t\t\t\t'" . $_POST['iid'] . "',\n\t\t\t\t\t\t\t\t'" . $_POST['tinvoiceno'] . "',\n\t\t\t\t\t\t\t\t'" . $_POST['tuprice'] . "',\n\t\t\t\t\t\t\t\t'" . $_POST['tqty'] . "',\n\t\t\t\t\t\t\t\t'" . $_POST['tuprice'] * $_POST['tqty'] . "',\n\t\t\t\t\t\t\t\t'" . $_POST['tcomments'] . "',\n\t\t\t\t\t\t\t\t'" . time() . "'\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t"; } elseif ($_POST['trans_t'] == 'Purchase') { $sql_q = "INSERT INTO purchase_transactions\n\t\t\t\t\t\t\t\t( p_trans_id, date, item_id, vendor_id, invoice_id, uprice, qty, comments, timestamp )\n\t\t\t\t\t\tVALUES\t(\n\t\t\t\t\t\t\t\t'',\n\t\t\t\t\t\t\t\t'" . $_POST['t_date_val'] . "',\n\t\t\t\t\t\t\t\t'" . $_POST['iid'] . "',\n\t\t\t\t\t\t\t\t'',\n\t\t\t\t\t\t\t\t'',\n\t\t\t\t\t\t\t\t'" . $_POST['tuprice'] . "',\n\t\t\t\t\t\t\t\t'" . $_POST['tqty'] . "',\n\t\t\t\t\t\t\t\t'" . $_POST['tcomments'] . "',\n\t\t\t\t\t\t\t\t'" . time() . "'\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t"; } $dbhi->query($sql_q) or die($dbhi->error); if ($dbhi->affected_rows == 1) { header("Location: " . $_SERVER['PHP_SELF'] . "?iid=" . $_POST['iid'] . "&submit_success=yes&message=" . $_POST['trans_t'] . " Added"); } else { header("Location: " . $_SERVER['PHP_SELF'] . "?iid=" . $_POST['iid'] . "&submit_success=no&message=MYSQL_ERR_NOTONERET");