load->model('purchaseorder_model'); $this->isLoggedIn(); } /** * This function used to load the first screen of the user */ public function index() { $this->global['pageTitle'] = 'Siddharth : AddPO'; $this->loadViews("addPO", $this->global, NULL , NULL); } /** * This function is used to load the purchaseorder list */ function purchaseorderListing() { if($this->isAdmin() == TRUE) { $this->loadThis(); } else { $this->load->model('purchaseorder_model'); $searchText = $this->input->post('searchText'); $data['searchText'] = $searchText; $this->load->library('pagination'); $count = $this->purchaseorder_model->purchaseorderListingCount($searchText); $returns = $this->paginationCompress ( "purchaseorderListing/", $count, 5 ); $data['userRecords'] = $this->purchaseorder_model->purchaseorderListing($searchText, $returns["page"], $returns["segment"]); $this->global['pageTitle'] = 'Siddharth : PO Listing'; $this->loadViews("POlist", $this->global, $data, NULL); } } /** * This function is used to load the add new PO */ function addPO() { if($this->isAdmin() == TRUE) { $this->loadThis(); } else { $this->load->model('purchaseorder_model'); $data['SupplierName'] = $this->purchaseorder_model->getSupplierName(); $data['users'] = $this->purchaseorder_model->getusers(); $this->global['pageTitle'] = 'siddharth : AddNew PO'; $this->loadViews("addPO", $this->global, $data, NULL); } } /** * This function is used to check whether email already exist or not function checkEmailExists() { $userId = $this->input->post("userId"); $email = $this->input->post("email"); if(empty($userId)){ $result = $this->user_model->checkEmailExists($email); } else { $result = $this->user_model->checkEmailExists($email, $userId); } if(empty($result)){ echo("true"); } else { echo("false"); } }*/ /** * This function is used to add new user to the system */ function addNewPO() { if($this->isAdmin() == TRUE) { $this->loadThis(); } else { $this->load->library('form_validation'); $PO = $this->input->post('PO'); $this->form_validation->set_rules('PO_Type','PO Type','trim|required|'); $this->form_validation->set_rules('PO_Date','PO Date','trim|required|'); $this->form_validation->set_rules('SupplierID','SupplierID','trim|required|'); $this->form_validation->set_rules('SpecialOrder','Special Requirement of order','|max_length[20]'); $this->form_validation->set_rules('role','UserID','trim||numeric'); $this->form_validation->set_rules('re_email','Requester email','trim|valid_email|xss_clean|max_length[128]'); $this->form_validation->set_rules('re_phone','Requester ph','required|min_length[10]|xss_clean'); $this->form_validation->set_rules('re_Date','Requested Date','required'); $this->form_validation->set_rules('bug_manager','Budget Manager'); $this->form_validation->set_rules('bud_manager_de','Budget Manager Department','trim'); $this->form_validation->set_rules('Pur_category','Purchasing Category','trim|required'); if($this->form_validation->run() == FALSE) { $this->addPO(); } else { $POType = ucwords(strtolower($this->input->post('PO_Type'))); $PODate = $this->input->post('PO_Date'); $SupplierID = $this->input->post('SupplierID'); $SpecialOrder = $this->input->post('SpecialOrder'); $role = $this->input->post('role'); $re_email = $this->input->post('re_email'); $re_phone = $this->input->post('re_phone'); $re_Date = $this->input->post('re_Date'); $bug_manager = $this->input->post('bug_manager'); $bud_manager_de = $this->input->post('bud_manager_de'); $Pur_category = $this->input->post('Pur_category'); $POInfo = array('POType'=>$POType, 'PODate'=>$PODate, 'SupplierID'=>$SupplierID, 'SpecialOrder'=> $SpecialOrder,'UserID'=>$role,'RequestedDate'=>$re_Date,'RequesterEmail'=>$re_email,'RequesterPh'=>$re_phone, 'PurchasingCategory'=>$Pur_category,'BudgetManager'=>$bug_manager,'BudgetManagerDepartment'=>$bud_manager_de,'createdBy'=>$this->vendorId, 'createdDtm'=>date('Y-m-d H:i:sa')); $this->load->model('purchaseorder_model'); $result = $this->purchaseorder_model->addNewPO($POInfo); if($result > 0) { $this->session->set_flashdata('success', 'New PO created successfully'); } else { $this->session->set_flashdata('error', 'PO Not Create'); } redirect('addPO'); } } } /** * This function is used load user edit information * @param number $userId : Optional : This is user id */ function editOldPO($PO = NULL) { if($this->isAdmin() == TRUE || $PO == 1) { $this->loadThis(); } else { if($PO == null) { redirect('purchaseorderListing'); } $data['SupplierName'] = $this->purchaseorder_model->getSupplierName(); $data['users'] = $this->purchaseorder_model->getusers(); $this->global['pageTitle'] = 'Siddharth : Edit User'; $this->loadViews("editOldPO", $this->global, $data, NULL); } } /** * This function is used to edit the user information */ function editPO() { if($this->isAdmin() == TRUE) { $this->loadThis(); } else { $this->load->library('form_validation'); $PO = $this->input->post('PO'); $this->form_validation->set_rules('POType','PO Type','trim|required|'); $this->form_validation->set_rules('PODate','PO Date','trim|required|'); $this->form_validation->set_rules('SupplierID','SupplierID','trim|required|'); $this->form_validation->set_rules('SpecialOrder','Special Requirement of order','|max_length[20]'); $this->form_validation->set_rules('role','UserID','trim||numeric'); $this->form_validation->set_rules('reemail','Requester email','trim|valid_email|xss_clean|max_length[128]'); $this->form_validation->set_rules('rephone','Requester ph','required|min_length[10]|xss_clean'); $this->form_validation->set_rules('reDate','Requested Date','required'); $this->form_validation->set_rules('budmanager','Budget Manager'); $this->form_validation->set_rules('budmanagerde','Budget Manager Department','trim'); $this->form_validation->set_rules('PurchasingCategory','Purchasing Category','trim'); if($this->form_validation->run() == FALSE) { $this->editPO(); } else { $POType = ucwords(strtolower($this->input->post('POType'))); $PODate = $this->input->post('PODate'); $SupplierID = $this->input->post('SupplierID'); $SpecialOrder = $this->input->post('SpecialOrder'); $role = $this->input->post('role'); $reemail = $this->input->post('reemail'); $rephone = $this->input->post('rephone'); $reDate = $this->input->post('reDate'); $budmanager = $this->input->post('budmanager'); $budmanagerde = $this->input->post('budmanagerde'); $Purcategory = $this->input->post('PurchasingCategory'); $POInfo = array('POType'=>$POType, 'PODate'=>$PODate, 'SupplierID'=>$SupplierID, 'SpecialOrder'=> $SpecialOrder,'UserID'=>$role,'RequestedDate'=>$reDate,'RequesterEmail'=>$reemail,'RequesterPh'=>$rephone, 'PurchasingCategory'=>$Purcategory,'BudgetManager'=>$budmanager,'BudgetManagerDepartment'=>$budmanagerde,'createdBy'=>$this->vendorId, 'createdDtm'=>date('Y-m-d H:i:sa')); $POInfo = array(); $result = $this->purchaseorder_model->editPO($POInfo, $PO); if($result == true) { $this->session->set_flashdata('success', 'PO updated successfully'); } else { $this->session->set_flashdata('error', 'PO updation failed'); } redirect('purchaseorderListing'); } } } /** * This function is used to delete the user using userId * @return boolean $result : TRUE / FALSE function deleteUser() { if($this->isAdmin() == TRUE) { echo(json_encode(array('status'=>'access'))); } else { $userId = $this->input->post('userId'); $userInfo = array('isDeleted'=>1,'updatedBy'=>$this->vendorId, 'updatedDtm'=>date('Y-m-d H:i:sa')); $result = $this->user_model->deleteUser($userId, $userInfo); if ($result > 0) { echo(json_encode(array('status'=>TRUE))); } else { echo(json_encode(array('status'=>FALSE))); } } }*/ function pageNotFound() { $this->global['pageTitle'] = 'CodeInsect : 404 - Page Not Found'; $this->loadViews("404", $this->global, NULL, NULL); } } ?>