Subversion Repositories SmartDukaan

Rev

Rev 12996 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
10582 lgm 1
<?php
2
if (!defined('BASEPATH'))
3
	exit('No direct script access allowed');
4
 
5
 
6
/*
7
 * Model for home
8
 */ 
9
 
10
Class Recharge_model extends CI_Model {
11
 
12
	var $url = '';
13
	var $parser_model;
14
	var $parser;
15
 
16
	function __construct() {
17
 
18
		// Call the Model constructor
19
		parent::__construct();
20
		//load appropriate parser
21
		$this->current_client =$this -> config -> item('current_client');
22
		$model = $this->current_client.'_model';
23
		$this->load->model($model);
24
		$this->parser = $this-> $model;
25
 
26
 
27
	}
28
 
29
 
30
 
31
	function getList($get=array(),$post=array(),$module=array())
32
	{
33
		$output =array();
34
		if(isset($module) and !empty($module))
35
		{
36
			if(isset($module['header']) and !empty($module['header']))
37
			{
38
				foreach($module['header'] as $header)
39
				{
40
 
41
					$this->curlURL($header,'get');
42
				}
43
			}
44
			if(isset($module['footer']) and !empty($module['footer']))
45
			{
46
				foreach($module['footer'] as $footer)
47
				{
48
					$this->curlURL($footer,'get');
49
				}
50
			}
51
			if(isset($module['response']) and !empty($module['response']))
52
			{
53
				foreach($module['response'] as $response)
54
				{
55
 
56
					if(isset($post) and !empty($post))
57
					{
58
						if($this->current_client=='magento' )
59
						$this->curlURL($response,'get',$post);
60
					else
61
						$this->curlURL($response,'get',$post);
62
 
63
					}
64
					else
65
					{
66
 
67
						$this->curlURL($response,'get',$get);
68
					}
69
				}
70
			}
71
 
72
 
73
		}
12996 anikendra 74
		$responses = $this->mcurl->execute();		
10582 lgm 75
		if(isset($responses) and !empty($responses))
76
		$responses = $this->parser->parse_response($responses,$module);
77
		return $responses;
78
	}
79
function curlURL($configurl=null,$methodtype='get',$parameter=array())
80
{
81
		//echo $configurl;
82
		$params ='';
83
		$display='';
84
		$url = $this->config->item('curl_base_url');
85
		$productsurl =$this->config->item($configurl);
86
		if(isset($productsurl['url']) and !empty($productsurl['url']))
87
			{
88
				$url .=$productsurl['url'];
15788 amit.gupta 89
				if(isset($productsurl['display']) and !empty($productsurl['display'])){
90
					$display=$productsurl['display'];
91
				}
10582 lgm 92
		if(empty($parameter)){$parameter=$productsurl['params'];}
93
 
94
 
95
		if(isset($parameter) and !empty($parameter) and $methodtype=='get')
96
		{
97
			$params = $this->parser->prepareParams($parameter,$display,$configurl);
98
 
99
		}
100
		if(isset($parameter) and !empty($parameter) and $methodtype=='post')
101
		{
102
			$params = $this->parser->prepareParams($parameter,$display,$configurl);
103
			$methodtype ='post';
104
		}
105
		if(!isset($parameter) || empty($parameter))
106
			{$params =$this->parser->prepareParams('',$display,$configurl);}
107
		$productsparams =$this->config->item($configurl);
108
		$productsparams = $productsparams['params'];
109
		$i = 0;
110
		$newparams = array();
111
		foreach($productsparams as $key => $value){
112
		 	if (array_key_exists($value,$params)){
113
    			$newparams[$value] = $params[$value];
114
    			$i++;
115
			}
116
		 }
117
		$params = $newparams;
118
		if($configurl == 'recharge_amount'){
119
			$methodtype = 'get';
120
		}
121
		if($configurl == 'recharge_paymentSubmit'){
122
			$methodtype = 'post';
123
		}
124
		return $this->mcurl->add_call($configurl,$methodtype,$url,$params);
125
	}
126
	else
127
		{return '';}
128
 
129
}
130
 
131
}