whoami7 - Manager
:
/
proc
/
self
/
root
/
home
/
papecmvm
/
www
/
application
/
controllers
/
webapp
/
Upload File:
files >> //proc/self/root/home/papecmvm/www/application/controllers/webapp/People_07072023.php
<?php use Aws\S3\S3Client; use Aws\S3\Exception\S3Exception; use Aws\CommandPool; if ( ! defined('BASEPATH')) exit('No direct script access allowed'); require_once APPPATH."third_party/aws/autoload.php"; class People extends CI_Controller { function __construct() { parent::__construct(); $userdata = $this->session->userdata('reg_info'); if(!isset($userdata)) { $base = base_url(); redirect($base); } $this->load->model('app', "model"); $CI = & get_instance(); $this->db = $CI->load->database('default', TRUE); $this->db2 = $CI->load->database('db2', TRUE); //aws $bucketname = 'paperpushbucket'; $key = 'AKIAJJ72VRLHXBD272YQ'; $secret = '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'; $this->s3 = S3Client::factory( array( 'credentials' => array( 'key' => $key, 'secret' => $secret ), 'version' => 'latest', 'region' => 'ap-south-1' ) ); } public function office($offset = '0') { $where = array('type!=' => 'customer'); $cnt_data['data']=$this->model->DetailData('tbl_registration', $where); $cnt=count($cnt_data['data']); $this->load->library('pagination'); $config['base_url'] = base_url().'webapp/people/office'; $config['total_rows'] = $cnt; $config['per_page'] = 20; $config['full_tag_open'] = '<div class="pagination"><ul class="list-inline">'; $config['full_tag_close'] = '</ul></div>'; $config['first_link'] = '« First'; $config['first_tag_open'] = '<li class="prev page">'; $config['first_tag_close'] = '</li>'; $config['last_link'] = 'Last »'; $config['last_tag_open'] = '<li class="next page">'; $config['last_tag_close'] = '</li>'; $config['next_link'] = 'Next →'; $config['next_tag_open'] = '<li class="next page">'; $config['next_tag_close'] = '</li>'; $config['prev_link'] = '← Previous'; $config['prev_tag_open'] = '<li class="prev page">'; $config['prev_tag_close'] = '</li>'; $config['cur_tag_open'] = '<li class="active"><a href="">'; $config['cur_tag_close'] = '</a></li>'; $config['num_tag_open'] = '<li class="page">'; $config['num_tag_close'] = '</li>'; $this->pagination->initialize($config); $userdata['data'] = $this->model->get_pagination_where('tbl_registration', $config['per_page'], $offset, $where); $userdata['type'] = 'office'; $this->load->view("webapp/office",$userdata); } public function customer($offset = 0) { $where = array('type' => 'customer'); $cnt_data['data']=$this->model->DetailData('tbl_registration', $where); $cnt=count($cnt_data['data']); $this->load->library('pagination'); $config['base_url'] = base_url().'webapp/people/customer'; $config['total_rows'] = $cnt; $config['per_page'] = 20; $config['full_tag_open'] = '<div class="pagination"><ul class="list-inline">'; $config['full_tag_close'] = '</ul></div>'; $config['first_link'] = '« First'; $config['first_tag_open'] = '<li class="prev page">'; $config['first_tag_close'] = '</li>'; $config['last_link'] = 'Last »'; $config['last_tag_open'] = '<li class="next page">'; $config['last_tag_close'] = '</li>'; $config['next_link'] = 'Next →'; $config['next_tag_open'] = '<li class="next page">'; $config['next_tag_close'] = '</li>'; $config['prev_link'] = '← Previous'; $config['prev_tag_open'] = '<li class="prev page">'; $config['prev_tag_close'] = '</li>'; $config['cur_tag_open'] = '<li class="active"><a href="">'; $config['cur_tag_close'] = '</a></li>'; $config['num_tag_open'] = '<li class="page">'; $config['num_tag_close'] = '</li>'; $this->pagination->initialize($config); $userdata['data'] = $this->model->get_pagination_where('tbl_registration', $config['per_page'], $offset, $where); $userdata['type'] = 'customer'; $userdata['customer'] = 'Customer'; $this->load->view("webapp/office",$userdata); } public function view($encrypted_id) { $id = $this->model->decryptdata($encrypted_id); $where=array('rid' => $id); $userdata['data'] = $this->model->DetailData('tbl_registration', $where); $cur_year = date('Y'); $this->db2->order_by('id', 'DESC'); $this->db2->limit(12); $userdata['log'] = $this->db2->get_where('tbl_cust_log', $where)->result_array(); $where2=array('type' => 'office_user'); $userdata['office_user'] = $this->model->DetailData('tbl_registration', $where2); //$where3=array('afrom' => $id); $userdata['access_folder'] = $this->model->getAccess($id); $userdata['encrypted_id'] = $encrypted_id; //echo "<pre>"; print_r($userdata['access_folder']); die; $where = array('code' => $userdata['data'][0]['folder_code']); $userdata['struct'] = $this->db2->get_where('cust_upload_structure', $where)->result_array(); $userdata['code'] = $userdata['data'][0]['folder_code']; $where_current = array('code' => $userdata['data'][0]['folder_code'], 'year'=>$cur_year); $userdata['current_ser'] = $this->db2->get_where('cust_upload_structure', $where_current)->row_array(); //echo "<pre>"; print_r($userdata['struct']); die; $this->db2->select('*'); $this->db2->from('cust_upload_notify'); $this->db2->where('n_from', $id); $this->db2->limit(10); $userdata['logs'] = $this->db2->get()->result_array(); //echo "<pre>"; print_r($userdata); die; $this->load->view("webapp/view_people",$userdata); } public function add_user(){ if($this->input->post('save')=='save'){ $email = $this->input->post('email'); $username = $this->input->post('username'); $where = array('username' => $username, 'type!=' => 'customer'); $chk_username = $this->model->DetailData('tbl_registration', $where); $cnt = count($chk_username); if($cnt == '0'){ $pass = $this->input->post('phone'); $password = md5($pass); $config['upload_path'] = './webapp/profile/'; $config['allowed_types']= 'gif|jpg|png|jpeg'; $config['encrypt_name'] = TRUE; $this->upload->initialize($config); $this->load->library('upload', $config); $this->upload->do_upload('photo'); $data = $this->upload->data(); $photo = $data['file_name']; $insertdata=array('pass'=>$password, 'name'=>$this->input->post('name'), 'email'=>$email, 'username'=>$username, 'mobile'=>$this->input->post('phone'), 'photo'=>$photo, 'type'=>$this->input->post('type'), 'reg_from'=>'system', 'status'=>'1' ); $this->model->insertData('tbl_registration',$insertdata); $this->session->set_flashdata('msg', ' <div class="alert alert-success alert-dismissible" role="alert"> <button type="button" class="close" data-dismiss="alert" aria-label="Close"> <span aria-hidden="true">×</span></button> <strong>Success!</strong> User has been added. </div>'); redirect('webapp/people/office'); }else{ $this->session->set_flashdata('msg', ' <div class="alert alert-danger alert-dismissible" role="alert"> <button type="button" class="close" data-dismiss="alert" aria-label="Close"> <span aria-hidden="true">×</span></button> <strong>Error!</strong> User Name is already available. </div>'); redirect('webapp/people/office'); } }else{ $this->load->view('webapp/add_user'); } } public function search(){ $search = $this->input->post('src'); $this->db2->select('*'); $this->db2->like('name', $search); $result = $this->db2->get('tbl_registration')->result_array(); foreach ($result as $key => $value) { $encrypted_id = $this->model->encryptdata($value['rid']); if($value['type'] == 'team_leader'){ $label = "Team Leader"; }elseif($value['type'] == 'office_user'){ $label = "Office User"; }elseif($value['type'] == 'admin'){ $label = "Admin"; } if($value['status'] == '1'){ $es = '<span class="badge bg-green">Verified</span>'; }else{ $es = '<span class="badge bg-red">pending</span>'; } echo '<tr> <td class="text-capitalize"><a href="'.base_url()."webapp/people/view/".$encrypted_id.'">'.$value["name"].'</a><br><span class="text-danger">'.$label.'</span></td> <td>'.$value["email"].'</td> <td>'.$value["mobile"].'</td> <td>'.$es.'</td> <td>'; echo '<a href="'.base_url().'webapp/people/updateUser/'.$encrypted_id.'" class="btn btn-primary"><i class="fa fa-pencil-square-o"></i></a> '; if($value['type'] != 'admin'){ if($value['status'] == '1'){ echo '<a href="'.base_url().'webapp/people/deactive/'.$encrypted_id.'" class="btn btn-danger" data-toggle="tooltip" data-placement="top" title="Click here to deactive" aria-hidden="true"><i class="fa fa-times" aria-hidden="true"></i></a>'; }else{ echo '<a href="'.base_url().'webapp/people/active/'.$encrypted_id.'" class="btn btn-success" data-toggle="tooltip" data-placement="top" title="Click here to active" aria-hidden="true"><i class="fa fa-check" aria-hidden="true"></i></a>'; } } '</td> </tr>'; } } public function json_office_rec($offset = '0') { $where = array('type!=' => 'customer'); $cnt_data['data']=$this->model->DetailData('tbl_registration', $where); $cnt=count($cnt_data['data']); $this->load->library('pagination'); $config['base_url'] = base_url().'webapp/people/json_office_rec'; $config['total_rows'] = $cnt; $config['per_page'] = 20; $config['full_tag_open'] = '<div class="pagination"><ul class="list-inline">'; $config['full_tag_close'] = '</ul></div>'; $config['first_link'] = '« First'; $config['first_tag_open'] = '<li class="prev page">'; $config['first_tag_close'] = '</li>'; $config['last_link'] = 'Last »'; $config['last_tag_open'] = '<li class="next page">'; $config['last_tag_close'] = '</li>'; $config['next_link'] = 'Next →'; $config['next_tag_open'] = '<li class="next page">'; $config['next_tag_close'] = '</li>'; $config['prev_link'] = '← Previous'; $config['prev_tag_open'] = '<li class="prev page">'; $config['prev_tag_close'] = '</li>'; $config['cur_tag_open'] = '<li class="active"><a href="">'; $config['cur_tag_close'] = '</a></li>'; $config['num_tag_open'] = '<li class="page">'; $config['num_tag_close'] = '</li>'; $this->pagination->initialize($config); $result = $this->model->get_pagination_where('tbl_registration', $config['per_page'], $offset, $where); foreach ($result as $key => $value) { $encrypted_id = $this->model->encryptdata($value['rid']); if($value['type'] == 'team_leader'){ $label = "Team Leader"; }elseif($value['type'] == 'office_user'){ $label = "Office User"; }elseif($value['type'] == 'admin'){ $label = "Admin"; } echo '<tr> <td class="text-capitalize"><a href="'.base_url()."webapp/people/view/".$encrypted_id.'">'.$value["name"].'</a><br><span class="text-danger">'.$label.'</span></td> <td>'.$value["email"].'</td> <td>'.$value["mobile"].'</td> <td>'; echo '<a href="'.base_url().'webapp/people/updateUser/'.$encrypted_id.'" class="btn btn-primary"><i class="fa fa-pencil-square-o"></i></a> '; if($value['type'] != 'admin'){ if($value['status'] == '1'){ echo '<a href="'.base_url().'webapp/people/deactive/'.$encrypted_id.'" class="btn btn-danger" data-toggle="tooltip" data-placement="top" title="Click here to deactive" aria-hidden="true"><i class="fa fa-times" aria-hidden="true"></i></a>'; }else{ echo '<a href="'.base_url().'webapp/people/active/'.$encrypted_id.'" class="btn btn-success" data-toggle="tooltip" data-placement="top" title="Click here to active" aria-hidden="true"><i class="fa fa-check" aria-hidden="true"></i></a>'; } } '</td> </tr>'; } } public function search_cust(){ $search = $this->input->post('src'); $this->db2->select('*'); $this->db2->where('type', 'customer'); $this->db2->like('name', $search); $result = $this->db2->get('tbl_registration')->result_array(); foreach ($result as $key => $value) { $encrypted_id = $this->model->encryptdata($value['rid']); if($value['status'] == '1'){ $email_status = '<span class="badge bg-green">Verified</span>'; }else{ $email_status = '<span class="badge bg-red">Pending</span>'; } if($value['payment_status'] == '1'){ $payment_status = '<span class="badge bg-green">Done</span>'; }else{ $payment_status = '<span class="badge bg-red">Pending</span>'; } echo '<tr> <td class="text-capitalize"><a href="'.base_url()."webapp/people/view/".$encrypted_id.'">'.$value["name"].'</a></td> <td>'.$value["email"].'</td> <td>'.$value["mobile"].'</td> <td>'.$email_status.'</td> <td>'.$payment_status.'</td> <td>'; echo '<a href="'.base_url().'webapp/people/updateUser/'.$encrypted_id.'" class="btn btn-primary"><i class="fa fa-pencil-square-o"></i></a> '; if($value['type'] != 'admin'){ if($value['payment_status'] == '1'){ echo '<a href="'.base_url().'webapp/people/deactive/'.$encrypted_id.'" class="btn btn-danger" data-toggle="tooltip" data-placement="top" title="Click here to deactive" aria-hidden="true"><i class="fa fa-times" aria-hidden="true"></i></a>'; }else{ echo '<a href="'.base_url().'webapp/people/active/'.$encrypted_id.'" class="btn btn-success" data-toggle="tooltip" data-placement="top" title="Click here to active" aria-hidden="true"><i class="fa fa-check" aria-hidden="true"></i></a>'; } } '</td> </tr>'; } } public function json_cust_rec($offset = '0') { $where = array('type' => 'customer'); $cnt_data['data']=$this->model->DetailData('tbl_registration', $where); $cnt=count($cnt_data['data']); $this->load->library('pagination'); $config['base_url'] = base_url().'webapp/people/json_cust_rec'; $config['total_rows'] = $cnt; $config['per_page'] = 20; $config['full_tag_open'] = '<div class="pagination"><ul class="list-inline">'; $config['full_tag_close'] = '</ul></div>'; $config['first_link'] = '« First'; $config['first_tag_open'] = '<li class="prev page">'; $config['first_tag_close'] = '</li>'; $config['last_link'] = 'Last »'; $config['last_tag_open'] = '<li class="next page">'; $config['last_tag_close'] = '</li>'; $config['next_link'] = 'Next →'; $config['next_tag_open'] = '<li class="next page">'; $config['next_tag_close'] = '</li>'; $config['prev_link'] = '← Previous'; $config['prev_tag_open'] = '<li class="prev page">'; $config['prev_tag_close'] = '</li>'; $config['cur_tag_open'] = '<li class="active"><a href="">'; $config['cur_tag_close'] = '</a></li>'; $config['num_tag_open'] = '<li class="page">'; $config['num_tag_close'] = '</li>'; $this->pagination->initialize($config); $result = $this->model->get_pagination_where('tbl_registration', $config['per_page'], $offset, $where); foreach ($result as $key => $value) { $encrypted_id = $this->model->encryptdata($value['rid']); if($value['status'] == '1'){ $email_status = '<span class="badge bg-green">Verified</span>'; }else{ $email_status = '<span class="badge bg-red">Pending</span>'; } if($value['payment_status'] == '1'){ $payment_status = '<span class="badge bg-green">Done</span>'; }else{ $payment_status = '<span class="badge bg-red">Pending</span>'; } echo '<tr> <td class="text-capitalize"><a href="'.base_url()."webapp/people/view/".$encrypted_id.'">'.$value["name"].'</a></td> <td>'.$value["email"].'</td> <td>'.$value["mobile"].'</td> <td>'.$email_status.'</td> <td>'.$payment_status.'</td> <td>'; echo '<a href="'.base_url().'webapp/people/updateUser/'.$encrypted_id.'" class="btn btn-primary"><i class="fa fa-pencil-square-o"></i></a> '; if($value['type'] != 'admin'){ if($value['payment_status'] == '1'){ echo '<a href="'.base_url().'webapp/people/deactive/'.$encrypted_id.'" class="btn btn-danger" data-toggle="tooltip" data-placement="top" title="Click here to deactive" aria-hidden="true"><i class="fa fa-times" aria-hidden="true"></i></a>'; }else{ echo '<a href="'.base_url().'webapp/people/active/'.$encrypted_id.'" class="btn btn-success" data-toggle="tooltip" data-placement="top" title="Click here to active" aria-hidden="true"><i class="fa fa-check" aria-hidden="true"></i></a>'; } } '</td> </tr>'; } } public function changePhoto(){ $uid = $this->input->post('uid'); $where = array('rid' => $uid); $user = $this->model->DetailData('tbl_registration', $where); $old_photo = $user[0]['photo']; $config['upload_path'] = './webapp/profile/'; $config['allowed_types']= 'gif|jpg|png|pdf|jpeg'; $config['encrypt_name'] = TRUE; $this->upload->initialize($config); $this->load->library('upload', $config); if($this->upload->do_upload('photo')){ if(!empty($old_photo)){ unlink('webapp/profile/'.$old_photo); } $data = $this->upload->data(); $photo = $data['file_name']; }else{ $photo = $this->input->post('hiddenPhoto'); } $date_incorporation = date("Y-m-d", strtotime($this->input->post('date_incorporation'))); $country = explode('_', $this->input->post('country')); $country = $country[1]; if($country == "India"){ $phone_code = "+91"; $gst = $this->input->post('gst'); $pan = $this->input->post('pan'); $llc_no = $this->input->post('llc_no'); $llp_no = $this->input->post('llp_no'); $cin_no = $this->input->post('cin_no'); $tax_id = ""; $impo_expo_no = $this->input->post('impo_expo_no'); $other_reg_no = $this->input->post('other_reg_no'); }else{ $phone_code = "+1"; $gst = ""; $pan = ""; $llc_no = $this->input->post('llc_no'); $llp_no = $this->input->post('llp_no'); $cin_no = ""; $tax_id = $this->input->post('tax_id'); $impo_expo_no = $this->input->post('impo_expo_no'); $other_reg_no = $this->input->post('other_reg_no'); } $insertdata=array( 'photo' => $photo, 'name' => $this->input->post('name'), 'email' => $this->input->post('email'), 'phone_code' => $phone_code, 'mobile' => $this->input->post('phone'), 'constitution'=>$this->input->post('constitution'), 'business_name'=>$this->input->post('business_name'), 'constitution_other'=>$this->input->post('constitution_other'), 'date_incorporation'=>$date_incorporation, 'nob'=>$this->input->post('nob'), 'ur'=>$this->input->post('ur'), 'ri'=>$this->input->post('ri'), 'gst'=>$gst, 'pan'=>$pan, 'llc_no'=>$llc_no, 'llp_no'=>$llp_no, 'cin_no'=>$cin_no, 'tax_id'=>$tax_id, 'impo_expo_no'=>$impo_expo_no, 'other_reg_no'=>$other_reg_no, 'country'=>$country, 'state'=>$this->input->post('state'), 'address'=>$this->input->post('address') ); $this->model->UpdateData('tbl_registration', $insertdata, $where); /************************************************************************/ $where_fltr=array('rid'=>$uid); $fltrData=$this->model->DetailData('tbl_director',$where_fltr); $fltrData = count($fltrData); if($fltrData >0){ $this->model->DeleteData('tbl_director',$where_fltr); } $count = count($this->input->post('director_name')); $director_name = $this->input->post('director_name'); $din_no = $this->input->post('din_no'); for($i=0; $i<$count; $i++){ if($director_name[$i] != ""){ $insertdata_flo=array( 'rid'=>$uid, 'director_name'=>$director_name[$i], 'din_no'=>$din_no[$i], ); $this->model->insertData('tbl_director', $insertdata_flo); } } /*************************************************************************/ $this->session->set_flashdata('msg', ' <div class="alert alert-success alert-dismissible" role="alert"> <button type="button" class="close" data-dismiss="alert" aria-label="Close"> <span aria-hidden="true">×</span></button> <strong>Success!</strong> Data has been updated. </div>'); redirect('webapp/users/profile'); } public function updateUser($encrypted_id){ $uid = $this->model->decryptdata($encrypted_id); if($this->input->post('save')=='save'){ $where = array('rid' => $uid); $user = $this->model->DetailData('tbl_registration', $where); $old_photo = $user[0]['photo']; $config['upload_path'] = './webapp/profile/'; $config['allowed_types']= 'gif|jpg|png|pdf|jpeg'; $config['encrypt_name'] = TRUE; $this->upload->initialize($config); $this->load->library('upload', $config); if($this->upload->do_upload('photo')){ if(!empty($old_photo)){ unlink('webapp/profile/'.$old_photo); } $data = $this->upload->data(); $photo = $data['file_name']; }else{ $photo = $this->input->post('hiddenPhoto'); } $insertdata=array( 'photo' => $photo, 'name' => $this->input->post('name'), 'email' => $this->input->post('email'), 'mobile' => $this->input->post('phone') ); $this->model->UpdateData('tbl_registration', $insertdata, $where); $this->session->set_flashdata('msg', ' <div class="alert alert-success alert-dismissible" role="alert"> <button type="button" class="close" data-dismiss="alert" aria-label="Close"> <span aria-hidden="true">×</span></button> <strong>Success!</strong> Data has been updated. </div>'); redirect('webapp/people/office'); }else{ $where = array('rid' => $uid); $data['user'] = $this->model->DetailData('tbl_registration', $where); $this->load->view('webapp/add_user', $data); } } public function deactive($encrypted_id){ $uid = $this->model->decryptdata($encrypted_id); $where = array('rid' => $uid); $upd = array('payment_status' => '0'); $this->model->UpdateData('tbl_registration', $upd, $where); $this->session->set_flashdata('msg', ' <div class="alert alert-success alert-dismissible" role="alert"> <button type="button" class="close" data-dismiss="alert" aria-label="Close"> <span aria-hidden="true">×</span></button> <strong>Success!</strong> User is Deactivated. </div>'); $data = $this->model->DetailData('tbl_registration', $where); $type = $data[0]['type']; if($type == 'customer'){ redirect('webapp/people/customer'); }else{ redirect('webapp/people/office'); } } public function active($encrypted_id){ $uid = $this->model->decryptdata($encrypted_id); $where = array('rid' => $uid); $upd = array('payment_status' => '1'); $this->model->UpdateData('tbl_registration', $upd, $where); $this->session->set_flashdata('msg', ' <div class="alert alert-success alert-dismissible" role="alert"> <button type="button" class="close" data-dismiss="alert" aria-label="Close"> <span aria-hidden="true">×</span></button> <strong>Success!</strong> User is Activated. </div>'); $data = $this->model->DetailData('tbl_registration', $where); $type = $data[0]['type']; if($type == 'customer'){ $name = $data[0]["name"]; $to = $data[0]["email"]; $msg = ' <!DOCTYPE html> <html> <head> <title>PaperPush</title> </head> <body style="font-family: sans-serif;"> <div class="container" style="width:50%; margin: 0 auto; background-color: #eee; box-shadow: 1px 1px 1px 1px #a09191; margin-top: 5rem; margin-bottom: 5rem;"> <div style="color:#fff; background-image: linear-gradient(-20deg, #CF212A 0%, #003865 100%); padding: 10px; text-align: center;"> <h3>Welcome to Paperpush</h3> </div> <div style="padding: 1rem;"> <p><strong>Dear '.$name.',</strong></p> <p><strong>PaperPush is glad to inform you that your account has been activated and now you can start uploading your documents with your account credentials.</strong></p> </div> </div> Regards,<br> Team PaperPush. <p>Note: Please do not reply of this email. This is system generated email. </p> </body> </html>'; $sub = "PaperPush"; $this->model->emailsend($to, $sub, $msg); redirect('webapp/people/customer'); }else{ redirect('webapp/people/office'); } } public function directory($path){ $mypath = $path; $path = explode('-', $path); $data['folder'] = $path[0]; $data['year'] = $path[1]; $data['month'] = $path[2]; $data['voucher'] = $path[3]; $data['mypath'] = $mypath; $this->load->view("webapp/view_directory",$data); } public function directory_used($path){ $mypath = $path; $path = explode('-', $path); $data['folder'] = $path[0]; $data['year'] = $path[1]; $data['month'] = $path[2]; $data['voucher'] = $path[3]; $data['mypath'] = $mypath; $this->load->view("webapp/view_directory_used",$data); } public function directory_scratched($path){ $mypath = $path; $path = explode('-', $path); $data['folder'] = $path[0]; $data['year'] = $path[1]; $data['month'] = $path[2]; $data['voucher'] = $path[3]; $data['mypath'] = $mypath; $this->load->view("webapp/view_directory_scratched",$data); } public function makeUsed(){ $folder = $_POST['folder']; $year = $_POST['year']; $month = $_POST['month']; $voucher = $_POST['voucher']; $name = $_POST['name']; $url1 = base_url().'documents/'.$folder.'/'.$year.'/'.$month.'/'.$voucher.'/'.$name; $url2 = './documents/'.$folder.'/'.$year.'/'.$month.'/'.$voucher.'/used'; $url3 = './documents/'.$folder.'/'.$year.'/'.$month.'/'.$voucher.'/used/'.$name; $url4 = './documents/'.$folder.'/'.$year.'/'.$month.'/'.$voucher.'/'.$name; if(is_dir($url2)) { if(rename($url4, $url3)){ echo 'Success'; }else{ echo 'somthing went wrong'; } }else{ mkdir($url2); if(rename($url4, $url3)){ echo 'Success'; }else{ echo 'somthing went wrong'; } } } public function makeScratched(){ $folder = $_POST['folder']; $year = $_POST['year']; $month = $_POST['month']; $voucher = $_POST['voucher']; $name = $_POST['name']; $url1 = base_url().'documents/'.$folder.'/'.$year.'/'.$month.'/'.$voucher.'/'.$name; $url2 = './documents/'.$folder.'/'.$year.'/'.$month.'/'.$voucher.'/scratched'; $url3 = './documents/'.$folder.'/'.$year.'/'.$month.'/'.$voucher.'/scratched/'.$name; $url4 = './documents/'.$folder.'/'.$year.'/'.$month.'/'.$voucher.'/'.$name; if(is_dir($url2)) { if(rename($url4, $url3)){ echo 'Success'; }else{ echo 'somthing went wrong'; } }else{ mkdir($url2); if(rename($url4, $url3)){ echo 'Success'; }else{ echo 'somthing went wrong'; } } } public function trashUsed(){ $folder = $_POST['folder']; $year = $_POST['year']; $month = $_POST['month']; $voucher = $_POST['voucher']; $name = $_POST['name']; $url = './documents/'.$folder.'/'.$year.'/'.$month.'/'.$voucher.'/used/'.$name; if(unlink($url)){ echo 'Removed'; }else{ echo 'Error'; } } public function trashScratched(){ $folder = $_POST['folder']; $year = $_POST['year']; $month = $_POST['month']; $voucher = $_POST['voucher']; $name = $_POST['name']; $url = './documents/'.$folder.'/'.$year.'/'.$month.'/'.$voucher.'/scratched/'.$name; if(unlink($url)){ echo 'Removed'; }else{ echo 'Error'; } } public function makeStructure_ser(){ //echo '<pre>'; print_r($_POST); die; $user_code = $this->input->post('code'); $year = $this->input->post('year'); $ent = str_replace(' ', '_', $this->input->post('ser_name')); $bucketname = 'paperpushbucket'; $month = ['a_april', 'b_may', 'c_june', 'd_july', 'e_august', 'f_september', 'g_october', 'h_november', 'i_december', 'j_january', 'k_february', 'l_march']; foreach ($month as $value) { $this->s3->putObject(['Bucket' => $bucketname, 'Key' => $user_code."/".$year."/".$value."/".$ent."/", 'Body' => "", 'ACL' => 'public-read']); } $where = array('code' => $user_code, 'year' => $year); $get = $this->db2->get_where('cust_upload_structure', $where)->row_array(); $stage = $get['stage']; $dec_stage = json_decode($stage); $new_stage=[]; foreach($dec_stage as $key => $val){ $new_stage[]=$val; } $new_stage[]=$ent; $enc_stage = json_encode($new_stage); $upd = array('stage'=>$enc_stage); $this->model->UpdateData('cust_upload_structure',$upd,$where); $array['status'] = 'success'; echo json_encode($array); } public function remService(){ //echo '<pre>'; print_r($_POST); die; $code = $this->input->post('code'); $year = $this->input->post('year'); $posted_stage = $this->input->post('stage'); $where = array('code'=>$code, 'year'=>$year); $get = $this->db2->get_where('cust_upload_structure', $where)->row_array(); $stage = json_decode($get['stage']); //echo '<pre>'; print_r($stage); if (($key = array_search($posted_stage, $stage)) !== false) { unset($stage[$key]); } //echo '<pre>'; print_r($stage); die; $enc_stage = json_encode($stage); $data = array('stage'=>$enc_stage); $this->model->UpdateData('cust_upload_structure', $data, $where); $array['status'] = 'success'; echo json_encode($array); } public function makeStructure_pastDir(){ //echo '<pre>'; print_r($_POST); die; $user_code = $this->input->post('code'); $year = $this->input->post('year'); //$year = '2020'; $check = $this->db2->get_where('cust_upload_structure', array('year'=>$year, 'code'=>$user_code))->num_rows(); if($check == 0){ $array['status'] = 'success'; $entries = ['purchase_invoices', 'sales_invoices', 'cash_payment', 'cash_receipt', 'cheque_paid', 'expense_vouchers', 'debit_notes', 'credit_notes', 'bank_statements', 'cheque_deposited', 'reports', 'others']; $json_entry = json_encode($entries); $data = array( 'code' => $user_code, 'year' => $year, 'stage' => $json_entry ); $this->model->insertData('cust_upload_structure', $data); $bucketname = 'paperpushbucket'; $this->s3->putObject( [ 'Bucket' => $bucketname, 'Key' => $user_code."/", 'Key' => $user_code."/".$year."/", 'Body' => "", 'ACL' => 'public-read' ], ); $month = ['a_april', 'b_may', 'c_june', 'd_july', 'e_august', 'f_september', 'g_october', 'h_november', 'i_december', 'j_january', 'k_february', 'l_march']; foreach ($month as $value) { $this->s3->putObject(['Bucket' => $bucketname, 'Key' => $user_code."/".$year."/".$value."/", 'Body' => "", 'ACL' => 'public-read']); $entries = ['purchase_invoices', 'sales_invoices', 'cash_payment', 'cash_receipt', 'cheque_paid', 'expense_vouchers', 'debit_notes', 'credit_notes', 'bank_statements', 'cheque_deposited', 'reports', 'others']; foreach ($entries as $ent) { $this->s3->putObject(['Bucket' => $bucketname, 'Key' => $user_code."/".$year."/".$value."/".$ent."/", 'Body' => "", 'ACL' => 'public-read']); //$this->s3->putObject(['Bucket' => $bucketname, 'Key' => $user_code."/".$year."/".$value."/".$ent."/completed/", 'Body' => "", 'ACL' => 'public-read']); //$this->s3->putObject(['Bucket' => $bucketname, 'Key' => $user_code."/".$year."/".$value."/".$ent."/rejected/", 'Body' => "", 'ACL' => 'public-read']); } } }else{ $array['status'] = 'error'; $array['msg'] = 'Selected disrectory is alrady available.'; } echo json_encode($array); } public function upload_temp(){ //echo "<pre>"; print_r($_FILES); echo "<pre>"; print_r($_POST); die; $bucketname = 'paperpushbucket'; $code = $this->input->post('code'); $userdata = $this->session->userdata('reg_info'); $rid = $userdata[0]['rid']; $path = $code.'/Templates'; $count = count($_FILES['doc']['size']); for($i = 0; $i < $count; $i++){ $filename = $_FILES['doc']['name'][$i]; $ext = pathinfo($filename, PATHINFO_EXTENSION); $ext = strtolower($ext); if(!empty($ext)){ if($ext == 'jpg' || $ext == 'jpeg' || $ext == 'png' || $ext == 'pdf' || $ext == 'csv' || $ext == 'xls' || $ext == 'xlsb' || $ext == 'xlsx'){ //echo "<pre>"; print_r($_FILES); die; $rand =rand(10,100); $target_file = preg_replace("/[^a-z0-9\_\-\.]/i", '', $_FILES['doc']['name'][$i]); $new_file = $rand.'_'.$target_file; $file_name = $_FILES['doc']['name'][$i]; $temp_file_location = $_FILES['doc']['tmp_name'][$i]; //$ct = ['image/jpg', 'image/jpeg', 'image/png', 'application/csv']; if($ext == 'pdf' || $ext == 'PDF'){ $this->s3->putObject([ 'Bucket' => $bucketname, 'Key' => $path.'/'.$new_file, 'SourceFile' => $temp_file_location, 'ContentType' => 'application/pdf', //'Body' => fopen($temp_file_location, 'rb'), 'ACL' => 'public-read', ]); }else{ $this->s3->putObject([ 'Bucket' => $bucketname, 'Key' => $path.'/'.$new_file, 'SourceFile' => $temp_file_location, //'ContentType' => 'image/jpg', //'Body' => fopen($temp_file_location, 'rb'), 'ACL' => 'public-read', ]); } //insert in table $data = array( 'ct_from' => $rid, 'ct_code' => $code, 'ct_filename' => $new_file, 'datetime' => date('Y-m-d H:i:s'), ); $this->model->insertData('cust_templates', $data); } } } } public function view_temp(){ $code=$this->input->post('code'); $data = $this->db2->get_where('cust_templates', array('ct_code'=>$code))->result_array(); if(!empty($data)){ $html=''; $html.='<ul class="list-unstyled">'; $i=0; foreach($data as $k => $v){ $i++; $path = $code.'/Templates/'.$v["ct_filename"]; $html.='<li>'.$i.') <a href="https://paperpushbucket.s3.ap-south-1.amazonaws.com/'.$path.'">'.$v["ct_filename"].'</a></li>'; } $html.='</ul>'; }else{ $html='Files not available'; } $array['html'] = $html; echo json_encode($array); } public function remUsr(){ $aid=$this->input->post('aid'); $where = array('aid' => $aid); $this->model->DeleteData('tbl_access', $where); $array['status'] = 'success'; echo json_encode($array); } }
Copyright ©2021 || Defacer Indonesia