function add_user()
 {
     $do_api_user = new User();
     if ($this->firstname == '' || $this->lastname == '') {
         $this->setMessage("521", "First name, Last name required");
         return false;
     } elseif ($this->email == '') {
         $this->setMessage("522", "Email Id Required");
         return false;
     } elseif ($this->username == '') {
         $this->setMessage("523", "Username required.");
         return false;
     } elseif ($do_api_user->checkDuplicateUserName(trim($this->username))) {
         $this->setMessage("524", "Username is already in use.");
         return false;
     } elseif ($this->password == '') {
         $this->setMessage("525", "Password is required.");
         return false;
     } else {
         $do_api_user->addNew();
         $do_api_user->firstname = $this->firstname;
         $do_api_user->lastname = $this->lastname;
         $do_api_user->email = $this->email;
         $do_api_user->username = $this->username;
         $do_api_user->password = $this->password;
         $do_api_user->company = $this->company;
         $do_api_user->plan = $this->plan;
         $do_api_user->regdate = date("Y-m-d");
         $do_api_user->add();
         $inserted_id = $do_api_user->getPrimaryKeyValue();
         //$do_api_user->addUserAsContact($this->firstname,$this->lastname,$this->company,$this->email,$inserted_id);
         // Lets create the Contact view now
         $ContactView = new ContactView();
         $ContactView->rebuildContactUserTable($inserted_id);
         $this->email_work = $this->email;
         $this->add_contact();
         // adding the contact to the API key user
         //$do_api_user->idcontact = $this->idcontact;
         //$do_api_user->update();
         $this->setValues(array("msg" => "User Added", "stat" => "ok", "code" => "520", "iduser" => $inserted_id, "contact" => $this->idcontact));
         return true;
     }
 }