Subversion Repositories SmartDukaan

Rev

Rev 11426 | Go to most recent revision | Details | 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
 
85
		return $responses;
86
	}
87
function curlURL($configurl=null,$methodtype='get',$parameter=array())
88
{
89
		$params ='';
90
		$display='';
91
		$url = $this->config->item('curl_base_url');
92
		$productsurl =$this->config->item($configurl);
93
		if(isset($productsurl['url']) and !empty($productsurl['url']))
94
			{
95
				$url .=$productsurl['url'];
96
				if($productsurl['display'])
97
				{$display=$productsurl['display'];}
98
			if(empty($parameter)){$parameter=$productsurl['params'];}
99
 
100
 
101
		if(isset($parameter) and !empty($parameter) and $methodtype=='get')
102
		{
103
			$params = $this->parser->prepareParams($parameter,$display,$configurl);
104
 
105
		}
106
		if(isset($parameter) and !empty($parameter) and $methodtype=='post')
107
		{
108
			$params = $this->parser->prepareParams($parameter,$display,$configurl);
109
			$methodtype ='post';
110
		}
111
		if(!isset($parameter) || empty($parameter))
112
			{$params =$this->parser->prepareParams('',$display,$configurl);}
113
		 if($configurl == 'payment_process'){
114
		 	$methodtype = 'get';
115
		 }
116
		 if($configurl == 'pickup' || $configurl == 'emi'){
117
		 	$methodtype = 'get';
118
		 	$params = array();
119
		 }
120
		 if($configurl == 'carts'){
121
		 	$methodtype = 'get';
122
		 	$productsparams =$this->config->item($configurl);
123
		 	$productsparams = $productsparams['params'];
124
		 	$i = 0;
125
		 	$newparams = array();
126
		 	foreach($productsparams as $key => $value){
127
		 		if (array_key_exists($value,$params)){
128
    				$newparams[$value] = $params[$value];
129
    				$i++;
130
				}
131
		 	}
132
		 	$params = $newparams;
133
		 }
134
		 if($configurl == 'payment_submit'){
135
		 	$productsparams =$this->config->item($configurl);
136
		 	$productsparams = $productsparams['params'];
137
		 	$i = 0;
138
		 	$newparams = array();
139
		 	foreach($productsparams as $key => $value){
140
		 		if (array_key_exists($value,$params)){
141
    				$newparams[$value] = $params[$value];
142
    				$i++;
143
				}
144
		 	}
145
		 	$params = $newparams;
146
		 }
147
 
148
		return $this->mcurl->add_call($configurl,$methodtype,$url,$params);
149
	}
150
	else
151
		{return '';}
152
 
153
}
154
 
155
}