Пример #1
0
function GetSalesTypeDetails($salestype, $user, $password)
{
    $Errors = array();
    $db = db($user, $password);
    if (gettype($db) == 'integer') {
        $Errors[0] = NoAuthorisation;
        return $Errors;
    }
    $Errors = VerifySalesType($salestype, sizeof($Errors), $Errors, $db);
    if (sizeof($Errors) == 0) {
        $sql = 'SELECT * FROM salestypes WHERE typeabbrev="' . $salestype . '"';
        $result = DB_query($sql, $db);
        $Errors[0] = 0;
        $Errors[1] = DB_fetch_array($result);
        return $Errors;
    } else {
        return $Errors;
    }
}
Пример #2
0
function ModifyCustomer($CustomerDetails, $user, $password)
{
    $Errors = array();
    $db = db($user, $password);
    if (gettype($db) == 'integer') {
        $Errors[0] = NoAuthorisation;
        return $Errors;
    }
    foreach ($CustomerDetails as $key => $value) {
        $CustomerDetails[$key] = DB_escape_string($value);
    }
    if (!isset($CustomerDetails['debtorno'])) {
        $Errors[sizeof($Errors)] = NoDebtorNumber;
        return $Errors;
    }
    $Errors = VerifyDebtorExists($CustomerDetails['debtorno'], sizeof($Errors), $Errors, $db);
    if (in_array(DebtorDoesntExist, $Errors)) {
        return $Errors;
    }
    if (isset($CustomerDetails['name'])) {
        $Errors = VerifyDebtorName($CustomerDetails['name'], sizeof($Errors), $Errors);
    }
    if (isset($CustomerDetails['address1'])) {
        $Errors = VerifyAddressLine($CustomerDetails['address1'], 40, sizeof($Errors), $Errors);
    }
    if (isset($CustomerDetails['address2'])) {
        $Errors = VerifyAddressLine($CustomerDetails['address2'], 40, sizeof($Errors), $Errors);
    }
    if (isset($CustomerDetails['address3'])) {
        $Errors = VerifyAddressLine($CustomerDetails['address3'], 40, sizeof($Errors), $Errors);
    }
    if (isset($CustomerDetails['address4'])) {
        $Errors = VerifyAddressLine($CustomerDetails['address4'], 50, sizeof($Errors), $Errors);
    }
    if (isset($CustomerDetails['address5'])) {
        $Errors = VerifyAddressLine($CustomerDetails['address5'], 20, sizeof($Errors), $Errors);
    }
    if (isset($CustomerDetails['address6'])) {
        $Errors = VerifyAddressLine($CustomerDetails['address6'], 15, sizeof($Errors), $Errors);
    }
    if (isset($CustomerDetails['currcode'])) {
        $Errors = VerifyCurrencyCode($CustomerDetails['currcode'], sizeof($Errors), $Errors, $db);
    }
    if (isset($CustomerDetails['salestype'])) {
        $Errors = VerifySalesType($CustomerDetails['salestype'], sizeof($Errors), $Errors, $db);
    }
    if (isset($CustomerDetails['clientsince'])) {
        $Errors = VerifyClientSince($CustomerDetails['clientsince'], sizeof($Errors), $Errors);
    }
    if (isset($CustomerDetails['holdreason'])) {
        $Errors = VerifyHoldReason($CustomerDetails['holdreason'], sizeof($Errors), $Errors, $db);
    }
    if (isset($CustomerDetails['paymentterms'])) {
        $Errors = VerifyPaymentTerms($CustomerDetails['paymentterms'], sizeof($Errors), $Errors, $db);
    }
    if (isset($CustomerDetails['discount'])) {
        $Errors = VerifyDiscount($CustomerDetails['discount'], sizeof($Errors), $Errors);
    }
    if (isset($CustomerDetails['pymtdiscount'])) {
        $Errors = VerifyPymtDiscount($CustomerDetails['pymtdiscount'], sizeof($Errors), $Errors);
    }
    if (isset($CustomerDetails['lastpaid'])) {
        $Errors = VerifyLastPaid($CustomerDetails['lastpaid'], sizeof($Errors), $Errors);
    }
    if (isset($CustomerDetails['lastpaiddate'])) {
        $Errors = VerifyLastPaidDate($CustomerDetails['lastpaiddate'], sizeof($Errors), $Errors);
    }
    if (isset($CustomerDetails['creditlimit'])) {
        $Errors = VerifyCreditLimit($CustomerDetails['creditlimit'], sizeof($Errors), $Errors);
    }
    if (isset($CustomerDetails['invaddrbranch'])) {
        $Errors = VerifyInvAddrBranch($CustomerDetails['invaddrbranch'], sizeof($Errors), $Errors);
    }
    if (isset($CustomerDetails['discountcode'])) {
        $Errors = VerifyDiscountCode($CustomerDetails['discountcode'], sizeof($Errors), $Errors);
    }
    if (isset($CustomerDetails['ediinvoices'])) {
        $Errors = VerifyEDIInvoices($CustomerDetails['ediinvoices'], sizeof($Errors), $Errors);
    }
    if (isset($CustomerDetails['ediorders'])) {
        $Errors = VerifyEDIOrders($CustomerDetails['ediorders'], sizeof($Errors), $Errors);
    }
    if (isset($CustomerDetails['edireference'])) {
        $Errors = VerifyEDIReference($CustomerDetails['edireference'], sizeof($Errors), $Errors);
    }
    if (isset($CustomerDetails['editransport'])) {
        $Errors = VerifyEDITransport($CustomerDetails['editransport'], sizeof($Errors), $Errors);
    }
    if (isset($CustomerDetails['ediserveruser'])) {
        $Errors = VerifyEDIServerUser($CustomerDetails['ediserveruser'], sizeof($Errors), $Errors);
    }
    if (isset($CustomerDetails['ediserverpwd'])) {
        $Errors = VerifyEDIServerPassword($CustomerDetails['ediserverpwd'], sizeof($Errors), $Errors);
    }
    if (isset($CustomerDetails['taxref'])) {
        $Errors = VerifyTaxRef($CustomerDetails['taxref'], sizeof($Errors), $Errors);
    }
    if (isset($CustomerDetails['customerpoline'])) {
        $Errors = VerifyCustomerPOLine($CustomerDetails['customerpoline'], sizeof($Errors), $Errors);
    }
    if (isset($CustomerDetails['typeid'])) {
        $Errors = VerifyCustomerType($CustomerDetails['typeid'], sizeof($Errors), $Errors, $db);
    }
    $sql = "UPDATE debtorsmaster SET ";
    foreach ($CustomerDetails as $key => $value) {
        $sql .= $key . '="' . $value . '", ';
    }
    $sql = mb_substr($sql, 0, -2) . " WHERE debtorno='" . $CustomerDetails['debtorno'] . "'";
    if (sizeof($Errors) == 0) {
        $result = DB_Query($sql, $db);
        if (DB_error_no($db) != 0) {
            $Errors[0] = DatabaseUpdateFailed;
        } else {
            $Errors[0] = 0;
        }
    }
    return $Errors;
}
Пример #3
0
function GetStockPrice($StockID, $Currency, $SalesType, $user, $password)
{
    $Errors = array();
    $db = db($user, $password);
    if (gettype($db) == 'integer') {
        $Errors[0] = NoAuthorisation;
        return $Errors;
    }
    $Errors = VerifyStockCodeExists($StockID, sizeof($Errors), $Errors, $db);
    $Errors = VerifyCurrencyCode($Currency, sizeof($Errors), $Errors, $db);
    $Errors = VerifySalesType($SalesType, sizeof($Errors), $Errors, $db);
    if (sizeof($Errors) != 0) {
        return $Errors;
    }
    $sql = "SELECT COUNT(*) FROM prices\n\t\t\t\t WHERE stockid='" . $StockID . "'\n\t\t\t\t AND typeabbrev='" . $SalesType . "'\n\t\t\t\t AND currabrev='" . $Currency . "'\n\t\t\t\t AND startdate<='" . Date('Y-m-d') . "'\n\t\t\t\t AND (enddate>'" . Date('Y-m-d') . "' OR enddate='0000-00-00')";
    $result = DB_Query($sql, $db);
    $myrow = DB_fetch_row($result);
    if ($myrow[0] == 0) {
        $Errors[0] = NoPricesSetup;
        return $Errors;
    } else {
        $sql = "SELECT price FROM prices\n\t\t\t\t\t\t\tWHERE stockid='" . $StockID . "'\n\t\t\t\t\t\t\t AND typeabbrev='" . $SalesType . "'\n\t\t\t\t\t\t\t AND currabrev='" . $Currency . "'\n\t\t\t\t\t\t\t AND startdate<='" . Date('Y-m-d') . "'\n\t\t\t\t\t\t\t AND (enddate>'" . Date('Y-m-d') . "' OR enddate='0000-00-00')";
    }
    $result = DB_Query($sql, $db);
    $myrow = DB_fetch_row($result);
    $Errors[0] = 0;
    $Errors[1] = $myrow;
    return $Errors;
}
Пример #4
0
function GetStockPrice($StockID, $Currency, $SalesType, $user, $password)
{
    $Errors = array();
    $db = db($user, $password);
    if (gettype($db) == 'integer') {
        $Errors[0] = NoAuthorisation;
        return $Errors;
    }
    $Errors = VerifyStockCodeExists($StockID, sizeof($Errors), $Errors, $db);
    $Errors = VerifyCurrencyCode($Currency, sizeof($Errors), $Errors, $db);
    $Errors = VerifySalesType($SalesType, sizeof($Errors), $Errors, $db);
    if (sizeof($Errors) != 0) {
        return $Errors;
    }
    $sql = 'SELECT COUNT(*) FROM prices
				 WHERE stockid="' . $StockID . '"
				 and typeabbrev="' . $SalesType . '"
				 and currabrev="' . $Currency . '"';
    $result = DB_Query($sql, $db);
    $myrow = DB_fetch_row($result);
    if ($myrow[0] == 0) {
        $Errors[0] = NoPricesSetup;
        return $Errors;
    } else {
        $sql = 'SELECT price FROM prices WHERE stockid="' . $StockID . '"
				 and typeabbrev="' . $SalesType . '"
				 and currabrev="' . $Currency . '"';
    }
    $result = DB_Query($sql, $db);
    $myrow = DB_fetch_row($result);
    $Errors[0] = 0;
    $Errors[1] = $myrow;
    return $Errors;
}