function create() { $this->load->library('form_validation'); $this->form_validation->set_rules('title', 'Name', 'required'); $this->form_validation->set_rules('productcategory', 'Kategorie', 'required'); if ($this->form_validation->run() == TRUE) { $product = new Product(); $productcategory = new Productcategory(); $productcategory->get_by_id($this->input->post('productcategory')); $product->title = $this->input->post('title'); $product->save($productcategory); redirect('products'); } else { $productcategory = new Productcategory(); $this->template->set('productcategories', $productcategory->get()); $this->template->set('page_name', 'Produkt erstellen'); $this->template->current_view = 'content/products/create'; $this->template->render(); } }
function __construct() { adminGateKeeper(); $short_name = getInput("short_name"); $label = getInput("label"); $description = getInput("description"); $hidden = getInput("hidden"); if ($hidden == 0) { $hidden = false; } else { $hidden = true; } $product_category = new Productcategory(); $product_category->short_name = $short_name; $product_category->label = $label; $product_category->description = $description; $product_category->hidden = $hidden; $product_category->save(); new SystemMessage("Your product category has been saved."); forward("store"); }
public static function boot() { parent::boot(); //This event will delete all related model in category model static::deleted(function ($brand) { $r = $brand->categories()->lists('id'); if (!empty($r)) { Productcategory::destroy($r); } }); static::updated(function ($brand) { //$r = $brand->categories()->lists('id'); }); }
public function saveaddProducts() { $productcat_id = Input::get('productcat_id'); $products = json_decode(Input::get('name')); if (!empty($products)) { $catName = Productcategory::find($productcat_id)->pluck('name'); $BrandName = Productcategory::find($productcat_id)->brand->pluck('name'); //$catName = $BrandID_CatName->name; //Log area $log['products'] = "[ {$BrandName} / {$catName} ] = " . implode(' | ', $products); $log['stocktype'] = 'create'; $this->_saveActivityLog($log); } return Product::saveAll($products, $productcat_id); }
/** * 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 the ID of the model to be loaded */ public function loadModel($id) { $model=Productcategory::model()->findByPk($id); if($model===null) throw new CHttpException(404,'The requested page does not exist.'); return $model; }
<?php // echo $form->error($model, 'type_id'); ?> </div> </div> <div class="row top"> <div class="col-md-3"> <?php echo $form->labelEx($model, 'cat_id'); ?> </div> <div class="col-md-9"> <?php echo $form->dropDownList($model, 'cat_id', Productcategory::getCategories(), array('empty' => 'Select'), array('options' => array($model->cat_id => array('selected' => true)))); ?> <?php echo $form->error($model, 'cat_id'); ?> </div> </div> <div class="row top"> <div class="col-md-3"> <?php echo $form->labelEx($model, 'ord'); ?> </div> <div class="col-md-9"> <?php
public function saveOrUpdatePrdprcCat($model, $extcatid = null, $newcatid) { $product_id = $model->product_id; $productprice_id = $model->id; $result = array(); if(!empty($extcatid)) { $condition = 'product_id=' . $product_id; $condition .= ' AND productprice_id = ' . $productprice_id; $condition .= ' AND category_id = ' . $extcatid; $criteria = new CDbCriteria; $criteria->select = array( 'id' ); $criteria->condition = $condition; $result = Productcategory::model()->findAll( $criteria ); } if(count($result) > 0) { $prdcat = Productcategory::model()->findByPk( $result[0]->id ); } else { $prdcat = new Productcategory; } $prdcat->product_id = $product_id; $prdcat->productprice_id = $productprice_id; $prdcat->category_id = $newcatid; $rtn = $prdcat->save(); if(!$rtn) { $this->msg = $prdcat->getErrors(); } return $rtn; }
private function deleteProductCategoriesByPrdId($productid) { $conditions = array('product_id=?', $productid); $result = \Productcategory::find('all', array('conditions' => $conditions)); foreach($result as $data){ $data->delete(); } }
<?php $trad_prod = Productcategory::model()->findAll(array("condition" => "sub=" . getParam('subcat') . " and oid = " . getFranchiseId())); ?> <script src="<?php echo getThemeUrl() . '/js/option/jssor.core.js'; ?> "></script> <script src="<?php echo getThemeUrl() . '/js/option/jssor.utils.js'; ?> "></script> <script src="<?php echo getThemeUrl() . '/js/option/jssor.slider.js'; ?> "></script> <script> var products = []; jQuery(document).ready(function($) { var options = { $AutoPlay: false, //[Optional] Whether to auto play, to enable slideshow, this option must be set to true, default value is false $AutoPlaySteps: 1, //[Optional] Steps to go for each navigation request (this options applys only when slideshow disabled), the default value is 1 $AutoPlayInterval: 6000, //[Optional] Interval (in milliseconds) to go for next slide since the previous stopped if the slider is auto playing, default value is 3000 $PauseOnHover: 1, //[Optional] Whether to pause when mouse over if a slider is auto playing, 0 no pause, 1 pause for desktop, 2 pause for touch device, 3 pause for desktop and touch device, default value is 1 $ArrowKeyNavigation: true, //[Optional] Allows keyboard (arrow key) navigation or not, default value is false $SlideDuration: 500, //[Optional] Specifies default duration (swipe) for slide in milliseconds, default value is 500 $MinDragOffsetToSlide: 20, //[Optional] Minimum drag offset to trigger slide , default value is 20 //$SlideWidth: 600, //[Optional] Width of every slide in pixels, default value is width of 'slides' container //$SlideHeight: 300, //[Optional] Height of every slide in pixels, default value is height of 'slides' container $SlideSpacing: 0, //[Optional] Space between each slide in pixels, default value is 0
public static function getProductCategory() { $c = Productcategory::get(); self::$productcategory = $c; return new self(); }
private function mustBeUniqueToProductCategories($productcatID) { return Productcategory::find($productcatID)->products->lists('name'); }
public function actionCustomerReply() { $this->layout = '//layouts/maindate'; if (isset($_POST['customer']) && isset($_POST['customer']['ajax'])) { $customer_questions = $this->loadModel(getCurCusId()); $customer_questions->provisional_date = isset($_POST['customer']['provisional_date']) ? $_POST['customer']['provisional_date'] : ""; $customer_questions->call_date = isset($_POST['customer']['call_date']) ? $_POST['customer']['call_date'] : ""; if ($customer_questions->provisional_date) { $temp = array(); $date = explode('/', $customer_questions->provisional_date); if (count($date) == 3) { $temp[] = $date[1]; $temp[] = $date[0]; $temp[] = $date[2]; $temp = implode('/', $temp); $customer_questions->provisional_date = $temp; } } if ($customer_questions->call_date) { $temp = array(); $date = explode('/', $customer_questions->call_date); if (count($date) == 3) { $temp[] = $date[1]; $temp[] = $date[0]; $temp[] = $date[2]; $temp = implode('/', $temp); $customer_questions->call_date = $temp; } } // p($customer_questions->attributes); $customer_questions->save(); $menus = isset(Yii::app()->session['menus']) ? Yii::app()->session['menus'] : array(); if (count($menus)) { $menus_keys = array_keys($menus); $delSelMenu = SelectedCategories::model()->deleteAll(" user_id =" . getCurCusId() . " and cat_id not in (" . implode(',', $menus_keys) . ")"); } // p($delSelMenu); foreach ($menus as $key => $value) { $sel_cat = SelectedCategories::model()->findByAttributes(array('user_id' => getCurCusId(), 'cat_id' => $key)); if (!$sel_cat) { $sel_cat = new SelectedCategories(); } $productsIds = CJSON::encode($value['like']); $sel_cat->attributes = $value; $sel_cat->user_id = getCurCusId(); $sel_cat->cat_id = $key; $sel_cat->like = $sel_cat->like ? 1 : 0; $sel_cat->product_ids = $productsIds; $sel_cat->save(false); } $selected_product = isset(Yii::app()->session['sel_prod_n']) ? Yii::app()->session['sel_prod_n'] : array(); if (count($selected_product)) { $delSelProd = SelProducts::model()->deleteAll("cus_id = " . getCurCusId() . ' and product_id not in (' . implode(',', $selected_product) . ')'); } if (count($selected_product)) { $selected_product = array_unique($selected_product); } foreach ($selected_product as $pid) { $selPro = SelProducts::model()->findByAttributes(array('product_id' => $pid, 'cus_id' => getCurCusId())); if (!$selPro) { $selPro = new SelProducts(); } $selPro->product_id = $pid; $selPro->cus_id = getCurCusId(); $selPro->save(false); } // p($selPro->attributes,0); // p(CActiveForm::validate($selPro->attributes)); unset(Yii::app()->session['sel_prod_n']); unset(Yii::app()->session['menus']); echo json_encode(array('success' => 1)); exit; } DynamicCall::GetEdit1stPdf(getCurCusId()); $id = getParam('id'); $customer = Customer::model()->findByPk($id); $magic_spoon = MagicSpool::model()->findAll(array('select' => 'one,two,three,four,five', 'condition' => 'cus_id=:cus_id', 'limit' => 1, 'params' => array(':cus_id' => $id))); $menus = isset(Yii::app()->session['menus']) ? Yii::app()->session['menus'] : array(); $items = array(); $allItems = $temp = array(); foreach ($menus as $key => $value) { $arrr = explode(',', getAllowedCategoriesId()); if (in_array($key, $arrr)) { unset($menus[$key]); continue; } $product_category = Productcategory::model()->findByPk($key); $menus[$key] = array_merge($product_category->attributes, $value); $allItems = array_merge($value['like'], $allItems); } foreach ($menus as $menu) { $temp[$menu['order']] = $menu; } /* e($temp); if (count($temp)) ksort($temp); $menus = $temp; */ foreach ($allItems as $i) { $product = Product::model()->findByPk($i); if ($product) { $items[] = $product; } } ksort($items); /* $temp = array(); foreach ($items as $item): foreach ($item as $i): $temp[] = $i; endforeach; endforeach; $items = $temp; */ $this->render('customerreply', array('magic_spoon' => $magic_spoon, 'menus' => $menus, 'items' => $items, 'customer' => $customer)); }
/** * @param int $count * * @return string */ public static function generateSampleProducts($count = 10) { // Type $typeIds = Producttype::getIdsOrCreateDummy(); // category $categoryIds = Productcategory::getIdsOrCreateSampelData(); // unit berat $unitIds = Units::getIdsOrCreateSampleUnits(); // parent_id $parentId = 0; $fake = static::getFake(); // // Buat Product $catId = $fake->getFake()->randomElement($categoryIds); $typeId = $fake->getFake()->randomElement($typeIds); $unitWeightId = $fake->getFake()->randomElement($unitIds); $unitWidthId = $fake->getFake()->randomElement($unitIds); $supplierIds = Suppliers::getRecordIdsOrCreate(); $currencyIds = Currencies::getIdsOrCreateSample(); // color $colorIds = Colors::getIdsOrCreate(); // gradeIds $gradeIds = Fabricgrade::getIdsOrCreate(); $productIds = array(); for ($rec = 0; $rec < $count; $rec++) { $product = $fake->getProduct()->product($catId, $typeId, $unitWeightId, $unitWidthId, $parentId, '\\Emayk\\Ics\\Repo\\Productcategory\\Productcategory'); $record = static::createRecord($product); $productId = $record->id; $productIds[] = $productId; // Image/ Photo Product $imagesIds[] = Images::getIdsOrCreate($productId, '\\Emayk\\Ics\\Repo\\Products\\Products'); // Supplier Product // Product Supplier (Product dapat dari Supplier mana ?) $supplierId = $fake->getFake()->randomElement($supplierIds); $supplierProduct = Productsuppliers::create(array('master_product_id' => $productId, 'master_supplier_id' => $supplierId)); $supplierProductId = $supplierProduct->id; // Create Detail // Buat Product Detail $unitId = $fake->getFake()->randomElement($unitIds); $colorId = $fake->getFake()->randomElement($colorIds); $gradeId = $fake->getFake()->randomElement($gradeIds); $currSp = $fake->getFake()->randomElement($currencyIds); $currSpm = $fake->getFake()->randomElement($currencyIds); $detailIds[] = Productdetails::getIdOrCreate($productId, $colorId, $unitId, $gradeId, $currSp, $currSpm); //Buat Stock // Buat Stock $stockIds[] = Stockproducts::createStock($productId); } foreach ($stockIds as $stockId) { for ($history = 0; $history < 9; $history++) { // Buat Stock Detail/History277 if ($history % 2 == 0 || $history == 0) { $typeHistory = 'in'; } else { $typeHistory = 'out'; } $firstHistory = $history == 0; // $stockHistoryIds[] = Stockproducthistory::createHistoryStockSample($stockId, $typeHistory, $firstHistory); } } return "Sudah Generate sebanyak " . count($productIds) . " records"; return s($productIds, $supplierProductId, $imagesIds, $detailIds); }
public static function syncCat($categories) { e($categories); foreach ($categories as $category) { $cat = Productcategory::model()->findByPk($category->id); if (!$cat) { $cat = new Productcategory(); $cat->id = $category->id; } $cat->name = $category->name; $cat->desc = $category->cat_descp; $cat->type = $category->pid; if ($cat->save()) { DynamicCall::syncProd($cat->id, $category->pid); } } }
public static function syncSubCat($catid, $oid) { $url = 'http://mccreative.jaspersonline.co.uk/api/products/getSubMenus/' . $catid . '/' . $oid; $results = self::getData($url); // e($results); if (!$results->count) { return false; } $ii = 1; // e($results->data); foreach ($results->data as $result) { $subcat = Productcategory::model()->findByPk($oid . $result->id); if (!$subcat) { $subcat = new Productcategory(); $subcat->id = $oid . $result->id; } $subcat->jaspers_id = $result->id; $subcat->name = $result->name; if (!$subcat->image) { $subcat->image = "http://bmsdev.jaspersonline.co.uk/store/products/order_images/{$result->id}.jpg"; } $subcat->desc = $result->description; $subcat->type = 0; $subcat->sub = $catid; $subcat->oid = $oid; if ($subcat->save()) { // e($result->id, 0); self::syncProd($oid, $result, $subcat); } // if ($subcat->save()) // self::syncProd($oid, $result, $subcat); // else // e('not saved'); $ii++; } // e('end'); }
private function _monitorChildrenStatus(array $ids) { foreach ($ids as $id) { $cat = Productcategory::find($id); $status = $cat->products->lists('published'); $cat->published = in_array(1, $status) ? 1 : 0; $cat->save(); } }
public function actionMenu_old($id) { Productcategory::getTradSubMenus(); if (getParam('menu')) { $currentMenu = Productcategory::model()->findByPk(getParam('menu')); } if (getParam('subcat')) { $currentMenu = Productcategory::model()->findByPk(getParam('subcat')); } $criteria = new CDbCriteria(); $criteria->order = '`order` asc'; $criteria->compare('oid', 0); $criteria->addCondition('id != 17'); $criteria->compare('type', 0, false, '>'); $menus = Productcategory::model()->findAll($criteria); if (!isset($currentMenu)) { $currentMenu = Productcategory::model()->findByPk(1092507461); } DynamicCall::GetEdit1stPdf(getCurCusId()); if ($currentMenu->type == 1) { $this->render('menu', array('id' => $id, 'menus' => $menus, 'currentMenu' => $currentMenu)); } elseif ($currentMenu->type == 2) { $this->render('subcategories', array('id' => $id, 'menus' => $menus, 'currentMenu' => $currentMenu)); } else { $this->render('traditional', array('id' => $id, 'menus' => $menus, 'currentMenu' => $currentMenu)); } }
/** * [PHPB2B] Copyright (C) 2007-2099, Ualink Inc. All Rights Reserved. * The contents of this file are subject to the License; you may not use this file except in compliance with the License. * * @version $Revision: 2075 $ */ function smarty_function_category($params, &$smarty) { $conditions[] = 'available=1'; $result = array(); if (class_exists("Productcategories")) { $cat = new Productcategories(); $cat_controller = new Productcategory(); } else { uses("productcategory"); $cat = new Productcategories(); $cat_controller = new Productcategory(); } $limit = $offset = 0; if (isset($params['row'])) { $limit = $params['row']; } if (isset($params['start'])) { $offset = $params['start']; } $cat->setCondition($conditions); $table_name = $cat->table_prefix . $cat_controller->pluralize($params['name']); $cat->dbstuff->setFetchMode(ADODB_FETCH_ASSOC); if (isset($params['depth'])) { //depth if ($params['depth'] == -1) { $result = $cat->dbstuff->GetArray("SELECT * FROM " . $table_name . $cat->getCondition()); return $result; } } $level = intval($params['depth']); $return = array(); switch ($level) { case 1: $conditions[] = "level IN (" . $level . ")"; $cat->setCondition($conditions); $return = $cat->dbstuff->GetArray("SELECT * FROM " . $table_name . $cat->getCondition() . " ORDER BY display_order ASC"); break; case 2: $conditions[] = "level IN (1,2)"; $cat->setCondition($conditions); $result = $cat->dbstuff->GetArray("SELECT * FROM " . $table_name . $cat->getCondition() . " ORDER BY display_order ASC"); foreach ($result as $val) { if ($val['level'] == 1) { $result_1[$val['id']] = $val; } elseif ($val['level'] == 2) { $result_2[] = $val; } } unset($result); foreach ($result_2 as $val2) { if ($val2['parent_id'] == $result_1[$val2['parent_id']]['id']) { $result_1[$val2['parent_id']]['child'][] = $val2; } } $return = $result_1; unset($result, $result_1, $result_2); break; case 3: $conditions[] = "level IN (1,2,3)"; $cat->setCondition($conditions); $result = $cat->dbstuff->GetArray("SELECT * FROM " . $table_name . $cat->getCondition() . " ORDER BY display_order ASC"); foreach ($result as $val) { if ($val['level'] == 1) { $return[$val['id']] = $val; } elseif ($val['level'] == 2) { $return[$val['parent_id']]['child'][$val['id']] = $val; } elseif ($val['level'] == 3) { $return[$val['top_parentid']]['child'][$val['parent_id']]['child'][] = $val; } } unset($result); break; default: break; } //$cat->setLimitOffset($offset, $limit); if (isset($params['output'])) { return $return; } else { if (empty($params['var'])) { $params['var'] = "category"; } $smarty->assign($params['var'], $return); unset($return); } }
public function actionMenu($id) { Productcategory::getTradSubMenus(); if (getParam('menu')) { $currentMenu = Productcategory::model()->findByPk(getParam('menu')); } $criteria = new CDbCriteria(); $criteria->order = '`order` asc'; $criteria->compare('sub', 0); $criteria->compare('display_in_menu', 1); $menus = Productcategory::model()->findAll($criteria); // e($menus); if (!isset($currentMenu)) { $currentMenu = current($menus); } DynamicCall::GetEdit1stPdf(getCurCusId()); if (!$currentMenu->type) { $this->render('menu', array('id' => $id, 'menus' => $menus, 'currentMenu' => $currentMenu)); } else { $this->render('traditional', array('id' => $id, 'menus' => $menus, 'currentMenu' => $currentMenu)); // $this->render('subcategories', array('id' => $id, 'menus' => $menus, 'currentMenu' => $currentMenu)); } }
public static function getTradSubMenus() { $menus = Productcategory::model()->with(array('count'))->findAll(array('condition' => "type = 0 and sub = 0")); // e($menus); return Productcategory::model()->with(array('count'))->findAll(array('condition' => "type = 0 and sub = 0")); }
<?php //$trad_prod = Productcategory::model()->findAll(array("condition" => "type=1 and sub!= 0")); $trad_prod = Productcategory::getTradSubMenus(); ?> <div class="container center"> <div class="row"> <div class="col-lg-12" > <div class="col-lg-6 top20"> <?php foreach ($menus as $menu) { ?> <div class="col-lg-4 col-md-4 col-sm-4 cimg"> <form method="post" action="product"> <?php $params = array('id' => getParam('id'), 'menu' => $menu->id); ?> <a href="<?php echo createUrl('site/menu', $params); ?> "> <?php if (strtolower($menu->name) == 'traditional menu') { ?> <img src="<?php echo getCatImg() . $menu->image; ?> " class="img-responsive mar_auto img_submit"> <?php } else {
public function actionChecktrans() { $postedData = $this->getPostedData(); $product_id = $postedData['productId']; // $values=array(); $condition = 'product_id=' .$product_id; $criteria = new CDbCriteria; $criteria->condition = $condition; $Prdprice = Productcategory::model()->findAll( $criteria ); $mastercate = Masterproductcategory::model()->findAll( $criteria ); if(count($Prdprice)>0) { $categoryFlag=(object)["flag"=>false,"catId"=>$mastercate[0]->category_id]; // $values[]=$categoryFlag; } else $categoryFlag=(object)["flag"=>false]; echo json_encode($categoryFlag); }
<?php $trad_prod = Productcategory::model()->findAll(array("condition" => "type=1 and sub!= 0 and sub!= 22", "order" => "`order` asc")); //e($trad_prod); ?> <script src="<?php echo getThemeUrl() . '/js/option/jssor.core.js'; ?> "></script> <script src="<?php echo getThemeUrl() . '/js/option/jssor.utils.js'; ?> "></script> <script src="<?php echo getThemeUrl() . '/js/option/jssor.slider.js'; ?> "></script> <script> var products = []; jQuery(document).ready(function($) { var options = { $AutoPlay: false, //[Optional] Whether to auto play, to enable slideshow, this option must be set to true, default value is false $AutoPlaySteps: 1, //[Optional] Steps to go for each navigation request (this options applys only when slideshow disabled), the default value is 1 $AutoPlayInterval: 6000, //[Optional] Interval (in milliseconds) to go for next slide since the previous stopped if the slider is auto playing, default value is 3000 $PauseOnHover: 1, //[Optional] Whether to pause when mouse over if a slider is auto playing, 0 no pause, 1 pause for desktop, 2 pause for touch device, 3 pause for desktop and touch device, default value is 1 $ArrowKeyNavigation: true, //[Optional] Allows keyboard (arrow key) navigation or not, default value is false $SlideDuration: 500, //[Optional] Specifies default duration (swipe) for slide in milliseconds, default value is 500 $MinDragOffsetToSlide: 20, //[Optional] Minimum drag offset to trigger slide , default value is 20 //$SlideWidth: 600, //[Optional] Width of every slide in pixels, default value is width of 'slides' container //$SlideHeight: 300, //[Optional] Height of every slide in pixels, default value is height of 'slides' container
<?php echo $form->labelEx($model, 'order'); ?> <?php echo $form->textField($model, 'order', array('size' => 60, 'maxlength' => 255)); ?> <?php echo $form->error($model, 'order'); ?> </div> <div class="row"> <?php echo $form->labelEx($model, 'sub'); ?> <?php echo $form->dropDownList($model, 'sub', Productcategory::getCategories(), array('empty' => 'select')); ?> <?php echo $form->error($model, 'sub'); ?> </div> <div class="row"> <?php $model->type = 1; ?> <?php echo $form->hiddenField($model, 'type'); ?> <?php // echo $form->labelEx($model, 'type');
private function statusChildrenCategory($productcatsID, $status) { foreach ($productcatsID as $productcat_id) { $cat = Productcategory::find($productcat_id); $cat->published = $status; $productsID = $cat->products->lists('id'); if (!empty($productsID)) { $this->statusChildrenProduct($productsID, $status); } $cat->save(); } }