Esempio n. 1
0
function ParseLDAP()
{
    $ldap = new cronldap();
    $today = date('Y-m-d');
    $connect = $ldap->ldap_connection;
    $_GET["suffix"] = $ldap->suffix;
    $pattern = "(&(objectClass=UserArticaClass)(FinalDateToLive=*)(!(FinalDateToLive=0)))";
    $attr = array("uid", "FinalDateToLive", "dn");
    $sr = ldap_search($connect, $_GET["suffix"], $pattern, $attr);
    if ($sr) {
        $hash = ldap_get_entries($connect, $sr);
        if ($hash["count"] > 0) {
            for ($i = 0; $i < $hash["count"]; $i++) {
                $uid = $hash[$i]["uid"][0];
                $dn = $hash[$i]["dn"];
                $FinalDateToLive = $hash[$i][strtolower("FinalDateToLive")][0];
                $diff = DateDiff($today, $FinalDateToLive);
                echo "Analyze {$dn}: {$uid} :{$FinalDateToLive} ({$diff} day(s))\n";
                if ($diff < 0) {
                    echo "This user must be deleted...\n";
                    delete_ldap($dn, $connect, true);
                    DeleteMBX($uid);
                }
            }
        }
    }
    @ldap_unbind($connect);
    unset($GLOBALS["LDAP_BIN_ID"]);
    unset($GLOBALS["LDAP_CONNECT_ID"]);
    echo "\n";
}
Esempio n. 2
0
 public function updatecar($reg = '')
 {
     include "../connect.php";
     $sql = "SELECT * FROM checkcar WHERE registration='{$reg}'";
     $res = mysqli_query($conn, $sql);
     $i = 0;
     while ($row = mysqli_fetch_assoc($res)) {
         $ar[$i] = $row['date_'];
         if ($i > 0) {
             $d = (int) DateDiff($ar[$i], $ar[$i - 1]);
             $a = $ar[$i];
             if ($d < 0) {
                 $d = $d * -1;
             }
             // echo $d;
             mysqli_query($conn, "UPDATE checkcar SET countday='{$d}' WHERE registration='{$reg}' AND date_='{$a}'");
         }
         $i++;
     }
 }
Esempio n. 3
0
$_SESSION['countdate'] = DateDiff($_SESSION['date2'], $_SESSION['date3']);
$data = array("mild" => $_POST['mild'], "date" => $_POST['date'], "regis" => $_POST["regis"], "countdate" => $_SESSION['countdate']);
$_SESSION["datelate"] = $_POST['date'];
/*
$sql = "INSERT INTO checkcar.check_id, Car.registration
FROM checkcar
INNER JOIN Car
ON checkcar.check_id=Car.car_id";
*/
$sql = "INSERT INTO checkcar (registration, date_,mile_late)\n VALUES (?,?,?) ";
$qr = $conn->prepare($sql);
if ($qr === false) {
    trigger_error("Wrong SQL" . $sql . "Error :" . $conn->error, E_USER_ERROR);
}
$qr->bind_param("ssi", $data["regis"], $data["date"], $data["mild"]);
$qr->execute();
$reg = $data["regis"];
$result = mysql_query($conn, "SELECT * FROM checkcar WHERE registration={$reg}");
$i = 0;
while ($row = mysql_fetch_assoc($result)) {
    $ar[$i] = $row['date_'];
    if ($i % 2 == 1) {
        echo DateDiff($ar[$i], $ar[$i - 1]);
    }
}
$qr->close();
?>

	<script language="javascript">
	window.location = "../layout/page.php";
	</script>
         /*Tax being entered manually accept the taxamount entered as is*/
         $_SESSION['SuppTrans']->Taxes[$Tax->TaxCalculationOrder]->TaxOvAmount = filter_number_format($_POST['TaxAmount' . $Tax->TaxCalculationOrder]);
     }
     $TaxTotal += $_SESSION['SuppTrans']->Taxes[$Tax->TaxCalculationOrder]->TaxOvAmount;
 }
 $InputError = False;
 if ($TaxTotal + $_SESSION['SuppTrans']->OvAmount <= 0) {
     $InputError = True;
     prnMsg(_('The credit note as entered cannot be processed because the total amount of the credit note is less than or equal to 0') . '. ' . _('Credit notes are expected to be entered as positive amounts to credit'), 'warn');
 } elseif (mb_strlen($_SESSION['SuppTrans']->SuppReference) < 1) {
     $InputError = True;
     prnMsg(_('The credit note as entered cannot be processed because the there is no suppliers credit note number or reference entered') . '. ' . _('The supplier credit note number must be entered'), 'error');
 } elseif (!Is_Date($_SESSION['SuppTrans']->TranDate)) {
     $InputError = True;
     prnMsg(_('The credit note as entered cannot be processed because the date entered is not in the format') . ' ' . $_SESSION['DefaultDateFormat'], 'error');
 } elseif (DateDiff(Date($_SESSION['DefaultDateFormat']), $_SESSION['SuppTrans']->TranDate, 'd') < 0) {
     $InputError = True;
     prnMsg(_('The credit note as entered cannot be processed because the date is after today') . '. ' . _('Purchase credit notes are expected to have a date prior to or today'), 'error');
 } elseif ($_SESSION['SuppTrans']->ExRate <= 0) {
     $InputError = True;
     prnMsg(_('The credit note as entered cannot be processed because the exchange rate for the credit note has been entered as a negative or zero number') . '. ' . _('The exchange rate is expected to show how many of the suppliers currency there are in 1 of the local currency'), 'warn');
 } elseif ($_SESSION['SuppTrans']->OvAmount < round($TotalShiptValue + $TotalGLValue + $TotalAssetValue + $TotalGRNValue, $_SESSION['SuppTrans']->CurrDecimalPlaces)) {
     prnMsg(_('The credit note total as entered is less than the sum of the shipment charges') . ', ' . _('the general ledger entries (if any) and the charges for goods received') . '. ' . _('There must be a mistake somewhere') . ', ' . _('the credit note as entered will not be processed'), 'error');
     $InputError = True;
 } else {
     /* SQL to process the postings for purchase credit note */
     /*Start an SQL transaction */
     DB_Txn_Begin($db);
     /*Get the next transaction number for internal purposes and the period to post GL transactions in based on the credit note date*/
     $CreditNoteNo = GetNextTransNo(21, $db);
     $PeriodNo = GetPeriod($_SESSION['SuppTrans']->TranDate, $db);
Esempio n. 5
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_format($_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'];
                }
            } elseif ($TotalRequirement < $TotalSupply) {
                $TotalSupply -= $TotalRequirement;
                $Supplies[$supi]['supplyquantity'] -= $TotalRequirement;
                $TotalRequirement = 0;
                $Requirements[$reqi]['quantity'] = 0;
                $reqi++;
                if ($RequirementCount > $reqi) {
                    $TotalRequirement += $Requirements[$reqi]['quantity'];
                }
            } else {
                $TotalSupply -= $TotalRequirement;
                $Supplies[$supi]['supplyquantity'] -= $TotalRequirement;
                $TotalRequirement = 0;
                $Requirements[$reqi]['quantity'] = 0;
                $reqi++;
                if ($RequirementCount > $reqi) {
                    $TotalRequirement += $Requirements[$reqi]['quantity'];
                }
                $TotalRequirement -= $TotalSupply;
                $Requirements[$reqi]['quantity'] -= $TotalSupply;
                $TotalSupply = 0;
                $Supplies[$supi]['supplyquantity'] = 0;
                $supi++;
                if ($SupplyCount > $supi) {
                    $TotalSupply += $Supplies[$supi]['supplyquantity'];
                }
            }
            // 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);
        }
    }
}
Esempio n. 6
0
                                 $db->Query("DELETE FROM ad_exits WHERE id='{$id_ad}' AND affid='{$affid}' LIMIT 1");
                             }
                         }
                     }
                 }
             }
         }
         $db->Query("DELETE FROM ad_purchased WHERE id='{$id}' AND affid='{$affid}' LIMIT 1");
         echo "affid={$affid} deleted purchased ad id={$id} type={$type}\n";
     }
 }
 // delete unverified signups after 3 days
 $db->Query("SELECT affid, username, pass, fname, lname, email, datesignedup FROM users WHERE verified='0'");
 $result = $db->result;
 while (list($affid, $username, $pass, $fname, $lname, $email, $datesignedup) = mysqli_fetch_row($result)) {
     $num_days = DateDiff(mysql_datetime_to_timestamp($datesignedup), time(), 'd');
     $num_days = round($num_days);
     if ($num_days > 3) {
         $db->Query("DELETE FROM users WHERE affid='{$affid}' LIMIT 1");
     } else {
         $hash = substr(md5(strrev(sha1($affid))), 0, 5);
         $val_url = "http://freeadplanet.com/?c=validatesignup&affid={$affid}&h={$hash}";
         @mail($email, 'Free AD Planet - Validate Account Notice', "Hello {$fname} {$lname},\n\nVisit the URL below to Validate your Account.\n\n{$val_url}\n\nUsername: {$username}\nPassword: {$pass}\n\nRegards,\nhttp://freeadplanet.com Staff", $headers);
         //@mail('*****@*****.**', 'Free AD Planet - Validate Account Notice', "Hello $fname $lname,\n\nVisit the URL below to Validate your Account.\n\n$val_url\n\nUsername: $username\nPassword: $pass\n\nRegards,\nhttp://freeadplanet.com Staff", $headers);
     }
 }
 // calculate new Quota Week
 if ($dayOfWeek == 'Mon') {
     echo "\n** dayOfWeek={$dayOfWeek} which is new quota week\n";
     $db->Query("SELECT affid, status, weekadcount, weekadmissed FROM users WHERE verified != '0' ORDER BY affid");
     $result = $db->result;
Esempio n. 7
0
     $opvboost1 = date("l, dS of F, Y", $opvboost1);
 }
 if ($today > $opvboost2) {
     $opvboost2 = date("l, dS of F, Y", $opvboost2);
     $opvboost2 = "<font color=#FF0000>{$opvboost2}</font>";
 } else {
     $opvboost2 = date("l, dS of F, Y", $opvboost2);
 }
 if ($today > $dtboost) {
     $dtboost = date("l, dS of F, Y", $dtboost);
     $dtboost = "<font color=#FF0000>{$dtboost}</font>";
 } else {
     $dtboost = date("l, dS of F, Y", $dtboost);
 }
 // Calculate the child's age in days
 $childAgeInDays = DateDiff("d", $dobdate, $today);
 // Calculate the child's age in months
 $childAgeInMonths = $childAgeInDays / 30;
 // Calculate the child's age in years
 $childAgeInYears = floor($childAgeInMonths / 12);
 if ($childAgeInYears < 1) {
     $childAgeInMs = floor($childAgeInDays / 30);
     $childAgeInDs = $childAgeInDays % 30;
 }
 if ($childAgeInYears >= 1) {
     $childAgeInMs = floor($childAgeInDays / 30);
     $childAgeInMs = $childAgeInMs - $childAgeInYears * 12;
 }
 // Format the DOB in a presentable form
 $dobdate = date("l, dS of F, Y", $dobdate);
 ?>
Esempio n. 8
0
 }
 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;
     }
 }
 if (!in_array('EffectiveAfter', $Errors)) {
Esempio n. 9
0
        $assetarray[$i]['bsdepnaccount'] = $bsnamerow['accountname'];
        $plnamesql = 'SELECT accountname FROM chartmaster WHERE accountcode="' . $assetarray[$i]['pldepn'] . '"';
        $plnameresult = DB_query($plnamesql, $db);
        $plnamerow = DB_fetch_array($plnameresult);
        $assetarray[$i]['pldepnaccount'] = $plnamerow['accountname'];
        /* Need a method to correctly enter the journal date,
         * and for it to be available to the depn calculation - Tim
         */
        if (isset($_POST['JournalProcessDate'])) {
            $_SESSION['JournalDetail']->JnlDate = $_POST['JournalProcessDate'];
        }
        if (!Is_Date($_SESSION['JournalDetail']->JnlDate)) {
            // Default the date to the last day of the previous month
            $_SESSION['JournalDetail']->JnlDate = Date($_SESSION['DefaultDateFormat'], mktime(0, 0, 0, date('m'), 0, date('Y')));
        }
        $NoOfMonths = DateDiff($_SESSION['JournalDetail']->JnlDate, ConvertSQLDate($assetarray[$i]['datepurchased']), 'm');
        if ($assetarray[$i]['DepreciationType'] == _('Straight Line')) {
            $TotalDepnAmount = round($NoOfMonths / 12 * ($assetarray[$i]['DepreciationRate'] / 100) * $assetarray[$i]['cost'], 2);
        } else {
            $TotalDepnAmount = round($NoOfMonths / 12 * ($assetarray[$i]['DepreciationRate'] / 100) * ($assetarray[$i]['cost'] - $assetarray[$i]['depn']), 2);
        }
        if ($TotalDepnAmount + $assetarray[$i]['disposalvalue'] > $assetarray[$i]['cost']) {
            $TotalDepnAmount = $assetarray[$i]['cost'] - $assetarray[$i]['disposalvalue'];
        }
        $assetarray[$i]['narrative'] = 'Depreciation Journal - ' . $assetarray[$i]['stockid'] . ' - ' . $assetarray[$i]['serialno'] . ' - ' . $assetarray[$i]['locationdescription'];
        $_SESSION['JournalDetail']->Add_To_GLAnalysis(-($TotalDepnAmount - $assetarray[$i]['depn']), $assetarray[$i]['narrative'], $assetarray[$i]['bsdepn'], $assetarray[$i]['bsdepnaccount'], 0, $assetarray[$i]['id']);
        $_SESSION['JournalDetail']->Add_To_GLAnalysis($TotalDepnAmount - $assetarray[$i]['depn'], $assetarray[$i]['narrative'], $assetarray[$i]['pldepn'], $assetarray[$i]['pldepnaccount'], 0, $assetarray[$i]['id']);
        $i++;
    }
}
if (isset($_POST['JournalProcessDate'])) {
Esempio n. 10
0
				<th>' . _('Order Total') . ' ' . _('in') . ' ' . $_SESSION['CompanyRecord']['currencydefault'] . '</th>
			</tr>';
    $SQL = "SELECT salesorders.orderno,\n\t\t\t\t\t\tdebtorsmaster.name,\n\t\t\t\t\t\tcustbranch.brname,\n\t\t\t\t\t\tsalesorders.customerref,\n\t\t\t\t\t\tsalesorders.orddate,\n\t\t\t\t\t\tsalesorders.deliverto,\n\t\t\t\t\t\tsalesorders.deliverydate,\n\t\t\t\t\t\tsalesorders.printedpackingslip,\n\t\t\t\t\t\tsalesorders.poplaced,\n\t\t\t\t\t\tSUM(salesorderdetails.unitprice*salesorderdetails.quantity*(1-salesorderdetails.discountpercent)/currencies.rate) AS ordervalue\n\t\t\t\t\tFROM salesorders INNER JOIN salesorderdetails\n\t\t\t\t\t\tON salesorders.orderno = salesorderdetails.orderno\n\t\t\t\t\t\tINNER JOIN debtorsmaster\n\t\t\t\t\t\tON salesorders.debtorno = debtorsmaster.debtorno\n\t\t\t\t\t\tINNER JOIN custbranch\n\t\t\t\t\t\tON debtorsmaster.debtorno = custbranch.debtorno\n\t\t\t\t\t\tAND salesorders.branchcode = custbranch.branchcode\n\t\t\t\t\t\tINNER JOIN currencies\n\t\t\t\t\t\tON debtorsmaster.currcode = currencies.currabrev\n\t\t\t\t\tWHERE salesorderdetails.completed=0\n\t\t\t\t\tAND salesorders.quotation =0\n\t\t\t\t\tGROUP BY salesorders.orderno,\n\t\t\t\t\t\tdebtorsmaster.name,\n\t\t\t\t\t\tcustbranch.brname,\n\t\t\t\t\t\tsalesorders.customerref,\n\t\t\t\t\t\tsalesorders.orddate,\n\t\t\t\t\t\tsalesorders.deliverto,\n\t\t\t\t\t\tsalesorders.deliverydate,\n\t\t\t\t\t\tsalesorders.printedpackingslip\n\t\t\t\t\tORDER BY salesorders.orddate DESC, salesorders.orderno";
    $ErrMsg = _('No orders or quotations were returned by the SQL because');
    $SalesOrdersResult = DB_query($SQL, $ErrMsg);
    /*show a table of the orders returned by the SQL */
    if (DB_num_rows($SalesOrdersResult) > 0) {
        $k = 0;
        //row colour counter
        $OrdersTotal = 0;
        $FontColor = '';
        while ($myrow = DB_fetch_array($SalesOrdersResult)) {
            $OrderDate = ConvertSQLDate($myrow['orddate']);
            $FormatedDelDate = ConvertSQLDate($myrow['deliverydate']);
            $FormatedOrderValue = locale_number_format($myrow['ordervalue'], $_SESSION['CompanyRecord']['decimalplaces']);
            if (DateDiff(Date($_SESSION['DefaultDateFormat']), $OrderDate, 'd') > 5) {
                $FontColor = ' style="color:green; font-weight:bold"';
            }
            if ($k == 1) {
                echo '<tr class="EvenTableRows">';
                $k = 0;
            } else {
                echo '<tr class="OddTableRows">';
                $k++;
            }
            printf('<td><a href="%s" target="_blank">' . $myrow['orderno'] . '</a></td>
					<td' . $FontColor . '>%s</td>
					<td' . $FontColor . '>%s</td>
					<td' . $FontColor . '>%s</td>
					<td' . $FontColor . '>%s</td>
					<td' . $FontColor . '>%s</td>
Esempio n. 11
0
         }
     }
 } else {
     $STATUS_COLOR = "#00AA00";
     $CAL_TITLE .= "状态:已完成";
 }
 if ($MANAGER_ID != "") {
     $query = "SELECT USER_NAME from USER where USER_ID='" . $MANAGER_ID . "'";
     $rs = $db->Execute($query);
     $rs_b = $rs->GetArray();
     if (sizeof($rs_b) > 0) {
         $CAL_TITLE .= "\n安排人:" . $rs_b[0]['USER_NAME'];
     }
 }
 $CONTENT = htmlspecialchars($CONTENT);
 $days = DateDiff("d", $CAL_TIME, $END_TIME);
 $showBeginDate = substr($CAL_TIME, 11, 5);
 $showEndDate = substr($END_TIME, 11, 5);
 if ($days > 0) {
     $showBeginDate = date("d日H:i", strtotime($CAL_TIME));
     $showEndDate = date("d日H:i", strtotime($END_TIME));
 }
 $CONTENT = "<div id=\"cal_" . $CAL_ID . "\" title='" . $CAL_TITLE . "'>" . $showBeginDate . "-" . $showEndDate . ("<br><a href='javascript:my_note(" . $CAL_ID . ");' style='color:") . $STATUS_COLOR . ";'>" . $CONTENT . "</a>";
 $CONTENT .= "<br><span id=\"cal_" . $CAL_ID . "_op\" style=\"display:none;\">";
 if ($user_id == $_SESSION['LOGIN_USER_ID']) {
     if ($OVER_STATUS == "0") {
         $CONTENT .= "<a href=\"../calendar_newai.php?action=finish&id=" . $CAL_ID . "&OVER_STATUS=1&YEAR={$YEAR}&MONTH={$MONTH}&DAY={$DAY}\"> 完成</a>";
     } else {
         if ($OVER_STATUS == "" || $OVER_STATUS == "1") {
             $CONTENT .= "<a href=\"../calendar_newai.php?action=finish&id=" . $CAL_ID . "&OVER_STATUS=0&YEAR={$YEAR}&MONTH={$MONTH}&DAY={$DAY}\"> 未完成</a>";
         }
				<th>' . _('Depn Type') . '</th>
				<th>' . _('Depn Rate') . '</th>
				<th>' . _('New Depn') . '</th>
			</tr>';
echo $Heading;
$AssetCategoryDescription = '0';
$TotalCost = 0;
$TotalAccumDepn = 0;
$TotalDepn = 0;
$RowCounter = 0;
$TotalCategoryCost = 0;
$TotalCategoryAccumDepn = 0;
$TotalCategoryDepn = 0;
$k = 0;
while ($AssetRow = DB_fetch_array($AssetsResult)) {
    $MonthsOwned = DateDiff($_POST['ProcessDate'], ConvertSQLDate($AssetRow['datepurchased']), 'm');
    if ($AssetCategoryDescription != $AssetRow['categorydescription'] or $AssetCategoryDescription == '0') {
        if ($AssetCategoryDescription != '0') {
            //then print totals
            echo '<tr><th colspan="3" align="right">' . _('Total for') . ' ' . $AssetCategoryDescription . ' </th>
						<th class="number">' . locale_money_format($TotalCategoryCost, $_SESSION['CompanyRecord']['currencydefault']) . '</th>
						<th class="number">' . locale_money_format($TotalCategoryAccumDepn, $_SESSION['CompanyRecord']['currencydefault']) . '</th>
						<th class="number">' . locale_money_format($TotalCategoryCost - $TotalCategoryAccumDepn, $_SESSION['CompanyRecord']['currencydefault']) . '</th>
						<th colspan="2"></th>
						<th class="number">' . locale_money_format($TotalCategoryDepn, $_SESSION['CompanyRecord']['currencydefault']) . '</th>
					</tr>';
        }
        echo '<tr><th colspan="9" align="left">' . $AssetRow['categorydescription'] . '</th></tr>';
        $AssetCategoryDescription = $AssetRow['categorydescription'];
        $TotalCategoryCost = 0;
        $TotalCategoryAccumDepn = 0;
Esempio n. 13
0
function userLogin($Name, $Password, $SysAdminEmail = '', $db)
{
    global $debug;
    global $PathPrefix;
    if (!isset($_SESSION['AccessLevel']) or $_SESSION['AccessLevel'] == '' or isset($Name) and $Name != '') {
        /* if not logged in */
        $_SESSION['AccessLevel'] = '';
        $_SESSION['CustomerID'] = '';
        $_SESSION['UserBranch'] = '';
        $_SESSION['SalesmanLogin'] = '';
        $_SESSION['Module'] = '';
        $_SESSION['PageSize'] = '';
        $_SESSION['UserStockLocation'] = '';
        $_SESSION['AttemptsCounter']++;
        // Show login screen
        if (!isset($Name) or $Name == '') {
            $_SESSION['DatabaseName'] = '';
            $_SESSION['CompanyName'] = '';
            return UL_SHOWLOGIN;
        }
        /* The SQL to get the user info must use the * syntax because the field name could change between versions if the fields are specifed directly then the sql fails and the db upgrade will fail */
        $sql = "SELECT *\n\t\t\t\tFROM www_users\n\t\t\t\tWHERE www_users.userid='" . $Name . "'";
        $ErrMsg = _('Could not retrieve user details on login because');
        $debug = 1;
        $PasswordVerified = false;
        $Auth_Result = DB_query($sql, $ErrMsg);
        if (DB_num_rows($Auth_Result) > 0) {
            $myrow = DB_fetch_array($Auth_Result);
            if (VerifyPass($Password, $myrow['password'])) {
                $PasswordVerified = true;
            } elseif (isset($GLOBALS['CryptFunction'])) {
                /*if the password stored in the DB was compiled the old way,
                 * the previous comparison will fail,
                 * try again with the old hashing algorithm,
                 * then re-hash the password using the new algorithm.
                 * The next version should not have $CryptFunction any more for new installs.
                 */
                switch ($GLOBALS['CryptFunction']) {
                    case 'sha1':
                        if ($myrow['password'] == sha1($Password)) {
                            $PasswordVerified = true;
                        }
                        break;
                    case 'md5':
                        if ($myrow['password'] == md5($Password)) {
                            $PasswordVerified = true;
                        }
                        break;
                    default:
                        if ($myrow['password'] == $Password) {
                            $PasswordVerified = true;
                        }
                }
                if ($PasswordVerified) {
                    $sql = "UPDATE www_users SET password = '******'" . " WHERE userid = '" . $Name . "';";
                    DB_query($sql);
                }
            }
        }
        // Populate session variables with data base results
        if ($PasswordVerified) {
            if ($myrow['blocked'] == 1) {
                //the account is blocked
                return UL_BLOCKED;
            }
            /*reset the attempts counter on successful login */
            $_SESSION['UserID'] = $myrow['userid'];
            $_SESSION['AttemptsCounter'] = 0;
            $_SESSION['AccessLevel'] = $myrow['fullaccess'];
            $_SESSION['CustomerID'] = $myrow['customerid'];
            $_SESSION['UserBranch'] = $myrow['branchcode'];
            $_SESSION['DefaultPageSize'] = $myrow['pagesize'];
            $_SESSION['UserStockLocation'] = $myrow['defaultlocation'];
            $_SESSION['UserEmail'] = $myrow['email'];
            $_SESSION['ModulesEnabled'] = explode(",", $myrow['modulesallowed']);
            $_SESSION['UsersRealName'] = $myrow['realname'];
            $_SESSION['Theme'] = $myrow['theme'];
            $_SESSION['Language'] = $myrow['language'];
            $_SESSION['SalesmanLogin'] = $myrow['salesman'];
            $_SESSION['CanCreateTender'] = $myrow['cancreatetender'];
            $_SESSION['AllowedDepartment'] = $myrow['department'];
            $_SESSION['ShowDashboard'] = $myrow['showdashboard'];
            if (isset($myrow['pdflanguage'])) {
                $_SESSION['PDFLanguage'] = $myrow['pdflanguage'];
            } else {
                $_SESSION['PDFLanguage'] = '0';
                //default to latin western languages
            }
            if ($myrow['displayrecordsmax'] > 0) {
                $_SESSION['DisplayRecordsMax'] = $myrow['displayrecordsmax'];
            } else {
                $_SESSION['DisplayRecordsMax'] = $_SESSION['DefaultDisplayRecordsMax'];
                // default comes from config.php
            }
            $sql = "UPDATE www_users SET lastvisitdate='" . date('Y-m-d H:i:s') . "'\n\t\t\t\t\t\t\tWHERE www_users.userid='" . $Name . "'";
            $Auth_Result = DB_query($sql);
            /*get the security tokens that the user has access to */
            $sql = "SELECT tokenid\n\t\t\t\t\tFROM securitygroups\n\t\t\t\t\tWHERE secroleid =  '" . $_SESSION['AccessLevel'] . "'";
            $Sec_Result = DB_query($sql);
            $_SESSION['AllowedPageSecurityTokens'] = array();
            if (DB_num_rows($Sec_Result) == 0) {
                return UL_CONFIGERR;
            } else {
                $i = 0;
                $UserIsSysAdmin = FALSE;
                while ($myrow = DB_fetch_row($Sec_Result)) {
                    if ($myrow[0] == 15) {
                        $UserIsSysAdmin = TRUE;
                    }
                    $_SESSION['AllowedPageSecurityTokens'][$i] = $myrow[0];
                    $i++;
                }
            }
            /*User is logged in so get configuration parameters  - save in session*/
            include $PathPrefix . 'includes/GetConfig.php';
            if (isset($_SESSION['DB_Maintenance'])) {
                if ($_SESSION['DB_Maintenance'] > 0) {
                    //run the DB maintenance script
                    if (DateDiff(Date($_SESSION['DefaultDateFormat']), ConvertSQLDate($_SESSION['DB_Maintenance_LastRun']), 'd') >= $_SESSION['DB_Maintenance']) {
                        /*Do the DB maintenance routing for the DB_type selected */
                        DB_Maintenance();
                        $_SESSION['DB_Maintenance_LastRun'] = Date('Y-m-d');
                        /* Audit trail purge only runs if DB_Maintenance is enabled */
                        if (isset($_SESSION['MonthsAuditTrail'])) {
                            $sql = "DELETE FROM audittrail\n\t\t\t\t\t\t\t\t\tWHERE  transactiondate <= '" . Date('Y-m-d', mktime(0, 0, 0, Date('m') - $_SESSION['MonthsAuditTrail'])) . "'";
                            $ErrMsg = _('There was a problem deleting expired audit-trail history');
                            $result = DB_query($sql);
                        }
                    }
                }
            }
            /*Check to see if currency rates need to be updated */
            if (isset($_SESSION['UpdateCurrencyRatesDaily'])) {
                if ($_SESSION['UpdateCurrencyRatesDaily'] != 0) {
                    /* Only run the update to currency rates if today is after the last update i.e. only runs once a day */
                    if (DateDiff(Date($_SESSION['DefaultDateFormat']), ConvertSQLDate($_SESSION['UpdateCurrencyRatesDaily']), 'd') > 0) {
                        if ($_SESSION['ExchangeRateFeed'] == 'ECB') {
                            $CurrencyRates = GetECBCurrencyRates();
                            // gets rates from ECB see includes/MiscFunctions.php
                            /*Loop around the defined currencies and get the rate from ECB */
                            if ($CurrencyRates != false) {
                                $CurrenciesResult = DB_query("SELECT currabrev FROM currencies");
                                while ($CurrencyRow = DB_fetch_row($CurrenciesResult)) {
                                    if ($CurrencyRow[0] != $_SESSION['CompanyRecord']['currencydefault']) {
                                        $UpdateCurrRateResult = DB_query("UPDATE currencies SET rate='" . GetCurrencyRate($CurrencyRow[0], $CurrencyRates) . "'\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE currabrev='" . $CurrencyRow[0] . "'", $db);
                                    }
                                }
                            }
                        } else {
                            $CurrenciesResult = DB_query("SELECT currabrev FROM currencies");
                            while ($CurrencyRow = DB_fetch_row($CurrenciesResult)) {
                                if ($CurrencyRow[0] != $_SESSION['CompanyRecord']['currencydefault']) {
                                    $UpdateCurrRateResult = DB_query("UPDATE currencies SET rate='" . google_currency_rate($CurrencyRow[0]) . "'\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE currabrev='" . $CurrencyRow[0] . "'", $db);
                                }
                            }
                        }
                        $_SESSION['UpdateCurrencyRatesDaily'] = Date('Y-m-d');
                        $UpdateConfigResult = DB_query("UPDATE config SET confvalue = '" . Date('Y-m-d') . "' WHERE confname='UpdateCurrencyRatesDaily'");
                    }
                }
            }
            /* Set the logo if not yet set.
             * will be done only once per session and each time
             * we are not in session (i.e. before login)
             */
            if (empty($_SESSION['LogoFile'])) {
                /* find a logo in companies/CompanyDir */
                if (file_exists($PathPrefix . 'companies/' . $_SESSION['DatabaseName'] . '/logo.png')) {
                    $_SESSION['LogoFile'] = 'companies/' . $_SESSION['DatabaseName'] . '/logo.png';
                } elseif (file_exists($PathPrefix . 'companies/' . $_SESSION['DatabaseName'] . '/logo.jpg')) {
                    $_SESSION['LogoFile'] = 'companies/' . $_SESSION['DatabaseName'] . '/logo.jpg';
                }
            }
            if (!isset($_SESSION['DB_Maintenance'])) {
                return UL_CONFIGERR;
            } else {
                if ($_SESSION['DB_Maintenance'] == -1 and !in_array(15, $_SESSION['AllowedPageSecurityTokens'])) {
                    // the configuration setting has been set to -1 ==> Allow SysAdmin Access Only
                    // the user is NOT a SysAdmin
                    return UL_MAINTENANCE;
                }
            }
        } else {
            // Incorrect password
            // 5 login attempts, show failed login screen
            if (!isset($_SESSION['AttemptsCounter'])) {
                $_SESSION['AttemptsCounter'] = 0;
            } elseif ($_SESSION['AttemptsCounter'] >= 5 and isset($Name)) {
                /*User blocked from future accesses until sysadmin releases */
                $sql = "UPDATE www_users\n\t\t\t\t\t\t\tSET blocked=1\n\t\t\t\t\t\t\tWHERE www_users.userid='" . $Name . "'";
                $Auth_Result = DB_query($sql);
                if ($SysAdminEmail != '') {
                    $EmailSubject = _('User access blocked') . ' ' . $Name;
                    $EmailText = _('User ID') . ' ' . $Name . ' - ' . $Password . ' - ' . _('has been blocked access at') . ' ' . Date('Y-m-d H:i:s') . ' ' . _('from IP') . ' ' . $_SERVER["REMOTE_ADDR"] . ' ' . _('due to too many failed attempts.');
                    if ($_SESSION['SmtpSetting'] == 0) {
                        mail($SysAdminEmail, $EmailSubject, $EmailText);
                    } else {
                        include 'includes/htmlMimeMail.php';
                        $mail = new htmlMimeMail();
                        $mail->setSubject($EmailSubject);
                        $mail->setText($EmailText);
                        $result = SendmailBySmtp($mail, array($SysAdminEmail));
                    }
                }
                return UL_BLOCKED;
            }
            return UL_NOTVALID;
        }
    }
    // End of userid/password check
    // Run with debugging messages for the system administrator(s) but not anyone else
    return UL_OK;
    /* All is well */
}
Esempio n. 14
0
: <?php 
    echo $ratio;
    ?>
<br />
		<?php 
    echo T_("AVG_DAILY_DL");
    ?>
: <?php 
    echo mksize($user["downloaded"] / (DateDiff($user["added"], time()) / 86400));
    ?>
<br />
		<?php 
    echo T_("AVG_DAILY_UL");
    ?>
: <?php 
    echo mksize($user["uploaded"] / (DateDiff($user["added"], time()) / 86400));
    ?>
<br />
		<?php 
    echo T_("TORRENTS_POSTED");
    ?>
: <?php 
    echo number_format($numtorrents);
    ?>
<br />
		<?php 
    echo T_("COMMENTS_POSTED");
    ?>
: <?php 
    echo number_format($numcomments);
    ?>
Esempio n. 15
0
 function DrawLine($ACEC)
 {
     $vBranchInfo = GetBranchInfo();
     $vHeight = $this->FontSize * 1.5;
     $vRowData = array();
     $vCECDate = ExtractWord($ACEC['date'], ' ', 0);
     $vCaseID = $ACEC['case_id'];
     $vNumCECesBefore = GetNumCECes($vCaseID, $vCECDate, $ACEC['id']);
     $vCECNumber = $ACEC['cec_number'];
     if ($vCECNumber == 0) {
         $vCECNumber = '';
     }
     $vRowData[] = $vCECNumber . "\n(" . ($vNumCECesBefore + 1) . ')';
     //   'Дата',
     $vRowData[] = Date2Readable($vCECDate);
     //   'Врач',
     $vRowData[] = FormatUserName($ACEC['user_id']);
     //   'Ф.И.О. больного' & 'Дата рождения'
     //            $vRowData[] = FormatName($ACEC['last_name'], $ACEC['first_name'],$ACEC['patr_name'])
     $vRowData[] = FormatNameEx($ACEC) . "\n" . FormatBornDateAndAge($vCECDate, $ACEC['born_date']) . "\nи.б. " . $vCaseID;
     //            $vRowData[] = FormatSex($ACase['is_male']);
     //   'Адрес',
     $vRowData[] = FormatAddress($ACEC['addr_reg_street'], $ACEC['addr_reg_num'], $ACEC['addr_reg_subnum'], $ACEC['addr_reg_apartment']);
     //            $vRowData[] = $ACase['phone'];
     //   'Место работы' & 'Профессия'
     $vTmpList = array();
     $vTmp = FormatWorkableAge($vCECDate, $ACEC['born_date'], $ACEC['is_male']);
     if (!empty($vTmp)) {
         $vTmpList[] = $vTmp;
     }
     $vTmp = FormatCategory($ACEC['employment_category_id']);
     if (!empty($vTmp)) {
         $vTmpList[] = $vTmp;
     }
     $vTmp = $ACEC['employment_place'];
     if (!empty($vTmp)) {
         $vTmpList[] = $vTmp;
     }
     $vTmp = $ACEC['profession'];
     if (!empty($vTmp)) {
         $vTmpList[] = $vTmp;
     }
     $vRowData[] = implode(",\n", $vTmpList);
     //   'Диагноз',
     $vRowData[] = $ACEC['diagnosis'];
     //   '№ листка нетрудоспособности',
     $vTmp = $ACEC['ill_doc'];
     if (!empty($vTmp)) {
         $vTmp .= "\n" . Date2Readable($ACEC['disability_from_date']);
         $vTmp .= "\n" . Date2Readable($vCECDate);
         $vTmp .= "\n(" . (DateDiff($vCECDate, $ACEC['disability_from_date']) + 1) . ')';
     }
     $vRowData[] = $vTmp;
     //   'Заключение комиссии'
     $vRowData[] = "лечение продлено\nс " . Date2Readable(DateAddDay($vCECDate)) . "\nпо " . Date2Readable($ACEC['cec_cureup_date']) . "\n(" . DateDiff($ACEC['cec_cureup_date'], $vCECDate) . ')';
     //   'Подписи членов комиссии'
     $vTmp = $ACEC['cec_members'];
     if (empty($vTmp)) {
         $vTmp = $vBranchInfo['cec_members'];
     }
     $vRowData[] = $vTmp;
     foreach ($vRowData as &$v) {
         $v = iconv('utf-8', 'cp1251', $v);
     }
     $this->OutTableRow($vHeight, $vRowData);
 }
Esempio n. 16
0
     $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'];
 }
 $catidsql = 'SELECT stkcatpropid FROM stockcatproperties WHERE categoryid="' . $_POST['assetcategory'] . '" AND label="' . _('Annual Internal Depreciation Percentage') . '"';
 $catidresult = DB_query($catidsql, $db);
 $catidrow = DB_fetch_array($catidresult);
 $catvaluesql = 'SELECT value FROM stockitemproperties WHERE stockid="' . $myrow['stockid'] . '" AND stkcatpropid=' . $catidrow['stkcatpropid'];
 $catvalueresult = DB_query($catvaluesql, $db);
 $catvaluerow = DB_fetch_array($catvalueresult);
 $MonthsOld = DateDiff(date('d/m/Y'), ConvertSQLDate($myrow['datepurchased']), 'm');
 $InternalDepreciation = $myrow['cost'] * $catvaluerow['value'] / 100 * $MonthsOld / 12;
 if ($InternalDepreciation + $myrow['disposalvalue'] > $myrow['cost']) {
     $InternalDepreciation = $myrow['cost'] - $myrow['disposalvalue'];
 }
 echo '<tr><td style="vertical-align:top">' . $myrow['id'] . '</td>';
 echo '<td style="vertical-align:top">' . $myrow['stockid'] . '</td>';
 echo '<td style="vertical-align:top">' . $myrow['longdescription'] . '</td>';
 echo '<td style="vertical-align:top">' . $myrow['serialno'] . '</td>';
 echo '<td>' . $myrow['locationdescription'] . '<br>';
 for ($i = 1; $i < sizeOf($ancestors) - 1; $i++) {
     for ($j = 0; $j < $i; $j++) {
         echo '&nbsp;&nbsp;&nbsp;&nbsp;';
     }
     echo '|_' . $ancestors[$i] . '<br>';
 }
Esempio n. 17
0
     @mail('*****@*****.**', 'WARNING: List payment over due: ' . $today, $late_bill_message, $headers);
 }
 /////////////////////////////////////////
 // handle billing for safelist members //
 /////////////////////////////////////////
 $db->SelectDB('mle');
 // loop each list check for do billing check
 $db->Query("SELECT paylinkparams, listownerID, listname FROM listmanager WHERE created='1'");
 $lists = $db->result;
 while (list($params, $id, $list) = mysqli_fetch_row($lists)) {
     $parts = explode('|', $params);
     if ($parts[10]) {
         $db->Query("SELECT userID, datelastbilled FROM users WHERE verified='yes' AND status != 'mem' AND memberpaid='1' AND listname='{$list}' AND listownerID='{$id}'");
         $users = $db->result;
         while (list($uID, $datelastbilled) = mysqli_fetch_row($users)) {
             $months = DateDiff(mysql_datetime_to_timestamp($datelastbilled), time(), 'm');
             switch ($parts[11]) {
                 case 0:
                     if ($months > 0) {
                         $db->Query("UPDATE users SET memberpaid='0', datelastbilled=NOW() WHERE userID='{$uID}' LIMIT 1");
                         $maildata .= "list: {$list} User: {$uID} paid reset to 0 - monthly\n";
                     }
                     break;
                 case 1:
                     if ($months > 1) {
                         $db->Query("UPDATE users SET memberpaid='0', datelastbilled=NOW() WHERE userID='{$uID}' LIMIT 1");
                         $maildata .= "list: {$list} User: {$uID} paid reset to 0 - bi monthly\n";
                     }
                     break;
                 case 2:
                     if ($months > 2) {
Esempio n. 18
0
        $_SESSION['Shipment']->VoyageRef = $_POST['VoyageRef'];
    }
    /*The user hit the update the shipment button and there are some lines on the shipment*/
    if ($InputError == 0 and (count($_SESSION['Shipment']->LineItems) > 0 or isset($_GET['Add']))) {
        $sql = "SELECT shiptref FROM shipments WHERE shiptref =" . $_SESSION['Shipment']->ShiptRef;
        $result = DB_query($sql);
        if (DB_num_rows($result) == 1) {
            $sql = "UPDATE shipments SET vessel='" . $_SESSION['Shipment']->Vessel . "',\n\t\t\t\t\t\t\t\t\t\tvoyageref='" . $_SESSION['Shipment']->VoyageRef . "',\n\t\t\t\t\t\t\t\t\t\teta='" . $_SESSION['Shipment']->ETA . "'\n\t\t\t\t\tWHERE shiptref ='" . $_SESSION['Shipment']->ShiptRef . "'";
        } else {
            $sql = "INSERT INTO shipments (shiptref,\n\t\t\t\t\t\t\tvessel,\n\t\t\t\t\t\t\tvoyageref,\n\t\t\t\t\t\t\teta,\n\t\t\t\t\t\t\tsupplierid)\n\t\t\t\t\tVALUES ('" . $_SESSION['Shipment']->ShiptRef . "',\n\t\t\t\t\t\t'" . $_SESSION['Shipment']->Vessel . "',\n\t\t\t\t\t\t'" . $_SESSION['Shipment']->VoyageRef . "',\n\t\t\t\t\t\t'" . $_SESSION['Shipment']->ETA . "',\n\t\t\t\t\t\t'" . $_SESSION['Shipment']->SupplierID . "')";
        }
        /*now update or insert as necessary */
        $result = DB_query($sql);
        /*now check that the delivery date of all PODetails are the same as the ETA as the shipment */
        foreach ($_SESSION['Shipment']->LineItems as $LnItm) {
            if (DateDiff(ConvertSQLDate($LnItm->DelDate), ConvertSQLDate($_SESSION['Shipment']->ETA), 'd') != 0) {
                $sql = "UPDATE purchorderdetails\n\t\t\t\t\t\tSET deliverydate ='" . $_SESSION['Shipment']->ETA . "'\n\t\t\t\t\t\tWHERE podetailitem='" . $LnItm->PODetailItem . "'";
                $result = DB_query($sql);
                $_SESSION['Shipment']->LineItems[$LnItm->PODetailItem]->DelDate = $_SESSION['Shipment']->ETA;
            }
        }
        prnMsg(_('Updated the shipment record and delivery dates of order lines as necessary'), 'success');
        echo '<br />';
    }
    //error traps all passed ok
}
//user hit Update
if (isset($_GET['Add']) and $_SESSION['Shipment']->Closed == 0 and $InputError == 0) {
    $sql = "SELECT purchorderdetails.orderno,\n\t\t\t\t\tpurchorderdetails.itemcode,\n\t\t\t\t\tpurchorderdetails.itemdescription,\n\t\t\t\t\tpurchorderdetails.unitprice,\n\t\t\t\t\tpurchorderdetails.stdcostunit,\n\t\t\t\t\tstockmaster.materialcost+stockmaster.labourcost+stockmaster.overheadcost as stdcost,\n\t\t\t\t\tpurchorderdetails.quantityord,\n\t\t\t\t\tpurchorderdetails.quantityrecd,\n\t\t\t\t\tpurchorderdetails.deliverydate,\n\t\t\t\t\tstockmaster.units,\n\t\t\t\t\tstockmaster.decimalplaces,\n\t\t\t\t\tpurchorderdetails.qtyinvoiced\n\t\t\tFROM purchorderdetails INNER JOIN stockmaster\n\t\t\tON purchorderdetails.itemcode=stockmaster.stockid\n\t\t\tWHERE purchorderdetails.podetailitem='" . $_GET['Add'] . "'";
    $result = DB_query($sql);
    $myrow = DB_fetch_array($result);
Esempio n. 19
0
<?php

include "../connect.php";
include "../function/function.php";
session_start();
$reg = '1กง2533';
$sql = "SELECT * FROM checkcar WHERE registration='{$reg}'";
$res = mysqli_query($conn, $sql);
$i = 0;
while ($row = mysqli_fetch_assoc($res)) {
    $ar[$i] = $row['date_'];
    if ($i > 0) {
        $d = (int) DateDiff($ar[$i], $ar[$i - 1]);
        $a = $ar[$i];
        if ($d < 0) {
            $d = $d * -1;
        }
        echo $d;
        mysqli_query($conn, "UPDATE checkcar SET countday='{$d}' WHERE registration='{$reg}' AND date_='{$a}'");
    }
    $i++;
}
print_r($ar);
Esempio n. 20
0
function LevelNetting(&$db, $part, $eoq, $pansize, $shrinkfactor)
{
    // 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($_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 % $pansize != 0) {
                $plannedqty = ceil($plannedqty / $pansize) * $pansize;
            }
            $sql = "INSERT INTO mrpplannedorders (id,\n\t\t\t\t\t\t\t\tpart,\n\t\t\t\t\t\t\t\tduedate,\n\t\t\t\t\t\t\t\tsupplyquantity,\n\t\t\t\t\t\t\t\tordertype,\n\t\t\t\t\t\t\t\torderno,\n\t\t\t\t\t\t\t\tmrpdate,\n\t\t\t\t\t\t\t\tupdateflag)\n\t\t\t\t\t\t\tVALUES ('NULL',\n\t\t\t\t\t\t\t\t'" . $requirement['part'] . "',\n\t\t\t\t\t\t\t\t'" . $requirement['daterequired'] . "',\n\t\t\t\t\t\t\t\t'" . $plannedqty . "',\n\t\t\t\t\t\t\t\t'" . $requirement['mrpdemandtype'] . "',\n\t\t\t\t\t\t\t\t'" . $requirement['orderno'] . "',\n\t\t\t\t\t\t\t\t'" . $requirement['daterequired'] . "',\n\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 WHERE parent ='" . $requirement['part'] . "'";
            $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          AND ordertype <> 'QOH'";
            $result = DB_query($sql, $db);
        }
    }
}
Esempio n. 21
0
        $assetarray[$i]['bsdepnaccount'] = $bsnamerow['accountname'];
        $plnamesql = 'SELECT accountname FROM chartmaster WHERE accountcode=' . $assetarray[$i]['pldepn'];
        $plnameresult = DB_query($plnamesql, $db);
        $plnamerow = DB_fetch_array($plnameresult);
        $assetarray[$i]['pldepnaccount'] = $plnamerow['accountname'];
        /* Need a method to correctly enter the journal date, 
         * and for it to be available to the depn calculation - Tim
         */
        if (isset($_POST['JournalProcessDate'])) {
            $_SESSION['JournalDetail']->JnlDate = $_POST['JournalProcessDate'];
        }
        if (!Is_Date($_SESSION['JournalDetail']->JnlDate)) {
            // Default the date to the last day of the previous month
            $_SESSION['JournalDetail']->JnlDate = Date($_SESSION['DefaultDateFormat'], mktime(0, 0, 0, date('m'), 0, date('Y')));
        }
        $NoOfMonths = DateDiff($_SESSION['JournalDetail']->JnlDate, FormatDateForSQL($assetarray[$i]['datepurchased']), 'm');
        if ($assetarray[$i]['DepreciationType'] == _('Straight Line')) {
            $TotalDepnAmount = round($NoOfMonths / 12 * ($assetarray[$i]['DepreciationRate'] / 100) * $assetarray[$i]['cost'], 2);
        } else {
            $TotalDepnAmount = round($NoOfMonths / 12 * ($assetarray[$i]['DepreciationRate'] / 100) * ($assetarray[$i]['cost'] - $assetarray[$i]['depn']), 2);
        }
        $assetarray[$i]['narrative'] = 'Depreciation Journal - ' . $assetarray[$i]['stockid'] . ' - ' . $assetarray[$i]['serialno'] . ' - ' . $assetarray[$i]['locationdescription'];
        $_SESSION['JournalDetail']->Add_To_GLAnalysis(-($TotalDepnAmount - $assetarray[$i]['depn']), $assetarray[$i]['narrative'], $assetarray[$i]['bsdepn'], $assetarray[$i]['bsdepnaccount'], 0, $assetarray[$i]['id']);
        $_SESSION['JournalDetail']->Add_To_GLAnalysis($TotalDepnAmount - $assetarray[$i]['depn'], $assetarray[$i]['narrative'], $assetarray[$i]['pldepn'], $assetarray[$i]['pldepnaccount'], 0, $assetarray[$i]['id']);
        $i++;
    }
}
if (isset($_POST['JournalProcessDate'])) {
    $_SESSION['JournalDetail']->JnlDate = $_POST['JournalProcessDate'];
    if (!Is_Date($_POST['JournalProcessDate'])) {
        prnMsg(_('The date entered was not valid please enter the date to process the journal in the format') . $_SESSION['DefaultDateFormat'], 'warn');
Esempio n. 22
0
            <div class="form-group">
                <span id="hStory">โดยจะทำการรื้อถอนให้แล้วเสร็จใน </span> <label>วันที่.......<?php 
echo $Oday;
?>
.......เดือน..........<?php 
echo chageMount($Omonth);
?>
..........พ.ศ.......<?php 
echo changeYear($Oyear);
?>
.......</label>
            </div>
            <div class="form-group">
                <label>
                    รวมระยะเวลาขอติดตั้ง.....<?php 
echo DateDiff($row_event[4], $row_event[5]);
?>
.....วัน
                </label>
            </div>
            <div class="form-group" style="text-indent: 15%">
                <label>กรณีป้ายโฆษณาที่ติดตั้งไว้ได้ก่อให้เกิดความเสียหายต่อชีวิต ร่างกาย หรือทรัพย์สินของบุคคล<br>อื่นไม่ว่ากรณีใดๆก็ตาม   ผู้ได้รับอนุญาตจะต้องรับผิดชอบต่อความเสียหายที่เกิดขึ้นนั้น</label>
            </div>
            <div class="form-group" style="text-indent: 15%">
                <label>ข้าพเจ้ายินดีปฏิบัติตามระเบียบ ประกาศ และเงื่อนไขของมหาวิทยาลัยขอนแก่นทุกประการ</label>
            </div>
            <div class="form-group" style="text-indent: 15%">
                <label>จึงเรียนมาเพื่อโปรดพิจารณาอนุญาต   จักขอบคุณยิ่ง</label>
            </div>
            <br>
            <br>
Esempio n. 23
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
}
Esempio n. 24
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);
}
Esempio n. 25
0
.....................................… (แนบข้อความและแบบป้ายประกอบการขออนุญาต) </label>
                                        </div>
                                        <div class="form-group">
                                            <label>
                                                <?php 
echo 'ตั้งแต่วันที่..' . $Sday . '..เดือน.......' . chageMount($Smonth) . '.......พ.ศ...........' . changeYear($Syear) . '...........';
?>
                                            </label>
                                            <label>
                                                <?php 
echo 'ตั้งแต่วันที่..' . $Eday . '..เดือน.......' . chageMount($Emonth) . '.......พ.ศ...........' . changeYear($Eyear) . '...........';
?>
                                            </label>
                                            <label>
                                                รวมระยะเวลาขอติดตั้ง.....<?php 
echo DateDiff($row[4], $row[5]);
?>
.....วัน
                                            </label>
                                        </div>
                                        <div class="form-group">
                                            <label>
                                                โดยจะทำการรื้อถอนให้แล้วเสร็จใน <?php 
echo 'ตั้งแต่วันที่..' . $Oday . '..เดือน.......' . chageMount($Omonth) . '.......พ.ศ...........' . changeYear($Oyear) . '...........';
?>
                                            </label>
                                        </div>
                                        <div class="form-group">
                                            <p>
                                                กรณีป้ายโฆษณาที่ติดตั้งไว้ได้ก่อให้เกิดความเสียหายต่อชีวิต ร่างกาย หรือทรัพย์สินของบุคคลอื่นไม่ว่ากรณีใดๆก็ตาม   ผู้ได้รับอนุญาตจะต้องรับผิดชอบต่อความเสียหายที่เกิดขึ้นนั้น
                                            </p>
Esempio n. 26
0
            $year += $number * 3;
            break;
        case "m":
            $month += $number;
            break;
        case "y":
        case "d":
        case "w":
            $day += $number;
            break;
        case "ww":
            $day += $number * 7;
            break;
        case "h":
            $hours += $number;
            break;
        case "n":
            $minutes += $number;
            break;
        case "s":
            $seconds += $number;
            break;
    }
    $timestamp = mktime($hours, $minutes, $seconds, $month, $day, $year);
    return $timestamp;
}
$tickdif = DateDiff("s", $ticktime, time());
if ($Userid != "") {
    $result = mysql_query("SELECT * FROM " . $PA["table"] . " WHERE id={$Userid}", $db);
    $myrow = mysql_fetch_array($result);
}
Esempio n. 27
0
function DoSetup()
{
    global $PathPrefix;
    if (isset($_SESSION['db']) and $_SESSION['db'] != '') {
        include $PathPrefix . 'includes/GetConfig.php';
    }
    $db = $_SESSION['db'];
    // Used a bit in the following.
    if (isset($_SESSION['DB_Maintenance'])) {
        if ($_SESSION['DB_Maintenance'] != 0) {
            if (DateDiff(Date($_SESSION['DefaultDateFormat']), ConvertSQLDate($_SESSION['DB_Maintenance_LastRun']), 'd') > $_SESSION['DB_Maintenance']) {
                /*Do the DB maintenance routing for the DB_type selected */
                DB_Maintenance($db);
                //purge the audit trail if necessary
                if (isset($_SESSION['MonthsAuditTrail'])) {
                    $sql = "DELETE FROM audittrail\n\t\t\t\t\t\t    WHERE  transactiondate <= '" . Date('Y-m-d', mktime(0, 0, 0, Date('m') - $_SESSION['MonthsAuditTrail'])) . "'";
                    $ErrMsg = _('There was a problem deleting expired audit-trail history');
                    $result = DB_query($sql, $db);
                }
                $_SESSION['DB_Maintenance_LastRun'] = Date('Y-m-d');
            }
        }
    }
    /*Check to see if currency rates need to be updated */
    if (isset($_SESSION['UpdateCurrencyRatesDaily'])) {
        if ($_SESSION['UpdateCurrencyRatesDaily'] != 0) {
            if (DateDiff(Date($_SESSION['DefaultDateFormat']), ConvertSQLDate($_SESSION['UpdateCurrencyRatesDaily']), 'd') > 0) {
                $CurrencyRates = GetECBCurrencyRates();
                // gets rates from ECB see includes/MiscFunctions.php
                /*Loop around the defined currencies and get the rate from ECB */
                $CurrenciesResult = DB_query("SELECT currabrev FROM currencies", $db);
                while ($CurrencyRow = DB_fetch_row($CurrenciesResult)) {
                    if ($CurrencyRow[0] != $_SESSION['CompanyRecord']['currencydefault']) {
                        $UpdateCurrRateResult = DB_query("UPDATE currencies SET\n\t\t\t\t\t\t\t\t\t\t\t    rate='" . GetCurrencyRate($CurrencyRow[0], $CurrencyRates) . "'\n\t\t\t\t\t\t\t\t\t\t\t    WHERE currabrev='" . $CurrencyRow[0] . "'", $db);
                    }
                }
                $_SESSION['UpdateCurrencyRatesDaily'] = Date('Y-m-d');
                $UpdateConfigResult = DB_query("UPDATE config SET confvalue = '" . Date('Y-m-d') . "' WHERE confname='UpdateCurrencyRatesDaily'", $db);
            }
        }
    }
}
     $Result = DB_query($SQL, $db, $ErrMsg, $DbgMsg, true);
 }
 /* If balance of the order cancelled update sales order details quantity. Also insert log records for OrderDeliveryDifferencesLog */
 foreach ($_SESSION['Items']->LineItems as $OrderLine) {
     if ($_POST['BOPolicy'] == 'CAN') {
         $SQL = "UPDATE salesorderdetails\r\n\t\t\t\tSET quantity = quantity - " . ($OrderLine->Quantity - $OrderLine->QtyDispatched) . " WHERE orderno = " . $_SESSION['ProcessingOrder'] . " AND stkcode = '" . $OrderLine->StockID . "'";
         $ErrMsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('The sales order detail record could not be updated because');
         $DbgMsg = _('The following SQL to update the sales order detail record was used');
         $Result = DB_query($SQL, $db, $ErrMsg, $DbgMsg, true);
         if ($OrderLine->Quantity - $OrderLine->QtyDispatched > 0) {
             $SQL = "INSERT INTO orderdeliverydifferenceslog (\r\n\t\t\t\t\t\torderno,\r\n\t\t\t\t\t\tinvoiceno,\r\n\t\t\t\t\t\tstockid,\r\n\t\t\t\t\t\tquantitydiff,\r\n\t\t\t\t\t\tdebtorno,\r\n\t\t\t\t\t\tbranch,\r\n\t\t\t\t\t\tcan_or_bo\r\n\t\t\t\t\t\t)\r\n\t\t\t\t\tVALUES (\r\n\t\t\t\t\t\t" . $_SESSION['ProcessingOrder'] . ",\r\n\t\t\t\t\t\t" . $InvoiceNo . ",\r\n\t\t\t\t\t\t'" . $OrderLine->StockID . "',\r\n\t\t\t\t\t\t" . ($OrderLine->Quantity - $OrderLine->QtyDispatched) . ",\r\n\t\t\t\t\t\t'" . $_SESSION['Items']->DebtorNo . "',\r\n\t\t\t\t\t\t'" . $_SESSION['Items']->Branch . "',\r\n\t\t\t\t\t\t'CAN'\r\n\t\t\t\t\t\t)";
             $ErrMsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('The order delivery differences log record could not be inserted because');
             $DbgMsg = _('The following SQL to insert the order delivery differences record was used');
             $Result = DB_query($SQL, $db, $ErrMsg, $DbgMsg, true);
         }
     } elseif ($OrderLine->Quantity - $OrderLine->QtyDispatched > 0 && DateDiff(ConvertSQLDate($DefaultDispatchDate), $_SESSION['Items']->DeliveryDate, 'd') > 0) {
         /*The order is being short delivered after the due date - need to insert a delivery differnce log */
         $SQL = "INSERT INTO orderdeliverydifferenceslog (\r\n\t\t\t\t\torderno,\r\n\t\t\t\t\tinvoiceno,\r\n\t\t\t\t\tstockid,\r\n\t\t\t\t\tquantitydiff,\r\n\t\t\t\t\tdebtorno,\r\n\t\t\t\t\tbranch,\r\n\t\t\t\t\tcan_or_bo\r\n\t\t\t\t)\r\n\t\t\t\tVALUES (\r\n\t\t\t\t\t" . $_SESSION['ProcessingOrder'] . ",\r\n\t\t\t\t\t" . $InvoiceNo . ",\r\n\t\t\t\t\t'" . $OrderLine->StockID . "',\r\n\t\t\t\t\t" . ($OrderLine->Quantity - $OrderLine->QtyDispatched) . ",\r\n\t\t\t\t\t'" . $_SESSION['Items']->DebtorNo . "',\r\n\t\t\t\t\t'" . $_SESSION['Items']->Branch . "',\r\n\t\t\t\t\t'BO'\r\n\t\t\t\t)";
         $ErrMsg = '<br>' . _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('The order delivery differences log record could not be inserted because');
         $DbgMsg = _('The following SQL to insert the order delivery differences record was used');
         $Result = DB_query($SQL, $db, $ErrMsg, $DbgMsg, true);
     }
     /*end of order delivery differences log entries */
     /*Now update SalesOrderDetails for the quantity invoiced and the actual dispatch dates. */
     if ($OrderLine->QtyDispatched != 0 and $OrderLine->QtyDispatched != "" and $OrderLine->QtyDispatched) {
         // Test above to see if the line is completed or not
         if ($OrderLine->QtyDispatched >= $OrderLine->Quantity - $OrderLine->QtyInv or $_POST['BOPolicy'] == "CAN") {
             $SQL = "UPDATE salesorderdetails\r\n\t\t\t\t\tSET qtyinvoiced = qtyinvoiced + " . $OrderLine->QtyDispatched . ",\r\n\t\t\t\t\tactualdispatchdate = '" . $DefaultDispatchDate . "',\r\n\t\t\t\t\tcompleted=1\r\n\t\t\t\t\tWHERE orderno = " . $_SESSION['ProcessingOrder'] . "\r\n\t\t\t\t\tAND orderlineno = '" . $OrderLine->LineNumber . "'";
         } else {
             $SQL = "UPDATE salesorderdetails\r\n\t\t\t\t\tSET qtyinvoiced = qtyinvoiced + " . $OrderLine->QtyDispatched . ",\r\n\t\t\t\t\tactualdispatchdate = '" . $DefaultDispatchDate . "'\r\n\t\t\t\t\tWHERE orderno = " . $_SESSION['ProcessingOrder'] . "\r\n\t\t\t\t\tAND orderlineno = '" . $OrderLine->LineNumber . "'";
         }
Esempio n. 29
0
        // skip owners that have more than 1 list, for now
        $db->SelectDB("pxm");
        if ($db->Query("SELECT listname FROM extended WHERE listownername='{$listownername}'")) {
            continue;
        }
        // get listownerID
        $db->SelectDB("mle");
        if ($db->Query("SELECT listownerID FROM listowner WHERE username='******'")) {
            list($listownerID) = $db->FetchRow();
        } else {
            $notValid .= "<br />\nlistownerID not found for listowner={$listownername}";
            continue;
        }
        $db->Query("SELECT COUNT(*) FROM users WHERE verified='yes' AND listname='{$listname}' AND listownerID='{$listownerID}'");
        list($totalmem) = $db->FetchRow();
        $days_bill_late = intval(DateDiff(mysql_datetime_to_timestamp($datesubmitted), time(), "d"));
        if (1 == 1) {
            $ids[] = $id;
            $listnames[] = $listname;
            $listownerIDs[] = $listownerID;
            $listownernames[] = $listownername;
            $dayslate[] = $days_bill_late;
            $totalmembers[] = $totalmem;
        }
    }
} else {
    exit("No lists found to be convertable.");
}
?>

<html>