MMCT TEAM
Server IP : 162.214.80.37  /  Your IP : 216.73.216.83
Web Server : Apache
System : Linux sh013.webhostingservices.com 4.19.286-203.ELK.el7.x86_64 #1 SMP Wed Jun 14 04:33:55 CDT 2023 x86_64
User : imyrqtmy ( 2189)
PHP Version : 8.2.18
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON
Directory (0755) :  /home2/imyrqtmy/public_html/builty/admin/

[  Home  ][  C0mmand  ][  Upload File  ]

Current File : /home2/imyrqtmy/public_html/builty/admin/add_builty.php
<?php
include("inc/config.php");

if (isset($_POST['add_builty'])) {
    // Fetch form data
    $emp_id = $_POST['emp_id'];
    $invoice_no = $_POST['invoice_no'];
    $origin = $_POST['origin'];
    $consignor_state = $_POST['consignor_state'];
    $destination = $_POST['destination'];
    $origin_address = $_POST['origin_address'];
    $origin_gst = $_POST['origin_gst'];
    $origin_phone = $_POST['origin_phone'];
    $origin_eway = $_POST['origin_eway'];
    $grno = $_POST['grno'];
    $state = $_POST['state'];
    $sgst_amount = $_POST['sgst_amount'];
    $cgst_amount = $_POST['cgst_amount'];
    $sgst_rate = $_POST['sgst_rate'];
    $cgst_rate = $_POST['cgst_rate'];
    $qacl = $_POST['qacl'];
    $transport_by = $_POST['transport_by'];
    $booking_date = $_POST['booking_date'];
    $booking_time = $_POST['booking_time'];
    $destination_address = $_POST['destination_address'];
    $destination_gst = $_POST['destination_gst'];
    $destination_phone = $_POST['destination_phone'];
    $destination_eway = $_POST['destination_eway'];
    $pkg_total = $_POST['pkg_total'];
    $pkg_type = $_POST['pkg_type'];
    $party_invoice = $_POST['party_invoice'];
    $party_name = $_POST['party_name'];

    function handleArrayInput($input) {
        return is_array($input) ? implode(",", $input) : $input;
    }

    $length = handleArrayInput($_POST['length']);
    $width = handleArrayInput($_POST['width']);
    $height = handleArrayInput($_POST['height']);
    $charge_weight = handleArrayInput($_POST['charge_weight']);
    $demention_quantity = handleArrayInput($_POST['demention_quantity']);
    $volume = handleArrayInput($_POST['volume']);
    $total_weight = handleArrayInput($_POST['total_weight']);
    $box_weight = handleArrayInput($_POST['box_weight']);
    $box_quantity = handleArrayInput($_POST['box_quantity']);
    $total_box_weight = handleArrayInput($_POST['total_box_weight']);
    $total_charged_weight = $_POST['total_charged_weight'];
    $saidtocontent = $_POST['saidtocontent'];
    $quantity = $_POST['quantity'];
    $gross_weight = $_POST['gross_weight'];
    $amount = $_POST['amount'];
    $consignee = $_POST['consignee'];
    $consignor = $_POST['consignor'];
    $freight_rate = $_POST['freight_rate'];
    $freight_amount = $_POST['freight_amount'];
    $cod_rate = $_POST['cod_rate'];
    $cod_amount = $_POST['cod_amount'];
    $fov_rate = $_POST['fov_rate'];
    $fov_amount = $_POST['fov_amount'];
    $doc_rate = $_POST['doc_rate'];
    $doc_amount = $_POST['doc_amount'];
    $cartage_rate = $_POST['cartage_rate'];
    $cartage_amount = $_POST['cartage_amount'];
    $labour_rate = $_POST['labour_rate'];
    $labour_amount = $_POST['labour_amount'];
    $other_rate = $_POST['other_rate'];
    $other_amount = $_POST['other_amount'];
    $gst_rate = $_POST['gst_rate'];
    $gst_amount = $_POST['gst_amount'];
    $total_amount = $_POST['total_amount'];
    $delivery_detail = $_POST['delivery_detail'];
    $delivery_date = $_POST['delivery_date'];
    $ttb_origin = $_POST['ttb_origin'];
    $paid = $_POST['paid'];
    $status = $_POST['status'];

    // Handle optional file upload
    $attachment = "";
    if (isset($_FILES['attachment']) && $_FILES['attachment']['error'] == 0) {
        $allowed_exts = ['jpg', 'jpeg', 'png', 'gif', 'pdf'];
        $file_ext = strtolower(pathinfo($_FILES['attachment']['name'], PATHINFO_EXTENSION));

        if (in_array($file_ext, $allowed_exts)) {
            $upload_dir = "sublier/";
            if (!file_exists($upload_dir)) {
                mkdir($upload_dir, 0777, true);
            }

            $new_file_name = uniqid("file_") . "." . $file_ext;
            $upload_path = $upload_dir . $new_file_name;

            if (move_uploaded_file($_FILES['attachment']['tmp_name'], $upload_path)) {
                $attachment = $new_file_name;
            }
        }
    }

    // Insert into DB
    $query = "INSERT INTO `builties` (
        `emp_id`, `invoice_no`, `origin`, `consignor_state`, `destination`, `origin_address`, `origin_gst`, `origin_phone`, `origin_eway`, `grno`, `state`,
        `sgst_amount`, `sgst_rate`, `cgst_amount`, `cgst_rate`, `qacl`, `transport_by`, `booking_date`, `booking_time`, `destination_address`, `destination_gst`,
        `destination_phone`, `destination_eway`, `pkg_total`, `pkg_type`, `party_invoice`, `party_name`, `length`, `width`, `height`, `charge_weight`,
        `demention_quantity`, `volume`, `total_weight`, `box_weight`, `box_quantity`, `total_box_weight`, `total_charged_weight`, `saidtocontent`, `quantity`,
        `gross_weight`, `amount`, `consignee`, `consignor`, `freight_rate`, `freight_amount`, `cod_rate`, `cod_amount`, `doc_rate`, `doc_amount`,
        `fov_rate`, `fov_amount`, `cartage_rate`, `cartage_amount`, `labour_rate`, `labour_amount`, `other_rate`, `other_amount`, `gst_rate`, `gst_amount`,
        `total_amount`, `delivery_detail`, `delivery_date`, `ttb_origin`, `paid`, `status`, `attachment`
    ) VALUES (
        '$emp_id', '$invoice_no', '$origin', '$consignor_state', '$destination', '$origin_address', '$origin_gst', '$origin_phone', '$origin_eway', '$grno', '$state',
        '$sgst_amount', '$sgst_rate', '$cgst_amount', '$cgst_rate', '$qacl', '$transport_by', '$booking_date', '$booking_time', '$destination_address', '$destination_gst',
        '$destination_phone', '$destination_eway', '$pkg_total', '$pkg_type', '$party_invoice', '$party_name', '$length', '$width', '$height', '$charge_weight',
        '$demention_quantity', '$volume', '$total_weight', '$box_weight', '$box_quantity', '$total_box_weight', '$total_charged_weight', '$saidtocontent', '$quantity',
        '$gross_weight', '$amount', '$consignee', '$consignor', '$freight_rate', '$freight_amount', '$cod_rate', '$cod_amount', '$doc_rate', '$doc_amount',
        '$fov_rate', '$fov_amount', '$cartage_rate', '$cartage_amount', '$labour_rate', '$labour_amount', '$other_rate', '$other_amount', '$gst_rate', '$gst_amount',
        '$total_amount', '$delivery_detail', '$delivery_date', '$ttb_origin', '$paid', '$status', '$attachment'
    )";

    $query_run = mysqli_query($conn, $query);

    if ($query_run) {
        $_SESSION['status'] = "Data Uploaded Successfully";
        header('Location: view-builty.php');
        exit;
    } else {
        $_SESSION['status'] = "Data Not Uploaded Successfully";
        header('Location: builty.php');
        exit;
    }
}







if (isset($_POST['update_builty'])) {
    $id = $_POST['id'];

    // Fetch form values like in insert code
    $emp_id = $_POST['emp_id'];
    $invoice_no = $_POST['invoice_no'];
    $origin = $_POST['origin'];
    $consignor_state = $_POST['consignor_state'];
    $destination = $_POST['destination'];
    $origin_address = $_POST['origin_address'];
    $origin_gst = $_POST['origin_gst'];
    $origin_phone = $_POST['origin_phone'];
    $origin_eway = $_POST['origin_eway'];
    $grno = $_POST['grno'];
    $state = $_POST['state'];
    $sgst_amount = $_POST['sgst_amount'];
    $cgst_amount = $_POST['cgst_amount'];
    $sgst_rate = $_POST['sgst_rate'];
    $cgst_rate = $_POST['cgst_rate'];
    $qacl = $_POST['qacl'];
    $transport_by = $_POST['transport_by'];
    $booking_date = $_POST['booking_date'];
    $booking_time = $_POST['booking_time'];
    $destination_address = $_POST['destination_address'];
    $destination_gst = $_POST['destination_gst'];
    $destination_phone = $_POST['destination_phone'];
    $destination_eway = $_POST['destination_eway'];
    $pkg_total = $_POST['pkg_total'];
    $pkg_type = $_POST['pkg_type'];
    $party_invoice = $_POST['party_invoice'];
    $party_name = $_POST['party_name'];

    function handleArrayInput($input) {
        return is_array($input) ? implode(",", $input) : $input;
    }

    $length = handleArrayInput($_POST['length']);
    $width = handleArrayInput($_POST['width']);
    $height = handleArrayInput($_POST['height']);
    $charge_weight = handleArrayInput($_POST['charge_weight']);
    $demention_quantity = handleArrayInput($_POST['demention_quantity']);
    $volume = handleArrayInput($_POST['volume']);
    $total_weight = handleArrayInput($_POST['total_weight']);
    $box_weight = handleArrayInput($_POST['box_weight']);
    $box_quantity = handleArrayInput($_POST['box_quantity']);
    $total_box_weight = handleArrayInput($_POST['total_box_weight']);
    $total_charged_weight = $_POST['total_charged_weight'];
    $saidtocontent = $_POST['saidtocontent'];
    $quantity = $_POST['quantity'];
    $gross_weight = $_POST['gross_weight'];
    $amount = $_POST['amount'];
    $consignee = $_POST['consignee'];
    $consignor = $_POST['consignor'];
    $freight_rate = $_POST['freight_rate'];
    $freight_amount = $_POST['freight_amount'];
    $cod_rate = $_POST['cod_rate'];
    $cod_amount = $_POST['cod_amount'];
    $fov_rate = $_POST['fov_rate'];
    $fov_amount = $_POST['fov_amount'];
    $doc_rate = $_POST['doc_rate'];
    $doc_amount = $_POST['doc_amount'];
    $cartage_rate = $_POST['cartage_rate'];
    $cartage_amount = $_POST['cartage_amount'];
    $labour_rate = $_POST['labour_rate'];
    $labour_amount = $_POST['labour_amount'];
    $other_rate = $_POST['other_rate'];
    $other_amount = $_POST['other_amount'];
    $gst_rate = $_POST['gst_rate'];
    $gst_amount = $_POST['gst_amount'];
    $total_amount = $_POST['total_amount'];
    $delivery_detail = $_POST['delivery_detail'];
    $delivery_date = $_POST['delivery_date'];
    $ttb_origin = $_POST['ttb_origin'];
    $paid = $_POST['paid'];
    $status = $_POST['status'];

    // Handle file upload
    $attachment = $_POST['attachment_old'];
    if (isset($_FILES['attachment']) && $_FILES['attachment']['error'] == 0) {
        $allowed_exts = ['jpg', 'jpeg', 'png', 'gif', 'pdf'];
        $file_ext = strtolower(pathinfo($_FILES['attachment']['name'], PATHINFO_EXTENSION));

        if (in_array($file_ext, $allowed_exts)) {
            $upload_dir = "sublier/";
            if (!file_exists($upload_dir)) {
                mkdir($upload_dir, 0777, true);
            }

            $new_file_name = uniqid("file_") . "." . $file_ext;
            $upload_path = $upload_dir . $new_file_name;

            if (move_uploaded_file($_FILES['attachment']['tmp_name'], $upload_path)) {
                $attachment = $new_file_name;
            }
        }
    }

    $query = "UPDATE `builties` SET
        emp_id='$emp_id', invoice_no='$invoice_no', origin='$origin', consignor_state='$consignor_state',
        destination='$destination', origin_address='$origin_address', origin_gst='$origin_gst', origin_phone='$origin_phone',
        origin_eway='$origin_eway', grno='$grno', state='$state', sgst_amount='$sgst_amount', sgst_rate='$sgst_rate',
        cgst_amount='$cgst_amount', cgst_rate='$cgst_rate', qacl='$qacl', transport_by='$transport_by',
        booking_date='$booking_date', booking_time='$booking_time', destination_address='$destination_address',
        destination_gst='$destination_gst', destination_phone='$destination_phone', destination_eway='$destination_eway',
        pkg_total='$pkg_total', pkg_type='$pkg_type', party_invoice='$party_invoice', party_name='$party_name',
        length='$length', width='$width', height='$height', charge_weight='$charge_weight', demention_quantity='$demention_quantity',
        volume='$volume', total_weight='$total_weight', box_weight='$box_weight', box_quantity='$box_quantity',
        total_box_weight='$total_box_weight', total_charged_weight='$total_charged_weight', saidtocontent='$saidtocontent',
        quantity='$quantity', gross_weight='$gross_weight', amount='$amount', consignee='$consignee', consignor='$consignor',
        freight_rate='$freight_rate', freight_amount='$freight_amount', cod_rate='$cod_rate', cod_amount='$cod_amount',
        doc_rate='$doc_rate', doc_amount='$doc_amount', fov_rate='$fov_rate', fov_amount='$fov_amount',
        cartage_rate='$cartage_rate', cartage_amount='$cartage_amount', labour_rate='$labour_rate', labour_amount='$labour_amount',
        other_rate='$other_rate', other_amount='$other_amount', gst_rate='$gst_rate', gst_amount='$gst_amount',
        total_amount='$total_amount', delivery_detail='$delivery_detail', delivery_date='$delivery_date',
        ttb_origin='$ttb_origin', paid='$paid', status='$status', attachment='$attachment'
        WHERE id='$id'";

    $run = mysqli_query($conn, $query);

    if ($run) {
        $_SESSION['status'] = "Data Updated Successfully";
        header('Location: view-builty.php');
        exit;
    } else {
        $_SESSION['status'] = "Data Not Updated";
        header('Location: builty-edit.php?id=' . $id);
        exit;
    }
}




// if (isset($_POST['update_builty'])) {
//     $id = $_POST['id'];
//     $emp_id = $_POST['emp_id'];
 
//     $origin = $_POST['origin'];
//     $destination = $_POST['destination'];
//     $origin_address = $_POST['origin_address'];

//     $origin_gst = $_POST['origin_gst'];
//     $origin_phone = $_POST['origin_phone'];
//     $origin_eway = $_POST['origin_eway'];
//     $grno = $_POST['grno'];
//     $qacl = $_POST['qacl'];
//     $transport_by = $_POST['transport_by'];
//     $booking_date = $_POST['booking_date'];
//     $booking_time = $_POST['booking_time'];
//     $destination_address = $_POST['destination_address'];
//     $destination_gst = $_POST['destination_gst'];
//     $destination_phone = $_POST['destination_phone'];
//     $destination_eway = $_POST['destination_eway'];
//     $pkg_total = $_POST['pkg_total'];
//     $pkg_type = $_POST['pkg_type'];
//     $party_invoice = $_POST['party_invoice'];
//     $party_name = $_POST['party_name'];
 

//      $length = $_POST['length'];
//       $width = $_POST['width'];
//       $height = $_POST['height'];
//       $charge_weight = $_POST['charge_weight'];
//       $demention_quantity = $_POST['demention_quantity'];
//       $volume = $_POST['volume'];
//       $total_weight = $_POST['total_weight'];
//       $box_weight = $_POST['box_weight'];
//       $box_quantity = $_POST['box_quantity'];
//       $total_box_weight = $_POST['total_box_weight'];
//       $total_charged_weight = $_POST['total_charged_weight'];


    

    
//     $saidtocontent = $_POST['saidtocontent'];
//     $quantity = $_POST['quantity'];
//     $gross_weight = $_POST['gross_weight'];
//     $charge_weight = $_POST['charge_weight'];
//     $amount = $_POST['amount'];
//     $consignee = $_POST['consignee'];
//     $consignor = $_POST['consignor'];
//     $freight_rate = $_POST['freight_rate'];
//     $freight_amount = $_POST['freight_amount'];
//     $cod_rate = $_POST['cod_rate'];
//     $cod_amount = $_POST['cod_amount'];
//     $doc_rate = $_POST['doc_rate'];
//     $doc_amount = $_POST['doc_amount'];
//     $fov_rate = $_POST['fov_rate'];
//     $fov_amount = $_POST['fov_amount'];
//     $cartage_rate = $_POST['cartage_rate'];
//     $cartage_amount = $_POST['cartage_amount'];
//     $labour_rate = $_POST['labour_rate'];
//     $labour_amount = $_POST['labour_amount'];

//     $other_rate = $_POST['other_rate'];
//     $other_amount = $_POST['other_amount'];
//     $gst_rate = $_POST['gst_rate'];
//     $gst_amount = $_POST['gst_amount'];
//     $total_amount = $_POST['total_amount'];
//     $delivery_detail = $_POST['delivery_detail'];
//     $delivery_date = $_POST['delivery_date'];
//     $ttb_origin = $_POST['ttb_origin'];
//     $to_pay = $_POST['to_pay'];
//     $paid = $_POST['paid'];
//     $status = $_POST['status'];


//     $query = "UPDATE `builties` SET 
//     `emp_id`='$emp_id',
//     `origin`='$origin',
//     `destination`='$destination',
//     `origin_address`='$origin_address',
//     `origin_gst`='$origin_gst',
//     `origin_phone`='$origin_phone',
//     `origin_eway`='$origin_eway',
//     `grno`='$grno',
//     `qacl`='$qacl',
//     `transport_by`='$transport_by',
//     `booking_date`='$booking_date',
//     `booking_time`='$booking_time',
//     `destination_address`='$destination_address',
//     `destination_gst`='$destination_gst',
//     `destination_phone`='$destination_phone',
//     `destination_eway`='$destination_eway',
//     `pkg_total`='$pkg_total',
//     `pkg_type`='$pkg_type',
//     `party_invoice`='$party_invoice',
//      `party_name`='$party_name',
//       `length`='$length',
//       `width`='$width',
//       `height`='$height',
//       `charge_weight`='$charge_weight',
//       `demention_quantity`='$demention_quantity',
//       `volume`='$volume',
//       `total_weight`='$total_weight',
//       `box_weight`='$box_weight',
//       `box_quantity`='$box_quantity',
//       `total_box_weight`='$total_box_weight',
//       `total_charged_weight`='$total_charged_weight',
//       `dimension`='$dimension',
//       `dimension`='$dimension',
//       `dimension`='$dimension',

//     `saidtocontent`='$saidtocontent',
//     `quantity`='$quantity',
//     `gross_weight`='$gross_weight',
//     `charge_weight`='$charge_weight',
//     `amount`='$amount',
//     `consignee`='$consignee',
//     `consignor`='$consignor',
//     `freight_rate`='$freight_rate',
//     `freight_amount`='$freight_amount',
//     `cod_rate`='$cod_rate',
//     `cod_amount`='$cod_amount',
//      `fov_rate`='$fov_rate',
//     `fov_amount`='$fov_amount',
//     `doc_rate`='$doc_rate',
//     `doc_amount`='$doc_amount',
//     `cartage_rate`='$cartage_rate',
//     `cartage_amount`='$cartage_amount',
//     `labour_rate`='$labour_rate',
//     `labour_amount`='$labour_amount',
//     `other_rate`='$other_rate',
//     `other_amount`='$other_amount',
//     `gst_rate`='$gst_rate',
//     `gst_amount`='$gst_amount',
//     `total_amount`='$total_amount',
//     `delivery_detail`='$delivery_detail',
//     `delivery_time`='$delivery_time',
//     `ttb_origin`='$ttb_origin',
//     `to_pay`='$to_pay',
//     `paid`='$paid',
//     `status`='$status'
// WHERE `id`='$id'";


//     $query_run = mysqli_query($conn, $query);

//     if ($query_run) {
//         $_SESSION['status'] = "Updated Successfully";
//         header('Location: view-builty.php');
//     } else {
//         $_SESSION['status'] = " Not Updated Successfully";
//         header('Location: view-builty.php');
//     }
// }



// if (isset($_POST['complete_project'])) {
//     $project_id = $_POST['project_id'];

 
//     $query = "UPDATE projects SET project_status = 'Complete' WHERE id = '$project_id'";
//     $query_run = mysqli_query($conn, $query);

//     if ($query_run) {
      
//         header("Location: view-project.php?status=success");
//         exit();
//     } else {
       
//         header("Location: view-project.php?status=error");
//         exit();
//     }
// } else {
//     header("Location: view-project.php");
//     exit();
// }




// delete

if (isset($_POST['delete_builty'])) {

    $id = $_POST['delete_id'];
    
    $query = "DELETE FROM `builties` WHERE id = '$id'";
    $query_run = mysqli_query($conn, $query);

    if ($query_run) {
        $_SESSION['status'] = "Deleted Successfully";
        header('Location: view-builty.php');
    } else {
        $_SESSION['status'] = "Not Deleted Successfully";
        header('Location: view-builty.php');
    }
}

?>

MMCT - 2023