public function get_form_expiry_stats($form)
 {
     //die('called');
     $form_id = $form->get_form_id();
     $form_options = $form->get_form_options();
     $criterian = $form_options->form_expired_by;
     $remaining = (object) array('state' => 'perpetual', 'criteria' => 'both', 'remaining_days' => 'undefined', 'remaining_subs' => 'undefined', 'sub_limit' => 0);
     if (!$form->form_should_auto_expire || $this->get_setting('display_progress_bar') !== 'yes') {
         return $remaining;
     }
     if ($criterian == "date") {
         if (RM_DBManager::is_expired_by_date($form_id, $remaining->remaining_days)) {
             $remaining->state = 'expired';
             $remaining->criteria = 'date';
         } else {
             $remaining->state = 'not_expired';
             $remaining->criteria = 'date';
         }
         return $remaining;
     } elseif ($criterian == "submissions") {
         if (RM_DBManager::is_expired_by_submissions($form_id, $form_options->form_submissions_limit, $remaining->remaining_subs)) {
             $remaining->state = 'expired';
             $remaining->criteria = 'subs';
         } else {
             $remaining->state = 'not_expired';
             $remaining->criteria = 'subs';
             $remaining->sub_limit = $form_options->form_submissions_limit;
         }
         return $remaining;
     } elseif ($criterian == "both") {
         if (RM_DBManager::is_expired_by_date($form_id, $remaining->remaining_days) || RM_DBManager::is_expired_by_submissions($form_id, $form_options->form_submissions_limit, $remaining->remaining_subs)) {
             $remaining->state = 'expired';
             $remaining->criteria = 'both';
         } else {
             $remaining->state = 'not_expired';
             $remaining->criteria = 'both';
             $remaining->sub_limit = $form_options->form_submissions_limit;
         }
         return $remaining;
     }
 }
 public function get_form_expiry_stats($form, $is_form_object = true)
 {
     if ($is_form_object) {
         $form_id = $form->get_form_id();
         $form_options = $form->get_form_options();
         $criterian = $form_options->form_expired_by;
         $form_should_auto_expire = $form->get_form_should_auto_expire();
     } else {
         $form_id = $form->form_id;
         $form_options = maybe_unserialize($form->form_options);
         $criterian = $form_options->form_expired_by;
         $form_should_auto_expire = $form->form_should_auto_expire;
     }
     $remaining = (object) array('state' => 'perpetual', 'criteria' => 'both', 'remaining_days' => 'undefined', 'remaining_subs' => 'undefined', 'sub_limit' => 0, 'date_limit' => 0);
     if (!$form_should_auto_expire) {
         return $remaining;
     }
     if ($criterian == "date") {
         if (RM_DBManager::is_expired_by_date($form_id, $remaining->remaining_days)) {
             $remaining->state = 'expired';
             $remaining->criteria = 'date';
             $remaining->date_limit = $form_options->form_expiry_date;
         } else {
             $remaining->state = 'not_expired';
             $remaining->criteria = 'date';
             $remaining->date_limit = $form_options->form_expiry_date;
         }
         return $remaining;
     } elseif ($criterian == "submissions") {
         if (RM_DBManager::is_expired_by_submissions($form_id, $form_options->form_submissions_limit, $remaining->remaining_subs)) {
             $remaining->state = 'expired';
             $remaining->criteria = 'subs';
             $remaining->sub_limit = $form_options->form_submissions_limit;
         } else {
             $remaining->state = 'not_expired';
             $remaining->criteria = 'subs';
             $remaining->sub_limit = $form_options->form_submissions_limit;
         }
         return $remaining;
     } elseif ($criterian == "both") {
         if (RM_DBManager::is_expired_by_date($form_id, $remaining->remaining_days) || RM_DBManager::is_expired_by_submissions($form_id, $form_options->form_submissions_limit, $remaining->remaining_subs)) {
             $remaining->state = 'expired';
             $remaining->criteria = 'both';
             $remaining->sub_limit = $form_options->form_submissions_limit;
             $remaining->date_limit = $form_options->form_expiry_date;
         } else {
             $remaining->state = 'not_expired';
             $remaining->criteria = 'both';
             $remaining->sub_limit = $form_options->form_submissions_limit;
             $remaining->date_limit = $form_options->form_expiry_date;
         }
         return $remaining;
     }
 }