예제 #1
1
function login()
{
    if ($username == null) {
        echo "E-Mail is a required field.";
    } else {
        if ($password == null) {
            echo "Password is a required field.";
        } else {
            ProgressIndicator::Show();
            $url = "http://demo.kikapptools.com/Gastos/crud/Login.php";
            $httpClient_post = new httpClient();
            $inputMetodo = new InputText();
            $inputMetodo->setValue("login");
            $httpClient_post->addVariable('username', $username);
            $httpClient_post->addVariable('password', $password);
            $result = $httpClient_post->Execute('POST', $url);
            $id_user = new InputText();
            $struct = array("response" => DataType::Character(50));
            Data::FromJson($struct, $result);
            $id_user = $struct['response'];
            ProgressIndicator::Hide();
            if ($id_user != "0") {
                StorageAPI::Set("token", $id_user);
                AndroidAction::GoHome();
            } else {
                echo "Wrong user or password";
            }
        }
    }
}
예제 #2
0
function clickme()
{
    StorageAPI::Set("token", $input);
    $name = new InputText();
    $name = StorageAPI::Get("token");
    echo "Your name is: " . $name;
}
예제 #3
0
function save()
{
    if ($email == null) {
        echo "EMail is a required field.";
    } else {
        if ($password == null) {
            echo "Password is a required field.";
        } else {
            if ($password != $password_2) {
                echo "Please make sure your passwords match.";
            } else {
                ProgressIndicator::Show();
                $url = "http://demo.kikapptools.com/Gastos/crud/Register.php";
                $http = new httpClient();
                $http->addVariable('username', $email);
                $http->addVariable('passcode', $password);
                //lo de pasar la clave a md5 lo hace el Register.php
                $result = $http->Execute('POST', $url);
                $struct = array("id_usuario" => DataType::Character(101));
                Data::FromJson($struct, $result);
                $id_user = new InputText(100);
                $id_user = $struct['id_usuario'];
                if ($id_user == "0") {
                    echo "User already signed up";
                } else {
                    echo "Signed up succesfully.";
                    StorageAPI::Set("token", $id_user);
                    AndroidAction::GoHome();
                }
            }
        }
    }
}
예제 #4
0
function login()
{
    if ($email == null) {
        echo "E-Mail is a required field.";
    } else {
        if ($pass == null) {
            echo "Password is a required field.";
        } else {
            ProgressIndicator::Show();
            $url = "http://demo.kikapptools.com/magento/apiKikApp/api.php?metodo=login";
            $httpClient_post = new httpClient();
            $httpClient_post->addVariable('email', $email);
            $httpClient_post->addVariable('password', $pass);
            $result = $httpClient_post->Execute('POST', $url);
            $customerToken = new InputText();
            $userName = new InputText();
            $response = array("customerToken" => DataType::Character(150), "userName" => DataType::Character(150));
            Data::FromJson($response, $result);
            $customerToken = $response['customerToken'];
            $userName = $response['userName'];
            ProgressIndicator::Hide();
            if ($customerToken != "") {
                StorageAPI::Set("token", $customerToken);
                StorageAPI::Set("userName", $userName);
                AndroidAction::GoHome();
            } else {
                echo "Invalid user";
            }
        }
    }
}
예제 #5
0
function clientStart()
{
    $token = StorageAPI::Get("token");
    $url = "http://demo.kikapptools.com/Gastos/crud/getAccount.php";
    $httpClient = new httpClient();
    $httpClient->addVariable("id", $token);
    $result = $httpClient->Execute('POST', $url);
    $struct = array("money" => DataType::Numeric(11));
    Data::FromJson($struct, $result);
    $input = $struct['money'];
}
예제 #6
0
function confirm()
{
    $token = StorageAPI::Get("token");
    ProgressIndicator::ShowWithTitle("Adding budget...");
    $httpUpdate = new httpClient();
    $httpUpdate->addVariable('money', $money_value);
    $httpUpdate->addVariable('dates', $input_date);
    $httpUpdate->addVariable("id", $token);
    $httpUpdate->Execute('POST', "http://demo.kikapptools.com/Gastos/crud/updateAccount.php");
    ProgressIndicator::Hide();
    AndroidAction::GoHome();
}
예제 #7
0
function confirm()
{
    $token = StorageAPI::Get("token");
    ProgressIndicator::ShowWithTitle("Inserting movement...");
    $httpUpdate = new httpClient();
    $httpUpdate->addVariable('value', $input_value);
    $httpUpdate->addVariable('moveType', $moveType);
    $httpUpdate->addVariable('description', $input_desc);
    $httpUpdate->addVariable("id", $token);
    $httpUpdate->addVariable('idCat', $dc_cat);
    $httpUpdate->addVariable('dates', $input_date);
    $httpUpdate->Execute('POST', "http://demo.kikapptools.com/Gastos/crud/insertMovements.php");
    ProgressIndicator::Hide();
    AndroidAction::GoHome();
}
예제 #8
0
function logout()
{
    StorageAPI::Remove("token");
    AndroidAction::GoHome();
}
예제 #9
0
function add_cart()
{
    $token = new InputText(80);
    $token = StorageAPI::Get("token");
    if ($token != null) {
        ProgressIndicator::Show();
        $url_cart = "http://demo.kikapptools.com/magento/apiKikApp/api.php?metodo=addProductToCart&qty=1&productId=" . $id . "&customerToken=" . $token;
        $hc = new httpClient();
        $rs_cart = $hc->Execute("GET", $url_cart);
        $sdt_rs = array("error" => DataType::Character(300));
        Data::FromJson($sdt_rs, $rs_cart);
        $rs = new InputText(300);
        $rs = $sdt_rs['error'];
        ProgressIndicator::Hide();
        if ($rs == "0") {
            $win->Open("ShoppingCart", $token);
        } else {
            echo $rs;
        }
    } else {
        $win->Open("Login");
    }
}
예제 #10
0
function Refresh()
{
    $token = StorageAPI::Get("token");
    $url = "http://demo.kikapptools.com/magento/apiKikApp/api.php?metodo=userCartTotal&customerToken=" . $token;
    $httpClient = new httpClient();
    $result = $httpClient->Execute("GET", $url);
    $struct = array("total" => DataType::Character(10), "tax" => DataType::Character(10), "shipping" => DataType::Character(10), "subtotal" => DataType::Character(10));
    Data::FromJson($struct, $result);
    $total = $struct["total"];
    $shipping = $struct["shipping"];
    $tax = $struct["tax"];
    $subtotal = $struct["subtotal"];
    if ($subtotal == 0) {
        $table_result->setVisible(false);
    } else {
        $table_result->setVisible(true);
    }
}
예제 #11
0
/**
 * Function ClientStart.
 * This function is execute in event user and is the first event in execute
 */
function ClientStart()
{
    $token = StorageAPI::Get("token");
    //$userName = StorageAPI::Get("userName");
    if ($token == null) {
        $table_UserData->setVisible(false);
        $table_mycart->setVisible(false);
        $table_logout->setVisible(false);
        $table_login->setVisible(true);
        $headerLabel->setValue("Magento KikApp Store");
    } else {
        $table_login->setVisible(false);
        $table_UserData->setVisible(true);
        $table_mycart->setVisible(true);
        $table_logout->setVisible(true);
        $headerLabel = StorageAPI::Get("userName");
    }
}
예제 #12
0
function ClientStart()
{
    $token = new InputText(80);
    $token = StorageAPI::Get("token");
    if ($token == null) {
        $btn_cart->setVisible(false);
    } else {
        $btn_cart->setVisible(true);
    }
}