Blame view

modules/admin/controller/catalogController.php 1.58 KB
8d65d0ce   andryeyev   init
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
  <?php
  
  Class Admin_CatalogController Extends baseController {
  
  protected $_navig = array('name'=>"Catalog");
  
  public function preDispatch(){
    $auth = new Auth();
    if($auth->is_login_session() == false)Redirect($this->url.'/admin/auth/');
  }
  
  public function index($brend_id = 0)
  { 
  	$this->tpl->assign('brend_id',$brend_id);
  	$menu = new Menu($this->lang);
  	$row = $menu->view_params('catalog');
  	$this->tpl->assign('menu_one',$row);
  	
  	$catalog = new Catalog($this->lang);
  	$this->tpl->assign('rubrics',$catalog->getRubrics_tree($brend_id));
  }
  
  
  
  
  
  
  
  public function save($brend_id = 0,$id = 0){
  	$this->tpl->assign('brend_id',$brend_id);
    $catalog = new Catalog($this->lang);
    if ($_SERVER["REQUEST_METHOD"] == "POST") {
       $this->error = $catalog->valid($this->postParam);
       if(!$this->error){
        $catalog->saveRubric($this->postParam,$_FILES);
        Redirect($this->url.'/admin/catalog/index/'.$brend_id.'/');
       }
    }
    if($id != null){
     $row = $catalog->viewRubric($id);
     $this->tpl->assign('rubric_one', $row);
    }
    $this->tpl->assign('rubrics_list', $catalog->getRubrics_tree($brend_id,0,$id) );
  }
  
  
  
  
  
  
  
  public function delete($brend_id = null,$id = null){
    if($id != null){
  	$catalog = new Catalog($this->lang);
  	$catalog->deleteRubric($id);
  	Redirect($this->url.'/admin/catalog/index/'.$brend_id.'/');
    }
  }
  
  public function export(){
  	$products = new Products($this->lang);
  	$products->export();
  }
  
  public function import(){
  	$products = new Products($this->lang);
  	if(isset($_FILES['file']) && strlen($_FILES['file']['tmp_name'])>0){
  		$products->import($_FILES['file']);
  	}
  }
  
  }
  ?>