예제 #1
0
파일: db_funs.inc.php 프로젝트: Khum/SDFU
function InsertUpdateRecord($fields, $table, $pk = 'id')
{
    if (isset($fields[$pk]) && $fields[$pk] > 0) {
        $sql = "UPDATE `{$table}` SET ";
        foreach ($fields as $k => $v) {
            if ($k == $pk) {
                continue;
            } else {
                if ($v === 'now()') {
                    $sql .= "`{$k}` = now(), ";
                } else {
                    $sql .= "`{$k}` = '" . Encode($v) . "', ";
                }
            }
        }
        $sql = rtrim($sql, ", ");
        if (is_array($fields[$pk]) && !empty($fields[$pk])) {
            $sql .= " where `{$pk}` in ('" . implode("','", $fields[$pk]) . "') ";
        } else {
            $sql .= " where `{$pk}` = '" . Encode($fields[$pk]) . "'";
        }
        //echo $sql; return $fields[$pk];
        Query($sql);
        // if there was no update.. insert the record
        if (mysql_affected_rows() == 0) {
            //echo 'true';
            if (!IsExist($table, $pk, $fields[$pk])) {
                return InsertUpdateRecord($fields, $table);
            }
        }
        return $fields[$pk];
    } else {
        $sql = "INSERT INTO `{$table}` (";
        $values = ") VALUES (";
        foreach ($fields as $k => $v) {
            $sql .= "`{$k}`, ";
            if ($v === 'now()') {
                $values .= " now(), ";
            } else {
                $values .= "'" . Encode($v) . "', ";
            }
        }
        $sql = rtrim($sql, ", ");
        $values = rtrim($values, ", ") . ")";
        //echo $sql.$values; exit;
        if (Query($sql . $values)) {
            return mysql_insert_id();
        } else {
            return NULL;
        }
    }
}
예제 #2
0
    //         }else{
    //             $quotation_attraction_tickets = 1;
    //         }
    //         if($_POST['quotation_meals']!='on'){
    //             $quotation_meals = 0;
    //         }else{
    //             $quotation_meals = 1;
    //         }
    //         if($_POST['quotation_transfers']!='on'){
    //             $quotation_transfers = 0;
    //         }else{
    //             $quotation_transfers = 1;
    //         }
    $update_data = array();
    $update_data = array_copy('id,country_residence,destination,source,handled_by,agent_name,client_name,email,in_date,tr_date,arrival_date,arrival_option,number_of_night,adults,child,infant,currency,budget_from,budget_to,remarks,hotel_start_preference,status' . $dated, $_POST);
    InsertUpdateRecord($update_data, DB_TABLE_PREFIX . 'inquiry', 'id');
    $message = "Inquiry has beed updated";
    enqueueMsg($message, "success", "inquiry.php");
}
if (isset($_GET['id'])) {
    $id = $_GET["id"];
    $where = array('id' => $id);
    $result_arr = getRows(DB_TABLE_PREFIX . 'inquiry', $where);
    if ($result_arr['total_recs'] > 0) {
        $result = $result_arr['result'];
        $row_data = GetArr($result);
        extract($row_data);
        $var_clear = false;
    } else {
        enqueueMsg('Invalid record id.', "alert");
    }
예제 #3
0
         InsertUpdateRecord($update_schdule_M4, DB_TABLE_PREFIX . 'schedule_m4', 'id');
     } else {
         if ($month4 != "") {
             $update_schdule_M4 = array('month' => $month4, 'monday' => $monday4, 'tuesday' => $tuesday4, 'wednesday' => $wednesday4, 'thursday' => $thursday4, 'friday' => $friday4, 'saturday' => $saturday4, 'sunday' => $sunday4, 'product_id' => $p_id);
             InsertUpdateRecord($update_schdule_M4, DB_TABLE_PREFIX . 'schedule_m4', 'id');
         }
     }
     $allowedExts = array("gif", "jpeg", "jpg", "png");
     if (!empty($_FILES["image"]["name"])) {
         $path_parts = pathinfo($_FILES["image"]["name"]);
         $extension = $path_parts['extension'];
         if (($_FILES["image"]["type"] == "image/gif" || $_FILES["image"]["type"] == "image/jpeg" || $_FILES["image"]["type"] == "image/jpg" || $_FILES["image"]["type"] == "image/pjpeg" || $_FILES["image"]["type"] == "image/x-png" || $_FILES["image"]["type"] == "image/png") && in_array($extension, $allowedExts)) {
             $fileName = "product_" . $product_id . '.' . $extension;
             move_uploaded_file($_FILES["image"]["tmp_name"], "../img/products/" . $fileName);
             $update_image = array('image' => $fileName, 'id' => $product_id);
             InsertUpdateRecord($update_image, DB_TABLE_PREFIX . 'product', 'id');
         } else {
             enqueueMsg("Image type does not uploaded, Invalid image file.", "error", 'product.php', false);
         }
     }
     //            $message = "Record has beed " . ($id > 0 ? 'updated' : 'added') . ".";
     //            enqueueMsg($message, "success");
     if ($_GET['id'] > 0) {
         header("location:product.php?id=" . $_GET['id']);
     } else {
         $message = "Record has beed " . ($id > 0 ? 'updated' : 'added') . ".";
         enqueueMsg($message, "success");
     }
 } else {
     $msg = displayMsg('This slug "' . $slug . '" already is use.', 'error');
     $var_clear = false;
예제 #4
0
파일: services.php 프로젝트: Khum/SDFU
$msg = deQueueMsg();
$var_clear = true;
if (!empty($_POST)) {
    extract($_POST);
    if (isset($_POST['is_active'])) {
        $_POST['is_active'] = 'Y';
    } else {
        $_POST['is_active'] = 'N';
    }
    if (empty($services)) {
        $msg = displayMsg('Enter Service name.', 'error');
        $var_clear = false;
    } else {
        $update_data = array();
        $update_data = array_copy('id,services,price,sort_order,is_active');
        $new_id = InsertUpdateRecord($update_data, DB_TABLE_PREFIX . 'services', 'id');
        $message = "Record has beed " . ($id > 0 ? 'updated' : 'added') . ".";
        enqueueMsg($message, $message_type);
    }
}
if (isset($_GET['id'])) {
    $id = $_GET["id"];
    $where = array('id' => $id);
    $result_arr = getRows(DB_TABLE_PREFIX . 'services', $where);
    if ($result_arr['total_recs'] > 0) {
        $result = $result_arr['result'];
        $row_data = GetArr($result);
        extract($row_data);
        $var_clear = false;
    } else {
        enqueueMsg('Invalid record id.', "alert");
예제 #5
0
파일: category.php 프로젝트: Khum/SDFU
    }
    if (isset($_POST['is_active'])) {
        $_POST['is_active'] = 'Y';
    } else {
        $_POST['is_active'] = 'N';
    }
    if (empty($slug)) {
        $msg = displayMsg('Enter slug.', 'error');
        $var_clear = false;
    } else {
        $slugResult = getRows(DB_TABLE_PREFIX . 'category', 'WHERE ' . implode(' AND ', $slugWhere));
        $message_type = 'success';
        if ($slugResult['total_recs'] == 0) {
            $update_data = array();
            $update_data = array_copy('id,title,slug,description,sort_order,is_active' . $dated, $_POST);
            $new_id = InsertUpdateRecord($update_data, DB_TABLE_PREFIX . 'category', 'id');
            $message = "Record has beed " . ($id > 0 ? 'updated' : 'added') . ".";
            enqueueMsg($message, $message_type);
        } else {
            $msg = displayMsg('This slug "' . $slug . '" already is use.', 'error');
            $var_clear = false;
        }
    }
}
if (isset($_GET['id'])) {
    $id = $_GET["id"];
    $where = array('id' => $id);
    $result_arr = getRows(DB_TABLE_PREFIX . 'category', $where);
    if ($result_arr['total_recs'] > 0) {
        $result = $result_arr['result'];
        $row_data = GetArr($result);
예제 #6
0
파일: order-update.php 프로젝트: Khum/SDFU
    } else {
        $_POST['welcome'] = '0';
    }
    if ($_POST['dinner'] == 'on') {
        $_POST['dinner'] = '1';
    } else {
        $_POST['dinner'] = '0';
    }
    if ($_POST['bike'] == 'on') {
        $_POST['bike'] = '1';
    } else {
        $_POST['bike'] = '0';
    }
    $update_data = array();
    $update_data = array_copy('id,full_name,email,mobile,hotel_name,hotel_address,room_no,total_adult,total_child,tour_date,per_adult_price,per_child_price,total_adult_price,total_child_price,total_price,payment_mod,status,last_updated,guide,pickup,insurance,coffee,coffee,welcome,dinner,bike,delivery_type,delivery_time' . $dated, $_POST);
    InsertUpdateRecord($update_data, DB_TABLE_PREFIX . 'order', 'id');
    $message = "Order has beed updated";
    enqueueMsg($message, "success", "order.php");
}
if (isset($_GET['id'])) {
    $id = $_GET["id"];
    $where = array('id' => $id);
    $result_arr = getRows(DB_TABLE_PREFIX . 'order', $where);
    if ($result_arr['total_recs'] > 0) {
        $result = $result_arr['result'];
        $row_data = GetArr($result);
        extract($row_data);
        $var_clear = false;
    } else {
        enqueueMsg('Invalid record id.', "alert");
    }