for add // 1 -> for edit public function __construct() { parent::__construct(); //call parent constructor $this->is_logged_in(); //this->output->enable_profiler(TRUE); //profiler for debugging //start load models, helpers, libraries, etc $this->load->model('mydocument/mydocument_m'); $this->load->model('common/common_type_m'); $this->load->model('common/indp_mst_data_m'); $this->load->model('systmMngt/oa_brands_m'); $this->load->model('user/user_master_m'); $this->load->model('systmMngt/org_accounts_m'); $this->load->model('common/permission_validate_m'); //$this->load->model('accounts/acc_mst_m'); //start load models, helpers, libraries, etc //start constructor code //constructor code here //end constructor code } public function index() { $head['title'] = 'My Documnet'; $pvs_ObjNm='mydocument'; $common = new common_c(); //create object $colNm = null; $colValue = null; $orgColumName = 'OA_BRAND_ID'; $orgID = $this->session->userdata('oaBrandID'); $userColumnName = 'USER_ID'; $userID = $this->session->userdata('user_id'); $primaryKeyColumn = 'DOCUMENT_ID'; $data = $common->getTableDtl($pvs_ObjNm,$primaryKeyColumn,$colNm,$colValue,$orgColumName,$orgID,$userColumnName,$userID); //call function $data['firstParameter'] = 'DOCUMENT_ID'; $data['editFunctionName'] = 'editDOCUMENT'; $data['deleteFunctionName'] = 'delete'; $data['secondParameter'] = ''; if(! empty($this->input->get('pid'))) $this->session->set_userdata('permission_id', $this->input->get('pid')); $template['header'] = $this->load->view('include/header_v', $head); $template['menu'] = $this->load->view('include/left_menu_v', true); $template['body'] = $this->load->view('asset_manager/mydocument_v', $data); $template['footer'] = $this->load->view('include/footer_v', true); $this->load->view('include/main_page_v', $template); } public function initForm($Id){ //start of setting initial values for insert mode if(!$Id) { $head['title'] = 'New Document'; $data['title'] = 'New Document'; $data['action'] = site_url('mydocument/mydocument/insert'); $data['id'] = null; // $data['Assetid'] = null; // $data['VendorId'] = null; // $data['Accountcode'] = null; // $data['FA']=null; $data['purchaseDate'] = null; $data['financeDate'] = null; $data['actionMode'] = "add"; $data['OaId'] = $this->session->userdata('oaID'); $data['OaBrandId'] = $this->session->userdata('oaBrandID'); $data['UserId'] = $this->session->userdata('user_id'); //$data['OaBrandID'] = null; } //end of setting initial values for insert mode //start of setting initial values for update mode if($Id) { $head['title'] = 'Edit Document'; $data['title'] = 'Edit Document'; $data['action'] = site_url('mydocument/mydocument/update'); $data['id'] = $Id; $data['actionMode'] = "edit"; $data['OaId'] = $this->mydocument_m->getoaId($Id); $data['UserId'] = $this->mydocument_m->getuserId($Id); $data['OaBrandId'] = $this->mydocument_m->getOaBrndId($Id); } //end of setting initial values for update mode $data['DOCUMENT_ID'] = $this->mydocument_m->getdocumentid($Id,1); $data['FILE_NAME'] = $this->mydocument_m->getfilename($Id,1); $data['PARENT_FOLDER'] = $this->mydocument_m->getparentfolder($Id,1); $data['ASSIGN_TO_OWNER'] = $this->mydocument_m->getassigntoowner($Id,1); $data['ASSIGN_TO_DEPARTMENT'] = $this->mydocument_m->getassigntodepartment($Id,1); $data['CATEGORY'] = $this->mydocument_m->getcategory($Id,1); $data['HOW_TO_GUIDE'] = $this->mydocument_m->gethowtoguide($Id,1); $data['PROJECT'] = $this->mydocument_m->getproject($Id,1); $data['DOCUMENT_TYPE'] = $this->mydocument_m->getdocumenttype($Id,1); $data['DESCRIPTION'] = $this->mydocument_m->getdescription($Id,1); $data['COMMENT'] = $this->mydocument_m->getcomment($Id,1); //start of setting initial values for both insert and update mode $data['orgpath'] = site_url('user/user_domain/changeOrgBrand/'); $data['orgBrandPath'] = site_url('systmMngt/oa_brands/dependableUserBasedOnOrgBrand'); $data['organisationDrop'] = $this->org_accounts_m->getAllOrganisations(); $data['brandDrop']=$this->oa_brands_m->getAllOrgBrandsforEdit($data['OaId']); $data['userDrop']=$this->oa_brands_m->getAllUserBasedOnOrgBrandForEdit($data['OaBrandId']); //$DeviceNameIndMstId = 230; //$data['Device_list'] = $this->indp_mst_data_m->getAllIndMstDetailsDropdownByTypeId($DeviceNameIndMstId); $ALPU = 537; $data['alpUnit'] = $this->indp_mst_data_m->getAllIndMstDetailsByTypeId($ALPU)->result(); $DM = 538; $data['DMethod'] = $this->indp_mst_data_m->getAllIndMstDetailsByTypeId($DM)->result(); $data['AssetIdnamef']=$this->asset_reg_m->getAssetmaster(); $template['header'] = $this->load->view('include/header_v', $head); $template['menu'] = $this->load->view('include/left_menu_v', true); $template['body'] = $this->load->view('mydocument/view_mydocument', $data); $template['footer'] = $this->load->view('include/footer_v', true); $this->load->view('include/main_page_v', $template); //end of setting initial values for both insert and update mode } public function setFormControls(){ //start of setting rules for insert mode if($this->actionMode==0){ //enter insert rules here } //end of setting rules for insert mode //start of setting rules for update mode if($this->actionMode==1){ $this->DOCUMENT_ID = $this->input->post('id'); } //end of setting rules for update mode //start of setting rules for both insert and update mode //$this->gvn_settingId = $this->input->post('refTypId'); $this->FILE_NAME = $this->input->post('FILE_NAME'); $this->PARENT_FOLDER = $this->input->post('PARENT_FOLDER'); $this->ASSIGN_TO_OWNER = $this->input->post('ASSIGN_TO_OWNER'); $this->ASSIGN_TO_DEPARTMENT = $this->input->post('ASSIGN_TO_DEPARTMENT'); $this->CATEGORY = $this->input->post('CATEGORY'); $this->HOW_TO_GUIDE = $this->input->post('HOW_TO_GUIDE'); $this->PROJECT = $this->input->post('PROJECT'); $this->DOCUMENT_TYPE = $this->input->post('DOCUMENT_TYPE'); $this->DESCRIPTION = $this->input->post('DESCRIPTION'); $this->COMMENT = $this->input->post('COMMENT'); if($this->session->userdata('is_admin')!=0) { $this->gvn_oaId = $this->input->post('OaId'); $this->gvn_BrandId = $this->input->post('OaBrandID'); $this->gvn_userId = $this->input->post('user'); } else { $this->gvn_oaId = $this->session->userdata('oaID'); $this->gvn_BrandId = $this->session->userdata('oaBrandID'); $this->gvn_userId = $this->session->userdata('user_id'); } //$accdate = date('Y-m-d H:i:s'); //end of setting rules for both insert and update mode if($this->actionMode==0) { $this->mydocument_m->insert($this->FILE_NAME,$this->PARENT_FOLDER, $this->ASSIGN_TO_OWNER,$this->ASSIGN_TO_DEPARTMENT, $this->CATEGORY,$this->HOW_TO_GUIDE ,$this->PROJECT,$this->DOCUMENT_TYPE,$this->DESCRIPTION,$this->COMMENT,$this->gvn_oaId, $this->gvn_BrandId, $this->gvn_userId); } else { $this->mydocument_m->update($this->DOCUMENT_ID,$this->FILE_NAME,$this->PARENT_FOLDER, $this->ASSIGN_TO_OWNER,$this->ASSIGN_TO_DEPARTMENT, $this->CATEGORY,$this->HOW_TO_GUIDE ,$this->PROJECT,$this->DOCUMENT_TYPE,$this->DESCRIPTION,$this->COMMENT,$this->gvn_oaId, $this->gvn_BrandId, $this->gvn_userId); } } public function setFormValidationRules(){ //start of setting rules for insert mode if($this->actionMode==0){ //enter insert rules here } //end of setting rules for insert mode //start of setting rules for update mode if($this->actionMode==1){ $this->form_validation->set_rules('id', 'ASSET Reg Id', 'trim|required|integer'); } //end of setting rules for update mode //start of setting rules for both insert and update mode $this->form_validation->set_rules('FILE_NAME', 'FILE_NAME', 'trim|required'); $this->form_validation->set_rules('PARENT_FOLDER', 'PARENT_FOLDER', 'trim|required'); $this->form_validation->set_rules('ASSIGN_TO_OWNER', 'ASSIGN_TO_OWNER', 'trim|required'); $this->form_validation->set_rules('ASSIGN_TO_DEPARTMENT', 'ASSIGN_TO_DEPARTMENT', 'trim|required'); $this->form_validation->set_rules('CATEGORY', 'CATEGORY', 'trim|required'); $this->form_validation->set_rules('HOW_TO_GUIDE', 'HOW_TO_GUIDE', 'trim|required'); $this->form_validation->set_rules('PROJECT', 'PROJECT', 'trim|required'); $this->form_validation->set_rules('DOCUMENT_TYPE', 'DOCUMENT_TYPE', 'trim|required'); $this->form_validation->set_rules('DESCRIPTION', 'DESCRIPTION', 'trim|required'); $this->form_validation->set_rules('COMMENT', 'COMMENT', 'trim|required'); //end of setting rules for both insert and update mode } public function newdocument() { //$actionMode = 0; if(! $this->permission_validate_m->has_insert_permission()) { $mstrText =$this->indp_mst_data_m->getAllIndpMstDataByCode(EMTSI00001)->row()->MSTR_NM; $this->session->set_flashdata("success", nl2br(wordwrap($mstrText))); redirect('/asset_manager/asset_finance', 'refresh'); } $this->initForm(0); } public function editdocument($DOCUMENT_ID=null) { //$actionMode = 1; $this->initForm($DOCUMENT_ID); } public function insert() { $this->actionMode = 0; //start of form validation $this->load->library('form_validation'); $this->setFormValidationRules(); //end of form validation if ($this->form_validation->run() == FALSE) { $this->newdocument(); } else { $this->setFormControls(); $this->session->set_flashdata("success", "Successfully Added Document"); redirect('/mydocument/mydocument', 'refresh'); } } public function update() { $this->actionMode = 1; if(! $this->permission_validate_m->has_modify_permission()) { $mstrText =$this->indp_mst_data_m->getAllIndpMstDataByCode(EMTSI00002)->row()->MSTR_NM; $this->session->set_flashdata("success", nl2br(wordwrap($mstrText))); redirect('/mydocument/mydocument', 'refresh'); } //start of form validation $this->load->library('form_validation'); $this->setFormValidationRules(); //end of form validation if ($this->form_validation->run() == FALSE) { $this->editdocument($this->input->post('id')); } else { $this->setFormControls(); $this->session->set_flashdata("success", "Successfully Updated Document"); redirect('/mydocument/mydocument', 'refresh'); } } public function delete($id) { if(! $this->permission_validate_m->has_delete_permission()) { $mstrText =$this->indp_mst_data_m->getAllIndpMstDataByCode(EMTSI00003)->row()->MSTR_NM; $this->session->set_flashdata("success", nl2br(wordwrap($mstrText))); redirect('/mydocument/mydocument/?pid='.$this->session->userdata('permission_id'), 'refresh'); } $this->mydocument_m->delete($id); $this->session->set_flashdata("success", "Successfully Deleted Document"); redirect('/mydocument/mydocument/?pid='.$this->session->userdata('permission_id'), 'refresh'); } public function ajaxDepnDropRefId($gvn_RefTypId) { //echo $pvi_TypeId; header('Content-Type: application/x-json; charset=utf-8'); echo(json_encode($this->indp_mst_data_m->getAllIndMstDetailsDropdownByTypeId($gvn_RefTypId))); } public function ajaxDepnDropRefCod($gvn_RefTypCod) { //echo $pvi_TypeId; //header('Content-Type: application/x-json; charset=utf-8'); //echo(json_encode($this->indp_mst_data_m->getAllIndMstDetailsDropdownByTypeId($gvn_RefTypId))); echo $this->indp_mst_data_m->getMasterCode($gvn_RefTypCod); } public function __destruct(){ //destructor code here } } model getColDetails($documentId,'mydocument','DOCUMENT_ID',1,$detail_flag); } function getfilename($documentId,$detail_flag=0) { return $this->getColDetails($documentId,'mydocument','FILE_NAME',1,$detail_flag); } function getparentfolder($documentId,$detail_flag=0) { return $this->getColDetails($documentId,'mydocument','PARENT_FOLDER',1,$detail_flag); } function getassigntoowner($documentId,$detail_flag=0) { return $this->getColDetails($documentId,'mydocument','ASSIGN_TO_OWNER',1,$detail_flag); } function getassigntodepartment($documentId,$detail_flag=0) { return $this->getColDetails($documentId,'mydocument','ASSIGN_TO_DEPARTMENT',1,$detail_flag); } function getcategory($documentId,$detail_flag=0) { return $this->getColDetails($documentId,'mydocument','CATEGORY',1,$detail_flag); } function gethowtoguide($documentId,$detail_flag=0) { return $this->getColDetails($documentId,'mydocument','HOW_TO_GUIDE',1,$detail_flag); } function getproject($documentId,$detail_flag=0) { return $this->getColDetails($documentId,'mydocument','PROJECT',1,$detail_flag); } function getdocumenttype($documentId,$detail_flag=0) { return $this->getColDetails($documentId,'mydocument','DOCUMENT_TYPE',1,$detail_flag); } function getdescription($documentId,$detail_flag=0) { return $this->getColDetails($documentId,'mydocument','DESCRIPTION',1,$detail_flag); } function getcomment($documentId,$detail_flag=0) { return $this->getColDetails($documentId,'mydocument','COMMENT',1,$detail_flag); } } ?>