EVOLUTION-NINJA
Edit File: Controller.php
<?php defined('BASEPATH') OR exit('No direct script access allowed'); class Controller extends CI_Controller { function __construct() { parent:: __construct(); $this->load->model('Model'); ini_set('max_execution_time', 30000); $this->output->set_header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); // Prevent caching $this->output->set_header('Strict-Transport-Security: max-age=31536000; includeSubDomains'); $this->output->set_header('Content-Security-Policy: default-src \'self\'; script-src \'self\' \'unsafe-inline\' \'unsafe-eval\'; style-src \'self\' \'unsafe-inline\'; img-src \'self\' data:;'); $this->output->set_header('X-Content-Type-Options: nosniff'); $this->output->set_header('X-Frame-Options: SAMEORIGIN'); $this->output->set_header('X-XSS-Protection: 1; mode=block'); $this->output->set_header('Permissions-Policy: accelerometer=(), camera=(), geolocation=(), microphone=()'); $this->output->set_header('Referrer-Policy: strict-origin-when-cross-origin'); $this->output->set_header('Cache-Control: no-store, no-cache, must-revalidate, proxy-revalidate'); $this->output->set_header('Pragma: no-cache'); $this->output->set_header('X-Powered-By:'); $this->output->set_header('X-Powered-By:'); } public function index() { $sessionData = $this->decryptSessionData(); // print_r($sessionData);die(); if($login && $id){ $login = $sessionData['login']; $id = $sessionData['id']; $id1 = $sessionData['id1']; $id2= $sessionData['id2']; $id3 = $sessionData['id3']; $id4 = $sessionData['id4']; if(($login==1) && (!empty($id1))) { $table='profile'; $where=array('id'=>$id); $data['details']=$this->model->get_where_row($table,$where); $table='news'; $data['news']=$this->model->get_all_data($table); $data['years']=$this->model->news_year(); $data['feedback'] =$this->model->get_opinions(); $table = "feedback_count"; $where = array('delete_status'=>'ACTIVE'); $data['feedback_count'] =$this->model->get_feedback_count($table,$where); $this->load->view('includes/admin_header',$data); // $this->load->view('new_dashboard',$data); $this->load->view('news',$data); $this->load->view('includes/admin_footer',$data); } else if(($login==2) && (!empty($id2))) { $table1='supervisor'; $where1=array('id'=>$id); $data['details']=$this->model->get_where_row($table1,$where1); $table='news'; $data['news']=$this->model->get_all_data($table); //print_r($data['details']); $this->load->view('admin_index',$data); } else if(($login==3) && (!empty($id3))) { $table1='supervisor'; $where1=array('id'=>$id); $data['details']=$this->model->get_where_row($table1,$where1); $table='news'; $data['news']=$this->model->get_all_data($table); $this->load->view('region_news_view',$data); } else if(($login==4) && (!empty($id4))) { $table1='supervisor'; $where1=array('id'=>$id); $data['details']=$this->model->get_where_row($table1,$where1); $table='news'; $data['news']=$this->model->get_all_data($table); $this->load->view('includes/header',$data); $this->load->view('news',$data); $this->load->view('includes/footer',$data); }else { redirect('controller/logout'); } }else { $table = "home_page_images"; $where = array('delete_status'=>'ACTIVE','approve_status'=>'APPROVED'); $data['images'] =$this->model->fetch_where_data($table,$where); $data['feedback'] =$this->model->get_opinions(); $table = "feedback_count"; $where = array('delete_status'=>'ACTIVE'); $data['feedback_count'] =$this->model->get_feedback_count($table,$where); $table='news'; $data['news']=$this->model->get_all_data($table); $data['years']=$this->model->news_year(); $this->load->view('login',$data); } } // public function index() // { // if($this->session->userdata('login') && $this->session->userdata('id')){ // $login=$this->session->userdata('login'); // $id=$this->session->userdata('id'); // $id1=$this->session->userdata('id1'); // $id2=$this->session->userdata('id2'); // $id3=$this->session->userdata('id3'); // $id4=$this->session->userdata('id4'); // if(($login==1) && (!empty($id1))) // { // $table='profile'; // $where=array('id'=>$id); // $data['details']=$this->model->get_where_row($table,$where); // $table='news'; // $data['news']=$this->model->get_all_data($table); // $data['years']=$this->model->news_year(); // $data['feedback'] =$this->model->get_opinions(); // $table = "feedback_count"; // $where = array('delete_status'=>'ACTIVE'); // $data['feedback_count'] =$this->model->get_feedback_count($table,$where); // $this->load->view('includes/admin_header',$data); // // $this->load->view('new_dashboard',$data); // $this->load->view('news',$data); // $this->load->view('includes/admin_footer',$data); // } // else if(($login==2) && (!empty($id2))) // { // $table1='supervisor'; // $where1=array('id'=>$id); // $data['details']=$this->model->get_where_row($table1,$where1); // $table='news'; // $data['news']=$this->model->get_all_data($table); // //print_r($data['details']); // $this->load->view('admin_index',$data); // } // else if(($login==3) && (!empty($id3))) // { // $table1='supervisor'; // $where1=array('id'=>$id); // $data['details']=$this->model->get_where_row($table1,$where1); // $table='news'; // $data['news']=$this->model->get_all_data($table); // $this->load->view('region_news_view',$data); // } // else if(($login==4) && (!empty($id4))) // { // $table1='supervisor'; // $where1=array('id'=>$id); // $data['details']=$this->model->get_where_row($table1,$where1); // $table='news'; // $data['news']=$this->model->get_all_data($table); // $this->load->view('includes/header',$data); // $this->load->view('news',$data); // $this->load->view('includes/footer',$data); // }else // { // redirect('controller/logout'); // } // }else // { // $table = "home_page_images"; // $where = array('delete_status'=>'ACTIVE','approve_status'=>'APPROVED'); // $data['images'] =$this->model->fetch_where_data($table,$where); // $data['feedback'] =$this->model->get_opinions(); // $table = "feedback_count"; // $where = array('delete_status'=>'ACTIVE'); // $data['feedback_count'] =$this->model->get_feedback_count($table,$where); // $table='news'; // $data['news']=$this->model->get_all_data($table); // $data['years']=$this->model->news_year(); // $this->load->view('login',$data); // } // } public function admin() { $sessionData = $this->decryptSessionData(); if (!$sessionData || !isset($sessionData['id']) || $sessionData['role'] != '1') { redirect('controller/login'); } $w=array('id'=>1); $t='supervisor'; $data['details']=$this->model->get_where_row($t,$w); $this->load->view('admin_index',$data); } public function login() { date_default_timezone_set('Asia/Kolkata'); if($this->session->userdata('id') == ''){ $table='profile'; $email=$this->input->post('email'); $password=$this->input->post('password'); // $currentIp = $this->input->ip_address(); $where=array('uid'=>$email,'password'=>$password); $user=$this->model->get_where_row($table,$where); $table1='supervisor'; $where1=array('usercode'=>$email,'password'=>$password); $user1=$this->model->get_where_row($table1,$where1); $table2='robotics_registration'; $where2=array('email'=>$email,'password'=>$password); $user2=$this->model->get_where_row($table2,$where2); $loginAttempts = $this->session->userdata('login_attempts') ?? 0; if ($loginAttempts >= 5) { $this->session->set_flashdata('msg2', '<div class="alert alert-danger text-center">Account locked due to too many failed attempts. Try again later.</div>'); redirect('/'); return; } // $this->db->where('login_time <', date('Y-m-d H:i:s', strtotime('-1 hours')))->delete('active_sessions'); // if ($this->db->where('email', $email)->where('ip_address !=', $currentIp)->get('active_sessions')->row()) { // $this->session->set_flashdata('msg2', '<div class="alert alert-danger text-center">Concurrent login detected from another IP address.</div>'); // redirect('/'); // return; // } if(!empty($user)) { $this->session->unset_userdata('login_attempts'); $session=array('id'=>$user->id,'uid'=>$user->uid,'role'=>$user->role,'region'=>$user->region, 'company_name'=>$user->company_name,'mobile'=>$user->mobile,'email'=>$user->email,'password'=>$user->password, 'login'=>1,'id1'=>$user->id); $encryptedSessionData = $this->encryption->encrypt(json_encode($session)); $this->session->set_userdata('session_ci', $encryptedSessionData); // $this->db->insert('active_sessions', [ // 'email' => $email, // 'ip_address' => $currentIp, // 'login_time' => date('Y-m-d H:i:s') // ]); $table='profile'; $where=array('uid'=>$email,'password'=>$password); $data['details']=$this->model->get_where_row($table,$where); $table='news'; $data['news']=$this->model->get_all_data($table); $data['years']=$this->model->news_year(); $data['feedback'] =$this->model->get_opinions(); $table = "feedback_count"; $where = array('delete_status'=>'ACTIVE'); $data['feedback_count'] =$this->model->get_feedback_count($table,$where); $this->load->view('includes/admin_header',$data); // $this->load->view('new_dashboard',$data); $this->load->view('news',$data); $this->load->view('includes/admin_footer',$data); } elseif(!empty($user2)) { if($user2->role==1) { $this->load->view('robotics_form'); } elseif($user2->role==2) { $table = 'robotics_details'; $data['res'] = $this->model->get_all_disctinct_data($table); $table2 = 'robotics_details'; $data['robot'] = $this->model->get_all_data($table2); $this->load->view('robotics_user_list',$data); } } elseif(!empty($user1)) { if($user1->role==1) { // $this->db->insert('active_sessions', [ // 'email' => $email, // 'ip_address' => $currentIp, // 'login_time' => date('Y-m-d H:i:s') // ]); $session=array('id'=>$user1->id,'region'=>$user1->region,'usercode'=>$user1->usercode,'username'=>$user1->username, 'password'=>$user1->password,'email'=>$user1->email,'department'=>$user1->department,'role'=>$user1->role, 'user_dept'=>$user1->user_dept,'login'=>2,'id2'=>$user1->id); // $this->session->set_userdata($session); $encryptedSessionData = $this->encryption->encrypt(json_encode($session)); $this->session->set_userdata('session_ci', $encryptedSessionData); $table1='supervisor'; $where1=array('usercode'=>$email,'password'=>$password); $data['details']=$this->model->get_where_row($table1,$where1); $table='news'; $data['news']=$this->model->get_all_data($table); //print_r($data['details']); $this->load->view('admin_index',$data); } elseif($user1->role==8) { // $this->db->insert('active_sessions', [ // 'email' => $email, // 'ip_address' => $currentIp, // 'login_time' => date('Y-m-d H:i:s') // ]); $session=array('id'=>$user1->id,'usercode'=>$user1->usercode,'region'=>$user1->region,'username'=>$user1->username, 'password'=>$user1->password,'email'=>$user1->email,'department'=>$user1->department,'role'=>$user1->role, 'user_dept'=>$user1->user_dept,'login'=>3,'id3'=>$user1->id); $encryptedSessionData = $this->encryption->encrypt(json_encode($session)); $this->session->set_userdata('session_ci', $encryptedSessionData); $table1='supervisor'; $where1=array('usercode'=>$email,'password'=>$password); $data['details']=$this->model->get_where_row($table1,$where1); // $table='news'; // $data['news']=$this->model->get_all_data($table); $this->load->view('region_news_view',$data); } else { // $this->db->insert('active_sessions', [ // 'email' => $email, // 'ip_address' => $currentIp, // 'login_time' => date('Y-m-d H:i:s') // ]); $session=array('id'=>$user1->id,'usercode'=>$user1->usercode,'region'=>$user1->region,'username'=>$user1->username, 'password'=>$user1->password,'email'=>$user1->email,'department'=>$user1->department, 'role'=>$user1->role,'user_dept'=>$user1->user_dept,'login'=>4,'id4'=>$user1->id); // $this->session->set_userdata($session); $encryptedSessionData = $this->encryption->encrypt(json_encode($session)); $this->session->set_userdata('session_ci', $encryptedSessionData); $table1='supervisor'; $where1=array('usercode'=>$email,'password'=>$password); // print_r($where1);die(); $data['details']=$this->model->get_where_row($table1,$where1); $table='news'; $data['news']=$this->model->get_all_data($table); $this->load->view('includes/header',$data); $this->load->view('news',$data); $this->load->view('includes/footer',$data); } } else { $this->session->set_userdata('login_attempts', $loginAttempts + 1); $this->session->set_flashdata('msg2', '<div class="alert alert-danger text-center">Wrong Credentials</div>'); redirect('/'); //echo '<script>alert("Check Your credentials"); window.location.href="controller/index?status=invalid"</script>'; //redirect('controller/index?status=invalid'); } } else { $this->session->set_flashdata('msg2', '<div class="alert alert-danger text-center">Please Login With New Browser.</div>'); redirect('/'); //redirect('controller/index?status=invalid'); } } private function decryptSessionData() { $this->load->library('encryption'); $encryptedSession = $this->session->userdata('session_ci'); if ($encryptedSession) { return json_decode($this->encryption->decrypt($encryptedSession), true); } return null; } public function user_dashboard() { // if($this->session->userdata('uid')== ''){redirect('controller/index');} $sessionData = $this->decryptSessionData(); $uid=$sessionData['uid']; if($uid == ''){ redirect('controller/index'); } else { $table='profile'; $where=array('uid'=>$sessionData['uid']); $data['details']=$this->model->get_where_row($table,$where); $table='news'; $data['news']=$this->model->get_all_data($table); $data['years']=$this->model->news_year(); $data['feedback'] =$this->model->get_opinions(); $table = "feedback_count"; $where = array('delete_status'=>'ACTIVE'); $data['feedback_count'] =$this->model->get_feedback_count($table,$where); $this->load->view('includes/admin_header',$data); // $this->load->view('new_dashboard',$data); $this->load->view('news',$data); $this->load->view('includes/admin_footer',$data); } } public function product() { $sessionData = $this->decryptSessionData(); if (!$sessionData || !isset($sessionData['id']) || $sessionData['role'] != '1' ) { redirect('controller/login'); } $table='news'; $data['news']=$this->model->get_all_data($table); //print_r($data['details']); $this->load->view('admin_index',$data); } public function forgotpass() { $this->load->view('forgot_password'); } public function forgot_password() { $uid = $this->input->post('email'); $login_table = 'profile'; $login_table1 = 'supervisor'; $check_email = array('uid'=>$uid ); $check_email1 = array('usercode'=>$uid ); $checkingemail = $this->model->get_where_row($login_table,$check_email); $checkingemail1 = $this->model->get_where_row($login_table1,$check_email1); if($checkingemail) { $email=$checkingemail->email; $this->load->library('email'); $this->email->set_mailtype('html'); $chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; $password = substr( str_shuffle( $chars ), 0, 8 ); $password1= md5($password); $table='profile'; // $data=array('password'=>$password); // $query =$this->model->update_new($check_email,$table,$data); $msg = "Hello"." ".$checkingemail->first_name.'('.$check_email.')'." Wants to know his password.".'<br/><br/>'."Thank you".'<br/>'."Myvote Team"; $this->email->from('notify@yaskawa.in', 'Yaskawa'); //$this->email->to($checkingemail->email); $this->email->to('pradeepkumar_a@yaskawa.in'); $this->email->subject('Yaskawa Temporary Password'); $data['message'] = $msg; $this->email->message($msg); $this->email->send(); $msg="Temporary Password is sent your email please check or No Records found with credentials"; redirect('controller/index'); } elseif($checkingemail1) { $email=$checkingemail1->email; $this->load->library('email'); $this->email->set_mailtype('html'); $chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; $password = substr( str_shuffle( $chars ), 0, 8 ); $password1= md5($password); $table='supervisor'; $data=array('password'=>$password); $query =$this->model->update_new($check_email1,$table,$data); $msg = "Hello"." ".$checkingemail1->username.','.'<br/><br/>'."Your Temporary Password is"." ".$password.'<br/><br/>'."Thank you".'<br/>'."Myvote Team"; $this->email->from('notify@yaskawa.in', 'Yaskawa'); $this->email->to($checkingemail1->email); $this->email->subject('Yaskawa Temporary Password'); $data['message'] = $msg; $this->email->message($msg); $this->email->send(); $msg="Temporary Password is sent your email please check or No Records found with credentials"; redirect('controller/index'); } else { $msg="Please check your Email id."; redirect('controller/index'); } } public function change_password() { $this->load->view('change_password'); } public function change_old_password() { // if($this->session->userdata('user_id')== ''){redirect('controller/index');} $sessionData = $this->decryptSessionData(); $user_id=$sessionData['user_id']; if($user_id ==''){ redirect('controller/index'); } //$id=$this->input->post('user_id'); $new=$this->input->post('new'); // $userid=$this->session->userdata('user_id'); $userid=$sessionData['user_id']; $table="profile"; $where=array('user_id'=>$userid); $data=array('password'=>$new); $this->model->update_new($where,$table,$data); redirect('controller/manage_user'); } public function profile() { // $role=$this->session->userdata('role'); // $id=$this->session->userdata('id'); $sessionData = $this->decryptSessionData(); if (!isset($sessionData['id'], $sessionData['role'])) { redirect('/'); return; } $id = $sessionData['id']; $role = $sessionData['role']; if($id){ if($role==3) { $w=array('id'=>$id); $t='profile'; $data['details']=$this->model->get_where_row($t,$w); $this->load->view('includes/admin_header',$data); $this->load->view('profile',$data); $this->load->view('includes/admin_footer',$data); } else { $w=array('id'=>$id); $t='supervisor'; $data['details']=$this->model->get_where_row($t,$w); // print_r($data['details']);die(); $this->load->view('supervisor_profile',$data); } }else { redirect('/'); } } public function profile_insert() { $ui=$this->input->post('ui'); $company_name=$this->input->post('first_name'); $address=$this->input->post('address'); $city=$this->input->post('city'); $state=$this->input->post('state'); $pin=$this->input->post('pin'); $landline=$this->input->post('landline'); $mobile1=$this->input->post('mobile1'); $mobile2=$this->input->post('mobile2'); $email1=$this->input->post('email1'); $email2=$this->input->post('email2'); $pan=$this->input->post('pan'); $tin=$this->input->post('tin'); $role=$this->input->post('role'); $pass1=$this->input->post('password'); //$pass2=$this->input->post('pass2'); if(is_uploaded_file($_FILES['image']['tmp_name'])) { $sourcePath = $_FILES['image']['tmp_name']; $targetPath = "uploads/".$_FILES['image']['name']; move_uploaded_file($_FILES['image']['tmp_name'],$targetPath); } $table='profile'; $where=array('uid'=>$ui); $unique=$this->model->get_where_row($table,$where); if(count($unique)>0) { return true; } else{ $data=array('uid'=>$ui,'company_name'=>$company_name,'address'=>$address,'city'=>$city,'state'=>$state,'pin'=>$pin,'landline'=>$landline,'mobile'=>$mobile1,'alt_mobile'=>$mobile2,'email'=>$email1,'alt_email'=>$email2,'password'=>$pass1,'pan'=>$pan,'tin'=>$tin,'attachments'=>$targetPath,'role'=>$role); $this->model->insert($table,$data); return false; } } public function update_profile() { // $id=$this->session->userdata('id'); $sessionData = $this->decryptSessionData(); $id = $sessionData['id']; if($id){ $company_name=$this->input->post('username'); $mobile1=$this->input->post('mobile'); $email1=$this->input->post('email'); $table='supervisor'; $where=array('id'=>$id); $data=array('phone'=>$mobile1,'email'=>$email1,'username'=>$company_name); $this->model->update_new($where,$table,$data); redirect('controller/profile'); }else { redirect('/'); } } public function profile_update() { // $id=$this->session->userdata('id'); $sessionData = $this->decryptSessionData(); $id = $sessionData['id']; $ui=$this->input->post('ui'); $company_name=$this->input->post('first_name'); $address=$this->input->post('address'); $city=$this->input->post('city'); $state=$this->input->post('state'); $pin=$this->input->post('pin'); $landline=$this->input->post('landline'); $mobile1=$this->input->post('mobile1'); $mobile2=$this->input->post('mobile2'); $email1=$this->input->post('email1'); $email2=$this->input->post('email2'); $pan=$this->input->post('pan'); $tin=$this->input->post('tin'); $role=$this->input->post('role'); $pass1=$this->input->post('password'); //$pass2=$this->input->post('pass2'); if(is_uploaded_file($_FILES['image']['tmp_name'])) { $sourcePath = $_FILES['image']['tmp_name']; $targetPath = "uploads/".$_FILES['image']['name']; move_uploaded_file($_FILES['image']['tmp_name'],$targetPath); } $table='profile'; $where=array('id'=>$id,'uid'=>$ui); $unique=$this->model->get_where_row($table,$where); if(count($unique)>0) { return false; } else { $table='profile'; $where1=array('id'=>$id,'uid'=>$ui); $data1=array('uid'=>$ui,'company_name'=>$company_name,'address'=>$address,'city'=>$city,'state'=>$state,'pin'=>$pin,'landline'=>$landline,'mobile'=>$mobile1,'alt_mobile'=>$mobile2,'email'=>$email1,'alt_email'=>$email2,'password'=>$pass1,'pan'=>$pan,'tin'=>$tin,'attachments'=>$targetPath,'role'=>$role); $this->model->update_new($where1,$table,$data1); return true; } } public function stock_updates() { $sessionData = $this->decryptSessionData(); $id = $sessionData['id']; $role = $sessionData['role']; if($id){ if($role==3) { $w=array('id'=>$id); $t='profile'; $data['details']=$this->model->get_where_row($t,$w); } else { $w=array('id'=>$id); $t='supervisor'; $data['details']=$this->model->get_where_row($t,$w); } $tab="stock_info"; $data['time']=$this->model->get_time($tab); $this->load->view('includes/admin_header',$data); $this->load->view('stock_updates',$data); $this->load->view('includes/admin_footer',$data); }else { redirect('/'); } } public function po_acknowledgemets() { $sessionData = $this->decryptSessionData(); // Check if session is valid if (!isset($sessionData['id'], $sessionData['role'])) { redirect('/'); // Redirect if session is invalid return; } $id = $sessionData['id']; $role = $sessionData['role']; if($id){ if($role==3) { $id1=$this->session->userdata('uid'); $w=array('id'=>$id); $t='profile'; $data['details']=$this->model->get_where_row($t,$w); $table='po_info'; $data['acknowledgemets']=$this->model->partner_code($table,$id1); } else { $w=array('id'=>$id); $t='supervisor'; $data['details']=$this->model->get_where_row($t,$w); $data['acknowledgemets']=""; } $this->load->view('includes/admin_header',$data); $this->load->view('po_acknowledgemets',$data); $this->load->view('includes/admin_footer',$data); }else { redirect('/'); } } public function outstanding_display_insert() { /*$table='fin_outstanding'; $id=$this->session->userdata('uid'); $details=$this->model->partner_code($table,$id); echo json_encode($details);*/ $id=$this->session->userdata('uid'); $page = isset($_POST['page'])?$_POST['page']:1; $limit = isset($_POST['rows'])?$_POST['rows']:10; $sidx = isset($_POST['sidx'])?$_POST['sidx']:'id'; $sord = isset($_POST['sord'])?$_POST['sord']:''; $totalrows = isset($_REQUEST['totalrows']) ? $_REQUEST['totalrows']: false; if($totalrows) { $limit = $totalrows; } $start = $limit*$page - $limit; $start = ($start<0)?0:$start; $where = ""; $searchField = isset($_POST['searchField']) ? $_POST['searchField'] : false; $searchOper = isset($_POST['searchOper']) ? $_POST['searchOper']: false; $searchString = isset($_POST['searchString']) ? $_POST['searchString'] : false; if(!$sidx) $sidx =1; //$count = $this->db->count_all_results('rate'); $whers=array('status'=>0); $table='fin_outstanding'; $count = $this->model->partner_code1($table,$whers,$id); //echo $count; $count=count($count); if( $count > 0 ) { $total_pages = ceil($count/$limit); //echo $total_pages; } else { $total_pages = 0; } if ($page > $total_pages) $page=$total_pages; $query = $this->model->getdata2($start,$limit,$sidx,$sord,$whers,$table,$id); //print_r($query); $responce = array(); $responce["page"] = $page; $responce["total"] = $total_pages; $responce["records"] = $count; $i=0; foreach($query as $row) { $responce["rows"][$i]['id']=$row->id; $responce["rows"][$i]['cell']=array($row->id,$row->partner_code,$row->partner_name,$row->invoice_number,$row->invoice_ref_no,$row->invoicedate,$row->invoice_value,$row->due_date); $i++; } echo json_encode($responce); } public function outstanding_statement() { // $role=$this->session->userdata('role'); // $department=$this->session->userdata('department'); // $id=$this->session->userdata('id'); $sessionData = $this->decryptSessionData(); // Check if session is valid if (!isset($sessionData['id'], $sessionData['role'], $sessionData['department'])) { redirect('/'); // Redirect if session is invalid return; } $id = $sessionData['id']; $role = $sessionData['role']; $department= $sessionData['department']; if (!($role == '2' && $department == '5') && !($role == '2' && $department == '7') && $role != '3') { log_message('error', "Unauthorized access attempt. Role: $role, Department: $department"); redirect('/'); return; } if($role==3) { $w=array('id'=>$id); $t='profile'; $data['details']=$this->model->get_where_row($t,$w); } else { $w=array('id'=>$id); $t='supervisor'; $data['details']=$this->model->get_where_row($t,$w); } $tab="fin_outstanding"; $data['time']=$this->model->get_time($tab); $this->load->view('outstanding_statement',$data); } public function overdue_statement() { // $role=$this->session->userdata('role'); // $department=$this->session->userdata('department'); // $id=$this->session->userdata('id'); $sessionData = $this->decryptSessionData(); // Check if session is valid if (!isset($sessionData['id'], $sessionData['role'], $sessionData['department'])) { redirect('/'); // Redirect if session is invalid return; } $id = $sessionData['id']; $role = $sessionData['role']; $department= $sessionData['department']; if (!($role == '2' && $department == '5') && !($role == '2' && $department == '7') && $role != '3') { log_message('error', "Unauthorized access attempt. Role: $role, Department: $department"); redirect('/'); return; } if($role==3) { $w=array('id'=>$id); $t='profile'; $data['details']=$this->model->get_where_row($t,$w); } else { $w=array('id'=>$id); $t='supervisor'; $data['details']=$this->model->get_where_row($t,$w); } $tab="fin_overdue"; $data['time']=$this->model->get_time($tab); $this->load->view('overdue_statement',$data); } public function drive_catalogues() { // $role=$this->session->userdata('role'); // $id=$this->session->userdata('id'); $sessionData = $this->decryptSessionData(); // Check if session is valid if (!isset($sessionData['id'], $sessionData['role'])) { redirect('/'); // Redirect if session is invalid return; } $id = $sessionData['id']; $role = $sessionData['role']; if($id){ if($role==3) { $w=array('id'=>$id); $t='profile'; $data['details']=$this->model->get_where_row($t,$w); } else { $w=array('id'=>$id); $t='supervisor'; $data['details']=$this->model->get_where_row($t,$w); } $table="manuals"; $data['products']=$this->model->products(); $data['manuals']=$this->model->get_all_data($table); $data['time']=$this->model->get_time($table); $this->load->view('includes/admin_header',$data); $this->load->view('drive_catalogues',$data); $this->load->view('includes/admin_footer',$data); }else { redirect('/'); } } public function drive_catalogues_import() { $product_name=$this->input->post('product_name'); $category=$this->input->post('category'); $document_type=$this->input->post('document_type'); $parent_type=$this->input->post('parent_type'); $option_card_name=$this->input->post('option_card_name'); if(is_uploaded_file($_FILES['attachment']['tmp_name'])) { $sourcePath = $_FILES['attachment']['tmp_name']; $targetPath = "uploads/manual_uploads/".$_FILES['attachment']['name']; move_uploaded_file($_FILES['attachment']['tmp_name'],$targetPath); } else { $targetPath=""; } $attachment=$targetPath; $data=array('product_name'=>$product_name,'category'=>$category,'document_type'=>$document_type,'document_sub_type'=>$parent_type,'option_card_name'=>$option_card_name,'attachment'=>$attachment); $table='manuals'; $this->model->insert($table,$data); $role=$this->session->userdata('role'); $id=$this->session->userdata('id'); if($role==3) { $w=array('id'=>$id); $t='profile'; $data['details']=$this->model->get_where_row($t,$w); } else { $w=array('id'=>$id); $t='supervisor'; $data['details']=$this->model->get_where_row($t,$w); } $tab="manuals"; $data['time']=$this->model->get_time($tab); redirect('controller/drive_mannual_upload'); } public function case_stories() { // $role=$this->session->userdata('role'); // $id=$this->session->userdata('id'); $sessionData = $this->decryptSessionData(); // Check if session is valid if (!isset($sessionData['id'], $sessionData['role'])) { redirect('/'); // Redirect if session is invalid return; } $id = $sessionData['id']; $role = $sessionData['role']; if($id){ if($role==3) { $id1=$this->session->userdata('uid'); $w=array('id'=>$id); $t='profile'; $data['details']=$this->model->get_where_row($t,$w); $table='case_stories'; //$data['case']=$this->model->partner_code($table,$id1); $data['case']=$this->model->get_all_data($table); } else { $w=array('id'=>$id); $t='supervisor'; $data['details']=$this->model->get_where_row($t,$w); } $this->load->view('includes/admin_header',$data); $this->load->view('case_stories',$data); $this->load->view('includes/admin_footer',$data); }else { redirect('/'); } } public function c_forms() { // $role=$this->session->userdata('role'); // $department=$this->session->userdata('department'); // $id=$this->session->userdata('id'); $sessionData = $this->decryptSessionData(); // Check if session is valid if (!isset($sessionData['id'], $sessionData['role'], $sessionData['department'])) { redirect('/'); // Redirect if session is invalid return; } $id = $sessionData['id']; $role = $sessionData['role']; $department= $sessionData['department']; if (!($role == '2' && $department == '5') && !($role == '2' && $department == '7') && $role != '3') { log_message('error', "Unauthorized access attempt. Role: $role, Department: $department"); redirect('/'); return; } if($role==3) { $w=array('id'=>$id); $t='profile'; $data['details']=$this->model->get_where_row($t,$w); } else { $w=array('id'=>$id); $t='supervisor'; $data['details']=$this->model->get_where_row($t,$w); } $tab="fin_cforms"; $data['time']=$this->model->get_time($tab); $this->load->view('c_forms',$data); } public function news() { // $role=$this->session->userdata('role'); // $id=$this->session->userdata('id'); $sessionData = $this->decryptSessionData(); if (!isset($sessionData['id'])) { redirect('/'); // Redirect if session is invalid return; } $id = $sessionData['id']; if($id){ $data['feedback'] =$this->model->get_opinions(); $table = "feedback_count"; $where = array('delete_status'=>'ACTIVE'); $data['feedback_count'] =$this->model->get_feedback_count($table,$where); if($role==3) { $w=array('id'=>$id); $t='profile'; $data['details']=$this->model->get_where_row($t,$w); $table='news'; $data['news']=$this->model->get_all_data($table); $data['years']=$this->model->news_year(); $this->load->view('includes/admin_header',$data); $this->load->view('new_dashboard',$data); $this->load->view('includes/admin_footer',$data); }else if(2) { $w=array('id'=>$id); $t='supervisor'; $data['details']=$this->model->get_where_row($t,$w); $table='news'; $data['news']=$this->model->get_all_data($table); $data['years']=$this->model->news_year(); $this->load->view('supervisor_news',$data); } else { $w=array('id'=>$id); $t='supervisor'; $data['details']=$this->model->get_where_row($t,$w); $table='news'; $data['news']=$this->model->get_all_data($table); $data['years']=$this->model->news_year(); $this->load->view('region_news_view',$data); } }else { reditect('/'); } } public function case_stories_insert1() { /*$table='case_stories'; $where=array('status'=>0); $details=$this->model->fetch_where_data($table,$where); echo json_encode($details);*/ $page = isset($_POST['page'])?$_POST['page']:1; $limit = isset($_POST['rows'])?$_POST['rows']:10; $sidx = isset($_POST['sidx'])?$_POST['sidx']:'id'; $sord = isset($_POST['sord'])?$_POST['sord']:''; $totalrows = isset($_REQUEST['totalrows']) ? $_REQUEST['totalrows']: false; if($totalrows) { $limit = $totalrows; } $start = $limit*$page - $limit; $start = ($start<0)?0:$start; $where = ""; $searchField = isset($_POST['searchField']) ? $_POST['searchField'] : false; $searchOper = isset($_POST['searchOper']) ? $_POST['searchOper']: false; $searchString = isset($_POST['searchString']) ? $_POST['searchString'] : false; if(!$sidx) $sidx =1; $whers=array('status'=>0); $table='case_stories'; $count = $this->model->fetch_where_data_case_stories($table,$whers); $count=count($count); if( $count > 0 ) { $total_pages = ceil($count/$limit); } else { $total_pages = 0; } if ($page > $total_pages) $page=$total_pages; $query = $this->model->getdata_case_stories($start,$limit,$sidx,$sord,$whers,$table); $responce = array(); $responce["page"] = $page; $responce["total"] = $total_pages; $responce["records"] = $count; $i=0; foreach($query as $row) { $responce["rows"][$i]['id']=$row->case_id; $responce["rows"][$i]['cell']=array($row->case_id,$row->industry,$row->application,$row->product_type,$row->document_name,$row->document); $i++; } echo json_encode($responce); } public function case_stories_fetch() { $id=$this->input->post('id'); $table='case_stories'; $where=array('case_id'=>$id); $data=$this->model->get_where_row($table,$where); echo json_encode($data); } public function news_view() { $sessionData = $this->decryptSessionData(); if (!$sessionData || !isset($sessionData['id']) || $sessionData['role'] != '1') { redirect('controller/login'); } $table='news'; $data['news']=$this->model->get_all_data($table); $this->load->view('admin_news_view',$data); } public function news_upload() { $sessionData = $this->decryptSessionData(); // Check if session is valid if (!isset($sessionData['id'], $sessionData['role'])) { redirect('/'); // Redirect if session is invalid return; } $id = $sessionData['id']; $role = $sessionData['role']; if($id){ if($role==3) { $w=array('id'=>$id); $t='profile'; $data['details']=$this->model->get_where_row($t,$w); } else { $w=array('id'=>$id); $t='supervisor'; $data['details']=$this->model->get_where_row($t,$w); } $table='news'; $data['news']=$this->model->get_all_data($table); $this->load->view('news_upload',$data); } else { redirect('/'); } } public function news_insert() { $sessionData = $this->decryptSessionData(); $title=$this->input->post('title',true); $desc=$this->input->post('desc',true); $url=$this->input->post('url',true); // $role=$this->session->userdata('role'); // $id=$this->session->userdata('id'); $id = $sessionData['id']; $role = $sessionData['role']; $allowedExtensions = ['pdf', 'doc', 'docx', 'jpg', 'jpeg', 'png', 'gif']; $allowedMimeTypes = ['application/pdf', 'application/msword', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'image/jpeg', 'image/png', 'image/gif']; if($id){ if($_FILES) { $path = $_FILES['file']['name']; $fileExtension = strtolower(pathinfo($path, PATHINFO_EXTENSION)); $fileMimeType = mime_content_type($_FILES['file']['tmp_name']); if (!in_array($fileExtension, $allowedExtensions)) { echo json_encode(['result' => '0', 'message' => 'Invalid file type!']); return; } // Validate MIME type if (!in_array($fileMimeType, $allowedMimeTypes)) { echo json_encode(['result' => '0', 'message' => 'Invalid file content!']); return; } $path=$_FILES['file']['name']; $target5='uploads/'; $stamp=getdate(); $target5.=$stamp[0].basename($_FILES['file']['name']); $file3=$target5; move_uploaded_file($_FILES['file']['tmp_name'],$target5); } else { $file3=" "; } $data=array('news_title'=>$title,'news_description'=>$desc,'url'=>$url,'attachment'=>$file3); $table='news'; $this->model->insert($table,$data); $id=$this->session->userdata('id'); if($role==3) { $w=array('id'=>$id); $t='profile'; $data['details']=$this->model->get_where_row($t,$w); } else { $w=array('id'=>$id); $t='supervisor'; $data['details']=$this->model->get_where_row($t,$w); } $table='news'; $data['news']=$this->model->get_all_data($table); $this->load->view('news_upload',$data); }else { redirect('/'); } } public function deletenews() { $id=$_GET['id']; $table='news'; $where=array('news_id'=>$id); $this->model->delete($table,$where); redirect('controller/news_upload'); } public function po_import() { // $role=$this->session->userdata('role'); // $department=$this->session->userdata('department'); // $id=$this->session->userdata('id'); $sessionData = $this->decryptSessionData(); $id = $sessionData['id']; $role = $sessionData['role']; $department= $sessionData['department']; if (!(($role == '2' && $department == '4') || $role == '3')) { log_message('error', "Unauthorized access attempt. Role: $role, Department: $department"); redirect('/'); return; } if($role==3) { $w=array('id'=>$id); $t='profile'; $data['details']=$this->model->get_where_row($t,$w); } else { $w=array('id'=>$id); $t='supervisor'; $data['details']=$this->model->get_where_row($t,$w); } $table='po_info'; $data['time']=$this->model->get_time($table); $this->load->view('po_import',$data); } public function inventory_import() { // $role=$this->session->userdata('role'); // $department=$this->session->userdata('department'); // $id=$this->session->userdata('id'); $sessionData = $this->decryptSessionData(); $id = $sessionData['id']; $role = $sessionData['role']; $department = $sessionData['department']; // print_r($sessionData);die(); if (!($role == '2' && $department == '4') && $role != '3') { log_message('error', "Unauthorized access attempt. Role: $role, Department: $department"); redirect('/'); return; } if($role==3) { $w=array('id'=>$id); $t='profile'; $data['details']=$this->model->get_where_row($t,$w); } else { $w=array('id'=>$id); $t='supervisor'; $data['details']=$this->model->get_where_row($t,$w); // print_r($data['details']);die(); } $table='stock_info'; $data['view_data']= $this->model->get_all_data($table); $data['time']=$this->model->get_time($table); // print_r($data); // die(); $this->load->view('inventory_import',$data); } public function case_stories_import() { //$partner_code=$this->input->post('partner_code'); $industry=$this->input->post('industry'); $application=$this->input->post('application'); $product_type=$this->input->post('product_type'); $document_name=$this->input->post('document_name'); //$document=$this->input->post('document'); if(is_uploaded_file($_FILES['document']['tmp_name'])) { $document = $_FILES['document']['tmp_name']; $document = "uploads/case_uploads/".$_FILES['document']['name']; move_uploaded_file($_FILES['document']['tmp_name'],$document); } else { $document=""; } $data=array('industry'=>$industry,'application'=>$application,'product_type'=>$product_type,'document_no'=>$document_name,'document'=>$document); $table='case_stories'; $this->model->insert($table,$data); redirect('controller/case_stories_upload'); } public function supervisor_view() { $sessionData = $this->decryptSessionData(); if (!$sessionData || !isset($sessionData['id']) || $sessionData['role'] != '1') { redirect('controller/login'); } $table="master_data"; $where=array('type'=>2); $data['supervisor']=$this->model->fetch_where_data($table,$where); $table1="region"; $data['region']=$this->model->get_all_data($table1); $data['time']=$this->model->get_time($table1); $table2="master_data"; $where2=array('id'=>2); $data['role']=$this->model->fetch_where_data($table2,$where2); $tab="supervisor"; $data['time']=$this->model->get_time($tab); $this->load->view('supervisor_view',$data); } public function reg_supervisor_view() { $sessionData = $this->decryptSessionData(); if (!$sessionData || !isset($sessionData['id']) || $sessionData['role'] != '8') { redirect('controller/login'); } $table="master_data"; $data['supervisor']=$this->model->get_all_data($table); $table2="master_data"; $where2=array('id'=>2); $data['role']=$this->model->fetch_where_data($table2,$where2); $tab="supervisor"; $data['time']=$this->model->get_time($tab); $this->load->view('reg_supervisor_view',$data); } public function supervisor_view_insert() { /*if ($_REQUEST['_search'] == 'false') { $table='supervisor'; $where=array('status'=>0,'role'=>2); $details=$this->model->fetch_where_data($table,$where); //print_r($details); echo json_encode($details); $page = isset($_POST['page'])?$_POST['page']:2; $limit = isset($_POST['rows'])?$_POST['rows']:5; $sidx = isset($_POST['sidx'])?$_POST['sidx']:'id'; $sord = isset($_POST['sord'])?$_POST['sord']:''; }*/ $page = isset($_POST['page'])?$_POST['page']:1; $limit = isset($_POST['rows'])?$_POST['rows']:10; $sidx = isset($_POST['sidx'])?$_POST['sidx']:'id'; $sord = isset($_POST['sord'])?$_POST['sord']:''; $totalrows = isset($_REQUEST['totalrows']) ? $_REQUEST['totalrows']: false; if($totalrows) { $limit = $totalrows; } $start = $limit*$page - $limit; $start = ($start<0)?0:$start; $where = ""; $searchField = isset($_POST['searchField']) ? $_POST['searchField'] : false; $searchOper = isset($_POST['searchOper']) ? $_POST['searchOper']: false; $searchString = isset($_POST['searchString']) ? $_POST['searchString'] : false; if(!$sidx) $sidx =1; $whers=array('status'=>0); $table1='supervisor'; $count = $this->model->fetch_where_data($table1,$whers); $count=count($count); if( $count > 0 ) { $total_pages = ceil($count/$limit); } else { $total_pages = 0; } if ($page > $total_pages) $page=$total_pages; $query = $this->model->getdata($start,$limit,$sidx,$sord,$whers,$table1); $responce = array(); $responce["page"] = $page; $responce["total"] = $total_pages; $responce["records"] = $count; $i=0; foreach($query as $row) { $responce["rows"][$i]['id']=$row->id; $responce["rows"][$i]['cell']=array($row->id,$row->usercode,$row->region,$row->username,$row->email,$row->password,$row->phone,$row->department,$row->role); $i++; } echo json_encode($responce); } public function reg_supervisor_view_insert() { if ($_REQUEST['_search'] == 'false') { $region=$this->session->userdata('region'); $table='supervisor'; $where=array('status'=>0,'region'=>$region); $details=$this->model->fetch_where_data($table,$where); //print_r($details); echo json_encode($details); $page = isset($_POST['page'])?$_POST['page']:2; $limit = isset($_POST['rows'])?$_POST['rows']:5; $sidx = isset($_POST['sidx'])?$_POST['sidx']:'id'; $sord = isset($_POST['sord'])?$_POST['sord']:''; } } public function supervisor_view_add() { $cc = $this->input->post('cc'); $usercode = $this->input->post('usercode'); $region = $this->input->post('region'); $username = $this->input->post('username'); $email = $this->input->post('email'); $password = $this->input->post('password'); $phone = $this->input->post('phone'); $department = $this->input->post('department'); $role = $this->input->post('role'); $rate = array( 'usercode' => $usercode, 'region' => $region, 'username' => $username, 'email' => $email, 'password' => $password, 'phone' => $phone, 'department' => $department, 'role' => $role ); $table = 'supervisor'; $where = array('department' => $department); $det = $this->model->fetch_where_data($table, $where); if (count($det) > 2) { return false; } else { $this->model->insert($table, $rate); $this->load->library('email'); $this->email->set_mailtype('html'); $msg = "Hi, Added new supervisor: " . $username . ", email: " . $email; $this->email->from('notify@yaskawa.in', 'yaskawa'); $this->email->to($email, 'yaskawa'); $this->email->cc($cc); $this->email->subject('Added information'); $this->email->message($msg); $this->email->send(); } return true; } // Function to check if a password is strong private function isStrongPassword($password) { // Password should be at least 8 characters, with at least one uppercase, one lowercase, one digit, and one special character return preg_match('/^(?=.*[A-Z])(?=.*[a-z])(?=.*\d)(?=.*[@$!%*?&#])[A-Za-z\d@$!%*?&#]{8,}$/', $password); } public function supervisor_view_edit() { $cc=$this->input->post('cc'); $id=$this->input->post('id'); $usercode=$this->input->post('usercode'); $region=$this->input->post('region'); $username=$this->input->post('username'); $email=$this->input->post('email'); $password=$this->input->post('password'); $phone=$this->input->post('phone'); $department=$this->input->post('department'); $role=$this->input->post('role'); //$image=$this->input->post('image'); //$createdate=$this->input->post('createdate'); //$status=$this->input->post('status'); $rate=array('usercode'=>$usercode,'region'=>$region,'username'=>$username,'email'=>$email,'password'=>$password,'phone'=>$phone,'department'=>$department,'role'=>$role); $table='supervisor'; $where=array('id'=>$id); $dat = $this->model->get_where_row($table,$where); if($dat) { $this->model->update_new($where,$table,$rate); $this->load->library('email'); $this->email->set_mailtype('html'); $msg = "Hi, Edited supervisor:".$username.','."email:".$email; $this->email->from('notify@yaskawa.in', 'yaskawa'); $this->email->to($email, 'yaskawa'); $this->email->cc($cc); $this->email->subject('Added information'); // //$data['message'] = $msg; $this->email->message($msg); $this->email->send(); } else return ""; } public function supervisor_view_delete() { $cc=$this->input->post('cc'); $id=$this->input->post('id'); $table='supervisor'; $where=array('id'=>$id); $this->model->delete($table,$where); $this->load->library('email'); $this->email->set_mailtype('html'); $msg = "Hi, Deleted supervisor:".$username.','."email:".$email; $this->email->from('notify@yaskawa.in', 'yaskawa'); $this->email->to($email, 'yaskawa'); $this->email->cc($cc); $this->email->subject('Added information'); // //$data['message'] = $msg; $this->email->message($msg); $this->email->send(); return true; } public function abp_view() { $sessionData = $this->decryptSessionData(); if (!$sessionData || !isset($sessionData['id']) || $sessionData['role'] != '1') { redirect('controller/login'); } $table='profile'; $data['id']=$this->model->get_all_data($table); $table1='master_data'; $where=array('id'=>3); $data['abp_role']=$this->model->fetch_where_data($table1,$where); $table2='region'; $data['region']=$this->model->get_all_data($table2); $table3='softwares'; $data['softwares']=$this->model->get_all_data($table3); $table4='others'; $data['others']=$this->model->get_all_data($table4); $table5='projects'; $data['projects']=$this->model->get_all_data($table5); $tab="supervisor"; $data['time']=$this->model->get_time($tab); $this->load->view('abp_view',$data); } public function reg_abp_view() { $sessionData = $this->decryptSessionData(); if (!$sessionData || !isset($sessionData['id']) || $sessionData['role'] != '8') { redirect('controller/login'); } $table='profile'; $data['id']=$this->model->get_all_data($table); $tab="profile"; $data['time']=$this->model->get_time($tab); $this->load->view('reg_abp_view',$data); } public function abp_view_insert() { /*if ($_REQUEST['_search'] == 'false') { $table='profile'; $where=array('status'=>0); $details=$this->model->fetch_where_data($table,$where); //print_r($details); echo json_encode($details); $page = isset($_POST['page'])?$_POST['page']:2; $limit = isset($_POST['rows'])?$_POST['rows']:5; $sidx = isset($_POST['sidx'])?$_POST['sidx']:'id'; $sord = isset($_POST['sord'])?$_POST['sord']:''; }*/ $page = isset($_POST['page'])?$_POST['page']:1; $limit = isset($_POST['rows'])?$_POST['rows']:10; $sidx = isset($_POST['sidx'])?$_POST['sidx']:'id'; $sord = isset($_POST['sord'])?$_POST['sord']:''; $totalrows = isset($_REQUEST['totalrows']) ? $_REQUEST['totalrows']: false; if($totalrows) { $limit = $totalrows; } $start = $limit*$page - $limit; $start = ($start<0)?0:$start; $where = ""; $searchField = isset($_POST['searchField']) ? $_POST['searchField'] : false; $searchOper = isset($_POST['searchOper']) ? $_POST['searchOper']: false; $searchString = isset($_POST['searchString']) ? $_POST['searchString'] : false; if(!$sidx) $sidx =1; $whers=array('status'=>0); $table='profile'; $count = $this->model->fetch_where_data($table,$whers); $count=count($count); if( $count > 0 ) { $total_pages = ceil($count/$limit); } else { $total_pages = 0; } if ($page > $total_pages) $page=$total_pages; $query = $this->model->getdata($start,$limit,$sidx,$sord,$whers,$table); $responce = array(); $responce["page"] = $page; $responce["total"] = $total_pages; $responce["records"] = $count; $i=0; foreach($query as $row) { $responce["rows"][$i]['id']=$row->id; //$responce["rows"][$i]['cell']=array($row->id,$row->uid,$row->role,$row->region,$row->company_name,$row->address,$row->city,$row->state,$row->state_code,$row->pin,$row->landline,$row->mobile,$row->alt_mobile,$row->email,$row->alt_email,$row->password,$row->pan,$row->gstin,$row->tin); $responce["rows"][$i]['cell']=array($row->id,$row->uid,$row->role,$row->region,$row->company_name,$row->address,$row->city,$row->state,$row->state_code,$row->pin,$row->landline,$row->mobile,$row->alt_mobile,$row->email,$row->alt_email,$row->password,$row->pan,$row->gstin,$row->tin,$row->access_status); $responce["rows"][$i]['software_status']=$row->access_status; $i++; } echo json_encode($responce); } public function reg_abp_view_insert() { if ($_REQUEST['_search'] == 'false') { $region=$this->session->userdata('region'); $table='profile'; $where=array('status'=>0,'region'=>$region); $details=$this->model->fetch_where_data($table,$where); //print_r($details); echo json_encode($details); $page = isset($_POST['page'])?$_POST['page']:2; $limit = isset($_POST['rows'])?$_POST['rows']:5; $sidx = isset($_POST['sidx'])?$_POST['sidx']:'id'; $sord = isset($_POST['sord'])?$_POST['sord']:''; } } public function abp_view_add() { $cc=$this->input->post('cc'); $uid=$this->input->post('uid'); $region=$this->input->post('region'); $role=$this->input->post('role'); $company_name=$this->input->post('company_name'); $address=$this->input->post('address'); $city=$this->input->post('city'); $state=$this->input->post('state'); $state_code=$this->input->post('state_code'); $pin=$this->input->post('pin'); $landline=$this->input->post('landline'); $mobile=$this->input->post('mobile'); $alt_mobile=$this->input->post('alt_mobile'); $email=$this->input->post('email'); $alt_email=$this->input->post('alt_email'); $password=$this->input->post('password'); $pan=$this->input->post('pan'); $tin=$this->input->post('tin'); $gstin=$this->input->post('gstin'); $rate=array('uid'=>$uid,'role'=>$role,'region'=>$region,'company_name'=>$company_name,'address'=>$address,'city'=>$city,'state'=>$state,'state_code'=>$state_code,'pin'=>$pin,'gstin'=>$gstin,'landline'=>$landline,'mobile'=>$mobile,'alt_mobile'=>$alt_mobile,'email'=>$email,'alt_email'=>$alt_email,'pan'=>$pan,'password'=>$password,'tin'=>$tin); $table='profile'; $this->model->insert($table,$rate); $this->load->library('email'); $this->email->set_mailtype('html'); $msg = "Hi, yaskawa added new ABP:".$company_name.','."email:".$email; $this->email->from('notify@yaskawa.in', 'yaskawa'); $this->email->to($email, 'yaskawa'); $this->email->cc($cc); $this->email->subject('New ABP information'); // //$data['message'] = $msg; $this->email->message($msg); $this->email->send(); return true; } public function abp_view_edit() { /*$id=$this->input->post('id'); $uid=$this->input->post('uid'); $role=$this->input->post('role'); $company_name=$this->input->post('company_name'); $address=$this->input->post('address'); $city=$this->input->post('city'); $state=$this->input->post('state'); $pin=$this->input->post('pin'); $landline=$this->input->post('landline'); $mobile=$this->input->post('mobile'); $alt_mobile=$this->input->post('alt_mobile'); $email=$this->input->post('email'); $alt_email=$this->input->post('alt_email'); $password=$this->input->post('password'); $pan=$this->input->post('pan'); $tin=$this->input->post('tin'); $attachments=$this->input->post('attachments'); $rate=array('uid'=>$uid,'role'=>$role,'company_name'=>$company_name,'address'=>$address,'city'=>$city,'state'=>$state,'pin'=>$pin,'landline'=>$landline,'mobile'=>$mobile,'alt_mobile'=>$alt_mobile,'email'=>$email,'alt_email'=>$alt_email,'pan'=>$pan,'password'=>$password,'tin'=>$tin,'attachments'=>$attachments); $table='profile'; $where=array('id'=>$id); $data=$this->model->get_where_row($table,$where); if(count($data)>0) { $this->model->update_new($where,$table,$rate); } else return "";*/ $cc=$this->input->post('cc'); $id=$this->input->post('id'); $uid=$this->input->post('uid'); $region=$this->input->post('region'); $role=$this->input->post('role'); $company_name=$this->input->post('company_name'); $address=$this->input->post('address'); $city=$this->input->post('city'); $state=$this->input->post('state'); $state_code=$this->input->post('state_code'); $pin=$this->input->post('pin'); $landline=$this->input->post('landline'); $mobile=$this->input->post('mobile'); $alt_mobile=$this->input->post('alt_mobile'); $email=$this->input->post('email'); $alt_email=$this->input->post('alt_email'); $password=$this->input->post('password'); $pan=$this->input->post('pan'); $tin=$this->input->post('tin'); $gstin=$this->input->post('gstin'); $rate=array('uid'=>$uid,'role'=>$role,'region'=>$region,'company_name'=>$company_name,'address'=>$address,'city'=>$city,'state'=>$state,'state_code'=>$state_code,'pin'=>$pin,'gstin'=>$gstin,'landline'=>$landline,'mobile'=>$mobile,'alt_mobile'=>$alt_mobile,'email'=>$email,'alt_email'=>$alt_email,'pan'=>$pan,'password'=>$password,'tin'=>$tin); $table='profile'; $where=array('id'=>$id); $data=$this->model->get_where_row($table,$where); if(count($data)>0) { $this->model->update_new($where,$table,$rate); $this->load->library('email'); $this->email->set_mailtype('html'); $msg = "Hai, your profile is updated:".$partner_name.','."email:".$email; $this->email->from('notify@yaskawa.in', 'yaskawa'); $this->email->to($email, 'yaskawa'); $this->email->cc($cc); $this->email->subject('Updation information'); // //$data['message'] = $msg; $this->email->message($msg); $this->email->send(); } else { return ""; } } public function abp_view_delete() { $cc=$this->input->post('cc'); $id=$this->input->post('id'); $table='profile'; $where=array('id'=>$id); $this->model->delete($table,$where); $this->load->library('email'); $this->email->set_mailtype('html'); $msg = "Hi, your ABP has been deleted :".$company_name.','."email:".$email; $this->email->from('notify@yaskawa.in', 'yaskawa'); $this->email->to($email, 'yaskawa'); $this->email->cc($cc); $this->email->subject('Deleted information'); // //$data['message'] = $msg; $this->email->message($msg); $this->email->send(); return true; } public function stock_updates_view() { $sessionData = $this->decryptSessionData(); if (!$sessionData || !isset($sessionData['id']) || $sessionData['role'] != '1') { redirect('controller/login'); } $t="stock_info"; $data['time']=$this->model->get_time($t); $this->load->view('stock_updates_view',$data); } public function reg_stock_updates_view() { $sessionData = $this->decryptSessionData(); if (!$sessionData || !isset($sessionData['id']) || $sessionData['role'] != '8') { redirect('controller/login'); } $t="stock_info"; $data['time']=$this->model->get_time($t); $this->load->view('reg_stock_updates_view',$data); } public function stock_updates_view_insert() { /* if ($_REQUEST['_search'] == 'false') { $table='stock_info'; $where=array('status'=>0); $details=$this->model->fetch_where_data($table,$where); //print_r($details); echo json_encode($details); $page = isset($_POST['page'])?$_POST['page']:2; $limit = isset($_POST['rows'])?$_POST['rows']:5; $sidx = isset($_POST['sidx'])?$_POST['sidx']:'stock_id'; $sord = isset($_POST['sord'])?$_POST['sord']:''; }*/ $page = isset($_POST['page'])?$_POST['page']:1; $limit = isset($_POST['rows'])?$_POST['rows']:10; $sidx = isset($_POST['sidx'])?$_POST['sidx']:'id'; $sord = isset($_POST['sord'])?$_POST['sord']:''; $totalrows = isset($_REQUEST['totalrows']) ? $_REQUEST['totalrows']: false; if($totalrows) { $limit = $totalrows; } $start = $limit*$page - $limit; $start = ($start<0)?0:$start; $where = ""; $searchField = isset($_POST['searchField']) ? $_POST['searchField'] : false; $searchOper = isset($_POST['searchOper']) ? $_POST['searchOper']: false; $searchString = isset($_POST['searchString']) ? $_POST['searchString'] : false; if(!$sidx) $sidx =1; //$count = $this->db->count_all_results('rate'); $whers=array('status'=>0); $table='stock_info'; $count = $this->model->fetch_where_data_stock($table,$whers); //echo $count; $count=count($count); if( $count > 0 ) { $total_pages = ceil($count/$limit); //echo $total_pages; } else { $total_pages = 0; } if ($page > $total_pages) $page=$total_pages; $query = $this->model->getdata($start,$limit,$sidx,$sord,$whers,$table); //print_r($query); $responce = array(); $responce["page"] = $page; $responce["total"] = $total_pages; $responce["records"] = $count; $i=0; foreach($query as $row) { $responce["rows"][$i]['id']=$row->stock_id; $responce["rows"][$i]['cell']=array($row->stock_id,$row->material,$row->material_description,$row->quantity_in_stock,$row->open_po,$row->in_transit_stock,$row->month_planned_qty,$row->remarks); $i++; } echo json_encode($responce); } public function stock_updates_abp() { if ($_REQUEST['_search'] == 'false') { $ui=$this->input->post('ui'); $table='stock_info'; $where=array('partner_code'=>$ui,'status'=>0); $details=$this->model->fetch_where_data($table,$where); //print_r($details); echo json_encode($details); $page = isset($_POST['page'])?$_POST['page']:2; $limit = isset($_POST['rows'])?$_POST['rows']:5; $sidx = isset($_POST['sidx'])?$_POST['sidx']:'stock_id'; $sord = isset($_POST['sord'])?$_POST['sord']:''; } } public function stock_info_insert_add() { $stock_id = $this->input->post('stock_id'); //$partner_code = $this->input->post('partner_code'); $material = $this->input->post('material'); $material_description = $this->input->post('material_description'); $quantity_in_stock = $this->input->post('quantity_in_stock'); $open_po = $this->input->post('open_po'); $in_transit_stock = $this->input->post('in_transit_stock'); $month_planned_qty = $this->input->post('month_planned_qty'); $remarks = $this->input->post('remarks'); $rate=array('material'=>$material,'material_description'=>$material_description,'quantity_in_stock'=>$quantity_in_stock,'open_po'=>$open_po,'in_transit_stock'=>$in_transit_stock,'month_planned_qty'=>$month_planned_qty,'remarks'=>$remarks); $table='stock_info'; $this->model->insert($table,$rate); return true; } public function stock_info_insert_edit() { $stock_id = $this->input->post('stock_id'); //$partner_code = $this->input->post('partner_code'); $material = $this->input->post('material'); $material_description = $this->input->post('material_description'); $quantity_in_stock = $this->input->post('quantity_in_stock'); $open_po = $this->input->post('open_po'); $in_transit_stock = $this->input->post('in_transit_stock'); $month_planned_qty = $this->input->post('month_planned_qty'); $remarks = $this->input->post('remarks'); $rate=array('material'=>$material,'material_description'=>$material_description,'quantity_in_stock'=>$quantity_in_stock,'open_po'=>$open_po,'in_transit_stock'=>$in_transit_stock,'month_planned_qty'=>$month_planned_qty,'remarks'=>$remarks); $table='stock_info'; $where=array('stock_id'=>$stock_id); $data=$this->model->get_where_row($table,$where); if(count($data)>0) { $this->model->update_new($where,$table,$rate); } else return ""; } public function stock_info_insert_delete() { $stock_id = $this->input->post('stock_id'); $table='stock_info'; $where=array('stock_id'=>$stock_id); $data=$this->model->delete($table,$where); return true; } public function po_view() { $sessionData = $this->decryptSessionData(); if (!$sessionData || !isset($sessionData['id']) || $sessionData['role'] != '1') { redirect('controller/login'); } $t="po_info"; $data['time']=$this->model->get_time($t); $this->load->view('po_view',$data); } public function po_view_new() { $sessionData = $this->decryptSessionData(); if (!$sessionData || !isset($sessionData['id']) || $sessionData['role'] != '1') { redirect('controller/login'); } $t="po_info"; $data['time']=$this->model->get_time($t); //print_r($data['time']); $this->load->view('po_view_new',$data); } // public function download_po() // { // $this->load->helper('download'); // $path ='./uploads/acknowledgement'; // ob_clean(); // $data = file_get_contents($path); // Read the file's contents // $name = 'acknowledgement.pdf'; // force_download($name, $data); // redirect('controller/po_view_new'); // } public function download_po($fileName = '') { $this->load->helper('download'); $filePath = FCPATH . 'uploads/acknowledgement/' . $fileName; if (!file_exists($filePath)) { show_error('File not found: ' . $filePath); return; } ob_clean(); flush(); $data = file_get_contents($filePath); force_download($fileName, $data); } public function reg_po_view() { $sessionData = $this->decryptSessionData(); if (!$sessionData || !isset($sessionData['id']) || $sessionData['role'] != '8') { redirect('controller/login'); } $tab="po_info"; $data['time']=$this->model->get_time($tab); $this->load->view('reg_po_view',$data); } public function po_view_insert() { $id=$this->session->userdata('region'); $page = isset($_POST['page'])?$_POST['page']:1; $limit = isset($_POST['rows'])?$_POST['rows']:10; $sidx = isset($_POST['sidx'])?$_POST['sidx']:'po_id'; $sord = isset($_POST['sord'])?$_POST['sord']:''; $totalrows = isset($_REQUEST['totalrows']) ? $_REQUEST['totalrows']: false; if($totalrows) { $limit = $totalrows; } $start = $limit*$page - $limit; $start = ($start<0)?0:$start; $where = ""; $searchField = isset($_POST['searchField']) ? $_POST['searchField'] : false; $searchOper = isset($_POST['searchOper']) ? $_POST['searchOper']: false; $searchString = isset($_POST['searchString']) ? $_POST['searchString'] : false; if(!$sidx) $sidx =1; //$count = $this->db->count_all_results('rate'); $whers=array('status'=>0); $table1='po_info'; $count = $this->model->fetch_where_data_new($table1,$whers); //echo $count; $count=count($count); if( $count > 0 ) { $total_pages = ceil($count/$limit); //echo $total_pages; } else { $total_pages = 0; } if ($page > $total_pages) $page=$total_pages; $query = $this->model->getdata($start,$limit,$sidx,$sord,$whers,$table1); //print_r($query); $responce = array(); $responce["page"] = $page; $responce["total"] = $total_pages; $responce["records"] = $count; $i=0; foreach($query as $row) { $responce["rows"][$i]['id']=$row->po_id; $responce["rows"][$i]['cell']=array($row->po_id,$row->partner_code,$row->po_number,$row->acknowledgement,date('d-m-Y H:i:s', strtotime($row->createdate))); $i++; } echo json_encode($responce); } public function po_info_insert_add() { $cc=$this->input->post('cc'); $po_id = $this->input->post('po_id'); $partner_code = $this->input->post('partner_code'); $po_number = $this->input->post('po_number'); //$date = $this->input->post('date'); $acknowledgement = $this->input->post('acknowledgement'); //$createdate = $this->input->post('createdate'); $rate=array('po_number'=>$po_number,'partner_code'=>$partner_code,'acknowledgement'=>$acknowledgement); $table='po_info'; $this->model->insert($table,$rate); $table1='profile'; $where1=array('id'=>$po_id); $date['get']=$this->model->get_where_row($table1,$where1); $email=$date['get']->email; $this->load->library('email'); $this->email->set_mailtype('html'); $msg = "Hi, new information is added:".$partner_name.','."email:".$email; $this->email->from('notify@yaskawa.in', 'yaskawa'); $this->email->to($email, 'yaskawa'); $this->email->cc($cc); $this->email->subject('Added information'); // //$data['message'] = $msg; $this->email->message($msg); $this->email->send(); return true; } public function po_info_insert_edit() { $cc=$this->input->post('cc'); $po_id = $this->input->post('po_id'); $partner_code = $this->input->post('partner_code'); $po_number = $this->input->post('po_number'); $date = $this->input->post('date'); $acknowledgement = $this->input->post('acknowledgement'); $createdate = $this->input->post('createdate'); $rate=array('po_number'=>$po_number,'partner_code'=>$partner_code,'acknowledgement'=>$acknowledgement); $table='po_info'; $where=array('po_id'=>$po_id); $data=$this->model->get_where_row($table,$where); if(count($data)>0) { $this->model->update_new($where,$table,$rate); $table1='profile'; $where1=array('id'=>$po_id); $date['get']=$this->model->get_where_row($table1,$where1); $email=$date['get']->email; $this->load->library('email'); $this->email->set_mailtype('html'); $msg = "Hi, information is edited:".$partner_name.','."email:".$email; $this->email->from('notify@yaskawa.in', 'yaskawa'); $this->email->to($email, 'yaskawa'); $this->email->cc($cc); $this->email->subject('Added information'); $data['message'] = $msg; $this->email->message($msg); $this->email->send(); } else return ""; } public function po_info_insert_delete() { $cc=$this->input->post('cc'); $po_id = $this->input->post('po_id'); $table='po_info'; $where=array('po_id'=>$po_id); $data=$this->model->delete($table,$where); $table1='profile'; $where1=array('id'=>$partner_code); $date['get']=$this->model->get_where_row($table1,$where1); $email=$date['get']->email; $this->load->library('email'); $this->email->set_mailtype('html'); $msg = "Hi, information is edited.email:".$email; $this->email->from('notify@yaskawa.in', 'yaskawa'); $this->email->to($email, 'yaskawa'); $this->email->cc($cc); $this->email->subject('Added information'); // //$data['message'] = $msg; $this->email->message($msg); $this->email->send(); return true; } public function import() { date_default_timezone_set('Asia/Kolkata'); include '../PHPExcel/IOFactory.php'; if(isset($_FILES['file']['name'])) { $file_name = $_FILES['file']['name']; $ext = pathinfo($file_name, PATHINFO_EXTENSION); if($ext == "xlsx") { $file_name = $_FILES['file']['tmp_name']; $inputFileName = $file_name; try { $inputFileType = PHPExcel_IOFactory::identify($inputFileName); $objReader = PHPExcel_IOFactory::createReader($inputFileType); $objPHPExcel = $objReader->load($inputFileName); } catch (Exception $e) { die('Error loading file "' . pathinfo($inputFileName, PATHINFO_BASENAME) . '": ' . $e->getMessage()); } $sheet = $objPHPExcel->getSheet(0); $highestRow = $sheet->getHighestRow(); $highestColumn = $sheet->getHighestColumn(); $allDataInSheet = $objPHPExcel->getActiveSheet()->toArray(null,true,true,true); $arrayCount = count($allDataInSheet); // Here get total count of row in that Excel sheet $table='stock_info'; $this->model->table_truncate($table); if(count($allDataInSheet)>0){ for($i=2;$i<=$arrayCount;$i++){ //$partner_code = trim($allDataInSheet[$i]["A"]); $material = trim($allDataInSheet[$i]["A"]); $material_description = trim($allDataInSheet[$i]["B"]); $quantity_in_stock = trim($allDataInSheet[$i]["C"]); $open_po = trim($allDataInSheet[$i]["D"]); $in_transit_stock = trim($allDataInSheet[$i]["E"]); $month_planned_qty = trim($allDataInSheet[$i]["F"]); $remarks = trim($allDataInSheet[$i]["G"]); $data=array('material'=>$material,'material_description'=>$material_description,'quantity_in_stock'=>$quantity_in_stock,'open_po'=>$open_po,'in_transit_stock'=>$in_transit_stock,'month_planned_qty'=>$month_planned_qty,'remarks'=>$remarks); $this->model->insert($table,$data); } redirect('controller/inventory_import'); } } else{ echo '<p style="color:red;">Please upload file with xlsx extension only</p>'; } } } public function imported() { $sessionData = $this->decryptSessionData(); // Check if session is valid if (!isset($sessionData['id'], $sessionData['role'])) { redirect('/'); // Redirect if session is invalid return; } $id_login= $sessionData['id']; $region_login = $sessionData['region']; // $id_login=$this->session->userdata('id'); // $region_login=$this->session->userdata('region'); date_default_timezone_set('Asia/Kolkata'); include '../PHPExcel/IOFactory.php'; if(isset($_FILES['file']['name'])){ $file_name = $_FILES['file']['name']; $ext = pathinfo($file_name, PATHINFO_EXTENSION); if($ext == "xls") { $file_name = $_FILES['file']['tmp_name']; $inputFileName = $file_name; try { $inputFileType = PHPExcel_IOFactory::identify($inputFileName); $objReader = PHPExcel_IOFactory::createReader($inputFileType); $objPHPExcel = $objReader->load($inputFileName); } catch (Exception $e) { die('Error loading file "' . pathinfo($inputFileName, PATHINFO_BASENAME) . '": ' . $e->getMessage()); } $sheet = $objPHPExcel->getSheet(0); $highestRow = $sheet->getHighestRow(); $highestColumn = $sheet->getHighestColumn(); $allDataInSheet = $objPHPExcel->getActiveSheet()->toArray(null,true,true,true); $arrayCount = count($allDataInSheet); // Here get total count of row in that Excel sheet $table='fin_outstanding'; $this->model->table_truncate($table); if(count($allDataInSheet)>0){ for($i=2;$i<=$arrayCount;$i++){ $partner_code = trim($allDataInSheet[$i]["A"]); $partner_name = trim($allDataInSheet[$i]["B"]); $invoice_number = trim($allDataInSheet[$i]["C"]); $invoice_ref_no = trim($allDataInSheet[$i]["D"]); $invoicedate = trim($allDataInSheet[$i]["E"]); $invoice_value = trim($allDataInSheet[$i]["F"]); $due_date = trim($allDataInSheet[$i]["G"]); $data=array('partner_code'=>$partner_code,'partner_name'=>$partner_name,'invoice_number'=>$invoice_number,'invoice_ref_no'=>$invoice_ref_no,'invoicedate'=>$invoicedate,'invoice_value'=>$invoice_value,'due_date'=>$due_date,'region'=>$region_login,'added_by'=>$id_login); $this->model->insert($table,$data); $emails=$this->model->outstanding_email(); foreach($emails as $email) { $email=$email->email; //$partner_name=$email->partner_name; $this->load->library('email'); $this->email->set_mailtype('html'); $msg = "Hi,Your Finance Outstanding statements is updated."; $this->email->from('notify@yaskawa.in', 'yaskawa'); $this->email->to($email, 'yaskawa'); $this->email->subject('Finance Outstanding information'); // //$data['message'] = $msg; $this->email->message($msg); $this->email->send(); } } redirect('controller/outstanding_statement'); } } else{ echo '<p style="color:red;">Please upload file with xls extension only</p>'; } } } public function importie() { date_default_timezone_set('Asia/Kolkata'); include '../PHPExcel/IOFactory.php'; if(isset($_FILES['file']['name'])){ $file_name = $_FILES['file']['name']; $ext = pathinfo($file_name, PATHINFO_EXTENSION); if($ext == "xls") { $file_name = $_FILES['file']['tmp_name']; $inputFileName = $file_name; try { $inputFileType = PHPExcel_IOFactory::identify($inputFileName); $objReader = PHPExcel_IOFactory::createReader($inputFileType); $objPHPExcel = $objReader->load($inputFileName); } catch (Exception $e) { die('Error loading file "' . pathinfo($inputFileName, PATHINFO_BASENAME) . '": ' . $e->getMessage()); } $sheet = $objPHPExcel->getSheet(0); $highestRow = $sheet->getHighestRow(); $highestColumn = $sheet->getHighestColumn(); $allDataInSheet = $objPHPExcel->getActiveSheet()->toArray(null,true,true,true); $arrayCount = count($allDataInSheet); // Here get total count of row in that Excel sheet $table='fin_overdue'; $this->model->table_truncate($table); if(count($allDataInSheet)>0){ for($i=2;$i<=$arrayCount;$i++){ $partner_code = trim($allDataInSheet[$i]["A"]); $partner_name = trim($allDataInSheet[$i]["B"]); $invoice_number = trim($allDataInSheet[$i]["C"]); $invoice_ref_no = trim($allDataInSheet[$i]["D"]); $invoicedate = trim($allDataInSheet[$i]["E"]); $invoice_value = trim($allDataInSheet[$i]["F"]); $due_date = trim($allDataInSheet[$i]["G"]); $data=array('partner_code'=>$partner_code,'partner_name'=>$partner_name,'invoice_number'=>$invoice_number,'invoice_ref_no'=>$invoice_ref_no,'invoicedate'=>$invoicedate,'invoice_value'=>$invoice_value,'due_date'=>$due_date); $this->model->insert($table,$data); $emails=$this->model->overdue_email(); /* foreach($emails as $email) { $email=$email->email; //$partner_name=$email->partner_name; $this->load->library('email'); $this->email->set_mailtype('html'); $msg = "Hi,Your Finance Overdue statements is updated."; $this->email->from('notify@yaskawa.in', 'yaskawa'); $this->email->to($email, 'yaskawa'); $this->email->subject('Finance Overdue information'); // //$data['message'] = $msg; $this->email->message($msg); $this->email->send(); } */ } redirect('controller/overdue_statement'); } } else{ echo '<p style="color:red;">Please upload file with xls extension only</p>'; } } } public function c_form() { date_default_timezone_set('Asia/Kolkata'); include '../PHPExcel/IOFactory.php'; if(isset($_FILES['file']['name'])){ $file_name = $_FILES['file']['name']; $ext = pathinfo($file_name, PATHINFO_EXTENSION); if($ext == "xlsx") { $file_name = $_FILES['file']['tmp_name']; $inputFileName = $file_name; try { $inputFileType = PHPExcel_IOFactory::identify($inputFileName); $objReader = PHPExcel_IOFactory::createReader($inputFileType); $objPHPExcel = $objReader->load($inputFileName); } catch (Exception $e) { die('Error loading file "' . pathinfo($inputFileName, PATHINFO_BASENAME) . '": ' . $e->getMessage()); } $sheet = $objPHPExcel->getSheet(0); $highestRow = $sheet->getHighestRow(); $highestColumn = $sheet->getHighestColumn(); $allDataInSheet = $objPHPExcel->getActiveSheet()->toArray(null,true,true,true); $arrayCount = count($allDataInSheet); // Here get total count of row in that Excel sheet $table='fin_cforms'; $this->model->table_truncate($table); if(count($allDataInSheet)>0){ for($i=2;$i<=$arrayCount;$i++){ $partner_code = trim($allDataInSheet[$i]["A"]); $partner_name = trim($allDataInSheet[$i]["B"]); $month = trim($allDataInSheet[$i]["C"]); $quarter = trim($allDataInSheet[$i]["D"]); $invoice_number = trim($allDataInSheet[$i]["E"]); $date = trim($allDataInSheet[$i]["F"]); $invoicedate = trim($allDataInSheet[$i]["G"]); $taxable_amount = trim($allDataInSheet[$i]["H"]); $cst = trim($allDataInSheet[$i]["I"]); $invoice_value = trim($allDataInSheet[$i]["J"]); $state = trim($allDataInSheet[$i]["K"]); $data=array('partner_code'=>$partner_code,'partner_name'=>$partner_name,'month'=>$month,'quarter'=>$quarter,'invoice_number'=>$invoice_number,'date'=>$date,'invoicedate'=>$invoicedate,'taxable_amount'=>$taxable_amount,'cst'=>$cst,'invoice_value'=>$invoice_value,'state'=>$state); $this->model->insert($table,$data); $emails=$this->model->cform_email(); foreach($emails as $email) { $email=$email->email; //$partner_name=$email->partner_name; $this->load->library('email'); $this->email->set_mailtype('html'); $msg = "Hi,Your C-Forms statements is updated."; $this->email->from('notify@yaskawa.in', 'yaskawa'); $this->email->to($email, 'yaskawa'); $this->email->subject('C-Forms information'); // //$data['message'] = $msg; $this->email->message($msg); $this->email->send(); } } redirect('controller/c_forms'); } } else{ echo '<p style="color:red;">Please upload file with xlsx extension only</p>'; } } } public function importe() { $cc=$this->input->post('demo1'); $ponum=$this->input->post('email'); $partner=$this->input->post('code'); $ref=$this->input->post('pwd'); if(is_uploaded_file($_FILES['file']['tmp_name'])) { $sourcePath = $_FILES['file']['tmp_name']; $targetPath = "uploads/".$_FILES['file']['name']; move_uploaded_file($_FILES['file']['tmp_name'],$targetPath); } $insert_variables = array('po_number'=>$ponum,'partner_code'=>$partner,'reference_code'=>$ref,'acknowledgement'=>$targetPath); print_r($insert_variables); $table='po_info'; $data=$this->model->insert($table,$insert_variables); $w=array('uid'=>$partner); $t='profile'; $details=$this->model->get_where_row($t,$w); $email=$details->email; $this->load->library('email'); $this->email->set_mailtype('html'); $msg = "Hi, new information is added.email:".$email; $this->email->from('notify@yaskawa.in', 'yaskawa'); $this->email->to($email, 'yaskawa'); $this->email->cc($cc); $this->email->subject('Added information'); // //$data['message'] = $msg; $this->email->message($msg); $this->email->send(); redirect('controller/po_import'); } public function outstanding_statements_display() { // $role=$this->session->userdata('role'); // $id=$this->session->userdata('id'); $sessionData = $this->decryptSessionData(); // Check if session is valid if (!isset($sessionData['id'], $sessionData['role'])) { redirect('/'); // Redirect if session is invalid return; } $id = $sessionData['id']; $role = $sessionData['role']; if($id){ if($role==3) { $w=array('id'=>$id); $t='profile'; $data['details']=$this->model->get_where_row($t,$w); $table='fin_outstanding'; $data['outstandings']=$this->model->get_all_data($table); } else { $w=array('id'=>$id); $t='supervisor'; $data['details']=$this->model->get_where_row($t,$w); } $t="fin_outstanding"; $data['time']=$this->model->get_time($t); $this->load->view('includes/admin_header',$data); $this->load->view('outstanding_statements_display',$data); $this->load->view('includes/admin_footer',$data); }else { redirect('/'); } } public function overdue_statements_display() { // $role=$this->session->userdata('role'); // $id=$this->session->userdata('id'); $sessionData = $this->decryptSessionData(); // Check if session is valid if (!isset($sessionData['id'], $sessionData['role'])) { redirect('/'); // Redirect if session is invalid return; } $id = $sessionData['id']; $role = $sessionData['role']; if($id){ if($role==3) { $w=array('id'=>$id); $t='profile'; $data['details']=$this->model->get_where_row($t,$w); $table='fin_overdue'; $data['overdues']=$this->model->get_all_data($table); } else { $w=array('id'=>$id); $t='supervisor'; $data['details']=$this->model->get_where_row($t,$w); } $t="fin_overdue"; $data['time']=$this->model->get_time($t); $this->load->view('includes/admin_header',$data); $this->load->view('overdue_statements_display',$data); $this->load->view('includes/admin_footer',$data); }else { redirect('/'); } } public function c_forms_display() { // $role=$this->session->userdata('role'); // $id=$this->session->userdata('id'); $sessionData = $this->decryptSessionData(); // Check if session is valid if (!isset($sessionData['id'], $sessionData['role'])) { redirect('/'); // Redirect if session is invalid return; } $id = $sessionData['id']; $role = $sessionData['role']; if($id){ if($role==3) { $w=array('id'=>$id); $t='profile'; $data['details']=$this->model->get_where_row($t,$w); $table='fin_cforms'; $data['cforms']=$this->model->get_all_data($table); } else { $w=array('id'=>$id); $t='supervisor'; $data['details']=$this->model->get_where_row($t,$w); } $t="fin_cforms"; $data['time']=$this->model->get_time($t); $this->load->view('includes/admin_header',$data); $this->load->view('c_forms_display',$data); $this->load->view('includes/admin_footer',$data); }else { reditect('/'); } } public function drive_mannual_upload() { // $role=$this->session->userdata('role'); // $department=$this->session->userdata('department'); // $id=$this->session->userdata('id'); $sessionData = $this->decryptSessionData(); if (!isset($sessionData['id'], $sessionData['role'], $sessionData['department'])) { redirect('/'); return; } $id = $sessionData['id']; $role = $sessionData['role']; $department = $sessionData['department']; if (!(($role == '2' && $department == '6') || $role == '3')) { log_message('error', "Unauthorized access attempt. Role: $role, Department: $department"); redirect('/'); return; } if($role==3) { $w=array('id'=>$id); $t='profile'; $data['details']=$this->model->get_where_row($t,$w); } else { $w=array('id'=>$id); $t='supervisor'; $data['details']=$this->model->get_where_row($t,$w); } $tab="manuals"; $data['time']=$this->model->get_time($tab); $data['manuals']=$this->model->get_all_data($tab); $this->load->view('driver_mannual_upload',$data); } public function case_stories_upload() { // $role=$this->session->userdata('role'); // $department=$this->session->userdata('department'); // $id=$this->session->userdata('id'); $sessionData = $this->decryptSessionData(); if (!isset($sessionData['id'], $sessionData['role'], $sessionData['department'])) { redirect('/'); return; } $id = $sessionData['id']; $role = $sessionData['role']; $department = $sessionData['department']; if (!(($role == '2' && $department == '6') || $role == '3')) { log_message('error', "Unauthorized access attempt. Role: $role, Department: $department"); redirect('/'); return; } if($role==3) { $w=array('id'=>$id); $t='profile'; $data['details']=$this->model->get_where_row($t,$w); } else { $w=array('id'=>$id); $t='supervisor'; $data['details']=$this->model->get_where_row($t,$w); } $tab="case_stories"; $data['time']=$this->model->get_time($tab); $this->load->view('case_stories_upload',$data); } public function outstanding_view() { $sessionData = $this->decryptSessionData(); if (!$sessionData || !isset($sessionData['id']) || $sessionData['role'] != '1') { redirect('controller/login'); } $t="fin_outstanding"; $data['time']=$this->model->get_time($t); $this->load->view('outstanding_statement_view',$data); } public function reg_outstanding_view() { $sessionData = $this->decryptSessionData(); if (!$sessionData || !isset($sessionData['id']) || $sessionData['role'] != '8') { redirect('controller/login'); } $t="fin_outstanding"; $data['time']=$this->model->get_time($t); $this->load->view('reg_outstanding_statement_view',$data); } public function outstanding_insert() { /*$table='fin_outstanding'; $where=array('status'=>0); $details=$this->model->fetch_where_data($table,$where); echo json_encode($details);*/ $page = isset($_POST['page'])?$_POST['page']:1; $limit = isset($_POST['rows'])?$_POST['rows']:1000; $sidx = isset($_POST['sidx'])?$_POST['sidx']:'id'; $sord = isset($_POST['sord'])?$_POST['sord']:''; $totalrows = isset($_REQUEST['totalrows']) ? $_REQUEST['totalrows']: false; if($totalrows) { $limit = $totalrows; } $start = $limit*$page - $limit; $start = ($start<0)?0:$start; $where = ""; $searchField = isset($_POST['searchField']) ? $_POST['searchField'] : false; $searchOper = isset($_POST['searchOper']) ? $_POST['searchOper']: false; $searchString = isset($_POST['searchString']) ? $_POST['searchString'] : false; if(!$sidx) $sidx =1; $whers=array('status'=>0); $table='fin_outstanding'; $count = $this->model->fetch_where_data($table,$whers); $count=count($count); if( $count > 0 ) { $total_pages = ceil($count/$limit); } else { $total_pages = 0; } if ($page > $total_pages) $page=$total_pages; $query = $this->model->getdata($start,$limit,$sidx,$sord,$whers,$table); $responce = array(); $responce["page"] = $page; $responce["total"] = $total_pages; $responce["records"] = $count; $i=0; foreach($query as $row) { $responce["rows"][$i]['id']=$row->id; $responce["rows"][$i]['cell']=array($row->id,$row->partner_code,$row->partner_name,$row->invoice_number,$row->invoice_ref_no,$row->invoicedate,$row->invoice_value,$row->due_date); $i++; } echo json_encode($responce); } public function outstanding_add() { $cc=$this->input->post('cc'); $partner_code=$this->input->post('partner_code'); $partner_name=$this->input->post('partner_name'); $invoice_number=$this->input->post('invoice_number'); $invoice_ref_no=$this->input->post('invoice_ref_no'); $invoicedate=$this->input->post('invoicedate'); $invoice_value=$this->input->post('invoice_value'); $due_date=$this->input->post('due_date'); $table1='profile'; $where=array('id'=>$partner_code); $date['get']=$this->model->get_where_row($table1,$where); $email=$date['get']->email; $data=array('partner_code'=>$partner_code,'partner_name'=>$partner_name,'invoice_number'=>$invoice_number,'invoice_ref_no'=>$invoice_ref_no,'invoicedate'=>$invoicedate,'invoice_value'=>$invoice_value,'due_date'=>$due_date); $table='fin_outstanding'; $this->model->insert($table,$data); $this->load->library('email'); $this->email->set_mailtype('html'); $msg = "Hi, new information is added:".$partner_name.','."email:".$email; $this->email->from('notify@yaskawa.in', 'yaskawa'); $this->email->to($email, 'yaskawa'); $this->email->cc($cc); $this->email->subject('Added information'); // //$data['message'] = $msg; $this->email->message($msg); $this->email->send(); return true; } public function outstanding_edit() { $cc=$this->input->post('cc'); $id=$this->input->post('id'); $partner_code=$this->input->post('partner_code'); $partner_name=$this->input->post('partner_name'); $invoice_number=$this->input->post('invoice_number'); $invoice_ref_no=$this->input->post('invoice_ref_no'); $invoicedate=$this->input->post('invoicedate'); $invoice_value=$this->input->post('invoice_value'); $due_date=$this->input->post('due_date'); $table1='profile'; $where=array('id'=>$partner_code); $date['get']=$this->model->get_where_row($table1,$where); $email=$date['get']->email; $data=array('partner_code'=>$partner_code,'partner_name'=>$partner_name,'invoice_number'=>$invoice_number,'invoice_ref_no'=>$invoice_ref_no,'invoicedate'=>$invoicedate,'invoice_value'=>$invoice_value,'due_date'=>$due_date); $table='fin_outstanding'; $where=array('id'=>$id); $this->model->update_new($where,$table,$data); $this->load->library('email'); $this->email->set_mailtype('html'); $msg = "Hi, information is updated:".$partner_name.','."email:".$email; $this->email->from('notify@yaskawa.in', 'yaskawa'); $this->email->to($email, 'yaskawa'); $this->email->cc($cc); $this->email->subject('Added information'); // //$data['message'] = $msg; $this->email->message($msg); $this->email->send(); return true; } public function outstanding_delete() { $cc=$this->input->post('cc'); $id=$this->input->post('id'); $table1='profile'; $where1=array('id'=>$partner_code); $date['get']=$this->model->get_where_row($table1,$where1); $email=$date['get']->email; $table='fin_outstanding'; $where=array('id'=>$id); $this->model->delete($table,$where); $this->load->library('email'); $this->email->set_mailtype('html'); $msg = "Hi, New out standing statement is added:"."email:".$email; $this->email->from('notify@yaskawa.in', 'yaskawa'); $this->email->to($email, 'yaskawa'); $this->email->cc($cc); $this->email->subject('Deleted information'); // //$data['message'] = $msg; $this->email->message($msg); $this->email->send(); return true; } public function overdue_view() { $sessionData = $this->decryptSessionData(); if (!$sessionData || !isset($sessionData['id']) || $sessionData['role'] != '1') { redirect('controller/login'); } $t="fin_overdue"; $data['time']=$this->model->get_time($t); $this->load->view('overdue_statement_view',$data); } public function reg_overdue_view() { $sessionData = $this->decryptSessionData(); if (!$sessionData || !isset($sessionData['id']) || $sessionData['role'] != '8') { redirect('controller/login'); } $t="fin_overdue"; $data['time']=$this->model->get_time($t); $this->load->view('reg_overdue_statement_view',$data); } public function overdue_insert() { /*$table='fin_overdue'; $where=array('status'=>0); $details=$this->model->fetch_where_data($table,$where); echo json_encode($details);*/ $page = isset($_POST['page'])?$_POST['page']:1; $limit = isset($_POST['rows'])?$_POST['rows']:1000; $sidx = isset($_POST['sidx'])?$_POST['sidx']:'id'; $sord = isset($_POST['sord'])?$_POST['sord']:''; $totalrows = isset($_REQUEST['totalrows']) ? $_REQUEST['totalrows']: false; if($totalrows) { $limit = $totalrows; } $start = $limit*$page - $limit; $start = ($start<0)?0:$start; $where = ""; $searchField = isset($_POST['searchField']) ? $_POST['searchField'] : false; $searchOper = isset($_POST['searchOper']) ? $_POST['searchOper']: false; $searchString = isset($_POST['searchString']) ? $_POST['searchString'] : false; if(!$sidx) $sidx =1; $whers=array('status'=>0); $table='fin_overdue'; $count = $this->model->fetch_where_data($table,$whers); $count=count($count); if( $count > 0 ) { $total_pages = ceil($count/$limit); } else { $total_pages = 0; } if ($page > $total_pages) $page=$total_pages; $query = $this->model->getdata($start,$limit,$sidx,$sord,$whers,$table); $responce = array(); $responce["page"] = $page; $responce["total"] = $total_pages; $responce["records"] = $count; $i=0; foreach($query as $row) { $responce["rows"][$i]['id']=$row->id; $responce["rows"][$i]['cell']=array($row->id,$row->partner_code,$row->partner_name,$row->invoice_number,$row->invoice_ref_no,$row->invoicedate,$row->invoice_value,$row->due_date); $i++; } echo json_encode($responce); } public function overdue_add() { $cc=$this->input->post('cc'); $partner_code=$this->input->post('partner_code'); $partner_name=$this->input->post('partner_name'); $invoice_number=$this->input->post('invoice_number'); $invoice_ref_no=$this->input->post('invoice_ref_no'); if($this->input->post('invoicedate')!="") { //$date=date("Y-m-d",strtotime($date1)); list($date, $month, $year) = explode("/", $this->input->post('invoicedate')); $date = $year . '-' . $month . '-' . $date; } $invoicedate=$date; $invoice_value=$this->input->post('invoice_value'); if($this->input->post('due_date')!="") { //$date=date("Y-m-d",strtotime($date1)); list($date, $month, $year) = explode("/", $this->input->post('due_date')); $dates = $year . '-' . $month . '-' . $date; } $due_date=$dates; $data=array('partner_code'=>$partner_code,'partner_name'=>$partner_name,'invoice_number'=>$invoice_number,'invoice_ref_no'=>$invoice_ref_no,'invoicedate'=>$invoicedate,'invoice_value'=>$invoice_value,'due_date'=>$due_date); $table='fin_overdue'; $this->model->insert($table,$data); $table1='profile'; $where=array('id'=>$partner_code); $date['get']=$this->model->get_where_row($table1,$where); $email=$date['get']->email; $this->load->library('email'); $this->email->set_mailtype('html'); $msg = "Hi, new information is added:".$partner_name."email:".$email; $this->email->from('notify@yaskawa.in', 'yaskawa'); $this->email->to($email, 'yaskawa'); $this->email->cc($cc); $this->email->subject('Added information'); // //$data['message'] = $msg; $this->email->message($msg); $this->email->send(); return true; } public function overdue_edit() { $cc=$this->input->post('cc'); $id=$this->input->post('id'); $partner_code=$this->input->post('partner_code'); $partner_name=$this->input->post('partner_name'); $invoice_number=$this->input->post('invoice_number'); $invoice_ref_no=$this->input->post('invoice_ref_no'); $invoicedate=$this->input->post('invoicedate'); $invoice_value=$this->input->post('invoice_value'); $due_date=$this->input->post('due_date'); $table1='profile'; $where1=array('id'=>$partner_code); $date['get']=$this->model->get_where_row($table1,$where1); $email=$date['get']->email; $data=array('partner_code'=>$partner_code,'partner_name'=>$partner_name,'invoice_number'=>$invoice_number,'invoice_ref_no'=>$invoice_ref_no,'invoicedate'=>$invoicedate,'invoice_value'=>$invoice_value,'due_date'=>$due_date); $table='fin_overdue'; $where=array('id'=>$id); $this->model->update_new($where,$table,$data); $this->load->library('email'); $this->email->set_mailtype('html'); $msg = "Hi, new information is added:".$partner_name.','."email:".$email; $this->email->from('notify@yaskawa.in', 'yaskawa'); $this->email->to($email, 'yaskawa'); $this->email->cc($cc); $this->email->subject('Added information'); // //$data['message'] = $msg; $this->email->message($msg); $this->email->send(); return true; } public function overdue_delete() { $cc=$this->input->post('cc'); $id=$this->input->post('id'); $table='fin_overdue'; $where=array('id'=>$id); $this->model->delete($table,$where); $table1='profile'; $where=array('id'=>$partner_code); $date['get']=$this->model->get_where_row($table1,$where); $email=$date['get']->email; $this->load->library('email'); $this->email->set_mailtype('html'); $msg = "Hi, new information is added.email:".$email; $this->email->from('notify@yaskawa.in', 'yaskawa'); $this->email->to($email, 'yaskawa'); $this->email->cc($cc); $this->email->subject('Added information'); // //$data['message'] = $msg; $this->email->message($msg); $this->email->send(); return true; } public function cform_view() { $sessionData = $this->decryptSessionData(); if (!$sessionData || !isset($sessionData['id']) || $sessionData['role'] != '1') { redirect('controller/login'); } $t="fin_cforms"; $data['time']=$this->model->get_time($t); $this->load->view('c_forms_view',$data); } public function reg_cform_view() { $sessionData = $this->decryptSessionData(); if (!$sessionData || !isset($sessionData['id']) || $sessionData['role'] != '8') { redirect('controller/login'); } $t="fin_cforms"; $data['time']=$this->model->get_time($t); $this->load->view('reg_c_forms_view',$data); } public function cform_insert() { /*$table='fin_cforms'; $where=array('status'=>0); $details=$this->model->fetch_where_data($table,$where); echo json_encode($details);*/ $page = isset($_POST['page'])?$_POST['page']:1; $limit = isset($_POST['rows'])?$_POST['rows']:10; $sidx = isset($_POST['sidx'])?$_POST['sidx']:'id'; $sord = isset($_POST['sord'])?$_POST['sord']:''; $totalrows = isset($_REQUEST['totalrows']) ? $_REQUEST['totalrows']: false; if($totalrows) { $limit = $totalrows; } $start = $limit*$page - $limit; $start = ($start<0)?0:$start; $where = ""; $searchField = isset($_POST['searchField']) ? $_POST['searchField'] : false; $searchOper = isset($_POST['searchOper']) ? $_POST['searchOper']: false; $searchString = isset($_POST['searchString']) ? $_POST['searchString'] : false; if(!$sidx) $sidx =1; $whers=array('status'=>0); $table='fin_cforms'; $count = $this->model->fetch_where_data($table,$whers); $count=count($count); if( $count > 0 ) { $total_pages = ceil($count/$limit); } else { $total_pages = 0; } if ($page > $total_pages) $page=$total_pages; $query = $this->model->getdata($start,$limit,$sidx,$sord,$whers,$table); $responce = array(); $responce["page"] = $page; $responce["total"] = $total_pages; $responce["records"] = $count; $i=0; foreach($query as $row) { $responce["rows"][$i]['id']=$row->id; $responce["rows"][$i]['cell']=array($row->id,$row->partner_code,$row->partner_name,$row->month,$row->quarter,$row->invoice_number,$row->date,$row->invoicedate,$row->taxable_amount,$row->cst,$row->invoice_value,$row->state); $i++; } echo json_encode($responce); } public function cform_add() { $cc=$this->input->post('cc'); $partner_code=$this->input->post('partner_code'); $partner_name=$this->input->post('partner_name'); $month=$this->input->post('month'); $quarter=$this->input->post('quarter'); $invoice_number=$this->input->post('invoice_number'); $date=$this->input->post('date'); $invoicedate=$this->input->post('invoicedate'); $taxable_amount=$this->input->post('taxable_amount'); $cst=$this->input->post('cst'); $invoice_value=$this->input->post('invoice_value'); $state=$this->input->post('state'); $data=array('partner_code'=>$partner_code,'partner_name'=>$partner_name,'month'=>$month,'quarter'=>$quarter,'invoice_number'=>$invoice_number,'date'=>$date,'invoicedate'=>$invoicedate,'taxable_amount'=>$taxable_amount,'cst'=>$cst,'invoicedate'=>$invoicedate,'invoice_value'=>$invoice_value,'state'=>$state); $table='fin_cforms'; $this->model->insert($table,$data); $table1='profile'; $where1=array('id'=>$partner_code); $date['get']=$this->model->get_where_row($table1,$where1); $email=$date['get']->email; $this->load->library('email'); $this->email->set_mailtype('html'); $msg = "Hi, new information is added:".$partner_name.','."email:".$email; $this->email->from('notify@yaskawa.in', 'yaskawa'); $this->email->to($email, 'yaskawa'); $this->email->cc($cc); $this->email->subject('Added information'); // //$data['message'] = $msg; $this->email->message($msg); $this->email->send(); return true; } public function cform_edit() { $cc=$this->input->post('cc'); $id=$this->input->post('id'); $partner_code=$this->input->post('partner_code'); $partner_name=$this->input->post('partner_name'); $month=$this->input->post('month'); $quarter=$this->input->post('quarter'); $invoice_number=$this->input->post('invoice_number'); $date=$this->input->post('date'); $invoicedate=$this->input->post('invoicedate'); $taxable_amount=$this->input->post('taxable_amount'); $cst=$this->input->post('cst'); $invoice_value=$this->input->post('invoice_value'); $state=$this->input->post('state'); $data=array('partner_code'=>$partner_code,'partner_name'=>$partner_name,'month'=>$month,'quarter'=>$quarter,'invoice_number'=>$invoice_number,'date'=>$date,'invoicedate'=>$invoicedate,'taxable_amount'=>$taxable_amount,'cst'=>$cst,'invoicedate'=>$invoicedate,'invoice_value'=>$invoice_value,'state'=>$state); $table='fin_cforms'; $where=array('id'=>$id); $this->model->update_new($where,$table,$data); $table1='profile'; $where1=array('id'=>$partner_code); $date['get']=$this->model->get_where_row($table1,$where1); $email=$date['get']->email; $this->load->library('email'); $this->email->set_mailtype('html'); $msg = "Hi, information is edited:".$partner_name.','."email:".$email; $this->email->from('notify@yaskawa.in', 'yaskawa'); $this->email->to($email, 'yaskawa'); $this->email->cc($cc); $this->email->subject('Added information'); // //$data['message'] = $msg; $this->email->message($msg); $this->email->send(); return true; } public function cform_delete() { $cc=$this->input->post('cc'); $id=$this->input->post('id'); $table='fin_cforms'; $where=array('id'=>$id); $this->model->delete($table,$where); $table1='profile'; $where1=array('id'=>$id); $date['get']=$this->model->get_where_row($table1,$where1); $email=$date['get']->email; $this->load->library('email'); $this->email->set_mailtype('html'); $msg = "Hi, information is edited.email:".$email; $this->email->from('notify@yaskawa.in', 'yaskawa'); $this->email->to($email, 'yaskawa'); $this->email->cc($cc); $this->email->subject('Added information'); // //$data['message'] = $msg; $this->email->message($msg); $this->email->send(); return true; } public function drive_catalogues_view() { $sessionData = $this->decryptSessionData(); if (!$sessionData || !isset($sessionData['id']) || $sessionData['role'] != '1') { redirect('controller/login'); } $t="manuals"; $data['time']=$this->model->get_time($t); $this->load->view('drive_catalogues_view',$data); } public function reg_drive_catalogues_view() { $sessionData = $this->decryptSessionData(); if (!$sessionData || !isset($sessionData['id']) || $sessionData['role'] != '8') { redirect('controller/login'); } $t="manuals"; $data['time']=$this->model->get_time($t); $this->load->view('reg_drive_catalogues_view',$data); } public function drive_catalogues_insert() { $table='manuals'; $where=array('status'=>0); $result=$this->model->drive_manual($table,$where); echo json_encode($result); } public function drive_catalogues_add() { $product_name=$this->input->post('product_name'); $category=$this->input->post('category'); $document_type=$this->input->post('document_type'); $parent_type=$this->input->post('parent_type'); $option_card_name=$this->input->post('option_card_name'); if(is_uploaded_file($_FILES['attachment']['tmp_name'])) { $sourcePath = $_FILES['attachment']['tmp_name']; $targetPath = "uploads/mannual_uploads".$_FILES['attachment']['name']; move_uploaded_file($_FILES['attachment']['tmp_name'],$targetPath); } else { $targetPath=""; } $attachment=$targetPath; $data=array('product_name'=>$product_name,'category'=>$category,'document_type'=>$document_type,'document_sub_type'=>$parent_type,'option_card_name'=>$option_card_name,'attachment'=>$attachment); $table='manuals'; $this->model->insert($table,$data); return true; } public function drive_catalogues_edit() { $id=$this->input->post('update_id'); $product_name=$this->input->post('update_product_name'); $category=$this->input->post('update_category'); $document_type=$this->input->post('update_document_type'); $parent_type=$this->input->post('update_document_sub_type'); $option_card_name=$this->input->post('update_option_card_name'); if(is_uploaded_file($_FILES['update_attachment']['tmp_name'])) { $sourcePath = $_FILES['update_attachment']['tmp_name']; $targetPath = "uploads/manual_uploads".$_FILES['update_attachment']['name']; move_uploaded_file($_FILES['update_attachment']['tmp_name'],$targetPath); $attachment=$targetPath; $data=array('product_name'=>$product_name,'category'=>$category,'document_type'=>$document_type,'document_sub_type'=>$parent_type,'option_card_name'=>$option_card_name,'attachment'=>$attachment); } else { $data=array('product_name'=>$product_name,'category'=>$category,'document_type'=>$document_type,'document_sub_type'=>$parent_type,'option_card_name'=>$option_card_name); } $table='manuals'; $where=array('id'=>$id); $this->model->update_new($where,$table,$data); // return true; redirect('controller/drive_mannual_upload'); } public function priority_edit() { $id=$this->input->post('update_id'); $priority=$this->input->post('priority'); $data=array('priority'=>$priority); $table='manuals'; $where=array('id'=>$id); $this->model->update_new($where,$table,$data); // return true; redirect('controller/drive_mannual_upload'); } public function drive_catalogues_fetch() { $id=$this->input->post('id'); $table='manuals'; $where=array('id'=>$id); $data=$this->model->get_where_row($table,$where); echo json_encode($data); } public function drive_catalogues_delete() { $id=$this->input->post('id'); $table='manuals'; $where=array('id'=>$id); $this->model->delete($table,$where); return true; } public function case_stories_view() { $sessionData = $this->decryptSessionData(); if (!$sessionData || !isset($sessionData['id']) || $sessionData['role'] != '1') { redirect('controller/login'); } $t="case_stories"; $data['time']=$this->model->get_time($t); $this->load->view('case_stories_view',$data); } public function reg_case_stories_view() { $sessionData = $this->decryptSessionData(); if (!$sessionData || !isset($sessionData['id']) || $sessionData['role'] != '8') { redirect('controller/login'); } $t="case_stories"; $data['time']=$this->model->get_time($t); $this->load->view('reg_case_stories_view',$data); } public function case_stories_insert() { $table='case_stories'; $where=array('status'=>0); $result=$this->model->get_all_data_new($table,$where); echo json_encode($result); } public function case_stories_add() { //$partner_code=$this->input->post('partner_code'); $industry=$this->input->post('industry'); $application=$this->input->post('application'); $product_type=$this->input->post('product_type'); $document_name=$this->input->post('document_name'); $document=$this->input->post('document'); $data=array('industry'=>$industry,'application'=>$application,'product_type'=>$product_type,'document_name'=>$document_name,'document'=>$document); $table='case_stories'; $this->model->insert($table,$data); return true; } public function case_stories_edit() { $id=$this->input->post('update_id'); //$partner_code=$this->input->post('partner_code'); $industry=$this->input->post('update_industry'); $application=$this->input->post('update_application'); $product_type=$this->input->post('update_product_type'); $document_name=$this->input->post('update_document_name'); //$createdate=$this->input->post('createdate'); // $document=$this->input->post('update_document'); if(is_uploaded_file($_FILES['update_document']['tmp_name'])) { $document = $_FILES['update_document']['tmp_name']; $document = "uploads/case_uploads/".$_FILES['update_document']['name']; move_uploaded_file($_FILES['update_document']['tmp_name'],$document); $data=array('industry'=>$industry,'application'=>$application,'product_type'=>$product_type,'document_no'=>$document_name,'document'=>$document); } else { $data=array('industry'=>$industry,'application'=>$application,'product_type'=>$product_type,'document_no'=>$document_name); } $table='case_stories'; $where=array('case_id'=>$id); $this->model->update_new($where,$table,$data); redirect('controller/case_stories_upload'); } public function case_stories_delete() { $id=$this->input->post('id'); $table='case_stories'; $where=array('case_id'=>$id); $this->model->delete($table,$where); return true; } public function download1() { $this->load->helper('download'); $path ='./application/sample_excel/Sample_Stock_Info.xlsx'; ob_clean(); $data = file_get_contents($path); // Read the file's contents $name = 'Sample_Stock_Info.xlsx'; force_download($name, $data); redirect('controller/inventory_import'); } public function download2() { $this->load->helper('download'); $path ='./application/sample_excel/FIN_Outstanding.xls'; ob_clean(); $data = file_get_contents($path); // Read the file's contents $name = 'Sample_out_standing.xls'; force_download($name, $data); redirect('controller/outstanding_statement'); } public function download3() { $this->load->helper('download'); $path ='./application/sample_excel/Sample ABP Overdue Statement.xls'; ob_clean(); $data = file_get_contents($path); // Read the file's contents $name = 'Sample_overdue_statement.xls'; force_download($name, $data); redirect('controller/overdue_statement'); } public function download4() { $this->load->helper('download'); $path ='./application/sample_excel/Sample ABP C forms.xlsx'; ob_clean(); $data = file_get_contents($path); // Read the file's contents $name = 'Sample ABP C forms.xlsx'; force_download($name, $data); redirect('controller/c_forms'); } public function download_product() { $this->load->helper('download'); $path ='./application/sample_excel/Sample_Product.xlsx'; ob_clean(); $data = file_get_contents($path); // Read the file's contents $name = 'Sample_product_list.xlsx'; force_download($name, $data); redirect('controller/add_product'); } public function download_shipment() { $this->load->helper('download'); $path ='./application/sample_excel/Sample_Shipment.xlsx'; ob_clean(); $data = file_get_contents($path); // Read the file's contents $name = 'Sample_shipment_address.xlsx'; force_download($name, $data); redirect('controller/add_product'); } public function autocomplete() { $keyword=$this->input->post('category'); $data1=$this->model->GetRowlog($keyword); //print_r($keyword); foreach($data1 as $row) { $data[]=$row->category; } echo json_encode($data); } public function product_view() { $page = $this->input->post('page'); $limit = $this->input->post('rows'); $sidx = $this->input->post('sidx'); $sord = $this->input->post('sord'); $totalrows = isset($_REQUEST['totalrows']) ? $_REQUEST['totalrows']: false; if($totalrows) { $limit = $totalrows; } $start = $limit*$page - $limit; $start = ($start<0)?0:$start; $where = ""; $searchField = isset($_POST['searchField']) ? $_POST['searchField'] : false; $searchOper = isset($_POST['searchOper']) ? $_POST['searchOper']: false; $searchString = isset($_POST['searchString']) ? $_POST['searchString'] : false; if(!$sidx) $sidx =1; //$count = $this->db->count_all_results('rate'); $whers=array('status'=>0); $table1='product_list'; $count = $this->model->fetch_where_data($table1,$whers); //echo $count; $count=count($count); if( $count > 0 ) { $total_pages = ceil($count/$limit); //echo $total_pages; } else { $total_pages = 0; } if ($page > $total_pages) $page=$total_pages; $query = $this->model->getdata($start,$limit,$sidx,$sord,$whers,$table1); //print_r($query); $responce = array(); $responce["page"] = $page; $responce["total"] = $total_pages; $responce["records"] = $count; $i=0; foreach($query as $row) { $responce["rows"][$i]['id']=$row->id; $responce["rows"][$i]['cell']=array($row->id,$row->product,$row->createdate); $i++; } echo json_encode($responce); } public function product_add() { $product=$this->input->post('product'); $createdate=$this->input->post('createdate'); $rate=array('product'=>$product); $table='product_list'; $det=$this->model->fetch_where_data($table,$rate); if((count($det))>0) { return false; } else { $this->model->insert($table,$rate); } return true; } public function product_edit() { $id=$this->input->post('id'); $product=$this->input->post('product'); $createdate=$this->input->post('createdate'); $rate=array('product'=>$product); $table='product_list'; $where=array('id'=>$id); $data=$this->model->get_where_row($table,$where); if(count($data)>0) { $this->model->update_new($where,$table,$rate); } else return ""; } public function product_delete() { $id=$this->input->post('id'); $table='product_list'; $where=array('id'=>$id); $this->model->delete($table,$where); return true; } public function category_view() { $page = $this->input->post('page'); $limit = $this->input->post('rows'); $sidx = $this->input->post('sidx'); $sord = $this->input->post('sord'); $totalrows = isset($_REQUEST['totalrows']) ? $_REQUEST['totalrows']: false; if($totalrows) { $limit = $totalrows; } $start = $limit*$page - $limit; $start = ($start<0)?0:$start; $where = ""; $searchField = isset($_POST['searchField']) ? $_POST['searchField'] : false; $searchOper = isset($_POST['searchOper']) ? $_POST['searchOper']: false; $searchString = isset($_POST['searchString']) ? $_POST['searchString'] : false; if(!$sidx) $sidx =1; //$count = $this->db->count_all_results('rate'); $whers=array('status'=>0); $table1='category'; $count = $this->model->fetch_where_data($table1,$whers); //echo $count; $count=count($count); if( $count > 0 ) { $total_pages = ceil($count/$limit); //echo $total_pages; } else { $total_pages = 0; } if ($page > $total_pages) $page=$total_pages; $query = $this->model->getdata($start,$limit,$sidx,$sord,$whers,$table1); //print_r($query); $responce = array(); $responce["page"] = $page; $responce["total"] = $total_pages; $responce["records"] = $count; $i=0; foreach($query as $row) { $responce["rows"][$i]['id']=$row->id; $responce["rows"][$i]['cell']=array($row->id,$row->category,$row->createdate); $i++; } echo json_encode($responce); } public function category_add() { $category=$this->input->post('category'); $createdate=$this->input->post('createdate'); $rate=array('category'=>$category); $table='category'; $det=$this->model->fetch_where_data($table,$rate); if((count($det))>0) { return false; } else { $this->model->insert($table,$rate); } return true; } public function category_edit() { $id=$this->input->post('id'); $category=$this->input->post('category'); $createdate=$this->input->post('createdate'); $rate=array('category'=>$category); $table='category'; $where=array('id'=>$id); $data=$this->model->get_where_row($table,$where); if(count($data)>0) { $this->model->update_new($where,$table,$rate); } else return ""; } public function category_delete() { $id=$this->input->post('id'); $table='category'; $where=array('id'=>$id); $this->model->delete($table,$where); return true; } public function drive_catalogues_insert1() { $sessionData = $this->decryptSessionData(); $id= $sessionData['region']; // $id=$this->session->userdata('region'); $table='manuals'; $where=array('status'=>0); $details=$this->model->get_all_data($table); echo json_encode($details); } public function cform_insert1() { $sessionData = $this->decryptSessionData(); $id= $sessionData['region']; // $id=$this->session->userdata('region'); $table='fin_cforms'; $where=array('status'=>0); $details=$this->model->get_cform($id); echo json_encode($details); } public function outstanding_insert1() { $sessionData = $this->decryptSessionData(); $id= $sessionData['region']; // $id=$this->session->userdata('region'); $table='fin_outstanding'; $where=array('partner_code'=>$id); $details=$this->model->region_get_outed($id); //print_r($details); echo json_encode($details); } public function po_view_insert1() { $sessionData = $this->decryptSessionData(); $id= $sessionData['region']; // $id=$this->session->userdata('region'); if ($_REQUEST['_search'] == 'false') { $table='po_info'; $where=array('status'=>0,'partner_code'=>$id); $details=$this->model->region_get_po($id); //print_r($details); echo json_encode($details); $page = isset($_POST['page'])?$_POST['page']:2; $limit = isset($_POST['rows'])?$_POST['rows']:5; $sidx = isset($_POST['sidx'])?$_POST['sidx']:'po_id'; $sord = isset($_POST['sord'])?$_POST['sord']:''; } } public function stock_updates_view_insert1() { // $id=$this->session->userdata('region'); $sessionData = $this->decryptSessionData(); $id= $sessionData['region']; if ($_REQUEST['_search'] == 'false') { $table='stock_info'; $details=$this->model->get_all_data($table); //print_r($details); echo json_encode($details); $page = isset($_POST['page'])?$_POST['page']:2; $limit = isset($_POST['rows'])?$_POST['rows']:5; $sidx = isset($_POST['sidx'])?$_POST['sidx']:'stock_id'; $sord = isset($_POST['sord'])?$_POST['sord']:''; } } public function overdue_insert1() { // $id=$this->session->userdata('region'); $sessionData = $this->decryptSessionData(); $id= $sessionData['region']; //print_r($id); $table='fin_overdue'; $where=array('partner_code'=>$id); $details=$this->model->region_get($id); echo json_encode($details); } public function stock_updates_display_abp() { /*$id=$this->session->userdata('uid'); $table='stock_info'; $details=$this->model->partner_code($table,$id); echo json_encode($details);*/ // $id=$this->session->userdata('uid'); $sessionData = $this->decryptSessionData(); $id= $sessionData['uid']; $page = isset($_POST['page'])?$_POST['page']:1; $limit = isset($_POST['rows'])?$_POST['rows']:10; $sidx = isset($_POST['sidx'])?$_POST['sidx']:'id'; $sord = isset($_POST['sord'])?$_POST['sord']:''; $totalrows = isset($_REQUEST['totalrows']) ? $_REQUEST['totalrows']: false; if($totalrows) { $limit = $totalrows; } $start = $limit*$page - $limit; $start = ($start<0)?0:$start; $where = ""; $searchField = isset($_POST['searchField']) ? $_POST['searchField'] : false; $searchOper = isset($_POST['searchOper']) ? $_POST['searchOper']: false; $searchString = isset($_POST['searchString']) ? $_POST['searchString'] : false; if(!$sidx) $sidx =1; //$count = $this->db->count_all_results('rate'); $whers=array('status'=>0); $table='stock_info'; $count = $this->model->get_all_data($table); //echo $count; $count=count($count); if( $count > 0 ) { $total_pages = ceil($count/$limit); //echo $total_pages; } else { $total_pages = 0; } if ($page > $total_pages) $page=$total_pages; $query = $this->model->getdata($start,$limit,$sidx,$sord,$whers,$table); //print_r($query); $responce = array(); $responce["page"] = $page; $responce["total"] = $total_pages; $responce["records"] = $count; $i=0; foreach($query as $row) { $responce["rows"][$i]['id']=$row->stock_id; $responce["rows"][$i]['cell']=array($row->stock_id,$row->material,$row->material_description,$row->quantity_in_stock,$row->open_po,$row->in_transit_stock,$row->month_planned_qty,$row->remarks); $i++; } echo json_encode($responce); } public function overdue_display_insert() { /*$table='fin_overdue'; $id=$this->session->userdata('uid'); $details=$this->model->partner_code($table,$id); echo json_encode($details);*/ // $id=$this->session->userdata('uid'); $sessionData = $this->decryptSessionData(); $id= $sessionData['uid']; $page = isset($_POST['page'])?$_POST['page']:1; $limit = isset($_POST['rows'])?$_POST['rows']:10; $sidx = isset($_POST['sidx'])?$_POST['sidx']:'id'; $sord = isset($_POST['sord'])?$_POST['sord']:''; $totalrows = isset($_REQUEST['totalrows']) ? $_REQUEST['totalrows']: false; if($totalrows) { $limit = $totalrows; } $start = $limit*$page - $limit; $start = ($start<0)?0:$start; $where = ""; $searchField = isset($_POST['searchField']) ? $_POST['searchField'] : false; $searchOper = isset($_POST['searchOper']) ? $_POST['searchOper']: false; $searchString = isset($_POST['searchString']) ? $_POST['searchString'] : false; if(!$sidx) $sidx =1; //$count = $this->db->count_all_results('rate'); $whers=array('status'=>0); $table='fin_overdue'; $count = $this->model->partner_code1($table,$whers,$id); //echo $count; $count=count($count); if( $count > 0 ) { $total_pages = ceil($count/$limit); //echo $total_pages; } else { $total_pages = 0; } if ($page > $total_pages) $page=$total_pages; $query = $this->model->getdata2($start,$limit,$sidx,$sord,$whers,$table,$id); //print_r($query); $responce = array(); $responce["page"] = $page; $responce["total"] = $total_pages; $responce["records"] = $count; $i=0; foreach($query as $row) { $responce["rows"][$i]['id']=$row->id; $responce["rows"][$i]['cell']=array($row->id,$row->partner_code,$row->partner_name,$row->invoice_number,$row->invoice_ref_no,$row->invoicedate,$row->invoice_value,$row->due_date); $i++; } echo json_encode($responce); } public function cform_display_insert() { /*$id=$this->session->userdata('uid'); $table='fin_cforms'; $details=$this->model->partner_code($table,$id); echo json_encode($details);*/ // $id=$this->session->userdata('uid'); $sessionData = $this->decryptSessionData(); $id= $sessionData['uid']; $page = isset($_POST['page'])?$_POST['page']:1; $limit = isset($_POST['rows'])?$_POST['rows']:10; $sidx = isset($_POST['sidx'])?$_POST['sidx']:'id'; $sord = isset($_POST['sord'])?$_POST['sord']:''; $totalrows = isset($_REQUEST['totalrows']) ? $_REQUEST['totalrows']: false; if($totalrows) { $limit = $totalrows; } $start = $limit*$page - $limit; $start = ($start<0)?0:$start; $where = ""; $searchField = isset($_POST['searchField']) ? $_POST['searchField'] : false; $searchOper = isset($_POST['searchOper']) ? $_POST['searchOper']: false; $searchString = isset($_POST['searchString']) ? $_POST['searchString'] : false; if(!$sidx) $sidx =1; //$count = $this->db->count_all_results('rate'); $whers=array('status'=>0); $table='fin_cforms'; $count = $this->model->partner_code1($table,$whers,$id); //echo $count; $count=count($count); if( $count > 0 ) { $total_pages = ceil($count/$limit); //echo $total_pages; } else { $total_pages = 0; } if ($page > $total_pages) $page=$total_pages; $query = $this->model->getdata2($start,$limit,$sidx,$sord,$whers,$table,$id); //print_r($query); $responce = array(); $responce["page"] = $page; $responce["total"] = $total_pages; $responce["records"] = $count; $i=0; foreach($query as $row) { $responce["rows"][$i]['id']=$row->id; $responce["rows"][$i]['cell']=array($row->id,$row->partner_code,$row->partner_name,$row->month,$row->quarter,$row->invoice_number,$row->date,$row->invoicedate,$row->taxable_amount,$row->cst,$row->invoice_value,$row->state); $i++; } echo json_encode($responce); } public function logout() { $sessionData = $this->decryptSessionData(); // print_r($sessionData);die(); $ip_address=$sessionData['ip_address']; $email=$sessionData['email']; $role=$sessionData['role']; $identifier = ''; if ($role == '1' || $role == '2' || $role == '8' ) { $identifier = isset($sessionData['usercode']) ? $sessionData['usercode'] : ''; } elseif ($role == '3') { $identifier = isset($sessionData['uid']) ? $sessionData['uid'] : ''; } else { $identifier = $email; } if (!empty($identifier) && !empty($ip_address)) { $this->db->where('email', $identifier); $this->db->where('ip_address', $ip_address); $this->db->delete('active_sessions'); } $this->session->unset_userdata('id'); $this->session->unset_userdata('login'); $this->session->unset_userdata('session_ci'); $this->session->sess_destroy(); redirect('/'); } // public function logout() // { // $user_id = $this->session->userdata('id'); // $this->session->unset_userdata('id'); // $this->session->unset_userdata('login'); // $this->session->sess_destroy(); // redirect('/'); // } // public function logout() // { // $sessionData = $this->decryptSessionData(); // if (!empty($sessionData)) { // $this->session->unset_userdata('session_ci'); // // print_r($sessionData); // if (isset($sessionData['id'])) { // $this->session->unset_userdata('id'); // } // if (isset($sessionData['login'])) { // $this->session->unset_userdata('login'); // } // $this->session->sess_destroy(); // // $this->session->sess_regenerate(TRUE); // redirect('/'); // } else { // redirect('/'); // } // } public function region_view() { $sessionData = $this->decryptSessionData(); if (!$sessionData || !isset($sessionData['id']) || $sessionData['role'] != '1') { redirect('controller/login'); } $table="master_data"; $where=array('type'=>2); $data['supervisor']=$this->model->fetch_where_data($table,$where); $table1="region"; $data['region']=$this->model->get_all_data($table1); $table2="master_data"; $where2=array('id'=>8); $data['role']=$this->model->fetch_where_data($table2,$where2); $tab="supervisor"; $data['time']=$this->model->get_time($tab); $this->load->view('region_view',$data); } public function region_view_insert() { $page = isset($_POST['page'])?$_POST['page']:1; $limit = isset($_POST['rows'])?$_POST['rows']:10; $sidx = isset($_POST['sidx'])?$_POST['sidx']:'id'; $sord = isset($_POST['sord'])?$_POST['sord']:''; $totalrows = isset($_REQUEST['totalrows']) ? $_REQUEST['totalrows']: false; if($totalrows) { $limit = $totalrows; } $start = $limit*$page - $limit; $start = ($start<0)?0:$start; $where = ""; $searchField = isset($_POST['searchField']) ? $_POST['searchField'] : false; $searchOper = isset($_POST['searchOper']) ? $_POST['searchOper']: false; $searchString = isset($_POST['searchString']) ? $_POST['searchString'] : false; if(!$sidx) $sidx =1; //$count = $this->db->count_all_results('rate'); $whers=array('status'=>0,'role'=>8); $table1='supervisor'; $count = $this->model->fetch_where_data($table1,$whers); //echo $count; $count=count($count); if( $count > 0 ) { $total_pages = ceil($count/$limit); //echo $total_pages; } else { $total_pages = 0; } if ($page > $total_pages) $page=$total_pages; $query = $this->model->getdata($start,$limit,$sidx,$sord,$whers,$table1); //print_r($query); $responce = array(); $responce["page"] = $page; $responce["total"] = $total_pages; $responce["records"] = $count; $i=0; foreach($query as $row) { $responce["rows"][$i]['id']=$row->id; $responce["rows"][$i]['cell']=array($row->id,$row->usercode,$row->region,$row->username,$row->email,$row->password,$row->phone,$row->role); $i++; } echo json_encode($responce); } public function region_view_add() { $cc=$this->input->post('cc'); $usercode=$this->input->post('usercode'); $region=$this->input->post('region'); $username=$this->input->post('username'); $email=$this->input->post('email'); $password=$this->input->post('password'); $phone=$this->input->post('phone'); //$department=$this->input->post('department'); $role=$this->input->post('role'); //$image=$this->input->post('image'); //$createdate=$this->input->post('createdate'); //$status=$this->input->post('status'); $rate=array('usercode'=>$usercode,'username'=>$username,'email'=>$email,'password'=>$password,'phone'=>$phone,'role'=>$role,'region'=>$region); //print_r($rate); $table='supervisor'; $where=array('role'=>8); $det=$this->model->fetch_where_data($table,$where); if((count($det))>0) { $this->model->insert($table,$rate); $this->load->library('email'); $this->email->set_mailtype('html'); $msg = "Hi, Added new supervisor:".$username.','."email:".$email; $this->email->from('notify@yaskawa.in', 'yaskawa'); $this->email->to($email, 'yaskawa'); $this->email->cc($cc); $this->email->subject('Added information'); // //$data['message'] = $msg; $this->email->message($msg); $this->email->send(); } return true; } public function region_view_edit() { $cc=$this->input->post('cc'); $id=$this->input->post('id'); $usercode=$this->input->post('usercode'); $region=$this->input->post('region'); $username=$this->input->post('username'); $email=$this->input->post('email'); $password=$this->input->post('password'); $phone=$this->input->post('phone'); //$department=$this->input->post('department'); $role=$this->input->post('role'); //$image=$this->input->post('image'); //$createdate=$this->input->post('createdate'); //$status=$this->input->post('status'); $rate=array('usercode'=>$usercode,'username'=>$username,'email'=>$email,'password'=>$password,'phone'=>$phone,'role'=>$role,'region'=>$region); $table='supervisor'; $where=array('id'=>$id); $data=$this->model->get_where_row($table,$where); if(count($data)>0) { $this->model->update_new($where,$table,$rate); $this->load->library('email'); $this->email->set_mailtype('html'); $msg = "Hi, Edited supervisor:".$username.','."email:".$email; $this->email->from('notify@yaskawa.in', 'yaskawa'); $this->email->to($email, 'yaskawa'); $this->email->cc($cc); $this->email->subject('Added information'); // //$data['message'] = $msg; $this->email->message($msg); $this->email->send(); } else return ""; } public function auto_product() { $keyword=$this->input->post('product_name'); $data1=$this->model->Get($keyword); //print_r($data1); foreach($data1 as $row) { $data[]=$row->product; } echo json_encode($data); } public function reg_news_view() { $sessionData = $this->decryptSessionData(); if (!$sessionData || !isset($sessionData['id']) || $sessionData['role'] != '8') { redirect('controller/login'); } $reg=$this->session->userdata('region'); $table='news'; $data['news']=$this->model->get_all_data($table); $this->load->view('region_news_view',$data); } ///version-2 public function create_po() { // $role=$this->session->userdata('role'); // $id=$this->session->userdata('id'); $sessionData = $this->decryptSessionData(); $id = $sessionData['id']; $role = $sessionData['role']; if($id){ if($role==3) { $w=array('id'=>$id); $t='profile'; $data['details']=$this->model->get_where_row($t,$w); $table='product_details'; $where=array('status'=>0); $data['confirmed_data']=$this->model->fetch_where_data($table,$where); } else { $w=array('id'=>$id); $t='supervisor'; $data['details']=$this->model->get_where_row($t,$w); $table='product_details'; $where=array('status'=>0); $data['confirmed_data']=$this->model->fetch_where_data($table,$where); } $table='po_info'; $data['time']=$this->model->get_time($table); $this->load->view('includes/admin_header',$data); $this->load->view('purchase_order_grid',$data); $this->load->view('includes/admin_footer',$data); }else { redirect('/'); } } public function generated_product_wish_list() { // $role=$this->session->userdata('role'); // $id=$this->session->userdata('id'); $sessionData = $this->decryptSessionData(); $id = $sessionData['id']; $role = $sessionData['role']; $add='address'; $whe=array('abp_id'=>$id); $data['address']=$this->model->fetch_where_data($add,$whe); if($id){ if($role==3) { $w=array('id'=>$id); $t='profile'; $data['details']=$this->model->get_where_row($t,$w); $data2=$this->input->post('ids'); $data1=substr($data2, 0, -1); $exp=array(); $path = explode("|", $data1); $exp = array_merge($exp, $path); $data1=array(); foreach($exp as $val) { $table='product_details'; $where=array('id'=>$val); $arr=$this->model->get_wish_list_dataa($val); array_push($data1,$arr); } $data['confirmed_data']=$data1; } else { $w=array('id'=>$id); $t='supervisor'; $data['details']=$this->model->get_where_row($t,$w); $data2=$_REQUEST['ids']; $data1=substr($data2, 0, -1); $exp=array(); $path = explode("|", $data1); $exp = array_merge($exp, $path); $data1=array(); foreach($exp as $val) { $table='product_details'; $where=array('id'=>$val); $arr=$this->model->get_wish_list_dataa($val); array_push($data1,$arr); } $data['confirmed_data']=$data1; } $table='product_po'; $indent=$this->model->select_purchase_no($table); if(empty($indent)) { $data['sl_no']=1; } else{ $data['sl_no']=$indent->po_no + 1; } $table='region'; $data['region'] = $this->model->get_all_data($table); $this->load->view('includes/admin_header',$data); $this->load->view('po_generate',$data); $this->load->view('includes/admin_footer',$data); }else { redirect('/'); } } public function address_details() { $add_id=$this->input->post('id'); // $role=$this->session->userdata('role'); // $id=$this->session->userdata('id'); $sessionData = $this->decryptSessionData(); $id = $sessionData['id']; $role = $sessionData['role']; $add='address'; $whe=array('abp_id'=>$id,'id'=>$add_id); $data=$this->model->get_row($add,$whe); echo json_encode($data); } public function add_product() { $sessionData = $this->decryptSessionData(); if (!$sessionData || !isset($sessionData['id']) || $sessionData['role'] != '1') { redirect('controller/login'); } $role=$this->session->userdata('role'); $id=$this->session->userdata('id'); if($role==3) { $w=array('id'=>$id); $t='profile'; $data['details']=$this->model->get_where_row($t,$w); } else { $w=array('id'=>$id); $t='supervisor'; $data['details']=$this->model->get_where_row($t,$w); } $this->load->view('add_product_details',$data); } public function edit_product() { $sessionData = $this->decryptSessionData(); if (!isset($sessionData['id'])) { redirect('/'); return; } $uri = $_SERVER["REQUEST_URI"]; $id = substr($uri, strpos($uri, "=") + 1); $w=array('id'=>$id); $t='product_details'; $data['products']=$this->model->get_where_row($t,$w); $id = $sessionData['id']; $role = $sessionData['role']; if($role==3) { $w=array('id'=>$id); $t='profile'; $data['details']=$this->model->get_where_row($t,$w); } else { $w=array('id'=>$id); $t='supervisor'; $data['details']=$this->model->get_where_row($t,$w); } $this->load->view('edit_product',$data); } /*public function insert_po_multi_data() { $product= $this->input->post('product'); $hsn= $this->input->post('hsn'); $description= $this->input->post('description'); $quant= $this->input->post('quant'); $unit=$this->input->post('unit'); $price= $this->input->post('price'); $trade=$this->input->post('trade'); $cash= $this->input->post('cash'); $net=$this->input->post('net'); $base= $this->input->post('base'); $sgst=$this->input->post('sgst'); $cgst= $this->input->post('cgst'); $igst= $this->input->post('igst'); $delivery_date= $this->input->post('delivery_date'); $tot_value= $this->input->post('tot_value'); $add1=$this->input->post('add1'); $add2=$this->input->post('add2'); $add3=$this->input->post('add3'); $add4=$this->input->post('add4'); $add5=$this->input->post('add5'); $add6=$this->input->post('add6'); $addr1=$this->input->post('addr1'); $addr2=$this->input->post('addr2'); $addr3=$this->input->post('addr3'); $addr4=$this->input->post('addr4'); $addr5=$this->input->post('addr5'); $addr6=$this->input->post('addr6'); $po_type = $this->input->post('po_type'); $region = $this->input->post('region'); $delivery=$this->input->post('delivery'); if($delivery=="") { $delivery="Not Applicable."; } $taxes=$this->input->post('taxes'); if($taxes=="") { $taxes="As Applicable."; } $term=$this->input->post('term'); if($term=="") { $term="As per ABP agreement."; } $bank=$this->input->post('bank'); if($bank=="") { $bank="As per ABP agreement."; } $note=$this->input->post('note'); if($note=="") { $note="Not Applicable."; } foreach($product as $key=>$val) { // if($igst[$key]==NULL) // { // $igst=0; // } // else // { // $igst=$igst[$key]; // } $data=array('product'=>$product[$key], 'hsn'=>$hsn[$key], 'description'=>$description[$key], 'quantity'=>$quant[$key], 'unit'=>$unit[$key], 'price'=>$price[$key], 'trade'=>$trade[$key], 'cash'=>$cash[$key], 'net'=>$net[$key], 'base'=>$base[$key], 'sgst'=>$sgst[$key], 'cgst'=>$cgst[$key], 'igst'=>$igst[$key], 'totalvalue'=>$tot_value[$key], 'delivery_date'=>$delivery_date[$key], 'po_no'=> $this->input->post('po_no'), 'location'=> $this->input->post('location'), 'po_date'=> $this->input->post('po_date'), 'billadd1'=>$this->input->post('add1'), 'billadd2'=>$this->input->post('add2'), 'billadd3'=>$this->input->post('add3'), 'billadd4'=>$this->input->post('add4'), 'billadd5'=>$this->input->post('add5'), 'billstate_code'=>$this->input->post('add6'), 'shipadd1'=>$this->input->post('addr1'), 'shipadd2'=>$this->input->post('addr2'), 'shipadd3'=>$this->input->post('addr3'), 'shipadd4'=>$this->input->post('addr4'), 'shipadd5'=>$this->input->post('addr5'), 'shipstate_code'=>$this->input->post('addr6'), // 'bill_address'=> $this->input->post('bill_address'), // 'ship_address'=>$this->input->post('ship_address'), 'currency'=> $this->input->post('currency'), 'delivery'=>$delivery, 'taxes'=>$taxes, 'term'=>$term, 'bank'=>$bank, 'sub_tot'=> $this->input->post('sub_tot'), 'frieght'=> $this->input->post('frieght'), 'invoice'=> $this->input->post('invoice'), 'paid' => $this->input->post('paid'), 'due' => $this->input->post('due'), 'note' => $note, 'po_type'=>$po_type, 'region'=>$region, 'status'=>'0', ); $table='product_po'; $this->db->insert($table,$data); } }*/ public function insert_po_multi_data() { // $role=$this->session->userdata('role'); // $id=$this->session->userdata('id'); $sessionData = $this->decryptSessionData(); $id = $sessionData['id']; $role = $sessionData['role']; $po_type = $this->input->post('po_type'); if($po_type == "normal") { $product= $this->input->post('product'); $hsn= $this->input->post('hsn'); $description= $this->input->post('description'); $quant= $this->input->post('quant'); $unit=$this->input->post('unit'); $price= $this->input->post('price'); $trade=$this->input->post('trade'); $cash= $this->input->post('cash'); $net=$this->input->post('net'); $base= $this->input->post('base'); $sgst=$this->input->post('sgst'); $cgst= $this->input->post('cgst'); $igst= $this->input->post('igst'); $delivery_date= $this->input->post('delivery_date'); $tot_value= $this->input->post('tot_value'); $add1=$this->input->post('add1'); $add2=$this->input->post('add2'); $add3=$this->input->post('add3'); $add4=$this->input->post('add4'); $add5=$this->input->post('add5'); $add6=$this->input->post('add6'); $addr1=$this->input->post('addr1'); $addr2=$this->input->post('addr2'); $addr3=$this->input->post('addr3'); $addr4=$this->input->post('addr4'); $addr5=$this->input->post('addr5'); $addr6=$this->input->post('addr6'); $po_type = $this->input->post('po_type'); $region = $this->input->post('region'); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $created_at = $date->format('Y-m-d H:i:s'); $delivery=$this->input->post('delivery'); if($delivery=="") { $delivery="Not Applicable."; } $taxes=$this->input->post('taxes'); if($taxes=="") { $taxes="As Applicable."; } $term=$this->input->post('term'); if($term=="") { $term="As per ABP agreement."; } $bank=$this->input->post('bank'); if($bank=="") { $bank="As per ABP agreement."; } $note=$this->input->post('note'); if($note=="") { $note="Not Applicable."; } foreach($product as $key=>$val) { $data=array('product'=>$product[$key], 'hsn'=>$hsn[$key], 'description'=>$description[$key], 'quantity'=>$quant[$key], 'unit'=>$unit[$key], 'price'=>$price[$key], 'trade'=>$trade[$key], 'cash'=>$cash[$key], 'net'=>$net[$key], 'base'=>$base[$key], 'sgst'=>$sgst[$key], 'cgst'=>$cgst[$key], 'igst'=>$igst[$key], 'totalvalue'=>$tot_value[$key], 'delivery_date'=>$delivery_date[$key], 'po_no'=> $this->input->post('po_no'), 'location'=> $this->input->post('location'), 'po_date'=> $this->input->post('po_date'), 'billadd1'=>$this->input->post('add1'), 'billadd2'=>$this->input->post('add2'), 'billadd3'=>$this->input->post('add3'), 'billadd4'=>$this->input->post('add4'), 'billadd5'=>$this->input->post('add5'), 'billstate_code'=>$this->input->post('add6'), 'shipadd1'=>$this->input->post('addr1'), 'shipadd2'=>$this->input->post('addr2'), 'shipadd3'=>$this->input->post('addr3'), 'shipadd4'=>$this->input->post('addr4'), 'shipadd5'=>$this->input->post('addr5'), 'shipstate_code'=>$this->input->post('addr6'), // 'bill_address'=> $this->input->post('bill_address'), // 'ship_address'=>$this->input->post('ship_address'), 'currency'=> $this->input->post('currency'), 'sub_tot'=> $this->input->post('sub_tot'), 'frieght'=> $this->input->post('frieght'), 'invoice'=> $this->input->post('invoice'), 'delivery'=>$delivery, 'taxes'=>$taxes, 'term'=>$term, 'bank'=>$bank, 'paid' => $this->input->post('paid'), 'due' => $this->input->post('due'), 'status'=>'0', 'po_type'=>'normal', 'region'=>$region, 'note' => $note, 'approve_status'=>'UNAPPROVED', 'user_id'=>$id, 'created_at'=>$created_at, ); $table='product_po'; $res = $this->db->insert($table,$data); } if($res) { $where =array('po_no'=>$this->input->post('po_no')); $table='product_po'; $fetch_det = $this->model->get_where_row($table,$where); $send_to_po_no = $fetch_det->po_no ; } $mail_po_no = $send_to_po_no; $this->load->library('email'); $this->email->set_mailtype('html'); $msg = "Hi, PO NO : ".$mail_po_no." Has Been Generated "; $this->email->from('notify@yaskawa.in', 'yaskawa'); $this->email->to('avinash_s@yaskawa.in', 'yaskawa'); $this->email->subject('New PO Generated'); $this->email->message($msg); $this->email->send(); } else { $po_no=$this->input->post('po_no'); $description=$this->input->post('description'); $files = $_FILES; $myFile = $_FILES['userFiles']; $cpt = count($_FILES['userFiles']['name']); $ext = pathinfo($cpt, PATHINFO_EXTENSION); // if($ext == "pdf") // { for($i=0; $i<$cpt; $i++) { $error = $myFile["error"][$i]; if ($error == '4') { $file1=""; } else { if($_FILES['userFiles']['name']) { $path=$_FILES['userFiles']['name'][$i]; $target5='signed_po/'; $stamp=getdate(); $target5.= basename($_FILES['userFiles']['name'][$i]); $file2[]=$target5; move_uploaded_file($_FILES['userFiles']['tmp_name'][$i],$target5); $file1=$target5; //echo $file1; } else { $file1=""; } } } $data=array('po_path'=>$file1,'po_no'=>$po_no,'description'=>$description,'po_type'=>'special','approve_status'=>'UNAPPROVED','user_id'=>$id); $table='signed_po'; $this->model->insert($table,$data); $table='product_po'; $this->db->insert($table,$data); $data=array('po_path'=>$file1,'po_no'=>$po_no,'description'=>$description,'status'=>'0','user_id'=>$id); $table='po_link'; $this->db->insert($table,$data); redirect('controller/create_po'); } } public function purchase_order() { // $role=$this->session->userdata('role'); // $id=$this->session->userdata('id'); $sessionData = $this->decryptSessionData(); $id = $sessionData['id']; $role = $sessionData['role']; if($id){ if($role==3) { $w=array('id'=>$id); $t='profile'; $data['details']=$this->model->get_where_row($t,$w); } else { $w=array('id'=>$id); $t='supervisor'; $data['details']=$this->model->get_where_row($t,$w); } $table='po_info'; $data['time']=$this->model->get_time($table); $tables='product_po'; $indent=$this->model->max_select_purchase_no($tables); $data['po']=$indent->po_no; $data['id']=$indent->id; $id=$indent->po_no; $tab='product_po'; $where=array('po_no'=>$id); $data['po_details']=$this->model->fetch_where_data($tab,$where); $data['address']=$this->model->get_where_row($tab,$where); $this->load->view('includes/admin_header',$data); $this->load->view('purchase_order',$data); $this->load->view('includes/admin_footer',$data); }else { redirect('/'); } } public function add_new_po() { // $role=$this->session->userdata('role'); // $id=$this->session->userdata('id'); $sessionData = $this->decryptSessionData(); $id = $sessionData['id']; $role = $sessionData['role']; if($id){ if($role==3) { $w=array('id'=>$id); $t='profile'; $data['details']=$this->model->get_where_row($t,$w); $table='product_details'; $where=array('status'=>0); $data['confirmed_data']=$this->model->fetch_where_data($table,$where); } else { $w=array('id'=>$id); $t='supervisor'; $data['details']=$this->model->get_where_row($t,$w); $table='product_details'; $where=array('status'=>0); $data['confirmed_data']=$this->model->fetch_where_data($table,$where); } $table='po_info'; $data['time']=$this->model->get_time($table); $this->load->view('add_new_po',$data); }else { redirect('/'); } } public function upload() { $po_no=$this->input->post('po_no'); $files = $_FILES; $myFile = $_FILES['userFiles']; $cpt = count($_FILES['userFiles']['name']); $ext = pathinfo($cpt, PATHINFO_EXTENSION); // if($ext == "pdf") // { for($i=0; $i<$cpt; $i++) { $error = $myFile["error"][$i]; if ($error == '4') { $file1=""; } else { if($_FILES['userFiles']['name']) { $path=$_FILES['userFiles']['name'][$i]; $target5='generated_po/'; $stamp=getdate(); $target5.= basename($_FILES['userFiles']['name'][$i]); $file2[]=$target5; move_uploaded_file($_FILES['userFiles']['tmp_name'][$i],$target5); $file1=$target5; //echo $file1; } else { $file1=""; } } } $data=array('po_path'=>$file1,'po_no'=>$po_no); $table='po_link'; $this->model->insert($table,$data); redirect('controller/add_new_po'); } // public function po_list() // { // // $role=$this->session->userdata('role'); // // $id=$this->session->userdata('id'); // // $user_dept=$this->session->userdata('user_dept'); // // Decrypt session data // $sessionData = $this->decryptSessionData(); // // if (!isset($sessionData['id'], $sessionData['role'], $sessionData['user_dept'])) { // // redirect('/'); // // return; // // } // $id = $sessionData['id']; // $role = $sessionData['role']; // $user_dept= $sessionData['user_dept']; // if($id){ // if($role==3) // { // $w=array('id'=>$id); // $t='profile'; // $data['details']=$this->model->get_where_row($t,$w); // $table='po_link'; // $where=array('status'=>0); // $data['confirmed_data']=$this->model->fetch_where_data($table,$where); // $t='product_po'; // $w=array('user_id'=>$id); // $data['po']=$this->model->fetch_where_data($t,$w); // $table='po_info'; // $data['time']=$this->model->get_time($table); // $this->load->view('includes/admin_header',$data); // $this->load->view('po_list',$data); // $this->load->view('includes/admin_footer',$data); // } // elseif($user_dept == 1) // { // $w=array('id'=>$id); // $t='supervisor'; // $data['details']=$this->model->get_where_row($t,$w); // $table='po_link'; // $where=array('status'=>0); // $data['confirmed_data']=$this->model->fetch_where_data($table,$where); // $t='product_po'; // $w=array('user_id'=>$id); // $data['po']=$this->model->get_where_row($t,$w); // $table='po_info'; // $data['time']=$this->model->get_time($table); // $this->load->view('view_reg_wise_po_list',$data); // } // elseif($user_dept == 2) // { // $w=array('id'=>$id); // $t='supervisor'; // $data['details']=$this->model->get_where_row($t,$w); // $table='po_link'; // $where=array('status'=>0); // $data['confirmed_data']=$this->model->fetch_where_data($table,$where); // $t='product_po'; // $w=array('user_id'=>$id); // $data['po']=$this->model->get_where_row($t,$w); // $table='po_info'; // $data['time']=$this->model->get_time($table); // $this->load->view('supervisorpo_list',$data); // } // elseif($user_dept == 3) // { // $w=array('id'=>$id); // $t='supervisor'; // $data['details']=$this->model->get_where_row($t,$w); // $table='po_link'; // $where=array('status'=>0); // $data['confirmed_data']=$this->model->fetch_where_data($table,$where); // $t='product_po'; // $w=array('user_id'=>$id); // $data['po']=$this->model->get_where_row($t,$w); // $table='po_info'; // $data['time']=$this->model->get_time($table); // $this->load->view('view_supervisor_po_list',$data); // } // else // { // $w=array('id'=>$id); // $t='supervisor'; // $data['details']=$this->model->get_where_row($t,$w); // $table='po_link'; // $where=array('status'=>0); // $data['confirmed_data']=$this->model->fetch_where_data($table,$where); // $t='product_po'; // $w=array('user_id'=>$id); // $data['po']=$this->model->get_where_row($t,$w); // $table='po_info'; // $data['time']=$this->model->get_time($table); // $this->load->view('supervisorpo_list',$data); // } // }else // { // redirect('/'); // } // } public function insert_product() { // if($this->session->userdata('id')== ''){redirect('/');} $sessionData = $this->decryptSessionData(); // Check if session is valid if (!isset($sessionData['id'])) { redirect('/'); // Redirect if session is invalid return; } $id = $sessionData['id']; $role = $sessionData['role']; $item=$this->input->post('item_name'); $code=$this->input->post('code'); $hsn=$this->input->post('hsn'); $price=$this->input->post('price'); $description=$this->input->post('description'); $table='product_details'; $data=array('item'=>$item,'item_code'=>$code,'item_description'=>$description,'list_price'=>$price,'hsn_code'=>$hsn); $this->model->insert($table,$data); $role=$this->session->userdata('role'); $id=$this->session->userdata('id'); if($role==3) { $w=array('id'=>$id); $t='profile'; $data['details']=$this->model->get_where_row($t,$w); } else { $w=array('id'=>$id); $t='supervisor'; $data['details']=$this->model->get_where_row($t,$w); } $this->load->view('add_product_details',$data); } public function upload_signed_po() { // $role=$this->session->userdata('role'); // $id=$this->session->userdata('id'); $sessionData = $this->decryptSessionData(); $id = $sessionData['id']; $role = $sessionData['role']; if($id){ if($role==3) { $w=array('id'=>$id); $t='profile'; $data['details']=$this->model->get_where_row($t,$w); $table='product_details'; $where=array('status'=>0); $data['confirmed_data']=$this->model->fetch_where_data($table,$where); $table='region'; $data['region'] = $this->model->get_all_data($table); } else { $w=array('id'=>$id); $t='supervisor'; $data['details']=$this->model->get_where_row($t,$w); $table='product_details'; $where=array('status'=>0); $data['confirmed_data']=$this->model->fetch_where_data($table,$where); $table='region'; $data['region'] = $this->model->get_all_data($table); } $table='po_info'; $data['time']=$this->model->get_time($table); $data['id']=$id; $this->load->view('includes/admin_header',$data); $this->load->view('upload_signed_po',$data); $this->load->view('includes/admin_footer',$data); }else { redirect('/'); } } public function upload_special_po() { // $role=$this->session->userdata('role'); // $id=$this->session->userdata('id'); $sessionData = $this->decryptSessionData(); $id = $sessionData['id']; $role = $sessionData['role']; if($id){ if($role==3) { $w=array('id'=>$id); $t='profile'; $data['details']=$this->model->get_where_row($t,$w); $table='product_details'; $where=array('status'=>0); $data['confirmed_data']=$this->model->fetch_where_data($table,$where); $table='region'; $data['region'] = $this->model->get_all_data($table); } else { $w=array('id'=>$id); $t='supervisor'; $data['details']=$this->model->get_where_row($t,$w); $table='product_details'; $where=array('status'=>0); $data['confirmed_data']=$this->model->fetch_where_data($table,$where); $table='region'; $data['region'] = $this->model->get_all_data($table); } $table='po_info'; $data['time']=$this->model->get_time($table); $data['id']=$id; $this->load->view('includes/admin_header',$data); $this->load->view('upload_special_po',$data); $this->load->view('includes/admin_footer',$data); }else { redirect('/'); } } // public function signed_po() // { // $po_no=$this->input->post('po_no'); // $uid=$this->input->post('uid'); // $description=$this->input->post('description'); // $region=$this->input->post('region'); // $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); // $created_at = $date->format('d-m-Y'); // $files = $_FILES; // $myFile = $_FILES['userFiles']; // $cpt = count($_FILES['userFiles']['name']); // $ext = pathinfo($cpt, PATHINFO_EXTENSION); // // if($ext == "pdf") // // { // for($i=0; $i<$cpt; $i++) // { // $error = $myFile["error"][$i]; // if ($error == '4') // { // $file1=""; // } // else // { // if($_FILES['userFiles']['name']) // { // $path=$_FILES['userFiles']['name'][$i]; // $target5='signed_po/'; // $stamp=getdate(); // $target5.= basename($_FILES['userFiles']['name'][$i]); // $file2[]=$target5; // move_uploaded_file($_FILES['userFiles']['tmp_name'][$i],$target5); // $file1=$target5; // //echo $file1; // } // else // { // $file1=""; // } // } // } // $data=array('user_id'=>$uid,'po_path'=>$file1,'po_no'=>$po_no,'description'=>$description,'po_type'=>'signed','approve_status'=>'SIGNED','region'=>$region,'created_at'=>$created_at); // $table='signed_po'; // $this->model->insert($table,$data); // $role=$this->session->userdata('role'); // $id=$this->session->userdata('id'); // if($role==3) // { // $w=array('id'=>$id); // $t='profile'; // $details=$this->model->get_where_row($t,$w); // $username=$details->uid; // $w1=array('region'=>$details->region); // $t1='supervisor'; // $details1=$this->model->get_where_row($t1,$w1); // $email=$details1->email; // $this->load->library('email'); // $this->email->set_mailtype('html'); // $msg = "Hi,User ID:".$username." Added New Signed PO "; // $this->email->from('notify@yaskawa.in', 'yaskawa'); // $this->email->to($email, 'yaskawa'); // //$this->email->cc($cc); // $this->email->subject('Added New Signed PO'); // // //$data['message'] = $msg; // $this->email->message($msg); // $this->email->send(); // } // redirect('controller/upload_signed_po'); // } public function signed_po() { $po_no = $this->input->post('po_no'); $uid = $this->input->post('uid'); $description = $this->input->post('description'); $region = $this->input->post('region'); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $created_at = $date->format('d-m-Y'); // Allowed file types $allowed_extensions = ['pdf', 'jpg', 'jpeg', 'png', 'doc', 'docx', 'xls', 'xlsx', 'ppt', 'pptx']; $file1 = ""; $file2 = []; if (isset($_FILES['userFiles'])) { $files = $_FILES['userFiles']; $cpt = count($files['name']); for ($i = 0; $i < $cpt; $i++) { $error = $files["error"][$i]; if ($error == 4) { // No file uploaded continue; } $file_name = $files['name'][$i]; $file_tmp = $files['tmp_name'][$i]; $extension = strtolower(pathinfo($file_name, PATHINFO_EXTENSION)); // Validate file extension if (!in_array($extension, $allowed_extensions)) { $this->session->set_flashdata('error_message', "Invalid file type: $file_name. Only images, PDF, and MS Office files are allowed."); redirect('controller/upload_signed_po'); return; } // Define the target path $target_path = 'signed_po/' . basename($file_name); $file2[] = $target_path; // Move uploaded file to target path if (!move_uploaded_file($file_tmp, $target_path)) { echo "Failed to upload file: $file_name"; return; } $file1 = $target_path; } } // Insert data into the database $data = [ 'user_id' => $uid, 'po_path' => $file1, 'po_no' => $po_no, 'description' => $description, 'po_type' => 'signed', 'approve_status' => 'SIGNED', 'region' => $region, 'created_at' => $created_at ]; $table = 'signed_po'; $this->model->insert($table, $data); // Email notification $role = $this->session->userdata('role'); $id = $this->session->userdata('id'); if ($role == 3) { $w = ['id' => $id]; $t = 'profile'; $details = $this->model->get_where_row($t, $w); $username = $details->uid; $w1 = ['region' => $details->region]; $t1 = 'supervisor'; $details1 = $this->model->get_where_row($t1, $w1); $email = $details1->email; $this->load->library('email'); $this->email->set_mailtype('html'); $msg = "Hi, User ID: $username has added a new signed PO."; $this->email->from('notify@yaskawa.in', 'yaskawa'); $this->email->to($email); $this->email->subject('Added New Signed PO'); $this->email->message($msg); $this->email->send(); } redirect('controller/upload_signed_po'); } public function special_po() { // $id=$this->session->userdata('id'); $sessionData = $this->decryptSessionData(); $id = $sessionData['id']; $po_no=$this->input->post('po_no'); $region=$this->input->post('region'); $uid=$this->input->post('uid'); $description=$this->input->post('description'); $files = $_FILES; $myFile = $_FILES['userFiles']; $cpt = count($_FILES['userFiles']['name']); $ext = pathinfo($cpt, PATHINFO_EXTENSION); // if($ext == "pdf") // { for($i=0; $i<$cpt; $i++) { $error = $myFile["error"][$i]; if ($error == '4') { $file1=""; } else { if($_FILES['userFiles']['name']) { $path=$_FILES['userFiles']['name'][$i]; $target5='signed_po/'; $stamp=getdate(); $target5.= basename($_FILES['userFiles']['name'][$i]); $file2[]=$target5; move_uploaded_file($_FILES['userFiles']['tmp_name'][$i],$target5); $file1=$target5; //echo $file1; } else { $file1=""; } } } $data=array('po_path'=>$file1,'po_no'=>$po_no,'description'=>$description,'po_type'=>'special','user_id'=>$uid,'region'=>$region); $table='signed_po'; $this->model->insert($table,$data); $role=$this->session->userdata('role'); $id=$this->session->userdata('id'); if($role==3) { /* $w=array('id'=>$id); $t='profile'; $details=$this->model->get_where_row($t,$w); $username=$details->uid; $w1=array('region'=>$details->region); $t1='supervisor'; $details1=$this->model->get_where_row($t1,$w1); $email=$details1->email; $this->load->library('email'); $this->email->set_mailtype('html'); $msg = "Hi,User ID:".$username." Added New Special PO "; $this->email->from('notify@yaskawa.in', 'yaskawa'); $this->email->to($email, 'yaskawa'); //$this->email->cc($cc); $this->email->subject('Added New Signed PO'); // //$data['message'] = $msg; $this->email->message($msg); $this->email->send();*/ } redirect('controller/po_list'); } public function signed_po_list() { // $role=$this->session->userdata('role'); // $id=$this->session->userdata('id'); $sessionData = $this->decryptSessionData(); $id = $sessionData['id']; $role = $sessionData['role']; if($id){ if($role==3) { $w=array('id'=>$id); $t='profile'; $data['details']=$this->model->get_where_row($t,$w); $table='signed_po'; //$where=array('status'=>0,'approve_status'=>'SIGNED','user_id'=>$id); $data['confirmed_data']=$this->model->fetch_signed_po($id); } else { $w=array('id'=>$id); $t='supervisor'; $data['details']=$this->model->get_where_row($t,$w); $det_reg=$this->model->fetch_where_data($t,$w); foreach($det_reg as $det) { $region = $det->region; } $table='signed_po'; $where=array('status'=>0,'approve_status'=>'SIGNED','region'=>$region); $data['confirmed_data']=$this->model->fetch_special_po_reg($region); } $table='po_info'; $data['time']=$this->model->get_time($table); $this->load->view('includes/admin_header',$data); $this->load->view('signed_po_list',$data); $this->load->view('includes/admin_footer',$data); }else { redirect('/'); } } public function add_shipaddress_details() { // $id=$this->session->userdata('id'); //$where=array('abp_id'=>$id); $sessionData = $this->decryptSessionData(); $id = $sessionData['id']; $table='address'; $detail=$this->model->get_all_data($table); echo json_encode($detail); } public function add_shipaddress() { if($this->session->userdata('id')== ''){redirect('/');} $role=$this->session->userdata('role'); $id=$this->session->userdata('id'); if($role==3) { $w=array('id'=>$id); $t='profile'; $data['details']=$this->model->get_where_row($t,$w); $table='product_details'; $where=array('status'=>0); $data['confirmed_data']=$this->model->fetch_where_data($table,$where); } else { $w=array('id'=>$id); $t='supervisor'; $data['details']=$this->model->get_where_row($t,$w); $table='product_details'; $where=array('status'=>0); $data['confirmed_data']=$this->model->fetch_where_data($table,$where); } $table='po_info'; $data['time']=$this->model->get_time($table); $this->load->view('add_shipaddress',$data); } public function admin_shipaddress() { // $role=$this->session->userdata('role'); // // print_r($role);die(); // $id=$this->session->userdata('id'); // Decrypt session data $sessionData = $this->decryptSessionData(); // Check if session is valid if (!isset($sessionData['id'], $sessionData['role'])) { redirect('/'); // Redirect if session is invalid return; } $id = $sessionData['id']; $role = $sessionData['role']; if ($role != '3' && $role != '1') { redirect('/'); return; } if($role == 3) { $w=array('id'=>$id); $t='profile'; $data['details']=$this->model->get_where_row($t,$w); $table='product_details'; $where=array('status'=>0); $data['confirmed_data']=$this->model->fetch_where_data($table,$where); } else { $w=array('id'=>$id); $t='supervisor'; $data['details']=$this->model->get_where_row($t,$w); $table='product_details'; $where=array('status'=>0); $data['confirmed_data']=$this->model->fetch_where_data($table,$where); } $t='profile'; $data['abps']=$this->model->get_all_data($t); $table='po_info'; $data['time']=$this->model->get_time($table); $this->load->view('admin_shipment',$data); } public function insert_address() { $item=ucfirst($this->input->post('name')); $code=ucfirst($this->input->post('street')); $hsn=ucfirst($this->input->post('city')); $price=ucfirst($this->input->post('state')); $description=$this->input->post('pincode'); $gstin=$this->input->post('gstin'); $state_code=$this->input->post('state_code'); $state_gst=$this->input->post('state_gst'); // $role=$this->session->userdata('role'); // $id=$this->session->userdata('id'); $sessionData = $this->decryptSessionData(); $id = $sessionData['id']; $role = $sessionData['role']; if($id){ $table='address'; $data=array('abp_id'=>$id,'name'=>$item,'street'=>$code,'pincode'=>$description,'state'=>$price,'city'=>$hsn,'gstin'=>$gstin,'state_code'=>$state_code,'state_gst'=>$state_gst); $this->model->insert($table,$data); if($role==3) { $w=array('id'=>$id); $t='profile'; $data['details']=$this->model->get_where_row($t,$w); } else { $w=array('id'=>$id); $t='supervisor'; $data['details']=$this->model->get_where_row($t,$w); } $this->load->view('add_shipaddress',$data); }else { redirect('/'); } } public function insert_adminaddress() { $abp_id=ucfirst($this->input->post('abp_id')); $item=ucfirst($this->input->post('name')); $code=ucfirst($this->input->post('street')); $hsn=ucfirst($this->input->post('city')); $price=ucfirst($this->input->post('state')); $description=$this->input->post('pincode'); $gstin=$this->input->post('gstin'); $state_code=$this->input->post('state_code'); $state_gst=$this->input->post('state_gst'); // $role=$this->session->userdata('role'); // $id=$this->session->userdata('id'); $sessionData = $this->decryptSessionData(); $id = $sessionData['id']; $role = $sessionData['role']; $table='address'; $data=array('abp_id'=>$abp_id,'name'=>$item,'street'=>$code,'pincode'=>$description,'state'=>$price,'city'=>$hsn,'gstin'=>$gstin,'state_code'=>$state_code,'state_gst'=>$state_gst); $this->model->insert($table,$data); // if($role==3) // { // $w=array('id'=>$id); // $t='profile'; // $data['details']=$this->model->get_where_row($t,$w); // } // else // { // $w=array('id'=>$id); // $t='supervisor'; // $data['details']=$this->model->get_where_row($t,$w); // } redirect('controller/admin_shipaddress'); } public function shipment_id() { $uri = $_SERVER["REQUEST_URI"]; $val = substr($uri, strpos($uri, "=") + 1); $table='address'; $where=array('id'=>$val); $data['fetch_data']=$this->model->get_row($table,$where); // $role=$this->session->userdata('role'); // $id=$this->session->userdata('id'); $sessionData = $this->decryptSessionData(); $id = $sessionData['id']; $role = $sessionData['role']; if($id){ if($role==3) { $w=array('id'=>$id); $t='profile'; $data['details']=$this->model->get_where_row($t,$w); $table='product_details'; $where=array('status'=>0); $data['confirmed_data']=$this->model->fetch_where_data($table,$where); } else { $w=array('id'=>$id); $t='supervisor'; $data['details']=$this->model->get_where_row($t,$w); $table='product_details'; $where=array('status'=>0); $data['confirmed_data']=$this->model->fetch_where_data($table,$where); } $table='po_info'; $data['time']=$this->model->get_time($table); $this->load->view('add_shipaddress',$data); }else { reditect('/'); } } public function adminshipment_id() { $uri = $_SERVER["REQUEST_URI"]; $val = substr($uri, strpos($uri, "=") + 1); $table='address'; $where=array('id'=>$val); $data['fetch_data']=$this->model->get_row($table,$where); // $role=$this->session->userdata('role'); // $id=$this->session->userdata('id'); $sessionData = $this->decryptSessionData(); $id = $sessionData['id']; $role = $sessionData['role']; if($id){ if($role==3) { $w=array('id'=>$id); $t='profile'; $data['details']=$this->model->get_where_row($t,$w); $table='product_details'; $where=array('status'=>0); $data['confirmed_data']=$this->model->fetch_where_data($table,$where); } else { $w=array('id'=>$id); $t='supervisor'; $data['details']=$this->model->get_where_row($t,$w); $table='product_details'; $where=array('status'=>0); $data['confirmed_data']=$this->model->fetch_where_data($table,$where); } $table='po_info'; $data['time']=$this->model->get_time($table); $t='profile'; $data['abps']=$this->model->get_all_data($t); $this->load->view('admin_shipment',$data); }else { redirect('/'); } } public function shipadress_delete() { $uri = $_SERVER["REQUEST_URI"]; $val = substr($uri, strpos($uri, "=") + 1); $table='address'; $where=array('id'=>$val); $this->model->delete($table,$where); // $role=$this->session->userdata('role'); // $id=$this->session->userdata('id'); $sessionData = $this->decryptSessionData(); $id = $sessionData['id']; $role = $sessionData['role']; if($id){ if($role==3) { $w=array('id'=>$id); $t='profile'; $data['details']=$this->model->get_where_row($t,$w); $table='product_details'; $where=array('status'=>0); $data['confirmed_data']=$this->model->fetch_where_data($table,$where); } else { $w=array('id'=>$id); $t='supervisor'; $data['details']=$this->model->get_where_row($t,$w); $table='product_details'; $where=array('status'=>0); $data['confirmed_data']=$this->model->fetch_where_data($table,$where); } $table='po_info'; $data['time']=$this->model->get_time($table); $t='profile'; $data['abps']=$this->model->get_all_data($t); $this->load->view('admin_shipment',$data); }else { redirect('/'); } } public function update_address() { $item=ucfirst($this->input->post('name')); $u_id=ucfirst($this->input->post('u_id')); $code=ucfirst($this->input->post('street')); $hsn=ucfirst($this->input->post('city')); $price=ucfirst($this->input->post('state')); $description=$this->input->post('pincode'); $gstin=$this->input->post('gstin'); $state_code=$this->input->post('state_code'); $state_gst=$this->input->post('state_gst'); // $role=$this->session->userdata('role'); // $id=$this->session->userdata('id'); $table='address'; $where=array('id'=>$u_id); $data=array('name'=>$item,'street'=>$code,'pincode'=>$description,'state'=>$price,'city'=>$hsn,'gstin'=>$gstin,'state_code'=>$state_code,'state_gst'=>$state_gst); $this->model->update_new($where,$table,$data); redirect('controller/add_shipaddress'); } public function adminupdate_address() { $item=ucfirst($this->input->post('name')); $u_id=ucfirst($this->input->post('u_id')); $code=ucfirst($this->input->post('street')); $hsn=ucfirst($this->input->post('city')); $price=ucfirst($this->input->post('state')); $description=$this->input->post('pincode'); $gstin=$this->input->post('gstin'); $state_code=$this->input->post('state_code'); $state_gst=$this->input->post('state_gst'); // $role=$this->session->userdata('role'); // $id=$this->session->userdata('id'); $table='address'; $where=array('id'=>$u_id); $data=array('name'=>$item,'street'=>$code,'pincode'=>$description,'state'=>$price,'city'=>$hsn,'gstin'=>$gstin,'state_code'=>$state_code,'state_gst'=>$state_gst); $this->model->update_new($where,$table,$data); redirect('controller/admin_shipaddress'); } public function conversion() { //$this->mpdf->useOnlyCoreFonts = true; $id=$this->session->userdata('id'); $w=array('id'=>$id); $t='profile'; $data['details']=$this->model->get_where_row($t,$w); $tables='product_po'; $indent=$this->model->max_select_purchase_no($tables); $data['po']=$indent->po_no; $po = $indent->po_no; $po_type = $indent->po_type; $id=$indent->po_no; $tab='product_po'; $where=array('po_no'=>$id); $data['po_details']=$this->model->fetch_where_data($tab,$where); $po_details=$this->model->fetch_where_data($tab,$where); $data['address']=$this->model->get_where_row($tab,$where); $address=$this->model->get_where_row($tab,$where); include("assets/mpdf60/mpdf.php"); //$mpdf=new mPDF('c','A4','','',32,25,47,47,10,10); $mpdf = new mPDF('c', 'A4-L'); $mpdf->mirrorMargins = 1; $cts=0; $tax=0; $inv=0; $fri=0; $paid=0; $due=0; $base=0; $base1=0; $tv1 =0; $html = ''; $index = 1; $html=$html.'<html><head></head><body>'; $html=$html.'<h3 style="text-align:center; color:blue;">PURCHASE ORDER</h3>'; $html=$html.'<input type="hidden" id="po_no" value="<?php echo $po;?>">'; $html=$html.'<table style="border-collapse: collapse;border:1px solid #000;width:100%;">'; $html = $html.'<tr><td style="border-right:1px solid #000;width:50%;padding:5px;">Yaskawa India Private Limited</td>'; $html = $html.'<td style="padding:5px;width:50%;">P. O. No# <span style="float:right;">'.$po.'</span></td></tr>'; $html = $html.'<tr><td style="border-right:1px solid #000;width:50%;padding:5px;">Plot No. 17/A, Electronic City, Phase I, Bangalore</td>'; $html = $html.'<td style="padding:5px;width:50%;">Date <span style="float:right;">'.date("d-m-Y").'</span></td></tr>'; $html = $html.'<tr><td style="border-right:1px solid #000;width:50%;padding:5px;">Tel : (080) 2200-0000, Fax : (080) 2200-0000</td>'; $html = $html.'<td style="padding:5px;width:50%;">Your Ref#</td></tr>'; $html = $html.'<tr><td style="border-right:1px solid #000;width:50%;padding:5px;">GSTIN -29AAACY4408P1ZR</td>'; $html = $html.'<td style="padding:5px;width:50%;">Our Ref#</td></tr></table>'; $html = $html.'<table style="border-collapse: collapse;border:1px solid #000;width:100%;margin-top:20px;"><tr>'; $html = $html.'<td style="width:50%;padding:5px;">Transaction Type</td>'; $html = $html.'<td style="padding:5px;width:50%;">Domestic</td></tr>'; $html = $html.'<tr><td style="width:50%;padding:5px;">Nature of Transaction</td>'; $html = $html.'<td style="padding:5px;width:50%;">Inter-State Purchase / Intra-State Purchase</td></tr>'; $html = $html.'<tr><td style="width:50%;padding:5px;">Nature of Supply</td>'; $html = $html.'<td style="padding:5px;width:50%;">Goods / Services / Goods & Services</td></tr></table>'; $html = $html.'<table style="border-collapse: collapse;width:100%;"><tr>'; $html = $html.'<td style="padding:5px 0px;width:50%;"><b><em>Billing To</em></b></td>'; $html = $html.'<td style="padding:5px 0px;width:50%;"><b><em>Deliver To</em></b></td></tr></table>'; $html = $html.'<table style="border-collapse: collapse;border:1px solid #000;width:100%;"><tr>'; $html = $html.'<td style="padding:5px;width:50%;border-right:1px solid #000;"><b>'.$address->billadd1.'</b></td>'; $html=$html.'<td style="padding:5px;width:50%;"><b>'.$address->shipadd1.'</b></td></tr>'; $html=$html.'<tr><td style="padding:5px;width:50%;border-right:1px solid #000;">'.$address->billadd2.'</td>'; $html = $html.'<td style="padding:5px;width:50%;">'.$address->shipadd2.'</td></tr>'; $html = $html.'<tr><td style="padding:5px;width:50%;border-right:1px solid #000;">State Code: '.$address->billstate_code.'</td>'; $html = $html.'<td style="padding:5px;width:50%;">State Code: '.$address->shipstate_code.'</td></tr>'; $html = $html.'<tr><td style="padding:5px;width:50%;border-right:1px solid #000;">India</td>'; $html = $html.'<td style="padding:5px;width:50%;">India</td></tr>'; $html = $html.'<tr><td style="padding:5px;width:50%;border-right:1px solid #000;">GSTIN: '.$address->billadd5.'</td>'; $html = $html.'<td style="padding:5px;width:50%;">GSTIN: '.$address->shipadd5.'</td></tr></table>'; $html = $html.'<table style="border-collapse: collapse;width:100%;"><tr>'; $html = $html.'<td style="padding:5px 0px;width:50%;">Attention To : Contact Person/ contact no /email-id</td>'; $html = $html.'<td style="padding:5px 0px;width:50%;">Attention To : Contact Person</td></tr></table>'; $html = $html.'<table style="border-collapse: collapse;width:100%;border:1px solid #000;"><tr>'; $html = $html.'<th style="border:1px solid #000;padding:3px;">HSN/SA CODE</th>'; $html = $html.'<th style="border:1px solid #000;padding:3px;">Description</th>'; $html = $html.'<th style="border:1px solid #000;padding:3px;">Qty</th>'; $html = $html.'<th style="border:1px solid #000;padding:3px;">Date</th>'; $html = $html.'<th style="border:1px solid #000;padding:3px;">Unit</th>'; $html = $html.'<th style="border:1px solid #000;padding:3px;">Unit<br>Price</th>'; $html = $html.'<th style="border:1px solid #000;padding:3px;">Trade<br>Discount</th>'; $html = $html.'<th style="border:1px solid #000;padding:3px;">Cash<br>Discount</th>'; $html = $html.'<th style="border:1px solid #000;padding:3px;">Unit Net<br>Price</th>'; $html = $html.'<th style="border:1px solid #000;padding:3px;">Base<br>Price</th>'; $html = $html.'<th style="border:1px solid #000;padding:3px;">IGST<br>Rate</th>'; $html = $html.'<th style="border:1px solid #000;padding:3px;">IGST<br>Amount</th>'; $html = $html.'<th style="border:1px solid #000;padding:3px;">SGST<br>Rate</th>'; $html = $html.'<th style="border:1px solid #000;padding:3px;">SGST<br>Amount</th>'; $html = $html.'<th style="border:1px solid #000;padding:3px;">CGST<br>Rate</th>'; $html = $html.'<th style="border:1px solid #000;padding:3px;">CGST<br>Amount</th>'; $html = $html.'<th style="border:1px solid #000;padding:3px;">Total<br>Amount</th>'; $html = $html.'</tr>'; foreach($po_details as $ct){ $base = $ct->base; $base1 = str_replace( ',', '', $base ); $html = $html.'<tr>'; $html = $html.'<td style="border:1px solid #000;padding:3px;">'.$ct->hsn.'</td>'; $html = $html.'<td style="border:1px solid #000;padding:3px;">'.$ct->description.'</td>'; $html = $html.'<td style="border:1px solid #000;padding:3px;">'.$ct->quantity.'</td>'; $html = $html.'<td style="border:1px solid #000;padding:3px;">'.$ct->delivery_date.'</td>'; $html = $html.'<td style="border:1px solid #000;padding:3px;">'.$ct->unit.'</td>'; $html = $html.'<td style="border:1px solid #000;padding:3px;">'.$ct->price.'</td>'; $html = $html.'<td style="border:1px solid #000;padding:3px;">'.$ct->trade.'</td>'; $html = $html.'<td style="border:1px solid #000;padding:3px;">'.$ct->cash.'</td>'; $html = $html.'<td style="border:1px solid #000;padding:3px;">'.$ct->net.'</td>'; $html = $html.'<td style="border:1px solid #000;padding:3px;">'.$ct->base.'</td>'; $html = $html.'<td style="border:1px solid #000;padding:3px;">'.$ct->igst.'</td>'; if($ct->igst > 0){ $c=(($base1 * $ct->igst)/100); } else { $c=0; } $html = $html.'<td style="border:1px solid #000;padding:3px;">'.$c.'</td>'; $html = $html.'<td style="border:1px solid #000;padding:3px;">'.$ct->sgst.'</td>'; if($ct->sgst > 0){ $a=(($base1 * $ct->sgst)/100); } else { $a=0; } $html = $html.'<td style="border:1px solid #000;padding:3px;">'.$a.'</td>'; $html = $html.'<td style="border:1px solid #000;padding:3px;">'.$ct->cgst.'</td>'; if($ct->cgst > 0){ $b=(($base1 * $ct->cgst)/100); } else { $b=0; } $html = $html.'<td style="border:1px solid #000;padding:3px;">'.$b.'</td>'; $tv=$base1 +$a+$b+$c; $tv1 = str_replace( ',', '', $tv); $html = $html.'<td style="border:1px solid #000;padding:3px;">'.$tv1.'</td>'; $cts=$cts+$tv; $inv=$ct->invoice; $fri=$ct->frieght; $paid=$ct->paid; $due=$ct->due; $html = $html.'</tr>'; } $html = $html.'<tr><td colspan="4" rowspan="7" style="border:1px solid #000;padding:3px;">Comments:'; foreach($po_details as $pos) { $html= $html.$pos->note; break; } $html = $html.'</td>'; $html = $html.'<td colspan="12" style="border:1px solid #000;padding:3px;">Sub Total</td>'; $html = $html.'<td style="border:1px solid #000;padding:3px;">'.$cts.'</td></tr>'; $html=$html.'<tr><td colspan="12" style="border:1px solid #000;padding:3px;">Freight</td>'; $html= $html.'<td style="border:1px solid #000;padding:3px;">'.$fri.'</td></tr>'; $html= $html.'<tr><td colspan="12" style="border:1px solid #000;padding:3px;">Invoice Total</td>'; $html= $html.'<td style="border:1px solid #000;padding:3px;">'.$inv.'</td></tr>'; $html=$html.'<tr><td colspan="12" style="border:1px solid #000;padding:3px;">Amount Paid</td>'; $html=$html.'<td style="border:1px solid #000;padding:3px;">'.$paid.'</td></tr>'; $html= $html.'<tr><td colspan="12" style="border:1px solid #000;padding:3px;">Balance Due</td>'; $html= $html.'<td style="border:1px solid #000;padding:3px;">'.$due.'</td></tr></table>'; foreach($po_details as $posd) { $html= $html.'<p style="margin-bottom:3px;">Terms & Conditions</p>'; $html= $html.'<p style="margin-bottom:3px; margin-top:3px;">1. Material Delivery: '.$posd->delivery.'</p>'; $html= $html.'<p style="margin-bottom:3px; margin-top:3px;">2. Tax: '.$posd->taxes.'</p>'; $html= $html.'<p style="margin-bottom:3px; margin-top:3px;">3. Terms of Payment: '.$posd->term.'</p>'; $html= $html.'<p style="margin-bottom:3px; margin-top:3px;">4. Bank Details: '.$posd->bank.'</p>'; break; } $html= $html.'</body>'; $html= $html.'</html>'; $mpdf->SetDisplayMode('fullpage'); $mpdf->SetWatermarkText(''); $mpdf->watermark_font = 'DejaVuSansCondensed'; $mpdf->showWatermarkText = true; //$mpdf->WriteHTML($html); //$mpdf->AddPage(); // //$mpdf->SetWatermarkImage('tiger.wmf', 1, '', array(160,10)); //$mpdf->showWatermarkImage = true; $mpdf->WriteHTML($html); $data = date('d-M-y-H-i'); $file='generated_po/yaskawa'.$data.'PO.pdf'; $mpdf->Output('generated_po/yaskawa'.$data.'PO.pdf', 'F'); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $created_at = $date->format('d-m-Y'); $table='po_link'; $data=array('po_no'=>$po,'po_path'=>$file,'po_type'=>$po_type,'created_at'=>$created_at); $result = $this->model->insert($table,$data); if($result) { echo "1"; } } public function product_import() { date_default_timezone_set('Asia/Kolkata'); include '../PHPExcel/IOFactory.php'; if(isset($_FILES['file']['name'])){ $file_name = $_FILES['file']['name']; $ext = pathinfo($file_name, PATHINFO_EXTENSION); if($ext == "xlsx") { $file_name = $_FILES['file']['tmp_name']; $inputFileName = $file_name; try { $inputFileType = PHPExcel_IOFactory::identify($inputFileName); $objReader = PHPExcel_IOFactory::createReader($inputFileType); $objPHPExcel = $objReader->load($inputFileName); } catch (Exception $e) { die('Error loading file "' . pathinfo($inputFileName, PATHINFO_BASENAME) . '": ' . $e->getMessage()); } $sheet = $objPHPExcel->getSheet(0); $highestRow = $sheet->getHighestRow(); $highestColumn = $sheet->getHighestColumn(); $allDataInSheet = $objPHPExcel->getActiveSheet()->toArray(null,true,true,true); $arrayCount = count($allDataInSheet); // Here get total count of row in that Excel sheet $table='product_details'; $this->model->table_truncate($table); if(count($allDataInSheet)>0){ for($i=2;$i<=$arrayCount;$i++){ //$partner_code = trim($allDataInSheet[$i]["A"]); $item = trim($allDataInSheet[$i]["A"]); $item_code= trim($allDataInSheet[$i]["B"]); $item_description = trim($allDataInSheet[$i]["C"]); $list_price = trim($allDataInSheet[$i]["D"]); $hsn_code = trim($allDataInSheet[$i]["E"]); $data=array('item'=>$item,'item_code'=>$item_code,'item_description'=>$item_description,'list_price'=>$list_price,'hsn_code'=>$hsn_code); $this->model->insert($table,$data); } } redirect('controller/add_product'); } else{ echo '<p style="color:red;">Please upload file with xlsx extension only</p>'; } } } public function shipment_import() { date_default_timezone_set('Asia/Kolkata'); include '../PHPExcel/IOFactory.php'; if(isset($_FILES['file']['name'])){ $file_name = $_FILES['file']['name']; $ext = pathinfo($file_name, PATHINFO_EXTENSION); if($ext == "xlsx") { $file_name = $_FILES['file']['tmp_name']; $inputFileName = $file_name; try { $inputFileType = PHPExcel_IOFactory::identify($inputFileName); $objReader = PHPExcel_IOFactory::createReader($inputFileType); $objPHPExcel = $objReader->load($inputFileName); } catch (Exception $e) { die('Error loading file "' . pathinfo($inputFileName, PATHINFO_BASENAME) . '": ' . $e->getMessage()); } $sheet = $objPHPExcel->getSheet(0); $highestRow = $sheet->getHighestRow(); $highestColumn = $sheet->getHighestColumn(); $allDataInSheet = $objPHPExcel->getActiveSheet()->toArray(null,true,true,true); $arrayCount = count($allDataInSheet); // Here get total count of row in that Excel sheet //$this->model->table_truncate($table); if(count($allDataInSheet)>0){ for($i=2;$i<=$arrayCount;$i++){ //$partner_code = trim($allDataInSheet[$i]["A"]); $abp = trim($allDataInSheet[$i]["A"]); $table='profile'; $where=array('uid'=>$abp); $abps =$this->model->get_where_row($table,$where); $abp_id=$abps->id; $name= trim($allDataInSheet[$i]["B"]); $street = trim($allDataInSheet[$i]["C"]); $city = trim($allDataInSheet[$i]["D"]); $state = trim($allDataInSheet[$i]["E"]); $pincode = trim($allDataInSheet[$i]["F"]); $state_code = trim($allDataInSheet[$i]["G"]); $state_gst = trim($allDataInSheet[$i]["H"]); $gstin = trim($allDataInSheet[$i]["I"]); $table='address'; $data=array('abp_id'=>$abp_id,'name'=>$name,'street'=>$street,'city'=>$city,'state'=>$state,'pincode'=>$pincode,'state_code'=>$state_code,'state_gst'=>$state_gst,'gstin'=>$gstin); if($abp_id >0) { $this->model->insert($table,$data); } } } redirect('controller/add_product'); } else{ echo '<p style="color:red;">Please upload file with xlsx extension only</p>'; } } } public function product_list() { $sessionData = $this->decryptSessionData(); if (!$sessionData || !isset($sessionData['id']) || $sessionData['role'] != '1') { redirect('controller/login'); } $table='product_details'; $where=array('status'=>0); $data['confirmed_data']=$this->model->fetch_where_data($table,$where); $this->load->view('product_list',$data); } public function update_product() { $sessionData = $this->decryptSessionData(); $id = $sessionData['id']; $role = $sessionData['role']; $id=$this->input->post('item_id'); $item=$this->input->post('item_name'); $code=$this->input->post('code'); $hsn=$this->input->post('hsn'); $price=$this->input->post('price'); $description=$this->input->post('description'); $table='product_details'; $data=array('item'=>$item,'item_code'=>$code,'item_description'=>$description,'list_price'=>$price,'hsn_code'=>$hsn); $where=array('id'=>$id); $this->model->update_new($where,$table,$data); // $role=$this->session->userdata('role'); // $id=$this->session->userdata('id'); if($role==3) { $w=array('id'=>$id); $t='profile'; $data['details']=$this->model->get_where_row($t,$w); } else { $w=array('id'=>$id); $t='supervisor'; $data['details']=$this->model->get_where_row($t,$w); } if($role==1){ redirect('controller/product_list'); } else{ redirect('controller/reg_product_list'); } } public function po_edit() { $po=$_GET['id']; $tables='product_po'; $where1=array('id'=>$po); $indent=$this->model->get_where_row($tables,$where1); $data['po']=$indent->po_no; $data['id']=$indent->id; $id=$indent->po_no; $where=array('po_no'=>$id); $data['po_details']=$this->model->fetch_where_data($tables,$where); $data['p_details']=$this->model->get_where_row($tables,$where); // $role=$this->session->userdata('role'); // $id=$this->session->userdata('id'); $sessionData = $this->decryptSessionData(); $id = $sessionData['id']; $role = $sessionData['role']; if($id){ if($role==3) { $w=array('id'=>$id); $t='profile'; $data['details']=$this->model->get_where_row($t,$w); $abp=$data['details']->id; $tab='address'; $where2=array('abp_id'=>$abp); $data['address']=$this->model->fetch_where_data($tab,$where2); } else { $w=array('id'=>$id); $t='supervisor'; $data['details']=$this->model->get_where_row($t,$w); $abp=$data['details']->abp_id; $tab='address'; $where2=array('id'=>$abp); $data['address']=$this->model->fetch_where_data($tab,$where2); } //print_r($data['p_details']); $this->load->view('po_edit',$data); }else { redirect('/'); } } public function normal_po_details() { // $role=$this->session->userdata('role'); // $id=$this->session->userdata('id'); // $user_dept = $this->session->userdata('user_dept'); $sessionData = $this->decryptSessionData(); $id = $sessionData['id']; $role = $sessionData['role']; $user_dept = $sessionData['$user_dept']; if($role==3) { $w=array('id'=>$id); $t='profile'; $data['details']=$this->model->get_where_row($t,$w); $table='po_link'; $result=$this->model->fetch_normal_po($id); if($result) { echo json_encode($result); } else { echo json_encode(array('result'=>0,'message'=>"No data available")); } } elseif($user_dept==1) { $w=array('id'=>$id); $t='supervisor'; $data['details']=$this->model->get_where_row($t,$w); $det_reg=$this->model->fetch_where_data($t,$w); foreach($det_reg as $det) { $region = $det->region; } $table='po_link'; $where=array('status'=>0); $result=$this->model->fetch_normal_po_reg($region); if($result) { echo json_encode($result); } else { echo json_encode(array('result'=>0,'message'=>"No data available")); } } elseif($user_dept==2) { $result=$this->model->get_all_normal_po_data(); if($result) { echo json_encode($result); } else { echo json_encode(array('result'=>0,'message'=>"No data available")); } } else { $w=array('id'=>$id); $t='supervisor'; $data['details']=$this->model->get_where_row($t,$w); $det_reg=$this->model->fetch_where_data($t,$w); foreach($det_reg as $det) { $region = $det->region; } $table='po_link'; $where=array('status'=>0); $result=$this->model->fetch_normal_po_reg($region); if($result) { echo json_encode($result); } else { echo json_encode(array('result'=>0,'message'=>"No data available")); } } $table='po_info'; $data['time']=$this->model->get_time($table); } public function special_po_details() { $sessionData = $this->decryptSessionData(); $id = $sessionData['id']; $role = $sessionData['role']; $user_dept = $sessionData['$user_dept']; if($role==3) { $w=array('id'=>$id); $t='profile'; $data['details']=$this->model->get_where_row($t,$w); $table='signed_po'; $where=array('status'=>0); $result=$this->model->fetch_special_po($id); if($result) { echo json_encode($result); } else { echo json_encode(array('result'=>0,'message'=>"No data available")); } } elseif($user_dept==1) { $w=array('id'=>$id); $t='supervisor'; $data['details']=$this->model->get_where_row($t,$w); $table='signed_po'; $where=array('user_id'=>$id); $det_reg=$this->model->fetch_where_data($table,$where); $region = $data['details']->region; $result=$this->model->fetch_special_po_reg($region); if($result) { echo json_encode($result); } else { echo json_encode(array('result'=>0,'message'=>"No data available")); } } elseif($user_dept==2) { $result=$this->model->get_all_special_po_data(); if($result) { echo json_encode($result); } else { echo json_encode(array('result'=>0,'message'=>"No data available")); } } else { $w=array('id'=>$id); $t='supervisor'; $data['details']=$this->model->get_where_row($t,$w); $table='signed_po'; $where=array('user_id'=>$id); $det_reg=$this->model->fetch_where_data($table,$where); $region = $data['details']->region; $result=$this->model->fetch_special_po_reg($region); if($result) { echo json_encode($result); } else { echo json_encode(array('result'=>0,'message'=>"No data available")); } } $table='po_info'; $data['time']=$this->model->get_time($table); } public function get_normal_approved_po_details() { // $role=$this->session->userdata('role'); // $id=$this->session->userdata('id'); // $user_dept=$this->session->userdata('user_dept'); $sessionData = $this->decryptSessionData(); $id = $sessionData['id']; $role = $sessionData['role']; $user_dept = $sessionData['$user_dept']; if($role==3) { $w=array('id'=>$id); $t='profile'; $data['details']=$this->model->get_where_row($t,$w); $table='po_link'; $where=array('status'=>0,'approve_status'=>'APPROVED'); $result=$this->model->fetch_normal_approved_po($table,$where,$id); if($result) { echo json_encode($result); } else { echo json_encode(array('result'=>0,'message'=>"No data available")); } } elseif($user_dept==1) { $w=array('id'=>$id); $t='supervisor'; $data['details']=$this->model->get_where_row($t,$w); $table='signed_po'; $where=array('user_id'=>$id); $det_reg=$this->model->fetch_where_data($table,$where); $region = $data['details']->region; $result=$this->model->fetch_normal_approved_po_reg($region); if($result) { echo json_encode($result); } else { echo json_encode(array('result'=>0,'message'=>"No data available")); } } elseif($user_dept==2) { $result=$this->model->get_all_normal_approved_po_data(); if($result) { echo json_encode($result); } else { echo json_encode(array('result'=>0,'message'=>"No data available")); } } else { $w=array('id'=>$id); $t='supervisor'; $data['details']=$this->model->get_where_row($t,$w); $table='po_link'; $where=array('status'=>0,'approve_status'=>'APPROVED'); $det_reg=$this->model->fetch_where_data($t,$w); foreach($det_reg as $det) { $region = $det->region; } $result=$this->model->fetch_normal_approved_po_reg($region); if($result) { echo json_encode($result); } else { echo json_encode(array('result'=>0,'message'=>"No data available")); } } $table='po_info'; $data['time']=$this->model->get_time($table); } public function get_special_approved_po_details() { // $role=$this->session->userdata('role'); // $id=$this->session->userdata('id'); // $user_dept=$this->session->userdata('user_dept'); $sessionData = $this->decryptSessionData(); $id = $sessionData['id']; $role = $sessionData['role']; $user_dept = $sessionData['$user_dept']; if($role==3) { $w=array('id'=>$id); $t='profile'; $data['details']=$this->model->get_where_row($t,$w); $table='signed_po'; $where=array('status'=>0,'approve_status'=>'APPROVED','user_id'=>$id); $result=$this->model->fetch_special_approved_po($table,$where); if($result) { echo json_encode($result); } else { echo json_encode(array('result'=>0,'message'=>"No data available")); } } elseif($user_dept==1) { $w=array('id'=>$id); $t='supervisor'; $data['details']=$this->model->get_where_row($t,$w); $region = $data['details']->region; $table='signed_po'; $where=array('status'=>0,'approve_status'=>'APPROVED','user_id'=>$id); $result=$this->model->fetch_special_approved_po_reg($region); if($result) { echo json_encode($result); } else { echo json_encode(array('result'=>0,'message'=>"No data available")); } } elseif($user_dept==2) { $result=$this->model->get_all_special_approved_po_data(); if($result) { echo json_encode($result); } else { echo json_encode(array('result'=>0,'message'=>"No data available")); } } else { $w=array('id'=>$id); $t='supervisor'; $data['details']=$this->model->get_where_row($t,$w); $region = $data['details']->region; $table='signed_po'; $where=array('status'=>0,'approve_status'=>'APPROVED','user_id'=>$id); $result=$this->model->fetch_special_approved_po_reg($region); if($result) { echo json_encode($result); } else { echo json_encode(array('result'=>0,'message'=>"No data available")); } } $table='po_info'; $data['time']=$this->model->get_time($table); } public function view_po() { $po_no = $this->input->post('po_no'); $table='po_link'; $where=array('id'=>$po_no); $result=$this->model->fetch_where_data($table,$where); if($result) { echo json_encode(array('result'=>1,'res'=>$result)); } else{ echo json_encode(array('result'=>0,'message'=>"No data available")); } } public function view_specialpo() { $po_no = $this->input->post('po_no'); $table='signed_po'; $where=array('id'=>$po_no); $result=$this->model->fetch_where_data($table,$where); if($result) { echo json_encode(array('result'=>1,'res'=>$result)); } else{ echo json_encode(array('result'=>0,'message'=>"No data available")); } } /* public function approve_po() { $po_no = $this->input->post('po_no'); $table='po_link'; $where=array('id'=>$po_no); $result=$this->model->get_where_row($table,$where); //$where = array('po_no'=>$result->po_no); $table1='product_po'; $data1 = array('approve_status'=>'APPROVED'); $where1 = array('po_no'=>$result->po_no); $res=$this->model->update_new($where1,$table1,$data1); if($res) { echo json_encode(array('result'=>1,'res'=>$res)); } else{ echo json_encode(array('result'=>0,'message'=>"No data available")); } $table='po_link'; $data = array('approve_status'=>'APPROVED'); $result=$this->model->update_new($where,$table,$data); if($result) { echo json_encode(array('result'=>1,'res'=>$result)); } else{ echo json_encode(array('result'=>0,'message'=>"No data available")); } }*/ public function approve_po() { $po_no = $this->input->post('po_no'); $table='po_link'; $where=array('id'=>$po_no); $result=$this->model->get_where_row($table,$where); //$where = array('po_no'=>$result->po_no); $table1='product_po'; $data1 = array('approve_status'=>'APPROVED'); $where1 = array('id'=>$po_no); $res=$this->model->update_new($where1,$table1,$data1); if($res > 0) { $where =array('po_no'=>$po_no); $table='product_po'; $fetch_det = $this->model->get_where_row($table,$where); $send_to_po_no = $fetch_det->po_no ; $mail_po_no = $send_to_po_no; $this->load->library('email'); $this->email->set_mailtype('html'); $msg = "Hi, PO NO.:".$mail_po_no." Has Been Approved "; $this->email->from('notify@yaskawa.in', 'yaskawa'); $this->email->to('avinash_s@yaskawa.in', 'yaskawa'); $this->email->subject('New PO Approved'); $this->email->message($msg); $this->email->send(); echo json_encode(array('result'=>1,'res'=>$res)); } else { echo json_encode(array('result'=>0,'message'=>"No data available")); } $table='po_link'; $data = array('approve_status'=>'APPROVED'); $result=$this->model->update_new($where,$table,$data); if($result) { echo json_encode(array('result'=>1,'res'=>$result)); } else{ echo json_encode(array('result'=>0,'message'=>"No data available")); } } public function approve_specialpo() { $po_no = $this->input->post('po_no'); $table='signed_po'; $where=array('id'=>$po_no); $data1 = array('approve_status'=>'APPROVED'); $res=$this->model->update_new($where,$table,$data1); if($res) { $where =array('po_no'=>$po_no); $table='product_po'; $fetch_det = $this->model->get_where_row($table,$where); $send_to_po_no = $fetch_det->po_no ; $mail_po_no = $send_to_po_no; $this->load->library('email'); $this->email->set_mailtype('html'); $msg = "Hi, PO NO.:".$mail_po_no." Has Been Approved "; $this->email->from('notify@yaskawa.in', 'yaskawa'); $this->email->to('avinash_s@yaskawa.in', 'yaskawa'); $this->email->subject('New PO Approved'); $this->email->message($msg); $this->email->send(); echo json_encode(array('result'=>1,'res'=>$res)); } else { echo json_encode(array('result'=>0,'message'=>"No data available")); } } public function disapprove_po() { $po_no = $this->input->post('po_no'); $where = array('po_no'=>$po_no); $table1='product_po'; $data1 = array('approve_status'=>'DISAPPROVED'); $where1 = array('po_no'=>$po_no); $res=$this->model->update_new($where1,$table1,$data1); if($res) { echo json_encode(array('result'=>1,'res'=>$res)); } else{ echo json_encode(array('result'=>0,'message'=>"No data available")); } $table='po_link'; $data = array('approve_status'=>'DISAPPROVED'); $result=$this->model->update_new($where,$table,$data); if($result) { echo json_encode(array('result'=>1,'res'=>$result)); } else{ echo json_encode(array('result'=>0,'message'=>"No data available")); } } public function disapprove_specialpo() { $po_no = $this->input->post('po_no'); $table='signed_po'; $where=array('id'=>$po_no); $data1 = array('approve_status'=>'DISAPPROVED'); //$where1 = array('po_no'=>$po_no); $res=$this->model->update_new($where,$table,$data1); if($res) { echo json_encode(array('result'=>1,'res'=>$res)); } else{ echo json_encode(array('result'=>0,'message'=>"No data available")); } } public function confirm_PO() { $po=$this->input->post('id'); // $role=$this->session->userdata('role'); // $id=$this->session->userdata('id'); $sessionData = $this->decryptSessionData(); $id = $sessionData['id']; $role = $sessionData['role']; $tab='po_link'; $where2=array('po_no'=>$po); $detail=$this->model->get_where_row($tab,$where2); $file1=$detail->po_path; if($role==3) { $w=array('id'=>$id); $t='profile'; $details=$this->model->get_where_row($t,$w); $username=$details->uid; $w1=array('region'=>$details->region); $t1='supervisor'; $details1=$this->model->fetch_where_data($t1,$w1); echo json_encode(array('result'=>1,'message'=>$file1)); } else { $w=array('id'=>$id); $t='supervisor'; $data['details']=$this->model->get_where_row($t,$w); $abp=$data['details']->id; $tab='address'; $where2=array('abp_id'=>$abp); $data['address']=$this->model->fetch_where_data($tab,$where2); echo json_encode(array('result'=>1,'message'=>$file1)); } return 1; } public function add_robotics_details() { $category = $this->input->post('category'); $model = $this->input->post('model'); $specification = $this->input->post('specification'); $payload = $this->input->post('payload'); $reach = $this->input->post('reach'); $files = $_FILES; $myFile = $_FILES['userFiles']; $cpt = count($_FILES['userFiles']['name']); $ext = pathinfo($cpt, PATHINFO_EXTENSION); // if($ext == "pdf") // { for($i=0; $i<$cpt; $i++) { $error = $myFile["error"][$i]; if ($error == '4') { $file1=""; } else { if($_FILES['userFiles']['name']) { $path=$_FILES['userFiles']['name'][$i]; $target5='robotics_details/'; $stamp=getdate(); $target5.= basename($_FILES['userFiles']['name'][$i]); $file2[]=$target5; move_uploaded_file($_FILES['userFiles']['tmp_name'][$i],$target5); $file1=$target5; } else { $file1=""; } } } $table = 'robotics_details'; $data = array('category'=>$category,'model'=>$model,'specification'=>$specification,'payload'=>$payload,'reach'=>$reach,'files'=>$file1); $result = $this->model->insert($table,$data); if($result) { echo json_encode(array('result'=>1,'message'=>'Added')); } else{ echo json_encode(array('result'=>0,'message'=>'Something went wrong..')); } } public function get_robotics_details() { $table = 'robotics_details'; $result = $this->model->get_all_data($table); if($result) { echo json_encode($result); } else { echo json_encode(array('result'=>0,'message'=>'No datas available')); } } public function get_robotics_file() { $ids = $this->input->post('ids'); $table = 'robotics_details'; $where = array('id'=>$ids); $result = $this->model->fetch_where_data($table,$where); if($result) { echo json_encode(array('result'=>1,'res'=>$result)); } } public function robotics_form() { // if($this->session->userdata('id')== ''){redirect('/');} $sessionData = $this->decryptSessionData(); // Check if session is valid if (!isset($sessionData['id'])) { redirect('/'); return; } $this->load->view('robotics_form'); } public function robotics_list() { $sessionData = $this->decryptSessionData(); // Check if session is valid if (!isset($sessionData['id'])) { redirect('/'); return; } $table = 'robotics_details'; $data['res'] = $this->model->get_all_disctinct_data($table); $table2 = 'robotics_details'; $data['robot'] = $this->model->get_all_data($table2); $this->load->view('robotics_list',$data); } public function robotics_user_list() { if($this->session->userdata('id')== ''){redirect('/');} $this->load->view('robotics_user_list'); } public function upload_po_pdf() { $sessionData = $this->decryptSessionData(); $id = $sessionData['id']; // $id=$this->session->userdata('id'); $po_no = $this->input->post('po_no'); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $created_at = $date->format('d-m-Y'); $files = $_FILES; $myFile = $_FILES['pdf_file']; $cpt = count($_FILES['pdf_file']['name']); $ext = pathinfo($cpt, PATHINFO_EXTENSION); // if($ext == "pdf") // { for($i=0; $i<$cpt; $i++) { $error = $myFile["error"][$i]; if ($error == '4') { $file1=""; } else { if($_FILES['pdf_file']['name']) { $path=$_FILES['pdf_file']['name'][$i]; $target5='pending_po_transfers/'; $stamp=getdate(); $target5.= basename($_FILES['pdf_file']['name'][$i]); $file2[]=$target5; move_uploaded_file($_FILES['pdf_file']['tmp_name'][$i],$target5); $file1=$target5; } else { $file1=""; } } } $data = array('user_id'=>$id,'po_no'=>$po_no,'po_type'=>'transferred','po_path'=>$file1,'created_at'=>$created_at); $table = "signed_po"; $result = $this->model->insert($table,$data); $where_id = array('id'=>$result); $get_po = $this->model->get_where_row($table,$where_id); $table_product = "product_po"; $po = $get_po->po_no; $where_po = array('po_no'=>$po); $get_data = $this->model->get_where_row($table_product,$where_po); $where_data_po_no = array('po_no'=>$get_data->po_no); $update_data = array('transfer_status'=>'TRANSFERRED'); $update_table = $this->model->update($where_data_po_no,$table_product,$update_data); if($result) { $where =array('po_no'=>$this->input->post('po_no')); $table='signed_po'; $fetch_det = $this->model->get_where_row($table,$where); $send_to_po_no = $fetch_det->po_no ; } $mail_po_no = $send_to_po_no; $this->load->library('email'); $this->email->set_mailtype('html'); $msg = "Hi, PO NO.:".$mail_po_no." Has Been Transferred "; $this->email->from('notify@yaskawa.in', 'yaskawa'); $this->email->to('avinash_s@yaskawa.in', 'yaskawa'); $this->email->subject('Your PO Has Been Transferred'); $this->email->message($msg); $this->email->send(); if($result) { echo json_encode($result); } else { echo json_encode(array('result'=>0,'message'=>"Something went wrong...")); } } public function transfer_cancelled() { $reply = $this->input->post('reply'); $po = $this->input->post('po'); $table = "product_po"; $where = array('po_no'=>$po); $data = array('transfer_status'=>$reply); $res = $this->model->update_new($where,$table,$data); if($res) { echo json_encode(array('result'=>1,'message'=>'Transfer Cancelled')); } } public function get_pending_po() { // $id=$this->session->userdata('id'); // $user_dept=$this->session->userdata('user_dept'); $sessionData = $this->decryptSessionData(); $id = $sessionData['id']; $user_dept = $sessionData['user_dept']; if($user_dept == 3) { $where = array('transfer_status'=>'PENDING'); $table = 'product_po'; $res = $this->model->fetch_where_data($table,$where); if($res) { echo json_encode($res); } else { echo json_encode(array('result'=>0,'message'=>"No data available")); } } elseif($user_dept == 1) { $w=array('id'=>$id); $t='supervisor'; $data['details']=$this->model->get_where_row($t,$w); $det_reg=$this->model->fetch_where_data($t,$w); foreach($det_reg as $det) { $region = $det->region; } $res = $this->model->fetch_pending_po_reg($region); if(!empty($res)) { echo json_encode($res); } else { echo json_encode(array('result'=>0,'message'=>"No data available")); } } elseif($user_dept == 2) { $res = $this->model->get_all_pending_po_data(); if($res) { echo json_encode($res); } else { echo json_encode(array('result'=>0,'message'=>"No data available")); } } else { $res = $this->model->get_pending_po($id); if($res) { echo json_encode($res); } else { echo json_encode(array('result'=>0,'message'=>"No data available")); } } } public function view_pendingpo() { // $id=$this->session->userdata('id'); // $user_dept=$this->session->userdata('user_dept'); $sessionData = $this->decryptSessionData(); $id = $sessionData['id']; $user_dept = $sessionData['user_dept']; if($user_dept == 1) { $ids = $this->input->post('ids'); $where = array('po_no'=>$ids,'transfer_status'=>'PENDING'); $table = 'product_po'; $data['details']=$this->model->get_where_row($table,$where); $region = $data['details']->region; $res = $this->model->view_pending_po_reg($region); if($res) { echo json_encode(array('result'=>1,'res'=>$res)); } else { echo json_encode(array('result'=>0,'message'=>"No data available")); } } elseif($user_dept == 2) { $ids = $this->input->post('ids'); //$where = array('po_no'=>$ids); $res = $this->model->view_pending_po($ids); if($res) { echo json_encode(array('result'=>1,'res'=>$res)); } else { echo json_encode(array('result'=>0,'message'=>"No data available")); } } else { $ids = $this->input->post('ids'); $table='po_link'; $where=array('id'=>$ids); $result=$this->model->fetch_pending_po($ids); if($result) { echo json_encode(array('result'=>1,'res'=>$result)); } else { echo json_encode(array('result'=>0,'message'=>"No data available")); } } } public function upload_pending_po_pdf() { // $id=$this->session->userdata('id'); $sessionData = $this->decryptSessionData(); $id = $sessionData['id']; // $ids = $this->input->post('ids'); $po_no = $this->input->post('po_no'); $files = $_FILES; $myFile = $_FILES['pdf_file']; $cpt = count($_FILES['pdf_file']['name']); $ext = pathinfo($cpt, PATHINFO_EXTENSION); // if($ext == "pdf") // { for($i=0; $i<$cpt; $i++) { $error = $myFile["error"][$i]; if ($error == '4') { $file1=""; } else { if($_FILES['pdf_file']['name']) { $path=$_FILES['pdf_file']['name'][$i]; $target5='pending_po_transfers/'; $stamp=getdate(); $target5.= basename($_FILES['pdf_file']['name'][$i]); $file2[]=$target5; move_uploaded_file($_FILES['pdf_file']['tmp_name'][$i],$target5); $file1=$target5; } else { $file1=""; } } } $where = array('po_no'=>$po_no); $table = 'product_po'; $set_data = array('transfer_status'=>'TRANSFERRED'); $result = $this->model->update_new($where,$table,$set_data); $table1 = "signed_po"; $data = array('user_id'=>$id,'po_no'=>$po_no,'po_type'=>'transferred','po_path'=>$file1); $result = $this->model->insert($table1,$data); if($result) { echo json_encode($result); } else { echo json_encode(array('result'=>0,'message'=>"Something went wrong...")); } } public function get_transferred_po() { // $id=$this->session->userdata('id'); // $user_dept=$this->session->userdata('user_dept'); $sessionData = $this->decryptSessionData(); $id = $sessionData['id']; $user_dept = $sessionData['user_dept']; if($user_dept == 3) { $where = array('transfer_status'=>'TRANSFERRED'); $table = 'product_po'; $res = $this->model->fetch_where_data($table,$where); if($res) { echo json_encode($res); } else { echo json_encode(array('result'=>0,'message'=>"No data available")); } } elseif($user_dept == 2) { $res = $this->model->get_all_transferred_po(); if($res) { echo json_encode($res); } else { echo json_encode(array('result'=>0,'message'=>"No data available")); } } elseif($user_dept == 1) { $w=array('id'=>$id); $t='supervisor'; $data['details']=$this->model->get_where_row($t,$w); $det_reg=$this->model->fetch_where_data($t,$w); foreach($det_reg as $det) { $region = $det->region; } $res = $this->model->fetch_transferred_po_reg($region); if($res) { echo json_encode($res); } else { echo json_encode(array('result'=>0,'message'=>"No data available")); } } else { $res = $this->model->get_transferred_po($id); if($res) { echo json_encode($res); } else { echo json_encode(array('result'=>0,'message'=>"No data available")); } } } public function view_signed_po() { $po_no = $this->input->post('po_no'); $table='signed_po'; $where=array('id'=>$po_no); $result=$this->model->fetch_where_data($table,$where); if($result) { echo json_encode(array('result'=>1,'res'=>$result)); } else{ echo json_encode(array('result'=>0,'message'=>"No data available")); } } public function get_signed_po() { // $user_dept=$this->session->userdata('user_dept'); $sessionData = $this->decryptSessionData(); $user_dept = $sessionData['user_dept']; if($user_dept == 2) { $result = $this->model->get_signed_po(); echo json_encode($result); } } public function view_signed_po_details() { // $id=$this->session->userdata('id'); // $user_dept=$this->session->userdata('user_dept'); $sessionData = $this->decryptSessionData(); $id = $sessionData['id']; $user_dept = $sessionData['user_dept']; if($user_dept == 2) { $ids = $this->input->post('ids'); //$where = array('po_no'=>$ids); $res = $this->model->view_signed_po($ids); if($res) { echo json_encode(array('result'=>1,'res'=>$res)); } else { echo json_encode(array('result'=>0,'message'=>"No data available")); } } } public function approve_signedpo() { $po_no = $this->input->post('po_no'); // $table='po_link'; // $where=array('id'=>$po_no); // $result=$this->model->get_where_row($table,$where); //$where = array('po_no'=>$result->po_no); $table1='signed_po'; $data1 = array('approve_status'=>'APPROVED'); $where1 = array('id'=>$po_no); $res=$this->model->update_new($where1,$table1,$data1); //if($res > 0) // { $where =array('id'=>$po_no); $table='signed_po'; $fetch_det = $this->model->get_where_row($table,$where); $send_to_po_no = $fetch_det->po_no ; $mail_po_no = $send_to_po_no; $this->load->library('email'); $this->email->set_mailtype('html'); $msg = "Hi, PO NO.:".$mail_po_no." Has Been Approved "; $this->email->from('notify@yaskawa.in', 'yaskawa'); $this->email->to('sowmya@jayblues.com', 'yaskawa'); $this->email->subject('New PO Approved'); $this->email->message($msg); $this->email->send(); echo json_encode(array('result'=>1,'res'=>$res)); } public function disapprove_signedpo() { $po_no = $this->input->post('po_no'); $table1='signed_po'; $data1 = array('approve_status'=>'DISAPPROVED'); $where1 = array('id'=>$po_no); $res=$this->model->update_new($where1,$table1,$data1); // if($res > 0) // { $where =array('id'=>$po_no); $table='signed_po'; $fetch_det = $this->model->get_where_row($table,$where); $send_to_po_no = $fetch_det->po_no ; $mail_po_no = $send_to_po_no; $this->load->library('email'); $this->email->set_mailtype('html'); $msg = "Hi, PO NO.:".$mail_po_no." Has Been Dispproved "; $this->email->from('notify@yaskawa.in', 'yaskawa'); $this->email->to('sowmya@jayblues.com', 'yaskawa'); $this->email->subject('PO Disapproved'); $this->email->message($msg); $this->email->send(); echo json_encode(array('result'=>1,'res'=>$res)); /*} else { echo json_encode(array('result'=>0,'message'=>"No data available")); }*/ } public function po_number_validation() { $po_id=$this->input->post('id'); //$role=$this->session->userdata('role'); //$id=$this->session->userdata('id'); $add='product_po'; $whe=array('po_no'=>$po_id); $data=$this->model->get_row($add,$whe); if($data) { echo json_encode(array('result' => 1, 'message' => 'This PO Number Already Exist')); } else { echo json_encode(array('result' => 0, 'message' => 'This PO Number is Correct')); } } public function catalogue_details() { $table='manuals'; $where=array('status'=>0); $result=$this->model->drive_manual($table,$where); echo json_encode($result); } public function case_notes() { $table='case_stories'; $where=array('status'=>0); $result=$this->model->get_all_data_new($table,$where); echo json_encode($result); } /*----------------------new-pages----------------------------*/ public function menu(){ $sessionData = $this->decryptSessionData(); if (!isset($sessionData['id'])) { redirect('/'); return; } $this->load->view('menu'); } public function d_technical_manuals(){ $sessionData = $this->decryptSessionData(); if (!isset($sessionData['id'])) { redirect('/'); return; } $this->load->view('d_technical_manuals'); } public function d_case_notes(){ // if($this->session->userdata('id')== ''){redirect('/');} $sessionData = $this->decryptSessionData(); if (!isset($sessionData['id'])) { redirect('/'); return; } $this->load->view('d_case_notes'); } public function d_application_letter(){ // $role=$this->session->userdata('role'); // $id=$this->session->userdata('id'); $sessionData = $this->decryptSessionData(); $id = $sessionData['id']; $role = $sessionData['role']; if($id){ if($role==3) { // $id1=$this->session->userdata('uid'); $id1= $sessionData['uid']; $w=array('id'=>$id); $t='profile'; $data['details']=$this->model->get_where_row($t,$w); $table='appreciation_letter'; //$data['case']=$this->model->partner_code($table,$id1); $data['case']=$this->model->get_all_data($table); } else { $w=array('id'=>$id); $t='supervisor'; $data['details']=$this->model->get_where_row($t,$w); } $this->load->view('includes/admin_header',$data); $this->load->view('d_application_letter'); $this->load->view('includes/admin_footer',$data); }else { redirect('/'); } } public function get_appreciation_letter() { $table='appreciation_letter'; $data=$this->model->get_all_data($table); echo json_encode($data); } public function d_application_notes(){ // $role=$this->session->userdata('role'); // $id=$this->session->userdata('id'); $sessionData = $this->decryptSessionData(); $id = $sessionData['id']; $role = $sessionData['role']; if($id){ if($role==3) { // $id1=$this->session->userdata('uid'); $id1= $sessionData['uid']; $w=array('id'=>$id); $t='profile'; $data['details']=$this->model->get_where_row($t,$w); } else { $w=array('id'=>$id); $t='supervisor'; $data['details']=$this->model->get_where_row($t,$w); } $this->load->view('includes/admin_header',$data); $this->load->view('d_application_notes'); $this->load->view('includes/admin_footer',$data); }else { redirect('/'); } } public function get_application_notes() { $table='application_notes'; $data=$this->model->get_all_data($table); echo json_encode($data); } public function d_technical_notes_test(){ // $role=$this->session->userdata('role'); // $id=$this->session->userdata('id'); $sessionData = $this->decryptSessionData(); $id = $sessionData['id']; $role = $sessionData['role']; if($id){ if($role==3) { // $id1=$this->session->userdata('uid'); $id1= $sessionData['uid']; $w=array('id'=>$id); $t='profile'; $data['details']=$this->model->get_where_row($t,$w); } else { $w=array('id'=>$id); $t='supervisor'; $data['details']=$this->model->get_where_row($t,$w); } $this->load->view('includes/admin_header',$data); $this->load->view('d_technical_notes_test'); $this->load->view('includes/admin_footer',$data); }else { redirect('/'); } } public function d_technical_notes(){ // $role=$this->session->userdata('role'); // $id=$this->session->userdata('id'); $sessionData = $this->decryptSessionData(); $id = $sessionData['id']; $role = $sessionData['role']; if($id){ if($role==3) { // $id1=$this->session->userdata('uid'); $id1= $sessionData['uid']; $w=array('id'=>$id); $t='profile'; $data['details']=$this->model->get_where_row($t,$w); } else { $w=array('id'=>$id); $t='supervisor'; $data['details']=$this->model->get_where_row($t,$w); } $this->load->view('includes/admin_header',$data); //$this->load->view('d_technical_notes'); $this->load->view('d_technical_notes_test'); $this->load->view('includes/admin_footer',$data); }else { redirect('/'); } } public function get_technical_notes() { $table='technical_notes'; $data=$this->model->get_all_data($table); echo json_encode($data); } public function d_training_presentations(){ // $role=$this->session->userdata('role'); // $id=$this->session->userdata('id'); $sessionData = $this->decryptSessionData(); $id = $sessionData['id']; $role = $sessionData['role']; if($id){ if($role==3) { // $id1=$this->session->userdata('uid'); $id1= $sessionData['uid']; $w=array('id'=>$id); $t='profile'; $data['details']=$this->model->get_where_row($t,$w); } else { $w=array('id'=>$id); $t='supervisor'; $data['details']=$this->model->get_where_row($t,$w); } $this->load->view('includes/admin_header',$data); $this->load->view('d_training_presentations'); $this->load->view('includes/admin_footer',$data); }else { redirect('/'); } } public function get_training_presentation() { $table='training_presentation'; $data=$this->model->get_all_data($table); echo json_encode($data); } public function d_softwares(){ // $role=$this->session->userdata('role'); // $id=$this->session->userdata('id'); $sessionData = $this->decryptSessionData(); $id = $sessionData['id']; $role = $sessionData['role']; if($id){ if($role==3) { // $id1=$this->session->userdata('uid'); $id1= $sessionData['uid']; $w=array('id'=>$id); $t='profile'; $data['details']=$this->model->get_where_row($t,$w); } else { $w=array('id'=>$id); $t='supervisor'; $data['details']=$this->model->get_where_row($t,$w); } $this->load->view('includes/admin_header',$data); $this->load->view('d_softwares'); $this->load->view('includes/admin_footer',$data); }else { redirect('/'); } } public function get_softwares() { $table='softwares'; $where=array('status'=>0); $result=$this->model->get_accessed_softwares($table,$where); echo json_encode($result); } public function d_projects(){ // $role=$this->session->userdata('role'); // $id=$this->session->userdata('id'); $sessionData = $this->decryptSessionData(); $id = $sessionData['id']; $role = $sessionData['role']; if($id){ if($role==3) { // $id1=$this->session->userdata('uid'); $id1= $sessionData['uid']; $w=array('id'=>$id); $t='profile'; $data['details']=$this->model->get_where_row($t,$w); } else { $w=array('id'=>$id); $t='supervisor'; $data['details']=$this->model->get_where_row($t,$w); } $this->load->view('includes/admin_header',$data); $this->load->view('d_projects'); $this->load->view('includes/admin_footer',$data); }else { redirect('/'); } } public function get_projects() { $table='projects'; $where=array('status'=>0); $result=$this->model->get_accessed_projects($table,$where); echo json_encode($result); } public function d_others(){ // $role=$this->session->userdata('role'); // $id=$this->session->userdata('id'); $sessionData = $this->decryptSessionData(); $id = $sessionData['id']; $role = $sessionData['role']; if($id){ if($role==3) { // $id1=$this->session->userdata('uid'); $id1 = $sessionData['uid']; $w=array('id'=>$id); $t='profile'; $data['details']=$this->model->get_where_row($t,$w); } else { $w=array('id'=>$id); $t='supervisor'; $data['details']=$this->model->get_where_row($t,$w); } $this->load->view('includes/admin_header',$data); $this->load->view('d_others'); $this->load->view('includes/admin_footer',$data); }else { redirect('/'); } } public function get_others() { $table='others'; $where=array('status'=>0); $result=$this->model->get_accessed_others($table,$where); echo json_encode($result); } public function application_letter_upload() { $sessionData = $this->decryptSessionData(); // if (!isset($sessionData['id'], $sessionData['role'], $sessionData['department'])) { // redirect('/'); // return; // } $id = $sessionData['id']; $role = $sessionData['role']; $department = $sessionData['department']; if (!(($role == '2' && $department == '6') || $role == '3')) { log_message('error', "Unauthorized access attempt. Role: $role, Department: $department"); redirect('/'); return; } if($role==3) { $w=array('id'=>$id); $t='profile'; $data['details']=$this->model->get_where_row($t,$w); } else { $w=array('id'=>$id); $t='supervisor'; $data['details']=$this->model->get_where_row($t,$w); } $tab="appreciation_letter"; $data['time']=$this->model->get_time($tab); $this->load->view('application_letter_upload',$data); } public function application_notes_upload() { // $role=$this->session->userdata('role'); // $department=$this->session->userdata('department'); // $id=$this->session->userdata('id'); $sessionData = $this->decryptSessionData(); if (!isset($sessionData['id'], $sessionData['role'], $sessionData['department'])) { redirect('/'); return; } $id = $sessionData['id']; $role = $sessionData['role']; $department = $sessionData['department']; if (!(($role == '2' && $department == '6') || $role == '3')) { log_message('error', "Unauthorized access attempt. Role: $role, Department: $department"); redirect('/'); return; } if($role==3) { $w=array('id'=>$id); $t='profile'; $data['details']=$this->model->get_where_row($t,$w); } else { $w=array('id'=>$id); $t='supervisor'; $data['details']=$this->model->get_where_row($t,$w); } $tab="application_notes"; $data['time']=$this->model->get_time($tab); $this->load->view('application_notes_upload',$data); } public function technical_notes_upload() { // $role=$this->session->userdata('role'); // $department=$this->session->userdata('department'); // $id=$this->session->userdata('id'); $sessionData = $this->decryptSessionData(); if (!isset($sessionData['id'], $sessionData['role'], $sessionData['department'])) { redirect('/'); return; } $id = $sessionData['id']; $role = $sessionData['role']; $department = $sessionData['department']; if (!(($role == '2' && $department == '6') || $role == '3')) { log_message('error', "Unauthorized access attempt. Role: $role, Department: $department"); redirect('/'); return; } if($role==3) { $w=array('id'=>$id); $t='profile'; $data['details']=$this->model->get_where_row($t,$w); } else { $w=array('id'=>$id); $t='supervisor'; $data['details']=$this->model->get_where_row($t,$w); } $tab="technical_notes"; $data['time']=$this->model->get_time($tab); $this->load->view('technical_notes_upload',$data); } public function training_presentations_upload() { // $role=$this->session->userdata('role'); // $department=$this->session->userdata('department'); // $id=$this->session->userdata('id'); $sessionData = $this->decryptSessionData(); if (!isset($sessionData['id'], $sessionData['role'], $sessionData['department'])) { redirect('/'); return; } $id = $sessionData['id']; $role = $sessionData['role']; $department = $sessionData['department']; if (!(($role == '2' && $department == '6') || $role == '3')) { log_message('error', "Unauthorized access attempt. Role: $role, Department: $department"); redirect('/'); return; } if($role==3) { $w=array('id'=>$id); $t='profile'; $data['details']=$this->model->get_where_row($t,$w); } else { $w=array('id'=>$id); $t='supervisor'; $data['details']=$this->model->get_where_row($t,$w); } $tab="training_presentation"; $data['time']=$this->model->get_time($tab); $this->load->view('training_presentations_upload',$data); } public function softwares_upload() { // $role=$this->session->userdata('role'); // $department=$this->session->userdata('department'); // $id=$this->session->userdata('id'); $sessionData = $this->decryptSessionData(); if (!isset($sessionData['id'], $sessionData['role'], $sessionData['department'])) { redirect('/'); return; } $id = $sessionData['id']; $role = $sessionData['role']; $department = $sessionData['department']; if (!(($role == '2' && $department == '6') || $role == '3')) { log_message('error', "Unauthorized access attempt. Role: $role, Department: $department"); redirect('/'); return; } if($role==3) { $w=array('id'=>$id); $t='profile'; $data['details']=$this->model->get_where_row($t,$w); } else { $w=array('id'=>$id); $t='supervisor'; $data['details']=$this->model->get_where_row($t,$w); } $tab="softwares"; $data['time']=$this->model->get_time($tab); $this->load->view('softwares_upload',$data); } public function projects_upload() { // $role=$this->session->userdata('role'); // $department=$this->session->userdata('department'); // $id=$this->session->userdata('id'); $sessionData = $this->decryptSessionData(); if (!isset($sessionData['id'], $sessionData['role'], $sessionData['department'])) { redirect('/'); return; } $id = $sessionData['id']; $role = $sessionData['role']; $department = $sessionData['department']; if (!(($role == '2' && $department == '6') || $role == '3')) { log_message('error', "Unauthorized access attempt. Role: $role, Department: $department"); redirect('/'); return; } if($role==3) { $w=array('id'=>$id); $t='profile'; $data['details']=$this->model->get_where_row($t,$w); } else { $w=array('id'=>$id); $t='supervisor'; $data['details']=$this->model->get_where_row($t,$w); } $tab="projects"; $data['time']=$this->model->get_time($tab); $this->load->view('projects_upload',$data); } public function others_upload() { // $role=$this->session->userdata('role'); // $department=$this->session->userdata('department'); // $id=$this->session->userdata('id'); $sessionData = $this->decryptSessionData(); if (!isset($sessionData['id'], $sessionData['role'], $sessionData['department'])) { redirect('/'); return; } $id = $sessionData['id']; $role = $sessionData['role']; $department = $sessionData['department']; if (!(($role == '2' && $department == '6') || $role == '3')) { log_message('error', "Unauthorized access attempt. Role: $role, Department: $department"); redirect('/'); return; } if($role==3) { $w=array('id'=>$id); $t='profile'; $data['details']=$this->model->get_where_row($t,$w); } else { $w=array('id'=>$id); $t='supervisor'; $data['details']=$this->model->get_where_row($t,$w); } $tab="others"; $data['time']=$this->model->get_time($tab); $this->load->view('others_upload',$data); } public function appreciation_letter_import() { $document_no=$this->input->post('document_no'); $industry=$this->input->post('segment'); $application=$this->input->post('company'); $product_type=$this->input->post('location'); $allowedExtensions = ['csv', 'xls', 'xlsx', 'pdf', 'doc', 'docx', 'ppt', 'pptx', 'jpg', 'jpeg']; $file = $_FILES['document']; if (is_uploaded_file($file['tmp_name'])) { $sourcePath = $file['tmp_name']; $file_name = $file['name']; $fileExtension = strtolower(pathinfo($file_name, PATHINFO_EXTENSION)); if (!in_array($fileExtension, $allowedExtensions)) { echo json_encode(['result' => '0', 'message' => 'Invalid file type!']); return; } if(is_uploaded_file($_FILES['document']['tmp_name'])) { $document = $_FILES['document']['tmp_name']; $document = "uploads/appreciation_uploads/".$_FILES['document']['name']; move_uploaded_file($_FILES['document']['tmp_name'],$document); } else { $document=""; } $data=array('document_no'=>$document_no,'segment'=>$industry,'company'=>$application,'location'=>$product_type,'document'=>$document); $table='appreciation_letter'; $this->model->insert($table,$data); redirect('controller/application_letter_upload'); } } public function appreciation_letter_insert() { $table='appreciation_letter'; $data=$this->model->get_all_data($table); echo json_encode($data); } public function appreciation_letter_fetch() { $id=$this->input->post('id'); $table='appreciation_letter'; $where=array('id'=>$id); $data=$this->model->get_where_row($table,$where); echo json_encode($data); } public function appreciation_letter_edit() { $id=$this->input->post('update_id'); $document_no=$this->input->post('update_document_no'); $industry=$this->input->post('update_segment'); $application=$this->input->post('update_company'); $product_type=$this->input->post('update_location'); $allowedExtensions = ['csv', 'xls', 'xlsx', 'pdf', 'doc', 'docx', 'ppt', 'pptx', 'jpg', 'jpeg']; $file = $_FILES['update_document']; if (is_uploaded_file($file['tmp_name'])) { $sourcePath = $file['tmp_name']; $file_name = $file['name']; $fileExtension = strtolower(pathinfo($file_name, PATHINFO_EXTENSION)); if (!in_array($fileExtension, $allowedExtensions)) { echo json_encode(['result' => '0', 'message' => 'Invalid file type!']); return; } if(is_uploaded_file($_FILES['update_document']['tmp_name'])) { $document = $_FILES['update_document']['tmp_name']; $document = "uploads/appreciation_uploads/".$_FILES['update_document']['name']; move_uploaded_file($_FILES['update_document']['tmp_name'],$document); $data=array('document_no'=>$document_no,'segment'=>$industry,'company'=>$application,'location'=>$product_type,'document'=>$document); } else { $data=array('document_no'=>$document_no,'segment'=>$industry,'company'=>$application,'location'=>$product_type); } $table='appreciation_letter'; $where=array('id'=>$id); $this->model->update_new($where,$table,$data); redirect('controller/application_letter_upload'); } } public function appreciation_letter_delete() { $id=$this->input->post('id'); $table='appreciation_letter'; $where=array('id'=>$id); $this->model->delete($table,$where); return true; } public function application_notes_import() { $document_no=$this->input->post('document_no'); $document_name=$this->input->post('document_name'); $product=$this->input->post('product'); $application=$this->input->post('application'); $segment=$this->input->post('segment'); $allowedExtensions = ['csv', 'xls', 'xlsx', 'pdf', 'doc', 'docx', 'ppt', 'pptx', 'jpg', 'jpeg']; $file = $_FILES['document']; if (is_uploaded_file($file['tmp_name'])) { $sourcePath = $file['tmp_name']; $file_name = $file['name']; $fileExtension = strtolower(pathinfo($file_name, PATHINFO_EXTENSION)); if (!in_array($fileExtension, $allowedExtensions)) { echo json_encode(['result' => '0', 'message' => 'Invalid file type!']); return; } if(is_uploaded_file($_FILES['document']['tmp_name'])) { $document = $_FILES['document']['tmp_name']; $document = "uploads/application_uploads/".$_FILES['document']['name']; move_uploaded_file($_FILES['document']['tmp_name'],$document); } else { $document=""; } $data=array('document_no'=>$document_no,'document_name'=>$document_name,'product'=>$product,'application'=>$application,'segment'=>$segment,'document'=>$document); $table='application_notes'; $this->model->insert($table,$data); redirect('controller/application_notes_upload'); } } public function application_notes_insert() { $table='application_notes'; $data=$this->model->get_all_data($table); echo json_encode($data); } public function application_notes_fetch() { $id=$this->input->post('id'); $table='application_notes'; $where=array('id'=>$id); $data=$this->model->get_where_row($table,$where); echo json_encode($data); } public function application_notes_edit() { $id=$this->input->post('update_id'); $document_no=$this->input->post('update_document_no'); $document_name=$this->input->post('update_document_name'); $product=$this->input->post('update_product'); $application=$this->input->post('update_application'); $segment=$this->input->post('update_segment'); $allowedExtensions = ['csv', 'xls', 'xlsx', 'pdf', 'doc', 'docx', 'ppt', 'pptx', 'jpg', 'jpeg']; $file = $_FILES['update_document']; if (is_uploaded_file($file['tmp_name'])) { $sourcePath = $file['tmp_name']; $file_name = $file['name']; $fileExtension = strtolower(pathinfo($file_name, PATHINFO_EXTENSION)); if (!in_array($fileExtension, $allowedExtensions)) { echo json_encode(['result' => '0', 'message' => 'Invalid file type!']); return; } if(is_uploaded_file($_FILES['update_document']['tmp_name'])) { $document = $_FILES['update_document']['tmp_name']; $document = "uploads/application_uploads/".$_FILES['update_document']['name']; move_uploaded_file($_FILES['update_document']['tmp_name'],$document); $data=array('document_no'=>$document_no,'document_name'=>$document_name,'product'=>$product,'application'=>$application,'segment'=>$segment,'document'=>$document); } else { $data=array('document_no'=>$document_no,'document_name'=>$document_name,'product'=>$product,'application'=>$application,'segment'=>$segment); } $table='application_notes'; $where=array('id'=>$id); $this->model->update_new($where,$table,$data); redirect('controller/application_notes_upload'); } } public function application_notes_delete() { $id=$this->input->post('id'); $table='application_notes'; $where=array('id'=>$id); $this->model->delete($table,$where); return true; } public function technical_notes_import() { $document_no=$this->input->post('document_no'); $document_name=$this->input->post('document_name'); $product=$this->input->post('product'); $application=$this->input->post('application'); $allowedExtensions = ['csv', 'xls', 'xlsx', 'pdf', 'doc', 'docx', 'ppt', 'pptx', 'jpg', 'jpeg']; $file = $_FILES['document']; if (is_uploaded_file($file['tmp_name'])) { $sourcePath = $file['tmp_name']; $file_name = $file['name']; $fileExtension = strtolower(pathinfo($file_name, PATHINFO_EXTENSION)); if (!in_array($fileExtension, $allowedExtensions)) { echo json_encode([ 'message' => 'Invalid file type!']); return; } if(is_uploaded_file($_FILES['document']['tmp_name'])) { $document = $_FILES['document']['tmp_name']; $document = "uploads/technical_uploads/".$_FILES['document']['name']; move_uploaded_file($_FILES['document']['tmp_name'],$document); } else { $document=""; } $data=array('document_no'=>$document_no,'document_name'=>$document_name,'product'=>$product,'application'=>$application,'document'=>$document); $table='technical_notes'; $this->model->insert($table,$data); redirect('controller/technical_notes_upload'); } } public function technical_notes_insert() { $table='technical_notes'; $data=$this->model->get_all_data($table); echo json_encode($data); } public function technical_notes_fetch() { $id=$this->input->post('id'); $table='technical_notes'; $where=array('id'=>$id); $data=$this->model->get_where_row($table,$where); echo json_encode($data); } public function technical_notes_edit() { $id=$this->input->post('update_id'); $document_no=$this->input->post('update_document_no'); $document_name=$this->input->post('update_document_name'); $product=$this->input->post('update_product'); $application=$this->input->post('update_application'); $allowedExtensions = ['csv', 'xls', 'xlsx', 'pdf', 'doc', 'docx', 'ppt', 'pptx', 'jpg', 'jpeg']; $file = $_FILES['update_document']; if (is_uploaded_file($file['tmp_name'])) { $sourcePath = $file['tmp_name']; $file_name = $file['name']; $fileExtension = strtolower(pathinfo($file_name, PATHINFO_EXTENSION)); if (!in_array($fileExtension, $allowedExtensions)) { echo json_encode(['message' => 'Invalid file type!']); return; } if(is_uploaded_file($_FILES['update_document']['tmp_name'])) { $document = $_FILES['update_document']['tmp_name']; $document = "uploads/technical_uploads/".$_FILES['update_document']['name']; move_uploaded_file($_FILES['update_document']['tmp_name'],$document); $data=array('document_no'=>$document_no,'document_name'=>$document_name,'product'=>$product,'application'=>$application,'document'=>$document); } else { $data=array('document_no'=>$document_no,'document_name'=>$document_name,'product'=>$product,'application'=>$application); } } $table='technical_notes'; $where=array('id'=>$id); $this->model->update_new($where,$table,$data); redirect('controller/technical_notes_upload'); } public function technical_notes_delete() { $id=$this->input->post('id'); $table='technical_notes'; $where=array('id'=>$id); $this->model->delete($table,$where); return true; } public function training_presentation_import() { $document_no=$this->input->post('document_no'); $document_name=$this->input->post('document_name'); $product=$this->input->post('product'); if(is_uploaded_file($_FILES['document']['tmp_name'])) { $document = $_FILES['document']['tmp_name']; $document = "uploads/training_presentation_uploads/".$_FILES['document']['name']; move_uploaded_file($_FILES['document']['tmp_name'],$document); } else { $document=""; } $data=array('document_no'=>$document_no,'document_name'=>$document_name,'product'=>$product,'document'=>$document); $table='training_presentation'; $this->model->insert($table,$data); redirect('controller/training_presentations_upload'); } public function training_presentations_insert() { $table='training_presentation'; $data=$this->model->get_all_data($table); echo json_encode($data); } public function training_presentations_edit() { $id=$this->input->post('update_id'); $document_no=$this->input->post('update_document_no'); $document_name=$this->input->post('update_document_name'); $product=$this->input->post('update_product'); if(is_uploaded_file($_FILES['update_document']['tmp_name'])) { $document = $_FILES['update_document']['tmp_name']; $document = "uploads/training_presentation_uploads/".$_FILES['update_document']['name']; move_uploaded_file($_FILES['update_document']['tmp_name'],$document); $data=array('document_no'=>$document_no,'document_name'=>$document_name,'product'=>$product,'document'=>$document); } else { $data=array('document_no'=>$document_no,'document_name'=>$document_name,'product'=>$product); } $table='training_presentation'; $where=array('id'=>$id); $this->model->update_new($where,$table,$data); redirect('controller/training_presentations_upload'); } public function training_presentations_fetch() { $id=$this->input->post('id'); $table='training_presentation'; $where=array('id'=>$id); $data=$this->model->get_where_row($table,$where); echo json_encode($data); } public function training_presentations_delete() { $id=$this->input->post('id'); $table='training_presentation'; $where=array('id'=>$id); $this->model->delete($table,$where); return true; } public function softwares_import() { $document_no=$this->input->post('software'); $document_name=$this->input->post('description'); $product=$this->input->post('version'); $allowedExtensions = ['csv', 'xls', 'xlsx', 'pdf', 'doc', 'docx', 'ppt', 'pptx', 'jpg', 'jpeg']; $file = $_FILES['document']; if (is_uploaded_file($file['tmp_name'])) { $sourcePath = $file['tmp_name']; $file_name = $file['name']; $fileExtension = strtolower(pathinfo($file_name, PATHINFO_EXTENSION)); if (!in_array($fileExtension, $allowedExtensions)) { echo json_encode([ 'message' => 'Invalid file type!']); return; } if(is_uploaded_file($_FILES['document']['tmp_name'])) { $document = $_FILES['document']['tmp_name']; $document = "uploads/software_uploads/".$_FILES['document']['name']; move_uploaded_file($_FILES['document']['tmp_name'],$document); } else { $document=""; } $data=array('software'=>$document_no,'description'=>$document_name,'version'=>$product,'document'=>$document); $table='softwares'; $this->model->insert($table,$data); redirect('controller/softwares_upload'); } } public function softwares_insert() { $table='softwares'; $data=$this->model->get_all_data($table); echo json_encode($data); } public function softwares_edit() { $id=$this->input->post('update_id'); $document_no=$this->input->post('update_software'); $document_name=$this->input->post('update_description'); $product=$this->input->post('update_version'); if(is_uploaded_file($_FILES['update_document']['tmp_name'])) { $document = $_FILES['update_document']['tmp_name']; $document = "uploads/software_uploads/".$_FILES['update_document']['name']; move_uploaded_file($_FILES['update_document']['tmp_name'],$document); $data=array('software'=>$document_no,'description'=>$document_name,'version'=>$product,'document'=>$document); } else { $data=array('software'=>$document_no,'description'=>$document_name,'version'=>$product); } $table='softwares'; $where=array('id'=>$id); $this->model->update_new($where,$table,$data); redirect('controller/softwares_upload'); } public function softwares_fetch() { $id=$this->input->post('id'); $table='softwares'; $where=array('id'=>$id); $data=$this->model->get_where_row($table,$where); echo json_encode($data); } public function softwares_delete() { $id=$this->input->post('id'); $table='softwares'; $where=array('id'=>$id); $this->model->delete($table,$where); return true; } public function projects_import() { print_r($_POST); $customer=$this->input->post('customer'); $description=$this->input->post('description'); $product=$this->input->post('product'); $application=$this->input->post('application'); $segment=$this->input->post('segment'); $allowedExtensions = ['csv', 'xls', 'xlsx', 'pdf', 'doc', 'docx', 'ppt', 'pptx', 'jpg', 'jpeg','rar']; print_r($_FILES); $file = $_FILES['document']; $file1 = $_FILES['report']; if (is_uploaded_file($file['tmp_name'])) { $sourcePath = $file['tmp_name']; $file_name = $file['name']; echo (is_uploaded_file($file['tmp_name'])); $fileExtension = strtolower(pathinfo($file_name, PATHINFO_EXTENSION)); if (!in_array($fileExtension, $allowedExtensions)) { echo json_encode(['message' => 'Invalid file type!']); return; } if (is_uploaded_file($file1['tmp_name'])) { $sourcePath = $file1['tmp_name']; $file_name = $file1['name']; $fileExtension = strtolower(pathinfo($file_name, PATHINFO_EXTENSION)); if (!in_array($fileExtension, $allowedExtensions)) { echo json_encode(['message' => 'Invalid file type!']); return; } } if(is_uploaded_file($_FILES['document']['tmp_name'])) { $document = $_FILES['document']['tmp_name']; $document = "uploads/projects_uploads/".$_FILES['document']['name']; move_uploaded_file($_FILES['document']['tmp_name'],$document); } else { $document=""; } if(is_uploaded_file($_FILES['report']['tmp_name'])) { $report = $_FILES['report']['tmp_name']; $report = "uploads/projects_uploads/".$_FILES['report']['name']; move_uploaded_file($_FILES['report']['tmp_name'],$report); } else { $report=""; } //$data=array('customer'=>$customer,'description'=>$description,'product'=>$product,'application'=>$application,'segment'=>$segment,'document'=>$document); $data=array('customer'=>$customer,'description'=>$description,'product'=>$product,'application'=>$application,'segment'=>$segment,'document'=>$document,'report'=>$report); $table='projects'; $this->model->insert($table,$data); print_r($this->db->last_query()); redirect('controller/projects_upload'); } else{ echo 'Not Uploaded'; } } public function projects_insert() { $table='projects'; $data=$this->model->get_all_data($table); echo json_encode($data); } public function projects_edit() { $id=$this->input->post('update_id'); $customer=$this->input->post('update_customer'); $description=$this->input->post('update_description'); $product=$this->input->post('update_product'); $application=$this->input->post('update_application'); $segment=$this->input->post('update_segment'); if(is_uploaded_file($_FILES['update_document']['tmp_name'])) { $document = $_FILES['update_document']['tmp_name']; $document = "uploads/projects_uploads/".$_FILES['update_document']['name']; move_uploaded_file($_FILES['update_document']['tmp_name'],$document); $data = array('document'=>$document); $table='projects'; $where=array('id'=>$id); $this->model->update_new($where,$table,$data); } if(is_uploaded_file($_FILES['update_report']['tmp_name'])) { $report = $_FILES['update_report']['tmp_name']; $report = "uploads/projects_uploads/".$_FILES['update_report']['name']; move_uploaded_file($_FILES['update_report']['tmp_name'],$report); $data = array('report'=>$report); $table='projects'; $where=array('id'=>$id); $this->model->update_new($where,$table,$data); } $data = array('customer'=>$customer,'description'=>$description,'product'=>$product,'application'=>$application,'segment'=>$segment); $table='projects'; $where=array('id'=>$id); $this->model->update_new($where,$table,$data); redirect('controller/projects_upload'); } public function projects_fetch() { $id=$this->input->post('id'); $table='projects'; $where=array('id'=>$id); $data=$this->model->get_where_row($table,$where); echo json_encode($data); } public function projects_delete() { $id=$this->input->post('id'); $table='projects'; $where=array('id'=>$id); $this->model->delete($table,$where); return true; } public function others_import() { $document_name=$this->input->post('document_name'); $allowedExtensions = ['jpg', 'jpeg', 'png', 'gif', 'doc', 'docx', 'xls', 'xlsx', 'ppt', 'pptx', 'zip','pdf']; if (is_uploaded_file($_FILES['document']['tmp_name'])) { $fileName = $_FILES['document']['name']; $fileExtension = strtolower(pathinfo($fileName, PATHINFO_EXTENSION)); $fileMimeType = mime_content_type($_FILES['document']['tmp_name']); } // Validate file extension if (!in_array($fileExtension, $allowedExtensions)) { echo json_encode(['result' => '0', 'message' => 'Invalid file type!']); return; } if(is_uploaded_file($_FILES['document']['tmp_name'])) { $document = $_FILES['document']['tmp_name']; $document = "uploads/others_uploads/".$_FILES['document']['name']; move_uploaded_file($_FILES['document']['tmp_name'],$document); } else { $document=""; } $data=array('document_name'=>$document_name,'document'=>$document); $table='others'; $this->model->insert($table,$data); redirect('controller/others_upload'); } public function others_insert() { $table='others'; $data=$this->model->get_all_data($table); echo json_encode($data); } public function others_fetch() { $id=$this->input->post('id'); $table='others'; $where=array('id'=>$id); $data=$this->model->get_where_row($table,$where); echo json_encode($data); } public function others_edit() { $id=$this->input->post('update_id'); $document_name=$this->input->post('update_document_name'); if(is_uploaded_file($_FILES['update_document']['tmp_name'])) { $document = $_FILES['update_document']['tmp_name']; $document = "uploads/others_uploads/".$_FILES['update_document']['name']; move_uploaded_file($_FILES['update_document']['tmp_name'],$document); $data=array('document_name'=>$document_name,'document'=>$document); } else { $data=array('document_name'=>$document_name); } $table='others'; $where=array('id'=>$id); $this->model->update_new($where,$table,$data); redirect('controller/others_upload'); } public function others_delete() { $id=$this->input->post('id'); $table='others'; $where=array('id'=>$id); $this->model->delete($table,$where); return true; } public function dashboard() { $sessionData = $this->decryptSessionData(); if (!isset($sessionData['id'])) { redirect('/'); return; } $this->load->view('new_dashboard'); } public function catalogue_details_subgrid() { $get = $this->uri->segment(3); $table='manuals'; $where=array('product_name'=>$get); $result=$this->model->fetch_where_data_asc($table,$where); echo json_encode($result); } //---------------------- home page images -----------------------// public function home_page_image_upload() { // $role=$this->session->userdata('role'); // $id=$this->session->userdata('id'); // Decrypt session data $sessionData = $this->decryptSessionData(); if (!isset($sessionData['id'], $sessionData['role'])) { redirect('/'); // Redirect if session is invalid return; } $id = $sessionData['id']; $role = $sessionData['role']; // Check user role for access if ($role != '3' && $role != '1') { redirect('/'); return; } if($id){ if($role ==3) { redirect('/'); return; $w=array('id'=>$id); $t='profile'; $data['details']=$this->model->get_where_row($t,$w); $table='product_details'; $where=array('status'=>0); $data['confirmed_data']=$this->model->fetch_where_data($table,$where); } else { $w=array('id'=>$id); $t='supervisor'; $data['details']=$this->model->get_where_row($t,$w); $table='product_details'; $where=array('status'=>0); $data['confirmed_data']=$this->model->fetch_where_data($table,$where); } $t='profile'; $data['abps']=$this->model->get_all_data($t); $table='po_info'; $data['time']=$this->model->get_time($table); $this->load->view('admin_home_images',$data); }else { redirect('/'); } } public function insert_home_images() { $table = "home_page_images"; $allowedExtensions = ['jpg', 'jpeg', 'png', 'gif']; $allowedMimeTypes = ['image/jpeg', 'image/png', 'image/gif']; $minFileSize = 50 * 1024; $file = $_FILES['file']; if (is_uploaded_file($file['tmp_name'])) { $sourcePath = $file['tmp_name']; $file_name = $file['name']; $fileExtension = strtolower(pathinfo($file_name, PATHINFO_EXTENSION)); $fileMimeType = mime_content_type($sourcePath); $fileSize = $file['size']; if (!in_array($fileExtension, $allowedExtensions)) { echo json_encode(['result' => '0', 'message' => 'Invalid file type!']); return; } if (!in_array($fileMimeType, $allowedMimeTypes)) { echo json_encode(['result' => '0', 'message' => 'Invalid file content!']); return; } if ($fileSize < $minFileSize) { echo json_encode(['result' => '0', 'message' => ' Minimum size is 50 KB.']); return; } $targetPath = "home_page_images/" . basename($file_name); if (move_uploaded_file($sourcePath, $targetPath)) { $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $created_at = $date->format('d-m-Y H:i:s'); // Prepare data for insertion $data = [ 'image' => $file_name, 'delete_status' => 'ACTIVE', 'created_at' => $created_at, 'approve_status' => 'NOT_APPROVED' ]; // Insert data into the database $result = $this->model->insert($table, $data); if ($result) { echo json_encode(['result' => '1', 'message' => 'Added!']); } else { echo json_encode(['result' => '0', 'message' => 'Database insertion failed!']); } } else { echo json_encode(['result' => '0', 'message' => 'File upload failed!']); } } else { echo json_encode(['result' => '0', 'message' => 'No file uploaded!']); } } public function get_added_home_images() { $table = "home_page_images"; $where = array('delete_status'=>'ACTIVE'); $result = $this->model->fetch_where_data($table,$where); echo json_encode($result); } public function delete_home_page_images() { $id = $this->input->post('id'); $where = array('id'=>$id); $data = array('delete_status'=>'INACTIVE'); $table = "home_page_images"; $result = $this->model->update($where,$table,$data); if($result > 0) { echo json_encode(array('result'=>'1','message'=>'Deleted!')); } else { echo json_encode(array('result'=>'0','message'=>'Something went wrong!')); } } public function approve_home_page_images() { $id = $this->input->post('id'); $where = array('id'=>$id); $data = array('approve_status'=>'APPROVED'); $table = "home_page_images"; $result = $this->model->update($where,$table,$data); if($result > 0) { echo json_encode(array('result'=>'1','message'=>'APPROVED!')); } else { echo json_encode(array('result'=>'0','message'=>'Something went wrong!')); } } //------------------------- Feedback ----------------------------------------// public function feedback() { $sessionData = $this->decryptSessionData(); if (!$sessionData || !isset($sessionData['id']) || $sessionData['role'] != '1' ) { redirect('controller/login'); } $id = $sessionData['id']; $role= $sessionData['role']; if($role == 3) { $w=array('id'=>$id); $t='profile'; $data['details']=$this->model->get_where_row($t,$w); $table='product_details'; $where=array('status'=>0); $data['confirmed_data']=$this->model->fetch_where_data($table,$where); } else { $w=array('id'=>$id); $t='supervisor'; $data['details']=$this->model->get_where_row($t,$w); $table='product_details'; $where=array('status'=>0); $data['confirmed_data']=$this->model->fetch_where_data($table,$where); } $t='profile'; $data['abps']=$this->model->get_all_data($t); $table='po_info'; $data['time']=$this->model->get_time($table); $this->load->view('feedback',$data); } public function insert_feedbacks() { $feedback = htmlspecialchars(strip_tags($this->input->post('feedback')), ENT_QUOTES, 'UTF-8'); $options = $this->input->post('options'); $sanitized_options = array_map(function($option) { return htmlspecialchars(strip_tags($option), ENT_QUOTES, 'UTF-8'); }, $options); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $created_at = $date->format('d-m-Y H:i:s'); // Prepare data for insertion $data = array( 'feedback' => $feedback, 'options' => json_encode($sanitized_options), 'created_at' => $created_at ); // Insert data into the database $table = "feedback"; $result = $this->model->insert($table, $data); if ($result) { echo json_encode(array('result' => '1', 'message' => 'Added!')); } else { echo json_encode(array('result' => '0', 'message' => 'Something went wrong!')); } } public function get_added_feedbacks() { $table = "feedback"; $where = array('delete_status'=>'ACTIVE'); $result = $this->model->fetch_where_data($table,$where); $array = array(); foreach($result as $res) { $data['id'] = $res->id; $data['feedback'] = $res->feedback; $data['options'] = json_decode($res->options); array_push($array,$data); } echo json_encode($array); } public function delete_feedback() { $id = $this->input->post('id'); $where = array('id'=>$id); $data = array('delete_status'=>'INACTIVE'); $table = "feedback"; $result = $this->model->update($where,$table,$data); if($result > 0) { echo json_encode(array('result'=>'1','message'=>'Deleted!')); } else { echo json_encode(array('result'=>'0','message'=>'Something went wrong!')); } } public function add_feedbacks() { $select_option = $this->input->post('select_option'); $feedback_id = $this->input->post('feedback_id'); $table = "feedback_count"; $where = array('feedback_id'=>$feedback_id,'selected_option'=>$select_option,'delete_status'=>'ACTIVE'); $details = $this->model->fetch_where_data($table,$where); if(empty($details)) { $data = array('feedback_id'=>$feedback_id,'selected_option'=>$select_option,'count'=>'1','delete_status'=>'ACTIVE'); $this->model->insert($table,$data); } else { $count = 0; foreach($details as $dets) { $count = $dets->count; $count++; } $where = array('feedback_id'=>$feedback_id,'selected_option'=>$select_option,'delete_status'=>'ACTIVE'); $data = array('count'=>$count); $this->model->update($where,$table,$data); } } public function contact() { $this->load->view('contact'); } public function appreciation_letter_view() { $sessionData = $this->decryptSessionData(); if (!$sessionData || !isset($sessionData['id']) || $sessionData['role'] != '1') { redirect('controller/login'); } $t="appreciation_letter"; $data['time']=$this->model->get_time($t); $this->load->view('appreciation_letter_view',$data); } public function application_notes_view() { $sessionData = $this->decryptSessionData(); if (!$sessionData || !isset($sessionData['id']) || $sessionData['role'] != '1') { redirect('controller/login'); } $t='application_notes'; $data['time']=$this->model->get_time($t); $this->load->view('application_notes_view',$data); } public function technical_notes_view() { $sessionData = $this->decryptSessionData(); if (!$sessionData || !isset($sessionData['id']) || $sessionData['role'] != '1') { redirect('controller/login'); } $t='technical_notes'; $data['time']=$this->model->get_time($t); $this->load->view('technical_notes_view',$data); } public function training_presentation_view() { $sessionData = $this->decryptSessionData(); if (!$sessionData || !isset($sessionData['id']) || $sessionData['role'] != '1') { redirect('controller/login'); } $t='training_presentation'; $data['time']=$this->model->get_time($t); $this->load->view('training_presentation_view',$data); } public function software_view() { $sessionData = $this->decryptSessionData(); if (!$sessionData || !isset($sessionData['id']) || $sessionData['role'] != '1') { redirect('controller/login'); } $t='softwares'; $data['time']=$this->model->get_time($t); $this->load->view('software_view',$data); } public function projects_view() { $sessionData = $this->decryptSessionData(); if (!$sessionData || !isset($sessionData['id']) || $sessionData['role'] != '1') { redirect('controller/login'); } $t='projects'; $data['time']=$this->model->get_time($t); $this->load->view('projects_view',$data); } public function others_view() { $sessionData = $this->decryptSessionData(); if (!$sessionData || !isset($sessionData['id']) || $sessionData['role'] != '1') { redirect('controller/login'); } $t='others'; $data['time']=$this->model->get_time($t); $this->load->view('others_view',$data); } public function get_appreciation_letter_view() { $table='appreciation_letter'; $data=$this->model->get_all_data($table); echo json_encode($data); } public function get_application_notes_view() { $table='application_notes'; $data=$this->model->get_all_data($table); echo json_encode($data); } public function get_technical_notes_view() { $table='technical_notes'; $data=$this->model->get_all_data($table); echo json_encode($data); } public function get_training_presentation_view() { $table='training_presentation'; $data=$this->model->get_all_data($table); echo json_encode($data); } public function get_software_view() { $table='softwares'; $data=$this->model->get_all_data($table); echo json_encode($data); } public function get_projects_view() { $table='projects'; $data=$this->model->get_all_data($table); echo json_encode($data); } public function get_others_view() { $table='others'; $data=$this->model->get_all_data($table); echo json_encode($data); } public function update_access_status() { $id = $this->input->post('id'); $access_status = $this->input->post('access_status'); $table = "profile"; $where = array('id'=>$id); $data = array('access_status'=>$access_status); $result = $this->model->update($where,$table,$data); if($this->db->affected_rows() > 0) { echo json_encode(array('result'=>'1','message'=>'Selected!')); } else { echo json_encode(array('result'=>'0','message'=>'Something went wrong!')); } } public function update_software_access() { $software = $this->input->post('software'); $id = $this->input->post('profile_id'); $selected_software = json_encode($software); $where = array('id'=>$id); $data = array('software_access_status'=>$selected_software); $table = 'profile'; $result = $this->model->update($where,$table,$data); if($this->db->affected_rows() > 0) { echo json_encode(array('result'=>'1','message'=>'Added!')); } else { echo json_encode(array('result'=>'0','message'=>'Something went wrong!')); } } /*public function update_access() { $downloads = $this->input->post('downloads'); if($downloads=="") { $downloads="NO"; } else { $downloads="YES"; } $information = $this->input->post('information'); if($information=="") { $information="NO"; } else { $information="YES"; } $financials = $this->input->post('financials'); if($financials=="") { $financials="NO"; } else { $financials="YES"; } $po_generate = $this->input->post('po_generate'); if($po_generate=="") { $po_generate="NO"; } else { $po_generate="YES"; } $softwares = $this->input->post('softwares'); if($softwares=="") { $softwares="NO"; } else { $softwares="YES"; } $software_selected = $this->input->post('software'); if(!empty($software_selected)) { $sw = json_encode($software_selected); } else { $sw = ""; } $id = $this->input->post('profile_id'); $where = array('id'=>$id); $data = array('downloads_access_status'=>$downloads,'information_access_status'=>$information,'financials_access_status'=>$financials,'po_generate_access_status'=>$po_generate,'access_status'=>$softwares,'software_access_status'=>$sw); $table = 'profile'; $result = $this->model->update($where,$table,$data); if($this->db->affected_rows() > 0) { echo json_encode(array('result'=>'1','message'=>'Access is Given')); } else { echo json_encode(array('result'=>'0','message'=>'Something went wrong!')); } }*/ public function update_access() { $downloads = $this->input->post('downloads'); if($downloads=="") { $downloads="NO"; } else { $downloads="YES"; } $technical_manuals = $this->input->post('technical_manuals'); if($technical_manuals=="") { $technical_manuals="NO"; } else { $technical_manuals="YES"; } $case_notes = $this->input->post('case_notes'); if($case_notes=="") { $case_notes="NO"; } else { $case_notes="YES"; } $appreciation_letters = $this->input->post('appreciation_letters'); if($appreciation_letters=="") { $appreciation_letters="NO"; } else { $appreciation_letters="YES"; } $application_notes = $this->input->post('application_notes'); if($application_notes=="") { $application_notes="NO"; } else { $application_notes="YES"; } $technical_notes = $this->input->post('technical_notes'); if($technical_notes=="") { $technical_notes="NO"; } else { $technical_notes="YES"; } $training_presentations = $this->input->post('training_presentations'); if($training_presentations=="") { $training_presentations="NO"; } else { $training_presentations="YES"; } $softwares = $this->input->post('softwares'); if($softwares=="") { $softwares="NO"; } else { $softwares="YES"; } $software_selected = $this->input->post('software'); if(!empty($software_selected)) { $sw = json_encode($software_selected); } else { $sw = ""; } $projects = $this->input->post('project'); if($projects=="") { $projects="NO"; } else { $projects="YES"; } $project_selected = $this->input->post('projects'); if(!empty($project_selected)) { $ps = json_encode($project_selected); } else { $ps = ""; } $others = $this->input->post('other'); if($others=="") { $others="NO"; } else { $others="YES"; } $others_selected = $this->input->post('others'); if(!empty($others_selected)) { $os = json_encode($others_selected); } else { $os = ""; } $information = $this->input->post('information'); if($information=="") { $information="NO"; } else { $information="YES"; } $financials = $this->input->post('financials'); if($financials=="") { $financials="NO"; } else { $financials="YES"; } $po_generate = $this->input->post('po_generate'); if($po_generate=="") { $po_generate="NO"; } else { $po_generate="YES"; } $id = $this->input->post('profile_id'); $where = array('id'=>$id); $data = array('downloads_access_status'=>$downloads, 'technical_manuals_access'=>$technical_manuals, 'case_notes_access'=>$case_notes, 'appreciation_letters_access'=>$appreciation_letters, 'application_notes_access'=>$application_notes, 'technical_notes_access'=>$technical_notes , 'training_presentations_access'=>$training_presentations, 'projects_access'=>$projects , 'in_projects_access'=>$ps, 'others_access'=>$others , 'in_others_access'=>$os, 'access_status'=>$softwares, 'software_access_status'=>$sw, 'information_access_status'=>$information, 'financials_access_status'=>$financials, 'po_generate_access_status'=>$po_generate ); $table = 'profile'; $result = $this->model->update($where,$table,$data); if($this->db->affected_rows() > 0) { echo json_encode(array('result'=>'1','message'=>'Access is Given')); } else { echo json_encode(array('result'=>'0','message'=>'Something went wrong!')); } } public function upload_attachment() { if(is_uploaded_file($_FILES['attachment']['tmp_name'])) { $sourcePath = $_FILES['attachment']['tmp_name']; $targetPath = "uploads/mannual_uploads/".$_FILES['attachment']['name']; move_uploaded_file($_FILES['attachment']['tmp_name'],$targetPath); } } public function get_selected_access() { $id = $this->input->post('id'); $where = array('id'=>$id); $table = "profile"; $result = $this->model->get_where_selected_access_row($id); if($result) { echo json_encode(array('result'=>1,'access'=>$result)); } else { echo json_encode(array('result'=>0,'access'=>'Something went wrong')); } } public function regional_add_product() { // $role=$this->session->userdata('role'); // $id=$this->session->userdata('id'); // Decrypt session data $sessionData = $this->decryptSessionData(); if (!isset($sessionData['id'], $sessionData['role'])) { redirect('/'); // Redirect if session is invalid return; } $id = $sessionData['id']; $role = $sessionData['role']; if ($role != '3' && $role != '8') { redirect('/'); return; } if($role==3) { $w=array('id'=>$id); $t='profile'; $data['details']=$this->model->get_where_row($t,$w); } else { $w=array('id'=>$id); $t='supervisor'; $data['details']=$this->model->get_where_row($t,$w); } $this->load->view('regional_add_product_details',$data); } public function reg_product_list() { $sessionData = $this->decryptSessionData(); if (!$sessionData || !isset($sessionData['id']) || $sessionData['role'] != '8') { redirect('controller/login'); } $table='product_details'; $where=array('status'=>0); $data['confirmed_data']=$this->model->fetch_where_data($table,$where); $this->load->view('reg_product_list',$data); } public function reg_edit_product() { $uri = $_SERVER["REQUEST_URI"]; $id = substr($uri, strpos($uri, "=") + 1); $w=array('id'=>$id); $t='product_details'; $data['products']=$this->model->get_where_row($t,$w); // $role=$this->session->userdata('role'); // $id=$this->session->userdata('id'); $sessionData = $this->decryptSessionData(); $id = $sessionData['id']; $role = $sessionData['role']; if($role==3) { $w=array('id'=>$id); $t='profile'; $data['details']=$this->model->get_where_row($t,$w); } else { $w=array('id'=>$id); $t='supervisor'; $data['details']=$this->model->get_where_row($t,$w); } $this->load->view('reg_edit_product',$data); } ////////////////////////// public function reg_appreciation_letter_view() { $sessionData = $this->decryptSessionData(); if (!$sessionData || !isset($sessionData['id']) || $sessionData['role'] != '8') { redirect('controller/login'); } $t="appreciation_letter"; $data['time']=$this->model->get_time($t); $this->load->view('reg_appreciation_letter_view',$data); } public function reg_application_notes_view() { $sessionData = $this->decryptSessionData(); if (!$sessionData || !isset($sessionData['id']) || $sessionData['role'] != '8') { redirect('controller/login'); } $t='application_notes'; $data['time']=$this->model->get_time($t); $this->load->view('reg_application_notes_view',$data); } public function reg_technical_notes_view() { $sessionData = $this->decryptSessionData(); if (!$sessionData || !isset($sessionData['id']) || $sessionData['role'] != '8') { redirect('controller/login'); } $t='technical_notes'; $data['time']=$this->model->get_time($t); $this->load->view('reg_technical_notes_view',$data); } public function reg_training_presentation_view() { $sessionData = $this->decryptSessionData(); if (!$sessionData || !isset($sessionData['id']) || $sessionData['role'] != '8') { redirect('controller/login'); } $t='training_presentation'; $data['time']=$this->model->get_time($t); $this->load->view('reg_training_presentation_view',$data); } public function reg_software_view() { $sessionData = $this->decryptSessionData(); if (!$sessionData || !isset($sessionData['id']) || $sessionData['role'] != '8') { redirect('controller/login'); } $t='softwares'; $data['time']=$this->model->get_time($t); $this->load->view('reg_software_view',$data); } public function reg_projects_view() { $sessionData = $this->decryptSessionData(); if (!$sessionData || !isset($sessionData['id']) || $sessionData['role'] != '8') { redirect('controller/login'); } $t='projects'; $data['time']=$this->model->get_time($t); $this->load->view('reg_projects_view',$data); } public function reg_others_view() { $sessionData = $this->decryptSessionData(); if (!$sessionData || !isset($sessionData['id']) || $sessionData['role'] != '8') { redirect('controller/login'); } $t='others'; $data['time']=$this->model->get_time($t); $this->load->view('reg_others_view',$data); } } ?>