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 Myaccount_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 getOrder($get=array(),$post=array(),$module=array())
32
	{
33
 
34
		$last = $this->uri->total_segments();
35
		$orderId = $this->uri->segment($last);
36
 
37
		$output =array();
38
		if(isset($module) and !empty($module))
39
		{
40
			if(isset($module['header']) and !empty($module['header']))
41
			{
42
				foreach($module['header'] as $header)
43
				{
44
 
45
					$this->curlURL($header,'get');
46
				}
47
			}
48
			if(isset($module['footer']) and !empty($module['footer']))
49
			{
50
				foreach($module['footer'] as $footer)
51
				{
52
					$this->curlURL($footer,'get');
53
				}
54
			}
55
			if(isset($module['response']) and !empty($module['response']))
56
			{
57
				foreach($module['response'] as $response)
58
				{
59
 
60
					if(isset($post) and !empty($post))
61
					{
62
						if($this->current_client=='magento' )
63
						$this->curlURL($response,'get',$post);
64
					else
65
						$this->curlURL($response,'get',$post);
66
 
67
					}
68
					else
69
					{
70
 
71
						$this->curlURL($response,'get',$get,$orderId);
72
					}
73
				}
74
			}
75
 
76
 
77
		}
78
 
79
		//add_call( KEY, METHOD, URL, array of PARAMS, array of CURL_OPTS )
80
		//$this->curlURL('products','get',$get);
81
		$responses = $this->mcurl->execute();
82
		//print_r($responses);
83
		if(isset($responses) and !empty($responses))
84
		$responses = $this->parser->parse_response($responses,$module);
85
 
86
 
87
		return $responses;
88
	}
89
function curlURL($configurl=null,$methodtype='get',$parameter=array(),$orderId=null)
90
{
91
		$params ='';
92
		$display='';
93
		$url = $this->config->item('curl_base_url');
94
		$productsurl =$this->config->item($configurl);
95
		if(isset($productsurl['url']) and !empty($productsurl['url']))
96
			{
97
				$url .=$productsurl['url'];
98
				if($productsurl['display'])
99
				{$display=$productsurl['display'];}
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
		if(isset($orderId) && $orderId != null && $configurl == 'order_details')
116
			{
117
				$url .= '/'.$orderId;
118
			}
119
		return $this->mcurl->add_call($configurl,$methodtype,$url,$params);
120
	}
121
	else
122
		{return '';}
123
 
124
}
125
 
126
}