misc($query); } if (isset($_POST['EditSelected']) && is_array($_POST['product']) && !empty($_POST['MoveTo'])) { $i=0; foreach ($_POST['product'] as $key => $product_id) { if ($_POST['current'][$product_id] == $_POST['MoveTo']) break; ## Update primary category $query = sprintf("UPDATE %sCubeCart_inventory SET `cat_id`='%d' WHERE `productId`='%d';", $glob['dbprefix'], $_POST['MoveTo'], $product_id); $db->misc($query); ## Check if target category was added as an extra for product before $query = sprintf("SELECT cat_id FROM %sCubeCart_cats_idx WHERE `cat_id` = '%d' AND productId = '%d' LIMIT 1;", $glob['dbprefix'], $_POST['MoveTo'], $product_id); $previous = $db->select($query); if ($previous) { ## Delete old primary category record only, new category already there $query = sprintf("DELETE FROM %sCubeCart_cats_idx WHERE cat_id = '%d' AND productId = '%d'", $glob['dbprefix'], $_POST['current'][$product_id], $product_id ); $db->misc($query); ## Product counted before we dont need it for target category product count unset($_POST['product'][$key]); } else { ## Update secondary categories $query = sprintf("UPDATE %1\$sCubeCart_cats_idx SET cat_id = '%2\$d' WHERE productId = '%3\$d' AND cat_id = '%4\$d' LIMIT 1;", $glob['dbprefix'], $_POST['MoveTo'], $product_id, $_POST['current'][$product_id]); $db->misc($query); } ## Update category product count $db->categoryNos($_POST['current'][$product_id], '-', 1); $db->categoryNos($_POST['MoveTo'], '+', 1); $i++; } $cache = new cache(); $cache->clearCache(); } if(isset($_POST['normPer']) && isset($_POST['salePer'])) { $cache = new cache(); $cache->clearCache(); $sqlUpdateWhere = ""; if(is_array($_POST['cat_id_price'])) { for ($n=0; $n0) { if($n==0) { $sqlUpdateWhere .= " WHERE cat_id = ".$db->mySQLSafe($_POST['cat_id_price'][$n]); } else { $sqlUpdateWhere .= " OR cat_id = ".$db->mySQLSafe($_POST['cat_id_price'][$n]); } } } } if(is_numeric($_POST['normPer'])) { if($_POST['normPerMethod']=="percent" && $_POST['normPer']>0) { $sum = " * ".($_POST['normPer']/100); } elseif($_POST['normPerMethod']=="value" && $_POST['normPer']<0) { $sum = $_POST['normPer']; } elseif($_POST['normPerMethod']=="value") { $sum = " + ".$_POST['normPer']; } $query = "UPDATE ".$glob['dbprefix']."CubeCart_inventory SET `price` = `price` ".$sum.$sqlUpdateWhere; $result = $db->misc($query); } if (is_numeric($_POST['salePer'])) { if ($_POST['salePerMethod']=="percent" && $_POST['normPer']>0) { $sum = " * ".($_POST['salePer']/100); } else if ($_POST['salePerMethod']=="value" && $_POST['salePer']<0) { $sum = $_POST['salePer']; } else if ($_POST['salePerMethod']=="value") { $sum = " + ".$_POST['salePer']; } $query = "UPDATE ".$glob['dbprefix']."CubeCart_inventory SET `sale_price` = `sale_price` ".$sum.$sqlUpdateWhere; $result = $db->misc($query); } if ($result) { $msg2 = "

".$lang['admin']['products_price_upd_successful']."

"; } else { $msg2 = "

".$lang['admin']['products_price_upd_fail']."

"; } } else if (isset($_GET['delete']) && $_GET["delete"]>0) { $cache = new cache(); $cache->clearCache(); // delete product $where = "productId=".$db->mySQLSafe($_GET["delete"]); $delete = $db->delete($glob['dbprefix']."CubeCart_inventory", $where); // set categories -1 $cats = $db->select("SELECT cat_id FROM ".$glob['dbprefix']."CubeCart_cats_idx WHERE productId=".$db->mySQLSafe($_GET["delete"])); if ($cats == true) { for ($i=0;$icategoryNos($cats[$i]['cat_id'], "-"); } } // delete category index $where = "productId=".$db->mySQLSafe($_GET["delete"]); $deleteIdx = $db->delete($glob['dbprefix']."CubeCart_cats_idx", $where); unset($record); // delete product options $record['product'] = $db->mySQLSafe($_GET["delete"]); $where = "product=".$db->mySQLSafe($_GET["delete"]); $deleteOps = $db->delete($glob['dbprefix']."CubeCart_options_bot", $where); unset($record); if ($delete == true) { $msg = "

".$lang['admin']['products_delete_success']."

"; } else { $msg = "

".$lang['admin']['products_delete_fail']."

"; } } else if (isset($_POST['productId'])) { $cache = new cache(); $cache->clearCache(); $allowedFields = $db->getFields($glob['dbprefix'].'CubeCart_inventory'); foreach ($_POST as $name => $value) { if (in_array($name, $allowedFields) && (!empty($value) || $value == '0')) { $record[$name] = $db->mySQLSafe($value); } } ## Custom field translation $record['image'] = $db->mySQLSafe(imgPath($_POST['imageName'], false, '')); $record['tax_inclusive'] = ($_POST['tax_inclusive'] == 1) ? '1' : '0'; $record['cat_id'] = $db->mySQLSafe($_POST['cat_id']); $description = (detectSSL() && !$config['force_ssl'] && $config['rootRel'] != CC_DS) ? str_replace($config['rootRel_SSL'], $glob['rootRel'], $_POST['FCKeditor']) : $_POST['FCKeditor']; $record['description'] = (!empty($description)) ? $db->mySQLSafe($description) : 'NULL'; ## Generate product code if (empty($_POST['productCode'])) { $chars = array("A","B","C","D","E","F","G","H","I","J","K","L","M","N", "O","P","Q","R","S","T","U","V","W","X","Y","Z","1","2","3", "4","5","6","7","8","9","0"); $max_chars = count($chars) - 1; srand((double)microtime()*1000000); for ($i = 0; $i < 5; $i++) { $randChars = ($i == 0) ? $chars[rand(0, $max_chars)] : $randnum . $chars[rand(0, $max_chars)]; } $record["productCode"] = $db->mySQLSafe(strtoupper(substr($_POST['name'],0,3)).$randChars.$_POST['cat_id']); } else { $record["productCode"] = $db->mySQLSafe($_POST['productCode']); } // if image is a JPG check thumbnail doesn't exist and if not make one /* $imageFormat = strtoupper(ereg_replace(".*\.(.*)$","\\1",$_POST['imageName'])); if($imageFormat == "JPG" || $imageFormat == "JPEG" || $imageFormat == "PNG" || ($imageFormat == "GIF" && $config['gdGifSupport']==1)) { $rootThumbFile = imgPath($_POST['imageName'],$thumb=1,$path="root"); $rootMasterFile = imgPath($_POST['imageName'],$thumb=0,$path="root"); if(file_exists($rootThumbFile)) { @unlink($rootThumbFile); } $img = new gd($rootMasterFile); $img->size_auto($config['gdthumbSize']); $img->save($rootThumbFile); } */ if (isset($_POST['productId']) && $_POST['productId']>0) { $where = "productId=".$db->mySQLSafe($_POST['productId']); $update = $db->update($glob['dbprefix']."CubeCart_inventory", $record, $where); unset($record, $where); // update category count if($_POST['oldCatId']!==$_POST['cat_id']) { // set old category -1 IF IT WAS IN THERE BEFORE $numOldCat = $db->numrows("SELECT * FROM ".$glob['dbprefix']."CubeCart_cats_idx WHERE cat_id = ".$db->mySQLSafe($_POST['oldCatId'])." AND productId = ".$db->mySQLSafe($_POST['productId'])); if($numOldCat>0){ $db->categoryNos($_POST['oldCatId'], "-"); } // set new category +1 IF IT WAS NOT IN THERE BEFORE $numNewCat = $db->numrows("SELECT * FROM ".$glob['dbprefix']."CubeCart_cats_idx WHERE cat_id = ".$db->mySQLSafe($_POST['cat_id'])." AND productId = ".$db->mySQLSafe($_POST['productId'])); if($numNewCat == 0) { $db->categoryNos($_POST['cat_id'], "+"); } // delete old idx $where = "productId = ".$db->mySQLSafe($_POST['productId'])." AND cat_id = ".$db->mySQLSafe($_POST['oldCatId']); $deleteIdx = $db->delete($glob['dbprefix']."CubeCart_cats_idx", $where); unset($record); // delete new index if it was added as an extra before $where = "productId = ".$db->mySQLSafe($_POST['productId'])." AND cat_id = ".$db->mySQLSafe($_POST['cat_id']); $deleteIdx = $db->delete($glob['dbprefix']."CubeCart_cats_idx", $where); unset($record); // add new idx $record['productId'] = $db->mySQLSafe($_POST['productId']); $record['cat_id'] = $db->mySQLSafe($_POST['cat_id']); $insertIdx = $db->insert($glob['dbprefix']."CubeCart_cats_idx", $record); unset($record); } if ($update == TRUE) { $msg = "

'".$_POST['name']."' ".$lang['admin']['products_update_successful']."

"; } else { $msg = "

".$lang['admin']['products_update_fail']."

"; } } else { $insert = $db->insert($glob['dbprefix']."CubeCart_inventory", $record); unset($record); $record['cat_id'] = $db->mySQLSafe($_POST['cat_id']); $record['productId'] = $db->insertid(); $insertIdx = $db->insert($glob['dbprefix']."CubeCart_cats_idx", $record); unset($record); if($insert == TRUE) { $msg = "

'".$_POST['name']."' ".$lang['admin']['products_add_success']."

"; // notch up amount of products in category $db->categoryNos($_POST['cat_id'], "+"); } else { $msg = "

".$lang['admin']['products_add_fail']."

"; } } } if (!isset($_GET['mode'])) { ## Build the SQL Query if (isset($_GET['edit']) && $_GET['edit']>0) { $query = sprintf("SELECT * FROM ".$glob['dbprefix']."CubeCart_inventory WHERE productId = %s", $db->mySQLSafe($_GET['edit'])); } else { if (isset($_GET['orderCol']) && isset($_GET['orderDir'])) { $orderBy = "I.".$_GET['orderCol']." ".$_GET['orderDir']; } else { $orderBy = "I.productId ASC"; } $whereClause = ''; if (isset($_GET['searchStr']) && !empty($_GET['searchStr'])) { $searchwords = split ( "[ ,]", $_GET['searchStr']); foreach ($searchwords as $word) { $searchArray[]=$word; } $noKeys = count($searchArray); for ($i=0; $i<$noKeys;$i++) { $ucSearchTerm = strtoupper($searchArray[$i]); if (($ucSearchTerm !== "AND") && ($ucSearchTerm !== "OR")) { $like .= "(I.name LIKE '%".$searchArray[$i]."%' OR I.description LIKE '%".$searchArray[$i]."%' OR I.productCode LIKE '%".$searchArray[$i]."%') OR "; } else { $like = substr($like,0,strlen($like)-3); $like .= $ucSearchTerm; } } $like = substr($like,0,strlen($like)-3); $whereClause .= "WHERE ".$like; } if (isset($_GET['category']) && $_GET['category']>0) { $whereClause .= (isset($like)) ? ' AND ' : ' WHERE '; $whereClause .= "I.cat_id = ".$_GET['category']; } $query = "SELECT * FROM ".$glob['dbprefix']."CubeCart_inventory AS I INNER JOIN ".$glob['dbprefix']."CubeCart_category AS C ON I.cat_id = C.cat_id ".$whereClause." ORDER BY ".$orderBy; } // query database $page = (isset($_GET['page'])) ? $_GET['page'] : 0; $results = $db->select($query, $productsPerPage, $page); $numrows = $db->numrows($query); $pagination = paginate($numrows, $productsPerPage, $page, "page", "txtLink", 7, array('delete')); } $query = "SELECT cat_id, cat_name, cat_father_id, cat_desc FROM ".$glob['dbprefix']."CubeCart_category ORDER BY cat_id ASC"; $categoryArray = $db->select($query); require($glob['adminFolder'].CC_DS."includes".CC_DS."header.inc.php"); ?>
href="?_g=products/index&mode=new" class="txtLink" >

 

onclick="openPopUp('?_g=products/extraCats&productId=&cat_id=&cat_father_id=&cat_name=&name=','extraCats',500,450,1);" class="txtLink">
<?php echo $results[$i]['name']; ?>
href="?_g=products/index&edit=" class="txtLink"> href="?_g=products/index&delete=&cat_id=" onclick="return confirm('')" class="txtLink"> href="?_g=products/languages&prod_master_id=" class="txtLink">
 



0) { if(isset($_GET["edit"]) && $_GET["edit"]>0){ $modeTxt = $lang['admin_common']['edit']; } else { $modeTxt = $lang['admin_common']['add']; } ?>

0){ echo $modeTxt; } else { echo $modeTxt; } echo " ".$lang['admin']['products_product'];?>

 
BasePath = $GLOBALS['rootRel'].$glob['adminFolder'].'/includes/rte/' ; $oFCKeditor->Value = (isset($results[0]['description'])) ? $results[0]['description'] : ''; if (!$config['richTextEditor']) $oFCKeditor->off = true; $oFCKeditor->Create(); ?>


/>


/> />
/> /> class="hiddenTextbox" />
  " />

  " />