<section class="content-header">
      <h1>
        Mailbox
        <small>messages</small>
      </h1>
      <ol class="breadcrumb">
        <li><a href="#"><i class="fa fa-dashboard"></i> Home</a></li>
        <li class="active">Mailbox</li>
      </ol>
</section>
<section class="content">
    <div class="row">
        <div class="col-md-6">
            <div class="box box-primary">
                <div class="box-header with-border">
                    <h3 class="box-title">Seleção de E-mail</h3>
                </div>
                <form id="form-envia-emails" action="#" method="POST">
  
                <!-- /.box-header -->
                <div class="box-body">
                    <div class="row">
                        <div class="col-md-12">
                            <div class="form-group">
                                <label>Emails</label>
                                <input type='text' name='emails' id='emails' />
                            </div>
                        </div>
                    </div>
                    <?php if($emails_tb !=null){
                            foreach($emails_tb as $key=>$tb){
                                if(!empty($tb['emails'])){
                                $c = $key;
                    ?>
                    
                    
                    <div class="card">
                        <div class="card-header collapse-trigger">
                            <h5>Tabela: <?php  echo $tb['dt']->nome; ?> - <small class="label label-default"> <?php echo count($tb['emails']); ?></small>
                            <div class="box-tools pull-right">  
                                <button type="button" class="btn btn-box-tool" data-toggle="collapse" data-target="#table-<?php  e($c); ?>"><i class="fa fa-plus"></i></button>
                            </div>
                            </h5>
                        </div>
                        <div class="card-body collapse" id="table-<?php e($c); ?>">
                            <div class="row">
                                <div class="col-xs-5">
                                    <select name="from[]" id="search<?php e($c); ?>" data-key="<?php e($c); ?>" class="form-control search" size="8" multiple="multiple">
                                        <?php  foreach($tb['emails'] as $email){
                                           echo "<option value='$email'>$email</option>";
                                        } ?>
                                    </select>
                                </div>
                            
                                <div class="col-xs-2">
                                    <button type="button" id="js_right_All_<?php e($c); ?>" class="btn btn-block"><i class="fa fa-angle-double-right"></i></button>
                                    <button type="button" id="js_right_Selected_<?php e($c); ?>" class="btn btn-block"><i class="fa fa-angle-right "></i></button>
                                    <button type="button" id="js_left_Selected_<?php e($c); ?>" class="btn btn-block"><i class="fa fa-angle-left "></i></button>
                                    <button type="button" id="js_left_All_<?php e($c); ?>" class="btn btn-block"><i class="fa fa-angle-double-left "></i></button>
                                </div>
                            
                                <div class="col-xs-5">
                                    <select name="to[]" id="js_multiselect_to_<?php e($c); ?>" class="form-control search_to" size="8" multiple="multiple"></select>
                                </div>
                            </div>
                        </div>
                    </div>
                    
                    
                    <!--<div class="box box-primary collapsed-box">
                        <div class="box-header with-border">
                            <h3 class="box-title collapse-trigger">Tabela: <?php  echo $tb['dt']->nome; ?></h3> <small class="label label-default"> <?php echo count($tb['emails']); ?></small>
                            <div class="box-tools">
                                <button type="button" class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-plus"></i></button>
                            </div>
                        </div>
                        <div class="box-body">
                            <div class="row">
                                <div class="col-md-12">
                                    <div class="row">
                                        <div class="col-xs-5">
                                            <select name="from[]" id="search<?php e($c); ?>" data-key="<?php e($c); ?>" class="form-control search" size="8" multiple="multiple">
                                                <?php  foreach($tb['emails'] as $email){
                                                   echo "<option value='$email'>$email</option>";
                                                } ?>
                                            </select>
                                        </div>
                                    
                                        <div class="col-xs-2">
                                            <button type="button" id="js_right_All_<?php e($c); ?>" class="btn btn-block"><i class="fa fa-angle-double-right"></i></button>
                                            <button type="button" id="js_right_Selected_<?php e($c); ?>" class="btn btn-block"><i class="fa fa-angle-right "></i></button>
                                            <button type="button" id="js_left_Selected_<?php e($c); ?>" class="btn btn-block"><i class="fa fa-angle-left "></i></button>
                                            <button type="button" id="js_left_All_<?php e($c); ?>" class="btn btn-block"><i class="fa fa-angle-double-left "></i></button>
                                        </div>
                                    
                                        <div class="col-xs-5">
                                            <select name="to[]" id="js_multiselect_to_<?php e($c); ?>" class="form-control search_to" size="8" multiple="multiple"></select>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>-->
                    
                    <?php }}} ?>
                    <?php if($listas !=null){
                             $c = 0;
                            if($emails_tb !=null){$c = count($emails_tb)+1;}
                            foreach($listas as $key=>$tb){
                                $c += $key;
                            
                    ?>
                    <div class="card">
                        <div class="card-header collapse-trigger">
                            <h5>Lista: <?php  echo $tb['dt']->nome; ?> - <small class="label label-default"> 
                            <?php echo count($tb['emails']); ?></small>
                            <div class="box-tools pull-right">  
                                <button type="button" class="btn btn-box-tool" data-toggle="collapse" data-target="#list-<?php  echo $key ?>"><i class="fa fa-plus"></i></button>
                            </div>
                            </h5>
                        </div>
                        <div class="card-body collapse" id="list-<?php echo $key; ?>">
                            <div class="row">
                                <div class="col-xs-5">
                                    <select name="from[]" id="search<?php e($c); ?>" data-key="<?php e($c); ?>" class="form-control search" size="8" multiple="multiple">
                                                <?php  foreach($tb['emails'] as $email){
                                                   echo "<option value='$email'>$email</option>";
                                                } ?>
                                            </select>
                                </div>
                            
                                <div class="col-xs-2">
                                    <button type="button" id="js_right_All_<?php e($c); ?>" class="btn btn-block"><i class="fa fa-angle-double-right"></i></button>
                                    <button type="button" id="js_right_Selected_<?php e($c); ?>" class="btn btn-block"><i class="fa fa-angle-right "></i></button>
                                    <button type="button" id="js_left_Selected_<?php e($c); ?>" class="btn btn-block"><i class="fa fa-angle-left "></i></button>
                                    <button type="button" id="js_left_All_<?php e($c); ?>" class="btn btn-block"><i class="fa fa-angle-double-left "></i></button>
                                </div>
                            
                                <div class="col-xs-5">
                                    <select name="to[]" id="js_multiselect_to_<?php e($c); ?>" class="form-control search_to" size="8" multiple="multiple"></select>
                                </div>
                            </div>
                        </div>
                    </div>
                    
                    
                    
                    <!--<div class="box box-primary collapsed-box">
                        <div class="box-header with-border">
                            <h3 class="box-title collapse-trigger">Lista: <?php  echo $tb['dt']->nome; ?></h3> <small class="label label-default"> <?php echo count($tb['emails']); ?></small>
                            <div class="box-tools">
                                <button type="button" class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-plus"></i></button>
                            </div>
                        </div>
                        <div class="box-body">
                            <div class="row">
                                <div class="col-md-12">
                                    <div class="row">
                                        <div class="col-xs-5">
                                            <select name="from[]" id="search<?php e($c); ?>" data-key="<?php e($c); ?>" class="form-control search" size="8" multiple="multiple">
                                                <?php  foreach($tb['emails'] as $email){
                                                   echo "<option value='$email'>$email</option>";
                                                } ?>
                                            </select>
                                        </div>
                                    
                                        <div class="col-xs-2">
                                            <button type="button" id="js_right_All_<?php e($c); ?>" class="btn btn-block"><i class="fa fa-angle-double-right"></i></button>
                                            <button type="button" id="js_right_Selected_<?php e($c); ?>" class="btn btn-block"><i class="fa fa-angle-right"></i></button>
                                            <button type="button" id="js_left_Selected_<?php e($c); ?>" class="btn btn-block"><i class="fa fa-angle-left"></i></button>
                                            <button type="button" id="js_left_All_<?php e($c); ?>" class="btn btn-block"><i class="fa fa-angle-double-left"></i></button>
                                        </div>
                                    
                                        <div class="col-xs-5">
                                            <select name="to[]" id="js_multiselect_to_<?php e($c); ?>" class="form-control search_to" size="8" multiple="multiple"></select>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>-->
                    
                    <?php }} ?>
                    
                    
                </div>
            </div>
        </div>  
        
        <div class="col-md-6">
          <div class="box box-primary">
            <div class="box-header with-border">
              <h3 class="box-title">Campanha</h3>
            </div>
            <!-- /.box-header -->
            <div class="box-body">
                <div class="form-group">
                  <label>Campanha</label>
                  <select class="form-control" id="select_campanha" name="campanha">
                    <option value="1">Mensagem Customizada</option>
                    <?php if($campanhas != null){
                            foreach($campanhas as $camp)
                            {
                               echo '<option value="'.$camp->id_campanha.'">'.$camp->nome.'</option>';
                            }
                    }?>
                    
                  </select>
                </div>
                
              <div class="inputs_default">
                  <div class="form-group">
                    <input name="subject"class="form-control" placeholder="Subject:">
                  </div>
                  <div class="form-group">
                    <input name="titulo" class="form-control" placeholder="Titulo:">
                  </div>
                  <div class="form-group">
                      <label>Mensagem</label>
                      <textarea name="msg"class="form-control" rows="3" placeholder="Mensagem"></textarea>
                    </div>
              </div>
            <label>Arquivar </label>
                <div class="form-group">
                    <label class="radio-inline">
                        <input class="ipt-arquivar" type="radio" name="arquivar" value="0" checked>Não
                    </label>
                    <label class="radio-inline">
                        <input class="ipt-arquivar" type="radio" name="arquivar" value="1">Sim
                    </label>
                </div>
                
                <div class="grupo_nome_arquivo" style="display: none;">
                    <label for="arquivo">Nome do Arquivo</label>
                    <div class="form-group">
                        <div class="col-sm-10">
                            <select class="select2 _select2-arquivos _js-states form-control" id="select_arquivo" name="arquivo">
                                <option value="">Selecione</option>
                                <?php if(isset($arquivos)){ foreach($arquivos as $arquivo){?>
                                    <option value="<?php echo $arquivo->id_arquivo; ?>"><?php echo $arquivo->id_arquivo." - ".$arquivo->nome; ?></option>
                                <?php }}?>
                            </select>
                        </div>
                        <div class="col-sm-2">
                            <button type="button" class="btn btn-info btn-flat" data-toggle="modal" data-target="#modal_add_arquivo"><i class="fa fa-plus-circle" aria-hidden="true"></i></button>
                        </div>
                    </div>
                </div>
            </div>   
            <!-- /.box-body -->
            <div class="box-footer">
              <div class="pull-right">
                <button type="submit" id="enviar_emails" class="btn btn-primary"><i class="fa fa-envelope-o"></i> Send</button>
                </form>
              </div>
            </div>
            <!-- /.box-footer -->
          </div>
          <!-- /. box -->
        </div>
        <div class="col-md-6">
          <div class="box box-primary">
            <div class="box-header with-border">
              <h3 class="box-title">Progresso</h3>
            </div>
            <!-- /.box-header -->
            <div class="box-body">
                <div class="row">
                    <div class="col-md-12">
                        <div class="progress progress-sm active">
                            <div id="progress-bar" class="progress-bar progress-bar-success progress-bar-striped" role="progressbar" aria-valuenow="20" aria-valuemin="0" aria-valuemax="100" style="">
                            </div>
                        </div>
                        <div class="col-xs-6">
                            <span id="qnt-p" style="text-align:left; display:block;">0%</span>
                        </div> 
                        <div class="col-xs-6">
                            <span id="qnt-r" style="text-align:right; display:block;">0/0</span>
                        </div>
                        
                        
                        <!--<input type="button" onclick="startTask();"  value="Start Long Task" />
                        <input type="button" onclick="stopTask();"  value="Stop Task" />-->
                        <div class="col-lg-6"> 
                            <div class="box box-solid">
                                    <div class="box-header with-border">
                                      <h3 class="box-title">Enviou</h3>
                                    </div>
                                    <div class="box-body">
                                        <div id="results" style="border:1px solid #000; padding:10px; width:100%; height:250px; overflow:auto; background:#eee;"></div>
                                    </div>
                             </div>
                            
                        </div>
                        <div class="col-lg-6">
                            <div class="box box-solid">
                                    <div class="box-header with-border">
                                      <h3 class="box-title">Falhou</h3>
                                    </div>
                                    <div class="box-body">
                                        <div id="erros" style="border:1px solid #000; padding:10px; width:100%; height:250px; overflow:auto; background:#eee;"></div>
                                    </div>
                             </div>
                        </div>  
                    </div>
            </div>
            </div>
          </div>
          <!-- /. box -->
        </div>
      </div>
      <!-- /.row -->
      <?php echo $modal_add_arquivo ?>