/home/mip/mip/public/img/credit/datatables/sqldelete.php.tar
home/mip/public_html_/old_mip/sqldelete.php 0000644 00000013567 15152061634 0015057 0 ustar 00 <?php
// Files for deleting a field.
session_start();
require_once("common_msg.inc");
require_once("func-select.php");
require_once("func-proc.php");
$db = db_connect();
$what = isset($_GET['what']) ? $_GET['what'] : '';
switch($what){
case 'principal':
$sql = "DELETE FROM principals WHERE principal_id='".$_POST['principal_id']."'";
$result = mysql_query($sql,$db);
break;
case 'jo_pos':
$sql = "DELETE FROM jo_position WHERE jo_pos_id='".$_POST['jo_pos_id']."'";
$result = mysql_query($sql,$db);
break;
case 'job_order':
$sql = "DELETE FROM job_order WHERE job_order_id='".$_POST['job_order_id']."'";
$result = mysql_query($sql,$db);
$sql1 = "DELETE FROM jo_position WHERE job_order_id='".$_POST['job_order_id']."'";
$result1 = mysql_query($sql1,$db);
break;
case 'position':
$sql = "DELETE FROM positions WHERE position_id='".$_POST['position_id']."'";
$result = mysql_query($sql,$db);
break;
case 'deletewebjob':
$sql = "delete from web_jobs where webjob_id='".$_POST['webjob_id']."'";
$result = mysql_query($sql);
echo mysql_error();
$array = array(
'webjob_id'=>$_POST['webjob_id'],
'msg_status'=>'1'
);
echo json_encode($array);
break;
case 'announcements':
$sql = "DELETE FROM web_announcements WHERE id='".$_POST['id']."'";
$result = mysql_query($sql);
echo mysql_error();
$array = array(
'id'=>$_POST['id'],
'msg_status'=>'1'
);
echo json_encode($array);
break;
case 'web_doc_library_file':
$filename = getfield("doc_file","$table","id","$id");
// delete the file attached to this applicant
if($filename) @$del_file = @unlink($doc_dir.$applicant_id."/".$filename);
$sql = "UPDATE $table SET doc_file='' WHERE id=$id and applicant_id = '$applicant_id'";
$result = mysql_query($sql);
header("Location: apply_online_doc.php?Action=edit&applicant_id=$applicant_id&table=$table&id=$id");
break;
case 'web_doc_library':
$document = getdata_one("*","web_doc_library","id",$id);
unlink('uploads/documents/'.$document['applicant_id'].'/'.$document['doc_file']);
$sql = "delete from web_doc_library where id='$id'";
mysql_query($sql,$db);
header("Location: apply_online_document.php?applicant_id=$applicant_id&msg='Deleted'");
break;
case 'web_doc':
$filename = getfield("doc_file","$table","id","$id");
// delete the file attached to this applicant
if($filename) @$del_file = @unlink($doc_dir.$applicant_id."/".$filename);
$sql = "DELETE FROM $table WHERE id=$id and applicant_id = '$applicant_id'";
$result = mysql_query($sql);
echo mysql_error();
header("Location: apply_online_doc.php?Action=edit&applicant_id=$applicant_id&table=$table&msg=One(1) document record deleted.");
break;
case 'myresume':
$filename = getfield("resumefile",$table,"applicant_id",$applicant_id);
// delete the file attached
if($filename){
$del_file = @unlink($doc_dir.$applicant_id."/".$filename);
}
if($del_file){
$sql = "UPDATE $table SET resumefile='' where applicant_id='$applicant_id'";
mysql_query($sql);
echo mysql_error();
header("Location: apply_online.php?applicant_id=$applicant_id&resume=1&whatapply=$whatapply&msg=resume was successfully deleted");
} else{
header("Location: apply_online.php?applicant_id=$applicant_id&resume=1&whatapply=$whatapply&msg=sorry an error occured, pls try again later");
}
break;
case 'attachments':
$filename = getfield("doc_file",$atttable,"id",$id);
// delete the file attached
if($filename){
$del_file = @unlink($doc_dir.$applicant_id."/".$filename);
}
if($del_file){
$sql = "DELETE FROM $atttable WHERE id=$id";
mysql_query($sql);
echo mysql_error();
header("Location: apply_online.php?applicant_id=$applicant_id&resume=1&whatapply=$whatapply&msg=file was successfully deleted");
}
else{
header("Location: apply_online.php?applicant_id=$applicant_id&resume=1&whatapply=$whatapply&msg=sorry an error occured, pls try again later");
}
break;
case 'picture':
if($picture) @$del_file = unlink($pic_dir.$picture);
$sql = "UPDATE $table SET picture='' WHERE applicant_id='$applicant_id'";
$result = mysql_query($sql);
echo mysql_error();
if($result){
if($table=='personal') {
header("Location: apply_online.php?applicant_id=$applicant_id&table=$table&action=check_again&whatapply=$whatapply");
} else {
header("Location: apply_online.php?applicant_id=$applicant_id&table=$table&action=check&whatapply=$whatapply");
}
}
break;
case 'web_education':
$sql = "delete from web_education where id='$id'";
mysql_query($sql,$db);
header("Location: apply_online_education.php?applicant_id=$applicant_id");
break;
case 'web_employment':
$sql = "delete from web_employment where id='$id'";
mysql_query($sql,$db);
header("Location: apply_online_employment.php?applicant_id=$applicant_id");
break;
case 'web_training':
$sql = "delete from web_training where training_id='$id'";
mysql_query($sql,$db);
header("Location: apply_online_training.php?applicant_id=$applicant_id");
break;
case 'removefile':
$document = getdata_one("*","web_doc_library","id",$id);
unlink('uploads/documents/'.$document['applicant_id'].'/'.$document['doc_file']);
$sql = "update web_doc_library set doc_file='' where id='$id'";
mysql_query($sql,$db);
break;
}
?>