/**
  * adds it to $this->notSatisfied if it does not match
  * 
  * @param  Specification $specification 
  * @param  mixed         $object   
  * @param  array         &[$notSatisfied] (optional) array to contain the not satisfiedBy @array<Specification)
  * @return void
  */
 protected function appendIfNotSatisfiedBy($specification, $object, array &$notSatisfied = [])
 {
     if (!$specification->isSatisfiedBy($object)) {
         if ($specification instanceof AbstractCombinationSpecification) {
             $notSatisfied = array_merge($notSatisfied, $specification->getSpecificationsNotSatisfiedBy($object));
         } else {
             $notSatisfied[] = $specification;
         }
     }
 }
 private function createCriteria($filter)
 {
     $this->loadClass("specification", null, "libraries");
     $specification = new Specification();
     $criteria = null;
     if (!is_null($filter["username"]) && $filter["username"] != "") {
         $criteria = $specification->equalSpecification("username", $filter["username"]);
     }
     return $criteria;
 }
Exemple #3
0
 function testIsSameSpec()
 {
     $sp1 = new Specification("simple_spec/test", "1.0");
     $sp2 = new Specification("simple_spec/world", "");
     $sp3 = new Specification("simple_spec/test", "2");
     $this->assertTrue($sp1->is_same_spec($sp3), "Le specifiche non corrispondono!!");
     $this->assertTrue($sp2->is_same_spec($sp2), "Le specifiche non corrispondono!!");
     $this->assertTrue($sp1->is_same_spec($sp1), "Le specifiche non corrispondono!!");
     $this->assertFalse($sp1->is_same_spec($sp2), "Le specifiche corrispondono!!");
 }
 public static function inSpecificationSQL($field, $value)
 {
     if ($value == null) {
         return "";
     }
     if (is_array($value)) {
         $values = '';
         foreach ($value as $row) {
             if ($values == '') {
                 $values = Specification::formatValueToSQL($row);
             } else {
                 $values = $values . ',' . Specification::formatValueToSQL($row);
             }
         }
         return "({$field} in ({$values}))";
     } else {
         return Specification::equalSpecificationSQL($field, $value);
     }
 }
Exemple #5
0
<?php

if (!_acl::isAllow('catalog')) {
    die("Access denied");
}
$dbtree = new dbtree(_DB_PREFIX_ . 'category', 'category', $db);
$specification = new Specification();
$user = new Users();
$specification->Setlist();
$tpl->Assign('spec_list', $specification->list);
unset($parsed_res);
if (isset($GLOBALS['REQAR'][1]) && is_numeric($GLOBALS['REQAR'][1])) {
    $id_category = $GLOBALS['REQAR'][1];
}
//else{
//	if(isset($_GET['upload'])){
//		$img_upload = array();
//		$img_upload = array(
//			'download_via_php' => true,
//			'upload_dir' => $_SERVER['DOCUMENT_ROOT'].'/images/category_banner/',
//			'upload_url' => $_SERVER['DOCUMENT_ROOT'].'/images/category_banner/',
//			'user_dirs' => false,
//			'param_name' => 'img',
//			'accept_file_types' => '/\.(gif|jpe?g|jpg|png)$/i'
//		);
//		if(isset($_GET['category_img_urls'])){
//			$arr = $dbtree->Full(array('translit'), array('and' => array('id_category = '.$_POST['id_category'])));
//			$img_name = $arr[0]['translit'];
//			$_FILES['img']['name'] = $img_name;
//			$img_upload['upload_dir'] = $_SERVER['DOCUMENT_ROOT'].'/efiles/katalog/';
//			$img_upload['upload_url'] = $_SERVER['DOCUMENT_ROOT'].'/efiles/katalog/';
Exemple #6
0
 /**
  * Add an input' specification to the set of specifications.
  * @param Specification $inSpecification Input's specification to add.
  * @return $this
  */
 public function addInputSpecification(Specification $inSpecification)
 {
     $this->__inputsSpecifications[$inSpecification->getName()] = $inSpecification;
     return $this;
 }
 function getSQL()
 {
     return Specification::greaterThanSQL($this->field_name, $this->field_value);
 }
 /**
  * @param mixed $object
  * @return bool
  */
 public function isSatisfiedBy($object)
 {
     return !$this->specification->isSatisfiedBy($object);
 }
 /**
  * {@inheritdoc}
  */
 public function isSatisfiedBy($candidate)
 {
     return $this->one->isSatisfiedBy($candidate) || $this->other->isSatisfiedBy($candidate);
 }
Exemple #10
0
<?php

if ($_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest') {
    $Specification = new Specification();
    if (isset($_POST['action'])) {
        switch ($_POST['action']) {
            case "getProdlistModeration":
                $arr = $Specification->GetProdlistModeration($_POST['id_category'], $_POST['specification'], $_POST['value']);
                foreach ($arr as $k => $value) {
                    $value['id_prod'];
                    $value['name'];
                    echo "<li><a target='_blank' href='/adm/productedit/" . $value['id_prod'] . "'>" . ($k + 1) . " - " . $value['name'] . "</a></li>";
                }
                break;
            case 'changeSpecificationValue':
                if ($Specification->UpdateSpecsValueMonitoring($_POST)) {
                    echo "ok";
                } else {
                    echo "error";
                }
                break;
            default:
                break;
        }
        exit;
    }
}
Exemple #11
0
 /**
  * [DuplicateProduct description]
  * @param [type] $data [description]
  */
 public function DuplicateProduct($data)
 {
     // creating new article
     $art = $this->CheckArticle((int) $this->GetLastArticle());
     // duplicating main product information & category
     $this->SetFieldsById($data['id_product']);
     $old_product_info = $this->fields;
     $old_product_info['art'] = $art;
     // $old_product_info['dupl_idproduct'] = $data['id_product'];
     $old_product_info['name'] .= ' ' . $art;
     if (!($id_product = $this->AddProduct($old_product_info))) {
         return false;
     }
     // duplicating product assortment
     $sql = "SELECT * FROM " . _DB_PREFIX_ . "assortiment AS a\n\t\t\tWHERE a.id_product = " . $data['id_product'];
     $res = $this->db->GetArray($sql);
     if (!empty($res)) {
         foreach ($res as &$value) {
             $value['id_product'] = $id_product;
             $this->AddToAssortWithAdm($value);
         }
     }
     // duplicating product specifications
     $sql = "SELECT * FROM " . _DB_PREFIX_ . "specs_prods as s\n\t\t\tWHERE s.id_prod = " . $data['id_product'];
     $res = $this->db->GetArray($sql);
     if (!empty($res)) {
         $specifications = new Specification();
         foreach ($res as $value) {
             $specifications->AddSpecToProd($value, $id_product);
         }
     }
     // duplicating product segmentation
     $sql = "SElECT * FROM " . _DB_PREFIX_ . "segment_prods AS sp\n\t\tWHERE sp.id_product = " . $data['id_product'];
     $res = $this->db->GetArray($sql);
     if (!empty($res)) {
         $segmentation = new Segmentation();
         foreach ($res as $value) {
             $segmentation->AddSegmentInProduct($id_product, $value['id_segment']);
         }
     }
     // duplicating product videos
     $res = $this->GetVideoById($data['id_product']);
     if (!empty($res)) {
         $this->UpdateVideo($id_product, $res);
     }
     // duplicating product images
     $res = $this->GetPhotoById($data['id_product']);
     foreach ($res as &$value) {
         $value = $value['src'];
     }
     if (!empty($res)) {
         $this->UpdatePhoto($id_product, $res);
     }
     return $id_product;
 }
 /**
  * 类型添加
  */
 public function actionCreate()
 {
     if ($_POST) {
         $GoodsType = new GoodsType();
         $GoodsType->attributes = $this->post('Type');
         $type_brand_attributes = $this->post('TypeBrand');
         //商品类型主表修改
         $result = $GoodsType->save();
         if (!$result) {
             $GoodsType = new GoodsType();
             $this->message('error', CHtml::errorSummary($GoodsType), $this->createUrl('index'));
         }
         $type_id = Yii::app()->db->getLastInsertID();
         //类型-品牌
         if ($type_brand_attributes) {
             $TypeBrand = new TypeBrand();
             $result = $TypeBrand->brand_type_update($type_id, $type_brand_attributes);
             if (!$result) {
                 $this->message('error', CHtml::errorSummary($TypeBrand), $this->createUrl('index'));
             }
         }
         //类型-扩展属性
         $type_props_attributes = $this->post('TypeProps');
         if (isset($type_props_attributes['props_id']) && $type_props_attributes['props_id']) {
             $GoodsTypePropsRelation = new GoodsTypePropsRelation();
             $result = $GoodsTypePropsRelation->props_update($type_id, $type_props_attributes['props_id']);
             if (!$result) {
                 $this->message('error', CHtml::errorSummary($GoodsTypePropsRelation), $this->createUrl('index'));
             }
         }
         //类型-规格
         $type_props_spec = $this->post('Spec');
         if (isset($type_props_spec['spec_id']) && $type_props_spec['spec_id']) {
             $GoodsTypeSpec = new GoodsTypeSpec();
             $result = $GoodsTypeSpec->spec_update($type_id, $type_props_spec['spec_id']);
             if (!$result) {
                 $this->message('error', CHtml::errorSummary($GoodsTypeSpec), $this->createUrl('index'));
             }
         }
         $this->message('success', '创建成功', $this->createUrl('index'));
     }
     //品牌列表
     $model['brand_list'] = Brand::model()->findAll('disabled = :disabled', array(':disabled' => 'false'));
     //规格
     $model['spec_list'] = Specification::model()->findAll('disabled = :disabled', array(':disabled' => 'false'));
     $this->render('create', array('model' => $model));
 }
 function getSQL()
 {
     return Specification::betweenFullDateSQL($this->field_name, $this->value1, $this->value2);
 }
 /**
  * @param mixed $object
  * @return bool
  */
 public function isSatisfiedBy($object)
 {
     return $this->one->isSatisfiedBy($object) && $this->other->isSatisfiedBy($object);
 }
Exemple #15
0
 /**
  * {inheritdoc}
  */
 public function isSatisfiedBy($candidate)
 {
     return $this->firstPart->isSatisfiedBy($candidate) || $this->secondPart->isSatisfiedBy($candidate);
 }
Exemple #16
0
 /**
  * 
  * can be 0+, just duplicate to return a single one that is not an array and rename this `findAllSatisfying`
  * @return array<Object|empty>
  * 
  */
 public function findSatisfying(Specification $specification)
 {
     $data = $this->findAll();
     $result = array();
     foreach ($data as $object) {
         if ($specification->isSatisfiedBy($object)) {
             $result[] = $object;
         }
     }
     return $result;
 }
Exemple #17
0
<?php

// if(!_acl::isAllow('monitoring')){
// 	die("Access denied");
// }
unset($parsed_res);
$ii = count($GLOBALS['IERA_LINKS']);
$GLOBALS['IERA_LINKS'][$ii]['title'] = "Мониторинг";
$tpl->Assign('h1', $GLOBALS['IERA_LINKS'][$ii]['title']);
$Products = new Products();
if (isset($GLOBALS['REQAR'][1])) {
    switch ($GLOBALS['REQAR'][1]) {
        case 'specifications':
            $ii = count($GLOBALS['IERA_LINKS']);
            $GLOBALS['IERA_LINKS'][$ii]['title'] = "Характеристики";
            $specification = new Specification();
            // получить список категорий
            $res = $specification->GetSpecsForCats();
            // die();
            foreach ($res as $value) {
                $cat_spec[$value['id_cat']]['name'] = $value['name'];
                $cat_spec[$value['id_cat']]['specs'][$value['id_spec']] = $value['caption'];
            }
            // список категории и характеристик для выпадающего списка фильтров
            $tpl->Assign('cat_spec', $cat_spec);
            if (isset($_GET['smb'])) {
                if (isset($_GET['id_category']) && $_GET['id_category'] !== '0') {
                    $where['id_category'] = $_GET['id_category'];
                }
                if (isset($_GET['id_caption']) && $_GET['id_caption'] !== '0') {
                    $where['id_caption'] = $_GET['id_caption'];
 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  * @param integer $id the ID of the model to be loaded
  * @return Specification the loaded model
  * @throws CHttpException
  */
 public function loadModel($id)
 {
     $model = Specification::model()->findByPk($id);
     // if($model===null)
     // 	throw new CHttpException(404,'The requested page does not exist.');
     return $model;
 }
 /**
  * 规格删除
  */
 public function actionDelete()
 {
     $spec_id = $this->get('spec_id');
     $result = Specification::model()->deleteAll('spec_id = :spec_id', array(':spec_id' => $spec_id));
     if (!$result) {
         $Specification = new Specification();
         $this->message('error', CHtml::errorSummary($Specification), $this->createUrl('index'));
     }
     $result = SpecValues::model()->deleteAll('spec_id = :spec_id', array(':spec_id' => $spec_id));
     if ($result) {
         $this->message('success', '删除成功', $this->createUrl('index'));
     } else {
         $SpecValues = new SpecValues();
         $this->message('error', CHtml::errorSummary($SpecValues), $this->createUrl('index'));
     }
 }
Exemple #20
0
 /**
  * {inheritdoc}
  */
 public function isSatisfiedBy($candidate)
 {
     return !$this->wrappedSpecification->isSatisfiedBy($candidate);
 }
 function getSQL()
 {
     return Specification::isnotnullSpecificationSQL($this->field_name);
 }
 function getSQL()
 {
     return Specification::containSQL($this->field_name, $this->field_value);
 }
 function getSQL()
 {
     return Specification::endWithSQL($this->field_name, $this->field_value);
 }
Exemple #24
0
 public function parseUrl($url)
 {
     $Products = new Products();
     $Specification = new Specification();
     $Images = new Images();
     $product = array();
     $html = file_get_html($url);
     if (!$html) {
         return false;
     }
     // Название товара
     $product['name'] = $html->find('[itemprop="name"]', 0)->plaintext;
     if (!$product['name']) {
         return false;
     }
     // if($Products->SetFieldsByRewrite(G::StrToTrans($product['name']))){
     // 	return false;
     // }
     // Описание товара
     $product['descr'] = $html->find('[itemprop="description"]', 0)->plaintext;
     // Указываем базовую активность товара
     $product['active'] = 1;
     // Получаем цену товара
     $product['price_opt_otpusk'] = $product['price_mopt_otpusk'] = $html->find('[itemprop="price"]', 0)->innertext;
     // Находим характеристики товара
     foreach ($html->find('.stats tr') as $element) {
         $caption = trim($element->find('.name span', 0)->innertext);
         if ($caption == 'Артикул') {
             $sup_comment = trim($element->children(1)->plaintext);
         } elseif ($caption !== '' && !in_array($caption, array('Доставка', 'Самовывоз', 'Гарантия'))) {
             $value = trim($element->children(1)->plaintext);
             $spec = $Specification->SpecExistsByCaption($caption);
             $product['specs'][] = array('id_spec' => $spec ? $spec['id'] : $Specification->Add(array('caption' => $caption)), 'value' => $value);
         }
     }
     // Выбираем изображения максимального размера
     foreach ($html->find('#photo #elementTableImg img') as $element) {
         $filename = 'http://zona220.com' . str_replace('/500_500_1/', '/', str_replace('/resize_cache/', '/', $element->src));
         $img_info = array_merge(getimagesize($filename), pathinfo($filename));
         $path = $GLOBALS['PATH_product_img'] . 'original/' . date('Y') . '/' . date('m') . '/' . date('d') . '/';
         $Images->checkStructure($path);
         copy($filename, $path . $img_info['basename']);
         $product['images'][] = str_replace($GLOBALS['PATH_global_root'], '/', $path . $img_info['basename']);
         $product['images_visible'][] = 1;
     }
     $html->clear();
     unset($html);
     // Добавляем новый товар в БД
     if ($id_product = $Products->AddProduct($product)) {
         // Добавляем характеристики новому товару
         if (!empty($product['specs'])) {
             foreach ($product['specs'] as $specification) {
                 $Specification->AddSpecToProd($specification, $id_product);
             }
         }
         // Формирем массив записи ассортимента
         $assort = array('id_assortiment' => false, 'id_supplier' => 25392, 'id_product' => $id_product, 'price_opt_otpusk' => $product['price_opt_otpusk'], 'price_mopt_otpusk' => $product['price_mopt_otpusk'], 'active' => 0, 'inusd' => 0, 'sup_comment' => $sup_comment);
         // $assort = array('id_assortiment' => false, 'id_supplier' => 23029, 'id_product' => $id_product, 'price_opt_otpusk' => $product['price_opt_otpusk'], 'price_mopt_otpusk' => $product['price_mopt_otpusk'], 'active' => 0, 'inusd' => 0);
         // Добавляем зпись в ассортимент
         $Products->AddToAssortWithAdm($assort);
         // Получаем артикул нового товара
         $article = $Products->GetArtByID($id_product);
         // Переименовываем фото товара
         $to_resize = $images_arr = array();
         if (isset($product['images'])) {
             foreach ($product['images'] as $k => $image) {
                 $to_resize[] = $newname = $article['art'] . ($k == 0 ? '' : '-' . $k) . '.jpg';
                 $file = pathinfo(str_replace('/' . str_replace($GLOBALS['PATH_global_root'], '', $GLOBALS['PATH_product_img']), '', $image));
                 $path = $GLOBALS['PATH_product_img'] . trim($file['dirname']) . '/';
                 $images_arr[] = str_replace($file['basename'], $newname, $image);
                 rename($path . $file['basename'], $path . $newname);
             }
         }
         //Проверяем ширину и высоту загруженных изображений, и если какой-либо из показателей выше 1000px, уменяьшаем размер
         foreach ($images_arr as $filename) {
             $file = $GLOBALS['PATH_product_img'] . str_replace('/' . str_replace($GLOBALS['PATH_global_root'], '', $GLOBALS['PATH_product_img']), '', $filename);
             $size = getimagesize($file);
             // $size = getimagesize($path.$filename); //Получаем ширину, высоту, тип картинки
             $width = $size[0];
             $height = $size[1];
             if ($size[0] > 1000 || $size[1] > 1000) {
                 $ratio = $size[0] / $size[1];
                 //коэфициент соотношения сторон
                 //Определяем размеры нового изображения
                 if (max($size[0], $size[1]) == $size[0]) {
                     $width = 1000;
                     $height = 1000 / $ratio;
                 } elseif (max($size[0], $size[1]) == $size[1]) {
                     $width = 1000 * $ratio;
                     $height = 1000;
                 }
             }
             $res = imagecreatetruecolor($width, $height);
             imagefill($res, 0, 0, imagecolorallocate($res, 255, 255, 255));
             $src = $size['mime'] == 'image/jpeg' ? imagecreatefromjpeg($file) : imagecreatefrompng($file);
             imagecopyresampled($res, $src, 0, 0, 0, 0, $width, $height, $size[0], $size[1]);
             $stamp = imagecreatefrompng($GLOBALS['PATH_global_root'] . 'images/watermark.png');
             imagecopyresampled($res, $stamp, 10, 10, 0, 0, imagesx($stamp), imagesy($stamp), imagesx($stamp), imagesy($stamp));
             imagejpeg($res, $file);
         }
         $Images->resize(false, $to_resize);
         // Привязываем новые фото к товару в БД
         $Products->UpdatePhoto($id_product, $images_arr, $product['images_visible']);
     }
     return $id_product;
 }
 public function deletespecificationAction()
 {
     global $mySession;
     $db = new Db();
     if ($_REQUEST['Id'] != "") {
         $arrId = explode("|", $_REQUEST['Id']);
         if (count($arrId) > 0) {
             foreach ($arrId as $key => $Id) {
                 if ($Id > 1) {
                     $myObj = new Specification();
                     $Result = $myObj->deleteSpecification($Id);
                 }
             }
         }
     }
     exit;
 }
Exemple #26
0
 /**
  * @param $object
  *
  * @return bool
  */
 public function isSatisfiedBy($object)
 {
     return $this->left->isSatisfiedBy($object) && $this->right->isSatisfiedBy($object);
 }
Exemple #27
0
 /**
  * {@inheritdoc}
  */
 public function isSatisfiedBy($candidate) : bool
 {
     return $this->firstSpec->isSatisfiedBy($candidate) && $this->secondSpec->isSatisfiedBy($candidate);
 }
 function getSQL()
 {
     return Specification::equalSpecificationSQL($this->field_name, $this->field_value);
 }
Exemple #29
0
<?if($_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest'){
	header('Content-Type: text/javascript; charset=utf-8');
	$Products = new Products();
	if(isset($_POST['action']))
		switch($_POST['action']){
			case 'specification_update':
				$Specification = new Specification();
				$Products->UpdateProduct(array('id_product'=>$_POST['id_product']));
				if($_POST['id_spec_prod'] == ''){
					if($Specification->AddSpecToProd($_POST, $_POST['id_product'])){
						echo json_encode('ok');
					}
				}else{
					if($Specification->UpdateSpecsInProducts($_POST)){
						echo json_encode('ok');
					}
				}
				break;
			case 'update_translit':
				echo json_encode($Products->UpdateTranslit($_POST['id_product']));
				break;
			case 'datalist':
				echo json_encode($Products->GetIdOneRowArrayByArt($_POST['article']));
				break;
			case 'datalist_supplier':
				$Supplier = new Suppliers();
				echo json_encode($Supplier->GetIdOneRowArrayByArt($_POST['article']));
				break;
			case 'insert_related':
				echo json_encode($Products->AddRelatedProduct($_POST['id_prod'], $_POST['id_related_prod']));
				break;
Exemple #30
0
 /**
  * {@inheritdoc}
  */
 public function isSatisfiedBy($candidate)
 {
     return !$this->spec->isSatisfiedBy($candidate);
 }