Subversion Repositories SmartDukaan

Rev

Rev 12694 | Details | Compare with Previous | 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 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
 
12738 anikendra 35
		error_log("[GETCHECKOUTDETAILS] POST ".print_r($post,1));
12694 anikendra 36
		$output =array();
37
		if(isset($module) and !empty($module))
38
		{
39
			if(isset($module['header']) and !empty($module['header']))
40
			{
41
				foreach($module['header'] as $header)
42
				{
43
 
44
					$this->curlURL($header,'get');
45
				}
46
			}
47
			if(isset($module['footer']) and !empty($module['footer']))
48
			{
49
				foreach($module['footer'] as $footer)
50
				{
51
					$this->curlURL($footer,'get');
52
				}
53
			}
54
			if(isset($module['response']) and !empty($module['response']))
55
			{
56
				foreach($module['response'] as $response)
57
				{
58
 
59
					if(isset($post) and !empty($post))
60
					{
61
						if($this->current_client=='magento' )
62
						$this->curlURL($response,'post',$post);
63
					else
64
						$this->curlURL($response,'post',$post);
65
 
66
					}
67
					else
68
					{						
69
						$this->curlURL($response,'get',$get);
70
 
71
					}
72
				}
73
			}
74
 
75
 
76
		}
77
 
78
		//add_call( KEY, METHOD, URL, array of PARAMS, array of CURL_OPTS )
79
		//$this->curlURL('products','get',$get);
80
		$responses = $this->mcurl->execute();
81
		//print_r($responses);
82
		if(isset($responses) and !empty($responses))
83
		$responses = $this->parser->parse_response($responses,$module);
84
		log_message('debug',"[GETCHECKOUTDETAILS] Response ".print_r($responses,1));
85
 
86
		return $responses;
87
	}
88
function curlURL($configurl=null,$methodtype='get',$parameter=array())
89
{
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
			if(empty($parameter)){$parameter=$productsurl['params'];}
100
 
101
 
102
		if(isset($parameter) and !empty($parameter) and $methodtype=='get')
103
		{
104
			$params = $this->parser->prepareParams($parameter,$display,$configurl);
105
 
106
		}
107
		if(isset($parameter) and !empty($parameter) and $methodtype=='post')
108
		{
109
			$params = $this->parser->prepareParams($parameter,$display,$configurl);
110
			$methodtype ='post';
111
		}
112
		if(!isset($parameter) || empty($parameter))
113
			{$params =$this->parser->prepareParams('',$display,$configurl);}
114
		 if($configurl == 'payment_process'){
115
		 	$methodtype = 'get';
116
		 }
117
		 if($configurl == 'pickup' || $configurl == 'emi'){
118
		 	$methodtype = 'get';
119
		 	$params = array();
120
		 }
121
		 if($configurl == 'carts'){
122
		 	$methodtype = 'get';
123
		 	$productsparams =$this->config->item($configurl);
124
		 	$productsparams = $productsparams['params'];
125
		 	$i = 0;
126
		 	$newparams = array();
127
		 	foreach($productsparams as $key => $value){
128
		 		if (array_key_exists($value,$params)){
129
    				$newparams[$value] = $params[$value];
130
    				$i++;
131
				}
132
		 	}
133
		 	$params = $newparams;
134
		 }
135
		 if($configurl == 'payment_submit'){
136
		 	$productsparams =$this->config->item($configurl);
137
		 	$productsparams = $productsparams['params'];
138
		 	$i = 0;
139
		 	$newparams = array();
140
		 	foreach($productsparams as $key => $value){
141
		 		if (array_key_exists($value,$params)){
142
    				$newparams[$value] = $params[$value];
143
    				$i++;
144
				}
145
		 	}
146
		 	$params = $newparams;
147
		 }
148
 
149
		return $this->mcurl->add_call($configurl,$methodtype,$url,$params);
150
	}
151
	else
152
		{return '';}
153
 
154
}
155
 
156
}