File size: 6,734 Bytes
971eb1e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
<?php
/* 

 * Author		= Dian Hermanto

 * Create Date	= 23 Maret 2017

 * File Name	= Scheduling.php

 * Location		= -

*/

if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class C_scheduling extends CI_Controller  

{
 	public function index() // OK

	{
		$sqlApp 		= "SELECT * FROM tappname";
		$resultaApp = $this->db->query($sqlApp)->result();
		foreach($resultaApp as $therow) :
			$appName = $therow->app_name;		
		endforeach;
		
		$url			= site_url('c_project/c_scheduling/listproject/?id='.$this->url_encryption_helper->encode_url($appName));
		redirect($url);
	}
	
	function listproject($offset=0)

	{
		$this->load->model('m_project/m_scheduling/m_scheduling', '', TRUE);
		
		if ($this->session->userdata('login') == TRUE)
		{
			$idAppName	= $_GET['id'];
			$appName	= $this->url_encryption_helper->decode_url($idAppName);
					
			$data['title'] 				= $appName;
			$data['h2_title']			= 'Project List';
			
			$num_rows 					= $this->m_scheduling->count_all_project();
			$data["recordcount"] 		= $num_rows;	 
			$data['vewproject']			= $this->m_scheduling->get_last_ten_project()->result();	
			
			$this->load->view('v_project/v_scheduling/listproject', $data);
		}
		else
		{
			redirect('Auth');
		}
	}

	function get_all_schedule($offset=0) // OK

	{
		$this->load->model('m_project/m_scheduling/m_scheduling', '', TRUE);
		
		if ($this->session->userdata('login') == TRUE)
		{	
			$sqlApp 		= "SELECT * FROM tappname";
			$resultaApp = $this->db->query($sqlApp)->result();
			foreach($resultaApp as $therow) :
				$appName = $therow->app_name;		
			endforeach;
			
			$PRJCODE					= $_GET['id'];
			$PRJCODE					= $this->url_encryption_helper->decode_url($PRJCODE);
			
			$data['title'] 				= $appName;
			$data['h2_title'] 			= 'Vendor Category';
			$data['h3_title'] 			= 'purchase';
			$data['secAddURL'] 			= site_url('c_project/c_scheduling/add/?id='.$this->url_encryption_helper->encode_url($PRJCODE));
			$data["MenuCode"] 			= 'MN117';
			
			$num_rows 					= $this->m_scheduling->count_all_schedule();
			$data['countvendcat'] 		= $num_rows;
	 
			$data['viewvendcat'] 		= $this->m_scheduling->get_all_schedule()->result();
			
			$this->load->view('v_purchase/v_vendcat/vendor_category', $data);
		}
		else
		{
			redirect('Auth');
		}
	}
	
	function add() // OK

	{
		$this->load->model('m_project/m_scheduling/m_scheduling', '', TRUE);
		
		if ($this->session->userdata('login') == TRUE)
		{		
			$sqlApp 		= "SELECT * FROM tappname";
			$resultaApp = $this->db->query($sqlApp)->result();
			foreach($resultaApp as $therow) :
				$appName = $therow->app_name;		
			endforeach;
			
			$PRJCODE	= $_GET['id'];
			$PRJCODE	= $this->url_encryption_helper->decode_url($PRJCODE);
			
			$data['title'] 			= $appName;
			$data['task'] 			= 'add';
			$data['h2_title']		= 'Add Vendor Category';
			$data['h3_title'] 		= 'purchase';
			$data['form_action']	= site_url('c_project/c_scheduling/add_process');
			$data['link'] 			= array('link_back' => anchor('c_project/c_scheduling/','<input type="button" class="btn btn-danger" id="btnCancel" class="button_css" value="Cancel" />', array('style' => 'text-decoration: none;')));
			$data["MenuCode"] 		= 'MN117';
			
			$this->load->view('v_purchase/v_vendcat/vendor_category_form', $data);
		}
		else
		{
			redirect('Auth');
		}
	}
		
	function getVENDCATCODE($cinta) // 

	{ 
		$this->load->model('m_project/m_scheduling/m_scheduling', '', TRUE);
		$recordcountVCAT 	= $this->m_vendcat->count_all_scheduleVCAT($cinta);
		echo $recordcountVCAT;
	}
	
	function add_process() // 

	{
		$this->load->model('m_project/m_scheduling/m_scheduling', '', TRUE);
		
		if ($this->session->userdata('login') == TRUE)
		{
			$vendcat = array('VendCat_Code' 	=> $this->input->post('VendCat_Code'),
							'VendCat_Name'		=> $this->input->post('VendCat_Name'),
							'VendCat_Desc'		=> $this->input->post('VendCat_Desc'));

			$this->m_vendcat->add($vendcat);
						
			$sqlApp 		= "SELECT * FROM tappname";
			$resultaApp = $this->db->query($sqlApp)->result();
			foreach($resultaApp as $therow) :
				$appName = $therow->app_name;		
			endforeach;
			
			$url			= site_url('c_project/c_scheduling/?id='.$this->url_encryption_helper->encode_url($appName));
			redirect($url);
		}
		else
		{
			redirect('Auth');
		}
	}
	
	function update() // 

	{
		$this->load->model('m_project/m_scheduling/m_scheduling', '', TRUE);
		$VendCat_Code	= $_GET['id'];
		$VendCat_Code	= $this->url_encryption_helper->decode_url($VendCat_Code);
		
		if ($this->session->userdata('login') == TRUE)
		{			
			$sqlApp 		= "SELECT * FROM tappname";
			$resultaApp = $this->db->query($sqlApp)->result();
			foreach($resultaApp as $therow) :
				$appName = $therow->app_name;		
			endforeach;
			
			$data['title'] 			= $appName;
			$data['task'] 			= 'edit';
			$data['h2_title']		= 'Edit Vendor Category';
			$data['h3_title'] 		= 'purchase';
			$data['form_action']	= site_url('c_project/c_scheduling/update_process');
			$data['link'] 			= array('link_back' => anchor('c_project/c_scheduling/','<input type="button" class="btn btn-danger" id="btnCancel" class="button_css" value="Cancel" />', array('style' => 'text-decoration: none;')));
			$data["MenuCode"] 		= 'MN117';
			
			$getvendcat 			= $this->m_vendcat->get_vendcat_by_code($VendCat_Code)->row();
			
			$data['default']['VendCat_Code'] = $getvendcat->VendCat_Code;
			$data['default']['VendCat_Name'] = $getvendcat->VendCat_Name;		
			$data['default']['VendCat_Desc'] = $getvendcat->VendCat_Desc;
			
			$this->load->view('v_purchase/v_vendcat/vendor_category_form', $data);
		}
		else
		{
			redirect('Auth');
		}
	}
	
	function update_process() // 

	{
		$this->load->model('m_project/m_scheduling/m_scheduling', '', TRUE);
		
		if ($this->session->userdata('login') == TRUE)
		{
			$VendCat_Code		= $this->input->post('VendCat_Code');
			$VendCat_Name		= $this->input->post('VendCat_Name');
			$VendCat_Desc		= $this->input->post('VendCat_Desc');
			
			$vendcat = array('VendCat_Code' 	=> $VendCat_Code,
							'VendCat_Name' 		=> $VendCat_Name,
							'VendCat_Desc'		=> $VendCat_Desc);
										
			$this->m_vendcat->update($VendCat_Code, $vendcat);
			
			$sqlApp 		= "SELECT * FROM tappname";
			$resultaApp = $this->db->query($sqlApp)->result();
			foreach($resultaApp as $therow) :
				$appName = $therow->app_name;		
			endforeach;
			
			$url			= site_url('c_project/c_scheduling/?id='.$this->url_encryption_helper->encode_url($appName));
			redirect($url);
		}
		else
		{
			redirect('Auth');
		}
	}
}