setStatus($id, $status); } if ($task == 'set-cat-order') { $categories = new Products_Categories(); if(isset($_POST['catrow'])) $categories->setCategoriesOrder($_POST['catrow']); } if ($task == 'addlevel') { $cat_id = Tools_Http::Post('cat_id'); $start = Tools_Http::Post('start'); $end = Tools_Http::Post('end'); if($cat_id) { $sql='INSERT INTO pricelevels (cat_id,start,end) VALUES ("'.$_POST['cat_id'].'","'.$_POST['start'].'","'.$_POST['end'].'") '; $res=$DB->Exec($sql); echo mysql_insert_id(); } } if ($task == 'removelevel') { $value = Tools_Http::Post('value'); $sql='DELETE FROM pricelevels WHERE level_id="'.$_POST['value'].'"'; $res=$DB->Exec($sql); if($res) echo $res; } if ($task=='addCar') { $title = $DB->Escape(Tools_Http::Post('title')); $id = Tools_Http::Post('catid',true); if (!$title) { array_push($errors,'title'); $err_msg = $L->Str('Ievadiet markas nosaukumu!'); } $pic = $_FILES['imgfile']; $pic_file=''; if ($pic['name'] && !sizeof($errors)) { $hash = Tools_Text::getRandomHash(); $thumb_file = $hash.'.jpg'; $dest = WEBPATH.'images/cars/'; $upload = Tools_Filesystem::uploadFile ('imgfile', $dest, $thumb_file); if (!$upload) { array_push($errors,'pic'); $err_msg = $L->Str('Neizdevās ielādēt bildi.'); } else { if (getimagesize($dest.$thumb_file)) { Tools_Image:: imageResize ($dest.$thumb_file,$dest.$thumb_file,90,90,true,100); chmod($dest.$thumb_file,0777); if ($id) { $cat_data = $DB -> getRow('goods_cars',$id); if ($cat_data['icon']) { unlink($dest.$cat_data['icon']); } $DB->Exec("UPDATE goods_cars SET icon = '".$thumb_file."' WHERE id = ".$id); } $pic_file = $thumb_file; } else { unlink ($dest.$thumb_file); array_push($errors, 'imgilfe'); $err_msg = $L->Str('Ielādētais fails nav bilde!'); } } } if (!sizeof($errors)) { $sql = ($id ? "UPDATE":"INSERT INTO")." goods_cars SET title = '".$title."' ".($id?" WHERE id = ".$id:", icon='".$pic_file."'"); $DB -> Exec($sql); //echo 'OK|'.$L->Str('Marka pievienota.').'|document.location.href=document.location.href;window.opener.document.location.href=window.opener.document.location.href;'; ?> Escape(Tools_Http::Post('update_value')); $log = new Common_Logs; $products = new Products(); if ($field == 'price' || $field == 'price_2' || $field == 'price_old' || $field == 'stock' ) { $value = Tools_Common::formatPrice($value); $array[$field]=$value; $compare_fields = $products ->compareProduct($id,$array); foreach($compare_fields as $f) $log->addLog($id ,'goods_'.$f['field'],$f['new_data'],$f['saved_data']); $sql= "UPDATE goods SET ".$field." = '".$value."' WHERE id = ".$id; } if($field == 'price_purchase' && $Admin->IsRoot()) { $array[$field]=$value; $compare_fields = $products ->compareProduct($id,$array); foreach($compare_fields as $f) $log->addLog($id ,'goods_'.$f['field'],$f['new_data'],$f['saved_data']); $value = Tools_Common::formatPrice($value); $sql= "UPDATE goods SET ".$field." = '".$value."' WHERE id = ".$id; } if($field == 'title') { $sql = 'UPDATE languages_texts SET translation="'.$value.'" WHERE objectid='.$id.' AND col="title" AND type="goods" AND lang="'.$L->getCurrentLanguage().'" '; if($L->getCurrentLanguage()=='ru') $DB->Exec("UPDATE goods SET ".$field." = '".$value."' WHERE id = ".$id); } $DB->Exec($sql); if($field == 'title') $L->generateLanguageFiles(); echo $value; } if ($task == 'toggle-cat') { $id = Tools_Http::Post('id',true); $state = Tools_Http::Post('state'); $state = $state == 'true' ? 'active' : 'hidden'; $categories = new Products_Categories(); $categories -> setStatus ($id, $state); } if ($task == 'set-field') { $id = Tools_Http::Post('id',true); $field = Tools_Http::Post('field'); $value = $DB->Escape(Tools_Http::Post('value')); $sql = "UPDATE goods SET ".$field." = '".$value."' WHERE id = ".$id; $DB -> Exec($sql); } if ($task == 'addProduct') { $title = $_POST['title']; $title2 = isset($_POST['title2']) ? $_POST['title2'] : array(); $descr = $_POST['descr']; $code = $DB->Escape(Tools_Http::Post('code')); $product_id = Tools_Http::Post('itemid', true); $tag_id = Tools_Http::Post('tag_id', true); $catid = Tools_Http::Post('catid', true); $catid2 = Tools_Http::Post('catid2', true); $catid3 = Tools_Http::Post('catid3', true); $catid4 = Tools_Http::Post('catid4', true); $catid5 = Tools_Http::Post('catid5', true); $catid6 = Tools_Http::Post('catid6', true); $status = Tools_Http::Post('status'); $ean = Tools_Http::Post('ean'); $sale = Tools_Http::Post('sale', true); $new = Tools_Http::Post('new', true); $clearance = Tools_Http::Post('clearance', true); $stock = Tools_Http::Post('stock', true); $car = Tools_Http::Post('car', true); $price = floatval(Tools_Http::Post('price')); $price_2 = floatval(Tools_Http::Post('price_2')); $price_old = floatval(Tools_Http::Post('price_old')); $price_purchase = floatval(Tools_Http::Post('price_purchase')); $pricelevels=isset($_POST['pricelevel']) ? $_POST['pricelevel'] : array(); $power=floatval($_POST['power']); $free_shipping = Tools_Http::Post('free_shipping', true); $measure=(int) $_POST['measure']; /* if (!$title) { array_push($errors,'title'); $err_msg = $L->Str('Ievadiet produkta nosaukumu!'); } */ if (!$catid) { array_push($errors,'catid'); $err_msg = $L->Str('Izvēlieties kategoriju!'); } if (sizeof($errors)) { ?> compareProduct($product_id,$_POST); $log = new Common_Logs; foreach($compare_fields as $field) $log->addLog($product_id,'goods_'.$field['field'],$field['new_data'],$field['saved_data']); $result = $products -> editItem ($ean,$tag_id,$free_shipping, $title,$title2, $descr, $catid,$catid2,$catid3,$catid4,$catid5,$catid6,$power, $code, $status, $sale, $new,$clearance, $price,$price_2,$price_old,$price_purchase,$measure, $stock,$car, $product_id,$pricelevels); if(!$product_id && $result) $log->addLog($result,'goods_new'); $seo = new Seo(); foreach($_POST['seo'] as $key =>$value) { $seo->addSeoMetadata('product',$result,$key,$value,$_POST['seokey'][$key]); } ?> Escape(Tools_Http::Post('title')); $group_id = Tools_Http::Post('group_id',true); if (!$title) { array_push($errors, 'title'); $err_msg = $L->Str('Ievadiet nosaukumu!'); } if (empty($errors)) { if ($group_id) { $DB -> Exec("UPDATE properties_groups SET title = '".$title."' WHERE id = ".$group_id); $id - $group_id; } else { $DB -> Exec("INSERT INTO properties_groups SET title = '".$title."' "); $id = $DB->lastId(); } $L->addText ('properties_groups', 'title', $id); echo 'OK|'.$L->Str('Dati saglabāti').'|reloadPage(); window.opener.reloadPage();'; } } if ($task == 'addTag') { $tags = new Products_Tags(); $id = Tools_Http::Post('id', true); $array = $_POST; $pic = $_FILES['imgfile']; if ($pic['name']) { $ext = explode('.',$pic['name']); $hash = Tools_Text::getRandomHash(20); $thumb_file = $hash.'.'.array_pop($ext); $dest = WEBPATH.'images/tags/'; if($id) $tag_data = $tags->getItem($id); $upload = Tools_Filesystem::uploadFile ('imgfile', $dest, $thumb_file); if (!$upload) { array_push($errors,'pic'); $err_msg = $L->Str('Neizdevās ielādēt bildi.'); } else { if (getimagesize($dest.$thumb_file)) { //Tools_Image:: imageResize ($dest.$thumb_file,$dest.$thumb_file,170,120,true,100); chmod($dest.$thumb_file,0777); if ($id) { if ($tag_data['image']) { unlink($dest.$tag_data['image']); } $DB->Exec("UPDATE goods_tags SET image = '".$thumb_file."' WHERE id = ".$id); } $pic_file = $thumb_file; } else { unlink ($dest.$thumb_file); array_push($errors, 'imgilfe'); $err_msg = $L->Str('Ielādētais fails nav bilde!'); } } } if (sizeof($errors)) { ?> editItem($id,$array,$thumb_file); ?> addProductLabel($id,$label); elseif($action=='remove') $result = $labels->delProductLabel($id,$label); echo $result; } if ($task == 'addLabel') { $tags = new Products_Labels(); $id = Tools_Http::Post('id', true); $array = $_POST; if (sizeof($errors)) { ?> editItem($id,$array); ?> Escape(Tools_Http::Post('sef')); $catid = Tools_Http::Post('catid', true); $parentid = Tools_Http::Post('parentid', true); $parentid2 = Tools_Http::Post('parentid2', true); $parentid3 = Tools_Http::Post('parentid3', true); $groupid = Tools_Http::Post('groupid', true); $car = Tools_Http::Post('car', true); $pic = $_FILES['imgfile']; $start = isset($_POST['start']) ? $_POST['start'] : 0; $end = isset($_POST['end']) ? $_POST['end'] : 0; $level_id = isset($_POST['level_id']) ? $_POST['level_id'] : 0; $sef = strtolower($sef ? $sef : Tools_Text::cleanString($title['ru'])); /* if (!$title) { array_push($errors,'title'); $err_msg = $L->Str('Ievadiet kategorijas nosaukumu!'); } */ $sef_check = $DB -> GetRow('goods_categories', $sef, 'sef'); if (!empty($sef_check)) { if ($sef_check['id'] != $catid) { array_push($errors,'sef'); $err_msg = $L->Str('Kategorija ar šādu nosaukumu jau eksistē!'); } } if ($pic['name'] && !sizeof($errors)) { if ($catid) { $GoodsCategories = new Products_Categories(); $cat_data = $GoodsCategories -> getItem($catid); $i_title = $cat_data['title']; } else { $i_title = $title; } $hash = strtolower(Tools_Text :: cleanString ($i_title).'_'.substr(Tools_Text::getRandomHash(), 0, 5)); $thumb_file = $hash.'.jpg'; $dest = WEBPATH.'images/category/'; $upload = Tools_Filesystem::uploadFile ('imgfile', $dest, $thumb_file); if (!$upload) { array_push($errors,'pic'); $err_msg = $L->Str('Neizdevās ielādēt bildi.'); } else { if (getimagesize($dest.$thumb_file)) { //Tools_Image:: imageResize ($dest.$thumb_file,$dest.$thumb_file,170,120,true,100); chmod($dest.$thumb_file,0777); if ($catid) { if ($cat_data['image']) { unlink($dest.$cat_data['image']); } echo 'Thumb'.$thumb_file; $DB->Exec("UPDATE goods_categories SET image = '".$thumb_file."' WHERE id = ".$catid); } $pic_file = $thumb_file; } else { unlink ($dest.$thumb_file); array_push($errors, 'imgilfe'); $err_msg = $L->Str('Ielādētais fails nav bilde!'); } } } if (sizeof($errors)) { ?> editCategory($title,$seo_description, $sef, $parentid,$parentid2,$parentid3,$groupid,$pic_file, $catid,$start,$end,$level_id); $seo = new Seo(); foreach($_POST['seo'] as $key =>$value) { $seo->addSeoMetadata('category',$result,$key,$value,$_POST['seokey'][$key]); } ?>