public function getPackageFields($vars = null)
 {
     Loader::loadHelpers($this, array("Html"));
     // Set any module fields
     $fields = new ModuleFields();
     $fields->setHtml("\n            <script type=\"text/javascript\">\n                \$(document).ready(function() {\n                    // Re-fetch module options\n                    \$('#type, #manageapps, #firewall').change(function() {\n                        fetchModuleOptions();\n                    });\n                });\n            </script>\n        ");
     // Fetch all packages available for the given server or server group
     $module_row = null;
     if (isset($vars->module_group) && $vars->module_group == "") {
         // Set a module row if one is given
         if (isset($vars->module_row) && $vars->module_row > 0) {
             $module_row = $this->getModuleRow($vars->module_row);
         } else {
             // Set the first module row of any that exist
             $rows = $this->getModuleRows();
             if (isset($rows[0])) {
                 $module_row = $rows[0];
             }
             unset($rows);
         }
     } else {
         // Set the first module row from the list of servers in the selected group
         $rows = $this->getModuleRows($vars->module_group);
         if (isset($rows[0])) {
             $module_row = $rows[0];
         }
         unset($rows);
     }
     $packages = array();
     $acls = array();
     if ($module_row) {
         $packages = $this->getPkgs($module_row);
         $acls = array('' => Language::_("tastycpanel.package.acl_default", true)) + $this->getAcls($module_row);
     }
     $package = $fields->label(Language::_("tastycpanel.package", true), "package_name");
     $package->attach($fields->fieldSelect("meta[package]", $packages, $this->Html->ifSet($vars->meta['package']), array('id' => "package_name")));
     $fields->setField($package);
     if ($module_row && $module_row->meta->username == "root") {
         $select_options = array('standard' => "Standard", 'reseller' => "Reseller");
         $typefield = $fields->label(Language::_("tastycpanel.package.type", true), "type");
         $typefield->attach($fields->fieldSelect("meta[type]", $select_options, $this->Html->ifSet($vars->meta['type']), array('id' => "type")));
         $fields->setField($typefield);
     } else {
         $typefield = $fields->fieldHidden("meta[type]", "standard");
         $fields->setField($typefield);
     }
     if ($vars->meta['type'] === "reseller") {
         $acl = $fields->label(Language::_("tastycpanel.package.acl", true), "acls");
         $acl->attach($fields->fieldSelect("meta[acls]", $acls, $this->Html->ifSet($vars->meta['acls']), array('id' => "acls")));
         $fields->setField($acl);
     }
     $select_options = array('true' => "Enable", 'false' => "Disable");
     $additionaldiskfield = $fields->label(Language::_("tastycpanel.additionaldisk", true), "additionaldisk");
     $additionaldiskfield->attach($fields->tooltip(Language::_("tastycpanel.additionaldisktip", true)));
     $additionaldiskfield->attach($fields->fieldSelect("meta[additionaldisk]", $select_options, $this->Html->ifSet($vars->meta['additionaldisk']), array('id' => "additionaldisk")));
     $fields->setField($additionaldiskfield);
     $additionalbandwidthfield = $fields->label(Language::_("tastycpanel.additionalbandwidth", true), "additionalbandwidth");
     $additionalbandwidthfield->attach($fields->tooltip(Language::_("tastycpanel.additionalbandwidthtip", true)));
     $additionalbandwidthfield->attach($fields->fieldSelect("meta[additionalbandwidth]", $select_options, $this->Html->ifSet($vars->meta['additionalbandwidth']), array('id' => "additionalbandwidth")));
     $fields->setField($additionalbandwidthfield);
     $accountusagefield = $fields->label(Language::_("tastycpanel.accountusage", true), "accountusage");
     $accountusagefield->attach($fields->fieldSelect("meta[accountusage]", $select_options, $this->Html->ifSet($vars->meta['accountusage']), array('id' => "accountusage")));
     $fields->setField($accountusagefield);
     $changepasswordfield = $fields->label(Language::_("tastycpanel.changepassword", true), "changepassword");
     $changepasswordfield->attach($fields->fieldSelect("meta[changepassword]", $select_options, $this->Html->ifSet($vars->meta['changepassword']), array('id' => "changepassword")));
     $fields->setField($changepasswordfield);
     $emailfield = $fields->label(Language::_("tastycpanel.email", true), "email");
     $emailfield->attach($fields->fieldSelect("meta[email]", $select_options, $this->Html->ifSet($vars->meta['email']), array('id' => "email")));
     $fields->setField($emailfield);
     $emailforwardersfield = $fields->label(Language::_("tastycpanel.emailforwarders", true), "emailforwarders");
     $emailforwardersfield->attach($fields->fieldSelect("meta[emailforwarders]", $select_options, $this->Html->ifSet($vars->meta['emailforwarders']), array('id' => "emailforwarders")));
     $fields->setField($emailforwardersfield);
     $ftpaccountsfield = $fields->label(Language::_("tastycpanel.ftpaccounts", true), "ftpaccounts");
     $ftpaccountsfield->attach($fields->fieldSelect("meta[ftpaccounts]", $select_options, $this->Html->ifSet($vars->meta['ftpaccounts']), array('id' => "ftpaccounts")));
     $fields->setField($ftpaccountsfield);
     $subdomainsfield = $fields->label(Language::_("tastycpanel.subdomains", true), "subdomains");
     $subdomainsfield->attach($fields->fieldSelect("meta[subdomains]", $select_options, $this->Html->ifSet($vars->meta['subdomains']), array('id' => "subdomains")));
     $fields->setField($subdomainsfield);
     $addondomainsfield = $fields->label(Language::_("tastycpanel.addondomains", true), "addondomains");
     $addondomainsfield->attach($fields->fieldSelect("meta[addondomains]", $select_options, $this->Html->ifSet($vars->meta['addondomains']), array('id' => "addondomains")));
     $fields->setField($addondomainsfield);
     $parkeddomainsfield = $fields->label(Language::_("tastycpanel.parkeddomains", true), "parkeddomains");
     $parkeddomainsfield->attach($fields->fieldSelect("meta[parkeddomains]", $select_options, $this->Html->ifSet($vars->meta['parkeddomains']), array('id' => "parkeddomains")));
     $fields->setField($parkeddomainsfield);
     $databasesfield = $fields->label(Language::_("tastycpanel.databases", true), "databases");
     $databasesfield->attach($fields->fieldSelect("meta[databases]", $select_options, $this->Html->ifSet($vars->meta['databases']), array('id' => "databases")));
     $fields->setField($databasesfield);
     $cronjobsfield = $fields->label(Language::_("tastycpanel.cronjobs", true), "cronjobs");
     $cronjobsfield->attach($fields->fieldSelect("meta[cronjobs]", $select_options, $this->Html->ifSet($vars->meta['cronjobs']), array('id' => "cronjobs")));
     $fields->setField($cronjobsfield);
     $backupsfield = $fields->label(Language::_("tastycpanel.backups", true), "backups");
     $backupsfield->attach($fields->fieldSelect("meta[backups]", $select_options, $this->Html->ifSet($vars->meta['backups']), array('id' => "backups")));
     $fields->setField($backupsfield);
     $ipblockerfield = $fields->label(Language::_("tastycpanel.ipblocker", true), "ipblocker");
     $ipblockerfield->attach($fields->fieldSelect("meta[ipblocker]", $select_options, $this->Html->ifSet($vars->meta['ipblocker']), array('id' => "ipblocker")));
     $fields->setField($ipblockerfield);
     $firewall = $fields->label(Language::_("tastycpanel.firewall_admin", true), "firewall");
     $firewall->attach($fields->fieldSelect("meta[firewall]", $select_options, $this->Html->ifSet($vars->meta['firewall']), array('id' => "firewall")));
     $fields->setField($firewall);
     if ($vars->meta['firewall'] === "true") {
         $firewall_options = array('show' => "Show & Allow Client To Enter The IP Address To Unblock it From CSF", 'hide' => "Use the Client's IP Address");
         $firewall_ad = $fields->label(Language::_("tastycpanel.firewall_ip", true), "firewall_ip");
         $firewall_ad->attach($fields->fieldSelect("meta[firewall_ip]", $firewall_options, $this->Html->ifSet($vars->meta['firewall_ip']), array('id' => "firewall_ip")));
         $fields->setField($firewall_ad);
     }
     $manage_select = array('false' => "Disable", 'softaculous' => "Softaculous", 'installatron' => "Installatron");
     $manageapps = $fields->label(Language::_("tastycpanel.manageapps", true), "manageapps");
     $manageapps->attach($fields->fieldSelect("meta[manageapps]", $manage_select, $this->Html->ifSet($vars->meta['manageapps']), array('id' => "manageapps")));
     $fields->setField($manageapps);
     if ($vars->meta['type'] === "reseller") {
         $whmfield = $fields->label(Language::_("tastycpanel.whm_login", true), "whm_login");
         $whmfield->attach($fields->fieldSelect("meta[whm_login]", $select_options, $this->Html->ifSet($vars->meta['whm_login']), array('id' => "whm_login")));
         $fields->setField($whmfield);
     }
     $cpanelfield = $fields->label(Language::_("tastycpanel.cpanel_login", true), "cpanel_login");
     $cpanelfield->attach($fields->fieldSelect("meta[cpanel_login]", $select_options, $this->Html->ifSet($vars->meta['cpanel_login']), array('id' => "cpanel_login")));
     $fields->setField($cpanelfield);
     $webmailfield = $fields->label(Language::_("tastycpanel.webmail_login", true), "webmail_login");
     $webmailfield->attach($fields->fieldSelect("meta[webmail_login]", $select_options, $this->Html->ifSet($vars->meta['webmail_login']), array('id' => "webmail_login")));
     $fields->setField($webmailfield);
     $phpmyadminfield = $fields->label(Language::_("tastycpanel.phpmyadmin_login", true), "phpmyadmin_login");
     $phpmyadminfield->attach($fields->fieldSelect("meta[phpmyadmin_login]", $select_options, $this->Html->ifSet($vars->meta['phpmyadmin_login']), array('id' => "phpmyadmin_login")));
     $fields->setField($phpmyadminfield);
     $filemanager_login = $fields->label(Language::_("tastycpanel.filemanager_login", true), "filemanager_login");
     $filemanager_login->attach($fields->fieldSelect("meta[filemanager_login]", $select_options, $this->Html->ifSet($vars->meta['filemanager_login']), array('id' => "filemanager_login")));
     $fields->setField($filemanager_login);
     return $fields;
 }