public static function retrieveInventoryForProduct($db, $table, $product_id) { $select = $db->select(); $select->from($table, '*')->where('product_id = ?', $product_id); $records = $db->fetchAll($select); $id = array(); $inventoryArray = array(); foreach ($records as $k => $v) { $inventoryDetail['basic'] = $v; $inventoryDetail['profile'] = self::loadInventoryProfileDetail($db, 'product_inventory_profile', $v['product_inventory_id']); $inventoryDetail['profileCount'] = count($inventoryDetail['profile']); $inventoryDetail['images'] = DatabaseObject_Helper_ImageUpload::loadImagesForItem($db, 'product_inventory_images', $v['product_inventory_id']); $inventoryArray[] = $inventoryDetail; } //return $id; return $inventoryArray; }
public function imageAction() { if ($this->request->getParam('delete')) { $image_id = (int) $this->request->getParam('image'); $inventory_id = (int) $this->request->getParam('id'); //$attribute_name = $this->request->getParam('attribute_name'); if (DatabaseObject_Helper_ImageUpload::removeProductAndInventoryImage($this->db, 'product_inventories', 'product_inventory_images', 'inventory', $image_id, $inventory_id, $this->signedInUserSessionInfoHolder->generalInfo->userID)) { $this->messenger->addMessage('image successfully deleted'); $this->_redirect($_SERVER['HTTP_REFERER']); } } }
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 uploadattributeAction() { //action= 1 = new //action= 2 = add //action= 3 = delete //action= 0 =view $action = $this->request->getParam('actioncall'); //echo 'action is '.$action; if (!isset($action) || $action < 0 && $action > 3 || !is_numeric($action)) { echo 'invalid action'; //invalid action. } elseif ($action == 1) { //1 new. //need the action, paramSet echo 'action 1'; $table = $this->request->getParam('paramSet'); $table_details = $table . '_details'; //$paramSet = 'fabricSet'; Zend_Debug::dump($_FILES); //addition of new attributes. $fp = new FormProcessor_Attribute_CustomAttribute($this->db, $table, $this->signedInUserSessionInfoHolder->generalInfo->userID); if ($this->request->isPost()) { echo 'here at post<br />'; if ($fp->process($this->request)) { echo 'it is processed'; Zend_Debug::dump($_FILES); //Zend_Debug::dump($v); //echo 'product name is: '.$fp->product->name; echo 'the name of customeSetName is: ' . $fp->customSetName[0]; DatabaseObject_Helper_ImageUpload::uploadAttributeImage($_FILES['customAttributeDetailImage'], $fp->customSetParam, $this->db, $table_details, $fp->customSetName[0], $fp->attributeID, $this->signedInUserSessionInfoHolder->generalInfo->username); //redirect back to product listing/where they came from. //$this->_redirect("/manageattribute/uploadattribute?actioncall=0¶mSet=$table&id=$fp->attributeID"); $this->messenger->addMessage('Attribute set has been added'); $this->_redirect($_SERVER['HTTP_REFERER']); } else { echo "it is not processed."; $this->messenger->addMessage('it is not processed, there is a duplicate'); $this->_redirect($_SERVER['HTTP_REFERER']); //add message and redirect back to product listing where they came from. } } } elseif ($action == 2) { //add //need id of attribute_table //need the paramSet $id = $this->request->getParam('id'); if (isset($id) || $id > 0 && is_numeric($id)) { //load attribute $table = $this->request->getParam('paramSet'); $table_details = $table . '_details'; //check fabric id is valid $fabricSet = DatabaseObject_Helper_ManageAttribute::confirmattributeidwithuploader($this->db, $table, $this->signedInUserSessionInfoHolder->generalInfo->userID, $id); if (count($fabricSet) == 1) { $fp = new FormProcessor_Attribute_CustomAttribute($this->db, $table, $this->signedInUserSessionInfoHolder->generalInfo->userID); //load load id for attributeSet if ($fp->load($id)) { //if uploaded if ($this->request->isPost()) { //process image upload $customSetParam = $this->request->getParam('attributeSet'); //upload attribute details for image upload; DatabaseObject_Helper_ImageUpload::uploadAttributeImage($_FILES['customAttributeDetailImage'], $customSetParam, $this->db, $table_details, $fp->customSet->name_of_set, $fp->customSet->getId(), $this->signedInUserSessionInfoHolder->generalInfo->username); echo 'finished upload'; $this->_redirect("/manageattribute/uploadattribute?actioncall=0¶mSet={$table}&id={$id}"); $this->_redirect($_SERVER['HTTP_REFERER']); } } //$this->view->attribute = $attribute; } else { $this->messenger->addMessage('sorry you do not have permission to edit this attribute'); $this->_redirect($_SERVER['HTTP_REFERER']); } //edit existing attribute status } } elseif ($action == 3) { //3 delete //need id of attribute_detail id //need paramSet_detail list echo 'action is 3'; if ($this->request->isPost()) { $ids = $this->request->getParam('image_id'); //$attribute_name = $this->request->getParam('attribute_name'); $table = $this->request->getParam('paramSet'); $table_details = $table . '_details'; Zend_Debug::dump($ids); if (isset($ids) || count($ids) > 0) { foreach ($ids as $k => $v) { $image = new DatabaseObject_Attribute_CustomAttributeDetails($this->db, $table_details); if ($image->loadForPost($this->signedInUserSessionInfoHolder->generalInfo->username, $v)) { $attributeSetTmp = DatabaseObject_Helper_ManageAttribute::receiveAttributeSetFromId($this->db, $table, $image->set_id); Zend_Debug::dump($attributeSetTmp); $image->setSaveFilePath($this->signedInUserSessionInfoHolder->generalInfo->username, $table_details, $attributeSetTmp[0]['name_of_set']); //this has to be set for every operation that usesthe get thumbnail path. $image->delete(); } } $this->_redirect($_SERVER['HTTP_REFERER']); } else { $this->messenger->addMessage('You must select an attribute to delete'); $this->_redirect($_SERVER['HTTP_REFERER']); } } } elseif ($action == 0) { //view details echo 'action is 0'; $id = $this->request->getParam('id'); if (isset($id) || $id > 0 && is_numeric($id)) { $table = $this->request->getParam('paramSet'); $attributeSet = DatabaseObject_Helper_ManageAttribute::confirmattributeidwithuploader($this->db, $table, $this->signedInUserSessionInfoHolder->generalInfo->userID, $id); if (count($attributeSet) == 1) { Zend_Debug::dump($attributeSet); echo 'here at exisitng attribute'; $attribute = DatabaseObject_Helper_ManageAttribute::loadAttributeIdDetail($this->db, $table, $id); Zend_Debug::dump($attribute); $this->view->attribute = $attribute; } else { //$this->messenger->addMessage('sorry you do not have permission to edit this attribute'); echo 'can not load this attribute'; } } else { echo 'you must provide an specific id'; } } //only new fabric sets will be generated }