$products = new Products(); $availableProducts = $products->getAvailable(); usort($availableProducts, function ($a, $b) { $ret = 0; $ap = new Product($a['id'], $a['spider']); $bp = new Product($b['id'], $b['spider']); $atd = $ap->getData()['tagsData']; $btd = $bp->getData()['tagsData']; if (!$ret) { #$ret = strcmp(implode(", ", $ap->getData()['tags']), implode(", ", $bp->getData()['tags'])); $as = sprintf("%-32s.%06d", $atd['product'], $atd['quantity']); $bs = sprintf("%-32s.%06d", $btd['product'], $btd['quantity']); $ret = strcmp($as, $bs); } if (!$ret) { $ret = -1 * ($ap->isAvailable() - $bp->isAvailable()); } if (!$ret && $atd['unitPrice'] && $btd['unitPrice']) { $ret = 1 * (int) 1000 * ($atd['unitPrice'] - $btd['unitPrice']); } if (!$ret) { $ret = (int) ($ap->getData()['price'] - $bp->getData()['price']); } if (!$ret) { $ret = strcmp($ap->getData()['name'], $bp->getData()['name']); } return $ret; }); foreach ($availableProducts as $rawProd) { $prod = new Product($rawProd['id'], $rawProd['spider']); $data = $prod->getData();
$day = "weekday"; } return $day; } public function working_hours() { $day1 = $this->isWeekend(); if ($day1 == "weekend") { echo "<br/> Working Hours of {$this->name}: <br/> 10h. - 16h. <br/>"; } elseif ($day1 == "weekday") { echo "<br/> Working Hours of {$this->name}: <br/> 9h. - 19h. <br/>"; } } } $pearPhone = new Product('PearPhone', 'TX300', 'Phone', 750, 17, 2014); $pearPhone->show_info(); $pearPhone->buyItems(15); $pearPhone->show_info(); $pearPhone->isAvailable(); $pearPhone->year = 2015; echo "Release year corrected. New year: {$pearPhone->year}. <br/>"; echo "Review of the product: {$pearPhone->review} <br/>"; $pearBook = new Product('PearBook', 'L350', 'Notebook', 1250, 21, 2015); $pearBook->show_info(); $pearBook->newItems(16); $main_store = new Store('p-Store', 'Pear Street 75', 'Michael Sheldon', 1200000, 800, 18); $main_store->show_store(); $sec_store = new Store('NoteBook', 'Fearville Street 18', 'George Kennedy', 3500875, 958, 25); $sec_store->show_store(); $sec_store->working_hours(); $sec_store->hire_employee('Carter Flemings', 'manager', 2150);
$showAlerts = new CommonMethods(); $productModel = new ProductModel(); $productModel->_setProductName($productDetails->productname); $productModel->_setProductAbbrevations($productDetails->abbrevation); $productModel->_setProductUnitOfMeasure($productDetails->unitofmeasure); $productModel->_setProductAlertQty($productDetails->alertquantity); $productModel->_setProductColor($productDetails->color); $productModel->_setProductDescription($productDetails->description); $productModel->_setProductPackaging($productDetails->packaging); $productModel->_setProductType($productDetails->materialtypeid); $productModel->_setProductOperation($productDetails->opertaion); $productObj = new Product($productModel); switch ($productDetails->opertaion) { case 'insert': # code... if (!$productObj->isAvailable($dbh)) { $productObj->insertProductInToDb($dbh, $userId); } else { $showAlerts->showAlert("Failure", "Product you are trying to add is already added"); } break; case 'delete': # code... //$productObj = new Product(); $productObj->deleteProduct($dbh, $userId, $productDetails); break; case 'modify': if ($productDetails->isProductMasterTable || $productDetails->isProductDetailsTable || $productDetails->isProductPackagingTable || $productDetails->isProductMaterialTable) { $productObj->updateProduct($dbh, $userId, $productDetails); } else { $showAlerts->showAlert('Failure', "Nothing to update");