diff --git a/application/helpers/custom_helper.php b/application/helpers/custom_helper.php index d62b419..98cb73a 100644 --- a/application/helpers/custom_helper.php +++ b/application/helpers/custom_helper.php @@ -27,7 +27,16 @@ function check_auth() } } - + //check admin + if (!function_exists('is_superadmin')) + { + function is_superadmin() + { + // Get a reference to the controller object + $ci =& get_instance(); + return $ci->auth_model->is_superadmin(); + } + } //check admin if (!function_exists('is_admin')) { diff --git a/application/modules/Asset/controllers/Asset.php b/application/modules/Asset/controllers/Asset.php index 9f6deec..9b0c57b 100644 --- a/application/modules/Asset/controllers/Asset.php +++ b/application/modules/Asset/controllers/Asset.php @@ -109,8 +109,9 @@ public function editAsset($id) $asset_value = $this->Asset_model->get_by_asset_id($id,'asset_value',user()->business_id); $asset_usage = $this->Asset_model->get_by_asset_id($id,'asset_usage',user()->business_id); $asset_amc = $this->Asset_model->get_amc_with_join($id,'amc',user()->business_id); + $asset_insurance = $this->Asset_model->get_insurance_with_join($id,user()->business_id); $asset_images = $this->Asset_model->get_by_asset_id($id,'asset_images',user()->business_id); - $data = array('asset_id'=>$assetData->id,'asset_value' => $asset_value ,'asset_usage' => $asset_usage , 'asset_amc' =>$asset_amc , 'asset_images'=>$asset_images); + $data = array('asset_id'=>$assetData->id,'asset_value' => $asset_value ,'asset_usage' => $asset_usage , 'asset_amc' =>$asset_amc ,'asset_insurance'=>$asset_insurance, 'asset_images'=>$asset_images); $sub_asset_value_htmlPage = $this->load->view('asset_sub_value_list.php',$data,true); $this->layout->set('sub_asset_value_htmlPage', $sub_asset_value_htmlPage); $this->layout->set('editData', $assetData); @@ -179,20 +180,24 @@ public function deleteAsset($id) public function view_asset_details($id) { - + $tab = $this->session->flashdata(); + // $tab = 1; + //print_r($tab);die(); // select asset value by id $table="asset"; $assetData = $this->Asset_model->get_asset_by_md5_id($id,user()->business_id); // select asset sub values by id $asset_value = $this->Asset_model->get_by_asset_id($id,'asset_value',user()->business_id); $asset_usage = $this->Asset_model->get_by_asset_id($id,'asset_usage',user()->business_id); - $asset_amc = $this->Asset_model->get_amc_with_join($id,'amc',user()->business_id); + $asset_amc = $this->Asset_model->get_amc_with_join($id,user()->business_id); + $asset_insurance = $this->Asset_model->get_insurance_with_join($id,user()->business_id); $asset_images = $this->Asset_model->get_by_asset_id($id,'asset_images',user()->business_id); - $data = array('asset_id'=>$assetData->id,'asset_value' => $asset_value ,'asset_usage' => $asset_usage , 'asset_amc' =>$asset_amc , 'asset_images'=>$asset_images); + $data = array('asset_id'=>$assetData->id,'asset_value' => $asset_value ,'asset_usage' => $asset_usage , 'asset_amc' =>$asset_amc ,'asset_insurance'=>$asset_insurance, 'asset_images'=>$asset_images,'tab'=>$tab); $sub_asset_value_htmlPage = $this->load->view('asset_sub_value_list.php',$data,true); $this->layout->set('sub_asset_value_htmlPage', $sub_asset_value_htmlPage); $this->layout->set('editData', $assetData); - $this->layout->buffer('main_content', 'Asset/view_asset_details'); + $this->layout->set('viewData', 1); + $this->layout->buffer('main_content', 'Asset/edit_asset'); $this->layout->render('default_layout'); } @@ -248,6 +253,7 @@ public function add_or_edit_asset_value() $data['created_by'] = user()->id; $createAssetValueData = $this->MY_Model->insert($data, 'asset_value'); //$this->view_asset_details(md5($this->input->post('asset_id_for_add'))); + $this->session->set_flashdata(1); redirect('asset/view_asset_details/'.md5($this->input->post('asset_id_for_add'))); } } @@ -301,14 +307,13 @@ public function add_or_edit_asset_usage() public function getAssetAMCForm($id) { $split = preg_split('/_/', $id); - $insuranceData = $this->MY_Model->select_by_business_id_and_type('third_parties',user()->business_id,4); $serviceProviderData = $this->MY_Model->select_by_business_id_and_type('third_parties',user()->business_id,3); if(count($split) > 1) { - $data = array('asset_id'=> $split[0], 'insuranceData'=>$insuranceData,'serviceProviderData'=>$serviceProviderData, 'heading'=>'Add AMC' , 'submit_button_title'=>'Submit'); + $data = array('asset_id'=> $split[0], 'serviceProviderData'=>$serviceProviderData, 'heading'=>'Add AMC' , 'submit_button_title'=>'Submit'); }else{ $asset_amc_data = $this->Asset_model->get_amc_by_id_with_join($id); - $data = array('insuranceData'=>$insuranceData,'serviceProviderData'=>$serviceProviderData,'assetAMCData'=>$asset_amc_data ,'heading'=>'Edit AMC' , 'submit_button_title'=>'Update'); + $data = array('serviceProviderData'=>$serviceProviderData,'assetAMCData'=>$asset_amc_data ,'heading'=>'Edit AMC' , 'submit_button_title'=>'Update'); } $htmlPage = $this->load->view('asset_amc_form.php',$data,true); @@ -329,7 +334,6 @@ public function add_or_edit_asset_amc() $data['business_id'] = user()->business_id; $data['service_provider'] = $this->input->post('service_provider'); $data['cost'] = $this->input->post('cost'); - $data['insurance'] = $this->input->post('insurance'); $data['description'] = $this->input->post('description'); $data['valid_from'] = $this->input->post('valid_from'); $data['valid_to'] = $this->input->post('valid_to'); @@ -342,6 +346,50 @@ public function add_or_edit_asset_amc() +public function getAssetInsuranceForm($id) + { + $split = preg_split('/_/', $id); + $insuranceData = $this->MY_Model->select_by_business_id_and_type('third_parties',user()->business_id,4); + if(count($split) > 1) + { + $data = array('asset_id'=> $split[0], 'insuranceData'=>$insuranceData, 'heading'=>'Add AMC' , 'submit_button_title'=>'Submit'); + }else{ + $asset_insurance_data = $this->Asset_model->get_insurance_by_id_with_join($id); + $data = array('insuranceData'=>$insuranceData,'assetInsuranceData'=>$asset_insurance_data ,'heading'=>'Edit AMC' , 'submit_button_title'=>'Update'); + } + + $htmlPage = $this->load->view('asset_insurance_form.php',$data,true); + echo json_encode($htmlPage); + } + + + + + public function add_or_edit_asset_insurance() + { + if($this->input->post('id')) + { + $value = $this->input->post(); + unset($value['asset_id_for_add']); + $editInsuranceData = $this->MY_Model->edit_option($value, $this->input->post('id'), 'asset_insurance'); + redirect('asset/view_asset_details/'.md5($this->input->post('asset_id'))); + }else{ + $data['asset_id'] = $this->input->post('asset_id_for_add'); + $data['business_id'] = user()->business_id; + $data['insurance_company'] = $this->input->post('insurance_company'); + $data['valid_from'] = $this->input->post('valid_from'); + $data['valid_to'] = $this->input->post('valid_to'); + $data['created_by'] = user()->id; + $createInsuranceData = $this->MY_Model->insert($data, 'asset_insurance'); + redirect('asset/view_asset_details/'.md5($this->input->post('asset_id_for_add'))); + } + } + + + + + + public function getAssetImageForm($id) { @@ -410,6 +458,14 @@ public function deleteAssetImage($id) $Data = $this->Asset_model->delete_by_md5_id($key,user()->business_id,'asset_images'); redirect('asset/view_asset_details/'.md5($asset_id)); } + public function deleteAssetInsurance($id) + { + $split = preg_split('/_/', $id); + $key = $split[0]; + $asset_id = $split[1]; + $Data = $this->Asset_model->delete_by_md5_id($key,user()->business_id,'asset_insurance'); + redirect('asset/view_asset_details/'.md5($asset_id)); + } diff --git a/application/modules/Asset/models/Asset_model.php b/application/modules/Asset/models/Asset_model.php index 9ec5d71..4b0f440 100644 --- a/application/modules/Asset/models/Asset_model.php +++ b/application/modules/Asset/models/Asset_model.php @@ -47,12 +47,12 @@ public function get_by_asset_id($id,$table,$business_id) $query = $query->result(); return $query; } -public function get_amc_with_join($id,$table,$business_id) +public function get_amc_with_join($id,$business_id) { - $this->db->select('A.* , third_parties.name as service_provider_name , tp.name as insurance_name'); + $this->db->select('A.* , third_parties.name as service_provider_name '); $this->db->from('amc A'); $this->db->join('third_parties', 'third_parties.id = A.service_provider', 'left'); - $this->db->join('third_parties as tp', 'tp.id = A.insurance', 'left'); + $this->db->where('A.business_id', $business_id); $this->db->where('md5(A.asset_id)', $id); $this->db->where('is_active', 1); @@ -62,10 +62,33 @@ public function get_amc_with_join($id,$table,$business_id) } public function get_amc_by_id_with_join($id) { - $this->db->select('A.* , third_parties.name as service_provider_name , tp.name as insurance_name'); + $this->db->select('A.* , third_parties.name as service_provider_name '); $this->db->from('amc A'); $this->db->join('third_parties', 'third_parties.id = A.service_provider', 'left'); - $this->db->join('third_parties as tp', 'tp.id = A.insurance', 'left'); + $this->db->where('md5(A.id)', $id); + $this->db->where('is_active', 1); + $query = $this->db->get(); + $query = $query->row(); + return $query; +} + +public function get_insurance_with_join($id,$business_id) + { + $this->db->select('A.* , third_parties.name as insurance_company_name '); + $this->db->from('asset_insurance A'); + $this->db->join('third_parties', 'third_parties.id = A.insurance_company', 'left'); + $this->db->where('A.business_id', $business_id); + $this->db->where('md5(A.asset_id)', $id); + $this->db->where('is_active', 1); + $query = $this->db->get(); + $query = $query->result(); + return $query; + } +public function get_insurance_by_id_with_join($id) +{ + $this->db->select('A.* , third_parties.name as insurance_company_name '); + $this->db->from('asset_insurance A'); + $this->db->join('third_parties', 'third_parties.id = A.insurance_company', 'left'); $this->db->where('md5(A.id)', $id); $this->db->where('is_active', 1); $query = $this->db->get(); diff --git a/application/modules/Asset/views/add_asset.php b/application/modules/Asset/views/add_asset.php index 2046744..ab29a1a 100644 --- a/application/modules/Asset/views/add_asset.php +++ b/application/modules/Asset/views/add_asset.php @@ -131,7 +131,7 @@
- +
  • diff --git a/application/modules/Asset/views/asset_amc_form.php b/application/modules/Asset/views/asset_amc_form.php index ce5dc09..69c500a 100644 --- a/application/modules/Asset/views/asset_amc_form.php +++ b/application/modules/Asset/views/asset_amc_form.php @@ -38,17 +38,6 @@ -
    - -
    - -
    -
    diff --git a/application/modules/Asset/views/asset_insurance_form.php b/application/modules/Asset/views/asset_insurance_form.php new file mode 100644 index 0000000..7c44766 --- /dev/null +++ b/application/modules/Asset/views/asset_insurance_form.php @@ -0,0 +1,72 @@ + + diff --git a/application/modules/Asset/views/asset_list.php b/application/modules/Asset/views/asset_list.php index ba86707..54f1acb 100644 --- a/application/modules/Asset/views/asset_list.php +++ b/application/modules/Asset/views/asset_list.php @@ -14,9 +14,9 @@
    - - - +
    + +
    @@ -75,7 +75,7 @@ - +
    diff --git a/application/modules/Asset/views/asset_sub_value_list.php b/application/modules/Asset/views/asset_sub_value_list.php index 94c4a35..3b69f09 100644 --- a/application/modules/Asset/views/asset_sub_value_list.php +++ b/application/modules/Asset/views/asset_sub_value_list.php @@ -1,4 +1,4 @@ - +

    Details

    @@ -15,7 +15,10 @@ Asset usage +
    @@ -80,15 +84,15 @@ " data-toggle="modal" data-target=".bs-example-modal-sm" style=" text-align: center; font-size: 25px; color:#2A3F54; ">

  • - +
    - - - - - + + + + + @@ -111,9 +115,8 @@
    From To Quater Shift Action From To Quater Shift Action
    -
    - - +
    +
    @@ -123,18 +126,17 @@ " data-toggle="modal" data-target=".bs-example-modal-sm" style=" text-align: center; font-size: 25px; color:#2A3F54; ">

  • - +
    - - - - - - - - + + + + + + + @@ -144,7 +146,6 @@ - @@ -161,11 +162,47 @@
    Service Provider Cost Insurance Description Valid From Valid To Expair on Action Service Provider Cost Description Valid From Valid To Expire on Action
    service_provider_name; ?> cost; ?>insurance_name; ?> description; ?> valid_from); ?> valid_to); ?>
    - + +
    +
    +
    + + + + + + + + + + + + $value) { ?> + + + + + + + + +
    Insurance Company Valid From Valid To Action
    insurance_company_name; ?>valid_from); ?>valid_to); ?> +   + + +  + asset_id;?>" style="font-size: 16px;"> +
    +
    +
    +
    @@ -208,8 +245,7 @@
    - xxFood truck fixie locavore, accusamus mcsweeney's marfa nulla single-origin coffee squid. Exercitation +1 labore velit, blog sartorial PBR leggings next level wes anderson artisan four loko farm-to-table craft beer twee. Qui photo - booth letterpress, commodo enim craft beer mlkshk +
    diff --git a/application/modules/Asset/views/edit_asset.php b/application/modules/Asset/views/edit_asset.php index 0dfd957..a434f86 100644 --- a/application/modules/Asset/views/edit_asset.php +++ b/application/modules/Asset/views/edit_asset.php @@ -1,13 +1,13 @@ - +
    -

    Edit Assets

    +

    - +Assets List
    @@ -28,13 +28,14 @@
    - + >
    -> $value) { ?> @@ -46,24 +47,24 @@
    - +>
    - +>
    - +>
    -> $value) { ?> @@ -77,7 +78,7 @@
    -> $value) { ?> @@ -87,7 +88,7 @@
    - > $value) { ?> @@ -100,7 +101,7 @@
    - +

    Order Related Information

    @@ -109,14 +110,14 @@
    - + >
    - + /> @@ -132,7 +133,7 @@
    -> $value) { ?> @@ -143,7 +144,7 @@
    - +>
    @@ -152,12 +153,16 @@
    - +
    + +Girl in a jacket + +
    @@ -169,7 +174,7 @@ - +
    @@ -177,6 +182,8 @@
    + +
    @@ -190,9 +197,6 @@ -
    -
    -
    diff --git a/application/modules/Asset/views/view_asset_details.php b/application/modules/Asset/views/view_asset_details.php index c2b4e34..6d62f5b 100644 --- a/application/modules/Asset/views/view_asset_details.php +++ b/application/modules/Asset/views/view_asset_details.php @@ -1,7 +1,7 @@ - +
    @@ -14,7 +14,7 @@
    General Information
    diff --git a/application/modules/Auth/models/Auth_model.php b/application/modules/Auth/models/Auth_model.php index d8d874f..fa14f56 100644 --- a/application/modules/Auth/models/Auth_model.php +++ b/application/modules/Auth/models/Auth_model.php @@ -41,7 +41,24 @@ public function get_user($id) $query = $this->db->get('users'); return $query->row(); } + + //is super admin + public function is_superadmin() + { + // get_header_info(); + //check logged in + if (!$this->is_logged_in()) { + return false; + } + //check role + if (user()->role == 'sadmin') { + return true; + } else { + return false; + } + } + //is admin public function is_admin() { diff --git a/application/modules/Dashboard/views/dashboard.php b/application/modules/Dashboard/views/dashboard.php index b6474e1..2c367c6 100644 --- a/application/modules/Dashboard/views/dashboard.php +++ b/application/modules/Dashboard/views/dashboard.php @@ -16,6 +16,7 @@

    LOGGEDIN :

    +

    IS_SUPERADMIN :

    IS_ADMIN :

    IS_USER :

    USER :

    diff --git a/application/modules/Layout/views/includes/default_footer.php b/application/modules/Layout/views/includes/default_footer.php index 11b7263..1b2ad48 100644 --- a/application/modules/Layout/views/includes/default_footer.php +++ b/application/modules/Layout/views/includes/default_footer.php @@ -180,6 +180,23 @@ }); }); +$(document).on('click','.asset_insurance',function(){ + var id = $(this).attr("id"); + + var getUrl = window.location; + var baseUrl = getUrl .protocol + "//" + getUrl.host + "/" + getUrl.pathname.split('/')[1]; + var url = baseUrl+"/"; + + $.ajax({ + url:url+"asset/getAssetInsuranceForm/"+id, + type:"GET", + success:function(data){ + + $('#edit-form').html(JSON.parse(data)); + + } + }); +}); $(document).on('click','.asset_image',function(){ var id = $(this).attr("id"); @@ -203,12 +220,22 @@ $(document).on('click','#close-form',function(){ - + $('#edit-form').css('display', 'none'); - $("#asset_usage-tab").tab('show'); + +}); +$( document ).ready(function() { + var tab_value = $("#current_tab").val(); + + if(tab_value == 1) + { + $("#asset_usage-tab").tab('show'); + } + }); + diff --git a/application/modules/Layout/views/includes/default_menu.php b/application/modules/Layout/views/includes/default_menu.php index 9a68072..a829e62 100644 --- a/application/modules/Layout/views/includes/default_menu.php +++ b/application/modules/Layout/views/includes/default_menu.php @@ -2,7 +2,10 @@
    -
    + \ No newline at end of file diff --git a/assets/uploads/istockphoto-1322913815-612x6121.jpg b/assets/uploads/istockphoto-1322913815-612x6121.jpg new file mode 100644 index 0000000..b305021 Binary files /dev/null and b/assets/uploads/istockphoto-1322913815-612x6121.jpg differ