?
Current Path : /home1/savoy/public_html/savoyglobal.net/sec_old/application/models/ |
Linux gator3171.hostgator.com 4.19.286-203.ELK.el7.x86_64 #1 SMP Wed Jun 14 04:33:55 CDT 2023 x86_64 |
Current File : /home1/savoy/public_html/savoyglobal.net/sec_old/application/models/franchiseemodel.php |
<?php if (!defined('BASEPATH')) exit('No direct script access allowed'); class Franchiseemodel extends CI_Model { function __construct() { // Call the Model constructor parent::__construct(); // $this->load->model('hrmodel'); } function search_franchisee($pagenum) { $data = array(); $this->db->select('*'); $this->db->from('franchisee'); $this->db->join('master', 'master_id=franchisee_id'); $this->db->order_by('franchisee_id', 'desc'); $data['results'] = $this->db->get(); return $data; } function insert_franchisee($postdata) { $data = array(); $this->db->trans_begin(); $masterid = $this->mastermodel->insertmasterdata(); $tblValues = array( 'franchisee_id' => $masterid, 'franchisee_name' => $postdata['franchisee_name'], 'franchisee_code' => $postdata['franchisee_code'], 'franchisee_address' => $postdata['franchisee_address'], 'franchisee_contact_no' => $postdata['franchisee_contact_no'], 'franchisee_email' => $postdata['franchisee_email'], 'franchisee_website' => $postdata['franchisee_website'], 'franchisee_remarks' => $postdata['franchisee_remarks'], ); $this->db->insert('franchisee', $tblValues); $i = 1; while (isset($postdata['course_id' . $i])) { if ($postdata['course_id' . $i] != "") { $tblValues = array( 'franchisee_id' => $masterid, 'course_id' => $postdata['course_id' . $i], 'franchisee_course_remarks' => $postdata['franchisee_course_remarks' . $i], ); $this->db->insert('franchisee_course', $tblValues); } $i++; } $i = 1; while (isset($postdata['franchisee_contact_person_name' . $i])) { if ($postdata['franchisee_contact_person_name' . $i] != "") { $tblValues = array( 'franchisee_id' => $masterid, 'franchisee_contact_person_name' => $postdata['franchisee_contact_person_name' . $i], 'franchisee_contact_no' => $postdata['franchisee_contact_no' . $i], 'franchisee_contact_email' => $postdata['franchisee_contact_email' . $i], 'franchisee_contact_address' => $postdata['franchisee_contact_address' . $i] ); $this->db->insert('franchisee_contact', $tblValues); } $i++; } $parent = $this->mastermodel->get_account_settings('franchisee', 'finance_sub_account_settings'); if ($parent) { $chart_type_id = $this->mastermodel->get_single_field_value('finance_chart_master', 'chart_type_id', 'chart_master_id', $parent); if ($this->mastermodel->get_num_rows('finance_chart_master', 'chart_account_code', $postdata['franchisee_code']) == 0) { $tblValues = array( 'chart_account_code' => $postdata['franchisee_code'], 'chart_account_name' => $postdata['franchisee_name'], 'chart_type_id' => $chart_type_id, 'parent' => $parent, 'inactive' => 0); $this->db->insert('finance_chart_master', $tblValues); } else { $tblValues = array( 'chart_account_name' => $postdata['franchisee_name'], 'chart_type_id' => $chart_type_id, 'parent' => $parent, 'inactive' => 0); $this->db->where('chart_account_code', $postdata['franchisee_code']); $this->db->update('finance_chart_master', $tblValues); } } $data['resfunction'] = 'search_franchisee'; if ($this->db->trans_status() === FALSE) { $this->db->trans_rollback(); $data['res'] = 0; $data['msg'] = 'Error On Adding Record'; return $data; } else { $this->db->trans_commit(); $data['res'] = 1; $data['msg'] = 'Record Added Successfully'; return $data; } } function update_franchisee($postdata) { $data = array(); $this->db->trans_begin(); $tblValues = array( 'franchisee_name' => $postdata['franchisee_name'], 'franchisee_address' => $postdata['franchisee_address'], 'franchisee_contact_no' => $postdata['franchisee_contact_no'], 'franchisee_email' => $postdata['franchisee_email'], 'franchisee_website' => $postdata['franchisee_website'], 'franchisee_remarks' => $postdata['franchisee_remarks'], ); $this->db->where('franchisee_id', $postdata['franchisee_id']); $this->db->update('franchisee', $tblValues); $this->db->where('franchisee_id', $postdata['franchisee_id']); $this->db->delete('franchisee_course'); $i = 1; while (isset($postdata['course_id' . $i])) { if ($postdata['course_id' . $i] != '') { $tblValues = array( 'franchisee_id' => $postdata['franchisee_id'], 'course_id' => $postdata['course_id' . $i], 'franchisee_course_remarks' => $postdata['franchisee_course_remarks' . $i], ); $this->db->insert('franchisee_course', $tblValues); } $i++; } $this->db->where('franchisee_id', $postdata['franchisee_id']); $this->db->delete('franchisee_contact'); $i = 1; while (isset($postdata['franchisee_contact_person_name' . $i])) { if ($postdata['franchisee_contact_person_name' . $i] != '') { $tblValues = array( 'franchisee_id' => $postdata['franchisee_id'], 'franchisee_contact_person_name' => $postdata['franchisee_contact_person_name' . $i], 'franchisee_contact_no' => $postdata['franchisee_contact_no' . $i], 'franchisee_contact_email' => $postdata['franchisee_contact_email' . $i], 'franchisee_contact_address' => $postdata['franchisee_contact_address' . $i] ); $this->db->insert('franchisee_contact', $tblValues); } $i++; } $parent = $this->mastermodel->get_account_settings('franchisee', 'finance_sub_account_settings'); if ($parent) { $chart_type_id = $this->mastermodel->get_single_field_value('finance_chart_master', 'chart_type_id', 'chart_master_id', $parent); if ($this->mastermodel->get_num_rows('finance_chart_master', 'chart_account_code', $postdata['franchisee_code']) == 0) { $tblValues = array('chart_account_code' => $postdata['franchisee_code'], 'chart_account_name' => $postdata['franchisee_name'], 'chart_type_id' => $chart_type_id, 'parent' => $parent, 'inactive' => 0); $this->db->insert('finance_chart_master', $tblValues); } else { $tblValues = array( 'chart_account_name' => $postdata['franchisee_name'], 'chart_type_id' => $chart_type_id, 'parent' => $parent, 'inactive' => 0); $this->db->where('chart_account_code', $postdata['franchisee_code']); $this->db->update('finance_chart_master', $tblValues); } } $data['resfunction'] = 'search_franchisee'; if ($this->db->trans_status() === FALSE) { $this->db->trans_rollback(); $data['res'] = 0; $data['msg'] = 'Error On Updating Record'; return $data; } else { $this->db->trans_commit(); $data['res'] = 1; $data['msg'] = 'Record Updated Successfully'; return $data; } } } ?>