Subversion Repositories SmartDukaan

Rev

Rev 11426 | 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 Checkout_model extends CI_Model {
11
 
12
	var $url = '';
13
	var $parser_model;
14
	var $parser;
15
	var $current_client='';
16
 
17
	function __construct() {
18
 
19
		// Call the Model constructor
20
		parent::__construct();
21
		//load appropriate parser
22
		$current_client =$this -> config -> item('current_client');
23
		$model = $current_client.'_model';
24
		$this->load->model($model);
25
		$this->parser = $this-> $model;
26
		$this->current_client=$this -> config -> item('current_client');
27
 
28
	}
29
 
30
 
31
 
32
	function getCheckoutDetails($get=array(),$post=array(),$module=array())
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,'post',$post);
62
					else
63
						$this->curlURL($response,'post',$post);
64
 
65
					}
66
					else
67
					{						
68
						$this->curlURL($response,'get',$get);
69
 
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
		return $responses;
85
	}
86
function curlURL($configurl=null,$methodtype='get',$parameter=array())
87
{
88
		$params ='';
89
		$display='';
90
		$url = $this->config->item('curl_base_url');
91
		$productsurl =$this->config->item($configurl);
92
		if(isset($productsurl['url']) and !empty($productsurl['url']))
93
			{
94
				$url .=$productsurl['url'];
95
				if($productsurl['display'])
96
				{$display=$productsurl['display'];}
97
			if(empty($parameter)){$parameter=$productsurl['params'];}
98
 
99
 
100
		if(isset($parameter) and !empty($parameter) and $methodtype=='get')
101
		{
102
			$params = $this->parser->prepareParams($parameter,$display,$configurl);
103
 
104
		}
105
		if(isset($parameter) and !empty($parameter) and $methodtype=='post')
106
		{
107
			$params = $this->parser->prepareParams($parameter,$display,$configurl);
108
			$methodtype ='post';
109
		}
110
		if(!isset($parameter) || empty($parameter))
111
			{$params =$this->parser->prepareParams('',$display,$configurl);}
112
		 if($configurl == 'payment_process'){
113
		 	$methodtype = 'get';
114
		 }
20609 amit.gupta 115
		 if($configurl == 'payment_process1'){
116
		 	$methodtype = 'get';
117
		 }
10582 lgm 118
		 if($configurl == 'pickup' || $configurl == 'emi'){
119
		 	$methodtype = 'get';
120
		 	$params = array();
121
		 }
122
		 if($configurl == 'carts'){
123
		 	$methodtype = 'get';
124
		 	$productsparams =$this->config->item($configurl);
125
		 	$productsparams = $productsparams['params'];
126
		 	$i = 0;
127
		 	$newparams = array();
128
		 	foreach($productsparams as $key => $value){
129
		 		if (array_key_exists($value,$params)){
130
    				$newparams[$value] = $params[$value];
131
    				$i++;
132
				}
133
		 	}
134
		 	$params = $newparams;
135
		 }
136
		 if($configurl == 'payment_submit'){
137
		 	$productsparams =$this->config->item($configurl);
138
		 	$productsparams = $productsparams['params'];
139
		 	$i = 0;
140
		 	$newparams = array();
141
		 	foreach($productsparams as $key => $value){
142
		 		if (array_key_exists($value,$params)){
143
    				$newparams[$value] = $params[$value];
144
    				$i++;
145
				}
146
		 	}
147
		 	$params = $newparams;
148
		 }
149
 
150
		return $this->mcurl->add_call($configurl,$methodtype,$url,$params);
151
	}
152
	else
153
		{return '';}
154
 
155
}
156
 
157
}