EVOLUTION-NINJA
Edit File: Gss1.php
<?php namespace App\Controllers; use App\Models\Gss_model; class Gss extends BaseController { // function __construct() { // parent::__construct(); // ini_set('max_execution_time', 30000); // date_default_timezone_set('Asia/Kolkata'); // } //Login form public function index() { return view('admin/login'); } //Access controls form public function access_controls() { $admin_id = session()->get('admin_id'); if($admin_id) { $user_type_table = 'gss_user_type'; $where = array('delete_status'=>'ACTIVE','user_type_id !='=>1); $data['user_types'] = $this->gss_model->get_where_result($user_type_table,$where); $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $this->load->view('admin/access_controls',$data); } else { redirect('/'); } } //Add access controls public function add_access_controls() { $account_type = $this->input->post('account_type'); $username = $this->input->post('username'); $email = $this->input->post('email'); $password = $this->input->post('password'); $mail_password =$this->input->post('mail_password'); $signature = $this->input->post('signature'); $roles = $this->input->post('roles'); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $created_at = $date->format('Y-m-d H:i:s'); $table = 'gss_login'; $data = array( 'user_type_id' => $account_type, 'email' => $email, 'username' => $username, 'password' => $password, 'mail_password' =>$mail_password, 'signature' => $signature, 'roles' => $roles, 'delete_status' => 'ACTIVE', 'created_at' => $created_at ); $executive_id = $this->input->post('executive_id'); if(isset($executive_id)) { $data['executive_id'] = $this->input->post('executive_id'); } $land_owner_id = $this->input->post('land_owner_id'); if(isset($land_owner_id)) { $data['land_owner_id'] = $this->input->post('land_owner_id'); } $where = array('delete_status'=>'ACTIVE'); $emails = $this->gss_model->get_where_result($table,$where); $array = array(); foreach($emails as $value) { array_push($array, $value->email); } if(in_array($email,$array)) { echo json_encode(array('result'=>2,'message'=>"Email already exists")); } else { $result = $this->gss_model->insert($table,$data); if($result) { echo json_encode(array('result'=>1,'message'=>"Credentials added successfully")); } else { echo json_encode(array('result'=>0,'message'=>"Something went wrong.. try again")); } } } //Access controls list public function get_all_controls() { $table = 'gss_login'; $result = $this->gss_model->get_all_controls(); if($result) { echo json_encode($result); } else { echo json_encode(array('result'=>0)); } } //Delete access public function delete_access() { $table = 'gss_login'; $user_id = $this->input->post('user_id'); $where = array('user_id'=>$user_id); $data = array('delete_status'=>'INACTIVE'); $result = $this->gss_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)); } } //Edit access control public function edit_access_control() { $table = 'gss_login'; $user_id = $this->input->post('user_id'); $where = array('user_id'=>$user_id,'delete_status'=>'ACTIVE'); $result = $this->gss_model->get_where_row($table,$where); if($result) { echo json_encode(array('user_details'=>$result,'result'=>1)); } else { echo json_encode(array('result'=>0)); } } //Update access control public function update_access() { $user_id = $this->input->post('user_id'); $account_type = $this->input->post('type'); $username = $this->input->post('username'); $email = $this->input->post('email'); $password = $this->input->post('password'); $mail_password =$this->input->post('mail_password'); $signature = $this->input->post('signature'); $roles = $this->input->post('edit_roles'); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $updated_at = $date->format('Y-m-d H:i:s'); $data = array( 'user_type_id' => $account_type, 'email' => $email, 'username' => $username, 'password' => $password, 'mail_password' => $mail_password, 'signature' => $signature, 'roles' => $roles, 'delete_status' => 'ACTIVE', 'updated_at' => $updated_at ); $executive_id = $this->input->post('executive_id'); if(isset($executive_id)) { $data['executive_id'] = $this->input->post('executive_id'); } $land_owner_id = $this->input->post('land_owner_id'); if(isset($land_owner_id)) { $data['land_owner_id'] = $this->input->post('land_owner_id'); } $where = array('user_id'=>$user_id); $table = 'gss_login'; $user_data = $this->gss_model->get_where_row($table,$where); $where_email = $user_data->email; $where_clause = array('delete_status'=>'ACTIVE','email !='=>$where_email); $emails = $this->gss_model->get_where_result($table,$where_clause); $array = array(); foreach($emails as $value) { array_push($array, $value->email); } if(in_array($email,$array)) { echo json_encode(array('result'=>2,'message'=>"Email already exists")); } else { $result = $this->gss_model->update($where,$table,$data); if($this->db->affected_rows() > 0) { echo json_encode(array('result'=>1,'message'=>"Credentials updated successfully")); } else { echo json_encode(array('result'=>0,'message'=>"Something went wrong.. try again")); } } } //Admin login public function login() { $email = $this->input->post('email'); $password = $this->input->post('password'); $result = $this->gss_model->admin_login($email,$password); if($result) { $this->session->set_userdata('admin',$result->username); $this->session->set_userdata('admin_id',$result->user_id); $this->session->set_userdata('user_type',$result->user_type); $this->session->set_userdata('user_type_id',$result->user_type_id); $this->session->set_userdata('executive_id',$result->executive_id); $this->session->set_userdata('land_owner_id',$result->land_owner_id); $table = 'gss_access_controls'; $where = array('delete_status'=>'ACTIVE','department_id'=>$result->user_type_id); $res = $this->gss_model->get_where_result($table,$where); echo json_encode(array( 'result' => 1, 'user_type' => session()->get('user_type'), 'user_type_id' => session()->get('user_type_id'), 'username' => session()->get('admin'), 'admin_id' => session()->get('admin_id'), //'powers' => session()->get('powers') )); } else { echo json_encode(array('result'=>0,'message'=>"Wrong login credentials")); } } //access public function access_details() { $gss_model = new Gss_model(); $id=session()->get('admin_id'); $table='gss_login'; $where=array('user_id'=>$id); $d=$gss_model->get_where_row($table,$where); $data['user_type_id']=$d->user_type_id; $table='gss_access_controls'; $where=array('department_id'=>$data['user_type_id']); return $gss_model->get_where_result($table,$where); } public function access_id() { $gss_model = new Gss_model(); $id=session()->get('admin_id'); $table='gss_login'; $where=array('user_id'=>$id); $d=$gss_model->get_where_row($table,$where); return $d->user_type_id; } //Admin dashboard //Land owner form public function land_owner_form() { $admin_id = session()->get('admin_id'); if($admin_id) { $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $this->load->view('admin/land_owner_form',$data); } else { redirect('/'); } } //Land owner list public function land_owner_list() { $admin_id = session()->get('admin_id'); if($admin_id) { $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $this->load->view('admin/land_owners_list',$data); } else { redirect('/'); } } //Update admin login credentials public function update_admin_password() { $password1 = $this->input->post('password1'); $password2 = $this->input->post('password2'); if($password1 == $password2) { $table = 'gss_login'; $admin_id = session()->get('admin_id'); $where = array('user_id'=>$admin_id); $data = array('password'=>md5($password2)); $result = $this->gss_model->update($where,$table,$data); if($this->db->affected_rows() > 0) { echo json_encode(array('result'=>1,'message'=>"Password updated successfully")); } } else { echo json_encode(array('result'=>0,'message'=>"Password doesn't match.")); } } //Add land owners public function add_land_owners() { $project = $this->input->post('project_name'); $name = $this->input->post('name'); $email = $this->input->post('email'); $mobile = $this->input->post('mobile'); $address = $this->input->post('address'); $pan_or_adhar = $this->input->post('pan_or_adhar'); $this->load->library('image_lib'); $file_name = ""; if($_FILES) { if(empty($_FILES['id_proof_image']['name'])) { $file_name = ""; } else { $target='land_owners_images/'; $target.=time().$_FILES['id_proof_image']['name']; $file_name=time().$_FILES['id_proof_image']['name']; $image=$target; move_uploaded_file($_FILES['id_proof_image']['tmp_name'],$target); $config['source_image']=$target; $config['maintain_ratio']=TRUE; $config['width']=200; $config['height']=150; $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( 'project_name' => $project, 'name' => $name, 'email' => $email, 'mobile' => $mobile, 'address' => $address, 'pan_or_adhar_number' => $pan_or_adhar, 'id_proof_image' => $file_name, 'delete_status' => 'ACTIVE', 'created_at' => $created_at ); $land_table = 'gss_land_owners'; $image_table = 'gss_land_images'; $where = array('delete_status'=>'ACTIVE'); $numbers = $this->gss_model->get_where_result($land_table,$where); $array = array(); $check_owner = $this->gss_model->check_land_owners($project,$name,$mobile); if($check_owner) { echo json_encode(array('result'=>2,'message'=>"Land owner already exists")); } else { $result = $this->gss_model->insert($land_table,$data); if($result) { echo json_encode(array('result'=>1,'message'=>"Land owner details added successfully")); } else { echo json_encode(array('result'=>0,'message'=>"Something went wrong.. try again")); } } } //Land owners list public function land_owners_list() { $table = 'gss_land_owners'; $where = array('delete_status'=>'ACTIVE'); $order_by = "name"; $result = $this->gss_model->get_where_result_alphabetical($table,$where,$order_by); if($result) { echo json_encode($result); } else { echo json_encode(array('result'=>0)); } } //Delete land owners public function delete_land_owner() { $table = 'gss_land_owners'; $owner_id = $this->input->post('owner_id'); $where = array('owner_id'=>$owner_id); $data = array('delete_status'=>'INACTIVE'); $result = $this->gss_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)); } } //Edit land owner public function edit_land_owner() { $table = 'gss_land_owners'; $owner_id = $this->input->post('owner_id'); $where = array('owner_id'=>$owner_id,'delete_status'=>'ACTIVE'); $result = $this->gss_model->get_where_row($table,$where); if($result) { echo json_encode(array('land_owners_details'=>$result,'result'=>1)); } else { echo json_encode(array('result'=>0)); } } //Update land owners public function update_land_owner() { $table = 'gss_land_owners'; $owner_id = $this->input->post('owner_id'); $name = $this->input->post('name'); $project_name = $this->input->post('project_name'); $email = $this->input->post('email'); $mobile = $this->input->post('mobile'); $address = $this->input->post('address'); $pan_or_adhar = $this->input->post('pan_or_adhar'); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $updated_at = $date->format('Y-m-d H:i:s'); $where_file = array('owner_id'=>$owner_id); $file_data = $this->gss_model->get_where_row($table,$where_file); $id_proof = $file_data->id_proof_image; if(empty($_FILES['id_proof_image']['name'])) { $data = array( 'name' => $name, 'project_name' => $project_name, 'email' => $email, 'mobile' => $mobile, 'address' => $address, 'pan_or_adhar_number' => $pan_or_adhar, 'id_proof_image' => $id_proof, 'delete_status' => 'ACTIVE', 'updated_at' => $updated_at ); } else { $this->load->library('image_lib'); $target='land_owners_images/'; $target.=time().$_FILES['id_proof_image']['name']; $file_name=time().$_FILES['id_proof_image']['name']; $image=$target; move_uploaded_file($_FILES['id_proof_image']['tmp_name'],$target); $config['source_image']=$target; $config['maintain_ratio']=TRUE; $config['width']=200; $config['height']=450; $this->image_lib->initialize($config); $this->image_lib->resize(); $data = array( 'name' => $name, 'project_name' => $project_name, 'email' => $email, 'mobile' => $mobile, 'address' => $address, 'pan_or_adhar_number' => $pan_or_adhar, 'id_proof_image' => $file_name, 'delete_status' => 'ACTIVE', 'updated_at' => $updated_at ); } $where_mobile = $file_data->mobile; $where = array('delete_status'=>'ACTIVE','mobile !='=>$where_mobile); $numbers = $this->gss_model->get_where_result($table,$where); $array = array(); foreach($numbers as $value) { array_push($array, $value->mobile); } if(in_array($mobile,$array)) { echo json_encode(array('result'=>2,'message'=>"Contact number already exists")); } else { $where_id = array('owner_id'=>$owner_id); $result = $this->gss_model->update($where_id,$table,$data); 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")); } } } //Enquiry form public function enquiry_form() { $admin_id = session()->get('admin_id'); if($admin_id) { $table = 'gss_webportals'; $broker_table = 'gss_brokers'; $databasetable ='gss_database'; $where = array('delete_status'=>'ACTIVE'); $where_reference = array('delete_status'=>'ACTIVE','type'=>'Executives'); $order_by1 = 'associate_name'; $order_by2 = 'webportal'; $order_by3 = 'database_name'; $data['reference'] = $this->gss_model->get_where_result_alphabetical($broker_table,$where_reference,$order_by1); $data['webportals'] = $this->gss_model->get_where_result_alphabetical($table,$where,$order_by2); $data['database'] = $this->gss_model->get_where_result_alphabetical($databasetable,$where,$order_by3); $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $this->load->view('admin/enquiry_form',$data); } else { redirect('/'); } } //Enquiry form public function enquiry_list() { $admin_id = session()->get('admin_id'); if($admin_id) { $table = 'gss_webportals'; $broker_table = 'gss_brokers'; $databasetable ='gss_database'; $where = array('delete_status'=>'ACTIVE'); $where_reference = array('delete_status'=>'ACTIVE','type'=>'Executives'); $order_by1 = 'associate_name'; $order_by2 = 'webportal'; $order_by3 = 'database_name'; $data['reference'] = $this->gss_model->get_where_result_alphabetical($broker_table,$where_reference,$order_by1); $data['webportals'] = $this->gss_model->get_where_result_alphabetical($table,$where,$order_by2); $data['database'] = $this->gss_model->get_where_result_alphabetical($databasetable,$where,$order_by3); $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $this->load->view('admin/enquiry_list',$data); } else { redirect('/'); } } //Add enquiries public function add_enquiries() { $name = ucfirst($this->input->post('name')); $email = $this->input->post('email'); $mobile = $this->input->post('mobile'); $mobile2 = $this->input->post('mobile2'); $address = $this->input->post('address'); $web_portal = $this->input->post('web_portal'); $reference = $this->input->post('reference'); $database = $this->input->post('database'); $status = $this->input->post('status'); $day = $this->input->post('day'); //$date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $created_at = date("Y-m-d", strtotime($day)); $table = 'gss_enquiries'; $data = array( 'customer_name' => ucfirst($name), 'email' => $email, 'mobile' => $mobile, 'mobile2' => $mobile2, 'address' => $address, 'web_portal_address' => $web_portal, 'reference' => $reference, 'database_name' => $database, 'status' => $status, 'delete_status' => 'ACTIVE', 'created_at' => $created_at ); $contacts = $this->gss_model->check_enquiries($name,$mobile); if($contacts) { echo json_encode(array('result'=>2,'message'=>"Customer details already exists")); } else { $result = $this->gss_model->insert($table,$data); if($result) { echo json_encode(array('result'=>1,'message'=>"Enquiry added successfully")); } else { echo json_encode(array('result'=>0,'message'=>"Something went wrong.. try again")); } } } public function enquiries() { $customer_name = $_GET['customer_name']; $table = 'gss_enquiries'; $where = array('delete_status'=>'ACTIVE'); $order_by = 'enquiry_id'; $result = $this->gss_model->get_where_result_orderby_desc1($table,$where,$order_by,$customer_name); // print_r($customer_name); // die(); if($result) { echo json_encode($result); } else { echo json_encode(array('result'=>0)); } } public function enquiries_list() { $from_date = $_GET['from_date']; if($from_date != "") { $date = new DateTime($from_date); $from_date = $date->format('Y-m-d'); } $to_date =$_GET['to_date']; if($to_date != "") { $date = new DateTime($to_date); $to_date = $date->format('Y-m-d'); } $customer_name = $_GET['customer_name']; $table = 'gss_enquiries'; $result = $this->gss_model->get_where_result1($table,$from_date,$to_date,$customer_name); echo json_encode($result); } //Delete enquiries public function delete_enquiries() { $table = 'gss_enquiries'; $enquiry_id = $this->input->post('enquiry_id'); $where = array('enquiry_id'=>$enquiry_id); $data = array('delete_status'=>'INACTIVE'); $result = $this->gss_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)); } } //Edit enquiry public function edit_enquiries() { $table = 'gss_enquiries'; $enquiry_id = $this->input->post('enquiry_id'); $where = array('enquiry_id'=>$enquiry_id,'delete_status'=>'ACTIVE'); $result = $this->gss_model->get_where_row($table,$where); if($result) { echo json_encode(array('enquiry_details'=>$result,'result'=>1)); } else { echo json_encode(array('result'=>0)); } } //Update enquiry public function update_enquiry() { $table = 'gss_enquiries'; $enquiry_id = $this->input->post('enquiry_id'); $name = $this->input->post('name'); $email = $this->input->post('email'); $mobile = $this->input->post('mobile'); $mobile2 = $this->input->post('mobile2'); $address = $this->input->post('address'); $web_portal = $this->input->post('web_portal'); $database = $this->input->post('database_name'); $reference = $this->input->post('reference'); $status = $this->input->post('status'); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $updated_at = $date->format('Y-m-d H:i:s'); $data = array( 'customer_name' => $name, 'email' => $email, 'mobile' => $mobile, 'mobile2' => $mobile2, 'address' => $address, 'web_portal_address' => $web_portal, 'reference' => $reference, 'database_name' => $database, 'status' => $status, 'delete_status' => 'ACTIVE', 'updated_at' => $updated_at ); $where_id = array('enquiry_id'=>$enquiry_id); $result = $this->gss_model->update($where_id,$table,$data); 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 plot payment public function add_plot_payment() { $customer = $this->input->post('customer_name'); $project = $this->input->post('project'); $site_number = $this->input->post('site_number'); $dimension = $this->input->post('dimension'); $tsv = $this->input->post('tsv'); $agreement_amount = $this->input->post('agreement_amount'); $agreement_payment_mode = $this->input->post('agreement_payment_mode'); $agreement_payment_receipt = $this->input->post('agreement_payment_receipt'); } public function update_cancellation_details() { $project = $this->input->post('project_id'); $site_number = $this->input->post('site_number'); $refund_id = $this->input->post('refunded_id'); $booking_id = $this->input->post('booking_id'); $cancellation_id = $this->input->post('cancellation_id'); $refunded = $this->input->post('refunded'); $refunded_to = $this->input->post('refunded_to'); $refunded_date = $this->input->post('new_refunded_date'); $total = $this->input->post('total'); $total = str_replace(',', '', $total); $due_amount = $this->input->post('new_due_amount'); $due_amount = str_replace(',', '', $due_amount); $due_with = $this->input->post('new_due_with'); $refund_amount = $this->input->post('new_refunded_amount'); $refund_amount = str_replace(',', '', $refund_amount); //$refunded_amount = array($refund_amount); $cancellation_date = $this->input->post('cancellation_date'); if($cancellation_date != "") { $date = new DateTime($cancellation_date); $cancellation_date = $date->format('Y-m-d'); } $refunded_payment_mode = $this->input->post('new_refunded_payment_mode'); $cheque_no = ''; $cheque_date = ''; $bank_name = ''; $vtr_no = ''; $online_date = ''; $result = ''; $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $created_at = $date->format('Y-m-d H:i:s'); $note = $this->input->post('note'); $data = array( 'booking_id' => $booking_id, 'refunded' => $refunded, 'cancellation_date' => $cancellation_date, 'created_at' => $created_at ); $cancel_table = 'gss_cancellations'; $booking_table = 'gss_bookings'; $where_booking = array('booking_id' => $booking_id); $check_status = $this->gss_model->payment_site_booking_details($site_number,$project); $where_cancel = array('cancellation_id' => $cancellation_id); $result = $this->gss_model->update($where_cancel,$cancel_table,$data); if($result) { $payments = $this->input->post('edit_payment_id'); $installments = $this->input->post('installment_amount'); $installments = str_replace(',', '', $installments); $edit_booking_id = $this->input->post('edit_booking_id'); $sale_agree_amount = $this->input->post('sale_agree_amount'); $sale_agree_amount = str_replace(',', '', $sale_agree_amount); $payment_table = 'gss_plot_payments'; $where_booking = array('booking_id' => $edit_booking_id); $aggr_data = array('agreement_amount' => $sale_agree_amount); $update_aggr = $this->gss_model->update($where_booking,$payment_table,$aggr_data); if($payments) { foreach($payments as $keys=>$vals) { $where_payment = array('payment_id' => $vals); $instl_data = array('installment_amount1' => $installments[$keys]); $update_inst = $this->gss_model->update($where_payment,$payment_table,$instl_data); } } if(!empty($refund_amount)) { $payment_data_array = array(); foreach($refund_amount as $key=>$val) { if(!empty($refunded_date)) { $refunded_date = $refunded_date; } else { $refunded_date = '0000-00-00'; } if($refunded_payment_mode[$key] == 'Cheque') { $cheque_no = $this->input->post('new_cheque_no'); if(!empty($cheque_no)) { $cheque_no = $this->input->post('new_cheque_no'); } else { $cheque_no = '0'; } $cheque_date = $this->input->post('new_cheque_date'); if(!empty($cheque_date)) { //print_r($cheque_date[$key]); $cheque_date = $cheque_date; } else { $cheque_date = '00-00-0000'; } $bank_name = $this->input->post('new_bank_name'); if(!empty($bank_name)) { $bank_name = $this->input->post('new_bank_name'); } else { $bank_name = '0'; } $vtr_no[$key] = '0'; $online_date[$key] = '00-00-0000'; } else if($refunded_payment_mode[$key] == 'Online Payment') { $vtr_no = $this->input->post('new_vtr_no'); if(!empty($vtr_no)) { $vtr_no = $this->input->post('new_vtr_no'); } else { $vtr_no = '0'; } $online_date = $this->input->post('new_online_date'); if(!empty($online_date)) { $online_date = $online_date; } else { $online_date = '00-00-0000'; } $cheque_no = '0'; $cheque_date = '00-00-0000'; $bank_name = '0'; } else { $vtr_no[$key] = '0'; $online_date[$key] = '00-00-0000'; $cheque_no[$key] = '0'; $cheque_date[$key] = '00-00-0000'; $bank_name[$key] = '0'; } $payment_data = array( 'cancellation_id' => $cancellation_id, 'booking_id' => $booking_id, 'total' => $total, 'due_amount' => $due_amount[$key], 'refunded_payment_mode' => $refunded_payment_mode[$key], 'refunded_date' => $refunded_date[$key], 'refunded_amount' => $refund_amount[$key], 'due_with' => $due_with[$key], 'vtr_no' => $vtr_no[$key], 'online_date' => $online_date[$key], 'cheque_no' => $cheque_no[$key], 'cheque_date' => $cheque_date[$key], 'bank_name' => $bank_name[$key], 'delete_status' => 'ACTIVE', 'created_at' => $created_at ); $payment_data_array[] = $payment_data; if($due_amount[$key] == 0 && $refunded == "Yes") { $booking_data = array('booking_status' => 'REFUNDED'); } else if($due_amount[$key] != 0 && $refunded == "Yes") { $booking_data = array('booking_status' => 'REFUND_PENDING'); } else { $booking_data = array('booking_status' => 'CANCELLED'); } /*$booking_result = $this->gss_model->update($where_booking,$booking_table,$booking_data); if($this->db->affected_rows() > 0) { $table = 'gss_cancellation_refunds'; $refund_result = $this->db->insert_batch($table,$payment_data_array); if($refund_result) { echo json_encode(array('result'=>1,'message'=>'Details added successfully')); } else { echo json_encode(array('result'=>0,'message'=>'Something went wrong')); } } else { echo json_encode(array('result'=>0,'message'=>'Something went wrong')); }*/ } if(!empty($payment_data)) { /*$get_details = $this->gss_model->get_where_row($booking_table,$where_booking); if($get_details->booking_status == 'REFUND_PENDING') {*/ $booking_result = $this->gss_model->update($where_booking,$booking_table,$booking_data); $table = 'gss_cancellation_refunds'; $refund_result = $this->db->insert_batch($table,$payment_data_array); if($refund_result) { echo json_encode(array('result'=>1,'message'=>'Details added successfully')); } else { echo json_encode(array('result'=>0,'message'=>'Something went wrong')); } /* } else { echo json_encode(array('result'=>0,'message'=>'Something went wrong')); }*/ } else { echo json_encode(array('result'=>0,'message'=>'No details to update')); } } else { echo json_encode(array('result'=>0,'message'=>'No details entered to update')); } } else { echo json_encode(array('result'=>0,'message'=>'Something went wrong')); } } /* //Add cancellation details public function add_cancellation_details() { $project = $this->input->post('project_id'); $site_number = $this->input->post('site_number'); $booking_id = $this->input->post('booking_id'); $refunded = $this->input->post('refunded'); $refunded_to = $this->input->post('refunded_to'); $refunded_date = $this->input->post('refunded_date'); $total = $this->input->post('total'); $due_amount = $this->input->post('due_amount1'); $due_with = $this->input->post('due_with'); if($refunded_date != "") { $date = new DateTime($refunded_date); $refunded_date = $date->format('Y-m-d'); } $refunded_amount = $this->input->post('refunded_amount'); $cancellation_date = $this->input->post('cancellation_date'); if($cancellation_date != "") { $date = new DateTime($cancellation_date); $cancellation_date = $date->format('Y-m-d'); } $refunded_payment_mode = $this->input->post('refunded_payment_mode'); $cheque_no = ''; $cheque_date = ''; $bank_name = ''; if($refunded_payment_mode == 'Cheque') { $cheque_no = $this->input->post('cheque_no'); $cheque_date = $this->input->post('cheque_date'); if($cheque_date != "") { $date = new DateTime($cheque_date); $cheque_date = $date->format('Y-m-d'); } $bank_name = $this->input->post('bank_name'); } $vtr_no = ''; $online_date = ''; if($refunded_payment_mode == 'Online Payment') { $vtr_no = $this->input->post('vtr_no'); $online_date = $this->input->post('online_date'); if($online_date != "") { $date = new DateTime($online_date); $online_date = $date->format('Y-m-d'); } } $file_name = ""; $file_name1 = ""; $this->load->library('image_lib'); if($_FILES) { if(empty($_FILES['refunded_request_letter']['name'])) { $file_name = ""; } else { $target='cancellation_uploads/'; $target.=time().$_FILES['refunded_request_letter']['name']; $file_name=time().$_FILES['refunded_request_letter']['name']; $image=$target; move_uploaded_file($_FILES['refunded_request_letter']['tmp_name'],$target); $config['source_image']=$target; $config['maintain_ratio']=TRUE; $config['width']=200; $config['height']=450; $this->image_lib->initialize($config); $this->image_lib->resize(); } if(empty($_FILES['cancellation_agreement_image']['name'])) { $file_name1 = ""; } else { $target1='cancellation_uploads/'; $target1.=time().$_FILES['cancellation_agreement_image']['name']; $file_name1=time().$_FILES['cancellation_agreement_image']['name']; $image1=$target1; move_uploaded_file($_FILES['cancellation_agreement_image']['tmp_name'],$target1); $config1['source_image']=$target1; $config1['maintain_ratio']=TRUE; $config1['width']=200; $config1['height']=450; $this->image_lib->initialize($config1); $this->image_lib->resize(); } } else { $file_name = ""; $file_name1 = ""; } $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $created_at = $date->format('Y-m-d H:i:s'); // $note = $this->input->post('note'); $data = array( 'booking_id' => $booking_id, 'refunded' => $refunded, //'refunded_to' => $refunded_to, //'refunded_date' => $refunded_date, //'refunded_amount' => $refunded_amount, //'refunded_payment_mode' => $refunded_payment_mode, //'cheque_no' => $cheque_no, //'cheque_date' => $cheque_date, // 'bank_name' => $bank_name, // 'total' => $total, 'refunded_request_letter' => $file_name, 'cancellation_date' => $cancellation_date, 'cancellation_agreement_image' => $file_name1, // 'due_amount' => $due_amount, // 'due_with' => $due_with, // 'vtr_no' => $vtr_no, // 'online_date' => $online_date, 'delete_status' => 'ACTIVE', // 'note' =>$note, 'created_at' => $created_at ); $cancel_table = 'gss_cancellations'; $booking_table = 'gss_bookings'; $where_booking = array('booking_id' => $booking_id); $check_status = $this->gss_model->payment_site_booking_details($site_number,$project); if($check_status->booking_status == 'CANCELLED') { echo json_encode(array('result'=>2,'message'=>'Site already cancelled')); } else { $result = $this->gss_model->insert($cancel_table,$data); if($result) { if($refunded == "Yes") { $booking_data = array('booking_status' => 'REFUNDED'); } else { $booking_data = array('booking_status' => 'CANCELLED'); } $booking_result = $this->gss_model->update($where_booking,$booking_table,$booking_data); echo json_encode(array('result'=>1,'message'=>'Details added successfully')); } else { echo json_encode(array('result'=>0,'message'=>'Something went wrong..try again')); } } }*/ /* public function add_cancellation_details() { $project = $this->input->post('project_id'); $site_number = $this->input->post('site_number'); $booking_id = $this->input->post('booking_id'); $refunded = $this->input->post('refunded'); $refunded_to = $this->input->post('refunded_to'); $refunded_date = $this->input->post('refunded_date'); $total = $this->input->post('total'); $due_amount = $this->input->post('due_amount'); $due_with = $this->input->post('due_with'); $refund_amount = $this->input->post('refunded_amount'); //$refunded_amount = array($refund_amount); $cancellation_date = $this->input->post('cancellation_date'); if($cancellation_date != "") { $date = new DateTime($cancellation_date); $cancellation_date = $date->format('Y-m-d'); } $refunded_payment_mode = $this->input->post('refunded_payment_mode'); $cheque_no = ''; $cheque_date = ''; $bank_name = ''; $vtr_no = ''; $online_date = ''; $result = ''; $file_name = ""; $file_name1 = ""; $this->load->library('image_lib'); if($_FILES) { if(empty($_FILES['refunded_request_letter']['name'])) { $file_name = ""; } else { $target='cancellation_uploads/'; $target.=time().$_FILES['refunded_request_letter']['name']; $file_name=time().$_FILES['refunded_request_letter']['name']; $image=$target; move_uploaded_file($_FILES['refunded_request_letter']['tmp_name'],$target); $config['source_image']=$target; $config['maintain_ratio']=TRUE; $config['width']=200; $config['height']=450; $this->image_lib->initialize($config); $this->image_lib->resize(); } if(empty($_FILES['cancellation_agreement_image']['name'])) { $file_name1 = ""; } else { $target1='cancellation_uploads/'; $target1.=time().$_FILES['cancellation_agreement_image']['name']; $file_name1=time().$_FILES['cancellation_agreement_image']['name']; $image1=$target1; move_uploaded_file($_FILES['cancellation_agreement_image']['tmp_name'],$target1); $config1['source_image']=$target1; $config1['maintain_ratio']=TRUE; $config1['width']=200; $config1['height']=450; $this->image_lib->initialize($config1); $this->image_lib->resize(); } } else { $file_name = ""; $file_name1 = ""; } $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $created_at = $date->format('Y-m-d H:i:s'); $note = $this->input->post('note'); $data = array( 'booking_id' => $booking_id, 'refunded' => $refunded, 'refunded_request_letter' => $file_name, 'cancellation_date' => $cancellation_date, 'cancellation_agreement_image' => $file_name1, 'created_at' => $created_at ); $cancel_table = 'gss_cancellations'; $booking_table = 'gss_bookings'; $where_booking = array('booking_id' => $booking_id); $check_status = $this->gss_model->payment_site_booking_details($site_number,$project); if($check_status->booking_status == 'CANCELLED') { echo json_encode(array('result'=>2,'message'=>'Site already cancelled')); } else { $result = $this->gss_model->insert($cancel_table,$data); if($result) { if(!empty($refund_amount)) { $payment_data_array = array(); foreach($refund_amount as $key=>$val) { if(!empty($refunded_date)) { $refunded_date = $refunded_date; } else { $refunded_date = '0000-00-00'; } if($refunded_payment_mode[$key] == 'Cheque') { $cheque_no = $this->input->post('cheque_no'); if(!empty($cheque_no)) { $cheque_no = $this->input->post('cheque_no'); } else { $cheque_no = '0'; } $cheque_date = $this->input->post('cheque_date'); if(!empty($cheque_date)) { //print_r($cheque_date[$key]); $cheque_date = $cheque_date; } else { $cheque_date = '00-00-0000'; } $bank_name = $this->input->post('bank_name'); if(!empty($bank_name)) { $bank_name = $this->input->post('bank_name'); } else { $bank_name = '0'; } $vtr_no[$key] = '0'; $online_date[$key] = '00-00-0000'; } else if($refunded_payment_mode[$key] == 'Online Payment') { $vtr_no = $this->input->post('vtr_no'); if(!empty($vtr_no)) { $vtr_no = $this->input->post('vtr_no'); } else { $vtr_no = '0'; } $online_date = $this->input->post('online_date'); if(!empty($online_date)) { $online_date = $online_date; } else { $online_date = '00-00-0000'; } $cheque_no = '0'; $cheque_date = '00-00-0000'; $bank_name = '0'; } else { $vtr_no[$key] = '0'; $online_date[$key] = '00-00-0000'; $cheque_no[$key] = '0'; $cheque_date[$key] = '00-00-0000'; $bank_name[$key] = '0'; } $payment_data = array( 'cancellation_id' => $result, 'booking_id' => $booking_id, 'total' => $total, 'due_amount' => $due_amount[$key], 'refunded_payment_mode' => $refunded_payment_mode[$key], 'refunded_date' => $refunded_date[$key], 'refunded_amount' => $refund_amount[$key], 'due_with' => $due_with[$key], 'vtr_no' => $vtr_no[$key], 'online_date' => $online_date[$key], 'cheque_no' => $cheque_no[$key], 'cheque_date' => $cheque_date[$key], 'bank_name' => $bank_name[$key], 'delete_status' => 'ACTIVE', 'created_at' => $created_at ); $payment_data_array[] = $payment_data; } if($due_amount[$key] == 0 && $refunded == "Yes") { $booking_data = array('booking_status' => 'REFUNDED'); } else if($due_amount[$key] != 0 && $refunded == "Yes") { $booking_data = array('booking_status' => 'REFUND_PENDING'); } else { $booking_data = array('booking_status' => 'CANCELLED'); } $booking_result = $this->gss_model->update($where_booking,$booking_table,$booking_data); if($booking_result) { $table = 'gss_cancellation_refunds'; $refund_result = $this->db->insert_batch($table,$payment_data_array); if($refund_result) { echo json_encode(array('result'=>1,'message'=>'Details added successfully')); } else { echo json_encode(array('result'=>0,'message'=>'Something went wrong')); } } else { echo json_encode(array('result'=>0,'message'=>'Something went wrong')); } } } else { echo json_encode(array('result'=>0,'message'=>'Something went wrong')); } } }*/ public function add_cancellation_details() { $project = $this->input->post('project_id'); $site_number = $this->input->post('site_number'); $booking_id = $this->input->post('booking_id'); $refunded = $this->input->post('refunded'); $refunded_to = $this->input->post('refunded_to'); $refunded_date = $this->input->post('refunded_date'); $total = $this->input->post('total'); $due_amount = $this->input->post('due_amount'); $due_amount = str_replace(',', '', $due_amount); $due_with = $this->input->post('due_with'); $refund_amount = $this->input->post('refunded_amount'); $refund_amount = str_replace(',', '', $refund_amount); //$refunded_amount = array($refund_amount); $cancellation_date = $this->input->post('cancellation_date'); if($cancellation_date != "") { $date = new DateTime($cancellation_date); $cancellation_date = $date->format('Y-m-d'); } $refunded_payment_mode = $this->input->post('refunded_payment_mode'); $cheque_no = ''; $cheque_date = ''; $bank_name = ''; $vtr_no = ''; $online_date = ''; $result = ''; $file_name = ""; $file_name1 = ""; $this->load->library('image_lib'); if($_FILES) { if(empty($_FILES['refunded_request_letter']['name'])) { $file_name = ""; } else { $target='cancellation_uploads/'; $target.=time().$_FILES['refunded_request_letter']['name']; $file_name=time().$_FILES['refunded_request_letter']['name']; $image=$target; move_uploaded_file($_FILES['refunded_request_letter']['tmp_name'],$target); $config['source_image']=$target; $config['maintain_ratio']=TRUE; $config['width']=200; $config['height']=450; $this->image_lib->initialize($config); $this->image_lib->resize(); } if(empty($_FILES['cancellation_agreement_image']['name'])) { $file_name1 = ""; } else { $target1='cancellation_uploads/'; $target1.=time().$_FILES['cancellation_agreement_image']['name']; $file_name1=time().$_FILES['cancellation_agreement_image']['name']; $image1=$target1; move_uploaded_file($_FILES['cancellation_agreement_image']['tmp_name'],$target1); $config1['source_image']=$target1; $config1['maintain_ratio']=TRUE; $config1['width']=200; $config1['height']=450; $this->image_lib->initialize($config1); $this->image_lib->resize(); } } else { $file_name = ""; $file_name1 = ""; } $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $created_at = $date->format('Y-m-d H:i:s'); $note = $this->input->post('note'); $data = array( 'booking_id' => $booking_id, 'refunded' => $refunded, 'refunded_request_letter' => $file_name, 'cancellation_date' => $cancellation_date, 'cancellation_agreement_image' => $file_name1, 'created_at' => $created_at ); $cancel_table = 'gss_cancellations'; $booking_table = 'gss_bookings'; $where_booking = array('booking_id' => $booking_id); $check_status = $this->gss_model->payment_site_booking_details($site_number,$project); if($check_status->booking_status == 'CANCELLED') { echo json_encode(array('result'=>2,'message'=>'Site already cancelled')); } else { $result = $this->gss_model->insert($cancel_table,$data); if($result) { if(!empty($refund_amount)) { $payment_data_array = array(); foreach($refund_amount as $key=>$val) { if(!empty($refunded_date)) { $refunded_date = $refunded_date; } else { $refunded_date = '0000-00-00'; } if($refunded_payment_mode[$key] == 'Cheque') { $cheque_no = $this->input->post('cheque_no'); if(!empty($cheque_no)) { $cheque_no = $this->input->post('cheque_no'); } else { $cheque_no = '0'; } $cheque_date = $this->input->post('cheque_date'); if(!empty($cheque_date)) { //print_r($cheque_date[$key]); $cheque_date = $cheque_date; } else { $cheque_date = '00-00-0000'; } $bank_name = $this->input->post('bank_name'); if(!empty($bank_name)) { $bank_name = $this->input->post('bank_name'); } else { $bank_name = '0'; } $vtr_no[$key] = '0'; $online_date[$key] = '00-00-0000'; } else if($refunded_payment_mode[$key] == 'Online Payment') { $vtr_no = $this->input->post('vtr_no'); if(!empty($vtr_no)) { $vtr_no = $this->input->post('vtr_no'); } else { $vtr_no = '0'; } $online_date = $this->input->post('online_date'); if(!empty($online_date)) { $online_date = $online_date; } else { $online_date = '00-00-0000'; } $cheque_no = '0'; $cheque_date = '00-00-0000'; $bank_name = '0'; } else { $vtr_no[$key] = '0'; $online_date[$key] = '00-00-0000'; $cheque_no[$key] = '0'; $cheque_date[$key] = '00-00-0000'; $bank_name[$key] = '0'; } $payment_data = array( 'cancellation_id' => $result, 'booking_id' => $booking_id, 'total' => $total, 'due_amount' => $due_amount[$key], 'refunded_payment_mode' => $refunded_payment_mode[$key], 'refunded_date' => $refunded_date[$key], 'refunded_amount' => $refund_amount[$key], 'due_with' => $due_with[$key], 'vtr_no' => $vtr_no[$key], 'online_date' => $online_date[$key], 'cheque_no' => $cheque_no[$key], 'cheque_date' => $cheque_date[$key], 'bank_name' => $bank_name[$key], 'delete_status' => 'ACTIVE', 'created_at' => $created_at ); $payment_data_array[] = $payment_data; } if($due_amount[$key] == 0 && $refunded == "Yes") { $booking_data = array('booking_status' => 'REFUNDED'); } else if($due_amount[$key] != 0 && $refunded == "Yes") { $booking_data = array('booking_status' => 'REFUND_PENDING'); } $booking_result = $this->gss_model->update($where_booking,$booking_table,$booking_data); if($booking_result) { $table = 'gss_cancellation_refunds'; $refund_result = $this->db->insert_batch($table,$payment_data_array); if($refund_result) { echo json_encode(array('result'=>1,'message'=>'Details added successfully')); } else { echo json_encode(array('result'=>0,'message'=>'Something went wrong')); } } else { echo json_encode(array('result'=>0,'message'=>'Something went wrong')); } } else { if($refunded == "No") { $booking_data = array('booking_status' => 'CANCELLED'); } $booking_result = $this->gss_model->update($where_booking,$booking_table,$booking_data); if($booking_result) { echo json_encode(array('result'=>1,'message'=>'Details added successfully')); } else { echo json_encode(array('result'=>0,'message'=>'Something went wrong')); } } } else { echo json_encode(array('result'=>0,'message'=>'Something went wrong')); } } } //Cancellation list public function cancellation_list() { $result = $this->gss_model->cancellation_list(); if($result) { echo json_encode($result); } else { echo json_encode(array('result'=>0)); } } // Canellation details /* public function cancellation_details() { $admin_id = session()->get('admin_id'); if($admin_id) { $broker_table = 'gss_brokers'; $cancellation_id = $this->uri->segment(2); $cancel_result = $this->gss_model->cancellation_details2($cancellation_id); $data['payment'] = $this->gss_model->cancellation_payment_details($cancellation_id); //$data['details'] = $this->gss_model->cancellation_details2($cancellation_id); if($cancel_result->refunded == 'No') { $data['details'] = $this->gss_model->cancellation_details2($cancellation_id); } else { $data['detailss'] = $this->gss_model->cancellation_details1($cancellation_id); $data['refunds'] = $this->gss_model->get_where_refunds($cancellation_id); } //print_r($data['details']); // print_r($data); $this->load->view('admin/cancellation_details',$data); } else { redirect('/'); } }*/ public function cancellation_details() { $admin_id = session()->get('admin_id'); if($admin_id) { $broker_table = 'gss_brokers'; $cancellation_id = $this->uri->segment(2); $cancel_result = $this->gss_model->cancellation_details2($cancellation_id); $data['payment'] = $this->gss_model->cancellation_payment_details($cancellation_id); $data['agreement'] = $this->gss_model->cancellation_agreement_details($cancellation_id); $data['total_amount'] = $this->gss_model->cancellation_total_amount($cancellation_id); if($cancel_result->refunded == 'No') { $data['details'] = $this->gss_model->cancellation_details_no_refunds($cancellation_id); } else { $data['detailss'] = $this->gss_model->cancellation_details1($cancellation_id); } $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $this->load->view('admin/cancellation_details',$data); } else { redirect('/'); } } public function edit_cancellation_details() { $admin_id = session()->get('admin_id'); if($admin_id) { $broker_table = 'gss_brokers'; $project_table = 'gss_new_projects'; $where_project = array('delete_status'=>'ACTIVE','project_status'=>'ONGOING'); $where_reference = array('delete_status'=>'ACTIVE','type'=>'Executives'); $where_associate = array('delete_status'=>'ACTIVE','type'=>'Associate'); $where_subassociate = array('delete_status'=>'ACTIVE','type'=>'Sub Associate'); $order_by_project = 'project_name'; $order_by_associate = 'associate_name'; $order_by_reference = 'associate_name'; $data['associates'] = $this->gss_model->get_where_result_alphabetical($broker_table,$where_associate,$order_by_associate); $data['subassociates'] = $this->gss_model->get_where_result_alphabetical($broker_table,$where_subassociate,$order_by_associate); $data['projects'] = $this->gss_model->get_where_result_alphabetical($project_table,$where_project,$order_by_project); $data['reference'] = $this->gss_model->get_where_result_alphabetical($broker_table,$where_reference,$order_by_reference); $broker_table = 'gss_brokers'; $cancellation_id = $this->uri->segment(2); $data['details'] = $this->gss_model->edit_cancellation_details1($cancellation_id); $cancel_result = $this->gss_model->edit_cancellation($cancellation_id); $data['mul_refunds'] = $this->gss_model->get_refunds($cancellation_id); $data['latest_due_amount'] = $this->gss_model->get_where_due_amount($cancellation_id); $cancellation_table = 'gss_cancellations'; $where_booking = array('cancellation_id'=>$cancellation_id); $data['cancellation_details'] = $this->gss_model->get_where_result($cancellation_table,$where_booking); $cancellation_details = $this->gss_model->get_where_row($cancellation_table,$where_booking); $can_booking_id = $cancellation_details->booking_id; $where_booking_id = array('booking_id'=>$can_booking_id); $plot_payment_table = 'gss_plot_payments'; $where_installment = array('booking_id'=>$can_booking_id,'instal_delete_status'=>'ACTIVE'); $get_install_amount = $this->gss_model->get_where_result($plot_payment_table,$where_booking_id); $data['get_install_amount'] = $this->gss_model->get_where_result($plot_payment_table,$where_booking_id); $where_payments = array('booking_id'=>$can_booking_id,'agreement_delete_status'=>'ACTIVE'); $data['get_agreement_amount'] = $this->gss_model->get_where_row($plot_payment_table,$where_payments); $branchtable = 'gss_branches'; $where_branch = array('delete_status'=>'ACTIVE'); $data['branch'] = $this->gss_model->get_where_result($branchtable,$where_branch); $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $this->load->view('admin/edit_cancellation',$data); } else { redirect('/'); } } //Delete cancellation list public function delete_cancellation_list() { $table = 'gss_cancellations'; $cancellation_id = $this->uri->segment(2); $where = array('cancellation_id'=>$cancellation_id); $data = array('delete_status'=>'INACTIVE'); $result = $this->gss_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)); } } //Associate / Executive / Logistic form public function associate_broker_form() { $admin_id = session()->get('admin_id'); if($admin_id) { $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $this->load->view('admin/associative_executive_logistic_form',$data); } else { redirect('/'); } } //Associate / Executive / Logistic form list public function associate_broker_list() { $admin_id = session()->get('admin_id'); if($admin_id) { $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $this->load->view('admin/associative_executive_logistic_list',$data); } else { redirect('/'); } } //Booking form public function bookings() { $admin_id = session()->get('admin_id'); if($admin_id) { $web_table = 'gss_webportals'; $broker_table = 'gss_brokers'; $project_table = 'gss_new_projects'; $where_portal = array('delete_status'=>'ACTIVE'); $where_associate = array('delete_status'=>'ACTIVE','type'=>'Associate'); $where_subassociate = array('delete_status'=>'ACTIVE','type'=>'Sub Associate'); $where_logistics = array('delete_status'=>'ACTIVE','type'=>'Logistic'); $where_reference = array('delete_status'=>'ACTIVE','type'=>'Executives'); $where_project = array('delete_status'=>'ACTIVE','project_status'=>'ONGOING'); //$where_project = array('delete_status'=>'ACTIVE'); $order_by = 'associate_name'; $order_by_portal = 'webportal'; $order_by_project = 'project_name'; $data['webportals'] = $this->gss_model->get_where_result_alphabetical($web_table,$where_portal,$order_by_portal); $data['associates'] = $this->gss_model->get_where_result_orderby_asc($broker_table,$where_associate,$order_by); $data['subassociates'] = $this->gss_model->get_where_result_orderby_asc($broker_table,$where_subassociate,$order_by); $data['logistics'] = $this->gss_model->get_where_result_orderby_asc($broker_table,$where_logistics,$order_by); $data['reference'] = $this->gss_model->get_where_result_orderby_asc($broker_table,$where_reference,$order_by); $data['projects'] = $this->gss_model->get_where_result_orderby_asc($project_table,$where_project,$order_by_project); $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $this->load->view('admin/booking_form',$data); } else { redirect('/'); } } //Booked sites public function booked_sites() { $admin_id = session()->get('admin_id'); if($admin_id) { $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $this->load->view('admin/booked_sites',$data); } else { redirect('/'); } } //Payment form public function payment_form() { $admin_id = session()->get('admin_id'); if($admin_id) { $project_table = 'gss_new_projects'; $order_by = 'project_name'; $where_project = array('delete_status'=>'ACTIVE','project_status'=>'ONGOING'); $data['projects'] = $this->gss_model->get_where_result_alphabetical($project_table,$where_project,$order_by); $table ='gss_project_master'; $where = array('delete_status'=>'ACTIVE'); $data['project'] = $this->gss_model->get_where_result($table,$where); $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $this->load->view('admin/individual_payment_form',$data); } else { redirect('/'); } } //Payments list public function payments_list() { $admin_id = session()->get('admin_id'); if($admin_id) { $project_table = 'gss_new_projects'; $where_project = array('delete_status'=>'ACTIVE','project_status'=>'ONGOING'); $data['projects'] = $this->gss_model->get_where_result($project_table,$where_project); $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $this->load->view('admin/individual_payment_details',$data); } else { redirect('/'); } } //Cancellation form public function cancellation_form() { $admin_id = session()->get('admin_id'); if($admin_id) { $broker_table = 'gss_brokers'; $project_table = 'gss_new_projects'; $where_project = array('delete_status'=>'ACTIVE'); $where_reference = array('delete_status'=>'ACTIVE','type'=>'Executives'); $where_associate = array('delete_status'=>'ACTIVE','type'=>'Associate'); $where_subassociate = array('delete_status'=>'ACTIVE','type'=>'Sub Associate'); $order_by_project = 'project_name'; $order_by_associate = 'associate_name'; $order_by_reference = 'associate_name'; $data['associates'] = $this->gss_model->get_where_result_alphabetical($broker_table,$where_associate,$order_by_associate); $data['subassociates'] = $this->gss_model->get_where_result_alphabetical($broker_table,$where_subassociate,$order_by_associate); $data['projects'] = $this->gss_model->get_where_result_alphabetical($project_table,$where_project,$order_by_project); $data['reference'] = $this->gss_model->get_where_result_alphabetical($broker_table,$where_reference,$order_by_reference); $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $this->load->view('admin/cancellation_form',$data); } else { redirect('/'); } } //Cancellation list public function cancellations_list() { $admin_id = session()->get('admin_id'); if($admin_id) { $broker_table = 'gss_brokers'; $project_table = 'gss_new_projects'; $where_project = array('delete_status'=>'ACTIVE','project_status'=>'ONGOING'); $where_reference = array('delete_status'=>'ACTIVE','type'=>'Executives'); $where_associate = array('delete_status'=>'ACTIVE','type'=>'Associate'); $data['associates'] = $this->gss_model->get_where_result($broker_table,$where_associate); $data['projects'] = $this->gss_model->get_where_result($project_table,$where_project); $data['reference'] = $this->gss_model->get_where_result($broker_table,$where_reference); $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $this->load->view('admin/cancellation_list',$data); } else { redirect('/'); } } //Add brokers public function add_brokers() { $name_or_id = $this->input->post('name_or_id'); $type = $this->input->post('type'); if($type == 'Executives') { $basic_target = $this->input->post('basic_target'); $incentive_type = $this->input->post('incentive_type'); if($incentive_type == "incentive_in_percentage") { $incentive_percent = $this->input->post('incentive_in_percentage'); $incentive_rupees = ''; } else { $incentive_percent = ''; $incentive_rupees = $this->input->post('incentive_in_rs'); } $incentive_target_rs = ""; } else if($type == 'Logistic') { $basic_target = ""; $incentive_type = ""; $incentive_percent = ""; $incentive_rupees = ""; $incentive_target_rs = $this->input->post('incentive_target'); } else { $basic_target = ""; $incentive_type = ""; $incentive_percent = ""; $incentive_rupees = ""; $incentive_target_rs= ""; } $associate_name = $this->input->post('associate_name'); $email = $this->input->post('email'); $mobile = $this->input->post('mobile'); $mobile2 = $this->input->post('mobile2'); $address = $this->input->post('address'); $pan_number = $this->input->post('pan_number'); $adhar_number = $this->input->post('adhar_number'); $reference_details = $this->input->post('reference_details'); $this->load->library('image_lib'); if($_FILES) { if(empty($_FILES['scan_copy']['name'])) { $file_name = ""; } else { $target='broker_uploads/'; $target.=time().$_FILES['scan_copy']['name']; $file_name=time().$_FILES['scan_copy']['name']; $image=$target; $target1 = preg_replace('/\s+/', '_', $target); move_uploaded_file($_FILES['scan_copy']['tmp_name'],$target1); $config['source_image']=$target1; $config['maintain_ratio']=TRUE; $this->image_lib->initialize($config); $this->image_lib->resize(); } } if(!empty($file_name)) { $file_names = preg_replace('/\s+/', '_', $file_name); } else { $file_names = ""; } $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $created_at = $date->format('Y-m-d H:i:s'); $data = array( 'type' => $type, 'name_or_id' => $name_or_id, 'associate_name' => $associate_name, 'email' => $email, 'mobile' => $mobile, 'mobile2' => $mobile2, 'address' => $address, 'pan_number' => $pan_number, 'adhar_number' => $adhar_number, 'reference_details' => $reference_details, 'scan_copy' => $file_names, 'basic_target' => $basic_target, 'incentive_type' => $incentive_type, 'incentive_percent' => $incentive_percent, 'incentive_rupees' => $incentive_rupees, 'incentive_target_rs' => $incentive_target_rs, 'delete_status' => 'ACTIVE', 'created_at' => $created_at ); $table = 'gss_brokers'; $result = $this->gss_model->insert($table,$data); if($result) { echo json_encode(array('result'=>1,'message'=>"Broker details added successfully")); } else { echo json_encode(array('result'=>0,'message'=>"Something went wrong.. try again")); } } //Bokers list /* public function brokers_list() { $table = 'gss_brokers'; $order_by = "associate_name"; $where = array('delete_status' => 'ACTIVE',); $result = $this->gss_model->get_where_result_alphabetical_broker($table,$where,$order_by); if($result) { echo json_encode($result); } else { echo json_encode(array('result'=>0)); } }*/ //Bokers list public function brokers_list() { $type = $_GET['type']; $table = 'gss_brokers'; $order_by = "associate_name"; $where = array('type'=>$type,'delete_status' => 'ACTIVE',); $result = $this->gss_model->get_where_result_alphabetical_broker($table,$where,$order_by); if($result) { echo json_encode($result); } else { echo json_encode(array('result'=>0)); } } //Delete broker public function delete_broker() { $table = 'gss_brokers'; $broker_id = $this->input->post('broker_id'); $where = array('broker_id'=>$broker_id); $data = array('delete_status'=>'INACTIVE'); $result = $this->gss_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)); } } //Edit broker public function edit_broker() { $type = $_GET['type']; $table = 'gss_brokers'; $broker_id = $this->input->post('broker_id'); $where = array('type'=>$type,'broker_id'=>$broker_id,'delete_status'=>'ACTIVE'); $result = $this->gss_model->get_where_row($table,$where); if($result) { echo json_encode(array('broker_details'=>$result,'result'=>1)); } else { echo json_encode(array('result'=>0)); } } //Update broker /* public function update_broker() { $table = 'gss_brokers'; $broker_id = $this->input->post('broker_id'); $type = $this->input->post('type'); $name_or_id = $this->input->post('name_or_id'); $associate_name = $this->input->post('associate_name'); $address = $this->input->post('address'); $email = $this->input->post('email'); $mobile = $this->input->post('mobile'); $mobile2 = $this->input->post('mobile2'); $reference_details = $this->input->post('reference_details'); $pan_number = $this->input->post('pan_number'); $adhar_number = $this->input->post('adhar_number'); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $updated_at = $date->format('Y-m-d H:i:s'); $where_file = array('broker_id'=>$broker_id); $file_data = $this->gss_model->get_where_row($table,$where_file); $scan_copy = $file_data->scan_copy; if(empty($_FILES['scan_copy']['name'])) { $data = array( 'type' => $type, 'name_or_id' => $name_or_id, 'associate_name' => $associate_name, 'email' => $email, 'mobile' => $mobile, 'mobile2' => $mobile2, 'address' => $address, 'pan_number' => $pan_number, 'adhar_number' => $adhar_number, 'reference_details' => $reference_details, 'scan_copy' => $scan_copy, 'delete_status' => 'ACTIVE', 'updated_at' => $updated_at ); } else { $this->load->library('image_lib'); $target='broker_uploads/'; $target.=time().$_FILES['scan_copy']['name']; $file_name=time().$_FILES['scan_copy']['name']; $image=$target; move_uploaded_file($_FILES['scan_copy']['tmp_name'],$target); $config['source_image']=$target; $config['maintain_ratio']=TRUE; // $config['width']=200; // $config['height']=450; $this->image_lib->initialize($config); $this->image_lib->resize(); $data = array( 'type' => $type, 'name_or_id' => $name_or_id, 'associate_name' => $associate_name, 'email' => $email, 'mobile' => $mobile, 'mobile2' => $mobile2, 'address' => $address, 'pan_number' => $pan_number, 'adhar_number' => $adhar_number, 'reference_details' => $reference_details, 'scan_copy' => $file_name, 'delete_status' => 'ACTIVE', 'updated_at' => $updated_at ); } $where_mobile = $file_data->mobile; $where = array('delete_status'=>'ACTIVE','mobile !='=>$where_mobile,'mobile2 !='=>$where_mobile); $numbers = $this->gss_model->get_where_result($table,$where); $array = array(); foreach($numbers as $value) { $data['mobile']= $value->mobile; $data['mobile2']= $value->mobile2; array_push($array, $data); } if(in_array($mobile,$array)) { echo json_encode(array('result'=>2,'message'=>"Contact number already exists")); } else { $where_id = array('broker_id'=>$broker_id); $result = $this->gss_model->update($where_id,$table,$data); 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")); } } } */ //Update broker public function update_broker() { $type = $_GET['type']; if($type == 'Executives') { $basic_target = $this->input->post('basic_target'); $incentive_type = $this->input->post('incentive_type'); if($incentive_type == "incentive_in_percentage") { $incentive_percent = $this->input->post('incentive_in_percentage'); $incentive_rupees = ''; } else { $incentive_percent = ''; $incentive_rupees = $this->input->post('incentive_in_rs'); } $incentive_target_rs = ""; } else if($type == 'Logistic') { $basic_target = ""; $incentive_type = ""; $incentive_percent = ""; $incentive_rupees = ""; $incentive_target_rs = $this->input->post('incentive_target'); } else { $basic_target = ""; $incentive_type = ""; $incentive_percent = ""; $incentive_rupees = ""; $incentive_target_rs= ""; } $table = 'gss_brokers'; $broker_id = $this->input->post('broker_id'); //$type = $this->input->post('type'); $name_or_id = $this->input->post('name_or_id'); $associate_name = $this->input->post('associate_name'); $address = $this->input->post('address'); $email = $this->input->post('email'); $mobile = $this->input->post('mobile'); $mobile2 = $this->input->post('mobile2'); $reference_details = $this->input->post('reference_details'); $pan_number = $this->input->post('pan_number'); $adhar_number = $this->input->post('adhar_number'); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $updated_at = $date->format('Y-m-d H:i:s'); $where_file = array('type'=>$type,'broker_id'=>$broker_id); $file_data = $this->gss_model->get_where_row($table,$where_file); $scan_copy = $file_data->scan_copy; if(empty($_FILES['scan_copy']['name'])) { $data = array( 'type' => $type, 'name_or_id' => $name_or_id, 'associate_name' => $associate_name, 'email' => $email, 'mobile' => $mobile, 'mobile2' => $mobile2, 'address' => $address, 'pan_number' => $pan_number, 'adhar_number' => $adhar_number, 'reference_details' => $reference_details, 'scan_copy' => $scan_copy, 'basic_target' => $basic_target, 'incentive_type' => $incentive_type, 'incentive_percent' => $incentive_percent, 'incentive_rupees' => $incentive_rupees, 'incentive_target_rs' => $incentive_target_rs, 'delete_status' => 'ACTIVE', 'updated_at' => $updated_at ); } else { $this->load->library('image_lib'); $target='broker_uploads/'; $target.=time().$_FILES['scan_copy']['name']; $file_name=time().$_FILES['scan_copy']['name']; $image=$target; move_uploaded_file($_FILES['scan_copy']['tmp_name'],$target); $config['source_image']=$target; $config['maintain_ratio']=TRUE; // $config['width']=200; // $config['height']=450; $this->image_lib->initialize($config); $this->image_lib->resize(); $data = array( 'type' => $type, 'name_or_id' => $name_or_id, 'associate_name' => $associate_name, 'email' => $email, 'mobile' => $mobile, 'mobile2' => $mobile2, 'address' => $address, 'pan_number' => $pan_number, 'adhar_number' => $adhar_number, 'reference_details' => $reference_details, 'scan_copy' => $file_name, 'basic_target' => $basic_target, 'incentive_type' => $incentive_type, 'incentive_percent' => $incentive_percent, 'incentive_rupees' => $incentive_rupees, 'incentive_target_rs' => $incentive_target_rs, 'delete_status' => 'ACTIVE', 'updated_at' => $updated_at ); } $where_id = array('broker_id'=>$broker_id,'type'=>$type); $result = $this->gss_model->update($where_id,$table,$data); 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")); } } // New projects form public function project_form() { $admin_id = session()->get('admin_id'); if($admin_id) { $land_table = 'gss_land_owners'; $where = array('delete_status'=>'ACTIVE'); $order_by='name'; $data['owners'] = $this->gss_model->get_where_result_orderby_asc($land_table,$where,$order_by); //$data['owners'] = $this->gss_model->get_where_result($land_table,$where); $land_table1 = 'gss_login'; $where1 = array('delete_status'=>'ACTIVE','user_type_id'=>'5'); $order_by1='username'; $data['users'] = $this->gss_model->get_where_result_orderby_asc($land_table1,$where1,$order_by1); //$data['users'] = $this->gss_model->get_where_result($land_table1,$where1); //addd $owner_table ="gss_project_ownership"; $where = array('delete_status'=>'ACTIVE'); $data['project_owners'] = $this->gss_model->get_where_result($owner_table,$where); $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $table2 = "gss_project_master"; $where2 = array('delete_status'=>'ACTIVE'); $data['projects'] = $this->gss_model->get_where_result($table2,$where2); $this->load->view('admin/new_project_form',$data); } else { redirect('/'); } } // projects list form public function project_list() { $admin_id = session()->get('admin_id'); if($admin_id) { $land_table = 'gss_land_owners'; $where = array('delete_status'=>'ACTIVE'); $data['owners'] = $this->gss_model->get_where_result($land_table,$where); $owner_table = 'gss_project_ownership'; $where = array('delete_status'=>'ACTIVE'); $data['project_owner'] = $this->gss_model->get_where_result($owner_table,$where); $land_table1 = 'gss_login'; $where1 = array('delete_status'=>'ACTIVE','user_type_id'=>'5'); $data['users'] = $this->gss_model->get_where_result($land_table1,$where1); $project_table = "gss_new_projects"; $where2 = array('delete_status'=>'ACTIVE'); $data['projects'] = $this->gss_model->get_where_result($project_table,$where2); $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $table2 = "gss_project_master"; $where2 = array('delete_status'=>'ACTIVE'); $data['project_master'] = $this->gss_model->get_where_result($table2,$where2); $this->load->view('admin/projects_list',$data); } else { redirect('/'); } } /*public function add_project() { $project = $this->input->post('project_name'); $site_type = $this->input->post('site_type'); $land_owner = $this->input->post('land_owner'); $marketing = $this->input->post('marketing'); $handle = $this->input->post('handled_by'); $nick_name = $this->input->post('nick_name'); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $created_at = $date->format('Y-m-d'); $project_table = 'gss_new_projects'; $image_table = 'gss_nine_and_eleven_images'; $nine_and_eleven_image = ""; $release_order_image = ""; $conversion_order_image = ""; $this->load->library('image_lib'); if(empty($_FILES['approved_plan_image']['name'])) { $approved_plan_image = ""; } else { $target='project_uploads/'; $target.=time().$_FILES['approved_plan_image']['name']; $approved_plan_image=time().$_FILES['approved_plan_image']['name']; $image=$target; move_uploaded_file($_FILES['approved_plan_image']['tmp_name'],$target); $config['source_image']=$target; $config['maintain_ratio']=TRUE; $config['width']=900; $config['height']=900; $this->image_lib->initialize($config); $this->image_lib->resize(); } if($_FILES['conversion_order_image']['size'][0]!= 0) { for($i=0;$i< count($_FILES['conversion_order_image']['name']);$i++) { $target1='conversion_orders/'; $stamp = getdate(); $target1.=$stamp[0].basename($_FILES['conversion_order_image']['name'][$i]); $target2=$stamp[0].basename($_FILES['conversion_order_image']['name'][$i]); $url[]=$target2; move_uploaded_file($_FILES['conversion_order_image']['tmp_name'][$i],$target1); $config1['source_image']=$target1; $config1['maintain_ratio']=TRUE; $this->image_lib->initialize($config1); $this->image_lib->resize(); $this->image_lib->clear(); } } $where = array('delete_status'=>'ACTIVE'); $projects = $this->gss_model->get_where_result($project_table,$where); $array = array(); $check_project = $this->gss_model->check_project($project); if($check_project) { echo json_encode(array('result'=>2,'message'=>"Project already exists")); } else { $data = array( 'project_name' => $project, 'site_type' => $site_type, 'land_owner_id' => $land_owner, 'marketing' => $marketing, 'project_status' => 'ONGOING', 'conversion_image' => $conversion_order_image, 'approval_image' => $approved_plan_image, 'handled_by' =>$handle, 'nick_name' =>$nick_name, 'delete_status' => 'ACTIVE', 'created_at' => $created_at ); $result = $this->gss_model->insert($project_table,$data); if($result) { if(isset($url)) { foreach($url as $key=>$get_url) { $image_table = 'gss_project_conversion_orders'; $gallery_array = array( 'project_id' => $result, 'conversion_order' => $get_url, 'delete_status' => 'ACTIVE', 'created_at' => $created_at ); $gallery = $this->gss_model->insert($image_table,$gallery_array); } } if(isset($_FILES['excel_file']['name'])) { date_default_timezone_set('Asia/Kolkata'); include 'PHPExcel/IOFactory.php'; $file_name = $_FILES['excel_file']['name']; $ext = pathinfo($file_name, PATHINFO_EXTENSION); if($ext == "xlsx" || $ext == "xls") { $file_name = $_FILES['excel_file']['tmp_name']; $inputFileName = $file_name; try { $inputFileType = PHPExcel_IOFactory::identify($inputFileName); $objReader = PHPExcel_IOFactory::createReader($inputFileType); $objPHPExcel = $objReader->load($inputFileName); } catch (Exception $e) { die('Error loading file "' . pathinfo($inputFileName, PATHINFO_BASENAME) . '": ' . $e->getMessage()); } $sheet = $objPHPExcel->getSheet(0); $highestRow = $sheet->getHighestRow(); $highestColumn = $sheet->getHighestColumn(); $allDataInSheet = $objPHPExcel->getActiveSheet()->toArray(null,true,true,true); $arrayCount = count($allDataInSheet); // Here get total count of row in that Excel sheet $table = 'gss_new_sites'; //$this->gss_model->table_truncate($table); if(count($allDataInSheet)>0){ for($i = 2;$i <= $arrayCount;$i++){ $site_number = trim($allDataInSheet[$i]["A"]); $north_in_mtrs = trim($allDataInSheet[$i]["B"]); $north_in_mtrs = sprintf ("%.2f", $north_in_mtrs); $south_in_mtrs = trim($allDataInSheet[$i]["C"]); $south_in_mtrs = sprintf ("%.2f", $south_in_mtrs); $east_in_mtrs = trim($allDataInSheet[$i]["D"]); $east_in_mtrs = sprintf ("%.2f", $east_in_mtrs); $west_in_mtrs = trim($allDataInSheet[$i]["E"]); $west_in_mtrs = sprintf ("%.2f", $west_in_mtrs); $total_in_sqmtrs = trim($allDataInSheet[$i]["F"]); $total_in_sqmtrs = sprintf ("%.2f", $total_in_sqmtrs); $total_in_sqft = trim($allDataInSheet[$i]["G"]); $total_in_sqft = sprintf ("%.2f", $total_in_sqft); $east_facing = trim($allDataInSheet[$i]["H"]); $west_facing = trim($allDataInSheet[$i]["I"]); $north_facing = trim($allDataInSheet[$i]["J"]); $south_facing = trim($allDataInSheet[$i]["K"]); $status = trim($allDataInSheet[$i]["L"]); $data =array( 'project_id' => $result, 'site_number' => $site_number, 'north_in_mtrs' => $north_in_mtrs, 'south_in_mtrs' => $south_in_mtrs, 'east_in_mtrs' => $east_in_mtrs, 'west_in_mtrs' => $west_in_mtrs, 'total_in_sqmtrs' => $total_in_sqmtrs, 'total_in_sqft' => $total_in_sqft, 'east_facing' => $east_facing, 'west_facing' => $west_facing, 'north_facing' => $north_facing, 'south_facing' => $south_facing, 'status' => $status, 'delete_status' => 'ACTIVE', 'created_at ' => $created_at ); $this->gss_model->insert($table,$data); } } } echo json_encode(array('result'=>1,'message'=>"Project added successfully")); } else { echo json_encode(array('result'=>3,'message'=>"Please upload file with xlsx extension only")); } } else { echo json_encode(array('result'=>0,'message'=>"Something went wrong.. try again")); } } }*/ public function add_project() { $project = $this->input->post('project_name'); $site_type = $this->input->post('site_type'); $land_owner = $this->input->post('land_owner'); $marketing = $this->input->post('marketing'); $handle = $this->input->post('handled_by'); $nick_name = $this->input->post('nick_name'); $land_owner_address = $this->input->post('land_owner_address'); $project_ownership =$this->input->post('project_ownership'); $confirming_party_name =$this->input->post('confirming_party_name'); $per_sq_ft = $this->input->post('per_sq_ft'); $no_of_years = $this->input->post('no_of_years'); if(!empty($project_ownership)) { $p_name=$project_ownership; } else { $p_name=$confirming_party_name; } $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $created_at = $date->format('Y-m-d'); $project_table = 'gss_new_projects'; $image_table = 'gss_nine_and_eleven_images'; $nine_and_eleven_image = ""; $release_order_image = ""; $conversion_order_image = ""; $this->load->library('image_lib'); if(empty($_FILES['approved_plan_image']['name'])) { $approved_plan_image = ""; } else { $target='project_uploads/'; $target.=time().$_FILES['approved_plan_image']['name']; $approved_plan_image=time().$_FILES['approved_plan_image']['name']; $target1 = preg_replace('/\s+/', '_', $target); $image=$target1; move_uploaded_file($_FILES['approved_plan_image']['tmp_name'],$target1); $config['source_image']=$target1; $config['maintain_ratio']=TRUE; $config['width']=900; $config['height']=900; $this->image_lib->initialize($config); $this->image_lib->resize(); } if(!empty($approved_plan_image)) { $approved_plan_images = preg_replace('/\s+/', '_', $approved_plan_image); } else { $approved_plan_images = ""; } if($_FILES['conversion_order_image']['size'][0]!= 0) { for($i=0;$i< count($_FILES['conversion_order_image']['name']);$i++) { $target1='conversion_orders/'; $stamp = getdate(); $target1.=$stamp[0].basename($_FILES['conversion_order_image']['name'][$i]); $target2=$stamp[0].basename($_FILES['conversion_order_image']['name'][$i]); $target3 = preg_replace('/\s+/', '_', $target1); $url[]=$target2; move_uploaded_file($_FILES['conversion_order_image']['tmp_name'][$i],$target3); $config1['source_image']=$target3; $config1['maintain_ratio']=TRUE; $this->image_lib->initialize($config1); $this->image_lib->resize(); $this->image_lib->clear(); } } if(empty($_FILES['release_order_image']['name'])) { $release_order_image = ""; } else { $target='release_orders/'; $target.=time().$_FILES['release_order_image']['name']; $release_order_image=time().$_FILES['release_order_image']['name']; $image=$target; $target1 = preg_replace('/\s+/', '_', $target); move_uploaded_file($_FILES['release_order_image']['tmp_name'],$target1); $config['source_image']=$target1; $config['maintain_ratio']=TRUE; $config['width']=900; $config['height']=900; $this->image_lib->initialize($config); $this->image_lib->resize(); } if(!empty($release_order_image)) { $release_order_images = preg_replace('/\s+/', '_', $release_order_image); } else { $release_order_images = ""; } if(!empty($conversion_order_image)) { $conversion_order_images = preg_replace('/\s+/', '_', $conversion_order_image); } else { $conversion_order_images = ""; } $where = array('delete_status'=>'ACTIVE'); $projects = $this->gss_model->get_where_result($project_table,$where); $array = array(); $check_project = $this->gss_model->check_project($project); if($check_project) { echo json_encode(array('result'=>2,'message'=>"Project already exists")); } else { $data = array( 'project_name' => $project, 'site_type' => $site_type, 'land_owner_id' => $land_owner, 'land_owner_address'=> $land_owner_address, 'marketing' => $marketing, 'project_ownership'=>$p_name, 'project_status' => 'ONGOING', 'conversion_image' => $conversion_order_images, 'approval_image' => $approved_plan_images, 'release_image' => $release_order_images, 'handled_by' =>$handle, 'nick_name' =>$nick_name, 'no_of_years' =>$no_of_years, 'maintenance_per_sqft' =>$per_sq_ft, 'delete_status' => 'ACTIVE', 'created_at' => $created_at ); $result = $this->gss_model->insert($project_table,$data); if($result) { if(isset($url)) { foreach($url as $key=>$get_url) { $image_table = 'gss_project_conversion_orders'; $gallery_array = array( 'project_id' => $result, 'conversion_order' => $get_url, 'delete_status' => 'ACTIVE', 'created_at' => $created_at ); $gallery = $this->gss_model->insert($image_table,$gallery_array); } } if(isset($_FILES['excel_file']['name'])) { date_default_timezone_set('Asia/Kolkata'); include 'PHPExcel/IOFactory.php'; $file_name = $_FILES['excel_file']['name']; $ext = pathinfo($file_name, PATHINFO_EXTENSION); if($ext == "xlsx" || $ext == "xls") { $file_name = $_FILES['excel_file']['tmp_name']; $inputFileName = $file_name; try { $inputFileType = PHPExcel_IOFactory::identify($inputFileName); $objReader = PHPExcel_IOFactory::createReader($inputFileType); $objPHPExcel = $objReader->load($inputFileName); } catch (Exception $e) { die('Error loading file "' . pathinfo($inputFileName, PATHINFO_BASENAME) . '": ' . $e->getMessage()); } $sheet = $objPHPExcel->getSheet(0); $highestRow = $sheet->getHighestRow(); $highestColumn = $sheet->getHighestColumn(); $allDataInSheet = $objPHPExcel->getActiveSheet()->toArray(null,true,true,true); $arrayCount = count($allDataInSheet); // Here get total count of row in that Excel sheet $table = 'gss_new_sites'; //$this->gss_model->table_truncate($table); if(count($allDataInSheet)>0){ for($i = 2;$i <= $arrayCount;$i++){ $site_number = trim($allDataInSheet[$i]["A"]); $north_in_mtrs = trim($allDataInSheet[$i]["B"]); $north_in_mtrs = sprintf ("%.2f", $north_in_mtrs); $south_in_mtrs = trim($allDataInSheet[$i]["C"]); $south_in_mtrs = sprintf ("%.2f", $south_in_mtrs); $east_in_mtrs = trim($allDataInSheet[$i]["D"]); $east_in_mtrs = sprintf ("%.2f", $east_in_mtrs); $west_in_mtrs = trim($allDataInSheet[$i]["E"]); $west_in_mtrs = sprintf ("%.2f", $west_in_mtrs); $total_in_sqmtrs = trim($allDataInSheet[$i]["F"]); $total_in_sqmtrs = sprintf ("%.2f", $total_in_sqmtrs); $total_in_sqft = trim($allDataInSheet[$i]["G"]); $total_in_sqft = sprintf ("%.2f", $total_in_sqft); $east_facing = trim($allDataInSheet[$i]["H"]); $west_facing = trim($allDataInSheet[$i]["I"]); $north_facing = trim($allDataInSheet[$i]["J"]); $south_facing = trim($allDataInSheet[$i]["K"]); $status = trim($allDataInSheet[$i]["L"]); $data =array( 'project_id' => $result, 'site_number' => $site_number, 'north_in_mtrs' => $north_in_mtrs, 'south_in_mtrs' => $south_in_mtrs, 'east_in_mtrs' => $east_in_mtrs, 'west_in_mtrs' => $west_in_mtrs, 'total_in_sqmtrs' => $total_in_sqmtrs, 'total_in_sqft' => $total_in_sqft, 'east_facing' => $east_facing, 'west_facing' => $west_facing, 'north_facing' => $north_facing, 'south_facing' => $south_facing, 'status' => $status, 'delete_status' => 'ACTIVE', 'created_at ' => $created_at ); $this->gss_model->insert($table,$data); } } } echo json_encode(array('result'=>1,'message'=>"Project added successfully")); } else { echo json_encode(array('result'=>3,'message'=>"Please upload file with xlsx extension only")); } } else { echo json_encode(array('result'=>0,'message'=>"Something went wrong.. try again")); } } } //Projects list public function projects_list() { $table = 'gss_projects'; $result = $this->gss_model->projects_list(); if($result) { echo json_encode(array('projects_list'=>$result,'result'=>1)); } else { echo json_encode(array('result'=>0)); } } //Delete new project public function delete_new_project() { $project_table = 'gss_new_projects'; $sites_table = 'gss_new_sites'; $image_table = 'gss_nine_and_eleven_images'; $project_id = $this->input->post('project_id'); $where = array('project_id'=>$project_id); $data = array('delete_status'=>'INACTIVE'); $result2 = $this->gss_model->update($where,$sites_table,$data); $result4 = $this->gss_model->update($where,$image_table,$data); $result3 = $this->gss_model->update($where,$project_table,$data); if($this->db->affected_rows() > 0) { echo json_encode(array('result'=>1,'message'=>'Deleted successfully')); } else { echo json_encode(array('result'=>0)); } } //New project details public function project_details() { $admin_id = session()->get('admin_id'); if($admin_id) { $project_table = 'gss_new_projects'; $sites_table = 'gss_new_sites'; $image_table = 'gss_nine_and_eleven_images'; $conversin_orders = 'gss_project_conversion_orders'; $project_id = $this->uri->segment(2); $where = array('delete_status'=>'ACTIVE','project_id'=>$project_id); $data['project_id'] = $project_id; $table = 'gss_new_projects'; $where = array('project_id'=>$project_id); $get_land_owner_id = $this->gss_model->get_where_row($table, $where); $land_owner_id = $get_land_owner_id->land_owner_id; $tables = 'gss_land_owners'; $wheres = array('owner_id'=>$land_owner_id); $data['land_owner'] = $this->gss_model->get_where_row($tables, $wheres); $condition=array('delete_status'=>'ACTIVE'); $data['project'] = $this->gss_model->get_where_result($project_table,$condition); $data['mappings'] = $this->gss_model->get_where_result_mapping_sketch(); $table1 = 'gss_mapping_sketch'; $where1 = array('project_id'=>$project_id ); $data['sketch'] = $this->gss_model->get_where_row($table1,$where1); $where_data = array('project_id'=>$project_id,'delete_status'=>'ACTIVE'); $table_site='gss_new_sites'; $data['site']=$this->gss_model->get_where_result($table_site,$where_data); $table_mapping='gss_mapping'; $data['site_id']=$this->gss_model->get_where_result($table_mapping,$where_data); ////////////// $data['project'] = $this->gss_model->get_where_row($project_table,$where); $data['count'] = $this->gss_model->get_where_result($sites_table,$where); $data['orders'] = $this->gss_model->get_where_result($conversin_orders,$where); $where = array('delete_status'=>'ACTIVE','project_id'=>$project_id); $data['release_orders'] = $this->gss_model->get_where_result($project_table,$where); $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $this->load->view('admin/project_details',$data); } else { redirect('/'); } } //Sites type list of single project public function sites_type_list() { $table = 'gss_site_type'; $project_id = $this->input->post('project_id'); $order_by = "site_type_id"; $where = array( 'delete_status' => 'ACTIVE', 'project_id' => $project_id ); $result = $this->gss_model->get_where_result_orderby($table,$where,$order_by); if($result) { echo json_encode(array('result'=>1,'sites_list'=>$result)); } else { echo json_encode(array('result'=>0)); } } //Sites list public function sites_list() { $table = 'gss_site_description'; $site_type_id = $this->input->post('site_type_id'); $order_by = "site_type_id"; $where = array( 'delete_status' => 'ACTIVE', 'site_type_id' => $site_type_id ); $result = $this->gss_model->get_where_result_orderby($table,$where,$order_by); if($result) { echo json_encode(array('result'=>1,'sites_list'=>$result)); } else { echo json_encode(array('result'=>0)); } } // New sites list public function new_sites_list() { $table = 'gss_new_sites'; $project_id = $_GET['project_id']; //echo $project_id; $order_by = "site_number"; $where = array( 'delete_status' => 'ACTIVE', 'project_id' => $project_id ); $result = $this->gss_model->get_where_result_orderby_asc($table,$where,$order_by); if($result) { $data = array(); foreach($result as $row) { $data[] = $row; } echo json_encode($data); } else { echo json_encode(array('result'=>0)); } } //Delete site type public function delete_site() { $table = 'gss_site_type'; $site_type_id = $this->input->post('site_type_id'); $where = array('site_type_id'=>$site_type_id); $data = array('delete_status'=>'INACTIVE'); $result = $this->gss_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)); } } //Delete new site public function delete_new_site() { $table = 'gss_new_sites'; $site_id = $this->input->post('site_id'); $where = array('site_id'=>$site_id); $data = array('delete_status'=>'INACTIVE'); $result = $this->gss_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)); } } //new site details public function new_site_details() { $admin_id = session()->get('admin_id'); if($admin_id) { $booking_table = 'gss_bookings'; $detail_table = 'gss_booking_details'; $site_table = 'gss_new_sites'; $project_id = $this->uri->segment(2); $site_number = $this->uri->segment(3); $data['site_number']= $site_number; $data['project'] = $this->gss_model->project_details($site_number,$project_id); $project_result = $this->gss_model->project_details($site_number,$project_id); if($project_result) { $where_site = array( 'delete_status' => 'ACTIVE', 'project_id' => $project_result->project_id, 'site_number' => $site_number ); $check_site = $this->gss_model->test($project_result->project_id,$site_number); if($check_site) { //$data['booked'] = "Booked"; $where_booking = array( 'delete_status' => 'ACTIVE', 'booking_id' => $check_site->booking_id, ); $site_result = $this->gss_model->get_where_row($booking_table,$where_booking); if($site_result) { $data['booking_status'] = $site_result->booking_status; } } } $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $this->load->view('admin/new_site_details',$data); } else { redirect('/'); } } //Get project id public function get_project_id() { $table = 'gss_new_sites'; $site_number = $this->input->post('site_number'); $where = array('site_number' => $site_number ,'delete_status' => 'ACTIVE'); $result = $this->gss_model->get_where_row($table,$where); if($result) { echo json_encode(array('result'=>1,'project_id'=>$result->project_id)); } else { echo json_encode(array('result'=>0)); } } //Single project sites public function single_project_sites() { $table = 'gss_new_sites'; $project_id = $this->input->post('project_id'); $where = array('project_id' => $project_id); $order_by = 'site_number'; $result = $this->gss_model->single_project_sites($table,$where,$order_by); //print_r($result);die(); if($result) { echo json_encode(array('result'=>1,'sites'=>$result)); } else { echo json_encode(array('result'=>0)); } } public function get_maintenance_sites() { //$table = 'gss_new_sites'; $project_id = $this->input->post('project_id'); $where = array('project_id' => $project_id); $order_by = 'site_number'; $result = $this->gss_model->get_registerd_sites_maintenance($project_id); //print_r($result);die(); if($result) { echo json_encode(array('result'=>1,'sites'=>$result)); } else { echo json_encode(array('result'=>0)); } } //Delete site public function delete_single_site() { $desc_table = 'gss_site_description'; $site_type_table = 'gss_site_type'; $site_id = $this->input->post('site_id'); $site_type_id = $this->input->post('site_type_id'); $where_type = array('site_type_id'=>$site_type_id); $type_result = $this->gss_model->get_where_row($site_type_table,$where_type); $no_of_sites = $type_result->no_of_sites - 1; $count_data = array('no_of_sites'=>$no_of_sites); $update_count = $this->gss_model->update($where_type,$site_type_table,$count_data); if($this->db->affected_rows() > 0) { $where = array('site_id'=>$site_id); $data = array('delete_status'=>'INACTIVE'); $result = $this->gss_model->update($where,$desc_table,$data); if($this->db->affected_rows() > 0) { echo json_encode(array('result'=>1,'message'=>'Deleted successfully')); } else { echo json_encode(array('result'=>0)); } } } //Add site description public function add_site_description() { $site_id = $this->input->post('site_id'); $site_number = $this->input->post('site_number'); $comment = $this->input->post('comment'); $facing = $this->input->post('facing'); $description = $this->input->post('description'); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $updated_at = $date->format('Y-m-d H:i:s'); $data = array( 'site_number' => $site_number, 'facing' => $facing, 'comment' => $comment, 'description' => $description, 'delete_status' => 'ACTIVE', 'updated_at' => $updated_at ); $where = array('site_id'=>$site_id); $table = 'gss_site_description'; $result = $this->gss_model->update($where,$table,$data); if($this->db->affected_rows() > 0) { echo json_encode(array('result'=>1,'message'=>"Description added successfully")); } else { echo json_encode(array('result'=>0,'message'=>"Something went wrong.. try again")); } } //Update site description public function update_site_description() { $site_id = $this->input->post('site_id'); $site_number = $this->input->post('site_number'); $comment = $this->input->post('comment'); $facing = $this->input->post('facing'); $description = $this->input->post('description'); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $updated_at = $date->format('Y-m-d H:i:s'); $data = array( 'site_number' => $site_number, 'facing' => $facing, 'comment' => $comment, 'description' => $description, 'delete_status' => 'ACTIVE', 'updated_at' => $updated_at ); $where = array('site_id'=>$site_id); $table = 'gss_site_description'; $result = $this->gss_model->update($where,$table,$data); if($this->db->affected_rows() > 0) { echo json_encode(array('result'=>1,'message'=>"Description updated successfully")); } else { echo json_encode(array('result'=>0,'message'=>"Something went wrong.. try again")); } } //Land developer form public function land_developers() { $admin_id = session()->get('admin_id'); if($admin_id) { $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $this->load->view('admin/land_developer_form',$data); } else { redirect('/'); } } //Add land developers public function add_land_developers() { $name = $this->input->post('name'); $email = $this->input->post('email'); $mobile = $this->input->post('mobile'); $address = $this->input->post('address'); $pan_or_adhar = $this->input->post('pan_or_adhar'); $this->load->library('image_lib'); $file_name = ""; if($_FILES) { if(empty($_FILES['id_proof_image']['name'])) { $file_name = ""; } else { $target='land_developers_images/'; $target.=time().$_FILES['id_proof_image']['name']; $file_name=time().$_FILES['id_proof_image']['name']; $image=$target; move_uploaded_file($_FILES['id_proof_image']['tmp_name'],$target); $config['source_image']=$target; $config['maintain_ratio']=TRUE; $config['width']=200; $config['height']=150; $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( 'name' => $name, 'email' => $email, 'mobile' => $mobile, 'address' => $address, 'pan_or_adhar_number' => $pan_or_adhar, 'id_proof_image' => $file_name, 'delete_status' => 'ACTIVE', 'created_at' => $created_at ); $developer_table = 'gss_land_developers'; $where = array('delete_status'=>'ACTIVE'); $numbers = $this->gss_model->get_where_result($developer_table,$where); $array = array(); foreach($numbers as $value) { array_push($array, $value->mobile); } if(in_array($mobile,$array)) { echo json_encode(array('result'=>2,'message'=>"Contact number already exists")); } else { $result = $this->gss_model->insert($developer_table,$data); if($result) { echo json_encode(array('result'=>1,'message'=>"Land developer details added successfully")); } else { echo json_encode(array('result'=>0,'message'=>"Something went wrong.. try again")); } } } //Land developers list public function land_developers_list() { $table = 'gss_land_developers'; $where = array('delete_status'=>'ACTIVE'); $order_by = "developer_id"; $result = $this->gss_model->get_where_result_orderby($table,$where,$order_by); if($result) { echo json_encode(array('result'=>1,'land_developers_list'=>$result)); } else { echo json_encode(array('result'=>0)); } } //Delete land developer public function delete_land_developer() { $table = 'gss_land_developers'; $developer_id = $this->input->post('developer_id'); $where = array('developer_id'=>$developer_id); $data = array('delete_status'=>'INACTIVE'); $result = $this->gss_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)); } } //Edit land developer public function edit_land_developer() { $table = 'gss_land_developers'; $developer_id = $this->input->post('developer_id'); $where = array('developer_id'=>$developer_id,'delete_status'=>'ACTIVE'); $result = $this->gss_model->get_where_row($table,$where); if($result) { echo json_encode(array('land_developer_details'=>$result,'result'=>1)); } else { echo json_encode(array('result'=>0)); } } //Update land developer public function update_land_developer() { $table = 'gss_land_developers'; $developer_id = $this->input->post('developer_id'); $name = $this->input->post('name'); $email = $this->input->post('email'); $mobile = $this->input->post('mobile'); $address = $this->input->post('address'); $pan_or_adhar = $this->input->post('pan_or_adhar'); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $updated_at = $date->format('Y-m-d H:i:s'); $where_file = array('developer_id'=>$developer_id); $file_data = $this->gss_model->get_where_row($table,$where_file); $id_proof = $file_data->id_proof_image; if(empty($_FILES['id_proof_image']['name'])) { $data = array( 'name' => $name, 'email' => $email, 'mobile' => $mobile, 'address' => $address, 'pan_or_adhar_number' => $pan_or_adhar, 'id_proof_image' => $id_proof, 'delete_status' => 'ACTIVE', 'updated_at' => $updated_at ); } else { $this->load->library('image_lib'); $target='land_developers_images/'; $target.=time().$_FILES['id_proof_image']['name']; $file_name=time().$_FILES['id_proof_image']['name']; $image=$target; move_uploaded_file($_FILES['id_proof_image']['tmp_name'],$target); $config['source_image']=$target; $config['maintain_ratio']=TRUE; $config['width']=200; $config['height']=450; $this->image_lib->initialize($config); $this->image_lib->resize(); $data = array( 'name' => $name, 'email' => $email, 'mobile' => $mobile, 'address' => $address, 'pan_or_adhar_number' => $pan_or_adhar, 'id_proof_image' => $file_name, 'delete_status' => 'ACTIVE', 'updated_at' => $updated_at ); } $where_mobile = $file_data->mobile; $where = array('delete_status'=>'ACTIVE','mobile !='=>$where_mobile); $numbers = $this->gss_model->get_where_result($table,$where); $array = array(); foreach($numbers as $value) { array_push($array, $value->mobile); } if(in_array($mobile,$array)) { echo json_encode(array('result'=>2,'message'=>"Contact number already exists")); } else { $where_id = array('developer_id'=>$developer_id); $result = $this->gss_model->update($where_id,$table,$data); 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 portal public function add_webportals() { $webportal = $this->input->post('webportal'); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $created_at = $date->format('Y-m-d H:i:s'); $table = 'gss_webportals'; $data = array( 'webportal' => ucfirst($webportal), 'delete_status' => 'ACTIVE', 'created_at' => $created_at ); $portals = $this->gss_model->chek_portal_exists($webportal); if($portals) { echo json_encode(array('result'=>2,'message'=>"Webportal already exists")); } else { $result = $this->gss_model->insert($table,$data); if($result) { echo json_encode(array('result'=>1,'message'=>"Webportals added successfully")); } else { echo json_encode(array('result'=>0,'message'=>"Something went wrong.. try again")); } } } public function add_database() { $webportal = $this->input->post('database'); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $created_at = $date->format('Y-m-d H:i:s'); $table = 'gss_database'; $data = array( 'database_name' => ucfirst($webportal), 'delete_status' => 'ACTIVE', 'created_at' => $created_at ); //print_r($data); $portals = $this->gss_model->chek_database_exists($webportal); if($portals) { echo json_encode(array('result'=>2,'message'=>"Database already exists")); } else { $result = $this->gss_model->insert($table,$data); if($result) { echo json_encode(array('result'=>1,'message'=>"Database added successfully")); } else { echo json_encode(array('result'=>0,'message'=>"Something went wrong.. try again")); } } } //Web portal form public function web_portals() { $admin_id = session()->get('admin_id'); if($admin_id) { $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $this->load->view('admin/webportal_form',$data); } else { redirect('/'); } } //Web portal list public function web_portal_list() { $table = 'gss_webportals'; $where = array('delete_status'=>'ACTIVE'); $order_by = 'webportal'; $result = $this->gss_model->get_where_result_alphabetical($table,$where,$order_by); if($result) { echo json_encode($result); } else { echo json_encode(array('result'=>0)); } } public function database_list() { $table = 'gss_database'; $where = array('delete_status'=>'ACTIVE'); $order_by = 'database_name'; $result = $this->gss_model->get_where_result_alphabetical($table,$where,$order_by); if($result) { echo json_encode($result); } else { echo json_encode(array('result'=>0)); } } //Delete portal public function delete_portal() { $table = 'gss_webportals'; $portal_id = $this->input->post('portal_id'); $where = array('portal_id'=>$portal_id); $data = array('delete_status'=>'INACTIVE'); $result = $this->gss_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)); } } //Update webportal public function update_webportal() { $portal_id = $this->input->post('portal_id'); $webportal = $this->input->post('webportal'); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $updated_at = $date->format('Y-m-d H:i:s'); $table = 'gss_webportals'; $where = array('portal_id'=>$portal_id); $data = array( 'webportal' => $webportal, 'updated_at' => $updated_at ); $result = $this->gss_model->update($where,$table,$data); 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_database() { $table = 'gss_database'; $portal_id = $this->input->post('database_id'); $where = array('database_id'=>$portal_id); $data = array('delete_status'=>'INACTIVE'); $result = $this->gss_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)); } } //Update webportal public function update_database() { $portal_id = $this->input->post('database_id'); $webportal = $this->input->post('database'); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $updated_at = $date->format('Y-m-d H:i:s'); $table = 'gss_database'; $where = array('database_id'=>$portal_id); $data = array( 'database_name' => $webportal, 'update_at' => $updated_at ); $result = $this->gss_model->update($where,$table,$data); 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")); } } //New Projects list public function new_projects_list() { $table = 'gss_new_projects'; $result = $this->gss_model->new_projects_list(); if($result) { echo json_encode($result); } else { echo json_encode(array('result'=>0)); } } //Edit new project public function edit_new_project() { $table = 'gss_new_projects'; $project_id = $this->input->post('project_id'); $where = array('project_id'=>$project_id,'delete_status'=>'ACTIVE'); $result = $this->gss_model->edit_new_project($project_id); if($result) { echo json_encode(array('project_details'=>$result,'result'=>1)); } else { echo json_encode(array('result'=>0)); } } //Update project /*public function update_new_project() { $this->load->library('image_lib'); $table = 'gss_new_projects'; $project_id = $this->input->post('project_id'); $project_name = $this->input->post('project_name'); $project_type = $this->input->post('project_type'); $land_owner = $this->input->post('land_owner'); $marketing = $this->input->post('marketing'); $handled_by = $this->input->post('handled_by'); $nick_name = $this->input->post('nick_name'); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $updated_at = $date->format('Y-m-d H:i:s'); $where_file = array('project_id'=>$project_id); $file_data = $this->gss_model->get_where_row($table,$where_file); $release_order_image = $file_data->release_image; $conversion_order_image = $file_data->conversion_image; $approved_plan_image = $file_data->approval_image; if(empty($_FILES['approved_plan_image']['name'])) { $approved_plan_image = $approved_plan_image; } else { $target='project_uploads/'; $target.=time().$_FILES['approved_plan_image']['name']; $approved_plan_image=time().$_FILES['approved_plan_image']['name']; $image=$target; move_uploaded_file($_FILES['approved_plan_image']['tmp_name'],$target); $config['source_image']=$target; $config['maintain_ratio']=TRUE; $config['width']=900; $config['height']=900; $this->image_lib->initialize($config); $this->image_lib->resize(); } if($_FILES['conversion_order_image']['size'][0]!= 0) { for($i=0;$i< count($_FILES['conversion_order_image']['name']);$i++) { $target1='conversion_orders/'; $stamp = getdate(); $target1.=$stamp[0].basename($_FILES['conversion_order_image']['name'][$i]); $target2=$stamp[0].basename($_FILES['conversion_order_image']['name'][$i]); $url[]=$target2; move_uploaded_file($_FILES['conversion_order_image']['tmp_name'][$i],$target1); $config1['source_image']=$target1; $config1['maintain_ratio']=TRUE; $this->image_lib->initialize($config1); $this->image_lib->resize(); $this->image_lib->clear(); } } $data = array( 'project_name' => $project_name, 'nick_name' => $nick_name, 'site_type' => $project_type, 'land_owner_id' => $land_owner, 'marketing' => $marketing, 'project_status' => 'ONGOING', 'conversion_image' => $conversion_order_image, 'release_image' => $release_order_image, 'approval_image' => $approved_plan_image, 'handled_by' => $handled_by, 'delete_status' => 'ACTIVE', 'updated_at' => $updated_at ); $where_project = $file_data->project_name; $where = array('delete_status'=>'ACTIVE','project_name !='=>$where_project); $numbers = $this->gss_model->get_where_result($table,$where); $array = array(); foreach($numbers as $value) { array_push($array, $value->project_name); } if(in_array($project_name,$array)) { echo json_encode(array('result'=>2,'message'=>"Project already exists")); } else { $where_id = array('project_id'=>$project_id); if(empty($_FILES['excel_file']['name'])) { } else { date_default_timezone_set('Asia/Kolkata'); include 'PHPExcel/IOFactory.php'; $file_name = $_FILES['excel_file']['name']; $ext = pathinfo($file_name, PATHINFO_EXTENSION); if($ext == "xlsx" || $ext == "xls") { $file_name = $_FILES['excel_file']['tmp_name']; $inputFileName = $file_name; try { $inputFileType = PHPExcel_IOFactory::identify($inputFileName); $objReader = PHPExcel_IOFactory::createReader($inputFileType); $objPHPExcel = $objReader->load($inputFileName); } catch (Exception $e) { die('Error loading file "' . pathinfo($inputFileName, PATHINFO_BASENAME) . '": ' . $e->getMessage()); } $sheet = $objPHPExcel->getSheet(0); $highestRow = $sheet->getHighestRow(); $highestColumn = $sheet->getHighestColumn(); $allDataInSheet = $objPHPExcel->getActiveSheet()->toArray(null,true,true,true); $arrayCount = count($allDataInSheet); // Here get total count of row in that Excel sheet $site_table = 'gss_new_sites'; //$this->gss_model->table_truncate($table); if(count($allDataInSheet)>0){ $this->gss_model->delete($site_table,$where_id); for($i = 2;$i <= $arrayCount;$i++){ //echo $allDataInSheet[$i]["A"]; $site_number = trim($allDataInSheet[$i]["A"]); $north_in_mtrs = trim($allDataInSheet[$i]["B"]); $north_in_mtrs = sprintf ("%.2f", $north_in_mtrs); $south_in_mtrs = trim($allDataInSheet[$i]["C"]); $south_in_mtrs = sprintf ("%.2f", $south_in_mtrs); $east_in_mtrs = trim($allDataInSheet[$i]["D"]); $east_in_mtrs = sprintf ("%.2f", $east_in_mtrs); $west_in_mtrs = trim($allDataInSheet[$i]["E"]); $west_in_mtrs = sprintf ("%.2f", $west_in_mtrs); $total_in_sqmtrs = trim($allDataInSheet[$i]["F"]); $total_in_sqmtrs = sprintf ("%.2f", $total_in_sqmtrs); $total_in_sqft = trim($allDataInSheet[$i]["G"]); $total_in_sqft = sprintf ("%.2f", $total_in_sqft); $east_facing = trim($allDataInSheet[$i]["H"]); $west_facing = trim($allDataInSheet[$i]["I"]); $north_facing = trim($allDataInSheet[$i]["J"]); $south_facing = trim($allDataInSheet[$i]["K"]); $status = trim($allDataInSheet[$i]["L"]); $site_data =array( 'project_id' => $project_id, 'site_number' => $site_number, 'north_in_mtrs' => $north_in_mtrs, 'south_in_mtrs' => $south_in_mtrs, 'east_in_mtrs' => $east_in_mtrs, 'west_in_mtrs' => $west_in_mtrs, 'total_in_sqmtrs' => $total_in_sqmtrs, 'total_in_sqft' => $total_in_sqft, 'east_facing' => $east_facing, 'west_facing' => $west_facing, 'north_facing' => $north_facing, 'south_facing' => $south_facing, 'status' => $status, 'delete_status' => 'ACTIVE', 'updated_at ' => $updated_at ); $this->gss_model->insert($site_table,$site_data); } } } } if(isset($url)) { $image_table = 'gss_project_conversion_orders'; $delete_images = $this->gss_model->delete($image_table,$where_file); foreach($url as $key=>$get_url) { $gallery_array = array( 'project_id' => $project_id, 'conversion_order' => $get_url, 'delete_status' => 'ACTIVE', 'created_at' => $updated_at ); $gallery = $this->gss_model->insert($image_table,$gallery_array); } } $result = $this->gss_model->update($where_id,$table,$data); 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 update_new_project() { $this->load->library('image_lib'); $table = 'gss_new_projects'; $project_id = $this->input->post('project_id'); $project_name = $this->input->post('project_name'); $project_type = $this->input->post('project_type'); $land_owner = $this->input->post('land_owner'); $marketing = $this->input->post('marketing'); $project_ownership =$this->input->post('project_ownership'); $confirming_party_name =$this->input->post('confirming_party_name'); $no_of_years = $this->input->post('no_of_years'); $per_sq_ft = $this->input->post('per_sq_ft'); $handled_by = $this->input->post('handled_by'); $nick_name = $this->input->post('nick_name'); $land_owner_address = $this->input->post('land_owner_address'); if($marketing=='Confirming Party') { $p_name=$confirming_party_name; } else { $p_name=$project_ownership; } $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $updated_at = $date->format('Y-m-d H:i:s'); $where_file = array('project_id'=>$project_id); $file_data = $this->gss_model->get_where_row($table,$where_file); $release_order_image = $file_data->release_image; $conversion_order_image = $file_data->conversion_image; $approved_plan_image = $file_data->approval_image; if(empty($_FILES['approved_plan_image']['name'])) { $approved_plan_image = $approved_plan_image; } else { $target='project_uploads/'; $target.=time().$_FILES['approved_plan_image']['name']; $approved_plan_image=time().$_FILES['approved_plan_image']['name']; $image=$target; $target1 = preg_replace('/\s+/', '_', $target); move_uploaded_file($_FILES['approved_plan_image']['tmp_name'],$target1); $config['source_image']=$target1; $config['maintain_ratio']=TRUE; $config['width']=900; $config['height']=900; $this->image_lib->initialize($config); $this->image_lib->resize(); } if(!empty($approved_plan_image)) { $approved_plan_images = preg_replace('/\s+/', '_', $approved_plan_image); } else { $approved_plan_images = ""; } if($_FILES['conversion_order_image']['size'][0]!= 0) { for($i=0;$i< count($_FILES['conversion_order_image']['name']);$i++) { $target1='conversion_orders/'; $stamp = getdate(); $target1.=$stamp[0].basename($_FILES['conversion_order_image']['name'][$i]); $target2=$stamp[0].basename($_FILES['conversion_order_image']['name'][$i]); $url[]=$target2; $target3 = preg_replace('/\s+/', '_', $target2); move_uploaded_file($_FILES['conversion_order_image']['tmp_name'][$i],$target3); $config1['source_image']=$target3; $config1['maintain_ratio']=TRUE; $this->image_lib->initialize($config1); $this->image_lib->resize(); $this->image_lib->clear(); } } if(empty($_FILES['release_order_image']['name'])) { $release_order_image = $release_order_image; } else { $target='release_orders/'; $target.=time().$_FILES['release_order_image']['name']; $release_order_image=time().$_FILES['release_order_image']['name']; $image=$target; $target1 = preg_replace('/\s+/', '_', $target); move_uploaded_file($_FILES['release_order_image']['tmp_name'],$target1); $config['source_image']=$target1; $config['maintain_ratio']=TRUE; $config['width']=900; $config['height']=900; $this->image_lib->initialize($config); $this->image_lib->resize(); } if(!empty($release_order_image)) { $release_order_images = preg_replace('/\s+/', '_', $release_order_image); } else { $release_order_images = ""; } $data = array( 'project_name' => $project_name, 'nick_name' => $nick_name, 'site_type' => $project_type, 'land_owner_id' => $land_owner, 'land_owner_address' => $land_owner_address, 'marketing' => $marketing, 'project_ownership' =>$p_name, 'no_of_years' =>$no_of_years, 'maintenance_per_sqft' =>$per_sq_ft, 'project_status' => 'ONGOING', 'conversion_image' => $conversion_order_image, 'release_image' => $release_order_images, 'approval_image' => $approved_plan_images, 'handled_by' => $handled_by, 'delete_status' => 'ACTIVE', 'updated_at' => $updated_at ); $where_project = $file_data->project_name; $where = array('delete_status'=>'ACTIVE','project_name !='=>$where_project); $numbers = $this->gss_model->get_where_result($table,$where); $array = array(); foreach($numbers as $value) { array_push($array, $value->project_name); } if(in_array($project_name,$array)) { echo json_encode(array('result'=>2,'message'=>"Project already exists")); } else { $where_id = array('project_id'=>$project_id); if(empty($_FILES['excel_file']['name'])) { } else { date_default_timezone_set('Asia/Kolkata'); include 'PHPExcel/IOFactory.php'; $file_name = $_FILES['excel_file']['name']; $ext = pathinfo($file_name, PATHINFO_EXTENSION); if($ext == "xlsx" || $ext == "xls") { $file_name = $_FILES['excel_file']['tmp_name']; $inputFileName = $file_name; try { $inputFileType = PHPExcel_IOFactory::identify($inputFileName); $objReader = PHPExcel_IOFactory::createReader($inputFileType); $objPHPExcel = $objReader->load($inputFileName); } catch (Exception $e) { die('Error loading file "' . pathinfo($inputFileName, PATHINFO_BASENAME) . '": ' . $e->getMessage()); } $sheet = $objPHPExcel->getSheet(0); $highestRow = $sheet->getHighestRow(); $highestColumn = $sheet->getHighestColumn(); $allDataInSheet = $objPHPExcel->getActiveSheet()->toArray(null,true,true,true); $arrayCount = count($allDataInSheet); // Here get total count of row in that Excel sheet $site_table = 'gss_new_sites'; //$this->gss_model->table_truncate($table); if(count($allDataInSheet)>0){ $this->gss_model->delete($site_table,$where_id); for($i = 2;$i <= $arrayCount;$i++){ //echo $allDataInSheet[$i]["A"]; $site_number = trim($allDataInSheet[$i]["A"]); $north_in_mtrs = trim($allDataInSheet[$i]["B"]); $north_in_mtrs = sprintf ("%.2f", $north_in_mtrs); $south_in_mtrs = trim($allDataInSheet[$i]["C"]); $south_in_mtrs = sprintf ("%.2f", $south_in_mtrs); $east_in_mtrs = trim($allDataInSheet[$i]["D"]); $east_in_mtrs = sprintf ("%.2f", $east_in_mtrs); $west_in_mtrs = trim($allDataInSheet[$i]["E"]); $west_in_mtrs = sprintf ("%.2f", $west_in_mtrs); $total_in_sqmtrs = trim($allDataInSheet[$i]["F"]); $total_in_sqmtrs = sprintf ("%.2f", $total_in_sqmtrs); $total_in_sqft = trim($allDataInSheet[$i]["G"]); $total_in_sqft = sprintf ("%.2f", $total_in_sqft); $east_facing = trim($allDataInSheet[$i]["H"]); $west_facing = trim($allDataInSheet[$i]["I"]); $north_facing = trim($allDataInSheet[$i]["J"]); $south_facing = trim($allDataInSheet[$i]["K"]); $status = trim($allDataInSheet[$i]["L"]); $site_data =array( 'project_id' => $project_id, 'site_number' => $site_number, 'north_in_mtrs' => $north_in_mtrs, 'south_in_mtrs' => $south_in_mtrs, 'east_in_mtrs' => $east_in_mtrs, 'west_in_mtrs' => $west_in_mtrs, 'total_in_sqmtrs' => $total_in_sqmtrs, 'total_in_sqft' => $total_in_sqft, 'east_facing' => $east_facing, 'west_facing' => $west_facing, 'north_facing' => $north_facing, 'south_facing' => $south_facing, 'status' => $status, 'delete_status' => 'ACTIVE', 'updated_at ' => $updated_at ); $this->gss_model->insert($site_table,$site_data); } } } } if(isset($url)) { $image_table = 'gss_project_conversion_orders'; $delete_images = $this->gss_model->delete($image_table,$where_file); foreach($url as $key=>$get_url) { if(!empty($get_url)) { $get_urls = preg_replace('/\s+/', '_', $get_url); } else { $get_urls = ""; } $gallery_array = array( 'project_id' => $project_id, 'conversion_order' => $get_urls, 'delete_status' => 'ACTIVE', 'created_at' => $updated_at ); $gallery = $this->gss_model->insert($image_table,$gallery_array); } } $result = $this->gss_model->update($where_id,$table,$data); 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")); } } } //Edit new site public function edit_new_site() { $table = 'gss_new_sites'; $site_id = $this->input->post('site_id'); $where = array('site_id'=>$site_id,'delete_status'=>'ACTIVE'); $result = $this->gss_model->get_where_row($table,$where); if($result) { echo json_encode(array('site_details'=>$result,'result'=>1)); } else { echo json_encode(array('result'=>0)); } } //Add more site public function add_more_site() { $project_id = $this->input->post('project_id'); $site_number = $this->input->post('site_number'); $north_in_mtrs = sprintf ("%.2f", $this->input->post('north_in_mtrs')); $south_in_mtrs = sprintf ("%.2f", $this->input->post('south_in_mtrs')); $east_in_mtrs = sprintf ("%.2f", $this->input->post('east_in_mtrs')); $west_in_mtrs = sprintf ("%.2f", $this->input->post('west_in_mtrs')); $total_in_sqmtrs = $this->input->post('total_in_sqmtrs'); $total_in_sqft = $this->input->post('total_in_sqft'); $east_facing = $this->input->post('east_facing'); $west_facing = $this->input->post('west_facing'); $north_facing = $this->input->post('north_facing'); $south_facing = $this->input->post('south_facing'); $status = $this->input->post('status'); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $created_at = $date->format('Y-m-d H:i:s'); $this->load->library('image_lib'); $file_name = ""; if($_FILES) { if(empty($_FILES['site_image']['name'])) { $file_name = ""; } else { $target='project_uploads/9_and_11/'; $target.=time().$_FILES['site_image']['name']; $file_name=time().$_FILES['site_image']['name']; $image=$target; move_uploaded_file($_FILES['site_image']['tmp_name'],$target); $config['source_image']=$target; $config['maintain_ratio']=TRUE; // $config['width']=200; // $config['height']=150; $this->image_lib->initialize($config); $this->image_lib->resize(); } } $data = array( 'project_id' => $project_id, 'site_number' => $site_number, 'north_in_mtrs' => $north_in_mtrs, 'south_in_mtrs' => $south_in_mtrs, 'east_in_mtrs' => $east_in_mtrs, 'west_in_mtrs' => $west_in_mtrs, 'total_in_sqmtrs' => $total_in_sqmtrs, 'total_in_sqft' => $total_in_sqft, 'east_facing' => $east_facing, 'west_facing' => $west_facing, 'north_facing' => $north_facing, 'south_facing' => $south_facing, 'status' => $status, 'site_image' => $file_name, 'delete_status' => 'ACTIVE', 'created_at' => $created_at ); $site_table = 'gss_new_sites'; $where = array( 'delete_status' => 'ACTIVE', 'site_number' => $site_number, 'project_id' => $project_id ); $numbers = $this->gss_model->get_where_result($site_table,$where); $array = array(); foreach($numbers as $value) { array_push($array, $value->site_number); } if(in_array($site_number,$array)) { echo json_encode(array('result'=>2,'message'=>"Site number already exists")); } else { $result = $this->gss_model->insert($site_table,$data); if($result) { echo json_encode(array('result'=>1,'message'=>"Site added successfully")); } else { echo json_encode(array('result'=>0,'message'=>"Something went wrong.. try again")); } } } //Update new site public function update_new_site() { $table = 'gss_new_sites'; $site_id = $this->input->post('site_id'); $project_id = $this->input->post('project_id'); $site_number = $this->input->post('site_number'); $north_in_mtrs = $this->input->post('north_in_mtrs'); $south_in_mtrs = $this->input->post('south_in_mtrs'); $east_in_mtrs = $this->input->post('east_in_mtrs'); $west_in_mtrs = $this->input->post('west_in_mtrs'); $total_in_sqmtrs = $this->input->post('total_in_sqmtrs'); $total_in_sqft = $this->input->post('total_in_sqft'); $east_facing = $this->input->post('east_facing'); $west_facing = $this->input->post('west_facing'); $north_facing = $this->input->post('north_facing'); $south_facing = $this->input->post('south_facing'); $status = $this->input->post('status'); $assigned_project = $this->input->post('assigned_project'); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $updated_at = $date->format('Y-m-d H:i:s'); $where_file = array('site_id'=>$site_id); $site_data = $this->gss_model->get_where_row($table,$where_file); $data = array( 'site_number' => $site_number, 'north_in_mtrs' => $north_in_mtrs, 'south_in_mtrs' => $south_in_mtrs, 'east_in_mtrs' => $east_in_mtrs, 'west_in_mtrs' => $west_in_mtrs, 'total_in_sqmtrs' => $total_in_sqmtrs, 'total_in_sqft' => $total_in_sqft, 'east_facing' => $east_facing, 'west_facing' => $west_facing, 'north_facing' => $north_facing, 'south_facing' => $south_facing, 'status' => $status, 'assigned_project'=> $assigned_project, 'delete_status' => 'ACTIVE', 'updated_at' => $updated_at ); $where_site = $site_data->site_number; $where = array( 'delete_status' => 'ACTIVE', 'site_number !=' => $where_site, 'project_id' => $project_id ); $numbers = $this->gss_model->get_where_result($table,$where); $array = array(); foreach($numbers as $value) { array_push($array, $value->site_number); } if(in_array($site_number,$array)) { echo json_encode(array('result'=>2,'message'=>"Site number already exists in this project")); } else { $where_id = array('site_id' => $site_id,'project_id' => $project_id); $result = $this->gss_model->update($where_id,$table,$data); 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")); } } } // Completed Projects list form public function completed_projects() { $admin_id = session()->get('admin_id'); if($admin_id) { $land_table = 'gss_new_projects'; $where = array('delete_status'=>'ACTIVE'); $data['owners'] = $this->gss_model->get_where_result($land_table,$where); $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $this->load->view('admin/completed_project_form',$data); } else { redirect('/'); } } //Completed Projects list public function completed_projects_list() { $table = 'gss_new_projects'; $result = $this->gss_model->completed_projects_list(); if($result) { echo json_encode($result); } else { echo json_encode(array('result'=>0)); } } //close project public function close_new_project() { $table = 'gss_new_projects'; $project_id = $this->input->post('project_id'); $where = array('project_id'=>$project_id); $check_status = $this->gss_model->get_where_row($table, $where); if($check_status->project_status == 'ONGOING') { $data = array('project_status'=>'COMPLETED'); } else { $data = array('project_status'=>'ONGOING'); } $result = $this->gss_model->update($where,$table,$data); if($result > 0) { echo json_encode(array('result'=>1,'message'=>'Changed successfully')); } else { echo json_encode(array('result'=>0)); } } public function add_booking_details() { $customer_name = $this->input->post('customer_name'); $relation = $this->input->post('relation'); $fa_hu_name = $this->input->post('fa_hu_name'); $email = $this->input->post('email'); $alternative_email = $this->input->post('alternative_email'); $mobile1 = $this->input->post('mobile1'); $mobile2 = $this->input->post('mobile2'); $office_no = $this->input->post('office_no'); $bday = $this->input->post('bday'); if($bday != "") { $date = new DateTime($bday); $bday = $date->format('Y-m-d'); } $doa = $this->input->post('doa'); if($doa != "") { $date = new DateTime($doa); $doa = $date->format('Y-m-d'); } $address = $this->input->post('address'); $id_name = $this->input->post('id_name'); $id_no = $this->input->post('id_no'); $nominee = $this->input->post('nominee'); $nominee_con_no = $this->input->post('nominee_con_no'); $reference = $this->input->post('reference'); $web_portal = $this->input->post('web_portal'); $logistics = $this->input->post('logistics'); $associate = $this->input->post('associate'); $subassociate = $this->input->post('subassociate'); $source_type = $this->input->post('source_type'); $source_bank_name = $this->input->post('source_bank_name'); $project_id = $this->input->post('project_id'); $site_number = $this->input->post('site_number'); $reference_two = $this->input->post('reference_two'); $logistics_two = $this->input->post('logistics_two'); if($site_number[0] == 0) { $site_number = substr($site_number, 1); } else { $site_number = $site_number; } $site_dimension = $this->input->post('site_dimension'); $booking_date1 = $this->input->post('booking_date1'); if($booking_date1 != "") { $date = new DateTime($booking_date1); $booking_date1 = $date->format('Y-m-d'); } $booking_amount_1 = $this->input->post('booking_amount1'); $booking_amount1 = str_replace(',', '', $booking_amount_1); $booking_date2 = $this->input->post('booking_date2'); if($booking_date2 != "") { $date = new DateTime($booking_date2); $booking_date2 = $date->format('Y-m-d'); } if($this->input->post('booking_amount2') == '') { $booking_amount2 = '0'; } else { $booking_amount_2 = $this->input->post('booking_amount2'); $booking_amount2 = str_replace(',', '', $booking_amount_2); } $confirming_party1 =$this->input->post('owners_type1'); $confirming_party2 =$this->input->post('owners_type2'); $instal_due_date = $this->input->post('instal_due_date'); if($instal_due_date != "") { $date = new DateTime($instal_due_date); $instal_due_date = $date->format('Y-m-d'); } $instal_due_amounts = $this->input->post('instal_due_amount'); $instal_due_amount = str_replace(',', '', $instal_due_amounts); $reg_date_type = $this->input->post('reg_date_type'); $reg_due_date = $this->input->post('reg_due_date'); if($reg_due_date != "") { $date = new DateTime($reg_due_date); $reg_due_date = $date->format('Y-m-d'); } $reg_due_amounts = $this->input->post('reg_due_amount'); $reg_due_amount = str_replace(',', '', $reg_due_amounts); $sale_agree_date = $this->input->post('sale_agree_date'); if($sale_agree_date != "") { $date = new DateTime($sale_agree_date); $sale_agree_date = $date->format('Y-m-d'); } $sale_agree_amounts = $this->input->post('sale_agree_amount'); $sale_agree_amount = str_replace(',', '', $sale_agree_amounts); $tsvs = $this->input->post('tsv'); $tsv = str_replace(',', '', $tsvs); $per_sqft = $this->input->post('per_sqft'); $land_owner_rate = $this->input->post('land_owner_rate'); $land_owner_amounts = $this->input->post('land_owner_amount'); $land_owner_amount = str_replace(',', '', $land_owner_amounts); $gss_rate = $this->input->post('gss_rate'); $gss_amounts = $this->input->post('gss_amount'); $gss_amount = str_replace(',', '', $gss_amounts); $payment_type1 = $this->input->post('payment_type1'); $check_no1 = ''; $check_date1 = ''; $bank_name1 = ''; $vtr_no1 = ''; $online_date1 = ''; $dd_no1 = ''; $dd_date1 = ''; $dd_bank1 = ''; $ref_no = ''; $paytm_date = ''; $upi_ref_no = ''; $upi_date = ''; if($payment_type1 == 'Cheque') { $check_no1 = $this->input->post('check_no1'); $check_date1 = $this->input->post('check_date1'); if($check_date1 != "") { $date = new DateTime($check_date1); $check_date1 = $date->format('Y-m-d'); } $bank_name1 = $this->input->post('bank_name1'); } else if($payment_type1 == 'Online Payment') { $vtr_no1 = $this->input->post('vtr_no1'); $online_date1 = $this->input->post('online_date1'); if($online_date1 != "") { $date = new DateTime($online_date1); $online_date1 = $date->format('Y-m-d'); } } else if($payment_type1 == 'DD') { $dd_no1 = $this->input->post('dd_no1'); $dd_date1 = $this->input->post('dd_date1'); if($dd_date1 != "") { $date = new DateTime($dd_date1); $dd_date1 = $date->format('Y-m-d'); } $dd_bank1 = $this->input->post('dd_bank1'); } else if($payment_type1 == 'Paytm Payment') { $ref_no = $this->input->post('ref_no'); $paytm_date = $this->input->post('paytm_date'); if($paytm_date != "") { $date = new DateTime($paytm_date); $paytm_date = $date->format('Y-m-d'); } } else if($payment_type1 == 'UPI Payment') { $upi_ref_no = $this->input->post('upi_ref_no'); $upi_date = $this->input->post('upi_date'); if($upi_date != "") { $date = new DateTime($upi_date); $upi_date = $date->format('Y-m-d'); } } $payment_type2 = $this->input->post('payment_type2'); $check_no2 = ''; $check_date2 = ''; $bank_name2 = ''; $vtr_no2 = ''; $online_date2 = ''; $dd_no2 = ''; $dd_date2 = ''; $dd_bank2 = ''; $ref_no1 =''; $paytm_date1 =''; $upi_ref_no1 =''; $upi_date1 =''; if($payment_type2 == 'Cheque') { $check_no2 = $this->input->post('check_no2'); $check_date2 = $this->input->post('check_date2'); if($check_date2 != "") { $date = new DateTime($check_date2); $check_date2 = $date->format('Y-m-d'); } $bank_name2 = $this->input->post('bank_name2'); } else if($payment_type2 == 'Online Payment') { $vtr_no2 = $this->input->post('vtr_no2'); $online_date2 = $this->input->post('online_date2'); if($online_date2 != "") { $date = new DateTime($online_date2); $online_date2 = $date->format('Y-m-d'); } } else if($payment_type2 == 'DD') { $dd_no2 = $this->input->post('dd_no2'); $dd_date2 = $this->input->post('dd_date2'); if($dd_date2 != "") { $date = new DateTime($dd_date2); $dd_date2 = $date->format('Y-m-d'); } $dd_bank2 = $this->input->post('dd_bank2'); } else if($payment_type2 == 'Paytm Payment') { $ref_no1 = $this->input->post('ref_no1'); $paytm_date1 = $this->input->post('paytm_date1'); if($paytm_date1 != "") { $date = new DateTime($paytm_date1); $paytm_date1 = $date->format('Y-m-d'); } } else if($payment_type2 == 'UPI Payment') { $upi_ref_no1 = $this->input->post('upi_ref_no1'); $upi_date1 = $this->input->post('upi_date1'); if($upi_date1 != "") { $date = new DateTime($upi_date1); $upi_date1 = $date->format('Y-m-d'); } } $this->load->library('image_lib'); $id_scan = ""; $application_scan = ""; if($_FILES) { if(empty($_FILES['id_scan']['name'])) { $id_scan = ""; } else { $target='booking_uploads/'; $target.=time().$_FILES['id_scan']['name']; $id_scan=time().$_FILES['id_scan']['name']; $image=$target; $target1 = preg_replace('/\s+/', '_', $target); move_uploaded_file($_FILES['id_scan']['tmp_name'],$target1); $config['source_image']=$target1; $config['maintain_ratio']=TRUE; $this->image_lib->initialize($config); $this->image_lib->resize(); } if(!empty($id_scan)) { $id_scans = preg_replace('/\s+/', '_', $id_scan); } else { $id_scans = ""; } if(empty($_FILES['application_scan']['name'])) { $application_scan = ""; } else { $target='booking_uploads/'; $target.=time().$_FILES['application_scan']['name']; $application_scan=time().$_FILES['application_scan']['name']; $image=$target; $target1 = preg_replace('/\s+/', '_', $target); move_uploaded_file($_FILES['application_scan']['tmp_name'],$target1); $config['source_image']=$target1; $config['maintain_ratio']=TRUE; $this->image_lib->initialize($config); $this->image_lib->resize(); } if(!empty($application_scan)) { $application_scans = preg_replace('/\s+/', '_', $application_scan); } else { $application_scans = ""; } } $khata_status = $this->input->post('khata_status'); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $created_at = $date->format('Y-m-d H:i:s'); $booking_data = array( 'project_id' => $project_id, 'customer_name' => $customer_name, 'relation' => $relation, 'father_or_husband' => $fa_hu_name, 'email' => $email, 'alternative_email' => $alternative_email, 'mobile1' => $mobile1, 'mobile2' => $mobile2, 'dob' => $bday, 'doa' => $doa, 'address' => $address, 'nominee_name' => $nominee, 'nominee_contact' => $nominee_con_no, 'office_number' => $office_no, 'idproof_name' => $id_name, 'idproof_number' => $id_no, 'idproof_image' => $id_scans, 'webportal' => $web_portal, 'logistics' => $logistics, 'reference' => $reference, 'associate' => $associate, 'subassociate' => $subassociate, 'reference_two' => $reference_two, 'logistics_two' => $logistics_two, 'source_type' => $source_type, 'source_bank_name' => $source_bank_name, 'khata_status' => $khata_status, 'delete_status' => 'ACTIVE', 'created_at' => $created_at ); //print_r($booking_data);die(); $total = 0; if($instal_due_amount == 0 || $instal_due_amount == "") { $total = $booking_amount1 + $booking_amount2 + $reg_due_amount + $sale_agree_amount; } else { $total = $booking_amount1 + $booking_amount2 + $instal_due_amount + $reg_due_amount + $sale_agree_amount; } if($total > $tsv || $total < $tsv) { echo json_encode(array('result'=>3,'message'=>"Not matching TSV")); } else if($payment_type1 == "") { echo json_encode(array('result'=>4,'message'=>"Choose atleaset one payment type")); } else { $booking_table = 'gss_bookings'; $detail_table = 'gss_booking_details'; $instal_table = 'gss_booking_installments'; $where = array('delete_status'=>'ACTIVE','project_id'=>$project_id); $sites = $this->gss_model->get_where_result($detail_table,$where); $array = array(); foreach($sites as $value) { array_push($array, $value->site_number); } if(in_array($site_number,$array)) { $order_by = 'booking_id'; $where1 = array('delete_status'=>'ACTIVE','project_id'=>$project_id,'site_number'=>$site_number); $check = $this->gss_model->get_where_orderby_row($detail_table,$where1,$order_by); $where2 = array('delete_status'=>'ACTIVE','booking_id'=>$check->booking_id); $status = $this->gss_model->get_where_orderby_row($booking_table,$where2,$order_by); $result = $this->gss_model->insert($booking_table,$booking_data); if($result) { $detail_data = array( 'booking_id' => $result, 'project_id' => $project_id, 'booking_date1' => $booking_date1, 'booking_amount1' => $booking_amount1, 'booking_date2' => $booking_date2, 'booking_amount2' => $booking_amount2, 'booking_payment_type' => $payment_type1, 'booking_payment_type2' => $payment_type2, 'confirming_party1' =>$confirming_party1, 'confirming_party2' =>$confirming_party2, 'check_no' => $check_no1, 'check_date' => $check_date1, 'bank_name' => $bank_name1, 'vtr_no' => $vtr_no1, 'online_date' => $online_date1, 'dd_no' => $dd_no1, 'dd_date' => $dd_date1, 'dd_bank' => $dd_bank1, 'paytm_ref_no' =>$ref_no, 'paytm_online_date' =>$paytm_date, 'upi_ref_no' =>$upi_ref_no, 'upi_online_date' =>$upi_date, 'check_no2' => $check_no2, 'check_date2' => $check_date2, 'bank_name2' => $bank_name2, 'vtr_no2' => $vtr_no2, 'online_date2' => $online_date2, 'dd_no2' => $dd_no2, 'dd_date2' => $dd_date2, 'dd_bank2' => $dd_bank2, 'paytm_ref_no2' =>$ref_no1, 'paytm_online_date2' =>$paytm_date1, 'upi_ref_no2' =>$upi_ref_no1, 'upi_online_date2' =>$upi_date1, 'tsv' => $tsv, 'tsv_per_sft_rs' => $per_sqft, 'land_owner_rate' => $land_owner_rate, 'land_owner_amount' => $land_owner_amount, 'gss_rate' => $gss_rate, 'gss_amount' => $gss_amount, 'sales_agreement_due_date' => $sale_agree_date, 'sales_agreement_due_amount' => $sale_agree_amount, 'reg_date_type' => $reg_date_type, 'registration_due_date' => $reg_due_date, 'registration_due_amount' => $reg_due_amount, 'site_number' => $site_number, 'dimension' => $site_dimension, 'application_scan' => $application_scans, 'delete_status' => 'ACTIVE', 'created_at' => $created_at ); $detail_result = $this->gss_model->insert($detail_table,$detail_data); if($detail_result) { $result1 = $this->gss_model->booking_status($detail_result); if($result1) { $data=array('site_status'=>'BOOKED'); $project_table = 'gss_new_sites'; $where=array('site_number'=>$result1->site_number,'delete_status'=>'ACTIVE'); $resulted = $this->gss_model->update($where,$project_table,$data); } $this->session->set_userdata('booking_id',$result); $instal_data = array( 'booking_id' => $result, 'booking_detal_id' => $detail_result, 'installment_due_date' => $instal_due_date, 'installment_due_amount' => $instal_due_amount, 'payment_mode' => $payment_type1 ); $instal_result = $this->gss_model->insert($instal_table,$instal_data); $where_user = array('booking_id'=>$result); $user_data = $this->gss_model->get_where_row($booking_table,$where_user); $booking_receipt = $this->gss_model->booking_receipt_site_data($result); $todays_date = $date->format('Y-m-d'); $received = $booking_amount1 + $booking_amount2; $mobile1 = json_decode($user_data->mobile1); //$number = rtrim(implode(',', $mobile1), ','); $number = $mobile1; $balance = $tsv - $received; $total = $received + $balance; echo json_encode(array( 'result' => 1, 'booking_id' => $result, 'user_data' => $user_data, 'todays_date' => $todays_date, 'booking_receipt' => $booking_receipt, 'received' => $received, 'number' => $number, 'balance' => $balance, 'total' => $total, 'message' => "Site booked successfully" )); } else { echo json_encode(array('result'=>0,'message'=>"Something went wrong.. try again")); } } else { echo json_encode(array('result'=>0,'message'=>"Something went wrong.. try again")); } } else { $site_table = "gss_new_sites"; $where = array('delete_status'=>'ACTIVE','project_id'=>$project_id); $site_numbers = $this->gss_model->get_where_result($site_table,$where); $array = array(); foreach($site_numbers as $value) { array_push($array, $value->site_number); } if(!(in_array($site_number,$array))) { echo json_encode(array('result'=>2,'message'=>"Site number does not exist")); } else { $result = $this->gss_model->insert($booking_table,$booking_data); if($result) { $detail_data = array( 'booking_id' => $result, 'project_id' => $project_id, 'booking_date1' => $booking_date1, 'booking_amount1' => $booking_amount1, 'booking_date2' => $booking_date2, 'booking_amount2' => $booking_amount2, 'booking_payment_type' => $payment_type1, 'confirming_party1' =>$confirming_party1, 'confirming_party2' =>$confirming_party2, 'check_no' => $check_no1, 'check_date' => $check_date1, 'bank_name' => $bank_name1, 'vtr_no' => $vtr_no1, 'online_date' => $online_date1, 'dd_no' => $dd_no1, 'dd_date' => $dd_date1, 'dd_bank' => $dd_bank1, 'paytm_ref_no' =>$ref_no, 'paytm_online_date' =>$paytm_date, 'upi_ref_no' =>$upi_ref_no, 'upi_online_date' =>$upi_date, 'booking_payment_type2' => $payment_type2, 'check_no2' => $check_no2, 'check_date2' => $check_date2, 'bank_name2' => $bank_name2, 'vtr_no2' => $vtr_no2, 'dd_no2' => $dd_no2, 'dd_date2' => $dd_date2, 'dd_bank2' => $dd_bank2, 'online_date2' => $online_date2, 'paytm_ref_no2' =>$ref_no1, 'paytm_online_date2' =>$paytm_date1, 'upi_ref_no2' =>$upi_ref_no1, 'upi_online_date2' =>$upi_date1, 'tsv' => $tsv, 'tsv_per_sft_rs' => $per_sqft, 'land_owner_rate' => $land_owner_rate, 'land_owner_amount' => $land_owner_amount, 'gss_rate' => $gss_rate, 'gss_amount' => $gss_amount, 'sales_agreement_due_date' => $sale_agree_date, 'sales_agreement_due_amount' => $sale_agree_amount, 'reg_date_type' => $reg_date_type, 'registration_due_date' => $reg_due_date, 'registration_due_amount' => $reg_due_amount, 'site_number' => $site_number, 'dimension' => $site_dimension, 'application_scan' => $application_scans, 'delete_status' => 'ACTIVE', 'created_at' => $created_at ); $detail_result = $this->gss_model->insert($detail_table,$detail_data); if($detail_result) { $result1 = $this->gss_model->booking_status($detail_result); if($result1) { $data=array('site_status'=>'BOOKED'); $project_table = 'gss_new_sites'; $where=array('site_number'=>$result1->site_number,'delete_status'=>'ACTIVE'); $resulted = $this->gss_model->update($where,$project_table,$data); } $this->session->set_userdata('booking_id',$result); $instal_data = array( 'booking_id' => $result, 'booking_detal_id' => $detail_result, 'installment_due_date' => $instal_due_date, 'installment_due_amount' => $instal_due_amount, 'payment_mode' => $payment_type2 ); $instal_result = $this->gss_model->insert($instal_table,$instal_data); $where_user = array('booking_id'=>$result); $user_data = $this->gss_model->get_where_row($booking_table,$where_user); $booking_receipt = $this->gss_model->booking_receipt_site_data($result); $todays_date = $date->format('Y-m-d'); $received = $booking_amount1 + $booking_amount2; if($user_data) { $mobile2 = json_decode($user_data->mobile2); $number = $mobile2; $balance = $tsv - $received; $total = $received + $balance; echo json_encode(array( 'result' => 1, 'booking_id' => $result, 'user_data' => $user_data, 'todays_date' => $todays_date, 'booking_receipt' => $booking_receipt, 'received' => $received, 'number' => $number, 'balance' => $balance, 'total' => $total, 'message' => "Site booked successfully" )); } else { echo json_encode(array('result'=>0,'message'=>"Something went wrong.. try again")); } } else { echo json_encode(array('result'=>0,'message'=>"Something went wrong.. try again")); } } } } } } //Edit booking details public function edit_booking_details() { $admin_id = session()->get('admin_id'); if($admin_id) { $web_table = 'gss_webportals'; $broker_table = 'gss_brokers'; $project_table = 'gss_new_projects'; $where_portal = array('delete_status'=>'ACTIVE'); $where_reference = array('delete_status'=>'ACTIVE','type'=>'Executives'); $where_logistics = array('delete_status'=>'ACTIVE','type'=>'Logistic'); $where_associate = array('delete_status'=>'ACTIVE','type'=>'Associate'); $where_subassociate = array('delete_status'=>'ACTIVE','type'=>'Sub Associate'); $where_project = array('delete_status'=>'ACTIVE'); $order_by_portal = 'webportal'; $order_by = 'associate_name'; $order_by_project = 'project_name'; $data['webportals'] = $this->gss_model->get_where_result_alphabetical($web_table,$where_portal,$order_by_portal); $data['reference'] = $this->gss_model->get_where_result_orderby_asc($broker_table,$where_reference,$order_by); $data['logistics'] = $this->gss_model->get_where_result_orderby_asc($broker_table,$where_logistics,$order_by); $data['associates'] = $this->gss_model->get_where_result_orderby_asc($broker_table,$where_associate,$order_by); $data['subassociates'] = $this->gss_model->get_where_result_orderby_asc($broker_table,$where_subassociate,$order_by); $data['projects'] = $this->gss_model->get_where_result_orderby_asc($project_table,$where_project,$order_by_project); $booking_id = $this->uri->segment(2); $data['booking'] = $this->gss_model->single_booking_details($booking_id); $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $this->load->view('admin/edit_booking_form',$data); } else { redirect('/'); } } //Update booking public function update_booking() { $booking_table = 'gss_bookings'; $detail_table = 'gss_booking_details'; $instal_table = 'gss_booking_installments'; $booking_id = $this->input->post('booking_id'); $detail_id = $this->input->post('detail_id'); $installment_id = $this->input->post('installment_id'); $customer_name = $this->input->post('customer_name'); $relation = $this->input->post('relation'); $fa_hu_name = $this->input->post('fa_hu_name'); $email = $this->input->post('email'); $alternative_email = $this->input->post('alternative_email'); $mobile1 = $this->input->post('mobile1'); $mobile2 = $this->input->post('mobile2'); $office_no = $this->input->post('office_no'); $bday = $this->input->post('bday'); if($bday !="") { $date = new DateTime($bday); $bday = $date->format('Y-m-d'); } $doa = $this->input->post('doa'); if($doa !="") { $date = new DateTime($doa); $doa = $date->format('Y-m-d'); } $address = $this->input->post('address'); $id_name = $this->input->post('id_name'); $id_no = $this->input->post('id_no'); $nominee = $this->input->post('nominee'); $nominee_con_no = $this->input->post('nominee_con_no'); $reference = $this->input->post('reference'); $web_portal = $this->input->post('web_portal'); $logistics = $this->input->post('logistics'); $associate = $this->input->post('associate'); $subassociate = $this->input->post('subassociate'); $source_type = $this->input->post('source_type'); $source_bank_name = $this->input->post('source_bank_name'); $project_id = $this->input->post('project_id'); $site_number = $this->input->post('site_number'); $site_dimension = $this->input->post('site_dimension'); $booking_date1 = $this->input->post('booking_date1'); $reference_two = $this->input->post('reference_two'); $logistics_two = $this->input->post('logistics_two'); if($booking_date1 != "") { $date = new DateTime($booking_date1); $booking_date1 = $date->format('Y-m-d'); } $booking_amount_1 = $this->input->post('booking_amount1'); $booking_amount1 = str_replace(',', '', $booking_amount_1); $booking_date2 = $this->input->post('booking_date2'); if($booking_date2 != "") { $date = new DateTime($booking_date2); $booking_date2 = $date->format('Y-m-d'); } $booking_amount_2 = $this->input->post('booking_amount2'); $booking_amount2 = str_replace(',', '', $booking_amount_2); $instal_due_date = $this->input->post('instal_due_date'); if($instal_due_date != "") { $date = new DateTime($instal_due_date); $instal_due_date = $date->format('Y-m-d'); } $instal_due_amounts = $this->input->post('instal_due_amount'); $instal_due_amount = str_replace(',', '', $instal_due_amounts); $reg_due_date = $this->input->post('reg_due_date'); if($reg_due_date != "") { $date = new DateTime($reg_due_date); $reg_due_date = $date->format('Y-m-d'); } $reg_due_amounts = $this->input->post('reg_due_amount'); $reg_due_amount = str_replace(',', '', $reg_due_amounts); $sale_agree_date = $this->input->post('sale_agree_date'); if($sale_agree_date != "") { $date = new DateTime($sale_agree_date); $sale_agree_date = $date->format('Y-m-d'); } $sale_agree_amounts = $this->input->post('sale_agree_amount'); $sale_agree_amount = str_replace(',', '', $sale_agree_amounts); $tsvs = $this->input->post('tsv'); $tsv = str_replace(',', '', $tsvs); $per_sqft = $this->input->post('per_sqft'); $land_owner_rate = $this->input->post('land_owner_rate'); $land_owner_amounts = $this->input->post('land_owner_amount'); $land_owner_amount = str_replace(',', '', $land_owner_amounts); $gss_rate = $this->input->post('gss_rate'); $gss_amounts = $this->input->post('gss_amount'); $gss_amount = str_replace(',', '', $gss_amounts); $reg_date_type = $this->input->post('reg_date_type'); $confirming_party1 =$this->input->post('owners_type1'); $confirming_party2 =$this->input->post('owners_type2'); $payment_type = $this->input->post('payment_type'); $check_no = ''; $check_date = ''; $bank_name = ''; $vtr_no = ''; $online_date = ''; $dd_no = ''; $dd_date = ''; $dd_bank = ''; $ref_no =''; $paytm_date =''; $upi_ref_no =''; $upi_date =''; if($payment_type == 'Cheque') { $check_no = $this->input->post('check_no'); $check_date = $this->input->post('check_date'); if($check_date != "") { $date = new DateTime($check_date); $check_date = $date->format('Y-m-d'); } $bank_name = $this->input->post('bank_name'); } else if($payment_type == 'Online Payment') { $vtr_no = $this->input->post('vtr_no'); $online_date = $this->input->post('online_date'); if($online_date != "") { $date = new DateTime($online_date); $online_date = $date->format('Y-m-d'); } } else if($payment_type == 'DD') { $dd_no = $this->input->post('dd_no'); $dd_date = $this->input->post('dd_date'); if($dd_date != "") { $date = new DateTime($dd_date); $dd_date = $date->format('Y-m-d'); } $dd_bank = $this->input->post('dd_bank'); } else if($payment_type == 'Paytm Payment') { $ref_no = $this->input->post('ref_no'); $paytm_date = $this->input->post('paytm_date'); if($paytm_date != "") { $date = new DateTime($paytm_date); $paytm_date = $date->format('Y-m-d'); } } else if($payment_type == 'UPI Payment') { $upi_ref_no = $this->input->post('upi_ref_no'); $upi_date = $this->input->post('upi_date'); if($upi_date != "") { $date = new DateTime($upi_date); $upi_date = $date->format('Y-m-d'); } } //-----------------------------------------------------------// $payment_type2 = $this->input->post('payment_type2'); $check_no2 = ''; $check_date2 = ''; $bank_name2 = ''; $vtr_no2 = ''; $online_date2 = ''; $dd_no2 = ''; $dd_date2 = ''; $dd_bank2 = ''; $ref_no1 =''; $paytm_date1 =''; $upi_ref_no1 =''; $upi_date1 =''; if($payment_type2 == 'Cheque') { $check_no2 = $this->input->post('check_no2'); $check_date2 = $this->input->post('check_date2'); if($check_date2 != "") { $date = new DateTime($check_date2); $check_date2 = $date->format('Y-m-d'); } $bank_name2 = $this->input->post('bank_name2'); } else if($payment_type2 == 'Online Payment') { $vtr_no2 = $this->input->post('vtr_no2'); $online_date2 = $this->input->post('online_date2'); if($online_date2 != "") { $date = new DateTime($online_date2); $online_date2 = $date->format('Y-m-d'); } } else if($payment_type2 == 'DD') { $dd_no2 = $this->input->post('dd_no2'); $dd_date2 = $this->input->post('dd_date2'); if($dd_date2 != "") { $date = new DateTime($dd_date2); $dd_date2 = $date->format('Y-m-d'); } $dd_bank2 = $this->input->post('dd_bank2'); } else if($payment_type2 == 'Paytm Payment') { $ref_no1 = $this->input->post('ref_no1'); $paytm_date1 = $this->input->post('paytm_date1'); if($paytm_date1 != "") { $date = new DateTime($paytm_date1); $paytm_date1 = $date->format('Y-m-d'); } } else if($payment_type2 == 'UPI Payment') { $upi_ref_no1 = $this->input->post('upi_ref_no1'); $upi_date1 = $this->input->post('upi_date1'); if($upi_date1 != "") { $date = new DateTime($upi_date1); $upi_date1 = $date->format('Y-m-d'); } } //---------------------------------------------------------// $mobile = json_encode(array($mobile1, $mobile2)); $this->load->library('image_lib'); $id_scan = ""; $application_scan = ""; $where_booking = array('booking_id'=>$booking_id,'delete_status'=>'ACTIVE'); if($_FILES) { if(empty($_FILES['id_scan']['name'])) { $id_result = $this->gss_model->get_where_row($booking_table,$where_booking); $id_scan = $id_result->idproof_image; } else { $target='booking_uploads/'; $target.=time().$_FILES['id_scan']['name']; $id_scan=time().$_FILES['id_scan']['name']; $image=$target; move_uploaded_file($_FILES['id_scan']['tmp_name'],$target); $config['source_image']=$target; $config['maintain_ratio']=TRUE; $this->image_lib->initialize($config); $this->image_lib->resize(); } if(empty($_FILES['application_scan']['name'])) { $appln_result = $this->gss_model->get_where_row($detail_table,$where_booking); $application_scan = $appln_result->application_scan; } else { $target='booking_uploads/'; $target.=time().$_FILES['application_scan']['name']; $application_scan=time().$_FILES['application_scan']['name']; $image=$target; move_uploaded_file($_FILES['application_scan']['tmp_name'],$target); $config['source_image']=$target; $config['maintain_ratio']=TRUE; $this->image_lib->initialize($config); $this->image_lib->resize(); } } $khata_status = $this->input->post('khata_status'); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $created_at = $date->format('Y-m-d H:i:s'); $booking_data = array( 'project_id' => $project_id, 'customer_name' => $customer_name, 'relation' => $relation, 'father_or_husband' => $fa_hu_name, 'email' => $email, 'alternative_email' => $alternative_email, 'mobile1' => $mobile1, 'mobile2' => $mobile2, 'dob' => $bday, 'doa' => $doa, 'address' => $address, 'nominee_name' => $nominee, 'nominee_contact' => $nominee_con_no, 'office_number' => $office_no, 'idproof_name' => $id_name, 'idproof_number' => $id_no, 'idproof_image' => $id_scan, 'webportal' => $web_portal, 'logistics' => $logistics, 'reference' => $reference, 'associate' => $associate, 'subassociate' => $subassociate, 'reference_two' => $reference_two, 'logistics_two' => $logistics_two, 'source_type' => $source_type, 'source_bank_name' => $source_bank_name, 'khata_status' => $khata_status, 'delete_status' => 'ACTIVE', 'created_at' => $created_at ); $detail_data = array( 'booking_id' => $booking_id, 'project_id' => $project_id, 'booking_date1' => $booking_date1, 'booking_amount1' => $booking_amount1, 'booking_date2' => $booking_date2, 'booking_amount2' => $booking_amount2, 'booking_payment_type' => $payment_type, 'confirming_party1' =>$confirming_party1, 'confirming_party2' =>$confirming_party2, 'check_no' => $check_no, 'check_date' => $check_date, 'bank_name' => $bank_name, 'vtr_no' => $vtr_no, 'online_date' => $online_date, 'dd_no' => $dd_no, 'dd_date' => $dd_date, 'dd_bank' => $dd_bank, 'paytm_ref_no' => $ref_no, 'paytm_online_date' => $paytm_date, 'upi_ref_no' =>$upi_ref_no, 'upi_online_date' =>$upi_date, 'booking_payment_type2' => $payment_type2, 'check_no2' => $check_no2, 'check_date2' => $check_date2, 'bank_name2' => $bank_name2, 'vtr_no2' => $vtr_no2, 'dd_no2' => $dd_no2, 'dd_date2' => $dd_date2, 'dd_bank2' => $dd_bank2, 'online_date2' => $online_date2, 'paytm_ref_no2' =>$ref_no1, 'paytm_online_date2' =>$paytm_date1, 'upi_ref_no2' =>$upi_ref_no1, 'upi_online_date2' =>$upi_date1, 'tsv' => $tsv, 'tsv_per_sft_rs' => $per_sqft, 'land_owner_rate' => $land_owner_rate, 'land_owner_amount' => $land_owner_amount, 'gss_rate' => $gss_rate, 'gss_amount' => $gss_amount, 'reg_date_type' => $reg_date_type, 'sales_agreement_due_date' => $sale_agree_date, 'sales_agreement_due_amount' => $sale_agree_amount, 'registration_due_date' => $reg_due_date, 'registration_due_amount' => $reg_due_amount, 'site_number' => $site_number, 'dimension' => $site_dimension, 'application_scan' => $application_scan, 'delete_status' => 'ACTIVE', 'created_at' => $created_at ); $where_installment = array('installment_id'=>$installment_id); $where_detail = array('detail_id'=>$detail_id); $instal_data = array( 'booking_id' => $booking_id, 'booking_detal_id' => $detail_id, 'installment_due_date' => $instal_due_date, 'installment_due_amount' => $instal_due_amount, 'payment_mode' => $payment_type ); $total = 0; if($instal_due_amount == 0 || $instal_due_amount == "") { $total = $booking_amount1 + $booking_amount2 + $reg_due_amount + $sale_agree_amount; } else { $total = $booking_amount1 + $booking_amount2 + $instal_due_amount + $reg_due_amount + $sale_agree_amount; } if($total > $tsv || $total < $tsv) { echo json_encode(array('result'=>2,'message'=>"Not matching TSV")); } else { $instal_result = $this->gss_model->update($where_installment,$instal_table,$instal_data); $detail_result = $this->gss_model->update($where_detail,$detail_table,$detail_data); if($this->db->affected_rows() > 0) { $this->gss_model->update($where_booking,$booking_table,$booking_data); //-------------------------------------------------------------------------------------// $notification_table = 'gss_commission_notifications'; $check_associate = $this->gss_model->get_where_row($booking_table,$where_booking); if($check_associate->associate != 0) { $notifications = $this->gss_model->check_notification($booking_id,$detail_id); if($notifications) { } else { $payment_table = 'gss_plot_payments'; $check_amounts = $this->gss_model->get_where_row($payment_table,$where_booking); //print_r($check_amounts);die(); if(!empty($check_amounts->agreement_amount)) { $commission_agreement = 'Available'; } else { $commission_agreement = "Not Available"; } if(!empty($check_amounts->registration_amount)) { $commission_registration = 'Available'; } else { $commission_registration = "Not Available"; } $notification_data = array( 'booking_id' => $booking_id, 'detail_id' => $detail_id, 'commission_agreement' => $commission_agreement, 'commission_registration' => $commission_registration, 'status' => 'PENDING' ); $commission_result = $this->gss_model->insert($notification_table,$notification_data); } } //-------------------------------------------------------------------------------------// echo json_encode(array('result' => 1,'message' => "Updated successfully")); } else { echo json_encode(array('result'=>0,'message'=>"Something went wrong.. try again")); } } } //Load payment from booking from public function add_payment() { $admin_id = session()->get('admin_id'); if($admin_id) { $booking_id = $this->uri->segment(2); $project_table = 'gss_new_projects'; $where_project = array('delete_status'=>'ACTIVE','project_status'=>'ONGOING'); $data['booking_id'] = $booking_id; $data['projects'] = $this->gss_model->get_where_result($project_table,$where_project); $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $this->load->view('admin/payment_form',$data); } else { redirect('/'); } } //Add payment details public function add_payment_details() { $booking_table = 'gss_bookings'; $detail_table = 'gss_booking_details'; $instal_table = 'gss_booking_installments'; $booking_id = $this->input->post('booking_id'); $detail_id = $this->input->post('detail_id'); $customer_name = $this->input->post('customer_name'); $project_id = $this->input->post('project_id'); $site_number = $this->input->post('site_number'); $site_dimension = $this->input->post('site_dimension'); $tsv = $this->input->post('tsv'); $per_sqft = $this->input->post('per_sqft'); $booking_date = $this->input->post('booking_date'); $booking_amount = $this->input->post('booking_amount'); $sale_agree_date = $this->input->post('sale_agree_date'); $sale_agree_amount = $this->input->post('sale_agree_amount'); $reg_due_date = $this->input->post('reg_due_date'); $reg_due_amount = $this->input->post('reg_due_amount'); $instalement_date1 = $this->input->post('instalement_date1'); $instalement_amount1 = $this->input->post('instalement_amount1'); $main_amount = $this->input->post('main_amount'); $no_of_years = $this->input->post('no_of_years'); $membership_amount = $this->input->post('membership_amount'); $payment_type = $this->input->post('payment_type'); $instalement_date2 = $this->input->post('instalement_date2'); $instalement_amount2 = $this->input->post('instalement_amount2'); $check_no = ''; $check_date = ''; $bank_name = ''; $vtr_no = ''; $online_date = ''; if($payment_type == 'Check') { $check_no = $this->input->post('check_no'); $check_date = $this->input->post('check_date'); $bank_name = $this->input->post('bank_name'); } else if($payment_type == 'Online Payment') { $vtr_no = $this->input->post('vtr_no'); $online_date = $this->input->post('online_date'); } $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $updated_at = $date->format('Y-m-d H:i:s'); $booking_data = array( 'project_id' => $project_id, 'customer_name' => $customer_name, 'delete_status' => 'ACTIVE', 'updated_at' => $updated_at ); $where_booking = array('booking_id' => $booking_id); $booking_result = $this->gss_model->update($where_booking,$booking_table,$booking_data); $detail_data = array( 'project_id' => $project_id, 'booking_date' => $booking_date, 'booking_amount' => $booking_amount, 'booking_payment_type' => $payment_type, 'check_no' => $check_no, 'check_date' => $check_date, 'bank_name' => $bank_name, 'vtr_no' => $vtr_no, 'online_date' => $online_date, 'tsv' => $tsv, 'tsv_per_sft_rs' => $per_sqft, 'sales_agreement_due_date' => $sale_agree_date, 'sales_agreement_due_amount' => $sale_agree_amount, 'registration_due_date' => $reg_due_date, 'registration_due_amount' => $reg_due_amount, 'site_number' => $site_number, 'dimension' => $site_dimension, 'maintainance_amount' => $main_amount, 'no_of_years' => $no_of_years, 'clubhouse_membership_amount' => $membership_amount, 'delete_status' => 'ACTIVE', 'updated_at' => $updated_at ); $where_detail = array('booking_id'=>$booking_id); $detail_result = $this->gss_model->update($where_detail,$detail_table,$detail_data); if($this->db->affected_rows() > 0) { $where = array('booking_detal_id'=>$detail_id); $check_intal = $this->gss_model->get_where_row($instal_table,$where); if($instalement_date1 == "0000-00-00") { } else { $instal_data1 = array( 'booking_id' => $booking_id, 'booking_detal_id' => $detail_id, 'installment_due_date' => $instalement_date1, 'installment_due_amount' => $instalement_amount1, 'payment_mode' => $payment_type ); $instal_result = $this->gss_model->insert($instal_table,$instal_data1); } if($instalement_date2 == "0000-00-00" || $instalement_date2 == "") { } else { $instal_data2 = array( 'booking_id' => $booking_id, 'booking_detal_id' => $detail_id, 'installment_due_date' => $instalement_date2, 'installment_due_amount' => $instalement_amount2, 'payment_mode' => $payment_type ); $instal_result = $this->gss_model->insert($instal_table,$instal_data2); } echo json_encode(array('result'=>1,'message'=>"Updated successfully")); } else { echo json_encode(array('result'=>0 ,'message'=>'Something went wrong')); } } //Booking list public function booking_list() { $table = 'gss_bookings'; $where = array('delete_status'=>'ACTIVE'); $order_by = "booking_id"; $result = $this->gss_model->get_all_bookings(); if($result) { echo json_encode($result); } else { echo json_encode(array('result'=>0)); } } //Check Booking public function check_booking() { $table = 'gss_bookings'; $booking_id = $this->input->post('booking_id'); $result = $this->gss_model->get_single_booking_details($booking_id); if($result) { echo json_encode(array('result'=>1,'booking_details'=>$result)); } else { echo json_encode(array('result'=>0)); } } //Booking details public function booking_details() { $admin_id = session()->get('admin_id'); if($admin_id) { $table = 'gss_bookings'; $broker_table = 'gss_brokers'; $instal_table = 'gss_booking_installments'; $booking_id = $this->uri->segment(2); $data['site_result'] = $this->gss_model->user_site_booking_details1($booking_id); $site_result = $this->gss_model->user_site_booking_details1($booking_id); $where = array('booking_id'=>$booking_id,'delete_status'=>'ACTIVE'); $data['instal_result'] = $this->gss_model->get_where_row($instal_table,$where); $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $this->load->view('admin/site_booking_details',$data); } else { redirect('/'); } } //Booking details public function user_site_booking_details() { $table = 'gss_bookings'; $instal_table = 'gss_booking_installments'; $booking_id = $this->uri->segment(2); $site_result = $this->gss_model->user_site_booking_details($booking_id); $where = array('booking_id'=>'6','delete_status'=>'ACTIVE'); $instal_result = $this->gss_model->get_where_result($instal_table,$where); if($site_result) { echo json_encode(array('result'=>1,'booking_details'=>$site_result,'instalments'=>$instal_result)); } else { echo json_encode(array('result'=>0)); } } //Site details /*public function booked_site_details() { $instal_table = 'gss_plot_payments'; $site_number = $this->input->post('site_number'); $project_id = $this->input->post('project_id'); $check_site = $this->gss_model->project_details($site_number,$project_id); if($check_site) { $site_result = $this->gss_model->payment_site_booking_details($site_number,$project_id); if($site_result) { if($site_result->booking_status == 'CANCELLED') { echo json_encode(array('result'=>3,'message'=>'Site number '.$site_number.' has been cancelled')); } else { $where_booking = array('booking_id'=>$site_result->booking_id,'delete_status'=>'ACTIVE'); $instal_result = $this->gss_model->get_where_result($instal_table,$where_booking); $agree_result = $this->gss_model->get_where_row($instal_table,$where_booking); $tbale='gss_registration_amount_details'; $condition=array('booking_id'=>$site_result->booking_id,'delete_status'=>'ACTIVE'); $get_reg_amt=$this->gss_model->get_where_result($tbale,$condition); $cancellation_table='gss_cancellations'; $cancellation_con=array('booking_id'=>$site_result->booking_id,'delete_status'=>'ACTIVE'); $get_due_amount=$this->gss_model->get_where_result($cancellation_table,$cancellation_con); $pay_table = 'gss_plot_payments'; $pay_condition=array('booking_id'=>$site_result->booking_id,'delete_status'=>'ACTIVE'); $agr_amount = $this->gss_model->get_where_result($pay_table,$pay_condition); echo json_encode(array('result'=>1,'booking_details'=>$site_result,'installments'=>$instal_result,'agree'=>$agree_result,'reg_amount'=>$get_reg_amt,'due_amount'=>$get_due_amount,'payment_agr_amount'=>$agr_amount)); } } else { echo json_encode(array('result'=>0,'message'=>'Site number '.$site_number.' not booked')); } } else { echo json_encode(array('result'=>2,'message'=>'Site number '.$site_number.' not found')); } }*/ public function booked_site_details() { $instal_table = 'gss_plot_payments'; $site_number = $this->input->post('site_number'); $project_id = $this->input->post('project_id'); $check_site = $this->gss_model->project_details($site_number,$project_id); if($check_site) { $get_site = $this->gss_model->check_site_payment_details($site_number,$project_id); if($get_site) { if($get_site->booking_status == 'CANCELLED') { echo json_encode(array('result'=>3,'message'=>'Site number '.$site_number.' has been cancelled')); } else { $where_booking = array('booking_id'=>$get_site->booking_id1,'delete_status'=>'ACTIVE'); $instal_result = $this->gss_model->get_where_result($instal_table,$where_booking); $agree_result = $this->gss_model->get_where_row($instal_table,$where_booking); $tbale='gss_registration_amount_details'; $condition=array('booking_id'=>$get_site->booking_id1,'delete_status'=>'ACTIVE'); $get_reg_amt=$this->gss_model->get_where_result($tbale,$condition); $cancellation_table='gss_cancellations'; $cancellation_con=array('booking_id'=>$get_site->booking_id1,'delete_status'=>'ACTIVE'); $get_due_amount=$this->gss_model->get_where_row($cancellation_table,$cancellation_con); $pay_table = 'gss_plot_payments'; $pay_condition=array('booking_id'=>$get_site->booking_id1,'delete_status'=>'ACTIVE'); $agr_amount = $this->gss_model->get_where_result($pay_table,$pay_condition); $refund_table = 'gss_cancellation_refunds'; $refund_condition=array('booking_id'=>$get_site->booking_id1,'delete_status'=>'ACTIVE'); $refunds = $this->gss_model->get_where_result($refund_table,$refund_condition); $where = array('booking_id'=>$get_site->booking_id1); $table = 'gss_bookings'; $details = $this->gss_model->get_where_row($table,$where); echo json_encode(array('result'=>1,'details'=>$details,'booking_details'=>$get_site,'installments'=>$instal_result,'agree'=>$agree_result,'reg_amount'=>$get_reg_amt,'due_amount'=>$get_due_amount,'payment_agr_amount'=>$agr_amount,'refunds'=>$refunds)); } } else { echo json_encode(array('result'=>0,'message'=>'Site number '.$site_number.' not booked')); } } else { echo json_encode(array('result'=>2,'message'=>'Site number '.$site_number.' not found')); } } //Site details /*public function booked_site_details1() { $site_number = $this->input->post('site_number'); $project_id = $this->input->post('project_id'); $table = 'gss_booking_details'; $table1 = 'gss_plot_payments'; $where = array('site_number'=>$site_number,'project_id'=>$project_id,'delete_status'=>'ACTIVE'); //$get_ids = $this->gss_model->test($project_id,$site_number); $get_ids = $this->gss_model->test_details($project_id,$site_number); if($get_ids) { $where1 = array('booking_id'=>$get_ids->booking_id,'detail_id'=>$get_ids->detail_id,'delete_status'=>'ACTIVE'); $booking_id = $get_ids->booking_id; $detail_id = $get_ids->detail_id; $check_ids = $this->gss_model->get_payments_types_result($booking_id,$detail_id); $check_ids_row = $this->gss_model->get_payments_types($booking_id,$detail_id); if($check_ids_row){ $check_ids_row=$check_ids_row; }else{ $check_ids_row='0'; } $tbale='gss_registration_amount_details'; $condition=array('booking_id'=>$get_ids->booking_id,'detail_id'=>$get_ids->detail_id,'delete_status'=>'ACTIVE'); $get_reg_amt=$this->gss_model->get_where_result($tbale,$condition); if($get_reg_amt) { $get_reg_amt=$get_reg_amt; } else { $get_reg_amt=''; } } $check_site = $this->gss_model->project_details($site_number,$project_id); if($check_site) { //$site_result = $this->gss_model->payment_site_booking_details($site_number,$project_id); $site_result = $this->gss_model->payment_booking_details($site_number,$project_id,$booking_id); $due_amounts = $this->gss_model->due_amounts($site_number,$project_id); if($site_result) { if($site_result->booking_status == 'CANCELLED') { echo json_encode(array('result'=>3,'message'=>'Site number '.$site_number.' has been cancelled')); } else { echo json_encode(array('result'=>1,'booking_details'=>$site_result,'due_amounts'=>$due_amounts,'row_amounts'=>$check_ids,'amounts'=>$check_ids_row,'registration_amt'=>$get_reg_amt)); } } else { echo json_encode(array('result'=>0,'message'=>'Site number '.$site_number.' not booked')); } } else { echo json_encode(array('result'=>2,'message'=>'Site number '.$site_number.' not found')); } }*/ public function booked_site_details1() { $site_number = $this->input->post('site_number'); $project_id = $this->input->post('project_id'); $table = 'gss_booking_details'; $table1 = 'gss_plot_payments'; $where = array('site_number'=>$site_number,'project_id'=>$project_id,'delete_status'=>'ACTIVE'); //$get_ids = $this->gss_model->test($project_id,$site_number); $get_ids = $this->gss_model->test_details($project_id,$site_number); $booking_id = 0; if(!empty($get_ids)) { $where1 = array('booking_id'=>$get_ids->booking_id,'detail_id'=>$get_ids->detail_id,'delete_status'=>'ACTIVE'); $booking_id = $get_ids->booking_id; $detail_id = $get_ids->detail_id; $check_ids = $this->gss_model->get_payments_types_result($booking_id,$detail_id); $check_ids_rows = $this->gss_model->get_payments_types($booking_id,$detail_id); if(!empty($check_ids_rows)) { $check_ids_row=$check_ids_rows; } else { $check_ids_row=$this->gss_model->get_registration_amount($booking_id); } $get_reg_amt=$this->gss_model->registration_details_get($booking_id,$detail_id); //$get_reg_amt1=$this->gss_model->registration_details_get_plot($booking_id,$detail_id); if(!empty($get_reg_amt)) { $get_reg_amt=$get_reg_amt; } //else if(!empty($get_reg_amt1)) //{ // $get_reg_amt=$get_reg_amt1; //} else { $get_reg_amt=''; } } $check_site = $this->gss_model->project_details($site_number,$project_id); if(!empty($check_site)) { //$site_result = $this->gss_model->payment_site_booking_details($site_number,$project_id); $site_result = $this->gss_model->payment_booking_details($site_number,$project_id,$booking_id); $due_amounts = $this->gss_model->due_amounts($site_number,$project_id); if(!empty($site_result)) { $agreement_details = $this->gss_model->get_agreement_amount_details($booking_id,$detail_id); //$initial_reg_details = $this->gss_model->get_registration_amount_details($booking_id,$detail_id); $initial_reg_details = $this->gss_model->registration_payment_details($booking_id); $installment_details = $this->gss_model->get_installment_amount_details($booking_id,$detail_id); if($site_result->booking_status == 'CANCELLED') { echo json_encode(array('result'=>3,'message'=>'Site number '.$site_number.' has been cancelled')); } else { echo json_encode(array('result'=>1,'booking_details'=>$site_result,'due_amounts'=>$due_amounts,'row_amounts'=>$check_ids,'amounts'=>$check_ids_row,'registration_amt'=>$get_reg_amt,'agreement_details'=>$agreement_details,'registration_details'=>$initial_reg_details,'installment_details'=>$installment_details)); } } else { echo json_encode(array('result'=>0,'message'=>'Site number '.$site_number.' not booked')); } } else { echo json_encode(array('result'=>2,'message'=>'Site number '.$site_number.' not found')); } } // public function individual_payment_details() // { // $payment_table = 'gss_plot_payments'; // $type_table = 'gss_plot_payment_types'; // $multireg_table = 'gss_registration_amount_details'; // $booking_id = $this->input->post('booking_id'); // $detail_id = $this->input->post('detail_id'); // $agreement_payment_type = $this->input->post('agreement_payment_type'); // $sale_agree_amounts = $this->input->post('sale_agree_amount'); // $sale_agree_amount = str_replace(',', '', $sale_agree_amounts); // $sale_agree_date = $this->input->post('sale_agree_date'); // $instalment_payment_type1 = $this->input->post('instalment_payment_type1'); // $instalement_amount1s = $this->input->post('instalement_amount1'); // $instalement_amount1 = str_replace(',', '', $instalement_amount1s); // $instal_amount = array($instalement_amount1); // $installment_date1 = $this->input->post('installment_date1'); // $regn_payment_type = $this->input->post('regn_payment_type'); // $reg_due_amounts = $this->input->post('reg_due_amount'); // $reg_due_amount = str_replace(',', '', $reg_due_amounts); // $reg_values = $this->input->post('reg_value'); // $reg_value = str_replace(',', '', $reg_values); // $reg_status = $this->input->post('reg_status'); // $regn_amount_type = $this->input->post('regn_amount_type'); // $loan_from = $this->input->post('loan_from'); // $tsvs = $this->input->post('tsv'); // $tsv = str_replace(',', '', $tsvs); // $loanregn_payment_type1 = $this->input->post('loanregn_payment_type1'); // $loanreg_due_amounts = $this->input->post('loanreg_due_amount1'); // $loanreg_due_amount1 = str_replace(',', '', $loanreg_due_amounts); // // $loanreg_status1 = $this->input->post('loanreg_status1'); // $loanregndate1 = $this->input->post('loanregndate1'); // $loanregn_no1 = $this->input->post('loanregn_no1'); // $loanregn_bank1 = $this->input->post('loanregn_bank1'); // $loanregn_amount_type = $this->input->post('loanregn_amount_type'); // $loanloan_from = $this->input->post('loanloan_from'); // $instalment_cheque_no1 = $this->input->post('instalment_cheque_no2'); // $instalment_cheque_date1 = $this->input->post('instalment_cheque_date2'); // $instalment_bank_name1 = $this->input->post('instalment_bank_name2'); // $instalment_vtr_no11 = $this->input->post('instalment_vtr_no2'); // $instalment_online_date11 = $this->input->post('instalment_online_date2'); // $instalment_dd_no11 = $this->input->post('installment_dd_no2'); // $instalment_dd_date11 = $this->input->post('installment_dd_date2'); // $instalment_dd_bank11 = $this->input->post('installment_dd_bank2'); // $registration1_date =$this->input->post('registration1_date'); // //print_r($instalment_dd_date11);die(); // $paytm_ref_no11 =$this->input->post('paytm_ref_no2'); // $paytm_online_date11 =$this->input->post('paytm_online_date2'); // $upi_ref_no11 =$this->input->post('upi_ref_no2'); // $upi_online_date11 =$this->input->post('upi_online_date2'); // $install_swipe_date2 =$this->input->post('install_swipe_date2'); // $install_cash_date2 =$this->input->post('install_cash_date2'); // if($reg_status == "Date") // { // $reg_status = $reg_status; // $registration_date = $this->input->post('registration_date'); // if($registration_date != "") // { // // $date = new DateTime($registration_date); // // $registration_date = $date->format('Y-m-d'); // $registration_date = date('Y-m-d',strtotime($registration_date)); // } // } // else // { // $reg_status = $reg_status; // $registration_date = '0000-00-00'; // } // $main_amounts = $this->input->post('main_amount'); // $main_amount = str_replace(',', '', $main_amounts); // $no_of_years = $this->input->post('no_of_years'); // $membership_amounts = $this->input->post('membership_amount'); // $membership_amount = str_replace(',', '', $membership_amounts); // $agreement_cheque_no = $this->input->post('agreement_cheque_no'); // $agreement_cheque_date = $this->input->post('agreement_cheque_date'); // if($agreement_cheque_date != "") // { // //$date = new DateTime($agreement_cheque_date); // //$agreement_cheque_date = $date->format('Y-m-d'); // $agreement_cheque_date = date('Y-m-d',strtotime($agreement_cheque_date)); // } // else // { // $agreement_cheque_date =""; // } // $agreement_bank_name = $this->input->post('agreement_bank_name'); // $agreement_vtr_no = $this->input->post('agreement_vtr_no'); // $agreement_online_date = $this->input->post('agreement_online_date'); // if($agreement_online_date != "" || $agreement_online_date != "undefined-undefined-") // { // /*$date = new DateTime($agreement_online_date); // $agreement_online_date = $date->format('Y-m-d');*/ // $agreement_online_date = date('Y-m-d',strtotime($agreement_online_date)); // } // else // { // $agreement_online_date =""; // } // $agreement_dd_no = $this->input->post('agreement_dd_no'); // $agreement_dd_date = $this->input->post('agreement_dd_date'); // if($agreement_dd_date != "") // { // /*$date = new DateTime($agreement_dd_date); // $agreement_dd_date = $date->format('Y-m-d');*/ // $agreement_dd_date = date('Y-m-d',strtotime($agreement_dd_date)); // } // else // { // $agreement_dd_date =""; // } // $agreement_dd_bank = $this->input->post('agreement_dd_bank'); // $agreementpaytm_ref_no =$this->input->post('paytm_ref_no'); // $agreementpaytm_online_date =$this->input->post('paytm_online_date'); // $agreementupi_ref_no =$this->input->post('upi_ref_no'); // $agreementupi_online_date =$this->input->post('upi_online_date'); // $site_number = $this->input->post('site_number'); // $project_id = $this->input->post('project_id'); // $dues_option = $this->input->post('dues_option'); // if($dues_option == 'dues') // { // $remarks = $this->input->post('remarks_added'); // } // else // { // $remarks = ""; // } // $agreement_confirming_type =$this->input->post('owners_type1'); // $check_site = $this->gss_model->project_details($site_number,$project_id); // if($check_site) // { // $site_result = $this->gss_model->individual_payment_site_booking_details($site_number,$project_id,$booking_id); // //$tsvamount= $tsv-($site_result->booking_amount1 +$site_result->booking_amount2); // if($site_result) // { // $tsvamount= $tsv-($site_result->booking_amount1 +$site_result->booking_amount2); // if($site_result->booking_status == 'CANCELLED') // { // echo json_encode(array('result'=>3,'message'=>'Site number '.$site_number.' has been cancelled')); // } // else // { // $regn_cheque_no = $this->input->post('regn_cheque_no'); // $regn_cheque_date = $this->input->post('regn_cheque_date'); // if($regn_cheque_date != "") // { // /*$date = new DateTime($regn_cheque_date); // $regn_cheque_date = $date->format('Y-m-d');*/ // $regn_cheque_date = date('Y-m-d',strtotime($regn_cheque_date)); // } // else // { // $regn_cheque_date =""; // } // $regn_bank_name = $this->input->post('regn_bank_name'); // $regn_vtr_no = $this->input->post('regn_vtr_no'); // $regn_online_date = $this->input->post('regn_online_date'); // if($regn_online_date != "") // { // /*$date = new DateTime($regn_online_date); // $regn_online_date = $date->format('Y-m-d');*/ // $regn_online_date = date('Y-m-d',strtotime($regn_online_date)); // } // else // { // $regn_online_date =""; // } // $regn_dd_no = $this->input->post('regn_dd_no'); // $regn_dd_date = $this->input->post('regn_dd_date'); // if($regn_dd_date != "") // { // /*$date = new DateTime($regn_dd_date); // $regn_dd_date = $date->format('Y-m-d');*/ // $regn_dd_date = date('Y-m-d',strtotime($regn_dd_date)); // } // else // { // $regn_dd_date =""; // } // $regn_dd_bank = $this->input->post('regn_dd_bank'); // $regn_ref_no =$this->input->post('regn_ref_no'); // $regn_paytm_date =$this->input->post('regn_paytm_date'); // if($regn_paytm_date != "") // { // /*$date = new DateTime($regn_dd_date); // $regn_dd_date = $date->format('Y-m-d');*/ // $regn_paytm_date = date('Y-m-d',strtotime($regn_paytm_date)); // } // else // { // $regn_paytm_date =""; // } // $regn_upiref_no =$this->input->post('regn_upiref_no'); // $regn_upi_date =$this->input->post('regn_upi_date'); // if($regn_upi_date != "") // { // /*$date = new DateTime($regn_dd_date); // $regn_dd_date = $date->format('Y-m-d');*/ // $regn_upi_date = date('Y-m-d',strtotime($regn_upi_date)); // } // else // { // $regn_upi_date =""; // } // $cash_date =$this->input->post('cash_date'); // if($cash_date != "") // { // /*$date = new DateTime($regn_dd_date); // $regn_dd_date = $date->format('Y-m-d');*/ // $cash_date = date('Y-m-d',strtotime($cash_date)); // } // else // { // $cash_date =""; // } // $swipe_date =$this->input->post('swipe_date'); // if($swipe_date != "") // { // /*$date = new DateTime($regn_dd_date); // $regn_dd_date = $date->format('Y-m-d');*/ // $swipe_date = date('Y-m-d',strtotime($swipe_date)); // } // else // { // $swipe_date =""; // } // $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); // $created_at = $date->format('Y-m-d H:i:s'); // $where1 = array('booking_id'=>$booking_id,'detail_id'=>$detail_id,'delete_status'=>'ACTIVE'); // $check_ids = $this->gss_model->get_where_payment_id_result($payment_table,$where1); // $whereloan1 = array('booking_id'=>$booking_id,'detail_id'=>$detail_id,'delete_status'=>'ACTIVE'); // $check_idsloan = $this->gss_model->get_where_multireg_id_result($multireg_table,$whereloan1); // $notifications = $this->gss_model->check_notification($booking_id,$detail_id); // $booking_table = 'gss_bookings'; // $where_booking = array('booking_id'=>$booking_id); // $notification_table = 'gss_commission_notifications'; // if($notifications) // { // if($notifications->commission_agreement == "Not Available" && $sale_agree_amount != "") // { // $commission_agreement = 'Available'; // $notification_data = array( // 'booking_id' => $booking_id, // 'commission_agreement' => $commission_agreement // ); // $update = $this->gss_model->update($where_booking,$notification_table,$notification_data); // } // if($notifications->commission_registration == "Not Available" && $reg_due_amount != "") // { // $commission_registration = 'Available'; // $notification_data = array( // 'booking_id' => $booking_id, // 'commission_registration' => $commission_registration // ); // $update = $this->gss_model->update($where_booking,$notification_table,$notification_data); // } // } // else // { // if($sale_agree_amount != "") // { // $commission_agreement = 'Available'; // } // else // { // $commission_agreement = "Not Available"; // } // if($reg_due_amount != "") // { // $commission_registration = 'Available'; // } // else // { // $commission_registration = "Not Available"; // } // $notification_data = array( // 'booking_id' => $booking_id, // 'detail_id' => $detail_id, // 'commission_agreement' => $commission_agreement, // 'commission_registration' => $commission_registration, // 'status' => 'PENDING' // ); // $check_associate = $this->gss_model->get_where_row($booking_table,$where_booking); // if($check_associate->associate != 0) // { // $commission_result = $this->gss_model->insert($notification_table,$notification_data); // } // } // if($check_ids) // { // /* foreach($check_ids as $id) // { // //echo $id->payment_id; // $deletetable='gss_plot_payment_types'; // $deletewhere=array('payment_id'=> $id->payment_id); // $drop=$this->gss_model->delete($deletetable,$deletewhere); // $deletetable1='gss_plot_payments'; // $deletewhere1=array('payment_id'=> $id->payment_id); // $this->gss_model->delete($deletetable1,$deletewhere1); // }*/ // $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); // $created_at = $date->format('Y-m-d H:i:s'); // $total = 0; // $arr = array(); // if(!empty($instalement_amount1)) // { // //$instal_amt = array_sum($instalement_amount1); // $instal_amt = array_sum($instalement_amount1); // } // else // { // $instal_amt = 0; // } // if(!empty($loanreg_due_amount1)) // { // $reg_amt = array_sum($loanreg_due_amount1); // } // else // { // $reg_amt=0; // } // if($sale_agree_amount!="" && $reg_due_amount!="") // { // $total = $sale_agree_amount + $instal_amt + $reg_due_amount + $reg_amt; // } // else if($sale_agree_amount!="" && $reg_due_amount=="") // { // $reg_due_amount=0; // $total = $sale_agree_amount + $instal_amt + $reg_due_amount + $reg_amt; // } // else if($sale_agree_amount=="" && $reg_due_amount!="") // { // $sale_agree_amount=0; // $total = $sale_agree_amount + $instal_amt + $reg_due_amount +$reg_amt; // } // if($total > $tsvamount) // { // echo json_encode(array('result'=>3,'message'=>"Not matching TSV")); // } // else // { // foreach($check_ids as $id) // { // //echo $id->payment_id; // $deletetable='gss_plot_payment_types'; // $deletewhere=array('payment_id'=> $id->payment_id); // $drop=$this->gss_model->delete($deletetable,$deletewhere); // $deletetable1='gss_plot_payments'; // $deletewhere1=array('payment_id'=> $id->payment_id); // $this->gss_model->delete($deletetable1,$deletewhere1); // } // $data10=array(); // if($instalement_amount1 != "") // { // foreach($instalement_amount1 as $key=>$val) // { // $installment_confirming_type =$this->input->post('installment_confirming_type'.$key); // //$registration_confirming_type=$this->input->post('registration_confirming_types'.$key); // $registration_confirming_type=$this->input->post('registration_confirming_type'); // $payment_data = array( // 'booking_id' => $booking_id, // 'detail_id' => $detail_id, // 'agreement_amount' => $sale_agree_amount, // 'agreement_date' => $sale_agree_date, // 'agreement_payment_mode' => $agreement_payment_type, // 'agreement_confirming_type' => $agreement_confirming_type, // 'installment_amount1' => $instalement_amount1[$key], // 'installment_payment_mode1' => $instalment_payment_type1[$key], // 'installment1_date' => $installment_date1[$key], // 'installment_confirming_type' => $installment_confirming_type, // 'registration_amount' => $reg_due_amount, // 'registration_value' => $reg_value, // 'regn_amount_type' =>$regn_amount_type, // 'loan_from' =>$loan_from, // 'registration_date' => $registration_date, // 'registration_payment_mode' => $regn_payment_type, // 'registration_status' => $reg_status, // 'registration_confirming_type' => $registration_confirming_type, // //'registration_done_date' =>$registration1_date, // 'membership_amount' => $membership_amount, // 'maintenence_amount' => $main_amount, // 'no_of_years' => $no_of_years, // 'dues_option' => $dues_option, // 'remarks' => $remarks, // 'delete_status' => 'ACTIVE', // 'created_at' => $created_at // ); // $result = $this->gss_model->insert($payment_table,$payment_data); // array_push($data10,$result); // } // } // else // { // $registration_confirming_type=$this->input->post('registration_confirming_type'); // $payment_data = array( // 'booking_id' => $booking_id, // 'detail_id' => $detail_id, // 'agreement_amount' => $sale_agree_amount, // 'agreement_date' => $sale_agree_date, // 'agreement_payment_mode' => $agreement_payment_type, // 'agreement_confirming_type' => $agreement_confirming_type, // 'installment_amount1' => '', // 'installment_payment_mode1' => '', // 'installment1_date' => '', // 'registration_amount' => $reg_due_amount, // 'registration_value' => $reg_value, // 'regn_amount_type' =>$regn_amount_type, // 'loan_from' =>$loan_from, // 'registration_date' => $registration_date, // 'registration_payment_mode' => $regn_payment_type, // 'registration_status' => $reg_status, // 'registration_confirming_type' => $registration_confirming_type, // //'registration_done_date' =>$registration1_date, // 'membership_amount' => $membership_amount, // 'maintenence_amount' => $main_amount, // 'no_of_years' => $no_of_years, // 'dues_option' => $dues_option, // 'remarks' => $remarks, // 'delete_status' => 'ACTIVE', // 'created_at' => $created_at // ); // $res_id = $this->gss_model->insert($payment_table,$payment_data); // } // $data9=array(); // $type_dataa = []; // if(!empty($instalement_amount1)) // { // foreach($instalement_amount1 as $key=>$val) // { // if($val != "") // { // if($instalment_payment_type1[$key] == 'Cheque') // { // $installment_cheque_no =$this->input->post('instalment_cheque_no2'.$key); // $installment_cheque_date=$this->input->post('instalment_cheque_date2'.$key); // $instalment_bank_name=$this->input->post('instalment_bank_name2'.$key); // $type_dataa = array( // 'install_cheque_no1' => $installment_cheque_no, // 'install_cheque_date1' =>$installment_cheque_date, // 'install_bank1' => $instalment_bank_name, // 'install_vtr_no1' => ' ', // 'install_online_date1' => ' ', // 'install_dd_no1' => ' ', // 'install_dd_date1' => ' ', // 'install_dd_bank1' => ' ', // 'paytm_ref_no' =>' ', // 'paytm_online_date1' =>' ', // 'upi_ref_no' =>' ', // 'upi_online_date1'=>' ', // 'install_cash_date' => '', // 'install_swipe_date' =>'', // 'payment_id' => $data10[$key], // ); // } // else if($instalment_payment_type1[$key] == 'Online Payment') // { // $installment_vtr_no =$this->input->post('instalment_vtr_no2'.$key); // $installment_online_date=$this->input->post('instalment_online_date2'.$key); // $type_dataa = array( // 'install_cheque_no1' => '', // 'install_cheque_date1' =>'', // 'install_bank1' => '', // 'install_vtr_no1' => $installment_vtr_no, // 'install_online_date1' => $installment_online_date, // 'install_dd_no1' => '', // 'install_dd_date1' => '', // 'install_dd_bank1' => '', // 'paytm_ref_no' =>' ', // 'paytm_online_date1' =>' ', // 'upi_ref_no' =>' ', // 'upi_online_date1'=>' ', // 'install_cash_date' => '', // 'install_swipe_date' =>'', // 'payment_id' => $data10[$key], // ); // } // else if($instalment_payment_type1[$key] == 'DD') // { // $installment_dd_no =$this->input->post('installment_dd_no2'.$key); // $installment_dd_date=$this->input->post('installment_dd_date2'.$key); // $installment_dd_bank=$this->input->post('installment_dd_bank2'.$key); // $type_dataa = array( // 'install_cheque_no1' => '', // 'install_cheque_date1' =>'', // 'install_bank1' => '', // 'install_vtr_no1' => '', // 'install_online_date1' => '', // 'install_dd_no1' => $installment_dd_no, // 'install_dd_date1' => $installment_dd_date, // 'install_dd_bank1' => $installment_dd_bank, // 'paytm_ref_no' =>' ', // 'paytm_online_date1' =>' ', // 'upi_ref_no' =>' ', // 'upi_online_date1'=>' ', // 'install_cash_date' => '', // 'install_swipe_date' =>'', // 'payment_id' => $data10[$key], // ); // } // else if($instalment_payment_type1[$key] == 'Paytm Payment') // { // $paytm_ref_no =$this->input->post('paytm_ref_no2'.$key); // $paytm_online_date=$this->input->post('paytm_online_date2'.$key); // $type_dataa = array( // 'install_cheque_no1' => '', // 'install_cheque_date1' =>'', // 'install_bank1' => '', // 'install_vtr_no1' => '', // 'install_online_date1' => '', // 'install_dd_no1' => ' ', // 'install_dd_date1' => ' ', // 'install_dd_bank1' =>' ' , // 'paytm_ref_no' =>$paytm_ref_no, // 'paytm_online_date1' =>$paytm_online_date, // 'upi_ref_no' =>' ', // 'upi_online_date1'=>' ', // 'install_cash_date' => '', // 'install_swipe_date' =>'', // 'payment_id' => $data10[$key], // ); // } // else if($instalment_payment_type1[$key] == 'UPI Payment') // { // $upi_ref_no =$this->input->post('upi_ref_no2'.$key); // $upi_online_date=$this->input->post('upi_online_date2'.$key); // $type_dataa = array( // 'install_cheque_no1' => '', // 'install_cheque_date1' =>'', // 'install_bank1' => '', // 'install_vtr_no1' => '', // 'install_online_date1' => '', // 'install_dd_no1' => ' ', // 'install_dd_date1' => ' ', // 'install_dd_bank1' => ' ', // 'paytm_ref_no' =>' ', // 'paytm_online_date1' =>' ', // 'upi_ref_no' =>$upi_ref_no, // 'upi_online_date1'=>$upi_online_date, // 'install_cash_date' => '', // 'install_swipe_date' =>'', // 'payment_id' => $data10[$key], // ); // } // else if($instalment_payment_type1[$key] == 'Cash') // { // $install_cash_date2 =$this->input->post('install_cash_date2'.$key); // $type_dataa = array( // 'install_cheque_no1' => '', // 'install_cheque_date1' =>'', // 'install_bank1' => '', // 'install_vtr_no1' => '', // 'install_online_date1' => '', // 'install_dd_no1' => '', // 'install_dd_date1' => '', // 'install_dd_bank1' => '', // 'paytm_ref_no' =>' ', // 'paytm_online_date1' =>' ', // 'upi_ref_no' =>' ', // 'upi_online_date1'=>' ', // 'install_cash_date' => $install_cash_date2, // 'install_swipe_date' =>'', // 'payment_id' => $data10[$key], // ); // } // else if($instalment_payment_type1[$key] == 'Swipe') // { // $install_swipe_date2 =$this->input->post('install_swipe_date2'.$key); // $type_dataa = array( // 'install_cheque_no1' => '', // 'install_cheque_date1' =>'', // 'install_bank1' => '', // 'install_vtr_no1' => '', // 'install_online_date1' => '', // 'install_dd_no1' => '', // 'install_dd_date1' => '', // 'install_dd_bank1' => '', // 'paytm_ref_no' =>' ', // 'paytm_online_date1' =>' ', // 'upi_ref_no' =>' ', // 'upi_online_date1'=>' ', // 'install_cash_date' => '', // 'install_swipe_date' =>$install_swipe_date2, // 'payment_id' => $data10[$key], // ); // } // $type_table='gss_plot_payment_types'; // $resulttt = $this->gss_model->insert($type_table,$type_dataa); // array_push($data9,$resulttt); // } // } // } // else // { // if($agreement_payment_type == 'Cheque') // { // $type_data = array( // 'agreement_cheque_no' => $agreement_cheque_no, // 'agreement_cheque_date' =>$agreement_cheque_date, // 'agreement_bank' => $agreement_bank_name, // 'agreement_vtr_no' => '', // 'agreement_online_date' => '', // 'agreement_dd_no' => '', // 'agreement_dd_date' => '', // 'agreement_dd_bank' => '', // 'agreementpaytm_ref_no'=>'', // 'agreementpaytm_online_date1'=> '', // 'agreementupi_ref_no' =>'', // 'agreementupi_online_date1' =>'', // 'payment_id' => $res_id, // ); // } // else if($agreement_payment_type == 'Online Payment') // { // $type_data = array( // 'agreement_cheque_no' => '', // 'agreement_cheque_date' =>'', // 'agreement_bank' => '', // 'agreement_vtr_no' => $agreement_vtr_no, // 'agreement_online_date' => $agreement_online_date, // 'agreement_dd_no' => '', // 'agreement_dd_date' => '', // 'agreement_dd_bank' => '', // 'agreementpaytm_ref_no'=>'', // 'agreementpaytm_online_date1'=> '', // 'agreementupi_ref_no' =>'', // 'agreementupi_online_date1' =>'', // 'payment_id' => $res_id, // ); // } // else if($agreement_payment_type == 'DD') // { // $type_data = array( // 'agreement_cheque_no' => '', // 'agreement_cheque_date' =>'', // 'agreement_bank' => '', // 'agreement_vtr_no' => '', // 'agreement_online_date' => '', // 'agreement_dd_no' =>$agreement_dd_no, // 'agreement_dd_date' => $agreement_dd_date, // 'agreement_dd_bank' => $agreement_dd_bank, // 'agreementpaytm_ref_no'=>'', // 'agreementpaytm_online_date1'=> '', // 'agreementupi_ref_no' =>'', // 'agreementupi_online_date1' =>'', // 'payment_id' => $res_id, // ); // } // else if($agreement_payment_type == 'Paytm Payment') // { // $type_data = array( // 'agreement_cheque_no' => '', // 'agreement_cheque_date' =>'', // 'agreement_bank' => '', // 'agreement_vtr_no' => '', // 'agreement_online_date' => '', // 'agreement_dd_no' => '', // 'agreement_dd_date' => '', // 'agreement_dd_bank' => '', // 'agreementpaytm_ref_no'=> $agreementpaytm_ref_no, // 'agreementpaytm_online_date1'=> $agreementpaytm_online_date, // 'agreementupi_ref_no' =>'', // 'agreementupi_online_date1' =>'', // 'payment_id' => $res_id, // ); // } // else if($agreement_payment_type == 'UPI Payment') // { // $type_data = array( // 'agreement_cheque_no' => '', // 'agreement_cheque_date' =>'', // 'agreement_bank' => '', // 'agreement_vtr_no' => '', // 'agreement_online_date' => '', // 'agreement_dd_no' => '', // 'agreement_dd_date' => '', // 'agreement_dd_bank' => '', // 'agreementpaytm_ref_no'=> '', // 'agreementpaytm_online_date1'=> '', // 'agreementupi_ref_no' =>$agreementupi_ref_no, // 'agreementupi_online_date1' =>$agreementupi_online_date, // 'payment_id' => $res_id, // ); // } // else if($agreement_payment_type == 'Cash') // { // $type_data = array( // 'agreement_cheque_no' => '', // 'agreement_cheque_date' =>'', // 'agreement_bank' => '', // 'agreement_vtr_no' => '', // 'agreement_online_date' => '', // 'agreement_dd_no' =>'', // 'agreement_dd_date' => '', // 'agreement_dd_bank' => '', // 'agreementpaytm_ref_no'=>'', // 'agreementpaytm_online_date1'=> '', // 'agreementupi_ref_no' =>'', // 'agreementupi_online_date1' =>'', // 'payment_id' => $res_id, // ); // } // $type_table='gss_plot_payment_types'; // $up_res_id = $this->gss_model->insert($type_table,$type_data); // } // if($instalment_payment_type1 != "") // { // foreach($instalment_payment_type1 as $key=>$val) // { // $type_data = array( // 'payment_id' => $data10[$key], // 'agreement_cheque_no' => $agreement_cheque_no, // 'agreement_cheque_date' => $agreement_cheque_date, // 'agreement_bank' => $agreement_bank_name, // 'agreement_vtr_no' => $agreement_vtr_no, // 'agreement_online_date' => $agreement_online_date, // 'agreement_dd_no' => $agreement_dd_no, // 'agreement_dd_date' => $agreement_dd_date, // 'agreement_dd_bank' => $agreement_dd_bank, // //varuuu // 'agreementpaytm_ref_no' =>$agreementpaytm_ref_no, // 'agreementpaytm_online_date1' =>$agreementpaytm_online_date, // 'agreementupi_ref_no' =>$agreementupi_ref_no, // 'agreementupi_online_date1' =>$agreementupi_online_date, // 'regn_cheque_no' => $regn_cheque_no, // 'regn_cheque_date' => $regn_cheque_date, // 'regn_bank' => $regn_bank_name, // 'regn_vtr_no' => $regn_vtr_no, // 'regn_online_date' => $regn_online_date, // 'regn_dd_no' => $regn_dd_no, // 'regn_dd_date' => $regn_dd_date, // 'regn_dd_bank' => $regn_dd_bank, // //varu // 'regn_ref_no' =>$regn_ref_no, // 'regn_paytm_date'=>$regn_paytm_date, // 'regn_upiref_no' =>$regn_upiref_no, // 'regn_upi_date' =>$regn_upi_date, // 'cash_date'=>$cash_date, // 'swipe_date'=>$swipe_date, // 'delete_status' => 'ACTIVE', // 'created_at' => $created_at, // ); // $table='gss_plot_payment_types'; // $where=array('type_id'=>$data9[$key]); // $this->gss_model->update($where,$table,$type_data); // } // }else{ // $type_data = array( // 'payment_id' => $res_id, // 'agreement_cheque_no' => $agreement_cheque_no, // 'agreement_cheque_date' => $agreement_cheque_date, // 'agreement_bank' => $agreement_bank_name, // 'agreement_vtr_no' => $agreement_vtr_no, // 'agreement_online_date' => $agreement_online_date, // 'agreement_dd_no' => $agreement_dd_no, // 'agreement_dd_date' => $agreement_dd_date, // 'agreement_dd_bank' => $agreement_dd_bank, // 'agreementpaytm_ref_no' =>$agreementpaytm_ref_no, // //varu // 'agreementpaytm_online_date1' =>$agreementpaytm_online_date, // 'agreementupi_ref_no' =>$agreementupi_ref_no, // 'agreementupi_online_date1' =>$agreementupi_online_date, // 'regn_cheque_no' => $regn_cheque_no, // 'regn_cheque_date' => $regn_cheque_date, // 'regn_bank' => $regn_bank_name, // 'regn_vtr_no' => $regn_vtr_no, // 'regn_online_date' => $regn_online_date, // 'regn_dd_no' => $regn_dd_no, // 'regn_dd_date' => $regn_dd_date, // 'regn_dd_bank' => $regn_dd_bank, // 'regn_ref_no' =>$regn_ref_no, // 'regn_paytm_date'=>$regn_paytm_date, // 'regn_upiref_no' =>$regn_upiref_no, // 'regn_upi_date' =>$regn_upi_date, // 'cash_date'=>$cash_date, // 'swipe_date'=>$swipe_date, // 'delete_status' => 'ACTIVE', // 'created_at' => $created_at, // ); // $table='gss_plot_payment_types'; // $where=array('type_id'=>$up_res_id); // $this->gss_model->update($where,$table,$type_data); // } // if($check_idsloan) // { // foreach($check_idsloan as $ids) // { // $deletetable='gss_registration_amount_details'; // $deletewhere=array('id'=> $ids->id); // $drop=$this->gss_model->delete($deletetable,$deletewhere); // } // if($loanreg_due_amount1 != "") // { // foreach($loanreg_due_amount1 as $key=>$val) // { // $registration_confirming_types=$this->input->post('registration_confirming_types'); // $multireg_data = array( // 'booking_id' => $booking_id, // 'detail_id' => $detail_id, // 'reg_amount ' => $loanreg_due_amount1[$key], // //'reg_date' => $loanreg_status1[$key], // 'reg_payment_mode' => $loanregn_payment_type1[$key], // 'number' => $loanregn_no1[$key], // 'mode_date' => $loanregndate1[$key], // 'branch_name' => $loanregn_bank1[$key], // 'loan_type' =>$loanregn_amount_type[$key], // 'loan_from' =>$loanloan_from[$key], // 'registration_confirming_type' =>$registration_confirming_types[$key], // 'delete_status' => 'ACTIVE', // 'created_at' => $created_at // ); // $result = $this->gss_model->insert($multireg_table,$multireg_data); // } // } // } // else // { // if($loanreg_due_amount1 != "") // { // foreach($loanreg_due_amount1 as $key=>$val) // { // $registration_confirming_types=$this->input->post('registration_confirming_types'); // $multireg_data = array( // 'booking_id' => $booking_id, // 'detail_id' => $detail_id, // 'reg_amount ' => $loanreg_due_amount1[$key], // //'reg_date' => $loanreg_status1[$key], // 'reg_payment_mode' => $loanregn_payment_type1[$key], // 'number' => $loanregn_no1[$key], // 'mode_date' => $loanregndate1[$key], // 'branch_name' => $loanregn_bank1[$key], // 'loan_type' =>$loanregn_amount_type[$key], // 'loan_from' =>$loanloan_from[$key], // 'registration_confirming_type' =>$registration_confirming_types[$key], // 'delete_status' => 'ACTIVE', // 'created_at' => $created_at // ); // $result = $this->gss_model->insert($multireg_table,$multireg_data); // } // } // } // echo json_encode(array('result'=>1,'message'=>" successfully Updated")); // } // } // else // { // $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); // $created_at = $date->format('Y-m-d H:i:s'); // $total = 0; // $arr = array(); // if(!empty($instalement_amount1)) // { // $instal_amt = array_sum($instalement_amount1); // } // else // { // $instal_amt = 0; // } // if(!empty($loanreg_due_amount1)) // { // $reg_amt = array_sum($loanreg_due_amount1); // } // else // { // $reg_amt=0; // } // if($sale_agree_amount!="" && $reg_due_amount!="") // { // $total = $sale_agree_amount + $instal_amt+$reg_due_amount+$reg_amt; // } // else if($sale_agree_amount!="" && $reg_due_amount=="") // { // $reg_due_amount=0; // $total = $sale_agree_amount + $instal_amt+$reg_due_amount+$reg_amt; // } // else if($sale_agree_amount=="" && $reg_due_amount!="") // { // $sale_agree_amount=0; // $total = $sale_agree_amount + $instal_amt+$reg_due_amount+$reg_amt; // } // if($total > $tsvamount) // { // echo json_encode(array('result'=>3,'message'=>"Not matching TSV")); // } // else // { // $data10=array(); // if($instalement_amount1 != "") // { // foreach($instalement_amount1 as $key=>$val) // { // $installment_confirming_type =$this->input->post('installment_confirming_type'.$key); // //$registration_confirming_type=$this->input->post('registration_confirming_types'.$key); // $registration_confirming_type=$this->input->post('registration_confirming_type'); // $payment_data = array( // 'booking_id' => $booking_id, // 'detail_id' => $detail_id, // 'agreement_amount' => $sale_agree_amount, // 'agreement_date' => $sale_agree_date, // 'agreement_payment_mode' => $agreement_payment_type, // 'agreement_confirming_type' => $agreement_confirming_type, // 'installment_amount1' => $instalement_amount1[$key], // 'installment_payment_mode1' => $instalment_payment_type1[$key], // 'installment1_date' => $installment_date1[$key], // 'installment_confirming_type' => $installment_confirming_type, // 'registration_amount' => $reg_due_amount, // 'registration_value' => $reg_value, // 'regn_amount_type' =>$regn_amount_type, // 'loan_from' =>$loan_from, // 'registration_date' => $registration_date, // 'registration_payment_mode' => $regn_payment_type, // 'registration_status' => $reg_status, // 'registration_confirming_type' => $registration_confirming_type, // //'registration_done_date' =>$registration1_date, // 'membership_amount' => $membership_amount, // 'maintenence_amount' => $main_amount, // 'no_of_years' => $no_of_years, // 'delete_status' => 'ACTIVE', // 'dues_option' => $dues_option, // 'remarks' => $remarks, // 'created_at' => $created_at // ); // $result = $this->gss_model->insert($payment_table,$payment_data); // array_push($data10,$result); // } // } // else // { // $registration_confirming_type=$this->input->post('registration_confirming_type'); // $payment_data = array( // 'booking_id' => $booking_id, // 'detail_id' => $detail_id, // 'agreement_amount' => $sale_agree_amount, // 'agreement_date' => $sale_agree_date, // 'agreement_payment_mode' => $agreement_payment_type, // 'agreement_confirming_type' => $agreement_confirming_type, // 'installment_amount1' => '', // 'installment_payment_mode1' => '', // 'installment1_date' => '', // 'installment_confirming_type' => '', // 'registration_amount' => $reg_due_amount, // 'registration_value' => $reg_value, // 'regn_amount_type' =>$regn_amount_type, // 'loan_from' =>$loan_from, // 'registration_date' => $registration_date, // 'registration_payment_mode' => $regn_payment_type, // 'registration_status' => $reg_status, // 'registration_confirming_type' => $registration_confirming_type, // //'registration_done_date' =>$registration1_date, // 'membership_amount' => $membership_amount, // 'maintenence_amount' => $main_amount, // 'no_of_years' => $no_of_years, // 'delete_status' => 'ACTIVE', // 'dues_option' => $dues_option, // 'remarks' => $remarks, // 'created_at' => $created_at // ); // $res_id = $this->gss_model->insert($payment_table,$payment_data); // } // $data9=array(); // if($instalement_amount1 != "") // { // foreach($instalement_amount1 as $key=>$val) // { // if($instalment_payment_type1[$key] == 'Cheque') // { // $installment_cheque_no =$this->input->post('instalment_cheque_no2'.$key); // $installment_cheque_date=$this->input->post('instalment_cheque_date2'.$key); // $instalment_bank_name=$this->input->post('instalment_bank_name2'.$key); // $type_dataa = array( // 'install_cheque_no1' => $installment_cheque_no, // 'install_cheque_date1' =>$installment_cheque_date, // 'install_bank1' => $instalment_bank_name, // 'install_vtr_no1' => ' ', // 'install_online_date1' => ' ', // 'install_dd_no1' => ' ', // 'install_dd_date1' => ' ', // 'install_dd_bank1' => ' ', // 'paytm_ref_no' =>' ', // 'paytm_online_date1' =>' ', // 'upi_ref_no' =>' ', // 'upi_online_date1'=>' ', // 'install_cash_date' => '', // 'install_swipe_date' =>'', // 'payment_id' => $data10[$key], // ); // $type_table='gss_plot_payment_types'; // $resulttt = $this->gss_model->insert($type_table,$type_dataa); // array_push($data9,$resulttt); // } // else if($instalment_payment_type1[$key] == 'Online Payment') // { // $installment_vtr_no =$this->input->post('instalment_vtr_no2'.$key); // $installment_online_date=$this->input->post('instalment_online_date2'.$key); // $type_dataa = array( // 'install_cheque_no1' => '', // 'install_cheque_date1' =>'', // 'install_bank1' => '', // 'install_vtr_no1' => $installment_vtr_no, // 'install_online_date1' => $installment_online_date, // 'install_dd_no1' => '', // 'install_dd_date1' => '', // 'install_dd_bank1' => '', // 'paytm_ref_no' =>' ', // 'paytm_online_date1' =>' ', // 'upi_ref_no' =>' ', // 'upi_online_date1'=>' ', // 'install_cash_date' => '', // 'install_swipe_date' =>'', // 'payment_id' => $data10[$key], // ); // $type_table='gss_plot_payment_types'; // $resulttt = $this->gss_model->insert($type_table,$type_dataa); // array_push($data9,$resulttt); // } // else if($instalment_payment_type1[$key] == 'DD') // { // $installment_dd_no =$this->input->post('installment_dd_no2'.$key); // $installment_dd_date=$this->input->post('installment_dd_date2'.$key); // $installment_dd_bank=$this->input->post('installment_dd_bank2'.$key); // $type_dataa = array( // 'install_cheque_no1' => '', // 'install_cheque_date1' =>'', // 'install_bank1' => '', // 'install_vtr_no1' => '', // 'install_online_date1' => '', // 'install_dd_no1' => $installment_dd_no, // 'install_dd_date1' => $installment_dd_date, // 'install_dd_bank1' => $installment_dd_bank, // 'paytm_ref_no' =>' ', // 'paytm_online_date1' =>' ', // 'upi_ref_no' =>' ', // 'upi_online_date1'=>' ', // 'install_cash_date' => '', // 'install_swipe_date' =>'', // 'payment_id' => $data10[$key], // ); // $type_table='gss_plot_payment_types'; // $resulttt = $this->gss_model->insert($type_table,$type_dataa); // array_push($data9,$resulttt); // } // else if($instalment_payment_type1[$key] == 'Paytm Payment') // { // $paytm_ref_no =$this->input->post('paytm_ref_no2'.$key); // $paytm_online_date=$this->input->post('paytm_online_date2'.$key); // $type_dataa = array( // 'install_cheque_no1' => '', // 'install_cheque_date1' =>'', // 'install_bank1' => '', // 'install_vtr_no1' => '', // 'install_online_date1' => '', // 'install_dd_no1' => ' ', // 'install_dd_date1' => ' ', // 'install_dd_bank1' =>' ' , // 'paytm_ref_no' =>$paytm_ref_no, // 'paytm_online_date1' =>$paytm_online_date, // 'upi_ref_no' =>' ', // 'upi_online_date1'=>' ', // 'install_cash_date' => '', // 'install_swipe_date' =>'', // 'payment_id' => $data10[$key], // ); // $type_table='gss_plot_payment_types'; // $resulttt = $this->gss_model->insert($type_table,$type_dataa); // array_push($data9,$resulttt); // } // else if($instalment_payment_type1[$key] == 'UPI Payment') // { // $upi_ref_no =$this->input->post('upi_ref_no2'.$key); // $upi_online_date=$this->input->post('upi_online_date2'.$key); // $type_dataa = array( // 'install_cheque_no1' => '', // 'install_cheque_date1' =>'', // 'install_bank1' => '', // 'install_vtr_no1' => '', // 'install_online_date1' => '', // 'install_dd_no1' => ' ', // 'install_dd_date1' => ' ', // 'install_dd_bank1' => ' ', // 'paytm_ref_no' =>' ', // 'paytm_online_date1' =>' ', // 'upi_ref_no' =>$upi_ref_no, // 'upi_online_date1'=>$upi_online_date, // 'install_cash_date' => '', // 'install_swipe_date' =>'', // 'payment_id' => $data10[$key], // ); // $type_table='gss_plot_payment_types'; // $resulttt = $this->gss_model->insert($type_table,$type_dataa); // array_push($data9,$resulttt); // } // else if($instalment_payment_type1[$key] == 'Cash') // { // $install_cash_date2=$this->input->post('install_cash_date2'.$key); // $type_dataa = array( // 'install_cheque_no1' => '', // 'install_cheque_date1' =>'', // 'install_bank1' => '', // 'install_vtr_no1' => '', // 'install_online_date1' => '', // 'install_dd_no1' => '', // 'install_dd_date1' => '', // 'install_dd_bank1' => '', // 'paytm_ref_no' =>' ', // 'paytm_online_date1' =>' ', // 'upi_ref_no' =>' ', // 'upi_online_date1'=>' ', // 'install_cash_date' => $install_cash_date2, // 'install_swipe_date' =>'', // 'payment_id' => $data10[$key], // ); // $type_table='gss_plot_payment_types'; // $resulttt = $this->gss_model->insert($type_table,$type_dataa); // array_push($data9,$resulttt); // } // else if($instalment_payment_type1[$key] == 'Swipe') // { // $install_swipe_date2=$this->input->post('install_swipe_date2'.$key); // $type_dataa = array( // 'install_cheque_no1' => '', // 'install_cheque_date1' =>'', // 'install_bank1' => '', // 'install_vtr_no1' => '', // 'install_online_date1' => '', // 'install_dd_no1' => '', // 'install_dd_date1' => '', // 'install_dd_bank1' => '', // 'paytm_ref_no' =>' ', // 'paytm_online_date1' =>' ', // 'upi_ref_no' =>' ', // 'upi_online_date1'=>' ', // 'install_cash_date' => '', // 'install_swipe_date' =>$install_swipe_date2, // 'payment_id' => $data10[$key], // ); // $type_table='gss_plot_payment_types'; // $resulttt = $this->gss_model->insert($type_table,$type_dataa); // array_push($data9,$resulttt); // } // else // { // $type_dataa = array( // 'install_cheque_no1' => '', // 'install_cheque_date1' =>'', // 'install_bank1' => '', // 'install_vtr_no1' => '', // 'install_online_date1' => '', // 'install_dd_no1' => '', // 'install_dd_date1' => '', // 'install_dd_bank1' => '', // 'paytm_ref_no' =>' ', // 'paytm_online_date1' =>' ', // 'upi_ref_no' =>' ', // 'upi_online_date1'=>' ', // 'install_cash_date' => '', // 'install_swipe_date' =>'', // 'payment_id' => $data10[$key], // ); // $type_table='gss_plot_payment_types'; // $resulttt = $this->gss_model->insert($type_table,$type_dataa); // array_push($data9,$resulttt); // } // } // } // else // { // if($agreement_payment_type == 'Cheque') // { // $type_data = array( // 'agreement_cheque_no' => $agreement_cheque_no, // 'agreement_cheque_date' =>$agreement_cheque_date, // 'agreement_bank' => $agreement_bank_name, // 'agreement_vtr_no' => '', // 'agreement_online_date' => '', // 'agreement_dd_no' => '', // 'agreement_dd_date' => '', // 'agreement_dd_bank' => '', // 'agreementpaytm_ref_no' =>'', // 'agreementpaytm_online_date1'=>'', // 'agreementupi_ref_no'=>'', // 'agreementupi_online_date1' =>'', // 'payment_id' => $res_id, // ); // } // else if($agreement_payment_type == 'Online Payment') // { // $type_data = array( // 'agreement_cheque_no' => '', // 'agreement_cheque_date' =>'', // 'agreement_bank' => '', // 'agreement_vtr_no' => $agreement_vtr_no, // 'agreement_online_date' => $agreement_online_date, // 'agreement_dd_no' => '', // 'agreement_dd_date' => '', // 'agreement_dd_bank' => '', // 'agreementpaytm_ref_no' =>'', // 'agreementpaytm_online_date1'=>'', // 'agreementupi_ref_no'=>'', // 'agreementupi_online_date1' =>'', // 'payment_id' => $res_id, // ); // } // else if($agreement_payment_type == 'DD') // { // $type_data = array( // 'agreement_cheque_no' => '', // 'agreement_cheque_date' =>'', // 'agreement_bank' => '', // 'agreement_vtr_no' => '', // 'agreement_online_date' => '', // 'agreement_dd_no' =>$agreement_dd_no, // 'agreement_dd_date' => $agreement_dd_date, // 'agreement_dd_bank' => $agreement_dd_bank, // 'agreementpaytm_ref_no' =>'', // 'agreementpaytm_online_date1'=>'', // 'agreementupi_ref_no'=>'', // 'agreementupi_online_date1' =>'', // 'payment_id' => $res_id, // ); // } // else if($agreement_payment_type == 'Paytm Payment') // { // $type_data = array( // 'agreement_cheque_no' => '', // 'agreement_cheque_date' =>'', // 'agreement_bank' => '', // 'agreement_vtr_no' => '', // 'agreement_online_date' => '', // 'agreement_dd_no' => '', // 'agreement_dd_date' => '', // 'agreement_dd_bank' => '', // 'agreementpaytm_ref_no' =>$agreementpaytm_ref_no, // 'agreementpaytm_online_date1'=>$agreementpaytm_online_date, // 'agreementupi_ref_no'=>'', // 'agreementupi_online_date1' =>'', // 'payment_id' => $res_id, // ); // } // else if($agreement_payment_type == 'UPI Payment') // { // $type_data = array( // 'agreement_cheque_no' => '', // 'agreement_cheque_date' =>'', // 'agreement_bank' => '', // 'agreement_vtr_no' => '', // 'agreement_online_date' => '', // 'agreement_dd_no' => '', // 'agreement_dd_date' => '', // 'agreement_dd_bank' => '', // 'agreementpaytm_ref_no' =>'', // 'agreementpaytm_online_date1'=>'', // 'agreementupi_ref_no'=>$agreementupi_ref_no, // 'agreementupi_online_date1' =>$agreementupi_online_date, // 'payment_id' => $res_id, // ); // } // else if($agreement_payment_type == 'Cash') // { // $type_data = array( // 'agreement_cheque_no' => '', // 'agreement_cheque_date' =>'', // 'agreement_bank' => '', // 'agreement_vtr_no' => '', // 'agreement_online_date' => '', // 'agreement_dd_no' =>'', // 'agreement_dd_date' => '', // 'agreement_dd_bank' => '', // 'agreementpaytm_ref_no' =>'', // 'agreementpaytm_online_date1'=>'', // 'agreementupi_ref_no'=>'', // 'agreementupi_online_date1' =>'', // 'payment_id' => $res_id, // ); // } // $type_table='gss_plot_payment_types'; // $up_res_id = $this->gss_model->insert($type_table,$type_data); // } // if($instalment_payment_type1 != "") // { // foreach($instalment_payment_type1 as $key=>$val) // { // $type_data = array( // 'payment_id' => $data10[$key], // 'agreement_cheque_no' => $agreement_cheque_no, // 'agreement_cheque_date' => $agreement_cheque_date, // 'agreement_bank' => $agreement_bank_name, // 'agreement_vtr_no' => $agreement_vtr_no, // 'agreement_online_date' => $agreement_online_date, // 'agreement_dd_no' => $agreement_dd_no, // 'agreement_dd_date' => $agreement_dd_date, // 'agreement_dd_bank' => $agreement_dd_bank, // 'agreementpaytm_ref_no' =>$agreementpaytm_ref_no, // 'agreementpaytm_online_date1' =>$agreementpaytm_online_date, // 'agreementupi_ref_no' =>$agreementupi_ref_no, // 'agreementupi_online_date1' =>$agreementupi_online_date, // 'regn_cheque_no' => $regn_cheque_no, // 'regn_cheque_date' => $regn_cheque_date, // 'regn_bank' => $regn_bank_name, // 'regn_vtr_no' => $regn_vtr_no, // 'regn_online_date' => $regn_online_date, // 'regn_dd_no' => $regn_dd_no, // 'regn_dd_date' => $regn_dd_date, // 'regn_dd_bank' => $regn_dd_bank, // 'regn_ref_no'=>$regn_ref_no, // 'regn_paytm_date'=>$regn_paytm_date, // 'regn_upiref_no'=>$regn_upiref_no, // 'regn_upi_date'=>$regn_upi_date, // 'cash_date'=>$cash_date, // 'swipe_date'=>$swipe_date, // 'delete_status' => 'ACTIVE', // 'created_at' => $created_at, // ); // $table='gss_plot_payment_types'; // $where=array('type_id'=>$data9[$key]); // $this->gss_model->update($where,$table,$type_data); // } // } // else // { // $type_data = array( // 'payment_id' => $res_id, // 'agreement_cheque_no' => $agreement_cheque_no, // 'agreement_cheque_date' => $agreement_cheque_date, // 'agreement_bank' => $agreement_bank_name, // 'agreement_vtr_no' => $agreement_vtr_no, // 'agreement_online_date' => $agreement_online_date, // 'agreement_dd_no' => $agreement_dd_no, // 'agreement_dd_date' => $agreement_dd_date, // 'agreement_dd_bank' => $agreement_dd_bank, // 'agreementpaytm_ref_no' =>$agreementpaytm_ref_no, // 'agreementpaytm_online_date1' =>$agreementpaytm_online_date, // 'agreementupi_ref_no' =>$agreementupi_ref_no, // 'agreementupi_online_date1' =>$agreementupi_online_date, // 'regn_cheque_no' => $regn_cheque_no, // 'regn_cheque_date' => $regn_cheque_date, // 'regn_bank' => $regn_bank_name, // 'regn_vtr_no' => $regn_vtr_no, // 'regn_online_date' => $regn_online_date, // 'regn_dd_no' => $regn_dd_no, // 'regn_dd_date' => $regn_dd_date, // 'regn_dd_bank' => $regn_dd_bank, // 'regn_ref_no'=>$regn_ref_no, // 'regn_paytm_date'=>$regn_paytm_date, // 'regn_upiref_no'=>$regn_upiref_no, // 'regn_upi_date'=>$regn_upi_date, // 'cash_date'=>$cash_date, // 'swipe_date'=>$swipe_date, // 'delete_status' => 'ACTIVE', // 'created_at' => $created_at, // ); // $table='gss_plot_payment_types'; // $where=array('type_id'=>$up_res_id); // $this->gss_model->update($where,$table,$type_data); // } // if($loanreg_due_amount1 !=""){ // foreach($loanreg_due_amount1 as $key=>$val) // { // $registration_confirming_types=$this->input->post('registration_confirming_types'); // $multireg_data = array( // 'booking_id' => $booking_id, // 'detail_id' => $detail_id, // 'reg_amount ' => $loanreg_due_amount1[$key], // //'reg_date' => $loanreg_status1[$key], // 'reg_payment_mode`' => $loanregn_payment_type1[$key], // 'number' => $loanregn_no1[$key], // 'mode_date' => $loanregndate1[$key], // 'branch_name' => $loanregn_bank1[$key], // 'loan_type' =>$loanregn_amount_type[$key], // 'loan_from' =>$loanloan_from[$key], // 'registration_confirming_type'=>$registration_confirming_types[$key], // 'delete_status' => 'ACTIVE', // 'created_at' => $created_at // ); // $result = $this->gss_model->insert($multireg_table,$multireg_data); // } // } // echo json_encode(array('result'=>1,'message'=>" successfully Added")); // } // } // } // } // else // { // echo json_encode(array('result'=>0,'message'=>'Site number '.$site_number.' not booked')); // } // } // else // { // echo json_encode(array('result'=>2,'message'=>'Site number '.$site_number.' not found')); // } // } public function individual_payment_details() { $payment_table = 'gss_plot_payments'; $type_table = 'gss_plot_payment_types'; $multireg_table = 'gss_registration_amount_details'; $booking_id = $this->input->post('booking_id'); $detail_id = $this->input->post('detail_id'); $agreement_payment_type = $this->input->post('agreement_payment_type'); $sale_agree_amounts = $this->input->post('sale_agree_amount'); $sale_agree_amount = str_replace(',', '', $sale_agree_amounts); $sale_agree_date = $this->input->post('sale_agree_date'); $instalment_payment_type1 = $this->input->post('instalment_payment_type1'); $instalement_amount1s = $this->input->post('instalement_amount1'); $instalement_amount1 = str_replace(',', '', $instalement_amount1s); $instal_amount = array($instalement_amount1); $installment_date1 = $this->input->post('installment_date1'); $regn_payment_type = $this->input->post('regn_payment_type'); $reg_due_amounts = $this->input->post('reg_due_amount'); $reg_due_amount = str_replace(',', '', $reg_due_amounts); $reg_values = $this->input->post('reg_value'); $reg_value = str_replace(',', '', $reg_values); $reg_status = $this->input->post('reg_status'); $regn_amount_type = $this->input->post('regn_amount_type'); $loan_from = $this->input->post('loan_from'); $tsvs = $this->input->post('tsv'); $tsv = str_replace(',', '', $tsvs); $loanregn_payment_type1 = $this->input->post('loanregn_payment_type1'); $loanreg_due_amounts = $this->input->post('loanreg_due_amount1'); $loanreg_due_amount1 = str_replace(',', '', $loanreg_due_amounts); // $loanreg_status1 = $this->input->post('loanreg_status1'); $loanregndate1 = $this->input->post('loanregndate1'); $loanregn_no1 = $this->input->post('loanregn_no1'); $loanregn_bank1 = $this->input->post('loanregn_bank1'); $loanregn_amount_type = $this->input->post('loanregn_amount_type'); $loanloan_from = $this->input->post('loanloan_from'); $instalment_cheque_no1 = $this->input->post('instalment_cheque_no2'); $instalment_cheque_date1 = $this->input->post('instalment_cheque_date2'); $instalment_bank_name1 = $this->input->post('instalment_bank_name2'); $instalment_vtr_no11 = $this->input->post('instalment_vtr_no2'); $instalment_online_date11 = $this->input->post('instalment_online_date2'); $instalment_dd_no11 = $this->input->post('installment_dd_no2'); $instalment_dd_date11 = $this->input->post('installment_dd_date2'); $instalment_dd_bank11 = $this->input->post('installment_dd_bank2'); $registration1_date =$this->input->post('registration1_date'); //print_r($instalment_dd_date11);die(); $paytm_ref_no11 =$this->input->post('paytm_ref_no2'); $paytm_online_date11 =$this->input->post('paytm_online_date2'); $upi_ref_no11 =$this->input->post('upi_ref_no2'); $upi_online_date11 =$this->input->post('upi_online_date2'); $install_swipe_date2 =$this->input->post('install_swipe_date2'); $install_cash_date2 =$this->input->post('install_cash_date2'); if($reg_status == "Date") { $reg_status = $reg_status; $registration_date = $this->input->post('registration_date'); if($registration_date != "") { // $date = new DateTime($registration_date); // $registration_date = $date->format('Y-m-d'); $registration_date = date('Y-m-d',strtotime($registration_date)); } } else { $reg_status = $reg_status; $registration_date = '0000-00-00'; } $main_amounts = $this->input->post('main_amount'); $main_amount = str_replace(',', '', $main_amounts); $no_of_years = $this->input->post('no_of_years'); $membership_amounts = $this->input->post('membership_amount'); $membership_amount = str_replace(',', '', $membership_amounts); $agreement_cheque_no = $this->input->post('agreement_cheque_no'); $agreement_cheque_date = $this->input->post('agreement_cheque_date'); if($agreement_cheque_date != "") { //$date = new DateTime($agreement_cheque_date); //$agreement_cheque_date = $date->format('Y-m-d'); $agreement_cheque_date = date('Y-m-d',strtotime($agreement_cheque_date)); } else { $agreement_cheque_date =""; } $agreement_bank_name = $this->input->post('agreement_bank_name'); $agreement_vtr_no = $this->input->post('agreement_vtr_no'); $agreement_online_date = $this->input->post('agreement_online_date'); if($agreement_online_date != "" || $agreement_online_date != "undefined-undefined-") { /*$date = new DateTime($agreement_online_date); $agreement_online_date = $date->format('Y-m-d');*/ $agreement_online_date = date('Y-m-d',strtotime($agreement_online_date)); } else { $agreement_online_date =""; } $agreement_dd_no = $this->input->post('agreement_dd_no'); $agreement_dd_date = $this->input->post('agreement_dd_date'); if($agreement_dd_date != "") { /*$date = new DateTime($agreement_dd_date); $agreement_dd_date = $date->format('Y-m-d');*/ $agreement_dd_date = date('Y-m-d',strtotime($agreement_dd_date)); } else { $agreement_dd_date =""; } $agreement_dd_bank = $this->input->post('agreement_dd_bank'); $agreementpaytm_ref_no =$this->input->post('paytm_ref_no'); $agreementpaytm_online_date =$this->input->post('paytm_online_date'); $agreementupi_ref_no =$this->input->post('upi_ref_no'); $agreementupi_online_date =$this->input->post('upi_online_date'); $site_number = $this->input->post('site_number'); $project_id = $this->input->post('project_id'); $dues_option = $this->input->post('dues_option'); if($dues_option == 'dues') { $remarks = $this->input->post('remarks_added'); } else { $remarks = ""; } $agreement_confirming_type =$this->input->post('owners_type1'); $check_site = $this->gss_model->project_details($site_number,$project_id); if($check_site) { $site_result = $this->gss_model->individual_payment_site_booking_details($site_number,$project_id,$booking_id); $tsvamount= $tsv-($site_result->booking_amount1 +$site_result->booking_amount2); if($site_result) { if($site_result->booking_status == 'CANCELLED') { echo json_encode(array('result'=>3,'message'=>'Site number '.$site_number.' has been cancelled')); } else { $regn_cheque_no = $this->input->post('regn_cheque_no'); $regn_cheque_date = $this->input->post('regn_cheque_date'); if($regn_cheque_date != "") { /*$date = new DateTime($regn_cheque_date); $regn_cheque_date = $date->format('Y-m-d');*/ $regn_cheque_date = date('Y-m-d',strtotime($regn_cheque_date)); } else { $regn_cheque_date =""; } $regn_bank_name = $this->input->post('regn_bank_name'); $regn_vtr_no = $this->input->post('regn_vtr_no'); $regn_online_date = $this->input->post('regn_online_date'); if($regn_online_date != "") { /*$date = new DateTime($regn_online_date); $regn_online_date = $date->format('Y-m-d');*/ $regn_online_date = date('Y-m-d',strtotime($regn_online_date)); } else { $regn_online_date =""; } $regn_dd_no = $this->input->post('regn_dd_no'); $regn_dd_date = $this->input->post('regn_dd_date'); if($regn_dd_date != "") { /*$date = new DateTime($regn_dd_date); $regn_dd_date = $date->format('Y-m-d');*/ $regn_dd_date = date('Y-m-d',strtotime($regn_dd_date)); } else { $regn_dd_date =""; } $regn_dd_bank = $this->input->post('regn_dd_bank'); $regn_ref_no =$this->input->post('regn_ref_no'); $regn_paytm_date =$this->input->post('regn_paytm_date'); if($regn_paytm_date != "") { /*$date = new DateTime($regn_dd_date); $regn_dd_date = $date->format('Y-m-d');*/ $regn_paytm_date = date('Y-m-d',strtotime($regn_paytm_date)); } else { $regn_paytm_date =""; } $regn_upiref_no =$this->input->post('regn_upiref_no'); $regn_upi_date =$this->input->post('regn_upi_date'); if($regn_upi_date != "") { /*$date = new DateTime($regn_dd_date); $regn_dd_date = $date->format('Y-m-d');*/ $regn_upi_date = date('Y-m-d',strtotime($regn_upi_date)); } else { $regn_upi_date =""; } $cash_date =$this->input->post('cash_date'); if($cash_date != "") { /*$date = new DateTime($regn_dd_date); $regn_dd_date = $date->format('Y-m-d');*/ $cash_date = date('Y-m-d',strtotime($cash_date)); } else { $cash_date =""; } $swipe_date =$this->input->post('swipe_date'); if($swipe_date != "") { /*$date = new DateTime($regn_dd_date); $regn_dd_date = $date->format('Y-m-d');*/ $swipe_date = date('Y-m-d',strtotime($swipe_date)); } else { $swipe_date =""; } if($regn_payment_type == 'Cheque') { $reg_f_num=$this->input->post('regn_cheque_no'); $reg_f_bank=$this->input->post('regn_bank_name'); $reg_f_date=$this->input->post('regn_cheque_date'); } else if($regn_payment_type == 'Cash') { $reg_f_num=""; $reg_f_bank=""; $reg_f_date=$this->input->post('cash_date'); } else if($regn_payment_type == 'DD') { $reg_f_num=$this->input->post('regn_dd_no'); $reg_f_bank=$this->input->post('regn_dd_bank'); $reg_f_date=$this->input->post('regn_dd_bank'); } else if($regn_payment_type == 'Online Payment') { $reg_f_num=$this->input->post('regn_vtr_no'); $reg_f_bank=""; $reg_f_date=$this->input->post('regn_online_date'); } else if($regn_payment_type == 'Paytm Payment') { $reg_f_num=$this->input->post('regn_ref_no'); $reg_f_bank=""; $reg_f_date=$this->input->post('regn_paytm_date'); } else if($regn_payment_type == 'UPI Payment') { $reg_f_num=$this->input->post('regn_upiref_no'); $reg_f_bank=""; $reg_f_date=$this->input->post('regn_upi_date'); } else if($regn_payment_type == 'Swipe') { $reg_f_num=""; $reg_f_bank=""; $reg_f_date=$this->input->post('swipe_date'); } else { $reg_f_num=""; $reg_f_bank=""; $reg_f_date=""; } $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $created_at = $date->format('Y-m-d H:i:s'); $where1 = array('booking_id'=>$booking_id,'detail_id'=>$detail_id,'delete_status'=>'ACTIVE'); $check_ids = $this->gss_model->get_where_payment_id_result($payment_table,$where1); $whereloan1 = array('booking_id'=>$booking_id,'detail_id'=>$detail_id,'delete_status'=>'ACTIVE'); $check_idsloan = $this->gss_model->get_where_multireg_id_result($multireg_table,$whereloan1); $notifications = $this->gss_model->check_notification($booking_id,$detail_id); $booking_table = 'gss_bookings'; $where_booking = array('booking_id'=>$booking_id); $notification_table = 'gss_commission_notifications'; if($notifications) { if($notifications->commission_agreement == "Not Available" && $sale_agree_amount != "") { $commission_agreement = 'Available'; $notification_data = array( 'booking_id' => $booking_id, 'commission_agreement' => $commission_agreement ); $update = $this->gss_model->update($where_booking,$notification_table,$notification_data); } if($notifications->commission_registration == "Not Available" && $reg_due_amount != "") { $commission_registration = 'Available'; $notification_data = array( 'booking_id' => $booking_id, 'commission_registration' => $commission_registration ); $update = $this->gss_model->update($where_booking,$notification_table,$notification_data); } } else { if($sale_agree_amount != "") { $commission_agreement = 'Available'; } else { $commission_agreement = "Not Available"; } if($reg_due_amount != "") { $commission_registration = 'Available'; } else { $commission_registration = "Not Available"; } $notification_data = array( 'booking_id' => $booking_id, 'detail_id' => $detail_id, 'commission_agreement' => $commission_agreement, 'commission_registration' => $commission_registration, 'status' => 'PENDING' ); $check_associate = $this->gss_model->get_where_row($booking_table,$where_booking); if($check_associate->associate != 0) { $commission_result = $this->gss_model->insert($notification_table,$notification_data); } } if($check_ids) { $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $created_at = $date->format('Y-m-d H:i:s'); $total = 0; $arr = array(); foreach ($instalement_amount1 as $key => $value) { if (empty($value)) { unset($instalement_amount1[$key]); } } foreach ($instalment_payment_type1 as $key => $value) { if ($value == '0') { unset($instalment_payment_type1[$key]); } } $up_res_id = 0; if(!empty($instalement_amount1)) { $instal_amt = array_sum($instalement_amount1); } else { $instal_amt = 0; } if(!empty($loanreg_due_amount1)) { $reg_amt = array_sum($loanreg_due_amount1); } else { $reg_amt=0; } if($sale_agree_amount!="" && $reg_due_amount!="") { $total = $sale_agree_amount + $instal_amt + $reg_due_amount + $reg_amt; } else if($sale_agree_amount!="" && $reg_due_amount=="") { $reg_due_amount=0; $total = $sale_agree_amount + $instal_amt + $reg_due_amount + $reg_amt; } else if($sale_agree_amount=="" && $reg_due_amount!="") { $sale_agree_amount=0; $total = $sale_agree_amount + $instal_amt + $reg_due_amount +$reg_amt; } if($total > $tsvamount) { echo json_encode(array('result'=>3,'message'=>"Not matching TSV")); } else { foreach($check_ids as $id) { //echo $id->payment_id; $deletetable='gss_plot_payment_types'; $deletewhere=array('payment_id'=> $id->payment_id); $drop=$this->gss_model->delete($deletetable,$deletewhere); $deletetable1='gss_plot_payments'; $deletewhere1=array('payment_id'=> $id->payment_id); $this->gss_model->delete($deletetable1,$deletewhere1); } $data10=array(); if(!empty($instalement_amount1)) { foreach($instalement_amount1 as $key=>$val) { $installment_confirming_type =$this->input->post('installment_confirming_type'.$key); //$registration_confirming_type=$this->input->post('registration_confirming_types'.$key); $registration_confirming_type=$this->input->post('registration_confirming_type'); $payment_data = array( 'booking_id' => $booking_id, 'detail_id' => $detail_id, 'agreement_amount' => $sale_agree_amount, 'agreement_date' => $sale_agree_date, 'agreement_payment_mode' => $agreement_payment_type, 'agreement_confirming_type' => $agreement_confirming_type, 'installment_amount1' => $instalement_amount1[$key], 'installment_payment_mode1' => $instalment_payment_type1[$key], 'installment1_date' => $installment_date1[$key], 'installment_confirming_type' => $installment_confirming_type, 'registration_amount' => $reg_due_amount, 'registration_value' => $reg_value, 'regn_amount_type' =>$regn_amount_type, 'loan_from' =>$loan_from, 'registration_date' => $registration_date, 'registration_payment_mode' => $regn_payment_type, 'registration_status' => $reg_status, 'registration_confirming_type' => $registration_confirming_type, //'registration_done_date' =>$registration1_date, 'reg_f_num' => $reg_f_num, 'reg_f_bank' => $reg_f_bank, 'reg_f_date' => $reg_f_date, 'membership_amount' => $membership_amount, 'maintenence_amount' => $main_amount, 'no_of_years' => $no_of_years, 'dues_option' => $dues_option, 'remarks' => $remarks, 'delete_status' => 'ACTIVE', 'created_at' => $created_at ); $result = $this->gss_model->insert($payment_table,$payment_data); array_push($data10,$result); } } else { $registration_confirming_type=$this->input->post('registration_confirming_type'); $payment_data = array( 'booking_id' => $booking_id, 'detail_id' => $detail_id, 'agreement_amount' => $sale_agree_amount, 'agreement_date' => $sale_agree_date, 'agreement_payment_mode' => $agreement_payment_type, 'agreement_confirming_type' => $agreement_confirming_type, 'installment_amount1' => '', 'installment_payment_mode1' => '', 'installment1_date' => '', 'registration_amount' => $reg_due_amount, 'registration_value' => $reg_value, 'regn_amount_type' =>$regn_amount_type, 'loan_from' =>$loan_from, 'registration_date' => $registration_date, 'registration_payment_mode' => $regn_payment_type, 'registration_status' => $reg_status, 'registration_confirming_type' => $registration_confirming_type, //'registration_done_date' =>$registration1_date, 'reg_f_num' => $reg_f_num, 'reg_f_bank' => $reg_f_bank, 'reg_f_date' => $reg_f_date, 'membership_amount' => $membership_amount, 'maintenence_amount' => $main_amount, 'no_of_years' => $no_of_years, 'dues_option' => $dues_option, 'remarks' => $remarks, 'delete_status' => 'ACTIVE', 'created_at' => $created_at ); $res_id = $this->gss_model->insert($payment_table,$payment_data); } $data9=array(); if(!empty($instalement_amount1)) { foreach($instalement_amount1 as $key=>$val) { if($instalment_payment_type1[$key] == 'Cheque') { $installment_cheque_no =$this->input->post('instalment_cheque_no2'.$key); $installment_cheque_date=$this->input->post('instalment_cheque_date2'.$key); $instalment_bank_name=$this->input->post('instalment_bank_name2'.$key); $type_dataa = array( 'install_cheque_no1' => $installment_cheque_no, 'install_cheque_date1' =>$installment_cheque_date, 'install_bank1' => $instalment_bank_name, 'install_vtr_no1' => ' ', 'install_online_date1' => ' ', 'install_dd_no1' => ' ', 'install_dd_date1' => ' ', 'install_dd_bank1' => ' ', 'paytm_ref_no' =>' ', 'paytm_online_date1' =>' ', 'upi_ref_no' =>' ', 'upi_online_date1'=>' ', 'install_cash_date' => '', 'install_swipe_date' =>'', 'payment_id' => $data10[$key], ); } else if($instalment_payment_type1[$key] == 'Online Payment') { $installment_vtr_no =$this->input->post('instalment_vtr_no2'.$key); $installment_online_date=$this->input->post('instalment_online_date2'.$key); $type_dataa = array( 'install_cheque_no1' => '', 'install_cheque_date1' =>'', 'install_bank1' => '', 'install_vtr_no1' => $installment_vtr_no, 'install_online_date1' => $installment_online_date, 'install_dd_no1' => '', 'install_dd_date1' => '', 'install_dd_bank1' => '', 'paytm_ref_no' =>' ', 'paytm_online_date1' =>' ', 'upi_ref_no' =>' ', 'upi_online_date1'=>' ', 'install_cash_date' => '', 'install_swipe_date' =>'', 'payment_id' => $data10[$key], ); } else if($instalment_payment_type1[$key] == 'DD') { $installment_dd_no =$this->input->post('installment_dd_no2'.$key); $installment_dd_date=$this->input->post('installment_dd_date2'.$key); $installment_dd_bank=$this->input->post('installment_dd_bank2'.$key); $type_dataa = array( 'install_cheque_no1' => '', 'install_cheque_date1' =>'', 'install_bank1' => '', 'install_vtr_no1' => '', 'install_online_date1' => '', 'install_dd_no1' => $installment_dd_no, 'install_dd_date1' => $installment_dd_date, 'install_dd_bank1' => $installment_dd_bank, 'paytm_ref_no' =>' ', 'paytm_online_date1' =>' ', 'upi_ref_no' =>' ', 'upi_online_date1'=>' ', 'install_cash_date' => '', 'install_swipe_date' =>'', 'payment_id' => $data10[$key], ); } else if($instalment_payment_type1[$key] == 'Paytm Payment') { $paytm_ref_no =$this->input->post('paytm_ref_no2'.$key); $paytm_online_date=$this->input->post('paytm_online_date2'.$key); $type_dataa = array( 'install_cheque_no1' => '', 'install_cheque_date1' =>'', 'install_bank1' => '', 'install_vtr_no1' => '', 'install_online_date1' => '', 'install_dd_no1' => ' ', 'install_dd_date1' => ' ', 'install_dd_bank1' =>' ' , 'paytm_ref_no' =>$paytm_ref_no, 'paytm_online_date1' =>$paytm_online_date, 'upi_ref_no' =>' ', 'upi_online_date1'=>' ', 'install_cash_date' => '', 'install_swipe_date' =>'', 'payment_id' => $data10[$key], ); } else if($instalment_payment_type1[$key] == 'UPI Payment') { $upi_ref_no =$this->input->post('upi_ref_no2'.$key); $upi_online_date=$this->input->post('upi_online_date2'.$key); $type_dataa = array( 'install_cheque_no1' => '', 'install_cheque_date1' =>'', 'install_bank1' => '', 'install_vtr_no1' => '', 'install_online_date1' => '', 'install_dd_no1' => ' ', 'install_dd_date1' => ' ', 'install_dd_bank1' => ' ', 'paytm_ref_no' =>' ', 'paytm_online_date1' =>' ', 'upi_ref_no' =>$upi_ref_no, 'upi_online_date1'=>$upi_online_date, 'install_cash_date' => '', 'install_swipe_date' =>'', 'payment_id' => $data10[$key], ); } else if($instalment_payment_type1[$key] == 'Cash') { $install_cash_date2 =$this->input->post('install_cash_date2'.$key); $type_dataa = array( 'install_cheque_no1' => '', 'install_cheque_date1' =>'', 'install_bank1' => '', 'install_vtr_no1' => '', 'install_online_date1' => '', 'install_dd_no1' => '', 'install_dd_date1' => '', 'install_dd_bank1' => '', 'paytm_ref_no' =>' ', 'paytm_online_date1' =>' ', 'upi_ref_no' =>' ', 'upi_online_date1'=>' ', 'install_cash_date' => $install_cash_date2, 'install_swipe_date' =>'', 'payment_id' => $data10[$key], ); } else if($instalment_payment_type1[$key] == 'Swipe') { $install_swipe_date2 =$this->input->post('install_swipe_date2'.$key); $type_dataa = array( 'install_cheque_no1' => '', 'install_cheque_date1' =>'', 'install_bank1' => '', 'install_vtr_no1' => '', 'install_online_date1' => '', 'install_dd_no1' => '', 'install_dd_date1' => '', 'install_dd_bank1' => '', 'paytm_ref_no' =>' ', 'paytm_online_date1' =>' ', 'upi_ref_no' =>' ', 'upi_online_date1'=>' ', 'install_cash_date' => '', 'install_swipe_date' =>$install_swipe_date2, 'payment_id' => $data10[$key], ); } $type_table='gss_plot_payment_types'; $resulttt = $this->gss_model->insert($type_table,$type_dataa); array_push($data9,$resulttt); } } else if($agreement_payment_type != '0') { //{ if($agreement_payment_type == 'Cheque') { $type_data = array( 'agreement_cheque_no' => $agreement_cheque_no, 'agreement_cheque_date' =>$agreement_cheque_date, 'agreement_bank' => $agreement_bank_name, 'agreement_vtr_no' => '', 'agreement_online_date' => '', 'agreement_dd_no' => '', 'agreement_dd_date' => '', 'agreement_dd_bank' => '', 'agreementpaytm_ref_no'=>'', 'agreementpaytm_online_date1'=> '', 'agreementupi_ref_no' =>'', 'agreementupi_online_date1' =>'', 'payment_id' => $res_id, 'regn_cheque_no' => $regn_cheque_no, 'regn_cheque_date' => $regn_cheque_date, 'regn_bank' => $regn_bank_name, 'regn_vtr_no' => $regn_vtr_no, 'regn_online_date' => $regn_online_date, 'regn_dd_no' => $regn_dd_no, 'regn_dd_date' => $regn_dd_date, 'regn_dd_bank' => $regn_dd_bank, //varu 'regn_ref_no' =>$regn_ref_no, 'regn_paytm_date'=>$regn_paytm_date, 'regn_upiref_no' =>$regn_upiref_no, 'regn_upi_date' =>$regn_upi_date, 'cash_date'=>$cash_date, 'swipe_date'=>$swipe_date, ); } else if($agreement_payment_type == 'Online Payment') { $type_data = array( 'agreement_cheque_no' => '', 'agreement_cheque_date' =>'', 'agreement_bank' => '', 'agreement_vtr_no' => $agreement_vtr_no, 'agreement_online_date' => $agreement_online_date, 'agreement_dd_no' => '', 'agreement_dd_date' => '', 'agreement_dd_bank' => '', 'agreementpaytm_ref_no'=>'', 'agreementpaytm_online_date1'=> '', 'agreementupi_ref_no' =>'', 'agreementupi_online_date1' =>'', 'payment_id' => $res_id, 'regn_cheque_no' => $regn_cheque_no, 'regn_cheque_date' => $regn_cheque_date, 'regn_bank' => $regn_bank_name, 'regn_vtr_no' => $regn_vtr_no, 'regn_online_date' => $regn_online_date, 'regn_dd_no' => $regn_dd_no, 'regn_dd_date' => $regn_dd_date, 'regn_dd_bank' => $regn_dd_bank, //varu 'regn_ref_no' =>$regn_ref_no, 'regn_paytm_date'=>$regn_paytm_date, 'regn_upiref_no' =>$regn_upiref_no, 'regn_upi_date' =>$regn_upi_date, 'cash_date'=>$cash_date, 'swipe_date'=>$swipe_date, ); } else if($agreement_payment_type == 'DD') { $type_data = array( 'agreement_cheque_no' => '', 'agreement_cheque_date' =>'', 'agreement_bank' => '', 'agreement_vtr_no' => '', 'agreement_online_date' => '', 'agreement_dd_no' =>$agreement_dd_no, 'agreement_dd_date' => $agreement_dd_date, 'agreement_dd_bank' => $agreement_dd_bank, 'agreementpaytm_ref_no'=>'', 'agreementpaytm_online_date1'=> '', 'agreementupi_ref_no' =>'', 'agreementupi_online_date1' =>'', 'payment_id' => $res_id, 'regn_cheque_no' => $regn_cheque_no, 'regn_cheque_date' => $regn_cheque_date, 'regn_bank' => $regn_bank_name, 'regn_vtr_no' => $regn_vtr_no, 'regn_online_date' => $regn_online_date, 'regn_dd_no' => $regn_dd_no, 'regn_dd_date' => $regn_dd_date, 'regn_dd_bank' => $regn_dd_bank, //varu 'regn_ref_no' =>$regn_ref_no, 'regn_paytm_date'=>$regn_paytm_date, 'regn_upiref_no' =>$regn_upiref_no, 'regn_upi_date' =>$regn_upi_date, 'cash_date'=>$cash_date, 'swipe_date'=>$swipe_date, ); } else if($agreement_payment_type == 'Paytm Payment') { $type_data = array( 'agreement_cheque_no' => '', 'agreement_cheque_date' =>'', 'agreement_bank' => '', 'agreement_vtr_no' => '', 'agreement_online_date' => '', 'agreement_dd_no' => '', 'agreement_dd_date' => '', 'agreement_dd_bank' => '', 'agreementpaytm_ref_no'=> $agreementpaytm_ref_no, 'agreementpaytm_online_date1'=> $agreementpaytm_online_date, 'agreementupi_ref_no' =>'', 'agreementupi_online_date1' =>'', 'payment_id' => $res_id, 'regn_cheque_no' => $regn_cheque_no, 'regn_cheque_date' => $regn_cheque_date, 'regn_bank' => $regn_bank_name, 'regn_vtr_no' => $regn_vtr_no, 'regn_online_date' => $regn_online_date, 'regn_dd_no' => $regn_dd_no, 'regn_dd_date' => $regn_dd_date, 'regn_dd_bank' => $regn_dd_bank, //varu 'regn_ref_no' =>$regn_ref_no, 'regn_paytm_date'=>$regn_paytm_date, 'regn_upiref_no' =>$regn_upiref_no, 'regn_upi_date' =>$regn_upi_date, 'cash_date'=>$cash_date, 'swipe_date'=>$swipe_date, ); } else if($agreement_payment_type == 'UPI Payment') { $type_data = array( 'agreement_cheque_no' => '', 'agreement_cheque_date' =>'', 'agreement_bank' => '', 'agreement_vtr_no' => '', 'agreement_online_date' => '', 'agreement_dd_no' => '', 'agreement_dd_date' => '', 'agreement_dd_bank' => '', 'agreementpaytm_ref_no'=> '', 'agreementpaytm_online_date1'=> '', 'agreementupi_ref_no' =>$agreementupi_ref_no, 'agreementupi_online_date1' =>$agreementupi_online_date, 'payment_id' => $res_id, 'regn_cheque_no' => $regn_cheque_no, 'regn_cheque_date' => $regn_cheque_date, 'regn_bank' => $regn_bank_name, 'regn_vtr_no' => $regn_vtr_no, 'regn_online_date' => $regn_online_date, 'regn_dd_no' => $regn_dd_no, 'regn_dd_date' => $regn_dd_date, 'regn_dd_bank' => $regn_dd_bank, //varu 'regn_ref_no' =>$regn_ref_no, 'regn_paytm_date'=>$regn_paytm_date, 'regn_upiref_no' =>$regn_upiref_no, 'regn_upi_date' =>$regn_upi_date, 'cash_date'=>$cash_date, 'swipe_date'=>$swipe_date, ); } else if($agreement_payment_type == 'Cash') { $type_data = array( 'agreement_cheque_no' => '', 'agreement_cheque_date' =>'', 'agreement_bank' => '', 'agreement_vtr_no' => '', 'agreement_online_date' => '', 'agreement_dd_no' =>'', 'agreement_dd_date' => '', 'agreement_dd_bank' => '', 'agreementpaytm_ref_no'=>'', 'agreementpaytm_online_date1'=> '', 'agreementupi_ref_no' =>'', 'agreementupi_online_date1' =>'', 'payment_id' => $res_id, 'regn_cheque_no' => $regn_cheque_no, 'regn_cheque_date' => $regn_cheque_date, 'regn_bank' => $regn_bank_name, 'regn_vtr_no' => $regn_vtr_no, 'regn_online_date' => $regn_online_date, 'regn_dd_no' => $regn_dd_no, 'regn_dd_date' => $regn_dd_date, 'regn_dd_bank' => $regn_dd_bank, //varu 'regn_ref_no' =>$regn_ref_no, 'regn_paytm_date'=>$regn_paytm_date, 'regn_upiref_no' =>$regn_upiref_no, 'regn_upi_date' =>$regn_upi_date, 'cash_date'=>$cash_date, 'swipe_date'=>$swipe_date, ); } $type_table='gss_plot_payment_types'; $up_res_id = $this->gss_model->insert($type_table,$type_data); } else { $type_data = array( 'agreement_cheque_no' => '', 'agreement_cheque_date' =>'', 'agreement_bank' => '', 'agreement_vtr_no' => '', 'agreement_online_date' => '', 'agreement_dd_no' =>'', 'agreement_dd_date' => '', 'agreement_dd_bank' => '', 'agreementpaytm_ref_no'=>'', 'agreementpaytm_online_date1'=> '', 'agreementupi_ref_no' =>'', 'agreementupi_online_date1' =>'', 'payment_id' => $res_id, 'regn_cheque_no' => $regn_cheque_no, 'regn_cheque_date' => $regn_cheque_date, 'regn_bank' => $regn_bank_name, 'regn_vtr_no' => $regn_vtr_no, 'regn_online_date' => $regn_online_date, 'regn_dd_no' => $regn_dd_no, 'regn_dd_date' => $regn_dd_date, 'regn_dd_bank' => $regn_dd_bank, //varu 'regn_ref_no' =>$regn_ref_no, 'regn_paytm_date'=>$regn_paytm_date, 'regn_upiref_no' =>$regn_upiref_no, 'regn_upi_date' =>$regn_upi_date, 'cash_date'=>$cash_date, 'swipe_date'=>$swipe_date, ); $type_table='gss_plot_payment_types'; $up_res_id = $this->gss_model->insert($type_table,$type_data); } if(!empty($instalment_payment_type1)) { foreach($instalment_payment_type1 as $key=>$val) { $type_data = array( 'payment_id' => $data10[$key], 'agreement_cheque_no' => $agreement_cheque_no, 'agreement_cheque_date' => $agreement_cheque_date, 'agreement_bank' => $agreement_bank_name, 'agreement_vtr_no' => $agreement_vtr_no, 'agreement_online_date' => $agreement_online_date, 'agreement_dd_no' => $agreement_dd_no, 'agreement_dd_date' => $agreement_dd_date, 'agreement_dd_bank' => $agreement_dd_bank, //varuuu 'agreementpaytm_ref_no' =>$agreementpaytm_ref_no, 'agreementpaytm_online_date1' =>$agreementpaytm_online_date, 'agreementupi_ref_no' =>$agreementupi_ref_no, 'agreementupi_online_date1' =>$agreementupi_online_date, 'regn_cheque_no' => $regn_cheque_no, 'regn_cheque_date' => $regn_cheque_date, 'regn_bank' => $regn_bank_name, 'regn_vtr_no' => $regn_vtr_no, 'regn_online_date' => $regn_online_date, 'regn_dd_no' => $regn_dd_no, 'regn_dd_date' => $regn_dd_date, 'regn_dd_bank' => $regn_dd_bank, //varu 'regn_ref_no' =>$regn_ref_no, 'regn_paytm_date'=>$regn_paytm_date, 'regn_upiref_no' =>$regn_upiref_no, 'regn_upi_date' =>$regn_upi_date, 'cash_date'=>$cash_date, 'swipe_date'=>$swipe_date, 'delete_status' => 'ACTIVE', 'created_at' => $created_at, ); $table='gss_plot_payment_types'; $where=array('type_id'=>$data9[$key]); $this->gss_model->update($where,$table,$type_data); } }else{ $type_data = array( 'payment_id' => $res_id, 'agreement_cheque_no' => $agreement_cheque_no, 'agreement_cheque_date' => $agreement_cheque_date, 'agreement_bank' => $agreement_bank_name, 'agreement_vtr_no' => $agreement_vtr_no, 'agreement_online_date' => $agreement_online_date, 'agreement_dd_no' => $agreement_dd_no, 'agreement_dd_date' => $agreement_dd_date, 'agreement_dd_bank' => $agreement_dd_bank, 'agreementpaytm_ref_no' =>$agreementpaytm_ref_no, //varu 'agreementpaytm_online_date1' =>$agreementpaytm_online_date, 'agreementupi_ref_no' =>$agreementupi_ref_no, 'agreementupi_online_date1' =>$agreementupi_online_date, 'regn_cheque_no' => $regn_cheque_no, 'regn_cheque_date' => $regn_cheque_date, 'regn_bank' => $regn_bank_name, 'regn_vtr_no' => $regn_vtr_no, 'regn_online_date' => $regn_online_date, 'regn_dd_no' => $regn_dd_no, 'regn_dd_date' => $regn_dd_date, 'regn_dd_bank' => $regn_dd_bank, 'regn_ref_no' =>$regn_ref_no, 'regn_paytm_date'=>$regn_paytm_date, 'regn_upiref_no' =>$regn_upiref_no, 'regn_upi_date' =>$regn_upi_date, 'cash_date'=>$cash_date, 'swipe_date'=>$swipe_date, 'delete_status' => 'ACTIVE', 'created_at' => $created_at, ); $table='gss_plot_payment_types'; $where=array('type_id'=>$up_res_id); $this->gss_model->update($where,$table,$type_data); } if($check_idsloan) { foreach($check_idsloan as $ids) { $deletetable='gss_registration_amount_details'; $deletewhere=array('id'=> $ids->id); $drop=$this->gss_model->delete($deletetable,$deletewhere); } if($loanreg_due_amount1 != "") { foreach($loanreg_due_amount1 as $key=>$val) { $registration_confirming_types=$this->input->post('registration_confirming_types'); $multireg_data = array( 'booking_id' => $booking_id, 'detail_id' => $detail_id, 'reg_amount ' => $loanreg_due_amount1[$key], //'reg_date' => $loanreg_status1[$key], 'reg_payment_mode' => $loanregn_payment_type1[$key], 'number' => $loanregn_no1[$key], 'mode_date' => $loanregndate1[$key], 'branch_name' => $loanregn_bank1[$key], 'loan_type' =>$loanregn_amount_type[$key], 'loan_from' =>$loanloan_from[$key], 'registration_confirming_type' =>$registration_confirming_types[$key], 'delete_status' => 'ACTIVE', 'created_at' => $created_at ); $result = $this->gss_model->insert($multireg_table,$multireg_data); } } } else { if($loanreg_due_amount1 != "") { foreach($loanreg_due_amount1 as $key=>$val) { $registration_confirming_types=$this->input->post('registration_confirming_types'); $multireg_data = array( 'booking_id' => $booking_id, 'detail_id' => $detail_id, 'reg_amount ' => $loanreg_due_amount1[$key], //'reg_date' => $loanreg_status1[$key], 'reg_payment_mode' => $loanregn_payment_type1[$key], 'number' => $loanregn_no1[$key], 'mode_date' => $loanregndate1[$key], 'branch_name' => $loanregn_bank1[$key], 'loan_type' =>$loanregn_amount_type[$key], 'loan_from' =>$loanloan_from[$key], 'registration_confirming_type' =>$registration_confirming_types[$key], 'delete_status' => 'ACTIVE', 'created_at' => $created_at ); $result = $this->gss_model->insert($multireg_table,$multireg_data); } } } echo json_encode(array('result'=>1,'message'=>" successfully Updated")); } } else { $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $created_at = $date->format('Y-m-d H:i:s'); $total = 0; $arr = array(); if(!empty($instalement_amount1)) { $instal_amt = array_sum($instalement_amount1); } else { $instal_amt = 0; } if(!empty($loanreg_due_amount1)) { $reg_amt = array_sum($loanreg_due_amount1); } else { $reg_amt=0; } if($sale_agree_amount!="" && $reg_due_amount!="") { $total = $sale_agree_amount + $instal_amt+$reg_due_amount+$reg_amt; } else if($sale_agree_amount!="" && $reg_due_amount=="") { $reg_due_amount=0; $total = $sale_agree_amount + $instal_amt+$reg_due_amount+$reg_amt; } else if($sale_agree_amount=="" && $reg_due_amount!="") { $sale_agree_amount=0; $total = $sale_agree_amount + $instal_amt+$reg_due_amount+$reg_amt; } if($total > $tsvamount) { echo json_encode(array('result'=>3,'message'=>"Not matching TSV")); } else { $data10=array(); if($instalement_amount1 != "") { foreach($instalement_amount1 as $key=>$val) { $installment_confirming_type =$this->input->post('installment_confirming_type'.$key); //$registration_confirming_type=$this->input->post('registration_confirming_types'.$key); $registration_confirming_type=$this->input->post('registration_confirming_type'); $payment_data = array( 'booking_id' => $booking_id, 'detail_id' => $detail_id, 'agreement_amount' => $sale_agree_amount, 'agreement_date' => $sale_agree_date, 'agreement_payment_mode' => $agreement_payment_type, 'agreement_confirming_type' => $agreement_confirming_type, 'installment_amount1' => $instalement_amount1[$key], 'installment_payment_mode1' => $instalment_payment_type1[$key], 'installment1_date' => $installment_date1[$key], 'installment_confirming_type' => $installment_confirming_type, 'registration_amount' => $reg_due_amount, 'registration_value' => $reg_value, 'regn_amount_type' =>$regn_amount_type, 'loan_from' =>$loan_from, 'registration_date' => $registration_date, 'registration_payment_mode' => $regn_payment_type, 'registration_status' => $reg_status, 'registration_confirming_type' => $registration_confirming_type, //'registration_done_date' =>$registration1_date, 'reg_f_num' => $reg_f_num, 'reg_f_bank' => $reg_f_bank, 'reg_f_date' => $reg_f_date, 'membership_amount' => $membership_amount, 'maintenence_amount' => $main_amount, 'no_of_years' => $no_of_years, 'delete_status' => 'ACTIVE', 'dues_option' => $dues_option, 'remarks' => $remarks, 'created_at' => $created_at ); $result = $this->gss_model->insert($payment_table,$payment_data); array_push($data10,$result); } } else { $registration_confirming_type=$this->input->post('registration_confirming_type'); $payment_data = array( 'booking_id' => $booking_id, 'detail_id' => $detail_id, 'agreement_amount' => $sale_agree_amount, 'agreement_date' => $sale_agree_date, 'agreement_payment_mode' => $agreement_payment_type, 'agreement_confirming_type' => $agreement_confirming_type, 'installment_amount1' => '', 'installment_payment_mode1' => '', 'installment1_date' => '', 'installment_confirming_type' => '', 'registration_amount' => $reg_due_amount, 'registration_value' => $reg_value, 'regn_amount_type' =>$regn_amount_type, 'loan_from' =>$loan_from, 'registration_date' => $registration_date, 'registration_payment_mode' => $regn_payment_type, 'registration_status' => $reg_status, 'registration_confirming_type' => $registration_confirming_type, //'registration_done_date' =>$registration1_date, 'reg_f_num' => $reg_f_num, 'reg_f_bank' => $reg_f_bank, 'reg_f_date' => $reg_f_date, 'membership_amount' => $membership_amount, 'maintenence_amount' => $main_amount, 'no_of_years' => $no_of_years, 'delete_status' => 'ACTIVE', 'dues_option' => $dues_option, 'remarks' => $remarks, 'created_at' => $created_at ); $res_id = $this->gss_model->insert($payment_table,$payment_data); } $data9=array(); if($instalement_amount1 != "") { foreach($instalement_amount1 as $key=>$val) { if($instalment_payment_type1[$key] == 'Cheque') { $installment_cheque_no =$this->input->post('instalment_cheque_no2'.$key); $installment_cheque_date=$this->input->post('instalment_cheque_date2'.$key); $instalment_bank_name=$this->input->post('instalment_bank_name2'.$key); $type_dataa = array( 'install_cheque_no1' => $installment_cheque_no, 'install_cheque_date1' =>$installment_cheque_date, 'install_bank1' => $instalment_bank_name, 'install_vtr_no1' => ' ', 'install_online_date1' => ' ', 'install_dd_no1' => ' ', 'install_dd_date1' => ' ', 'install_dd_bank1' => ' ', 'paytm_ref_no' =>' ', 'paytm_online_date1' =>' ', 'upi_ref_no' =>' ', 'upi_online_date1'=>' ', 'install_cash_date' => '', 'install_swipe_date' =>'', 'payment_id' => $data10[$key], ); $type_table='gss_plot_payment_types'; $resulttt = $this->gss_model->insert($type_table,$type_dataa); array_push($data9,$resulttt); } else if($instalment_payment_type1[$key] == 'Online Payment') { $installment_vtr_no =$this->input->post('instalment_vtr_no2'.$key); $installment_online_date=$this->input->post('instalment_online_date2'.$key); $type_dataa = array( 'install_cheque_no1' => '', 'install_cheque_date1' =>'', 'install_bank1' => '', 'install_vtr_no1' => $installment_vtr_no, 'install_online_date1' => $installment_online_date, 'install_dd_no1' => '', 'install_dd_date1' => '', 'install_dd_bank1' => '', 'paytm_ref_no' =>' ', 'paytm_online_date1' =>' ', 'upi_ref_no' =>' ', 'upi_online_date1'=>' ', 'install_cash_date' => '', 'install_swipe_date' =>'', 'payment_id' => $data10[$key], ); $type_table='gss_plot_payment_types'; $resulttt = $this->gss_model->insert($type_table,$type_dataa); array_push($data9,$resulttt); } else if($instalment_payment_type1[$key] == 'DD') { $installment_dd_no =$this->input->post('installment_dd_no2'.$key); $installment_dd_date=$this->input->post('installment_dd_date2'.$key); $installment_dd_bank=$this->input->post('installment_dd_bank2'.$key); $type_dataa = array( 'install_cheque_no1' => '', 'install_cheque_date1' =>'', 'install_bank1' => '', 'install_vtr_no1' => '', 'install_online_date1' => '', 'install_dd_no1' => $installment_dd_no, 'install_dd_date1' => $installment_dd_date, 'install_dd_bank1' => $installment_dd_bank, 'paytm_ref_no' =>' ', 'paytm_online_date1' =>' ', 'upi_ref_no' =>' ', 'upi_online_date1'=>' ', 'install_cash_date' => '', 'install_swipe_date' =>'', 'payment_id' => $data10[$key], ); $type_table='gss_plot_payment_types'; $resulttt = $this->gss_model->insert($type_table,$type_dataa); array_push($data9,$resulttt); } else if($instalment_payment_type1[$key] == 'Paytm Payment') { $paytm_ref_no =$this->input->post('paytm_ref_no2'.$key); $paytm_online_date=$this->input->post('paytm_online_date2'.$key); $type_dataa = array( 'install_cheque_no1' => '', 'install_cheque_date1' =>'', 'install_bank1' => '', 'install_vtr_no1' => '', 'install_online_date1' => '', 'install_dd_no1' => ' ', 'install_dd_date1' => ' ', 'install_dd_bank1' =>' ' , 'paytm_ref_no' =>$paytm_ref_no, 'paytm_online_date1' =>$paytm_online_date, 'upi_ref_no' =>' ', 'upi_online_date1'=>' ', 'install_cash_date' => '', 'install_swipe_date' =>'', 'payment_id' => $data10[$key], ); $type_table='gss_plot_payment_types'; $resulttt = $this->gss_model->insert($type_table,$type_dataa); array_push($data9,$resulttt); } else if($instalment_payment_type1[$key] == 'UPI Payment') { $upi_ref_no =$this->input->post('upi_ref_no2'.$key); $upi_online_date=$this->input->post('upi_online_date2'.$key); $type_dataa = array( 'install_cheque_no1' => '', 'install_cheque_date1' =>'', 'install_bank1' => '', 'install_vtr_no1' => '', 'install_online_date1' => '', 'install_dd_no1' => ' ', 'install_dd_date1' => ' ', 'install_dd_bank1' => ' ', 'paytm_ref_no' =>' ', 'paytm_online_date1' =>' ', 'upi_ref_no' =>$upi_ref_no, 'upi_online_date1'=>$upi_online_date, 'install_cash_date' => '', 'install_swipe_date' =>'', 'payment_id' => $data10[$key], ); $type_table='gss_plot_payment_types'; $resulttt = $this->gss_model->insert($type_table,$type_dataa); array_push($data9,$resulttt); } else if($instalment_payment_type1[$key] == 'Cash') { $install_cash_date2=$this->input->post('install_cash_date2'.$key); $type_dataa = array( 'install_cheque_no1' => '', 'install_cheque_date1' =>'', 'install_bank1' => '', 'install_vtr_no1' => '', 'install_online_date1' => '', 'install_dd_no1' => '', 'install_dd_date1' => '', 'install_dd_bank1' => '', 'paytm_ref_no' =>' ', 'paytm_online_date1' =>' ', 'upi_ref_no' =>' ', 'upi_online_date1'=>' ', 'install_cash_date' => $install_cash_date2, 'install_swipe_date' =>'', 'payment_id' => $data10[$key], ); $type_table='gss_plot_payment_types'; $resulttt = $this->gss_model->insert($type_table,$type_dataa); array_push($data9,$resulttt); } else if($instalment_payment_type1[$key] == 'Swipe') { $install_swipe_date2=$this->input->post('install_swipe_date2'.$key); $type_dataa = array( 'install_cheque_no1' => '', 'install_cheque_date1' =>'', 'install_bank1' => '', 'install_vtr_no1' => '', 'install_online_date1' => '', 'install_dd_no1' => '', 'install_dd_date1' => '', 'install_dd_bank1' => '', 'paytm_ref_no' =>' ', 'paytm_online_date1' =>' ', 'upi_ref_no' =>' ', 'upi_online_date1'=>' ', 'install_cash_date' => '', 'install_swipe_date' =>$install_swipe_date2, 'payment_id' => $data10[$key], ); $type_table='gss_plot_payment_types'; $resulttt = $this->gss_model->insert($type_table,$type_dataa); array_push($data9,$resulttt); } else { $type_dataa = array( 'install_cheque_no1' => '', 'install_cheque_date1' =>'', 'install_bank1' => '', 'install_vtr_no1' => '', 'install_online_date1' => '', 'install_dd_no1' => '', 'install_dd_date1' => '', 'install_dd_bank1' => '', 'paytm_ref_no' =>' ', 'paytm_online_date1' =>' ', 'upi_ref_no' =>' ', 'upi_online_date1'=>' ', 'install_cash_date' => '', 'install_swipe_date' =>'', 'payment_id' => $data10[$key], ); $type_table='gss_plot_payment_types'; $resulttt = $this->gss_model->insert($type_table,$type_dataa); array_push($data9,$resulttt); } } } else { if($agreement_payment_type == 'Cheque') { $type_data = array( 'agreement_cheque_no' => $agreement_cheque_no, 'agreement_cheque_date' =>$agreement_cheque_date, 'agreement_bank' => $agreement_bank_name, 'agreement_vtr_no' => '', 'agreement_online_date' => '', 'agreement_dd_no' => '', 'agreement_dd_date' => '', 'agreement_dd_bank' => '', 'agreementpaytm_ref_no' =>'', 'agreementpaytm_online_date1'=>'', 'agreementupi_ref_no'=>'', 'agreementupi_online_date1' =>'', 'payment_id' => $res_id, 'regn_cheque_no' => $regn_cheque_no, 'regn_cheque_date' => $regn_cheque_date, 'regn_bank' => $regn_bank_name, 'regn_vtr_no' => $regn_vtr_no, 'regn_online_date' => $regn_online_date, 'regn_dd_no' => $regn_dd_no, 'regn_dd_date' => $regn_dd_date, 'regn_dd_bank' => $regn_dd_bank, //varu 'regn_ref_no' =>$regn_ref_no, 'regn_paytm_date'=>$regn_paytm_date, 'regn_upiref_no' =>$regn_upiref_no, 'regn_upi_date' =>$regn_upi_date, 'cash_date'=>$cash_date, 'swipe_date'=>$swipe_date, ); } else if($agreement_payment_type == 'Online Payment') { $type_data = array( 'agreement_cheque_no' => '', 'agreement_cheque_date' =>'', 'agreement_bank' => '', 'agreement_vtr_no' => $agreement_vtr_no, 'agreement_online_date' => $agreement_online_date, 'agreement_dd_no' => '', 'agreement_dd_date' => '', 'agreement_dd_bank' => '', 'agreementpaytm_ref_no' =>'', 'agreementpaytm_online_date1'=>'', 'agreementupi_ref_no'=>'', 'agreementupi_online_date1' =>'', 'payment_id' => $res_id, 'regn_cheque_no' => $regn_cheque_no, 'regn_cheque_date' => $regn_cheque_date, 'regn_bank' => $regn_bank_name, 'regn_vtr_no' => $regn_vtr_no, 'regn_online_date' => $regn_online_date, 'regn_dd_no' => $regn_dd_no, 'regn_dd_date' => $regn_dd_date, 'regn_dd_bank' => $regn_dd_bank, //varu 'regn_ref_no' =>$regn_ref_no, 'regn_paytm_date'=>$regn_paytm_date, 'regn_upiref_no' =>$regn_upiref_no, 'regn_upi_date' =>$regn_upi_date, 'cash_date'=>$cash_date, 'swipe_date'=>$swipe_date, ); } else if($agreement_payment_type == 'DD') { $type_data = array( 'agreement_cheque_no' => '', 'agreement_cheque_date' =>'', 'agreement_bank' => '', 'agreement_vtr_no' => '', 'agreement_online_date' => '', 'agreement_dd_no' =>$agreement_dd_no, 'agreement_dd_date' => $agreement_dd_date, 'agreement_dd_bank' => $agreement_dd_bank, 'agreementpaytm_ref_no' =>'', 'agreementpaytm_online_date1'=>'', 'agreementupi_ref_no'=>'', 'agreementupi_online_date1' =>'', 'payment_id' => $res_id, 'regn_cheque_no' => $regn_cheque_no, 'regn_cheque_date' => $regn_cheque_date, 'regn_bank' => $regn_bank_name, 'regn_vtr_no' => $regn_vtr_no, 'regn_online_date' => $regn_online_date, 'regn_dd_no' => $regn_dd_no, 'regn_dd_date' => $regn_dd_date, 'regn_dd_bank' => $regn_dd_bank, //varu 'regn_ref_no' =>$regn_ref_no, 'regn_paytm_date'=>$regn_paytm_date, 'regn_upiref_no' =>$regn_upiref_no, 'regn_upi_date' =>$regn_upi_date, 'cash_date'=>$cash_date, 'swipe_date'=>$swipe_date, ); } else if($agreement_payment_type == 'Paytm Payment') { $type_data = array( 'agreement_cheque_no' => '', 'agreement_cheque_date' =>'', 'agreement_bank' => '', 'agreement_vtr_no' => '', 'agreement_online_date' => '', 'agreement_dd_no' => '', 'agreement_dd_date' => '', 'agreement_dd_bank' => '', 'agreementpaytm_ref_no' =>$agreementpaytm_ref_no, 'agreementpaytm_online_date1'=>$agreementpaytm_online_date, 'agreementupi_ref_no'=>'', 'agreementupi_online_date1' =>'', 'payment_id' => $res_id, 'regn_cheque_no' => $regn_cheque_no, 'regn_cheque_date' => $regn_cheque_date, 'regn_bank' => $regn_bank_name, 'regn_vtr_no' => $regn_vtr_no, 'regn_online_date' => $regn_online_date, 'regn_dd_no' => $regn_dd_no, 'regn_dd_date' => $regn_dd_date, 'regn_dd_bank' => $regn_dd_bank, //varu 'regn_ref_no' =>$regn_ref_no, 'regn_paytm_date'=>$regn_paytm_date, 'regn_upiref_no' =>$regn_upiref_no, 'regn_upi_date' =>$regn_upi_date, 'cash_date'=>$cash_date, 'swipe_date'=>$swipe_date, ); } else if($agreement_payment_type == 'UPI Payment') { $type_data = array( 'agreement_cheque_no' => '', 'agreement_cheque_date' =>'', 'agreement_bank' => '', 'agreement_vtr_no' => '', 'agreement_online_date' => '', 'agreement_dd_no' => '', 'agreement_dd_date' => '', 'agreement_dd_bank' => '', 'agreementpaytm_ref_no' =>'', 'agreementpaytm_online_date1'=>'', 'agreementupi_ref_no'=>$agreementupi_ref_no, 'agreementupi_online_date1' =>$agreementupi_online_date, 'payment_id' => $res_id, 'regn_cheque_no' => $regn_cheque_no, 'regn_cheque_date' => $regn_cheque_date, 'regn_bank' => $regn_bank_name, 'regn_vtr_no' => $regn_vtr_no, 'regn_online_date' => $regn_online_date, 'regn_dd_no' => $regn_dd_no, 'regn_dd_date' => $regn_dd_date, 'regn_dd_bank' => $regn_dd_bank, //varu 'regn_ref_no' =>$regn_ref_no, 'regn_paytm_date'=>$regn_paytm_date, 'regn_upiref_no' =>$regn_upiref_no, 'regn_upi_date' =>$regn_upi_date, 'cash_date'=>$cash_date, 'swipe_date'=>$swipe_date, ); } else if($agreement_payment_type == 'Cash') { $type_data = array( 'agreement_cheque_no' => '', 'agreement_cheque_date' =>'', 'agreement_bank' => '', 'agreement_vtr_no' => '', 'agreement_online_date' => '', 'agreement_dd_no' =>'', 'agreement_dd_date' => '', 'agreement_dd_bank' => '', 'agreementpaytm_ref_no' =>'', 'agreementpaytm_online_date1'=>'', 'agreementupi_ref_no'=>'', 'agreementupi_online_date1' =>'', 'payment_id' => $res_id, 'regn_cheque_no' => $regn_cheque_no, 'regn_cheque_date' => $regn_cheque_date, 'regn_bank' => $regn_bank_name, 'regn_vtr_no' => $regn_vtr_no, 'regn_online_date' => $regn_online_date, 'regn_dd_no' => $regn_dd_no, 'regn_dd_date' => $regn_dd_date, 'regn_dd_bank' => $regn_dd_bank, //varu 'regn_ref_no' =>$regn_ref_no, 'regn_paytm_date'=>$regn_paytm_date, 'regn_upiref_no' =>$regn_upiref_no, 'regn_upi_date' =>$regn_upi_date, 'cash_date'=>$cash_date, 'swipe_date'=>$swipe_date, ); } $type_table='gss_plot_payment_types'; $up_res_id = $this->gss_model->insert($type_table,$type_data); } if($instalment_payment_type1 != "") { foreach($instalment_payment_type1 as $key=>$val) { $type_data = array( 'payment_id' => $data10[$key], 'agreement_cheque_no' => $agreement_cheque_no, 'agreement_cheque_date' => $agreement_cheque_date, 'agreement_bank' => $agreement_bank_name, 'agreement_vtr_no' => $agreement_vtr_no, 'agreement_online_date' => $agreement_online_date, 'agreement_dd_no' => $agreement_dd_no, 'agreement_dd_date' => $agreement_dd_date, 'agreement_dd_bank' => $agreement_dd_bank, 'agreementpaytm_ref_no' =>$agreementpaytm_ref_no, 'agreementpaytm_online_date1' =>$agreementpaytm_online_date, 'agreementupi_ref_no' =>$agreementupi_ref_no, 'agreementupi_online_date1' =>$agreementupi_online_date, 'regn_cheque_no' => $regn_cheque_no, 'regn_cheque_date' => $regn_cheque_date, 'regn_bank' => $regn_bank_name, 'regn_vtr_no' => $regn_vtr_no, 'regn_online_date' => $regn_online_date, 'regn_dd_no' => $regn_dd_no, 'regn_dd_date' => $regn_dd_date, 'regn_dd_bank' => $regn_dd_bank, 'regn_ref_no'=>$regn_ref_no, 'regn_paytm_date'=>$regn_paytm_date, 'regn_upiref_no'=>$regn_upiref_no, 'regn_upi_date'=>$regn_upi_date, 'cash_date'=>$cash_date, 'swipe_date'=>$swipe_date, 'delete_status' => 'ACTIVE', 'created_at' => $created_at, ); $table='gss_plot_payment_types'; $where=array('type_id'=>$data9[$key]); $this->gss_model->update($where,$table,$type_data); } } else { $type_data = array( 'payment_id' => $res_id, 'agreement_cheque_no' => $agreement_cheque_no, 'agreement_cheque_date' => $agreement_cheque_date, 'agreement_bank' => $agreement_bank_name, 'agreement_vtr_no' => $agreement_vtr_no, 'agreement_online_date' => $agreement_online_date, 'agreement_dd_no' => $agreement_dd_no, 'agreement_dd_date' => $agreement_dd_date, 'agreement_dd_bank' => $agreement_dd_bank, 'agreementpaytm_ref_no' =>$agreementpaytm_ref_no, 'agreementpaytm_online_date1' =>$agreementpaytm_online_date, 'agreementupi_ref_no' =>$agreementupi_ref_no, 'agreementupi_online_date1' =>$agreementupi_online_date, 'regn_cheque_no' => $regn_cheque_no, 'regn_cheque_date' => $regn_cheque_date, 'regn_bank' => $regn_bank_name, 'regn_vtr_no' => $regn_vtr_no, 'regn_online_date' => $regn_online_date, 'regn_dd_no' => $regn_dd_no, 'regn_dd_date' => $regn_dd_date, 'regn_dd_bank' => $regn_dd_bank, 'regn_ref_no'=>$regn_ref_no, 'regn_paytm_date'=>$regn_paytm_date, 'regn_upiref_no'=>$regn_upiref_no, 'regn_upi_date'=>$regn_upi_date, 'cash_date'=>$cash_date, 'swipe_date'=>$swipe_date, 'delete_status' => 'ACTIVE', 'created_at' => $created_at, ); $table='gss_plot_payment_types'; $where=array('type_id'=>$up_res_id); $this->gss_model->update($where,$table,$type_data); } if($loanreg_due_amount1 !=""){ foreach($loanreg_due_amount1 as $key=>$val) { $registration_confirming_types=$this->input->post('registration_confirming_types'); $multireg_data = array( 'booking_id' => $booking_id, 'detail_id' => $detail_id, 'reg_amount ' => $loanreg_due_amount1[$key], //'reg_date' => $loanreg_status1[$key], 'reg_payment_mode`' => $loanregn_payment_type1[$key], 'number' => $loanregn_no1[$key], 'mode_date' => $loanregndate1[$key], 'branch_name' => $loanregn_bank1[$key], 'loan_type' =>$loanregn_amount_type[$key], 'loan_from' =>$loanloan_from[$key], 'registration_confirming_type'=>$registration_confirming_types[$key], 'delete_status' => 'ACTIVE', 'created_at' => $created_at ); $result = $this->gss_model->insert($multireg_table,$multireg_data); } } echo json_encode(array('result'=>1,'message'=>" successfully Added")); } } } } else { echo json_encode(array('result'=>0,'message'=>'Site number '.$site_number.' not booked')); } } else { echo json_encode(array('result'=>2,'message'=>'Site number '.$site_number.' not found')); } } //Add site image public function add_site_image() { $site_id = $this->input->post('site_id'); $this->load->library('image_lib'); $file_name = ""; if($_FILES) { if(empty($_FILES['site_image']['name'])) { $file_name = ""; } else { $target='project_uploads/9_and_11/'; $target.=time().$_FILES['site_image']['name']; $file_name=time().$_FILES['site_image']['name']; $image=$target; move_uploaded_file($_FILES['site_image']['tmp_name'],$target); $config['source_image']=$target; $config['maintain_ratio']=TRUE; // $config['width']=200; // $config['height']=150; $this->image_lib->initialize($config); $this->image_lib->resize(); } } $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $updated_at = $date->format('Y-m-d H:i:s'); $data = array( 'site_image' => $file_name, 'delete_status' => 'ACTIVE', 'updated_at' => $updated_at ); $site_table = 'gss_new_sites'; $where = array('delete_status'=>'ACTIVE','site_id'=>$site_id); $result = $this->gss_model->update($where,$site_table,$data); if($this->db->affected_rows() > 0) { echo json_encode(array('result'=>1,'message'=>"Site image added successfully")); } else { echo json_encode(array('result'=>0,'message'=>"Something went wrong.. try again")); } } //Site available form public function site_availabilities() { $admin_id = session()->get('admin_id'); if($admin_id) { $project_table = 'gss_new_projects'; $where_project = array('delete_status'=>'ACTIVE','project_status'=>'ONGOING'); $order_by = 'project_name'; $data['projects'] = $this->gss_model->get_where_result_orderby_asc($project_table,$where_project,$order_by); $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $this->load->view('admin/site_available_form',$data); } else { redirect('/'); } } //Get approved project image public function get_approved_plan() { $table = 'gss_new_projects'; $project_id = $this->input->post('project_id'); $where = array('project_id'=>$project_id,'delete_status'=>'ACTIVE','project_status'=>'ONGOING'); $result = $this->gss_model->get_where_row($table,$where); if($result) { echo json_encode(array('approved_plan'=>$result,'result'=>1)); } else { echo json_encode(array('result'=>0,'message'=>'Approved plan not found')); } } //Sms-email form public function sms_email() { $admin_id = session()->get('admin_id'); if($admin_id) { $project_table = 'gss_new_projects'; $where_project = array('delete_status'=>'ACTIVE'); $data['projects'] = $this->gss_model->get_where_result($project_table,$where_project); $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $this->load->view('admin/sms_email_form',$data); } else { redirect('/'); } } //Get user contacts public function get_user_contacts() { $table = 'gss_bookings'; $project_id = $this->input->post('project_id'); $where = array('project_id'=>$project_id,'delete_status'=>'ACTIVE'); $result = $this->gss_model->get_where_result($table,$where); $contact_array = array(); $email_array = array(); foreach($result as $value) { $mobile = json_decode($value->mobile); foreach($mobile as $value) { array_push($contact_array,$value); } } foreach($result as $value) { array_push($email_array,$value->email); } $user_contacts = array_filter($contact_array, 'strlen'); $user_emails = array_filter($email_array, 'strlen'); if($result) { echo json_encode(array('user_contacts'=>$result,'result'=>1,'user_contacts'=>$user_contacts,'user_emails'=>$user_emails)); } else { echo json_encode(array('result'=>0,'message'=>'Users not found')); } } //Download user contacts public function download_user_contacts($filename='Contactlist') { $booking_table = 'gss_bookings'; $project_table = 'gss_new_projects'; $project_id = $this->uri->segment(2); $where = array('project_id'=>$project_id,'delete_status'=>'ACTIVE'); $result = $this->gss_model->get_where_result($booking_table,$where); $projects = $this->gss_model->get_where_row($project_table,$where); $contact_array = array(); foreach($result as $value) { $mobile = json_decode($value->mobile); foreach($mobile as $value) { array_push($contact_array,$value); } } $user_contacts = array_filter($contact_array, 'strlen'); $headers1 = $projects->project_name; // just creating the var for field headers to append to below $data1 = ""; $filename = $projects->project_name.' user contacts'; header("Content-type: application/x-msdownload"); header("Content-Disposition: attachment; filename=$filename.xls"); echo $headers1."\t"; foreach($user_contacts as $val) { echo $data1."\n".$val; } } //Commission form public function commission_form() { $admin_id = session()->get('admin_id'); if($admin_id) { $broker_table = 'gss_brokers'; $project_table = 'gss_new_projects'; $notification_table = 'gss_commission_notifications'; $where_project = array('delete_status'=>'ACTIVE','project_status'=>'ONGOING'); $where_reference = array('delete_status'=>'ACTIVE','type'=>'Executives'); $where_associate = array('delete_status'=>'ACTIVE','type'=>'Associate'); $data['associates'] = $this->gss_model->get_where_result($broker_table,$where_associate); $data['projects'] = $this->gss_model->get_where_result($project_table,$where_project); $data['reference'] = $this->gss_model->get_where_result($broker_table,$where_reference); $data['agreement'] = $this->gss_model->commission_notifications(); $data['registration'] = $this->gss_model->commission_notifications(); $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $this->load->view('admin/management',$data); } else { redirect('/'); } } //Notifications public function notifications() { $result = $this->gss_model->commission_notifications(); //print_r($result); if($result) { echo json_encode(array('result'=>1,'notifications'=>$result,'total'=>count($result))); } else { echo json_encode(array('result'=>0)); } } //Reminders from public function reminders() { $admin_id = session()->get('admin_id'); if($admin_id) { $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $this->load->view('admin/reminders',$data); } else { redirect('/'); } } public function get_all_reminders() { $result = $this->gss_model->get_all_reminders(); if($result) { echo json_encode(array('result'=>1,'reminders'=>$result,'total'=>count($result))); } else { echo json_encode(array('result'=>0)); } } //Commission list public function commission_list() { $admin_id = session()->get('admin_id'); if($admin_id) { $broker_table = 'gss_brokers'; $project_table = 'gss_new_projects'; $where_project = array('delete_status'=>'ACTIVE','project_status'=>'ONGOING'); $where_reference = array('delete_status'=>'ACTIVE','type'=>'Executives'); $where_associate = array('delete_status'=>'ACTIVE','type'=>'Associate'); $data['associates'] = $this->gss_model->get_where_result($broker_table,$where_associate); $data['projects'] = $this->gss_model->get_where_result($project_table,$where_project); $data['reference'] = $this->gss_model->get_where_result($broker_table,$where_reference); $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $this->load->view('admin/commission_list',$data); } else { redirect('/'); } } //details for management public function details_for_management() { $instal_table = 'gss_booking_installments'; $site_number = $this->input->post('site_number'); $project_id = $this->input->post('project_id'); $check_site = $this->gss_model->project_details($site_number,$project_id); if($check_site) { $site_result = $this->gss_model->site_booking_details1($site_number,$project_id); if($site_result) { $booking_id = $site_result->booking_id; $detail_id = $site_result->detail_id; $dates = $this->gss_model->executed_dates($booking_id,$detail_id); if($site_result->booking_status == 'CANCELLED') { echo json_encode(array('result'=>3,'message'=>'Site number '.$site_number.' has been cancelled')); } else { echo json_encode(array('result'=>1,'booking_details'=>$site_result,'dates'=>$dates)); } } else { echo json_encode(array('result'=>0,'message'=>'Site number '.$site_number.' not booked')); } } else { echo json_encode(array('result'=>2,'message'=>'Site number '.$site_number.' not found')); } } //Add management details public function add_management_details() { $booking_id = $this->input->post('booking_id'); $detail_id = $this->input->post('detail_id'); $total_commission_perc = $this->input->post('total_commission_perc'); $total_commission_rs = $this->input->post('total_commission_rs'); $payment_on_agreement = $this->input->post('payment_on_agreement'); $payment_on_registration = $this->input->post('payment_on_registration'); $agreement_executed = strtotime($this->input->post('agreement_executed_on')); if($agreement_executed != ""){ $agreement_executed_on = date("Y-m-d", $agreement_executed);; } else { $agreement_executed_on =""; } $registration = strtotime($this->input->post('registration_on')); if($registration != ""){ $registration_on = date("Y-m-d", $registration);; } else { $registration_on=""; } $subtotal_commission_perc = $this->input->post('subtotal_commission_perc'); $subtotal_commission_rs = $this->input->post('subtotal_commission_rs'); $subpayment_on_agreement = $this->input->post('subpayment_on_agreement'); $subpayment_on_registration = $this->input->post('subpayment_on_registration'); $subagreement_executed = strtotime($this->input->post('subagreement_executed_on')); if($subagreement_executed != ""){ $subagreement_executed_on = date("Y-m-d", $subagreement_executed);; } else { $subagreement_executed_on =""; } $subregistration = strtotime($this->input->post('subregistration_on')); if($subregistration != ""){ $subregistration_on = date("Y-m-d", $subregistration);; } else { $subregistration_on =""; } $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $created_at = $date->format('Y-m-d H:i:s'); $data = array( 'booking_id' => $booking_id, 'detail_id' => $detail_id, 'total_commission_perc' => $total_commission_perc, 'total_commission_rs' => $total_commission_rs, 'payment_on_agreement' => $payment_on_agreement, 'agreement_executed_on' => $agreement_executed_on, 'payment_on_registration' => $payment_on_registration, 'registration_on' => $registration_on, 'subtotal_commission_perc' => $subtotal_commission_perc, 'subtotal_commission_rs' => $subtotal_commission_rs, 'subpayment_on_agreement' => $subpayment_on_agreement, 'subagreement_executed_on' => $subagreement_executed_on, 'subpayment_on_registration' => $subpayment_on_registration, 'subregistration_on' => $subregistration_on, 'agreement_status' => 'PENDING', 'registration_status' => 'PENDING', 'delete_status' => 'ACTIVE', 'created_at' => $created_at ); $table = 'gss_management'; $where = array('delete_status'=>'ACTIVE'); $booking_ids = $this->gss_model->get_where_result($table,$where); $array = array(); if(!empty($payment_on_agreement)) { $payment_on_agreement =$payment_on_agreement; } else{ $payment_on_agreement =0; } if(!empty($payment_on_registration)) { $payment_on_registration =$payment_on_registration; } else{ $payment_on_registration =0; } $total = $payment_on_agreement + $payment_on_registration; foreach($booking_ids as $id) { array_push($array, $id->booking_id); } if(in_array($booking_id,$array)) { echo json_encode(array('result'=>2,'message'=>"Commission details already added.. Please update the details")); } else if($total > $total_commission_rs) { echo json_encode(array('result'=>3,'message'=>"Commission exceeded")); } else { //$result1 = $this->gss_model->insert($table,$data1); $result = $this->gss_model->insert($table,$data); if($result) { $table = 'gss_commission_notifications'; $where = array('booking_id'=>$booking_id); $data = array('status'=>'APPROVED'); $update = $this->gss_model->update($where,$table,$data); echo json_encode(array('result'=>1,'message'=>"Data added successfully")); } else { echo json_encode(array('result'=>0,'message'=>"Something went wrong.. try again")); } } } //Management list public function management_list() { $result = $this->gss_model->management_list(); if($result) { echo json_encode($result); } else { echo json_encode(array('result'=>0,'message'=>"No data available")); } } public function submanagement_list() { $id=$_GET['id']; $result = $this->gss_model->submanagement_list($id); if($result) { echo json_encode($result); } else { echo json_encode(array('result'=>0,'message'=>"No data available")); } } //Approve commission public function approve_aggr_commission() { $table = 'gss_management'; $management_id = $this->input->post('management_id'); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $updated_at = $date->format('Y-m-d H:i:s'); $data = array( 'agreement_status' => 'APPROVED', 'delete_status' => 'ACTIVE', 'updated_at' => $updated_at ); $where_id = array('management_id'=>$management_id); $result = $this->gss_model->update($where_id,$table,$data); if($this->db->affected_rows() > 0) { echo json_encode(array('result'=>1,'message'=>"Approved successfully")); } else { echo json_encode(array('result'=>0,'message'=>"Failed to approve. Try again")); } } public function cancel_po() { $table = 'gss_po_generate'; $management_id = $this->input->post('management_id'); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $updated_at = $date->format('Y-m-d H:i:s'); $data = array( //'agreement_status' => 'APPROVED', 'cancel_status' => 'CANCELLED' //'updated_at' => $updated_at ); $where_id = array('id'=>$management_id); $result = $this->gss_model->update($where_id,$table,$data); if($this->db->affected_rows() > 0) { echo json_encode(array('result'=>1,'message'=>"Cancelled successfully")); } else { echo json_encode(array('result'=>0,'message'=>"Failed to cancel. Try again")); } } public function cancelled_po() { $table = 'gss_po_generate'; $management_id = $this->input->post('management_id'); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $updated_at = $date->format('Y-m-d H:i:s'); $data = array( 'cancel_status' => 'CANCEL' ); $where_id = array('id'=>$management_id); $result = $this->gss_model->update($where_id,$table,$data); if($this->db->affected_rows() > 0) { echo json_encode(array('result'=>1,'message'=>"Cancelled is Removed")); } else { echo json_encode(array('result'=>0,'message'=>"Fail. Try again")); } } public function cancel_wo() { $table = 'gss_wo_generate'; $management_id = $this->input->post('management_id'); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $updated_at = $date->format('Y-m-d H:i:s'); $data = array( //'agreement_status' => 'APPROVED', 'cancel_status' => 'CANCELLED' //'updated_at' => $updated_at ); $where_id = array('id'=>$management_id); $result = $this->gss_model->update($where_id,$table,$data); if($this->db->affected_rows() > 0) { echo json_encode(array('result'=>1,'message'=>"Cancelled successfully")); } else { echo json_encode(array('result'=>0,'message'=>"Failed to cancel. Try again")); } } public function cancelled_wo() { $table = 'gss_wo_generate'; $management_id = $this->input->post('management_id'); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $updated_at = $date->format('Y-m-d H:i:s'); $data = array( 'cancel_status' => 'CANCEL' ); $where_id = array('id'=>$management_id); $result = $this->gss_model->update($where_id,$table,$data); if($this->db->affected_rows() > 0) { echo json_encode(array('result'=>1,'message'=>"Cancelled is Removed")); } else { echo json_encode(array('result'=>0,'message'=>"Fail. Try again")); } } //Approve commission public function approve_reg_commission() { $table = 'gss_management'; $management_id = $this->input->post('management_id'); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $updated_at = $date->format('Y-m-d H:i:s'); $data = array( 'registration_status' => 'APPROVED', 'delete_status' => 'ACTIVE', 'updated_at' => $updated_at ); $where_id = array('management_id'=>$management_id); $result = $this->gss_model->update($where_id,$table,$data); if($this->db->affected_rows() > 0) { echo json_encode(array('result'=>1,'message'=>"Approved successfully")); } else { echo json_encode(array('result'=>0,'message'=>"Failed to approve. Try again")); } } //Dis approve commission public function dis_approve_aggr_commission() { $table = 'gss_management'; $management_id = $this->input->post('management_id'); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $updated_at = $date->format('Y-m-d H:i:s'); $data = array( 'agreement_status' => 'PENDING', 'delete_status' => 'ACTIVE', 'updated_at' => $updated_at ); $where_id = array('management_id'=>$management_id); $result = $this->gss_model->update($where_id,$table,$data); if($this->db->affected_rows() > 0) { echo json_encode(array('result'=>1,'message'=>"Dispproved successfully")); } else { echo json_encode(array('result'=>0,'message'=>"Failed to approve. Try again")); } } //Dis approve commission public function dis_approve_reg_commission() { $table = 'gss_management'; $management_id = $this->input->post('management_id'); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $updated_at = $date->format('Y-m-d H:i:s'); $data = array( 'registration_status' => 'PENDING', 'delete_status' => 'ACTIVE', 'updated_at' => $updated_at ); $where_id = array('management_id'=>$management_id); $result = $this->gss_model->update($where_id,$table,$data); if($this->db->affected_rows() > 0) { echo json_encode(array('result'=>1,'message'=>"Dispproved successfully")); } else { echo json_encode(array('result'=>0,'message'=>"Failed to approve. Try again")); } } //Delete commission public function delete_commission() { $table = 'gss_management'; $management_id = $this->input->post('management_id'); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $updated_at = $date->format('Y-m-d H:i:s'); $data = array( 'delete_status' => 'INACTIVE', 'updated_at' => $updated_at ); $where_id = array('management_id'=>$management_id); $result = $this->gss_model->update($where_id,$table,$data); if($this->db->affected_rows() > 0) { echo json_encode(array('result'=>1,'message'=>"Deleted successfully")); } else { echo json_encode(array('result'=>0,'message'=>"Failed to approve. Try again")); } } //Edit commission public function edit_agreecommission() { $admin_id = session()->get('admin_id'); if($admin_id) { $broker_table = 'gss_brokers'; $project_table = 'gss_new_projects'; $where_project = array('delete_status'=>'ACTIVE','project_status'=>'ONGOING'); $where_reference = array('delete_status'=>'ACTIVE','type'=>'Executives'); $where_associate = array('delete_status'=>'ACTIVE','type'=>'Associate'); $where_subassociate = array('delete_status'=>'ACTIVE','type'=>'Sub Associate'); $management_id = $this->uri->segment(2); $data['associates'] = $this->gss_model->get_where_result($broker_table,$where_associate); $data['subassociates'] = $this->gss_model->get_where_result($broker_table,$where_subassociate); $data['projects'] = $this->gss_model->get_where_result($project_table,$where_project); $data['reference'] = $this->gss_model->get_where_result($broker_table,$where_reference); $data['commission'] = $this->gss_model->single_commission_details($management_id); $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $this->load->view('admin/edit_commission',$data); } else { redirect('/'); } } public function edit_regcommission() { $admin_id = session()->get('admin_id'); if($admin_id) { $broker_table = 'gss_brokers'; $project_table = 'gss_new_projects'; $where_project = array('delete_status'=>'ACTIVE','project_status'=>'ONGOING'); $where_reference = array('delete_status'=>'ACTIVE','type'=>'Executives'); $where_associate = array('delete_status'=>'ACTIVE','type'=>'Associate'); $where_subassociate = array('delete_status'=>'ACTIVE','type'=>'Sub Associate'); $management_id = $this->uri->segment(2); $data['associates'] = $this->gss_model->get_where_result($broker_table,$where_associate); $data['subassociates'] = $this->gss_model->get_where_result($broker_table,$where_subassociate); $data['projects'] = $this->gss_model->get_where_result($project_table,$where_project); $data['reference'] = $this->gss_model->get_where_result($broker_table,$where_reference); $data['commission'] = $this->gss_model->single_commission_details($management_id); $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $this->load->view('admin/edit_regcommission',$data); } else { redirect('/'); } } //Update_commission public function update_commission() { $management_id = $this->input->post('management_id'); $booking_id = $this->input->post('booking_id'); $detail_id = $this->input->post('detail_id'); $total_commission_perc = $this->input->post('total_commission_perc'); $total_commission_rs = $this->input->post('total_commission_rs'); $payment_on_agreement = $this->input->post('payment_on_agreement'); $payment_on_registration = $this->input->post('payment_on_registration'); $registration_on = $this->input->post('registration_on'); $subtotal_commission_perc = $this->input->post('subtotal_commission_perc'); $subtotal_commission_rs = $this->input->post('subtotal_commission_rs'); $subpayment_on_agreement = $this->input->post('subpayment_on_agreement'); $subagreement_executed_on = $this->input->post('subagreement_executed_on'); //$subregistration_on = $this->input->post('subregistration_on'); if($registration_on != "") { $date = new DateTime($registration_on); $registration_on = $date->format('Y-m-d'); } $agreement_executed_on = $this->input->post('agreement_executed_on'); if($agreement_executed_on != "") { $date = new DateTime($agreement_executed_on); $agreement_executed_on = $date->format('Y-m-d'); } else { $agreement_executed_on =""; } // if($subregistration_on != "") // { // $date = new DateTime($subregistration_on); // $subregistration_on = $date->format('Y-m-d'); // } $agreement_status = $this->input->post('agreement_status'); $registration_status = $this->input->post('registration_status'); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $created_at = $date->format('Y-m-d H:i:s'); $data = array( 'booking_id' => $booking_id, 'detail_id' => $detail_id, 'total_commission_perc' => $total_commission_perc, 'total_commission_rs' => $total_commission_rs, 'payment_on_agreement' => $payment_on_agreement, 'payment_on_registration' => $payment_on_registration, 'agreement_executed_on' => $agreement_executed_on, 'registration_on' => $registration_on, 'subtotal_commission_perc' => $subtotal_commission_perc, 'subtotal_commission_rs' => $subtotal_commission_rs, 'subpayment_on_agreement' => $subpayment_on_agreement, //'subpayment_on_registration' => $subpayment_on_registration, 'subagreement_executed_on' => $subagreement_executed_on, 'subregistration_on' => $registration_on, 'agreement_status' => $agreement_status, 'registration_status' => $registration_status, 'delete_status' => 'ACTIVE', 'updated_at' => $created_at ); $table = 'gss_management'; $where = array('booking_id'=>$booking_id); $result = $this->gss_model->update($where,$table,$data); if($this->db->affected_rows() > 0) { echo json_encode(array('result'=>1,'message'=>"Updated successfully")); } else { echo json_encode(array('result'=>0,'message'=>"Something went wrong.. try again")); } } //Accounts form public function accounts() { $admin_id = session()->get('admin_id'); if($admin_id) { $result['accounts'] = $this->gss_model->account_management_list(); $result['user_type_id'] = $this->access_id(); $result['access'] = $this->access_details(); $this->load->view('admin/accounts',$result); } else { redirect('/'); } } //Account Management list public function account_management_list() { $result = $this->gss_model->account_management_list(); if($result) { echo json_encode(array('result'=>1,'management_list'=>$result)); } else { echo json_encode(array('result'=>0,'message'=>"No data available")); } } //Commission details public function commission_details() { $admin_id = session()->get('admin_id'); if($admin_id) { $management_table = 'gss_management'; $booking_id = $this->uri->segment(2); $where = array('booking_id'=>$booking_id); $data['aggreement'] = $this->gss_model->commission_dates_and_amounts($booking_id); $data['registration'] = $this->gss_model->commission_dates_and_amounts1($booking_id); $data['commission'] = $this->gss_model->commission($booking_id); //$data['subcommission'] = $this->gss_model->subcommission($booking_id); $data['user'] = $this->gss_model->single_user_account_management_list($booking_id); $data['subuser'] = $this->gss_model->subsingle_user_account_management_list($booking_id); $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $this->load->view('admin/commission_details',$data); } else { redirect('/'); } } //Commission payment public function commission_payment() { $table = 'gss_commission_payments'; $mgnt_table = 'gss_management'; $booking_id = $this->input->post('management_id'); $order_by = 'payment_id'; $where_booking = array('booking_id' => $booking_id,'delete_status' => 'ACTIVE'); $id_result = $this->gss_model->get_where_row($mgnt_table,$where_booking); $management_id = $id_result->management_id; $where = array('management_id'=>$management_id,'delete_status'=>'ACTIVE'); $result = $this->gss_model->get_where_row_orderby($table,$where,$order_by); if($result) { echo json_encode(array('result'=>1,'commission_payment'=>$result)); } else { echo json_encode(array('result'=>0,'message'=>"No data available")); } } //Add commission payment public function add_commission_payment() { $table = 'gss_commission_payments'; $mgnt_table = 'gss_management'; $booking_id = $this->input->post('management_id'); $payment_type = $this->input->post('payment_type'); $commission_type = $this->input->post('commission_type'); $amount = $this->input->post('amount'); $tds = $this->input->post('tds'); $without_tax = $amount*$tds/100; $with_tax = $amount - $without_tax; $cheque_no = ''; $cheque_date = ''; $bank_name = ''; $utr_no = ''; $online_date = ''; $dd_no = ''; $dd_date = ''; $dd_bank = ''; $cash_date = ''; $payment_date =''; $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $created_at = $date->format('Y-m-d H:i:s'); if($payment_type == 'Cheque') { $cheque_no = $this->input->post('check_no'); $cheque_date = $this->input->post('check_date'); if($cheque_date != "") { $date = new DateTime($cheque_date); $cheque_date = $date->format('Y-m-d'); $payment_date= $date->format('Y-m-d'); } $bank_name = $this->input->post('bank_name'); } else if($payment_type == 'Online') { $utr_no = $this->input->post('utr_no'); $online_date = $this->input->post('online_date'); if($online_date != "") { $date = new DateTime($online_date); $online_date = $date->format('Y-m-d'); $payment_date = $date->format('Y-m-d'); } } else if($payment_type == 'DD') { $dd_no = $this->input->post('dd_no'); $dd_date = $this->input->post('dd_date'); if($dd_date != "") { $date = new DateTime($dd_date); $dd_date = $date->format('Y-m-d'); $payment_date = $date->format('Y-m-d'); } $dd_bank = $this->input->post('dd_bank'); } else if($payment_type == 'Cash') { $cheque_date = $this->input->post('cash_date'); if($cheque_date != "") { $date = new DateTime($cheque_date); $cheque_date = $date->format('Y-m-d'); $payment_date = $date->format('Y-m-d'); } } $where_booking = array('booking_id' => $booking_id,'delete_status' => 'ACTIVE'); $id_result = $this->gss_model->get_where_row($mgnt_table,$where_booking); $management_id = $id_result->management_id; $data = array( 'management_id' => $management_id, 'commission_type' => $commission_type, 'payment_type' => $payment_type, 'tds' => $tds, 'amount' => $amount, 'with_tax' => $with_tax, 'cheque_no' => $cheque_no, 'cheque_date' => $cheque_date, 'utr_no' => $utr_no, 'online_date' => $online_date, 'dd_no' => $dd_no, 'dd_date' => $dd_date, 'dd_bank' => $dd_bank, 'bank_name' => $bank_name, 'payment_date' => $payment_date, 'delete_status' => 'ACTIVE', 'created_at' => $created_at ); $where = array('management_id' => $management_id,'delete_status' => 'ACTIVE'); $management = $this->gss_model->get_where_row($mgnt_table,$where); $payments = $this->gss_model->get_where_result($table,$where); $total_commn = $management->total_commission_rs; $paid_amount = ''; foreach($payments as $val) { $paid_amount+= $val->amount; } $total_amount = $paid_amount + $amount; if($total_amount > $total_commn) { echo json_encode(array('result'=>2,'message'=>"Commission amount exceeded")); } else if($payment_type == "") { echo json_encode(array('result'=>3,'message'=>"Select payment type")); } else if($commission_type == "") { echo json_encode(array('result'=>4,'message'=>"Select commission type")); } else { $result = $this->gss_model->insert($table,$data); if($result) { $whr_mgnt = array('management_id'=>$management_id); $data = $this->gss_model->get_where_result($table,$whr_mgnt); if($data) { $agr_array = array(); $regn_array = array(); foreach($data as $val) { array_push($agr_array, $val->commission_type); array_push($regn_array, $val->commission_type); } if(in_array('Agreement',$agr_array) || in_array('Registration',$regn_array)) { $where1 = array('management_id'=>$management_id); $table1 = 'gss_management'; $final_status = array('final_status'=>'APPROVED'); $final_update = $this->gss_model->update($where1,$table1,$final_status); } } echo json_encode(array('result'=>1,'message'=>"Added successfully")); } else { echo json_encode(array('result'=>0,'message'=>"Something went wrong")); } } } //Payment list public function payment_list() { $result = $this->gss_model->payment_list(); if($result) { echo json_encode($result); } else { echo json_encode(array('result'=>0)); } } //Payment details public function payment_details() { $admin_id = session()->get('admin_id'); if($admin_id) { $booking_id = $this->uri->segment(2); /*$data['payment'] = $this->gss_model->payment_details($booking_id); $data['payment_list'] = $this->gss_model->payment_detailsgroup($booking_id); $data['without_install'] = $this->gss_model->payment_withoutinstall($booking_id);*/ $data['agreement_details'] = $this->gss_model->agreement_payment_details($booking_id); $data['installment_details'] = $this->gss_model->installment_payment_details($booking_id); $data['registration1_details'] = $this->gss_model->registration_payment_details($booking_id); $data['others'] = $this->gss_model->payment_withoutinstall($booking_id); //print_r($data['others']);die(); $tbale='gss_registration_amount_details'; $condition=array('booking_id'=>$booking_id,'delete_status'=>'ACTIVE'); $get_reg_amt=$this->gss_model->get_where_result($tbale,$condition); if($get_reg_amt) { $data['more_registration_details']=$get_reg_amt; } else { $data['more_registration_details']=''; } $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $this->load->view('admin/payment_details',$data); } else { redirect('/'); } } //Payment receipt details public function payment_receipt_details() { $booking_id = $this->uri->segment(2); //$data['result'] = $this->gss_model->booking_receipt_site_data($booking_id); /* $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $mobile = $result->mobile1; $number = $mobile.",".$result->mobile2; $todays_date = $date->format('Y-m-d');*/ /*if($result) { echo json_encode(array('result'=>1,'number'=>$number,'todays_date'=>$todays_date,'booking_receipt'=>$result)); } else { echo json_encode(array('result'=>0)); }*/ $table = 'gss_bookings'; $broker_table = 'gss_brokers'; $instal_table = 'gss_booking_installments'; $data['site_result'] = $this->gss_model->user_site_booking_details1($booking_id); $site_result = $this->gss_model->user_site_booking_details1($booking_id); $where = array('booking_id'=>$booking_id,'delete_status'=>'ACTIVE'); $data['instal_result'] = $instal_result = $this->gss_model->get_where_row($instal_table,$where); $detail_id = $instal_result->booking_detal_id; $where = array('booking_id'=>$booking_id); $get_project = $this->gss_model->get_where_row($table,$where); $project_id = $get_project->project_id; $where_project = array('project_id'=>$project_id); $project_table = 'gss_new_projects'; $get_project_details = $this->gss_model->get_where_row($project_table,$where_project); $data['project'] = $get_project_details; $land_owner = $get_project_details->land_owner_id; $land_owner_table = 'gss_land_owners'; $where_land_owner = array('owner_id'=>$land_owner); $get_land_owner = $this->gss_model->get_where_row($land_owner_table,$where_land_owner); $data['land_owner'] = $get_land_owner; $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $check_ids_rows = $this->gss_model->get_payments_types($booking_id,$detail_id); if($check_ids_rows) { $data['res']=$check_ids_rows; } else { $data['res']=$this->gss_model->get_registration_amount($booking_id); } if($get_land_owner->name == 'GSS Project Consultants') { $this->load->view('admin/gss_agreement_receipt',$data); } else { $this->load->view('admin/gss_agreement_ack',$data); } } //registration reciept details public function registration_receipt_details() { $booking_id = $this->uri->segment(2); $ack_no = $this->uri->segment(3); $table = 'gss_bookings'; $broker_table = 'gss_brokers'; $instal_table = 'gss_booking_installments'; $data['site_result'] = $this->gss_model->user_site_booking_details1($booking_id); $site_result = $this->gss_model->user_site_booking_details1($booking_id); $where = array('booking_id'=>$booking_id,'delete_status'=>'ACTIVE'); $data['instal_result'] = $instal_result = $this->gss_model->get_where_row($instal_table,$where); $detail_id = $instal_result->booking_detal_id; $where = array('booking_id'=>$booking_id); $get_project = $this->gss_model->get_where_row($table,$where); $project_id = $get_project->project_id; $where_project = array('project_id'=>$project_id); $project_table = 'gss_new_projects'; $get_project_details = $this->gss_model->get_where_row($project_table,$where_project); $data['project'] = $get_project_details; $land_owner = $get_project_details->land_owner_id; $land_owner_table = 'gss_land_owners'; $where_land_owner = array('owner_id'=>$land_owner); $get_land_owner = $this->gss_model->get_where_row($land_owner_table,$where_land_owner); $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $data['land_owner'] = $get_land_owner; $check_ids_rows = $this->gss_model->get_payments_types($booking_id,$detail_id); if($check_ids_rows) { $data['res']=$check_ids_rows; } else { $data['res']=$this->gss_model->get_registration_amount($booking_id); } $table = 'gss_registration_amount_details'; $where = array('booking_id'=>$booking_id); $data['regs'] = $this->gss_model->get_where_result($table,$where); $data['ack_no'] = $ack_no; $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); if($get_land_owner->name == 'GSS Project Consultants') { $this->load->view('admin/gss_reg_receipt',$data); } else { $this->load->view('admin/gss_reg_ack',$data); } } //registration reciept details public function installment_receipt_details() { $booking_id = $this->uri->segment(2); $payment_id = $this->uri->segment(3); $ack_no = $this->uri->segment(4); $table = 'gss_bookings'; $broker_table = 'gss_brokers'; $instal_table = 'gss_booking_installments'; $data['site_result'] = $this->gss_model->user_site_booking_details1($booking_id); $site_result = $this->gss_model->user_site_booking_details1($booking_id); $where = array('booking_id'=>$booking_id,'delete_status'=>'ACTIVE'); $data['instal_result'] = $instal_result = $this->gss_model->get_where_row($instal_table,$where); $detail_id = $instal_result->booking_detal_id; $where = array('booking_id'=>$booking_id); $get_project = $this->gss_model->get_where_row($table,$where); $project_id = $get_project->project_id; $where_project = array('project_id'=>$project_id); $project_table = 'gss_new_projects'; $get_project_details = $this->gss_model->get_where_row($project_table,$where_project); $data['project'] = $get_project_details; $land_owner = $get_project_details->land_owner_id; $land_owner_table = 'gss_land_owners'; $where_land_owner = array('owner_id'=>$land_owner); $get_land_owner = $this->gss_model->get_where_row($land_owner_table,$where_land_owner); $data['land_owner'] = $get_land_owner; $data['ack_no'] = $ack_no; $data['res'] = $this->gss_model->get_where_installments($payment_id); $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); if($get_land_owner->name == 'GSS Project Consultants') { $this->load->view('admin/gss_installment_receipt',$data); } else { $this->load->view('admin/gss_installment_ack',$data); } } //Delete commistion payment installment public function delete_commission_payment() { $table = 'gss_commission_payments'; $payment_id = $this->input->post('payment_id'); $where = array('payment_id'=>$payment_id); $data = array('delete_status'=>'INACTIVE'); $result = $this->gss_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)); } } //Reports public function reports() { $admin_id = session()->get('admin_id'); $land_owner_id = session()->get('land_owner_id'); if($admin_id) { $broker_table = 'gss_brokers'; $web_table = 'gss_webportals'; $project_table = 'gss_new_projects'; $land_table1 = 'gss_login'; $where_associate = array('delete_status'=>'ACTIVE','type'=>'Associate'); $where_subassociate = array('delete_status'=>'ACTIVE','type'=>'Sub Associate'); $where_logistics = array('delete_status'=>'ACTIVE','type'=>'Logistic'); $where_reference = array('delete_status'=>'ACTIVE','type'=>'Executives'); $where_portal = array('delete_status'=>'ACTIVE'); $where_project = array('delete_status'=>'ACTIVE'); $where1 = array('delete_status'=>'ACTIVE','user_type_id'=>'5'); $portals_order_by = 'webportal'; $associate_order_by = 'associate_name'; $projects_order_by = 'project_name'; $order_by1='username'; $data['webportals'] = $this->gss_model->get_where_result_orderby_asc($web_table,$where_portal,$portals_order_by); $data['associates'] = $this->gss_model->get_where_result_orderby_asc($broker_table,$where_associate,$associate_order_by); $data['subassociates'] = $this->gss_model->get_where_result_orderby_asc($broker_table,$where_subassociate,$associate_order_by); $data['logistics'] = $this->gss_model->get_where_result_orderby_asc($broker_table,$where_logistics,$associate_order_by); $data['reference'] = $this->gss_model->get_where_result_orderby_asc($broker_table,$where_reference,$associate_order_by); //$data['projects'] = $this->gss_model->get_where_result_orderby_asc($project_table,$where_project,$projects_order_by); $data['users'] = $this->gss_model->get_where_result_orderby_asc($land_table1,$where1,$order_by1); $data['projects'] = $this->gss_model->get_projects_ownerwise($admin_id,$land_owner_id); $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $this->load->view('admin/reports',$data); } else { redirect('/'); } } //Booking reports public function get_booking_reports() { $from_date = $_GET['from_date']; if($from_date != "") { $date = new DateTime($from_date); $from_date = $date->format('Y-m-d'); } $to_date =$_GET['to_date']; if($to_date != "") { $date = new DateTime($to_date); $to_date = $date->format('Y-m-d'); } $project = $_GET['project']; if($_GET['reference'] != "") { $reference = $_GET['reference']; } else { $reference = 0; } if($_GET['logistic'] != 'undefined') { $logistic = $_GET['logistic']; } else { $logistic = 0; } if($_GET['associate'] != 'undefined') { $associate = $_GET['associate']; } else { $associate = 0; } if($_GET['ported'] != 'undefined') { $ported = $_GET['ported']; } else { $ported = 0; } $result = $this->gss_model->booking_reports($from_date,$to_date,$project,$reference,$logistic,$associate,$ported); echo json_encode($result); } //Booking contact report public function get_booking_contact_reports() { $from_date = $_GET['from_date']; if($from_date != "") { $date = new DateTime($from_date); $from_date = $date->format('Y-m-d'); } $to_date =$_GET['to_date']; if($to_date != "") { $date = new DateTime($to_date); $to_date = $date->format('Y-m-d'); } $project = $_GET['project']; $reference = $_GET['reference']; $logistic = $_GET['logistic']; $associate = $_GET['associate']; $ported = $_GET['ported']; $result = $this->gss_model->booking_reports($from_date,$to_date,$project,$reference,$logistic,$associate,$ported); echo json_encode($result); } public function edit_subcommission_payment() { $table = 'gss_sub_commission_payments'; $payment_id = $this->input->post('subpayment_id'); $where = array('sub_payment_id'=>$payment_id,'delete_status'=>'ACTIVE'); $result = $this->gss_model->get_where_row($table,$where); if($result) { echo json_encode(array('commission_details'=>$result,'result'=>1)); } else { echo json_encode(array('result'=>0)); } } public function update_subcommission_payment() { $table = 'gss_sub_commission_payments'; $mgnt_table = 'gss_management'; $management_id = $this->input->post('management_id2'); $payment_id = $this->input->post('payment_id2'); $payment_type = $this->input->post('payment_type5'); $commission_type = $this->input->post('commission_type2'); $amount = $this->input->post('amount2'); $tds = $this->input->post('tds2'); $without_tax = $amount*$tds/100; $with_tax = $amount - $without_tax; $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $created_at = $date->format('Y-m-d H:i:s'); $cheque_no = ''; $cheque_date = ''; $bank_name = ''; $utr_no = ''; $online_date = ''; $dd_no = ''; $dd_date = ''; $dd_bank = ''; if($payment_type == 'Cheque') { $cheque_no = $this->input->post('check_no2'); $cheque_date = $this->input->post('check_date2'); if($cheque_date != "") { $date = new DateTime($cheque_date); $cheque_date = $date->format('Y-m-d'); } $bank_name = $this->input->post('bank_name2'); } else if($payment_type == 'Online') { $utr_no = $this->input->post('utr_no2'); $online_date = $this->input->post('online_date2'); if($online_date != "") { $date = new DateTime($online_date); $online_date = $date->format('Y-m-d'); } } else if($payment_type == 'DD') { $dd_no = $this->input->post('dd_no2'); $dd_date = $this->input->post('dd_date2'); if($dd_date != "") { $date = new DateTime($dd_date); $dd_date = $date->format('Y-m-d'); } $dd_bank = $this->input->post('dd_bank2'); } $data = array( 'management_id' => $management_id, 'commission_type' => $commission_type, 'payment_type' => $payment_type, 'tds' => $tds, 'amount' => $amount, 'with_tax' => $with_tax, 'cheque_no' => $cheque_no, 'cheque_date' => $cheque_date, 'utr_no' => $utr_no, 'online_date' => $online_date, 'dd_no' => $dd_no, 'dd_date' => $dd_date, 'dd_bank' => $dd_bank, 'bank_name' => $bank_name, 'delete_status' => 'ACTIVE', 'updated_at' => $created_at ); // print_r($data); // die(); $where = array('sub_payment_id'=>$payment_id); $result = $this->gss_model->update($where,$table,$data); if($this->db->affected_rows() > 0) { echo json_encode(array('result'=>1,'message'=>"Updated successfully")); } else { echo json_encode(array('result'=>0,'message'=>"Something went wrong")); } } public function subcommission_payment() { $table = 'gss_sub_commission_payments'; $mgnt_table = 'gss_management'; $booking_id = $this->input->post('management_id'); $order_by = 'sub_payment_id'; $where_booking = array('booking_id' => $booking_id,'delete_status' => 'ACTIVE'); $id_result = $this->gss_model->get_where_row($mgnt_table,$where_booking); $management_id = $id_result->management_id; $where = array('management_id'=>$management_id,'delete_status'=>'ACTIVE'); $result = $this->gss_model->get_where_row_orderby($table,$where,$order_by); if($result) { echo json_encode(array('result'=>1,'commission_payment'=>$result)); } else { echo json_encode(array('result'=>0,'message'=>"No data available")); } } public function delete_subcommission_payment() { $table = 'gss_sub_commission_payments'; $payment_id = $this->input->post('subpayment_id'); $where = array('sub_payment_id'=>$payment_id); $data = array('delete_status'=>'INACTIVE'); $result = $this->gss_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)); } } //Add commission payment public function add_subcommission_payment() { $table = 'gss_sub_commission_payments'; $mgnt_table = 'gss_management'; $booking_id = $this->input->post('management_id'); $payment_type = $this->input->post('payment_type3'); $commission_type = $this->input->post('commission_type'); $amount = $this->input->post('amount'); $tds = $this->input->post('tds'); $without_tax = $amount*$tds/100; $with_tax = $amount - $without_tax; $cheque_no = ''; $cheque_date = ''; $bank_name = ''; $utr_no = ''; $online_date = ''; $dd_no = ''; $dd_date = ''; $dd_bank = ''; $cash_date = ''; $payment_date =''; $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $created_at = $date->format('Y-m-d H:i:s'); if($payment_type == 'Cheque') { $cheque_no = $this->input->post('check_no2'); $cheque_date = $this->input->post('check_date2'); if($cheque_date != "") { $date = new DateTime($cheque_date); $cheque_date = $date->format('Y-m-d'); $payment_date= $date->format('Y-m-d'); } $bank_name = $this->input->post('bank_name2'); } else if($payment_type == 'Online') { $utr_no = $this->input->post('utr_no2'); $online_date = $this->input->post('online_date2'); if($online_date != "") { $date = new DateTime($online_date); $online_date = $date->format('Y-m-d'); $payment_date = $date->format('Y-m-d'); } } else if($payment_type == 'DD') { $dd_no = $this->input->post('dd_no2'); $dd_date = $this->input->post('dd_date2'); if($dd_date != "") { $date = new DateTime($dd_date); $dd_date = $date->format('Y-m-d'); $payment_date = $date->format('Y-m-d'); } $dd_bank = $this->input->post('dd_bank2'); } else if($payment_type == 'Cash') { $cheque_date = $this->input->post('cash_date2'); if($cheque_date != "") { $date = new DateTime($cheque_date); $cheque_date = $date->format('Y-m-d'); $payment_date = $date->format('Y-m-d'); } } $where_booking = array('booking_id' => $booking_id,'delete_status' => 'ACTIVE'); $id_result = $this->gss_model->get_where_row($mgnt_table,$where_booking); $management_id = $id_result->management_id; $data = array( 'management_id' => $management_id, 'commission_type' => $commission_type, 'payment_type' => $payment_type, 'tds' => $tds, 'amount' => $amount, 'with_tax' => $with_tax, 'cheque_no' => $cheque_no, 'cheque_date' => $cheque_date, 'utr_no' => $utr_no, 'online_date' => $online_date, 'dd_no' => $dd_no, 'dd_date' => $dd_date, 'dd_bank' => $dd_bank, 'bank_name' => $bank_name, 'payment_date' => $payment_date, 'delete_status' => 'ACTIVE', 'created_at' => $created_at ); // print_r($data); // die(); $where = array('management_id' => $management_id,'delete_status' => 'ACTIVE'); $management = $this->gss_model->get_where_row($mgnt_table,$where); $payments = $this->gss_model->get_where_result($table,$where); $total_commn = $management->total_commission_rs; $paid_amount = ''; foreach($payments as $val) { $paid_amount+= $val->amount; } $total_amount = $paid_amount + $amount; if($total_amount > $total_commn) { echo json_encode(array('result'=>2,'message'=>"Commission amount exceeded")); } else if($payment_type == "") { echo json_encode(array('result'=>3,'message'=>"Select payment type")); } else if($commission_type == "") { echo json_encode(array('result'=>4,'message'=>"Select commission type")); } else { $result = $this->gss_model->insert($table,$data); if($result) { $whr_mgnt = array('management_id'=>$management_id); $data = $this->gss_model->get_where_result($table,$whr_mgnt); if($data) { $agr_array = array(); $regn_array = array(); foreach($data as $val) { array_push($agr_array, $val->commission_type); array_push($regn_array, $val->commission_type); } if(in_array('Agreement',$agr_array) || in_array('Registration',$regn_array)) { $where1 = array('management_id'=>$management_id); $table1 = 'gss_management'; $final_status = array('final_status'=>'APPROVED'); $final_update = $this->gss_model->update($where1,$table1,$final_status); } } echo json_encode(array('result'=>1,'message'=>"Added successfully")); } else { echo json_encode(array('result'=>0,'message'=>"Something went wrong")); } } } //Booking Email report public function get_booking_email_reports() { $from_date = $_GET['from_date']; if($from_date != "") { $date = new DateTime($from_date); $from_date = $date->format('Y-m-d'); } $to_date =$_GET['to_date']; if($to_date != "") { $date = new DateTime($to_date); $to_date = $date->format('Y-m-d'); } $project = $_GET['project']; $reference = $_GET['reference']; $logistic = $_GET['logistic']; $associate = $_GET['associate']; $ported = $_GET['ported']; $result = $this->gss_model->booking_reports($from_date,$to_date,$project,$reference,$logistic,$associate,$ported); echo json_encode($result); } /* public function get_all_status_reports() { $project = $_GET['project']; $result = $this->gss_model->status_reports($project); if($result) { echo json_encode($result); } else { echo json_encode(array('result'=>0)); } }*/ /*public function get_status_reports() { $project = $_GET['project']; $result = $this->gss_model->get_status_reports($project); if($result) { echo json_encode($result); } else { echo json_encode(array('result'=>0)); } }*/ //Enquiry reports public function get_enquiry_reports() { $web_portal = $_GET['type']; $from_date = $_GET['from_date']; if($from_date != "") { $date = new DateTime($from_date); $from_date = $date->format('Y-m-d'); } $to_date = $_GET['to_date']; if($to_date != "") { $date = new DateTime($to_date); $to_date = $date->format('Y-m-d'); } $reference = $_GET['reference']; $result = $this->gss_model->enquiry_reports($from_date,$to_date,$web_portal,$reference); if($result) { echo json_encode($result); } else { echo json_encode(array('result'=>0)); } } public function get_enquiry_contact_reports() { // $reference = $this->input->post('reference'); $web_portal = $_GET['type']; $from_date = $_GET['from_date']; $reference = $_GET['reference']; if($from_date != "") { $date = new DateTime($from_date); $from_date = $date->format('Y-m-d'); } $to_date = $_GET['to_date']; if($to_date != "") { $date = new DateTime($to_date); $to_date = $date->format('Y-m-d'); } if($web_portal=='Webportal') { $result = $this->gss_model->enquiry_reports($from_date,$to_date,$web_portal,$reference); } else if($web_portal=='Database') { $result = $this->gss_model->enquiry_databasereports($from_date,$to_date,$web_portal,$reference); } if($result) { echo json_encode($result); } else { echo json_encode(array('result'=>0)); } } public function get_enquiry_email_reports() { // $reference = $this->input->post('reference'); $web_portal = $_GET['type']; $from_date = $_GET['from_date']; $reference = $_GET['reference']; if($from_date != "") { $date = new DateTime($from_date); $from_date = $date->format('Y-m-d'); } $to_date = $_GET['to_date']; if($to_date != "") { $date = new DateTime($to_date); $to_date = $date->format('Y-m-d'); } if($web_portal=='Webportal') { $result = $this->gss_model->enquiry_reports($from_date,$to_date,$web_portal,$reference); } else if($web_portal=='Database') { $result = $this->gss_model->enquiry_databasereports($from_date,$to_date,$web_portal,$reference); } if($result) { echo json_encode($result); } else { echo json_encode(array('result'=>0)); } } public function get_dataenquiry_reports() { // $reference = $this->input->post('reference'); $web_portal = $_GET['type']; $from_date = $_GET['from_date']; if($from_date != "") { $date = new DateTime($from_date); $from_date = $date->format('Y-m-d'); } $to_date = $_GET['to_date']; if($to_date != "") { $date = new DateTime($to_date); $to_date = $date->format('Y-m-d'); } $reference = $_GET['reference']; if($web_portal=='Webportal') { $result = $this->gss_model->enquiry_reports($from_date,$to_date,$web_portal,$reference); } else if($web_portal=='Database') { $result = $this->gss_model->enquiry_databasereports($from_date,$to_date,$web_portal,$reference); } if($result) { echo json_encode($result); } else { echo json_encode(array('result'=>0)); } } //Associate reports public function get_associate_reports() { $from_date = $_GET['from_date']; if($from_date != "") { $date = new DateTime($from_date); $from_date = $date->format('Y-m-d'); } $to_date = $_GET['to_date']; if($to_date != "") { $date = new DateTime($to_date); $to_date = $date->format('Y-m-d'); } //print_r($to_date); $result = $this->gss_model->associate_reports($from_date,$to_date); echo json_encode($result); } public function get_associate_payments() { $booking_id = $_GET['id']; $result = $this->gss_model->associate_payment_reports($booking_id); echo json_encode($result); } public function get_associate_contact_reports() { $from_date = $_GET['from_date']; if($from_date != "") { $date = new DateTime($from_date); $from_date = $date->format('Y-m-d'); } $to_date = $_GET['to_date']; if($to_date != "") { $date = new DateTime($to_date); $to_date = $date->format('Y-m-d'); } $result = $this->gss_model->associate_reports($from_date,$to_date); echo json_encode($result); } public function get_associate_email_reports() { $from_date = $_GET['from_date']; if($from_date != "") { $date = new DateTime($from_date); $from_date = $date->format('Y-m-d'); } $to_date = $_GET['to_date']; if($to_date != "") { $date = new DateTime($to_date); $to_date = $date->format('Y-m-d'); } $result = $this->gss_model->associate_reports($from_date,$to_date); echo json_encode($result); } //Cancellation reports /*public function get_cancellation_reports() { //$type = $this->input->post('type'); $from_date = $_GET['from_date']; //$project_id = $this->input->post('project_id'); if($from_date != "") { $date = new DateTime($from_date); $from_date = $date->format('Y-m-d'); } $to_date = $_GET['to_date']; if($to_date != "") { $date = new DateTime($to_date); $to_date = $date->format('Y-m-d'); } //$reference = $this->input->post('reference'); $result = $this->gss_model->cancellation_reports($from_date,$to_date); echo json_encode($result); }*/ public function get_cancellation_reports() { //$type = $this->input->post('type'); $from_date = $_GET['from_date']; //$project_id = $this->input->post('project_id'); if($from_date != "") { $date = new DateTime($from_date); $from_date = $date->format('Y-m-d'); } $to_date = $_GET['to_date']; if($to_date != "") { $date = new DateTime($to_date); $to_date = $date->format('Y-m-d'); } $project_id = $_GET['project']; $result = $this->gss_model->cancellation_reports($from_date,$to_date,$project_id); echo json_encode($result); } public function get_cancellation_print() { $i = $_GET['id']; $from_date = $_GET['from_date']; if($from_date != "") { $date = new DateTime($from_date); $from_date = $date->format('Y-m-d'); } $to_date = $_GET['to_date']; if($to_date != "") { $date = new DateTime($to_date); $to_date = $date->format('Y-m-d'); } $project_id = $_GET['project']; $result1 = $this->gss_model->new_refund_reports($from_date,$to_date,$project_id); $result2 = $this->gss_model->get_new_refund_reports($i); if($result1) { echo json_encode(array('result'=>1,'message1'=>$result1,'message2'=>$result2)); } else { echo json_encode(array('result'=>0,'message'=>'No Data Found')); } } public function get_refund_reports() { //$type = $this->input->post('type'); $from_date = $_GET['from_date']; //$project_id = $this->input->post('project_id'); if($from_date != "") { $date = new DateTime($from_date); $from_date = $date->format('Y-m-d'); } $to_date = $_GET['to_date']; if($to_date != "") { $date = new DateTime($to_date); $to_date = $date->format('Y-m-d'); } $project_id = $_GET['project']; $result = $this->gss_model->refund_reports($from_date,$to_date,$project_id); echo json_encode($result); } public function get_refund_pending_reports() { //$type = $this->input->post('type'); $from_date = $_GET['from_date']; //$project_id = $this->input->post('project_id'); if($from_date != "") { $date = new DateTime($from_date); $from_date = $date->format('Y-m-d'); } $to_date = $_GET['to_date']; if($to_date != "") { $date = new DateTime($to_date); $to_date = $date->format('Y-m-d'); } $project_id = $_GET['project']; $result = $this->gss_model->refund_pending_reports($from_date,$to_date,$project_id); echo json_encode($result); } public function get_refund_pending_print() { $i = $_GET['id']; $from_date = $_GET['from_date']; if($from_date != "") { $date = new DateTime($from_date); $from_date = $date->format('Y-m-d'); } $to_date = $_GET['to_date']; if($to_date != "") { $date = new DateTime($to_date); $to_date = $date->format('Y-m-d'); } $project_id = $_GET['project']; $result1 = $this->gss_model->refund_pending_reports($from_date,$to_date,$project_id); $result2 = $this->gss_model->get_new_refund_reports($i); if($result1) { echo json_encode(array('result'=>1,'message1'=>$result1,'message2'=>$result2)); } else { echo json_encode(array('result'=>0,'message'=>'No Data Found')); } } //Cancellation reports /*public function get_cancellation_contact_reports() { //$type = $this->input->post('type'); $from_date = $_GET['from_date']; //$project_id = $this->input->post('project_id'); if($from_date != "") { $date = new DateTime($from_date); $from_date = $date->format('Y-m-d'); } $to_date = $_GET['to_date']; if($to_date != "") { $date = new DateTime($to_date); $to_date = $date->format('Y-m-d'); } //$reference = $this->input->post('reference'); $result = $this->gss_model->cancellation_reports($from_date,$to_date); echo json_encode($result); }*/ public function get_cancellation_contact_reports() { //$type = $this->input->post('type'); $from_date = $_GET['from_date']; //$project_id = $this->input->post('project_id'); if($from_date != "") { $date = new DateTime($from_date); $from_date = $date->format('Y-m-d'); } $to_date = $_GET['to_date']; if($to_date != "") { $date = new DateTime($to_date); $to_date = $date->format('Y-m-d'); } $project_id = $_GET['project']; //$reference = $this->input->post('reference'); $result = $this->gss_model->cancellation_reports($from_date,$to_date,$project_id); echo json_encode($result); } /* public function get_cancellation_email_reports() { //$type = $this->input->post('type'); $from_date = $_GET['from_date']; //$project_id = $this->input->post('project_id'); if($from_date != "") { $date = new DateTime($from_date); $from_date = $date->format('Y-m-d'); } $to_date = $_GET['to_date']; if($to_date != "") { $date = new DateTime($to_date); $to_date = $date->format('Y-m-d'); } //$reference = $this->input->post('reference'); $result = $this->gss_model->cancellation_reports($from_date,$to_date); echo json_encode($result); }*/ public function get_cancellation_email_reports() { //$type = $this->input->post('type'); $from_date = $_GET['from_date']; //$project_id = $this->input->post('project_id'); if($from_date != "") { $date = new DateTime($from_date); $from_date = $date->format('Y-m-d'); } $to_date = $_GET['to_date']; if($to_date != "") { $date = new DateTime($to_date); $to_date = $date->format('Y-m-d'); } $project_id = $_GET['project']; //$reference = $this->input->post('reference'); $result = $this->gss_model->cancellation_reports($from_date,$to_date,$project_id); echo json_encode($result); } //Payment reports public function get_payment_reports() { $from_date = $_GET['from_date']; if($from_date != "") { $date = new DateTime($from_date); $from_date = $date->format('Y-m-d'); } $to_date = $_GET['to_date']; if($to_date != "") { $date = new DateTime($to_date); $to_date = $date->format('Y-m-d'); } $p_poject = $_GET['p_poject']; $result = $this->gss_model->payment_reports_receivable($from_date,$to_date,$p_poject); echo json_encode($result); } //Payment reports public function get_payment_contact_reports() { $from_date = $_GET['from_date']; if($from_date != "") { $date = new DateTime($from_date); $from_date = $date->format('Y-m-d'); } $to_date = $_GET['to_date']; if($to_date != "") { $date = new DateTime($to_date); $to_date = $date->format('Y-m-d'); } $p_poject = $_GET['p_poject']; $result = $this->gss_model->payment_reports_receivable($from_date,$to_date,$p_poject); echo json_encode($result); } //Payment email reports public function get_payment_email_reports() { $from_date = $_GET['from_date']; if($from_date != "") { $date = new DateTime($from_date); $from_date = $date->format('Y-m-d'); } $to_date = $_GET['to_date']; if($to_date != "") { $date = new DateTime($to_date); $to_date = $date->format('Y-m-d'); } $p_poject = $_GET['p_poject']; $result = $this->gss_model->payment_reports_receivable($from_date,$to_date,$p_poject); echo json_encode($result); } //Add refund details public function add_refund_details() { $cancellation_id = $this->input->post('cancellation_id'); $refunded_date = $this->input->post('refunded_date'); $due_amount = $this->input->post('due_amount'); $due_with = $this->input->post('due_with'); if($refunded_date != "") { $date = new DateTime($refunded_date); $refunded_date = $date->format('Y-m-d'); } $refunded_amount = $this->input->post('refunded_amount'); $refunded_payment_mode = $this->input->post('refunded_payment_mode'); $cheque_no = ''; $cheque_date = ''; $bank_name = ''; if($refunded_payment_mode == 'Cheque') { $cheque_no = $this->input->post('cheque_no'); $cheque_date = $this->input->post('cheque_date'); if($cheque_date != "") { $date = new DateTime($cheque_date); $cheque_date = $date->format('Y-m-d'); } $bank_name = $this->input->post('bank_name'); } $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $updated_at = $date->format('Y-m-d H:i:s'); $data = array( 'refunded' => 'Yes', 'refunded_date' => $refunded_date, 'refunded_amount' => $refunded_amount, 'refunded_payment_mode' => $refunded_payment_mode, 'cheque_no' => $cheque_no, 'cheque_date' => $cheque_date, 'bank_name' => $bank_name, 'due_amount' => $due_amount, 'due_with' => $due_with, 'updated_at' => $updated_at ); $table = 'gss_cancellations'; $where = array('cancellation_id' => $cancellation_id); $result = $this->gss_model->update($where,$table,$data); $booking = $this->gss_model->get_where_row($table,$where); $booking_table = 'gss_bookings'; $where_booking = array('booking_id' => $booking->booking_id); $update_data = array('booking_status'=> 'REFUNDED'); $result = $this->gss_model->update($where_booking,$booking_table,$update_data); $cancel_table = 'gss_cancellations'; if($this->db->affected_rows() > 0) { $where_user = array('booking_id'=>$booking->booking_id); $user_data = $this->gss_model->get_where_row($booking_table,$where_user); $booking_receipt = $this->gss_model->booking_receipt_site_data($booking->booking_id); $mobile = json_decode($user_data->mobile); $number = rtrim(implode(',', $mobile), ','); $todays_date = $date->format('Y-m-d'); $refunded_data = $this->gss_model->get_where_row($cancel_table,$where_user); echo json_encode(array( 'result' => 1, 'user_data' => $user_data, 'todays_date' => $todays_date, 'number' => $number, 'booking_receipt' => $booking_receipt, 'refunded' => $refunded_data, 'message' => 'Payment details added successfully' )); } else { echo json_encode(array('result'=>0,'message'=>'Something went wrong..try again')); } } //Client reports public function get_client_reports() { $from_date = $_GET['from_date']; if($from_date != "") { $date = new DateTime($from_date); $from_date = $date->format('Y-m-d'); } $to_date = $_GET['to_date']; if($to_date != "") { $date = new DateTime($to_date); $to_date = $date->format('Y-m-d'); } $c_project = $_GET['c_project']; $reference = $_GET['reference']; $result = $this->gss_model->client_reports($from_date,$to_date,$c_project,$reference); if($result) { echo json_encode($result); } else { echo json_encode(array('result'=>0)); } } public function get_client_contact_reports() { $from_date = $_GET['from_date']; if($from_date != "") { $date = new DateTime($from_date); $from_date = $date->format('Y-m-d'); } $to_date = $_GET['to_date']; if($to_date != "") { $date = new DateTime($to_date); $to_date = $date->format('Y-m-d'); } $result = $this->gss_model->client_reports($from_date,$to_date); if($result) { echo json_encode($result); } else { echo json_encode(array('result'=>0)); } } public function get_client_email_reports() { $from_date = $_GET['from_date']; if($from_date != "") { $date = new DateTime($from_date); $from_date = $date->format('Y-m-d'); } $to_date = $_GET['to_date']; if($to_date != "") { $date = new DateTime($to_date); $to_date = $date->format('Y-m-d'); } $result = $this->gss_model->client_reports($from_date,$to_date); if($result) { echo json_encode($result); } else { echo json_encode(array('result'=>0)); } } //Sites reports public function get_sites_reports() { $project_id = $_GET['project_id']; $from_date = $_GET['from_date']; if($from_date != "") { $date = new DateTime($from_date); $from_date = $date->format('Y-m-d'); } $to_date = $_GET['to_date']; if($to_date != "") { $date = new DateTime($to_date); $to_date = $date->format('Y-m-d'); } $result = $this->gss_model->sites_reports($project_id,$from_date,$to_date); //print_r($result); if($result) { echo json_encode($result); } else { echo json_encode(array('result'=>0)); } } public function get_sites_contact_reports() { $project_id = $_GET['project_id']; $from_date = $_GET['from_date']; if($from_date != "") { $date = new DateTime($from_date); $from_date = $date->format('Y-m-d'); } $to_date = $_GET['to_date']; if($to_date != "") { $date = new DateTime($to_date); $to_date = $date->format('Y-m-d'); } $result = $this->gss_model->sites_reports($project_id,$from_date,$to_date); if($result) { echo json_encode($result); } else { echo json_encode(array('result'=>0)); } } public function get_sites_email_reports() { $project_id = $_GET['project_id']; $from_date = $_GET['from_date']; if($from_date != "") { $date = new DateTime($from_date); $from_date = $date->format('Y-m-d'); } $to_date = $_GET['to_date']; if($to_date != "") { $date = new DateTime($to_date); $to_date = $date->format('Y-m-d'); } $result = $this->gss_model->sites_reports($project_id,$from_date,$to_date); if($result) { echo json_encode($result); } else { echo json_encode(array('result'=>0)); } } //Loans public function loans() { $admin_id = session()->get('admin_id'); $loan_user_id = session()->get('loan_user_id'); $project_table = 'gss_new_projects'; $where_project = array('delete_status'=>'ACTIVE','project_status'=>'ONGOING'); $order_by = 'project_name'; $data['projects'] = $this->gss_model->get_where_result_orderby_asc($project_table,$where_project,$order_by); $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); if($admin_id || $loan_user_id) { $this->load->view('admin/loans_list',$data); } else { redirect('/'); } } //Loans list public function get_loans_list() { $project = $_GET['l_project_id']; /*$project =$this->input->post('l_project_id');*/ $result = $this->gss_model->get_loans_list($project); if($result) { echo json_encode($result); } else { echo json_encode(array('result'=>0)); } } public function get_loansagree_list() { $project = $_GET['l_project_id']; /*$project =$this->input->post('l_project_id');*/ $result = $this->gss_model->get_loansagree_list($project); if($result) { echo json_encode($result); } else { echo json_encode(array('result'=>0)); } } //loan form public function loan_form() { $admin_id = session()->get('admin_id'); if($admin_id) { $table = 'gss_login'; $booking_table = 'gss_bookings'; $where = array('user_type_id' => '6'); $data['booking_id'] = $this->uri->segment(2); $booking_id = $this->uri->segment(2); $where_booking = array('booking_id' => $booking_id); $data['source_type'] = $this->gss_model->get_where_row($booking_table,$where_booking); $data['loan_admins'] = $this->gss_model->get_where_result($table,$where); $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $this->load->view('admin/loan_form',$data); } else { redirect('/'); } } //Add loan detailss public function add_loan_details() { $booking_id = $this->input->post('booking_id'); $sale_agreement_amount1 = $this->input->post('sale_agreement_amount'); $sale_agreement_amount = str_replace(',', '', $sale_agreement_amount1); $loan_amount_applied1 = $this->input->post('loan_amount_applied'); $loan_amount_applied = str_replace(',', '', $loan_amount_applied1); $financial_institution = $this->input->post('financial_institution'); $processing_fees1 = $this->input->post('processing_fees'); $processing_fees = str_replace(',', '', $processing_fees1); $applied_on = $this->input->post('applied_on'); $source_type = $this->input->post('source_type'); $source_bank_name = $this->input->post('source_bank_name'); if($applied_on != "") { $date = new DateTime($applied_on); $applied_on = $date->format('Y-m-d'); } $sanctioned_date = $this->input->post('sanctioned_date'); if($sanctioned_date != "") { $date = new DateTime($sanctioned_date); $sanctioned_date = $date->format('Y-m-d'); } $disbursed_date = $this->input->post('disbursed_date'); if($disbursed_date != "") { $date = new DateTime($disbursed_date); $disbursed_date = $date->format('Y-m-d'); } $bank_name = $this->input->post('bank_name'); $cheque_no = $this->input->post('cheque_no'); $cheque_date = $this->input->post('cheque_date'); if($cheque_date != "") { $date = new DateTime($cheque_date); $cheque_date = $date->format('Y-m-d'); } $disbursed_cheque_amount1 = $this->input->post('disbursed_cheque_amount'); $disbursed_cheque_amount = str_replace(',', '', $disbursed_cheque_amount1); $remarks = $this->input->post('remarks'); $follow_up = $this->input->post('follow_up'); $this->load->library('image_lib'); if($_FILES) { if(empty($_FILES['cheque_scanned_copy']['name'])) { $file_name = ""; } else { $target='loan_uploads/'; $target.=time().$_FILES['cheque_scanned_copy']['name']; $file_name=time().$_FILES['cheque_scanned_copy']['name']; $image=$target; move_uploaded_file($_FILES['cheque_scanned_copy']['tmp_name'],$target); $config['source_image']=$target; $config['maintain_ratio']=TRUE; //$config['width']=200; //$config['height']=450; $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( 'booking_id' => $booking_id, 'sale_agreement_amount' => $sale_agreement_amount, 'loan_amount_applied' => $loan_amount_applied, 'financial_institution' => $financial_institution, 'processing_fees' => $processing_fees, 'applied_on' => $applied_on, 'sanctioned_date' => $sanctioned_date, 'disbursed_date' => $disbursed_date, 'bank_name' => $bank_name, 'cheque_no' => $cheque_no, 'cheque_date' => $cheque_date, 'disbursed_cheque_amount' => $disbursed_cheque_amount, 'remarks' => $remarks, 'follow_up' => $follow_up, 'cheque_scanned_copy' => $file_name, 'delete_status' => 'ACTIVE', 'created_at' => $created_at ); $table = 'gss_loans'; $where = array('booking_id' => $booking_id); $check_booking = $this->gss_model->get_where_row($table,$where); if($check_booking) { echo json_encode(array('result'=>2,'message'=>"Details already exists.. Please edit content")); } else { $booking_table = 'gss_bookings'; $source_data = array('source_type'=>$source_type,'source_bank_name'=>$source_bank_name); $update_source = $this->gss_model->update($where,$booking_table,$source_data); $result = $this->gss_model->insert($table,$data); if($result) { echo json_encode(array('result'=>1,'message'=>"Details added successfully")); } else { echo json_encode(array('result'=>0,'message'=>"Something went wrong.. try again")); } } } //Loans list public function get_loan_details() { $booking_id = $this->input->post('booking_id'); $result = $this->gss_model->get_loan_details($booking_id); if($result) { echo json_encode(array('result'=>1,'loan_details'=>$result)); } else { echo json_encode(array('result'=>0)); } } //Edit loan form public function edit_loan() { $admin_id = session()->get('admin_id'); if($admin_id) { $admin_table = 'gss_login'; $table = 'gss_loans'; $loan_id = $this->uri->segment(2); $data['loan_id'] = $this->uri->segment(2); $where = array('loan_id' => $loan_id); $where_admin = array('user_type_id' => '6'); $data['details'] = $this->gss_model->get_where_row($table,$where); $booking_id=$data['details']->booking_id; $booking_table = 'gss_bookings'; $where_booking = array('booking_id' => $booking_id); $data['source_type'] = $this->gss_model->get_where_row($booking_table,$where_booking); //print_r($data['source_type']); //die(); $data['details'] = $this->gss_model->get_where_row($table,$where); $data['loan_admins'] = $this->gss_model->get_where_result($admin_table,$where_admin); $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $this->load->view('admin/edit_loan_form',$data); } else { redirect('/'); } } //Update loan detailss public function update_loan_details() { $loan_id = $this->input->post('loan_id'); $booking_id = $this->input->post('booking_id'); $sale_agreement_amount1 = $this->input->post('sale_agreement_amount'); $sale_agreement_amount = str_replace(',', '', $sale_agreement_amount1); $loan_amount_applied1 = $this->input->post('loan_amount_applied'); $loan_amount_applied = str_replace(',', '', $loan_amount_applied1); $financial_institution = $this->input->post('financial_institution'); $processing_fees1 = $this->input->post('processing_fees'); $processing_fees = str_replace(',', '', $processing_fees1); $applied_on = $this->input->post('applied_on'); $source_type = $this->input->post('source_type'); if($applied_on != "") { $date = new DateTime($applied_on); $applied_on = $date->format('Y-m-d'); } $sanctioned_date = $this->input->post('sanctioned_date'); if($sanctioned_date != "") { $date = new DateTime($sanctioned_date); $sanctioned_date = $date->format('Y-m-d'); } $disbursed_date = $this->input->post('disbursed_date'); if($disbursed_date != "") { $date = new DateTime($disbursed_date); $disbursed_date = $date->format('Y-m-d'); } $bank_name = $this->input->post('bank_name'); $cheque_no = $this->input->post('cheque_no'); $cheque_date = $this->input->post('cheque_date'); if($cheque_date != "") { $date = new DateTime($cheque_date); $cheque_date = $date->format('Y-m-d'); } $disbursed_cheque_amount1 = $this->input->post('disbursed_cheque_amount'); $disbursed_cheque_amount = str_replace(',', '', $disbursed_cheque_amount1); $remarks = $this->input->post('remarks'); $follow_up = $this->input->post('follow_up'); $table = 'gss_loans'; $where = array('loan_id' => $loan_id); $this->load->library('image_lib'); if(empty($_FILES['cheque_scanned_copy']['name'])) { $check_booking = $this->gss_model->get_where_row($table,$where); $file_name = $check_booking->cheque_scanned_copy; } else { $target='loan_uploads/'; $target.=time().$_FILES['cheque_scanned_copy']['name']; $file_name=time().$_FILES['cheque_scanned_copy']['name']; $image=$target; move_uploaded_file($_FILES['cheque_scanned_copy']['tmp_name'],$target); $config['source_image']=$target; $config['maintain_ratio']=TRUE; //$config['width']=200; //$config['height']=450; $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( 'booking_id' => $booking_id, 'sale_agreement_amount' => $sale_agreement_amount, 'loan_amount_applied' => $loan_amount_applied, 'financial_institution' => $financial_institution, 'processing_fees' => $processing_fees, 'applied_on' => $applied_on, 'sanctioned_date' => $sanctioned_date, 'disbursed_date' => $disbursed_date, 'bank_name' => $bank_name, 'cheque_no' => $cheque_no, 'cheque_date' => $cheque_date, 'disbursed_cheque_amount' => $disbursed_cheque_amount, 'remarks' => $remarks, 'follow_up' => $follow_up, 'cheque_scanned_copy' => $file_name, 'delete_status' => 'ACTIVE', 'updated_at' => $created_at ); if($source_type != "0") { $booking_table = 'gss_bookings'; $where_booking = array('booking_id' => $booking_id); $source_data = array('source_type' => $source_type); $this->gss_model->update($where_booking,$booking_table,$source_data); } $result = $this->gss_model->update($where,$table,$data); if($this->db->affected_rows() > 0) { echo json_encode(array('result'=>1,'message'=>"Details updated successfully")); } else { echo json_encode(array('result'=>0,'message'=>"Something went wrong.. try again")); } } //Loans reports public function get_loans_reports() { $project_status = $_GET['project_status']; $project_id = $_GET['project']; //$result = $this->gss_model->get_loans_reports($project_id); $result = $this->gss_model->get_loansreports($project_status,$project_id); if($result) { echo json_encode($result); } else { echo json_encode(array('result'=>0)); } } public function get_loans_contact_reports() { $project_status = $_GET['project_status']; $project_id = $_GET['project']; // $project_id = $this->input->post('project_id'); //$result = $this->gss_model->get_loans_reports($project_id); $result = $this->gss_model->get_loansreports($project_status,$project_id); if($result) { echo json_encode($result); } else { echo json_encode(array('result'=>0)); } } public function get_loans_email_reports() { $project_status = $_GET['project_status']; $project_id = $_GET['project']; // $project_id = $this->input->post('project_id'); //$result = $this->gss_model->get_loans_reports($project_id); $result = $this->gss_model->get_loansreports($project_status,$project_id); if($result) { echo json_encode($result); } else { echo json_encode(array('result'=>0)); } } //Reception form public function reception_form() { $admin_id = session()->get('admin_id'); if($admin_id) { $project_table = 'gss_new_projects'; $where_project = array('delete_status'=>'ACTIVE'); $order_by = 'project_name'; $data['projects'] = $this->gss_model->get_where_result_alphabetical($project_table,$where_project,$order_by); $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $this->load->view('admin/reception_form',$data); } else { redirect('/'); } } //Add reception detailss public function add_reception_details() { $booking_id = $this->input->post('booking_id'); $detail_id = $this->input->post('detail_id'); $project_id = $this->input->post('project_id'); $site_number = $this->input->post('site_number'); $customer_name = $this->input->post('customer_name'); $client_khatha = $this->input->post('client_khatha'); $dispatched_type = $this->input->post('dispatched_type'); $dispatched_date = $this->input->post('dispatched_date'); if($dispatched_date != "") { $date = new DateTime($dispatched_date); $dispatched_date = $date->format('Y-m-d'); } $this->load->library('image_lib'); if($_FILES) { if(empty($_FILES['nine_and_eleven_copy']['name'])) { $nine_and_eleven_copy = ""; } else { $target='reception_uploads/'; $target.=time().$_FILES['nine_and_eleven_copy']['name']; $nine_and_eleven_copy=time().$_FILES['nine_and_eleven_copy']['name']; $image=$target; move_uploaded_file($_FILES['nine_and_eleven_copy']['tmp_name'],$target); $config['source_image']=$target; $config['maintain_ratio']=TRUE; //$config['width']=200; //$config['height']=450; $this->image_lib->initialize($config); $this->image_lib->resize(); } if(empty($_FILES['muda_khatha']['name'])) { $muda_khatha = ""; } else { $target='reception_uploads/'; $target.=time().$_FILES['muda_khatha']['name']; $muda_khatha=time().$_FILES['muda_khatha']['name']; $image=$target; move_uploaded_file($_FILES['muda_khatha']['tmp_name'],$target); $config['source_image']=$target; $config['maintain_ratio']=TRUE; //$config['width']=200; //$config['height']=450; $this->image_lib->initialize($config); $this->image_lib->resize(); } if(empty($_FILES['other_document']['name'])) { $other_document = ""; } else { $target='reception_uploads/'; $target.=time().$_FILES['other_document']['name']; $other_document=time().$_FILES['other_document']['name']; $image=$target; move_uploaded_file($_FILES['other_document']['tmp_name'],$target); $config['source_image']=$target; $config['maintain_ratio']=TRUE; //$config['width']=200; //$config['height']=450; $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( 'booking_id_fk' => $booking_id, 'detail_id_fk' => $detail_id, 'project_id' => $project_id, 'site_number' => $site_number, 'nine_and_eleven_copy' => $nine_and_eleven_copy, 'muda_khatha' => $muda_khatha, 'other_document' => $other_document, 'client_name' => $customer_name, 'client_khatha' => $client_khatha, 'dispatched_type' => $dispatched_type, 'dispatched_date' => $dispatched_date, 'delete_status' => 'ACTIVE', 'created_at' => $created_at ); $table = 'gss_reception'; if($booking_id != "" && $detail_id != "") { $where = array('project_id' => $project_id,'site_number' => $site_number,'delete_status'=>'ACTIVE'); $check_booking = $this->gss_model->get_where_row($table,$where); if($check_booking) { echo json_encode(array('result'=>2,'message'=>"Details already exists.. Please edit content")); } else { $result = $this->gss_model->insert($table,$data); if($result) { echo json_encode(array('result'=>1,'message'=>"Details added successfully")); } else { echo json_encode(array('result'=>0,'message'=>"Something went wrong.. try again")); } } } else { $where = array('project_id' => $project_id,'site_number' => $site_number,'delete_status'=>'ACTIVE'); $check_booking = $this->gss_model->get_where_row($table,$where); if($check_booking) { echo json_encode(array('result'=>2,'message'=>"Details already exists.. Please edit content")); } else { $result = $this->gss_model->insert($table,$data); if($result) { echo json_encode(array('result'=>1,'message'=>"Details added successfully")); } else { echo json_encode(array('result'=>0,'message'=>"Something went wrong.. try again")); } } } } //Reception list form public function reception_list() { $admin_id = session()->get('admin_id'); if($admin_id) { $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $this->load->view('admin/reception_list',$data); } else { redirect('/'); } } //Reception list public function get_reception_list() { $booked = $this->gss_model->reception_list(); // $not_booked = $this->gss_model->reception_list1(); if($booked) { echo json_encode($booked); } else { echo json_encode(array('result'=>0)); } } //Delete reception public function delete_reception() { $table = 'gss_reception'; $reception_id = $this->input->post('reception_id'); $where = array('reception_id'=>$reception_id); $data = array('delete_status'=>'INACTIVE'); $result = $this->gss_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)); } } //Edit reception public function edit_reception_details() { $admin_id = session()->get('admin_id'); if($admin_id) { $project_table = 'gss_new_projects'; $where_project = array('delete_status'=>'ACTIVE'); $order_by = 'project_name'; $data['projects'] = $this->gss_model->get_where_result_alphabetical($project_table,$where_project,$order_by); $reception_table = 'gss_reception'; $reception_id = $this->uri->segment(2); $data['result'] = $this->gss_model->edit_reception($reception_id); $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $this->load->view('admin/edit_reception',$data); } else { redirect('/'); } } //Edit reception for non booked sites public function edit_reception() { $admin_id = session()->get('admin_id'); if($admin_id) { $project_table = 'gss_new_projects'; $where_project = array('delete_status'=>'ACTIVE'); $data['projects'] = $this->gss_model->get_where_result($project_table,$where_project); $reception_table = 'gss_reception'; $reception_id = $this->uri->segment(2); $data['result'] = $this->gss_model->edit_reception1($reception_id); $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $this->load->view('admin/not_booked_edit_reception',$data); } else { redirect('/'); } } //Update reception detailss public function update_reception() { $reception_id = $this->input->post('reception_id'); $booking_id = $this->input->post('booking_id'); $detail_id = $this->input->post('detail_id'); $project_id = $this->input->post('project_id'); $site_number = $this->input->post('site_number'); $customer_name = $this->input->post('customer_name'); $client_khatha = $this->input->post('client_khatha'); $dispatched_type = $this->input->post('dispatched_type'); $dispatched_date = $this->input->post('dispatched_date'); if($dispatched_date != "") { $date = new DateTime($dispatched_date); $dispatched_date = $date->format('Y-m-d'); } $table = 'gss_reception'; $where = array('reception_id' => $reception_id); $this->load->library('image_lib'); if(empty($_FILES['nine_and_eleven_copy']['name'])) { $check_file = $this->gss_model->get_where_row($table,$where); $nine_and_eleven_copy = $check_file->nine_and_eleven_copy; } else { $target='reception_uploads/'; $target.=time().$_FILES['nine_and_eleven_copy']['name']; $nine_and_eleven_copy=time().$_FILES['nine_and_eleven_copy']['name']; $image=$target; move_uploaded_file($_FILES['nine_and_eleven_copy']['tmp_name'],$target); $config['source_image']=$target; $config['maintain_ratio']=TRUE; //$config['width']=200; //$config['height']=450; $this->image_lib->initialize($config); $this->image_lib->resize(); } if(empty($_FILES['muda_khatha']['name'])) { $check_file = $this->gss_model->get_where_row($table,$where); $muda_khatha = $check_file->muda_khatha; } else { $target='reception_uploads/'; $target.=time().$_FILES['muda_khatha']['name']; $muda_khatha=time().$_FILES['muda_khatha']['name']; $image=$target; move_uploaded_file($_FILES['muda_khatha']['tmp_name'],$target); $config['source_image']=$target; $config['maintain_ratio']=TRUE; //$config['width']=200; //$config['height']=450; $this->image_lib->initialize($config); $this->image_lib->resize(); } if(empty($_FILES['other_document']['name'])) { $check_file = $this->gss_model->get_where_row($table,$where); $other_document = $check_file->other_document; } else { $target='reception_uploads/'; $target.=time().$_FILES['other_document']['name']; $other_document=time().$_FILES['other_document']['name']; $image=$target; move_uploaded_file($_FILES['other_document']['tmp_name'],$target); $config['source_image']=$target; $config['maintain_ratio']=TRUE; //$config['width']=200; //$config['height']=450; $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( 'booking_id_fk' => $booking_id, 'detail_id_fk' => $detail_id, 'project_id' => $project_id, 'site_number' => $site_number, 'nine_and_eleven_copy' => $nine_and_eleven_copy, 'muda_khatha' => $muda_khatha, 'other_document' => $other_document, 'client_name' => $customer_name, 'client_khatha' => $client_khatha, 'dispatched_type' => $dispatched_type, 'dispatched_date' => $dispatched_date, 'delete_status' => 'ACTIVE', 'updated_at' => $created_at ); $result = $this->gss_model->update($where,$table,$data); if($this->db->affected_rows() > 0) { echo json_encode(array('result'=>1,'message'=>"Updated successfully")); } else { echo json_encode(array('result'=>0,'message'=>"Something went wrong.. try again")); } } //Reception reports public function get_reception_reports() { $from_date = $_GET['from_date']; if($from_date != "") { $date = new DateTime($from_date); $from_date = $date->format('Y-m-d'); } $to_date = $_GET['to_date']; if($to_date != "") { $date = new DateTime($to_date); $to_date = $date->format('Y-m-d'); } $project_id = $_GET['project_id']; $result = $this->gss_model->get_reception_reports($from_date,$to_date,$project_id); if($result) { echo json_encode($result); } else { echo json_encode(array('result'=>0)); } } public function get_reception_contact_reports() { $from_date = $_GET['from_date']; if($from_date != "") { $date = new DateTime($from_date); $from_date = $date->format('Y-m-d'); } $to_date = $_GET['to_date']; if($to_date != "") { $date = new DateTime($to_date); $to_date = $date->format('Y-m-d'); } $project_id = $_GET['project_id']; $result = $this->gss_model->get_reception_reports($from_date,$to_date,$project_id); if($result) { echo json_encode($result); } else { echo json_encode(array('result'=>0)); } } public function get_reception_email_reports() { $from_date = $_GET['from_date']; if($from_date != "") { $date = new DateTime($from_date); $from_date = $date->format('Y-m-d'); } $to_date = $_GET['to_date']; if($to_date != "") { $date = new DateTime($to_date); $to_date = $date->format('Y-m-d'); } $project_id = $_GET['project_id']; $result = $this->gss_model->get_reception_reports($from_date,$to_date,$project_id); if($result) { echo json_encode($result); } else { echo json_encode(array('result'=>0)); } } //All sales public function get_all_sales() { $result = $this->gss_model->get_all_sales(); if($result) { echo json_encode(array('result'=>1,'total'=>count($result),'all_sales'=>$result)); } else { echo json_encode(array('result'=>0)); } } //Datewise sales public function datewise_sales_for_chart() { $from_date = $this->input->post('from_date'); if($from_date != "") { $date = new DateTime($from_date); $from_date = $date->format('Y-m-d'); } $to_date = $this->input->post('to_date'); if($to_date != "") { $date = new DateTime($to_date); $to_date = $date->format('Y-m-d'); } $result = $this->gss_model->datewise_sales_for_chart($from_date,$to_date); if($result) { echo json_encode(array('result'=>1,'all_sales'=>$result,'total'=>count($result))); } else { echo json_encode(array('result'=>0)); } } public function executive_sales_for_chart() { $from_date = $this->input->post('from_date'); if($from_date != "") { $date = new DateTime($from_date); $from_date = $date->format('Y-m-d'); } $to_date = $this->input->post('to_date'); if($to_date != "") { $date = new DateTime($to_date); $to_date = $date->format('Y-m-d'); } $executive = $this->input->post('reference'); $result = $this->gss_model->executive_sales_for_chart($from_date,$to_date,$executive); if($result) { echo json_encode(array('result'=>1,'all_sales'=>$result,'total'=>count($result))); } else { echo json_encode(array('result'=>0)); } } //Brokers reports public function get_broker_report() { $table = 'gss_brokers'; $broker_type = $this->input->post('broker_type'); $where = array('type' => $broker_type); $result = $this->gss_model->get_where_result($table,$where); if($result) { echo json_encode(array('result'=>1,'brokers_list'=>$result,'total'=>count($result))); } else { echo json_encode(array('result'=>0)); } } //Excel format download public function excel_format($filename='Sites_format') { header("Content-Type: application/vnd.ms-excel"); header("Content-Disposition: attachment; filename=site_excel_format.xls"); header("Pragma: no-cache"); header("Expires: 0"); flush(); include 'PHPExcel/IOFactory.php'; $objPHPExcel = new PHPExcel(); // here fill data to your Excel sheet $row = $objPHPExcel->getActiveSheet()->getHighestRow()+0; $objPHPExcel->getActiveSheet()->SetCellValue('A'.$row, 'SITE NO'); $objPHPExcel->getActiveSheet()->SetCellValue('B'.$row, 'NORTH (in mtrs)'); $objPHPExcel->getActiveSheet()->SetCellValue('C'.$row, 'SOUTH (in mtrs)'); $objPHPExcel->getActiveSheet()->SetCellValue('D'.$row, 'EAST(IN MTRS)'); $objPHPExcel->getActiveSheet()->SetCellValue('E'.$row, 'WEST (IN MTRS)'); $objPHPExcel->getActiveSheet()->SetCellValue('F'.$row, 'TOTAL IN SQ MTRS'); $objPHPExcel->getActiveSheet()->SetCellValue('G'.$row, 'TOTAL IN SFT'); $objPHPExcel->getActiveSheet()->SetCellValue('H'.$row, 'EAST FACING'); $objPHPExcel->getActiveSheet()->SetCellValue('I'.$row, 'WEST FACING'); $objPHPExcel->getActiveSheet()->SetCellValue('J'.$row, 'NORTH FACING'); $objPHPExcel->getActiveSheet()->SetCellValue('K'.$row, 'SOUTH FACING'); $objPHPExcel->getActiveSheet()->SetCellValue('L'.$row, 'STATUS'); $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5'); $objWriter->save('php://output'); } //Edit commission payment public function edit_commission_payment() { $table = 'gss_commission_payments'; $payment_id = $this->input->post('payment_id'); $where = array('payment_id'=>$payment_id,'delete_status'=>'ACTIVE'); $result = $this->gss_model->get_where_row($table,$where); if($result) { echo json_encode(array('commission_details'=>$result,'result'=>1)); } else { echo json_encode(array('result'=>0)); } } //Update commission payment public function update_commission_payment() { $table = 'gss_commission_payments'; $mgnt_table = 'gss_management'; $management_id = $this->input->post('management_id1'); $payment_id = $this->input->post('payment_id1'); $payment_type = $this->input->post('payment_type1'); $commission_type = $this->input->post('commission_type1'); $amount = $this->input->post('amount1'); $tds = $this->input->post('tds1'); $without_tax = $amount*$tds/100; $with_tax = $amount - $without_tax; $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $created_at = $date->format('Y-m-d H:i:s'); $cash_date = ''; $cheque_no = ''; $cheque_date = ''; $bank_name = ''; $utr_no = ''; $online_date = ''; $dd_no = ''; $dd_date = ''; $dd_bank = ''; $payment_date =''; if($payment_type == 'Cheque') { $cheque_no = $this->input->post('check_no1'); $cheque_date = $this->input->post('check_date1'); if($cheque_date != "") { $date = new DateTime($cheque_date); $cheque_date = $date->format('Y-m-d'); $payment_date= $date->format('Y-m-d'); } $bank_name = $this->input->post('bank_name1'); } else if($payment_type == 'Online') { $utr_no = $this->input->post('utr_no1'); $online_date = $this->input->post('online_date1'); if($online_date != "") { $date = new DateTime($online_date); $online_date = $date->format('Y-m-d'); $payment_date= $date->format('Y-m-d'); } } else if($payment_type == 'DD') { $dd_no = $this->input->post('dd_no1'); $dd_date = $this->input->post('dd_date1'); if($dd_date != "") { $date = new DateTime($dd_date); $dd_date = $date->format('Y-m-d'); $payment_date = $date->format('Y-m-d'); } $dd_bank = $this->input->post('dd_bank1'); } else if($payment_type == 'Cash') { $cheque_date = $this->input->post('cash_date1'); if($cheque_date != "") { $date = new DateTime($cheque_date); $cheque_date = $date->format('Y-m-d'); $payment_date = $date->format('Y-m-d'); } } $data = array( 'management_id' => $management_id, 'commission_type' => $commission_type, 'payment_type' => $payment_type, 'tds' => $tds, 'amount' => $amount, 'with_tax' => $with_tax, 'cheque_no' => $cheque_no, 'cheque_date' => $cheque_date, 'utr_no' => $utr_no, 'online_date' => $online_date, 'dd_no' => $dd_no, 'dd_date' => $dd_date, 'dd_bank' => $dd_bank, 'bank_name' => $bank_name, 'payment_date' => $payment_date, 'delete_status' => 'ACTIVE', 'updated_at' => $created_at ); // print_r($data); // die(); $where = array('payment_id'=>$payment_id); $result = $this->gss_model->update($where,$table,$data); if($this->db->affected_rows() > 0) { echo json_encode(array('result'=>1,'message'=>"Updated successfully")); } else { echo json_encode(array('result'=>0,'message'=>"Something went wrong")); } } //Delete conversion order public function delete_conversion_order() { $table = 'gss_project_conversion_orders'; $image_id = $this->input->post('image_id'); $where = array('image_id'=>$image_id); $data = array('delete_status'=>'INACTIVE'); $result = $this->gss_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 check_enquired_user() { $customer_name = ucfirst($this->input->post('customer_name')); $mobile1 = $this->input->post('mobile1'); $result = $this->gss_model->check_enquired_user($customer_name,$mobile1); if($result) { echo json_encode(array('result'=>1,'data'=>$result)); } else { echo json_encode(array('result'=>0)); } } //Commission form public function add_commission() { $admin_id = session()->get('admin_id'); if($admin_id) { $broker_table = 'gss_brokers'; $project_table = 'gss_new_projects'; $notification_table = 'gss_commission_notifications'; $booking_id = $this->uri->segment(2); $data['details'] = $this->gss_model->user_site_booking_details2($booking_id); $where_project = array('delete_status'=>'ACTIVE','project_status'=>'ONGOING'); $order_by2='project_name'; $where_reference = array('delete_status'=>'ACTIVE','type'=>'Executives'); $where_associate = array('delete_status'=>'ACTIVE','type'=>'Associate'); $order_by1 ='associate_name'; $where_subassociate = array('delete_status'=>'ACTIVE','type'=>'Sub Associate'); $data['dates'] = $this->gss_model->executed_dates($booking_id); $data['associates']=$this->gss_model->get_where_result_alphabetical($broker_table,$where_associate,$order_by1); //$data['associates'] = $this->gss_model->get_where_result($broker_table,$where_associate); $data['subassociates']=$this->gss_model->get_where_result_alphabetical($broker_table,$where_associate,$order_by1); //$data['subassociates'] = $this->gss_model->get_where_result($broker_table,$where_subassociate); $data['projects']=$this->gss_model->get_where_result_alphabetical($project_table,$where_project,$order_by2); //$data['projects'] = $this->gss_model->get_where_result($project_table,$where_project); $data['reference']=$this->gss_model->get_where_result_alphabetical($broker_table,$where_reference,$order_by1); //$data['reference'] = $this->gss_model->get_where_result($broker_table,$where_reference); $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $this->load->view('admin/add_commission_form',$data); } else { redirect('/'); } } public function add_regcommission() { $admin_id = session()->get('admin_id'); if($admin_id) { $broker_table = 'gss_brokers'; $project_table = 'gss_new_projects'; $notification_table = 'gss_commission_notifications'; $booking_id = $this->uri->segment(2); $data['details'] = $this->gss_model->user_site_booking_details2($booking_id); // print_r($data['details']); // die(); $where_project = array('delete_status'=>'ACTIVE','project_status'=>'ONGOING'); $where_reference = array('delete_status'=>'ACTIVE','type'=>'Executives'); $where_associate = array('delete_status'=>'ACTIVE','type'=>'Associate'); $where_subassociate = array('delete_status'=>'ACTIVE','type'=>'Sub Associate'); $data['dates'] = $this->gss_model->executed_dates($booking_id); $data['associates'] = $this->gss_model->get_where_result($broker_table,$where_associate); $data['subassociates'] = $this->gss_model->get_where_result($broker_table,$where_subassociate); $data['projects'] = $this->gss_model->get_where_result($project_table,$where_project); $data['reference'] = $this->gss_model->get_where_result($broker_table,$where_reference); $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $this->load->view('admin/add_regcommission_form',$data); } else { redirect('/'); } } //Account Notifications public function accounts_notifications() { $result = $this->gss_model->accounts_notifications(); if($result) { echo json_encode(array('result'=>1,'notifications'=>$result,'total'=>count($result))); } else { echo json_encode(array('result'=>0)); } } //Status status list public function sites_status_list() { $project_id = $this->input->post('project_id'); $result = $this->gss_model->sites_status_list($project_id); if($result) { echo json_encode(array('site_status_list'=>$result,'result'=>1)); } else { echo json_encode(array('result'=>0)); } } //Add access public function add_access() { $admin_id = session()->get('admin_id'); if($admin_id) { $data['menu'] = $this->gss_model->get_all_menu(); $data['departments'] = $this->gss_model->get_all_departments(); $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $table = 'gss_login'; $where = array('delete_status'=>'ACTIVE','user_type_id'=>'20'); $data['roles'] = $this->gss_model->get_where_result($table,$where); $this->load->view('admin/add_access',$data); } else { redirect('/'); } } //Menu list public function get_all_menu() { $table = 'gss_menu'; $where = array('delete_status'=>'ACTIVE'); $result = $this->gss_model->get_all_menu(); if($result) { echo json_encode(array('menu_list'=>$result,'result'=>1)); } else { echo json_encode(array('result'=>0)); } } //Staff list public function get_all_staff() { $result = $this->gss_model->get_all_staff(); if($result) { echo json_encode(array('staff_list'=>$result,'result'=>1)); } else { echo json_encode(array('result'=>0)); } } //Add access controls /* public function add_menu_access() { $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 = 'gss_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->gss_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->gss_model->update($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->gss_model->insert($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")); } } }*/ //Departmentu list public function get_all_departments() { $table = 'gss_menu'; $where = array('delete_status'=>'ACTIVE'); $result = $this->gss_model->get_all_departments(); if($result) { echo json_encode(array('departments'=>$result,'result'=>1)); } else { echo json_encode(array('result'=>0)); } } //Access list public function get_access_list() { $result = $this->gss_model->get_access_list(); if($result) { echo json_encode(array('get_access_list'=>$result,'result'=>1)); } else { echo json_encode(array('result'=>0)); } } //Menu list public function get_menu_list() { $table = 'gss_menu'; $where = array('delete_status'=>'ACTIVE'); $result = $this->gss_model->get_where_result($table,$where); if($result) { echo json_encode(array('menu_list'=>$result,'result'=>1)); } else { echo json_encode(array('result'=>0)); } } //Access roles public function access_roles() { $table = 'gss_access_controls'; $where = array('delete_status'=>'ACTIVE'); $result = $this->gss_model->get_where_result($table,$where); if($result) { echo json_encode(array('access_roles'=>$result,'result'=>1)); } else { echo json_encode(array('result'=>0)); } } //Departemmts form public function departments() { $admin_id = session()->get('admin_id'); if($admin_id) { $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $this->load->view('admin/departments',$data); } else { redirect('/'); } } //Add usertype public function add_department() { $department = $this->input->post('department'); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $created_at = $date->format('Y-m-d H:i:s'); $table = 'gss_user_type'; $data = array( 'user_type' => ucfirst($department), 'delete_status' => 'ACTIVE', 'created_at' => $created_at ); $user_types = $this->gss_model->check_usertype_exists($department); if($user_types) { echo json_encode(array('result'=>2,'message'=>"Department already exists")); } else { $result = $this->gss_model->insert($table,$data); 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() { $table = 'gss_user_type'; $where = array('delete_status'=>'ACTIVE','user_type_id !='=>'1'); $result = $this->gss_model->get_where_result($table,$where); if($result) { echo json_encode($result); } else { echo json_encode(array('result'=>0)); } } //Update usertype public function update_department() { $user_type_id = $this->input->post('user_type_id'); $department = $this->input->post('department'); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $updated_at = $date->format('Y-m-d H:i:s'); $table = 'gss_user_type'; $where = array('user_type_id'=>$user_type_id); $data = array( 'user_type' => $department, 'updated_at' => $updated_at ); $result = $this->gss_model->update($where,$table,$data); 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")); } } //Delete usertype public function delete_usertype() { $table = 'gss_user_type'; $user_type_id = $this->input->post('user_type_id'); $where = array('user_type_id'=>$user_type_id); $data = array('delete_status'=>'INACTIVE'); $result = $this->gss_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)); } } //Single department access /*public function single_department_access() { $table = 'gss_access_controls'; $department_id = $this->input->post('department_id'); $where = array('delete_status' =>'ACTIVE','department_id' =>$department_id); $result = $this->gss_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)); } }*/ //Delete booking public function delete_booking() { $booking_table = 'gss_bookings'; $detail_table = 'gss_booking_details'; $booking_id = $this->input->post('booking_id'); $where = array('booking_id'=>$booking_id); $data = array('delete_status'=>'INACTIVE'); $result = $this->gss_model->update($where,$booking_table,$data); $result1 = $this->gss_model->update($where,$detail_table,$data); if($this->db->affected_rows() > 0) { echo json_encode(array('result'=>1,'message'=>'Deleted successfully')); } else { echo json_encode(array('result'=>0)); } } //Branches list public function get_branches_list() { $table = 'gss_branches'; $where = array('delete_status'=>'ACTIVE'); $result = $this->gss_model->get_where_result($table,$where); if($result) { echo json_encode(array('result'=>1,'result1'=>$result)); } else { echo json_encode(array('result'=>0)); } } public function get_branches_master() { $gss_model = new Gss_model(); $table = 'gss_branches'; $where = array('delete_status'=>'ACTIVE'); $result = $gss_model->get_where_result($table,$where); if($result) { echo json_encode($result); } else { echo json_encode(array('result'=>0)); } } //Dob calendar public function dob_calendar() { $admin_id = session()->get('admin_id'); if($admin_id) { $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $this->load->view('admin/dob_calendar',$data); } else { redirect('/'); } } //DOB list public function get_dob_dates() { $table = 'gss_bookings'; $where = array('delete_status'=>'ACTIVE'); $result = $this->gss_model->get_dob_list($table,$where); if($result) { echo json_encode(array('dob_list'=>$result,'result'=>1)); } else { echo json_encode(array('result'=>0)); } } //Doa calendar public function doa_calendar() { $admin_id = session()->get('admin_id'); if($admin_id) { $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $this->load->view('admin/doa_calendar',$data); } else { redirect('/'); } } //DOA list public function get_doa_dates() { $table = 'gss_bookings'; $where = array('delete_status'=>'ACTIVE'); $result = $this->gss_model->get_doa_list($table,$where); if($result) { echo json_encode(array('doa_list'=>$result,'result'=>1)); } else { echo json_encode(array('result'=>0)); } } //Branches form public function branches() { $admin_id = session()->get('admin_id'); if($admin_id) { $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); return view('admin/branches',$data); } else { redirect('/'); } } //Delete branch public function delete_branch() { $table = 'gss_branches'; $branch_id = $this->input->post('branch_id'); $where = array('branch_id'=>$branch_id); $data = array('delete_status'=>'INACTIVE'); $result = $this->gss_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)); } } //Add branch public function add_branch() { $branch = $this->input->post('branch'); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $created_at = $date->format('Y-m-d H:i:s'); $table = 'gss_branches'; $data = array( 'branch' => ucfirst($branch), 'delete_status' => 'ACTIVE', 'created_at' => $created_at ); $branches = $this->gss_model->check_branch_exists($branch); if($branches) { echo json_encode(array('result'=>2,'message'=>"Branch already exists")); } else { $result = $this->gss_model->insert($table,$data); if($result) { echo json_encode(array('result'=>1,'message'=>"Branch added successfully")); } else { echo json_encode(array('result'=>0,'message'=>"Something went wrong.. try again")); } } } //Update branch public function update_branch() { $branch_id = $this->input->post('branch_id'); $branch = $this->input->post('branch'); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $updated_at = $date->format('Y-m-d H:i:s'); $table = 'gss_branches'; $where = array('branch_id'=>$branch_id); $data = array( 'branch' => $branch, 'updated_at' => $updated_at ); $result = $this->gss_model->update($where,$table,$data); 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")); } } //Booking details /*public function user_booking_details() { $admin_id = session()->get('admin_id'); if($admin_id) { $table = 'gss_bookings'; $broker_table = 'gss_brokers'; $instal_table = 'gss_booking_installments'; $booking_id = $this->uri->segment(2); $data['site_result'] = $this->gss_model->user_site_booking_details1($booking_id); $site_result = $this->gss_model->user_site_booking_details1($booking_id); $where = array('booking_id'=>$booking_id,'delete_status'=>'ACTIVE'); $data['instal_result'] = $this->gss_model->get_where_row($instal_table,$where); $this->load->view('admin/user_booking_details',$data); } else { redirect('/'); } }*/ public function user_booking_details() { $admin_id = session()->get('admin_id'); if($admin_id) { $table = 'gss_bookings'; $broker_table = 'gss_brokers'; $instal_table = 'gss_booking_installments'; $booking_id = $this->uri->segment(2); $data['site_result'] = $this->gss_model->user_site_booking_details1($booking_id); $data['instal_result'] = $this->gss_model->user_site_booking_detail($booking_id); //$data['details']= $this->gss_model->client_details1($booking_id); $payment_table = 'gss_plot_payments'; $payment_type_table = 'gss_plot_payment_types'; $where_booking = array('booking_id'=>$booking_id,'delete_status'=>'ACTIVE'); $type_result = $this->gss_model->get_where_row($payment_table,$where_booking); if($type_result){ $data['registration_date'] = date('d-m-Y', strtotime($type_result->registration_date)); $data['registration_status'] = 'Registered'; } else{ $data['registration_date'] = ''; $data['registration_status'] = 'Not Registered'; } $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $this->load->view('admin/user_booking_details',$data); } else { redirect('/'); } } //Delete payment public function delete_individual_payment() { $payment_table = 'gss_plot_payments'; $payment_type_table = 'gss_plot_payment_types'; $booking_id = $this->input->post('booking_id'); $where_booking = array('booking_id'=>$booking_id,'delete_status'=>'ACTIVE'); $type_result = $this->gss_model->get_where_row($payment_table,$where_booking); $payment_id = $type_result->payment_id; $where_type = array('payment_id'=>$payment_id); $where_booking = array('booking_id'=>$booking_id); $delete_status = array('delete_status'=>'INACTIVE'); $result = $this->gss_model->update($where_type,$payment_type_table,$delete_status); $result = $this->gss_model->update($where_booking,$payment_table,$delete_status); if($this->db->affected_rows() > 0) { echo json_encode(array('result'=>1,'message'=>'Deleted successfully')); } else { echo json_encode(array('result'=>0)); } } //All sales public function get_project_total_sqft() { $result = $this->gss_model->get_project_total_sqft(); if($result) { echo json_encode(array('result'=>1,'total'=>count($result),'all_sales'=>$result)); } else { echo json_encode(array('result'=>0)); } } //All sales public function get_project_total_sqft_left() { $result = $this->gss_model->get_project_total_sqft_left(); if($result) { echo json_encode(array('result'=>1,'total'=>count($result),'all_sales'=>$result)); } else { echo json_encode(array('result'=>0)); } } //Logout public function logout() { $this->session->sess_destroy(); redirect('/'); } /* public function get_table_details() { $id=$this->input->post('id'); $table='gss_brokers'; $arr=array(); foreach($id as $ids){ $table = 'gss_brokers'; $order_by = "associate_name"; $where = array('delete_status' => 'ACTIVE','broker_id'=>$ids); $result = $this->gss_model->get_where_result_alphabetical($table,$where,$order_by); array_push($arr,$result); } if($arr) { echo json_encode($arr); } else { echo json_encode(array('result'=>0,'message'=>'No Details found')); } }*/ public function get_table_details() { $type =$_GET['type']; $result = $this->gss_model->assoc_reports($type); if($result) { echo json_encode($result); } else { echo json_encode(array('result'=>0,'message'=>'No Details found')); } } public function get_enquirytable_details() { $id=$this->input->post('id'); $table='gss_brokers'; $arr=array(); foreach($id as $ids){ $table = 'gss_enquiries'; $where = array('delete_status'=>'ACTIVE','enquiry_id'=>$ids); $order_by = 'enquiry_id'; $result = $this->gss_model->get_where_result_orderby_desc_row($table,$where,$order_by); //print_r($result); array_push($arr,$result); } if($arr) { echo json_encode($arr); } else { echo json_encode(array('result'=>0,'message'=>'No Details found')); } } public function single_site_details() { $project_id = $this->uri->segment(2); $site_number = $this->uri->segment(3); $details = $this->gss_model->test($project_id,$site_number); if(empty($details)) { $data['bookin_details'] = ''; $data['payment_ind'] = ''; $data['agreement_details'] = ''; $data['installment_details'] = ''; $data['registration1_details'] = ''; $data['others'] = ''; /*?> <script>alert('This Site is Not Booked'); window.location = '<?php echo site_url("reports")?>'; </script> <?php*/ } else { $data['bookin_details']=$details; //print_r($data['bookin_details']);die(); $booking_id = $data['bookin_details']->b_id; $data['payment_ind'] = $this->gss_model->payment_ind($booking_id); $data['agreement_details'] = $this->gss_model->agreement_payment_details($booking_id); $data['installment_details'] = $this->gss_model->installment_payment_details($booking_id); $data['registration1_details'] = $this->gss_model->registration_payment_details($booking_id); $data['others'] = $this->gss_model->payment_withoutinstall($booking_id); //print_r($data['others']);die(); $tbale='gss_registration_amount_details'; $condition=array('booking_id'=>$booking_id,'delete_status'=>'ACTIVE'); $get_reg_amt=$this->gss_model->get_where_result($tbale,$condition); if($get_reg_amt) { $data['more_registration_details']=$get_reg_amt; } else { $data['more_registration_details']=''; } } $table='gss_new_projects'; $where=array('project_id'=>$project_id); $data['project_name']=$this->gss_model->get_where_row($table,$where); $data['site_no']=$site_number ; $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $this->load->view('admin/report_status_details',$data); } public function delete_payment_id() { $payment_table = 'gss_plot_payments'; $payment_type_table = 'gss_plot_payment_types'; $payment_id = $this->input->post('payment_id'); $where_booking = array('payment_id'=>$payment_id,'delete_status'=>'ACTIVE'); $type_result = $this->gss_model->get_where_row($payment_table,$where_booking); $payment_id = $type_result->payment_id; $where_type = array('payment_id'=>$payment_id); //$where_booking = array('booking_id'=>$booking_id); $delete_status = array('delete_status'=>'INACTIVE'); $result = $this->gss_model->update($where_type,$payment_type_table,$delete_status); $this->gss_model->update($where_type,$payment_table,$delete_status); 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_reg_id() { $payment_table = 'gss_registration_amount_details'; $id = $this->input->post('id'); $where_type = array('id'=>$id,'delete_status'=>'ACTIVE'); $delete_status = array('delete_status'=>'INACTIVE'); $result = $this->gss_model->update($where_type,$payment_table,$delete_status); if($result) { echo json_encode(array('result'=>1,'message'=>'Deleted successfully')); } else { echo json_encode(array('result'=>0)); } } public function upload() { date_default_timezone_set('Asia/Kolkata'); include 'PHPExcel/IOFactory.php'; if(isset($_FILES['file']['name'])){ $file_name = $_FILES['file']['name']; $ext = pathinfo($file_name, PATHINFO_EXTENSION); if($ext == "xlsx" || $ext == "xls") { $file_name = $_FILES['file']['tmp_name']; $inputFileName = $file_name; try { $inputFileType = PHPExcel_IOFactory::identify($inputFileName); $objReader = PHPExcel_IOFactory::createReader($inputFileType); $objPHPExcel = $objReader->load($inputFileName); } catch (Exception $e) { die('Error loading file "' . pathinfo($inputFileName, PATHINFO_BASENAME) . '": ' . $e->getMessage()); } $sheet = $objPHPExcel->getSheet(0); $highestRow = $sheet->getHighestRow(); $highestColumn = $sheet->getHighestColumn(); $allDataInSheet = $objPHPExcel->getActiveSheet()->toArray(null,true,true,true); $arrayCount = count($allDataInSheet); // Here get total count of row in that Excel sheet $table='gss_enquiries'; if(count($allDataInSheet)>0){ for($i=2;$i<=$arrayCount;$i++){ //$partner_code = trim($allDataInSheet[$i]["A"]); $customer_name = trim($allDataInSheet[$i]["B"]); $email= trim($allDataInSheet[$i]["C"]); $mobile = trim($allDataInSheet[$i]["D"]); $mobile2 = trim($allDataInSheet[$i]["E"]); $address = trim($allDataInSheet[$i]["F"]); $web_portal_address = trim($allDataInSheet[$i]["G"]); $database_name = trim($allDataInSheet[$i]["H"]); $reference = trim($allDataInSheet[$i]["I"]); $status = 'ACTIVE'; $crts = trim($allDataInSheet[$i]["J"]); $enquiry_status = trim($allDataInSheet[$i]["K"]); $crt=date("Y-m-d", strtotime($crts)); if($customer_name) { $data=array('customer_name'=>$customer_name,'email'=>$email,'mobile'=>$mobile,'mobile2'=>$mobile2,'address'=>$address,'web_portal_address'=>$web_portal_address,'database_name'=>$database_name,'reference'=>$reference,'status'=>$enquiry_status,'delete_status'=>$status,'created_at'=>$crt); $this->gss_model->insert($table,$data); } } redirect('gss/enquiry_form'); } } else{ echo '<p style="color:red;">Please upload file with xlsx extension only</p>'; } } } //Shrimathi public function site_map_form() { $admin_id = session()->get('admin_id'); if($admin_id) { $table='gss_new_projects'; $condition=array('delete_status'=>'ACTIVE'); $data['project'] = $this->gss_model->get_where_result($table,$condition); $data['mappings'] = $this->gss_model->get_where_result_mapping_sketch(); $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $this->load->view('admin/mapping_form',$data); } else { redirect('/'); } } public function add_mapping_sketch() { $id = $this->input->post('id'); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $created_at = $date->format('Y-m-d H:i:s'); $this->load->library('image_lib'); $file_name = ""; if($_FILES) { if(empty($_FILES['hobli_sketch']['name'])) { $file_name = ""; } else { $target='mapping_image/'; $target.=time().$_FILES['hobli_sketch']['name']; $file_name=time().$_FILES['hobli_sketch']['name']; $image=$target; move_uploaded_file($_FILES['hobli_sketch']['tmp_name'],$target); $config['source_image']=$target; $config['maintain_ratio']=TRUE; $config['width']=900; $config['height']=900; $this->image_lib->initialize($config); $this->image_lib->resize(); } } $table = 'gss_mapping_sketch'; $data = array( 'project_id' => $id, 'image' => $file_name, 'delete_status' => 'ACTIVE', 'created_at' => $created_at, 'modified_at' => $created_at ); $where = array('delete_status'=>'ACTIVE'); $hoblis = $this->gss_model->get_where_result($table,$where); $array = array(); foreach($hoblis as $value) { array_push($array, $value->project_id); } if(in_array($id,$array)) { echo json_encode(array('result'=>2,'message'=>"Sketch already exists for this project")); } else { $result = $this->gss_model->insert($table,$data); if($result) { echo json_encode(array('result'=>1,'message'=>"Sketch added successfully")); } else { echo json_encode(array('result'=>0,'message'=>"Something went wrong.. try again")); } } } //Update hobli sketch public function update_map_sketch() { $sketch_id = $this->input->post('hobli_sketch_id'); $project_id = $this->input->post('id'); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $updated_at = $date->format('Y-m-d H:i:s'); $table = 'gss_mapping_sketch'; $where = array('sketch_id'=>$sketch_id); $where_file = array('sketch_id'=>$sketch_id); $file_data = $this->gss_model->get_where_row($table,$where_file); $hobli_sketch = $file_data->image; //echo $hobli_sketch;die(); $this->load->library('image_lib'); if(empty($_FILES['hobli_sketch']['name'])) { $file_name = $hobli_sketch; } else { $target='mapping_image/'; $target.=time().$_FILES['hobli_sketch']['name']; $file_name=time().$_FILES['hobli_sketch']['name']; $image=$target; move_uploaded_file($_FILES['hobli_sketch']['tmp_name'],$target); $config['source_image']=$target; $config['maintain_ratio']=TRUE; $config['width']=900; $config['height']=900; $this->image_lib->initialize($config); $this->image_lib->resize(); } $data = array( 'sketch_id' => $sketch_id, 'image' => $file_name, 'modified_at' => $updated_at ); $result = $this->gss_model->update($where,$table,$data); 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 get_project_sketches() { $result = $this->gss_model->get_where_result_mapping_sketch(); if($result) { echo json_encode(array('result'=>1,'sketch_list'=>$result)); } else { echo json_encode(array('result'=>0)); } } public function mapping_sketch() { $admin_id = session()->get('admin_id'); if($admin_id) { $sketch_id = $this->uri->segment(2); $table = 'gss_mapping_sketch'; $where = array('sketch_id'=>$sketch_id,'delete_status'=>'ACTIVE'); $data['sketch'] = $this->gss_model->get_where_row($table,$where); $data['project_id']=$data['sketch']->project_id; $where_data = array('project_id'=>$data['sketch']->project_id,'delete_status'=>'ACTIVE'); $table_site='gss_new_sites'; $data['site']=$this->gss_model->get_where_result($table_site,$where_data); $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $this->load->view('admin/sketch_mapping',$data); } else { redirect('/'); } } public function get_sketch_mapping_tags() { $project_id = $this->input->post('project_id'); $condition=array('delete_status'=>'ACTIVE','project_id'=>$project_id); $table='gss_mapping'; $result = $this->gss_model->get_where_result($table,$condition); if($result) { echo json_encode(array('result'=>1,'mapping_tags'=>$result)); } else { echo json_encode(array('result'=>0)); } } public function get_map_sketch_data() { $table = 'gss_mapping_sketch'; $sketch_id = $this->input->post('sketch_id'); $where = array('sketch_id'=>$sketch_id,'delete_status'=>'ACTIVE'); $result = $this->gss_model->get_where_row($table,$where); if($result) { echo json_encode(array('sketch_data'=>$result,'result'=>1)); } else { echo json_encode(array('result'=>0)); } } //Hobli sketc view public function update_area_coordinate_mapping() { $admin_id = session()->get('admin_id'); if($admin_id) { $sketch_id = $this->uri->segment(2); $table_sketch='gss_mapping'; $where = array('mapping_id'=>$sketch_id); $gss_new_projects_table = 'gss_new_projects'; $data['sketch_id'] =$sketch_id ; $details=$this->gss_model->get_where_row($table_sketch,$where ); $where_new_projects = array('project_id'=>$details->project_id); $data['coordinates']=$this->gss_model->get_where_result($table_sketch,$where_new_projects); $data['project'] = $this->gss_model->get_where_row($gss_new_projects_table,$where_new_projects); $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $this->load->view('admin/update_area_coordinate_mapping',$data); } else { redirect('/'); } } public function get_mapping_tags() { $project_id = $this->input->post('project_id'); $table='gss_mapping'; $where=array('project_id'=>$project_id,'delete_status'=>'ACTIVE'); $result=$this->gss_model->get_where_result($table,$where); if($result) { echo json_encode(array('result'=>1,'mapping_tags'=>$result)); } else { echo json_encode(array('result'=>0)); } } public function update_mapping_code() { $mapping_id = $this->input->post('mapping_id'); $area_tag = $this->input->post('area_tag'); $site_id = $this->input->post('site_id'); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $updated_at = $date->format('Y-m-d H:i:s'); $table = 'gss_mapping'; foreach($mapping_id as $index=>$val) { $data = array( 'area_tag' => $area_tag[$index], 'site_id' => $site_id[$index], 'modified_at' => $updated_at ); $where = array('mapping_id'=>$val); $result = $this->gss_model->update($where,$table,$data); } if($result) { 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_mapping_code() { $table = 'gss_mapping'; $mapping_id = $this->input->post('mapping_id'); $where = array('mapping_id'=>$mapping_id); $data = array('delete_status'=>'INACTIVE'); $result = $this->gss_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 add_mapping_tags() { $project_id = $this->input->post('project_id'); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $created_at = $date->format('Y-m-d H:i:s'); $area_tag = $this->input->post('area_tag'); $site_ids = $this->input->post('site_ids'); $project_status = $this->input->post('project_status'); $table = 'gss_mapping'; foreach($area_tag as $index=>$val) { $data = array( 'project_id'=>$project_id, 'area_tag' => $val, 'site_id' => $site_ids[$index], 'project_status' => $project_status[$index], 'delete_status' => 'ACTIVE', 'created_at' => $created_at ); $result = $this->gss_model->insert($table,$data); } if($result) { echo json_encode(array('result'=>1,'message'=>"Data added successfully")); } else { echo json_encode(array('result'=>0,'message'=>"Something went wrong.. try again")); } } public function delete_site_sketch() { $table = 'gss_mapping_sketch'; $sketch_id = $this->input->post('sketch_id'); $where = array('sketch_id'=>$sketch_id); $data = array('delete_status'=>'INACTIVE'); $result = $this->gss_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)); } } ///////////////////////////New Requirements//////////////////////////// public function vendor_details() { $admin_id = session()->get('admin_id'); if($admin_id) { $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $this->load->view('admin/add_vendor',$data); } else { redirect('/'); } } public function bank_details() { $admin_id = session()->get('admin_id'); // print_r($admin_id); // die(); if($admin_id) { $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $this->load->view('admin/add_bankdetails',$data); } else { redirect('/'); } } ///20-2-18 public function add_vendor_details() { $table = 'gss_vendor_details'; $vendor_name = $this->input->post('vendor_name'); $company_name = $this->input->post('company_name'); $contact1 = $this->input->post('contact1'); $contact2 = $this->input->post('contact2'); $email = $this->input->post('email'); $company_address = $this->input->post('company_address'); $gstin = $this->input->post('gstin'); $bank_name = $this->input->post('bank_name'); $acc_no = $this->input->post('acc_no'); $ifsc = $this->input->post('ifsc'); $bank_address = $this->input->post('bank_address'); $myFile = $_FILES['file_upload']; $cpt = count($_FILES['file_upload']['name']); $file_doc=""; for($i=0; $i<$cpt; $i++) { $error = $myFile["error"][$i]; if ($error == '4') { $file_new=""; } else { if($_FILES['file_upload']['name']) { $path=$_FILES['file_upload']['name'][$i]; $target='vendor_details_uploads/'; $target.=time().$_FILES['file_upload']['name'][$i]; $document[]=time().$_FILES['file_upload']['name'][$i]; move_uploaded_file($_FILES['file_upload']['tmp_name'][$i],$target); $file_doc=json_encode($document); } else { $file_doc=""; } } } $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $created_at = $date->format('Y-m-d H:i:s'); $data = array('vendor_name'=>$vendor_name,'company_name'=>$company_name,'phone_one'=>$contact1,'phone_two'=>$contact2,'email'=>$email,'company_address'=>$company_address,'gstin'=>$gstin,'bank_name'=>$bank_name,'account_no'=>$acc_no,'ifsc_coce'=>$ifsc,'bank_address'=>$bank_address,'upload_files'=>$file_doc,'modified_at'=> $created_at,'created_at'=> $created_at,'delete_status'=>'ACTIVE'); $condition=array('vendor_name'=>$vendor_name,'company_name'=>$company_name,'phone_one'=>$contact1,'phone_two'=>$contact2,'email'=>$email,'company_address'=>$company_address,'gstin'=>$gstin,'bank_name'=>$bank_name,'account_no'=>$acc_no,'ifsc_coce'=>$ifsc,'bank_address'=>$bank_address,); $get_det=$this->gss_model->get_where_row($table,$condition); if(empty($get_det)){ $result = $this->gss_model->insert($table,$data); echo json_encode(array('result'=>1,'message'=>'Added successfully')); } else { echo json_encode(array('result'=>0,'message'=>'Data Already Exist')); } } //vendor_list public function vendor_list() { $table = 'gss_vendor_details'; $where = array('delete_status'=>'ACTIVE'); $order_by='id'; $result = $this->gss_model->get_where_result_orderby($table,$where,$order_by); if($result) { echo json_encode($result); } else { echo json_encode(array('result'=>0)); } } //update_vendor_details public function update_vendor_details() { $table = 'gss_vendor_details'; $id=$this->input->post('edit_id'); $vendor_name = $this->input->post('vendor_name_update'); $company_name = $this->input->post('company_name_update'); $contact1 = $this->input->post('contact1_update'); $contact2 = $this->input->post('contact2_update'); $email = $this->input->post('email_update'); $company_address = $this->input->post('company_address_update'); $gstin = $this->input->post('gstin_update'); $bank_name = $this->input->post('bank_name_update'); $acc_no = $this->input->post('acc_no_update'); $ifsc = $this->input->post('ifsc_update'); $bank_address = $this->input->post('bank_address_update'); $where = array('id'=>$id); $check_images = $this->gss_model->get_where_row($table,$where); $array = array(); if($check_images->upload_files != "") { $prev_con_docs = $check_images->upload_files; $prev_con_docs = json_decode($prev_con_docs); foreach($prev_con_docs as $key=>$val){ array_push($array,$val); } $images = json_encode($array); } $myFile = $_FILES['file_upload_update']; $cpt = count($_FILES['file_upload_update']['name']); if($_FILES['file_upload_update']['size'][0]!= 0) { for($i=0; $i<$cpt; $i++) { $error = $myFile["error"][$i]; if ($error == '4') { $file_new=""; } else { if($_FILES['file_upload_update']['name']) { $path=$_FILES['file_upload_update']['name'][$i]; $target='vendor_details_uploads/'; $target.=time().$_FILES['file_upload_update']['name'][$i]; $document[]=time().$_FILES['file_upload_update']['name'][$i]; move_uploaded_file($_FILES['file_upload_update']['tmp_name'][$i],$target); $file_doc=json_encode($document); $data['upload_files']=$file_doc; } else { } } } if($prev_con_docs != "") { $all_docs = json_encode(array_merge($array,$document)); } else { $all_docs = json_encode($document); } } else { $all_docs = $check_images->upload_files; } $condition=array('id'=>$id); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $created_at = $date->format('Y-m-d H:i:s'); $data = array('vendor_name'=>$vendor_name,'company_name'=>$company_name,'phone_one'=>$contact1,'phone_two'=>$contact2,'email'=>$email,'company_address'=>$company_address,'gstin'=>$gstin,'bank_name'=>$bank_name,'account_no'=>$acc_no,'ifsc_coce'=>$ifsc,'bank_address'=>$bank_address,'modified_at'=> $created_at,'delete_status'=>'ACTIVE','upload_files'=>$all_docs); $result = $this->gss_model->update($condition,$table,$data); if($result) { echo json_encode(array('result'=>1,'message'=>'Added Updated')); } else { echo json_encode(array('result'=>0)); } } public function get_vendor_details() { $table = 'gss_vendor_details'; $id=$this->input->post('id'); $where = array('id'=>$id); $result = $this->gss_model->get_where_row($table,$where); if($result) { echo json_encode(array('result'=>1,'message'=>$result)); } else { echo json_encode(array('result'=>0,'message'=>'data not found')); } } public function delete_vendor_details() { $table = 'gss_vendor_details'; $id = $this->input->post('id'); $where = array('id'=>$id); $data = array('delete_status'=>'INACTIVE'); $result = $this->gss_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 add_bank_details() { $table = 'gss_bank_details'; $acc_name_holder = $this->input->post('acc_name_holder'); $acc_holder = $this->input->post('acc_holder'); $acc_holder_address = $this->input->post('acc_holder_address'); $acc_no = $this->input->post('acc_no'); $pan_no = $this->input->post('pan_no'); $gst_no = $this->input->post('gst_no'); $ifsc = $this->input->post('ifsc'); $branch_name = $this->input->post('branch_name'); $address = $this->input->post('address'); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $created_at = $date->format('Y-m-d H:i:s'); $data = array('holder_name'=>$acc_holder,'holder_address'=>$acc_holder_address,'bank_name'=>$acc_name_holder,'acc_no'=>$acc_no,'pan_no'=>$pan_no,'gst_no'=>$gst_no,'ifsc'=>$ifsc,'bank_branch'=>$branch_name,'bank_address'=>$address,'modified_at'=> $created_at,'created_at'=> $created_at,'delete_status'=>'ACTIVE'); $condition=array('bank_name'=>$acc_name_holder,'acc_no'=>$acc_no,'delete_status'=>'ACTIVE'); $get_det=$this->gss_model->get_where_row($table,$condition); //print_r($get_det); //die(); if(empty($get_det)){ $result = $this->gss_model->insert($table,$data); echo json_encode(array('result'=>1,'message'=>'Added successfully')); } else { echo json_encode(array('result'=>0,'message'=>'Data Already Exist')); } } //vendor_list public function bank_list() { $table = 'gss_bank_details'; $where = array('delete_status'=>'ACTIVE'); $order_by='id'; $result = $this->gss_model->get_where_result_orderby($table,$where,$order_by); if($result) { echo json_encode($result); } else { echo json_encode(array('result'=>0)); } } public function get_bank_details() { $table = 'gss_bank_details'; $id=$this->input->post('id'); $where = array('id'=>$id); $result = $this->gss_model->get_where_row($table,$where); if($result) { echo json_encode(array('result'=>1,'message'=>$result)); } else { echo json_encode(array('result'=>0,'message'=>'data not found')); } } public function update_bank_details() { $table = 'gss_bank_details'; $id = $this->input->post('edit_id'); $where = array('id'=>$id); $acc_name_holder = $this->input->post('acc_name_holder_update'); $acc_holder = $this->input->post('acc_holder_update'); $acc_holder_address= $this->input->post('acc_holder_address_update'); $acc_no = $this->input->post('acc_no_update'); $pan_no = $this->input->post('pan_no_update'); $gst_no = $this->input->post('gst_no_update'); $ifsc = $this->input->post('ifsc_update'); $branch_name = $this->input->post('branch_name_update'); $address = $this->input->post('address_update'); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $created_at = $date->format('Y-m-d H:i:s'); $data = array('holder_name'=>$acc_holder,'holder_address'=>$acc_holder_address,'bank_name'=>$acc_name_holder,'acc_no'=>$acc_no,'pan_no'=>$pan_no,'gst_no'=>$gst_no,'ifsc'=>$ifsc,'bank_branch'=>$branch_name,'bank_address'=>$address,'modified_at'=> $created_at,'delete_status'=>'ACTIVE'); $result = $this->gss_model->update($where,$table,$data); if($this->db->affected_rows() > 0) { echo json_encode(array('result'=>1,'message'=>'Updated successfully')); } else { echo json_encode(array('result'=>0)); } } public function delete_bank_details() { $table = 'gss_bank_details'; $id = $this->input->post('id'); $where = array('id'=>$id); $data = array('delete_status'=>'INACTIVE'); $result = $this->gss_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 product_details() { $admin_id = session()->get('admin_id'); if($admin_id) { $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $this->load->view('admin/add_product_details',$data); } else { redirect('/'); } } public function service_details() { $admin_id = session()->get('admin_id'); if($admin_id) { $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $this->load->view('admin/add_services',$data); } else { redirect('/'); } } public function add_product_details() { $table = 'gss_product_details'; $pro_name = $this->input->post('pro_name'); $pro_description = $this->input->post('pro_description'); $pro_dept = $this->input->post('pro_dept'); $pro_currency = $this->input->post('pro_currency'); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $created_at = $date->format('Y-m-d H:i:s'); $data = array('product_name'=>$pro_name,'description'=>$pro_description,'deptartment'=>$pro_dept,'currency'=>$pro_currency,'modified_at'=> $created_at,'created_at'=> $created_at,'delete_status'=>'ACTIVE'); $condition=array('product_name'=>$pro_name,'description'=>$pro_description,'deptartment'=>$pro_dept,); $get_det=$this->gss_model->get_where_row($table,$condition); if(empty($get_det)){ $result = $this->gss_model->insert($table,$data); echo json_encode(array('result'=>1,'message'=>'Added successfully')); } else { echo json_encode(array('result'=>0,'message'=>'Data Already Exist')); } } public function add_project_details() { $table = 'gss_project_master'; $pro_name = $this->input->post('pro_name'); $pro_description = $this->input->post('pro_description'); $no_of_years = $this->input->post('no_of_years'); $per_sq_ft = $this->input->post('per_sq_ft'); $data = array('project_name'=>$pro_name,'description'=>$pro_description,'no_of_years'=>$no_of_years,'per_sq_ft'=>$per_sq_ft,'delete_status'=>'ACTIVE'); $condition=array('project_name'=>$pro_name,'description'=>$pro_description,'no_of_years'=>$no_of_years,'per_sq_ft'=>$per_sq_ft,'delete_status'=>'ACTIVE'); $get_det=$this->gss_model->get_where_row($table,$condition); if(empty($get_det)){ $result = $this->gss_model->insert($table,$data); echo json_encode(array('result'=>1,'message'=>'Added successfully')); } else { echo json_encode(array('result'=>0,'message'=>'Data Already Exist')); } } public function add_service_details() { $table = 'gss_service_details'; $pro_name = $this->input->post('pro_name'); $pro_description = $this->input->post('pro_description'); $pro_dept = $this->input->post('pro_dept'); $pro_currency = $this->input->post('pro_currency'); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $created_at = $date->format('Y-m-d H:i:s'); $data = array('product_name'=>$pro_name,'description'=>$pro_description,'deptartment'=>$pro_dept,'currency'=>$pro_currency,'modified_at'=> $created_at,'created_at'=> $created_at,'delete_status'=>'ACTIVE'); $condition=array('product_name'=>$pro_name,'description'=>$pro_description,'deptartment'=>$pro_dept,); $get_det=$this->gss_model->get_where_row($table,$condition); if(empty($get_det)){ $result = $this->gss_model->insert($table,$data); echo json_encode(array('result'=>1,'message'=>'Added successfully')); } else { echo json_encode(array('result'=>0,'message'=>'Data Already Exist')); } } public function other_project_list() { $table = 'gss_project_master'; $where = array('delete_status'=>'ACTIVE'); $order_by='id'; $result = $this->gss_model->get_where_result_orderby($table,$where,$order_by); if($result) { echo json_encode($result); } else { echo json_encode(array('result'=>0)); } } public function product_list() { $table = 'gss_product_details'; $where = array('delete_status'=>'ACTIVE'); $order_by='id'; $result = $this->gss_model->get_where_result_orderby($table,$where,$order_by); if($result) { echo json_encode($result); } else { echo json_encode(array('result'=>0)); } } public function service_list() { $table = 'gss_service_details'; $where = array('delete_status'=>'ACTIVE'); $order_by='id'; $result = $this->gss_model->get_where_result_orderby($table,$where,$order_by); if($result) { echo json_encode($result); } else { echo json_encode(array('result'=>0)); } } public function update_product_details() { $table = 'gss_product_details'; $id = $this->input->post('edit_id'); $pro_name = $this->input->post('pro_name'); $pro_description = $this->input->post('pro_description'); $pro_dept = $this->input->post('pro_dept'); $pro_currency = $this->input->post('pro_currency'); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $created_at = $date->format('Y-m-d H:i:s'); $data = array('product_name'=>$pro_name,'description'=>$pro_description,'deptartment'=>$pro_dept,'currency'=>$pro_currency,'modified_at'=> $created_at,'created_at'=> $created_at,'delete_status'=>'ACTIVE'); $where=array('id'=>$id); $result = $this->gss_model->update($where,$table,$data); if($this->db->affected_rows() > 0) { echo json_encode(array('result'=>1,'message'=>'Updated successfully')); } else { echo json_encode(array('result'=>0)); } } public function update_project_details() { $table = 'gss_project_master'; $id = $this->input->post('edit_id'); $pro_name = $this->input->post('pro_name'); $pro_description = $this->input->post('pro_description'); $no_of_years = $this->input->post('no_of_years'); $per_sq_ft = $this->input->post('per_sq_ft'); $data = array('project_name'=>$pro_name,'description'=>$pro_description,'no_of_years'=>$no_of_years,'per_sq_ft'=>$per_sq_ft,'delete_status'=>'ACTIVE'); $where=array('id'=>$id); $result = $this->gss_model->update($where,$table,$data); if($this->db->affected_rows() > 0) { echo json_encode(array('result'=>1,'message'=>'Updated successfully')); } else { echo json_encode(array('result'=>0)); } } public function update_service_details() { $table = 'gss_service_details'; $id = $this->input->post('edit_id'); $pro_name = $this->input->post('pro_name'); $pro_description = $this->input->post('pro_description'); $pro_dept = $this->input->post('pro_dept'); $pro_currency = $this->input->post('pro_currency'); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $created_at = $date->format('Y-m-d H:i:s'); $data = array('product_name'=>$pro_name,'description'=>$pro_description,'deptartment'=>$pro_dept,'currency'=>$pro_currency,'modified_at'=> $created_at,'created_at'=> $created_at,'delete_status'=>'ACTIVE'); $where=array('id'=>$id); $result = $this->gss_model->update($where,$table,$data); if($this->db->affected_rows() > 0) { echo json_encode(array('result'=>1,'message'=>'Updated successfully')); } else { echo json_encode(array('result'=>0)); } } public function get_product_details() { $table = 'gss_product_details'; $id=$this->input->post('id'); $where = array('id'=>$id); $result = $this->gss_model->get_where_row($table,$where); if($result) { echo json_encode(array('result'=>1,'message'=>$result)); } else { echo json_encode(array('result'=>0,'message'=>'data not found')); } } public function get_other_project() { $table = 'gss_project_master'; $id=$this->input->post('id'); $where = array('id'=>$id); $result = $this->gss_model->get_where_row($table,$where); if($result) { echo json_encode(array('result'=>1,'message'=>$result)); } else { echo json_encode(array('result'=>0,'message'=>'data not found')); } } public function get_service_details() { $table = 'gss_service_details'; $id=$this->input->post('id'); //print_r($id); $where = array('id'=>$id); $result = $this->gss_model->get_where_row($table,$where); if($result) { echo json_encode(array('result'=>1,'message'=>$result)); } else { echo json_encode(array('result'=>0,'message'=>'data not found')); } } public function delete_product_details() { $table = 'gss_product_details'; $id = $this->input->post('id'); $where = array('id'=>$id); $data = array('delete_status'=>'INACTIVE'); $result = $this->gss_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 delete_project_details() { $table = 'gss_project_master'; $id = $this->input->post('id'); $where = array('id'=>$id); $data = array('delete_status'=>'INACTIVE'); $result = $this->gss_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 delete_service_details() { $table = 'gss_service_details'; $id = $this->input->post('id'); $where = array('id'=>$id); $data = array('delete_status'=>'INACTIVE'); $result = $this->gss_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 invoice_form() { $admin_id = session()->get('admin_id'); if($admin_id) { $table='gss_new_projects'; $where_project = array('delete_status'=>'ACTIVE'); $order_by2='project_name'; $data['project_names']=$this->gss_model->get_where_result_alphabetical($table,$where_project,$order_by2); $table= 'gss_bank_details' ; $where = array('delete_status'=>'ACTIVE'); $order_by='holder_name'; $data['bank_name'] = $this->gss_model->get_where_result_alphabetical($table,$where_project,$order_by); //$data['invoice'] = $this->gss_model->get_invoice_id(); $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $this->load->view('admin/invoice',$data); } else { redirect('/'); } } public function get_invoice_no() { $type=$_REQUEST['type']; $holder=$_REQUEST['holder']; $invoice = $this->gss_model->get_invoice_id($type,$holder); echo json_encode($invoice); } public function get_project_sites() { $table = 'gss_new_sites'; $project_id=$_GET['project_id']; $result = $this->gss_model->get_where_result_site_ids($project_id); if($result) { echo json_encode($result); } else { echo json_encode(array('result'=>0)); } } public function get_project_sites_edit() { $table = 'gss_new_sites'; $project_id=$_GET['project_id']; $inv=$_GET['inv']; $result = $this->gss_model->get_where_result_site_ids_edit($project_id,$inv); if($result) { echo json_encode($result); } else { echo json_encode(array('result'=>0)); } } public function get_sites_sqft() { $project_id=$this->input->post('project_id'); $site_id=$this->input->post('site_id'); $total_sqft=0; $site_ids=array(); $site_numbers=array(); foreach($project_id as $key=>$project_ids) { $details=$this->gss_model->get_where_result_sites_sqft($project_ids,$site_id[$key]); if($details) { $total_sqft+=$details->total_in_sqft; array_push($site_ids,$details->site_id); array_push($site_numbers,$details->site_number); } } if($total_sqft) { echo json_encode(array('result'=>1,'message'=>$total_sqft,'site_id'=>$site_ids,'site_number'=>$site_numbers)); } else { echo json_encode(array('result'=>0,'message'=>'Not found')); } } public function add_invoice_details() { $table = 'gss_invoice_details'; $invoice_number = $this->input->post('invoice_number'); $project_name = $this->input->post('project_name'); $site_list[] = $this->input->post('site_list'); $site_number[] = $this->input->post('site_number'); $invoice_type = $this->input->post('invoice_type'); // print_r($invoice_type); // die(); $to = $this->input->post('to'); $total_sqft = $this->input->post('total_sqft'); $rate_per_sqft = $this->input->post('rate_per_sqft'); $total_amt = $this->input->post('total_amt'); $sgst = $this->input->post('sgst'); $cgst = $this->input->post('cgst'); $total_amt1=$total_amt * $total_sqft; $total_withgst_amt = $this->input->post('total_withgst_amt'); $total_sgst=round(($total_amt * $sgst)/100); $total_cgst=round(($total_amt * $cgst)/100); $bank_holder_name=$this->input->post('bank_holder_name'); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $created_at = $date->format('Y-m-d H:i:s'); $data = array('invoice_number'=>$invoice_number,'project_id'=>$project_name,'site_ids'=>json_encode($site_list),'invoice_type'=>$invoice_type,'invoice_to'=>$to,'total_sqft'=>$total_sqft,'rate_per_sqft'=>$rate_per_sqft,'without_gst_total_amt'=>$total_amt,'sgst'=>$sgst,'cgst'=>$cgst,'with_gst_total_amt'=>$total_withgst_amt,'modified_at'=> $created_at,'created_at'=> $created_at,'delete_status'=>'ACTIVE','site_numbers'=>json_encode($site_number),'total_sgst'=>$total_sgst,'total_cgst'=>$total_cgst,'bank_name'=>$bank_holder_name); $condition =array('invoice_number'=>$invoice_number,'project_id'=>$project_name,'site_ids'=>json_encode($site_list),'invoice_type'=>$invoice_type,'invoice_to'=>$to,'total_sqft'=>$total_sqft,'rate_per_sqft'=>$rate_per_sqft,'without_gst_total_amt'=>$total_amt,'sgst'=>$sgst,'cgst'=>$cgst,'with_gst_total_amt'=>$total_withgst_amt,'total_sgst'=>$total_sgst,'total_cgst'=>$total_cgst,'bank_name'=>$bank_holder_name); // print_r($data); // die(); $get_det=$this->gss_model->get_where_row($table,$condition); if(empty($get_det)) { $invoice_type = $this->input->post('invoice_type'); // print_r($invoice_type); // die(); if($invoice_type == "Tax Invoice") { $in_type="tax"; } else if($invoice_type == "Proforma Invoice") { $in_type="proforma"; } $result = $this->gss_model->insert($table,$data); $site_numbers = $this->input->post('site_number'); $explode= explode(",",$site_numbers); foreach ($explode as $keys => $values) { $tble_sites='gss_new_sites'; $condition_sites=array('project_id'=>$project_name,'site_number'=>$values); $update_data=array('billing_status'=>$invoice_type,'invoice_no'=>$invoice_number); $this->gss_model->update($condition_sites,$tble_sites,$update_data); } echo json_encode(array('result'=>1,'message'=>$result,'in_type'=>$invoice_type)); } else { echo json_encode(array('result'=>0,'message'=>'Data Already Exist')); } } public function invoice_print() { $admin_id = session()->get('admin_id'); if($admin_id) { $id=$_GET['id']; $table ='gss_bank_details'; $where = array('delete_status'=>'ACTIVE'); $data['bank_name'] = $this->gss_model->getallbankdetails($table,$where); $data['bank_address'] = $this->gss_model->getallbankdetails($table,$where); $data['details']=$this->gss_model->get_where_row_for_print($id); // print_r($data['details']); // die(); $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $this->load->view('admin/invoice_print',$data); } else { redirect('/'); } } public function update_invoice_number() { $table = 'gss_invoice_details'; $id = $this->input->post('id'); $invoice_no = $this->input->post('invoice_no'); $pro_name = $this->input->post('pro_name'); $pro_description = $this->input->post('pro_description'); $pro_dept = $this->input->post('pro_dept'); $pro_currency = $this->input->post('pro_currency'); $a=date("y"); $b=$a+1; $new_invoice='GSS/'.$a.'-'.$b.'/'.$invoice_no; $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $created_at = $date->format('Y-m-d H:i:s'); $data = array('invoice_no'=>$new_invoice,'modified_at'=> $created_at); $where=array('id'=>$id); $result = $this->gss_model->update($where,$table,$data); //print_r($where); if($result) { echo json_encode(array('result'=>1,'message'=>'Updated successfully')); } else { echo json_encode(array('result'=>0)); } } public function tax_invoice_list() { $from_date = $_GET['from_date']; if($from_date != "") { $date = new DateTime($from_date); $from_date = $date->format('Y-m-d'); } $to_date = $_GET['to_date']; if($to_date != "") { $date = new DateTime($to_date); $to_date = $date->format('Y-m-d'); } $holder_name = $_GET['holder_name']; $result = $this->gss_model->get_where_result_tax_invoice_list($from_date,$to_date,$holder_name); // print_r($result); if($result) { echo json_encode($result); } else { echo json_encode(array('result'=>0)); } } public function proforma_invoice_list() { $from_date = $_GET['from_date']; if($from_date != "") { $date = new DateTime($from_date); $from_date = $date->format('Y-m-d'); } $to_date = $_GET['to_date']; if($to_date != "") { $date = new DateTime($to_date); $to_date = $date->format('Y-m-d'); } $holder_name = $_GET['holder_name']; $result = $this->gss_model->get_where_result_proforma_invoice_list($from_date,$to_date,$holder_name); if($result) { echo json_encode($result); } else { echo json_encode(array('result'=>0)); } } public function tax_invoice_form() { $admin_id = session()->get('admin_id'); if($admin_id) { $table='gss_new_projects'; $data['project_names']=$this->gss_model->get_where_reults_project_name(); $table ='gss_bank_details'; $where = array('delete_status'=>'ACTIVE'); $data['bank_details']=$this->gss_model->getallbankdetails($table,$where); $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $this->load->view('admin/tax_invoice_form',$data); } else { redirect('/'); } } public function proforma_invoice_form() { $admin_id = session()->get('admin_id'); if($admin_id) { $table='gss_new_projects'; $data['project_names']=$this->gss_model->get_where_reults_project_name(); $table ='gss_bank_details'; $where = array('delete_status'=>'ACTIVE'); $data['bank_details']=$this->gss_model->getallbankdetails($table,$where); $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $this->load->view('admin/proforma_invoice_form',$data); } else { redirect('/'); } } public function convert_invoice() { $table = 'gss_invoice_details'; $id = $this->input->post('id'); $wheres = array('id'=>$id); $datas=$this->gss_model->get_where_row($table,$wheres); $holder=$datas->bank_name; $invoice = $this->gss_model->get_tax_id($holder); $inv=$invoice->invoice_number+1; $where = array('id'=>$id,'tax_status'=>0); $data = array('invoice_type'=>'Tax Invoice','tax_status'=>1,'invoice_number'=>$inv); $result = $this->gss_model->update($where,$table,$data); if($this->db->affected_rows() > 0) { $table = 'gss_invoice_details'; $where = array('id'=>$id,'tax_status'=>1,'invoice_number'=>$inv); $data=$this->gss_model->get_where_row($table,$where); $site_numbers = $data->site_numbers; $project_name=$data->project_id; $invoice_number=$data->invoice_number; //$explode= explode(",",$site_numbers); $data1=substr($site_numbers, 2, -2); $exp=array(); $path = explode(",", $data1); $exp = array_merge($exp, $path); foreach ($exp as $keys => $values) { $tble_sites='gss_new_sites'; $condition_sites=array('project_id'=>$project_name,'site_number'=>$values); $update_data=array('billing_status'=>'Tax Invoice','invoice_no'=>$invoice_number); $this->gss_model->update($condition_sites,$tble_sites,$update_data); } echo json_encode(array('result'=>1,'message'=>'Converted successfully')); } else { echo json_encode(array('result'=>0)); } } public function delete_invoice() { $table = 'gss_invoice_details'; $id = $this->input->post('id'); $tables = 'gss_invoice_details'; $wheres = array('id'=>$id); $data=$this->gss_model->get_where_row($tables,$wheres); $site_numbers = $data->site_numbers; $project_name=$data->project_id; $invoice_number=$data->invoice_number; //$explode= explode(",",$site_numbers); $data1=substr($site_numbers, 2, -2); $exp=array(); $path = explode(",", $data1); $exp = array_merge($exp, $path); foreach ($exp as $keys => $values) { $tble_sites='gss_new_sites'; $condition_sites=array('site_number'=>$values,'invoice_no'=>$invoice_number); $update_data=array('billing_status'=>'','invoice_no'=>0); $this->gss_model->update($condition_sites,$tble_sites,$update_data); //echo $values; } $where = array('id'=>$id); $data = array('delete_status'=>'INACTIVE'); $result = $this->gss_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 get_table_details_invoice() { $id=$this->input->post('id'); $table='gss_invoice_details'; $arr=array(); foreach($id as $ids){ $result=$this->gss_model->get_all_result1_invoice_data_print_export($table,$ids); array_push($arr,$result); } if($arr) { echo json_encode($arr); } else { echo json_encode(array('result'=>0,'message'=>'No Details found')); } } public function work_order_form() { $admin_id = session()->get('admin_id'); if($admin_id) { $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $this->load->view('admin/work_order_form',$data); } else { redirect('/'); } } public function generate_po() { $admin_id = session()->get('admin_id'); if($admin_id) { $ids=$_GET['id']; $explode_id=explode(",",$ids); $array_ids=array(); foreach($explode_id as $eids) { array_push($array_ids,$eids); } $land_table='gss_project_master'; $data['product_list']=$this->gss_model->get_where_work_order($array_ids); $data['owners'] = $this->gss_model->get_where_result1111($land_table); $data['wo_no']=$this->gss_model->get_work_order(); $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $this->load->view('admin/po_generate',$data); } else { redirect('/'); } } public function auto_complete_vendor_name() { $keyword=$_GET['term']; $data1=$this->gss_model->GetRowlog($keyword); foreach($data1 as $row) { $data[]=$row->vendor_name; } echo json_encode($data); } public function vendor_search_by_fetch() { $vendor_name=$this->input->post('id'); $table='gss_vendor_details'; $condition=array('delete_status'=>'ACTIVE'); $result=$this->gss_model->get_whererow($table,$condition,$vendor_name); if($result) { echo json_encode(array('result'=>1,'message'=>$result)); } else { echo json_encode(array('result'=>0,'message'=>'No Details found')); } } public function insert_work_po_data() { $bank_details = $this->input->post('bank_details'); $vendor_name = $this->input->post('vendor_name'); $g_date = $this->input->post('g_date'); $po_no = $this->input->post('po_no'); $currency = $this->input->post('currency'); $address = $this->input->post('address'); $contact_person = $this->input->post('contact_person'); $contact_number = $this->input->post('contact_number'); $email = $this->input->post('email'); $product_id = $this->input->post('product_id'); $p_name = $this->input->post('p_name'); $description = $this->input->post('description'); $i_no = $this->input->post('i_no'); $cgst = $this->input->post('cgst'); $sgst = $this->input->post('sgst'); $project_name = $this->input->post('project_name'); $purpose = $this->input->post('purpose'); $quantityy = $this->input->post('quantityy'); $igst = $this->input->post('igst'); $unit = $this->input->post('unit'); $inrvalue = $this->input->post('inrvalue'); $totalvalue = $this->input->post('totalvalue'); $ot_charges = $this->input->post('ot_charges'); $quantity_val = $this->input->post('quantity_val'); $unit1 = $this->input->post('unit1'); $inr_value_val = $this->input->post('inr_value_val'); $ot_sgst = $this->input->post('ot_sgst'); $ot_cgst = $this->input->post('ot_cgst'); $ot_igst = $this->input->post('ot_igst'); $total_value_val = $this->input->post('total_value_val'); $note = $this->input->post('note'); $total_amt = $this->input->post('total_amt'); $discount = $this->input->post('discount'); $g_total = $this->input->post('g_total'); $comment = $this->input->post('comment'); $gst_no = $this->input->post('gst_no'); $terms_payment = $this->input->post('terms_payment'); $bank_details = $this->input->post('bank_details'); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $created_at = $date->format('Y-m-d H:i:s'); $table='gss_po_generate'; $codition=array('po_no'=>$po_no,'delete_status'=>'ACTIVE'); $get_po_no=$this->gss_model->get_where_row($table,$codition); if(empty($get_po_no)){ foreach($product_id as $key=>$ids) { $data=array( 'po_no' =>$po_no, 'vendor'=>$vendor_name, 'date'=>$g_date, 'currency'=>$currency, 'vendor_address'=>$address, 'contact_person'=>$contact_person, 'contact_number' =>$contact_number, 'email' =>$email, 'product_id' =>$ids, 'product_name' =>$p_name[$key], 'description' =>$description[$key], 'indent' =>$i_no[$key], 'project_name'=>$project_name[$key], 'purpose_no'=>$purpose[$key], 'quentity'=>$quantityy[$key], 'unit_price'=>$unit[$key], 'inr_value'=>$inrvalue[$key], 'sgst'=>$sgst[$key], 'cgst'=>$cgst[$key], 'igst'=>$igst[$key], 'total_value'=>$totalvalue[$key], 'total_amt'=>$total_amt, 'discount'=>$discount, 'grand_total'=>$g_total, 'delete_status'=>'ACTIVE', 'material_delivery'=>$comment, 'bank_details'=>$bank_details, 'terms_of_payment'=>$terms_payment, 'gst_no'=>$gst_no, 'ot_charges'=>$ot_charges, 'ot_unit'=>$unit1, 'ot_quantity'=>$quantity_val, 'ot_inr_value'=>$inr_value_val, 'ot_sgst'=>$ot_sgst, 'ot_cgst'=>$ot_cgst, 'ot_discount'=>$discount, 'ot_igst'=>$ot_igst, 'ot_total_value'=>$total_value_val, 'created_at'=>$created_at, 'modified_at'=>$created_at, 'note'=>$note, 'cancel_status'=>'CANCEL' ); // print_r($data); // die(); $result=$this->gss_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')); } }else { echo json_encode(array('result'=>0,'message'=>'This PO number already exist')); } } public function insert_work_wo_data() { $bank_details = $this->input->post('bank_details'); $vendor_name = $this->input->post('vendor_name'); $g_date = $this->input->post('g_date'); $po_no = $this->input->post('po_no'); $currency = $this->input->post('currency'); $address = $this->input->post('address'); $contact_person = $this->input->post('contact_person'); $contact_number = $this->input->post('contact_number'); $email = $this->input->post('email'); $product_id = $this->input->post('product_id'); $p_name = $this->input->post('p_name'); $description = $this->input->post('description'); $i_no = $this->input->post('i_no'); $cgst = $this->input->post('cgst'); $sgst = $this->input->post('sgst'); $project_name = $this->input->post('project_name'); $purpose = $this->input->post('purpose'); //$quantityy = $this->input->post('quantityy'); $igst = $this->input->post('igst'); // $unit = $this->input->post('unit'); $inrvalue = $this->input->post('inrvalue'); $totalvalue = $this->input->post('totalvalue'); $ot_charges = $this->input->post('ot_charges'); $quantity_val = $this->input->post('quantity_val'); $unit1 = $this->input->post('unit1'); $inr_value_val = $this->input->post('inr_value_val'); $ot_sgst = $this->input->post('ot_sgst'); $ot_cgst = $this->input->post('ot_cgst'); $ot_igst = $this->input->post('ot_igst'); $total_value_val = $this->input->post('total_value_val'); $note = $this->input->post('note'); $total_amt = $this->input->post('total_amt'); $discount = $this->input->post('discount'); $g_total = $this->input->post('g_total'); $comment = $this->input->post('comment'); $gst_no = $this->input->post('gst_no'); $terms_payment = $this->input->post('terms_payment'); $tds = $this->input->post('tds'); $bank_details = $this->input->post('bank_details'); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $created_at = $date->format('Y-m-d H:i:s'); $table='gss_wo_generate'; $codition=array('po_no'=>$po_no,'delete_status'=>'ACTIVE'); $get_po_no=$this->gss_model->get_where_row($table,$codition); if(empty($get_po_no)){ foreach($product_id as $key=>$ids) { $data=array( 'po_no' =>$po_no, 'vendor'=>$vendor_name, 'date'=>$g_date, 'currency'=>$currency, 'vendor_address'=>$address, 'product_id' =>$ids, 'contact_person'=>$contact_person, 'contact_number' =>$contact_number, 'email' =>$email, 'product_name' =>$p_name[$key], 'description' =>$description[$key], 'indent' =>$i_no[$key], 'project_name'=>$project_name[$key], 'purpose_no'=>$purpose[$key], // 'quentity'=>$quantityy[$key], // 'unit_price'=>$unit[$key], 'inr_value'=>$inrvalue[$key], 'sgst'=>$sgst[$key], 'cgst'=>$cgst[$key], 'igst'=>$igst[$key], 'total_value'=>$totalvalue[$key], 'total_amt'=>$total_amt, 'discount'=>$discount, 'grand_total'=>$g_total, 'delete_status'=>'ACTIVE', 'material_delivery'=>$comment, 'bank_details'=>$bank_details, 'tds'=>$tds, 'terms_of_payment'=>$terms_payment, 'gst_no'=>$gst_no, 'ot_charges'=>$ot_charges, 'ot_unit'=>$unit1, 'ot_quantity'=>$quantity_val, 'ot_inr_value'=>$inr_value_val, 'ot_sgst'=>$ot_sgst, 'ot_cgst'=>$ot_cgst, 'ot_igst'=>$ot_igst, 'ot_total_value'=>$total_value_val, 'ot_discount'=>$discount, 'created_at'=>$created_at, 'modified_at'=>$created_at, 'note'=>$note, 'cancel_status'=>'CANCEL' ); $result=$this->gss_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')); } }else { echo json_encode(array('result'=>0,'message'=>'This WO number already exist')); } } public function po_genereted_list_form() { $admin_id = session()->get('admin_id'); if($admin_id) { $land_table = 'gss_project_master'; $data['project'] = $this->gss_model->get_where_result1111($land_table); $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $this->load->view('admin/po_genereted_list',$data); } else { redirect('/'); } } /*public function work_order_po_generated_list() { $table='gss_po_generate'; $condition=array('delete_status'=>'ACTIVE'); $result = $this->gss_model->get_where_result_distinct($table,$condition); if($result) { echo json_encode($result); } else { echo json_encode(array('result'=>0)); } }*/ /*public function work_order_wo_generated_list() { $table='gss_wo_generate'; $condition=array('delete_status'=>'ACTIVE'); $result = $this->gss_model->get_where_result_distinct($table,$condition); // print_r($result); // die(); if($result) { echo json_encode($result); } else { echo json_encode(array('result'=>0)); } }*/ public function purchase_order_form() { $admin_id = session()->get('admin_id'); if($admin_id) { $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $this->load->view('admin/purchase_order_form',$data); } else { redirect('/'); } } public function purchase_order_generate_po() { $admin_id = session()->get('admin_id'); if($admin_id) { $ids=$_GET['id']; $explode_id=explode(",",$ids); $array_ids=array(); foreach($explode_id as $eids) { array_push($array_ids,$eids); } $data['product_list']=$this->gss_model->get_where_reults_work_order_list($array_ids); $land_table = 'gss_project_master'; $data['owners'] = $this->gss_model->get_where_result1111($land_table); $data['wo_no']= $this->gss_model->get_purchase_order(); $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $this->load->view('admin/purchase_order_generate_po',$data); } else { redirect('/'); } } public function purchase_po_genereted_list_form() { $admin_id = session()->get('admin_id'); if($admin_id) { $land_table = 'gss_project_master'; $data['project'] = $this->gss_model->get_where_result1111($land_table); $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $this->load->view('admin/purchase_po_genereted_list_form',$data); } else { redirect('/'); } } public function edit_work_order_po() { $admin_id = session()->get('admin_id'); if($admin_id) { $ids=$_GET['id']; $where=array('id'=>$ids); $table='gss_wo_generate'; $data['po_details']=$this->gss_model->get_where_row($table,$where); $where1 = array('po_no'=>$data['po_details']->po_no); $data['fetch_details'] = $this->gss_model->fetch_where_subgrid_data1($table,$where1); $data['key']=1; $land_table = 'gss_project_master'; $data['owners'] = $this->gss_model->get_where_result1111($land_table); $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $this->load->view('admin/edit_work_order_po',$data); } else { redirect('/'); } } public function view_work_order_po() { $admin_id = session()->get('admin_id'); if($admin_id) { $ids=$_GET['id']; $condition=array('id'=>$ids); $table='gss_po_generate'; $data['fetch_address']=$this->gss_model->get_where_row($table,$condition); $data['key']=1; $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $this->load->view('admin/view_work_order_po',$data); } else { redirect('/'); } } public function update_work_po_data() { $id=$this->input->post('edit_id'); $bank_details = $this->input->post('bank_details'); $vendor_name = $this->input->post('vendor_name'); $g_date = $this->input->post('g_date'); $po_no = $this->input->post('po_no'); $currency = $this->input->post('currency'); $address = $this->input->post('address'); $contact_person = $this->input->post('contact_person'); $contact_number = $this->input->post('contact_number'); $email = $this->input->post('email'); $product_id = $this->input->post('product_id'); $p_name = $this->input->post('p_name'); $description = $this->input->post('description'); $i_no = $this->input->post('i_no'); $cgst = $this->input->post('cgst'); $sgst = $this->input->post('sgst'); $project_name = $this->input->post('project_name'); $purpose = $this->input->post('purpose'); $quantityy = $this->input->post('quantityy'); $igst = $this->input->post('igst'); $unit = $this->input->post('unit'); $inrvalue = $this->input->post('inrvalue'); $totalvalue = $this->input->post('totalvalue'); $ot_charges = $this->input->post('ot_charges'); $quantity_val = $this->input->post('quantity_val'); $unit1 = $this->input->post('unit1'); $inr_value_val = $this->input->post('inr_value_val'); $ot_sgst = $this->input->post('ot_sgst'); $ot_cgst = $this->input->post('ot_cgst'); $ot_igst = $this->input->post('ot_igst'); $total_value_val = $this->input->post('total_value_val'); $note = $this->input->post('note'); $total_amt = $this->input->post('total_amt'); $discount = $this->input->post('discount'); $g_total = $this->input->post('g_total'); $comment = $this->input->post('comment'); $gst_no = $this->input->post('gst_no'); $terms_payment = $this->input->post('terms_payment'); $bank_details = $this->input->post('bank_details'); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $created_at = $date->format('Y-m-d H:i:s'); $table='gss_po_generate'; foreach($product_id as $key=>$ids) { $data=array( 'id'=>$id[$key], 'po_no' =>$po_no, 'vendor'=>$vendor_name, 'date'=>$g_date, 'currency'=>$currency, 'vendor_address'=>$address, 'contact_person'=>$contact_person, 'contact_number' =>$contact_number, 'email' =>$email, 'product_id' =>$ids, 'product_name' =>$p_name[$key], 'description' =>$description[$key], 'indent' =>$i_no[$key], 'project_name'=>$project_name[$key], 'purpose_no'=>$purpose[$key], 'quentity'=>$quantityy[$key], 'unit_price'=>$unit[$key], 'inr_value'=>$inrvalue[$key], 'sgst'=>$sgst[$key], 'cgst'=>$cgst[$key], 'igst'=>$igst[$key], 'total_value'=>$totalvalue[$key], 'total_amt'=>$total_amt, 'discount'=>$discount, 'grand_total'=>$g_total, 'delete_status'=>'ACTIVE', 'material_delivery'=>$comment, 'bank_details'=>$bank_details, 'terms_of_payment'=>$terms_payment, 'gst_no'=>$gst_no, 'ot_charges'=>$ot_charges, 'ot_unit'=>$unit1, 'ot_quantity'=>$quantity_val, 'ot_inr_value'=>$inr_value_val, 'ot_sgst'=>$ot_sgst, 'ot_cgst'=>$ot_cgst, 'ot_igst'=>$ot_igst, 'ot_total_value'=>$total_value_val, 'modified_at'=>$created_at, 'note'=>$note, ); $condition=array('id'=>$id[$key],); $result=$this->gss_model->update($condition,$table,$data); } if($result) { echo json_encode(array('result'=>1,'message'=>'Updated successfully')); } else { echo json_encode(array('result'=>0,'message'=>'Not Added')); } } public function update_work_wo_data() { $id=$this->input->post('edit_id'); $bank_details = $this->input->post('bank_details'); $vendor_name = $this->input->post('vendor_name'); $g_date = $this->input->post('g_date'); $po_no = $this->input->post('po_no'); $currency = $this->input->post('currency'); $contact_person = $this->input->post('contact_person'); $contact_number = $this->input->post('contact_number'); $email = $this->input->post('email'); $address = $this->input->post('address'); $product_id = $this->input->post('product_id'); $p_name = $this->input->post('p_name'); $description = $this->input->post('description'); $i_no = $this->input->post('i_no'); $cgst = $this->input->post('cgst'); $sgst = $this->input->post('sgst'); $project_name = $this->input->post('project_name'); $purpose = $this->input->post('purpose'); //$quantityy = $this->input->post('quantityy'); $igst = $this->input->post('igst'); // $unit = $this->input->post('unit'); $inrvalue = $this->input->post('inrvalue'); $totalvalue = $this->input->post('totalvalue'); $ot_charges = $this->input->post('ot_charges'); $quantity_val = $this->input->post('quantity_val'); $unit1 = $this->input->post('unit1'); $inr_value_val = $this->input->post('inr_value_val'); $ot_sgst = $this->input->post('ot_sgst'); $ot_cgst = $this->input->post('ot_cgst'); $ot_igst = $this->input->post('ot_igst'); $total_value_val = $this->input->post('total_value_val'); $note = $this->input->post('note'); $total_amt = $this->input->post('total_amt'); $discount = $this->input->post('discount'); $g_total = $this->input->post('g_total'); $comment = $this->input->post('comment'); $gst_no = $this->input->post('gst_no'); $terms_payment = $this->input->post('terms_payment'); $bank_details = $this->input->post('bank_details'); $tds = $this->input->post('tds'); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $created_at = $date->format('Y-m-d H:i:s'); $table='gss_wo_generate'; foreach($product_id as $key=>$ids) { $data=array( 'id'=>$id[$key], 'po_no' =>$po_no, 'vendor'=>$vendor_name, 'date'=>$g_date, 'currency'=>$currency, 'contact_person'=>$contact_person, 'contact_number' =>$contact_number, 'email' =>$email, 'vendor_address'=>$address, 'product_id' =>$ids, 'product_name' =>$p_name[$key], 'description' =>$description[$key], 'indent' =>$i_no[$key], 'project_name'=>$project_name[$key], 'purpose_no'=>$purpose[$key], //'quentity'=>$quantityy[$key], //'unit_price'=>$unit[$key], 'inr_value'=>$inrvalue[$key], 'sgst'=>$sgst[$key], 'cgst'=>$cgst[$key], 'igst'=>$igst[$key], 'total_value'=>$totalvalue[$key], 'total_amt'=>$total_amt, 'discount'=>$discount, 'grand_total'=>$g_total, 'delete_status'=>'ACTIVE', 'material_delivery'=>$comment, 'bank_details'=>$bank_details, 'tds'=>$tds, 'terms_of_payment'=>$terms_payment, 'gst_no'=>$gst_no, 'ot_charges'=>$ot_charges, 'ot_unit'=>$unit1, 'ot_quantity'=>$quantity_val, 'ot_inr_value'=>$inr_value_val, 'ot_sgst'=>$ot_sgst, 'ot_cgst'=>$ot_cgst, 'ot_igst'=>$ot_igst, 'ot_total_value'=>$total_value_val, 'modified_at'=>$created_at, 'note'=>$note, ); // print_r($data); $condition=array('id'=>$id[$key]); //print_r($condition); $result=$this->gss_model->update($condition,$table,$data); } // die(); if($result) { echo json_encode(array('result'=>1,'message'=>'Updated successfully')); } else { echo json_encode(array('result'=>0,'message'=>'Not Added')); } } public function edit_purchase_order_po() { $admin_id = session()->get('admin_id'); if($admin_id) { $ids=$_GET['id']; $where=array('id'=>$ids); $table='gss_po_generate'; $data['po_details']=$this->gss_model->get_where_row($table,$where); $where1 = array('po_no'=>$data['po_details']->po_no); $data['fetch_details'] = $this->gss_model->fetch_where_subgrid_data1($table,$where1); $data['key']=1; $land_table = 'gss_project_master'; $data['owners'] = $this->gss_model->get_where_result1111($land_table); $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $this->load->view('admin/edit_purchase_order_po',$data); } else { redirect('/'); } } public function view_work_order_wo() { $admin_id = session()->get('admin_id'); if($admin_id) { $ids=$_GET['id']; $table='gss_wo_generate'; $where = array('delete_status'=>'ACTIVE','id'=>$ids); $data['fetch_address']=$this->gss_model->get_where_row($table,$where); $where1 = array('po_no'=>$data['fetch_address']->po_no); $data['fetch_details'] = $this->gss_model->fetch_where_subgrid_data1($table,$where1); $data['key']=1; $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $this->load->view('admin/view_work_order_po',$data); } else { redirect('/'); } } public function view_purchase_order_po() { $admin_id = session()->get('admin_id'); if($admin_id) { $ids=$_GET['id']; $table='gss_po_generate'; $where = array('delete_status'=>'ACTIVE','id'=>$ids); $data['fetch_address']=$this->gss_model->get_where_row($table,$where); $where1 = array('po_no'=>$data['fetch_address']->po_no); $data['fetch_details'] = $this->gss_model->fetch_where_subgrid_data1($table,$where1); $data['key']=1; $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $this->load->view('admin/view_purchase_order_po',$data); } else { redirect('/'); } } public function update_invoice_details() { $table = 'gss_invoice_details'; $id = $this->input->post('id'); $invoice_number = $this->input->post('invoice_number'); $project_name = $this->input->post('project_name'); $site_list[] = $this->input->post('site_list'); $site_number[] = $this->input->post('site_number'); $invoice_type = $this->input->post('invoice_type'); // print_r($invoice_type); // die(); $to = $this->input->post('invoice_to'); $total_sqft = $this->input->post('total_sqft'); $rate_per_sqft = $this->input->post('rate_per_sqft'); $total_amt = $this->input->post('total_amt'); $sgst = $this->input->post('sgst'); $cgst = $this->input->post('cgst'); $total_amt1=$total_amt * $total_sqft; $total_withgst_amt = $this->input->post('total_withgst_amt'); $total_sgst=round(($total_amt * $sgst)/100); $total_cgst=round(($total_amt * $cgst)/100); $bank_name=$this->input->post('bank_holder_name'); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $updated_at = $date->format('Y-m-d H:i:s'); $data = array('invoice_number'=>$invoice_number,'project_id'=>$project_name,'site_ids'=>json_encode($site_list),'invoice_type'=>$invoice_type,'invoice_to'=>$to,'total_sqft'=>$total_sqft,'rate_per_sqft'=>$rate_per_sqft,'without_gst_total_amt'=>$total_amt,'sgst'=>$sgst,'cgst'=>$cgst,'with_gst_total_amt'=>$total_withgst_amt,'created_at'=> $updated_at,'delete_status'=>'ACTIVE','site_numbers'=>json_encode($site_number),'total_sgst'=>$total_sgst,'total_cgst'=>$total_cgst,'bank_name'=>$bank_name); // print_r($data); // die(); $where_id = array('id'=>$id); $result = $this->gss_model->update($where_id,$table,$data); $tble_sitess='gss_new_sites'; $condition_sitess=array('invoice_no'=>$invoice_number); $update_datas=array('billing_status'=>"",'invoice_no'=>0); $this->gss_model->update($condition_sitess,$tble_sitess,$update_datas); $site_numbers = $this->input->post('site_number'); $explode= explode(",",$site_numbers); foreach ($explode as $keys => $values) { $tble_sites='gss_new_sites'; $condition_sites=array('project_id'=>$project_name,'site_number'=>$values); $update_data=array('billing_status'=>$invoice_type,'invoice_no'=>$invoice_number); $this->gss_model->update($condition_sites,$tble_sites,$update_data); } if($result) { echo json_encode(array('result'=>1,'message'=>'Updated successfully')); } else { echo json_encode(array('result'=>0,'message'=>'Not Updated')); } } public function tax_invoice_print() { $uri = $_SERVER["REQUEST_URI"]; $val = substr($uri, strpos($uri, "=") + 1); $admin_id = session()->get('admin_id'); if($admin_id) { $id=$val; $data['details']=$this->gss_model->get_where_row_for_print($id); $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $this->load->view('admin/tax_invoice_print',$data); } else { redirect('/'); } } public function proforma_invoice_print() { $admin_id = session()->get('admin_id'); if($admin_id) { $id=$_GET['id']; $table ='gss_bank_details'; $where = array('delete_status'=>'ACTIVE'); $data['bank_name'] = $this->gss_model->getallbankdetails($table,$where); $data['details']=$this->gss_model->get_where_row_for_print($id); $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $this->load->view('admin/proforma_invoice_print',$data); } else { redirect('/'); } } public function edit_invoice_form() { $admin_id = session()->get('admin_id'); if($admin_id) { $table='gss_invoice_details'; $id=$this->input->post('id'); $where = array('id'=>$id,'delete_status'=>'ACTIVE'); $r = $this->gss_model->get_where_row($table,$where); $table1= 'gss_bank_details' ; $where1 = array('delete_status'=>'ACTIVE'); $d = $this->gss_model->getallbankdetails($table1,$where1); // print_r($r); // die(); if($r) { echo json_encode(array('invoice_details'=>$r,'bank'=>$d,'result'=>1)); } else { echo json_encode(array('result'=>0)); } } else { redirect('/'); } } public function wo_subgrid() { $i=$_GET['id']; $table='gss_wo_generate'; $where = array('id'=>$i); $getalldatas = $this->gss_model->get_where_row($table,$where); $po=$getalldatas->po_no; $where1 = array('po_no'=>$po); $getalldata = $this->gss_model->fetch_where_subgrid_data1($table,$where1); echo json_encode($getalldata); } public function po_subgrid() { $i=$_GET['id']; $table='gss_po_generate'; $where = array('id'=>$i); $getalldatas = $this->gss_model->get_where_row($table,$where); $po=$getalldatas->po_no; $where1 = array('po_no'=>$po); $getalldata = $this->gss_model->fetch_where_subgrid_data1($table,$where1); echo json_encode($getalldata); } public function project_master() { $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $this->load->view('admin/add_project_master',$data); } public function edit_proforma_invoice_form() { $admin_id = session()->get('admin_id'); if($admin_id) { $i=$_GET['id']; //$id=$this->input->post('id'); $table='gss_new_projects'; $data['project_names']=$this->gss_model->get_where_reults_project_name(); $table= 'gss_bank_details' ; $where = array('delete_status'=>'ACTIVE'); $data['bank_name'] = $this->gss_model->getallbankdetails($table,$where); $where1 = array('id'=>$i); $tab='gss_invoice_details'; $data['details']=$this->gss_model->get_where_row($tab,$where1); $data['invoice'] = $this->gss_model->get_proforma_invoice_details($where1); $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $this->load->view('admin/edit_proforma_invoice_form',$data); } else { redirect('/'); } } public function get_row_details() { $table = 'gss_invoice_details'; $id = $this->input->post('id'); $where = array('id'=>$id); $result = $this->gss_model->get_where_row($table,$where); // print_r($result); // die(); if($result) { echo json_encode(array('result'=>1,'message'=>$result)); } else { echo json_encode(array('result'=>0,'message'=>'Not Found')); } } public function edit_tax_invoice_form() { $admin_id = session()->get('admin_id'); if($admin_id) { $i=$_GET['id']; //$id=$this->input->post('id'); $table='gss_new_projects'; $data['project_names']=$this->gss_model->get_where_reults_project_name(); $table= 'gss_bank_details' ; $where = array('delete_status'=>'ACTIVE'); $data['bank_name'] = $this->gss_model->getallbankdetails($table,$where); $where1 = array('id'=>$i); $tab='gss_invoice_details'; $data['details']=$this->gss_model->get_where_row($tab,$where1); $data['invoice'] = $this->gss_model->get_tax_invoice_details($where1); $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $this->load->view('admin/edit_tax_invoice_form',$data); } else { redirect('/'); } } public function client_details_form() { $broker_table = 'gss_brokers'; $where_reference = array('delete_status'=>'ACTIVE','type'=>'Executives'); $order_by1 = 'associate_name'; $data['reference'] = $this->gss_model->get_where_result_alphabetical($broker_table,$where_reference,$order_by1); $land_table = 'gss_new_projects'; // $data['owners'] = $this->gss_model->get_where_result1111($land_table); $where_reference1 = array('delete_status'=>'ACTIVE'); $order_by2 = 'project_name'; $data['owners'] = $this->gss_model->get_where_result_alphabetical($land_table,$where_reference1,$order_by2); $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $this->load->view('admin/client_details_form',$data); } public function add_client_details() { $customer_name = $this->input->post('customer_name'); $relation = $this->input->post('relation'); $relative = $this->input->post('fa_hu_name'); $project_id = $this->input->post('project_id'); $mobile1 = $this->input->post('mobile11'); $mobile2 = $this->input->post('mobile12'); $email = $this->input->post('email'); $office_no = $this->input->post('office_no'); $address = $this->input->post('address'); $bday = $this->input->post('bday'); if($bday != "") { $date = new DateTime($bday); $bday = $date->format('Y-m-d'); } $doa = $this->input->post('doa'); if($doa != "") { $date = new DateTime($doa); $doa = $date->format('Y-m-d'); } $executive = $this->input->post('reference'); $site_number = $this->input->post('site_number'); $site_dimension = $this->input->post('site_dimension'); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $created_at = $date->format('Y-m-d H:i:s'); $data = array('project_id'=>$project_id, 'customer_name'=>$customer_name, 'relation'=>$relation, 'father_or_husband'=>$relative, 'mobile1'=>$mobile1, 'mobile2'=>$mobile2, 'office_number'=>$office_no, 'email'=>$email, 'address'=>$address, 'dob'=>$bday, 'doa'=>$doa, 'reference'=>$executive, 'status'=>1, 'booking_status'=>"ENQUIRED", 'delete_status'=>'ACTIVE', 'created_at'=>$created_at); $booking_table = 'gss_bookings'; $detail_table = 'gss_booking_details'; //$where = array('delete_status'=>'ACTIVE','mobile1'=>$mobile1); $where_booked_site = array('delete_status'=>'ACTIVE','project_id'=>$project_id); $site_table = 'gss_new_sites'; $where_sites = array('project_id' => $project_id ,'delete_status' => 'ACTIVE'); $sites = $this->gss_model->get_where_result($site_table,$where_sites); $array2 = array(); foreach($sites as $value) { array_push($array2, $value->site_number); } $booked_site_table = "gss_booking_details"; $booked_sites = $this->gss_model->get_where_result($booked_site_table,$where_booked_site); $array1 = array(); foreach($booked_sites as $value) { array_push($array1, $value->site_number); } if(in_array($site_number,$array1)) { $booking_table = 'gss_bookings'; $order_by = 'booking_id'; $where1 = array('delete_status'=>'ACTIVE','project_id'=>$project_id,'site_number'=>$site_number); $check = $this->gss_model->get_where_orderby_row($detail_table,$where1,$order_by); $where2 = array('delete_status'=>'ACTIVE','booking_id'=>$check->booking_id,'project_id'=>$project_id); $status = $this->gss_model->get_where_orderby_row($booking_table,$where2,$order_by); if($status->booking_status == 'BOOKED') { echo json_encode(array('result'=>2,'message'=>"Site already Booked..")); } else if($status->booking_status == 'ENQUIRED') { echo json_encode(array('result'=>2,'message'=>"Site already Enquired..")); } else if($status->booking_status == 'CANCELLED' || $status->booking_status == 'REFUNDED') { $result = $this->gss_model->insert($booking_table,$data); $table1='gss_booking_details'; $data1=array('project_id'=>$project_id, 'site_number'=>$site_number, 'dimension'=>$site_dimension, 'booking_id'=>$result); $result1 = $this->gss_model->insert($table1,$data1); if($result1) { echo json_encode(array('result'=>1,'message'=>"Client Details added successfully")); } else { echo json_encode(array('result'=>0,'message'=>"Something went wrong.. try again")); } } } else if(in_array($site_number,$array2)) { $result = $this->gss_model->insert($booking_table,$data); $table1='gss_booking_details'; $data1=array('project_id'=>$project_id, 'site_number'=>$site_number, 'dimension'=>$site_dimension, 'booking_id'=>$result); $result1 = $this->gss_model->insert($table1,$data1); if($result1) { echo json_encode(array('result'=>1,'message'=>"Client Details added successfully")); } else { echo json_encode(array('result'=>0,'message'=>"Something went wrong.. try again")); } } else { $result = $this->gss_model->insert($booking_table,$data); $table1='gss_booking_details'; $data1=array('project_id'=>$project_id, 'site_number'=>$site_number, 'dimension'=>$site_dimension, 'booking_id'=>$result); $result1 = $this->gss_model->insert($table1,$data1); if($result1) { echo json_encode(array('result'=>1,'message'=>"Client Details added successfully")); } else { echo json_encode(array('result'=>0,'message'=>"Something went wrong.. try again")); } } } public function client_booking_details() { $admin_id = session()->get('admin_id'); if($admin_id) { $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $this->load->view('admin/client_list',$data); } else { redirect('/'); } } public function client_detail_list() { $table = 'gss_bookings'; $where = array('delete_status'=>'ACTIVE','status'=>1); $result = $this->gss_model->get_all_clients(); if($result) { echo json_encode($result); } else { echo json_encode(array('result'=>0)); } } public function view_client_details() { $admin_id = session()->get('admin_id'); if($admin_id) { $table = 'gss_bookings'; $booking_id = $this->uri->segment(2); $data['site_result'] = $this->gss_model->client_site_booking_details1($booking_id); $site_result = $this->gss_model->user_site_booking_details1($booking_id); $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $this->load->view('admin/view_client_details',$data); } else { redirect('/'); } } public function edit_client_details() { $admin_id = session()->get('admin_id'); if($admin_id) { $web_table = 'gss_webportals'; $broker_table = 'gss_brokers'; $project_table = 'gss_new_projects'; $where_portal = array('delete_status'=>'ACTIVE'); $where_reference = array('delete_status'=>'ACTIVE','type'=>'Executives'); $where_logistics = array('delete_status'=>'ACTIVE','type'=>'Logistic'); $where_associate = array('delete_status'=>'ACTIVE','type'=>'Associate'); $where_subassociate = array('delete_status'=>'ACTIVE','type'=>'Sub Associate'); $where_project = array('delete_status'=>'ACTIVE'); $order_by_portal = 'webportal'; $order_by = 'associate_name'; $order_by_project = 'project_name'; $data['webportals'] = $this->gss_model->get_where_result_alphabetical($web_table,$where_portal,$order_by_portal); $data['reference'] = $this->gss_model->get_where_result_orderby_asc($broker_table,$where_reference,$order_by); $data['projects'] = $this->gss_model->get_where_result_orderby_asc($project_table,$where_project,$order_by_project); $booking_id = $this->uri->segment(2); $data['booking'] = $this->gss_model->client_booking_details($booking_id); $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $this->load->view('admin/edit_client_form',$data); } else { redirect('/'); } } //Update Client Details public function update_client_details() { $booking_table = 'gss_bookings'; $detail_table = 'gss_booking_details'; $booking_id = $this->input->post('booking_id'); $detail_id = $this->input->post('detail_id'); $customer_name = $this->input->post('customer_name'); $relation = $this->input->post('relation'); $fa_hu_name = $this->input->post('fa_hu_name'); $email = $this->input->post('email'); $alternative_email = $this->input->post('alternative_email'); $mobile1 = $this->input->post('mobile11'); $mobile2 = $this->input->post('mobile12'); $office_no = $this->input->post('office_no'); $bday = $this->input->post('bday'); if($bday !="") { $date = new DateTime($bday); $bday = $date->format('Y-m-d'); } $doa = $this->input->post('doa'); if($doa !="") { $date = new DateTime($doa); $doa = $date->format('Y-m-d'); } $address = $this->input->post('address'); $reference = $this->input->post('reference'); $project_id = $this->input->post('project_id'); $site_number = $this->input->post('site_number'); $site_dimension = $this->input->post('site_dimension'); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $created_at = $date->format('Y-m-d H:i:s'); //$mobile = json_encode(array($mobile1, $mobile2)); $booking_data = array( 'project_id' => $project_id, 'customer_name' => $customer_name, 'relation' => $relation, 'father_or_husband' => $fa_hu_name, 'email' => $email, 'alternative_email' => $alternative_email, 'mobile1' => $mobile1, 'mobile2' => $mobile2, 'dob' => $bday, 'doa' => $doa, 'address' => $address, 'reference' => $reference, 'status' => 1, 'delete_status' => 'ACTIVE', 'created_at' => $created_at ); $detail_data = array( 'booking_id' => $booking_id, 'project_id' => $project_id, 'site_number' => $site_number, 'dimension' => $site_dimension, 'delete_status' => 'ACTIVE', 'created_at' => $created_at ); // print_r($booking_data); // print_r($detail_data); // die(); $where_detail = array('booking_id'=>$booking_id); //print_r($where_detail); $where_booking = array('booking_id' => $booking_id); // print_r($where_booking); // die(); $detail_result = $this->gss_model->update($where_detail,$detail_table,$detail_data); if($this->db->affected_rows() > 0) { $detail = $this->gss_model->update($where_booking,$booking_table,$booking_data); echo json_encode(array('result' => 1,'message' => "Updated successfully")); } else { echo json_encode(array('result'=>0,'message'=>"Something went wrong.. try again")); } } public function delele_registration_amount() { $table = 'gss_registration_amount_details'; $id = $this->input->post('id'); $where = array('id'=>$id); $data = array('delete_status'=>'INACTIVE'); $result = $this->gss_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 follow_ups() { $admin_id = session()->get('admin_id'); $type=session()->get('user_type_id'); // print_r($type);die(); if($admin_id) { $land_table = 'gss_new_projects'; $project_id=$this->input->post('project_id'); $site_type=$this->input->post('site_type'); if($type != 1 && $type != 4) { $where=array('handled_by'=>$admin_id); // $data['owners'] = $this->gss_model->get_where_user($land_table,$where); $data['owners'] = $this->gss_model->get_where_user($where); $data['details'] =$this->gss_model->get_user_details($where); $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $this->load->view('admin/follow_up_details',$data); } else if($type == 4) { $where=array('handled_by'=>$admin_id); // $data['owners'] = $this->gss_model->get_where_user($land_table,$where); $data['owners'] = $this->gss_model->get_documents(); $data['details'] =$this->gss_model->get_user_details($where); $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $this->load->view('admin/follow_up_details',$data); } else { $current_date = date('Y-m-d'); $data['owners'] = $this->gss_model->get_where_alluser($land_table,$current_date); $data['details'] =$this->gss_model->get_alluser_details($current_date); $project_table = 'gss_new_projects'; $where_project = array('delete_status'=>'ACTIVE','project_status'=>'ONGOING'); $projects_order_by = 'project_name'; $data['projects'] = $this->gss_model->get_where_result_orderby_asc($project_table,$where_project,$projects_order_by); $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $this->load->view('admin/admin_follow_up_details',$data); } } else { redirect('/'); } } /*public function update_reminder() { $admin_id = session()->get('admin_id'); $type=session()->get('user_type_id'); if($admin_id) { $detail_id = $this->input->post('reminder_id'); $call_convo = $this->input->post('call_convo'); $where=$detail_id; $details=$this->gss_model->get_follow_call_details($where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $created_at = $date->format('Y-m-d H:i:s'); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $updated_at = $date->format('d-m-Y'); $conver_id = $this->input->post('conver_id'); $table = 'gss_follow_ups'; $data = array( 'user_id'=>$admin_id, 'detail_id'=>$details->detail_id, 'project_id'=>$details->project_id, 'site_number'=>$details->site_number, 'conversation'=>$call_convo, 'conversation_status'=>'ONGOING', // 'conversation_id'=>$conver_id, 'delete_status'=>'ACTIVE', 'created_at'=>$created_at ); $a = $this->gss_model->insert($table,$data); $where_detail_id = $a; $res = $this->gss_model->get_return_result($a); foreach($res as $r) { $id_detail = $r->detail_id; } $booking_table = 'gss_booking_details'; $update_where=array('detail_id'=>$id_detail); $update_data = array( 'updated_at'=>$updated_at ); $this->gss_model->update($update_where,$booking_table,$update_data); // $convo_id =$a; echo json_encode($a); } else { redirect('/'); } }*/ public function add_conversation() { $admin_id = session()->get('admin_id'); $type=session()->get('user_type_id'); if($admin_id) { $detail_id = $this->input->post('reminder_id'); $call_convo = $this->input->post('call_convo'); $where=$detail_id; $details=$this->gss_model->get_follow_call_details($where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $created_at = $date->format('Y-m-d'); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $updated_at = $date->format('d-m-Y'); $conver_id = $this->input->post('conver_id'); $table = 'gss_follow_ups'; $data = array( 'user_id'=>$admin_id, 'detail_id'=>$details->detail_id, 'project_id'=>$details->project_id, 'site_number'=>$details->site_number, 'conversation'=>$call_convo, 'conversation_status'=>'ONGOING', // 'conversation_id'=>$conver_id, 'delete_status'=>'ACTIVE', 'created_at'=>$created_at ); $a = $this->gss_model->insert($table,$data); $where_detail_id = $a; $res = $this->gss_model->get_return_result($a); foreach($res as $r) { $id_detail = $r->detail_id; } $booking_table = 'gss_booking_details'; $update_where=array('detail_id'=>$id_detail); $update_data = array( 'updated_at'=>$updated_at ); $this->gss_model->update($update_where,$booking_table,$update_data); // $convo_id =$a; echo json_encode($a); } else { redirect('/'); } } public function call_follow_up() { $admin_id = session()->get('admin_id'); if($admin_id) { $detail_id = $this->input->post('reminder_id'); $uri = $_SERVER["REQUEST_URI"]; $val = substr($uri, strpos($uri, "=") + 1); $where =$val; $where1=array('handled_by'=>$admin_id); $data['detailSS']= $this->gss_model->get_call_p_details($where); $data['detail']= $this->gss_model->get_call_details($where,$where1); $data['comment']= $this->gss_model->get_comment_details($where,$where1); $comment = $data['comment']; $data['reply']= $this->gss_model->get_reply_details($where); $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $this->load->view('admin/follow_up',$data); } else { redirect('/'); } } public function add_date() { $admin_id = session()->get('admin_id'); if($admin_id) { $detail_id = $this->input->post('reminder_id'); $reminder_date = $this->input->post('rem_date'); $where=array('id'=>$detail_id); $table = 'gss_follow_ups'; $data=array('reminder'=>$reminder_date); $a=$this->gss_model->update($where,$table,$data); } else { redirect('/'); } } public function update_call_status() { $admin_id = session()->get('admin_id'); if($admin_id) { $detail_id = $this->input->post('reminder_id'); $where=array('id'=>$detail_id); $table = 'gss_follow_ups'; $data=array('conversation_status'=>'COMPLETED','close_status'=> 1); $a=$this->gss_model->update($where,$table,$data); } else { redirect('/'); } } public function admin_dashboard() { $session = session(); $admin_id = $session->get('admin_id'); if ($admin_id) { $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); return view('admin/admin_dashboard', $data); } else { return redirect()->to('/'); } } public function get_all_reminder() { $total_admin_reminder_notifications = ''; $admin_id = session()->get('admin_id'); $type=session()->get('user_type_id'); $result=""; $comment=""; $reply=""; $reminder=""; if($type >1) { $data = $this->gss_model->get_follow_up_reminders($admin_id); foreach($data as $res) { $dmy = date('d-m-Y'); $date = $res->reminder; $newdate = strtotime ( '-2 day' , strtotime ($date) ) ; $newdate = date ( 'd-m-Y' , $newdate ); $d = array(); if($newdate == $dmy) { array_push($d, $res->reminder); } else { } foreach($d as $det) { $table = 'gss_follow_ups'; $admin_id = session()->get('admin_id'); $type=session()->get('user_type_id'); if($type >1) { $where = array('reminder'=>$det,'user_id'=>$admin_id); $where1 = array('user_id'=>$admin_id); $result = $this->gss_model->get_follow_up_reminderss($where); $total_user_reminder_notifications = $this->gss_model->get_total_follow_up_reminder($where); $current_date = date('d-m-Y'); $new = array(); array_push($new,$result); } } } $data['detail']=$result; $total_user_reminders = $total_user_reminder_notifications; if($result) { echo json_encode(array('result'=>1,'total_user_reminders'=>$total_user_reminder_notifications,'detail'=>$result)); } else { echo json_encode(array('result'=>0)); } } else { $admin_id = session()->get('admin_id'); $data = $this->gss_model->get_follow_up_admin_reminders($admin_id); foreach($data as $res) { $current_date = date('d-m-Y'); $admin_reminder_date = $res->admin_reminder_date; $newdate = strtotime ( '-2 day' , strtotime ($admin_reminder_date) ) ; $newdate = date ( 'd-m-Y' , $newdate ); $admin_date = array(); if($newdate == $current_date) { array_push($admin_date, $res->admin_reminder_date); } else { } foreach($admin_date as $adm_det) { $table = 'gss_comment'; $admin_id = session()->get('admin_id'); $type=session()->get('user_type_id'); $where = array('admin_reminder_date'=>$adm_det); $result = $this->gss_model->get_admin_reminders($where); $total_admin_reminder_notifications = $this->gss_model->get_total_follow_up_admin_reminder($where); } } $data['detail']=$result; $total_admin_reminders = $total_admin_reminder_notifications; if($result) { echo json_encode(array('result'=>1,'total_admin_reminders'=>$total_admin_reminder_notifications,'detail'=>$result)); } else { echo json_encode(array('result'=>0)); } } } public function add_comment() { $admin_id = session()->get('admin_id'); if($admin_id) { $conversation_id = $this->input->post('conv_id'); $detail_id = $this->input->post('detail_id'); $project_id = $this->input->post('project_id'); $site_number = $this->input->post('site_number'); $handled_by = $this->input->post('handled_by'); $admin_comment = $this->input->post('admin_comment'); $comment_date = date('d-m-Y'); $created_at = date('Y-m-d H:i:s'); $data = array('detail_id'=>$detail_id,'project_id'=>$project_id,'site_number'=>$site_number,'user_id'=>$admin_id,'receiver_id'=>$handled_by,'comment'=>$admin_comment,'conversation_id '=>$conversation_id,'comment_date'=>$comment_date,'delete_status'=>'ACTIVE','created_at'=>$created_at); // print_r($data); // die(); $table = 'gss_comment'; $result = $this->db->insert($table,$data); } else { redirect('/'); } } public function get_follow_project_details() { $admin_id = session()->get('admin_id'); if($admin_id) { $table='gss_new_projects'; $data['project_names']=$this->gss_model->get_where_reults_project_name(); $id = $this->input->post('id'); $current_date = date('d-m-Y'); $data['details'] =$this->gss_model->get_followup_details($id,$current_date); $result = $data['details']; //$this->load->view('admin/follow_up_details',$data); if($result) { echo json_encode(array('result'=>1,'details'=>$result)); } else { echo json_encode(array('result'=>0)); } } else { redirect('/'); } } public function get_mul_reg_amount_sites_reports() { $i = $_GET['id']; $table = "gss_registration_amount_details"; $result = $this->gss_model->get_sites_reports($i); if($result) { echo json_encode($result); } else { echo json_encode(array('result'=>0)); } } public function get_mul_refunds() { $i = $_GET['id']; $table = "gss_cancellation_refunds"; $result = $this->gss_model->get_refund_reports($i); if($result) { echo json_encode($result); } else { echo json_encode(array('result'=>0)); } } /*public function send_mail() { $table='gss_po_generate'; $id = $this->input->post('id'); $where = array('id'=>$id); $result = $this->gss_model->get_mail($table,$where); $email=$result->email; $details = $this->gss_model->get_mails($table,$where); foreach($details as $det) { $po_no =$det['po_no']; } $data['details'] = $this->gss_model->get_mails($table,$where); $where1 = array('po_no'=>$det['po_no']); $data['fetch_details'] = $this->gss_model->fetch_where_subgrid_data1($table,$where1); $this->load->view('email/view_purchase_order_po.php',$data); $this->load->library('email'); $this->email->set_mailtype("html"); $body = $this->load->view('email/view_purchase_order_po.php',$data,TRUE); $this->email->from('info@jayblues.org','GSS'); // change it to yours $this->email->to($email,'GSS');// change it to yours $this->email->subject('Purchase Order From'); $this->email->message($body); $this->email->set_newline("\r\n"); $this->email->send(); }*/ public function send_mail() { $table='gss_po_generate'; $id = $this->input->post('id'); $where = array('id'=>$id); $result = $this->gss_model->get_mail($table,$where); $email=$result->email; $details = $this->gss_model->get_mails($table,$where); foreach($details as $det) { $po_no =$det['po_no']; } $data['details'] = $this->gss_model->get_mails($table,$where); $where1 = array('po_no'=>$det['po_no']); $data['fetch_details'] = $this->gss_model->fetch_where_subgrid_data1($table,$where1); /*$data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details();*/ $admin_id = session()->get('admin_id'); $login_table = 'gss_login'; $where_login = array('user_id'=>$admin_id); $get_sign = $this->gss_model->get_where_row($login_table,$where_login); $cc = $get_sign->email; $this->load->view('email/view_purchase_order_po.php',$data); $this->load->library('email'); $config = array( 'protocol' => 'smtp', 'smtp_host' => 'ssl://smtp.googlemail.com', 'smtp_port' => 465, 'smtp_user' => 'gssorganised@gmail.com', 'smtp_pass' => 'GSSKarthi@1236#', 'mailtype' => 'html', 'charset' => 'utf-8' ); $this->email->initialize($config); $this->email->set_mailtype("html"); $this->email->set_newline("\r\n"); // $this->email->set_mailtype("html"); $body = $this->load->view('email/view_purchase_order_po.php',$data,TRUE); $this->email->from('info@jayblues.org','GSS'); // change it to yours $this->email->to($email,'GSS');// change it to yours //$this->email->cc('sowmyashreelr@gmail.com'); $this->email->cc($cc); $this->email->subject('Purchase Order From'); $this->email->message($body); // $this->email->set_newline("\r\n"); $this->email->send(); } public function send_email() { $table='gss_wo_generate'; $id = $this->input->post('id'); $where = array('id'=>$id); $result = $this->gss_model->get_mail($table,$where); $email=$result->email; $details = $this->gss_model->get_emails($table,$where); foreach($details as $det) { $wo_no =$det['po_no']; } $data['details'] = $this->gss_model->get_emails($table,$where); $where1 = array('po_no'=>$det['po_no']); $data['fetch_details'] = $this->gss_model->fetch_where_subgrid_data1($table,$where1); $this->load->view('email/view_work_order_po.php',$data); $admin_id = session()->get('admin_id'); $login_table = 'gss_login'; $where_login = array('user_id'=>$admin_id); $get_sign = $this->gss_model->get_where_row($login_table,$where_login); $cc = $get_sign->email; $this->load->library('email'); $this->email->set_mailtype("html"); $body = $this->load->view('email/view_work_order_po.php',$data,TRUE); $this->email->from('info@jayblues.org','GSS'); // change it to yours $this->email->to($email,'GSS');// change it to yours //$this->email->cc('sowmyashreelr@gmail.com'); $this->email->cc($cc); $this->email->subject('Work Order Form'); $this->email->message($body); $this->email->set_newline("\r\n"); $this->email->send(); } public function get_follow_up_project() { $admin_id = session()->get('admin_id'); if($admin_id) { $project_id = $this->input->post('project_id'); $site_number = $this->input->post('site_number'); //$data['detail']=$this->gss_model->get_follow_up_project_details($project_id,$site_number); $result = $this->gss_model->get_follow_up_project_details($project_id,$site_number); if($result) { echo json_encode(array('result'=>1,'detail'=>$result)); } else { echo json_encode(array('result'=>0,'message'=>"Site Details Not Available")); } } else { redirect('/'); } } public function get_all_follow_up_reminder() { $admin_id = session()->get('admin_id'); if($admin_id) { $type=session()->get('user_type_id'); $result=""; if($type >1) { $data = $this->gss_model->get_follow_up_reminders($admin_id); foreach($data as $res) { $dmy = date('d-m-Y'); $date = $res->reminder; $newdate = strtotime ( '-2 day' , strtotime ($date) ) ; $newdate = date ( 'd-m-Y' , $newdate ); $d = array(); if($newdate == $dmy) { array_push($d, $res->reminder); } else { } foreach($d as $det) { $table = 'gss_follow_ups'; $admin_id = session()->get('admin_id'); $type=session()->get('user_type_id'); if($type >1) { $where = array('reminder'=>$det); $data['details'] = $this->gss_model->get_follow_up_reminder_notifications($where); $result = $data['details']; foreach($result as $res) { $notification_status = $res->notification_status; } $where1 = array('reminder'=>$det,'notification_status'=>0); $table = 'gss_follow_ups' ; $notification_data = array('notification_status'=>1); $this->gss_model->update($where1,$table,$notification_data); } } } $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $this->load->view('admin/reminder_details',$data); } else { $data = $this->gss_model->get_follow_up_admin_reminders($admin_id); foreach($data as $res) { $current_date = date('d-m-Y'); $admin_reminder_date = $res->admin_reminder_date; $newdate = strtotime ( '-2 day' , strtotime ($admin_reminder_date) ) ; $newdate = date ( 'd-m-Y' , $newdate ); $admin_date = array(); if($newdate == $current_date) { array_push($admin_date, $res->admin_reminder_date); } else { } foreach($admin_date as $adm_det) { $table = 'gss_comment'; $admin_id = session()->get('admin_id'); $type=session()->get('user_type_id'); $where = array('admin_reminder_date'=>$adm_det); $data['details'] = $this->gss_model->get_follow_up_admin_reminder_notifications($where); $details = $data['details']; foreach($details as $dets) { $notification_status = $dets->admin_notification_status; } $where1 = array('admin_reminder_date'=>$adm_det,'admin_notification_status'=>0); $notific_data = array('admin_notification_status'=>1); $this->gss_model->update($where1,$table,$notific_data); } } $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $this->load->view('admin/admin_reminder_details',$data); } } else { redirect('/'); } } public function get_all_follow_up_comment() { $admin_id = session()->get('admin_id'); if($admin_id) { $type=session()->get('user_type_id'); if($type >1) { $admin_id = session()->get('admin_id'); $current_date = date('d-m-Y'); $data = $this->gss_model->get_follow_up_comments($current_date,$admin_id); $data['details'] = $this->gss_model->get_follow_up_comment_notifiocation($current_date,$admin_id); $result = $data['details']; foreach($result as $res) { $notification_status = $res->notification_status; } $where1 = array('comment_date'=>$current_date,'notification_status'=>0); // print_r($where1); // die(); $table = 'gss_comment' ; $notification_data = array('notification_status'=>1); $this->gss_model->update($where1,$table,$notification_data); $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $this->load->view('admin/comment_details',$data); } else { $current_date = date('d-m-Y'); $data['details'] = $this->gss_model->get_followup_replies($current_date); $result = $data['details']; foreach($result as $res) { $notification_status = $res->notification_status; } $where_rep_data = array('reply_date'=>$current_date,'notification_status'=>0); $data['followup_details'] = $this->gss_model->get_all_follow_up_details($current_date); $reply_table = 'gss_reply'; $notification_reply_data = array('notification_status'=>1); $this->gss_model->update($where_rep_data,$reply_table,$notification_reply_data); $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $this->load->view('admin/reply_details',$data); } } else { redirect('/'); } } public function reply() { $admin_id = session()->get('admin_id'); if($admin_id) { $detail_id = $this->input->post('detail_id'); $project = $this->input->post('project_id'); $site_number = $this->input->post('site_number'); $handled_by = $this->input->post('handled_by'); $comment_id = $this->input->post('comment_id'); $conversation_id = $this->input->post('conversation_id'); $reply = $this->input->post('reply'); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $reply_date = $date->format('d-m-Y'); $created_at = date('Y-m-d H:i:s'); $table = 'gss_reply'; $data=array('detail_id'=>$detail_id,'project_id'=>$project,'site_number'=>$site_number,'user_id'=>$admin_id,'comment_id'=>$comment_id,'conversation_id'=>$conversation_id,'user_reply'=>$reply,'reply_date'=>$reply_date,'created_at'=>$created_at ); $a=$this->gss_model->insert($table,$data); } else { redirect('/'); } } public function add_admin_reminder() { $admin_id = session()->get('admin_id'); if($admin_id) { $detail_id = $this->input->post('reminder_id'); $admin_reminder_date = $this->input->post('rem_date'); $where=array('id'=>$detail_id); $table = 'gss_comment'; $data=array('admin_reminder_date'=>$admin_reminder_date); $a=$this->gss_model->update($where,$table,$data); } else { redirect('/'); } } /*public function add_conversation() { $admin_id = session()->get('admin_id'); $type=session()->get('user_type_id'); if($admin_id) { $detail_id = $this->input->post('reminder_id'); $call_convo = $this->input->post('call_convo'); $where=$detail_id; $details=$this->gss_model->get_follow_call_details($where); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $created_at = $date->format('Y-m-d H:i:s'); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $updated_at = $date->format('d-m-Y'); $conver_id = $this->input->post('conver_id'); $table = 'gss_follow_ups'; $data = array( 'user_id'=>$admin_id, 'detail_id'=>$details->detail_id, 'project_id'=>$details->project_id, 'site_number'=>$details->site_number, 'conversation'=>$call_convo, 'conversation_status'=>'ONGOING', // 'conversation_id'=>$conver_id, 'delete_status'=>'ACTIVE', 'created_at'=>$created_at ); $a = $this->gss_model->insert($table,$data); $where_detail_id = $a; $res = $this->gss_model->get_return_result($a); foreach($res as $r) { $id_detail = $r->detail_id; } $booking_table = 'gss_booking_details'; $update_where=array('detail_id'=>$id_detail); $update_data = array( 'updated_at'=>$updated_at ); $this->gss_model->update($update_where,$booking_table,$update_data); // $convo_id =$a; echo json_encode($a); } else { redirect('/'); } }*/ public function get_all_comments() { $admin_id = session()->get('admin_id'); if($admin_id) { $type=session()->get('user_type_id'); $result=""; $comment=""; $reply=""; $reminder=""; if($type >1) { $admin_id = session()->get('admin_id'); $current_date = date('d-m-Y'); $comment = $this->gss_model->get_follow_up_comments($current_date,$admin_id); $total_comment_notifications = $this->gss_model->get_total_follow_up_commments($current_date,$admin_id); $data['comment']=$comment; $total_comments = $total_comment_notifications; if($comment) { echo json_encode(array('result'=>1,'total_comments'=>$total_comment_notifications,'comment'=>$comment)); } else { echo json_encode(array('result'=>0)); } } else { $admin_id = session()->get('admin_id'); $current_date = date('d-m-Y'); $reply = $this->gss_model->get_follow_up_user_replies($current_date); $total_reply_notifications = $this->gss_model->get_total_follow_up_replies($current_date); $total_replies = $total_reply_notifications; if($reply) { echo json_encode(array('result'=>1,'total_replies'=>$total_reply_notifications,'reply'=>$reply)); } else { echo json_encode(array('result'=>0)); } } } else { redirect('/'); } } public function get_total_reminder_comment() { $total_comment_notifications = ''; $admin_id = session()->get('admin_id'); $total_admin_reminder_notifications = 0; $type=session()->get('user_type_id'); $result = ""; $comment = ""; $reply = ""; $admin_reminders = ""; if($type >1) { $data = $this->gss_model->get_follow_up_reminders($admin_id); foreach($data as $res) { $dmy = date('d-m-Y'); $date = $res->reminder; if($date != "") { $newdate = strtotime ( '-2 day' , strtotime ($date) ) ; $newdate = date ( 'd-m-Y' , $newdate ); $d = array(); if($newdate == $dmy) { array_push($d, $res->reminder); } else { } foreach($d as $det) { $table = 'gss_follow_ups'; $admin_id = session()->get('admin_id'); $where = array('reminder'=>$det,'user_id'=>$admin_id,'notification_status'=>0); $result = $this->gss_model->get_follow_up_reminderss($where); $total_user_reminder_notifications = $this->gss_model->get_total_follow_up_reminder_notif($where); $current_date = date('d-m-Y'); $comment = $this->gss_model->get_follow_up_comments($current_date,$admin_id); $total_comment_notifications = $this->gss_model->get_total_follow_up_comment_notif($current_date); } } else { $total_user_reminder_notifications = 0; $current_date = date('d-m-Y'); $comment = $this->gss_model->get_follow_up_comments($current_date,$admin_id); $total_comment_notifications = $this->gss_model->get_total_follow_up_comment_notif($current_date); } } $data['reminder'] = $result; $user_reminder_notifications = $total_user_reminder_notifications; $data['comment'] = $comment; $user_comment_notifications = $total_comment_notifications; $total_user_notifications = $user_reminder_notifications + $user_comment_notifications; if($total_user_notifications) { echo json_encode(array('result'=>1,'user_total'=>$total_user_notifications,'reminder'=>$result,'comment'=>$comment)); } else { echo json_encode(array('result'=>0)); } } else { $total_admin_reminder_notifications = 0; $total_reply_notifications = 0; $admin_id = session()->get('admin_id'); $data = $this->gss_model->get_follow_up_admin_reminders($admin_id); foreach($data as $res) { $current_date = date('d-m-Y'); $admin_reminder_date = $res->admin_reminder_date; if($admin_reminder_date != "") { $newdate = strtotime ( '-2 day' , strtotime ($admin_reminder_date) ) ; $newdate = date ( 'd-m-Y' , $newdate ); $admin_date = array(); if($newdate == $current_date) { array_push($admin_date, $res->admin_reminder_date); } else { } foreach($admin_date as $adm_det) { $table = 'gss_comment'; $admin_id = session()->get('admin_id'); $where = array('admin_reminder_date'=>$adm_det,'user_id'=>$admin_id); $admin_reminders = $this->gss_model->get_admin_reminders($where); $total_admin_reminder_notifications = $this->gss_model->get_total_follow_up_admin_reminder_notif($where); $reply = $this->gss_model->get_follow_up_user_replies($current_date); $total_reply_notifications = $this->gss_model->get_total_follow_up_reply_notif($current_date); } } else { $total_admin_reminder_notifications = 0; $current_date = date('d-m-Y'); $reply = $this->gss_model->get_follow_up_user_replies($current_date); $total_reply_notifications = $this->gss_model->get_total_follow_up_reply_notif($current_date); } } $data['admin_reminder'] = $admin_reminders; $admin_reminder_notifications = $total_admin_reminder_notifications; $data['user_reply'] = $reply; $user_reply_notifications = $total_reply_notifications; $total_admin_notifications = $admin_reminder_notifications + $user_reply_notifications; if($total_admin_notifications) { echo json_encode(array('result'=>1,'admin_total'=>$total_admin_notifications,'admin_reminder'=>$admin_reminders,'user_reply'=>$reply)); } else { echo json_encode(array('result'=>0)); } } } public function get_admin_follow_project_details() { $admin_id = session()->get('admin_id'); if($admin_id) { $table='gss_new_projects'; $data['project_names']=$this->gss_model->get_where_reults_project_name(); $id = $this->input->post('id'); $site_number = $this->input->post('site_number'); $current_date = date('d-m-Y'); $data['details'] =$this->gss_model->get_admin_followup_details($id,$site_number,$current_date); $result = $data['details']; if($result) { echo json_encode(array('result'=>1,'details'=>$result)); } else { echo json_encode(array('result'=>0)); } } else { redirect('/'); } } public function get_follow_up_project_datewise() { $admin_id = session()->get('admin_id'); if($admin_id) { $from_date = $this->input->post('from_date'); $to_date = $this->input->post('to_date'); //$data['detail']=$this->gss_model->get_follow_up_project_details($project_id,$site_number); $result = $this->gss_model->get_follow_up_project_dates($from_date,$to_date); if($result) { echo json_encode(array('result'=>1,'detail'=>$result)); } else { echo json_encode(array('result'=>0,'message'=>"Site Details Not Available")); } } else { redirect('/'); } } public function delete_installation() { $payment_table = 'gss_plot_payments'; $payment_type_table = 'gss_plot_payment_types'; $payment_id = $this->input->post('payment_id'); $where_booking = array('payment_id'=>$payment_id,'install_delete_status'=>'ACTIVE'); $type_result = $this->gss_model->get_where_row($payment_table,$where_booking); if($type_result->installment_amount1 != "") { $installment = $type_result->installment_amount1; $where_type = array('payment_id'=>$payment_id); //$where_booking = array('booking_id'=>$booking_id); $delete_status = array('install_delete_status'=>'INACTIVE'); $result = $this->gss_model->update($where_type,$payment_table,$delete_status); // $this->gss_model->update($where_type,$payment_table,$delete_status); if($this->db->affected_rows() > 0) { echo json_encode(array('result'=>1,'message'=>'Deleted successfully')); } else { echo json_encode(array('result'=>0)); } } else { } } public function check_project_status() { $project_id = $this->input->post('project_id'); $site_number = $this->input->post('site_number'); $check_site = $this->gss_model->project_details($site_number,$project_id); if($check_site) { $site_result = $this->gss_model->payment_site_booking_details1($site_number,$project_id); if(!empty($site_result)) { if($site_result->booking_status == 'BOOKED') { echo json_encode(array('result'=>0,'dimension'=>$site_result->total_in_sqft,'message'=>'Site number '.$site_number.' has been already BOOKED')); } else if($site_result->booking_status == 'ENQUIRED') { echo json_encode(array('result'=>0,'dimension'=>$site_result->total_in_sqft,'message'=>'Site number '.$site_number.' has been already ENQUIRED')); } } else { $check_site_result = $this->gss_model->payment_site_booking_details2($site_number,$project_id); if($check_site_result) { echo json_encode(array('result'=>1,'dimension'=>$check_site_result->total_in_sqft)); } else { } } } else { } } public function get_po_no_date() { $table = 'gss_po_generate'; $where = array('delete_status'=>'ACTIVE'); $result = $this->gss_model->get_where_result($table,$where); $array = array(); foreach($result as $res) { $in_date = $res->date; $i_date = date("Y-m-d", strtotime($in_date)); array_push($array, $i_date); } if($result) { echo json_encode(array('result'=>1,'details'=>$array)); } else { echo json_encode(array('result'=>0,'message'=>'No Details found')); } } public function get_wo_no_date() { $table = 'gss_wo_generate'; $where = array('delete_status'=>'ACTIVE'); $result = $this->gss_model->get_where_result($table,$where); $array = array(); foreach($result as $res) { $in_date = $res->date; $i_date = date("Y-m-d", strtotime($in_date)); array_push($array, $i_date); } if($result) { echo json_encode(array('result'=>1,'details'=>$array)); } else { echo json_encode(array('result'=>0,'message'=>'No Details found')); } } //---------------------CIVIL---------------------// public function civil_vendor_details() { $admin_id = session()->get('admin_id'); if($admin_id) { $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $this->load->view('admin/add_civil_vendor',$data); } else { redirect('/'); } } //add civil_vendors public function add_civil_vendor_details() { $table = 'gss_civil_vendor_details'; $vendor_name = $this->input->post('vendor_name'); $company_name = $this->input->post('company_name'); $contact1 = $this->input->post('contact1'); $contact2 = $this->input->post('contact2'); $email = $this->input->post('email'); $company_address = $this->input->post('company_address'); $gstin = $this->input->post('gstin'); $bank_name = $this->input->post('bank_name'); $acc_no = $this->input->post('acc_no'); $ifsc = $this->input->post('ifsc'); $bank_address = $this->input->post('bank_address'); $myFile = $_FILES['file_upload']; $cpt = count($_FILES['file_upload']['name']); $file_doc=""; for($i=0; $i<$cpt; $i++) { $error = $myFile["error"][$i]; if ($error == '4') { $file_new=""; } else { if($_FILES['file_upload']['name']) { $path=$_FILES['file_upload']['name'][$i]; $target='civil_vendor_details_uploads/'; $target.=time().$_FILES['file_upload']['name'][$i]; $document[]=time().$_FILES['file_upload']['name'][$i]; move_uploaded_file($_FILES['file_upload']['tmp_name'][$i],$target); $file_doc=json_encode($document); } else { $file_doc=""; } } } $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $created_at = $date->format('Y-m-d H:i:s'); $data = array('vendor_name'=>$vendor_name,'company_name'=>$company_name,'mobile'=>$contact1,'mobile2'=>$contact2,'email'=>$email,'company_address'=>$company_address,'gstin'=>$gstin,'bank_name'=>$bank_name,'account_no'=>$acc_no,'ifsc_code'=>$ifsc,'bank_address'=>$bank_address,'upload_files'=>$file_doc,'modified_at'=> $created_at,'created_at'=> $created_at,'delete_status'=>'ACTIVE'); $condition=array('vendor_name'=>$vendor_name,'company_name'=>$company_name,'mobile'=>$contact1,'mobile2'=>$contact2,'email'=>$email,'company_address'=>$company_address,'gstin'=>$gstin,'bank_name'=>$bank_name,'account_no'=>$acc_no,'ifsc_code'=>$ifsc,'bank_address'=>$bank_address,); $get_det=$this->gss_model->get_where_row($table,$condition); if(empty($get_det)){ $result = $this->gss_model->insert($table,$data); echo json_encode(array('result'=>1,'message'=>'Added successfully')); } else { echo json_encode(array('result'=>0,'message'=>'Data Already Exist')); } } //civil_vendor_list public function civil_vendor_list() { $table = 'gss_civil_vendor_details'; $where = array('delete_status'=>'ACTIVE'); $order_by='id'; $result = $this->gss_model->get_where_result_orderby($table,$where,$order_by); if($result) { echo json_encode($result); } else { echo json_encode(array('result'=>0)); } } public function update_civil_vendor_details() { $table = 'gss_civil_vendor_details'; $id=$this->input->post('edit_id'); $vendor_name = $this->input->post('vendor_name_update'); $company_name = $this->input->post('company_name_update'); $contact1 = $this->input->post('contact1_update'); $contact2 = $this->input->post('contact2_update'); $email = $this->input->post('email_update'); $company_address = $this->input->post('company_address_update'); $gstin = $this->input->post('gstin_update'); $bank_name = $this->input->post('bank_name_update'); $acc_no = $this->input->post('acc_no_update'); $ifsc = $this->input->post('ifsc_update'); $bank_address = $this->input->post('bank_address_update'); $condition=array('id'=>$id); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $created_at = $date->format('Y-m-d H:i:s'); $data = array('vendor_name'=>$vendor_name,'company_name'=>$company_name,'mobile'=>$contact1,'mobile2'=>$contact2,'email'=>$email,'company_address'=>$company_address,'gstin'=>$gstin,'bank_name'=>$bank_name,'account_no'=>$acc_no,'ifsc_code'=>$ifsc,'bank_address'=>$bank_address,'modified_at'=> $created_at,'delete_status'=>'ACTIVE'); $myFile = $_FILES['file_upload_update']; $cpt = count($_FILES['file_upload_update']['name']); for($i=0; $i<$cpt; $i++) { $error = $myFile["error"][$i]; if ($error == '4') { $file_new=""; } else { if($_FILES['file_upload_update']['name']) { $path=$_FILES['file_upload_update']['name'][$i]; $target='civil_vendor_details_uploads/'; $target.=time().$_FILES['file_upload_update']['name'][$i]; $document[]=time().$_FILES['file_upload_update']['name'][$i]; move_uploaded_file($_FILES['file_upload_update']['tmp_name'][$i],$target); $file_doc=json_encode($document); $data['upload_files']=$file_doc; } else { } } } $result = $this->gss_model->update($condition,$table,$data); if($result) { echo json_encode(array('result'=>1,'message'=>'Added Updated')); } else { echo json_encode(array('result'=>0)); } } public function get_civil_vendor_details() { $table = 'gss_civil_vendor_details'; $id=$this->input->post('id'); $where = array('id'=>$id); $result = $this->gss_model->get_where_row($table,$where); if($result) { echo json_encode(array('result'=>1,'message'=>$result)); } else { echo json_encode(array('result'=>0,'message'=>'data not found')); } } public function delete_civil_vendor_details() { $table = 'gss_civil_vendor_details'; $id = $this->input->post('id'); $where = array('id'=>$id); $data = array('delete_status'=>'INACTIVE'); $result = $this->gss_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 civil_bank_details() { $admin_id = session()->get('admin_id'); if($admin_id) { $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $this->load->view('admin/add_civil_bank_details',$data); } else { redirect('/'); } } public function civil_bank_list() { $table = 'gss_civil_bank_details'; $where = array('delete_status'=>'ACTIVE'); $order_by='id'; $result = $this->gss_model->get_where_result_orderby($table,$where,$order_by); if($result) { echo json_encode($result); } else { echo json_encode(array('result'=>0)); } } public function add_civil_bank_details() { $table = 'gss_civil_bank_details'; $acc_name_holder = $this->input->post('acc_name_holder'); $acc_holder = $this->input->post('acc_holder'); $acc_holder_address = $this->input->post('acc_holder_address'); $acc_no = $this->input->post('acc_no'); $pan_no = $this->input->post('pan_no'); $gst_no = $this->input->post('gst_no'); $ifsc = $this->input->post('ifsc'); $branch_name = $this->input->post('branch_name'); $address = $this->input->post('address'); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $created_at = $date->format('Y-m-d H:i:s'); $data = array('holder_name'=>$acc_holder,'holder_address'=>$acc_holder_address,'bank_name'=>$acc_name_holder,'acc_no'=>$acc_no,'pan_no'=>$pan_no,'gst_no'=>$gst_no,'ifsc'=>$ifsc,'bank_branch'=>$branch_name,'bank_address'=>$address,'modified_at'=> $created_at,'created_at'=> $created_at,'delete_status'=>'ACTIVE'); $condition=array('bank_name'=>$acc_name_holder,'acc_no'=>$acc_no,'delete_status'=>'ACTIVE'); $get_det=$this->gss_model->get_where_row($table,$condition); //print_r($get_det); //die(); if(empty($get_det)){ $result = $this->gss_model->insert($table,$data); echo json_encode(array('result'=>1,'message'=>'Added successfully')); } else { echo json_encode(array('result'=>0,'message'=>'Data Already Exist')); } } public function get_civil_bank_details() { $table = 'gss_civil_bank_details'; $id=$this->input->post('id'); $where = array('id'=>$id); $result = $this->gss_model->get_where_row($table,$where); if($result) { echo json_encode(array('result'=>1,'message'=>$result)); } else { echo json_encode(array('result'=>0,'message'=>'data not found')); } } public function update_civil_bank_details() { $table = 'gss_civil_bank_details'; $id = $this->input->post('edit_id'); $where = array('id'=>$id); $acc_name_holder = $this->input->post('acc_name_holder_update'); $acc_holder = $this->input->post('acc_holder_update'); $acc_holder_address= $this->input->post('acc_holder_address_update'); $acc_no = $this->input->post('acc_no_update'); $pan_no = $this->input->post('pan_no_update'); $gst_no = $this->input->post('gst_no_update'); $ifsc = $this->input->post('ifsc_update'); $branch_name = $this->input->post('branch_name_update'); $address = $this->input->post('address_update'); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $created_at = $date->format('Y-m-d H:i:s'); $data = array('holder_name'=>$acc_holder,'holder_address'=>$acc_holder_address,'bank_name'=>$acc_name_holder,'acc_no'=>$acc_no,'pan_no'=>$pan_no,'gst_no'=>$gst_no,'ifsc'=>$ifsc,'bank_branch'=>$branch_name,'bank_address'=>$address,'modified_at'=> $created_at,'delete_status'=>'ACTIVE'); $result = $this->gss_model->update($where,$table,$data); if($this->db->affected_rows() > 0) { echo json_encode(array('result'=>1,'message'=>'Updated successfully')); } else { echo json_encode(array('result'=>0)); } } public function delete_civil_bank_details() { $table = 'gss_civil_bank_details'; $id = $this->input->post('id'); $where = array('id'=>$id); $data = array('delete_status'=>'INACTIVE'); $result = $this->gss_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 civil_product_details() { $admin_id = session()->get('admin_id'); if($admin_id) { $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $this->load->view('admin/add_civil_product_details',$data); } else { redirect('/'); } } public function civil_product_list() { $table = 'gss_civil_product_details'; $where = array('delete_status'=>'ACTIVE'); $order_by='id'; $result = $this->gss_model->get_where_result_orderby($table,$where,$order_by); if($result) { echo json_encode($result); } else { echo json_encode(array('result'=>0)); } } public function add_civil_product_details() { $table = 'gss_civil_product_details'; $pro_name = $this->input->post('pro_name'); $pro_description = $this->input->post('pro_description'); $pro_dept = $this->input->post('pro_dept'); $pro_currency = $this->input->post('pro_currency'); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $created_at = $date->format('Y-m-d H:i:s'); $data = array('product_name'=>$pro_name,'description'=>$pro_description,'department'=>$pro_dept,'currency'=>$pro_currency,'modified_at'=> $created_at,'created_at'=> $created_at,'delete_status'=>'ACTIVE'); $condition=array('product_name'=>$pro_name,'description'=>$pro_description,'department'=>$pro_dept,); $get_det=$this->gss_model->get_where_row($table,$condition); if(empty($get_det)){ $result = $this->gss_model->insert($table,$data); echo json_encode(array('result'=>1,'message'=>'Added successfully')); } else { echo json_encode(array('result'=>0,'message'=>'Data Already Exist')); } } public function get_civil_product_details() { $table = 'gss_civil_product_details'; $id=$this->input->post('id'); $where = array('id'=>$id); $result = $this->gss_model->get_where_row($table,$where); if($result) { echo json_encode(array('result'=>1,'message'=>$result)); } else { echo json_encode(array('result'=>0,'message'=>'data not found')); } } public function update_civil_product_details() { $table = 'gss_civil_product_details'; $id = $this->input->post('edit_id'); $pro_name = $this->input->post('pro_name'); $pro_description = $this->input->post('pro_description'); $pro_dept = $this->input->post('pro_dept'); $pro_currency = $this->input->post('pro_currency'); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $created_at = $date->format('Y-m-d H:i:s'); $data = array('product_name'=>$pro_name,'description'=>$pro_description,'department'=>$pro_dept,'currency'=>$pro_currency,'modified_at'=> $created_at,'created_at'=> $created_at,'delete_status'=>'ACTIVE'); $where=array('id'=>$id); $result = $this->gss_model->update($where,$table,$data); if($this->db->affected_rows() > 0) { echo json_encode(array('result'=>1,'message'=>'Updated successfully')); } else { echo json_encode(array('result'=>0)); } } public function delete_civil_product_details() { $table = 'gss_civil_product_details'; $id = $this->input->post('id'); $where = array('id'=>$id); $data = array('delete_status'=>'INACTIVE'); $result = $this->gss_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 civil_service_details() { $admin_id = session()->get('admin_id'); if($admin_id) { $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $this->load->view('admin/add_civil_services',$data); } else { redirect('/'); } } public function civil_service_list() { $table = 'gss_civil_service_details'; $where = array('delete_status'=>'ACTIVE'); $order_by='id'; $result = $this->gss_model->get_where_result_orderby($table,$where,$order_by); if($result) { echo json_encode($result); } else { echo json_encode(array('result'=>0)); } } public function add_civil_service_details() { $table = 'gss_civil_service_details'; $pro_name = $this->input->post('pro_name'); $pro_description = $this->input->post('pro_description'); $pro_dept = $this->input->post('pro_dept'); $pro_currency = $this->input->post('pro_currency'); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $created_at = $date->format('Y-m-d H:i:s'); $data = array('product_name'=>$pro_name,'description'=>$pro_description,'department'=>$pro_dept,'currency'=>$pro_currency,'modified_at'=> $created_at,'created_at'=> $created_at,'delete_status'=>'ACTIVE'); $condition=array('product_name'=>$pro_name,'description'=>$pro_description,'department'=>$pro_dept,); $get_det=$this->gss_model->get_where_row($table,$condition); if(empty($get_det)){ $result = $this->gss_model->insert($table,$data); echo json_encode(array('result'=>1,'message'=>'Added successfully')); } else { echo json_encode(array('result'=>0,'message'=>'Data Already Exist')); } } public function get_civil_service_details() { $table = 'gss_civil_service_details'; $id=$this->input->post('id'); //print_r($id); $where = array('id'=>$id); $result = $this->gss_model->get_where_row($table,$where); if($result) { echo json_encode(array('result'=>1,'message'=>$result)); } else { echo json_encode(array('result'=>0,'message'=>'data not found')); } } public function update_civil_service_details() { $table = 'gss_civil_service_details'; $id = $this->input->post('edit_id'); $pro_name = $this->input->post('pro_name'); $pro_description = $this->input->post('pro_description'); $pro_dept = $this->input->post('pro_dept'); $pro_currency = $this->input->post('pro_currency'); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $created_at = $date->format('Y-m-d H:i:s'); $data = array('product_name'=>$pro_name,'description'=>$pro_description,'department'=>$pro_dept,'currency'=>$pro_currency,'modified_at'=> $created_at,'created_at'=> $created_at,'delete_status'=>'ACTIVE'); $where=array('id'=>$id); $result = $this->gss_model->update($where,$table,$data); if($this->db->affected_rows() > 0) { echo json_encode(array('result'=>1,'message'=>'Updated successfully')); } else { echo json_encode(array('result'=>0)); } } public function delete_civil_service_details() { $table = 'gss_civil_service_details'; $id = $this->input->post('id'); $where = array('id'=>$id); $data = array('delete_status'=>'INACTIVE'); $result = $this->gss_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 civil_project_master() { $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $this->load->view('admin/add_civil_projects',$data); } public function civil_project_list() { $table = 'gss_civil_project_master'; $where = array('delete_status'=>'ACTIVE'); $order_by='id'; $result = $this->gss_model->get_where_result_orderby($table,$where,$order_by); if($result) { echo json_encode($result); } else { echo json_encode(array('result'=>0)); } } public function add_civil_project_details() { $table = 'gss_civil_project_master'; $pro_name = $this->input->post('pro_name'); $pro_description = $this->input->post('pro_description'); $nick_name = $this->input->post('pro_nick_name'); $data = array('project_name'=>$pro_name,'description'=>$pro_description,'nick_name'=>$nick_name,'delete_status'=>'ACTIVE'); $condition=array('project_name'=>$pro_name,'description'=>$pro_description,'delete_status'=>'ACTIVE'); $get_det=$this->gss_model->get_where_row($table,$condition); if(empty($get_det)){ $result = $this->gss_model->insert($table,$data); echo json_encode(array('result'=>1,'message'=>'Added successfully')); } else { echo json_encode(array('result'=>0,'message'=>'Data Already Exist')); } } public function get_civil_project_details() { $table = 'gss_civil_project_master'; $id=$this->input->post('id'); $where = array('id'=>$id); $result = $this->gss_model->get_where_row($table,$where); if($result) { echo json_encode(array('result'=>1,'message'=>$result)); } else { echo json_encode(array('result'=>0,'message'=>'data not found')); } } public function update_civil_project_details() { $table = 'gss_civil_project_master'; $id = $this->input->post('edit_id'); $pro_name = $this->input->post('pro_name'); $pro_description = $this->input->post('pro_description'); $nick_name = $this->input->post('pro_nick_name'); $data = array('project_name'=>$pro_name,'description'=>$pro_description,'nick_name'=>$nick_name,'delete_status'=>'ACTIVE'); $where=array('id'=>$id); $result = $this->gss_model->update($where,$table,$data); if($this->db->affected_rows() > 0) { echo json_encode(array('result'=>1,'message'=>'Updated successfully')); } else { echo json_encode(array('result'=>0)); } } public function delete_civil_project_details() { $table = 'gss_civil_project_master'; $id = $this->input->post('id'); $where = array('id'=>$id); $data = array('delete_status'=>'INACTIVE'); $result = $this->gss_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 auto_complete_civil_vendor_name() { $keyword=$_GET['term']; $data1=$this->gss_model->get_civil_vendors($keyword); foreach($data1 as $row) { $data[]=$row->vendor_name; } echo json_encode($data); } public function civil_vendor_search_by_fetch() { $vendor_name=$this->input->post('id'); $table='gss_civil_vendor_details'; $condition=array('delete_status'=>'ACTIVE'); if($vendor_name != "") { $result=$this->gss_model->get_whererow($table,$condition,$vendor_name); if($result) { echo json_encode(array('result'=>1,'message'=>$result)); } else { echo json_encode(array('result'=>0,'message'=>'No Details found')); } } } public function civil_purchase_order_form() { $admin_id = session()->get('admin_id'); if($admin_id) { $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $this->load->view('admin/civil_purchase_order_form',$data); } else { redirect('/'); } } /* public function civil_purchase_order_generate_po() { $admin_id = session()->get('admin_id'); if($admin_id) { $ids=$_GET['id']; $explode_id=explode(",",$ids); $array_ids=array(); foreach($explode_id as $eids) { array_push($array_ids,$eids); } $data['product_list']=$this->gss_model->get_civil_products_list($array_ids); $land_table = 'gss_civil_project_master'; $data['owners'] = $this->gss_model->get_where_result1111($land_table); $data['wo_no']= $this->gss_model->get_civil_purchase_order(); $this->load->view('admin/civil_purchase_order_generate_po',$data); } else { redirect('/'); } }*/ public function civil_purchase_order_generate_po() { $admin_id = session()->get('admin_id'); if($admin_id) { $ids=$_GET['id']; $explode_id=explode(",",$ids); $array_ids=array(); foreach($explode_id as $eids) { array_push($array_ids,$eids); } $data['product_list']=$this->gss_model->get_civil_products_list($array_ids); $land_table = 'gss_civil_project_master'; $data['owners'] = $this->gss_model->get_where_result1111($land_table); $data['wo_no']= $this->gss_model->get_civil_purchase_order(); $mtable_table = 'gss_from_master_table'; $data['mfrom_address'] = $this->gss_model->get_where_result1111($mtable_table); $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $this->load->view('admin/civil_purchase_order_generate_po',$data); } else { redirect('/'); } } /* public function get_civil_po() { $admin_id = session()->get('admin_id'); if($admin_id) { $year = $this->input->post('input_year'); $table = 'gss_civil_po'; $where = array('delete_status'=>'ACTIVE','year'=>$year); $result = $this->gss_model->get_where_max($table,$where); if($result) { echo json_encode(array('result'=>1,'message'=>$result)); } else { echo json_encode(array('result'=>0)); } } else { redirect('/'); } }*/ public function get_civil_po() { $admin_id = session()->get('admin_id'); if($admin_id) { $year = $this->input->post('input_year'); $mid = $this->input->post('mid'); $table = 'gss_civil_po'; $where = array('mid'=>$mid,'delete_status'=>'ACTIVE','year'=>$year); $result['count_no'] = $this->gss_model->get_where_count($table,$where); if($result) { echo json_encode(array('result'=>1,'message'=>$result)); } else { echo json_encode(array('result'=>0)); } } else { redirect('/'); } } /* public function insert_civil_purchase_order() { $bank_details = $this->input->post('bank_details'); $vendor_name = $this->input->post('vendor_name'); $g_date = $this->input->post('g_date'); $exp = explode('-',$g_date); $in_year = $exp[2]; $po_no = $this->input->post('po_no'); $exp_po = explode('00000',$po_no); $po = $exp_po[1]; $currency = $this->input->post('currency'); $address = $this->input->post('address'); $contact_person = $this->input->post('contact_person'); $contact_number = $this->input->post('contact_number'); $email = $this->input->post('email'); $product_id = $this->input->post('product_id'); $p_name = $this->input->post('p_name'); $remarks = $this->input->post('remarks'); $i_no = $this->input->post('i_no'); $cgst = $this->input->post('cgst'); $sgst = $this->input->post('sgst'); $project_name = $this->input->post('project_name'); $purpose = $this->input->post('purpose'); $quantityy = $this->input->post('quantityy'); $igst = $this->input->post('igst'); $unit = $this->input->post('unit'); $inrvalue = $this->input->post('inrvalue'); $totalvalue = $this->input->post('totalvalue'); $ot_charges = $this->input->post('ot_charges'); $quantity_val = $this->input->post('quantity_val'); $unit1 = $this->input->post('unit1'); $inr_value_val = $this->input->post('inr_value_val'); $ot_sgst = $this->input->post('ot_sgst'); $ot_cgst = $this->input->post('ot_cgst'); $ot_igst = $this->input->post('ot_igst'); $otc_remarks = $this->input->post('otc_remarks'); $total_value_val = $this->input->post('total_value_val'); $note = $this->input->post('note'); $total_amt = $this->input->post('total_amt'); $discount = $this->input->post('discount'); $g_total = $this->input->post('g_total'); $d = ($total_amt * $discount)/100; $val = $total_amt - $d; $grand_total = round($val); $comment = $this->input->post('comment'); $gst_no = $this->input->post('gst_no'); $terms_payment = $this->input->post('terms_payment'); $bank_details = $this->input->post('bank_details'); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $created_at = $date->format('Y-m-d'); $table='gss_civil_po'; $condition=array('delete_status'=>'ACTIVE','po_no'=>$po,'year'=>$in_year); $order_by = 'id'; $get_po_no=$this->gss_model->get_where_orderby($table,$condition,$order_by); if($get_po_no) { $get_year = $get_po_no->date; $get_po = $get_po_no->po_no; $year = date("Y", strtotime($get_year)); if($year == $in_year && $po == $get_po) { echo json_encode(array('result'=>0,'message'=>'This PO number already exist')); } else { foreach($product_id as $key=>$ids) { $data=array( 'po_no' =>$po, 'vendor'=>$vendor_name, 'project_name'=>$project_name, 'date'=>$g_date, 'year'=>$in_year, 'currency'=>$currency, 'vendor_address'=>$address, 'contact_person'=>$contact_person, 'contact_number' =>$contact_number, 'email' =>$email, 'product_id' =>$ids, 'product_name' =>$p_name[$key], 'remarks' =>$remarks[$key], 'indent' =>$i_no[$key], 'purpose_no'=>$purpose[$key], 'quentity'=>$quantityy[$key], 'unit_price'=>$unit[$key], 'inr_value'=>$inrvalue[$key], 'sgst'=>$sgst[$key], 'cgst'=>$cgst[$key], 'igst'=>$igst[$key], 'total_value'=>$totalvalue[$key], 'total_amt'=>$total_amt, 'discount'=>$discount, 'grand_total'=>$grand_total, 'delete_status'=>'ACTIVE', 'material_delivery'=>$comment, 'bank_details'=>$bank_details, 'terms_of_payment'=>$terms_payment, 'gst_no'=>$gst_no, 'ot_charges'=>$ot_charges, 'ot_unit'=>$unit1, 'ot_quantity'=>$quantity_val, 'ot_inr_value'=>$inr_value_val, 'ot_sgst'=>$ot_sgst, 'ot_cgst'=>$ot_cgst, 'ot_discount'=>$discount, 'ot_igst'=>$ot_igst, 'ot_total_value'=>$total_value_val, 'otc_remarks'=>$otc_remarks, 'created_at'=>$created_at, 'modified_at'=>$created_at, 'note'=>$note, 'cancel_status'=>'CANCEL' ); $result=$this->gss_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')); } } } else { foreach($product_id as $key=>$ids) { $data=array( 'po_no' =>$po, 'vendor'=>$vendor_name, 'project_name'=>$project_name, 'date'=>$g_date, 'year'=>$in_year, 'currency'=>$currency, 'vendor_address'=>$address, 'contact_person'=>$contact_person, 'contact_number' =>$contact_number, 'email' =>$email, 'product_id' =>$ids, 'product_name' =>$p_name[$key], 'remarks' =>$remarks[$key], 'indent' =>$i_no[$key], 'purpose_no'=>$purpose[$key], 'quentity'=>$quantityy[$key], 'unit_price'=>$unit[$key], 'inr_value'=>$inrvalue[$key], 'sgst'=>$sgst[$key], 'cgst'=>$cgst[$key], 'igst'=>$igst[$key], 'total_value'=>$totalvalue[$key], 'total_amt'=>$total_amt, 'discount'=>$discount, 'grand_total'=>$grand_total, 'delete_status'=>'ACTIVE', 'material_delivery'=>$comment, 'bank_details'=>$bank_details, 'terms_of_payment'=>$terms_payment, 'gst_no'=>$gst_no, 'ot_charges'=>$ot_charges, 'ot_unit'=>$unit1, 'ot_quantity'=>$quantity_val, 'ot_inr_value'=>$inr_value_val, 'ot_sgst'=>$ot_sgst, 'ot_cgst'=>$ot_cgst, 'ot_discount'=>$discount, 'ot_igst'=>$ot_igst, 'ot_total_value'=>$total_value_val, 'otc_remarks'=>$otc_remarks, 'created_at'=>$created_at, 'modified_at'=>$created_at, 'note'=>$note, 'cancel_status'=>'CANCEL' ); $result=$this->gss_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')); } } }*/ public function insert_civil_purchase_order() { $mid = $this->input->post('mid'); $vendor_name = $this->input->post('vendor_name'); $g_date = $this->input->post('g_date'); $exp = explode('-',$g_date); $in_year = $exp[2]; $po_no = $this->input->post('po_no'); $exp_po = explode('00000',$po_no); $po = $exp_po[1]; $currency = $this->input->post('currency'); $address = $this->input->post('address'); $contact_person = $this->input->post('contact_person'); $contact_number = $this->input->post('contact_number'); $email = $this->input->post('email'); $product_id = $this->input->post('product_id'); $p_name = $this->input->post('p_name'); $remarks = $this->input->post('remarks'); $i_no = $this->input->post('i_no'); $cgst = $this->input->post('cgst'); $sgst = $this->input->post('sgst'); $project_name = $this->input->post('project_name'); $purpose = $this->input->post('purpose'); $quantityy = $this->input->post('quantityy'); $igst = $this->input->post('igst'); $unit = $this->input->post('unit'); $inrvalue = $this->input->post('inrvalue'); $totalvalue = $this->input->post('totalvalue'); $ot_charges = $this->input->post('ot_charges'); $quantity_val = $this->input->post('quantity_val'); $unit1 = $this->input->post('unit1'); $inr_value_val = $this->input->post('inr_value_val'); $ot_sgst = $this->input->post('ot_sgst'); $ot_cgst = $this->input->post('ot_cgst'); $ot_igst = $this->input->post('ot_igst'); $otc_remarks = $this->input->post('otc_remarks'); $total_value_val = $this->input->post('total_value_val'); $note = $this->input->post('note'); $total_amt = $this->input->post('total_amt'); $discount = $this->input->post('discount'); $g_total = $this->input->post('g_total'); $d = ($total_amt * $discount)/100; $val = $total_amt - $d; $grand_total = round($val); $comment = $this->input->post('comment'); $gst_no = $this->input->post('gst_no'); $terms_payment = $this->input->post('terms_payment'); $bank_details = $this->input->post('bank_details'); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $created_at = $date->format('Y-m-d'); $table='gss_civil_po'; $condition=array('mid'=>$mid,'delete_status'=>'ACTIVE','po_no'=>$po,'year'=>$in_year); $order_by = 'id'; $get_po_no=$this->gss_model->get_where_orderby($table,$condition,$order_by); if($get_po_no) { $get_year = $get_po_no->date; $get_po = $get_po_no->po_no; $year = date("Y", strtotime($get_year)); if($year == $in_year && $po == $get_po) { echo json_encode(array('result'=>0,'message'=>'This PO number already exist')); } else { foreach($product_id as $key=>$ids) { $data=array( 'po_no' =>$po, 'vendor'=>$vendor_name, 'project_name'=>$project_name, 'date'=>$g_date, 'year'=>$in_year, 'currency'=>$currency, 'vendor_address'=>$address, 'contact_person'=>$contact_person, 'contact_number' =>$contact_number, 'email' =>$email, 'product_id' =>$ids, 'product_name' =>$p_name[$key], 'remarks' =>$remarks[$key], 'indent' =>$i_no[$key], 'purpose_no'=>$purpose[$key], 'quentity'=>$quantityy[$key], 'unit_price'=>$unit[$key], 'inr_value'=>$inrvalue[$key], 'sgst'=>$sgst[$key], 'cgst'=>$cgst[$key], 'igst'=>$igst[$key], 'total_value'=>$totalvalue[$key], 'total_amt'=>$total_amt, 'discount'=>$discount, 'grand_total'=>$grand_total, 'delete_status'=>'ACTIVE', 'material_delivery'=>$comment, 'bank_details'=>$bank_details, 'terms_of_payment'=>$terms_payment, 'gst_no'=>$gst_no, 'ot_charges'=>$ot_charges, 'ot_unit'=>$unit1, 'ot_quantity'=>$quantity_val, 'ot_inr_value'=>$inr_value_val, 'ot_sgst'=>$ot_sgst, 'ot_cgst'=>$ot_cgst, 'ot_discount'=>$discount, 'ot_igst'=>$ot_igst, 'ot_total_value'=>$total_value_val, 'otc_remarks'=>$otc_remarks, 'created_at'=>$created_at, 'modified_at'=>$created_at, 'note'=>$note, 'cancel_status'=>'CANCEL' ); $result=$this->gss_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')); } } } else { foreach($product_id as $key=>$ids) { $data=array( 'mid' => $mid, 'po_no' =>$po, 'vendor'=>$vendor_name, 'project_name'=>$project_name, 'date'=>$g_date, 'year'=>$in_year, 'currency'=>$currency, 'vendor_address'=>$address, 'contact_person'=>$contact_person, 'contact_number' =>$contact_number, 'email' =>$email, 'product_id' =>$ids, 'product_name' =>$p_name[$key], 'remarks' =>$remarks[$key], 'indent' =>$i_no[$key], 'purpose_no'=>$purpose[$key], 'quentity'=>$quantityy[$key], 'unit_price'=>$unit[$key], 'inr_value'=>$inrvalue[$key], 'sgst'=>$sgst[$key], 'cgst'=>$cgst[$key], 'igst'=>$igst[$key], 'total_value'=>$totalvalue[$key], 'total_amt'=>$total_amt, 'discount'=>$discount, 'grand_total'=>$grand_total, 'delete_status'=>'ACTIVE', 'material_delivery'=>$comment, 'bank_details'=>$bank_details, 'terms_of_payment'=>$terms_payment, 'gst_no'=>$gst_no, 'ot_charges'=>$ot_charges, 'ot_unit'=>$unit1, 'ot_quantity'=>$quantity_val, 'ot_inr_value'=>$inr_value_val, 'ot_sgst'=>$ot_sgst, 'ot_cgst'=>$ot_cgst, 'ot_discount'=>$discount, 'ot_igst'=>$ot_igst, 'ot_total_value'=>$total_value_val, 'otc_remarks'=>$otc_remarks, 'created_at'=>$created_at, 'modified_at'=>$created_at, 'note'=>$note, 'cancel_status'=>'CANCEL' ); $result=$this->gss_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')); } } } /* public function civil_purchase_order_subgrid() { $i=$_GET['id']; $table='gss_civil_po'; $where = array('id'=>$i); $getalldatas = $this->gss_model->get_where_row($table,$where); $po=$getalldatas->po_no; $year=$getalldatas->year; $vendor=$getalldatas->vendor; $where1 = array('po_no'=>$po,'year'=>$year); $getalldata = $this->gss_model->fetch_where_subgrid_data1($table,$where1); echo json_encode($getalldata); }*/ public function civil_purchase_order_subgrid() { $i=$_GET['id']; $table='gss_civil_po'; $where = array('id'=>$i); $getalldatas = $this->gss_model->get_where_row($table,$where); $po=$getalldatas->po_no; $year=$getalldatas->year; $vendor=$getalldatas->vendor; $mid=$getalldatas->mid; $where1 = array('mid'=>$mid,'po_no'=>$po,'year'=>$year); $getalldata = $this->gss_model->fetch_where_subgrid_data1($table,$where1); echo json_encode($getalldata); } /* public function edit_civil_purchase_order() { $admin_id = session()->get('admin_id'); if($admin_id) { $ids=$_GET['id']; $where=array('id'=>$ids); $table='gss_civil_po'; $data['po_details']=$this->gss_model->get_where_row($table,$where); $where1 = array('po_no'=>$data['po_details']->po_no,'year'=>$data['po_details']->year); $data['fetch_details'] = $this->gss_model->fetch_where_subgrid_data1($table,$where1); $data['key']=1; $land_table = 'gss_civil_project_master'; $where = array('nick_name'=>$data['po_details']->project_name); $data['civil_project'] = $this->gss_model->get_where_row($land_table,$where); $land_table = 'gss_civil_project_master'; $data['owners'] = $this->gss_model->get_where_result1111($land_table); $this->load->view('admin/edit_civil_purchase_order',$data); } else { redirect('/'); } }*/ public function edit_civil_purchase_order() { $admin_id = session()->get('admin_id'); if($admin_id) { $ids=$_GET['id']; $where=array('id'=>$ids); $table='gss_civil_po'; $data['po_details']=$this->gss_model->get_where_row($table,$where); $where1 = array('vendor'=>$data['po_details']->vendor,'mid'=>$data['po_details']->mid,'po_no'=>$data['po_details']->po_no,'year'=>$data['po_details']->year); $data['fetch_details'] = $this->gss_model->fetch_where_subgrid_data1($table,$where1); $data['key']=1; $land_table = 'gss_civil_project_master'; $where = array('nick_name'=>$data['po_details']->project_name); $data['civil_project'] = $this->gss_model->get_where_row($land_table,$where); $land_table = 'gss_civil_project_master'; $data['owners'] = $this->gss_model->get_where_result1111($land_table); $table1='gss_from_master_table'; $where2 = array('mid'=>$data['po_details']->mid); $data['master_data']=$this->gss_model->get_where_row($table1,$where2); $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $this->load->view('admin/edit_civil_purchase_order',$data); } else { redirect('/'); } } public function update_civil_purchase_order() { $id=$this->input->post('edit_id'); $bank_details = $this->input->post('bank_details'); $vendor_name = $this->input->post('vendor_name'); $g_date = $this->input->post('g_date'); $exp = explode('-',$g_date); $in_year = $exp[2]; $po_no = $this->input->post('po_no'); $exp_po = explode('0000',$po_no); $po = $exp_po[1]; $currency = $this->input->post('currency'); $address = $this->input->post('address'); $contact_person = $this->input->post('contact_person'); $contact_number = $this->input->post('contact_number'); $email = $this->input->post('email'); $product_id = $this->input->post('product_id'); $p_name = $this->input->post('p_name'); $i_no = $this->input->post('i_no'); $cgst = $this->input->post('cgst'); $sgst = $this->input->post('sgst'); $project_name = $this->input->post('project_name'); $purpose = $this->input->post('purpose'); $quantityy = $this->input->post('quantityy'); $igst = $this->input->post('igst'); $unit = $this->input->post('unit'); $inrvalue = $this->input->post('inrvalue'); $totalvalue = $this->input->post('totalvalue'); $ot_charges = $this->input->post('ot_charges'); $quantity_val = $this->input->post('quantity_val'); $unit1 = $this->input->post('unit1'); $inr_value_val = $this->input->post('inr_value_val'); $ot_sgst = $this->input->post('ot_sgst'); $ot_cgst = $this->input->post('ot_cgst'); $ot_igst = $this->input->post('ot_igst'); $total_value_val = $this->input->post('total_value_val'); $otc_remarks = $this->input->post('otc_remarks'); $remarks = $this->input->post('remarks'); $note = $this->input->post('note'); $total_amt = $this->input->post('total_amt'); $discount = $this->input->post('discount'); $g_total = $this->input->post('g_total'); $d = ($total_amt * $discount)/100; $val = $total_amt - $d; $grand_total = round($val); $comment = $this->input->post('comment'); $gst_no = $this->input->post('gst_no'); $terms_payment = $this->input->post('terms_payment'); $bank_details = $this->input->post('bank_details'); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $created_at = $date->format('Y-m-d'); $table='gss_civil_po'; foreach($product_id as $key=>$ids) { $data=array( 'id'=>$id[$key], 'po_no' =>$po, 'vendor'=>$vendor_name, 'date'=>$g_date, 'year'=>$in_year, 'currency'=>$currency, 'vendor_address'=>$address, 'contact_person'=>$contact_person, 'contact_number' =>$contact_number, 'email' =>$email, 'product_id' =>$ids, 'product_name' =>$p_name[$key], 'indent' =>$i_no[$key], 'project_name'=>$project_name, 'purpose_no'=>$purpose[$key], 'quentity'=>$quantityy[$key], 'unit_price'=>$unit[$key], 'inr_value'=>$inrvalue[$key], 'sgst'=>$sgst[$key], 'cgst'=>$cgst[$key], 'igst'=>$igst[$key], 'total_value'=>$totalvalue[$key], 'total_amt'=>$total_amt, 'discount'=>$discount, 'grand_total'=>$grand_total, 'delete_status'=>'ACTIVE', 'material_delivery'=>$comment, 'bank_details'=>$bank_details, 'terms_of_payment'=>$terms_payment, 'gst_no'=>$gst_no, 'ot_charges'=>$ot_charges, 'ot_unit'=>$unit1, 'ot_quantity'=>$quantity_val, 'ot_inr_value'=>$inr_value_val, 'ot_sgst'=>$ot_sgst, 'ot_cgst'=>$ot_cgst, 'ot_igst'=>$ot_igst, 'ot_total_value'=>$total_value_val, 'modified_at'=>$created_at, 'note'=>$note, 'remarks' =>$remarks[$key], 'otc_remarks' =>$otc_remarks, ); $condition=array('id'=>$id[$key],); $result=$this->gss_model->update($condition,$table,$data); } if($result) { echo json_encode(array('result'=>1,'message'=>'Updated successfully')); } else { echo json_encode(array('result'=>0,'message'=>'Not Added')); } } public function cancel_civil_purchase_order() { $table = 'gss_civil_po'; $management_id = $this->input->post('management_id'); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $updated_at = $date->format('Y-m-d H:i:s'); $data = array( //'agreement_status' => 'APPROVED', 'cancel_status' => 'CANCELLED' //'updated_at' => $updated_at ); $where_id = array('id'=>$management_id); $result = $this->gss_model->update($where_id,$table,$data); if($this->db->affected_rows() > 0) { echo json_encode(array('result'=>1,'message'=>"Cancelled successfully")); } else { echo json_encode(array('result'=>0,'message'=>"Failed to cancel. Try again")); } } public function cancelled_civil_purchase_order() { $table = 'gss_civil_po'; $management_id = $this->input->post('management_id'); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $updated_at = $date->format('Y-m-d H:i:s'); $data = array( 'cancel_status' => 'CANCEL' ); $where_id = array('id'=>$management_id); $result = $this->gss_model->update($where_id,$table,$data); if($this->db->affected_rows() > 0) { echo json_encode(array('result'=>1,'message'=>"Cancelled is Removed")); } else { echo json_encode(array('result'=>0,'message'=>"Fail. Try again")); } } /* public function view_civil_purchase_order() { $admin_id = session()->get('admin_id'); if($admin_id) { $ids=$_GET['id']; $condition=array('id'=>$ids); $table='gss_civil_po'; $data['fetch_address']=$this->gss_model->get_where_row($table,$condition); $where1 = array('po_no'=>$data['fetch_address']->po_no,'year'=>$data['fetch_address']->year); $data['fetch_details'] = $this->gss_model->fetch_where_subgrid_data1($table,$where1); $data['key']=1; $land_table = 'gss_civil_project_master'; $where = array('project_name'=>$data['fetch_address']->project_name); $data['civil_project'] = $this->gss_model->get_where_row($land_table,$where); $this->load->view('admin/view_civil_purchase_order',$data); } else { redirect('/'); } }*/ public function view_civil_purchase_order() { $admin_id = session()->get('admin_id'); if($admin_id) { $ids=$_GET['id']; $condition=array('id'=>$ids); $table='gss_civil_po'; $data['fetch_address']=$this->gss_model->get_where_row($table,$condition); $where1 = array('vendor'=>$data['fetch_address']->vendor,'mid'=>$data['fetch_address']->mid,'po_no'=>$data['fetch_address']->po_no,'year'=>$data['fetch_address']->year); $data['fetch_details'] = $this->gss_model->fetch_where_subgrid_data1($table,$where1); $data['key']=1; $land_table = 'gss_civil_project_master'; $where = array('project_name'=>$data['fetch_address']->project_name); $data['civil_project'] = $this->gss_model->get_where_row($land_table,$where); $data['po_bill_details'] = $this->gss_model->po_bill_details($ids); $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $this->load->view('admin/view_civil_purchase_order',$data); } else { redirect('/'); } } public function civil_po_send_mail() { $table='gss_civil_po'; $id = $this->input->post('id'); $where = array('id'=>$id); $result = $this->gss_model->get_mail($table,$where); $email=$result->email; $details = $this->gss_model->civil_po_send_mail($table,$where); foreach($details as $det) { $po_no =$det['po_no']; } $data['details'] = $this->gss_model->civil_po_send_mail($table,$where); $where1 = array('po_no'=>$det['po_no']); $data['fetch_details'] = $this->gss_model->fetch_where_subgrid_data1($table,$where1); $this->load->view('email/view_civil_purchase_order.php',$data); $admin_id = session()->get('admin_id'); $login_table = 'gss_login'; $where_login = array('user_id'=>$admin_id); $get_sign = $this->gss_model->get_where_row($login_table,$where_login); $cc = $get_sign->email; $this->load->library('email'); $config = array( 'protocol' => 'smtp', 'smtp_host' => 'ssl://smtp.googlemail.com', 'smtp_port' => 465, 'smtp_user' => 'gssorganised@gmail.com', 'smtp_pass' => 'GSSKarthi@1236#', 'mailtype' => 'html', 'charset' => 'utf-8' ); $this->email->initialize($config); $this->email->set_mailtype("html"); $this->email->set_newline("\r\n"); // $this->email->set_mailtype("html"); $body = $this->load->view('email/view_civil_purchase_order.php',$data,TRUE); $this->email->from('info@jayblues.org','GSS'); // change it to yours $this->email->to($email,'GSS');// change it to yours //$this->email->cc('sowmyashreelr@gmail.com'); $this->email->cc($cc); $this->email->subject('Civil Purchase Order From'); $this->email->message($body); // $this->email->set_newline("\r\n"); $this->email->send(); } public function civil_work_order_form() { $admin_id = session()->get('admin_id'); if($admin_id) { $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $this->load->view('admin/civil_work_order_form',$data); } else { redirect('/'); } } /*public function civil_work_order_generate_wo() { $admin_id = session()->get('admin_id'); if($admin_id) { $ids=$_GET['id']; $explode_id=explode(",",$ids); $array_ids=array(); foreach($explode_id as $eids) { array_push($array_ids,$eids); } $data['product_list']=$this->gss_model->get_civil_service_list($array_ids); $land_table = 'gss_civil_project_master'; $data['owners'] = $this->gss_model->get_where_result1111($land_table); $data['wo_no']= $this->gss_model->get_civil_work_order(); $this->load->view('admin/civil_work_order_generate_wo',$data); } else { redirect('/'); } }*/ public function civil_work_order_generate_wo() { $admin_id = session()->get('admin_id'); if($admin_id) { $ids=$_GET['id']; $explode_id=explode(",",$ids); $array_ids=array(); foreach($explode_id as $eids) { array_push($array_ids,$eids); } $data['product_list']=$this->gss_model->get_civil_service_list($array_ids); $land_table = 'gss_civil_project_master'; $data['owners'] = $this->gss_model->get_where_result1111($land_table); $data['wo_no']= $this->gss_model->get_civil_work_order(); $mtable_table = 'gss_from_master_table'; $data['mfrom_address'] = $this->gss_model->get_where_result1111($mtable_table); $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $this->load->view('admin/civil_work_order_generate_wo',$data); } else { redirect('/'); } } public function civil_work_order_list() { $admin_id = session()->get('admin_id'); if($admin_id) { $land_table = 'gss_civil_project_master'; $data['project'] = $this->gss_model->get_where_result1111($land_table); $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $this->load->view('admin/civil_work_order_list',$data); } else { redirect('/'); } } /*public function insert_civil_work_order() { $bank_details = $this->input->post('bank_details'); $vendor_name = $this->input->post('vendor_name'); $g_date = $this->input->post('g_date'); $exp = explode('-',$g_date); $in_year = $exp[2]; $wo_no = $this->input->post('po_no'); $exp_wo = explode('00000',$wo_no); $wo = $exp_wo[1]; $currency = $this->input->post('currency'); $address = $this->input->post('address'); $contact_person = $this->input->post('contact_person'); $contact_number = $this->input->post('contact_number'); $email = $this->input->post('email'); $product_id = $this->input->post('product_id'); $p_name = $this->input->post('p_name'); $remarks = $this->input->post('remarks'); $i_no = $this->input->post('i_no'); $cgst = $this->input->post('cgst'); $sgst = $this->input->post('sgst'); $project_name = $this->input->post('project_name'); $purpose = $this->input->post('purpose'); //$quantityy = $this->input->post('quantityy'); $igst = $this->input->post('igst'); //$unit = $this->input->post('unit'); $inrvalue = $this->input->post('inrvalue'); $totalvalue = $this->input->post('totalvalue'); $ot_charges = $this->input->post('ot_charges'); // $quantity_val = $this->input->post('quantity_val'); // $unit1 = $this->input->post('unit1'); $inr_value_val = $this->input->post('inr_value_val'); $ot_sgst = $this->input->post('ot_sgst'); $ot_cgst = $this->input->post('ot_cgst'); $ot_igst = $this->input->post('ot_igst'); $otc_remarks = $this->input->post('otc_remarks'); $tds = $this->input->post('tds'); $total_value_val = $this->input->post('total_value_val'); $note = $this->input->post('note'); $total_amt = $this->input->post('total_amt'); $discount = $this->input->post('discount'); $g_total = $this->input->post('g_total'); $d = ($total_amt * $discount)/100; $val = $total_amt - $d; $tds_val = ($total_amt * $tds)/100; $grand_total = round($val - $tds_val); $comment = $this->input->post('comment'); $gst_no = $this->input->post('gst_no'); $terms_payment = $this->input->post('terms_payment'); $bank_details = $this->input->post('bank_details'); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $created_at = $date->format('Y-m-d'); $table='gss_civil_wo'; $where=array('delete_status'=>'ACTIVE','year'=>$in_year,'po_no'=>$wo); $order_by = 'id'; $get_po_no=$this->gss_model->get_where_orderby($table,$where,$order_by); if($get_po_no) { $get_year = $get_po_no->date; $get_po = $get_po_no->po_no; $year = date("Y", strtotime($get_year)); if($year == $in_year && $wo == $get_po) { echo json_encode(array('result'=>0,'message'=>'This WO number already exist')); } else { foreach($product_id as $key=>$ids) { $data=array( 'po_no' =>$wo, 'vendor'=>$vendor_name, 'project_name'=>$project_name, 'date'=>$g_date, 'year'=>$in_year, 'currency'=>$currency, 'vendor_address'=>$address, 'contact_person'=>$contact_person, 'contact_number' =>$contact_number, 'email' =>$email, 'product_id' =>$ids, 'product_name' =>$p_name[$key], 'remarks' =>$remarks[$key], 'indent' =>$i_no[$key], 'purpose_no'=>$purpose[$key], // 'quentity'=>$quantityy[$key], // 'unit_price'=>$unit[$key], 'inr_value'=>$inrvalue[$key], 'sgst'=>$sgst[$key], 'cgst'=>$cgst[$key], 'igst'=>$igst[$key], 'total_value'=>$totalvalue[$key], 'total_amt'=>$total_amt, 'discount'=>$discount, 'grand_total'=>$g_total, 'delete_status'=>'ACTIVE', 'material_delivery'=>$comment, 'bank_details'=>$bank_details, 'terms_of_payment'=>$terms_payment, 'gst_no'=>$gst_no, 'ot_charges'=>$ot_charges, // 'ot_unit'=>$unit1, 'tds'=>$tds, 'ot_inr_value'=>$inr_value_val, 'ot_sgst'=>$ot_sgst, 'ot_cgst'=>$ot_cgst, 'ot_discount'=>$discount, 'ot_igst'=>$ot_igst, 'ot_total_value'=>$total_value_val, 'otc_remarks'=>$otc_remarks, 'created_at'=>$created_at, 'modified_at'=>$created_at, 'note'=>$note, 'cancel_status'=>'CANCEL' ); $result=$this->gss_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')); } } } else { foreach($product_id as $key=>$ids) { $data=array( 'po_no' =>$wo, 'vendor'=>$vendor_name, 'project_name'=>$project_name, 'date'=>$g_date, 'year'=>$in_year, 'currency'=>$currency, 'vendor_address'=>$address, 'contact_person'=>$contact_person, 'contact_number' =>$contact_number, 'email' =>$email, 'product_id' =>$ids, 'product_name' =>$p_name[$key], 'remarks' =>$remarks[$key], 'indent' =>$i_no[$key], 'purpose_no'=>$purpose[$key], // 'quentity'=>$quantityy[$key], // 'unit_price'=>$unit[$key], 'inr_value'=>$inrvalue[$key], 'sgst'=>$sgst[$key], 'cgst'=>$cgst[$key], 'igst'=>$igst[$key], 'total_value'=>$totalvalue[$key], 'total_amt'=>$total_amt, 'discount'=>$discount, 'grand_total'=>$g_total, 'delete_status'=>'ACTIVE', 'material_delivery'=>$comment, 'bank_details'=>$bank_details, 'terms_of_payment'=>$terms_payment, 'gst_no'=>$gst_no, 'ot_charges'=>$ot_charges, // 'ot_unit'=>$unit1, 'tds'=>$tds, 'ot_inr_value'=>$inr_value_val, 'ot_sgst'=>$ot_sgst, 'ot_cgst'=>$ot_cgst, 'ot_discount'=>$discount, 'ot_igst'=>$ot_igst, 'ot_total_value'=>$total_value_val, 'otc_remarks'=>$otc_remarks, 'created_at'=>$created_at, 'modified_at'=>$created_at, 'note'=>$note, 'cancel_status'=>'CANCEL' ); $result=$this->gss_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')); } } }*/ public function insert_civil_work_order() { $mid = $this->input->post('mid'); $vendor_name = $this->input->post('vendor_name'); $g_date = $this->input->post('g_date'); $exp = explode('-',$g_date); $in_year = $exp[2]; $wo_no = $this->input->post('po_no'); $exp_wo = explode('00000',$wo_no); $wo = $exp_wo[1]; $currency = $this->input->post('currency'); $address = $this->input->post('address'); $contact_person = $this->input->post('contact_person'); $contact_number = $this->input->post('contact_number'); $email = $this->input->post('email'); $product_id = $this->input->post('product_id'); $p_name = $this->input->post('p_name'); $remarks = $this->input->post('remarks'); $i_no = $this->input->post('i_no'); $cgst = $this->input->post('cgst'); $sgst = $this->input->post('sgst'); $project_name = $this->input->post('project_name'); $purpose = $this->input->post('purpose'); //$quantityy = $this->input->post('quantityy'); $igst = $this->input->post('igst'); //$unit = $this->input->post('unit'); $inrvalue = $this->input->post('inrvalue'); $totalvalue = $this->input->post('totalvalue'); $ot_charges = $this->input->post('ot_charges'); // $quantity_val = $this->input->post('quantity_val'); // $unit1 = $this->input->post('unit1'); $inr_value_val = $this->input->post('inr_value_val'); $ot_sgst = $this->input->post('ot_sgst'); $ot_cgst = $this->input->post('ot_cgst'); $ot_igst = $this->input->post('ot_igst'); $otc_remarks = $this->input->post('otc_remarks'); $tds = $this->input->post('tds'); $total_value_val = $this->input->post('total_value_val'); $note = $this->input->post('note'); $total_amt = $this->input->post('total_amt'); $discount = $this->input->post('discount'); $g_total = $this->input->post('g_total'); $d = ($total_amt * $discount)/100; $val = $total_amt - $d; $tds_val = ($total_amt * $tds)/100; $grand_total = round($val - $tds_val); $comment = $this->input->post('comment'); $gst_no = $this->input->post('gst_no'); $terms_payment = $this->input->post('terms_payment'); $bank_details = $this->input->post('bank_details'); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $created_at = $date->format('Y-m-d'); $table='gss_civil_wo'; $where=array('mid'=>$mid,'delete_status'=>'ACTIVE','year'=>$in_year,'po_no'=>$wo); $order_by = 'id'; $get_po_no=$this->gss_model->get_where_orderby($table,$where,$order_by); if($get_po_no) { $get_year = $get_po_no->date; $get_po = $get_po_no->po_no; $year = date("Y", strtotime($get_year)); if($year == $in_year && $wo == $get_po) { echo json_encode(array('result'=>0,'message'=>'This WO number already exist')); } else { foreach($product_id as $key=>$ids) { $data=array( 'mid' => $mid, 'po_no' =>$wo, 'vendor'=>$vendor_name, 'project_name'=>$project_name, 'date'=>$g_date, 'year'=>$in_year, 'currency'=>$currency, 'vendor_address'=>$address, 'contact_person'=>$contact_person, 'contact_number' =>$contact_number, 'email' =>$email, 'product_id' =>$ids, 'product_name' =>$p_name[$key], 'remarks' =>$remarks[$key], 'indent' =>$i_no[$key], 'purpose_no'=>$purpose[$key], // 'quentity'=>$quantityy[$key], // 'unit_price'=>$unit[$key], 'inr_value'=>$inrvalue[$key], 'sgst'=>$sgst[$key], 'cgst'=>$cgst[$key], 'igst'=>$igst[$key], 'total_value'=>$totalvalue[$key], 'total_amt'=>$total_amt, 'discount'=>$discount, 'grand_total'=>$g_total, 'delete_status'=>'ACTIVE', 'material_delivery'=>$comment, 'bank_details'=>$bank_details, 'terms_of_payment'=>$terms_payment, 'gst_no'=>$gst_no, 'ot_charges'=>$ot_charges, // 'ot_unit'=>$unit1, 'tds'=>$tds, 'ot_inr_value'=>$inr_value_val, 'ot_sgst'=>$ot_sgst, 'ot_cgst'=>$ot_cgst, 'ot_discount'=>$discount, 'ot_igst'=>$ot_igst, 'ot_total_value'=>$total_value_val, 'otc_remarks'=>$otc_remarks, 'created_at'=>$created_at, 'modified_at'=>$created_at, 'note'=>$note, 'cancel_status'=>'CANCEL' ); $result=$this->gss_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')); } } } else { foreach($product_id as $key=>$ids) { $data=array( 'mid' => $mid, 'po_no' =>$wo, 'vendor'=>$vendor_name, 'project_name'=>$project_name, 'date'=>$g_date, 'year'=>$in_year, 'currency'=>$currency, 'vendor_address'=>$address, 'contact_person'=>$contact_person, 'contact_number' =>$contact_number, 'email' =>$email, 'product_id' =>$ids, 'product_name' =>$p_name[$key], 'remarks' =>$remarks[$key], 'indent' =>$i_no[$key], 'purpose_no'=>$purpose[$key], // 'quentity'=>$quantityy[$key], // 'unit_price'=>$unit[$key], 'inr_value'=>$inrvalue[$key], 'sgst'=>$sgst[$key], 'cgst'=>$cgst[$key], 'igst'=>$igst[$key], 'total_value'=>$totalvalue[$key], 'total_amt'=>$total_amt, 'discount'=>$discount, 'grand_total'=>$g_total, 'delete_status'=>'ACTIVE', 'material_delivery'=>$comment, 'bank_details'=>$bank_details, 'terms_of_payment'=>$terms_payment, 'gst_no'=>$gst_no, 'ot_charges'=>$ot_charges, // 'ot_unit'=>$unit1, 'tds'=>$tds, 'ot_inr_value'=>$inr_value_val, 'ot_sgst'=>$ot_sgst, 'ot_cgst'=>$ot_cgst, 'ot_discount'=>$discount, 'ot_igst'=>$ot_igst, 'ot_total_value'=>$total_value_val, 'otc_remarks'=>$otc_remarks, 'created_at'=>$created_at, 'modified_at'=>$created_at, 'note'=>$note, 'cancel_status'=>'CANCEL' ); $result=$this->gss_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')); } } } /* public function civil_work_order_subgrid() { $i=$_GET['id']; $table='gss_civil_wo'; $where = array('id'=>$i); $getalldatas = $this->gss_model->get_where_row($table,$where); $po=$getalldatas->po_no; $year=$getalldatas->year; $where1 = array('po_no'=>$po,'year'=>$year); $getalldata = $this->gss_model->fetch_where_subgrid_data1($table,$where1); echo json_encode($getalldata); }*/ public function civil_work_order_subgrid() { $i=$_GET['id']; $table='gss_civil_wo'; $where = array('id'=>$i); $getalldatas = $this->gss_model->get_where_row($table,$where); $po=$getalldatas->po_no; $year=$getalldatas->year; $mid =$getalldatas->mid; $where1 = array('mid'=>$mid,'po_no'=>$po,'year'=>$year); $getalldata = $this->gss_model->fetch_where_subgrid_data1($table,$where1); echo json_encode($getalldata); } /* public function edit_civil_work_order() { $admin_id = session()->get('admin_id'); if($admin_id) { $ids=$_GET['id']; $where=array('id'=>$ids); $table='gss_civil_wo'; $data['po_details']=$this->gss_model->get_where_row($table,$where); $where1 = array('po_no'=>$data['po_details']->po_no,'year'=>$data['po_details']->year); $data['fetch_details'] = $this->gss_model->fetch_where_subgrid_data1($table,$where1); $data['key']=1; $land_table = 'gss_civil_project_master'; $where = array('nick_name'=>$data['po_details']->project_name); $data['civil_project'] = $this->gss_model->get_where_row($land_table,$where); $data['owners'] = $this->gss_model->get_where_result1111($land_table); $this->load->view('admin/edit_civil_work_order',$data); } else { redirect('/'); } }*/ public function edit_civil_work_order() { $admin_id = session()->get('admin_id'); if($admin_id) { $ids=$_GET['id']; $where=array('id'=>$ids); $table='gss_civil_wo'; $data['po_details']=$this->gss_model->get_where_row($table,$where); $where1 = array('vendor'=>$data['po_details']->vendor,'mid'=>$data['po_details']->mid,'po_no'=>$data['po_details']->po_no,'year'=>$data['po_details']->year); $data['fetch_details'] = $this->gss_model->fetch_where_subgrid_data1($table,$where1); $data['key']=1; $land_table = 'gss_civil_project_master'; $where = array('nick_name'=>$data['po_details']->project_name); $data['civil_project'] = $this->gss_model->get_where_row($land_table,$where); $data['owners'] = $this->gss_model->get_where_result1111($land_table); $table1='gss_from_master_table'; $where2 = array('mid'=>$data['po_details']->mid); $data['master_data']=$this->gss_model->get_where_row($table1,$where2); $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $this->load->view('admin/edit_civil_work_order',$data); } else { redirect('/'); } } public function update_civil_work_order() { $id=$this->input->post('edit_id'); $bank_details = $this->input->post('bank_details'); $vendor_name = $this->input->post('vendor_name'); $g_date = $this->input->post('g_date'); $exp = explode('-',$g_date); $in_year = $exp[2]; $po_no = $this->input->post('po_no'); $exp_wo = explode('0000',$po_no); $wo = $exp_wo[1]; $currency = $this->input->post('currency'); $address = $this->input->post('address'); $contact_person = $this->input->post('contact_person'); $contact_number = $this->input->post('contact_number'); $email = $this->input->post('email'); $product_id = $this->input->post('product_id'); $p_name = $this->input->post('p_name'); $i_no = $this->input->post('i_no'); $cgst = $this->input->post('cgst'); $sgst = $this->input->post('sgst'); $project_name = $this->input->post('project_name'); $purpose = $this->input->post('purpose'); // $quantityy = $this->input->post('quantityy'); $igst = $this->input->post('igst'); // $unit = $this->input->post('unit'); $tds = $this->input->post('tds'); $inrvalue = $this->input->post('inrvalue'); $totalvalue = $this->input->post('totalvalue'); $ot_charges = $this->input->post('ot_charges'); // $quantity_val = $this->input->post('quantity_val'); // $unit1 = $this->input->post('unit1'); $inr_value_val = $this->input->post('inr_value_val'); $ot_sgst = $this->input->post('ot_sgst'); $ot_cgst = $this->input->post('ot_cgst'); $ot_igst = $this->input->post('ot_igst'); $total_value_val = $this->input->post('total_value_val'); $otc_remarks = $this->input->post('otc_remarks'); $remarks = $this->input->post('remarks'); $note = $this->input->post('note'); $total_amt = $this->input->post('total_amt'); $discount = $this->input->post('discount'); $g_total = $this->input->post('g_total'); $d = ($total_amt * $discount)/100; $val = $total_amt - $d; $tds_val = ($total_amt * $tds)/100; $grand_total = round($val - $tds_val); $comment = $this->input->post('comment'); $gst_no = $this->input->post('gst_no'); $terms_payment = $this->input->post('terms_payment'); $bank_details = $this->input->post('bank_details'); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $created_at = $date->format('Y-m-d'); $table='gss_civil_wo'; foreach($product_id as $key=>$ids) { $data=array( 'id'=>$id[$key], 'po_no' =>$wo, 'vendor'=>$vendor_name, 'date'=>$g_date, 'year'=>$in_year, 'currency'=>$currency, 'vendor_address'=>$address, 'contact_person'=>$contact_person, 'contact_number' =>$contact_number, 'email' =>$email, 'product_id' =>$ids, 'product_name' =>$p_name[$key], 'indent' =>$i_no[$key], 'project_name'=>$project_name, 'purpose_no'=>$purpose[$key], // 'quentity'=>$quantityy[$key], // 'unit_price'=>$unit[$key], 'inr_value'=>$inrvalue[$key], 'sgst'=>$sgst[$key], 'cgst'=>$cgst[$key], 'igst'=>$igst[$key], 'total_value'=>$totalvalue[$key], 'total_amt'=>$total_amt, 'discount'=>$discount, 'grand_total'=>$g_total, 'delete_status'=>'ACTIVE', 'material_delivery'=>$comment, 'bank_details'=>$bank_details, 'terms_of_payment'=>$terms_payment, 'gst_no'=>$gst_no, 'ot_charges'=>$ot_charges, 'tds'=>$tds, // 'ot_unit'=>$unit1, // 'ot_quantity'=>$quantity_val, 'ot_inr_value'=>$inr_value_val, 'ot_sgst'=>$ot_sgst, 'ot_cgst'=>$ot_cgst, 'ot_igst'=>$ot_igst, 'ot_total_value'=>$total_value_val, 'modified_at'=>$created_at, 'note'=>$note, 'remarks' =>$remarks[$key], 'otc_remarks' =>$otc_remarks, ); $condition=array('id'=>$id[$key],); $result=$this->gss_model->update($condition,$table,$data); } if($result) { echo json_encode(array('result'=>1,'message'=>'Updated successfully')); } else { echo json_encode(array('result'=>0,'message'=>'Not Added')); } } public function cancel_civil_work_order() { $table = 'gss_civil_wo'; $management_id = $this->input->post('management_id'); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $updated_at = $date->format('Y-m-d H:i:s'); $data = array( //'agreement_status' => 'APPROVED', 'cancel_status' => 'CANCELLED' //'updated_at' => $updated_at ); $where_id = array('id'=>$management_id); $result = $this->gss_model->update($where_id,$table,$data); if($this->db->affected_rows() > 0) { echo json_encode(array('result'=>1,'message'=>"Cancelled successfully")); } else { echo json_encode(array('result'=>0,'message'=>"Failed to cancel. Try again")); } } public function cancelled_civil_work_order() { $table = 'gss_civil_wo'; $management_id = $this->input->post('management_id'); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $updated_at = $date->format('Y-m-d H:i:s'); $data = array( 'cancel_status' => 'CANCEL' ); $where_id = array('id'=>$management_id); $result = $this->gss_model->update($where_id,$table,$data); if($this->db->affected_rows() > 0) { echo json_encode(array('result'=>1,'message'=>"Cancelled is Removed")); } else { echo json_encode(array('result'=>0,'message'=>"Fail. Try again")); } } /* public function view_civil_work_order() { $admin_id = session()->get('admin_id'); if($admin_id) { $ids=$_GET['id']; $condition=array('id'=>$ids); $table='gss_civil_wo'; $data['fetch_address']=$this->gss_model->get_where_row($table,$condition); $where1 = array('po_no'=>$data['fetch_address']->po_no); $data['fetch_details'] = $this->gss_model->fetch_where_subgrid_data1($table,$where1); $data['key']=1; $land_table = 'gss_civil_project_master'; $where = array('project_name'=>$data['fetch_address']->project_name); $data['civil_project'] = $this->gss_model->get_where_row($land_table,$where); $this->load->view('admin/view_civil_work_order',$data); } else { redirect('/'); } }*/ public function view_civil_work_order() { $admin_id = session()->get('admin_id'); if($admin_id) { $ids=$_GET['id']; $condition=array('id'=>$ids); $table='gss_civil_wo'; $data['fetch_address']=$this->gss_model->get_where_row($table,$condition); $where1 = array('vendor'=>$data['fetch_address']->vendor,'mid'=>$data['fetch_address']->mid,'po_no'=>$data['fetch_address']->po_no); $data['fetch_details'] = $this->gss_model->fetch_where_subgrid_data1($table,$where1); $data['key']=1; $land_table = 'gss_civil_project_master'; $where = array('project_name'=>$data['fetch_address']->project_name); $data['civil_project'] = $this->gss_model->get_where_row($land_table,$where); $data['wo_bill_details'] = $this->gss_model->wo_bill_details($ids); $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $this->load->view('admin/view_civil_work_order',$data); } else { redirect('/'); } } public function civil_wo_send_mail() { $table='gss_civil_wo'; $id = $this->input->post('id'); $where = array('id'=>$id); $result = $this->gss_model->get_mail($table,$where); $email=$result->email; $details = $this->gss_model->civil_wo_send_mail($table,$where); foreach($details as $det) { $po_no =$det['po_no']; } $data['details'] = $this->gss_model->civil_wo_send_mail($table,$where); $where1 = array('po_no'=>$det['po_no']); $data['fetch_details'] = $this->gss_model->fetch_where_subgrid_data1($table,$where1); $this->load->view('email/view_civil_work_order.php',$data); $admin_id = session()->get('admin_id'); $login_table = 'gss_login'; $where_login = array('user_id'=>$admin_id); $get_sign = $this->gss_model->get_where_row($login_table,$where_login); $cc = $get_sign->email; $this->load->library('email'); $config = array( 'protocol' => 'smtp', 'smtp_host' => 'ssl://smtp.googlemail.com', 'smtp_port' => 465, 'smtp_user' => 'gssorganised@gmail.com', 'smtp_pass' => 'GSSKarthi@1236#', 'mailtype' => 'html', 'charset' => 'utf-8' ); $this->email->initialize($config); $this->email->set_mailtype("html"); $this->email->set_newline("\r\n"); // $this->email->set_mailtype("html"); $body = $this->load->view('email/view_civil_work_order.php',$data,TRUE); $this->email->from('info@jayblues.org','GSS'); // change it to yours $this->email->to($email,'GSS');// change it to yours //$this->email->cc('sowmyashreelr@gmail.com'); $this->email->cc($cc); $this->email->subject('Civil Work Order From'); $this->email->message($body); // $this->email->set_newline("\r\n"); $this->email->send(); } /* public function get_civil_wo() { $admin_id = session()->get('admin_id'); if($admin_id) { $year = $this->input->post('input_year'); $table = 'gss_civil_wo'; $where = array('delete_status'=>'ACTIVE','year'=>$year); $result = $this->gss_model->get_where_max($table,$where); if(empty($result)) { echo json_encode(array('result'=>0,'message'=>'00001')); } else { echo json_encode(array('result'=>1,'message'=>$result)); } } else { redirect('/'); } } */ public function get_civil_wo() { $admin_id = session()->get('admin_id'); if($admin_id) { $year = $this->input->post('input_year'); $mid = $this->input->post('mid'); $table = 'gss_civil_wo'; $where = array('mid'=>$mid,'delete_status'=>'ACTIVE','year'=>$year); $result['count_no'] = $this->gss_model->get_where_count($table,$where); if(empty($result)) { echo json_encode(array('result'=>0,'message'=>'00001')); } else { echo json_encode(array('result'=>1,'message'=>$result)); } } else { redirect('/'); } } //Single project po_no public function single_project_po_no() { $table = 'gss_civil_po'; $project = $this->input->post('project'); $where = array('project_name' => $project ,'delete_status' => 'ACTIVE'); $order_by = 'id'; $result = $this->gss_model->get_where_result_distinct($table,$where,$order_by); if($result) { echo json_encode(array('result'=>1,'po_no'=>$result)); } else { echo json_encode(array('result'=>0)); } } public function single_project_wo_no() { $table = 'gss_civil_wo'; $project = $this->input->post('project'); $where = array('project_name' => $project ,'delete_status' => 'ACTIVE'); $order_by = 'id'; $result = $this->gss_model->get_where_result_distinct($table,$where,$order_by); if($result) { echo json_encode(array('result'=>1,'wo_no'=>$result)); } else { echo json_encode(array('result'=>0)); } } public function get_civil_wo_reports() { $from_date = $_GET['from_date']; if($from_date != "") { $date = new DateTime($from_date); $from_date = $date->format('Y-m-d'); } $to_date =$_GET['to_date']; if($to_date != "") { $date = new DateTime($to_date); $to_date = $date->format('Y-m-d'); } $project = $_GET['project']; $wo_no = $_GET['wo_no']; $table = 'gss_civil_wo'; $result = $this->gss_model->get_where_distinct_civil($table,$from_date,$to_date,$project,$wo_no); echo json_encode($result); } public function get_civil_po_reports() { $from_date = $_GET['from_date']; if($from_date != "") { $date = new DateTime($from_date); $from_date = $date->format('Y-m-d'); } $to_date =$_GET['to_date']; if($to_date != "") { $date = new DateTime($to_date); $to_date = $date->format('Y-m-d'); } $project = $_GET['project']; $po_no = $_GET['po_no']; $table = 'gss_civil_po'; $result = $this->gss_model->get_where_distinct_civil($table,$from_date,$to_date,$project,$po_no); echo json_encode($result); } public function single_project_po() { $table = 'gss_po_generate'; $project = $this->input->post('project'); $where = array('project_name' => $project ,'delete_status' => 'ACTIVE'); $order_by = 'id'; $result = $this->gss_model->get_where_result_distinct($table,$where,$order_by); if($result) { echo json_encode(array('result'=>1,'po_no'=>$result)); } else { echo json_encode(array('result'=>0)); } } public function single_project_wo() { $table = 'gss_wo_generate'; $project = $this->input->post('project'); $where = array('project_name' => $project ,'delete_status' => 'ACTIVE'); $order_by = 'id'; $result = $this->gss_model->get_where_result_distinct($table,$where,$order_by); if($result) { echo json_encode(array('result'=>1,'wo_no'=>$result)); } else { echo json_encode(array('result'=>0)); } } public function civil_work_order_generated_list() { $from_date = $_GET['from']; if($from_date != "") { $date = new DateTime($from_date); $from_date = $date->format('d-m-Y'); } $to_date =$_GET['to']; if($to_date != "") { $date = new DateTime($to_date); $to_date = $date->format('d-m-Y'); } $result = $this->gss_model->get_civil_work_order_dates($from_date,$to_date); if($result) { echo json_encode($result); } else { echo json_encode(array('result'=>0)); } } public function civil_work_order_project_wise() { $from_date = $_GET['from']; if($from_date != "") { $date = new DateTime($from_date); $from_date = $date->format('d-m-Y'); } $to_date =$_GET['to']; if($to_date != "") { $date = new DateTime($to_date); $to_date = $date->format('d-m-Y'); } $project = $_GET['project']; $po_no = $_GET['wo_no']; $table = 'gss_civil_wo' ; if($project == 'all' && $from_date == "" && $to_date == "") { $table='gss_civil_wo'; $condition=array('delete_status'=>'ACTIVE'); $result = $this->gss_model->get_where_distinct_po($table,$condition); if($result) { echo json_encode($result); } else { echo json_encode(array('result'=>0)); } } else if($project != "" && $po_no =="all" && $from_date!= "" && $to_date!= "") { $result = $this->gss_model->get_civil_po_order($table,$from_date,$to_date,$project,$po_no); if($result) { echo json_encode($result); } else { echo json_encode(array('result'=>0)); } } else if($project == 'all' && $from_date!= "" && $to_date!= "") { $result = $this->gss_model->get_civil_work_order_dates($from_date,$to_date); if($result) { echo json_encode($result); } else { echo json_encode(array('result'=>0)); } } else if($po_no == "all") { $where = array('project_name'=>$project); $result = $this->gss_model->get_where_distinct_civil_po_wo($table,$where,$project,$po_no); if($result) { echo json_encode($result); } else { echo json_encode(array('result'=>0)); } } else if($project != "" && $po_no !="" && $from_date!= "" && $to_date!= "") { $result = $this->gss_model->get_civil_wo($from_date,$to_date,$project,$wo_no); if($result) { echo json_encode($result); } else { echo json_encode(array('result'=>0)); } } else { $condition=array('po_no'=>$po_no); $result = $this->gss_model->get_civil_work_order_project($project,$po_no); if($result) { echo json_encode($result); } else { echo json_encode(array('result'=>0)); } } } public function civil_purchase_order_generated_list() { $from_date = $_GET['from']; if($from_date != "") { $date = new DateTime($from_date); $from_date = $date->format('d-m-Y'); } $to_date =$_GET['to']; if($to_date != "") { $date = new DateTime($to_date); $to_date = $date->format('d-m-Y'); } $result = $this->gss_model->get_civil_purchase_order_dates($from_date,$to_date); if($result) { echo json_encode($result); } else { echo json_encode(array('result'=>0)); } } public function civil_purchase_order_project_wise() { $from_date = $_GET['from']; if($from_date != "") { $date = new DateTime($from_date); $from_date = $date->format('d-m-Y'); } $to_date =$_GET['to']; if($to_date != "") { $date = new DateTime($to_date); $to_date = $date->format('d-m-Y'); } $project = $_GET['project']; $po_no = $_GET['po_no']; $table = 'gss_civil_po' ; if($project == 'all' && $from_date == "" && $to_date == "") { $table='gss_civil_po'; $condition=array('delete_status'=>'ACTIVE'); $result = $this->gss_model->get_where_distinct_po($table,$condition); if($result) { echo json_encode($result); } else { echo json_encode(array('result'=>0)); } } else if($project != "" && $po_no =="all" && $from_date!= "" && $to_date!= "") { $result = $this->gss_model->get_civil_po_order($table,$from_date,$to_date,$project,$po_no); if($result) { echo json_encode($result); } else { echo json_encode(array('result'=>0)); } } else if($po_no == "all") { $where = array('project_name'=>$project); $result = $this->gss_model->get_where_distinct_civil_po_wo($table,$where,$project,$po_no); if($result) { echo json_encode($result); } else { echo json_encode(array('result'=>0)); } } else if($project == 'all' && $from_date!= "" && $to_date!= "") { $result = $this->gss_model->get_civil_purchase_order_dates($from_date,$to_date); if($result) { echo json_encode($result); } else { echo json_encode(array('result'=>0)); } } else if($project != "" && $po_no !="all" && $from_date!= "" && $to_date!= "") { $result = $this->gss_model->get_civil_po($from_date,$to_date,$project,$po_no); if($result) { echo json_encode($result); } else { echo json_encode(array('result'=>0)); } } else { $condition=array('po_no'=>$po_no); $result = $this->gss_model->get_civil_purchase_order_project($project,$po_no); if($result) { echo json_encode($result); } else { echo json_encode(array('result'=>0)); } } } public function work_order_po_generated_list() { $from_date = $_GET['from']; if($from_date != "") { $date = new DateTime($from_date); $from_date = $date->format('d-m-Y'); } $to_date =$_GET['to']; if($to_date != "") { $date = new DateTime($to_date); $to_date = $date->format('d-m-Y'); } $result = $this->gss_model->get_purchase_order_dates($from_date,$to_date); if($result) { echo json_encode($result); } else { echo json_encode(array('result'=>0)); } } public function purchase_order_project_wise() { $from_date = $_GET['from']; if($from_date != "") { $date = new DateTime($from_date); $from_date = $date->format('Y-m-d'); } $to_date =$_GET['to']; if($to_date != "") { $date = new DateTime($to_date); $to_date = $date->format('Y-m-d'); } $project = $_GET['project']; $po_no = $_GET['po_no']; $table = 'gss_po_generate' ; if($project == 'all' && $from_date == "" && $to_date == "") { $table='gss_po_generate'; $condition=array('delete_status'=>'ACTIVE'); $result = $this->gss_model->get_where_distinct_po($table,$condition); if($result) { echo json_encode($result); } else { echo json_encode(array('result'=>0)); } } else if($project != "" && $po_no =="all" && $from_date!= "" && $to_date!= "") { $result = $this->gss_model->get_civil_po_wo_order($table,$from_date,$to_date,$project,$po_no); if($result) { echo json_encode($result); } else { echo json_encode(array('result'=>0)); } } else if($po_no == 'all') { $where = array('project_name'=>$project); $result = $this->gss_model->get_where_distinct_po_wo($table,$where,$from_date,$to_date,$project); if($result) { echo json_encode($result); } else { echo json_encode(array('result'=>0)); } } else if($project == 'all' && $from_date!= "" && $to_date!= "") { $result = $this->gss_model->get_purchase_order_dates($from_date,$to_date); if($result) { echo json_encode($result); } else { echo json_encode(array('result'=>0)); } } else if($project != "" && $po_no !="" && $from_date!= "" && $to_date!= "") { $result = $this->gss_model->get_po($from_date,$to_date,$project,$po_no); if($result) { echo json_encode($result); } else { echo json_encode(array('result'=>0)); } } else { $condition=array('po_no'=>$po_no); $result = $this->gss_model->get_purchase_order_project($project,$po_no); if($result) { echo json_encode($result); } else { echo json_encode(array('result'=>0)); } } } public function work_order_wo_generated_list() { $from_date = $_GET['from']; if($from_date != "") { $date = new DateTime($from_date); $from_date = $date->format('d-m-Y'); } $to_date =$_GET['to']; if($to_date != "") { $date = new DateTime($to_date); $to_date = $date->format('d-m-Y'); } $result = $this->gss_model->get_work_order_dates($from_date,$to_date); if($result) { echo json_encode($result); } else { echo json_encode(array('result'=>0)); } } public function work_order_project_wise() { $from_date = $_GET['from']; if($from_date != "") { $date = new DateTime($from_date); $from_date = $date->format('Y-m-d'); } $to_date =$_GET['to']; if($to_date != "") { $date = new DateTime($to_date); $to_date = $date->format('Y-m-d'); } $project = $_GET['project']; $po_no = $_GET['po_no']; $table = 'gss_wo_generate' ; if($project == 'all' && $from_date == "" && $to_date == "") { $table='gss_wo_generate'; $condition=array('delete_status'=>'ACTIVE'); $result = $this->gss_model->get_where_distinct_po($table,$condition); if($result) { echo json_encode($result); } else { echo json_encode(array('result'=>0)); } } else if($project != "" && $po_no =="all" && $from_date!= "" && $to_date!= "") { $result = $this->gss_model->get_civil_po_wo_order($table,$from_date,$to_date,$project,$po_no); if($result) { echo json_encode($result); } else { echo json_encode(array('result'=>0)); } } else if($po_no == "all") { $where = array('project_name'=>$project); $result = $this->gss_model->get_where_distinct_po_wo($table,$where,$project,$po_no); if($result) { echo json_encode($result); } else { echo json_encode(array('result'=>0)); } } else if($project == 'all' && $from_date != "" && $to_date != "") { $result = $this->gss_model->get_work_order_dates($from_date,$to_date); if($result) { echo json_encode($result); } else { echo json_encode(array('result'=>0)); } } else if($project != "" && $po_no !="" && $from_date!= "" && $to_date!= "") { $result = $this->gss_model->get_wo($from_date,$to_date,$project,$po_no); if($result) { echo json_encode($result); } else { echo json_encode(array('result'=>0)); } } else { $result = $this->gss_model->get_work_order_project($project,$po_no); if($result) { echo json_encode($result); } else { echo json_encode(array('result'=>0)); } } } public function export_print_work_order() { $from_date = $_GET['from']; if($from_date != "") { $date = new DateTime($from_date); $from_date = $date->format('Y-m-d'); } $to_date =$_GET['to']; if($to_date != "") { $date = new DateTime($to_date); $to_date = $date->format('Y-m-d'); } $project = $_GET['project']; $po_no = $_GET['po_no']; $table='gss_wo_generate'; //$condition=array('delete_status'=>'ACTIVE'); if($project == 'all' && $from_date == "" && $to_date == "") { $table='gss_wo_generate'; $condition=array('delete_status'=>'ACTIVE'); $result = $this->gss_model->get_where_distinct_po($table,$condition); if($result) { echo json_encode($result); } else { echo json_encode(array('result'=>0)); } } else if($project != "" && $po_no =="all" && $from_date!= "" && $to_date!= "") { $result = $this->gss_model->get_civil_po_wo_order($table,$from_date,$to_date,$project,$po_no); if($result) { echo json_encode($result); } else { echo json_encode(array('result'=>0)); } } else if($po_no == "all") { $where = array('project_name'=>$project); $result = $this->gss_model->get_where_distinct_po_wo($table,$where,$project,$po_no); if($result) { echo json_encode($result); } else { echo json_encode(array('result'=>0)); } } else if($project == 'all' && $from_date != "" && $to_date != "") { $result = $this->gss_model->get_work_order_dates($from_date,$to_date); if($result) { echo json_encode($result); } else { echo json_encode(array('result'=>0)); } } else if($project != "" && $po_no !="" && $from_date!= "" && $to_date!= "") { $result = $this->gss_model->get_wo($from_date,$to_date,$project,$po_no); if($result) { echo json_encode($result); } else { echo json_encode(array('result'=>0)); } } else { $result = $this->gss_model->get_work_order_project($project,$po_no); if($result) { echo json_encode($result); } else { echo json_encode(array('result'=>0)); } } } public function export_print_purchase_order() { $from_date = $_GET['from']; if($from_date != "") { $date = new DateTime($from_date); $from_date = $date->format('Y-m-d'); } $to_date =$_GET['to']; if($to_date != "") { $date = new DateTime($to_date); $to_date = $date->format('Y-m-d'); } $project = $_GET['project']; $po_no = $_GET['po_no']; $table='gss_po_generate'; //$condition=array('delete_status'=>'ACTIVE'); if($project == 'all' && $from_date == "" && $to_date == "") { $table='gss_po_generate'; $condition=array('delete_status'=>'ACTIVE'); $result = $this->gss_model->get_where_distinct_po($table,$condition); if($result) { echo json_encode($result); } else { echo json_encode(array('result'=>0)); } } else if($project != "" && $po_no =="all" && $from_date!= "" && $to_date!= "") { $result = $this->gss_model->get_civil_po_wo_order($table,$from_date,$to_date,$project,$po_no); if($result) { echo json_encode($result); } else { echo json_encode(array('result'=>0)); } } else if($po_no == 'all') { $where = array('project_name'=>$project); $result = $this->gss_model->get_where_distinct_po_wo($table,$where,$from_date,$to_date,$project); if($result) { echo json_encode($result); } else { echo json_encode(array('result'=>0)); } } else if($project == 'all' && $from_date!= "" && $to_date!= "") { $result = $this->gss_model->get_purchase_order_dates($from_date,$to_date); if($result) { echo json_encode($result); } else { echo json_encode(array('result'=>0)); } } else if($project != "" && $po_no !="" && $from_date!= "" && $to_date!= "") { $result = $this->gss_model->get_po($from_date,$to_date,$project,$po_no); if($result) { echo json_encode($result); } else { echo json_encode(array('result'=>0)); } } else { $condition=array('po_no'=>$po_no); $result = $this->gss_model->get_purchase_order_project($project,$po_no); if($result) { echo json_encode($result); } else { echo json_encode(array('result'=>0)); } } } public function export_print_civil_work_order() { $from_date = $_GET['from']; if($from_date != "") { $date = new DateTime($from_date); $from_date = $date->format('d-m-Y'); } $to_date =$_GET['to']; if($to_date != "") { $date = new DateTime($to_date); $to_date = $date->format('d-m-Y'); } $project = $_GET['project']; $po_no = $_GET['wo_no']; $table = 'gss_civil_wo' ; if($project == 'all' && $from_date == "" && $to_date == "") { $table='gss_civil_wo'; $condition=array('delete_status'=>'ACTIVE'); $result = $this->gss_model->get_where_distinct_po($table,$condition); if($result) { echo json_encode($result); } else { echo json_encode(array('result'=>0)); } } else if($project != "" && $po_no =="all" && $from_date!= "" && $to_date!= "") { $result = $this->gss_model->get_civil_po_order($table,$from_date,$to_date,$project,$po_no); if($result) { echo json_encode($result); } else { echo json_encode(array('result'=>0)); } } else if($project == 'all' && $from_date!= "" && $to_date!= "") { $result = $this->gss_model->get_civil_work_order_dates($from_date,$to_date); if($result) { echo json_encode($result); } else { echo json_encode(array('result'=>0)); } } else if($po_no == "all") { $where = array('project_name'=>$project); $result = $this->gss_model->get_where_distinct_civil_po_wo($table,$where,$project,$po_no); if($result) { echo json_encode($result); } else { echo json_encode(array('result'=>0)); } } else if($project != "" && $po_no !="" && $from_date!= "" && $to_date!= "") { $result = $this->gss_model->get_civil_wo($from_date,$to_date,$project,$wo_no); if($result) { echo json_encode($result); } else { echo json_encode(array('result'=>0)); } } else { $condition=array('po_no'=>$po_no); $result = $this->gss_model->get_civil_work_order_project($project,$po_no); if($result) { echo json_encode($result); } else { echo json_encode(array('result'=>0)); } } } public function export_print_civil_purchase_order() { $from_date = $_GET['from']; if($from_date != "") { $date = new DateTime($from_date); $from_date = $date->format('d-m-Y'); } $to_date =$_GET['to']; if($to_date != "") { $date = new DateTime($to_date); $to_date = $date->format('d-m-Y'); } $project = $_GET['project']; $po_no = $_GET['po_no']; $table='gss_civil_po'; //$condition=array('delete_status'=>'ACTIVE'); if($project == 'all' && $from_date == "" && $to_date == "") { $table='gss_civil_po'; $condition=array('delete_status'=>'ACTIVE'); $result = $this->gss_model->get_where_distinct_po($table,$condition); if($result) { echo json_encode($result); } else { echo json_encode(array('result'=>0)); } } else if($project != "" && $po_no =="all" && $from_date!= "" && $to_date!= "") { $result = $this->gss_model->get_civil_po_order($table,$from_date,$to_date,$project,$po_no); if($result) { echo json_encode($result); } else { echo json_encode(array('result'=>0)); } } else if($po_no == "all") { $where = array('project_name'=>$project); $result = $this->gss_model->get_where_distinct_civil_po_wo($table,$where,$project,$po_no); if($result) { echo json_encode($result); } else { echo json_encode(array('result'=>0)); } } else if($project == 'all' && $from_date!= "" && $to_date!= "") { $result = $this->gss_model->get_civil_purchase_order_dates($from_date,$to_date); if($result) { echo json_encode($result); } else { echo json_encode(array('result'=>0)); } } else if($project != "" && $po_no !="all" && $from_date!= "" && $to_date!= "") { $result = $this->gss_model->get_civil_po($from_date,$to_date,$project,$po_no); if($result) { echo json_encode($result); } else { echo json_encode(array('result'=>0)); } } else { $condition=array('po_no'=>$po_no); $result = $this->gss_model->get_civil_purchase_order_project($project,$po_no); if($result) { echo json_encode($result); } else { echo json_encode(array('result'=>0)); } } } public function civil_purchase_order_list() { $admin_id = session()->get('admin_id'); if($admin_id) { $land_table = 'gss_civil_project_master'; $data['project'] = $this->gss_model->get_where_result1111($land_table); $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $this->load->view('admin/civil_purchase_order_list',$data); } else { redirect('/'); } } public function from_address_master(){ $admin_id = session()->get('admin_id'); if($admin_id) { $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $this->load->view('admin/from_address_master',$data); } else { redirect('/'); } } public function from_address_master_insert(){ $mname = $this->input->post('mname'); $msname = $this->input->post('msname'); $maddress = $this->input->post('maddress'); $mgstno = $this->input->post('mgstno'); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $created_at = $date->format('Y-m-d H:i:s'); $data = array( 'name' => $mname, 'sname' => $msname, 'address' => $maddress, 'gstno' => $mgstno, 'created_on' => $created_at, ); $table = "gss_from_master_table"; $result = $this->gss_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 from_address_master_list() { $table = 'gss_from_master_table'; $where = array('delete_status'=>'ACTIVE'); $result = $this->gss_model->get_where_result($table,$where); if($result) { echo json_encode($result); } else { echo json_encode(array('result'=>0)); } } //Delete usertype /* public function delete_from_address() { $table = 'gss_from_master_table'; $mid = $this->input->post('mid'); $where = array('mid'=>$mid); $data = array('delete_status'=>'INACTIVE'); $result = $this->gss_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 delete_from_address() { $table = 'gss_from_master_table'; $mid = $this->input->post('mid'); if($mid == 2){ $where = array('mid'=>$mid); $data = array('delete_status'=>'ACTIVE'); $result = $this->gss_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,'message'=>'GSS Foundation data cannot be deleted')); } }else{ $where = array('mid'=>$mid); $data = array('delete_status'=>'INACTIVE'); $result = $this->gss_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)); } } } //Update usertype public function update_from_master_table() { $mid = $this->input->post('edit_mid'); $edit_mname = $this->input->post('edit_mname'); $edit_msname = $this->input->post('edit_msname'); $edit_maddress = $this->input->post('edit_maddress'); $edit_mgstno = $this->input->post('edit_mgstno'); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $updated_on = $date->format('Y-m-d H:i:s'); $table = 'gss_from_master_table'; $where = array('mid'=>$mid); $data = array( 'name' => $edit_mname, 'sname' => $edit_msname, 'address' => $edit_maddress, 'gstno' => $edit_mgstno, 'updated_on' => $updated_on ); $result = $this->gss_model->update($where,$table,$data); 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")); } } //Edit access control public function edit_master_form() { $table = ' gss_from_master_table'; $mid = $this->input->post('mid'); $where = array('mid'=>$mid,'delete_status'=>'ACTIVE'); $result = $this->gss_model->get_where_row($table,$where); if($result) { echo json_encode(array('details'=>$result,'result'=>1)); } else { echo json_encode(array('result'=>0)); } } public function check_project_sites_for_booked() { $project_id = $this->input->post('project_id'); $site_number = $this->input->post('site_number'); $where = array('project_id'=>$project_id,'site_number'=>$site_number,'delete_status'=>'ACTIVE'); $table = 'gss_booking_details'; // $result = $this->gss_model->get_where_row($table,$where); // if($result) // { // echo json_encode(array('details'=>$result,'result'=>1)); // } // else // { // echo json_encode(array('result'=>0)); // } $this->db->select('A.*,C.*'); $this->db->from('gss_bookings A'); $this->db->join('gss_booking_details C','C.booking_id=A.booking_id'); $this->db->where('A.delete_status','ACTIVE'); $this->db->where('C.delete_status','ACTIVE'); $this->db->where('C.project_id',$project_id); $this->db->where('C.site_number',$site_number); $result = $this->db->get(); $result = $result->row(); if($result) { if($result->booking_status == 'BOOKED') { echo json_encode(array('details'=>$result,'result'=>1)); } else { echo json_encode(array('result'=>0)); } } else { echo json_encode(array('result'=>0)); } } public function get_site_dimensions() { $project_id = $this->input->post('project_id'); $site_number = $this->input->post('site_number'); $table = 'gss_new_sites'; $where = array('delete_status'=>'ACTIVE','site_number'=>$site_number,'project_id'=>$project_id); $get_dimsension = $this->gss_model->get_where_row($table,$where); if(!empty($get_dimsension)) { $total_sqft = $get_dimsension->total_in_sqft; $khata_status =$get_dimsension->status; if($total_sqft) { echo json_encode(array('total_sqft'=>$total_sqft,'khata_status'=>$khata_status,'result'=>1)); } else { echo json_encode(array('result'=>0,'message'=>"No Data Found")); } } else { echo json_encode(array('result'=>0,'message'=>"No Data Found")); } } //------------------------------- reception form new -----------------------------// public function new_reception_form() { $admin_id = session()->get('admin_id'); if($admin_id) { $project_table = 'gss_new_projects'; $order_by = 'project_name'; $where_project = array('delete_status'=>'ACTIVE','project_status'=>'ONGOING'); $data['projects'] = $this->gss_model->get_where_result_alphabetical($project_table,$where_project,$order_by); $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $this->load->view('admin/new_reception_form',$data); } else { redirect('/'); } } /* public function add_new_reception_details() { $admin_id = session()->get('admin_id'); if($admin_id) { $project_id = $this->input->post('project_id'); $booking_id = $this->input->post('booking_id'); $detail_id = $this->input->post('detail_id'); $site_number = $this->input->post('site_number'); $site_dimension = $this->input->post('site_dimension'); $customer_name = $this->input->post('customer_name'); $contact1 = $this->input->post('contact1'); $contact2 = $this->input->post('contact2'); $dispatched = $this->input->post('dispatched'); $dispatched_date = $this->input->post('dispatched_date'); $doc_details = $this->input->post('doc_details'); $ack_doc = $this->input->post('ack_doc'); $remarks = $this->input->post('remarks'); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $created_at = $date->format('Y-m-d H:i:s'); $data = array( 'detail_id' => $detail_id, 'booking_id' => $booking_id, 'project_id' => $project_id, 'site_number' => $site_number, 'site_dimension'=> $site_dimension, 'customer_name' => $customer_name, 'contact1' => $contact1, 'contact2' => $contact2, 'dispatched' => $dispatched, 'dispatched_date'=> $dispatched_date, 'doc_details' => $doc_details, 'ack_doc' => $ack_doc, 'remarks' => $remarks, 'delete_status' => 'ACTIVE', 'created_at' => $created_at ); $table = 'gss_new_receptions'; $result = $this->gss_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")); } } else { redirect('/'); } }*/ public function add_new_reception_details() { $admin_id = session()->get('admin_id'); if($admin_id) { $project_id = $this->input->post('project_id'); $booking_id = $this->input->post('booking_id'); $detail_id = $this->input->post('detail_id'); $site_number = $this->input->post('site_number'); $site_dimension = $this->input->post('site_dimension'); $customer_name = $this->input->post('customer_name'); $contact1 = $this->input->post('contact1'); $contact2 = $this->input->post('contact2'); $dispatched = $this->input->post('dispatched'); $dispatched_date = $this->input->post('dispatched_date'); $doc_details = $this->input->post('doc_details'); $ack_doc = $this->input->post('ack_doc'); $remarks = $this->input->post('remarks'); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $created_at = $date->format('Y-m-d H:i:s'); $table = 'gss_new_receptions'; $where = array('project_id'=>$project_id,'site_number'=>$site_number,'delete_status'=>'ACTIVE'); $check_details = $this->gss_model->get_where_result($table,$where); if($check_details) { echo json_encode(array('result'=>0,'message'=>"Details already exists")); } else { $data = array( 'detail_id' => $detail_id, 'booking_id' => $booking_id, 'project_id' => $project_id, 'site_number' => $site_number, 'site_dimension'=> $site_dimension, 'customer_name' => $customer_name, 'contact1' => $contact1, 'contact2' => $contact2, 'dispatched' => $dispatched, 'dispatched_date'=> $dispatched_date, 'doc_details' => $doc_details, 'ack_doc' => $ack_doc, 'remarks' => $remarks, 'delete_status' => 'ACTIVE', 'created_at' => $created_at ); $result = $this->gss_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")); } } } else { redirect('/'); } } public function new_reception_list() { $admin_id = session()->get('admin_id'); if($admin_id) { $project_table = 'gss_new_projects'; $projects_order_by = 'project_name'; $where_project = array('delete_status'=>'ACTIVE'); $data['projects'] = $this->gss_model->get_where_result_orderby_asc($project_table,$where_project,$projects_order_by); $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $this->load->view('admin/new_reception_list',$data); } else { redirect('/'); } } public function get_new_reception_list() { $admin_id = session()->get('admin_id'); if($admin_id) { $result = $this->gss_model->get_new_reception_list(); // $not_booked = $this->gss_model->reception_list1(); if($result) { echo json_encode($result); } else { echo json_encode(array('result'=>0)); } } else { redirect('/'); } } //Edit New reception public function edit_new_reception_details() { $admin_id = session()->get('admin_id'); if($admin_id) { $project_table = 'gss_new_projects'; $where_project = array('delete_status'=>'ACTIVE'); $order_by = 'project_name'; $data['projects'] = $this->gss_model->get_where_result_alphabetical($project_table,$where_project,$order_by); $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $this->load->view('admin/edit_new_reception',$data); } else { redirect('/'); } } public function get_new_reception_details() { $admin_id = session()->get('admin_id'); if($admin_id) { $reception_table = 'gss_new_receptions'; $reception_id = $this->input->post('id'); $result = $this->gss_model->edit_new_reception($reception_id); if($result) { echo json_encode(array('result'=>1,'message'=>$result)); } else { echo json_encode(array('result'=>0,'message'=>"Something went wrong.. try again")); } } else { redirect('/'); } } public function update_new_reception() { $admin_id = session()->get('admin_id'); if($admin_id) { $reception_id = $this->input->post('rec_id'); $project_id = $this->input->post('project_id'); $booking_id = $this->input->post('booking_id'); $detail_id = $this->input->post('detail_id'); $site_number = $this->input->post('site_number'); $site_dimension = $this->input->post('site_dimension'); $customer_name = $this->input->post('customer_name'); $contact1 = $this->input->post('contact1'); $contact2 = $this->input->post('contact2'); $dispatched = $this->input->post('dispatched'); $dispatched_date = $this->input->post('dispatched_date'); $doc_details = $this->input->post('doc_details'); $ack_doc = $this->input->post('ack_doc'); $remarks = $this->input->post('remarks'); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $created_at = $date->format('Y-m-d H:i:s'); $table = 'gss_new_receptions'; $where = array('id' => $reception_id); $data = array( 'detail_id' => $detail_id, 'booking_id' => $booking_id, 'project_id' => $project_id, 'site_number' => $site_number, 'site_dimension'=> $site_dimension, 'customer_name' => $customer_name, 'contact1' => $contact1, 'contact2' => $contact2, 'dispatched' => $dispatched, 'dispatched_date'=> $dispatched_date, 'doc_details' => $doc_details, 'ack_doc' => $ack_doc, 'remarks' => $remarks, 'delete_status' => 'ACTIVE', 'updated_at' => $created_at ); $result = $this->gss_model->update($where,$table,$data); if($this->db->affected_rows() > 0) { echo json_encode(array('result'=>1,'message'=>"Updated successfully")); } else { echo json_encode(array('result'=>0,'message'=>"Something went wrong.. try again")); } } else { redirect('/'); } } //Delete new reception public function delete_new_reception() { $admin_id = session()->get('admin_id'); if($admin_id) { $table = 'gss_new_receptions'; $reception_id = $this->input->post('reception_id'); $where = array('id'=>$reception_id); $data = array('delete_status'=>'INACTIVE'); $result = $this->gss_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)); } } else { redirect('/'); } } public function view_new_reception() { $admin_id = session()->get('admin_id'); if($admin_id) { $table = 'gss_new_receptions'; $reception_id = $this->uri->segment(2); $where = array('id'=>$reception_id); $data['result'] = $this->gss_model->edit_new_reception($reception_id); $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $this->load->view('admin/view_new_reception',$data); } else { redirect('/'); } } //-------------------------------------------------------- Status report notifications -----------------------------------------// public function status_conversation() { $user_type_id = session()->get('user_type_id'); if($user_type_id) { $booking_id = $this->uri->segment(2); $due_type = $this->uri->segment(3); $table = 'gss_status_conversation'; $where = array('booking_id'=>$booking_id); $data['detail'] = $this->gss_model->get_conversation_replies($booking_id); $data['due_type_detail'] = $this->gss_model->get_due_type_details($booking_id,$due_type); $data['project_details'] = $this->gss_model->conversation_booking_details($booking_id); $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $this->load->view('admin/conversation',$data); } else { redirect('/'); } } public function add_status_conversation() { $user_type_id = session()->get('user_type_id'); $admin_id = session()->get('admin_id'); if($user_type_id) { $conversation = $this->input->post('conversation'); $source_type = $this->input->post('source_type'); $selected_department= $this->input->post('selected_department'); $reminder_date = $this->input->post('rem_date'); $booking_id = $this->input->post('booking_id'); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $created_at = $date->format('d-m-Y H:i:s'); $data = array('conversation' => $conversation, 'source_type' => $source_type, 'booking_id' => $booking_id, 'user_type_id' => $user_type_id, 'created_by' => $admin_id, 'reminder_date' => $reminder_date, 'selected_department' => $selected_department, 'delete_status' => 'ACTIVE', 'created_at' => $created_at ); $table = 'gss_status_conversation'; $result = $this->gss_model->insert($table,$data); if($result) { $conversation_id = $result; $table = 'gss_bookings'; $where = array('booking_id'=>$booking_id,'delete_status'=>'ACTIVE'); $client_details = $this->gss_model->get_where_row($table,$where); $client_name = $client_details->customer_name; $table = 'gss_booking_details'; $where = array('booking_id'=>$booking_id,'delete_status'=>'ACTIVE'); $client_project_details = $this->gss_model->get_where_row($table,$where); $client_project_id = $client_project_details->project_id; $client_site_number = $client_project_details->site_number; $table = 'gss_new_projects'; $where = array('project_id'=>$client_project_id); $client_project = $this->gss_model->get_where_row($table,$where); if($client_project->nick_name) { $client_project_name = $client_project->nick_name; } else { $client_project_name = $client_project->project_name; } $table = 'gss_login'; $where = array('user_id'=>$admin_id); $created = $this->gss_model->get_where_row($table,$where); $created_name = $created->username; $data = array('conversation_id' => $conversation_id, 'conversation' => $conversation, 'booking_id' => $booking_id, 'user_type_id' => $user_type_id, 'created_by' => $admin_id, 'client_name' => $client_name, 'client_project_id' => $client_project_id, 'client_project' => $client_project_name, 'client_site' => $client_site_number, 'delete_status' => 'ACTIVE', 'created_name' => $created_name, 'created_at' => $created_at ); $table = 'gss_status_notifications'; $result = $this->gss_model->insert($table,$data); if($result) { echo json_encode(array('result'=>'1','message'=>'Message Sent!')); } else { echo json_encode(array('result'=>'0','message'=>'Something went wrong..')); } } else { echo json_encode(array('result'=>'0','message'=>'Something went wrong..')); } } else { redirect('/'); } } public function add_conversation_reply() { $user_type_id = session()->get('user_type_id'); $admin_id = session()->get('admin_id'); if($user_type_id) { $reply = $this->input->post('reply'); $conversation_id = $this->input->post('conversation_id'); $booking_id = $this->input->post('booking_id'); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $created_at = $date->format('d-m-Y H:i:s'); $data = array('reply' => $reply, 'status_conversation_id' => $conversation_id, 'booking_id' => $booking_id, 'user_type_id' => $user_type_id, 'created_by' => $admin_id, 'delete_status' => 'ACTIVE', 'created_at' => $created_at ); $table = 'gss_status_conversation_replies'; $result = $this->gss_model->insert($table,$data); if($result) { if($result) { $reply_id = $result; $table = 'gss_bookings'; $where = array('booking_id'=>$booking_id,'delete_status'=>'ACTIVE'); $client_details = $this->gss_model->get_where_row($table,$where); $client_name = $client_details->customer_name; $table = 'gss_booking_details'; $where = array('booking_id'=>$booking_id,'delete_status'=>'ACTIVE'); $client_project_details = $this->gss_model->get_where_row($table,$where); $client_project_id = $client_project_details->project_id; $client_site_number = $client_project_details->site_number; $table = 'gss_new_projects'; $where = array('project_id'=>$client_project_id); $client_project = $this->gss_model->get_where_row($table,$where); if($client_project->nick_name) { $client_project_name = $client_project->nick_name; } else { $client_project_name = $client_project->project_name; } $table = 'gss_login'; $where = array('user_id'=>$admin_id); $created = $this->gss_model->get_where_row($table,$where); $created_name = $created->username; $data = array('conversation_id' => $conversation_id, 'reply_id' =>$reply_id, 'conversation' => $reply, 'booking_id' => $booking_id, 'user_type_id' => $user_type_id, 'created_by' => $admin_id, 'client_name' => $client_name, 'client_project_id' => $client_project_id, 'client_project' => $client_project_name, 'client_site' => $client_site_number, 'delete_status' => 'ACTIVE', 'created_name' => $created_name, 'created_at' => $created_at ); $table = 'gss_status_notifications'; $result = $this->gss_model->insert($table,$data); if($result) { echo json_encode(array('result'=>'1','message'=>'Message Sent!')); } else { echo json_encode(array('result'=>'0','message'=>'Something went wrong..')); } } else { echo json_encode(array('result'=>'0','message'=>'Something went wrong..')); } } else { echo json_encode(array('result'=>'0','message'=>'Something went wrong..')); } } else { redirect('/'); } } public function get_all_status_reports() { $project = $_GET['project']; $result = $this->gss_model->status_reports($project); if($result) { echo json_encode($result); } else { echo json_encode(array('result'=>0)); } } public function get_status_reports() { $project = $_GET['project']; $result = $this->gss_model->get_status_reports($project); if($result) { echo json_encode($result); } else { echo json_encode(array('result'=>0)); } } public function get_status_reports_datewise() { $project = $_GET['project']; $from_date = $_GET['from_date']; $to_date = $_GET['to_date']; $result = $this->gss_model->get_status_reports_datewise($project,$from_date,$to_date); if($result) { echo json_encode($result); } else { echo json_encode(array('result'=>0)); } } public function get_management_status_reports() { $user_type_id = session()->get('user_type_id'); $project = $_GET['project']; $result = $this->gss_model->management_status_reports($project); if($result) { echo json_encode($result); } else { echo json_encode(array('result'=>0)); } } public function get_doc_status_reports() { $user_type_id = session()->get('user_type_id'); $project = $_GET['project']; $result = $this->gss_model->doc_status_reports($project); if($result) { echo json_encode($result); } else { echo json_encode(array('result'=>0)); } } public function delete_conversation() { $admin_id = session()->get('admin_id'); if($admin_id) { $table = 'gss_status_conversation'; $conversation_id = $this->input->post('conversation_id'); $where = array('id'=>$conversation_id); $data = array('delete_status'=>'INACTIVE'); $result = $this->gss_model->update($where,$table,$data); $table = 'gss_status_conversation_replies'; $where = array('status_conversation_id'=>$conversation_id); $data = array('delete_status'=>'INACTIVE'); $result = $this->gss_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)); } } else { redirect('/'); } } public function delete_reply() { $admin_id = session()->get('admin_id'); if($admin_id) { $table = 'gss_status_conversation_replies'; $reply_id = $this->input->post('reply_id'); $where = array('id'=>$reply_id); $data = array('delete_status'=>'INACTIVE'); $result = $this->gss_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)); } } else { redirect('/'); } } public function get_client_booking_details() { $project_id = $this->input->post('project_id'); $site_number = $this->input->post('site_number'); $table = 'gss_booking_details'; $where = array('delete_status' =>'ACTIVE','project_id'=>$project_id,'site_number'=>$site_number); $result = $this->gss_model->get_where_row($table,$where); $booking_id = $result->booking_id; /*$table = 'gss_status_conversation'; $where = array('booking_id'=>$booking_id); $detail = $this->gss_model->get_conversation_replies($booking_id); //$this->load->view('admin/conversation',$data);*/ if($result) { echo json_encode(array('result'=>1,'booking_id'=>$booking_id)); } else { echo json_encode(array('result'=>0)); } } public function status_conversation_list() { $result = $this->gss_model->get_status_notifications(); if($result) { echo json_encode(array('result'=>1,'conversations'=>$result,'total'=>count($result))); } else { echo json_encode(array('result'=>0)); } } public function notification_status_conversation() { $user_type_id = session()->get('user_type_id'); if($user_type_id) { $booking_id = $this->uri->segment(2); $table = 'gss_status_conversation'; $where = array('booking_id'=>$booking_id,'delete_status'=>'ACTIVE'); $data['detail'] = $this->gss_model->get_conversation_replies($booking_id); $table = 'gss_bookings'; $where = array('booking_id'=>$booking_id,'delete_status'=>'ACTIVE'); $bookings = $this->gss_model->get_where_row($table,$where); $data['customer_name'] = $bookings->customer_name; $project_id = $bookings->project_id; $table = 'gss_new_projects'; $where = array('project_id'=>$project_id,'delete_status'=>'ACTIVE'); $project = $this->gss_model->get_where_row($table,$where); $data['project'] = $project->project_name; $table = 'gss_booking_details'; $where = array('booking_id'=>$booking_id,'delete_status'=>'ACTIVE'); $booking_details = $this->gss_model->get_where_row($table,$where); $data['site_number'] = $booking_details->site_number; $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $this->load->view('admin/notification_status_conversation',$data); } else { redirect('/'); } } public function get_status_notifications() { $admin_id = session()->get('admin_id'); $type = session()->get('user_type_id'); $total_count = ""; $conversations = ""; $result = $this->gss_model->get_status_notifications(); if($result) { $data['conversation'] = $result; $total_count = count($result); echo json_encode(array('result'=>1,'conversation'=>$result,'total_status_notifications'=>$total_count)); } else { echo json_encode(array('result'=>0)); } } /* public function get_not_viewed_notifications() { $admin_id = session()->get('admin_id'); $user_type_id = session()->get('user_type_id'); $notification_id = $this->input->post('notification_id'); $project_id = $this->input->post('project_id'); $site_number = $this->input->post('site_number'); $table = 'gss_status_notifications'; $where = array('client_project_id' => $project_id,'client_site'=>$site_number); if($user_type_id == 1) { $data = array('admin'=>'VIEWED','viewed_by'=>$admin_id); } else if($user_type_id == 4) { $data = array('management'=>'VIEWED','viewed_by'=>$admin_id); } else if($user_type_id == 5) { $data = array('documentation'=>'VIEWED','viewed_by'=>$admin_id); } $result = $this->gss_model->update($where,$table,$data); if($result) { echo json_encode(array('result'=>1)); } else { echo json_encode(array('result'=>0)); } }*/ public function get_not_viewed_notifications() { $admin_id = session()->get('admin_id'); $user_type_id = session()->get('user_type_id'); $booking_id = $this->uri->segment(2); $table = 'gss_status_notifications'; $where = array('booking_id' => $booking_id); if($user_type_id == 1) { $data = array('admin'=>'VIEWED','viewed_by'=>$admin_id); } else if($user_type_id == 4) { $data = array('management'=>'VIEWED','viewed_by'=>$admin_id); } else if($user_type_id == 5) { $data = array('documentation'=>'VIEWED','viewed_by'=>$admin_id); } else if($user_type_id == 6) { $data = array('loan'=>'VIEWED','viewed_by'=>$admin_id); } $result = $this->gss_model->update($where,$table,$data); if($this->db->affected_rows() > 0) { //echo json_encode(array('result'=>1)); $table = 'gss_status_conversation'; $where = array('booking_id'=>$booking_id,'delete_status'=>'ACTIVE'); $data['detail'] = $this->gss_model->get_conversation_replies($booking_id); $table = 'gss_bookings'; $where = array('booking_id'=>$booking_id,'delete_status'=>'ACTIVE'); $bookings = $this->gss_model->get_where_row($table,$where); $data['customer_name'] = $bookings->customer_name; $project_id = $bookings->project_id; $table = 'gss_new_projects'; $where = array('project_id'=>$project_id,'delete_status'=>'ACTIVE'); $project = $this->gss_model->get_where_row($table,$where); $data['project'] = $project->project_name; $table = 'gss_booking_details'; $where = array('booking_id'=>$booking_id,'delete_status'=>'ACTIVE'); $booking_details = $this->gss_model->get_where_row($table,$where); $data['site_number'] = $booking_details->site_number; $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $this->load->view('admin/notification_status_conversation',$data); } else { echo json_encode(array('result'=>0)); } } public function get_reception_reports_datewise() { $project = $_GET['project']; $from_date = $_GET['from_date']; $to_date = $_GET['to_date']; $result = $this->gss_model->get_reception_reports_datewise($project,$from_date,$to_date); if($result) { echo json_encode($result); } else { echo json_encode(array('result'=>0)); } } public function delete_agreement_amount() { $table = 'gss_plot_payments'; $payment_id = $this->input->post('payment_id'); $where = array('payment_id'=>$payment_id); $data = array('agreement_amount'=>'','agreement_date'=>'','agreement_payment_mode'=>''); $result = $this->gss_model->update($where,$table,$data); $table = 'gss_plot_payment_types'; $data = array('agreement_cheque_no'=>'0','agreement_cheque_date'=>'','agreement_bank'=>'0','agreement_vtr_no'=>'','agreement_online_date'=>'','agreement_dd_no'=>'0','agreement_dd_date'=>'','agreement_dd_bank'=>'0'); $result = $this->gss_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 check_cancelled_refunded_site_details() { $instal_table = 'gss_plot_payments'; $site_number = $this->input->post('site_number'); $project_id = $this->input->post('project_id'); $check_site = $this->gss_model->project_details($site_number,$project_id); if($check_site) { $get_site = $this->gss_model->check_site_payment_details($site_number,$project_id); if($get_site) { if($get_site->booking_status == 'CANCELLED') { echo json_encode(array('result'=>3,'message'=>'Site number '.$site_number.' has been cancelled')); } else if($get_site->booking_status == 'REFUNDED') { echo json_encode(array('result'=>3,'message'=>'Site number '.$site_number.' has been refunded')); } else { $where_booking = array('booking_id'=>$get_site->booking_id,'delete_status'=>'ACTIVE'); $instal_result = $this->gss_model->get_where_result($instal_table,$where_booking); $agree_result = $this->gss_model->get_where_row($instal_table,$where_booking); $tbale='gss_registration_amount_details'; $condition=array('booking_id'=>$get_site->booking_id,'delete_status'=>'ACTIVE'); $get_reg_amt=$this->gss_model->get_where_result($tbale,$condition); $cancellation_table='gss_cancellations'; $cancellation_con=array('booking_id'=>$get_site->booking_id,'delete_status'=>'ACTIVE'); $get_due_amount=$this->gss_model->get_where_result($cancellation_table,$cancellation_con); $pay_table = 'gss_plot_payments'; $pay_condition=array('booking_id'=>$get_site->booking_id,'delete_status'=>'ACTIVE'); $agr_amount = $this->gss_model->get_where_result($pay_table,$pay_condition); echo json_encode(array('result'=>1,'booking_details'=>$get_site,'installments'=>$instal_result,'agree'=>$agree_result,'reg_amount'=>$get_reg_amt,'due_amount'=>$get_due_amount,'payment_agr_amount'=>$agr_amount)); } } else { echo json_encode(array('result'=>0,'message'=>'Site number '.$site_number.' not booked')); } } else { echo json_encode(array('result'=>2,'message'=>'Site number '.$site_number.' not found')); } } public function check_project_type_status() { $status = $this->input->post('value'); if($status == "ALL") { $where = array('delete_status'=>'ACTIVE'); } else { $where = array('project_status'=>$status,'delete_status'=>'ACTIVE'); } $order_by = 'project_name'; $table = 'gss_new_projects'; $admin_id = session()->get('admin_id'); $land_owner_id = session()->get('land_owner_id'); $check_status = $this->gss_model->get_projects_landownerwise($admin_id,$land_owner_id,$status); if($check_status) { echo json_encode(array('result'=>1,'message'=>$check_status)); } else { echo json_encode(array('result'=>0,'message'=>'No Data Found')); } } public function preview_booking_details() { $admin_id = session()->get('admin_id'); if($admin_id) { $table = 'gss_bookings'; $broker_table = 'gss_brokers'; $instal_table = 'gss_booking_installments'; $booking_id = $this->uri->segment(2); $data['site_result'] = $this->gss_model->user_site_booking_details1($booking_id); $site_result = $this->gss_model->user_site_booking_details1($booking_id); $where = array('booking_id'=>$booking_id,'delete_status'=>'ACTIVE'); $data['instal_result'] = $this->gss_model->get_where_row($instal_table,$where); $where = array('booking_id'=>$booking_id); $get_project = $this->gss_model->get_where_row($table,$where); $project_id = $get_project->project_id; $where_project = array('project_id'=>$project_id); $project_table = 'gss_new_projects'; $get_project_details = $this->gss_model->get_where_row($project_table,$where_project); $data['project'] = $get_project_details; $land_owner = $get_project_details->land_owner_id; $land_owner_table = 'gss_land_owners'; $where_land_owner = array('owner_id'=>$land_owner); $get_land_owner = $this->gss_model->get_where_row($land_owner_table,$where_land_owner); $data['land_owner'] = $get_land_owner; $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); if($get_land_owner->name == 'GSS Project Consultants') { $this->load->view('admin/gss_receipt',$data); } else { $this->load->view('admin/gss_ack',$data); } //$this->load->view('admin/preview_booking_details',$data); } else { redirect('/'); } } public function get_booking_details() { $table = 'gss_bookings'; $broker_table = 'gss_brokers'; $instal_table = 'gss_booking_installments'; $booking_id = $this->uri->segment(2); $booking_receipt = $this->gss_model->booking_receipt_site_data($booking_id); $where_user = array('booking_id'=>$booking_id); $user_data = $this->gss_model->get_where_row($table,$where_user); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $todays_date = $date->format('Y-m-d'); echo json_encode(array('result'=>1, 'user_data' => $user_data, 'todays_date' => $todays_date, 'booking_receipt' => $booking_receipt )); } public function get_balance_sqft() { $project = $this->input->post('project_id'); $table = 'gss_new_sites'; $tot_project_sqft = $this->gss_model->get_total_project_sqft($project); $booked_sqft = $this->gss_model->get_booked_project_sqft($project); //$balance_sqft = $tot_project_sqft - $booked_sqft; $booking_sqft = 0; $balance = 0; foreach($tot_project_sqft as $tps) { $total_project_sqft = $tps->total_in_sqft; foreach($booked_sqft as $bs) { $booking_sqft = $bs->booked_sqft; } $balance = $total_project_sqft - $booking_sqft; //$balance_sqft = array_push($array,$balance); } if($balance) { echo json_encode(array('result'=>1, 'balance_sqft'=>$balance)); } else { echo json_encode(array('result'=>0, 'message'=>'NO data found')); } } public function get_status_agree_due_reports() { $project = $_GET['project']; $result = $this->gss_model->get_status_agree_due_reports($project); if($result) { echo json_encode($result); } else { echo json_encode(array('result'=>0)); } } public function get_status_reg_due_reports() { $project = $_GET['project']; $result = $this->gss_model->get_status_reg_due_reports($project); if($result) { echo json_encode($result); } else { echo json_encode(array('result'=>0)); } } public function get_management_agree_status_reports() { $user_type_id = session()->get('user_type_id'); $project = $_GET['project']; $result = $this->gss_model->management_agree_status_reports($project); if($result) { echo json_encode($result); } else { echo json_encode(array('result'=>0)); } } public function get_management_reg_status_reports() { $user_type_id = session()->get('user_type_id'); $project = $_GET['project']; $result = $this->gss_model->management_reg_status_reports($project); if($result) { echo json_encode($result); } else { echo json_encode(array('result'=>0)); } } public function get_doc_agree_status_reports() { $user_type_id = session()->get('user_type_id'); $project = $_GET['project']; $result = $this->gss_model->agree_doc_status_reports($project); if($result) { echo json_encode($result); } else { echo json_encode(array('result'=>0)); } } public function get_doc_reg_status_reports() { $user_type_id = session()->get('user_type_id'); $project = $_GET['project']; $result = $this->gss_model->reg_doc_status_reports($project); if($result) { echo json_encode($result); } else { echo json_encode(array('result'=>0)); } } public function get_loan_agree_status_reports() { $user_type_id = session()->get('user_type_id'); $project = $_GET['project']; $result = $this->gss_model->agree_loan_status_reports($project); if($result) { echo json_encode($result); } else { echo json_encode(array('result'=>0)); } } public function get_loan_reg_status_reports() { $user_type_id = session()->get('user_type_id'); $project = $_GET['project']; $result = $this->gss_model->reg_loan_status_reports($project); if($result) { echo json_encode($result); } else { echo json_encode(array('result'=>0)); } } public function check_booking_status() { $booking_id = $this->input->post('booking_id'); $where = array('booking_id'=>$booking_id); $table = 'gss_bookings'; $details = $this->gss_model->get_where_row($table,$where); if($details) { if($details->booking_status != 'REFUND_PENDING' || $details->booking_status != 'REFUNDED') { echo json_encode(array('result'=>1)); } else { echo json_encode(array('result'=>0)); } } else { echo json_encode(array('result'=>0)); } } public function delete_refunds() { $id = $this->input->post('id'); $refund_table = 'gss_cancellation_refunds'; $where_id = array('id'=>$id); $get_booking_id = $this->gss_model->get_where_row($refund_table,$where_id); $booking_id = $get_booking_id->booking_id; $booking_table = 'gss_bookings'; $where_booking_id = array('booking_id'=>$booking_id); $get_status = $this->gss_model->get_where_row($booking_table,$where_booking_id); if($get_status->booking_status == 'REFUNDED') { $data = array('booking_status'=>'REFUND_PENDING'); $result = $this->gss_model->update($where_booking_id,$booking_table,$data); if($this->db->affected_rows() > 0) { $result = $this->db->delete($refund_table,$where_id); if($result) { echo json_encode(array('result'=>1,'message'=>'Deleted!')); } else { echo json_encode(array('result'=>0)); } } else { echo json_encode(array('result'=>0)); } } else { $result = $this->db->delete($refund_table,$where_id); if($result) { echo json_encode(array('result'=>1,'message'=>'Deleted!')); } else { echo json_encode(array('result'=>0)); } } } public function cancellation_preview() { $admin_id = session()->get('admin_id'); if($admin_id) { $table = 'gss_bookings'; $broker_table = 'gss_brokers'; $instal_table = 'gss_booking_installments'; $cancellation_id = $this->uri->segment(2); $canc_table = 'gss_cancellations'; $where = array('cancellation_id'=>$cancellation_id); $details = $this->gss_model->get_where_row($canc_table, $where); $booking_id = $details->booking_id; $data['site_result'] = $this->gss_model->user_site_booking_details1($booking_id); $site_result = $this->gss_model->user_site_booking_details1($booking_id); $where = array('booking_id'=>$booking_id,'delete_status'=>'ACTIVE'); $data['instal_result'] = $this->gss_model->get_where_row($instal_table,$where); $where = array('booking_id'=>$booking_id); $get_project = $this->gss_model->get_where_row($table,$where); $project_id = $get_project->project_id; $where_project = array('project_id'=>$project_id); $project_table = 'gss_new_projects'; $get_project_details = $this->gss_model->get_where_row($project_table,$where_project); $data['project'] = $get_project_details; $land_owner = $get_project_details->land_owner_id; $land_owner_table = 'gss_land_owners'; $where_land_owner = array('owner_id'=>$land_owner); $get_land_owner = $this->gss_model->get_where_row($land_owner_table,$where_land_owner); $data['land_owner'] = $get_land_owner; $data['refunds'] = $this->gss_model->get_where_refunds($cancellation_id); /* $paym_table = 'gss_plot_payments'; $where = array('booking_id'=>$booking_id); $ack_no = $this->gss_model->get_where_row($paym_table, $where); $data['ack_no'] = $ack_no+1;*/ $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); if($get_land_owner->name == 'GSS Project Consultants') { $this->load->view('admin/gss_cancellation_receipt',$data); } else { $this->load->view('admin/gss_cancellation_ack',$data); } } else { redirect('/'); } } public function get_status_report_balance_agree_amt() { $project = $this->input->post('project_id'); $tot_agree_due_amt = $this->gss_model->get_total_agree_due_amt($project); $total_agreement_due_amount = 0; $total_registration_due_amount = 0; foreach($tot_agree_due_amt as $tada) { $total_agreement_due_amt = $tada->sales_agreement_due_amount; $total_agreement_due_amount += $total_agreement_due_amt; $total_reg_due_amt = $tada->registration_due_amount; $total_registration_due_amount += $total_reg_due_amt; } $received_agreement_amt = $this->gss_model->get_received_agree_amt($project); $received_agreement_amount = 0; $received_registration_amount = 0; foreach($received_agreement_amt as $raa) { $received_agree_amt = $raa->agreement_amount; $received_agreement_amount += is_numeric($received_agree_amt); $received_due_amt = $raa->registration_amount; $received_registration_amount += is_numeric($received_due_amt); } $from_date = ""; $to_date = ""; $total_paid = 0; $tot_agr_amt = 0; $tot_booking_amt = 0; $total_paid_reg = $this->gss_model->payment_reports_receivable($from_date,$to_date,$project); foreach($total_paid_reg as $tpr) { $tot_booking = $tpr['booking_amount1']; $tot_booking_amt += $tot_booking; $tot_agr = $tpr['agreement_amount2']; $tot_agr_amt += is_numeric($tot_agr); $tot_paid = $tpr['subtotal2']; $total_paid += $tot_paid; } $received_agr_amount = $tot_booking_amt+$tot_agr_amt; $received_reg_amount = $total_paid; $balance_agree_amount = $total_agreement_due_amount - $received_agreement_amount; $balance_reg_amount = $total_registration_due_amount - $received_registration_amount; $total_dimn_result = $this->gss_model->total_marketing_dimension_report($project); $booked_dimn_result = $this->gss_model->total_booked_dimension_report($project); /* if($balance_agree_amount) {*/ echo json_encode(array('result'=>1,'total_dimension'=>$total_dimn_result,'booked_dimnsion'=>$booked_dimn_result, 'balance_agreement_amount'=>$balance_agree_amount,'received_reg_amount'=>$received_reg_amount,'received_registration_amount'=>$received_registration_amount,'balance_reg_amount'=>$balance_reg_amount,'received_agreement_amount'=>$received_agreement_amount,'received_agr_amount'=>$received_agr_amount)); /*} else { echo json_encode(array('result'=>0, 'message'=>'NO data found')); } */ } /* public function get_booking_receipt_details() { $admin_id = session()->get('admin_id'); if($admin_id) { $booking_id = $this->uri->segment(2); $ack_no = $this->input->post('ack_no'); $booking_date1 = $this->input->post('booking_date1'); $booking_date2 = $this->input->post('booking_date2'); $booking_amount1 = $this->input->post('booking_amount1'); $booking_amount2 = $this->input->post('booking_amount2'); $booking_count1 = $this->input->post('booking_count'); $booking_count2 = $this->input->post('booking_count2'); if($booking_count2 == 0) { $booking_count1 = $this->input->post('booking_count'); } else { $booking_count1 = $this->input->post('booking_count2'); } $booking_payment_particulars1 = $this->input->post('booking_payment_particulars1'); $booking_payment_particulars2 = $this->input->post('booking_payment_particulars2'); $table ='gss_login'; $where = array('user_id'=>$admin_id); $user = $this->gss_model->get_where_row($table,$where); $user_email = $user->email; $where_b_id = array('booking_id'=>$booking_id); $booking_table = 'gss_bookings'; $client = $this->gss_model->get_where_row($booking_table,$where_b_id); $booking_detail_table = 'gss_booking_details'; $client_site = $this->gss_model->get_where_row($booking_detail_table,$where_b_id); $client_email = $client->email; $project_table = 'gss_new_projects'; $project_id = $client->project_id; $where_project = array('project_id'=>$project_id); $project = $this->gss_model->get_where_row($project_table,$where_project); $client_name = $client->customer_name; $project_name = $project->project_name; $site_number = $client_site->site_number; $particulars = $ack_no.', Payment Type towards '.$booking_count1; $subject = $project_name.', '.$site_number.' and '.$client_name.' - '.$particulars; $message = 'Dear '.$client_name.', Please find enclosed the Receipt Details of '.$booking_count1; if($message) { echo json_encode(array('result'=>'1','message'=>$message,'subject'=>$subject,'particulars'=>$particulars,'user_email'=>$user_email,'client_email'=>$client_email)); } else { echo json_encode(array('result'=>'0','message'=>'Something went wrong!')); } } else { redirect('/'); } }*/ public function send_mail_receipt() { $admin_id = session()->get('admin_id'); if($admin_id) { $booking_id = $this->input->post('booking_ids'); $receipt_type = $this->input->post('receipt_type'); $ack_no1 = $this->input->post('ack_no1'); $ack_no2 = $this->input->post('ack_no2'); if($ack_no2 == 0) { $ack_no1 = $this->input->post('ack_no1'); } else { $ack_no1 = $this->input->post('ack_no2'); } $booking_date1 = $this->input->post('booking_date1'); $booking_date2 = $this->input->post('booking_date2'); $booking_amount1 = $this->input->post('booking_amount1'); $booking_amount2 = $this->input->post('booking_amount2'); $booking_count1 = $this->input->post('booking_count'); $booking_count2 = $this->input->post('booking_count2'); if($booking_count2 == 0) { $booking_count1 = $this->input->post('booking_count'); } else { $booking_count1 = $this->input->post('booking_count2'); } $booking_payment_particulars1 = $this->input->post('booking_payment_particulars1'); $booking_payment_particulars2 = $this->input->post('booking_payment_particulars2'); $table ='gss_login'; $where = array('user_id'=>$admin_id); $user = $this->gss_model->get_where_row($table,$where); $logged_in_email = $user->email; $where_b_id = array('booking_id'=>$booking_id); $booking_table = 'gss_bookings'; $client = $this->gss_model->get_where_row($booking_table,$where_b_id); $booking_detail_table = 'gss_booking_details'; $client_site = $this->gss_model->get_where_row($booking_detail_table,$where_b_id); $client_email = $client->email; $project_table = 'gss_new_projects'; $project_id = $client->project_id; $where_project = array('project_id'=>$project_id); $project = $this->gss_model->get_where_row($project_table,$where_project); $land_owner = $project->land_owner_id; $address =$project->land_owner_address; $land_owner_table = 'gss_land_owners'; $where_land_owner = array('owner_id'=>$land_owner); $get_land_owner = $this->gss_model->get_where_row($land_owner_table,$where_land_owner); $land_owner_address = $get_land_owner->address; $client_name = $client->customer_name; $project_name = $project->project_name; $site_number = $client_site->site_number; $particulars = $ack_no1.', Payment Type towards '.$booking_count1; $subject = $project_name.', '.$site_number.' and '.$client_name.' - '.$particulars; $message = 'Dear '.$client_name.', Please find enclosed the Receipt Details of '.$booking_count1; $table = 'gss_email_details'; $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $created_at = $date->format('Y-m-d H:i:s'); $today = $date->format('d-m-Y'); $data = array('user_email'=>$logged_in_email, 'client_email' => $client_email, 'client_name' => $client_name, 'project_name' => $project_name, 'site_number' => $site_number, 'particulars' => $particulars, 'subject' => $subject, 'created_at' => $created_at, 'message' => $message); $insert_result = $this->gss_model->insert($table,$data); if($insert_result) { // include("assets/mpdf60/mpdf.php"); // $mpdf=new mPDF('A4'); // $mpdf->mirrorMargins = 1; $html = ''; $index = 1; if($receipt_type == 'GSS Project Consultants Pvt. Ltd.') { $email_content = ''; $email_content.= '<html>'; $email_content.= '<head>'; $email_content.= '</head>'; $email_content.= '<body style="width:900px;display:block;margin:auto !important; border-left:10px solid #E3000F;padding-left: 100px !important;padding-right: 100px !important;padding-top: 50px !important;padding-bottom: 50px !important;">'; $email_content.= '<div style="padding-bottom:10px;clear:both;">'; $email_content.= '<h2 style="text-align:center;padding-bottom:5px;">GSS Project Consultants Pvt. Ltd.</h2>'; $email_content.= '<img src="assets/images/header_line.png" style="display:block;margin:auto;padding-left:300px;">'; $email_content.= "<h2 style='font-size: 28px;line-height: 1.3;text-align:center;'>Project Name: $project_name <br>Address: $address"; $email_content.= '</div>'; $email_content.= '<div style="padding-bottom:15px;padding-top:15px;margin-bottom: 5px;position:relative;clear:both;">'; $email_content.= '<img src="assets/images/line.png" style="display:block;margin:auto;width: 100%;">'; $email_content.= '<div style="padding-top:10px;padding-bottom:10px;">'; $email_content.= '<table style="margin-bottom:0px !important;width:100%;">'; $email_content.= '<tr>'; /* $email_content.= "<td><p style='margin:0;font-size:18px;font-weight:bold;padding-top: 3px;'>Date: $today</p></td>";*/ $email_content.= '<td style="text-align:center;"><h3 style="margin-bottom:0px;margin-top:0px;text-align:center;color:#E40025;font-weight:bold;">RECEIPT</h3></td>'; //$email_content.= '<td style="text-align:right;"><p style="margin:0;font-size:18px;font-weight:bold;padding-top: 3px;">Receipt No: 1234</p></td>'; $email_content.= '</tr>'; $email_content.= '</table>'; $email_content.= '</div>'; $email_content.= '<img src="assets/images/line.png" style="display:block;margin:auto;width: 100%;">'; $email_content.= '</div>'; $email_content.= '<div style="padding-bottom:20px;clear:both;">'; $email_content.= '<div>'; $email_content.= '<table style="margin-bottom:0px !important;width:100%;">'; $email_content.= '<tr>'; $email_content.= "<td><p style='padding-left: 50px;margin:0;font-size:18px;font-weight:bold;padding-top: 3px;'>Client Name: $client_name</p></td>"; $email_content.= "<td><p style='padding-right:50px;margin:0;text-align:right;font-size:18px;font-weight:bold;padding-top: 3px;'>Site No: $site_number</p></td>"; $email_content.= '</tr>'; $email_content.= '</table>'; $email_content.= '</div>'; $email_content.= '</div>'; $email_content.= '<div style="clear:both;">'; $email_content.= '<table style="width:100%;border-collapse: collapse;border-color:red;" border="1">'; $email_content.= '<tr>'; $email_content.= '<td style="border: 3px solid #e40025 !important;padding:8px 5px;font-weight:bold;font-size:16px;text-align:center;">Payment Date</td>'; /* $email_content.= '<td style="border: 3px solid #e40025 !important;padding:8px 5px;font-weight:bold;font-size:16px;text-align:center;">Receipt No</td>';*/ $email_content.= '<td style="border: 3px solid #e40025 !important;padding:8px 5px;font-weight:bold;font-size:16px;text-align:center;">Amount</td>'; $email_content.= '<td style="border: 3px solid #e40025 !important;padding:8px 5px;font-weight:bold;font-size:16px;text-align:center;">Payment Type</td>'; $email_content.= '<td style="border: 3px solid #e40025 !important;padding:8px 5px;font-weight:bold;font-size:16px;text-align:center;">Particulars</td>'; $email_content.= '</tr>'; $email_content.= '<tr>'; $email_content.= "<td style='border: 3px solid #e40025 !important;padding:8px 5px;font-weight:bold;font-size:16px;text-align:center;'>$booking_date1</td>"; /*$email_content.= "<td style='border: 3px solid #e40025 !important;padding:8px 5px;font-weight:bold;font-size:16px;text-align:center;width:20%;'>$ack_no1</td>";*/ $email_content.= "<td style='border: 3px solid #e40025 !important;padding:8px 5px;font-weight:bold;font-size:16px;text-align:center;'>$booking_amount1</td>"; $email_content.= "<td style='border: 3px solid #e40025 !important;padding:8px 5px;font-weight:bold;font-size:16px;text-align:center;'>$booking_count1</td>"; $email_content.= "<td style='border: 3px solid #e40025 !important;padding:8px 5px;font-weight:bold;font-size:16px;text-align:center;'>$booking_payment_particulars1</td>"; $email_content.= '</tr>'; if($booking_date2 !== '') { $email_content.= '<tr>'; $email_content.= "<td style='border: 3px solid #e40025 !important;padding:8px 5px;font-weight:bold;font-size:16px;text-align:center;'>$booking_date2</td>"; /* $email_content.= "<td style='border: 3px solid #e40025 !important;padding:8px 5px;font-weight:bold;font-size:16px;text-align:center;width:20%;'>$ack_no2</td>";*/ $email_content.= "<td style='border: 3px solid #e40025 !important;padding:8px 5px;font-weight:bold;font-size:16px;text-align:center;'>$booking_amount2</td>"; $email_content.= "<td style='border: 3px solid #e40025 !important;padding:8px 5px;font-weight:bold;font-size:16px;text-align:center;'>$booking_count2</td>"; $email_content.= "<td style='border: 3px solid #e40025 !important;padding:8px 5px;font-weight:bold;font-size:16px;text-align:center;'>$booking_payment_particulars2</td>"; $email_content.= '</tr>'; } $email_content.= '</table>'; $email_content.= '<p style="text-align:center;font-weight:bold;font-size:18px;line-height:1.8;padding-top:15px;margin-bottom:4px;">(The validity of this receipt is subject to realization of all <br>cheques/demand draft/account transfer)</p>'; $email_content.= '<p style="text-align:center;font-weight:bold;font-size:18px;line-height:1.8;margin-top:4px;">This is a computer generated receipt. Signature is not required.</p>'; $email_content.= '</div>'; $email_content.= '<div class="row row_five" style="clear:both;padding-top:50px;">'; $email_content.= '<p style="margin-bottom:0px;margin-top:0px;font-size:18px;font-weight:bold;padding-top: 3px;">For GSS Project Consultants</p>'; $email_content.= '<p style="padding-left:30px;padding-top:50px;margin-bottom:0px;margin-top:0px;font-size:18px;font-weight:bold;">Authorized Signatory</p>'; $email_content.= '</div>'; $email_content.= '</body>'; $email_content.= '</html>'; } else { $email_content = ''; $email_content.= '<html>'; $email_content.= '<head>'; $email_content.= '</head>'; $email_content.= '<body style="width:900px;display:block;margin:auto !important; border-left:10px solid #E3000F !important;padding-left: 100px !important;padding-right: 100px !important;padding-top: 50px !important;padding-bottom: 50px !important;">'; $email_content.= '<div style="padding-bottom:10px;clear:both;">'; $email_content.= '<h2 style="text-align:center;padding-bottom:5px;">Acknowledgement</h2>'; $email_content.= '<img src="assets/images/header_line.png" style="display:block;margin:auto;padding-left:45%;">'; $email_content.= "<h2 style='font-size: 28px;line-height: 1.3;text-align:center;border-top:10px solid #E3000F !important;'>Project Name: $project_name <br>Address: $land_owner_address"; $email_content.= '</div>'; $email_content.= '<div style="padding-bottom:15px;padding-top:15px;margin-bottom: 5px;position:relative;clear:both;">'; $email_content.= '<img src="assets/images/line.png" style="display:block;margin:auto;width: 100%;">'; $email_content.= '<div style="padding-top:10px;padding-bottom:10px;">'; $email_content.= '<table style="margin-bottom:0px !important;width:100%;">'; $email_content.= '<tr>'; /* $email_content.= "<td><p style='margin:0;font-size:18px;font-weight:bold;padding-top: 3px;'>Date: $today</p></td>";*/ $email_content.= "<td><p style='padding-left: 50px;margin:0;font-size:18px;font-weight:bold;padding-top: 3px;'>Client Name: $client_name</p></td>"; $email_content.= "<td><p style='padding-right:50px;margin:0;text-align:right;font-size:18px;font-weight:bold;padding-top: 3px;'>Site No: $site_number</p></td>"; //$email_content.= '<td style="text-align:right;"><p style="margin:0;font-size:18px;font-weight:bold;padding-top: 3px;">Ack No: 01</p></td>'; $email_content.= '</tr>'; $email_content.= '</table>'; $email_content.= '</div>'; $email_content.= '<img src="assets/images/line.png" style="display:block;margin:auto;width: 100%;">'; $email_content.= '</div>'; /* $email_content.= '<div style="padding-bottom:20px;clear:both;">'; $email_content.= '<div>'; $email_content.= '<table style="margin-bottom:0px !important;width:100%;">'; $email_content.= '<tr>'; $email_content.= "<td><p style='padding-left: 50px;margin:0;font-size:18px;font-weight:bold;padding-top: 3px;'>Client Name: $client_name</p></td>"; $email_content.= "<td><p style='padding-right:50px;margin:0;text-align:right;font-size:18px;font-weight:bold;padding-top: 3px;'>Site No: $site_number</p></td>"; $email_content.= '</tr>'; $email_content.= '</table>'; $email_content.= '</div>'; $email_content.= '</div>';*/ $email_content.= '<div style="clear:both;">'; $email_content.= '<table style="width:100%;border-collapse: collapse;border-color:red;" border="1">'; $email_content.= '<tr>'; $email_content.= '<td style="border-top: 3px solid red !important;padding:8px 5px;font-weight:bold;font-size:16px;text-align:center;">Payment Date</td>'; /* $email_content.= '<td style="border: 3px solid #e40025 !important;padding:8px 5px;font-weight:bold;font-size:16px;text-align:center;">Ack No</td>';*/ $email_content.= '<td style="border: 3px solid #e40025 !important;padding:8px 5px;font-weight:bold;font-size:16px;text-align:center;">Amount</td>'; $email_content.= '<td style="border: 3px solid #e40025 !important;padding:8px 5px;font-weight:bold;font-size:16px;text-align:center;">Payment Type</td>'; $email_content.= '<td style="border: 3px solid #e40025 !important;padding:8px 5px;font-weight:bold;font-size:16px;text-align:center;">Particulars</td>'; $email_content.= '</tr>'; $email_content.= '<tr>'; $email_content.= "<td style='border: 3px solid #e40025 !important;padding:8px 5px;font-weight:bold;font-size:16px;text-align:center;'>$booking_date1</td>"; /* $email_content.= "<td style='border: 3px solid #e40025 !important;padding:8px 5px;font-weight:bold;font-size:16px;text-align:center;width:20%;'>$ack_no1</td>";*/ $email_content.= "<td style='border: 3px solid #e40025 !important;padding:8px 5px;font-weight:bold;font-size:16px;text-align:center;'>$booking_amount1</td>"; $email_content.= "<td style='border: 3px solid #e40025 !important;padding:8px 5px;font-weight:bold;font-size:16px;text-align:center;'>$booking_count1</td>"; $email_content.= "<td style='border: 3px solid #e40025 !important;padding:8px 5px;font-weight:bold;font-size:16px;text-align:center;'>$booking_payment_particulars1</td>"; $email_content.= '</tr>'; if($booking_date2 !== '') { $email_content.= '<tr>'; $email_content.= "<td style='border: 3px solid #e40025 !important;padding:8px 5px;font-weight:bold;font-size:16px;text-align:center;'>$booking_date2</td>"; /*$email_content.= "<td style='border: 3px solid #e40025 !important;padding:8px 5px;font-weight:bold;font-size:16px;text-align:center;'>$ack_no2</td>";*/ $email_content.= "<td style='border: 3px solid #e40025 !important;padding:8px 5px;font-weight:bold;font-size:16px;text-align:center;'>$booking_amount2</td>"; $email_content.= "<td style='border: 3px solid #e40025 !important;padding:8px 5px;font-weight:bold;font-size:16px;text-align:center;'>$booking_count2</td>"; $email_content.= "<td style='border: 3px solid #e40025 !important;padding:8px 5px;font-weight:bold;font-size:16px;text-align:center;'>$booking_payment_particulars2</td>"; $email_content.= '</tr>'; } $email_content.= '</table>'; $email_content.= '<p style="text-align:center;font-weight:bold;font-size:18px;line-height:1.8;padding-top:15px;margin-bottom:4px;">(The validity of this receipt is subject to realization of all <br>cheques/demand draft/account transfer)</p>'; $email_content.= '<p style="text-align:center;font-weight:bold;font-size:18px;line-height:1.8;margin-top:4px;">This is a computer generated receipt. Signature is not required.</p>'; $email_content.= '</div>'; $email_content.= '</body>'; $email_content.= '</html>'; } // $mpdf->SetDisplayMode('fullpage'); // $mpdf->watermark_font = 'DejaVuSansCondensed'; // $mpdf->showWatermarkText = true; // $mpdf->WriteHTML($email_content); require "vendor/autoload.php"; $mpdf = new \Mpdf\Mpdf(); $mpdf->WriteHTML($email_content); $name = 'client_receipt'.$insert_result.'.pdf'; $data = array('email_receipt'=>$name); $where = array('id'=>$insert_result); $result = $this->gss_model->update($where,$table,$data); $pdf = $mpdf->Output("./email_receipts/".$name, 'F'); if($this->db->affected_rows() > 0) { echo json_encode(array('result'=>1 ,'message'=>$insert_result)); } else { echo json_encode(array('result'=>0,'message'=>"Data could not be added")); } } else { echo json_encode(array('result'=>0,'message'=>"Data could not be added")); } //$this->load->view('admin/send_email',$data); } else { redirect('/'); } } public function view_mail_content() { $admin_id = session()->get('admin_id'); if($admin_id) { $id = $this->uri->segment(2); $table = 'gss_email_details'; $where = array('id'=>$id); $data['details'] = $this->gss_model->get_where_row($table,$where); $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $this->load->view('admin/send_email',$data); } else { redirect('/'); } } public function send_receipt_email() { $admin_id = session()->get('admin_id'); if($admin_id) { $id = $this->input->post('id'); $to = $this->input->post('to'); $table = 'gss_email_details'; $where = array('id'=>$id); $details = $this->gss_model->get_where_row($table,$where); $data = array('client_email'=>$to); $update = $this->gss_model->update($where,$table,$data); $user_email = $details->user_email; $client_email = $details->client_email; $subject = $details->subject; $login_table = 'gss_login'; $where_login = array('user_id'=>$admin_id); $get_sign = $this->gss_model->get_where_row($login_table,$where_login); $email = $get_sign->email; $mail_password =$get_sign->mail_password; $sign = $get_sign->signature; $base_url = base_url(); $message = $details->message; $message .= '<br>'; $message .= '<br>'; $message .= 'Thanks and regards,<br>'; $message .= '<br>'; $message .= "<img src='".$base_url."assets/images/gss_logo.jpg' style='width:20%'>"; $message .= '<br>'; $message .= $sign; // $body = $message; $file = $details->email_receipt; $this->load->library('email'); // $config = array( // 'protocol' => 'smtp', // 'smtp_host' => 'ssl://smtp.googlemail.com', // 'smtp_port' => 465, // 'smtp_user' => 'gssorganised@gmail.com', // 'smtp_pass' => 'GSSKarthi@1236#', // 'mailtype' => 'html', // 'charset' => 'utf-8' // ); // $this->email->initialize($config); // $this->email->set_mailtype("html"); // $this->email->set_newline("\r\n"); // $this->email->from($user_email,'GSS'); // change it to yours // $this->email->to($client_email,'GSS');// change it to yours // $this->email->subject($subject); // $this->email->message($message); // $this->email->attach('./email_receipts/'.$file); require_once './email/PHPMailerAutoload.php'; $phpMailer = new PHPMailer(true); //$phpMailer->isSMTP(); $phpMailer->Host = "ssl://smtp.googlemail.com"; $phpMailer->SMTPAuth = true; $phpMailer->Username = "gssorganised@gmail.com"; $phpMailer->Password = "GSSKarthi@1236#"; $phpMailer->SMTPSecure = "tls"; $phpMailer->Port = 587; $phpMailer->isHTML(true); $phpMailer->CharSet = "UTF-8"; $phpMailer->setFrom($user_email, "GSS"); $phpMailer->addAddress($client_email); //$phpMailer->addAddress('sowmyayp@gmail.com'); $phpMailer->Subject = $subject; $phpMailer->Body = $message; //$phpMailer->AddCC('sowmyashreelr@gmail'); $phpMailer->AddCC($email); $phpMailer->addAttachment('./email_receipts/'.$file); if ($phpMailer->send()) { echo json_encode(array('result'=>1,'message'=>'Your Email has successfully been sent.')); } else { echo json_encode(array('result'=>0,'message'=>'Something Went Wrong!')); show_error($this->email->print_debugger()); } } else { redirect('/'); } } public function send_site_reports() { $admin_id = session()->get('admin_id'); if($admin_id) { $project_id = $this->input->post('project_id'); $site_number = $this->input->post('site_number'); $booking_id = $this->input->post('booking_id'); $total_amount_1 = $this->input->post('total_amount_1'); $balance_amount_1 = $this->input->post('balance_amount_1'); $table ='gss_login'; $where = array('user_id'=>$admin_id); $user = $this->gss_model->get_where_row($table,$where); $logged_in_email = $user->email; $where_b_id = array('booking_id'=>$booking_id); $booking_table = 'gss_bookings'; $client = $this->gss_model->get_where_row($booking_table,$where_b_id); $booking_detail_table = 'gss_booking_details'; $client_site = $this->gss_model->get_where_row($booking_detail_table,$where_b_id); $client_email = $client->email; $project_table = 'gss_new_projects'; $project_id = $client->project_id; $where_project = array('project_id'=>$project_id); $project = $this->gss_model->get_where_row($project_table,$where_project); $land_owner = $project->land_owner_id; $land_owner_table = 'gss_land_owners'; $where_land_owner = array('owner_id'=>$land_owner); $get_land_owner = $this->gss_model->get_where_row($land_owner_table,$where_land_owner); $land_owner_address = $get_land_owner->address; $client_name = $client->customer_name; $project_name = $project->project_name; $site_number = $client_site->site_number; $particulars = 'Site Details Report'; $subject = $project_name.', '.$site_number.' and '.$client_name.' - '.$particulars; $message = 'Dear '.$client_name.', Please find enclosed the Receipt Details of '.$particulars; $table = 'gss_email_details'; $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $created_at = $date->format('Y-m-d H:i:s'); $today = $date->format('d-m-Y'); $details = $this->gss_model->test($project_id,$site_number); if(empty($details)) { $data['bookin_details']=''; $data['payment_list']=''; $data['cancellation']=''; $data['payment_ind'] =''; $data['tsv_list'] =''; $data['without_install'] =''; $data['without_agree'] =''; ?> <script>alert('This Site is Not Booked'); window.location = '<?php echo site_url("reports")?>'; </script> <?php } else { $bookin_details = $details; $booking_id = $bookin_details->booking_id; //$data['payment'] = $this->gss_model->payment_details($booking_id); $payment_ind = $this->gss_model->payment_ind($booking_id); if(!empty($payment_ind->sales_agreement_due_date)) { $sales_agreement_due_date = date("d-m-Y", strtotime($payment_ind->sales_agreement_due_date)); } else { $sales_agreement_due_date = ""; } if(!empty($payment_ind->installment_due_date)) { $installment_due_date = date("d-m-Y", strtotime($payment_ind->installment_due_date)); } else { $installment_due_date = ""; } if(!empty($payment_ind->registration_due_date)) { $registration_due_date = date("d-m-Y", strtotime($payment_ind->registration_due_date)); } else { $registration_due_date=""; } $payment = $this->gss_model->payment_details($booking_id); $data['payment_list'] = $this->gss_model->payment_detailsgroup($booking_id); $without_install = $this->gss_model->payment_withoutinstall($booking_id); $without_agree = $this->gss_model->payment_withoutagree($booking_id); $data['tsv_list'] = $this->gss_model->payment_details_ind($booking_id); $data['cancellation'] = $this->gss_model->get_cancellation_types_result($booking_id); $data['commission'] = $this->gss_model->commission($booking_id); $data['user'] = $this->gss_model->single_user_account_management_list($booking_id); $tbale='gss_registration_amount_details'; $condition=array('booking_id'=>$booking_id,'delete_status'=>'ACTIVE'); $get_reg_amt=$this->gss_model->get_where_result($tbale,$condition); if($get_reg_amt) { $data['get_reg_amt']=$get_reg_amt; } else { $data['get_reg_amt']=''; } } $num= $bookin_details->tsv;$explrestunits = "" ; if(strlen($num)>3) { $lastthree = substr($num, strlen($num)-3, strlen($num)); $restunits = substr($num, 0, strlen($num)-3); // extracts the last three digits $restunits = (strlen($restunits)%2 == 1)?"0".$restunits:$restunits; // explodes the remaining digits in 2's formats, adds a zero in the beginning to maintain the 2's grouping. $expunit = str_split($restunits, 2); for($i=0; $i<sizeof($expunit); $i++) { // creates each of the 2's group and adds a comma to the end if($i==0) { $explrestunits .= (int)$expunit[$i].","; // if is first value , convert into integer } else { $explrestunits .= $expunit[$i].","; } } $tsv_total = $explrestunits.$lastthree; } else { $tsv_total = $num; } $tsv = $tsv_total; $site_no=$site_number ; $number = ""; $mode_date = ""; $bank = ""; $data = array('user_email'=>$logged_in_email, 'client_email' => $client_email, 'client_name' => $client_name, 'project_name' => $project_name, 'site_number' => $site_number, 'particulars' => $particulars, 'subject' => $subject, 'created_at' => $created_at, 'message' => $message); $insert_result = $this->gss_model->insert($table,$data); if($insert_result) { // include("assets/mpdf60/mpdf.php"); // $mpdf=new mPDF('A4'); // $mpdf->mirrorMargins = 1; require "vendor/autoload.php"; $mpdf = new \Mpdf\Mpdf(); $html = ''; $index = 1; /*$email_content = ''; $email_content = ""; $email_content.= '<html>'; $email_content.= '<head>'; $email_content.= '</head>'; $email_content.= '<body style="width:900px;display:block;margin:auto !important; border-left:10px solid #E3000F;padding-left: 100px !important;padding-right: 100px !important;padding-top: 50px !important;padding-bottom: 50px !important;">'; $email_content.= '<div style="padding-bottom:10px;clear:both;">'; $email_content.= '<h2 style="text-align:center;padding-bottom:5px;">GSS</h2>'; $email_content.= '<img src="/gss/assets/images/header_line.png" style="display:block;margin:auto;">'; $email_content.= "<h2 style='font-size: 28px;line-height: 1.3;text-align:center;'>Project Name: $project_name <br>Address: $land_owner_address"; $email_content.= '</div>';*/ $email_content = ''; $email_content.= '<html>'; $email_content.= '<head>'; $email_content.= '</head>'; $email_content.= '<body style="width:900px;display:block;margin:auto !important; border-left:10px solid #E3000F !important;padding-left: 100px !important;padding-right: 100px !important;padding-top: 50px !important;padding-bottom: 50px !important;">'; $email_content.= '<div style="padding-bottom:10px;clear:both;">'; if($get_land_owner->name == 'GSS Project Consultants') { $email_content.= '<h2 style="text-align:center;padding-bottom:5px;">GSS Project Consultants Pvt. Ltd.</h2>'; } else { $email_content.= '<h2 style="text-align:center;padding-bottom:5px;">Acknowledgement</h2>'; } $email_content.= '<img src="assets/images/header_line.png" style="display:block;margin:auto;padding-left:45%;">'; $email_content.= "<h2 style='font-size: 28px;line-height: 1.3;text-align:center;border-top:10px solid #E3000F !important;'>Project Name: $project_name <br>Address: $land_owner_address"; $email_content.= '</div>'; $email_content.= '<div style="padding-bottom:15px;padding-top:15px;margin-bottom: 5px;position:relative;clear:both;">'; $email_content.= '<img src="assets/images/line.png" style="display:block;margin:auto;width: 100%;">'; $email_content.= '<div style="padding-top:10px;padding-bottom:10px;">'; $email_content.= '<table style="width:100%;border-collapse: collapse;border-color:red;" border="1">'; $email_content.= '<tr>'; $email_content.= "<td><p style='margin:0;font-size:18px;font-weight:bold;padding-top: 3px;'>Date: $today</p></td>"; $email_content.= "<td><h3 style='margin-bottom:0px;margin-top:0px;text-align:center;color:#E40025;font-weight:bold;'><p>TSV: $tsv</p></h3></td>"; $email_content.= '</tr>'; $email_content.= '</table>'; $email_content.= '</div>'; $email_content.= '<img src="assets/images/line.png" style="display:block;margin:auto;width: 100%;">'; $email_content.= '</div>'; $email_content.= '<div style="padding-bottom:20px;clear:both;">'; $email_content.= '<div>'; $email_content.= '<table style="width:100%;border-collapse: collapse;border-color:red;" border="1">'; $email_content.= '<tr>'; $email_content.= "<td><p style='padding-left: 50px;margin:0;font-size:18px;font-weight:bold;padding-top: 3px;'>Client Name: $client_name</p></td>"; $email_content.= "<td><p style='padding-right:50px;margin:0;text-align:right;font-size:18px;font-weight:bold;padding-top: 3px;'>Site No: $site_no</p></td>"; $email_content.= '</tr>'; $email_content.= '</table>'; $email_content.= '</div>'; $email_content.= '</div>'; $email_content.= '<h3 style="margin-left:6%;">Received Details</h3>'; $total=0; if($without_agree->booking_amount1 >0) { $without_agree->booking_amount1; $num=$without_agree->booking_amount1; $explrestunits = "" ; if(strlen($num)>3) { $lastthree = substr($num, strlen($num)-3, strlen($num)); $restunits = substr($num, 0, strlen($num)-3); // extracts the last three digits $restunits = (strlen($restunits)%2 == 1)?"0".$restunits:$restunits; // explodes the remaining digits in 2's formats, adds a zero in the beginning to maintain the 2's grouping. $expunit = str_split($restunits, 2); for($i=0; $i<sizeof($expunit); $i++) { // creates each of the 2's group and adds a comma to the end if($i==0) { $explrestunits .= (int)$expunit[$i].","; // if is first value , convert into integer } else { $explrestunits .= $expunit[$i].","; } $thecash = $explrestunits.$lastthree; } } else { $thecash = $num; } $total=$total+$num; } $booking_particularss2 = ''; $booking_date1 =""; if(!empty($without_agree->booking_date1)) { $booking_date1 = date("d-m-Y", strtotime($without_agree->booking_date1)); } else { $booking_date1 =""; } $booking_particularss = $without_agree->booking_payment_type; if($booking_particularss == "Online Payment") { $booking_particulars = 'NEFT / RTGS'; } else if($booking_particularss == "Paytm Payment") { $booking_particulars = 'UPI / Direct payment'; } else if($booking_particularss == "UPI Payment") { $booking_particulars = 'Credit / debit Payment'; } else { $booking_particulars = $booking_particularss; } if($booking_particularss == "Cheque") { $number = $without_agree->check_no; $mode_date = date("d-m-Y", strtotime($without_agree->check_date)); $bank =$without_agree->bank_name; //$b_particulars = 'Payment Mode: Cheque, No: '.$number.', Date: '.$mode_date.', Bank: '.$bank; $b_particulars1 = 'Payment Mode: Cheque'; $b_particulars11 = ' No: '.$number; $b_particulars12 = 'Date: '.$mode_date; $b_particulars13= 'Bank: '.$bank; } else if($booking_particularss == "Online Payment") { $number = $without_agree->vtr_no; $mode_date = date("d-m-Y", strtotime($without_agree->online_date)); $bank = ''; //$b_particulars = 'Payment Mode: NEFT/RTGS, No: '.$number.', Date: '.$mode_date; $b_particulars1 = 'Payment Mode: NEFT/RTGS'; $b_particulars11 = 'No: '.$number; $b_particulars12 = 'Date: '.$mode_date; $b_particulars13 =''; } else if($booking_particularss == "DD") { $number = $without_agree->dd_no; $mode_date = date("d-m-Y", strtotime($without_agree->dd_date)); $bank = $without_agree->dd_bank; //$b_particulars = 'Payment Mode: DD, No: '.$number.', Date: '.$mode_date.', Bank: '.$bank; $b_particulars1 = 'Payment Mode: DD'; $b_particulars11 = 'No: '.$number; $b_particulars12 = 'Date: '.$mode_date; $b_particulars13 = ' Bank: '.$bank; } else if($booking_particularss == "Paytm Payment") { $number = $without_agree->paytm_ref_no; $mode_date = date("d-m-Y", strtotime($without_agree->paytm_online_date)); $bank = ''; //$b_particulars = 'Payment Mode: UPI / Direct Payment, No: '.$number.', Date: '.$mode_date; $b_particulars1 = 'Payment Mode: UPI / Direct Payment'; $b_particulars11 = 'No: '.$number; $b_particulars12 = ' Date: '.$mode_date; $b_particulars13 = ''; } else if($booking_particularss == "UPI Payment") { $number = $without_agree->upi_ref_no; $mode_date = date("d-m-Y", strtotime($without_agree->upi_online_date)); $bank = ''; //$b_particulars = 'Payment Mode: Credit / Debit Payment , No: '.$number.', Date: '.$mode_date; $b_particulars1 = 'Payment Mode: Credit / Debit Payment'; $b_particulars11 = 'No: '.$number; $b_particulars12 = 'Date: '.$mode_date; $b_particulars13 = ''; } else if($booking_particularss == "Cash") { $b_particulars1 = 'Cash' ; $b_particulars11 =''; $b_particulars12 =''; $b_particulars13 =''; } else if($booking_particularss == "Swipe") { $b_particulars1 = 'Swipe' ; $b_particulars11 =''; $b_particulars12 =''; $b_particulars13 =''; } $total=0; if($without_agree->booking_amount2 >0) { $without_agree->booking_amount2; $num=$without_agree->booking_amount2; $explrestunits = "" ; if(strlen($num)>3) { $lastthree = substr($num, strlen($num)-3, strlen($num)); $restunits = substr($num, 0, strlen($num)-3); // extracts the last three digits $restunits = (strlen($restunits)%2 == 1)?"0".$restunits:$restunits; // explodes the remaining digits in 2's formats, adds a zero in the beginning to maintain the 2's grouping. $expunit = str_split($restunits, 2); for($i=0; $i<sizeof($expunit); $i++) { // creates each of the 2's group and adds a comma to the end if($i==0) { $explrestunits .= (int)$expunit[$i].","; // if is first value , convert into integer } else { $explrestunits .= $expunit[$i].","; } $thecash1 = $explrestunits.$lastthree; } } else { $thecash1 = $num; } $total=$total+$num; } $booking_date2=""; if(!empty($without_agree->booking_date2)) { if($booking_date2 != '30-11-0001') { $booking_date2 = date("d-m-Y", strtotime($without_agree->booking_date2)); } } else { $booking_date2=""; } $booking_particularss2 = $without_agree->booking_payment_type2; if($booking_particularss2 == "Online Payment") { $booking_particulars2 = 'NEFT / RTGS'; } else if($booking_particularss2 == "Paytm Payment") { $booking_particulars2 = 'UPI / Direct Payment'; } else if($booking_particularss2 == "UPI Payment") { $booking_particulars2 = 'Credit / Debit payment'; } else { $booking_particulars2 = $booking_particularss2; } if($booking_particularss2 == "Cheque") { $number = $without_agree->check_no2; $mode_date = date("d-m-Y", strtotime($without_agree->check_date2)); $bank =$without_agree->bank_name2; //$b_particulars2 = 'Payment Mode: Cheque, No: '.$number.', Date: '.$mode_date.', Bank: '.$bank; $b_particulars2 = 'Payment Mode: Cheque'; $b_particulars21 = 'No: '.$number; $b_particulars22 = 'Date: '.$mode_date; $b_particulars23= 'Bank: '.$bank; } else if($booking_particularss2 == "Online Payment") { $number = $without_agree->vtr_no2; $mode_date = date("d-m-Y", strtotime($without_agree->online_date2)); $bank = ''; //$b_particulars2 = 'Payment Mode: NEFT/RTGS, No: '.$number.', Date: '.$mode_date; $b_particulars2 = 'Payment Mode: NEFT/RTGS'; $b_particulars21 = 'No: '.$number; $b_particulars22 = 'Date: '.$mode_date; $b_particulars23 =''; } else if($booking_particularss2 == "DD") { $number = $without_agree->dd_no2; $mode_date = date("d-m-Y", strtotime($without_agree->dd_date2)); $bank = $without_agree->dd_bank2; $b_particulars2 = 'Payment Mode: DD, No: '.$number.', Date: '.$mode_date.', Bank: '.$bank; $b_particulars2 = 'Payment Mode: DD'; $b_particulars21 = 'No: '.$number; $b_particulars22 = 'Date: '.$mode_date; $b_particulars23 = ' Bank: '.$bank; } else if($booking_particularss2 == "Paytm Payment") { $number = $without_agree->paytm_ref_no2; $mode_date = date("d-m-Y", strtotime($without_agree->paytm_online_date2)); $bank = ''; //$b_particulars2 = 'Payment Mode: UPI / Direct Payment, No: '.$number.', Date: '.$mode_date; $b_particulars2 = 'Payment Mode: UPI / Direct Payment'; $b_particulars21 = 'No: '.$number; $b_particulars22 = 'Date: '.$mode_date; $b_particulars23 = ''; } else if($booking_particularss2 == "UPI Payment") { $number = $without_agree->upi_ref_no2; $mode_date = date("d-m-Y", strtotime($without_agree->upi_online_date2)); $bank = ''; //$b_particulars2 = 'Payment Mode: Credit / Debit Payment, No: '.$number.', Date: '.$mode_date; $b_particulars2 = 'Payment Mode: Credit / Debit Payment'; $b_particulars21 = 'No: '.$number; $b_particulars22 = 'Date: '.$mode_date; $b_particulars23 = ''; } else if($booking_particularss2 == "Cash") { //$b_particulars2 = 'Cash' ; $b_particulars2 = 'Cash' ; $b_particulars21 =''; $b_particulars22 =''; $b_particulars23 =''; } else if($booking_particularss2 == "Swipe") { $b_particulars2 = 'Swipe' ; $b_particulars21 =''; $b_particulars22 =''; $b_particulars23 =''; } // Booking // $email_content.= '<div style="clear:both;">'; $email_content.= '<table style="width:100%;border-collapse: collapse;border-color:red;" border="1">'; $email_content.= '<tr>'; $email_content.= '<td style="border: 3px solid #e40025 !important;padding:8px 5px;font-weight:bold;font-size:16px;text-align:center;">Booking Date</td>'; $email_content.= '<td style="border: 3px solid #e40025 !important;padding:8px 5px;font-weight:bold;font-size:16px;text-align:center;">Booking Amount</td>'; $email_content.= '<td style="border: 3px solid #e40025 !important;padding:8px 5px;font-weight:bold;font-size:16px;text-align:center;">Particulars</td>'; $email_content.= '</tr>'; $email_content.= '<tr>'; $email_content.= "<td style='border: 3px solid #e40025 !important;padding:8px 5px;font-weight:bold;font-size:16px;text-align:center;'>$booking_date1</td>"; $email_content.= "<td style='border: 3px solid #e40025 !important;padding:8px 5px;font-weight:bold;font-size:16px;text-align:center;'>Rs. $thecash /-</td>"; $email_content.= "<td style='border: 3px solid #e40025 !important;padding:8px 5px;font-weight:bold;font-size:16px;text-align:center;'> <p>$b_particulars1</p> <p>$b_particulars11</p> <p>$b_particulars12</p> <p>$b_particulars13</p> </td>"; $email_content.= '</tr>'; if($without_agree->booking_amount2 != 0) { $email_content.= '<tr>'; $email_content.= "<td style='border: 3px solid #e40025 !important;padding:8px 5px;font-weight:bold;font-size:16px;text-align:center;'>$booking_date2</td>"; $email_content.= "<td style='border: 3px solid #e40025 !important;padding:8px 5px;font-weight:bold;font-size:16px;text-align:center;'>Rs. $thecash1 /-</td>"; $email_content.= "<td style='border: 3px solid #e40025 !important;padding:8px 5px;font-weight:bold;font-size:16px;text-align:center;'><p>$b_particulars2</p> <p>$b_particulars21</p> <p>$b_particulars22</p> <p>$b_particulars23</p></td>"; $email_content.= '</tr>'; } $email_content.= '</table>'; $email_content.= '</div>'; $email_content.= '<br>'; $email_content.= '<br>'; // Agreement // if(empty($without_install)) { } else { if( $without_install->agreement_amount != 0 || $without_install->agreement_payment_mode != 0) { $without_install->agreement_amount; $num=$without_install->agreement_amount;$explrestunits = "" ; if(strlen($num)>3) { $lastthree = substr($num, strlen($num)-3, strlen($num)); $restunits = substr($num, 0, strlen($num)-3); // extracts the last three digits $restunits = (strlen($restunits)%2 == 1)?"0".$restunits:$restunits; // explodes the remaining digits in 2's formats, adds a zero in the beginning to maintain the 2's grouping. $expunit = str_split($restunits, 2); for($i=0; $i<sizeof($expunit); $i++) { // creates each of the 2's group and adds a comma to the end if($i==0) { $explrestunits .= (int)$expunit[$i].","; // if is first value , convert into integer } else { $explrestunits .= $expunit[$i].","; } } $thecash = $explrestunits.$lastthree; } else { $thecash = $num; } $total=$total+$num; } } $agreement_date = date("d-m-Y", strtotime($without_install->agreement_date)); $agreement_particularss = $without_install->agreement_payment_mode; if($agreement_particularss == "Online Payment") { $agreement_particulars = 'NEFT / RTGS'; } else if($agreement_particularss == "Paytm Payment") { $agreement_particulars = 'UPI / Direct Payment'; } else if($agreement_particularss == "UPI Payment") { $agreement_particulars = 'Credit / Debit Payment'; } else { $agreement_particulars = $agreement_particularss; } if($agreement_particularss == "Cheque") { $number = $without_install->agreement_cheque_no; $mode_date = date("d-m-Y", strtotime($without_install->agreement_cheque_date)); $bank =$without_install->agreement_bank; //$a_particulars = 'Payment Mode: Cheque, No: '.$number.', Date: '.$mode_date.', Bank: '.$bank; $a_particulars = 'Payment Mode: Cheque'; $a_particulars1 = 'No: '.$number; $a_particulars2 = 'Date: '.$mode_date; $a_particulars3= ' Bank: '.$bank; } else if($agreement_particularss == "Online Payment") { $number = $without_install->agreement_vtr_no; $mode_date = date("d-m-Y", strtotime($without_install->agreement_online_date)); $bank = ''; //$a_particulars = 'Payment Mode: NEFT/RTGS, No: '.$number.', Date: '.$mode_date; $a_particulars = 'Payment Mode: NEFT/RTGS'; $a_particulars1 = 'No: '.$number; $a_particulars2 = 'Date: '.$mode_date; $a_particulars3= ''; } else if($agreement_particularss == "DD") { $number = $without_install->agreement_dd_no; $mode_date = date("d-m-Y", strtotime($without_install->agreement_dd_date)); $bank = $without_install->agreement_dd_bank; //$a_particulars = 'Payment Mode: DD, No: '.$number.', Date: '.$mode_date; $a_particulars = 'Payment Mode: DD'; $a_particulars1 = 'No: '.$number; $a_particulars2 = 'Date: '.$mode_date; $a_particulars3= ' Bank: '.$bank; } else if($agreement_particularss == "Paytm Payment") { $number = $without_install->agreementpaytm_ref_no; $mode_date = date("d-m-Y", strtotime($without_install->agreementpaytm_online_date1)); $bank = ''; //$a_particulars = 'Payment Mode: UPI / Direct Payment, No: '.$number.', Date: '.$mode_date; $a_particulars = 'Payment Mode: UPI / Direct Payment'; $a_particulars1 = 'No: '.$number; $a_particulars2 = 'Date: '.$mode_date; $a_particulars3= ''; } else if($agreement_particularss == "UPI Payment") { $number = $without_install->agreementupi_online_date1; $mode_date = date("d-m-Y", strtotime($without_install->agreementupi_ref_no)); $bank = ''; //$a_particulars = 'Payment Mode: Credit / Debit Payment, No: '.$number.', Date: '.$mode_date; $a_particulars = 'Payment Mode: Credit / Debit Payment'; $a_particulars1 = 'No: '.$number; $a_particulars2 = 'Date: '.$mode_date; $a_particulars3= ''; } else if($agreement_particularss == "Cash") { $a_particulars = 'Cash' ; $a_particulars1= ''; $a_particulars2= ''; $a_particulars3= ''; } else if($agreement_particularss == "Swipe") { $a_particulars = 'Swipe' ; $a_particulars1= ''; $a_particulars2= ''; $a_particulars3= ''; } $email_content.= '<div style="clear:both;">'; $email_content.= '<table style="width:100%;border-collapse: collapse;border-color:red;" border="1">'; $email_content.= '<tr>'; $email_content.= '<td style="border: 3px solid #e40025 !important;padding:8px 5px;font-weight:bold;font-size:16px;text-align:center;">Agreement Date</td>'; $email_content.= '<td style="border: 3px solid #e40025 !important;padding:8px 5px;font-weight:bold;font-size:16px;text-align:center;">Agreement Amount</td>'; $email_content.= '<td style="border: 3px solid #e40025 !important;padding:8px 5px;font-weight:bold;font-size:16px;text-align:center;">Particulars</td>'; $email_content.= '</tr>'; $email_content.= '<tr>'; $email_content.= "<td style='border: 3px solid #e40025 !important;padding:8px 5px;font-weight:bold;font-size:16px;text-align:center;'>$agreement_date</td>"; $email_content.= "<td style='border: 3px solid #e40025 !important;padding:8px 5px;font-weight:bold;font-size:16px;text-align:center;'>Rs. $thecash /-</td>"; $email_content.= "<td style='border: 3px solid #e40025 !important;padding:8px 5px;font-weight:bold;font-size:16px;text-align:center;'> <p>$a_particulars</p> <p>$a_particulars1</p> <p>$a_particulars2</p> <p>$a_particulars3</p> </td>"; $email_content.= '</tr>'; $email_content.= '</table>'; $email_content.= '</div>'; $email_content.= '<br>'; $email_content.= '<br>'; // Installment // $i = 1; if(empty($payment)) { } else { $h=1; foreach($payment as $payment) { if($payment->installment_amount1 != 0 || $payment->installment_payment_mode1 != 0) { $payment->installment_amount1; $num=$payment->installment_amount1; $explrestunits = "" ; if(strlen($num)>3) { $lastthree = substr($num, strlen($num)-3, strlen($num)); $restunits = substr($num, 0, strlen($num)-3); // extracts the last three digits $restunits = (strlen($restunits)%2 == 1)?"0".$restunits:$restunits; // explodes the remaining digits in 2's formats, adds a zero in the beginning to maintain the 2's grouping. $expunit = str_split($restunits, 2); for($i=0; $i<sizeof($expunit); $i++) { // creates each of the 2's group and adds a comma to the end if($i==0) { $explrestunits .= (int)$expunit[$i].","; // if is first value , convert into integer } else { $explrestunits .= $expunit[$i].","; } } $thecash = $explrestunits.$lastthree; } else { $thecash = $num; } $total=$total+$num; $installment1_date = date("d-m-Y", strtotime($payment->installment1_date)); $installment_particularss = $payment->installment_payment_mode1; if($installment_particularss == "Online Payment") { $installment_particulars = 'NEFT / RTGS'; } else if($installment_particularss == "Paytm Payment") { $installment_particulars = 'UPI / Direct Payment'; } else if($installment_particularss == "UPI Payment") { $installment_particulars = 'Credit / Debit Payment'; } else { $installment_particulars = $installment_particularss; } if($installment_particularss == "Cheque") { $number = $payment->install_cheque_no1; $mode_date = date("d-m-Y", strtotime($payment->install_cheque_date1)); $bank =$payment->install_bank1; //$i_particulars = 'Payment Mode: Cheque, No: '.$number.', Date: '.$mode_date.', Bank: '.$bank; $i_particulars1 = 'Payment Mode: UPI / Direct Payment'; $i_particulars11 = 'No: '.$number; $i_particulars12 = 'Date: '.$mode_date; $i_particulars13= 'Bank: '.$bank; } else if($installment_particularss == "Online Payment") { $number = $payment->install_vtr_no1; $mode_date = date("d-m-Y", strtotime($payment->install_online_date1)); $bank = ''; //$i_particulars = 'Payment Mode: NEFT/RTGS, No: '.$number.', Date: '.$mode_date; $i_particulars1 = 'Payment Mode: NEFT/RTGS'; $i_particulars11 = ' No: '.$number; $i_particulars12 = 'Date: '.$mode_date; $i_particulars13= ''; } else if($installment_particularss == "DD") { $number = $payment->install_dd_no1; $mode_date = date("d-m-Y", strtotime($payment->install_dd_date1)); $bank = $payment->install_dd_bank1; //$i_particulars = 'Payment Mode: DD, No: '.$number.', Date: '.$mode_date.', Bank: '.$bank; $i_particulars1 = 'Payment Mode: DD'; $i_particulars11 = ' No: '.$number; $i_particulars12 = 'Date: '.$mode_date; $i_particulars13= ' Bank: '.$bank; } else if($installment_particularss == "Paytm Payment") { $number = $payment->paytm_num; $mode_date = date("d-m-Y", strtotime($payment->paytm_date)); $bank = ''; //$i_particulars = 'Payment Mode: UPI / Direct Payment, No: '.$number.', Date: '.$mode_date; $i_particulars1 = 'Payment Mode: UPI / Direct Payment'; $i_particulars11 = ' No: '.$number; $i_particulars12 = 'Date: '.$mode_date; $i_particulars13= ''; } else if($installment_particularss == "UPI Payment") { $number = $payment->upi_num; $mode_date = date("d-m-Y", strtotime($payment->upi_date)); $bank = ''; //$i_particulars = 'Payment Mode: Credit / Debit Payment, No: '.$number.', Date: '.$mode_date; $i_particulars1 = 'Payment Mode: Credit / Debit Payment'; $i_particulars11 = ' No: '.$number; $i_particulars12 = 'Date: '.$mode_date; $i_particulars13= ''; } else if($installment_particularss == "Cash") { $i_particulars1 = 'Cash'; $i_particulars11 = ''; $i_particulars12 = ''; $i_particulars13= ''; } else if($installment_particularss == "Swipe") { $i_particulars1 = 'Swipe'; $i_particulars11 = ''; $i_particulars12 = ''; $i_particulars13= ''; } $email_content.= '<div style="clear:both;">'; $email_content.= '<table style="width:100%;border-collapse: collapse;border-color:red;" border="1">'; $email_content.= '<tr>'; $email_content.= '<td style="border: 3px solid #e40025 !important;padding:8px 5px;font-weight:bold;font-size:16px;text-align:center;">Sl No.</td>'; $email_content.= '<td style="border: 3px solid #e40025 !important;padding:8px 5px;font-weight:bold;font-size:16px;text-align:center;">Installment Date</td>'; $email_content.= '<td style="border: 3px solid #e40025 !important;padding:8px 5px;font-weight:bold;font-size:16px;text-align:center;">Installment Amount</td>'; $email_content.= '<td style="border: 3px solid #e40025 !important;padding:8px 5px;font-weight:bold;font-size:16px;text-align:center;">Particulars</td>'; $email_content.= '</tr>'; $email_content.= '<tr>'; $email_content.= "<td style='border: 3px solid #e40025 !important;padding:8px 5px;font-weight:bold;font-size:16px;text-align:center;'>$h</td>"; $email_content.= "<td style='border: 3px solid #e40025 !important;padding:8px 5px;font-weight:bold;font-size:16px;text-align:center;'>$installment1_date</td>"; $email_content.= "<td style='border: 3px solid #e40025 !important;padding:8px 5px;font-weight:bold;font-size:16px;text-align:center;'>Rs. $thecash /-</td>"; $email_content.= "<td style='border: 3px solid #e40025 !important;padding:8px 5px;font-weight:bold;font-size:16px;text-align:center;'> <p>$i_particulars1</p> <p>$i_particulars11</p> <p>$i_particulars12</p> <p>$i_particulars13</p></td>"; $email_content.= '</tr>'; $email_content.= '</table>'; $email_content.= '</div>'; $email_content.= '<br>'; $email_content.= '<br>'; } else if($payment->installment_amount2 != 0 || $payment->installment_payment_mode2 != 0) { $payment->installment_amount2; $num=$payment->installment_amount2;$explrestunits = "" ; $explrestunits = "" ; if(strlen($num)>3) { $lastthree = substr($num, strlen($num)-3, strlen($num)); $restunits = substr($num, 0, strlen($num)-3); // extracts the last three digits $restunits = (strlen($restunits)%2 == 1)?"0".$restunits:$restunits; // explodes the remaining digits in 2's formats, adds a zero in the beginning to maintain the 2's grouping. $expunit = str_split($restunits, 2); for($i=0; $i<sizeof($expunit); $i++) { // creates each of the 2's group and adds a comma to the end if($i==0) { $explrestunits .= (int)$expunit[$i].","; // if is first value , convert into integer } else { $explrestunits .= $expunit[$i].","; } } $thecash2 = $explrestunits.$lastthree; } else { $thecash2 = $num; } $total=$total+$num; $installment2_date = date("d-m-Y", strtotime($payment->installment2_date)); $installment_particularss2 = $payment->agreement_payment_mode; if($installment_particularss2 == "Online Payment") { $installment_particulars2 = 'NEFT / RTGS'; } else if($installment_particularss == "Paytm Payment") { $installment_particulars = 'UPI / Direct Payment'; } else if($installment_particularss == "UPI Payment") { $installment_particulars = 'Credit / Debit Payment'; } else { $installment_particulars2 = $installment_particularss2; } if($installment_particularss2 == "Cheque") { $number = $payment->install_cheque_no2; $mode_date = date("d-m-Y", strtotime($payment->install_cheque_date2)); $bank =$payment->install_bank2; //$i_particulars2 = 'Payment Mode: Cheque, No: '.$number.', Date: '.$mode_date.', Bank: '.$bank; $i_particulars2 = 'Payment Mode: Cheque'; $i_particulars21 = 'No: '.$number; $i_particulars22 = 'Date: '.$mode_date; $i_particulars23= 'Bank: '.$bank; } else if($installment_particularss2 == "Online Payment") { $number = $payment->install_vtr_no2; $mode_date = date("d-m-Y", strtotime($payment->install_online_date2)); $bank = ''; //$i_particulars2 = 'Payment Mode: NEFT/RTGS, No: '.$number.', Date: '.$mode_date; $i_particulars2 = 'Payment Mode: NEFT/RTGS'; $i_particulars21 = 'No: '.$number; $i_particulars22 = 'Date: '.$mode_date; $i_particulars23= ''; } else if($installment_particularss2 == "DD") { $number = $payment->install_dd_no2; $mode_date = date("d-m-Y", strtotime($payment->install_dd_date2)); $bank = $payment->install_dd_bank2; //$i_particulars2 = 'Payment Mode: DD, No: '.$number.', Date: '.$mode_date.', Bank: '.$bank; $i_particulars2 = 'Payment Mode: DD'; $i_particulars21 = 'No: '.$number; $i_particulars22 = 'Date: '.$mode_date; $i_particulars23= 'Bank: '.$bank; } else if($installment_particularss2 == "Paytm Payment") { $number = $payment->paytm_num2; $mode_date = date("d-m-Y", strtotime($payment->paytm_date2)); $bank = ''; //$i_particulars2 = 'Payment Mode: UPI / Direct Payment, No: '.$number.', Date: '.$mode_date; $i_particulars2 = 'Payment Mode: UPI / Direct Payment'; $i_particulars21 = 'No: '.$number; $i_particulars22 = 'Date: '.$mode_date; $i_particulars23= ''; } else if($installment_particularss2 == "UPI Payment") { $number = $payment->upi_num2; $mode_date = date("d-m-Y", strtotime($payment->upi_date2)); $bank = ''; //$i_particulars2 = 'Payment Mode: Credit / Debit Payment, No: '.$number.', Date: '.$mode_date; $i_particulars2 = 'Payment Mode: Credit / Debit Payment'; $i_particulars21 = 'No: '.$number; $i_particulars22 = 'Date: '.$mode_date; $i_particulars23= ''; } else if($installment_particularss2 == "Cash") { $i_particulars2 = 'Cash'; $i_particulars21 = ''; $i_particulars22 = ''; $i_particulars23= ''; } else if($installment_particularss2 == "Swipe") { $i_particulars2 = 'Swipe'; $i_particulars21 = ''; $i_particulars22 = ''; $i_particulars23= ''; } $email_content.= '<div style="clear:both;">'; $email_content.= '<table style="width:100%;border-collapse: collapse;border-color:red;" border="1">'; $email_content.= '<tr>'; $email_content.= '<td style="border: 3px solid #e40025 !important;padding:8px 5px;font-weight:bold;font-size:16px;text-align:center;">Installment Date</td>'; $email_content.= '<td style="border: 3px solid #e40025 !important;padding:8px 5px;font-weight:bold;font-size:16px;text-align:center;">Installment Amount</td>'; $email_content.= '<td style="border: 3px solid #e40025 !important;padding:8px 5px;font-weight:bold;font-size:16px;text-align:center;">Particulars</td>'; $email_content.= '</tr>'; $email_content.= '<tr>'; $email_content.= "<td style='border: 3px solid #e40025 !important;padding:8px 5px;font-weight:bold;font-size:16px;text-align:center;'>$installment2_date</td>"; $email_content.= "<td style='border: 3px solid #e40025 !important;padding:8px 5px;font-weight:bold;font-size:16px;text-align:center;'>Rs. $thecash2 /-</td>"; $email_content.= "<td style='border: 3px solid #e40025 !important;padding:8px 5px;font-weight:bold;font-size:16px;text-align:center;'><p>$i_particulars2</p> <p>$i_particulars21</p> <p>$i_particulars22</p> <p>$i_particulars23</p></td>"; $email_content.= '</tr>'; $email_content.= '</table>'; $email_content.= '</div>'; $email_content.= '<br>'; $email_content.= '<br>'; } $h++; } } // registration // if(empty($without_install)) { } else { if($without_install->registration_amount != 0 || $without_install->registration_payment_mode != 0) { $without_install->registration_amount; $num=$without_install->registration_amount;$explrestunits = "" ; if(strlen($num)>3) { $lastthree = substr($num, strlen($num)-3, strlen($num)); $restunits = substr($num, 0, strlen($num)-3); // extracts the last three digits $restunits = (strlen($restunits)%2 == 1)?"0".$restunits:$restunits; // explodes the remaining digits in 2's formats, adds a zero in the beginning to maintain the 2's grouping. $expunit = str_split($restunits, 2); for($i=0; $i<sizeof($expunit); $i++) { // creates each of the 2's group and adds a comma to the end if($i==0) { $explrestunits .= (int)$expunit[$i].","; // if is first value , convert into integer } else { $explrestunits .= $expunit[$i].","; } } $thecash = $explrestunits.$lastthree; } else { $thecash2 = $num; } $total=$total+$num; $registration_date = date("d-m-Y", strtotime($without_install->registration_date)); if($registration_date == '30-11--0001') { $registration_date = '00-00-0000'; } else { $registration_date = date("d-m-Y", strtotime($without_install->registration_date)); } $reg_particularss = $without_install->registration_payment_mode; if($reg_particularss == "Online Payment") { $reg_particulars = 'NEFT / RTGS'; } else if($reg_particularss == "Paytm Payment") { $reg_particulars = 'UPI / Direct payment'; } else if($reg_particularss == "UPI Payment") { $reg_particulars = 'Credit / Debit payment'; } else { $reg_particulars = $reg_particularss; } if($reg_particularss == "Cheque") { $number = $without_install->regn_cheque_no; $mode_date = date("d-m-Y", strtotime($without_install->regn_cheque_date)); $bank =$without_install->regn_bank; //$reg_particulars = 'Payment Mode: Cheque, No: '.$number.', Date: '.$mode_date.', Bank: '.$bank; $reg_particulars = 'Payment Mode: Cheque'; $reg_particulars1 = 'No: '.$number; $reg_particulars2 = 'Date: '.$mode_date; $reg_particulars3= 'Bank: '.$bank; } else if($reg_particularss == "Online Payment") { $number = $without_install->regn_vtr_no; $mode_date = date("d-m-Y", strtotime($without_install->regn_online_date)); $bank = ''; //$reg_particulars = 'Payment Mode: NEFT/RTGS, No: '.$number.', Date: '.$mode_date; $reg_particulars = 'Payment Mode: NEFT/RTGS'; $reg_particulars1 = 'No: '.$number; $reg_particulars2 = 'Date: '.$mode_date; $reg_particulars3 = ''; } else if($reg_particularss == "DD") { $number = $without_install->regn_dd_no; $mode_date = date("d-m-Y", strtotime($without_install->regn_dd_date)); $bank = $without_install->regn_dd_bank; //$reg_particulars = 'Payment Mode: DD, No: '.$number.', Date: '.$mode_date.', Bank: '.$bank; $reg_particulars = 'Payment Mode: DD'; $reg_particulars1 = 'No: '.$number; $reg_particulars2 = 'Date: '.$mode_date; $reg_particulars3 = 'Bank: '.$bank; } else if($reg_particularss == "Paytm Payment") { $number = $without_install->regn_ref_no; $mode_date = date("d-m-Y", strtotime($without_install->regn_paytm_date)); $bank = ''; //$reg_particulars = 'Payment Mode: UPI / Direct Payment, No: '.$number.', Date: '.$mode_date; $reg_particulars = 'Payment Mode: UPI / Direct Payment'; $reg_particulars1 = 'No: '.$number; $reg_particulars2 = 'Date: '.$mode_date; $reg_particulars3 = ''; } else if($reg_particularss == "UPI Payment") { $number = $without_install->regn_upiref_no; $mode_date = date("d-m-Y", strtotime($without_install->regn_upi_date)); $bank = ''; //$reg_particulars = 'Payment Mode: Credit / Debit Payment, No: '.$number.', Date: '.$mode_date; $reg_particulars = 'Payment Mode: Credit / Debit Payment'; $reg_particulars1 = 'No: '.$number; $reg_particulars2 = 'Date: '.$mode_date; $reg_particulars3 = ''; } else if($reg_particularss == "Cash") { $number = ''; $mode_date = date("d-m-Y", strtotime($without_install->cash_date)); $bank = ''; //$reg_particulars = 'Payment Mode: Cash, Date: '.$mode_date; $reg_particulars = 'Payment Mode: Cash'; $reg_particulars1 = ''; $reg_particulars2 = 'Date: '.$mode_date; $reg_particulars3 = ''; } else if($reg_particularss == "Swipe") { $number = ''; $mode_date = date("d-m-Y", strtotime($without_install->swipe_date)); $bank = ''; //$reg_particulars = 'Payment Mode: Swipe, Date: '.$mode_date; $reg_particulars = 'Payment Mode: Swipe'; $reg_particulars1 = ''; $reg_particulars2 = 'Date: '.$mode_date; $reg_particulars3 = ''; } $email_content.= '<div style="clear:both;">'; $email_content.= '<table style="width:100%;border-collapse: collapse;border-color:red;" border="1">'; $email_content.= '<tr>'; $email_content.= '<td style="border: 3px solid #e40025 !important;padding:8px 5px;font-weight:bold;font-size:16px;text-align:center;">Sl No.</td>'; $email_content.= '<td style="border: 3px solid #e40025 !important;padding:8px 5px;font-weight:bold;font-size:16px;text-align:center;">Registration Date</td>'; $email_content.= '<td style="border: 3px solid #e40025 !important;padding:8px 5px;font-weight:bold;font-size:16px;text-align:center;">Registration Amount</td>'; $email_content.= '<td style="border: 3px solid #e40025 !important;padding:8px 5px;font-weight:bold;font-size:16px;text-align:center;">Particulars</td>'; $email_content.= '</tr>'; $email_content.= '<tr>'; $email_content.= "<td style='border: 3px solid #e40025 !important;padding:8px 5px;font-weight:bold;font-size:16px;text-align:center;'>1</td>"; $email_content.= "<td style='border: 3px solid #e40025 !important;padding:8px 5px;font-weight:bold;font-size:16px;text-align:center;'>$registration_date</td>"; $email_content.= "<td style='border: 3px solid #e40025 !important;padding:8px 5px;font-weight:bold;font-size:16px;text-align:center;'>Rs. $thecash /-</td>"; $email_content.= "<td style='border: 3px solid #e40025 !important;padding:8px 5px;font-weight:bold;font-size:16px;text-align:center;'><p>$reg_particulars</p> <p>$reg_particulars1</p> <p>$reg_particulars2</p> <p>$reg_particulars3</p></td>"; $email_content.= '</tr>'; $email_content.= '</table>'; $email_content.= '</div>'; $email_content.= '<br>'; } } if($get_reg_amt != "") { $a=1; foreach($get_reg_amt as $get_reg_amt) { $get_reg_amt->reg_amount; $num=$get_reg_amt->reg_amount;$explrestunits = "" ; $explrestunits = "" ; if(strlen($num)>3) { $lastthree = substr($num, strlen($num)-3, strlen($num)); $restunits = substr($num, 0, strlen($num)-3); // extracts the last three digits $restunits = (strlen($restunits)%2 == 1)?"0".$restunits:$restunits; // explodes the remaining digits in 2's formats, adds a zero in the beginning to maintain the 2's grouping. $expunit = str_split($restunits, 2); for($i=0; $i<sizeof($expunit); $i++) { // creates each of the 2's group and adds a comma to the end if($i==0) { $explrestunits .= (int)$expunit[$i].","; // if is first value , convert into integer } else { $explrestunits .= $expunit[$i].","; } } $thecash2 = $explrestunits.$lastthree; } else { $thecash2 = $num; } $total=$total+$num; /*$reg_date = date("d-m-Y", strtotime($get_reg_amt->reg_date)); if($reg_date == '30-11--0001') { $reg_date = '00-00-0000'; } else { $reg_date = date("d-m-Y", strtotime($get_reg_amt->reg_date)); }*/ $r_particularss = $get_reg_amt->reg_payment_mode; if($r_particularss == "Online Payment") { $r_particulars = 'NEFT / RTGS'; } if($r_particularss == "Paytm Payment") { $r_particulars = 'UPI / Direct Payment'; } if($r_particularss == "UPI Payment") { $r_particulars = 'Credit / Debit Payment'; } else { $r_particulars = $r_particularss; } if($r_particularss == "Cheque") { $number = $get_reg_amt->number; $mode_date = date("d-m-Y", strtotime($get_reg_amt->mode_date)); $bank =$get_reg_amt->branch_name; //$r_particulars = 'Payment Mode: Cheque, No: '.$number.', Date: '.$mode_date.', Bank: '.$bank; $r_particulars = 'Payment Mode: Cheque'; $r_particulars1 = 'No: '.$number; $r_particulars2 = 'Date: '.$mode_date; $r_particulars3 = ' Bank: '.$bank; } else if($r_particularss == "Online Payment") { $number = $get_reg_amt->number; $mode_date = date("d-m-Y", strtotime($get_reg_amt->mode_date)); $bank = ''; //$r_particulars = 'Payment Mode: NEFT/RTGS, No: '.$number.', Date: '.$mode_date; $r_particulars = 'Payment Mode: NEFT/RTGS'; $r_particulars1 = 'No: '.$number; $r_particulars2 = 'Date: '.$mode_date; $r_particulars3 = ''; } else if($r_particularss == "Paytm Payment") { $number = ''; $mode_date = date("d-m-Y", strtotime($get_reg_amt->mode_date)); $bank = ''; //$r_particulars = 'Payment Mode: UPI / Direct Payment, Date: '.$mode_date; $r_particulars = 'Payment Mode: UPI / Direct Payment'; $r_particulars1 = 'No: '.$number; $r_particulars2 = 'Date: '.$mode_date; $r_particulars3 = ''; } else if($r_particularss == "UPI Payment") { $number = ''; $mode_date = date("d-m-Y", strtotime($get_reg_amt->mode_date)); $bank = ''; //$r_particulars = 'Payment Mode: Credit / Debit Payment, Date: '.$mode_date; $r_particulars = 'Payment Mode: Credit / Debit Payment'; $r_particulars1 = 'No: '.$number; $r_particulars2 = 'Date: '.$mode_date; $r_particulars3 = ''; } else if($r_particularss == "DD") { $number = $get_reg_amt->number; $mode_date = date("d-m-Y", strtotime($get_reg_amt->mode_date)); $bank = $get_reg_amt->branch_name; //$r_particulars = 'Payment Mode: DD, No: '.$number.', Date: '.$mode_date.', Bank: '.$bank; $r_particulars = 'Payment Mode: DD'; $r_particulars1 = 'No: '.$number; $r_particulars2 = 'Date: '.$mode_date; $r_particulars3 = ' Bank: '.$bank; } else if($r_particularss == "Cash") { $number = ''; $mode_date = date("d-m-Y", strtotime($get_reg_amt->mode_date)); $bank = ''; //$r_particulars = 'Payment Mode:Cash, Date: '.$mode_date; $r_particulars = 'Payment Mode: Cash'; $r_particulars1 = ''; $r_particulars2 = 'Date: '.$mode_date; $r_particulars3 = ''; } else if($r_particularss == "Swipe") { $number = ''; $mode_date = date("d-m-Y", strtotime($get_reg_amt->mode_date)); $bank = ''; //$r_particulars = 'Payment Mode: Swipe, Date: '.$mode_date; $r_particulars = 'Payment Mode: Swipe'; $r_particulars1 = ''; $r_particulars2 = 'Date: '.$mode_date; $r_particulars3 = ''; } $a++; $email_content.= '<div style="clear:both;">'; $email_content.= '<table style="width:100%;border-collapse: collapse;border-color:red;" border="1">'; $email_content.= '<tr>'; $email_content.= '<td style="border: 3px solid #e40025 !important;padding:8px 5px;font-weight:bold;font-size:16px;text-align:center;">Sl No.</td>'; /*$email_content.= '<td style="border: 3px solid #e40025 !important;padding:8px 5px;font-weight:bold;font-size:16px;text-align:center;">Registration Date</td>';*/ $email_content.= '<td style="border: 3px solid #e40025 !important;padding:8px 5px;font-weight:bold;font-size:16px;text-align:center;">Registration Amount</td>'; $email_content.= '<td style="border: 3px solid #e40025 !important;padding:8px 5px;font-weight:bold;font-size:16px;text-align:center;">Particulars</td>'; $email_content.= '</tr>'; $email_content.= '<tr>'; $email_content.= "<td style='border: 3px solid #e40025 !important;padding:8px 5px;font-weight:bold;font-size:16px;text-align:center;'>$a</td>"; /* $email_content.= "<td style='border: 3px solid #e40025 !important;padding:8px 5px;font-weight:bold;font-size:16px;text-align:center;'>$reg_date</td>";*/ $email_content.= "<td style='border: 3px solid #e40025 !important;padding:8px 5px;font-weight:bold;font-size:16px;text-align:center;'>Rs. $thecash2 /-</td>"; $email_content.= "<td style='border: 3px solid #e40025 !important;padding:8px 5px;font-weight:bold;font-size:16px;text-align:center;'><p>$r_particulars</p> <p>$r_particulars1</p> <p>$r_particulars2</p> <p>$r_particulars3</p></td>"; $email_content.= '</tr>'; $email_content.= '</table>'; $email_content.= '</div>'; $email_content.= '<br>'; } } $email_content.= '<div style="clear:both;">'; $email_content.= "<p style='color:green;'>$balance_amount_1</p>"; $email_content.= '</div>'; $email_content.= '<div style="clear:both;">'; $email_content.= "<p style='color:blue;'>$total_amount_1</p>"; $email_content.= '</div>'; $email_content.= '</body>'; $email_content.= '</html>'; // $mpdf->SetDisplayMode('fullpage'); // $mpdf->watermark_font = 'DejaVuSansCondensed'; // $mpdf->showWatermarkText = true; // $mpdf->WriteHTML($email_content); $mpdf->WriteHTML($email_content); $name = 'site_report'.$insert_result.'.pdf'; $data = array('email_receipt'=>$name); $where = array('id'=>$insert_result); $result = $this->gss_model->update($where,$table,$data); $pdf = $mpdf->Output("./email_receipts/".$name, 'F'); if($this->db->affected_rows() > 0) { echo json_encode(array('result'=>1 ,'message'=>$insert_result)); } else { echo json_encode(array('result'=>0,'message'=>"Data could not be added")); } } else { echo json_encode(array('result'=>0,'message'=>"Data could not be added")); } } else { redirect('/'); } } // Documentation projects form public function documentation_project_form() { $admin_id = session()->get('admin_id'); if($admin_id) { $table = "gss_project_master"; $where = array('delete_status'=>'ACTIVE'); $data['projects'] = $this->gss_model->get_where_result($table,$where); $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $this->load->view('admin/doc_project_form',$data); } else { redirect('/'); } } public function add_documentation_project() { $project_name = $this->input->post('project_name'); $project_owner_name = $this->input->post('project_owner_name'); // $approved_plan_image = ""; $release_order_image = ""; $conversion_order_image = ""; $conversion_order = ""; $brochure = ""; $combined = ""; $array = array(); $this->load->library('image_lib'); if(!isset($_FILES['approved_plan_image']['name'])) { $approved_plan_image = ""; } else { $target='documentation_approved_uploads/'; $target.=time().$_FILES['approved_plan_image']['name']; $approved_plan_image=time().$_FILES['approved_plan_image']['name']; $image=$target; move_uploaded_file($_FILES['approved_plan_image']['tmp_name'],$target); $config['source_image']=$target; $config['maintain_ratio']=TRUE; $config['width']=900; $config['height']=900; $this->image_lib->initialize($config); $this->image_lib->resize(); } $conversion_doc_name = $this->input->post('conversion_doc_name'); if(!empty($_FILES['conversion_order_image'])) { if($_FILES['conversion_order_image']['size'][0]!= 0) { for($i=0;$i< count($_FILES['conversion_order_image']['name']);$i++) { $target1='documentation_other_uploads/'; $stamp = getdate(); $target1.=$stamp[0].basename($_FILES['conversion_order_image']['name'][$i]); $target2=$stamp[0].basename($_FILES['conversion_order_image']['name'][$i]); $url[$i]=$target2; move_uploaded_file($_FILES['conversion_order_image']['tmp_name'][$i],$target1); $config1['source_image']=$target1; $config1['maintain_ratio']=TRUE; $this->image_lib->initialize($config1); $this->image_lib->resize(); $this->image_lib->clear(); } } $com = array(); foreach ($url as $key=>$val) { $conversion_doc_name = $this->input->post("conversion_doc_name"); $data['image'] = $val; $data['name'] = $conversion_doc_name[$key]; array_push($com,$data); } $doc = json_encode($com); } if(!isset($_FILES['release_order_image']['name'])) { $release_order_image = ""; } else { $target='documentation_release_uploads/'; $target.=time().$_FILES['release_order_image']['name']; $release_order_image=time().$_FILES['release_order_image']['name']; $image=$target; move_uploaded_file($_FILES['release_order_image']['tmp_name'],$target); $config['source_image']=$target; $config['maintain_ratio']=TRUE; $config['width']=900; $config['height']=900; $this->image_lib->initialize($config); $this->image_lib->resize(); } if(!isset($_FILES['conversion_order']['name'])) { $conversion_order = ""; } else { $target='documentation_conversion_uploads/'; $target.=time().$_FILES['conversion_order']['name']; $conversion_order=time().$_FILES['conversion_order']['name']; $image=$target; move_uploaded_file($_FILES['conversion_order']['tmp_name'],$target); $config['source_image']=$target; $config['maintain_ratio']=TRUE; $config['width']=900; $config['height']=900; $this->image_lib->initialize($config); $this->image_lib->resize(); } if(!isset($_FILES['brochure']['name'])) { $brochure = ""; } else { $target='documentation_borchure_uploads/'; $target.=time().$_FILES['brochure']['name']; $brochure=time().$_FILES['brochure']['name']; $image=$target; move_uploaded_file($_FILES['brochure']['tmp_name'],$target); $config['source_image']=$target; $config['maintain_ratio']=TRUE; $config['width']=900; $config['height']=900; $this->image_lib->initialize($config); $this->image_lib->resize(); } $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $created_at = $date->format('d-m-Y'); $table = "gss_doc_projects"; $data = array('project_name' =>$project_name, 'project_owner_name' => $project_owner_name, 'approval_image' => $approved_plan_image, // 'other_image' => $conversion_order_image, 'other_image' => $doc, 'release_image' => $release_order_image, 'conversion_order' => $conversion_order, 'brochure' => $brochure, 'delete_status' =>'ACTIVE', 'created_at' => $created_at); $result = $this->gss_model->insert($table,$data); if($result) { echo json_encode(array('result'=>1,'message'=>"Project Added!")); } else { echo json_encode(array('result'=>0,'message'=>"Data could not be added")); } } public function documentation_project_list() { $admin_id = session()->get('admin_id'); if($admin_id) { $table = "gss_project_master"; $where = array('delete_status'=>'ACTIVE'); $data['projects'] = $this->gss_model->get_where_result($table,$where); $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $this->load->view('admin/doc_project_list',$data); } else { redirect('/'); } } public function doc_project_list() { $table = "gss_doc_projects"; $where = array('delete_status'=>'ACTIVE'); $result = $this->gss_model->get_where_result($table,$where); echo json_encode($result); } public function delete_doc_project() { $project_table = 'gss_doc_projects'; $project_id = $this->input->post('project_id'); $where = array('id'=>$project_id); $data = array('delete_status'=>'INACTIVE'); $result = $this->gss_model->update($where,$project_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_doc_project() { $table = 'gss_doc_projects'; $project_id = $this->input->post('project_id'); $where = array('id'=>$project_id,'delete_status'=>'ACTIVE'); $result = $this->gss_model->get_where_row($table,$where); if($result) { echo json_encode(array('project_details'=>$result,'result'=>1)); } else { echo json_encode(array('result'=>0)); } } // public function update_doc_project() // { // $project_id = $this->input->post('project_id'); // $project_name = $this->input->post('project_name'); // $project_owner_name = $this->input->post('project_owner_name'); // $approved_plan_image = ""; // $release_order_image = ""; // $conversion_order_image = ""; // $conversion_order = ""; // $brochure = ""; // $table = "gss_doc_projects"; // $where = array('id'=>$project_id); // $check_images = $this->gss_model->get_where_row($table,$where); // $array = array(); // $this->load->library('image_lib'); // if(empty($_FILES['approved_plan_image']['name'])) // { // $approved_plan_image = $check_images->approval_image; // } // else // { // $target='documentation_approved_uploads/'; // $target.=time().$_FILES['approved_plan_image']['name']; // $approved_plan_image=time().$_FILES['approved_plan_image']['name']; // $image=$target; // move_uploaded_file($_FILES['approved_plan_image']['tmp_name'],$target); // $config['source_image']=$target; // $config['maintain_ratio']=TRUE; // $config['width']=900; // $config['height']=900; // $this->image_lib->initialize($config); // $this->image_lib->resize(); // } // // if(empty($_FILES['conversion_order_image']['name'])) // // { // // $conversion_order_image = $check_images->other_image; // // } // // else // // { // // $target='documentation_other_uploads/'; // // $target.=time().$_FILES['conversion_order_image']['name']; // // $conversion_order_image=time().$_FILES['conversion_order_image']['name']; // // $image=$target; // // move_uploaded_file($_FILES['conversion_order_image']['tmp_name'],$target); // // $config['source_image']=$target; // // $config['maintain_ratio']=TRUE; // // $config['width']=900; // // $config['height']=900; // // $this->image_lib->initialize($config); // // $this->image_lib->resize(); // // } // $old_new_combined = ''; // $prev_con_docs = ''; // $all_docs = ''; // $array = array(); // if($check_images->other_image != "") // { // $prev_con_docs = $check_images->other_image; // $prev_con_docs = json_decode($prev_con_docs); // foreach($prev_con_docs as $key=>$val){ // $array[$key] = $val; // } // } // $conversion_doc_name = $this->input->post('conversion_doc_name'); // if($_FILES['conversion_order_image']['size'][0]!= 0) // { // for($i=0;$i< count($_FILES['conversion_order_image']['name']);$i++) // { // $target1='documentation_other_uploads/'; // $stamp = getdate(); // $target1.=$stamp[0].basename($_FILES['conversion_order_image']['name'][$i]); // $target2=$stamp[0].basename($_FILES['conversion_order_image']['name'][$i]); // $url[]=$target2; // move_uploaded_file($_FILES['conversion_order_image']['tmp_name'][$i],$target1); // $config1['source_image']=$target1; // $config1['maintain_ratio']=TRUE; // $this->image_lib->initialize($config1); // $this->image_lib->resize(); // $this->image_lib->clear(); // } // $combined = array_combine($url, $conversion_doc_name); // if($prev_con_docs != "") // { // $all_docs = json_encode(array_merge($array,$combined)); // } // else // { // $all_docs = json_encode($combined); // } // } // else // { // $all_docs = $check_images->other_image; // } // if(empty($_FILES['release_order_image']['name'])) // { // $release_order_image = $check_images->release_image; // } // else // { // $target='documentation_release_uploads/'; // $target.=time().$_FILES['release_order_image']['name']; // $release_order_image=time().$_FILES['release_order_image']['name']; // $image=$target; // move_uploaded_file($_FILES['release_order_image']['tmp_name'],$target); // $config['source_image']=$target; // $config['maintain_ratio']=TRUE; // $config['width']=900; // $config['height']=900; // $this->image_lib->initialize($config); // $this->image_lib->resize(); // } // if(empty($_FILES['conversion_order']['name'])) // { // $conversion_order = $check_images->conversion_order; // } // else // { // $target='documentation_conversion_uploads/'; // $target.=time().$_FILES['conversion_order']['name']; // $conversion_order=time().$_FILES['conversion_order']['name']; // $image=$target; // move_uploaded_file($_FILES['conversion_order']['tmp_name'],$target); // $config['source_image']=$target; // $config['maintain_ratio']=TRUE; // $config['width']=900; // $config['height']=900; // $this->image_lib->initialize($config); // $this->image_lib->resize(); // } // if(empty($_FILES['brochure']['name'])) // { // $brochure = $check_images->brochure; // } // else // { // $target='documentation_borchure_uploads/'; // $target.=time().$_FILES['brochure']['name']; // $brochure=time().$_FILES['brochure']['name']; // $image=$target; // move_uploaded_file($_FILES['brochure']['tmp_name'],$target); // $config['source_image']=$target; // $config['maintain_ratio']=TRUE; // $config['width']=900; // $config['height']=900; // $this->image_lib->initialize($config); // $this->image_lib->resize(); // } // $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); // $created_at = $date->format('d-m-Y'); // $data = array('project_name' =>$project_name, // 'project_owner_name' => $project_owner_name, // 'approval_image' => $approved_plan_image, // // 'other_image' => $conversion_order_image, // 'other_image' => $all_docs, // 'release_image' => $release_order_image, // 'conversion_order' => $conversion_order, // 'brochure' => $brochure, // 'delete_status' =>'ACTIVE', // 'created_at' => $created_at); // $result = $this->gss_model->update($where,$table,$data); // if($result) // { // echo json_encode(array('result'=>1,'message'=>"Project Added!")); // } // else // { // echo json_encode(array('result'=>0,'message'=>"Data could not be added")); // } // } public function update_doc_project() { $project_id = $this->input->post('project_id'); $project_name = $this->input->post('project_name'); $project_owner_name = $this->input->post('project_owner_name'); $approved_plan_image = ""; $release_order_image = ""; $conversion_order_image = ""; $conversion_order = ""; $brochure = ""; $table = "gss_doc_projects"; $where = array('id'=>$project_id); $check_images = $this->gss_model->get_where_row($table,$where); $array = array(); $this->load->library('image_lib'); if(empty($_FILES['approved_plan_image']['name'])) { $approved_plan_image = $check_images->approval_image; } else { $target='documentation_approved_uploads/'; $target.=time().$_FILES['approved_plan_image']['name']; $approved_plan_image=time().$_FILES['approved_plan_image']['name']; $image=$target; move_uploaded_file($_FILES['approved_plan_image']['tmp_name'],$target); $config['source_image']=$target; $config['maintain_ratio']=TRUE; $config['width']=900; $config['height']=900; $this->image_lib->initialize($config); $this->image_lib->resize(); } $old_new_combined = ''; $prev_con_docs = ''; $all_docs = ''; $array = array(); if($check_images->other_image != "") { $prev_con_docs = $check_images->other_image; $prev_con_docs = json_decode($prev_con_docs); foreach($prev_con_docs as $key=>$val){ //$array[$key] = $val; $data['image'] = $val->image; $data['name'] = $val->name; array_push($array,$data); } } $conversion_doc_name = $this->input->post('conversion_doc_name'); if($_FILES['conversion_order_image']['size'][0]!= 0) { for($i=0;$i< count($_FILES['conversion_order_image']['name']);$i++) { $target1='documentation_other_uploads/'; $stamp = getdate(); $target1.=$stamp[0].basename($_FILES['conversion_order_image']['name'][$i]); $target2=$stamp[0].basename($_FILES['conversion_order_image']['name'][$i]); $url[]=$target2; move_uploaded_file($_FILES['conversion_order_image']['tmp_name'][$i],$target1); $config1['source_image']=$target1; $config1['maintain_ratio']=TRUE; $this->image_lib->initialize($config1); $this->image_lib->resize(); $this->image_lib->clear(); } $combined = array_combine($url, $conversion_doc_name); $com = array(); foreach ($url as $key=>$val) { $conversion_doc_name = $this->input->post("conversion_doc_name"); $data['image'] = $val; $data['name'] = $conversion_doc_name[$key]; array_push($com,$data); } if($prev_con_docs != "") { $all_docs = json_encode(array_merge($array,$com)); } else { $all_docs = json_encode($com); } } else { $all_docs = $check_images->other_image; } if(empty($_FILES['release_order_image']['name'])) { $release_order_image = $check_images->release_image; } else { $target='documentation_release_uploads/'; $target.=time().$_FILES['release_order_image']['name']; $release_order_image=time().$_FILES['release_order_image']['name']; $image=$target; move_uploaded_file($_FILES['release_order_image']['tmp_name'],$target); $config['source_image']=$target; $config['maintain_ratio']=TRUE; $config['width']=900; $config['height']=900; $this->image_lib->initialize($config); $this->image_lib->resize(); } if(empty($_FILES['conversion_order']['name'])) { $conversion_order = $check_images->conversion_order; } else { $target='documentation_conversion_uploads/'; $target.=time().$_FILES['conversion_order']['name']; $conversion_order=time().$_FILES['conversion_order']['name']; $image=$target; move_uploaded_file($_FILES['conversion_order']['tmp_name'],$target); $config['source_image']=$target; $config['maintain_ratio']=TRUE; $config['width']=900; $config['height']=900; $this->image_lib->initialize($config); $this->image_lib->resize(); } if(empty($_FILES['brochure']['name'])) { $brochure = $check_images->brochure; } else { $target='documentation_borchure_uploads/'; $target.=time().$_FILES['brochure']['name']; $brochure=time().$_FILES['brochure']['name']; $image=$target; move_uploaded_file($_FILES['brochure']['tmp_name'],$target); $config['source_image']=$target; $config['maintain_ratio']=TRUE; $config['width']=900; $config['height']=900; $this->image_lib->initialize($config); $this->image_lib->resize(); } $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $created_at = $date->format('d-m-Y'); $data = array('project_name' =>$project_name, 'project_owner_name' => $project_owner_name, 'approval_image' => $approved_plan_image, // 'other_image' => $conversion_order_image, 'other_image' => $all_docs, 'release_image' => $release_order_image, 'conversion_order' => $conversion_order, 'brochure' => $brochure, 'delete_status' =>'ACTIVE', 'created_at' => $created_at); $result = $this->gss_model->update($where,$table,$data); if($result) { echo json_encode(array('result'=>1,'message'=>"Updated Successfully")); } else { echo json_encode(array('result'=>1,'message'=>"Updated Successfully")); } } public function view_other_documents() { $admin_id = session()->get('admin_id'); if($admin_id) { $id = $this->uri->segment(2); $table = "gss_doc_projects"; $where = array('delete_status'=>'ACTIVE','id'=>$id); $data['projects'] = $this->gss_model->get_where_row($table,$where); $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $this->load->view('admin/view_other_digidocuments',$data); } else { redirect('/'); } } // Documentation sites form public function documentation_site_form() { $admin_id = session()->get('admin_id'); if($admin_id) { $table = "gss_doc_projects"; $where = array('delete_status'=>'ACTIVE'); $data['projects'] = $this->gss_model->get_where_result($table,$where); $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $this->load->view('admin/doc_site_form',$data); } else { redirect('/'); } } public function add_documentation_site() { $project_id = $this->input->post('project_id'); $site_number = $this->input->post('site_number'); $dimension = $this->input->post('dimension'); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $created_at = $date->format('d-m-Y'); $table = "gss_doc_sites"; $data = array('project_id' => $project_id, 'site_number' => $site_number, 'dimension' => $dimension, 'delete_status' =>'ACTIVE', 'created_at' => $created_at); $where_pro_site = array('site_number'=>$site_number,'project_id'=>$project_id,'delete_status'=>'ACTIVE'); $check = $this->gss_model->get_where_row($table,$where_pro_site); if($check) { echo json_encode(array('result'=>0,'message'=>"Site already exists")); } else { $result = $this->gss_model->insert($table,$data); if($result) { echo json_encode(array('result'=>1,'message'=>"Site Added!")); } else { echo json_encode(array('result'=>0,'message'=>"Data could not be added")); } } } public function documentation_site_list() { $admin_id = session()->get('admin_id'); if($admin_id) { $table = "gss_doc_projects"; $where = array('delete_status'=>'ACTIVE'); $data['projects'] = $this->gss_model->get_where_result($table,$where); $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $this->load->view('admin/doc_site_list',$data); } else { redirect('/'); } } public function doc_site_list() { $table = "gss_doc_sites"; $where = array('delete_status'=>'ACTIVE'); $result = $this->gss_model->get_doc_site_details($table,$where); echo json_encode($result); } public function delete_doc_site() { $table = 'gss_doc_sites'; $site_id = $this->input->post('site_id'); $where = array('id'=>$site_id); $data = array('delete_status'=>'INACTIVE'); $result = $this->gss_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_doc_site() { $table = 'gss_doc_sites'; $id = $this->input->post('id'); $where = array('id'=>$id,'delete_status'=>'ACTIVE'); $result = $this->gss_model->get_doc_sites($id); if($result) { echo json_encode(array('site_details'=>$result,'result'=>1)); } else { echo json_encode(array('result'=>0)); } } public function update_doc_site() { $site_id = $this->input->post('site_id'); $project_id = $this->input->post('project_id'); $site_number = $this->input->post('site_number'); $dimension = $this->input->post('dimension'); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $created_at = $date->format('d-m-Y'); $table = "gss_doc_sites"; $where = array('delete_status'=>'ACTIVE'); $check = $this->gss_model->get_where_result($table,$where); $where_site_id = array('id'=>$site_id); $site_data = $this->gss_model->get_where_row($table,$where_site_id); $data = array('site_number' => $site_number, 'dimension' => $dimension); $where_site = $site_data->site_number; $where = array( 'delete_status' => 'ACTIVE', 'site_number !=' => $where_site, 'project_id' => $project_id ); $numbers = $this->gss_model->get_where_result($table,$where); $array = array(); foreach($numbers as $value) { array_push($array, $value->site_number); } if(in_array($site_number,$array)) { echo json_encode(array('result'=>2,'message'=>"Site number already exists in this project")); } else { $where_id = array('id' => $site_id,'project_id' => $project_id); $result = $this->gss_model->update($where_id,$table,$data); 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 get_unreg_site_details() { $project = $_GET['project']; $result = $this->gss_model->get_unreg_site_details($project); if($result) { echo json_encode($result); } else { echo json_encode(array('result'=>0)); } } public function get_pending_reg_amt() { $project = $this->input->post('project_id'); $tot_agree_due_amt = $this->gss_model->get_total_agree_due_amt($project); $total_registration_due_amount = 0; foreach($tot_agree_due_amt as $tada) { $total_reg_due_amt = $tada->registration_due_amount; $total_registration_due_amount += $total_reg_due_amt; } $received_agreement_amt = $this->gss_model->get_received_pending_amt($project); $received_registration_amount = 0; foreach($received_agreement_amt as $raa) { $received_due_amt = $raa->registration_amount; $received_registration_amount += is_numeric($received_due_amt); } $balance_reg_amount = $total_registration_due_amount - $received_registration_amount; echo json_encode(array('result'=>1,'received_registration_amount'=>$received_registration_amount,'balance_reg_amount'=>$balance_reg_amount)); } //owner document form public function owner_document_form() { $admin_id = session()->get('admin_id'); if($admin_id) { $table = "gss_doc_projects"; $where = array('delete_status'=>'ACTIVE'); $data['projects'] = $this->gss_model->get_where_result($table,$where); $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $this->load->view('admin/doc_owner_form',$data); } else { redirect('/'); } } public function get_doc_projects() { $admin_id = session()->get('admin_id'); if($admin_id) { $project_id = $this->input->post('project_id'); $where = array('project_id'=>$project_id,'delete_status'=>'ACTIVE'); $table = 'gss_doc_sites'; $order_by ="site_number"; $sites = $this->gss_model->single_project_sites($table,$where,$order_by); if($sites) { echo json_encode(array('result'=>1,'sites'=>$sites)); } else { echo json_encode(array('result'=>0)); } } else { redirect('/'); } } public function add_owner_documents() { $admin_id = session()->get('admin_id'); if($admin_id) { $this->load->library('image_lib'); $project_id = $this->input->post('project_id'); $site_number = $this->input->post('site_number'); $owner_name = $this->input->post('owner_name'); if(empty($_FILES['sales_agreement_files']['name'])) { $sales_agreement_files = ''; } else { $target='doc_sales_agreement/'; $target.=$_FILES['sales_agreement_files']['name']; $sales_agreement_files=$_FILES['sales_agreement_files']['name']; //$target.=time().$_FILES['sales_agreement_files']['name']; //$sales_agreement_files=time().$_FILES['sales_agreement_files']['name']; $target1 = preg_replace('/\s+/', '_', $target); $image=$target1; move_uploaded_file($_FILES['sales_agreement_files']['tmp_name'],$target1); $config['source_image']=$target1; $config['maintain_ratio']=TRUE; $config['width']=900; $config['height']=900; $this->image_lib->initialize($config); $this->image_lib->resize(); } if($sales_agreement_files != "") { $sales_agreement_files1 = preg_replace('/\s+/', '_', $sales_agreement_files); $sales_agreement_files_added = $sales_agreement_files1; } else { $sales_agreement_files_added =""; } if(empty($_FILES['sales_deed']['name'])) { $sales_deed = ''; } else { $target='doc_sales_deed/'; $target.=$_FILES['sales_deed']['name']; $sales_deed=$_FILES['sales_deed']['name']; /*$target.=time().$_FILES['sales_deed']['name']; $sales_deed=time().$_FILES['sales_deed']['name'];*/ $target1 = preg_replace('/\s+/', '_', $target); $image=$target1; move_uploaded_file($_FILES['sales_deed']['tmp_name'],$target1); $config['source_image']=$target1; $config['maintain_ratio']=TRUE; $config['width']=900; $config['height']=900; $this->image_lib->initialize($config); $this->image_lib->resize(); } if($sales_deed != "") { $sales_deed1 = preg_replace('/\s+/', '_', $sales_deed); $sales_deed_added = $sales_deed1; } else { $sales_deed_added =""; } if(empty($_FILES['owner_khata']['name'])) { $owner_khata = ''; } else { $target='doc_owner_khata/'; $target.=$_FILES['owner_khata']['name']; $owner_khata=$_FILES['owner_khata']['name']; /*$target.=time().$_FILES['owner_khata']['name']; $owner_khata=time().$_FILES['owner_khata']['name']; */ $target1 = preg_replace('/\s+/', '_', $target); $image=$target1; move_uploaded_file($_FILES['owner_khata']['tmp_name'],$target1); $config['source_image']=$target1; $config['maintain_ratio']=TRUE; $config['width']=900; $config['height']=900; $this->image_lib->initialize($config); $this->image_lib->resize(); } if($owner_khata != "") { $owner_khata1 = preg_replace('/\s+/', '_', $owner_khata); $owner_khata_added = $owner_khata1; } else { $owner_khata_added =""; } $ec_from_date = $this->input->post('ec_from_date'); $ec_to_date = $this->input->post('ec_to_date'); $ec_uploads = $this->input->post('ec_uploads'); $count = 0; $array = array(); foreach ($ec_from_date as $key => $value) { $count++; $ec_from_dates = $value; $ec_to_dates = $ec_to_date[$key]; if(empty($_FILES['ec_uploads']['name'][$key])) { $ec_uploads = ''; } else { $target='doc_ec_uploads/'; /*$target.=time().$_FILES['ec_uploads']['name'][$key]; $ec_uploads=time().$_FILES['ec_uploads']['name'][$key];*/ $target.=$_FILES['ec_uploads']['name'][$key]; $ec_uploads=$_FILES['ec_uploads']['name'][$key]; $target1 = preg_replace('/\s+/', '_', $target); $image=$target1; move_uploaded_file($_FILES['ec_uploads']['tmp_name'][$key],$target1); $config['source_image']=$target1; $config['maintain_ratio']=TRUE; $config['width']=900; $config['height']=900; $this->image_lib->initialize($config); $this->image_lib->resize(); } if($ec_uploads != "") { $ec_uploads1 = preg_replace('/\s+/', '_', $ec_uploads); $ec_uploads_added = $ec_uploads1; } else { $ec_uploads_added =""; } if(!empty($ec_from_dates)) { $res['id']=$count; $res['ec_from']=$ec_from_dates; $res['ec_to']=$ec_to_dates; $res['ec_upload']=$ec_uploads_added; array_push($array,$res); $ec= json_encode($array); } else { $ec= ""; } } $owner_from_date = $this->input->post('owner_from_date'); $owner_to_date = $this->input->post('owner_to_date'); $owner_tax = $this->input->post('owner_tax'); $tax_count = 0; $array1 = array(); foreach ($owner_from_date as $keys => $values) { $tax_count++; $owner_from_dates = $values; $owner_to_dates = $owner_to_date[$keys]; if(empty($_FILES['owner_tax']['name'][$keys])) { $owner_taxs = ''; } else { $target='doc_owner_tax_uploads/'; $target.=$_FILES['owner_tax']['name'][$keys]; $owner_taxs=$_FILES['owner_tax']['name'][$keys]; $target1 = preg_replace('/\s+/', '_', $target); $image=$target1; move_uploaded_file($_FILES['owner_tax']['tmp_name'][$keys],$target1); $config['source_image']=$target1; $config['maintain_ratio']=TRUE; $config['width']=900; $config['height']=900; $this->image_lib->initialize($config); $this->image_lib->resize(); } if($owner_taxs != "") { $owner_taxs1 = preg_replace('/\s+/', '_', $owner_taxs); $owner_taxs_added = $owner_taxs1; } else { $owner_taxs_added =""; } if(!empty($owner_from_dates)) { $res1['id']=$tax_count; $res1['owner_from']=$owner_from_dates; $res1['owner_to']=$owner_to_dates; $res1['tax_upload']=$owner_taxs_added; array_push($array1,$res1); $owner= json_encode($array1); } else { $owner= ""; } } $doc_count = 0; $array2 = array(); $doc_name = $this->input->post('documents_name'); foreach ($doc_name as $keyss => $values) { $doc_count++; $document_name = $values; if(empty($_FILES['documents']['name'][$keys])) { $documents = ''; } else { $target='doc_owner_documents/'; /*$target.=time().$_FILES['documents']['name'][$keys]; $documents=time().$_FILES['documents']['name'][$keys];*/ $target.=$_FILES['documents']['name'][$keys]; $documents=$_FILES['documents']['name'][$keys]; $target1 = preg_replace('/\s+/', '_', $target); $image=$target1; move_uploaded_file($_FILES['documents']['tmp_name'][$keys],$target1); $config['source_image']=$target1; $config['maintain_ratio']=TRUE; $config['width']=900; $config['height']=900; $this->image_lib->initialize($config); $this->image_lib->resize(); } if($documents != "") { $documents1 = preg_replace('/\s+/', '_', $documents); $documents_added = $documents1; } else { $documents_added =""; } if(!empty($document_name)) { $res2['id']=$doc_count; $res2['doc_name']=$values; $res2['upload_doc']=$documents_added; array_push($array2,$res2); $upload_doc= json_encode($array2); } else { $upload_doc= ""; } } $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $created_at = $date->format('d-m-Y'); $data = array('project_id'=>$project_id, 'site_number'=>$site_number, 'owner_name'=>$owner_name, 'sales_agreement_files'=>$sales_agreement_files_added, 'sales_deed'=>$sales_deed_added, 'ec'=>$ec, 'owner'=>$owner, 'owner_khata'=>$owner_khata_added, 'upload_doc'=>$upload_doc, 'created_at'=>$created_at); $table = 'gss_doc_owner_documents'; $result = $this->gss_model->insert($table,$data); if($result) { echo json_encode(array('result'=>1,'message'=>"Added!")); } else { echo json_encode(array('result'=>0,'message'=>"File could not be added")); } } else { redirect('/'); } } public function owner_document_list() { $admin_id = session()->get('admin_id'); if($admin_id) { $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $table = "gss_doc_projects"; $where = array('delete_status'=>'ACTIVE'); $order_by = 'project_name'; $data['projects'] = $this->gss_model->get_where_result_alphabetical($table,$where,$order_by); $this->load->view('admin/doc_owner_document_list',$data); } else { redirect('/'); } } public function get_doc_owner_documents_list() { $project = $_GET['project']; $project_status = $_GET['project_status']; $result = $this->gss_model->get_doc_owner_document_details($project,$project_status); echo json_encode($result); } public function view_owner_ec_documents() { $id = $this->uri->segment(2); $where = array('id'=>$id); $table = "gss_doc_owner_documents"; $data['details'] = $this->gss_model->get_where_row($table,$where); $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $this->load->view('admin/view_owner_documents',$data); } public function view_owner_tax_documents() { $id = $this->uri->segment(2); $where = array('id'=>$id); $table = "gss_doc_owner_documents"; $data['details'] = $this->gss_model->get_where_row($table,$where); $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $this->load->view('admin/view_owner_tax_documents',$data); } public function view_owner_documents() { $id = $this->uri->segment(2); $where = array('id'=>$id); $table = "gss_doc_owner_documents"; $data['details'] = $this->gss_model->get_where_row($table,$where); $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $this->load->view('admin/view_owner_docs',$data); } public function view_owner_sales_agreement() { $id = $this->uri->segment(2); $where = array('id'=>$id); $table = "gss_doc_owner_documents"; $data['details'] = $this->gss_model->get_where_row($table,$where); $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $this->load->view('admin/view_owner_sales_agreement',$data); } public function view_owner_sales_deeds() { $id = $this->uri->segment(2); $where = array('id'=>$id); $table = "gss_doc_owner_documents"; $data['details'] = $this->gss_model->get_where_row($table,$where); $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $this->load->view('admin/view_owner_sales_deeds',$data); } public function view_owner_khata() { $id = $this->uri->segment(2); $where = array('id'=>$id); $table = "gss_doc_owner_documents"; $data['details'] = $this->gss_model->get_where_row($table,$where); $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $this->load->view('admin/view_owner_khata',$data); } public function edit_owner_documents() { $id = $this->uri->segment(2); $where = array('id'=>$id); $table = "gss_doc_owner_documents"; $data['details'] = $this->gss_model->get_where_row($table,$where); $table = "gss_doc_projects"; $where = array('delete_status'=>'ACTIVE'); $order_by ="project_name"; $data['projects'] = $this->gss_model->get_where_result_orderby_asc($table,$where,$order_by); $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $this->load->view('admin/edit_owner_document',$data); } public function update_owner_documents() { $admin_id = session()->get('admin_id'); if($admin_id) { $this->load->library('image_lib'); $id = $this->input->post('id'); $project_id = $this->input->post('project_id'); $site_number = $this->input->post('site_number'); $owner_name = $this->input->post('owner_name'); $table = 'gss_doc_owner_documents'; $where = array('id'=>$id); $det = $this->gss_model->get_where_row($table,$where); if(empty($_FILES['sales_agreement_files']['name'])) { $sales_agreement_files = $det->sales_agreement_files; } else { $target='doc_sales_agreement/'; $target.=$_FILES['sales_agreement_files']['name']; $sales_agreement_files=$_FILES['sales_agreement_files']['name']; $target1 = preg_replace('/\s+/', '_', $target); $image=$target1; move_uploaded_file($_FILES['sales_agreement_files']['tmp_name'],$target1); $config['source_image']=$target; $config['maintain_ratio']=TRUE; $config['width']=900; $config['height']=900; $this->image_lib->initialize($config); $this->image_lib->resize(); } if($sales_agreement_files != "") { $sales_agreement_files1 = preg_replace('/\s+/', '_', $sales_agreement_files); $sales_agreement_files_added = $sales_agreement_files1; } else { $sales_agreement_files_added =""; } if(empty($_FILES['sales_deed']['name'])) { $sales_deed = $det->sales_deed; } else { $target='doc_sales_deed/'; $target.=$_FILES['sales_deed']['name']; $sales_deed=$_FILES['sales_deed']['name']; $target1 = preg_replace('/\s+/', '_', $target); $image=$target1; move_uploaded_file($_FILES['sales_deed']['tmp_name'],$target1); $config['source_image']=$target; $config['maintain_ratio']=TRUE; $config['width']=900; $config['height']=900; $this->image_lib->initialize($config); $this->image_lib->resize(); } if($sales_deed != "") { $sales_deed1 = preg_replace('/\s+/', '_', $sales_deed); $sales_deed_added = $sales_deed1; } else { $sales_deed_added =""; } $ec_from_date = $this->input->post('ec_from_date'); $ec_to_date = $this->input->post('ec_to_date'); $ec_uploads = $this->input->post('ec_uploads'); $ec_uploaded = $this->input->post('ec_uploaded'); $arrays = array(); $get_ec = json_decode($det->ec); /*foreach($get_ec as $get_ecs) { $ec_uploaded= $get_ecs->ec_upload; array_push($arrays,$ec_uploaded); }*/ $count = 0; $array = array(); foreach ($ec_from_date as $key => $value) { $count++; $res['id']= $count; $res['ec_from'] = $value; $res['ec_to'] = $ec_to_date[$key]; if(empty($_FILES['ec_uploads']['name'][$key])) { $res['ec_upload'] = $ec_uploaded[$key]; $ec_uploads_added =""; } else { $target='doc_ec_uploads/'; /*$target.=time().$_FILES['ec_uploads']['name'][$key]; $ec_uploads=time().$_FILES['ec_uploads']['name'][$key];*/ $target.=$_FILES['ec_uploads']['name'][$key]; $ec_uploads=$_FILES['ec_uploads']['name'][$key]; $target1 = preg_replace('/\s+/', '_', $target); $image=$target1; move_uploaded_file($_FILES['ec_uploads']['tmp_name'][$key],$target1); $config['source_image']=$target; $config['maintain_ratio']=TRUE; $config['width']=900; $config['height']=900; $this->image_lib->initialize($config); $this->image_lib->resize(); $res['id']=$count; $res['ec_from']=$value; $res['ec_to']=$ec_to_date[$key]; $res['ec_upload']=$ec_uploads; if($ec_uploads != "") { $ec_uploads1 = preg_replace('/\s+/', '_', $ec_uploads); $ec_uploads_added = $ec_uploads1; } else { $ec_uploads_added =""; } } if(!empty($value)) { array_push($array,$res); $ec= json_encode($array); } else { $ec= ''; } } if(empty($_FILES['owner_khata']['name'])) { $owner_khata = $det->owner_khata; } else { $target='doc_owner_khata/'; /*$target.=time().$_FILES['owner_khata']['name']; $owner_khata=time().$_FILES['owner_khata']['name']; */ $target.=$_FILES['owner_khata']['name']; $owner_khata=$_FILES['owner_khata']['name']; $target1 = preg_replace('/\s+/', '_', $target); $image=$target1; move_uploaded_file($_FILES['owner_khata']['tmp_name'],$target1); $config['source_image']=$target; $config['maintain_ratio']=TRUE; $config['width']=900; $config['height']=900; $this->image_lib->initialize($config); $this->image_lib->resize(); } if($owner_khata != "") { $owner_khata1 = preg_replace('/\s+/', '_', $owner_khata); $owner_khata_added = $owner_khata1; } else { $owner_khata_added =""; } $owner_from_date = $this->input->post('owner_from_date'); $owner_to_date = $this->input->post('owner_to_date'); $owner_tax = $this->input->post('owner_tax'); $owner_tax_id = $this->input->post('owner_tax_id'); $owner_tax_uploaded = $this->input->post('owner_tax_uploaded'); $tax_count = 0; $array1 = array(); $get_tax = json_decode($det->owner); foreach ($owner_from_date as $keys => $values) { $tax_count++; $res1['id']= $tax_count; $res1['owner_from'] = $values; $res1['owner_to'] = $owner_to_date[$keys]; if(empty($_FILES['owner_tax']['name'][$keys])) { $res1['tax_upload'] = $owner_tax_uploaded[$keys]; $owner_taxs_added =""; } else { $target='doc_owner_tax_uploads/'; /*$target.=time().$_FILES['owner_tax']['name'][$keys]; $owner_taxs=time().$_FILES['owner_tax']['name'][$keys]; */ $target.=$_FILES['owner_tax']['name'][$keys]; $owner_taxs=$_FILES['owner_tax']['name'][$keys]; $target1 = preg_replace('/\s+/', '_', $target); $image=$target1; move_uploaded_file($_FILES['owner_tax']['tmp_name'][$keys],$target1); $config['source_image']=$target; $config['maintain_ratio']=TRUE; $config['width']=900; $config['height']=900; $this->image_lib->initialize($config); $this->image_lib->resize(); $get_tax = json_decode($det->owner); $res1['id']=$tax_count; $res1['owner_from']=$values; $res1['owner_to'] = $owner_to_date[$keys]; $res1['tax_upload']=$owner_taxs; if($owner_taxs != "") { $owner_taxs1 = preg_replace('/\s+/', '_', $owner_taxs); $owner_taxs_added = $owner_taxs1; } else { $owner_taxs_added =""; } } if(!empty($values)) { array_push($array1, $res1); $owner = json_encode($array1); } else { $owner= ''; } } $image_files = []; $array2 = array(); $doc_id = $this->input->post('documents_id'); $doc_name = $this->input->post('documents_name'); $doc_uploaded = $this->input->post('doc_uploaded'); $get_doc = json_decode($det->upload_doc); foreach ($doc_name as $keyss => $valuess) { $res2['id']=$doc_id[$keyss]; $res2['doc_name']=$valuess ; if(empty($_FILES['documents']['name'][$keyss])) { $res2['upload_doc'] = $doc_uploaded[$keyss]; $documents_added =""; } else { //echo "hi"; $target='doc_owner_documents/'; /*$target.=time().$_FILES['documents']['name'][$keyss]; $image_files=time().$_FILES['documents']['name'][$keyss];*/ $target.=$_FILES['documents']['name'][$keyss]; $image_files=$_FILES['documents']['name'][$keyss]; $target1 = preg_replace('/\s+/', '_', $target); $image=$target1; move_uploaded_file($_FILES['documents']['tmp_name'][$keyss],$target1); $config['source_image']=$target; $config['maintain_ratio']=TRUE; $config['width']=900; $config['height']=900; $this->image_lib->initialize($config); $this->image_lib->resize(); $get_doc = json_decode($det->upload_doc); $res2['id']=$doc_id[$keyss]; $res2['doc_name']=$valuess; $res2['upload_doc'] = $image_files; if($image_files != "") { $documents1 = preg_replace('/\s+/', '_', $documents); $documents_added = $documents1; } else { $documents_added =""; } } if(!empty($valuess)) { array_push($array2, $res2); $upload_doc = json_encode($array2); } else { $upload_doc= ''; } } $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $created_at = $date->format('d-m-Y'); $where = array('id'=>$id); $data = array('project_id'=>$project_id, 'site_number'=>$site_number, 'owner_name'=>$owner_name, 'sales_agreement_files'=>$sales_agreement_files_added, 'sales_deed'=>$sales_deed_added, 'ec'=>$ec, 'owner'=>$owner, 'owner_khata'=>$owner_khata_added, 'upload_doc'=>$upload_doc, 'modified_at'=>$created_at); $table = 'gss_doc_owner_documents'; $result = $this->gss_model->update($where,$table,$data); if($result) { echo json_encode(array('result'=>1,'message'=>"Updated!")); } else { echo json_encode(array('result'=>0,'message'=>"No changes added")); } } else { redirect('/'); } } public function delete_doc_owner_documents() { $table = 'gss_doc_owner_documents'; $id = $this->input->post('id'); $where = array('id'=>$id); $data = array('delete_status'=>'INACTIVE'); $result = $this->gss_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 document form public function client_document_form() { $admin_id = session()->get('admin_id'); if($admin_id) { $table = "gss_doc_projects"; $where = array('delete_status'=>'ACTIVE'); $order_by ="project_name"; $data['projects'] = $this->gss_model->get_where_result_orderby_asc($table,$where,$order_by); $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $this->load->view('admin/client_doc_form',$data); } else { redirect('/'); } } public function add_client_documents() { $admin_id = session()->get('admin_id'); if($admin_id) { $this->load->library('image_lib'); $project_id = $this->input->post('project_id'); $site_number = $this->input->post('site_number'); $client_name = $this->input->post('client_name'); if(empty($_FILES['booking_application']['name'])) { $booking_application = ''; } else { $target='doc_client_booking_applications/'; /*$target.=time().$_FILES['booking_application']['name']; $booking_application=time().$_FILES['booking_application']['name']; */ $target.=$_FILES['booking_application']['name']; $booking_application=$_FILES['booking_application']['name']; $target1 = preg_replace('/\s+/', '_', $target); $image=$target; move_uploaded_file($_FILES['booking_application']['tmp_name'],$target1); $config['source_image']=$target1; $config['maintain_ratio']=TRUE; $config['width']=900; $config['height']=900; $this->image_lib->initialize($config); $this->image_lib->resize(); } if($booking_application != "") { if(file_exists("doc_client_booking_applications/".$booking_application)) { $booking_applications = preg_replace('/\s+/', '_', $booking_application); $booking_application_added = $booking_applications; } else { $booking_application_added =""; echo json_encode(array('result'=>0,'message'=>"File could not be added. Please try again!")); } } else { $booking_application_added =""; } if(empty($_FILES['sales_agreement_files']['name'])) { $sales_agreement_files = ''; } else { $target='doc_client_sales_agreement/'; /*$target.=time().$_FILES['sales_agreement_files']['name']; $sales_agreement_files=time().$_FILES['sales_agreement_files']['name'];*/ $target.=$_FILES['sales_agreement_files']['name']; $sales_agreement_files=$_FILES['sales_agreement_files']['name']; $target1 = preg_replace('/\s+/', '_', $target); $image=$target; move_uploaded_file($_FILES['sales_agreement_files']['tmp_name'],$target1); $config['source_image']=$target1; $config['maintain_ratio']=TRUE; $config['width']=900; $config['height']=900; $this->image_lib->initialize($config); $this->image_lib->resize(); } if($sales_agreement_files != "") { if(file_exists("doc_client_sales_agreement/".$sales_agreement_files)) { $sales_agreement_filess = preg_replace('/\s+/', '_', $sales_agreement_files); $sales_agreement_files_added = $sales_agreement_filess; } else { $sales_agreement_files_added =""; echo json_encode(array('result'=>0,'message'=>"File could not be added. Please try again!")); } } else { $sales_agreement_files_added =""; } if(empty($_FILES['sales_deed']['name'])) { $sales_deed = ''; } else { $target='doc_client_sales_deed/'; /*$target.=time().$_FILES['sales_deed']['name']; $sales_deed=time().$_FILES['sales_deed']['name']; */ $target.=$_FILES['sales_deed']['name']; $sales_deed=$_FILES['sales_deed']['name']; $target1 = preg_replace('/\s+/', '_', $target); $image=$target; move_uploaded_file($_FILES['sales_deed']['tmp_name'],$target1); $config['source_image']=$target1; $config['maintain_ratio']=TRUE; $config['width']=900; $config['height']=900; $this->image_lib->initialize($config); $this->image_lib->resize(); } if($sales_deed != "") { if(file_exists("doc_client_sales_deed/".$sales_deed)) { $sales_deeds = preg_replace('/\s+/', '_', $sales_deed); $sales_deed_added = $sales_deeds; } else { $sales_deed_added =""; echo json_encode(array('result'=>0,'message'=>"File could not be added. Please try again!")); } } else { $sales_deed_added =""; } $ec_from_date = $this->input->post('ec_from_date'); $ec_to_date = $this->input->post('ec_to_date'); $ec_uploads = $this->input->post('ec_uploads'); $count = 0; $array = array(); foreach ($ec_from_date as $key => $value) { $count++; $ec_from_dates = $value; $ec_to_dates = $ec_to_date[$key]; if(empty($_FILES['ec_uploads']['name'][$key])) { $ec_uploads = ''; } else { $target='doc_client_ec_uploads/'; /*$target.=time().$_FILES['ec_uploads']['name'][$key]; $ec_uploads=time().$_FILES['ec_uploads']['name'][$key]; */ $target.=$_FILES['ec_uploads']['name'][$key]; $ec_uploads=$_FILES['ec_uploads']['name'][$key]; $target1 = preg_replace('/\s+/', '_', $target); $image=$target; move_uploaded_file($_FILES['ec_uploads']['tmp_name'][$key],$target1); $config['source_image']=$target1; $config['maintain_ratio']=TRUE; $config['width']=900; $config['height']=900; $this->image_lib->initialize($config); $this->image_lib->resize(); } if($ec_uploads != "") { if(file_exists("doc_client_ec_uploads/".$ec_uploads)) { $ec_up = preg_replace('/\s+/', '_', $ec_uploads); $ec_uploads_added = $ec_up; } else { $ec_uploads_added =""; echo json_encode(array('result'=>0,'message'=>"File could not be added. Please try again!")); die(); } } else { $ec_uploads_added =""; } if(!empty($value)) { $res['id']=$count; $res['ec_from']=$value; $res['ec_to']=$ec_to_dates; $res['ec_upload']=$ec_uploads_added; array_push($array,$res); $ec= json_encode($array); } else { $ec= ""; } } if(empty($_FILES['client_khata']['name'])) { $client_khata = ''; } else { $target='doc_client_khata/'; /*$target.=time().$_FILES['client_khata']['name']; $client_khata=time().$_FILES['client_khata']['name']; */ $target.=$_FILES['client_khata']['name']; $client_khata=$_FILES['client_khata']['name']; $target1 = preg_replace('/\s+/', '_', $target); $image=$target; move_uploaded_file($_FILES['client_khata']['tmp_name'],$target1); $config['source_image']=$target1; $config['maintain_ratio']=TRUE; $config['width']=900; $config['height']=900; $this->image_lib->initialize($config); $this->image_lib->resize(); } if($client_khata != "") { if(file_exists("doc_client_khata/".$client_khata)) { $client_khatas = preg_replace('/\s+/', '_', $client_khata); $client_khata_added = $client_khatas; } else { $client_khata_added =""; echo json_encode(array('result'=>0,'message'=>"File could not be added. Please try again!")); } } else { $client_khata_added =""; } $client_from_date = $this->input->post('client_from_date'); $client_to_date = $this->input->post('client_to_date'); $client_tax = $this->input->post('client_tax'); $paid_date = $this->input->post('paid_date'); $tax_count = 0; $array1 = array(); foreach ($client_from_date as $keys => $values) { $tax_count++; $client_from_dates = $values; $client_to_dates = $client_to_date[$keys]; if(empty($_FILES['client_tax']['name'][$keys])) { $client_taxs = ''; } else { $target='doc_client_tax_uploads/'; /* $target.=time().$_FILES['client_tax']['name'][$keys]; $client_taxs=time().$_FILES['client_tax']['name'][$keys]; */ $target.=$_FILES['client_tax']['name'][$keys]; $client_taxs=$_FILES['client_tax']['name'][$keys]; $target1 = preg_replace('/\s+/', '_', $target); $image=$target; move_uploaded_file($_FILES['client_tax']['tmp_name'][$keys],$target1); $config['source_image']=$target1; $config['maintain_ratio']=TRUE; $config['width']=900; $config['height']=900; $this->image_lib->initialize($config); $this->image_lib->resize(); } if($client_taxs != "") { if(file_exists("doc_client_tax_uploads/".$client_taxs)) { $client_taxss = preg_replace('/\s+/', '_', $client_taxs); $client_taxs_added = $client_taxss; } else { $client_taxs_added =""; echo json_encode(array('result'=>0,'message'=>"File could not be added. Please try again!")); die(); } } else { $client_taxs_added =""; } if(!empty($values)) { $res1['id'] = $tax_count; $res1['client_from']= $values; $res1['client_to'] = $client_to_dates; $res1['tax_upload']= $client_taxs_added; $res1['paid_date'] = $paid_date; array_push($array1,$res1); $client= json_encode($array1); } else { $client= ""; } } $doc_count = 0; $array2 = array(); $doc_name = $this->input->post('documents_name'); foreach ($doc_name as $keyss => $vals) { $doc_count++; $document_name = $vals; if(empty($_FILES['documents']['name'][$keyss])) { $documents = ''; } else { $target='doc_client_documents/'; /*$target.=time().$_FILES['documents']['name'][$keyss]; $documents=time().$_FILES['documents']['name'][$keyss]; */ $target.=$_FILES['documents']['name'][$keyss]; $documents=$_FILES['documents']['name'][$keyss]; $target1 = preg_replace('/\s+/', '_', $target); $image=$target; move_uploaded_file($_FILES['documents']['tmp_name'][$keyss],$target1); $config['source_image']=$target1; $config['maintain_ratio']=TRUE; $config['width']=900; $config['height']=900; $this->image_lib->initialize($config); $this->image_lib->resize(); } if($documents != "") { if(file_exists("doc_client_documents/".$documents)) { $documentss = preg_replace('/\s+/', '_', $documents); $documents_added = $documentss; } else { $documents_added =""; echo json_encode(array('result'=>0,'message'=>"File could not be added. Please try again!")); die(); } } else { $documents_added =""; } if(!empty($vals)) { $res2['id']=$doc_count; $res2['doc_name']=$vals; $res2['upload_doc']=$documents_added; array_push($array2,$res2); $upload_doc= json_encode($array2); } else { $upload_doc= ""; } } $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $created_at = $date->format('d-m-Y'); $data = array('project_id' =>$project_id, 'site_number' =>$site_number, 'client_name' =>$client_name, 'booking_application' =>$booking_application_added, 'sales_agreement_files' =>$sales_agreement_files_added, 'sales_deed' =>$sales_deed_added, 'ec' =>$ec, 'client' =>$client, 'client_khata' =>$client_khata_added, 'upload_doc' =>$upload_doc, 'created_at' =>$created_at); $table = 'gss_doc_client_documents'; $result = $this->gss_model->insert($table,$data); if($result) { echo json_encode(array('result'=>1,'message'=>"Added!")); } else { echo json_encode(array('result'=>0,'message'=>"Data could not be added")); } } else { redirect('/'); } } public function client_document_list() { $admin_id = session()->get('admin_id'); if($admin_id) { $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $table = "gss_doc_projects"; $where = array('delete_status'=>'ACTIVE'); $order_by = 'project_name'; $data['projects'] = $this->gss_model->get_where_result_alphabetical($table,$where,$order_by); $this->load->view('admin/doc_client_document_list',$data); } else { redirect('/'); } } public function get_doc_client_documents_list() { $project = $_GET['project']; $project_status = $_GET['project_status']; $result = $this->gss_model->get_doc_client_document_details($project,$project_status); echo json_encode($result); } public function view_client_ec_documents() { $id = $this->uri->segment(2); $where = array('id'=>$id); $table = "gss_doc_client_documents"; $data['details'] = $this->gss_model->get_where_row($table,$where); $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $this->load->view('admin/view_client_ec_documents',$data); } public function view_client_tax_documents() { $id = $this->uri->segment(2); $where = array('id'=>$id); $table = "gss_doc_client_documents"; $data['details'] = $this->gss_model->get_where_row($table,$where); $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $this->load->view('admin/view_client_tax_documents',$data); } public function view_client_documents() { $id = $this->uri->segment(2); $where = array('id'=>$id); $table = "gss_doc_client_documents"; $data['details'] = $this->gss_model->get_where_row($table,$where); $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $this->load->view('admin/view_client_docs',$data); } public function view_client_sales_agreement() { $id = $this->uri->segment(2); $where = array('id'=>$id); $table = "gss_doc_client_documents"; $data['details'] = $this->gss_model->get_where_row($table,$where); $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $this->load->view('admin/view_client_sales_agreement',$data); } public function view_client_sales_deeds() { $id = $this->uri->segment(2); $where = array('id'=>$id); $table = "gss_doc_client_documents"; $data['details'] = $this->gss_model->get_where_row($table,$where); $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $this->load->view('admin/view_client_sales_deed',$data); } public function view_client_khata() { $id = $this->uri->segment(2); $where = array('id'=>$id); $table = "gss_doc_client_documents"; $data['details'] = $this->gss_model->get_where_row($table,$where); $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $this->load->view('admin/view_client_khata',$data); } public function view_client_booking_application() { $id = $this->uri->segment(2); $where = array('id'=>$id); $table = "gss_doc_client_documents"; $data['details'] = $this->gss_model->get_where_row($table,$where); $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $this->load->view('admin/view_client_booking_application',$data); } public function edit_client_documents() { $id = $this->uri->segment(2); $where = array('id'=>$id); $table = "gss_doc_client_documents"; $data['details'] = $this->gss_model->get_where_row($table,$where); $table = "gss_doc_projects"; $where = array('delete_status'=>'ACTIVE'); $order_by ="project_name"; $data['projects'] = $this->gss_model->get_where_result_orderby_asc($table,$where,$order_by); $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $this->load->view('admin/edit_client_document',$data); } public function update_client_documents() { $admin_id = session()->get('admin_id'); if($admin_id) { $this->load->library('image_lib'); $id = $this->input->post('id'); $project_id = $this->input->post('project_id'); $site_number = $this->input->post('site_number'); $client_name = $this->input->post('client_name'); $table = 'gss_doc_client_documents'; $where = array('id'=>$id); $det = $this->gss_model->get_where_row($table,$where); if(empty($_FILES['booking_application']['name'])) { $booking_application = $det->booking_application; } else { $target='doc_client_booking_applications/'; /*$target.=time().$_FILES['booking_application']['name']; $booking_application=time().$_FILES['booking_application']['name']; */ $target.=$_FILES['booking_application']['name']; $booking_application=$_FILES['booking_application']['name']; $target1 = preg_replace('/\s+/', '_', $target); $image=$target; move_uploaded_file($_FILES['booking_application']['tmp_name'],$target1); $config['source_image']=$target1; $config['maintain_ratio']=TRUE; $config['width']=900; $config['height']=900; $this->image_lib->initialize($config); $this->image_lib->resize(); } if($booking_application != "") { if(file_exists("doc_client_booking_applications/".$booking_application)) { $booking_applications = preg_replace('/\s+/', '_', $booking_application); $booking_application_added = $booking_applications; } else { $booking_application_added =""; echo json_encode(array('result'=>0,'message'=>"File could not be added. Please try again!")); } } else { $booking_application_added =""; } if(empty($_FILES['sales_agreement_files']['name'])) { $sales_agreement_files = $det->sales_agreement_files; } else { $target='doc_client_sales_agreement/'; /*$target.=time().$_FILES['sales_agreement_files']['name']; $sales_agreement_files=time().$_FILES['sales_agreement_files']['name'];*/ $target.=$_FILES['sales_agreement_files']['name']; $sales_agreement_files=$_FILES['sales_agreement_files']['name']; $target1 = preg_replace('/\s+/', '_', $target); $image=$target; move_uploaded_file($_FILES['sales_agreement_files']['tmp_name'],$target1); $config['source_image']=$target1; $config['maintain_ratio']=TRUE; $config['width']=900; $config['height']=900; $this->image_lib->initialize($config); $this->image_lib->resize(); } if($sales_agreement_files != "") { if(file_exists("doc_client_sales_agreement/".$sales_agreement_files)) { $sales_agreement_filess = preg_replace('/\s+/', '_', $sales_agreement_files); $sales_agreement_files_added = $sales_agreement_filess; } else { $sales_agreement_files_added =""; echo json_encode(array('result'=>0,'message'=>"File could not be added. Please try again!")); } } else { $sales_agreement_files_added =""; } if(empty($_FILES['sales_deed']['name'])) { $sales_deed = $det->sales_deed; } else { $target='doc_client_sales_deed/'; /*$target.=time().$_FILES['sales_deed']['name']; $sales_deed=time().$_FILES['sales_deed']['name'];*/ $target.=$_FILES['sales_deed']['name']; $sales_deed=$_FILES['sales_deed']['name']; $target1 = preg_replace('/\s+/', '_', $target); $image=$target; move_uploaded_file($_FILES['sales_deed']['tmp_name'],$target1); $config['source_image']=$target1; $config['maintain_ratio']=TRUE; $config['width']=900; $config['height']=900; $this->image_lib->initialize($config); $this->image_lib->resize(); } if($sales_deed != "") { if(file_exists("doc_client_sales_deed/".$sales_deed)) { $sales_deeds = preg_replace('/\s+/', '_', $sales_deed); $sales_deed_added = $sales_deeds; } else { $sales_deed_added =""; echo json_encode(array('result'=>0,'message'=>"File could not be added. Please try again!")); } } else { $sales_deed_added =""; } $ec_from_date = $this->input->post('ec_from_date'); $ec_to_date = $this->input->post('ec_to_date'); $ec_uploads = $this->input->post('ec_uploads'); $ec_uploaded = $this->input->post('ec_uploaded'); $arrays = array(); $get_ec = json_decode($det->ec); $count = 0; $array = array(); foreach ($ec_from_date as $key => $value) { $count++; $res['id']= $count; $res['ec_from'] = $value; $res['ec_to'] = $ec_to_date[$key]; if(empty($_FILES['ec_uploads']['name'][$key])) { $res['ec_upload'] = $ec_uploaded[$key]; } else { $target='doc_client_ec_uploads/'; /*$target.=time().$_FILES['ec_uploads']['name'][$key]; $ec_uploads=time().$_FILES['ec_uploads']['name'][$key]; */ $target.=$_FILES['ec_uploads']['name'][$key]; $ec_uploads=$_FILES['ec_uploads']['name'][$key]; $target1 = preg_replace('/\s+/', '_', $target); $image=$target; move_uploaded_file($_FILES['ec_uploads']['tmp_name'][$key],$target1); $config['source_image']=$target1; $config['maintain_ratio']=TRUE; $config['width']=900; $config['height']=900; $this->image_lib->initialize($config); $this->image_lib->resize(); $res['id']=$count; $res['ec_from']=$value; $res['ec_to']=$ec_to_date[$key]; $res['ec_upload']=$ec_uploads; } if($ec_uploads != "") { if(file_exists("doc_client_ec_uploads/".$ec_uploads)) { $ec_uploadss = preg_replace('/\s+/', '_', $ec_uploads); $ec_uploads_added = $ec_uploadss; } else { $ec_uploads_added =""; echo json_encode(array('result'=>0,'message'=>"File could not be added. Please try again!")); die(); } } else { $ec_uploads_added =""; } if(!empty($value)) { array_push($array,$res); $ec= json_encode($array); } else { $ec= ''; } } if(empty($_FILES['client_khata']['name'])) { $client_khata = $det->client_khata; } else { $target='doc_client_khata/'; /* $target.=time().$_FILES['client_khata']['name']; $client_khata=time().$_FILES['client_khata']['name']; */ $target.=$_FILES['client_khata']['name']; $client_khata=$_FILES['client_khata']['name']; $target1 = preg_replace('/\s+/', '_', $target); $image=$target; move_uploaded_file($_FILES['client_khata']['tmp_name'],$target1); $config['source_image']=$target1; $config['maintain_ratio']=TRUE; $config['width']=900; $config['height']=900; $this->image_lib->initialize($config); //$this->image_lib->resize(); } if($client_khata != "") { if(file_exists("doc_client_khata/".$client_khata)) { $client_khatas = preg_replace('/\s+/', '_', $client_khata); $client_khata_added = $client_khatas; } else { $client_khata_added =""; echo json_encode(array('result'=>0,'message'=>"File could not be added. Please try again!")); } } else { $client_khata_added =""; } $client_from_date = $this->input->post('client_from_date'); $client_to_date = $this->input->post('client_to_date'); $client_tax = $this->input->post('client_tax'); $client_tax_id = $this->input->post('client_tax_id'); $paid_date = $this->input->post('paid_date'); $client_tax_uploaded = $this->input->post('client_tax_uploaded'); $tax_count = 0; $array1 = array(); $get_tax = json_decode($det->client); if(!empty($client_from_date)) { foreach ($client_from_date as $keys => $values) { $tax_count++; $res1['id']= $tax_count; $res1['client_from'] = $values; $res1['client_to'] = $client_to_date[$keys]; $res1['paid_date'] = $paid_date[$keys]; if(empty($_FILES['client_tax']['name'][$keys])) { $res1['tax_upload'] = $client_tax_uploaded[$keys]; } else { $target='doc_client_tax_uploads/'; /*$target.=time().$_FILES['client_tax']['name'][$keys]; $client_taxs=time().$_FILES['client_tax']['name'][$keys];*/ $target.=$_FILES['client_tax']['name'][$keys]; $client_taxs=$_FILES['client_tax']['name'][$keys]; $target1 = preg_replace('/\s+/', '_', $target); $image=$target; move_uploaded_file($_FILES['client_tax']['tmp_name'][$keys],$target1); $config['source_image']=$target1; $config['maintain_ratio']=TRUE; $config['width']=900; $config['height']=900; $this->image_lib->initialize($config); $this->image_lib->resize(); $get_tax = json_decode($det->client); $res1['id']=$tax_count; $res1['client_from']=$values; $res1['client_to'] = $client_to_date[$keys]; $res1['paid_date'] = $paid_date[$keys]; $res1['tax_upload']=$client_taxs; } if($client_taxs != "") { if(file_exists("doc_client_tax_uploads/".$client_taxs)) { $client_taxss = preg_replace('/\s+/', '_', $client_taxs); $client_taxs_added = $client_taxss; } else { $client_taxs_added =""; echo json_encode(array('result'=>0,'message'=>"File could not be added. Please try again!")); die(); } } else { $client_taxs_added =""; } if(!empty($values)) { array_push($array1, $res1); $client = json_encode($array1); } else { $client =''; } } } else { $client =""; } $image_files = []; $array2 = array(); $doc_id = $this->input->post('documents_id'); $doc_name = $this->input->post('documents_name'); $doc_uploaded = $this->input->post('doc_uploaded'); $get_doc = json_decode($det->upload_doc); if(!empty($doc_uploaded)) { $documents=''; foreach ($doc_name as $keyss => $valuess) { $res2['id']=$doc_id[$keyss]; $res2['doc_name']=$valuess; if(empty($_FILES['documents']['name'][$keyss])) { $res2['upload_doc'] = $doc_uploaded[(int)$keyss]; } else { $target='doc_client_documents/'; /*$target.=time().$_FILES['documents']['name'][$keyss]; $image_files=time().$_FILES['documents']['name'][$keyss]; */ $target.=$_FILES['documents']['name'][$keyss]; $image_files=$_FILES['documents']['name'][$keyss]; $target1 = preg_replace('/\s+/', '_', $target); $image=$target; move_uploaded_file($_FILES['documents']['tmp_name'][$keyss],$target1); $config['source_image']=$target1; $config['maintain_ratio']=TRUE; $config['width']=900; $config['height']=900; //$this->image_lib->initialize($config); //$this->image_lib->resize(); $this->load->library('image_lib'); $get_doc = json_decode($det->upload_doc); $res2['id']=$doc_id[$keyss]; $res2['doc_name']=$valuess; $res2['upload_doc'] = $image_files; } if($documents != "") { if(file_exists("doc_client_documents/".$documents)) { $documentss = preg_replace('/\s+/', '_', $documents); $documents_added = $documentss; } else { $documents_added =""; echo json_encode(array('result'=>0,'message'=>"File could not be added. Please try again!")); die(); } } else { $documents_added =""; } if(!empty($valuess)) { array_push($array2, $res2); $upload_doc = json_encode($array2); } else { $upload_doc = ''; } } } else { $upload_doc =""; } $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $created_at = $date->format('d-m-Y'); $where = array('id'=>$id); $data = array('project_id' =>$project_id, 'site_number' =>$site_number, 'client_name' =>$client_name, 'booking_application' =>$booking_application_added, 'sales_agreement_files' =>$sales_agreement_files_added, 'sales_deed' =>$sales_deed_added, 'ec' =>$ec, 'client' =>$client, 'client_khata' =>$client_khata_added, 'upload_doc' =>$upload_doc, 'modified_at' =>$created_at); $table = 'gss_doc_client_documents'; $result = $this->gss_model->update($where,$table,$data); if($result) { echo json_encode(array('result'=>1,'message'=>"Updated!")); } else { echo json_encode(array('result'=>0,'message'=>"Data could not be added")); } } else { redirect('/'); } } public function delete_doc_client_documents() { $table = 'gss_doc_client_documents'; $id = $this->input->post('id'); $where = array('id'=>$id); $data = array('delete_status'=>'INACTIVE'); $result = $this->gss_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 send_mail_owner_contents() { $admin_id = session()->get('admin_id'); if($admin_id) { $id = $this->uri->segment(2); $table = 'gss_doc_owner_documents'; $where = array('id'=>$id); $data['details'] = $details = $this->gss_model->get_where_row($table,$where); $project_id = $details->project_id; $table = 'gss_doc_projects'; $where = array('id'=>$project_id); $data['project'] = $this->gss_model->get_where_row($table,$where); $table = 'gss_login'; $where = array('user_id'=>$admin_id); $data['user'] = $this->gss_model->get_where_row($table,$where); $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $this->load->view('admin/send_mail_contents',$data); } else { redirect('/'); } } public function add_owner_doc_email() { $admin_id = session()->get('admin_id'); if($admin_id) { $from = $this->input->post('from'); $to = $this->input->post('to'); $subject = $this->input->post('subject'); $message = $this->input->post('message'); $document = $this->input->post('document'); $file_type = $this->input->post('file_type'); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $created_at = $date->format('d-m-Y'); $table = 'gss_owner_mail_khata'; $data = array('email_from'=>$from, 'email_to'=>$to, 'subject'=>$subject, 'message'=>$message, 'document'=>$document, 'delete_status'=>'ACTIVE', 'created_at'=>$created_at); $result = $this->gss_model->insert($table,$data); if($result) { $where = array('id'=>$result); $table = 'gss_owner_mail_khata'; $details = $this->gss_model->get_where_row($table,$where); $from = $details->email_from; $email_to = $details->email_to; $subject = $details->subject; $message = $details->message; $document = $details->document; $login_table = 'gss_login'; $where_login = array('user_id'=>$admin_id); $get_sign = $this->gss_model->get_where_row($login_table,$where_login); $sign = $get_sign->signature; $cc = $get_sign->email; $base_url = base_url(); $message = $details->message; $message .= '<br>'; $message .= '<br>'; $message .= 'Thanks and regards,<br>'; $message .= '<br>'; $message .= "<img src='".$base_url."assets/images/gss_logo.jpg' style='width:20%'>"; $message .= '<br>'; $message .= $sign; // $body = $message; if($file_type == "owk") { $path = './doc_owner_khata/'.$document; } else if($file_type == "owa") { $path = './doc_sales_agreement/'.$document; } else if($file_type == "owd") { $path = './doc_sales_deed/'.$document; } $this->load->library('email'); $config = array( 'protocol' => 'smtp', 'smtp_host' => 'ssl://smtp.googlemail.com', 'smtp_port' => 465, 'smtp_user' => 'gssorganised@gmail.com', 'smtp_pass' => 'GSSKarthi@1236#', 'mailtype' => 'html', 'charset' => 'utf-8' ); $this->email->initialize($config); $this->email->set_mailtype("html"); $this->email->set_newline("\r\n"); $this->email->from($from,'GSS'); // change it to yours $this->email->to($to,'GSS');// change it to yours //$this->email->cc('sowmyashreelr@gmail.com'); $this->email->cc($cc); $this->email->subject($subject); $this->email->message($message); $this->email->attach($path); if ($this->email->send()) { echo json_encode(array('result'=>1,'message'=>'Your Email has successfully been sent.')); } else { echo json_encode(array('result'=>0,'message'=>'Something Went Wrong!')); show_error($this->email->print_debugger()); } } else { } } else { redirect('/'); } } public function send_mail_owner_tax() { $admin_id = session()->get('admin_id'); if($admin_id) { $id = $this->uri->segment(2); $table = 'gss_doc_owner_documents'; $where = array('id'=>$id); $data['details'] = $details = $this->gss_model->get_where_row($table,$where); $table = 'gss_owner_tax_docs'; $where = array('owner_doc_id'=>$id); $data['docs'] = $this->gss_model->get_where_row($table,$where); $project_id = $details->project_id; $table = 'gss_doc_projects'; $where = array('id'=>$project_id); $data['project'] = $this->gss_model->get_where_row($table,$where); $table = 'gss_login'; $where = array('user_id'=>$admin_id); $data['user'] = $this->gss_model->get_where_row($table,$where); $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $this->load->view('admin/send_owner_mail',$data); } else { redirect('/'); } } public function add_owner_doc_tax() { $admin_id = session()->get('admin_id'); if($admin_id) { $from = $this->input->post('from'); $to = $this->input->post('to'); $subject = $this->input->post('subject'); $message = $this->input->post('message'); $document = $this->input->post('documents'); $file_type = $this->input->post('file_type'); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $created_at = $date->format('d-m-Y'); $table = 'gss_owner_mail_khata'; $data = array('email_from'=>$from, 'email_to'=>$to, 'subject'=>$subject, 'message'=>$message, 'document'=>json_encode($document), 'delete_status'=>'ACTIVE', 'created_at'=>$created_at); $result = $this->gss_model->insert($table,$data); if($result) { $where = array('id'=>$result); $table = 'gss_owner_mail_khata'; $details = $this->gss_model->get_where_row($table,$where); $from = $details->email_from; $email_to = $details->email_to; $subject = $details->subject; $message = $details->message; $documents = json_decode($details->document); $array = array(); foreach ($documents as $value) { $doc = $value; if($file_type == "owt") { $path = './doc_owner_tax_uploads/'.$doc; } else if($file_type == "owe") { $path = './doc_ec_uploads/'.$doc; } else if($file_type == "od") { $path = './doc_owner_documents/'.$doc; } array_push($array,$path); } $doc_attach = $array; $login_table = 'gss_login'; $where_login = array('user_id'=>$admin_id); $get_sign = $this->gss_model->get_where_row($login_table,$where_login); $sign = $get_sign->signature; $cc = $get_sign->email; $base_url = base_url(); $message = $details->message; $message .= '<br>'; $message .= '<br>'; $message .= 'Thanks and regards,<br>'; $message .= '<br>'; $message .= "<img src='".$base_url."assets/images/gss_logo.jpg' style='width:20%'>"; $message .= '<br>'; $message .= $sign; $this->load->library('email'); $this->load->library('upload'); $config = array( 'protocol' => 'smtp', 'smtp_host' => 'ssl://smtp.googlemail.com', 'smtp_port' => 465, 'smtp_user' => 'gssorganised@gmail.com', 'smtp_pass' => 'GSSKarthi@1236#', 'mailtype' => 'html', 'charset' => 'utf-8' ); $this->email->initialize($config); $this->email->set_mailtype("html"); $this->email->set_newline("\r\n"); $this->email->from($from,'GSS'); // change it to yours $this->email->to($to,'GSS');// change it to yours //$this->email->cc('sowmyashreelr@gmail.com'); $this->email->cc($cc); $this->email->subject($subject); $this->email->message($message); foreach($doc_attach as $value) { $this->email->attach($value); } if ($this->email->send()) { echo json_encode(array('result'=>1,'message'=>'Your Email has successfully been sent.')); } else { echo json_encode(array('result'=>0,'message'=>'Something Went Wrong!')); show_error($this->email->print_debugger()); } } else { } } else { redirect('/'); } } public function send_mail_client_contents() { $admin_id = session()->get('admin_id'); if($admin_id) { $id = $this->uri->segment(2); $table = 'gss_doc_client_documents'; $where = array('id'=>$id); $data['details'] = $details = $this->gss_model->get_where_row($table,$where); $project_id = $details->project_id; $table = 'gss_doc_projects'; $where = array('id'=>$project_id); $data['project'] = $this->gss_model->get_where_row($table,$where); $table = 'gss_login'; $where = array('user_id'=>$admin_id); $data['user'] = $this->gss_model->get_where_row($table,$where); $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $this->load->view('admin/send_mail_cleint_contents',$data); } else { redirect('/'); } } public function add_client_doc_email() { $admin_id = session()->get('admin_id'); if($admin_id) { $from = $this->input->post('from'); $to = $this->input->post('to'); $subject = $this->input->post('subject'); $message = $this->input->post('message'); $document = $this->input->post('document'); $file_type = $this->input->post('file_type'); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $created_at = $date->format('d-m-Y'); $table = 'gss_client_mail_details'; $data = array('email_from'=>$from, 'email_to'=>$to, 'subject'=>$subject, 'message'=>$message, 'document'=>$document, 'delete_status'=>'ACTIVE', 'created_at'=>$created_at); $result = $this->gss_model->insert($table,$data); if($result) { $where = array('id'=>$result); $table = 'gss_client_mail_details'; $details = $this->gss_model->get_where_row($table,$where); $from = $details->email_from; $email_to = $details->email_to; $subject = $details->subject; $message = $details->message; $document = $details->document; $login_table = 'gss_login'; $where_login = array('user_id'=>$admin_id); $get_sign = $this->gss_model->get_where_row($login_table,$where_login); $sign = $get_sign->signature; $cc = $get_sign->email; $base_url = base_url(); $message = $details->message; $message .= '<br>'; $message .= '<br>'; $message .= 'Thanks and regards,<br>'; $message .= '<br>'; $message .= "<img src='".$base_url."assets/images/gss_logo.jpg' style='width:20%'>"; $message .= '<br>'; $message .= $sign; // $body = $message; if($file_type == "cba") { $path = './doc_client_booking_applications/'.$document; } else if($file_type == "csa") { $path = './doc_client_sales_agreement/'.$document; } else if($file_type == "csd") { $path = './doc_client_sales_deed/'.$document; } else if($file_type == "ck") { $path = './doc_client_khata/'.$document; } $this->load->library('email'); $config = array( 'protocol' => 'smtp', 'smtp_host' => 'ssl://smtp.googlemail.com', 'smtp_port' => 465, 'smtp_user' => 'gssorganised@gmail.com', 'smtp_pass' => 'GSSKarthi@1236#', 'mailtype' => 'html', 'charset' => 'utf-8' ); $this->email->initialize($config); $this->email->set_mailtype("html"); $this->email->set_newline("\r\n"); $this->email->from($from,'GSS'); // change it to yours $this->email->to($to,'GSS');// change it to yours //$this->email->cc('sowmyashreelr@gmail.com'); $this->email->cc($cc); $this->email->subject($subject); $this->email->message($message); $this->email->attach($path); if ($this->email->send()) { echo json_encode(array('result'=>1,'message'=>'Your Email has successfully been sent.')); } else { echo json_encode(array('result'=>0,'message'=>'Something Went Wrong!')); show_error($this->email->print_debugger()); } } else { } } else { redirect('/'); } } public function get_tax_selected() { $admin_id = session()->get('admin_id'); if($admin_id) { $id = $this->input->post('id'); $where = array('id'=>$id); $table = 'gss_doc_owner_documents'; $check = $this->gss_model->get_where_row($table,$where); $get_tax = $check->owner; $tax = json_decode($get_tax); $selected_tax = $this->input->post('selected_tax'); $owner_array = array(); foreach ($selected_tax as $ot) { $owner_tax = $ot; $array = array(); foreach($tax as $key=>$get_tax_id) { $tax_ids = $get_tax_id->id; $uploads = $get_tax_id->tax_upload; if($tax_ids == $owner_tax) { $owner_tax_doc = $uploads; array_push($owner_array,$owner_tax_doc); } } } $owner_docs = json_encode($owner_array); $table = 'gss_owner_tax_docs'; $where = array('owner_doc_id'=>$id); $check_row = $this->gss_model->get_where_row($table,$where); if(empty($check_row)) { $data = array('owner_doc_id'=>$id,'document'=>$owner_docs); $result = $this->db->insert($table,$data); if($result) { echo json_encode(array('result'=>1)); } else { echo json_encode(array('result'=>0)); } } else { $where = array('owner_doc_id'=>$id); $this->gss_model->delete($table,$where); $data = array('owner_doc_id'=>$id,'document'=>$owner_docs); $result = $this->db->insert($table,$data); if($result) { echo json_encode(array('result'=>1)); } else { echo json_encode(array('result'=>0)); } } } else { redirect('/'); } } public function get_ec_selected() { $id = $this->input->post('id'); $where = array('id'=>$id); $table = 'gss_doc_owner_documents'; $check = $this->gss_model->get_where_row($table,$where); $get_ec = $check->ec; $ec = json_decode($get_ec); $ec_id = $this->input->post('ec_id'); $ec_array = array(); foreach ($ec_id as $ot) { $owner_ec = $ot; $array = array(); foreach($ec as $key=>$get_ec_id) { $ec_ids = $get_ec_id->id; $uploads = $get_ec_id->ec_upload; if($ec_ids == $owner_ec) { $owner_ec_doc = $uploads; array_push($ec_array,$owner_ec_doc); } } } $ec_docs = json_encode($ec_array); $table = 'gss_owner_tax_docs'; $where = array('owner_doc_id'=>$id); $check_row = $this->gss_model->get_where_row($table,$where); if(empty($check_row)) { $data = array('owner_doc_id'=>$id,'document'=>$ec_docs); $result = $this->db->insert($table,$data); if($result) { echo json_encode(array('result'=>1)); } else { echo json_encode(array('result'=>0)); } } else { $where = array('owner_doc_id'=>$id); $this->gss_model->delete($table,$where); $data = array('owner_doc_id'=>$id,'document'=>$ec_docs); $result = $this->db->insert($table,$data); if($result) { echo json_encode(array('result'=>1)); } else { echo json_encode(array('result'=>0)); } } } public function get_doc_selected() { $id = $this->input->post('id'); $where = array('id'=>$id); $table = 'gss_doc_owner_documents'; $check = $this->gss_model->get_where_row($table,$where); $get_ec = $check->upload_doc; $client_doc = json_decode($get_ec); $ec_id = $this->input->post('ec_id'); $ec_array = array(); foreach ($ec_id as $ot) { $owner_ec = $ot; $array = array(); foreach($client_doc as $key=>$get_ec_id) { $ec_ids = $get_ec_id->id; $uploads = $get_ec_id->upload_doc; if($ec_ids == $owner_ec) { $owner_ec_doc = $uploads; array_push($ec_array,$owner_ec_doc); } } } $ec_docs = json_encode($ec_array); $table = 'gss_owner_tax_docs'; $where = array('owner_doc_id'=>$id); $check_row = $this->gss_model->get_where_row($table,$where); if(empty($check_row)) { $data = array('owner_doc_id'=>$id,'document'=>$ec_docs); $result = $this->db->insert($table,$data); if($result) { echo json_encode(array('result'=>1)); } else { echo json_encode(array('result'=>0)); } } else { $where = array('owner_doc_id'=>$id); $this->gss_model->delete($table,$where); $data = array('owner_doc_id'=>$id,'document'=>$ec_docs); $result = $this->db->insert($table,$data); if($result) { echo json_encode(array('result'=>1)); } else { echo json_encode(array('result'=>0)); } } } public function send_mail_client_tax() { $admin_id = session()->get('admin_id'); if($admin_id) { $id = $this->uri->segment(2); $table = 'gss_doc_client_documents'; $where = array('id'=>$id); $data['details'] = $details = $this->gss_model->get_where_row($table,$where); $table = 'gss_client_tax_docs'; $where = array('client_doc_id'=>$id); $data['docs'] = $this->gss_model->get_where_row($table,$where); $project_id = $details->project_id; $table = 'gss_doc_projects'; $where = array('id'=>$project_id); $data['project'] = $this->gss_model->get_where_row($table,$where); $table = 'gss_login'; $where = array('user_id'=>$admin_id); $data['user'] = $this->gss_model->get_where_row($table,$where); $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $this->load->view('admin/send_client_mail',$data); } else { redirect('/'); } } public function add_client_doc_tax() { $admin_id = session()->get('admin_id'); if($admin_id) { $from = $this->input->post('from'); $to = $this->input->post('to'); $subject = $this->input->post('subject'); $message = $this->input->post('message'); $document = $this->input->post('documents'); $file_type = $this->input->post('file_type'); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $created_at = $date->format('d-m-Y'); $table = 'gss_client_mail_details'; $data = array('email_from'=>$from, 'email_to'=>$to, 'subject'=>$subject, 'message'=>$message, 'document'=>json_encode($document), 'delete_status'=>'ACTIVE', 'created_at'=>$created_at); $result = $this->gss_model->insert($table,$data); if($result) { $where = array('id'=>$result); $table = 'gss_client_mail_details'; $details = $this->gss_model->get_where_row($table,$where); $from = $details->email_from; $email_to = $details->email_to; $subject = $details->subject; $message = $details->message; $documents = json_decode($details->document); $array = array(); foreach ($documents as $value) { $doc = $value; if($file_type == "ce") { $path = './doc_client_ec_uploads/'.$doc; } else if($file_type == "ct") { $path = './doc_client_tax_uploads/'.$doc; } else if($file_type == "cd") { $path = './doc_client_documents/'.$doc; } array_push($array,$path); } $doc_attach = $array; $login_table = 'gss_login'; $where_login = array('user_id'=>$admin_id); $get_sign = $this->gss_model->get_where_row($login_table,$where_login); $sign = $get_sign->signature; $cc = $get_sign->email; $base_url = base_url(); $message = $details->message; $message .= '<br>'; $message .= '<br>'; $message .= 'Thanks and regards,<br>'; $message .= '<br>'; $message .= "<img src='".$base_url."assets/images/gss_logo.jpg' style='width:20%'>"; $message .= '<br>'; $message .= $sign; $this->load->library('email'); $this->load->library('upload'); $config = array( 'protocol' => 'smtp', 'smtp_host' => 'ssl://smtp.googlemail.com', 'smtp_port' => 465, 'smtp_user' => 'gssorganised@gmail.com', 'smtp_pass' => 'GSSKarthi@1236#', 'mailtype' => 'html', 'charset' => 'utf-8' ); $this->email->initialize($config); $this->email->set_mailtype("html"); $this->email->set_newline("\r\n"); $this->email->from($from,'GSS'); // change it to yours $this->email->to($to,'GSS');// change it to yours //$this->email->cc('sowmyashreelr@gmail.com'); $this->email->cc($cc); $this->email->subject($subject); $this->email->message($message); foreach($doc_attach as $value) { $this->email->attach($value); } if ($this->email->send()) { echo json_encode(array('result'=>1,'message'=>'Your Email has successfully been sent.')); } else { echo json_encode(array('result'=>0,'message'=>'Something Went Wrong!')); show_error($this->email->print_debugger()); } } else { } } else { redirect('/'); } } public function get_client_ec_selected() { $id = $this->input->post('id'); $where = array('id'=>$id); $table = 'gss_doc_client_documents'; $check = $this->gss_model->get_where_row($table,$where); $get_ec = $check->ec; $ec = json_decode($get_ec); $ec_id = $this->input->post('ec_id'); $ec_array = array(); foreach ($ec_id as $ot) { $owner_ec = $ot; $array = array(); foreach($ec as $key=>$get_ec_id) { $ec_ids = $get_ec_id->id; $uploads = $get_ec_id->ec_upload; if($ec_ids == $owner_ec) { $owner_ec_doc = $uploads; array_push($ec_array,$owner_ec_doc); } } } $ec_docs = json_encode($ec_array); $table = 'gss_client_tax_docs'; $where = array('client_doc_id'=>$id); $check_row = $this->gss_model->get_where_row($table,$where); if(empty($check_row)) { $data = array('client_doc_id'=>$id,'document'=>$ec_docs); $result = $this->db->insert($table,$data); if($result) { echo json_encode(array('result'=>1)); } else { echo json_encode(array('result'=>0)); } } else { $where = array('client_doc_id'=>$id); $this->gss_model->delete($table,$where); $data = array('client_doc_id'=>$id,'document'=>$ec_docs); $result = $this->db->insert($table,$data); if($result) { echo json_encode(array('result'=>1)); } else { echo json_encode(array('result'=>0)); } } } public function get_client_tax_selected() { $id = $this->input->post('id'); $where = array('id'=>$id); $table = 'gss_doc_client_documents'; $check = $this->gss_model->get_where_row($table,$where); $get_ec = $check->client; $client_doc = json_decode($get_ec); $ec_id = $this->input->post('ec_id'); $ec_array = array(); foreach ($ec_id as $ot) { $owner_ec = $ot; $array = array(); foreach($client_doc as $key=>$get_ec_id) { $ec_ids = $get_ec_id->id; $uploads = $get_ec_id->tax_upload; if($ec_ids == $owner_ec) { $owner_ec_doc = $uploads; array_push($ec_array,$owner_ec_doc); } } } $ec_docs = json_encode($ec_array); $table = 'gss_client_tax_docs'; $where = array('client_doc_id'=>$id); $check_row = $this->gss_model->get_where_row($table,$where); if(empty($check_row)) { $data = array('client_doc_id'=>$id,'document'=>$ec_docs); $result = $this->db->insert($table,$data); if($result) { echo json_encode(array('result'=>1)); } else { echo json_encode(array('result'=>0)); } } else { $where = array('client_doc_id'=>$id); $this->gss_model->delete($table,$where); $data = array('client_doc_id'=>$id,'document'=>$ec_docs); $result = $this->db->insert($table,$data); if($result) { echo json_encode(array('result'=>1)); } else { echo json_encode(array('result'=>0)); } } } public function get_client_doc_selected() { $id = $this->input->post('id'); $where = array('id'=>$id); $table = 'gss_doc_client_documents'; $check = $this->gss_model->get_where_row($table,$where); $get_ec = $check->upload_doc; $client_doc = json_decode($get_ec); $ec_id = $this->input->post('ec_id'); $ec_array = array(); foreach ($ec_id as $ot) { $owner_ec = $ot; $array = array(); foreach($client_doc as $key=>$get_ec_id) { $ec_ids = $get_ec_id->id; $uploads = $get_ec_id->upload_doc; if($ec_ids == $owner_ec) { $owner_ec_doc = $uploads; array_push($ec_array,$owner_ec_doc); } } } $ec_docs = json_encode($ec_array); $table = 'gss_client_tax_docs'; $where = array('client_doc_id'=>$id); $check_row = $this->gss_model->get_where_row($table,$where); if(empty($check_row)) { $data = array('client_doc_id'=>$id,'document'=>$ec_docs); $result = $this->db->insert($table,$data); if($result) { echo json_encode(array('result'=>1)); } else { echo json_encode(array('result'=>0)); } } else { $where = array('client_doc_id'=>$id); $this->gss_model->delete($table,$where); $data = array('client_doc_id'=>$id,'document'=>$ec_docs); $result = $this->db->insert($table,$data); if($result) { echo json_encode(array('result'=>1)); } else { echo json_encode(array('result'=>0)); } } } //---------------------------------------------------------------------- new access controls -------------------------------------------------------------------// public function get_assigned_accessed_rigts() { $table = 'gss_access_controls'; $department_id = $this->input->post('department_id'); $menu_id = $this->input->post('menu_id'); $where = array('delete_status' =>'ACTIVE','department_id' =>$department_id); $result = $this->gss_model->get_where_row($table,$where); if($result) { $access_menu_ids = unserialize($result->menu_id); //$insert_id = unserialize($result->insert_id); $delete_id = unserialize($result->delete_id); $preview_id = unserialize($result->preview_id); $edit_id = unserialize($result->edit_id); if($access_menu_ids) { echo json_encode(array('access_result'=>1,'menu_id'=>$menu_id,'menu_ids'=>$access_menu_ids,'delete_id'=>$delete_id,'preview_id'=>$preview_id,'edit_id'=>$edit_id,'result'=>1)); } else { echo json_encode(array('result'=>0)); } } else { echo json_encode(array('result'=>0)); } } public function add_access_rights() { $department_id = $this->input->post('department_id'); $menu_id = $this->input->post('menu_ids'); //role_id is user_id from gss_login table $role_id = $this->input->post('role_id'); $table = 'gss_access_controls'; foreach($menu_id as $key=>$value) { $count_id = $this->input->post('count_id_'.$value); //$insert_id = $this->input->post('insert_id_'.$value); $edit_id = $this->input->post('edit_id_'.$value); $delete_id = $this->input->post('delete_id_'.$value); $preview_id = $this->input->post('preview_id_'.$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]; } if($preview_id[$key] == '') { $data['preview_id'] = 0; } else { $data['preview_id'] = $preview_id[$key]; } $data['department_id'] = $department_id; $data['menu_id'] = $value; $data['role_id'] = $role_id; $where = array('department_id'=>$department_id,'menu_id'=>$value); $check_exists = $this->gss_model->get_where_result($table,$where); if($check_exists) { $update_access = $this->gss_model->update($where,$table,$data); } else { $insert_access = $this->gss_model->insert($table,$data); } } } echo json_encode(array('result'=>1,'message'=>"Access controls added successfully")); } //Single department access public function single_department_access() { $table = 'gss_access_controls'; $department_id = $this->input->post('department_id'); $role_id = $this->input->post('role_id'); $where = array('delete_status' =>'ACTIVE','department_id' =>$department_id); $result = $this->gss_model->get_where_row($table,$where); if($result) { $access = unserialize($result->menu_id); $insert_id = unserialize($result->insert_id); $edit_id = unserialize($result->edit_id); $preview_id = unserialize($result->preview_id); $delete_id = unserialize($result->delete_id); if($access) { echo json_encode(array('access'=>$access,'insert_id'=>$insert_id,'edit_id'=>$edit_id,'preview_id'=>$preview_id,'delete_id'=>$delete_id,'result'=>1)); } } else { echo json_encode(array('result'=>0)); } } public function add_menu_access() { $department_id = $this->input->post('department_id'); $array = array(); $table = 'gss_access_controls'; $menu_id = $this->input->post('menu_id'); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $created_at = $date->format('Y-m-d H:i:s'); $menu_array = array(); $insert_array = array(); $edit_array = array(); $preview_array = array(); $delete_array = array(); foreach($menu_id as $key=>$val) { //$array[] = $val; $menu_id = array_push($menu_array, $val); $role_id = $this->input->post('role'); //$insert_id = $this->input->post('insert_id_'.$val); $edit_id = $this->input->post('edit_id_'.$val); $preview_id = $this->input->post('preview_id_'.$val); $delete_id = $this->input->post('delete_id_'.$val); /*if($insert_id) { $insert_id = 1; } else { $insert_id = 0; } $insert_ids = array_push($insert_array, $insert_id);*/ if($edit_id) { $edit_id = 1; } else { $edit_id = 0; } $edit_id_ids = array_push($edit_array, $edit_id); if($preview_id) { $preview_id = 1; } else { $preview_id = 0; } $preview_ids = array_push($preview_array, $preview_id); if($delete_id) { $delete_id = 1; } else { $delete_id = 0; } $delete_ids = array_push($delete_array, $delete_id); } $data = array( 'menu_id' => serialize($menu_array), 'role_id' => $role_id, //'insert_id' => serialize($insert_array), 'edit_id' => serialize($edit_array), 'preview_id' => serialize($preview_array), 'delete_id' => serialize($delete_array), 'department_id' => $department_id, 'delete_status' => 'ACTIVE', 'created_at' => $created_at ); $where = array('department_id' => $department_id,'delete_status' => 'ACTIVE'); $depts = $this->gss_model->get_where_row($table,$where); if($depts) { $where = array('access_id' => $depts->access_id); $result = $this->gss_model->update($where,$table,$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->gss_model->insert($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 delete_owner_khata() { $id = $this->input->post('id'); $table = "gss_doc_owner_documents"; $where = array('id'=>$id); $data = array('owner_khata'=>''); $result = $this->gss_model->update($where,$table,$data); if($this->db->affected_rows() > 0) { echo json_encode(array('result'=>1,'message'=>'Deleted!')); } else { echo json_encode(array('result'=>0)); } } public function delete_owner_sales_deed() { $id = $this->input->post('id'); $table = "gss_doc_owner_documents"; $where = array('id'=>$id); $data = array('sales_deed'=>''); $result = $this->gss_model->update($where,$table,$data); if($this->db->affected_rows() > 0) { echo json_encode(array('result'=>1,'message'=>'Deleted!')); } else { echo json_encode(array('result'=>0)); } } public function delete_owner_sales_agreement() { $id = $this->input->post('id'); $table = "gss_doc_owner_documents"; $where = array('id'=>$id); $data = array('sales_agreement_files'=>''); $result = $this->gss_model->update($where,$table,$data); if($this->db->affected_rows() > 0) { echo json_encode(array('result'=>1,'message'=>'Deleted!')); } else { echo json_encode(array('result'=>0)); } } /*public function delete_owner_ec() { $id = $this->input->post('id'); $ec_id = $this->input->post('ec_id'); $table = "gss_doc_owner_documents"; $where = array('id'=>$id); $get_ec = $this->gss_model->get_where_row($table,$where); $ec = json_decode($get_ec->ec); $array = array(); foreach($ec as $key=>$ec_det) { if($ec_det->id==$ec_id){ unset($ec[$key]); } else { array_push($array, $ec_det); } } $encoded = json_encode($array); $data = array('ec'=>$encoded); $result = $this->gss_model->update($where,$table,$data); if($this->db->affected_rows() > 0) { echo json_encode(array('result'=>1,'message'=>'Deleted!')); } else { echo json_encode(array('result'=>0)); } }*/ public function delete_owner_ec() { $id = $this->input->post('id'); $ec_id = $this->input->post('ec_id'); $table = "gss_doc_owner_documents"; $where = array('id'=>$id); $get_ec = $this->gss_model->get_where_row($table,$where); $ec = json_decode($get_ec->ec); $array = array(); foreach($ec as $key=>$ec_det) { if($ec_det->id==$ec_id) { if(count($key) == 1) { $array = ''; } else { unset($ec[$key]); } } else { $ec_det = $ec_det; array_push($array, $ec_det); } } if(!empty($array)) { $encoded = json_encode($array); } else { $encoded = ''; } $data = array('ec'=>$encoded); $result = $this->gss_model->update($where,$table,$data); if($this->db->affected_rows() > 0) { echo json_encode(array('result'=>1,'message'=>'Deleted!')); } else { echo json_encode(array('result'=>0)); } } public function delete_owner_tax() { $id = $this->input->post('id'); $tax_id = $this->input->post('tax_id'); $table = "gss_doc_owner_documents"; $where = array('id'=>$id); $get_owner = $this->gss_model->get_where_row($table,$where); $owner = json_decode($get_owner->owner); $array = array(); foreach($owner as $key=>$owner_det) { if($owner_det->id==$tax_id) { if(count($key) == 1) { $array = ''; } else { unset($owner[$key]); } } else { $owner_det = $owner_det; array_push($array, $owner_det); } } if(!empty($array)) { $encoded = json_encode($array); } else { $encoded = ''; } $data = array('owner'=>$encoded); $result = $this->gss_model->update($where,$table,$data); if($this->db->affected_rows() > 0) { echo json_encode(array('result'=>1,'message'=>'Deleted!')); } else { echo json_encode(array('result'=>0)); } } public function delete_owner_doc() { $id = $this->input->post('id'); $doc_id = $this->input->post('doc_id'); $table = "gss_doc_owner_documents"; $where = array('id'=>$id); $get_doc = $this->gss_model->get_where_row($table,$where); $doc = json_decode($get_doc->upload_doc); $array = array(); foreach($doc as $key=>$doc_det) { if($doc_det->id==$doc_id) { if(count($key) == 1) { $array = ''; } else { unset($doc[$key]); } } else { $doc_det = $doc_det; array_push($array, $doc_det); } } //$encoded = json_encode($array); if(!empty($array)) { $encoded = json_encode($array); } else { $encoded = ''; } $data = array('upload_doc'=>$encoded); $result = $this->gss_model->update($where,$table,$data); if($this->db->affected_rows() > 0) { echo json_encode(array('result'=>1,'message'=>'Deleted!')); } else { echo json_encode(array('result'=>0)); } } public function delete_client_booking() { $id = $this->input->post('id'); $table = "gss_doc_client_documents"; $where = array('id'=>$id); $data = array('booking_application'=>''); $result = $this->gss_model->update($where,$table,$data); if($this->db->affected_rows() > 0) { echo json_encode(array('result'=>1,'message'=>'Deleted!')); } else { echo json_encode(array('result'=>0)); } } public function delete_client_khata() { $id = $this->input->post('id'); $table = "gss_doc_client_documents"; $where = array('id'=>$id); $data = array('client_khata'=>''); $result = $this->gss_model->update($where,$table,$data); if($this->db->affected_rows() > 0) { echo json_encode(array('result'=>1,'message'=>'Deleted!')); } else { echo json_encode(array('result'=>0)); } } public function delete_client_sales_deed() { $id = $this->input->post('id'); $table = "gss_doc_client_documents"; $where = array('id'=>$id); $data = array('sales_deed'=>''); $result = $this->gss_model->update($where,$table,$data); if($this->db->affected_rows() > 0) { echo json_encode(array('result'=>1,'message'=>'Deleted!')); } else { echo json_encode(array('result'=>0)); } } public function delete_client_sales_agreement() { $id = $this->input->post('id'); $table = "gss_doc_client_documents"; $where = array('id'=>$id); $data = array('sales_agreement_files'=>''); $result = $this->gss_model->update($where,$table,$data); if($this->db->affected_rows() > 0) { echo json_encode(array('result'=>1,'message'=>'Deleted!')); } else { echo json_encode(array('result'=>0)); } } public function delete_client_ec() { $id = $this->input->post('id'); $ec_id = $this->input->post('ec_id'); $table = "gss_doc_client_documents"; $where = array('id'=>$id); $get_ec = $this->gss_model->get_where_row($table,$where); $ec = json_decode($get_ec->ec); $array = array(); foreach($ec as $key=>$ec_det) { if($ec_det->id==$ec_id) { if(count($key) == 1) { $array = ''; } else { unset($ec[$key]); } } else { $ec_det = $ec_det; array_push($array, $ec_det); } } if(!empty($array)) { $encoded = json_encode($array); } else { $encoded = ''; } $data = array('ec'=>$encoded); $result = $this->gss_model->update($where,$table,$data); if($this->db->affected_rows() > 0) { echo json_encode(array('result'=>1,'message'=>'Deleted!')); } else { echo json_encode(array('result'=>0)); } } public function delete_client_tax() { $id = $this->input->post('id'); $tax_id = $this->input->post('tax_id'); $table = "gss_doc_client_documents"; $where = array('id'=>$id); $get_owner = $this->gss_model->get_where_row($table,$where); $owner = json_decode($get_owner->client); $array = array(); foreach($owner as $key=>$owner_det) { if($owner_det->id==$tax_id) { if(count($key) == 1) { $array = ''; } else { unset($owner[$key]); } } else { $owner_det = $owner_det; array_push($array, $owner_det); } } if(!empty($array)) { $encoded = json_encode($array); } else { $encoded = ''; } $data = array('client'=>$encoded); $result = $this->gss_model->update($where,$table,$data); if($this->db->affected_rows() > 0) { echo json_encode(array('result'=>1,'message'=>'Deleted!')); } else { echo json_encode(array('result'=>0)); } } public function delete_client_doc() { $id = $this->input->post('id'); $doc_id = $this->input->post('doc_id'); $table = "gss_doc_client_documents"; $where = array('id'=>$id); $get_doc = $this->gss_model->get_where_row($table,$where); $doc = json_decode($get_doc->upload_doc); $array = array(); foreach($doc as $key=>$doc_det) { if($doc_det->id==$doc_id) { if(count($key) == 1) { $array = ''; } else { unset($doc[$key]); } } else { $doc_det = $doc_det; array_push($array, $doc_det); } } //$encoded = json_encode($array); if(!empty($array)) { $encoded = json_encode($array); } else { $encoded = ''; } $data = array('upload_doc'=>$encoded); $result = $this->gss_model->update($where,$table,$data); if($this->db->affected_rows() > 0) { echo json_encode(array('result'=>1,'message'=>'Deleted!')); } else { echo json_encode(array('result'=>0)); } } //Payments list public function dues_list() { $admin_id = session()->get('admin_id'); if($admin_id) { $project_table = 'gss_new_projects'; $where_project = array('delete_status'=>'ACTIVE','project_status'=>'ONGOING'); $order_by = 'project_name'; $data['projects'] = $this->gss_model->get_where_result_alphabetical($project_table,$where_project,$order_by); $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $this->load->view('admin/dues_list',$data); } else { redirect('/'); } } //Dues list public function get_dues_list() { $project = $_GET['project']; $result = $this->gss_model->dues_list($project); if($result) { echo json_encode($result); } else { echo json_encode(array('result'=>0)); } } //Dues list public function get_dues_all_list() { $result = $this->gss_model->all_dues_list(); if($result) { echo json_encode($result); } else { echo json_encode(array('result'=>0)); } } public function get_doc_owner_documents_list_project_wise() { $project = $_GET['project']; $result = $this->gss_model->get_doc_owner_document_details_project_wise($project); if($result) { echo json_encode($result); } else { echo json_encode(array('result'=>0)); } } public function get_doc_client_documents_list_project_wise() { $project = $_GET['project']; $result = $this->gss_model->get_doc_client_document_details_project_wise($project); if($result) { echo json_encode($result); } else { echo json_encode(array('result'=>0)); } } public function get_status_reports_datewise_agree_done() { $result = $this->gss_model->get_status_reports_datewise_agree_done(); //print_r($result);die(); $site_number = array_column($result, 'site_number'); array_multisort($site_number, SORT_ASC, $result); if($result) { echo json_encode($result); } else { echo json_encode(array('result'=>0)); } } public function get_status_report_total_balance() { $result = $this->gss_model->get_status_report_total_balance(); if($result) { echo json_encode($result); } else { echo json_encode(array('result'=>0)); } } /*public function get_convo_reminder_list() { $admin_id = session()->get('admin_id'); $table = "gss_status_conversation"; $result = $this->gss_model->get_conversation_reminder_details($admin_id); if($result) { echo json_encode(array('result'=>1,'convo_details'=>$result)); } else { echo json_encode(array('result'=>0)); } }*/ public function get_follow_ups_reports() { $project = $_GET['project']; $reminder_date = $_GET['reminder_date']; if($reminder_date != "") { $date = new DateTime($reminder_date); $reminder_date = $date->format('d-m-Y'); } $result = $this->gss_model->get_follow_ups_reports($project,$reminder_date); if($result) { echo json_encode($result); } else { echo json_encode(array('result'=>0)); } } public function follow_up_status_conversation() { $user_type_id = session()->get('user_type_id'); if($user_type_id) { $booking_id = $this->uri->segment(2); $table = 'gss_status_conversation'; $where = array('booking_id'=>$booking_id); $data['detail'] = $this->gss_model->get_conversation_replies($booking_id); $data['due_type_detail'] = ""; $data['project_details'] = $this->gss_model->conversation_booking_details($booking_id); $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $this->load->view('admin/conversation',$data); } else { redirect('/'); } } //-------------------------------------------------------------------------------- Incentive ---------------------------------------------------------// public function incentive_form() { $admin_id = session()->get('admin_id'); if($admin_id) { $broker_table = 'gss_brokers'; $where_reference = array('delete_status'=>'ACTIVE','type'=>'Executives'); $where_logistics = array('delete_status'=>'ACTIVE','type'=>'Logistic'); $associate_order_by = 'associate_name'; $data['logistics'] = $this->gss_model->get_where_result_orderby_asc($broker_table,$where_logistics,$associate_order_by); $data['reference'] = $this->gss_model->get_where_result_orderby_asc($broker_table,$where_reference,$associate_order_by); //$data['invoice'] = $this->gss_model->get_invoice_id(); $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $this->load->view('admin/incentive',$data); } else { redirect('/'); } } public function executive_incentive() { $from_date = $_GET['from_date']; if($from_date != "") { $date = new DateTime($from_date); $from_date = $date->format('Y-m-d'); } $to_date = $_GET['to_date']; if($to_date != "") { $date = new DateTime($to_date); $to_date = $date->format('Y-m-d'); } $executive = $_GET['reference']; $result = $this->gss_model->get_executive_incentives($from_date,$to_date,$executive); if($result) { echo json_encode($result); } else { echo json_encode(array('result'=>0)); } } public function pending_executive_incentive() { $from_date = $_GET['from_date']; if($from_date != "") { $date = new DateTime($from_date); $from_date = $date->format('Y-m-d'); } $to_date = $_GET['to_date']; if($to_date != "") { $date = new DateTime($to_date); $to_date = $date->format('Y-m-d'); } $executive = $_GET['reference']; $result = $this->gss_model->get_pending_executive_incentives($from_date,$to_date,$executive); if($result) { echo json_encode($result); } else { echo json_encode(array('result'=>0)); } } public function get_brokers_total_sites_sqft() { $project_id=$this->input->post('project_id'); $site_id=$this->input->post('site_id'); $booking_id=$this->input->post('booking_id'); $broker_id = $this->input->post('broker_id'); $total_sqft=0; $site_numbers=array(); $project_ids=array(); $executive_ids=array(); foreach($booking_id as $key=>$booking_ids) { $details=$this->gss_model->get_total_sites_sqft_booked($booking_ids); //$exe_details=$this->gss_model->get_total_sites_sqft_booked_executive_id($booking_ids); if($details) { $total_sqft+=$details->dimension; array_push($project_ids,$details->project_id); array_push($site_numbers,$details->site_number); array_push($executive_ids,$details->reference); } } if($total_sqft) { echo json_encode(array('result'=>1,'message'=>$total_sqft,'project_id'=>$project_ids,'site_number'=>$site_numbers,'executive_id'=>$executive_ids)); } else { echo json_encode(array('result'=>0,'message'=>'Not found')); } } public function get_broker_targets() { $reference = $this->input->post('reference'); $where = array('broker_id'=>$reference,'delete_status'=>'ACTIVE'); $table = "gss_brokers"; $result = $this->gss_model->get_where_row($table,$where); if($result) { echo json_encode(array('result'=>'1','details'=>$result)); } else { echo json_encode(array('result'=>'0','details'=>'No data found!')); } } public function add_executive_incentive() { $table = 'gss_executive_incentives_reports'; $array1 = array(); $broker_id = $this->input->post('broker_id'); $fourty_broker_id = $this->input->post('fourty_broker_id'); $sixty_project_id = explode(",",$this->input->post('sixty_project_id')); $fourty_project_id = explode(",",$this->input->post('fourty_project_id')); $both_project = explode(",",$this->input->post('both_project_id')); $total_project_id = array_merge($fourty_project_id,$sixty_project_id,$both_project); $fourty_site_number = explode(",",$this->input->post('fourty_site_number')); $sixty_site_number = explode(",",$this->input->post('sixty_site_number')); $both_site_number = explode(",",$this->input->post('both_site_number')); $total_site_num = array_merge($fourty_site_number,$sixty_site_number,$both_site_number); foreach ($total_project_id as $keys => $values) { $project_ids = $values; if(!empty($project_ids)) { $res['project_id']=$total_project_id[$keys]; $res['site_number']=$total_site_num[$keys]; $res['executive']=$fourty_broker_id; array_push($array1,$res); } else { $projects_sites_ids= ""; } } $projects_sites_ids= json_encode($array1); $total_sqft = $this->input->post('total_sqft'); $basic_target = $this->input->post('basic_target'); $duration = $this->input->post('duration'); $total_target = $this->input->post('total_target'); $achieved = $this->input->post('achieved'); $cancelled = $this->input->post('cancelled'); $excess = $this->input->post('excess'); $shortage = $this->input->post('shortage'); $net_achieved = $this->input->post('net_achieved'); $net_amt = $this->input->post('net_amt'); $amount = $this->input->post('amount'); $payment_type1 = $this->input->post('payment_type1'); if($payment_type1 == "Cheque") { $cheque_number = $this->input->post('check_no1'); $cheque_date = $this->input->post('check_date1'); $cheque_amount = $this->input->post('cheque_amount'); $bank_name = $this->input->post('bank_name1'); $utr_number = ""; $online_date = "00-00-0000"; $cash_amount = ""; $cash_date = "00-00-0000"; $neft_cheque = ""; $neft_cheque_amt = ""; } else if($payment_type1 == "Cash") { $cash_amount = $this->input->post('cash_amount'); $cash_date = $this->input->post('cash_date'); $cheque_date = "00-00-0000"; $bank_name = ""; $cheque_number = ""; $utr_number = ""; $neft_cheque = ""; $neft_cheque_amt = ""; $online_date = "00-00-0000"; $cheque_amount = ""; } else if($payment_type1 == "Online Payment") { $utr_number = $this->input->post('vtr_no1'); $online_date = $this->input->post('online_date1'); $neft_cheque = $this->input->post('neft_cheque'); $neft_cheque_amt = $this->input->post('neft_cheque_amt'); $cheque_date = "00-00-0000"; $bank_name = ""; $cheque_number = ""; $cash_amount = ""; $cash_date = "00-00-0000"; $cheque_amount = ""; } $fourty_booking_id = explode(",",$this->input->post('fourty_booking_id')); $sixty_booking_id = explode(",",$this->input->post('sixty_booking_id')); $both_booking_id = explode(",",$this->input->post('both_booking_id')); $final_booking_ids = array_merge($fourty_booking_id,$sixty_booking_id,$both_booking_id); $booking_ids = array_unique($final_booking_ids); $exe_remark = $this->input->post('exe_remark'); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $created_at = $date->format('Y-m-d H:i:s'); foreach ($total_project_id as $keys => $values) { if(!empty($values)) { $data = array('broker_id'=>$fourty_broker_id, 'projects_sites'=>$projects_sites_ids, 'total_sqft'=>$total_sqft, 'basic_target'=>$basic_target, 'duration' =>$duration, 'total_target' =>$total_target, 'achieved'=>$achieved, 'cancelled'=>$cancelled, 'excess'=>$excess, 'shortage'=>$shortage, 'net_achieved'=>$net_achieved, 'net_amt'=>$net_amt, 'amount'=>$amount, 'payment_type'=>$payment_type1, 'cheque_number'=>$cheque_number, 'cheque_date'=>$cheque_date, 'cheque_amount'=>$cheque_amount, 'bank_name'=>$bank_name, 'cash_amount'=>$cash_amount, 'cash_date'=>$cash_date, 'utr_number'=>$utr_number, 'online_date'=>$online_date, 'neft_cheque'=>$neft_cheque, 'neft_cheque_amt'=>$neft_cheque_amt, 'exe_remark'=>$exe_remark, 'delete_status'=>'ACTIVE', 'created_at'=>$created_at, 'project_id'=>$total_project_id[$keys], 'site_number'=>$total_site_num[$keys], 'executive_id'=>$fourty_broker_id, ); $result = $this->gss_model->insert($table,$data); } } foreach ($final_booking_ids as $key => $value) { $id = json_decode($value); if(!empty($id)) { $table_reference ='gss_booking_details'; $where_reference = array('shared_between_executive'=>$fourty_broker_id,'booking_id'=>$id); $get_reference = $this->gss_model->get_where_row($table_reference,$where_reference); if(empty($get_reference)) { $where = array('booking_id'=>$id,'delete_status'=>'ACTIVE'); $table = "gss_incentive_reports"; $get_row = $this->gss_model->get_where_row($table,$where); if(!empty($get_row)) { if($get_row->balance == "0" || $get_row->balance == "00" || $get_row->balance == "0.0") { $update_booking_datas['selected_incentive_status'] = "YES"; } else { $update_booking_datas['selected_incentive_status'] = ""; } } else { $update_booking_datas['selected_incentive_status'] = ""; } } else { $where = array('booking_id2'=>$id,'delete_status'=>'ACTIVE'); $table = "gss_incentive_reports"; $get_row = $this->gss_model->get_where_row($table,$where); if(!empty($get_row)) { if($get_row->balance == "0" || $get_row->balance == "00" || $get_row->balance == "0.0") { $update_booking_datas['selected_incentive_status2'] = "YES"; } else { $update_booking_datas['selected_incentive_status2'] = ""; } } else { $update_booking_datas['selected_incentive_status2'] = ""; } } $tble_sites='gss_new_sites'; $condition_sites=array('project_id'=>$total_project_id[$key],'site_number'=>$total_site_num[$key]); $update_data=array('incentive_status'=>"YES"); $this->gss_model->update($condition_sites,$tble_sites,$update_data); $tble_bookings_details='gss_booking_details'; $condition_bookings=array('booking_id'=>$id); $this->gss_model->update($condition_bookings,$tble_bookings_details,$update_booking_datas); } } $fourty_status = $this->input->post('fourty_status'); $sixty_status = $this->input->post('sixty_status'); $both_status = $this->input->post('both_status'); if($fourty_status !="") { $update_booking_data=array('fourty_status'=>$fourty_status); $update_booking_data2=array('fourty_status2'=>$fourty_status); $fourty_booking_id = explode(",",$this->input->post('fourty_booking_id')); foreach ($fourty_booking_id as $key => $value) { if(!empty($value)) { $table_reference ='gss_booking_details'; $where_reference = array('shared_between_executive'=>$fourty_broker_id,'booking_id'=>$value); $get_reference = $this->gss_model->get_where_row($table_reference,$where_reference); if(empty($get_reference)) { $table ='gss_incentive_reports'; $where_booking = array('booking_id'=>$value); $get_booking_row = $this->gss_model->get_where_row($table,$where_booking); if($get_booking_row->sixty_status != "") { $update_insentive_data['fourty_status'] = $fourty_status; $this->gss_model->update($where_booking,$table,$update_insentive_data); } $condition_booking=array('booking_id'=>$value); $tble_booking_details='gss_booking_details'; $this->gss_model->update($condition_booking,$tble_booking_details,$update_booking_data); } else { $table ='gss_incentive_reports'; $where_booking = array('booking_id2'=>$value); $get_booking_row = $this->gss_model->get_where_row($table,$where_booking); if($get_booking_row->sixty_status2 != "") { $update_insentive_data['fourty_status2'] = $fourty_status; $this->gss_model->update($where_booking,$table,$update_insentive_data); } $condition_booking=array('booking_id'=>$value); $tble_booking_details='gss_booking_details'; $this->gss_model->update($condition_booking,$tble_booking_details,$update_booking_data2); } } } } if($sixty_status !="") { $update_booking_data=array('sixty_status'=>$sixty_status); $update_booking_data2=array('sixty_status2'=>$sixty_status); $sixty_booking_id = explode(",",$this->input->post('sixty_booking_id')); foreach ($sixty_booking_id as $key => $value) { if(!empty($value)) { $table_reference ='gss_booking_details'; $where_reference = array('shared_between_executive'=>$fourty_broker_id,'booking_id'=>$value); $get_reference = $this->gss_model->get_where_row($table_reference,$where_reference); if(empty($get_reference)) { $table ='gss_incentive_reports'; $where_booking = array('booking_id'=>$value); $get_booking_row = $this->gss_model->get_where_row($table,$where_booking); if($get_booking_row->fourty_status != "") { $update_insentive_data['sixty_status'] = $sixty_status; $this->gss_model->update($where_booking,$table,$update_insentive_data); } $condition_booking=array('booking_id'=>$value); $tble_booking_details='gss_booking_details'; $this->gss_model->update($condition_booking,$tble_booking_details,$update_booking_data); } else { $table ='gss_incentive_reports'; $where_booking = array('booking_id2'=>$value); $get_booking_row = $this->gss_model->get_where_row($table,$where_booking); if($get_booking_row->fourty_status2 != "") { $update_insentive_data['sixty_status2'] = $sixty_status; $this->gss_model->update($where_booking,$table,$update_insentive_data); } $condition_booking=array('booking_id'=>$value); $tble_booking_details='gss_booking_details'; $this->gss_model->update($condition_booking,$tble_booking_details,$update_booking_data2); } } } } if($both_status !="") { $update_booking_data=array('both_status'=>$both_status); $update_booking_data2=array('both_status2'=>$both_status); $both_booking_id = explode(",",$this->input->post('both_booking_id')); foreach ($both_booking_id as $key => $value) { if(!empty($value)) { $table_reference ='gss_booking_details'; $where_reference = array('shared_between_executive'=>$fourty_broker_id,'booking_id'=>$value); $get_reference = $this->gss_model->get_where_row($table_reference,$where_reference); if(empty($get_reference)) { $condition_booking=array('booking_id'=>$value); $tble_booking_details='gss_booking_details'; $this->gss_model->update($condition_booking,$tble_booking_details,$update_booking_data); } else { $condition_booking=array('booking_id'=>$value); $tble_booking_details='gss_booking_details'; $this->gss_model->update($condition_booking,$tble_booking_details,$update_booking_data2); } } } } 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 selected_executive_incentive() { $from_date = $_GET['from_date']; if($from_date != "") { $date = new DateTime($from_date); $from_date = $date->format('Y-m-d'); } $to_date = $_GET['to_date']; if($to_date != "") { $date = new DateTime($to_date); $to_date = $date->format('Y-m-d'); } $executive = $_GET['reference']; $result = $this->gss_model->get_selected_executive_incentives($from_date,$to_date,$executive); if(!empty($result)) { echo json_encode($result); } else { echo json_encode(array('result'=>0)); } } public function logistic_incentive() { $from_date = $_GET['from_date']; if($from_date != "") { $date = new DateTime($from_date); $from_date = $date->format('Y-m-d'); } $to_date = $_GET['to_date']; if($to_date != "") { $date = new DateTime($to_date); $to_date = $date->format('Y-m-d'); } $executive = $_GET['reference']; $result = $this->gss_model->get_logistic_incentives($from_date,$to_date,$executive); if($result) { echo json_encode($result); } else { echo json_encode(array('result'=>0)); } } public function selected_logistic_incentive() { $from_date = $_GET['from_date']; if($from_date != "") { $date = new DateTime($from_date); $from_date = $date->format('Y-m-d'); } $to_date = $_GET['to_date']; if($to_date != "") { $date = new DateTime($to_date); $to_date = $date->format('Y-m-d'); } $executive = $_GET['reference']; $result = $this->gss_model->get_selected_logistic_incentives($from_date,$to_date,$executive); if($result) { echo json_encode($result); } else { echo json_encode(array('result'=>0)); } } public function update_shared_logistic() { $booking_id = $this->input->post('booking_id'); $shared_between_log = $this->input->post('logistics_ids'); $shared_log_amount = $this->input->post('shared_log_amount'); $table = "gss_booking_details"; $where = array('booking_id'=>$booking_id); $data = array('shared_between_logistic'=>$shared_between_log,'shared_logistic_amount'=>$shared_log_amount); $result = $this->gss_model->update($where,$table,$data); if($this->db->affected_rows() > 0) { echo json_encode(array('result'=>1,'message'=>'Added!')); } else { echo json_encode(array('result'=>0)); } } public function get_logistics() { $broker_id = $this->input->post('broker_id'); $broker_table = 'gss_brokers'; $associate_order_by = 'associate_name'; $where_logistics = array('delete_status'=>'ACTIVE','type'=>'Logistic','broker_id !='=>$broker_id); $this->db->select('*'); $this->db->from($broker_table); $this->db->where($where_logistics); $this->db->order_by($associate_order_by,"ASC"); $query=$this->db->get(); $result = $query->result(); if($result) { echo json_encode(array('result'=>1,'logistics'=>$result)); } else { echo json_encode(array('result'=>0)); } } /* public function add_logistic_incentive() { $table = 'gss_logistic_incentives'; $array = array(); $broker_id = $this->input->post('log_broker_id'); $project_id[] = $this->input->post('log_project_id'); $site_number[] = $this->input->post('log_site_number'); foreach ($project_id as $keys => $values) { $project_ids = $values; if(!empty($project_ids)) { $res['project_id']=$values; $res['site_number']=$site_number[$keys]; array_push($array,$res); $projects_sites= json_encode($array); } else { $projects_sites= ""; } } $total_sites = $this->input->post('total_sites'); $amount = $this->input->post('tot_amt'); $log_remark = $this->input->post('log_remark'); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $created_at = $date->format('Y-m-d H:i:s'); $data = array('broker_id'=>$broker_id, 'projects_sites'=>$projects_sites, 'total_sites'=>$total_sites, 'amount'=>$amount, 'log_remark'=>$log_remark, 'delete_status'=>'ACTIVE', 'created_at'=>$created_at ); $result = $this->gss_model->insert($table,$data); $project_id = $this->input->post('log_project_id'); $site_numbers = $this->input->post('log_site_number'); $explode_project_ids= explode(",",$project_id); $explode_site_numbers= explode(",",$site_numbers); foreach($explode_project_ids as $key=>$vals) { $tble_sites='gss_new_sites'; $condition_sites=array('project_id'=>$vals,'site_number'=>$explode_site_numbers[$key]); $update_data=array('log_incentive_status'=>'YES'); $this->gss_model->update($condition_sites,$tble_sites,$update_data); $tble_booking_details='gss_booking_details'; $condition_booking=array('project_id'=>$vals,'site_number'=>$explode_site_numbers[$key]); $update_booking_data=array('selected_incentive_status'=>'YES'); $this->gss_model->update($condition_booking,$tble_booking_details,$update_booking_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_logistic_incentive() { $table = 'gss_logistic_incentives'; $array = array(); $broker_id = $this->input->post('log_broker_id'); $project_id[] = $this->input->post('log_project_id'); $site_number[] = $this->input->post('log_site_number'); foreach ($project_id as $keys => $values) { $project_ids = $values; if(!empty($project_ids)) { $res['project_id']=$values; $res['site_number']=$site_number[$keys]; array_push($array,$res); $projects_sites= json_encode($array); } else { $projects_sites= ""; } } $total_sites = $this->input->post('total_sites'); $amount = $this->input->post('tot_amt'); $log_remark = $this->input->post('log_remark'); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $created_at = $date->format('Y-m-d H:i:s'); $data = array('broker_id'=>$broker_id, 'projects_sites'=>$projects_sites, 'total_sites'=>$total_sites, 'amount'=>$amount, 'log_remark'=>$log_remark, 'delete_status'=>'ACTIVE', 'created_at'=>$created_at ); $result = $this->gss_model->insert($table,$data); $project_id = $this->input->post('log_project_id'); $site_numbers = $this->input->post('log_site_number'); $explode_project_ids= explode(",",$project_id); $explode_site_numbers= explode(",",$site_numbers); foreach($explode_project_ids as $key=>$vals) { $tble_sites='gss_new_sites'; $condition_sites=array('project_id'=>$vals,'site_number'=>$explode_site_numbers[$key]); $update_data=array('log_incentive_status'=>'YES'); $this->gss_model->update($condition_sites,$tble_sites,$update_data); $tble_booking_details='gss_booking_details'; $condition_booking=array('project_id'=>$vals,'site_number'=>$explode_site_numbers[$key]); $update_booking_data=array('selected_incentive_status'=>'YES'); $this->gss_model->update($condition_booking,$tble_booking_details,$update_booking_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_executives() { $broker_id = $this->input->post('broker_id'); $broker_table = 'gss_brokers'; $associate_order_by = 'associate_name'; $where_logistics = array('delete_status'=>'ACTIVE','type'=>'Executives','broker_id !='=>$broker_id); $this->db->select('*'); $this->db->from($broker_table); $this->db->where($where_logistics); $this->db->order_by($associate_order_by,"ASC"); $query=$this->db->get(); $result = $query->result(); if($result) { echo json_encode(array('result'=>1,'executives'=>$result)); } else { echo json_encode(array('result'=>0)); } } public function update_shared_executive() { $booking_id = $this->input->post('exe_booking_id'); $shared_between_exe = $this->input->post('executive_ids'); $shared_to_exe = $this->input->post('shared_exe_to'); $shared_exe_amount = $this->input->post('shared_total_amount'); $shared_amount = $this->input->post('shared_total_amount'); $shared_percentage = $this->input->post('shared_exe_percent'); /* if($shared_exe_amount == 0) { $shared_amount = 0; } else { $shared_percentage = 0; }*/ $table = "gss_booking_details"; $where = array('booking_id'=>$booking_id); $data = array('shared_from_executive'=>$shared_to_exe,'shared_between_executive'=>$shared_between_exe,'shared_executive_amount'=>$shared_amount,'shared_executive_percentage'=>$shared_percentage,'shared_amount'=>$shared_exe_amount); $result = $this->gss_model->update($where,$table,$data); if($this->db->affected_rows() > 0) { echo json_encode(array('result'=>1,'message'=>'Added!')); } else { echo json_encode(array('result'=>0)); } } public function logistic_incentive_reports() { $from_date = $_GET['from_date']; if($from_date != "") { $date = new DateTime($from_date); $from_date = $date->format('Y-m-d'); } $to_date = $_GET['to_date']; if($to_date != "") { $date = new DateTime($to_date); $to_date = $date->format('Y-m-d'); } $executive = $_GET['reference']; $result = $this->gss_model->get_logistic_incentive_reports($from_date,$to_date,$executive); if($result) { echo json_encode($result); } else { echo json_encode(array('result'=>0)); } } public function executive_incentive_reports() { $from_date = $_GET['from_date']; if($from_date != "") { $date = new DateTime($from_date); $from_date = $date->format('Y-m-d'); } $to_date = $_GET['to_date']; if($to_date != "") { $date = new DateTime($to_date); $to_date = $date->format('Y-m-d'); } $executive = $_GET['reference']; $month = $_GET['months']; $year = $_GET['year']; $result = $this->gss_model->get_executive_incentive_reports($from_date,$to_date,$executive,$month,$year); if($result) { echo json_encode($result); } else { echo json_encode(array('result'=>0)); } } public function get_executive_payments() { $id = $_GET['id']; $result = $this->gss_model->executive_payment_reports($id); echo json_encode($result); } public function get_payment_particulars_reports() { $from_date = $_GET['from_date']; if($from_date != "") { $date = new DateTime($from_date); $from_date = $date->format('Y-m-d'); } $to_date = $_GET['to_date']; if($to_date != "") { $date = new DateTime($to_date); $to_date = $date->format('Y-m-d'); } $project = $_GET['p_poject']; $result = $this->gss_model->get_payment_particulars_reports($from_date,$to_date,$project); if(!empty($result)) { echo json_encode(array('result'=>'1','message'=>$result)); } else { echo json_encode(array('result'=>'0','message'=>'No data found!')); } } public function shared_to_executive_incentive() { $from_date = $_GET['from_date']; if($from_date != "") { $date = new DateTime($from_date); $from_date = $date->format('Y-m-d'); } $to_date = $_GET['to_date']; if($to_date != "") { $date = new DateTime($to_date); $to_date = $date->format('Y-m-d'); } $executive = $_GET['reference']; $result = $this->gss_model->get_shared_executive_incentives($from_date,$to_date,$executive); if($result) { echo json_encode($result); } else { echo json_encode(array('result'=>0)); } } public function shared_to_logistic_incentive() { $from_date = $_GET['from_date']; if($from_date != "") { $date = new DateTime($from_date); $from_date = $date->format('Y-m-d'); } $to_date = $_GET['to_date']; if($to_date != "") { $date = new DateTime($to_date); $to_date = $date->format('Y-m-d'); } $logistic = $_GET['reference']; $result = $this->gss_model->get_shared_logistic_incentives($from_date,$to_date,$logistic); if($result) { echo json_encode($result); } else { echo json_encode(array('result'=>0)); } } public function pending_logistic_incentive() { $from_date = $_GET['from_date']; if($from_date != "") { $date = new DateTime($from_date); $from_date = $date->format('Y-m-d'); } $to_date = $_GET['to_date']; if($to_date != "") { $date = new DateTime($to_date); $to_date = $date->format('Y-m-d'); } $executive = $_GET['reference']; $result = $this->gss_model->get_pending_logistic_incentives($from_date,$to_date,$executive); if($result) { echo json_encode($result); } else { echo json_encode(array('result'=>0)); } } public function export_print_executive_incentive_reports() { $from_date = $_GET['from_date']; if($from_date != "") { $date = new DateTime($from_date); $from_date = $date->format('Y-m-d'); } $to_date = $_GET['to_date']; if($to_date != "") { $date = new DateTime($to_date); $to_date = $date->format('Y-m-d'); } $executive = $_GET['reference']; $month = $_GET['months']; $year = $_GET['year']; $result = $this->gss_model->get_export_print_executive_incentive_reports($from_date,$to_date,$executive,$month,$year); if($result) { echo json_encode($result); } else { echo json_encode(array('result'=>0)); } } public function get_payment_particulars_reports_export() { $from_date = $_GET['from_date']; if($from_date != "") { $date = new DateTime($from_date); $from_date = $date->format('Y-m-d'); } $to_date = $_GET['to_date']; if($to_date != "") { $date = new DateTime($to_date); $to_date = $date->format('Y-m-d'); } $project = $_GET['p_poject']; $result = $this->gss_model->get_payment_particulars_reports_export($from_date,$to_date,$project); if(!empty($result)) { echo json_encode(array('result'=>1,'message'=>$result)); } else { echo json_encode(array('result'=>'0','message'=>'No data found!')); } } /*public function delete_executive_incentives() { $id = $this->input->post('id'); $project_id = $this->input->post('project_id'); $booking_id = $this->input->post('booking_id'); $site_number = $this->input->post('site_number'); $table = "gss_executive_incentives"; $where = array('id'=>$id); $get_det = $this->gss_model->get_where_row($table,$where); $projects_sites = json_decode($get_det->projects_sites); $array = array(); foreach($projects_sites as $key=>$ps_det) { $p_project_id=explode(",",$ps_det->project_id); $p_site_number=explode(",",$ps_det->site_number); $p_executive=explode(",",$ps_det->executive); foreach($p_project_id as $keys=>$p_pro_id) { if($project_id == $p_pro_id && $site_number==$p_site_number[$keys]) { unset($p_project_id[$keys]); unset($p_site_number[$keys]); unset($p_executive[$keys]); } } $p_project_ids=implode(",",$p_project_id); $p_site_numbers=implode(",",$p_site_number); $p_executives=implode(",",$p_executive); $res['project_id']=$p_project_ids; $res['site_number']=$p_site_numbers; $res['executive']=$p_executives; array_push($array,$res); } $encoded = json_encode($array); $data = array('projects_sites'=>$encoded); $result = $this->gss_model->update($where,$table,$data); if($this->db->affected_rows() > 0) { $table1 = "gss_booking_details"; $data1 = array('selected_incentive_status'=>''); $where1 = array('booking_id'=>$booking_id); $result = $this->gss_model->update($where1,$table1,$data1); if($this->db->affected_rows() > 0) { echo json_encode(array('result'=>1,'message'=>'Deleted!')); } else { echo json_encode(array('result'=>0)); } } else { echo json_encode(array('result'=>0)); } } */ public function delete_logistic_incentives() { $id = $this->input->post('id'); $project_id = $this->input->post('project_id'); $booking_id = $this->input->post('booking_id'); $site_number = $this->input->post('site_number'); $table = "gss_logistic_incentives"; $where = array('id'=>$id); $get_det = $this->gss_model->get_where_row($table,$where); $projects_sites = json_decode($get_det->projects_sites); $array = array(); foreach($projects_sites as $key=>$ps_det) { $p_project_id=explode(",",$ps_det->project_id); $p_site_number=explode(",",$ps_det->site_number); foreach($p_project_id as $keys=>$p_pro_id) { if($project_id == $p_pro_id && $site_number==$p_site_number[$keys]) { unset($p_project_id[$keys]); unset($p_site_number[$keys]); } } $p_project_ids=implode(",",$p_project_id); $p_site_numbers=implode(",",$p_site_number); $res['project_id']=$p_project_ids; $res['site_number']=$p_site_numbers; array_push($array,$res); } $encoded = json_encode($array); $data = array('projects_sites'=>$encoded); $result = $this->gss_model->update($where,$table,$data); if($this->db->affected_rows() > 0) { $table1 = "gss_booking_details"; $data1 = array('selected_incentive_status'=>''); $where1 = array('booking_id'=>$booking_id); $result = $this->gss_model->update($where1,$table1,$data1); if($this->db->affected_rows() > 0) { echo json_encode(array('result'=>1,'message'=>'Deleted!')); } else { echo json_encode(array('result'=>0)); } } else { echo json_encode(array('result'=>0)); } } public function delete_registration() { $payment_table = 'gss_plot_payments'; $payment_id = $this->input->post('payment_id'); $booking_id = $this->input->post('booking_id'); $where_booking = array('booking_id'=>$booking_id,'registration_delete_status'=>'ACTIVE'); $update_status = array('registration_delete_status'=>'INACTIVE'); $result = $this->gss_model->update($where_booking,$payment_table,$update_status); 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_agreements() { $payment_table = 'gss_plot_payments'; $payment_id = $this->input->post('payment_id'); $booking_id = $this->input->post('booking_id'); $where_booking = array('booking_id'=>$booking_id,'agreement_delete_status'=>'ACTIVE'); $update_status = array('agreement_delete_status'=>'INACTIVE'); $result = $this->gss_model->update($where_booking,$payment_table,$update_status); if($this->db->affected_rows() > 0) { echo json_encode(array('result'=>1,'message'=>'Deleted successfully')); } else { echo json_encode(array('result'=>0)); } } //get total stats public function get_total_stats() { $admin_id = session()->get('admin_id'); if($admin_id) { $land_table = 'gss_land_owners'; $broker_table = 'gss_brokers'; $project_table = 'gss_new_projects'; $enquiry_table = 'gss_enquiries'; $where = array('delete_status'=>'ACTIVE'); $total_owner_result = $this->gss_model->get_where_result($land_table,$where); $total_result_projects = $this->gss_model->get_where_result($project_table,$where); $total_result_brokers = $this->gss_model->get_where_result($broker_table,$where); $total_result_enquiries = $this->gss_model->get_where_result($enquiry_table,$where); $total_result_notification = $this->gss_model->commission_notifications(); $total_result_accounts = $this->gss_model->account_management_list(); $total_result_reception = $this->gss_model->reception_list(); $total_result_loans = $this->gss_model->get_loans_total(); $total_result_dob = $this->gss_model->get_dob_count(); $total_result_doa = $this->gss_model->get_doa_count(); if($total_owner_result) { echo json_encode(array('result'=>1, 'total_owners'=>count($total_owner_result), 'total_projects'=>count($total_result_projects), 'total_brokers'=>count($total_result_brokers), 'total_enquiries'=>count($total_result_enquiries), 'total_notifications'=>count($total_result_notification), 'total_accounts'=>count($total_result_accounts), 'total_reception'=>count($total_result_reception), 'total_loans'=>count($total_result_loans), 'total_dob'=>count($total_result_dob), 'total_doa'=>count($total_result_doa) )); } else { echo json_encode(array('result'=>0,'message'=>'No data Found')); } } else { redirect('/'); } } public function booked_site_payment_details() { $payment_table = 'gss_plot_payments'; $site_number = $this->input->post('site_number'); $project_id = $this->input->post('project_id'); $check_site = $this->gss_model->project_details($site_number,$project_id); if($check_site) { $get_site = $this->gss_model->check_site_payment_details($site_number,$project_id); if($get_site) { if($get_site->booking_status == 'CANCELLED') { echo json_encode(array('result'=>3,'message'=>'Site number '.$site_number.' has been cancelled')); } else { $where_agr_booking = array('booking_id'=>$get_site->booking_id1,'delete_status'=>'ACTIVE','agreement_delete_status'=>'ACTIVE'); $agree_result = $this->gss_model->get_where_row($payment_table,$where_agr_booking); $where_ins_booking = array('booking_id'=>$get_site->booking_id1,'delete_status'=>'ACTIVE','install_delete_status'=>'ACTIVE'); $instal_result = $this->gss_model->get_where_result($payment_table,$where_ins_booking); $tbale='gss_registration_amount_details'; $condition=array('booking_id'=>$get_site->booking_id1,'delete_status'=>'ACTIVE'); $get_reg_amt=$this->gss_model->get_where_result($tbale,$condition); $cancellation_table='gss_cancellations'; $cancellation_con=array('booking_id'=>$get_site->booking_id1,'delete_status'=>'ACTIVE'); $get_due_amount=$this->gss_model->get_where_row($cancellation_table,$cancellation_con); $pay_table = 'gss_plot_payments'; $pay_condition=array('booking_id'=>$get_site->booking_id1,'delete_status'=>'ACTIVE','agreement_delete_status'=>'ACTIVE'); $agr_amount = $this->gss_model->get_where_result($pay_table,$pay_condition); $refund_table = 'gss_cancellation_refunds'; $refund_condition=array('booking_id'=>$get_site->booking_id1,'delete_status'=>'ACTIVE'); $refunds = $this->gss_model->get_where_result($refund_table,$refund_condition); $where = array('booking_id'=>$get_site->booking_id1); $table = 'gss_bookings'; $details = $this->gss_model->get_where_row($table,$where); echo json_encode(array('result'=>1,'details'=>$details,'booking_details'=>$get_site,'installments'=>$instal_result,'agree'=>$agree_result,'reg_amount'=>$get_reg_amt,'due_amount'=>$get_due_amount,'payment_agr_amount'=>$agr_amount,'refunds'=>$refunds)); } } else { echo json_encode(array('result'=>0,'message'=>'Site number '.$site_number.' not booked')); } } else { echo json_encode(array('result'=>2,'message'=>'Site number '.$site_number.' not found')); } } //------------------------------------ownership-------------------------------// public function ownership_master() { $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $this->load->view('admin/add_ownership_master',$data); } public function other_ownership_list() { $table = 'gss_project_ownership'; $where = array('delete_status'=>'ACTIVE'); $order_by='id'; $result = $this->gss_model->get_where_result_orderby($table,$where,$order_by); if($result) { echo json_encode($result); } else { echo json_encode(array('result'=>0)); } } public function get_ownership_details() { $table = 'gss_project_ownership'; $id=$this->input->post('id'); $where = array('id'=>$id); $result = $this->gss_model->get_where_row($table,$where); if($result) { echo json_encode(array('result'=>1,'message'=>$result)); } else { echo json_encode(array('result'=>0,'message'=>'data not found')); } } public function delete_ownership_details() { $table = 'gss_project_ownership'; $id = $this->input->post('id'); $where = array('id'=>$id); $data = array('delete_status'=>'INACTIVE'); $result = $this->gss_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 add_ownership_details() { $table = 'gss_project_ownership'; $ownership_name = $this->input->post('ownership_name'); $data = array('project_ownership'=>$ownership_name,'delete_status'=>'ACTIVE'); $condition=array('project_ownership'=>$ownership_name,'delete_status'=>'ACTIVE'); $get_det=$this->gss_model->get_where_row($table,$condition); if(empty($get_det)){ $result = $this->gss_model->insert($table,$data); echo json_encode(array('result'=>1,'message'=>'Added successfully')); } else { echo json_encode(array('result'=>0,'message'=>'Data Already Exist')); } } public function update_ownership_details() { $table = 'gss_project_ownership'; $id = $this->input->post('edit_id'); $ownership_name = $this->input->post('ownership_name'); $data = array('project_ownership'=>$ownership_name,'delete_status'=>'ACTIVE'); $where=array('id'=>$id); $result = $this->gss_model->update($where,$table,$data); if($this->db->affected_rows() > 0) { echo json_encode(array('result'=>1,'message'=>'Updated successfully')); } else { echo json_encode(array('result'=>0)); } } public function maintenance_form() { $admin_id = session()->get('admin_id'); if($admin_id) { $project_table = 'gss_new_projects'; $where_project = array('delete_status'=>'ACTIVE'); $order_by_project = 'project_name'; $data['projects'] = $this->gss_model->get_where_result_alphabetical($project_table,$where_project,$order_by_project); $booking_table ='gss_booking_details'; $where_booking = array('delete_status'=>'ACTIVE'); $data['bookings'] = $this->gss_model->get_where_result($booking_table,$where_booking); $table ='gss_project_master'; $where = array('delete_status'=>'ACTIVE'); $data['details'] = $this->gss_model->get_where_result($table,$where); $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $this->load->view('admin/maintenance_form',$data); } else { redirect('/'); } } public function add_maintenance_details() { $table = 'gss_maintenance_details'; $project_id = $this->input->post('project_id'); $site_number = $this->input->post('site_number'); $booking_id = $this->input->post('booking_id'); $site_dimension = $this->input->post('site_dimension'); $per_sqft = $this->input->post('per_sqft'); $maintainance_amounts = $this->input->post('maintainance_amount'); $maintainance_amount = str_replace(',', '', $maintainance_amounts); $no_of_years = $this->input->post('no_of_years'); $client_name = $this->input->post('client_name'); $maintenance_payment_type = $this->input->post('maintenance_payment_type'); $note = $this->input->post('note'); $check_no1 = ''; $check_date1 = ''; $bank_name1 = ''; $vtr_no1 = ''; $online_date1 = ''; $dd_no1 = ''; $dd_date1 = ''; $dd_bank1 = ''; $ref_no = ''; $paytm_date = ''; $upi_ref_no = ''; $upi_date = ''; $cash_payment_date = ''; if($maintenance_payment_type == 'Cheque') { $check_no1 = $this->input->post('check_no1'); $check_date1 = $this->input->post('check_date1'); if($check_date1 != "") { $date = new DateTime($check_date1); $check_date1 = $date->format('Y-m-d'); } $bank_name1 = $this->input->post('bank_name1'); } else if($maintenance_payment_type == 'Online Payment') { $vtr_no1 = $this->input->post('vtr_no1'); $online_date1 = $this->input->post('online_date1'); if($online_date1 != "") { $date = new DateTime($online_date1); $online_date1 = $date->format('Y-m-d'); } } else if($maintenance_payment_type == 'DD') { $dd_no1 = $this->input->post('dd_no1'); $dd_date1 = $this->input->post('dd_date1'); if($dd_date1 != "") { $date = new DateTime($dd_date1); $dd_date1 = $date->format('Y-m-d'); } $dd_bank1 = $this->input->post('dd_bank1'); } else if($maintenance_payment_type == 'Paytm Payment') { $ref_no = $this->input->post('ref_no'); $paytm_date = $this->input->post('paytm_date'); if($paytm_date != "") { $date = new DateTime($paytm_date); $paytm_date = $date->format('Y-m-d'); } } else if($maintenance_payment_type == 'UPI Payment') { $upi_ref_no = $this->input->post('upi_ref_no'); $upi_date = $this->input->post('upi_date'); if($upi_date != "") { $date = new DateTime($upi_date); $upi_date = $date->format('Y-m-d'); } } else if($maintenance_payment_type == 'Cash') { $cash_payment_date = $this->input->post('cash_payment_date'); $date = new DateTime($cash_payment_date); $cash_payment_date = $date->format('Y-m-d'); } if($maintenance_payment_type!='') { $payment_status="RECEIVED"; } else { $payment_status="NOT RECEIVED"; } $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $created_at = $date->format('Y-m-d H:i:s'); $data= array('booking_id'=>$booking_id,'project_id'=>$project_id,'site'=>$site_number,'dimension'=>$site_dimension,'per_sq_ft'=>$per_sqft,'main_amount'=>$maintainance_amount,'no_of_yrs'=>$no_of_years,'payment_mode'=> $maintenance_payment_type,'check_no'=> $check_no1,'check_date' => $check_date1,'check_bank' => $bank_name1,'vtr_no' => $vtr_no1,'vtr_date'=> $online_date1,'dd_no' => $dd_no1,'dd_date' => $dd_date1,'dd_bank' => $dd_bank1,'paytm_ref_no'=>$ref_no,'paytm_date'=>$paytm_date,'upi_ref_no'=>$upi_ref_no, 'upi_date'=>$upi_date,'client_name'=>$client_name,'created_at'=>$created_at,'delete_status'=>'ACTIVE','maintenance_status'=>$payment_status,'note'=>$note,'cash_payment_date'=>$cash_payment_date); $maintenance_table = 'gss_maintenance_details'; $where=array('project_id'=>$project_id,'delete_status'=>'ACTIVE'); $check = $this->gss_model->get_where_result($maintenance_table,$where); //print_r($check);die(); $array = array(); foreach($check as $value) { array_push($array,$value->site); } if(in_array($site_number,$array)) { echo json_encode(array('result'=>2,'message'=>'Data Already Exist')); } else { $result = $this->gss_model->insert($table,$data); if($result) { $data=array('maintain_status'=>'RECEIVED'); $maintain_table = 'gss_booking_details'; $where=array('project_id'=>$project_id,'site_number'=>$site_number,'delete_status'=>'ACTIVE'); //print_r($where);die();'booking_id'=>$booking_id, $resulted = $this->gss_model->update($where,$maintain_table,$data); if($resulted > 0) { echo json_encode(array('result'=>1,'message'=>'Added successfully')); } else { echo json_encode(array('result'=>0,'message'=>'Something Went Wrong..')); } } } } public function booked_site_maintenance_details() { $payment_table = 'gss_plot_payments'; $site_number = $this->input->post('site_number'); $project_id = $this->input->post('project_id'); $check_site = $this->gss_model->project_details($site_number,$project_id); if($check_site) { $get_site = $this->gss_model->check_site_maintenance_details($site_number,$project_id); // print_r($get_site);die(); if($get_site) { $where = array('booking_id'=>$get_site->booking_id); $table = 'gss_bookings'; $details = $this->gss_model->get_where_row($table,$where); echo json_encode(array('result'=>1,'details'=>$details,'booking_details'=>$get_site)); } else { echo json_encode(array('result'=>0,'message'=>'Site number '.$site_number.' not booked')); } } else { echo json_encode(array('result'=>2,'message'=>'Site number '.$site_number.' not found')); } } public function maintenance_list() { $admin_id = session()->get('admin_id'); if($admin_id) { $owner_table = 'gss_new_projects'; $where = array('delete_status'=>'ACTIVE'); $data['projects'] = $this->gss_model->get_where_result($owner_table,$where); $booking_table ='gss_booking_details'; $where_booking = array('delete_status'=>'ACTIVE'); $data['bookings'] = $this->gss_model->get_where_result($booking_table,$where_booking); $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $this->load->view('admin/maintenance_list',$data); } else { redirect('/'); } } public function get_maintainance_list() { $result = $this->gss_model->get_all_maintainance(); //print_r($result);die(); if($result) { echo json_encode($result); } else { echo json_encode(array('result'=>0,'message'=>'data not found')); } } public function edit_maintenance() { $table = 'gss_maintenance_details'; $id = $this->input->post('id'); $where = array('id'=>$id,'delete_status'=>'ACTIVE'); $result = $this->gss_model->get_maintainance_individual($id); //print_r($result);die(); if($result) { echo json_encode(array('details'=>$result,'result'=>1)); } else { echo json_encode(array('result'=>0)); } } public function delete_maintenance() { $table = 'gss_maintenance_details'; $id = $this->input->post('id'); $where = array('id'=>$id); $data = array('delete_status'=>'INACTIVE','main_amount'=>''); $result = $this->gss_model->update($where,$table,$data); $result1= $this->gss_model->get_where_row($table,$where); $data=array('maintain_status'=>'NOT RECEIVED'); $maintain_table = 'gss_booking_details'; $where=array('project_id'=>$result1->project_id,'site_number'=>$result1->site,'delete_status'=>'ACTIVE'); $resulted = $this->gss_model->update($where,$maintain_table,$data); if($resulted > 0) { echo json_encode(array('result'=>1,'message'=>'Deleted successfully')); } else { echo json_encode(array('result'=>0)); } } public function update_maintenance() { $table = 'gss_maintenance_details'; $id = $this->input->post('id'); $project_id = $this->input->post('project_id'); $site = $this->input->post('site'); $dimension = $this->input->post('dimension'); $per_sq_ft = $this->input->post('per_sq_ft'); $main_amounts = $this->input->post('main_amount'); $main_amount = str_replace(',', '', $main_amounts); $no_of_yrs = $this->input->post('no_of_yrs'); $maintenance_payment_type = $this->input->post('maintenance_payment_type'); $client_name = $this->input->post('client_name'); $note = $this->input->post('note'); $check_no1 = ''; $check_date1 = ''; $bank_name1 = ''; $vtr_no1 = ''; $online_date1 = ''; $dd_no1 = ''; $dd_date1 = ''; $dd_bank1 = ''; $ref_no = ''; $paytm_date = ''; $upi_ref_no = ''; $upi_date = ''; if($maintenance_payment_type == 'Cheque') { $check_no1 = $this->input->post('check_no1'); $check_date1 = $this->input->post('check_date1'); if($check_date1 != "") { $date = new DateTime($check_date1); $check_date1 = $date->format('Y-m-d'); } $bank_name1 = $this->input->post('bank_name1'); } else if($maintenance_payment_type == 'Online Payment') { $vtr_no1 = $this->input->post('vtr_no1'); $online_date1 = $this->input->post('online_date1'); if($online_date1 != "") { $date = new DateTime($online_date1); $online_date1 = $date->format('Y-m-d'); } } else if($maintenance_payment_type == 'DD') { $dd_no1 = $this->input->post('dd_no1'); $dd_date1 = $this->input->post('dd_date1'); if($dd_date1 != "") { $date = new DateTime($dd_date1); $dd_date1 = $date->format('Y-m-d'); } $dd_bank1 = $this->input->post('dd_bank1'); } else if($maintenance_payment_type == 'Paytm Payment') { $ref_no = $this->input->post('ref_no'); $paytm_date = $this->input->post('paytm_date'); if($paytm_date != "") { $date = new DateTime($paytm_date); $paytm_date = $date->format('Y-m-d'); } } else if($maintenance_payment_type == 'UPI Payment') { $upi_ref_no = $this->input->post('upi_ref_no'); $upi_date = $this->input->post('upi_date'); if($upi_date != "") { $date = new DateTime($upi_date); $upi_date = $date->format('Y-m-d'); } } else if($maintenance_payment_type == 'Cash') { $cash_payment_date = $this->input->post('cash_payment_date'); if($cash_payment_date != "") { $date = new DateTime($cash_payment_date); $cash_payment_date = $date->format('Y-m-d'); } } $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $updated_at = $date->format('Y-m-d H:i:s'); $data = array( 'project_id' => $project_id, 'site' => $site, 'dimension' => $dimension, 'per_sq_ft' => $per_sq_ft, 'main_amount' => $main_amount, 'no_of_yrs' => $no_of_yrs, 'payment_mode'=> $maintenance_payment_type, 'check_no'=> $check_no1, 'check_date' => $check_date1, 'check_bank' => $bank_name1, 'vtr_no' => $vtr_no1, 'vtr_date'=> $online_date1, 'dd_no' => $dd_no1, 'dd_date' => $dd_date1, 'dd_bank' => $dd_bank1, 'paytm_ref_no'=>$ref_no, 'paytm_date'=>$paytm_date, 'upi_ref_no'=>$upi_ref_no, 'upi_date'=>$upi_date, 'client_name' => $client_name, 'note' => $note, 'cash_payment_date' => $cash_payment_date, 'delete_status' => 'ACTIVE', 'updated_at' => $updated_at ); $where = array('id'=>$id); $result = $this->gss_model->update($where,$table,$data); 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")); } } public function get_report_status_details() { $admin_id = session()->get('admin_id'); if($admin_id) { //$project=$this->uri->segement(2); $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $this->load->view('admin/report_status_grid',$data); } else { redirect('/'); } } //add public function add_report_status() { $table = 'gss_report_status'; $this->gss_model->table_truncate($table); $project_id_datewise = $this->input->post('project_id_datewise'); $agr_type = $this->input->post('agr_type'); $from_date_datewise = $this->input->post('from_date_datewise'); $to_date_datewise = $this->input->post('to_date_datewise'); $budget_from_date_datewise = $this->input->post('budget_from_date_datewise'); $budget_to_date_datewise = $this->input->post('budget_to_date_datewise'); $khata_status = $this->input->post('khata_status'); $project_ownership = $this->input->post('project_ownership'); $s1_project_type = $this->input->post('s1_project_type'); $handled_by = $this->input->post('handled_by'); $reference = $this->input->post('reference'); $logistic = $this->input->post('logistic'); $data = array('project_status'=>$s1_project_type,'project'=>$project_id_datewise,'from_date'=>$from_date_datewise,'type'=>$agr_type,'to_date'=>$to_date_datewise,'budget_from'=>$budget_from_date_datewise,'budget_to'=>$budget_to_date_datewise,'project_ownership'=>$project_ownership,'khata_status'=>$khata_status,'handled_by'=>$handled_by,'reference'=>$reference,'logistic'=>$logistic,'delete_status'=>'ACTIVE'); $result = $this->gss_model->insert($table,$data); if($result) { echo json_encode(array('result'=>1,'message'=>$result)); } else { echo json_encode(array('result'=>0,'message'=>'Data Already Exist')); } } //add public function get_report_status() { $id=$this->uri->segment(2); $table="gss_report_status"; $where = array('id'=>$id); $result = $this->gss_model->get_where_row($table,$where); //print_r($result);die(); //$data['details']=$result->message; if($result) { echo json_encode($result); } else { echo json_encode(array('result'=>0,'message'=>'data not found')); } } //add public function client_address_details() { $admin_id = session()->get('admin_id'); if($admin_id) { $project_table = 'gss_new_projects'; $where_project = array('delete_status'=>'ACTIVE','project_status'=>'ONGOING'); $order_by = 'project_name'; $data['projects'] = $this->gss_model->get_where_result_orderby_asc($project_table,$where_project,$order_by); $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $this->load->view('admin/address_list',$data); } else { redirect('/'); } } //add public function get_address_list() { $p_poject = $_GET['p_poject']; $result = $this->gss_model->get_address_list($p_poject); //print_r($result);die(); if($result) { echo json_encode($result); } else { echo json_encode(array('result'=>0,'message'=>'data not found')); } } //add public function print_address_list() { $admin_id = session()->get('admin_id'); if($admin_id) { $booking_id = $this->uri->segment(2); $data['address'] = $this->gss_model->print_address_list($booking_id); $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $this->load->view('admin/print_address_list',$data); } else { redirect('/'); } } //add public function get_maintenance_reports() { $project_id = $_GET['project_id']; $m_project_type = $_GET['m_project_type']; $result = $this->gss_model->get_maintenance_reports($project_id,$m_project_type); if($result) { echo json_encode($result); } else { echo json_encode(array('result'=>0)); } } //add public function get_maintenance_email_reports() { $project_id = $_GET['project_id']; $result = $this->gss_model->get_maintenance_reports($project_id); if($result) { echo json_encode($result); } else { echo json_encode(array('result'=>0)); } } //addd public function get_maintenance_contact_reports() { $project_id = $_GET['project_id']; $result = $this->gss_model->get_maintenance_reports($project_id); //print_r($result);die(); if($result) { echo json_encode($result); } else { echo json_encode(array('result'=>0)); } } //add public function get_maintenance_due_reports() { $project_id = $_GET['project_id']; $m_project_type = strtoupper($_GET['m_project_type']); $result = $this->gss_model->get_maintenance_due_reports($project_id,$m_project_type); //print_r($result);die(); if($result) { echo json_encode($result); } else { echo json_encode(array('result'=>0)); } } public function new_sites() { $table = 'gss_new_sites'; $project_id = $_GET['project_id']; //echo $project_id; /*$order_by = "site_number";*/ $where = array( 'delete_status' => 'ACTIVE', 'project_id' => $project_id ); $result = $this->gss_model->get_new_sites($table,$where); if($result) { $data = array(); foreach($result as $row) { $data[] = $row; } echo json_encode($data); } else { echo json_encode(array('result'=>0)); } } public function address_list_print() { $p_poject =$_GET['p_poject']; $result = $this->gss_model->address_list_print($p_poject); if($result) { echo json_encode($result); } else { echo json_encode(array('result'=>0,'message'=>'No Details found')); } } public function unbooked_site_report_site() { //$p_poject =$_GET['p_poject']; $result = $this->gss_model->unbooked_site_report_site(); if($result) { echo json_encode($result); } else { echo json_encode(array('result'=>0,'message'=>'No Details found')); } } public function get_status_report_type() { //$id = $_GET['id']; $table= 'gss_report_status'; $id = $this->input->post('id'); $where = array('id'=>$id,'delete_status'=>'ACTIVE'); $result = $this->gss_model->get_where_row($table,$where); //print_r($result);die(); if($result) { echo json_encode(array('details'=>$result,'result'=>1)); } else { echo json_encode(array('result'=>0)); } } public function get_report_status_unbooked_details() { $admin_id = session()->get('admin_id'); if($admin_id) { //$project=$this->uri->segement(2); $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $this->load->view('admin/report_status_unbooked_grid',$data); } else { redirect('/'); } } public function view_cancelation_details() { $admin_id = session()->get('admin_id'); if($admin_id) { $project=$this->uri->segment(2); $site_number =$this->uri->segment(3); //print_r($site_number);die(); $broker_table = 'gss_brokers'; $project_table = 'gss_new_projects'; $where_project = array('delete_status'=>'ACTIVE','project_status'=>'ONGOING','project_id'=>$project); $where_reference = array('delete_status'=>'ACTIVE','type'=>'Executives'); $where_associate = array('delete_status'=>'ACTIVE','type'=>'Associate'); $data['associates'] = $this->gss_model->get_where_result($broker_table,$where_associate); $data['projects'] = $this->gss_model->get_where_result($project_table,$where_project); $data['reference'] = $this->gss_model->get_where_result($broker_table,$where_reference); $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $this->load->view('admin/view_cancelation_details',$data); } else { redirect('/'); } } public function site_cancellation_list() { $project_id = $_GET['project_id']; $site_number=$_GET['site_number']; //print_r($site_number); $result = $this->gss_model->site_cancellation_list($project_id,$site_number); //print_r($result);die(); if($result) { echo json_encode($result); } else { echo json_encode(array('result'=>0)); } } public function site_cancellation_details() { $admin_id = session()->get('admin_id'); if($admin_id) { $broker_table = 'gss_brokers'; $cancellation_id = $this->uri->segment(2); $cancel_result = $this->gss_model->cancellation_details2($cancellation_id); $data['payment'] = $this->gss_model->cancellation_payment_details($cancellation_id); $data['agreement'] = $this->gss_model->cancellation_agreement_details($cancellation_id); $data['total_amount'] = $this->gss_model->cancellation_total_amount($cancellation_id); if($cancel_result->refunded == 'No') { $data['details'] = $this->gss_model->cancellation_details_no_refunds($cancellation_id); } else { $data['detailss'] = $this->gss_model->cancellation_details1($cancellation_id); } $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $this->load->view('admin/site_cancellation_details',$data); } else { redirect('/'); } } public function remove_payment_details() { $admin_id = session()->get('admin_id'); if($admin_id) { $booking_id = $this->uri->segment(2); $project_table = 'gss_new_projects'; $where_project = array('delete_status'=>'ACTIVE','project_status'=>'ONGOING'); $data['booking_id'] = $booking_id; $data['projects'] = $this->gss_model->get_where_result($project_table,$where_project); $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $this->load->view('admin/remove_individual_payments',$data); } else { redirect('/'); } } public function preview_maintenance_details() { $admin_id = session()->get('admin_id'); if($admin_id) { $table = 'gss_bookings'; $broker_table = 'gss_brokers'; $maintainance_table = 'gss_maintenance_details'; $maintain_id = $this->uri->segment(2); $maintainance_data = $this->gss_model->get_maintenance_details($maintain_id); $data['maintain_data'] =$maintainance_data; //print_r($data['maintain_data']);die(); $where = array('id'=>$maintain_id); $get_project = $this->gss_model->get_where_row($maintainance_table,$where); $project_id = $get_project->project_id; $where_project = array('project_id'=>$project_id); $project_table = 'gss_new_projects'; $get_project_details = $this->gss_model->get_where_row($project_table,$where_project); $data['project'] = $get_project_details; $land_owner = $get_project_details->land_owner_id; $land_owner_table = 'gss_land_owners'; $where_land_owner = array('owner_id'=>$land_owner); $get_land_owner = $this->gss_model->get_where_row($land_owner_table,$where_land_owner); $data['land_owner'] = $get_land_owner; $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); if($get_land_owner->name == 'GSS Project Consultants') { $this->load->view('admin/maintainance_receipt',$data); } else { $this->load->view('admin/maintenance_acknowledgement',$data); } //$this->load->view('admin/preview_booking_details',$data); } else { redirect('/'); } } public function send_maintenance_mail_receipt() { $admin_id = session()->get('admin_id'); if($admin_id) { $maintain_id = $this->input->post('maintain_ids'); $receipt_type = $this->input->post('receipt_type'); $ack_no1 = $this->input->post('ack_no1'); $maintain_date1 = $this->input->post('maintain_date1'); $maintenance_amount = $this->input->post('maintenance_amount'); $maintenance_count = $this->input->post('maintenance_count'); $maintenance_payment_particulars1 = $this->input->post('maintenance_payment_particulars1'); $table ='gss_login'; $where = array('user_id'=>$admin_id); $user = $this->gss_model->get_where_row($table,$where); $logged_in_email = $user->email; $client = $this->gss_model->get_maintenance_details($maintain_id); $booking_id = $client->booking_id; $booking_detail_table = 'gss_bookings'; $booking_id_where = array('booking_id'=>$booking_id); $client_site = $this->gss_model->get_where_row($booking_detail_table,$booking_id_where); $client_email = $client_site->email; $project_table = 'gss_new_projects'; $project_id = $client->project_id; $where_project = array('project_id'=>$project_id); $project = $this->gss_model->get_where_row($project_table,$where_project); $address =$project->land_owner_address; $land_owner = $project->land_owner_id; $land_owner_table = 'gss_land_owners'; $where_land_owner = array('owner_id'=>$land_owner); $get_land_owner = $this->gss_model->get_where_row($land_owner_table,$where_land_owner); $land_owner_address = $get_land_owner->address; $client_name = $client->customer_name; $project_name = $project->project_name; $site_number = $client->site; $particulars = $ack_no1.', Payment Type towards '.$maintenance_count; $subject = $project_name.', '.$site_number.' and '.$client_name.' - '.$particulars; $message = 'Dear '.$client_name.', Please find enclosed the Receipt Details of '.$maintenance_count; $table = 'gss_email_details'; $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $created_at = $date->format('Y-m-d H:i:s'); $today = $date->format('d-m-Y'); $data = array('user_email'=>$logged_in_email, 'client_email' => $client_email, 'client_name' => $client_name, 'project_name' => $project_name, 'site_number' => $site_number, 'particulars' => $particulars, 'subject' => $subject, 'created_at' => $created_at, 'message' => $message); $insert_result = $this->gss_model->insert($table,$data); if($insert_result) { // include("assets/mpdf60/mpdf.php"); // $mpdf=new mPDF('A4'); // $mpdf->mirrorMargins = 1; $html = ''; $index = 1; if($receipt_type == 'Maintainance Receipt') { $email_content = ''; $email_content.= '<html>'; $email_content.= '<head>'; $email_content.= '</head>'; $email_content.= '<body style="width:900px;display:block;margin:auto !important; border-left:10px solid #E3000F;padding-left: 100px !important;padding-right: 100px !important;padding-top: 50px !important;padding-bottom: 50px !important;">'; $email_content.= '<div style="padding-bottom:10px;clear:both;">'; $email_content.= '<h2 style="text-align:center;padding-bottom:5px;">Maintainance Receipt</h2>'; $email_content.= '<img src="assets/images/header_line.png" style="display:block;margin:auto;padding-left:45%;padding-left:300px;">'; $email_content.= "<h2 style='font-size: 28px;line-height: 1.3;text-align:center;'>Project Name: $project_name <br>Address:$address"; $email_content.= '</div>'; $email_content.= '<div style="padding-bottom:15px;padding-top:15px;margin-bottom: 5px;position:relative;clear:both;">'; $email_content.= '<img src="assets/images/line.png" style="display:block;margin:auto;width: 100%;">'; $email_content.= '<div style="padding-top:10px;padding-bottom:10px;">'; $email_content.= '<table style="margin-bottom:0px !important;width:100%;">'; $email_content.= '<tr>'; /* $email_content.= "<td><p style='margin:0;font-size:18px;font-weight:bold;padding-top: 3px;'>Date: $today</p></td>";*/ $email_content.= '<td style="text-align:center;"><h3 style="margin-bottom:0px;margin-top:0px;text-align:center;color:#E40025;font-weight:bold;">RECEIPT</h3></td>'; //$email_content.= '<td style="text-align:right;"><p style="margin:0;font-size:18px;font-weight:bold;padding-top: 3px;">Receipt No: 1234</p></td>'; $email_content.= '</tr>'; $email_content.= '</table>'; $email_content.= '</div>'; $email_content.= '<img src="assets/images/line.png" style="display:block;margin:auto;width: 100%;">'; $email_content.= '</div>'; $email_content.= '<div style="padding-bottom:20px;clear:both;">'; $email_content.= '<div>'; $email_content.= '<table style="margin-bottom:0px !important;width:100%;">'; $email_content.= '<tr>'; $email_content.= "<td><p style='padding-left: 50px;margin:0;font-size:18px;font-weight:bold;padding-top: 3px;'>Client Name: $client_name</p></td>"; $email_content.= "<td><p style='padding-right:50px;margin:0;text-align:right;font-size:18px;font-weight:bold;padding-top: 3px;'>Site No: $site_number</p></td>"; $email_content.= '</tr>'; $email_content.= '</table>'; $email_content.= '</div>'; $email_content.= '</div>'; $email_content.= '<div style="clear:both;">'; $email_content.= '<table style="width:100%;border-collapse: collapse;border-color:red;" border="1">'; $email_content.= '<tr>'; $email_content.= '<td style="border: 3px solid #e40025 !important;padding:8px 5px;font-weight:bold;font-size:16px;text-align:center;">Payment Date</td>'; /*$email_content.= '<td style="border: 3px solid #e40025 !important;padding:8px 5px;font-weight:bold;font-size:16px;text-align:center;">Receipt No</td>';*/ $email_content.= '<td style="border: 3px solid #e40025 !important;padding:8px 5px;font-weight:bold;font-size:16px;text-align:center;">Maintenance Amount</td>'; $email_content.= '<td style="border: 3px solid #e40025 !important;padding:8px 5px;font-weight:bold;font-size:16px;text-align:center;">Payment Type</td>'; $email_content.= '<td style="border: 3px solid #e40025 !important;padding:8px 5px;font-weight:bold;font-size:16px;text-align:center;">Particulars</td>'; $email_content.= '</tr>'; $email_content.= '<tr>'; $email_content.= "<td style='border: 3px solid #e40025 !important;padding:8px 5px;font-weight:bold;font-size:16px;text-align:center;'>$maintain_date1</td>"; /*$email_content.= "<td style='border: 3px solid #e40025 !important;padding:8px 5px;font-weight:bold;font-size:16px;text-align:center;width:20%;'>$ack_no1</td>";*/ $email_content.= "<td style='border: 3px solid #e40025 !important;padding:8px 5px;font-weight:bold;font-size:16px;text-align:center;'>$maintenance_amount</td>"; $email_content.= "<td style='border: 3px solid #e40025 !important;padding:8px 5px;font-weight:bold;font-size:16px;text-align:center;'>$maintenance_count</td>"; $email_content.= "<td style='border: 3px solid #e40025 !important;padding:8px 5px;font-weight:bold;font-size:16px;text-align:center;'>$maintenance_payment_particulars1</td>"; $email_content.= '</tr>'; $email_content.= '</table>'; $email_content.= '<p style="text-align:center;font-weight:bold;font-size:18px;line-height:1.8;padding-top:15px;margin-bottom:4px;">(The validity of this receipt is subject to realization of all <br>cheques/demand draft/account transfer)</p>'; $email_content.= '<p style="text-align:center;font-weight:bold;font-size:18px;line-height:1.8;margin-top:4px;">This is a computer generated receipt. Signature is not required.</p>'; $email_content.= '</div>'; $email_content.= '<div class="row row_five" style="clear:both;padding-top:50px;">'; $email_content.= '<p style="margin-bottom:0px;margin-top:0px;font-size:18px;font-weight:bold;padding-top: 3px;">For GSS Project Consultants</p>'; $email_content.= '<p style="padding-left:30px;padding-top:50px;margin-bottom:0px;margin-top:0px;font-size:18px;font-weight:bold;">Authorized Signatory</p>'; $email_content.= '</div>'; $email_content.= '</body>'; $email_content.= '</html>'; } else { $email_content = ''; $email_content.= '<html>'; $email_content.= '<head>'; $email_content.= '</head>'; $email_content.= '<body style="width:900px;display:block;margin:auto !important; border-left:10px solid #E3000F !important;padding-left: 100px !important;padding-right: 100px !important;padding-top: 50px !important;padding-bottom: 50px !important;">'; $email_content.= '<div style="padding-bottom:10px;clear:both;">'; $email_content.= '<h2 style="text-align:center;padding-bottom:5px;">Acknowledgement</h2>'; $email_content.= '<img src="assets/images/header_line.png" style="display:block;margin:auto;padding-left:45%;">'; $email_content.= "<h2 style='font-size: 28px;line-height: 1.3;text-align:center;border-top:10px solid #E3000F !important;'>Project Name: $project_name <br>Address: $land_owner_address"; $email_content.= '</div>'; $email_content.= '<div style="padding-bottom:15px;padding-top:15px;margin-bottom: 5px;position:relative;clear:both;">'; $email_content.= '<img src="assets/images/line.png" style="display:block;margin:auto;width: 100%;">'; $email_content.= '<div style="padding-top:10px;padding-bottom:10px;">'; $email_content.= '<table style="margin-bottom:0px !important;width:100%;">'; $email_content.= '<tr>'; /* $email_content.= "<td><p style='margin:0;font-size:18px;font-weight:bold;padding-top: 3px;'>Date: $today</p></td>";*/ $email_content.= "<td><p style='padding-left: 50px;margin:0;font-size:18px;font-weight:bold;padding-top: 3px;'>Client Name: $client_name</p></td>"; $email_content.= "<td><p style='padding-right:50px;margin:0;text-align:right;font-size:18px;font-weight:bold;padding-top: 3px;'>Site No: $site_number</p></td>"; //$email_content.= '<td style="text-align:right;"><p style="margin:0;font-size:18px;font-weight:bold;padding-top: 3px;">Ack No: 01</p></td>'; $email_content.= '</tr>'; $email_content.= '</table>'; $email_content.= '</div>'; $email_content.= '<img src="assets/images/line.png" style="display:block;margin:auto;width: 100%;">'; $email_content.= '</div>'; /* $email_content.= '<div style="padding-bottom:20px;clear:both;">'; $email_content.= '<div>'; $email_content.= '<table style="margin-bottom:0px !important;width:100%;">'; $email_content.= '<tr>'; $email_content.= "<td><p style='padding-left: 50px;margin:0;font-size:18px;font-weight:bold;padding-top: 3px;'>Client Name: $client_name</p></td>"; $email_content.= "<td><p style='padding-right:50px;margin:0;text-align:right;font-size:18px;font-weight:bold;padding-top: 3px;'>Site No: $site_number</p></td>"; $email_content.= '</tr>'; $email_content.= '</table>'; $email_content.= '</div>'; $email_content.= '</div>';*/ $email_content.= '<div style="clear:both;">'; $email_content.= '<table style="width:100%;border-collapse: collapse;border-color:red;" border="1">'; $email_content.= '<tr>'; $email_content.= '<td style="border-top: 3px solid red !important;padding:8px 5px;font-weight:bold;font-size:16px;text-align:center;">Payment Date</td>'; /*$email_content.= '<td style="border: 3px solid #e40025 !important;padding:8px 5px;font-weight:bold;font-size:16px;text-align:center;">Ack No</td>';*/ $email_content.= '<td style="border: 3px solid #e40025 !important;padding:8px 5px;font-weight:bold;font-size:16px;text-align:center;">Maintenance Amount</td>'; $email_content.= '<td style="border: 3px solid #e40025 !important;padding:8px 5px;font-weight:bold;font-size:16px;text-align:center;">Payment Type</td>'; $email_content.= '<td style="border: 3px solid #e40025 !important;padding:8px 5px;font-weight:bold;font-size:16px;text-align:center;">Particulars</td>'; $email_content.= '</tr>'; $email_content.= '<tr>'; $email_content.= "<td style='border: 3px solid #e40025 !important;padding:8px 5px;font-weight:bold;font-size:16px;text-align:center;'>$maintain_date1</td>"; /*$email_content.= "<td style='border: 3px solid #e40025 !important;padding:8px 5px;font-weight:bold;font-size:16px;text-align:center;width:20%;'>$ack_no1</td>";*/ $email_content.= "<td style='border: 3px solid #e40025 !important;padding:8px 5px;font-weight:bold;font-size:16px;text-align:center;'>$maintenance_amount</td>"; $email_content.= "<td style='border: 3px solid #e40025 !important;padding:8px 5px;font-weight:bold;font-size:16px;text-align:center;'>$maintenance_count</td>"; $email_content.= "<td style='border: 3px solid #e40025 !important;padding:8px 5px;font-weight:bold;font-size:16px;text-align:center;'>$maintenance_payment_particulars1</td>"; $email_content.= '</tr>'; $email_content.= '</table>'; $email_content.= '<p style="text-align:center;font-weight:bold;font-size:18px;line-height:1.8;padding-top:15px;margin-bottom:4px;">(The validity of this receipt is subject to realization of all <br>cheques/demand draft/account transfer)</p>'; $email_content.= '<p style="text-align:center;font-weight:bold;font-size:18px;line-height:1.8;margin-top:4px;">This is a computer generated receipt. Signature is not required.</p>'; $email_content.= '</div>'; $email_content.= '</body>'; $email_content.= '</html>'; } // $mpdf->SetDisplayMode('fullpage'); // $mpdf->watermark_font = 'DejaVuSansCondensed'; // $mpdf->showWatermarkText = true; // $mpdf->WriteHTML($email_content); require "vendor/autoload.php"; $mpdf = new \Mpdf\Mpdf(); // Write some HTML code: $mpdf->WriteHTML($email_content); $name = 'client_receipt'.$insert_result.'.pdf'; $data = array('email_receipt'=>$name); $where = array('id'=>$insert_result); $result = $this->gss_model->update($where,$table,$data); $pdf = $mpdf->Output("./email_receipts/".$name, 'F'); if($this->db->affected_rows() > 0) { echo json_encode(array('result'=>1 ,'message'=>$insert_result)); } else { echo json_encode(array('result'=>0,'message'=>"Data could not be added")); } } else { echo json_encode(array('result'=>0,'message'=>"Data could not be added")); } //$this->load->view('admin/send_email',$data); } else { redirect('/'); } } public function get_total_dimension_for_unbooked_sites() { $project = $this->input->post('project_id'); $table = 'gss_new_sites'; $tot_project_sqft = $this->gss_model->total_marketing_dimension(); $booked_sqft = $this->gss_model->total_booked_dimension(); //$balance_sqft = $tot_project_sqft - $booked_sqft; if($tot_project_sqft) { echo json_encode(array('result'=>1, 'total_marketing'=>$tot_project_sqft,'booked_sqft'=>$booked_sqft)); } else { echo json_encode(array('result'=>0, 'message'=>'NO data found')); } } public function get_sites_reports_export() { $i = $_GET['id']; $from_date = $_GET['from_date']; if($from_date != "") { $date = new DateTime($from_date); $from_date = $date->format('Y-m-d'); } $to_date = $_GET['to_date']; if($to_date != "") { $date = new DateTime($to_date); $to_date = $date->format('Y-m-d'); } $project_id = $_GET['project_id']; $result1 = $this->gss_model->sites_reports($project_id,$from_date,$to_date); $result2 = $this->gss_model->get_sites_reports_export($i); if($result1) { echo json_encode(array('result'=>1,'message1'=>$result1,'message2'=>$result2)); } else { echo json_encode(array('result'=>0,'message'=>'No Data Found')); } } public function get_executives_list() { $val = $_GET['department']; $val = 'Executives'; $table = 'gss_brokers'; $where = array('type' => $val,'delete_status' =>'ACTIVE'); $result = $this->gss_model->get_where_result($table,$where); if($result) { echo json_encode(array('result'=>1,'data'=>$result)); } else { echo json_encode(array('result'=>0,'message'=>'No Data Found')); } } // public function add_insentive_calculation() // { // $admin_id = session()->get('admin_id'); // $reference = $this->input->post('calc_reference'); // $booking_id = $this->input->post('calc_booking_id'); // $total_sqft = $this->input->post('calc_total_sqft'); // $rate_per_sqft = $this->input->post('calc_rate_per_sqft'); // $total_amount_fixed = $this->input->post('calc_total_amount_fixed'); // $total_amount_fixed = str_replace(',', '', $total_amount_fixed); // $incentive_on_agmnt = $this->input->post('calc_incentive_on_agmnt'); // $incentive_on_agmnt = str_replace(',', '', $incentive_on_agmnt); // $incentive_on_regn = $this->input->post('calc_incentive_on_regn'); // $incentive_on_regn = str_replace(',', '', $incentive_on_regn); // $insentive_perc = $this->input->post('calc_insentive_perc'); // $balance = $this->input->post('calc_balance'); // $balance = str_replace(',', '', $balance); // $source = $this->input->post('calc_source'); // $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); // $created_at = $date->format('Y-m-d H:i:s'); // $calc_table = 'gss_incentive_reports'; // $calc_data = array( // 'reference' => $reference, // 'booking_id' => $booking_id, // 'total_sqft' => $total_sqft, // 'rate_per_sqft' => $rate_per_sqft, // 'total_amount_fixed' => $total_amount_fixed, // 'incentive_on_agmnt' => $incentive_on_agmnt, // 'incentive_on_regn' => $incentive_on_regn, // 'insentive_perc' => $insentive_perc, // 'balance' => $balance, // 'source' => $source, // 'created_by' => $admin_id, // 'delete_status' => 'ACTIVE', // 'created_at' => $created_at // ); // $where_booking = array('booking_id'=>$booking_id); // $inc_data = $this->gss_model->get_where_row($calc_table,$where_booking); // if($inc_data) // { // $update_data = array( // 'total_sqft' => $total_sqft, // 'rate_per_sqft' => $rate_per_sqft, // 'total_amount_fixed' => $total_amount_fixed, // 'incentive_on_agmnt' => $incentive_on_agmnt, // 'incentive_on_regn' => $incentive_on_regn, // 'insentive_perc' => $insentive_perc, // 'balance' => $balance, // 'source' => $source, // 'updated_at' => $created_at // ); // $update_result = $this->gss_model->update($where_booking,$calc_table,$update_data); // if($this->db->affected_rows() > 0) // { // echo json_encode(array('result'=> 1,'message' => "Updated Successfully")); // } // else // { // echo json_encode(array('result'=> 0,'message' => "Something went wrong.. try again")); // } // } // else // { // $result = $this->gss_model->insert($calc_table,$calc_data); // if($result) // { // echo json_encode(array('result'=> 1,'message' => "Inserted Successfully")); // } // else // { // echo json_encode(array('result'=> 0,'message' => "Something went wrong.. try again")); // } // } // } public function add_insentive_calculation() { $admin_id = session()->get('admin_id'); $reference = $this->input->post('calc_reference'); $booking_id = $this->input->post('calc_booking_id'); $table_reference ='gss_booking_details'; $where_reference = array('shared_between_executive'=>$reference,'booking_id'=>$booking_id); $get_reference = $this->gss_model->get_where_row($table_reference,$where_reference); if(empty($get_reference)) { $total_sqft = $this->input->post('calc_total_sqft'); $rate_per_sqft = $this->input->post('calc_rate_per_sqft'); $total_amount_fixed = $this->input->post('calc_total_amount_fixed'); $total_amount_fixed = str_replace(',', '', $total_amount_fixed); $incentive_on_agmnt = $this->input->post('calc_incentive_on_agmnt'); $incentive_on_agmnt = str_replace(',', '', $incentive_on_agmnt); $incentive_on_regn = $this->input->post('calc_incentive_on_regn'); $incentive_on_regn = str_replace(',', '', $incentive_on_regn); $insentive_perc = $this->input->post('calc_insentive_perc'); $balance = $this->input->post('calc_balance'); $balance = str_replace(',', '', $balance); $source = $this->input->post('calc_source'); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $created_at = $date->format('Y-m-d H:i:s'); $calc_table = 'gss_incentive_reports'; $calc_data = array( 'reference' => $reference, 'booking_id' => $booking_id, 'total_sqft' => $total_sqft, 'rate_per_sqft' => $rate_per_sqft, 'total_amount_fixed' => $total_amount_fixed, 'incentive_on_agmnt' => $incentive_on_agmnt, 'incentive_on_regn' => $incentive_on_regn, // 'insentive_perc' => $insentive_perc, 'balance' => $balance, 'source' => $source, 'created_by' => $admin_id, 'delete_status' => 'ACTIVE', 'created_at' => $created_at, ); if($insentive_perc == '40%') { $calc_data['insentive_perc'] = $insentive_perc; $table ='gss_booking_details'; $where_booking = array('booking_id'=>$booking_id); $get_booking_row = $this->gss_model->get_where_row($table,$where_booking); if($get_booking_row->sixty_status != "") { $calc_data['sixty_status'] = $get_booking_row->sixty_status; } else { $calc_data['sixty_status'] = ""; } $get_booking_row = $this->gss_model->get_where_row($table,$where_booking); if($get_booking_row->both_status != "") { $calc_data['both_status'] = $get_booking_row->both_status; } else { $calc_data['both_status'] = ""; } } else if($insentive_perc == '60%') { $calc_data['insentive_perc_sixty'] = $insentive_perc; $table ='gss_booking_details'; $where_booking = array('booking_id'=>$booking_id); $get_booking_row = $this->gss_model->get_where_row($table,$where_booking); if($get_booking_row->fourty_status != "") { $calc_data['fourty_status'] = $get_booking_row->fourty_status; } $get_booking_row = $this->gss_model->get_where_row($table,$where_booking); if($get_booking_row->both_status != "") { $calc_data['both_status'] = $get_booking_row->both_status; } } else { $calc_data['insentive_perc_both'] = $insentive_perc; $table ='gss_booking_details'; $where_booking = array('booking_id'=>$booking_id); $get_booking_row = $this->gss_model->get_where_row($table,$where_booking); if($get_booking_row->fourty_status != "") { $calc_data['fourty_status'] = $get_booking_row->fourty_status; } else { $calc_data['fourty_status'] = ""; } if($get_booking_row->sixty_status != "") { $calc_data['sixty_status'] = $get_booking_row->sixty_status; } else { $calc_data['sixty_status'] = ""; } } $where_booking = array('booking_id'=>$booking_id); $inc_data = $this->gss_model->get_where_row($calc_table,$where_booking); if(!empty($inc_data)) { $update_data = array('reference' => $reference, 'total_sqft' => $total_sqft, 'rate_per_sqft' => $rate_per_sqft, 'total_amount_fixed' => $total_amount_fixed, 'incentive_on_agmnt' => $incentive_on_agmnt, 'incentive_on_regn' => $incentive_on_regn, // 'insentive_perc' => $insentive_perc, 'balance' => $balance, 'source' => $source, 'updated_at' => $created_at, ); if($insentive_perc == '40%') { $update_data['insentive_perc'] = $insentive_perc; $table ='gss_booking_details'; $where_booking = array('booking_id'=>$booking_id); $get_booking_row = $this->gss_model->get_where_row($table,$where_booking); if($get_booking_row->sixty_status != "") { $update_data['sixty_status'] = $get_booking_row->sixty_status; } else { $update_data['sixty_status'] = ""; } $get_booking_row = $this->gss_model->get_where_row($table,$where_booking); if($get_booking_row->both_status != "") { $update_data['both_status'] = $get_booking_row->both_status; } else { $update_data['both_status'] = ""; } } else if($insentive_perc == '60%') { $table ='gss_booking_details'; $where_booking = array('booking_id'=>$booking_id); $get_booking_row = $this->gss_model->get_where_row($table,$where_booking); if($get_booking_row->fourty_status != "") { $update_data['fourty_status'] = $get_booking_row->fourty_status; } else { $update_data['fourty_status'] = ""; } $get_booking_row = $this->gss_model->get_where_row($table,$where_booking); if($get_booking_row->both_status != "") { $update_data['both_status'] = $get_booking_row->both_status; } else { $update_data['both_status'] = ""; } $update_data['insentive_perc_sixty'] = $insentive_perc; } else { $table ='gss_booking_details'; $where_booking = array('booking_id'=>$booking_id); $get_booking_row = $this->gss_model->get_where_row($table,$where_booking); if($get_booking_row->fourty_status != "") { $update_data['fourty_status'] = $get_booking_row->fourty_status; } else { $update_data['fourty_status'] = ""; } if($get_booking_row->sixty_status != "") { $update_data['sixty_status'] = $get_booking_row->sixty_status; } else { $update_data['sixty_status'] = ""; } $update_data['insentive_perc_both'] = $insentive_perc; } $update_result = $this->gss_model->update($where_booking,$calc_table,$update_data); if($this->db->affected_rows() > 0) { echo json_encode(array('result'=> 1,'message' => "Updated Successfully")); } else { echo json_encode(array('result'=> 0,'message' => "Something went wrong.. try again")); } } else { $result = $this->gss_model->insert($calc_table,$calc_data); if($result) { echo json_encode(array('result'=> 1,'message' => "Inserted Successfully")); } else { echo json_encode(array('result'=> 0,'message' => "Something went wrong.. try again")); } } } else { $total_sqft = $this->input->post('calc_total_sqft'); $rate_per_sqft = $this->input->post('calc_rate_per_sqft'); $total_amount_fixed = $this->input->post('calc_total_amount_fixed'); $total_amount_fixed = str_replace(',', '', $total_amount_fixed); $incentive_on_agmnt = $this->input->post('calc_incentive_on_agmnt'); $incentive_on_agmnt = str_replace(',', '', $incentive_on_agmnt); $incentive_on_regn = $this->input->post('calc_incentive_on_regn'); $incentive_on_regn = str_replace(',', '', $incentive_on_regn); $insentive_perc = $this->input->post('calc_insentive_perc'); $balance = $this->input->post('calc_balance'); $balance = str_replace(',', '', $balance); $source = $this->input->post('calc_source'); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $created_at = $date->format('Y-m-d H:i:s'); $calc_table = 'gss_incentive_reports'; $calc_data = array( 'reference2' => $reference, 'booking_id2' => $booking_id, 'total_sqft2' => $total_sqft, 'rate_per_sqft2' => $rate_per_sqft, 'total_amount_fixed2' => $total_amount_fixed, 'incentive_on_agmnt2' => $incentive_on_agmnt, 'incentive_on_regn2' => $incentive_on_regn, // 'insentive_perc' => $insentive_perc, 'balance2' => $balance, 'source2' => $source, 'created_by' => $admin_id, 'delete_status' => 'ACTIVE', 'created_at' => $created_at, ); if($insentive_perc == '40%') { $calc_data['insentive_perc2'] = $insentive_perc; $table ='gss_booking_details'; $where_booking = array('booking_id'=>$booking_id); $get_booking_row = $this->gss_model->get_where_row($table,$where_booking); if($get_booking_row->sixty_status2 != "") { $calc_data['sixty_status2'] = $get_booking_row->sixty_status2; } else { $calc_data['sixty_status2'] = ""; } $get_booking_row = $this->gss_model->get_where_row($table,$where_booking); if($get_booking_row->both_status2 != "") { $calc_data['both_status2'] = $get_booking_row->both_status2; } else { $calc_data['both_status2'] = ""; } } else if($insentive_perc == '60%') { $calc_data['insentive_perc_sixty2'] = $insentive_perc; $table ='gss_booking_details'; $where_booking = array('booking_id'=>$booking_id); $get_booking_row = $this->gss_model->get_where_row($table,$where_booking); if($get_booking_row->fourty_status2 != "") { $calc_data['fourty_status2'] = $get_booking_row->fourty_status2; } $get_booking_row = $this->gss_model->get_where_row($table,$where_booking); if($get_booking_row->both_status2 != "") { $calc_data['both_status2'] = $get_booking_row->both_status2; } } else { $calc_data['insentive_perc_both2'] = $insentive_perc; $table ='gss_booking_details'; $where_booking = array('booking_id'=>$booking_id); $get_booking_row = $this->gss_model->get_where_row($table,$where_booking); if($get_booking_row->fourty_status2 != "") { $calc_data['fourty_status2'] = $get_booking_row->fourty_status2; } else { $calc_data['fourty_status2'] = ""; } if($get_booking_row->sixty_status2 != "") { $calc_data['sixty_status2'] = $get_booking_row->sixty_status2; } else { $calc_data['sixty_status2'] = ""; } } $where_booking2 = array('booking_id2'=>$booking_id); $inc_data = $this->gss_model->get_where_row($calc_table,$where_booking2); if(!empty($inc_data)) { $update_data = array('reference2' => $reference, 'total_sqft2' => $total_sqft, 'rate_per_sqft2' => $rate_per_sqft, 'total_amount_fixed2' => $total_amount_fixed, 'incentive_on_agmnt2' => $incentive_on_agmnt, 'incentive_on_regn2' => $incentive_on_regn, 'balance2' => $balance, 'source2' => $source, 'updated_at' => $created_at, ); if($insentive_perc == '40%') { $update_data['insentive_perc2'] = $insentive_perc; $table ='gss_booking_details'; $where_booking = array('booking_id'=>$booking_id); $get_booking_row = $this->gss_model->get_where_row($table,$where_booking); if($get_booking_row->sixty_status2 != "") { $update_data['sixty_status2'] = $get_booking_row->sixty_status2; } else { $update_data['sixty_status2'] = ""; } $get_booking_row = $this->gss_model->get_where_row($table,$where_booking); if($get_booking_row->both_status2 != "") { $update_data['both_status2'] = $get_booking_row->both_status2; } else { $update_data['both_status2'] = ""; } } else if($insentive_perc == '60%') { $table ='gss_booking_details'; $where_booking = array('booking_id'=>$booking_id); $get_booking_row = $this->gss_model->get_where_row($table,$where_booking); if($get_booking_row->fourty_status2 != "") { $update_data['fourty_status2'] = $get_booking_row->fourty_status2; } else { $update_data['fourty_status2'] = ""; } $get_booking_row = $this->gss_model->get_where_row($table,$where_booking); if($get_booking_row->both_status2 != "") { $update_data['both_status2'] = $get_booking_row->both_status2; } else { $update_data['both_status2'] = ""; } $update_data['insentive_perc_sixty2'] = $insentive_perc; } else { $table ='gss_booking_details'; $where_booking = array('booking_id'=>$booking_id); $get_booking_row = $this->gss_model->get_where_row($table,$where_booking); if($get_booking_row->fourty_status2 != "") { $update_data['fourty_status2'] = $get_booking_row->fourty_status2; } else { $update_data['fourty_status2'] = ""; } if($get_booking_row->sixty_status2 != "") { $update_data['sixty_status2'] = $get_booking_row->sixty_status2; } else { $update_data['sixty_status2'] = ""; } $update_data['insentive_perc_both2'] = $insentive_perc; } $update_result = $this->gss_model->update($where_booking2,$calc_table,$update_data); if($this->db->affected_rows() > 0) { echo json_encode(array('result'=> 1,'message' => "Updated Successfully")); } else { echo json_encode(array('result'=> 0,'message' => "Something went wrong.. try again")); } } else { $result = $this->gss_model->insert($calc_table,$calc_data); if($result) { echo json_encode(array('result'=> 1,'message' => "Inserted Successfully")); } else { echo json_encode(array('result'=> 0,'message' => "Something went wrong.. try again")); } } } } public function get_insentive_details() { $booking_id = $this->input->post('booking_id'); $reference = $this->input->post('reference'); $table_reference ='gss_booking_details'; $where_reference = array('shared_between_executive'=>$reference,'booking_id'=>$booking_id); $get_reference = $this->gss_model->get_where_row($table_reference,$where_reference); if(empty($get_reference)) { $calc_table = 'gss_incentive_reports'; $where_booking = array('booking_id'=>$booking_id); $inc_data = $this->gss_model->get_where_row($calc_table,$where_booking); if($inc_data) { echo json_encode(array('result'=> 1,'data' => $inc_data,'executive'=>'executive1')); } else { echo json_encode(array('result'=> 0)); } } else { $calc_table = 'gss_incentive_reports'; $where_booking = array('booking_id2'=>$booking_id); $inc_data = $this->gss_model->get_where_row($calc_table,$where_booking); if($inc_data) { echo json_encode(array('result'=> 1,'data' => $inc_data,'executive'=>'executive2')); } else { echo json_encode(array('result'=> 0)); } } } public function update_mobile_project_status() { $project_id = $this->input->post('project_id'); $status = $this->input->post('status'); if($status == 'checked') { $status = 'SELECTED'; } else { $status = 'NOT_SELECTED'; } $update_data = array('mobile_status' => $status); $where_project = array('project_id' => $project_id); $project_table = 'gss_new_projects'; $update_result = $this->gss_model->update($where_project,$project_table,$update_data); if($this->db->affected_rows() > 0) { echo json_encode(array('result'=> 1,'message' => "Updated Successfully")); } else { echo json_encode(array('result'=> 0,'message' => "Something went wrong.. try again")); } } public function close_document_project() { $table = 'gss_doc_projects'; $project_id = $this->input->post('project_id'); $where = array('id'=>$project_id); $check_status = $this->gss_model->get_where_row($table, $where); if($check_status->project_status == 'ONGOING') { $data = array('project_status'=>'COMPLETED'); } else { $data = array('project_status'=>'ONGOING'); } $result = $this->gss_model->update($where,$table,$data); if($result > 0) { echo json_encode(array('result'=>1,'message'=>'Changed successfully')); } else { echo json_encode(array('result'=>0)); } } public function get_document_projects() { $project_status = $this->input->post('project_status'); if($project_status == "ALL") { $where = array('delete_status'=>'ACTIVE'); } else { $where = array('project_status'=>$project_status,'delete_status'=>'ACTIVE'); } $order_by = 'project_name'; $table = 'gss_doc_projects'; $check_status = $this->gss_model->get_where_result_alphabetical($table,$where,$order_by); if($check_status) { echo json_encode(array('result'=>1,'message'=>$check_status)); } else { echo json_encode(array('result'=>0,'message'=>'No Data Found')); } } public function get_cancelled_after_agmnt_reports() { $from_date = $_GET['from_date']; if($from_date != "") { $date = new DateTime($from_date); $from_date = $date->format('Y-m-d'); } $to_date = $_GET['to_date']; if($to_date != "") { $date = new DateTime($to_date); $to_date = $date->format('Y-m-d'); } $project_id = $_GET['project']; $result = $this->gss_model->cancelled_after_agmnt_reports($from_date,$to_date,$project_id); echo json_encode($result); } public function get_cancelled_after_agmnt_reports_print() { $from_date = $_GET['from_date']; if($from_date != "") { $date = new DateTime($from_date); $from_date = $date->format('Y-m-d'); } $to_date = $_GET['to_date']; if($to_date != "") { $date = new DateTime($to_date); $to_date = $date->format('Y-m-d'); } $project_id = $_GET['project']; $result = $this->gss_model->cancelled_after_agmnt_reports($from_date,$to_date,$project_id); if($result) { echo json_encode(array('result'=>1,'data'=>$result)); } else { echo json_encode(array('result'=>0,'data'=>'No Data Found')); } } public function get_landowners_list() { $table = 'gss_land_owners'; $where = array('delete_status' =>'ACTIVE'); $order_by = 'name'; $result = $this->gss_model->get_where_result_orderby_asc($table,$where,$order_by); if($result) { echo json_encode(array('result'=>1,'data'=>$result)); } else { echo json_encode(array('result'=>0,'message'=>'No Data Found')); } } public function get_site_project_details() { $site_id = $this->input->post('site_id'); $result = $this->gss_model->get_site_project_details($site_id); if($result) { echo json_encode(array('site_details'=>$result,'result'=>1)); } else { echo json_encode(array('result'=>0)); } } public function paidpending_executive_incentive() { $from_date = $_GET['from_date']; if($from_date != "") { $date = new DateTime($from_date); $from_date = $date->format('Y-m-d'); } $to_date = $_GET['to_date']; if($to_date != "") { $date = new DateTime($to_date); $to_date = $date->format('Y-m-d'); } $executive = $_GET['reference']; $result = $this->gss_model->get_paidpending_executive_incentives($from_date,$to_date,$executive); if($result) { echo json_encode($result); } else { echo json_encode(array('result'=>0)); } } public function add_paidinsentive_calculation() { $admin_id = session()->get('admin_id'); $reference = $this->input->post('paidcalc_reference'); $booking_id = $this->input->post('paidcalc_booking_id'); $total_sqft = $this->input->post('paidcalc_total_sqft'); $rate_per_sqft = $this->input->post('paidcalc_rate_per_sqft'); $total_amount_fixed = $this->input->post('paidcalc_total_amount_fixed'); $total_amount_fixed = str_replace(',', '', $total_amount_fixed); $incentive_on_agmnt = $this->input->post('paidcalc_incentive_on_agmnt'); $incentive_on_agmnt = str_replace(',', '', $incentive_on_agmnt); $incentive_on_regn = $this->input->post('paidcalc_incentive_on_regn'); $incentive_on_regn = str_replace(',', '', $incentive_on_regn); $insentive_perc = $this->input->post('paidcalc_insentive_perc'); $balance = $this->input->post('paidcalc_balance'); $balance = str_replace(',', '', $balance); $source = $this->input->post('paidcalc_source'); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $created_at = $date->format('Y-m-d H:i:s'); $calc_table = 'gss_incentive_reports'; $calc_data = array( 'reference' => $reference, 'booking_id' => $booking_id, 'total_sqft' => $total_sqft, 'rate_per_sqft' => $rate_per_sqft, 'total_amount_fixed' => $total_amount_fixed, 'incentive_on_agmnt' => $incentive_on_agmnt, 'incentive_on_regn' => $incentive_on_regn, // 'insentive_perc' => $insentive_perc, 'balance' => $balance, 'source' => $source, 'created_by' => $admin_id, 'delete_status' => 'ACTIVE', 'created_at' => $created_at ); // if($insentive_perc == '40%') // { // $calc_data['insentive_perc'] = $insentive_perc; // } // else if($insentive_perc == '60%') // { // $calc_data['insentive_perc_sixty'] = $insentive_perc; // } // else // { // $calc_data['insentive_perc_both'] = $insentive_perc; // } $where_booking = array('booking_id'=>$booking_id); $inc_data = $this->gss_model->get_where_row($calc_table,$where_booking); if($inc_data) { $update_data = array( 'total_sqft' => $total_sqft, 'rate_per_sqft' => $rate_per_sqft, 'total_amount_fixed' => $total_amount_fixed, 'incentive_on_agmnt' => $incentive_on_agmnt, 'incentive_on_regn' => $incentive_on_regn, // 'insentive_perc' => $insentive_perc, 'balance' => $balance, 'source' => $source, 'updated_at' => $created_at ); if($inc_data->insentive_perc != "") { //$update_data['insentive_perc'] = $insentive_perc; if($inc_data->insentive_perc_sixty == "" && $insentive_perc == '60%') { $update_data['insentive_perc_sixty'] = $insentive_perc; } else if($inc_data->insentive_perc_both == "" && $insentive_perc == 'Both') { $update_data['insentive_perc_both'] = $insentive_perc; } } else if($inc_data->insentive_perc_sixty != "") { //$update_data['insentive_perc_sixty'] = $insentive_perc; if($inc_data->insentive_perc == "" && $insentive_perc == '40%') { $update_data['insentive_perc'] = $insentive_perc; } else if($inc_data->insentive_perc_both == "" && $insentive_perc == 'Both') { $update_data['insentive_perc_both'] = $insentive_perc; } } else if($inc_data->insentive_perc_both != "") { //$update_data['insentive_perc_both'] = $insentive_perc; if($inc_data->insentive_perc == "" && $insentive_perc == '40%') { $update_data['insentive_perc'] = $insentive_perc; } else if($inc_data->insentive_perc_sixty == "" && $insentive_perc == '60%') { $update_data['insentive_perc_sixty'] = $insentive_perc; } } // print_r($update_data); $update_result = $this->gss_model->update($where_booking,$calc_table,$update_data); if($this->db->affected_rows() > 0) { echo json_encode(array('result'=> 1,'message' => "Updated Successfully")); } else { echo json_encode(array('result'=> 0,'message' => "Something went wrong.. try again")); } } else { echo json_encode(array('result'=> 0,'message' => "Something went wrong.. try again")); } } public function delete_other_document() { $pr_id = $this->input->post('pr_id'); $file_link = $this->input->post('file_link'); $file_name = $this->input->post('file_name'); $table = "gss_doc_projects"; $where = array('id'=>$pr_id); $check_images = $this->gss_model->get_where_row($table,$where); $array = array(); if($check_images) { if($check_images->other_image != "") { $prev_con_docs = $check_images->other_image; $prev_con_docs = json_decode($prev_con_docs); foreach($prev_con_docs as $key=>$val){ if($val->image != $file_link && $val->name != $file_name) { $data['image'] = $val->image; $data['name'] = $val->name; array_push($array,$data); } } } $all_docs = json_encode($array); $data = array('other_image' => $all_docs); $table = "gss_doc_projects"; $where = array('id'=>$pr_id); $result = $this->gss_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,'message' => "Could not delete.. try again")); } } else { echo json_encode(array('result'=> 0,'message' => "No data found")); } } public function get_project_based_all_sites() { $admin_id = session()->get('admin_id'); if($admin_id) { $booking_table = 'gss_bookings'; $detail_table = 'gss_booking_details'; $site_table = 'gss_new_sites'; $project_id = $this->uri->segment(2); $data['project'] = $this->gss_model->project_all_site_details($project_id); $project_result = $this->gss_model->project_all_site_details($project_id); $data['user_type_id'] = $this->access_id(); $data['access'] = $this->access_details(); $this->load->view('admin/download_all_sites_page',$data); } else { redirect('/'); } } public function sixty_perc_executive_incentive() { $from_date = $_GET['from_date']; if($from_date != "") { $date = new DateTime($from_date); $from_date = $date->format('Y-m-d'); } $to_date = $_GET['to_date']; if($to_date != "") { $date = new DateTime($to_date); $to_date = $date->format('Y-m-d'); } $executive = $_GET['reference']; $result = $this->gss_model->get_sixty_perc_executive_incentive($from_date,$to_date,$executive); if(!empty($result)) { echo json_encode($result); } else { echo json_encode(array('result'=>0)); } } public function get_sixty_percentage_total_amount() { $sixty_amount = $this->input->post('sixty_amount'); if(!empty($sixty_amount)) { $sixty_total = 0; foreach ($sixty_amount as $keys => $values) { $sixty_amounts = $values; if(!empty($sixty_amounts)) { $sixty_total+=$sixty_amounts; } } } else { $sixty_total = 0; } if($sixty_total != "0") { echo json_encode(array('result'=>1,'sixty_percent_amount'=>$sixty_total)); } else { echo json_encode(array('result'=>0)); } } public function get_fourty_percentage_total_amount() { $fourty_amount = $this->input->post('fourty_amount'); if(!empty($fourty_amount)) { $total = 0; foreach ($fourty_amount as $keys => $values) { $fourty_amounts = $values; if(!empty($fourty_amounts)) { $total+=$fourty_amounts; } } } else { $total = 0; } if($total!='0') { echo json_encode(array('result'=>1,'fourty_percent_amount'=>$total)); } else { echo json_encode(array('result'=>0)); } } public function get_shared_executive_details() { $booking_id = $this->input->post('booking_id'); $where = array('booking_id'=>$booking_id); $table = "gss_booking_details"; $result = $this->gss_model->get_where_row($table,$where); if(!empty($result)) { echo json_encode(array('result'=>1,'message'=>$result)); } else { echo json_encode(array('result'=>0)); } } public function get_edit_executives() { $broker_id = $this->input->post('broker_id'); $broker_table = 'gss_brokers'; $associate_order_by = 'associate_name'; $where_logistics = array('delete_status'=>'ACTIVE','type'=>'Executives'); $this->db->select('*'); $this->db->from($broker_table); $this->db->where($where_logistics); $this->db->order_by($associate_order_by,"ASC"); $query=$this->db->get(); $result = $query->result(); $booking_id = $this->input->post('booking_id'); $where = array('booking_id'=>$booking_id); $table = "gss_booking_details"; $result2 = $this->gss_model->get_where_row($table,$where); if($result) { echo json_encode(array('result'=>1,'executives'=>$result,'message'=>$result2)); } else { echo json_encode(array('result'=>0)); } } public function update_shared_executive_between() { $booking_id = $this->input->post('edit_exe_booking_id'); $shared_between_exe = $this->input->post('edit_shared_to_executive_ids'); $shared_to_exe = $this->input->post('edit_shared_exe_to'); $shared_exe_amount = $this->input->post('edit_shared_exe_amount'); $shared_amount = $this->input->post('edit_shared_total_amount'); $shared_percentage = $this->input->post('edit_shared_exe_percent'); $table = "gss_booking_details"; $where = array('booking_id'=>$booking_id); $data = array('shared_from_executive'=>$shared_to_exe,'shared_between_executive'=>$shared_between_exe,'shared_executive_amount'=>$shared_exe_amount,'shared_executive_percentage'=>$shared_percentage,'shared_amount'=>$shared_amount); $result = $this->gss_model->update($where,$table,$data); if($this->db->affected_rows() > 0) { echo json_encode(array('result'=>1,'message'=>'Added!')); } else { echo json_encode(array('result'=>0,'message'=>"No Data Changes to Update")); } } public function get_both_total_amount() { $fourty_amount = $this->input->post('fourty_amount'); $sixty_amount = $this->input->post('sixty_amount'); $total1 = 0; foreach ($fourty_amount as $keys => $values) { $fourty_amounts = $values; if(!empty($fourty_amounts)) { $total1+=$fourty_amounts; } } $total2 = 0; foreach ($sixty_amount as $keys => $values) { $sixty_amounts = $values; if(!empty($sixty_amounts)) { $total2+=$sixty_amounts; } } $both_amount = $total1+$total2; if(!empty($both_amount)) { echo json_encode(array('result'=>1,'both_amount'=>$both_amount)); } else { echo json_encode(array('result'=>0)); } } public function update_incentive_calculation() { $admin_id = session()->get('admin_id'); $reference = $this->input->post('edit_calc_reference'); $booking_id = $this->input->post('edit_calc_booking_id'); $total_sqft = $this->input->post('edit_calc_total_sqft'); $rate_per_sqft = $this->input->post('edit_calc_rate_per_sqft'); $total_amount_fixed = $this->input->post('edit_calc_total_amount_fixed'); $total_amount_fixed = str_replace(',', '', $total_amount_fixed); $incentive_on_agmnt = $this->input->post('edit_calc_incentive_on_agmnt'); $incentive_on_agmnt = str_replace(',', '', $incentive_on_agmnt); $incentive_on_regn = $this->input->post('edit_calc_incentive_on_regn'); $incentive_on_regn = str_replace(',', '', $incentive_on_regn); $insentive_perc = $this->input->post('edit_calc_insentive_perc'); $balance = $this->input->post('edit_calc_balance'); $balance = str_replace(',', '', $balance); $source = $this->input->post('edit_calc_source'); $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $created_at = $date->format('Y-m-d H:i:s'); $calc_table = 'gss_incentive_reports'; $update_data = array( 'total_sqft' => $total_sqft, 'rate_per_sqft' => $rate_per_sqft, 'total_amount_fixed' => $total_amount_fixed, 'incentive_on_agmnt' => $incentive_on_agmnt, 'incentive_on_regn' => $incentive_on_regn, // 'insentive_perc' => $insentive_perc, 'balance' => $balance, 'source' => $source, 'updated_at' => $created_at ); if($insentive_perc == '40%') { $update_data['insentive_perc'] = $insentive_perc; $update_data['insentive_perc_both'] = ""; $update_data['insentive_perc_sixty'] = ""; } else if($insentive_perc == '60%') { $update_data['insentive_perc'] = ""; $update_data['insentive_perc_sixty'] = $insentive_perc; $update_data['insentive_perc_both'] = ""; } else { $update_data['insentive_perc_both'] = $insentive_perc; $update_data['insentive_perc_sixty'] = ""; $update_data['insentive_perc'] = ""; } $where_booking = array('booking_id'=>$booking_id); $update_result = $this->gss_model->update($where_booking,$calc_table,$update_data); if($this->db->affected_rows() > 0) { echo json_encode(array('result'=> 1,'message' => "Updated Successfully")); } else { echo json_encode(array('result'=> 0,'message' => "Something went wrong.. try again")); } } public function delete_executive_incentives() { $booking_id = $this->input->post('booking_id'); $table = "gss_incentive_reports"; $where = array('booking_id'=>$booking_id); $data = array('delete_status'=>"INACTIVE",'booking_id'=>""); $result = $this->gss_model->update($where,$table,$data); $table1 = "gss_booking_details"; $data1 = array('selected_incentive_status'=>''); $where1 = array('booking_id'=>$booking_id); $result = $this->gss_model->update($where1,$table1,$data1); if($this->db->affected_rows() > 0) { echo json_encode(array('result'=>1,'message'=>'Deleted!')); } else { echo json_encode(array('result'=>0)); } } public function get_total_sqft() { $fourty_booking_id = explode(",",$this->input->post('fourty_booking_id')); $sixty_booking_id = explode(",",$this->input->post('sixty_booking_id')); $both_booking_id = explode(",",$this->input->post('both_booking_id')); $final_booking_ids = array_merge($fourty_booking_id,$sixty_booking_id,$both_booking_id); $ids = array_unique($final_booking_ids); $total_sqft=0; foreach($ids as $key=>$booking_ids) { if(!empty($booking_ids)) { $details=$this->gss_model->get_total_sites_sqft_booked($booking_ids); if($details) { $total_sqft+=$details->dimension; } } } if($total_sqft) { echo json_encode(array('result'=>1,'message'=>$total_sqft)); } else { echo json_encode(array('result'=>0,'message'=>'Not found')); } } } ?>