EVOLUTION-NINJA
Edit File: Yaskawa.php
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); require_once 'vendor/autoload.php'; // Include the Composer autoloader use Mpdf\Mpdf; use PHPMailer\PHPMailer\PHPMailer; use PHPMailer\PHPMailer\Exception; use PHPMailer\PHPMailer\SMTP; class yaskawa extends CI_Controller{ public function __construct() { parent::__construct(); // Load the necessary model $this->load->model('Yaskawa_model'); } //index view public function index() { $this->load->view('admin/login'); } //Login page public function admin_login() { $this->load->view('admin/login'); } //Admin login // public function login() // { // $email = $this->input->post('email'); // //$password = md5($this->input->post('password')); // $pass_word = $this->input->post('password'); // $remember = $this->input->post('remember'); // $result = $this->yaskawa_model->admin_login($email,$pass_word); // if($result) // { // $pass_prefix = '$2a$05$'; // $pass_suffix = '$'; // $Allowed_Charsa ='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789./'; // $Chars_Len = 63; // $Salt_Length = 21; // $salt_password = ""; // $salt_password=$result->salt_pass; // $encrypted_pass = $pass_prefix . $salt_password . $pass_suffix; // $hashed_password = crypt($pass_word,$encrypted_pass); // if($result->password==$hashed_password){ // if($result->user_type_id == '1') // { // $this->session->set_userdata('admin',$result->user_name); // $this->session->set_userdata('admin_id',$result->user_id); // $this->session->set_userdata('user_type',$result->user_type_name); // $this->session->set_userdata('email',$result->email); // $this->session->set_userdata('user_type_id',$result->user_type_id); // $this->session->set_userdata('Mobile',$result->Mobile); // //$this->session->set_userdata('ext',$result->Mobile); // $this->session->set_userdata('role_id',$result->role_id); // echo json_encode(array( // 'result' => 1, // 'user_type' => $this->session->userdata('user_type'), // 'user_name' => $this->session->userdata('admin'), // 'admin_id' => $this->session->userdata('admin_id'), // 'user_type_id' => $this->session->userdata('user_type_id'), // 'role_id' => $this->session->userdata('role_id'), // )); // if($remember==1) // { // $this->load->helper('cookie'); // set_cookie("password", $pass_word, time()+86500); // set_cookie("email", $email, time()+86500); // set_cookie("remember", $remember, time()+86500); // } // } // else if($result->user_type_id == '2' || $result->user_type_id == '3') // { // $this->session->set_userdata('user',$result->user_name); // $this->session->set_userdata('user_name',$result->user_name); // $this->session->set_userdata('admin_id',$result->user_id); // $this->session->set_userdata('user_type',$result->user_type_name); // $this->session->set_userdata('role_id',$result->role_id); // echo json_encode(array( // 'result' => 1, // 'user_type' => $this->session->userdata('user_type'), // 'user_name' => $this->session->userdata('user_name'), // 'admin_id' => $this->session->userdata('user_id'), // 'role_id' => $this->session->userdata('role_id'), // )); // if($remember==1) // { // $this->load->helper('cookie'); // set_cookie("password", $password, time()+86500); // set_cookie("email", $email, time()+86500); // set_cookie("remember", $remember, time()+86500); // } // } // } // else // { // echo json_encode(array('result'=>0,'message'=>"Wrong login credentials")); // } // } // else // { // echo json_encode(array('result'=>0,'message'=>"Wrong login credentials")); // } // } public function login() { $email = $this->input->post('email'); $password = $this->input->post('password'); $remember = $this->input->post('remember'); // Authenticate using plain text password $result = $this->yaskawa_model->admin_login($email, $password); if ($result) { if ($result->password === $password) { // Compare plain text password // Handle admin login if ($result->user_type_id == '1') { $this->session->set_userdata('admin', $result->user_name); $this->session->set_userdata('admin_id', $result->user_id); $this->session->set_userdata('user_type', $result->user_type_name); $this->session->set_userdata('email', $result->email); $this->session->set_userdata('user_type_id', $result->user_type_id); $this->session->set_userdata('Mobile', $result->Mobile); $this->session->set_userdata('role_id', $result->role_id); echo json_encode(array( 'result' => 1, 'user_type' => $this->session->userdata('user_type'), 'user_name' => $this->session->userdata('admin'), 'admin_id' => $this->session->userdata('admin_id'), 'user_type_id' => $this->session->userdata('user_type_id'), 'role_id' => $this->session->userdata('role_id'), )); if ($remember == 1) { $this->load->helper('cookie'); set_cookie("password", $password, time() + 86500); set_cookie("email", $email, time() + 86500); set_cookie("remember", $remember, time() + 86500); } } // Handle other user types else if ($result->user_type_id == '2' || $result->user_type_id == '3') { $this->session->set_userdata('user', $result->user_name); $this->session->set_userdata('user_name', $result->user_name); $this->session->set_userdata('admin_id', $result->user_id); $this->session->set_userdata('user_type', $result->user_type_name); $this->session->set_userdata('role_id', $result->role_id); echo json_encode(array( 'result' => 1, 'user_type' => $this->session->userdata('user_type'), 'user_name' => $this->session->userdata('user_name'), 'admin_id' => $this->session->userdata('user_id'), 'role_id' => $this->session->userdata('role_id'), )); // if ($remember == 1) { // $this->load->helper('cookie'); // set_cookie("password", $password, time() + 86500); // set_cookie("email", $email, time() + 86500); // set_cookie("remember", $remember, time() + 86500); // } } } else { echo json_encode(array('result' => 0, 'message' => "Wrong login credentials")); } } else { echo json_encode(array('result' => 0, 'message' => "Wrong login credentials")); } } //Logout public function logout() { $this->session->sess_destroy(); redirect('/admin-login'); } //Admin dashboard public function admin_dashboard() { $admin=$this->session->userdata('admin'); $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $data['company_details']=$this->yaskawa_model->fetch_company_details(); $this->load->view('admin/index',$data); } else { redirect('/'); } } //add_new_leads view public function new_lead() { $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count=0; foreach($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if($months=='11'){ $count+=1; } } $data['count']=$count; $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $data['company_details']=$this->yaskawa_model->fetch_company_details(); $data['user_details']=$this->yaskawa_model->get_user_details(); $data['source_details']=$this->yaskawa_model->get_lead_source_details(); $data['status_details']=$this->yaskawa_model->get_lead_status_details(); $data['lead_ratings']=$this->yaskawa_model->get_lead_ratings_details(); $data['honorific']=$this->yaskawa_model->get_honorific(); $data['customer_type']=$this->yaskawa_model->get_customer_type(); $data['lead_process']=$this->yaskawa_model->get_lead_process(); $data['industry_details']=$this->yaskawa_model->get_lead_industry_details(); $this->load->view('admin/add_new_leads',$data); } else { redirect('/'); } } //add_new_leads view public function lead_list() { $lead_ids=$this->input->post('lead_ids'); $this->yaskawa_model->deleteleads($lead_ids); $admin_id = $this->session->userdata('admin_id'); $role_id = $this->session->userdata('role_id'); if($admin_id) { $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count=0; foreach($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if($months=='11'){ $count+=1; } } $result['count']=$count; $result['user_type_id'] = $this->access_id(); $result['access'] = $this->access_details(); $lead_list = $this->yaskawa_model->get_all_leads($role_id); $arr=array(); foreach ($lead_list as $key => $value) { $res['lead_id']=$value->lead_id; $res['first_name']=$value->first_name; $res['company_name']=$value->company_name; $res['mobile']=$value->mobile; $res['street']=$value->street; $res['c_date']=$value->c_date; $res['email']=$value->email; $res['description']=$value->description; $res['user_name']=$value->user_name; $res['lead_convert']=$value->lead_convert; $table="lead_attach_notes"; $lead_id=$value->lead_id; $res['lead_notes']=$value->description;; /*$note=$this->yaskawa_model->get_row_by_desc($lead_id); if($note){ $res['lead_notes']=$note->lead_notes; }else{ $res['lead_notes']=''; }*/ array_push($arr,$res); } $result['lead']=$arr; $result['company_details'] = $this->yaskawa_model->fetch_company_details(); $result['contacted_leads'] = $this->yaskawa_model->fetch_contacted_leads(); $result['closed_leads'] = $this->yaskawa_model->fetch_closed_leads(); $result['converted_leads'] = $this->yaskawa_model->fetch_converted_leads(); $this->load->view('admin/new_lead_list',$result); } else { redirect('/'); } } //lead_module view public function lead_module() { $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count=0; foreach($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if($months=='11'){ $count+=1; } } $data['count']=$count; $data['company_details']=$this->yaskawa_model->fetch_company_details(); $this->load->view('admin/lead_module',$data); } else { redirect('/'); } } //list_lead_module view public function list_lead_module() { $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count=0; foreach($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if($months=='11'){ $count+=1; } } $data['count']=$count; $data['company_details']=$this->yaskawa_model->fetch_company_details(); $this->load->view('admin/list_lead_module',$data); } else { redirect('/'); } } //add_employees view public function add_employees() { $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count=0; foreach($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if($months=='11'){ $count+=1; } } $data['count']=$count; $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $data['dept_list'] = $this->yaskawa_model->get_all_departments(); $data['e_id']=$this->yaskawa_model->get_emp_id(); $data['company_details']=$this->yaskawa_model->fetch_company_details(); $data['roles_list_admin'] = $this->yaskawa_model->get_all_roles_admin(); $data['designation_list'] = $this->yaskawa_model->get_all_designation(); $this->load->view('admin/add_new_employee',$data); } else { redirect('/'); } } //add_department view public function add_department() { $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $result['user_type_id'] = $this->access_id(); $result['access'] = $this->access_details(); $result['dept_list'] = $this->yaskawa_model->get_all_departments(); $result['emp_list'] = $this->yaskawa_model->employee_list(); $result['company_details']=$this->yaskawa_model->fetch_company_details(); $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count=0; foreach($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if($months=='11'){ $count+=1; } } $result['count']=$count; $this->load->view('admin/add_department',$result); } else { redirect('/'); } } //add_new_leads view public function add_designation() { $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $result['user_type_id'] = $this->access_id(); $result['access'] = $this->access_details(); $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count=0; foreach($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if($months=='11'){ $count+=1; } } $result['count']=$count; $result['desig_list'] = $this->yaskawa_model->get_all_designation(); $result['company_details']=$this->yaskawa_model->fetch_company_details(); $this->load->view('admin/add_designation',$result); } else { redirect('/'); } } //lead_feeds view public function lead_contact() { $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count=0; foreach($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if($months=='11'){ $count+=1; } } $data['count']=$count; $data['company_details']=$this->yaskawa_model->fetch_company_details(); $this->load->view('admin/lead_contact',$data); } else { redirect('/'); } } //lead_feeds view public function calender() { $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count=0; foreach($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if($months=='11'){ $count+=1; } } $data['count']=$count; $data['company_details']=$this->yaskawa_model->fetch_company_details(); $this->load->view('admin/calender',$data); } else { redirect('/'); } } //all_reports view public function all_reports() { $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count=0; foreach($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if($months=='11'){ $count+=1; } } $data['count']=$count; $table="report_menu"; $where=array('report_status'=>'ACTIVE','delete_status'=>'ACTIVE'); $data['contents']=$this->yaskawa_model->get_alldata($table,$where); $data['company_details']=$this->yaskawa_model->fetch_company_details(); $this->load->view('admin/all_reports',$data); } else { redirect('/'); } } //recent_reports view public function recent_reports() { $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count=0; foreach($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if($months=='11'){ $count+=1; } } $data['count']=$count; $data['company_details']=$this->yaskawa_model->fetch_company_details(); $this->load->view('admin/recent_reports',$data); } else { redirect('/'); } } //recent_reports_me view public function recent_reports_me() { $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count=0; foreach($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if($months=='11'){ $count+=1; } } $data['count']=$count; $data['company_details']=$this->yaskawa_model->fetch_company_details(); $this->load->view('admin/recent_reports_me',$data); } else { redirect('/'); } } //shared_reports view public function shared_reports() { $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $data['company_details']=$this->yaskawa_model->fetch_company_details(); $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count=0; foreach($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if($months=='11'){ $count+=1; } } $data['count']=$count; $this->load->view('admin/shared_reports',$data); } else { redirect('/'); } } //potential_reports view public function potential_reports() { $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count=0; foreach($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if($months=='11'){ $count+=1; } } $data['count']=$count; $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $table="report_menu"; $where=array('report_status'=>'ACTIVE','type'=>'Potential Reports'); $data['contents']=$this->yaskawa_model->get_alldata($table,$where); $data['company_details']=$this->yaskawa_model->fetch_company_details(); $this->load->view('admin/potential_reports',$data); } else { redirect('/'); } } //lead_reports view public function lead_reports() { $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count=0; foreach($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if($months=='11'){ $count+=1; } } $data['count']=$count; $table="report_menu"; $where=array('report_status'=>'ACTIVE','type'=>'Lead Reports'); $data['contents']=$this->yaskawa_model->get_alldata($table,$where); $data['company_details']=$this->yaskawa_model->fetch_company_details(); $this->load->view('admin/lead_reports',$data); } else { redirect('/'); } } //activity_reports view public function activity_reports() { $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count=0; foreach($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if($months=='11'){ $count+=1; } } $data['count']=$count; $table="report_menu"; $where=array('report_status'=>'ACTIVE','type'=>'Activity Reports'); $data['contents']=$this->yaskawa_model->get_alldata($table,$where); $data['company_details']=$this->yaskawa_model->fetch_company_details(); $this->load->view('admin/activity_reports',$data); } else { redirect('/'); } } //sales_matrics_reports view public function sales_matrics_reports() { $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count=0; foreach($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if($months=='11'){ $count+=1; } } $data['count']=$count; $table="report_menu"; $where=array('report_status'=>'ACTIVE','type'=>'Sales Metrics Reports'); $data['contents']=$this->yaskawa_model->get_alldata($table,$where); $data['company_details']=$this->yaskawa_model->fetch_company_details(); $this->load->view('admin/sales_matrics_report',$data); } else { redirect('/'); } } //recently_deleted_reports view public function recently_deleted_reports() { $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count=0; foreach($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if($months=='11'){ $count+=1; } } $data['count']=$count; $table="report_menu"; $where=array('report_status'=>'ACTIVE','delete_status'=>'DEACTIVE'); $data['content']=$this->yaskawa_model->get_alldata($table,$where); $data['company_details']=$this->yaskawa_model->fetch_company_details(); $this->load->view('admin/recently_deleted_reports',$data); } else { redirect('/'); } } //recently_deleted_reports view public function potential_performance_reports() { $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count=0; foreach($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if($months=='11'){ $count+=1; } } $data['count']=$count; $data['company_details']=$this->yaskawa_model->fetch_company_details(); $this->load->view('admin/potential_performance_reports',$data); } else { redirect('/'); } } //recently_deleted_reports view public function potential_lead_source() { $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count=0; foreach($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if($months=='11'){ $count+=1; } } $data['count']=$count; $data['company_details']=$this->yaskawa_model->fetch_company_details(); $this->load->view('admin/potential_lead_source',$data); } else { redirect('/'); } } //recently_deleted_reports view public function potential_sales_this_month() { $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count=0; foreach($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if($months=='11'){ $count+=1; } } $data['count']=$count; $data['company_details']=$this->yaskawa_model->fetch_company_details(); $this->load->view('admin/potential_sales_this_month',$data); } else { redirect('/'); } } //recently_deleted_reports view public function potential_todays_sales() { $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count=0; foreach($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if($months=='11'){ $count+=1; } } $data['count']=$count; $data['company_details']=$this->yaskawa_model->fetch_company_details(); $this->load->view('admin/potential_todays_sales',$data); } else { redirect('/'); } } //recently_deleted_reports view public function lead_industry_list() { $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count=0; foreach($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if($months=='11'){ $count+=1; } } $data['count']=$count; $data['company_details']=$this->yaskawa_model->fetch_company_details(); $this->load->view('admin/lead_industry_list',$data); } else { redirect('/'); } } //recently_deleted_reports view public function lead_ownership_list() { $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count=0; foreach($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if($months=='11'){ $count+=1; } } $data['count']=$count; $data['company_details']=$this->yaskawa_model->fetch_company_details(); $this->load->view('admin/lead_ownership_list',$data); } else { redirect('/'); } } //recently_deleted_reports view public function lead_converted_list() { $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count=0; foreach($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if($months=='11'){ $count+=1; } } $data['count']=$count; $data['company_details']=$this->yaskawa_model->fetch_company_details(); $this->load->view('admin/lead_converted_list',$data); } else { redirect('/'); } } //recently_deleted_reports view public function lead_todays_list() { $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count=0; foreach($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if($months=='11'){ $count+=1; } } $data['count']=$count; $data['company_details']=$this->yaskawa_model->fetch_company_details(); $this->load->view('admin/lead_todays_list',$data); } else { redirect('/'); } } //recently_deleted_reports view public function lead_status_list() { $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count=0; foreach($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if($months=='11'){ $count+=1; } } $data['count']=$count; $data['company_details']=$this->yaskawa_model->fetch_company_details(); $this->load->view('admin/lead_status_list',$data); } else { redirect('/'); } } // edit leads under me dileep *********************************************************************************************** // In your Lead controller // In application/controllers/Lead.php public function fetch_lead_data() { // Ensure you're receiving the correct lead_id from the AJAX request $lead_id = $this->input->post('lead_id'); if (!$lead_id) { echo json_encode(['error' => 'Lead ID is missing']); return; } // Load the model $this->load->model('Yaskawa_model'); // Fetch the lead data $lead = $this->Yaskawa_model->get_lead_by_id($lead_id); // Return lead data as JSON if ($lead) { echo json_encode($lead); } else { echo json_encode(['error' => 'Lead not found']); } } // Controller method to handle update and redirect // In application/controllers/Lead.php public function update_lead() { // Get the lead_id and other POST data $lead_id = $this->input->post('lead_id'); $data = array( 'first_name' => $this->input->post('first_name'), 'company_name' => $this->input->post('company_name'), 'mobile' => $this->input->post('mobile'), 'street' => $this->input->post('street'), 'email' => $this->input->post('email'), 'description' => $this->input->post('description') ); // Log the data for debugging log_message('debug', 'Updating lead with data: ' . json_encode($data)); // Load the model $this->load->model('Yaskawa_model'); // Try to update the lead $updated = $this->Yaskawa_model->update_lead($lead_id, $data); if ($updated) { // Return success response if update is successful echo json_encode(['success' => true]); } else { // Return error response if update failed echo json_encode(['success' => false, 'error' => 'Error updating lead!']); } } public function delete_leads() { $account_id = $this->input->post('lead_id'); if ($account_id) { $this->db->where('lead_id', $account_id); $deleted = $this->db->delete('leads'); if ($deleted) { echo json_encode(['status' => 'success']); } else { echo json_encode(['status' => 'error']); } } else { echo json_encode(['status' => 'error']); } } // Controller method to load the list of leads // potential model edit public function get_potential_details($potential_id) { $potential_details = $this->Yaskawa_model->get_potential_by_id($potential_id); if ($potential_details) { echo json_encode($potential_details); } else { echo json_encode(['error' => 'Potential not found']); } } // Method to fetch potential details by ID (model) public function get_potential_by_id($potential_id) { $this->db->where('potential_id', $potential_id); $query = $this->db->get('new_potential'); // Ensure the table name is correct return $query->row_array(); // Return as an array } public function update_potential() { // Get data from POST $potential_id = $this->input->post('potential_id'); $potential_name = $this->input->post('potential_name'); $description = $this->input->post('description'); $city = $this->input->post('city'); $amount = $this->input->post('amount'); // Validate the inputs (optional, based on your requirements) if (empty($potential_name) || empty($description) || empty($city) || empty($amount)) { echo json_encode(array('result' => 0, 'message' => 'Please fill in all fields.')); return; } // Prepare data for updating $data = array( 'potential_name' => $potential_name, 'description' => $description, 'city' => $city, 'amount' => $amount ); // Update the database record $this->db->where('potential_id', $potential_id); // Specify the record to update $this->db->update('new_potential', $data); // Update the record in the potential_table // Check if update was successful if ($this->db->affected_rows() > 0) { echo json_encode(array('result' => 1, 'message' => 'Potential updated successfully.')); } else { echo json_encode(array('result' => 0, 'message' => 'You Not ! update the potential.')); } } // ACCOUNT EDIT // Method to display account details public function fetch_account_details() { $account_id = $this->input->post('account_id'); // Fetch data from the 'new_account' table using account_id $account = $this->db->get_where('new_account', array('account_id' => $account_id))->row(); if ($account) { echo json_encode([ 'status' => 'success', 'data' => [ 'account_id' => $account->account_id, 'account_name' => $account->account_name, 'contact_person' => $account->contact_person, // Assuming 'contact_person' is the field name 'phone' => $account->phone, 'website' => $account->website, 'owner' => $account->account_owner // Assuming 'account_owner' is the field name ] ]); } else { echo json_encode(['status' => 'error']); } } // alter public function fetch(){ $account_id = $this->input->post('account_id'); $account = $this->db->get_where('new_account', array('account_id'=> $account_id) )->row(); if($account){ echo json_encode([ 'status'=>'success', 'data'=>[ 'account_id'=>$account->account_id, 'account_name'=>$account->account_name, ] ]); }else{ } } // Update account details after editing public function update_account() { $account_id = $this->input->post('account_id'); $account_name = $this->input->post('account_name'); $contact_person = $this->input->post('contact_person'); $phone = $this->input->post('phone'); $website = $this->input->post('website'); $owner = $this->input->post('owner'); // Prepare data for update $data = [ 'account_name' => $account_name, 'contact_person' => $contact_person, 'phone' => $phone, 'website' => $website, 'account_owner' => $owner // Assuming 'account_owner' is the field name ]; // Update the 'new_account' table $this->db->where('account_id', $account_id); $this->db->update('new_account', $data); echo json_encode(['status' => 'success']); } // delete public function delete_account() { $account_id = $this->input->post('account_id'); // Perform the deletion using the account_id $this->db->where('account_id', $account_id); $deleted = $this->db->delete('new_account'); // Check if deletion was successful if ($deleted) { echo json_encode(['status' => 'success']); } else { echo json_encode(['status' => 'error']); } } // end edit and upate under me 'dileep'****************************************************************************************************** //recently_deleted_reports view public function lead_source_list() { $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count=0; foreach($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if($months=='11'){ $count+=1; } } $data['count']=$count; $data['company_details']=$this->yaskawa_model->fetch_company_details(); $this->load->view('admin/lead_source_list',$data); } else { redirect('/'); } } //recently_deleted_reports view public function activity_task_event_list() { $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count=0; foreach($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if($months=='11'){ $count+=1; } } $data['count']=$count; $data['company_details']=$this->yaskawa_model->fetch_company_details(); $this->load->view('admin/activity_task_event_list',$data); } else { redirect('/'); } } //recently_deleted_reports view public function sales_across_owners() { $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count=0; foreach($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if($months=='11'){ $count+=1; } } $data['count']=$count; $data['company_details']=$this->yaskawa_model->fetch_company_details(); $this->load->view('admin/sales_across_owners',$data); } else { redirect('/'); } } //recently_deleted_reports view public function sales_count_across_owners() { $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count=0; foreach($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if($months=='11'){ $count+=1; } } $data['count']=$count; $data['company_details']=$this->yaskawa_model->fetch_company_details(); $this->load->view('admin/sales_count_across_owners',$data); } else { redirect('/'); } } //recently_deleted_reports view public function sales_across_industry() { $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count=0; foreach($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if($months=='11'){ $count+=1; } } $data['count']=$count; $data['company_details']=$this->yaskawa_model->fetch_company_details(); $this->load->view('admin/sales_across_industry',$data); } else { redirect('/'); } } //recently_deleted_reports view public function sales_across_source() { $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count=0; foreach($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if($months=='11'){ $count+=1; } } $data['count']=$count; $data['company_details']=$this->yaskawa_model->fetch_company_details(); $this->load->view('admin/sales_across_source',$data); } else { redirect('/'); } } //Sachin-part public function auto() { $keyword=$this->input->get('term'); $key=substr($keyword,1); $data1=$this->yaskawa_model->Get_search($key); foreach($data1 as $row) { $data[]=$row->lead_owner; } echo json_encode($data); } //lead_feeds view public function lead_feeds() { $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $result['user_type_id'] = $this->access_id(); $result['access'] = $this->access_details(); $result['comment']=$this->yaskawa_model->get_all_comments(); $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count=0; foreach($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if($months=='11'){ $count+=1; } } $result['count']=$count; $result['udata']=$this->yaskawa_model->get_all_users(); $result['send_data']=$this->yaskawa_model->feed_data($admin_id); $result['login_person_data']=$this->yaskawa_model->login_person($admin_id); $result['company_details']=$this->yaskawa_model->fetch_company_details(); $this->load->view('admin/lead_feeds',$result); } else { redirect('/'); } } public function admin_functions() { $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $user_data['user_type_id'] = $this->access_id(); $user_data['access'] = $this->access_details(); $user_data['users']=$this->yaskawa_model->number_of_users(); $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count=0; foreach($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if($months=='11'){ $count+=1; } } $user_data['count']=$count; $user_data['company_details']=$this->yaskawa_model->fetch_company_details(); $user_data['employee_list'] = $this->yaskawa_model->get_all_employees(); $user_data['login_person_data']=$this->yaskawa_model->login_person($admin_id); $user_data['roles_list_admin'] = $this->yaskawa_model->get_all_roles_admin(); $this->load->view('admin/admin_user',$user_data); } else { redirect('/'); } } public function insert_feeds() { $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $send_at = $date->format('Y-m-d H:i:s'); $date = $date->format('Y-m-d'); $sender_id = $this->session->userdata('admin_id'); $user_id = $this->input->post('user_id'); $message = $this->input->post('text'); $this->load->library('image_lib'); $file_name = ""; if($_FILES) { if(empty($_FILES['upload']['name'])) { $file_name = ""; } else { $target='document_uploads/'; $target.=time().$_FILES['upload']['name']; $file_name=time().$_FILES['upload']['name']; $image=$target; move_uploaded_file($_FILES['upload']['tmp_name'],$target); $config['source_image']=$target; $config['maintain_ratio']=TRUE; // $config['width']=1280; // $config['height']=960; $this->image_lib->initialize($config); //$this->image_lib->resize(); } } $feeds_details=array( 'sender_id' => $sender_id, 'receiver_id' => $user_id, 'message' => $message, 'send_date_time' => $send_at, 'document_name' => $file_name, 'date' => $date, 'delete_status' =>'ACTIVE' ); $result=$this->yaskawa_model->feed_insert($feeds_details); if($result) { echo json_encode(array('result'=>1,'res'=>$result)); } else { echo json_encode(array('result'=>0)); } } //sachin part public function feeds_data_filter(){ $days=$this->input->post('days'); $dt = new DateTime(); if($days=="today"){ $days=$dt->format('Y-m-d'); $result=$this->yaskawa_model->feeds_records($days); $ar=array(); foreach ($result as $key => $value) { $data['user_name'] = $value->sender_name; $data['comment'] = $value->message; $data['admin_pic'] = $value->admin_pic; $data['document_name'] = $value->document_name; $data['receiver_name'] = $value->receiver_name; $data['send_date_time'] = $value->send_date_time; $where=$value->feeds_id; //echo $where; $table="feeds_comment"; $data['subcomment']=$this->yaskawa_model->feeds_records1($where,$table); array_push($ar,$data); } if($ar){ echo json_encode(array('date_result'=>$ar,'result'=>1)); } else { echo json_encode(array('date_result'=>$result,'result'=>0)); } }else if($days=="yesterday"){ $days=date("Y-m-d", strtotime("-1 day")); $result=$this->yaskawa_model->feeds_records($days); $ar=array(); foreach ($result as $key => $value) { $data['user_name']=$value->sender_name; $data['comment']=$value->message; $data['admin_pic']=$value->admin_pic; $data['document_name']=$value->document_name; $data['receiver_name']=$value->receiver_name; $data['send_date_time']=$value->send_date_time; $where=$value->feeds_id; //echo $where; $table="feeds_comment"; $data['subcomment']=$this->yaskawa_model->feeds_records1($where,$table); array_push($ar,$data); } if($ar){ echo json_encode(array('date_result'=>$ar,'result'=>1)); } else { echo json_encode(array('date_result'=>$result,'result'=>0)); } }else if($days=="lastweek"){ $date= new DateTime('now', new DateTimeZone('Asia/Kolkata')); $result=$this->yaskawa_model->feeds_lastweek__records(); $ar1=array(); foreach ($result as $key => $value) { $data['user_name']=$value->sender_name; $data['comment']=$value->message; $data['admin_pic']=$value->admin_pic; $data['document_name']=$value->document_name; $data['receiver_name']=$value->receiver_name; $data['send_date_time']=$value->send_date_time; $where=$value->feeds_id; //echo $where; $table="feeds_comment"; $data['subcomment']=$this->yaskawa_model->feeds_lastweek__records1($where,$table); array_push($ar1,$data); } if($ar1){ echo json_encode(array('date_result'=>$ar1,'result'=>1)); } else { echo json_encode(array('date_result'=>$result,'result'=>0)); } }else if($days=="current-month"){ $date= new DateTime('now', new DateTimeZone('Asia/Kolkata')); $current_month = $date->format('m'); $result=$this->yaskawa_model->currentmonth_feeds_records($current_month); $ar2=array(); foreach ($result as $key => $value) { $data['user_name']=$value->sender_name; $data['comment']=$value->message; $data['admin_pic']=$value->admin_pic; $data['document_name']=$value->document_name; $data['receiver_name']=$value->receiver_name; $data['send_date_time']=$value->send_date_time; $where=$value->feeds_id; //echo $where; $table="feeds_comment"; $data['subcomment']=$this->yaskawa_model->currentmonth_feeds_records1($where,$table,$current_month); array_push($ar2,$data); } if($ar2){ echo json_encode(array('date_result'=>$ar2,'result'=>1)); } else { echo json_encode(array('date_result'=>$result,'result'=>0)); } }else if($days=="lastmonth"){ $date= new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date = $date->format("Y-m-d"); $lastmonth=date("m", strtotime("-1 MONTH")); $result=$this->yaskawa_model->feeds_lastmonth__records($lastmonth); $ar3=array(); foreach ($result as $key => $value) { $data['user_name']=$value->sender_name; $data['comment']=$value->message; $data['admin_pic']=$value->admin_pic; $data['document_name']=$value->document_name; $data['receiver_name']=$value->receiver_name; $data['send_date_time']=$value->send_date_time; $where=$value->feeds_id; //echo $where; $table="feeds_comment"; $data['subcomment']=$this->yaskawa_model->currentmonth_feeds_records1($where,$table,$lastmonth); array_push($ar3,$data); } if($ar3){ echo json_encode(array('date_result'=>$ar3,'result'=>1)); } else { echo json_encode(array('date_result'=>$result,'result'=>0)); } } } //Add New Leads public function add_new_lead() { $admin_id = $this->session->userdata('admin_id'); $role_id = $this->session->userdata('role_id'); $lead_owner = $this->input->post('lead_owner'); $company_name = $this->input->post('company_name'); $first_name = $this->input->post('first_name'); $last_name = $this->input->post('last_name'); $lead_title = $this->input->post('lead_title'); $email = $this->input->post('email'); $phone = $this->input->post('phone'); $fax = $this->input->post('fax'); $mobile = $this->input->post('mobile'); $website = $this->input->post('website'); $lead_source = $this->input->post('lead_source'); $industry = $this->input->post('industry'); $no_of_employees = $this->input->post('no_of_employees'); $annual_revenue = $this->input->post('annual_revenue'); $ratings = $this->input->post('ratings'); $service_name = $this->input->post('service_name'); $service_date = $this->input->post('service_date'); $service_amount = $this->input->post('service_amount'); $alternate_email = $this->input->post('alternate_email'); $alternate_phone = $this->input->post('alternate_phone'); if(!empty($service_name)){ $service_names=json_encode($service_name); }else { $service_names=''; } if(!empty($service_amount)){ $service_amounts=json_encode($service_amount); }else { $service_amounts=''; } if(!empty($service_date)){ $service_dates=json_encode($service_date); }else { $service_dates=''; } $email_otps = $this->input->post('email_otp'); if($email_otps=='on') { $email_otp='YES'; }else { $email_otp='NO'; } $skype_id = $this->input->post('skype_id'); $sec_email = $this->input->post('sec_email'); // $twitter = $this->input->post('twitter'); $street = $this->input->post('street'); $city = $this->input->post('city'); $state = $this->input->post('state'); $zip_code = $this->input->post('zip_code'); $country = $this->input->post('country'); $Cperson = $this->input->post('Cperson'); $explode=explode(':',$Cperson); if(count($explode)==2) { $Cperson=$explode[0]; $contact_id=$explode[1]; } else { $Cperson=$explode[0]; $contact_id=0; } $Cphone = $this->input->post('Cphone'); $cType = $this->input->post('cType'); $lprocess = $this->input->post('lprocess'); $description = $this->input->post('description'); $lead_status = $this->input->post('lead_status'); $this->load->library('image_lib'); $file_name = ""; $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $created_at = $date->format('Y-m-d'); $lead_details = array( 'service_amount'=>$service_amounts, 'service_date'=>$service_dates, 'service_name'=>$service_names, 'user_id' => $admin_id, 'contact_id' => $contact_id, 'role_id' => $role_id, 'lead_owner' => $lead_owner, 'company_name' => $company_name, 'first_name' => $first_name, 'last_name' => $last_name, 'lead_title' => $lead_title, 'email' => $email, 'phone' => $phone, 'website' => $website, 'fax' => $fax, 'mobile' => $mobile, 'lead_source' => $lead_source, 'lead_status' => $lead_status, 'industry' => $industry, 'no_of_employees' => $no_of_employees, 'annual_revenue' => $annual_revenue, 'ratings' => $ratings, 'email_otp' => $email_otp, 'skype_id' => $skype_id, 'sec_email' => $sec_email, //'twitter' => $twitter, 'street' => $street, 'city' => $city, 'state' => $state, 'zip_code' => $zip_code, 'country' => $country, 'Cperson' => $Cperson, 'Cphone' => $Cphone, 'cType' => $cType, 'lprocess' => $lprocess, 'description' => $description, 'delete_status' => 'ACTIVE', 'l_type' => 'LEAD', 'alternate_email' => $alternate_email, 'alternate_phone' => $alternate_phone, 'created_at' => $created_at ); $Cperson = $this->input->post('Cperson'); $tbl='leads'; //$condition1=array('email' => $email,'delete_status' => 'ACTIVE'); //$condition2=array('mobile' => $mobile,'delete_status' => 'ACTIVE'); //$details1=$this->yaskawa_model->get_where_row($tbl,$condition1); //$details2=$this->yaskawa_model->get_where_row($tbl,$condition2); //if($details1->email==''){ //if($details2->mobile==''){ $result = $this->yaskawa_model->add_leads($lead_details); echo json_encode(array('result'=>1,'message'=>"Lead added successfully")); //}else //{ //echo json_encode(array('result'=>0,'message'=>"Mobil number already exists")); //} //} //else //{ /// echo json_encode(array('result'=>0,'message'=>"Email id already exists")); //} } //lead list public function leads_list() { $result = $this->yaskawa_model->get_all_leads(); $menu = $this->yaskawa_model->get_menu(); if($result) { echo json_encode(array('menu'=>$menu,'leads_list'=>$result,'result'=>1)); } else { echo json_encode(array('result'=>0)); } } //Delete lead public function delete_lead() { $lead_id = $this->input->post('lead_id'); $data = array('delete_status'=>'INACTIVE'); $result = $this->yaskawa_model->delete_lead($lead_id,$data); if($this->db->affected_rows() > 0) { echo json_encode(array('result'=>1,'message'=>'Deleted successfully')); } else { echo json_encode(array('result'=>0)); } } public function delete_potential() { $lead_id = $this->input->post('id'); $data = array('delete_status'=>'INACTIVE'); $result = $this->yaskawa_model->delete_potential($lead_id,$data); if($this->db->affected_rows() > 0) { echo json_encode(array('result'=>1,'message'=>'Deleted successfully')); } else { echo json_encode(array('result'=>0)); } } public function edit_lead() { $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count=0; foreach($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if($months=='11'){ $count+=1; } } $data['count']=$count; $lead_id = $this->uri->segment(2); $data['lead_details'] = $this->yaskawa_model->edit_lead_details($lead_id); $data['company_details']=$this->yaskawa_model->fetch_company_details(); $this->load->view('admin/edit_content_form',$data); } else { redirect('/'); } } //Update lead public function update_leads() { $lead_id = $this->input->post('lead_id'); $lead_owner = $this->input->post('lead_owner'); $company_name = $this->input->post('company_name'); $first_name = $this->input->post('first_name'); $last_name = $this->input->post('last_name'); $lead_title = $this->input->post('lead_title'); $email = $this->input->post('email'); $phone = $this->input->post('phone'); $fax = $this->input->post('fax'); $mobile = $this->input->post('mobile'); $website = $this->input->post('website'); $lead_source = $this->input->post('lead_source'); $industry = $this->input->post('industry'); $no_of_employees = $this->input->post('no_of_employees'); $annual_revenue = $this->input->post('annual_revenue'); $ratings = $this->input->post('ratings'); $email_otp = $this->input->post('email_otp'); if($email_otps=='on') { $email_otp='YES'; }else { $email_otp='NO'; } $skype_id = $this->input->post('skype_id'); $sec_email = $this->input->post('sec_email'); //$twitter = $this->input->post('twitter'); $street = $this->input->post('street'); $city = $this->input->post('city'); $state = $this->input->post('state'); $zip_code = $this->input->post('zip_code'); $country = $this->input->post('country'); $description = $this->input->post('description'); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $updated_at = $date->format('Y-m-d H:i:s'); $lead_details = array( 'lead_owner' => $lead_owner, 'company_name' => $company_name, 'first_name' => $first_name, 'last_name' => $last_name, 'lead_title' => $lead_title, 'email' => $email, 'phone' => $phone, 'website' => $website, 'fax' => $fax, 'mobile' => $mobile, 'lead_source' => $lead_source, 'industry' => $industry, 'no_of_employees' => $no_of_employees, 'annual_revenue' => $annual_revenue, 'ratings' => $ratings, 'email_otp' => $email_otp, 'skype_id' => $skype_id, 'sec_email' => $sec_email, //'twitter' => $twitter, 'street' => $street, 'city' => $city, 'state' => $state, 'zip_code' => $zip_code, 'country' => $country, 'description' => $description, 'delete_status' => 'ACTIVE', 'updated_at' => $updated_at ); $result = $this->yaskawa_model->update_lead($lead_id,$lead_details); if($this->db->affected_rows() > 0) { echo json_encode(array('result'=>1,'message'=>"Updated successfully")); } else { echo json_encode(array('result'=>0,'message'=>"Failed to update. Try again")); } } //Add New Employee public function add_new_employees(){ $employee_id = $this->input->post('employee_id'); //$employee_id='JB-100'.$employee_id; $first_name = $this->input->post('first_name'); $last_name = $this->input->post('last_name'); $email_id = $this->input->post('email_id'); $nick_name = $this->input->post('nick_name'); $department_id = $this->input->post('department_id'); //$designation_id = $this->input->post('designation_id'); $reporting_to = $this->input->post('reporting_to'); $source_of_hire = $this->input->post('source_of_hire'); $location = $this->input->post('location'); $title = $this->input->post('title'); $date_of_joining = $this->input->post('date_of_joining'); $seating_location = $this->input->post('seating_location'); $work_phone = $this->input->post('work_phone'); $extension = $this->input->post('extension'); $employee_status = $this->input->post('employee_status'); $employee_type = $this->input->post('employee_type'); $company_name = $this->input->post('company_name'); $role_id = $this->input->post('role_id'); $pan_no = $this->input->post('pan_no'); $date_of_birth = $this->input->post('date_of_birth'); $address = $this->input->post('address'); $residential_address = $this->input->post('residential_address'); $marital_status = $this->input->post('marital_status'); $job_description = $this->input->post('job_description'); $about_me = $this->input->post('about_me'); $date_of_exit = $this->input->post('date_of_exit'); $gender = $this->input->post('gender'); $pre_com_name = $this->input->post('pre_com_name'); $pre_com_name1 = json_encode($pre_com_name); $job_title = $this->input->post('job_title'); $job_title1 = json_encode($job_title); $from_date = $this->input->post('from_date'); $from_date1 = json_encode($from_date); $to_date = $this->input->post('to_date'); $to_date1 = json_encode($to_date); $work_job_description = $this->input->post('work_job_description'); $work_job_description1 = json_encode($work_job_description); $school_name = $this->input->post('school_name'); $diplamo_degree = $this->input->post('diplamo_degree'); $field_of_study = $this->input->post('field_of_study'); $date_of_completion = $this->input->post('date_of_completion'); $additional_notes = $this->input->post('additional_notes'); $interests = $this->input->post('interests'); $dependent_name = $this->input->post('dependent_name'); $dependent_name1 = json_encode($dependent_name); $dependent_relationship = $this->input->post('dependent_relationship'); $dependent_relationship1 = json_encode($dependent_relationship); $dependent_dob = $this->input->post('dependent_dob'); $dependent_dob1 = json_encode($dependent_dob); $aggregate = $this->input->post('aggregate'); $aggregate1 = json_encode($aggregate); // $documents = $this->input->post(); // To handle file inputs $this->load->library('upload'); // Load upload library $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $created_at = $date->format('Y-m-d'); $employee_details = array( 'employee_id' => $employee_id, 'first_name' => $first_name, 'last_name' => $last_name, 'email_id' => $email_id, 'nick_name' => $nick_name, 'department_id' => $department_id, 'reporting_to' => $reporting_to, 'source_of_hire' => $source_of_hire, 'location' => $location, 'title' => $title, 'date_of_joining' => $date_of_joining, 'seating_location' => $seating_location, 'work_phone' => $work_phone, 'extension' => $extension, 'employee_status' => $employee_status, 'employee_type' => $employee_type, 'company_name' => $company_name, 'role_id' => $role_id, 'pan_no' => $pan_no, 'date_of_birth' => $date_of_birth, 'address' => $address, 'residential_address'=> $residential_address, 'marital_status' => $marital_status, 'job_description' => $job_description, 'about_me' => $about_me, 'date_of_exit' => $date_of_exit, 'gender' => $gender, 'pre_company_name' => $pre_com_name1, 'job_title' => $job_title1, 'from_date' => $from_date1, 'to_date' => $to_date1, 'work_job_description' => $work_job_description1, 'dependent_name' => $dependent_name1, 'dependent_relationship' => $dependent_relationship1, 'dependent_dob' => $dependent_dob1, 'delete_status' => 'ACTIVE', 'created_at' => $created_at ); $documents = []; if ( isset($_FILES['doc_file']) && !empty($_FILES['doc_file']['name'][0]) ) { $doc_files = $_FILES['doc_file']; $doc_names = $this->input->post('doc_name'); $allowed_extensions = ['jpg','jpeg','png','gif','pdf','doc','docx','xls','xlsx']; for ($i = 0; $i < count($doc_files['name']); $i++) { if (empty($doc_names[$i]) || empty($doc_files['name'][$i])) { continue; } $ext = pathinfo($doc_files['name'][$i], PATHINFO_EXTENSION); if (!in_array(strtolower($ext), $allowed_extensions)) { continue; } if ($doc_files['size'][$i] > 5 * 1024 * 1024) { continue; } $safe_name = time().'_'.$i.'_'.preg_replace('/[^a-zA-Z0-9\._-]/','_', $doc_files['name'][$i]); $target_path = 'files/'.$safe_name; if (move_uploaded_file($doc_files['tmp_name'][$i], $target_path)) { $documents[] = [ 'name' => $doc_names[$i], 'file' => $target_path ]; } } } /* Store JSON in employee table */ if (!empty($documents)) { $employee_details['documents'] = json_encode($documents, JSON_UNESCAPED_UNICODE); } // Add the employee to the database $result = $this->yaskawa_model->add_employee($employee_details); // Handle the education details as before if (!empty($school_name)) { foreach ($school_name as $key => $d) { $education_details = array( 'employee_id' => $result, 'college_name' => $school_name[$key], 'diplamo_degree' => $diplamo_degree[$key], 'field_of_study' => $field_of_study[$key], 'date_of_completion' => $date_of_completion[$key], 'additional_notes' => $additional_notes[$key], 'interests' => $interests[$key], 'aggregate' => $aggregate[$key], 'delete_status' => 'ACTIVE', 'created_at' => $created_at ); $cpt = count($_FILES['file_upload'.$key]['name']); $file_doc = ""; for ($i = 0; $i < $cpt; $i++) { if ($_FILES['file_upload'.$key]['name']) { $path = $_FILES['file_upload'.$key]['name'][$i]; $target = 'files/'; $target .= time() . $_FILES['file_upload'.$key]['name'][$i]; $document[] = time() . $_FILES['file_upload'.$key]['name'][$i]; move_uploaded_file($_FILES['file_upload'.$key]['tmp_name'][$i], $target); $file_doc = $document; } else { $file_doc = ""; } } $education_details['file'] = json_encode($file_doc); // Add education details to the database $result_edu = $this->yaskawa_model->add_employee_education($education_details); } } // Return success message if employee is added successfully if ($result) { echo json_encode(array('result' => 1, 'message' => "Employee added successfully")); } else { echo json_encode(array('result' => 0, 'message' => "Something went wrong.. try again")); } } //employee list public function employee_list() { $result = $this->yaskawa_model->get_all_employees(); if($result) { echo json_encode(array('employee_list'=>$result,'result'=>1)); } else { echo json_encode(array('result'=>0)); } } //Add New department public function add_new_department() { $department_name = $this->input->post('department_name'); $email_id = $this->input->post('email_id'); $department_lead = $this->input->post('department_lead'); $parent_department = $this->input->post('parent_department'); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $created_at = $date->format('Y-m-d H:i:s'); $department_details = array( 'department_name' => $department_name, 'email_id' => $email_id, 'department_lead' => $department_lead, 'parent_department' => $parent_department, 'delete_status' => 'ACTIVE', 'created_at' => $created_at ); $result = $this->yaskawa_model->add_department($department_details); if($result) { echo json_encode(array('result'=>1,'message'=>"Department added successfully")); } else { echo json_encode(array('result'=>0,'message'=>"Something went wrong.. try again")); } } //department list public function department_list() { $result = $this->yaskawa_model->get_all_departments(); if($result) { echo json_encode(array('department_list'=>$result,'result'=>1)); } else { echo json_encode(array('result'=>0)); } } //Delete department public function delete_department() { $department_id = $this->input->post('id'); $data = array('delete_status'=>'INACTIVE'); $result = $this->yaskawa_model->delete_department($department_id,$data); if($this->db->affected_rows() > 0) { echo json_encode(array('result'=>1,'message'=>'Deleted successfully')); } else { echo json_encode(array('result'=>0,'message'=>'Something went wrong')); } } //Edit department // public function edit_department() // { // $admin_id = $this->session->userdata('admin_id'); // if($admin_id) // { // $data['user_type_id'] = $this->access_id(); // $data['access'] = $this->access_details(); // $department_id = $this->uri->segment(2); // $data['emp_details'] = $this->yaskawa_model->edit_department_details($department_id); // $data['company_details']=$this->yaskawa_model->fetch_company_details(); // $this->load->view('admin/edit_content_form',$data); // } // else // { // redirect('/'); // } // } public function edit_department() { $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $department_id=$this->input->post('id'); $data['company_details'] = $this->yaskawa_model->fetch_company_details(); $table='department'; $where=array('department_id'=>$department_id,'delete_status'=>'ACTIVE'); $result = $this->yaskawa_model->get_data_row($table,$where); $data['dept_list'] = $this->yaskawa_model->get_all_departments(); if($result) { echo json_encode(array('result'=>1,'message'=>$result)); } else { echo json_encode(array('result'=>0,'message'=>"No data found")); } } else { redirect('/'); } } public function update_department() { $department_id = $this->input->post('department_id'); $department_name = $this->input->post('department_name'); $email_id = $this->input->post('email_id'); $department_lead = $this->input->post('department_lead'); $parent_department = $this->input->post('parent_department'); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $updated_at = $date->format('Y-m-d H:i:s'); $department_details = array('department_name' => $department_name, 'email_id' => $email_id, 'department_lead' => $department_lead, 'parent_department' => $parent_department, 'delete_status' => 'ACTIVE', 'updated_at' => $updated_at); $result = $this->yaskawa_model->update_department($department_id,$department_details); if($result > 0) { echo json_encode(array('result'=>1,'message'=>"Updated successfully")); } else { echo json_encode(array('result'=>0,'message'=>"Failed to update. Try again")); } } //Add New designation public function add_new_designation() { $designation_name = $this->input->post('designation_name'); $email_id = $this->input->post('email_id'); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $created_at = $date->format('Y-m-d H:i:s'); $designation_details = array( 'designation_name' => $designation_name, 'email_id' => $email_id, 'delete_status' => 'ACTIVE', 'created_at' => $created_at ); $result = $this->yaskawa_model->add_designation($designation_details); if($result) { echo json_encode(array('result'=>1,'message'=>"Designation added successfully")); } else { echo json_encode(array('result'=>0,'message'=>"Something went wrong.. try again")); } } //designation list public function designation_list() { $result = $this->yaskawa_model->get_all_designation(); if($result) { echo json_encode(array('designation_list'=>$result,'result'=>1)); } else { echo json_encode(array('result'=>0)); } } //Delete department public function delete_designation() { $designation_id = $this->input->post('id'); $data = array('delete_status'=>'INACTIVE'); $result = $this->yaskawa_model->delete_designation($designation_id,$data); if($this->db->affected_rows() > 0) { echo json_encode(array('result'=>1,'message'=>'Deleted successfully')); } else { echo json_encode(array('result'=>0,'message'=>'Something went wrong')); } } public function edit_role() { $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $role_id=$this->input->post('id'); $table='roles'; $where=array('role_id'=>$role_id,'delete_status'=>'ACTIVE'); $result = $this->yaskawa_model->get_data_row($table,$where); $data['dept_list'] = $this->yaskawa_model->get_all_departments(); if($result) { echo json_encode(array('result'=>1,'message'=>$result)); } else { echo json_encode(array('result'=>0,'message'=>"No data found")); } } else { redirect('/'); } } //Edit designation public function edit_designation() { $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $designation_id=$this->input->post('id'); $data['company_details'] = $this->yaskawa_model->fetch_company_details(); $table='designation'; $where=array('designation_id'=>$designation_id,'delete_status'=>'ACTIVE'); $result = $this->yaskawa_model->get_data_row($table,$where); $data['dept_list'] = $this->yaskawa_model->get_all_departments(); if($result) { echo json_encode(array('result'=>1,'message'=>$result)); } else { echo json_encode(array('result'=>0,'message'=>"No data found")); } } else { redirect('/'); } } //update department public function update_designation() { $designation_id = $this->input->post('designation_id'); $designation_name = $this->input->post('designation_name'); $email_id = $this->input->post('email_id'); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $updated_at = $date->format('Y-m-d H:i:s'); $designation_details = array('designation_name' => $designation_name, 'email_id' => $email_id, 'delete_status' => 'ACTIVE', 'updated_at' => $updated_at); $result = $this->yaskawa_model->update_designation($designation_id,$designation_details); if($result > 0) { echo json_encode(array('result'=>1,'message'=>"Updated successfully")); } else { echo json_encode(array('result'=>0,'message'=>"Failed to update. Try again")); } } //menu_list public function menu_list() { $result = $this->yaskawa_model->get_all_menu(); if($result) { echo json_encode(array('menu_list'=>$result,'result'=>1)); } else { echo json_encode(array('result'=>0)); } } //menu_details public function menu_details() { $menu_id = $this->input->post('id'); $alt_name = $this->input->post('alt_name'); $menu_status = array('status'=>'1'); $result = $this->yaskawa_model->update_menu_status($menu_id,$menu_status); if($this->db->affected_rows() > 0) { echo json_encode(array('result'=>1)); } else { echo json_encode(array('result'=>0)); } } //single_lead_view public function single_lead_view() { $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $lead_id = $this->uri->segment(2); //$data['user_details']=$this->yaskawa_model->get_user_details4($lead_id); $data['user_details']=$this->yaskawa_model->get_user_details_new(); $data['customer_type']=$this->yaskawa_model->get_customer_type(); $data['single_details'] = $this->yaskawa_model->single_lead_detail($lead_id); $data['pic_details'] = $this->yaskawa_model->get_pic_details($lead_id); $data['lead_details'] = $this->yaskawa_model->get_event_call_details_lead($lead_id); $data['closed_details'] = $this->yaskawa_model->get_event_closed_details_lead($lead_id); $data['notes_details'] = $this->yaskawa_model->get_notes_details($lead_id); $data['attachment_details'] = $this->yaskawa_model->get_attachment_details($lead_id); $data['converted_status'] = $this->yaskawa_model->get_converted_status_new_leads($lead_id); $data['quotation_details'] = $this->yaskawa_model->get_quotation_details_lead($lead_id); $data['lead_process']=$this->yaskawa_model->get_lead_process(); $data['company_details']=$this->yaskawa_model->fetch_company_details(); $data['lead_ratings'] = $this->yaskawa_model->get_lead_ratings_details(); $data['industry_details'] = $this->yaskawa_model->get_lead_industry_details(); $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count=0; foreach($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if($months=='11'){ $count+=1; } } $data['count']=$count; $this->load->view('admin/lead_information',$data); } else { redirect('/'); } } public function lead_report_view() { $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $lead_id = $this->uri->segment(2); //$data['user_details']=$this->yaskawa_model->get_user_details4($lead_id); $data['user_details']=$this->yaskawa_model->get_user_details_new(); $data['customer_type']=$this->yaskawa_model->get_customer_type(); $data['single_details'] = $this->yaskawa_model->single_lead_details($lead_id); $data['pic_details'] = $this->yaskawa_model->get_pic_details($lead_id); $data['lead_details'] = $this->yaskawa_model->get_event_call_details_lead($lead_id); $data['closed_details'] = $this->yaskawa_model->get_event_closed_details_lead($lead_id); $data['notes_details'] = $this->yaskawa_model->get_notes_details($lead_id); $data['attachment_details'] = $this->yaskawa_model->get_attachment_details($lead_id); $data['converted_status'] = $this->yaskawa_model->get_converted_status_new_leads($lead_id); $data['quotation_details'] = $this->yaskawa_model->get_quotation_details_lead($lead_id); $data['lead_process']=$this->yaskawa_model->get_lead_process(); $data['company_details']=$this->yaskawa_model->fetch_company_details(); $data['lead_ratings'] = $this->yaskawa_model->get_lead_ratings_details(); $data['industry_details'] = $this->yaskawa_model->get_lead_industry_details(); $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count=0; foreach($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if($months=='11'){ $count+=1; } } $data['count']=$count; $this->load->view('admin/lead_report_view',$data); } else { redirect('/'); } } //lead_information view public function closed_activity() { $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $task_id = $this->uri->segment(2); $dat=array('activity'=>'CLOSE','delete_status'=>'ACTIVE'); $this->yaskawa_model->update_status($task_id,$dat); $det=$this->yaskawa_model->get_row($task_id); $lead_id=$det->lead_id; $data['user_details'] = $this->yaskawa_model->get_user_details4($task_id); $data['customer_type'] = $this->yaskawa_model->get_customer_type(); $data['single_details'] = $this->yaskawa_model->single_lead_details($lead_id); $data['pic_details'] = $this->yaskawa_model->get_pic_details($lead_id); $data['lead_details'] = $this->yaskawa_model->get_event_call_details_lead($lead_id); $data['closed_details'] = $this->yaskawa_model->get_event_closed_details_lead($lead_id); $data['notes_details'] = $this->yaskawa_model->get_notes_details($lead_id); $data['attachment_details'] = $this->yaskawa_model->get_attachment_details($lead_id); $data['company_details'] = $this->yaskawa_model->fetch_company_details(); $data['converted_status'] = $this->yaskawa_model->get_converted_status_new($lead_id); $data['quotation_details'] = $this->yaskawa_model->get_quotation_details_lead($lead_id); $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count=0; foreach($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if($months=='11'){ $count+=1; } } $data['count']=$count; $this->load->view('admin/lead_information',$data); } else { redirect('/'); } } public function account_info() { $admin_id = $this->session->userdata('admin_id'); $role_id = $this->session->userdata('role_id'); if($admin_id) { $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $id = $this->uri->segment(2); $data['user_name']= $this->session->userdata('user_name'); $data['honorific']=$this->yaskawa_model->get_honorific(); $data['user_details']=$this->yaskawa_model->get_user_details2($id); $data['single_details'] = $this->yaskawa_model->single_lead_details($id); $data['account_details'] = $this->yaskawa_model->single_account_details($id); $data['quotation_details'] = $this->yaskawa_model->get_quotation_details_account($id); $data['converted_status'] = $this->yaskawa_model->get_converted_status_new($id); $data['notes_details'] = $this->yaskawa_model->get_account_notes_details($id); $data['task_details'] = $this->yaskawa_model->get_account_task_details($id); $data['closed_details'] = $this->yaskawa_model->get_acc_closed_details($id); $data['lead_ratings'] = $this->yaskawa_model->get_lead_ratings_details(); $table='new_account'; $condition=array('delete_status'=>'ACTIVE','old_account_id'=>$id); $data['new_member']= $this->yaskawa_model->fetch_where_data($table,$condition); //$data['contact_data']=$this->yaskawa_model->contact_list($role_id); $data['potential_data']=$this->yaskawa_model->select_new_potential($role_id); $data['potential_related'] = $this->yaskawa_model->potential_related($id); $data['contact_related'] = $this->yaskawa_model->contact_related($id); $data['account_type'] = $this->yaskawa_model->get_account_type(); $data['industry_details'] = $this->yaskawa_model->get_lead_industry_details(); $table="masters"; $where=array('master_type_id'=>'13','delete_status'=>'ACTIVE'); $data['account_type']=$this->yaskawa_model->get_where_row($table,$where); $table="masters"; $where=array('master_type_id'=>'14','delete_status'=>'ACTIVE'); $data['account_site']=$this->yaskawa_model->get_where_row($table,$where); $data['acc_attachment_details'] = $this->yaskawa_model->get_acc_attachment_details($id); $data['company_details']=$this->yaskawa_model->fetch_company_details(); $data['user_details']=$this->yaskawa_model->get_user_details(); $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count=0; foreach($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if($months=='11'){ $count+=1; } } $data['count']=$count; $account_id = $this->uri->segment(2); $company_table = 'companies'; $where_company = array('delete_status' => 'ACTIVE','account_id' => $account_id); $data['companies'] = $this->yaskawa_model->get_where_result($company_table,$where_company); $this->load->view('admin/account_info',$data); } else { redirect('/'); } } //import excel file to db public function import_leads() { $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $created_at = $date->format('Y-m-d H:i:s'); include '../PHPExcel/IOFactory.php'; if(isset($_FILES['import_leads']['name'])) { $file_name = $_FILES['import_leads']['name']; $ext = pathinfo($file_name, PATHINFO_EXTENSION); if($ext == "xlsx" || $ext == "xls") { $file_name = $_FILES['import_leads']['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'; //$this->erp_model->table_truncate($table); if(count($allDataInSheet)>0){ for($i = 2;$i <= $arrayCount;$i++){ //$sl_no = trim($allDataInSheet[$i]["A"]); $lead_owner = trim($allDataInSheet[$i]["B"]); $company_name = trim($allDataInSheet[$i]["C"]); $first_name = trim($allDataInSheet[$i]["D"]); $last_name = trim($allDataInSheet[$i]["E"]); $lead_title = trim($allDataInSheet[$i]["F"]); $email = trim($allDataInSheet[$i]["G"]); $phone = trim($allDataInSheet[$i]["H"]); $fax = trim($allDataInSheet[$i]["I"]); $mobile = trim($allDataInSheet[$i]["J"]); $website = trim($allDataInSheet[$i]["K"]); $lead_source = trim($allDataInSheet[$i]["L"]); $industry = trim($allDataInSheet[$i]["M"]); $no_of_employees = trim($allDataInSheet[$i]["N"]); $annual_revenue = trim($allDataInSheet[$i]["O"]); $ratings = trim($allDataInSheet[$i]["P"]); $email_otp = trim($allDataInSheet[$i]["Q"]); $skype_id = trim($allDataInSheet[$i]["R"]); $sec_email = trim($allDataInSheet[$i]["S"]); $twitter = trim($allDataInSheet[$i]["T"]); $street = trim($allDataInSheet[$i]["U"]); $city = trim($allDataInSheet[$i]["V"]); $state = trim($allDataInSheet[$i]["W"]); $zip_code = trim($allDataInSheet[$i]["X"]); $country = trim($allDataInSheet[$i]["Y"]); $description = trim($allDataInSheet[$i]["Z"]); $data =array( 'lead_owner' => $lead_owner, 'company_name' => $company_name, 'first_name' => $first_name, 'last_name' => $last_name, 'lead_title' => $lead_title, 'email' => $email, 'phone' => $phone, 'fax' => $fax, 'mobile' => $mobile, 'website' => $website, 'lead_source' => $lead_source, 'industry' => $industry, 'no_of_employees' => $no_of_employees, 'annual_revenue' => $annual_revenue, 'ratings' => $ratings, 'email_otp' => $email_otp, 'skype_id' => $skype_id, 'sec_email' => $sec_email, 'twitter' => $twitter, 'street' => $street, 'city' => $city, 'state' => $state, 'zip_code' => $zip_code, 'country' => $country, 'description' => $description, 'delete_status' => 'ACTIVE', 'created_at ' => $created_at ); $result = $this->yaskawa_model->import_lead_data($data); } echo json_encode(array('result'=>1,'message'=>"Leads added successfully")); } } } else { echo json_encode(array('result'=>3,'message'=>"Please upload file with xlsx extension only")); } } public function todays_sales() { $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $lead_id = $this->uri->segment(2); $data['details'] = $this->yaskawa_model->todays_sales(); $data['company_details']=$this->yaskawa_model->fetch_company_details(); $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count=0; foreach($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if($months=='11'){ $count+=1; } } $data['count']=$count; $this->load->view('admin/potential_todays_sales',$data); } else { redirect('/'); } } public function month_sale() { $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $lead_id = $this->uri->segment(2); $data['details'] = $this->yaskawa_model->month_sale(); $data['company_details']=$this->yaskawa_model->fetch_company_details(); $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count=0; foreach($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if($months=='11'){ $count+=1; } } $data['count']=$count; $this->load->view('admin/potential_sales_this_month',$data); } else { redirect('/'); } } public function task_event() { $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $lead_id = $this->uri->segment(2); $data['details'] = $this->yaskawa_model->task($lead_id); $data['company_details']=$this->yaskawa_model->fetch_company_details(); $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count=0; foreach($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if($months=='11'){ $count+=1; } } $data['count']=$count; $this->load->view('admin/activity_task_event_list',$data); } else { redirect('/'); } } public function event_task() { $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $lead_id = $this->uri->segment(2); $data['details'] = $this->yaskawa_model->task($lead_id); $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count=0; foreach($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if($months=='11'){ $count+=1; } } $data['count']=$count; $data['company_details']=$this->yaskawa_model->fetch_company_details(); $this->load->view('admin/activity_task_event_list',$data); } else { redirect('/'); } } public function call_status() { $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $lead_id = $this->uri->segment(2); $data['details'] = $this->yaskawa_model->call_status($lead_id); $data['company_details']=$this->yaskawa_model->fetch_company_details(); $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count=0; foreach($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if($months=='11'){ $count+=1; } } $data['count']=$count; $this->load->view('admin/activity_call_status',$data); } else { redirect('/'); } } public function sales_source() { $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $lead_id = $this->uri->segment(2); $data['details'] = $this->yaskawa_model->sales_source(); $data['company_details']=$this->yaskawa_model->fetch_company_details(); $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count=0; foreach($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if($months=='11'){ $count+=1; } } $data['count']=$count; $this->load->view('admin/potential_lead_source',$data); } else { redirect('/'); } } public function converted_leads() { $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $lead_id = $this->uri->segment(2); $data['details'] = $this->yaskawa_model->acc_converted_leads(); $data['company_details']=$this->yaskawa_model->fetch_company_details(); $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count=0; foreach($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if($months=='11'){ $count+=1; } } $data['count']=$count; $this->load->view('admin/lead_converted_list',$data); } else { redirect('/'); } } public function ownership() { $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $result['user_type_id'] = $this->access_id(); $result['access'] = $this->access_details(); $result['lead_owner_data']=$this->yaskawa_model->ownership(); $result['company_details']=$this->yaskawa_model->fetch_company_details(); $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count=0; foreach($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if($months=='11'){ $count+=1; } } $result['count']=$count; $this->load->view('admin/lead_ownership_list',$result); } else { redirect('/'); } } //industry_leads view public function industry_leads() { $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $result['user_type_id'] = $this->access_id(); $result['access'] = $this->access_details(); $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count=0; foreach($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if($months=='11'){ $count+=1; } } $result['count']=$count; $result['industry_leads'] = $this->yaskawa_model->leads_by_industry(); $result['company_details']=$this->yaskawa_model->fetch_company_details(); $this->load->view('admin/lead_industry_list',$result); } else { redirect('/'); } } //recently_deleted_reports view public function today_leads() { $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $result['user_type_id'] = $this->access_id(); $result['access'] = $this->access_details(); $result['today_leads'] = $this->yaskawa_model->todays_leads_list(); $result['company_details']=$this->yaskawa_model->fetch_company_details(); $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count=0; foreach($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if($months=='11'){ $count+=1; } } $result['count']=$count; $this->load->view('admin/lead_todays_list',$result); } else { redirect('/'); } } //lead_status view public function lead_status() { $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $result['user_type_id'] = $this->access_id(); $result['access'] = $this->access_details(); $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count=0; foreach($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if($months=='11'){ $count+=1; } } $result['count']=$count; $result['lead_status'] = $this->yaskawa_model->leads_by_status(); $result['company_details']=$this->yaskawa_model->fetch_company_details(); $this->load->view('admin/lead_status_list',$result); } else { redirect('/'); } } //favorite_reports view public function favorite_reports() { $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $result['user_type_id'] = $this->access_id(); $result['access'] = $this->access_details(); $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count=0; foreach($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if($months=='11'){ $count+=1; } } $result['count']=$count; $result['fav_reoprts'] = $this->yaskawa_model->favorite_reports(); $result['company_details']=$this->yaskawa_model->fetch_company_details(); $this->load->view('admin/favorite_reports',$result); } else { redirect('/'); } } //leads_source view public function leads_source() { $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $result['user_type_id'] = $this->access_id(); $result['access'] = $this->access_details(); $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count=0; foreach($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if($months=='11'){ $count+=1; } } $result['count']=$count; $result['lead_source'] = $this->yaskawa_model->leads_by_source(); $result['company_details']=$this->yaskawa_model->fetch_company_details(); $this->load->view('admin/lead_source_list',$result); } else { redirect('/'); } } //sales_across_owner view public function lead_conversion() { $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $result['user_type_id'] = $this->access_id(); $result['access'] = $this->access_details(); $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count=0; foreach($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if($months=='11'){ $count+=1; } } $result['count']=$count; $result['sales_across_owner']=$this->yaskawa_model->sales_across_owner(); $result['company_details']=$this->yaskawa_model->fetch_company_details(); $this->load->view('admin/sales_across_owners',$result); } else { redirect('/'); } } //sales_count_across_owners view public function conversion_count() { $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $result['user_type_id'] = $this->access_id(); $result['access'] = $this->access_details(); $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count=0; foreach($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if($months=='11'){ $count+=1; } } $result['count']=$count; $result['sales_across_owner']=$this->yaskawa_model->sales_across_owner(); $result['company_details']=$this->yaskawa_model->fetch_company_details(); $this->load->view('admin/sales_count_across_owners',$result); } else { redirect('/'); } } //sales_across_source view public function conversion_source() { $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $result['user_type_id'] = $this->access_id(); $result['access'] = $this->access_details(); $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count=0; foreach($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if($months=='11'){ $count+=1; } } $result['count']=$count; $result['sales_across_source']=$this->yaskawa_model->sales_across_source(); $result['company_details']=$this->yaskawa_model->fetch_company_details(); $this->load->view('admin/sales_across_source',$result); } else { redirect('/'); } } //sales_across_industry view public function conversion_industry() { $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $result['user_type_id'] = $this->access_id(); $result['access'] = $this->access_details(); $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count=0; foreach($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if($months=='11'){ $count+=1; } } $result['count']=$count; $result['sales_across_owner']=$this->yaskawa_model->sales_across_owner(); $result['company_details']=$this->yaskawa_model->fetch_company_details(); $this->load->view('admin/sales_across_industry',$result); } else { redirect('/'); } } public function personal_settings() { $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $result['user_type_id'] = $this->access_id(); $result['access'] = $this->access_details(); $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count=0; foreach($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if($months=='11'){ $count+=1; } } $result['count']=$count; $result['login_person_data']=$this->yaskawa_model->login_person($admin_id); $result['company_details']=$this->yaskawa_model->fetch_company_details(); $this->load->view('admin/profile_setting',$result); } else { redirect('/'); } } public function email_settings() { $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $result['user_type_id'] = $this->access_id(); $result['access'] = $this->access_details(); $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count=0; foreach($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if($months=='11'){ $count+=1; } } $result['count']=$count; $result['email_details'] = $this->yaskawa_model->get_all_email_settings(); $result['company_details']=$this->yaskawa_model->fetch_company_details(); $this->load->view('admin/email_settings',$result); } else { redirect('/'); } } public function users() { $admin_id = $this->session->userdata('admin_id'); if($admin_id) { redirect('yaskawa/admin_functions'); } else { redirect('/'); } } public function security_control() { $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $result['user_type_id'] = $this->access_id(); $result['access'] = $this->access_details(); //$result['menu'] = $this->yaskawa_model->get_all_menus(); $result['role_name'] = $this->yaskawa_model->add_new_roles2(); //$result['sub_menu1'] = $this->yaskawa_model->get_all_sub_menus(); //$result['sub_menu2'] = $this->yaskawa_model->get_all_sub_menus1(); $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count=0; foreach($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if($months=='11'){ $count+=1; } } $result['count']=$count; $result['company_details']=$this->yaskawa_model->fetch_company_details(); $this->load->view('admin/security_control',$result); } else { redirect('/'); } } public function tree_structure(){ $result = $this->yaskawa_model->tree_structure(); if($result) { echo json_encode(array('result'=>1,'tree_structure'=>$result)); } else { echo json_encode(array('result'=>0)); } } public function accounts() { $admin_id = $this->session->userdata('admin_id'); $role_id = $this->session->userdata('role_id'); if($admin_id) { $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $data['accounts_data'] = $this->yaskawa_model->select_new_accounts($role_id); $data['company_details']=$this->yaskawa_model->fetch_company_details(); $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count=0; foreach($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if($months=='11'){ $count+=1; } } $data['count']=$count; $this->load->view('admin/lead_account',$data); } else { redirect('/'); } } //delete remove_records public function remove_records() { $record_ids=$this->input->post('report_ids'); $data=array('delete_status'=>'DEACTIVE'); $this->yaskawa_model->delete_report($record_ids,$data); if($this->db->affected_rows() > 0) { echo json_encode(array('result'=>1,'message'=>'Deleted successfully')); } else { echo json_encode(array('result'=>0)); } } //delete remove_reports public function remove_reports() { $record_ids=$this->input->post('report_ids'); $data=array('delete_status'=>'DELETED'); $this->yaskawa_model->delete_report($record_ids,$data); if($this->db->affected_rows() > 0) { echo json_encode(array('result'=>1,'message'=>'Deleted successfully')); } else { echo json_encode(array('result'=>0)); } } // delete restore_reports public function restore_reports() { $record_ids=$this->input->post('report_ids'); $data=array('delete_status'=>'ACTIVE'); $this->yaskawa_model->delete_report($record_ids,$data); if($this->db->affected_rows() > 0) { echo json_encode(array('result'=>1,'message'=>'Deleted successfully')); } else { echo json_encode(array('result'=>0)); } } // delete delete_potential_data public function delete_potential_data() { $record_ids=$this->input->post('report_ids'); $data=array('type'=>'POTENTIAL_DEACTIVE'); $this->yaskawa_model->delete_report($record_ids,$data); } // delete delete_lead_report public function delete_lead_report() { $record_ids=$this->input->post('report_ids'); $data=array('type'=>'LEAD_DEACTIVE'); $this->yaskawa_model->delete_report($record_ids,$data); } // delete delete_activity_report public function delete_activity_report() { $record_ids=$this->input->post('report_ids'); $data=array('type'=>'ACTIVITY_DEACTIVE'); $this->yaskawa_model->delete_report($record_ids,$data); } // delete sales_matric_report public function sales_matric_report() { $record_ids=$this->input->post('report_ids'); $data=array('type'=>'SALES_DEACTIVE'); $this->yaskawa_model->delete_report($record_ids,$data); } //favorite_reports view public function update_favorite_reports() { $report_id = $this->input->post('report_id'); $data = array('favorite_report'=>'yes'); $result = $this->yaskawa_model->update_favorite_reports($report_id,$data); if($this->db->affected_rows() > 0) { echo json_encode(array('result'=>1)); } else { echo json_encode(array('result'=>0)); } } //favorite_reports view public function move_reports() { $report_id = $this->input->post('report_id'); $report_val = $this->input->post('report_val'); $data = array('type'=> $report_val); foreach ($report_id as $key => $value) { $var = $value; $result = $this->yaskawa_model->move_reports_folder($var,$data); } if($this->db->affected_rows() > 0) { echo json_encode(array('result'=>1)); } else { echo json_encode(array('result'=>0)); } } public function add_new_roles() { $role_name = $this->input->post('role_name'); $report_to = $this->input->post('report_to'); $zone = $this->input->post('zone'); $description = $this->input->post('description'); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $created_at = $date->format('Y-m-d H:i:s'); $data = $this->yaskawa_model->add_new_roles1($report_to); $role_details = array( 'role_name' => $role_name, 'report_to' => $data->role_id, // 'zone' => $zone, 'description' => $description, 'delete_status' => 'ACTIVE', 'created_at' => $created_at ); if($data) { $result = $this->yaskawa_model->add_new_roles_check($role_name); if($result) { if($data->role_id == $result->report_to) { echo json_encode(array('result'=>1,'id'=>$result,'message'=>"Roles added successfully")); } else { $result = $this->yaskawa_model->add_new_roles($role_details); if($result) { echo json_encode(array('result'=>2,'id'=>$result,'message'=>"Roles added successfully")); } else { echo json_encode(array('result'=>0,'message'=>"Something went wrong.. try again")); } } } else { $result = $this->yaskawa_model->add_new_roles($role_details); if($result) { echo json_encode(array('result'=>2,'id'=>$result,'message'=>"Roles added successfully")); } else { echo json_encode(array('result'=>0,'message'=>"Something went wrong.. try again")); } } } else { $result = $this->yaskawa_model->add_new_roles($role_details); if($result) { echo json_encode(array('result'=>2,'id'=>$result,'message'=>"Roles added successfully")); } else { echo json_encode(array('result'=>0,'message'=>"Something went wrong.. try again")); } } } public function redirect_roles() { $result['user_type_id'] = $this->access_id(); $result['access'] = $this->access_details(); $role_id = $this->uri->segment(3); $result['roles'] = $this->yaskawa_model->get_roles(); $result['details'] = $this->yaskawa_model->get_role_data($role_id); $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count=0; foreach($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if($months=='11'){ $count+=1; } } $result['count']=$count; $result['company_details']=$this->yaskawa_model->fetch_company_details(); $this->load->view('admin/security_control_roles',$result); } public function update_role() { $role_id = $this->input->post('role_id'); $role_name = $this->input->post('role_name'); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $updated_at = $date->format('Y-m-d H:i:s'); $role_details = array('role_name' => $role_name, 'delete_status' => 'ACTIVE', 'updated_at' => $updated_at); $result = $this->yaskawa_model->update_roles($role_id,$role_details); if($result > 0) { echo json_encode(array('result'=>1,'message'=>"Updated successfully")); } else { echo json_encode(array('result'=>0,'message'=>"Failed to update. Try again")); } } //update update_roles public function update_roles() { $role_id = $this->input->post('role_id'); $role_name = $this->input->post('role_name'); $report_to = $this->input->post('report_to'); $description = $this->input->post('description'); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $updated_at = $date->format('Y-m-d H:i:s'); $role_details = array( 'role_name' => $role_name, 'report_to' => $report_to, 'description' => $description, 'delete_status' => 'ACTIVE', 'updated_at' => $updated_at ); $result = $this->yaskawa_model->update_roles($role_id,$role_details); if($this->db->affected_rows() > 0) { echo json_encode(array('result'=>1,'message'=>"Updated successfully")); } else { echo json_encode(array('result'=>0,'message'=>"Failed to update. Try again")); } } public function delete_role() { $role_id = $this->input->post('id'); $data = array('delete_status'=>'INACTIVE'); $result = $this->yaskawa_model->delete_role($role_id,$data); if($this->db->affected_rows() > 0) { echo json_encode(array('result'=>1,'message'=>'Deleted successfully')); } else { echo json_encode(array('result'=>0,'message'=>'Something went wrong')); } } //Delete delete_roles public function delete_roles() { $role_id = $this->input->post('role_id'); $data = array('delete_status'=>'INACTIVE'); $result = $this->yaskawa_model->delete_role($role_id,$data); if($this->db->affected_rows() > 0) { echo json_encode(array('result'=>1,'message'=>'Deleted successfully')); } else { echo json_encode(array('result'=>0)); } } //organizing_email_address public function organizing_email_address() { $display_name = $this->input->post('display_name'); $email = $this->input->post('email'); $can_see = $this->input->post('can_see'); // $confirm_status = $this->input->post('confirm_status'); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $created_at = $date->format('Y-m-d H:i:s'); $email_address_details = array( 'display_name' => $display_name, 'email_address' => $email, //'confirm_status' => $confirm_status, 'who_can_see' => $can_see, 'delete_status' => 'ACTIVE', 'created_at' => $created_at ); $result = $this->yaskawa_model->insert_email_settings($email_address_details); //$result1 = $this->yaskawa_model->get_all_email_settings(); if($result) { echo json_encode(array('emailsetting'=>$result,'result'=>1)); } else { echo json_encode(array('result'=>0)); } } public function added_new_users(){ { $role_id = $this->input->post('role_id'); $fname = $this->input->post('fname'); $lname = $this->input->post('lname'); $email = $this->input->post('email'); $role = $this->input->post('role'); $zone = $this->input->post('zone'); $profile_pic = $this->input->post('profile_pic'); $this->load->library('image_lib'); $file_name = ""; if($_FILES) { if(empty($_FILES['profile_pic']['name'])) { $file_name = ""; } else { $target='profile_pictures/'; $target.=time().$_FILES['profile_pic']['name']; $file_name=time().$_FILES['profile_pic']['name']; $image=$target; move_uploaded_file($_FILES['profile_pic']['tmp_name'],$target); $config['source_image']=$target; $config['maintain_ratio']=TRUE; $this->image_lib->initialize($config); } } $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $created_at = $date->format('Y-m-d'); $password='password'; $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); $insert=array( 'user_name' => $fname, 'user_type_id' => '2', 'salt_pass' =>$salt_password, 'department_id' => '3', 'last_name' => $lname, 'email' => $email, 'role_id' => $role_id, 'role' => $role, 'zone' => $zone, 'password' => $hashed_password, 'profile_pick' => $file_name, 'created_at' => $created_at, ); $result = $this->yaskawa_model->insert_new_users($insert); if($result) { echo json_encode(array('result'=>1,'res'=>$result)); } else { echo json_encode(array('result'=>0)); } } } // fetch user_details public function details(){ $user_id=$this->input->post('user_id'); $user_data=$this->yaskawa_model->user_details($user_id); echo json_encode($user_data); } // fetch user_data_update public function user_data_update(){ $uid = $this->input->post('user_id'); $alias = $this->input->post('alias'); $phone = $this->input->post('phone'); $mobile = $this->input->post('mobile'); $fax = $this->input->post('fax'); $website = $this->input->post('website'); $Date = $this->input->post('Date_of_Birth'); $newDate = date("Y-m-d", strtotime($Date)); $street = $this->input->post('street'); $city = $this->input->post('city'); $state = $this->input->post('state'); $zip_code = $this->input->post('zip_code'); $country = $this->input->post('country'); $udate = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $update_at = $udate->format('Y-m-d H:i:s'); $update_data=array( 'Alias' => $alias, 'Phone' => $phone, 'Mobile' => $mobile, 'Fax' => $fax, 'Website' => $website, 'Date_of_Birth' => $newDate, 'Street' => $street, 'City' => $city, 'State' => $state, 'Zip_Code' => $zip_code, 'Country' => $country, 'updated_at' => $update_at, ); $result=$this->yaskawa_model->user_details_update($uid,$update_data); if($result) { echo json_encode(array('result'=>1,'res'=>$result)); } else { echo json_encode(array('result'=>0)); } } // insert insert_company_details public function insert_company_details(){ $cname = $this->input->post('cname'); $Alias = $this->input->post('Alias'); $ecount = $this->input->post('ecount'); $Phone = $this->input->post('Phone'); $Mobile = $this->input->post('Mobile'); $Fax = $this->input->post('Fax'); $Website = $this->input->post('Website'); $Description = $this->input->post('Description'); $Super_Admin = $this->input->post('Super_Admin'); $Street = $this->input->post('Street'); $City = $this->input->post('City'); $State = $this->input->post('State'); $Zip_Code = $this->input->post('Zip_Code'); $Country = $this->input->post('Country'); $cdate = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $create_at = $cdate->format('Y-m-d H:i:s'); $company_details=array( 'Company_Name' => $cname, 'Alias' => $Alias, 'Employee_Count' => $ecount, 'Phone' => $Phone, 'Mobile' => $Mobile, 'Fax' => $Fax, 'Website' => $Website, 'Description' => $Description, 'Super_Admin' => $Super_Admin, 'Street' => $Street, 'City' => $City, 'State' => $State, 'Zip_Code' => $Zip_Code, 'Country' => $Country, 'create_at' => $create_at ); $result=$this->yaskawa_model->company_details($company_details); if($result) { echo json_encode(array('result'=>1,'res'=>$result)); } else { echo json_encode(array('result'=>0)); } } //Users list public function get_users_list() { $username = $this->input->post('username'); $result = $this->yaskawa_model->get_users_list($username); if($result) { echo json_encode(array('get_users_list'=>$result,'result'=>1)); } else { echo json_encode(array('result'=>0)); } } public function sender_upload_files(){ $sender_id = $this->session->userdata('admin_id'); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $send_at = $date->format('Y-m-d H:i:s'); $receiverids = $this->input->post('receiver-ids'); $message = $this->input->post('admin_message'); $feeds_id = $this->input->post('feedsids'); $comm_date = $date->format('Y-m-d'); $this->load->library('image_lib'); $file_name = ""; if($_FILES) { if(empty($_FILES['admin_upload']['name'])) { $file_name = ""; } else { $target='document_uploads/'; $target.=time().$_FILES['admin_upload']['name']; $file_name=time().$_FILES['admin_upload']['name']; $image=$target; move_uploaded_file($_FILES['admin_upload']['tmp_name'],$target); $config['source_image']=$target; $config['maintain_ratio']=TRUE; // $config['width']=1280; // $config['height']=960; //$this->image_lib->resize(); } } $tbl='feeds_comment'; $condition=array('feeds_id'=>$feeds_id); $oder_by='comment_id'; $get_last_commented_id=$this->yaskawa_model->get_where_orderby_row($tbl,$condition,$oder_by); if(!empty($get_last_commented_id)) { $rcv_id=$get_last_commented_id->send_id; } else { $rcv_id=$receiverids; } $comment_details=array( 'feeds_id' => $feeds_id, 'send_id' => $sender_id, 'receive_id' => $rcv_id, 'comment' => $message, 'send_at' => $send_at, 'file_name' => $file_name, 'comm_date' => $comm_date ); $result=$this->yaskawa_model->comment_feeds($comment_details); if($result) { echo json_encode(array('result'=>1,'res'=>$result)); } else { echo json_encode(array('result'=>0)); } } //attach_notes public function attach_notes() { $lead_notes = $this->input->post('lead_notes'); $note_id = $this->input->post('note_id'); if($note_id!=''){ $where=array('notes_id'=>$note_id); $table="account_attach_notes"; $attach_file = $this->input->post('attach_file'); $lead_id = $this->input->post('lead_id'); $this->load->library('image_lib'); $file_name = ""; if($_FILES) { if(empty($_FILES['attach_file']['name'])) { $file_name = ""; } else { $target='attach_file/'; $target.=time().$_FILES['attach_file']['name']; $file_name=time().$_FILES['attach_file']['name']; $image=$target; move_uploaded_file($_FILES['attach_file']['tmp_name'],$target); $config['source_image']=$target; $config['maintain_ratio']=TRUE; $this->image_lib->initialize($config); } } $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $created_at = $date->format('Y-m-d'); $notes_details = array( 'lead_id' => $lead_id, 'lead_notes' => $lead_notes, 'attach_file' => $file_name, 'created_by' => $this->session->userdata('admin_id'), 'delete_status' => 'NOTE', 'updated_at' => $created_at, 'notes_from'=>'Lead', ); $result = $this->yaskawa_model->update_single($where,$table,$notes_details); if($result) { echo json_encode(array('result'=>2,'message'=>"Notes Updated successfully")); } else { echo json_encode(array('result'=>0,'message'=>"Something went wrong.. try again")); } }else{ $attach_file = $this->input->post('attach_file'); $lead_id = $this->input->post('lead_id'); $this->load->library('image_lib'); $file_name = ""; if($_FILES) { if(empty($_FILES['attach_file']['name'])) { $file_name = ""; } else { $target='attach_file/'; $target.=time().$_FILES['attach_file']['name']; $file_name=time().$_FILES['attach_file']['name']; $image=$target; move_uploaded_file($_FILES['attach_file']['tmp_name'],$target); $config['source_image']=$target; $config['maintain_ratio']=TRUE; $this->image_lib->initialize($config); } } $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $created_at = $date->format('Y-m-d H:i:s'); $notes_details = array( 'lead_id' => $lead_id, 'lead_notes' => $lead_notes, 'attach_file' => $file_name, 'created_by' => $this->session->userdata('admin_id'), 'delete_status' => 'NOTE', 'created_at' => $created_at, 'notes_from'=>'Lead', ); $result = $this->yaskawa_model->add_lead_notes($notes_details); if($result) { echo json_encode(array('result'=>1,'message'=>"Notes added successfully")); } else { echo json_encode(array('result'=>0,'message'=>"Something went wrong.. try again")); } } } public function attach_potential_notes() { $lead_notes = $this->input->post('potential_notes'); $note_id = $this->input->post('note_id'); if($note_id!=''){ $where=array('notes_id'=>$note_id); $table="account_attach_notes"; $attach_file = $this->input->post('attach_file'); $potential_id = $this->input->post('potential_id'); $this->load->library('image_lib'); $file_name = ""; if($_FILES) { if(empty($_FILES['attach_file']['name'])) { $file_name = ""; } else { $target='attach_file/'; $target.=time().$_FILES['attach_file']['name']; $file_name=time().$_FILES['attach_file']['name']; $image=$target; move_uploaded_file($_FILES['attach_file']['tmp_name'],$target); $config['source_image']=$target; $config['maintain_ratio']=TRUE; $this->image_lib->initialize($config); } } $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $created_at = $date->format('Y-m-d'); $notes_details = array( 'lead_id' => $potential_id, 'lead_notes' => $lead_notes, 'attach_file' => $file_name, 'created_by' => $this->session->userdata('admin_id'), 'delete_status' => 'NOTE', 'updated_at' => $created_at, 'notes_from'=>'Potential', ); $result = $this->yaskawa_model->update_single($where,$table,$notes_details); if($result) { echo json_encode(array('result'=>2,'message'=>"Notes Updated successfully")); } else { echo json_encode(array('result'=>0,'message'=>"Something went wrong.. try again")); } }else{ $attach_file = $this->input->post('attach_file'); $lead_id = $this->input->post('potential_id'); $this->load->library('image_lib'); $file_name = ""; if($_FILES) { if(empty($_FILES['attach_file']['name'])) { $file_name = ""; } else { $target='attach_file/'; $target.=time().$_FILES['attach_file']['name']; $file_name=time().$_FILES['attach_file']['name']; $image=$target; move_uploaded_file($_FILES['attach_file']['tmp_name'],$target); $config['source_image']=$target; $config['maintain_ratio']=TRUE; $this->image_lib->initialize($config); } } $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $created_at = $date->format('Y-m-d H:i:s'); $notes_details = array( 'lead_id' => $lead_id, 'lead_notes' => $lead_notes, 'attach_file' => $file_name, 'created_by' => $this->session->userdata('admin_id'), 'delete_status' => 'NOTE', 'created_at' => $created_at, 'notes_from'=>'Potential', ); $table="account_attach_notes"; $result = $this->yaskawa_model->insert_access($table,$notes_details); if($result) { echo json_encode(array('result'=>1,'message'=>"Notes added successfully")); } else { echo json_encode(array('result'=>0,'message'=>"Something went wrong.. try again")); } } } //attach_notes public function attach_accountnotes() { $lead_notes = $this->input->post('lead_notes'); $attach_file = $this->input->post('attach_file'); $account_id = $this->input->post('account_id'); $note_id = $this->input->post('note_id'); if($note_id!=''){ $where=array('notes_id'=>$note_id); $table="account_attach_notes"; $this->load->library('image_lib'); $file_name = ""; if($_FILES) { if(empty($_FILES['attach_file']['name'])) { $file_name = ""; } else { $target='attach_file/'; $target.=time().$_FILES['attach_file']['name']; $file_name=time().$_FILES['attach_file']['name']; $image=$target; move_uploaded_file($_FILES['attach_file']['tmp_name'],$target); $config['source_image']=$target; $config['maintain_ratio']=TRUE; $this->image_lib->initialize($config); } } $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $created_at = $date->format('Y-m-d H:i:s'); $notes_details = array( 'lead_id' => $account_id, 'lead_notes' => $lead_notes, 'attach_file' => $file_name, 'delete_status' => 'ACTIVE', 'notes_from'=>'Account', 'created_by' =>$this->session->userdata('admin_id'), 'updated_at' => $created_at ); $result = $this->yaskawa_model->update_single($where,$table,$notes_details); if($result) { echo json_encode(array('result'=>2,'message'=>"Notes updated successfully")); } else { echo json_encode(array('result'=>0,'message'=>"Something went wrong.. try again")); } }else{ $this->load->library('image_lib'); $file_name = ""; if($_FILES) { if(empty($_FILES['attach_file']['name'])) { $file_name = ""; } else { $target='attach_file/'; $target.=time().$_FILES['attach_file']['name']; $file_name=time().$_FILES['attach_file']['name']; $image=$target; move_uploaded_file($_FILES['attach_file']['tmp_name'],$target); $config['source_image']=$target; $config['maintain_ratio']=TRUE; $this->image_lib->initialize($config); } } $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $created_at = $date->format('Y-m-d H:i:s'); $notes_details = array( 'lead_id' => $account_id, 'lead_notes' => $lead_notes, 'attach_file' => $file_name, 'notes_from'=>'Account', 'delete_status' => 'ACTIVE', 'created_by' =>$this->session->userdata('admin_id'), 'created_at' => $created_at ); $result = $this->yaskawa_model->add_account_notes($notes_details); if($result) { echo json_encode(array('result'=>1,'message'=>"Notes added successfully")); } else { echo json_encode(array('result'=>0,'message'=>"Something went wrong.. try again")); } } } public function attach_contactnotes() { $lead_notes = $this->input->post('contact_notes'); $attach_file = $this->input->post('attach_file'); $contact_id = $this->input->post('contact_id'); $this->load->library('image_lib'); $file_name = ""; if($_FILES) { if(empty($_FILES['attach_file']['name'])) { $file_name = ""; } else { $target='attach_file/'; $target.=time().$_FILES['attach_file']['name']; $file_name=time().$_FILES['attach_file']['name']; $image=$target; move_uploaded_file($_FILES['attach_file']['tmp_name'],$target); $config['source_image']=$target; $config['maintain_ratio']=TRUE; // $config['width']=1280; // $config['height']=960; $this->image_lib->initialize($config); //$this->image_lib->resize(); } } $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $created_at = $date->format('Y-m-d'); $notes_details = array( 'lead_id' => $contact_id, 'lead_notes' => $lead_notes, 'attach_file' => $file_name, 'delete_status' => 'ACTIVE', 'notes_from'=>'Contact', 'created_at' => $created_at ); $result = $this->yaskawa_model->add_account_notes($notes_details); if($result) { echo json_encode(array('result'=>1,'message'=>"Notes added successfully")); } else { echo json_encode(array('result'=>0,'message'=>"Something went wrong.. try again")); } } //attach_files public function attach_files() { $attach_file = $this->input->post('attach_file'); $lead_id = $this->input->post('lead_id'); $this->load->library('image_lib'); $file_name = ""; if($_FILES) { if(empty($_FILES['attach_file']['name'])) { $file_name = ""; } else { $target='attach_file/'; $target.=time().$_FILES['attach_file']['name']; $file_name=time().$_FILES['attach_file']['name']; $image=$target; move_uploaded_file($_FILES['attach_file']['tmp_name'],$target); $config['source_image']=$target; $config['maintain_ratio']=TRUE; // $config['width']=1280; // $config['height']=960; $this->image_lib->initialize($config); //$this->image_lib->resize(); } } $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $created_at = $date->format('Y-m-d'); $attachment_details = array( 'lead_id' => $lead_id, 'type' =>'Attached File', 'attach_file' => $file_name, 'delete_status' => 'FILE', 'created_at' => $created_at ); $result = $this->yaskawa_model->add_lead_attachments($attachment_details); if($result) { echo json_encode(array('result'=>1,'message'=>"Attachments added successfully")); } else { echo json_encode(array('result'=>0,'message'=>"Something went wrong.. try again")); } } //attach_files public function attach_linl_url() { $link_url = $this->input->post('linkurl'); $lead_id = $this->input->post('lead_id'); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $created_at = $date->format('Y-m-d'); $url_details = array( 'lead_id' => $lead_id, 'type' =>'Link URL', 'link_url' => $link_url, 'delete_status' => 'URL', 'created_at' => $created_at ); $result = $this->yaskawa_model->add_lead_attachments($url_details); if($result) { echo json_encode(array('result'=>1,'message'=>"Attachments added successfully")); } else { echo json_encode(array('result'=>0,'message'=>"Something went wrong.. try again")); } } //new_task public function new_task() { $subject = $this->input->post('subject'); $due_date = $this->input->post('due_date'); $priority = $this->input->post('priority'); $owner = $this->input->post('owner'); //$start_date = $this->input->post('start_date'); //$end_date = $this->input->post('end_date'); $status = $this->input->post('status'); $lead_id = $this->input->post('lead_id'); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $created_at = $date->format('Y-m-d'); $task_details = array( 'lead_id' => $lead_id, 'type' => 'Task', 'subject' => $subject, 'due_date' => $due_date, 'priority' => $priority, 'owner' => $owner, //'start_date' => date('Y-m-d', strtotime($start_date)), //'end_date' => date('Y-m-d', strtotime($end_date)), 'status' => $status, 'details_from'=>'Lead', 'activity' => 'OPEN', 'delete_status' => 'ACTIVE', 'created_at' => $created_at ); $result = $this->yaskawa_model->add_new_task($task_details); if($result) { echo json_encode(array('result'=>1,'message'=>"Attachments added successfully")); } else { echo json_encode(array('result'=>0,'message'=>"Something went wrong.. try again")); } } //new_events public function new_events() { $event_name = $this->input->post('event_name'); $all_days = $this->input->post('all_day'); if($all_days=='on') { $all_day='All Day'; }else { $all_day=''; } $from_date = date("Y-m-d", strtotime($this->input->post('from_date'))); $to_date = date("Y-m-d", strtotime($this->input->post('to_date'))); $host = $this->input->post('host'); $related_to = $this->input->post('related_to'); $lead = $this->input->post('lead'); //$repeat = $this->input->post('repeat'); $description = $this->input->post('description'); $lead_id = $this->input->post('lead_id'); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $created_at = $date->format('Y-m-d'); $event_details = array( 'lead_id' => $lead_id, 'type' => 'Event', 'subject' => $event_name, 'all_day' => $all_day, 'start_date' => $from_date, 'end_date' => $to_date, 'details_from'=>'Lead', 'host' => $host, 'related_to' => $related_to, 'owner' => $lead, 'description' => $description, 'activity' => 'OPEN', 'delete_status' => 'ACTIVE', 'created_at' => $created_at ); $result = $this->yaskawa_model->add_new_task($event_details); if($result) { echo json_encode(array('result'=>1,'message'=>"Attachments added successfully")); } else { echo json_encode(array('result'=>0,'message'=>"Something went wrong.. try again")); } } //new_calls public function new_calls() { $lead_id = $this->input->post('lead_id'); $subject = $this->input->post('subject'); $call_type = $this->input->post('call_type'); $call_purpose = $this->input->post('call_purpose'); $contact_num = $this->input->post('contact_name'); $call_details = $this->input->post('call_details'); $call_duration = $this->input->post('call_duration'); $description = $this->input->post('description'); $call_result = $this->input->post('call_result'); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $created_at = $date->format('Y-m-d'); $call_details = array( 'lead_id' => $lead_id, 'type' => 'Call', 'subject' => $subject, 'call_type' => $call_type, 'call_purpose' => $call_purpose, 'contact_name' => $contact_num, 'call_details' => $call_details, 'call_duration' => $call_duration, 'description' => $description, 'call_result' => $call_result, 'details_from'=>'Lead', 'activity' => 'OPEN', 'delete_status' => 'ACTIVE', 'created_at' => $created_at ); $result = $this->yaskawa_model->add_new_task($call_details); if($result) { echo json_encode(array('result'=>1,'message'=>"Attachments added successfully")); } else { echo json_encode(array('result'=>0,'message'=>"Something went wrong.. try again")); } } //upload_profile_pic public function upload_profile_pic() { $profile_pic = $this->input->post('profile_pic'); $lead_id = $this->input->post('lead_id'); $this->load->library('image_lib'); $file_name = ""; if($_FILES) { if(empty($_FILES['profile_pic']['name'])) { $file_name = ""; } else { $target='profile_pictures/'; $target.=time().$_FILES['profile_pic']['name']; $file_name=time().$_FILES['profile_pic']['name']; $image=$target; move_uploaded_file($_FILES['profile_pic']['tmp_name'],$target); $config['source_image']=$target; $config['maintain_ratio']=TRUE; // $config['width']=1280; // $config['height']=960; $this->image_lib->initialize($config); //$this->image_lib->resize(); } } $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $created_at = $date->format('Y-m-d'); $image_details = array( 'lead_id' => $lead_id, 'profile_pic' => $file_name, 'delete_status' => 'ACTIVE', 'created_at' => $created_at ); $result = $this->yaskawa_model->add_profile_pic($image_details); if($result) { echo json_encode(array('result'=>1,'message'=>"Attachments added successfully")); } else { echo json_encode(array('result'=>0,'message'=>"Something went wrong.. try again")); } } //Edit send_mail public function send_mail() { $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count=0; foreach($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if($months=='11'){ $count+=1; } } $data['count']=$count; $data['mail_details'] = $this->yaskawa_model->get_all_mail_from_user(); $data['company_details']=$this->yaskawa_model->fetch_company_details(); $this->load->view('admin/send_mail',$data); } else { redirect('/'); } } //send_mail_user public function send_mail_user() { $email_settings_id = $this->input->post('email_settings_id'); $to_whom = $this->input->post('to_whom'); $subject = $this->input->post('subject'); //$lead_id = $this->input->post('lead_id'); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $created_at = $date->format('Y-m-d'); $this->load->library('email'); $this->email->set_mailtype('html'); $this->email->from($email_settings_id); $this->email->to($to_whom); $this->email->subject($subject); $res=$this->email->send(); print_r($res);die(); if($res) { echo json_encode(array('result'=>1,'message'=>"email sent successfully")); } else { echo json_encode(array('result'=>0,'message'=>"Something went wrong.. try again")); } } //attach_accountfiles public function attach_accountfiles() { $attach_file = $this->input->post('attach_file'); $account_id = $this->input->post('account_id'); $this->load->library('image_lib'); $file_name = ""; if($_FILES) { if(empty($_FILES['attach_file']['name'])) { $file_name = ""; } else { $target='attach_file/'; $target.=time().$_FILES['attach_file']['name']; $file_name=time().$_FILES['attach_file']['name']; $image=$target; move_uploaded_file($_FILES['attach_file']['tmp_name'],$target); $config['source_image']=$target; $config['maintain_ratio']=TRUE; // $config['width']=1280; // $config['height']=960; $this->image_lib->initialize($config); //$this->image_lib->resize(); } } $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $created_at = $date->format('Y-m-d'); $attachment_details = array( 'lead_id' => $account_id, 'type' =>'Attached File', 'attach_file' => $file_name, 'delete_status' => 'ACTIVE', 'created_at' => $created_at ); $result = $this->yaskawa_model->add_lead_account_attachment($attachment_details); if($result) { echo json_encode(array('result'=>1,'message'=>"Attachments added successfully")); } else { echo json_encode(array('result'=>0,'message'=>"Something went wrong.. try again")); } } //attach_accountlinl_url public function attach_accountlinl_url() { $link_url = $this->input->post('linkurl'); $account_id = $this->input->post('account_id'); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $created_at = $date->format('Y-m-d'); $url_details = array( 'lead_id' => $account_id, 'type' =>'Link URL', 'link_url' => $link_url, 'delete_status' => 'ACTIVE', 'created_at' => $created_at ); $result = $this->yaskawa_model->add_lead_account_attachment($url_details); if($result) { echo json_encode(array('result'=>1,'message'=>"Attachments added successfully")); } else { echo json_encode(array('result'=>0,'message'=>"Something went wrong.. try again")); } } //new_accounttask public function new_accounttask() { $subject = $this->input->post('subject'); $due_date = date('Y-m-d', strtotime($this->input->post('due_date'))); $priority = $this->input->post('priority'); $owner = $this->input->post('owner'); //$start_date = $this->input->post('start_date'); //$end_date = $this->input->post('end_date'); $status = $this->input->post('status'); $account_id = $this->input->post('account_id'); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $created_at = $date->format('Y-m-d'); $task_details = array( 'lead_id' => $account_id, 'type' =>'Task', 'subject' => $subject, 'due_date' => $due_date, 'priority' => $priority, 'owner' => $owner, //'start_date' => date('Y-m-d', strtotime($start_date)), //'end_date' => date('Y-m-d', strtotime($end_date)), 'status' => $status, 'activity' => 'OPEN', 'details_from'=>'Account', 'delete_status' => 'ACTIVE', 'created_at' => $created_at ); $result = $this->yaskawa_model->add_new_account_task($task_details); if($result) { echo json_encode(array('result'=>1,'message'=>"Attachments added successfully")); } else { echo json_encode(array('result'=>0,'message'=>"Something went wrong.. try again")); } } //new_accountevents public function new_accountevents() { $event_name = $this->input->post('event_name'); $all_day = $this->input->post('all_day'); $from_date = date('Y-m-d', strtotime($this->input->post('from_date'))); $to_date = date('Y-m-d', strtotime($this->input->post('to_date'))); $host = $this->input->post('host'); $related_to = $this->input->post('related_to'); $lead = $this->input->post('lead'); //$repeat = $this->input->post('repeat'); $description = $this->input->post('description'); $account_id = $this->input->post('account_id'); if(!empty($all_day)) { $all_days=$all_day; }else { $all_days=''; } $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $created_at = $date->format('Y-m-d'); $event_details = array( 'lead_id' => $account_id, 'type' =>'Event', 'subject' => $event_name, 'all_day' => $all_days, 'start_date' => $from_date, 'end_date' => $to_date, 'owner' => $host, 'related_to' => $related_to, 'lead' => $lead, 'details_from'=>'Account', //'repeat' => $repeat, 'description' => $description, 'delete_status' => 'ACTIVE', 'created_at' => $created_at ); $result = $this->yaskawa_model->add_new_account_task($event_details); if($result) { echo json_encode(array('result'=>1,'message'=>"Attachments added successfully")); } else { echo json_encode(array('result'=>0,'message'=>"Something went wrong.. try again")); } } //new_accountcalls public function new_accountcalls() { $account_id = $this->input->post('account_id'); $subject = $this->input->post('subject'); $call_type = $this->input->post('call_type'); $call_purpose = $this->input->post('call_purpose'); $contact_num = $this->input->post('contact_name'); $call_details = $this->input->post('call_details'); //$call_timer = $this->input->post('call_timer'); $call_duration = $this->input->post('call_duration'); $description = $this->input->post('description'); $call_result = $this->input->post('call_result'); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $created_at = $date->format('Y-m-d'); $call_details = array( 'lead_id' => $account_id, 'type' =>'Call', 'subject' => $subject, 'call_type' => $call_type, 'call_purpose' => $call_purpose, 'contact_name' => $contact_num, 'call_details' => $call_details, //'call_timer' => $call_timer, 'call_duration' => $call_duration, 'description' => $description, 'call_result' => $call_result, 'delete_status' => 'ACTIVE', 'details_from'=>'Account', 'created_at' => $created_at ); $result = $this->yaskawa_model->add_new_account_task($call_details); if($result) { echo json_encode(array('result'=>1,'message'=>"Attachments added successfully")); } else { echo json_encode(array('result'=>0,'message'=>"Something went wrong.. try again")); } } // send_account_mail public function send_account_mail() { $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count=0; foreach($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if($months=='11'){ $count+=1; } } $data['count']=$count; $data['mail_details'] = $this->yaskawa_model->get_all_mail(); $data['company_details']=$this->yaskawa_model->fetch_company_details(); $this->load->view('admin/account_send_mail',$data); } else { redirect('/'); } } //account_mail public function account_mail() { $email_settings = $this->input->post('email_settings'); $to_whom = $this->input->post('to_whom'); $subject = $this->input->post('subject'); //$lead_id = $this->input->post('lead_id'); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $created_at = $date->format('Y-m-d'); $this->load->library('email'); $this->email->set_mailtype('html'); $this->email->from($email_settings); $this->email->to($to_whom); $this->email->subject($subject); $this->email->send(); } public function add_quotations() { $quo_date = date('Y-m-d', strtotime($this->input->post('quo_date'))); $res_date = date('Y-m-d', strtotime($this->input->post('response_date'))); $probability = $this->input->post('probability'); $amount = str_replace(',', '',$this->input->post('amount')); $description = $this->input->post('description'); $lead_id = $this->input->post('account_id'); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $created_at = $date->format('Y-m-d'); $quotation_number=$this->input->post('quotation_number'); $quotation_details = array( 'lead_id' => $lead_id, 'quotation_number' => $quotation_number, 'quo_date' => $quo_date, 'response_date' => $res_date, 'probability' => $probability, 'amount' => $amount, 'description' => $description, 'delete_status' => 'ACTIVE', 'created_at' => $created_at ); $result = $this->yaskawa_model->add_new_quotations($quotation_details); if($result) { echo json_encode(array('result'=>1,'message'=>"Notes added successfully")); } else { echo json_encode(array('result'=>0,'message'=>"Something went wrong.. try again")); } } // convert_status public function convert_status() { $lead_id = $this->input->post('id'); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $created_at = $date->format('Y-m-d'); $data = array('lead_convert'=>'CONVERTED','converted_at'=>$created_at); $table='leads'; $where=array('lead_id'=>$lead_id); //$this->yaskawa_model->update($where,$table,$data); $table='leads'; $where=array('lead_id'=>$lead_id); $details=$this->yaskawa_model->get_where_row($table,$where); $data=array( 'user_id' => $details->user_id, 'role_id' => $details->role_id, 'account_owner' => $details->lead_owner, 'rating' => $details->ratings, // 'account_name' => $details->first_name, 'account_name' => $details->company_name, 'phone' => $details->mobile, 'email_id' => $details->email, 'fax' => $details->fax, 'website' => $details->website, 'industry' => $details->industry, 'employees' => $details->no_of_employees, 'annual_revenue' => $details->annual_revenue, 'description' => $details->description, //'contact_person' => $details->Cperson, 'contact_person' => $details->first_name, 'billing_street'=>$details->street, 'shipping_street'=>$details->street, 'billing_city'=>$details->city, 'shipping_city'=>$details->city, 'billing_state'=>$details->state, 'shipping_state'=>$details->state, 'billing_country'=>$details->country, 'shipping_country'=>$details->country, 'shipping_country'=>$details->country, 'billing_code'=>$details->zip_code, 'shipping_code'=>$details->zip_code, 'address'=> $details->street.','.$details->city.','.$details->state.','.$details->country, 'service_name' => $details->service_name, 'service_date' => $details->service_date, 'service_amount' => $details->service_amount, //'lead_id' => $lead_id, 'lead_id' => $details->lead_id, 'delete_status' => 'ACTIVE', 'designation' =>$details->lead_title, ); $result=$this->yaskawa_model->add_new_account($data); if($result) { $where1=array('lead_id'=>$lead_id,'type'=>'Task'); $where2=array('lead_id'=>$lead_id,'type'=>'Event'); $where3=array('lead_id'=>$lead_id,'type'=>'Call'); $data1=array('details_from'=>'Account','lead_id'=>$result); $tableg='lead_new_tasks'; $get_activity=$this->yaskawa_model->update($where1,$tableg,$data1); $where2=array('lead_id'=>$lead_id,'type'=>'Event'); $get_event=$this->yaskawa_model->update($where2,$tableg,$data1); $where3=array('lead_id'=>$lead_id,'type'=>'Call'); $get_call=$this->yaskawa_model->update($where3,$tableg,$data1); $table="quotations"; $dat=array('quatetion_from'=>'Account','account_id'=>$result,'lead_id'=>0); $con=array('lead_id'=>$lead_id); $update_quatetion=$this->yaskawa_model->update($con,$table,$dat); $tables='account_attach_notes'; $datas=array('notes_from'=>'Account','lead_id' =>$result,); $this->yaskawa_model->update($where,$tables,$datas); $table='leads'; $where=array('lead_id'=>$lead_id); $datax=array('delete_status'=>'INACTIVE','converted_next_level'=>'ACONVERT'); $res=$this->yaskawa_model->update($where,$table,$datax); $r=1; echo json_encode($r); } else { $r=0; echo json_encode($r); } } // convert_status public function potential_status() { $quotation_id = $this->input->post('id'); //$result = $this->yaskawa_model->potential_convert_status($quotation_id,$data); //$data = array('potential_status'=>'CONVERTED'); //$table='new_potential'; //$where=array('potential_id'=>$quotation_id); //$this->yaskawa_model->update($where,$table,$data); $table='new_potential'; $where=array('potential_id'=>$quotation_id); $details=$this->yaskawa_model->get_where_row($table,$where); $data=array( 'user_id' => $details->user_id, 'role_id' => $details->role_id, 'account_owner' => $details->potential_owner, 'potentail_id' => $details->potential_id, 'name_type' => $details->potential_type, 'account_name' => $details->potential_name, 'annual_revenue' => $details->expected_revenue, 'description' => $details->description, 'phone'=>$details->phone_number, 'email_id'=>$details->email_id, 'contact_id'=>$details->contact_id, 'delete_status' => 'ACTIVE', 'service_name'=>$details->service_name, 'service_amount'=>$details->service_amount, 'service_date'=>$details->service_date, 'contact_person' =>$details->contact_name, 'rating' => $details->ratings, 'fax' => $details->fax, 'website' => $details->website, 'industry' => $details->industry, 'employees' => $details->no_of_employees, 'annual_revenue' => $details->annual_revenue, 'designation' => $details->designation, 'billing_street'=>$details->street, 'shipping_street'=>$details->street, 'billing_city'=>$details->city, 'shipping_city'=>$details->city, 'billing_state'=>$details->state, 'shipping_state'=>$details->state, 'billing_country'=>$details->country, 'shipping_country'=>$details->country, 'billing_code'=>$details->zip_code, 'shipping_code'=>$details->zip_code, 'address'=> $details->street.','.$details->city.','.$details->state.','.$details->country, ); $result=$this->yaskawa_model->add_new_account($data); $tables='account_attach_notes'; $datas=array('notes_from'=>'Account','lead_id'=>$result); $wheres=array('lead_id'=>$quotation_id); $this->yaskawa_model->update($wheres,$tables,$datas); if($result) { $where1=array('lead_id'=>$quotation_id,'type'=>'Task'); $where2=array('lead_id'=>$quotation_id,'type'=>'Event'); $where3=array('lead_id'=>$quotation_id,'type'=>'Call'); $data1=array('details_from'=>'Account','lead_id'=>$result); $tableg='lead_new_tasks'; $get_activity=$this->yaskawa_model->update($where1,$tableg,$data1); $get_event=$this->yaskawa_model->update($where2,$tableg,$data1); $get_call=$this->yaskawa_model->update($where3,$tableg,$data1); $table="quotations"; $dat=array('account_id'=>$result,'quatetion_from'=>'Account','potential_id'=>0); $con=array('potential_id'=>$quotation_id); $update_quatetion=$this->yaskawa_model->update($con,$table,$dat); $table="new_potential"; $where=array('potential_id'=>$quotation_id); $data=array('delete_status'=>'INACTIVE','converted_next_level'=>'ACONVERT','potential_status'=>'CONVERTED'); $res=$this->yaskawa_model->update($where,$table,$data); $r=1; echo json_encode($r); } else { $r=0; echo json_encode($r); } } //recently_deleted_reports view public function employees_list() { $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $result['user_type_id'] = $this->access_id(); $result['access'] = $this->access_details(); $result['employee_list'] = $this->yaskawa_model->get_all_employees(); $result['company_details']=$this->yaskawa_model->fetch_company_details(); $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count=0; foreach($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if($months=='11'){ $count+=1; } } $result['count']=$count; // print_r($result);die(); $this->load->view('admin/employee_list',$result); } else { redirect('/'); } } // delete_employee public function delete_employee() { $emp_id = $this->input->post('id'); $data = array('delete_status'=>'INACTIVE'); $result = $this->yaskawa_model->delete_employee($emp_id,$data); if($result) { echo json_encode(array('result'=>1,'message'=>'Deleted successfully')); } else { echo json_encode(array('result'=>0)); } } //import excel file to db public function import_employees() { $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $created_at = $date->format('Y-m-d H:i:s'); include '../PHPExcel/IOFactory.php'; if(isset($_FILES['import_employee']['name'])) { $file_name = $_FILES['import_employee']['name']; $ext = pathinfo($file_name, PATHINFO_EXTENSION); if($ext == "xlsx" || $ext == "xls") { $file_name = $_FILES['import_employee']['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++){ $employee_id = trim($allDataInSheet[$i]["B"]); $first_name = trim($allDataInSheet[$i]["C"]); $last_name = trim($allDataInSheet[$i]["D"]); $email_id = trim($allDataInSheet[$i]["E"]); $nick_name = trim($allDataInSheet[$i]["F"]); $department = trim($allDataInSheet[$i]["G"]); $reporting_to = trim($allDataInSheet[$i]["H"]); $source_of_hire = trim($allDataInSheet[$i]["I"]); $location = trim($allDataInSheet[$i]["J"]); $title = trim($allDataInSheet[$i]["K"]); $date_of_joining = trim($allDataInSheet[$i]["L"]); $seating_location = trim($allDataInSheet[$i]["M"]); $work_phone = trim($allDataInSheet[$i]["N"]); $extension = trim($allDataInSheet[$i]["O"]); $employee_status = trim($allDataInSheet[$i]["P"]); $employee_type = trim($allDataInSheet[$i]["Q"]); $employee_role = trim($allDataInSheet[$i]["R"]); $pan_no = trim($allDataInSheet[$i]["S"]); $date_of_birth = trim($allDataInSheet[$i]["T"]); $address = trim($allDataInSheet[$i]["U"]); $residential_address = trim($allDataInSheet[$i]["V"]); $marital_status = trim($allDataInSheet[$i]["W"]); $job_description = trim($allDataInSheet[$i]["X"]); $about_me = trim($allDataInSheet[$i]["Y"]); $date_of_exit = trim($allDataInSheet[$i]["Z"]); $gender = trim($allDataInSheet[$i]["AA"]); //$pre_company_name = trim($allDataInSheet[$i]["AB"]); //$job_title = trim($allDataInSheet[$i]["AC"]); $from_date = trim($allDataInSheet[$i]["AD"]); $to_date = trim($allDataInSheet[$i]["AE"]); //$work_job_description = trim($allDataInSheet[$i]["AF"]); //$school_name = trim($allDataInSheet[$i]["AG"]); //$diplamo_degree = trim($allDataInSheet[$i]["AH"]); //$field_of_study = trim($allDataInSheet[$i]["AI"]); $date_of_completion = trim($allDataInSheet[$i]["AJ"]); //$additional_notes = trim($allDataInSheet[$i]["AK"]); //$interests = trim($allDataInSheet[$i]["AL"]); //$dependent_name = trim($allDataInSheet[$i]["AM"]); //$dependent_relationship = trim($allDataInSheet[$i]["AN"]); $dependent_dob = trim($allDataInSheet[$i]["AO"]); $data =array( 'employee_id' => $employee_id, 'first_name' => $first_name, 'last_name' => $last_name, 'email_id' => $email_id, 'nick_name' => $nick_name, 'department' => $department, 'reporting_to' => $reporting_to, 'source_of_hire' => $source_of_hire, 'location' => $location, 'title' => $title, 'date_of_joining' => $date_of_joining, 'seating_location' => $seating_location, 'work_phone' => $work_phone, 'extension' => $extension, 'employee_status' => $employee_status, 'employee_type' => $employee_type, 'role_id' => $role_id, 'pan_no' => $pan_no, 'date_of_birth' => $date_of_birth, 'address' => $address, 'residential_address' => $residential_address, 'marital_status' => $marital_status, 'job_description' => $job_description, 'about_me' => $about_me, 'date_of_exit' => $date_of_exit, 'gender' => $gender, //'pre_company_name' => $pre_company_name, //'job_title' => $job_title, 'from_date' => $from_date, 'to_date' => $to_date, //'work_job_description' => $work_job_description, //'school_name' => $school_name, //'diplamo_degree' => $diplamo_degree, //'field_of_study' => $field_of_study, 'date_of_completion' => $date_of_completion, //'additional_notes' => $additional_notes, //'interests' => $interests, //'dependent_name' => $dependent_name, //'dependent_relationship' => $dependent_relationship, //'dependent_dob' => $dependent_dob, 'delete_status' => 'ACTIVE', 'created_at ' => $created_at ); $result = $this->yaskawa_model->import_employee_data($data); } echo json_encode(array('result'=>1,'message'=>"Leads added successfully")); } } } else { echo json_encode(array('result'=>3,'message'=>"Please upload file with xlsx extension only")); } } //single_employee_view /*public function single_employee_view() { $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $emp_id = $this->uri->segment(2); $data['employee_details'] = $this->yaskawa_model->single_employee_details($emp_id); $data['job_details'] = unserialize($data['employee_details']->job_title); $data['work_details'] = unserialize($data['employee_details']->work_job_description); $data['school_name'] = unserialize($data['employee_details']->school_name); $data['diplamo_degree'] = unserialize($data['employee_details']->diplamo_degree); $data['field_of_study'] = unserialize($data['employee_details']->field_of_study); $data['additional_notes'] = unserialize($data['employee_details']->additional_notes); $data['interests'] = unserialize($data['employee_details']->interests); $data['dependent_name'] = unserialize($data['employee_details']->dependent_name); $data['dependent_relationship'] = unserialize($data['employee_details']->dependent_relationship); $data['get_all_roles'] = $this->yaskawa_model->get_all_roles_admin(); $data['get_all_departments'] = $this->yaskawa_model->get_all_departments(); $data['designation_list'] = $this->yaskawa_model->get_all_designation(); $data['company_details']=$this->yaskawa_model->fetch_company_details(); $this->load->view('admin/employee_info',$data); } else { redirect('/'); } }*/ public function single_employee_view(){ $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $emp_id = $this->uri->segment(2); $data['employee_details'] = $this->yaskawa_model->single_employee_details($emp_id); // print_r($data['employee_details']);die(); if (isset($data['employee_details']->documents)) { $data['employee_details']->documents = json_decode($data['employee_details']->documents, true) ?: []; } $data['education_details'] = $this->yaskawa_model->employee_education_details($emp_id); if(!empty($data['employee_details'])){ if(($data['employee_details']->job_title)!=' '){ $data['job_details'] = json_decode($data['employee_details']->job_title); }else{ $data['job_details'] = ""; } if(($data['employee_details']->work_job_description)!=' '){ $data['work_details'] = json_decode($data['employee_details']->work_job_description); }else{ $data['work_details'] = ""; } if(($data['employee_details']->dependent_name)!=' '){ $data['dependent_name'] = json_decode($data['employee_details']->dependent_name); }else{ $data['dependent_name'] = ""; } if(($data['employee_details']->dependent_relationship)!=' '){ $data['dependent_relationship'] = json_decode($data['employee_details']->dependent_relationship); }else{ $data['dependent_relationship'] = ""; } }else{ $data['dependent_relationship'] =""; $data['job_details'] = ""; $data['dependent_name'] = ""; $data['interests'] = ""; $data['additional_notes'] = ""; $data['field_of_study'] = ""; $data['diplamo_degree'] = ""; $data['school_name'] = ""; $data['work_details'] = ""; } $data['get_all_roles'] = $this->yaskawa_model->get_all_roles_admin(); $data['get_all_departments'] = $this->yaskawa_model->get_all_departments(); $data['designation_list'] = $this->yaskawa_model->get_all_designation(); $data['company_details']=$this->yaskawa_model->fetch_company_details(); $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count=0; foreach($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if($months=='11'){ $count+=1; } } $data['count']=$count; $this->load->view('admin/employee_info',$data); } else { redirect('/'); } } public function lead_convert() { $lead_id = $this->uri->segment(2); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $converted_at = $date->format('Y-m-d'); $data = array('lead_status'=>'CONVERTED','converted_at'=>$converted_at); $result = $this->yaskawa_model->lead_convert_status($lead_id,$data); if($this->db->affected_rows() > 0) { $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $data['single_details'] = $this->yaskawa_model->single_lead_details($lead_id); $data['pic_details'] = $this->yaskawa_model->get_pic_details($lead_id); $data['lead_details'] = $this->yaskawa_model->get_event_call_details_lead($lead_id); $data['closed_details'] = $this->yaskawa_model->get_event_closed_details_lead($lead_id); $data['notes_details'] = $this->yaskawa_model->get_notes_details($lead_id); $data['converted_status'] = $this->yaskawa_model->get_converted_status_new($lead_id); $data['quotation_details'] = $this->yaskawa_model->get_quotation_details_lead($lead_id); $data['attachment_details'] = $this->yaskawa_model->get_attachment_details($lead_id); $data['company_details']=$this->yaskawa_model->fetch_company_details(); //$this->load->view('admin/lead_information',$data); $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count=0; foreach($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if($months=='11'){ $count+=1; } } $data['count']=$count; $this->load->view('admin/lead_information',$data); } } //acc_closed_activity public function acc_closed_activity() { $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $task_id = $this->uri->segment(2); $task_id2 = $this->uri->segment(3); $dat=array('activity'=>'CLOSE','delete_status'=>'ACTIVE'); $this->yaskawa_model->acc_update_status($task_id2,$dat); $det=$this->yaskawa_model->get_row($task_id); $lead_id=$task_id; //$det->lead_id; $data['honorific']=$this->yaskawa_model->get_honorific(); $data['user_details']=$this->yaskawa_model->get_user_details(); $data['single_details'] = $this->yaskawa_model->single_lead_details($lead_id); $data['account_details'] = $this->yaskawa_model->single_account_details($lead_id); $data['quotation_details'] = $this->yaskawa_model->get_quotation_details_account($lead_id); $data['converted_status'] = $this->yaskawa_model->get_converted_status($lead_id); $data['notes_details'] = $this->yaskawa_model->get_account_notes_details($lead_id); $data['task_details'] = $this->yaskawa_model->get_account_task_details($task_id); $data['closed_details'] = $this->yaskawa_model->get_acc_closed_details($lead_id); $data['lead_ratings'] = $this->yaskawa_model->get_lead_ratings_details(); $data['contact_data']=$this->yaskawa_model->contact_list($lead_id); $data['potential_data']=$this->yaskawa_model->select_new_potential($lead_id); $data['potential_related'] = $this->yaskawa_model->potential_related($lead_id); $data['contact_related'] = $this->yaskawa_model->contact_related($lead_id); $data['account_type'] = $this->yaskawa_model->get_account_type(); $data['industry_details'] = $this->yaskawa_model->get_lead_industry_details(); $data['acc_attachment_details'] = $this->yaskawa_model->get_acc_attachment_details($lead_id); $data['company_details']=$this->yaskawa_model->fetch_company_details(); $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count=0; foreach($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if($months=='11'){ $count+=1; } } $data['count']=$count; $this->load->view('admin/account_info',$data); } else { redirect('/'); } } //edit_quotation public function edit_quotation() { $quotation_id = $this->input->post('id'); $result = $this->yaskawa_model->edit_quotation($quotation_id); if($result) { echo json_encode(array('result'=>1,'edit_details'=>$result,'message'=>"Got edit successfully")); } else { echo json_encode(array('result'=>0,'message'=>"Something went wrong.. try again")); } } // update_quotation public function update_quotation() { $quo_date = date("Y-m-d", strtotime($this->input->post('quo_date'))); $invoice_num = $this->input->post('invoice_num'); $invoice_date = date("Y-m-d", strtotime($this->input->post('invoice_date'))); $invoice_amount = str_replace(',', '',$this->input->post('invoice_amount')); $description = $this->input->post('description'); $lead_id = $this->input->post('account_id'); $quotation_id = $this->input->post('quoteid'); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $updated_at = $date->format('Y-m-d H:i:s'); $quotation_details = array( 'lead_id' => $lead_id, 'invoice_num' => $invoice_num, 'invoice_date' => $invoice_date, 'invoice_amount' => $invoice_amount, 'description' => $description, 'delete_status' => 'ACTIVE', 'convert_status' =>'CONVERTED', 'updated_at' => $updated_at ); $result = $this->yaskawa_model->update_quotation($quotation_id,$lead_id,$quotation_details); if($this->db->affected_rows() > 0) { echo json_encode(array('result'=>1,'message'=>"Updated successfully")); } else { echo json_encode(array('result'=>0,'message'=>"Failed to update. Try again")); } } public function upload_image() { $this->load->library('image_lib'); $user_ids = $this->input->post('user_ids'); $replace_image = $this->input->post('replace_image'); if($_FILES) { if(empty($_FILES['replace_image']['name'])) { $file_name = ""; } else { $target='profile_pictures/'; $target.=time().$_FILES['replace_image']['name']; $file_name=time().$_FILES['replace_image']['name']; $image=$target; move_uploaded_file($_FILES['replace_image']['tmp_name'],$target); $config['source_image']=$target; $config['maintain_ratio']=TRUE; // $config['width']=1280; // $config['height']=960; $this->image_lib->initialize($config); //$this->image_lib->resize(); } } $image_details = array( 'profile_pick' => $file_name, ); $result=$this->yaskawa_model->replace_image($user_ids,$image_details); if($result) { echo json_encode(array('result'=>1,'res'=>$result)); } else { echo json_encode(array('result'=>0)); } } public function lead_upload_image() { $this->load->library('image_lib'); $lead_ids = $this->input->post('lead_ids'); $replace_image = $this->input->post('replace_image'); if($_FILES) { if(empty($_FILES['replace_image']['name'])) { $file_name = ""; } else { $target='profile_pictures/'; $target.=time().$_FILES['replace_image']['name']; $file_name=time().$_FILES['replace_image']['name']; $image=$target; move_uploaded_file($_FILES['replace_image']['tmp_name'],$target); $config['source_image']=$target; $config['maintain_ratio']=TRUE; // $config['width']=1280; // $config['height']=960; $this->image_lib->initialize($config); //$this->image_lib->resize(); } } $lead_image_details = array( 'profile_pick' => $file_name, ); $result=$this->yaskawa_model->lead_replace_image($lead_ids,$lead_image_details); if($result) { echo json_encode(array('result'=>1,'res'=>$result)); } else { echo json_encode(array('result'=>0)); } } public function lead_page_back(){ redirect('yaskawa/lead_list'); } //Delete department public function delete_email_organizing() { $email_settings_id = $this->input->post('id'); $data = array('delete_status'=>'INACTIVE'); $result = $this->yaskawa_model->delete_email_organizing($email_settings_id,$data); if($this->db->affected_rows() > 0) { echo json_encode(array('result'=>1,'message'=>'Deleted successfully')); } else { echo json_encode(array('result'=>0)); } } public function account_inf_back(){ redirect('yaskawa/accounts'); } public function company_details() { $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $user_data['user_type_id'] = $this->access_id(); $user_data['access'] = $this->access_details(); $user_data['users']=$this->yaskawa_model->number_of_users(); $user_data['login_person_data']=$this->yaskawa_model->login_person($admin_id); $user_data['company_details']=$this->yaskawa_model->fetch_company_details(); //$user_data['company_details']=$this->yaskawa_model->fetch_company_details(); $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count=0; foreach($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if($months=='11'){ $count+=1; } } $user_data['count']=$count; $this->load->view('admin/company_settings',$user_data); } else { redirect('/'); } } public function company_logo() { $this->load->library('image_lib'); $cmp_ids = $this->input->post('cmp_ids'); $replace_image = $this->input->post('replace_image'); if($_FILES) { if(empty($_FILES['replace_image']['name'])) { $file_name = ""; } else { $target='profile_pictures/'; $target.=time().$_FILES['replace_image']['name']; $file_name=time().$_FILES['replace_image']['name']; $image=$target; move_uploaded_file($_FILES['replace_image']['tmp_name'],$target); $config['source_image']=$target; $config['maintain_ratio']=TRUE; // $config['width']=1280; // $config['height']=960; $this->image_lib->initialize($config); //$this->image_lib->resize(); } } $company_image = array( 'company_pic' => $file_name, ); $result=$this->yaskawa_model->company_logo($cmp_ids,$company_image); if($result) { echo json_encode(array('result'=>1,'res'=>$result)); } else { echo json_encode(array('result'=>0)); } } public function account_page_back(){ redirect('yaskawa/accounts'); } //Edit employee public function edit_employee() { $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $emp_id = $this->uri->segment(2); $data['dept_list'] = $this->yaskawa_model->get_all_departments(); $data['emp_details'] = $this->yaskawa_model->edit_emp_details($emp_id); if (isset($data['emp_details']->documents)) { $data['emp_details']->documents = json_decode($data['emp_details']->documents, true); } $data['education_details'] = $this->yaskawa_model->employee_education_details($emp_id); $data['company_details']=$this->yaskawa_model->fetch_company_details(); $data['dept_list'] = $this->yaskawa_model->get_all_departments(); $data['designation_list'] = $this->yaskawa_model->get_all_designation(); $data['get_all_roles'] = $this->yaskawa_model->get_all_roles_admin(); $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count=0; foreach($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if($months=='11'){ $count+=1; } } $data['count']=$count; $this->load->view('admin/edit_employee',$data); } else { redirect('/'); } } //update Employee public function update_employee(){ //$employee_id = $this->input->post('employee_id'); $emp_id = $this->input->post('emp_id'); $employee_id='JB-100'.$emp_id; $first_name = $this->input->post('first_name'); $last_name = $this->input->post('last_name'); $email_id = $this->input->post('email_id'); $nick_name = $this->input->post('nick_name'); $department_id = $this->input->post('department_id'); //$designation_id = $this->input->post('designation_id'); $reporting_to = $this->input->post('reporting_to'); $source_of_hire = $this->input->post('source_of_hire'); $location = $this->input->post('location'); $title = $this->input->post('title'); $date_of_joining = $this->input->post('date_of_joining'); $seating_location = $this->input->post('seating_location'); $work_phone = $this->input->post('work_phone'); $extension = $this->input->post('extension'); $employee_status = $this->input->post('employee_status'); $employee_type = $this->input->post('employee_type'); $role_id = $this->input->post('role_id'); $pan_no = $this->input->post('pan_no'); $date_of_birth = $this->input->post('date_of_birth'); $address = $this->input->post('address'); $residential_address = $this->input->post('residential_address'); $marital_status = $this->input->post('marital_status'); $job_description = $this->input->post('job_description'); $about_me = $this->input->post('about_me'); $date_of_exit = $this->input->post('date_of_exit'); $gender = $this->input->post('gender'); $pre_com_name = $this->input->post('pre_com_name'); $pre_com_name1 = json_encode($pre_com_name); $job_title = $this->input->post('job_title'); $job_title1 = json_encode($job_title); $from_date = $this->input->post('from_date'); $from_date1 = json_encode($from_date); $to_date = $this->input->post('to_date'); $to_date1 = json_encode($to_date); $work_job_description = $this->input->post('work_job_description'); $work_job_description1 = json_encode($work_job_description); $school_name = $this->input->post('school_name'); $diplamo_degree = $this->input->post('diplamo_degree'); $field_of_study = $this->input->post('field_of_study'); $date_of_completion = $this->input->post('date_of_completion'); $additional_notes = $this->input->post('additional_notes'); $interests = $this->input->post('interests'); $dependent_name = $this->input->post('dependent_name'); $dependent_name1 = json_encode($dependent_name); $dependent_relationship = $this->input->post('dependent_relationship'); $dependent_relationship1 = json_encode($dependent_relationship); $dependent_dob = $this->input->post('dependent_dob'); $dependent_dob1 = json_encode($dependent_dob); $aggregate = $this->input->post('aggregate'); $aggregate1 = json_encode($aggregate); $this->load->library('upload'); //$myFile = $_FILES['file_upload']; // $file=$this->input->post('file_upload'); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $created_at = $date->format('Y-m-d'); $data = array( 'employee_id' => $employee_id, 'first_name' => $first_name, 'last_name' => $last_name, 'email_id' => $email_id, 'nick_name' => $nick_name, 'department_id' => $department_id, //'designation_id' => $designation_id, 'reporting_to' => $reporting_to, 'source_of_hire' => $source_of_hire, 'location' => $location, 'title' => $title, 'date_of_joining' => $date_of_joining, 'seating_location' => $seating_location, 'work_phone' => $work_phone, 'extension' => $extension, 'employee_status' => $employee_status, 'employee_type' => $employee_type, 'role_id' => $role_id, 'pan_no' => $pan_no, 'date_of_birth' => $date_of_birth, 'address' => $address, 'residential_address' => $residential_address, 'marital_status' => $marital_status, 'job_description' => $job_description, 'about_me' => $about_me, 'date_of_exit' => $date_of_exit, 'gender' => $gender, 'pre_company_name' => $pre_com_name1, 'job_title' => $job_title1, 'from_date' => $from_date1, 'to_date' => $to_date1, 'work_job_description' => $work_job_description1, 'dependent_name' => $dependent_name1, 'dependent_relationship' => $dependent_relationship1, 'dependent_dob' => $dependent_dob1, 'delete_status' => 'ACTIVE', 'created_at' => $created_at ); // ================= FETCH EXISTING DOCUMENTS ================= $emp_row = $this->db ->where('emp_id', $emp_id) ->where('delete_status', 'ACTIVE') ->get('employees') ->row(); $existing_docs = []; if (!empty($emp_row->documents)) { $existing_docs = json_decode($emp_row->documents, true); } // ================= REMOVE SELECTED DOCUMENTS ================= $remove_docs = $this->input->post('remove_doc') ?? []; foreach ($remove_docs as $index) { if (isset($existing_docs[$index])) { $file_path = FCPATH . $existing_docs[$index]['file']; if (file_exists($file_path)) { unlink($file_path); } unset($existing_docs[$index]); } } $existing_docs = array_values($existing_docs); // ================= UPLOAD NEW DOCUMENTS ================= $new_docs = []; $doc_names = $this->input->post('doc_name'); // TEXT NAMES if (isset($_FILES['doc_file']) && !empty($_FILES['doc_file']['name'][0])) { $allowed_extensions = ['jpg','jpeg','png','gif','pdf','doc','docx','xls','xlsx']; foreach ($_FILES['doc_file']['name'] as $key => $filename) { if (empty($filename)) continue; $ext = strtolower(pathinfo($filename, PATHINFO_EXTENSION)); if (!in_array($ext, $allowed_extensions)) continue; $safe_name = time().'_'.$key.'_'.preg_replace('/[^a-zA-Z0-9._-]/','_', $filename); $relative_path = 'files/'.$safe_name; $full_path = FCPATH . $relative_path; if (move_uploaded_file($_FILES['doc_file']['tmp_name'][$key], $full_path)) { $new_docs[] = [ 'name' => $doc_names[$key] ?? 'Document', 'file' => $relative_path ]; } } } // ================= MERGE OLD + NEW ================= $final_docs = array_merge($existing_docs, $new_docs); if (!empty($final_docs)) { $data['documents'] = json_encode($final_docs); } $where=array('emp_id'=>$emp_id,'delete_status'=>'ACTIVE'); $table_employee='employees'; $result = $this->yaskawa_model->update_employee_details($table_employee,$where,$data); $where_edu=array('employee_id'=>$emp_id,'delete_status'=>'ACTIVE'); $table_education='employee_education'; $get_data = $this->yaskawa_model->get_data($table_education,$where_edu); $edu_id=array(); foreach($get_data as $val) { array_push($edu_id,$val->id); } $count_id=count($edu_id); $test=$this->input->post('test'); if(!empty($school_name)){ foreach($school_name as $key=>$d) { $education_details = array('employee_id' =>$emp_id, 'college_name' =>$school_name[$key], 'diplamo_degree' =>$diplamo_degree[$key], 'field_of_study' =>$field_of_study[$key], 'date_of_completion' =>$date_of_completion[$key], 'additional_notes' =>$additional_notes[$key], 'interests' =>$interests[$key], 'aggregate' =>$aggregate[$key], 'delete_status' =>'ACTIVE', 'created_at' =>$created_at); $myFile = $_FILES['file_upload'.$test[$key]]; $cpt = count($_FILES['file_upload'.$test[$key]]['name']); $file_doc=""; unset($document); for($i=0; $i<$cpt; $i++) { $file_name='file_upload'.$test[$key]; if($_FILES['file_upload'.$test[$key]]['name']) { $path=$_FILES['file_upload'.$test[$key]]['name'][$i]; $target='files/'; $target.=time().$_FILES['file_upload'.$test[$key]]['name'][$i]; $document[]=time().$_FILES['file_upload'.$test[$key]]['name'][$i]; move_uploaded_file($_FILES['file_upload'.$test[$key]]['tmp_name'][$i],$target); $file_doc=json_encode($document); } else { $file_doc=""; } } if($myFile['name'][0]!="") { $education_details['file']=$file_doc; } $table_education='employee_education'; if($count_id>1||$count_id>=1) { $where=array('id'=>$edu_id[$key],'delete_status'=>'ACTIVE'); $count_id=$count_id-1; $result = $this->yaskawa_model->update_employee_details($table_education,$where,$education_details); } else { $result = $this->yaskawa_model->add_employee_education($education_details); } } } if($result) { echo json_encode(array('result'=>1,'message'=>"Employee added successfully")); } else { echo json_encode(array('result'=>0,'message'=>"Something went wrong.. try again")); } } public function user_name_authentication(){ $user_name=$this->input->post('user_name'); $result=$this->yaskawa_model->user_name_authentication($user_name); echo json_encode($result); } // single_quotation_update public function single_quotation_update() { $quo_date = $this->input->post('quo_date'); $amount = $this->input->post('amount'); $response_date = $this->input->post('response_date'); $probability_range = $this->input->post('probability_range'); $description = $this->input->post('description'); $account_id = $this->input->post('account_id'); $quotation_id = $this->input->post('quote_id'); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $updated_at = $date->format('Y-m-d H:i:s'); $quotation_details = array( 'lead_id' => $account_id, 'quo_date' => $quo_date, 'response_date' => $response_date, 'probability' => $probability_range, 'amount' => $amount, 'description' => $description, 'delete_status' => 'ACTIVE', 'updated_at' => $updated_at ); $result = $this->yaskawa_model->single_quotation_update($quotation_id,$quotation_details); if($this->db->affected_rows() > 0) { echo json_encode(array('result'=>1,'message'=>"Updated successfully")); } else { echo json_encode(array('result'=>0,'message'=>"Failed to update. Try again")); } } public function users_email_authentication(){ $email_authentication=$this->input->post('email_authentication'); $result=$this->yaskawa_model->users_email_authentication($email_authentication); if($result){ echo json_encode(array('result'=>1)); } else { echo json_encode(array('result'=>0)); } } public function verify_email() { $email = $this->input->post('email'); $result = $this->yaskawa_model->verify_email($email); if($result){ echo json_encode(array('result'=>1,'id'=>$result)); } else { echo json_encode(array('result'=>0)); } } //new_events public function reset_password() { //$data['user_type_id'] = $this->access_id(); //$data['access'] = $this->access_details(); $data['user_id'] = $this->uri->segment(3); $this->load->view('admin/reset_password',$data); } // update_password public function update_password() { $password = $this->input->post('password'); $password1 = $this->input->post('password1'); //$password1 = md5($this->input->post('password1')); $user_id = $this->input->post('user_id'); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $updated_at = $date->format('Y-m-d H:i:s'); if($password == $password1){ $password_details = array( 'password' => md5($password1), 'delete_status' => 'ACTIVE', 'updated_at' => $updated_at ); $result = $this->yaskawa_model->update_password($user_id,$password_details); if($this->db->affected_rows() > 0) { echo json_encode(array('result'=>1,'message'=>"Updated successfully")); } else { echo json_encode(array('result'=>0,'message'=>"Failed to update. Try again")); } }else{ echo json_encode(array('result'=>0,'message'=>"Failed to update. Try again")); } } //////////////Access Control///////////////////// public function access_details() { $admin_id = $this->session->userdata('admin_id'); //$where=array('user_id'=>$id); //$approved_by=$admin_id; $where=array('user_id'=>$admin_id); $approved_by=$admin_id; $table='users'; $where=array('user_id'=>$approved_by); $d=$this->yaskawa_model->get_where_row($table,$where); $data['user_type_id']=$d->department_id; $role_id=$this->session->userdata('role_id'); $table='yaskawa_access_controls'; $where=array('department_id'=>$role_id); return $this->yaskawa_model->get_where_row($table,$where); } public function access_id() { $admin_id = $this->session->userdata('admin_id'); $where=array('user_id'=>$admin_id); $approved_by=$admin_id; $table='users'; $where=array('user_id'=>$approved_by); $d=$this->yaskawa_model->get_where_row($table,$where); return $d->department_id; } public function add_access_menu() { $department_id = $this->input->post('department_id'); $menu_id = $this->input->post('menu_id'); $array = array(); foreach($menu_id as $val) { $array[] = $val; } $menu_ids = serialize($array); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $created_at = $date->format('Y-m-d H:i:s'); $table = 'yaskawa_access_controls'; $data = array( 'menu_id' => $menu_ids, 'department_id' => $department_id, 'delete_status' => 'ACTIVE', 'created_at' => $created_at ); $where = array('delete_status'=>'ACTIVE'); $depts = $this->yaskawa_model->get_where_result($table,$where); $dept_array = array(); foreach($depts as $value) { array_push($dept_array, $value->department_id); } if(in_array($department_id,$dept_array)) { $where_dept = array('department_id' => $department_id); $update_data = $data; $result = $this->yaskawa_model->update_access($where_dept,$table,$update_data); if($this->db->affected_rows() > 0) { echo json_encode(array('result'=>1,'message'=>'Access controls added successfully')); } else { echo json_encode(array('result'=>0)); } } else { $result = $this->yaskawa_model->insert_access($table,$data); if($result) { echo json_encode(array('result'=>1,'message'=>"Access controls added successfully")); } else { echo json_encode(array('result'=>0,'message'=>"Something went wrong.. try again")); } } } public function add_access() { $data['menu'] = $this->yaskawa_model->get_all_menu_data(); $data['roles'] = $this->yaskawa_model->get_all_departments_data(); $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $data['company_details']=$this->yaskawa_model->fetch_company_details(); $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count=0; foreach($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if($months=='11'){ $count+=1; } } $data['count']=$count; $this->load->view('admin/add_access',$data); } public function get_menu_list() { $table = 'yaskawa_menu'; $where = array('delete_status'=>'ACTIVE'); $result = $this->yaskawa_model->fetch_where_data($table,$where); if($result) { echo json_encode(array('menu_list'=>$result,'result'=>1)); } else { echo json_encode(array('result'=>0)); } } public function single_department_access() { $table = 'yaskawa_access_controls'; $department_id = $this->input->post('department_id'); $where = array('delete_status' =>'ACTIVE','department_id' =>$department_id); $result = $this->yaskawa_model->get_where_row($table,$where); if($result) { $access = unserialize($result->menu_id); if($access) { echo json_encode(array('access'=>$access,'result'=>1)); } else { echo json_encode(array('result'=>0)); } } else { echo json_encode(array('result'=>0)); } } public function verify_lead_email() { $email = $this->input->post('email'); $result = $this->yaskawa_model->verify_lead_email_id($email); if($result){ echo json_encode(array('result'=>1,'id'=>$result)); } else { echo json_encode(array('result'=>0)); } } public function verify_employee_email() { $email = $this->input->post('email'); $result = $this->yaskawa_model->verify_employee_email_id($email); if($result){ echo json_encode(array('result'=>1,'id'=>$result)); } else { echo json_encode(array('result'=>0)); } } //profile_info public function profile_info() { $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $lead_id = $this->uri->segment(2); $data['single_details'] = $this->yaskawa_model->single_lead_profile_details($lead_id); $data['pic_details'] = $this->yaskawa_model->get_pic_details($lead_id); $data['lead_details'] = $this->yaskawa_model->get_event_call_details($lead_id); $data['closed_details'] = $this->yaskawa_model->get_event_closed_details($lead_id); $data['notes_details'] = $this->yaskawa_model->get_notes_details($lead_id); $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count=0; foreach($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if($months=='11'){ $count+=1; } } $data['count']=$count; $data['attachment_details'] = $this->yaskawa_model->get_attachment_details($lead_id); $data['company_details']=$this->yaskawa_model->fetch_company_details(); $this->load->view('admin/profile_view',$data); } else { redirect('/'); } } public function profile_info1() { $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $lead_id = $this->uri->segment(2); $data['single_details'] = $this->yaskawa_model->single_lead_details($lead_id); $data['pic_details'] = $this->yaskawa_model->get_pic_details($lead_id); $data['lead_details'] = $this->yaskawa_model->get_event_call_details($lead_id); $data['closed_details'] = $this->yaskawa_model->get_event_closed_details($lead_id); $data['notes_details'] = $this->yaskawa_model->get_notes_details($lead_id); $data['attachment_details'] = $this->yaskawa_model->get_attachment_details($lead_id); $data['company_details']=$this->yaskawa_model->fetch_company_details(); $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count=0; foreach($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if($months=='11'){ $count+=1; } } $data['count']=$count; $this->load->view('admin/profile_view1',$data); } else { redirect('/'); } } public function update_company_details(){ $id = $this->input->post('id'); $cname = $this->input->post('cname'); $Alias = $this->input->post('Alias'); $ecount = $this->input->post('ecount'); $Phone = $this->input->post('Phone'); $Mobile = $this->input->post('Mobile'); $Fax = $this->input->post('Fax'); $Website = $this->input->post('Website'); $Description = $this->input->post('Description'); $Super_Admin = $this->input->post('Super_Admin'); $Street = $this->input->post('Street'); $City = $this->input->post('City'); $State = $this->input->post('State'); $Zip_Code = $this->input->post('Zip_Code'); $Country = $this->input->post('Country'); $cdate = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $create_at = $cdate->format('Y-m-d H:i:s'); $company_details=array( 'Company_Name' => $cname, 'Alias' => $Alias, 'Employee_Count' => $ecount, 'Phone' => $Phone, 'Mobile' => $Mobile, 'Fax' => $Fax, 'Website' => $Website, 'Description' => $Description, 'Super_Admin' => $Super_Admin, 'Street' => $Street, 'City' => $City, 'State' => $State, 'Zip_Code' => $Zip_Code, 'Country' => $Country, 'create_at' => $create_at ); $result=$this->yaskawa_model->update_company_details($id,$company_details); if($result) { echo json_encode(array('result'=>1,'res'=>$result)); } else { echo json_encode(array('result'=>0)); } } //Acc_reports view public function Acc_reports() { $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $table="acc_report_menu"; $where=array('report_status'=>'ACTIVE','delete_status'=>'ACTIVE'); $data['Acc_contents']=$this->yaskawa_model->Acc_contents($table,$where); $data['company_details']=$this->yaskawa_model->fetch_company_details(); $data['user_id']= $this->session->userdata('user_type_id'); $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count=0; foreach($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if($months=='11'){ $count+=1; } } $data['count']=$count; $this->load->view('admin/Acc_reports',$data); } else { redirect('/'); } } public function Acc_favorite_reports() { $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $result['user_type_id'] = $this->access_id(); $result['access'] = $this->access_details(); $result['acc_fav_reoprts'] = $this->yaskawa_model->Acc_favorite_reports(); $result['company_details']=$this->yaskawa_model->fetch_company_details(); $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count=0; foreach($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if($months=='11'){ $count+=1; } } $result['count']=$count; $this->load->view('admin/acc_favorite_reports',$result); } else { redirect('/'); } } public function Acc_today_leads() { $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $result['user_type_id'] = $this->access_id(); $result['access'] = $this->access_details(); $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count=0; foreach($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if($months=='11'){ $count+=1; } } $result['count']=$count; $result['acc_today_leads'] = $this->yaskawa_model->acc_todays_leads_list(); $result['company_details']=$this->yaskawa_model->fetch_company_details(); $this->load->view('admin/acc_lead_todays_list',$result); } else { redirect('/'); } } public function Acc_lead_status() { $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $result['user_type_id'] = $this->access_id(); $result['access'] = $this->access_details(); $result['acc_lead_status'] = $this->yaskawa_model->acc_leads_by_status(); $result['company_details']=$this->yaskawa_model->fetch_company_details(); $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count=0; foreach($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if($months=='11'){ $count+=1; } } $result['count']=$count; $this->load->view('admin/acc_lead_status_list',$result); } else { redirect('/'); } } public function Acc_industry_leads() { $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $result['user_type_id'] = $this->access_id(); $result['access'] = $this->access_details(); $result['acc_industry_leads'] = $this->yaskawa_model->acc_leads_by_industry(); $result['company_details']=$this->yaskawa_model->fetch_company_details(); $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count=0; foreach($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if($months=='11'){ $count+=1; } } $result['count']=$count; $this->load->view('admin/acc_lead_industry_list',$result); } else { redirect('/'); } } public function Acc_sales_source() { $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $lead_id = $this->uri->segment(2); $data['acc_details'] = $this->yaskawa_model->acc_sales_source(); $data['company_details']=$this->yaskawa_model->fetch_company_details(); $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count=0; foreach($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if($months=='11'){ $count+=1; } } $data['count']=$count; $this->load->view('admin/acc_potential_lead_source',$data); } else { redirect('/'); } } public function Acc_lead_conversion() { $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $result['user_type_id'] = $this->access_id(); $result['access'] = $this->access_details(); $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count=0; foreach($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if($months=='11'){ $count+=1; } } $result['count']=$count; $result['acc_sales_across_owner']=$this->yaskawa_model->acc_sales_across_owner(); $result['company_details']=$this->yaskawa_model->fetch_company_details(); $this->load->view('admin/acc_sales_across_owners',$result); } else { redirect('/'); } } public function Acc_conversion_count() { $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $result['user_type_id'] = $this->access_id(); $result['access'] = $this->access_details(); $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count=0; foreach($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if($months=='11'){ $count+=1; } } $result['count']=$count; $result['acc_sales_across_owner']=$this->yaskawa_model->acc_sales_across_owner(); $result['company_details']=$this->yaskawa_model->fetch_company_details(); $this->load->view('admin/acc_sales_count_across_owners',$result); } else { redirect('/'); } } public function Acc_conversion_industry() { $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $result['user_type_id'] = $this->access_id(); $result['access'] = $this->access_details(); $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count=0; foreach($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if($months=='11'){ $count+=1; } } $result['count']=$count; $result['acc_sales_across_owner']=$this->yaskawa_model->acc_sales_across_owner(); $result['company_details']=$this->yaskawa_model->fetch_company_details(); $this->load->view('admin/acc_sales_across_industry',$result); } else { redirect('/'); } } public function Acc_lead_reports() { $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count=0; foreach($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if($months=='11'){ $count+=1; } } $data['count']=$count; $table="acc_report_menu"; $where=array('report_status'=>'ACTIVE','type'=>'Lead Reports'); $data['Acc_contents']=$this->yaskawa_model->acc_get_alldata($table,$where); $data['company_details']=$this->yaskawa_model->fetch_company_details(); $this->load->view('admin/acc_lead_reports',$data); } else { redirect('/'); } } public function Acc_activity_reports() { $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count=0; foreach($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if($months=='11'){ $count+=1; } } $data['count']=$count; $table="acc_report_menu"; $where=array('report_status'=>'ACTIVE','type'=>'Activity Reports'); $data['Acc_contents']=$this->yaskawa_model->acc_get_alldata($table,$where); $data['company_details']=$this->yaskawa_model->fetch_company_details(); $this->load->view('admin/acc_activity_reports',$data); } else { redirect('/'); } } public function Acc_sales_matrics_reports() { $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count=0; foreach($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if($months=='11'){ $count+=1; } } $data['count']=$count; $table="acc_report_menu"; $where=array('report_status'=>'ACTIVE','type'=>'Sales Metrics Reports'); $data['Acc_contents']=$this->yaskawa_model->acc_get_alldata($table,$where); $data['company_details']=$this->yaskawa_model->fetch_company_details(); $this->load->view('admin/acc_sales_matrics_report',$data); } else { redirect('/'); } } public function Acc_todays_sales() { $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $lead_id = $this->uri->segment(2); $data['acc_details'] = $this->yaskawa_model->acc_todays_sales(); $data['company_details']=$this->yaskawa_model->fetch_company_details(); $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count=0; foreach($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if($months=='11'){ $count+=1; } } $data['count']=$count; $this->load->view('admin/acc_potential_todays_sales',$data); } else { redirect('/'); } } public function Acc_converted_leads() { $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $lead_id = $this->uri->segment(2); $data['acc_details'] = $this->yaskawa_model->acc_converted_leads(); $data['company_details']=$this->yaskawa_model->fetch_company_details(); $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count=0; foreach($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if($months=='11'){ $count+=1; } } $data['count']=$count; $this->load->view('admin/acc_lead_converted_list',$data); } else { redirect('/'); } } public function Acc_month_sale() { $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $lead_id = $this->uri->segment(2); $data['acc_details'] = $this->yaskawa_model->acc_month_sale(); $data['company_details']=$this->yaskawa_model->fetch_company_details(); $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count=0; foreach($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if($months=='11'){ $count+=1; } } $data['count']=$count; $this->load->view('admin/acc_potential_sales_this_month',$data); } else { redirect('/'); } } public function Acc_event_task() { $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $lead_id = $this->uri->segment(2); $data['acc_details'] = $this->yaskawa_model->acc_task($lead_id); $data['company_details']=$this->yaskawa_model->fetch_company_details(); $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count=0; foreach($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if($months=='11'){ $count+=1; } } $data['count']=$count; $this->load->view('admin/acc_activity_task_event_list',$data); } else { redirect('/'); } } public function Acc_call_status() { $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $lead_id = $this->uri->segment(2); $data['acc_details'] = $this->yaskawa_model->acc_call_status($lead_id); $data['company_details']=$this->yaskawa_model->fetch_company_details(); $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count=0; foreach($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if($months=='11'){ $count+=1; } } $data['count']=$count; $this->load->view('admin/acc_activity_call_status',$data); } else { redirect('/'); } } public function Acc_conversion_source() { $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $result['user_type_id'] = $this->access_id(); $result['access'] = $this->access_details(); $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count=0; foreach($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if($months=='11'){ $count+=1; } } $result['count']=$count; $result['acc_sales_across_source']=$this->yaskawa_model->acc_sales_across_source(); $result['company_details']=$this->yaskawa_model->fetch_company_details(); $this->load->view('admin/acc_sales_across_source',$result); } else { redirect('/'); } } public function Acc_update_favorite_reports() { $acc_report_id = $this->input->post('acc_report_id'); $data = array('acc_favorite_report'=>'yes'); $result = $this->yaskawa_model->acc_update_favorite_reports($acc_report_id,$data); if($this->db->affected_rows() > 0) { echo json_encode(array('result'=>1)); } else { echo json_encode(array('result'=>0)); } } public function delete_post() { $feeds_id = $this->uri->segment(2); $data = array('delete_status'=>'INACTIVE'); $this->yaskawa_model->feeds_update_status($feeds_id,$data); redirect('lead-feeds'); } public function notification() { $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $lead_id = $this->uri->segment(2); $data['company_details']=$this->yaskawa_model->fetch_company_details(); $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count=0; foreach($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if($months=='11'){ $count+=1; } } $data['count']=$count; $this->load->view('admin/notification',$data); } else { redirect('/'); } } public function account_notification() { $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $lead_id = $this->uri->segment(2); $data['company_details']=$this->yaskawa_model->fetch_company_details(); $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count=0; foreach($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if($months=='11'){ $count+=1; } } $data['count']=$count; $this->load->view('admin/account_notification',$data); } else { redirect('/'); } } public function quotation_notification() { $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $lead_id = $this->uri->segment(2); $data['company_details']=$this->yaskawa_model->fetch_company_details(); $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count=0; foreach($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if($months=='11'){ $count+=1; } } $data['count']=$count; $this->load->view('admin/quotation_notification',$data); } else { redirect('/'); } } public function invoice_notification() { $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $lead_id = $this->uri->segment(2); $data['company_details']=$this->yaskawa_model->fetch_company_details(); $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count=0; foreach($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if($months=='11'){ $count+=1; } } $data['count']=$count; $this->load->view('admin/invoice_notification',$data); } else { redirect('/'); } } public function get_todays_notifications() { $result = $this->yaskawa_model->get_todays_notifications(); //$results = $this->yaskawa_model->get_quotations(); if($result) { echo json_encode(array('result'=>1,'total'=>count($result),'notifications'=>$result)); } else { echo json_encode(array('result'=>0)); } } public function get_alldays_notifications() { $result = $this->yaskawa_model->get_alldays_notifications(); if($result) { echo json_encode(array('result'=>1,'total'=>count($result),'notifications'=>$result)); } else { echo json_encode(array('result'=>0)); } } public function get_thisweek_notifications() { $array = array(); $timestamp = time(); for ($i = 0 ; $i < 7 ; $i++) { $dates = date('Y-m-d', $timestamp); $timestamp -= 24 * 3600; array_push($array,$dates); } $result = $this->yaskawa_model->get_thisweek_notifications($array); if($result) { echo json_encode(array('result'=>1,'total'=>count($result),'notifications'=>$result)); } else { echo json_encode(array('result'=>0)); } } public function getacc_todays_notifications() { $result = $this->yaskawa_model->getacc_todays_notifications(); //$results = $this->yaskawa_model->get_quotations(); if($result) { echo json_encode(array('result'=>1,'total'=>count($result),'notifications'=>$result)); } else { echo json_encode(array('result'=>0)); } } public function getacc_alldays_notifications() { $result = $this->yaskawa_model->getacc_alldays_notifications(); if($result) { echo json_encode(array('result'=>1,'total'=>count($result),'notifications'=>$result)); } else { echo json_encode(array('result'=>0)); } } public function getacc_thisweek_notifications() { $array = array(); $timestamp = time(); for ($i = 0 ; $i < 7 ; $i++) { $dates = date('Y-m-d', $timestamp); $timestamp -= 24 * 3600; array_push($array,$dates); } $result = $this->yaskawa_model->getacc_thisweek_notifications($array); if($result) { echo json_encode(array('result'=>1,'total'=>count($result),'notifications'=>$result)); } else { echo json_encode(array('result'=>0)); } } public function getquot_todays_notifications() { $result = $this->yaskawa_model->getquot_todays_notifications(); //$results = $this->yaskawa_model->get_quotations(); if($result) { echo json_encode(array('result'=>1,'total'=>count($result),'notifications'=>$result)); } else { echo json_encode(array('result'=>0)); } } public function getquot_alldays_notifications() { $result = $this->yaskawa_model->getquot_alldays_notifications(); if($result) { echo json_encode(array('result'=>1,'total'=>count($result),'notifications'=>$result)); } else { echo json_encode(array('result'=>0)); } } public function getquot_thisweek_notifications() { $array = array(); $timestamp = time(); for ($i = 0 ; $i < 7 ; $i++) { $dates = date('Y-m-d', $timestamp); $timestamp -= 24 * 3600; array_push($array,$dates); } $result = $this->yaskawa_model->getquot_thisweek_notifications($array); if($result) { echo json_encode(array('result'=>1,'total'=>count($result),'notifications'=>$result)); } else { echo json_encode(array('result'=>0)); } } public function getinv_todays_notifications() { $result = $this->yaskawa_model->getinv_todays_notifications(); //$results = $this->yaskawa_model->get_quotations(); if($result) { echo json_encode(array('result'=>1,'total'=>count($result),'notifications'=>$result)); } else { echo json_encode(array('result'=>0)); } } public function getinv_alldays_notifications() { $result = $this->yaskawa_model->getinv_alldays_notifications(); if($result) { echo json_encode(array('result'=>1,'total'=>count($result),'notifications'=>$result)); } else { echo json_encode(array('result'=>0)); } } public function getinv_thisweek_notifications() { $array = array(); $timestamp = time(); for ($i = 0 ; $i < 7 ; $i++) { $dates = date('Y-m-d', $timestamp); $timestamp -= 24 * 3600; array_push($array,$dates); } $result = $this->yaskawa_model->getinv_thisweek_notifications($array); if($result) { echo json_encode(array('result'=>1,'total'=>count($result),'notifications'=>$result)); } else { echo json_encode(array('result'=>0)); } } public function smr_data_filter(){ $date=$this->input->post('date'); $created_at = date("m", strtotime($date)); $result=$this->yaskawa_model->smr_data_filter($created_at); if($result) { echo json_encode(array('date_result'=>$result,'result'=>1)); } else { echo json_encode(array('date_result'=>$result,'result'=>0)); } } public function sales_manager_record() { $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $result['user_type_id'] = $this->access_id(); $result['access'] = $this->access_details(); $result['login_person_data']=$this->yaskawa_model->login_person($admin_id); $result['acc_today_leads'] = $this->yaskawa_model->acc_todays_leads_list(); $result['company_details']=$this->yaskawa_model->fetch_company_details(); $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count=0; foreach($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if($months=='11'){ $count+=1; } } $result['count']=$count; $this->load->view('admin/sales_manager_record',$result); } else { redirect('/'); } } public function lead_home() { $admin_id = $this->session->userdata('admin_id'); $user_type = $this->session->userdata('user_type'); if($admin_id) { $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $data['today_leads'] = $this->yaskawa_model->today_leads(); $data['home_employee'] = $this->yaskawa_model->home_employee(); $data['accounts_list']=$this->yaskawa_model->home_accounts_list(); $data['open_tasks']=$this->yaskawa_model->open_tasks(); $data['user_id']= $this->session->userdata('user_type_id'); $data['company_details']=$this->yaskawa_model->fetch_company_details(); $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count=0; foreach($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if($months=='11'){ $count+=1; } } $data['count']=$count; $data['ticket_list']=$this->yaskawa_model->get_open_ticket_list($date_format); $this->load->view('admin/lead_home',$data); } else { redirect('/'); } } public function social_media(){ $ids=$this->input->post("ids"); $social_media1=$this->input->post("social_media1"); $social_media2=$this->input->post("social_media2"); $social_media3=$this->input->post("social_media3"); if($social_media1){ $social_media_update=array('Twitter'=>$social_media1); $result=$this->yaskawa_model->social_media($ids,$social_media_update); if($result) { echo json_encode(array('result'=>1,'res'=>$result)); } else { echo json_encode(array('result'=>0)); } } if($social_media2){ $social_media_update=array('Facebook'=>$social_media2); $result=$this->yaskawa_model->social_media($ids,$social_media_update); if($result) { echo json_encode(array('result'=>1,'res'=>$result)); } else { echo json_encode(array('result'=>0)); } } if($social_media3){ $social_media_update=array('Google'=>$social_media3); $result=$this->yaskawa_model->social_media($ids,$social_media_update); if($result) { echo json_encode(array('result'=>1,'res'=>$result)); } else { echo json_encode(array('result'=>0)); } } } public function acc_recently_deleted_reports() { $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count=0; foreach($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if($months=='11'){ $count+=1; } } $data['count']=$count; $table="acc_report_menu"; $where=array('report_status'=>'ACTIVE','delete_status'=>'DEACTIVE'); $data['content']=$this->yaskawa_model->acc_get_alldata($table,$where); $data['company_details']=$this->yaskawa_model->fetch_company_details(); $this->load->view('admin/acc_recently_deleted_reports',$data); } else { redirect('/'); } } public function acc_restore_reports() { $acc_report_id=$this->input->post('acc_report_id'); $data=array('delete_status'=>'ACTIVE'); $this->yaskawa_model->acc_delete_report($acc_report_id,$data); if($this->db->affected_rows() > 0) { echo json_encode(array('result'=>1,'message'=>'Deleted successfully')); } else { echo json_encode(array('result'=>0)); } } public function acc_remove_reports() { $acc_report_id=$this->input->post('acc_report_id'); $data=array('delete_status'=>'DELETED'); $this->yaskawa_model->acc_delete_report($acc_report_id,$data); if($this->db->affected_rows() > 0) { echo json_encode(array('result'=>1,'message'=>'Deleted successfully')); } else { echo json_encode(array('result'=>0)); } } public function acc_remove_records() { $record_ids=$this->input->post('report_ids'); $data=array('delete_status'=>'DEACTIVE'); $this->yaskawa_model->acc_delete_report($record_ids,$data); if($this->db->affected_rows() > 0) { echo json_encode(array('result'=>1,'message'=>'Deleted successfully')); } else { echo json_encode(array('result'=>0)); } } public function delete_lead_source(){ $source_id=$this->input->post('source_id'); $data=array('delete_status'=>'INACTIVE'); $result=$this->yaskawa_model->delete_lead_source($source_id,$data); if($result) { echo json_encode(array('result'=>1,'res'=>$result)); } else { echo json_encode(array('result'=>0)); } } public function delete_lead_industry(){ $industry_id=$this->input->post('industry_id'); $data=array('delete_status'=>'INACTIVE'); $result=$this->yaskawa_model->delete_lead_industry($industry_id,$data); if($result) { echo json_encode(array('result'=>1,'res'=>$result)); } else { echo json_encode(array('result'=>0)); } } public function delete_lead_status(){ $status_id=$this->input->post('status_id'); $data=array('delete_status'=>'INACTIVE'); $result=$this->yaskawa_model->delete_lead_status($status_id,$data); if($result) { echo json_encode(array('result'=>1,'res'=>$result)); } else { echo json_encode(array('result'=>0)); } } public function delete_rating(){ $rating_id=$this->input->post('rating_id'); $data=array('delete_status'=>'INACTIVE'); $result=$this->yaskawa_model->delete_rating($rating_id,$data); if($result) { echo json_encode(array('result'=>1,'res'=>$result)); } else { echo json_encode(array('result'=>0)); } } public function delete_account_type(){ $account_id=$this->input->post('account_id'); $data=array('delete_status'=>'INACTIVE'); $result=$this->yaskawa_model->delete_account_type($account_id,$data); if($result) { echo json_encode(array('result'=>1,'res'=>$result)); } else { echo json_encode(array('result'=>0)); } } public function lead_details_update() { $lids = $this->input->post('lids'); $lead_owner = $this->input->post('lead_owner'); $company_name = $this->input->post('company_name'); $last_name = $this->input->post('last_name'); $lead_title = $this->input->post('lead_title'); $email = $this->input->post('email'); $phone = $this->input->post('phone'); $fax = $this->input->post('fax'); $mobile = $this->input->post('mobile'); $website = $this->input->post('website'); $lead_source = $this->input->post('lead_source'); $industry = $this->input->post('industry'); $no_of_employees = $this->input->post('no_of_employees'); $annual_revenue = $this->input->post('annual_revenue'); $ratings = $this->input->post('ratings'); $email_otp = $this->input->post('email_otp'); $street = $this->input->post('street'); $city = $this->input->post('city'); $state = $this->input->post('state'); $zip_code = $this->input->post('zip_code'); $country = $this->input->post('country'); $Cperson = $this->input->post('Cperson'); $alternate_email = $this->input->post('alternate_email'); $alternate_phone = $this->input->post('alternate_phone'); $service_name = $this->input->post('service_name'); $service_date = $this->input->post('service_date'); $service_amount = $this->input->post('service_amount'); if(!empty($service_name)){ $service_names=json_encode($service_name); }else { $service_names=''; } if(!empty($service_amount)){ $service_amounts=json_encode($service_amount); }else { $service_amounts=''; } if(!empty($service_date)){ $service_dates=json_encode($service_date); }else { $service_dates=''; } $explode=explode(':', $Cperson); if(count($explode)==2) { $Cperson=$explode[0]; $contact_id=$explode[1]; } else { $Cperson=$explode[0]; $contact_id=0; } $Cphone = $this->input->post('Cphone'); $cType = $this->input->post('cType'); $lprocess = $this->input->post('lprocess'); $description = $this->input->post('description'); $lead_details_update = array( 'service_amount'=>$service_amounts, 'service_date'=>$service_dates, 'service_name'=>$service_names, 'lead_owner' => $lead_owner, 'contact_id' => $contact_id, 'company_name' => $company_name, 'first_name' => $last_name, 'lead_title' => $lead_title, 'email' => $email, 'phone' => $phone, 'website' => $website, 'fax' => $fax, 'mobile' => $mobile, 'lead_source' => $lead_source, 'industry' => $industry, 'no_of_employees' => $no_of_employees, 'annual_revenue' => $annual_revenue, 'ratings' => $ratings, 'email_otp' => $email_otp, 'street' => $street, 'city' => $city, 'state' => $state, 'zip_code' => $zip_code, 'country' => $country, 'Cperson' => $Cperson, 'Cphone' => $Cphone, 'cType' => $cType, 'lprocess' => $lprocess, 'description' => $description, 'alternate_email' => $alternate_email, 'alternate_phone' => $alternate_phone, 'delete_status' => 'ACTIVE', ); $result = $this->yaskawa_model->lead_details_update($lids,$lead_details_update); if($result) { echo json_encode(array('result'=>1,'message'=>"Lead added successfully")); } else { echo json_encode(array('result'=>0,'message'=>"Something went wrong.. try again")); } } public function master_page() { $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $user_data['user_type_id'] = $this->access_id(); $user_data['access'] = $this->access_details(); $user_data['lead_source']=$this->yaskawa_model->get_lead_source_details(); $user_data['lead_ratings']=$this->yaskawa_model->get_lead_ratings_details(); $user_data['lead_status']=$this->yaskawa_model->get_lead_status_details(); $user_data['lead_industry']=$this->yaskawa_model->get_lead_industry_details(); $user_data['honorific']=$this->yaskawa_model->get_honorific(); $user_data['customer_type']=$this->yaskawa_model->get_customer_type(); $user_data['lead_process']=$this->yaskawa_model->get_lead_process(); $user_data['company_details']=$this->yaskawa_model->fetch_company_details(); $user_data['login_person_data']=$this->yaskawa_model->login_person($admin_id); $user_data['roles_list_admin'] = $this->yaskawa_model->get_all_roles_admin(); $user_data['account_type'] = $this->yaskawa_model->get_account_type(); $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count=0; foreach($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if($months=='11'){ $count+=1; } } $user_data['count']=$count; $this->load->view('admin/master_page',$user_data); } else { redirect('/'); } } public function insert_master_page(){ $ids=$this->input->post("ids"); $master_data=$this->input->post('master_data'); if($master_data == 1){ if( $ids == ""){ $enter_data=$this->input->post('enter_data'); $data=array('lead_source_name'=>$enter_data); $result=$this->yaskawa_model->insert_lead_source1($data); redirect('yaskawa/master_page',$result); }else{ $enter_data=$this->input->post('enter_data'); $data=array('lead_source_name'=>$enter_data); $result=$this->yaskawa_model->update_lead_source1($ids,$data); redirect('yaskawa/master_page',$result); } }else if($master_data == 2){ if( $ids == ""){ $enter_data=$this->input->post('enter_data'); $data=array('industry_name'=>$enter_data); $result=$this->yaskawa_model->insert_industry1($data); redirect('yaskawa/master_page',$result); }else{ $enter_data=$this->input->post('enter_data'); $data=array('industry_name'=>$enter_data); $result=$this->yaskawa_model->update_industry1($ids,$data); redirect('yaskawa/master_page',$result); } }else if($master_data == 3){ if($ids == ""){ $enter_data=$this->input->post('enter_data'); $data=array('lead_status_name'=>$enter_data); $result=$this->yaskawa_model->insert_lead_status1($data); redirect('yaskawa/master_page',$result); }else{ $enter_data=$this->input->post('enter_data'); $data=array('lead_status_name'=>$enter_data); $result=$this->yaskawa_model->update_lead_status1($ids,$data); redirect('yaskawa/master_page',$result); } }else if($master_data == 4){ if( $ids == ""){ $enter_data=$this->input->post('enter_data'); $data=array('ratings'=>$enter_data); $result=$this->yaskawa_model->insert_rating1($data); if($result) redirect('yaskawa/master_page',$result); }else{ $enter_data=$this->input->post('enter_data'); $data=array('ratings'=>$enter_data); $result=$this->yaskawa_model->update_rating1($ids,$data); redirect('yaskawa/master_page',$result); } }else if($master_data == 5){ if( $ids == ""){ $enter_data=$this->input->post('enter_data'); $data=array('account_type'=>$enter_data); $result=$this->yaskawa_model->insert_account_type1($data); redirect('yaskawa/master_page',$result); }else{ $enter_data=$this->input->post('enter_data'); $data=array('account_type'=>$enter_data); $result=$this->yaskawa_model->update_account_type1($ids,$data); redirect('yaskawa/master_page',$result); } }else if($master_data == 6){ if( $ids == ""){ $enter_data=$this->input->post('enter_data'); $data=array('honorific'=>$enter_data); $result=$this->yaskawa_model->insert_honorific($data); redirect('yaskawa/master_page',$result); }else{ $enter_data=$this->input->post('enter_data'); $data=array('honorific'=>$enter_data); $result=$this->yaskawa_model->update_honorific1($ids,$data); redirect('yaskawa/master_page',$result); } }else if($master_data == 7){ if( $ids == ""){ $enter_data=$this->input->post('enter_data'); $data=array('customer_type'=>$enter_data); $result=$this->yaskawa_model->insert_customer_type($data); redirect('yaskawa/master_page',$result); }else{ $enter_data=$this->input->post('enter_data'); $data=array('customer_type'=>$enter_data); $result=$this->yaskawa_model->update_customer_type1($ids,$data); redirect('yaskawa/master_page',$result); } }else if($master_data == 8){ if( $ids == ""){ $enter_data=$this->input->post('enter_data'); $progress_range=$this->input->post('progress'); $data=array('lead_process'=>$enter_data,'process_rate'=>$progress_range); $result=$this->yaskawa_model->insert_lead_process($data); redirect('yaskawa/master_page',$result); }else{ $enter_data=$this->input->post('enter_data'); $progress_range=$this->input->post('progress'); $data=array('lead_process'=>$enter_data,'process_rate'=>$progress_range); $result=$this->yaskawa_model->update_lead_process1($ids,$data); redirect('yaskawa/master_page',$result); } } } public function edit_lead_source(){ $source_id=$this->input->post('source_id'); $data=array('delete_status'=>'ACTIVE'); $result=$this->yaskawa_model->edit_lead_source($source_id,$data); echo json_encode($result); } public function edit_lead_industry(){ $industry_id=$this->input->post('industry_id'); $data=array('delete_status'=>'ACTIVE'); $result=$this->yaskawa_model->edit_lead_industry($industry_id,$data); echo json_encode($result); } public function edit_lead_status(){ $status_id=$this->input->post('status_id'); $data=array('delete_status'=>'ACTIVE'); $result=$this->yaskawa_model->edit_lead_status($status_id,$data); echo json_encode($result); } public function edit_rating(){ $rating_id=$this->input->post('rating_id'); $data=array('delete_status'=>'ACTIVE'); $result=$this->yaskawa_model->edit_rating($rating_id,$data); echo json_encode($result); } public function edit_account_type(){ $account_id=$this->input->post('account_id'); $data=array('delete_status'=>'ACTIVE'); $result=$this->yaskawa_model->edit_account_type($account_id,$data); echo json_encode($result); } public function edit_honorific(){ $honorific_id=$this->input->post('honorific_id'); $data=array('delete_status'=>'ACTIVE'); $result=$this->yaskawa_model->edit_honorific($honorific_id,$data); echo json_encode($result); } public function edit_customer_type(){ $customer_type_id=$this->input->post('customer_type_id'); $data=array('delete_status'=>'ACTIVE'); $result=$this->yaskawa_model->edit_customer_type($customer_type_id,$data); echo json_encode($result); } public function edit_lead_process(){ $lead_process_id=$this->input->post('lead_process_id'); $data=array('delete_status'=>'ACTIVE'); $result=$this->yaskawa_model->edit_lead_process($lead_process_id,$data); echo json_encode($result); } public function add_account(){ $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $uri = $_SERVER["REQUEST_URI"]; if (strpos($uri, '=') !== false) { $val = substr($uri, strpos($uri, "=") + 1); $data['account_id']=$val; }else { $data['account_id']=''; } $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $data['user_name']= $this->session->userdata('user_name'); $data['honorific']=$this->yaskawa_model->get_honorific(); $data['user_details']=$this->yaskawa_model->get_user_details(); $data['lead_ratings']=$this->yaskawa_model->get_lead_ratings_details(); $data['industry_details']=$this->yaskawa_model->get_lead_industry_details(); $table="masters"; $where=array('master_type_id'=>'13','delete_status'=>'ACTIVE'); $data['account_type']=$this->yaskawa_model->get_where_row($table,$where); $table="masters"; $where=array('master_type_id'=>'14','delete_status'=>'ACTIVE'); $data['account_site']=$this->yaskawa_model->get_where_row($table,$where); $data['company_details']=$this->yaskawa_model->fetch_company_details(); $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count=0; foreach($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if($months=='11'){ $count+=1; } } $data['count']=$count; $this->load->view('admin/add_account',$data); } else { redirect('/'); } } public function add_potential(){ $admin_id = $this->session->userdata('admin_id'); $role_id = $this->session->userdata('role_id'); if($admin_id) { $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $data['honorific']=$this->yaskawa_model->get_honorific(); $data['user_name']= $this->session->userdata('user_name'); $data['user_details']=$this->yaskawa_model->get_user_details(); $data['potential_details']=$this->yaskawa_model->select_new_potential($role_id); $data['company_details']=$this->yaskawa_model->fetch_company_details(); $data['account_persons']=$this->yaskawa_model->account_details(); $data['source_details']=$this->yaskawa_model->get_lead_source_details(); $data['status_details']=$this->yaskawa_model->get_lead_status_details(); $data['lead_ratings']=$this->yaskawa_model->get_lead_ratings_details(); $data['industry_details']=$this->yaskawa_model->get_lead_industry_details(); $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count=0; foreach($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if($months=='11'){ $count+=1; } } $data['count']=$count; $this->load->view('admin/add_potential',$data); } else { redirect('/'); } } public function add_potential_new(){ $admin_id = $this->session->userdata('admin_id'); $role_id = $this->session->userdata('role_id'); if($admin_id) { $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $data['honorific']=$this->yaskawa_model->get_honorific(); $data['user_name']= $this->session->userdata('user_name'); $data['user_details']=$this->yaskawa_model->get_user_details(); $data['potential_details']=$this->yaskawa_model->select_new_potential($role_id); $data['company_details']=$this->yaskawa_model->fetch_company_details(); //$data['account_persons']=$this->yaskawa_model->account_details(); $id = $this->uri->segment(2); $data['account_persons'] = $this->yaskawa_model->single_account_details($id); $data['source_details']=$this->yaskawa_model->get_lead_source_details(); $data['status_details']=$this->yaskawa_model->get_lead_status_details(); $data['lead_ratings']=$this->yaskawa_model->get_lead_ratings_details(); $data['industry_details']=$this->yaskawa_model->get_lead_industry_details(); $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count=0; foreach($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if($months=='11'){ $count+=1; } } $data['count']=$count; $this->load->view('admin/add_potential_new',$data); } else { redirect('/'); } } public function delete_quotation() { $id = $this->input->post('id'); $condition=array('quotation_id'=>$id); $data = array('delete_status'=>'INACTIVE'); $table='quotations'; $result = $this->yaskawa_model->update($condition,$table,$data); if($result) { echo json_encode(array('result'=>1,'message'=>'Deleted successfully')); } else { echo json_encode(array('result'=>0)); } } public function potentials_list(){ $admin_id = $this->session->userdata('admin_id'); $role_id = $this->session->userdata('role_id'); if($admin_id) { $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $data['potential_data']=$this->yaskawa_model->select_new_potential($role_id); $data['company_details']=$this->yaskawa_model->fetch_company_details(); $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count=0; foreach($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if($months=='11'){ $count+=1; } } $data['count']=$count; $this->load->view('admin/potentials_list',$data); } else { redirect('/'); } } public function add_new_account(){ $admin_id = $this->session->userdata('admin_id'); $role_id = $this->session->userdata('role_id'); $open_on = $this->input->post('opened_on'); if(!empty($open_on)) { $opened_on = date('Y-m-d',strtotime($open_on)); } else { $opened_on = '0000-00-00'; } $account_owner = $this->input->post('account_owner'); $rating = $this->input->post('rating'); $account_name = $this->input->post('account_name'); $phone = $this->input->post('phone'); $account_site = $this->input->post('account_site'); $fax = $this->input->post('fax'); $parent_account = $this->input->post('parent_account'); $website = $this->input->post('website'); //$account_number = $this->input->post('account_number'); //$ticker_symbol = $this->input->post('ticker_symbol'); $account_type = $this->input->post('account_type'); //$ownership = $this->input->post('ownership'); $industry = $this->input->post('industry'); $employees = $this->input->post('employees'); $annual_revenue = $this->input->post('annual_revenue'); $sic_code = $this->input->post('sic_code'); $billing_street = $this->input->post('billing_street'); $shipping_street = $this->input->post('shipping_street'); $billing_city = $this->input->post('billing_city'); $shipping_city = $this->input->post('shipping_city'); $billing_state = $this->input->post('billing_state'); $shipping_state = $this->input->post('shipping_state'); $billing_state_code = $this->input->post('billing_state_code'); $shipping_state_code= $this->input->post('shipping_state_code'); $billing_code = $this->input->post('billing_code'); $shipping_code = $this->input->post('shipping_code'); $billing_country = $this->input->post('billing_country'); $shipping_country = $this->input->post('shipping_country'); $description = $this->input->post('description'); $email = $this->input->post('email'); $domain_date = $this->input->post('domain_purchase_date'); if(!empty($domain_date)) { $domain_purchase_date = date('Y-m-d',strtotime($domain_date)); } else { $domain_purchase_date = '0000-00-00'; } $website_livedate = $this->input->post('website_live_date'); if(!empty($website_livedate)) { $website_live_date = date('Y-m-d',strtotime($website_livedate)); } else { $website_live_date = '0000-00-00'; } $amc_date = $this->input->post('amc_date'); if($amc_date=='YES') { $due_date = $this->input->post('due_date'); $due_date = date('Y-m-d',strtotime($due_date)); } else if($amc_date=='NO') { $due_date = ''; } $service_name = $this->input->post('service_name'); $service_date = $this->input->post('service_date'); $service_amount = $this->input->post('service_amount'); if(!empty($service_name)){ $service_names=json_encode($service_name); }else { $service_names=''; } if(!empty($service_amount)){ $service_amounts=json_encode($service_amount); }else { $service_amounts=''; } if(!empty($service_date)){ $service_dates=json_encode($service_date); }else { $service_dates=''; } //////////////////////////////////////////////////////////////////////// /*$net_amount = $this->input->post('net_amount'); $gst_18 = $this->input->post('gst_18'); $total_amount = $this->input->post('total_amount'); $initial_paid1 = $this->input->post('initial_paid1'); $initial_paid2 = $this->input->post('initial_paid2'); $final_pay = $this->input->post('final_pay');*/ //////////////////////////////////////////////////////////////////////// $data=array( /*'final_pay'=>$final_pay, 'initial_paid2'=>$initial_paid2, 'initial_paid1'=>$initial_paid1, 'total_amount'=>$total_amount, 'gst_18'=>$gst_18, 'net_amount'=>$net_amount,*/ 'user_id' => $admin_id, 'role_id' => $role_id, 'opened_on' => $opened_on, 'gst_code' => $this->input->post('gst_code'), 'created_by' => $this->session->userdata('admin_id'), 'account_owner' => $account_owner, 'rating' => $rating, 'email_id' => $email, 'account_name' => $account_name, 'phone' => $phone, 'domain_purchase_date' =>$domain_purchase_date , 'website_live_date' => $website_live_date, 'account_site' => $account_site, 'fax' => $fax, 'parent_account' => $parent_account, 'website' => $website, //'account_number' => $account_number, //'ticker_symbol' => $ticker_symbol, 'account_type' => $account_type, //'ownership' => $ownership, 'industry' => $industry, 'employees' => $employees, 'annual_revenue' => $annual_revenue, 'sic_code' => $sic_code, 'billing_street' => $billing_street, 'shipping_street' => $shipping_street, 'billing_city' => $billing_city, 'shipping_city' => $shipping_city, 'billing_state' => $billing_state, 'shipping_state' => $shipping_state, 'billing_state_code'=> $billing_state_code, 'shipping_state_code'=> $shipping_state_code, 'billing_code' => $billing_code, 'shipping_code' => $shipping_code, 'billing_country' => $billing_country, 'contact_person' =>$this->input->post('contact_name'), 'designation' =>$this->input->post('designation'), 'shipping_country' => $shipping_country, 'description' => $description, 'amc_date' => $amc_date, 'due_date' => $due_date, 'service_amount' => $service_amounts, 'service_date' => $service_dates, 'service_name' => $service_names, 'domain' => $this->input->post('domain'), 'hosting' => $this->input->post('hosting'), 'delete_status' => 'ACTIVE', ); $account_id=$this->input->post('account_id'); if(!empty($account_id)) { $data['old_account_id']=$account_id; } $result=$this->yaskawa_model->add_new_account($data); if($result){ echo json_encode(array('result'=>1,'message'=>"Lead added successfully")); }else { echo json_encode(array('result'=>0,'message'=>"Phone number already exists")); } } public function add_new_potential(){ $admin_id = $this->session->userdata('admin_id'); $role_id = $this->session->userdata('role_id'); $potential_owner = $this->input->post('potential_owner'); $email_id = $this->input->post('email_id'); $sec_email_id = $this->input->post('sec_email_id'); $fax = $this->input->post('fax'); $amount = $this->input->post('amount'); $potential_name = $this->input->post('potential_name'); $close_date = $this->input->post("closing_date"); if(!empty($close_date)) { $close_date = new DateTime($this->input->post("closing_date")); $closing_date = $close_date->format('Y-m-d'); } else { $closing_date='0000-00-00'; } $account_name = $this->input->post('account_name'); $stage = $this->input->post('stage'); $type = $this->input->post('type'); $probability = $this->input->post('probability'); $next_step = $this->input->post('next_step'); $expected_revenue = $this->input->post('expected_revenue'); $lead_source = $this->input->post('lead_source'); $campaign_source = $this->input->post('campaign_source'); $contact_name = $this->input->post('contact_name'); $description = $this->input->post('description'); $contact_id = $this->input->post('contact_id'); $acc_id = $this->input->post('account_id'); $designation = $this->input->post('designation'); $website = $this->input->post('website'); $otp = $this->input->post('email_otp'); if($otp=='on') { $email_otp='YES'; } else { $email_otp='NO'; } $lead_status = $this->input->post('lead_status'); $industry = $this->input->post('industry'); $no_of_employees = $this->input->post('no_of_employees'); $annual_revenue = $this->input->post('annual_revenue'); $ratings = $this->input->post('ratings'); $skype_id = $this->input->post('skype_id'); $street = $this->input->post('street'); $city = $this->input->post('city'); $state = $this->input->post('state'); $zip_code = $this->input->post('zip_code'); $country = $this->input->post('country'); $service_name = $this->input->post('service_name'); $service_date = $this->input->post('service_date'); $service_amount = $this->input->post('service_amount'); if(!empty($service_name)){ $service_names=json_encode($service_name); }else { $service_names=''; } if(!empty($service_amount)){ $service_amounts=json_encode($service_amount); }else { $service_amounts=''; } if(!empty($service_date)){ $service_dates=json_encode($service_date); }else { $service_dates=''; } $data=array( 'user_id' => $admin_id, 'account_id' => $acc_id, 'role_id' => $role_id, 'email_id' => $email_id, 'sec_email' => $sec_email_id, 'fax' => $fax, 'designation' => $designation, 'website' => $website, 'email_otp' => $email_otp, 'potential_status' => $lead_status, 'industry' => $industry, 'no_of_employees' => $no_of_employees, 'annual_revenue' => $annual_revenue, 'ratings' => $ratings, 'skype_id' => $skype_id, 'street' => $street, 'city' => $city, 'state' => $state, 'zip_code' => $zip_code, 'country' => $country, 'address' => $this->input->post('address'), 'service_amount' => $service_amounts, 'service_date' => $service_dates, 'service_name' => $service_names, 'phone_number' =>$this->input->post('contact_number'), 'potential_owner' => $potential_owner, 'amount' => $amount, 'potential_name' => $potential_name, 'closing_date' => $closing_date, 'account_name' => $account_name, 'stage' => $stage, 'contact_id' => $contact_id, 'type' => $type, 'probability' => $probability, 'next_step' => $next_step, 'expected_revenue' => $expected_revenue, 'lead_source' => $lead_source, 'campaign_source' => $campaign_source, 'contact_name' => $contact_name, 'description' => $description, 'p_type' => 'POTENTIAL', 'delete_status' => 'ACTIVE', ); $result=$this->yaskawa_model->add_new_potential($data); if($result) { echo json_encode(array('result'=>1)); } else { echo json_encode(array('result'=>0)); } } public function accounts_details_update() { $open_on = $this->input->post('opened_on'); if(!empty($open_on)) { $opened_on = date('Y-m-d',strtotime($open_on)); } else { $opened_on = '0000-00-00'; } $acc_lids = $this->input->post('acc_lids'); $account_owner = $this->input->post('account_owner'); $rating = $this->input->post('rating'); $account_name = $this->input->post('account_name'); $phone = $this->input->post('phone'); $account_site = $this->input->post('account_site'); $fax = $this->input->post('fax'); $parent_account = $this->input->post('parent_account'); $website = $this->input->post('website'); //$account_number = $this->input->post('account_number'); //$ticker_symbol = $this->input->post('ticker_symbol'); $account_type = $this->input->post('account_type'); //$ownership = $this->input->post('ownership'); $industry = $this->input->post('industry'); $domain_purchase_date = $this->input->post('domain_purchase_date'); $domain_purchase_date =date('Y-m-d',strtotime($domain_purchase_date)); $website_live_date = $this->input->post('website_live_date'); $website_live_date =date('Y-m-d',strtotime($website_live_date)); $employees = $this->input->post('employees'); $annual_revenue = $this->input->post('annual_revenue'); $sic_code = $this->input->post('sic_code'); $billing_street = $this->input->post('billing_street'); $shipping_street = $this->input->post('shipping_street'); $billing_city = $this->input->post('billing_city'); $shipping_city = $this->input->post('shipping_city'); $billing_state = $this->input->post('billing_state'); $shipping_state = $this->input->post('shipping_state'); $billing_state_code = $this->input->post('billing_state_code'); $shipping_state_code= $this->input->post('shipping_state_code'); $billing_code = $this->input->post('billing_code'); $shipping_code = $this->input->post('shipping_code'); $billing_country = $this->input->post('billing_country'); $shipping_country = $this->input->post('shipping_country'); $description = $this->input->post('description'); $email = $this->input->post('email'); $domain_date = $this->input->post('domain_purchase_date'); if(!empty($domain_date)) { $domain_purchase_date = date('Y-m-d',strtotime($domain_date)); } else { $domain_purchase_date = '0000-00-00'; } $website_livedate = $this->input->post('website_live_date'); if(!empty($website_livedate)) { $website_live_date = date('Y-m-d',strtotime($website_livedate)); } else { $website_live_date = '0000-00-00'; } $amc_date = $this->input->post('amc_date'); if($amc_date=='YES') { $due_date = $this->input->post('due_date'); $due_date = date('Y-m-d',strtotime($due_date)); } else if($amc_date=='NO') { $due_date = ''; }else { $due_date = ''; } $service_name = $this->input->post('service_name'); $service_date = $this->input->post('service_date'); $service_amount = $this->input->post('service_amount'); if(!empty($service_name)){ $service_names=json_encode($service_name); }else { $service_names=''; } if(!empty($service_amount)){ $service_amounts=json_encode($service_amount); }else { $service_amounts=''; } if(!empty($service_date)){ $service_dates=json_encode($service_date); }else { $service_dates=''; } //////////////////////////////////////////////////////////////////////// /*$net_amount = $this->input->post('net_amount'); $gst_18 = $this->input->post('gst_18'); $total_amount = $this->input->post('total_amount'); $initial_paid1 = $this->input->post('initial_paid1'); $initial_paid2 = $this->input->post('initial_paid2'); $final_pay = $this->input->post('final_pay');*/ //////////////////////////////////////////////////////////////////////// $data=array( /*'final_pay'=>$final_pay, 'initial_paid2'=>$initial_paid2, 'initial_paid1'=>$initial_paid1, 'total_amount'=>$total_amount, 'gst_18'=>$gst_18, 'net_amount'=>$net_amount,*/ 'account_owner' => $account_owner, 'domain_purchase_date' =>$domain_purchase_date, 'website_live_date' =>$website_live_date, 'contact_person' =>$this->input->post('contact_name'), 'designation' =>$this->input->post('designation'), 'rating' => $rating, 'opened_on' => $opened_on, 'gst_code' => $this->input->post('gst_code'), 'updated_by' => $this->session->userdata('admin_id'), 'account_name' => $account_name, 'phone' => $phone, 'account_site' => $account_site, 'fax' => $fax, 'parent_account' => $parent_account, 'website' => $website, //'account_number' => $account_number, //'ticker_symbol' => $ticker_symbol, 'account_type' => $account_type, //'ownership' => $ownership, 'industry' => $industry, 'employees' => $employees, 'annual_revenue' => $annual_revenue, 'sic_code' => $sic_code, 'billing_street' => $billing_street, 'shipping_street' => $shipping_street, 'billing_city' => $billing_city, 'shipping_city' => $shipping_city, 'billing_state' => $billing_state, 'shipping_state' => $shipping_state, 'billing_state_code' => $billing_state_code, 'shipping_state_code' => $shipping_state_code, 'domain' => $this->input->post('domain'), 'hosting' => $this->input->post('hosting'), 'billing_code' => $billing_code, 'shipping_code' => $shipping_code, 'billing_country' => $billing_country, 'shipping_country' => $shipping_country, 'description' => $description, 'email_id' => $email, 'amc_date' => $amc_date, 'due_date' => $due_date, 'service_amount' => $service_amounts, 'service_date' => $service_dates, 'service_name' => $service_names, 'delete_status' => 'ACTIVE', ); $result = $this->yaskawa_model->accounts_details_update($acc_lids,$data); if($result) { echo json_encode(array('result'=>1,'message'=>"added successfully")); } else { echo json_encode(array('result'=>0,'message'=>"Something went wrong.. try again")); } } public function add_contact(){ $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $data['honorific']=$this->yaskawa_model->get_honorific(); $data['user_name']= $this->session->userdata('user_name'); $data['user_details']=$this->yaskawa_model->get_user_details(); $data['lead_source']=$this->yaskawa_model->get_lead_source_details(); $data['potential_details']=$this->yaskawa_model->select_new_potential($admin_id); $data['company_details']=$this->yaskawa_model->fetch_company_details(); $data['account_persons']=$this->yaskawa_model->account_details(); $table="masters"; $where=array('master_type_id'=>'13','delete_status'=>'ACTIVE'); $data['account_type']=$this->yaskawa_model->get_where_row($table,$where); $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count=0; foreach($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if($months=='11'){ $count+=1; } } $data['count']=$count; $this->load->view('admin/add_contact',$data); } else { redirect('/'); } } public function add_new_contact(){ $admin_id = $this->session->userdata('admin_id'); $role_id = $this->session->userdata('role_id'); $contact_owner = $this->input->post('contact_owner'); $lead_source = $this->input->post('lead_source'); // $name_type = $this->input->post('name_type'); $first_name = $this->input->post('first_name'); $last_name = $this->input->post('last_name'); $account_name = $this->input->post('account_name'); $title = $this->input->post('title'); $Email = $this->input->post('Email'); $department = $this->input->post('department'); $phone = $this->input->post('phone'); $home_phone = $this->input->post('home_phone'); $other_phone = $this->input->post('other_phone'); $fax = $this->input->post('fax'); $mobile = $this->input->post('mobile'); $originalDate = $this->input->post('DOB'); if(!empty($originalDate)){ $DOB = date("Y-m-d", strtotime($originalDate)); }else { $DOB = '00-00-0000'; } $assistant = $this->input->post('assistant'); $asst_phone = $this->input->post('asst_phone'); $report_to = $this->input->post('report_to'); $email_otp_out = $this->input->post('email_otp_out'); $skype_id = $this->input->post('skype_id'); $secondary_email = $this->input->post('secondary_email'); $twitter = $this->input->post('twitter'); $mailing_street = $this->input->post('mailing_street'); $other_street = $this->input->post('other_street'); $mailing_city = $this->input->post('mailing_city'); $other_city = $this->input->post('other_city'); $mailing_state = $this->input->post('mailing_state'); $other_state = $this->input->post('other_state'); $mailing_zip_code = $this->input->post('mailing_zip_code'); $other_zip_code = $this->input->post('other_zip_code'); $mailing_country = $this->input->post('mailing_country'); $other_country = $this->input->post('other_country'); $description = $this->input->post('description'); $aniversary_date = $this->input->post('aniversary_date'); $contact_type = $this->input->post('contact_type'); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $created_at = $date->format('Y-m-d'); $data=array( 'user_id' => $admin_id, 'role_id' => $role_id, 'contact_owner' => $contact_owner, 'lead_source' => $lead_source, // 'name_type' => $name_type, 'first_name' => $first_name, 'last_name' => $last_name, 'account_name' => $account_name, 'title' => $title, 'Email' => $Email, 'contact_type' => $contact_type, 'department' => $department, 'phone' => $phone, 'home_phone' => $home_phone, 'other_phone' => $other_phone, 'fax' => $fax, 'mobile' => $mobile, 'DOB' => $DOB, 'assistant' => $assistant, 'asst_phone' => $asst_phone, 'report_to' => $report_to, 'email_otp_out' => $email_otp_out, 'skype_id' => $skype_id, 'secondary_email' => $secondary_email, 'twitter' => $twitter, 'mailing_street' => $mailing_street, 'other_street' => $other_street, 'mailing_city' => $mailing_city, 'other_city' => $other_city, 'mailing_state' => $mailing_state, 'other_state' => $other_state, 'mailing_zip_code' => $mailing_zip_code, 'other_zip_code' => $other_zip_code, 'mailing_country' => $mailing_country, 'other_country' => $other_country, 'description' => $description, 'created_at' => $created_at, 'aniversary_date' => date('Y-m-d',strtotime($aniversary_date)), 'delete_status' => 'ACTIVE', ); $tbl='new_contact'; $condition1=array('Email' => $Email,'delete_status' => 'ACTIVE'); $condition2=array('mobile' => $mobile,'delete_status' => 'ACTIVE'); $details1=$this->yaskawa_model->get_where_row($tbl,$condition1); $details2=$this->yaskawa_model->get_where_row($tbl,$condition2); if(empty($details1)){ if(empty($details2)){ $result=$this->yaskawa_model->add_new_contact($data); $data1=array('contact_id'=>$account_name); $this->yaskawa_model->contact_data_to_account($account_name,$data1); echo json_encode(array('result'=>1,'message'=>"Lead added successfully")); }else { echo json_encode(array('result'=>0,'message'=>"Mobil number already exists")); } } else { echo json_encode(array('result'=>0,'message'=>"Email id already exists")); } } public function contact_info(){ $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $id = $this->uri->segment(2); $data['honorific']=$this->yaskawa_model->get_honorific(); $data['user_name']= $this->session->userdata('user_name'); $data['user_details']=$this->yaskawa_model->get_user_details1($id); $data['attachments']=$this->yaskawa_model->contact_attachments1($id); $data['lead_source']=$this->yaskawa_model->get_lead_source_details(); $data['closed_activities'] = $this->yaskawa_model->contact_closed_details($id); $data['notes_details'] = $this->yaskawa_model->get_contact_notes_details($id); $data['activities']=$this->yaskawa_model->contact_activities1($id); $data['contact_details'] = $this->yaskawa_model->single_contact_details($id); $data['contact_id']=$id; $data['company_details']=$this->yaskawa_model->fetch_company_details(); $table="masters"; $where=array('master_type_id'=>'13','delete_status'=>'ACTIVE'); $data['account_type']=$this->yaskawa_model->get_where_row($table,$where); $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count=0; foreach($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if($months=='11'){ $count+=1; } } $data['count']=$count; $this->load->view('admin/contact_info',$data); } else { redirect('/'); } } public function closed_contact() { $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $id = $this->uri->segment(2); $dat=array('delete_status'=>'CLOSE'); $this->yaskawa_model->contact_closed($id,$dat); $det=$this->yaskawa_model->get_row1($id); $contact_id=$det->contact_id; $data['honorific']=$this->yaskawa_model->get_honorific(); $data['user_name'] = $this->session->userdata('user_name'); $data['user_details']=$this->yaskawa_model->get_user_details1($id); $data['lead_source']=$this->yaskawa_model->get_lead_source_details(); $data['closed_activities'] = $this->yaskawa_model->contact_closed_details($contact_id); $data['attachments'] = $this->yaskawa_model->contact_attachments1($contact_id); $data['notes_details'] = $this->yaskawa_model->get_contact_notes_details($id); $data['activities'] = $this->yaskawa_model->contact_activities1($contact_id); $data['contact_details'] = $this->yaskawa_model->single_contact_details($contact_id); $data['company_details'] = $this->yaskawa_model->fetch_company_details(); $data['contact_id']=$id; $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count=0; foreach($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if($months=='11'){ $count+=1; } } $data['count']=$count; $this->load->view('admin/contact_info',$data); } else { redirect('/'); } } public function contact_list(){ $admin_id = $this->session->userdata('admin_id'); $role_id = $this->session->userdata('role_id'); if($admin_id) { $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $data['contact_data']=$this->yaskawa_model->contact_list($role_id); $data['company_details']=$this->yaskawa_model->fetch_company_details(); $data['contacts_lists']=$this->yaskawa_model->contacts_lists($role_id); $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count=0; foreach($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if($months=='11'){ $count+=1; } } $data['count']=$count; $this->load->view('admin/contact_list',$data); } else { redirect('/'); } } public function contact_details_update() { $cont_lids = $this->input->post('cont_lids'); $Contact_Owner = $this->input->post('Contact_Owner'); $Lead_Source = $this->input->post('Lead_Source'); $name_type = $this->input->post('name_type'); $first_name = $this->input->post('first_name'); $last_name = $this->input->post('last_name'); $account_name = $this->input->post('account_id'); $title = $this->input->post('title'); $Email = $this->input->post('Email'); $department = $this->input->post('department'); $phone = $this->input->post('phone'); $home_phone = $this->input->post('home_phone'); $other_phone = $this->input->post('other_phone'); $fax = $this->input->post('fax'); $mobile = $this->input->post('mobile'); $DOBs=$this->input->post('dob'); if(!empty($DOBs)){ $dob = date("Y-m-d", strtotime($DOBs)); }else { $dob ='0000-00-00'; } $Assistant = $this->input->post('Assistant'); $asst_phone = $this->input->post('asst_phone'); $report_to = $this->input->post('report_to'); $email_otp_out = $this->input->post('email_otp_out'); $skype_id = $this->input->post('skype_id'); $Secondary_email = $this->input->post('Secondary_email'); $twitter = $this->input->post('twitter'); $Mailing_Street = $this->input->post('Mailing_Street'); $Other_Street = $this->input->post('Other_Street'); $Mailing_City = $this->input->post('Mailing_City'); $Other_City = $this->input->post('Other_City'); $Mailing_State = $this->input->post('Mailing_State'); $Other_State = $this->input->post('Other_State'); $Mailing_Code = $this->input->post('Mailing_Code'); $Other_Code = $this->input->post('Other_Code'); $Mailing_Country = $this->input->post('Mailing_Country'); $Other_Country = $this->input->post('Other_Country'); $description = $this->input->post('description'); $aniversary_date = $this->input->post('aniversary_date'); $data=array( 'contact_owner' => $Contact_Owner, 'lead_source' => $Lead_Source, 'name_type' => $name_type, 'first_name' => $first_name, 'last_name' => $last_name, 'account_name' => $account_name, 'title' => $title, 'Email' => $Email, 'department' => $department, 'phone' => $phone, 'home_phone' => $home_phone, 'other_phone' => $other_phone, 'fax' => $fax, 'mobile' => $mobile, 'DOB' => $dob, 'assistant' => $Assistant, 'asst_phone' => $asst_phone, 'report_to' => $report_to, 'email_otp_out' => $email_otp_out, 'skype_id' => $skype_id, 'secondary_email' => $Secondary_email, 'twitter' => $twitter, 'mailing_street' => $Mailing_Street, 'other_street' => $Other_Street, 'mailing_city' => $Mailing_City, 'other_city' => $Other_City, 'mailing_state' => $Mailing_State, 'other_state' => $Other_State, 'aniversary_date' => date('Y-m-d',strtotime($aniversary_date)), 'mailing_zip_code' => $Mailing_Code, 'contact_type' => $this->input->post('contact_type'), 'other_zip_code' => $Other_Code, 'mailing_country' => $Mailing_Country, 'other_country' => $Other_Country, 'description' => $description, 'delete_status' => 'ACTIVE', ); $result = $this->yaskawa_model->contact_details_update($cont_lids,$data); if($result) { echo json_encode(array('result'=>1,'message'=>"added successfully")); } else { echo json_encode(array('result'=>0,'message'=>"Something went wrong.. try again")); } } public function potential_details_update() { $pot_lids = $this->input->post('pot_lids'); $Potential_Owner = $this->input->post('Potential_Owner'); $amount = $this->input->post('amount'); $email_id = $this->input->post('email_id'); //$potential_type = $this->input->post('potential_type'); $potential_name = $this->input->post('potential_name'); $close_date = $this->input->post("closing_date"); if(!empty($close_date)) { $close_date = new DateTime($this->input->post("closing_date")); $closing_date = $close_date->format('Y-m-d'); } else { $closing_date='0000-00-00'; } $account_name = $this->input->post('account_name'); $stage = $this->input->post('stage'); $type = $this->input->post('type'); $probability = $this->input->post('probability'); $next_step = $this->input->post('next_step'); $expected_revenue = $this->input->post('expected_revenue'); $lead_source_name = $this->input->post('lead_source_name'); $campaign_source = $this->input->post('campaign_source'); $contact_name = $this->input->post('contact_name'); $description = $this->input->post('description'); $sec_email_id = $this->input->post('sec_email_id'); $fax = $this->input->post('fax'); $designation = $this->input->post('designation'); $website = $this->input->post('website'); $otp = $this->input->post('email_otp'); if($otp=='on') { $email_otp='YES'; } else { $email_otp='NO'; } $lead_status = $this->input->post('lead_status'); $industry = $this->input->post('industry'); $no_of_employees = $this->input->post('no_of_employees'); $annual_revenue = $this->input->post('annual_revenue'); $ratings = $this->input->post('ratings'); $skype_id = $this->input->post('skype_id'); $street = $this->input->post('street'); $city = $this->input->post('city'); $state = $this->input->post('state'); $zip_code = $this->input->post('zip_code'); $country = $this->input->post('country'); $service_name = $this->input->post('service_name'); $service_date = $this->input->post('service_date'); $service_amount = $this->input->post('service_amount'); if(!empty($service_name)){ $service_names=json_encode($service_name); }else { $service_names=''; } if(!empty($service_amount)){ $service_amounts=json_encode($service_amount); }else { $service_amounts=''; } if(!empty($service_date)){ $service_dates=json_encode($service_date); }else { $service_dates=''; } $data=array( 'potential_owner' => $Potential_Owner, 'address' =>$this->input->post('address'), 'phone_number'=>$this->input->post('contact_number'), 'email_id' =>$email_id, 'amount' => $amount, //'potential_type' => $potential_type, 'potential_name' => $potential_name, 'closing_date' => $closing_date, 'account_name' => $account_name, 'stage' => $stage, 'type' => $type, 'probability' => $probability, 'next_step' => $next_step, 'expected_revenue' => $expected_revenue, 'lead_source' => $lead_source_name, 'campaign_source' => $campaign_source, 'contact_name' => $contact_name, 'description' => $description, 'sec_email' => $sec_email_id, 'fax' => $fax, 'designation' => $designation, 'website' => $website, 'email_otp' => $email_otp, //'lead_status' => $lead_status, 'potential_status' => $lead_status, 'industry' => $industry, 'no_of_employees' => $no_of_employees, 'annual_revenue' => $annual_revenue, 'ratings' => $ratings, 'skype_id' => $skype_id, 'street' => $street, 'city' => $city, 'state' => $state, 'zip_code' => $zip_code, 'country' => $country, 'service_amount' => $service_amounts, 'service_date' => $service_dates, 'service_name' => $service_names, 'delete_status' => 'ACTIVE', ); $result = $this->yaskawa_model->potential_details_update($pot_lids,$data); if($result) { echo json_encode(array('result'=>1,'message'=>"added successfully")); } else { echo json_encode(array('result'=>0,'message'=>"Something went wrong.. try again")); } } public function contact_attach_file(){ $contact_id = $this->input->post('contact_id'); $attach_file = $this->input->post('attach_file'); $this->load->library('image_lib'); $file_name = ""; if($_FILES) { if(empty($_FILES['attach_file']['name'])) { $file_name = ""; } else { $target='attach_file/'; $target.=time().$_FILES['attach_file']['name']; $file_name=time().$_FILES['attach_file']['name']; $image=$target; move_uploaded_file($_FILES['attach_file']['tmp_name'],$target); $config['source_image']=$target; $config['maintain_ratio']=TRUE; // $config['width']=1280; // $config['height']=960; $this->image_lib->initialize($config); //$this->image_lib->resize(); } } $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $created_at = $date->format('Y-m-d H:i:s'); $data=array( "contact_id" => $contact_id, "type" => "Attached File", "attach_file" => $file_name, "delete_status" => "ACTIVE", "created_at" => $created_at, ); $result=$this->yaskawa_model->contact_attachments($data); if($result){ echo json_encode(array('result'=>1,'message'=>"added successfully")); } else { echo json_encode(array('result'=>0,'message'=>"Something went wrong.. try again")); } } public function contact_attach_url(){ $contact_id = $this->input->post('contact_id'); $enter_url = $this->input->post('enter_url'); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $created_at = $date->format('Y-m-d H:i:s'); $data=array( "contact_id" => $contact_id, "type" => "Link URL", "link_url" => $enter_url, "delete_status" => "ACTIVE", "created_at" => $created_at, ); $result=$this->yaskawa_model->contact_attachments($data); if($result){ echo json_encode(array('result'=>1,'message'=>"added successfully")); } else { echo json_encode(array('result'=>0,'message'=>"Something went wrong.. try again")); } } public function contact_newtask(){ $contact_id = $this->input->post('contact_id'); $subject = $this->input->post('subject'); $due_date = date("Y-m-d", strtotime($this->input->post('due_date'))); $priority = $this->input->post('priority'); $owner = $this->input->post('owner'); $status = $this->input->post('status'); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $created_at = $date->format('Y-m-d H:i:s'); $data=array( "contact_id" => $contact_id, "type" => "Task", "subject" => $subject, "due_date" => $due_date, "priority" => $priority, "owner" => $owner, "status" => $status, "created_at" => $created_at, ); $result=$this->yaskawa_model->contact_activities($data); if($result){ echo json_encode(array('result'=>1,'message'=>"added successfully")); } else { echo json_encode(array('result'=>0,'message'=>"Something went wrong.. try again")); } } public function contact_newevents() { $contact_id = $this->input->post('contact_id'); $all_day = $this->input->post('all_day'); $from_date = date("Y-m-d", strtotime($this->input->post('from_date'))); $to_date = date("Y-m-d", strtotime($this->input->post('to_date'))); $host = $this->input->post('host'); $participants = $this->input->post('participants'); $related_to = $this->input->post('related_to'); $lead = $this->input->post('lead'); $description = $this->input->post('description'); $lead_id = $this->input->post('lead_id'); if(!empty($all_day)) { $all_days=$all_day; }else { $all_days=''; } $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $created_at = $date->format('Y-m-d'); $event_details = array( 'contact_id' => $contact_id, 'type' => 'Event', 'all_day' => $all_days, 'start_date' => $from_date, 'end_date' => $to_date, 'host' => $host, 'participants' => $participants, 'related_to' => $related_to, 'lead' => $lead, 'description' => $description, 'delete_status' => 'ACTIVE', 'created_at' => $created_at ); $result = $this->yaskawa_model->contact_activities($event_details); if($result) { echo json_encode(array('result'=>1,'message'=>"Attachments added successfully")); } else { echo json_encode(array('result'=>0,'message'=>"Something went wrong.. try again")); } } public function contact_createcall() { $contact_id = $this->input->post('contact_id'); $subject = $this->input->post('subject'); $call_type = $this->input->post('call_type'); $call_purpose = $this->input->post('call_purpose'); $contact_name = $this->input->post('contact_name'); $call_details = $this->input->post('call_details'); $call_timer = $this->input->post('call_timer'); $call_duration = $this->input->post('call_duration'); $description = $this->input->post('description'); $call_result = $this->input->post('call_result'); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $created_at = $date->format('Y-m-d'); $event_details = array( 'contact_id' => $contact_id, 'type' => 'Call', 'subject' => $subject, 'call_type' => $call_type, 'call_purpose' => $call_purpose, 'contact_name' => $contact_name, 'call_details' => $call_details, 'call_timer' => $call_timer, 'call_duration' => $call_duration, 'description' => $description, 'call_result' => $call_result, 'delete_status' => 'ACTIVE', 'created_at' => $created_at ); $result = $this->yaskawa_model->contact_activities($event_details); if($result) { echo json_encode(array('result'=>1,'message'=>"Attachments added successfully")); } else { echo json_encode(array('result'=>0,'message'=>"Something went wrong.. try again")); } } public function potential_info(){ $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $id = $this->uri->segment(2); $data['honorific']=$this->yaskawa_model->get_honorific(); $data['user_name']= $this->session->userdata('user_name'); $data['contact_data']=$this->yaskawa_model->contact_list1_potentials($id); $data['user_details']=$this->yaskawa_model->get_user_details3($id); $data['honorific']=$this->yaskawa_model->get_honorific(); $data['stage_history']=$this->yaskawa_model->stage_master_update1($id); $data['competitor']=$this->yaskawa_model->potential_competitor1($id); $data['lead_source']=$this->yaskawa_model->get_lead_source_details(); $data['activities']=$this->yaskawa_model->potential_activities1($id); $data['attachments']=$this->yaskawa_model->potential_attachments1($id); $data['potential_details'] = $this->yaskawa_model->single_potential_details_potential($id); $data['notes_details'] = $this->yaskawa_model->get_potentails_notes_details($id); $data['closed_activities'] = $this->yaskawa_model->potential_closed_details($id); $data['company_details']=$this->yaskawa_model->fetch_company_details(); $data['quotation_details'] = $this->yaskawa_model->get_quotation_amount_details_potential($id); $data['converted_status'] = $this->yaskawa_model->get_converted_status_new($id); $data['account_persons']=$this->yaskawa_model->account_details(); $data['status_details']=$this->yaskawa_model->get_lead_status_details(); $data['lead_ratings']=$this->yaskawa_model->get_lead_ratings_details(); $data['industry_details']=$this->yaskawa_model->get_lead_industry_details(); $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count=0; foreach($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if($months=='11'){ $count+=1; } } $data['count']=$count; $this->load->view('admin/potential_info',$data); } else { redirect('/'); } } public function closed_potential(){ $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $id = $this->uri->segment(2); $id2 = $this->uri->segment(3); $dat = array('activity'=>'CLOSE'); $this->yaskawa_model->potential_closed($id2,$dat); $det=$this->yaskawa_model->get_row2($id); $potential_id=$det->lead_id; $data['honorific']=$this->yaskawa_model->get_honorific(); $data['user_name']= $this->session->userdata('user_name'); $data['contact_data']=$this->yaskawa_model->contact_list1($potential_id); $data['user_details']=$this->yaskawa_model->get_user_details3($id); $data['stage_history']=$this->yaskawa_model->stage_master_update1($potential_id); $data['lead_source']=$this->yaskawa_model->get_lead_source_details(); $data['competitor']=$this->yaskawa_model->potential_competitor1($potential_id); $data['activities']=$this->yaskawa_model->potential_activities1($potential_id); $data['attachments']=$this->yaskawa_model->potential_attachments1($potential_id); $data['notes_details'] = $this->yaskawa_model->get_potentails_notes_details($id); $data['potential_details'] = $this->yaskawa_model->single_potential_details_potential($potential_id); $data['closed_activities'] = $this->yaskawa_model->potential_closed_details($potential_id); $data['quotation_details'] = $this->yaskawa_model->get_quotation_details_potential($id); $data['converted_status'] = $this->yaskawa_model->get_converted_status_new($id); $data['company_details']=$this->yaskawa_model->fetch_company_details(); $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count=0; foreach($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if($months=='11'){ $count+=1; } } $data['count']=$count; $this->load->view('admin/potential_info',$data); } else { redirect('/'); } } public function potential_attach_file(){ $potential_id = $this->input->post('potential_id'); $attach_file = $this->input->post('attach_file'); $this->load->library('image_lib'); $file_name = ""; if($_FILES) { if(empty($_FILES['attach_file']['name'])) { $file_name = ""; } else { $target='attach_file/'; $target.=time().$_FILES['attach_file']['name']; $file_name=time().$_FILES['attach_file']['name']; $image=$target; move_uploaded_file($_FILES['attach_file']['tmp_name'],$target); $config['source_image']=$target; $config['maintain_ratio']=TRUE; // $config['width']=1280; // $config['height']=960; $this->image_lib->initialize($config); //$this->image_lib->resize(); } } $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $created_at = $date->format('Y-m-d H:i:s'); $data=array( "potential_id" => $potential_id, "type" => "Attached File", "attach_file" => $file_name, "activity" => 'FILE', "delete_status" => "ACTIVE", "created_at" => $created_at, ); $result=$this->yaskawa_model->potential_attachments($data); if($result){ echo json_encode(array('result'=>1,'message'=>"added successfully")); } else { echo json_encode(array('result'=>0,'message'=>"Something went wrong.. try again")); } } public function potential_attach_url(){ $potential_id = $this->input->post('potential_id'); $enter_url = $this->input->post('enter_url'); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $created_at = $date->format('Y-m-d H:i:s'); $data=array( "potential_id" => $potential_id, "type" => "Link URL", "link_url" => $enter_url, "activity" => "URL", "delete_status" => "ACTIVE", "created_at" => $created_at, ); $result=$this->yaskawa_model->potential_attachments($data); if($result){ echo json_encode(array('result'=>1,'message'=>"added successfully")); } else { echo json_encode(array('result'=>0,'message'=>"Something went wrong.. try again")); } } public function potential_newtask(){ $potential_id = $this->input->post('potential_id'); $subject = $this->input->post('subject'); $due_date = date("Y-m-d", strtotime($this->input->post('due_date'))); $priority = $this->input->post('priority'); $owner = $this->input->post('owner'); $status = $this->input->post('status'); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $created_at = $date->format('Y-m-d H:i:s'); $data=array( "lead_id" => $potential_id, "type" => "Task", "subject" => $subject, "due_date" => $due_date, "priority" => $priority, "owner" => $owner, "status" => $status, "activity" => "OPEN", "delete_status" => "ACTIVE", "created_at" => $created_at, "details_from"=>"Potential", ); $result=$this->yaskawa_model->potential_activities($data); if($result){ echo json_encode(array('result'=>1,'message'=>"added successfully")); } else { echo json_encode(array('result'=>0,'message'=>"Something went wrong.. try again")); } } public function potential_newevents() { $potential_id = $this->input->post('potential_id'); $all_day = $this->input->post('all_day'); $from_date = date("Y-m-d", strtotime($this->input->post('from_date'))); $to_date = date("Y-m-d", strtotime($this->input->post('to_date'))); $host = $this->input->post('host'); $participants = $this->input->post('participants'); $related_to = $this->input->post('related_to'); $lead = $this->input->post('lead'); $description = $this->input->post('description'); $lead_id = $this->input->post('lead_id'); $event_name = $this->input->post('event'); if(!empty($all_day)) { $all_days=$all_day; }else { $all_days=''; } $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $created_at = $date->format('Y-m-d'); $event_details = array( 'event_name'=>$event_name, 'lead_id' => $potential_id, 'type' => 'Event', 'all_day' => $all_days, 'start_date' => $from_date, 'end_date' => $to_date, 'host' => $host, 'participants' => $participants, 'related_to' => $related_to, 'lead' => $lead, 'description' => $description, 'activity' => 'OPEN', 'delete_status' => 'ACTIVE', 'created_at' => $created_at, "details_from"=>"Potential", ); $result = $this->yaskawa_model->potential_activities($event_details); if($result) { echo json_encode(array('result'=>1,'message'=>"Attachments added successfully")); } else { echo json_encode(array('result'=>0,'message'=>"Something went wrong.. try again")); } } public function potetial_createcall() { $potential_id = $this->input->post('potential_id'); $subject = $this->input->post('subject'); $call_type = $this->input->post('call_type'); $call_purpose = $this->input->post('call_purpose'); $contact_name = $this->input->post('contact_name'); $call_details = $this->input->post('call_details'); $call_timer = $this->input->post('call_timer'); $call_duration = $this->input->post('call_duration'); $description = $this->input->post('description'); $call_result = $this->input->post('call_result'); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $created_at = $date->format('Y-m-d'); $event_details = array( 'lead_id' => $potential_id, 'type' => 'Call', 'subject' => $subject, 'call_type' => $call_type, 'call_purpose' => $call_purpose, 'contact_name' => $contact_name, 'call_details' => $call_details, 'call_timer' => $call_timer, 'call_duration' => $call_duration, 'description' => $description, 'call_result' => $call_result, 'activity' => 'OPEN', 'delete_status' => 'ACTIVE', 'created_at' => $created_at, "details_from"=>"Potential", ); $result = $this->yaskawa_model->potential_activities($event_details); if($result) { echo json_encode(array('result'=>1,'message'=>"Attachments added successfully")); } else { echo json_encode(array('result'=>0,'message'=>"Something went wrong.. try again")); } } public function create_competitor() { $potential_id = $this->input->post('potential_id'); $competitor_name = $this->input->post('competitor_name'); $Website = $this->input->post('Website'); $Strengths = $this->input->post('Strengths'); $Weaknesses = $this->input->post('Weaknesses'); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $created_at = $date->format('Y-m-d'); $competitor = array( 'potential_id' => $potential_id, 'competitor_name' => $competitor_name, 'Website' => $Website, 'Strengths' => $Strengths, 'Weaknesses' => $Weaknesses, 'delete_status' => 'ACTIVE', 'created_at' => $created_at ); $result = $this->yaskawa_model->potential_competitor($competitor); if($result) { echo json_encode(array('result'=>1,'message'=>"Attachments added successfully")); } else { echo json_encode(array('result'=>0,'message'=>"Something went wrong.. try again")); } } public function potential_contact_mapping(){ $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $id = $this->uri->segment(2); $data['user_name']= $this->session->userdata('user_name'); $data['contact']=$this->yaskawa_model->quick_contact1($id); $data['potential_details'] = $this->yaskawa_model->single_potential_details($id); $data['accounts_data'] = $this->yaskawa_model->select_new_accounts($admin_id); // $data['lead_source']=$this->yaskawa_model->get_lead_source_details(); // $data['potential_details'] = $this->yaskawa_model->single_potential_details($id); $data['company_details']=$this->yaskawa_model->fetch_company_details(); $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count=0; foreach($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if($months=='11'){ $count+=1; } } $data['count']=$count; $this->load->view('admin/potential_contact_mapping',$data); } else { redirect('/'); } } public function quick_contact(){ $admin_id = $this->session->userdata('admin_id'); $role_id = $this->session->userdata('role_id'); $potential_id = $this->input->post('potential_id'); $contact_owner = $this->input->post('potential_owner'); $first_name = $this->input->post('first_name'); $last_name = $this->input->post('last_name'); $account_id = $this->input->post('account_id'); $account_name = $this->input->post('account_name'); $email = $this->input->post('email'); $phone = $this->input->post('phone'); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $created_at = $date->format('Y-m-d'); $quick_contact = array( 'user_id' => $admin_id, 'role_id' => $role_id, 'potential_id' => $potential_id, 'contact_owner' => $contact_owner, 'first_name' => $first_name, 'last_name' => $last_name, 'account_id' => $account_id, 'account_name' => $account_name, 'email' => $email, 'phone' => $phone, 'delete_status' => 'ACTIVE', 'created_at' => $created_at ); $result = $this->yaskawa_model->add_new_contact($quick_contact); if($result) { echo json_encode(array('result'=>1,'message'=>"Attachments added successfully")); } else { echo json_encode(array('result'=>0,'message'=>"Something went wrong.. try again")); } } public function mapping_details(){ $account_id=$this->input->post('account_id'); $user_data=$this->yaskawa_model->single_account_details($account_id); echo json_encode($user_data); } public function contact_update(){ $account_id=$this->input->post('account_id'); $contact_roles=$this->input->post('contact_roles'); $data=array('contact_roles'=>$contact_roles); $result=$this->yaskawa_model->contact_update($account_id, $data); if($result) { echo json_encode(array('result'=>1,'message'=>"Attachments added successfully")); } else { echo json_encode(array('result'=>0,'message'=>"Something went wrong.. try again")); } } public function potential_contact_edit_mapping(){ $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $id = $this->uri->segment(2); $data['user_name']= $this->session->userdata('user_name'); $data['quick_contact'] = $this->yaskawa_model->quick_contact2($id); $data['potential_details'] = $this->yaskawa_model->single_potential_details($id); // $data['lead_source']=$this->yaskawa_model->get_lead_source_details(); $data['company_details']=$this->yaskawa_model->fetch_company_details(); $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count=0; foreach($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if($months=='11'){ $count+=1; } } $data['count']=$count; $this->load->view('admin/potential_contact_edit_mapping',$data); } else { redirect('/'); } } public function potential_search(){ $search=$this->input->post('search'); $search=$this->yaskawa_model->potential_search($search); if($search) { echo json_encode(array('search_data'=>$search,'result'=>1)); } else { echo json_encode(array('search_data'=>$search,'result'=>0)); } } public function back_potential_info(){ $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $id = $this->uri->segment(2); $data['user_name']= $this->session->userdata('user_name'); $data['contact']=$this->yaskawa_model->quick_contact1($id); $data['user_details']=$this->yaskawa_model->get_user_details(); $data['contact_data']=$this->yaskawa_model->contact_list1($id); $data['competitor']=$this->yaskawa_model->potential_competitor1($id); $data['lead_source']=$this->yaskawa_model->get_lead_source_details(); $data['activities']=$this->yaskawa_model->potential_activities1($id); $data['attachments']=$this->yaskawa_model->potential_attachments1($id); $data['stage_history']=$this->yaskawa_model->stage_master_update1($id); $data['potential_details'] = $this->yaskawa_model->single_potential_details_potential($id); $data['closed_activities'] = $this->yaskawa_model->potential_closed_details($id); $data['notes_details'] = $this->yaskawa_model->get_potentails_notes_details($id); $data['company_details']=$this->yaskawa_model->fetch_company_details(); $data['quotation_details'] = $this->yaskawa_model->get_quotation_details_potential($id); $data['converted_status'] = $this->yaskawa_model->get_converted_status_new($id); $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count=0; foreach($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if($months=='11'){ $count+=1; } } $data['count']=$count; $this->load->view('admin/potential_info',$data); } public function quick_create_contact(){ $pot_lids = $this->input->post('pot_lids'); $camount = $this->input->post('camount'); $closing_date = $this->input->post('closing_date'); $originalDate = $closing_date; $newDate = date("Y-m-d", strtotime($originalDate)); $reason_for_loss = $this->input->post('reason_for_loss'); $data = array( 'potential_id' => $pot_lids, 'amount' => $camount, 'closing_date' => $newDate, 'reason' => $reason_for_loss, 'delete_status' => 'ACTIVE' ); $result = $this->yaskawa_model->potential_details_update($pot_lids,$data); if($result) { echo json_encode(array('result'=>1,'message'=>"Update Successfully")); } else { echo json_encode(array('result'=>0,'message'=>"Something went wrong.. try again")); } } public function update_edit_mapping(){ $contactids=$this->input->post('contactids'); $contact_roles=$this->input->post('contact_roles'); $result = $this->yaskawa_model->update_edit_mapping($contactids,$contact_roles); } public function auto_complete_account_name(){ $keyword=$this->input->get('term'); $data1=$this->yaskawa_model->account_name_search($keyword); foreach($data1 as $row) { $data[]=$row->account_name; } echo json_encode($data); } public function stage_master_update(){ $potential_id=$this->input->post('pot_lids'); $Potential_Owner=$this->input->post('Potential_Owner'); $stage=$this->input->post('stage'); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $modified_time = $date->format('Y-m-d H:i:s'); $data=array( 'potential_id'=>$potential_id, 'stage'=>$stage, 'modified_by'=>$Potential_Owner, 'modified_time'=>$modified_time, ); $data1=array( 'stage'=>$stage, ); $result=$this->yaskawa_model->potential_details_update($potential_id,$data1); $result=$this->yaskawa_model->stage_master_update($data); if($result) { echo json_encode(array('result'=>1,'message'=>"Update Successfully")); } else { echo json_encode(array('result'=>0,'message'=>"Something went wrong.. try again")); } } public function get_role_details(){ $role=$this->input->post('role'); $result=$this->yaskawa_model->get_role_details($role); echo json_encode($result); } public function other_account(){ $admin_id = $this->session->userdata('admin_id'); $role_id = $this->session->userdata('role_id'); if($admin_id) { $data['roles_list_admin'] = $this->yaskawa_model->get_all_roles_admin(); $data['company_details']=$this->yaskawa_model->fetch_company_details(); $data['quotations']=$this->yaskawa_model->individual_sales($admin_id); $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count=0; foreach($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if($months=='11'){ $count+=1; } } $data['count']=$count; $this->load->view('admin/other_account',$data); } else { redirect('/'); } } public function sales_pipeline_and_trend(){ $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $data['accounts_data'] = $this->yaskawa_model->select_new_accounts1(); $data['company_details']=$this->yaskawa_model->fetch_company_details(); $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count=0; foreach($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if($months=='11'){ $count+=1; } } $data['count']=$count; $this->load->view('admin/sales_pipeline_and_trend',$data); } else { redirect('/'); } } public function industry_wise_sales(){ $admin_id = $this->session->userdata('admin_id'); $role_id = $this->session->userdata('role_id'); if($admin_id) { $data['industry_details']=$this->yaskawa_model->get_lead_industry_details(); $data['company_details']=$this->yaskawa_model->fetch_company_details(); $data['industry_wise_sales']=$this->yaskawa_model->industry_wise_sales($role_id); $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count=0; foreach($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if($months=='11'){ $count+=1; } } $data['count']=$count; $this->load->view('admin/industry_wise_sales',$data); } else { redirect('/'); } } public function region_wise_sales(){ $admin_id = $this->session->userdata('admin_id'); $role_id = $this->session->userdata('role_id'); if($admin_id) { $data['get_all_roles_region'] = $this->yaskawa_model->get_all_roles_region(); $data['company_details']=$this->yaskawa_model->fetch_company_details(); $data['region_wise_sales']=$this->yaskawa_model->region_wise_sales($role_id); $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count=0; foreach($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if($months=='11'){ $count+=1; } } $data['count']=$count; $this->load->view('admin/region_wise_sales',$data); } else { redirect('/'); } } public function model_wise_sales(){ $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $data['company_details']=$this->yaskawa_model->fetch_company_details(); $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count=0; foreach($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if($months=='11'){ $count+=1; } } $data['count']=$count; $this->load->view('admin/model_wise_sales',$data); } else { redirect('/'); } } public function industry_wise_filter(){ $admin_id = $this->session->userdata('admin_id'); $role_id = $this->session->userdata('role_id'); $indistry_name = $this->input->post('indistry_name'); $from_date = date("Y-m-d", strtotime($this->input->post('from_date'))); $to_date = date("Y-m-d", strtotime($this->input->post('to_date'))); $result=$this->yaskawa_model->industry_wise_filter($role_id,$indistry_name,$from_date,$to_date); if($result) { echo json_encode(array('date_result'=>$result,'result'=>1)); } else { echo json_encode(array('date_result'=>$result,'result'=>0)); } } public function region_wise_filter(){ $admin_id = $this->session->userdata('admin_id'); $role_id = $this->session->userdata('role_id'); $region_wise = $this->input->post('region_wise'); $from_date = date("Y-m-d", strtotime($this->input->post('from_date'))); $to_date = date("Y-m-d", strtotime($this->input->post('to_date'))); $result=$this->yaskawa_model->region_wise_filter($region_wise,$from_date,$to_date); if($result) { echo json_encode(array('date_result'=>$result,'result'=>1)); } else { echo json_encode(array('date_result'=>$result,'result'=>0)); } } public function individual_sales_filter(){ $admin_id = $this->session->userdata('admin_id'); $role_id = $this->session->userdata('role_id'); $member = $this->input->post('member'); $from_date = date("Y-m-d", strtotime($this->input->post('from_date'))); $to_date = date("Y-m-d", strtotime($this->input->post('to_date'))); $result=$this->yaskawa_model->individual_sales_filter($member,$from_date,$to_date); if($result) { echo json_encode(array('date_result'=>$result,'result'=>1)); } else { echo json_encode(array('date_result'=>$result,'result'=>0)); } } public function employee_activity(){ $admin_id = $this->session->userdata('admin_id'); $role_id = $this->session->userdata('role_id'); if($admin_id) { $data['company_details']=$this->yaskawa_model->fetch_company_details(); $data['number_of_users']=$this->yaskawa_model->number_of_users(); $data['lead_employees']=$this->yaskawa_model->lead_employees(); $data['account_employees']=$this->yaskawa_model->account_employees(); $data['potential_employees']=$this->yaskawa_model->potential_employees(); $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count=0; foreach($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if($months=='11'){ $count+=1; } } $data['count']=$count; $this->load->view('admin/employee_activity',$data); } else { redirect('/'); } } public function employee_lead_filter(){ $employee_id = $this->input->post('employee_id'); $result = $this->yaskawa_model->employee_lead_filter($employee_id); if($result) { echo json_encode(array('date_result'=>$result,'result'=>1)); } else { echo json_encode(array('date_result'=>$result,'result'=>0)); } } public function employee_account_filter(){ $employee_id = $this->input->post('employee_id'); $result = $this->yaskawa_model->employee_account_filter($employee_id); if($result) { echo json_encode(array('date_result'=>$result,'result'=>1)); } else { echo json_encode(array('date_result'=>$result,'result'=>0)); } } public function employee_potential_filter(){ $employee_id = $this->input->post('employee_id'); $result = $this->yaskawa_model->employee_potential_filter($employee_id); if($result) { echo json_encode(array('date_result'=>$result,'result'=>1)); } else { echo json_encode(array('date_result'=>$result,'result'=>0)); } } public function employee_activity_filter1(){ $from_date = date("Y-m-d", strtotime($this->input->post('from_date'))); $to_date = date("Y-m-d", strtotime($this->input->post('to_date'))); $result=$this->yaskawa_model->employee_activity_filter1($from_date,$to_date); if($result) { echo json_encode(array('date_result'=>$result,'result'=>1)); } else { echo json_encode(array('date_result'=>$result,'result'=>0)); } } public function employee_activity_filter2(){ $from_date = date("Y-m-d", strtotime($this->input->post('from_date'))); $to_date = date("Y-m-d", strtotime($this->input->post('to_date'))); $result=$this->yaskawa_model->employee_activity_filter2($from_date,$to_date); if($result) { echo json_encode(array('date_result1'=>$result,'result'=>2)); } else { echo json_encode(array('date_result1'=>$result,'result'=>0)); } } public function employee_activity_filter3(){ $from_date = date("Y-m-d", strtotime($this->input->post('from_date'))); $to_date = date("Y-m-d", strtotime($this->input->post('to_date'))); $result=$this->yaskawa_model->employee_activity_filter3($from_date,$to_date); if($result) { echo json_encode(array('date_result3'=>$result,'result'=>3)); } else { echo json_encode(array('date_result3'=>$result,'result'=>0)); } } public function role_wise_filter(){ $role_id = $this->input->post('role_id'); $result=$this->yaskawa_model->role_wise_filter($role_id); echo json_encode(array('date_result'=>$result,'result'=>1)); } public function employee_wise_filter(){ $userid = $this->input->post('userid'); $result=$this->yaskawa_model->employee_wise_filter($userid); if($result){ echo json_encode(array('date_result1'=>$result,'result'=>1)); }else{ echo json_encode(array('date_result1'=>$result,'result'=>0)); } } public function autocompletesearch(){ $keyword=$_GET['term']; $data1=$this->yaskawa_model->autocompletesearch($keyword); foreach($data1 as $row) { $data[]=$row->first_name; } echo json_encode($data); } public function convert_lead_to_potential_status() { $lead_id = $this->input->post('id'); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $created_at = $date->format('Y-m-d'); $data = array('lead_convert'=>'PCONVERTED','converted_at'=>$created_at); $table='leads'; $where=array('lead_id'=>$lead_id); $this->yaskawa_model->update($where,$table,$data); $tables='account_attach_notes'; $datas=array('notes_from'=>'Potential'); $this->yaskawa_model->update($where,$tables,$datas); $table='leads'; $where=array('lead_id'=>$lead_id); $details=$this->yaskawa_model->get_where_row($table,$where); $detail=$this->yaskawa_model->get_row_by_desc($lead_id); $close=''; if(!empty($detail->lead_notes)){ $description=$detail->lead_notes; }else { $description=$details->description; } $street=$details->street.' '.$details->city.' '.$details->state.' '.$details->country.' '.$details->zip_code; $data=array( 'user_id' => $details->user_id, 'role_id' => $details->role_id, 'potential_owner' => $details->lead_owner, 'potential_name' => $details->first_name, 'lead_source' => $details->lead_source, 'phone_number' => $details->mobile, 'email_id' => $details->email, 'description' => $description, 'service_name'=>$details->service_name, 'service_date'=>$details->service_date, 'service_amount'=>$details->service_amount, 'address' => $street, 'contact_name'=>$details->Cperson, 'designation' =>$details->lead_title, 'fax'=>$details->fax, 'website'=>$details->website, 'street'=>$details->street, 'city'=>$details->city, 'state'=>$details->state, 'country'=>$details->country, 'zip_code'=>$details->zip_code, 'potential_status'=>$details->lead_status, 'no_of_employees'=>$details->no_of_employees, 'industry'=>$details->industry, 'email_otp'=>$details->email_otp, 'delete_status' => 'ACTIVE', 'closing_date' => $close, 'ratings'=>$details->ratings, 'skype_id'=>$details->skype_id, 'annual_revenue'=>$details->annual_revenue, 'sec_email'=>$details->sec_email, ); $result=$this->yaskawa_model->add_new_potential($data); if($result) { $where1=array('lead_id'=>$lead_id,'type'=>'Task'); $where2=array('lead_id'=>$lead_id,'type'=>'Event'); $where3=array('lead_id'=>$lead_id,'type'=>'Call'); $data1=array('details_from'=>'Potential','lead_id'=>$result); $tableg='lead_new_tasks'; $get_activity=$this->yaskawa_model->update($where1,$tableg,$data1); $where2=array('lead_id'=>$lead_id,'type'=>'Event'); $get_event=$this->yaskawa_model->update($where2,$tableg,$data1); $where3=array('lead_id'=>$lead_id,'type'=>'Call'); $get_call=$this->yaskawa_model->update($where3,$tableg,$data1); $wheres=array('lead_id'=>$lead_id); $tables='account_attach_notes'; $datas=array('notes_from'=>'Potential','lead_id'=>$result); $this->yaskawa_model->update($wheres,$tables,$datas); $table="quotations"; $dat=array('potential_id'=>$result,'quatetion_from'=>'Potential','lead_id'=>0); $con=array('lead_id'=>$lead_id); $update_quatetion=$this->yaskawa_model->update($con,$table,$dat); /*$data=array( 'lead_id'=>$result, 'potential_notes'=>$description, 'created_by' =>$this->session->userdata('admin_id') ); $r=$this->yaskawa_model->add_data($table1,$data);*/ $table='leads'; $where=array('lead_id'=>$lead_id); $data=array('delete_status'=>'INACTIVE','converted_next_level'=>'PCONVERT'); $res=$this->yaskawa_model->update($where,$table,$data); $r=1; echo json_encode(array('result'=>1,'message'=>'Added Successfully')); } else { $r=0; echo json_encode(array('result'=>0,'message'=>'Added Successfully')); } } //lead_module view // public function assets_creation() // { // $admin_id = $this->session->userdata('admin_id'); // if($admin_id) // { // $data['user_type_id'] = $this->access_id(); // $data['access'] = $this->access_details(); // $data['company_details']=$this->yaskawa_model->fetch_company_details(); // $this->load->view('admin/add_assets',$data); // } // else // { // redirect('/'); // } // } public function create_assets(){ $domain_name = $this->input->post('domain'); $domain_link = $this->input->post('domain_link'); $user_name = $this->input->post('username'); $password = $this->input->post('password'); $gate_way_name = $this->input->post('gate_way'); $g_username = $this->input->post('g_username'); $g_password = $this->input->post('g_password'); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $created_at = $date->format('Y-m-d'); $quick_contact = array( 'domain_name' => $domain_name, 'domain_username' => $user_name, 'domain_link' => $domain_link, 'd_password' => $password, 'gate_way' => $gate_way_name, 'g_username' => $g_username, 'g_password' => $g_password, 'delete_status' => 'ACTIVE', 'created_at' => $created_at ); $result = $this->yaskawa_model->add_assets($quick_contact); if($result) { echo json_encode(array('result'=>1,'message'=>"Assets added successfully")); } else { echo json_encode(array('result'=>0,'message'=>"Something went wrong.. try again")); } } public function assets_list(){ $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $data['company_details']=$this->yaskawa_model->fetch_company_details(); $data['asset_detail']=$this->yaskawa_model->fetch_assets_details(); $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count=0; foreach($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if($months=='11'){ $count+=1; } } $data['count']=$count; $this->load->view('admin/assets_list',$data); } else { redirect('/'); } } public function delete_assets(){ $assets_id = $this->input->post('assets_id'); $table="assets"; $data=array('delete_status'=>'INACTIVE'); $result=$this->yaskawa_model->delete_assets($assets_id,$data); echo json_encode(array('res'=>$result)); } public function edit_assets(){ $admin_id = $this->session->userdata('admin_id'); $a_id=$this->uri->segment(2); if($admin_id) { $a_id=urlencode(base64_decode($a_id)); $a_id=explode("%",$a_id); $a_id=$a_id[0]; $table="assets"; $where=array('assets_id'=>$a_id); $data['asset']=$this->yaskawa_model->get_single_row($table,$where); $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $data['company_details']=$this->yaskawa_model->fetch_company_details(); $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count=0; foreach($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if($months=='11'){ $count+=1; } } $data['count']=$count; $this->load->view('admin/edit_assets',$data); } else { redirect('/'); } } public function update_assets(){ $domain_name = $this->input->post('domain'); $domain_link = $this->input->post('domain_link'); $user_name = $this->input->post('username'); $password = $this->input->post('password'); $gate_way_name = $this->input->post('gate_way'); $g_username = $this->input->post('g_username'); $g_password = $this->input->post('g_password'); $a_id = $this->input->post('asset_id'); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $created_at = $date->format('Y-m-d'); $where=array('assets_id'=>$a_id); $table="assets"; $quick_contact = array( 'domain_name' => $domain_name, 'domain_username' => $user_name, 'domain_link' => $domain_link, 'd_password' => $password, 'gate_way' => $gate_way_name, 'g_username' => $g_username, 'g_password' => $g_password, 'delete_status' => 'ACTIVE', 'created_at' => $created_at ); $result = $this->yaskawa_model->update_single($where,$table,$quick_contact); if($result) { echo json_encode(array('result'=>1,'message'=>"Assets added successfully")); } else { echo json_encode(array('result'=>0,'message'=>"Something went wrong.. try again")); } } public function add_customer_assets(){ $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $data['company_details']=$this->yaskawa_model->fetch_company_details(); $table="service_type"; $where=array('delete_status'=>'ACTIVE'); $data['service']=$this->yaskawa_model->get_customer_result($table,$where); $table="assets"; $where=array('delete_status'=>'ACTIVE'); $data['asset']=$this->yaskawa_model->get_customer_result($table,$where); $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $data['website']=$this->yaskawa_model->get_customer_result($table,$where); $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count=0; foreach($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if($months=='11'){ $count+=1; } } $data['count']=$count; $this->load->view('admin/add_customer_asset',$data); } else { redirect('/'); } } public function add_customer_assets_new(){ $customer_name = $this->input->post('customer_name'); $domain_name = $this->input->post('domain_name'); $website = $this->input->post('website'); $service_type = $this->input->post('service_type'); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $created_at = $date->format('Y-m-d'); $table="customer_assets"; foreach ($customer_name as $key => $value) { $quick_contact = array( 'c_name' => $value, 'c_domain_name' => $domain_name[$key], 'c_website' => $website[$key], 'c_service' => $service_type[$key], 'delete_status' => 'ACTIVE', 'created_at' => $created_at ); $result = $this->yaskawa_model->insert($table,$quick_contact); } if($result) { echo json_encode(array('result'=>1,'message'=>"Assets added successfully")); } else { echo json_encode(array('result'=>0,'message'=>"Something went wrong.. try again")); } } public function customer_assets_list(){ $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $data['company_details']=$this->yaskawa_model->fetch_company_details(); $data['customer_detail']=$this->yaskawa_model->customer_assets_details(); $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count=0; foreach($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if($months=='11'){ $count+=1; } } $data['count']=$count; $this->load->view('admin/customer_assets_list',$data); } } public function delete_customer_assets(){ $assets_id = $this->input->post('assets_id'); $table="customer_assets"; $where=array('c_id'=>$assets_id); $result=$this->yaskawa_model->delete($table,$where); echo json_encode(array('res'=>$result)); } //master module public function master_form() { $admin_id = $this->session->userdata('admin_id'); if($admin_id) {$this->load->helper('language'); $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $data['company_details'] = $this->yaskawa_model->fetch_company_details(); $table = 'master_type'; $where = array('delete_status' => 'ACTIVE'); $data['master_type'] = $this->yaskawa_model->get_where_result($table,$where); $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count=0; foreach($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if($months=='11'){ $count+=1; } } $data['count']=$count; $this->load->view('admin/master_form',$data); } else { redirect('/'); } } // public function add_masters() // { // $table = 'masters'; // $master_type_id = $this->input->post('master_type_id'); // $field_type = $this->input->post('field_type'); // $field_label = $this->input->post('field_label'); // $field_value = $this->input->post('field_value'); // $required = $this->input->post('hidden_required'); // $result = ''; // if($field_type) // { // foreach($field_type as $index=>$value) // { // $data = array( // 'master_type_id' => $master_type_id, // 'field_type' => $value, // 'field_label' => $field_label[$index], // 'field_value' => $field_value[$index], // 'required' => $required[$index] // ); // $result = $this->yaskawa_model->insert($table,$data); // } // } // if($result) // { // echo json_encode(array('result'=>1 ,'message'=>'Master added successfully')); // } // else // { // echo json_encode(array('result'=>0,'message'=>"Master could not add")); // } // } public function add_masters() { $from_detail=$this->input->post('from_data'); if($from_detail=='MAIL') { $table = 'invoice_quotation_from_mail'; $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d H:i:s'); $name = $this->input->post('name'); $designation = $this->input->post('designation'); $phone = $this->input->post('phone'); $address = $this->input->post('address'); $master_type_id = $this->input->post('edit_master_type_id'); $data=array('name'=>$name,'designation'=>$designation,'phone'=>$phone,'address'=>$address,'created_at'=>$date_format); if(!empty($master_type_id)) { $where=array('id'=>$master_type_id); $result=$this->yaskawa_model->update($where,$table,$data); }else { $result=$this->yaskawa_model->insert($table,$data); } }else { $table = 'masters'; $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d H:i:s'); $master_type_id = $this->input->post('master_type_id'); $field_type = $this->input->post('field_type'); $field_label = $this->input->post('field_label'); $field_value = $this->input->post('field_value'); $required = $this->input->post('hidden_required'); $result = ''; $where = array('master_type_id' =>$master_type_id,'delete_status'=>'ACTIVE'); $order_by = 'master_id'; $check = $this->yaskawa_model->get_where_orderby_row($table,$where,$order_by); if($check){ $chek=json_decode($check->field_value); $arr=array(); foreach($field_value as $val){ array_push($arr,$val); } $arr1=array(); foreach($chek as $va){ array_push($arr1,$va); } $d=array_merge($arr1,$arr); $ar=json_encode($d); $update_data=array( 'field_value'=> $ar, 'updated_at' => $date_format ); $update = $this->yaskawa_model->update_single($where,$table,$update_data); } else{ $data=array( 'field_value' => json_encode($field_value), 'master_type_id' => $master_type_id, 'field_label' => $field_label, 'field_type' => 'select', 'field_name' => str_replace(' ', '_', strtolower($field_label)), 'required' => 'NO', 'created_at' => $date_format ); $result = $this->yaskawa_model->insert($table,$data); } } if($result || $update) { echo json_encode(array('result'=>1 ,'message'=>'Master added successfully')); } else { echo json_encode(array('result'=>0,'message'=>"Master could not add")); } } public function master_list() { $admin_id = $this->session->userdata('admin_id'); if($admin_id) {$this->load->helper('language'); $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $data['company_details'] = $this->yaskawa_model->fetch_company_details(); $data['master_list'] = $this->yaskawa_model->get_all_masters_list(); $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count=0; foreach($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if($months=='11'){ $count+=1; } } $data['count']=$count; $this->load->view('admin/master_list',$data); } else { redirect('/'); } } public function get_all_masters_list() { $result = $this->yaskawa_model->get_all_masters_list(); if($result) { echo json_encode(array('result'=>1,'masters_list'=>$result)); } else { echo json_encode(array('result'=>0)); } } public function delete_master() { $table = 'masters'; $master_id = $this->input->post('master_id'); $where = array('master_id'=>$master_id); $data = array('delete_status'=>'INACTIVE'); $result = $this->yaskawa_model->update($where,$table,$data); if($this->db->affected_rows() > 0) { echo json_encode(array('result'=>1,'message'=>'Deleted successfully')); } else { echo json_encode(array('result'=>0)); } } //client requirement public function client_requirement() { $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $data['source_details']=$this->yaskawa_model->get_lead_source_details(); $data['company_details']=$this->yaskawa_model->fetch_company_details(); $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count=0; foreach($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if($months=='11'){ $count+=1; } } $data['count']=$count; $data['industry_details']=$this->yaskawa_model->get_lead_industry_details(); $this->load->view('admin/client_requirement_sheet',$data); } else { redirect('/'); } } public function quotation(){ $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $data['user_type_id'] = $this->access_id(); $table="masters"; $where_sgst=array('field_label'=>'sgst','delete_status'=>'ACTIVE'); $data_sgst=$this->yaskawa_model->get_data_row($table,$where_sgst); $data['sgst']=json_decode($data_sgst->field_value); $where_igst=array('field_label'=>'igst','delete_status'=>'ACTIVE'); $data_igst=$this->yaskawa_model->get_data_row($table,$where_igst); $data['igst']=json_decode($data_igst->field_value); $data['access'] = $this->access_details(); $data['company_details']=$this->yaskawa_model->fetch_company_details(); $where=array('delete_status'=>'ACTIVE'); $table="quotations"; $data['quotation']=$this->yaskawa_model->get_quotation_last_row($table,$where); $where=array('delete_status'=>'ACTIVE'); $table="masters"; $where_gst=array('field_label'=>'gst','delete_status'=>'ACTIVE'); $data_gst=$this->yaskawa_model->get_data_row($table,$where_gst); $data['gst']=json_decode($data_gst->field_value); $where=array('delete_status'=>'ACTIVE','master_type_id'=>'17'); $id="master_id"; $data['master']=$this->yaskawa_model->get_last_master_row($table,$where,$id); $table="masters"; $where=array('delete_status'=>'ACTIVE','master_type_id'=>'7'); $order_by='master_id'; $data['comment']=$this->yaskawa_model->get_last_master_row($table,$where,$order_by); $table="masters"; $where=array('delete_status'=>'ACTIVE','master_type_id'=>'8'); $order_by='master_id'; $data['desc']=$this->yaskawa_model->get_last_master_row($table,$where,$order_by); $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count=0; foreach($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if($months=='11'){ $count+=1; } } $data['count']=$count; $this->load->view('admin/add_quotation',$data); } else { redirect('/'); } } public function quotation_new(){ $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $data['user_type_id'] = $this->access_id(); $table="masters"; $where_sgst=array('field_label'=>'sgst','delete_status'=>'ACTIVE'); $data_sgst=$this->yaskawa_model->get_data_row($table,$where_sgst); $data['sgst']=json_decode($data_sgst->field_value); $where_igst=array('field_label'=>'igst','delete_status'=>'ACTIVE'); $data_igst=$this->yaskawa_model->get_data_row($table,$where_igst); $data['igst']=json_decode($data_igst->field_value); $data['access'] = $this->access_details(); $data['company_details']=$this->yaskawa_model->fetch_company_details(); $where=array('delete_status'=>'ACTIVE'); $table="quotations"; $data['quotation']=$this->yaskawa_model->get_quotation_last_row($table,$where); $where=array('delete_status'=>'ACTIVE'); $id = $this->uri->segment(2); $data['account_persons'] = $this->yaskawa_model->single_account_details($id); $table="masters"; $where_gst=array('field_label'=>'gst','delete_status'=>'ACTIVE'); $data_gst=$this->yaskawa_model->get_data_row($table,$where_gst); $data['gst']=json_decode($data_gst->field_value); $where=array('delete_status'=>'ACTIVE','master_type_id'=>'17'); $id="master_id"; $data['master']=$this->yaskawa_model->get_last_master_row($table,$where,$id); $table="masters"; $where=array('delete_status'=>'ACTIVE','master_type_id'=>'7'); $order_by='master_id'; $data['comment']=$this->yaskawa_model->get_last_master_row($table,$where,$order_by); $table="masters"; $where=array('delete_status'=>'ACTIVE','master_type_id'=>'8'); $order_by='master_id'; $data['desc']=$this->yaskawa_model->get_last_master_row($table,$where,$order_by); $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count=0; foreach($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if($months=='11'){ $count+=1; } } $data['count']=$count; $this->load->view('admin/quotation_new',$data); } else { redirect('/'); } } public function add_quotation(){ // $admin=$this->session->userdata('admin'); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $created_at = $date->format('Y-m-d'); $created_at_new = $date->format('Y-m-d H:i:s'); $qu_date=$this->input->post('quo_date'); $till_date=date('Y-m-d', strtotime($qu_date)); $quot_end_date=$this->input->post('quot_end_date'); $quot_end_date=date('Y-m-d', strtotime($quot_end_date)); $table="quotations"; $qt=$this->input->post('total_amount'); $price=$this->input->post('price'); $stamp_duty=str_replace(',', '', $qt); $sub_total=$this->input->post('sub_total'); $sub_total=str_replace(',', '', $sub_total); $gst_value=$this->input->post('gst_value'); // $gst_value=str_replace(',', '', $gst_value); $gst_value = str_replace(',', '', $gst_value ?? ''); $cgst_amounts=$this->input->post('cgst_amount'); $cgst_amount=str_replace(',', '', $cgst_amounts); $admin=$this->session->userdata('admin'); if($sub_total==0) { $sub_total=$stamp_duty; } if($admin==''){ $admin=$this->session->userdata('user'); } $to_name=$this->input->post('to_name'); $get_ids=$this->yaskawa_model->get_potential_lead_id($to_name); $quotation_number= $this->input->post('quotation_number'); $gst_value=$this->input->post('gst_value'); // $gst_value=str_replace(',', '', $gst_value); $gst_value = str_replace(',', '', $gst_value ?? ''); $sgst_value=$this->input->post('sgst_amount'); $sgst_value=str_replace(',', '', $sgst_value); $igst_value=$this->input->post('igst_amount'); $igst_value=str_replace(',', '', $igst_value); $sgst=$this->input->post('sgst'); $igst=$this->input->post('igst'); $cgst=$this->input->post('cgst'); if($get_ids->lead_source=='lead_source'){ $arr=array( 'lead_id' =>$get_ids->id, 'sgst' =>$sgst, 'quatetion_from'=>'Lead', 'price'=>json_encode($price), 'sgst_amount' =>$sgst_value, 'igst' =>$igst, 'igst_amount' =>$igst_value, 'potential_id' =>'0', 'gst' =>$cgst, 'gst_amount' =>$cgst_amount, 'quo_date' =>$till_date, 'tax_no_tax' =>$this->input->post('invoice_tax'), 'quotation_number' =>$this->input->post('quotation_number'), 'amount' =>$stamp_duty, 'comments' =>$this->input->post('comments'), 'description' =>json_encode($this->input->post('description')), 'client_name' =>$this->input->post('client_name'), 'address' =>$this->input->post('address'), 'quot_end_date' =>$quot_end_date, 'sub_total' =>$sub_total, 'created_at' =>$created_at_new, 'generated_by' =>$admin, //'generated_by' =>, 'convert_status' =>'Waiting For Approval' ); } else if($get_ids->lead_source=='Account') { $arr=array( 'lead_id' =>$get_ids->id, 'sgst' =>$sgst, 'sgst_amount' =>$sgst_value, 'quatetion_from'=>'Account', 'igst' =>$igst, 'price'=>json_encode($price), 'igst_amount' =>$igst_value, 'potential_id' =>0, 'account_id'=>$get_ids->a_id, 'tax_no_tax' =>$this->input->post('invoice_tax'), 'quotation_number' =>$this->input->post('quotation_number'), 'quo_date' =>$till_date, 'amount' =>$stamp_duty, 'comments' =>$this->input->post('comments'), 'description' =>json_encode($this->input->post('description')), 'client_name' =>$this->input->post('client_name'), 'address' =>$this->input->post('address'), 'quot_end_date' =>$quot_end_date, 'gst' =>$cgst, 'gst_amount' =>$cgst_amount, 'sub_total' =>$sub_total, 'created_at' =>$created_at_new, 'generated_by' =>$admin, 'convert_status' =>'Waiting For Approval' ); } else { $arr=array( 'lead_id' =>'0', 'sgst' =>$sgst, 'sgst_amount' =>$sgst_value, 'igst' =>$igst, 'price'=>json_encode($price), 'igst_amount' =>$igst_value, 'potential_id' =>$get_ids->id, 'quatetion_from'=>'Potential', 'tax_no_tax' =>$this->input->post('invoice_tax'), 'quotation_number' =>$this->input->post('quotation_number'), 'quo_date' =>$till_date, 'amount' =>$stamp_duty, 'comments' =>$this->input->post('comments'), 'description' =>json_encode($this->input->post('description')), 'client_name' =>$this->input->post('client_name'), 'address' =>$this->input->post('address'), 'quot_end_date' =>$quot_end_date, 'gst' =>$cgst, 'gst_amount' =>$cgst_amount, 'sub_total' =>$sub_total, 'created_at' =>$created_at_new, 'generated_by' =>$admin, 'convert_status' =>'Waiting For Approval' ); } $tax_state=$this->input->post('invoice_tax_state'); if(!empty($tax_state)) { $arr['tax_state'] = $tax_state; } $result=$this->yaskawa_model->insert($table,$arr); echo json_encode($result); } public function update_quotation_data(){ $admin=$this->session->userdata('admin'); if($admin==''){ $admin=$this->session->userdata('user'); } $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $created_at = $date->format('Y-m-d'); $created_at_new = $date->format('Y-m-d H:i:s'); $quotation_id=$this->input->post('quotation_id'); $qu_date=$this->input->post('quo_date'); $till_date=date('Y-m-d', strtotime($qu_date)); $quot_end_date=$this->input->post('quot_end_date'); $quot_end_date=date('Y-m-d', strtotime($quot_end_date)); $table="quotations"; $qt=$this->input->post('total_amount'); $stamp_duty=str_replace(',', '', $qt); $sub_total=$this->input->post('sub_total'); $sub_total=str_replace(',', '', $sub_total); $gst_value=$this->input->post('cgst_amount'); $gst_value=str_replace(',', '', $gst_value); $sgst_value=$this->input->post('sgst_amount'); $sgst_value=str_replace(',', '', $sgst_value); $igst_value=$this->input->post('igst_amount'); $igst_value=str_replace(',', '', $igst_value); $igst=$this->input->post('igst'); $sgst=$this->input->post('sgst'); $quot_num=$this->input->post('quotation_number'); $to_name=$this->input->post('to_name'); $to_name = explode(":",$to_name); $to_name_new=$to_name[0]; if($sub_total==0) { $sub_total=$stamp_duty; } $arr=array( 'quo_date' =>$till_date, 'amount' =>$stamp_duty, 'quotation_number' =>$quot_num, 'comments' =>$this->input->post('comments'), 'description' =>json_encode($this->input->post('description')), 'price' =>json_encode($this->input->post('price')), 'client_name' =>$to_name_new, 'address' =>$this->input->post('address'), 'quot_end_date' =>$quot_end_date, 'gst' =>$this->input->post('cgst'), 'gst_amount' =>$gst_value, 'sgst' =>$sgst, 'sgst_amount' =>$sgst_value, 'igst' =>$igst, 'tax_no_tax' =>$this->input->post('invoice_tax'), 'igst_amount' =>$igst_value, 'sub_total' =>$sub_total, 'created_at' =>$created_at_new, 'generated_by' =>$admin, //'convert_status' =>'Waiting For Approval' ); $where=array('quotation_id'=>$quotation_id); $table="quotations"; $tax_state=$this->input->post('invoice_tax_state'); if(!empty($tax_state)) { $arr['tax_state'] = $tax_state; } $get_last_quotation=$this->yaskawa_model->get_row_data($table,$where); $details=array( 'quotation_id' =>$get_last_quotation->quotation_id, 'lead_id' => $get_last_quotation->lead_id, 'quotation_number' => $get_last_quotation->quotation_number, 'quo_date' => $get_last_quotation->quo_date, 'response_date' => $get_last_quotation->response_date, 'probability' => $get_last_quotation->probability, 'amount' => $get_last_quotation->amount, 'description' => $get_last_quotation->description, 'delete_status' => $get_last_quotation->delete_status, 'old_created_at' => $get_last_quotation->created_at, 'comments' =>$get_last_quotation->comments, 'price' =>$get_last_quotation->price, 'client_name' =>$get_last_quotation->client_name, 'address' =>$get_last_quotation->address, 'quot_end_date' =>$get_last_quotation->quot_end_date, 'gst' =>$get_last_quotation->gst, 'gst_amount' =>$get_last_quotation->gst_amount, 'sgst' =>$get_last_quotation->sgst, 'sgst_amount' =>$get_last_quotation->sgst_amount, 'igst' =>$get_last_quotation->igst, 'tax_no_tax' =>$get_last_quotation->tax_no_tax, 'igst_amount' =>$get_last_quotation->igst_amount, 'sub_total' =>$get_last_quotation->sub_total, 'created_at' =>date("Y-m-d H:i:s"), 'generated_by' =>$get_last_quotation->generated_by, 'convert_status' =>$get_last_quotation->convert_status, 'quatetion_from'=>$get_last_quotation->quatetion_from, 'potential_id' =>$get_last_quotation->potential_id, 'account_id'=>$get_last_quotation->account_id, 'old_updated_at'=>$get_last_quotation->updated_at, ); $table_new='old_quotation_details'; $results=$this->yaskawa_model->insert($table_new,$details); $result=$this->yaskawa_model->update_single($where,$table,$arr); echo json_encode($result); } public function quotation_edit(){ $admin_id = $this->session->userdata('admin_id'); $quotation_id = $this->uri->segment(2); if($admin_id) { $data['user_type_id'] = $this->access_id(); $id="quotation_id"; $where=array('quotation_id'=>$quotation_id); $table="quotations"; $data['quotations']=$this->yaskawa_model->get_last_master_row($table,$where,$id); $data['access'] = $this->access_details(); $data['company_details']=$this->yaskawa_model->fetch_company_details(); // $where=array('delete_status'=>'ACTIVE'); // $table="quotations"; // $data['quotation']=$this->yaskawa_model->get_quotation_last_row($table,$where); // $where=array('delete_status'=>'ACTIVE'); $table="masters"; $where=array('delete_status'=>'ACTIVE','master_type_id'=>'17'); $id="master_id"; $data['master']=$this->yaskawa_model->get_last_master_row($table,$where,$id); $table="masters"; $where=array('delete_status'=>'ACTIVE','master_type_id'=>'7'); $order_by='master_id'; $data['comment']=$this->yaskawa_model->get_last_master_row($table,$where,$order_by); $table="masters"; $where=array('delete_status'=>'ACTIVE','master_type_id'=>'8'); $order_by='master_id'; $data['desc']=$this->yaskawa_model->get_last_master_row($table,$where,$order_by); $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count=0; foreach($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if($months=='11'){ $count+=1; } } $data['count']=$count; $table="masters"; $where_sgst=array('field_label'=>'sgst','delete_status'=>'ACTIVE'); $data_sgst=$this->yaskawa_model->get_data_row($table,$where_sgst); $data['sgst']=json_decode($data_sgst->field_value); $where_igst=array('field_label'=>'igst','delete_status'=>'ACTIVE'); $data_igst=$this->yaskawa_model->get_data_row($table,$where_igst); $data['igst']=json_decode($data_igst->field_value); $table="masters"; $where_gst=array('field_label'=>'gst','delete_status'=>'ACTIVE'); $data_gst=$this->yaskawa_model->get_data_row($table,$where_gst); $data['gst']=json_decode($data_gst->field_value); $this->load->view('admin/update_quotation',$data); } else { redirect('/'); } } public function quotation_list(){ $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $data['user_type_id'] = $this->access_id(); $table="users"; $condition=array('user_id'=>$admin_id,'delete_status'=>'ACTIVE'); $order_by='user_id'; $get_user_type_id=$this->yaskawa_model->get_where_orderby_row($table,$condition,$order_by); $data['user_type_ids']=$get_user_type_id->user_type_id; $data['access'] = $this->access_details(); $data['company_details']=$this->yaskawa_model->fetch_company_details(); $data['quotation']=$this->yaskawa_model->get_quotation_result(); $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count=0; foreach($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if($months=='11'){ $count+=1; } } $data['count']=$count; $this->load->view('admin/quotation_list',$data); } else { redirect('/'); } } public function search_lead(){ $val=$this->input->post('val'); $result=$this->yaskawa_model->search_lead($val); echo json_encode($result); } public function get_amount(){ $value=$this->input->post('value'); $table="masters"; $where=array('master_id'=>$value,'delete_status'=>'ACTIVE'); $id='master_id'; $result=$this->yaskawa_model->get_last_master_row($table,$where,$id); echo json_encode($result); } public function get_quotation_details(){ $id=$this->input->post('id'); $result=$this->yaskawa_model->get_quotation_details_new($id); $gst=($result->amount*$result->gst)/100; $total=$gst+$result->amount; echo json_encode(array('result'=>$result,'gst'=>$gst,'total'=>$total)); } public function invoice(){ $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $table="quotations"; $where=array('delete_status'=>'ACTIVE'); $data['quot']=$this->yaskawa_model->get_customer_result($table,$where); $table='masters'; $where_gst=array('field_label'=>'gst','delete_status'=>'ACTIVE'); $where_sgst=array('field_label'=>'sgst','delete_status'=>'ACTIVE'); $where_igst=array('field_label'=>'igst','delete_status'=>'ACTIVE'); $data_gst=$this->yaskawa_model->get_data_row($table,$where_gst); $data['gst']=json_decode($data_gst->field_value); $data_sgst=$this->yaskawa_model->get_data_row($table,$where_sgst); $data_igst=$this->yaskawa_model->get_data_row($table,$where_igst); $data['igst']=json_decode($data_igst->field_value); $proforma=$this->yaskawa_model->get_proforma_id(); $date=date("dmY"); if(!empty($proforma)) { // $num=$proforma->invoice_no; // if (strpos($num, '/') !== false) { // $split = explode("/",$num); // if(!empty($split[2])){ // $pid=$split[2]; // }else // { // $pid=$split[1]; // } // $fid=$pid+1; // $date=date("dmY"); // //$data['proforma_id']='JB-PROFORMA/'.$date.'/'.$fid; // $data['proforma_id']='JB-'.$date.'/'.$fid.'/PROFORMA'; // }else // { // //$data['proforma_id']='JB-PROFORMA/'.$date.'/1'; // $data['proforma_id']='JB-'.$date.'/1'.'/PROFORMA'; // } // }else // { // //$data['proforma_id']='JB-PROFORMA/'.$date.'/1'; // $data['proforma_id']='JB-'.$date.'/1'.'/PROFORMA'; // } // $cash=$this->yaskawa_model->get_cash_id_new(); // //print_r($cash); // if($cash) // { // // $num=$cash->invoice_number; // // $split = explode("/",$num); // // $pid=$split[2]; // $pid = $cash->invoice_number; // $fid=$pid+1; // $date=date("dmY"); // //$data['cash_id']='JB-CASH/'.$date.'/'.$fid; // $data['cash_id']='JB-'.$date.'/'.$fid.'/CASH'; // }else // { // //$data['cash_id']='JB-CASH/'.$date.'/1'; // $data['cash_id']='JB-'.$date.'/1'.'/CASH'; // } // $row=$this->yaskawa_model->get_invoice_id(); // if(!empty($row)) // { // $num=$row->invoice_no; // $split = explode("/",$num); // if(!empty($split[2])){ // $pid=$split[2]; // }else // { // $pid=$split[1]; // } // $fid=$pid+1; // $date=date("dmY"); //$data['invoice_id']='JB-NORMAL/'.$date.'/'.$fid; //---------------------16-10-2019-------------------------// $num_table = 'invoice_numbers'; $order_by = 'number_id'; $where_inv = array('delete_status'=>'ACTIVE','invoice_type'=>'NORMAL'); $inv_result = $this->yaskawa_model->get_where_orderby_row($num_table,$where_inv,$order_by); $data['new_invoice_num'] = $inv_result->invoice_number + 1; $where_inv_pr = array('delete_status'=>'ACTIVE','invoice_type'=>'PROFORMA'); $pr_inv_result = $this->yaskawa_model->get_where_orderby_row($num_table,$where_inv_pr,$order_by); $data['new_pr_invoice_num'] = $pr_inv_result->invoice_number + 1; $where_inv_cash = array('delete_status'=>'ACTIVE','invoice_type'=>'CASH'); $cash_inv_result = $this->yaskawa_model->get_where_orderby_row($num_table,$where_inv_cash,$order_by); $data['new_cash_invoice_num'] = $cash_inv_result->invoice_number + 1; $fid = $inv_result->invoice_number + 1; $pfid = $pr_inv_result->invoice_number + 1; $cfid = $cash_inv_result->invoice_number + 1; $data['proforma_id'] = 'JB-'.$date.'/'.$pfid.'/PROFORMA'; $data['cash_id'] = 'JB-'.$date.'/'.$cfid.'/CASH'; //--------------------------------------------------------// $data['invoice_id']='JB-'.$date.'/'.$fid; }else { $data['invoice_id']='JB-'.$date.'/1'; } //print_r($data['invoice_id']); /* $num=$row->invoice_no; $split = explode("/",$num); $id=$split[1]; $data['invoice_id']=$id;*/ $data['sgst']=json_decode($data_sgst->field_value); $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count=0; foreach($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if($months=='11'){ $count+=1; } } $data['count']=$count; $this->load->view('admin/invoice',$data); } else { redirect('/'); } } public function get_lead_detail(){ $id=$this->input->post('lead_id'); $table="leads"; $where=array('lead_id'=>$id); $result=$this->yaskawa_model->get_row_data($table,$where); echo json_encode($result); } public function get_potentialnew_detail(){ $id=$this->input->post('lead_id'); $table="new_potential"; $result=$this->yaskawa_model->get_potentialnew_detail($id); $results=$this->yaskawa_model->get_potentialaccount_detail($id); $resultss=$this->yaskawa_model->get_potential_detail($id); if($result->mailing_street!=''){ //echo 'hi'; echo json_encode($result); }else if($results->mailing_street!=''){ echo json_encode($results); }else { echo json_encode($resultss); } } public function send_quotation(){ $table='invoice_quotation_from_mail'; $condition=array('delete_status'=>'ACTIVE','checked_status'=>1); $get_signature=$this->yaskawa_model->get_row_data($table,$condition); if(!empty($get_signature)) { $signature=$get_signature; }else { //$signature=array('name'=>'Subramanya','designation'=>'Sales Executive Manager','phone'=>'9663933606','address'=>' K R Square, #1073, 15th cross, 30th main, Banashankari 2nd stage, Bangalore - 560070'); $signature=array('name'=>'Rekha R','designation'=>'Inside Sales','phone'=>'9606655606','address'=>' K R Square, #1073, 15th cross, 30th main, Banashankari 2nd stage, Bangalore - 560070'); } $quot_id=$this->input->post('lead_id'); $email_new=$this->input->post('email'); $cc=$this->input->post('cc'); $where=array('quotation_id'=>$quot_id); $table="quotations"; $quot=$this->yaskawa_model->get_row_data($table,$where); $email=$this->input->post('email'); if($quot!=''){ if($quot->lead_id!='0'){ $lead_id=$quot->lead_id; $where=array('lead_id'=>$lead_id); $table="leads"; $result=$this->yaskawa_model->get_row_data($table,$where); $adress=$result->street.' '.$result->city; } else{ $lead_id=$quot->potential_id; $where=array('potential_id'=>$lead_id); $table="new_potential"; $result=$this->yaskawa_model->get_potentialnew_detail_new($lead_id); if($result->mailing_street!=''){ $result=$result; }else{ $result=$this->yaskawa_model->get_potentialaccount_detail($lead_id); } $adress=$result->mailing_street.''.$result->mailing_city.''.$result->mailing_state.''.$result->mailing_zip_code; } } $sub_total=number_format($quot->sub_total); $amount=number_format($quot->amount); $gst_amt=number_format($quot->gst_amount); $name = 'quotation'.$quot_id.'.pdf'; include("admin_assets/mpdf60/mpdf.php"); $mpdf=new mPDF('A4'); $mpdf->mirrorMargins = 1; $html = ''; $index = 1; $html=$html.'<html style="margin:0 !important; padding:0 !important;">'; $html=$html.'<head>'; $html=$html.'<title>Quotation</title>'; $html=$html.'</head>'; $html=$html.'<body>'; $html=$html.'<div class="row_1">'; $html=$html.'<img src="https://jayblues.in/jayerp/admin_assets/logo.png">'; $html=$html.'<h1 style="color: #A6A6A6; border-bottom: 1px solid #000;text-align: right;padding-bottom: 5px;margin-bottom: 0px;">Quotation</h1>'; $html=$html.'<p style="margin-top: 5px;margin-bottom: 0px;">Please do not compare our quotation with others as Quality is our main priority!</p>'; $html=$html.'</div>'; $html=$html.'<div class="" style="clear:both !important;"></div>'; $html=$html.'<div class="row_2">'; $html=$html.'<table style="width:100%;">'; $html=$html.'<tr>'; $html=$html.'<td style="width:70%"></td>'; $html=$html.'<td style="width:30%; text-align:right;padding-right:10px;"><b>DATE</b></td>'; $html=$html.'<td>'.$quot->quo_date.'</td>'; $html=$html.'</tr>'; $html=$html.'<tr>'; $html=$html.'<td style="width:70%"></td>'; $html=$html.'<td style="width:30%; text-align:right;padding-right:10px;"><b>Quotation #</b></td>'; $html=$html.'<td>'.$quot->quotation_number.'</td>'; $html=$html.'</tr>'; $html=$html.'<tr>'; $html=$html.'<td style="width:70%"></td>'; $html=$html.'<td style="width:30%; text-align:right;padding-right:10px;"><em>Quotation valid until:</em></td>'; $html=$html.'<td>'.$quot->quot_end_date.'</td>'; $html=$html.'</tr>'; $html=$html.'<tr>'; $html=$html.'<td style="width:70%"></td>'; $html=$html.'<td style="width:30%; text-align:right;padding-right:10px;"><em>Prepared by:</em></td>'; $html=$html.'<td>'.$quot->generated_by.'</td>'; $html=$html.'</tr>'; $html=$html.'</table>'; $html=$html.'</div>'; $html=$html.'<div class="" style="clear:both !important;"></div>'; $html=$html.'<div class="row_3">'; $html=$html.'<p style="margin-bottom:5px;margin-top:5px;"><b>To:</b></p>'; $html=$html.'<p style="margin-bottom:5px;margin-top:5px;">'.$quot->client_name.'</p>'; $html=$html.'<p style="margin-bottom:5px;margin-top:5px;">'.$adress.'</p>'; $html=$html.'<p style="margin-bottom: 5px;padding-top:10px;"><b>Comments or special instructions:</b></p>'; $html=$html.'<p style="margin-top: 5px;">'.$quot->comments.'</p>'; $html=$html.'</div>'; $html=$html.'<div class="row_4" style="padding: 10px 0px 20px;">'; $html=$html.'<table border="1" style="width:100%;border-collapse: collapse;">'; $html=$html.'<tr style="background: #F2F2F2;">'; $html=$html.'<th style="width: 80%;padding: 5px;">Description</th>'; $html=$html.'<th style="width: 20%;padding: 5px;">AMOUNT</th>'; $html=$html.'</tr>'; $html=$html.'<tr>'; $html=$html.'<td style="padding: 50px 5px;text-align: center">'.$quot->description.'</td>'; $html=$html.'<td style="padding: 50px 5px;text-align: right">'.$sub_total.'Rs.</td>'; $html=$html.'</tr>'; $html=$html.'<tr>'; $html=$html.'<td style="padding: 5px;text-align: right;"><b>Sub Total</b></td>'; $html=$html.'<td style="padding: 5px;text-align: right;">'.$sub_total.'Rs. </td>'; $html=$html.'</tr>'; $html=$html.'<tr>'; $html=$html.'<td style="padding: 5px;text-align: right;"><b>TOTAL</b></td>'; $html=$html.'<td style="padding: 5px;text-align: right;">'.$amount.' Rs. </td>'; $html=$html.'</tr>'; $html=$html.'</table>'; $html=$html.'<p><b>Note:</b>18% service tax extra on the quoted amount.</p>'; $html=$html.'</div>'; $html=$html.'<div class="row_5" style="padding-top:10px;">'; $html=$html.'<table style="width:100%; color:#898989;">'; $html=$html.'<tr>'; $html=$html.'<td style="width:35%;font-size: 12px;">Company GSTN : 29BZLPS4657ILZG</td>'; $html=$html.'<td style="width:35%;font-size: 12px;">Company GSTN : 29BZLPS4657ILZG</td>'; $html=$html.'<td style="text-align:right;width:30%;font-size: 12px;">For JAYBLUES TECHNOLOGIES</td>'; $html=$html.'</tr>'; $html=$html.'<tr>'; $html=$html.'<td style="font-size: 12px;">Company Bank Details :</td>'; $html=$html.'<td style="font-size: 12px;">Company Bank Details :</td>'; $html=$html.'<td rowspan="3"><img src="https://jayblues.in/jayerp/admin_assets/ajay_sig.jpg" style="float:right;"/></td>'; $html=$html.'</tr>'; $html=$html.'<tr>'; $html=$html.'<td style="font-size: 12px;">SBI</td>'; $html=$html.'<td style="font-size: 12px;">HDFC Bank</td>'; $html=$html.'</tr>'; $html=$html.'<tr>'; $html=$html.'<td style="font-size: 12px;">Jayblues</td>'; $html=$html.'<td style="font-size: 12px;">Jayblues</td>'; $html=$html.'</tr>'; $html=$html.'<tr>'; $html=$html.'<td style="font-size: 12px;">Account Type : Current Account</td>'; $html=$html.'<td style="font-size: 12px;">Account Type : Current Account</td>'; $html=$html.'<td style="text-align:right;color:#000;font-size: 12px; style="font-size: 14px;"">Authorized Signatory</td>'; $html=$html.'</tr>'; $html=$html.'<tr>'; $html=$html.'<td style="font-size: 12px;">Account Number : 62439776675</td>'; $html=$html.'<td style="font-size: 12px;">Account Number : 50200010784596</td>'; $html=$html.'<td></td>'; $html=$html.'</tr>'; $html=$html.'<tr>'; $html=$html.'<td style="font-size: 12px;">IFSC : SBIN0020555</td>'; $html=$html.'<td style="font-size: 12px;">IFSC : HDFC0000065</td>'; $html=$html.'<td></td>'; $html=$html.'</tr>'; $html=$html.'<tr>'; $html=$html.'<td style="font-size: 12px;">Branch : Kalidasa Road, Mysore</td>'; $html=$html.'<td style="font-size: 12px;">Branch : Saraswathipuram, Mysore</td>'; $html=$html.'<td></td>'; $html=$html.'</tr>'; $html=$html.'</table>'; $html=$html.'</div>'; $html=$html.'<div class="row_5" style="padding-top:10px;">'; $html=$html.'<h3 style="text-align: center;padding-bottom: 10px;border-bottom: 1px solid #000;margin-bottom: 5px;">THANK YOU FOR YOUR BUSINESS!</h3>'; $html=$html.'<p style="text-align: center;color:#898989; margin: 0 !important; padding-bottom: 8px;font-size:12px;">Head Off. : #656/D, 16th Main, 5th Cross, Saraswathipuram, Mysore, Karnataka-570009.</p>'; $html=$html.'<p style="text-align: center;color:#898989; margin: 0 !important;font-size:12px;">Branch Off. : K R Square, #1073, 15th cross, 30th main, Banashankari 2nd stage, Bangalore - 560070.<br>'; $html=$html.'Ph: 9663933606 / 9740285566, www.jayblues.com</p>'; $html=$html.'</div>'; $html=$html.'</body>'; $html=$html.'</html>'; $mpdf->SetDisplayMode('fullpage'); $mpdf->watermark_font = 'DejaVuSansCondensed'; $mpdf->showWatermarkText = true; $mpdf->WriteHTML($html); $data = date('d-M-y H:i'); $pdf=$mpdf->Output("./pdf/".$name, 'F'); $body1=$this->input->post('body'); $m='quotation'.$quot_id.'.pdf'; $msg ='Hello Sir,'.'<br/><br/>'; $msg.='Greetings from Jayblues Technologies!'.'<br/><br/>'; $msg.= 'Please find the below attached quotation for '.$quot->description; $msg.='<br/><br/>'; //----------------------------15-10-2019--------------------------// $msg.='<p>Please go through the same and let me know if we have any quires.</p>'; $msg.= '<a href="https://www.youtube.com/watch?v=nMyTBP2iloc">YouTube: Click here to watch how Jayblues can increase your revenue!</a>'; //----------------------------------------------------------------// $msg.=$body1; $msg.='<p> Thank you</p>'; $msg.='<p><b> Regards,</b></p>'; $msg.='<p style="color: rgb(31,73,125);"><b> '.$signature->name.' | '.$signature->designation.' | +91'.$signature->phone.'</b></p>'; $msg.='<p><b> JayBlues Technologies</b></p>'; $msg.='<p><span style="color:rgb(91,155,213);"><b> Address</b></span>: K R Square, #1073, '.$signature->address.'</p>'; $msg.='<p><span style="color:rgb(91,155,213);">Tel</span>: +91 '.$signature->phone.' | www.jayblues.com | E: support@jayblues.com</p>'; $subject=$this->input->post('subject'); $name='Jayblues'; $email='sales@jayblues.com'; $email_to=implode(',',$email_new); $result= $this->sendEmail($email,$email_to,$name,$subject,$msg,$m,$cc,$body1); if($result){ echo json_encode(array('result'=>1,'message'=>'Email Sent Sucessfully')); }else{ echo json_encode(array('result'=>0,'message'=>'Not Sent')); } } public function sendEmail($from,$email_to,$name,$subject,$message,$attach,$cc) { // $this->load->library('email'); // $config = array( // 'protocol' => 'smtp', // 'smtp_host' => 'ssl://smtp.zoho.com', // 'smtp_port' => 465, // 'smtp_user' => 'sales@jayblues.com', // 'smtp_pass' => 'jayblues1236', // '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->cc($cc); // $this->email->subject($subject); // $this->email->message($message); // $this->email->attach($_SERVER["DOCUMENT_ROOT"].'/jayerp/pdf/'.$attach); // if ($this->email->send()) { // return 1; // } else { // show_error($this->email->print_debugger()); // } // require_once($_SERVER["DOCUMENT_ROOT"].'/jayerp/application/third_party/phpmailer/PHPMailerAutoload.php'); // $phpMailer = new PHPMailer(true); // $phpMailer->isSMTP(); // $phpMailer->Host = "smtp.zoho.com"; // $phpMailer->SMTPAuth = true; // $phpMailer->Username = "sales@jayblues.com"; // $phpMailer->Password = "m7uMqE8MFMR8"; // $phpMailer->SMTPSecure = "tls"; // $phpMailer->Port = 587; // $phpMailer->isHTML(true); // $phpMailer->CharSet = "UTF-8"; // $phpMailer->setFrom("sales@jayblues.com", "Jayblues"); // $phpMailer->addAttachment($_SERVER["DOCUMENT_ROOT"]."/jayerp/pdf/".$attach); // $phpMailer->addAddress($email_to); // $phpMailer->addCC('ajay@jayblues.com'); // $phpMailer->addCC('subramanya@jayblues.com'); // //$phpMailer->addAddress('chaya@jayblues.com'); // $phpMailer->Subject = $subject; // $phpMailer->Body = $message; // if ($phpMailer->send()) { // return 1; // } else { // show_error($phpMailer->print_debugger()); // } $this->load->library('email'); $phpMailer = new PHPMailer(true); //$phpMailer->isSMTP(); $phpMailer->Host = "smtp.zoho.com"; $phpMailer->SMTPAuth = true; $phpMailer->Username = "support@jayblues.com"; $phpMailer->Password = "Jayblues@1236"; $phpMailer->SMTPSecure = "tls"; $phpMailer->Port = 587; $phpMailer->isHTML(true); $phpMailer->CharSet = "UTF-8"; $phpMailer->setFrom("support@jayblues.com", "Jayblues"); $phpMailer->addAttachment($_SERVER["DOCUMENT_ROOT"]."/jayerp/pdf/".$attach); $phpMailer->addAddress($email_to); //$phpMailer->addAddress('chaya@jayblues.com'); $phpMailer->addCC('ajay@jayblues.com'); $phpMailer->Subject = $subject; $phpMailer->Body = $message; if ($phpMailer->send()) { return 1; } else { show_error($phpMailer->print_debugger()); } } public function delet_account(){ $acc_id=$this->input->post('account_id'); $table="new_account"; $where=array('account_id'=>$acc_id); $result=$this->yaskawa_model->delete($table,$where); if($result){ $result=1; }else{ $result=0; } echo json_encode($result); } public function delete_education_detail() { $id=$this->uri->segment(2); $table="employee_education"; $where=array('id'=>$id,'delete_status'=>'ACTIVE'); $data= array('delete_status'=>'INACTIVE'); $result=$this->yaskawa_model->delete_detail($where,$data,$table); } public function add_role() { $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $table='roles'; $where =array('delete_status'=>'ACTIVE'); $data['role_list'] = $this->yaskawa_model->get_all_role($table,$where); $data['company_details'] =$this->yaskawa_model->fetch_company_details(); $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count=0; foreach($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if($months=='11'){ $count+=1; } } $data['count']=$count; $this->load->view('admin/add_role',$data); } else { redirect('/'); } } public function add_new_role() { $role_name = $this->input->post('role_name'); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $created_at = $date->format('Y-m-d H:i:s'); //$where=array('role_name'=>$role_name); $table="roles"; $result=$this->yaskawa_model->search_role($role_name); if($result){ echo json_encode(array('result'=>2,'message'=>"Role already Exist")); }else { $role_details = array( 'role_name' => $role_name, 'delete_status' => 'ACTIVE', 'created_at' => $created_at, 'updated_at' => $created_at); $table='roles'; $result = $this->yaskawa_model->add_details($table,$role_details); if($result) { echo json_encode(array('result'=>1,'message'=>"Role added successfully")); } else { echo json_encode(array('result'=>0,'message'=>"Something went wrong.. try again")); } } } //asset creation public function assets_creation() { $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $data['company_details'] = $this->yaskawa_model->fetch_company_details(); $data['domain_server'] = $this->yaskawa_model->get_domain_server(); $data['domain_service_provider'] = $this->yaskawa_model->get_domain_service_provider(); $data['hosting_service_provider'] = $this->yaskawa_model->get_hosting_service_provider(); $data['pg_service_provider'] = $this->yaskawa_model->pg_service_provider(); $data['sms_service_provider'] = $this->yaskawa_model->get_sms_service_provider(); $data['email_service_provider'] = $this->yaskawa_model->get_email_service_provider(); $data['accounts'] = $this->yaskawa_model->account_details(); $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count=0; foreach($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if($months=='11'){ $count+=1; } } $data['count']=$count; $this->load->view('admin/client_assets',$data); } else { redirect('/'); } } // public function add_client_assets() // { // $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); // $created_at = $date->format('Y-m-d H:i:s'); // $table = 'client_assets'; // $asset_for = $this->input->post('asset_for'); // $insert_data = array( // 'asset_for' => $asset_for, // 'domain_name' => $this->input->post('domain_name'), // 'domain_server' => $this->input->post('domain_server'), // 'domain_username' => $this->input->post('domain_username'), // 'domain_password' => $this->input->post('domain_password'), // 'domain_start_date' => $this->input->post('domain_start_date'), // 'domain_expiry_date' => $this->input->post('domain_expiry_date'), // 'domain_status' => $this->input->post('domain_status'), // 'domain_space' => $this->input->post('domain_space'), // 'domain_service_provider' => $this->input->post('domain_service_provider'), // 'domain_name' => $this->input->post('domain_name'), // 'hosting_username' => $this->input->post('hosting_username'), // 'hosting_password' => $this->input->post('hosting_password'), // 'hosting_service_provider' => $this->input->post('hosting_service_provider'), // 'hosting_expiry_date' => $this->input->post('hosting_expiry_date'), // 'pg_username' => $this->input->post('pg_username'), // 'pg_password' => $this->input->post('pg_password'), // 'pg_service_provider' => $this->input->post('pg_service_provider'), // 'pg_commission' => $this->input->post('pg_commission'), // 'sms_username' => $this->input->post('sms_username'), // 'sms_password' => $this->input->post('sms_password'), // 'sms_service_provider' => $this->input->post('sms_service_provider'), // 'sms_expiry_date' => $this->input->post('sms_expiry_date'), // 'no_of_sms' => $this->input->post('no_of_sms'), // 'email_username' => $this->input->post('email_username'), // 'email_password' => $this->input->post('email_password'), // 'email_service_provider' => $this->input->post('email_service_provider'), // 'email_expiry_date' => $this->input->post('email_expiry_date'), // 'no_of_emails' => $this->input->post('no_of_emails'), // 'delete_status' => 'ACTIVE', // 'created_at' => $created_at // ); // $insert_result = $this->yaskawa_model->insert($table,$insert_data); // if($insert_result) // { // echo json_encode(array('result'=>1 ,'message'=>'Data added successfully')); // } // else // { // echo json_encode(array('result'=>0,'message'=>"Data could not add")); // } // } public function add_client_assets() { $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $created_at = $date->format('Y-m-d H:i:s'); $table = 'client_assets'; $domain_asset_for = $this->input->post('domain_asset_for'); $hosting_asset_for = $this->input->post('hosting_asset_for'); $pg_asset_for = $this->input->post('pg_asset_for'); $sms_asset_for = $this->input->post('sms_asset_for'); $email_asset_for = $this->input->post('email_asset_for'); $domain_asset_for = $this->input->post('domain_asset_for'); if($domain_asset_for == "") { $domain_asset_for = ''; } $hosting_asset_for = $this->input->post('hosting_asset_for'); if($hosting_asset_for == "") { $hosting_asset_for = ''; } $pg_asset_for = $this->input->post('pg_asset_for'); if($pg_asset_for == "") { $pg_asset_for = ''; } $sms_asset_for = $this->input->post('sms_asset_for'); if($sms_asset_for == "") { $sms_asset_for = ''; } $email_asset_for = $this->input->post('email_asset_for'); if($email_asset_for == "") { $email_asset_for = ''; } $insert_data = array( 'domain_asset_for' => $domain_asset_for, 'domain_name' => $this->input->post('domain_name'), 'domain_server' => $this->input->post('domain_server'), 'domain_username' => $this->input->post('domain_username'), 'domain_password' => $this->input->post('domain_password'), 'domain_start_date' => $this->input->post('domain_start_date'), 'domain_expiry_date' => $this->input->post('domain_expiry_date'), 'domain_status' => $this->input->post('domain_status'), 'domain_space' => $this->input->post('domain_space'), 'domain_service_provider' => $this->input->post('domain_service_provider'), 'domain_name' => $this->input->post('domain_name'), 'account_id' => $this->input->post('account_id'), 'hosting_asset_for' => $hosting_asset_for, 'hosting_username' => $this->input->post('hosting_username'), 'hosting_password' => $this->input->post('hosting_password'), 'hosting_service_provider' => $this->input->post('hosting_service_provider'), 'hosting_expiry_date' => $this->input->post('hosting_expiry_date'), 'pg_asset_for' => $pg_asset_for, 'pg_username' => $this->input->post('pg_username'), 'pg_password' => $this->input->post('pg_password'), 'pg_service_provider' => $this->input->post('pg_service_provider'), 'pg_commission' => $this->input->post('pg_commission'), 'sms_asset_for' => $sms_asset_for, 'sms_username' => $this->input->post('sms_username'), 'sms_password' => $this->input->post('sms_password'), 'sms_service_provider' => $this->input->post('sms_service_provider'), 'sms_expiry_date' => $this->input->post('sms_expiry_date'), 'no_of_sms' => $this->input->post('no_of_sms'), 'email_asset_for' => $email_asset_for, 'email_username' => $this->input->post('email_username'), 'email_password' => $this->input->post('email_password'), 'email_service_provider' => $this->input->post('email_service_provider'), 'email_expiry_date' => $this->input->post('email_expiry_date'), 'no_of_emails' => $this->input->post('no_of_emails'), 'delete_status' => 'ACTIVE', 'created_at' => $created_at ); if($_FILES['upload']['size'][0]!= 0) { for($i=0;$i< count($_FILES['upload']['name']);$i++) { $target1='attach_file/'; $stamp = getdate(); $target1.=$stamp[0].basename($_FILES['upload']['name'][$i]); $target2=$stamp[0].basename($_FILES['upload']['name'][$i]); $g_url[]=$target2; move_uploaded_file($_FILES['upload']['tmp_name'][$i],$target1); } } $arr=array(); if(isset($g_url)) { foreach($g_url as $key=>$get_url) { array_push($arr,$get_url); } } $insert_data['attachment_upload']=json_encode($arr); $insert_result = $this->yaskawa_model->insert($table,$insert_data); if($insert_result) { echo json_encode(array('result'=>1 ,'message'=>'Data added successfully')); } else { echo json_encode(array('result'=>0,'message'=>"Data could not add")); } } public function client_assets_list() { $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $data['company_details'] = $this->yaskawa_model->fetch_company_details(); $data['domain_server'] = $this->yaskawa_model->get_domain_server(); $data['domain_service_provider'] = $this->yaskawa_model->get_domain_service_provider(); $data['hosting_service_provider'] = $this->yaskawa_model->get_hosting_service_provider(); $data['pg_service_provider'] = $this->yaskawa_model->pg_service_provider(); $data['sms_service_provider'] = $this->yaskawa_model->get_sms_service_provider(); $data['email_service_provider'] = $this->yaskawa_model->get_email_service_provider(); $data['accounts'] = $this->yaskawa_model->account_details(); $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count=0; foreach($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if($months=='11'){ $count+=1; } } $data['count']=$count; $this->load->view('admin/client_assets_list',$data); } else { redirect('/'); } } public function all_client_assets() { $result = $this->yaskawa_model->get_all_client_assets(); if($result) { echo json_encode($result); } else { echo json_encode(array('result'=>0)); } } public function single_client_asset() { $asset_id = $this->input->post('asset_id'); $table = 'client_assets'; $where = array('asset_id' => $asset_id,'delete_status' => 'ACTIVE'); $result = $this->yaskawa_model->get_where_row($table,$where); if($result) { echo json_encode(array('result'=>1,'single_asset'=>$result)); } else { echo json_encode(array('result'=>0)); } } public function delete_client_asset() { $table = 'client_assets'; $asset_id = $this->input->post('asset_id'); $master_type = $this->input->post('master_type'); $where = array('asset_id'=>$asset_id); if($master_type == 'Domain') { $data = array('domain_asset_for'=>''); } else if($master_type == 'Hosting') { $data = array('hosting_asset_for'=>''); } else if($master_type == 'Payment Gateway') { $data = array('pg_asset_for'=>''); } else if($master_type == 'SMS') { $data = array('sms_asset_for'=>''); } else if($master_type == 'Email') { $data = array('email_asset_for'=>''); } $result = $this->yaskawa_model->update($where,$table,$data); if($this->db->affected_rows() > 0) { echo json_encode(array('result'=>1,'message'=>'Deleted successfully')); } else { echo json_encode(array('result'=>0)); } } public function update_client_asset() { // $asset_id = $this->input->post('asset_id'); // $table = 'client_assets'; // $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); // $created_at = $date->format('Y-m-d H:i:s'); // $where = array('asset_id'=>$asset_id); // $data = array( // 'domain_name' => $this->input->post('domain_name'), // 'domain_server' => $this->input->post('domain_server'), // 'domain_username' => $this->input->post('domain_username'), // 'domain_password' => $this->input->post('domain_password'), // 'domain_start_date' => $this->input->post('domain_start_date'), // 'domain_expiry_date' => $this->input->post('domain_expiry_date'), // 'domain_status' => $this->input->post('domain_status'), // 'domain_space' => $this->input->post('domain_space'), // 'domain_service_provider' => $this->input->post('domain_service_provider'), // 'no_of_sms' => $this->input->post('no_of_sms'), // 'pg_commission' => $this->input->post('pg_commission'), // 'updated_at' => $created_at // ); // $result = $this->yaskawa_model->update($where,$table,$data); // if($this->db->affected_rows() > 0) // { // echo json_encode(array('result'=>1,'message'=>"Asset updated successfully")); // } // else // { // echo json_encode(array('result'=>0,'message'=>"Something went wrong..please try again later")); // } $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $created_at = $date->format('Y-m-d H:i:s'); $asset_id = $this->input->post('asset_id'); $master_type = $this->input->post('master_type'); $table = 'client_assets'; if($master_type == "Domain") { $data = array( 'domain_asset_for' => $this->input->post('domain_asset_for'), 'domain_name' => $this->input->post('domain_name'), 'domain_server' => $this->input->post('domain_server'), 'domain_username' => $this->input->post('domain_username'), 'domain_password' => $this->input->post('domain_password'), 'domain_start_date' => $this->input->post('domain_start_date'), 'domain_expiry_date' => $this->input->post('domain_expiry_date'), 'domain_status' => $this->input->post('domain_status'), 'domain_space' => $this->input->post('domain_space'), 'domain_service_provider' => $this->input->post('domain_service_provider'), 'updated_at' => $created_at ); } else if($master_type == "Hosting") { $data = array( 'hosting_asset_for' => $this->input->post('hosting_asset_for'), 'hosting_username' => $this->input->post('hosting_username'), 'hosting_password' => $this->input->post('hosting_password'), 'hosting_service_provider' => $this->input->post('hosting_service_provider'), 'hosting_expiry_date' => $this->input->post('hosting_expiry_date'), 'updated_at' => $created_at ); } else if($master_type == "Payment Gateway") { $data = array( 'pg_asset_for' => $this->input->post('pg_asset_for'), 'pg_username' => $this->input->post('pg_username'), 'pg_password' => $this->input->post('pg_password'), 'pg_service_provider' => $this->input->post('pg_service_provider'), 'pg_commission' => $this->input->post('pg_commission'), 'updated_at' => $created_at ); } else if($master_type == "SMS") { $data = array( 'sms_asset_for' => $this->input->post('sms_asset_for'), 'sms_username' => $this->input->post('sms_username'), 'sms_password' => $this->input->post('sms_password'), 'sms_service_provider' => $this->input->post('sms_service_provider'), 'sms_expiry_date' => $this->input->post('sms_expiry_date'), 'no_of_sms' => $this->input->post('no_of_sms'), 'updated_at' => $created_at ); } else if($master_type == "Email") { $data = array( 'email_asset_for' => $this->input->post('email_asset_for'), 'email_username' => $this->input->post('email_username'), 'email_password' => $this->input->post('email_password'), 'email_service_provider' => $this->input->post('email_service_provider'), 'email_expiry_date' => $this->input->post('email_expiry_date'), 'no_of_emails' => $this->input->post('no_of_emails'), 'updated_at' => $created_at ); } $where = array('asset_id'=>$asset_id); $result = $this->yaskawa_model->update($where,$table,$data); if($this->db->affected_rows() > 0) { echo json_encode(array('result'=>1,'message'=>"Asset updated successfully")); } else { echo json_encode(array('result'=>0,'message'=>"Something went wrong..please try again later")); } } public function search_account() { $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $val=$this->input->post('val'); $result=$this->yaskawa_model->search_account($val); echo json_encode($result); } else { redirect('/'); } } public function add_invoice_details() { $admin=$this->session->userdata('admin'); if($admin==''){ $admin=$this->session->userdata('user'); } $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $invoice=$this->input->post('invoice'); $date=$this->input->post('date'); $name=$this->input->post('name'); $explode=explode(':',$name); if(count($explode)==2) { $invoice_name=$explode[0]; $account_id=$explode[1]; } else { $invoice_name=$explode[0]; $account_id=0; } $invoice=$this->input->post('invoice'); $quotation_ids = $this->input->post('quotation_ids'); $address=$this->input->post('address'); $gstn=$this->input->post('gstn'); $sino=$this->input->post('sino'); $description=$this->input->post('description'); $sac=$this->input->post('sac'); $price=$this->input->post('price'); $sub_total=$this->input->post('sub_total'); $sub_total=str_replace(',', '', $sub_total); $cgst=$this->input->post('cgst'); $cgst_amount=$this->input->post('cgst_amount'); $cgst_amount=str_replace(',','',$cgst_amount); $sgst_amount=$this->input->post('sgst_amount'); $sgst_amount=str_replace(',', '', $sgst_amount); $sgst=$this->input->post('sgst'); $total_amount=$this->input->post('total_amount'); $total_amount=str_replace(',', '', $total_amount); if($sub_total==0|| $sub_total=='') { $sub_total=$total_amount; } $igst=$this->input->post('igst'); if(empty($igst)) { $igst=0; } if(empty($gstn)) { $gstn=0; } if(empty($cgst)) { $cgst=0; } if(empty($sgst)) { $sgst=0; } $igst_amount=$this->input->post('igst_amount'); $igst_amount=str_replace(',', '', $igst_amount); $quot_id=$this->input->post('quotation_id'); $grand_total=$this->input->post('grand_total'); $grand_total=str_replace(',', '', $grand_total); $total_amount_words=$this->input->post('amount_in_words'); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date = $date->format('Y-m-d H:i:s'); $invoce_data=array('invoice_date' =>$date, 'name' =>$invoice_name, 'invoice_no' =>$this->input->post('invoice'), 'igst' =>$igst, 'igst_amount' =>$igst_amount, 'address' =>$address, 'account_id' =>$account_id, 'gstn' =>$gstn, 'description' =>json_encode($description), 'sac' =>json_encode($sac), 'cgst' =>$cgst, 'sgst' =>$sgst, 'cgst_amount' =>$cgst_amount, 'price' =>json_encode($price), 'sgst_amount' =>$sgst_amount, 'total' =>$sub_total, 'total_amount' =>$total_amount, 'si_no' =>$sino, 'total_amount_words' =>$total_amount_words, 'invoice_type' =>$this->input->post('invoice_type'), 'grand_total' =>$grand_total, 'supply_to' =>$this->input->post('supply_to'), 'quotation_id' => $quotation_ids, 'supply_address' =>$this->input->post('supply_to_address'), 'created_at' =>$date, 'created_by' =>$admin, 'delete_status' =>'ACTIVE'); $result=$this->yaskawa_model->add_invoice($invoce_data); if($result) { //---------------------------16-10-2019------------------------// $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $created_at = $date->format('Y-m-d H:i:s'); $num_table = 'invoice_numbers'; $invoice_type = $this->input->post('invoice_type'); if($invoice_type == 'Normal') { $inv_data = array('invoice_type' => 'NORMAL','invoice_number' =>$this->input->post('new_invoice_num'),'delete_status' => 'ACTIVE','created_at' => $created_at); } else if($invoice_type == 'Profomo') { $inv_data = array('invoice_type' => 'PROFORMA','invoice_number' =>$this->input->post('new_pr_invoice_num'),'delete_status' => 'ACTIVE','created_at' => $created_at); } else if($invoice_type == 'Cash') { $inv_data = array('invoice_type' => 'CASH','invoice_number' =>$this->input->post('new_cash_invoice_num'),'delete_status' => 'ACTIVE','created_at' => $created_at); } $inv_result=$this->yaskawa_model->insert($num_table,$inv_data); //--------------------------------------------------------------// if($quot_id!=''){ $table="quotations"; $where=array('quotation_id'=>$quot_id); $data=array('quotation_status'=>'CLOSED'); $res=$this->yaskawa_model->update_invoice_payments($where,$data,$table); } echo json_encode(array('result'=>1,'message'=>"Invoice added successfully")); } else { echo json_encode(array('result'=>0,'message'=>"Something went wrong.. try again")); } } else { redirect('/'); } } public function invoice_list() { $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $table='masters'; $where_gst=array('field_label'=>'gst','delete_status'=>'ACTIVE'); $where_sgst=array('field_label'=>'sgst','delete_status'=>'ACTIVE'); $data_gst=$this->yaskawa_model->get_data_row($table,$where_gst); $data['gst']=json_decode($data_gst->field_value); $data_sgst=$this->yaskawa_model->get_data_row($table,$where_sgst); $data['invoice_id']=$this->yaskawa_model->get_invoice_id(); $data['sgst']=json_decode($data_sgst->field_value); $where=array('master_type_id'=>'19'); $table="masters"; $data['master']=$this->yaskawa_model->get_single_row($table,$where); $data['company_details']=$this->yaskawa_model->fetch_company_details(); $table='invoice'; $where=array('delete_status'=>'ACTIVE'); $data['invoice_list']=$this->yaskawa_model->get_data($table,$where); $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $data['company_details'] = $this->yaskawa_model->fetch_company_details(); $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count=0; foreach($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if($months=='11'){ $count+=1; } } $data['count']=$count; $this->load->view('admin/invoice_list',$data); } else { redirect('/'); } } public function edit_invoice() { $admin_id = $this->session->userdata('admin_id'); if($admin_id) { echo json_encode(array('result'=>1)); } else { redirect('/'); } } public function edit_invoice_disp() { $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $table="quotations"; $where=array('delete_status'=>'ACTIVE'); $data['quot']=$this->yaskawa_model->get_customer_result($table,$where); $table='masters'; $where_gst=array('field_label'=>'gst','delete_status'=>'ACTIVE'); $where_sgst=array('field_label'=>'sgst','delete_status'=>'ACTIVE'); $where_igst=array('field_label'=>'igst','delete_status'=>'ACTIVE'); $data_igst=$this->yaskawa_model->get_data_row($table,$where_igst); $data['igst']=json_decode($data_igst->field_value); $data_gst=$this->yaskawa_model->get_data_row($table,$where_gst); $data['gst']=json_decode($data_gst->field_value); $data_sgst=$this->yaskawa_model->get_data_row($table,$where_sgst); $data['invoice_id']=$this->yaskawa_model->get_invoice_id(); $data['sgst']=json_decode($data_sgst->field_value); $id=$this->uri->segment(2); $table='invoice'; $where=array('id'=>$id,'delete_status'=>'ACTIVE'); $data['result']=$this->yaskawa_model->get_data_row($table,$where); $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count=0; foreach($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if($months=='11'){ $count+=1; } } $data['count']=$count; //--------------------------------------------// $invoice_id = $this->uri->segment(2); $payment_table = "invoice_payments"; $where_payment = array('invoice_id'=>$invoice_id,'delete_status'=>'ACTIVE'); $data['payment_res'] = $this->yaskawa_model->get_single_invoice_payment_details($invoice_id); //--------------------------------------------// $this->load->view('admin/edit_invoice',$data); } else { redirect('/'); } } public function print_invoice_disp() { $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $table="quotations"; $where=array('delete_status'=>'ACTIVE'); $data['quot']=$this->yaskawa_model->get_customer_result($table,$where); $table='masters'; $where_gst=array('field_label'=>'gst','delete_status'=>'ACTIVE'); $where_sgst=array('field_label'=>'sgst','delete_status'=>'ACTIVE'); $where_igst=array('field_label'=>'igst','delete_status'=>'ACTIVE'); $data_igst=$this->yaskawa_model->get_data_row($table,$where_igst); $data['igst']=json_decode($data_igst->field_value); $data_gst=$this->yaskawa_model->get_data_row($table,$where_gst); $data['gst']=json_decode($data_gst->field_value); $data_sgst=$this->yaskawa_model->get_data_row($table,$where_sgst); $data['invoice_id']=$this->yaskawa_model->get_invoice_id(); $data['sgst']=json_decode($data_sgst->field_value); $id=$this->uri->segment(2); $table='invoice'; $where=array('id'=>$id,'delete_status'=>'ACTIVE'); $data['result']=$this->yaskawa_model->get_data_row($table,$where); $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count=0; foreach($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if($months=='11'){ $count+=1; } } $id=$this->uri->segment(2); $table='invoice_payments'; $where=array('invoice_id'=>$id,'delete_status'=>'ACTIVE'); $payment_result=$this->yaskawa_model->get_data($table,$where); $result1 = array(); foreach($payment_result as $val){ $pay_result['payment_type']=$val->payment_type; $pay_result['id']=$val->payment_id; $pay_result['name']=$val->favour_of; $pay_result['cheque_no']=$val->cheque_no; $pay_result['cheque_date']=$val->cheque_date; $pay_result['dd_no']=$val->dd_no; $pay_result['dd_date']=$val->dd_date; $pay_result['utr_no']=$val->utr_no; $pay_result['online_date']=$val->online_date; $pay_result['bank_name']=$val->bank_name; $pay_result['branch_name']=$val->branch_name; $pay_result['collected_by']=$val->collected_by; $invoce_amount=number_format($val->amount); $pay_result['paid_amount']=$invoce_amount; // print_r( $pay_result); die(); array_push($result1,$pay_result); } $data['payment_details'] = $result1; $data['count']=$count; //$this->load->view('admin/edit_invoice',$data); $this->load->view('admin/print_invoice_list',$data); } else { redirect('/'); } } public function delete_invoice() { $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $invoice_id = $this->input->post('id'); $table ='invoice'; $data = array('delete_status'=>'INACTIVE'); $where =array('id'=>$invoice_id,'delete_status'=>'ACTIVE'); $result = $this->yaskawa_model->delete_detail($where,$data,$table); if($result) { echo json_encode(array('result'=>1,'message'=>'Deleted successfully')); } else { echo json_encode(array('result'=>0)); } } else { redirect('/'); } } public function cancel_invoice() { $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $invoice_id = $this->input->post('id'); $table ='invoice'; $data = array('invoice_status'=>'CANCELLED'); $where =array('id'=>$invoice_id,'delete_status'=>'ACTIVE'); $result = $this->yaskawa_model->delete_detail($where,$data,$table); if($result) { echo json_encode(array('result'=>1,'message'=>'Deleted successfully')); } else { echo json_encode(array('result'=>0)); } } else { redirect('/'); } } public function update_invoice_details() { $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $invoice=$this->input->post('invoice'); $invoice_date=$this->input->post('date'); $invoice_date=date('Y-m-d',strtotime($invoice_date)); $name=$this->input->post('name'); $explode=explode(':',$name); if(count($explode)==2) { $invoice_name=$explode[0]; $account_id=$explode[1]; } else { $invoice_name=$explode[0]; $account_id=$this->input->post('account_id'); } $address_new=$this->input->post('address'); $invoice=$this->input->post('invoice'); $address=$this->input->post('address'); $gstn=$this->input->post('gstn'); $sino=$this->input->post('sino'); $description=$this->input->post('description'); $sac=$this->input->post('sac'); $price=$this->input->post('price'); $price1=str_replace(',','',$price); $sub_total=$this->input->post('sub_total'); $sub_total1=str_replace(',','',$sub_total); $cgst=$this->input->post('cgst'); $cgst_amount=$this->input->post('cgst_amount'); $cgst_amount1=str_replace(',','',$cgst_amount); $igst=$this->input->post('igst'); $igst_amount=$this->input->post('igst_amount'); $igst_amount=str_replace(',','',$igst_amount); $sgst_amount=$this->input->post('sgst_amount'); $sgst_amount1=str_replace(',','',$sgst_amount); $sgst=$this->input->post('sgst'); $grand_total_amount=$this->input->post('total_amount'); $total_amount1=str_replace(',','',$grand_total_amount); // $tds_amount=$this->input->post('tds_amount'); // $tds_amount=str_replace(',','',$tds_amount); $g_total=$this->input->post('grand_total'); $g_total=str_replace(',','',$g_total); $total_amount_words=$this->input->post('amount_in_words'); $admin=$this->session->userdata('admin'); if($admin==''){ $admin=$this->session->userdata('user'); } $date= date('Y-m-d'); $invoce_data=array('invoice_date' =>$invoice_date, //'account_id' =>$account_id, 'igst' =>$igst, 'igst_amount' =>$igst_amount, 'name' =>$invoice_name, 'invoice_no' =>$this->input->post('invoice_no'), 'account_id' =>$account_id, 'address' =>$address_new, 'gstn' =>$gstn, 'description' =>json_encode($description), 'sac' =>json_encode($sac), 'cgst' =>$cgst, 'sgst' =>$sgst, 'cgst_amount' =>$cgst_amount1, 'price' =>json_encode($price1), 'sgst_amount' =>$sgst_amount1, 'total' =>$sub_total1, 'total_amount' =>$total_amount1, 'si_no' =>$sino, 'tds_amount' =>0, 'grand_total' =>$g_total, 'updated_by' =>$admin, 'invoice_type' =>$this->input->post('invoice_type'), 'total_amount_words' =>$total_amount_words, 'supply_to' =>$this->input->post('supply_to'), 'supply_address'=>$this->input->post('supply_to_address'), 'updated_at' =>$date); $table='invoice'; $id=$this->input->post('id'); $where=array('id'=>$id,'delete_status'=>'ACTIVE'); $result=$this->yaskawa_model->delete_detail($where,$invoce_data,$table); if($result) { echo json_encode(array('result'=>1,'id'=>$invoice)); } else { echo json_encode(array('result'=>0,'message'=>"Something went wrong.. try again")); } } else { redirect('/'); } } public function view_invoice_list() { $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $data['company_details']=$this->yaskawa_model->fetch_company_details(); $table='invoice'; $where=array('delete_status'=>'ACTIVE'); $result=$this->yaskawa_model->get_data_new_invoice($table,$where); if($result) { echo json_encode($result); } else { echo json_encode(array('result'=>0,'message'=>'No data Found')); } } else { redirect('/'); } } public function pending_invoice_list() { $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $data['company_details']=$this->yaskawa_model->fetch_company_details(); $table='invoice'; $where=array('delete_status'=>'ACTIVE','invoice_status'=>'PENDING'); $result=$this->yaskawa_model->get_data_new_invoice($table,$where); if($result) { echo json_encode($result); } else { echo json_encode(array('result'=>0,'message'=>'No data Found')); } } else { redirect('/'); } } public function cancelled_invoice_list() { $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $data['company_details']=$this->yaskawa_model->fetch_company_details(); $table='invoice'; $where=array('delete_status'=>'ACTIVE','invoice_status'=>'CANCELLED'); $result=$this->yaskawa_model->get_data_new_invoice($table,$where); if($result) { echo json_encode($result); } else { echo json_encode(array('result'=>0,'message'=>'No data Found')); } } else { redirect('/'); } } public function cleared_invoice_list() { $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $data['company_details']=$this->yaskawa_model->fetch_company_details(); $table='invoice'; $where=array('delete_status'=>'ACTIVE','invoice_status'=>'CLEARED'); $result=$this->yaskawa_model->get_data_new_invoice($table,$where); if($result) { echo json_encode($result); } else { echo json_encode(array('result'=>0,'message'=>'No data Found')); } } else { redirect('/'); } } public function partial_invoice_list() { $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $data['company_details']=$this->yaskawa_model->fetch_company_details(); $table='invoice'; $where=array('delete_status'=>'ACTIVE','invoice_status'=>'PARTIAL'); $result=$this->yaskawa_model->get_data_new_invoice($table,$where); if($result) { echo json_encode($result); } else { echo json_encode(array('result'=>0,'message'=>'No data Found')); } } else { redirect('/'); } } public function offer_letter() { $emp_id = $this->uri->segment(2); // Ensure that the employee data is being fetched correctly $data['employee_result'] = $this->yaskawa_model->get_employee_designation($emp_id); // Debugging: check if employee result is fetched if (!$data['employee_result']) { // Log error or show a message if employee data isn't found log_message('error', 'No employee data found for emp_id: ' . $emp_id); } $data['company_details'] = $this->yaskawa_model->fetch_company_details(); $table = "new_account"; $where = array('delete_status' => 'ACTIVE'); $res = $this->yaskawa_model->get_customer_result($table, $where); // Calculate the count of records where months = 11 $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count = 0; foreach ($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365 * 60 * 60 * 24)); $months = floor(($diff - $years * 365 * 60 * 60 * 24) / (30 * 60 * 60 * 24)); $days = floor(($diff - $years * 365 * 60 * 60 * 24 - $months * 30 * 60 * 60 * 24) / (60 * 60 * 24)); if ($months == '11') { $count += 1; } } $data['count'] = $count; // Load the view $this->load->view('admin/offer_letter', $data); } public function get_employee_details() { $emp_id = $this->input->post('id'); $where = array('delete_status'=>'ACTIVE','emp_id'=>$emp_id); $table="employees"; $employee_result = $this->yaskawa_model->get_data_row($table,$where); if($employee_result) { echo json_encode(array('result'=>1,'details'=>$employee_result)); } else { echo json_encode(array('result'=>0)); } } public function get_account_address(){ $acc_id = $this->input->post('acc_id'); $table="new_account"; $where=array('account_id'=>$acc_id,'delete_status'=>'ACTIVE'); $result=$this->yaskawa_model->get_single_row($table,$where); echo json_encode($result); } //client requirement public function search_project() { $project_name = $this->input->post('project_name'); $result = $this->yaskawa_model->search_project($project_name); if($result) { echo json_encode(array('result'=>1,'project_list'=>$result)); } else { echo json_encode(array('result'=>0)); } } public function add_client_requirement() { $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $created_at = $date->format('Y-m-d H:i:s'); $table = 'client_requirements'; $searched_project = $this->input->post('searched_project'); $insert_data = array( 'entered_by' => $this->session->userdata('admin_id'), 'completion_status' =>$this->input->post('completion_status'), 'project_id' => $this->input->post('project_id'), 'project_comments' => $this->input->post('project_comments'), 'client_name' => $this->input->post('client_name'), 'client_name_comments' => $this->input->post('client_name_comments'), 'contact_number' => $this->input->post('contact_number'), 'contact_number_comments' => $this->input->post('contact_number_comments'), 'email' => $this->input->post('email'), 'email_comments' => $this->input->post('email_comments'), 'website' => $this->input->post('website'), 'website_comments' => $this->input->post('website_comments'), 'industry_type' => $this->input->post('industry_type'), 'industry_type_comments' => $this->input->post('industry_type_comments'), 'website_type' => $this->input->post('website_type'), 'website_type_comments' => $this->input->post('website_type_comments'), 'client_domain' => $this->input->post('client_domain'), 'client_domain_comments' => $this->input->post('client_domain_comments'), 'client_server' => $this->input->post('client_server'), 'client_server_comments' => $this->input->post('client_server_comments'), 'reference_shared' => $this->input->post('reference_shared'), 'reference_shared_comments' => $this->input->post('reference_shared_comments'), 'logo' => $this->input->post('logo'), 'logo_comments' => $this->input->post('logo_comments'), 'blog' => $this->input->post('blog'), 'blog_comments' => $this->input->post('blog_comments'), 'no_of_templates' => $this->input->post('no_of_templates'), 'template_comments' => $this->input->post('template_comments'), 'template_concept' => $this->input->post('template_concept'), 'template_concept_comments' => $this->input->post('template_concept_comments'), 'approved_date' => $this->input->post('approved_date'), 'approved_date_comments' => $this->input->post('approved_date_comments'), 'content_received_date' => $this->input->post('content_received_date'), 'content_received_date_comments' => $this->input->post('content_received_date_comments'), 'development_start_date' => $this->input->post('development_start_date'), 'development_start_date_comments' => $this->input->post('development_start_date_comments'), 'development_end_date' => $this->input->post('development_end_date'), 'development_end_date_comments' => $this->input->post('development_end_date_comments'), 'testing' => $this->input->post('testing'), 'testing_comments' => $this->input->post('testing_comments'), 'website_live_date' => $this->input->post('website_live_date'), 'website_live_comments' => $this->input->post('website_live_comments'), 'changes' => $this->input->post('changes'), 'changes_comments' => $this->input->post('changes_comments'), 'email_provided' => $this->input->post('email_provided'), 'email_provided_comments' => $this->input->post('email_provided_comments'), 'google_analytics' => $this->input->post('google_analytics'), 'google_analytics_comments' => $this->input->post('google_analytics_comments'), 'payment_gateway' => $this->input->post('payment_gateway'), 'payment_gateway_comments' => $this->input->post('payment_gateway_comments'), 'seo' => $this->input->post('seo'), 'seo_comments' => $this->input->post('seo_comments'), 'ssl' => $this->input->post('ssl'), 'ssl_comments' => $this->input->post('ssl_comments'), 'bulk_sms' => $this->input->post('bulk_sms'), 'bulk_sms_comments' => $this->input->post('bulk_sms_comments'), 'adwards' => $this->input->post('adwards'), 'adwards_comments' => $this->input->post('adwards_comments'), 'support_number' => $this->input->post('support_number'), 'support_number_comments' => $this->input->post('support_number_comments'), 'client_username' => $this->input->post('client_username'), 'client_password' => $this->input->post('client_password'), 'client_login_comments' => $this->input->post('client_login_comments'), 'delete_status' => 'ACTIVE', 'created_at' => $created_at ); $where = array('client_username' => $this->input->post('client_username'),'client_password' => $this->input->post('client_password')); $where_web = array('website' => $this->input->post('website')); $order_by = 'client_requirement_id'; $check = $this->yaskawa_model->get_where_orderby_row($table,$where,$order_by); $check_web = $this->yaskawa_model->get_where_orderby_row($table,$where_web,$order_by); if($check) { echo json_encode(array('result'=>0,'message'=>"Username or password already exists")); } else { $insert_result = $this->yaskawa_model->insert($table,$insert_data); if($insert_result) { // include("admin_assets/mpdf60/mpdf.php"); // $mpdf=new mPDF('A4'); $mpdf = new Mpdf(); $mpdf->mirrorMargins = 1; $html = ''; $index = 1; $email_content = ''; $email_content.= '<div style="margin-left:10%;width: 1015px;">'; $email_content.= '<form id="land_owner" class="form-inline client_form" enctype="multipart/form-data">'; $email_content.= '<h3 style="text-align:center;">Client Sheet</h3>'; $email_content.= '<div class="row_1">'; $email_content.= '<table border="1" style="width:100%;border-collapse: collapse;">'; $email_content.= '<tr>'; $email_content.= '<td colspan="2" style="padding: 5px;width:60%;"></td>'; $email_content.= '<td style="padding: 5px;width:40%;">Entered by '.$this->session->userdata('admin').'</td></td>'; $email_content.= '</tr>'; $email_content.= '<tr>'; $email_content.= '<td style="padding: 5px;">Project Name</td>'; $email_content.= '<td style="padding: 5px;">'.$searched_project.'</td>'; $email_content.= '<td style="padding: 5px;">'.$this->input->post('project_comments').'</td></td>'; $email_content.= '</tr>'; $email_content.= '<tr>'; $email_content.= '<td style="padding: 5px;">Name of the Client</td>'; $email_content.= '<td style="padding: 5px;">'.$this->input->post('client_name').'</td>'; $email_content.= '<td style="padding: 5px;">'.$this->input->post('client_name_comments').'</td></td>'; $email_content.= '</tr>'; $email_content.= '<tr>'; $email_content.= '<td style="padding: 5px;">Contact Number</td>'; $email_content.= '<td style="padding: 5px;">'.$this->input->post('contact_number').'</td>'; $email_content.= '<td style="padding: 5px;">'.$this->input->post('contact_number_comments').'</td></td>'; $email_content.= '</tr>'; $email_content.= '<tr>'; $email_content.= '<td style="padding: 5px;">Contact Email</td>'; $email_content.= '<td style="padding: 5px;">'.$this->input->post('email').'</td>'; $email_content.= '<td style="padding: 5px;">'.$this->input->post('email_comments').'</td></td>'; $email_content.= '</tr>'; $email_content.= '<tr>'; $email_content.= '<td style="padding: 5px;">Website</td>'; $email_content.= '<td style="padding: 5px;">'.$this->input->post('website').'</td>'; $email_content.= '<td style="padding: 5px;">'.$this->input->post('website_comments').'</td></td>'; $email_content.= '</tr>'; $email_content.= '</table>'; $email_content.= '</div>'; $email_content.= '<div class="row_2" style="padding-top:30px;">'; $email_content.= '<table border="1" style="width:100%;border-collapse: collapse;">'; $email_content.= '<tr>'; $email_content.= '<td style="padding: 5px;">Type of Industry </td>'; $email_content.= '<td style="padding: 5px;">'.$this->input->post('industry_type').'</td>'; $email_content.= '<td style="padding: 5px;">'.$this->input->post('industry_type_comments').'</td>'; $email_content.= '</tr>'; $email_content.= '<tr>'; $email_content.= '<td style="padding: 5px;">website Type <br>(static/dynamic/e-commerce) </td>'; $email_content.= '<td style="padding: 5px;">'.$this->input->post('website_type').'</td>'; $email_content.= '<td style="padding: 5px;">'.$this->input->post('website_type_comments').'</td></td>'; $email_content.= '</tr>'; $email_content.= '<tr>'; $email_content.= '<td style="padding: 5px;">Client Domain (Y/N)</td>'; $email_content.= '<td style="padding: 5px;">'.$this->input->post('client_domain').'</td>'; $email_content.= '<td style="padding: 5px;">'.$this->input->post('client_domain_comments').'</td></td>'; $email_content.= '</tr>'; $email_content.= '<tr>'; $email_content.= '<td style="padding: 5px;">Client Server (Y/N)</td>'; $email_content.= '<td style="padding: 5px;">'.$this->input->post('client_server').'</td>'; $email_content.= '<td style="padding: 5px;">'.$this->input->post('client_server_comments').'</td></td>'; $email_content.= '</tr>'; $email_content.= '<tr>'; $email_content.= '<td style="padding: 5px;">Reference shared <br>and color combination</td>'; $email_content.= '<td style="padding: 5px;">From US:<br>'; $email_content.= 'OR<br>'; $email_content.= 'From Client: '.$this->input->post('reference_shared').'</td>'; $email_content.= '<td style="padding: 5px;">'.$this->input->post('reference_shared_comments').'</td></td>'; $email_content.= '</tr>'; $email_content.= '<tr>'; $email_content.= '<td style="padding: 5px;">Logo (Y/N)</td>'; $email_content.= '<td style="padding: 5px;">'.$this->input->post('logo').'</td>'; $email_content.= '<td style="padding: 5px;">'.$this->input->post('logo_comments').'</td></td>'; $email_content.= '</tr>'; $email_content.= '<tr>'; $email_content.= '<td style="padding: 5px;">Blog (Y/N)</td>'; $email_content.= '<td style="padding: 5px;">'.$this->input->post('blog').'</td>'; $email_content.= '<td style="padding: 5px;">'.$this->input->post('blog_comments').'</td></td>'; $email_content.= '</tr>'; $email_content.= '<tr>'; $email_content.= '<td style="padding: 5px;">Number of templates shared</td>'; $email_content.= '<td style="padding: 5px;">'.$this->input->post('no_of_templates').'</td>'; $email_content.= '<td style="padding: 5px;">'.$this->input->post('template_comments').'</td></td>'; $email_content.= '</tr>'; $email_content.= '<tr>'; $email_content.= '<td style="padding: 5px;">Templates shared (concepts shared) date</td>'; $email_content.= '<td style="padding: 5px;">'.$this->input->post('template_concept').'</td>'; $email_content.= '<td style="padding: 5px;">'.$this->input->post('template_concept_comments').'</td></td>'; $email_content.= '</tr>'; $email_content.= '<tr>'; $email_content.= '<td style="padding: 5px;">Approved date</td>'; $email_content.= '<td style="padding: 5px;">'.$this->input->post('approved_date').'</td>'; $email_content.= '<td style="padding: 5px;">'.$this->input->post('approved_date_comments').'</td></td>'; $email_content.= '</tr>'; $email_content.= '<tr>'; $email_content.= '<td style="padding: 5px;">Content received date </td>'; $email_content.= '<td style="padding: 5px;">'.$this->input->post('content_received_date').'</td>'; $email_content.= '<td style="padding: 5px;">'.$this->input->post('content_received_date_comments').'</td></td>'; $email_content.= '</tr>'; $email_content.= '<tr>'; $email_content.= '<td style="padding: 5px;">Development Start date</td>'; $email_content.= '<td style="padding: 5px;">'.$this->input->post('development_start_date').'</td>'; $email_content.= '<td style="padding: 5px;">'.$this->input->post('development_start_date_comments').'</td></td>'; $email_content.= '</tr>'; $email_content.= '<tr>'; $email_content.= '<td style="padding: 5px;">Development End date</td>'; $email_content.= '<td style="padding: 5px;">'.$this->input->post('development_end_date').'</td>'; $email_content.= '<td style="padding: 5px;">'.$this->input->post('development_end_date').'</td></td>'; $email_content.= '</tr>'; $email_content.= '<tr>'; $email_content.= '<td style="padding: 5px;">Testing </td>'; $email_content.= '<td style="padding: 5px;">'.$this->input->post('testing').'</td>'; $email_content.= '<td style="padding: 5px;">'.$this->input->post('testing_comments').'</td></td>'; $email_content.= '</tr>'; $email_content.= '<tr>'; $email_content.= '<td style="padding: 5px;">Website live date</td>'; $email_content.= '<td style="padding: 5px;">'.$this->input->post('website_live_date').'</td>'; $email_content.= '<td style="padding: 5px;">'.$this->input->post('website_live_comments').'</td></td>'; $email_content.= '</tr>'; $email_content.= '<tr>'; $email_content.= '<td style="padding: 5px;">Changes (No. of times and days)</td>'; $email_content.= '<td style="padding: 5px;">'.$this->input->post('changes').'</td>'; $email_content.= '<td style="padding: 5px;">'.$this->input->post('changes_comments').'</td></td>'; $email_content.= '</tr>'; $email_content.= '<tr>'; $email_content.= '<td style="padding: 5px;">Email ID provided (Y/N)</td>'; $email_content.= '<td style="padding: 5px;">'.$this->input->post('email_provided').'</td>'; $email_content.= '<td style="padding: 5px;">'.$this->input->post('email_provided_comments').'</td></td>'; $email_content.= '</tr>'; $email_content.= '<tr>'; $email_content.= '<td style="padding: 5px;">Google Analytics (Y/N)</td>'; $email_content.= '<td style="padding: 5px;">'.$this->input->post('google_analytics').'</td>'; $email_content.= '<td style="padding: 5px;">'.$this->input->post('google_analytics_comments').'</td></td>'; $email_content.= '</tr>'; $email_content.= '<tr>'; $email_content.= '<td style="padding: 5px;">Payment Gateway(Y/N)</td>'; $email_content.= '<td style="padding: 5px;">'.$this->input->post('payment_gateway').'</td>'; $email_content.= '<td style="padding: 5px;">'.$this->input->post('payment_gateway_comments').'</td></td>'; $email_content.= '</tr>'; $email_content.= '<tr>'; $email_content.= '<td style="padding: 5px;">SEO </td>'; $email_content.= '<td style="padding: 5px;">'.$this->input->post('seo').'</td>'; $email_content.= '<td style="padding: 5px;">'.$this->input->post('seo_comments').'</td></td>'; $email_content.= '</tr>'; $email_content.= '<tr>'; $email_content.= '<td style="padding: 5px;">SSL certificate</td>'; $email_content.= '<td style="padding: 5px;">'.$this->input->post('ssl').'</td>'; $email_content.= '<td style="padding: 5px;">'.$this->input->post('ssl_comments').'</td></td>'; $email_content.= '</tr>'; $email_content.= '<tr>'; $email_content.= '<td style="padding: 5px;">Bulk SMS </td>'; $email_content.= '<td style="padding: 5px;">'.$this->input->post('bulk_sms').'</td>'; $email_content.= '<td style="padding: 5px;">'.$this->input->post('bulk_sms_comments').'</td></td>'; $email_content.= '</tr>'; $email_content.= '<tr>'; $email_content.= '<td style="padding: 5px;">Adwords</td>'; $email_content.= '<td style="padding: 5px;">'.$this->input->post('adwards').'</td>'; $email_content.= '<td style="padding: 5px;">'.$this->input->post('adwards_comments').'</td></td>'; $email_content.= '</tr>'; $email_content.= '<tr>'; $email_content.= '<td style="padding: 5px;">Support Number </td>'; $email_content.= '<td style="padding: 5px;">'.$this->input->post('support_number').'</td>'; $email_content.= '<td style="padding: 5px;">'.$this->input->post('support_number_comments').'</td></td>'; $email_content.= '</tr>'; $email_content.= '<tr>'; $email_content.= '<td style="padding: 5px;">Clients Individual ERP login </td>'; $email_content.= '<td style="padding: 5px;"><br>'; $email_content.= 'Username: '.$this->input->post('client_username').'<br>'; $email_content.= 'Password: '.$this->input->post('client_password').'</td>'; $email_content.= '<td style="padding: 5px;">'.$this->input->post('client_login_comments').'</td></td>'; $email_content.= '</tr>'; $email_content.= '</table>'; $email_content.= '</div>'; $email_content.= '</form>'; $email_content.= '</div>'; $mpdf->SetDisplayMode('fullpage'); $mpdf->watermark_font = 'DejaVuSansCondensed'; $mpdf->showWatermarkText = true; $mpdf->WriteHTML($email_content); $name = 'client_sheet'.$insert_result.'.pdf'; $pdf = $mpdf->Output("./client_requirements/".$name, 'F'); $this->load->library('email'); $phpMailer = new PHPMailer(true); $phpMailer->isSMTP(); $phpMailer->Host = "smtp.zoho.com"; $phpMailer->SMTPAuth = true; $phpMailer->Username = "sales@jayblues.com"; $phpMailer->Password = "m7uMqE8MFMR8"; $phpMailer->SMTPSecure = "tls"; $phpMailer->Port = 587; $phpMailer->setFrom("sales@jayblues.com", "Jayblues"); $phpMailer->addAttachment($_SERVER["DOCUMENT_ROOT"].'/jayerp/client_requirements/'.$name); $phpMailer->addAddress('kvy547@gmail.com'); $phpMailer->isHTML(true); $phpMailer->CharSet = 'UTF-8'; $phpMailer->Subject = 'Client Sheet'; $phpMailer->Body = $email_content; $phpMailer->send(); echo json_encode(array('result'=>1 ,'message'=>'Requirements added successfully')); } else { echo json_encode(array('result'=>0,'message'=>"Data could not add")); } } } public function get_project_account_details() { $account_id = $this->input->post('account_id'); $table = 'new_account'; $where = array('account_id' => $account_id,'delete_status' => 'ACTIVE'); $result = $this->yaskawa_model->get_where_row($table,$where); if($result) { echo json_encode(array('result'=>1,'project_details'=>$result)); } else { echo json_encode(array('result'=>0)); } } public function approve_quotation() { $id=$this->input->post('id'); $table="quotations"; $where=array('quotation_id'=>$id,'delete_status'=>'ACTIVE'); $data= array('convert_status'=>'APPROVED'); $result=$this->yaskawa_model->update($where,$table,$data); if($result) { echo json_encode(array('result'=>1 ,'message'=>'Quotetion Approved')); } else { echo json_encode(array('result'=>0,'message'=>"Quotetion Not Approved")); } } //client requirement list public function client_requirement_list() { $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $data['session_id'] = $admin_id; $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $data['company_details'] = $this->yaskawa_model->fetch_company_details(); $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count=0; foreach($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if($months=='11'){ $count+=1; } } $data['count']=$count; $this->load->view('admin/client_requirement_list',$data); } else { redirect('/'); } } public function all_client_requirements() { $result = $this->yaskawa_model->all_client_requirements(); if($result) { echo json_encode($result); } else { echo json_encode(array('result'=>0)); } } public function all_client_completed_requirements() { $result = $this->yaskawa_model->all_client_completed_requirements(); if($result) { echo json_encode($result); } else { echo json_encode(array('result'=>0)); } } public function all_client_closed_requirements() { $result = $this->yaskawa_model->all_client_closed_requirements(); if($result) { echo json_encode($result); } else { echo json_encode(array('result'=>0)); } } public function all_client_ongoing_requirements() { $result = $this->yaskawa_model->all_client_ongoing_requirements(); if($result) { echo json_encode($result); } else { echo json_encode(array('result'=>0)); } } public function delete_client_requirement() { $table = 'client_requirements'; $client_requirement_id = $this->input->post('client_requirement_id'); $where = array('client_requirement_id'=>$client_requirement_id); $data = array('delete_status'=>'INACTIVE'); $result = $this->yaskawa_model->update($where,$table,$data); if($this->db->affected_rows() > 0) { echo json_encode(array('result'=>1,'message'=>'Deleted successfully')); } else { echo json_encode(array('result'=>0)); } } public function edit_client_requirement() { $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $client_requirement_id = $this->uri->segment(2); $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $data['status_details']=$this->yaskawa_model->get_lead_status_details(); $data['company_details'] = $this->yaskawa_model->fetch_company_details(); $table = 'client_requirements'; $where = array('client_requirement_id' => $client_requirement_id,'delete_status' => 'ACTIVE'); $data['client_requirement'] =$c = $this->yaskawa_model->single_client_requirement($client_requirement_id); $u_industry=$c->u_industry; $u_web_type=$c->u_web_type; $table="users"; $where=array('user_id'=>$u_industry,'delete_status'=>'ACTIVE'); $data['u_industry']=$this->yaskawa_model->get_single_row($table,$where); $where=array('user_id'=>$u_web_type,'delete_status'=>'ACTIVE'); $data['web_type_name']=$this->yaskawa_model->get_single_row($table,$where); $where=array('user_id'=>$c->u_domain_id,'delete_status'=>'ACTIVE'); $data['domain_name']=$this->yaskawa_model->get_single_row($table,$where); $where=array('user_id'=>$c->u_client_server_id,'delete_status'=>'ACTIVE'); $data['server_name']=$this->yaskawa_model->get_single_row($table,$where); $where=array('user_id'=>$c->reference_id,'delete_status'=>'ACTIVE'); $data['reference_name']=$this->yaskawa_model->get_single_row($table,$where); $where=array('user_id'=>$c->u_logo_id,'delete_status'=>'ACTIVE'); $data['logo_name']=$this->yaskawa_model->get_single_row($table,$where); $where=array('user_id'=>$c->u_blog_id,'delete_status'=>'ACTIVE'); $data['blog_name']=$this->yaskawa_model->get_single_row($table,$where); $where=array('user_id'=>$c->u_template_id,'delete_status'=>'ACTIVE'); $data['temp_name']=$this->yaskawa_model->get_single_row($table,$where); $where=array('user_id'=>$c->u_temp_concept_id,'delete_status'=>'ACTIVE'); $data['concept_name']=$this->yaskawa_model->get_single_row($table,$where); $where=array('user_id'=>$c->u_approved_id,'delete_status'=>'ACTIVE'); $data['approve_name']=$this->yaskawa_model->get_single_row($table,$where); $where=array('user_id'=>$c->u_content_id,'delete_status'=>'ACTIVE'); $data['content_name']=$this->yaskawa_model->get_single_row($table,$where); $where=array('user_id'=>$c->u_development_id,'delete_status'=>'ACTIVE'); $data['develop_name']=$this->yaskawa_model->get_single_row($table,$where); $where=array('user_id'=>$c->u_end_id,'delete_status'=>'ACTIVE'); $data['end_name']=$this->yaskawa_model->get_single_row($table,$where); $where=array('user_id'=>$c->u_testing_id,'delete_status'=>'ACTIVE'); $data['test_name']=$this->yaskawa_model->get_single_row($table,$where); $where=array('user_id'=>$c->u_website_id,'delete_status'=>'ACTIVE'); $data['web_ser_name']=$this->yaskawa_model->get_single_row($table,$where); $where=array('user_id'=>$c->u_change_id,'delete_status'=>'ACTIVE'); $data['change_name']=$this->yaskawa_model->get_single_row($table,$where); $where=array('user_id'=>$c->u_email_id,'delete_status'=>'ACTIVE'); $data['email_name']=$this->yaskawa_model->get_single_row($table,$where); $where=array('user_id'=>$c->u_analytic_id,'delete_status'=>'ACTIVE'); $data['analytic_name']=$this->yaskawa_model->get_single_row($table,$where); $where=array('user_id'=>$c->u_gateway_id,'delete_status'=>'ACTIVE'); $data['gateway_name']=$this->yaskawa_model->get_single_row($table,$where); $where=array('user_id'=>$c->u_seo_id,'delete_status'=>'ACTIVE'); $data['seo_name']=$this->yaskawa_model->get_single_row($table,$where); $where=array('user_id'=>$c->u_ssl_id,'delete_status'=>'ACTIVE'); $data['ssl_name']=$this->yaskawa_model->get_single_row($table,$where); $where=array('user_id'=>$c->u_bulksms_id,'delete_status'=>'ACTIVE'); $data['bulk_name']=$this->yaskawa_model->get_single_row($table,$where); $where=array('user_id'=>$c->u_adward_id,'delete_status'=>'ACTIVE'); $data['adward_name']=$this->yaskawa_model->get_single_row($table,$where); $where=array('user_id'=>$c->u_support_id,'delete_status'=>'ACTIVE'); $data['support_name']=$this->yaskawa_model->get_single_row($table,$where); $where=array('user_id'=>$c->u_completion_id,'delete_status'=>'ACTIVE'); $data['completion_name']=$this->yaskawa_model->get_single_row($table,$where); $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count=0; foreach($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if($months=='11'){ $count+=1; } } $data['count']=$count; $data['industry_details']=$this->yaskawa_model->get_lead_industry_details(); $this->load->view('admin/edit_client_requirement',$data); } else { redirect('/'); } } public function update_client_requirement(){ $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $created_at = $date->format('Y-m-d H:i:s'); $table = 'client_requirements'; $searched_project = $this->input->post('searched_project'); $live_date=$this->input->post('website_live_date'); if($live_date!='00-00-0000' && $live_date!=''){ $live_date=date('d-m-Y',strtotime($live_date)); }else{ $live_date='00-00-0000'; } $data = array( 'project_id' => $this->input->post('project_id'), 'project_comments' => $this->input->post('project_comments'), 'client_name' => $this->input->post('client_name'), 'client_name_comments' => $this->input->post('client_name_comments'), 'contact_number' => $this->input->post('contact_number'), 'contact_number_comments' => $this->input->post('contact_number_comments'), 'email' => $this->input->post('email'), 'email_comments' => $this->input->post('email_comments'), 'website' => $this->input->post('website'), 'website_comments' => $this->input->post('website_comments'), 'industry_type' => $this->input->post('industry_type'), 'industry_type_comments' => $this->input->post('industry_type_comments'), 'website_type' => $this->input->post('website_type'), 'website_type_comments' => $this->input->post('website_type_comments'), 'client_domain' => $this->input->post('client_domain'), 'client_domain_comments' => $this->input->post('client_domain_comments'), 'client_server' => $this->input->post('client_server'), 'client_server_comments' => $this->input->post('client_server_comments'), 'reference_shared' => $this->input->post('reference_shared'), 'reference_shared_comments' => $this->input->post('reference_shared_comments'), 'logo' => $this->input->post('logo'), 'logo_comments' => $this->input->post('logo_comments'), 'blog' => $this->input->post('blog'), 'blog_comments' => $this->input->post('blog_comments'), 'no_of_templates' => $this->input->post('no_of_templates'), 'template_comments' => $this->input->post('template_comments'), 'template_concept' => $this->input->post('template_concept'), 'template_concept_comments' => $this->input->post('template_concept_comments'), 'approved_date' => $this->input->post('approved_date'), 'approved_date_comments' => $this->input->post('approved_date_comments'), 'content_received_date' => $this->input->post('content_received_date'), 'content_received_date_comments' => $this->input->post('content_received_date_comments'), 'development_start_date' => $this->input->post('development_start_date'), 'development_start_date_comments' => $this->input->post('development_start_date_comments'), 'development_end_date' => $this->input->post('development_end_date'), 'development_end_date_comments' => $this->input->post('development_end_date_comments'), 'testing' => $this->input->post('testing'), 'testing_comments' => $this->input->post('testing_comments'), 'website_live_date' => $live_date, 'website_live_comments' => $this->input->post('website_live_comments'), 'changes' => $this->input->post('changes'), 'changes_comments' => $this->input->post('changes_comments'), 'email_provided' => $this->input->post('email_provided'), 'email_provided_comments' => $this->input->post('email_provided_comments'), 'google_analytics' => $this->input->post('google_analytics'), 'google_analytics_comments' => $this->input->post('google_analytics_comments'), 'payment_gateway' => $this->input->post('payment_gateway'), 'payment_gateway_comments' => $this->input->post('payment_gateway_comments'), 'seo' => $this->input->post('seo'), 'seo_comments' => $this->input->post('seo_comments'), 'ssl' => $this->input->post('ssl'), 'ssl_comments' => $this->input->post('ssl_comments'), 'bulk_sms' => $this->input->post('bulk_sms'), 'bulk_sms_comments' => $this->input->post('bulk_sms_comments'), 'adwards' => $this->input->post('adwards'), 'adwards_comments' => $this->input->post('adwards_comments'), 'support_number' => $this->input->post('support_number'), 'support_number_comments' => $this->input->post('support_number_comments'), 'client_username' => $this->input->post('client_username'), 'client_password' => $this->input->post('client_password'), 'client_login_comments' => $this->input->post('client_login_comments'), 'completion_status' => $this->input->post('completion_status'), 'delete_status' => 'ACTIVE', 'updated_at' => $created_at ); $client_id=$this->input->post('client_requirement_id'); $table = 'client_requirements'; $where = array('client_requirement_id' => $this->input->post('client_requirement_id')); $client=$this->yaskawa_model->get_single_row($table,$where); if($client->project_id!=$this->input->post('project_id') || $client->client_name!=$this->input->post('client_name') || $client->contact_number!=$this->input->post('contact_number') || $client->email!=$this->input->post('email') ){ $data['updated_by'] = $this->session->userdata('admin_id'); } if($client->industry_type!=$this->input->post('industry_type')){ $data['u_industry']=$this->session->userdata('admin_id'); $data['u_industry_on']=$created_at; } if($client->website_type!=$this->input->post('website_type')){ $data['u_web_type']=$this->session->userdata('admin_id'); $data['u_web_type_edit_on']=$created_at; } if($client->client_domain!=$this->input->post('client_domain')){ $data['u_domain_id']=$this->session->userdata('admin_id'); $data['u_domain_edit_on']=$created_at; } if($client->client_server!=$this->input->post('client_server')){ $data['u_client_server_id']=$this->session->userdata('admin_id'); $data['u_client_edit_on']=$created_at; } if($client->reference_shared!=$this->input->post('reference_shared')){ $data['reference_id']=$this->session->userdata('admin_id'); $data['reference_edit_on']=$created_at; } if($client->logo!=$this->input->post('no_of_templates')){ $data['u_logo_id']=$this->session->userdata('admin_id'); $data['logo_edit_on']=$created_at; } if($client->blog!=$this->input->post('blog')){ $data['u_blog_id']=$this->session->userdata('admin_id'); $data['u_blog_edit_on']=$created_at; } if($client->no_of_templates!=$this->input->post('no_of_templates')){ $data['u_template_id']=$this->session->userdata('admin_id'); $data['u_template_edit_on']=$created_at; } if($client->template_concept!=$this->input->post('template_concept')){ $data['u_temp_concept_id']=$this->session->userdata('admin_id'); $data['concept_edit_on']=$created_at; } if($client->approved_date!=$this->input->post('approved_date')){ $data['u_approved_id']=$this->session->userdata('admin_id'); $data['u_approved_on']=$created_at; } if($client->content_received_date!=$this->input->post('content_received_date')){ $data['u_content_id']=$this->session->userdata('admin_id'); $data['u_content_edit_on']=$created_at; } if($client->development_start_date!=$this->input->post('development_start_date')){ $data['u_development_id']=$this->session->userdata('admin_id'); $data['u_development_edit_on']=$created_at; } if($client->development_end_date!=$this->input->post('development_end_date')){ $data['u_end_id']=$this->session->userdata('admin_id'); $data['u_end_edit_on']=$created_at; } if($client->testing!=$this->input->post('testing')){ $data['u_testing_id']=$this->session->userdata('admin_id'); $data['u_test_edit_on']=$created_at; } if($client->website_live_date!=$this->input->post('website_live_date')){ $data['u_website_id']=$this->session->userdata('admin_id'); $data['u_website_live_on']=$created_at; } if($client->changes!=$this->input->post('changes')){ $data['u_change_id']=$this->session->userdata('admin_id'); $data['u_change_on']=$created_at; } if($client->email_provided!=$this->input->post('email_provided')){ $data['u_email_id']=$this->session->userdata('admin_id'); $data['u_email_edit_on']=$created_at; } if($client->google_analytics!=$this->input->post('google_analytics')){ $data['u_analytic_id']=$this->session->userdata('admin_id'); $data['u_analytic_edit_on']=$created_at; } if($client->payment_gateway!=$this->input->post('payment_gateway')){ $data['u_gateway_id']=$this->session->userdata('admin_id'); $data['u_gateway_edit_on']=$created_at; } if($client->seo!=$this->input->post('seo')){ $data['u_seo_id']=$this->session->userdata('admin_id'); $data['u_seo_edit_on']=$created_at; } if($client->ssl!=$this->input->post('ssl')){ $data['u_ssl_id']=$this->session->userdata('admin_id'); $data['u_ssl_edit_on']=$created_at; } if($client->bulk_sms!=$this->input->post('bulk_sms')){ $data['u_bulksms_id']=$this->session->userdata('admin_id'); $data['u_bulksms_edit_on']=$created_at; } if($client->adwards!=$this->input->post('adwards')){ $data['u_adward_id']=$this->session->userdata('admin_id'); $data['u_award_edit_on']=$created_at; } if($client->support_number!=$this->input->post('support_number')){ $data['u_support_id']=$this->session->userdata('admin_id'); $data['u_support_edit_on']=$created_at; } if($client->completion_status!=$this->input->post('completion_status')){ $data['u_completion_id']=$this->session->userdata('admin_id'); $data['u_complete_edit_on']=$created_at; } $phone=$this->input->post('contact_number'); $where = array('client_requirement_id' => $this->input->post('client_requirement_id')); $result = $this->yaskawa_model->update_single($where,$table,$data); if($this->db->affected_rows() > 0) { $table="users"; $where=array('email' =>$this->input->post('client_username')); $r=$this->yaskawa_model->get_single_row($table,$where); if($r){ }else{ $table="users"; $p=$this->input->post('client_password'); $password=$p; $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('user_name'=>$this->input->post('project_name'),'email' =>$this->input->post('client_username'),'salt_pass'=>$salt_password,'role_id'=>'68','password'=>$hashed_password,'role'=>'Client','user_type_id'=>'3'); $res=$this->yaskawa_model->insert($table,$data); $u_name=$this->input->post('client_username'); $p_word=$this->input->post('client_password'); $link='https://jayblues.com/jayerp/'; if($res){ $msg='For any assistance please login to the application with following credentials'.PHP_EOL; $msg.='Username -'.$u_name.PHP_EOL; $msg.='Password -'.$p_word.PHP_EOL; $msg.='Application Link -'.$link.PHP_EOL; $msg.='and upload the request'; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, 'http://sms.jayblues.com/http-api.php?'); curl_setopt($ch, CURLOPT_POSTFIELDS, "username=subr1634&password=123321&senderid=JBLUES&route=1&number=$phone&message=$msg"); curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30); curl_setopt($ch, CURLOPT_TIMEOUT, 30); $data = curl_exec($ch); $httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE); curl_close($ch); $subject='JayBlues Support Portal'; $name='Jayblues'; $from='support@jayblues.com'; $to=$this->input->post('email'); $msg='Greetings from JayBlues'.'<br/><br/>'; $msg.='For any assistance please login to the application with following credentials'.'<br/><br/>'; $msg.='Username -'.$u_name.'<br/><br/>'; $msg.='Password -'.$p_word.'<br/><br/>'; $msg.='Application Link -'.$link.'<br/><br/>'; $msg.='and upload the request'; //$this->load->library('encrypt'); $this->load->library('email'); //SMTP & mail configuration $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($msg); $this->email->send(); } } echo json_encode(array('result'=>1,'message'=>"Updated Successfully")); } else { echo json_encode(array('result'=>0,'message'=>"Data Could Not update")); } } public function payment() { $admin_id = $this->session->userdata('admin_id'); if($admin_id) { echo json_encode (array('result'=>1)); } else { redirect('/'); } } public function invoice_payment() { $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $data['invoice_id']=$this->uri->segment(2); $data['company_details']=$this->yaskawa_model->fetch_company_details(); $where=array('field_label'=>'paid_to','delete_status'=>'ACTIVE'); $table="masters"; $data_gst=$this->yaskawa_model->get_data_row($table,$where); $data['paid_to']=json_decode($data_gst->field_value); $where=array('master_type_id'=>'20','delete_status'=>'ACTIVE'); $table="masters"; $data_gst=$this->yaskawa_model->get_data_row($table,$where); $data['payment']=json_decode($data_gst->field_value); $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count=0; foreach($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if($months=='11'){ $count+=1; } } $data['count']=$count; $this->load->view('admin/payment',$data); } else { redirect('/'); } } public function add_payment() { $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $invoice_id=$this->input->post('id'); $table="invoice"; $where=array('id'=>$invoice_id); $amount=$this->input->post('amount'); $invoice=$this->yaskawa_model->get_row_data($table,$where); $amt=0; foreach($amount as $key => $value) { $invoice_amount=str_replace(',','',$value); $amt+=$invoice_amount; } /* if($amt < $invoice->total_amount || $amt < $invoice->total){*/ $paid_to=$this->input->post('favour_of'); $payment_type=$this->input->post('payment_type'); $no=$this->input->post('no'); $date=$this->input->post('date'); $bank=$this->input->post('bank'); $branch=$this->input->post('branch'); $collected_by=$this->input->post('collected_by'); $admin=$this->session->userdata('admin'); if($admin==''){ $admin=$this->session->userdata('user'); } $table='invoice_payments'; foreach($payment_type as $key=>$d) { $invoice_amount=str_replace(',','',$amount[$key]); if($payment_type[$key]=='Cheque') { $data = array('invoice_id' =>$invoice_id, 'favour_of' =>$paid_to[$key], 'payment_type' =>$payment_type[$key], 'amount' =>$invoice_amount, 'cheque_no' =>$no[$key], 'cheque_date' =>$date[$key], 'bank_name' =>$bank[$key], 'collected_by' =>$collected_by[$key], 'branch_name' =>$branch[$key], 'added_by' =>$admin); } else if($payment_type[$key]=='DD') { $data = array('invoice_id' =>$invoice_id, 'favour_of' =>$paid_to[$key], 'payment_type' =>$payment_type[$key], 'amount' =>$invoice_amount, 'dd_no' =>$no[$key], 'dd_date' =>$date[$key], 'bank_name' =>$bank[$key], 'collected_by' =>$collected_by[$key], 'branch_name' =>$branch[$key], 'added_by' =>$admin); } else if($payment_type[$key]=='Online Payment') { $data = array('invoice_id' =>$invoice_id, 'favour_of' =>$paid_to[$key], 'payment_type' =>$payment_type[$key], 'amount' =>$invoice_amount, 'collected_by' =>$collected_by[$key], 'utr_no' =>$no[$key], 'online_date' =>$date[$key], 'added_by' =>$admin); } else { $data = array('invoice_id' =>$invoice_id, 'favour_of' =>$paid_to[$key], 'payment_type' =>$payment_type[$key], 'collected_by' =>$collected_by[$key], 'amount' =>$invoice_amount, 'added_by' =>$admin); } $date1 = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $created_at = $date1->format('Y-m-d H:i:s'); $data['created_at']=$created_at; $data['delete_status']='ACTIVE'; $result=$this->yaskawa_model->add_data($table,$data); $amt=0; foreach($amount as $key => $value) { $invoice_amount=str_replace(',','',$value); $amt+=$invoice_amount; } $p=0; $pri=json_decode($invoice->price); foreach ($pri as $key => $value) { $p+=$value; } if($result){ //if($invoice->grand_total <= $amt || $p <= $amt){ if($invoice->grand_total <= $amt || $invoice->total <= $amt){ $table="invoice"; $where=array('id'=>$invoice_id); $data=array('invoice_status'=>'CLEARED'); $invoice=$this->yaskawa_model->update_invoice_payments($where,$data,$table); }elseif($invoice->grand_total!=$amt || $invoice->total!=$amt){ $table="invoice"; $where=array('id'=>$invoice_id); $data=array('invoice_status'=>'PARTIAL'); $invoice=$this->yaskawa_model->update_invoice_payments($where,$data,$table); } } } if($result) { echo json_encode (array('result'=>1)); } /*}else { echo json_encode (array('result'=>0,'message'=>'Payment Amount exceed invoice amount. Amount Is:'.$invoice->grand_total)); }*/ } else { redirect('/'); } } public function view_invoice_payment() { $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $id=$this->uri->segment(2); $table='invoice_payments'; $where=array('invoice_id'=>$id,'delete_status'=>'ACTIVE'); $payment_result=$this->yaskawa_model->get_data($table,$where); $result=array(); foreach($payment_result as $val){ $pay_result['payment_type']=$val->payment_type; $pay_result['id']=$val->payment_id; $pay_result['name']=$val->favour_of; $pay_result['cheque_no']=$val->cheque_no; $pay_result['cheque_date']=$val->cheque_date; $pay_result['dd_no']=$val->dd_no; $pay_result['dd_date']=$val->dd_date; $pay_result['utr_no']=$val->utr_no; $pay_result['online_date']=$val->online_date; $pay_result['bank_name']=$val->bank_name; $pay_result['branch_name']=$val->branch_name; $pay_result['collected_by']=$val->collected_by; $invoce_amount=number_format($val->amount); $pay_result['paid_amount']=$invoce_amount; array_push($result,$pay_result); } if($result) { echo json_encode($result); } else { echo json_encode(array('result'=>0,'message'=>'No data Found')); } } else { redirect('/'); } } public function send_invoice_mail(){ $table='invoice_quotation_from_mail'; $condition=array('delete_status'=>'ACTIVE','checked_status'=>1); $get_signature=$this->yaskawa_model->get_row_data($table,$condition); if(!empty($get_signature)) { $signature=$get_signature; }else { //$signature=array('name'=>'Subramanya','designation'=>'Sales Exicutive Manager','phone'=>'9663933606','address'=>' K R Square, #1073, 15th cross, 30th main, Banashankari 2nd stage, Bangalore - 560070'); $signature=array('name'=>'Rekha R','designation'=>'Inside Sales','phone'=>'9606655606','address'=>' K R Square, #1073, 15th cross, 30th main, Banashankari 2nd stage, Bangalore - 560070'); } $invoice_id=$this->input->post('invoice_id'); $email_to=$this->input->post('email_to'); $email_to=implode(', ', $email_to); $where=array('id'=>$invoice_id); $table="invoice"; $invoice=$this->yaskawa_model->get_row_data($table,$where); $description=json_decode($invoice->description); $sac=json_decode($invoice->sac); $pric=json_decode($invoice->price); $cgst_amount=number_format($invoice->cgst_amount); $sgst_amount=number_format($invoice->sgst_amount); $total_amount=number_format($invoice->total_amount); $sub_total=number_format($invoice->total); $invoice_date=date('d-m-Y',strtotime($invoice->invoice_date)); $name = 'invoice'.$invoice_id.'.pdf'; // include("admin_assets/mpdf60/mpdf.php"); // $mpdf=new mPDF('A4'); // require_once FCPATH . 'vendor/autoload.php'; require_once(APPPATH . '../vendor/autoload.php'); $mpdf = new Mpdf(['format' => 'A4']); $mpdf->mirrorMargins = 1; $html = ''; $index = 1; $html=$html.'<html>'; $html=$html.'<head>'; $html=$html.'<title style="">Invoice</title>'; $html=$html.'</head>'; $html=$html.'<body style="width: 800px;">'; $html=$html.'<div class="row_1" style="border-bottom: 1px solid #000;padding-bottom:15px;">'; $html=$html.'<img src="https://jayblues.in/jayerp/admin_assets/logo.png" style="float:left;">'; $html=$html.'<h1 style="color: #A6A6A6;text-align: right;padding-bottom: 5px;margin-bottom: 0px;float:right;">INVOICE</h1>'; $html=$html.'</div>'; $html=$html.'<div style="clear:both !important;"></div>'; $html=$html.'<div class="row_2" style="padding-top:15px;padding-bottom:15px;">'; $html=$html.'<table>'; $html=$html.'<tr>'; $html=$html.'<td style="padding-right:10px;"><b>Date: </b></td>'; $html=$html.'<td style="width: 100px;">'.$invoice_date.'</td>'; $html=$html.'</tr>'; $html=$html.'<tr>'; $html=$html.'<td style=" padding-right:10px;"><b>Invoice: </b></td>'; $html=$html.'<td>'.$invoice->invoice_no.'</td>'; $html=$html.'</tr>'; $html=$html.'</table>'; $html=$html.'</div>'; $html=$html.'<div class="" style="clear:both !important;"></div>'; $html=$html.'<div class="row_3">'; $html=$html.'<table style="width: 100%;">'; $html=$html.'<tr>'; $html=$html.'<td style="width:50%;"><p style="margin-bottom:0px;"><b>Bill To,</p></td>'; $html=$html.'<td style="width:50%;"><p style="margin-bottom:0px;"><b>Supply To,</p></td>'; $html=$html.'</tr>'; $html=$html.'<tr>'; $html=$html.'<td><p style="margin-top:0px;margin-bottom:0px;">'.$invoice->name.'</p></td>'; $html=$html.'<td><p style="margin-top:0px;margin-bottom:0px;">'.$invoice->supply_to.'</p></td>'; $html=$html.'</tr>'; $html=$html.'<tr>'; $html=$html.'<td><p style="margin-top:0px;">'.$invoice->address.'</p></td>'; $html=$html.'<td><p style="margin-top:0px;">'.$invoice->supply_address.'</p></td>'; $html=$html.'</tr>'; $html=$html.'</table>'; $html=$html.'<p style="">GSTN: '.$invoice->gstn.'</p>'; $html=$html.'</div>'; $html=$html.'<div class="row_4" style="padding: 10px 0px 30px;">'; $html=$html.'<table border="1" style="width:100%;border-collapse: collapse;border-left: initial;border-bottom: initial;">'; $html=$html.'<tr style="background:#7B8CA0;">'; $html=$html.'<th style="width: 10%;padding: 5px;border: 1px solid #000;">SI NO</th>'; $html=$html.'<th style="width: 50%;padding: 5px;border: 1px solid #000;">DESCRIPTION</th>'; $html=$html.'<th style="width: 20%;padding: 5px;border: 1px solid #000;">SAC</th>'; $html=$html.'<th style="width: 20%;padding: 5px;border: 1px solid #000;">PRICE</th>'; $html=$html.'</tr>'; foreach($description as $key=>$value) { $k=$key+1; $sac=$sac[$key]; $p=number_format($pric[$key]); $html=$html.'<tr>'; $html=$html.'<td style="padding: 5px;border: 1px solid #000;">'.$k.'</td>'; $html=$html.'<td style="padding: 5px;border: 1px solid #000;">'.$value.'</td>'; $html=$html.'<td style="padding: 5px;border: 1px solid #000;">'.$sac.'</td>'; $html=$html.'<td style="padding: 5px;border: 1px solid #000;text-align: right;">'.$p.' Rs</td>'; $html=$html.'</tr>'; } $html=$html.'<tr>'; $html=$html.'<td colspan="2" rowspan="3" style="border-bottom:initial;border-left:initial;"></td>'; $html=$html.'<td style="padding: 5px;text-align: right;border: 1px solid #000;"><b>Sub Total</b></td>'; $html=$html.'<td style="padding: 5px;text-align: right;border: 1px solid #000;">'.$sub_total.' Rs</td>'; $html=$html.'</tr>'; $html=$html.'<tr >'; $html=$html.'<td style="padding: 5px;text-align: right;border: 1px solid #000;"><b>CGST @ '.$invoice->cgst.'</b></td>'; $html=$html.'<td style="padding: 5px;text-align: right;border: 1px solid #000;">'.$cgst_amount.' Rs</td>'; $html=$html.'</tr>'; $html=$html.'<tr>'; $html=$html.'<td style="padding: 5px;text-align: right;border: 1px solid #000;"><b>SGST @ '.$invoice->sgst.'</b></td>'; $html=$html.'<td style="padding: 5px;text-align: right;border: 1px solid #000;">'.$sgst_amount.' Rs</td>'; $html=$html.'</tr>'; $html=$html.'<tr >'; $html=$html.'<td colspan="2" style="padding: 5px;border-top:initial;border-bottom:initial;border-left:initial;"><b>In Words - </b>'.$invoice->total_amount_words.'</td>'; $html=$html.'<td style="padding: 5px;text-align: right;border: 1px solid #000;"><b>Total</b></td>'; $html=$html.'<td style="padding: 5px;text-align: right;border: 1px solid #000;">'.$total_amount.' Rs</td>'; $html=$html.'</tr>'; $html=$html.'</table>'; $html=$html.'</div>'; $html=$html.'<div class="row_5" style="padding-top:20px;">'; $html=$html.'<table style="width:100%; color:#898989;">'; $html=$html.'<tr>'; $html=$html.'<td style="font-size:12px;">Company GSTN : 29BZLPS4657ILZG</td>'; $html=$html.'<td style="font-size:12px;">Company GSTN : 29BZLPS4657ILZG</td>'; $html=$html.'<td></td>'; $html=$html.'</tr>'; $html=$html.'<tr>'; $html=$html.'<td style="font-size:12px;">Company Bank Details :</td>'; $html=$html.'<td style="font-size:12px;">Company Bank Details :</td>'; $html=$html.'<td style="text-align:right;">For JAYBLUES TECHNOLOGIES</td>'; $html=$html.'</tr>'; $html=$html.'<tr>'; $html=$html.'<td style="font-size:12px;">SBI</td>'; $html=$html.'<td style="font-size:12px;">HDFC Bank</td>'; $html=$html.'<td rowspan="3"><img src="https://jayblues.in/jayerp/admin_assets/ajay_sig.jpg" style="float:right;"/></td>'; $html=$html.'</tr>'; $html=$html.'<tr>'; $html=$html.'<td style="font-size:12px;">Jayblues</td>'; $html=$html.'<td style="font-size:12px;">Jayblues</td>'; $html=$html.'</tr>'; $html=$html.'<tr>'; $html=$html.'<td style="font-size:12px;">Account Type : Current Account</td>'; $html=$html.'<td style="font-size:12px;">Account Type : Current Account</td>'; $html=$html.'</tr>'; $html=$html.'<tr>'; $html=$html.'<td style="font-size:12px;">Account Number : 62439776675</td>'; $html=$html.'<td style="font-size:12px;">Account Number : 50200010784596</td>'; $html=$html.'<td style="text-align:right;color:#000;font-size:13px;">Authorized Signatory</td>'; $html=$html.'</tr>'; $html=$html.'<tr>'; $html=$html.'<td style="font-size:12px;">IFSC : SBIN0020555</td>'; $html=$html.'<td style="font-size:12px;">IFSC : HDFC0000065</td>'; $html=$html.'<td></td>'; $html=$html.'</tr>'; $html=$html.'<tr>'; $html=$html.'<td style="font-size:12px;">Branch : Kalidasa Road, Mysore</td>'; $html=$html.'<td style="font-size:12px;">Branch : Saraswathipuram, Mysore</td>'; $html=$html.'<td></td>'; $html=$html.'</tr>'; $html=$html.'</table>'; $html=$html.'</div>'; $html=$html.'<div class="row_6" style="padding-top:30px;">'; $html=$html.'<p style="text-align:center;margin-bottom:5px;">Declaration: Payment mode will be in Cash, Cheques, NEFT or RTGS only. Make all cheques payable to [Jayblues]</p>'; $html=$html.'<h4 style="text-align: center;padding-bottom: 10px;border-bottom: 1px solid #000;margin-bottom: 5px;margin-top: 5px;">THANK YOU FOR YOUR BUSINESS!</h4>'; $html=$html.'<p style="text-align: center;color:#898989; margin: 0 !important; padding-bottom: 8px;">Head Off. : #656/D, 16th Main, 5th Cross, Saraswathipuram, Mysore, Karnataka-570009.</p>'; $html=$html.'<p style="text-align: center;color:#898989; margin: 0 !important;">Branch Off. : K R Square, #1073, 15th cross, 30th main, Banashankari 2nd stage, Bangalore - 560070.<br> Tel: +919740285566 I www.jayblues.com | E: support@jayblues.com</p>'; $html=$html.'</div>'; $html=$html.'</body>'; $html=$html.'</html>'; $mpdf->SetDisplayMode('fullpage'); $mpdf->watermark_font = 'DejaVuSansCondensed'; $mpdf->showWatermarkText = true; $mpdf->WriteHTML($html); $data = date('d-M-y H:i'); $pdf=$mpdf->Output("./invoicepdf/".$name, 'F'); $attach='invoice'.$invoice_id.'.pdf'; $subject=$this->input->post('subject'); $body=$this->input->post('body'); $msg ='Hello Sir,'.'<br/><br/>'; $msg.='Greetings from Jayblues Technologies!'.'<br/><br/>'; $msg.= 'Please find the below attached invoice for '; foreach($description as $key => $value) { $msg.=$value; } $msg.='<br/><br/>'; $msg.=$body; $msg.='<p> Thank you</p>'; $msg.='<p><b> Regards,</b></p>'; //$msg.='<p style="color: rgb(31,73,125);"><b> '.$signature->name.' | '.$signature->designation.' </b></p>'; $msg.='<p><b> JayBlues Technologies</b></p>'; $msg.='<p><span style="color:rgb(91,155,213);"><b> Address</b></span>: #656/D, 16th Main,5th Cross, Saraswathipuram,Mysore, Karnataka-570009</p>'; $msg.='<p><span style="color:rgb(91,155,213);">Tel</span>: +91 9663933606 | www.jayblues.com | E: info@jayblues.com</p>'; $name='Jayblues'; $email='support@jayblues.com'; $cc=$this->input->post('cc'); $result= $this->sendEmailnew($email,$email_to,$name,$subject,$msg,$attach,$cc); if($result) { echo json_encode(array('result'=>1,'message'=>"Invoice Sent Sucessfully !")); } else{ echo json_encode(array('result'=>0,'message'=>"Email not send,Something went wrong.. try again")); } } public function sendEmailnew($from,$to,$name,$subject,$message,$attach,$cc) { $this->load->library('email'); $phpMailer = new PHPMailer(true); $phpMailer->isSMTP(); // $phpMailer->SMTPDebug = 2; // $phpMailer->Debugoutput = 'html'; $phpMailer->Host = "smtp.zoho.com"; $phpMailer->SMTPAuth = true; $phpMailer->Username = "support@jayblues.com"; $phpMailer->Password = "Jayblues@1236"; $phpMailer->SMTPSecure = "tls"; $phpMailer->Port = 587; $phpMailer->isHTML(true); $phpMailer->CharSet = "UTF-8"; $phpMailer->setFrom("support@jayblues.com", "Jayblues"); $phpMailer->addAttachment($_SERVER["DOCUMENT_ROOT"]."/jayerp/invoicepdf/".$attach); $phpMailer->addAddress($to); $phpMailer->addCC('ajay@jayblues.com'); $phpMailer->Subject = $subject; $phpMailer->Body = $message; if ($phpMailer->send()) { return 1; } else { show_error($phpMailer->print_debugger()); } } // $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->cc($cc); // $this->email->subject($subject); // $this->email->message($message); // $this->email->attach($_SERVER["DOCUMENT_ROOT"].'/jayerp/invoicepdf/'.$attach); // if ($this->email->send()) { // return 1; // } else { // show_error($this->email->print_debugger()); // } // require_once($_SERVER["DOCUMENT_ROOT"].'/jayerp/application/third_party/phpmailer/PHPMailerAutoload.php'); // $phpMailer = new PHPMailer(true); // $phpMailer->isSMTP(); // $phpMailer->Host = "smtp.zoho.com"; // $phpMailer->SMTPAuth = true; // $phpMailer->Username = "sales@jayblues.com"; // $phpMailer->Password = "m7uMqE8MFMR8"; // $phpMailer->SMTPSecure = "tls"; // $phpMailer->Port = 587; // $phpMailer->isHTML(true); // $phpMailer->CharSet = "UTF-8"; // $phpMailer->setFrom("sales@jayblues.com", "Jayblues"); // $phpMailer->addAttachment($_SERVER["DOCUMENT_ROOT"]."/jayerp/invoicepdf/".$attach); // $phpMailer->addAddress($to); // $phpMailer->addCC('ajay@jayblues.com'); // $phpMailer->addCC('subramanya@jayblues.com'); // // $phpMailer->addCC('chaya@jayblues.com'); // // $phpMailer->addCC('divya@jayblues.com'); // $phpMailer->Subject = $subject; // $phpMailer->Body = $message; // if ($phpMailer->send()) { // return 1; // } else { // show_error($phpMailer->print_debugger()); // } public function add_tickets() { $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $data['company_details'] = $this->yaskawa_model->fetch_company_details(); $table = 'new_account'; $where = array('delete_status' => 'ACTIVE'); $data['projects'] = $this->yaskawa_model->get_where_result($table,$where); $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count=0; foreach($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if($months=='11'){ $count+=1; } } $data['count']=$count; $this->load->view('admin/add_tickets',$data); } else { redirect('/'); } } public function tickets_list() { $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $data['company_details'] = $this->yaskawa_model->fetch_company_details(); $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count=0; foreach($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if($months=='11'){ $count+=1; } } $data['count']=$count; $this->load->view('admin/tickets_list',$data); } else { redirect('/'); } } public function add_tickets_data() { $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $created_at = $date->format('Y-m-d H:i:s'); $table = 'tickets'; $this->load->library('image_lib'); if(empty($_FILES['ticket_file']['name'])) { $file_name = ''; } else { $target='ticket_uploads/'; $target.=time().$_FILES['ticket_file']['name']; $file_name=time().$_FILES['ticket_file']['name']; $image=$target; move_uploaded_file($_FILES['ticket_file']['tmp_name'],$target); $config['source_image']=$target; $config['maintain_ratio']=TRUE; $this->image_lib->initialize($config); $this->image_lib->resize(); } $priority = $this->input->post('ticket_priority'); if($priority == '') { $priority = ''; } else { $priority = 'YES'; } $insert_data = array( 'project_id' => $this->input->post('project_id'), 'ticket_title' => $this->input->post('ticket_title'), 'ticket_description' => $this->input->post('content'), 'ticket_priority' => $priority, 'ticket_file' => $file_name, 'ticket_link' => $this->input->post('ticket_link'), 'ticket_link_text' => $this->input->post('ticket_link_text'), 'created_by' => $this->session->userdata('admin_id'), 'ticket_status' => 'RAISED', 'delete_status' => 'ACTIVE', 'created_at' => $created_at ); $insert_result = $this->yaskawa_model->insert($table,$insert_data); if($insert_result) { echo json_encode(array('result'=>1 ,'message'=>'Ticket added successfully')); } else { echo json_encode(array('result'=>0,'message'=>"Data could not add")); } } public function get_all_tickets() { $result = $this->yaskawa_model->get_all_tickets(); if($result) { echo json_encode($result); } else { echo json_encode(array('result'=>0)); } } public function delete_ticket() { $table = 'tickets'; $ticket_id = $this->input->post('ticket_id'); $where = array('ticket_id'=>$ticket_id); $data = array('delete_status'=>'INACTIVE'); $result = $this->yaskawa_model->update($where,$table,$data); if($this->db->affected_rows() > 0) { echo json_encode(array('result'=>1,'message'=>'Deleted successfully')); } else { echo json_encode(array('result'=>0)); } } public function edit_ticket() { $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $ticket_id = $this->uri->segment(2); $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $data['company_details'] = $this->yaskawa_model->fetch_company_details(); $table = 'tickets'; $where = array('ticket_id' => $ticket_id,'delete_status' => 'ACTIVE'); $data['ticket_data'] = $this->yaskawa_model->get_single_ticket($ticket_id); $table = 'new_account'; $where = array('delete_status' => 'ACTIVE'); $data['projects'] = $this->yaskawa_model->get_where_result($table,$where); $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count=0; foreach($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if($months=='11'){ $count+=1; } } $data['count']=$count; $this->load->view('admin/edit_ticket',$data); } else { redirect('/'); } } public function update_ticket() { $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $created_at = $date->format('Y-m-d H:i:s'); $table = 'tickets'; $where = array('ticket_id' => $this->input->post('ticket_id')); $check = $this->yaskawa_model->get_where_row($table,$where); $this->load->library('image_lib'); if(empty($_FILES['ticket_file']['name'])) { $file_name = $check->ticket_file; } else { $target='ticket_uploads/'; $target.=time().$_FILES['ticket_file']['name']; $file_name=time().$_FILES['ticket_file']['name']; $image=$target; move_uploaded_file($_FILES['ticket_file']['tmp_name'],$target); $config['source_image']=$target; $config['maintain_ratio']=TRUE; $this->image_lib->initialize($config); $this->image_lib->resize(); } $insert_data = array( 'project_id' => $this->input->post('project_id'), 'ticket_title' => $this->input->post('ticket_title'), 'ticket_description' => $this->input->post('content'), 'ticket_priority' => $this->input->post('ticket_priority'), 'ticket_file' => $file_name, 'ticket_link' => $this->input->post('ticket_link'), 'ticket_link_text' => $this->input->post('ticket_link_text'), 'ticket_status' => $this->input->post('status'), 'delete_status' => 'ACTIVE', 'updated_at' => $created_at ); $insert_result = $this->yaskawa_model->update($where,$table,$insert_data); if($insert_result) { echo json_encode(array('result'=>1 ,'message'=>'Ticket updated successfully')); } else { echo json_encode(array('result'=>0,'message'=>"Data could not update")); } } public function assign_task_main() { $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $data['company_details']=$this->yaskawa_model->fetch_company_details(); $project_table='new_account'; $condition=array('delete_status'=>'ACTIVE'); $data['project_lists']=$this->yaskawa_model->get_where_result($project_table,$condition); $table_employee='employees'; $data['persons']=$this->yaskawa_model->get_where_result($table_employee,$condition); $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count=0; foreach($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if($months=='11'){ $count+=1; } } $data['count']=$count; $this->load->view('admin/assign_task_main',$data); } else { redirect('/'); } } public function add_task_main() { $admin_id = $this->session->userdata('admin_id'); if($admin_id) { date_default_timezone_set('Asia/Kolkata'); $date = date('Y-m-d'); $client_requirement_id=$this->input->post('client_requirement_id'); $task_title=$this->input->post('task_title'); $description=$this->input->post('description'); $resposible_person=$this->input->post('resposible_person'); $deadline=$this->input->post('deadline'); $link_text=$this->input->post('link_text'); $priority=$this->input->post('priority'); if($priority==null) { $priority=0; }else { $priority=1; } $client_requirements_tab='client_requirements'; $con=array('client_requirement_id'=>$client_requirement_id,'delete_status'=>'ACTIVE'); $get_project=$this->yaskawa_model->get_single_row($client_requirements_tab,$con); $project_name=$get_project->project_id; $link=$this->input->post('link'); $this->load->library('image_lib'); $myFile = $_FILES['file']; $cpt = count($_FILES['file']['name']); $file_doc=""; for($i=0; $i<$cpt; $i++) { $error = $myFile["error"][$i]; if ($error == '4') { $file_new=""; } else { if($_FILES['file']['name']) { $path=$_FILES['file']['name'][$i]; $target='taskattachment/'; $target.=time().$_FILES['file']['name'][$i]; $document[]=time().$_FILES['file']['name'][$i]; move_uploaded_file($_FILES['file']['tmp_name'][$i],$target); $file_doc=json_encode($document); } else { $file_doc=""; } } } $table='assign_task'; $data = array('title' =>$task_title, 'description' =>$description, 'attachment' =>$file_doc, 'responsible_person'=>json_encode($resposible_person), 'deadline' =>$deadline, 'priority' =>$priority, 'project_id' =>$project_name, 'link_text' =>$link_text, 'created_by' =>$admin_id, 'modified_by' =>$admin_id, 'created_at' =>$date, 'modified_at' =>$date, 'delete_status' =>'ACTIVE', 'client_requirement_id'=>$client_requirement_id, 'link' =>$link, ); $result=$this->yaskawa_model->insert($table,$data); $details_table='assigned_task_person_details'; foreach($resposible_person as $key=>$id) { $datas= array( 'emp_id'=>$id, 'task_id' =>$result, 'project_id' =>$project_name, 'created_at' =>$date, 'modified_at' =>$date, 'delete_status' =>'ACTIVE', 'client_requirement_id'=>$client_requirement_id, ); $result=$this->yaskawa_model->insert($details_table,$datas); } if($result) { echo json_encode(array('result'=>1,'message'=>"Added successfully")); } else { echo json_encode(array('result'=>0,'message'=>"Something went wrong.. try again")); } } else { redirect('/'); } } public function assign_task_list() { $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $data['company_details']=$this->yaskawa_model->fetch_company_details(); $project_table='new_account'; $order1='account_name'; $condition=array('delete_status'=>'ACTIVE'); $data['project_lists']=$this->yaskawa_model->get_where_result_orderby($project_table,$condition,$order1); $table_employee='employees'; $order='first_name'; $data['persons']=$this->yaskawa_model->get_where_result_orderby($table_employee,$condition,$order); $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count=0; foreach($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if($months=='11'){ $count+=1; } } $data['count']=$count; $this->load->view('admin/assign_task_list_main',$data); } else { redirect('/'); } } public function view_assign_task_list() { $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $result=$this->yaskawa_model->get_assign_task_main_list($admin_id); echo json_encode($result); } else { redirect('/'); } } public function assign_task_sub() { $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $data['company_details']=$this->yaskawa_model->fetch_company_details(); $project_table='new_account'; $condition=array('delete_status'=>'ACTIVE'); $data['project_lists']=$this->yaskawa_model->get_where_result($project_table,$condition); $table_employee='employees'; $data['persons']=$this->yaskawa_model->get_where_result($table_employee,$condition); $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count=0; foreach($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if($months=='11'){ $count+=1; } } $data['count']=$count; $this->load->view('admin/assign_task_sub',$data); } else { redirect('/'); } } public function add_task_sub() { $admin_id = $this->session->userdata('admin_id'); if($admin_id) { date_default_timezone_set('Asia/Kolkata'); $date = date('Y-m-d'); $client_requirement_id=$this->input->post('client_requirement_id'); $task_title=$this->input->post('task_title'); $description=$this->input->post('description'); $resposible_person=$this->input->post('resposible_person'); $deadline=$this->input->post('deadline'); $link_text=$this->input->post('link_text'); $priority=$this->input->post('priority'); if($priority==null) { $priority=0; }else { $priority=1; } $client_requirements_tab='client_requirements'; $con=array('client_requirement_id'=>$client_requirement_id,'delete_status'=>'ACTIVE'); $get_project=$this->yaskawa_model->get_single_row($client_requirements_tab,$con); $project_name=$get_project->project_id; $link=$this->input->post('link'); $this->load->library('image_lib'); $myFile = $_FILES['file']; $cpt = count($_FILES['file']['name']); $file_doc=""; for($i=0; $i<$cpt; $i++) { $error = $myFile["error"][$i]; if ($error == '4') { $file_new=""; } else { if($_FILES['file']['name']) { $path=$_FILES['file']['name'][$i]; $target='taskattachment/'; $target.=time().$_FILES['file']['name'][$i]; $document[]=time().$_FILES['file']['name'][$i]; move_uploaded_file($_FILES['file']['tmp_name'][$i],$target); $file_doc=json_encode($document); } else { $file_doc=""; } } } $table='share_project_task'; $data = array('title' =>$task_title, 'description' =>$description, 'attachment' =>$file_doc, 'responsible_person'=>json_encode($resposible_person), 'deadline' =>$deadline, 'priority' =>$priority, 'project_id' =>$project_name, 'link_text' =>$link_text, 'created_by' =>$admin_id, 'modified_by' =>$admin_id, 'created_at' =>$date, 'modified_at' =>$date, 'delete_status' =>'ACTIVE', 'client_requirement_id'=>$client_requirement_id, 'link' =>$link, ); $result=$this->yaskawa_model->insert($table,$data); $details_table='task_shared_persons'; foreach($resposible_person as $key=>$id) { $datas= array( 'emp_id'=>$id, 'task_id' =>$result, 'project_id' =>$project_name, 'created_at' =>$date, 'modified_at' =>$date, 'delete_status' =>'ACTIVE', 'client_requirement_id'=>$client_requirement_id, ); $result=$this->yaskawa_model->insert($details_table,$datas); } if($result) { echo json_encode(array('result'=>1,'message'=>"Added successfully")); } else { echo json_encode(array('result'=>0,'message'=>"Something went wrong.. try again")); } } else { redirect('/'); } } public function assign_task_list_sub() { $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $data['company_details']=$this->yaskawa_model->fetch_company_details(); $project_table='new_account'; $order1='account_name'; $condition=array('delete_status'=>'ACTIVE'); $data['project_lists']=$this->yaskawa_model->get_where_result_orderby($project_table,$condition,$order1); $table_employee='employees'; $order='first_name'; $data['persons']=$this->yaskawa_model->get_where_result_orderby($table_employee,$condition,$order); $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count=0; foreach($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if($months=='11'){ $count+=1; } } $data['count']=$count; $this->load->view('admin/assign_task_list_sub',$data); } else { redirect('/'); } } public function view_assign_task_list_sub() { $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $result=$this->yaskawa_model->get_assign_task_sub_list($admin_id); echo json_encode($result); } else { redirect('/'); } } public function delete_assign_task_main() { $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $id=$this->input->post('id'); $condition=array('id'=>$id); $conditions=array('task_id'=>$id); $data=array('delete_status'=>'INACTIVE'); $table='assign_task'; $table_person='assigned_task_person_details'; $result=$this->yaskawa_model->update($condition,$table,$data); $result=$this->yaskawa_model->update($conditions,$table_person,$data); if($result){ echo json_encode(array('result'=>1,'message'=>'Deleted')); }else { echo json_encode(array('result'=>0,'message'=>'Not Deleted')); } } else { redirect('/'); } } public function delete_assign_task_sub() { $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $id=$this->input->post('id'); $condition=array('id'=>$id); $conditions=array('task_id'=>$id); $data=array('delete_status'=>'INACTIVE'); $table='share_project_task'; $table_person='task_shared_persons'; $result=$this->yaskawa_model->update($condition,$table,$data); $result=$this->yaskawa_model->update($conditions,$table_person,$data); if($result){ echo json_encode(array('result'=>1,'message'=>'Deleted')); }else { echo json_encode(array('result'=>0,'message'=>'Not Deleted')); } } else { redirect('/'); } } //assign ticket mpdule public function assign_ticket() { $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $ticket_id = $this->uri->segment(2); $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $data['company_details'] = $this->yaskawa_model->fetch_company_details(); $table = 'tickets'; $where = array('delete_status'=>'ACTIVE','ticket_status'=>'RAISED'); $data['tickets'] = $this->yaskawa_model->get_raised_ticket($ticket_id); $table = 'employees'; $where = array('delete_status'=>'ACTIVE'); $data['employees'] = $this->yaskawa_model->get_where_result($table,$where); $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count=0; foreach($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if($months=='11'){ $count+=1; } } $data['count']=$count; $this->load->view('admin/assign_ticket',$data); } else { redirect('/'); } } public function assign_ticket_task() { $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $created_at = $date->format('Y-m-d H:i:s'); $table = 'assigned_tickets'; $employees = $this->input->post('responsible_person'); foreach($employees as $val) { $insert_data = array( 'ticket_id' => $this->input->post('ticket_id'), 'task' => $this->input->post('task'), 'task_description' => $this->input->post('content'), 'responsible_person' => $val, 'assigned_date' => $created_at, 'due_date' => $this->input->post('due_date'), 'assigned_by' => $this->session->userdata('admin_id'), 'ticket_task_status' => 'ASSIGNED', 'delete_status' => 'ACTIVE', 'created_at' => $created_at ); $insert_result = $this->yaskawa_model->insert($table,$insert_data); } if($insert_result) { $where = array('ticket_id' => $this->input->post('ticket_id')); $table = 'tickets'; $update_data = array('ticket_status' => 'ASSIGNED'); $update = $this->yaskawa_model->update($where,$table,$update_data); echo json_encode(array('result'=>1 ,'message'=>'Task added successfully')); } else { echo json_encode(array('result'=>0,'message'=>"Data could not add")); } } public function search_role(){ $keyword=$this->input->post('role_name'); $result=$this->yaskawa_model->search_role($keyword); echo json_encode(array('result'=>$result)); } public function add_contact_potential(){ $admin_id = $this->session->userdata('admin_id'); $role_id = $this->session->userdata('role_id'); if($admin_id) { $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $data['honorific']=$this->yaskawa_model->get_honorific(); $data['user_name']= $this->session->userdata('user_name'); $data['user_details']=$this->yaskawa_model->get_user_details(); $data['potential_details']=$this->yaskawa_model->select_new_potential($role_id); $data['company_details']=$this->yaskawa_model->fetch_company_details(); $data['source_details']=$this->yaskawa_model->source_details(); $data['account_persons']=$this->yaskawa_model->account_details(); $uri_path = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH); $uri_segments = explode('/', $uri_path); // print_r($uri_segments); $id=$uri_segments[3]; $table="new_contact"; $where=array('contact_id'=>$id); $data['contct']=$this->yaskawa_model->get_single_row($table,$where); $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count=0; foreach($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if($months=='11'){ $count+=1; } } $data['count']=$count; $this->load->view('admin/add_contact_potential',$data); } else { redirect('/'); } } public function generate_invoice_reports1() { $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $from_date1=$this->input->post('from_date'); $to_date1=$this->input->post('to_date'); $invoice_type=$this->input->post('invoice_type'); $from_date = date("Y-m-d", strtotime($from_date1)); $to_date = date("Y-m-d", strtotime($to_date1)); $delete=$this->yaskawa_model->delete_invoice_reports(); if($delete){ $result=$this->yaskawa_model->get_invoice_details($from_date,$to_date,$invoice_type); if($result) { foreach($result as $val) { $data['id']=$val->id; $data['invoice_date']=$val->invoice_date; $data['name']=$val->name; $data['invoice_status']=$val->invoice_status; $data['invoice_no']=$val->invoice_no; $data['address']=$val->address; $data['type']=$val->type; if($val->invoice_type=='Profomo') { $data['invoice_type'] ='Profarma'; }else{ $data['invoice_type']=$val->invoice_type; } $data['account_id']=$val->account_id; $data['gstn']=$val->gstn; $data['si_no']=$val->si_no; $description=json_decode($val->description); if($description!=""){ $data['description']=json_encode($description); }else{ $description=array(); $data['description']=json_encode($description); } $sac=json_decode($val->sac); if($sac!=""){ $data['sac']=json_encode($sac); }else{ $sac=array(); $data['sac']=json_encode($sac); } $price=json_decode($val->price); if($price!=""){ $data['price']=json_encode($price); }else{ $price=array(); $data['price']=json_encode($price); } $data['cgst']=$val->cgst; $data['sgst']=$val->sgst; $data['cgst_amount']=$val->cgst_amount; $data['sgst_amount']=$val->sgst_amount; $data['total']=$val->total; $data['total_amount']=$val->total_amount; $data['total_amount_words']=$val->total_amount_words; $data['tds_amount']=$val->tds_amount; $data['grand_total']=$val->grand_total; $data['created_at']=$val->created_at; $data['updated_at']=$val->updated_at; $data['delete_status']=$val->delete_status; $data['created_by']=$val->created_by; $table='invoice_reports'; $report_result=$this->yaskawa_model->insert($table,$data); } echo json_encode(array('result'=>1,'from_date'=>$from_date,'to_date'=>$to_date)); } else { echo json_encode(array('result'=>0,'message'=>'No data Found')); } } } else { redirect('/'); } } public function generate_invoice_reports() { $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $table='invoice_reports'; $where=array('delete_status'=>'ACTIVE'); $result=$this->yaskawa_model->get_data($table,$where); if($result) { echo json_encode($result); } else { echo json_encode(array('result'=>0,'message'=>'No data Found')); } } else { redirect('/'); } } public function invoice_reports(){ $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $data['company_details']=$this->yaskawa_model->fetch_company_details(); $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count=0; foreach($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if($months=='11'){ $count+=1; } } $data['count']=$count; $this->load->view('admin/invoice_reports',$data); } else { redirect('/'); } } public function edit_invoice_payment() { $admin_id = $this->session->userdata('admin_id'); if($admin_id) { echo json_encode(array('result'=>1)); } else { redirect('/'); } } public function edit_invoice_payments() { $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $payment_id=$this->uri->segment(2); $table='invoice_payments'; $where=array('payment_id'=>$payment_id); $data['result']=$this->yaskawa_model->get_data_row($table,$where); $data['company_details']=$this->yaskawa_model->fetch_company_details(); $data['invoice_amount']=number_format($data['result']->amount); $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count=0; foreach($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if($months=='11'){ $count+=1; } } $data['count']=$count; $this->load->view('admin/edit_invoice_payment',$data); } else { redirect('/'); } } public function update_payment() { $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $payment_id=$this->input->post('id'); $paid_to=$this->input->post('favour_of'); $collected_by=$this->input->post('collected_by'); $amount=$this->input->post('amount'); $payment_type=$this->input->post('payment_type'); $no=$this->input->post('no'); $date=$this->input->post('date'); $bank=$this->input->post('bank'); $branch=$this->input->post('branch'); $table='invoice_payments'; $invoice_amount=str_replace(',','',$amount); if($payment_type=='Cheque') { $data = array('favour_of' =>$paid_to, 'collected_by' =>$collected_by, 'payment_type' =>$payment_type, 'amount' =>$invoice_amount, 'dd_no' =>"", 'dd_date' =>"", 'utr_no' =>"", 'online_date' =>"", 'cheque_no' =>$no, 'cheque_date' =>$date, 'bank_name' =>$bank, 'branch_name' =>$branch); } else if($payment_type=='DD') { $data = array('favour_of' =>$paid_to, 'collected_by' =>$collected_by, 'payment_type' =>$payment_type, 'amount' =>$invoice_amount, 'cheque_no' =>"", 'cheque_date' =>"", 'utr_no' =>"", 'online_date' =>"", 'dd_no' =>$no, 'dd_date' =>$date, 'bank_name' =>$bank, 'branch_name' =>$branch); } else if($payment_type=='Online Payment') { $data = array('favour_of' =>$paid_to, 'collected_by' =>$collected_by, 'payment_type' =>$payment_type, 'amount' =>$invoice_amount, 'cheque_no' =>"", 'cheque_date' =>"", 'dd_no' =>"", 'dd_date' =>"", 'utr_no' =>$no, 'online_date' =>$date); } else { $data = array('favour_of' =>$paid_to, 'collected_by' =>$collected_by, 'payment_type' =>$payment_type, 'cheque_no' =>"", 'cheque_date' =>"", 'dd_no' =>"", 'dd_date' =>"", 'utr_no' =>"", 'online_date' =>"", 'amount' =>$invoice_amount); } $table='invoice_payments'; $where =array('payment_id'=>$payment_id,'delete_status'=>'ACTIVE'); $created_at = date('Y-m-d'); $data['updated_at']=$created_at; $result=$this->yaskawa_model->delete_detail($where,$data,$table); if($result) { echo json_encode (array('result'=>1)); } } else { redirect('/'); } } public function delete_payment() { $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $payment_id = $this->input->post('id'); $table ='invoice_payments'; $data = array('delete_status'=>'INACTIVE'); $where =array('payment_id'=>$payment_id,'delete_status'=>'ACTIVE'); $result = $this->yaskawa_model->delete_detail($where,$data,$table); if($result) { echo json_encode(array('result'=>1,'message'=>'Deleted successfully')); } else { echo json_encode(array('result'=>0)); } } else { redirect('/'); } } public function releaving_letter() { $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $emp_id = $this->uri->segment(2); $where = array('delete_status'=>'ACTIVE','emp_id'=>$emp_id); $table="employees"; $data['releaving_result'] = $this->yaskawa_model->get_resignation_data($emp_id); if(($data['releaving_result']->date_of_exit)!="") { $date = $data['releaving_result']->date_of_exit; $data['exit_date'] = date('F jS, Y', strtotime($date)); } else { $data['exit_date'] = ""; } $this->load->view('admin/resign',$data); } else { redirect('/'); } } public function lead_data(){ $id=$this->input->post('id'); $table="quotations"; $where=array('quotation_id'=>$id); $result=$this->yaskawa_model->get_single_row($table,$where); if($result->lead_id!='0'){ $lead_id=$result->lead_id; $table="leads"; $where=array('lead_id'=>$lead_id); $result_new=$this->yaskawa_model->get_single_row($table,$where); }else{ $id=$result->potential_id; $result_new=$this->yaskawa_model->get_potentialnew_detail_new($id); if($result_new->email!=''){ $result_new=$result_new; }else{ $result_new=$this->yaskawa_model->get_potentialaccount_detail($id); } } echo json_encode($result_new); } public function get_invoice_email(){ $id=$this->input->post('id'); //print_r($id); die(); $where=array('id'=>$id); $table="invoice"; $result1=$this->yaskawa_model->get_single_row($table,$where); $where_new=array('account_id'=>$result1->account_id); $table="new_account"; $result=$this->yaskawa_model->get_single_row($table,$where_new); echo json_encode($result); } public function get_invoice_report_details(){ $table="invoice_reports"; $result=$this->yaskawa_model->get_invoice_reports_details(); $array=array(); foreach($result as $key => $value) { $data['invoice_date']=$value->invoice_date; $data['name'] =$value->name; $data['invoice_no'] =$value->invoice_no; $data['address']=$value->address; $data['invoice_status']=$value->invoice_status; $data['total_amount']=$value->total_amount; $data['gstn']=$value->gstn; $data['description']=$value->description; $data['sac']=$value->sac; $data['price']=$value->price; $data['cgst']=$value->cgst; $data['sgst']=$value->sgst; $data['cgst_amount']=$value->cgst_amount; $data['sgst_amount']=$value->sgst_amount; $data['grand_total']=$value->grand_total; $data['created_by']=$value->created_by; $data['id']=$value->id; $id=$value->id; $where=array('invoice_id'=>$id); $table="invoice_payments"; $payments=$this->yaskawa_model->fetch_where_data($table,$where); if(!empty($payments)){ $data['payments']=$payments; }else{ $data['payments']='null'; } array_push($array,$data); } echo json_encode($array); } public function print_invoice() { $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $table='masters'; $where_gst=array('field_label'=>'gst','delete_status'=>'ACTIVE'); $where_sgst=array('field_label'=>'sgst','delete_status'=>'ACTIVE'); $data_gst=$this->yaskawa_model->get_data_row($table,$where_gst); $data['gst']=json_decode($data_gst->field_value); $data_sgst=$this->yaskawa_model->get_data_row($table,$where_sgst); $data['invoice_id']=$this->yaskawa_model->get_invoice_id(); $data['sgst']=json_decode($data_sgst->field_value); $id=$this->uri->segment(2); $table='invoice'; $where=array('id'=>$id,'delete_status'=>'ACTIVE'); $data['result']=$this->yaskawa_model->get_data_row($table,$where); $table="invoice_payments"; $where=array('invoice_id'=>$id); $data['payment']=$this->yaskawa_model->get_customer_result($table,$where); $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count=0; foreach($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if($months=='11'){ $count+=1; } } $data['count']=$count; $this->load->view('admin/print_invoice',$data); } else { redirect('/'); } } public function get_user_details_new(){ $id=$this->input->post('id'); $where=array('user_id'=>$id); $table="users"; $result=$this->yaskawa_model->get_single_row($table,$where); echo json_encode($result); } public function get_roles_list(){ $roles = $this->yaskawa_model->get_roles(); echo json_encode($roles); } public function update_new_users(){ $user_id = $this->input->post('user_id'); $role_id = $this->input->post('role'); $role=$this->input->post('role_id'); $fname = $this->input->post('fname'); $lname = $this->input->post('lname'); $email = $this->input->post('email'); $zone = $this->input->post('zone'); $profile_pic = $this->input->post('profile_pic'); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $updated_at = $date->format('Y-m-d H:i:s'); $insert=array( 'user_name' => $fname, 'user_type_id' => '2', 'department_id' => '3', 'last_name' => $lname, 'email' => $email, 'role_id' => $role_id, 'role' => $role, 'zone' => $zone, //'password' => md5('password'), //'profile_pick' => $file_name, 'updated_at' => $updated_at, ); $this->load->library('image_lib'); $file_name = ""; if($_FILES) { if(empty($_FILES['profile_pic']['name'])) { //$file_name = ""; } else { $target='profile_pictures/'; $target.=time().$_FILES['profile_pic']['name']; $file_name=time().$_FILES['profile_pic']['name']; $image=$target; move_uploaded_file($_FILES['profile_pic']['tmp_name'],$target); $config['source_image']=$target; $config['maintain_ratio']=TRUE; $this->image_lib->initialize($config); $insert['profile_pick']=$file_name; } } $id=$this->input->post('user_id'); $result = $this->yaskawa_model->update_user($id,$insert); if($result) { echo json_encode(array('result'=>1,'res'=>$result)); } else { echo json_encode(array('result'=>0)); } } public function update_password_new(){ $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $data['company_details']=$this->yaskawa_model->fetch_company_details(); $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count=0; foreach($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if($months=='11'){ $count+=1; } } $data['count']=$count; $this->load->view('admin/update_password',$data); } else { redirect('/'); } } public function password_update(){ $email=$this->input->post('email'); $password=$this->input->post('password'); $where=array('user_id'=>$this->session->userdata('admin_id')); $table="users"; $result=$this->yaskawa_model->get_single_row($table,$where); $confirm_password=$this->input->post('confirm_password'); if($result){ $pass_prefix = '$2a$05$'; $pass_suffix = '$'; $Allowed_Chars ='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789./'; $Chars_Len = 63; $Salt_Length = 21; $salt_password = ""; $salt_password=$result->salt_pass; $encrypted_pass = $pass_prefix . $salt_password . $pass_suffix; $hashed_password = crypt($password,$encrypted_pass); $where=array('email'=>$email); $data=array('password'=>$hashed_password); $table="users"; $result=$this->yaskawa_model->update_single($where,$table,$data); echo json_encode(array('result'=>1,'message'=>"password updated successfully")); }else{ echo json_encode(array('result'=>2,'message'=>"you have entered wrong Email")); } } public function update_lead_new(){ $id=$this->input->post('id'); $table="leads"; $where=array('lead_id'=>$id); $data=array('delete_status'=>'INACTIVE'); $result=$this->yaskawa_model->update_new($table,$where,$data); if($result){ echo json_encode(array('result'=>1,'message'=>"Deleted Successfully")); }else{ echo json_encode(array('result'=>0,'message'=>"Something went wrong")); } } public function delete_attach_notes(){ $id=$this->input->post('id'); $table="account_attach_notes"; $where=array('notes_id'=>$id); $result=$this->yaskawa_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 delete_potential_attach_notes(){ $id=$this->input->post('id'); $table="account_attach_notes"; $where=array('notes_id'=>$id); $result=$this->yaskawa_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 delete_account_attach_notes(){ $id=$this->input->post('id'); $table="account_attach_notes"; $where=array('notes_id'=>$id); $result=$this->yaskawa_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 update_invoice_status(){ $res=$this->yaskawa_model->get_invoice_list(); foreach ($res as $key => $value) { $where=array('invoice_id'=>$value->id); $table="invoice_payments"; $s=$this->yaskawa_model->get_invoice_sum_value($where,$table); $array=array( 'invoice_id'=>$s->invoice_id, 'amount' =>$s->amount ); if($s->invoice_id!=''){ if($s->amount==$value->grand_total){ $data=array('invoice_status'=>'CLEARED'); $where=array('id'=>$value->id); $table="invoice"; $result=$this->yaskawa_model->update_invoice_payments($where,$data,$table); } else if($s->amount!=$value->grand_total){ $data=array('invoice_status'=>'PARTIAL'); $where=array('id'=>$value->id); $table="invoice"; $result=$this->yaskawa_model->update_invoice_payments($where,$data,$table); } }else{ $data=array('invoice_status'=>'PENDING'); $where=array('id'=>$value->id); $table="invoice"; $result=$this->yaskawa_model->update_invoice_payments($where,$data,$table); } //echo json_encode(array('result'=>'1','message'=>'updated successfully')); } } public function update_invoice(){ $invoice_id=$this->input->post('invoice_id'); $others=$this->input->post('others'); $reason=$this->input->post('reason'); $where=array('id'=>$invoice_id); $table="invoice"; $data=array('invoice_status'=>'CLEARED','reason'=>$reason,'others'=>$others); $result=$this->yaskawa_model->update_invoice_payments($where,$data,$table); if($result){ echo json_encode(array('result'=>'1','message'=>'Updated Successfully')); }else{ echo json_encode(array('result'=>'0','message'=>'Not Updated')); } } //add_new_leads view public function pay_slip(){ $emp_id = $this->uri->segment(2); $where=array('emp_id'=>$emp_id); $table="employees"; $result['emp']=$this->yaskawa_model->get_employee_row($emp_id); $admin_id = $this->session->userdata('admin_id'); $role_id = $this->session->userdata('role_id'); if($admin_id) { $result['user_type_id'] = $this->access_id(); $result['access'] = $this->access_details(); //$result['lead_list'] = $this->yaskawa_model->get_all_leads($role_id); $result['company_details']=$this->yaskawa_model->fetch_company_details(); $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count=0; foreach($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if($months=='11'){ $count+=1; } } $data['count']=$count; $this->load->view('admin/pay_slip',$result); } else { redirect('/'); } } public function product_reneval(){ $admin_id = $this->session->userdata('admin_id'); $role_id = $this->session->userdata('role_id'); if($admin_id) { $result['user_type_id'] = $this->access_id(); $result['access'] = $this->access_details(); $where=array('master_type_id'=>'18','delete_status'=>'ACTIVE'); $table="masters"; $result['category']=$this->yaskawa_model->get_single_row($table,$where); $result['company_details']=$this->yaskawa_model->fetch_company_details(); $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count=0; foreach($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if($months=='11'){ $count+=1; } } $result['count']=$count; $this->load->view('admin/product_reneval',$result); } else { redirect('/'); } } public function reneval_list(){ $admin_id = $this->session->userdata('admin_id'); $role_id = $this->session->userdata('role_id'); if($admin_id) { $result['user_type_id'] = $this->access_id(); $result['access'] = $this->access_details(); $result['company_details']=$this->yaskawa_model->fetch_company_details(); $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count=0; foreach($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if($months=='11'){ $count+=1; } } $result['count']=$count; $this->load->view('admin/renewal_list',$result); } else { redirect('/'); } } public function get_renewal_list_data(){ $table="product_renewal"; $where=array('delete_status'=>'ACTIVE'); $result=$this->yaskawa_model->get_renewal_list_data($table,$where); echo json_encode($result); } public function add_product_renewal(){ $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $created_at = $date->format('Y-m-d H:i:s'); $product_start=$this->input->post('product_start'); if($product_start != "") { $product_start = date('Y-m-d',strtotime($product_start)); } else { $product_start = ""; } $amc_date=$this->input->post('amc_date'); if($amc_date != "") { $amc_date = date('Y-m-d',strtotime($amc_date)); } else { $amc_date = ""; } $notify_before_date=$this->input->post('notify_before_date'); if($notify_before_date != "") { $notify_before_date = date('Y-m-d',strtotime($notify_before_date)); } else { $notify_before_date = ""; } $document_renewal_date=$this->input->post('document_renewal_date'); if($document_renewal_date != "") { $document_renewal_date = date('Y-m-d',strtotime($document_renewal_date)); } else { $document_renewal_date = ''; } $agreement_renewal_date=$this->input->post('agreement_renewal_date'); if($agreement_renewal_date != "") { $agreement_renewal_date=date('Y-m-d',strtotime($agreement_renewal_date)); } else { $agreement_renewal_date = ''; } $p_c=$this->input->post('product_radio'); if($p_c==''){ $p_c=''; } $d_c=$this->input->post('document_radio'); if($d_c == ''){ $d_c=''; } $a_c=$this->input->post('agreement_radio'); if($a_c==''){ $a_c=''; } $amc=$this->input->post('amc_status'); if($amc==''){ $amc=''; } $data=array( 'category' =>$this->input->post('category'), 'category_product' =>$p_c, 'category_document' =>$d_c, 'category_agreement' =>$a_c, 'product_name' =>$this->input->post('product_name'), 'product_start_date' =>$product_start, 'product_des' =>$this->input->post('product_description'), 'amc_status' =>$amc, 'amc_date' =>$amc_date, 'notify_before_date' =>$notify_before_date, 'document_name' =>$this->input->post('document_name'), 'document_desc' =>$this->input->post('description'), 'doc_renewal_date' =>$document_renewal_date, 'agreement_name' =>$this->input->post('agreement_name'), 'agreement_desc' =>$this->input->post('agreement_desc'), 'agree_renewal_date' =>$agreement_renewal_date, 'delete_status' =>'ACTIVE', 'created_at' =>$created_at); $this->load->library('image_lib'); $file_name = ""; if($_FILES) { if(empty($_FILES['purchase_bill']['name'])) { } else { $target='products/'; $target.=time().$_FILES['purchase_bill']['name']; $file_name=time().$_FILES['purchase_bill']['name']; $image=$target; move_uploaded_file($_FILES['purchase_bill']['tmp_name'],$target); $config['source_image']=$target; $config['maintain_ratio']=TRUE; $this->image_lib->initialize($config); $data['purchase_bill']=$file_name; } } $file_name = ""; if($_FILES) { if(empty($_FILES['product_image']['name'])) { } else { $target='products/'; $target.=time().$_FILES['product_image']['name']; $file_name=time().$_FILES['product_image']['name']; $image=$target; move_uploaded_file($_FILES['product_image']['tmp_name'],$target); $config['source_image']=$target; $config['maintain_ratio']=TRUE; $this->image_lib->initialize($config); $data['product_image']=$file_name; } } $file_name = ""; if($_FILES) { if(empty($_FILES['upload_document']['name'])) { } else { $target='products/'; $target.=time().$_FILES['upload_document']['name']; $file_name=time().$_FILES['upload_document']['name']; $image=$target; move_uploaded_file($_FILES['upload_document']['tmp_name'],$target); $config['source_image']=$target; $config['maintain_ratio']=TRUE; $this->image_lib->initialize($config); $data['upload_document']=$file_name; } } $file_name = ""; if($_FILES) { if(empty($_FILES['upload_document_new']['name'])) { } else { $target='products/'; $target.=time().$_FILES['upload_document_new']['name']; $file_name=time().$_FILES['upload_document_new']['name']; $image=$target; move_uploaded_file($_FILES['upload_document_new']['tmp_name'],$target); $config['source_image']=$target; $config['maintain_ratio']=TRUE; $this->image_lib->initialize($config); $data['document_upload']=$file_name; } } $file_name = ""; if($_FILES) { if(empty($_FILES['agreement_upload']['name'])) { } else { $target='products/'; $target.=time().$_FILES['agreement_upload']['name']; $file_name=time().$_FILES['agreement_upload']['name']; $image=$target; move_uploaded_file($_FILES['agreement_upload']['tmp_name'],$target); $config['source_image']=$target; $config['maintain_ratio']=TRUE; $this->image_lib->initialize($config); $data['agreement_upload']=$file_name; } } $table="product_renewal"; $result=$this->yaskawa_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 delete_products_renewal(){ $id=$this->input->post('id'); $where=array('product_id'=>$id); $table="product_renewal"; $data=array('delete_status'=>'INACTIVE'); $result=$this->yaskawa_model->update_invoice_payments($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 edit_reneval_list(){ $admin_id = $this->session->userdata('admin_id'); $role_id = $this->session->userdata('role_id'); if($admin_id) { $result['user_type_id'] = $this->access_id(); $result['access'] = $this->access_details(); $where=array('master_type_id'=>'18','delete_status'=>'ACTIVE'); $table="masters"; $result['category']=$this->yaskawa_model->get_single_row($table,$where); $id = $this->uri->segment(2); $table="product_renewal"; $where=array('product_id'=>$id); $result['renewal']=$this->yaskawa_model->get_single_row($table,$where); $result['company_details']=$this->yaskawa_model->fetch_company_details(); $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count=0; foreach($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if($months=='11'){ $count+=1; } } $result['count']=$count; $this->load->view('admin/edit_renewal',$result); } else { redirect('/'); } } public function update_product_renewal(){ $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $created_at = $date->format('Y-m-d'); $product_id=$this->input->post('product_id'); $product_start=$this->input->post('product_start'); $product_start=date('Y-m-d',strtotime($product_start)); $amc_date=$this->input->post('amc_date'); $amc_date=date('Y-m-d',strtotime($amc_date)); $notify_before_date=$this->input->post('notify_before_date'); $notify_before_date=date('Y-m-d',strtotime($notify_before_date)); $document_renewal_date=$this->input->post('document_renewal_date'); $document_renewal_date=date('Y-m-d',strtotime($document_renewal_date)); $agreement_renewal_date=$this->input->post('agreement_renewal_date'); $agreement_renewal_date=date('Y-m-d',strtotime($agreement_renewal_date)); $p_c=$this->input->post('product_radio'); if($p_c==''){ $p_c=''; } $d_c=$this->input->post('document_radio'); if($d_c == ''){ $d_c=''; } $a_c=$this->input->post('agreement_radio'); if($a_c==''){ $a_c=''; } $amc=$this->input->post('amc_status'); if($amc==''){ $amc=''; } $data=array( 'category' =>$this->input->post('category'), 'category_product' =>$p_c, 'category_document' =>$d_c, 'category_agreement' =>$a_c, 'product_name' =>$this->input->post('product_name'), 'product_start_date' =>$product_start, 'product_des' =>$this->input->post('product_description'), 'amc_status' =>$amc, 'amc_date' =>$amc_date, 'notify_before_date' =>$notify_before_date, 'document_name' =>$this->input->post('document_name'), 'document_desc' =>$this->input->post('description'), 'doc_renewal_date' =>$document_renewal_date, 'agreement_name' =>$this->input->post('agreement_name'), 'agreement_desc' =>$this->input->post('agreement_desc'), 'agree_renewal_date' =>$agreement_renewal_date, 'delete_status' =>'ACTIVE', 'created_at' =>$created_at); $this->load->library('image_lib'); $file_name = ""; if($_FILES) { if(empty($_FILES['purchase_bill']['name'])) { } else { $target='products/'; $target.=time().$_FILES['purchase_bill']['name']; $file_name=time().$_FILES['purchase_bill']['name']; $image=$target; move_uploaded_file($_FILES['purchase_bill']['tmp_name'],$target); $config['source_image']=$target; $config['maintain_ratio']=TRUE; $this->image_lib->initialize($config); $data['purchase_bill']=$file_name; } } $file_name = ""; if($_FILES) { if(empty($_FILES['product_image']['name'])) { } else { $target='products/'; $target.=time().$_FILES['product_image']['name']; $file_name=time().$_FILES['product_image']['name']; $image=$target; move_uploaded_file($_FILES['product_image']['tmp_name'],$target); $config['source_image']=$target; $config['maintain_ratio']=TRUE; $this->image_lib->initialize($config); $data['product_image']=$file_name; } } $file_name = ""; if($_FILES) { if(empty($_FILES['upload_document']['name'])) { } else { $target='products/'; $target.=time().$_FILES['upload_document']['name']; $file_name=time().$_FILES['upload_document']['name']; $image=$target; move_uploaded_file($_FILES['upload_document']['tmp_name'],$target); $config['source_image']=$target; $config['maintain_ratio']=TRUE; $this->image_lib->initialize($config); $data['upload_document']=$file_name; } } $file_name = ""; if($_FILES) { if(empty($_FILES['upload_document_new']['name'])) { } else { $target='products/'; $target.=time().$_FILES['upload_document_new']['name']; $file_name=time().$_FILES['upload_document_new']['name']; $image=$target; move_uploaded_file($_FILES['upload_document_new']['tmp_name'],$target); $config['source_image']=$target; $config['maintain_ratio']=TRUE; $this->image_lib->initialize($config); $data['document_upload']=$file_name; } } $file_name = ""; if($_FILES) { if(empty($_FILES['agreement_upload']['name'])) { } else { $target='products/'; $target.=time().$_FILES['agreement_upload']['name']; $file_name=time().$_FILES['agreement_upload']['name']; $image=$target; move_uploaded_file($_FILES['agreement_upload']['tmp_name'],$target); $config['source_image']=$target; $config['maintain_ratio']=TRUE; $this->image_lib->initialize($config); $data['agreement_upload']=$file_name; } } $where=array('product_id'=>$product_id); $table="product_renewal"; $result=$this->yaskawa_model->update_invoice_payments($where,$data,$table); if($result){ echo json_encode(array('result'=>'1','message'=>'Added Sucessfully')); }else{ echo json_encode(array('result'=>'0','message'=>'Not Added')); } } public function add_employee_salary(){ $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $data['company_details']=$this->yaskawa_model->fetch_company_details(); $table="employees"; $where=array('delete_status'=>'Active','employee_status'=>'Active'); $data['employee']=$this->yaskawa_model->get_emp_list($table,$where); $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count=0; foreach($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if($months=='11'){ $count+=1; } } $data['count']=$count; $this->load->view('admin/add_salary',$data); } else { redirect('/'); } } public function add_salary_employee(){ $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $created_at = $date->format('Y-m-d H:i:s'); $earning=$this->input->post('earning'); $earning=str_replace(',','',$earning); $deduction=$this->input->post('deduction'); $deduction=str_replace(',','',$deduction); $basic=$this->input->post('basic'); $basic=str_replace(',','',$basic); $hra=$this->input->post('hra'); $hra=str_replace(',','',$hra); $ca=$this->input->post('ca'); $ca=str_replace(',','',$ca); $prof_tax=$this->input->post('prof_tax'); $prof_tax=str_replace(',','',$prof_tax); $special_allowance=$this->input->post('special_allowance'); $special_allowance=str_replace(',','',$special_allowance); $gross_earning=$this->input->post('gross_earning'); $gross_earning=str_replace(',','',$gross_earning); $gross_deduction=$this->input->post('gross_deduction'); $gross_deduction=str_replace(',','',$gross_deduction); $net_pay=$this->input->post('net_pay'); $net_pay=str_replace(',','',$net_pay); $data=array( 'emp_id' => $this->input->post('emp_id'), 'earning' => $earning, 'deduction' => $deduction, 'basic' => $basic, 'hra' => $hra, 'ca' => $ca, 'prof_tax' => $prof_tax, 'special_allowance' => $special_allowance, 'gross_earning' => $gross_earning, 'gross_deduction' => $gross_deduction, 'net_pay' => $net_pay, 'created_at' =>$created_at ); $table="salary"; $result=$this->yaskawa_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 salary_list(){ $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $data['company_details']=$this->yaskawa_model->fetch_company_details(); $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count=0; foreach($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if($months=='11'){ $count+=1; } } $data['count']=$count; $this->load->view('admin/salary_list',$data); } else { redirect('/'); } } public function get_emp_salary_list(){ $result=$this->yaskawa_model->get_emp_salary_list(); echo json_encode($result); } public function delete_employee_salary(){ $id=$this->input->post('id'); $result=$this->yaskawa_model->delete_salary_emp($id); if($result){ echo json_encode(array('result'=>'1','message'=>'Deleted Sucessfully')); }else{ echo json_encode(array('result'=>'0','message'=>'Not Deleted')); } } public function update_salary(){ $admin_id = $this->session->userdata('admin_id'); $emp_id = $this->uri->segment(2); if($admin_id) { $data['user_type_id'] = $this->access_id(); $table="salary"; $where=array('salary_id'=>$emp_id); $data['sal']=$this->yaskawa_model->get_single_row($table,$where); $table="employees"; $where=array('delete_status'=>'Active'); $data['employee']=$this->yaskawa_model->get_customer_result($table,$where); $data['access'] = $this->access_details(); $data['company_details']=$this->yaskawa_model->fetch_company_details(); $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count=0; foreach($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if($months=='11'){ $count+=1; } } $data['count']=$count; $this->load->view('admin/edit_salary',$data); } else { redirect('/'); } } public function update_emp_salary(){ $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $created_at = $date->format('Y-m-d'); $salary_id=$this->input->post('salary_id'); $earning=$this->input->post('earning'); $earning=str_replace(',','',$earning); $deduction=$this->input->post('deduction'); $deduction=str_replace(',','',$deduction); $basic=$this->input->post('basic'); $basic=str_replace(',','',$basic); $hra=$this->input->post('hra'); $hra=str_replace(',','',$hra); $ca=$this->input->post('ca'); $ca=str_replace(',','',$ca); $prof_tax=$this->input->post('prof_tax'); $prof_tax=str_replace(',','',$prof_tax); $special_allowance=$this->input->post('special_allowance'); $special_allowance=str_replace(',','',$special_allowance); $gross_earning=$this->input->post('gross_earning'); $gross_earning=str_replace(',','',$gross_earning); $gross_deduction=$this->input->post('gross_deduction'); $gross_deduction=str_replace(',','',$gross_deduction); $net_pay=$this->input->post('net_pay'); $net_pay=str_replace(',','',$net_pay); $salary_id=$this->input->post('salary_id'); $data=array( 'emp_id' => $this->input->post('emp_id'), 'earning' => $earning, 'deduction' => $deduction, 'basic' => $basic, 'hra' => $hra, 'ca' => $ca, 'prof_tax' => $prof_tax, 'special_allowance' => $special_allowance, 'gross_earning' => $gross_earning, 'gross_deduction' => $gross_deduction, 'net_pay' => $net_pay, 'updated_at' =>$created_at ); $table="salary"; $where=array('salary_id'=>$salary_id); $result=$this->yaskawa_model->update_invoice_payments($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 add_message(){ $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $data['user_type_id'] = $this->access_id(); $table="msg_template"; $where=array('delete_status'=>'ACTIVE'); $data['message']=$this->yaskawa_model->get_customer_result($table,$where); $data['access'] = $this->access_details(); $data['honorific']=$this->yaskawa_model->get_honorific(); $data['user_name']= $this->session->userdata('user_name'); $data['user_details']=$this->yaskawa_model->get_user_details(); $data['lead_source']=$this->yaskawa_model->get_lead_source_details(); $data['potential_details']=$this->yaskawa_model->select_new_potential($admin_id); $data['account_persons']=$this->yaskawa_model->account_details(); $data['company_details']=$this->yaskawa_model->fetch_company_details(); $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count=0; foreach($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if($months=='11'){ $count+=1; } } $data['count']=$count; $this->load->view('admin/add_message',$data); } else { redirect('/'); } } public function search_client(){ $val=$this->input->post('val'); $result=$this->yaskawa_model->search_client($val); echo json_encode($result); } public function send_message(){ $client=$this->input->post('client'); $phone_number=$this->input->post('phone_number'); $message=$this->input->post('message'); $status=$this->input->post('status'); if($status=='Single') { $data=array( 'client' =>$client, 'phone_number' =>$phone_number, 'message' =>$message ); $table="sms"; $result=$this->yaskawa_model->insert($table,$data); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, 'http://sms.jayblues.com/http-api.php?'); curl_setopt($ch, CURLOPT_POSTFIELDS, "username=subr1634&password=123321&senderid=JBLUES&route=1&number=$phone_number&message=$message"); curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30); curl_setopt($ch, CURLOPT_TIMEOUT, 30); $data = curl_exec($ch); $httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE); curl_close($ch); if($result){ echo json_encode(array('result'=>'1','message'=>'Sent Sucessfully')); }else{ echo json_encode(array('result'=>'0','message'=>'Not Updated')); } }else{ $data=array( 'client' =>'null', 'phone_number' =>0, 'message' =>$message ); $table="sms"; $result=$this->yaskawa_model->insert($table,$data); $res=$this->yaskawa_model->get_account_phone_number(); $res_new=$this->yaskawa_model->get_leads_phone_number(); $res_neww=$this->yaskawa_model->get_contact_phone_number(); $arr=array_merge($res,$res_new); $arr=array_merge($arr,$res_neww); foreach ($arr as $key => $value) { if($value->phone!=''){ $phon=$value->phone; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, 'http://sms.jayblues.com/http-api.php?'); curl_setopt($ch, CURLOPT_POSTFIELDS, "username=subr1634&password=123321&senderid=JBLUES&route=1&number=$phon&message=$message"); curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30); curl_setopt($ch, CURLOPT_TIMEOUT, 30); $data = curl_exec($ch); $httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE); curl_close($ch); } } if($result){ echo json_encode(array('result'=>'1','message'=>'Sent Sucessfully')); }else{ echo json_encode(array('result'=>'0','message'=>'Not Updated')); } } } public function send_quotation_message(){ // $phone_number=$this->input->post('phone_number'); // $message=$this->input->post('message_text'); // $ch = curl_init(); // curl_setopt($ch, CURLOPT_URL, 'http://sms.jayblues.com/http-api.php?'); // curl_setopt($ch, CURLOPT_POSTFIELDS, "username=subr1634&password=123321&senderid=JBLUES&route=1&number=$phone_number&message=$message"); // curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']); // curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30); // curl_setopt($ch, CURLOPT_TIMEOUT, 30); // $data = curl_exec($ch); // $httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE); // curl_close($ch); // echo json_encode(array('result'=>'1','message'=>'Sent Sucessfully')); $contact_number = $this->input->post('phone_number'); $sms_message_new = $this->input->post('message_text'); $url = "http://sms.jayblues.com/http-api.php?"; $postData2 = array( 'username'=> 'jayerp', 'password'=>'Password@1236', 'senderid'=>'JAYERP', 'route'=>1, 'message' => $sms_message_new, 'number' => $contact_number ); $ch2 = curl_init(); curl_setopt_array($ch2, array( CURLOPT_URL => $url, CURLOPT_RETURNTRANSFER => true, CURLOPT_POST => true, CURLOPT_POSTFIELDS => $postData2 )); $output1 = curl_exec($ch2); if(curl_errno($ch2)) { echo 'error:' . curl_error($ch2); } else { echo json_encode(array('result'=>'1','message'=>'Sent Sucessfully')); } curl_close($ch2); } public function add_contact_new(){ $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $data['honorific']=$this->yaskawa_model->get_honorific(); $data['user_name']= $this->session->userdata('user_name'); $data['user_details']=$this->yaskawa_model->get_user_details(); $data['lead_source']=$this->yaskawa_model->get_lead_source_details(); $data['potential_details']=$this->yaskawa_model->select_new_potential($admin_id); $data['account_persons']=$this->yaskawa_model->account_details(); $data['company_details']=$this->yaskawa_model->fetch_company_details(); $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count=0; foreach($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if($months=='11'){ $count+=1; } } $data['count']=$count; $this->load->view('admin/add_new_contact',$data); } else { redirect('/'); } } public function quotation_change_status(){ $table="quotations"; $where=array('delete_status'=>'ACTIVE','quotation_status'=>'WAITING'); $result=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $created_at = $date->format('Y-m-d'); foreach($result as $key => $value) { $quo_date = strtotime($value->quo_date); $final = date("Y-m-d", strtotime("+1 month", $quo_date)); if($final<$created_at){ $table="quotations"; $where=array('quotation_id'=>$value->quotation_id); $data=array('quotation_status'=>'EXPIRED'); $res=$this->yaskawa_model->update_invoice_payments($where,$data,$table); echo $res; } } } public function invoice_change_status(){ $table="invoice"; $where=array('delete_status'=>'ACTIVE','status'=>'WAITING'); $result=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $created_at = $date->format('Y-m-d'); foreach($result as $key => $value) { $quo_date = strtotime($value->invoice_date); $final = date("Y-m-d", strtotime("+1 month", $quo_date)); if($final<$created_at){ $table="invoice"; $where=array('id'=>$value->id); $data=array('status'=>'EXPIRED'); $res=$this->yaskawa_model->update_invoice_payments($where,$data,$table); echo $res; } } } public function get_amc_notification(){ $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count=0; $arr=array(); foreach($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if($months=='11'){ $data['website']=$value->website; $data['account_name']=$value->account_name; $data['account_id']=$value->account_id; array_push($arr,$data); } } echo json_encode(array('result'=>1,'notification'=>$arr)); } public function get_quotation_status_data(){ $status=$this->input->post('status'); $result=$this->yaskawa_model->get_quotation_status_data($status); echo json_encode($result); } public function delete_master_new(){ $master_type_id=$this->input->post('id'); $table="master_type"; $where=array('master_type_id'=>$master_type_id); $res=$this->yaskawa_model->delete_master_new($table,$where); echo json_encode(array('result'=>'1','msg'=>'Deleted Successfully')); } public function update_master_new(){ $table="master_type"; $master_type_id=$this->input->post('master_type_id'); $master_type=$this->input->post('master_type'); $data=array( 'master_type' =>$master_type ); $where=array('master_type_id'=>$master_type_id); $res=$this->yaskawa_model->update_invoice_payments($where,$data,$table); if($res){ echo json_encode(array('result'=>'1','message'=>'Updated Sucessfully')); }else{ echo json_encode(array('result'=>'0','message'=>'Not Updated')); } } public function add_master_new(){ $table="master_type"; $data=array('master_type'=>$this->input->post('master_type')); $res=$this->yaskawa_model->insert($table,$data); if($res){ echo json_encode(array('result'=>'1','message'=>'Added Sucessfully')); }else{ echo json_encode(array('result'=>'0','message'=>'Not Added')); } } public function get_employee_status_data(){ $status=$this->input->post('status'); $result=$this->yaskawa_model->get_employee_status_data($status); echo json_encode($result); } public function get_mastar_value(){ $id=$this->input->post('id'); $table="masters"; $where=array('master_type_id'=>$id); $result=$this->yaskawa_model->get_single_row($table,$where); if($result){ echo json_encode($result); }else{ $result='null'; echo json_encode($result); } } public function delete_master_data(){ $value=$this->input->post('value'); $m_id=$this->input->post('m_id'); $table="masters"; $where=array('master_id'=>$m_id); $res=$this->yaskawa_model->get_single_row($table,$where); $m_value=json_decode($res->field_value); $array = array(); foreach($m_value as $val) { array_push($array, $val); } if(($key = array_search($value, $array)) !== false) { unset($array[$key]); } $encoded = json_encode($array); $data['field_value']=$encoded; $table="masters"; $where=array('master_id'=>$m_id); $res=$this->yaskawa_model->update_invoice_payments($where,$data,$table); echo json_encode($res); } public function upload_emp_offer_letter(){ $table="employees"; $emp_id=$this->input->post('emp_id'); if($_FILES['upload_image']['name']) { $target='offer_letter/'; $target.=time().$_FILES['upload_image']['name']; $document_file=time().$_FILES['upload_image']['name']; $image=$target; move_uploaded_file($_FILES['upload_image']['tmp_name'],$target); } else { $document_file=""; } $where=array('emp_id' =>$emp_id); $ar=array('offer_letter'=>$document_file); $res=$this->yaskawa_model->update_invoice_payments($where,$ar,$table); redirect('employee-list'); } public function upload_relieve_letter(){ $table="employees"; $emp_id=$this->input->post('emp_id'); if($_FILES['upload_relieve']['name']) { $target='offer_letter/'; $target.=time().$_FILES['upload_relieve']['name']; $document_file=time().$_FILES['upload_relieve']['name']; $image=$target; move_uploaded_file($_FILES['upload_relieve']['tmp_name'],$target); } else { $document_file=""; } $where=array('emp_id' =>$emp_id); $ar=array('relieve_letter'=>$document_file); $res=$this->yaskawa_model->update_invoice_payments($where,$ar,$table); redirect('employee-list'); } public function add_template(){ $template=$this->input->post('template'); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d H:i:s'); $table="msg_template"; $data=array( 'template' => $template, 'created_at' => $date_format ); $result=$this->yaskawa_model->insert($table,$data); if($result){ echo json_encode(array('result'=>'1','message'=>'Added Sucessfully')); }else{ echo json_encode(array('result'=>'1','message'=>'Not Added')); } } public function get_tickets_notifications(){ $result=$this->yaskawa_model->get_tickets_notifications(); echo json_encode($result); } public function send_email_multiple(){ $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $data['company_details']=$this->yaskawa_model->fetch_company_details(); $table="msg_template"; $where=array('delete_status'=>'ACTIVE'); $data['message']=$this->yaskawa_model->get_customer_result($table,$where); $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count=0; foreach($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if($months=='11'){ $count+=1; } } $data['count']=$count; $this->load->view('admin/send_email',$data); } else { redirect('/'); } } public function ticket_notification(){ $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $data['company_details']=$this->yaskawa_model->fetch_company_details(); $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count=0; foreach($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if($months=='11'){ $count+=1; } } $data['count']=$count; $this->load->view('admin/tickets_notification',$data); } else { redirect('/'); } } public function send_email_to(){ $status=$this->input->post('status'); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d H:i:s'); $client=$this->input->post('client'); $to=$this->input->post('email'); $subject=$this->input->post('message_new'); if($status=='Single'){ $arr=array( 'client_name' => $this->input->post('client'), 'email' => $this->input->post('email'), 'message' => $this->input->post('message_new'), 'created_at' => $date_format ); if($_FILES['template']['name']) { $target='templates/'; $target.=time().$_FILES['template']['name']; $document_file=time().$_FILES['template']['name']; $image=$target; move_uploaded_file($_FILES['template']['tmp_name'],$target); } else { $document_file=""; } $arr['e_template']=$document_file; $table="email_template"; $result=$this->yaskawa_model->insert_access($table,$arr); if($result) { $table="email_template"; $r=$this->yaskawa_model->get_last_row_template(); $template=$r->e_template; $message=$subject; $message.='<img src="https://jayblues.com/jayerp/templates/'.$template.'">'; $attach=$r->e_template; $this->load->library('email'); $subject=$this->input->post('message_new'); $from='enquiry09.gta@gmail.com'; $name='Jayblues'; $config = array( 'protocol' => 'smtp', 'smtp_host' => 'smtp.gmail.com', 'smtp_port' => 587, 'smtp_user' => 'enquiry09.gta@gmail.com', 'smtp_pass' => 'phiw kvrj kofj jfid', '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()) { echo 1; } else { show_error($this->email->print_debugger()); } } } else{ $arr=array( 'client_name' => $this->input->post('client'), 'email' => 'null', 'message' => $this->input->post('message_new'), 'created_at' => $date_format ); if($_FILES['template']['name']) { $target='templates/'; $target.=time().$_FILES['template']['name']; $document_file=time().$_FILES['template']['name']; $image=$target; move_uploaded_file($_FILES['template']['tmp_name'],$target); } else { $document_file=""; } $arr['e_template']=$document_file; $table="email_template"; $result=$this->yaskawa_model->insert_access($table,$arr); if($result) { $table="email_template"; $r=$this->yaskawa_model->get_last_row_template(); $res=$this->yaskawa_model->get_account_phone_number(); $res_new=$this->yaskawa_model->get_leads_phone_number(); $res_neww=$this->yaskawa_model->get_contact_phone_number(); $arr=array_merge($res,$res_new); $arr=array_merge($arr,$res_neww); $rrr=array(); foreach($arr as $key => $value) { if($value->email!=''){ array_push($rrr,$value->email); } } $template=$r->e_template; $message=$subject; //$message.='JAYBLUES Wishes you all a Happy GOWRI and GANESHA CHATURTHI. #GaneshaChaturthi2018'.'<br/><br/>'; $message.='<img src="https://jayblues.com/jayerp/templates/'.$template.'">'; $attach=$r->e_template; $to=$value; $this->load->library('email'); $subject=$this->input->post('message_new'); $from='support@jayblues.com'; $name='Jayblues'; $config = array( 'protocol' => 'smtp', 'smtp_host' => 'smtp.gmail.com', 'smtp_port' => 587, 'smtp_user' => 'enquiry09.gta@gmail.com', 'smtp_pass' => 'phiw kvrj kofj jfid', 'mailtype' => 'html', 'charset' => 'utf-8' ); $this->email->initialize($config); $this->email->set_mailtype("html"); $this->email->set_newline("\r\n"); $this->email->to($rrr); $this->email->from($from,$name); $this->email->subject($subject); $this->email->message($message); if ($this->email->send()) { echo 1; } else { show_error($this->email->print_debugger()); } } } } public function get_today_ticket_notification(){ $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $result=$this->yaskawa_model->get_today_ticket_notification($date_format); echo json_encode(array('result'=>1,'notification'=>$result)); } public function get_week_ticket_notification(){ $array = array(); $timestamp = time(); for ($i = 0 ; $i < 7 ; $i++) { $dates = date('Y-m-d', $timestamp); $timestamp -= 24 * 3600; array_push($array,$dates); } $result=$this->yaskawa_model->get_week_ticket_notification($array); echo json_encode(array('result'=>1,'notification'=>$result)); } public function get_allday_ticket_notification(){ $result=$this->yaskawa_model->get_allday_ticket_notification(); echo json_encode(array('result'=>1,'notification'=>$result)); } public function add_action_access(){ $admin=$this->session->userdata('admin'); $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $data['menu'] = $this->yaskawa_model->get_all_menu_data(); $data['roles'] = $this->yaskawa_model->get_all_departments_data(); $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $data['company_details']=$this->yaskawa_model->fetch_company_details(); $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count=0; foreach($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if($months=='11'){ $count+=1; } } $data['count']=$count; $this->load->view('admin/add_action_access',$data); } else { redirect('/'); } } public function single_department_menu_access() { $table = 'yaskawa_access_controls'; $department_id = $this->input->post('department_id'); $where = array('delete_status' =>'ACTIVE','department_id' =>$department_id); $result = $this->yaskawa_model->get_single_row($table,$where); if($result) { $access = unserialize($result->menu_id); if($access) { $access_res = $this->yaskawa_model->single_department_menu_access($access,$department_id); if($access_res) { echo json_encode(array('access'=>$access_res,'result'=>1)); } else { echo json_encode(array('result'=>0)); } } else { echo json_encode(array('result'=>0)); } } else { echo json_encode(array('result'=>0)); } } public function search_contact(){ $val=$this->input->post('val'); $res=$this->yaskawa_model->search_contacts($val); echo json_encode($res); } public function get_contact_number(){ $id=$this->input->post('id'); $table="new_contact"; $where=array('contact_id'=>$id,'delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_single_row($table,$where); echo json_encode($res); } public function lead_report(){ $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count=0; foreach($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if($months=='11'){ $count+=1; } } $data['count']=$count; $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $data['company_details']=$this->yaskawa_model->fetch_company_details(); $this->load->view('admin/lead_report',$data); } else { redirect('/'); } } public function generate_lead_report(){ $from=$this->input->post('from_date'); $to=$this->input->post('to_date'); $from=date('Y-m-d',strtotime($from)); $to=date('Y-m-d',strtotime($to)); $result=$this->yaskawa_model->generate_lead_report($from,$to); echo json_encode($result); } public function lead_status_data(){ $status=$this->input->post('status'); $res=$this->yaskawa_model->lead_status_data($status); $arr=array(); foreach($res as $key => $value) { $data['lead_id']=$value->lead_id; $data['first_name']=$value->first_name; $data['company_name']=$value->company_name; $data['mobile']=$value->mobile; $data['street']=$value->street; $data['email']=$value->email; $data['create_at']=$value->c_date; $data['lead_convert']=$value->lead_convert; $data['converted_next_level']=$value->converted_next_level; $lead_id=$value->lead_id; $note=$this->yaskawa_model->get_row_by_desc($lead_id); if($note){ $data['note']=$note->lead_notes; }else{ $data['note']=''; } $data['user_name']=$value->user_name; array_push($arr,$data); } echo json_encode($arr); } public function lead_status_sort_data(){ $status=$this->input->post('status'); $from=$this->input->post('from'); $from=date('Y-m-d',strtotime($from)); $to=$this->input->post('to'); $to=date('Y-m-d',strtotime($to)); $res=$this->yaskawa_model->lead_status_sort_data($status,$from,$to); echo json_encode($res); } public function open_ticket_list(){ $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count=0; foreach($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if($months=='11'){ $count+=1; } } $data['count']=$count; $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $data['company_details']=$this->yaskawa_model->fetch_company_details(); $data['ticket_list']=$this->yaskawa_model->get_open_ticket_list(); $this->load->view('admin/open_ticket_list',$data); } else { redirect('/'); } } public function reject_quotation() { $id=$this->input->post('id'); $table="quotations"; $where=array('quotation_id'=>$id,'delete_status'=>'ACTIVE'); $data= array('quotation_status'=>'REJECTED'); $result=$this->yaskawa_model->update($where,$table,$data); if($result) { echo json_encode(array('result'=>1 ,'message'=>'Quotetion Approved')); } else { echo json_encode(array('result'=>0,'message'=>"Quotetion Not Approved")); } } public function add_access_rights() { $department_id = $this->input->post('department_id'); $menu_id = $this->input->post('menu_id'); $table = 'access_action_rights'; foreach($menu_id as $index=>$val) { $count_id = $this->input->post('count_id_'.$val); $insert_id = $this->input->post('insert_id_'.$val); $edit_id = $this->input->post('edit_id_'.$val); $delete_id = $this->input->post('delete_id_'.$val); if($count_id != "") { foreach($count_id as $key=>$value) { if($value != '') { if($insert_id[$key] == '') { $data['insert_id'] = 0; } else { $data['insert_id'] = $insert_id[$key]; } if($edit_id[$key] == '') { $data['edit_id'] = 0; } else { $data['edit_id'] = $edit_id[$key]; } if($delete_id[$key] == '') { $data['delete_id'] = 0; } else { $data['delete_id'] = $delete_id[$key]; } $data['department_id'] = $department_id; $data['menu_id'] = $value; $where = array('department_id'=>$department_id,'menu_id'=>$value); $check_exists = $this->yaskawa_model->get_customer_result($table,$where); if($check_exists) { $update_access = $this->yaskawa_model->update_single($where,$table,$data); } else { $insert_access = $this->yaskawa_model->insert($table,$data); } } } } } echo json_encode(array('result'=>1,'message'=>"Access controls added successfully")); } public function ticket_status() { $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $ticket_id = $this->uri->segment(2); $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $data['company_details'] = $this->yaskawa_model->fetch_company_details(); $table = 'tickets'; $where = array('ticket_id' => $ticket_id,'delete_status' => 'ACTIVE'); $data['ticket_data'] = $this->yaskawa_model->get_single_ticket($ticket_id); $table = 'new_account'; $where = array('delete_status' => 'ACTIVE'); $data['projects'] = $this->yaskawa_model->get_where_result($table,$where); $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count=0; foreach($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if($months=='11'){ $count+=1; } } $data['count']=$count; $this->load->view('admin/tickets_status',$data); } else { redirect('/'); } } public function admin_password_update(){ //$email=$this->input->post('email'); $password=$this->input->post('password'); $user_id_new=$this->input->post('user_id_new'); $where=array('user_id'=>$user_id_new); $table="users"; $result=$this->yaskawa_model->get_single_row($table,$where); $confirm_password=$this->input->post('confirm_password'); if($result){ $pass_prefix = '$2a$05$'; $pass_suffix = '$'; $Allowed_Chars ='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789./'; $Chars_Len = 63; $Salt_Length = 21; $salt_password = ""; $salt_password=$result->salt_pass; $encrypted_pass = $pass_prefix . $salt_password . $pass_suffix; $hashed_password = crypt($password,$encrypted_pass); $where=array('user_id'=>$user_id_new); $data=array('password'=>$hashed_password); $table="users"; $result=$this->yaskawa_model->update_single($where,$table,$data); echo json_encode(array('result'=>1,'message'=>"password updated successfully")); }else{ echo json_encode(array('result'=>2,'message'=>"you have entered wrong Email")); } } public function get_assigned_accessed_rigts() { $department_id = $this->input->post('role_id'); $menu_id = $this->input->post('menu_id'); $table = 'access_action_rights'; $where = array('department_id'=>$department_id,'menu_id'=>$menu_id); $result = $this->yaskawa_model->get_single_row($table,$where); if($result) { echo json_encode(array('access'=>$result,'access_result'=>1)); } else { echo json_encode(array('access_result'=>0)); } } public function expense() { $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $data['company_details'] = $this->yaskawa_model->fetch_company_details(); $table = 'new_account'; $where = array('delete_status' => 'ACTIVE'); $data['projects'] = $this->yaskawa_model->get_where_result($table,$where); $table = 'masters'; $where = array('field_name' => 'expense_type','master_type_id'=>'26'); $matser = $this->yaskawa_model->get_where_row($table,$where); $data['master'] =json_decode($matser->field_value); $table = 'employees'; $where = array('delete_status' => 'ACTIVE','employee_status'=>'Active'); $data['employee'] = $this->yaskawa_model->get_where_result($table,$where); // =json_decode($matser->field_value); $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count=0; foreach($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if($months=='11'){ $count+=1; } } $data['count']=$count; $this->load->view('admin/expense',$data); } else { redirect('/'); } } public function add_expense(){ $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d H:i:s'); $date=$this->input->post('date'); $date=date('Y-m-d',strtotime($date)); $expense_amt=$this->input->post('expense_amt'); $expense_amt=str_replace(',', '',$expense_amt); $paymeny_by=$this->input->post('payment_by'); $temparray=explode(':',$paymeny_by); if(!empty($temparray[1])) { $paymentby=$temparray[1]; }else { $paymentby=0; } $data=array( 'expense_type' => $this->input->post('expense_type'), 'expense_amount' => $expense_amt, 'expense_towards_account' => $this->input->post('expense_twoards_acct'), 'expense_date' => $date, 'reference_number' => $this->input->post('reference_number'), 'payment_by' =>$paymentby, 'payment_mode' => $this->input->post('payment_mode'), 'delete_status' =>'ACTIVE', 'created_at' =>$date_format, 'vendor_name'=>$this->input->post('vendor_name'), ); $table="expense"; $result=$this->yaskawa_model->insert($table,$data); if($result){ echo json_encode(array('result'=>1,'message'=>"Added Successfully")); }else{ echo json_encode(array('result'=>0,'message'=>"Not Added Successfully")); } } public function expense_list() { $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $data['company_details'] = $this->yaskawa_model->fetch_company_details(); $table = 'new_account'; $where = array('delete_status' => 'ACTIVE'); $data['projects'] = $this->yaskawa_model->get_where_result($table,$where); $table = 'expense'; $where = array('delete_status' => 'ACTIVE'); $data['expense'] = $this->yaskawa_model->get_where_result($table,$where); $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count=0; foreach($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if($months=='11'){ $count+=1; } } $data['count']=$count; $this->load->view('admin/expense_list',$data); } else { redirect('/'); } } public function get_expense_list(){ $from=$this->input->post('from_date'); $to=$this->input->post('to_date'); $from=date('Y-m-d',strtotime($from)); $to=date('Y-m-d',strtotime($to)); $result=$this->yaskawa_model->get_expense_list($from,$to); echo json_encode($result); } public function delete_expense(){ $id=$this->input->post('id'); $table="expense"; $where=array('expense_id'=>$id); $result=$this->yaskawa_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 update_expense() { $admin_id = $this->session->userdata('admin_id'); $id = $this->uri->segment(2); if($admin_id) { $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $data['company_details'] = $this->yaskawa_model->fetch_company_details(); $table = 'new_account'; $where = array('delete_status' => 'ACTIVE'); $data['projects'] = $this->yaskawa_model->get_where_result($table,$where); $table = 'masters'; $where = array('field_name' => 'expense_type','master_type_id'=>'26'); $matser = $this->yaskawa_model->get_where_row($table,$where); $data['master'] =json_decode($matser->field_value); $table = 'expense'; //$where = array('expense_id' => $id); $data['expense'] = $this->yaskawa_model->get_expense_data($id); $table = 'employees'; $where = array('delete_status' => 'ACTIVE','employee_status'=>'Active'); $data['employee'] = $this->yaskawa_model->get_where_result($table,$where); $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count=0; foreach($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if($months=='11'){ $count+=1; } } $data['count']=$count; $this->load->view('admin/update_expense',$data); } else { redirect('/'); } } // public function edit_expense(){ // $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); // $date_format = $date->format('Y-m-d'); // $expense_id=$this->input->post('expense_id'); // $date=$this->input->post('date'); // $date=date('Y-m-d',strtotime($date)); // $expense_amt=$this->input->post('expense_amt'); // $expense_amt=str_replace(',', '',$expense_amt); // $paymeny_by=$this->input->post('payment_by'); // $temparray=explode(':',$paymeny_by); // $paymentby=$temparray[1]; // $data=array( // 'expense_type' => $this->input->post('expense_type'), // 'expense_amount' => $expense_amt, // 'expense_towards_account' => $this->input->post('expense_twoards_acct'), // 'expense_date' => $date, // 'reference_number' => $this->input->post('reference_number'), // 'payment_by' => $paymentby, // 'payment_mode' => $this->input->post('payment_mode'), // 'delete_status' =>'ACTIVE', // 'updated_at' =>$date_format, // 'vendor_name'=>$this->input->post('vendor_name'), // ); // $table="expense"; // $where=array('expense_id' =>$expense_id); // $result=$this->yaskawa_model->update_invoice_payments($where,$data,$table); // if($result){ // echo json_encode(array('result'=>1,'message'=>"Updated Successfully")); // }else{ // echo json_encode(array('result'=>0,'message'=>"Not Updated Successfully")); // } // } public function edit_expense() { $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $expense_id = $this->input->post('expense_id'); $date = $this->input->post('date'); $date = date('Y-m-d', strtotime($date)); $expense_amt = $this->input->post('expense_amt'); $expense_amt = str_replace(',', '', $expense_amt); $paymeny_by = $this->input->post('payment_by'); $temparray = explode(':', $paymeny_by); $paymentby = $temparray[1]; $data = array( 'expense_type' => $this->input->post('expense_type'), 'expense_amount' => $expense_amt, 'expense_towards_account' => $this->input->post('expense_twoards_acct'), 'expense_date' => $date, 'reference_number' => $this->input->post('reference_number'), 'payment_by' => $paymentby, 'payment_mode' => $this->input->post('payment_mode'), 'delete_status' => 'ACTIVE', 'updated_at' => $date_format, 'vendor_name' => $this->input->post('vendor_name'), ); $table = "expense"; $where = array('expense_id' => $expense_id); // Debugging output log_message('debug', 'Updating expense with data: ' . print_r($data, true)); $result = $this->Yaskawa_model->update_invoice_payments($where, $data, $table); // Check if rows are affected if ($this->db->affected_rows() > 0) { echo json_encode(array('result' => 1, 'message' => "Updated Successfully")); } else { echo json_encode(array('result' => 0, 'message' => "Not Updated Successfully")); } } public function update_invoice_payments($where, $data, $table) { // Using CodeIgniter's query builder to update the table $this->db->where($where); return $this->db->update($table, $data); } public function potential_status_data(){ $status=$this->input->post('status'); $res=$this->yaskawa_model->get_potential_data_status($status); $arr=array(); foreach($res as $key => $value) { $data['potential_id']=$value->potential_id; $data['potential_name']=$value->potential_name; $data['mailing_city']=$value->mailing_city; $data['amount']=$value->amount; $data['stage']=$value->stage; $data['closing_date']=$value->closing_date; $data['account_name']=$value->account_name; $data['contact_name']=$value->contact_name; $data['phone_number']=$value->phone_number; $data['address']=$value->address; $data['email_id']=$value->email_id; //$data['lead_convert']=$value->lead_convert; $data['user_name']=$value->user_name; $table="potential_attach_notes"; //$where=array('potential_id'=>$value->potential_id); $note=$this->yaskawa_model->get_row_by_desc_new($value->potential_id); if($note!=''){ $data['note']=$note->potential_notes; }else{ $data['note']=''; } array_push($arr,$data); } echo json_encode($arr); } public function close_lead(){ $id=$this->input->post('id'); $table="leads"; $where=array('lead_id'=>$id); $data=array('lead_convert'=>'CLOSED'); $res=$this->yaskawa_model->update_single($where,$table,$data); echo json_encode($res); } public function close_potential(){ $id=$this->input->post('id'); $table="new_potential"; $where=array('potential_id'=>$id); $data=array('stage'=>'CLOSED'); $res=$this->yaskawa_model->update_single($where,$table,$data); echo json_encode($res); } public function tickets_dashboard() { $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $data['company_details'] = $this->yaskawa_model->fetch_company_details(); $table = 'new_account'; $where = array('delete_status' => 'ACTIVE'); $data['projects'] = $this->yaskawa_model->get_where_result($table,$where); $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count=0; foreach($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if($months=='11'){ $count+=1; } } $data['count']=$count; $this->load->view('admin/ticket_dashboard',$data); } else { redirect('/'); } } public function tickets_user() { $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $data['company_details'] = $this->yaskawa_model->fetch_company_details(); $table = 'new_account'; $where = array('delete_status' => 'ACTIVE'); $data['projects'] = $this->yaskawa_model->get_where_result($table,$where); $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count=0; foreach($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if($months=='11'){ $count+=1; } } $data['count']=$count; $this->load->view('admin/ticket_user',$data); } else { redirect('/'); } } public function tickets_organisation() { $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $data['company_details'] = $this->yaskawa_model->fetch_company_details(); $table = 'new_account'; $where = array('delete_status' => 'ACTIVE'); $data['projects'] = $this->yaskawa_model->get_where_result($table,$where); $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count=0; foreach($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if($months=='11'){ $count+=1; } } $data['count']=$count; $this->load->view('admin/ticket_organisation',$data); } else { redirect('/'); } } public function agents_directory() { $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $data['company_details'] = $this->yaskawa_model->fetch_company_details(); $table = 'new_account'; $where = array('delete_status' => 'ACTIVE'); $data['projects'] = $this->yaskawa_model->get_where_result($table,$where); $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count=0; foreach($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if($months=='11'){ $count+=1; } } $data['count']=$count; $table="employees"; $where=array('agents'=>'AGENT'); $data['agent']=$this->yaskawa_model->get_agents_list(); $this->load->view('admin/agents_directory',$data); } else { redirect('/'); } } public function ticket_profile() { $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $data['company_details'] = $this->yaskawa_model->fetch_company_details(); $table = 'new_account'; $where = array('delete_status' => 'ACTIVE'); $data['projects'] = $this->yaskawa_model->get_where_result($table,$where); $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count=0; foreach($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if($months=='11'){ $count+=1; } } $data['count']=$count; $this->load->view('admin/profile',$data); } else { redirect('/'); } } public function ticket_task() { $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $data['company_details'] = $this->yaskawa_model->fetch_company_details(); $table = 'new_account'; $where = array('delete_status' => 'ACTIVE'); $data['projects'] = $this->yaskawa_model->get_where_result($table,$where); $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count=0; foreach($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if($months=='11'){ $count+=1; } } $data['count']=$count; $table="new_task"; $where=array('delete_status'=>'ACTIVE'); $open=$this->yaskawa_model->get_customer_result($table,$where); $data['open']=count($open); $this->load->view('admin/ticket_task',$data); } else { redirect('/'); } } public function open_ticket() { $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $data['company_details'] = $this->yaskawa_model->fetch_company_details(); $table = 'new_account'; $where = array('delete_status' => 'ACTIVE'); $data['projects'] = $this->yaskawa_model->get_where_result($table,$where); $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count=0; foreach($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if($months=='11'){ $count+=1; } } $data['count']=$count; $table="tickets"; $where=array('ticket_status'=>'Open'); $open=$this->yaskawa_model->get_customer_result($table,$where); $data['open']=count($open); $data['open_list']=$open; $table="tickets"; $where=array('ticket_status'=>'Resolved'); $resolved=$this->yaskawa_model->get_customer_result($table,$where); $data['resolved']=count($resolved); $table="tickets"; $where=array('ticket_status'=>'Closed'); $Closed=$this->yaskawa_model->get_customer_result($table,$where); $data['Closed']=count($Closed); $this->load->view('admin/open_ticket',$data); } else { redirect('/'); } } public function overdue_ticket() { $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $data['company_details'] = $this->yaskawa_model->fetch_company_details(); $table = 'new_account'; $where = array('delete_status' => 'ACTIVE'); $data['projects'] = $this->yaskawa_model->get_where_result($table,$where); $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count=0; foreach($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if($months=='11'){ $count+=1; } } $data['count']=$count; $table="tickets"; $where=array('ticket_status'=>'Open'); $open=$this->yaskawa_model->get_customer_result($table,$where); $data['open']=count($open); $table="tickets"; $where=array('ticket_status'=>'Resolved'); $resolved=$this->yaskawa_model->get_customer_result($table,$where); $data['resolved']=count($resolved); $data['resolved_list']=$resolved; $table="tickets"; $where=array('ticket_status'=>'Closed'); $Closed=$this->yaskawa_model->get_customer_result($table,$where); $data['Closed']=count($Closed); $this->load->view('admin/overdue_ticket',$data); } else { redirect('/'); } } public function closed_ticket() { $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $data['company_details'] = $this->yaskawa_model->fetch_company_details(); $table = 'new_account'; $where = array('delete_status' => 'ACTIVE'); $data['projects'] = $this->yaskawa_model->get_where_result($table,$where); $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count=0; foreach($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if($months=='11'){ $count+=1; } } $data['count']=$count; $table="tickets"; $where=array('ticket_status'=>'Open'); $open=$this->yaskawa_model->get_customer_result($table,$where); $data['open']=count($open); $table="tickets"; $where=array('ticket_status'=>'Resolved'); $resolved=$this->yaskawa_model->get_customer_result($table,$where); $data['resolved']=count($resolved); $table="tickets"; $where=array('ticket_status'=>'Closed'); $Closed=$this->yaskawa_model->get_customer_result($table,$where); $data['Closed']=count($Closed); $data['closed_list']=$Closed; $this->load->view('admin/closed_ticket',$data); } else { redirect('/'); } } public function new_ticket() { $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $data['company_details'] = $this->yaskawa_model->fetch_company_details(); $table = 'new_account'; $where = array('delete_status' => 'ACTIVE'); $data['projects'] = $this->yaskawa_model->get_where_result($table,$where); $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count=0; foreach($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if($months=='11'){ $count+=1; } } $data['count']=$count; $table="tickets"; $where=array('ticket_status'=>'Open'); $open=$this->yaskawa_model->get_customer_result($table,$where); $data['open']=count($open); $table="tickets"; $where=array('ticket_status'=>'Resolved'); $resolved=$this->yaskawa_model->get_customer_result($table,$where); $data['resolved']=count($resolved); $table="tickets"; $where=array('ticket_status'=>'Closed'); $Closed=$this->yaskawa_model->get_customer_result($table,$where); $data['Closed']=count($Closed); $this->load->view('admin/new_ticket',$data); } else { redirect('/'); } } public function faq() { $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $data['company_details'] = $this->yaskawa_model->fetch_company_details(); $table = 'new_account'; $where = array('delete_status' => 'ACTIVE'); $data['projects'] = $this->yaskawa_model->get_where_result($table,$where); $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count=0; foreach($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if($months=='11'){ $count+=1; } } $data['count']=$count; $this->load->view('admin/faq',$data); } else { redirect('/'); } } public function category_faq() { $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $data['company_details'] = $this->yaskawa_model->fetch_company_details(); $table = 'new_account'; $where = array('delete_status' => 'ACTIVE'); $data['projects'] = $this->yaskawa_model->get_where_result($table,$where); $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count=0; foreach($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if($months=='11'){ $count+=1; } } $data['count']=$count; $this->load->view('admin/category_faq',$data); } else { redirect('/'); } } public function canned_faq() { $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $data['company_details'] = $this->yaskawa_model->fetch_company_details(); $table = 'new_account'; $where = array('delete_status' => 'ACTIVE'); $data['projects'] = $this->yaskawa_model->get_where_result($table,$where); $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count=0; foreach($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if($months=='11'){ $count+=1; } } $data['count']=$count; $this->load->view('admin/canned_faq',$data); } else { redirect('/'); } } public function update_employee_agent(){ $arr=$this->input->post('arr'); foreach($arr as $key => $value) { $table="employees"; $where=array('emp_id'=>$value); $data=array('agents'=>'AGENT'); $result=$this->yaskawa_model->update_single($where,$table,$data); } echo json_encode(array('result'=>'1','msg'=>'Updated Sucessfully')); } public function get_front_status(){ $status=$this->input->post('status'); $result=$this->yaskawa_model->get_agents_list_where($status); echo json_encode($result); } public function add_new_ticket(){ $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $due_date=$this->input->post('due_date'); $due_date=date('Y-m-d',strtotime($due_date)); $data=array( 'email' => $this->input->post('email'), 'full_name' => $this->input->post('full_name'), 'ticket_notice' => '1', 'ticket_source' => $this->input->post('ticket_source'), 'help_topic' => $this->input->post('help_topic'), 'department' => $this->input->post('department'), 'sla_plan' => $this->input->post('sla_plan'), 'due_date' => $due_date, 'due_time' => $this->input->post('due_time'), 'assign_to' => $this->input->post('assign_to'), 'canned_response' => $this->input->post('canned_response'), 'append' => '1', 'canned_note' => $this->input->post('canned_note'), 'signature' => $this->input->post('signature'), 'ticket_status' => $this->input->post('ticket_status'), 'internal_note' => $this->input->post('internal_note'), 'delete_status' => 'ACTIVE', 'ticket_priority' => $this->input->post('ticket_priority'), 'created_by' => $this->session->userdata('admin_id'), 'created_at' => $date_format ); $table="tickets"; $result=$this->yaskawa_model->insert($table,$data); if($result){ echo json_encode(array('result'=>1,'message'=>"Added Successful")); }else{ echo json_encode(array('result'=>0,'message'=>"Unsuccessful")); } } public function get_ticket_activity(){ $table="tickets"; $where=array('ticket_status'=>'Open'); $Open=$this->yaskawa_model->get_customer_result($table,$where); $table="tickets"; $where=array('ticket_status'=>'Closed'); $Closed=$this->yaskawa_model->get_customer_result($table,$where); $table="tickets"; $where=array('ticket_status'=>'Resolved'); $overdue=$this->yaskawa_model->get_customer_result($table,$where); $table="tickets"; $where=array('ticket_status'=>'Assigned'); $Resolved=$this->yaskawa_model->get_customer_result($table,$where); $table="tickets"; $where=array('ticket_status'=>'Reopened'); $Reopened=$this->yaskawa_model->get_customer_result($table,$where); echo json_encode(array('Open'=>count($Open),'Closed'=>count($Closed),'overdue'=>count($overdue),'Resolved'=>count($Resolved),'Reopened'=>count($Reopened))); } public function update_profile(){ $id=$this->input->post('admin_id'); $first_name=$this->input->post('first_name'); $last_name=$this->input->post('last_name'); $email=$this->input->post('email'); $phone_number=$this->input->post('phone_number'); $mobile_number=$this->input->post('mobile_number'); $data=array( 'user_name' => $first_name, 'last_name' => $last_name, 'email' => $email, 'Phone' => $phone_number, 'Mobile' => $mobile_number ); $where=array('user_id'=>$id); $table="users"; $result=$this->yaskawa_model->update_single($where,$table,$data); if($result){ echo json_encode(array('result'=>'1','msg'=>'Updated Sucessfully')); }else{ echo json_encode(array('result'=>'0','msg'=>'Updated Sucessfully')); } } public function add_tasks() { $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $title=$this->input->post('title'); $description=$this->input->post('description'); $visibality_description=$this->input->post('visibality_description'); $assignee=$this->input->post('assignee'); $due_date=$this->input->post('due_date'); $due_time=$this->input->post('due_time'); $data=array('title'=>$title,'description'=>$description,'visibality_description'=>$visibality_description,'assignee'=>$assignee,'due_date'=>$due_date,'due_time'=>$due_time,'delete_status'=>'ACTIVE','created_at'=>$date_format,'modified_at'=>$date_format); $table='new_task'; $result=$this->yaskawa_model->insert($table,$data); if($result) { echo json_encode(array('result'=>1,'message'=>"Task added successfully")); }else { echo json_encode(array('result'=>0,'message'=>"Task Not added")); } } } public function get_tasks() { $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $condition=array('delete_status'=>'ACTIVE'); $table='new_task'; $order_by='id'; $result=$this->yaskawa_model->get_where_result_orderby($table,$condition,$order_by); if($result) { echo json_encode(array('result'=>1,'message'=>$result)); }else { echo json_encode(array('result'=>0,'message'=>"No data found")); } } } public function get_sort_tasks() { $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $sort=$this->input->post('sort'); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $condition=array('delete_status'=>'ACTIVE'); $table='new_task'; if($sort==1) { $order_by='created_at'; }else if($sort==2) { $order_by='modified_at'; } else if($sort==3) { $order_by='due_date'; } else if($sort==4) { $order_by='id'; } else if($sort==5) { $order_by='modified_at'; } $result=$this->yaskawa_model->get_where_result_orderby($table,$condition,$order_by); if($result) { echo json_encode(array('result'=>1,'message'=>$result)); }else { echo json_encode(array('result'=>0,'message'=>"No data found")); } } } public function search_tasks() { $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $srch_term=$this->input->post('srch-term'); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $result=$this->yaskawa_model->get_search_data($srch_term); if($result) { echo json_encode(array('result'=>1,'message'=>$result)); }else { echo json_encode(array('result'=>0,'message'=>"No data found")); } } } public function add_ticket_users() { $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $email=$this->input->post('email'); $name=$this->input->post('name'); $phone1=$this->input->post('phone1'); $phone2=$this->input->post('phone2'); $phone=$phone1.$phone2; $user_status=$this->input->post('user_status'); //$register_status=$this->input->post('register_status'); $note=$this->input->post('note'); $data=array('email'=>$email,'name'=>$name,'phone'=>$phone,'user_status'=>$user_status,'note'=>$note,'delete_status'=>'ACTIVE','created_at'=>$date_format,'modified_at'=>$date_format); $table='add_ticket_user'; $result=$this->yaskawa_model->insert($table,$data); if($result) { echo json_encode(array('result'=>1,'message'=>"Ticket user added successfully")); }else { echo json_encode(array('result'=>0,'message'=>"Ticket user Not added")); } } } public function get_tockets_users() { $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $condition=array('delete_status'=>'ACTIVE'); $table='add_ticket_user'; $order_by='id'; $result=$this->yaskawa_model->get_where_result_orderby($table,$condition,$order_by); if($result) { echo json_encode(array('result'=>1,'message'=>$result)); }else { echo json_encode(array('result'=>0,'message'=>"No data found")); } } } public function search_ticket_users() { $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $srch_term=$this->input->post('srch-term'); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $result=$this->yaskawa_model->get_search_ticket_users($srch_term); if($result) { echo json_encode(array('result'=>1,'message'=>$result)); }else { echo json_encode(array('result'=>0,'message'=>"No data found")); } } } public function update_register_status() { $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $id=$this->input->post('id'); $result=$this->yaskawa_model->update_ticket_user_register_status($id); if($result) { echo json_encode(array('result'=>1,'message'=>$result)); }else { echo json_encode(array('result'=>0,'message'=>"No data found")); } } } public function delete_ticket_user() { $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $id=$this->input->post('id'); $result=$this->yaskawa_model->delete_ticket_user($id); if($result) { echo json_encode(array('result'=>1,'message'=>$result)); }else { echo json_encode(array('result'=>0,'message'=>"No data found")); } } } public function Unlock_ticket_user() { $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $id=$this->input->post('id'); $tbale="add_ticket_user"; $data=array('locked'=>'NO'); $condition=array('id'=>$id); $result=$this->yaskawa_model->update($condition,$tbale,$data); if($result) { echo json_encode(array('result'=>1,'message'=>$result)); }else { echo json_encode(array('result'=>0,'message'=>"No data found")); } } } public function lock_ticket_user() { $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $id=$this->input->post('id'); $result=$this->yaskawa_model->update_locked_ticked_user($id); if($result) { echo json_encode(array('result'=>1,'message'=>$result)); }else { echo json_encode(array('result'=>0,'message'=>"No data found")); } } } public function import_ticket_user() { $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); include '../PHPExcel/IOFactory.php'; if(isset($_FILES['excel_upload']['name'])) { $file_name = $_FILES['excel_upload']['name']; $ext = pathinfo($file_name, PATHINFO_EXTENSION); if($ext == "xlsx" || $ext == "xls") { $file_name = $_FILES['excel_upload']['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 = 'saha_document_to_executive_associate'; //$this->erp_model->table_truncate($table); if(count($allDataInSheet)>0){ for($i = 2;$i <= $arrayCount;$i++){ $email= trim($allDataInSheet[$i]["A"]); $phone= trim($allDataInSheet[$i]["B"]); $name= trim($allDataInSheet[$i]["C"]); $user_status= trim($allDataInSheet[$i]["D"]); $note= trim($allDataInSheet[$i]["E"]); $data=array('email'=>$email,'name'=>$name,'phone'=>$phone,'user_status'=>$user_status,'note'=>$note,'delete_status'=>'ACTIVE','created_at'=>$date_format,'modified_at'=>$date_format); $table='add_ticket_user'; $result=$this->yaskawa_model->insert($table,$data); } if($result) { echo json_encode(array('result'=>1,'message'=>"User added successfully")); } else { echo json_encode(array('result'=>2,'message'=>"Something went wrong.. try again")); } } } else { echo json_encode(array('result'=>3,'message'=>"Please upload file with xlsx extension only")); } } } public function add_ticket_organization() { $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $address=$this->input->post('address'); $name=$this->input->post('name'); $phone1=$this->input->post('phone1'); $phone2=$this->input->post('phone2'); $phone=$phone1.$phone2; $website=$this->input->post('website'); //$register_status=$this->input->post('register_status'); $note=$this->input->post('note'); $data=array('address'=>$address,'name'=>$name,'phone'=>$phone,'website'=>$website,'note'=>$note,'delete_status'=>'ACTIVE','created_at'=>$date_format,'modified_at'=>$date_format); $table='add_ticket_organization'; $result=$this->yaskawa_model->insert($table,$data); if($result) { echo json_encode(array('result'=>1,'message'=>"Ticket organization added successfully")); }else { echo json_encode(array('result'=>0,'message'=>"Ticket organization Not added")); } } } public function get_tickets_organization() { $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $condition=array('delete_status'=>'ACTIVE'); $table='add_ticket_organization'; $order_by='id'; $result=$this->yaskawa_model->get_where_result_orderby($table,$condition,$order_by); if($result) { echo json_encode(array('result'=>1,'message'=>$result)); }else { echo json_encode(array('result'=>0,'message'=>"No data found")); } } } public function search_organization() { $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $srch_term=$this->input->post('srch-term'); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $result=$this->yaskawa_model->get_search_ticket_organization($srch_term); if($result) { echo json_encode(array('result'=>1,'message'=>$result)); }else { echo json_encode(array('result'=>0,'message'=>"No data found")); } } } public function delete_ticket_organization() { $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $id=$this->input->post('id'); $result=$this->yaskawa_model->delete_ticket_organization($id); if($result) { echo json_encode(array('result'=>1,'message'=>$result)); }else { echo json_encode(array('result'=>0,'message'=>"No data found")); } } } public function add_to_ticket_orgs() { $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $id=$this->input->post('id'); $result=$this->yaskawa_model->add_to_ticket_orgs($id); if($result) { echo json_encode(array('result'=>1,'message'=>$result)); }else { echo json_encode(array('result'=>0,'message'=>"No data found")); } } } public function autocomplete_ticket_users() { $keyword=$_GET['term']; $data1=$this->yaskawa_model->get_user_searched($keyword); foreach($data1 as $row) { $data[]=$row->email; } echo json_encode($data); } public function get_searched_user() { $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $email=$this->input->post('email'); $condition=array('delete_status'=>'ACTIVE','email'=>$email); $table='add_ticket_user'; $result=$this->yaskawa_model->get_single_row($table,$condition); if($result) { echo json_encode(array('result'=>1,'message'=>$result)); }else { echo json_encode(array('result'=>0,'message'=>"No data found")); } } } public function get_sort_ticket_activity(){ $date=$this->input->post('date'); $date=date('Y-m-d',strtotime($date)); $range=$this->input->post('range'); $table="tickets"; $where=array('ticket_status'=>'Open'); $Open=$this->yaskawa_model->get_customer_new_result($table,$where,$date,$range); $table="tickets"; $where=array('ticket_status'=>'Closed'); $Closed=$this->yaskawa_model->get_customer_new_result($table,$where,$date,$range); $table="tickets"; $where=array('ticket_status'=>'Resolved'); $overdue=$this->yaskawa_model->get_customer_new_result($table,$where,$date,$range); $table="tickets"; $where=array('ticket_status'=>'Assigned'); $Resolved=$this->yaskawa_model->get_customer_new_result($table,$where,$date,$range); $table="tickets"; $where=array('ticket_status'=>'Reopened'); $Reopened=$this->yaskawa_model->get_customer_new_result($table,$where,$date,$range); echo json_encode(array('Open'=>count($Open),'Closed'=>count($Closed),'overdue'=>count($overdue),'Resolved'=>count($Resolved),'Reopened'=>count($Reopened))); } public function search_quotation(){ $val=$this->input->post('val'); $result=$this->yaskawa_model->search_quotation($val); echo json_encode($result); } public function get_invoice_payment_details() { $n = $this->input->post('name'); $quotation_id = $this->input->post('quotation_id'); $from = $this->input->post('from'); $result = $this->yaskawa_model->get_invoice_payment_details($n,$quotation_id,$from); $quotation = $this->yaskawa_model->get_single_quotation_details($n,$quotation_id,$from); $quot_result = $this->yaskawa_model->get_single_quotation_tax_details($n,$quotation_id,$from); if($result || $quot_result) { echo json_encode(array('result' => 1, 'message' => $result,'quotation'=>$quotation,'quot_tax'=>$quot_result)); } else { echo json_encode(array('result' => 0)); } } public function search_invoice_date() { $date = $this->uri->segment(3); $status = $this->uri->segment(4); $result = $this->yaskawa_model->search_invoice_date($date,$status); if($result) { echo json_encode($result); } else { echo json_encode(array('result' => 0)); } } public function view_invoice_search_payment() { $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $id=$this->uri->segment(3); $date=$this->uri->segment(4); $table='invoice_payments'; $where=array('invoice_id'=>$id,'delete_status'=>'ACTIVE'); $payment_result=$this->yaskawa_model->view_invoice_search_payment($table,$id, $date); $result=array(); foreach($payment_result as $val){ $pay_result['payment_type']=$val['payment_type']; $pay_result['id']=$val['payment_id']; $pay_result['name']=$val['favour_of']; $pay_result['cheque_no']=$val['cheque_no']; $pay_result['cheque_date']=$val['cheque_date']; $pay_result['dd_no']=$val['dd_no']; $pay_result['dd_date']=$val['dd_date']; $pay_result['utr_no']=$val['utr_no']; $pay_result['online_date']=$val['online_date']; $pay_result['bank_name']=$val['bank_name']; $pay_result['branch_name']=$val['branch_name']; $pay_result['collected_by']=$val['collected_by']; $invoce_amount=number_format($val['amount']); $pay_result['paid_amount']=$invoce_amount; array_push($result,$pay_result); } if($result) { echo json_encode($result); } else { echo json_encode(array('result'=>0,'message'=>'No data Found')); } } else { redirect('/'); } } public function auto_complete_paymeny_by_name(){ $keyword=$this->input->get('term'); $data1=$this->yaskawa_model->auto_complete_paymeny_by_name($keyword); if($data1){ foreach($data1 as $row) { $data[]=$row->first_name.' '.$row->last_name.':'.$row->emp_id; } }else { $data[]='No Searched name :0' ; } echo json_encode($data); } public function account_address(){ $id=$this->input->post('lead_id'); $table="new_account"; $where=array('account_id'=>$id); $result=$this->yaskawa_model->get_row_data($table,$where); echo json_encode($result); } public function amc_notification(){ $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $created_at = $date->format('Y-m-d'); $table="new_account"; $result=$this->yaskawa_model->amc_notification_count(); if($result) { echo json_encode(array('result'=>1,'message'=>count($result))); } else { echo json_encode(array('result'=>0,'message'=>'No data Found')); } } public function AMC_notification_form(){ $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $data['company_details'] = $this->yaskawa_model->fetch_company_details(); $table = 'new_account'; $where = array('delete_status' => 'ACTIVE'); $data['projects'] = $this->yaskawa_model->get_where_result($table,$where); $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count=0; foreach($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if($months=='11'){ $count+=1; } } $data['count']=$count; $this->load->view('admin/amc_notification',$data); } } public function get_amc_notification_new(){ $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $created_at = $date->format('Y-m-d'); $result=$this->yaskawa_model->amc_notification(); if($result) { echo json_encode(array('result'=>1,'message'=>$result)); } else { echo json_encode(array('result'=>0,'message'=>'No data Found')); } } public function update_amc_notification_new(){ $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $created_at = $date->format('Y-m-d'); $table="new_account"; $condition=array('delete_status'=>'ACTIVE','view_status'=>0); $data=array('view_status'=>1); $results=$this->yaskawa_model->update_single($condition,$table,$data); $result=$this->yaskawa_model->amc_notification(); if($result) { echo json_encode(array('result'=>1,'message'=>$result)); } else { echo json_encode(array('result'=>0,'message'=>'No data Found')); } } public function verify_potential_email() { $email = $this->input->post('email'); $result = $this->yaskawa_model->verify_potential_email_id($email); if($result){ echo json_encode(array('result'=>1,'id'=>$result)); } else { echo json_encode(array('result'=>0)); } } public function old_quotation_details(){ $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $ids=$this->uri->segment(2); $data['user_type_id'] = $this->access_id(); $table="users"; $condition=array('user_id'=>$admin_id,'delete_status'=>'ACTIVE'); $order_by='user_id'; $get_user_type_id=$this->yaskawa_model->get_where_orderby_row($table,$condition,$order_by); $data['user_type_ids']=$get_user_type_id->user_type_id; $data['access'] = $this->access_details(); $data['company_details']=$this->yaskawa_model->fetch_company_details(); $data['quotation']=$this->yaskawa_model->get_quotation_result_old($ids); $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count=0; foreach($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if($months=='11'){ $count+=1; } } $data['count']=$count; $this->load->view('admin/old_quotation_list',$data); } else { redirect('/'); } } public function search_quotation_id(){ $qid=$this->input->post('q_id'); $result=$this->yaskawa_model->search_quotation_id($qid); if($result){ echo json_encode(array('result'=>1,'message'=>$result)); } else { echo json_encode(array('result'=>0)); } } public function search_quotation_id_to_invoice(){ $qid=$this->input->post('q_id'); $result=$this->yaskawa_model->search_quotation_id_to_invoice($qid); if($result){ echo json_encode(array('result'=>1,'message'=>$result)); } else { echo json_encode(array('result'=>0)); } } public function get_description_and_price(){ $qid=$this->input->post('quotation_id'); $result=$this->yaskawa_model->get_description_and_price($qid); if($result){ echo json_encode(array('result'=>1,'message'=>$result)); } else { echo json_encode(array('result'=>0)); } } public function get_mastar_value_invoice_quotation(){ $table='invoice_quotation_from_mail'; $condition=array('delete_status'=>'ACTIVE'); $result=$this->yaskawa_model->get_where_result($table,$condition); if($result){ echo json_encode(array('result'=>1,'message'=>$result)); } else { echo json_encode(array('result'=>0)); } } public function delete_mail_signature() { $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $id=$this->input->post('id'); $where=array('id'=>$id); $table='invoice_quotation_from_mail'; $data=array('delete_status'=>'INACTIVE'); $result=$this->yaskawa_model->update($where,$table,$data); if($result) { echo json_encode(array('result'=>1,'message'=>'Deleted')); }else { echo json_encode(array('result'=>0,'message'=>"No data found")); } } } public function mail_from_selected() { $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $table='invoice_quotation_from_mail'; $id=$this->input->post('id'); $status=$this->input->post('status'); $where=array('delete_status'=>'ACTIVE'); $data=array('checked_status'=>0); $result=$this->yaskawa_model->update($where,$table,$data); $where=array('id'=>$id); $data=array('checked_status'=>$status); $result=$this->yaskawa_model->update($where,$table,$data); if($result) { echo json_encode(array('result'=>1,'message'=>'Selected')); }else { echo json_encode(array('result'=>0,'message'=>"No data found")); } } } public function print_quotation(){ $admin_id = $this->session->userdata('admin_id'); $quotation_id = $this->uri->segment(2); if($admin_id) { $data['user_type_id'] = $this->access_id(); $id="quotation_id"; $where=array('quotation_id'=>$quotation_id); $table="quotations"; $data['quotations']=$this->yaskawa_model->get_last_master_row($table,$where,$id); //print_r($data['quotations']); $data['access'] = $this->access_details(); $data['company_details']=$this->yaskawa_model->fetch_company_details(); // $where=array('delete_status'=>'ACTIVE'); // $table="quotations"; // $data['quotation']=$this->yaskawa_model->get_quotation_last_row($table,$where); // $where=array('delete_status'=>'ACTIVE'); $table="masters"; $where=array('delete_status'=>'ACTIVE','master_type_id'=>'17'); $id="master_id"; $data['master']=$this->yaskawa_model->get_last_master_row($table,$where,$id); $table="masters"; $where=array('delete_status'=>'ACTIVE','master_type_id'=>'7'); $order_by='master_id'; $data['comment']=$this->yaskawa_model->get_last_master_row($table,$where,$order_by); $table="masters"; $where=array('delete_status'=>'ACTIVE','master_type_id'=>'8'); $order_by='master_id'; $data['desc']=$this->yaskawa_model->get_last_master_row($table,$where,$order_by); $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count=0; foreach($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if($months=='11'){ $count+=1; } } $data['count']=$count; $table="masters"; $where_sgst=array('field_label'=>'sgst','delete_status'=>'ACTIVE'); $data_sgst=$this->yaskawa_model->get_data_row($table,$where_sgst); $data['sgst']=json_decode($data_sgst->field_value); $where_igst=array('field_label'=>'igst','delete_status'=>'ACTIVE'); $data_igst=$this->yaskawa_model->get_data_row($table,$where_igst); $data['igst']=json_decode($data_igst->field_value); $table="masters"; $where_gst=array('field_label'=>'gst','delete_status'=>'ACTIVE'); $data_gst=$this->yaskawa_model->get_data_row($table,$where_gst); $data['gst']=json_decode($data_gst->field_value); $this->load->view('admin/print_quotation',$data); } else { redirect('/'); } } //---------------------------------companies-----------------------------// public function add_companies() { $admin_id = $this->session->userdata('admin_id'); $role_id = $this->session->userdata('role_id'); if($admin_id) { $data['company_details'] = $this->yaskawa_model->fetch_company_details(); $this->load->view('admin/companies_form',$data); } else { redirect('/'); } } public function search_company_account() { $val = $this->input->post('val'); $result = $this->yaskawa_model->search_company_account($val); echo json_encode($result); } public function get_searched_company_details() { $company_name = $this->input->post('company_name'); $account_id = $this->input->post('account_id'); $result = $this->yaskawa_model->get_searched_company_details($company_name,$account_id); if($result) { echo json_encode(array('result'=>1,'data'=>$result)); } else { echo json_encode(array('result'=>0)); } } public function add_company_reviews() { $account_id = $this->input->post('account_id'); $company_name = $this->input->post('company_name'); $addresss = $this->input->post('address'); $phone = $this->input->post('phone'); $type_of_service = $this->input->post('type_of_service'); $reviews = $this->input->post('reviews'); $this->load->library('image_lib'); $logo = ""; $videos = ""; if($_FILES) { if($_FILES['logo']['name'] != "") { $path = $_FILES['logo']['name']; $target = 'logo/'; $target .= time().$_FILES['logo']['name']; $image_document = time().$_FILES['logo']['name']; move_uploaded_file($_FILES['logo']['tmp_name'],$target); $logo = $image_document; } } if($_FILES) { if($_FILES['video']['name'] != "") { $path = $_FILES['video']['name']; $target = 'videos/'; $target .= time().$_FILES['video']['name']; $image_document = time().$_FILES['video']['name']; move_uploaded_file($_FILES['video']['tmp_name'],$target); $videos = $image_document; } } $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $created_at = $date->format('Y-m-d H:i:s'); $table = 'companies'; $data = array( 'account_id' => $account_id, 'company_name' => $company_name, 'addresss' => $addresss, 'phone' => $phone, 'logo' => $logo, 'type_of_service' => $type_of_service, 'reviews' => $reviews, 'reviews_video' => $videos, 'delete_status' => 'ACTIVE', 'created_at' => $created_at ); $result = $this->Yaskawa_model->insert($table,$data); if($result) { echo json_encode(array('result'=>1,'message'=>"Added successfully")); } else { echo json_encode(array('result'=>0,'message'=>"Something went wrong. try again")); } } public function get_company_reviews() { $account_id = $this->input->post('account_id'); $result = $this->yaskawa_model->get_where_result($table,$where); if($result) { echo json_encode(array('result'=>1,'data'=>$result)); } else { echo json_encode(array('result'=>0)); } } public function delete_review() { $company_id = $this->input->post('company_id'); $data = array('delete_status' => 'INACTIVE'); $table = 'companies'; $where = array('company_id' => $company_id); $result = $this->yaskawa_model->update($where,$table,$data); if($result) { echo json_encode(array('result' => 1,'message'=>"Deleted successfully")); } else { echo json_encode(array('result' => 0,'message'=>"Something went wrong..Try again")); } } public function edit_reviews() { $admin_id = $this->session->userdata('admin_id'); $role_id = $this->session->userdata('role_id'); if($admin_id) { $company_id = $this->uri->segment(2); $data['company_details'] = $this->yaskawa_model->fetch_company_details(); $data['details'] = $this->yaskawa_model->fetch_single_company_details($company_id); $this->load->view('admin/edit_reviews',$data); } else { redirect('/'); } } public function update_company_reviews() { $account_id = $this->input->post('account_id'); $company_id = $this->input->post('company_id'); $company_name = $this->input->post('company_name'); $addresss = $this->input->post('address'); $phone = $this->input->post('phone'); $type_of_service = $this->input->post('type_of_service'); $reviews = $this->input->post('reviews'); $this->load->library('image_lib'); // $logo = ""; // $videos = ""; $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $created_at = $date->format('Y-m-d H:i:s'); $table = 'companies'; $data = array( 'account_id' => $account_id, 'company_name' => $company_name, 'addresss' => $addresss, 'phone' => $phone, // 'logo' => $logo, 'type_of_service' => $type_of_service, 'reviews' => $reviews, // 'reviews_video' => $videos, 'delete_status' => 'ACTIVE', 'created_at' => $created_at ); if($_FILES) { if($_FILES['logo']['name'] != "") { $path = $_FILES['logo']['name']; $target = 'logo/'; $target .= time().$_FILES['logo']['name']; $image_document = time().$_FILES['logo']['name']; move_uploaded_file($_FILES['logo']['tmp_name'],$target); $logo = $image_document; $data['logo'] = $logo; } } if($_FILES) { if($_FILES['video']['name'] != "") { $path = $_FILES['video']['name']; $target = 'videos/'; $target .= time().$_FILES['video']['name']; $image_document = time().$_FILES['video']['name']; move_uploaded_file($_FILES['video']['tmp_name'],$target); $videos = $image_document; $data['reviews_video'] = $videos; } } $where = array('company_id'=>$company_id,'delete_status'=>'ACTIVE'); $result = $this->yaskawa_model->update($where,$table,$data); if($result) { echo json_encode(array('result'=>1,'message'=>"Updated successfully")); } else { echo json_encode(array('result'=>0,'message'=>"Something went wrong. try again")); } } //-----------------------------------------------------------------------// public function old_quotation() { $admin_id = $this->session->userdata('admin_id'); $quotation_id = $this->uri->segment(2); if($admin_id) { $data['user_type_id'] = $this->access_id(); $id="quotation_id"; $where=array('id'=>$quotation_id); $table="old_quotation_details"; $data['quotations']=$this->yaskawa_model->get_old_quotations($quotation_id); $data['access'] = $this->access_details(); $data['company_details']=$this->yaskawa_model->fetch_company_details(); $table="masters"; $where=array('delete_status'=>'ACTIVE','master_type_id'=>'17'); $id="master_id"; $data['master']=$this->yaskawa_model->get_last_master_row($table,$where,$id); $table="masters"; $where=array('delete_status'=>'ACTIVE','master_type_id'=>'7'); $order_by='master_id'; $data['comment']=$this->yaskawa_model->get_last_master_row($table,$where,$order_by); $table="masters"; $where=array('delete_status'=>'ACTIVE','master_type_id'=>'8'); $order_by='master_id'; $data['desc']=$this->yaskawa_model->get_last_master_row($table,$where,$order_by); $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count=0; foreach($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if($months=='11'){ $count+=1; } } $data['count']=$count; $table="masters"; $where_sgst=array('field_label'=>'sgst','delete_status'=>'ACTIVE'); $data_sgst=$this->yaskawa_model->get_data_row($table,$where_sgst); $data['sgst']=json_decode($data_sgst->field_value); $where_igst=array('field_label'=>'igst','delete_status'=>'ACTIVE'); $data_igst=$this->yaskawa_model->get_data_row($table,$where_igst); $data['igst']=json_decode($data_igst->field_value); $table="masters"; $where_gst=array('field_label'=>'gst','delete_status'=>'ACTIVE'); $data_gst=$this->yaskawa_model->get_data_row($table,$where_gst); $data['gst']=json_decode($data_gst->field_value); $this->load->view('admin/old_quotation',$data); } else { redirect('/'); } } public function converted_lead_info() { $admin_id = $this->session->userdata('admin_id'); if($admin_id) { $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $lead_id = $this->uri->segment(2); //$data['user_details']=$this->yaskawa_model->get_user_details4($lead_id); $data['user_details']=$this->yaskawa_model->get_user_details_new(); $data['customer_type']=$this->yaskawa_model->get_customer_type(); $data['single_details'] = $this->yaskawa_model->single_lead_detail($lead_id); $data['pic_details'] = $this->yaskawa_model->get_pic_details($lead_id); $data['lead_details'] = $this->yaskawa_model->get_event_call_details_lead($lead_id); $data['closed_details'] = $this->yaskawa_model->get_event_closed_details_lead($lead_id); $data['notes_details'] = $this->yaskawa_model->get_notes_details($lead_id); $data['attachment_details'] = $this->yaskawa_model->get_attachment_details($lead_id); $data['converted_status'] = $this->yaskawa_model->get_converted_status_new_leads($lead_id); $data['quotation_details'] = $this->yaskawa_model->get_quotation_details_lead($lead_id); $data['lead_process']=$this->yaskawa_model->get_lead_process(); $data['company_details']=$this->yaskawa_model->fetch_company_details(); $data['lead_ratings'] = $this->yaskawa_model->get_lead_ratings_details(); $data['industry_details'] = $this->yaskawa_model->get_lead_industry_details(); $table="new_account"; $where=array('delete_status'=>'ACTIVE'); $res=$this->yaskawa_model->get_customer_result($table,$where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $date_format = $date->format('Y-m-d'); $count=0; foreach($res as $key => $value) { $date1 = $value->opened_on; $date2 = $date_format; $diff = abs(strtotime($date2) - strtotime($date1)); $years = floor($diff / (365*60*60*24)); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); if($months=='11'){ $count+=1; } } $data['count']=$count; $this->load->view('admin/converted_lead_info',$data); } else { redirect('/'); } } public function get_more_invoice_description() { $emp_id = $this->input->post('id'); $where = array('delete_status'=>'ACTIVE','id'=>$emp_id); $table = "invoice"; $result = $this->yaskawa_model->get_data_row($table,$where); if($result) { echo json_encode(array('result'=>1,'details'=>$result)); } else { echo json_encode(array('result'=>0)); } } public function delete_document() { $id = $this->input->post('id'); // Employee ID $key = $this->input->post('key'); // Key of the document in JSON // Load the employee details $this->load->model('Yaskawa_model'); $employee = $this->Yaskawa_model->get_employee_by_id($id); if ($employee) { $documents = json_decode($employee->documents, true); // Decode JSON data if (isset($documents[$key])) { unset($documents[$key]); // Remove the specific document by key $updated_documents = json_encode(array_values($documents)); // Re-index and encode back to JSON // Update the employee record $update_status = $this->Yaskawa_model->update_employee_documents($id, $updated_documents); if ($update_status) { echo json_encode(['success' => true]); } else { echo json_encode(['success' => false, 'message' => 'Failed to update the database.']); } } else { echo json_encode(['success' => false, 'message' => 'Document not found in JSON.']); } } else { echo json_encode(['success' => false, 'message' => 'Employee not found.']); } } } ?>