<?php
    global $wpgamasms_option;
	
    $table2 = "{$wpdb->prefix}gamasms_subscribes_group";
    $table3 = "{$wpdb->prefix}gamasms_subscribes";
	
	$sql3 = "select * from $table2 order by name asc";
    $list_subscribes_group = $wpdb->get_results($sql3,ARRAY_A);
    // Para que no se produzcan errores cuando no hay datos
    if(empty($list_subscribes_group)){ 
       $list_subscribes_group = array();
    }
	
	//cantidad de usuarios activos
    $sql4 = "select count(*) as total from $table3 where status='1'";
    $list_subscribes = $wpdb->get_results($sql4,ARRAY_A);
       // Para que no se produzcan errores cuando no hay datos
    if(empty($list_subscribes)){ 
          $list_groups = array();
          $total_subscribes = 0;
    }else{
          $total_subscribes = $list_subscribes[0]['total'];
    }


   $token = $wpgamasms_option['token'];
   $medio = $wpgamasms_option['medio'];
   $smstype = $wpgamasms_option['smstype'];
   $adminmobilenumber = $wpgamasms_option['admin_mobile_number'];



   $cf7_metabox = $wpgamasms_option['cf7_metabox'];
   $wpforms_process_complete = $wpgamasms_option['wpforms_process_complete'];
   $wpforms_process_complete_template = $wpgamasms_option['wpforms_process_complete_template'];
   $wc_notif_new_order = $wpgamasms_option['wc_notif_new_order'];
   $wc_notif_new_order_template = $wpgamasms_option['wc_notif_new_order_template'];
   $wc_notif_new_order_self = $wpgamasms_option['wc_notif_new_order_self'];
   $wc_notif_new_order_self_template = $wpgamasms_option['wc_notif_new_order_self_template'];
   $wc_notif_created_customer = $wpgamasms_option['wc_notif_created_customer'];
   $wc_notif_created_customer_template = $wpgamasms_option['wc_notif_created_customer_template'];
   $wc_notif_created_customer_self = $wpgamasms_option['wc_notif_created_customer_self'];
   $wc_notif_created_customer_self_template = $wpgamasms_option['wc_notif_created_customer_self_template'];
   $wc_notif_created_customer_add_db = $wpgamasms_option['wc_notif_created_customer_add_db'];
   $wc_notif_created_customer_add_db_group_id = $wpgamasms_option['wc_notif_created_customer_add_db_group_id'];
   $edd_notif_new_order = $wpgamasms_option['edd_notif_new_order'];
   $edd_notif_new_order_template = $wpgamasms_option['edd_notif_new_order_template'];
   $gamasms_publish_post = $wpgamasms_option['gamasms_publish_post'];
   $gamasms_publish_post_template = $wpgamasms_option['gamasms_publish_post_template'];
   $gamasms_comment_post = $wpgamasms_option['gamasms_comment_post'];
   $gamasms_comment_post_template = $wpgamasms_option['gamasms_comment_post_template'];
   $wpforms_process_complete_send_to = $wpgamasms_option['wpforms_process_complete_send_to'];
   $wpforms_process_complete_send_to_subscribes_group_id = $wpgamasms_option['wpforms_process_complete_send_to_subscribes_group_id'];
   $gamasms_publish_post_send_to = $wpgamasms_option['gamasms_publish_post_send_to'];
   $gamasms_publish_post_send_to_subscribes_group_id = $wpgamasms_option['gamasms_publish_post_send_to_subscribes_group_id'];
   $gamasms_comment_post_send_to = $wpgamasms_option['gamasms_comment_post_send_to'];
   $gamasms_comment_post_send_to_subscribes_group_id = $wpgamasms_option['gamasms_comment_post_send_to_subscribes_group_id'];
   $gform_after_submission = $wpgamasms_option['gform_after_submission'];
   $gform_after_submission_send_to = $wpgamasms_option['gform_after_submission_send_to'];
   $gform_after_submission_send_to_subscribes_group_id = $wpgamasms_option['gform_after_submission_send_to_subscribes_group_id'];
   $gform_after_submission_template = $wpgamasms_option['gform_after_submission_template'];
   $gform_after_submission_forms = $wpgamasms_option['gform_after_submission_forms'];
   $gform_after_submission_forms_ids = $wpgamasms_option['gform_after_submission_forms_ids'];
   $wc_notif_processing_order = $wpgamasms_option['wc_notif_processing_order'];
   $wc_notif_processing_order_template = $wpgamasms_option['wc_notif_processing_order_template'];
   $wc_notif_cancelled_order = $wpgamasms_option['wc_notif_cancelled_order'];
   $wc_notif_cancelled_order_template = $wpgamasms_option['wc_notif_cancelled_order_template'];
   $wc_notif_completed_order = $wpgamasms_option['wc_notif_completed_order'];
   $wc_notif_completed_order_template = $wpgamasms_option['wc_notif_completed_order_template'];
   $wc_notif_pending_order = $wpgamasms_option['wc_notif_pending_order'];
   $wc_notif_pending_order_template = $wpgamasms_option['wc_notif_pending_order_template'];
   $wc_notif_failed_order = $wpgamasms_option['wc_notif_failed_order'];
   $wc_notif_failed_order_template = $wpgamasms_option['wc_notif_failed_order_template'];
   $wc_notif_refunded_order = $wpgamasms_option['wc_notif_refunded_order'];
   $wc_notif_refunded_order_template = $wpgamasms_option['wc_notif_refunded_order_template'];  
   $wc_notif_note_order = $wpgamasms_option['wc_notif_note_order'];
   $wc_notif_note_order_template = $wpgamasms_option['wc_notif_note_order_template']; 
   
   //¿Está activo WooCommerce?
   if ( is_plugin_active( 'woocommerce/woocommerce.php' ) ) {
	   $plugin_woocommerce_active = "yes";
   }else{
	   $plugin_woocommerce_active = "no";
   }

    if ( is_plugin_active( 'contact-form-7/wp-contact-form-7.php' ) ) {
		$plugin_cf7_active = "yes";
	}else{
		$plugin_cf7_active = "no";
	}
	
	if ( is_plugin_active( 'easy-digital-downloads/easy-digital-downloads.php' ) ) {
		$plugin_edd_active = "yes";
	}else{
		$plugin_edd_active = "no";
	}

    //¿Está activo gravity form?
	if ( is_plugin_active( 'gravityforms/gravityforms.php' ) ) {
        $plugin_gform_active = "yes";
    }else{
		$plugin_gform_active = "no";
	}	 

//echo var_dump($wpgamasms_option);
?>



<div class="wrap">
<?php
   echo "<h1 class='wp-heading-inline'>".get_admin_page_title()."</h1>";
   
   // Por seguridad solo muestra esta pagina al administrador
   if(current_user_can('manage_options')){ 
?>
   <ul class="nav nav-tabs">
      <li class="nav-item">
           <a data-toggle="tab" id="smsconfig" class="nav-link active" aria-current="page" href="#tabsmsconfig">General</a>
      </li>
      <li class="nav-item">
           <a data-toggle="tab" id="integrations" class="nav-link" href="#tabintegrations">Integraciones</a>
      </li>
   </ul>

   <div class="tab-content">
      <div id="tabsmsconfig" class="tab-pane fade show active" role="tabpanel" aria-labelledby="smsconfig">
         <p>
         <form method="POST">
		 
         <div class="form-group">
          <div class="row">		 
          <label for="token" class="col-md-4 col-form-label"><strong>Token:</strong></label>
          <div class="col-md-8">
           <input class="form-control" id="token" name="token" value="<?php echo $token; ?>" placeholder="Ingrese la credencial token">
		   <small>Debera contar con una cuenta o solicitarla a <a href="https://gamanet.pe/solicitud-de-cuenta-demo/" target="_blank">Gamanet</a></small>
           </div>
         </div>
		 </div>
		 
         <div class="form-group">
          <div class="row">		 
          <label for="medio" class="col-md-4 col-form-label"><strong>Medio:</strong></label>
          <div class="col-md-8">
             <select name="medio" id="medio" class="form-control" type="select">
                  <option value="sms" <?php if($medio=="sms") echo "selected"; ?>>SMS</option>
                  <option value="whatsapp" <?php if($medio=="whatsapp") echo "selected"; ?>>WhatsApp</option>
             </select>
             <small>Tipo de medio por el que se enviara el mensaje.</small>
           </div>
         </div>
		 </div>
		 
         <div class="form-group <?php if($medio=="whatsapp") echo "d-none"; ?>" id="smstype-group">
          <div class="row">		 
          <label for="smstype" class="col-md-4 col-form-label"><strong>Tipo de Remitente SMS:</strong></label>
          <div class="col-md-8">
             <select name="smstype" id="smstype" class="form-control" type="select">
                  <option value="0" <?php if($smstype=="0") echo "selected"; ?>>Remitente Largo</option>
                  <option value="1" <?php if($smstype=="1") echo "selected"; ?>>Remitente Corto</option>
             </select>
             <small>Tipo de remitente sms por defecto.</small>
           </div>
         </div>
		 </div>

         <div class="form-group">
          <div class="row">		 
          <label for="adminmobilenumber" class="col-md-4 col-form-label"><strong>Celular de Administrador:</strong></label>
          <div class="col-md-8">
           <input class="form-control" id="adminmobilenumber" name="adminmobilenumber" value="<?php echo $adminmobilenumber; ?>" placeholder="Ingrese Celular de Administrador">
		   <small>Puede agregar mas celulares separados por comas. ( Ej: 51911111111, 51922222222 )</small>
           </div>
         </div>
		 </div>

         <button id="btn-gamanet-save-config-general" type="submit" class="btn btn-primary" name="btn-gamanet-save-config-general">Guardar</button>
		 <span id="result-config-general"></span>
         </form>
         </p>
      </div>

      <div id="tabintegrations" class="tab-pane fade" role="tabpanel" aria-labelledby="integrations">
         <p>
         <form method="POST">

          <div class="form-group <?php if($plugin_cf7_active=="no") echo 'd-none'; ?>">
          <label><strong>Contact Form 7</strong></label>
          <div class="row">
             <label for="cf7_metabox" class="col-md-4 col-form-label">Agregar lengueta a plugin:</label>
             <div class="col-md-8">
                <select name="cf7_metabox" id="cf7_metabox" class="form-control" type="select">
                  <option value="0" <?php if($cf7_metabox=="0") echo "selected"; ?>>No activo</option>
                  <option value="1" <?php if($cf7_metabox=="1") echo "selected"; ?>>Activo</option>
                </select>
                <small>Agrega nuevas opciones de notificacion a Contact Form 7.</small>
             </div>
         </div>
		 <hr>
         </div>
		 
		 <div class="form-group">
          <label><strong>wpForms</strong></label>
          <div class="row">
          <label for="wpforms_process_complete" class="col-md-4 col-form-label">Notificar Envio de Formulario:</label>
          <div class="col-md-8">
              <select name="wpforms_process_complete" id="wpforms_process_complete" class="form-control" type="select">
                <option value="0" <?php if($wpforms_process_complete=="0") echo "selected"; ?>>No activo</option>
                <option value="1" <?php if($wpforms_process_complete=="1") echo "selected"; ?>>Activo</option>
              </select>
              <small>Envia una notificacion cuando se envia un formulario</small>
          </div>
		 </div>
		 
         <div id="wpforms_process_complete_more" class="row <?php if($wpforms_process_complete=="0") echo 'd-none'; ?>" >
   
         <label for="wpforms_process_complete_send_to" class="col-md-4 col-form-label"><i>Para:</i></label>
         <div class="col-md-8 form-inline">  
                               <select name="wpforms_process_complete_send_to" id="wpforms_process_complete_send_to" class="form-control" type="select">
                                     <option value="admin" <?php if($wpforms_process_complete_send_to=="admin") echo 'selected'; ?> >Administrador</option>
                                     <option value="subscribes_group" <?php if($wpforms_process_complete_send_to=="subscribes_group") echo 'selected'; ?>>Suscriptores</option>
                                </select>
                               <select name="wpforms_process_complete_send_to_subscribes_group_id" id="wpforms_process_complete_send_to_subscribes_group_id" class="form-control" type="select" style="<?php if($wpforms_process_complete_send_to!="subscribes_group") echo 'display:none"'; ?>" >
                                     
                                     <?php
									 	  if($wpforms_process_complete_send_to_subscribes_group_id==-1){
                                               echo '<option value="-1" selected>Todos ( '.$total_subscribes.' suscritores activos)</option>';
										  }else{
                                               echo '<option value="-1">Todos ( '.$total_subscribes.' suscritores activos)</option>';									
										  }

                                          foreach($list_subscribes_group as $key => $value){
                                                $id = $value['id'];
                                                $name = $value['name'];
												if($wpforms_process_complete_send_to_subscribes_group_id==$id){
                                                   echo '<option value="'.$id.'" selected>'.$name.'</option>';
												}else{
			                                       echo '<option value="'.$id.'">'.$name.'</option>';										
												}
                                           }
                                      ?>
                                </select>
          </div>
		 
		 
		 
          <label for="wpforms_process_complete_template" class="col-md-4 col-form-label"><i>Mensaje:</i></label>
          <div class="col-md-8">
              <textarea cols="50" rows="5" id="wpforms_process_complete_template" class="form-control" name="wpforms_process_complete_template" placeholder="Notificacion de %name% su correo es:  %email% mensaje: %textarea% , telefono: %text% "><?php echo $wpforms_process_complete_template; ?></textarea>
              <small>Variables:  %name%, %email%, %textarea%, %text% </small>
           </div>
         </div>
         <hr>		 
         </div>
		 
         <div class="form-group <?php if($plugin_woocommerce_active=="no") echo 'd-none'; ?>">
          <label><strong>WooCommerce</strong></label>
          <div class="row">
          <label for="wc_notif_new_order" class="col-md-4 col-form-label">Nueva Orden(Administrador):</label>
          <div class="col-md-8">
              <select name="wc_notif_new_order" id="wc_notif_new_order" class="form-control" type="select">
                <option value="0" <?php if($wc_notif_new_order=="0") echo "selected"; ?>>No activo</option>
                <option value="1" <?php if($wc_notif_new_order=="1") echo "selected"; ?>>Activo</option>
              </select>
              <small>Envia una notificacion al administrador cuando hay una nueva orden</small>
           </div>
         </div>

         <div id="wc_notif_new_order_more" class="row <?php if($wc_notif_new_order=="0") echo 'd-none'; ?>" >
          <label for="wc_notif_new_order_template" class="col-md-4 col-form-label"><i>Mensaje:</i></label>
          <div class="col-md-8">
              <textarea cols="50" rows="5" id="wc_notif_new_order_template" class="form-control" name="wc_notif_new_order_template" placeholder="Nuevo pedido # %order_id% . Ir al panel de pedidos para mas detalles."><?php echo $wc_notif_new_order_template; ?></textarea>
              <small>Variables: %order_id%, %status%, %total%, %billing_company%, %billing_phone%, %billing_first_name%, %billing_address_1% </small>
           </div>
		  </div>
		 
          <div class="row">
          <label for="wc_notif_new_order_self" class="col-md-4 col-form-label">Nueva Orden(Usuario):</label>
          <div class="col-md-8">
              <select name="wc_notif_new_order_self" id="wc_notif_new_order_self" class="form-control" type="select">
                <option value="0" <?php if($wc_notif_new_order_self=="0") echo "selected"; ?>>No activo</option>
                <option value="1" <?php if($wc_notif_new_order_self=="1") echo "selected"; ?>>Activo</option>
              </select>
              <small>Envia una notificacion al usuario cuando solicita una nueva orden</small>
           </div>
         </div>

        <div id="wc_notif_new_order_self_more" class="row <?php if($wc_notif_new_order_self=="0") echo 'd-none'; ?>" >		 
          <label for="wc_notif_new_order_self_template" class="col-md-4 col-form-label"><i>Mensaje:</i></label>
          <div class="col-md-8">
              <textarea cols="50" rows="5" id="wc_notif_new_order_self_template" class="form-control" name="wc_notif_new_order_self_template" placeholder="Su pedido # %order_id% se ha recibido. Gracias."><?php echo $wc_notif_new_order_self_template; ?></textarea>
              <small>Variables: %order_id%, %status%, %total%, %billing_company%, %billing_phone%, %billing_first_name%, %billing_address_1% </small>
           </div>
		 </div>
		 
		 <div class="row">
          <label for="wc_notif_created_customer" class="col-md-4 col-form-label">Registro nueva Cuenta(Adminstrador):</label>
          <div class="col-md-8">
              <select name="wc_notif_created_customer" id="wc_notif_created_customer" class="form-control" type="select">
                <option value="0" <?php if($wc_notif_created_customer=="0") echo "selected"; ?>>No activo</option>
                <option value="1" <?php if($wc_notif_created_customer=="1") echo "selected"; ?>>Activo</option>
              </select>
              <small>Envia una notificacion al administrador cuando se registra una nueva cuenta</small>
           </div>

         </div>

        <div id="wc_notif_created_customer_more" class="row <?php if($wc_notif_created_customer=="0") echo 'd-none'; ?>" >		 
          <label for="wc_notif_created_customer_template" class="col-md-4 col-form-label"><i>Mensaje:</i></label>
          <div class="col-md-8">
              <textarea cols="50" rows="5" id="wc_notif_created_customer_template" class="form-control" name="wc_notif_created_customer_template" placeholder="Se creo una nueva cuenta %user_login% ."><?php echo $wc_notif_created_customer_template; ?></textarea>
              <small>Variables: %customer_id%,  %user_email%, %user_login%, %billing_phone%</small>
           </div>
		 </div>
		 
		 
		 <div class="row">
          <label for="wc_notif_created_customer_self" class="col-md-4 col-form-label">Registro nueva Cuenta(Usuario):</label>
          <div class="col-md-8">
              <select name="wc_notif_created_customer_self" id="wc_notif_created_customer_self" class="form-control" type="select">
                <option value="0" <?php if($wc_notif_created_customer_self=="0") echo "selected"; ?>>No activo</option>
                <option value="1" <?php if($wc_notif_created_customer_self=="1") echo "selected"; ?>>Activo</option>
              </select>
              <small>Envia una notificacion al usuario cuando se registra una nueva cuenta</small>
           </div>
         </div>

        <div id="wc_notif_created_customer_self_more" class="row <?php if($wc_notif_created_customer_self=="0") echo 'd-none'; ?>" >		 
          <label for="wc_notif_created_customer_self_template" class="col-md-4 col-form-label"><i>Mensaje:</i></label>
          <div class="col-md-8">
              <textarea cols="50" rows="5" id="wc_notif_created_customer_self_template" class="form-control" name="wc_notif_created_customer_self_template" placeholder="Gracias por registrarse."><?php echo $wc_notif_created_customer_self_template; ?></textarea>
              <small>Variables: %customer_id%,  %user_email%, %user_login%, %billing_phone%</small>
           </div>		
         </div>	

		 
		 <div class="row">
          <label for="wc_notif_created_customer_add_db" class="col-md-4 col-form-label">Agregar Cuenta a Suscriptores:</label>
          <div class="col-md-8">
              <select name="wc_notif_created_customer_add_db" id="wc_notif_created_customer_add_db" class="form-control" type="select">
                <option value="0" <?php if($wc_notif_created_customer_add_db=="0") echo "selected"; ?>>No activo</option>
                <option value="1" <?php if($wc_notif_created_customer_add_db=="1") echo "selected"; ?>>Activo</option>
              </select>
              <small>Agregar la cuenta a la lista de suscriptores, cuando se crea una cuenta o finaliza un pedido.</small>
           </div>
         </div>

        <div id="wc_notif_created_customer_add_db_more" class="row <?php if($wc_notif_created_customer_add_db=="0") echo 'd-none'; ?>" >		 
          <label for="wc_notif_created_customer_add_db_group_id" class="col-md-4 col-form-label"><i>Grupo de Suscriptores:</i></label>
          <div class="col-md-8">
              <?php
                  if(count($list_subscribes_group)>0){ 
               ?>
              <select name="wc_notif_created_customer_add_db_group_id" id="wc_notif_created_customer_add_db_group_id" class="form-control" type="select">
              <?php
				  foreach($list_subscribes_group as $key => $value){
                     $id = $value['id'];
                     $name = $value['name'];
					 if($wc_notif_created_customer_add_db_group_id==$id){
                             echo '<option value="'.$id.'" selected>'.$name.'</option>';
					 }else{
			                 echo '<option value="'.$id.'">'.$name.'</option>';										
					 }
                  }
				  
				  
               ?>
              </select>
              <?php
                  }else{
                      echo 'No hay grupos. <a href="./admin.php?page=gamasms/admin/GroupsMenu.php">Agregar</a>';

                  }
              ?>

           </div>		
         </div>	
		 
		 
          <div class="row">
          <label for="wc_notif_processing_order" class="col-md-4 col-form-label">Procesando Orden(Usuario):</label>
          <div class="col-md-8">
              <select name="wc_notif_processing_order" id="wc_notif_processing_order" class="form-control" type="select">
                <option value="0" <?php if($wc_notif_processing_order=="0") echo "selected"; ?>>No activo</option>
                <option value="1" <?php if($wc_notif_processing_order=="1") echo "selected"; ?>>Activo</option>
              </select>
              <small>Envia una notificacion al usuario cuando la orden se esta procesando</small>
           </div>
         </div>

        <div id="wc_notif_processing_order_more" class="row <?php if($wc_notif_processing_order!="1") echo 'd-none'; ?>" >		 
          <label for="wc_notif_processing_order_template" class="col-md-4 col-form-label"><i>Mensaje:</i></label>
          <div class="col-md-8">
              <textarea cols="50" rows="5" id="wc_notif_processing_order_template" class="form-control" name="wc_notif_processing_order_template" placeholder="Su pedido # %order_id% esta siendo procesado. Gracias."><?php echo $wc_notif_processing_order_template; ?></textarea>
              <small>Variables: %order_id%, %status%, %total%, %billing_company%, %billing_phone%, %billing_first_name%, %billing_address_1% </small>
           </div>
		 </div>
		 

          <div class="row">
          <label for="wc_notif_cancelled_order" class="col-md-4 col-form-label">Cancelada Orden(Usuario):</label>
          <div class="col-md-8">
              <select name="wc_notif_cancelled_order" id="wc_notif_cancelled_order" class="form-control" type="select">
                <option value="0" <?php if($wc_notif_cancelled_order=="0") echo "selected"; ?>>No activo</option>
                <option value="1" <?php if($wc_notif_cancelled_order=="1") echo "selected"; ?>>Activo</option>
              </select>
              <small>Envia una notificacion al usuario cuando la orden se ha cancelado</small>
           </div>
         </div>

        <div id="wc_notif_cancelled_order_more" class="row <?php if($wc_notif_cancelled_order!="1") echo 'd-none'; ?>" >		 
          <label for="wc_notif_cancelled_order_template" class="col-md-4 col-form-label"><i>Mensaje:</i></label>
          <div class="col-md-8">
              <textarea cols="50" rows="5" id="wc_notif_cancelled_order_template" class="form-control" name="wc_notif_cancelled_order_template" placeholder="Su pedido # %order_id% se ha cancelado. Gracias."><?php echo $wc_notif_cancelled_order_template; ?></textarea>
              <small>Variables: %order_id%, %status%, %total%, %billing_company%, %billing_phone%, %billing_first_name%, %billing_address_1% </small>
           </div>
		 </div>
		 
		 
          <div class="row">
          <label for="wc_notif_completed_order" class="col-md-4 col-form-label">Completada Orden(Usuario):</label>
          <div class="col-md-8">
              <select name="wc_notif_completed_order" id="wc_notif_completed_order" class="form-control" type="select">
                <option value="0" <?php if($wc_notif_completed_order=="0") echo "selected"; ?>>No activo</option>
                <option value="1" <?php if($wc_notif_completed_order=="1") echo "selected"; ?>>Activo</option>
              </select>
              <small>Envia una notificacion al usuario cuando la orden se ha completado</small>
           </div>
         </div>

        <div id="wc_notif_completed_order_more" class="row <?php if($wc_notif_completed_order!="1") echo 'd-none'; ?>" >		 
          <label for="wc_notif_completed_order_template" class="col-md-4 col-form-label"><i>Mensaje:</i></label>
          <div class="col-md-8">
              <textarea cols="50" rows="5" id="wc_notif_completed_order_template" class="form-control" name="wc_notif_completed_order_template" placeholder="Su pedido # %order_id% se ha completado. Gracias."><?php echo $wc_notif_completed_order_template; ?></textarea>
              <small>Variables: %order_id%, %status%, %total%, %billing_company%, %billing_phone%, %billing_first_name%, %billing_address_1% </small>
           </div>
		 </div>
		 
		 
          <div class="row">
          <label for="wc_notif_pending_order" class="col-md-4 col-form-label">Pendiente Orden(Usuario):</label>
          <div class="col-md-8">
              <select name="wc_notif_pending_order" id="wc_notif_pending_order" class="form-control" type="select">
                <option value="0" <?php if($wc_notif_pending_order=="0") echo "selected"; ?>>No activo</option>
                <option value="1" <?php if($wc_notif_pending_order=="1") echo "selected"; ?>>Activo</option>
              </select>
              <small>Envia una notificacion al usuario cuando la orden esta pendiente</small>
           </div>
         </div>

        <div id="wc_notif_pending_order_more" class="row <?php if($wc_notif_pending_order!="1") echo 'd-none'; ?>" >		 
          <label for="wc_notif_pending_order_template" class="col-md-4 col-form-label"><i>Mensaje:</i></label>
          <div class="col-md-8">
              <textarea cols="50" rows="5" id="wc_notif_pending_order_template" class="form-control" name="wc_notif_pending_order_template" placeholder="Su pedido # %order_id% esta pendiente. Gracias."><?php echo $wc_notif_pending_order_template; ?></textarea>
              <small>Variables: %order_id%, %status%, %total%, %billing_company%, %billing_phone%, %billing_first_name%, %billing_address_1% </small>
           </div>
		 </div>
		 
		 
          <div class="row">
          <label for="wc_notif_failed_order" class="col-md-4 col-form-label">Fallo Orden(Usuario):</label>
          <div class="col-md-8">
              <select name="wc_notif_failed_order" id="wc_notif_failed_order" class="form-control" type="select">
                <option value="0" <?php if($wc_notif_failed_order=="0") echo "selected"; ?>>No activo</option>
                <option value="1" <?php if($wc_notif_failed_order=="1") echo "selected"; ?>>Activo</option>
              </select>
              <small>Envia una notificacion al usuario cuando la orden ha fallado</small>
           </div>
         </div>

        <div id="wc_notif_failed_order_more" class="row <?php if($wc_notif_failed_order!="1") echo 'd-none'; ?>" >		 
          <label for="wc_notif_failed_order_template" class="col-md-4 col-form-label"><i>Mensaje:</i></label>
          <div class="col-md-8">
              <textarea cols="50" rows="5" id="wc_notif_failed_order_template" class="form-control" name="wc_notif_failed_order_template" placeholder="Su pedido # %order_id% fallo. Gracias."><?php echo $wc_notif_failed_order_template; ?></textarea>
              <small>Variables: %order_id%, %status%, %total%, %billing_company%, %billing_phone%, %billing_first_name%, %billing_address_1% </small>
           </div>
		 </div>
		 
		 
          <div class="row">
          <label for="wc_notif_refunded_order" class="col-md-4 col-form-label">Reembolsado Orden(Usuario):</label>
          <div class="col-md-8">
              <select name="wc_notif_refunded_order" id="wc_notif_refunded_order" class="form-control" type="select">
                <option value="0" <?php if($wc_notif_refunded_order=="0") echo "selected"; ?>>No activo</option>
                <option value="1" <?php if($wc_notif_refunded_order=="1") echo "selected"; ?>>Activo</option>
              </select>
              <small>Envia una notificacion al usuario cuando la orden es Reembolsada.</small>
           </div>
         </div>

        <div id="wc_notif_refunded_order_more" class="row <?php if($wc_notif_refunded_order!="1") echo 'd-none'; ?>" >		 
          <label for="wc_notif_refunded_order_template" class="col-md-4 col-form-label"><i>Mensaje:</i></label>
          <div class="col-md-8">
              <textarea cols="50" rows="5" id="wc_notif_refunded_order_template" class="form-control" name="wc_notif_refunded_order_template" placeholder="Su pedido # %order_id% se ha Reembolsado.. Gracias."><?php echo $wc_notif_refunded_order_template; ?></textarea>
              <small>Variables: %order_id%, %status%, %total%, %billing_company%, %billing_phone%, %billing_first_name%, %billing_address_1% </small>
           </div>
		 </div>
		 
		 
          <div class="row">
          <label for="wc_notif_note_order" class="col-md-4 col-form-label">Nota agregada a la Orden(Usuario):</label>
          <div class="col-md-8">
              <select name="wc_notif_note_order" id="wc_notif_note_order" class="form-control" type="select">
                <option value="0" <?php if($wc_notif_note_order=="0") echo "selected"; ?>>No activo</option>
                <option value="1" <?php if($wc_notif_note_order=="1") echo "selected"; ?>>Activo</option>
              </select>
              <small>Envia una notificacion al usuario de nota agregada a la orden.</small>
           </div>
         </div>

        <div id="wc_notif_note_order_more" class="row <?php if($wc_notif_note_order!="1") echo 'd-none'; ?>" >		 
          <label for="wc_notif_note_order_template" class="col-md-4 col-form-label"><i>Mensaje:</i></label>
          <div class="col-md-8">
		  	  <small style="color:red" id="wc_notif_note_order_error"></small>
              <textarea cols="50" rows="5" id="wc_notif_note_order_template" class="form-control" name="wc_notif_note_order_template" placeholder="Una nota acaba de ser añadida a su pedido # %order_id%: %note% ."><?php echo $wc_notif_note_order_template; ?></textarea>
              <small>Variables: %order_id%, %note% %status%, %total%, %billing_company%, %billing_phone%, %billing_first_name%, %billing_address_1% </small>
           </div>
		 </div>
		 
		 
		 
         <hr>
         </div>		


        <div class="form-group <?php if($plugin_edd_active=="no") echo 'd-none'; ?>">
          <label><strong>Easy Digital Downloads</strong></label>
          <div class="row">
          <label for="edd_notif_new_order" class="col-md-4 col-form-label">Nueva Orden:</label>
          <div class="col-md-8">
              <select name="edd_notif_new_order" id="edd_notif_new_order" class="form-control" type="select">
                <option value="0" <?php if($edd_notif_new_order=="0") echo "selected"; ?>>No activo</option>
                <option value="1" <?php if($edd_notif_new_order=="1") echo "selected"; ?>>Activo</option>
              </select>
              <small>Envia una notificacion al administrador cuando hay una nueva orden</small>
           </div>
         </div>
		 
		 <div id="edd_notif_new_order_more" class="row <?php if($edd_notif_new_order=="0") echo 'd-none'; ?>" >
          <label for="edd_notif_new_order_template" class="col-md-4 col-form-label"><i>Mensaje:</i></label>
          <div class="col-md-8">
              <textarea cols="50" rows="5" id="edd_notif_new_order_template" class="form-control" name="edd_notif_new_order_template"><?php echo $edd_notif_new_order_template; ?></textarea>
              <small>email de cliente: %edd_email%, nombre de cliente: %edd_first%, apellido de cliente: %edd_last%</small>
           </div>
		 </div>
         <hr>		 
         </div>
		 

        <div class="form-group">
          <label><strong>WordPress Publish Post</strong></label>
          <div class="row">
          <label for="gamasms_publish_post" class="col-md-4 col-form-label">Nuevo Post:</label>
          <div class="col-md-8">
              <select name="gamasms_publish_post" id="gamasms_publish_post" class="form-control" type="select">
                <option value="0" <?php if($gamasms_publish_post=="0") echo "selected"; ?>>No activo</option>
                <option value="1" <?php if($gamasms_publish_post=="1") echo "selected"; ?>>Activo</option>
              </select>
              <small>Envia una notificacion cuando se publica un nuevo post</small>
           </div>
         </div>
		 
		 <div id="gamasms_publish_post_more" class="row <?php if($gamasms_publish_post=="0") echo 'd-none'; ?>" >
		 
         <label for="gamasms_publish_post_send_to" class="col-md-4 col-form-label">Para:</label>
         <div class="col-md-8 form-inline">  
                               <select name="gamasms_publish_post_send_to" id="gamasms_publish_post_send_to" class="form-control" type="select">
                                     <option value="admin" <?php if($gamasms_publish_post_send_to=="admin") echo 'selected'; ?> >Administrador</option>
                                     <option value="subscribes_group" <?php if($gamasms_publish_post_send_to=="subscribes_group") echo 'selected'; ?>>Suscriptores</option>
                                </select>
                               <select name="gamasms_publish_post_send_to_subscribes_group_id" id="gamasms_publish_post_send_to_subscribes_group_id" class="form-control" type="select" style="<?php if($gamasms_publish_post_send_to!="subscribes_group") echo 'display:none"'; ?>" >
                                     
                                     <?php
									 	  if($gamasms_publish_post_send_to_subscribes_group_id==-1){
                                               echo '<option value="-1" selected>Todos ( '.$total_subscribes.' suscritores activos)</option>';
										  }else{
                                               echo '<option value="-1">Todos ( '.$total_subscribes.' suscritores activos)</option>';								
										  }

                                          foreach($list_subscribes_group as $key => $value){
                                                $id = $value['id'];
                                                $name = $value['name'];
												if($gamasms_publish_post_send_to_subscribes_group_id==$id){
                                                   echo '<option value="'.$id.'" selected>'.$name.'</option>';
												}else{
			                                       echo '<option value="'.$id.'">'.$name.'</option>';										
												}
                                           }
                                      ?>
                                </select>
          </div>
		 
		 
          <label for="gamasms_publish_post_template" class="col-md-4 col-form-label"><i>Mensaje:</i></label>
          <div class="col-md-8">
              <textarea cols="50" rows="5" id="gamasms_publish_post_template" class="form-control" name="gamasms_publish_post_template" placeholder="Hay un nuevo post %title% haga clic en el siguiente enlace para leerlo %permalink%"><?php echo $gamasms_publish_post_template; ?></textarea>
              <small>%post_id%, %author_id%, %author_name%, %author_email% , %title%, %permalink%</small>
           </div>
		 </div>
         <hr>
         </div>
		 
		 
        <div class="form-group">
          <label><strong>WordPress Comentario Post</strong></label>
          <div class="row">
          <label for="gamasms_comment_post" class="col-md-4 col-form-label">Comentario Post:</label>
          <div class="col-md-8">
              <select name="gamasms_comment_post" id="gamasms_comment_post" class="form-control" type="select">
                <option value="0" <?php if($gamasms_comment_post=="0") echo "selected"; ?>>No activo</option>
                <option value="1" <?php if($gamasms_comment_post=="1") echo "selected"; ?>>Activo</option>
              </select>
              <small>Envia una notificacion cuando se publica un nuevo comentario</small>
           </div>
         </div>
		
		 <div id="gamasms_comment_post_more" class="row <?php if($gamasms_comment_post=="0") echo 'd-none'; ?>" >	

         <label for="gamasms_comment_post_send_to" class="col-md-4 col-form-label"><i>Para:</i></label>
         <div class="col-md-8 form-inline">  
                               <select name="gamasms_comment_post_send_to" id="gamasms_comment_post_send_to" class="form-control" type="select">
                                     <option value="admin" <?php if($gamasms_comment_post_send_to=="admin") echo 'selected'; ?> >Administrador</option>
                                     <option value="subscribes_group" <?php if($gamasms_comment_post_send_to=="subscribes_group") echo 'selected'; ?>>Suscriptores</option>
                                </select>
                               <select name="gamasms_comment_post_send_to_subscribes_group_id" id="gamasms_comment_post_send_to_subscribes_group_id" class="form-control" type="select" style="<?php if($gamasms_comment_post_send_to!="subscribes_group") echo 'display:none"'; ?>" >
                                     
                                     <?php
									 	  if($gamasms_comment_post_send_to_subscribes_group_id=="-1"){
                                               echo "<option value=-1 selected>Todos ( ".$total_subscribes." suscritores activos)</option>";
										  }else{
                                               echo "<option value=-1>Todos ( ".$total_subscribes." suscritores activos)</option>";									
										  }

                                          foreach($list_subscribes_group as $key => $value){
                                                $id = $value['id'];
                                                $name = $value['name'];
												if($gamasms_comment_post_send_to_subscribes_group_id==$id){
                                                   echo '<option value="'.$id.'" selected>'.$name.'</option>';
												}else{
			                                       echo '<option value="'.$id.'">'.$name.'</option>';										
												}
                                           }
                                      ?>
                                </select>
          </div>

		 
          <label for="gamasms_comment_post_template" class="col-md-4 col-form-label"><i>Mensaje:</i></label>
          <div class="col-md-8">
              <textarea cols="50" rows="5" id="gamasms_comment_post_template" class="form-control" name="gamasms_comment_post_template" placeholder="Hay un nuevo comentario del post %title% haga clic en el siguiente enlace para leerlo %permalink%"><?php echo $gamasms_comment_post_template; ?></textarea>
              <small>%comment_id%, %author_id%, %author_name%, %author_email% , %title%, %permalink%</small>
           </div>
		 </div>
          <hr>		   
         </div>
		 

        <div class="form-group <?php if($plugin_gform_active=="no") echo 'd-none'; ?>">
          <label><strong>Gravity Forms</strong></label>
          <div class="row">
          <label for="gform_after_submission" class="col-md-4 col-form-label">Form Post:</label>
          <div class="col-md-8">
              <select name="gform_after_submission" id="gform_after_submission" class="form-control" type="select">
                <option value="0" <?php if($gform_after_submission=="0") echo "selected"; ?>>No activo</option>
                <option value="1" <?php if($gform_after_submission=="1") echo "selected"; ?>>Activo</option>
              </select>
              <small>Envia una notificacion cuando se envia un formulario</small>
           </div>
         </div>
		
		 <div id="gform_after_submission_more" class="row <?php if($gform_after_submission=="0") echo 'd-none'; ?>" >	

         <label for="gform_after_submission_send_to" class="col-md-4 col-form-label"><i>Para:</i></label>
         <div class="col-md-8 form-inline">  
                               <select name="gform_after_submission_send_to" id="gform_after_submission_send_to" class="form-control" type="select">
                                     <option value="admin" <?php if($gform_after_submission_send_to=="admin") echo 'selected'; ?> >Administrador</option>
                                     <option value="subscribes_group" <?php if($gform_after_submission_send_to=="subscribes_group") echo 'selected'; ?>>Suscriptores</option>
                                </select>
                               <select name="gform_after_submission_send_to_subscribes_group_id" id="gform_after_submission_send_to_subscribes_group_id" class="form-control" type="select" style="<?php if($gform_after_submission_send_to!="subscribes_group") echo 'display:none"'; ?>" >
                                     
                                     <?php
									 	  if($gform_after_submission_send_to_subscribes_group_id=="-1"){
                                               echo "<option value=-1 selected>Todos ( ".$total_subscribes." suscritores activos)</option>";
										  }else{
                                               echo "<option value=-1>Todos ( ".$total_subscribes." suscritores activos)</option>";									
										  }

                                          foreach($list_subscribes_group as $key => $value){
                                                $id = $value['id'];
                                                $name = $value['name'];
												if($gform_after_submission_send_to_subscribes_group_id==$id){
                                                   echo '<option value="'.$id.'" selected>'.$name.'</option>';
												}else{
			                                       echo '<option value="'.$id.'">'.$name.'</option>';										
												}
                                           }
                                      ?>
                                </select>
          </div>

		 
          <label for="gform_after_submission_template" class="col-md-4 col-form-label"><i>Mensaje:</i></label>
          <div class="col-md-8">
              <textarea cols="50" rows="5" id="gform_after_submission_template" class="form-control" name="gform_after_submission_template" placeholder="Se recibio formularion con los siguentes valores de entrada  %all_inputs%."><?php echo $gform_after_submission_template; ?></textarea>
              <small>%form_id%, %url%, %name%, %all_inputs%</small>
           </div>
		   
		   <label for="gform_after_submission_forms" class="col-md-4 col-form-label"><i>Formularios:</i></label>
		    <div class="col-md-8">
              <select name="gform_after_submission_forms" id="gform_after_submission_forms" class="form-control" type="select">
                <option value="0" <?php if($gform_after_submission_forms=="0") echo "selected"; ?>>Todos</option>
                <option value="1" <?php if($gform_after_submission_forms=="1") echo "selected"; ?>>Algunos</option>
              </select>
              <small>Asigna los formularios que lanzaran la notificacion.</small>
			  
			  <div id="gform_after_submission_forms-group" class="<?php if($gform_after_submission_forms=="0") echo 'd-none'; ?>" >
              <input class="form-control" id="gform_after_submission_forms_ids" name="gform_after_submission_forms_ids" value="<?php echo $gform_after_submission_forms_ids; ?>" placeholder="Ingrese el numero identificador del formulario">
              <small>ID [form_id]. Puede asignar varios identificadores de formularios, separados por comas ejemplo: 1,5,12,23</small>
		      </div>
			  
           </div>
		   

		   
		   
		   
		 </div>
		  <hr>	
         </div>
		 
		 
		 


         <button id="btn-gamanet-save-config-integrations" type="submit" class="btn btn-primary" name="btn-gamanet-save-config-integrations">Guardar</button>
		 <span id="result-config-integrations"></span>
         </form>
         </p>
      </div>
   </div>

<?php

   }else{
	   echo "No tienes permisos para acceder.";
   }
?>

</div>
