Exemplo n.º 1
0
function ReSequenceEffectiveDates($Item, $PriceList, $CurrAbbrev, $CustomerID, $db)
{
    /*This is quite complicated - the idea is that prices set up should be unique and there is no way two prices could be returned as valid - when getting a price in includes/GetPrice.inc the logic is to first look for a price of the salestype/currency within the effective start and end dates - then if not get the price with a start date prior but a blank end date (the default price). We would not want two prices where the effective dates fall between an existing price so it is necessary to update enddates of prices  - with me - I am just hanging on here myself
    	 Prices with no end date are default prices and need to be ignored in this resquence*/
    $SQL = "SELECT branchcode,\n\t\t\t\t\t\tstartdate,\n\t\t\t\t\t\tenddate\n\t\t\t\t\t\tFROM prices\n\t\t\t\t\t\tWHERE debtorno='" . $CustomerID . "'\n\t\t\t\t\t\tAND stockid='" . $Item . "'\n\t\t\t\t\t\tAND currabrev='" . $CurrAbbrev . "'\n\t\t\t\t\t\tAND typeabbrev='" . $PriceList . "'\n\t\t\t\t\t\tAND enddate<>''\n\t\t\t\t\t\tORDER BY\n\t\t\t\t\t\tbranchcode,\n\t\t\t\t\t\tstartdate,\n\t\t\t\t\t\tenddate";
    $result = DB_query($SQL, $db);
    unset($BranchCode);
    while ($myrow = DB_fetch_array($result)) {
        if (!isset($BranchCode)) {
            unset($NextDefaultStartDate);
            //a price with a blank end date
            unset($NextStartDate);
            unset($EndDate);
            unset($StartDate);
            $BranchCode = $myrow['branchcode'];
        }
        if (isset($NextStartDate)) {
            if (Date1GreaterThanDate2(ConvertSQLDate($myrow['startdate']), $NextStartDate)) {
                $NextStartDate = ConvertSQLDate($myrow['startdate']);
                if (Date1GreaterThanDate2(ConvertSQLDate($EndDate), ConvertSQLDate($myrow['startdate']))) {
                    /*Need to make the end date the new start date less 1 day */
                    $SQL = "UPDATE prices SET enddate = '" . FormatDateForSQL(DateAdd($NextStartDate, 'd', -1)) . "'\n\t\t\t\t\t\t\t\t\t\tWHERE stockid ='" . $Item . "'\n\t\t\t\t\t\t\t\t\t\tAND currabrev='" . $CurrAbbrev . "'\n\t\t\t\t\t\t\t\t\t\tAND typeabbrev='" . $PriceList . "'\n\t\t\t\t\t\t\t\t\t\tAND startdate ='" . $StartDate . "'\n\t\t\t\t\t\t\t\t\t\tAND enddate = '" . $EndDate . "'\n\t\t\t\t\t\t\t\t\t\tAND debtorno ='" . $CustomerID . "'";
                    $UpdateResult = DB_query($SQL, $db);
                }
            }
            //end of if startdate  after NextStartDate - we have a new NextStartDate
        } else {
            $NextStartDate = ConvertSQLDate($myrow['startdate']);
        }
        $StartDate = $myrow['startdate'];
        $EndDate = $myrow['enddate'];
    }
}
Exemplo n.º 2
0
function submit(&$db, &$ChangeDate)
{
    //initialize no input errors
    $InputError = 0;
    /* actions to take once the user has clicked the submit button
    	ie the page has called itself with some user input */
    //first off validate inputs sensible
    if (!Is_Date($_POST['FromDate'])) {
        $InputError = 1;
        prnMsg(_('Invalid From Date'), 'error');
    }
    if (!Is_Date($_POST['ToDate'])) {
        $InputError = 1;
        prnMsg(_('Invalid To Date'), 'error');
    }
    // Use FormatDateForSQL to put the entered dates into right format for sql
    // Use ConvertSQLDate to put sql formatted dates into right format for functions such as
    // DateDiff and DateAdd
    $FormatFromDate = FormatDateForSQL($_POST['FromDate']);
    $FormatToDate = FormatDateForSQL($_POST['ToDate']);
    $ConvertFromDate = ConvertSQLDate($FormatFromDate);
    $ConvertToDate = ConvertSQLDate($FormatToDate);
    $DateGreater = Date1GreaterThanDate2($_POST['ToDate'], $_POST['FromDate']);
    $DateDiff = DateDiff($ConvertToDate, $ConvertFromDate, 'd');
    // Date1 minus Date2
    if ($DateDiff < 1) {
        $InputError = 1;
        prnMsg(_('To Date Must Be Greater Than From Date'), 'error');
    }
    if ($InputError == 1) {
        ShowInputForm($db, $ChangeDate);
        return;
    }
    $sql = "DROP TABLE IF EXISTS mrpcalendar";
    $result = DB_query($sql);
    $sql = "CREATE TABLE mrpcalendar (\n\t\t\t\tcalendardate date NOT NULL,\n\t\t\t\tdaynumber int(6) NOT NULL,\n\t\t\t\tmanufacturingflag smallint(6) NOT NULL default '1',\n\t\t\t\tINDEX (daynumber),\n\t\t\t\tPRIMARY KEY (calendardate)) DEFAULT CHARSET=utf8";
    $ErrMsg = _('The SQL to create passbom failed with the message');
    $result = DB_query($sql, $ErrMsg);
    $i = 0;
    /* $DaysTextArray used so can get text of day based on the value get from DayOfWeekFromSQLDate of
    	 the calendar date. See if that text is in the ExcludeDays array note no gettext here hard coded english days from $_POST*/
    $DaysTextArray = array('Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday');
    $ExcludeDays = array($_POST['Sunday'], $_POST['Monday'], $_POST['Tuesday'], $_POST['Wednesday'], $_POST['Thursday'], $_POST['Friday'], $_POST['Saturday']);
    $CalDate = $ConvertFromDate;
    for ($i = 0; $i <= $DateDiff; $i++) {
        $DateAdd = FormatDateForSQL(DateAdd($CalDate, 'd', $i));
        // If the check box for the calendar date's day of week was clicked, set the manufacturing flag to 0
        $DayOfWeek = DayOfWeekFromSQLDate($DateAdd);
        $ManuFlag = 1;
        foreach ($ExcludeDays as $exday) {
            if ($exday == $DaysTextArray[$DayOfWeek]) {
                $ManuFlag = 0;
            }
        }
        $sql = "INSERT INTO mrpcalendar (\n\t\t\t\t\tcalendardate,\n\t\t\t\t\tdaynumber,\n\t\t\t\t\tmanufacturingflag)\n\t\t\t\t VALUES ('" . $DateAdd . "',\n\t\t\t\t\t\t'1',\n\t\t\t\t\t\t'" . $ManuFlag . "')";
        $result = DB_query($sql, $ErrMsg);
    }
    // Update daynumber. Set it so non-manufacturing days will have the same daynumber as a valid
    // manufacturing day that precedes it. That way can read the table by the non-manufacturing day,
    // subtract the leadtime from the daynumber, and find the valid manufacturing day with that daynumber.
    $DayNumber = 1;
    $sql = "SELECT * FROM mrpcalendar\n\t\t\tORDER BY calendardate";
    $result = DB_query($sql, $ErrMsg);
    while ($myrow = DB_fetch_array($result)) {
        if ($myrow['manufacturingflag'] == "1") {
            $DayNumber++;
        }
        $CalDate = $myrow['calendardate'];
        $sql = "UPDATE mrpcalendar SET daynumber = '" . $DayNumber . "'\n\t\t\t\t\tWHERE calendardate = '" . $CalDate . "'";
        $resultupdate = DB_query($sql, $ErrMsg);
    }
    prnMsg(_('The MRP Calendar has been created'), 'success');
    ShowInputForm($db, $ChangeDate);
}
Exemplo n.º 3
0
         $PurchPrice = $PurchRow['price'] / $PurchRow['conversionfactor'];
         $ConversionFactor = $PurchRow['conversionfactor'];
         $SupplierDescription = $PurchRow['suppliers_partno'] . ' - ';
         if (mb_strlen($PurchRow['supplierdescription']) > 2) {
             $SupplierDescription .= $PurchRow['supplierdescription'];
         } else {
             $SupplierDescription .= $ItemRow['description'];
         }
         $SuppliersUnitOfMeasure = $PurchRow['suppliersuom'];
         $SuppliersPartNo = $PurchRow['suppliers_partno'];
         $LeadTime = $PurchRow['leadtime'];
         /* Work out the delivery date based on today + lead time
          * if > header DeliveryDate then set DeliveryDate to today + leadtime
          */
         $DeliveryDate = DateAdd(Date($_SESSION['DefaultDateFormat']), 'd', $LeadTime);
         if (!Date1GreaterThanDate2($DeliveryDate, $_SESSION['PO' . $identifier]->DeliveryDate)) {
             $DeliveryDate = $_SESSION['PO' . $identifier]->DeliveryDate;
         }
     } else {
         // no purchasing data setup
         $PurchPrice = 0;
         $ConversionFactor = 1;
         $SupplierDescription = $ItemRow['description'];
         $SuppliersUnitOfMeasure = $ItemRow['units'];
         $SuppliersPartNo = '';
         $LeadTime = 1;
         $DeliveryDate = $_SESSION['PO' . $identifier]->DeliveryDate;
     }
     $_SESSION['PO' . $identifier]->add_to_order($_SESSION['PO' . $identifier]->LinesOnOrder + 1, $ItemCode, 0, 0, filter_number_format($Quantity) * $ConversionFactor, $SupplierDescription, $PurchPrice, $ItemRow['units'], $ItemRow['stockact'], $DeliveryDate, 0, 0, 0, 0, 0, $ItemRow['accountname'], $ItemRow['decimalplaces'], $SuppliersUnitOfMeasure, $ConversionFactor, $LeadTime, $SuppliersPartNo);
 } else {
     //no rows returned by the SQL to get the item
    unset($_SESSION['Items' . $identifier]);
    include 'includes/footer.inc';
    exit;
}
if (isset($_POST['Process'])) {
    $Result = DB_Txn_Begin();
    $InputErrors = 0;
    if (!Is_Date($_POST['StartDate'])) {
        $InputErrors = 1;
        prnMsg(_('The last recurrence or start date of this recurring order must be a valid date in the format') . ' ' . $_SESSION['DefaultDateFormat'], 'error');
    }
    if (!Is_Date($_POST['StopDate'])) {
        $InputErrors = 1;
        prnMsg(_('The end date of this recurring order must be a valid date in the format') . ' ' . $_SESSION['DefaultDateFormat'], 'error');
    }
    if (Date1GreaterThanDate2($_POST['StartDate'], $_POST['StopDate'])) {
        $InputErrors = 1;
        prnMsg(_('The end date of this recurring order must be after the start date'), 'error');
    }
    if (isset($_POST['MakeRecurringOrder']) and $_POST['Quotation'] == 1) {
        $InputErrors = 1;
        prnMsg(_('A recurring order cannot be made from a quotation'), 'error');
    }
    if ($InputErrors == 0) {
        /*Error checks above all passed ok so lets go*/
        if ($NewRecurringOrder == 'Yes') {
            /* finally write the recurring order header to the database and then the line details*/
            $DelDate = FormatDateforSQL($_SESSION['Items' . $identifier]->DeliveryDate);
            $HeaderSQL = "INSERT INTO recurringsalesorders (\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\tcustomerref,\n\t\t\t\t\t\t\t\t\t\tcomments,\n\t\t\t\t\t\t\t\t\t\torddate,\n\t\t\t\t\t\t\t\t\t\tordertype,\n\t\t\t\t\t\t\t\t\t\tdeliverto,\n\t\t\t\t\t\t\t\t\t\tdeladd1,\n\t\t\t\t\t\t\t\t\t\tdeladd2,\n\t\t\t\t\t\t\t\t\t\tdeladd3,\n\t\t\t\t\t\t\t\t\t\tdeladd4,\n\t\t\t\t\t\t\t\t\t\tdeladd5,\n\t\t\t\t\t\t\t\t\t\tdeladd6,\n\t\t\t\t\t\t\t\t\t\tcontactphone,\n\t\t\t\t\t\t\t\t\t\tcontactemail,\n\t\t\t\t\t\t\t\t\t\tfreightcost,\n\t\t\t\t\t\t\t\t\t\tfromstkloc,\n\t\t\t\t\t\t\t\t\t\tshipvia,\n\t\t\t\t\t\t\t\t\t\tlastrecurrence,\n\t\t\t\t\t\t\t\t\t\tstopdate,\n\t\t\t\t\t\t\t\t\t\tfrequency,\n\t\t\t\t\t\t\t\t\t\tautoinvoice)\n\t\t\t\t\t\t\t\t\tvalues (\n\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'" . $_SESSION['Items' . $identifier]->Branch . "',\n\t\t\t\t\t\t\t\t\t\t'" . $_SESSION['Items' . $identifier]->CustRef . "',\n\t\t\t\t\t\t\t\t\t\t'" . $_SESSION['Items' . $identifier]->Comments . "',\n\t\t\t\t\t\t\t\t\t\t'" . Date('Y-m-d H:i') . "',\n\t\t\t\t\t\t\t\t\t\t'" . $_SESSION['Items' . $identifier]->DefaultSalesType . "',\n\t\t\t\t\t\t\t\t\t\t'" . $_SESSION['Items' . $identifier]->DeliverTo . "',\n\t\t\t\t\t\t\t\t\t\t'" . $_SESSION['Items' . $identifier]->DelAdd1 . "',\n\t\t\t\t\t\t\t\t\t\t'" . $_SESSION['Items' . $identifier]->DelAdd2 . "',\n\t\t\t\t\t\t\t\t\t\t'" . $_SESSION['Items' . $identifier]->DelAdd3 . "',\n\t\t\t\t\t\t\t\t\t\t'" . $_SESSION['Items' . $identifier]->DelAdd4 . "',\n\t\t\t\t\t\t\t\t\t\t'" . $_SESSION['Items' . $identifier]->DelAdd5 . "',\n\t\t\t\t\t\t\t\t\t\t'" . $_SESSION['Items' . $identifier]->DelAdd6 . "',\n\t\t\t\t\t\t\t\t\t\t'" . $_SESSION['Items' . $identifier]->PhoneNo . "',\n\t\t\t\t\t\t\t\t\t\t'" . $_SESSION['Items' . $identifier]->Email . "',\n\t\t\t\t\t\t\t\t\t\t'" . $_SESSION['Items' . $identifier]->FreightCost . "',\n\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'" . $_SESSION['Items' . $identifier]->ShipVia . "',\n\t\t\t\t\t\t\t\t\t\t'" . FormatDateforSQL($_POST['StartDate']) . "',\n\t\t\t\t\t\t\t\t\t\t'" . FormatDateforSQL($_POST['StopDate']) . "',\n\t\t\t\t\t\t\t\t\t\t'" . $_POST['Frequency'] . "',\n\t\t\t\t\t\t\t\t\t\t'" . $_POST['AutoInvoice'] . "')";
            $ErrMsg = _('The recurring order cannot be added because');
            $DbgMsg = _('The SQL that failed was');
     prnMsg(_('No price list currency is selected to update. No updates will take place'), 'error');
     $InputError = 1;
 }
 if (!Is_Date($_POST['PriceEndDate']) and $_POST['PriceEndDate'] != '') {
     $InputError = 1;
     prnMsg(_('The date the new price is to be in effect to must be entered in the format') . ' ' . $_SESSION['DefaultDateFormat'], 'error');
 }
 if (!Is_Date($_POST['PriceStartDate'])) {
     $InputError = 1;
     prnMsg(_('The date this price is to take effect from must be entered in the format') . ' ' . $_SESSION['DefaultDateFormat'], 'error');
 }
 if (Date1GreaterThanDate2($_POST['PriceStartDate'], $_POST['PriceEndDate']) and $_POST['PriceEndDate'] != '') {
     $InputError = 1;
     prnMsg(_('The end date is expected to be after the start date, enter an end date after the start date for this price'), 'error');
 }
 if (Date1GreaterThanDate2(Date($_SESSION['DefaultDateFormat']), $_POST['PriceStartDate'])) {
     $InputError = 1;
     prnMsg(_('The date this new price is to start from is expected to be after today'), 'error');
 }
 if ($_POST['StkCatTo'] < $_POST['StkCatFrom']) {
     prnMsg(_('The stock category from must be before the stock category to - there would be not items in the range to update'), 'error');
     $InputError = 1;
 }
 if ($_POST['CostType'] == 'OtherPriceList' and $_POST['BasePriceList'] == '0') {
     echo '<br />' . _('Base price list selected') . ': ' . $_POST['BasePriceList'];
     prnMsg(_('When you are updating prices based on another price list - the other price list must also be selected. No updates will take place until the other price list is selected'), 'error');
     $InputError = 1;
 }
 if ($_POST['CostType'] == 'OtherPriceList' and $_POST['BasePriceList'] == $_POST['PriceList']) {
     prnMsg(_('When you are updating prices based on another price list - the other price list cannot be the same as the price list being used for the calculation. No updates will take place until the other price list selected is different from the price list to be updated'), 'error');
     $InputError = 1;
Exemplo n.º 6
0
function submit(&$db, &$ChangeDate)
{
    //####SUBMIT_SUBMIT_SUBMIT_SUBMIT_SUBMIT_SUBMIT_SUBMIT_SUBMIT####
    //initialize no input errors
    $InputError = 0;
    /* actions to take once the user has clicked the submit button
    	ie the page has called itself with some user input */
    //first off validate inputs sensible
    if (!is_date($_POST['FromDate'])) {
        $InputError = 1;
        prnMsg(_('Invalid From Date'), 'error');
    }
    if (!is_date($_POST['ToDate'])) {
        $InputError = 1;
        prnMsg(_('Invalid To Date'), 'error');
    }
    if ($inputerror != 1) {
        $formatdate = FormatDateForSQL($_POST['FromDate']);
        echo "</br>Format Date: {$formatdate}</br>";
        $convertdate = ConvertSQLDate($formatdate);
        echo "</br>Convert Date: {$convertdate}</br>";
        $dayofweek = DayOfWeekFromSQLDate($formatdate);
        echo "</br>Day of week: {$dayofweek}</br>";
        //$dateadd = DateAdd($_POST['FromDate'],"d",-3);
        $dateadd = DateAdd($convertdate, "d", -8);
        echo "</br>Date Add: {$dateadd}</br>";
        $dategreater = Date1GreaterThanDate2($_POST['ToDate'], $_POST['FromDate']);
        echo "</br>Date Greater: {$dategreater}</br>";
        $datediff = DateDiff($_POST['ToDate'], $_POST['FromDate'], "d");
        // Date1 minus Date2
        echo "</br>Date Difference: {$datediff}</br>";
        $sql = 'DROP TABLE IF EXISTS mrpcalendar';
        $result = DB_query($sql, $db);
        $sql = 'CREATE TABLE mrpcalendar (
					calendardate date NOT NULL,
					daynumber int(6) NOT NULL,
					manufacturingflag smallint(6) NOT NULL default "1",
					INDEX (daynumber),
					PRIMARY KEY (calendardate))';
        $ErrMsg = _('The SQL to to create passbom failed with the message');
        $result = DB_query($sql, $db, $ErrMsg);
        $i = 0;
        // $daystext used so can get text of day based on the value get from DayOfWeekFromSQLDate of
        // the calendar date. See if that text is in the ExcludeDays array
        $daysText = array(_('Sunday'), _('Monday'), _('Tuesday'), _('Wednesday'), _('Thursday'), _('Friday'), _('Saturday'));
        $ExcludeDays = array($_POST['Sunday'], $_POST['Monday'], $_POST['Tuesday'], $_POST['Wednesday'], $_POST['Thursday'], $_POST['Friday'], $_POST['Saturday']);
        $caldate = $_POST['FromDate'];
        for ($i = 0; $i <= $datediff; $i++) {
            $dateadd = FormatDateForSQL(DateAdd($caldate, "d", $i));
            // If the check box for the calendar date's day of week was clicked, set the manufacturing flag to 0
            $dayofweek = DayOfWeekFromSQLDate($dateadd);
            $manuflag = 1;
            foreach ($ExcludeDays as $exday) {
                if ($exday == $daysText[$dayofweek]) {
                    $manuflag = 0;
                }
            }
            // echo "</br>Date: $dateadd Day: $dayofweek";
            $sql = "INSERT INTO mrpcalendar (\n\t\t\t\t\t\tcalendardate,\n\t\t\t\t\t\tdaynumber,\n\t\t\t\t\t\tmanufacturingflag)\n\t\t\t\t\t VALUES ('{$dateadd}',\n\t\t\t\t\t\t\t'1',\n\t\t\t\t\t\t\t'{$manuflag}')";
            $result = DB_query($sql, $db, $ErrMsg);
        }
        // Update daynumber. Set it so non-manufacturing days will have the same daynumber as a valid
        // manufacturing day that precedes it. That way can read the table by the non-manufacturing day,
        // subtract the leadtime from the daynumber, and find the valid manufacturing day with that daynumber.
        $daynumber = 1;
        $sql = 'SELECT * FROM mrpcalendar ORDER BY calendardate';
        $result = DB_query($sql, $db, $ErrMsg);
        while ($myrow = DB_fetch_array($result)) {
            if ($myrow['manufacturingflag'] == "1") {
                $daynumber++;
            }
            $caldate = $myrow['calendardate'];
            $sql = "UPDATE mrpcalendar SET daynumber = '{$daynumber}'\n\t\t\t\t\t\tWHERE calendardate = '{$caldate}'";
            $resultupdate = DB_query($sql, $db, $ErrMsg);
        }
        echo '</br>' . _('Number of days') . ':' . $i . '</br>';
        prnMsg(_("The MRP Calendar has been created"), 'success');
        display($db, $ChangeDate);
    }
    // End of if inputerror != 1
}
     $TotalCategoryDepn = 0;
 }
 $BookValueBfwd = $AssetRow['costtotal'] - $AssetRow['depnbfwd'];
 if ($AssetRow['depntype'] == 0) {
     //striaght line depreciation
     $DepreciationType = _('SL');
     $NewDepreciation = $AssetRow['costtotal'] * $AssetRow['depnrate'] / 100 / 12;
     if ($NewDepreciation > $BookValueBfwd) {
         $NewDepreciation = $BookValueBfwd;
     }
 } else {
     //Diminishing value depreciation
     $DepreciationType = _('DV');
     $NewDepreciation = $BookValueBfwd * $AssetRow['depnrate'] / 100 / 12;
 }
 if (Date1GreaterThanDate2($AssetRow['datepurchased'], $_POST['ProcessDate'])) {
     /*Over-ride calculations as the asset was not purchased at the date of the calculation!! */
     $NewDepreciation = 0;
 }
 $RowCounter++;
 if ($RowCounter == 15) {
     echo $Heading;
     $RowCounter = 0;
 }
 if ($k == 1) {
     echo '<tr class="EvenTableRows">';
     $k = 0;
 } else {
     echo '<tr class="OddTableRows">';
     $k++;
 }
Exemplo n.º 8
0
     unset($_POST['RebateAmount']);
 } elseif (filter_number_format($_POST['RebateAmount']) == 0 and filter_number_format($_POST['RebatePercent']) == 0) {
     prnMsg(_('Both the rebate amount and the rebate percent is zero. One or the other must be a positive number?'), 'error');
     $InputError = 1;
     /*
     	} elseif (mb_strlen($_POST['Narrative'])==0 OR $_POST['Narrative']==''){
     		prnMsg(_('The narrative cannot be empty.'),'error');
     		$InputError = 1;
     */
 } elseif (filter_number_format($_POST['RebatePercent']) > 100 or filter_number_format($_POST['RebatePercent']) < 0) {
     prnMsg(_('The rebate percent must be greater than zero but less than 100 percent. No changes will be made to this record'), 'error');
     $InputError = 1;
 } elseif (filter_number_format($_POST['RebateAmount']) != 0 and filter_number_format($_POST['RebatePercent']) != 0) {
     prnMsg(_('Both the rebate percent and rebate amount are non-zero. Only one or the other can be used.'), 'error');
     $InputError = 1;
 } elseif (Date1GreaterThanDate2($_POST['EffectiveFrom'], $_POST['EffectiveTo'])) {
     prnMsg(_('The effective to date is prior to the effective from date.'), 'error');
     $InputError = 1;
 }
 if ($InputError == 0 and isset($_POST['AddRecord'])) {
     $sql = "INSERT INTO sellthroughsupport (supplierno,\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\tcategoryid,\n\t\t\t\t\t\t\t\t\t\t\t\tstockid,\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\trebateamount,\n\t\t\t\t\t\t\t\t\t\t\t\trebatepercent,\n\t\t\t\t\t\t\t\t\t\t\t\teffectivefrom,\n\t\t\t\t\t\t\t\t\t\t\t\teffectiveto )\n\t\t\t\t\t\tVALUES ('" . $SupplierID . "',\n\t\t\t\t\t\t\t'" . $_POST['DebtorNo'] . "',\n\t\t\t\t\t\t\t'" . $_POST['CategoryID'] . "',\n\t\t\t\t\t\t\t'" . $_POST['StockID'] . "',\n\t\t\t\t\t\t\t'" . $_POST['Narrative'] . "',\n\t\t\t\t\t\t\t'" . filter_number_format($_POST['RebateAmount']) . "',\n\t\t\t\t\t\t\t'" . filter_number_format($_POST['RebatePercent'] / 100) . "',\n\t\t\t\t\t\t\t'" . FormatDateForSQL($_POST['EffectiveFrom']) . "',\n\t\t\t\t\t\t\t'" . FormatDateForSQL($_POST['EffectiveTo']) . "')";
     $ErrMsg = _('The sell through support record could not be added to the database because');
     $DbgMsg = _('The SQL that failed was');
     $AddResult = DB_query($sql, $db, $ErrMsg, $DbgMsg);
     prnMsg(_('This sell through support has been added to the database'), 'success');
 }
 if ($InputError == 0 and isset($_POST['UpdateRecord'])) {
     $sql = "UPDATE sellthroughsupport SET debtorno='" . $_POST['DebtorNo'] . "',\n\t\t\t\t\t\t\t\t\t\t\tcategoryid='" . $_POST['CategoryID'] . "',\n\t\t\t\t\t\t\t\t\t\t\tstockid='" . $_POST['StockID'] . "',\n\t\t\t\t\t\t\t\t\t\t\tnarrative='" . $_POST['Narrative'] . "',\n\t\t\t\t\t\t\t\t\t\t\trebateamount='" . filter_number_format($_POST['RebateAmount']) . "',\n\t\t\t\t\t\t\t\t\t\t\trebatepercent='" . filter_number_format($_POST['RebatePercent']) / 100 . "',\n\t\t\t\t\t\t\t\t\t\t\teffectivefrom='" . FormatDateForSQL($_POST['EffectiveFrom']) . "',\n\t\t\t\t\t\t\t\t\t\t\teffectiveto='" . FormatDateForSQL($_POST['EffectiveTo']) . "'\n\t\t\t\t\t\t\tWHERE id='" . $_POST['SellSupportID'] . "'";
     $ErrMsg = _('The sell through support record could not be updated because');
     $DbgMsg = _('The SQL that failed was');
     $UpdResult = DB_query($sql, $db, $ErrMsg, $DbgMsg);
$LastUserResponsible = '';
while ($myrow = DB_fetch_array($result)) {
    if (!isset(${'Mail' . $myrow['userresponsible']}) and IsEmailAddress($myrow['email'])) {
        if ($LastUserResponsible != '') {
            ${'Mail' . $myrow['userresponsible']}->setText($MailText);
            $SendResult = ${'Mail' . $myrow['userresponsible']}->send(array($LastUserEmail));
            $MailText = _('You have the following maintenance task(s) falling due or over-due:') . "\n";
        }
        $LastUserResponsible = $myrow['userresponsible'];
        $LastUserEmail = $myrow['email'];
        ${'Mail' . $myrow['userresponsible']} = new htmlMimeMail();
        ${'Mail' . $myrow['userresponsible']}->setSubject('Maintenance Tasks Reminder');
        ${'Mail' . $myrow['userresponsible']}->setFrom('Do_not_reply <>');
    }
    $MailText .= "Asset: " . $myrow['description'] . "\nTask: " . $myrow['taskdescription'] . "\nDue: " . ConvertSQLDate($myrow['duedate']);
    if (Date1GreaterThanDate2(ConvertSQLDate($myrow['duedate']), Date($_SESSION['DefaultDateFormat']))) {
        $MailText .= _('NB: THIS JOB IS OVERDUE');
    }
    $MailText . "\n\n";
}
if (DB_num_rows($result) > 0) {
    ${'Mail' . $LastUserResponsible}->setText($MailText);
    $SendResult = ${'Mail' . $LastUserResponsible}->send(array(${'Mail' . $LastUserResponsible}));
}
/* Now do manager emails for overdue jobs */
$sql = "SELECT \tdescription,\n\t\t\t\ttaskdescription,\n\t\t\t\tADDDATE(lastcompleted,frequencydays) AS duedate,\n\t\t\t\trealname,\n\t\t\t\tmanager\n\t\tFROM fixedassettasks\n\t\tINNER JOIN fixedassets\n\t\tON fixedassettasks.assetid=fixedassets.assetid\n\t\tINNER JOIN www_users\n\t\tON fixedassettasks.userresponsible=www_users.userid\n\t\tWHERE ADDDATE(lastcompleted,frequencydays)> CURDATE()\n\t\tORDER BY manager";
$result = DB_query($sql, $db);
$LastManager = '';
while ($myrow = DB_fetch_array($result)) {
    if (!isset(${'Mail' . $myrow['userresponsible']})) {
        if ($LastUserResponsible != '') {
Exemplo n.º 10
0
		</tr>';
$k = 0;
//row colour counter
$OrderTotal = 0;
$RecdTotal = 0;
while ($myrow = DB_fetch_array($LineItemsResult)) {
    $OrderTotal += $myrow['quantityord'] * $myrow['unitprice'];
    $RecdTotal += $myrow['quantityrecd'] * $myrow['unitprice'];
    $DisplayReqdDate = ConvertSQLDate($myrow['deliverydate']);
    if ($myrow['decimalplaces'] != NULL) {
        $DecimalPlaces = $myrow['decimalplaces'];
    } else {
        $DecimalPlaces = 2;
    }
    // if overdue and outstanding quantities, then highlight as so
    if ($myrow['quantityord'] - $myrow['quantityrecd'] > 0 and Date1GreaterThanDate2(Date($_SESSION['DefaultDateFormat']), $DisplayReqdDate)) {
        echo '<tr class="OsRow">';
    } else {
        if ($k == 1) {
            echo '<tr class="EvenTableRows">';
            $k = 0;
        } else {
            echo '<tr class="OddTableRows">';
            $k = 1;
        }
    }
    printf('<td>%s</td>
			<td>%s</td>
			<td class="number">%s</td>
			<td class="number">%s</td>
			<td class="number">%s</td>
Exemplo n.º 11
0
 * $Ancestors = array();
 $Ancestors[0] = $myrow['locationdescription'];
 $i = 0;
 while ($Ancestors[$i] != '') {
 $LocationSQL = "SELECT parentlocationid from fixedassetlocations where locationdescription='" . $Ancestors[$i] . "'";
 $LocationResult = DB_query($LocationSQL, $db);
 $LocationRow = DB_fetch_array($LocationResult);
 $ParentSQL = "SELECT locationdescription from fixedassetlocations where locationid='" . $LocationRow['parentlocationid'] . "'";
 $ParentResult = DB_query($ParentSQL, $db);
 $ParentRow = DB_fetch_array($ParentResult);
 $i++;
 $Ancestors[$i] = $ParentRow['locationdescription'];
 }
 */
 if (Date1GreaterThanDate2(ConvertSQLDate($myrow['disposaldate']), $_POST['FromDate']) or $myrow['disposaldate'] = '0000-00-00') {
     if ($myrow['disposaldate'] != '0000-00-00' and Date1GreaterThanDate2($_POST['ToDate'], ConvertSQLDate($myrow['disposaldate']))) {
         /*The asset was disposed during the period */
         $CostCfwd = 0;
         $AccumDepnCfwd = 0;
     } else {
         $CostCfwd = $myrow['periodadditions'] + $myrow['costbfwd'];
         $AccumDepnCfwd = $myrow['perioddepn'] + $myrow['depnbfwd'];
     }
     if (isset($_POST['pdf'])) {
         $LeftOvers = $pdf->addTextWrap($XPos, $YPos, 30 - $Left_Margin, $FontSize, $myrow['assetid']);
         $LeftOvers = $pdf->addTextWrap($XPos + 30, $YPos, 150 - $Left_Margin, $FontSize, $myrow['description']);
         $LeftOvers = $pdf->addTextWrap($XPos + 180, $YPos, 40 - $Left_Margin, $FontSize, $myrow['serialno']);
         /*
         				 * $TempYPos = $YPos;
         				 for ($i = 1;$i < sizeof($Ancestors) - 1;$i++) {
         				 for ($j = 0;$j < $i;$j++) {
Exemplo n.º 12
0
    $result = DB_query($sql, $ErrMsg);
    $myrow = DB_fetch_array($result);
    $_SESSION['Shipment']->SupplierID = $_SESSION['SupplierID'];
    $_SESSION['Shipment']->SupplierName = $myrow['suppname'];
    $_SESSION['Shipment']->CurrCode = $myrow['currcode'];
    $_SESSION['Shipment']->CurrDecimalPlaces = $myrow['currdecimalplaces'];
    $_SESSION['Shipment']->ShiptRef = GetNextTransNo(31, $db);
}
if (isset($_POST['Update']) or isset($_GET['Add']) and $_SESSION['Shipment']->Closed == 0) {
    //user hit the update button
    $InputError = 0;
    if (isset($_POST['Update'])) {
        if (!Is_Date($_POST['ETA'])) {
            $InputError = 1;
            prnMsg(_('The date of expected arrival of the shipment must be entered in the format') . ' ' . $_SESSION['DefaultDateFormat'], 'error');
        } elseif (Date1GreaterThanDate2($_POST['ETA'], Date($_SESSION['DefaultDateFormat'])) == 0) {
            $InputError = 1;
            prnMsg(_('An expected arrival of the shipment must be a date after today'), 'error');
        } else {
            $_SESSION['Shipment']->ETA = FormatDateForSQL($_POST['ETA']);
        }
        if (mb_strlen($_POST['Vessel']) < 2) {
            prnMsg(_('A reference to the vessel of more than 2 characters is expected'), 'error');
        }
        if (mb_strlen($_POST['VoyageRef']) < 2) {
            prnMsg(_('A reference to the voyage (or HAWB in the case of air-freight) of more than 2 characters is expected'), 'error');
        }
    } elseif (mb_strlen($_SESSION['Shipment']->Vessel) < 2 or mb_strlen($_SESSION['Shipment']->VoyageRef) < 2) {
        prnMsg(_('Cannot add purchase order lines to the shipment unless the shipment is first initiated - hit update to setup the shipment first'), 'info');
        $InputError = 1;
    }
Exemplo n.º 13
0
     $Errors[$i] = 'EffectiveTo';
     $i++;
 }
 if (!is_numeric(filter_number_format($_POST['Quantity']))) {
     $InputError = 1;
     prnMsg(_('The quantity entered must be numeric'), 'error');
     $Errors[$i] = 'Quantity';
     $i++;
 }
 if (filter_number_format($_POST['Quantity']) == 0) {
     $InputError = 1;
     prnMsg(_('The quantity entered cannot be zero'), 'error');
     $Errors[$i] = 'Quantity';
     $i++;
 }
 if (!Date1GreaterThanDate2($_POST['EffectiveTo'], $_POST['EffectiveAfter'])) {
     $InputError = 1;
     prnMsg(_('The effective to date must be a date after the effective after date') . '<br />' . _('The effective to date is') . ' ' . DateDiff($_POST['EffectiveTo'], $_POST['EffectiveAfter'], 'd') . ' ' . _('days before the effective after date') . '! ' . _('No updates have been performed') . '.<br />' . _('Effective after was') . ': ' . $_POST['EffectiveAfter'] . ' ' . _('and effective to was') . ': ' . $_POST['EffectiveTo'], 'error');
     $Errors[$i] = 'EffectiveAfter';
     $i++;
     $Errors[$i] = 'EffectiveTo';
     $i++;
 }
 if ($_POST['AutoIssue'] == 1 and isset($_POST['Component'])) {
     $sql = "SELECT controlled FROM stockmaster WHERE stockid='" . $_POST['Component'] . "'";
     $CheckControlledResult = DB_query($sql, $db);
     $CheckControlledRow = DB_fetch_row($CheckControlledResult);
     if ($CheckControlledRow[0] == 1) {
         prnMsg(_('Only non-serialised or non-lot controlled items can be set to auto issue. These items require the lot/serial numbers of items issued to the works orders to be specified so autoissue is not an option. Auto issue has been automatically set to off for this component'), 'warn');
         $_POST['AutoIssue'] = 0;
     }
Exemplo n.º 14
0
 }
 //The contractRef cannot be the same as an existing stockid or contractref
 $result = DB_query("SELECT stockid FROM stockmaster WHERE stockid='" . $_POST['ContractRef'] . "'");
 if (DB_num_rows($result) == 1 and $_SESSION['Contract' . $identifier]->Status == 0) {
     prnMsg(_('The contract reference cannot be the same as a previously created stock item. Please modify the contract reference before continuing'), 'error');
     $InputError = true;
 }
 if (mb_strlen($_POST['ContractDescription']) < 10) {
     prnMsg(_('The contract description is expected to be more than 10 characters long. Please alter the contract description in full before proceeding.'), 'error');
     $InputError = true;
 }
 if (!Is_Date($_POST['RequiredDate'])) {
     prnMsg(_('The date the contract is required to be completed by must be entered in the format') . ' ' . $_SESSION['DefaultDateFormat'], 'error');
     $InputError = true;
 }
 if (Date1GreaterThanDate2(Date($_SESSION['DefaultDateFormat']), $_POST['RequiredDate']) and $_POST['RequiredDate'] != '') {
     prnMsg(_('The date that the contract is to be completed by is expected to be a date in the future. Make the required date a date after today before proceeding.'), 'error');
     $InputError = true;
 }
 if (!$InputError) {
     $_SESSION['Contract' . $identifier]->ContractRef = $_POST['ContractRef'];
     $_SESSION['Contract' . $identifier]->ContractDescription = $_POST['ContractDescription'];
     $_SESSION['Contract' . $identifier]->CategoryID = $_POST['CategoryID'];
     $_SESSION['Contract' . $identifier]->LocCode = $_POST['LocCode'];
     $_SESSION['Contract' . $identifier]->RequiredDate = $_POST['RequiredDate'];
     $_SESSION['Contract' . $identifier]->Margin = filter_number_format($_POST['Margin']);
     $_SESSION['Contract' . $identifier]->Status = $_POST['Status'];
     $_SESSION['Contract' . $identifier]->CustomerRef = $_POST['CustomerRef'];
     $_SESSION['Contract' . $identifier]->ExRate = filter_number_format($_POST['ExRate']);
     /*Get the first work centre for the users location - until we set this up properly */
     $result = DB_query("SELECT code FROM workcentres WHERE location='" . $_SESSION['Contract' . $identifier]->LocCode . "'");
Exemplo n.º 15
0
$title = _('MRP Create Demands');
include 'includes/header.inc';
if (isset($_POST['submit'])) {
    // Create mrpdemands based on sales order history
    $InputError = 0;
    if (isset($_POST['FromDate']) and !Is_Date($_POST['FromDate'])) {
        $msg = _('The date from must be specified in the format') . ' ' . $_SESSION['DefaultDateFormat'];
        $InputError = 1;
        unset($_POST['FromDate']);
    }
    if (isset($_POST['ToDate']) and !Is_Date($_POST['ToDate'])) {
        $msg = _('The date to must be specified in the format') . ' ' . $_SESSION['DefaultDateFormat'];
        $InputError = 1;
        unset($_POST['ToDate']);
    }
    if (isset($_POST['FromDate']) and isset($_POST['ToDate']) and Date1GreaterThanDate2($_POST['FromDate'], $_POST['ToDate'])) {
        $msg = _('The date to must be after the date from');
        $InputError = 1;
        unset($_POST['ToDate']);
        unset($_POST['FromoDate']);
    }
    if (isset($_POST['DistDate']) and !Is_Date($_POST['DistDate'])) {
        $msg = _('The distribution start date must be specified in the format') . ' ' . $_SESSION['DefaultDateFormat'];
        $InputError = 1;
        unset($_POST['DistDate']);
    }
    if (!is_numeric(filter_number_format($_POST['ExcludeQuantity']))) {
        $msg = _('The quantity below which no demand will be created must be numeric');
        $InputError = 1;
    }
    if (!is_numeric(filter_number_format($_POST['Multiplier']))) {
Exemplo n.º 16
0
echo '</div>
	  </form>';
echo '<br />';
if (isset($_POST['ShowSales'])) {
    $InputError = 0;
    //assume no input errors now test for errors
    if ($_POST['DateRange'] == 'Custom') {
        if (!Is_Date($_POST['FromDate'])) {
            $InputError = 1;
            prnMsg(_('The date entered for the from date is not in the appropriate format. Dates must be entered in the format') . ' ' . $_SESSION['DefaultDateFormat'], 'error');
        }
        if (!Is_Date($_POST['ToDate'])) {
            $InputError = 1;
            prnMsg(_('The date entered for the to date is not in the appropriate format. Dates must be entered in the format') . ' ' . $_SESSION['DefaultDateFormat'], 'error');
        }
        if (Date1GreaterThanDate2($_POST['FromDate'], $_POST['ToDate'])) {
            $InputError = 1;
            prnMsg(_('The from date is expected to be a date prior to the to date. Please review the selected date range'), 'error');
        }
    }
    switch ($_POST['DateRange']) {
        case 'ThisWeek':
            $FromDate = date('Y-m-d', mktime(0, 0, 0, date('m'), date('d') - date('w') + 1, date('Y')));
            $ToDate = date('Y-m-d');
            break;
        case 'ThisMonth':
            $FromDate = date('Y-m-d', mktime(0, 0, 0, date('m'), 1, date('Y')));
            $ToDate = date('Y-m-d');
            break;
        case 'ThisQuarter':
            switch (date('m')) {
Exemplo n.º 17
0
function ReSequenceEffectiveDates($Item, $PriceList, $CurrAbbrev, $QuantityBreak, $db)
{
    /*This is quite complicated - the idea is that prices set up should be unique and there is no way two prices could be returned as valid - when getting a price in includes/GetPrice.inc the logic is to first look for a price of the salestype/currency within the effective start and end dates - then if not get the price with a start date prior but a blank end date (the default price). We would not want two prices where one price falls inside another effective date range except in the case of a blank end date - ie no end date - the default price for the currency/salestype.
    	I first thought that we would need to update the previous default price (blank end date), when a new default price is entered, to have an end date of the startdate of this new default price less 1 day - but this is  converting a default price into a special price which could result in having two special prices over the same date range - best to leave it unchanged and use logic in the GetPrice.inc to ensure the correct default price is returned
    	*
    	* After further discussion (Ricard) if the new price has a blank end date - i.e. no end then the pre-existing price with no end date should be changed to have an end date just prior to the new default (no end date) price commencing
    	*/
    //this is just the case where debtorno='' - see the Prices_Customer.php script for customer special prices
    $SQL = "SELECT price,\r\n\t\t\t\t\t\tstartdate,\r\n\t\t\t\t\t\tenddate\r\n\t\t\t\tFROM pricematrix\r\n\t\t\t\tWHERE stockid='" . $Item . "'\r\n\t\t\t\tAND currabrev='" . $CurrAbbrev . "'\r\n\t\t\t\tAND salestype='" . $PriceList . "'\r\n\t\t\t\tAND quantitybreak='" . $QuantityBreak . "'\r\n\t\t\t\tORDER BY startdate, enddate";
    $result = DB_query($SQL);
    while ($myrow = DB_fetch_array($result)) {
        if (isset($NextStartDate)) {
            if (Date1GreaterThanDate2(ConvertSQLDate($myrow['startdate']), $NextStartDate)) {
                $NextStartDate = ConvertSQLDate($myrow['startdate']);
                //Only if the previous enddate is after the new start date do we need to look at updates
                if (Date1GreaterThanDate2(ConvertSQLDate($EndDate), ConvertSQLDate($myrow['startdate']))) {
                    /*Need to make the end date the new start date less 1 day */
                    $SQL = "UPDATE pricematrix SET enddate = '" . FormatDateForSQL(DateAdd($NextStartDate, 'd', -1)) . "'\r\n\t\t\t\t\t\t\t\t\t\tWHERE stockid ='" . $Item . "'\r\n\t\t\t\t\t\t\t\t\t\tAND currabrev='" . $CurrAbbrev . "'\r\n\t\t\t\t\t\t\t\t\t\tAND salestype='" . $PriceList . "'\r\n\t\t\t\t\t\t\t\t\t\tAND startdate ='" . $StartDate . "'\r\n\t\t\t\t\t\t\t\t\t\tAND enddate = '" . $EndDate . "'\r\n\t\t\t\t\t\t\t\t\t\tAND quantitybreak ='" . $QuantityBreak . "'";
                    $UpdateResult = DB_query($SQL);
                }
            }
            //end of if startdate  after NextStartDate - we have a new NextStartDate
        } else {
            $NextStartDate = ConvertSQLDate($myrow['startdate']);
        }
        $StartDate = $myrow['startdate'];
        $EndDate = $myrow['enddate'];
        $Price = $myrow['price'];
    }
    // end of loop around all prices
}
Exemplo n.º 18
0
    $_SESSION['Shipment']->ShiptRef = GetNextTransNo(31, $db);
}
if (isset($_POST['Update']) or isset($_GET['Add']) and $_SESSION['Shipment']->Closed == 0) {
    //user hit the update button
    $InputError = 0;
    if (isset($_POST['Update'])) {
        if (!Is_Date($_POST['ShipmentDate'])) {
            $InputError = 1;
            prnMsg(_('The date of expected arrival of the shipment must be entered in the format') . ' ' . $_SESSION['DefaultDateFormat'], 'error');
        } else {
            $_SESSION['Shipment']->ShipmentDate = FormatDateForSQL($_POST['ShipmentDate']);
        }
        if (!Is_Date($_POST['ETA'])) {
            $InputError = 1;
            prnMsg(_('The date of expected arrival of the shipment must be entered in the format') . ' ' . $_SESSION['DefaultDateFormat'], 'error');
        } elseif (Date1GreaterThanDate2($_POST['ETA'], $_POST['ShipmentDate']) == 0) {
            $InputError = 1;
            prnMsg(_('An expected arrival of the shipment must be a date after the shipment date'), 'error');
        } else {
            $_SESSION['Shipment']->ETA = FormatDateForSQL($_POST['ETA']);
        }
        if (mb_strlen($_POST['Vessel']) < 2) {
            prnMsg(_('A reference to the vessel of more than 2 characters is expected'), 'error');
        }
        if (mb_strlen($_POST['VoyageRef']) < 2) {
            prnMsg(_('A reference to the voyage (or HAWB in the case of air-freight) of more than 2 characters is expected'), 'error');
        }
    } elseif (mb_strlen($_SESSION['Shipment']->Vessel) < 2 or mb_strlen($_SESSION['Shipment']->VoyageRef) < 2) {
        prnMsg(_('Cannot add purchase order lines to the shipment unless the shipment is first initiated - hit update to setup the shipment first'), 'info');
        $InputError = 1;
    }