Ejemplo n.º 1
0
 public function clean($mlm_plan)
 {
     require_once 'registersubmit.php';
     $obj_reg = new registersubmit();
     require_once 'validation.php';
     $obj_val = new validation();
     require_once 'board_registersubmit.php';
     $obj_board = new board_registersubmit();
     $session_data = $this->session->userdata('logged_in');
     $admin_pass = $obj_val->getAdminPassword();
     $admin_id = $obj_val->getAdminId();
     $details = $this->getUserDetail($admin_id);
     //to get details of admin
     //$logged_user_id = $details['user_detail_refid'];
     $logged_user_id = 12345;
     $table_prefix = $session_data['table_prefix'];
     $user_name = $session_data['user_name'];
     $this->begin();
     $res1 = $this->db->truncate('amount_paid');
     $res2 = $this->db->truncate('complaint_query_table');
     $res3 = $this->db->truncate('complaint_ticket_table');
     $res4 = $this->db->truncate('events');
     $res5 = $this->db->truncate('feedback');
     $res6 = $this->db->truncate('ft_individual');
     $res7 = $this->db->truncate('ft_individual_unilevel');
     $res8 = $this->db->truncate('fund_transfer_details');
     $res9 = $this->db->truncate('investment');
     $res10 = $this->db->truncate('leg_amount');
     $res11 = $this->db->truncate('leg_carry_forward');
     $res12 = $this->db->truncate('login_user');
     $res13 = $this->db->truncate('mailtoadmin');
     $res14 = $this->db->truncate('mailtouser');
     $res15 = $this->db->truncate('news');
     $res16 = $this->db->truncate('password_reset_table');
     $res17 = $this->db->truncate('pin_numbers');
     $res18 = $this->db->truncate('pin_request');
     $res19 = $this->db->truncate('payout_release_requests');
     $res20 = $this->db->truncate('sms_history');
     $res21 = $this->db->truncate('tran_password');
     $res22 = $this->db->truncate('user_balance_amount');
     $res23 = $this->db->truncate('user_details');
     $res24 = $this->db->truncate('leg_details');
     $res25 = $this->db->truncate('product_image_table');
     $res26 = $this->db->truncate('rank_history');
     $res27 = $this->db->truncate('sales_order');
     $res28 = $this->db->truncate('activity_history');
     $res29 = $this->db->truncate('live_account_registration_details');
     $res30 = $this->db->truncate('credit_card_purchase_details');
     $res31 = $this->db->truncate('pin_used');
     $res31 = $this->db->truncate('username_change_history');
     $res61 = $this->db->truncate('payment_registration_details');
     $res62 = $this->db->truncate('authorize_payment_details');
     $res63 = $this->db->truncate('employee_details');
     $res64 = $this->db->truncate('login_employee');
     $res65 = $this->db->truncate('cron_history');
     $res66 = $this->db->truncate('exact_payment_history');
     $res66 = $this->db->truncate('cookie_user');
     $login_user = $this->table_prefix . "login_user";
     $set_auto_increment_login_user = "******";
     $res32 = $this->db->query($set_auto_increment_login_user);
     $ft_individual = $this->table_prefix . "ft_individual";
     $set_auto_increment_ft_individual = "ALTER TABLE {$ft_individual} AUTO_INCREMENT={$logged_user_id}";
     $res33 = $this->db->query($set_auto_increment_ft_individual);
     $login_data = array('user_id' => $logged_user_id, 'user_type' => 'admin', 'addedby' => 'code', 'user_name' => $user_name, 'password' => $admin_pass);
     $res37 = $this->db->insert('login_user', $login_data);
     $current_date = date("Y-m-d H:i:s");
     $ft_details = array('id' => $logged_user_id, 'father_id' => '0', 'position' => '', 'user_name' => $user_name, 'active' => 'yes', 'date_of_joining' => $current_date, 'product_id' => '1');
     $res38 = $this->db->insert('ft_individual', $ft_details);
     $ft_details_ul = array('id' => $logged_user_id, 'father_id' => '0', 'position' => '0', 'user_name' => $user_name, 'active' => 'yes', 'date_of_joining' => $current_date, 'product_id' => '1');
     $res39 = $this->db->insert('ft_individual_unilevel', $ft_details_ul);
     $leg_details = array('id' => $logged_user_id);
     $res40 = $this->db->insert('leg_details', $leg_details);
     ///////////////////code added by amrutha
     $date = date("Y-m-d H:i:s");
     $user_details = array('user_detail_refid' => $logged_user_id, 'user_detail_name' => $details['user_detail_name'], 'user_detail_address' => $details['user_detail_address'], 'user_detail_town' => $details['user_detail_town'], 'user_detail_country' => $details['user_detail_country'], 'user_detail_state' => $details['user_detail_state'], 'user_detail_pin' => $details['user_detail_pin'], 'user_detail_passcode' => $details['user_detail_passcode'], 'user_detail_mobile' => $details['user_detail_mobile'], 'user_detail_land' => $details['user_detail_land'], 'user_detail_email' => $details['user_detail_email'], 'user_detail_dob' => $details['user_detail_dob'], 'user_detail_gender' => $details['user_detail_gender'], 'user_detail_nominee' => $details['user_detail_nominee'], 'user_detail_relation' => $details['user_detail_relation'], 'user_detail_acnumber' => $details['user_detail_acnumber'], 'user_detail_nbank' => $details['user_detail_nbank'], 'user_photo' => $details['user_photo'], 'join_date' => $date, 'user_detail_nbranch' => $details['user_detail_nbranch']);
     $res41 = $this->db->insert('user_details', $user_details);
     $this->db->select_max('user_id', 'user_id');
     $this->db->from('login_user');
     $query = $this->db->get();
     foreach ($query->result() as $row) {
         $get_id = $row->user_id;
     }
     if ($mlm_plan == 'Board') {
         $res42 = $obj_board->tmpInsert($get_id, "1");
     } else {
         $res42 = $obj_reg->tmpInsert($get_id, "L");
         $res43 = $obj_reg->tmpInsert($get_id, "R");
     }
     $user_balance_details = array('user_id' => $get_id, 'balance_amount' => '0');
     $res44 = $this->db->insert('user_balance_amount', $user_balance_details);
     $tran_password_details = array('user_id' => $logged_user_id, 'tran_password' => '12345678');
     $res45 = $this->db->insert('tran_password', $tran_password_details);
     if ($mlm_plan == "Board") {
         /////////////////////////////////////////////////////////////for board  plan
         $res46 = $this->db->truncate("board_split_status");
         $res47 = $this->db->truncate("board_user_detail");
         $res48 = $this->db->truncate("auto_board_1");
         $res49 = $this->db->truncate("board_view");
         $res50 = $this->db->truncate("board_referral_count");
         $auto_board = $this->table_prefix . "auto_board_1";
         $set_auto_increment_auto_board = "ALTER TABLE {$auto_board} AUTO_INCREMENT={$logged_user_id}";
         $res51 = $this->db->query($set_auto_increment_auto_board);
         $board_split_status = $this->table_prefix . "board_split_status";
         $set_auto_increment_board_split_status = "ALTER TABLE {$board_split_status} AUTO_INCREMENT=1";
         $res52 = $this->db->query($set_auto_increment_board_split_status);
         $board_user_detail = $this->table_prefix . "board_user_detail";
         $set_auto_increment_board_user_detail = "ALTER TABLE {$board_user_detail} AUTO_INCREMENT=1";
         $res53 = $this->db->query($set_auto_increment_board_user_detail);
         $board_view = $this->table_prefix . "board_view";
         $set_auto_increment_board_view = "ALTER TABLE {$board_view} AUTO_INCREMENT = 1";
         $res54 = $this->db->query($set_auto_increment_board_view);
         $board_view = $this->table_prefix . "board_referral_count";
         $set_auto_increment_board_referral_count = "ALTER TABLE {$board_view} AUTO_INCREMENT = 1";
         $res55 = $this->db->query($set_auto_increment_board_referral_count);
         $board_user_details = array("board_table_name" => '1', "user_id" => $logged_user_id, "board_serial_no" => '1', "date_of_join" => $date);
         $res56 = $this->db->insert('board_user_detail', $board_user_details);
         $board_split_status_det = array("user_ref_id" => $logged_user_id, "board_number" => '1', "status" => 'no', "date_of_update" => $date);
         $res57 = $this->db->insert('board_split_status', $board_split_status_det);
         $auto_board_det = array("user_ref_id" => $logged_user_id, "user_name" => $user_name, "position" => '', "active" => 'yes', "father_id" => '0', "date_of_joining" => $date, "user_level" => '0');
         $res58 = $this->db->insert('auto_board_1', $auto_board_det);
         $board_view_det = array("board_top_id" => $logged_user_id, "board_table_name" => '1', "board_no" => '1', "board_split_status" => 'no', "date_of_join" => $date);
         $res59 = $this->db->insert('board_view', $board_view_det);
         $board_referral_count_det = array("board_id" => $logged_user_id, "user_ref_id" => $logged_user_id, "referral_count" => '0');
         $res60 = $this->db->insert('board_referral_count', $board_referral_count_det);
         /* ///////////////////////////////if auto_board_2 exists
                       $res61 = $this->db->truncate("auto_board_2");
         
                       $auto_board2 = $this->table_prefix . "auto_board_2";
                       $set_auto_increment_auto_board = "ALTER TABLE $auto_board2 AUTO_INCREMENT=$logged_user_id";
                       $res62 = $this->db->query($set_auto_increment_auto_board);
         
                       $board_user_details = array(
                       "board_table_name" => '2',
                       "user_id" => $logged_user_id,
                       "board_serial_no" => '1',
                       "date_of_join" => $date
                       );
                       $res63 = $this->db->insert('board_user_detail', $board_user_details);
         
                       $auto_board_det = array(
                       "user_ref_id" => $logged_user_id,
                       "user_name" => $user_name,
                       "position" => '',
                       "active" => 'yes',
                       "father_id" => '0',
                       "date_of_joining" => $date,
                       "user_level" => '0'
                       );
                       $res64 = $this->db->insert('auto_board_2', $auto_board_det);
         
                       $board_view_det = array(
                       "board_top_id" => $logged_user_id,
                       "board_table_name" => '2',
                       "board_no" => '1',
                       "board_split_status" => 'no',
                       "date_of_join" => $date
                       );
                       $res65 = $this->db->insert('board_view', $board_view_det); */
         ////////////////////////////////////////////////////
     }
     if ($res45) {
         $this->commit();
     } else {
         $this->rollBack();
     }
     return $res45;
 }
 public function confirmRegister($regr, $module_status)
 {
     /* print_r($regr);
        die(); */
     $this->load->model('board_registersubmit');
     $reg = new board_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']);
     // echo  $regr['fatherid'];die();
     $regr['referral_id'] = $reg->obj_vali->userNameToID($regr['referral_name']);
     if ($this->validateRegisterData($regr, $module_status)) {
         $child_node = $reg->obj_vali->getChildNodeId($regr['fatherid'], $regr['position']);
         $reg->begin();
         $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']);
                 $pin_status = $module_status['pin_status'];
                 $pin_status;
                 //                    if ($pin_status == "yes") {
                 //
                 //                        $updt_pin_status_res = $pin_upd_res = $reg->updatePinNumber($regr['passcode'], $regr['username']);
                 //                    }
                 $regr['userid'] = $last_insert_id;
                 $unilevel_arr['order_id'] = $next_order_id;
                 $unilevel_arr['position'] = $regr['position'];
                 $unilevel_arr['user_level'] = $user_level;
                 $updt_ft_uni = $reg->insertToUnilevelTree($regr, $unilevel_arr);
                 $insert_user_det_res = $reg->insertUserDetails($regr, $unilevel_arr);
                 $insert_tmp1_res = $reg->tmpInsert($last_insert_id, '1');
                 $new_position = $reg->getNewPositionOfUser($last_insert_id) + 1;
                 $insert_tmp2_res = $reg->tmpInsert($regr['fatherid'], $new_position);
             }
         }
         $board_no = 1;
         $user_name_for_board_split = $regr['username'];
         $active = "yes";
         $auto_goc_table_name_next = "auto_board_";
         $shuffle_status = $module_status['shuffle_status'];
         $shuffle_status . $this->obj_autofilling->addBoard($last_insert_id, $user_name_for_board_split, $active, $auto_goc_table_name_next, $board_no, $shuffle_status, "", $regr['referral_id']);
         $referal_amount = 0;
         $boardno = '';
         $amount_type = 'referal';
         $referal_status = $module_status['referal_status'];
         if ($referal_status == "yes") {
             $referal_amount = $this->getReferalAmount();
         }
         $referal_id = $this->obj_autofilling->getReferalId($last_insert_id);
         if ($referal_amount > 0) {
             $this->obj_autofilling->insertAmount($referal_id, $boardno, $amount_type, $referal_amount);
         }
         //            $leadership_bonus = $this->getLeaderShipBonus();
         //            $leadership_users = $this->getLeaderShipUsers($child_node);
         //            for ($i = 0; $i < count($leadership_users); $i++) {
         //                $leader_bonus = $leadership_bonus["leader$i"];
         //                $leader_user = $leadership_users[$i];
         //                $this->obj_autofilling->insertLeaderShipBonus($leader_user, $boardno, 'leadership_bonus', $leader_bonus, $child_node);
         //            }
         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'];
             //$mobid = $regr['mobid'];
             $tran_code = $reg->getRandTransPasscode(8);
             //$tran_code = $password;
             $reg->savePassCodes($last_insert_id, $tran_code);
             if ($regr['email'] != "" && $regr['email'] != null) {
                 $mailBodyDetails = '<html>
                   <head>
                   <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
                   </head>
                   <body >
                   <table id="Table_01" width="700"   border="0" cellpadding="0" cellspacing="0">
                   <tr><td colspan="2">
                   <table width="400"   border="0" cellpadding="0" cellspacing="0">
                   <tr><td colspan="2"><b>Account Details</b></td></tr>
                   <tr><td>Username :</td><td><b>' . $username . '</b></td></tr>
                   <tr><td>Password :</td><td><b>' . $password . '</b></td></tr>
                   <tr><td>Transaction Passcode :</td><td><b>' . $tran_code . '</b></td></tr>
                   </table>
                   </td></tr>
                   <tr><td colspan="2" >Welcome ' . $username . ',<br />Your account has successfully registered.
                   </td></tr>
                   <tr><td colspan="2">Regards,<br />In</td></tr>
                   <tr><td colspan="2">www.ventures99.com</td></tr>
                   </table>
                   </body></html>';
                 $this->sendEmail($mailBodyDetails, $regr['email']);
             }
             $reg->insertBalanceAmount($regr['userid']);
             $encript_id = $this->session->userdata('user_id');
             $encr_id = $this->getEncrypt($encript_id);
             $reg->commit();
             $msg['user'] = $username;
             $msg['pwd'] = $password;
             $msg['id'] = $encr_id;
             $msg['status'] = true;
             $msg['tran'] = $tran_code;
             return $msg;
         } else {
             $reg->rollBack();
             $encript_id = $this->session->userdata('user_id');
             $encr_id = $this->getEncrypt($encript_id);
             $msg['user'] = "";
             $msg['pwd'] = "";
             $msg['id'] = "";
             $msg['status'] = false;
             $msg['tran'] = "";
             return $msg;
         }
     }
 }