PageRenderTime 50ms CodeModel.GetById 23ms RepoModel.GetById 0ms app.codeStats 0ms

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

https://bitbucket.org/seyar/ari100krat.local
PHP | 158 lines | 105 code | 34 blank | 19 comment | 8 complexity | 24d2750c14092edf57e3ea1a146d9f2e MD5 | raw file
Possible License(s): BSD-3-Clause, LGPL-2.1
  1. <?php defined('SYSPATH') OR die('No direct access allowed.');
  2. class Controller_PayMethods extends Controller_Shop {
  3. //public $template = 'paymethods_list.tpl';
  4. public $template = 'shop_paymentoptions';
  5. public $module_title = 'Payment Methods';
  6. public $module_desc_short = 'Shop Descr Short';
  7. public $module_desc_full = 'Shop Descr Full';
  8. public function before()
  9. {
  10. parent::before();
  11. $this->model = new Model_PayMethods();
  12. //die(Kohana::debug($this->model));
  13. //die('ok!');
  14. //$this->request->controller .= ':'.MODULE_SUBCONTROLLER;
  15. }
  16. public function action_index()
  17. {
  18. $this->template = View::factory('shop_paymentoptions');
  19. $rows = $current_category = array(); $page_links = ''; $total_pages = 0;
  20. // list($rows, $pagination, $total_pages) = $this->model->show();
  21. // $this->template->rows = $rows;
  22. // $this->template->pagination = $pagination;
  23. $rows = array();
  24. $page_links = '';
  25. $total_pages = 0;
  26. $where = array();
  27. list($this->template->pagination, $this->template->rows) = Admin::model_pagination('', 'shop_payment_methods',
  28. array('id', 'name', 'print_invoice', 'margin', 'status'),
  29. $where, array('orderid','ASC')
  30. );
  31. }
  32. public function action_delete()
  33. {
  34. // if ($this->request->param('id'))
  35. // {
  36. // $obj = $this->model->load($this->request->param('id'));
  37. // $this->model->delete( $this->request->param('id') );
  38. // $this->model->setMethod($obj['fs_name'])->delete( $obj['settings_id'] );
  39. // }
  40. // die(Kohana::debug($_POST));
  41. // if (count($_POST['chk']))
  42. if (isset($_POST['chk']))
  43. {
  44. //$first = current($_POST['chk']);
  45. //die(Kohana::debug($first));
  46. //$obj = $this->model->load($first);
  47. $this->model->delete_list( $_POST['chk'], null );
  48. // $this->model->setMethod($obj['fs_name'])->delete_list( $_POST['chk'] );
  49. }
  50. $this->redirect_to_controller($this->request->controller);
  51. }
  52. public function action_edit()
  53. {
  54. $obj = $this->model->load( $this->request->param('id') );
  55. $filename = 'shop_payedit_'.strtolower($obj['fs_name']);
  56. $filename = file_exists( dirname( __FILE__).'/../../views/'.$filename.'.php' ) ? 'shop_payedit_'.strtolower($obj['fs_name']) : 'shop_payedit';
  57. $this->template = View::factory($filename);
  58. $this->template->obj = $obj;
  59. $this->template->shipments = Model_Shop::shipment_methods();
  60. }
  61. public function action_save()
  62. {
  63. $id = $this->request->param('id');
  64. if( $id == 0)
  65. $res = $this->model->add( $this->lang );
  66. else
  67. $res = $this->model->save( $this->lang, $id );
  68. $this->redirect_to_controller($this->request->controller);
  69. }
  70. public function action_update()
  71. {
  72. $id = $this->request->param('id');
  73. if( $id == 0)
  74. $res = $this->model->add( $this->lang );
  75. else
  76. $res = $this->model->save( $this->lang, $id );
  77. if($res)
  78. $this->redirect_to_controller( $this->request->controller.'/'.$res.'/edit' );
  79. else
  80. $this->redirect_to_controller( $this->request->controller );
  81. }
  82. public function action_step1()
  83. {
  84. $this->template = View::factory('paymethods_step1');
  85. $this->template->payTypes = Kohana::config('shop')->payTypes;
  86. }
  87. public function action_step2()
  88. {
  89. $payments = Model_PayMethods::getPaymentGroups( array('type' => $_POST['getFromPayment']) );
  90. $this->template = View::factory('paymethods_step2');
  91. $this->template->payments = $payments;
  92. }
  93. public function action_step3()
  94. {
  95. $payment = Model_PayMethods::getPaymentGroups( array('id' => $_POST['getFromPayment']), FALSE );
  96. $shipments = Model_Shop::shipment_methods();
  97. $fs_name = $payment['fs_name'];
  98. $this->template = View::factory('shop_payedit_'.strtolower($payment['fs_name']) );
  99. $this->template->fs_name = $fs_name;
  100. $this->template->payments = $payment;
  101. $this->template->shipments = $shipments;
  102. }
  103. static public function getCost($method, $sum = 0, $weight = 0)
  104. {
  105. $oPaymethods = new Model_PayMethods;
  106. $obj = $oPaymethods->load($method);
  107. return $oPaymethods->setMethod( $obj['fs_name'] )->getCost( $obj, $sum, $weight );
  108. }
  109. public function action_status()
  110. {
  111. if ($this->request->param('id'))
  112. $this->model->status( $this->request->param('id') );
  113. elseif (count($_POST['chk']))
  114. $this->model->status_list( $_POST['chk'] );
  115. $this->redirect_to_controller($this->request->controller);
  116. }
  117. function action_updateOrderId()
  118. {
  119. if( $this->model->updateOrderId( $_GET['ids'] ))
  120. die('1');
  121. else
  122. die('error');
  123. }
  124. }