EVOLUTION-NINJA
Edit File: controller (BKP on 201903060).php
<?php defined('BASEPATH') OR exit('No direct script access allowed'); class controller extends CI_Controller { function __construct() { parent:: __construct(); $this->load->model('model'); $this->output->set_header('Last-Modified:'.gmdate('D, d M Y H:i:s').'GMT'); $this->output->set_header('Cache-Control: no-store, no-cache, must-revalidate'); $this->output->set_header('Cache-Control: post-check=0, pre-check=0',false); $this->output->set_header('Pragma: no-cache'); } public function index() { $this->load->view('login'); } public function admin() { $w=array('id'=>1); $t='supervisor'; $data['details']=$this->model->get_where_row($t,$w); $this->load->view('admin_index',$data); } public function login() { $table='profile'; $email=$this->input->post('email'); $password=$this->input->post('password'); $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); if(count($user)>0) { $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); $this->session->set_userdata($session); $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); $this->load->view('news',$data); } elseif(count($user2)>0) { 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(count($user1)>0) { if($user1->role==1) { $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); $this->session->set_userdata($session); $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) { $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); $this->session->set_userdata($session); $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('region_news_view',$data); } else { $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); $this->session->set_userdata($session); $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']); //die(); $this->load->view('news',$data); } } else { redirect('controller/index?status=invalid'); } } public function product() { $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.','.'<br/><br/>'."Your Temporary Password is"." ".$password.'<br/><br/>'."Thank you".'<br/>'."Myvote Team"; $this->email->from('yindabpportal@yaskawa.in', 'Yaskawa'); $this->email->to($checkingemail->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'); } 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"." ".$checkingemail->first_name.','.'<br/><br/>'."Your Temporary Password is"." ".$password.'<br/><br/>'."Thank you".'<br/>'."Myvote Team"; $this->email->from('yindabpportal@yaskawa.in', 'Yaskawa'); $this->email->to($checkingemail->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('conroller/index');} //$id=$this->input->post('user_id'); $new=$this->input->post('new'); $userid=$this->session->userdata('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'); if($role==3) { $w=array('id'=>$id); $t='profile'; $data['details']=$this->model->get_where_row($t,$w); $this->load->view('profile',$data); } else { $w=array('id'=>$id); $t='supervisor'; $data['details']=$this->model->get_where_row($t,$w); $this->load->view('supervisor_profile',$data); } } 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'); $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'); } public function profile_update() { $id=$this->session->userdata('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() { $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="stock_info"; $data['time']=$this->model->get_time($tab); $this->load->view('stock_updates',$data); } public function po_acknowledgemets() { $role=$this->session->userdata('role'); $id=$this->session->userdata('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('po_acknowledgemets',$data); } 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'); $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="fin_outstanding"; $data['time']=$this->model->get_time($tab); $this->load->view('outstanding_statement',$data); } public function overdue_statement() { $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="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'); 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('drive_catalogues',$data); } 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/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); $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'); 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('case_stories',$data); } public function c_forms() { $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="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'); 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',$data); } 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($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->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 news_view() { $table='news'; $data['news']=$this->model->get_all_data($table); $this->load->view('admin_news_view',$data); } public function news_upload() { $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); } $table='news'; $data['news']=$this->model->get_all_data($table); $this->load->view('news_upload',$data); } public function news_insert() { $title=$this->input->post('title'); $desc=$this->input->post('desc'); $url=$this->input->post('url'); $role=$this->session->userdata('role'); $id=$this->session->userdata('id'); if($_FILES) { $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); } 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'); $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='po_info'; $data['time']=$this->model->get_time($table); $this->load->view('po_import',$data); } public function inventory_import() { $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); } $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_name'=>$document_name,'document'=>$document); $table='case_stories'; $this->model->insert($table,$data); redirect('controller/case_stories_upload'); } public function supervisor_view() { $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() { $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'); //$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('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('yindabpportal@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 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); $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('yindabpportal@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('yindabpportal@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() { $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); $tab="supervisor"; $data['time']=$this->model->get_time($tab); $this->load->view('abp_view',$data); } public function reg_abp_view() { $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); $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('yindabpportal@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('yindabpportal@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('yindabpportal@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() { $t="stock_info"; $data['time']=$this->model->get_time($t); $this->load->view('stock_updates_view',$data); } public function reg_stock_updates_view() { $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() { $t="po_info"; $data['time']=$this->model->get_time($t); $this->load->view('po_view',$data); } public function reg_po_view() { $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'); /*if ($_REQUEST['_search'] == 'false') { $table='po_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']:'po_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']:'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($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); $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('yindabpportal@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('yindabpportal@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('yindabpportal@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() { 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); $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('yindabpportal@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('yindabpportal@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('yindabpportal@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('yindabpportal@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'); 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('outstanding_statements_display',$data); } public function overdue_statements_display() { $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='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('overdue_statements_display',$data); } public function c_forms_display() { $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='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('c_forms_display',$data); } public function drive_mannual_upload() { $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); $this->load->view('driver_mannual_upload',$data); } public function case_stories_upload() { $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="case_stories"; $data['time']=$this->model->get_time($tab); $this->load->view('case_stories_upload',$data); } public function outstanding_view() { $t="fin_outstanding"; $data['time']=$this->model->get_time($t); $this->load->view('outstanding_statement_view',$data); } public function reg_outstanding_view() { $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']: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_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('yindabpportal@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('yindabpportal@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('yindabpportal@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() { $t="fin_overdue"; $data['time']=$this->model->get_time($t); $this->load->view('overdue_statement_view',$data); } public function reg_overdue_view() { $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']: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_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('yindabpportal@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('yindabpportal@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('yindabpportal@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() { $t="fin_cforms"; $data['time']=$this->model->get_time($t); $this->load->view('c_forms_view',$data); } public function reg_cform_view() { $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('yindabpportal@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('yindabpportal@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('yindabpportal@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() { $t="manuals"; $data['time']=$this->model->get_time($t); $this->load->view('drive_catalogues_view',$data); } public function reg_drive_catalogues_view() { $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); $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='manuals'; $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->product_name,$row->category,$row->document_type,$row->document_sub_type,$row->option_card_name,$row->attachment); $i++; } echo json_encode($responce); } 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('id'); $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'); $attachment=$this->input->post('attachment'); $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'; $where=array('id'=>$id); $this->model->update_new($where,$table,$data); return true; } 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() { $t="case_stories"; $data['time']=$this->model->get_time($t); $this->load->view('case_stories_view',$data); } public function reg_case_stories_view() { $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); $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($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->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_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('case_id'); //$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'; $where=array('case_id'=>$id); $this->model->update_new($where,$table,$data); } public function case_stories_delete() { $id=$this->input->post('case_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() { $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() { $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() { $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() { $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'); 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'); //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'); $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'); $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'); $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() { $this->session->sess_destroy(); redirect('controller/index'); } public function region_view() { $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('yindabpportal@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('yindabpportal@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() { $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'); 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('purchase_order_grid',$data); } public function generated_product_wish_list() { $role=$this->session->userdata('role'); $id=$this->session->userdata('id'); $add='address'; $whe=array('abp_id'=>$id); $data['address']=$this->model->fetch_where_data($add,$whe); if($role==3) { $w=array('id'=>$id); $t='profile'; $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; } 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('po_generate',$data); } public function address_details() { $add_id=$this->input->post('id'); $role=$this->session->userdata('role'); $id=$this->session->userdata('id'); $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() { $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() { $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'); 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'); $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('yindabpportal@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'); 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('purchase_order',$data); } public function add_new_po() { $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_new_po',$data); } 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'); 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('po_list',$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); } } public function insert_product() { $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'); 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('upload_signed_po',$data); } public function upload_special_po() { $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); $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('upload_special_po',$data); } 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('yindabpportal@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 special_po() { $id=$this->session->userdata('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('yindabpportal@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'); 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('signed_po_list',$data); } public function add_shipaddress_details() { $id=$this->session->userdata('id'); //$where=array('abp_id'=>$id); $table='address'; $detail=$this->model->get_all_data($table); echo json_encode($detail); } public function add_shipaddress() { $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'); $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); } $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'); $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); } 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'); $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'); 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 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'); 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); } 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'); 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); } 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() { $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() { $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); } redirect('controller/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'); 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); } public function normal_po_details() { $role=$this->session->userdata('role'); $id=$this->session->userdata('id'); $user_dept = $this->session->userdata('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() { $role=$this->session->userdata('role'); $id=$this->session->userdata('id'); $user_dept=$this->session->userdata('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'); 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'); 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('yindabpportal@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('yindabpportal@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'); $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() { $this->load->view('robotics_form'); } public function robotics_list() { $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() { $this->load->view('robotics_user_list'); } public function upload_po_pdf() { $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('yindabpportal@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'); 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'); 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'); // $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'); 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'); 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'); 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('yindabpportal@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('yindabpportal@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')); } } } ?>