function view($frm) { extract($_REQUEST); if ($msg = cForm::validateValue($supid, "num", 1, 10)) { return "<li class='err'>The supplier ID is invalid. {$msg}</li>\n\t\t\t<input type='button' onclick='window.history.back();' value='« Correction' />"; } /* @var frm cForm */ $frm->settitle("Supplier Pricelist"); $frm->setkey("import"); $frm->add_heading("Import New Pricelist"); $frm->add_message("\n\t\t\t<li class='err'>Pricelists has to be in CSV format and to import them\n\t\t\t\tyou have to specify the order and format of the fields<br />\n\t\t\t\tby selecting what each of them are in the same order as they appear\n\t\t\t\tin the file. Only the stock code<br />\n\t\t\t\tand the price is needed, so for the other fields you simply\n\t\t\t\tselect the '-' options.\n\t\t\t</li>", "inst"); $frm->add_message("\n\t\t\t<li class='err'>Note that the stock codes of the supplier should be added\n\t\t\t\tby editing the stock item and selecting the<br />\n\t\t\t\t'Add/Edit/Remove' button below the stock code input field.\n\t\t\t</li>", "suppstkcod"); $frm->add_hidden("supid", $supid, "num"); $frm->add_file("Pricelist", "supplist"); $frm->add_checkbox("VAT Inclusive", "vatinc", true, true); $frm->add_heading("Comma Seperated Volume (CSV) Fields"); $frm->add_layout("\n\t<tr %bgc>\n\t\t<td colspan='2' nowrap='t'>\n\t\t\t<strong>\n\t\t\t\t%fldonly ,\n\t\t\t\t%fldonly ,\n\t\t\t\t%fldonly ,\n\t\t\t\t%fldonly ,\n\t\t\t\t%fldonly ,\n\t\t\t\t%fldonly\n\t\t\t</strong>\n\t\t</td>\n\t</tr>"); // field types $ft = array("ignore" => "-", "stkcod" => "Stock Code", "price" => "Price"); $frm->add_select("", "fld[0]", "stkcod", $ft, "string", "5:6"); $frm->add_select("", "fld[1]", "price", $ft, "string", "5:6"); $frm->add_select("", "fld[2]", "ignore", $ft, "string", "5:6"); $frm->add_select("", "fld[3]", "ignore", $ft, "string", "5:6"); $frm->add_select("", "fld[4]", "ignore", $ft, "string", "5:6"); $frm->add_select("", "fld[5]", "ignore", $ft, "string", "5:6"); $frm->add_ctrlbtn("Import", "submit", "btn_import"); $OUT = $frm->getfrm_input(); /* supplier info */ $suppinfo = qrySupplier($supid); $supcur = qryCurrency($suppinfo["fcid"]); $supcur = $supcur["symbol"]; /* list current pricelist */ $OUT .= "\n\t<table " . TMPL_tblDflts . ">\n\t<tr>\n\t\t<th>Stock Code</td>\n\t\t<th>Supplier Stock Code</th>\n\t\t<th>Current Supplier Price</th>\n\t\t<th>Current Selling Price</th>\n\t</tr>"; $sql = "SELECT pli.*\n\t\t\tFROM exten.spricelist pl INNER JOIN exten.splist_prices pli\n\t\t\t\tON pl.listid=pli.listid\n\t\t\tWHERE pl.suppid='{$supid}'"; $qry = new dbSql($sql); $qry->run(); if ($qry->num_rows() <= 0) { $OUT .= "\n\t\t<tr bgcolor='" . bgcolorc(0) . "'>\n\t\t\t<td colspan='4'>No pricelist.</td>\n\t\t</tr>"; } $i = 0; while ($row = $qry->fetch_array()) { if (empty($row["supstkcod"])) { $our_stkcod = "No supplier stock code"; $our_price = ""; } else { if (($stkid = suppStkid($supid, $row["supstkcod"])) === false) { $our_stkcod = "<li class='err'>No such stock item.\n\t\t\t\t<a href='stock-add.php?stkcod={$row['supstkcod']}&supid={$supid}&supstkcod={$row['supstkcod']}'>Add Stock</a> /\n\t\t\t\t<a href='stock-view.php'>Edit Stock</li>"; $our_price = ""; } else { $stkrow = qryStock($stkid, "stkcod, selamt"); $our_stkcod = "<strong>{$stkrow['stkcod']}</strong>"; $our_price = CUR . " " . sprint($stkrow["selamt"]); } } $OUT .= "\n\t\t<tr bgcolor='" . bgcolor($i) . "'>\n\t\t\t<td>{$our_stkcod}</td>\n\t\t\t<td>{$row['supstkcod']}</td>\n\t\t\t<td align='right'>{$supcur} " . sprint($row["price"]) . "</td>\n\t\t\t<td align='right'>{$our_price}</td>\n\t\t</tr>"; } $OUT .= "\n\t</table>"; return $OUT; }
function edit($accid, $err = "") { require_lib("validate"); $v = new validate(); $v->isOk($accid, "num", 1, 50, "Invalid Account number."); if ($v->isError()) { return $v->genErrors(); } $acc = qryAccounts($accid); $acctypes = array("I" => "Income", "E" => "Expense", "B" => "Balance"); $size = strlen($acc['accname']); if ($size < 20) { $size = 20; } $OUT = "\n\t<h3>Edit Account</h3>\n\t{$err}\n\t<form action='" . SELF . "' method=post>\n\t<table " . TMPL_tblDflts . ">\n\t\t<input type='hidden' name='key' value='confirm' />\n\t\t<input type='hidden' name='accid' value='{$acc['accid']}' />\n\t\t<input type='hidden' name='fcatid' value='{$acc['catid']}' />\n\t\t<input type='hidden' name='acctype' value='{$acc['acctype']}' />\n\t\t<tr>\n\t\t\t<th>Field</th>\n\t\t\t<th>Value</th>\n\t\t</tr>\n\t\t<tr class='" . bg_class() . "'>\n\t\t\t<td>Account Name</td>\n\t\t\t<td>{$acc['accname']}</td>\n\t\t</tr>\n\t\t<tr class='" . bg_class() . "'>\n\t\t\t<td>Account Type</td>\n\t\t\t<td>" . $acctypes[$acc["acctype"]] . "</td>\n\t\t</tr>\n\t\t<tr class='" . bg_class() . "'>\n\t\t\t<td>To Category</td>\n\t\t\t<td>\n\t\t\t\t<select name=catid>"; $sql = "SELECT 'I' AS acctype, * FROM core.income WHERE div = '" . USER_DIV . "'\n\t\t\t\tUNION\n\t\t\t\tSELECT 'E' AS acctype, * FROM core.expenditure WHERE div='" . USER_DIV . "'\n\t\t\t\tUNION\n\t\t\t\tSELECT 'B' AS acctype, * FROM core.balance WHERE div='" . USER_DIV . "'"; $cats = new dbSql($sql); $cats->run(); if ($cats->num_rows() < 1) { return "There are no Account Categories in Cubit."; } $pgroup = false; while ($cat = $cats->fetch_array()) { if ($pgroup != $cat["acctype"]) { if ($pgroup) { $OUT .= "</optgroup>"; } $OUT .= "<optgroup label='" . $acctypes[$cat["acctype"]] . "'>"; } if ($cat["catid"] == $acc["catid"]) { $sel = "selected"; } else { $sel = ""; } $OUT .= "<option {$sel} value='{$cat['catid']}'>{$cat['catname']}</option>"; } $OUT .= "\n\t\t\t\t</optgroup>\n\t\t\t</select>\n\t\t</td></tr>\n\t\t<tr class='" . bg_class() . "'>\n\t\t\t<td>Account Number</td>\n\t\t\t<td valign='center'><input type='text' name='topacc' size='4' maxlength='4' value='{$acc['topacc']}' /> / <input type='text' name='accnum' size='3' maxlength='3' value='{$acc['accnum']}' /></td>\n\t\t</tr>\n\t\t" . TBL_BR . "\n\t\t<tr>\n\t\t\t<td colspan='2' align='right'><input type='submit' value='Confirm »' /></td>\n\t\t</tr>\n\t</table>\n\t</form>" . mkQuickLinks(ql("acc-view.php", "View Accounts")); return $OUT; }