Ejemplo n.º 1
0
        $_SESSION['Adjustment' . $identifier]->Quantity = 0;
    }
    $NewAdjustment = true;
} elseif (isset($_POST['StockID'])) {
    if (isset($_POST['StockID']) and $_POST['StockID'] != $_SESSION['Adjustment' . $identifier]->StockID) {
        $NewAdjustment = true;
        $_SESSION['Adjustment' . $identifier]->StockID = trim(mb_strtoupper($_POST['StockID']));
        $StockID = trim(mb_strtoupper($_POST['StockID']));
    }
    $_SESSION['Adjustment' . $identifier]->tag = $_POST['tag'];
    $_SESSION['Adjustment' . $identifier]->Narrative = $_POST['Narrative'];
    $_SESSION['Adjustment' . $identifier]->StockLocation = $_POST['StockLocation'];
    if ($_POST['Quantity'] == '') {
        $_POST['Quantity'] = 0;
    } else {
        $_POST['Quantity'] = filter_number_input($_POST['Quantity']);
    }
    $_SESSION['Adjustment' . $identifier]->Quantity = $_POST['Quantity'];
}
echo '<p class="page_title_text"><img src="' . $rootpath . '/css/' . $theme . '/images/supplier.png" title="' . _('Inventory Adjustment') . '" alt="" />' . ' ' . _('Inventory Adjustment') . '</p>';
if (isset($_POST['CheckCode'])) {
    echo '<p class="page_title_text"><img src="' . $rootpath . '/css/' . $theme . '/images/magnifier.png" title="' . _('Dispatch') . '" alt="" />' . ' ' . _('Select Item to Adjust') . '</p>';
    if (mb_strlen($_POST['StockText']) > 0) {
        $sql = "SELECT stockid, description FROM stockmaster WHERE description LIKE '%" . $_POST['StockText'] . "%'";
    } else {
        $sql = "SELECT stockid, description FROM stockmaster WHERE stockid LIKE '%" . $_POST['StockCode'] . "%'";
    }
    $ErrMsg = _('The stock information cannot be retrieved because');
    $DbgMsg = _('The SQL to get the stock description was');
    $result = DB_query($sql, $db, $ErrMsg, $DbgMsg);
    echo '<table class="selection">
Ejemplo n.º 2
0
            if (isset($UOM) and $Quantity > 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;
        }
Ejemplo n.º 3
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']);
Ejemplo n.º 4
0
     prnMsg(_('The price entered was not numeric and a number is expected. No changes have been made to the database'), 'error');
 }
 if ($_POST['Price'] == 0) {
     prnMsg(_('The price entered is zero') . '   ' . _('Is this intentional?'), 'warn');
 }
 if (!is_numeric(filter_number_input($_POST['LeadTime']))) {
     $InputError = 1;
     unset($_POST['LeadTime']);
     prnMsg(_('The lead time entered was not numeric a number of days is expected no changes have been made to the database'), 'error');
 }
 if (!is_numeric(filter_number_input($_POST['MinOrderQty']))) {
     $InputError = 1;
     unset($_POST['MinOrderQty']);
     prnMsg(_('The minimum order quantity was not numeric and a number is expected no changes have been made to the database'), 'error');
 }
 if (!is_numeric(filter_number_input($_POST['ConversionFactor']))) {
     $InputError = 1;
     unset($_POST['ConversionFactor']);
     prnMsg(_('The conversion factor entered was not numeric') . ' (' . _('a number is expected') . '). ' . _('The conversion factor is the number which the price must be divided by to get the unit price in our unit of measure') . '. <br />' . _('E.g.') . ' ' . _('The supplier sells an item by the tonne and we hold stock by the kg') . '. ' . _('The suppliers price must be divided by 1000 to get to our cost per kg') . '. ' . _('The conversion factor to enter is 1000') . '. <br /><br />' . _('No changes will be made to the database'), 'error');
 }
 if ($InputError == 0 and isset($_POST['AddRecord'])) {
     $sql = "INSERT INTO purchdata (supplierno,\n\t\t\t\t\t\t\t\t\t\tstockid,\n\t\t\t\t\t\t\t\t\t\tprice,\n\t\t\t\t\t\t\t\t\t\teffectivefrom,\n\t\t\t\t\t\t\t\t\t\tsuppliersuom,\n\t\t\t\t\t\t\t\t\t\tconversionfactor,\n\t\t\t\t\t\t\t\t\t\tuomdecimalplaces,\n\t\t\t\t\t\t\t\t\t\tsupplierdescription,\n\t\t\t\t\t\t\t\t\t\tsuppliers_partno,\n\t\t\t\t\t\t\t\t\t\tleadtime,\n\t\t\t\t\t\t\t\t\t\tminorderqty,\n\t\t\t\t\t\t\t\t\t\tpreferred)\n\t\t\t\t\t\t\t\t\tVALUES ('" . $SupplierID . "',\n\t\t\t\t\t\t\t\t\t\t'" . $StockID . "',\n\t\t\t\t\t\t\t\t\t\t'" . filter_currency_input($_POST['Price']) . "',\n\t\t\t\t\t\t\t\t\t\t'" . FormatDateForSQL($_POST['EffectiveFrom']) . "',\n\t\t\t\t\t\t\t\t\t\t'" . $_POST['SuppliersUOM'] . "',\n\t\t\t\t\t\t\t\t\t\t'" . $_POST['ConversionFactor'] . "',\n\t\t\t\t\t\t\t\t\t\t'" . $_POST['DecimalPlaces'] . "',\n\t\t\t\t\t\t\t\t\t\t'" . $_POST['SupplierDescription'] . "',\n\t\t\t\t\t\t\t\t\t\t'" . $_POST['SupplierCode'] . "',\n\t\t\t\t\t\t\t\t\t\t'" . $_POST['LeadTime'] . "',\n\t\t\t\t\t\t\t\t\t\t'" . $_POST['MinOrderQty'] . "',\n\t\t\t\t\t\t\t\t\t\t'" . $_POST['Preferred'] . "'\n\t\t\t\t\t\t\t\t\t)";
     $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');
Ejemplo n.º 5
0
     //page called attempting to delete a line - GET['Delete'] = the line number to delete
     $QuantityAlreadyDelivered = $_SESSION['Items' . $identifier]->Some_Already_Delivered($_GET['Delete']);
     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 = '';
         }
Ejemplo n.º 6
0
function LevelNetting(&$db, $part, $eoq, $PanSize, $ShrinkFactor, $LeadTime)
{
    // Create an array of mrprequirements and an array of mrpsupplies, then read through
    // them seeing if all requirements are covered by supplies. Create a planned order
    // for any unmet requirements. Change dates if necessary for the supplies.
    //echo '<br />Part is ' . "$part" . '<br />';
    // Get decimal places from stockmaster for rounding of shrinkage factor
    $sql = "SELECT decimalplaces FROM stockmaster WHERE stockid = '" . $part . "'";
    $result = DB_query($sql, $db);
    $myrow = DB_fetch_row($result);
    $DecimalPlaces = $myrow[0];
    // Load mrprequirements into $Requirements array
    $sql = "SELECT * FROM mrprequirements WHERE part = '" . $part . "' ORDER BY daterequired";
    $result = DB_query($sql, $db);
    $Requirements = array();
    $i = 0;
    while ($myrow = DB_fetch_array($result)) {
        array_push($Requirements, $myrow);
        $i++;
    }
    //end of while loop
    // Load mrpsupplies into $Supplies array
    $sql = "SELECT * FROM mrpsupplies WHERE part = '" . $part . "' ORDER BY duedate";
    $result = DB_query($sql, $db);
    $Supplies = array();
    $i = 0;
    while ($myrow = DB_fetch_array($result)) {
        array_push($Supplies, $myrow);
        $i++;
    }
    //end of while loop
    // Go through all requirements and check if have supplies to cover them
    $RequirementCount = count($Requirements);
    $SupplyCount = count($Supplies);
    $reqi = 0;
    //Index for requirements
    $supi = 0;
    // index for supplies
    $TotalRequirement = 0;
    $TotalSupply = 0;
    if ($RequirementCount > 0 && $SupplyCount > 0) {
        $TotalRequirement += $Requirements[$reqi]['quantity'];
        $TotalSupply += $Supplies[$supi]['supplyquantity'];
        while ($TotalRequirement > 0 && $TotalSupply > 0) {
            $Supplies[$supi]['updateflag'] = 1;
            // ******** Put leeway calculation in here ********
            $DueDate = ConvertSQLDate($Supplies[$supi]['duedate']);
            $ReqDate = ConvertSQLDate($Requirements[$reqi]['daterequired']);
            $DateDiff = DateDiff($DueDate, $ReqDate, 'd');
            //if ($Supplies[$supi]['duedate'] > $Requirements[$reqi]['daterequired']) {
            if ($DateDiff > abs(filter_number_input($_POST['Leeway']))) {
                $sql = "UPDATE mrpsupplies SET mrpdate = '" . $Requirements[$reqi]['daterequired'] . "' WHERE id = '" . $Supplies[$supi]['id'] . "' AND duedate = mrpdate";
                $result = DB_query($sql, $db);
            }
            if ($TotalRequirement > $TotalSupply) {
                $TotalRequirement -= $TotalSupply;
                $Requirements[$reqi]['quantity'] -= $TotalSupply;
                $TotalSupply = 0;
                $Supplies[$supi]['supplyquantity'] = 0;
                $supi++;
                if ($SupplyCount > $supi) {
                    $TotalSupply += $Supplies[$supi]['supplyquantity'];
                }
            } else {
                $TotalSupply -= $TotalRequirement;
                $Supplies[$supi]['supplyquantity'] -= $TotalRequirement;
                $TotalRequirement = 0;
                $Requirements[$reqi]['quantity'] = 0;
                $reqi++;
                if ($RequirementCount > $reqi) {
                    $TotalRequirement += $Requirements[$reqi]['quantity'];
                }
            }
            // End of if $TotalRequirement > $TotalSupply
        }
        // End of while
    }
    // End of if
    // When get to this part of code, have gone through all requirements, If there is any
    // unmet requirements, create an mrpplannedorder to cover it. Also call the
    // CreateLowerLevelRequirement() function to create gross requirements for lower level parts.
    // There is an excess quantity if the eoq is higher than the actual required amount.
    // If there is a subsuquent requirement, the excess quantity is subtracted from that
    // quantity. For instance, if the first requirement was for 2 and the eoq was 5, there
    // would be an excess of 3; if there was another requirement for 3 or less, the excess
    // would cover it, so no planned order would have to be created for the second requirement.
    $ExcessQty = 0;
    foreach ($Requirements as $key => $row) {
        $DateRequired[$key] = $row['daterequired'];
    }
    if (count($Requirements)) {
        array_multisort($DateRequired, SORT_ASC, $Requirements);
    }
    foreach ($Requirements as $Requirement) {
        // First, inflate requirement if there is a shrinkage factor
        // Should the quantity be rounded?
        if ($_POST['shrinkageflag'] == 'y' and $ShrinkFactor > 0) {
            $Requirement['quantity'] = $Requirement['quantity'] * 100 / (100 - $ShrinkFactor);
            $Requirement['quantity'] = round($Requirement['quantity'], $DecimalPlaces);
        }
        if ($ExcessQty >= $Requirement['quantity']) {
            $PlannedQty = 0;
            $ExcessQty -= $Requirement['quantity'];
        } else {
            $PlannedQty = $Requirement['quantity'] - $ExcessQty;
            $ExcessQty = 0;
        }
        if ($PlannedQty > 0) {
            if ($_POST['eoqflag'] == 'y' and $eoq > $PlannedQty) {
                $ExcessQty = $eoq - $PlannedQty;
                $PlannedQty = $eoq;
            }
            // Pansize calculation here
            // if $PlannedQty not evenly divisible by $PanSize, calculate as $PlannedQty
            // divided by $PanSize and rounded up to the next highest integer and then
            // multiplied by the pansize. For instance, with a planned qty of 17 with a pansize
            // of 5, divide 17 by 5 to get 3 with a remainder of 2, which is rounded up to 4
            // and then multiplied by 5 - the pansize - to get 20
            if ($_POST['pansizeflag'] == 'y' and $PanSize != 0 and $PlannedQty != 0) {
                $PlannedQty = ceil($PlannedQty / $PanSize) * $PanSize;
            }
            // Calculate required date by subtracting leadtime from top part's required date
            $PartRequiredDate = $Requirement['daterequired'];
            if ((int) $LeadTime > 0) {
                $CalendarSQL = "SELECT COUNT(*),cal2.calendardate\n\t\t\t\t\t\t  FROM mrpcalendar\n\t\t\t\t\t\t\tLEFT JOIN mrpcalendar as cal2\n\t\t\t\t\t\t\t  ON (mrpcalendar.daynumber - '" . $LeadTime . "') = cal2.daynumber\n\t\t\t\t\t\t  WHERE mrpcalendar.calendardate = '" . $PartRequiredDate . "'\n\t\t\t\t\t\t\tAND cal2.manufacturingflag='1'\n\t\t\t\t\t\t\tGROUP BY cal2.calendardate";
                $ResultDate = DB_query($CalendarSQL, $db);
                $myrowdate = DB_fetch_array($ResultDate);
                $NewDate = $myrowdate[1];
                // If can't find date based on manufacturing calendar, use $PartRequiredDate
            } else {
                // Convert $PartRequiredDate from mysql format to system date format, use that to subtract leadtime
                // from it using DateAdd, convert that date back to mysql format
                $ConvertDate = ConvertSQLDate($PartRequiredDate);
                $DateAdd = DateAdd($ConvertDate, 'd', $LeadTime * -1);
                $NewDate = FormatDateForSQL($DateAdd);
            }
            $sql = "INSERT INTO mrpplannedorders (id,\n\t\t\t\t\t\t\t\t\t\t\t\tpart,\n\t\t\t\t\t\t\t\t\t\t\t\tduedate,\n\t\t\t\t\t\t\t\t\t\t\t\tsupplyquantity,\n\t\t\t\t\t\t\t\t\t\t\t\tordertype,\n\t\t\t\t\t\t\t\t\t\t\t\torderno,\n\t\t\t\t\t\t\t\t\t\t\t\tmrpdate,\n\t\t\t\t\t\t\t\t\t\t\t\tupdateflag)\n\t\t\t\t\t\t\t\t\t\t\tVALUES (NULL,\n\t\t\t\t\t\t\t\t\t\t\t\t'" . $Requirement['part'] . "',\n\t\t\t\t\t\t\t\t\t\t\t\t'" . $NewDate . "',\n\t\t\t\t\t\t\t\t\t\t\t\t'" . $PlannedQty . "',\n\t\t\t\t\t\t\t\t\t\t\t\t'" . $Requirement['mrpdemandtype'] . "',\n\t\t\t\t\t\t\t\t\t\t\t\t'" . $Requirement['orderno'] . "',\n\t\t\t\t\t\t\t\t\t\t\t\t'" . $NewDate . "',\n\t\t\t\t\t\t\t\t\t\t\t\t'0')";
            $result = DB_query($sql, $db);
            // If part has lower level components, create requirements for them
            $sql = "SELECT COUNT(*) FROM bom\n\t\t\t\t\t  WHERE parent ='" . $Requirement['part'] . "'\n\t\t\t\t\t  GROUP BY parent";
            $result = DB_query($sql, $db);
            $myrow = DB_fetch_row($result);
            if ($myrow[0] > 0) {
                CreateLowerLevelRequirement($db, $Requirement['part'], $Requirement['daterequired'], $PlannedQty, $Requirement['mrpdemandtype'], $Requirement['orderno'], $Requirement['whererequired']);
            }
        }
        // End of if $PlannedQty > 0
    }
    // End of foreach $Requirements
    // If there are any supplies not used and updateflag is zero, those supplies are not
    // necessary, so change date
    foreach ($Supplies as $supply) {
        if ($supply['supplyquantity'] > 0 && $supply['updateflag'] == 0) {
            $id = $supply['id'];
            $sql = "UPDATE mrpsupplies SET mrpdate ='2050-12-31' WHERE id = '" . $id . "'\n\t\t\t\t\t  AND ordertype <> 'QOH'";
            $result = DB_query($sql, $db);
        }
    }
}
Ejemplo n.º 7
0
        if ($_POST['FromStockLocation'] == $_POST['ToStockLocation']) {
            $InputError = True;
            $ErrorMessage .= _('The transfer must have a different location to receive into and location sent from');
        }
    }
    //end if the transfer is not a duplicated
}
if (isset($_POST['Submit']) and $InputError == False) {
    $ErrMsg = _('CRITICAL ERROR') . '! ' . _('Unable to BEGIN Location Transfer transaction');
    DB_Txn_Begin($db);
    for ($i = 0; $i < $_POST['LinesCounter']; $i++) {
        if ($_POST['StockID' . $i] != '') {
            $DecimalsSql = "SELECT decimalplaces\n\t\t\t\t\t\t\tFROM stockmaster\n\t\t\t\t\t\t\tWHERE stockid='" . $_POST['StockID' . $i] . "'";
            $DecimalResult = DB_Query($DecimalsSql, $db);
            $DecimalRow = DB_fetch_array($DecimalResult);
            $sql = "INSERT INTO loctransfers (reference,\n\t\t\t\t\t\t\t\tstockid,\n\t\t\t\t\t\t\t\tshipqty,\n\t\t\t\t\t\t\t\tshipdate,\n\t\t\t\t\t\t\t\tshiploc,\n\t\t\t\t\t\t\t\trecloc)\n\t\t\t\t\t\tVALUES ('" . $_POST['Trf_ID'] . "',\n\t\t\t\t\t\t\t'" . $_POST['StockID' . $i] . "',\n\t\t\t\t\t\t\t'" . round(filter_number_input($_POST['StockQTY' . $i]), $DecimalRow['decimalplaces']) . "',\n\t\t\t\t\t\t\t'" . Date('Y-m-d') . "',\n\t\t\t\t\t\t\t'" . $_POST['FromStockLocation'] . "',\n\t\t\t\t\t\t\t'" . $_POST['ToStockLocation'] . "')";
            $ErrMsg = _('CRITICAL ERROR') . '! ' . _('Unable to enter Location Transfer record for') . ' ' . $_POST['StockID' . $i];
            $resultLocShip = DB_query($sql, $db, $ErrMsg);
        }
    }
    $ErrMsg = _('CRITICAL ERROR') . '! ' . _('Unable to COMMIT Location Transfer transaction');
    DB_Txn_Commit($db);
    prnMsg(_('The inventory transfer records have been created successfully'), 'success');
    echo '<p><a href="' . $rootpath . '/PDFStockLocTransfer.php?TransferNo=' . $_POST['Trf_ID'] . '">' . _('Print the Transfer Docket') . '</a></p>';
    include 'includes/footer.inc';
} else {
    //Get next Inventory Transfer Shipment Reference Number
    if (isset($_GET['Trf_ID'])) {
        $Trf_ID = $_GET['Trf_ID'];
    } elseif (isset($_POST['Trf_ID'])) {
        $Trf_ID = $_POST['Trf_ID'];
Ejemplo n.º 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'
Ejemplo n.º 9
0
<?php

/* $Id$*/
include 'includes/session.inc';
if (isset($_POST['PrintPDF'])) {
    include 'includes/PDFStarter.php';
    $pdf->addInfo('Title', _('Customer Listing'));
    $pdf->addInfo('Subject', _('Customer Listing'));
    $line_height = 12;
    $PageNumber = 0;
    $FontSize = 10;
    if ($_POST['Activity'] != 'All') {
        $_POST['ActivityAmount'] = filter_number_input($_POST['ActivityAmount']);
        if (!is_numeric($_POST['ActivityAmount'])) {
            $title = _('Customer List') . ' - ' . _('Problem Report') . '....';
            include 'includes/header.inc';
            echo '<br />';
            prnMsg(_('The activity amount is not numeric and you elected to print customer relative to a certain amount of activity') . ' - ' . _('this level of activity must be specified in the local currency') . '.', 'error');
            include 'includes/footer.inc';
            exit;
        }
    }
    /* Now figure out the customer data to report for the selections made */
    if (in_array('All', $_POST['Areas'])) {
        if (in_array('All', $_POST['SalesPeople'])) {
            $SQL = "SELECT debtorsmaster.debtorno,\n\t\t\t\t\tdebtorsmaster.name,\n\t\t\t\t\tdebtorsmaster.address1,\n\t\t\t\t\tdebtorsmaster.address2,\n\t\t\t\t\tdebtorsmaster.address3,\n\t\t\t\t\tdebtorsmaster.address4,\n\t\t\t\t\tdebtorsmaster.address5,\n\t\t\t\t\tdebtorsmaster.address6,\n\t\t\t\t\tdebtorsmaster.salestype,\n\t\t\t\t\tcustbranch.branchcode,\n\t\t\t\t\tcustbranch.brname,\n\t\t\t\t\tcustbranch.braddress1,\n\t\t\t\t\tcustbranch.braddress2,\n\t\t\t\t\tcustbranch.braddress3,\n\t\t\t\t\tcustbranch.braddress4,\n\t\t\t\t\tcustbranch.braddress5,\n\t\t\t\t\tcustbranch.braddress6,\n\t\t\t\t\tcustbranch.contactname,\n\t\t\t\t\tcustbranch.phoneno,\n\t\t\t\t\tcustbranch.faxno,\n\t\t\t\t\tcustbranch.email,\n\t\t\t\t\tcustbranch.area,\n\t\t\t\t\tcustbranch.salesman,\n\t\t\t\t\tareas.areadescription,\n\t\t\t\t\tsalesman.salesmanname\n\t\t\t\tFROM debtorsmaster INNER JOIN custbranch\n\t\t\t\tON debtorsmaster.debtorno=custbranch.debtorno\n\t\t\t\tINNER JOIN areas\n\t\t\t\tON custbranch.area = areas.areacode\n\t\t\t\tINNER JOIN salesman\n\t\t\t\tON custbranch.salesman=salesman.salesmancode\n\t\t\t\tORDER BY area,\n\t\t\t\t\tsalesman,\n\t\t\t\t\tdebtorsmaster.debtorno,\n\t\t\t\t\tcustbranch.branchcode";
        } else {
            /* there are a range of salesfolk selected need to build the where clause */
            $SQL = "SELECT debtorsmaster.debtorno,\n\t\t\t\t\tdebtorsmaster.name,\n\t\t\t\t\tdebtorsmaster.address1,\n\t\t\t\t\tdebtorsmaster.address2,\n\t\t\t\t\tdebtorsmaster.address3,\n\t\t\t\t\tdebtorsmaster.address4,\n\t\t\t\t\tdebtorsmaster.address5,\n\t\t\t\t\tdebtorsmaster.address6,\n\t\t\t\t\tdebtorsmaster.salestype,\n\t\t\t\t\tcustbranch.branchcode,\n\t\t\t\t\tcustbranch.brname,\n\t\t\t\t\tcustbranch.braddress1,\n\t\t\t\t\tcustbranch.braddress2,\n\t\t\t\t\tcustbranch.braddress3,\n\t\t\t\t\tcustbranch.braddress4,\n\t\t\t\t\tcustbranch.braddress5,\n\t\t\t\t\tcustbranch.braddress6,\n\t\t\t\t\tcustbranch.contactname,\n\t\t\t\t\tcustbranch.phoneno,\n\t\t\t\t\tcustbranch.faxno,\n\t\t\t\t\tcustbranch.email,\n\t\t\t\t\tcustbranch.area,\n\t\t\t\t\tcustbranch.salesman,\n\t\t\t\t\tareas.areadescription,\n\t\t\t\t\tsalesman.salesmanname\n\t\t\t\tFROM debtorsmaster INNER JOIN custbranch\n\t\t\t\tON debtorsmaster.debtorno=custbranch.debtorno\n\t\t\t\tINNER JOIN areas\n\t\t\t\tON custbranch.area = areas.areacode\n\t\t\t\tINNER JOIN salesman\n\t\t\t\tON custbranch.salesman=salesman.salesmancode\n\t\t\t\tWHERE (";
            $i = 0;
            foreach ($_POST['SalesPeople'] as $Salesperson) {
Ejemplo n.º 10
0
echo $TableHeader;
$j = 1;
$k = 0;
//row colour counter
while ($myrow = DB_fetch_array($LocStockResult)) {
    if ($k == 1) {
        echo '<tr class="EvenTableRows">';
        $k = 0;
    } else {
        echo '<tr class="OddTableRows">';
        $k = 1;
    }
    if (isset($_POST[$myrow['loccode']])) {
        $_POST[$myrow['loccode']] = filter_number_input($_POST[$myrow['loccode']]);
    } else {
        $_POST[$myrow['loccode']] = filter_number_input(0);
    }
    if (isset($_POST['Old' . $myrow['loccode']]) and $_POST['Old' . $myrow['loccode']] != $_POST[$myrow['loccode']] and isset($_POST['UpdateData']) and is_numeric($_POST[$myrow['loccode']]) and $_POST[$myrow['loccode']] >= 0) {
        $myrow['reorderlevel'] = $_POST[$myrow['loccode']];
        $sql = "UPDATE locstock SET reorderlevel = '" . $_POST[$myrow['loccode']] . "'\n\t   \t\tWHERE stockid = '" . $StockID . "'\n\t\t\tAND loccode = '" . $myrow['loccode'] . "'";
        $UpdateReorderLevel = DB_query($sql, $db);
    }
    printf('<td>%s</td>
		<td class="number">%s</td>
		<td><input type="text" class="number" name="%s" maxlength="10" size="10" value="%s" /></td>
		<input type="hidden" name="Old%s" maxlength="10" size="10" value="%s" />', $myrow['locationname'], locale_number_format($myrow['quantity'], $myrow['decimalplaces']), $myrow['loccode'], locale_number_format($myrow['reorderlevel'], $myrow['decimalplaces']), $myrow['loccode'], locale_number_format($myrow['reorderlevel'], $myrow['decimalplaces']));
    $j++;
    if ($j == 12) {
        $j = 1;
        echo $TableHeader;
    }
    } 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>
Ejemplo n.º 12
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=''";
     $QtyOnHandPrior = 0;
 }
 $QtyOnHand = $QtyOnHandPrior - $InTransitQuantity;
 if ($_SESSION['ProhibitNegativeStock'] == 0 or $_SESSION['ProhibitNegativeStock'] == 1 and $QtyOnHand >= $Quantity) {
     //stock moves were here removed
     $SQL = "UPDATE stockrequestitems\n\t\t\t\t\t\t\tSET qtydelivered=qtydelivered+" . $Quantity . "\n\t\t\t\t\t\t\tWHERE dispatchid='" . $RequestID . "'\n\t\t\t\t\t\t\t\tAND dispatchitemsid='" . $LineID . "'";
     $ErrMsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('The location stock record could not be updated because');
     $DbgMsg = _('The following SQL to update the stock record was used');
     $Result = DB_query($SQL, $db, $ErrMsg, $DbgMsg, true);
     $DecimalsSql = "SELECT decimalplaces\n\t\t\t\t\t\t\tFROM stockmaster\n\t\t\t\t\t\t\tWHERE stockid='" . $StockID . "'";
     $DecimalResult = DB_Query($DecimalsSql, $db);
     $DecimalRow = DB_fetch_array($DecimalResult);
     $sql_loccode = "SELECT loccode FROM locations WHERE locationname='" . $ReceiveLoc . "'";
     $LoccodeResult = DB_query($sql_loccode, $db);
     $LoccodeRow = DB_Fetch_array($LoccodeResult);
     $SQL = "INSERT INTO loctransfers (reference,\n\t\t\t\t\t\t\t\tstockid,\n\t\t\t\t\t\t\t\tshipqty,\n\t\t\t\t\t\t\t\tshipdate,\n\t\t\t\t\t\t\t\tshiploc,\n\t\t\t\t\t\t\t\trecloc)\n\t\t\t\t\t\tVALUES ('" . $Transid . "',\n\t\t\t\t\t\t\t'" . $StockID . "',\n\t\t\t\t\t\t\t'" . round(filter_number_input($Quantity), $DecimalRow['decimalplaces']) . "',\n\t\t\t\t\t\t\t'" . Date('Y-m-d') . "',\n\t\t\t\t\t\t\t'" . $Location . "',\n\t\t\t\t\t\t\t'" . $LoccodeRow['loccode'] . "')";
     $ErrMsg = _('CRITICAL ERROR') . '! ' . _('Unable to enter Location Transfer record for') . $Stockid;
     $resultLocShip = DB_query($SQL, $db, $ErrMsg);
     if ($Quantity >= $RequestedQuantity or $Completed == True) {
         $SQL = "UPDATE stockrequestitems\n\t\t\t\t\t\t\tSET completed=1\n\t\t\t\t\t\t\tWHERE dispatchid='" . $RequestID . "'\n\t\t\t\t\t\t\t\tAND dispatchitemsid='" . $LineID . "'";
         $Result = DB_query($SQL, $db, $ErrMsg, $DbgMsg, true);
     }
     $Result = DB_Txn_Commit($db);
     $ConfirmationText = _('A stock adjustment for') . ' ' . $StockID . _('has been created from location') . ' ' . $Location . ' ' . _('for a quantity of') . ' ' . $Quantity;
     prnMsg($ConfirmationText, 'success');
     if ($_SESSION['InventoryManagerEmail'] != '') {
         $ConfirmationText = $ConfirmationText . ' ' . _('by user') . ' ' . $_SESSION['UserID'] . ' ' . _('at') . ' ' . Date('Y-m-d H:i:s');
         $EmailSubject = _('Stock adjustment for') . ' ' . $StockID;
         mail($_SESSION['InventoryManagerEmail'], $EmailSubject, $ConfirmationText);
     }
 } else {
Ejemplo n.º 14
0
    if ($_POST['This_QuantityInv'] >= $_POST['QtyRecd'] - $_POST['Prev_QuantityInv']) {
        $Complete = True;
    } else {
        $Complete = False;
    }
    if ($_SESSION['Check_Qty_Charged_vs_Del_Qty'] == True) {
        if (($_POST['This_QuantityInv'] + $_POST['Prev_QuantityInv']) / $_POST['QtyRecd'] > 1 + $_SESSION['OverChargeProportion'] / 100) {
            prnMsg(_('The quantity being invoiced is more than the outstanding quantity by more than') . ' ' . $_SESSION['OverChargeProportion'] . ' ' . _('percent. The system is set up to prohibit this so will put this invoice on hold until it is authorised'), 'warn');
            $Hold = True;
        }
    }
    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 invoiced at this price'), 'error');
    } elseif ($_SESSION['Check_Price_Charged_vs_Order_Price'] == True) {
        $_POST['ChgPrice'] = filter_number_input($_POST['ChgPrice']);
        if ($_POST['ChgPrice'] / $_POST['OrderPrice'] > 1 + $_SESSION['OverChargeProportion'] / 100) {
            prnMsg(_('The price being invoiced is more than the purchase order price by more than') . ' ' . $_SESSION['OverChargeProportion'] . '%. ' . _('The system is set up to prohibit this so will put this invoice on hold until it is authorised'), 'warn');
            $Hold = True;
        }
    }
    if ($InputError == False) {
        //		$_SESSION['SuppTrans']->Remove_GRN_From_Trans($_POST['GRNNumber']);
        $_SESSION['SuppTrans']->Modify_GRN_To_Trans($_POST['GRNNumber'], $_POST['PODetailItem'], $_POST['ItemCode'], $_POST['ItemDescription'], $_POST['QtyRecd'], $_POST['Prev_QuantityInv'], $_POST['This_QuantityInv'], $_POST['OrderPrice'], $_POST['ChgPrice'], $Complete, $_POST['StdCostUnit'], $_POST['ShiptRef'], $_POST['JobRef'], $_POST['GLCode'], $Hold, 0, $_POST['DecimalPlaces']);
    }
}
if (isset($_GET['Delete'])) {
    $_SESSION['SuppTransTmp']->Copy_GRN_To_Trans($_SESSION['SuppTrans']->GRNs[$_GET['Delete']]);
    $_SESSION['SuppTrans']->Remove_GRN_From_Trans($_GET['Delete']);
}
/*Show all the selected GRNs so far from the SESSION['SuppTrans']->GRNs array */
Ejemplo n.º 15
0
             $ErrMsg = _('Cannot insert a GL entry for the change of asset category because');
             $DbgMsg = _('The SQL that failed to insert the cost GL Trans record was');
             $result = DB_query($SQL, $db, $ErrMsg, $DbgMsg, true);
         }
         /*end if there was accumulated depreciation for the asset */
     }
     /* end if there is a change in asset category */
     $sql = "UPDATE fixedassets\n\t\t\t\t\t\t\t\t\tSET longdescription='" . $_POST['LongDescription'] . "',\n\t\t\t\t\t\t\t\t\t\tdescription='" . $_POST['Description'] . "',\n\t\t\t\t\t\t\t\t\t\tassetcategoryid='" . $_POST['AssetCategoryID'] . "',\n\t\t\t\t\t\t\t\t\t\tassetlocation='" . $_POST['AssetLocation'] . "',\n\t\t\t\t\t\t\t\t\t\tdepntype='" . $_POST['DepnType'] . "',\n\t\t\t\t\t\t\t\t\t\tdepnrate='" . filter_number_input($_POST['DepnRate']) . "',\n\t\t\t\t\t\t\t\t\t\tbarcode='" . $_POST['BarCode'] . "',\n\t\t\t\t\t\t\t\t\t\tserialno='" . $_POST['SerialNo'] . "'\n\t\t\t\t\t\t\t\t\tWHERE assetid='" . $AssetID . "'";
     $ErrMsg = _('The asset could not be updated because');
     $DbgMsg = _('The SQL that was used to update the asset and failed was');
     $result = DB_query($sql, $db, $ErrMsg, $DbgMsg);
     prnMsg(_('Asset') . ' ' . $AssetID . ' ' . _('has been updated'), 'success');
     echo '<br />';
 } else {
     //it is a NEW part
     $sql = "INSERT INTO fixedassets (description,\n\t\t\t\t\t\t\t\t\t\t\tlongdescription,\n\t\t\t\t\t\t\t\t\t\t\tassetcategoryid,\n\t\t\t\t\t\t\t\t\t\t\tassetlocation,\n\t\t\t\t\t\t\t\t\t\t\tdepntype,\n\t\t\t\t\t\t\t\t\t\t\tdepnrate,\n\t\t\t\t\t\t\t\t\t\t\tbarcode,\n\t\t\t\t\t\t\t\t\t\t\tserialno)\n\t\t\t\t\t\t\t\t\t\tVALUES (\n\t\t\t\t\t\t\t\t\t\t\t'" . $_POST['Description'] . "',\n\t\t\t\t\t\t\t\t\t\t\t'" . $_POST['LongDescription'] . "',\n\t\t\t\t\t\t\t\t\t\t\t'" . $_POST['AssetCategoryID'] . "',\n\t\t\t\t\t\t\t\t\t\t\t'" . $_POST['AssetLocation'] . "',\n\t\t\t\t\t\t\t\t\t\t\t'" . $_POST['DepnType'] . "',\n\t\t\t\t\t\t\t\t\t\t\t'" . filter_number_input($_POST['DepnRate']) . "',\n\t\t\t\t\t\t\t\t\t\t\t'" . $_POST['BarCode'] . "',\n\t\t\t\t\t\t\t\t\t\t\t'" . $_POST['SerialNo'] . "' )";
     $ErrMsg = _('The asset could not be added because');
     $DbgMsg = _('The SQL that was used to add the asset failed was');
     $result = DB_query($sql, $db, $ErrMsg, $DbgMsg);
     if (DB_error_no($db) == 0) {
         $NewAssetID = DB_Last_Insert_ID($db, 'fixedassets', 'assetid');
         prnMsg(_('The new asset has been added to the database with an asset code of:') . ' ' . $NewAssetID, 'success');
         unset($_POST['LongDescription']);
         unset($_POST['Description']);
         //				unset($_POST['AssetCategoryID']);
         //				unset($_POST['AssetLocation']);
         //				unset($_POST['DepnType']);
         //				unset($_POST['DepnRate']);
         unset($_POST['BarCode']);
         unset($_POST['SerialNo']);
     }
Ejemplo n.º 16
0
         $ErrMsg = _('Cannot insert a GL transaction for the bank account credit because');
         $DbgMsg = _('Cannot insert a GL transaction for the bank account credit using the SQL');
         $result = DB_query($SQL, $db, $ErrMsg, $DbgMsg, true);
     }
 }
 /*now enter the BankTrans entry */
 if ($Transtype == 22) {
     $SQL = "INSERT INTO banktrans (transno,\n\t\t\t\t\ttype,\n\t\t\t\t\tbankact,\n\t\t\t\t\tref,\n\t\t\t\t\tchequeno,\n\t\t\t\t\texrate,\n\t\t\t\t\tfunctionalexrate,\n\t\t\t\t\ttransdate,\n\t\t\t\t\tbanktranstype,\n\t\t\t\t\tamount,\n\t\t\t\t\tcurrcode) ";
     $SQL = $SQL . "VALUES ('" . $TransNo . "',\n\t\t\t\t'" . $Transtype . "',\n\t\t\t\t'" . $_SESSION['PaymentDetail' . $identifier]->Account . "',\n\t\t\t\t'" . $_SESSION['PaymentDetail' . $identifier]->Narrative . "',\n\t\t\t\t'" . $_POST['cheque'] . "',\n\t\t\t\t'" . filter_number_input($_SESSION['PaymentDetail' . $identifier]->ExRate) . "',\n\t\t\t\t'" . filter_number_input($_SESSION['PaymentDetail' . $identifier]->FunctionalExRate) . "',\n\t\t\t\t'" . FormatDateForSQL($_SESSION['PaymentDetail' . $identifier]->DatePaid) . "',\n\t\t\t\t'" . $_SESSION['PaymentDetail' . $identifier]->Paymenttype . "',\n\t\t\t\t-" . filter_currency_input($_SESSION['PaymentDetail' . $identifier]->Amount) . ",\n\t\t\t\t'" . $_SESSION['PaymentDetail' . $identifier]->Currency . "'\n\t\t\t)";
     $ErrMsg = _('Cannot insert a bank transaction because');
     $DbgMsg = _('Cannot insert a bank transaction using the SQL');
     $result = DB_query($SQL, $db, $ErrMsg, $DbgMsg, true);
 } else {
     foreach ($_SESSION['PaymentDetail' . $identifier]->GLItems as $PaymentItem) {
         $SQL = "INSERT INTO banktrans (transno,\n\t\t\t\t\ttype,\n\t\t\t\t\tbankact,\n\t\t\t\t\tref,\n\t\t\t\t\tchequeno,\n\t\t\t\t\texrate,\n\t\t\t\t\tfunctionalexrate,\n\t\t\t\t\ttransdate,\n\t\t\t\t\tbanktranstype,\n\t\t\t\t\tamount,\n\t\t\t\t\tcurrcode) ";
         $SQL = $SQL . "VALUES ('" . $TransNo . "',\n\t\t\t\t\t'" . $Transtype . "',\n\t\t\t\t\t'" . $_SESSION['PaymentDetail' . $identifier]->Account . "',\n\t\t\t\t\t'" . $PaymentItem->Narrative . "',\n\t\t\t\t\t'" . $_SESSION['PaymentDetail' . $identifier]->cheque . "',\n\t\t\t\t\t'" . filter_number_input($_SESSION['PaymentDetail' . $identifier]->ExRate) . "',\n\t\t\t\t\t'" . filter_number_input($_SESSION['PaymentDetail' . $identifier]->FunctionalExRate) . "',\n\t\t\t\t\t'" . FormatDateForSQL($_SESSION['PaymentDetail' . $identifier]->DatePaid) . "',\n\t\t\t\t\t'" . $_SESSION['PaymentDetail' . $identifier]->Paymenttype . "',\n\t\t\t\t\t-" . filter_currency_input($PaymentItem->Amount) . ",\n\t\t\t\t\t'" . $_SESSION['PaymentDetail' . $identifier]->Currency . "'\n\t\t\t\t)";
         $ErrMsg = _('Cannot insert a bank transaction because');
         $DbgMsg = _('Cannot insert a bank transaction using the SQL');
         $result = DB_query($SQL, $db, $ErrMsg, $DbgMsg, true);
     }
 }
 DB_Txn_Commit($db);
 prnMsg(_('Payment') . ' ' . $TransNo . ' ' . _('has been successfully entered'), 'success');
 $LastSupplier = $_SESSION['PaymentDetail' . $identifier]->SupplierID;
 unset($_POST['BankAccount']);
 unset($_POST['DatePaid']);
 unset($_POST['ExRate']);
 unset($_POST['Paymenttype']);
 unset($_POST['Currency']);
 unset($_POST['Narrative']);
 unset($_POST['cheque']);
Ejemplo n.º 17
0
     $i++;
 }
 if (mb_strstr($_POST['Abbreviation'], "'") or mb_strstr($_POST['Abbreviation'], '+') or mb_strstr($_POST['Abbreviation'], "\"") or mb_strstr($_POST['Abbreviation'], '&') or mb_strstr($_POST['Abbreviation'], ' ') or mb_strstr($_POST['Abbreviation'], "\\") or mb_strstr($_POST['Abbreviation'], '.') or mb_strstr($_POST['Abbreviation'], '"')) {
     $InputError = 1;
     prnMsg(_('The currency code cannot contain any of the following characters') . " . - ' & + \" " . _('or a space'), 'error');
     $Errors[$i] = 'Abbreviation';
     $i++;
 }
 if (isset($SelectedCurrency) and $InputError != 1) {
     /*SelectedCurrency could also exist if submit had not been clicked this code would not run in this case cos submit is false of course  see the delete code below*/
     $sql = "UPDATE currencies SET\n\t\t\t\t\tcurrency='" . $CurrenciesArray[$SelectedCurrency] . "',\n\t\t\t\t\tcountry='" . $_POST['Country'] . "',\n\t\t\t\t\thundredsname='" . $_POST['HundredsName'] . "',\n\t\t\t\t\tdecimalplaces='" . $_POST['DecimalPlaces'] . "',\n\t\t\t\t\trate='" . filter_number_input($_POST['ExchangeRate']) . "'\n\t\t\t\t\tWHERE currabrev = '" . $SelectedCurrency . "'";
     $msg = _('The currency definition record has been updated');
 } else {
     if ($InputError != 1) {
         /*Selected currencies is null cos no item selected on first time round so must be adding a record must be submitting new entries in the new payment terms form */
         $sql = "INSERT INTO currencies (currency,\n\t\t\t\t\t\tcurrabrev,\n\t\t\t\t\t\tcountry,\n\t\t\t\t\t\thundredsname,\n\t\t\t\t\t\tdecimalplaces,\n\t\t\t\t\t\trate)\n\t\t\t\tVALUES ('" . $CurrenciesArray[$_POST['Abbreviation']] . "',\n\t\t\t\t\t\t'" . $_POST['Abbreviation'] . "',\n\t\t\t\t\t\t'" . $_POST['Country'] . "',\n\t\t\t\t\t\t'" . $_POST['HundredsName'] . "',\n\t\t\t\t\t\t'" . $_POST['DecimalPlaces'] . "',\n\t\t\t\t\t\t'" . filter_number_input($_POST['ExchangeRate']) . "'\n\t\t\t\t\t\t)";
         $msg = _('The currency definition record has been added');
     }
 }
 //run the SQL from either of the above possibilites
 $result = DB_query($sql, $db);
 if ($InputError != 1) {
     prnMsg($msg, 'success');
 }
 unset($SelectedCurrency);
 unset($_POST['CurrencyName']);
 unset($_POST['Country']);
 unset($_POST['HundredsName']);
 unset($_POST['ExchangeRate']);
 unset($_POST['DecimalPlaces']);
 unset($_POST['Abbreviation']);
Ejemplo n.º 18
0
         $_POST['PropReqSO' . $i] = 1;
     } else {
         $_POST['PropReqSO' . $i] = 0;
     }
     if (isset($_POST['PropNumeric' . $i]) and $_POST['PropNumeric' . $i] == true) {
         $_POST['PropNumeric' . $i] = 1;
     } else {
         $_POST['PropNumeric' . $i] = 0;
     }
     if ($_POST['PropID' . $i] == 'NewProperty' and mb_strlen($_POST['PropLabel' . $i]) > 0) {
         $sql = "INSERT INTO stockcatproperties (categoryid,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tlabel,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tcontroltype,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tdefaultvalue,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tminimumvalue,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tmaximumvalue,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tnumericvalue,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\treqatsalesorder)\n\t\t\t\t\t\t\t\t\t\t\tVALUES ('" . $SelectedCategory . "',\n\t\t\t\t\t\t\t\t\t\t\t\t\t'" . $_POST['PropLabel' . $i] . "',\n\t\t\t\t\t\t\t\t\t\t\t\t\t" . $_POST['PropControlType' . $i] . ",\n\t\t\t\t\t\t\t\t\t\t\t\t\t'" . $_POST['PropDefault' . $i] . "',\n\t\t\t\t\t\t\t\t\t\t\t\t\t'" . filter_number_input($_POST['PropMinimum' . $i]) . "',\n\t\t\t\t\t\t\t\t\t\t\t\t\t'" . filter_number_input($_POST['PropMaximum' . $i]) . "',\n\t\t\t\t\t\t\t\t\t\t\t\t\t'" . $_POST['PropNumeric' . $i] . "',\n\t\t\t\t\t\t\t\t\t\t\t\t\t" . $_POST['PropReqSO' . $i] . ')';
         $ErrMsg = _('Could not insert a new category property for') . $_POST['PropLabel' . $i];
         $result = DB_query($sql, $db, $ErrMsg);
     } elseif ($_POST['PropID' . $i] != 'NewProperty') {
         //we could be amending existing properties
         $sql = "UPDATE stockcatproperties SET label ='" . $_POST['PropLabel' . $i] . "',\n\t\t\t\t\t\t\t\t\t\t\t\t\t  controltype = " . $_POST['PropControlType' . $i] . ",\n\t\t\t\t\t\t\t\t\t\t\t\t\t  defaultvalue = '" . $_POST['PropDefault' . $i] . "',\n\t\t\t\t\t\t\t\t\t\t\t\t\t  minimumvalue = '" . filter_number_input($_POST['PropMinimum' . $i]) . "',\n\t\t\t\t\t\t\t\t\t\t\t\t\t  maximumvalue = '" . filter_number_input($_POST['PropMaximum' . $i]) . "',\n\t\t\t\t\t\t\t\t\t\t\t\t\t  numericvalue = '" . $_POST['PropNumeric' . $i] . "',\n\t\t\t\t\t\t\t\t\t\t\t\t\t  reqatsalesorder = " . $_POST['PropReqSO' . $i] . "\n\t\t\t\t\t\t\t\t\t\t\t\tWHERE stkcatpropid =" . $_POST['PropID' . $i];
         $ErrMsg = _('Updated the stock category property for') . ' ' . $_POST['PropLabel' . $i];
         $result = DB_query($sql, $db, $ErrMsg);
     }
 }
 //end of loop round properties
 prnMsg(_('Updated the stock category record for') . ' ' . stripslashes($_POST['CategoryDescription']), 'success');
 unset($SelectedCategory);
 unset($_POST['CategoryID']);
 unset($_POST['StockType']);
 unset($_POST['CategoryDescription']);
 unset($_POST['StockAct']);
 unset($_POST['AdjGLAct']);
 unset($_POST['IssueGLAct']);
 unset($_POST['PurchPriceVarAct']);
 unset($_POST['MaterialUseageVarAc']);
Ejemplo n.º 19
0
         $sql = "UPDATE salesorderdetails\n\t\t\t\t\t\tSET unitprice = '" . $ContractPrice * $_SESSION['Contract' . $identifier]->ExRate . "'\n\t\t\t\t\t\tWHERE stkcode='" . $_SESSION['Contract' . $identifier]->ContractRef . "'\n\t\t\t\t\t\tAND orderno='" . $_SESSION['Contract' . $identifier]->OrderNo . "'";
         $ErrMsg = _('The contract quotation could not be updated because');
         $DbgMsg = _('The SQL that failed to update the quotation was');
         $UpdQuoteResult = DB_query($sql, $db, $ErrMsg, $DbgMsg);
         prnMsg(_('The contract quotation has been updated based on the new contract cost and margin'), 'success');
         echo '<br /><a href="' . $rootpath . '/SelectSalesOrder.php?OrderNumber=' . $_SESSION['Contract' . $identifier]->OrderNo . '&amp;Quotations=Quotes_Only">' . _('Go to Quotation') . ' ' . $_SESSION['Contract' . $identifier]->OrderNo . '</a>';
     }
     if ($ExistingContract['status'] == 0 and $_POST['Status'] == 1) {
         /*we are updating the status on the contract to a quotation so we need to
          * add a new item for the contract into the stockmaster
          * add a salesorder header and detail as a quotation for the item
          */
     }
 } elseif (!$InputError) {
     /*Its a new contract - so insert */
     $sql = "INSERT INTO contracts ( contractref,\n\t\t\t\t\t\t\t\t\t\tdebtorno,\n\t\t\t\t\t\t\t\t\t\tbranchcode,\n\t\t\t\t\t\t\t\t\t\tcontractdescription,\n\t\t\t\t\t\t\t\t\t\tcategoryid,\n\t\t\t\t\t\t\t\t\t\tloccode,\n\t\t\t\t\t\t\t\t\t\trequireddate,\n\t\t\t\t\t\t\t\t\t\tmargin,\n\t\t\t\t\t\t\t\t\t\tcustomerref,\n\t\t\t\t\t\t\t\t\t\texrate)\n\t\t\t\t\tVALUES ('" . $_POST['ContractRef'] . "',\n\t\t\t\t\t\t\t'" . $_SESSION['Contract' . $identifier]->DebtorNo . "',\n\t\t\t\t\t\t\t'" . $_SESSION['Contract' . $identifier]->BranchCode . "',\n\t\t\t\t\t\t\t'" . $_POST['ContractDescription'] . "',\n\t\t\t\t\t\t\t'" . $_POST['CategoryID'] . "',\n\t\t\t\t\t\t\t'" . $_POST['LocCode'] . "',\n\t\t\t\t\t\t\t'" . FormatDateForSQL($_POST['RequiredDate']) . "',\n\t\t\t\t\t\t\t'" . filter_number_input($_POST['Margin']) . "',\n\t\t\t\t\t\t\t'" . $_POST['CustomerRef'] . "',\n\t\t\t\t\t\t\t'" . filter_number_input($_POST['ExRate']) . "')";
     $ErrMsg = _('The new contract could not be added because');
     $result = DB_query($sql, $db, $ErrMsg);
     /*Also need to add the reqts and contracbom*/
     $ErrMsg = _('Could not add a component to the contract bill of material');
     foreach ($_SESSION['Contract' . $identifier]->ContractBOM as $Component) {
         $sql = "INSERT INTO contractbom (contractref,\n\t\t\t\t\t\t\t\t\t\t\tstockid,\n\t\t\t\t\t\t\t\t\t\t\tworkcentreadded,\n\t\t\t\t\t\t\t\t\t\t\tquantity)\n\t\t\t\t\t\t\tVALUES ('" . $_POST['ContractRef'] . "',\n\t\t\t\t\t\t\t\t\t'" . $Component->StockID . "',\n\t\t\t\t\t\t\t\t\t'" . $WorkCentre . "',\n\t\t\t\t\t\t\t\t\t'" . $Component->Quantity . "')";
         $result = DB_query($sql, $db, $ErrMsg);
     }
     $ErrMsg = _('Could not add a requirement to the contract requirements');
     foreach ($_SESSION['Contract' . $identifier]->ContractReqts as $Requirement) {
         $sql = "INSERT INTO contractreqts (contractref,\n\t\t\t\t\t\t\t\t\t\t\t\trequirement,\n\t\t\t\t\t\t\t\t\t\t\t\tcostperunit,\n\t\t\t\t\t\t\t\t\t\t\t\tquantity)\n\t\t\t\t\t\t\tVALUES ( '" . $_POST['ContractRef'] . "',\n\t\t\t\t\t\t\t\t\t'" . $Requirement->Requirement . "',\n\t\t\t\t\t\t\t\t\t'" . $Requirement->CostPerUnit . "',\n\t\t\t\t\t\t\t\t\t'" . $Requirement->Quantity . "')";
         $result = DB_query($sql, $db, $ErrMsg);
     }
     prnMsg(_('The new contract has been added to the database'), 'success');
 }
Ejemplo n.º 20
0
<?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');
    }
Ejemplo n.º 21
0
 $result = DB_query("DROP TABLE IF EXISTS passbom2", $db);
 $sql = "CREATE TEMPORARY TABLE passbom (\n\t\t\t\tpart char(20),\n\t\t\t\textendedqpa double,\n\t\t\t\tsortpart text) DEFAULT CHARSET=utf8";
 $ErrMsg = _('The SQL to to create passbom failed with the message');
 $result = DB_query($sql, $db, $ErrMsg);
 $sql = "CREATE TEMPORARY TABLE tempbom (\n\t\t\t\tparent char(20),\n\t\t\t\tcomponent char(20),\n\t\t\t\tsortpart text,\n\t\t\t\tlevel int,\n\t\t\t\tworkcentreadded char(5),\n\t\t\t\tloccode char(5),\n\t\t\t\teffectiveafter date,\n\t\t\t\teffectiveto date,\n\t\t\t\tquantity double) DEFAULT CHARSET=utf8";
 $result = DB_query($sql, $db, _('Create of tempbom failed because'));
 // First, find first level of components below requested assembly
 // Put those first level parts in passbom, use COMPONENT in passbom
 // to link to PARENT in bom to find next lower level and accumulate
 // those parts into tempbom
 // This finds the top level
 $sql = "INSERT INTO passbom (part, extendedqpa, sortpart)\n\t\t\t   SELECT bom.component AS part,\n\t\t\t\t\t  (" . filter_number_input($_POST['Quantity']) . " * bom.quantity) as extendedqpa,\n\t\t\t\t\t   CONCAT(bom.parent,bom.component) AS sortpart\n\t\t\t\t\t  FROM bom\n\t\t\t  WHERE bom.parent ='" . $_POST['Part'] . "'\n\t\t\t  AND bom.effectiveto >= NOW()\n\t\t\t  AND bom.effectiveafter <= NOW()";
 $result = DB_query($sql, $db);
 $LevelCounter = 2;
 // $LevelCounter is the level counter
 $sql = "INSERT INTO tempbom (\n\t\t\t\tparent,\n\t\t\t\tcomponent,\n\t\t\t\tsortpart,\n\t\t\t\tlevel,\n\t\t\t\tworkcentreadded,\n\t\t\t\tloccode,\n\t\t\t\teffectiveafter,\n\t\t\t\teffectiveto,\n\t\t\t\tquantity)\n\t\t\tSELECT bom.parent,\n\t\t\t\t\t bom.component,\n\t\t\t\t\t CONCAT(bom.parent,bom.component) AS sortpart," . $LevelCounter . " as level,\n\t\t\t\t\t bom.workcentreadded,\n\t\t\t\t\t bom.loccode,\n\t\t\t\t\t bom.effectiveafter,\n\t\t\t\t\t bom.effectiveto,\n\t\t\t\t\t (" . filter_number_input($_POST['Quantity']) . " * bom.quantity) as extendedqpa\n\t\t\tFROM bom\n\t\t\tWHERE bom.parent ='" . $_POST['Part'] . "'\n\t\t\tAND bom.effectiveto >= NOW()\n\t\t\tAND bom.effectiveafter <= NOW()";
 $result = DB_query($sql, $db);
 //echo "<br />sql is $sql<br />";
 // This while routine finds the other levels as long as $ComponentCounter - the
 // component counter finds there are more components that are used as
 // assemblies at lower levels
 $ComponentCounter = 1;
 while ($ComponentCounter > 0) {
     $LevelCounter++;
     $sql = "INSERT INTO tempbom (\n\t\t\t\tparent,\n\t\t\t\tcomponent,\n\t\t\t\tsortpart,\n\t\t\t\tlevel,\n\t\t\t\tworkcentreadded,\n\t\t\t\tloccode,\n\t\t\t\teffectiveafter,\n\t\t\t\teffectiveto,\n\t\t\t\tquantity)\n\t\t\t  SELECT bom.parent,\n\t\t\t\t\t bom.component,\n\t\t\t\t\t CONCAT(passbom.sortpart,bom.component) AS sortpart,\n\t\t\t\t\t " . $LevelCounter . " as level,\n\t\t\t\t\t bom.workcentreadded,\n\t\t\t\t\t bom.loccode,\n\t\t\t\t\t bom.effectiveafter,\n\t\t\t\t\t bom.effectiveto,\n\t\t\t\t\t (bom.quantity * passbom.extendedqpa)\n\t\t\t FROM bom,passbom\n\t\t\t WHERE bom.parent = passbom.part\n\t\t\t  AND bom.effectiveto >= NOW()\n\t\t\t  AND bom.effectiveafter <= NOW()";
     $result = DB_query($sql, $db);
     $result = DB_query("DROP TABLE IF EXISTS passbom2", $db);
     $result = DB_query("ALTER TABLE passbom RENAME AS passbom2", $db);
     $result = DB_query("DROP TABLE IF EXISTS passbom", $db);
     $sql = "CREATE TEMPORARY TABLE passbom (part char(20),\n\t\t\t\t\t\t\t\t\t\t\t\textendedqpa decimal(10,3),\n\t\t\t\t\t\t\t\t\t\t\t\tsortpart text) DEFAULT CHARSET=utf8";
     $result = DB_query($sql, $db);
Ejemplo n.º 22
0
             foreach ($LineItem->Taxes as $TaxLine) {
                 if (isset($_POST[$LineItem->LineNumber . $TaxLine->TaxCalculationOrder . '_TaxRate'])) {
                     $_SESSION['CreditItems' . $identifier]->LineItems[$LineItem->LineNumber]->Taxes[$TaxLine->TaxCalculationOrder]->TaxRate = filter_number_input($_POST[$LineItem->LineNumber . $TaxLine->TaxCalculationOrder . '_TaxRate']) / 100;
                 }
             }
         }
         if ($Quantity < 0 or $Price < 0 or $DiscountPercentage > 100 or $DiscountPercentage < 0) {
             prnMsg(_('The item could not be updated because you are attempting to set the quantity credited to less than 0 or the price less than 0 or the discount more than 100% or less than 0%'), 'warn');
         } elseif (isset($_POST['Quantity_' . $LineItem->LineNumber])) {
             $_SESSION['CreditItems' . $identifier]->update_cart_item($LineItem->LineNumber, $Quantity, $Price, $LineItem->Units, $LineItem->ConversionFactor, $DiscountPercentage / 100, 1, $Narrative, 'No', $LineItem->ItemDue, $LineItem->POLine, 0);
         }
     }
 }
 foreach ($_SESSION['CreditItems' . $identifier]->FreightTaxes as $FreightTaxLine) {
     if (isset($_POST['FreightTaxRate' . $FreightTaxLine->TaxCalculationOrder])) {
         $_SESSION['CreditItems' . $identifier]->FreightTaxes[$FreightTaxLine->TaxCalculationOrder]->TaxRate = filter_number_input($_POST['FreightTaxRate' . $FreightTaxLine->TaxCalculationOrder]) / 100;
     }
 }
 if (isset($_POST['AddToCredit'])) {
     /* get the item details from the database and hold them in the cart object make the quantity 1 by default then add it to the cart */
     $AlreadyOnThisCredit = 0;
     foreach ($_SESSION['CreditItems' . $identifier]->LineItems as $OrderItem) {
         /* do a loop round the items on the credit note to see that the item
         			is not already on this credit note */
         if ($_SESSION['SO_AllowSameItemMultipleTimes'] == 0 and strcasecmp($OrderItem->StockID, $_POST['NewItem']) == 0) {
             $AlreadyOnThisCredit = 1;
             prnMsg(_('The item selected is already on this credit the system will not allow the same item on the credit note more than once. However you can change the quantity credited of the existing line if necessary.'), 'warn');
         }
     }
     /* end of the foreach loop to look for preexisting items of the same code */
     if ($AlreadyOnThisCredit != 1) {
Ejemplo n.º 23
0
        prnMsg(_('Cannot Enter this order line') . '<br />' . _('The price entered must be numeric'), 'warn');
    }
    if (!is_numeric(filter_number_input($_POST['Cost']))) {
        $AllowAdd = False;
        prnMsg(_('Cannot Enter this order line') . '<br />' . _('The cost entered must be numeric'), 'warn');
    }
    if (filter_number_input($_POST['Price']) / $_SESSION['SPL' . $identifier]->CustCurrExRate - filter_number_input($_POST['Cost']) / $_SESSION['SPL' . $identifier]->SuppCurrExRate < 0) {
        $AllowAdd = False;
        prnMsg(_('Cannot Enter this order line') . '<br />' . _('The sale is at a lower price than the cost'), 'warn');
    }
    if (!Is_Date($_POST['ReqDelDate'])) {
        $AllowAdd = False;
        prnMsg(_('Cannot Enter this order line') . '<br />' . _('The date entered must be in the format') . ' ' . $_SESSION['DefaultDateFormat'], 'warn');
    }
    if ($AllowAdd == True) {
        $_SESSION['SPL' . $identifier]->add_to_order($_POST['LineNo'], filter_number_input($_POST['Qty']), $_POST['ItemDescription'], filter_number_input($_POST['Price']), filter_number_input($_POST['Cost']), $_POST['StkCat'], $_POST['ReqDelDate']);
        unset($_POST['Price']);
        unset($_POST['Cost']);
        unset($_POST['ItemDescription']);
        unset($_POST['StkCat']);
        unset($_POST['ReqDelDate']);
        unset($_POST['Qty']);
    }
}
if (isset($_POST['StkLocation'])) {
    $_SESSION['SPL' . $identifier]->StkLocation = $_POST['StkLocation'];
}
if (isset($_POST['Initiator'])) {
    $_SESSION['SPL' . $identifier]->Initiator = $_POST['Initiator'];
}
if (isset($_POST['QuotationRef'])) {
Ejemplo n.º 24
0
     $myrow = DB_fetch_row($result);
     $_SESSION['ReceiptBatch']->BankAccountName = $myrow[0];
     $_SESSION['ReceiptBatch']->AccountCurrency = $myrow[1];
     unset($result);
 } elseif (DB_num_rows($result) == 0 and !$BankAccountEmpty) {
     prnMsg(_('The bank account number') . ' ' . $_POST['BankAccount'] . ' ' . _('is not set up as a bank account'), 'error');
     include 'includes/footer.inc';
     exit;
 }
 if (!Is_Date($_POST['DateBanked'])) {
     $_POST['DateBanked'] = Date($_SESSION['DefaultDateFormat']);
 }
 $_SESSION['ReceiptBatch']->DateBanked = $_POST['DateBanked'];
 if (isset($_POST['ExRate']) and $_POST['ExRate'] != '') {
     if (is_numeric(filter_number_input($_POST['ExRate']))) {
         $_SESSION['ReceiptBatch']->ExRate = filter_number_input($_POST['ExRate']);
     } else {
         prnMsg(_('The exchange rate entered should be numeric'), 'warn');
     }
 }
 if (isset($_POST['FunctionalExRate']) and $_POST['FunctionalExRate'] != '') {
     if (is_numeric($_POST['FunctionalExRate'])) {
         $_SESSION['ReceiptBatch']->FunctionalExRate = $_POST['FunctionalExRate'];
         //ex rate between receipt currency and account currency
     } else {
         prnMsg(_('The functional exchange rate entered should be numeric'), 'warn');
     }
 }
 $_SESSION['ReceiptBatch']->ReceiptType = $_POST['ReceiptType'];
 if (!isset($_POST['Currency'])) {
     $_POST['Currency'] = $_SESSION['CompanyRecord']['currencydefault'];
Ejemplo n.º 25
0
    $_SESSION['Request']->LineItems[$_POST['LineNumber']]->Quantity = $_POST['Quantity'];
}
if (isset($_GET['Delete'])) {
    unset($_SESSION['Request']->LineItems[$_GET['Delete']]);
    echo '<br />';
    prnMsg(_('The line was successfully deleted'), 'success');
    echo '<br />';
}
foreach ($_POST as $key => $value) {
    if (mb_strstr($key, 'StockID')) {
        $Index = mb_substr($key, 7);
        if (filter_number_input($_POST['Quantity' . $Index]) > 0) {
            $StockID = $value;
            $ItemDescription = $_POST['ItemDescription' . $Index];
            $DecimalPlaces = $_POST['DecimalPlaces' . $Index];
            $NewItem_array[$StockID] = filter_number_input($_POST['Quantity' . $Index]);
            $_POST['Units' . $StockID] = $_POST['Units' . $Index];
            $_SESSION['Request']->AddLine($StockID, $ItemDescription, $NewItem_array[$StockID], $_POST['Units' . $StockID], $DecimalPlaces);
        }
    }
}
if (isset($_POST['Submit'])) {
    DB_Txn_Begin($db);
    $InputError = 0;
    if ($_SESSION['Request']->Department == '') {
        prnMsg(_('You must select a Department for the request'), 'error');
        $InputError = 1;
    }
    if ($_SESSION['Request']->Location == '') {
        prnMsg(_('You must select a Location to request the items from'), 'error');
        $InputError = 1;
Ejemplo n.º 26
0
     }
     $SQL = "INSERT INTO stockmoves (stockid,\n\t\t\t\t\t\t\t\t\t\t\t\ttype,\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\tloccode,\n\t\t\t\t\t\t\t\t\t\t\t\ttrandate,\n\t\t\t\t\t\t\t\t\t\t\t\tdebtorno,\n\t\t\t\t\t\t\t\t\t\t\t\tbranchcode,\n\t\t\t\t\t\t\t\t\t\t\t\tprice,\n\t\t\t\t\t\t\t\t\t\t\t\tprd,\n\t\t\t\t\t\t\t\t\t\t\t\treference,\n\t\t\t\t\t\t\t\t\t\t\t\tqty,\n\t\t\t\t\t\t\t\t\t\t\t\tdiscountpercent,\n\t\t\t\t\t\t\t\t\t\t\t\tstandardcost,\n\t\t\t\t\t\t\t\t\t\t\t\tnarrative\n\t\t\t\t\t\t\t\t\t\t\t) VALUES ('" . $OrderLine->StockID . "',\n\t\t\t\t\t\t\t\t\t\t\t\t10,\n\t\t\t\t\t\t\t\t\t\t\t\t'" . $InvoiceNo . "',\n\t\t\t\t\t\t\t\t\t\t\t\t'" . $_SESSION['Items' . $identifier]->Location . "',\n\t\t\t\t\t\t\t\t\t\t\t\t'" . $DefaultDispatchDate . "',\n\t\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\t'" . $_SESSION['Items' . $identifier]->Branch . "',\n\t\t\t\t\t\t\t\t\t\t\t\t'" . filter_number_input($LocalCurrencyPrice) . "',\n\t\t\t\t\t\t\t\t\t\t\t\t'" . $PeriodNo . "',\n\t\t\t\t\t\t\t\t\t\t\t\t'" . $OrderNo . "',\n\t\t\t\t\t\t\t\t\t\t\t\t'-" . filter_number_input($OrderLine->Quantity * $OrderLine->ConversionFactor) . "',\n\t\t\t\t\t\t\t\t\t\t\t\t'" . $OrderLine->DiscountPercent . "',\n\t\t\t\t\t\t\t\t\t\t\t\t'" . $OrderLine->StandardCost . "',\n\t\t\t\t\t\t\t\t\t\t\t\t'" . DB_escape_string($OrderLine->Narrative) . "')";
 }
 $ErrMsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('Stock movement records could not be inserted because');
 $DbgMsg = _('The following SQL to insert the stock movement records was used');
 $Result = DB_query($SQL, $db, $ErrMsg, $DbgMsg, true);
 /*Get the ID of the StockMove... */
 $StkMoveNo = DB_Last_Insert_ID($db, 'stockmoves', 'stkmoveno');
 if (isset($OrderLine->SerialItems)) {
     foreach ($OrderLine->SerialItems['Number'] as $i => $SerialItemNumber) {
         $Batch[$SerialItemNumber] = $OrderLine->SerialItems['Quantity'][$i];
         $SQL = "UPDATE stockserialitems\n\t\t\t\t\t\t\tSET quantity=quantity-" . filter_number_input($OrderLine->SerialItems['Quantity'][$i] * $OrderLine->ConversionFactor) . "\n\t\t\t\t\t\t\tWHERE stockid='" . $OrderLine->StockID . "'\n\t\t\t\t\t\t\t\tAND serialno='" . $SerialItemNumber . "'";
         $ErrMsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('Batch numbers could not be updated');
         $DbgMsg = _('The following SQL to update the stock batch record was used');
         $Result = DB_query($SQL, $db, $ErrMsg, $DbgMsg, true);
         $SQL = "INSERT INTO stockserialmoves (stockmoveno,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tstockid,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tserialno,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tmoveqty\n\t\t\t\t\t\t\t\t\t\t\t\t\t) VALUES (\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t'" . $StkMoveNo . "',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t'" . $OrderLine->StockID . "',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t'" . $SerialItemNumber . "',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t'-" . filter_number_input($OrderLine->SerialItems['Quantity'][$i] * $OrderLine->ConversionFactor) . "'\n\t\t\t\t\t\t\t\t\t\t\t\t\t)";
         $ErrMsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('Batch numbers could not be updated');
         $DbgMsg = _('The following SQL to insert the stock batch movement was used');
         $Result = DB_query($SQL, $db, $ErrMsg, $DbgMsg, true);
     }
 }
 /*Insert the taxes that applied to this line */
 foreach ($OrderLine->Taxes as $Tax) {
     $SQL = "INSERT INTO stockmovestaxes (stkmoveno,\n\t\t\t\t\t\t\t\t\t\t\t\t\ttaxauthid,\n\t\t\t\t\t\t\t\t\t\t\t\t\ttaxrate,\n\t\t\t\t\t\t\t\t\t\t\t\t\ttaxcalculationorder,\n\t\t\t\t\t\t\t\t\t\t\t\t\ttaxontax\n\t\t\t\t\t\t\t\t\t\t\t\t) VALUES (\n\t\t\t\t\t\t\t\t\t\t\t\t\t'" . $StkMoveNo . "',\n\t\t\t\t\t\t\t\t\t\t\t\t\t'" . $Tax->TaxAuthID . "',\n\t\t\t\t\t\t\t\t\t\t\t\t\t'" . $Tax->TaxRate . "',\n\t\t\t\t\t\t\t\t\t\t\t\t\t'" . $Tax->TaxCalculationOrder . "',\n\t\t\t\t\t\t\t\t\t\t\t\t\t'" . $Tax->TaxOnTax . "')";
     $ErrMsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('Taxes and rates applicable to this invoice line item could not be inserted because');
     $DbgMsg = _('The following SQL to insert the stock movement tax detail records was used');
     $Result = DB_query($SQL, $db, $ErrMsg, $DbgMsg, true);
 }
 //end for each tax for the line
 /*Insert Sales Analysis records */
 $SQL = "SELECT COUNT(*),\n\t\t\t\t\tsalesanalysis.stockid,\n\t\t\t\t\tsalesanalysis.stkcategory,\n\t\t\t\t\tsalesanalysis.cust,\n\t\t\t\t\tsalesanalysis.custbranch,\n\t\t\t\t\tsalesanalysis.area,\n\t\t\t\t\tsalesanalysis.periodno,\n\t\t\t\t\tsalesanalysis.typeabbrev,\n\t\t\t\t\tsalesanalysis.salesperson\n\t\t\t\tFROM salesanalysis,\n\t\t\t\t\tcustbranch,\n\t\t\t\t\tstockmaster\n\t\t\t\tWHERE salesanalysis.stkcategory=stockmaster.categoryid\n\t\t\t\tAND salesanalysis.stockid=stockmaster.stockid\n\t\t\t\tAND salesanalysis.cust=custbranch.debtorno\n\t\t\t\tAND salesanalysis.custbranch=custbranch.branchcode\n\t\t\t\tAND salesanalysis.area=custbranch.area\n\t\t\t\tAND salesanalysis.salesperson=custbranch.salesman\n\t\t\t\tAND salesanalysis.typeabbrev ='" . $_SESSION['Items' . $identifier]->DefaultSalesType . "'\n\t\t\t\tAND salesanalysis.periodno='" . $PeriodNo . "'\n\t\t\t\tAND salesanalysis.cust " . LIKE . " '" . $_SESSION['Items' . $identifier]->DebtorNo . "'\n\t\t\t\tAND salesanalysis.custbranch " . LIKE . " '" . $_SESSION['Items' . $identifier]->Branch . "'\n\t\t\t\tAND salesanalysis.stockid " . LIKE . " '" . $OrderLine->StockID . "'\n\t\t\t\tAND salesanalysis.budgetoractual=1\n\t\t\t\tGROUP BY salesanalysis.stockid,\n\t\t\t\t\tsalesanalysis.stkcategory,\n\t\t\t\t\tsalesanalysis.cust,\n\t\t\t\t\tsalesanalysis.custbranch,\n\t\t\t\t\tsalesanalysis.area,\n\t\t\t\t\tsalesanalysis.periodno,\n\t\t\t\t\tsalesanalysis.typeabbrev,\n\t\t\t\t\tsalesanalysis.salesperson";
Ejemplo n.º 27
0
echo '<input type="hidden" name="FormID" value="' . $_SESSION['FormID'] . '" />';
if (!isset($_REQUEST['WO']) or !isset($_REQUEST['StockID'])) {
    /* This page can only be called with a purchase order number for invoicing*/
    echo '<div class="centre"><a href="' . $rootpath . '/SelectWorkOrder.php">' . _('Select a work order to receive') . '</a></div>';
    prnMsg(_('This page can only be opened if a work order has been selected. Please select a work order to receive first'), 'info');
    include 'includes/footer.inc';
    exit;
} else {
    echo '<input type="hidden" name="WO" value="' . $_REQUEST['WO'] . '" />';
    $_POST['WO'] = $_REQUEST['WO'];
    echo '<input type="hidden" name="StockID" value="' . $_REQUEST['StockID'] . '" />';
    $_POST['StockID'] = $_REQUEST['StockID'];
}
foreach ($_POST as $key => $value) {
    if (substr($key, 0, 3) == 'Qty') {
        $_POST[$key] = filter_number_input($value);
    }
}
if (isset($_POST['Process'])) {
    //user hit the process the work order receipts entered.
    $InputError = false;
    //ie assume no problems for a start - ever the optimist
    $ErrMsg = _('Could not retrieve the details of the selected work order item');
    $WOResult = DB_query("SELECT workorders.loccode,\n\t\t\t\t\t\t\t locations.locationname,\n\t\t\t\t\t\t\t workorders.requiredby,\n\t\t\t\t\t\t\t workorders.startdate,\n\t\t\t\t\t\t\t workorders.closed,\n\t\t\t\t\t\t\t stockmaster.description,\n\t\t\t\t\t\t\t stockmaster.controlled,\n\t\t\t\t\t\t\t stockmaster.serialised,\n\t\t\t\t\t\t\t stockmaster.decimalplaces,\n\t\t\t\t\t\t\t stockmaster.units,\n\t\t\t\t\t\t\t woitems.qtyreqd,\n\t\t\t\t\t\t\t woitems.qtyrecd,\n\t\t\t\t\t\t\t woitems.stdcost,\n\t\t\t\t\t\t\t stockcategory.wipact,\n\t\t\t\t\t\t\t stockcategory.stockact\n\t\t\t\t\t\t\tFROM workorders INNER JOIN locations\n\t\t\t\t\t\t\tON workorders.loccode=locations.loccode\n\t\t\t\t\t\t\tINNER JOIN woitems\n\t\t\t\t\t\t\tON workorders.wo=woitems.wo\n\t\t\t\t\t\t\tINNER JOIN stockmaster\n\t\t\t\t\t\t\tON woitems.stockid=stockmaster.stockid\n\t\t\t\t\t\t\tINNER JOIN stockcategory\n\t\t\t\t\t\t\tON stockmaster.categoryid=stockcategory.categoryid\n\t\t\t\t\t\t\tWHERE woitems.stockid='" . $_POST['StockID'] . "'\n\t\t\t\t\t\t\tAND workorders.wo='" . $_POST['WO'] . "'", $db, $ErrMsg);
    if (DB_num_rows($WOResult) == 0) {
        prnMsg(_('The selected work order item cannot be retrieved from the database'), 'info');
        include 'includes/footer.inc';
        exit;
    }
    $WORow = DB_fetch_array($WOResult);
    $QuantityReceived = 0;
Ejemplo n.º 28
0
 /* Need to get the current location quantity will need it later for the stock movement */
 $SQL = "SELECT locstock.quantity\n\t\t\t\t\t\t\t\tFROM locstock\n\t\t\t\t\t\t\t\tWHERE locstock.stockid='" . $OrderLine->StockID . "'\n\t\t\t\t\t\t\t\tAND loccode= '" . $_SESSION['PO']->Location . "'";
 $Result = DB_query($SQL, $db);
 if (DB_num_rows($Result) == 1) {
     $LocQtyRow = DB_fetch_row($Result);
     $QtyOnHandPrior = $LocQtyRow[0];
 } else {
     /*There must actually be some error this should never happen */
     $QtyOnHandPrior = 0;
 }
 $SQL = "UPDATE locstock\n\t\t\t\t\t\t\t\tSET quantity = locstock.quantity + " . filter_currency_input($OrderLine->ReceiveQty * $OrderLine->ConversionFactor) . "\n\t\t\t\t\t\t\t\tWHERE locstock.stockid = '" . $OrderLine->StockID . "'\n\t\t\t\t\t\t\t\tAND loccode = '" . $_SESSION['PO']->Location . "'";
 $ErrMsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('The location stock record could not be updated because');
 $DbgMsg = _('The following SQL to update the location stock record was used');
 $Result = DB_query($SQL, $db, $ErrMsg, $DbgMsg, true);
 /* Insert stock movements - with unit cost */
 $SQL = "INSERT INTO stockmoves (stockid,\n\t\t\t\t\t\t\t\t\t\t\t\ttype,\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\tloccode,\n\t\t\t\t\t\t\t\t\t\t\t\ttrandate,\n\t\t\t\t\t\t\t\t\t\t\t\tprice,\n\t\t\t\t\t\t\t\t\t\t\t\tprd,\n\t\t\t\t\t\t\t\t\t\t\t\treference,\n\t\t\t\t\t\t\t\t\t\t\t\tqty,\n\t\t\t\t\t\t\t\t\t\t\t\tstandardcost,\n\t\t\t\t\t\t\t\t\t\t\t\tnewqoh)\n\t\t\t\t\t\t\t\t\t\t\tVALUES (\n\t\t\t\t\t\t\t\t\t\t\t\t'" . $OrderLine->StockID . "',\n\t\t\t\t\t\t\t\t\t\t\t\t25,\n\t\t\t\t\t\t\t\t\t\t\t\t'" . $GRN . "',\n\t\t\t\t\t\t\t\t\t\t\t\t'" . $_SESSION['PO']->Location . "',\n\t\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\t'" . $LocalCurrencyPrice . "',\n\t\t\t\t\t\t\t\t\t\t\t\t'" . $PeriodNo . "',\n\t\t\t\t\t\t\t\t\t\t\t\t'" . $_SESSION['PO']->SupplierID . " (" . $_SESSION['PO']->SupplierName . ") - " . $_SESSION['PO']->OrderNo . "',\n\t\t\t\t\t\t\t\t\t\t\t\t'" . filter_number_input($OrderLine->ReceiveQty * $OrderLine->ConversionFactor) . "',\n\t\t\t\t\t\t\t\t\t\t\t\t'" . filter_currency_input($_SESSION['PO']->LineItems[$OrderLine->LineNo]->StandardCost / $OrderLine->ConversionFactor) . "',\n\t\t\t\t\t\t\t\t\t\t\t\t'" . filter_number_input($QtyOnHandPrior + $OrderLine->ReceiveQty * $OrderLine->ConversionFactor) . "'\n\t\t\t\t\t\t\t\t\t\t\t)";
 $ErrMsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('stock movement records could not be inserted because');
 $DbgMsg = _('The following SQL to insert the stock movement records was used');
 $Result = DB_query($SQL, $db, $ErrMsg, $DbgMsg, true);
 /*Get the ID of the StockMove... */
 $StkMoveNo = DB_Last_Insert_ID($db, 'stockmoves', 'stkmoveno');
 /* Do the Controlled Item INSERTS HERE */
 if ($OrderLine->Controlled == 1) {
     foreach ($OrderLine->SerialItems as $Item) {
         /* we know that StockItems return an array of SerialItem (s)
         		 We need to add the StockSerialItem record and
         		 The StockSerialMoves as well */
         //need to test if the controlled item exists first already
         $SQL = "SELECT COUNT(*) FROM stockserialitems\n\t\t\t\t\t\t\t\t\t\t\t\tWHERE stockid='" . $OrderLine->StockID . "'\n\t\t\t\t\t\t\t\t\t\t\t\tAND loccode = '" . $_SESSION['PO']->Location . "'\n\t\t\t\t\t\t\t\t\t\t\t\tAND serialno = '" . $Item->BundleRef . "'";
         $ErrMsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('Could not check if a batch or lot stock item already exists because');
         $DbgMsg = _('The following SQL to test for an already existing controlled but not serialised stock item was used');
Ejemplo n.º 29
0
if (isset($_GET['NewTransfer'])) {
    unset($_SESSION['Transfer']);
}
if (isset($_SESSION['Transfer']) and $_SESSION['Transfer']->TrfID == '') {
    unset($_SESSION['Transfer']);
}
if (isset($_POST['ProcessTransfer'])) {
    /*Ok Time To Post transactions to Inventory Transfers, and Update Posted variable & received Qty's  to LocTransfers */
    $PeriodNo = GetPeriod($_SESSION['Transfer']->TranDate, $db);
    $SQLTransferDate = FormatDateForSQL($_SESSION['Transfer']->TranDate);
    $InputError = False;
    /*Start off hoping for the best */
    $i = 0;
    $TotalQuantity = 0;
    foreach ($_SESSION['Transfer']->TransferItem as $TrfLine) {
        $_POST['Qty' . $i] = filter_number_input($_POST['Qty' . $i]);
        if (is_numeric($_POST['Qty' . $i])) {
            /*Update the quantity received from the inputs */
            $_SESSION['Transfer']->TransferItem[$i]->Quantity = $_POST['Qty' . $i];
        } else {
            prnMsg(_('The quantity entered for') . ' ' . $TrfLine->StockID . ' ' . _('is not numeric') . '. ' . _('All quantities must be numeric'), 'error');
            $InputError = True;
        }
        if ($_POST['Qty' . $i] < 0) {
            prnMsg(_('The quantity entered for') . ' ' . $TrfLine->StockID . ' ' . _('is negative') . '. ' . _('All quantities must be for positive numbers greater than zero'), 'error');
            $InputError = True;
        }
        if ($TrfLine->PrevRecvQty + $TrfLine->Quantity > $TrfLine->ShipQty) {
            prnMsg(_('The Quantity entered plus the Quantity Previously Received can not be greater than the Total Quantity shipped for') . ' ' . $TrfLine->StockID, 'error');
            $InputError = True;
        }
Ejemplo n.º 30
0
                $AllowThisPosting = false;
            }
            if ($_POST['GLCode'] == $_SESSION['CompanyRecord']['retainedearnings']) {
                prnMsg(_('Receipts involving the retained earnings control account cannot be entered. This account is automtically maintained.'), 'warn');
                $AllowThisPosting = false;
            }
        }
        if ($_POST['tag'] == '' or $_POST['tag'] == '0') {
            prnMsg(_('You must select a tag for all transactions.'), 'error');
            $AllowThisPosting = false;
        }
        if ($AllowThisPosting) {
            $_SESSION['ReceiptBatch']->add_to_batch(filter_number_input($_POST['Amount']), $_POST['CustomerID'], filter_number_input($_POST['Discount']), $_POST['Narrative'], $_POST['GLCode'], $_POST['PayeeBankDetail'], $_POST['CustomerName'], $_POST['tag']);
        }
    } else {
        $_SESSION['ReceiptBatch']->add_to_batch(filter_number_input($_POST['Amount']), $_POST['CustomerID'], filter_number_input($_POST['Discount']), $_POST['Narrative'], $_POST['GLCode'], $_POST['PayeeBankDetail'], $_POST['CustomerName'], $_POST['tag']);
    }
    /*Make sure the same receipt is not double processed by a page refresh */
    $Cancel = 1;
}
if (isset($Cancel)) {
    unset($_SESSION['CustomerRecord']);
    unset($_POST['CustomerID']);
    unset($_POST['CustomerName']);
    unset($_POST['Amount']);
    unset($_POST['Discount']);
    unset($_POST['Narrative']);
    unset($_POST['PayeeBankDetail']);
}
if (isset($_POST['CommitBatch'])) {
    /* once all receipts items entered, process all the data in the