Exemplo n.º 1
0
 function saveRegion($data)
 {
     $this->onExecuteBefore('saveRegion', array(&$data));
     $data['alias'] = KSFunctions::CheckAlias($data['alias'], $data['id']);
     $data['alias'] = $data['alias'] == '' ? KSFunctions::GenAlias($data['title']) : $data['alias'];
     $data['country_id'] = isset($data['country_id']) ? $data['country_id'] : 0;
     $table = $this->getTable('regions');
     if (empty($data['id'])) {
         $query = $this->_db->getQuery(true);
         $query->update('#__ksenmart_regions')->set('ordering=ordering+1');
         $this->_db->setQuery($query);
         $this->_db->query();
     }
     if (!$table->bindCheckStore($data)) {
         $this->setError($table->getError());
         return false;
     }
     $id = $table->id;
     KSMedia::saveItemMedia($id, $data, 'region', 'regions');
     $on_close = 'window.parent.RegionsList.refreshList();';
     $return = array('id' => $id, 'on_close' => $on_close);
     $this->onExecuteAfter('saveRegion', array(&$return));
     return $return;
 }
Exemplo n.º 2
0
 function saveManufacturer($data)
 {
     $this->onExecuteBefore('saveManufacturer', array(&$data));
     $data['alias'] = KSFunctions::CheckAlias($data['alias'], $data['id']);
     if ($data['alias'] == '') {
         $data['alias'] = KSFunctions::GenAlias($data['title']);
     }
     $data['country'] = isset($data['country']) ? $data['country'] : 0;
     $table = $this->getTable('manufacturers');
     if (!$table->bindCheckStore($data)) {
         $this->setError($table->getError());
         return false;
     }
     $id = $table->id;
     KSMedia::saveItemMedia($id, $data, 'manufacturer', 'manufacturers');
     $on_close = 'window.parent.ManufacturersModule.refresh();';
     $return = array('id' => $id, 'on_close' => $on_close);
     $this->onExecuteAfter('saveManufacturer', array(&$return));
     return $return;
 }
Exemplo n.º 3
0
 function saveProperty($data)
 {
     $this->onExecuteBefore('saveProperty', array(&$data));
     $data['alias'] = KSFunctions::CheckAlias($data['alias'], $data['id']);
     $data['alias'] = $data['alias'] == '' ? KSFunctions::GenAlias($data['title']) : $data['alias'];
     $data['published'] = isset($data['published']) ? $data['published'] : 0;
     $data['edit_price'] = isset($data['edit_price']) ? $data['edit_price'] : 0;
     $table = $this->getTable('properties');
     if (empty($data['id'])) {
         $query = $this->_db->getQuery(true);
         $query->update('#__ksenmart_properties')->set('ordering=ordering+1');
         $this->_db->setQuery($query);
         $this->_db->query();
     }
     if (!$table->bindCheckStore($data)) {
         $this->setError($table->getError());
         return false;
     }
     $id = $table->id;
     $in = array();
     foreach ($data['categories'] as $v) {
         $table = $this->getTable('PropertiesCategories');
         $d = array('category_id' => $v, 'property_id' => $id);
         if ($table->load($d)) {
             $d['id'] = $table->id;
         }
         if (!$table->bindCheckStore($d)) {
             $this->setError($table->getError());
             return false;
         }
         $in[] = $table->id;
     }
     $query = $this->_db->getQuery(true);
     $query->delete('#__ksenmart_product_categories_properties')->where('property_id=' . $id);
     if (count($in)) {
         $query->where('id not in (' . implode(', ', $in) . ')');
     }
     $this->_db->setQuery($query);
     $this->_db->query();
     $in = array();
     foreach ($data['values'] as $k => $v) {
         $v['property_id'] = $id;
         $table = $this->getTable('PropertiesValues');
         if ($k > 0) {
             $v['id'] = $k;
         }
         $v['alias'] = KSFunctions::CheckAlias($v['alias'], $v['id']);
         $v['alias'] = $v['alias'] == '' ? KSFunctions::GenAlias($v['title']) : $v['alias'];
         if (!$table->bindCheckStore($v)) {
             $this->setError($table->getError());
             return false;
         }
         $in[] = $table->id;
     }
     $query = $this->_db->getQuery(true);
     $query->delete('#__ksenmart_property_values')->where('property_id=' . $id);
     if (count($in)) {
         $query->where('id not in (' . implode(',', $in) . ')');
     }
     $this->_db->setQuery($query);
     $this->_db->query();
     $query = $this->_db->getQuery(true);
     $query->delete('#__ksenmart_product_properties_values')->where('property_id=' . $id);
     if (count($in)) {
         $query->where('value_id not in (' . implode(',', $in) . ')');
     }
     $this->_db->setQuery($query);
     $this->_db->query();
     $on_close = 'window.parent.PropertiesList.refreshList();';
     $return = array('id' => $id, 'on_close' => $on_close);
     $this->onExecuteAfter('saveProperty', array(&$return));
     return $return;
 }