Skip to content
Snippets Groups Projects
Select Git revision
  • 61f3054d178688d363006beb0b0458017e91afb9
  • master default
  • Data
  • DataNamespace
  • MCMC
  • CRAN_V2.0.4
  • V2.0.4
  • CRAN_V2.0.3
  • V2.0.3
  • CRAN_V2.0.2
  • V2.0.2
  • CRAN_V2.0.1
  • V2.0.1
  • CRAN_V2.0
  • V2.0
  • V1.0
  • V1.0.submission
17 results

USA_Annuities.xlsx

Blame
  • ordernumber.php 27.56 KiB
    <?php
    /**
     * @package VirtueMart 2 OrderNumber plugin for Joomla! 2.5
     * @author Reinhold Kainhofer, reinhold@kainhofer.com
     * @copyright (C) 2012-2014 - Reinhold Kainhofer
     * @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
    **/
    
    defined('_JEXEC') or     die( 'Direct Access to ' . basename( __FILE__ ) . ' is not allowed.' ) ;
    if (!class_exists('vmShopperPlugin')) 
        require(JPATH_VM_PLUGINS . DS . 'vmshopperplugin.php');
    if (!class_exists( 'VmConfig' )) 
        require(JPATH_ROOT.DS.'administrator'.DS.'components'.DS.'com_virtuemart'.DS.'helpers'.DS.'config.php');
    VmConfig::loadConfig();
    
    class plgVmShopperOrdernumber extends vmShopperPlugin {
    
        function __construct(& $subject, $config) {
            parent::__construct($subject, $config);
            /* Create the database table */
            $this->tableFields = array_keys ($this->getTableSQLFields ());
        }
    
        public function getVmPluginCreateTableSQL () {
            return $this->createTableSQL ('VM Shopper plugin: custom order and invoice numbers');
        }
    
        function getTableSQLFields () {
            $SQLfields = array(
                'id'             => 'int(11) UNSIGNED NOT NULL AUTO_INCREMENT',
                'number_type'    => 'varchar(30)',
                'number_format'  => 'varchar(255)',
                'count'          => 'int(1)',
            );
            return $SQLfields;
        }
    
        // We don't need this function, but the parent class declares it abstract, so we need to overload
        function plgVmOnUpdateOrderBEShopper($_orderID) {}
        
       function _getCounter($nrtype, $format, $default=0) {
            $db = JFactory::getDBO();
            
            /* prevent sql injection attacks by escaping the user-entered format! Empty for global counter... */
            /* For global counting, simply read the empty number_format entries! */
            $q = 'SELECT `count` FROM `'.$this->_tablename.'` WHERE `number_type`='.$db->quote($nrtype).' AND `number_format`='.$db->quote($format);
            $db->setQuery($q);
            $existing = $db->loadResult();
            $count = $existing?$existing:$default;
            return $count;
        }
        
        function _counterExists($nrtype, $format) {
            $db = JFactory::getDBO();
            $q = 'SELECT `count` FROM `'.$this->_tablename.'` WHERE `number_type`='.$db->quote($nrtype).' AND `number_format`='.$db->quote($format);
            $db->setQuery($q);
            return ($db->loadResult() != null);
        }
        
        // Insert new counter value into the db
        function _addCounter($nrtype, $format, $value) {
            $db = JFactory::getDBO();
            $q = 'INSERT INTO `'.$this->_tablename.'` (`count`, `number_type`, `number_format`) VALUES ('.(int)$value.','.$db->quote($nrtype).', '.$db->quote($format).')';
            $db->setQuery( $q );
            $db->query();
            return $db->getAffectedRows();
        }
    
        // Insert new counter value into the db or update existing one
        function _setCounter($nrtype, $format, $value) {