Advertisement
krot

opencart new module

Nov 9th, 2017
283
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.48 KB | None | 0 0
  1. C:\op\domains\shop.loc\admin\controller\pricelist\price.php
  2. <?php
  3. class Controllerpricelistprice extends Controller {
  4.     public function index() {
  5.         $this->load->language('pricelist/price');
  6.        
  7.         $this->load->model('pricelist/price');
  8.        
  9.         if (($this->request->server['REQUEST_METHOD'] == 'POST') ) {
  10.             switch($this->request->post['cmd']){
  11.             case 'markup':
  12.                 try {
  13.             $this->model_pricelist_price->setMarkup(
  14.                                         @$this->request->post['STOCK'],
  15.                                         @$this->request->post['PRICE_S'],
  16.                                         @$this->request->post['PRICE_E'],
  17.                                         @$this->request->post['MARKUP'],
  18.                                         @$this->request->post['DISCOUNT']
  19.             );
  20.                     } catch (Exception $e) {
  21.                         echo 'Выброшено исключение: ',  $e->getMessage(), "\n";
  22.                         }
  23.                
  24.             break;
  25.             }
  26.         }
  27.        
  28.        
  29.        
  30.         $data['price_markup'] = $this->model_pricelist_price->getMarkup();
  31.        
  32.        
  33.         $this->document->setTitle($this->language->get('heading_title'));
  34.  
  35.         $data['heading_title'] = $this->language->get('heading_title');
  36.  
  37.         $data['markup_submit'] = $this->language->get('markup_submit');
  38.         $data['markup_title'] = $this->language->get('markup_title');
  39.  
  40.         $data['breadcrumbs'] = array();
  41.  
  42.         $data['breadcrumbs'][] = array(
  43.             'text' => $this->language->get('text_home'),
  44.             'href' => $this->url->link('common/dashboard', 'token=' . $this->session->data['token'], true)
  45.         );
  46.  
  47.         $data['breadcrumbs'][] = array(
  48.             'text' => $this->language->get('heading_title'),
  49.             'href' => $this->url->link('pricelist/price', 'token=' . $this->session->data['token'], true)
  50.         );
  51.  
  52.         $data['header'] = $this->load->controller('common/header');
  53.         $data['column_left'] = $this->load->controller('common/column_left');
  54.         $data['footer'] = $this->load->controller('common/footer');
  55.        
  56.  
  57.         $this->response->setOutput($this->load->view('pricelist/setting', $data));
  58.     }
  59. }
  60. C:\op\domains\shop.loc\admin\language\ru-ru\pricelist\price.php
  61. <?php
  62. // Heading
  63. $_['heading_title']  = 'Настройка прайс-листов!';
  64. ..
  65.  
  66. C:\op\domains\shop.loc\admin\model\pricelist\price.php
  67.  
  68. <?php
  69. class Modelpricelistprice extends Model {
  70.  public function setMarkup( $STOCK,
  71.                             $PRICE_S,
  72.                             $PRICE_E,
  73.                             $MARKUP,
  74.                             $DISCOUNT){
  75.                            ..
  76.         $this->db->query("UPDATE l..");
  77.        
  78.        
  79.      
  80.  }
  81.   public function getMarkup(){
  82.    $sql="SELECT * FROM `load_markup`";
  83.    $query = $this->db->query($sql);
  84.    return $query->rows;
  85.  }
  86. }
  87.  
  88. C:\op\domains\shop.loc\admin\view\template\pricelist\setting.tpl
  89. <?php echo $header; ?><?php echo $column_left; ?>
  90. <div id="content">
  91. <div class="page-header">
  92.   <div class="container-fluid">
  93.     <h1><?php echo $heading_title; ?></h1>
  94.     <ul class="breadcrumb">
  95.       <?php foreach ($breadcrumbs as $breadcrumb) { ?>
  96.       <li><a href="<?php echo $breadcrumb['href']; ?>"><?php echo $breadcrumb['text']; ?></a></li>
  97.       <?php } ?>
  98.     </ul>
  99.   </div>
  100. </div>
  101. <div class="container-fluid">
  102.   <div class="panel panel-default">
  103.     <div class="panel-heading">
  104.       <h3 class="panel-title"><i class="fa fa-exclamation-triangle"></i> <?php echo $markup_title; ?></h3>
  105.     </div>
  106.     <div class="panel-body">
  107.       <noscript>Включите JavaScript!</noscript>
  108.    
  109.             <?php foreach($price_markup as $val): ?>
  110.            
  111.             <option value='<?=$val['STOCK'];?>'><?=$val['STOCK'];?></option>
  112.             ..
  113.             <?php endforeach; ?>
  114.    
  115.      
  116.     </div>
  117.   </div>
  118. </div>
  119. <?php echo $footer; ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement