public function replaceSubPropertyData($product_id = 0, $accessory_id = 0, $attribute_id = 0, $property_id = 0, $user_id, $uniqueid = "")
 {
     $producthelper = new producthelper();
     $subproperty = array();
     if ($property_id != 0 && $attribute_id != 0) {
         $attributes = $producthelper->getProductAttribute(0, 0, $attribute_id);
         $attributes = $attributes[0];
         $subproperty = $producthelper->getAttibuteSubProperty(0, $property_id);
     }
     if ($accessory_id != 0) {
         $prefix = $uniqueid . "acc_";
     } else {
         $prefix = $uniqueid . "prd_";
     }
     $attributelist = "";
     if (count($subproperty) > 0) {
         $commonid = $prefix . $product_id . '_' . $accessory_id . '_' . $attribute_id . '_' . $property_id;
         $subpropertyid = 'subproperty_id_' . $commonid;
         for ($i = 0; $i < count($subproperty); $i++) {
             $attributes_subproperty_vat = 0;
             if ($subproperty[$i]->subattribute_color_price > 0) {
                 $attributes_subproperty_vat = $producthelper->getProducttax($product_id, $subproperty[$i]->subattribute_color_price);
                 $subproperty[$i]->subattribute_color_price += $attributes_subproperty_vat;
                 $subproperty[$i]->text = urldecode($subproperty[$i]->subattribute_color_name) . " (" . $subproperty[$i]->oprand . $producthelper->getProductFormattedPrice($subproperty[$i]->subattribute_color_price) . ")";
             } else {
                 $subproperty[$i]->text = urldecode($subproperty[$i]->subattribute_color_name);
             }
             $attributelist .= '<input type="hidden" id="' . $subpropertyid . '_oprand' . $subproperty[$i]->value . '" value="' . $subproperty[$i]->oprand . '" />';
             $attributelist .= '<input type="hidden" id="' . $subpropertyid . '_protax' . $subproperty[$i]->value . '" value="' . $attributes_subproperty_vat . '" />';
             $attributelist .= '<input type="hidden" id="' . $subpropertyid . '_proprice' . $subproperty[$i]->value . '" value="' . $subproperty[$i]->subattribute_color_price . '" />';
         }
         $tmp_array = array();
         $tmp_array[0]->value = 0;
         $tmp_array[0]->text = JText::_('COM_REDSHOP_SELECT') . "&nbsp;" . urldecode($subproperty[0]->property_name);
         $new_subproperty = array_merge($tmp_array, $subproperty);
         $chklist = "";
         if ($attributes->allow_multiple_selection) {
             for ($chk = 0; $chk < count($subproperty); $chk++) {
                 $chklist .= "<br /><input type='checkbox' value='" . $subproperty[$chk]->value . "' name='" . $subpropertyid . "[]'  id='" . $subpropertyid . "' class='inputbox' onchange='javascript:calculateOfflineTotalPrice(\"" . $uniqueid . "\");' />&nbsp;" . $subproperty[$chk]->text;
             }
         } else {
             $chklist = JHTML::_('select.genericlist', $new_subproperty, $subpropertyid . '[]', ' id="' . $subpropertyid . '" class="inputbox" size="1" onchange="javascript:calculateOfflineTotalPrice(\'' . $uniqueid . '\');" ', 'value', 'text', '');
         }
         $lists['subproperty_id'] = $chklist;
         $attributelist .= "<tr><td>" . urldecode($subproperty[0]->property_name) . " : " . $lists['subproperty_id'];
     }
     return $attributelist;
 }
Beispiel #2
0
 function getProductData($userData)
 {
     $producthelper = new producthelper();
     if ($userData->product_id) {
         $productDetail = "";
         $product_data = $producthelper->getProductById($userData->product_id);
         if ($userData->subproperty_id) {
             $subproperty_data = $producthelper->getAttibuteSubProperty($userData->subproperty_id);
             $property_data = $producthelper->getAttibuteProperty($userData->property_id);
         } else {
             if ($userData->property_id) {
                 $property_data = $producthelper->getAttibuteProperty($userData->property_id);
             }
         }
         $productData = array();
         $productDetail = $product_data->product_name;
         if (count($property_data) > 0) {
             $productDetail .= "<br/>" . $property_data['property_name'];
         }
         if (count($subproperty_data) > 0) {
             $productDetail .= "<br/>" . $subproperty_data['subproperty_name'];
         }
         $productData['product_name'] = $product_data->product_name;
         $productData['product_detail'] = $productDetail;
         return $productData;
     }
 }
Beispiel #3
0
 /**
  * Load the attributes for export
  *
  * @return  void
  */
 private function loadAttributes()
 {
     $producthelper = new producthelper();
     $db = JFactory::getDbo();
     $query = "SELECT * FROM `#__redshop_product` ORDER BY product_id asc ";
     $this->_db->setQuery($query);
     $cur = $this->_db->loadObjectList();
     $ret = null;
     if (count($cur) > 0) {
         $redhelper = new redhelper();
         $isrecrm = false;
         if ($redhelper->isredCRM()) {
             $isrecrm = true;
         }
         for ($i = 0; $i < count($cur); $i++) {
             if ($i == 0) {
                 echo '"product_number","attribute_name","attribute_ordering","allow_multiple_selection","hide_attribute_price","attribute_required","display_type","property_name","property_stock"';
                 if ($isrecrm) {
                     echo ',"property_stock_placement"';
                 }
                 echo ',"property_ordering","property_virtual_number","setdefault_selected","setdisplay_type","oprand","property_price","property_image","property_main_image","subattribute_color_name","subattribute_stock"';
                 if ($isrecrm) {
                     echo ',"subattribute_stock_placement"';
                 }
                 echo ',"subattribute_color_ordering","subattribute_setdefault_selected","subattribute_color_title","subattribute_virtual_number","subattribute_color_oprand","required_sub_attribute","subattribute_color_price","subattribute_color_image","delete"';
                 echo "\r\n";
             }
             // Added attribute of products
             $attribute = $producthelper->getProductAttribute($cur[$i]->product_id);
             $attr = array();
             for ($att = 0; $att < count($attribute); $att++) {
                 if ($attribute[$att]->attribute_name != "") {
                     echo '"' . $cur[$i]->product_number . '","' . $attribute[$att]->attribute_name . '","' . $attribute[$att]->ordering . '","' . $attribute[$att]->allow_multiple_selection . '","' . $attribute[$att]->hide_attribute_price . '","' . $attribute[$att]->attribute_required . '","' . $attribute[$att]->display_type . '"';
                     if ($isrecrm) {
                         echo ',,';
                     }
                     echo ',,,,,,,,,,,,,,,,"0"';
                     echo "\r\n";
                     $att_property = $producthelper->getAttibuteProperty(0, $attribute[$att]->attribute_id);
                     for ($prop = 0; $prop < count($att_property); $prop++) {
                         $property_image = "";
                         $property_main_image = "";
                         $main_attribute_stock = "";
                         $sel_arrtibute_stock = "select * from `#__redshop_product_attribute_stockroom_xref` where section_id='" . $att_property[$prop]->property_id . "'";
                         $this->_db->setQuery($sel_arrtibute_stock);
                         $fetch_arrtibute_stock = $this->_db->loadObjectList();
                         for ($h = 0; $h < count($fetch_arrtibute_stock); $h++) {
                             $main_attribute_stock .= $fetch_arrtibute_stock[$h]->stockroom_id . ":" . $fetch_arrtibute_stock[$h]->quantity . "#";
                         }
                         if ($att_property[$prop]->property_image != "") {
                             $property_image = REDSHOP_FRONT_IMAGES_ABSPATH . 'product_attributes/' . $att_property[$prop]->property_image;
                         }
                         if ($att_property[$prop]->property_main_image != "") {
                             $property_main_image = REDSHOP_FRONT_IMAGES_ABSPATH . 'property/' . $att_property[$prop]->property_main_image;
                         }
                         echo '"' . $cur[$i]->product_number . '","' . $attribute[$att]->attribute_name . '",,,,,,"' . $att_property[$prop]->property_name . '","' . $main_attribute_stock . '"';
                         if ($isrecrm) {
                             $main_attribute_stock_placement = "";
                             // Initialiase variables.
                             $query = $this->_db->getQuery(true);
                             // Prepare query.
                             $query->select('stock_placement');
                             $query->from('#__redcrm_attribute_stock_placement');
                             $query->where('section = "property"');
                             $query->where('section_id = "' . $att_property[$prop]->property_id . '"');
                             // Inject the query and load the result.
                             $this->_db->setQuery($query);
                             $main_attribute_stock_placement = $this->_db->loadResult();
                             echo ',"' . $main_attribute_stock_placement . '"';
                         }
                         echo ',"' . $att_property[$prop]->ordering . '","' . $att_property[$prop]->property_number . '","' . $att_property[$prop]->setdefault_selected . '","' . $att_property[$prop]->setdisplay_type . '","' . $att_property[$prop]->oprand . '","' . $att_property[$prop]->property_price . '","' . $property_image . '","' . $property_main_image . '"';
                         if ($isrecrm) {
                             echo ',';
                         }
                         echo ',,,,,,,,,"0"';
                         echo "\n";
                         $subatt_property = $producthelper->getAttibuteSubProperty(0, $att_property[$prop]->property_id);
                         for ($subprop = 0; $subprop < count($subatt_property); $subprop++) {
                             $subattribute_color_image = "";
                             $main_attribute_stock_sub = "";
                             $sel_arrtibute_stock_sub = "select * from `#__redshop_product_attribute_stockroom_xref` where section_id='" . $subatt_property[$subprop]->subattribute_color_id . "'";
                             $this->_db->setQuery($sel_arrtibute_stock_sub);
                             $fetch_arrtibute_stock_sub = $this->_db->loadObjectList();
                             for ($b = 0; $b < count($fetch_arrtibute_stock_sub); $b++) {
                                 $main_attribute_stock_sub .= $fetch_arrtibute_stock_sub[$b]->stockroom_id . ":" . $fetch_arrtibute_stock_sub[$b]->quantity . "#";
                             }
                             if ($subatt_property[$subprop]->subattribute_color_image != "") {
                                 $subattribute_color_image = REDSHOP_FRONT_IMAGES_ABSPATH . 'subcolor/' . $subatt_property[$subprop]->subattribute_color_image;
                             }
                             echo '"' . $cur[$i]->product_number . '","' . $attribute[$att]->attribute_name . '",,,,,,"' . $att_property[$prop]->property_name . '"';
                             if ($isrecrm) {
                                 echo ',';
                             }
                             echo ',,,,,,,,,,"' . $subatt_property[$subprop]->subattribute_color_name . '","' . $main_attribute_stock_sub . '"';
                             if ($isrecrm) {
                                 $main_attribute_stock_sub_placement = "";
                                 // Initialiase variables.
                                 $query = $this->_db->getQuery(true);
                                 // Prepare query.
                                 $query->select('stock_placement');
                                 $query->from('#__redcrm_attribute_stock_placement');
                                 $query->where('section = "subproperty"');
                                 $query->where('section_id = "' . $subatt_property[$subprop]->subattribute_color_id . '"');
                                 // Inject the query and load the result.
                                 $this->_db->setQuery($query);
                                 $main_attribute_stock_sub_placement = $this->_db->loadResult();
                                 echo ',"' . $main_attribute_stock_sub_placement . '"';
                             }
                             echo ',"' . $subatt_property[$subprop]->ordering . '","' . $subatt_property[$subprop]->setdefault_selected . '","' . $subatt_property[$subprop]->subattribute_color_title . '","' . $subatt_property[$subprop]->subattribute_color_number . '","' . $subatt_property[$subprop]->oprand . '","' . $att_property[$prop]->setrequire_selected . '","' . $subatt_property[$subprop]->subattribute_color_price . '","' . $subattribute_color_image . '","0"';
                             echo "\n";
                         }
                     }
                 }
             }
         }
     }
 }
Beispiel #4
0
if ($showbuttons == 1) {
    switch ($media_section) {
        case "product":
            $sectionadata = $producthelper->getProductById($section_id);
            $section_name = $sectionadata->product_name;
            $sectiona_primary_image = $sectionadata->product_full_image;
            $directory = $media_section;
            break;
        case "property":
            $sectionadata = $producthelper->getAttibuteProperty($section_id);
            $section_name = $sectionadata[0]->property_name;
            $sectiona_primary_image = $sectionadata[0]->property_main_image;
            $directory = 'property';
            break;
        case "subproperty":
            $sectionadata = $producthelper->getAttibuteSubProperty($section_id);
            $section_name = $sectionadata[0]->subattribute_color_name;
            $sectiona_primary_image = $sectionadata[0]->subattribute_color_main_image;
            $directory = 'subproperty';
            break;
    }
}
if ($showbuttons == 1) {
    ?>
	<fieldset>
	<div style="float: right">
		<button type="button" onclick="Joomla.submitbutton('add');">
			<?php 
    echo JText::_('COM_REDSHOP_ADD');
    ?>
		</button>
 /**
  * Function delete_subprop.
  *
  * @param   int  $sp               sp
  * @param   int  $subattribute_id  subattribute_id
  *
  * @return  void
  */
 public function delete_subprop($sp, $subattribute_id)
 {
     $producthelper = new producthelper();
     if ($sp) {
         $subproperty = $producthelper->getAttibuteSubProperty($sp, $subattribute_id);
     } else {
         $subproperty = $producthelper->getAttibuteSubProperty(0, $subattribute_id);
     }
     for ($j = 0; $j < count($subproperty); $j++) {
         $query = "DELETE FROM `" . $this->table_prefix . "product_subattribute_color`\r\n\t\t\t\t\t  WHERE `subattribute_id` = '" . $subattribute_id . "'\r\n\t\t\t\t\t  AND subattribute_color_id= '" . $subproperty[$j]->subattribute_color_id . "'";
         $this->_db->setQuery($query);
         $this->_db->query();
         $this->delete_image($subproperty[$j]->subattribute_color_image, 'subcolor');
     }
 }
 public function removesubpropertyImage($pid)
 {
     $producthelper = new producthelper();
     $image = $producthelper->getAttibuteSubProperty($pid);
     $image = $image[0];
     $imagename = $image->subattribute_color_image;
     $imagethumbsrcphy = REDSHOP_FRONT_IMAGES_RELPATH . "subcolor/thumb/" . $imagename;
     if (is_file($imagethumbsrcphy)) {
         @unlink($imagethumbsrcphy);
     }
     $imagesrcphy = REDSHOP_FRONT_IMAGES_RELPATH . "subcolor/" . $imagename;
     if (is_file($imagesrcphy)) {
         @unlink($imagesrcphy);
     }
     $query = "UPDATE `" . $this->_table_prefix . "product_subattribute_color` SET `subattribute_color_image` = ''\r\n\t\tWHERE `subattribute_color_id` = " . $pid;
     $this->_db->setQuery($query);
     if (!$this->_db->Query()) {
         return false;
     }
     return true;
 }
Beispiel #7
0
 public function getFinalPreorderStockofProduct($product_id, $totalatt)
 {
     $producthelper = new producthelper();
     $isStockExists = $this->isPreorderStockExists($product_id);
     $isPreorderStockExists = '';
     if ($totalatt > 0 && !$isStockExists) {
         $property = $producthelper->getAttibuteProperty(0, 0, $product_id);
         for ($att_j = 0; $att_j < count($property); $att_j++) {
             $isSubpropertyStock = false;
             $sub_property = $producthelper->getAttibuteSubProperty(0, $property[$att_j]->property_id);
             for ($sub_j = 0; $sub_j < count($sub_property); $sub_j++) {
                 $isSubpropertyStock = $this->isPreorderStockExists($sub_property[$sub_j]->subattribute_color_id, 'subproperty');
                 if ($isSubpropertyStock) {
                     $isStockExists = $isSubpropertyStock;
                     break;
                 }
             }
             if ($isSubpropertyStock) {
                 break;
             } else {
                 $isPropertystock = $this->isPreorderStockExists($property[$att_j]->property_id, "property");
                 if ($isPropertystock) {
                     $isStockExists = $isPropertystock;
                     break;
                 }
             }
         }
     }
     return $isStockExists;
 }
Beispiel #8
0
$attributeproductStockStatus = null;
$selectedpropertyId = 0;
$selectedsubpropertyId = 0;
if (count($attributes) > 0 && count($attribute_template) > 0) {
    for ($a = 0; $a < count($attributes); $a++) {
        $selectedId = array();
        $property = $producthelper->getAttibuteProperty(0, $attributes[$a]->attribute_id);
        if ($attributes[$a]->text != "" && count($property) > 0) {
            for ($i = 0; $i < count($property); $i++) {
                if ($property[$i]->setdefault_selected) {
                    $selectedId[] = $property[$i]->property_id;
                }
            }
            if (count($selectedId) > 0) {
                $selectedpropertyId = $selectedId[count($selectedId) - 1];
                $subproperty = $producthelper->getAttibuteSubProperty(0, $selectedpropertyId);
                $selectedId = array();
                for ($sp = 0; $sp < count($subproperty); $sp++) {
                    if ($subproperty[$sp]->setdefault_selected) {
                        $selectedId[] = $subproperty[$sp]->subattribute_color_id;
                    }
                }
                if (count($selectedId) > 0) {
                    $selectedsubpropertyId = $selectedId[count($selectedId) - 1];
                }
            }
        }
    }
    $preselectedresult = $producthelper->displayAdditionalImage($this->data->product_id, 0, 0, $selectedpropertyId, $selectedsubpropertyId, $pw_thumb, $ph_thumb, $redview = 'product');
    $productAvailabilityDate = strstr($template_desc, "{product_availability_date}");
    $stockNotifyFlag = strstr($template_desc, "{stock_notify_flag}");