Subversion Repositories SmartDukaan

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
12694 anikendra 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
 
34
 
35
		$output =array();
36
		if(isset($module) and !empty($module))
37
		{
38
			if(isset($module['header']) and !empty($module['header']))
39
			{
40
				foreach($module['header'] as $header)
41
				{
42
 
43
					$this->curlURL($header,'get');
44
				}
45
			}
46
			if(isset($module['footer']) and !empty($module['footer']))
47
			{
48
				foreach($module['footer'] as $footer)
49
				{
50
					$this->curlURL($footer,'get');
51
				}
52
			}
53
			if(isset($module['response']) and !empty($module['response']))
54
			{
55
				foreach($module['response'] as $response)
56
				{
57
 
58
					if(isset($post) and !empty($post))
59
					{
60
						if($this->current_client=='magento' )
61
						$this->curlURL($response,'get',$post);
62
					else
63
						$this->curlURL($response,'get',$post);
64
 
65
					}
66
					else
67
					{
68
 
69
						$this->curlURL($response,'get',$get);
70
					}
71
				}
72
			}
73
 
74
 
75
		}
76
 
77
		//add_call( KEY, METHOD, URL, array of PARAMS, array of CURL_OPTS )
78
		//$this->curlURL('products','get',$get);
79
		$responses = $this->mcurl->execute();
80
		//print_r($responses);
81
		if(isset($responses) and !empty($responses))
82
		$responses = $this->parser->parse_response($responses,$module);
83
 
84
 
85
		return $responses;
86
	}
87
function curlURL($configurl=null,$methodtype='get',$parameter=array())
88
{
89
		//echo $configurl;
90
		$params ='';
91
		$display='';
92
		$url = $this->config->item('curl_base_url');
93
		$productsurl =$this->config->item($configurl);
94
		if(isset($productsurl['url']) and !empty($productsurl['url']))
95
			{
96
				$url .=$productsurl['url'];
97
				if($productsurl['display'])
98
				{$display=$productsurl['display'];
99
			}
100
		if(empty($parameter)){$parameter=$productsurl['params'];}
101
 
102
 
103
		if(isset($parameter) and !empty($parameter) and $methodtype=='get')
104
		{
105
			$params = $this->parser->prepareParams($parameter,$display,$configurl);
106
 
107
		}
108
		if(isset($parameter) and !empty($parameter) and $methodtype=='post')
109
		{
110
			$params = $this->parser->prepareParams($parameter,$display,$configurl);
111
			$methodtype ='post';
112
		}
113
		if(!isset($parameter) || empty($parameter))
114
			{$params =$this->parser->prepareParams('',$display,$configurl);}
115
		$productsparams =$this->config->item($configurl);
116
		$productsparams = $productsparams['params'];
117
		$i = 0;
118
		$newparams = array();
119
		foreach($productsparams as $key => $value){
120
		 	if (array_key_exists($value,$params)){
121
    			$newparams[$value] = $params[$value];
122
    			$i++;
123
			}
124
		 }
125
		$params = $newparams;
126
		if($configurl == 'recharge_amount'){
127
			$methodtype = 'get';
128
		}
129
		if($configurl == 'recharge_paymentSubmit'){
130
			$methodtype = 'post';
131
		}
132
		return $this->mcurl->add_call($configurl,$methodtype,$url,$params);
133
	}
134
	else
135
		{return '';}
136
 
137
}
138
 
139
}