PHP codeigniter如何当前用户创建一些模块,而当前用户模块仅显示当前用户和管理员

时间:2019-04-04 12:35:39

标签: php

我正在用PHP(Codeigniter Framework)开发医学检验实验室软件,管理员将医学检验发送到每个实验室,每个实验室成员都给出有关管理员医学检验的结果。实验室成员提供测试机的详细信息,结果输入和打印结果pdf选项,然后在结果后接受管理员

我的问题是当前用户如何创建实验室详细信息,实验室测试,实验室结果,而这些详细信息仅显示当前用户和管理员。

已经完成了管理功能,我只需要当前用户创建测试机详细信息,结果等...

类用户扩展了CI_Controller {

private $user = null;

function __construct()
{
    parent::__construct();
    $this->load->library('session');
    $this->load->helper(array('form', 'url'));
    $this->load->model('credential_model');
    $this->load->model('common_model');
    $this->load->model('user_model');

    if(isset($this->session->userdata["user_id"])){
        $s = array(
            'id' => $this->session->userdata["user_id"]
        );
        $this->user = $this->common_model->get_rows_with_condition('user',$s);
    }
}

public function index()
{
    $data["user"] = $this->user;
    $data['schemes'] = $this->common_model->get_rows_without_condition('schemes');
    $this->load->view('user/include/header');
    $this->load->view('user/include/page_header');
    $this->load->view('user/include/sidebar',$data);
    $this->load->view('user/dashboard');
    $this->load->view('user/include/page_footer');
    $this->load->view('user/include/footer');

}

public function notification()
{

    $data["user"] = $this->user;
    $data['schemes'] = $this->common_model->get_rows_without_condition("schemes");
    $data['notification'] = $this->common_model->get_rows_without_condition('notification');
    $this->load->view('user/include/header');
    $this->load->view('user/include/page_header');
    $this->load->view('user/include/sidebar',$data);
    $this->load->view('user/notification');
    $this->load->view('user/include/page_footer');
    $this->load->view('user/include/footer');

}
    // ****************sendmedhology****************************
public function sendmedhology($user_id = NULL)
{       
        $data["user"] = $this->user;
        $data['schemes'] = $this->common_model->get_rows_without_condition("schemes");
        $sendmedhology['schemes'] = $this->common_model->get_rows_without_condition("schemes");
        $user_id = $this->session->userdata["user_id"];
        $sendmedhology['create_tests'] = $this->common_model->get_rows_without_condition("create_tests");

        $sendmedhology['sendmedhology'] = $this->user_model->getsendmedhology($user_id);
        $this->load->view('user/include/header');
        $this->load->view('user/include/page_header');
        $this->load->view('user/include/sidebar',$data);
        $this->load->view('user/sendmedhology_list',$sendmedhology);
        $this->load->view('user/include/page_footer');
        $this->load->view('user/include/footer');
}

public function info($id = null)
{
    if (!empty($id)) {
        $data["user"] = $this->user;
        $data['schemes'] = $this->common_model->get_rows_without_condition("schemes");
        $r = array("id" => $id);
        $sendmedhology['edit_sendmedhology'] = $this->common_model->get_rows_with_condition("sendmedhology", $r);
        $sendmedhology['schemes'] = $this->common_model->get_rows_without_condition("schemes");
        $sendmedhology['user'] = $this->common_model->get_rows_without_condition("user");
        $sendmedhology['create_test'] = $this->common_model->get_rows_without_condition("create_tests");
        $this->load->view('user/include/header');
        $this->load->view('user/include/page_header');
        $this->load->view('user/include/sidebar',$data);
        $this->load->view('user/info',$sendmedhology);
        $this->load->view('user/include/page_footer');
        $this->load->view('user/include/footer');
    } else {
        redirect("user/sendmedhology_list");
    }
}

    // ****************sendmedhology****************************


public function files()
{
    $this->load->model('common_model');

    $data['picture_list'] = $this->common_model->get_all_pics();

    $data["user"] = $this->user;
    $data['schemes'] = $this->common_model->get_rows_without_condition("schemes");
    $data['notification'] = $this->common_model->get_rows_without_condition('notification');
    $this->load->view('user/include/header');
    $this->load->view('user/include/page_header');
    $this->load->view('user/include/sidebar',$data);
    $this->load->view('user/files');
    $this->load->view('user/include/page_footer');
    $this->load->view('user/include/footer');
}

public function details_notification($id = null)
{
    $data["user"] = $this->user;
    $data['schemes'] = $this->common_model->get_rows_without_condition("schemes");
    $r = array("id" => $id);
        $details_notification['details_notification'] = $this->common_model->get_rows_with_condition("notification", $r);
    $this->load->view('user/include/header');
    $this->load->view('user/include/page_header');
    $this->load->view('user/include/sidebar',$data);
    $this->load->view('user/details_notification', $details_notification);
    $this->load->view('user/include/page_footer');
    $this->load->view('user/include/footer');

}

public function selecttest($id = NULL)
{
    if($id != NULL){
        $data["user"] = $this->user;
        $data['schemes'] = $this->common_model->get_rows_without_condition('schemes');
        $s= array("id"=>$id);
        $data['scheme'] = $this->common_model->get_rows_with_condition('schemes', $s);
        $tests['tests'] = $this->user_model->gettests($id);
        $this->load->view('user/include/header');
        $this->load->view('user/include/page_header');
        $this->load->view('user/include/sidebar',$data);
        $this->load->view('user/select_tests',$tests);
        $this->load->view('user/include/page_footer');
        $this->load->view('user/include/footer');
    }else{
        redirect("user");
    }
}

public function createtest($id)
{
    $form_data=$_POST;
    $test = implode(",",$_POST['tests']);
    $test_name = implode(",",$_POST['tests_name']);
    unset($_POST['tests']);
    unset($_POST['tests_name']);
    $form_data['reciept_no'] = time(); 
    $form_data['tests'] = $test;
    $form_data['tests_name'] = $test_name;
    $form_data['scheme'] = $id;
    $data['msg_added']=$this->common_model->insert("create_tests",$form_data);
    $this->session->set_flashdata("msg_added",$data['msg_added']);
    redirect('user/viewtest/'.$id);
}

public function edittest($scheme = NULL,$id = NULL)
{
    if($id != NULL && $id != NULL){
        $data["user"] = $this->user;
        $data['schemes'] = $this->common_model->get_rows_without_condition('schemes');
        $s= array("id"=>$scheme);
        $tests['scheme'] = $this->common_model->get_rows_with_condition('schemes',$s);
        $t= array("id"=>$id);
        $tests['create_tests'] = $this->common_model->get_rows_with_condition('create_tests',$t);
        $tests['tests'] = $this->user_model->gettests($scheme);
        $this->load->view('user/include/header');
        $this->load->view('user/include/page_header');
        $this->load->view('user/include/sidebar',$data);
        $this->load->view('user/edit_tests',$tests);
        $this->load->view('user/include/page_footer');
        $this->load->view('user/include/footer');
    }else{
        redirect("user");
    }
}

public function updatetest($scheme,$id)
{
    $form_data=$_POST;
    $test = implode(",",$_POST['tests']);
    $test_name = implode(",",$_POST['tests_name']);
    unset($_POST['tests']);
    unset($_POST['tests_name']);
    $form_data['reciept_no'] = time(); 
    $form_data['tests'] = $test;
    $form_data['tests_name'] = $test_name;
    $data['msg_added']=$this->common_model->update_where("create_tests",'id',$form_data,$id);
    $this->session->set_flashdata("msg_added",$data['msg_added']);
    redirect('user/edittest/'.$scheme."/".$id);
}

public function makepayments($id = NULL)
{
    if($id != NUll){
        $data['schemes'] = $this->common_model->get_rows_without_condition("schemes");
        $data["user"] = $this->user;
        $cond = array("paid_status"=> 0,
                        "id"=> $id);
        $make_pay['create_tests'] = $this->common_model->get_rows_with_condition("create_tests",$cond);
        $this->load->view('user/include/header');
        $this->load->view('user/include/page_header');
        $this->load->view('user/include/sidebar',$data);
        $this->load->view('user/make_payments',$make_pay);
        $this->load->view('user/include/page_footer');
        $this->load->view('user/include/footer');
    }else{
        redirect("user");
    }

}

public function payment_add($id)
{   
    $formdata['user_id'] = $this->session->userdata["user_id"];
    $formdata['create_test_id'] = $id;
    $formdata["payment_date"]=$_POST["payemnt_date"];
    $create_data['paid_status'] = "1";
    $formdata["utr_neft"] = $_POST["utr_neft"];
    $reciept_no = $_POST["reciept_no"];
    unset($_POST["reciept_no"]);
    if(!empty($_FILES["neft_challan_wire_copy"]["name"]) || !empty($_POST["utr_neft"])){
        if(!empty($_FILES["neft_challan_wire_copy"]["name"]))
        {
            $file_name=rand().time().$_FILES["neft_challan_wire_copy"]["name"];
            if(move_uploaded_file($_FILES["neft_challan_wire_copy"]["tmp_name"],"assets/uploaded_files/".$file_name))
            {
                $formdata["neft_challan_wire_copy"]=$file_name;
            }
        }
        $table_name='payments';
        $this->user_model->insert($table_name,$formdata);
        $this->common_model->update_where("create_tests",'id',$create_data,$id);

        $from_email = "admin@iammeqascmc.org"; 
        $to_email = $this->session->userdata["email"]; //$this->input->post('email'); 
        $msg = '<html><body>Thank you pay against reciept no. <b>'.$reciept_no.'</b> to IAMM EQAS CMC Microbiology !!!. <br><br> Print your reciept. <br><br> Click here . '.base_url().'credential/login</body></html>';
        $this->email->set_mailtype("html");
        $this->email->from($from_email, 'IAMM EQAS CMC Microbiology'); 
        $this->email->to($to_email);
        $this->email->subject('Welcome to IAMM EQAS CMC Microbiology!!!'); 
        $this->email->message($msg); 

        //Send mail 
        if($this->email->send()) 

        $this->session->set_flashdata("msg_added","Successfully submitted...");
        redirect('user/viewpaymentdetails');
    }else{
        $this->session->set_flashdata("error_msg","Payment Ref or Upload payment reference is required !!!");
        redirect('user/makepayments/'.$id);
    }   
}


public function viewpaymentdetails()
{
    $data["user"] = $this->user;
    $data['schemes'] = $this->common_model->get_rows_without_condition('schemes');
    $payments['payments'] = $this->user_model->getpayments();
    $this->load->view('user/include/header');
    $this->load->view('user/include/page_header');
    $this->load->view('user/include/sidebar',$data);
    $this->load->view('user/view_payment_details',$payments);
    $this->load->view('user/include/page_footer');
    $this->load->view('user/include/footer');
}


public function viewtest($id = NULL)
{
    if($id != NULL){
        $data['schemes'] = $this->common_model->get_rows_without_condition("schemes");
        $data["user"] = $this->user;
        $s = array("id" => $id);
        $test['scheme'] = $this->common_model->get_rows_with_condition("schemes", $s);
        $s = array("id" => $id);
        $user_id = $this->session->userdata["user_id"];
        $ct = array("scheme" => $id,"user_id"=> $user_id);
        $test['tests'] = $this->common_model->get_rows_with_condition("create_tests", $ct);
        $t = array("scheme" => $id);
        $test['test_d'] = $this->common_model->get_rows_with_condition("tests", $t);
        $this->load->view('user/include/header');
        $this->load->view('user/include/page_header');
        $this->load->view('user/include/sidebar',$data);
        $this->load->view('user/view_tests',$test);
        $this->load->view('user/include/page_footer');
        $this->load->view('user/include/footer');
    }else{
        redirect("user");
    }
}


public function reciept($id = NULL)
{
    if($id != NULL){
        $data['schemes'] = $this->common_model->get_rows_without_condition("schemes");
        $data["user"] = $this->user;
        $t = array("id" => $id);
        $test['test'] = $this->common_model->get_rows_with_condition("create_tests", $t);
        $test['test_d'] = $this->common_model->get_rows_without_condition("tests");
        $this->load->view('user/include/header');
        $this->load->view('user/include/page_header');
        $this->load->view('user/include/sidebar',$data);
        $this->load->view('user/reciept',$test);
        $this->load->view('user/include/page_footer');
        $this->load->view('user/include/footer');
    }else{
        redirect("user");
    }
}

public function changepassword()
{
    $data['schemes'] = $this->common_model->get_rows_without_condition("schemes");
    $data["user"] = $this->user;
    $this->load->view('user/include/header');
    $this->load->view('user/include/page_header');
    $this->load->view('user/include/sidebar',$data);
    $this->load->view('user/change_password');
    $this->load->view('user/include/page_footer');
    $this->load->view('user/include/footer');
}       


public function update_password()
{
    $id=$this->session->userdata["user_id"];
    $data=$_POST;
    $tbl_name='login';
    $where='user_id';
    $data['msg_added']=$this->common_model->update_where($tbl_name, $where, $data, $id);
    $this->session->set_flashdata("msg_added",$data['msg_added']);
    redirect("user/changepassword");
}

public function editprofile()
{
    $data['schemes'] = $this->common_model->get_rows_without_condition("schemes");
    $data["user"] = $this->user;
    $user_id=$this->session->userdata["user_id"];
    $c = array("user_id"=> $user_id);
    $data['contact_persons'] = $this->common_model->get_rows_with_condition("contact_person_details",$c);
    $data["edit_user"] = $this->user_model->get_rows_profile($user_id);
    $this->load->view('user/include/header');
    $this->load->view('user/include/page_header');
    $this->load->view('user/include/sidebar',$data);
    $this->load->view('user/edit_profile');
    $this->load->view('user/include/page_footer');
    $this->load->view('user/include/footer');
}

public function update_profile($id)
{
    $qc_program_tier1='';
    if(isset($_POST["qc_program_tier1"]))
    {
        $qc_program_tier1=$_POST["qc_program_tier1"];
    }

    $qc_program_tier2='';
    if(isset($_POST["qc_program_tier2"]))
    {
        $qc_program_tier2=$_POST["qc_program_tier2"];
    }

    $qc_program_tier3='';
    if(isset($_POST["qc_program_tier3"]))
    {
        $qc_program_tier3=$_POST["qc_program_tier3"];
    }

    $private_medical_college='';
    if(isset($_POST["private_medical_college"]))
    {
        $private_medical_college=$_POST["private_medical_college"];
    }

    $government_medical_college='';
    if(isset($_POST["government_medical_college"]))
    {
        $government_medical_college=$_POST["government_medical_college"];
    }

    $government_hospital_laboratory='';
    if(isset($_POST["government_hospital_laboratory"]))
    {
        $government_hospital_laboratory=$_POST["government_hospital_laboratory"];
    }

    $private_laboratory='';
    if(isset($_POST["private_laboratory"]))
    {
        $private_laboratory=$_POST["private_laboratory"];
    }

    $private_hospital='';
    if(isset($_POST["private_hospital"]))
    {
        $private_hospital=$_POST["private_hospital"];
    }

    $registered_mail='';
    if(isset($_POST["registered_mail"]))
    {
        $registered_mail=$_POST["registered_mail"];
    }

    $speed_post='';
    if(isset($_POST["speed_post"]))
    {
        $speed_post=$_POST["speed_post"];
    }

    $courier='';
    if(isset($_POST["courier"]))
    {
        $courier=$_POST["courier"];
    }

    $dtdc='';
    if(isset($_POST["dtdc"]))
    {
        $dtdc=$_POST["dtdc"];
    }
    $professional='';
    if(isset($_POST["professional"]))
    {
        $professional=$_POST["professional"];
    }
    $trackon='';
    if(isset($_POST["trackon"]))
    {
        $trackon=$_POST["trackon"];
    }

    $user_data = array(
        "name" => $_POST["name"],
        "email" => $_POST["email"],
        "institution" => $_POST["institution"],
        "position"  => $_POST["position"],
        "mobile_no" => $_POST["mobile_no"],
        "previous_member_id" => $_POST["previous_member_id"],
        "bed_strength" => $_POST["bed_strength"],
        "out_patient" => $_POST["out_patient"],
        "hospital" => $_POST["hospital"],
        "department" => $_POST["department"],
        "postal_address" => $_POST["postal_address"],
        "city" => $_POST["city"],
        "pin_code"  => $_POST["pin_code"],
        "district" => $_POST["district"],
        "state" => $_POST["state"],
        "private_medical_college" =>  ($private_medical_college != "" ) ? $private_medical_college :"No",
        "government_medical_college" =>  ($government_medical_college != "" ) ? $government_medical_college :"No",
        "government_hospital_laboratory" =>  ($government_hospital_laboratory != "" ) ? $government_hospital_laboratory :"No",
        "private_laboratory" =>  ($private_laboratory != "" ) ? $private_laboratory :"No",
        "private_hospital"  =>  ($private_hospital != "" ) ? $private_hospital :"No",
        "registered_mail" =>  ($registered_mail != "" ) ? $registered_mail :"No",
        "speed_post" =>  ($speed_post != "" ) ? $speed_post :"No",
        "courier" =>  ($courier != "" ) ? $courier :"No",
        "dtdc" =>  ($dtdc != "" ) ? $dtdc :"No",
        "professional" =>  ($professional != "" ) ? $professional :"No",
        "trackon" =>  ($trackon != "" ) ? $trackon :"No",
        "qc_program_tier1" => ($qc_program_tier1 != "" ) ? $qc_program_tier1 :"No",
        "qc_program_tier2" => ($qc_program_tier2 != "" ) ? $qc_program_tier2 :"No",
        "qc_program_tier3" => ($qc_program_tier3 != "" ) ? $qc_program_tier3 :"No"
    );

    $this->common_model->update_where('user','id',$user_data,$id);

    $login_data = array(
        "email" => $_POST["email"]
    );

    $this->common_model->update_where('login','user_id',$login_data,$id);

    $laboratory_data = array(
        "bacteriology_microscopy" => $_POST['bacteriology_microscopy'],
        "bacteriology_microscopy_samples" => $_POST['bacteriology_microscopy_samples'],
        "bacteriology_culture" => $_POST['bacteriology_culture'],
        "bacteriology_culture_samples" => $_POST['bacteriology_culture_samples'],
        "bacteriology_susceptibility" => $_POST['bacteriology_susceptibility'],
        "bacteriology_susceptibility_samples" => $_POST['bacteriology_susceptibility_samples'],
        "mycobacteriology_microscopy" => $_POST['mycobacteriology_microscopy'],
        "mycobacteriology_microscopy_samples" => $_POST['mycobacteriology_microscopy_samples'],
        "mycobacteriology_culture" => $_POST['mycobacteriology_culture'],
        "mycobacteriology_culture_samples" => $_POST['mycobacteriology_culture_samples'],
        "mycobacteriology_susceptibility" => $_POST['mycobacteriology_susceptibility'],
        "mycobacteriology_susceptibility_samples" => $_POST['mycobacteriology_susceptibility_samples'],
        "mycology_microscopy" => $_POST['mycology_microscopy'],
        "mycology_microscopy_samples" => $_POST['mycology_microscopy_samples'],
        "mycology_culture" => $_POST['mycology_culture'],
        "mycology_culture_samples" => $_POST['mycology_culture_samples'],
        "mycology_susceptibility" => $_POST['mycology_susceptibility'],
        "mycology_susceptibility_samples" => $_POST['mycology_susceptibility_samples'],
        "serology" => $_POST['serology'],
        "serology_samples" => $_POST['serology_samples']
    );

    $this->common_model->update_where('laboratory_details','user_id',$laboratory_data,$id);

    $cp_id = $_POST['cp_id'];
    $cp_name = $_POST["cp_name"];
    $cp_mobile_no = $_POST["cp_mobile_no"];
    $cp_email = $_POST["cp_email"];
    $c_p = array();
    $j=0;
    for($i= 0; $i < count($cp_id); $i++,$j++){
            $contact_person = array(
                "id" => $cp_id[$i],
                "cp_name" => $cp_name[$i],
                "cp_mobile_no" => $cp_mobile_no[$i],
                "cp_email" => $cp_email[$i]
            );
            $this->common_model->update_where('contact_person_details','id',$contact_person,$cp_id[$i]);
        }
    for($k= $j; $k < count($cp_name); $k++){
        if(!empty($cp_name[$i]) || !empty($cp_mobile_no[$i]) || !empty($cp_email[$i])){
        $contact_person_new = array(
            "user_id" => $id,
            "cp_name" => $cp_name[$i],
            "cp_mobile_no" => $cp_mobile_no[$i],
            "cp_email" => $cp_email[$i]
        );
    }
        array_push($c_p,$contact_person_new);
    }


    if(count($c_p)!= 0 ){
        $this->common_model->insert_batch("contact_person_details",$c_p);
    }
    $this->session->set_flashdata("msg_added",'Successfully Updated...');
    redirect("/user/editprofile");
}

// **************************Kit Methods**************************
public function kitmethods($user_id = NULL)
{

    $data["user"] = $this->user;
    $data['schemes'] = $this->common_model->get_rows_without_condition("schemes");
    $data['kitmethods'] = $this->common_model->get_rows_without_condition('kitmethods');
    $this->load->view('user/include/header');
    $this->load->view('user/include/page_header');
    $this->load->view('user/include/sidebar',$data);
    $this->load->view('user/kitmethods');
    $this->load->view('user/include/page_footer');
    $this->load->view('user/include/footer');

}

public function editkitmethods($id = null)
{
    if (!empty($id)) {
        $data["user"] = $this->user;
    $data['schemes'] = $this->common_model->get_rows_without_condition("schemes");
        $r = array("id" => $id);
        $kitmethods['edit_kitmethods'] = $this->common_model->get_rows_with_condition("kitmethods", $r);
        $this->load->view('user/include/header');
    $this->load->view('user/include/page_header');
    $this->load->view('user/include/sidebar',$data);
    $this->load->view('user/edit_kitmethods', $kitmethods);
    $this->load->view('user/include/page_footer');
    $this->load->view('user/include/footer');
    } else {
        redirect("user/kitmethods");
    }
}

public function edit_kitmethods($id)
{
    $form_data = $_POST;
    $data['msg_added'] = $this->common_model->update("kitmethods", $form_data, $id);
    $this->session->set_flashdata("msg_added", $data['msg_added']);
    redirect('user/kitmethods');
}

// **************************Kit Methods**************************  

}

0 个答案:

没有答案