コード例 #1
0
 public function product_review($product_id)
 {
     $product_id = id_decrypt($product_id);
     $product_data = $this->Sementic_product_m->get_product_detail($product_id);
     if ($_POST) {
         $this->custom_log->write_log('custom_log', 'Form submit ' . print_r($_POST, true));
         $this->Sementic_product_m->activate_product($product_id);
         $this->session->set_flashdata('success', 'successfully added product in the productlist');
         $productHistoryDet = $this->Sementic_product_m->last_semantics_product_history($product_id);
         $this->custom_log->write_log('custom_log', 'product history details is ' . print_r($productHistoryDet, true));
         if (!empty($productHistoryDet)) {
             $lastProductHistoryId = $productHistoryDet->productHistoryId;
             $this->Sementic_product_m->activate_semantic_product_history($lastProductHistoryId);
         }
         if (!empty($product_data->productTypeId) && $product_data->productTypeId == 3) {
             if ($this->session->userdata('userType') == 'superadmin' || $this->session->userdata('userType') == 'admin' || $this->session->userdata('userType') == 'cse') {
                 $rules = add_pseudo_product_rules();
                 $this->form_validation->set_rules($rules);
                 $this->form_validation->set_error_delimiters('<div class="error">', '</div>');
                 if ($this->form_validation->run()) {
                     $checkAlreadyInventroy = $this->product_m->check_pseudo_organization_product_inventory($product_id);
                     $this->custom_log->write_log('custom_log', 'CHECk pseudo product inventory is ' . print_r($checkAlreadyInventroy, true));
                     if (!empty($checkAlreadyInventroy)) {
                         $organizationProductId = $checkAlreadyInventroy->organizationProductId;
                         $this->product_m->update_pseudo_organization_product($organizationProductId, $this->input->post('product_price'));
                         $this->custom_log->write_log('custom_log', 'update organization product id is ' . $organizationProductId);
                     } else {
                         $organizationProductId = $this->product_m->add_pseudo_organization_product($product_id, $this->input->post('product_price'));
                         $this->custom_log->write_log('custom_log', 'organization product id is ' . $organizationProductId);
                     }
                     /*********Inventory History Start******************/
                     $this->product_m->accept_request($product_id);
                     $this->product_m->unactive_old_inventory_history($organizationProductId);
                     $inventoryHistoryId = $this->product_m->add_pseudo_product_inventory_history($product_id, $organizationProductId, $this->input->post('product_price'));
                     $this->custom_log->write_log('custom_log', 'Inventory history id is ' . $inventoryHistoryId);
                     /*********Inventory History End  ******************/
                     if ($organizationProductId) {
                         $organizationColorIdArray = array();
                         $organizationSizeIdArray = array();
                         $productColors = $this->product_m->product_all_color($product_id);
                         $this->custom_log->write_log('custom_log', 'product colors ' . print_r($productColors, true));
                         if (!empty($productColors)) {
                             foreach ($productColors as $colorRow) {
                                 $organizationColorId = $this->product_m->add_organization_color_stock($organizationProductId, 1000000000, $colorRow->colorId);
                                 $this->custom_log->write_log('custom_log', 'organization color stock id is ' . $organizationColorId);
                                 $organizationColorIdArray[$organizationColorId]['id'] = $organizationColorId;
                                 $organizationColorIdArray[$organizationColorId]['colorId'] = $colorRow->colorId;
                             }
                         }
                         $productSizes = $this->product_m->product_all_size($product_id);
                         $this->custom_log->write_log('custom_log', 'product size ' . print_r($productSizes, true));
                         if (!empty($productSizes)) {
                             foreach ($productSizes as $sizeRow) {
                                 $organizationProductStockId = $this->product_m->add_organization_size_stock($organizationProductId, 1000000000, $sizeRow->productSizeId);
                                 $this->custom_log->write_log('custom_log', 'organization product size stock id is ' . $organizationProductStockId);
                                 $organizationSizeIdArray[$organizationProductStockId]['id'] = $organizationProductStockId;
                                 $organizationSizeIdArray[$organizationProductStockId]['productSizeId'] = $sizeRow->productSizeId;
                             }
                         }
                         /*********organziation product color size combination history***************************/
                         if (!empty($organizationColorIdArray) && !empty($organizationSizeIdArray)) {
                             foreach ($organizationColorIdArray as $colorId => $colorVal) {
                                 foreach ($organizationSizeIdArray as $sizeId => $sizeVal) {
                                     $organizationColorSizeId = $this->product_m->add_organization_color_size_stock($organizationProductId, $colorId, $sizeId, $colorVal['colorId'], $sizeVal['productSizeId'], 1000000000);
                                     $this->custom_log->write_log('custom_log', 'organization color size stock id is ' . $organizationColorSizeId);
                                 }
                             }
                         } elseif (!empty($organizationColorIdArray)) {
                             foreach ($organizationColorIdArray as $colorId => $colorVal) {
                                 $organizationColorSizeId = $this->product_m->add_organization_color_size_stock($organizationProductId, $colorId, 0, $colorVal['colorId'], 0, 1000000000);
                                 $this->custom_log->write_log('custom_log', 'organization color size stock id is ' . $organizationColorSizeId);
                             }
                         } elseif (!empty($organizationSizeIdArray)) {
                             foreach ($organizationSizeIdArray as $sizeId => $sizeVal) {
                                 $organizationColorSizeId = $this->product_m->add_organization_color_size_stock($organizationProductId, 0, $sizeId, 0, $sizeVal['productSizeId'], 1000000000);
                                 $this->custom_log->write_log('custom_log', 'organization color size stock id is ' . $organizationColorSizeId);
                             }
                         }
                         /*********organziation product color size combination history***************************/
                     } else {
                         $this->session->set_flashdata('error', 'inventory not create');
                         $this->custom_log->write_log('custom_log', 'inventory not create');
                         redirect(base_url() . $this->session->userdata('userType') . '/semantics/product_review/' . id_encrypt($product_id));
                     }
                     redirect('cse/product_management');
                 }
             } else {
                 redirect('cse/product_management');
             }
         } else {
             redirect('cse/product_management');
         }
     }
     $this->data['productcolorlist'] = $this->product_m->get_product_color_list($product_id);
     $this->data['product_data'] = $product_data;
     $this->data['product_detail'] = $this->product_m->product_attributes_details($product_id);
     $this->cseCustomView('admin/semantics/test3', $this->data);
 }
コード例 #2
0
 public function admin_product_review($product_id = '')
 {
     $userType = $this->CI->session->userdata('userType');
     $this->CI->custom_log->write_log('custom_log', 'product id is ' . $product_id);
     $returnArr = array();
     $returnArr['product_name'] = '';
     $returnArr['productDescription'] = '';
     $returnArr['upc'] = '';
     $returnArr['product_tax'] = '';
     $returnArr['segment_name'] = '';
     $returnArr['category_name'] = '';
     $returnArr['sub_category1_name'] = '';
     $returnArr['sub_category2_name'] = '';
     $returnArr['sub_category3_name'] = '';
     $returnArr['sub_category4_name'] = '';
     $returnArr['sub_category5_name'] = '';
     $returnArr['sub_category6_name'] = '';
     $returnArr['brandName'] = '';
     $returnArr['spid'] = '';
     $returnArr['item_weight'] = '';
     $returnArr['packing_weight'] = '';
     $returnArr['total_weight'] = '';
     $returnArr['productTypeId'] = '';
     $returnArr['product_Type'] = '';
     $returnArr['product_images'] = array();
     $returnArr['product_attributes'] = array();
     $returnArr['keyFeatures'] = array();
     $returnArr['mrp'] = '';
     $returnArr['active'] = '';
     $returnArr['brandStatus'] = 0;
     $returnArr['sizes'] = '';
     $returnArr['productPrice'] = '';
     //$productAttrDetails = $this->CI->product_m->product_brand_image_category_details($product_id);
     $productAttrDetails = $this->CI->product_m->product_brand_category_details($product_id);
     //echo "<pre>"; print_r($productAttrDetails); exit;
     $uriSeg5 = $this->CI->uri->segment(5);
     /***************add product of psudo in retailer inventory*************/
     if (!empty($productAttrDetails->productTypeId) && $productAttrDetails->productTypeId == 3) {
         if ($this->CI->session->userdata('userType') == 'superadmin' || $this->CI->session->userdata('userType') == 'admin' || $this->CI->session->userdata('userType') == 'cse') {
             $checkAlreadyInventroy = $this->CI->product_m->check_pseudo_organization_product_inventory($product_id);
             $this->CI->custom_log->write_log('custom_log', 'CHECk pseudo product inventory is ' . print_r($checkAlreadyInventroy, true));
             if (!empty($checkAlreadyInventroy)) {
                 $returnArr['productPrice'] = $checkAlreadyInventroy->currentPrice;
             }
             if ($_POST) {
                 $this->CI->custom_log->write_log('custom_log', 'Form submit ' . print_r($_POST, true));
                 $returnArr['productPrice'] = $this->CI->input->post('product_price');
                 $rules = add_pseudo_product_rules();
                 $this->CI->form_validation->set_rules($rules);
                 $this->CI->form_validation->set_error_delimiters('<div class="error">', '</div>');
                 if ($this->CI->form_validation->run()) {
                     if (!empty($checkAlreadyInventroy)) {
                         $organizationProductId = $checkAlreadyInventroy->organizationProductId;
                         $this->CI->product_m->update_pseudo_organization_product($organizationProductId, $returnArr['productPrice']);
                         $this->CI->custom_log->write_log('custom_log', 'update organization product id is ' . $organizationProductId);
                     } else {
                         $organizationProductId = $this->CI->product_m->add_pseudo_organization_product($product_id, $returnArr['productPrice']);
                         $this->CI->custom_log->write_log('custom_log', 'organization product id is ' . $organizationProductId);
                     }
                     /*********Inventory History Start******************/
                     $this->CI->product_m->unactive_old_inventory_history($organizationProductId);
                     $inventoryHistoryId = $this->CI->product_m->add_pseudo_product_inventory_history($product_id, $organizationProductId, $returnArr['productPrice']);
                     $this->CI->custom_log->write_log('custom_log', 'Inventory history id is ' . $inventoryHistoryId);
                     /*********Inventory History End  ******************/
                     if ($organizationProductId) {
                         $organizationColorIdArray = array();
                         $organizationSizeIdArray = array();
                         $productColors = $this->CI->product_m->product_all_color($product_id);
                         $this->CI->custom_log->write_log('custom_log', 'product colors ' . print_r($productColors, true));
                         $productSizes = $this->CI->product_m->product_all_size($product_id);
                         $this->CI->custom_log->write_log('custom_log', 'product size ' . print_r($productSizes, true));
                         if (!empty($productSizes)) {
                             foreach ($productSizes as $sizeRow) {
                                 $organizationProductStockId = $this->CI->product_m->add_organization_size_stock($organizationProductId, 1000000000, $sizeRow->productSizeId);
                                 $this->CI->custom_log->write_log('custom_log', 'organization product size stock id is ' . $organizationProductStockId);
                                 $organizationSizeIdArray[$organizationProductStockId]['id'] = $organizationProductStockId;
                                 $organizationSizeIdArray[$organizationProductStockId]['productSizeId'] = $sizeRow->productSizeId;
                             }
                         }
                         if (!empty($productColors)) {
                             foreach ($productColors as $colorRow) {
                                 $organizationColorId = $this->CI->product_m->add_organization_color_stock($organizationProductId, 1000000000, $colorRow->colorId);
                                 $this->CI->custom_log->write_log('custom_log', 'organization color stock id is ' . $organizationColorId);
                                 $organizationColorIdArray[$organizationColorId]['id'] = $organizationColorId;
                                 $organizationColorIdArray[$organizationColorId]['colorId'] = $colorRow->colorId;
                             }
                         }
                         /*********organziation product color size combination history***************************/
                         if (!empty($organizationColorIdArray) && !empty($organizationSizeIdArray)) {
                             foreach ($organizationColorIdArray as $colorId => $colorVal) {
                                 foreach ($organizationSizeIdArray as $sizeId => $sizeVal) {
                                     $organizationColorSizeId = $this->CI->product_m->add_organization_color_size_stock($organizationProductId, $colorId, $sizeId, $colorVal['colorId'], $sizeVal['productSizeId'], 1000000000);
                                     $this->CI->custom_log->write_log('custom_log', 'organization color size stock id is ' . $organizationColorSizeId);
                                 }
                             }
                         } elseif (!empty($organizationColorIdArray)) {
                             foreach ($organizationColorIdArray as $colorId => $colorVal) {
                                 $organizationColorSizeId = $this->CI->product_m->add_organization_color_size_stock($organizationProductId, $colorId, 0, $colorVal['colorId'], 0, 1000000000);
                                 $this->CI->custom_log->write_log('custom_log', 'organization color size stock id is ' . $organizationColorSizeId);
                             }
                         } elseif (!empty($organizationSizeIdArray)) {
                             foreach ($organizationSizeIdArray as $sizeId => $sizeVal) {
                                 $organizationColorSizeId = $this->CI->product_m->add_organization_color_size_stock($organizationProductId, 0, $sizeId, 0, $sizeVal['productSizeId'], 1000000000);
                                 $this->CI->custom_log->write_log('custom_log', 'organization color size stock id is ' . $organizationColorSizeId);
                             }
                         }
                         /*********organziation product color size combination history***************************/
                         $uriSeg5 = 'save';
                     } else {
                         $this->CI->session->set_flashdata('error', 'inventory not create');
                         $this->CI->custom_log->write_log('custom_log', 'inventory not create');
                         redirect(base_url() . $this->CI->session->userdata('userType') . '/product_management');
                     }
                 }
             }
         }
     }
     /***************add product of psudo in retailer inventory*************/
     if ($uriSeg5 == 'save') {
         if ($this->CI->session->userdata('userType') == 'superadmin' || $this->CI->session->userdata('userType') == 'admin') {
             $verificationResultId = 2;
             if (!empty($productAttrDetails)) {
                 $veriResId = $productAttrDetails->verificationResultId;
                 if ($veriResId == 3 || $veriResId == 4) {
                     $verificationResultId = 5;
                 }
             }
         } elseif ($this->CI->session->userdata('userType') == 'retailer') {
             $verificationResultId = 3;
         } elseif ($this->CI->session->userdata('userType') == 'cse') {
             $verificationResultId = 4;
         }
         $this->CI->db->where('productId', $product_id);
         $this->CI->db->update('product', array('verificationResultId' => $verificationResultId, 'lastModifiedBy' => $this->CI->session->userdata('userId'), 'lastModifiedDt' => date('Y-m-d H:i:s')));
         $productHistoryDet = $this->CI->product_m->last_product_history($product_id);
         $this->CI->custom_log->write_log('custom_log', 'product history details is ' . print_r($productHistoryDet, true));
         if (!empty($productHistoryDet)) {
             $lastProductHistoryId = $productHistoryDet->productHistoryId;
             if ($lastProductHistoryId) {
                 $this->CI->product_m->update_varification_history($lastProductHistoryId, $verificationResultId);
             }
         }
         $this->CI->session->set_flashdata('success', 'Product added successfully');
         $this->CI->custom_log->write_log('custom_log', 'Product added successfully');
         if ($this->CI->session->userdata('userType') == 'retailer') {
             redirect(base_url() . $this->CI->session->userdata('userType') . '/product_request_management');
         } else {
             redirect(base_url() . $this->CI->session->userdata('userType') . '/product_management');
         }
     }
     $this->CI->custom_log->write_log('custom_log', 'product row details is ' . print_r($productAttrDetails, true));
     if (!empty($productAttrDetails)) {
         $returnArr['product_name'] = $productAttrDetails->code;
         $returnArr['brandStatus'] = $productAttrDetails->brandStatus;
         $returnArr['active'] = $productAttrDetails->active;
         $returnArr['brandName'] = $productAttrDetails->brandName;
         $returnArr['spid'] = $productAttrDetails->productId;
         $returnArr['item_weight'] = $productAttrDetails->weight;
         $returnArr['packing_weight'] = $productAttrDetails->shippingWeight;
         $returnArr['total_weight'] = $returnArr['item_weight'] + $returnArr['packing_weight'];
         $returnArr['productTypeId'] = $productAttrDetails->productTypeId;
         $parentCatDet = $this->CI->segment_cat_m->category_parent_list($productAttrDetails->categoryId);
         if (!empty($parentCatDet)) {
             $i = 1;
             foreach ($parentCatDet as $row) {
                 if ($i == 1) {
                     $returnArr['segment_name'] = $row->categoryCode;
                 } elseif ($i == 2) {
                     $returnArr['category_name'] = $row->categoryCode;
                 } elseif ($i == 3) {
                     $returnArr['sub_category1_name'] = $row->categoryCode;
                 } elseif ($i == 4) {
                     $returnArr['sub_category2_name'] = $row->categoryCode;
                 } elseif ($i == 5) {
                     $returnArr['sub_category3_name'] = $row->categoryCode;
                 } elseif ($i == 6) {
                     $returnArr['sub_category4_name'] = $row->categoryCode;
                 } elseif ($i == 7) {
                     $returnArr['sub_category5_name'] = $row->categoryCode;
                 } elseif ($i == 8) {
                     $returnArr['sub_category6_name'] = $row->categoryCode;
                 }
                 $i++;
             }
         }
     }
     $returnArr['product_images'] = array();
     $productImages = $this->CI->product_m->product_images($product_id);
     if (!empty($productImages)) {
         $i = 0;
         foreach ($productImages as $row) {
             $returnArr['product_images'][$i]['imageName'] = $row->imageName;
             $returnArr['product_images'][$i]['displayOrder'] = $row->displayOrder;
             $i++;
         }
     }
     //$returnArr['marketing_product']=$this->CI->product_m->get_marketing_product_detail($product_id);
     $returnArr['marketing_product'] = $this->CI->product_m->get_marketing_product_detail_for_product($product_id);
     $returnArr['spid'] = 1000000000 + $returnArr['spid'];
     $attrDetails = '';
     $attrDetails = $this->CI->product_m->admin_product_attributes_details($product_id);
     //echo "<pre>"; print_r($returnArr['marketing_product']); exit;
     //echo "<pre>"; print_r($returnArr['attrDetails']); exit;
     if (!empty($attrDetails)) {
         $i = 0;
         foreach ($attrDetails as $row) {
             if (!empty($row->attributeName)) {
                 $returnArr['attributeName'][$i] = $row->attributeName;
             } else {
                 $returnArr['attributeName'][$i] = $row->productAttributeName;
             }
             $returnArr['attributeValue'][$i] = $row->attributeValue;
             $i++;
         }
     }
     $returnArr['productcolorlist'] = $this->CI->product_m->get_product_color_list($product_id);
     $returnArr['sizes'] = $this->CI->product_m->product_all_size($product_id);
     $returnArr['attrDetails'] = $attrDetails;
     return $returnArr;
 }