class Home extends MY_Controller { public function __construct() { parent::__construct(); $this->menu = "setting"; $this->load->database(); $this->load->helper(array("url")); date_default_timezone_set("Asia/Kabul"); $this->load->library(array("form_validation", "session")); $this->load->model(array("get_public_data", "setting_model")); if ($this->authentication->login()) { } else { redirect(base_url() . "home/login"); } } public function index() { $this->menu = "setting_acount"; $user_id = $this->session->userdata("user_id"); $data["user"] = $this->get_public_data->get_all_data("users", array("user_id" => $user_id)); $this->render("settings/user/user-profile", $data); } public function add_user() { $data = array("user_name" => $this->input->post("username"), "name" => $this->input->post("name"), "password" => md5($this->input->post("password")), "rule_id" => $this->input->post("rule"), "email" => $this->input->post("email")); if ($this->input->post("staff")) { $data["persen_id"] = $this->input->post("staff"); } if ($this->input->post("ashkhas")) { $data["persen_id"] = $this->input->post("ashkhas"); } if ($this->input->post("memo")) { $data["memo"] = $this->input->post("memo"); } if ($this->input->post("time")) { $data["time_id"] = $this->input->post("time"); } $insert = $this->setting_model->add_user($data); if ($insert) { $this->session->set_flashdata("success", "<div class="alert alert-success" style="margin:10px">
<button type="button" class="close" data-dismiss="alert" aria-hidden="true"></button>\xa یک یوزر موفقانه اضافه شد.</div>"); redirect(base_url() . "setting/home/user_list"); } else { $this->session->set_flashdata("success", "<div class="alert alert-warning" style="margin:px">\xa <button type="button" class="close" data-dismiss="alert" aria-hidden="true"></button>
متاسفانه یوزر اضافه نشد دوباره سعی کنید...</div>"); redirect(base_url() . "setting/home/user_list"); } } public function user_list() { $this->sub_menu = "user_list"; $where = array("is_supper" => 0); $users = $this->setting_model->user_list($where); for ($i = 0; $i < count($users); $i++) { $users[$i]["staff_id"] = $this->get_public_data->get_id("staff", array("s_id" => $users[$i]["persen_id"]), "staff_id"); $users[$i]["fname"] = $this->get_public_data->get_id("staff", array("s_id" => $users[$i]["persen_id"]), "f_name"); $users[$i]["lname"] = $this->get_public_data->get_id("staff", array("s_id" => $users[$i]["persen_id"]), "l_name"); $users[$i]["full_name"] = $users[$i]["fname"] . " " . $users[$i]["lname"]; } $data["users"] = $users; $data["rules"] = $this->get_public_data->get_all_data("access_rule"); $data["staff"] = $this->get_public_data->get_all_data("staff", array("state" => 1)); $this->render("settings/user/user_list", $data); } public function edit_user() { if ($this->input->post("identity")) { $id = $this->input->post("identity"); $data["identity"] = $id; $user = $this->get_public_data->get_all_data("users", array("user_id" => $id)); if (count($user) > 0) { $data["rule"] = $this->get_public_data->get_all_data("access_rule", array("group_id" => 1)); $data["user"] = $user; $this->load->view("settings/user/edit_user", $data); } } } public function update_user_admin() { $user_id = $this->input->post("user_id"); $data = array("user_name" => $this->input->post("username"), "user_state" => $this->input->post("state"), "email" => $this->input->post("email"), "user_state" => $this->input->post("user_state")); if ($this->input->post("password")) { $data["password"] = md5($this->input->post("password")); } if ($this->input->post("rule")) { $data["rule_id"] = $this->input->post("rule"); } $update = $this->setting_model->update_user($data, $user_id); if ($update) { $this->session->set_flashdata("success", "<div class="alert alert-success" style="margin:10px">\xa <button type="button" class="close" data-dismiss="alert" aria-hidden="true"></button>
user successfully updated.</div>"); redirect("setting/home/user_list"); } else { $this->session->set_flashdata("success", "<div class="alert alert-warning" style="margin:px">\xa <button type="button" class="close" data-dismiss="alert" aria-hidden="true"></button>\xa Sorry the user dose not update please try again!...</div>"); redirect("setting/home/user_list"); } } public function update_user() { $user_id = $this->input->post("user_id"); $data = array("name" => $this->input->post("name"), "email" => $this->input->post("email")); if ($this->input->post("password")) { $data["password"] = md5($this->input->post("password")); } if ($this->input->post("rule")) { $data["rule_id"] = $this->input->post("rule"); } $update = $this->setting_model->update_user($data, $user_id); if ($update) { $this->session->set_flashdata("success", "<div class="alert alert-success" style="margin0px">\xa <button type="button" class="close" data-dismiss="alert" aria-hidden="true"></button>
موفقانه ویرایش شد.</div>"); redirect("setting/home/index"); } else { $this->session->set_flashdata("success", "<div class="alert alert-warning" style="margin:10px">\xa <button type="button" class="close" data-dismiss="alert" aria-hidden="true"></button>
Sorry the user dose not update please try again!...</div>"); redirect("setting/home/index"); } } public function delete() { $data["id"] = $this->input->post("identity"); $this->load->view("settings/user/delete", $data); } public function do_delete() { $id = $this->input->post("id"); $where = array("user_id" => $id); $result = $this->get_public_data->delete("users", $where); redirect("setting/home/user_list"); } public function department($parameter = '') { $this->sub_menu = "department"; $data["department"] = $this->setting_model->get_department(); $data["section"] = $this->get_public_data->get_all_data("sections", array("section_id >" => 1)); if ($parameter == "add") { $value = array("dep_name" => $this->input->post("dep_name"), "en_dep_name" => $this->input->post("dep_name_en"), "dep_fees" => $this->input->post("dep_fees")); $result = $this->get_public_data->add("department", $value); if ($result) { $this->session->set_flashdata("msg", "<div class="alert alert-success"><button type="button" class="close" data-dismiss="alert">×</button><strong>موفقیت</strong> دیپارتمنت ازافه شد.</div>"); } else { $this->session->set_flashdata("msg", "<div class="alert alert-danger"><button type="button" class="close" data-dismiss="alert">×</button><strong>خطا</strong> دیپارتمنت ازافه نشد!</div>"); } redirect("setting/home/department"); } elseif ($parameter == "edit") { $id = $this->input->post("identity"); $data["department"] = $this->setting_model->get_one_department($id); $this->load->view("settings/department/edit", $data); } elseif ($parameter == "update") { $value = array("dep_name" => $this->input->post("dep_name"), "en_dep_name" => $this->input->post("dep_name_en"), "dep_fees" => $this->input->post("dep_fees")); $id = $this->input->post("id"); $where = array("dep_id" => $id); $result = $this->get_public_data->update("department", $value, $where); if ($result) { $this->session->set_flashdata("msg", "<div class="alert alert-success"><button type="button" class="close" data-dismiss="alert">×</button><strong>موفقیت</strong> دیپارتمنت ویرایش شد.</div>"); } else { $this->session->set_flashdata("msg", "<div class="alert alert-danger"><button type="button" class="close" data-dismiss="alert">×</button><strong>خطا</strong> دیپارتمنت ویرایش نشد!</div>"); } redirect("setting/home/department"); } elseif ($parameter == "delete") { $data["id"] = $this->input->post("identity"); $result = $this->get_public_data->get_all_data("staff", array("dep_id" => $data["id"])); if (count($result) > 0) { echo "<p class="alert alert-danger">این مورد را شما حذف نمی توانید، زیرا استفاده شده است.</p>"; } else { $this->load->view("settings/department/delete", $data); } } elseif ($parameter == "do_delete") { $id = $this->input->post("id"); $where = array("dep_id" => $id); $result = $this->get_public_data->delete("department", $where); if ($result) { $this->session->set_flashdata("msg", "<div class="alert alert-success"><button type="button" class="close" data-dismiss="alert">×</button><strong>موفقیت</strong> دیپارتمنت حذف شد.</div>"); } else { $this->session->set_flashdata("msg", "<div class="alert alert-danger"><button type="button" class="close" data-dismiss="alert">×</button><strong>خطا</strong> دیپارتمنت حذف نشد!</div>"); } redirect("setting/home/department"); } else { $this->render("settings/department/department_list", $data); } } public function section($parameter = '') { $this->sub_menu = "section"; $sections = $this->get_public_data->get_all_data("sections"); for ($i = 0; $i < count($sections); $i++) { $sections[$i]["category_name"] = $this->get_public_data->get_id("income_category", array("inc_category_id" => $sections[$i]["category_id"]), "in_category_name"); } $data["section"] = $sections; $data["category"] = $this->get_public_data->get_all_data("income_category"); if ($parameter == "add") { $data = array("section_name" => $this->input->post("dari_name"), "en_section_name" => $this->input->post("en_name"), "category_id" => $this->input->post("category")); $result = $this->get_public_data->add("sections", $data); if ($result) { $this->session->set_flashdata("msg", "<div class="alert alert-success"><button type="button" class="close" data-dismiss="alert">×</button><strong>موفقیت</strong> بخش ازافه شد.</div>"); } else { $this->session->set_flashdata("msg", "<div class="alert alert-danger"><button type="button" class="close" data-dismiss="alert">×</button><strong>خطا</strong> بخش ازافه نشد !</div>"); } redirect("setting/home/section"); } elseif ($parameter == "edit") { $id = $this->input->post("identity"); $data["section"] = $this->setting_model->get_one_section($id); $this->load->view("settings/section/edit", $data); } elseif ($parameter == "update") { $id = $this->input->post("id"); $value = array("section_name" => $this->input->post("dari_name"), "en_section_name" => $this->input->post("en_name"), "category_id" => $this->input->post("category")); $where = array("section_id" => $id); $result = $this->get_public_data->update("sections", $value, $where); if ($result) { $this->session->set_flashdata("msg", "<div class="alert alert-success"><button type="button" class="close" data-dismiss="alert">×</button><strong>موفقیت</strong> بخش ویرایش شد.</div>"); } else { $this->session->set_flashdata("msg", "<div class="alert alert-danger"><button type="button" class="close" data-dismiss="alert">×</button><strong>خطا</strong> بخش ویرایش نشد!</div>"); } redirect("setting/home/section"); } elseif ($parameter == "delete") { $data["id"] = $this->input->post("identity"); $this->load->view("settings/section/delete", $data); } elseif ($parameter == "do_delete") { $id = $this->input->post("id"); $where = array("section_id" => $id); $result = $this->get_public_data->delete("sections", $where); if ($result) { $this->session->set_flashdata("msg", "<div class="alert alert-success"><button type="button" class="close" data-dismiss="alert">×</button><strong>موفقیت</strong> بخش حذف شد.</div>"); } else { $this->session->set_flashdata("msg", "<div class="alert alert-danger"><button type="button" class="close" data-dismiss="alert">×</button><strong>خطا</strong> بخش حذف نشد!</div>"); } redirect("setting/home/section"); } else { $this->render("settings/section/section_list", $data); } } public function timeStartEndSetting($parameter = '') { $this->sub_menu = "tset"; $data["records"] = $this->get_public_data->get_all_data("time_start_end"); if ($parameter == "add") { $data = array("start" => $this->input->post("start"), "end" => $this->input->post("end"), "memo" => $this->input->post("memo")); $result = $this->get_public_data->add("time_start_end", $data); if ($result) { $this->session->set_flashdata("msg", "<div class="alert alert-success"><button type="button" class="close" data-dismiss="alert">×</button><strong>موفقیت</strong> بخش ازافه شد.</div>"); } else { $this->session->set_flashdata("msg", "<div class="alert alert-danger"><button type="button" class="close" data-dismiss="alert">×</button><strong>خطا</strong> بخش ازافه نشد !</div>"); } redirect("setting/home/timeStartEndSetting"); } elseif ($parameter == "edit") { $id = $this->input->post("identity"); $data["record"] = $this->get_public_data->get_all_data("time_start_end", array("id" => $id)); $this->load->view("hr/tset/edit", $data); } elseif ($parameter == "update") { $id = $this->input->post("identity"); $value = array("start" => $this->input->post("start"), "end" => $this->input->post("end"), "end_extra" => $this->input->post("end_extra"), "memo" => $this->input->post("memo")); $where = array("id" => $id); $result = $this->get_public_data->update("time_start_end", $value, $where); if ($result) { $this->session->set_flashdata("msg", "<div class="alert alert-success"><button type="button" class="close" data-dismiss="alert">×</button><strong>موفقیت</strong> بخش ویرایش شد.</div>"); } else { $this->session->set_flashdata("msg", "<div class="alert alert-danger"><button type="button" class="close" data-dismiss="alert">×</button><strong>خطا</strong> بخش ویرایش نشد!</div>"); } redirect("setting/home/timeStartEndSetting"); } elseif ($parameter == "delete") { $data["id"] = $this->input->post("identity"); $this->load->view("hr/home/delete", $data); } elseif ($parameter == "do_delete") { $id = $this->input->post("id"); $where = array("id" => $id); $result = $this->get_public_data->delete("time_start_end", $where); if ($result) { $this->session->set_flashdata("msg", "<div class="alert alert-success"><button type="button" class="close" data-dismiss="alert">×</button><strong>موفقیت</strong> بخش حذف شد.</div>"); } else { $this->session->set_flashdata("msg", "<div class="alert alert-danger"><button type="button" class="close" data-dismiss="alert">×</button><strong>خطا</strong> بخش حذف نشد!</div>"); } redirect("setting/home/timeStartEndSetting"); } else { $this->render("hr/tset/time-start-end-setting", $data); } } }
© 2023 Quttera Ltd. All rights reserved.