<sb-section title="'<?php echo $this->_("General Information"); ?>'">
    <form ng-submit="saveInfo()">
        <div class="col-md-4">
            <div class="form-group">
                <label class="control-label" for="name"><?php echo $this->_("Name"); ?></label>
                <input type="text" value="{{ tmp_application.name }}" ng-model="tmp_application.name" class="form-control" name="name" id="name" />
            </div>
        </div>
        <div class="col-md-4">
            <div class="form-group">
                <label class="control-label" for="bundle_id"><?php echo $this->_("Bundle Id"); ?></label>
                <input type="text" value="{{ tmp_application.bundle_id }}" ng-model="tmp_application.bundle_id" class="form-control" name="bundle_id" id="bundle_id" />
            </div>
        </div>

        <div class="col-md-4">
            <div class="form-group">
                <label class="control-label" for="domain"><?php echo $this->_("Domain"); ?></label>
                <input type="text" value="{{ tmp_application.domain }}" ng-model="tmp_application.domain" class="form-control" name="domain" id="domain">
            </div>
        </div>

        <div class="col-md-4">
            <div class="form-group">
                <label class="control-label" for="key"><?php echo $this->_("URL Key"); ?></label>
                <input type="text" value="{{ tmp_application.key }}" ng-model="tmp_application.key" class="form-control" name="key" id="key">
            </div>
        </div>

        <div class="col-md-4">
            <div class="form-group">
                <label class="control-label"><?php echo $this->_("URL"); ?></label>
                <a href="{{ tmp_application.url }}" class="block" target="_blank">{{ tmp_application.url }}</a>
            </div>
        </div>

        <div class="clear col-md-4">
            <div class="form-group">
                <div class="checkbox">
                    <label for="application_is_active">
                        <input type="checkbox" id="application_is_active" ng-model="tmp_application.is_active" ng-checked="tmp_application.is_active" />
                        <?php echo $this->_("This application is visible on the front"); ?>
                    </label>
                </div>
            </div>
        </div>

        <div class="col-md-4">
            <div class="form-group">
                <div class="checkbox">
                    <label for="application_is_locked">
                        <input type="checkbox" id="application_is_locked" ng-model="tmp_application.is_locked" ng-checked="tmp_application.is_locked" />
                        <?php echo $this->_("Lock the entire application"); ?>
                    </label>
                </div>
            </div>
        </div>

        <div class="col-md-12">
            <div class="form-group">
                <button type="submit" class="btn btn-primary left"><?php echo $this->_("Save"); ?></button>
                <sb-loader is_visible="application_form_loader_is_visible" type="'inner_content'" size="'small'" animation="'no'" class="form_loader"></sb-loader>
                <div class="clear"></div>
            </div>
        </div>
    </form>

</sb-section>

<div class="clear"></div>

<sb-section title="'<?php echo addslashes($this->_("Device Information")); ?>'">


    <form ng-submit="saveDeviceInfo()">

        <div ng-repeat="device in application.devices">

            <div class="col-md-{{ 12 / application.devices.length }}">

                <div class="title">
                    <h4>{{ device.name }}</h4>
                    <div class="clear"></div>
                </div>

                <div class="form-group">
                    <label for="{{ device.id }}_status"><?php echo $this->_('Status'); ?></label>
                    <select id="{{ device.id }}_status" class="form-control" ng-model="device.status_id" ng-options="k as v for (k, v) in statuses"></select>
                </div>

                <div class="form-group">
                    <label for="{{ device.id }}_version"><?php echo $this->_('Version'); ?></label>
                    <input type="text" ng-model="device.version" class="form-control" name="version" id="{{ device.id }}_version" />
                </div>

                <div class="form-group">
                    <label for="{{ device.id }}_store_url"><?php echo $this->_('Store URL'); ?></label>
                    <input type="url" ng-model="device.store_url" class="form-control" name="store_url" id="{{ device.id }}_store_url" />
                </div>

                <div class="form-group" ng-if="device.store_pass">
                    <label for="{{ device.id }}_store_pass"><?php echo $this->_('Store Password'); ?></label>
                    <p>{{ device.store_pass }}</p>
                </div>

                <div class="form-group" ng-if="device.key_pass">
                    <label for="{{ device.id }}_key_pass"><?php echo $this->_('Key Password'); ?></label>
                    <p>{{ device.key_pass }}</p>
                </div>

            </div>

        </div>

        <div class="col-md-12">
            <div class="form-group">
                <button type="submit" class="btn btn-primary left"><?php echo $this->_("Save"); ?></button>
                <sb-loader is_visible="device_form_loader_is_visible" type="'inner_content'" size="'small'" animation="'no'" class="form_loader"></sb-loader>
                <div class="clear"></div>
            </div>
        </div>
    </form>

</sb-section>

<div class="clear"></div>

<sb-section title="'<?php echo addslashes($this->_("Stores Info")); ?>'">

    <div class="col-md-12">
        <div class="form-group">
            <label class="control-label"><?php echo $this->_("Application Name"); ?></label>
            <p>{{ application.name }}</p>
        </div>
    </div>
    <div class="col-md-12">
        <div class="form-group">
            <label class="control-label"><?php echo $this->_("Description"); ?></label>
            <p>{{ application.description }}</p>
        </div>
    </div>
    <div class="col-md-12">
        <div class="form-group">
            <label class="control-label"><?php echo $this->_("Keywords"); ?></label>
            <p>{{ application.keywords }}</p>
        </div>
    </div>
    <div class="col-md-12">
        <div class="form-group">
            <label class="control-label"><?php echo $this->_("Main category"); ?></label>
            <p>{{ application.main_category_name }}</p>
        </div>
    </div>
    <div class="col-md-12">
        <div class="form-group">
            <label class="control-label"><?php echo $this->_("Secondary category"); ?></label>
            <p>{{ application.secondary_category_name }}</p>
        </div>
    </div>

</sb-section>

<div class="clear"></div>

<sb-section title="'<?php echo addslashes($this->_("User Information")); ?>'">

    <div class="col-md-12">
        <div class="form-group">
            <label class="control-label"><?php echo $this->_("Name"); ?></label>
            <p>{{ application.admin.name }}</p>
        </div>
    </div>
    <div class="col-md-12">
        <div class="form-group">
            <label class="control-label"><?php echo $this->_("Email"); ?></label>
            <p>{{ application.admin.email }}</p>
        </div>
    </div>
    <div class="col-md-12">
        <div class="form-group">
            <label class="control-label"><?php echo $this->_("Company"); ?></label>
            <p>{{ application.admin.company }}</p>
        </div>
    </div>
    <div class="col-md-12">
        <div class="form-group">
            <label class="control-label"><?php echo $this->_("Phone"); ?></label>
            <p>{{ application.admin.phone }}</p>
        </div>
    </div>

</sb-section>

<div class="clear"></div>

<sb-section title="'<?php echo addslashes($this->_("Developer Accounts")); ?>'">

    <div class="form-group" ng-repeat="device in application.devices">

        <div class="col-md-4" ng-class="{'text-danger': device.has_missing_information}">
            <h4 class="bold">{{ device.brand_name }}</h4>
        </div>

        <div class="col-md-4" ng-if="!device.has_missing_information && device.use_our_developer_account == 0">
            <label class="control-label"><?php echo $this->_("Username"); ?></label>
            <p>{{ device.developer_account_username }}</p>
        </div>
        <div class="col-md-4" ng-if="!device.has_missing_information && device.use_our_developer_account == 0">
            <label class="control-label"><?php echo $this->_("Password"); ?></label>
            <p>{{ device.developer_account_password }}</p>
        </div>

        <div class="col-md-8" ng-if="!device.has_missing_information && device.use_our_developer_account == 1">
            <h4><?php echo $this->_("Publish under our account"); ?></h4>
        </div>

        <div class="col-md-4" ng-if="device.has_missing_information">
            <h4 class="text-danger"><?php echo $this->_("Missing Information"); ?></h4>
        </div>

        <div class="clear"></div>
    </div>

</sb-section>

<div class="clear"></div>

<sb-section title="'<?php echo addslashes($this->_("Media")); ?>'">

    <div class="form-group">
        <div class="col-md-2">
            <label class="control-label"><?php echo $this->_("App Store Icon"); ?></label>
        </div>
        <div class="col-md-2 text-right">
            <img ng-src="{{ application.app_store_icon }}" width="100" />
        </div>
    </div>

    <div class="clear"></div>

    <div class="form-group">
        <div class="col-md-2">
            <label class="control-label"><?php echo $this->_("Google Play Icon"); ?></label>
        </div>
        <div class="col-md-2 text-right">
            <img ng-src="{{ application.google_play_icon }}" width="100" />
        </div>
    </div>

</sb-section>

<div class="clear"></div>

<sb-section title="'<?php echo addslashes($this->_("Mobile Source Codes")); ?>'">

    <div class="form-group">
        <div class="col-md-4">
            <label class="control-label"><?php echo $this->_("iPhone Version"); ?></label>
            <a href="<?php echo $this->getUrl("application/backoffice_view/downloadsource", array("device_id" => 1)); ?>/app_id/{{ application.id }}" class="block" target="_self"><i class="fa fa-cloud-download"></i> <?php echo $this->_("Download"); ?></a>
        </div>
    </div>

    <div class="form-group">
        <div class="col-md-4">
            <label class="control-label"><?php echo $this->_("Android Version"); ?></label>
            <a href="<?php echo $this->getUrl("application/backoffice_view/downloadsource", array("device_id" => 2)); ?>/app_id/{{ application.id }}" class="block" target="_self"><i class="fa fa-cloud-download" ></i> <?php echo $this->_("Download"); ?></a>
        </div>
    </div>

    <div class="form-group">
        <div class="col-md-4">
            <label class="control-label"><?php echo $this->_("Generate APK"); ?></label>
            <a href="javascript:void(0)" ng-click="downloadAndroidApk()" class="block"><i class="fa fa-cloud-download" ></i> <?php echo $this->_("Download"); ?></a>
            <p class="help-block"><?php echo $this->_("(only if the APK generator is installed)"); ?></p>
            <a href="{{ application.apk.link }}" class="help-block" target="_self" ng-if="application.apk.link"><?php echo $this->_("Download APK"); ?>
            (<?php echo $this->_("Date of generation: "); ?> {{ application.apk.date }})</a>
        </div>
    </div>

</sb-section>

<sb-section title="'<?php echo addslashes($this->_("Certificate")); ?>'" class="upload_area">

    <p class="help-block"><?php echo $this->_("Send here your iOS certificate to enable the push notifications for this application."); ?></p>
    <p class="help-block"><?php echo $this->_("<b>File type:</b> %s", "pem"); ?></p>

    <br />
    <div class="col-md-3">
        <div class="upload_a_file">
            <label for="certificate_uploader"><?php echo $this->_("Click here to send your certificate"); ?></label>
            <input id="certificate_uploader" type="file" nv-file-select="" uploader="certificate_uploader" />
        </div>
    </div>

    <div class="col-md-1">
        <div class="drop_a_file">
            <label><?php echo $this->_("OR"); ?></label>
        </div>
    </div>

    <div class="col-md-5">
        <div class="drop_a_file">
            <label><?php echo $this->_("Drop your certificate here"); ?></label>
            <div ng-show="certificate_uploader.isHTML5">
                <div class="well drop-zone" nv-file-drop="" nv-file-over="" uploader="certificate_uploader">
                </div>
            </div>
        </div>
    </div>

    <div class="toggle col-md-3" ng-if="application.has_ios_certificate || application.just_sent_the_certificate">
        <label ng-show="application.has_ios_certificate"><?php echo $this->_("You already have sent a certificate."); ?></label>
        <label ng-show="application.just_sent_the_certificate"><?php echo $this->_("You have sent a certificate."); ?></label>
        <div class="text-center">
            <img src="<?php echo $this->getImage("push/certificate.png"); ?>" width="100" />
        </div>
    </div>

    <div class="clear"></div>

    <table class="table" ng-show="certificate_uploader.queue.length">
        <thead>
        <tr>
            <th width="50%">Name</th>
            <th ng-show="certificate_uploader.isHTML5">Size</th>
            <th ng-show="certificate_uploader.isHTML5">Progress</th>
            <th>Status</th>
            <th>Actions</th>
        </tr>
        </thead>
        <tbody>
        <tr ng-repeat="item in certificate_uploader.queue" ng-show="certificate_uploader.queue.length">
            <td><strong>{{ item.file.name }}</strong></td>
            <td ng-show="certificate_uploader.isHTML5" nowrap>{{ item.file.size/1024/1024|number:2 }} MB</td>
            <td ng-show="certificate_uploader.isHTML5">
                <div class="progress">
                    <div class="progress-bar progress-bar-striped" role="progressbar" ng-style="{ 'width': item.progress + '%' }"></div>
                </div>
            </td>
            <td class="text-center">
                <span ng-show="item.isSuccess"><i class="fa fa-check"></i></span>
                <span ng-show="item.isCancel"><i class="fa fa-ban"></i></span>
                <span ng-show="item.isError"><i class="fa fa-remove"></i></span>
            </td>
            <td nowrap>
                <button type="button" class="btn btn-warning btn-xs" ng-click="item.cancel()" ng-disabled="!item.isUploading">
                    <span class="fa fa-ban"></span>
                </button>
                <button type="button" class="btn btn-danger btn-xs" ng-click="item.remove()" ng-disabled="item.isReady || item.isUploading || item.isSuccess">
                    <span class="fa fa-remove"></span>
                </button>
            </td>
        </tr>
        </tbody>
    </table>

</sb-section>

