-
Notifications
You must be signed in to change notification settings - Fork 57
Open
Description
1- Manage Departments->Allow escalation ->Escalate To->select department ->Escalate Wait Time-> here i mention 1 hour ...
put only numeric vale in this field ,
after wait 1 hour .. ticket did't escalate to higher department ..
i wish if my ticket auto escalate to another stuff .. i dont want manual assign.. to staff ..
solution please
There is code ..
ifthd->member['acp']['manage_depart'] ) { $this->ifthd->skin->error('no_perm'); } $this->ifthd->skin->set_section( 'Ticket Control' ); $this->ifthd->skin->set_description( 'Manage your tickets, departments, custom department fields and canned replies.' ); switch( $this->ifthd->input['code'] ) { case 'list': $this->list_departs(); break; case 'reorder': $this->reorder_departs(); break; case 'add': $this->add_depart(); break; case 'edit': $this->edit_depart(); break; case 'delete': $this->delete_depart(); break; case 'doreorder': $this->do_reorder(); break; case 'doadd': $this->do_create(); break; case 'doedit': $this->do_edit(); break; case 'dodel': $this->do_delete(); break; default: $this->list_departs(); break; } } #======================================= # @ List Departmenets # Show a list of departmenets. #======================================= function list_departs($error='', $alert='') { #============================= # Grab Departments #============================= $this->ifthd->core->db->construct( array( 'select' => 'all', 'from' => 'departments', 'order' => array( 'position' => 'asc' ), ) ); $this->ifthd->core->db->execute(); $depart_rows = ""; // Initialize for Security $row_count = 0; // Initialize for Security if ( $this->ifthd->core->db->get_num_rows() ) { while( $d = $this->ifthd->core->db->fetch_row() ) { $row_count ++; ( $row_count & 1 ) ? $row_class = 'option1-med' : $row_class = 'option2-med'; #============================= # Fix Up Information #============================= $d['description'] = $this->ifthd->shorten_str( $d['description'], 80, 1 ); $depart_rows .= " {$d['id']} {$d['name']} {$d['description']} {$d['tickets']}
";
}
}
#=============================
# Do Output
#=============================
if ( $error )
{
$error = "{$error}
";
}
elseif ( $alert )
{
$error = "{$alert}
";
}
$this->output = "{$error}
". $depart_rows ."
| ID | Name | Description | Tickets | Edit | Delete |
|---|
{$error}
";
}
$this->output = "<script type='text/javascript'>
function validate_form(form)
{
if ( ! form.name.value )
{
alert('Please enter a name.');
form.name.focus();
return false;
}
if ( ! form.description.value )
{
alert('Please enter a description.');
form.description.focus();
return false;
}
}
</script>
{$error}
Adding Department
";
if ( ACP_HELP )
{
$this->output .= "";
}
$this->output .= "";
if ( ACP_HELP )
{
$this->output .= "";
}
$this->output .= "";
if ( ACP_HELP )
{
$this->output .= "";
}
$this->output .= "";
if ( ACP_HELP )
{
$this->output .= "";
}
$this->output .= "";
if ( ACP_HELP )
{
$this->output .= "";
}
$this->output .= "";
if ( ACP_HELP )
{
$this->output .= "";
}
$this->output .= "";
if ( ACP_HELP )
{
$this->output .= "";
}
if ( $pop3 )
{
$this->output .= "";
}
$this->output .= "";
if ( ACP_HELP )
{
$this->output .= "";
}
$this->output .= "";
if ( ACP_HELP )
{
$this->output .= "";
}
$this->output .= "";
if ( ACP_HELP )
{
$this->output .= "";
}
$this->output .= "| Name | |
| Description | <textarea name='description' id='description' cols='50' rows='2'>{$this->ifthd->input['description']}</textarea> |
| Auto Assign | No one". $this->ifthd->build_staff_drop( $this->ifthd->input['auto_assign'] ) ." |
| Allow Escalation | ". $this->ifthd->skin->yes_no_radio( 'can_escalate', $this->ifthd->input['can_escalate'] ) ." |
| Escalate To | None". $this->ifthd->build_dprt_drop( $this->ifthd->input['escalate_depart'], 0, 1 ) ." (Optional) |
| Escalate Wait Time | (Hours) |
| Auto Close Wait Time | (Hours) (Leave blank to disable) |
| Enable Email Piping | ". $this->ifthd->skin->yes_no_radio( 'email_pipe', $this->ifthd->input['email_pipe'] ) ." |
| Incoming Email | |
| Enable POP3 Checking | ". $this->ifthd->skin->yes_no_radio( 'email_pop3', $this->ifthd->input['email_pop3'] ) ." |
| Mail Server Address | * |
| Username | * |
| Password | * |
| Enable Guest Emails | ". $this->ifthd->skin->yes_no_radio( 'guest_pipe', $this->ifthd->input['guest_pipe'] ) ." |
| Can Close Own Tickets | ". $this->ifthd->skin->yes_no_radio( 'ticket_own_close', $this->ifthd->input['ticket_own_close'] ) ." |
| Can Reopen Own Tickets | ". $this->ifthd->skin->yes_no_radio( 'ticket_own_reopen', $this->ifthd->input['ticket_own_reopen'] ) ." |
| Require Close Reason | ". $this->ifthd->skin->yes_no_radio( 'close_reason', $this->ifthd->input['close_reason'] ) ." |
| Allow Attachments | ". $this->ifthd->skin->yes_no_radio( 'can_attach', $his->ifthd->input['can_attach'] ) ." |
| Group Permissions | ". $this->ifthd->build_group_drop( $this->ifthd->input['group_perm'] ) ." |
* Only applies when POP3 is enabled.
";
$this->output .= "";
$this->ifthd->skin->add_output( $this->output );
$this->nav = array(
"Management",
"Departments",
"Add Department",
);
$this->ifthd->skin->do_output( array( 'nav' => $this->nav, 'title' => 'Manage Departments' ) );
}
#=======================================
# @ Edit Department
# Show edit department form.
#=======================================
function edit_depart($error="")
{
#=============================
# Security Checks
#=============================
$this->ifthd->input['id'] = intval( $this->ifthd->input['id'] );
if ( ! $this->ifthd->member['acp']['manage_depart_edit'] )
{
$this->ifthd->skin->error('no_perm');
}
if ( file_exists( HD_SRC .'pop3.php' ) )
{
$pop3 = 1;
}
$this->ifthd->core->db->construct( array(
'select' => 'all',
'from' => 'departments',
'where' => array( 'id', '=', $this->ifthd->input['id'] ),
'limit' => array( 0,1 ),
) );
$this->ifthd->core->db->execute();
if ( ! $this->ifthd->core->db->get_num_rows() )
{
$this->ifthd->skin->error('no_department');
}
$d = $this->ifthd->core->db->fetch_row();
#=============================
# Do Output
#=============================
if ( $error )
{
$error = "{$error}
";
$name = $this->ifthd->input['name'];
$description = $this->ifthd->input['description'];
$can_escalate = $this->ifthd->input['can_escalate'];
$escalate_depart = $this->ifthd->input['escalate_depart'];
$escalate_wait = $this->ifthd->input['escalate_wait'];
$auto_close = $this->ifthd->input['auto_close'];
$email_pipe = $this->ifthd->input['email_pipe'];
$guest_pipe = $this->ifthd->input['guest_pipe'];
$incoming_email = $this->ifthd->input['incoming_email'];
$email_pop3 = $this->ifthd->input['email_pop3'];
$pop3_host = $this->ifthd->input['pop3_host'];
$pop3_user = $this->ifthd->input['pop3_user'];
$pop3_pass = $this->ifthd->input['pop3_pass'];
$ticket_own_close = $this->ifthd->input['ticket_own_close'];
$ticket_own_reopen = $this->ifthd->input['ticket_own_reopen'];
$close_reason = $this->ifthd->input['close_reason'];
$can_attach = $this->ifthd->input['can_attach'];
$auto_assign = $this->ifthd->input['auto_assign'];
$group_perm = $this->ifthd->input['group_perm'];
}
else
{
$name = $d['name'];
$description = $d['description'];
$can_escalate = $d['can_escalate'];
$escalate_depart = $d['escalate_depart'];
$escalate_wait = $d['escalate_wait'];
$auto_close = $d['auto_close'];
$email_pipe = $d['email_pipe'];
$guest_pipe = $d['guest_pipe'];
$incoming_email = $d['incoming_email'];
$email_pop3 = $d['email_pop3'];
$pop3_host = $d['pop3_host'];
$pop3_user = $d['pop3_user'];
$pop3_pass = $d['pop3_pass'];
$ticket_own_close = $d['ticket_own_close'];
$ticket_own_reopen = $d['ticket_own_reopen'];
$close_reason = $d['close_reason'];
$can_attach = $d['can_attach'];
$auto_assign = $d['auto_assign'];
$this->ifthd->core->db->construct( array(
'select' => array( 'g_id', 'g_m_depart_perm' ),
'from' => 'groups',
) );
$this->ifthd->core->db->execute();
if ( $this->ifthd->core->db->get_num_rows() )
{
while ( $g = $this->ifthd->core->db->fetch_row() )
{
$g_temp_perm = unserialize( $g['g_m_depart_perm'] );
if ( $g_temp_perm[ $d['id'] ] )
{
$group_perm[] = $g['g_id'];
}
}
}
}
$this->output = "<script type='text/javascript'>
function validate_form(form)
{
if ( ! form.name.value )
{
alert('Please enter a name.');
form.name.focus();
return false;
}
if ( ! form.description.value )
{
alert('Please enter a description.');
form.description.focus();
return false;
}
}
</script>
{$error}
Editing Department: {$d['name']}
";
if ( ACP_HELP )
{
$this->output .= "";
}
$this->output .= "";
if ( ACP_HELP )
{
$this->output .= "";
}
$this->output .= "";
if ( ACP_HELP )
{
$this->output .= "";
}
$this->output .= "";
if ( ACP_HELP )
{
$this->output .= "";
}
$this->output .= "";
if ( ACP_HELP )
{
$this->output .= "";
}
$this->output .= "";
if ( ACP_HELP )
{
$this->output .= "";
}
$this->output .= "";
if ( ACP_HELP )
{
$this->output .= "";
}
if ( $pop3 )
{
$this->output .= "";
}
$this->output .= "";
if ( ACP_HELP )
{
$this->output .= "";
}
$this->output .= "";
if ( ACP_HELP )
{
$this->output .= "";
}
$this->output .= "";
if ( ACP_HELP )
{
$this->output .= "";
}
$this->output .= "| Name | |
| Description | <textarea name='description' id='description' cols='50' rows='2'>{$description}</textarea> |
| Auto Assign | No one". $this->ifthd->build_staff_drop( $auto_assign ) ." |
| Allow Escalation | ". $this->ifthd->skin->yes_no_radio( 'can_escalate', $can_escalate ) ." |
| Escalate To | None". $this->ifthd->build_dprt_drop( $escalate_depart, $d['id'], 1 ) ." (Optional) |
| Escalate Wait Time | (Hours) |
| Auto Close Wait Time | (Hours) (Leave blank to disable) |
| Enable Email Piping | ". $this->ifthd->skin->yes_no_radio( 'email_pipe', $email_pipe ) ." |
| Incoming Email | |
| Enable POP3 Checking | ". $this->ifthd->skin->yes_no_radio( 'email_pop3', $email_pop3 ) ." |
| Mail Server Address | * |
| Username | * |
| Password | * |
| Enable Guest Emails | ". $this->ifthd->skin->yes_no_radio( 'guest_pipe', $guest_pipe ) ." |
| Can Close Own Tickets | ". $this->ifthd->skin->yes_no_radio( 'ticket_own_close', $ticket_own_close ) ." |
| Can Reopen Own Tickets | ". $this->ifthd->skin->yes_no_radio( 'ticket_own_reopen', $ticket_own_reopen ) ." |
| Require Close Reason | ". $this->ifthd->skin->yes_no_radio( 'close_reason', $close_reason ) ." |
| Allow Attachments | ". $this->ifthd->skin->yes_no_radio( 'can_attach', $can_attach ) ." |
| Group Permissions | ". $this->ifthd->build_group_drop( $group_perm ) ." |
* Only applies when POP3 is enabled.
";
$this->output .= "";
$this->ifthd->skin->add_output( $this->output );
$this->nav = array(
"Management",
"Departments",
"Edit Department",
);
$this->ifthd->skin->do_output( array( 'nav' => $this->nav, 'title' => 'Manage Departments' ) );
}
#=======================================
# @ Delete Department
# Show delete department form.
#=======================================
function delete_depart()
{
#=============================
# Security Checks
#=============================
$this->ifthd->input['id'] = intval( $this->ifthd->input['id'] );
if ( ! $this->ifthd->member['acp']['manage_depart_delete'] )
{
$this->ifthd->skin->error('no_perm');
}
$this->ifthd->core->db->construct( array(
'select' => 'all',
'from' => 'departments',
'where' => array( 'id', '=', $this->ifthd->input['id'] ),
'limit' => array( 0,1 ),
) );
$this->ifthd->core->db->execute();
if ( ! $this->ifthd->core->db->get_num_rows() )
{
$this->ifthd->skin->error('no_department');
}
$d = $this->ifthd->core->db->fetch_row();
#=============================
# Do Output
#=============================
$depart_drop = $this->ifthd->build_dprt_drop( 0, $d['id'], 1 );
$this->output = "
Deleting Department: {$d['name']}
What would you like to do with the tickets in this department?
Move the tickets to this department: {$depart_drop}
Delete the tickets
";
$this->ifthd->skin->add_output( $this->output );
$this->nav = array(
"Management",
"Departments",
"Delete Department",
);
$this->ifthd->skin->do_output( array( 'nav' => $this->nav, 'title' => 'Manage Departments' ) );
}
#=======================================
# @ Do Create
# Create a new department.
#=======================================
function do_create()
{
#=============================
# Security Checks
#=============================
if ( file_exists( HD_SRC .'pop3.php' ) )
{
$pop3 = 1;
}
if ( ! $this->ifthd->member['acp']['manage_depart_add'] )
{
$this->ifthd->skin->error('no_perm');
}
if ( ! $this->ifthd->input['name'] )
{
$this->add_depart('Please enter a name.');
}
if ( ! $this->ifthd->input['description'] )
{
$this->add_depart('Please enter a description.');
}
if ( ! is_array( $this->ifthd->input['group_perm'] ) )
{
$this->add_depart('Please select some group permissions.');
}
if ( $this->ifthd->input['email_pipe'] )
{
if ( ! $this->ifthd->validate_email( $this->ifthd->input['incoming_email'] ) )
{
$this->add_depart('Please enter a valid incoming email address.');
}
$this->ifthd->core->db->construct( array(
'select' => array( 'id' ),
'from' => 'departments',
'where' => array( 'incoming_email', '=', $this->ifthd->input['incoming_email'] ),
'limit' => array( 0,1 ),
) );
$this->ifthd->core->db->execute();
if ( $this->ifthd->core->db->get_num_rows() )
{
$this->add_depart('That incoming email address is already used for another department. Please choose a different email.');
}
}
#=============================
# Add Department
#=============================
$db_array = array(
'name' => $this->ifthd->input['name'],
'description' => $this->ifthd->input['description'],
'can_escalate' => $this->ifthd->input['can_escalate'],
'escalate_depart' => $this->ifthd->input['escalate_depart'],
'escalate_wait' => $this->ifthd->input['escalate_wait'],
'auto_close' => $this->ifthd->input['auto_close'],
'ticket_own_close' => $this->ifthd->input['ticket_own_close'],
'ticket_own_reopen' => $this->ifthd->input['ticket_own_reopen'],
'close_reason' => $this->ifthd->input['close_reason'],
'can_attach' => $this->ifthd->input['can_attach'],
'email_pipe' => $this->ifthd->input['email_pipe'],
'guest_pipe' => $this->ifthd->input['guest_pipe'],
'incoming_email' => $this->ifthd->input['incoming_email'],
'auto_assign' => $this->ifthd->input['auto_assign'],
);
if ( $pop3 )
{
$db_array['email_pop3'] = $this->ifthd->input['email_pop3'];
$db_array['pop3_host'] = $this->ifthd->input['pop3_host'];
$db_array['pop3_user'] = $this->ifthd->input['pop3_user'];
$db_array['pop3_pass'] = $this->ifthd->input['pop3_pass'];
}
$this->ifthd->core->db->construct( array(
'insert' => 'departments',
'set' => $db_array,
) );
$this->ifthd->core->db->execute();
$depart_id = $this->ifthd->core->db->get_insert_id();
$this->ifthd->log( 'admin', "Department Added '". $this->ifthd->input['name'] ."'", 1, $depart_id );
#=============================
# Generate Permissions
#=============================
$this->ifthd->core->db->construct( array(
'select' => array( 'g_id', 'g_m_depart_perm' ),
'from' => 'groups',
'where' => array( 'g_id', 'in', $this->ifthd->input['group_perm'] ),
) );
$this->ifthd->core->db->execute();
if ( $this->ifthd->core->db->get_num_rows() )
{
while ( $g = $this->ifthd->core->db->fetch_row() )
{
$temp_perm[ $g['g_id'] ] = unserialize( $g['g_m_depart_perm'] );
$temp_perm[ $g['g_id'] ][ $depart_id ] = 1;
}
}
while ( list( $gid, $g_perm ) = each( $temp_perm ) )
{
$this->ifthd->core->db->construct( array(
'update' => 'groups',
'set' => array( 'g_m_depart_perm' => serialize($g_perm) ),
'where' => array( 'g_id', '=', $gid ),
) );
$this->ifthd->core->db->execute();
}
#=============================
# Rebuild Cache
#=============================
$this->ifthd->rebuild_dprt_cache();
$this->ifthd->rebuild_group_cache();
#=============================
# Redirect
#=============================
#$this->ifthd->skin->redirect( '?section=manage&act=depart&code=list', 'add_depart_success' );
$this->list_departs( '', 'The department has been successfully added.' );
}
#=======================================
# @ Do Edit
# Edit a department.
#=======================================
function do_edit()
{
#=============================
# Security Checks
#=============================
if ( file_exists( HD_SRC .'pop3.php' ) )
{
$pop3 = 1;
}
$this->ifthd->input['id'] = intval( $this->ifthd->input['id'] );
if ( ! $this->ifthd->member['acp']['manage_depart_edit'] )
{
$this->ifthd->skin->error('no_perm');
}
$this->ifthd->core->db->construct( array(
'select' => 'all',
'from' => 'departments',
'where' => array( 'id', '=', $this->ifthd->input['id'] ),
'limit' => array( 0,1 ),
) );
$this->ifthd->core->db->execute();
if ( ! $this->ifthd->core->db->get_num_rows() )
{
$this->ifthd->skin->error('no_department');
}
if ( ! $this->ifthd->input['name'] )
{
$this->edit_depart('Please enter a name.');
}
if ( ! $this->ifthd->input['description'] )
{
$this->edit_depart('Please enter a description.');
}
if ( ! is_array( $this->ifthd->input['group_perm'] ) )
{
$this->edit_depart('Please select some group permissions.');
}
if ( $this->ifthd->input['email_pipe'] )
{
if ( ! $this->ifthd->validate_email( $this->ifthd->input['incoming_email'] ) )
{
$this->edit_depart('Please enter a valid incoming email address.');
}
$this->ifthd->core->db->construct( array(
'select' => array( 'id' ),
'from' => 'departments',
'where' => array( array( 'incoming_email', '=', $this->ifthd->input['incoming_email'] ), array( 'id', '!=', $this->ifthd->input['id'], 'and' ) ),
'limit' => array( 0,1 ),
) );
$this->ifthd->core->db->execute();
if ( $this->ifthd->core->db->get_num_rows() )
{
$this->edit_depart('That incoming email address is already used for another department. Please choose a different email.');
}
}
#=============================
# Edit Department
#=============================
$db_array = array(
'name' => $this->ifthd->input['name'],
'description' => $this->ifthd->input['description'],
'can_escalate' => $this->ifthd->input['can_escalate'],
'escalate_depart' => $this->ifthd->input['escalate_depart'],
'escalate_wait' => $this->ifthd->input['escalate_wait'],
'auto_close' => $this->ifthd->input['auto_close'],
'ticket_own_close' => $this->ifthd->input['ticket_own_close'],
'ticket_own_reopen' => $this->ifthd->input['ticket_own_reopen'],
'close_reason' => $this->ifthd->input['close_reason'],
'can_attach' => $this->ifthd->input['can_attach'],
'email_pipe' => $this->ifthd->input['email_pipe'],
'guest_pipe' => $this->ifthd->input['guest_pipe'],
'incoming_email' => $this->ifthd->input['incoming_email'],
'auto_assign' => $this->ifthd->input['auto_assign'],
);
if ( $pop3 )
{
$db_array['email_pop3'] = $this->ifthd->input['email_pop3'];
$db_array['pop3_host'] = $this->ifthd->input['pop3_host'];
$db_array['pop3_user'] = $this->ifthd->input['pop3_user'];
$db_array['pop3_pass'] = $this->ifthd->input['pop3_pass'];
}
$this->ifthd->core->db->construct( array(
'update' => 'departments',
'set' => $db_array,
'where' => array( 'id', '=', $this->ifthd->input['id'] ),
) );
$this->ifthd->core->db->execute();
$this->ifthd->log( 'admin', "Department Edited '". $this->ifthd->input['name'] ."'", 1, $this->ifthd->input['id'] );
#=============================
# Generate Permissions
#=============================
if ( is_array( $this->ifthd->input['group_perm'] ) )
{
while ( list( , $mdperm ) = each( $this->ifthd->input['group_perm'] ) )
{
$m_depart_perm[ $mdperm ] = 1;
}
}
$this->ifthd->core->db->construct( array(
'select' => array( 'g_id', 'g_m_depart_perm' ),
'from' => 'groups',
) );
$this->ifthd->core->db->execute();
if ( $this->ifthd->core->db->get_num_rows() )
{
while ( $g = $this->ifthd->core->db->fetch_row() )
{
$temp_perm[ $g['g_id'] ] = unserialize( $g['g_m_depart_perm'] );
}
}
while ( list( $gid, $g_perm ) = each( $temp_perm ) )
{
if ( $m_depart_perm[ $gid ] )
{
$g_perm[ $this->ifthd->input['id'] ] = 1;
}
else
{
$g_perm[ $this->ifthd->input['id'] ] = 0;
}
$this->ifthd->core->db->construct( array(
'update' => 'groups',
'set' => array( 'g_m_depart_perm' => serialize($g_perm) ),
'where' => array( 'g_id', '=', $gid ),
) );
$this->ifthd->core->db->execute();
}
#=============================
# Rebuild Cache
#=============================
$this->ifthd->rebuild_dprt_cache();
$this->ifthd->rebuild_group_cache();
#=============================
# Redirect
#=============================
#$this->ifthd->skin->redirect( '?section=manage&act=depart&code=list', 'edit_depart_success' );
$this->list_departs( '', 'The department has been successfully updated.' );
}
#=======================================
# @ Do Delete
# Delete a department.
#=======================================
function do_delete()
{
#=============================
# Security Checks
#=============================
$this->ifthd->input['id'] = intval( $this->ifthd->input['id'] );
if ( ! $this->ifthd->member['acp']['manage_depart_delete'] )
{
$this->ifthd->skin->error('no_perm');
}
$this->ifthd->core->db->construct( array(
'select' => 'all',
'from' => 'departments',
'where' => array( 'id', '=', $this->ifthd->input['id'] ),
'limit' => array( 0,1 ),
) );
$this->ifthd->core->db->execute();
if ( ! $this->ifthd->core->db->get_num_rows() )
{
$this->ifthd->skin->error('no_department');
}
$da = $this->ifthd->core->db->fetch_row();
#=============================
# Perform Our Action
#=============================
if ( $this->ifthd->input['action'] == 1 )
{
$this->ifthd->core->db->construct( array(
'select' => 'all',
'from' => 'departments',
'where' => array( 'id', '=', $da['id'] ),
'limit' => array( 0,1 ),
) );
$this->ifthd->core->db->execute();
if ( ! $this->ifthd->core->db->get_num_rows() )
{
$this->ifthd->skin->error('no_department');
}
$d = $this->ifthd->core->db->fetch_row();
$this->ifthd->core->db->construct( array(
'update' => 'tickets',
'set' => array( 'did' => $d['id'], 'dname' => $d['name'] ),
'where' => array( 'did', '=', $da['id'] ),
) );
$this->ifthd->core->db->execute();
}
elseif ( $this->ifthd->input['action'] == 2 )
{
$this->ifthd->core->db->construct( array(
'delete' => 'tickets',
'where' => array( 'did', '=', $da['id'] ),
) );
$this->ifthd->core->db->execute();
}
#=============================
# Delete Department
#=============================
$this->ifthd->core->db->construct( array(
'delete' => 'departments',
'where' => array( 'id', '=', $da['id'] ),
'limit' => array( 1 ),
) );
$this->ifthd->core->db->execute();
$this->ifthd->log( 'admin', "Department Deleted '". $da['name'] ."'", 2, $da['id'] );
#=============================
# Rebuild Cache
#=============================
$this->ifthd->rebuild_dprt_cache();
#=============================
# Redirect
#=============================
#$this->ifthd->skin->redirect( '?section=manage&act=depart&code=list', 'delete_depart_success' );
$this->list_departs( 'The department has been successfully deleted.' );
}
#=======================================
# @ Reorder Departmenets
# Show reoarder departments form.
#=======================================
function reorder_departs()
{
#=============================
# Security Checks
#=============================
if ( ! $this->ifthd->member['acp']['manage_depart_reorder'] )
{
$this->ifthd->skin->error('no_perm');
}
#=============================
# Grab Departments
#=============================
$this->ifthd->core->db->construct( array(
'select' => 'all',
'from' => 'departments',
'order' => array( 'position' => 'asc' ),
) );
$this->ifthd->core->db->execute();
$depart_rows = ""; // Initialize for Security
$row_count = 0; // Initialize for Security
if ( $this->ifthd->core->db->get_num_rows() )
{
while( $d = $this->ifthd->core->db->fetch_row() )
{
$row_count ++;
( $row_count & 1 ) ? $row_class = 'option1-med' : $row_class = 'option2-med';
#=============================
# Fix Up Information
#=============================
$d['description'] = $this->ifthd->shorten_str( $d['description'], 80, 1 );
if ( $error )
{
$cur_pos = $this->ifthd->input[ 'pos_'. $d['id'] ];
}
else
{
$cur_pos = $d['position'];
}
$depart_rows .= "{$d['name']} ({$d['description']})
";
}
}
#=============================
# Do Output
#=============================
$this->output = "
Reordering Departments
To reorder departments, simply click and drag the department to the desired position.
". $depart_rows ."
<script type='text/javascript' language='javascript'>
Sortable.create( 'draggable', {tag:'div',constraint:'vertical'} )
function get_order() {
order = get_by_id('order');
order.value = Sortable.serialize('draggable');
}
</script>";
$this->ifthd->skin->add_output( $this->output );
$this->nav = array(
"Management",
"Departments",
"Reorder Departments",
);
$this->ifthd->skin->do_output( array( 'nav' => $this->nav, 'title' => 'Manage Departments' ) );
}
#=======================================
# @ Do Reorder
# Reorder departments.
#=======================================
function do_reorder()
{
#=============================
# Security Checks
#=============================
if ( ! $this->ifthd->member['acp']['manage_depart_reorder'] )
{
$this->ifthd->skin->error('no_perm');
}
$raw_order = str_replace( '&', '&', $this->ifthd->input['order'] );
parse_str( $raw_order, $order );
$final_order = array(); // Initialize for Security
$depart_count = 0; // Initialize for Security
while( list( , $did ) = each( $order['draggable'] ) )
{
$depart_count ++;
$final_order[ $did ] = $depart_count;
}
#=============================
# Reorder Departments
#=============================
$this->ifthd->core->db->construct( array(
'select' => 'all',
'from' => 'departments',
'order' => array( 'position' => 'asc' ),
) );
$sel_dep = $this->ifthd->core->db->execute();
$depart_rows = ""; // Initialize for Security
if ( $this->ifthd->core->db->get_num_rows($sel_dep) )
{
while( $d = $this->ifthd->core->db->fetch_row($sel_dep) )
{
if ( $d['position'] != intval( $final_order[ $d['id'] ] ) )
{
$this->ifthd->core->db->construct( array(
'update' => 'departments',
'set' => array( 'position' => intval( $final_order[ $d['id'] ] ) ),
'where' => array( 'id', '=', $d['id'] ),
) );
$this->ifthd->core->db->execute();
}
}
}
$this->ifthd->log( 'admin', "Departments Reordered" );
#=============================
# Rebuild Cache
#=============================
$this->ifthd->rebuild_dprt_cache();
#=============================
# Redirect
#=============================
#$this->ifthd->skin->redirect( '?section=manage&act=depart&code=list', 'reorder_depart_success' );
$this->list_departs( '', 'The departments have been successfully reordered. ');
}
}
?>Metadata
Metadata
Assignees
Labels
No labels

