<?php

$device_type = 1;

$linkProtocol = "";
$hrefName = "";
$unique_url  = "";

$groupExpenseHrefName = "";
$messExpenseHrefName = "";
$familyExpenseHrefName = "";

$imageName = "";
$alt = "";


$showText = "Use the App";

if ($expenseType == "1") {
    $linkProtocol = "expensecountge://";
} else if ($expenseType == "2") {
    $linkProtocol = "expensecountme://";
} else if ($expenseType == "3") {
    $linkProtocol = "expensecountfe://";
}

if ($device == "android") {
    $showText = "Use the Android App";
    $alt = "google play";

    if ($expenseType == "1") {
        $hrefName = "https://play.google.com/store/apps/details?id=com.expensecount.groupExpense";
    } else if ($expenseType == "2") {
        $hrefName = "https://play.google.com/store/apps/details?id=com.expensecount.messExpense";
    } else if ($expenseType == "3") {
        $hrefName = "https://play.google.com/store/apps/details?id=com.expensecount.familyExpense";
    }

    $device_type = 2;

    $groupExpenseHrefName = "https://play.google.com/store/apps/details?id=com.expensecount.groupExpense";
    $messExpenseHrefName = "https://play.google.com/store/apps/details?id=com.expensecount.messExpense";
    $familyExpenseHrefName = "https://play.google.com/store/apps/details?id=com.expensecount.familyExpense";



    $imageName = CDN_URL . "images/google_play.png";
} else if ($device == "iphone") {
    $showText = "Use the iOS App";
    $alt = "iPhone App";
    if ($expenseType == "1") {
        $hrefName = "https://itunes.apple.com/us/app/groupexpense/id1150902475?mt=8";
    } else if ($expenseType == "2") {
        $hrefName = "https://itunes.apple.com/us/app/messexpense/id1179871989?mt=8";
    } else if ($expenseType == "3") {
        $hrefName = "https://itunes.apple.com/us/app/familyexpense/id1193007779?mt=8";
    }
    $imageName = CDN_URL . "images/iphone.jpg";

    $groupExpenseHrefName = "https://itunes.apple.com/us/app/groupexpense/id1150902475?mt=8";
    $messExpenseHrefName = "https://itunes.apple.com/us/app/messexpense/id1179871989?mt=8";
    $familyExpenseHrefName = "https://itunes.apple.com/us/app/familyexpense/id1193007779?mt=8";



    $device_type = 2;
} else if ($device == "windows") {
    $showText = "Use the Windows App";
    $alt = "Windows Store";
    if ($expenseType == "1") {
        $hrefName = "https://play.google.com/store/apps/details?id=com.expensecount.groupExpense";
    } else if ($expenseType == "2") {
        $hrefName = "https://play.google.com/store/apps/details?id=com.expensecount.messExpense";
    } else if ($expenseType == "3") {
        $hrefName = "https://play.google.com/store/apps/details?id=com.expensecount.familyExpense";
    }

    $groupExpenseHrefName = "https://play.google.com/store/apps/details?id=com.expensecount.groupExpense";
    $messExpenseHrefName = "https://play.google.com/store/apps/details?id=com.expensecount.messExpense";
    $familyExpenseHrefName = "https://play.google.com/store/apps/details?id=com.expensecount.familyExpense";


    $imageName = CDN_URL . "images/Windows-Store.png";
    $device_type = 2;
}

$downloadTitle = __("LBL_DOWNLOAD_WE_XPENSE_IPHONE_ANDROID");
$downloadDesc  = __("LBL_CREATE_WE_XPENSE_ON_MOBILE_OFFLINE");

if ($expenseType == "1") {
    $downloadTitle = __("LBL_DOWNLOAD_WE_XPENSE_IPHONE_ANDROID");
    $downloadDesc  = __("LBL_CREATE_WE_XPENSE_ON_MOBILE_OFFLINE");
} else if ($expenseType == "2") {
    $downloadTitle = __("LBL_DOWNLOAD_ROOM_XPENSE_IPHONE_ANDROID");
    $downloadDesc  = __("LBL_CREATE_ROOM_XPENSE_ON_MOBILE_OFFLINE");
} else if ($expenseType == "3") {
    $downloadTitle = __("LBL_DOWNLOAD_MY_XPENSE_IPHONE_ANDROID");
    $downloadDesc  = __("LBL_CREATE_MY_XPENSE_ON_MOBILE_OFFLINE");
}

// for pc
if ($device_type == 1) {

    //$expense_type

    $group_display = "block";
    $mess_display = "block";
    $family_display = "block";

    if ($expenseType == "1") {
        $group_display = "block";
        $mess_display = "none";
        $family_display = "none";
    } else if ($expenseType == "2") {
        $mess_display = "block";
        $group_display = "none";
        $family_display = "none";
    } else if ($expenseType == "3") {
        $group_display = "none";
        $mess_display = "none";
        $family_display = "block";
    }

?>


    <link rel="stylesheet" href="<?php echo CDN_URL; ?>css/bootstrap-select.css">
    <script src="<?php echo CDN_URL; ?>js/jquery.min.js_1.11.3.js"></script>
    <script src="<?php echo CDN_URL; ?>js/bootstrap.min_3.3.4.js"></script>
    <script src="<?php echo CDN_URL; ?>js/bootstrap-select.js"></script>


    <div class="bodyContent shadow">

        <h1><?php echo __("LBL_EXPENSECOUNT_ON_YOUR_MOBILE"); ?></h1>
        <p><?php echo __("LBL_EXPENSECOUNT_AVAILABLE_MOBILE"); ?></p>
        <div class="pageDivider"></div>

        <div class="row">
            <div class="col-md-5 text-center">
                <img src="<?php echo CDN_URL; ?>images/mobile-apps-image.jpg" alt="" />
            </div>
            <div class="col-md-7">
                <h3><?php echo $downloadTitle; ?></h3>
                <p><?php echo $downloadDesc; ?></p>
                <!-- <p> <b>Please select expense type to download mobile app: </b>
                   <select onChange="showDownloadIcons()" id="expense_type_select_id" class="selectpicker1"  style="font-size: 0.85rem !important; padding: 5px 14px;" border=2 placeholder="Please select expense type ...">
                            <option value="" selected>Please select expense type ...</option>
                            <option value="1" <?php if ($expenseType == "1") { ?> selected <?php } ?>  >Group Expense</option>
                            <option value="2"  <?php if ($expenseType == "2") { ?> selected <?php } ?>  >Mess Expense</option>
                            <option value="3"  <?php if ($expenseType == "3") { ?> selected <?php } ?>  >Family Expense</option>
                     </select>
                     </p>-->

                <br />
                <?= $this->Form->create(); ?>
                <input type="hidden" name="expense_type">
                <input type="hidden" name="app_type">
                <div class="all-mobile-apps">
                    <div id="div_group_expense_id" class="margin-top20" style="display:<?php echo $group_display; ?>">
                        <div class="row single-expense">
                            <div class="col-sm-4 single-expense-img">
                                <img src="<?php echo CDN_URL; ?>images/WeXpense.png" alt="" />
                                <h4 class="text-center"><?php echo __("LBL_GROUP_EXPENSE"); ?></h4>
                            </div>
                            <div class="col-sm-8 text-center single-expense-link">
                                <a data-expense="1" data-apptype="1" onclick="submitAppInfo(this)" style="cursor:pointer">
                                    <img src="<?php echo CDN_URL; ?><?php echo __("LBL_GOOGLE_PLAY_IMG"); ?>" alt="" style="display: inline; border-radius: 9px;" />
                                </a>
                                <a data-expense="1" data-apptype="2" onclick="submitAppInfo(this)" style="cursor:pointer">
                                    <img src="<?php echo CDN_URL; ?><?php echo __("LBL_APP_STORE_IMG"); ?>" alt="" style="display: inline; border-radius: 9px;" />
                                </a>
                            </div>
                        </div>
                    </div>

                    <div id="div_mess_expense_id" class="margin-top20" style="display:<?php echo $mess_display; ?>">
                        <div class="row single-expense">
                            <div class="col-sm-4 single-expense-img">
                                <img src="<?php echo CDN_URL; ?>images/MessXpense.png" alt="" />
                                <h4 class="text-center"><?php echo __("LBL_MESS_EXPENSE"); ?></h4>
                            </div>
                            <div class="col-sm-8 text-center single-expense-link">
                                <a data-expense="2" data-apptype="1" onclick="submitAppInfo(this)" style="cursor:pointer"><img src="<?php echo CDN_URL; ?><?php echo __("LBL_GOOGLE_PLAY_IMG"); ?>" alt="" style="display: inline; border-radius: 9px;" /></a>
                                <a data-expense="2" data-apptype="2" onclick="submitAppInfo(this)" style="cursor:pointer"><img src="<?php echo CDN_URL; ?><?php echo __("LBL_APP_STORE_IMG"); ?>" alt="" style="display: inline; border-radius: 9px;" /></a>
                            </div>
                        </div>
                    </div>

                    <div id="div_family_expense_id" class="margin-top20" style="display:<?php echo $family_display; ?>;">
                        <div class="row single-expense">
                            <div class="col-sm-4 single-expense-img">
                                <img src="<?php echo CDN_URL; ?>images/MyXpense.png" alt="" />
                                <h4 class="text-center"><?php echo __("LBL_FAMILY_EXPENSE"); ?></h4>
                            </div>
                            <div class="col-sm-8 text-center single-expense-link">
                                <a data-expense="3" data-apptype="1" onclick="submitAppInfo(this)" style="cursor:pointer"><img src="<?php echo CDN_URL; ?><?php echo __("LBL_GOOGLE_PLAY_IMG"); ?>" alt="" style="display: inline; border-radius: 9px;" /></a>
                                <a data-expense="3" data-apptype="2" onclick="submitAppInfo(this)" style="cursor:pointer"><img src="<?php echo CDN_URL; ?><?php echo __("LBL_APP_STORE_IMG"); ?>" alt="" style="display: inline; border-radius: 9px;" /></a>
                            </div>
                        </div>

                        <!-- <a style="cursor:pointer" onClick="showMessage()"><img src="<?php echo $this->webroot; ?>images/windows-store-img.jpg" alt="" style="display: inline; border-radius: 9px;"/></a> -->
                    </div>
                </div>
                <?= $this->Form->end(); ?>
            </div>
        </div>


    </div>

    <script>
        function showMessage() {
            alert("Coming soon!");
        }

        function submitAppInfo(elem) {
            var expenseType = $(elem).data('expense');
            var appType = $(elem).data('apptype');
            $('input[name=expense_type]').val(expenseType);
            $('input[name=app_type]').val(appType);
            $('#CommentMobileAppsForm').submit();

        }


        function showDownloadIcons() {
            var type = document.getElementById("expense_type_select_id").value;

            document.getElementById("div_group_expense_id").style.display = "none";
            document.getElementById("div_mess_expense_id").style.display = "none";
            document.getElementById("div_family_expense_id").style.display = "none";

            if (type == "1") {
                document.getElementById("div_group_expense_id").style.display = "block";
            } else if (type == "2") {
                document.getElementById("div_mess_expense_id").style.display = "block";
            } else if (type == "3") {
                document.getElementById("div_family_expense_id").style.display = "block";
            }
        }
    </script>

<?php } else {


    if ($expenseType == "1") {
        ob_start();
        header('Location: ' . $groupExpenseHrefName);
        ob_end_flush();
        die();
    } else if ($expenseType == "2") {
        ob_start();
        header('Location: ' . $messExpenseHrefName);
        ob_end_flush();
        die();
    } else if ($expenseType == "3") {
        ob_start();
        header('Location: ' . $familyExpenseHrefName);
        ob_end_flush();
        die();
    }


?>

    <!DOCTYPE html>
    <html>

    <head>

        <title>Expensecount - The Solution for organizing group, mess and personal expenses</title>

        <!-- For-Mobile-Apps -->
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
        <meta name="description" content="The solution for managing Group, Mess and Personal Expenses" />
        <meta name="keywords" content="WeXpense, We Xpense, GroupXpense, Group Xpense, ExpenseCount, expensecount.com, expcount, expense count, split expenses, split bills, SplitWise, Spid, MyXpense, My Xpense, My Expense, personal expense tracker, personal budgeting app, shared room expenses, roommates cost sharing, MessXpense, Mess Xpense, Room Xpense, mess expense app, hostel expense manager, group expense manager, shared expense, group trip organizer, travel expense tracker, friends expenses, roommates expenses, Manage Group Expense, Track Expense, expenditure tracking, group activity expenses, bill splitting app, group budgeting, expense sheet, expense report, group expense report, household expense tracker, finance organizer, daily expense manager, monthly expense tracker, We Expense Manager, We Expense Calculator, organize expenses, accounting, tally expenses, split cost app, shared budgeting, organize travel costs, manage expenses, group activities, expense sharing app" />
        <script type="application/x-javascript">
            addEventListener("load", function() {
                setTimeout(hideURLbar, 0);
            }, false);

            function hideURLbar() {
                window.scrollTo(0, 1);
            }
        </script>
        <!-- //For-Mobile-Apps -->

        <!-- Style -->
        <link rel="stylesheet" href="mobile/css/style.css" type="text/css" media="all">

        <!-- Web-Fonts -->
        <link href='//fonts.googleapis.com/css?family=Raleway:400,500,600,700,800' rel='stylesheet' type='text/css'>
        <link href='//fonts.googleapis.com/css?family=Open+Sans:400,600,700' rel='stylesheet' type='text/css'>
        <!-- //Web-Fonts -->

    </head>
    <!-- //Head -->

    <!-- Body -->

    <body>

        <div class="bodyContent shadow">

            <center><a href="<?php echo $this->webroot; ?>"><img src="<?php echo CDN_URL; ?>images/mobile_en_logo.png"></a></center><br /><br />
            <div class="row">
                <div class="col-md-4">
                    <div>

                        <div class="box-content">
                            <div>
                                <font size="3">WeXpense</font><br />
                                Track, split and share group expenses
                            </div>
                            <br />

                        </div>

                    </div>

                    <center><a href="<?php echo $groupExpenseHrefName; ?>"> <img src="<?php echo $imageName; ?>" alt="<?php echo $alt; ?>"></a></center>
                </div>
                <hr />
                <div class="col-md-4">
                    <div>

                        <div class="box-content">
                            <div>
                                <font size="3">MessXpense</font><br />
                                <p>Manage meals and expenses at shared house </p>
                            </div>
                            <br />


                        </div>

                    </div>

                    <center><a href="<?php echo $messExpenseHrefName; ?>"> <img src="<?php echo $imageName; ?>" alt="<?php echo $alt; ?>"></a></center>
                </div>
                <hr />
                <div class="col-md-4">
                    <div>
                        <div class="box-content">
                            <div>
                                <font size="3">MyXpense</font><br />
                                <p>Organize your personal income and expenses </p>
                            </div>
                            <br />
                        </div>

                        <center><a href="<?php echo $familyExpenseHrefName; ?>"> <img src="<?php echo $imageName; ?>" alt="<?php echo $alt; ?>"></a></center><br />
                    </div>

                </div>
            </div>




        </div>



        <!-- Custom-JavaScript-File-Links -->
        <!-- Default-JavaScript -->
        <script src="mobile/js/jquery.min.js"></script>
        <!-- Tabs-JavaScript -->
        <script src="mobile/js/tabs.js"></script>
        <!-- //Custom-JavaScript-File-Links -->

    </body>
    <!-- //Body -->

    </html>

<?php } ?>