/**
  * Given the patterns for generating the names and aliases,
  * generate the various metric units of measure and add
  * them to this physical quantity.
  *
  * Names and Aliases are created by replacing identifiers in the respective
  * patterns.  The current allowed replacement identifiers are:
  *   %p = the abbreviated SI prefix, like 'M' for 'megameter' or 'k' for 'kilogram'
  *   %P = the full SI prefix, like 'mega' for 'megameter' or 'kilo' for 'kilogram'
  *   %U = uppercase version of %P
  *
  * So for instance, in order to generate 'kg', 'mg', and 'g' names for SI units, the
  * appropriate pattern would be '%pg'.  Similarly, to generate 'kilogram', 'milligram',
  * and 'gram' aliases, the pattern would be '%Pgram'.
  *
  * The $siUnit given in the 1st parameter must be some SI unit in the series of units
  * to be generated by this method.  This value is necessary to establish a conversion
  * factor between this continuum of SI units and the Physical Quantity's native unit.
  *
  * The second parameter provides a scaling factor between the given SI unit in the first parameter
  * and the base unit of the SI continuum (ie, 'grams', 'meters', 'seconds', etc).  For instance,
  * if a Kilogram unit of measure was passed for the 1st parameter, it would be necessary to
  * then pass 1e-3 in the 2nd parameter to indicate that a gram is 1/1000 of the given unit.
  *
  * @param  UnitOfMeasure $siUnit             A unit in this physical quantity that is an SI unit of measure
  * @param  integer       $toBaseSiUnitFactor The power-of-ten factor that converts the given SI unit into the not-prefixed SI base unit (ie 1e-3 for kilograms)
  * @param  string        $namePattern        The pattern to apply to the base unit's name to generate a new SI unit name
  * @param  array         $aliasPatterns      The collection of alias patterns to use in generating a new SI unit's aliases
  */
 protected static function addMissingSIPrefixedUnits(UnitOfMeasure $siUnit, $toBaseSiUnitFactor, $namePattern, array $aliasPatterns = [])
 {
     /**
      * The standard set of SI prefixes
      */
     $siPrefixes = [['abbr_prefix' => 'Y', 'long_prefix' => 'yotta', 'factor' => 1.0E+24], ['abbr_prefix' => 'Z', 'long_prefix' => 'zetta', 'factor' => 1.0E+21], ['abbr_prefix' => 'E', 'long_prefix' => 'exa', 'factor' => 1.0E+18], ['abbr_prefix' => 'P', 'long_prefix' => 'peta', 'factor' => 1000000000000000.0], ['abbr_prefix' => 'T', 'long_prefix' => 'tera', 'factor' => 1000000000000.0], ['abbr_prefix' => 'G', 'long_prefix' => 'giga', 'factor' => 1000000000.0], ['abbr_prefix' => 'M', 'long_prefix' => 'mega', 'factor' => 1000000.0], ['abbr_prefix' => 'k', 'long_prefix' => 'kilo', 'factor' => 1000.0], ['abbr_prefix' => 'h', 'long_prefix' => 'hecto', 'factor' => 100.0], ['abbr_prefix' => 'da', 'long_prefix' => 'deca', 'factor' => 10.0], ['abbr_prefix' => '', 'long_prefix' => '', 'factor' => 1], ['abbr_prefix' => 'd', 'long_prefix' => 'deci', 'factor' => 0.1], ['abbr_prefix' => 'c', 'long_prefix' => 'centi', 'factor' => 0.01], ['abbr_prefix' => 'm', 'long_prefix' => 'milli', 'factor' => 0.001], ['abbr_prefix' => 'µ', 'long_prefix' => 'micro', 'factor' => 1.0E-6], ['abbr_prefix' => 'n', 'long_prefix' => 'nano', 'factor' => 1.0E-9], ['abbr_prefix' => 'p', 'long_prefix' => 'pico', 'factor' => 1.0E-12], ['abbr_prefix' => 'f', 'long_prefix' => 'femto', 'factor' => 1.0E-15], ['abbr_prefix' => 'a', 'long_prefix' => 'atto', 'factor' => 1.0E-18], ['abbr_prefix' => 'z', 'long_prefix' => 'zepto', 'factor' => 9.999999999999999E-22], ['abbr_prefix' => 'y', 'long_prefix' => 'yocto', 'factor' => 9.999999999999999E-25]];
     // Determine the conversion factor from the no-prefix SI unit to the physical quantity's native unit
     $noPrefixToNativeUnitFactor = $siUnit->convertValueToNativeUnitOfMeasure(1) * $toBaseSiUnitFactor;
     // For each of the standard SI prefixes, attempt to register a new unit of measure
     foreach ($siPrefixes as $prefixDefinition) {
         // Build a function for resolving a pattern into a unit name
         $parsePattern = function ($pattern) use($prefixDefinition) {
             return strtr($pattern, ['%p' => $prefixDefinition['abbr_prefix'], '%P' => $prefixDefinition['long_prefix'], '%U' => strtoupper($prefixDefinition['long_prefix'])]);
         };
         // Generate the base name of the new unit
         $name = $parsePattern($namePattern);
         // Determine the factor that converts the new unit into the physical quantity's
         //   native unit of measure.
         $toNativeUnitFactor = $noPrefixToNativeUnitFactor * $prefixDefinition['factor'];
         // Instantiate the new unit of measure
         $newUnit = UnitOfMeasure::linearUnitFactory($name, $toNativeUnitFactor);
         // Generate the aliases of the new unit
         foreach ($aliasPatterns as $aliasPattern) {
             $newUnitAlias = $parsePattern($aliasPattern);
             $newUnit->addAlias($newUnitAlias);
         }
         // If the unit doesn't conflict with any of the already-existing units, register it
         if (!static::unitNameOrAliasesAlreadyRegistered($newUnit)) {
             static::addUnit($newUnit);
         }
     }
 }
Esempio n. 2
0
 /**
  * test grabbing location by productId
  **/
 public function testGetValidProductByLocationId()
 {
     // count the number of rows and save it for later
     $numRows = $this->getConnection()->getRowCount("location");
     // create a new location and insert to into mySQL
     $location = new Location(null, $this->VALID_storageCode, $this->VALID_description);
     $location->insert($this->getPDO());
     $quantity = 5.9;
     // create a new location and insert to into mySQL
     $productLocation = new productLocation($location->getLocationId(), $this->product->getProductId(), $this->unitOfMeasure->getUnitId(), $quantity);
     $productLocation->insert($this->getPDO());
     // grab the data from mySQL and enforce the fields match our expectations
     $pdoProductArray = Location::getProductByLocationId($this->getPDO(), $location->getLocationId());
     for ($i = 0; $i < count($pdoProductArray); $i++) {
         if ($i === 0) {
             $this->assertSame($pdoProductArray[$i]->getStorageCode(), $this->VALID_storageCode);
             $this->assertSame($pdoProductArray[$i]->getDescription(), $this->VALID_description);
         } else {
             $this->assertSame($pdoProductArray[$i]->getProductId(), $this->product->getProductId());
             $this->assertSame($pdoProductArray[$i]->getVendorId(), $this->product->getVendorId());
             $this->assertSame($pdoProductArray[$i]->getDescription(), $this->product->getDescription());
             $this->assertSame($pdoProductArray[$i]->getSku(), $this->product->getSku());
             $this->assertSame($pdoProductArray[$i]->getTitle(), $this->product->getTitle());
         }
     }
 }
 /**
  * Configure this object's mandatory properties.
  *
  * @param string   $name           This unit of measure's canonical name
  *
  * @throws Exception\NonStringUnitName
  */
 public function __construct($name)
 {
     parent::__construct($name, function ($valueInNativeUnit) {
         return $valueInNativeUnit;
     }, function ($valueInThisUnit) {
         return $valueInThisUnit;
     });
 }
 /**
  * Test Posting Valid Movement
  **/
 public function testPostValidMovement()
 {
     // create a new Movement
     $newMovement = new Movement(null, $this->fromLocation->getLocationId(), $this->toLocation->getLocationId(), $this->product->getProductId(), $this->unitOfMeasure->getUnitId(), $this->user->getUserId(), $this->VALID_cost, $this->VALID_movementDate, $this->VALID_movementType, $this->VALID_price);
     // run a get request to establish session tokens
     $this->guzzle->get('https://bootcamp-coders.cnm.edu/~invtext/backend/php/api/movement/?page=0');
     // grab the data from guzzle and enforce the status' match our expectations
     $response = $this->guzzle->post('https://bootcamp-coders.cnm.edu/~invtext/backend/php/api/movement/', ['headers' => ['X-XSRF-TOKEN' => $this->getXsrfToken()], 'json' => $newMovement]);
     $this->assertSame($response->getStatusCode(), 200);
     $body = $response->getBody();
     $movement = json_decode($body);
     $this->assertSame(200, $movement->status);
 }
 /**
  * Test grabbing Valid UnitOfMeasure by productId
  **/
 public function testGetValidUnitOfMeasureByProductId()
 {
     // create a new Product
     $newProduct = new Product(null, $this->vendor->getVendorId(), $this->VALID_description, $this->VALID_leadTime, $this->VALID_sku, $this->VALID_title);
     $newProduct->insert($this->getPDO());
     // create a new ProductLocation
     $quantity = 1.5;
     $newProductLocation = new ProductLocation($this->location->getLocationId(), $newProduct->getProductId(), $this->unitOfMeasure->getUnitId(), $quantity);
     $newProductLocation->insert($this->getPDO());
     // grab the data from guzzle
     $response = $this->guzzle->get('https://bootcamp-coders.cnm.edu/~invtext/backend/php/api/product/?productId=' . $newProduct->getProductId() . "&getUnitOfMeasure=true");
     $this->assertSame($response->getStatusCode(), 200);
     $body = $response->getBody();
     $product = json_decode($body);
     $this->assertSame(200, $product->status);
 }
 /**
  * test grabbing a ProductLocation by productId
  **/
 public function testGetValidProductLocationByProductId()
 {
     // count the number of rows and save it for later
     $numRows = $this->getConnection()->getRowCount("productLocation");
     // create a new ProductLocation and insert to into mySQL
     $productLocation = new ProductLocation($this->location->getLocationId(), $this->product->getProductId(), $this->unitOfMeasure->getUnitId(), $this->VALID_quantity);
     $productLocation->insert($this->getPDO());
     // grab the data from mySQL and enforce the fields match our expectations
     $pdoProductLocation = ProductLocation::getProductLocationByProductId($this->getPDO(), $this->product->getProductId());
     foreach ($pdoProductLocation as $pdoPL) {
         $this->assertSame($numRows + 1, $this->getConnection()->getRowCount("productLocation"));
         $this->assertSame($pdoPL->getLocationId(), $this->location->getLocationId());
         $this->assertSame($pdoPL->getUnitId(), $this->unitOfMeasure->getUnitId());
         $this->assertSame($pdoPL->getQuantity(), $this->VALID_quantity);
     }
 }
 /**
  * Test grabbing Valid Product by LocationId
  **/
 public function testGetValidProductByLocationId()
 {
     // create a new location and insert to into mySQL
     $newLocation = new Location(null, $this->VALID_storageCode, $this->VALID_description);
     $newLocation->insert($this->getPDO());
     $quantity = 5.9;
     // create a new location and insert to into mySQL
     $productLocation = new productLocation($newLocation->getLocationId(), $this->product->getProductId(), $this->unitOfMeasure->getUnitId(), $quantity);
     $productLocation->insert($this->getPDO());
     // grab the data from guzzle
     $response = $this->guzzle->get('https://bootcamp-coders.cnm.edu/~invtext/backend/php/api/location/?locationId=' . $newLocation->getLocationId() . "&getProducts=true");
     $this->assertSame($response->getStatusCode(), 200);
     $body = $response->getBody();
     $location = json_decode($body);
     echo $body . PHP_EOL;
     $this->assertSame(200, $location->status);
 }
Esempio n. 8
0
 /**
  * PointChannels::Load()
  *
  * @param mixed $userId
  * @param mixed $domainId
  * @return
  */
 function Load($userId, $domainId, $pointType = '', $participationType = '', $siftByResource = false, $rapMonth = false, $rapYear = false)
 {
     //echo "In PointChannels->Load(...)...<br>\n";
     $participationTypeClause = $participationType != '' ? " and pat.ParticipationTypeID = {$participationType} " : '';
     $pointTypeClause = $pointType != '' ? " and ptypes.PointTypeName = '{$pointType}' " : " and not ptypes.PointTypeName = 'Resource' ";
     $resourceSort = $siftByResource ? " rappc.ChannelDescription, " : '';
     $resourceClause = $siftByResource ? " and rap.AssetObjectID = pc.ObjectID\n and rap.AssetChannelID = pc.ChannelID\n and rap.ResourceObjectID = rappc.ObjectID \n " : '';
     $resourceTable = $siftByResource ? ", mdr.t_resourceassetprofiles rap, mdr.t_pointchannels rappc " : '';
     $resourceFields = $siftByResource ? ", rappc.ChannelDescription ResourceDescription, rap.AssetObjectID,  rap.AssetChannelID, rap.ResourceObjectID " : '';
     $rapDateClause = $rapMonth ? " and rap.EffectiveMonth = '{$rapMonth}' and rap.EffectiveYear = '{$rapYear}'" : '';
     //print $rapDateClause;
     $this->p_userId = $userId;
     $this->p_domainId = $domainId;
     $sql = "\n            SELECT DISTINCT\n                pc.*,\n                pn.ReadTimeOffset,\n                pn.ReadInterval,\n                t.TimeZoneID,\n                t.TimeZoneName,\n                t.TimeZoneDescription,\n                t.IsDstActive,\n                t.StdAbbreviation,\n                t.StdDescription,\n                t.StdOffset,\n                t.StdMonth,\n                t.StdWeek,\n                t.StdDay,\n                t.StdHour,\n                t.DstAbbreviation,\n                t.DstDescription,\n                t.DstOffset,\n                t.DstMonth,\n                t.DstWeek,\n                t.DstDay,\n                t.DstHour,\n                zo.ObjectDescription Zone,\n                pat.ParticipationTypeID,\n                pat.ParticipationTypeDescription,\n                pcppp.CommittedReduction,\n                rp.PriceID RealTimePriceID,\n                rp.PriceDescription RealTimePriceDescription,\n                hp.PriceID HourlyPriceID,\n                hp.PriceDescription HourlyPriceDescription {$resourceFields}\n            FROM\n                mdr.t_objectxrefs dgox,\n                mdr.t_objecttypes got,\n                mdr.t_objects go,\n                mdr.t_objectxrefs ugox,\n                mdr.t_actorprivilegexrefs gpx,\n                mdr.t_actorprivilegexrefs dpx,\n                mdr.t_privileges p,\n                mdr.t_privilegetypes pt,\n                mdr.t_points pn,\n                mdr.t_timezones t,\n                mdr.t_objects po,\n                mdr.t_pointchannels pc,\n                mdr.t_objectxrefs pzox,\n                mdr.t_objects zo,\n                mdr.t_zones z,\n                mdr.t_pointchannelprogramparticipationprofiles pcppp,\n                mdr.t_participationtypes pat,\n                mdr.t_pricelocations pl,\n                mdr.t_pricecomponents pco,\n                mdr.t_pricetypes rpt,\n                mdr.t_pricetypes hpt,\n                mdr.t_prices rp,\n                mdr.t_prices hp,\n                mdr.t_pointtypes ptypes {$resourceTable}\n            WHERE\n                got.ObjectTypeName = 'Group' and\n                go.ObjectTypeID = got.ObjectTypeID and\n                dgox.ChildObjectID = go.ObjectID and\n                dgox.ParentObjectID = {$this->p_domainId} and\n                ugox.ParentObjectID = dgox.ChildObjectID and\n                ugox.ChildObjectID = {$this->p_userId}  and\n                gpx.ObjectID = ugox.ParentObjectID and\n                dpx.ObjectID = dgox.ParentObjectID and\n                gpx.PrivilegeID = dpx.PrivilegeID and\n                p.PrivilegeID = gpx.PrivilegeID and\n                pt.PrivilegeTypeID = p.PrivilegeTypeID and\n                pt.PrivilegeTypeName = 'Read' and\n                po.ObjectID = p.ObjectID and\n                pn.ObjectID = po.ObjectID and\n                t.TimeZoneID = pn.TimeZoneID and\n                po.IsInactive = 0 and\n                pn.IsEnabled = 1 and\n                pc.ObjectID = pn.ObjectID and\n                pc.IsEnabled = 1 and\n                pc.IsPlotable = 1 and\n                pzox.ChildObjectID = pn.ObjectID and\n                zo.ObjectID = pzox.ParentObjectID and\n                z.ObjectID = zo.ObjectID and\n                pcppp.PointObjectID = p.ObjectID and\n                pat.ParticipationTypeID = pcppp.ParticipationTypeID and\n                pco.PriceComponentName = 'LBMP' and\n                pl.ZoneObjectID = z.ObjectID and\n                rpt.PriceTypeName = 'RealTimePrice' and\n                rp.PriceTypeID = rpt.PriceTypeID and\n                rp.PriceLocationID = pl.PriceLocationID and\n                rp.PriceComponentID = pco.PriceComponentID and\n                hpt.PriceTypeName = 'HourlyPrice' and\n                hp.PriceTypeID = hpt.PriceTypeID and\n                hp.PriceLocationID = pl.PriceLocationID and\n                hp.PriceComponentID = pco.PriceComponentID and\n                ptypes.PointTypeID = pn.PointTypeID {$participationTypeClause} {$resourceClause} {$pointTypeClause} {$rapDateClause} \n            ORDER BY\n                {$resourceSort}\n                pc.ChannelDescription\n            ";
     //$this->preDebugger($sql);
     $result = mysql_query($sql, $this->sqlConnection());
     //echo mysql_num_rows($result);
     if (mysql_num_rows($result) > 0) {
         while ($row = mysql_fetch_array($result)) {
             //$this->preDebugger($row);
             if ($siftByResource) {
                 $this->p_resources[$row['ResourceObjectID']]['description'] = $row['ResourceDescription'];
                 $this->p_resources[$row['ResourceObjectID']]['assets'][$row["AssetObjectID"] . ':' . $row["AssetChannelID"]]['id'] = $row["ObjectID"];
                 $this->p_resources[$row['ResourceObjectID']]['assets'][$row["AssetObjectID"] . ':' . $row["AssetChannelID"]]['channelId'] = $row["ChannelID"];
                 $this->p_resources[$row['ResourceObjectID']]['assets'][$row["AssetObjectID"] . ':' . $row["AssetChannelID"]]['description'] = $row["ChannelDescription"];
                 $this->p_resources[$row['ResourceObjectID']]['assets'][$row["AssetObjectID"] . ':' . $row["AssetChannelID"]]['programId'] = $row["ParticipationTypeID"];
                 $this->p_resources[$row['ResourceObjectID']]['assets'][$row["AssetObjectID"] . ':' . $row["AssetChannelID"]]['programDescription'] = $row["ParticipationTypeDescription"];
                 $this->p_resources[$row['ResourceObjectID']]['assets'][$row["AssetObjectID"] . ':' . $row["AssetChannelID"]]['assetIdentifier'] = $row["AssetIdentifier"];
             } else {
                 $inx = $this->p_length++;
                 //inx has no meaning in the new context -- just using it to hold things together right now.
                 $uom = new UnitOfMeasure();
                 $uom->Load($row["UnitOfMeasureID"]);
                 $dluom = new UnitOfMeasure();
                 $dluom->Load($row["DrawLimitUnitOfMeasureID"]);
                 $pointChannel = new PointChannel($row["ObjectID"], $row["ChannelID"], $row["ChannelName"], $row["ChannelDescription"], $uom, $row["PulseConversionFactor"], $row["DrawLimit"], $dluom, $row["IsGenerator"], $row["AssetIdentifier"]);
                 $this->p_pointChannel[$inx] = clone $pointChannel;
                 $this->p_pcMap[$pointChannel->objectId()][$pointChannel->channelId()] = $inx;
                 //$this->preDebugger($pointChannel);
                 /*
                             print '<pre style="color: red;">';
                             echo "pointChannel='" . $this->p_pointChannel[$inx]->objectId() . "', '" . $this->p_pointChannel[$inx]->channelId() . "'<br>\n";
                             echo "index='" . $this->p_pcMap[$pointChannel->objectId()][$pointChannel->channelId()] . "'<br>\n";
                             print '</pre>';
                 */
                 if (!isset($this->p_meterPoint[$pointChannel->objectId()])) {
                     $this->p_meterPoint[$pointChannel->objectId()] = new MeterPoint();
                     $this->p_meterPoint[$pointChannel->objectId()]->id($pointChannel->objectId());
                     $this->p_meterPoint[$pointChannel->objectId()]->readTimeOffset($row["ReadTimeOffset"]);
                     $this->p_meterPoint[$pointChannel->objectId()]->readInterval($row["ReadInterval"]);
                     $this->p_meterPoint[$pointChannel->objectId()]->zone($row["Zone"]);
                     $this->p_meterPoint[$pointChannel->objectId()]->committedReduction($row["CommittedReduction"]);
                     $this->p_meterPoint[$pointChannel->objectId()]->participationTypeID($row["ParticipationTypeID"]);
                     $this->p_meterPoint[$pointChannel->objectId()]->participationTypeDescription($row["ParticipationTypeDescription"]);
                     $this->p_meterPoint[$pointChannel->objectId()]->displayPriceId($row["RealTimePriceID"]);
                     $this->p_meterPoint[$pointChannel->objectId()]->displayPriceDescription($row["RealTimePriceDescription"]);
                     $this->p_meterPoint[$pointChannel->objectId()]->settlementPriceId($row["HourlyPriceID"]);
                     $this->p_meterPoint[$pointChannel->objectId()]->settlementPriceDescription($row["HourlyPriceDescription"]);
                     $this->p_participationTypeList[$row["ParticipationTypeID"]] = $row["ParticipationTypeDescription"];
                     $timeZone = new TimeZone();
                     $timeZone->id($row["TimeZoneID"]);
                     $timeZone->name($row["TimeZoneName"]);
                     $timeZone->description($row["TimeZoneDescription"]);
                     $timeZone->isDstActive($row["IsDstActive"]);
                     $timeZone->stdAbbreviation($row["StdAbbreviation"]);
                     $timeZone->stdDescription($row["StdDescription"]);
                     $timeZone->stdOffset($row["StdOffset"]);
                     $timeZone->stdMonth($row["StdMonth"]);
                     $timeZone->stdWeek($row["StdWeek"]);
                     $timeZone->stdDay($row["StdDay"]);
                     $timeZone->stdHour($row["StdHour"]);
                     $timeZone->dstAbbreviation($row["DstAbbreviation"]);
                     $timeZone->dstDescription($row["DstDescription"]);
                     $timeZone->dstOffset($row["DstOffset"]);
                     $timeZone->dstMonth($row["DstMonth"]);
                     $timeZone->dstWeek($row["DstWeek"]);
                     $timeZone->dstDay($row["DstDay"]);
                     $timeZone->dstHour($row["DstHour"]);
                     $this->p_meterPoint[$pointChannel->objectId()]->timeZone($timeZone);
                 }
                 $this->p_pointChannel[$inx]->meterPoint($this->p_meterPoint[$pointChannel->objectId()]);
             }
             //print_r($this->p_resource);
         }
         // end while
     } else {
         $this->p_resources = false;
     }
     //end if
 }
Esempio n. 9
0
<?php

/**
 * Add/Update File For Security Manager
 * @package		addsecuritymanager.inc.php
 * @Section		security_manager
 */
if (!isset($unitofmeasureObj)) {
    include_once SITE_CLASS_APPLICATION . 'class.UnitOfMeasure.php';
    $unitofmeasureObj = new UnitOfMeasure();
}
$gdbobj->getRequestVars();
$view = GetVar("view");
$iUnitId = GetVar("iUnitId");
$file = GetVar("file");
$arr = array();
if (count($_POST) > 0) {
    $arr[0] = $_POST;
} else {
    if ($view == 'edit') {
        $arr = $unitofmeasureObj->select($iUnitId);
        // prints($arr); exit;
    } else {
        $view = "add";
    }
}
$arr[0]['eStatus'] = isset($arr[0]['eStatus']) ? $arr[0]['eStatus'] : 'Active';
?>
<form name="frmadd" id="frmadd" action="index.php?file=<?php 
echo $file;
?>
Esempio n. 10
0
    $isusts = $stsdtls[0]['iStatusID'];
    $poitems = $poLineObj->getDetails('*', " AND iPurchaseOrderID={$poid} ");
    // && $podtls[0]['iStatusID'] != $crsts && $podtls[0]['iStatusID'] != $isusts
    // && (count($poitems)>0 && is_array($poitems) )
    // (count($poitems)>0 && is_array($poitems)) || ($podtls[0]['iStatusID']!=$sts && $podtls[0]['iStatusID']!=$crsts && $podtls[0]['iStatusID']!=$isusts) &&
    // prints($podtls); exit;
    if ($poad != 'yes' && $podtls[0]['iStatusID'] != $sts && $podtls[0]['eSaved'] != 'Yes') {
        // $podtls[0]['iStatusID']!=$sts
        header("Location: " . SITE_URL_DUM . "poviewitems/{$poid}");
        exit;
    }
}
// setlocale(LC_MONETARY, 'en_US.UTF-8'); 	// 'en_US.UTF-8' or 'en_US.ISO-8559-1'
$orderTypes = $gdbobj->mysqlEnumValues(PRJ_DB_PREFIX . "_purchase_order_line", "eOrderType");
$cntrydt = $countryObj->getDetails('*', " AND BINARY vCountryCode='" . $podtls[0]['vBillToCountry'] . "'");
//
if (!isset($unitofmeasureObj)) {
    include_once SITE_CLASS_APPLICATION . 'class.UnitOfMeasure.php';
    $unitofmeasureObj = new UnitOfMeasure();
}
$uom = $unitofmeasureObj->getDetails("iUnitId,vUnitOfMeasure", "AND eStatus = 'Active'");
// prints($poitems); exit;
$smarty->assign('poid', $poid);
$smarty->assign('podtls', $podtls);
$smarty->assign('msg', $msg);
$smarty->assign('view', $view);
$smarty->assign('orderTypes', $orderTypes);
$smarty->assign('cntrydt', $cntrydt);
$smarty->assign('poitems', $poitems);
$smarty->assign('vldmsg', $vldmsg);
$smarty->assign('uom', $uom);
Esempio n. 11
0
 /**
  * test grabbing unit of measure by the product id
  **/
 public function testGetValidUnitOfMeasurementByProductId()
 {
     // create a new product and insert to into mySQL
     $product = new Product(null, $this->vendor->getVendorId(), $this->VALID_description, $this->VALID_leadTime, $this->VALID_sku, $this->VALID_title);
     $product->insert($this->getPDO());
     $quantity = 5.9;
     // create a new product and insert to into mySQL
     $productLocation = new ProductLocation($this->location->getLocationId(), $product->getProductId(), $this->unitOfMeasure->getUnitId(), $quantity);
     $productLocation->insert($this->getPDO());
     // grab the data from mySQL and enforce the fields match our expectations
     $pdoUnitOfMeasureArray = Product::getUnitOfMeasureByProductId($this->getPDO(), $product->getProductId());
     for ($i = 0; $i < count($pdoUnitOfMeasureArray); $i++) {
         if ($i === 0) {
             $this->assertSame($pdoUnitOfMeasureArray[$i]->getVendorId(), $this->vendor->getVendorId());
             $this->assertSame($pdoUnitOfMeasureArray[$i]->getDescription(), $this->VALID_description);
             $this->assertSame($pdoUnitOfMeasureArray[$i]->getLeadTime(), $this->VALID_leadTime);
             $this->assertSame($pdoUnitOfMeasureArray[$i]->getSku(), $this->VALID_sku);
             $this->assertSame($pdoUnitOfMeasureArray[$i]->getTitle(), $this->VALID_title);
         } else {
             $this->assertSame($pdoUnitOfMeasureArray[$i]->getUnitId(), $this->unitOfMeasure->getUnitId());
             $this->assertSame($pdoUnitOfMeasureArray[$i]->getUnitCode(), $this->unitOfMeasure->getUnitCode());
             $this->assertSame($pdoUnitOfMeasureArray[$i]->getQuantity(), $this->unitOfMeasure->getQuantity());
         }
     }
 }
 /**
  * test grabbing a Unit of Measure by an unitCode that does not exists
  **/
 public function testGetInvalidUnitOfMeasureByUnitCode()
 {
     // grab a unit code that does not exist
     $unitOfMeasure = UnitOfMeasure::getUnitOfMeasureByUnitCode($this->getPDO(), $this->INVALID_unitCode);
     $this->assertNull($unitOfMeasure);
 }
Esempio n. 13
0
<?php

/**
 * Action file for add/Update of securitymanager
 *
 * @package		addsecuritymanager_a.php
 * @section		action/security_manager
 * @author		Jack Scott
*/
if (!isset($rptreportObj)) {
    include_once SITE_CLASS_APPLICATION . 'class.UnitOfMeasure.php';
    $unitofmeasureObj = new UnitOfMeasure();
}
$view = PostVar("view");
$Data = PostVar("Data");
$iReportId = PostVar("iUnitId");
$date = date("Y-m-d H:i:s");
$iAdminID = $_SESSION['B2B_SESS_USERID'];
/** This is for Check Duplicate Record------------------------------------------- */
$generalobj->getRequestVars();
$redirect_file = "index.php?file={$file}&view={$view}&iUnitId={$iUnitId}";
// $generalobj->checkDuplicate('iSMID', PRJ_DB_PREFIX . "_security_manager", Array('vUserName' => $Data['vUserName']), $redirect_file, USER_ALREADY_EXISTS, $iSMID);
if ($view == "add") {
    // $Data['iAdminID'] = $_SESSION['B2B_SESS_USERID'];
    //prints($Data);exit;
    $id = 0;
    $Data['dADate'] = $date;
    if (is_array($Data) && count(array_filter($Data)) > 0) {
        $id = $unitofmeasureObj->insert($Data);
    }
    if ($id) {
Esempio n. 14
0
 /**
  * test grabbing a Movement by movementType
  **/
 public function testGetValidAllMovements()
 {
     // count the number of rows and save it for later
     $numRows = $this->getConnection()->getRowCount("movement");
     // create a new Movement and insert to into mySQL
     $movement = new Movement(null, $this->fromLocation->getLocationId(), $this->toLocation->getLocationId(), $this->product->getProductId(), $this->unitOfMeasure->getUnitId(), $this->user->getUserId(), $this->VALID_cost, $this->VALID_movementDate, $this->VALID_movementType, $this->VALID_price);
     $movement->insert($this->getPDO());
     $page = 1;
     // grab the data from mySQL and enforce the fields match our expectations
     $pdoMovement = Movement::getAllMovements($this->getPDO(), $page);
     foreach ($pdoMovement as $pdoM) {
         $this->assertSame($numRows + 1, $this->getConnection()->getRowCount("movement"));
         $this->assertSame($pdoM->getFromLocationId(), $this->fromLocation->getLocationId());
         $this->assertSame($pdoM->getToLocationId(), $this->toLocation->getLocationId());
         $this->assertSame($pdoM->getProductId(), $this->product->getProductId());
         $this->assertSame($pdoM->getUnitId(), $this->unitOfMeasure->getUnitId());
         $this->assertSame($pdoM->getUserId(), $this->user->getUserId());
         $this->assertSame($pdoM->getCost(), $this->VALID_cost);
         $this->assertEquals($pdoM->getMovementDate(), $this->VALID_movementDate);
         $this->assertSame($pdoM->getMovementType(), $this->VALID_movementType);
         $this->assertSame($pdoM->getPrice(), $this->VALID_price);
     }
 }