<?php

/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: 			*/

// +----------------------------------------------------------------------+

// | PHP version 4/5                                                      |

// +----------------------------------------------------------------------+

// | Copyright (c) 2004-2010 ARMIA INC                                    |

// +----------------------------------------------------------------------+

// | This source file is a part of iScripts VistaCart                     |

// +----------------------------------------------------------------------+

// | Authors: Jipson<jipson.thomas@armiasystems.com>             		  |

// +----------------------------------------------------------------------+ 

class Giftcarduser extends AppModel

{

   var $name 	= 'Giftcarduser';

 

  

  ###### Function toget average rating f a product.............

 	function getTableName($tablename)

		 {

			$Db = ConnectionManager::getDataSource($this->useDbConfig);

			$tblnme = $Db->fullTableName($tablename);			

			$tblnme=trim(str_replace('`','',$tblnme));		

			return $tblnme;

		}

		

		 //Overriding Pagination starts here...

      function paginate($conditions, $fields, $order, $limit, $page = 1, $recursive = null, $extra = array())

	  {										

					//print_r($extra);

					if(!isset($extra['passit']['sort']))

					{

						$extra['passit']['page']= 1;

						$extra['passit']['sort']='Giftcarduser.date';

						$extra['passit']['direction'] ='DESC';

						$order = array($extra['passit']['sort'] => $extra['passit']['direction']);

					}

					else

					{

					  $order = array($extra['passit']['sort'] => $extra['passit']['direction']);		

					}		

					if(isset($extra["joins"]))		 $joins=$extra["joins"]; else  $joins='';

				    if(isset($extra["group"]))		 $group=$extra["group"]; else  $group='';			

					$params = array(

					  'conditions' => $conditions,	

					  'fields' => $fields, 

					  'order' => $order,

					  'limit' => $limit,

					  'joins' => $joins,

					  'page' => $page,

					  'group' => $group,	

					  'passit' => $extra['passit'],	  	 

					);		

					return $this->find('all', $params);		

         }



			function paginateCount($conditions = null, $recursive = 0, $extra = array()) 

			{

				 if(isset($extra["joins"]))		 $joins=$extra["joins"]; else  $joins='';

				 if(isset($extra["group"]))		 $group=$extra["group"]; else  $group='';

				 $params = array(

					  'conditions' => $conditions,	

					  'fields' => '',					 			  

					  'joins' =>  $joins,					 

					  'group' => $group,		  	 

					);		

					return count($this->find('all', $params));	

			}

        //Overriding Pagination starts here...

		

}

?>