public function setUp()
 {
     parent::setUp();
     $vendorId = null;
     $contactName = "Trevor Rigler";
     $vendorEmail = "*****@*****.**";
     $vendorName = "TruFork";
     $vendorPhoneNumber = "5053594687";
     $vendor = new Vendor($vendorId, $contactName, $vendorEmail, $vendorName, $vendorPhoneNumber);
     $vendor->insert($this->getPDO());
     $productId = null;
     $vendorId = $vendor->getVendorId();
     $description = "A glorius bead to use";
     $leadTime = 10;
     $sku = "TGT354";
     $title = "Bead-Green-Blue-Circular";
     $this->product = new Product($productId, $vendorId, $description, $leadTime, $sku, $title);
     $this->product->insert($this->getPDO());
     $locationId = null;
     $description = "Back Stock";
     $storageCode = 7;
     $this->location = new Location($locationId, $storageCode, $description);
     $this->location->insert($this->getPDO());
     $unitId = null;
     $unitCode = "pk";
     $quantity = 10.5;
     $this->unitOfMeasure = new UnitOfMeasure($unitId, $unitCode, $quantity);
     $this->unitOfMeasure->insert($this->getPDO());
 }
Beispiel #2
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     ini_set('max_execution_time', 0);
     $data = DB::select('select * from location');
     $insert = [];
     foreach ($data as $d) {
         $insert[] = ['id' => $d->id, 'name' => $d->location_name, 'code' => $d->location_code];
     }
     Location::insert($insert);
 }
 public function setUp()
 {
     parent::setUp();
     $this->guzzle = new \GuzzleHttp\Client(['cookies' => true]);
     $this->VALID_movementDate = DateTime::createFromFormat("Y-m-d H:i:s", "2015-09-26 08:45:25");
     $this->INVALID_movementDate = DateTime::createFromFormat("Y-m-d H:i:s", "2015-14-26 06:25:25");
     $userId = null;
     $firstName = "Jim";
     $lastName = "Jim";
     $root = 1;
     $attention = "Urgent: ";
     $addressLineOne = "123 House St.";
     $addressLineTwo = "P.O Box. 9965";
     $city = "Tattoine";
     $state = "AK";
     $zipCode = "52467";
     $email = "*****@*****.**";
     $phoneNumber = "5052253231";
     $salt = bin2hex(openssl_random_pseudo_bytes(32));
     $hash = hash_pbkdf2("sha512", "password1234", $salt, 262144, 128);
     $this->user = new User($userId, $lastName, $firstName, $root, $attention, $addressLineOne, $addressLineTwo, $city, $state, $zipCode, $email, $phoneNumber, $salt, $hash);
     $this->user->insert($this->getPDO());
     $vendorId = null;
     $contactName = "Trevor Rigler";
     $vendorEmail = "*****@*****.**";
     $vendorName = "TruFork";
     $vendorPhoneNumber = "5053594687";
     $vendor = new Vendor($vendorId, $contactName, $vendorEmail, $vendorName, $vendorPhoneNumber);
     $vendor->insert($this->getPDO());
     $productId = null;
     $vendorId = $vendor->getVendorId();
     $description = "A glorius bead to use";
     $leadTime = 10;
     $sku = "TGT354";
     $title = "Bead-Green-Blue-Circular";
     $this->product = new Product($productId, $vendorId, $description, $leadTime, $sku, $title);
     $this->product->insert($this->getPDO());
     $locationId = null;
     $description = "Back Stock";
     $storageCode = 13;
     $this->fromLocation = new Location($locationId, $storageCode, $description);
     $this->fromLocation->insert($this->getPDO());
     $locationId = null;
     $description = "Front Stock";
     $storageCode = 12;
     $this->toLocation = new Location($locationId, $storageCode, $description);
     $this->toLocation->insert($this->getPDO());
     $unitId = null;
     $unitCode = "pk";
     $quantity = 10.5;
     $this->unitOfMeasure = new UnitOfMeasure($unitId, $unitCode, $quantity);
     $this->unitOfMeasure->insert($this->getPDO());
 }
 public function run()
 {
     // Initialize empty array
     $location = array();
     $date = new DateTime();
     $location[] = array('name' => 'NY - Broad St', 'address' => '200 Broad Street', 'address2' => 'Suite 142', 'city' => 'New York', 'state' => 'NY', 'country' => 'US', 'zip' => '10004', 'currency' => '$', 'created_at' => $date->modify('-10 day'), 'updated_at' => $date->modify('-3 day'), 'user_id' => 1, 'deleted_at' => NULL);
     $location[] = array('name' => 'NY - Water St', 'address' => '200 Broad Street', 'address2' => 'Suite 142', 'city' => 'New York', 'state' => 'NY', 'country' => 'US', 'zip' => '10004', 'currency' => '$', 'created_at' => $date->modify('-10 day'), 'updated_at' => $date->modify('-3 day'), 'user_id' => 1, 'deleted_at' => NULL);
     $location[] = array('name' => 'SF - Broadway', 'address' => '200 Broadway', 'address2' => 'Suite 142', 'city' => 'San Francisco', 'state' => 'CA', 'country' => 'US', 'zip' => '94111', 'currency' => '$', 'created_at' => $date->modify('-10 day'), 'updated_at' => $date->modify('-3 day'), 'user_id' => 1, 'deleted_at' => NULL);
     $location[] = array('name' => 'LA - Hollywood Blvd', 'address' => '6253 Hollywood Blvd', 'address2' => 'Suite 142', 'city' => 'Los Angeles', 'state' => 'CA', 'country' => 'US', 'zip' => '90028', 'currency' => '$', 'created_at' => $date->modify('-10 day'), 'updated_at' => $date->modify('-3 day'), 'user_id' => 1, 'deleted_at' => NULL);
     // Delete all the old data
     DB::table('locations')->truncate();
     // Insert the new posts
     Location::insert($location);
 }
 /**
  * Set up for Vendor as well as guzzle/cookies
  **/
 public final function setUp()
 {
     parent::setUp();
     $vendorId = null;
     $contactName = "Trevor Rigler";
     $vendorEmail = "*****@*****.**";
     $vendorName = "TruFork";
     $vendorPhoneNumber = "5053594687";
     $this->vendor = new Vendor($vendorId, $contactName, $vendorEmail, $vendorName, $vendorPhoneNumber);
     $this->vendor->insert($this->getPDO());
     $locationId = null;
     $description = "Front Stock";
     $storageCode = 12;
     $this->location = new Location($locationId, $storageCode, $description);
     $this->location->insert($this->getPDO());
     $unitId = null;
     $unitCode = "pk";
     $quantity = 10.5;
     $this->unitOfMeasure = new UnitOfMeasure($unitId, $unitCode, $quantity);
     $this->unitOfMeasure->insert($this->getPDO());
     $alertCode = "78";
     $alertFrequency = "56";
     $alertPoint = 1.4;
     $alertOperator = "A";
     $this->alertLevel = new AlertLevel(null, $alertCode, $alertFrequency, $alertPoint, $alertOperator);
     $this->alertLevel->insert($this->getPDO());
     $notificationId = null;
     $alertId = $this->alertLevel->getAlertId();
     $emailStatus = false;
     $notificationDateTime = null;
     $notificationHandle = "unit test";
     $notificationContent = "place holder";
     $notificationDateTime = DateTime::createFromFormat("Y-m-d H:i:s", "1985-06-28 04:26:03");
     $this->notification = new Notification($notificationId, $alertId, $emailStatus, $notificationDateTime, $notificationHandle, $notificationContent);
     $this->notification->insert($this->getPDO());
     // create and insert a GuzzleHttp
     $this->guzzle = new \GuzzleHttp\Client(['cookies' => true]);
 }
 /**
  * test ability to Put valid location
  **/
 public function testPutValidLocation()
 {
     // create a new Location
     $newLocation = new Location(null, $this->VALID_storageCode, $this->VALID_description);
     $newLocation->insert($this->getPDO());
     // run a get request to establish session tokens
     $this->guzzle->get('https://bootcamp-coders.cnm.edu/~invtext/backend/php/api/location/');
     // grab the data from guzzle and enforce the status' match our expectations
     $response = $this->guzzle->put('https://bootcamp-coders.cnm.edu/~invtext/backend/php/api/location/' . $newLocation->getLocationId(), ['headers' => ['X-XSRF-TOKEN' => $this->getXsrfToken()], 'json' => $newLocation]);
     $this->assertSame($response->getStatusCode(), 200);
     $body = $response->getBody();
     $location = json_decode($body);
     $this->assertSame(200, $location->status);
 }
 /**
  * Allows a user to add a location.
  *
  */
 public function addAction()
 {
     $messages = array();
     $location = new Location();
     $form = $location->form();
     if ($this->_request->isPost()) {
         if ($form->isValid($_POST)) {
             $data = array('name' => $form->getValue('name'), 'locationType' => $form->getValue('locationType'), 'capacity' => $form->getValue('capacity'), 'description' => $form->getValue('description'), 'address' => $form->getValue('address'), 'status' => $form->getValue('status'));
             $locationId = $location->insert($data);
             $trigger = new Ot_Trigger();
             $data['accountId'] = Zend_Auth::getInstance()->getIdentity()->accountId;
             $trigger->setVariables($data);
             $trigger->dispatch('Location_Add');
             $this->_helper->flashMessenger->addMessage('msg-info-locationAdded');
             $this->_helper->redirector->gotoUrl('/workshop/location/details/?locationId=' . $locationId);
         } else {
             $messages[] = "msg-error-formSubmitProblem";
         }
     }
     $this->view->messages = $messages;
     $this->view->form = $form;
     $this->view->headScript()->appendFile($this->view->baseUrl() . '/scripts/jquery.wysiwyg.js');
     $this->view->headLink()->appendStylesheet($this->view->baseUrl() . '/css/jquery.wysiwyg.css');
     $this->_helper->pageTitle('workshop-location-add:title');
 }
 /**
  * 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());
         }
     }
 }
 /**
  * Insert city if not found and return id
  * otherwise just return actual city id
  */
 public static function insertIfNotFound($region_name, $parent_id, $tier)
 {
     if (!$region_name) {
         return false;
     }
     $city_id = self::verifyHierarchy($region_name, $parent_id, $tier);
     if (!$city_id) {
         $cityTable = new Location();
         $data = array();
         $data['location_name'] = $region_name;
         $data['parent_id'] = $parent_id;
         $data['tier'] = $tier;
         $city_id = $cityTable->insert($data);
     }
     return $city_id;
 }
Beispiel #10
0
     } else {
         if (empty($storageCode) === false) {
             $reply->data = Location::getLocationByStorageCode($pdo, $storageCode);
         } else {
             $reply->data = Location::getALLLocations($pdo)->toArray();
         }
     }
     // post to a new Location
 } else {
     if ($method === "POST") {
         // convert POSTed JSON to an object
         verifyXsrf();
         $requestContent = file_get_contents("php://input");
         $requestObject = json_decode($requestContent);
         $location = new Location($locationId, $requestObject->storageCode, $requestObject->description);
         $location->insert($pdo);
         $reply->data = "Location created OK";
         // delete an existing Location
     } else {
         if ($method === "DELETE") {
             verifyXsrf();
             $location = Location::getLocationByLocationId($pdo, $locationId);
             $location->delete($pdo);
             $reply->data = "Location deleted OK";
             // put to an existing Location
         } else {
             if ($method === "PUT") {
                 // convert PUTed JSON to an object
                 verifyXsrf();
                 $requestContent = file_get_contents("php://input");
                 $requestObject = json_decode($requestContent);
Beispiel #11
0
                                    $box->printForm($_GET['action']);
                                } else {
                                    $box->printForm($_GET['action']);
                                }
                            }
                        }
                    }
                }
            }
        }
        if ($_GET['type'] == 'location') {
            $location = new Location($connection);
            if (isset($_POST['submit'])) {
                if ($_GET['action'] == 'add') {
                    $location->loadFromPage();
                    $location->insert();
                } else {
                    if ($_GET['action'] == 'edit') {
                        $location->loadFromPage();
                        $location->update();
                    }
                }
            } else {
                if ($_GET['action'] == 'edit') {
                    $location->loadEntry($_GET['index']);
                }
                $location->printForm($_GET['action']);
            }
        }
    }
} catch (Exception $e) {