<?php
$companies = $queries -> getPayment("EXEC Getpayment_sp @p1= saba, @p2= saba ");
 
$companies = $companies[0]['getpayment'];
$companyname = '';
if(is_array($companies) && (sizeof($companies) > 0)){
    
    
    for($i=0; $i<sizeof($companies);$i++){
        
        $w_id = $companies[$i]['id_payment'];
        $w_name = $companies[$i]['store_nam'];
        
        $companyname .= '<option class=" py-4" value="'.$w_id.'">'.$w_name.'</option> ';
        
    }
    
    
    
 
    
}
$regmessage = 'ثبت نام نا موفق بود';
if($_SESSION['alslaksdjpAydaq'] == "laskd23#*(%kj23(sSMq"){
            

         if(isset($_POST['reqdashboadsubmit'])){
            $rname= $_POST['regname'];
            $rtel= $_POST['regtel'];
            $radd= $_POST['regadd'];
            $ruser= $rtel;
            $rpass= $rtel;
            $rrepass= $rtel;
            $rcom= $_POST['regcom'];
            
            if(!empty(trim($rname)) && !empty(trim($rtel)) && !empty(trim($radd)) && !empty(trim($ruser)) && !empty(trim($rpass)) && !empty(trim($rrepass)) && !empty(trim($rcom))){
                
                
                if (strcmp($rpass, $rrepass) == 0) { 
	                
                   	$rname = str_replace('ی','ي',$rname);
	                $radd = str_replace('ی','ي',$radd);
                  
                    $nam  =  iconv( "UTF-8", "Windows-1256",$rname);
                    $adr  =  iconv( "UTF-8", "Windows-1256",$radd);
                    $tel  =  iconv( "UTF-8", "Windows-1256",$rtel);
                    
                    $fstchar = $ruser[0];
				    if($fstchar == '0'){
					 $ruser = substr($ruser, 1);
					 $rpass = $ruser;
				    }
                    
                    $usernam    =  iconv( "UTF-8", "Windows-1256",$ruser);
                    $password    =  iconv( "UTF-8", "Windows-1256",$rpass);	
                    

                    
                    $valdataCheck = $queries -> addUser("EXEC insert_new_cast_sp @nam = N'".$nam."' , @adr = N'".$adr."'  , @tel = '$tel' ,@usernam = '$usernam',@password='$password', @ucid = '$rcom'");	

                    $res = json_decode($valdataCheck,true);
                    $res = $res[0]["newcast"];
                    if(is_array($res) && sizeof($res) > 0){
                        
                       $checkstateoflogin = true;
                       $regmessage = $res[0]["mag"]; 
					   $regstatus = $res[0]["stut"]; 
	
						
						if($regstatus=="0"){
							
												
						$so = $usernam;
						$pa = $password;
						$ci = $rcom;
						
						 if(!empty(trim($so)) && !empty(trim($pa)) && !empty(trim($ci))){
                
                
               							 $fstchar = $so[0];
											if($fstchar == '0'){
												 $so = substr($so, 1);
												 $pa = $so;
											}
                
                
                $rez = $queries -> getuser("EXEC GetUsers_sp   @p1 =  '$so' , @p2 = '$pa' ,@p3= '$ci' ");
                
                if ($rez){
                    
                    $res = $queries -> getCodeCast("EXEC Getcod_cast @p1='$so', @p2='$pa',@p3 = '$ci'");
                     
                    if($res !== 'none'){
                     
                      $c = strlen(trim($res));                    
                      if($c > 0){
 
                        
                        $_SESSION['uzi'] = $so;
                        $_SESSION['pzi'] = $pa;
                        $_SESSION['czi'] = $res;
                        $_SESSION['ucid'] = $ci;
                                            
                        header("Location: index.php");
                      }}}
 
                
            }
						
						
						
						}
                        
                    }else{ 
                        
                         
                         $checkstateoflogin = true;
                    }
                    
                     	
	
 
                 }else { 
	                   $checkstateoflogin = true;
                 }
            }else{
                $checkstateoflogin = true;
            }
            
        }else{
              $checkstateoflogin=false;
         }
            
        }else{
            $checkstateoflogin=false;
        }
           





?>
