Advertisement
AmourSpirit

Joomla controller with task example

Jul 28th, 2015
284
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.44 KB | None | 0 0
  1. <?php
  2. /**
  3.  * @version     0.4.0
  4.  * @package     com_cn_reports
  5.  * @copyright   Copyright (C) 2015. All rights reserved.
  6.  * @license     GNU General Public License version 2 or later; see LICENSE.txt
  7.  * @author      
  8.  */
  9.  
  10. // No direct access.
  11. defined('_JEXEC') or die;
  12.  
  13. jimport('joomla.application.component.controlleradmin');
  14.  
  15. /**
  16.  * Retailpartnersalesbypartners list controller class.
  17.  */
  18. class Cn_reportsControllerRetailpartnersalesbypartners extends JControllerAdmin
  19. {
  20.     /**
  21.      * Constructor.
  22.      *
  23.      * @param   array  $config  An optional associative array of configuration settings.
  24.      *
  25.      * @see     JController
  26.      * @since   1.6
  27.      */
  28.     public function __construct($config = array())
  29.     {
  30.         parent::__construct($config);
  31.  
  32.         $this->registerTask('exportcsvcommission', 'exportCsvCommission');
  33.         $this->registerTask('exportcsvoverrides', 'exportCsvOverrides');
  34.     }
  35.     /**
  36.      * Proxy for getModel.
  37.      * @since   1.6
  38.      */
  39.     public function getModel($name = 'retailpartnersalebypartner', $prefix = 'Cn_reportsModel', $config = array())
  40.     {
  41.         $model = parent::getModel($name, $prefix, array('ignore_request' => true));
  42.         return $model;
  43.     }
  44.  
  45.     public function exportCsvCommission()
  46.     {
  47.         header("Content-type: text/csv");
  48.         header("Content-Disposition: attachment; filename=Commissions.csv");
  49.         header("Pragma: no-cache");
  50.         header("Expires: 0");
  51.  
  52.         $this->getModel('Retailpartnersalesbypartners')->getCsvCommission();
  53.         jexit();
  54.     }
  55.     public function exportCsvOverrides()
  56.     {
  57.         header("Content-type: text/csv");
  58.         header("Content-Disposition: attachment; filename=Overrides.csv");
  59.         header("Pragma: no-cache");
  60.         header("Expires: 0");
  61.  
  62.         $this->getModel('Retailpartnersalesbypartners')->getCsvOverrides();
  63.         //      $this->getModel()->getCsvCommission();
  64.         jexit();
  65.     }
  66.     /**
  67.      * Method to save the submitted ordering values for records via AJAX.
  68.      *
  69.      * @return  void
  70.      *
  71.      * @since   3.0
  72.      */
  73.     public function saveOrderAjax()
  74.     {
  75.         // Get the input
  76.         $input = JFactory::getApplication()->input;
  77.         $pks = $input->post->get('cid', array(), 'array');
  78.         $order = $input->post->get('order', array(), 'array');
  79.  
  80.         // Sanitize the input
  81.         JArrayHelper::toInteger($pks);
  82.         JArrayHelper::toInteger($order);
  83.  
  84.         // Get the model
  85.         $model = $this->getModel();
  86.  
  87.         // Save the ordering
  88.         $return = $model->saveorder($pks, $order);
  89.  
  90.         if ($return)
  91.         {
  92.             echo "1";
  93.         }
  94.  
  95.         // Close the application
  96.         JFactory::getApplication()->close();
  97.     }
  98.  
  99.  
  100.  
  101. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement