public function __construct()
 {
     $this->bootstrap = true;
     $this->required_database = true;
     $this->required_fields = array('newsletter', 'optin');
     $this->table = 'customer';
     $this->className = 'Customer';
     $this->lang = false;
     $this->deleted = true;
     $this->explicitSelect = true;
     $this->allow_export = true;
     $this->addRowAction('edit');
     $this->addRowAction('view');
     $this->addRowAction('delete');
     $this->bulk_actions = array('delete' => array('text' => $this->l('Delete selected'), 'confirm' => $this->l('Delete selected items?'), 'icon' => 'icon-trash'));
     $this->context = Context::getContext();
     $this->default_form_language = $this->context->language->id;
     $titles_array = array();
     $genders = Gender::getGenders($this->context->language->id);
     foreach ($genders as $gender) {
         /** @var Gender $gender */
         $titles_array[$gender->id_gender] = $gender->name;
     }
     $this->_join = 'LEFT JOIN ' . _DB_PREFIX_ . 'gender_lang gl ON (a.id_gender = gl.id_gender AND gl.id_lang = ' . (int) $this->context->language->id . ')';
     $this->_use_found_rows = false;
     $this->fields_list = array('id_customer' => array('title' => $this->l('ID'), 'align' => 'text-center', 'class' => 'fixed-width-xs'), 'title' => array('title' => $this->l('Social title'), 'filter_key' => 'a!id_gender', 'type' => 'select', 'list' => $titles_array, 'filter_type' => 'int', 'order_key' => 'gl!name'), 'firstname' => array('title' => $this->l('First name')), 'lastname' => array('title' => $this->l('Last name')), 'email' => array('title' => $this->l('Email address')));
     if (Configuration::get('PS_B2B_ENABLE')) {
         $this->fields_list = array_merge($this->fields_list, array('company' => array('title' => $this->l('Company'))));
     }
     $this->fields_list = array_merge($this->fields_list, array('total_spent' => array('title' => $this->l('Sales'), 'type' => 'price', 'search' => false, 'havingFilter' => true, 'align' => 'text-right', 'badge_success' => true), 'active' => array('title' => $this->l('Enabled'), 'align' => 'text-center', 'active' => 'status', 'type' => 'bool', 'orderby' => false, 'filter_key' => 'a!active'), 'newsletter' => array('title' => $this->l('Newsletter'), 'align' => 'text-center', 'type' => 'bool', 'callback' => 'printNewsIcon', 'orderby' => false), 'optin' => array('title' => $this->l('Opt-in'), 'align' => 'text-center', 'type' => 'bool', 'callback' => 'printOptinIcon', 'orderby' => false), 'date_add' => array('title' => $this->l('Registration'), 'type' => 'date', 'align' => 'text-right'), 'connect' => array('title' => $this->l('Last visit'), 'type' => 'datetime', 'search' => false, 'havingFilter' => true)));
     $this->shopLinkType = 'shop';
     $this->shopShareDatas = Shop::SHARE_CUSTOMER;
     parent::__construct();
     $this->_select = '
     a.date_add, gl.name as title, (
         SELECT SUM(total_paid_real / conversion_rate)
         FROM ' . _DB_PREFIX_ . 'orders o
         WHERE o.id_customer = a.id_customer
         ' . Shop::addSqlRestriction(Shop::SHARE_ORDER, 'o') . '
         AND o.valid = 1
     ) as total_spent, (
         SELECT c.date_add FROM ' . _DB_PREFIX_ . 'guest g
         LEFT JOIN ' . _DB_PREFIX_ . 'connections c ON c.id_guest = g.id_guest
         WHERE g.id_customer = a.id_customer
         ORDER BY c.date_add DESC
         LIMIT 1
     ) as connect';
     // Check if we can add a customer
     if (Shop::isFeatureActive() && (Shop::getContext() == Shop::CONTEXT_ALL || Shop::getContext() == Shop::CONTEXT_GROUP)) {
         $this->can_add_customer = false;
     }
     self::$meaning_status = array('open' => $this->l('Open'), 'closed' => $this->l('Closed'), 'pending1' => $this->l('Pending 1'), 'pending2' => $this->l('Pending 2'));
 }
 protected function afterUpdate($object)
 {
     $res = parent::afterUpdate($object);
     if ($res && Module::isInstalled('agilemultipleseller')) {
         if (Tools::getValue('id_customer') && Tools::getValue('passwd')) {
             include_once _PS_ROOT_DIR_ . "/modules/agilemultipleseller/SellerInfo.php";
             $id_seller = SellerInfo::getSellerIdByCustomerId(Tools::getValue('id_customer'));
             AgileSellerManager::syncSellerCredentials('f2b', $id_seller);
         }
         $this->create_seller_account($object);
     }
     return $res;
 }