$OldResult = DB_query($sql, $db, $ErrMsg);
    $OldRow = DB_fetch_array($OldResult);
    $_POST['QOH'] = $OldRow['totalqoh'];
    $_POST['OldMaterialCost'] = $OldRow['materialcost'];
    if ($OldRow['mbflag'] == 'M') {
        $_POST['OldLabourCost'] = $OldRow['labourcost'];
        $_POST['OldOverheadCost'] = $OldRow['overheadcost'];
    } else {
        $_POST['OldLabourCost'] = 0;
        $_POST['OldOverheadCost'] = 0;
        $_POST['LabourCost'] = 0;
        $_POST['OverheadCost'] = 0;
    }
    DB_free_result($OldResult);
    $OldCost = filter_currency_input($_POST['OldMaterialCost'] + $_POST['OldLabourCost'] + $_POST['OldOverheadCost']);
    $NewCost = filter_currency_input($_POST['MaterialCost'] + $_POST['LabourCost'] + $_POST['OverheadCost']);
    $result = DB_query("SELECT stockid FROM stockmaster WHERE stockid='" . $StockID . "'", $db);
    if (DB_num_rows($result) == 0) {
        prnMsg(_('The entered item code does not exist'), 'error', _('Non-existent Item'));
    } elseif ($OldCost != $NewCost) {
        $Result = DB_Txn_Begin($db);
        ItemCostUpdateGL($db, $StockID, $NewCost, $OldCost, $_POST['QOH']);
        $SQL = "UPDATE stockmaster SET materialcost='" . $_POST['MaterialCost'] . "',\n\t\t\t\t\t\t\t\t\t\tlabourcost='" . $_POST['LabourCost'] . "',\n\t\t\t\t\t\t\t\t\t\toverheadcost='" . $_POST['OverheadCost'] . "',\n\t\t\t\t\t\t\t\t\t\tlastcost='" . $OldCost . "',\n\t\t\t\t\t\t\t\t\t\tlastcurcostdate='" . Date('Y-m-d') . "'\n\t\t\t\t\t\t\t\t\tWHERE stockid='" . $StockID . "'";
        $ErrMsg = _('The cost details for the stock item could not be updated because');
        $DbgMsg = _('The SQL that failed was');
        $Result = DB_query($SQL, $db, $ErrMsg, $DbgMsg, true);
        $Result = DB_Txn_Commit($db);
        UpdateCost($db, $StockID);
        //Update any affected BOMs
    }
}
     if ($QuantityAlreadyDelivered == 0) {
         $_SESSION['Items' . $identifier]->remove_from_cart($_GET['Delete'], 'Yes');
         /*Do update DB */
     } else {
         $_SESSION['Items' . $identifier]->LineItems[$_GET['Delete']]->Quantity = $QuantityAlreadyDelivered;
     }
 }
 $AlreadyWarnedAboutCredit = false;
 foreach ($_SESSION['Items' . $identifier]->LineItems as $OrderLine) {
     if (isset($_POST['Quantity_' . $OrderLine->LineNumber])) {
         if (!isset($PropertiesArray[$OrderLine->LineNumber])) {
             $PropertiesArray[$OrderLine->LineNumber] = '';
         }
         $Quantity = filter_number_input($_POST['Quantity_' . $OrderLine->LineNumber]);
         if (ABS($OrderLine->Price - $_POST['Price_' . $OrderLine->LineNumber]) > 0.01) {
             $Price = filter_currency_input($_POST['Price_' . $OrderLine->LineNumber]);
             $_POST['GPPercent_' . $OrderLine->LineNumber] = ($Price * (1 - $_POST['Discount_' . $OrderLine->LineNumber] / 100) - $OrderLine->StandardCost * $ExRate) / ($Price * (1 - $_POST['Discount_' . $OrderLine->LineNumber]) / 100);
         } elseif (ABS($OrderLine->GPPercent - $_POST['GPPercent_' . $OrderLine->LineNumber]) >= 0.01) {
             //then do a recalculation of the price at this new GP Percentage
             $Price = $OrderLine->StandardCost * $ExRate / (1 - ($_POST['GPPercent_' . $OrderLine->LineNumber] + $_POST['Discount_' . $OrderLine->LineNumber]) / 100);
         } else {
             $Price = $_POST['Price_' . $OrderLine->LineNumber];
         }
         $DiscountPercentage = $_POST['Discount_' . $OrderLine->LineNumber];
         if ($_SESSION['AllowOrderLineItemNarrative'] == 1) {
             $Narrative = $_POST['Narrative_' . $OrderLine->LineNumber];
         } else {
             $Narrative = '';
         }
         if (!isset($OrderLine->DiscountPercent)) {
             $OrderLine->DiscountPercent = 0;
 }
 if (Date1GreaterThanDate2($_POST['StartDate'], $_POST['EndDate']) and $_POST['EndDate'] != '') {
     $InputError = 1;
     $msg = _('The end date is expected to be after the start date, enter an end date after the start date for this price');
 }
 if (Date1GreaterThanDate2(Date($_SESSION['DefaultDateFormat']), $_POST['EndDate']) and $_POST['EndDate'] != '') {
     $InputError = 1;
     $msg = _('The end date is expected to be after today. There is no point entering a new price where the effective date is before today!');
 }
 if (isset($_POST['Editing']) and $_POST['Editing'] == 'Yes' and strlen($Item) > 1 and $InputError != 1) {
     //editing an existing price
     $sql = "UPDATE prices SET typeabbrev='" . $SalesType . "',\n\t\t                        currabrev='" . $CurrCode . "',\n\t\t\t\t\t\t\t\tprice='" . filter_currency_input($_POST['Price']) . "',\n\t\t\t\t\t\t\t\tunits='" . $_POST['Units'] . "',\n\t\t\t\t\t\t\t\tconversionfactor='" . filter_number_input($_POST['ConversionFactor']) . "',\n\t\t\t\t\t\t\t\tdecimalplaces='" . round($_POST['DecimalPlaces'], 0) . "',\n\t\t\t\t\t\t\t\tbranchcode='" . $_POST['Branch'] . "',\n\t\t\t\t\t\t\t\tstartdate='" . FormatDateForSQL($_POST['StartDate']) . "',\n\t\t\t\t\t\t\t\tenddate='" . FormatDateForSQL($_POST['EndDate']) . "'\n\t\t\t\tWHERE prices.stockid='" . $Item . "'\n\t\t\t\tAND prices.typeabbrev='" . $SalesType . "'\n\t\t\t\tAND prices.currabrev='" . $CurrCode . "'\n\t\t\t\tAND prices.startdate='" . $_POST['OldStartDate'] . "'\n\t\t\t\tAND prices.enddate='" . $_POST['OldEndDate'] . "'\n\t\t\t\tAND prices.debtorno='" . $_SESSION['CustomerID'] . "'";
     $msg = _('Price Updated');
 } elseif ($InputError != 1) {
     /*Selected price is null cos no item selected on first time round so must be adding a	record must be submitting new entries in the new price form */
     $sql = "INSERT INTO prices (stockid,\n\t\t                            typeabbrev,\n\t\t\t\t\t\t\t\t\tcurrabrev,\n\t\t\t\t\t\t\t\t\tdebtorno,\n\t\t\t\t\t\t\t\t\tprice,\n\t\t\t\t\t\t\t\t\tunits,\n\t\t\t\t\t\t\t\t\tconversionfactor,\n\t\t\t\t\t\t\t\t\tdecimalplaces,\n\t\t\t\t\t\t\t\t\tbranchcode,\n\t\t\t\t\t\t\t\t\tstartdate,\n\t\t\t\t\t\t\t\t\tenddate)\n\t\t\t\t\t\t\tVALUES (\n\t\t\t\t\t\t\t\t\t'" . $Item . "',\n\t\t\t\t\t\t\t\t\t'" . $SalesType . "',\n\t\t\t\t\t\t\t\t\t'" . $CurrCode . "',\n\t\t\t\t\t\t\t\t\t'" . $_SESSION['CustomerID'] . "',\n\t\t\t\t\t\t\t\t\t'" . filter_currency_input($_POST['Price']) . "',\n\t\t\t\t\t\t\t\t\t'" . $_POST['Units'] . "',\n\t\t\t\t\t\t\t\t\t'" . filter_number_input($_POST['ConversionFactor']) . "',\n\t\t\t\t\t\t\t\t\t'" . round($_POST['DecimalPlaces'], 0) . "',\n\t\t\t\t\t\t\t\t\t'" . $_POST['Branch'] . "',\n\t\t\t\t\t\t\t\t\t'" . FormatDateForSQL($_POST['StartDate']) . "',\n\t\t\t\t\t\t\t\t\t'" . FormatDateForSQL($_POST['EndDate']) . "'\n\t\t\t\t\t\t\t\t\t)";
     $msg = _('Price added') . '.';
 }
 //run the SQL from either of the above possibilites
 if ($InputError != 1) {
     $result = DB_query($sql, $db, '', '', false, false);
     if (DB_error_no($db) != 0) {
         if ($msg == _('Price Updated')) {
             $msg = _('The price could not be updated because') . ' - ' . DB_error_msg($db);
         } else {
             $msg = _('The price could not be added because') . ' - ' . DB_error_msg($db);
         }
     } else {
         ReSequenceEffectiveDates($Item, $SalesType, $CurrCode, $_SESSION['CustomerID'], $db);
         unset($_POST['EndDate']);
         unset($_POST['StartDate']);
 $result = DB_query($sql, $db);
 if (DB_num_rows($result) > 0) {
     echo '<tr><td>' . _('Doctors Name') . ':</td>';
     echo '<td><select name="Doctor">';
     echo '<option value="">' . _('Select a doctor from list') . '</option>';
     while ($myrow = DB_fetch_array($result)) {
         if (isset($_POST['Doctor']) and $_POST['Doctor'] == $myrow['supplierid']) {
             echo '<option selected="selected" value="' . $myrow['supplierid'] . '">' . $myrow['supplierid'] . ' - ' . $myrow['suppname'] . '</option>';
         } else {
             echo '<option value="' . $myrow['supplierid'] . '">' . $myrow['supplierid'] . ' - ' . $myrow['suppname'] . '</option>';
         }
     }
     echo '</select></td></tr>';
     echo '<tr><td>';
     if (isset($_POST['DoctorsFee']) and $_POST['DoctorsFee'] != '') {
         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>';
Example #5
0
     $i++;
 }
 if (isset($SelectedTab) and $InputError != 1) {
     $sql = "UPDATE pctabs\r\n\t\t\tSET usercode = '" . $_POST['SelectUser'] . "',\r\n\t\t\ttypetabcode = '" . $_POST['SelectTabs'] . "',\r\n\t\t\tcurrency = '" . $_POST['SelectCurrency'] . "',\r\n\t\t\ttablimit = '" . filter_currency_input($_POST['tablimit']) . "',\r\n\t\t\tassigner = '" . $_POST['SelectAssigner'] . "',\r\n\t\t\tauthorizer = '" . $_POST['SelectAuthorizer'] . "',\r\n\t\t\tglaccountassignment = '" . $_POST['glaccountcash'] . "',\r\n\t\t\tglaccountpcash = '" . $_POST['glaccountpcashtab'] . "'\r\n\t\t\tWHERE tabcode = '" . $SelectedTab . "'";
     $msg = _('The Petty Cash Tab') . ' ' . $SelectedTab . ' ' . _('has been updated');
 } elseif ($InputError != 1) {
     // First check the type is not being duplicated
     $checkSql = "SELECT count(*)\r\n\t\t\t\t FROM pctabs\r\n\t\t\t\t WHERE tabcode = '" . $_POST['tabcode'] . "'";
     $checkresult = DB_query($checkSql, $db);
     $checkrow = DB_fetch_row($checkresult);
     if ($checkrow[0] > 0) {
         $InputError = 1;
         prnMsg(_('The Tab ') . $_POST['tabcode'] . _(' already exist.'), 'error');
     } else {
         // Add new record on submit
         $sql = "INSERT INTO pctabs\r\n\t\t\t\t\t\t(tabcode,\r\n\t\t\t \t\t\t usercode,\r\n\t\t\t\t\t\t typetabcode,\r\n\t\t\t\t\t\t currency,\r\n\t\t\t\t\t\t tablimit,\r\n\t\t\t\t\t\t assigner,\r\n\t\t\t\t\t\t authorizer,\r\n\t\t\t\t\t\t glaccountassignment,\r\n\t\t\t\t\t\t glaccountpcash)\r\n\t\t\t\tVALUES ('" . $_POST['tabcode'] . "',\r\n\t\t\t\t\t'" . $_POST['SelectUser'] . "',\r\n\t\t\t\t\t'" . $_POST['SelectTabs'] . "',\r\n\t\t\t\t\t'" . $_POST['SelectCurrency'] . "',\r\n\t\t\t\t\t'" . filter_currency_input($_POST['tablimit']) . "',\r\n\t\t\t\t\t'" . $_POST['SelectAssigner'] . "',\r\n\t\t\t\t\t'" . $_POST['SelectAuthorizer'] . "',\r\n\t\t\t\t\t'" . $_POST['glaccountcash'] . "',\r\n\t\t\t\t\t'" . $_POST['glaccountpcashtab'] . "')";
         $msg = _('The Petty Cash Tab') . ' ' . $_POST['tabcode'] . ' ' . _('has been created');
     }
 }
 if ($InputError != 1) {
     //run the SQL from either of the above possibilites
     $result = DB_query($sql, $db);
     prnMsg($msg, 'success');
     unset($SelectedTab);
     unset($_POST['tabcode']);
     unset($_POST['SelectUser']);
     unset($_POST['SelectTabs']);
     unset($_POST['SelectCurrency']);
     unset($_POST['tablimit']);
     unset($_POST['SelectAssigner']);
     unset($_POST['SelectAuthorizer']);
Example #6
0
class Allocation
{
    var $TransID;
    var $Amount;
    function Allocation($TransID, $Amount)
    {
        $this->TransID = $TransID;
        $this->Amount = $Amount;
    }
}
include 'includes/session.inc';
include 'includes/SQL_CommonFunctions.inc';
include 'includes/GetPaymentMethods.php';
foreach ($_POST as $key => $value) {
    if (substr($key, 0, 6) == 'ExRate') {
        $_POST[$key] = filter_currency_input($value);
    }
}
if ((isset($_POST['PrintPDF']) or isset($_POST['PrintPDFAndProcess'])) and isset($_POST['FromCriteria']) and mb_strlen($_POST['FromCriteria']) >= 1 and isset($_POST['ToCriteria']) and mb_strlen($_POST['ToCriteria']) >= 1 and is_numeric($_POST['ExRate'])) {
    /*then print the report */
    $RefCounter = 0;
    include 'includes/PDFStarter.php';
    $pdf->addInfo('Title', _('Payment Run Report'));
    $pdf->addInfo('Subject', _('Payment Run') . ' - ' . _('suppliers from') . ' ' . $_POST['FromCriteria'] . ' to ' . $_POST['ToCriteria'] . ' in ' . $_POST['Currency'] . ' ' . _('and Due By') . ' ' . $_POST['AmountsDueBy']);
    $PageNumber = 1;
    $line_height = 12;
    /*Now figure out the invoice less credits due for the Supplier range under review */
    include 'includes/PDFPaymentRunPageHeader.inc';
    $sql = "SELECT suppliers.supplierid,\n\t\t\tSUM(supptrans.ovamount + supptrans.ovgst - supptrans.alloc) AS balance\n\t\tFROM suppliers,\n\t\t\tpaymentterms,\n\t\t\tsupptrans,\n\t\t\tsystypes\n\t\tWHERE systypes.typeid = supptrans.type\n\t\tAND suppliers.paymentterms = paymentterms.termsindicator\n\t\tAND suppliers.supplierid = supptrans.supplierno\n\t\tAND supptrans.ovamount + supptrans.ovgst - supptrans.alloc !=0\n\t\tAND supptrans.duedate <='" . FormatDateForSQL($_POST['AmountsDueBy']) . "'\n\t\tAND supptrans.hold=0\n\t\tAND suppliers.currcode = '" . $_POST['Currency'] . "'\n\t\tAND supptrans.supplierNo >= '" . $_POST['FromCriteria'] . "'\n\t\tAND supptrans.supplierno <= '" . $_POST['ToCriteria'] . "'\n\t\tGROUP BY suppliers.supplierid\n\t\tHAVING SUM(supptrans.ovamount + supptrans.ovgst - supptrans.alloc) > 0\n\t\tORDER BY suppliers.supplierid";
    $SuppliersResult = DB_query($sql, $db);
    $SupplierID = '';
Example #7
0
     $ErrMsg = _('The supplier purchasing details could not be added to the database because');
     $DbgMsg = _('The SQL that failed was');
     $AddResult = DB_query($sql, $db, $ErrMsg, $DbgMsg);
     prnMsg(_('This supplier purchasing data has been added to the database'), 'success');
     /* If the new purchdata is the preferred one, the old ones from the same suppliers shouldn't be preferred.
     		Are kept only for historic information only */
     if ($_POST['Preferred'] == 1) {
         $sql = "UPDATE purchdata SET preferred='0'\n\t\t\t\t\t\t\t\tWHERE purchdata.stockid='" . $StockID . "'\n\t\t\t\t\t\t\t\t\tAND purchdata.supplierno='" . $SupplierID . "'\n\t\t\t\t\t\t\t\t\tAND purchdata.effectivefrom < '" . FormatDateForSQL($_POST['EffectiveFrom']) . "'";
         $ErrMsg = _('The preferred supplier details could not be update because');
         $DbgMsg = _('The SQL that failed was');
         $UpdResult = DB_query($sql, $db, $ErrMsg, $DbgMsg);
         prnMsg(_('Supplier preferred flag has been updated'), 'success');
     }
 }
 if ($InputError == 0 and isset($_POST['UpdateRecord'])) {
     $sql = "UPDATE purchdata SET price='" . filter_currency_input($_POST['Price']) . "',\n\t\t\t\t\t\t\t\t\teffectivefrom='" . FormatDateForSQL($_POST['EffectiveFrom']) . "',\n\t\t\t\t\t\t\t\t\tsuppliersuom='" . $_POST['SuppliersUOM'] . "',\n\t\t\t\t\t\t\t\t\tconversionfactor='" . $_POST['ConversionFactor'] . "',\n\t\t\t\t\t\t\t\t\tuomdecimalplaces='" . $_POST['DecimalPlaces'] . "',\n\t\t\t\t\t\t\t\t\tsupplierdescription='" . $_POST['SupplierDescription'] . "',\n\t\t\t\t\t\t\t\t\tsuppliers_partno='" . $_POST['SupplierCode'] . "',\n\t\t\t\t\t\t\t\t\tleadtime='" . $_POST['LeadTime'] . "',\n\t\t\t\t\t\t\t\t\tminorderqty='" . $_POST['MinOrderQty'] . "',\n\t\t\t\t\t\t\t\t\tpreferred='" . $_POST['Preferred'] . "'\n\t\t\t\t\t\t\tWHERE purchdata.stockid='" . $StockID . "'\n\t\t\t\t\t\t\t\tAND purchdata.supplierno='" . $SupplierID . "'\n\t\t\t\t\t\t\t\tAND purchdata.effectivefrom='" . $_POST['WasEffectiveFrom'] . "'";
     $ErrMsg = _('The supplier purchasing details could not be update because');
     $DbgMsg = _('The SQL that failed was');
     $UpdResult = DB_query($sql, $db, $ErrMsg, $DbgMsg);
     prnMsg(_('Supplier purchasing data has been updated'), 'success');
 }
 if ($InputError == 0 and (isset($_POST['UpdateRecord']) or isset($_POST['AddRecord']))) {
     /*update or insert took place and need to clear the form  */
     unset($SupplierID);
     unset($_POST['Price']);
     unset($CurrCode);
     unset($_POST['SuppliersUOM']);
     unset($_POST['EffectiveFrom']);
     unset($_POST['ConversionFactor']);
     unset($_POST['SupplierDescription']);
     unset($_POST['LeadTime']);
Example #8
0
            }
            $ErrMsg = _('The customer could not be updated because');
            $result = DB_query($sql, $db, $ErrMsg);
            prnMsg(_('Customer updated'), 'success');
            echo '<br />';
        } else {
            //it is a new customer
            /* set the DebtorNo if $AutoDebtorNo in config.php has been set to
            			something greater 0 */
            if ($_SESSION['AutoDebtorNo'] > 0) {
                /* system assigned, sequential, numeric */
                if ($_SESSION['AutoDebtorNo'] == 1) {
                    $_POST['DebtorNo'] = GetNextTransNo(500, $db);
                }
            }
            $sql = "INSERT INTO debtorsmaster (\n\t\t\t\t\t\t\tdebtorno,\n\t\t\t\t\t\t\tname,\n\t\t\t\t\t\t\taddress1,\n\t\t\t\t\t\t\taddress2,\n\t\t\t\t\t\t\taddress3,\n\t\t\t\t\t\t\taddress4,\n\t\t\t\t\t\t\taddress5,\n\t\t\t\t\t\t\taddress6,\n\t\t\t\t\t\t\tcurrcode,\n\t\t\t\t\t\t\tclientsince,\n\t\t\t\t\t\t\tholdreason,\n\t\t\t\t\t\t\tpaymentterms,\n\t\t\t\t\t\t\tdiscount,\n\t\t\t\t\t\t\tdiscountcode,\n\t\t\t\t\t\t\tpymtdiscount,\n\t\t\t\t\t\t\tcreditlimit,\n\t\t\t\t\t\t\tsalestype,\n\t\t\t\t\t\t\tinvaddrbranch,\n\t\t\t\t\t\t\ttaxref,\n\t\t\t\t\t\t\tcustomerpoline,\n\t\t\t\t\t\t\ttypeid)\n\t\t\t\tVALUES ('" . $_POST['DebtorNo'] . "',\n\t\t\t\t\t'" . $_POST['CustName'] . "',\n\t\t\t\t\t'" . $_POST['Address1'] . "',\n\t\t\t\t\t'" . $_POST['Address2'] . "',\n\t\t\t\t\t'" . $_POST['Address3'] . "',\n\t\t\t\t\t'" . $_POST['Address4'] . "',\n\t\t\t\t\t'" . $_POST['Address5'] . "',\n\t\t\t\t\t'" . $_POST['Address6'] . "',\n\t\t\t\t\t'" . $_POST['CurrCode'] . "',\n\t\t\t\t\t'" . $SQL_ClientSince . "',\n\t\t\t\t\t'" . $_POST['HoldReason'] . "',\n\t\t\t\t\t'" . $_POST['PaymentTerms'] . "',\n\t\t\t\t\t " . filter_number_input($_POST['Discount']) . "/100,\n\t\t\t\t\t'" . $_POST['DiscountCode'] . "',\n\t\t\t\t\t " . filter_number_input($_POST['PymtDiscount']) . "/100,\n\t\t\t\t\t'" . filter_currency_input($_POST['CreditLimit']) . "',\n\t\t\t\t\t'" . $_POST['SalesType'] . "',\n\t\t\t\t\t'" . $_POST['AddrInvBranch'] . "',\n\t\t\t\t\t'" . $_POST['TaxRef'] . "',\n\t\t\t\t\t'" . $_POST['CustomerPOLine'] . "',\n\t\t\t\t\t'" . $_POST['typeid'] . "'\n\t\t\t\t\t)";
            $ErrMsg = _('This customer could not be added because');
            $result = DB_query($sql, $db, $ErrMsg);
            $BranchCode = mb_substr($_POST['DebtorNo'], 0, 4);
            echo '<meta http-equiv="Refresh" content="0; url=' . $rootpath . '/CustomerBranches.php?DebtorNo=' . $_POST['DebtorNo'] . '">';
            echo '<div class="centre">' . _('You should automatically be forwarded to the entry of a new Customer Branch page') . '. ' . _('If this does not happen') . ' (' . _('if the browser does not support META Refresh') . ') ' . '<a href="' . $rootpath . '/CustomerBranches.php?DebtorNo=' . $_POST['DebtorNo'] . '"></a></div>';
            include 'includes/footer.inc';
            exit;
        }
    } else {
        prnMsg(_('Validation failed') . '. ' . _('No updates or deletes took place'), 'error');
    }
} elseif (isset($_POST['delete'])) {
    //the link to delete a selected record was clicked instead of the submit button
    $CancelDelete = 0;
    // PREVENT DELETES IF DEPENDENT RECORDS IN 'DebtorTrans'
Example #9
0
            $TagResult = DB_query($tagsql, $db);
            $TagMyrow = DB_fetch_row($TagResult);
            if ($PaymentItem->tag == 0) {
                $TagName = 'None';
            } else {
                $TagName = $TagMyrow[0];
            }
            echo '<tr>
					<td align=left>' . $PaymentItem->cheque . '</td>
					<td class="number">' . $PaymentItem->Amount . '</td>
					<td>' . $PaymentItem->GLCode . ' - ' . $PaymentItem->GLActName . '</td>
					<td>' . stripslashes($PaymentItem->Narrative) . '</td>
					<td>' . $PaymentItem->tag . ' - ' . $TagName . '</td>
					<td><a href="' . htmlspecialchars($_SERVER['PHP_SELF'], ENT_QUOTES, 'UTF-8') . '?Delete=' . $PaymentItem->ID . '" onclick="return confirm(\'' . _('Are you sure you wish to delete this payment analysis item?') . '\');">' . _('Delete') . '</a></td>
				</tr>';
            $PaymentTotal += filter_currency_input($PaymentItem->Amount);
        }
        echo '<tr><td></td><td class="number"><b>' . locale_money_format($PaymentTotal, $_SESSION['PaymentDetail' . $identifier]->AccountCurrency) . '</b></td><td colspan="3"></td></tr></table><br />';
        echo '<button type="submit" name="CommitBatch">' . _('Accept and Process Payment') . '</button>';
    }
} else {
    /*a supplier is selected or the GL link is not active then set out
    the fields for entry of receipt amt and disc */
    if ($_SESSION['PaymentDetail' . $identifier]->Amount == 0) {
        echo '<table class="selection"><tr><td>' . _('Amount of Payment') . ' ' . $_SESSION['PaymentDetail' . $identifier]->Currency . ':</td>
				<td><input class="number" type="text" name="Amount" maxlength="12" size="13" value="' . locale_money_format(0, $_SESSION['PaymentDetail' . $identifier]->Currency) . '" /></td></tr>';
    } else {
        echo '<table class="selection"><tr><td>' . _('Amount of Payment') . ' ' . $_SESSION['PaymentDetail' . $identifier]->Currency . ':</td>
				<td><input class="number" type="text" name="Amount" maxlength="12" size="13" value="' . locale_money_format($_SESSION['PaymentDetail' . $identifier]->Amount, $_SESSION['PaymentDetail' . $identifier]->Currency) . '" /></td></tr>';
    }
    if (isset($_SESSION['PaymentDetail' . $identifier]->SupplierID)) {
Example #10
0
        /* Need to see if there is also a price entered that has an end date after the start date of this price and if
        		so we will need to update it so there is no ambiguity as to which price will be used*/
        //editing an existing price
        $sql = "UPDATE prices SET\n\t\t\t\t\ttypeabbrev='" . $_POST['TypeAbbrev'] . "',\n\t\t\t\t\tcurrabrev='" . $_POST['CurrAbrev'] . "',\n\t\t\t\t\tprice='" . filter_currency_input($_POST['Price']) . "',\n\t\t\t\t\tunits='" . $_POST['Units'] . "',\n\t\t\t\t\tconversionfactor='" . $_POST['ConversionFactor'] . "',\n\t\t\t\t\tdecimalplaces='" . $_POST['DecimalPlaces'] . "',\n\t\t\t\t\tstartdate='" . FormatDateForSQL($_POST['StartDate']) . "',\n\t\t\t\t\tenddate='" . $SQLEndDate . "'\n\t\t\t\tWHERE prices.stockid='" . $Item . "'\n\t\t\t\tAND startdate='" . $_POST['OldStartDate'] . "'\n\t\t\t\tAND enddate ='" . $_POST['OldEndDate'] . "'\n\t\t\t\tAND prices.typeabbrev='" . $_POST['OldTypeAbbrev'] . "'\n\t\t\t\tAND prices.currabrev='" . $_POST['OldCurrAbrev'] . "'\n\t\t\t\tAND prices.debtorno=''";
        $ErrMsg = _('Could not be update the existing prices');
        $result = DB_query($sql, $db, $ErrMsg);
        ReSequenceEffectiveDates($Item, $_POST['TypeAbbrev'], $_POST['CurrAbrev'], $db);
        prnMsg(_('The price has been updated'), 'success');
        echo '<br />';
    } elseif ($InputError != 1) {
        /*Selected price is null cos no item selected on first time round so must be adding a	record must be submitting new entries in the new price form */
        $sql = "UPDATE prices SET\n\t\t\t\t\tenddate='" . date('Y-m-d') . "'\n\t\t\t\tWHERE prices.stockid='" . $Item . "'\n\t\t\t\tAND startdate='" . FormatDateForSQL($_POST['StartDate']) . "'\n\t\t\t\tAND enddate ='" . $SQLEndDate . "'\n\t\t\t\tAND prices.typeabbrev='" . $_POST['TypeAbbrev'] . "'\n\t\t\t\tAND prices.currabrev='" . $_POST['CurrAbrev'] . "'\n\t\t\t\tAND prices.debtorno=''";
        $ErrMsg = _('Could not be update the existing prices');
        $result = DB_query($sql, $db, $ErrMsg);
        ReSequenceEffectiveDates($Item, $_POST['TypeAbbrev'], $_POST['CurrAbrev'], $db);
        $sql = "INSERT INTO prices (stockid,\n\t\t\t\t\t\t\t\t\ttypeabbrev,\n\t\t\t\t\t\t\t\t\tcurrabrev,\n\t\t\t\t\t\t\t\t\tunits,\n\t\t\t\t\t\t\t\t\tconversionfactor,\n\t\t\t\t\t\t\t\t\tdecimalplaces,\n\t\t\t\t\t\t\t\t\tstartdate,\n\t\t\t\t\t\t\t\t\tenddate,\n\t\t\t\t\t\t\t\t\tprice)\n\t\t\t\t\t\t\tVALUES ('" . $Item . "',\n\t\t\t\t\t\t\t\t'" . $_POST['TypeAbbrev'] . "',\n\t\t\t\t\t\t\t\t'" . $_POST['CurrAbrev'] . "',\n\t\t\t\t\t\t\t\t'" . $_POST['Units'] . "',\n\t\t\t\t\t\t\t\t'" . filter_number_input($_POST['ConversionFactor']) . "',\n\t\t\t\t\t\t\t\t'" . $_POST['DecimalPlaces'] . "',\n\t\t\t\t\t\t\t\t'" . FormatDateForSQL($_POST['StartDate']) . "',\n\t\t\t\t\t\t\t\t'" . $SQLEndDate . "',\n\t\t\t\t\t\t\t\t'" . filter_currency_input($_POST['Price']) . "')";
        $ErrMsg = _('The new price could not be added');
        $result = DB_query($sql, $db, $ErrMsg);
        ReSequenceEffectiveDates($Item, $_POST['TypeAbbrev'], $_POST['CurrAbrev'], $db);
        prnMsg(_('The new price has been inserted'), 'success');
        echo '<br />';
    }
    unset($_POST['Price']);
    unset($_POST['StartDate']);
    unset($_POST['EndDate']);
    unset($_POST['Units']);
    unset($_POST['ConversionFactor']);
    unset($_POST['DecimalPlaces']);
} elseif (isset($_GET['delete'])) {
    //the link to delete a selected record was clicked instead of the submit button
    $sql = "DELETE FROM prices\n\t\t\t\tWHERE prices.stockid = '" . $Item . "'\n\t\t\t\tAND prices.typeabbrev='" . $_GET['TypeAbbrev'] . "'\n\t\t\t\tAND prices.currabrev ='" . $_GET['CurrAbrev'] . "'\n\t\t\t\tAND  prices.startdate = '" . $_GET['StartDate'] . "'\n\t\t\t\tAND  prices.enddate = '" . $_GET['EndDate'] . "'\n\t\t\t\tAND prices.debtorno=''";
    } else {
        prnMsg(_('The other contract requirements cannot be altered because the customer has already placed the order'), 'warn');
    }
}
if (isset($_POST['EnterNewRequirement'])) {
    $InputError = false;
    if (!is_numeric(filter_number_input($_POST['Quantity']))) {
        prnMsg(_('The quantity of the new requirement is expected to be numeric'), 'error');
        $InputError = true;
    }
    if (!is_numeric(filter_currency_input($_POST['CostPerUnit']))) {
        prnMsg(_('The cost per unit of the new requirement is expected to be numeric'), 'error');
        $InputError = true;
    }
    if (!$InputError) {
        $_SESSION['Contract' . $identifier]->Add_To_ContractRequirements($_POST['RequirementDescription'], filter_number_input($_POST['Quantity']), filter_currency_input($_POST['CostPerUnit']));
        unset($_POST['RequirementDescription']);
        unset($_POST['Quantity']);
        unset($_POST['CostPerUnit']);
    }
}
/* This is where the other requirement as entered/modified should be displayed reflecting any deletions or insertions*/
echo '<form name="ContractReqtsForm" action="' . htmlspecialchars($_SERVER['PHP_SELF'], ENT_QUOTES, 'UTF-8') . '?identifier=' . $identifier . '" method="post">';
echo '<input type="hidden" name="FormID" value="' . $_SESSION['FormID'] . '" />';
echo '<p class="page_title_text"><img src="' . $rootpath . '/css/' . $theme . '/images/contract.png" title="' . _('Contract Other Requirements') . '" alt="" />  ' . _('Contract Other Requirements') . ' - ' . $_SESSION['Contract' . $identifier]->CustomerName . '</p>';
if (count($_SESSION['Contract' . $identifier]->ContractReqts) > 0) {
    echo '<table cellpadding="2" class="selection">';
    if (isset($_SESSION['Contract' . $identifier]->ContractRef)) {
        echo '<tr><th colspan="5">' . _('Contract Reference:') . ' ' . $_SESSION['Contract' . $identifier]->ContractRef . '</th></tr>';
    }
    echo '<tr>
if (isset($_POST['Update']) and $_POST['RowCounter'] > 1) {
    for ($Counter = 1; $Counter <= $_POST['RowCounter']; $Counter++) {
        if (isset($_POST['Clear_' . $Counter]) and $_POST['Clear_' . $Counter] == True) {
            /*Get amount to be cleared */
            $sql = "SELECT amount,\n\t\t\t\t\t\t\texrate\n\t\t\t\t\t\tFROM banktrans\n\t\t\t\t\t\tWHERE banktransid='" . $_POST['BankTrans_' . $Counter] . "'";
            $ErrMsg = _('Could not retrieve transaction information');
            $result = DB_query($sql, $db, $ErrMsg);
            $myrow = DB_fetch_array($result);
            $AmountCleared = round($myrow[0] / $myrow[1], 2);
            /*Update the banktrans recoord to match it off */
            $sql = "UPDATE banktrans SET amountcleared= '" . $AmountCleared . "'\n\t\t\t\t\t\t\t\t\tWHERE banktransid='" . $_POST['BankTrans_' . $Counter] . "'";
            $ErrMsg = _('Could not match off this payment because');
            $result = DB_query($sql, $db, $ErrMsg);
        } elseif (isset($_POST['AmtClear_' . $Counter]) and filter_currency_input($_POST['AmtClear_' . $Counter]) < 0 and $Type == 'Payments' or $Type == 'Receipts' and isset($_POST['AmtClear_' . $Counter]) and filter_currency_input($_POST['AmtClear_' . $Counter]) > 0) {
            /*if the amount entered was numeric and negative for a payment or positive for a receipt */
            $sql = "UPDATE banktrans SET amountcleared=" . filter_currency_input($_POST['AmtClear_' . $Counter]) . "\n\t\t\t\t\t WHERE banktransid='" . $_POST['BankTrans_' . $Counter] . "'";
            $ErrMsg = _('Could not update the amount matched off this bank transaction because');
            $result = DB_query($sql, $db, $ErrMsg);
        } elseif (isset($_POST['Unclear_' . $Counter]) and $_POST['Unclear_' . $Counter] == True) {
            $sql = "UPDATE banktrans SET amountcleared = 0\n\t\t\t\t\t WHERE banktransid='" . $_POST['BankTrans_' . $Counter] . "'";
            $ErrMsg = _('Could not unclear this bank transaction because');
            $result = DB_query($sql, $db, $ErrMsg);
        }
    }
    /*Show the updated position with the same criteria as previously entered*/
    $_POST['ShowTransactions'] = True;
}
echo '<div class="page_help_text">' . _('Use this screen to match webERP Receipts and Payments to your Bank Statement.  Check your bank statement and click the check-box when you find the matching transaction.') . '</div><br />';
echo '<form action="' . htmlspecialchars($_SERVER['PHP_SELF'], ENT_QUOTES, 'UTF-8') . '" method="post">';
echo '<input type="hidden" name="FormID" value="' . $_SESSION['FormID'] . '" />';
echo '<input type="hidden" name="Type" value="' . $Type . '" />';
         if (!($Result = DB_query($SQL, $db))) {
             $error = 'Could not delete old allocation record';
         }
     }
     //			 if ($AllocnItem->OrigAlloc != $AllocnItem->AllocAmt) // has previous allocated amount changed?
     //			 {
     if ($AllocnItem->AllocAmt > 0) {
         $SQL = "INSERT INTO\n\t\t\t\t\t\t\t\tcustallocns (\n\t\t\t\t\t\t\t\tdatealloc,\n\t\t\t\t\t\t\t\tamt,\n\t\t\t\t\t\t\t\ttransid_allocfrom,\n\t\t\t\t\t\t\t\ttransid_allocto\n\t\t\t\t\t\t\t) VALUES (\n\t\t\t\t\t\t\t\t'" . date('Y-m-d') . "',\n\t\t\t\t\t\t\t\t'" . $AllocnItem->AllocAmt . "',\n\t\t\t\t\t\t\t\t'" . $_SESSION['Alloc']->AllocTrans . "',\n\t\t\t\t\t\t\t\t'" . $AllocnItem->ID . "'\n\t\t\t\t\t\t\t)";
         if (!($Result = DB_query($SQL, $db))) {
             $error = 'Could not change allocation record';
         }
     }
     $NewAllocTotal = $AllocnItem->PrevAlloc + $AllocnItem->AllocAmt;
     $AllAllocations = $AllAllocations + $AllocnItem->AllocAmt;
     $Settled = abs(filter_currency_input($NewAllocTotal - $AllocnItem->TransAmount)) < 0.005 ? 1 : 0;
     $SQL = "UPDATE debtortrans\n\t\t\t\t\t\tSET diffonexch='" . $AllocnItem->DiffOnExch . "',\n\t\t\t\t\t\talloc = '" . filter_currency_input($NewAllocTotal) . "',\n\t\t\t\t\t\tsettled = '" . $Settled . "'\n\t\t\t\t\t\tWHERE id = '" . $AllocnItem->ID . "'";
     if (!($Result = DB_query($SQL, $db))) {
         $error = 'Could not update difference on exchange';
     }
     //			 }
 }
 $Settled = abs($TotalAllocated + $_SESSION['Alloc']->TransAmt) < 0.01 ? 1 : 0;
 // Update the receipt or credit note
 $SQL = "UPDATE debtortrans\n\t\t\t\tSET alloc = '" . -$AllAllocations . "',\n\t\t\t\tdiffonexch = '" . -$TotalDiffOnExch . "',\n\t\t\t\tsettled='" . $Settled . "'\n\t\t\t\tWHERE id = '" . $_POST['AllocTrans'] . "'";
 if (!($Result = DB_query($SQL, $db))) {
     $error = 'Could not update receipt or credit note';
 }
 // If GLLink to debtors active post diff on exchange to GL
 $MovtInDiffOnExch = -$_SESSION['Alloc']->PrevDiffOnExch - $TotalDiffOnExch;
 if ($MovtInDiffOnExch != 0) {
     if ($_SESSION['CompanyRecord']['gllink_debtors'] == 1) {
     }
     $SQLTestExists = "SELECT price FROM prices\n\t\t\t\t\t\t\t\t\t\tWHERE stockid = '" . $_POST['StockID_' . $PriceCounter] . "'\n\t\t\t\t\t\t\t\t\tAND prices.typeabbrev ='" . $_POST['SalesType'] . "'\n\t\t\t\t\t\t\t\t\tAND prices.currabrev ='" . $_POST['CurrCode'] . "'\n\t\t\t\t\t\t\t\t\tAND prices.debtorno ='" . $_POST['DebtorNo_' . $PriceCounter] . "'\n\t\t\t\t\t\t\t\t\tAND prices.branchcode ='" . $_POST['BranchCode_' . $PriceCounter] . "'\n\t\t\t\t\t\t\t\t\tAND prices.startdate<='" . date('Y-m-d') . "'\n\t\t\t\t\t\t\t\t\tAND prices.enddate>'" . date('Y-m-d') . "'";
     $TestExistsResult = DB_query($SQLTestExists, $db);
     if (DB_num_rows($TestExistsResult) == 1) {
         //then we are updating
         $SQLUpdate = "UPDATE prices\n\t\t\t\t\t\t\t\t\tSET price = '" . filter_currency_input($_POST['Price_' . $PriceCounter]) . "'\n\t\t\t\t\t\t\t\tWHERE stockid = '" . $_POST['StockID_' . $PriceCounter] . "'\n\t\t\t\t\t\t\t\t\tAND prices.typeabbrev ='" . $_POST['SalesType'] . "'\n\t\t\t\t\t\t\t\t\tAND prices.currabrev ='" . $_POST['CurrCode'] . "'\n\t\t\t\t\t\t\t\t\tAND prices.debtorno ='" . $_POST['DebtorNo_' . $PriceCounter] . "'\n\t\t\t\t\t\t\t\t\tAND prices.branchcode ='" . $_POST['BranchCode_' . $PriceCounter] . "'\n\t\t\t\t\t\t\t\t\tAND prices.units ='" . $_POST['Units_' . $PriceCounter] . "'\n\t\t\t\t\t\t\t\t\tAND prices.conversionfactor ='" . filter_number_input($_POST['ConversionFactor_' . $PriceCounter]) . "'\n\t\t\t\t\t\t\t\t\tAND prices.startdate<='" . date('Y-m-d') . "'";
         $ResultUpdate = DB_query($SQLUpdate, $db);
         if (DB_error_no($db) == 0) {
             prnMsg(_('The price for') . ' ' . $_POST['StockID_' . $PriceCounter] . ' ' . _('has been updated in the database'), 'success');
         } else {
             prnMsg(_('The price for') . ' ' . $_POST['StockID_' . $PriceCounter] . ' ' . _('could not be updated'), 'error');
         }
         echo '<br />';
     } else {
         //we need to add a new price from today
         $SQLInsert = "INSERT INTO prices (\n\t\t\t\t\t\t\tstockid,\n\t\t\t\t\t\t\tprice,\n\t\t\t\t\t\t\ttypeabbrev,\n\t\t\t\t\t\t\tcurrabrev,\n\t\t\t\t\t\t\tdebtorno,\n\t\t\t\t\t\t\tbranchcode,\n\t\t\t\t\t\t\tstartdate,\n\t\t\t\t\t\t\tenddate,\n\t\t\t\t\t\t\tunits,\n\t\t\t\t\t\t\tconversionfactor\n\t\t\t\t\t\t) VALUES (\n\t\t\t\t\t\t\t'" . $_POST['StockID_' . $PriceCounter] . "',\n\t\t\t\t\t\t\t'" . filter_currency_input($_POST['Price_' . $PriceCounter]) . "',\n\t\t\t\t\t\t\t'" . $_POST['SalesType'] . "',\n\t\t\t\t\t\t\t'" . $_POST['CurrCode'] . "',\n\t\t\t\t\t\t\t'" . $_POST['DebtorNo_' . $PriceCounter] . "',\n\t\t\t\t\t\t\t'" . $_POST['BranchCode_' . $PriceCounter] . "',\n\t\t\t\t\t\t\t'" . date('Y-m-d') . "',\n\t\t\t\t\t\t\t'2030-01-01',\n\t\t\t\t\t\t\t'" . $_POST['Units_' . $PriceCounter] . "',\n\t\t\t\t\t\t\t'" . filter_number_input($_POST['ConversionFactor_' . $PriceCounter]) . "'\n\t\t\t\t\t\t)";
         $ResultInsert = DB_query($SQLInsert, $db);
         if (DB_error_no($db) == 0) {
             prnMsg(_('The price for') . ' ' . $_POST['StockID_' . $PriceCounter] . ' ' . _('has been inserted in the database'), 'success');
         } else {
             prnMsg(_('The price for') . ' ' . $_POST['StockID_' . $PriceCounter] . ' ' . _('could not be inserted'), 'error');
         }
         echo '<br />';
     }
     $PriceCounter++;
 }
 DB_free_result($result);
 //clear the old result
 $result = DB_query($sql, $db);
 //re-run the query with the updated prices
 $numrow = DB_num_rows($result);
Example #15
0
     $SQL = "INSERT INTO banktrans (type,\n\t\t\t\t\t\t\t\t\t\ttransno,\n\t\t\t\t\t\t\t\t\t\tbankact,\n\t\t\t\t\t\t\t\t\t\tref,\n\t\t\t\t\t\t\t\t\t\texrate,\n\t\t\t\t\t\t\t\t\t\tfunctionalexrate,\n\t\t\t\t\t\t\t\t\t\ttransdate,\n\t\t\t\t\t\t\t\t\t\tbanktranstype,\n\t\t\t\t\t\t\t\t\t\tamount,\n\t\t\t\t\t\t\t\t\t\tcurrcode)\n\t\t\t\t\t\t\t\t\tVALUES (\n\t\t\t\t\t\t\t\t\t\t12,\n\t\t\t\t\t\t\t\t\t\t'" . $ReceiptNumber . "',\n\t\t\t\t\t\t\t\t\t\t'" . $_POST['BankAccount'] . "',\n\t\t\t\t\t\t\t\t\t\t'" . $_SESSION['Items' . $identifier]->LocationName . ' ' . _('Counter Sale') . ' ' . $InvoiceNo . "',\n\t\t\t\t\t\t\t\t\t\t'" . $ExRate . "',\n\t\t\t\t\t\t\t\t\t\t'" . $BankAccountExRate . "',\n\t\t\t\t\t\t\t\t\t\t'" . $DefaultDispatchDate . "',\n\t\t\t\t\t\t\t\t\t\t'" . $_POST['PaymentMethod'] . "',\n\t\t\t\t\t\t\t\t\t\t'" . filter_currency_input(filter_currency_input($_POST['AmountPaid']) * $BankAccountExRate) . "',\n\t\t\t\t\t\t\t\t\t\t'" . $_SESSION['Items' . $identifier]->DefaultCurrency . "')";
     $DbgMsg = _('The SQL that failed to insert the bank account transaction was');
     $ErrMsg = _('Cannot insert a bank transaction');
     $result = DB_query($SQL, $db, $ErrMsg, $DbgMsg, true);
     //insert a new debtortrans for the receipt
     $SQL = "INSERT INTO debtortrans (transno,\n\t\t\t\t\t\t\t\t\t\t\ttype,\n\t\t\t\t\t\t\t\t\t\t\tdebtorno,\n\t\t\t\t\t\t\t\t\t\t\ttrandate,\n\t\t\t\t\t\t\t\t\t\t\tinputdate,\n\t\t\t\t\t\t\t\t\t\t\tprd,\n\t\t\t\t\t\t\t\t\t\t\treference,\n\t\t\t\t\t\t\t\t\t\t\trate,\n\t\t\t\t\t\t\t\t\t\t\tovamount,\n\t\t\t\t\t\t\t\t\t\t\talloc,\n\t\t\t\t\t\t\t\t\t\t\tinvtext,\n\t\t\t\t\t\t\t\t\t\t\tsettled)\n\t\t\t\t\t\t\t\t\t\tVALUES (\n\t\t\t\t\t\t\t\t\t\t\t'" . $ReceiptNumber . "',\n\t\t\t\t\t\t\t\t\t\t\t12,\n\t\t\t\t\t\t\t\t\t\t\t'" . $_SESSION['Items' . $identifier]->DebtorNo . "',\n\t\t\t\t\t\t\t\t\t\t\t'" . $DefaultDispatchDate . "',\n\t\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\t'" . $PeriodNo . "',\n\t\t\t\t\t\t\t\t\t\t\t'" . $InvoiceNo . "',\n\t\t\t\t\t\t\t\t\t\t\t'" . $ExRate . "',\n\t\t\t\t\t\t\t\t\t\t\t'-" . filter_currency_input($_POST['AmountPaid']) . "',\n\t\t\t\t\t\t\t\t\t\t\t'-" . filter_currency_input($_POST['AmountPaid']) . "',\n\t\t\t\t\t\t\t\t\t\t\t'" . $_SESSION['Items' . $identifier]->LocationName . ' ' . _('Counter Sale') . "',\n\t\t\t\t\t\t\t\t\t\t\t'1')";
     $DbgMsg = _('The SQL that failed to insert the customer receipt transaction was');
     $ErrMsg = _('Cannot insert a receipt transaction against the customer because');
     $result = DB_query($SQL, $db, $ErrMsg, $DbgMsg, true);
     $ReceiptDebtorTransID = DB_Last_Insert_ID($db, 'debtortrans', 'id');
     $SQL = "UPDATE debtorsmaster SET lastpaiddate = '" . $DefaultDispatchDate . "',\n\t\t\t\t\t\t\t\t\t\t\tlastpaid='" . filter_currency_input($_POST['AmountPaid']) . "'\n\t\t\t\t\t\t\t\t\tWHERE debtorsmaster.debtorno='" . $_SESSION['Items' . $identifier]->DebtorNo . "'";
     $DbgMsg = _('The SQL that failed to update the date of the last payment received was');
     $ErrMsg = _('Cannot update the customer record for the date of the last payment received because');
     $result = DB_query($SQL, $db, $ErrMsg, $DbgMsg, true);
     //and finally add the allocation record between receipt and invoice
     $SQL = "INSERT INTO custallocns (\tamt,\n\t\t\t\t\t\t\t\t\t\t\t\tdatealloc,\n\t\t\t\t\t\t\t\t\t\t\t\ttransid_allocfrom,\n\t\t\t\t\t\t\t\t\t\t\t\ttransid_allocto )\n\t\t\t\t\t\t\t\t\tVALUES  ('" . filter_currency_input($_POST['AmountPaid']) . "',\n\t\t\t\t\t\t\t\t\t\t\t'" . $DefaultDispatchDate . "',\n\t\t\t\t\t\t\t\t\t\t\t '" . $ReceiptDebtorTransID . "',\n\t\t\t\t\t\t\t\t\t\t\t '" . $DebtorTransID . "')";
     $DbgMsg = _('The SQL that failed to insert the allocation of the receipt to the invoice was');
     $ErrMsg = _('Cannot insert the customer allocation of the receipt to the invoice because');
     $result = DB_query($SQL, $db, $ErrMsg, $DbgMsg, true);
 }
 //end if $_POST['AmountPaid']!= 0
 DB_Txn_Commit($db);
 // *************************************************************************
 //   E N D   O F   I N V O I C E   S Q L   P R O C E S S I N G
 // *************************************************************************
 unset($_SESSION['Items' . $identifier]->LineItems);
 unset($_SESSION['Items' . $identifier]);
 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 . '/PDFReceipt.php?FromTransNo=' . $InvoiceNo . '&amp;InvOrCredit=Invoice&amp;PrintPDF=True">' . _('Print this receipt') . '</a><br /><br />';
 //initialise no input errors assumed initially before we test
 $InputError = 0;
 if (!isset($_SESSION['Alloc'])) {
     prnMsg(_('Allocations can not be processed again') . '. ' . _('If you hit refresh on this page after having just processed an allocation') . ', ' . _('try to use the navigation links provided rather than the back button, to avoid this message in future'), 'warn');
     include 'includes/footer.inc';
     exit;
 }
 /*1st off run through and update the array with the amounts allocated
 	This works because the form has an input field called the value of
 	AllocnItm->ID for each record of the array - and PHP sets the value of
 	the form variable on a post*/
 $TotalAllocated = 0;
 $TotalDiffOnExch = 0;
 for ($AllocCounter = 0; $AllocCounter < $_POST['TotalNumberOfAllocs']; $AllocCounter++) {
     $_POST['Amt' . $AllocCounter] = filter_currency_input($_POST['Amt' . $AllocCounter]);
     $_POST['YetToAlloc' . $AllocCounter] = filter_currency_input($_POST['YetToAlloc' . $AllocCounter]);
     if (!is_numeric($_POST['Amt' . $AllocCounter])) {
         $_POST['Amt' . $AllocCounter] = 0;
     }
     if ($_POST['Amt' . $AllocCounter] < 0) {
         prnMsg(_('The entry for the amount to allocate was negative') . '. ' . _('A positive allocation amount is expected'), 'error');
         $_POST['Amt' . $AllocCounter] = 0;
     }
     if (isset($_POST['All' . $AllocCounter]) and $_POST['All' . $AllocCounter] == True) {
         $_POST['Amt' . $AllocCounter] = $_POST['YetToAlloc' . $AllocCounter];
     }
     /*Now check to see that the AllocAmt is no greater than the
     	 amount left to be allocated against the transaction under review */
     if ($_POST['Amt' . $AllocCounter] > $_POST['YetToAlloc' . $AllocCounter]) {
         $_POST['Amt' . $AllocCounter] = $_POST['YetToAlloc' . $AllocCounter];
     }
                 $Result = DB_query($SQL, $db, $ErrMsg, $DbgMsg, true);
             }
             //assetid provided doesn't exist so ignore it and treat as a normal nominal item
         }
         //assetid is set so the nominal item is an asset
         /* If GLLink_Stock then insert GLTrans to debit the GL Code  and credit GRN Suspense account at standard cost*/
         if ($_SESSION['PO']->GLLink == 1 and $OrderLine->GLCode != 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 debit using the GLCode in the PO detail record entry*/
             $SQL = "INSERT INTO gltrans (type,\n\t\t\t\t\t\t\t\t\t\t\ttypeno,\n\t\t\t\t\t\t\t\t\t\t\ttrandate,\n\t\t\t\t\t\t\t\t\t\t\tperiodno,\n\t\t\t\t\t\t\t\t\t\t\taccount,\n\t\t\t\t\t\t\t\t\t\t\tdefaulttag,\n\t\t\t\t\t\t\t\t\t\t\tnarrative,\n\t\t\t\t\t\t\t\t\t\t\tamount)\n\t\t\t\t\t\t\t\t\t\tVALUES (\n\t\t\t\t\t\t\t\t\t\t\t25,\n\t\t\t\t\t\t\t\t\t\t\t'" . $GRN . "',\n\t\t\t\t\t\t\t\t\t\t\t'" . $_POST['DefaultReceivedDate'] . "',\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'" . $OrderLine->GLCode . "',\n\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'PO: " . $_SESSION['PO']->OrderNo . " " . $_SESSION['PO']->SupplierID . " - " . $OrderLine->StockID . " - " . $OrderLine->ItemDescription . " x " . $OrderLine->ReceiveQty * $OrderLine->ConversionFactor . " @ " . locale_money_format($CurrentStandardCost, $_SESSION['CompanyRecord']['currencydefault']) . "',\n\t\t\t\t\t\t\t\t\t\t\t'" . filter_currency_input($CurrentStandardCost * $OrderLine->ReceiveQty * $OrderLine->ConversionFactor) . "'\n\t\t\t\t\t\t\t\t\t\t)";
             $ErrMsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('The purchase GL posting could not be inserted because');
             $DbgMsg = _('The following SQL to insert the purchase GLTrans record was used');
             $Result = DB_query($SQL, $db, $ErrMsg, $DbgMsg, true);
             /* If the CurrentStandardCost != UnitCost (the standard at the time the first delivery was booked in,  and its a stock item, then the difference needs to be booked in against the purchase price variance account */
             /*now the GRN suspense entry*/
             $SQL = "INSERT INTO gltrans (type,\n\t\t\t\t\t\t\t\t\t\t\ttypeno,\n\t\t\t\t\t\t\t\t\t\t\ttrandate,\n\t\t\t\t\t\t\t\t\t\t\tperiodno,\n\t\t\t\t\t\t\t\t\t\t\taccount,\n\t\t\t\t\t\t\t\t\t\t\tdefaulttag,\n\t\t\t\t\t\t\t\t\t\t\tnarrative,\n\t\t\t\t\t\t\t\t\t\t\tamount)\n\t\t\t\t\t\t\t\t\t\tVALUES (\n\t\t\t\t\t\t\t\t\t\t\t25,\n\t\t\t\t\t\t\t\t\t\t\t'" . $GRN . "',\n\t\t\t\t\t\t\t\t\t\t\t'" . $_POST['DefaultReceivedDate'] . "',\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'" . $_SESSION['CompanyRecord']['grnact'] . "',\n\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'" . _('PO') . ': ' . $_SESSION['PO']->OrderNo . ' ' . $_SESSION['PO']->SupplierID . ' - ' . $OrderLine->StockID . ' - ' . $OrderLine->ItemDescription . ' x ' . $OrderLine->ReceiveQty * $OrderLine->ConversionFactor . ' @ ' . locale_money_format($UnitCost, $_SESSION['CompanyRecord']['currencydefault']) . "',\n\t\t\t\t\t\t\t\t\t\t\t-" . filter_currency_input($UnitCost * $OrderLine->ReceiveQty * $OrderLine->ConversionFactor) . "\n\t\t\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 and standard cost !=0 */
     }
     /*Quantity received is != 0 */
 }
 /*end of OrderLine loop */
 $CompletedSQL = "SELECT SUM(completed) as completedlines,\n\t\t\t\t\t\t\t\t\t\t\t\tCOUNT(podetailitem) as alllines\n\t\t\t\t\t\t\t\t\t\t\tFROM purchorderdetails\n\t\t\t\t\t\t\t\t\t\t\tWHERE orderno='" . $_SESSION['PO']->OrderNo . "'";
 $CompletedResult = DB_query($CompletedSQL, $db);
 $MyCompletedRow = DB_fetch_array($CompletedResult);
 $Status = $MyCompletedRow['alllines'] - $MyCompletedRow['completedlines'];
 if ($Status == 0 or $OrderCompleted) {
     $sql = "SELECT stat_comment\n\t\t\t\t\tFROM purchorders\n\t\t\t\t\tWHERE orderno='" . $_SESSION['PO']->OrderNo . "'";
Example #18
0
     prnMsg('<br />' . _('An Amount must be input'), 'error');
     $Errors[$i] = 'TabCode';
     $i++;
 }
 $sqlLimit = "SELECT tablimit\n\t\t\t\t\tFROM pctabs\n\t\t\t\t\tWHERE tabcode='" . $SelectedTabs . "'";
 $ResultLimit = DB_query($sqlLimit, $db);
 $Limit = DB_fetch_array($ResultLimit);
 if ($_POST['CurrentAmount'] + $_POST['Amount'] > $Limit['tablimit']) {
     prnMsg('<br />' . _('The balance after this assignment would be greater than the specified limit for this PC tab'), 'warning');
 }
 if ($InputError != 1 and isset($SelectedIndex)) {
     $sql = "UPDATE pcashdetails\n\t\t\t\t\tSET date = '" . FormatDateForSQL($_POST['Date']) . "',\n\t\t\t\t\tamount = '" . filter_currency_input($_POST['Amount']) . "',\n\t\t\t\t\tauthorized = '0000-00-00',\n\t\t\t\t\tnotes = '" . $_POST['Notes'] . "',\n\t\t\t\t\treceipt = '" . $_POST['Receipt'] . "'\n\t\t\t\tWHERE counterindex = '" . $SelectedIndex . "'";
     $msg = _('Assignment of cash to PC Tab ') . ' ' . $SelectedTabs . ' ' . _('has been updated');
 } elseif ($InputError != 1) {
     // Add new record on submit
     $sql = "INSERT INTO pcashdetails\n\t\t\t\t\t\t(counterindex,\n\t\t\t\t\t\ttabcode,\n\t\t\t\t\t\tdate,\n\t\t\t\t\t\tcodeexpense,\n\t\t\t\t\t\tamount,\n\t\t\t\t\t\tauthorized,\n\t\t\t\t\t\tposted,\n\t\t\t\t\t\tnotes,\n\t\t\t\t\t\treceipt)\n\t\t\t\t\tVALUES ('',\n\t\t\t\t\t\t'" . $_POST['SelectedTabs'] . "',\n\t\t\t\t\t\t'" . FormatDateForSQL($_POST['Date']) . "',\n\t\t\t\t\t\t'ASSIGNCASH',\n\t\t\t\t\t\t'" . filter_currency_input($_POST['Amount']) . "',\n\t\t\t\t\t\tauthorized = '0000-00-00',\n\t\t\t\t\t\t'0',\n\t\t\t\t\t\t'" . $_POST['Notes'] . "',\n\t\t\t\t\t\t'" . $_POST['Receipt'] . "'\n\t\t\t\t\t)";
     $msg = _('Assignment of cash to PC Tab ') . ' ' . $_POST['SelectedTabs'] . ' ' . _('has been created');
     unset($_POST['SelectedTabs']);
     unset($_POST['Date']);
     unset($_POST['Amount']);
     unset($_POST['Notes']);
     unset($_POST['Receipt']);
 }
 if ($InputError != 1) {
     //run the SQL from either of the above possibilites
     $result = DB_query($sql, $db);
     prnMsg($msg, 'success');
     unset($_POST['SelectedExpense']);
     unset($_POST['Amount']);
     unset($_POST['Notes']);
     unset($_POST['Receipt']);
Example #19
0
     foreach ($_SESSION['PO' . $identifier]->LineItems as $POLine) {
         if ($POLine->Deleted == true) {
             if ($POLine->PODetailRec != '') {
                 $sql = "DELETE FROM purchorderdetails WHERE podetailitem='" . $POLine->PODetailRec . "'";
                 $ErrMsg = _('The purchase order detail line could not be deleted because');
                 $DbgMsg = _('The SQL statement used to delete the purchase order detail record, that failed was');
                 $result = DB_query($sql, $db, $ErrMsg, $DbgMsg, true);
             }
         } else {
             if ($POLine->PODetailRec == '') {
                 $sql = "INSERT INTO purchorderdetails ( orderno,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\titemcode,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tdeliverydate,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\titemdescription,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tglcode,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tunitprice,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tquantityord,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tshiptref,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tjobref,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\titemno,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tuom,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tconversionfactor,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tsuppliers_partno,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tsubtotal_amount,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tpackage,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tpcunit,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tnetweight,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tgw,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tcuft,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\ttotal_quantity,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\ttotal_amount,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tassetid )\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tVALUES (\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t'" . $_SESSION['PO' . $identifier]->OrderNo . "',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t'" . $POLine->StockID . "',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t'" . FormatDateForSQL($POLine->ReqDelDate) . "',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t'" . $POLine->ItemDescription . "',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t'" . $POLine->GLCode . "',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t'" . $POLine->Price . "',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t'" . $POLine->Quantity . "',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t'" . $POLine->ShiptRef . "',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t'" . $POLine->JobRef . "',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t'" . $POLine->ItemNo . "',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t'" . $POLine->UOM . "',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t'" . $POLine->ConversionFactor . "',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t'" . $POLine->Suppliers_PartNo . "',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t'" . $POLine->SubTotal_Amount . "',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t'" . $POLine->Package . "',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t'" . $POLine->PcUnit . "',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t'" . $POLine->NetWeight . "',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t'" . $POLine->gw . "',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t'" . $POLine->CuFt . "',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t'" . $POLine->Total_Quantity . "',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t'" . filter_currency_input($POLine->Total_Amount) . "',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t'" . $POLine->AssetID . "')";
             } else {
                 if ($POLine->Quantity == $POLine->QtyReceived) {
                     $sql = "UPDATE purchorderdetails SET itemcode='" . $POLine->StockID . "',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tdeliverydate ='" . FormatDateForSQL($POLine->ReqDelDate) . "',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\titemdescription='" . $POLine->ItemDescription . "',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tglcode='" . $POLine->GLCode . "',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tunitprice='" . $POLine->Price . "',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tquantityord='" . $POLine->Quantity . "',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tshiptref='" . $POLine->ShiptRef . "',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tjobref='" . $POLine->JobRef . "',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\titemno='" . $POLine->ItemNo . "',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tuom='" . $POLine->UOM . "',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tconversionfactor='" . $POLine->ConversionFactor . "',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tsuppliers_partno='" . $POLine->Suppliers_PartNo . "',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tsubtotal_amount='" . $POLine->SubTotal_Amount . "',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tpackage='" . $POLine->Package . "',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tpcunit='" . $POLine->PcUnit . "',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tnetweight='" . $POLine->NetWeight . "',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tgw='" . $POLine->gw . "',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tcuft='" . $POLine->CuFt . "',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\ttotal_quantity='" . $POLine->Total_Quantity . "',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\ttotal_amount='" . filter_currency_input($POLine->Total_Amount) . "',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tcompleted=1,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tassetid='" . $POLine->AssetID . "'\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE podetailitem='" . $POLine->PODetailRec . "'";
                 } else {
                     $sql = "UPDATE purchorderdetails SET itemcode='" . $POLine->StockID . "',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tdeliverydate ='" . FormatDateForSQL($POLine->ReqDelDate) . "',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\titemdescription='" . $POLine->ItemDescription . "',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tglcode='" . $POLine->GLCode . "',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tunitprice='" . $POLine->Price . "',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tquantityord='" . $POLine->Quantity . "',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tshiptref='" . $POLine->ShiptRef . "',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tjobref='" . $POLine->JobRef . "',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\titemno='" . $POLine->ItemNo . "',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tuom='" . $POLine->UOM . "',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tconversionfactor='" . $POLine->ConversionFactor . "',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tsuppliers_partno='" . $POLine->Suppliers_PartNo . "',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tsubtotal_amount='" . $POLine->SubTotal_Amount . "',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tpackage='" . $POLine->Package . "',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tpcunit='" . $POLine->PcUnit . "',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tnetweight='" . $POLine->NetWeight . "',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tgw='" . $POLine->gw . "',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tcuft='" . $POLine->CuFt . "',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\ttotal_quantity='" . $POLine->Total_Quantity . "',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\ttotal_amount='" . filter_currency_input($POLine->Total_Amount) . "',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tassetid='" . $POLine->AssetID . "'\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE podetailitem='" . $POLine->PODetailRec . "'";
                 }
             }
         }
         $ErrMsg = _('One of the purchase order detail records could not be updated because');
         $DbgMsg = _('The SQL statement used to update the purchase order detail record that failed was');
         $result = DB_query($sql, $db, $ErrMsg, $DbgMsg, true);
     }
     /* end of the loop round the detail line items on the order */
     echo '<br /><br />';
     prnMsg(_('Purchase Order') . ' ' . $_SESSION['PO' . $identifier]->OrderNo . ' ' . _('has been updated'), 'success');
     if ($_SESSION['PO' . $identifier]->AllowPrintPO == 1) {
         //    echo '<br /><a target="_blank" href="'.$rootpath.'/PO_PDFPurchOrder.php?OrderNo=' . $_SESSION['PO'.$identifier]->OrderNo . '">' . _('Print Purchase Order') . '</a>';
     }
 }
 /*end of if its a new order or an existing one */
<?php

/* $Id$*/
/*The supplier transaction uses the SuppTrans class to hold the information about the credit note
the SuppTrans class contains an array of GRNs objects - containing details of GRNs for invoicing and also
an array of GLCodes objects - only used if the AP - GL link is effective */
include 'includes/DefineSuppTransClass.php';
/* Session started in header.inc for password checking and authorisation level check */
include 'includes/session.inc';
$title = _('Enter Supplier Credit Note Against Goods Received');
include 'includes/header.inc';
if (isset($_POST['ChgPrice'])) {
    $_POST['ChgPrice'] = filter_currency_input($_POST['ChgPrice']);
    $_POST['This_QuantityCredited'] = filter_number_input($_POST['This_QuantityCredited']);
}
echo '<p class="page_title_text"><img src="' . $rootpath . '/css/' . $theme . '/images/magnifier.png" title="' . _('Dispatch') . '" alt="" />' . ' ' . $title . '</p>';
if (!isset($_SESSION['SuppTrans'])) {
    prnMsg(_('To enter a supplier transactions the supplier must first be selected from the supplier selection screen') . ', ' . _('then the link to enter a supplier credit note must be clicked on'), 'info');
    echo '<br /><a href="' . $rootpath . '/SelectSupplier.php">' . _('Select A Supplier to Enter a Transaction For') . '</a>';
    include 'includes/footer.inc';
    exit;
    /*It all stops here if there aint no supplier selected and credit note initiated ie $_SESSION['SuppTrans'] started off*/
}
/*If the user hit the Add to Credit Note button then process this first before showing all GRNs on the credit note otherwise it wouldnt show the latest addition*/
if (isset($_POST['AddGRNToTrans'])) {
    $InputError = False;
    $Complete = False;
    if (!is_numeric($_POST['ChgPrice']) and $_POST['ChgPrice'] < 0) {
        $InputError = True;
        prnMsg(_('The price charged in the suppliers currency is either not numeric or negative') . '. ' . _('The goods received cannot be credited at this price'), 'error');
    }
         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(filter_currency_input($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']) {
Example #22
0
 $SQL = "SELECT period,\n\t\t\t\t\tbudget,\n\t\t\t\t\tactual\n\t\t\t\tFROM chartdetails\n\t\t\t\tWHERE accountcode='" . $SelectedAccount . "'";
 $result = DB_query($SQL, $db);
 while ($myrow = DB_fetch_array($result)) {
     $budget[$myrow['period']] = $myrow['budget'];
     $actual[$myrow['period']] = $myrow['actual'];
 }
 if (isset($_POST['apportion'])) {
     for ($i = 1; $i <= 12; $i++) {
         if ($_POST['AnnualAmountLY'] != '0' and is_numeric(filter_currency_input($_POST['AnnualAmountLY']))) {
             $budget[$CurrentYearEndPeriod + $i - 24] = filter_currency_input($_POST['AnnualAmountLY']) / 12;
         }
         if ($_POST['AnnualAmountTY'] != '0' and is_numeric(filter_currency_input($_POST['AnnualAmountTY']))) {
             $budget[$CurrentYearEndPeriod + $i - 12] = filter_currency_input($_POST['AnnualAmountTY']) / 12;
         }
         if ($_POST['AnnualAmount'] != '0' and is_numeric(filter_currency_input($_POST['AnnualAmount']))) {
             $budget[$CurrentYearEndPeriod + $i] = filter_currency_input($_POST['AnnualAmount']) / 12;
         }
     }
 }
 $LastYearActual = 0;
 $LastYearBudget = 0;
 $ThisYearActual = 0;
 $ThisYearBudget = 0;
 $NextYearActual = 0;
 $NextYearBudget = 0;
 // Table Headers
 echo '<form name="form" action="' . htmlspecialchars($_SERVER['PHP_SELF'], ENT_QUOTES, 'UTF-8') . '" method="post">';
 echo '<input type="hidden" name="FormID" value="' . $_SESSION['FormID'] . '" />';
 echo '<br /><table class="selection">';
 echo '<tr><th colspan="3">' . _('Last Financial Year') . '</th>';
 echo '<th colspan="3">' . _('This Financial Year') . '</th>';
		<td><select name="OverRideTax" onChange="ReloadForm(form1.ToggleTaxMethod)">';
if ($_POST['OverRideTax'] == 'Man') {
    echo '<option value="Auto">' . _('Automatic') . '</option>';
    echo '<option selected="True" value="Man">' . _('Manual Entry') . '</option>';
} else {
    echo '<option selected="True" value="Auto">' . _('Automatic') . '</option>';
    echo '<option value="Man">' . _('Manual Entry') . '</option>';
}
echo '</select></td></tr>';
$TaxTotal = 0;
//initialise tax total
foreach ($_SESSION['SuppTrans']->Taxes as $Tax) {
    echo '<tr><td>' . $Tax->TaxAuthDescription . '</td><td>';
    /*Set the tax rate to what was entered */
    if (isset($_POST['TaxRate' . $Tax->TaxCalculationOrder])) {
        $_SESSION['SuppTrans']->Taxes[$Tax->TaxCalculationOrder]->TaxRate = filter_currency_input($_POST['TaxRate' . $Tax->TaxCalculationOrder] / 100);
    }
    /*If a tax rate is entered that is not the same as it was previously then recalculate automatically the tax amounts */
    if (!isset($_POST['OverRideTax']) or $_POST['OverRideTax'] == 'Auto') {
        echo ' <input type="text" class="number" name=TaxRate' . $Tax->TaxCalculationOrder . ' maxlength="4" size="4" value="' . locale_money_format($_SESSION['SuppTrans']->Taxes[$Tax->TaxCalculationOrder]->TaxRate * 100, $_SESSION['SuppTrans']->CurrCode) . '" />%';
        /*Now recaluclate the tax depending on the method */
        if ($Tax->TaxOnTax == 1) {
            $_SESSION['SuppTrans']->Taxes[$Tax->TaxCalculationOrder]->TaxOvAmount = $_SESSION['SuppTrans']->Taxes[$Tax->TaxCalculationOrder]->TaxRate * ($_SESSION['SuppTrans']->OvAmount + $TaxTotal);
        } else {
            /*Calculate tax without the tax on tax */
            $_SESSION['SuppTrans']->Taxes[$Tax->TaxCalculationOrder]->TaxOvAmount = $_SESSION['SuppTrans']->Taxes[$Tax->TaxCalculationOrder]->TaxRate * $_SESSION['SuppTrans']->OvAmount;
        }
        echo '<input type="hidden" name="TaxAmount' . $Tax->TaxCalculationOrder . '"  value="' . locale_money_format($_SESSION['SuppTrans']->Taxes[$Tax->TaxCalculationOrder]->TaxOvAmount, $_SESSION['SuppTrans']->CurrCode) . '" />';
        echo '</td><td class="number">' . locale_money_format($_SESSION['SuppTrans']->Taxes[$Tax->TaxCalculationOrder]->TaxOvAmount, $_SESSION['SuppTrans']->CurrCode);
    } else {
        /*Tax being entered manually accept the taxamount entered as is*/
				<td><a href="' . htmlspecialchars($_SERVER['PHP_SELF'], ENT_QUOTES, 'UTF-8') . '?Delete=' . $LineItem->LineNumber . '" onclick="return confirm(\'' . _('Are you sure you wish to delete this line item from the credit note?') . '\');">' . _('Delete') . '</a></td>


				</tr>';
            echo $RowStarter;
            echo '<td colspan="11"><textarea  name="Narrative_' . $LineItem->LineNumber . '" cols="100%" rows="1">' . $LineItem->Narrative . '</textarea><br /></td></tr>';
            $_SESSION['CreditItems' . $identifier]->total = $_SESSION['CreditItems' . $identifier]->total + $LineTotal;
            $_SESSION['CreditItems' . $identifier]->totalVolume = $_SESSION['CreditItems' . $identifier]->totalVolume + $LineItem->Quantity * $LineItem->Volume;
            $_SESSION['CreditItems' . $identifier]->totalWeight = $_SESSION['CreditItems' . $identifier]->totalWeight + $LineItem->Quantity * $LineItem->Weight;
        }
        if (!isset($_POST['ChargeFreightCost']) and !isset($_SESSION['CreditItems' . $identifier]->FreightCost)) {
            $_POST['ChargeFreightCost'] = 0;
        } elseif (!isset($_POST['ChargeFreightCost'])) {
            $_POST['ChargeFreightCost'] = filter_currency_input($_SESSION['CreditItems' . $identifier]->FreightCost);
        } else {
            $_POST['ChargeFreightCost'] = filter_currency_input($_POST['ChargeFreightCost']);
        }
        echo '<tr>
			<td colspan="5"></td>';
        echo '<td colspan="2" class="number">' . _('Credit Freight') . '</td>
			<td><input type="text" class="number" size="6" maxlength="6" name="ChargeFreightCost" value="' . locale_money_format($_SESSION['CreditItems' . $identifier]->FreightCost, $_SESSION['CreditItems' . $identifier]->DefaultCurrency) . '" /></td>';
        $FreightTaxTotal = 0;
        //initialise tax total
        echo '<td>';
        $i = 0;
        // initialise the number of taxes iterated through
        foreach ($_SESSION['CreditItems' . $identifier]->FreightTaxes as $FreightTaxLine) {
            if ($i > 0) {
                echo '<br />';
            }
            echo $FreightTaxLine->TaxAuthDescription;
/*The supplier transaction uses the SuppTrans class to hold the information about the invoice
the SuppTrans class contains an array of Asset objects called Assets- containing details of all asset additions on a supplier invoice
Asset additions are posted to the debit of fixed asset category cost account if the creditors GL link is on */
include 'includes/DefineSuppTransClass.php';
/* Session started here for password checking and authorisation level check */
include 'includes/session.inc';
$title = _('Fixed Asset Charges or Credits');
include 'includes/header.inc';
if (!isset($_SESSION['SuppTrans'])) {
    prnMsg(_('Fixed asset additions or credits are entered against supplier invoices or credit notes respectively') . '. ' . _('To enter supplier transactions the supplier must first be selected from the supplier selection screen') . ', ' . _('then the link to enter a supplier invoice or credit note must be clicked on'), 'info');
    echo '<br /><a href="' . $rootpath . '/SelectSupplier.php">' . _('Select A Supplier') . '</a>';
    exit;
    /*It all stops here if there aint no supplier selected and invoice/credit initiated ie $_SESSION['SuppTrans'] started off*/
}
if (isset($_POST['Amount'])) {
    $_POST['Amount'] = filter_currency_input($_POST['Amount']);
}
if (isset($_POST['AddAssetToInvoice'])) {
    $InputError = False;
    if ($_POST['AssetID'] == '') {
        if ($_POST['AssetSelection'] == '') {
            $InputError = True;
            prnMsg(_('A valid asset must be either selected from the list or entered'), 'error');
        } else {
            $_POST['AssetID'] = $_POST['AssetSelection'];
        }
    } else {
        $result = DB_query("SELECT assetid FROM fixedassets WHERE assetid='" . $_POST['AssetID'] . "'", $db);
        if (DB_num_rows($result) == 0) {
            prnMsg(_('The asset ID entered manually is not a valid fixed asset. If you do not know the asset reference, select it from the list'), 'error');
            $InputError = True;
Example #26
0
     /* then enter GLTrans records for discount, bank and debtors */
     if ($BatchReceiptsTotal != 0) {
         /* Bank account entry first */
         $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\tnarrative,\n\t\t\t\t\t\t\t\t\t\tamount)\n\t\t\t\tVALUES (\n\t\t\t\t\t12,\n\t\t\t\t\t'" . $_SESSION['ReceiptBatch']->BatchNo . "',\n\t\t\t\t\t'" . FormatDateForSQL($_SESSION['ReceiptBatch']->DateBanked) . "',\n\t\t\t\t\t'" . $PeriodNo . "',\n\t\t\t\t\t'" . $_SESSION['ReceiptBatch']->Account . "',\n\t\t\t\t\t'" . $_SESSION['ReceiptBatch']->Narrative . "',\n\t\t\t\t\t'" . filter_currency_input($BatchReceiptsTotal) . "'\n\t\t\t\t)";
         $DbgMsg = _('The SQL that failed to insert the GL transaction fro the bank account debit was');
         $ErrMsg = _('Cannot insert a GL transaction for the bank account debit');
         $result = DB_query($SQL, $db, $ErrMsg, $DbgMsg, true);
         /*now enter the BankTrans entry */
         $SQL = "INSERT INTO banktrans (type,\n\t\t\t\t\t\t\t\t\t\ttransno,\n\t\t\t\t\t\t\t\t\t\tbankact,\n\t\t\t\t\t\t\t\t\t\tref,\n\t\t\t\t\t\t\t\t\t\texrate,\n\t\t\t\t\t\t\t\t\t\tfunctionalexrate,\n\t\t\t\t\t\t\t\t\t\ttransdate,\n\t\t\t\t\t\t\t\t\t\tbanktranstype,\n\t\t\t\t\t\t\t\t\t\tamount,\n\t\t\t\t\t\t\t\t\t\tcurrcode)\n\t\t\t\tVALUES (\n\t\t\t\t\t12,\n\t\t\t\t\t'" . $_SESSION['ReceiptBatch']->BatchNo . "',\n\t\t\t\t\t'" . $_SESSION['ReceiptBatch']->Account . "',\n\t\t\t\t\t'" . $_SESSION['ReceiptBatch']->Narrative . "',\n\t\t\t\t\t'" . $_SESSION['ReceiptBatch']->ExRate . "',\n\t\t\t\t\t'" . $_SESSION['ReceiptBatch']->FunctionalExRate . "',\n\t\t\t\t\t'" . FormatDateForSQL($_SESSION['ReceiptBatch']->DateBanked) . "',\n\t\t\t\t\t'" . $_SESSION['ReceiptBatch']->ReceiptType . "',\n\t\t\t\t\t'" . filter_currency_input($BatchReceiptsTotal * $_SESSION['ReceiptBatch']->FunctionalExRate * $_SESSION['ReceiptBatch']->ExRate) . "',\n\t\t\t\t\t'" . $_SESSION['ReceiptBatch']->Currency . "'\n\t\t\t\t)";
         $DbgMsg = _('The SQL that failed to insert the bank account transaction was');
         $ErrMsg = _('Cannot insert a bank transaction');
         $result = DB_query($SQL, $db, $ErrMsg, $DbgMsg, true);
     }
     if ($BatchDebtorTotal != 0) {
         /* Now Credit Debtors account with receipts + discounts */
         $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\tnarrative,\n\t\t\t\t\t\t\t\t\t\tamount)\n\t\t\t\t\t\tVALUES (\n\t\t\t\t\t\t\t12,\n\t\t\t\t\t\t\t'" . $_SESSION['ReceiptBatch']->BatchNo . "',\n\t\t\t\t\t\t\t'" . FormatDateForSQL($_SESSION['ReceiptBatch']->DateBanked) . "',\n\t\t\t\t\t\t\t'" . $PeriodNo . "',\n\t\t\t\t\t\t\t'" . $_SESSION['CompanyRecord']['debtorsact'] . "',\n\t\t\t\t\t\t\t'" . $_SESSION['ReceiptBatch']->Narrative . "',\n\t\t\t\t\t\t\t-" . filter_currency_input($BatchDebtorTotal) . "\n\t\t\t\t\t\t\t)";
         $DbgMsg = _('The SQL that failed to insert the GL transaction for the debtors account credit was');
         $ErrMsg = _('Cannot insert a GL transaction for the debtors account credit');
         $result = DB_query($SQL, $db, $ErrMsg, $DbgMsg, true);
     }
     //end if there are some customer deposits in this batch
     if ($BatchDiscount != 0) {
         /* Now Debit Discount account with discounts allowed*/
         $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\tnarrative,\n\t\t\t\t\t\t\t\t\t\tamount)\n\t\t\t\t\t\tVALUES (\n\t\t\t\t\t\t\t\t12,\n\t\t\t\t\t\t\t\t'" . $_SESSION['ReceiptBatch']->BatchNo . "',\n\t\t\t\t\t\t\t\t'" . FormatDateForSQL($_SESSION['ReceiptBatch']->DateBanked) . "',\n\t\t\t\t\t\t\t\t'" . $PeriodNo . "',\n\t\t\t\t\t\t\t\t'" . $_SESSION['CompanyRecord']['pytdiscountact'] . "',\n\t\t\t\t\t\t\t\t'" . $_SESSION['ReceiptBatch']->Narrative . "',\n\t\t\t\t\t\t\t\t'" . $BatchDiscount . "'\n\t\t\t\t\t\t\t)";
         $DbgMsg = _('The SQL that failed to insert the GL transaction for the payment discount debit was');
         $ErrMsg = _('Cannot insert a GL transaction for the payment discount debit');
         $result = DB_query($SQL, $db, $ErrMsg, $DbgMsg, true);
     }
     //end if there is some discount
 }
 //end if there is GL work to be done - ie config is to link to GL
Example #27
0
                $sql = "SELECT description, decimalplaces FROM stockmaster WHERE stockid='" . $StockID . "'";
                $result = DB_query($sql, $db);
                $myrow = DB_fetch_array($result);
                $_SESSION['offer' . $identifier]->add_to_offer($_SESSION['offer' . $identifier]->LinesOnOffer, $StockID, $Quantity, $myrow['description'], $Price, $UOM, $myrow['decimalplaces'], DateAdd(date($_SESSION['DefaultDateFormat']), 'm', 3));
                unset($UOM);
            }
        }
    }
}
if (isset($_POST['Refresh']) and !isset($_POST['NewItem'])) {
    foreach ($_POST as $key => $value) {
        if (mb_substr($key, 0, 7) == 'StockID') {
            $Index = mb_substr($key, 7, mb_strlen($key) - 7);
            $StockID = $value;
            $Quantity = filter_number_input($_POST['Qty' . $Index]);
            $Price = filter_currency_input($_POST['Price' . $Index]);
            $ExpiryDate = $_POST['expirydate' . $Index];
        }
        if (isset($ExpiryDate)) {
            $_SESSION['offer' . $identifier]->update_offer_item($Index, $Quantity, $Price, $ExpiryDate);
            unset($ExpiryDate);
        }
    }
}
if (isset($_POST['Update'])) {
    foreach ($_POST as $key => $value) {
        if (mb_substr($key, 0, 3) == 'Qty') {
            $LineNo = mb_substr($key, 3);
            $Quantity = $value;
        }
        if (mb_substr($key, 0, 5) == 'Price') {
Example #28
0
    include 'includes/GLPostings.inc';
    include 'includes/footer.inc';
    exit;
} elseif (isset($_GET['Delete'])) {
    /* User hit delete the line from the journal */
    $_SESSION['JournalDetail']->Remove_GLEntry($_GET['Delete']);
} elseif (isset($_POST['Process'])) {
    //user hit submit a new GL Analysis line into the journal
    if ($_POST['GLCode'] != '') {
        $extract = explode(' - ', $_POST['GLCode']);
        $_POST['GLCode'] = $extract[0];
    }
    if ($_POST['Debit'] > 0) {
        $_POST['GLAmount'] = filter_currency_input($_POST['Debit']);
    } elseif ($_POST['Credit'] > 0) {
        $_POST['GLAmount'] = '-' . filter_currency_input($_POST['Credit']);
    }
    if ($_POST['GLManualCode'] != '' and is_numeric($_POST['GLManualCode'])) {
        // If a manual code was entered need to check it exists and isnt a bank account
        $AllowThisPosting = true;
        //by default
        if ($_SESSION['ProhibitJournalsToControlAccounts'] == 1) {
            if ($_SESSION['CompanyRecord']['gllink_debtors'] == '1' and $_POST['GLManualCode'] == $_SESSION['CompanyRecord']['debtorsact']) {
                prnMsg(_('GL Journals involving the debtors control account cannot be entered. The general ledger debtors ledger (AR) integration is enabled so control accounts are automatically maintained by webERP. This setting can be disabled in System Configuration'), 'warn');
                $AllowThisPosting = false;
            }
            if ($_SESSION['CompanyRecord']['gllink_creditors'] == '1' and $_POST['GLManualCode'] == $_SESSION['CompanyRecord']['creditorsact']) {
                prnMsg(_('GL Journals involving the creditors control account cannot be entered. The general ledger creditors ledger (AP) integration is enabled so control accounts are automatically maintained by webERP. This setting can be disabled in System Configuration'), 'warn');
                $AllowThisPosting = false;
            }
        }
        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'] . "'";
    $ErrMsg = _('The authentication details cannot be updated because');
    $Result = DB_query($sql, $db, $ErrMsg);
}
if (isset($_GET['Delete'])) {
    $sql = "DELETE FROM purchorderauth\n\t\tWHERE userid='" . $_GET['UserID'] . "'\n\t\tAND currabrev='" . $_GET['Currency'] . "'";
    $ErrMsg = _('The authentication details cannot be deleted because');
    $Result = DB_query($sql, $db, $ErrMsg);
}
$sql = "SELECT\n\tpurchorderauth.userid,\n\twww_users.realname,\n\tcurrencies.currabrev,\n\tcurrencies.currency,\n\tpurchorderauth.cancreate,\n\tpurchorderauth.offhold,\n\tpurchorderauth.authlevel\n\tFROM (purchorderauth\n\tLEFT JOIN www_users ON purchorderauth.userid=www_users.userid)\n\tLEFT JOIN currencies ON purchorderauth.currabrev=currencies.currabrev";
$ErrMsg = _('The authentication details cannot be retrieved because');
$Result = DB_query($sql, $db, $ErrMsg);
echo '<table class="selection"><tr>';
echo '<th>' . _('User ID') . '</th>';
echo '<th>' . _('User Name') . '</th>';
echo '<th>' . _('Currency') . '</th>';
Example #30
0
     }
     /*Now need to update the invoice DebtorTrans record for the amount to be allocated and if the invoice is now settled*/
     $SQL = "UPDATE debtortrans\n\t\t\tSET alloc = alloc + " . $Allocate_amount . ",\n\t\t\tsettled='" . $SettledInvoice . "'\n\t\t\tWHERE transno = '" . $_SESSION['ProcessingCredit'] . "'\n\t\t\tAND type=10";
     $ErrMsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('The alteration to the invoice record to reflect the allocation of the credit note to the invoice could not be done because');
     $DbgMsg = _('The following SQL to update the invoice allocation was used');
     $Result = DB_query($SQL, $db, $ErrMsg, $DbgMsg, true);
 }
 /*Now insert the Credit Note into the DebtorTrans table with the allocations as calculated above*/
 $SQL = "INSERT INTO debtortrans (transno,\n\t\t\t\t\ttype,\n\t\t\t\t\tdebtorno,\n\t\t\t\t\tbranchcode,\n\t\t\t\t\ttrandate,\n\t\t\t\t\tinputdate,\n\t\t\t\t\tprd,\n\t\t\t\t\treference,\n\t\t\t\t\ttpe,\n\t\t\t\t\torder_,\n\t\t\t\t\tovamount,\n\t\t\t\t\tovgst,\n\t\t\t\t\tovfreight,\n\t\t\t\t\trate,\n\t\t\t\t\tinvtext,\n\t\t\t\t\talloc,\n\t\t\t\t\tsettled)\n\t\tVALUES (" . $CreditNo . ",\n\t\t\t11,\n\t\t\t'" . $_SESSION['CreditItems']->DebtorNo . "',\n\t\t\t'" . $_SESSION['CreditItems']->Branch . "',\n\t\t\t'" . $DefaultDispatchDate . "',\n\t\t\t'" . date('Y-m-d H-i-s') . "',\n\t\t\t'" . $PeriodNo . "',\n\t\t\t'Inv-" . $_SESSION['ProcessingCredit'] . "',\n\t\t\t'" . $_SESSION['CreditItems']->DefaultSalesType . "',\n\t\t\t'" . $_SESSION['CreditItems']->OrderNo . "',\n\t\t\t-" . filter_currency_input($_SESSION['CreditItems']->total) . ",\n\t\t\t-" . filter_currency_input($TaxTotal) . ",\n\t\t\t-" . filter_currency_input($_SESSION['CreditItems']->FreightCost) . ",\n\t\t\t'" . $_SESSION['CurrencyRate'] . "',\n\t\t\t'" . $_POST['CreditText'] . "',\n\t\t\t-" . filter_currency_input($Allocate_amount) . ",\n\t\t\t'" . $Settled . "')";
 $ErrMsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('The customer credit note transaction could not be added to the database because');
 $DbgMsg = _('The following SQL to insert the customer credit note was used');
 $Result = DB_query($SQL, $db, $ErrMsg, $DbgMsg, true);
 $CreditTransID = DB_Last_Insert_ID($db, 'debtortrans', 'id');
 /* Insert the tax totals for each tax authority where tax was charged on the invoice */
 foreach ($TaxTotals as $TaxAuthID => $TaxAmount) {
     $SQL = "INSERT INTO debtortranstaxes (\n\t\t\t\t\t\t\tdebtortransid,\n\t\t\t\t\t\t\ttaxauthid,\n\t\t\t\t\t\t\ttaxamount)\n\t\t\t\tVALUES ('" . $CreditTransID . "',\n\t\t\t\t\t'" . $TaxAuthID . "',\n\t\t\t\t\t'-" . filter_currency_input($TaxAmount / $_SESSION['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);
 }
 /*Now insert the allocation record if > 0 */
 if ($Allocate_amount != 0) {
     $SQL = "INSERT INTO custallocns (amt,\n\t\t\t\t\t\ttransid_allocfrom,\n\t\t\t\t\t\ttransid_allocto,\n\t\t\t\t\t\tdatealloc)\n\t\t\tVALUES ('" . $Allocate_amount . "',\n\t\t\t\t'" . $CreditTransID . "',\n\t\t\t\t'" . $_SESSION['CreditItems']->TransID . "',\n\t\t\t\t'" . Date('Y-m-d') . "')";
     $ErrMsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('The allocation record for the credit note could not be added to the database because');
     $DbgMsg = _('The following SQL to insert the allocation record for the credit note was used');
     $Result = DB_query($SQL, $db, $ErrMsg, $DbgMsg, true);
 }
 /* Update sales order details quantity invoiced less this credit quantity. */
 foreach ($_SESSION['CreditItems']->LineItems as $CreditLine) {
     if ($CreditLine->QtyDispatched > 0) {
         $LocalCurrencyPrice = round($CreditLine->Price / $_SESSION['CurrencyRate'], 2);