function checkNewCode($code)
{
    $tmp = str_replace(' ', '', $code);
    if ($tmp != $code) {
        prnMsg('<br /><br />' . _('The New supplier code') . ': ' . $code . ' ' . _('must be not empty nor with spaces'), 'error');
        return false;
    }
    return true;
}
function DB_query_oc($SQL, $ErrorMessage = '', $DebugMessage = '', $Transaction = false, $TrapErrors = true)
{
    global $db_oc;
    global $PathPrefix;
    $Result = mysqli_query($db_oc, $SQL);
    if ($DebugMessage == '') {
        $DebugMessage = _('The SQL that failed was');
    }
    if (DB_error_no($db_oc) != 0 and $TrapErrors == true) {
        if ($TrapErrors) {
            require_once $PathPrefix . 'includes/header.inc';
        }
        prnMsg($ErrorMessage . '<br />' . DB_error_msg($db_oc), 'error', _('Database Error') . ' ' . DB_error_no($db_oc));
        if ($Debug == 1) {
            prnMsg($DebugMessage . '<br />' . $SQL . '<br />', 'error', _('Database SQL Failure'));
        }
        if ($Transaction) {
            $SQL = 'rollback';
            $Result = DB_query_oc($SQL);
            if (DB_error_no() != 0) {
                prnMsg(_('Error Rolling Back Transaction'), 'error', _('Database Rollback Error') . ' ' . DB_error_no($db_oc));
            } else {
                prnMsg(_('Rolling Back Transaction OK'), 'error', _('Database Rollback Due to Error Above'));
            }
        }
        if ($TrapErrors) {
            include $PathPrefix . 'includes/footer.inc';
            exit;
        }
    }
    return $Result;
}
Example #3
0
function display_children($Parent, $Level, &$BOMTree)
{
    global $db;
    global $i;
    // retrive all children of parent
    $c_result = DB_query("SELECT parent,\n\t\t\t\t\t\t\t\tcomponent\n\t\t\t\t\t\tFROM bom WHERE parent='" . $Parent . "'\n\t\t\t\t\t\tORDER BY sequence", $db);
    if (DB_num_rows($c_result) > 0) {
        while ($row = DB_fetch_array($c_result)) {
            if ($Parent != $row['component']) {
                // indent and display the title of this child
                $BOMTree[$i]['Level'] = $Level;
                // Level
                if ($Level > 15) {
                    prnMsg(_('A maximum of 15 levels of bill of materials only can be displayed'), 'error');
                    exit;
                }
                $BOMTree[$i]['Parent'] = $Parent;
                // Assemble
                $BOMTree[$i]['Component'] = $row['component'];
                // Component
                // call this function again to display this
                // child's children
                $i++;
                display_children($row['component'], $Level + 1, $BOMTree);
            }
        }
    }
}
Example #4
0
 function Remove_From_Shipment($PODetailItem, &$db)
 {
     if ($this->LineItems[$PODetailItem]->QtyInvoiced == 0) {
         unset($this->LineItems[$PODetailItem]);
         $sql = "UPDATE purchorderdetails SET shiptref = 0 WHERE podetailitem='" . $PODetailItem . "'";
         $Result = DB_query($sql, $db);
     } else {
         prnMsg(_('This shipment line has a quantity invoiced and already charged to the shipment - it cannot now be removed'), 'warn');
     }
 }
Example #5
0
function backup_tables($host, $user, $pass, $tables = '*', $db)
{
    //get all of the tables
    if ($tables == '*') {
        $tables = array();
        $result = DB_query('SHOW TABLES', $db);
        while ($row = DB_fetch_row($result)) {
            $tables[] = $row[0];
        }
    } else {
        $tables = is_array($tables) ? $tables : explode(',', $tables);
    }
    //cycle through
    foreach ($tables as $table) {
        $result = DB_query('SELECT * FROM ' . $table, $db);
        $num_fields = DB_num_fields($result);
        $num_rows = DB_num_rows($result);
        $return .= 'DROP TABLE IF EXISTS ' . $table . ';';
        $row2 = DB_fetch_row(DB_query('SHOW CREATE TABLE ' . $table, $db));
        $return .= "\n\n" . $row2[1] . ";\n\n";
        $return .= 'INSERT INTO ' . $table . ' VALUES';
        for ($i = 0; $i < $num_fields; $i++) {
            $last = 0;
            while ($row = DB_fetch_row($result)) {
                $last = $last + 1;
                $return .= '(';
                for ($j = 0; $j < $num_fields; $j++) {
                    $row[$j] = addslashes($row[$j]);
                    $row[$j] = ereg_replace("\n", "\\n", $row[$j]);
                    if (isset($row[$j])) {
                        $return .= '"' . $row[$j] . '"';
                    } else {
                        $return .= '""';
                    }
                    if ($j < $num_fields - 1 and isset($row[$j])) {
                        $return .= ',';
                    }
                }
                if ($last == $num_rows) {
                    $return .= ");\n";
                } else {
                    $return .= "),";
                }
            }
        }
        $return .= "\n\n\n";
    }
    //save file
    $handle = fopen('db-backup-' . time() . '-' . md5(implode(',', $tables)) . '.sql', 'w+');
    fwrite($handle, $return);
    fclose($handle);
    prnMsg(_(' back up successful'), 'success');
}
Example #6
0
function getXMLFile($file)
{
    $list = null;
    libxml_use_internal_errors(true);
    if (file_exists($file)) {
        $list = simplexml_load_file($file, "LabelList");
        if (!$list) {
            prnMsg(_('Failed loading XML file') . ' ' . $file . ':');
            foreach (libxml_get_errors() as $error) {
                echo "\n\t\t\t\t<br />", $error->message;
            }
            exit(_('Report this problem'));
        }
    }
    return $list;
}
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']);
} elseif (isset($_POST['StockID'])) {
    $StockID = trim(strtoupper($_POST['StockID']));
} elseif (!isset($StockID)) {
    prnMsg(_('You must select a stock item first before set a price maxtrix'), 'error');
    include 'includes/footer.inc';
    exit;
}
echo '<input type="hidden" name="StockID" value="' . $StockID . '" />';
if (!isset($_POST['StartDate'])) {
    $_POST['StartDate'] = Date($_SESSION['DefaultDateFormat']);
}
if (!isset($_POST['EndDate'])) {
    $_POST['EndDate'] = GetMySQLMaxDate();
}
echo '<tr><td>' . _('Price Effective From Date') . ':</td>
	<td><input type="text" class="date" alt="' . $_SESSION['DefaultDateFormat'] . '" name="StartDate" required="required" size="10" maxlength="10" title="' . _('Enter the date from which this price should take effect.') . '" value="' . $_POST['StartDate'] . '" /></td></tr>';
echo '<tr><td>' . _('Price Effective To Date') . ':</td>
			<td><input type="text" class="date" alt="' . $_SESSION['DefaultDateFormat'] . '" name="EndDate" size="10" maxlength="10" title="' . _('Enter the date to which this price should be in effect to, or leave empty if the price should continue indefinitely') . '" value="' . $_POST['EndDate'] . '" />';
echo '<tr>
                    $PeriodQty[$i] += 1;
                }
            }
            $i = 0;
            foreach ($PeriodQty as $demandqty) {
                $sql = "INSERT INTO mrpdemands (stockid,\n\t\t\t\t\t\t\t\t\tmrpdemandtype,\n\t\t\t\t\t\t\t\t\tquantity,\n\t\t\t\t\t\t\t\t\tduedate)\n\t\t\t\t\t\t\t\tVALUES ('" . $myrow['stkcode'] . "',\n\t\t\t\t\t\t\t\t\t'" . $_POST['MRPDemandtype'] . "',\n\t\t\t\t\t\t\t\t\t'" . $demandqty . "',\n\t\t\t\t\t\t\t\t\t'" . $datearray[$i] . "')";
                $insertresult = DB_query($sql, $db);
                $i++;
                $TotalRecords++;
            }
            // end of foreach for INSERT
        }
        // end of if that checks exludeqty, ExcludeAmount
    }
    //end while loop
    prnMsg($TotalRecords . ' ' . _('records have been created'), 'success');
}
// end if submit has been pressed
echo '<p class="page_title_text"><img src="' . $rootpath . '/css/' . $theme . '/images/inventory.png" title="' . _('Inventory') . '" alt="" />' . ' ' . $title . '</p>';
echo '<form action="' . htmlspecialchars($_SERVER['PHP_SELF'], ENT_QUOTES, 'UTF-8') . '" method="post">';
echo '<div>';
echo '<input type="hidden" name="FormID" value="' . $_SESSION['FormID'] . '" />';
echo '<table class="selection">
	<tr>
		<td>' . _('Demand Type') . ':</td>
		<td><select name="MRPDemandtype">';
$sql = "SELECT mrpdemandtype,\n\t\t\t\tdescription\n\t\tFROM mrpdemandtypes";
$result = DB_query($sql, $db);
while ($myrow = DB_fetch_array($result)) {
    echo '<option value="' . $myrow['mrpdemandtype'] . '">' . $myrow['mrpdemandtype'] . ' - ' . $myrow['description'] . '</option>';
}
			<input type="hidden" name="identifier" value="' . $identifier . '">
			<input type="hidden" name="EditControlled" value="true">
			<select name=Bundles[] multiple="multiple">';
        $id = 0;
        $ItemsAvailable = 0;
        while ($myrow = DB_fetch_array($Bundles, $db)) {
            if ($LineItem->Serialised == 1) {
                if (!array_key_exists($myrow['serialno'], $AllSerials)) {
                    echo '<option value="' . $myrow['serialno'] . '">' . $myrow['serialno'] . '</option>';
                    $ItemsAvailable++;
                }
            } else {
                if (!array_key_exists($myrow['serialno'], $AllSerials) or $myrow['quantity'] - $AllSerials[$myrow['serialno']] >= 0) {
                    $RecvQty = $myrow['quantity'] - $AllSerials[$myrow['serialno']];
                    echo '<option value="' . $myrow['serialno'] . '/|/' . $RecvQty . '">' . $myrow['serialno'] . ' - ' . _('Qty left') . ': ' . $RecvQty . '</option>';
                    $ItemsAvailable += $RecvQty;
                }
            }
        }
        echo '</select>
			<br />';
        echo '<br /><div class="centre"><input type="submit" name="AddBatches" value="' . _('Enter') . '"></div>
			<br />';
        echo '</form>';
        echo $ItemsAvailable . ' ' . _('items available');
        echo '</td>';
    } else {
        echo '<td>' . prnMsg(_('There does not appear to be any of') . ' ' . $StockID . ' ' . _('left in') . ' ' . $LocationOut, 'warn') . '</td>';
    }
    echo '</tr></table>';
}
Example #10
0
 /**
  * Trigger a PEAR error
  *
  * To improve performances, the PEAR.php file is included dynamically.
  *
  * @param string error message
  */
 function raiseError($msg)
 {
     prnMsg($msg, 'error');
 }
 }
 if (ContainsIllegalCharacters($_POST['NewStockID'])) {
     prnMsg(_('The new stock code to change the old code to contains illegal characters - no changes will be made'), 'error');
     include 'includes/footer.inc';
     exit;
 }
 if ($_POST['NewStockID'] == '') {
     prnMsg(_('The new stock code to change the old code to must be entered as well'), 'error');
     include 'includes/footer.inc';
     exit;
 }
 /*Now check that the new code doesn't already exist */
 $result = DB_query("SELECT stockid FROM stockmaster WHERE stockid='" . $_POST['NewStockID'] . "'", $db);
 if (DB_num_rows($result) != 0) {
     echo '<br><br>';
     prnMsg(_('The replacement stock code') . ': ' . $_POST['NewStockID'] . ' ' . _('already exists as a stock code in the system') . ' - ' . _('a unique stock code must be entered for the new code'), 'error');
     include 'includes/footer.inc';
     exit;
 }
 $result = DB_Txn_Begin($db);
 echo '<br>' . _('Adding the new stock master record');
 $sql = "INSERT INTO stockmaster (stockid,\n\t\t\t\t\tcategoryid,\n\t\t\t\t\tdescription,\n\t\t\t\t\tlongdescription,\n\t\t\t\t\tunits,\n\t\t\t\t\tmbflag,\n\t\t\t\t\tlastcurcostdate,\n\t\t\t\t\tactualcost,\n\t\t\t\t\tlastcost,\n\t\t\t\t\tmaterialcost,\n\t\t\t\t\tlabourcost,\n\t\t\t\t\toverheadcost,\n\t\t\t\t\tlowestlevel,\n\t\t\t\t\tdiscontinued,\n\t\t\t\t\tcontrolled,\n\t\t\t\t\teoq,\n\t\t\t\t\tvolume,\n\t\t\t\t\tkgs,\n\t\t\t\t\tbarcode,\n\t\t\t\t\tdiscountcategory,\n\t\t\t\t\ttaxcatid)\n\t\t\tSELECT '" . $_POST['NewStockID'] . "',\n\t\t\t\tcategoryid,\n\t\t\t\tdescription,\n\t\t\t\tlongdescription,\n\t\t\t\tunits,\n\t\t\t\tmbflag,\n\t\t\t\tlastcurcostdate,\n\t\t\t\tactualcost,\n\t\t\t\tlastcost,\n\t\t\t\tmaterialcost,\n\t\t\t\tlabourcost,\n\t\t\t\toverheadcost,\n\t\t\t\tlowestlevel,\n\t\t\t\tdiscontinued,\n\t\t\t\tcontrolled,\n\t\t\t\teoq,\n\t\t\t\tvolume,\n\t\t\t\tkgs,\n\t\t\t\tbarcode,\n\t\t\t\tdiscountcategory,\n\t\t\t\ttaxcatid\n\t\t\tFROM stockmaster\n\t\t\tWHERE stockid='" . $_POST['OldStockID'] . "'";
 $DbgMsg = _('The SQL statement that failed was');
 $ErrMsg = _('The SQL to insert the new stock master record failed');
 $result = DB_query($sql, $db, $ErrMsg, $DbgMsg, true);
 echo ' ... ' . _('completed');
 echo '<br>' . _('Changing stock location records');
 $sql = "UPDATE locstock SET stockid='" . $_POST['NewStockID'] . "' WHERE stockid='" . $_POST['OldStockID'] . "'";
 $ErrMsg = _('The SQL to update stock location records failed');
 $result = DB_query($sql, $db, $ErrMsg, $DbgMsg, true);
 echo ' ... ' . _('completed');
Example #12
0
        if ($YPos < $Bottom_Margin + $line_height) {
            PrintHeader($pdf, $YPos, $PageNumber, $Page_Height, $Top_Margin, $Left_Margin, $Page_Width, $Right_Margin, $assemblydesc);
        }
    }
    /*end while loop */
    $FontSize = 10;
    $YPos -= 2 * $line_height;
    if ($YPos < $Bottom_Margin + $line_height) {
        PrintHeader($pdf, $YPos, $PageNumber, $Page_Height, $Top_Margin, $Left_Margin, $Page_Width, $Right_Margin, $assemblydesc);
    }
    $pdfcode = $pdf->output();
    $len = strlen($pdfcode);
    if ($len <= 20) {
        $title = _('Print Indented BOM Listing Error');
        include 'includes/header.inc';
        prnMsg(_('There were no items for the selected assembly'), 'error');
        echo "<br><a href='{$rootpath}/index.php?" . SID . "'>" . _('Back to the menu') . '</a>';
        include 'includes/footer.inc';
        exit;
    } else {
        header('Content-type: application/pdf');
        header("Content-Length: " . $len);
        header('Content-Disposition: inline; filename=Customer_trans.pdf');
        header('Expires: 0');
        header('Cache-Control: private, post-check=0, pre-check=0');
        header('Pragma: public');
        $pdf->Output('BOMIndented.pdf', 'I');
    }
} else {
    /*The option to print PDF was not hit so display form */
    $title = _('Indented BOM Listing');
    }
    if (isset($_POST['Next'])) {
        $Offset = $_POST['NextList'];
    }
    if (isset($_POST['Prev'])) {
        $Offset = $_POST['Previous'];
    }
    if (!isset($Offset) or $Offset < 0) {
        $Offset = 0;
    }
    $SQL = $SQL . ' LIMIT ' . $_SESSION['DefaultDisplayRecordsMax'] . ' OFFSET ' . $_SESSION['DefaultDisplayRecordsMax'] * $Offset;
    $ErrMsg = _('There is a problem selecting the part records to display because');
    $DbgMsg = _('The SQL used to get the part selection was');
    $SearchResult = DB_query($SQL, $db, $ErrMsg, $DbgMsg);
    if (DB_num_rows($SearchResult) == 0) {
        prnMsg(_('There are no products available meeting the criteria specified'), 'info');
    }
    if (DB_num_rows($SearchResult) < $_SESSION['DisplayRecordsMax']) {
        $Offset = 0;
    }
}
//end of if search
/* display list if there is more than one record */
if (isset($searchresult) and !isset($_POST['Select'])) {
    echo '<form action="' . htmlspecialchars($_SERVER['PHP_SELF'], ENT_QUOTES, 'UTF-8') . '" method="post">';
    echo '<div>';
    echo '<input type="hidden" name="FormID" value="' . $_SESSION['FormID'] . '" />';
    $ListCount = DB_num_rows($searchresult);
    if ($ListCount > 0) {
        // If the user hit the search button and there is more than one item to show
        $ListPageMax = ceil($ListCount / $_SESSION['DisplayRecordsMax']);
 $CustomerResult = DB_query($SQL, $db, '', '', false, false);
 if (DB_error_no($db) != 0) {
     $Title = _('Customer Balances') . ' - ' . _('Problem Report');
     include 'includes/header.inc';
     prnMsg(_('The customer details could not be retrieved by the SQL because') . DB_error_msg($db), 'error');
     echo '<br /><a href="' . $RootPath . '/index.php">' . _('Back to the menu') . '</a>';
     if ($debug == 1) {
         echo '<br />' . $SQL;
     }
     include 'includes/footer.inc';
     exit;
 }
 if (DB_num_rows($CustomerResult) == 0) {
     $Title = _('Customer Balances') . ' - ' . _('Problem Report');
     include 'includes/header.inc';
     prnMsg(_('The customer details listing has no clients to report on'), 'warn');
     echo '<br /><a href="' . $RootPath . '/index.php">' . _('Back to the menu') . '</a>';
     include 'includes/footer.inc';
     exit;
 }
 include 'includes/PDFDebtorBalsPageHeader.inc';
 $TotBal = 0;
 while ($DebtorBalances = DB_fetch_array($CustomerResult, $db)) {
     $Balance = $DebtorBalances['balance'] - $DebtorBalances['afterdatetrans'] + $DebtorBalances['afterdatediffonexch'];
     $FXBalance = $DebtorBalances['fxbalance'] - $DebtorBalances['fxafterdatetrans'];
     if (abs($Balance) > 0.008999999999999999 or ABS($FXBalance) > 0.008999999999999999) {
         $DisplayBalance = locale_number_format($DebtorBalances['balance'] - $DebtorBalances['afterdatetrans'], $DebtorBalances['decimalplaces']);
         $DisplayFXBalance = locale_number_format($DebtorBalances['fxbalance'] - $DebtorBalances['fxafterdatetrans'], $DebtorBalances['decimalplaces']);
         $TotBal += $Balance;
         $LeftOvers = $pdf->addTextWrap($Left_Margin + 3, $YPos, 220 - $Left_Margin, $FontSize, $DebtorBalances['debtorno'] . ' - ' . html_entity_decode($DebtorBalances['name'], ENT_QUOTES, 'UTF-8'), 'left');
         $LeftOvers = $pdf->addTextWrap(220, $YPos, 60, $FontSize, $DisplayBalance, 'right');
                echo '<tr ' . $FailureStyle . '><td>' . $ItemDetails['stockid'] . '</td><td>' . 'Failure' . '</td><td>';
                for ($i = 0; $i < sizeof($answer); $i++) {
                    echo 'Error no ' . $answer[$i] . ' - ' . $ErrorDescription[$answer[$i]] . '<br />';
                }
                echo '</td></tr>';
                $failures++;
            }
        }
        unset($ItemDetails);
    }
    echo '<tr><td>' . $successes . _(' records successfully imported') . '</td></tr>';
    echo '<tr><td>' . $failures . _(' records failed to import') . '</td></tr>';
    echo '</table>';
    fclose($fp);
} else {
    $sql = "select * from locations";
    $result = DB_query($sql);
    if (DB_num_rows($result) == 0) {
        prnMsg(_('No locations have been set up. At least one location should be set up first'), "error");
    } else {
        prnMsg(_('Select a csv file containing the details of the parts that you wish to import into webERP. ') . '<br />' . _('The first line must contain the field names that you wish to import. ') . '<a href ="Z_DescribeTable.php?table=stockmaster">' . _('The field names can be found here') . '</a>', 'info');
        echo '<form id="ItemForm" enctype="multipart/form-data" method="post" action="' . htmlspecialchars($_SERVER['PHP_SELF'], ENT_QUOTES, 'UTF-8') . '?' . SID . '">';
        echo '<div class="centre">';
        echo '<input type="hidden" name="FormID" value="' . $_SESSION['FormID'] . '" />';
        echo '<table><tr><td>' . _('File to import') . '</td>' . '<td><input type="file" id="ImportFile" name="ImportFile" /></td></tr></table>';
        echo '<div class="centre"><input type="submit" name="update" value="Process" /></div>';
        echo '</div>
              </form>';
    }
}
include 'includes/footer.inc';
     }
     closedir($handle);
 }
 if ($handle = opendir(".//includes")) {
     while (false !== ($file = readdir($handle))) {
         if (substr($file, 0, 1) != "." && !is_dir($file)) {
             $AvailableModules[$i] = $file;
             $i += 1;
         }
     }
     closedir($handle);
 }
 sort($AvailableModules);
 $NumberOfModules = sizeof($AvailableModules) - 1;
 if (!is_writable('./locale/' . $_SESSION['Language'])) {
     prnMsg(_('You do not have write access to the required files please contact your system administrator'), 'error');
 } else {
     echo '<br><table><tr><td>';
     echo '<form method="post" action=' . $_SERVER['PHP_SELF'] . '?' . SID . '>';
     echo '<table>';
     echo '<tr><td>' . _('Select the module to edit') . '</td>';
     echo '<td><select name="module">';
     for ($i = 0; $i < $NumberOfModules; $i++) {
         echo '<option>' . $AvailableModules[$i] . '</option>';
     }
     echo '</select></td>';
     echo '</tr></table>';
     echo '<br>';
     echo '<div class="centre">';
     echo '<input type="Submit" name="proceed" VALUE="' . _('Proceed') . '">&nbsp;&nbsp;';
     echo '<br><br><input type="Submit" name="ReMergePO" VALUE="' . _('Refresh messages with latest strings') . '">';
        $DbgMsg = _('The following SQL to insert the debtor transaction record was used');
        $Result = DB_query($SQL, $db, $ErrMsg, $DbgMsg, true);
        $DebtorTransID = DB_Last_Insert_ID($db, 'debtortrans', 'id');
        $SQL = 'INSERT INTO debtortranstaxes (debtortransid,
							taxauthid,
							taxamount)
				VALUES (' . $DebtorTransID . ',
					' . $TaxAuthID . ',
					' . $Tax['FXAmount'] / $CurrencyRate . ')';
        $ErrMsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('The debtor transaction taxes records could not be inserted because');
        $DbgMsg = _('The following SQL to insert the debtor transaction taxes record was used');
        $Result = DB_query($SQL, $db, $ErrMsg, $DbgMsg, true);
        $SQL = 'COMMIT';
        $Result = DB_query($SQL, $db);
        echo _('Invoice number') . ' ' . $InvoiceNo . ' ' . _('processed') . '<BR>';
        $EmailText .= "\n" . _('This recurring order was set to produce the invoice automatically on invoice number') . ' ' . $InvoiceNo;
    }
    /*end if the recurring order is set to auto invoice */
    if (IsEmailAddress($RecurrOrderRow['email'])) {
        $mail = new htmlMimeMail();
        $mail->setText($EmailText);
        $mail->setSubject(_('Recurring Order Created Advice'));
        $mail->setFrom($_SESSION['CompanyRecord']['coyname'] . "<" . $_SESSION['CompanyRecord']['email'] . ">");
        $result = $mail->send(array($RecurrOrderRow['email']));
        unset($mail);
    } else {
        prnMsg(_('No email advice was sent for this order because the location has no email contact defined with a valid email address'), 'warn');
    }
}
/*end while there are recurring orders due to have a new order created */
include 'includes/footer.inc';
Example #18
0
        $FontSize = 8;
        $pdf->setFont('', 'B');
        $LeftOvers = $pdf->addTextWrap($Left_Margin, $YPos, 200, $FontSize, $Sections[$Section]);
        $LeftOvers = $pdf->addTextWrap($Left_Margin + 250, $YPos, 100, $FontSize, locale_number_format($SectionBalance, $_SESSION['CompanyRecord']['decimalplaces']), 'right');
        $LeftOvers = $pdf->addTextWrap($Left_Margin + 350, $YPos, 100, $FontSize, locale_number_format($SectionBalanceLY, $_SESSION['CompanyRecord']['decimalplaces']), 'right');
        $YPos -= $line_height;
    }
    $YPos -= $line_height;
    $LeftOvers = $pdf->addTextWrap($Left_Margin, $YPos, 200, $FontSize, _('Check Total'));
    $LeftOvers = $pdf->addTextWrap($Left_Margin + 250, $YPos, 100, $FontSize, locale_number_format($CheckTotal, $_SESSION['CompanyRecord']['decimalplaces']), 'right');
    $LeftOvers = $pdf->addTextWrap($Left_Margin + 350, $YPos, 100, $FontSize, locale_number_format($LYCheckTotal, $_SESSION['CompanyRecord']['decimalplaces']), 'right');
    if ($ListCount == 0) {
        //UldisN
        $Title = _('Print Balance Sheet Error');
        include 'includes/header.inc';
        prnMsg(_('There were no entries to print out for the selections specified'));
        echo '<br /><a href="' . $RootPath . '/index.php">' . _('Back to the menu') . '</a>';
        include 'includes/footer.inc';
        exit;
    } else {
        $pdf->OutputD($_SESSION['DatabaseName'] . '_GL_Balance_Sheet_' . date('Y-m-d') . '.pdf');
        $pdf->__destruct();
    }
    exit;
} else {
    $ViewTopic = 'GeneralLedger';
    $BookMark = 'BalanceSheet';
    include 'includes/header.inc';
    echo '<form onSubmit="return VerifyForm(this);" method="post" action="' . htmlspecialchars($_SERVER['PHP_SELF'], ENT_QUOTES, 'UTF-8') . '">';
    echo '<input type="hidden" name="FormID" value="' . $_SESSION['FormID'] . '" />';
    echo '<input type="hidden" name="BalancePeriodEnd" value="' . $_POST['BalancePeriodEnd'] . '" />';
        $InputError = 1;
    }
    if ($_POST['CurrCode'] == '') {
        prnMsg(_('You must select a currency from the list'), 'error');
        echo '<br />';
        $InputError = 1;
    }
    $sql = "SELECT COUNT(*)\n\t\t\tFROM purchorderauth\n\t\t\tWHERE userid='" . $_POST['UserID'] . "'\n\t\tAND currabrev='" . $_POST['CurrCode'] . "'";
    $result = DB_query($sql, $db);
    $myrow = DB_fetch_array($result);
    if ($myrow[0] == 0 and $InputError == 0) {
        $sql = "INSERT INTO purchorderauth (\n\t\t\tuserid,\n\t\t\tcurrabrev,\n\t\t\tcancreate,\n\t\t\toffhold,\n\t\t\tauthlevel)\n\t\t\tVALUES(\n\t\t\t'" . $_POST['UserID'] . "',\n\t\t\t'" . $_POST['CurrCode'] . "',\n\t\t\t'" . $CanCreate . "',\n\t\t\t'" . $OffHold . "',\n\t\t\t'" . filter_currency_input($_POST['AuthLevel']) . "')";
        $ErrMsg = _('The authentication details cannot be inserted because');
        $Result = DB_query($sql, $db, $ErrMsg);
    } else {
        prnMsg(_('There already exists an entry for this user/currency combination'), 'error');
        echo '<br />';
    }
}
if (isset($_POST['Update'])) {
    if (isset($_POST['CanCreate']) and $_POST['CanCreate'] == 'on') {
        $CanCreate = 0;
    } else {
        $CanCreate = 1;
    }
    if (isset($_POST['OffHold']) and $_POST['OffHold'] == 'on') {
        $OffHold = 0;
    } else {
        $OffHold = 1;
    }
    $sql = "UPDATE purchorderauth SET\n\t\t\tcancreate='" . $CanCreate . "',\n\t\t\toffhold='" . $OffHold . "',\n\t\t\tauthlevel='" . filter_currency_input($_POST['AuthLevel']) . "'\n\t\tWHERE userid='" . $_POST['UserID'] . "'\n\t\tAND currabrev='" . $_POST['CurrCode'] . "'";
Example #20
0
			AND debtortrans.transno=' . $FromTransNo . '
			AND debtortrans.debtorno=debtorsmaster.debtorno
			AND debtortrans.debtorno=custbranch.debtorno
			AND debtortrans.branchcode=custbranch.branchcode
			AND custbranch.salesman=salesman.salesmancode';
            if ($_POST['PrintEDI'] == 'No') {
                $sql = $sql . ' AND debtorsmaster.ediinvoices=0';
            }
        }
        $result = DB_query($sql, $db, '', '', false, false);
        if (DB_error_no($db) != 0) {
            $title = _('Transaction Print Error Report');
            include 'includes/header.inc';
            prnMsg(_('There was a problem retrieving the invoice or credit note details for note number') . ' ' . $InvoiceToPrint . ' ' . _('from the database') . '. ' . _('To print an invoice, the sales order record, the customer transaction record and the branch record for the customer must not have been purged') . '. ' . _('To print a credit note only requires the customer, transaction, salesman and branch records be available'), 'error');
            if ($debug == 1) {
                prnMsg(_('The SQL used to get this information that failed was') . "<br>" . $sql, 'error');
            }
            include 'includes/footer.inc';
            exit;
        }
        if (DB_num_rows($result) == 1) {
            $myrow = DB_fetch_array($result);
            $ExchRate = $myrow['rate'];
            if ($InvOrCredit == 'Invoice') {
                $sql = 'SELECT stockmoves.stockid,
					stockmaster.description,
					-stockmoves.qty as quantity,
					stockmoves.discountpercent,
					((1 - stockmoves.discountpercent) * stockmoves.price * ' . $ExchRate . '* -stockmoves.qty) AS fxnet,
					(stockmoves.price * ' . $ExchRate . ') AS fxprice,
					stockmoves.narrative,
<?php

/* $Id: Z_UpdateChartDetailsBFwd.php 6941 2014-10-26 23:18:08Z daintree $*/
include 'includes/session.inc';
$Title = _('Recalculation of Brought Forward Balances in Chart Details Table');
include 'includes/header.inc';
echo '<form method="post" action="' . htmlspecialchars($_SERVER['PHP_SELF'], ENT_QUOTES, 'UTF-8') . '">';
echo '<div>';
echo '<input type="hidden" name="FormID" value="' . $_SESSION['FormID'] . '" />';
if ($_POST['FromPeriod'] > $_POST['ToPeriod']) {
    prnMsg(_('The selected period from is actually after the period to') . '. ' . _('Please re-select the reporting period'), 'error');
    unset($_POST['FromPeriod']);
    unset($_POST['ToPeriod']);
}
if (!isset($_POST['FromPeriod']) or !isset($_POST['ToPeriod'])) {
    /*Show a form to allow input of criteria for TB to show */
    echo '<table><tr><td>' . _('Select Period From') . ':</td><td><select name="FromPeriod">';
    $sql = "SELECT periodno, lastdate_in_period FROM periods ORDER BY periodno";
    $Periods = DB_query($sql);
    while ($myrow = DB_fetch_array($Periods, $db)) {
        echo '<option value="' . $myrow['periodno'] . '">' . MonthAndYearFromSQLDate($myrow['lastdate_in_period']) . '</option>';
    }
    echo '</select></td></tr>';
    $sql = "SELECT MAX(periodno) FROM periods";
    $MaxPrd = DB_query($sql);
    $MaxPrdrow = DB_fetch_row($MaxPrd);
    $DefaultToPeriod = (int) ($MaxPrdrow[0] - 1);
    echo '<tr><td>' . _('Select Period To') . ':</td><td><select name="ToPeriod">';
    $RetResult = DB_data_seek($Periods, 0);
    while ($myrow = DB_fetch_array($Periods, $db)) {
        if ($myrow['periodno'] == $DefaultToPeriod) {
//	$_SESSION['InvID'] = new InvoiceID;
$SQL = "SELECT supptrans.supplierno,\n\t\tsupptrans.suppreference,\n\t\tsupptrans.trandate,\n\t\tsupptrans.alloc,\n\t\tsuppliers.currcode\n\tFROM supptrans\n\tLEFT JOIN suppliers\n\tON supptrans.supplierno=suppliers.supplierid\n\tWHERE supptrans.id IN (SELECT suppallocs.transid_allocfrom\n\t\t\t\tFROM supptrans, suppallocs\n\t\t\t\tWHERE supptrans.supplierno = '" . $SuppID . "'\n\t\t\t\tAND supptrans.suppreference = '" . $InvID . "'\n\t\t\t\tAND supptrans.id = suppallocs.transid_allocto)";
/*
Might be a way of doing this query without a subquery

$SQL= "SELECT supptrans.supplierno,
		supptrans.suppreference,
		supptrans.trandate,
		supptrans.alloc
	FROM supptrans INNER JOIN suppallocs ON supptrans.id=suppallocs.transid_allocfrom
	WHERE supptrans.supplierno = '$SuppID'
	AND supptrans.suppreference = '$InvID'
*/
$Result = DB_query($SQL, $db);
if (DB_num_rows($Result) == 0) {
    prnMsg(_('There may be a problem retrieving the information. No data is returned'), 'warn');
    echo '<br /><a HREF ="javascript:history.back()">' . _('Go back') . '</a>';
    include 'includes/foooter.inc';
    exit;
}
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)) {
    	ie the page has called itself with some user input */
    if ($InputError != 1) {
        $sql = "INSERT INTO discountmatrix (salestype,\n\t\t\t\t\t\t\tdiscountcategory,\n\t\t\t\t\t\t\tquantitybreak,\n\t\t\t\t\t\t\tdiscountrate)\n\t\t\t\t\tVALUES('" . $_POST['SalesType'] . "',\n\t\t\t\t\t\t'" . $_POST['DiscountCategory'] . "',\n\t\t\t\t\t\t'" . filter_number_format($_POST['QuantityBreak']) . "',\n\t\t\t\t\t\t'" . filter_number_format($_POST['DiscountRate']) / 100 . "')";
        $result = DB_query($sql, $db);
        prnMsg(_('The discount matrix record has been added'), 'success');
        echo '<br />';
        unset($_POST['DiscountCategory']);
        unset($_POST['SalesType']);
        unset($_POST['QuantityBreak']);
        unset($_POST['DiscountRate']);
    }
} elseif (isset($_GET['Delete']) and $_GET['Delete'] == 'yes') {
    /*the link to delete a selected record was clicked instead of the submit button */
    $sql = "DELETE FROM discountmatrix\n\t\tWHERE discountcategory='" . $_GET['DiscountCategory'] . "'\n\t\tAND salestype='" . $_GET['SalesType'] . "'\n\t\tAND quantitybreak='" . $_GET['QuantityBreak'] . "'";
    $result = DB_query($sql, $db);
    prnMsg(_('The discount matrix record has been deleted'), 'success');
    echo '<br />';
}
echo '<form method="post" action="' . htmlspecialchars($_SERVER['PHP_SELF'], ENT_QUOTES, 'UTF-8') . '">';
echo '<div>';
echo '<input type="hidden" name="FormID" value="' . $_SESSION['FormID'] . '" />';
echo '<table class="selection">';
$sql = "SELECT typeabbrev,\n\t\tsales_type\n\t\tFROM salestypes";
$result = DB_query($sql, $db);
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>';
if (isset($_POST['amend']) or isset($_POST['Create'])) {
    // its a new manufacturer being added
    echo '<form method="post" action="' . htmlspecialchars($_SERVER['PHP_SELF'], ENT_QUOTES, 'UTF-8') . '">';
    echo '<input type="hidden" name="FormID" value="' . $_SESSION['FormID'] . '" />';
    echo '<input type="hidden" name="ManufacturerID" value="' . $ManufacturerID . '" />';
    echo '<table class="selection">';
    echo '<input type="hidden" name="New" value="Yes" />';
    echo '<tr><td>' . _('Manufacturer Name') . ':</td><td><input tabindex="1" type="text" name="ManufacturerName" size="42" maxlength="40" value="' . $_POST['ManufacturerName'] . '" /></td></tr>';
    echo '<tr><td>' . _('Address Line 1') . ':</td><td><input tabindex="2" type="text" name="Address1" size="42" maxlength="40" value="' . $_POST['Address1'] . '" /></td></tr>';
    echo '<tr><td>' . _('Address Line 2') . ':</td><td><input tabindex="3" type="text" name="Address2" size="42" maxlength="40" value="' . $_POST['Address2'] . '" /></td></tr>';
    echo '<tr><td>' . _('Address Line 3') . ':</td><td><input tabindex="4" type="text" name="Address3" size="42" maxlength="40" value="' . $_POST['Address3'] . '" /></td></tr>';
    echo '<tr><td>' . _('Address Line 4') . ':</td><td><input tabindex="5" type="text" name="Address4" size="42" maxlength="40" value="' . $_POST['Address4'] . '" /></td></tr>';
    echo '<tr><td>' . _('Address Line 5') . ':</td><td><input tabindex="6" type="text" name="Address5" size="42" maxlength="40" value="' . $_POST['Address5'] . '" /></td></tr>';
    echo '<tr><td>' . _('Address Line 6') . ':</td><td><input tabindex="7" type="text" name="Address6" size="42" maxlength="40" value="' . $_POST['Address6'] . '" /></td></tr>';
    echo '<tr><td>' . _('Contact Name') . ':</td><td><input tabindex="8" type="text" name="ContactName" size="13" maxlength="25" value="' . $_POST['ContactName'] . '" /></td></tr>';
    echo '<tr><td>' . _('Telephone') . ':</td><td><input tabindex="9" type="text" name="Telephone" size="13" maxlength="25" value="' . $_POST['Telephone'] . '" /></td></tr>';
    echo '<tr><td>' . _('Fax') . ':</td><td><input tabindex="10" type="text" name="Fax" size="13" maxlength="25" value="' . $_POST['Fax'] . '" /></td></tr>';
    echo '<tr><td>' . _('Email') . ':</td><td><input tabindex="11" type="text" name="Email" size="55" maxlength="55" value="' . $_POST['Email'] . '" /></td></tr>';
}
if (isset($_POST['Create'])) {
    echo '</table><br /><div class="centre"><button tabindex="12" type="submit" name="submit">' . _('Insert New Manufacturer') . '</button></div><br />';
    echo '</form>';
} else {
    if (isset($_POST['amend'])) {
        echo '</table><br /><div class="centre"><button tabindex="13" type="submit" name="update">' . _('Update Manufacturer') . '</button><br />';
        prnMsg(_('There is no second warning if you hit the delete button below') . '. ' . _('However checks will be made to ensure there are no suppliers are using this manufacturer before the deletion is processed'), 'warn');
        echo '<br /><button tabindex="14" type="submit" name="delete" onclick="return confirm("' . _('Are you sure you wish to delete this manufacturer?') . '");" />' . _('Delete Manufacturer') . '</button></form></div>';
        echo '</form>';
    }
}
include 'includes/footer.inc';
        }
    }
    echo '</select></td></tr>';
    echo '</table>';
    echo '<div class="centre"><input type="submit" name="EnterAdjustment" value="' . _('Show Requests') . '" /></div>';
    echo '</form>';
    include 'includes/footer.inc';
    exit;
}
/* Retrieve the requisition header information
 */
if (isset($_POST['Location'])) {
    $sql = "SELECT stockrequest.dispatchid,\n\t\t\tlocations.locationname,\n\t\t\tstockrequest.despatchdate,\n\t\t\tstockrequest.narrative,\n\t\t\tdepartments.description,\n\t\t\twww_users.realname,\n\t\t\twww_users.email\n\t\tFROM stockrequest\n\t\tLEFT JOIN departments\n\t\t\tON stockrequest.departmentid=departments.departmentid\n\t\tLEFT JOIN locations\n\t\t\tON stockrequest.loccode=locations.loccode\n\t\tLEFT JOIN www_users\n\t\t\tON www_users.userid=departments.authoriser\n\tWHERE stockrequest.authorised=1\n\t\tAND stockrequest.closed=0\n\t\tAND stockrequest.loccode='" . $_POST['Location'] . "'";
    $result = DB_query($sql, $db);
    if (DB_num_rows($result) == 0) {
        prnMsg(_('There are no outstanding authorised requests for this location'), 'info');
        echo '<br />';
        echo '<div class="centre"><a href="' . htmlspecialchars($_SERVER['PHP_SELF'], ENT_QUOTES, 'UTF-8') . '">' . _('Select another location') . '</a></div>';
        include 'includes/footer.inc';
        exit;
    }
    echo '<form onSubmit="return VerifyForm(this);" method="post" class="noPrint" action="' . htmlspecialchars($_SERVER['PHP_SELF'], ENT_QUOTES, 'UTF-8') . '">';
    echo '<div>';
    echo '<input type="hidden" name="FormID" value="' . $_SESSION['FormID'] . '" />';
    echo '<table class="selection">
			<tr>
				<th>' . _('Request Number') . '</th>
				<th>' . _('Department') . '</th>
				<th>' . _('Location Of Stock') . '</th>
				<th>' . _('Requested Date') . '</th>
				<th>' . _('Narrative') . '</th>
        foreach ($_SESSION['SuppTrans']->Assets as $AssetAddition) {
            /*Asset additions need to have
             * 	1. A fixed asset transaction inserted for the cost
             * 	2. A general ledger transaction to fixed asset cost account if creditors linked - done in the GLCreditors Link above
             * 	3. The fixedasset table cost updated by the negative addition
             */
            /* First the fixed asset transaction */
            $SQL = "INSERT INTO fixedassettrans (assetid,\n\t\t\t\t\t\t\t\t\t\t\t\ttranstype,\n\t\t\t\t\t\t\t\t\t\t\t\ttransno,\n\t\t\t\t\t\t\t\t\t\t\t\ttransdate,\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\tinputdate,\n\t\t\t\t\t\t\t\t\t\t\t\tfixedassettranstype,\n\t\t\t\t\t\t\t\t\t\t\t\tamount)\n\t\t\t\t\t\t\tVALUES ('" . $AssetAddition->AssetID . "',\n\t\t\t\t\t\t\t\t\t\t\t21,\n\t\t\t\t\t\t\t\t\t\t\t'" . $CreditNoteNo . "',\n\t\t\t\t\t\t\t\t\t\t\t'" . $SQLCreditNoteDate . "',\n\t\t\t\t\t\t\t\t\t\t\t'" . $PeriodNo . "',\n\t\t\t\t\t\t\t\t\t\t\t'" . Date('Y-m-d') . "',\n\t\t\t\t\t\t\t\t\t\t\t'cost',\n\t\t\t\t\t\t\t\t\t\t\t'" . -$AssetAddition->Amount / $_SESSION['SuppTrans']->ExRate . "')";
            $ErrMsg = _('CRITICAL ERROR! NOTE DOWN THIS ERROR AND SEEK ASSISTANCE The fixed asset transaction could not be inserted because');
            $DbgMsg = _('The following SQL to insert the fixed asset transaction record was used');
            $Result = DB_query($SQL, $db, $ErrMsg, $DbgMsg, true);
            /*Now update the asset cost in fixedassets table */
            $SQL = "UPDATE fixedassets SET cost = cost - " . $AssetAddition->Amount / $_SESSION['SuppTrans']->ExRate . "\n\t\t\t\t\tWHERE assetid = '" . $AssetAddition->AssetID . "'";
            $ErrMsg = _('CRITICAL ERROR! NOTE DOWN THIS ERROR AND SEEK ASSISTANCE. The fixed asset cost  was not able to be updated because:');
            $DbgMsg = _('The following SQL was used to attempt the update of the asset cost:');
            $Result = DB_query($SQL, $db, $ErrMsg, $DbgMsg, true);
        }
        //end of non-gl fixed asset stuff
        DB_Txn_Commit($db);
        prnMsg(_('Supplier credit note number') . ' ' . $CreditNoteNo . ' ' . _('has been processed'), 'success');
        echo '<br /><div class="centre"><a href="' . $rootpath . '/SupplierCredit.php?&SupplierID=' . $_SESSION['SuppTrans']->SupplierID . '">' . _('Enter another Credit Note for this Supplier') . '</a></div>';
        unset($_SESSION['SuppTrans']->GRNs);
        unset($_SESSION['SuppTrans']->Shipts);
        unset($_SESSION['SuppTrans']->GLCodes);
        unset($_SESSION['SuppTrans']);
    }
}
/*end of process credit note */
echo '</div>
      </form>';
include 'includes/footer.inc';
Example #27
0
// if this is the first time displaying the form, there will only be a picture with the OldStockID name, if any, else there can be a $_POST['OldStockID'].'-TEMP'. '.jpg' file if one was uploaded
if (empty($_POST['StockID']) or $_POST['StockID'] == $_POST['OldStockID']) {
    $tempid = $_POST['OldStockID'] . '-TEMP';
} else {
    $tempid = $_POST['StockID'];
}
if (function_exists('imagecreatefromjpg') && isset($tempfile)) {
    $StockImgLink = '<img src="GetStockImage.php?automake=1&amp;textcolor=FFFFFF&amp;bgcolor=CCCCCC' . '&amp;StockID=' . urlencode($tempid) . '&amp;text=' . '&amp;width=100' . '&amp;height=100' . '" alt="" />';
} else {
    if (!empty($tempid) and file_exists($_SESSION['part_pics_dir'] . '/' . $tempid . '.jpg')) {
        $StockImgLink = '<img src="' . $_SESSION['part_pics_dir'] . '/' . $tempid . '.jpg" height="100" width="100" />';
        if (isset($_POST['ClearImage'])) {
            //workaround for many variations of permission issues that could cause unlink fail
            @unlink($_SESSION['part_pics_dir'] . '/' . $tempid . '.jpg');
            if (is_file($_SESSION['part_pics_dir'] . '/' . $tempid . '.jpg')) {
                prnMsg(_('You do not have access to delete this item image file.'), 'error');
            } else {
                $StockImgLink = _('No Image');
            }
        }
    } elseif (!empty($tempid) and !file_exists($_SESSION['part_pics_dir'] . '/' . $tempid . '.jpg') and file_exists($_SESSION['part_pics_dir'] . '/' . $_POST['OldStockID'] . '.jpg')) {
        if (!copy($_SESSION['part_pics_dir'] . '/' . $_POST['OldStockID'] . '.jpg', $_SESSION['part_pics_dir'] . '/' . $_POST['OldStockID'] . '-TEMP' . '.jpg')) {
            $StockImgLink = _('No Image');
        } else {
            $StockImgLink = '<img src="' . $_SESSION['part_pics_dir'] . '/' . $_POST['OldStockID'] . '-TEMP' . '.jpg" height="100" width="100" />';
        }
    } else {
        $StockImgLink = _('No Image');
    }
}
if ($StockImgLink != _('No Image')) {
        unset($_POST['Lower3']);
        unset($_POST['Upper3']);
        unset($_POST['Lower4']);
        unset($_POST['Upper4']);
    }
} elseif (isset($_GET['delete'])) {
    //the link to delete a selected record was clicked instead of the submit button
    $sql = "DELETE FROM reportcolumns WHERE reportid='" . $SelectedReport . "'";
    $ErrMsg = _('The deletion of the report column failed because');
    $DbgMsg = _('The SQL used to delete the report column was');
    $result = DB_query($sql, $ErrMsg, $DbgMsg);
    $sql = "DELETE FROM reportheaders WHERE reportid='" . $SelectedReport . "'";
    $ErrMsg = _('The deletion of the report heading failed because');
    $DbgMsg = _('The SQL used to delete the report headers was');
    $result = DB_query($sql, $ErrMsg, $DbgMsg);
    prnMsg(_('Report Deleted'), 'info');
    unset($SelectedReport);
    include 'includes/footer.inc';
    exit;
}
if (!isset($SelectedReport)) {
    /* It could still be the second time the page has been run and a record has been selected for modification - SelectedReport will exist because it was sent with the new call. If its the first time the page has been displayed with no parameters
    then none of the above are true and the list of Reports will be displayed with
    links to delete or edit each. These will call the same page again and allow update/input
    or deletion of the records*/
    $result = DB_query("SELECT reportid, reportheading FROM reportheaders ORDER BY reportid");
    echo '<table class="selection">';
    echo '<tr>
			<th>' . _('Report No') . '</th>
			<th>' . _('Report Title') . '</th>
          </tr>';
        }
        foreach ($TaxTotals as $TaxAuthID => $TaxAmount) {
            if ($TaxAmount != 0) {
                $SQL = "INSERT INTO gltrans (\r\n\t\t\t\t\t\ttype,\r\n\t\t\t\t\t\ttypeno,\r\n\t\t\t\t\t\ttrandate,\r\n\t\t\t\t\t\tperiodno,\r\n\t\t\t\t\t\taccount,\r\n\t\t\t\t\t\tnarrative,\r\n\t\t\t\t\t\tamount\r\n\t\t\t\t\t\t)\r\n\t\t\t\t\tVALUES (\r\n\t\t\t\t\t\t10,\r\n\t\t\t\t\t\t" . $InvoiceNo . ",\r\n\t\t\t\t\t\t'" . $DefaultDispatchDate . "',\r\n\t\t\t\t\t\t" . $PeriodNo . ",\r\n\t\t\t\t\t\t" . $TaxGLCodes[$TaxAuthID] . ",\r\n\t\t\t\t\t\t'" . $_SESSION['Items']->DebtorNo . "',\r\n\t\t\t\t\t\t" . -$TaxAmount / $_SESSION['CurrencyRate'] . "\r\n\t\t\t\t\t)";
                $ErrMsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('The tax GL posting could not be inserted because');
                $DbgMsg = _('The following SQL to insert the GLTrans record was used');
                $Result = DB_query($SQL, $db, $ErrMsg, $DbgMsg, true);
            }
        }
    }
    /*end of if Sales and GL integrated */
    DB_Txn_Commit($db);
    unset($_SESSION['Items']->LineItems);
    unset($_SESSION['Items']);
    unset($_SESSION['ProcessingOrder']);
    echo prnMsg(_('Invoice number') . ' ' . $InvoiceNo . ' ' . _('processed'), 'success');
    echo '<br><div class="centre">';
    if ($_SESSION['InvoicePortraitFormat'] == 0) {
        echo '<img src="' . $rootpath . '/css/' . $theme . '/images/printer.png" title="' . _('Print') . '" alt="">' . ' ' . '<a target="_blank" href="' . $rootpath . '/PrintCustTrans.php?' . SID . 'FromTransNo=' . $InvoiceNo . '&InvOrCredit=Invoice&PrintPDF=True">' . _('Print this invoice') . ' (' . _('Landscape') . ')</a><br><br>';
    } else {
        echo '<img src="' . $rootpath . '/css/' . $theme . '/images/printer.png" title="' . _('Print') . '" alt="">' . ' ' . '<a target="_blank" href="' . $rootpath . '/PrintCustTransPortrait.php?' . SID . 'FromTransNo=' . $InvoiceNo . '&InvOrCredit=Invoice&PrintPDF=True">' . _('Print this invoice') . ' (' . _('Portrait') . ')</a><br><br>';
    }
    echo '<a href="' . $rootpath . '/SelectSalesOrder.php?' . SID . '">' . _('Select another order for invoicing') . '</a><br><br>';
    echo '<a href="' . $rootpath . '/SelectOrderItems.php?' . SID . 'NewOrder=Yes">' . _('Sales Order Entry') . '</a></div><br>';
    /*end of process invoice */
} else {
    /*Process Invoice not set so allow input of invoice data */
    if (!isset($_POST['Consignment'])) {
        $_POST['Consignment'] = '';
    }
    if (!isset($_POST['InvoiceText'])) {
    if (DB_num_rows($result) > 0) {
        prnMsg(_('Cannot delete this stock category because stock items have been created using this stock category') . '<br /> ' . _('There are') . ' ' . $myrow[0] . ' ' . _('items referring to this stock category code'), 'warn');
    } else {
        $sql = "SELECT stkcat FROM salesglpostings WHERE stkcat='" . $SelectedCategory . "'";
        $result = DB_query($sql);
        if (DB_num_rows($result) > 0) {
            prnMsg(_('Cannot delete this stock category because it is used by the sales') . ' - ' . _('GL posting interface') . '. ' . _('Delete any records in the Sales GL Interface set up using this stock category first'), 'warn');
        } else {
            $sql = "SELECT stkcat FROM cogsglpostings WHERE stkcat='" . $SelectedCategory . "'";
            $result = DB_query($sql);
            if (DB_num_rows($result) > 0) {
                prnMsg(_('Cannot delete this stock category because it is used by the cost of sales') . ' - ' . _('GL posting interface') . '. ' . _('Delete any records in the Cost of Sales GL Interface set up using this stock category first'), 'warn');
            } else {
                $sql = "DELETE FROM stockcategory WHERE categoryid='" . $SelectedCategory . "'";
                $result = DB_query($sql);
                prnMsg(_('The stock category') . ' ' . $SelectedCategory . ' ' . _('has been deleted') . ' !', 'success');
                unset($SelectedCategory);
            }
        }
    }
    //end if stock category used in debtor transactions
}
if (!isset($SelectedCategory)) {
    /* It could still be the second time the page has been run and a record has been selected for modification - SelectedCategory will exist because it was sent with the new call. If its the first time the page has been displayed with no parameters
    then none of the above are true and the list of stock categorys will be displayed with
    links to delete or edit each. These will call the same page again and allow update/input
    or deletion of the records*/
    $sql = "SELECT\tcategoryid,\n\t\t\t\t\tcategorydescription,\n\t\t\t\t\tstocktype,\n\t\t\t\t\tdefaulttaxcatid,\n\t\t\t\t\tstockact,\n\t\t\t\t\tadjglact,\n\t\t\t\t\tissueglact,\n\t\t\t\t\tpurchpricevaract,\n\t\t\t\t\tmaterialuseagevarac,\n\t\t\t\t\twipact\n\t\t\t\tFROM stockcategory";
    $result = DB_query($sql);
    echo '<br />
		<table class="selection">