public function addinventoryAction() { //for uploading information into product_inventory add 'sys_' infront of all the variables uploaded // $productID = $this->request->getParam('id'); //$product = DatabaseObject_Helper_ProductDisplay::getBasicProductInfo($this->db, $productID); //Zend_Debug::dump($product); $allowedProduct = DatabaseObject_Helper_ProductListing::confirmproductforuploader($this->db, 'products', $this->signedInUserSessionInfoHolder->generalInfo->userID, $productID); //make sure that the product is not a Buy_now product if (count($allowedProduct) == 1 && $allowedProduct[0]['purchase_type'] == 'Customizable') { $allowedProduct['existingFabricSet'] = DatabaseObject_Helper_ManageAttribute::retrieveAttributeForProduct($this->db, 'fabric_set', $productID); //Zend_Debug::dump($fp->existingFabricSet); $allowedProduct['existingAttributeSet'] = DatabaseObject_Helper_ManageAttribute::retrieveAttributeForProduct($this->db, 'custom_attribute', $productID); $allowedProduct['systemColorAndShoesAttributes'] = DatabaseObject_Helper_ManageAttribute::retrieveProductColorAndShoeAttribute($this->db, $allowedProduct[0]['inventory_attribute_table'], $productID); //check to see if searchable criteria color is available. If not, redirect. $hasColor = false; foreach ($allowedProduct['systemColorAndShoesAttributes']['colors'][0] as $k => $v) { if ($v == '1' && $k != 'product_id') { $hasColor = true; break; } } if (!$hasColor) { $this->messenger->addMessage('Please select at least one major color categories this product belongs to.'); $this->_redirect('/manageattribute/editproductattribute?id=' . $productID); } //if the item is shoes, then fill all the measurements. if ($allowedProduct[0]['inventory_attribute_table'] == 'shoes') { //if there are no shoe attributes, redirect if (count($allowedProduct['systemColorAndShoesAttributes']['shoes']) == 0) { $this->messenger->addMessage('You must specify shoes attributes first!'); $this->_redirect('/manageattribute/editproductattribute?id=' . $productID); } $measurement = array(); $i = $allowedProduct['systemColorAndShoesAttributes']['shoes'][0]['min_size']; while ($i < $allowedProduct['systemColorAndShoesAttributes']['shoes'][0]['max_size'] + 0.5) { $measurement[] = $i; $i = $i + 0.5; } $this->view->measurements = $measurement; $heels = array(); foreach ($allowedProduct['systemColorAndShoesAttributes']['heels'][0] as $key => $value) { if ($key != 'product_id') { if ($value == 1) { $heels[] = $this->productConfig['attribute_conversion_details']['heel_sizes'][$key]; } } } Zend_Debug::dump($this->productConfig['attribute_conversion_details']['heel_sizes']); $this->view->heels = $heels; } elseif ($allowedProduct[0]['inventory_attribute_table'] != 'jewelry' && $allowedProduct[0]['inventory_attribute_table'] != 'accessories') { echo 'here at dancewear'; $inventoryDancewearAttribute = array(); foreach ($this->productConfig['attribute_categories_details'][$allowedProduct[0]['inventory_attribute_table']] as $k => $v) { $inventoryDancewearAttribute[$k] = array(); $inventoryDancewearAttribute[$k][] = 'Flexible'; $temp = $v['min']; while ($temp < $v['max']) { $inventoryDancewearAttribute[$k][] = $temp; $temp += $v['interval']; } } $this->view->measurements = $inventoryDancewearAttribute; Zend_Debug::dump($inventoryDancewearAttribute); } //inventory_attribute_table is the defualt system attribute system. $this->view->attributePartial = '_' . $allowedProduct[0]['inventory_attribute_table'] . 'Attribute.tpl'; $this->view->product = $allowedProduct; Zend_Debug::dump($allowedProduct); $fp = new FormProcessor_Inventory_AddInventory($this->db, $this->signedInUserSessionInfoHolder->generalInfo->userID); if ($this->request->isPost()) { if ($fp->process($this->request)) { //process images echo 'post is: ' . Zend_Debug::dump($this->request->getParams()); DatabaseObject_Helper_ImageUpload::uploadImage($_FILES['generalImages'], $this->db, 'product_inventory_images', 'inventory', $fp->inventoryProduct->getId(), $fp->sys_name); $this->messenger->addMessage('Inventory product has been added'); $this->_redirect($_SERVER['HTTP_REFERER']); } //echo 'here at post<br />'; } $inventories = DatabaseObject_Helper_ManageInventory::retrieveInventoryForProduct($this->db, 'product_inventories', $productID); if (count($inventories) != 0) { $tmpInventoryKey = array(); foreach ($inventories as $k => $v) { $tmpInventoryKey[] = $v['basic']['product_inventory_id']; } Zend_Debug::dump($tmpInventoryKey); $completeInventoryProfile = DatabaseObject_Helper_ManageInventory::retrieveUniqueProfileKeys($this->db, 'product_inventory_profile', $tmpInventoryKey); Zend_Debug::dump($completeInventoryProfile); $this->view->mostInventoryProfile = $completeInventoryProfile; } else { $this->view->mostInventoryProfile = array(); } //Zend_Debug::dump($inventories[$k]['profile']); $this->view->inventories = $inventories; $this->view->inventoryPartial = '_' . $allowedProduct[0]['inventory_attribute_table'] . 'Inventory.tpl'; $this->view->inventoryPartialTitle = '_' . $allowedProduct[0]['inventory_attribute_table'] . 'InventoryTitle.tpl'; $this->view->addPartial = '_add' . $allowedProduct[0]['purchase_type'] . 'Inventory.tpl'; echo 'add partial is: ' . '_add' . $allowedProduct[0]['purchase_type'] . 'Inventory.tpl'; Zend_Debug::dump($inventories); //$this->sendJson($json); //Zend_Debug::dump($json); //Zend_Debug::dump($this->request->getParams()); } else { $this->messenger->addMessage('sorry, an error has occured. You may not add an inventory product at this moment'); $this->_redirect('/index/error'); } }
public static function removeProductAndInventoryImage($db, $fatherTable, $imagetable, $product_tag, $imageID, $postID, $userID) { if ($product_tag == 'inventory') { $okayBool = DatabaseObject_Helper_InventoryManager::verifyInventoryItemForUser($db, $postID, $userID); } else { $okayBool = DatabaseObject_Helper_ProductListing::confirmproductforuploader($db, $fatherTable, $userID, $postID); } if ($okayBool) { $image = new DatabaseObject_Image($db, $imagetable, $product_tag); if ($image->loadForPost($postID, $imageID)) { echo 'here at load image'; if ($image->delete()) { echo 'here at delete image'; return true; } else { return false; } } else { echo 'image not loaded'; } } else { echo 'You have no permission to perform this action'; return false; } }
public function saveproductattributeAction() { $productID = $this->request->getParam('id'); Zend_Debug::dump($this->request->getParams()); echo 'product id is: ' . $productID; if (DatabaseObject_Helper_ProductListing::confirmproductforuploader($this->db, 'products', $this->signedInUserSessionInfoHolder->generalInfo->userID, $productID)) { echo 'here good at product'; $colors = $this->request->getParam('color'); if (count($colors) == 0) { $this->messenger->addMessage('please select at least one major color categories this product belongs to.'); $this->_redirect($_SERVER['HTTP_REFERER']); } Zend_Debug::dump($colors); foreach ($this->productConfig['attribute_categories_details']['color'] as $k => $v) { if (isset($colors[$v])) { $colors[$v] = 1; echo $v . '<br/>'; } else { $colors[$v] = 0; } } //Zend_Debug::dump($colors); $product = DatabaseObject_Helper_ProductDisplay::getBasicProductInfo($this->db, $productID); $inventory_attribute_table = $product[0]['inventory_attribute_table']; if ($inventory_attribute_table == 'shoes') { //echo 'editing shoes'; $shoesAttribute['product_id'] = $productID; $shoesAttribute['shoes_metric'] = $this->request->getParam('shoes_metric'); $shoesAttribute['min_size'] = $this->request->getParam('min_size'); $shoesAttribute['max_size'] = $this->request->getParam('max_size'); $shoesAttribute['size_interval'] = $this->request->getParam('size_interval'); $shoesAttribute['ts_created'] = date('Y-m-d G:i:s'); //insert shoes attribute DatabaseObject_Helper_ManageAttribute::insertShoeProductAttribute($this->db, 'product_shoes_attributes', $productID, $shoesAttribute); //insert shoes heel $heels = $this->request->getParam('heel'); if (count($heels) == 0) { $this->messenger->addMessage('please select at least one heel size for this product.'); $this->_redirect($_SERVER['HTTP_REFERER']); } Zend_Debug::dump($heels); foreach ($this->productConfig['attribute_categories_details']['heel'] as $k => $v) { if (isset($heels[$v])) { $heels[$v] = 1; echo $v . '<br/>'; } else { $heels[$v] = 0; } } DatabaseObject_Helper_ManageAttribute::insertShoeHeelAttribute($this->db, 'product_shoes_heel', $productID, $heels); } DatabaseObject_Helper_ManageAttribute::insertProductColors($this->db, 'product_colors', $productID, $colors); $this->messenger->addMessage('product attribute saved'); $this->_redirect('manageinventory/addinventory?id=' . $productID); } }