示例#1
0
        if ($s->check(false, $token, "CREATE_WDW")) {
            $o->updatedby = $xoopsUser->getVar('uid');
            //get current uid
            if ($o->updateCountry()) {
                //if data save successfully
                redirect_header("country.php?action=edit&country_id={$o->country_id}", $pausetime, "Your data is saved.");
            } else {
                redirect_header("country.php?action=edit&country_id={$o->country_id}", $pausetime, "Warning! Can't save the data, please make sure all value is insert properly.");
            }
        } else {
            redirect_header("country.php?action=edit&country_id={$o->country_id}", $pausetime, "Warning! Can't save the data, please make sure all value is insert properly.");
        }
        break;
    case "delete":
        if ($s->check(false, $token, "CREATE_WDW")) {
            if ($o->deleteCountry($o->country_id)) {
                redirect_header("country.php", $pausetime, "Data removed successfully.");
            } else {
                redirect_header("country.php?action=edit&country_id={$o->country_id}", $pausetime, "Warning! Can't delete data from database.");
            }
        } else {
            redirect_header("country.php?action=edit&country_id={$o->country_id}", $pausetime, "Warning! Can't delete data from database.");
        }
        break;
    default:
        $token = $s->createToken(120, "CREATE_WDW");
        //$o->orgctrl=$selectionOrg->selectionOrg($o->createdby,0);
        $o->getInputForm("new", 0, $token);
        $o->showCountryTable("WHERE country_id>0", "ORDER BY defaultlevel,country_name");
        break;
}
        Country::setDataOperationBusiness($registry[$nameDataBase]);
        $idTransaction = $transaction->insertTransaction(array(Country::$business, Country::$update, Country::$descriptionBusiness));
        $data = array($_POST['NAME'], $_POST['EDIT']);
        $statusTransactionDB = $catalog->updateCountry($data, $idTransaction);
        if ($statusTransactionDB > 0) {
            Forms::setMessage('SUCCESS', $v_label["SHORT_MESSAGE_OK_EDIT"], $v_label["DETAIL_MESSAGE_OK_EDIT"]);
        } else {
            Forms::setMessage('ERROR', $v_label["SHORT_MESSAGE_NOOK_EDIT"], $v_label["DETAIL_MESSAGE_NOOK_EDIT"]);
        }
        break;
    case 'DELETE':
        $transaction = new Transaction($registry[$nameDataBase]);
        Country::setDataOperationBusiness($registry[$nameDataBase]);
        $idTransaction = $transaction->insertTransaction(array(Country::$business, Country::$update, Country::$descriptionBusiness));
        $data = array($_GET['DELETE']);
        $statusTransactionDB = $catalog->deleteCountry($data, $idTransaction);
        if ($statusTransactionDB > 0) {
            Forms::setMessage('SUCCESS', $v_label["SHORT_MESSAGE_OK_DELETE"], $v_label["DETAIL_MESSAGE_OK_DELETE"]);
        } else {
            Forms::setMessage('ERROR', $v_label["SHORT_MESSAGE_NOOK_DELETE"], $v_label["DETAIL_MESSAGE_NOOK_DELETE"]);
        }
        break;
    default:
        break;
}
// Obtener lista
$list = $catalog->getListCountry();
?>
<div class="grid_10">
    <div class="box round first">
        <h2><?php 
示例#3
0
<?php

require_once "../config/Autoload.php";
//Autoload class
require_once "../libs/datafilter.php";
//form validate
$method = $_SERVER['REQUEST_METHOD'];
//variable contains the name of the "Request method"
if ($method == 'DELETE') {
    parse_str(file_get_contents("php://input"), $editData);
    //$editData - variable containe delete Data
    $editData = trimAll($editData);
    //validate PUT data
    $editData = htmlAll($editData);
    //validate PUT data
    $deleteCity = Main::deleteData($editData['del_country'], $editData['del_city'], $editData['del_language']);
    //delete city
    $editData['info'] = 'Successfully removed';
    $lastCity = City::lastCity($editData['del_country']);
    //if the country have only 1 city delete the country and language
    if (mysqli_num_rows($lastCity) == 0) {
        $deleteCountryLanguge = Language::deleteLanguage($editData['del_language']);
        //delete language
        $deleteCountry = Country::deleteCountry($editData['del_country']);
        //delete country
        $editData['info'] = 'Successfully removed';
    }
    echo json_encode($editData);
    //send response data to Jquery
}