EVOLUTION-NINJA
Edit File: Welcome.php
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); require APPPATH . 'PHPMailer/PHPMailer-master/src/Exception.php'; require APPPATH . 'PHPMailer/PHPMailer-master/src/PHPMailer.php'; require APPPATH . 'PHPMailer/PHPMailer-master/src/SMTP.php'; use PHPMailer\PHPMailer\PHPMailer; use PHPMailer\PHPMailer\SMTP; use PHPMailer\PHPMailer\Exception; class Welcome extends CI_Controller { /** * Index Page for this controller. * * Maps to the following URL * http://example.com/index.php/welcome * - or - * http://example.com/index.php/welcome/index * - or - * Since this controller is set as the default controller in * config/routes.php, it's displayed at http://example.com/ * * So any other public methods not prefixed with an underscore will * map to /index.php/welcome/<method_name> * @see https://codeigniter.com/user_guide/general/urls.html */ //index public function index() { $this->load->view('login'); } //login Function public function user_login(){ $username = $this->input->post('username'); $password = $this->input->post('password'); $remember=$this->input->post('remember'); $table="users"; $where=array('email'=>$username,'delete_status'=>'ACTIVE'); $result=$this->bidding_model->get_where_row($table,$where); if($result){ $pass_prefix = '$2a$05$'; $pass_suffix = '$'; $Allowed_Chars ='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789./'; $Chars_Len = 63; $Salt_Length = 21; $salt_password = ""; $salt_password=$result->salt; $encrypted_pass = $pass_prefix . $salt_password . $pass_suffix; $hashed_password = crypt($password,$encrypted_pass); // echo $hashed_password;die(); if($result->password==$hashed_password){ // if($result->login_status=="ONLINE") //{ //echo json_encode(array('result'=>'0','message'=>'You are already logged in')); //} // else //{ //----------------------------------------------------------------------------// $where_user = array('user_id'=>$result->user_id,'delete_status'=>'ACTIVE'); $login_status = array('login_status'=>'ONLINE'); $this->bidding_model->update_row($where_user,$login_status,$table); //---------------------------------------------------------------------------// $this->session->set_userdata('first_name',$result->first_name); $this->session->set_userdata('last_name',$result->last_name); $this->session->set_userdata('user_id',$result->user_id); $this->session->set_userdata('user_type_id',$result->user_type_id); echo json_encode(array('result'=>'1','bidding_user_id'=>$result->user_id,'user_type_id'=>$result->user_type_id,'message'=>'Login Sucessfully')); // } } else{ echo json_encode(array('result'=>'0','message'=>'Wrong login credentials')); } }else{ echo json_encode(array('result'=>'0','message'=>'Wrong login credentials')); } } //forgot password public function forgot_password(){ $this->load->view('forgot_password'); } //dashboard public function dashboard(){ $user_id = $this->session->userdata('user_id'); if($user_id) { $client=$this->bidding_model->get_count_clients(); $data['client']=count($client); $table="users"; $where=array('user_type_id'=>'2','delete_status'=>'ACTIVE'); $iadmin=$this->bidding_model->get_where_result($table,$where); $data['iadmin']=count($iadmin); $active_licence=$this->bidding_model->get_active_licences(); $data['license']=count($active_licence); $renewal_license=$this->bidding_model->get_licences_for_renewal(); $data['renewal']=count($renewal_license); $renewal_next_month=$this->bidding_model->get_renewal_for_next_month(); $data['renew_next']=count($renewal_next_month); //$table="users"; //$where=array('user_type_id'=>'4','delete_status'=>'ACTIVE'); // $vendor=$this->bidding_model->get_where_result($table,$where); $vendor=$this->bidding_model->get_sa_vendor_model_list(); $arr=array(); foreach($vendor as $key => $value) { $client=$this->bidding_model->get_vendor_client_list($value->user_id); $res['client_count']=count($client); $res['company_name']=$value->cname; $res['first_name']=$value->first_name; $res['email']=$value->email; $res['mobile_no']=$value->mobile_no; $res['industries']=$value->industries; $res['user_id']=$value->user_id; array_push($arr,$res); } $dvendor=$arr; $data['vendor']=count($dvendor); $table="users"; $where=array('user_id'=>$user_id,'delete_status'=>'ACTIVE'); $data['user']=$this->bidding_model->get_where_row($table,$where); $where=array('user_id'=>$user_id); $table="users"; $data['user_usreid']=$this->bidding_model->get_where_row($table,$where); $this->load->view('sa_dashboard',$data); }else{ redirect('/'); } } //logout public function logout() { $user_id = $this->session->userdata('user_id'); $table="users"; $where=array('user_id'=>$user_id); $res=$this->bidding_model->get_where_row($table,$where); $id=$res->login_count; $id+=1; $data=array('login_count'=>$id); $r=$this->bidding_model->update_row($where,$data,$table); if($r){ //----------------------------------------------------------------------------// $where_user = array('user_id'=>$user_id,'delete_status'=>'ACTIVE'); $login_status = array('login_status'=>'OFFLINE'); $this->bidding_model->update_row($where_user,$login_status,$table); //---------------------------------------------------------------------------// $this->session->sess_destroy(); $this->session->unset_userdata('user_id'); $this->session->unset_userdata('first_name'); } redirect('/'); } //events public function events(){ $user_id = $this->session->userdata('user_id'); if($user_id) { $where=array('user_id'=>$user_id); $table="users"; $data['user_usreid']=$this->bidding_model->get_where_row($table,$where); $this->load->view('events'); }else{ redirect('/'); } } //profile public function profile(){ $user_id = $this->session->userdata('user_id'); if($user_id) { $where=array('user_id'=>$user_id); $table="users"; $data['user_usreid']=$this->bidding_model->get_where_row($table,$where); $this->load->view('profile'); }else{ redirect('/'); } } //change forgot password // public function change_forgot_password(){ // $username=$this->input->post('username'); // $email=$this->input->post('email'); // $table="users"; // $where=array('user_name'=>$username,'email'=>$email); // $result=$this->bidding_model->get_where_row($table,$where); // $encoded_email = urlencode($email); // if($result){ // $msg = base_url() . "resetpassword/" . $result->user_id . "/" . $encoded_email; // } // $name='Jayblues'; // $email='support@jayblues.com'; // $email_to=$email; // $subject="Reset Password"; // $result= $this->sendEmail($email,$email_to,$name,$subject,$msg); // if($result){ // echo json_encode(array('result'=>'1','message'=>'Password Reset Link Send to Mail')); // }else{ // echo json_encode(array('result'=>'0','message'=>'Something Went Wrong')); // } // } // public function sendEmail($from,$to,$name,$subject,$message) // { // $this->load->library('email'); // $config = array( // 'protocol' => 'smtp', // 'smtp_host' => 'smtp.gmail.com', // 'smtp_port' => 587, // 'smtp_user' => 'jaybluesnew@gmail.com', // 'smtp_pass' => 'jayblues123', // 'mailtype' => 'html', // 'charset' => 'utf-8' // ); // $this->email->initialize($config); // $this->email->set_mailtype("html"); // $this->email->set_newline("\r\n"); // $this->email->to($to); // $this->email->from($from,$name); // $this->email->subject($subject); // $this->email->message($message); // if ($this->email->send()) { // return 1; // } else { // show_error($this->email->print_debugger()); // } // } public function reset_password(){ $this->load->view('forgot_reset_password'); } public function change_forgot_password(){ $username = $this->input->post('username'); $email = $this->input->post('email'); $table = "users"; $where = array('user_name' => $username, 'email' => $email); $result = $this->bidding_model->get_where_row($table, $where); $encoded_email = urlencode($email); $msg = ''; // Initialize $msg variable outside of the if block if ($result) { // $msg = base_url() . "resetpassword/" . $result->user_id . "/" . $encoded_email; $msg = base_url() . "resetpassword/" . $result->user_id . "/" . $encoded_email; } $name = 'Jayblues'; $email_from = 'support@jayblues.com'; $email_to = $email; $subject = "Reset Password"; $result = $this->sendEmail($email_from, $email_to, $name, $subject, $msg); // Pass $msg to sendEmail function if ($result) { echo json_encode(array('result' => '1', 'message' => 'Password Reset Link Send to Mail')); } else { echo json_encode(array('result' => '0', 'message' => 'Something Went Wrong')); } } public function sendEmail($email_from,$email_to,$name,$subject,$msg) { $mail = new PHPMailer(true); try { $mail->isSMTP(); $mail->Host = 'smtp.gmail.com'; $mail->SMTPAuth = true; $mail->Username = 'rbalu743@gmail.com'; $mail->Password = 'qcuw hzyn exhs irca'; $mail->SMTPSecure = 'tls'; $mail->Port = 587; $mail->setFrom($email_from, $name); $mail->addAddress($email_to); $mail->isHTML(true); $mail->Subject = $subject; $mail->Body = $msg; $mail->send(); return true; } catch (Exception $e) { return false; } } //update password public function update_password() { $user_id = $this->input->post('user_id'); $new_password = $this->input->post('new_password'); if (!empty($user_id) && !empty($new_password)) { $this->load->model('bidding_model'); $where = array('user_id' => $user_id, 'delete_status' => 'ACTIVE'); $user = $this->bidding_model->get_where_row('users', $where); if ($user) { $salt_length = 21; $allowed_chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789./'; $chars_len = strlen($allowed_chars); $salt = ''; for ($i = 0; $i < $salt_length; $i++) { $salt .= $allowed_chars[rand(0, $chars_len - 1)]; } $pass_prefix = '$2a$05$'; $pass_suffix = '$'; $encrypted_pass = $pass_prefix . $salt . $pass_suffix; $hashed_password = crypt($new_password, $encrypted_pass); $update_data = array( 'password' => $hashed_password, 'salt' => $salt ); $this->bidding_model->update_data('users', $update_data, array('user_id' => $user_id)); $response = array('success' => true, 'message' => 'Password updated successfully'); } else { $response = array('success' => false, 'message' => 'User not found'); } } else { $response = array('success' => false, 'message' => 'Missing parameters'); } header('Content-Type: application/json'); echo json_encode($response); } //Sa admin create public function sa_iadmin_create(){ $user_id = $this->session->userdata('user_id'); if($user_id) { $where=array('user_id'=>$user_id); $table="users"; $data['user_usreid']=$this->bidding_model->get_where_row($table,$where); $this->load->view('sa_iadmin_create'); }else{ redirect('/'); } } //Sa admin create list public function sa_iadmin_list(){ $user_id = $this->session->userdata('user_id'); if($user_id) { $table="users"; $where=array('user_type_id'=>'2','delete_status'=>'ACTIVE'); $user=$this->bidding_model->get_where_result($table,$where); $arr=array(); foreach($user as $key => $value) { $data['user_id'] = $value->user_id; $data['first_name'] = $value->first_name; $data['email'] = $value->email; $data['designation'] = $value->designation; $data['mobile_no'] = $value->mobile_no; $table="users"; $user_id=$value->user_id; $where=array('assigned_iadmin'=>$user_id,'delete_status'=>'ACTIVE','user_type_id'=>'3'); $client= $this->bidding_model->get_where_result($table,$where); $data['client']=count($client); array_push($arr,$data); } $result['user']=$arr; $ur_ids = $this->session->userdata('user_id'); $where=array('user_id'=>$ur_ids); $table="users"; $data['user_usreid']=$this->bidding_model->get_where_row($table,$where); $this->load->view('sa_admin_list',$result); }else{ redirect('/'); } } public function sa_vendor_delete() { $bidding_id = $this->input->post('id'); $table="users"; $where=array('user_id'=>$bidding_id); $data['iadmin']=$this->bidding_model->delete_row($where,$table); echo json_encode(array('result'=>1,'message'=>"Deleted Successfully")); } //Sa client create list public function sa_client_add(){ $user_id = $this->session->userdata('user_id'); $table="users"; $where=array('delete_status'=>'ACTIVE','user_type_id'=>'2'); $data['iadmin']=$this->bidding_model->get_where_asc_result($table,$where); if($user_id) { $ur_ids = $this->session->userdata('user_id'); $where=array('user_id'=>$ur_ids); $table="users"; $data['user_usreid']=$this->bidding_model->get_where_row($table,$where); $this->load->view('sa_client',$data); }else{ redirect('/'); } } //Sa client create list public function sa_client_list(){ $user_id = $this->session->userdata('user_id'); if($user_id) { $table="company_information"; $where=array('delete_status'=>'ACTIVE'); $comapny=$this->bidding_model->get_client_user_list_detail($table,$where); $arr=array(); foreach ($comapny as $key => $value) { $data['company_name']=$value->cname; $data['first_name']=$value->first_name; $data['mobile_no']=$value->mobile_no; $data['email']=$value->email; $data['date_of_creation']=$value->date_of_creation; $data['date_of_expiry']=$value->date_of_expiry; $data['contact_person']=$value->contact_person; $data['segment']=json_decode($value->industries); $data['user_id']=$value->u_id; $table="users"; $where=array('user_id'=>$value->assigned_iadmin); $data['admin']=$this->bidding_model->get_where_row($table,$where); array_push($arr,$data); } $data['company']=$arr; $ur_ids = $this->session->userdata('user_id'); $where=array('user_id'=>$ur_ids); $table="users"; $data['user_usreid']=$this->bidding_model->get_where_row($table,$where); $this->load->view('sa_client_list',$data); }else{ redirect('/'); } } //Sa vendor create public function sa_vendor_add(){ $user_id = $this->session->userdata('user_id'); if($user_id) { $ur_ids = $this->session->userdata('user_id'); $where=array('user_id'=>$ur_ids); $table="users"; $data['user_usreid']=$this->bidding_model->get_where_row($table,$where); $this->load->view('sa_vendor_add'); }else{ redirect('/'); } } //Sa vendor list public function sa_vendor_list(){ $user_id = $this->session->userdata('user_id'); if($user_id) { $vendor=$this->bidding_model->get_sa_vendor_model_list_get(); $arr=array(); foreach($vendor as $key => $value) { $client=$this->bidding_model->get_vendor_client_list($value->user_id); $res['client_count']=count($client); $res['company_name']=$value->cname; $res['first_name']=$value->first_name; $res['email']=$value->email; $res['mobile_no']=$value->mobile_no; $res['industries']=$value->industries; $res['user_id']=$value->user_id; array_push($arr,$res); } $data['vendor']=$arr; $ur_ids = $this->session->userdata('user_id'); $where=array('user_id'=>$ur_ids); $table="users"; $data['user_usreid']=$this->bidding_model->get_where_row($table,$where); $this->load->view('sa_vendor_list',$data); }else{ redirect('/'); } } //iadmin Addd public function add_iadmin(){ $name=$this->input->post('name'); $designation=$this->input->post('designation'); $email=$this->input->post('email'); $mobile_number=$this->input->post('mobile_number'); $user_id=$this->input->post('user_id'); $address=$this->input->post('address'); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d H:i:s'); $password='iadmin'; $pass_prefix = '$2a$05$'; $pass_suffix = '$'; $Allowed_Chars ='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789./'; $Chars_Len = 63; $Salt_Length = 21; $salt_password = ""; for($i=0; $i<=$Salt_Length; $i++) { $salt_password .= $Allowed_Chars[mt_rand(0,$Chars_Len)]; } $encrypted_pass = $pass_prefix . $salt_password . $pass_suffix; $hashed_password = crypt($password,$encrypted_pass); // echo $hashed_password;die(); $table="users"; $where=array('email'=>$email); $user_list=$this->bidding_model->get_where_row($table,$where); if(empty($user_list)) { $data=array( 'first_name' => $name, 'designation' => $designation, 'email' => $email, 'mobile_no' => $mobile_number, 'user_no' => $user_id, 'address' => $address, 'salt' => $salt_password, 'password' => $hashed_password, 'user_type_id' => '2', 'created_at' => $date_format ); $table="users"; $result=$this->bidding_model->insert($table,$data); if($result){ echo json_encode(array('result'=>1,'message'=>"Added Sucessfully")); }else{ echo json_encode(array('result'=>0,'message'=>"Not Added")); } } else { echo json_encode(array('result'=>2,'message'=>"This Email Id Already Exist")); } } //delete Iadmin public function delete_iadmin(){ $user_id = $this->session->userdata('user_id'); $table="clients_table"; $id=$this->input->post('id'); $where=array('vendor_id'=>$id,'user_id'=>$user_id); $results= $this->bidding_model->delete_row($where,$table); $id=$this->input->post('id'); $table="users"; $where=array('user_id'=>$id); // $data=array('delete_vendor'=>'INACTIVE'); $result=$this->bidding_model->get_bid_price_latest($table,$where); if($result){ $table="bidding_price_table"; $where=array('vendor_id'=>$id); $r=$this->bidding_model->delete_row($where,$table); if($r){ $table="vendor_bidding_table"; $where=array('user_id'=>$id); $r=$this->bidding_model->delete_row($where,$table); } } if($result){ echo json_encode(array('result'=>1,'message'=>"Deleted Successfully")); }else{ echo json_encode(array('result'=>0,'message'=>"Something went wrong")); } } //Sa vendor create public function sa_edit_iadmin(){ $id = $this->uri->segment(2); $table="users"; $where=array('user_id'=>$id); $data['user']=$this->bidding_model->get_where_row($table,$where); $user_id = $this->session->userdata('user_id'); if($user_id) { $ur_ids = $this->session->userdata('user_id'); $where=array('user_id'=>$ur_ids); $table="users"; $data['user_usreid']=$this->bidding_model->get_where_row($table,$where); $this->load->view('edit_iadmin',$data); }else{ redirect('/'); } } //update iadmin public function update_iadmin(){ $name=$this->input->post('name'); $designation=$this->input->post('designation'); $user_no=$this->input->post('user_no'); $email=$this->input->post('email'); $mobile_number=$this->input->post('mobile_number'); $user_id=$this->input->post('user_id'); $address=$this->input->post('address'); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $table="users"; $where=array('email'=>$email,'user_id !='=>$user_no); $user_list=$this->bidding_model->get_where_row($table,$where); if(empty($user_list)) { $where=array('user_id'=>$user_no); $data=array( 'first_name' => $name, 'designation' => $designation, 'email' => $email, 'mobile_no' => $mobile_number, 'user_no' => $user_id, 'address' => $address, 'user_type_id' => '2', 'updated_at' => $date_format ); $table="users"; $result=$this->bidding_model->update_row($where,$data,$table); if($result){ echo json_encode(array('result'=>1,'message'=>"Updated Sucessfully")); }else{ echo json_encode(array('result'=>0,'message'=>"Not Updated")); } } else { echo json_encode(array('result'=>2,'message'=>"This Email Id Already Exist")); } } //add client public function add_iclient(){ $company_name=$this->input->post('company_name'); $contact_person=$this->input->post('contact_person'); $email_id=$this->input->post('email_id'); $mobile_number=$this->input->post('mobile_number'); $date_of_creation=$this->input->post('date_of_creation'); $date_of_creation=date('Y-m-d',strtotime($date_of_creation)); $date_of_expiry=$this->input->post('date_of_expiry'); $date_of_expiry=date('Y-m-d',strtotime($date_of_expiry)); $assigned_admin=$this->input->post('assigned_admin'); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d H:i:s'); $password='iclient'; $pass_prefix = '$2a$05$'; $pass_suffix = '$'; $Allowed_Chars ='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789./'; $Chars_Len = 63; $Salt_Length = 21; $salt_password = ""; for($i=0; $i<=$Salt_Length; $i++) { $salt_password .= $Allowed_Chars[mt_rand(0,$Chars_Len)]; } $encrypted_pass = $pass_prefix . $salt_password . $pass_suffix; $hashed_password = crypt($password,$encrypted_pass); $table="users"; $where=array('email'=>$email_id); $user_list=$this->bidding_model->get_where_row($table,$where); if(empty( $user_list)) { $data=array( 'first_name' => $contact_person, 'company_name' => $company_name, 'email' => $email_id, 'mobile_no' => $mobile_number, 'salt' => $salt_password, 'password' => $hashed_password, 'assigned_iadmin' => $assigned_admin, 'user_type_id' => '3', 'user_name' => $email_id, 'date_of_creation' => $date_of_creation, 'date_of_expiry' => $date_of_expiry, 'created_at' => $date_format ); $table="users"; $result=$this->bidding_model->insert($table,$data); $mail = new PHPMailer(true); try { $mail->isSMTP(); $mail->Host = 'smtp.gmail.com'; $mail->SMTPAuth = true; $mail->Username = 'rbalu743@gmail.com'; $mail->Password = 'qcuw hzyn exhs irca'; $mail->SMTPSecure = 'tls'; $mail->Port = 587; $mail->setFrom('rbalu743@gmail.com', 'INTIPROCURE'); $mail->addAddress($email_id, $contact_person); $mail->isHTML(true); $mail->Subject = 'Intiprocure registration'; $mail->Body = '<p>You have successfully registered intiprocure you can login using your email '.$email_id.' and default password is " iclient " . Thankyou</p>'; $mail->send(); echo 'Successful'; } catch (Exception $e) { echo 'Message could not be sent. Mailer Error: ', $mail->ErrorInfo; } if($result){ echo json_encode(array('result'=>1,'message'=>"Added Sucessfully")); }else{ echo json_encode(array('result'=>0,'message'=>"Not Added")); } } else { echo json_encode(array('result'=>2,'message'=>"This Email Id Already Exist")); } } //add client public function add_ivendor(){ $company_name=$this->input->post('company_name'); $company_ids=$this->input->post('company_ids'); $user_type_ids=$this->input->post('user_type_ids'); $contact_person=$this->input->post('contact_person'); $email_id=$this->input->post('email_id'); $mobile_number=$this->input->post('mobile_number'); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d H:i:s'); $password='ivendor'; $pass_prefix = '$2a$05$'; $pass_suffix = '$'; $Allowed_Chars ='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789./'; $Chars_Len = 63; $Salt_Length = 21; $salt_password = ""; for($i=0; $i<=$Salt_Length; $i++) { $salt_password .= $Allowed_Chars[mt_rand(0,$Chars_Len)]; } $encrypted_pass = $pass_prefix . $salt_password . $pass_suffix; $hashed_password = crypt($password,$encrypted_pass); $table="users"; $where=array('email'=>$email_id); $user_list=$this->bidding_model->get_where_row($table,$where); ///if(empty( $user_list)) // { $data=array( 'first_name' => $contact_person, 'company_name' => $company_name, 'email' => $email_id, 'mobile_no' => $mobile_number, 'salt' => $salt_password, 'password' => $hashed_password, 'user_name' => $email_id, 'user_type_id' => '4', 'assigned_iadmin' => $this->session->userdata('user_id'), 'created_at' => $date_format, 'vendor_list_status' => 1 ); $table="users"; $company_ids=$this->input->post('company_ids'); $user_type_ids=$this->input->post('user_type_ids'); if($company_ids == '') { $result=$this->bidding_model->insert($table,$data); $table='users'; $where=array('user_id'=>$result); $result_d=$this->bidding_model->get_where_row($table,$where); $user_id = $this->session->userdata('user_id'); $where=array('user_id'=>$user_id); $result_user_id=$this->bidding_model->get_where_row($table,$where); $user_id = $this->session->userdata('user_id'); $table="clients_table"; $inserrt_datas=array('user_id'=>$user_id,'vendor_id'=>$result,'user_type'=>$result_user_id->user_type_id); $this->bidding_model->insert($table,$inserrt_datas); } else { $user_id = $this->session->userdata('user_id'); $where=array('user_id'=>$user_id); $result_user_id=$this->bidding_model->get_where_row($table,$where); $user_id = $this->session->userdata('user_id'); $table="clients_table"; $inserrt_datas=array('user_id'=>$user_id,'vendor_id'=>$company_ids,'user_type'=>$result_user_id->user_type_id); $this->bidding_model->insert($table,$inserrt_datas); $result='1' ; } if($result){ echo json_encode(array('result'=>1,'message'=>"Added Sucessfully")); }else{ echo json_encode(array('result'=>0,'message'=>"Not Added")); } // } // else // { // echo json_encode(array('result'=>2,'message'=>"This Email Id Already Exist")); // } } public function client_information(){ $user_id = $this->session->userdata('user_id'); if($user_id) { $table="users"; $where=array('user_id'=>$user_id,'delete_status'=>'ACTIVE'); $data['user']=$this->bidding_model->get_where_row($table,$where); $table="company_information"; $where=array('user_id'=>$user_id,'delete_status'=>'ACTIVE'); $data['company']=$this->bidding_model->get_where_row($table,$where); $table="contact_information"; $where=array('user_id'=>$user_id,'delete_status'=>'ACTIVE'); $data['contact']=$this->bidding_model->get_where_result($table,$where); $ur_ids = $this->session->userdata('user_id'); $where=array('user_id'=>$ur_ids); $table="users"; $data['user_usreid']=$this->bidding_model->get_where_row($table,$where); $this->load->view('client_information',$data); }else{ redirect('/'); } } public function client_dashboard(){ $user_id = $this->session->userdata('user_id'); if($user_id) { $table="users"; $where=array('user_id'=>$user_id,'delete_status'=>'ACTIVE'); $data['user']=$this->bidding_model->get_where_row($table,$where); $table="bidding_session"; $data['bidding']=$this->bidding_model->get_bidding_company_name($user_id); $bid=$this->bidding_model->get_bidding_company_name($user_id); $arr=array(); foreach($bid as $key =>$value) { $res['bidding_title']=$value->bidding_title; $res['bidding_id']=$value->bidding_session_id; $res['final_bidding_date']=$value->final_bidding_date; $res['bidding_time']=$value->bidding_time; $table="vendor_bidding_table"; $where=array('bidding_id'=>$value->bidding_session_id); $vendor=$this->bidding_model->get_where_result($table,$where); $res['vendor']=count($vendor); if($value->invitation_completed_date=='0000-00-00'){ $res['next_due_task']='Sending Invitations'; }else if($value->coordinate_completed_date=='0000-00-00'){ $res['next_due_task']='Cordinating with vendors for registation'; }else if($value->bidding_date_approval=='0000-00-00'){ $res['next_due_task']='Finalize the bidding date & time'; }else{ $res['next_due_task']='All Tasks Are Completed'; } array_push($arr,$res); } $data['bid']=$arr; $table="vendor_bidding_table"; $res=$this->bidding_model->get_iadmin_vendor_list_new_latest($user_id); $data['total_vendor']=count($res); $table="bidding_session"; $where=array('company_id'=>$user_id,'delete_status'=>'ACTIVE'); $res=$this->bidding_model->get_where_result($table,$where); $data['total_procur']=count($res); $table="bidding_session"; $where=array('company_id'=>$user_id,'delete_status'=>'ACTIVE'); $res=$this->bidding_model->get_waiting_procurement($table,$where); $data['wait_procur']=count($res); $res=$this->bidding_model->bidding_due($user_id); $data['bidding_due']=count($res); $data['bidding_new']=$this->bidding_model->get_client_bidding_events_new(); $data_bidding_new=$this->bidding_model->get_client_bidding_events_new(); $osl_details=array(); foreach($data_bidding_new as $f) { $vendor_id=$f->company_id; $t=$this->bidding_model->get_bidding_vendor($vendor_id); array_push($osl_details,$t); } $data['usres_tab_val']=$osl_details; //print_r($data['usres_tab_val']); //die(); $table="company_information"; $where=array('user_id'=>$user_id,'delete_status'=>'ACTIVE'); $data['company']=$this->bidding_model->get_where_row($table,$where); $ur_ids = $this->session->userdata('user_id'); $where=array('user_id'=>$ur_ids); $table="users"; $data['user_usreid']=$this->bidding_model->get_where_row($table,$where); $user_id = $this->session->userdata('user_id'); $this->session->userdata('user_id'); $table="users"; $where=array('user_id'=>$user_id,'delete_status'=>'ACTIVE'); $data['user']=$this->bidding_model->get_where_row($table,$where); // print_R($user_id); // die(); // $where=array('user_type_id'=>4,'assigned_iadmin'=>$user_id,'delete_vendor'=>'ACTIVE'); $vendor=$this->bidding_model->get_where_ivendorsresult($table,$user_id); $arr=array(); foreach($vendor as $key => $value) { $client=$this->bidding_model->get_vendor_client_list($value->user_id); $user=$this->bidding_model->get_user_vendor_client_detail($value->user_id); $res['client_count']=count($client); if($user){ $res['company_name']=$user->company_name; $res['first_name']=$user->first_name; $res['email']=$user->email; $res['mobile_no']=$user->mobile_no; $res['industries']=$user->industries; $res['user_id']=$value->user_id; array_push($arr,$res); } } $vendors=$this->bidding_model->get_iadmin_vendor_list_new($user_id); $arra=array(); foreach($vendors as $key => $value) { $client=$this->bidding_model->get_vendor_client_list($value->user_id); $user=$this->bidding_model->get_user_client_detail($value->user_id); $res['client_count']=count($client); if($user){ $res['company_name']=$user->company_name; $res['first_name']=$user->first_name; $res['email']=$user->email; $res['mobile_no']=$user->mobile_no; $res['industries']=$user->industries; $res['user_id']=$value->user_id; array_push($arr,$res); } } $result = array(); foreach ($arr as $key => $value){ if(!in_array($value, $result)) $result[$key]=$value; } $data['t_vendor']=count($result); $table="bidding_session"; $where=array('company_id'=>$user_id,'status'=>''); $order_by='final_bidding_date'; $data_rbidding=$this->bidding_model->get_where_orderby_row_new($table,$where,$order_by); $data['t_bid']=count($data_rbidding); $this->load->view('client_home',$data); }else{ redirect('/'); } } public function add_client_information(){ $company_name=$this->input->post('company_name'); $address=$this->input->post('address'); $city=$this->input->post('city'); $state=$this->input->post('state'); $postal_code=$this->input->post('postal_code'); $country=$this->input->post('country'); $telephone=$this->input->post('telephone'); $fax=$this->input->post('fax'); $email_id_new=$this->input->post('email'); $mobile_no=$this->input->post('mobile_no'); $website=$this->input->post('website'); $short_description=$this->input->post('short_description'); $industry_type=$this->input->post('industry_type'); $industries=$this->input->post('industries'); $user_id=$this->input->post('user_id'); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d H:i:s'); $table="company_information"; $where=array('user_id' =>$user_id); $res_new=$this->bidding_model->get_where_row($table,$where); $all_in=$this->input->post('all_industry'); if($all_in == '' || $all_in == NULL) { $all_industrys=''; } else { $all_industrys=$this->input->post('all_industry'); } $data=array( 'company_name' => $company_name, 'address' => $address, 'city' => $city, 'state' => $state, 'postal_code' => $postal_code, 'country' => $postal_code, 'telephone' => $telephone, 'fax' => $fax, 'website' => $website, 'email_id' => $email_id_new, 'short_desc' => $short_description, 'industry_type' => $industry_type, 'all_industry' => $all_industrys, 'industries' => json_encode($industries), 'user_id' => $user_id, 'created_at' => $date_format ); $table="company_information"; if($res_new){ $where=array('user_id'=>$user_id); $result=$this->bidding_model->update_row($where,$data,$table); }else { $result=$this->bidding_model->insert($table,$data); } if($result){ $contact_name=$this->input->post('contact_name'); $designation=$this->input->post('designation'); $mobile_no_new=$this->input->post('mobile_no_new'); $email_id=$this->input->post('email_id'); $where=array('user_id'=>$user_id); $table="contact_information"; $r=$this->bidding_model->delete_row($where,$table); if($r){ foreach($contact_name as $key => $value) { $arr=array( 'contact_name' => $value, 'designation' => $designation[$key], 'mobile_no' => $mobile_no_new[$key], 'email_id' => $email_id[$key], 'delete_status' => 'ACTIVE', 'user_id' => $user_id, 'created_at' => $date_format ); $table="contact_information"; $result=$this->bidding_model->insert($table,$arr); } } $first_name=$this->input->post('first_name'); $last_name=$this->input->post('last_name'); $email=$this->input->post('email'); $mobile_number=$this->input->post('mobile_number'); $designation_new=$this->input->post('designation_new'); $user_name=$this->input->post('user_name'); $password=$this->input->post('password'); $language=$this->input->post('language'); $pass_prefix = '$2a$05$'; $pass_suffix = '$'; $Allowed_Chars ='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789./'; $Chars_Len = 63; $Salt_Length = 21; $salt_password = ""; for($i=0; $i<=$Salt_Length; $i++) { $salt_password .= $Allowed_Chars[mt_rand(0,$Chars_Len)]; } $encrypted_pass = $pass_prefix . $salt_password . $pass_suffix; $hashed_password = crypt($password,$encrypted_pass); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $update_format = $date->format('Y-m-d'); $ar=array( 'company_name' => $company_name, 'first_name' => $first_name, 'last_name' => $last_name, 'designation' => $designation_new, 'email' => $email, 'mobile_no' => $mobile_number, 'user_name' => $user_name, 'language' => $this->input->post('language'), 'updated_at' => $update_format ); if($password!=''){ $ar['password'] = $hashed_password; $ar['salt'] = $salt_password; } $table="users"; $where=array('user_id'=>$user_id); $res=$this->bidding_model->update_row($where,$ar,$table); } if($res){ echo json_encode(array('result'=>'1','message'=>'Added Sucessfully')); } else { echo json_encode(array('result'=>'1','message'=>'Added Sucessfully')); } } public function client_task(){ $user_id = $this->session->userdata('user_id'); if($user_id) { $table="users"; $where=array('user_id'=>$user_id,'delete_status'=>'ACTIVE'); $data['user']=$this->bidding_model->get_where_row($table,$where); $ur_ids = $this->session->userdata('user_id'); $where=array('user_id'=>$ur_ids); $table="users"; $data['user_usreid']=$this->bidding_model->get_where_row($table,$where); $this->load->view('client_task',$data); }else{ redirect('/'); } } public function company_profile(){ $user_id = $this->uri->segment(2); if($user_id) { $table="users"; $where=array('user_id'=>$user_id,'delete_status'=>'ACTIVE'); $data['user']=$this->bidding_model->get_where_row($table,$where); $user_ids = $this->session->userdata('user_id'); $table="users"; $where=array('user_id'=>$user_ids,'delete_status'=>'ACTIVE'); $data['user_session']=$this->bidding_model->get_where_row($table,$where); $table="company_information"; $where=array('user_id'=>$user_id,'delete_status'=>'ACTIVE'); $data['company']=$this->bidding_model->get_where_row($table,$where); $table="contact_information"; $where=array('user_id'=>$user_id,'delete_status'=>'ACTIVE'); $data['contact']=$this->bidding_model->get_where_result($table,$where); $ur_ids = $this->session->userdata('user_id'); $where=array('user_id'=>$ur_ids); $table="users"; $data['user_usreid']=$this->bidding_model->get_where_row($table,$where); $this->load->view('company_profile',$data); }else{ redirect('/'); } } public function bidding_table(){ $user_id = $this->session->userdata('user_id'); if($user_id) { $table="users"; $where=array('user_id'=>$user_id,'delete_status'=>'ACTIVE'); $data['user']=$this->bidding_model->get_where_row($table,$where); $table="bidding_session"; $where=array('company_id'=>$user_id,'status'=>''); $order_by='final_bidding_date'; $data['bidding']=$this->bidding_model->get_where_orderby_row_new($table,$where,$order_by); $ur_ids = $this->session->userdata('user_id'); $where=array('user_id'=>$ur_ids); $table="users"; $data['user_usreid']=$this->bidding_model->get_where_row($table,$where); $this->load->view('bidding_table',$data); }else{ redirect('/'); } } public function coordinator_bidding_table(){ $user_id = $this->session->userdata('user_id'); if($user_id) { $table="users"; $where=array('user_id'=>$user_id,'delete_status'=>'ACTIVE'); $data['user']=$this->bidding_model->get_where_row($table,$where); $table="bidding_coordinators"; $where=array('user_id'=>$user_id); $bidding=$this->bidding_model->get_where_result($table,$where); $arr=array(); foreach ($bidding as $key => $value) { $table="bidding_session"; $where=array('bidding_session_id'=>$value->bidding_session_id); $bid=$this->bidding_model->get_where_result_update($table,$where); if($bid){ if($bid->status!='COMPLETED'){ array_push($arr,$bid->bidding_session_id); } } } $hh=array(); foreach($arr as $r) { $split=$r; $table="bidding_session"; $order_by='final_bidding_date'; $data_bidding=$this->bidding_model->get_where_orderby_rows_latest($table,$split,$order_by); array_push($hh,$data_bidding); } $data['bidding']=$hh; $data_bidding=$hh; $osl_details=array(); foreach($data_bidding as $bb) { foreach($bb as $b) { $vendor_id=$b->bidding_session_id; $table='bidding_session'; $where=array('bidding_session_id'=>$vendor_id); $tt=$this->bidding_model->get_bid_price_latest($table,$where); $v=$tt->company_id; $t=$this->bidding_model->get_bidding_vendor($v); array_push($osl_details,$t); } } $data['bidding_comapny']=$osl_details; $ur_ids = $this->session->userdata('user_id'); $where=array('user_id'=>$ur_ids); $table="users"; $data['user_usreid']=$this->bidding_model->get_where_row($table,$where); $this->load->view('coordinator_bidding_list',$data); }else{ redirect('/'); } } public function bidding_client_event(){ $user_id = $this->session->userdata('user_id'); if($user_id) { $table="users"; $where=array('user_id'=>$user_id,'delete_status'=>'ACTIVE'); $data['user']=$this->bidding_model->get_where_row($table,$where); $bidding_id = $this->uri->segment(2); $table="bidding_item"; $where=array('bidding_session_id'=>$bidding_id); $data['item']=$this->bidding_model->get_where_result($table,$where); $table="bidding_session"; $where=array('bidding_session_id'=>$bidding_id); $data['bid']=$this->bidding_model->get_where_row($table,$where); $table="bidding_status_table"; $where=array('bidding_id'=>$bidding_id); $data['status']=$this->bidding_model->get_latest_bidding_status($where); $this->load->view('bidding_client_event',$data); }else{ redirect('/'); } } public function get_contact_person_email(){ $email=$this->input->post('email'); $table="users"; // $where=array('email'=>$email,'delete_status'=>'ACTIVE'); $where=array('email'=>$email); $res=$this->bidding_model->get_where_row($table,$where); if($res){ echo json_encode(array('result'=>'1','detail'=>$res,'message'=>'Sucessful')); }else{ echo json_encode(array('result'=>'0','message'=>'Something went wrong')); } } //add bidding item public function add_bidding_item(){ $user_id=$this->session->userdata('user_id'); $where=array('user_id'=>$user_id); $table="users"; $res=$this->bidding_model->get_where_row($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $c_date = $date->format('Y-m-d'); if($res->date_of_expiry<$c_date){ echo json_encode(array('result'=>'2','msg'=>'license has expired')); }else { $sending_date=$this->input->post('sending_invitation'); if($sending_date!=''){ $sending_date=date('Y-m-d',strtotime($sending_date)); }else{ $sending_date=''; } $coordinate_vendor=$this->input->post('coordinate_vendor'); if($coordinate_vendor!=''){ $coordinate_vendor=date('Y-m-d',strtotime($coordinate_vendor)); }else{ $coordinate_vendor=''; } $finalized_bid_date_time=$this->input->post('finalized_bid_date_time'); if($finalized_bid_date_time!=''){ $finalized_bid_date_time=date('Y-m-d',strtotime($finalized_bid_date_time)); }else{ $finalized_bid_date_time=''; } $final_bidding_date=$this->input->post('final_bidding_date'); if($final_bidding_date!=''){ $final_bidding_date=date('Y-m-d',strtotime($final_bidding_date)); }else{ $final_bidding_date=''; } $sending_completed_date=$this->input->post('sending_completed_date'); if($sending_completed_date!=''){ $sending_completed_date=date('Y-m-d',strtotime($sending_completed_date)); }else{ $sending_completed_date=''; } $coordinate_completed_date=$this->input->post('coordinate_completed_date'); if($coordinate_completed_date!=''){ $coordinate_completed_date=date('Y-m-d',strtotime($coordinate_completed_date)); }else{ $coordinate_completed_date=''; } $finalized_completed_date=$this->input->post('finalized_completed_date'); if($finalized_completed_date!=''){ $finalized_completed_date=date('Y-m-d',strtotime($finalized_completed_date)); }else{ $finalized_completed_date=''; } $bidding_completed_date=$this->input->post('bidding_completed_date'); if($bidding_completed_date!=''){ $bidding_completed_date=date('Y-m-d',strtotime($bidding_completed_date)); }else{ $bidding_completed_date=''; } $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $created_at = $date->format('Y-m-d H:i:s'); $data=array( 'bidding_title' =>$this->input->post('bidding_title'), 'sending_invitation' =>$sending_date, 'coordinate_vendor' =>$coordinate_vendor, 'invitation_completed_date' =>$sending_completed_date, 'coordinate_completed_date' =>$coordinate_completed_date, 'bidding_date_approval' =>$bidding_completed_date, 'finalize_completed_date' =>$finalized_completed_date, 'finalized_bid_date_time' =>$finalized_bid_date_time, 'final_bidding_date' =>$final_bidding_date, 'bidding_limit_time' =>$this->input->post('bidding_time'), 'bidding_time' =>$this->input->post('final_bidding_time'), 'delete_status' =>'ACTIVE', 'created_at' =>$created_at, 'company_id' =>$this->session->userdata('user_id') ); $table="bidding_session"; $result=$this->bidding_model->insert($table,$data); if($result){ $coordinator_name= $this->input->post('coordinator_name'); $coordinator_phone= $this->input->post('coordinator_phone'); $coordinator_mail= $this->input->post('coordinator_mail'); $coordinator_company= $this->input->post('coordinator_company'); foreach($coordinator_name as $key=>$cname) { if($cname!=''){ $table="users"; $where=array('email' =>$coordinator_mail[$key]); $email=$this->bidding_model->get_where_row($table,$where); if($email){ $c_data=array( 'bidding_session_id' =>$result, 'coordinator_name' =>$cname, 'coordinator_phone' =>$coordinator_phone[$key], 'coordinator_email' =>$coordinator_mail[$key], 'coordinator_company' =>$coordinator_company[$key], 'user_id' =>$email->user_id, 'created_at' =>$created_at, ); $table="bidding_coordinators"; $this->bidding_model->insert($table,$c_data); }else{ $password='icoordinator'; $pass_prefix = '$2a$05$'; $pass_suffix = '$'; $Allowed_Chars ='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789./'; $Chars_Len = 63; $Salt_Length = 21; $salt_password = ""; for($i=0; $i<=$Salt_Length; $i++) { $salt_password .= $Allowed_Chars[mt_rand(0,$Chars_Len)]; } $encrypted_pass = $pass_prefix . $salt_password . $pass_suffix; $hashed_password = crypt($password,$encrypted_pass); $arr1=array( 'first_name' =>$cname, 'email' =>$coordinator_mail[$key], 'company_name' =>$coordinator_company[$key], 'mobile_no' =>$coordinator_phone[$key], 'created_at' =>$created_at, 'salt' =>$salt_password, 'password' =>$hashed_password, 'assigned_iadmin' =>'0', 'user_type_id' =>'5', 'delete_status' =>'ACTIVE' ); $table="users"; $user=$this->bidding_model->insert($table,$arr1); if($user){ $c_data=array( 'bidding_session_id' =>$result, 'coordinator_name' =>$cname, 'coordinator_phone' =>$coordinator_phone[$key], 'coordinator_email' =>$coordinator_mail[$key], 'coordinator_company' =>$coordinator_company[$key], 'user_id' =>$user, 'created_at' =>$created_at, ); $table="bidding_coordinators"; $this->bidding_model->insert($table,$c_data); } } } } $item_desc=$this->input->post('item_desc'); $specification=$this->input->post('specification'); $item_desc=$this->input->post('item_desc'); $item_desc=$this->input->post('item_desc'); $quantity=$this->input->post('quantity'); if(!empty($item_desc)){ foreach($item_desc as $key => $value) { if($value!=''){ $arr=array( 'bidding_session_id' =>$result, 'item_name' =>$value, 'specification' =>$specification[$key], 'quantity' =>$quantity[$key], 'delete_status' =>'ACTIVE', 'bidding_limit_time' =>$this->input->post('bidding_time'), 'created_at' =>$created_at ); $table="bidding_item"; $item_id=$this->bidding_model->insert($table,$arr); } } } $company_name=$this->input->post('company_name'); $email_id=$this->input->post('email_id'); $contact_parson=$this->input->post('contact_parson'); $phone_number=$this->input->post('phone_number'); foreach($company_name as $key => $value) { if($email_id[$key]!=''){ $table="users"; $where=array('email' =>$email_id[$key]); $email=$this->bidding_model->get_where_row($table,$where); if($email){ $user_id = $this->session->userdata('user_id'); $where=array('user_id'=>$user_id); $result_user_id=$this->bidding_model->get_where_row($table,$where); $user_id = $this->session->userdata('user_id'); $table="clients_table"; $inserrt_datas=array('user_id'=>$user_id,'vendor_id'=>$email->user_id,'user_type'=>$result_user_id->user_type_id); $this->bidding_model->insert($table,$inserrt_datas); if($email->delete_status == 'ACTIVE') { $table="vendor_bidding_table"; $bid=array( 'user_id' =>$email->user_id, 'bidding_id' =>$result, 'created_at' =>$created_at ); $table="vendor_bidding_table"; $ven_bid=$this->bidding_model->insert($table,$bid); } else { $table='users'; $where=array('user_id'=>$email->user_id); $up_data=array('delete_status'=>'ACTIVE','assigned_iadmin'=>$user_id); $this->bidding_model->update_row($where,$up_data,$table); $table="vendor_bidding_table"; $bid=array( 'user_id' =>$email->user_id, 'bidding_id' =>$result, 'created_at' =>$created_at ); $table="vendor_bidding_table"; $ven_bid=$this->bidding_model->insert($table,$bid); } }else{ $password='ivendor'; $pass_prefix = '$2a$05$'; $pass_suffix = '$'; $Allowed_Chars ='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789./'; $Chars_Len = 63; $Salt_Length = 21; $salt_password = ""; for($i=0; $i<=$Salt_Length; $i++) { $salt_password .= $Allowed_Chars[mt_rand(0,$Chars_Len)]; } $encrypted_pass = $pass_prefix . $salt_password . $pass_suffix; $hashed_password = crypt($password,$encrypted_pass); $arr1=array( 'first_name' =>$contact_parson[$key], 'email' =>$email_id[$key], 'company_name' =>$company_name[$key], 'mobile_no' =>$phone_number[$key], 'created_at' =>$created_at, 'salt' =>$salt_password, 'password' =>$hashed_password, 'assigned_iadmin' =>$this->session->userdata('user_id'), 'user_type_id' =>'4', 'delete_status' =>'ACTIVE' ); $table="users"; $user=$this->bidding_model->insert($table,$arr1); $user_id = $this->session->userdata('user_id'); $where=array('user_id'=>$user_id); $result_user_id=$this->bidding_model->get_where_row($table,$where); $user_id = $this->session->userdata('user_id'); $table="clients_table"; $inserrt_datas=array('user_id'=>$user_id,'vendor_id'=>$user,'user_type'=>$result_user_id->user_type_id); $this->bidding_model->insert($table,$inserrt_datas); if($user){ $table="vendor_bidding_table"; $bid=array( 'user_id' =>$user, 'bidding_id' =>$result, 'created_at' =>$created_at ); $table="vendor_bidding_table"; $ven_bid=$this->bidding_model->insert($table,$bid); } } } } echo json_encode(array('result'=>'1','bid_id'=>$result,'message'=>'Added Sucessfully')); }else{ echo json_encode(array('result'=>'0','message'=>'Something went wrong')); } } } public function edit_client_item(){ $user_id = $this->session->userdata('user_id'); if($user_id) { $table="users"; $where=array('user_id'=>$user_id,'delete_status'=>'ACTIVE'); $data['user']=$this->bidding_model->get_where_row($table,$where); $bidding_id = $this->uri->segment(2); $table="bidding_session"; $where=array('bidding_session_id' =>$bidding_id); $data['bid']=$this->bidding_model->get_where_row($table,$where); $table="bidding_item"; $where=array('bidding_session_id'=>$bidding_id); $data['item']=$this->bidding_model->get_where_result($table,$where); $table="bidding_coordinators"; $where=array('bidding_session_id'=>$bidding_id); $data['coordinators']=$this->bidding_model->get_where_result($table,$where); // $data['vendor']=$this->bidding_model->get_bidding_vendor_list($bidding_id); $data['vendor']=$this->bidding_model->get_bidding_vendor_inactive_list($bidding_id); $ur_ids = $this->session->userdata('user_id'); $where=array('user_id'=>$ur_ids); $table="users"; $data['user_usreid']=$this->bidding_model->get_where_row($table,$where); $this->load->view('edit_client_task',$data); }else{ redirect('/'); } } public function update_bidding_item(){ $sending_date=$this->input->post('sending_invitation'); if($sending_date!=''){ $sending_date=date('Y-m-d',strtotime($sending_date)); }else{ $sending_date=''; } $coordinate_vendor=$this->input->post('coordinate_vendor'); if($coordinate_vendor!=''){ $coordinate_vendor=date('Y-m-d',strtotime($coordinate_vendor)); }else{ $coordinate_vendor=''; } //final_bidding_date $finalized_bid_date_time=$this->input->post('finalized_bid_date_time'); if($finalized_bid_date_time!=''){ $finalized_bid_date_time=date('Y-m-d',strtotime($finalized_bid_date_time)); }else{ $finalized_bid_date_time=''; } $final_bidding_date=$this->input->post('final_bidding_date'); if($final_bidding_date!=''){ $final_bidding_date=date('Y-m-d',strtotime($final_bidding_date)); }else{ $final_bidding_date=''; } $sending_completed_date=$this->input->post('sending_completed_date'); if($sending_completed_date!=''){ $sending_completed_date=date('Y-m-d',strtotime($sending_completed_date)); }else{ $sending_completed_date=''; } $coordinate_completed_date=$this->input->post('coordinate_completed_date'); if($coordinate_completed_date!=''){ $coordinate_completed_date=date('Y-m-d',strtotime($coordinate_completed_date)); }else{ $coordinate_completed_date=''; } $finalized_completed_date=$this->input->post('finalized_completed_date'); if($finalized_completed_date!=''){ $finalized_completed_date=date('Y-m-d',strtotime($finalized_completed_date)); }else{ $finalized_completed_date=''; } $bidding_completed_date=$this->input->post('bidding_completed_date'); if($bidding_completed_date!=''){ $bidding_completed_date=date('Y-m-d',strtotime($bidding_completed_date)); }else{ $bidding_completed_date=''; } $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $created_at = $date->format('Y-m-d H:i:s'); $bidding_session_id=$this->input->post('bidding_id'); $data=array( 'bidding_title' =>$this->input->post('bidding_title'), 'bidding_room' =>$this->input->post('bidding_room'), 'sending_invitation' =>$sending_date, 'coordinate_vendor' =>$coordinate_vendor, 'invitation_completed_date' =>$sending_completed_date, 'coordinate_completed_date' =>$coordinate_completed_date, 'bidding_date_approval' =>$bidding_completed_date, 'finalize_completed_date' =>$finalized_completed_date, 'finalized_bid_date_time' =>$finalized_bid_date_time, 'final_bidding_date' =>$final_bidding_date, 'bidding_limit_time' =>$this->input->post('bidding_time'), 'bidding_time' =>$this->input->post('final_bidding_time'), 'delete_status' =>'ACTIVE', 'created_at' =>$created_at, 'company_id' =>$this->session->userdata('user_id') ); $table="bidding_session"; $bidding_session_id=$this->input->post('bidding_id'); $where=array('bidding_session_id' =>$bidding_session_id); $result=$this->bidding_model->update_row($where,$data,$table); if($result){ $coordinator_id=$this->input->post('coordinator_id'); $coordinator_name=$this->input->post('coordinator_name'); $coordinator_phone=$this->input->post('coordinator_phone'); $coordinator_mail=$this->input->post('coordinator_mail'); $coordinator_company=$this->input->post('coordinator_company'); if(!empty($coordinator_name)){ foreach($coordinator_name as $key=>$cname) { $table="users"; $where=array('email' =>$coordinator_mail[$key]); $email=$this->bidding_model->get_where_row($table,$where); if($email){ $table="bidding_coordinators"; $where=array('user_id' =>$email->user_id,'bidding_session_id'=>$this->input->post('bidding_id')); $vend=$this->bidding_model->get_where_row($table,$where); if($vend){ $where=array('user_id' =>$email->user_id,'bidding_session_id'=>$this->input->post('bidding_id')); $c_data=array( 'bidding_session_id' =>$bidding_session_id, 'coordinator_name' =>$coordinator_name[$key], 'coordinator_phone' =>$coordinator_phone[$key], 'coordinator_email' =>$coordinator_mail[$key], 'coordinator_company' =>$coordinator_company[$key], 'user_id' =>$email->user_id, 'created_at' =>$created_at, ); $this->bidding_model->update_row($where,$c_data,$table); }else{ } } else{ $password='coordinator'; $pass_prefix = '$2a$05$'; $pass_suffix = '$'; $Allowed_Chars ='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789./'; $Chars_Len = 63; $Salt_Length = 21; $salt_password = ""; for($i=0; $i<=$Salt_Length; $i++) { $salt_password .= $Allowed_Chars[mt_rand(0,$Chars_Len)]; } $encrypted_pass = $pass_prefix . $salt_password . $pass_suffix; $hashed_password = crypt($password,$encrypted_pass); $arr1=array( 'first_name' =>$coordinator_name[$key], 'email' =>$coordinator_mail[$key], 'company_name' =>$coordinator_company[$key], 'mobile_no' =>$coordinator_phone[$key], 'created_at' =>$created_at, 'user_type_id' =>'5', 'salt' =>$salt_password, 'password' =>$hashed_password, 'delete_status' =>'ACTIVE' ); $table="users"; $user=$this->bidding_model->insert($table,$arr1); if($user){ $c_data=array( 'bidding_session_id' =>$bidding_session_id, 'coordinator_name' =>$coordinator_name[$key], 'coordinator_phone' =>$coordinator_phone[$key], 'coordinator_email' =>$coordinator_mail[$key], 'coordinator_company' =>$coordinator_company[$key], 'user_id' =>$user, 'created_at' =>$created_at, ); $table_new="bidding_coordinators"; $this->bidding_model->insert($table_new,$c_data); } } } } $table="bidding_item"; // $where=array('bidding_session_id' =>$bidding_session_id); // $r=$this->bidding_model->delete_row($where,$table); //if($r){ $item_desc=$this->input->post('item_desc'); $specification=$this->input->post('specification'); $item_desc=$this->input->post('item_desc'); $item_desc=$this->input->post('item_desc'); $quantity=$this->input->post('quantity'); $item_id_key=$this->input->post('item_id_key'); foreach($item_desc as $key => $value) { if($item_id_key[$key]!='null'){ $arr=array( 'bidding_session_id' =>$bidding_session_id, 'item_name' =>$value, 'specification' =>$specification[$key], 'quantity' =>$quantity[$key], 'delete_status' =>'ACTIVE', 'bidding_limit_time' =>$this->input->post('bidding_time'), 'created_at' =>$created_at ); $table="bidding_item"; $where=array('item_id'=>$item_id_key[$key]); $item_id=$this->bidding_model->update_row($where,$arr,$table); }else{ if($value!=''){ $arr=array( 'bidding_session_id' =>$bidding_session_id, 'item_name' =>$value, 'specification' =>$specification[$key], 'quantity' =>$quantity[$key], 'delete_status' =>'ACTIVE', 'bidding_limit_time' =>$this->input->post('bidding_time'), 'created_at' =>$created_at ); $table="bidding_item"; $item_id=$this->bidding_model->insert($table,$arr); } } } //} include '../PHPExcel/IOFactory.php'; if(isset($_FILES['item_file']['name'])) { $file_name = $_FILES['item_file']['name']; $ext = pathinfo($file_name, PATHINFO_EXTENSION); if($ext == "xlsx" || $ext == "xls" || $ext == "csv") { $file_name = $_FILES['item_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 = 'leads'; if(count($allDataInSheet)>0){ for($i = 2;$i <= $arrayCount;$i++){ $item_name = trim($allDataInSheet[$i]["A"]); $specification = trim($allDataInSheet[$i]["B"]); $quantity = trim($allDataInSheet[$i]["C"]); $ar=array( 'bidding_session_id' =>$bidding_session_id, 'item_name' =>$item_name, 'specification' =>$specification, 'quantity' =>$quantity, 'delete_status' =>'ACTIVE', 'bidding_limit_time' =>$this->input->post('bidding_time'), 'created_at' =>$created_at ); $table="bidding_item"; $item_id=$this->bidding_model->insert($table,$ar); } } } } $company_name=$this->input->post('company_name'); $email_id=$this->input->post('email_id'); $contact_parson=$this->input->post('contact_parson'); $phone_number=$this->input->post('phone_number'); foreach($company_name as $key => $value) { $table="users"; $where=array('email' =>$email_id[$key]); $email=$this->bidding_model->get_where_row($table,$where); if($email){ $table="vendor_bidding_table"; $where=array('user_id' =>$email->user_id,'bidding_id'=>$this->input->post('bidding_id')); $vend=$this->bidding_model->get_where_row($table,$where); if($vend){ }else{ $bid=array( 'user_id' =>$email->user_id, 'bidding_id' =>$bidding_session_id, 'created_at' =>$created_at ); $table="vendor_bidding_table"; $ven_bid=$this->bidding_model->insert($table,$bid); } }else{ $password='ivendor'; $pass_prefix = '$2a$05$'; $pass_suffix = '$'; $Allowed_Chars ='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789./'; $Chars_Len = 63; $Salt_Length = 21; $salt_password = ""; for($i=0; $i<=$Salt_Length; $i++) { $salt_password .= $Allowed_Chars[mt_rand(0,$Chars_Len)]; } $encrypted_pass = $pass_prefix . $salt_password . $pass_suffix; $hashed_password = crypt($password,$encrypted_pass); $arr1=array( 'first_name' =>$contact_parson[$key], 'email' =>$email_id[$key], 'company_name' =>$company_name[$key], 'mobile_no' =>$phone_number[$key], 'created_at' =>$created_at, 'user_type_id' =>'4', 'salt' =>$salt_password, 'password' =>$hashed_password, 'delete_status' =>'ACTIVE' ); $table="users"; $user=$this->bidding_model->insert($table,$arr1); if($user){ $table="vendor_bidding_table"; $bid=array( 'user_id' =>$user, 'bidding_id' =>$bidding_session_id, 'created_at' =>$created_at ); $table="vendor_bidding_table"; $ven_bid=$this->bidding_model->insert($table,$bid); } } } if(isset($_FILES['vendor_file']['name'])) { $file_name = $_FILES['vendor_file']['name']; $ext = pathinfo($file_name, PATHINFO_EXTENSION); if($ext == "xlsx" || $ext == "xls" || $ext == "csv") { $file_name = $_FILES['vendor_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 = 'leads'; if(count($allDataInSheet)>0){ for($i = 2;$i <= $arrayCount;$i++){ $email_id = trim($allDataInSheet[$i]["A"]); $company_name = trim($allDataInSheet[$i]["B"]); $contact_parson = trim($allDataInSheet[$i]["C"]); $phone_number = trim($allDataInSheet[$i]["D"]); if($email_id!=''){ $table="users"; $where=array('email' =>$email_id); $email=$this->bidding_model->get_where_row($table,$where); if($email){ $table="vendor_bidding_table"; $where=array('user_id' =>$email->user_id,'bidding_id'=>$this->input->post('bidding_id')); $bidding_email=$this->bidding_model->get_where_row($table,$where); if($bidding_email) { } else { $table="vendor_bidding_table"; $bid=array( 'user_id' =>$email->user_id, 'bidding_id' =>$bidding_session_id, 'created_at' =>$created_at ); $table="vendor_bidding_table"; $ven_bid=$this->bidding_model->insert($table,$bid); } }else{ $password='ivendor'; $pass_prefix = '$2a$05$'; $pass_suffix = '$'; $Allowed_Chars ='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789./'; $Chars_Len = 63; $Salt_Length = 21; $salt_password = ""; for($i=0; $i<=$Salt_Length; $i++) { $salt_password .= $Allowed_Chars[mt_rand(0,$Chars_Len)]; } $encrypted_pass = $pass_prefix . $salt_password . $pass_suffix; $hashed_password = crypt($password,$encrypted_pass); $arr1=array( 'first_name' =>$contact_parson, 'email' =>$email_id, 'company_name' =>$company_name, 'mobile_no' =>$phone_number, 'created_at' =>$created_at, 'salt' =>$salt_password, 'password' =>$hashed_password, 'user_type_id' =>'4', 'delete_status' =>'ACTIVE' ); $table="users"; $user=$this->bidding_model->insert($table,$arr1); if($user){ $table="vendor_bidding_table"; $bid=array( 'user_id' =>$user, 'bidding_id' =>$bidding_session_id, 'created_at' =>$created_at ); $table="vendor_bidding_table"; $ven_bid=$this->bidding_model->insert($table,$bid); } } } } } } } echo json_encode(array('result'=>'1','message'=>'Added Sucessfully')); }else{ echo json_encode(array('result'=>'0','message'=>'Something went wrong')); } } public function get_iadmin_client_list(){ $id=$this->input->post('id'); $table="users"; //$where=array('assigned_iadmin'=>$id); $result=$this->bidding_model->get_complete_client_informations($id); echo json_encode($result); } public function vendor_home(){ $user_id = $this->session->userdata('user_id'); if($user_id) { $table="users"; $where=array('user_id'=>$user_id,'delete_status'=>'ACTIVE'); $data['user']=$this->bidding_model->get_where_row($table,$where); $table="company_information"; $data['profile']=$this->bidding_model->get_profile_information($user_id); $vendor_list=$this->bidding_model->get_vendor_bidding_client_list($user_id); $arr=array(); foreach($vendor_list as $key => $value) { $table="company_information"; $u_id=$value->company_id; $where=array('user_id'=>$u_id); $u=$this->bidding_model->get_where_row($table,$where); if($u){ $res['company_name']=$u->company_name; }else{ $res['company_name']=$value->company_name; } $table="vendor_bidding_table"; $where=array('bidding_id'=>$value->bidding_session_id); $vendor=$this->bidding_model->get_where_result($table,$where); $res['vendor']=count($vendor); $res['bidding_id']=$value->bidding_session_id; $res['bidding_date']=$value->final_bidding_date; $res['bidding_title']=$value->bidding_title; $res['bidding_time']=$value->bidding_time; array_push($arr,$res); } $data['com']=$arr; $total_bid=$this->bidding_model->get_total_biddings(); $data['total_bid']=count($total_bid); $completed_bid=$this->bidding_model->completed_biddings(); $data['completed_bid']=count($completed_bid); $upcoming_bid=$this->bidding_model->upcoming_biddings(); $data['upcoming_bid']=count($upcoming_bid); $todays_bid=$this->bidding_model->todays_biddings(); $data['todays_bid']=count($todays_bid); $table="company_information"; $where=array('user_id'=>$user_id,'delete_status'=>'ACTIVE'); $data['company']=$this->bidding_model->get_where_row($table,$where); $ur_ids = $this->session->userdata('user_id'); $where=array('user_id'=>$ur_ids); $table="users"; $data['user_usreid']=$this->bidding_model->get_where_row($table,$where); $this->load->view('vendor_home',$data); }else{ redirect('/'); } } public function vendor_profile(){ $user_id = $this->session->userdata('user_id'); if($user_id) { $table="users"; $where=array('user_id'=>$user_id,'delete_status'=>'ACTIVE'); $data['user']=$this->bidding_model->get_where_row($table,$where); $table="company_information"; $where=array('user_id'=>$user_id,'delete_status'=>'ACTIVE'); $data['company']=$this->bidding_model->get_where_row($table,$where); $table="contact_information"; $where=array('user_id'=>$user_id,'delete_status'=>'ACTIVE'); $data['contact']=$this->bidding_model->get_where_result($table,$where); $ur_ids = $this->session->userdata('user_id'); $where=array('user_id'=>$ur_ids); $table="users"; $data['user_usreid']=$this->bidding_model->get_where_row($table,$where); $this->load->view('vendor_profile',$data); }else{ redirect('/'); } } public function vendor_event(){ $user_id = $this->session->userdata('user_id'); if($user_id) { $table="users"; $where=array('user_id'=>$user_id,'delete_status'=>'ACTIVE'); $data['user']=$this->bidding_model->get_where_row($table,$where); $bidding_id = $this->uri->segment(2); $table="bidding_session"; $where=array('bidding_session_id'=>$bidding_id); $data['bid']=$this->bidding_model->get_bid_company_name($bidding_id); $table="bidding_item"; $where=array('bidding_session_id'=>$bidding_id); $data['item']=$this->bidding_model->get_where_result($table,$where); $table="bidding_status_table"; $where=array('bidding_id'=>$bidding_id); $data['status']=$this->bidding_model->get_latest_bidding_status($where); $table="bidding_coordinators"; $where=array('bidding_session_id'=>$bidding_id); $data['cordinate']=$this->bidding_model->get_where_result($table,$where); $ur_ids = $this->session->userdata('user_id'); $where=array('user_id'=>$ur_ids); $table="users"; $data['user_usreid']=$this->bidding_model->get_where_row($table,$where); $this->load->view('vendor_event',$data); }else{ redirect('/'); } } public function vendor_event_list(){ $user_id = $this->session->userdata('user_id'); if($user_id) { $table="users"; $where=array('user_id'=>$user_id,'delete_status'=>'ACTIVE'); $data['user']=$this->bidding_model->get_where_row($table,$where); $vendor_list=$this->bidding_model->get_vendor_bidding_client_list($user_id); $arr=array(); foreach($vendor_list as $key => $value) { $table="company_information"; $u_id=$value->company_id; $where=array('user_id'=>$u_id); $u=$this->bidding_model->get_where_row($table,$where); if($u){ $res['company_name']=$u->company_name; }else{ $res['company_name']=$value->company_name; } $res['bidding_date']=$value->final_bidding_date; $res['bidding_title']=$value->bidding_title; $res['bidding_time']=$value->bidding_time; $res['bidding_id']=$value->bidding_session_id; $res['contact_parson']=$value->first_name; $res['mobile']=$value->mobile_no; $res['email']=$value->email; array_push($arr,$res); } $data['com']=$arr; $ur_ids = $this->session->userdata('user_id'); $where=array('user_id'=>$ur_ids); $table="users"; $data['user_usreid']=$this->bidding_model->get_where_row($table,$where); $this->load->view('vendor_event_list',$data); }else{ redirect('/'); } } public function client_event_list(){ $user_id = $this->session->userdata('user_id'); if($user_id) { $table="users"; $where=array('user_id'=>$user_id,'delete_status'=>'ACTIVE'); $data['user']=$this->bidding_model->get_where_row($table,$where); $vendor_list=$this->bidding_model->get_vendor_bidding_client_list($user_id); $arr=array(); foreach($vendor_list as $key => $value) { $table="company_information"; $u_id=$value->company_id; $where=array('user_id'=>$u_id); $u=$this->bidding_model->get_where_row($table,$where); if($u) { $res['company_name']=$u->company_name; }else{ $res['company_name']=''; } $res['bidding_id']=$value->bidding_session_id; $res['bidding_date']=$value->final_bidding_date; $res['bidding_title']=$value->bidding_title; $res['bidding_time']=$value->bidding_time; $res['bidding_id']=$value->bidding_session_id; $res['contact_person']=$value->first_name; $res['mobile']=$value->mobile_no; $res['email']=$value->email; array_push($arr,$res); } $data['com']=$arr; $data_bidding_new=$arr; $osl_details=array(); foreach($data_bidding_new as $f) { // print_R($f); $vendors_id=$f['bidding_id']; $table='bidding_session'; $where=array('bidding_session_id'=>$vendors_id); $tt=$this->bidding_model->get_bid_price_latest($table,$where); $vendor_id=$tt->company_id; $t=$this->bidding_model->get_bidding_vendor($vendor_id); array_push($osl_details,$t); } $data['usres_bid_tab_val']=$osl_details; $ur_ids = $this->session->userdata('user_id'); $where=array('user_id'=>$ur_ids); $table="users"; $data['user_usreid']=$this->bidding_model->get_where_row($table,$where); $this->load->view('client_bid_list',$data); }else{ redirect('/'); } } public function client_event(){ $user_id = $this->session->userdata('user_id'); if($user_id) { $table="users"; $where=array('user_id'=>$user_id,'delete_status'=>'ACTIVE'); $data['user']=$this->bidding_model->get_where_row($table,$where); $bidding_id = $this->uri->segment(2); $table="bidding_session"; $where=array('bidding_session_id'=>$bidding_id); $data['bid']=$this->bidding_model->get_bid_company_name($bidding_id); $table="bidding_item"; $where=array('bidding_session_id'=>$bidding_id); $data['item']=$this->bidding_model->get_where_result($table,$where); $table="bidding_status_table"; $where=array('bidding_id'=>$bidding_id); $data['status']=$this->bidding_model->get_latest_bidding_status($where); $table="bidding_coordinators"; $where=array('bidding_session_id'=>$bidding_id); $data['cordinate']=$this->bidding_model->get_where_result($table,$where); $ur_ids = $this->session->userdata('user_id'); $where=array('user_id'=>$ur_ids); $table="users"; $data['user_usreid']=$this->bidding_model->get_where_row($table,$where); $this->load->view('client_event',$data); }else{ redirect('/'); } } public function sa_vendor_profile_view(){ $user_id = $this->session->userdata('user_id'); if($user_id) { $bidding_id = $this->uri->segment(2); $table="users"; $where=array('user_id'=>$bidding_id); //$where=array('user_id'=>$bidding_id,'delete_status'=>'ACTIVE'); $data['user']=$this->bidding_model->get_where_row($table,$where); $user_ids = $this->session->userdata('user_id'); $table="users"; $where=array('user_id'=>$user_ids,'delete_status'=>'ACTIVE'); $data['user_session']=$this->bidding_model->get_where_row($table,$where); $table="company_information"; $where=array('user_id'=>$bidding_id,'delete_status'=>'ACTIVE'); $data['company']=$this->bidding_model->get_where_row($table,$where); $table="contact_information"; $where=array('user_id'=>$bidding_id,'delete_status'=>'ACTIVE'); $data['contact']=$this->bidding_model->get_where_result($table,$where); $ur_ids = $this->session->userdata('user_id'); $where=array('user_id'=>$ur_ids); $table="users"; $data['user_usreid']=$this->bidding_model->get_where_row($table,$where); $this->load->view('sa_vendor_profile',$data); }else{ redirect('/'); } } public function client_vendor_profile_view(){ $user_id = $this->session->userdata('user_id'); if($user_id) { $bidding_id = $this->uri->segment(2); $table="users"; $where=array('user_id'=>$bidding_id,'delete_status'=>'ACTIVE'); $data['user']=$this->bidding_model->get_where_row($table,$where); $table="company_information"; $where=array('user_id'=>$bidding_id,'delete_status'=>'ACTIVE'); $data['company']=$this->bidding_model->get_where_row($table,$where); $table="contact_information"; $where=array('user_id'=>$bidding_id,'delete_status'=>'ACTIVE'); $data['contact']=$this->bidding_model->get_where_result($table,$where); $ur_ids = $this->session->userdata('user_id'); $where=array('user_id'=>$ur_ids); $table="users"; $data['user_usreid']=$this->bidding_model->get_where_row($table,$where); $this->load->view('client_vendor_profile',$data); }else{ redirect('/'); } } public function get_vendor_client_list(){ $id=$this->input->post('id'); $result=$this->bidding_model->get_vendor_client_list($id); echo json_encode($result); } public function add_bidding_status(){ $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d H:i:s'); $t = $date->format('H:i'); $start_time = date("g:i a", strtotime($t)); $bidding_id=$this->input->post('bidding_id'); $table="bidding_session"; $arr=array('start_biddding_time'=>$start_time); $where=array('bidding_session_id'=>$bidding_id); $this->bidding_model->update_row($where,$arr,$table); $item_id=$this->input->post('item_id'); $bidding_id=$this->input->post('bidding_id'); $status=$this->input->post('status'); $bid_time=$this->input->post('bid_time'); $where=array('item_id'=>$item_id,'bidding_id'=>$bidding_id); $table="bidding_status_table"; $res=$this->bidding_model->get_where_row($table,$where); if($res){ $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date = $date->format('Y-m-d'); $data=array( 'status_new' =>$status, 'flag' =>'1', 'updated_at' =>$date ); $result=$this->bidding_model->update_row($where,$data,$table); echo json_encode(array('result'=>'1')); }else { $data=array( 'item_id' =>$item_id, 'bidding_id' =>$bidding_id, 'status_new' =>$status, 'bid_time' =>$bid_time, 'flag' =>'1', 'created_at' =>$date_format ); $result=$this->bidding_model->insert($table,$data); echo json_encode(array('result'=>'1')); } } public function get_bidding_status(){ $bidding_id=$this->input->post('bidding_id'); $table='bidding_status_table'; $where=array('bidding_id'=>$bidding_id); $count=$this->bidding_model->get_where_result($table,$where); $data['cont']=count($count); $data['res']=$this->bidding_model->get_bidding_status($bidding_id); $table1='bidding_session'; $where1=array('bidding_session_id'=>$bidding_id); $data['bid']=$this->bidding_model->get_where_row($table1,$where1); echo json_encode($data); } public function add_vendor_item_price(){ $r=$this->input->post('item_id'); $g=$this->bidding_model->get_where_joiningrow($r); if($g->close_biddding_time == '') { $table="bidding_price_table"; $user_id = $this->session->userdata('user_id'); $where=array('item_id'=>$this->input->post('item_id'),'bidding_id'=>$this->input->post('bidding_id'),'price'=>$this->input->post('price')); $result_new=$this->bidding_model->get_where_row($table,$where); if($result_new){ echo json_encode(array('result'=>'2','message'=>'price already quoted by someother vendor')); }else{ $where=array('item_id'=>$this->input->post('item_id'),'bidding_id'=>$this->input->post('bidding_id'),'vendor_id'=>$user_id); $result=$this->bidding_model->get_where_row($table,$where); if($result){ $price=$this->input->post('price'); $new_price=$result->price; $r=abs($new_price-$price); $t=ceil($new_price*1/100); if($r>=$t){ $data=array( 'price' =>$this->input->post('price'), 'flag' =>'1' ); $result=$this->bidding_model->update_row($where,$data,$table); $item_id=$this->input->post('item_id'); $bidding_id=$this->input->post('bidding_id'); $min_price=$this->bidding_model->get_min_bidding_price($bidding_id,$item_id); echo json_encode(array('result'=>'1','min'=>$min_price)); }else{ echo json_encode(array('result'=>'3','message'=>'price Should be less than 1% from your best price')); } }else { $data=array( 'item_id' =>$this->input->post('item_id'), 'bidding_id' =>$this->input->post('bidding_id'), 'vendor_id' =>$user_id, 'price' =>$this->input->post('price'), 'flag' =>'1' ); $result=$this->bidding_model->insert($table,$data); $item_id=$this->input->post('item_id'); $bidding_id=$this->input->post('bidding_id'); $min_price=$this->bidding_model->get_min_bidding_price($bidding_id,$item_id); echo json_encode(array('result'=>'1','min'=>$min_price)); } } } else { echo json_encode(array('result'=>'5')); } } public function get_vendor_bidding_price(){ $bidding_id = $this->input->post('bidding_id'); $item_id = $this->input->post('item_id'); $bid = $this->bidding_model->get_vendor_bidding_price($bidding_id,$item_id); $arr = array(); foreach ($bid as $key => $value) { $data['vendor_id'] = $value->vendor_id; $data['company_name'] = $value->company_name; //$data['item_id']=$value->item_id; $table = "bidding_price_table"; $where = array( 'bidding_id' => $bidding_id, 'item_id' => $item_id, 'vendor_id' => $value->vendor_id ); $price=$this->bidding_model->get_where_row($table,$where); if($price){ $data['price']=$price->price; }else{ $data['price']=''; } array_push($arr,$data); } $result['bid']=$arr; $result['min_price']=$this->bidding_model->get_min_bidding_price($bidding_id,$item_id); echo json_encode($result); } public function item_bidding_status(){ $table=" bidding_status_table"; $bidding_id=$this->input->post('bidding_id'); $where=array('bidding_id'=>$bidding_id); $result=$this->bidding_model->get_latest_bidding_status($where); if($result){ echo json_encode(array('result'=>'1','msg'=>$result)); }else{ echo json_encode(array('result'=>'0','msg'=>$result)); } } public function update_bidding_status(){ $item_id=$this->input->post('item_id'); $timer=$this->input->post('timer'); $bidding_id=$this->input->post('bidding_id'); $status=$this->input->post('status'); $table="bidding_status_table"; $where=array('item_id'=>$item_id,'bidding_id'=>$bidding_id); $data=array('status_new'=>$status,'bid_time'=>$timer); $result=$this->bidding_model->update_row($where,$data,$table); if($result){ echo json_encode(array('result'=>'1','message'=>'Item Closed')); }else{ echo json_encode(array('result'=>'0','message'=>'Something Went Wrong')); } } public function update_flag_status(){ $item_id=$this->input->post('item_id'); $bidding_id=$this->input->post('bidding_id'); $flag=$this->input->post('flag'); $table="bidding_status_table"; $where=array('item_id'=>$item_id,'bidding_id'=>$bidding_id); $data=array('flag_execution'=>$flag); $result=$this->bidding_model->update_row($where,$data,$table); if($result){ echo json_encode(array('result'=>'1','message'=>'Item Closed')); }else{ echo json_encode(array('result'=>'0','message'=>'Something Went Wrong')); } } public function update_bidding_time(){ $item_id=$this->input->post('item_id'); $bidding_id=$this->input->post('bidding_id'); $counter_from=$this->input->post('counter_from'); $count=$this->input->post('count'); $table="bidding_status_table"; $where=array('item_id'=>$item_id,'bidding_id'=>$bidding_id); $time=$this->bidding_model->get_where_row($table,$where); $t=$time->total_bid_time; $t+=1; $b=$time->bid_time; $b-=1; if($b < 0) { $b = 0; } $data=array( 'total_bid_time' =>$t, 'bid_time' =>$count ); //print_r($data); $time_data= array('bidding_id'=>$bidding_id,'bid_time'=>$count,'counter_from'=>$counter_from); $time_table = 'testing_time'; $res = $this->bidding_model->insert($time_table,$time_data); //---------------------------------------new-------------------------------// $i = 0; $varray = array(); $min_price=$this->bidding_model->get_min_bidding_price($bidding_id,$item_id); foreach($min_price as $value) { $i = $i + 1; if($i<=3) { array_push($varray,$value->vendor_id); } } // print_r($varray); //-------------------------------------------------------------------------// $result=$this->bidding_model->update_row($where,$data,$table); if($this->db->affected_rows() > 0) { echo json_encode(array('result'=>'1','msg'=>$time,'message'=>'update time closed')); }else{ echo json_encode(array('result'=>'0','message'=>'Something Went Wrong')); } } public function view_current_bidding_time(){ $item_id=$this->input->post('item_id'); $bidding_id=$this->input->post('bidding_id'); $table="bidding_status_table"; $where=array('item_id'=>$item_id,'bidding_id'=>$bidding_id); $res=$this->bidding_model->get_where_row($table,$where); if($res){ echo json_encode(array('result'=>$res,'message'=>'update time closed')); }else{ echo json_encode(array('result'=>'0','message'=>'Something Went Wrong')); } } public function view_total_bidding_time(){ $bidding_id=$this->input->post('bidding_id'); $table="bidding_status_table"; $res=$this->bidding_model->get_total_bidding_time($bidding_id); if($res){ echo json_encode(array('result'=>$res,'message'=>'update time closed')); }else{ echo json_encode(array('result'=>'0','message'=>'Something Went Wrong')); } } public function update_vendor_item_price(){ $r = $this->input->post('item_id'); $g = $this->bidding_model->get_where_joiningrow($r); if($g->close_biddding_time == '') { $table = "bidding_price_table"; $where = array('item_id'=>$this->input->post('item_id'),'bidding_id'=>$this->input->post('bidding_id'),'price'=>$this->input->post('price')); $price = $this->input->post('price'); $result = $this->bidding_model->get_where_row($table,$where); if($result){ echo json_encode(array('result'=>'2','msg'=>'price already quoted by the someother vendor')); }else{ $where = array('item_id'=>$this->input->post('item_id'),'bidding_id'=>$this->input->post('bidding_id'),'vendor_id'=>$this->input->post('vendor_id')); $results = $this->bidding_model->get_where_row($table,$where); if($results){ $new_price = $results->price; $r = abs($new_price-$price); $t = ceil($new_price*1/100); if($r>=$t){ $data = array( 'price' => $this->input->post('price'), 'flag' => '1' ); $resulta = $this->bidding_model->update_row($where,$data,$table); $item_id = $this->input->post('item_id'); $bidding_id = $this->input->post('bidding_id'); $min_price = $this->bidding_model->get_min_bidding_price($bidding_id,$item_id); echo json_encode(array('result'=>'1','min'=>$min_price,'msg'=>'updated')); }else{ echo json_encode(array('result'=>'3','msg'=>'Price should be less than 1% from your best price')); } }else{ $data1=array( 'item_id' => $this->input->post('item_id'), 'bidding_id' => $this->input->post('bidding_id'), 'vendor_id' => $this->input->post('vendor_id'), 'flag' => '1', 'price' => $this->input->post('price') ); $table1 = "bidding_price_table"; $result = $this->bidding_model->insert($table1,$data1); $item_id = $this->input->post('item_id'); $bidding_id = $this->input->post('bidding_id'); $min_price = $this->bidding_model->get_min_bidding_price($bidding_id,$item_id); echo json_encode(array('result'=>'1','msg'=>'updated','min'=>$min_price)); } } } else { echo json_encode(array('result'=>'5')); } } public function test_bid_count() { $bidding_id=$this->input->post('bidding_id'); $item_id=$this->input->post('item_id'); $timer=$this->input->post('count'); $table="bidding_status_table"; $where=array('item_id'=>$item_id,'bidding_id'=>$bidding_id); $data=array('bid_time'=>$timer); $result=$this->bidding_model->update_row($where,$data,$table); $min_price=$this->bidding_model->get_min_bidding_price($bidding_id,$item_id); echo json_encode(array('result'=>'1','msg'=>'updated','min'=>$min_price)); } public function get_min_individual_bidding_price(){ $bidding_id=$this->input->post('bidding_id'); $item_id=$this->input->post('item_id'); $res=$this->bidding_model->get_min_individual_bidding_price_new($bidding_id,$item_id); echo json_encode($res); } public function get_bidding_time(){ $bidding_id=$this->input->post('bidding_id'); $item_id=$this->input->post('item_id'); $where=array('item_id'=>$item_id,'bidding_id'=>$bidding_id); $table="bidding_status_table"; $res=$this->bidding_model->get_where_row($table,$where); echo json_encode($res); } //dashboard public function iadmin_dashboard(){ $user_id = $this->session->userdata('user_id'); if($user_id) { $table="company_information"; $where=array('delete_status'=>'ACTIVE'); $client=$this->bidding_model->get_iadmin_client_user_detail($table,$where); $user_id = $this->session->userdata('user_id'); $table="company_information"; $where=array('delete_status'=>'ACTIVE'); //$comapny=$this->bidding_model->get_iadmin_client_user_detail($table,$where); $comapny=$this->bidding_model->get_iadmin_clientss_user_detail($table,$where); $arr=array(); foreach ($comapny as $key => $value) { $data['company_name']=$value->cname; $data['first_name']=$value->first_name; $data['mobile_no']=$value->mobile_no; $data['email']=$value->email; $data['date_of_creation']=$value->date_of_creation; $data['date_of_expiry']=$value->date_of_expiry; $data['contact_person']=$value->contact_person; $data['segment']=json_decode($value->industries); $data['user_id']=$value->user_id; $table="users"; $where=array('user_id'=>$value->assigned_iadmin); $data['admin']=$this->bidding_model->get_where_row($table,$where); array_push($arr,$data); } $data['company']=$arr; // $data['client']=count($client); $data['client']=count($arr); $table="users"; $where=array('user_type_id'=>'2','delete_status'=>'ACTIVE'); $iadmin=$this->bidding_model->get_where_result($table,$where); $data['iadmin']=count($iadmin); $active_licence=$this->bidding_model->get_iadmin_active_licences(); $data['license']=count($active_licence); $renewal_license=$this->bidding_model->get_licences_iadmin_for_renewal(); $data['renewal']=count($renewal_license); $renewal_next_month=$this->bidding_model->get_renewal_iadmin_for_next_month(); $data['renew_next']=count($renewal_next_month); $table="users"; $where=array('user_id'=>$user_id,'delete_status'=>'ACTIVE'); $data['user']=$this->bidding_model->get_where_row($table,$where); $ur_ids = $this->session->userdata('user_id'); $where=array('user_id'=>$ur_ids); $table="users"; $data['user_usreid']=$this->bidding_model->get_where_row($table,$where); $this->load->view('iadmin_home',$data); }else{ redirect('/'); } } //Sa client create list public function iadmin_client_add(){ $user_id = $this->session->userdata('user_id'); $table="users"; $where=array('delete_status'=>'ACTIVE','user_type_id'=>'2'); $data['iadmin']=$this->bidding_model->get_where_result($table,$where); if($user_id) { $ur_ids = $this->session->userdata('user_id'); $where=array('user_id'=>$ur_ids); $table="users"; $data['user_usreid']=$this->bidding_model->get_where_row($table,$where); $this->load->view('iadmin_client',$data); }else{ redirect('/'); } } public function add_iadmin_client(){ $user_id = $this->session->userdata('user_id'); $company_name=$this->input->post('company_name'); $contact_person=$this->input->post('contact_person'); $email_id=$this->input->post('email_id'); $mobile_number=$this->input->post('mobile_number'); $date_of_creation=$this->input->post('date_of_creation'); $date_of_creation=date('Y-m-d',strtotime($date_of_creation)); $date_of_expiryy=$this->input->post('date_of_expiry'); $date_of_expiry=date('Y-m-d',strtotime($date_of_expiryy)); $assigned_admin=$this->input->post('assigned_admin'); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d H:i:s'); $password='iclient'; $pass_prefix = '$2a$05$'; $pass_suffix = '$'; $Allowed_Chars ='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789./'; $Chars_Len = 63; $Salt_Length = 21; $salt_password = ""; for($i=0; $i<=$Salt_Length; $i++) { $salt_password .= $Allowed_Chars[mt_rand(0,$Chars_Len)]; } $encrypted_pass = $pass_prefix . $salt_password . $pass_suffix; $hashed_password = crypt($password,$encrypted_pass); $data=array( 'first_name' => $contact_person, 'company_name' => $company_name, 'email' => $email_id, 'mobile_no' => $mobile_number, 'salt' => $salt_password, 'password' => $hashed_password, 'assigned_iadmin' => $user_id, 'user_type_id' => '3', 'user_name' => $email_id, 'date_of_creation' => $date_of_creation, 'date_of_expiry' => $date_of_expiry, 'created_at' => $date_format ); $table="users"; $result=$this->bidding_model->insert($table,$data); if($result){ echo json_encode(array('result'=>1,'message'=>"Added Sucessfully")); }else{ echo json_encode(array('result'=>0,'message'=>"Not Added")); } } public function sa_iadmin_client_list(){ $user_id = $this->session->userdata('user_id'); if($user_id) { $table="company_information"; $where=array('delete_status'=>'ACTIVE'); //$comapny=$this->bidding_model->get_iadmin_client_user_detail($table,$where); $comapny=$this->bidding_model->get_iadmin_clientss_user_detail($table,$where); $arr=array(); foreach ($comapny as $key => $value) { $data['company_name']=$value->cname; $data['first_name']=$value->first_name; $data['mobile_no']=$value->mobile_no; $data['email']=$value->email; $data['date_of_creation']=$value->date_of_creation; $data['date_of_expiry']=$value->date_of_expiry; $data['contact_person']=$value->contact_person; $data['segment']=json_decode($value->industries); $data['user_id']=$value->user_id; $table="users"; $where=array('user_id'=>$value->assigned_iadmin); $data['admin']=$this->bidding_model->get_where_row($table,$where); array_push($arr,$data); } $data['company']=$arr; $ur_ids = $this->session->userdata('user_id'); $where=array('user_id'=>$ur_ids); $table="users"; $data['user_usreid']=$this->bidding_model->get_where_row($table,$where); $this->load->view('iadmin_client_list',$data); }else{ redirect('/'); } } //Sa vendor create public function iadmin_vendor_add(){ $user_id = $this->session->userdata('user_id'); if($user_id) { $ur_ids = $this->session->userdata('user_id'); $where=array('user_id'=>$ur_ids); $table="users"; $data['user_usreid']=$this->bidding_model->get_where_row($table,$where); $this->load->view('iadmin_vendor_add'); }else{ redirect('/'); } } public function iadmin_vendor_list(){ $user_id = $this->session->userdata('user_id'); if($user_id) { $table="users"; $where=array('user_id'=>$user_id,'delete_status'=>'ACTIVE'); $data['user']=$this->bidding_model->get_where_row($table,$where); // print_R($user_id); // die(); // $where=array('user_type_id'=>4,'assigned_iadmin'=>$user_id,'delete_vendor'=>'ACTIVE'); $vendor=$this->bidding_model->get_where_ivendorsresult($table,$user_id); $arr=array(); foreach($vendor as $key => $value) { $client=$this->bidding_model->get_vendor_client_list($value->user_id); $client=$this->bidding_model->get_vendor_client_list($value->user_id); $user=$this->bidding_model->get_user_vendor_client_detail($value->user_id); $res['client_count']=count($client); $res['company_name']=$value->company_name; $res['first_name']=$value->first_name; $res['email']=$value->email; $res['mobile_no']=$value->mobile_no; $res['industries']=$user->industries; $res['user_id']=$value->user_id; array_push($arr,$res); } $data['vendor']=$arr; $ur_ids = $this->session->userdata('user_id'); $where=array('user_id'=>$ur_ids); $table="users"; $data['user_usreid']=$this->bidding_model->get_where_row($table,$where); $this->load->view('iadmin_vendor_list',$data); }else{ redirect('/'); } } public function admin_vendor_edit(){ $user_id = $this->session->userdata('user_id'); if($user_id) { $vendor_id = $this->uri->segment(2); $where=array('user_id'=>$vendor_id,'delete_status'=>'ACTIVE'); $table="users"; $data['user']=$this->bidding_model->get_where_row($table,$where); $ur_ids = $this->session->userdata('user_id'); $where=array('user_id'=>$ur_ids); $table="users"; $data['user_usreid']=$this->bidding_model->get_where_row($table,$where); $this->load->view('edit_admin_vendor',$data); }else{ redirect('/'); } } public function client_vendor_edit(){ $user_id = $this->session->userdata('user_id'); if($user_id) { $vendor_id = $this->uri->segment(2); $where=array('user_id'=>$vendor_id,'delete_status'=>'ACTIVE'); $table="users"; $data['user']=$this->bidding_model->get_where_row($table,$where); $ur_ids = $this->session->userdata('user_id'); $where=array('user_id'=>$ur_ids); $table="users"; $data['user_usreid']=$this->bidding_model->get_where_row($table,$where); $this->load->view('edit_client_vendor',$data); }else{ redirect('/'); } } public function update_vendor(){ $company_name=$this->input->post('company_name'); $contact_person=$this->input->post('contact_person'); $email_id=$this->input->post('email_id'); $mobile_number=$this->input->post('mobile_number'); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $user_id = $this->input->post('user_id'); $table="users"; $where=array('email'=>$email_id,'user_id !='=>$user_id); $user_list=$this->bidding_model->get_where_row($table,$where); if(empty($user_list)) { $data=array( 'first_name' => $contact_person, 'company_name' => $company_name, 'email' => $email_id, 'mobile_no' => $mobile_number, 'user_name' => $email_id, 'user_type_id' => '4', 'updated_at' => $date_format ); $table="users"; $where=array('user_id'=>$this->input->post('user_id')); $result=$this->bidding_model->update_row($where,$data,$table); if($result){ echo json_encode(array('result'=>1,'message'=>"Updated Sucessfully")); }else{ echo json_encode(array('result'=>0,'message'=>"Not Updated")); } } else { echo json_encode(array('result'=>2,'message'=>"This Email Id Already Exist")); } } public function admin_client_edit(){ $user_id = $this->session->userdata('user_id'); if($user_id) { $vendor_id = $this->uri->segment(2); $where=array('user_id'=>$vendor_id,'delete_status'=>'ACTIVE'); $table="users"; $data['user']=$this->bidding_model->get_where_row($table,$where); $where=array('user_id'=>$user_id); $table="users"; $data['user_usreid']=$this->bidding_model->get_where_row($table,$where); $ur_ids = $this->session->userdata('user_id'); $where=array('user_id'=>$ur_ids); $table="users"; $data['user_usreid']=$this->bidding_model->get_where_row($table,$where); $this->load->view('iadmin_client_edit',$data); }else{ redirect('/'); } } //add client public function update_iadmin_client(){ $company_name=$this->input->post('company_name'); $contact_person=$this->input->post('contact_person'); $email_id=$this->input->post('email_id'); $mobile_number=$this->input->post('mobile_number'); $date_of_creation=$this->input->post('date_of_creation'); $date_of_creation=date('Y-m-d',strtotime($date_of_creation)); $date_of_expiry=$this->input->post('date_of_expiry'); $date_of_expiry=date('Y-m-d',strtotime($date_of_expiry)); $assigned_admin=$this->input->post('assigned_admin'); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $data=array( 'first_name' => $contact_person, 'company_name' => $company_name, 'email' => $email_id, 'mobile_no' => $mobile_number, 'user_name' => $email_id, 'date_of_creation' => $date_of_creation, 'date_of_expiry' => $date_of_expiry, 'updated_at' => $date_format ); $table="users"; $where=array('user_id'=>$this->input->post('user_id')); $result=$this->bidding_model->update_row($where,$data,$table); if($result){ echo json_encode(array('result'=>1,'message'=>"Updated Sucessfully")); }else{ echo json_encode(array('result'=>0,'message'=>"Not Updated")); } } public function update_sa_edit(){ $user_id = $this->session->userdata('user_id'); if($user_id) { $vendor_id = $this->uri->segment(2); $where=array('user_id'=>$vendor_id,'delete_status'=>'ACTIVE'); $table="users"; $data['user']=$this->bidding_model->get_where_row($table,$where); $table="users"; $where=array('delete_status'=>'ACTIVE','user_type_id'=>'2'); $data['iadmin']=$this->bidding_model->get_where_asc_result($table,$where); $where=array('user_id'=>$user_id); $table="users"; $data['user_usreid']=$this->bidding_model->get_where_row($table,$where); $ur_ids = $this->session->userdata('user_id'); $where=array('user_id'=>$ur_ids); $table="users"; $data['user_usreid']=$this->bidding_model->get_where_row($table,$where); $this->load->view('sa_client_edit',$data); }else{ redirect('/'); } } public function update_sa_vendor(){ $vendor_id = $this->uri->segment(2); // $where=array('user_id'=>$vendor_id,'delete_status'=>'ACTIVE'); $where=array('user_id'=>$vendor_id); $table="users"; $data['user']=$this->bidding_model->get_where_row($table,$where); $ur_ids = $this->session->userdata('user_id'); $where=array('user_id'=>$ur_ids); $table="users"; $data['user_usreid']=$this->bidding_model->get_where_row($table,$where); $this->load->view('sa_vendor_edit',$data); } public function edit_client(){ $company_name=$this->input->post('company_name'); $contact_person=$this->input->post('contact_person'); $email_id=$this->input->post('email_id'); $mobile_number=$this->input->post('mobile_number'); $date_of_creation=$this->input->post('date_of_creation'); $date_of_creation=date('Y-m-d',strtotime($date_of_creation)); $date_of_expiry=$this->input->post('date_of_expiry'); $date_of_expiry=date('Y-m-d',strtotime($date_of_expiry)); $assigned_admin=$this->input->post('assigned_admin'); $user_id=$this->input->post('user_id'); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); //$table="users"; // $where=array('email'=>$email_id,'user_id !='=>$user_id); //$user_list=$this->bidding_model->get_where_row($table,$where); // if(empty($user_list)) // { $data=array( 'first_name' => $contact_person, 'company_name' => $company_name, 'email' => $email_id, 'mobile_no' => $mobile_number, 'assigned_iadmin' => $assigned_admin, 'user_name' => $email_id, 'date_of_creation' => $date_of_creation, 'date_of_expiry' => $date_of_expiry, 'updated_at' => $date_format ); $table="users"; $where=array('user_id'=>$user_id); $result=$this->bidding_model->update_row($where,$data,$table); if($result){ echo json_encode(array('result'=>1,'message'=>"Updated Sucessfully")); }else{ echo json_encode(array('result'=>0,'message'=>"Not Updated")); } // } // else // { // echo json_encode(array('result'=>2,'message'=>"This Email Id Already Exist")); // } } public function delete_procurement_event(){ $bidding_id=$this->input->post('id'); $table="bidding_session"; $where=array('bidding_session_id'=>$bidding_id); $res=$this->bidding_model->delete_row($where,$table); if($res){ $table="bidding_item"; $where=array('bidding_session_id'=>$bidding_id); $res=$this->bidding_model->delete_row($where,$table); $table="vendor_bidding_table"; $where=array('bidding_id'=>$bidding_id); $res=$this->bidding_model->delete_row($where,$table); echo json_encode(array('result'=>1,'message'=>"Deletion Completed")); }else{ echo json_encode(array('result'=>0,'message'=>"Something went wrong")); } } //Sa vendor create public function client_vendor_add(){ $user_id = $this->session->userdata('user_id'); if($user_id) { $table="users"; $where=array('user_id'=>$user_id,'delete_status'=>'ACTIVE'); $data['user']=$this->bidding_model->get_where_row($table,$where); $ur_ids = $this->session->userdata('user_id'); $where=array('user_id'=>$ur_ids); $table="users"; $data['user_usreid']=$this->bidding_model->get_where_row($table,$where); $this->load->view('client_vendor_add',$data); }else{ redirect('/'); } } public function client_vendor_list(){ $user_id = $this->session->userdata('user_id'); $this->session->userdata('user_id'); if($user_id) { $table="users"; $where=array('user_id'=>$user_id,'delete_status'=>'ACTIVE'); $data['user']=$this->bidding_model->get_where_row($table,$where); // print_R($user_id); // die(); // $where=array('user_type_id'=>4,'assigned_iadmin'=>$user_id,'delete_vendor'=>'ACTIVE'); $vendor=$this->bidding_model->get_where_ivendorsresult($table,$user_id); $arr=array(); foreach($vendor as $key => $value) { $client=$this->bidding_model->get_vendor_client_list($value->user_id); $user=$this->bidding_model->get_user_vendor_client_detail($value->user_id); $res['client_count']=count($client); if($user){ $res['company_name']=$user->company_name; $res['first_name']=$user->first_name; $res['email']=$user->email; $res['mobile_no']=$user->mobile_no; $res['industries']=$user->industries; $res['user_id']=$value->user_id; array_push($arr,$res); } } $vendors=$this->bidding_model->get_iadmin_vendor_list_new($user_id); $arra=array(); foreach($vendors as $key => $value) { $client=$this->bidding_model->get_vendor_client_list($value->user_id); $user=$this->bidding_model->get_user_client_detail($value->user_id); $res['client_count']=count($client); if($user){ $res['company_name']=$user->company_name; $res['first_name']=$user->first_name; $res['email']=$user->email; $res['mobile_no']=$user->mobile_no; $res['industries']=$user->industries; $res['user_id']=$value->user_id; array_push($arr,$res); } } $result = array(); foreach ($arr as $key => $value){ if(!in_array($value, $result)) $result[$key]=$value; } $data['vendor']=$result; // $data['vendor']=$arra; $ur_ids = $this->session->userdata('user_id'); $where=array('user_id'=>$ur_ids); $table="users"; $data['user_usreid']=$this->bidding_model->get_where_row($table,$where); $this->load->view('client_vendor_list',$data); }else{ redirect('/'); } } public function get_vendor_bid_price(){ $bidding_id=$this->input->post('bidding_id'); $vendor_id=$this->input->post('vendor_id'); $item_id=$this->input->post('item_id'); $table="bidding_price_table"; $where=array('vendor_id'=>$vendor_id,'bidding_id'=>$bidding_id,'item_id'=>$item_id); $res=$this->bidding_model->get_where_row($table,$where); //echo json_encode($res); if($res) { echo json_encode(array('result' => 1,'data'=>$res)); } else { echo json_encode(array('result' => 0)); } } public function update_flag(){ $item_id=$this->input->post('item_id'); $bidding_id=$this->input->post('bidding_id'); $where=array('item_id'=>$item_id,'bidding_id'=>$bidding_id); $table="bidding_status_table"; $data=array( 'flag' =>'0', ); $result=$this->bidding_model->update_row($where,$data,$table); echo json_encode(array('result'=>$result)); } public function reset_line_item(){ $item_id=$this->input->post('item_id'); $bidding_id=$this->input->post('bidding_id'); $count=$this->input->post('count'); // $where=array('bidding_id'=>$bidding_id,'item_id'=>$item_id); // $table="bidding_price_table"; // $res=$this->bidding_model->delete_row($where,$table); $where=array('bidding_session_id'=>$bidding_id); $table="bidding_session"; $t=$this->bidding_model->get_where_row($table,$where); $status=$this->input->post('status'); $where1=array('item_id'=>$item_id,'bidding_id'=>$bidding_id); $table1="bidding_status_table"; $data=array( 'status_new' =>$status, //'bid_time' =>$t->bidding_limit_time, 'bid_time' =>$count, //added on 31-8-2019 'flag'=>'1' ); $res_time=$t->bidding_limit_time; $result=$this->bidding_model->update_row($where1,$data,$table1); // die(); if($this->db->affected_rows() > 0) { echo json_encode(array('result'=>$result,'bid_time'=>$res_time)); } } public function reset_line_item_new(){ $item_id=$this->input->post('item_id'); $bidding_id=$this->input->post('bidding_id'); $where=array('bidding_id'=>$bidding_id,'item_id'=>$item_id); $table="bidding_price_table"; $res=$this->bidding_model->delete_row($where,$table); if($res){ $where1=array('bidding_session_id'=>$bidding_id); $table1="bidding_session"; $t=$this->bidding_model->get_where_row($table1,$where1); $status=$this->input->post('status'); $where2=array('item_id'=>$item_id,'bidding_id'=>$bidding_id); $table2="bidding_status_table"; $data=array( 'status_new' =>$status, 'bid_time' =>$t->bidding_limit_time, 'flag'=>'1' ); $res_time=$t->bidding_limit_time; $result=$this->bidding_model->update_row($where2,$data,$table2); echo json_encode(array('result'=>$result,'bid_time'=>$res_time)); } } public function reset_bidding_session(){ $bidding_id=$this->input->post('bidding_id'); $bid_date=$this->input->post('final_bidding_date'); $final_bidding_time=$this->input->post('final_bidding_time'); $table="bidding_session"; $data=array( 'final_bidding_date' => date('Y-m-d',strtotime($bid_date)), 'bidding_time' =>$final_bidding_time ); $where=array('bidding_session_id'=>$bidding_id); $result=$this->bidding_model->update_row($where,$data,$table); if($result){ echo json_encode(array('result'=>'1','message'=>'Updated Sucessfully')); }else{ echo json_encode(array('result'=>'0','message'=>'Updated Sucessfully')); } } public function close_bidding_session(){ $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $t = $date->format('H:i'); //print_r($t); $close_time = date("g:i a", strtotime($t)); // $close_time = date("h:i a"); // date("%h:%i %a"; $bidding_id=$this->input->post('bidding_id'); $table="bidding_session"; $arr=array('status'=>'COMPLETED','updated_at'=>$date_format,'close_biddding_time'=>$close_time); $where=array('bidding_session_id'=>$bidding_id); $result=$this->bidding_model->update_row($where,$arr,$table); if($result){ echo json_encode(array('result'=>'1','message'=>'Updated Sucessfully')); }else{ echo json_encode(array('result'=>'0','message'=>'Updated Sucessfully')); } } public function bidding_time(){ $bidding_id=$this->input->post('bidding_id'); $result=$this->bidding_model->get_total_bidding_time($bidding_id); $t=$result->total_bid_time; $v=$t/60; $str=explode('.',$v); $s=count($str); if($s==2){ $min=$str[0]; $sec='0.'.$str[1]; $sec=ceil($sec*60); }else{ $min=0; $sec=0; } echo json_encode(array('min'=>$min,'sec'=>$sec)); } public function check_status(){ $bidding_id = $this->input->post('bidding_id'); $item_id = $this->input->post('item_id'); $table = "bidding_status_table"; $where = array('item_id'=>$item_id,'bidding_id'=>$bidding_id); $result['res'] = $this->bidding_model->get_where_row($table,$where); echo json_encode($result); } public function check_vendor_price(){ $bidding_id=$this->input->post('bidding_id'); $item_id=$this->input->post('item_id'); $table="bidding_price_table"; $where=array('bidding_id'=>$bidding_id,'flag'=>'1'); $result['res']=$this->bidding_model->get_where_row($table,$where); $result['min']=$this->bidding_model->get_least_min_bidding_price($bidding_id,$item_id); echo json_encode($result); } public function update_flag_new(){ $bidding_id=$this->input->post('bidding_id'); $item_id=$this->input->post('item_id'); $vendor_id=$this->input->post('vendor_id'); $table="bidding_price_table"; $where=array('bidding_id'=>$bidding_id,'item_id'=>$item_id,'vendor_id'=>$vendor_id); $data=array('flag'=>'0'); $res=$this->bidding_model->update_row($where,$data,$table); echo json_encode($res); } public function delete_item(){ $item_id=$this->input->post('id'); $table="bidding_item"; $where=array('item_id'=>$item_id); $res=$this->bidding_model->delete_row($where,$table); if($res){ echo json_encode(array('result'=>1,'message'=>"Deletion Completed")); }else{ echo json_encode(array('result'=>0,'message'=>"Something went wrong")); } } public function delete_coordinator(){ $item_id=$this->input->post('id'); $table="bidding_coordinators"; $where=array('id'=>$item_id); $res=$this->bidding_model->delete_row($where,$table); if($res){ echo json_encode(array('result'=>1,'message'=>"Deletion Completed")); }else{ echo json_encode(array('result'=>0,'message'=>"Something went wrong")); } } public function delete_vendor(){ $vendor_id=$this->input->post('id'); $bid_id=$this->input->post('bid_id'); $table="vendor_bidding_table"; $where=array('user_id'=>$vendor_id,'bidding_id'=>$bid_id); $res=$this->bidding_model->delete_row($where,$table); if($res){ echo json_encode(array('result'=>1,'message'=>"Deletion Completed")); }else{ echo json_encode(array('result'=>0,'message'=>"Something went wrong")); } } public function delete_clients_vendor(){ $vendor_id=$this->input->post('id'); $bid_id=$this->input->post('bid_id'); $table="vendor_bidding_table"; $where=array('user_id'=>$vendor_id,'bidding_id'=>$bid_id); // $res=$this->bidding_model->delete_row($where,$table); $res=1; if($res){ echo json_encode(array('result'=>1,'message'=>"Deletion Completed")); }else{ echo json_encode(array('result'=>0,'message'=>"Something went wrong")); } } public function item_description(){ $user_id = $this->session->userdata('user_id'); if($user_id) { $table="users"; $where=array('user_id'=>$user_id,'delete_status'=>'ACTIVE'); $data['user']=$this->bidding_model->get_where_row($table,$where); $bidding_id = $this->uri->segment(2); $data['bidding']=$this->bidding_model->get_bidding_company($bidding_id); $table="bidding_item"; $where=array('bidding_session_id'=>$bidding_id); $data['item']=$this->bidding_model->get_where_result($table,$where); $ur_ids = $this->session->userdata('user_id'); $where=array('user_id'=>$ur_ids); $table="users"; $data['user_usreid']=$this->bidding_model->get_where_row($table,$where); $this->load->view('item_description',$data); }else{ redirect('/'); } } public function vendor_item_description(){ $user_id = $this->session->userdata('user_id'); if($user_id) { $table="users"; $where=array('user_id'=>$user_id,'delete_status'=>'ACTIVE'); $data['user']=$this->bidding_model->get_where_row($table,$where); $bidding_id = $this->uri->segment(2); $data['bidding']=$this->bidding_model->get_bidding_company($bidding_id); $table="bidding_item"; $where=array('bidding_session_id'=>$bidding_id); $data['item']=$this->bidding_model->get_where_result($table,$where); $ur_ids = $this->session->userdata('user_id'); $where=array('user_id'=>$ur_ids); $table="users"; $data['user_usreid']=$this->bidding_model->get_where_row($table,$where); $this->load->view('vendor_item_description',$data); }else{ redirect('/'); } } public function bidding_history(){ $user_id = $this->session->userdata('user_id'); if($user_id) { $table="users"; $where=array('user_id'=>$user_id,'delete_status'=>'ACTIVE'); $data['user']=$this->bidding_model->get_where_row($table,$where); $table="bidding_session"; $where=array('company_id'=>$user_id,'status'=>'COMPLETED'); $order_by='final_bidding_date'; $data['bidding']=$this->bidding_model->get_where_orderby_row($table,$where,$order_by); $data['bidding_new']=$this->bidding_model->get_client_new_bidding_events(); $ur_ids = $this->session->userdata('user_id'); $where=array('user_id'=>$ur_ids); $table="users"; $data['user_usreid']=$this->bidding_model->get_where_row($table,$where); $this->load->view('bidding_history',$data); }else{ redirect('/'); } } public function bidding_client_report_new(){ $user_id = $this->session->userdata('user_id'); if($user_id) { $table="users"; $where=array('user_id'=>$user_id,'delete_status'=>'ACTIVE'); $data['user']=$this->bidding_model->get_where_row($table,$where); $bidding_id = $this->uri->segment(2); $table="bidding_item"; $where=array('bidding_session_id'=>$bidding_id); $item=$this->bidding_model->get_where_result($table,$where); $arr=array(); foreach($item as $key => $value) { $res['item_name']=$value->item_name; $res['item_id']=$value->item_id; $res['specification']=$value->specification; $res['quantity']=$value->quantity; $table="bidding_price_table"; $where=array('bidding_id'=>$bidding_id,'item_id'=>$value->item_id); $res['price']=$vendor=$this->bidding_model->get_bid_price($table,$where); $ar=array(); foreach($vendor as $key => $v) { $t=$this->bidding_model->get_bidding_vendor($v->vendor_id); array_push($ar,$t); } $res['vendor']=$ar; array_push($arr,$res); } $data['item']=$arr; $table="bidding_session"; $where=array('bidding_session_id'=>$bidding_id); $bid=$this->bidding_model->get_where_row($table,$where); $data['bid']=$bid; $table="vendor_bidding_table"; $where=array('bidding_id'=>$bidding_id); $vendor=$this->bidding_model->get_where_result($table,$where); $data['vendor']=count($vendor); $ur_ids = $this->session->userdata('user_id'); $where=array('user_id'=>$ur_ids); $table="users"; $data['user_usreid']=$this->bidding_model->get_where_row($table,$where); $this->load->view('bidding_client_report',$data); }else{ redirect('/'); } } public function vendor_history(){ $user_id = $this->session->userdata('user_id'); if($user_id) { $table="users"; $where=array('user_id'=>$user_id,'delete_status'=>'ACTIVE'); $data['user']=$this->bidding_model->get_where_row($table,$where); $table="bidding_session"; $where=array('company_id'=>$user_id,'status'=>'COMPLETED'); $order_by='final_bidding_date'; $data['bidding']=$this->bidding_model->get_where_orderby_row($table,$where,$order_by); $ur_ids = $this->session->userdata('user_id'); $where=array('user_id'=>$ur_ids); $table="users"; $data['user_usreid']=$this->bidding_model->get_where_row($table,$where); $this->load->view('bidding_vendor_history',$data); }else{ redirect('/'); } } public function update_ivendor(){ $company_name=$this->input->post('company_name'); $vendor_user_id=$this->input->post('vendor_user_id'); $contact_person=$this->input->post('contact_person'); $email_id=$this->input->post('email_id'); $mobile_number=$this->input->post('mobile_number'); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d H:i:s'); $password='ivendor'; $pass_prefix = '$2a$05$'; $pass_suffix = '$'; $Allowed_Chars ='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789./'; $Chars_Len = 63; $Salt_Length = 21; $salt_password = ""; for($i=0; $i<=$Salt_Length; $i++) { $salt_password .= $Allowed_Chars[mt_rand(0,$Chars_Len)]; } $encrypted_pass = $pass_prefix . $salt_password . $pass_suffix; $hashed_password = crypt($password,$encrypted_pass); $table="users"; $where=array('email'=>$email_id,'user_id !='=>$vendor_user_id); $user_list=$this->bidding_model->get_where_row($table,$where); // if(empty($user_list)) //{ $data=array( 'first_name' => $contact_person, 'company_name' => $company_name, 'email' => $email_id, 'mobile_no' => $mobile_number, 'salt' => $salt_password, 'password' => $hashed_password, 'user_name' => $email_id, 'user_type_id' => '4', 'assigned_iadmin' => $this->session->userdata('user_id'), 'created_at' => $date_format ); $table="users"; $where=array('user_id'=>$vendor_user_id); $result=$this->bidding_model->update_row($where,$data,$table); if($result){ echo json_encode(array('result'=>1,'message'=>"Updated Sucessfully")); }else{ echo json_encode(array('result'=>0,'message'=>"Not Updated")); } // } // // else // { // echo json_encode(array('result'=>2,'message'=>"This Email Id Already Exist")); // } } public function add_item(){ $table="demo_item"; $where=array('delete_status'=>'ACTIVE'); $res=$this->bidding_model->delete_row($where,$table); if($res){ include '../PHPExcel/IOFactory.php'; if(isset($_FILES['item_file']['name'])) { $file_name = $_FILES['item_file']['name']; $ext = pathinfo($file_name, PATHINFO_EXTENSION); if($ext == "xlsx" || $ext == "xls"||$ext == "csv") { $file_name = $_FILES['item_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 = 'leads'; if(count($allDataInSheet)>0){ for($i = 2;$i <= $arrayCount;$i++){ $item_name = trim($allDataInSheet[$i]["A"]); $specification = trim($allDataInSheet[$i]["B"]); $quantity = trim($allDataInSheet[$i]["C"]); $ar=array( 'demo_item_name' =>$item_name, 'demo_item_specification' =>$specification, 'demo_item_quantity' =>$quantity, 'delete_status' =>'ACTIVE' ); $table="demo_item"; $item_id=$this->bidding_model->insert($table,$ar); } } echo json_encode(array('result'=>'1','msg'=>'Sucessful')); } } } } public function get_item(){ $table="demo_item"; $where=array('delete_status'=>'ACTIVE'); $result=$this->bidding_model->get_where_result($table,$where); echo json_encode($result); } public function add_vendor(){ $table="demo_vendor"; $where=array('delete_status'=>'ACTIVE'); $res=$this->bidding_model->delete_row($where,$table); if($res){ include '../PHPExcel/IOFactory.php'; if(isset($_FILES['vendor_file']['name'])) { $file_name = $_FILES['vendor_file']['name']; $ext = pathinfo($file_name, PATHINFO_EXTENSION); if($ext == "xlsx" || $ext == "xls" || $ext == "csv") { $file_name = $_FILES['vendor_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 = 'demo_vendor'; if(count($allDataInSheet)>0){ for($i = 2;$i <= $arrayCount;$i++){ $email_id = trim($allDataInSheet[$i]["A"]); $company_name = trim($allDataInSheet[$i]["B"]); $contact_parson = trim($allDataInSheet[$i]["C"]); $phone_number = trim($allDataInSheet[$i]["D"]); if($email_id!=''){ $table="demo_vendor"; $bid=array( 'demo_vendor_email' =>$email_id, 'demo_vendor_company' =>$company_name, 'demo_vendor_contact' =>$contact_parson, 'demo_vendor_phone' =>$phone_number, 'delete_status' =>'ACTIVE' ); $table="demo_vendor"; $ven_bid=$this->bidding_model->insert($table,$bid); } } } echo json_encode(array('result'=>'1','msg'=>'Sucessful')); } } } } public function get_vendor(){ $table="demo_vendor"; $where=array('delete_status'=>'ACTIVE'); $result=$this->bidding_model->get_where_result($table,$where); echo json_encode($result); } public function change_password(){ $pwd = $this->input->post('pwd'); $user_name = $this->input->post('user_name'); $table="users"; $where=array('email'=>$user_name); $result=$this->bidding_model->get_where_row($table,$where); $password=$pwd; $pass_prefix = '$2a$05$'; $pass_suffix = '$'; $Allowed_Chars ='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789./'; $Chars_Len = 63; $Salt_Length = 21; $salt_password = ""; $salt_password=$result->salt; $encrypted_pass = $pass_prefix . $salt_password . $pass_suffix; $hashed_password = crypt($password,$encrypted_pass); $user_id = $this->session->userdata('user_id'); $table="users"; $where=array('user_id'=>$user_id); $data=array('password'=>$hashed_password); $result=$this->bidding_model->update_row($where,$data,$table); echo json_encode(array('result'=>'1','msg'=>'Updated Successfully')); } public function bidding_vendor_report_new(){ $user_id = $this->session->userdata('user_id'); if($user_id) { $table="users"; $where=array('user_id'=>$user_id,'delete_status'=>'ACTIVE'); $data['user']=$this->bidding_model->get_where_row($table,$where); $bidding_id = $this->uri->segment(2); $table="bidding_item"; $where=array('bidding_session_id'=>$bidding_id); $item=$this->bidding_model->get_where_result($table,$where); $arr=array(); $data_item=array(); foreach($item as $key => $value) { $res['item_name']=$value->item_name; $res['item_id']=$value->item_id; $res['specification']=$value->specification; $res['quantity']=$value->quantity; $table="bidding_price_table"; $where=array('bidding_id'=>$bidding_id,'item_id'=>$value->item_id,'vendor_id'=>$user_id); $v=$vendor=$this->bidding_model->get_bid_price_new($table,$where); if($v!=''){ $res['price']=$v->price; }else{ $res['price']=''; } $ar=array(); // foreach($vendor as $key => $v) { $t=$this->bidding_model->get_bidding_vendor($user_id); // array_push($ar,$t); // } $res['vendor']=$t; array_push($arr,$res); array_push($data_item,$t); } $data['item']=$arr; // $data_item=$arr; $aryr=array(); foreach($data_item as $s) { $where=$s->assigned_iadmin; // print_r($tt); $g=$this->bidding_model->get_bidding_vendor($where); array_push($aryr,$g); } $data['item_client']=$aryr; $table="bidding_session"; $where=array('bidding_session_id'=>$bidding_id); $bid=$this->bidding_model->get_where_row($table,$where); $data['bid']=$bid; $where=array('user_id'=>$bid->company_id); $table='users'; $data['user_details']=$this->bidding_model->get_where_row($table,$where); $table="vendor_bidding_table"; $where=array('bidding_id'=>$bidding_id); $vendor=$this->bidding_model->get_where_result($table,$where); $data['vendor']=count($vendor); $ur_ids = $this->session->userdata('user_id'); $where=array('user_id'=>$ur_ids); $table="users"; $data['user_usreid']=$this->bidding_model->get_where_row($table,$where); $this->load->view('bidding_vendor_report',$data); }else{ redirect('/'); } } public function bidding_vendor_history(){ $user_id = $this->session->userdata('user_id'); if($user_id) { $table="users"; $where=array('user_id'=>$user_id,'delete_status'=>'ACTIVE'); $data['user']=$this->bidding_model->get_where_row($table,$where); $table="bidding_session"; $where=array('company_id'=>$user_id,'status'=>'COMPLETED'); $data['bidding']=$this->bidding_model->get_where_result($table,$where); $data['bidding_new']=$this->bidding_model->get_client_history_bidding_events(); $data_bidding_new=$this->bidding_model->get_client_history_bidding_events(); $arr=array(); foreach($data_bidding_new as $b) { $where=array('user_id'=>$b->company_id); $table='users'; $res=$this->bidding_model->get_where_row($table,$where); array_push($arr,$res); } $data['user_comapny']=$arr; $ur_ids = $this->session->userdata('user_id'); $where=array('user_id'=>$ur_ids); $table="users"; $data['user_usreid']=$this->bidding_model->get_where_row($table,$where); $this->load->view('bidding_vendor_history',$data); }else{ redirect('/'); } } public function bidding_client_report_latest(){ $user_id = $this->session->userdata('user_id'); if($user_id) { $table="users"; $where=array('user_id'=>$user_id,'delete_status'=>'ACTIVE'); $data['user']=$this->bidding_model->get_where_row($table,$where); $bidding_id = $this->uri->segment(2); $table="bidding_item"; $where=array('bidding_session_id'=>$bidding_id); $item=$this->bidding_model->get_where_result($table,$where); $arr=array(); foreach($item as $key => $value) { $res['item_name']=$value->item_name; $res['item_id']=$value->item_id; $res['specification']=$value->specification; $res['quantity']=$value->quantity; $table="bidding_price_table"; $where=array('bidding_id'=>$bidding_id,'item_id'=>$value->item_id,'vendor_id'=>$user_id); $v=$vendor=$this->bidding_model->get_bid_price_latest($table,$where); if($v!=''){ $res['price']=$v->price; }else{ $res['price']=''; } $t=$this->bidding_model->get_bidding_vendor($user_id); $res['vendor']=$t; array_push($arr,$res); } $data['item']=$arr; $table="bidding_session"; $where=array('bidding_session_id'=>$bidding_id); $bid=$this->bidding_model->get_where_row($table,$where); $data['bid']=$bid; $table="vendor_bidding_table"; $where=array('bidding_id'=>$bidding_id); $vendor=$this->bidding_model->get_where_result($table,$where); $data['vendor']=count($vendor); $ur_ids = $this->session->userdata('user_id'); $where=array('user_id'=>$ur_ids); $table="users"; $data['user_usreid']=$this->bidding_model->get_where_row($table,$where); $this->load->view('client_bidding_report_new',$data); }else{ redirect('/'); } } public function active_client(){ $user_id = $this->session->userdata('user_id'); if($user_id) { $client=$this->bidding_model->active_client_list(); $ar=array(); foreach ($client as $key => $value) { $res['cname']=$value->cname; $res['first_name']=$value->first_name; $res['email']=$value->email; $res['mobile_no']=$value->mobile_no; $res['date_of_creation']=$value->date_of_creation; $res['date_of_expiry']=$value->date_of_expiry; $res['segment']=json_decode($value->industries); if($value->assigned_iadmin!='0'){ $table="users"; $where=array('user_id'=>$value->assigned_iadmin); $res['admin']=$this->bidding_model->get_where_row($table,$where); }else{ $res['admin']=''; } array_push($ar,$res); } $data['client']=$ar; $ur_ids = $this->session->userdata('user_id'); $where=array('user_id'=>$ur_ids); $table="users"; $data['user_usreid']=$this->bidding_model->get_where_row($table,$where); $this->load->view('sa_active_client',$data); }else{ redirect('/'); } } public function next_month_renewal_client(){ $user_id = $this->session->userdata('user_id'); if($user_id) { $renewal=$this->bidding_model->next_month_renewal_client_list(); $ar=array(); foreach($renewal as $key => $value) { $res['cname']=$value->cname; $res['first_name']=$value->first_name; $res['email']=$value->email; $res['mobile_no']=$value->mobile_no; $res['date_of_creation']=$value->date_of_creation; $res['date_of_expiry']=$value->date_of_expiry; $res['user_id']=$value->user_id; $res['segment']=json_decode($value->industries); $res['user_id']=$value->user_id; if($value->assigned_iadmin!='0'){ $table="users"; $where=array('user_id'=>$value->assigned_iadmin); $res['admin']=$this->bidding_model->get_where_row($table,$where); }else{ $res['admin']=''; } array_push($ar,$res); } $data['client']=$ar; // print_R($data['client']); // die(); $ur_ids = $this->session->userdata('user_id'); $where=array('user_id'=>$ur_ids); $table="users"; $data['user_usreid']=$this->bidding_model->get_where_row($table,$where); $this->load->view('next_month_renewal_client',$data); }else{ redirect('/'); } } public function expiry_client(){ $user_id = $this->session->userdata('user_id'); if($user_id) { $expiry=$this->bidding_model->expiry_client_list(); $ar=array(); foreach($expiry as $key => $value) { $res['cname']=$value->cname; $res['first_name']=$value->first_name; $res['email']=$value->email; $res['mobile_no']=$value->mobile_no; $res['date_of_creation']=$value->date_of_creation; $res['date_of_expiry']=$value->date_of_expiry; $res['user_id']=$value->user_id; $res['segment']=json_decode($value->industries); // if($value->assigned_iadmin!='0'){ // $table="users"; // $where=array('assigned_iadmin'=>$value->assigned_iadmin); // $d=$this->bidding_model->get_where_row($table,$where); // $res['user_name']=$d->first_name; // }else{ // $res['user_name']=''; // } if($value->assigned_iadmin!='0'){ $table="users"; $where=array('user_id'=>$value->assigned_iadmin); $res['admin']=$this->bidding_model->get_where_row($table,$where); }else{ $res['admin']=''; } array_push($ar,$res); } $data['client']=$ar; $ur_ids = $this->session->userdata('user_id'); $where=array('user_id'=>$ur_ids); $table="users"; $data['user_usreid']=$this->bidding_model->get_where_row($table,$where); $this->load->view('expiry_client',$data); }else{ redirect('/'); } } public function active_iclient(){ $user_id = $this->session->userdata('user_id'); if($user_id) { $client=$this->bidding_model->active_iclient_list($user_id); $ar=array(); foreach ($client as $key => $value) { $res['cname']=$value->cname; $res['first_name']=$value->first_name; $res['email']=$value->email; $res['mobile_no']=$value->mobile_no; $res['date_of_creation']=$value->date_of_creation; $res['date_of_expiry']=$value->date_of_expiry; $res['segment']=json_decode($value->industries); if($value->assigned_iadmin!='0'){ $table="users"; $where=array('assigned_iadmin'=>$value->assigned_iadmin); $d=$this->bidding_model->get_where_row($table,$where); $res['user_name']=$d->first_name; }else{ $res['user_name']=''; } array_push($ar,$res); } $data['client']=$ar; $ur_ids = $this->session->userdata('user_id'); $where=array('user_id'=>$ur_ids); $table="users"; $data['user_usreid']=$this->bidding_model->get_where_row($table,$where); $this->load->view('ia_active_client',$data); }else{ redirect('/'); } } public function ia_next_month_renewal_client(){ $user_id = $this->session->userdata('user_id'); if($user_id) { $renewal=$this->bidding_model->ia_month_renewal_client_list($user_id); $ar=array(); foreach($renewal as $key => $value) { $res['cname']=$value->cname; $res['first_name']=$value->first_name; $res['email']=$value->email; $res['mobile_no']=$value->mobile_no; $res['date_of_creation']=$value->date_of_creation; $res['date_of_expiry']=$value->date_of_expiry; $res['segment']=json_decode($value->industries); $res['user_id']=$value->user_id; if($value->assigned_iadmin!='0'){ $table="users"; $where=array('assigned_iadmin'=>$value->assigned_iadmin); $d=$this->bidding_model->get_where_row($table,$where); $res['user_name']=$d->first_name; }else{ $res['user_name']=''; } array_push($ar,$res); } $data['client']=$ar; $ur_ids = $this->session->userdata('user_id'); $where=array('user_id'=>$ur_ids); $table="users"; $data['user_usreid']=$this->bidding_model->get_where_row($table,$where); $this->load->view('ia_next_month_renewal',$data); }else{ redirect('/'); } } public function ia_expiry_client(){ $user_id = $this->session->userdata('user_id'); if($user_id) { $expiry=$this->bidding_model->ia_expiry_client_list($user_id); $ar=array(); foreach($expiry as $key => $value) { $res['cname']=$value->cname; $res['first_name']=$value->first_name; $res['email']=$value->email; $res['mobile_no']=$value->mobile_no; $res['date_of_creation']=$value->date_of_creation; $res['date_of_expiry']=$value->date_of_expiry; $res['segment']=json_decode($value->industries); $res['user_id']=$value->user_id; if($value->assigned_iadmin!='0'){ $table="users"; $where=array('assigned_iadmin'=>$value->assigned_iadmin); $d=$this->bidding_model->get_where_row($table,$where); $res['user_name']=$d->first_name; }else{ $res['user_name']=''; } array_push($ar,$res); } $data['client']=$ar; $ur_ids = $this->session->userdata('user_id'); $where=array('user_id'=>$ur_ids); $table="users"; $data['user_usreid']=$this->bidding_model->get_where_row($table,$where); $this->load->view('ia_expiry_client',$data); }else{ redirect('/'); } } public function closed_bidding_status(){ $item_id=$this->input->post('item_id'); $bidding_id=$this->input->post('bidding_id'); $status=$this->input->post('status'); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $table="bidding_status_table"; $where=array( 'item_id'=>$item_id, 'bidding_id'=>$bidding_id); $data=array( 'flag'=>'0', 'status'=>$status, 'updated_at'=>$date_format, 'status_new'=>'CLOSED'); $result=$this->bidding_model->update_row($where,$data,$table); if($result){ echo json_encode(array('result'=>$result,'message'=>'Item Closed')); }else{ echo json_encode(array('result'=>'0','message'=>'Something Went Wrong')); } } public function coordinator_bidding_client_event(){ $user_id = $this->session->userdata('user_id'); if($user_id) { $table="users"; $where=array('user_id'=>$user_id,'delete_status'=>'ACTIVE'); $data['user']=$this->bidding_model->get_where_row($table,$where); $bidding_id = $this->uri->segment(2); $table="bidding_item"; $where=array('bidding_session_id'=>$bidding_id); $data['item']=$this->bidding_model->get_where_result($table,$where); $table="bidding_session"; $where=array('bidding_session_id'=>$bidding_id); $data['bid']=$this->bidding_model->get_where_row($table,$where); $table="bidding_status_table"; $where=array('bidding_id'=>$bidding_id); $data['status']=$this->bidding_model->get_latest_bidding_status($where); $ur_ids = $this->session->userdata('user_id'); $where=array('user_id'=>$ur_ids); $table="users"; $data['user_usreid']=$this->bidding_model->get_where_row($table,$where); $this->load->view('coordinator_bidding_event',$data); }else{ redirect('/'); } } public function check_password(){ $user_id=$this->session->userdata('user_id'); $old_pass=$this->input->post('old_pass'); $where=array('user_id'=>$user_id,'delete_status'=>'ACTIVE'); $table="users"; $result=$this->bidding_model->get_where_row($table,$where); $password=$result->password; $pass_prefix = '$2a$05$'; $pass_suffix = '$'; $Allowed_Chars ='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789./'; $Chars_Len = 63; $Salt_Length = 21; $salt_password = ""; $salt_password=$result->salt; $encrypted_pass = $pass_prefix . $salt_password . $pass_suffix; //$hashed_password = crypt($password,$encrypted_pass); $user_password=crypt($old_pass,$encrypted_pass); if($user_password==$password){ echo json_encode(array('result'=>'1','msg'=>'Password Correct')); }else{ echo json_encode(array('result'=>'0','msg'=>'Password InCorrect')); } } public function update_date_time(){ $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $t = $date->format('H:i'); //print_r($t); $time = date("g:i a", strtotime($t)); //print_r($time);die(); $bidding_id=$this->input->post('bidding_id'); $where=array('bidding_session_id'=>$bidding_id); $table="bidding_session"; $data=array( 'final_bidding_date' => $date_format, 'bidding_time' => $time ); $res=$this->bidding_model->update_row($where,$data,$table); if($res){ echo json_encode(array('result'=>'1','msg'=>'Password Correct')); }else{ echo json_encode(array('result'=>'0','msg'=>'Password InCorrect')); } } public function coordinator_dashboard(){ $user_id = $this->session->userdata('user_id'); if($user_id) { $client=$this->bidding_model->get_count_iadmin_clients(); $data['client']=count($client); $table="users"; $table="users"; $where=array('user_id'=>$user_id,'delete_status'=>'ACTIVE'); $data['user']=$this->bidding_model->get_where_row($table,$where); $table="users"; $where=array('user_id'=>$user_id,'delete_status'=>'ACTIVE'); $data['user']=$this->bidding_model->get_where_row($table,$where); $table="bidding_coordinators"; $where=array('user_id'=>$user_id); $bidding=$this->bidding_model->get_where_result($table,$where); $arr=array(); foreach ($bidding as $key => $value) { $table="bidding_session"; $where=array('bidding_session_id'=>$value->bidding_session_id); $bid=$this->bidding_model->get_where_result_update($table,$where); if($bid){ if($bid->status!='COMPLETED'){ array_push($arr,$bid->bidding_session_id); } } } $hh=array(); foreach($arr as $r) { $split=$r; $table="bidding_session"; $order_by='final_bidding_date'; $data_bidding=$this->bidding_model->get_where_orderby_rows_latest($table,$split,$order_by); array_push($hh,$data_bidding); } $data['bidding']=$hh; $data_bidding=$hh; $osl_details=array(); foreach($data_bidding as $bb) { foreach($bb as $b) { $vendor_id=$b->bidding_session_id; $table='bidding_session'; $where=array('bidding_session_id'=>$vendor_id); $tt=$this->bidding_model->get_bid_price_latest($table,$where); $v=$tt->company_id; // $where=array('user_id'=>$v); // $table='' $t=$this->bidding_model->get_bidding_vendor($v); array_push($osl_details,$t); } } // print_r($osl_details); // die(); $data['bidding_comapny']=$osl_details; //print_R($osl_details); $ur_ids = $this->session->userdata('user_id'); $where=array('user_id'=>$ur_ids); $table="users"; $data['user_usreid']=$this->bidding_model->get_where_row($table,$where); $this->load->view('coordinator_dashbaord',$data); }else{ redirect('/'); } } public function add_iadmin_client_val(){ $user_id = $this->session->userdata('user_id'); $company_name=$this->input->post('company_name'); $contact_person=$this->input->post('contact_person'); $email_id=$this->input->post('email_id'); $mobile_number=$this->input->post('mobile_number'); $date_of_creation=$this->input->post('date_of_creation'); $date_of_creation=date('Y-m-d',strtotime($date_of_creation)); $date_of_expiryy=$this->input->post('date_of_expiry_val'); $date_of_expiry=date('Y-m-d',strtotime($date_of_expiryy)); $assigned_admin=$this->input->post('assigned_admin'); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d H:i:s'); $password='iclient'; $pass_prefix = '$2a$05$'; $pass_suffix = '$'; $Allowed_Chars ='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789./'; $Chars_Len = 63; $Salt_Length = 21; $salt_password = ""; for($i=0; $i<=$Salt_Length; $i++) { $salt_password .= $Allowed_Chars[mt_rand(0,$Chars_Len)]; } $encrypted_pass = $pass_prefix . $salt_password . $pass_suffix; $hashed_password = crypt($password,$encrypted_pass); $data=array( 'first_name' => $contact_person, 'company_name' => $company_name, 'email' => $email_id, 'mobile_no' => $mobile_number, 'salt' => $salt_password, 'password' => $hashed_password, 'assigned_iadmin' => $user_id, 'user_type_id' => '3', 'user_name' => $email_id, 'date_of_creation' => $date_of_creation, 'date_of_expiry' => $date_of_expiry, 'created_at' => $date_format ); $table="users"; $result=$this->bidding_model->insert($table,$data); if($result){ echo json_encode(array('result'=>1,'message'=>"Added Sucessfully")); }else{ echo json_encode(array('result'=>0,'message'=>"Not Added")); } } public function update_vendor_bidding_item(){ $sending_date=$this->input->post('sending_invitation'); if($sending_date!=''){ $sending_date=date('Y-m-d',strtotime($sending_date)); }else{ $sending_date=''; } $coordinate_vendor=$this->input->post('coordinate_vendor'); if($coordinate_vendor!=''){ $coordinate_vendor=date('Y-m-d',strtotime($coordinate_vendor)); }else{ $coordinate_vendor=''; } //final_bidding_date $finalized_bid_date_time=$this->input->post('finalized_bid_date_time'); if($finalized_bid_date_time!=''){ $finalized_bid_date_time=date('Y-m-d',strtotime($finalized_bid_date_time)); }else{ $finalized_bid_date_time=''; } $final_bidding_dates=$this->input->post('final_bidding_date_vendor'); if($final_bidding_dates!=''){ $final_bidding_date=date('Y-m-d',strtotime($final_bidding_dates)); }else{ $final_bidding_date=''; } $sending_completed_date=$this->input->post('sending_completed_date'); if($sending_completed_date!=''){ $sending_completed_date=date('Y-m-d',strtotime($sending_completed_date)); }else{ $sending_completed_date=''; } $coordinate_completed_date=$this->input->post('coordinate_completed_date'); if($coordinate_completed_date!=''){ $coordinate_completed_date=date('Y-m-d',strtotime($coordinate_completed_date)); }else{ $coordinate_completed_date=''; } $finalized_completed_date=$this->input->post('finalized_completed_date'); if($finalized_completed_date!=''){ $finalized_completed_date=date('Y-m-d',strtotime($finalized_completed_date)); }else{ $finalized_completed_date=''; } $bidding_completed_date=$this->input->post('bidding_completed_date'); if($bidding_completed_date!=''){ $bidding_completed_date=date('Y-m-d',strtotime($bidding_completed_date)); }else{ $bidding_completed_date=''; } $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $created_at = $date->format('Y-m-d H:i:s'); $bidding_session_id=$this->input->post('bidding_id'); $data=array( 'bidding_title' =>$this->input->post('bidding_title'), 'bidding_room' =>$this->input->post('bidding_room'), 'sending_invitation' =>$sending_date, 'coordinate_vendor' =>$coordinate_vendor, 'invitation_completed_date' =>$sending_completed_date, 'coordinate_completed_date' =>$coordinate_completed_date, 'bidding_date_approval' =>$bidding_completed_date, 'finalize_completed_date' =>$finalized_completed_date, 'finalized_bid_date_time' =>$finalized_bid_date_time, 'final_bidding_date' =>$final_bidding_date, 'bidding_limit_time' =>$this->input->post('bidding_time'), 'bidding_time' =>$this->input->post('final_bidding_time'), 'delete_status' =>'ACTIVE', 'created_at' =>$created_at, 'company_id' =>$this->session->userdata('user_id') ); $table="bidding_session"; $bidding_session_id=$this->input->post('bidding_id'); $where=array('bidding_session_id' =>$bidding_session_id); $result=$this->bidding_model->update_row($where,$data,$table); if($result){ $coordinator_id=$this->input->post('coordinator_id'); $coordinator_name=$this->input->post('coordinator_name'); $coordinator_phone=$this->input->post('coordinator_phone'); $coordinator_mail=$this->input->post('coordinator_mail'); $coordinator_company=$this->input->post('coordinator_company'); if(!empty($coordinator_name)){ foreach($coordinator_name as $key=>$cname) { $table="users"; $where=array('email' =>$coordinator_mail[$key]); $email=$this->bidding_model->get_where_row($table,$where); if($email){ $table="bidding_coordinators"; $where=array('user_id' =>$email->user_id,'bidding_session_id'=>$this->input->post('bidding_id')); $vend=$this->bidding_model->get_where_row($table,$where); if($vend){ $where=array('user_id' =>$email->user_id,'bidding_session_id'=>$this->input->post('bidding_id')); $c_data=array( 'bidding_session_id' =>$bidding_session_id, 'coordinator_name' =>$coordinator_name[$key], 'coordinator_phone' =>$coordinator_phone[$key], 'coordinator_email' =>$coordinator_mail[$key], 'coordinator_company' =>$coordinator_company[$key], 'user_id' =>$email->user_id, 'created_at' =>$created_at, ); $this->bidding_model->update_row($where,$c_data,$table); }else{ $c_data=array( 'bidding_session_id' =>$bidding_session_id, 'coordinator_name' =>$coordinator_name[$key], 'coordinator_phone' =>$coordinator_phone[$key], 'coordinator_email' =>$coordinator_mail[$key], 'coordinator_company' =>$coordinator_company[$key], 'user_id' =>$email->user_id, 'created_at' =>$created_at, ); $table="bidding_coordinators"; $this->bidding_model->insert($table,$c_data); } } else{ $password='coordinator'; $pass_prefix = '$2a$05$'; $pass_suffix = '$'; $Allowed_Chars ='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789./'; $Chars_Len = 63; $Salt_Length = 21; $salt_password = ""; for($i=0; $i<=$Salt_Length; $i++) { $salt_password .= $Allowed_Chars[mt_rand(0,$Chars_Len)]; } $encrypted_pass = $pass_prefix . $salt_password . $pass_suffix; $hashed_password = crypt($password,$encrypted_pass); $arr1=array( 'first_name' =>$coordinator_name[$key], 'email' =>$coordinator_mail[$key], 'company_name' =>$coordinator_company[$key], 'mobile_no' =>$coordinator_phone[$key], 'created_at' =>$created_at, 'user_type_id' =>'5', 'salt' =>$salt_password, 'password' =>$hashed_password, 'delete_status' =>'ACTIVE' ); $table="users"; $user=$this->bidding_model->insert($table,$arr1); if($user){ $c_data=array( 'bidding_session_id' =>$bidding_session_id, 'coordinator_name' =>$coordinator_name[$key], 'coordinator_phone' =>$coordinator_phone[$key], 'coordinator_email' =>$coordinator_mail[$key], 'coordinator_company' =>$coordinator_company[$key], 'user_id' =>$user, 'created_at' =>$created_at, ); $table_new="bidding_coordinators"; $this->bidding_model->insert($table_new,$c_data); } } } } $table="bidding_item"; // $where=array('bidding_session_id' =>$bidding_session_id); // $r=$this->bidding_model->delete_row($where,$table); //if($r){ $item_desc=$this->input->post('item_desc'); $specification=$this->input->post('specification'); $item_desc=$this->input->post('item_desc'); $item_desc=$this->input->post('item_desc'); $quantity=$this->input->post('quantity'); $item_id_key=$this->input->post('item_id_key'); foreach($item_desc as $key => $value) { if($item_id_key[$key] != 'null'){ $arr=array( 'bidding_session_id' =>$bidding_session_id, 'item_name' =>$value, 'specification' =>$specification[$key], 'quantity' =>$quantity[$key], 'delete_status' =>'ACTIVE', 'bidding_limit_time' =>$this->input->post('bidding_time'), 'created_at' =>$created_at ); $table="bidding_item"; $where=array('item_id'=>$item_id_key[$key]); $item_id=$this->bidding_model->update_row($where,$arr,$table); }else{ if($value != '') { $arr=array( 'bidding_session_id' =>$bidding_session_id, 'item_name' =>$value, 'specification' =>$specification[$key], 'quantity' =>$quantity[$key], 'delete_status' =>'ACTIVE', 'bidding_limit_time' =>$this->input->post('bidding_time'), 'created_at' =>$created_at ); $table="bidding_item"; $item_id=$this->bidding_model->insert($table,$arr); } } } //} include APPPATH . 'libraries/PHPExcel/IOFactory.php'; if(isset($_FILES['item_file']['name'])) { $file_name = $_FILES['item_file']['name']; $ext = pathinfo($file_name, PATHINFO_EXTENSION); if($ext == "xlsx" || $ext == "xls" || $ext == "csv") { $file_name = $_FILES['item_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 = 'leads'; if(count($allDataInSheet)>0){ for($i = 2;$i <= $arrayCount;$i++){ $item_name = trim($allDataInSheet[$i]["A"]); $specification = trim($allDataInSheet[$i]["B"]); $quantity = trim($allDataInSheet[$i]["C"]); $ar=array( 'bidding_session_id' =>$bidding_session_id, 'item_name' =>$item_name, 'specification' =>$specification, 'quantity' =>$quantity, 'delete_status' =>'ACTIVE', 'bidding_limit_time' =>$this->input->post('bidding_time'), 'created_at' =>$created_at ); $table="bidding_item"; $item_id=$this->bidding_model->insert($table,$ar); } } } } $company_name=$this->input->post('company_name'); $email_id=$this->input->post('email_id'); $contact_parson=$this->input->post('contact_parson'); $phone_number=$this->input->post('phone_number'); foreach($company_name as $key => $value) { $table="users"; $where=array('email' =>$email_id[$key]); $email=$this->bidding_model->get_where_row($table,$where); if($email){ $user_id = $this->session->userdata('user_id'); $where=array('user_id'=>$user_id); $result_user_id=$this->bidding_model->get_where_row($table,$where); $user_id = $this->session->userdata('user_id'); $table="clients_table"; $inserrt_datas=array('user_id'=>$user_id,'vendor_id'=>$email->user_id,'user_type'=>$result_user_id->user_type_id); $this->bidding_model->insert($table,$inserrt_datas); $table="vendor_bidding_table"; $where=array('user_id' =>$email->user_id,'bidding_id'=>$this->input->post('bidding_id')); $vend=$this->bidding_model->get_where_row($table,$where); if($vend){ }else{ $bid=array( 'user_id' =>$email->user_id, 'bidding_id' =>$bidding_session_id, 'created_at' =>$created_at ); $table="vendor_bidding_table"; $ven_bid=$this->bidding_model->insert($table,$bid); } }else{ $password='ivendor'; $pass_prefix = '$2a$05$'; $pass_suffix = '$'; $Allowed_Chars ='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789./'; $Chars_Len = 63; $Salt_Length = 21; $salt_password = ""; for($i=0; $i<=$Salt_Length; $i++) { $salt_password .= $Allowed_Chars[mt_rand(0,$Chars_Len)]; } $encrypted_pass = $pass_prefix . $salt_password . $pass_suffix; $hashed_password = crypt($password,$encrypted_pass); $arr1=array( 'first_name' =>$contact_parson[$key], 'email' =>$email_id[$key], 'company_name' =>$company_name[$key], 'mobile_no' =>$phone_number[$key], 'created_at' =>$created_at, 'user_type_id' =>'4', 'salt' =>$salt_password, 'password' =>$hashed_password, 'delete_status' =>'ACTIVE' ); $table="users"; $user=$this->bidding_model->insert($table,$arr1); $user_id = $this->session->userdata('user_id'); $where=array('user_id'=>$user_id); $result_user_id=$this->bidding_model->get_where_row($table,$where); $user_id = $this->session->userdata('user_id'); $table="clients_table"; $inserrt_datas=array('user_id'=>$user_id,'vendor_id'=>$user,'user_type'=>$result_user_id->user_type_id); $this->bidding_model->insert($table,$inserrt_datas); if($user){ $table="vendor_bidding_table"; $bid=array( 'user_id' =>$user, 'bidding_id' =>$bidding_session_id, 'created_at' =>$created_at ); $table="vendor_bidding_table"; $ven_bid=$this->bidding_model->insert($table,$bid); } } } // $company_name=$this->input->post('company_name'); if(isset($_FILES['vendor_file']['name'])) { $file_name = $_FILES['vendor_file']['name']; $ext = pathinfo($file_name, PATHINFO_EXTENSION); if($ext == "xlsx" || $ext == "xls" || $ext == "csv") { $file_name = $_FILES['vendor_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 = 'leads'; if(count($allDataInSheet)>0){ for($i = 2;$i <= $arrayCount;$i++){ $email_id = trim($allDataInSheet[$i]["A"]); $company_name = trim($allDataInSheet[$i]["B"]); $contact_parson = trim($allDataInSheet[$i]["C"]); $phone_number = trim($allDataInSheet[$i]["D"]); if($email_id!=''){ $table="users"; $where=array('email' =>$email_id); $email=$this->bidding_model->get_where_row($table,$where); if($email){ $table="vendor_bidding_table"; $where=array('user_id' =>$email->user_id,'bidding_id'=>$this->input->post('bidding_id')); $bidding_email=$this->bidding_model->get_where_row($table,$where); if($bidding_email) { } else { $table="vendor_bidding_table"; $bid=array( 'user_id' =>$email->user_id, 'bidding_id' =>$bidding_session_id, 'created_at' =>$created_at ); $table="vendor_bidding_table"; $ven_bid=$this->bidding_model->insert($table,$bid); } }else{ $password='ivendor'; $pass_prefix = '$2a$05$'; $pass_suffix = '$'; $Allowed_Chars ='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789./'; $Chars_Len = 63; $Salt_Length = 21; $salt_password = ""; for($i=0; $i<=$Salt_Length; $i++) { $salt_password .= $Allowed_Chars[mt_rand(0,$Chars_Len)]; } $encrypted_pass = $pass_prefix . $salt_password . $pass_suffix; $hashed_password = crypt($password,$encrypted_pass); $arr1=array( 'first_name' =>$contact_parson, 'email' =>$email_id, 'company_name' =>$company_name, 'mobile_no' =>$phone_number, 'created_at' =>$created_at, 'salt' =>$salt_password, 'password' =>$hashed_password, 'user_type_id' =>'4', 'delete_status' =>'ACTIVE' ); $table="users"; $user=$this->bidding_model->insert($table,$arr1); if($user){ $table="vendor_bidding_table"; $bid=array( 'user_id' =>$user, 'bidding_id' =>$bidding_session_id, 'created_at' =>$created_at ); $table="vendor_bidding_table"; $ven_bid=$this->bidding_model->insert($table,$bid); } } } } } } } echo json_encode(array('result'=>'1','message'=>'Added Sucessfully')); }else{ echo json_encode(array('result'=>'0','message'=>'Something went wrong')); } } public function add_iadmin_vendor_client_val(){ $user_id = $this->session->userdata('user_id'); $company_name=$this->input->post('company_name'); $contact_person=$this->input->post('contact_person'); $email_id=$this->input->post('email_id'); $mobile_number=$this->input->post('mobile_number'); $date_of_creation=$this->input->post('date_of_creation'); $date_of_creation=date('Y-m-d',strtotime($date_of_creation)); $date_of_expiryy=$this->input->post('date_of_expiry_vals'); $date_of_expiry=date('Y-m-d',strtotime($date_of_expiryy)); $assigned_admin=$this->input->post('assigned_admin'); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d H:i:s'); $password='iclient'; $pass_prefix = '$2a$05$'; $pass_suffix = '$'; $Allowed_Chars ='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789./'; $Chars_Len = 63; $Salt_Length = 21; $salt_password = ""; for($i=0; $i<=$Salt_Length; $i++) { $salt_password .= $Allowed_Chars[mt_rand(0,$Chars_Len)]; } $encrypted_pass = $pass_prefix . $salt_password . $pass_suffix; $hashed_password = crypt($password,$encrypted_pass); $data=array( 'first_name' => $contact_person, 'company_name' => $company_name, 'email' => $email_id, 'mobile_no' => $mobile_number, 'salt' => $salt_password, 'password' => $hashed_password, 'assigned_iadmin' => $user_id, 'user_type_id' => '3', 'user_name' => $email_id, 'date_of_creation' => $date_of_creation, 'date_of_expiry' => $date_of_expiry, 'created_at' => $date_format ); $table="users"; $result=$this->bidding_model->insert($table,$data); if($result){ echo json_encode(array('result'=>1,'message'=>"Added Sucessfully")); }else{ echo json_encode(array('result'=>0,'message'=>"Not Added")); } } public function get_email_details() { $username=$this->input->post('e'); $table="users"; $where=array('email'=>$username); $data['result']=$this->bidding_model->get_where_row($table,$where); echo json_encode($data); } public function delete_vendor_liast_iadmin(){ $user_id = $this->session->userdata('user_id'); $table="clients_table"; $id=$this->input->post('id'); $where=array('vendor_id'=>$id,'user_id'=>$user_id); $this->bidding_model->delete_row($where,$table); $id=$this->input->post('id'); $table="users"; $where=array('user_id'=>$id); $result=$this->bidding_model->get_bid_price_latest($table,$where); if($result){ $table="bidding_session"; $where=array('company_id'=>$user_id); $bidding_session_delete=$this->bidding_model->get_where_result($table,$where); $ar=array(); foreach($bidding_session_delete as $b) // print_R($b->bidding_session_id); $table="vendor_bidding_table";; $where=array('user_id'=>$id,'bidding_id'=>$b->bidding_session_id); $vendor_bidding_delete=$this->bidding_model->get_where_result($table,$where); array_push($ar,$vendor_bidding_delete); } foreach($ar as $a) { foreach($a as $g) { $table="vendor_bidding_table";; $where=array('vendor_id'=>$g->vendor_id); $r=$this->bidding_model->delete_row($where,$table); } // $table="vendor_bidding_table";; // $where=array('vendor_id'=>$a->vendor_id); // $r=$this->bidding_model->delete_row($where,$table); } if($result){ echo json_encode(array('result'=>1,'message'=>"Deleted Successfully")); }else{ echo json_encode(array('result'=>0,'message'=>"Something went wrong")); } } public function get_client_email_details() { $username=$this->input->post('e'); $table="users"; $where=array('email'=>$username); $data_result=$this->bidding_model->get_where_row($table,$where); if(empty($data_result)) { $r=0; } else { $r=1; } echo json_encode($r); } public function update_sa_iadmin_client(){ $user_id = $this->session->userdata('user_id'); if($user_id) { $vendor_id = $this->uri->segment(2); $where=array('user_id'=>$vendor_id,'delete_status'=>'ACTIVE'); $table="users"; $data['user']=$this->bidding_model->get_where_row($table,$where); $table="users"; $where=array('delete_status'=>'ACTIVE','user_type_id'=>'2'); $data['iadmin']=$this->bidding_model->get_where_asc_result($table,$where); $where=array('user_id'=>$user_id); $table="users"; $data['user_usreid']=$this->bidding_model->get_where_row($table,$where); $ur_ids = $this->session->userdata('user_id'); $where=array('user_id'=>$ur_ids); $table="users"; $data['user_usreid']=$this->bidding_model->get_where_row($table,$where); $this->load->view('iadmin_edit_client_edit',$data); }else{ redirect('/'); } } public function delete_vendor_list_iadmin(){ $user_id = $this->session->userdata('user_id'); $table="clients_table"; $id=$this->input->post('id'); $where=array('vendor_id'=>$id,'user_id'=>$user_id); $result= $this->bidding_model->delete_row($where,$table); if($result){ echo json_encode(array('result'=>1,'message'=>"Deleted Successfully")); }else{ echo json_encode(array('result'=>0,'message'=>"Something went wrong")); } } public function get_co_ordinator_person_email(){ $email=$this->input->post('email'); $table="users"; // $where=array('email'=>$email,'delete_status'=>'ACTIVE'); $where=array('email'=>$email); $res=$this->bidding_model->get_where_row($table,$where); if($res){ echo json_encode(array('result'=>'1','detail'=>$res,'message'=>'Sucessful')); }else{ echo json_encode(array('result'=>'0','message'=>'Something went wrong')); } } public function closed_bidding_news_status(){ $item_id=$this->input->post('item_id'); $bidding_id=$this->input->post('bidding_id'); $status=$this->input->post('status'); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $table="bidding_status_table"; $where=array( 'item_id'=>$item_id, 'bidding_id'=>$bidding_id, 'flag'=>'0', 'status'=>$status, 'status_new'=>'CLOSED'); $result=$this->bidding_model->get_where_row($table,$where); if($result){ echo json_encode(array('result'=>$result,'message'=>'Item Closed')); }else{ echo json_encode(array('result'=>'0','message'=>'Something Went Wrong')); } } public function update_news_vendor_item_price(){ $r=$this->input->post('item_id'); $g=$this->bidding_model->get_where_joiningrow($r); if($g->close_biddding_time == '') { echo json_encode(array('result'=>'4')); } else { echo json_encode(array('result'=>'5')); } } //total bidding list public function total_bid() { $data['total_bid'] = $this->bidding_model->get_total_biddings(); $this->load->view('vendor_bidding_list', $data); } //completed bid list public function completed_bidding_list() { $completed_bid = $this->bidding_model->completed_biddings(); $data['completed_bid'] = $completed_bid; $this->load->view('completed_bidding_list', $data); } //upcomming bid list public function upcoming_bidding_list(){ $upcoming_biddings = $this->bidding_model->upcoming_biddings(); $data['upcoming_biddings'] = $upcoming_biddings; $this->load->view('upcoming_bidding_list', $data); } //today's bid list public function todays_bidding_list() { $todays_biddings = $this->bidding_model->todays_biddings(); $data['todays_biddings'] = $todays_biddings; $this->load->view('todays_bidding_list', $data); } }