コード例 #1
0
    public function confirmRegisterNew($regr, $module_status)
    {
        $this->load->model('configuration_model');
        $this->load->model('registersubmit');
        $reg = new registersubmit();
        $max_nod_id = $reg->getMaxOrderID();
        $next_order_id = $max_nod_id + 1;
        if ($regr['user_name_type'] == 'dynamic') {
            $regr['username'] = $reg->getUsername();
        } else {
            $regr['username'] = $regr['user_name_entry'];
        }
        $regr['fatherid'] = $reg->obj_vali->userNameToID($regr['fatherid']);
        $regr['referral_id'] = $reg->obj_vali->userNameToID($regr['referral_name']);
        if ($regr['state'] != "") {
            $regr['state'] = $reg->getStateName($this->input->post('state'));
        }
        if ($this->validateRegisterData($regr, $module_status)) {
            $child_node = $reg->obj_vali->getChildNodeId($regr['fatherid'], $regr['position']);
            $updt_login_res = $res_login_update = $reg->updateLoginUser($regr['username'], md5($regr['pswd']), $child_node);
            if ($res_login_update) {
                $user_level = $reg->getLevel($regr['fatherid']) + 1;
                $updt_ft_res = $res_ftindi_update = $reg->updateFTIndividual($regr['fatherid'], $regr['position'], $regr['username'], $child_node, $next_order_id, $regr['by_using'], $user_level, $regr['prodcut_id']);
                if ($res_ftindi_update) {
                    $last_insert_id = $reg->obj_vali->userNameToID($regr['username']);
                    //echo "......vvv";die();
                    $pin_status = $module_status['pin_status'];
                    $pin_status;
                    $regr['userid'] = $last_insert_id;
                    $updt_ft_uni = $reg->insertToUnilevelTree($regr);
                    $insert_user_det_res = $res = $reg->insertUserDetails($regr);
                    $id = $insert_tmp1_res = $res1 = $reg->tmpInsert($last_insert_id, 'L');
                    $insert_tmp2_res = $res1 = $reg->tmpInsert($last_insert_id, 'R');
                }
            }
            $rank_status = $module_status['rank_status'];
            $product_status = $module_status['product_status'];
            $first_pair = $module_status['first_pair'];
            $referal_status = $module_status['referal_status'];
            $balance_amount = 0;
            if ($product_status == "yes" && $first_pair == "1:1") {
                require_once 'Calculation11Product.php';
            } else {
                if ($product_status == "no" && $first_pair == "1:1") {
                    require_once 'Calculation11WithOutProduct.php';
                } else {
                    if ($product_status == "yes" && $first_pair == "2:1") {
                        require_once 'Calculation21Product.php';
                    } else {
                        if ($product_status == "no" && $first_pair == "2:1") {
                            require_once 'Calculation21WithOutProduct.php';
                        }
                    }
                }
            }
            $obj_calc = new Calculation();
            if ($rank_status == "yes") {
                $referal_count = $reg->obj_vali->getReferalCount($regr['referral_id']);
                $old_rank = $reg->obj_vali->getUserRank($regr['referral_id']);
                $regr['rank'] = $reg->obj_vali->getCurrentRankFromRankConfig($referal_count);
                $new_rank = $regr['rank'];
                $this->updateUserRank($regr['referral_id'], $new_rank);
                if ($old_rank != $new_rank) {
                    $rank_bonuss = array();
                    $rank_bonuss = $this->configuration_model->getAllRankDetails($new_rank);
                    $this->insertIntoRankHistory($old_rank, $regr['rank'], $regr['referral_id']);
                    $date_of_sub = date("Y-m-d H:i:s");
                    $amount_type = "rank_bonus";
                    //$level = $this->getUserLevel($regr['referral_id']);
                    $obj_arr = $this->getSettings();
                    $tds_db = $obj_arr["tds"];
                    $service_charge_db = $obj_arr["service_charge"];
                    $rank_amount = $rank_bonuss[0]['rank_bonus'];
                    $tds_amount = $rank_amount * $tds_db / 100;
                    $service_charge = $rank_amount * $service_charge_db / 100;
                    $amount_payable = $rank_amount - ($tds_amount + $service_charge);
                    $obj_calc->insertInToLegAmount($regr['referral_id'], 0, 0, 0, $rank_amount, $amount_payable, $tds_amount, $service_charge, $date_of_sub, $amount_type);
                }
            }
            $product_status = $module_status['product_status'];
            $first_pair = $module_status['first_pair'];
            $referal_status = $module_status['referal_status'];
            if ($referal_status == "yes") {
                $referal_amount = $this->getReferalAmount();
                $referal_id = $obj_calc->getReferalId($last_insert_id);
                if ($referal_amount > 0) {
                    $raferal_amount = ($balance_amount + $referal_amount) * $regr['quantity'];
                    $ref_amt = $obj_calc->insertReferalAmount($referal_id, $raferal_amount, $regr['userid']);
                }
            }
            if ($product_status == "yes") {
                if ($first_pair == "2:1") {
                    require_once 'Calculation21Product.php';
                    $obj_calc = new Calculation();
                    $obj_calc->calculateLegCount($regr['userid'], $regr['fatherid'], $regr['prodcut_id'], $regr['position'], $regr['userid']);
                } else {
                    require_once 'Calculation11Product.php';
                    $obj_calc = new Calculation();
                    $obj_calc->calculateLegCount($regr['userid'], $regr['fatherid'], $regr['prodcut_id'], $regr['position'], $regr['userid'], $regr['quantity']);
                }
            } else {
                if ($first_pair == "2:1") {
                    require_once 'Calculation21WithOutProduct.php';
                    $obj_calc = new Calculation();
                    $obj_calc->calculateLegCount($regr['userid'], $regr['fatherid'], $regr['position'], $regr['userid']);
                } else {
                    require_once 'Calculation11WithOutProduct.php';
                    $obj_calc = new Calculation();
                    $obj_calc->calculateLegCount($regr['userid'], $regr['fatherid'], $regr['position'], $regr['referral_id'], $regr['userid']);
                }
            }
            $level_count = $this->getLevelCount();
            if ($level_count > 0) {
                if ($module_status['sponsor_commission_status'] == 'yes') {
                    $obj_calc->calculateLevelCommission($regr['userid'], $referal_id, $regr['prodcut_id']);
                }
            }
            if ($updt_ft_res && $updt_login_res && $insert_user_det_res && $insert_tmp1_res && $insert_tmp2_res) {
                $mobile = $regr['mobile'];
                $username = $regr['username'];
                $password = $regr['pswd'];
                $full_name = $regr['full_name'];
                $site_info = $this->obj_config->getSiteConfiguration();
                $site_name = $site_info['co_name'];
                $site_logo = $site_info['logo'];
                $base_url = base_url();
                $tran_code = $reg->getRandTransPasscode(8);
                $reg->savePassCodes($last_insert_id, $tran_code);
                if ($regr['email'] != "" && $regr['email'] != null) {
                    $reg_mail = $this->checkMailStatus();
                    if ($reg_mail['reg_mail_status'] == 'yes') {
                        $email = $regr['email'];
                        $mail_content = $this->obj_vali->getMailBody();
                        $subject = "{$site_name} Registration Notification";
                        $mailBodyDetails = '<html xmlns="https://www.w3.org/1999/xhtml">
                                                <head>
                                                    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
                                                    
                                                    <link href="https://fonts.googleapis.com/css?family=Droid+Serif" rel="stylesheet" type="text/css">
                                                    <style>
 
                                                                margin:0px;
                                                                padding:0px;
                                                          
                                                    </style>

                                                </head>

                                                <body>
                                                    <div style="width:80%;padding:40px;border: solid 10px #D0D0D0;margin:50px auto;">
                                                      <div style="min-height: 62px;border: solid 1px #d0d0d0;background: url(' . $base_url . 'public_html/images/head-bg.png) no-repeat center center;padding: 0px!important;">
                                                       <img src="' . $base_url . 'public_html/images/logos/' . $site_logo . '" alt="logo" style="width: 114px;margin-top: 10px;margin-left: 10px;"/>  
                                                      </div>
                                                      <div style="width:100%;margin:15px 0 0 0;">
                                                        <h1 style="font: normal 20px Tahoma, Geneva, sans-serif;">Dear <font color="#e10000">' . $full_name . ',</font></h1>
                                                       <p style="font: normal 12px Tahoma, Geneva, sans-serif;text-align:justify;color:#212121;line-height:23px;">' . $mail_content . '</p>
                                                        
                                                        <div style="width:400px;height:225px;margin:16px auto;background:url(' . $base_url . 'public_html/images/page.png);border: solid 1px #d0d0d0;border-radius: 10px;">
                                                          <h2 style="color:#C70716;font:normal 16px Tahoma, Geneva, sans-serif;line-height:34px;background:url(' . $base_url . 'public_html/images/login-icons.png) center left no-repeat;background-size: 35px 35px;margin:10px 0 0 22px;float:left;padding-left: 54px;">LOGIN DETAILS</h2>
                                                          <div style="clear:both;"></div>
                                                          <ul style="display:block;margin:14px 0 0 0;float:left;">
                                                            <li style="list-style:none;font:normal 15px Tahoma, Geneva, sans-serif;color:#212121;margin:5px 0 0 20px;border:1px solid #ccc;background:#fff;width:300px;padding:5px;"><span style="width:150px;float:left;">Login Link</span><font color="#025BB9"> : <a href="http://infinitemlmsoftware.com/soft/binary/login/index/user/' . $username . '" target="_blank">Click Here</a></font></li>
                                                            <li style="list-style:none;font:normal 15px Tahoma, Geneva, sans-serif;color:#212121;margin:5px 0 0 20px;border:1px solid #ccc;background:#fff;width:300px;padding:5px;"><span style="width:150px;float:left;">Your UserName</span><font color="#e10000"> : ' . $username . '</font></li>
                                                            <li style="list-style:none;font:normal 15px Tahoma, Geneva, sans-serif;color:#212121;margin:5px 0 0 20px;border:1px solid #ccc;background:#fff;width:300px;padding:5px;"><span style="width:150px;float:left;">Your Password</span><font color="#e10000"> : ' . $password . '</font></li>
                                                          </ul>
                                                        </div>
                                                      </div>

                                                    </div>
                                                </body>
                                            </html>';
                        $this->obj_vali->sendEmail($mailBodyDetails, $last_insert_id, $subject);
                    }
                }
                $reg->insertBalanceAmount($regr['userid']);
                $encr_id = $this->session->userdata('user_id');
                $encr_id = $this->getEncrypt($encr_id);
                $msg['user'] = $username;
                $msg['pwd'] = $password;
                $msg['id'] = $encr_id;
                $msg['status'] = true;
                $msg['tran'] = $tran_code;
                //if($using=='exact'){
                $user = $msg['user'];
                $pass = $msg['pwd'];
                $tran_code = $msg['tran'];
                $product_status = $module_status['product_status'];
                $payment_method = 'e-xact';
                $user_id = $this->userNameToID($user);
                if ($product_status == "yes") {
                    $insert_into_sales = $this->insertIntoSalesOrder($user_id, $regr['prodcut_id'], $payment_method, $regr['quantity'], $regr['x_trans_id'], "register");
                    //$this->insertExactHistory($regr);
                    $reg->commit();
                }
                //}
                return $msg;
            } else {
                $reg->rollBack();
                $encr_id = $this->session->userdata('user_id');
                $encr_id = $this->getEncrypt($encr_id);
                $msg['user'] = "";
                $msg['pwd'] = "";
                $msg['id'] = "";
                $msg['status'] = false;
                $msg['tran'] = "";
                return $msg;
            }
            if ($msg['status']) {
                //mail('*****@*****.**','commit',  ' starting' );//unc
                //$reg->commit();
                //mail('*****@*****.**','commit',  ' ending' );//unc
            }
        }
    }