*** go_user_ce.php	2013-06-13 12:57:06.000000000 -0400
--- go_user_ce.php	2013-06-18 14:24:21.000000000 -0400
***************
*** 410,415 ****
--- 410,436 ----
      function usersavedata($postvars=array()){
          if(!empty($postvars)){
  
+              if($postvars['accountNum'] === "ADMIN"){
+ 
+                  $this->gouser->asteriskDB->where(array("user_group"=>$postvars['accountNum'],'user !='=>'VDAD'));
+                  $userinfo = $this->gouser->asteriskDB->get('vicidial_users')->result();
+                  if(!empty($userinfo)){
+                       $newAdmin = get_object_vars($userinfo[0]); 
+                       unset($newAdmin['user_id']);
+                  }
+                  $newAdmin['user'] = (array_key_exists('user',$postvars)?$postvars['user']:"agent".$postvars['lastDigit']);
+                  $newAdmin['pass'] = (array_key_exists("pass",$postvars)?$postvars['pass']:$pass);
+                  $newAdmin['user_group'] = $postvars['accountNum'];
+                  $newAdmin['full_name'] = (array_key_exists('full_name',$postvars)?$postvars['full_name']:"agent".$postvars['lastDigit']);
+                  $newAdmin['user_level'] = (($postvars['accountNum']=="ADMIN")?'9':'1');
+                  $newAdmin['phone_login'] = "";
+                  $newAdmin['phone_pass'] = "";
+                  $newAdmin['agentonly_callbacks'] = '1';
+                  $newAdmin['agentcall_manual'] = '1';
+                  $newAdmin['condition'] = array('user'=>$newAdmin['user']);
+                  $data['vicidial_users'] = $newAdmin;
+ 
+              } else {
                   $pass = $this->genpassword();
                   $data['vicidial_users']['user'] = (array_key_exists('user',$postvars)?$postvars['user']:"agent".$postvars['lastDigit']);
                   $data['vicidial_users']['pass'] = (array_key_exists("pass",$postvars)?$postvars['pass']:$pass);
***************
*** 423,428 ****
--- 444,450 ----
                   $data['vicidial_users']['agentonly_callbacks'] = '1';
                   $data['vicidial_users']['agentcall_manual'] = '1';
                   $data['vicidial_users']['condition'] = array('user'=>$data['vicidial_users']['user']); 
+              }
                   /*$data['phones']['extension'] = $data['vicidial_users']['phone_login'];
                   $data['phones']['dialplan_number'] = '9999'.$data['vicidial_users']['phone_login'];
                   $data['phones']['voicemail_id'] = $data['vicidial_users']['phone_login'];
***************
*** 467,472 ****
--- 489,495 ----
              unset($data['phones']['condition']); # remove phones condition for saving
  
              $result = $this->gouser->insertuser('vicidial_users',$data['vicidial_users'],$v_ucondition); #insert data to vicidial_users
+             $this->gouser->goautodialDB->insert('go_login_type',array('account_num'=>$data['vicidial_users']['user'],'new_signup'=>'1'));
              
              /*if($result){ # phone saving part
  
***************
*** 699,705 ****
          #$data['go_main_content'] = 'go_user/go_user_main';
          $data['go_main_content'] = 'go_user/go_user_main_ce';
          #collectusers 
!         $users = $this->gouser->retrievedata('vicidial_users',array('active'=>'Y'),'user_id,user,full_name',null,array(array('full_name'=>'asc')));
          if(!empty($users)){
              foreach($users as $user){
                  $data['users'][$user->user] = "$user->user - $user->full_name";
--- 722,728 ----
          #$data['go_main_content'] = 'go_user/go_user_main';
          $data['go_main_content'] = 'go_user/go_user_main_ce';
          #collectusers 
!         $users = $this->gouser->retrievedata('vicidial_users',array('active'=>'Y','full_name NOT LIKE'=>'%Survey%'),'user_id,user,full_name',null,array(array('full_name'=>'asc')));
          if(!empty($users)){
              foreach($users as $user){
                  $data['users'][$user->user] = "$user->user - $user->full_name";
***************
*** 1670,1675 ****
--- 1693,1699 ----
                   # database intervensions starts here 
                   # insert in vicidial_users                 
                   $this->gouser->asteriskDB->insert("vicidial_users",$fields);
+                  $this->gouser->goautodialDB->insert('go_login_type',array('account_num'=>$fields['user'],'new_signup'=>'1'));
  
                   # insert in vicidial_inbound_group_agent
                   $viga = $this->gouser->retrievedata('vicidial_inbound_group_agents',
