}
}
$redirect_file = "index.php?file=m-useradd&mode=" . $mode . "&iUserId=" . $iUserId . $qs;
$GeneralObj->checkDuplicate('iUserId', 'User', array('vUsername'), $redirect_file, "Email Already Exists ", $iUserId, 'OR');
if ($mode == "Add") {
    $msg = '';
    try {
        $company = new Company($iCompanyId);
        if (!$company) {
            throw new Exception("Cannot get organization information!");
        }
        $result = $userObj->insert();
        if (!$result) {
            throw new Exception("Cannot add user!");
        }
        $result = $userObj->assignUserToGroup($iSGroupId);
        if (!$result) {
            throw new Exception("Cannot add user to group!");
        }
        $logo_url = $CFG->wwwroot . "/public/images/logo.png";
        $to = '' . $_REQUEST['vUsername'] . '';
        $subject = 'MLM Registration!';
        $message = "<html>\n\t\t\t\t\t\t<head><title></title></head>\n\t\t\t\t\t\t<body>\n\t\t\t\t\t\t<table>\n\t\t\t\t\t\t<tr><td align='left'><img src=\"" . $logo_url . "\" border=\"0\" height='90' width='300'></td></tr>\n\t\t\t\t\t\t\t\t<tr><td height='10'>&nbsp;</tr></td>\n\t\t\t\t\t\t\t\t<tr><td>Your registration is successful with Company " . $company->getvCompanyName() . "</td></tr>\n\t\t\t\t\t\t\t\t\t\t<tr><td height='10'>&nbsp;</tr></td>\n\t\t\t\t\t\t\t\t\t\t<tr><td>Please find your login credentials as following: <br/><br/>User Name: " . $_REQUEST['vUsername'] . " <br/>Password: "******"</td></tr>\n\t\t\t\t\t\t\t\t\t\t\t\t<tr><td height='10'>&nbsp;</tr></td>\n\t\t\t\t\t\t\t\t\t\t\t\t<tr><td height='10'>Thanks,<br/> Mobile Learning Manager</tr></td>\n\t\t\t\t\t\t\t\t\t\t\t\t</table>\n\t\t\t\t\t\t\t\t\t\t\t\t</body>\n\t\t\t\t\t\t\t\t\t\t\t\t</html>";
        $headers = 'From: ' . $company->getvEmail() . "\r\n";
        $headers .= 'Content-type: text/html; charset=iso-8859-1';
        @mail($to, $subject, $message, $headers);
    } catch (Exception $exc) {
        $msg = $exc->getTraceAsString();
    }
    // $userObj->setdCreated($dCreated);
    //  $userObj->setiSGroupId($iSGroupId);