ari100krat.local /modules/shop/classes/controller/paymethods.php

Language PHP Lines 158
MD5 Hash 24d2750c14092edf57e3ea1a146d9f2e Estimated Cost $2,509 (why?)
Repository https://bitbucket.org/seyar/ari100krat.local View Raw File View Project SPDX
  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
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
<?php defined('SYSPATH') OR die('No direct access allowed.');

class Controller_PayMethods extends Controller_Shop {

    //public $template		= 'paymethods_list.tpl';
    public $template		= 'shop_paymentoptions';

    public $module_title        = 'Payment Methods';
    public $module_desc_short   = 'Shop Descr Short';
    public $module_desc_full	= 'Shop Descr Full';
    
    public function before()
    {
        parent::before();
        $this->model = new Model_PayMethods();

        //die(Kohana::debug($this->model));

        //die('ok!');
        //$this->request->controller .= ':'.MODULE_SUBCONTROLLER;
    }

    public function action_index()
    {
        $this->template = View::factory('shop_paymentoptions');

        $rows = $current_category = array(); $page_links = ''; $total_pages = 0;

        
//	list($rows, $pagination, $total_pages) = $this->model->show();
//        $this->template->rows = $rows;
//        $this->template->pagination = $pagination;


        $rows = array();
        $page_links = '';
        $total_pages = 0;
        $where = array();

        list($this->template->pagination, $this->template->rows) = Admin::model_pagination('', 'shop_payment_methods',
                        array('id', 'name', 'print_invoice', 'margin', 'status'),
                        $where, array('orderid','ASC')
        );
    }

    public function action_delete()
    {
//	if ($this->request->param('id'))
//        {
//            $obj = $this->model->load($this->request->param('id'));
//	    $this->model->delete( $this->request->param('id') );
//	    $this->model->setMethod($obj['fs_name'])->delete( $obj['settings_id'] );
//        }
//        die(Kohana::debug($_POST));
//	if (count($_POST['chk']))
	if (isset($_POST['chk']))
        {
            //$first = current($_POST['chk']);
            //die(Kohana::debug($first));
            //$obj = $this->model->load($first);
	    $this->model->delete_list( $_POST['chk'], null );
//	    $this->model->setMethod($obj['fs_name'])->delete_list( $_POST['chk'] );
        }

        $this->redirect_to_controller($this->request->controller);
    }

    public function action_edit()
    {
        $obj = $this->model->load( $this->request->param('id') );
        $filename = 'shop_payedit_'.strtolower($obj['fs_name']);                
        $filename = file_exists( dirname( __FILE__).'/../../views/'.$filename.'.php' ) ? 'shop_payedit_'.strtolower($obj['fs_name']) : 'shop_payedit';
        
        $this->template = View::factory($filename);
        
        $this->template->obj = $obj;
        
        $this->template->shipments = Model_Shop::shipment_methods();
    }

    public function action_save()
    {
        $id = $this->request->param('id');
        if( $id == 0)
            $res = $this->model->add( $this->lang );
        else
            $res = $this->model->save( $this->lang, $id );
                
	    $this->redirect_to_controller($this->request->controller);
    }

    public function action_update()
    {
        $id = $this->request->param('id');
        if( $id == 0)
            $res = $this->model->add( $this->lang );
        else
            $res = $this->model->save( $this->lang, $id );
        
        if($res)        
            $this->redirect_to_controller( $this->request->controller.'/'.$res.'/edit' );
        else
            $this->redirect_to_controller( $this->request->controller );
        
	
    }

    public function action_step1()
    {
        $this->template = View::factory('paymethods_step1');
        $this->template->payTypes = Kohana::config('shop')->payTypes;
    }
    
    public function action_step2()
    {        
        $payments = Model_PayMethods::getPaymentGroups( array('type' => $_POST['getFromPayment']) );        
        $this->template = View::factory('paymethods_step2');
        $this->template->payments = $payments;
    }

    public function action_step3()
    {        
        $payment = Model_PayMethods::getPaymentGroups( array('id' => $_POST['getFromPayment']), FALSE );
        $shipments = Model_Shop::shipment_methods();
        $fs_name = $payment['fs_name'];        
        $this->template = View::factory('shop_payedit_'.strtolower($payment['fs_name']) );
        $this->template->fs_name = $fs_name;
        $this->template->payments = $payment;
        $this->template->shipments = $shipments;
    }

    static public function getCost($method, $sum = 0, $weight = 0)
    {
        $oPaymethods = new Model_PayMethods;
        $obj = $oPaymethods->load($method);
        return $oPaymethods->setMethod( $obj['fs_name'] )->getCost( $obj, $sum, $weight );
    }

    public function action_status()
    {
        
        if ($this->request->param('id'))
            $this->model->status( $this->request->param('id') );

        elseif (count($_POST['chk']))
            $this->model->status_list( $_POST['chk'] );

        $this->redirect_to_controller($this->request->controller);
    }
    
    function action_updateOrderId()
    {
        if( $this->model->updateOrderId( $_GET['ids'] ))
                die('1');
        else
                die('error');
    }
}
Back to Top