public function preDelete() { $product = DatabaseObject_Helper_ProductDisplay::getBasicProductInfo($this->_db, $this->product_id); if ($product[0]['purchase_type'] == 'Buy_now') { //remove color from product_colors; echo 'here at color removal'; $colors = array(); $colors['' . $this->sys_color . ''] = 0; DatabaseObject_Helper_ManageAttribute::insertProductColors($this->_db, 'product_colors', $this->product_id, $colors); } $this->getImages(); foreach ($this->images as $image) { $image->delete(false); } $this->profile->delete(); return true; }
public function process(Zend_Controller_Request_Abstract $request) { $this->customSetParam = $request->getParam('attributeSet'); //Zend_Debug::dump($this->customSetParam); //Zend_Debug::dump($_FILES['customAttributeDetailImage']); foreach ($this->customSetParam as $k => $v) { $this->customSetName[] = $k; } Zend_Debug::dump($this->customSetName[0]); foreach ($this->customSetParam[$this->customSetName[0]]['name'] as $k => $v) { $this->customSetKey[] = $k; } Zend_Debug::dump($this->customSetKey); $this->customSet->name_of_set = $this->customSetName[0]; $this->customSet->uploader_id = $this->userID; //echo $this->table; //echo $this->userID; //echo $this->customSetName[0]; if (!DatabaseObject_Helper_ManageAttribute::confirmattributenamewithuploader($this->db, $this->table, $this->userID, $this->customSetName[0])) { $this->customSet->save(); $this->attributeID = $this->customSet->getId(); //echo 'here at no error'; return true; } else { //echo 'here at errors'; echo 'duplicate, there is an error'; $this->addError('duplicate', 'this is a duplicate'); return !$this->hasError(); } //return true if no errors have occurred }
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 function retrieveProductFromProductsForPurchaseDetails($db, $productID) { //Fetch product $productProfileQuery = $db->select(); $productProfileQuery->from(array('p' => 'products'), '*')->where('product_id = ?', $productID); $productProfileQuery->join(array('u' => 'users'), 'u.userID=p.uploader_id', array('u.first_name', 'u.last_name')); $product = $db->fetchAll($productProfileQuery); if (count($product) == '1') { //Fetch description $productProfileQuery = $db->select(); $productProfileQuery->from('product_profiles', '*')->where('Product_id = ?', $product[0]['product_id']); $product['profile'] = $db->fetchAll($productProfileQuery); //Fetch product images $productImageQuery = $db->select(); $productImageQuery->from(array('images' => 'product_images'), '*')->where('images.Product_id = ?', $product[0]['product_id']); //echo $select2; $product['images'] = $db->fetchAll($productImageQuery); //Fetch general inventory information $inventorySelect = $db->select(); $inventorySelect->from(array('i' => 'product_inventories'), '*')->where('i.product_id = ?', $productID); $product['inventory'] = $db->fetchAll($inventorySelect); foreach ($product['inventory'] as $k => $v) { //Fetch inventory profile details $inventoryProfileQuery = $db->select(); $inventoryProfileQuery->from('product_inventory_profile', '*')->where('product_inventory_profile_id =?', $v['product_inventory_id']); $product['inventory'][$k]['profile'] = $db->fetchAll($inventoryProfileQuery); $product['inventory'][$k]['images'] = DatabaseObject_Helper_ImageUpload::loadImagesForItem($db, 'product_inventory_images', $v['product_inventory_id']); } $product['existingFabricSet'] = DatabaseObject_Helper_ManageAttribute::retrieveAttributeForProduct($db, 'fabric_set', $product[0]['product_id']); //Zend_Debug::dump($fp->existingFabricSet); $product['existingAttributeSet'] = DatabaseObject_Helper_ManageAttribute::retrieveAttributeForProduct($db, 'custom_attribute', $product[0]['product_id']); $product['systemColorAndShoesAttributes'] = DatabaseObject_Helper_ManageAttribute::retrieveProductColorAndShoeAttribute($db, $product[0]['inventory_attribute_table'], $product[0]['product_id']); } return $product; }
public function removeattributeAction() { $attributeType = $this->request->getParam('type'); $attributeID = $this->request->getParam('id'); if (DatabaseObject_Helper_ManageAttribute::confirmattributeidwithuploader($this->db, $attributeType, $this->signedInUserSessionInfoHolder->generalInfo->userID, $attributeID)) { if (DatabaseObject_Helper_ManageAttribute::removeAttributeForUser($this->db, $attributeType, $attributeID, $this->signedInUserSessionInfoHolder->generalInfo->username)) { $this->messenger->addMessage('Your attribute had been removed'); $this->_redirect($_SERVER['HTTP_REFERER']); } } }