function service_form_delete_process()
{
    log_debug("inc_services_process", "Executing service_form_delete_process()");
    /*
    	Fetch all form data
    */
    // get form data
    $id = @security_form_input_predefined("int", "id_service", 1, "");
    $data["delete_confirm"] = @security_form_input_predefined("any", "delete_confirm", 1, "You must confirm the deletion");
    //// ERROR CHECKING ///////////////////////
    // make sure the service actually exists
    $sql_obj = new sql_query();
    $sql_obj->string = "SELECT id FROM services WHERE id='{$id}' LIMIT 1";
    $sql_obj->execute();
    if (!$sql_obj->num_rows()) {
        log_write("error", "process", "The service you have attempted to edit - {$id} - does not exist in this system.");
    }
    // make sure the service is not active for any customers
    $sql_obj = new sql_query();
    $sql_obj->string = "SELECT id FROM services_customers WHERE serviceid='{$id}' LIMIT 1";
    $sql_obj->execute();
    if ($sql_obj->num_rows()) {
        log_write("error", "process", "Service is active for customers and can therefore not be deleted.");
    }
    /// if there was an error, go back to the entry page
    if ($_SESSION["error"]["message"]) {
        $_SESSION["error"]["form"]["service_delete"] = "failed";
        header("Location: ../index.php?page=services/delete.php&id={$id}");
        exit(0);
    } else {
        /*
        	Begin Transaction
        */
        $sql_obj = new sql_query();
        $sql_obj->trans_begin();
        /*
        	Delete the service data
        */
        $sql_obj->string = "DELETE FROM services WHERE id='{$id}' LIMIT 1";
        $sql_obj->execute();
        /*
        	Delete the service taxes
        */
        $sql_obj->string = "DELETE FROM services_taxes WHERE serviceid='{$id}'";
        $sql_obj->execute();
        /*
        	Delete the service bundle components (if any)
        */
        $sql_bundle_obj = new sql_query();
        $sql_bundle_obj->string = "SELECT id FROM services_bundles WHERE id_service='{$id}'";
        $sql_bundle_obj->execute();
        if ($sql_bundle_obj->num_rows()) {
            $sql_bundle_obj->fetch_array();
            foreach ($sql_bundle_obj->data as $data_bundle) {
                // delete any options for each bundle item
                $sql_obj->string = "DELETE FROM services_options WHERE option_type='service' AND option_type_id='" . $data_bundle["id"] . "'";
                $sql_obj->execute();
            }
        }
        $sql_obj->string = "DELETE FROM services_bundles WHERE id_service='{$id}'";
        $sql_obj->execute();
        /*
        	Delete the service cdr rate overrides (if any)
        */
        $sql_obj->string = "DELETE FROM cdr_rate_tables_overrides WHERE option_type='service' AND option_type_id='{$id}'";
        $sql_obj->execute();
        /*
        	Delete service journal data
        */
        journal_delete_entire("services", $id);
        /*
        	Commit
        */
        if (error_check()) {
            $sql_obj->trans_rollback();
            log_write("error", "process", "An error occured whilst attempting to delete the transaction. No changes have been made.");
            header("Location: ../index.php?page=services/view.php&id={$id}");
            exit(0);
        } else {
            $sql_obj->trans_commit();
            log_write("notification", "process", "Service successfully deleted");
            header("Location: ../index.php?page=services/services.php");
            exit(0);
        }
    }
    // end if passed tests
}
示例#2
0
 function action_delete()
 {
     log_debug("invoice", "Executing action_delete()");
     // we must have an ID provided
     if (!$this->id) {
         log_debug("invoice", "No invoice ID supplied to action_delete function");
         return 0;
     }
     /*
     	Start SQL Transaction
     */
     $sql_obj = new sql_query();
     $sql_obj->trans_begin();
     /*
     	Delete Invoice
     */
     $sql_obj->string = "DELETE FROM account_" . $this->type . " WHERE id='" . $this->id . "' LIMIT 1";
     $sql_obj->execute();
     /*
     	Delete Invoice Items
     
     	We do this by using the invoice_items::action_delete() function, since there are number of complex
     	steps when deleting certain invoice items (such as time items)
     */
     $sql_items_obj = new sql_query();
     $sql_items_obj->string = "SELECT id FROM account_items WHERE invoicetype='" . $this->type . "' AND invoiceid='" . $this->id . "'";
     $sql_items_obj->execute();
     if ($sql_items_obj->num_rows()) {
         $sql_items_obj->fetch_array();
         foreach ($sql_items_obj->data as $data_sql) {
             // delete each invoice one-at-a-time.
             $obj_invoice_item = new invoice_items();
             $obj_invoice_item->type_invoice = $this->type;
             $obj_invoice_item->id_invoice = $this->id;
             $obj_invoice_item->id_item = $data_sql["id"];
             $obj_invoice_item->action_delete();
             unset($obj_invoice_item);
         }
     }
     /*
     	Delete Journal
     */
     journal_delete_entire("account_" . $this->type . "", $this->id);
     /*
     	Delete transactions from ledger
     	
     	(Most transactions are deleted by the item deletion code, but tax, pay and AR/AP
     	 ledger transactions need to be removed manually)
     */
     $sql_obj->string = "DELETE FROM account_trans WHERE (type='" . $this->type . "' || type='" . $this->type . "_tax' || type='" . $this->type . "_pay') AND customid='" . $this->id . "'";
     $sql_obj->execute();
     /*
     	Commit
     */
     if (error_check()) {
         $sql_obj->trans_rollback();
         log_write("error", "invoice", "An error occured whilst deleting the invoice. No changes have been made.");
         return 0;
     } else {
         $sql_obj->trans_commit();
         return 1;
     }
 }
        $_SESSION["error"]["form"]["support_ticket_delete"] = "failed";
        header("Location: ../index.php?page=support/delete.php&id={$id}");
        exit(0);
    } else {
        // begin transaction
        $sql_obj = new sql_query();
        $sql_obj->trans_begin();
        /*
        	Delete Support Ticket
        */
        $sql_obj->string = "DELETE FROM support_tickets WHERE id='{$id}' LIMIT 1";
        $sql_obj->execute();
        /*
        	Delete Journal
        */
        journal_delete_entire("support_tickets", $id);
        // commit
        if (error_check()) {
            $sql_obj->trans_rollback();
            log_write("error", "process", "A fatal error occured whilst trying to delete the support ticket. No changes have been made.");
        } else {
            $sql_obj->trans_commit();
            log_write("error", "notification", "Support Ticket has been successfully deleted.");
        }
        // return to support ticket list
        header("Location: ../index.php?page=support/support.php");
        exit(0);
    }
    /////////////////////////
} else {
    // user does not have perms to view this page/isn't logged on
     $sql_obj->string = "DELETE FROM projects WHERE id='{$id}' LIMIT 1";
     $sql_obj->execute();
     /*
     	Delete Phases
     */
     $sql_obj->string = "DELETE FROM project_phases WHERE projectid='{$id}'";
     $sql_obj->execute();
     /*
     	Delete Time Groups
     */
     $sql_obj->string = "DELETE FROM time_groups WHERE projectid='{$id}'";
     $sql_obj->execute();
     /*
     	Delete Project Journal
     */
     journal_delete_entire("projects", $id);
     /*
     	Commit
     */
     if (error_check()) {
         $sql_obj->trans_rollback();
         log_write("error", "process", "An error occured whilst attempting to delete the project, no changes have been made");
         header("Location: ../index.php?page=projects/delete.php&id={$id}");
         exit(0);
     } else {
         $sql_obj->trans_commit();
         log_write("notification", "process", "Project deleted successfully");
         header("Location: ../index.php?page=projects/projects.php");
         exit(0);
     }
 }
示例#5
0
 function action_delete()
 {
     log_debug("inc_vendors", "Executing action_delete()");
     // start transaction
     $sql_obj = new sql_query();
     $sql_obj->trans_begin();
     /*
     	Delete Vendor
     */
     $sql_obj->string = "DELETE FROM vendors WHERE id='" . $this->id . "' LIMIT 1";
     $sql_obj->execute();
     /*
     	Delete vendor taxes
     */
     $sql_obj->string = "DELETE FROM vendors_taxes WHERE vendorid='" . $this->id . "'";
     $sql_obj->execute();
     /*
     	Delete vendor contacts and records
     */
     $sql_obj->string = "SELECT id from vendor_contacts WHERE id='" . $this->id . "'";
     $sql_obj->execute();
     $sql_obj->fetch_array();
     foreach ($sql_obj->data as $data) {
         $sql_obj->string = "DELETE FROM vendor_contact_records WHERE contact_id='" . $data["id"] . "'";
         $sql_obj->execute();
     }
     $sql_obj->string = "DELETE FROM vendor_contacts WHERE id='" . $this->id . "'";
     $sql_obj->execute();
     /*
     	Delete Journal
     */
     journal_delete_entire("vendors", $this->id);
     // commit
     if (error_check()) {
         $sql_obj->trans_rollback();
         log_write("error", "inc_vendors", "An error occured whilst attempting to delete vendor. No changes have been made.");
         return 0;
     } else {
         $sql_obj->trans_commit();
         log_write("notification", "inc_vendors", "Vendor has been successfully deleted.");
         return 1;
     }
 }
function quotes_form_delete_process($returnpage_error, $returnpage_success)
{
    log_debug("inc_quotes_forms", "Executing quotes_form_delete_process({$mode}, {$returnpage_error}, {$returnpage_success})");
    /*
    	Fetch all form data
    */
    // get form data
    $id = @security_form_input_predefined("int", "id_quote", 1, "");
    $data["delete_confirm"] = @security_form_input_predefined("any", "delete_confirm", 1, "You must confirm the deletion");
    // we don't use this value (since we can't trust it) but we need to read it
    // in here to work around a limitation in the Amberphplib framework
    $data["date_create"] = @security_form_input_predefined("any", "date_create", 1, "");
    //// ERROR CHECKING ///////////////////////
    // make sure the quote actually exists
    $sql_obj = new sql_query();
    $sql_obj->string = "SELECT id, date_create FROM `account_quotes` WHERE id='{$id}' LIMIT 1";
    $sql_obj->execute();
    if (!$sql_obj->num_rows()) {
        $_SESSION["error"]["message"][] = "The quote you have attempted to edit - {$id} - does not exist in this system.";
    }
    /// if there was an error, go back to the entry page
    if ($_SESSION["error"]["message"]) {
        $_SESSION["error"]["form"]["quote_delete"] = "failed";
        header("Location: ../../index.php?page={$returnpage_error}&id={$id}");
        exit(0);
    } else {
        /*
        	Start SQL Transaction
        */
        $sql_obj = new sql_query();
        $sql_obj->trans_begin();
        /*
        	delete quote itself
        */
        $sql_obj->string = "DELETE FROM account_quotes WHERE id='{$id}' LIMIT 1";
        $sql_obj->execute();
        /*
        	delete all the item options
        */
        $sql_item_obj = new sql_query();
        $sql_item_obj->string = "SELECT id FROM account_items WHERE invoicetype='quotes' AND invoiceid='{$id}'";
        $sql_item_obj->execute();
        if ($sql_item_obj->num_rows()) {
            $sql_item_obj->fetch_array();
            foreach ($sql_item_obj->data as $data) {
                $sql_obj->string = "DELETE FROM account_items_options WHERE itemid='" . $data["id"] . "'";
                $sql_obj->execute();
            }
        }
        /*
        	delete all the quote items
        */
        $sql_obj->string = "DELETE FROM account_items WHERE invoicetype='quotes' AND invoiceid='{$id}'";
        $sql_obj->execute();
        /*
        	delete quote journal entries
        */
        journal_delete_entire("account_quotes", $id);
        /*
        	Commit
        */
        if (error_check()) {
            $sql_obj->trans_rollback();
            log_write("error", "inc_quotes_forms", "An error occured whilst attempting to delete the quote. No changes have been made.");
            $_SESSION["error"]["form"]["quote_delete"] = "failed";
            header("Location: ../../index.php?page={$returnpage_error}&id={$id}");
            exit(0);
        } else {
            $sql_obj->trans_commit();
            log_write("notification", "inc_quotes_forms", "The quotation has been successfully deleted.");
            header("Location: ../../index.php?page={$returnpage_success}");
            exit(0);
        }
    }
    // end if passed tests
}
示例#7
0
 function action_delete()
 {
     log_debug("inc_staff", "Executing action_delete()");
     /*
     	Start Transaction
     */
     $sql_obj = new sql_query();
     $sql_obj->trans_begin();
     /*
     	Delete Employee
     */
     $sql_obj->string = "DELETE FROM staff WHERE id='" . $this->id . "' LIMIT 1";
     $sql_obj->execute();
     /*
     	Delete User <-> Employee permissions mappings
     */
     $sql_obj->string = "DELETE FROM users_permissions_staff WHERE staffid='{$this->id}'";
     $sql_obj->execute();
     /*
     	Delete Journal
     */
     journal_delete_entire("staff", $this->id);
     /*
     	Commit
     */
     if (error_check()) {
         $sql_obj->trans_rollback();
         log_write("error", "inc_staff", "An error occured whilst attempting to delete the employee. No changes have been made.");
         return 0;
     } else {
         $sql_obj->trans_commit();
         log_write("notification", "inc_staff", "Employee has been successfully deleted.");
         return 1;
     }
 }
        /*
        	Delete user permissions
        	(both access and staff permissions)
        */
        $sql_obj->string = "DELETE FROM users_permissions WHERE userid='{$id}'";
        $sql_obj->execute();
        $sql_obj->string = "DELETE FROM users_permissions_staff WHERE userid='{$id}'";
        $sql_obj->execute();
        // end transaction
        if ($_SESSION["error"]["message"]) {
            log_write("error", "process", "A fatal error occured whilst attempting to delete user. No changes have been made.");
            $sql_obj->trans_rollback();
        } else {
            log_write("notification", "process", "Successfully deleted user account & preferences");
            $sql_obj->trans_commit();
        }
        /*
        	Delete Journal
        */
        journal_delete_entire("users", $id);
        // return to user list
        header("Location: ../index.php?page=user/users.php");
        exit(0);
    }
    /////////////////////////
} else {
    // user does not have perms to view this page/isn't logged on
    error_render_noperms();
    header("Location: ../index.php?page=message.php");
    exit(0);
}
示例#9
0
 function action_delete()
 {
     log_debug("inc_customers", "Executing action_delete()");
     /*
     	Start Transaction
     */
     $sql_obj = new sql_query();
     $sql_obj->trans_begin();
     /*
     	Delete Customer
     */
     $sql_obj->string = "DELETE FROM customers WHERE id='" . $this->id . "' LIMIT 1";
     $sql_obj->execute();
     /*
     	Delete customer taxes
     */
     $sql_obj->string = "DELETE FROM customers_taxes WHERE customerid='" . $this->id . "'";
     $sql_obj->execute();
     /*
     	Delete customer contacts and records
     */
     $sql_obj->string = "SELECT id from customer_contacts WHERE id='" . $this->id . "'";
     $sql_obj->execute();
     $sql_obj->fetch_array();
     foreach ($sql_obj->data as $data) {
         $sql_obj->string = "DELETE FROM customer_contact_records WHERE contact_id='" . $data["id"] . "'";
         $sql_obj->execute();
     }
     $sql_obj->string = "DELETE FROM customer_contacts WHERE id='" . $this->id . "'";
     $sql_obj->execute();
     /*
     	Delete Journal
     */
     journal_delete_entire("customers", $this->id);
     /*
     	Commit
     */
     if (error_check()) {
         $sql_obj->trans_rollback();
         log_write("error", "inc_customers", "An error occured whilst trying to delete the customer.");
         return 0;
     } else {
         $sql_obj->trans_commit();
         log_write("notification", "inc_customers", "Customer has been successfully deleted.");
         return 1;
     }
 }