<input type="image" height=35 width=35 src="imgs/add.png" /> </th> </tr> </form> </thead> <tbody> <?php $mysql_q = "\n\t\t\t\t\t\t\t\tSELECT p_trans_id, date, item_id, vendor_id, invoice_id, uprice, qty, comments, timestamp\n\t\t\t\t\t\t\t\tFROM purchase_transactions\n\t\t\t\t\t\t\t\tORDER BY p_trans_id DESC\n\t\t\t\t\t\t\t\t"; $query_res = $dbhi->query($mysql_q); while ($row = $query_res->fetch_assoc()) { $item_info = get_item_info($row['item_id'], $dbhi); $row_style = 'style="color:#d00000"'; if (!empty($row['invoice_id'])) { $inv_no = get_vendor_invoice($row['invoice_id'], $dbhi); $invoice_html = "\t<a name='a_invid[]' href='javascript:;'>\n\t\t\t\t\t\t\t\t\t\t\t\t{$inv_no}\n\t\t\t\t\t\t\t\t\t\t\t\t<input type='hidden' name='val_invid[]' value='" . $row['invoice_id'] . "' />\n\t\t\t\t\t\t\t\t\t\t\t</a>"; } else { $invoice_html = "N/A"; } echo "\n\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t<td {$row_style}>" . $row['date'] . "</td>\n\n\t\t\t\t\t\t\t\t<td {$row_style}>\n\t\t\t\t\t\t\t\t\t<a href='transactions.php?iid=" . $row['item_id'] . "'>\n\t\t\t\t\t\t\t\t\t\t" . $item_info['name'] . "\n\t\t\t\t\t\t\t\t\t</a>\n\t\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t\t\t<td {$row_style}>\n\t\t\t\t\t\t\t\t\t<a href='vendors.php?vendorid=" . $row['vendor_id'] . "'>\n\t\t\t\t\t\t\t\t\t\t" . get_vendorname($row['vendor_id'], $dbhi) . "\n\t\t\t\t\t\t\t\t\t</a>\n\t\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t\t\t<td {$row_style}>{$invoice_html}</td>\n\t\t\t\t\t\t\t\t<td {$row_style} title='" . clean_num($row['uprice']) . "'>" . price2code(clean_num($row['uprice'])) . "</td>\n\t\t\t\t\t\t\t\t<td {$row_style}>" . clean_num($row['qty']) . "</td>\n\t\t\t\t\t\t\t\t<td {$row_style} title='" . clean_num($row['uprice'] * $row['qty']) . "'>" . price2code(clean_num($row['uprice'] * $row['qty'])) . "</td>\n\t\t\t\t\t\t\t\t<td {$row_style}>\n\t\t\t\t\t\t\t\t\t<pre style='display:inline;'>" . $row['comments'] . "</pre>\n\t\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t"; } ?> </tbody> </table> </center> <div id="v_inv_div"></div>
<?php 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()); } $vendorID = $_GET['vendorid']; $vendorName = get_vendorname($vendorID, $dbhi); //If Invoices are selected for payments, generate the payment form/div if (isset($_POST['invpay_check'])) { echo "\n\t\t\t<div style='display:none;padding:0px' name='div_addpayment'>\n\t\t\t\t<table style='margin:0px;' class='tclass_std' border='1'>\n\t\t\t\t\t<form name='add_payment' method='post' action='" . $_SERVER['PHP_SELF'] . "?vendorid={$vendorID}'>\n\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<th colspan='2'>\n\t\t\t\t\t\t\t\tAdding Payment for {$vendorName}\n\t\t\t\t\t\t\t</th>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td>Date: </td>\n\t\t\t\t\t\t\t<td>\n\t\t\t\t\t\t\t\t<input type='text' name='vp_date_disp'' size=10 readonly/>\n \t\t\t\t\t\t\t\t<input type='hidden' name='vp_date_val' />\n\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td>Invoices: </td>\n\t\t\t\t\t\t\t<td>\n\t\t\t\t"; foreach ($_POST['invpay_check'] as $invid_topay) { echo "\n\t\t\t\t\t\t\t\t\t\t<div class='wrap_box'>\n\t\t\t\t\t\t\t\t\t\t\t" . get_vendor_invoice($invid_topay, $dbhi) . "\n\t\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t\t"; } foreach ($_POST['invpay_check'] as $invid_topay) { echo "<input type='hidden' name='vp_invids[]' value='{$invid_topay}' />"; } echo "\n\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td>Payment Type: </td>\n\t\t\t\t\t\t\t<td>\n\t\t\t\t\t\t\t\t<select name='vp_payment_t'>\n\t\t\t\t"; foreach ($Payment_Types as $_paymentt) { echo "<option value=\"{$_paymentt}\">{$_paymentt}</option>"; } echo "\n\t\t\t\t\t\t\t\t</select>\n\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td>Reference #: </td>\n\t\t\t\t\t\t\t<td>\n\t\t\t\t\t\t\t\t<input type='text' name='vp_refno' />\n\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td>Comments: </td>\n\t\t\t\t\t\t\t<td>\n\t\t\t\t\t\t\t\t<textarea name='vp_comment' rows=1 cols=24 ></textarea>\n\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td colspan='2' align='center'>\n\t\t\t\t\t\t\t\t<input type='submit' name='vp_submit' value='Add Payment' />\n\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t</form>\n\t\t\t\t</table>\n\t\t\t</div>\n\t\t"; } //If the payment form is submitted, add the payment if ($_POST['vp_submit'] == 'Add Payment') { //Add Payment and Get the PaymentID $mysql_q = "\tINSERT INTO payment_out\n\t\t\t\t\t\t(payment_id, date, payment_type, ref_no, comments, timestamp)\n\t\t\t\t\tVALUES (\n\t\t\t\t\t\t\t'',\n\t\t\t\t\t\t\t'" . $_POST['vp_date_val'] . "',\n\t\t\t\t\t\t\t'" . $_POST['vp_payment_t'] . "',\n\t\t\t\t\t\t\t'" . $_POST['vp_refno'] . "',\n\t\t\t\t\t\t\t'" . $_POST['vp_comment'] . "',\n\t\t\t\t\t\t\t'" . time() . "'\n\t\t\t\t\t\t\t)\n\t\t"; $dbhi->query($mysql_q) or die($dbhi->error); $new_payment_id = $dbhi->insert_id;