?? GreyFile — Mystic File Browser

Current path: home/webdevt/cryptoimpot.fr/module/Application/view/application/partial/admin/



?? Go up: /home/webdevt/cryptoimpot.fr/module/Application/view/application/partial

?? Viewing: tab-content.phtml

<?php
$formDelete = $this->formDelete;
$formDelete->setAttribute('action', $this->url(Application\Controller\ImportationController::ROUTE_IMPORTATION_DELETE_ALL));

$echange = $formDelete->get('exchange');
if (!empty($this->exchange)) {
    $echange->setValue($this->exchange->getId());
} else {
    $echange->setValue(0);
}

$csrf = $formDelete->get('csrf');

$formButton = $formDelete->get('submit');
$formButton->setAttribute('class', 'delete-data-exchange btn btn-danger btn-sm btn-block');
$formButton->setAttribute('data-exchange-name', Application\Tool\TextTool::strToUrl($this->exchange->getName()));
$formDelete->setAttribute('class', 'form-horizontal');

$formDelete->prepare();

if ($this->formAPI) {
    $formAPI = $this->formAPI;
    $formButtonAPI = $formAPI->get('submit');
    $formButtonAPI->setAttribute('class', 'btn btn-primary btn-lg btn-block mt-4');
    $formAPI->setAttribute('class', 'form-horizontal');
}
?>

<style>
    @media(min-width: 992px) {
        .col-md-4:not(:first-child), 
        .col-md-6:not(:first-child) {
            border-left: 1px solid black;
        }
        .col-md-4:not(:last-child),
        .col-md-6:not(:last-child) {
            border-right: 1px solid black;
            margin-right: -1px;
        }
    }
</style>
<div class="text-center pt-3 tab-pane fade <?= $this->selected === true ? 'show active' : '' ?>" id="nav-<?= \Application\Tool\TextTool::strToUrl($this->exchange->getName()) ?>" role="tabpanel" aria-labelledby="nav-<?= \Application\Tool\TextTool::strToUrl($this->exchange->getName()) ?>-tab">
    <div class="container-fluid">

        <div class="row">
            <div class="col pr-5">
                <div class="row mt-2 mb-4 text-left">
                    <div class="col">

                        <!-- Button trigger modal -->
<!--                        <button type="button" class="btn btn-outline-info mb-2" data-toggle="modal" data-target="#info<?= \Application\Tool\TextTool::strToUrl($this->exchange->getName()) ?>">
                            <i class="fas fa-info-circle"></i> Comment importer le fichier de trade <?= !empty($this->exchange) ? 'de <b>' . $this->exchange->getName() . '</b>' : '' ?>
                        </button>-->
                        <a data-toggle="modal" href="#info<?= \Application\Tool\TextTool::strToUrl($this->exchange->getName()) ?>" class="button text-primary font-italic"><i class="fas fa-info"></i> Comment importer le fichier de transactions <?= !empty($this->exchange) ? 'de <b>' . $this->exchange->getName() . '</b>' : '' ?></a>
                    </div>
                </div>

                <div id="etape1">

                    <form id="fileupload-<?= \Application\Tool\TextTool::strToUrl($this->exchange->getName()) ?>" class="fileupload-multi" action="<?= $this->url(Application\Controller\ImportationController::ROUTE_IMPORTATION_UPLOAD) ?>" method="POST" enctype="multipart/form-data">
                        <!-- The file upload form used as target for the file upload widget -->

                        <div class="row fileupload-buttonbar">
                            <div class="col-lg-12 text-center">
                                <div id="dropzone" class="dropzone-file fade well">
                                    <span class="fileinput-button text-dark border-dark">
                                        <i class="fas fa-folder-plus"></i>
                                        <span class="">Pour charger vos fichiers de trade <?= !empty($this->exchange) ? $this->exchange->getName() : '' ?>, déposez les ou cliquez ici</span>
                                        <input type="file" name="files[]" multiple>
                                    </span>
                                </div>
                            </div>
                        </div>
                        <div class="row fileupload-buttonbar">
                            <div class="col-lg-12">

                                <!-- The global file processing state -->
                                <span class="fileupload-process"></span>
                            </div>
                            <!-- The global progress state -->
                            <div class="col-lg-2 fileupload-progress fade">
                                <!-- The global progress bar -->
                                <div class="progress progress-striped active" role="progressbar" aria-valuemin="0" aria-valuemax="100">
                                    <div class="progress-bar progress-bar-success" style="width:0%;"></div>
                                </div>
                                <!-- The extended global progress state -->
                                <div class="progress-extended">&nbsp;</div>
                            </div>
                        </div>

                        <input name="exchange-name" type="hidden" value="<?= \Application\Tool\TextTool::strToUrl($this->exchange->getName()) ?>">
                        <!-- The table listing the files available for upload/download -->
                        <table role="presentation" class="table table-striped"><tbody class="files container-file" id="container-file-<?= \Application\Tool\TextTool::strToUrl($this->exchange->getName()) ?>"></tbody></table>
                        <div class="text-center" id="spinner-<?= \Application\Tool\TextTool::strToUrl($this->exchange->getName()) ?>"><i class="fa-3x fas fa-spinner fa-spin"></i><br>chargement</div>
                    </form>
                    <div>
                        
                        <?php if ($this->devises) :  ?>
                        <?php foreach($this->devises as $devise) : ?>
                        <?php echo $devise->getCode(); ?>
                        <?php endforeach; ?>
                        <?php endif ?>
                        <?php echo $this->form()->openTag($formDelete) ?>

                        <!-- Csrf -->
                        <?php echo $this->formHidden($csrf) ?>
                        <!-- ./ Csrf -->

                        <!-- Echange -->
                        <?php echo $this->formHidden($echange) ?>
                        <!-- ./ Echange -->

                        <div id ="container-delete-button-trade-<?= \Application\Tool\TextTool::strToUrl($this->exchange->getName()) ?>" class="form-group row">
                            <div class="offset-lg-4 col-lg-4">
                                <?php //echo $this->formButton($formButton) ?>
                                <?= $this->formButton()->openTag($formButton); ?>
                                <i class="fas fa-trash"></i> Supprimer les données de trade <?= !empty($this->exchange) ? $this->exchange->getName() : '' ?>
                                <?= $this->formButton()->closeTag(); ?>
                            </div>
                        </div>


<!--                        <button class="btn btn-danger delete" data-type="csv" data-url="<?= $this->url(Application\Controller\ImportationController::ROUTE_IMPORTATION_DELETE_ALL) ?>">
                            <i class="fas fa-trash-alt"></i>
                            <span>Supprimer</span>
                        </button>-->
                        <?php echo $this->form()->closeTag() ?>
                    </div>
                </div>
            </div>


            <?php if (!empty($this->formAPI)) : ?>
                <div class="col col-md-6 text-left pl-5">
                    <div class="row mt-2 mb-4 text-left">
                        <div class="col">
                            <!-- Button trigger modal -->
                            <a data-toggle="modal" href="#info<?= \Application\Tool\TextTool::strToUrl($this->exchange->getName()) ?>-api" class="button text-primary font-italic"><i class="fas fa-info"></i> Comment importer par l'API <?= !empty($this->exchange) ? 'de <b>' . $this->exchange->getName() . '</b>' : '' ?></a>

                        </div>
                    </div>

    <!--                <button type="button" class="btn btn-outline-info mb-2" data-toggle="modal" data-target="#info<?= \Application\Tool\TextTool::strToUrl($this->exchange->getName()) ?>-api">
    <i class="fas fa-info-circle"></i> Comment utiliser l'importation par API <?= !empty($this->exchange) ? 'de ' . $this->exchange->getName() : '' ?>
    </button>-->
                    <!--                    <h2>Clés d'API</h2>-->
                    <div class="mt-4" style="font-size:0.8em">
                        <?= $this->form()->openTag($this->formAPI); ?>
                        <div id="" class="form-group <?php //echo $erreurNom   ?>">
                            <?= $this->formLabel($this->formAPI->get('public')); ?>

                            <?= $this->formElement($this->formAPI->get('public')); ?>
                            <?= $this->formElementErrors($this->formAPI->get('public')); ?>

                        <!--<input type="text" placeholder="Clé d'API" name="API" class="form-control">-->
                            <?php //echo $this->formLabel($echanges) ?>
                            <?php //echo $this->formSelect($echanges) ?>

                        </div>
                        <div id="" class="form-group <?php //echo $erreurNom   ?>">
                            <!--<input type="text" placeholder="Clé secrète" class="form-control">-->
                            <?= $this->formLabel($this->formAPI->get('private')); ?>

                            <?= $this->formElement($this->formAPI->get('private')); ?>
                            <?= $this->formElementErrors($this->formAPI->get('private')); ?>
                            <?php //echo $this->formLabel($echanges) ?>
                            <?php //echo $this->formSelect($echanges) ?>

                        </div>

                        <?= $this->formElement($this->formAPI->get('csrf')); ?>

                        <?= $this->formElement($formButtonAPI); ?>

                        <?= $this->form()->closeTag(); ?>




                    </div>
                </div>

            <?php endif ?>
        </div>
    </div>
</div>

<!-- Modal -->
<div class="modal fade" id="info<?= \Application\Tool\TextTool::strToUrl($this->exchange->getName()) ?>" tabindex="-1" role="dialog" aria-labelledby="info<?= \Application\Tool\TextTool::strToUrl($this->exchange->getName()) ?>" aria-hidden="true">
    <div class="modal-dialog modal-lg modal-dialog-centered modal-dialog-scrollable" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title" id="exampleModalScrollableTitle">Procédure d'importation des transactions <?= !empty($this->exchange) ? $this->exchange->getName() : '' ?></h5>
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                </button>
            </div>
            <div class="modal-body">
                <?php echo $this->partial('application/help-exchange-import/' . (\Application\Tool\TextTool::strToUrl($this->exchange->getName())) . '.phtml', array()); ?>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-secondary" data-dismiss="modal">Fermer</button>

            </div>
        </div>
    </div>
</div>

<?php if (!empty($this->formAPI)) : ?>
    <!-- Modal -->
    <div class="modal fade" id="info<?= \Application\Tool\TextTool::strToUrl($this->exchange->getName()) ?>-api" tabindex="-1" role="dialog" aria-labelledby="info<?= \Application\Tool\TextTool::strToUrl($this->exchange->getName()) ?>-api" aria-hidden="true">
        <div class="modal-dialog modal-lg modal-dialog-centered modal-dialog-scrollable" role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <h5 class="modal-title" id="exampleModalScrollableTitle">Procédure d'importation des transactions <?= !empty($this->exchange) ? $this->exchange->getName() : '' ?></h5>
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                        <span aria-hidden="true">&times;</span>
                    </button>
                </div>
                <div class="modal-body">
                    <?php echo $this->partial('application/help-exchange-import/' . (\Application\Tool\TextTool::strToUrl($this->exchange->getName())) . '-API.phtml', array()); ?>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-secondary" data-dismiss="modal">Fermer</button>

                </div>
            </div>
        </div>
    </div>
<?php endif ?>
<?php //var_dump('eee',$this->exchange->getName()); exit;?>


<script>

    $(function () {
        'use strict';
<?php if ($countTradeExchangeUser) : ?>
<?php else : ?>
            $('#container-delete-button-trade-<?= \Application\Tool\TextTool::strToUrl($this->exchange->getName()) ?>').hide();

<?php endif; ?>



        $("body").on('DOMSubtreeModified', "#container-file-<?= \Application\Tool\TextTool::strToUrl($this->exchange->getName()) ?>", function () {
            if ($('#container-file-<?= \Application\Tool\TextTool::strToUrl($this->exchange->getName()) ?> tr').length > 0) {
                //alert('ok');
                $('#container-delete-button-trade-<?= \Application\Tool\TextTool::strToUrl($this->exchange->getName()) ?>').show();
            }
        });

<?php //https://github.com/blueimp/jQuery-File-Upload/wiki/Options            ?>
        // Initialize the jQuery File Upload widget:
        $('#fileupload-<?= \Application\Tool\TextTool::strToUrl($this->exchange->getName()) ?>').fileupload({
            // Uncomment the following to send cross-domain cookies:
            //xhrFields: {withCredentials: true},
            url: '<?= $this->url(Application\Controller\ImportationController::ROUTE_IMPORTATION_UPLOAD) ?>',
            //type: 'POST',
            formData: [{'name': 'exchange-name', 'value': '<?= \Application\Tool\TextTool::strToUrl($this->exchange->getName()) ?>'}]
        }).bind('fileuploaddone', function (e, data) {
            e.preventDefault;
            var result = data.result;
            console.log(result);

            if (result.error && result.error.messages.length > 0) {
                for (var i = 0; i < result.error.messages.length; i++)
                {
                    $('#container-delete-button-trade-' + result.exchange).hide();
                
                    var message = result.error.messages[i];
                    Swal.fire({
                        type: 'error',
                        title: message.header,
                        text: message.body,
                        footer: message.footer
                    }).then(function () {
                        location.reload();
                    });

                }
                //var errorArray = result.error;



                //location.reload();
            } else if (result.success && result.success.messages.length > 0) {
                //var arrayMessage = result.success;
                
                for (var i = 0; i < result.success.messages.length; i++)
                {
                    var message = result.success.messages[i];
                    Swal.fire({
                        type: 'success',
                        title: message.header,
                        text: message.body,
                        footer: message.footer
                    }).then(function () {
                        location.reload();
                    });


                }
                //
            }
//            console.log('hide or show button');
//            console.log($('#container-file-' + result.exchange).html());
            if ($('#container-file-' + result.exchange).html() === '') {
                $('#container-delete-button-trade-' + result.exchange).hide();
                
                
            }
            // console.log('show delete button');
            if ($.trim($('#container-file-<?= !empty($this->exchange) ? \Application\Tool\TextTool::strToUrl($this->exchange->getName()) : 'exchange-generique' ?>')) == '') {
                console.log('vide');
            }

            //$('#container-delete-button-trade-<?= !empty($this->exchange) ? \Application\Tool\TextTool::strToUrl($this->exchange->getName()) : 'exchange-generique' ?>').show();

            //}


        });




//        // Load existing files:
        // $('#fileupload-<?= !empty($this->exchange) ? \Application\Tool\TextTool::strToUrl($this->exchange->getName()) : 'exchange-generique' ?>').addClass('fileupload-processing');

        $('#spinner-<?= \Application\Tool\TextTool::strToUrl($this->exchange->getName()) ?>').show();
        $.ajax({
            // Uncomment the following to send cross-domain cookies:
            //xhrFields: {withCredentials: true},
            url: $('#fileupload-<?= !empty($this->exchange) ? \Application\Tool\TextTool::strToUrl($this->exchange->getName()) : 'exchange-generique' ?>').fileupload('option', 'url'),
            data: {
                "exchange-name": '<?= \Application\Tool\TextTool::strToUrl($this->exchange->getName()) ?>'

            },
            dataType: 'json',
            context: $('#fileupload-<?= !empty($this->exchange) ? \Application\Tool\TextTool::strToUrl($this->exchange->getName()) : 'exchange-generique' ?>')[0]
        }).always(function () {
            //alert('chargement');
            //$(this).removeClass('fileupload-processing');
            $('#spinner-<?= \Application\Tool\TextTool::strToUrl($this->exchange->getName()) ?>').hide();
        }).done(function (result) {
            $(this).fileupload('option', 'done')
                    .call(this, $.Event('done'), {result: result});


//if (result && result.files && result.files.length > 0) {
            //  $('#container-delete-button-trade-<?php // !empty($this->exchange) ? \Application\Tool\TextTool::strToUrl($this->exchange->getName()) : 'exchange-generique'        ?>').show();

            //}
//            console.log(result);


        });


    });


</script>


??

??