<!--Valores-->
<div class="tab-pane fade" id="valoresEmpreendimento" role="tabpanel" aria-labelledby="valoresEmpreendimento-tab">
    <div class="card">
        <div class="card-header">Valores</div>
        <div class="card-body">
            <form action="" class="formAtualizaempreendimento">
            <div class="row">
                <div class="col-lg-6">
                    <div class="form-group">
                        <label for="adm_remuneracao">Estimativa de remuneração total</label>
                        <input type="text" name="adm_remuneracao" class="form-control moneyMask" id="adm_remuneracao" value="<?php e($remuneracaoTotal); ?>" readonly="readonly">
                    </div>
                    <div class="form-group">
                        <label for="adm_valor_midias_estimativa">Valor mensal ideal estimado para midias</label>
                        <input type="text" name="adm_valor_midias_estimativa" class="form-control moneyMask" id="adm_valor_midias_estimativa" value="<?php e($midiasMensal); ?>" readonly="readonly">
                    </div>
                    <div class="form-group">
                        <label for="adm_valor_midias">Valor mensal estimado para midias</label>
                        <input type="text" name="adm_valor_midias" class="form-control moneyMask" id="adm_valor_midias" value="<?php e($empreendimento->adm_valor_midias); ?>">
                    </div>
                    <div class="msgAtualizaempreendimento"></div>
                    <div class="form-group text-right mt-4 mb-0">
                        <button type="button" class="btn btn-success btnAtualizaempreendimento"><i class="fa fa-check"></i> Salvar</button>
                    </div>
                </div>
            </div>
            </form>
        </div>
    </div>
</div>

<!--Mídias-->
<div class="tab-pane fade" id="valoresMidias" role="tabpanel" aria-labelledby="valoresMidias-tab">
    <div class="card">
        <div class="card-header">Mídias</div>
        <div class="card-body">
            <!--<div class="row">
                <div class="col-lg-6">
                    <?php $restante = $valorInvestimento ; ?>
                    <p>1% de investimento: <strong><?php e(money($valorInvestimento)); ?></strong></p>
                    <?php foreach ($valoresMidia as $midia){ ?>
                        <p><?php e($midia->midia); ?>: <strong><?php $restante -= $midia->valor; e(money($midia->valor)); ?></strong></p>
                    <?php } ?>
                    <p>Restam para investir: <strong <?php e($restante<0?'style="color: red;"':'');?>><?php e(money($restante)); ?></strong></p>
                </div>
            </div>-->
            <div class="box-title-section">
                <div class="form-inline">
                    <div class="form-group">
                        <label class="mr-1 text-value text-primary" for="periodo">Relatório por período</label>
                        <select name="periodo" class="form-control" id="periodo">
                            <option value="dia">Diário</option>
                            <option value="semana">Semanal</option>
                            <option value="mes" selected="">Mensal</option>
                        </select>
                    </div>
                </div>
                <hr>
            </div>
            <div class="row">
                <div class="col-lg-6">
                    <div class="list-group" id="accordionMidias">
                        <button class="list-group-item d-flex justify-content-between list-group-item-action list-group-item-success" type="button">
                            Valor estimado mensal <span class="badge badge badge-success badge-pill"><?php e(money($empreendimento->adm_valor_midias)); ?></span>
                        </button>
                        
                        <?php $id_inv_midia = 1; $total_midias = 0; foreach ($valoresMidia as $midia){ ?>
                        <button class="list-group-item d-flex justify-content-between list-group-item-action" type="button" data-toggle="collapse" data-target="#midia-<?php e($id_inv_midia); ?>" aria-expanded="false" aria-controls="midia-<?php e($id_inv_midia); ?>">
                            <strong><?php e($midia->midia); ?></strong> 
                            <span class="badge badge-primary badge-pill"><?php e(money($midia->valor)); ?></span>
                        </button>
                        
                        <div class="list-group-item collapse" id="midia-<?php e($id_inv_midia); ?>" data-parent="#accordionMidias">
                            <table class="table table-borderless table-responsive-sm">
                                <thead>
                                    <tr>
                                        <th>Valor</th>
                                        <th>Data</th>
                                        <th>Comprovante</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    <?php 
                                        foreach($investimentos as $investimento){ 
                                        
                                        if($investimento->midia == $midia->midia){ 
                                    ?>
                                    <tr>
                                        <td><?php e(money($investimento->valor)); ?></td>
                                        <td><?php e(date('d/m/Y', strtotime($investimento->data))); ?></td>
                                        <td><?php if($investimento->comprovante !== ""){ ?><a href="<?php e($investimento->comprovante); ?>" target="_blank"><i class="fa fa-cloud-download" aria-hidden="true"></i> Download</a><?php } ?></td>
                                    </tr>
                                    <?php }} ?>
                                </tbody>
                            </table>
                        </div>
                        <?php $total_midias += $midia->valor; $id_inv_midia++;} ?>
                        
                        <?php $restante = $empreendimento->adm_valor_midias - $total_midias;?>
                        <button class="list-group-item d-flex justify-content-between list-group-item-action list-group-item-<?php e($restante<=0?'danger':'info');?>" type="button"> 
                            Verba disponível
                            <span class="badge badge-<?php e($restante<=0?'danger':'primary');?> badge-pill"><?php e(money($restante)); ?></span>
                        </button>
                    </div>
                </div>
            </div>
            <hr>
            <form action="" class="formAddInvestimento">
            <div class="row">
                <div class="col-lg-6">
                    <div class="row">
                        <div class="col-lg-6">
                            <div class="form-group">
                                <label for="midia">Mídia</label>
                                <select name="midia" class="form-control" id="midia">
                                    <option value="">Selecione</option>
                                    <option value="Facebook">Facebook</option>
                                    <option value="Instagram">Instagram</option>
                                    <option value="Google Ads">Google Ads</option>
                                    <option value="Portais de anúncio">Portais de anúncio</option>
                                </select>
                            </div>
                        </div>
                        <div class="col-lg-6">
                            <div class="form-group">
                                <label for="valor">Valor</label>
                                <input type="text" name="valor" class="form-control moneyMask" id="valor">
                            </div>
                        </div>
                    </div>
                    <div class="row">
                        <div class="col-lg-6">
                            <div class="form-group">
                                <label for="dataInv">Data</label>
                                <input type="text" name="data" class="form-control dataMask" id="dataInv">
                            </div>
                        </div>
                        <div class="col-lg-6">
                            <div class="form-group">
                                <label for="comprovante">Comprovante</label>
                                <div id="div_add_comprovante">
                                    <?php $file = ''; //o que volta do Banco de dados ?>
                                    <div class="container_upl_input custom-file  <?php echo $file != "" ? "d-none" : ""; ?>">
                                        <input type="file" name="comprovante" class="custom-file-input" data-value="<?php echo $file; ?>" id="inputGroupFile01" aria-describedby="inputGroupFileAddon01">
                                        <label class="custom-file-label " for="inputGroupFile01"><i class="fa fa-cloud-upload" aria-hidden="true"></i> Upload</label>
                                    </div>
                                    <div class="container_upl_img <?php echo $file != "" ? "" : "d-none"; ?>" >
                                        <a class="btn btn-outline-secondary">Documento <i class="fa fa-file" aria-hidden="true"></i></a>
                                        <a href="javascript:;" class="btn_remover_upl">Remover</a> 
                                        <a href="javascript:;" class="btn_pergunta_remover_upl d-none">Remover ?</a> 
                                    </div>
                                    <div class="container_upl_load text-center d-none">
                                        <label>Carregando <i class='fa fa-circle-o-notch fa-spin'></i></label>
                                    </div>
                                </div>
                            </div>
                            
                            
                        </div>
                    </div>
                    <div class="msgAddInvestimento"></div>
                    <div class="form-group text-right mt-4 mb-0">
                        <button type="button" class="btn btn-primary btn-sm btnAddInvestimento">
                            <i class="fa fa-plus"></i> Adicionar
                        </button>
                    </div>
                </div>
            </div>
            </form>
        </div>
    </div>
</div>