本文整理匯總了PHP中DB_free_result函數的典型用法代碼示例。如果您正苦於以下問題:PHP DB_free_result函數的具體用法?PHP DB_free_result怎麽用?PHP DB_free_result使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了DB_free_result函數的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: DB_query
}
$SQL = "SELECT currabrev FROM currencies";
$result = DB_query($SQL);
require_once 'includes/CurrenciesArray.php';
echo '<table class="selection">';
echo '<tr><td>' . _('Currency') . ':</td>
<td><select name="CurrAbrev">';
while ($myrow = DB_fetch_array($result)) {
echo '<option';
if ($myrow['currabrev'] == $_POST['CurrAbrev']) {
echo ' selected="selected"';
}
echo ' value="' . $myrow['currabrev'] . '">' . $CurrencyName[$myrow['currabrev']] . '</option>';
}
// End while loop
DB_free_result($result);
echo '</select></td>';
$sql = "SELECT typeabbrev,\r\n\t\tsales_type\r\n\t\tFROM salestypes";
$result = DB_query($sql);
echo '<tr><td>' . _('Customer Price List') . ' (' . _('Sales Type') . '):</td><td>';
echo '<select tabindex="1" name="SalesType">';
while ($myrow = DB_fetch_array($result)) {
if (isset($_POST['SalesType']) and $myrow['typeabbrev'] == $_POST['SalesType']) {
echo '<option selected="selected" value="' . $myrow['typeabbrev'] . '">' . $myrow['sales_type'] . '</option>';
} else {
echo '<option value="' . $myrow['typeabbrev'] . '">' . $myrow['sales_type'] . '</option>';
}
}
echo '</select></td></tr>';
if (isset($_GET['StockID'])) {
$StockID = trim($_GET['StockID']);
示例2: while
$Changes = 0;
while ($myrow = DB_fetch_array($Result)) {
if ($_SESSION['Items']->LineItems[$myrow['orderlineno']]->Quantity != $myrow['quantity'] or $_SESSION['Items']->LineItems[$myrow['orderlineno']]->QtyInv != $myrow['qtyinvoiced']) {
echo '<br>' . _('Orig order for') . ' ' . $myrow['orderlineno'] . ' ' . _('has a quantity of') . ' ' . $myrow['quantity'] . ' ' . _('and an invoiced qty of') . ' ' . $myrow['qtyinvoiced'] . ' ' . _('the session shows quantity of') . ' ' . $_SESSION['Items']->LineItems[$myrow['orderlineno']]->Quantity . ' ' . _('and quantity invoice of') . ' ' . $_SESSION['Items']->LineItems[$myrow['orderlineno']]->QtyInv;
prnMsg(_('This order has been changed or invoiced since this delivery was started to be confirmed') . ' ' . _('Processing halted.') . ' ' . _('To enter and confirm this dispatch, it must be re-selected and re-read again to update the changes made by the other user'), 'error');
echo '<br>';
echo '<div class="centre"><a href="' . $rootpath . '/SelectSalesOrder.php?' . SID . '">' . _('Select a sales order for confirming deliveries and invoicing') . '</a></div>';
unset($_SESSION['Items']->LineItems);
unset($_SESSION['Items']);
unset($_SESSION['ProcessingOrder']);
include 'includes/footer.inc';
exit;
}
}
/*loop through all line items of the order to ensure none have been invoiced since started looking at this order*/
DB_free_result($Result);
/*Now Get the next invoice number - function in SQL_CommonFunctions*/
$InvoiceNo = GetNextTransNo(10, $db);
$PeriodNo = GetPeriod($DefaultDispatchDate, $db);
/*Start an SQL transaction */
DB_Txn_Begin($db);
if ($DefaultShipVia != $_SESSION['Items']->ShipVia) {
$SQL = "UPDATE custbranch SET defaultshipvia ='" . $_SESSION['Items']->ShipVia . "' WHERE debtorno='" . $_SESSION['Items']->DebtorNo . "' AND branchcode='" . $_SESSION['Items']->Branch . "'";
$ErrMsg = _('Could not update the default shipping carrier for this branch because');
$DbgMsg = _('The SQL used to update the branch default carrier was');
$result = DB_query($SQL, $db, $ErrMsg, $DbgMsg, true);
}
$DefaultDispatchDate = FormatDateForSQL($DefaultDispatchDate);
/*Update order header for invoice charged on */
$SQL = "UPDATE salesorders SET comments = CONCAT(comments,' Inv ','" . $InvoiceNo . "') WHERE orderno= " . $_SESSION['ProcessingOrder'];
$ErrMsg = _('CRITICAL ERROR') . ' ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('The sales order header could not be updated with the invoice number');
示例3: _
$sql = "SELECT materialcost,\n\t\t\t\t\tlabourcost,\n\t\t\t\t\toverheadcost,\n\t\t\t\t\tmbflag,\n\t\t\t\t\tsum(quantity) as totalqoh\n\t\t\tFROM stockmaster INNER JOIN locstock\n\t\t\tON stockmaster.stockid=locstock.stockid\n\t\t\tWHERE stockmaster.stockid='" . $StockID . "'\n\t\t\tGROUP BY description,\n\t\t\t\t\tunits,\n\t\t\t\t\tlastcost,\n\t\t\t\t\tactualcost,\n\t\t\t\t\tmaterialcost,\n\t\t\t\t\tlabourcost,\n\t\t\t\t\toverheadcost,\n\t\t\t\t\tmbflag";
$ErrMsg = _('The entered item code does not exist');
$OldResult = DB_query($sql, $ErrMsg);
$OldRow = DB_fetch_array($OldResult);
$_POST['QOH'] = $OldRow['totalqoh'];
$_POST['OldMaterialCost'] = $OldRow['materialcost'];
if ($OldRow['mbflag'] == 'M') {
$_POST['OldLabourCost'] = $OldRow['labourcost'];
$_POST['OldOverheadCost'] = $OldRow['overheadcost'];
} else {
$_POST['OldLabourCost'] = 0;
$_POST['OldOverheadCost'] = 0;
$_POST['LabourCost'] = 0;
$_POST['OverheadCost'] = 0;
}
DB_free_result($OldResult);
$OldCost = $_POST['OldMaterialCost'] + $_POST['OldLabourCost'] + $_POST['OldOverheadCost'];
$NewCost = filter_number_format($_POST['MaterialCost']) + filter_number_format($_POST['LabourCost']) + filter_number_format($_POST['OverheadCost']);
$result = DB_query("SELECT * FROM stockmaster WHERE stockid='" . $StockID . "'");
$myrow = DB_fetch_row($result);
if (DB_num_rows($result) == 0) {
prnMsg(_('The entered item code does not exist'), 'error', _('Non-existent Item'));
} elseif ($OldCost != $NewCost) {
$Result = DB_Txn_Begin();
ItemCostUpdateGL($db, $StockID, $NewCost, $OldCost, $_POST['QOH']);
$SQL = "UPDATE stockmaster SET\tmaterialcost='" . filter_number_format($_POST['MaterialCost']) . "',\n\t\t\t\t\t\t\t\t\t\tlabourcost='" . filter_number_format($_POST['LabourCost']) . "',\n\t\t\t\t\t\t\t\t\t\toverheadcost='" . filter_number_format($_POST['OverheadCost']) . "',\n\t\t\t\t\t\t\t\t\t\tlastcost='" . $OldCost . "',\n\t\t\t\t\t\t\t\t\t\tlastcostupdate ='" . Date('Y-m-d') . "'\n\t\t\t\t\t\t\t\tWHERE stockid='" . $StockID . "'";
$ErrMsg = _('The cost details for the stock item could not be updated because');
$DbgMsg = _('The SQL that failed was');
$Result = DB_query($SQL, $ErrMsg, $DbgMsg, true);
$Result = DB_Txn_Commit();
UpdateCost($db, $StockID);
示例4: _
if (isset($_POST['StockType']) and $_POST['StockType'] == 'L') {
echo _('Labour Efficiency Variance GL Code');
} else {
echo _('Usage Variance GL Code');
}
echo ':</td>
<td><select name="MaterialUseageVarAc">';
while ($myrow = DB_fetch_array($PnLAccountsResult)) {
if (isset($_POST['MaterialUseageVarAc']) and $myrow['accountcode'] == $_POST['MaterialUseageVarAc']) {
echo '<option selected="selected" value="' . $myrow['accountcode'] . '">' . htmlspecialchars($myrow['accountname'], ENT_QUOTES, 'UTF-8', false) . ' (' . $myrow['accountcode'] . ')' . '</option>';
} else {
echo '<option value="' . $myrow['accountcode'] . '">' . htmlspecialchars($myrow['accountname'], ENT_QUOTES, 'UTF-8', false) . ' (' . $myrow['accountcode'] . ')' . '</option>';
}
}
//end while loop
DB_free_result($PnLAccountsResult);
echo '</select></td>
</tr>
</table>';
if (!isset($SelectedCategory)) {
$SelectedCategory = '';
}
if (isset($SelectedCategory)) {
//editing an existing stock category
$sql = "SELECT stkcatpropid,\n\t\t\t\t\tlabel,\n\t\t\t\t\tcontroltype,\n\t\t\t\t\tdefaultvalue,\n\t\t\t\t\tnumericvalue,\n\t\t\t\t\treqatsalesorder,\n\t\t\t\t\tminimumvalue,\n\t\t\t\t\tmaximumvalue\n\t\t\t FROM stockcatproperties\n\t\t\t WHERE categoryid='" . $SelectedCategory . "'\n\t\t\t ORDER BY stkcatpropid";
$result = DB_query($sql);
/* echo '<br />Number of rows returned by the sql = ' . DB_num_rows($result) .
'<br />The SQL was:<br />' . $sql;
*/
echo '<br />
<table class="selection">
示例5: array
include 'includes/header.inc';
include 'includes/SQL_CommonFunctions.inc';
$ModuleList = array(_('Orders'), _('Receivables'), _('Payables'), _('Purchasing'), _('Inventory'), _('Manufacturing'), _('General Ledger'), _('Asset Manager'), _('Petty Cash'), _('Setup'));
echo '<a href="' . $rootpath . '/SelectSupplier.php?">' . _('Back to Suppliers') . '</a><br />';
echo '<p class="page_title_text"><img src="' . $rootpath . '/css/' . $theme . '/images/supplier.png" title="' . _('Supplier') . '" alt="" />' . ' ' . _('Supplier') . ' : ' . $_SESSION['SupplierID'] . _(' has been selected') . '</p><br />';
//Make an array of the security roles where only one role is active and is ID 1
//For the security role selection box, we will only show roles that have:
//- Only one entry in securitygroups AND the tokenid of this entry == 1
//First get all available security role ID's'
$sql = "SELECT secroleid, secrolename FROM securityroles WHERE secrolename = 'Supplier Log On Only'";
$Sec_Result = DB_query($sql, $db);
// Now load it into an aray using Key/Value pairs
while ($Sec_row = DB_fetch_array($Sec_Result)) {
$SecurityRoles[$Sec_row['secroleid']] = $Sec_row['secrolename'];
}
DB_free_result($Sec_Result);
if (isset($_GET['SelectedUser'])) {
$SelectedUser = $_GET['SelectedUser'];
} elseif (isset($_POST['SelectedUser'])) {
$SelectedUser = $_POST['SelectedUser'];
}
if (isset($_POST['submit'])) {
//initialise no input errors assumed initially before we test
$InputError = 0;
/* actions to take once the user has clicked the submit button
ie the page has called itself with some user input */
//first off validate inputs sensible
if (mb_strlen($_POST['UserID']) < 3) {
$InputError = 1;
prnMsg(_('The user ID entered must be at least 4 characters long'), 'error');
} elseif (ContainsIllegalCharacters($_POST['UserID'])) {
示例6: DB_query
// $ForceConfigReload to true
if (isset($ForceConfigReload) or !isset($_SESSION['CompanyDefaultsLoaded'])) {
$sql = 'SELECT confname, confvalue FROM config';
// dont care about the order by
$ConfigResult = DB_query($sql, $db);
while ($myrow = DB_fetch_row($ConfigResult)) {
if (is_numeric($myrow[1])) {
//the variable name is given by $myrow[0]
$_SESSION[$myrow[0]] = (double) $myrow[1];
} else {
$_SESSION[$myrow[0]] = $myrow[1];
}
}
//end loop through all config variables
$_SESSION['CompanyDefaultsLoaded'] = true;
DB_free_result($ConfigResult);
// no longer needed
/* Also reads all the company data set up in the company record and returns an array */
$sql = "SELECT\n\t\tcoyname,\n\t\tgstno,\n\t\tregoffice1,\n\t\tregoffice2,\n\t\tregoffice3,\n\t\tregoffice4,\n\t\tregoffice5,\n\t\tregoffice6,\n\t\ttelephone,\n\t\tfax,\n\t\temail,\n\t\tcurrencydefault,\n\t\tdebtorsact,\n\t\tpytdiscountact,\n\t\tcreditorsact,\n\t\tpayrollact,\n\t\tgrnact,\n\t\texchangediffact,\n\t\tpurchasesexchangediffact,\n\t\tretainedearnings,\n\t\tfreightact,\n\t\tgllink_debtors,\n\t\tgllink_creditors,\n\t\tgllink_stock\n\tFROM companies\n\tWHERE coycode=1";
$ErrMsg = _('An error occurred accessing the database to retrieve the company information');
$ReadCoyResult = DB_query($sql, $db, $ErrMsg);
if (DB_num_rows($ReadCoyResult) == 0) {
echo '<BR><B>';
prnMsg(_('The company record has not yet been set up') . '</B><BR>' . _('From the system setup tab select company maintenance to enter the company infomation and system preferences'), 'error', _('CRITICAL PROBLEM'));
exit;
} else {
$_SESSION['CompanyRecord'] = DB_fetch_array($ReadCoyResult);
}
}
//end if force reload or not set already
/*
示例7: sum
$sql = "SELECT materialcost,\n labourcost,\n overheadcost,\n mbflag,\n sum(quantity) as totalqoh\n FROM stockmaster INNER JOIN locstock\n ON stockmaster.stockid=locstock.stockid\n WHERE stockmaster.stockid='" . $StockID . "'\n GROUP BY description,\n units,\n lastcost,\n actualcost,\n materialcost,\n labourcost,\n overheadcost,\n mbflag";
$ErrMsg = _('The entered item code does not exist');
$oldresult = DB_query($sql, $db, $ErrMsg);
$oldrow = DB_fetch_array($oldresult);
$_POST['QOH'] = $oldrow['totalqoh'];
$_POST['OldMaterialCost'] = $oldrow['materialcost'];
if ($oldrow['mbflag'] == 'M') {
$_POST['OldLabourCost'] = $oldrow['labourcost'];
$_POST['OldOverheadCost'] = $oldrow['overheadcost'];
} else {
$_POST['OldLabourCost'] = 0;
$_POST['OldOverheadCost'] = 0;
$_POST['LabourCost'] = 0;
$_POST['OverheadCost'] = 0;
}
DB_free_result($oldresult);
$OldCost = $_POST['OldMaterialCost'] + $_POST['OldLabourCost'] + $_POST['OldOverheadCost'];
$NewCost = $_POST['MaterialCost'] + $_POST['LabourCost'] + $_POST['OverheadCost'];
$result = DB_query("SELECT * FROM stockmaster WHERE stockid='{$StockID}'", $db);
$myrow = DB_fetch_row($result);
if (DB_num_rows($result) == 0) {
prnMsg(_('The entered item code does not exist'), 'error', _('Non-existent Item'));
} elseif ($OldCost != $NewCost) {
$Result = DB_Txn_Begin($db);
ItemCostUpdateGL($db, $StockID, $NewCost, $OldCost, $_POST['QOH']);
$SQL = "UPDATE stockmaster SET\n\t\t\t\t\tmaterialcost=" . $_POST['MaterialCost'] . ",\n\t\t\t\t\tlabourcost=" . $_POST['LabourCost'] . ",\n\t\t\t\t\toverheadcost=" . $_POST['OverheadCost'] . ",\n\t\t\t\t\tlastcost=" . $OldCost . "\n\t\t\tWHERE stockid='" . $StockID . "'";
$ErrMsg = _('The cost details for the stock item could not be updated because');
$DbgMsg = _('The SQL that failed was');
$Result = DB_query($SQL, $db, $ErrMsg, $DbgMsg, true);
$Result = DB_Txn_Commit($db);
UpdateCost($db, $StockID);
示例8: stripcomma
echo '<br />' . $SQL;
}
include 'includes/footer.inc';
exit;
}
$CSVContent = stripcomma('stockid') . ',' . stripcomma('description') . ',' . stripcomma('barcode') . ',' . stripcomma('units') . ',' . stripcomma('mbflag') . ',' . stripcomma('taxcatid') . ',' . stripcomma('discontinued') . ',' . stripcomma('price') . ',' . stripcomma('qty') . ',' . stripcomma('categoryid') . ',' . stripcomma('categorydescription') . "\n";
while ($PriceList = DB_fetch_array($PricesResult, $db)) {
$Qty = 0;
$sqlQty = "SELECT newqoh\n\t\t\tFROM stockmoves\n\t\t\tWHERE stockid = '" . $PriceList['stockid'] . "'\n\t\t\tAND loccode = '" . $_POST['Location'] . "'\n\t\t\tORDER BY stkmoveno DESC LIMIT 1";
$resultQty = DB_query($sqlQty, $ErrMsg);
if ($resultQty) {
if (DB_num_rows($resultQty) > 0) {
$Row = DB_fetch_row($resultQty);
$Qty = $Row[0];
}
DB_free_result($resultQty);
}
$DisplayUnitPrice = $PriceList['price'];
$CSVContent .= stripcomma($PriceList['stockid']) . ',' . stripcomma($PriceList['description']) . ',' . stripcomma($PriceList['barcode']) . ',' . stripcomma($PriceList['units']) . ',' . stripcomma($PriceList['mbflag']) . ',' . stripcomma($PriceList['taxcatid']) . ',' . stripcomma($PriceList['discontinued']) . ',' . stripcomma($DisplayUnitPrice) . ',' . stripcomma($Qty) . ',' . stripcomma($PriceList['categoryid']) . ',' . stripcomma($PriceList['categorydescription']) . "\n";
}
header('Content-type: application/csv');
header('Content-Length: ' . mb_strlen($CSVContent));
header('Content-Disposition: inline; filename=PriceList.csv');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
echo $CSVContent;
exit;
} elseif (isset($_POST['custlist'])) {
$SQL = "SELECT debtorsmaster.debtorno,\n\t\t\tcustbranch.branchcode,\n\t\t\tdebtorsmaster.name,\n\t\t\tcustbranch.contactname,\n\t\t\tdebtorsmaster.address1,\n\t\t\tdebtorsmaster.address2,\n\t\t\tdebtorsmaster.address3,\n\t\t\tdebtorsmaster.address4,\n\t\t\tdebtorsmaster.address5,\n\t\t\tdebtorsmaster.address6,\n\t\t\tdebtorsmaster.currcode,\n\t\t\tdebtorsmaster.clientsince,\n\t\t\tdebtorsmaster.creditlimit,\n\t\t\tdebtorsmaster.taxref,\n\t\t\tcustbranch.braddress1,\n\t\t\tcustbranch.braddress2,\n\t\t\tcustbranch.braddress3,\n\t\t\tcustbranch.braddress4,\n\t\t\tcustbranch.braddress5,\n\t\t\tcustbranch.braddress6,\n\t\t\tcustbranch.disabletrans,\n\t\t\tcustbranch.phoneno,\n\t\t\tcustbranch.faxno,\n\t\t\tcustbranch.email\n\t\tFROM debtorsmaster,\n\t\t\tcustbranch\n\t\tWHERE debtorsmaster.debtorno=custbranch.debtorno\n\t\tAND ((defaultlocation = '" . $_POST['Location'] . "') OR (defaultlocation = '') OR (defaultlocation IS NULL))";
$CustResult = DB_query($SQL, '', '', false, false);
示例9: MonthAndYearFromSQLDate
if ($j == 1) {
echo '<tr class="OddTableRows">';
$j = 0;
} else {
echo '<tr class="EvenTableRows">';
$j++;
}
echo ' <td>' . MonthAndYearFromSQLDate($TransRow['lastdate_in_period']) . '</td>
<td>' . $TranDate . '</td>
<td><a href="' . $URL . $DetailRow['otherpartycode'] . $FromDate . '">' . $TransRow['accountname'] . ' - ' . $DetailRow['otherparty'] . '</a></td>
<td>' . $TransRow['narrative'] . '</td>
<td class="number">' . $Debit . '</td>
<td class="number">' . $Credit . '</td>
<td>' . $Posted . '</td>
</tr>';
}
DB_free_result($DetailResult);
$AnalysisCompleted = 'Done';
}
}
DB_free_result($TransResult);
echo '<tr style="background-color:#FFFFFF">
<td class="number" colspan="4"><b>' . _('Total') . '</b></td>
<td class="number"><b>' . locale_number_format($DebitTotal, $_SESSION['CompanyRecord']['decimalplaces']) . '</b></td>
<td class="number"><b>' . locale_number_format(-$CreditTotal, $_SESSION['CompanyRecord']['decimalplaces']) . '</b></td>
<td> </td>
</tr>
</table>';
}
}
include 'includes/footer.inc';
示例10: array
<?php
/* $Id: GetPaymentMethods.php 5768 2012-12-20 08:38:22Z daintree $*/
$PaytTypes = array();
$ReceiptTypes = array();
$sql = 'SELECT paymentname,
paymenttype,
receipttype
FROM paymentmethods
ORDER by paymentname';
$PMResult = DB_query($sql, $db);
while ($PMrow = DB_fetch_array($PMResult)) {
if ($PMrow['paymenttype'] == 1) {
$PaytTypes[] = $PMrow['paymentname'];
}
if ($PMrow['receipttype'] == 1) {
$ReceiptTypes[] = $PMrow['paymentname'];
}
}
DB_free_result($PMResult);
// no longer needed
示例11: while
include 'includes/footer.inc';
exit;
}
while ($GLRow = DB_fetch_array($GLTransResult)) {
$LeftOvers = $pdf->addTextWrap($Left_Margin + 150, $YPos, 90, $FontSize, $GLRow['accountname'], 'left');
$LeftOvers = $pdf->addTextWrap($Left_Margin + 245, $YPos, 60, $FontSize, locale_money_format($GLRow['amount'], $Currency), 'right');
$LeftOvers = $pdf->addTextWrap($Left_Margin + 310, $YPos, 120, $FontSize, $GLRow['narrative'], 'left');
$YPos -= $line_height;
if ($YPos - 2 * $line_height < $Bottom_Margin) {
/*Then set up a new page */
$PageNumber++;
include 'includes/PDFChequeListingPageHeader.inc';
}
/*end of new page header */
}
DB_free_result($GLTransResult);
$YPos -= $line_height;
$TotalCheques = $TotalCheques - $myrow['amount'];
if ($YPos - 2 * $line_height < $Bottom_Margin) {
/*Then set up a new page */
$PageNumber++;
include 'includes/PDFChequeListingPageHeader.inc';
}
/*end of new page header */
}
/* end of while there are customer receipts in the batch to print */
$YPos -= $line_height;
$LeftOvers = $pdf->addTextWrap($Left_Margin, $YPos, 60, $FontSize, locale_money_format($TotalCheques, $Currency), 'right');
$LeftOvers = $pdf->addTextWrap($Left_Margin + 65, $YPos, 300, $FontSize, _('TOTAL') . ' ' . $Currency . ' ' . _('CHEQUES'), 'left');
$ReportFileName = $_SESSION['DatabaseName'] . '_ChequeListing_' . date('Y-m-d') . '.pdf';
$pdf->OutputD($ReportFileName);
示例12: chartdetails
$sql = "INSERT INTO chartdetails (accountcode, period)\n\t\t\tSELECT chartmaster.accountcode, periods.periodno\n\t\tFROM chartmaster CROSS JOIN periods\n\t\t\tLEFT JOIN chartdetails ON chartmaster.accountcode = chartdetails.accountcode\n\t\t\t\tAND periods.periodno = chartdetails.period\n\t\tWHERE (periods.periodno BETWEEN '" . $CreateFrom . "' AND '" . $CreateTo . "')\n\t\tAND chartdetails.accountcode IS NULL";
$ErrMsg = _('Inserting new chart details records required failed because');
$InsChartDetailsRecords = DB_query($sql, $db, $ErrMsg);
while ($AccountRow = DB_fetch_array($ChartDetailsNotSetUpResult)) {
/*Now run through each of the new chartdetail records created for each account and update them with the B/Fwd and B/Fwd budget no updates would be required where there were previously no chart details set up ie FirstPeriodPostedTo > 0 */
$sql = "SELECT actual,\n\t\t\t\tbfwd,\n\t\t\t\tbudget,\n\t\t\t\tbfwdbudget,\n\t\t\t\tperiod\n\t\t\tFROM chartdetails\n\t\t\tWHERE period >='" . ($AccountRow['period'] - 1) . "'\n\t\t\tAND accountcode='" . $AccountRow['accountcode'] . "'\n\t\t\tORDER BY period";
$ChartDetails = DB_query($sql, $db);
DB_Txn_Begin($db);
$BFwd = '';
$BFwdBudget = '';
$CFwd = 0;
$CFwdBudget = 0;
while ($myrow = DB_fetch_array($ChartDetails)) {
if ($BFwd = '') {
$BFwd = $myrow['bfwd'];
$BFwdBudget = $myrow['bfwdbudget'];
} else {
$BFwd += $myrow['actual'];
$BFwdBudget += $myrow['budget'];
$sql = "UPDATE chartdetails SET bfwd ='" . $BFwd . "',\n\t\t\t\t\t\t\tbfwdbudget ='" . $BFwdBudget . "'\n\t\t\t\t\tWHERE accountcode = '" . $AccountRow['accountcode'] . "'\n\t\t\t\t\tAND period ='" . ($myrow['period'] + 1) . "'";
$UpdChartDetails = DB_query($sql, $db, '', '', '', false);
}
}
DB_Txn_Commit($db);
DB_free_result($ChartDetailsCFwd);
}
prnMsg(_('Chart Details Created successfully'), 'success');
} else {
prnMsg(_('No additional chart details were required to be added'), 'success');
}
include 'includes/footer.inc';
示例13: substr
}
} else {
// for a specific stock category
if ($_POST['SupplierItemsOnly'] == 'on') {
$sql = "SELECT stockmaster.stockid,\n\t\t\t\t\t\t\t\tstockmaster.description,\n\t\t\t\t\t\t\t\tstockmaster.units\n\t\t\t\t\t\tFROM stockmaster INNER JOIN stockcategory\n\t\t\t\t\t\tON stockmaster.categoryid=stockcategory.categoryid\n\t\t\t\t\t\tINNER JOIN purchdata\n\t\t\t\t\t\tON stockmaster.stockid=purchdata.stockid\n\t\t\t\t\t\tWHERE (stockmaster.mbflag<>'D' OR stockcategory.stocktype='L')\n\t\t\t\t\t\tAND stockmaster.mbflag<>'A'\n\t\t\t\t\t\tAND stockmaster.mbflag<>'K'\n\t\t\t\t\t\tAND stockmaster.mbflag<>'G'\n\t\t\t\t\t\tAND purchdata.supplierno='" . $_SESSION['PO' . $identifier]->SupplierID . "'\n\t\t\t\t\t\tAND stockmaster.discontinued<>1\n\t\t\t\t\t\tAND stockmaster.categoryid='" . $_POST['StockCat'] . "'\n\t\t\t\t\t\tORDER BY stockmaster.stockid ";
} else {
$sql = "SELECT stockmaster.stockid,\n\t\t\t\t\t\t\tstockmaster.description,\n\t\t\t\t\t\t\tstockmaster.units\n\t\t\t\t\tFROM stockmaster INNER JOIN stockcategory\n\t\t\t\t\tON stockmaster.categoryid=stockcategory.categoryid\n\t\t\t\t\tWHERE (stockmaster.mbflag<>'D' OR stockcategory.stocktype='L')\n\t\t\t\t\tAND stockmaster.mbflag<>'A'\n\t\t\t\t\tAND stockmaster.mbflag<>'K'\n\t\t\t\t\tAND stockmaster.mbflag<>'G'\n\t\t\t\t\tAND stockmaster.discontinued<>1\n\t\t\t\t\tAND stockmaster.categoryid='" . $_POST['StockCat'] . "'\n\t\t\t\t\tORDER BY stockmaster.stockid ";
}
}
}
$SQLCount = substr($sql, strpos($sql, "FROM"));
$SQLCount = substr($SQLCount, 0, strpos($SQLCount, "ORDER"));
$SQLCount = 'SELECT COUNT(*) ' . $SQLCount;
$SearchResult = DB_query($SQLCount, $ErrMsg, $DbgMsg);
$myrow = DB_fetch_array($SearchResult);
DB_free_result($SearchResult);
unset($SearchResult);
$ListCount = $myrow[0];
$ListPageMax = ceil($ListCount / $_SESSION['DisplayRecordsMax']) - 1;
if ($ListPageMax < 0) {
$ListPageMax = 0;
}
if (isset($_POST['Next'])) {
$Offset = $_POST['currpage'] + 1;
}
if (isset($_POST['Prev'])) {
$Offset = $_POST['currpage'] - 1;
}
if (!isset($Offset)) {
$Offset = 0;
}