예제 #1
0
 function execute()
 {
     /*
     	Check that the employee can be deleted
     */
     $obj_employee = new hr_staff();
     $obj_employee->id = $this->id;
     $this->locked = $obj_employee->check_lock();
     unset($obj_employee);
     /*
     	Define form structure
     */
     $this->obj_form = new form_input();
     $this->obj_form->formname = "staff_delete";
     $this->obj_form->language = $_SESSION["user"]["lang"];
     $this->obj_form->action = "hr/staff-delete-process.php";
     $this->obj_form->method = "post";
     // general
     $structure = NULL;
     $structure["fieldname"] = "name_staff";
     $structure["type"] = "text";
     $this->obj_form->add_input($structure);
     // hidden
     $structure = NULL;
     $structure["fieldname"] = "id_staff";
     $structure["type"] = "hidden";
     $structure["defaultvalue"] = $this->id;
     $this->obj_form->add_input($structure);
     // confirm delete
     $structure = NULL;
     $structure["fieldname"] = "delete_confirm";
     $structure["type"] = "checkbox";
     $structure["options"]["label"] = "Yes, I wish to delete this employee and realise that once deleted the data can not be recovered.";
     $this->obj_form->add_input($structure);
     // define submit field
     $structure = NULL;
     $structure["fieldname"] = "submit";
     $structure["type"] = "submit";
     $structure["defaultvalue"] = "delete";
     $this->obj_form->add_input($structure);
     // define subforms
     $this->obj_form->subforms["staff_delete"] = array("name_staff");
     $this->obj_form->subforms["hidden"] = array("id_staff");
     if ($this->locked) {
         $this->obj_form->subforms["submit"] = array();
     } else {
         $this->obj_form->subforms["submit"] = array("delete_confirm", "submit");
     }
     // fetch the form data
     $this->obj_form->sql_query = "SELECT name_staff FROM `staff` WHERE id='" . $this->id . "' LIMIT 1";
     $this->obj_form->load_data();
 }
/*
	staff/edit-process.php

	access: staff_write

	Allows existing staff to be adjusted, or new staff to be added.
*/
// includes
include_once "../include/config.php";
include_once "../include/amberphplib/main.php";
// custom includes
include_once "../include/hr/inc_staff.php";
if (user_permissions_get('staff_write')) {
    // create object
    $obj_employee = new hr_staff();
    /*
    	Load POST data
    */
    $obj_employee->id = @security_form_input_predefined("int", "id_staff", 0, "");
    $obj_employee->data["name_staff"] = @security_form_input_predefined("any", "name_staff", 1, "");
    $obj_employee->data["staff_code"] = @security_form_input_predefined("any", "staff_code", 0, "");
    $obj_employee->data["staff_position"] = @security_form_input_predefined("any", "staff_position", 0, "");
    $obj_employee->data["contact_phone"] = @security_form_input_predefined("any", "contact_phone", 0, "");
    $obj_employee->data["contact_fax"] = @security_form_input_predefined("any", "contact_fax", 0, "");
    $obj_employee->data["contact_email"] = @security_form_input_predefined("email", "contact_email", 0, "");
    $obj_employee->data["date_start"] = @security_form_input_predefined("date", "date_start", 1, "");
    $obj_employee->data["date_end"] = @security_form_input_predefined("date", "date_end", 0, "");
    /*
    	Error Handling
    */
예제 #3
0
 function delete_employee($id)
 {
     log_debug("hr_staff_manager", "Executing delete_employee_details({$id}, values...)");
     if (user_permissions_get("staff_write")) {
         $obj_employee = new hr_staff();
         /*
         	Load POST Data
         */
         $obj_employee->id = @security_script_input_predefined("int", $id);
         if (!$obj_employee || $obj_employee == "error") {
             throw new SoapFault("Sender", "INVALID_INPUT");
         }
         /*
         	Error Handling
         */
         // verify employee ID (if editing an existing employee)
         if (!$obj_employee->verify_id()) {
             throw new SoapFault("Sender", "INVALID_ID");
         }
         // make sure employee is not locked
         if ($obj_employee->check_lock()) {
             throw new SoapFault("Sender", "LOCKED");
         }
         /*
         	Perform Changes
         */
         if ($obj_employee->action_delete()) {
             return 1;
         } else {
             throw new SoapFault("Sender", "UNEXPECTED_ACTION_ERROR");
         }
     } else {
         throw new SoapFault("Sender", "ACCESS DENIED");
     }
 }
/*
	hr/staff-delete-process.php

	access: staff_write

	Deletes a employee provided that the employee has not been added to invoices or time bookings.
*/
// includes
include_once "../include/config.php";
include_once "../include/amberphplib/main.php";
// custom includes
include_once "../include/hr/inc_staff.php";
if (user_permissions_get('staff_write')) {
    // prepare object
    $obj_employee = new hr_staff();
    /*
    	Load POST data
    */
    $obj_employee->id = @security_form_input_predefined("int", "id_staff", 1, "");
    // these exist to make error handling work right
    $data["name_staff"] = @security_form_input_predefined("any", "name_staff", 0, "");
    // confirm deletion
    $data["delete_confirm"] = @security_form_input_predefined("any", "delete_confirm", 1, "You must confirm the deletion");
    /*
    	Error Handling
    */
    // make sure the employee actually exists
    if (!$obj_employee->verify_id()) {
        log_write("error", "staff-edit-process", "The employee you have attempted to delete - " . $obj_employee->id . " - does not exist in this system.");
    }