<form action="<?php echo esc_url($pageurl);?>&noheader=1" method="post" id="smpush_jform" class="validate">
<input type="hidden" name="id" value="<?php echo esc_attr($token['id']);?>">
   <div id="post-body" class="metabox-holder columns-2">
      <div id="post-body-content" class="edit-form-section">
         <div id="namediv" class="stuffbox">
            <h3><label><?php echo ($token['id']==0)? esc_html__('Add New Subscriber', 'smio-push-notification') : esc_html__('Edit Subscriber Info', 'smio-push-notification') ;?></label></h3>
            <div class="inside">
               <table class="form-table">
                <tbody>
                  <tr valign="top" class="form-required">
                     <td class="first"><?php echo esc_html__('Device Token', 'smio-push-notification')?></td>
                     <td>
                     <textarea name="device_token" rows="5" cols="40" aria-required="true"><?php echo esc_attr($token['device_token']);?></textarea>
                     </td>
                  </tr>
                  <tr valign="top">
                     <td class="first"><?php echo esc_html__('Information', 'smio-push-notification')?></td>
                     <td>
                     <textarea name="information" rows="5" cols="40"><?php echo esc_attr($token['information']);?></textarea>
                     </td>
                  </tr>
                  <tr valign="top">
                     <td class="first"><?php echo esc_html__('Type', 'smio-push-notification')?></td>
                     <td>
                     <select name="device_type">
                        <option value="<?php echo esc_attr($types_name->ios_name);?>">iOS</option>
                        <option value="<?php echo esc_attr($types_name->iosfcm_name);?>" <?php if($token['device_type'] == $types_name->iosfcm_name){?>selected="selected"<?php }?>>iOS FCM</option>
                        <option value="<?php echo esc_attr($types_name->android_name);?>" <?php if($token['device_type'] == $types_name->android_name){?>selected="selected"<?php }?>>Android</option>
                        <option value="<?php echo esc_attr($types_name->wp_name);?>" <?php if($token['device_type'] == $types_name->wp_name){?>selected="selected"<?php }?>>Windows Phone</option>
                        <option value="<?php echo esc_attr($types_name->wp10_name);?>" <?php if($token['device_type'] == $types_name->wp10_name){?>selected="selected"<?php }?>>Windows 10</option>
                        <option value="<?php echo esc_attr($types_name->bb_name);?>" <?php if($token['device_type'] == $types_name->bb_name){?>selected="selected"<?php }?>>BlackBerry</option>
                        <option value="<?php echo esc_attr($types_name->chrome_name);?>" <?php if($token['device_type'] == $types_name->chrome_name){?>selected="selected"<?php }?>>Chrome</option>
                        <option value="<?php echo esc_attr($types_name->safari_name);?>" <?php if($token['device_type'] == $types_name->safari_name){?>selected="selected"<?php }?>>Safari</option>
                        <option value="<?php echo esc_attr($types_name->firefox_name);?>" <?php if($token['device_type'] == $types_name->firefox_name){?>selected="selected"<?php }?>>Firefox</option>
                        <option value="<?php echo esc_attr($types_name->opera_name);?>" <?php if($token['device_type'] == $types_name->opera_name){?>selected="selected"<?php }?>>Opera</option>
                        <option value="<?php echo esc_attr($types_name->edge_name);?>" <?php if($token['device_type'] == $types_name->edge_name){?>selected="selected"<?php }?>>Edge</option>
                        <option value="<?php echo esc_attr($types_name->samsung_name);?>" <?php if($token['device_type'] == $types_name->samsung_name){?>selected="selected"<?php }?>>Samsung Browser</option>
                        <option value="<?php echo esc_attr($types_name->viber_name);?>" <?php if($token['device_type'] == $types_name->viber_name){?>selected="selected"<?php }?>>Viber</option>
                        <option value="<?php echo esc_attr($types_name->fbmsn_name);?>" <?php if($token['device_type'] == $types_name->fbmsn_name){?>selected="selected"<?php }?>>Facebook Messenger</option>
                        <option value="<?php echo esc_attr($types_name->fbnotify_name);?>" <?php if($token['device_type'] == $types_name->fbnotify_name){?>selected="selected"<?php }?>>Facebook Notification</option>
                        <option value="<?php echo esc_attr($types_name->email_name);?>" <?php if($token['device_type'] == $types_name->email_name){?>selected="selected"<?php }?>>Newsletter</option>
                     </select>
                     </td>
                  </tr>
                  <tr valign="top">
                     <td class="first"><?php echo esc_html__('Channels', 'smio-push-notification')?></td>
                     <td>
                     <select name="channels[]" multiple>
                     <?php foreach($channels as $channel){?>
                        <option value="<?php echo esc_attr($channel->id);?>" <?php if(in_array($channel->id, $token['channels'])){?>selected="selected"<?php }?>><?php echo esc_attr($channel->title);?></option>
                     <?php }?>
                     </select>
                     </td>
                  </tr>
                  <tr valign="top">
                     <td class="first"><?php echo esc_html__('Latitude Point', 'smio-push-notification')?></td>
                     <td><input name="latitude" value="<?php echo esc_attr($token['latitude']);?>" type="text" size="40"></td>
                  </tr>
                  <tr valign="top">
                     <td class="first"><?php echo esc_html__('Longitude Point', 'smio-push-notification')?></td>
                     <td><input name="longitude" value="<?php echo esc_attr($token['longitude']);?>" type="text" size="40"></td>
                  </tr>
                  <tr valign="top">
                     <td class="first"><?php echo esc_html__('Active', 'smio-push-notification')?></td>
                     <td>
                     <select name="active">
                        <option value="1"><?php echo esc_html__('Yes', 'smio-push-notification')?></option>
                        <option value="0" <?php if($token['active'] == 0){?>selected="selected"<?php }?>><?php echo esc_html__('No', 'smio-push-notification')?></option>
                     </select>
                     </td>
                  </tr>
                  <tr valign="top">
                    <td colspan="2"><input type="submit" name="submit" id="smio-submit" class="button button-primary" style="width: 120px;" value="<?php echo esc_html__('Save Changes', 'smio-push-notification')?>">
                    <img src="<?php echo smpush_imgpath;?>/wpspin_light.gif" class="smpush_process" alt="" /></td>
                 </tr>
                </tbody>
              </table>
            </div>
         </div>
      </div>
   </div>
</form>
