$FontSize = 10;
         $pdf->addText($Left_Margin + 75, $Bottom_Margin + 10 + 3 * $line_height + 4, $FontSize, _('Current') . ' ');
         $pdf->addText($Left_Margin + 158, $Bottom_Margin + 10 + 3 * $line_height + 4, $FontSize, _('Past Due') . ' ');
         $pdf->addText($Left_Margin + 242, $Bottom_Margin + 10 + 3 * $line_height + 4, $FontSize, $_SESSION['PastDueDays1'] . '-' . $_SESSION['PastDueDays2'] . ' ' . _('days'));
         $pdf->addText($Left_Margin + 315, $Bottom_Margin + 10 + 3 * $line_height + 4, $FontSize, _('Over') . ' ' . $_SESSION['PastDueDays2'] . ' ' . _('days'));
         $pdf->addText($Left_Margin + 442, $Bottom_Margin + 10 + 3 * $line_height + 4, $FontSize, _('Total Balance'));
         $LeftOvers = $pdf->addTextWrap($Left_Margin + 37, $Bottom_Margin + 2 * $line_height + 8, 70, $FontSize, $DisplayCurrent, 'right');
         $LeftOvers = $pdf->addTextWrap($Left_Margin + 130, $Bottom_Margin + 2 * $line_height + 8, 70, $FontSize, $DisplayDue, 'right');
         $LeftOvers = $pdf->addTextWrap($Left_Margin + 222, $Bottom_Margin + 2 * $line_height + 8, 70, $FontSize, $DisplayOverdue1, 'right');
         $LeftOvers = $pdf->addTextWrap($Left_Margin + 305, $Bottom_Margin + 2 * $line_height + 8, 70, $FontSize, $DisplayOverdue2, 'right');
         $LeftOvers = $pdf->addTextWrap($Left_Margin + 432, $Bottom_Margin + 2 * $line_height + 8, 70, $FontSize, $DisplayBalance, 'right');
         /*draw a line under the balance info */
         $YPos = $Bottom_Margin + 2 * $line_height;
         $pdf->line($Left_Margin, $YPos, $Perforation, $YPos);
         if (mb_strlen($StmtHeader['lastpaiddate']) > 1 and $StmtHeader['lastpaid'] != 0) {
             $pdf->addText($Left_Margin + 5, $Bottom_Margin + 13, $FontSize, _('Last payment received') . ' ' . ConvertSQLDate($StmtHeader['lastpaiddate']) . '	' . _('Amount received was') . ' ' . locale_money_format($StmtHeader['lastpaid'], $StmtHeader['currcode']));
         }
         /*also show the total due in the remittance section */
         if ($AgedAnalysis['balance'] > 0) {
             /*No point showing a negative balance for payment! */
             $FontSize = 8;
             $LeftOvers = $pdf->addTextWrap($Perforation + 2, $Bottom_Margin + 2 * $line_height + 8, 40, $FontSize, _('Payment'), 'left');
             $LeftOvers = $pdf->addTextWrap($Page_Width - $Right_Margin - 90, $Bottom_Margin + 2 * $line_height + 8, 88, $FontSize, $DisplayBalance, 'right');
         }
     }
     /* end of check to see that there were statement transactons to print */
 }
 /* end loop to print statements */
 if (isset($pdf)) {
     $pdf->OutputI($_SESSION['DatabaseName'] . '_CustStatements_' . date('Y-m-d') . '.pdf');
     //UldisN
                if ($Level > 0) {
                    printf('<tr>
				<td colspan="2"><font size="2"><i>%s ' . _('Total') . ' </i></font></td>
				<td class="number"><i>%s</i></td>
				<td class="number"><i>%s</i></td>
				<td class="number"><i>%s</i></td>
				<td class="number"><i>%s</i></td>
				</tr>', $ParentGroups[$Level], locale_money_format($GrpActual[$Level], $_SESSION['CompanyRecord']['currencydefault']), locale_money_format($GrpBudget[$Level], $_SESSION['CompanyRecord']['currencydefault']), locale_money_format($GrpPrdActual[$Level], $_SESSION['CompanyRecord']['currencydefault']), locale_money_format($GrpPrdBudget[$Level], $_SESSION['CompanyRecord']['currencydefault']));
                    $GrpActual[$Level] = 0;
                    $GrpBudget[$Level] = 0;
                    $GrpPrdActual[$Level] = 0;
                    $GrpPrdBudget[$Level] = 0;
                    $ParentGroups[$Level] = '';
                } else {
                    $Level = 1;
                }
            }
        }
        printf('<tr bgcolor="#ffffff">
			<td colspan="2"><font color="black"><b>' . _('Check Totals') . '</b></font></td>
			<td class="number">%s</td>
			<td class="number">%s</td>
			<td class="number">%s</td>
			<td class="number">%s</td>
		</tr>', locale_money_format($CheckMonth, $_SESSION['CompanyRecord']['currencydefault']), locale_money_format($CheckBudgetMonth, $_SESSION['CompanyRecord']['currencydefault']), locale_money_format($CheckPeriodActual, $_SESSION['CompanyRecord']['currencydefault']), locale_money_format($CheckPeriodBudget, $_SESSION['CompanyRecord']['currencydefault']));
        echo '</table><br />';
        echo '<div class="centre"><button type="submit" name="SelectADifferentPeriod">' . _('Select A Different Period') . '</button></div><br />';
    }
}
echo '</form>';
include 'includes/footer.inc';
/*Print out the category totals */
if ($_POST['DetailedReport'] == 'Yes') {
    $YPos -= $line_height;
    $LeftOvers = $pdf->addTextWrap($Left_Margin, $YPos, 260 - $Left_Margin, $FontSize, _('Total for') . ' ' . $Category . ' - ' . $CategoryName, 'left');
}
$DisplayCatTotVal = locale_money_format($CatTot_Val, $_SESSION['CompanyRecord']['currencydefault']);
$LeftOvers = $pdf->addTextWrap(500, $YPos, 60, $FontSize, $DisplayCatTotVal, 'right');
if ($_POST['DetailedReport'] == 'Yes') {
    /*draw a line under the CATEGORY TOTAL*/
    $pdf->line($Left_Margin, $YPos + $line_height - 2, $Page_Width - $Right_Margin, $YPos + $line_height - 2);
    $YPos -= 2 * $line_height;
}
$YPos -= 2 * $line_height;
/*Print out the grand totals */
$LeftOvers = $pdf->addTextWrap(80, $YPos, 260 - $Left_Margin, $FontSize, _('Grand Total Value'), 'right');
$DisplayTotalVal = locale_money_format($Tot_Val, $_SESSION['CompanyRecord']['currencydefault']);
$LeftOvers = $pdf->addTextWrap(500, $YPos, 60, $FontSize, $DisplayTotalVal, 'right');
if ($_POST['DetailedReport'] == 'Yes') {
    $pdf->line($Left_Margin, $YPos + $line_height - 2, $Page_Width - $Right_Margin, $YPos + $line_height - 2);
    $YPos -= 2 * $line_height;
}
if ($ListCount == 0) {
    $title = _('Print Inventory Valuation Error');
    include 'includes/header.inc';
    echo '<br />' . _('There were no items with any value to print out for the location specified');
    echo '<br /><a href="' . $rootpath . '/index.php">' . _('Back to the menu') . '</a>';
    include 'includes/footer.inc';
    exit;
    // Javier: needs check
} else {
    include 'includes/htmlMimeMail.php';
     }
     //end of the batch controlled stuff
 }
 //end if the woitem received here is a controlled item
 /* If GLLink_Stock then insert GLTrans to debit the GL Code  and credit GRN Suspense account at standard cost*/
 if ($_SESSION['CompanyRecord']['gllink_stock'] == 1 and $WORow['stdcost'] * $QuantityReceived != 0) {
     /*GL integration with stock is activated so need the GL journals to make it so */
     /*first the debit the finished stock of the item received from the WO
       the appropriate account was already retrieved into the $StockGLCode variable as the Processing code is kicked off
       it is retrieved from the stock category record of the item by a function in SQL_CommonFunctions.inc*/
     $SQL = "INSERT INTO gltrans (type,\n\t\t\t\t\t\t\t\t\ttypeno,\n\t\t\t\t\t\t\t\t\ttrandate,\n\t\t\t\t\t\t\t\t\tperiodno,\n\t\t\t\t\t\t\t\t\taccount,\n\t\t\t\t\t\t\t\t\tdefaulttag,\n\t\t\t\t\t\t\t\t\tnarrative,\n\t\t\t\t\t\t\t\t\tamount)\n\t\t\t\t\t\t\tVALUES (26,\n\t\t\t\t\t\t\t\t'" . $WOReceiptNo . "',\n\t\t\t\t\t\t\t\t'" . Date('Y-m-d') . "',\n\t\t\t\t\t\t\t\t'" . $PeriodNo . "',\n\t\t\t\t\t\t\t\t'" . $StockGLCode['stockact'] . "',\n\t\t\t\t\t\t\t\t'" . $_SESSION['DefaultTag'] . "',\n\t\t\t\t\t\t\t\t'" . $_POST['WO'] . " " . $_POST['StockID'] . " - " . $WORow['description'] . ' x ' . $QuantityReceived . " @ " . locale_money_format($WORow['stdcost'], $_SESSION['CompanyRecord']['currencydefault']) . "',\n\t\t\t\t\t\t\t\t'" . $WORow['stdcost'] * $QuantityReceived . "')";
     $ErrMsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('The receipt of work order finished stock GL posting could not be inserted because');
     $DbgMsg = _('The following SQL to insert the work order receipt of finished items GLTrans record was used');
     $Result = DB_query($SQL, $db, $ErrMsg, $DbgMsg, true);
     /*now the credit WIP entry*/
     $SQL = "INSERT INTO gltrans (type,\n\t\t\t\t\t\t\t\t\ttypeno,\n\t\t\t\t\t\t\t\t\ttrandate,\n\t\t\t\t\t\t\t\t\tperiodno,\n\t\t\t\t\t\t\t\t\taccount,\n\t\t\t\t\t\t\t\t\tdefaulttag,\n\t\t\t\t\t\t\t\t\tnarrative,\n\t\t\t\t\t\t\t\t\tamount)\n\t\t\t\t\t\t\tVALUES (26,\n\t\t\t\t\t\t\t\t'" . $WOReceiptNo . "',\n\t\t\t\t\t\t\t\t'" . Date('Y-m-d') . "',\n\t\t\t\t\t\t\t\t'" . $PeriodNo . "',\n\t\t\t\t\t\t\t\t'" . $StockGLCode['wipact'] . "',\n\t\t\t\t\t\t\t\t'" . $_SESSION['DefaultTag'] . "',\n\t\t\t\t\t\t\t\t'" . $_POST['WO'] . " " . $_POST['StockID'] . " - " . $WORow['description'] . ' x ' . $QuantityReceived . " @ " . locale_money_format($WORow['stdcost'], $_SESSION['CompanyRecord']['currencydefault']) . "',\n\t\t\t\t\t\t\t\t'" . -($WORow['stdcost'] * $QuantityReceived) . "')";
     $ErrMsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('The WIP credit on receipt of finished items from a work order GL posting could not be inserted because');
     $DbgMsg = _('The following SQL to insert the WIP GLTrans record was used');
     $Result = DB_query($SQL, $db, $ErrMsg, $DbgMsg, true);
 }
 /* end of if GL and stock integrated and standard cost !=0 */
 if (!isset($LastRef)) {
     $LastRef = '';
 }
 //update the wo with the new qtyrecd
 $ErrMsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('Could not update the work order item record with the total quantity received because');
 $DbgMsg = _('The following SQL was used to update the work order');
 $UpdateWOResult = DB_query("UPDATE woitems\n\t\t\t\t\t\t\t\t\tSET qtyrecd=qtyrecd+" . $QuantityReceived . ",\n\t\t\t\t\t\t\t\t\t\tnextlotsnref='" . $LastRef . "'\n\t\t\t\t\t\t\t\t\tWHERE wo='" . $_POST['WO'] . "'\n\t\t\t\t\t\t\t\t\tAND stockid='" . $_POST['StockID'] . "'", $db, $ErrMsg, $DbgMsg, true);
 $Result = DB_Txn_Commit($db);
 prnMsg(_('The receipt of') . ' ' . $QuantityReceived . ' ' . $WORow['units'] . ' ' . _('of') . ' ' . $_POST['StockID'] . ' - ' . $WORow['description'] . ' ' . _('against work order') . ' ' . $_POST['WO'] . ' ' . _('has been processed'), 'info');
 echo '<a href="' . $rootpath . '/SelectWorkOrder.php">' . _('Select a different work order for receiving finished stock against') . '</a>';
            if ($j < 0) {
                $j = 11;
                echo $tableheader;
            }
            if ($k == 1) {
                echo '<tr class="EvenTableRows">';
                $k = 0;
            } else {
                echo '<tr class="OddTableRows">';
                $k = 1;
            }
            printf('<td>%s</td>
			<td class="number">%s</td>
			<td class="number">%s</td>
			<td class="number">%s%%</td>
			</tr>', $ph[0], locale_number_format($ph[1], $DecimalPlaces), locale_money_format($ph[2], $_SESSION['CompanyRecord']['currencydefault']), locale_number_format($ph[3] * 100, 2));
        }
        echo '</table>';
    } else {
        echo '<p>' . _('No history of sales of') . ' ' . $StockID . ' ' . _('to') . ' ' . $DebtorNo . '</p>';
    }
}
//end of displaying price history for a debtor
echo '<div class="centre">';
echo '<br /><a href="' . $rootpath . '/StockMovements.php?StockID=' . $StockID . '">' . _('Show Movements') . '</a>';
echo '<br /><a href="' . $rootpath . '/StockUsage.php?StockID=' . $StockID . '">' . _('Show Usage') . '</a>';
echo '<br /><a href="' . $rootpath . '/SelectSalesOrder.php?SelectedStockItem=' . $StockID . '">' . _('Search Outstanding Sales Orders') . '</a>';
echo '<br /><a href="' . $rootpath . '/SelectCompletedOrder.php?SelectedStockItem=' . $StockID . '">' . _('Search Completed Sales Orders') . '</a>';
if ($Its_A_KitSet_Assembly_Or_Dummy == False) {
    echo '<br /><a href="' . $rootpath . '/PO_SelectOSPurchOrder.php?SelectedStockItem=' . $StockID . '">' . _('Search Outstanding Purchase Orders') . '</a>';
}
}
/*Set up a form to allow input of new Shipment charges */
echo '<br /><form action="' . htmlspecialchars($_SERVER['PHP_SELF'], ENT_QUOTES, 'UTF-8') . '" method="post">';
echo '<input type="hidden" name="FormID" value="' . $_SESSION['FormID'] . '" />';
if (!isset($_POST['AssetID'])) {
    $_POST['AssetID'] = '';
}
prnMsg(_('If you know the code enter it in the Asset ID input box, otherwise select the asset from the list below. Only  assets with no cost will show in the list'), 'info');
echo '<br /><table class="selection">';
echo '<tr><td>' . _('Enter Asset ID') . ':</td>
	<td><input type="text" name="AssetID" size="5" maxlength="6" value="' . $_POST['AssetID'] . '" /> <a href="FixedAssetItems.php" target=_blank>' . _('New Fixed Asset') . '</a></td></tr>';
echo '<tr><td><b>' . _('OR') . ' </b>' . _('Select from list') . ':</td><td><select name="AssetSelection">';
$sql = "SELECT assetid,\n\t\t\t\tdescription\n\t\t\tFROM fixedassets\n\t\t\tWHERE cost=0\n\t\t\tORDER BY assetid DESC";
$result = DB_query($sql, $db);
while ($myrow = DB_fetch_array($result)) {
    if (isset($_POST['AssetSelection']) and $myrow['AssetID'] == $_POST['AssetSelection']) {
        echo '<option selected="True" value="' . $myrow['assetid'] . '">' . $myrow['assetid'] . ' - ' . $myrow['description'] . '</option>';
    } else {
        echo '<option value="' . $myrow['assetid'] . '">' . $myrow['assetid'] . ' - ' . $myrow['description'] . '</option>';
    }
}
echo '</select></td></tr>';
if (!isset($_POST['Amount'])) {
    $_POST['Amount'] = 0;
}
echo '<tr><td>' . _('Amount') . ':</td>
	<td><input type="text" class="number" name="Amount" size="12" maxlength="11" value="' . locale_money_format($_POST['Amount'], $_SESSION['SuppTrans']->CurrCode) . '" /></td></tr>';
echo '</table>';
echo '<br /><div class="centre"><button type="submit" name="AddAssetToInvoice">' . _('Enter Fixed Asset') . '</button></div>';
echo '</form>';
include 'includes/footer.inc';
Example #7
0
             echo '<tr class="EvenTableRows">';
             $k = 0;
         } else {
             echo '<tr class="OddTableRows">';
             $k = 1;
         }
         if ($LineItems->ExpiryDate < date('Y-m-d')) {
             echo '<tr bgcolor="#F7A9A9">';
         }
         echo '<input type="hidden" name="StockID' . $LineItems->LineNo . '" value="' . $LineItems->StockID . '" />';
         echo '<td>' . $LineItems->StockID . '</td>';
         echo '<td>' . $LineItems->ItemDescription . '</td>';
         echo '<td><input type="text" class="number" name="Qty' . $LineItems->LineNo . '" value="' . locale_number_format($LineItems->Quantity, $LineItems->DecimalPlaces) . '" /></td>';
         echo '<td>' . $LineItems->Units . '</td>';
         echo '<td><input type="text" class="number" name="Price' . $LineItems->LineNo . '" value="' . locale_money_format($LineItems->Price, $Currency) . '" /></td>';
         echo '<td class="number">' . locale_money_format($LineItems->Price * $LineItems->Quantity, $Currency) . '</td>';
         echo '<td><input type="text" size="11" class="date" alt="' . $_SESSION['DefaultDateFormat'] . '" name="expirydate' . $LineItems->LineNo . '" value="' . $LineItems->ExpiryDate . '" /></td>';
         echo '<td><a href="' . htmlspecialchars($_SERVER['PHP_SELF']) . '?identifier=' . $identifier . '&Delete=' . $LineItems->LineNo . '&Type=' . $_POST['TenderType'] . '">' . _('Remove') . '</a></td></tr>';
         echo '</tr>';
     }
 }
 echo '</table>';
 echo '<input type="hidden" name="TenderType" value="' . $_POST['TenderType'] . '" />';
 if ($_POST['TenderType'] == 1) {
     echo '<br /><div class="centre"><button type="submit" name="Update">' . _('Update offer') . '</button>';
     echo '<button type="submit" name="Refresh">' . _('Refresh screen') . '</button></div>';
 } else {
     if ($_POST['TenderType'] == 2) {
         echo '<br /><div class="centre"><button type="submit" name="Save">' . _('Save offer') . '</button>';
         echo '<button type="submit" name="Refresh">' . _('Refresh screen') . '</button></div>';
     }
				<td>' . $SalesRow['stockid'] . ' - ' . $SalesRow['description'] . '</td>
				<td>' . $SalesRow['categorydescription'] . '</td>
				<td class="number">' . locale_money_format($SalesRow['salesvalue'], $_SESSION['CompanyRecord']['currencydefault']) . '</td>
				<td class="number">' . locale_money_format($SalesRow['returnvalue'], $_SESSION['CompanyRecord']['currencydefault']) . '</td>
				<td class="number">' . locale_money_format($SalesRow['netsalesvalue'], $_SESSION['CompanyRecord']['currencydefault']) . '</td>
				<td class="number">' . locale_number_format($SalesRow['salesquantity'], 2) . '</td>
				</tr>';
        $i++;
        $CumulativeTotalSales += $SalesRow['salesvalue'];
        $CumulativeTotalRefunds += $SalesRow['returnvalue'];
        $CumulativeTotalNetSales += $SalesRow['salesvalue'] + $SalesRow['returnvalue'];
        $CumulativeTotalQuantity += $SalesRow['salesquantity'];
    }
    //loop around category sales for the period
    if ($k == 1) {
        echo '<tr class="EvenTableRows"><td colspan="8"><hr /></td></tr>';
        echo '<tr class="OddTableRows">';
    } else {
        echo '<tr class="OddTableRows"><td colspan="8"><hr /></td></tr>';
        echo '<tr class="EvenTableRows">';
    }
    echo '<td class="number" colspan="3">' . _('GRAND Total') . '</td>
		<td class="number">' . locale_money_format($CumulativeTotalSales, $_SESSION['CompanyRecord']['currencydefault']) . '</td>
		<td class="number">' . locale_money_format($CumulativeTotalRefunds, $_SESSION['CompanyRecord']['currencydefault']) . '</td>
		<td class="number">' . locale_money_format($CumulativeTotalNetSales, $_SESSION['CompanyRecord']['currencydefault']) . '</td>
		<td class="number">' . locale_number_format($CumulativeTotalQuantity, 2) . '</td>
		</tr>';
    echo '</table>';
}
//end of if user hit show sales
include 'includes/footer.inc';
Example #9
0
    if (!isset($_POST['SuppliersUOM'])) {
        $_POST['SuppliersUOM'] = '';
    }
    if (!isset($_POST['SupplierDescription'])) {
        $_POST['SupplierDescription'] = '';
    }
    if (!isset($_POST['SupplierCode'])) {
        $_POST['SupplierCode'] = '';
    }
    if (!isset($_POST['MinOrderQty'])) {
        $_POST['MinOrderQty'] = '1';
    }
    echo '<tr><td>' . _('Currency') . ':</td>
	<td><input type="hidden" name="CurrCode" . value="' . $CurrCode . '" />' . $CurrCode . '</td></tr>';
    echo '<tr><td>' . _('Price') . ' (' . _('in Supplier Currency') . '):</td>
	<td><input type="text" class="number" name="Price" maxlength="12" size="12" value="' . locale_money_format($_POST['Price'], $CurrCode) . '" /></td></tr>';
    echo '<tr><td>' . _('Date Updated') . ':</td>
	<td><input type="text" class="date" alt="' . $_SESSION['DefaultDateFormat'] . '" name="EffectiveFrom" maxlength="10" size="11" value="' . $_POST['EffectiveFrom'] . '" /></td></tr>';
    echo '<tr><td>' . _('Our Unit of Measure') . ':</td>';
    if (isset($SupplierID)) {
        echo '<td>' . $StockUOM . '</td></tr>';
    }
    echo '<tr><td>' . _('Suppliers Unit of Measure') . ':</td>';
    echo '<td><select name="SuppliersUOM">';
    $sql = "SELECT unitid,\n\t\t\t\t\tunitname\n\t\t\t\tFROM unitsofmeasure";
    $result = DB_query($sql, $db);
    while ($myrow = DB_fetch_array($result)) {
        if ($_POST['SuppliersUOM'] == $myrow['unitid']) {
            echo '<option selected="True" value="' . $myrow['unitid'] . '">' . $myrow['unitname'] . '</option>';
        } else {
            echo '<option value="' . $myrow['unitid'] . '">' . $myrow['unitname'] . '</option>';
        }
        /*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);
//UldisN
$pdf->__destruct();
//UldisN
if ($_POST['Email'] == 'Yes') {
    if (file_exists($_SESSION['reports_dir'] . '/' . $ReportFileName)) {
        unlink($_SESSION['reports_dir'] . '/' . $ReportFileName);
    }
    $fp = fopen($_SESSION['reports_dir'] . '/' . $ReportFileName, 'wb');
    fwrite($fp, $pdfcode);
    fclose($fp);
    include 'includes/htmlMimeMail.php';
    $mail = new htmlMimeMail();
Example #11
0
while ($myrow = DB_fetch_array($MovtsResult)) {
    if ($k == 1) {
        echo '<tr class="OddTableRows">';
        $k = 0;
    } else {
        echo '<tr class="EvenTableRows">';
        $k = 1;
    }
    $DisplayTranDate = ConvertSQLDate($myrow['trandate']);
    printf('<td><a target="_blank" href="StockStatus.php?StockID=%s">%s</td>
			<td>%s</td>
			<td>%s</td>
			<td>%s</td>
			<td>%s</td>
			<td class="number">%s</td>
			<td>%s</td>
			<td class="number">%s</td>
			<td class="number">%s</td>
			<td class="number">%s</td>
			</tr>', mb_strtoupper($myrow['stockid']), mb_strtoupper($myrow['stockid']), $myrow['typename'], $myrow['transno'], $DisplayTranDate, $myrow['debtorno'], locale_number_format($myrow['qty'], $myrow['decimalplaces']), $myrow['reference'], locale_money_format($myrow['price'], $_SESSION['CompanyRecord']['currencydefault']), locale_number_format($myrow['discountpercent'] * 100, 2), locale_number_format($myrow['newqoh'], $myrow['decimalplaces']));
    $j++;
    if ($j == 16) {
        $j = 1;
        echo $tableheader;
    }
    //end of page full new headings if
}
//end of while loop
echo '</table>';
echo '</form>';
include 'includes/footer.inc';
        echo '<tr class="EvenTableRows">';
        $k = 0;
    } else {
        echo '<tr class="OddTableRows">';
        $k = 1;
    }
    echo '<td>' . $myrow['suppname'] . '</td>
		<td>' . $myrow['typename'] . '</td>
		<td>' . $myrow['suppreference'] . '</td>
		<td>' . ConvertSQLDate($myrow['trandate']) . '</td>
		<td class=number>' . locale_money_format($myrow['value'], $myrow['currcode']) . '</td></tr>';
    $TotalGeneralShipmentChgs += $myrow['value'];
}
echo '<tr>
	<td class="number" colspan="4"><font color="blue"><b>' . _('Total General Shipment Charges') . ':</b></font></td>
	<td class="number">' . locale_money_format($TotalGeneralShipmentChgs, $ShipmentCurrency) . '</td></tr>';
echo '</table>';
echo '</td></tr></table>';
//major table close
if (isset($_GET['Close'])) {
    /* Only an opportunity to confirm user wishes to close */
    // if the page was called with Close=Yes then show options to confirm OK to c
    echo '<div class="centre">
			<form method="post" action="' . htmlspecialchars($_SERVER['PHP_SELF'], ENT_QUOTES, 'UTF-8') . '?SelectedShipment=' . $_GET['SelectedShipment'] . '">';
    echo '<input type="hidden" name="FormID" value="' . $_SESSION['FormID'] . '" />';
    if ($_SESSION['WeightedAverageCosting'] == 0) {
        /* We are standard costing - so show the option to update costs - under W. Avg cost updates are implicit */
        echo _('Update Standard Costs') . ':<select name="UpdateCost">
				<option selected value="Yes">' . _('Yes') . '</option>
				<option value="No">' . _('No') . '</option>
			</select>';
<?php

/* $Id$*/
include 'includes/session.inc';
$title = _('Currency Debtor Balances');
include 'includes/header.inc';
echo '<font size="4"><b>' . _('Debtors Balances By Currency Totals') . '</b></font>';
$sql = "SELECT SUM(ovamount+ovgst+ovdiscount+ovfreight-alloc) AS currencybalance,\n\t\tcurrcode,\n\t\tSUM((ovamount+ovgst+ovdiscount+ovfreight-alloc)/rate) AS localbalance\n\tFROM debtortrans INNER JOIN debtorsmaster\n\t\tON debtortrans.debtorno=debtorsmaster.debtorno\n\tWHERE (ovamount+ovgst+ovdiscount+ovfreight-alloc)<>0 GROUP BY currcode";
$result = DB_query($sql, $db);
$LocalTotal = 0;
echo '<table>';
while ($myrow = DB_fetch_array($result)) {
    echo '<tr><td><font size="4">' . _('Total Debtor Balances in') . ' </font></td>
		<td><font size="4">' . $myrow['currcode'] . '</font></td>
		<td class="number"><font size="4">' . locale_money_format($myrow['currencybalance'], $myrow['currcode']) . '</font></td>
		<td><font size="4"> in ' . $_SESSION['CompanyRecord']['currencydefault'] . '</font></td>
		<td class="number"><font size="4">' . locale_money_format($myrow['localbalance'], $_SESSION['CompanyRecord']['currencydefault']) . '</font></td></tr>';
    $LocalTotal += $myrow['localbalance'];
}
echo '<tr><td colspan="4"><font size="4">' . _('Total Balances in local currency') . ':</font></td>
	<td class="number"><font size="4">' . locale_money_format($LocalTotal, $_SESSION['CompanyRecord']['currencydefault']) . '</font></td></tr>';
echo '</table>';
include 'includes/footer.inc';
Example #14
0
			<input type="hidden" value="' . locale_number_format($_POST['NumberOfTopItems'], 0) . '" name="NumberOfTopItems" />';
    $k = 0;
    //row colour counter
    $i = 1;
    while ($myrow = DB_fetch_array($result)) {
        //find the quantity onhand item
        $sqloh = "SELECT sum(quantity) AS qty\n\t\t\t\t\tFROM locstock\n\t\t\t\t\tWHERE stockid='" . $myrow['stkcode'] . "'";
        $oh = DB_query($sqloh, $db);
        $ohRow = DB_fetch_array($oh);
        if ($k == 1) {
            echo '<tr class="EvenTableRows">';
            $k = 0;
        } else {
            echo '<tr class="OddTableRows">';
            $k = 1;
        }
        printf('<td class="number">%s</td>
				<td>%s</td>
				<td>%s</td>
				<td class="number">%s</td>
				<td>%s</td>
				<td class="number">%s</td>
				<td class="number">%s</td>
				</tr>', $i, $myrow['stkcode'], $myrow['description'], locale_number_format($myrow['totalinvoiced'], $myrow['decimalplaces']), $myrow['units'], locale_money_format($myrow['valuesales'], $_SESSION['CompanyRecord']['currencydefault']), locale_number_format($ohRow['qty'], $myrow['decimalplaces']));
        $i++;
    }
    echo '</table>';
    echo '<br /><div class="centre"><button type="submit" name="PrintPDF">' . _('Print To PDF') . '</button></div>';
    echo '</form>';
}
include 'includes/footer.inc';
						<th>' . _('Amount in') . ' ' . $_SESSION['CompanyRecord']['currencydefault'] . '</th>
						<th>' . _('Running Total') . ' ' . $_SESSION['CompanyRecord']['currencydefault'] . '</th>
					</tr>';
        $AccountCurrTotal = 0;
        $LocalCurrTotal = 0;
        while ($myrow = DB_fetch_array($result)) {
            $AccountCurrTotal += $myrow['amount'];
            $LocalCurrTotal += $myrow['amount'] / $myrow['functionalexrate'] / $myrow['exrate'];
            echo '<tr>
							<td>' . ConvertSQLDate($myrow['transdate']) . '</td>
							<td>' . $myrow['userid'] . '</td>
							<td>' . $myrow['typename'] . '</td>
							<td>' . $myrow['banktranstype'] . '</td>
							<td>' . $myrow['chequeno'] . '</td>
							<td>' . $myrow['ref'] . '</td>
							<td class="number">' . locale_money_format($myrow['amount'], $myrow['currcode']) . '</td>
							<td class="number">' . locale_money_format($AccountCurrTotal, $myrow['currcode']) . '</td>
							<td class="number">' . locale_money_format($myrow['amount'] / $myrow['functionalexrate'] / $myrow['exrate'], $_SESSION['CompanyRecord']['currencydefault']) . '</td>
							<td class="number">' . locale_money_format($LocalCurrTotal, $_SESSION['CompanyRecord']['currencydefault']) . '</td>
						</tr>';
        }
        echo '<tr><th colspan=10>' . _('Total number of receipts') . ' - ' . DB_num_rows($result) . '</th></tr>';
        echo '</table>';
    }
    //end if no bank trans in the range to show
    echo '<form action="' . htmlspecialchars($_SERVER['PHP_SELF'], ENT_QUOTES, 'UTF-8') . '" method="post">';
    echo '<input type="hidden" name="FormID" value="' . $_SESSION['FormID'] . '" />';
    echo '<br /><div class="centre"><button type="submit" name="Return">' . _('Select Another Date') . '</button></div><br />';
    echo '</form>';
}
include 'includes/footer.inc';
    echo '<tr><th>' . _('Asset ID') . '</th>
				<th>' . _('Description') . '</th>
				<th>' . _('Serial number') . '</th>
				<th>' . _('Purchase Cost') . '</th>
				<th>' . _('Total Depreciation') . '</th>
				<th>' . _('Current Location') . '</th>
				<th>' . _('Move To :') . '</th>
			</tr>';
    $locationsql = "SELECT locationid, locationdescription from fixedassetlocations";
    $LocationResult = DB_query($locationsql, $db);
    while ($myrow = DB_fetch_array($Result)) {
        echo '<tr><td>' . $myrow['assetid'] . '</td>
					<td>' . $myrow['description'] . '</td>
					<td>' . $myrow['serialno'] . '</td>
					<td class="number">' . locale_money_format($myrow['cost'], $_SESSION['CompanyRecord']['currencydefault']) . '</td>
					<td class="number">' . locale_money_format($myrow['accumdepn'], $_SESSION['CompanyRecord']['currencydefault']) . '</td>
					<td>' . $myrow['locationdescription'] . '</td>';
        echo '<td><select name="Location' . $myrow['assetid'] . '" onChange="ReloadForm(Move' . $myrow['assetid'] . ')">';
        echo '<option value=""></option>';
        while ($LocationRow = DB_fetch_array($LocationResult)) {
            if ($LocationRow['locationid'] == $myrow['location']) {
                echo '<option selected="True" value="' . $LocationRow['locationid'] . '">' . $LocationRow['locationdescription'] . '</option>';
            } else {
                echo '<option value="' . $LocationRow['locationid'] . '">' . $LocationRow['locationdescription'] . '</option>';
            }
        }
        DB_data_seek($LocationResult, 0);
        echo '</select></td>';
        echo '<input type="hidden" name="AssetCat" value="' . $_POST['AssetCat'] . '" />';
        echo '<input type="hidden" name="Keywords" value="' . $_POST['Keywords'] . '" />';
        echo '<input type="hidden" name="AssetID" value="' . $_POST['AssetID'] . '" />';
Example #17
0
                echo '<option selected="True" value="' . $myrow['currabrev'] . '">' . $myrow['currency'] . '</option>';
            } else {
                echo '<option value=' . $myrow['currabrev'] . '">' . $myrow['currency'] . '</option>';
            }
        }
    }
    //end while loop get type of tab
    echo '</select></td></tr>';
    if (!isset($_POST['tablimit'])) {
        $_POST['tablimit'] = 0;
    }
    if (!isset($_POST['SelectCurrency'])) {
        $_POST['SelectCurrency'] = $_SESSION['CompanyRecord']['currencydefault'];
    }
    echo '<tr>
			<td>' . _('Limit Of Tab') . ':</td><td><input type="text" class="number" name="tablimit" size="12" maxlength="11" value="' . locale_money_format($_POST['tablimit'], $_POST['SelectCurrency']) . '" /></td>
		</tr>';
    echo '<tr>
			<td>' . _('Cash Assigner') . ':</td><td><select name="SelectAssigner">';
    DB_data_seek($UsersResult);
    echo '<option value=""></option>';
    while ($myrow = DB_fetch_array($UsersResult)) {
        if (isset($_POST['SelectAssigner']) and $myrow['userid'] == $_POST['SelectAssigner']) {
            echo '<option selected="True" value="' . $myrow['userid'] . '">' . $myrow['userid'] . ' - ' . $myrow['realname'] . '</option>';
        } else {
            echo '<option value="' . $myrow['userid'] . '">' . $myrow['userid'] . ' - ' . $myrow['realname'] . '</option>';
        }
    }
    //end while loop get authorizer
    echo '</select></td></tr>';
    echo '<tr>
Example #18
0
            $SQL = "SELECT \tsalesorderdetails.stkcode,\n\t\t\t\t\t\tSUM(salesorderdetails.qtyinvoiced) totalinvoiced,\n\t\t\t\t\t\tSUM(salesorderdetails.qtyinvoiced * salesorderdetails.unitprice ) AS valuesales,\n\t\t\t\t\t\tstockmaster.description,\n\t\t\t\t\t\tstockmaster.decimalplaces,\n\t\t\t\t\t\tdebtorsmaster.currcode,\n\t\t\t\t\t\tstockmaster.units\n\t\t\t\t\tFROM \tsalesorderdetails, salesorders, debtorsmaster,stockmaster\n\t\t\t\t\tWHERE \tsalesorderdetails.orderno = salesorders.orderno\n\t\t\t\t\t\tAND salesorderdetails.stkcode = stockmaster.stockid\n\t\t\t\t\t\tAND salesorders.debtorno = debtorsmaster.debtorno\n\t\t\t\t\t\tAND salesorders.fromstkloc = '" . $_GET['Location'] . "'\n\t\t\t\t\t\tAND debtorsmaster.typeid = '" . $_GET['Customers'] . "'\n\t\t\t\t\t\tAND salesorderdetails.actualdispatchdate >= '" . $FromDate . "'\n\t\t\t\t\tGROUP BY salesorderdetails.stkcode\n\t\t\t\t\tORDER BY '" . $_GET['Sequence'] . "' DESC\n\t\t\t\t\tLIMIT " . $_GET['NumberOfTopItems'];
        }
    }
}
$result = DB_query($SQL, $db);
$YPos = $YPos - 6;
while ($myrow = DB_fetch_array($result)) {
    //find the quantity onhand item
    $sqloh = "SELECT   sum(quantity)as qty\n\t\t\t\t\t\tFROM     `locstock`\n\t\t\t\t\t\tWHERE     stockid='" . $myrow['0'] . "'";
    $oh = DB_query($sqloh, $db);
    $ohRow = DB_fetch_row($oh);
    $LeftOvers = $pdf->addTextWrap($Left_Margin + 1, $YPos, 300 - $Left_Margin, $FontSize, $myrow['stkcode']);
    $LeftOvers = $pdf->addTextWrap($Left_Margin + 100, $YPos, 270 - $Left_Margin, $FontSize, $myrow['description']);
    $LeftOvers = $pdf->addTextWrap($Left_Margin + 330, $YPos, 30, $FontSize, locale_number_format($myrow['totalinvoiced'], $myrow['decimalplaces']), 'right');
    $LeftOvers = $pdf->addTextWrap($Left_Margin + 370, $YPos, 300 - $Left_Margin, $FontSize, $myrow['units'], 'left');
    $LeftOvers = $pdf->addTextWrap($Left_Margin + 400, $YPos, 70, $FontSize, locale_money_format($myrow['valuesales'], $myrow['currcode']), 'right');
    $LeftOvers = $pdf->addTextWrap($Left_Margin + 490, $YPos, 30, $FontSize, locale_number_format($ohRow[0], $myrow['decimalplaces']), 'right');
    if (mb_strlen($LeftOvers) > 1) {
        $LeftOvers = $pdf->addTextWrap($Left_Margin + 1 + 94, $YPos - $line_height, 270, $FontSize, $LeftOvers, 'left');
        $YPos -= $line_height;
    }
    if ($YPos - $line_height <= $Bottom_Margin) {
        /* We reached the end of the page so finish off the page and start a newy */
        $PageNumber++;
        include 'includes/PDFTopItemsHeader.inc';
        $FontSize = 10;
    }
    //end if need a new page headed up
    /*increment a line down for the next line item */
    $YPos -= $line_height;
}
                } else {
                    $myrow['units'] = $PriceRow['customerunits'];
                }
                if ($PriceRow['currabrev'] != $_SESSION['Items' . $identifier]->DefaultCurrency) {
                    $PriceRow['price'] = 0;
                }
                echo '<td>' . $myrow['stockid'] . '</font></td>
						<td>' . $myrow['description'] . '</td>
						<td>' . $myrow['units'] . '</td>
						<td class="number">' . locale_number_format($QOH, $DecimalPlaces) . '</td>
						<td class="number">' . locale_number_format($DemandQty, $DecimalPlaces) . '</td>
						<td class="number">' . locale_number_format($OnOrder, $DecimalPlaces) . '</td>
						<td class="number">' . locale_number_format($Available, $DecimalPlaces) . '</td>
						<td><font size="1"><input class="number"  tabindex="' . ($j + 7) . '" type="text" size="6" name="Quantity' . $i . '" value="0" />
						<input type="hidden" name="StockID' . $i . '" value="' . $myrow['stockid'] . '" />
						<td class="number">' . locale_money_format($PriceRow['price'], $_SESSION['Items' . $identifier]->DefaultCurrency) . '</td>
						</td>
						</tr>';
                echo '<input type="hidden" name="ConversionFactor' . $i . '" value="' . $PriceRow['conversionfactor'] . '" />';
                echo '<input type="hidden" name="Units' . $i . '" value="' . $myrow['units'] . '" />';
                if ($j == 1) {
                    $jsCall = '<script  type="text/javascript">if (document.SelectParts) {defaultControl(document.SelectParts.itm' . $myrow['stockid'] . ');}</script>';
                }
                $i++;
                #end of page full new headings if
            }
            #end of while loop
            echo '<tr><td><input type="hidden" name="previous" value="' . ($Offset - 1) . '" />
					<button tabindex="' . ($j + 7) . '" type="submit" name="Prev">' . _('Prev') . '</button></td>';
            echo '<td style="text-align:center" colspan="7"><input type="hidden" name="order_items" value="1" />
				<button tabindex="' . ($j + 8) . '" type="submit">' . _('Add to Sales Order') . '</button></td>';
Example #20
0
function submitcsv(&$db, $PartNumber, $PartNumberOp, $SupplierId, $SupplierIdOp, $SupplierName, $SupplierNameOp, $SaveSummaryType)
{
    //initialize no input errors
    $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 (!Is_Date($_POST['FromDate'])) {
        $InputError = 1;
        prnMsg(_('Invalid From Date'), 'error');
    }
    if (!Is_Date($_POST['ToDate'])) {
        $InputError = 1;
        prnMsg(_('Invalid To Date'), 'error');
    }
    # Add more to WHERE statement, if user entered something for the part number,supplierid, name
    $WherePart = ' ';
    if (strlen($PartNumber) > 0 and $PartNumberOp == 'LIKE') {
        $PartNumber = $PartNumber . '%';
    } else {
        $PartNumberOp = '=';
    }
    if (strlen($PartNumber) > 0) {
        $WherePart = " AND purchorderdetails.itemcode " . $PartNumberOp . " '" . $PartNumber . "'  ";
    } else {
        $WherePart = ' ';
    }
    $WhereSupplierID = ' ';
    if ($SupplierIdOp == 'LIKE') {
        $SupplierId = $SupplierId . '%';
    } else {
        $SupplierIdOp = '=';
    }
    if (strlen($SupplierId) > 0) {
        $WhereSupplierID = " AND purchorders.supplierno " . $SupplierIdOp . " '" . $SupplierId . "'  ";
    } else {
        $WhereSupplierID = ' ';
    }
    $WhereSupplierName = ' ';
    if (strlen($SupplierName) > 0 and $SupplierNameOp == 'LIKE') {
        $SupplierName = $SupplierName . '%';
    } else {
        $SupplierNameOp = '=';
    }
    if (strlen($SupplierName) > 0) {
        $WhereSupplierName = " AND suppliers.suppname " . $SupplierNameOp . " '" . $SupplierName . "'  ";
    } else {
        $WhereSupplierName = ' ';
    }
    if (strlen($_POST['OrderNo']) > 0) {
        $WhereOrderNo = ' AND purchorderdetails.orderno = ' . " '" . $_POST['OrderNo'] . "'  ";
    } else {
        $WhereOrderNo = ' ';
    }
    $WhereLineStatus = ' ';
    // Had to use IF statement instead of comparing 'linestatus' to $_POST['LineStatus']
    //in WHERE clause because the WHERE clause didn't recognize
    // that had used the IF statement to create a field called linestatus
    if ($_POST['LineStatus'] != 'All') {
        if ($_POST['DateType'] == 'Order') {
            $WhereLineStatus = " AND IF(purchorderdetails.quantityord = purchorderdetails.qtyinvoiced or\n\t\t\t  purchorderdetails.completed = 1,'Completed','Open') = '" . $_POST['LineStatus'] . "'";
        } else {
            $WhereLineStatus = " AND IF(grns.qtyrecd - grns.quantityinv <> 0,'Open','Completed') = '" . $_POST['LineStatus'] . "'";
        }
    }
    $WhereCategory = ' ';
    if ($_POST['Category'] != 'All') {
        $WhereCategory = " AND stockmaster.categoryid = '" . $_POST['Category'] . "'";
    }
    if ($InputError != 1) {
        $FromDate = FormatDateForSQL($_POST['FromDate']);
        $ToDate = FormatDateForSQL($_POST['ToDate']);
        if ($_POST['ReportType'] == 'Detail') {
            if ($_POST['DateType'] == 'Order') {
                $sql = "SELECT purchorderdetails.orderno,\n\t\t\t\t\t\t\t   purchorderdetails.itemcode,\n\t\t\t\t\t\t\t   purchorderdetails.deliverydate,\n\t\t\t\t\t\t\t   purchorders.supplierno,\n\t\t\t\t\t\t\t   purchorders.orddate,\n\t\t\t\t\t\t\t   purchorderdetails.quantityord,\n\t\t\t\t\t\t\t   purchorderdetails.qtyinvoiced,\n\t\t\t\t\t\t\t   (purchorderdetails.quantityord * purchorderdetails.unitprice) as extprice,\n\t\t\t\t\t\t\t   (purchorderdetails.quantityord * purchorderdetails.stdcostunit) as extcost,\n\t\t\t\t\t\t\t   IF(purchorderdetails.quantityord = purchorderdetails.qtyinvoiced or\n\t\t\t\t\t\t\t\t  purchorderdetails.completed = 1,'Completed','Open') as linestatus,\n\t\t\t\t\t\t\t   suppliers.suppname,\n\t\t\t\t\t\t\t   suppliers.currcode,\n\t\t\t\t\t\t\t   stockmaster.decimalplaces,\n\t\t\t\t\t\t\t   stockmaster.description\n\t\t\t\t\t\t\t   FROM purchorderdetails\n\t\t\t\t\t\tLEFT JOIN purchorders ON purchorders.orderno=purchorderdetails.orderno\n\t\t\t\t\t\tLEFT JOIN suppliers ON purchorders.supplierno = suppliers.supplierid\n\t\t\t\t\t\tLEFT JOIN stockmaster ON purchorderdetails.itemcode = stockmaster.stockid\n\t\t\t\t\t\tWHERE purchorders.orddate >='{$FromDate}'\n\t\t\t\t\t\t AND purchorders.orddate <='{$ToDate}'\n\t\t\t\t\t\t{$WherePart}\n\t\t\t\t\t\t{$WhereSupplierID}\n\t\t\t\t\t\t{$WhereSupplierName}\n\t\t\t\t\t\t{$WhereOrderNo}\n\t\t\t\t\t\t{$WhereLineStatus}\n\t\t\t\t\t\t{$WhereCategory}\n\t\t\t\t\t\tORDER BY " . $_POST['SortBy'];
            } else {
                // Selects by delivery date from grns
                $sql = "SELECT purchorderdetails.orderno,\n\t\t\t\t\t\t\t   purchorderdetails.itemcode,\n\t\t\t\t\t\t\t   grns.deliverydate,\n\t\t\t\t\t\t\t   purchorders.supplierno,\n\t\t\t\t\t\t\t   purchorders.orddate,\n\t\t\t\t\t\t\t   grns.qtyrecd as quantityord,\n\t\t\t\t\t\t\t   grns.quantityinv as qtyinvoiced,\n\t\t\t\t\t\t\t   (grns.qtyrecd * purchorderdetails.unitprice) as extprice,\n\t\t\t\t\t\t\t   (grns.qtyrecd * grns.stdcostunit) as extcost,\n\t\t\t\t\t\t\t   IF(grns.qtyrecd - grns.quantityinv <> 0,'Open','Completed') as linestatus,\n\t\t\t\t\t\t\t   suppliers.suppname,\n\t\t\t\t\t\t\t   suppliers.currcode,\n\t\t\t\t\t\t\t   stockmaster.decimalplaces,\n\t\t\t\t\t\t\t   stockmaster.description\n\t\t\t\t\t\t\t   FROM grns\n\t\t\t\t\t\tLEFT JOIN purchorderdetails ON grns.podetailitem = purchorderdetails.podetailitem\n\t\t\t\t\t\tLEFT JOIN purchorders ON purchorders.orderno=purchorderdetails.orderno\n\t\t\t\t\t\tLEFT JOIN suppliers ON purchorders.supplierno = suppliers.supplierid\n\t\t\t\t\t\tLEFT JOIN stockmaster ON purchorderdetails.itemcode = stockmaster.stockid\n\t\t\t\t\t\tWHERE grns.deliverydate >='{$FromDate}'\n\t\t\t\t\t\t AND grns.deliverydate <='{$ToDate}'\n\t\t\t\t\t\t{$WherePart}\n\t\t\t\t\t\t{$WhereSupplierID}\n\t\t\t\t\t\t{$WhereSupplierName}\n\t\t\t\t\t\t{$WhereOrderNo}\n\t\t\t\t\t\t{$WhereLineStatus}\n\t\t\t\t\t\t{$WhereCategory}\n\t\t\t\t\t\tORDER BY " . $_POST['SortBy'];
            }
        } else {
            // sql for Summary report
            $orderby = $_POST['SummaryType'];
            // The following is because the 'extprice' summary is a special case - with the other
            // summaries, you group and order on the same field; with 'extprice', you are actually
            // grouping on the stkcode and ordering by extprice descending
            if ($_POST['SummaryType'] == 'extprice') {
                $_POST['SummaryType'] = 'itemcode';
                $orderby = 'extprice DESC';
            }
            if ($_POST['DateType'] == 'Order') {
                if ($_POST['SummaryType'] == 'extprice' or $_POST['SummaryType'] == 'itemcode') {
                    $sql = "SELECT purchorderdetails.itemcode,\n\t\t\t\t\t\t\t\t   SUM(purchorderdetails.quantityord) as quantityord,\n\t\t\t\t\t\t\t\t   SUM(purchorderdetails.qtyinvoiced) as qtyinvoiced,\n\t\t\t\t\t\t\t\t   SUM(purchorderdetails.quantityord * purchorderdetails.unitprice) as extprice,\n\t\t\t\t\t\t\t\t   SUM(purchorderdetails.quantityord * purchorderdetails.stdcostunit) as extcost,\n\t\t\t\t\t\t\t\t   suppliers.currcode,\n\t\t\t\t\t\t\t\t   stockmaster.decimalplaces,\n\t\t\t\t\t\t\t\t   stockmaster.description\n\t\t\t\t\t\t\t\t   FROM purchorderdetails\n\t\t\t\t\t\t\tLEFT JOIN purchorders ON purchorders.orderno=purchorderdetails.orderno\n\t\t\t\t\t\t\tLEFT JOIN suppliers ON purchorders.supplierno = suppliers.supplierid\n\t\t\t\t\t\t\tLEFT JOIN stockmaster ON purchorderdetails.itemcode = stockmaster.stockid\n\t\t\t\t\t\t\tLEFT JOIN stockcategory ON stockcategory.categoryid = stockmaster.categoryid\n\t\t\t\t\t\t\tWHERE purchorders.orddate >='{$FromDate}'\n\t\t\t\t\t\t\t AND purchorders.orddate <='{$ToDate}'\n\t\t\t\t\t\t\t{$WherePart}\n\t\t\t\t\t\t\t{$WhereSupplierID}\n\t\t\t\t\t\t\t{$WhereSupplierName}\n\t\t\t\t\t\t\t{$WhereOrderNo}\n\t\t\t\t\t\t\t{$WhereLineStatus}\n\t\t\t\t\t\t\t{$WhereCategory}\n\t\t\t\t\t\t\tGROUP BY " . $_POST['SummaryType'] . ",stockmaster.decimalplaces,\n\t\t\t\t\t\t\t  stockmaster.description\n\t\t\t\t\t\t\tORDER BY " . $orderby;
                } elseif ($_POST['SummaryType'] == 'orderno') {
                    $sql = "SELECT purchorderdetails.orderno,\n\t\t\t\t\t\t\t\t   purchorders.supplierno,\n\t\t\t\t\t\t\t\t   SUM(purchorderdetails.quantityord) as quantityord,\n\t\t\t\t\t\t\t\t   SUM(purchorderdetails.qtyinvoiced) as qtyinvoiced,\n\t\t\t\t\t\t\t\t   SUM(purchorderdetails.quantityord * purchorderdetails.unitprice) as extprice,\n\t\t\t\t\t\t\t\t   SUM(purchorderdetails.quantityord * purchorderdetails.stdcostunit) as extcost,\n\t\t\t\t\t\t\t\t   suppliers.currcode,\n\t\t\t\t\t\t\t\t   suppliers.suppname\n\t\t\t\t\t\t\t\t   FROM purchorderdetails\n\t\t\t\t\t\t\tLEFT JOIN purchorders ON purchorders.orderno=purchorderdetails.orderno\n\t\t\t\t\t\t\tLEFT JOIN suppliers ON purchorders.supplierno = suppliers.supplierid\n\t\t\t\t\t\t\tLEFT JOIN stockmaster ON purchorderdetails.itemcode = stockmaster.stockid\n\t\t\t\t\t\t\tLEFT JOIN stockcategory ON stockcategory.categoryid = stockmaster.categoryid\n\t\t\t\t\t\t\tWHERE purchorders.orddate >='{$FromDate}'\n\t\t\t\t\t\t\t AND purchorders.orddate <='{$ToDate}'\n\t\t\t\t\t\t\t{$WherePart}\n\t\t\t\t\t\t\t{$WhereSupplierID}\n\t\t\t\t\t\t\t{$WhereSupplierName}\n\t\t\t\t\t\t\t{$WhereOrderNo}\n\t\t\t\t\t\t\t{$WhereLineStatus}\n\t\t\t\t\t\t\t{$WhereCategory}\n\t\t\t\t\t\t\tGROUP BY " . $_POST['SummaryType'] . ",purchorders.supplierno,\n\t\t\t\t\t\t\t  suppliers.suppname\n\t\t\t\t\t\t\tORDER BY " . $orderby;
                } elseif ($_POST['SummaryType'] == 'supplierno' or $_POST['SummaryType'] == 'suppname,suppliers.supplierid') {
                    $sql = "SELECT purchorders.supplierno,\n\t\t\t\t\t\t\t\t   SUM(purchorderdetails.quantityord) as quantityord,\n\t\t\t\t\t\t\t\t   SUM(purchorderdetails.qtyinvoiced) as qtyinvoiced,\n\t\t\t\t\t\t\t\t   SUM(purchorderdetails.quantityord * purchorderdetails.unitprice) as extprice,\n\t\t\t\t\t\t\t\t   SUM(purchorderdetails.quantityord * purchorderdetails.stdcostunit) as extcost,\n\t\t\t\t\t\t\t\t   suppliers.currcode,\n\t\t\t\t\t\t\t\t   suppliers.suppname\n\t\t\t\t\t\t\t\t   FROM purchorderdetails\n\t\t\t\t\t\t\tLEFT JOIN purchorders ON purchorders.orderno=purchorderdetails.orderno\n\t\t\t\t\t\t\tLEFT JOIN suppliers ON purchorders.supplierno = suppliers.supplierid\n\t\t\t\t\t\t\tLEFT JOIN stockmaster ON purchorderdetails.itemcode = stockmaster.stockid\n\t\t\t\t\t\t\tLEFT JOIN stockcategory ON stockcategory.categoryid = stockmaster.categoryid\n\t\t\t\t\t\t\tWHERE purchorders.orddate >='{$FromDate}'\n\t\t\t\t\t\t\t AND purchorders.orddate <='{$ToDate}'\n\t\t\t\t\t\t\t{$WherePart}\n\t\t\t\t\t\t\t{$WhereSupplierID}\n\t\t\t\t\t\t\t{$WhereSupplierName}\n\t\t\t\t\t\t\t{$WhereOrderNo}\n\t\t\t\t\t\t\t{$WhereLineStatus}\n\t\t\t\t\t\t\t{$WhereCategory}\n\t\t\t\t\t\t\tGROUP BY " . $_POST['SummaryType'] . ",purchorders.supplierno,\n\t\t\t\t\t\t\t  suppliers.suppname\n\t\t\t\t\t\t\tORDER BY " . $orderby;
                } elseif ($_POST['SummaryType'] == 'month') {
                    $sql = "SELECT EXTRACT(YEAR_MONTH from purchorders.orddate) as month,\n\t\t\t\t\t\t\t\t   suppliers.currcode,\n\t\t\t\t\t\t\t\t   CONCAT(MONTHNAME(purchorders.orddate),' ',YEAR(purchorders.orddate)) as monthname,\n\t\t\t\t\t\t\t\t   SUM(purchorderdetails.quantityord) as quantityord,\n\t\t\t\t\t\t\t\t   SUM(purchorderdetails.qtyinvoiced) as qtyinvoiced,\n\t\t\t\t\t\t\t\t   SUM(purchorderdetails.quantityord * purchorderdetails.unitprice) as extprice,\n\t\t\t\t\t\t\t\t   SUM(purchorderdetails.quantityord * purchorderdetails.stdcostunit) as extcost\n\t\t\t\t\t\t\t\t   FROM purchorderdetails\n\t\t\t\t\t\t\tLEFT JOIN purchorders ON purchorders.orderno=purchorderdetails.orderno\n\t\t\t\t\t\t\tLEFT JOIN suppliers ON purchorders.supplierno = suppliers.supplierid\n\t\t\t\t\t\t\tLEFT JOIN stockmaster ON purchorderdetails.itemcode = stockmaster.stockid\n\t\t\t\t\t\t\tLEFT JOIN stockcategory ON stockcategory.categoryid = stockmaster.categoryid\n\t\t\t\t\t\t\tWHERE purchorders.orddate >='{$FromDate}'\n\t\t\t\t\t\t\t AND purchorders.orddate <='{$ToDate}'\n\t\t\t\t\t\t\t{$WherePart}\n\t\t\t\t\t\t\t{$WhereSupplierID}\n\t\t\t\t\t\t\t{$WhereSupplierName}\n\t\t\t\t\t\t\t{$WhereOrderNo}\n\t\t\t\t\t\t\t{$WhereLineStatus}\n\t\t\t\t\t\t\t{$WhereCategory}\n\t\t\t\t\t\t\tGROUP BY " . $_POST['SummaryType'] . ", monthname\n\t\t\t\t\t\t\tORDER BY " . $orderby;
                } elseif ($_POST['SummaryType'] == 'categoryid') {
                    $sql = "SELECT SUM(purchorderdetails.quantityord) as quantityord,\n\t\t\t\t\t\t\t\t   SUM(purchorderdetails.qtyinvoiced) as qtyinvoiced,\n\t\t\t\t\t\t\t\t   SUM(purchorderdetails.quantityord * purchorderdetails.unitprice) as extprice,\n\t\t\t\t\t\t\t\t   SUM(purchorderdetails.quantityord * purchorderdetails.stdcostunit) as extcost,\n\t\t\t\t\t\t\t\t   suppliers.currcode,\n\t\t\t\t\t\t\t\t   stockmaster.categoryid,\n\t\t\t\t\t\t\t\t   stockcategory.categorydescription\n\t\t\t\t\t\t\t\t   FROM purchorderdetails\n\t\t\t\t\t\t\tLEFT JOIN purchorders ON purchorders.orderno=purchorderdetails.orderno\n\t\t\t\t\t\t\tLEFT JOIN suppliers ON purchorders.supplierno = suppliers.supplierid\n\t\t\t\t\t\t\tLEFT JOIN stockmaster ON purchorderdetails.itemcode = stockmaster.stockid\n\t\t\t\t\t\t\tLEFT JOIN stockcategory ON stockcategory.categoryid = stockmaster.categoryid\n\t\t\t\t\t\t\tWHERE purchorders.orddate >='{$FromDate}'\n\t\t\t\t\t\t\t AND purchorders.orddate <='{$ToDate}'\n\t\t\t\t\t\t\t{$WherePart}\n\t\t\t\t\t\t\t{$WhereSupplierID}\n\t\t\t\t\t\t\t{$WhereSupplierName}\n\t\t\t\t\t\t\t{$WhereOrderNo}\n\t\t\t\t\t\t\t{$WhereLineStatus}\n\t\t\t\t\t\t\t{$WhereCategory}\n\t\t\t\t\t\t\tGROUP BY " . $_POST['SummaryType'] . ", categorydescription\n\t\t\t\t\t\t\tORDER BY " . $orderby;
                }
            } else {
                // Selects by delivery date from grns
                if ($_POST['SummaryType'] == 'extprice' or $_POST['SummaryType'] == 'itemcode') {
                    $sql = "SELECT purchorderdetails.itemcode,\n\t\t\t\t\t\t\t\t   SUM(grns.qtyrecd) as quantityord,\n\t\t\t\t\t\t\t\t   SUM(grns.quantityinv) as qtyinvoiced,\n\t\t\t\t\t\t\t\t   SUM(grns.qtyrecd * purchorderdetails.unitprice) as extprice,\n\t\t\t\t\t\t\t\t   SUM(grns.qtyrecd * grns.stdcostunit) as extcost,\n\t\t\t\t\t\t\t\t   suppliers.currcode,\n\t\t\t\t\t\t\t\t   stockmaster.description\n\t\t\t\t\t\t\t\t   FROM grns\n\t\t\t\t\t\t\tLEFT JOIN purchorderdetails ON grns.podetailitem = purchorderdetails.podetailitem\n\t\t\t\t\t\t\tLEFT JOIN purchorders ON purchorders.orderno=purchorderdetails.orderno\n\t\t\t\t\t\t\tLEFT JOIN suppliers ON purchorders.supplierno = suppliers.supplierid\n\t\t\t\t\t\t\tLEFT JOIN stockmaster ON purchorderdetails.itemcode = stockmaster.stockid\n\t\t\t\t\t\t\tLEFT JOIN stockcategory ON stockcategory.categoryid = stockmaster.categoryid\n\t\t\t\t\t\t\tWHERE grns.deliverydate >='{$FromDate}'\n\t\t\t\t\t\t\t AND grns.deliverydate <='{$ToDate}'\n\t\t\t\t\t\t\t{$WherePart}\n\t\t\t\t\t\t\t{$WhereSupplierID}\n\t\t\t\t\t\t\t{$WhereSupplierName}\n\t\t\t\t\t\t\t{$WhereOrderNo}\n\t\t\t\t\t\t\t{$WhereLineStatus}\n\t\t\t\t\t\t\t{$WhereCategory}\n\t\t\t\t\t\t\tGROUP BY " . $_POST['SummaryType'] . ", stockmaster.description\n\t\t\t\t\t\t\tORDER BY " . $orderby;
                } elseif ($_POST['SummaryType'] == 'orderno') {
                    $sql = "SELECT purchorderdetails.orderno,\n\t\t\t\t\t\t\t\t   purchorders.supplierno,\n\t\t\t\t\t\t\t\t   SUM(grns.qtyrecd) as quantityord,\n\t\t\t\t\t\t\t\t   SUM(grns.quantityinv) as qtyinvoiced,\n\t\t\t\t\t\t\t\t   SUM(grns.qtyrecd * purchorderdetails.unitprice) as extprice,\n\t\t\t\t\t\t\t\t   SUM(grns.qtyrecd * grns.stdcostunit) as extcost,\n\t\t\t\t\t\t\t\t   suppliers.currcode,\n\t\t\t\t\t\t\t\t   suppliers.suppname\n\t\t\t\t\t\t\t\t   FROM grns\n\t\t\t\t\t\t\tLEFT JOIN purchorderdetails ON grns.podetailitem = purchorderdetails.podetailitem\n\t\t\t\t\t\t\tLEFT JOIN purchorders ON purchorders.orderno=purchorderdetails.orderno\n\t\t\t\t\t\t\tLEFT JOIN suppliers ON purchorders.supplierno = suppliers.supplierid\n\t\t\t\t\t\t\tLEFT JOIN stockmaster ON purchorderdetails.itemcode = stockmaster.stockid\n\t\t\t\t\t\t\tLEFT JOIN stockcategory ON stockcategory.categoryid = stockmaster.categoryid\n\t\t\t\t\t\t\tWHERE grns.deliverydate >='{$FromDate}'\n\t\t\t\t\t\t\t AND grns.deliverydate <='{$ToDate}'\n\t\t\t\t\t\t\t{$WherePart}\n\t\t\t\t\t\t\t{$WhereSupplierID}\n\t\t\t\t\t\t\t{$WhereSupplierName}\n\t\t\t\t\t\t\t{$WhereOrderNo}\n\t\t\t\t\t\t\t{$WhereLineStatus}\n\t\t\t\t\t\t\t{$WhereCategory}\n\t\t\t\t\t\t\tGROUP BY " . $_POST['SummaryType'] . ", purchorders.supplierno,\n\t\t\t\t\t\t\t   suppliers.suppname\n\t\t\t\t\t\t\tORDER BY " . $orderby;
                } elseif ($_POST['SummaryType'] == 'supplierno' or $_POST['SummaryType'] == 'suppname,suppliers.supplierid') {
                    $sql = "SELECT purchorders.supplierno,\n\t\t\t\t\t\t\t\t   SUM(grns.qtyrecd) as quantityord,\n\t\t\t\t\t\t\t\t   SUM(grns.quantityinv) as qtyinvoiced,\n\t\t\t\t\t\t\t\t   SUM(grns.qtyrecd * purchorderdetails.unitprice) as extprice,\n\t\t\t\t\t\t\t\t   SUM(grns.qtyrecd * grns.stdcostunit) as extcost,\n\t\t\t\t\t\t\t\t   suppliers.currcode,\n\t\t\t\t\t\t\t\t   suppliers.suppname\n\t\t\t\t\t\t\t\t   FROM grns\n\t\t\t\t\t\t\tLEFT JOIN purchorderdetails ON grns.podetailitem = purchorderdetails.podetailitem\n\t\t\t\t\t\t\tLEFT JOIN purchorders ON purchorders.orderno=purchorderdetails.orderno\n\t\t\t\t\t\t\tLEFT JOIN suppliers ON purchorders.supplierno = suppliers.supplierid\n\t\t\t\t\t\t\tLEFT JOIN stockmaster ON purchorderdetails.itemcode = stockmaster.stockid\n\t\t\t\t\t\t\tLEFT JOIN stockcategory ON stockcategory.categoryid = stockmaster.categoryid\n\t\t\t\t\t\t\tWHERE grns.deliverydate >='{$FromDate}'\n\t\t\t\t\t\t\t AND grns.deliverydate <='{$ToDate}'\n\t\t\t\t\t\t\t{$WherePart}\n\t\t\t\t\t\t\t{$WhereSupplierID}\n\t\t\t\t\t\t\t{$WhereSupplierName}\n\t\t\t\t\t\t\t{$WhereOrderNo}\n\t\t\t\t\t\t\t{$WhereLineStatus}\n\t\t\t\t\t\t\t{$WhereCategory}\n\t\t\t\t\t\t\tGROUP BY " . $_POST['SummaryType'] . ", purchorders.supplierno,\n\t\t\t\t\t\t\t   suppliers.suppname\n\t\t\t\t\t\t\tORDER BY " . $orderby;
                } elseif ($_POST['SummaryType'] == 'month') {
                    $sql = "SELECT EXTRACT(YEAR_MONTH from purchorders.orddate) as month,\n\t\t\t\t\t\t\t\t   CONCAT(MONTHNAME(purchorders.orddate),' ',YEAR(purchorders.orddate)) as monthname,\n\t\t\t\t\t\t\t\t   suppliers.currcode,\n\t\t\t\t\t\t\t\t   SUM(grns.qtyrecd) as quantityord,\n\t\t\t\t\t\t\t\t   SUM(grns.quantityinv) as qtyinvoiced,\n\t\t\t\t\t\t\t\t   SUM(grns.qtyrecd * purchorderdetails.unitprice) as extprice,\n\t\t\t\t\t\t\t\t   SUM(grns.qtyrecd * grns.stdcostunit) as extcost\n\t\t\t\t\t\t\t\t   FROM grns\n\t\t\t\t\t\t\tLEFT JOIN purchorderdetails ON grns.podetailitem = purchorderdetails.podetailitem\n\t\t\t\t\t\t\tLEFT JOIN purchorders ON purchorders.orderno=purchorderdetails.orderno\n\t\t\t\t\t\t\tLEFT JOIN suppliers ON purchorders.supplierno = suppliers.supplierid\n\t\t\t\t\t\t\tLEFT JOIN stockmaster ON purchorderdetails.itemcode = stockmaster.stockid\n\t\t\t\t\t\t\tLEFT JOIN stockcategory ON stockcategory.categoryid = stockmaster.categoryid\n\t\t\t\t\t\t\tWHERE grns.deliverydate >='{$FromDate}'\n\t\t\t\t\t\t\t AND grns.deliverydate <='{$ToDate}'\n\t\t\t\t\t\t\t{$WherePart}\n\t\t\t\t\t\t\t{$WhereSupplierID}\n\t\t\t\t\t\t\t{$WhereSupplierName}\n\t\t\t\t\t\t\t{$WhereOrderNo}\n\t\t\t\t\t\t\t{$WhereLineStatus}\n\t\t\t\t\t\t\t{$WhereCategory}\n\t\t\t\t\t\t\tGROUP BY " . $_POST['SummaryType'] . ",monthname\n\t\t\t\t\t\t\tORDER BY " . $orderby;
                } elseif ($_POST['SummaryType'] == 'categoryid') {
                    $sql = "SELECT stockmaster.categoryid,\n\t\t\t\t\t\t\t\t   stockcategory.categorydescription,\n\t\t\t\t\t\t\t\t   suppliers.currcode,\n\t\t\t\t\t\t\t\t   SUM(grns.qtyrecd) as quantityord,\n\t\t\t\t\t\t\t\t   SUM(grns.quantityinv) as qtyinvoiced,\n\t\t\t\t\t\t\t\t   SUM(grns.qtyrecd * purchorderdetails.unitprice) as extprice,\n\t\t\t\t\t\t\t\t   SUM(grns.qtyrecd * grns.stdcostunit) as extcost\n\t\t\t\t\t\t\t\t   FROM grns\n\t\t\t\t\t\t\tLEFT JOIN purchorderdetails ON grns.podetailitem = purchorderdetails.podetailitem\n\t\t\t\t\t\t\tLEFT JOIN purchorders ON purchorders.orderno=purchorderdetails.orderno\n\t\t\t\t\t\t\tLEFT JOIN suppliers ON purchorders.supplierno = suppliers.supplierid\n\t\t\t\t\t\t\tLEFT JOIN stockmaster ON purchorderdetails.itemcode = stockmaster.stockid\n\t\t\t\t\t\t\tLEFT JOIN stockcategory ON stockcategory.categoryid = stockmaster.categoryid\n\t\t\t\t\t\t\tWHERE grns.deliverydate >='{$FromDate}'\n\t\t\t\t\t\t\t AND grns.deliverydate <='{$ToDate}'\n\t\t\t\t\t\t\t{$WherePart}\n\t\t\t\t\t\t\t{$WhereSupplierID}\n\t\t\t\t\t\t\t{$WhereSupplierName}\n\t\t\t\t\t\t\t{$WhereOrderNo}\n\t\t\t\t\t\t\t{$WhereLineStatus}\n\t\t\t\t\t\t\t{$WhereCategory}\n\t\t\t\t\t\t\tGROUP BY " . $_POST['SummaryType'] . ",categorydescription\n\t\t\t\t\t\t\tORDER BY " . $orderby;
                }
            }
        }
        // End of if ($_POST['ReportType']
        //echo "<br/>$sql<br/>";
        $ErrMsg = _('The SQL to find the parts selected failed with the message');
        $result = DB_query($sql, $db, $ErrMsg);
        $ctr = 0;
        $TotalQty = 0;
        $TotalExtCost = 0;
        $TotalExtPrice = 0;
        $TotalInvQty = 0;
        $FileName = $_SESSION['reports_dir'] . '/POReport.csv';
        $FileHandle = fopen($FileName, 'w');
        // Create array for summary type to display in header. Access it with $SaveSummaryType
        $Summary_Array['orderno'] = _('Order Number');
        $Summary_Array['itemcode'] = _('Part Number');
        $Summary_Array['extprice'] = _('Extended Price');
        $Summary_Array['supplierno'] = _('Customer Number');
        $Summary_Array['suppname'] = _('Customer Name');
        $Summary_Array['month'] = _('Month');
        $Summary_Array['categoryid'] = _('Stock Category');
        // Create array for sort for detail report to display in header
        $Detail_Array['purchorderdetails.orderno'] = _('Order Number');
        $Detail_Array['purchorderdetails.itemcode'] = _('Part Number');
        $Detail_Array['suppliers.supplierid,purchorderdetails.orderno'] = _('Supplier Number');
        $Detail_Array['suppliers.suppname,suppliers.supplierid,purchorderdetails.orderno'] = _('Supplier Name');
        // Display Header info
        if ($_POST['ReportType'] == 'Summary') {
            $SortBy_Display = $Summary_Array[$SaveSummaryType];
        } else {
            $SortBy_Display = $Detail_Array[$_POST['SortBy']];
        }
        fprintf($FileHandle, '"' . _('Purchase Order Report') . '","' . $_POST['ReportType'] . ' ' . _('By') . ' ' . $SortBy_Display . "\n");
        fprintf($FileHandle, '"' . _('Date Type') . '","' . $_POST['DateType'] . '"' . "\n");
        fprintf($FileHandle, '"' . _('Date Range') . '","' . $_POST['FromDate'] . _(' To ') . $_POST['ToDate'] . '"' . "\n");
        if (strlen(trim($PartNumber)) > 0) {
            fprintf($FileHandle, '"' . _('Part Number') . '","' . $_POST['PartNumberOp'] . ' ' . $_POST['PartNumber'] . '"' . "\n");
        }
        if (strlen(trim($_POST['SupplierId'])) > 0) {
            fprintf($FileHandle, '"' . _('Supplier Number') . '","' . $_POST['SupplierIdOp'] . ' ' . $_POST['SupplierId'] . '"' . "\n");
        }
        if (strlen(trim($_POST['SupplierName'])) > 0) {
            fprintf($FileHandle, '"' . _('Supplier Name') . '","' . $_POST['SupplierNameOp'] . ' ' . $_POST['SupplierName'] . '"' . "\n");
        }
        fprintf($FileHandle, '"' . _('Line Item Status') . '","' . $_POST['LineStatus'] . '"' . "\n");
        fprintf($FileHandle, '"' . _('Stock Category') . '","' . $_POST['Category'] . '"' . "\n");
        if ($_POST['ReportType'] == 'Detail') {
            if ($_POST['DateType'] == 'Order') {
                fprintf($FileHandle, '"%s","%s","%s","%s","%s","%s","%s","%s","%s","%s","%s","%s"' . "\n", _('Order No'), _('Part Number'), _('Order Date'), _('Supplier No'), _('Supplier Name'), _('Order Qty'), _('Extended Cost'), _('Extended Price'), _('Invoiced Qty'), _('Line Status'), _('Item Due'), _('Part Description'));
                $linectr = 0;
                while ($myrow = DB_fetch_array($result)) {
                    $linectr++;
                    // Detail for both DateType of Order
                    fprintf($FileHandle, '"%s","%s","%s","%s","%s",%s,%s,%s,%s,"%s","%s","%s"' . "\n", $myrow['orderno'], $myrow['itemcode'], ConvertSQLDate($myrow['orddate']), $myrow['supplierno'], $myrow['suppname'], locale_number_format($myrow['quantityord'], $myrow['decimalplaces']), locale_money_format($myrow['extcost'], $myrow['currcode']), locale_money_format($myrow['extprice'], $myrow['currcode']), locale_number_format($myrow['qtyinvoiced'], $myrow['decimalplaces']), $myrow['linestatus'], ConvertSQLDate($myrow['deliverydate']), $myrow['description']);
                    $LastDecimalPlaces = $myrow['decimalplaces'];
                    $TotalQty += $myrow['quantityord'];
                    $TotalExtCost += $myrow['extcost'];
                    $TotalExtPrice += $myrow['extprice'];
                    $TotalInvQty += $myrow['qtyinvoiced'];
                }
                //END WHILE LIST LOOP
            } else {
                // Header for Date Type of Delivery Date
                fprintf($FileHandle, '"%s","%s","%s","%s","%s","%s","%s","%s","%s","%s","%s","%s"' . "\n", _('Order No'), _('Part Number'), _('Order Date'), _('Supplier No'), _('Supplier Name'), _('Received'), _('Extended Cost'), _('Extended Price'), _('Invoiced Qty'), _('Line Status'), _('Delivered'), _('Part Description'));
                $linectr = 0;
                while ($myrow = DB_fetch_array($result)) {
                    $linectr++;
                    // Detail for both DateType of Ship
                    // In sql, had to alias grns.qtyrecd as quantityord so could use same name here
                    fprintf($FileHandle, '"%s","%s","%s","%s","%s",%s,%s,%s,%s,"%s","%s","%s"' . "\n", $myrow['orderno'], $myrow['itemcode'], ConvertSQLDate($myrow['orddate']), $myrow['supplierno'], $myrow['suppname'], locale_number_format($myrow['quantityord'], $myrow['decimalplaces']), locale_money_format($myrow['extcost'], $myrow['currcode']), locale_money_format($myrow['extprice'], $myrow['currcode']), locale_number_format($myrow['qtyinvoiced'], $myrow['decimalplaces']), $myrow['linestatus'], ConvertSQLDate($myrow['deliverydate']), $myrow['description']);
                    $LastDecimalPlaces = $myrow['decimalplaces'];
                    $TotalQty += $myrow['quantityord'];
                    $TotalExtCost += $myrow['extcost'];
                    $TotalExtPrice += $myrow['extprice'];
                    $TotalInvQty += $myrow['qtyinvoiced'];
                }
                //END WHILE LIST LOOP
            }
        } else {
            // Print summary stuff
            $summarytype = $_POST['SummaryType'];
            // For SummaryType 'suppname' had to add supplierid to it for the GROUP BY in the sql,
            // but have to take it away for $myrow[$summarytype] to be valid
            // Set up description based on the Summary Type
            if ($summarytype == 'suppname,suppliers.supplierid') {
                $summarytype = 'suppname';
                $description = 'supplierno';
                $summaryheader = _('Supplier Name');
                $descriptionheader = _('Supplier Number');
            }
            if ($summarytype == 'itemcode' or $summarytype == 'extprice') {
                $description = 'description';
                $summaryheader = _('Part Number');
                $descriptionheader = _('Part Description');
            }
            if ($summarytype == 'supplierno') {
                $description = 'suppname';
                $summaryheader = _('Supplier Number');
                $descriptionheader = _('Supplier Name');
            }
            if ($summarytype == 'orderno') {
                $description = 'supplierno';
                $summaryheader = _('Order Number');
                $descriptionheader = _('Supplier Number');
            }
            if ($summarytype == 'categoryid') {
                $description = 'categorydescription';
                $summaryheader = _('Stock Category');
                $descriptionheader = _('Category Description');
            }
            $summarydesc = $summaryheader;
            if ($orderby == 'extprice DESC') {
                $summarydesc = _('Extended Price');
            }
            if ($summarytype == 'month') {
                $description = 'monthname';
                $summaryheader = _('Month');
                $descriptionheader = _('Month');
            }
            fprintf($FileHandle, '"%s","%s","%s","%s","%s","%s"' . "\n", _($summaryheader), _($descriptionheader), _('Quantity'), _('Extended Cost'), _('Extended Price'), _('Invoiced Qty'));
            $suppname = ' ';
            $linectr = 0;
            while ($myrow = DB_fetch_array($result)) {
                $linectr++;
                if ($summarytype == 'orderno') {
                    $suppname = $myrow['suppname'];
                }
                fprintf($FileHandle, '"%s","%s",%s,%s,%s,%s,"%s"' . "\n", $myrow[$summarytype], $myrow[$description], locale_number_format($myrow['quantityord'], $myrow['decimalplaces']), locale_money_format($myrow['extcost'], $myrow['currcode']), locale_money_format($myrow['extprice'], $myrow['currcode']), locale_number_format($myrow['qtyinvoiced'], $myrow['decimalplaces']), $suppname);
                print '<br/>';
                $LastDecimalPlaces = $myrow['decimalplaces'];
                $TotalQty += $myrow['quantityord'];
                $TotalExtCost += $myrow['extcost'];
                $TotalExtPrice += $myrow['extprice'];
                $TotalInvQty += $myrow['qtyinvoiced'];
            }
            //END WHILE LIST LOOP
        }
        // End of if ($_POST['ReportType']
        fclose($FileHandle);
        echo '<div class="centre"><p>' . _('The report has been exported as a csv file.') . '</p>';
        echo '<p><a href="' . $FileName . '">' . _('click here') . '</a> ' . _('to view the file') . '</div></p>';
        echo '<div class="centre"><a href="">' . _('Return to Selection') . '</a></div>';
    }
    // End of if inputerror != 1
}
Example #21
0
     if ($Controlled == true) {
         while ($SerialStockMoves = DB_fetch_array($GetStockMoveResult)) {
             $SQL = "INSERT INTO stockserialmoves (\n\t\t\t\t\t\tstockmoveno,\n\t\t\t\t\t\tstockid,\n\t\t\t\t\t\tserialno,\n\t\t\t\t\t\tmoveqty)\n\t\t\t\t\tVALUES (\n\t\t\t\t\t\t'" . $StkMoveNo . "',\n\t\t\t\t\t\t'" . $GRN['itemcode'] . "',\n\t\t\t\t\t\t'" . $SerialStockMoves['serialno'] . "',\n\t\t\t\t\t\t'" . -$SerialStockMoves['moveqty'] . "')";
             $result = DB_query($SQL, $db, _('Could not insert the reversing stock movements for the batch/serial numbers'), _('The SQL used but failed was') . ':', true);
             $SQL = "UPDATE stockserialitems\n\t\t\t\t\tSET quantity=quantity - " . $SerialStockMoves['moveqty'] . "\n\t\t\t\t\tWHERE stockserialitems.stockid='" . $GRN['itemcode'] . "'\n\t\t\t\t\tAND stockserialitems.loccode ='" . $GRN['intostocklocation'] . "'\n\t\t\t\t\tAND stockserialitems.serialno = '" . $SerialStockMoves['serialno'] . "'";
             $result = DB_query($SQL, $db, _('Could not update the batch/serial stock records'), _('The SQL used but failed was') . ':', true);
         }
     }
 }
 /*end of its a stock item - updates to locations and insert movements*/
 /* If GLLink_Stock then insert GLTrans to debit the GL Code  and credit GRN Suspense account at standard cost*/
 if ($_SESSION['CompanyRecord']['gllink_stock'] == 1 and $GRN['glcode'] != 0 and $GRN['stdcostunit'] != 0) {
     /*GLCode is set to 0 when the GLLink is not activated
     	this covers a situation where the GLLink is now active  but it wasn't when this PO was entered */
     /*first the credit using the GLCode in the PO detail record entry*/
     $SQL = "INSERT INTO gltrans (\n\t\t\t\ttype,\n\t\t\t\ttypeno,\n\t\t\t\ttrandate,\n\t\t\t\tperiodno,\n\t\t\t\taccount,\n\t\t\t\tnarrative,\n\t\t\t\tamount)\n\t\t\tVALUES (\n\t\t\t\t25,\n\t\t\t\t'" . $_GET['GRNNo'] . "',\n\t\t\t\t'" . $GRN['deliverydate'] . "',\n\t\t\t\t'" . $PeriodNo . "',\n\t\t\t\t'" . $GRN['glcode'] . "',\n\t\t\t\t'" . _('GRN Reversal for PO') . ": " . $GRN['orderno'] . " " . $_POST['SupplierID'] . " - " . $GRN['itemcode'] . "-" . $GRN['itemdescription'] . " x " . $QtyToReverse . " @ " . locale_money_format($GRN['stdcostunit'], $GRN['currcode']) . "',\n\t\t\t\t'" . -($GRN['stdcostunit'] * $QtyToReverse) . "'\n\t\t\t\t)";
     $ErrMsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('The purchase GL posting could not be inserted for the reversal of the received item because');
     $DbgMsg = _('The following SQL to insert the purchase GLTrans record was used');
     $Result = DB_query($SQL, $db, $ErrMsg, $DbgMsg, true);
     /*now the GRN suspense entry*/
     $SQL = "INSERT INTO gltrans (type,\n\t\t\t\t\t\t\t\t\ttypeno,\n\t\t\t\t\t\t\t\t\ttrandate,\n\t\t\t\t\t\t\t\t\tperiodno,\n\t\t\t\t\t\t\t\t\taccount,\n\t\t\t\t\t\t\t\t\tnarrative,\n\t\t\t\t\t\t\t\t\tamount)\n\t\t\t\t\t\t\t\tVALUES (\n\t\t\t\t\t\t\t\t\t25,\n\t\t\t\t\t\t\t\t\t'" . $_GET['GRNNo'] . "',\n\t\t\t\t\t\t\t\t\t'" . $GRN['deliverydate'] . "',\n\t\t\t\t\t\t\t\t\t'" . $PeriodNo . "',\n\t\t\t\t\t\t\t\t\t'" . $_SESSION['CompanyRecord']['grnact'] . "', '" . _('GRN Reversal PO') . ': ' . $GRN['orderno'] . " " . $_POST['SupplierID'] . " - " . $GRN['itemcode'] . "-" . $GRN['itemdescription'] . " x " . $QtyToReverse . " @ " . locale_number_format($GRN['stdcostunit'], $GRN['decimalplaces']) . "',\n\t\t\t\t\t\t\t\t\t'" . $GRN['stdcostunit'] * $QtyToReverse . "'\n\t\t\t\t\t\t\t\t)";
     $ErrMsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('The GRN suspense side of the GL posting could not be inserted because');
     $DbgMsg = _('The following SQL to insert the GRN Suspense GLTrans record was used');
     $Result = DB_query($SQL, $db, $ErrMsg, $DbgMsg, true);
 }
 /* end of if GL and stock integrated*/
 $Result = DB_Txn_Commit($db);
 echo '<br />' . _('GRN number') . ' ' . $_GET['GRNNo'] . ' ' . _('for') . ' ' . $QtyToReverse . ' x ' . $GRN['itemcode'] . ' - ' . $GRN['itemdescription'] . ' ' . _('has been reversed') . '<br />';
 unset($_GET['GRNNo']);
 // to ensure it cant be done again!!
 echo '<a href="' . htmlspecialchars($_SERVER['PHP_SELF'], ENT_QUOTES, 'UTF-8') . '">' . _('Select another GRN to Reverse') . '</a>';
		<td>' . _('Order Quantity') . ':</td>
		<td><input type="text" class="number" size="7" maxlength="6" name="Qty" value="' . locale_number_format($_POST['Qty'], 2) . '" /></td>
	</tr>';
if (!isset($_POST['Cost'])) {
    $_POST['Cost'] = 0;
}
echo '<tr>
		<td>' . _('Unit Cost') . ':</td>
		<td><input type="text" class="number" size="15" maxlength="14" name="Cost" value="' . locale_money_format($_POST['Cost'], $_SESSION['SPL' . $identifier]->SuppCurrCode) . '" /></td>
	</tr>';
if (!isset($_POST['Price'])) {
    $_POST['Price'] = 0;
}
echo '<tr>
		<td>' . _('Unit Price') . ':</td>
		<td><input type="text" class="number" size="15" maxlength="14" name="Price" value="' . locale_money_format($_POST['Price'], $_SESSION['SPL' . $identifier]->CustCurrCode) . '" /></td>
	</tr>';
/*Default the required delivery date to tomorrow as a starting point */
$_POST['ReqDelDate'] = Date($_SESSION['DefaultDateFormat'], Mktime(0, 0, 0, Date('m'), Date('d') + 1, Date('y')));
echo '<tr>
		<td>' . _('Required Delivery Date') . ':</td>
		<td><input type="text" class="date" alt="' . $_SESSION['DefaultDateFormat'] . '" size="12" maxlength="11" name="ReqDelDate" value="' . $_POST['ReqDelDate'] . '" /></td>
	</tr>';
echo '</table>';
/* end of main table */
echo '<div class="centre">
		<button type="submit" name="EnterLine">' . _('Add Item to Order') . '</button>
		<br />
		<button type="submit" name="Cancel">' . _('Start Again') . '</button>
		<br />
		<button type="submit" name="Commit">' . _('Process This Order') . '</button>
					</tr>', locale_number_format($PrdGPPercent, 1) . '%');
                $j++;
            }
            $SectionPrdActual = 0;
            $Section = $myrow['sectioninaccounts'];
            if ($_POST['Detail'] == 'Detailed' and isset($Sections[$myrow['sectioninaccounts']])) {
                printf('<tr>
						<th colspan="6" class="header" style="text-align: left;">%s</th>
					</tr>', $Sections[$myrow['sectioninaccounts']]);
            }
            $j++;
        }
        echo '<tr>
			<td colspan="2"></td>
			<td colspan="6"><hr /></td>
		</tr>';
        printf('<tr>
				<th colspan="2" class="header" style="text-align: left;">' . _('Surplus') . ' - ' . _('Deficit') . '</th>
				<td></td>
				<td class="number">%s</td>
			</tr>', locale_money_format($PeriodProfitLoss, $_SESSION['CompanyRecord']['currencydefault']));
        echo '<tr>
			<td colspan="2"></td>
			<td colspan="6"><hr /></td>
		</tr>';
        echo '</table>';
        echo '<br /><div class="centre"><button type="submit" name="SelectADifferentPeriod">' . _('Select A Different Period') . '</button></div><br />';
    }
}
echo '</form>';
include 'includes/footer.inc';
         echo _('Doctors Fee') . ':</td><td><input type="text" class="number" size="10" name="DoctorsFee" value="' . locale_money_format(filter_currency_input($_POST['DoctorsFee']), $_SESSION['CompanyRecord']['currencydefault']) . '" />';
     } else {
         echo _('Doctors Fee') . ':</td><td><input type="text" class="number" size="10" name="DoctorsFee" value="" />';
     }
     if (isset($_POST['AddDoctorFee'])) {
         echo '<input type="checkbox" checked="checked" name="AddDoctorFee" value="Add Doctors fee to balance" onChange="ReloadForm(ChangeItem)" />' . _('Add Doctors fee to balance') . '</td></tr>';
     } else {
         echo '<input type="checkbox" name="AddDoctorFee" value="Add Doctors fee to balance" onChange="ReloadForm(ChangeItem)" />' . _('Add Doctors fee to balance') . '</td></tr>';
     }
 }
 if ($Patient[1] == 'CASH') {
     if (!isset($Received)) {
         $Received = $_SESSION['Items']['Value'];
     }
     echo '<tr><td>' . _('Amount Received') . '</td>';
     echo '<td><input type="text" class="number" size="10" name="Received" value="' . locale_money_format($Received, $_SESSION['CompanyRecord']['currencydefault']) . '" /></td></tr>';
     $sql = "SELECT bankaccountname,\n\t\t\t\tbankaccounts.accountcode,\n\t\t\t\tbankaccounts.currcode\n\t\t\tFROM bankaccounts,\n\t\t\t\tchartmaster\n\t\t\tWHERE bankaccounts.accountcode=chartmaster.accountcode\n\t\t\t\tAND pettycash=1";
     $ErrMsg = _('The bank accounts could not be retrieved because');
     $DbgMsg = _('The SQL used to retrieve the bank accounts was');
     $AccountsResults = DB_query($sql, $db, $ErrMsg, $DbgMsg);
     echo '<tr><td>' . _('Received into') . ':</td><td><select name="BankAccount">';
     if (DB_num_rows($AccountsResults) == 0) {
         echo '</select></td></tr></table><p>';
         prnMsg(_('Bank Accounts have not yet been defined. You must first') . ' <a href="' . $rootpath . '/BankAccounts.php">' . _('define the bank accounts') . '</a> ' . _('and general ledger accounts to be affected'), 'warn');
         include 'includes/footer.inc';
         exit;
     } else {
         echo '<option value=""></option>';
         while ($myrow = DB_fetch_array($AccountsResults)) {
             /*list the bank account names */
             if (isset($_SESSION['DefaultCashPoint']) and $_SESSION['DefaultCashPoint'] == $myrow['accountcode']) {
echo '</select></td></tr>';
echo '<input type="hidden" name="Item" value="' . $Item . '" />';
echo '<tr><td>' . _('Decimal Places') . '<br />' . _('to display') . '</td>';
if (isset($_POST['DecimalPlaces'])) {
    echo '<td><input type="text" class="number" name="DecimalPlaces" size="8" maxlength="8" value="' . $_POST['DecimalPlaces'] . '" /></td></tr>';
} else {
    echo '<td><input type="text" class="number" name="DecimalPlaces" size="8" maxlength="8" value="0" /></td></tr>';
}
echo '<tr><td>' . _('Conversion Factor') . '<br />' . _('to stock units') . '</td>';
if (isset($_POST['ConversionFactor'])) {
    echo '<td><input type="text" class="number" name="ConversionFactor" size="8" maxlength="8" value="' . locale_number_format($_POST['ConversionFactor'], 4) . '" /></td></tr>';
} else {
    echo '<td><input type="text" class="number" name="ConversionFactor" size="8" maxlength="8" value="' . locale_number_format(1, 4) . '" /></td></tr>';
}
echo '<tr><td>' . _('Price') . ':</td>
	          <td><input type="text" class="number" name="Price" size="11" maxlength="10" value="' . locale_money_format($_POST['Price'], $CustomerCurrencyCode) . '" /></td>
				</tr></table>';
echo '<br /><div class="centre"><button type="submit" name="submit">' . _('Enter Information') . '</button></div>';
echo '</form>';
include 'includes/footer.inc';
function ReSequenceEffectiveDates($Item, $PriceList, $CurrAbbrev, $CustomerID, $db)
{
    /*This is quite complicated - the idea is that prices set up should be unique and there is no way two prices could be returned as valid - when getting a price in includes/GetPrice.inc the logic is to first look for a price of the salestype/currency within the effective start and end dates - then if not get the price with a start date prior but a blank end date (the default price). We would not want two prices where the effective dates fall between an existing price so it is necessary to update enddates of prices  - with me - I am just hanging on here myself
    	 Prices with no end date are default prices and need to be ignored in this resquence*/
    $SQL = "SELECT branchcode,\n\t\t\t\t\t\tstartdate,\n\t\t\t\t\t\tenddate\n\t\t\t\t\t\tFROM prices\n\t\t\t\t\t\tWHERE debtorno='" . $CustomerID . "'\n\t\t\t\t\t\tAND stockid='" . $Item . "'\n\t\t\t\t\t\tAND currabrev='" . $CurrAbbrev . "'\n\t\t\t\t\t\tAND typeabbrev='" . $PriceList . "'\n\t\t\t\t\t\tAND enddate<>''\n\t\t\t\t\t\tORDER BY\n\t\t\t\t\t\tbranchcode,\n\t\t\t\t\t\tstartdate,\n\t\t\t\t\t\tenddate";
    $result = DB_query($SQL, $db);
    unset($BranchCode);
    while ($myrow = DB_fetch_array($result)) {
        if (!isset($BranchCode)) {
            unset($NextDefaultStartDate);
            //a price with a blank end date
			<td class="number">' . locale_number_format(-$WOIssuesRow['qty'], $WOIssuesRow['decimalplaces']) . '</td>
			<td class="number">' . locale_money_format(-$WOIssuesRow['qty'] * $WOIssuesRow['standardcost'], $_SESSION['CompanyRecord']['currencydefault']) . '</td>
			<td class="number">' . locale_money_format($WOIssuesRow['qty'] * $WOIssuesRow['standardcost'], $_SESSION['CompanyRecord']['currencydefault']) . '</td>
			<td class="number">0</td></tr>';
        $TotalUsageVar += $WOIssuesRow['qty'] * $WOIssuesRow['standardcost'];
    }
}
# <!--	<td colspan="5"></td> -->
echo '<tr><td colspan="3"></td><td><hr/></td><td colspan="2"></td><td colspan="3"><hr></td></tr>';
echo '<tr><td colspan="2" class="number">' . _('Totals') . '</td>
	<td></td>
	<td class="number">' . locale_money_format($TotalReqdCost, $_SESSION['CompanyRecord']['currencydefault']) . '</td>
	<td></td><td></td>
	<td class="number">' . locale_money_format($TotalIssuedCost, $_SESSION['CompanyRecord']['currencydefault']) . '</td>
	<td class="number">' . locale_money_format($TotalUsageVar, $_SESSION['CompanyRecord']['currencydefault']) . '</td>
	<td class="number">' . locale_money_format($TotalCostVar, $_SESSION['CompanyRecord']['currencydefault']) . '</td></tr>';
echo '<tr><td colspan="3"></td><td><hr/></td><td colspan="2"></td><td colspan="3"><hr></td></tr>';
#echo '<tr><td colspan="7"></td><td colspan="2"><hr></td></tr>';
if (isset($_POST['Close'])) {
    DB_data_seek($WOItemsResult, 0);
    $NoItemsOnWO = DB_num_rows($WOItemsResult);
    $TotalVariance = $TotalUsageVar + $TotalCostVar;
    $PeriodNo = GetPeriod(Date($_SESSION['DefaultDateFormat']), $db);
    $WOCloseNo = GetNextTransNo(29, $db);
    $TransResult = DB_Txn_Begin($db);
    while ($WORow = DB_fetch_array($WOItemsResult)) {
        if ($TotalStdValueRecd == 0) {
            $ShareProportion = 1 / $NoItemsOnWO;
        } else {
            $ShareProportion = $WORow['stdcost'] * $WORow['qtyrecd'] / $TotalStdValueRecd;
        }
echo '<table cellpadding="2" width="80%" class="selection">';
$TableHeader = '<tr>
<th>' . _('Supplier Number') . '<br />' . _('Reference') . '</th>
<th>' . _('Payment') . '<br />' . _('Reference') . '</th>
<th>' . _('Payment') . '<br />' . _('Date') . '</th>
<th>' . _('Total Payment') . '<br />' . _('Amount') . '</th></tr>';
echo $TableHeader;
$j = 1;
$k = 0;
//row colour counter
while ($myrow = DB_fetch_array($Result)) {
    if ($k == 1) {
        echo '<tr class="EvenTableRows">';
        $k = 0;
    } else {
        echo '<tr class="OddTableRows">';
        $k++;
    }
    echo '<td>' . $myrow['supplierno'] . '</td>
		<td>' . $myrow['suppreference'] . '</td>
		<td>' . ConvertSQLDate($myrow['trandate']) . '</td>
		<td class="number">' . locale_money_format($myrow['alloc'], $myrow['currcode']) . '</td>
		</tr>';
    $j++;
    if ($j == 18) {
        $j = 1;
        echo $TableHeader;
    }
}
echo '</table>';
include 'includes/footer.inc';
     if ($debug == 1 and abs($_SESSION['SuppTrans']->OvAmount / $_SESSION['SuppTrans']->ExRate - $LocalTotal) > 0.004) {
         prnMsg(_('The total posted to the credit accounts is') . ' ' . $LocalTotal . ' ' . _('but the sum of OvAmount converted at ExRate') . " = " . $_SESSION['SuppTrans']->OvAmount / $_SESSION['SuppTrans']->ExRate, 'error');
     }
     foreach ($_SESSION['SuppTrans']->Taxes as $Tax) {
         /* Now the TAX account */
         if ($Tax->TaxOvAmount / $_SESSION['SuppTrans']->ExRate != 0) {
             $SQL = "INSERT INTO gltrans (type,\n\t\t\t\t\t\t\t\t\t\t\t\ttypeno,\n\t\t\t\t\t\t\t\t\t\t\t\ttrandate,\n\t\t\t\t\t\t\t\t\t\t\t\tperiodno,\n\t\t\t\t\t\t\t\t\t\t\t\taccount,\n\t\t\t\t\t\t\t\t\t\t\t\tdefaulttag,\n\t\t\t\t\t\t\t\t\t\t\t\tnarrative,\n\t\t\t\t\t\t\t\t\t\t\t\tamount)\n\t\t\t\t\t\t\t\t\t\t\tVALUES (\n\t\t\t\t\t\t\t\t\t\t\t\t21,\n\t\t\t\t\t\t\t\t\t\t\t\t'" . $CreditNoteNo . "',\n\t\t\t\t\t\t\t\t\t\t\t\t'" . $SQLCreditNoteDate . "',\n\t\t\t\t\t\t\t\t\t\t\t\t'" . $PeriodNo . "',\n\t\t\t\t\t\t\t\t\t\t\t\t'" . $Tax->TaxGLCode . "',\n\t\t\t\t\t\t\t\t\t\t\t\t'" . $_SESSION['DefaultTag'] . "',\n\t\t\t\t\t\t\t\t\t\t\t\t'" . $_SESSION['SuppTrans']->SupplierID . ' - ' . _('Credit note') . ' ' . $_SESSION['SuppTrans']->SuppReference . ' ' . $_SESSION['SuppTrans']->CurrCode . $Tax->TaxOvAmount . ' @ ' . _('a rate of') . ' ' . $_SESSION['SuppTrans']->ExRate . "',\n\t\t\t\t\t\t\t\t\t\t\t\t'" . round(-$Tax->TaxOvAmount / $_SESSION['SuppTrans']->ExRate, 2) . "'\n\t\t\t\t\t\t\t\t\t\t\t)";
             $ErrMsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('The general ledger transaction for the tax could not be added because');
             $DbgMsg = _('The following SQL to insert the GL transaction was used');
             $Result = DB_query($SQL, $db, $ErrMsg, $DbgMsg, True);
         }
         /* if the tax is not 0 */
     }
     /*end of loop to post the tax */
     /* Now the control account */
     $SQL = "INSERT INTO gltrans (type,\n\t\t\t\t\t\t\t\t\t\ttypeno,\n\t\t\t\t\t\t\t\t\t\ttrandate,\n\t\t\t\t\t\t\t\t\t\tperiodno,\n\t\t\t\t\t\t\t\t\t\taccount,\n\t\t\t\t\t\t\t\t\t\tdefaulttag,\n\t\t\t\t\t\t\t\t\t\tnarrative,\n\t\t\t\t\t\t\t\t\t\tamount)\n\t\t\t\t\t\t\t\t\tVALUES (\n\t\t\t\t\t\t\t\t\t\t21,\n\t\t\t\t\t\t\t\t\t\t'" . $CreditNoteNo . "',\n\t\t\t\t\t\t\t\t\t\t'" . $SQLCreditNoteDate . "',\n\t\t\t\t\t\t\t\t\t\t'" . $PeriodNo . "',\n\t\t\t\t\t\t\t\t\t\t'" . $_SESSION['SuppTrans']->CreditorsAct . "',\n\t\t\t\t\t\t\t\t\t\t'" . $_SESSION['DefaultTag'] . "',\n\t\t\t\t\t\t\t\t\t\t'" . $_SESSION['SuppTrans']->SupplierID . ' - ' . _('Credit Note') . ' ' . $_SESSION['SuppTrans']->SuppReference . ' ' . $_SESSION['SuppTrans']->CurrCode . locale_money_format($_SESSION['SuppTrans']->OvAmount + $_SESSION['SuppTrans']->OvGST, $_SESSION['SuppTrans']->CurrCode) . ' @ ' . _('a rate of') . ' ' . $_SESSION['SuppTrans']->ExRate . "',\n\t\t\t\t\t\t\t\t\t\t'" . round($LocalTotal + $TaxTotal / $_SESSION['SuppTrans']->ExRate, 2) . "')";
     $ErrMsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('The general ledger transaction for the control total could not be added because');
     $DbgMsg = _('The following SQL to insert the GL transaction was used');
     $Result = DB_query($SQL, $db, $ErrMsg, $DbgMsg, True);
 }
 /*Thats the end of the GL postings */
 /*Now insert the credit note into the SuppTrans table*/
 $SQL = "INSERT INTO supptrans (transno,\n\t\t\t\t\t\t\t\t\t\ttype,\n\t\t\t\t\t\t\t\t\t\tsupplierno,\n\t\t\t\t\t\t\t\t\t\tsuppreference,\n\t\t\t\t\t\t\t\t\t\ttrandate,\n\t\t\t\t\t\t\t\t\t\tduedate,\n\t\t\t\t\t\t\t\t\t\tinputdate,\n\t\t\t\t\t\t\t\t\t\tovamount,\n\t\t\t\t\t\t\t\t\t\tovgst,\n\t\t\t\t\t\t\t\t\t\trate,\n\t\t\t\t\t\t\t\t\t\ttranstext)\n\t\t\t\t\t\t\t\t\tVALUES (\n\t\t\t\t\t\t\t\t\t\t'" . $CreditNoteNo . "',\n\t\t\t\t\t\t\t\t\t\t21,\n\t\t\t\t\t\t\t\t\t\t'" . $_SESSION['SuppTrans']->SupplierID . "',\n\t\t\t\t\t\t\t\t\t\t'" . $_SESSION['SuppTrans']->SuppReference . "',\n\t\t\t\t\t\t\t\t\t\t'" . $SQLCreditNoteDate . "',\n\t\t\t\t\t\t\t\t\t\t'" . FormatDateForSQL($_SESSION['SuppTrans']->DueDate) . "',\n\t\t\t\t\t\t\t\t\t\t'" . Date('Y-m-d H-i-s') . "',\n\t\t\t\t\t\t\t\t\t\t'" . round(-$_SESSION['SuppTrans']->OvAmount, 2) . "',\n\t\t\t\t\t\t\t\t\t\t'" . round(-$TaxTotal, 2) . "',\n\t\t\t\t\t\t\t\t\t\t'" . $_SESSION['SuppTrans']->ExRate . "',\n\t\t\t\t\t\t\t\t\t\t'" . $_SESSION['SuppTrans']->Comments . "'\n\t\t\t\t\t\t\t\t\t)";
 $ErrMsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('The supplier credit note transaction could not be added to the database because');
 $DbgMsg = _('The following SQL to insert the supplier credit note was used');
 $Result = DB_query($SQL, $db, $ErrMsg, $DbgMsg, True);
 $SuppTransID = DB_Last_Insert_ID($db, 'supptrans', 'id');
 /* Insert the tax totals for each tax authority where tax was charged on the invoice */
 foreach ($_SESSION['SuppTrans']->Taxes as $TaxTotals) {
     $SQL = "INSERT INTO supptranstaxes (supptransid,\n\t\t\t\t\t\t\t\t\t\t\t\ttaxauthid,\n\t\t\t\t\t\t\t\t\t\t\t\ttaxamount)\n\t\t\t\t\t\t\t\t\t\t\tVALUES (\n\t\t\t\t\t\t\t\t\t\t\t\t'" . $SuppTransID . "',\n\t\t\t\t\t\t\t\t\t\t\t\t'" . $TaxTotals->TaxAuthID . "',\n\t\t\t\t\t\t\t\t\t\t\t\t'" . -$TaxTotals->TaxOvAmount . "'\n\t\t\t\t\t\t\t\t\t\t\t)";
     $ErrMsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('The supplier transaction taxes records could not be inserted because');
        } else {
            echo '<option value="' . $myrow['currabrev'] . '">' . $myrow['currency'] . '</option>';
        }
    }
    echo '</select></td></tr>';
}
echo '<tr><td>' . _('User can create orders') . '</td>';
if (isset($CanCreate) and $CanCreate == 'No') {
    echo '<td><input type="checkbox" name="CanCreate" /></td></tr>';
} else {
    echo '<td><input type="checkbox" checked="True" name="CanCreate" /></td></tr>';
}
echo '<tr><td>' . _('User can release invoices') . '</td>';
if (isset($OffHold) and $OffHold == 'No') {
    echo '<td><input type="checkbox" name="OffHold" /></td></tr>';
} else {
    echo '<td><input type="checkbox" checked="True" name="OffHold" /></td></tr>';
}
echo '<tr><td>' . _('User can authorise orders up to :') . '</td>';
if ($Currency != '') {
    echo '<td><input type="input" name="AuthLevel" size="11" class="number" value="' . locale_money_format($AuthLevel, $Currency) . '" /></td></tr>';
} else {
    echo '<td><input type="input" name="AuthLevel" size="11" class="number" value="0" /></td></tr>';
}
echo '</table>';
if (isset($_GET['Edit'])) {
    echo '<br /><div class="centre"><button type="submit" name="Update">' . _('Update Information') . '</button></div><br /></form>';
} else {
    echo '<br /><div class="centre"><button type="submit" name="Submit">' . _('Enter Information') . '</button></div><br /></form>';
}
include 'includes/footer.inc';
Example #30
0
            }
            $Uom = $POLine->UOM;
            echo '<input type="hidden" name="ConversionFactor" value="' . $POLine->ConversionFactor . '" />';
            echo '<td>' . $POLine->StockID . '</td>
				<td>' . $POLine->GetItemDescription() . '</td>
				<td><input type="text" class="number" name="Qty' . $POLine->LineNo . '" size="11" value="' . $DisplayQuantity . '" /></td>
				<td>' . $Uom . '</td>
				<td><input type="text" class="number" name="NetWeight' . $POLine->LineNo . '" size="11" value="' . locale_number_format($POLine->NetWeight, 4) . '" /></td>
				<td><input type="text" class="number" name="Price' . $POLine->LineNo . '" size="11" value="' . $DisplayPrice . '" /></td>
				<td class="number">' . $DisplayLineTotal . '</td>
				<td><input type="text" class="date" alt="' . $_SESSION['DefaultDateFormat'] . '" name="ReqDelDate' . $POLine->LineNo . '" size="11" value="' . $POLine->ReqDelDate . '" /></td>
				<td><a href="' . htmlspecialchars($_SERVER['PHP_SELF'], ENT_QUOTES, 'UTF-8') . '?identifier=' . $identifier . '&Delete=' . $POLine->LineNo . '">' . _('Delete') . '</a></td></tr>';
            $_SESSION['PO' . $identifier]->Total = $_SESSION['PO' . $identifier]->Total + $LineTotal;
        }
    }
    $DisplayTotal = locale_money_format($_SESSION['PO' . $identifier]->Total, $_SESSION['PO' . $identifier]->CurrCode);
    echo '<tr><td colspan="6" class="number">' . _('TOTAL') . _(' excluding Tax') . '</td><td class="number"><b>' . $DisplayTotal . '</b></td></tr></table>';
    echo '<br /><div class="centre"><button type="submit" name="UpdateLines">' . _('Update Order Lines') . '</button>';
    echo '&nbsp;<button type="submit" name="Commit">' . _('Process Order') . '</button></div>';
    if (!isset($_POST['NewItem']) and isset($_GET['Edit'])) {
        /*show a form for putting in a new line item with or without a stock entry */
    }
}
/*Only display the order line items if there are any !! */
if (isset($_POST['NonStockOrder'])) {
    echo '<br /><table class="selection"><tr><td>' . _('Item Description') . '</td>';
    echo '<td><input type="text" name=ItemDescription size="40" /></td></tr>';
    echo '<tr><td>' . _('General Ledger Code') . '</td>';
    echo '<td><select name="GLCode">';
    $sql = "SELECT accountcode,\n\t\t\t\taccountname\n\t\t\tFROM chartmaster\n\t\t\tORDER BY accountcode ASC";
    $result = DB_query($sql, $db);