<?php
$actiondest = "login.php";
if($resultofinfo){
$actiondest = "";
} 

$showdetails = ((sizeof($gottensettings) == 20) && ($gottensettings['gfs1'] == "1"));
$showoutofstock = ((sizeof($gottensettings) == 20) && ($gottensettings['gfs2'] == "1"));
$countsofp = '';
for($i=0;$i<200;$i++){
    
   $countsofp .= '<option class=" py-4" value="'.$i.'">'.$i.'</option> ';
    
}

         $countsofpz = '';  
        for($k=100;$k<3000;$k=$k+100){
            
            
            $kvalue = $k * 0.001; 
            
            $unittitle = $k." گرم ";
            if($k > 999){
                 $unittitle = $k." گرم ";
            }
            
             $countsofpz .= '<option class=" py-4" value="'.$kvalue.'">'.$unittitle.'</option> ';
    
            
          }
        


for($i=0;$i<sizeof($ultimateprodata);$i++){
    

     
    
    $pro_img = $imgfadd.$ultimateprodata[$i]['pic_path'];
    $pro_name = $ultimateprodata[$i]['nam'];
    $pro_price = $ultimateprodata[$i]['price1'];
    $pro_price_withoutdis = $ultimateprodata[$i]['price2'];
	$pro_priceshow = $queries -> fa_number($pro_price);
    $pro_id = $ultimateprodata[$i]['cod'];
    $pro_count = $ultimateprodata[$i]['numb'];
    $handletypes = ($ultimateprodata[$i]['f_j']==0);
    
    
 
    

    if($handletypes){
        $handletypesres = ' <select name="cartitemscount" class=" custom-select mt-1 mb-1 text-right  border-0 bg-white rounded " id="getme" dir="rtl" style="font-size: 0.85rem; color: #121212; font-weight: 700;">'.$countsofp.'</select>';
		
		$intitle="تعداد";
		
    }else{
		
		 $handletypesres = ' <select name="cartitemscount" class=" custom-select mt-1 mb-1 text-right  border-0 bg-white rounded " id="getme" dir="rtl" style="font-size: 0.85rem; color: #121212; font-weight: 700;">'.$countsofpz.'</select>';
		
       // $handletypesres = '<input type="text" name="cartitemscount" class="form-control  border-0 bg-white text-right currencyTextBox"  placeholder="با کیبورد مقدار را وزن کنید" style="font-size:0.9rem;" autocomplete="off">';
			$intitle="وزن";
    }



    
if(filter_var(ltrim($pro_count, '0'), FILTER_VALIDATE_INT) || filter_var($pro_count, FILTER_VALIDATE_INT) === 0) {
 
    if(intval($pro_count) > 0){
        
        $price_section = '<div class="product-sub  font-weight-normal mr-1 mt-2">
                    <span class="ml-2">قیمت: </span>
                    <span>'.$pro_priceshow.'</span>
                </div>';
        
          $price_section_dis = '';
          $price_section_dis_tag = '';
                  
        
    
          if($queries -> fa_number($pro_price_withoutdis) !== "۰"){
        
        
              $pro_price_withoutdis_temp = floatval($pro_price_withoutdis);
              $pro_price_temp = floatval($pro_price);
        
        
        
              if($pro_price_temp < $pro_price_withoutdis_temp){
            
                  $pro_price_perc_temp = $pro_price_temp / $pro_price_withoutdis_temp;
                  $pro_price_perc_temp = $pro_price_perc_temp * 100;
                  $pro_price_perc_temp = 100 - $pro_price_perc_temp;
                  $pro_price_perc_temp = $queries -> fa_number($pro_price_perc_temp);
                  $pro_price_withoutdis_temp =  $queries -> fa_number($pro_price_withoutdis);
              
                  
                  
                  $price_section = 
                      '<div class="product-sub  font-weight-normal mr-1 mt-2">
                    <span class="ml-2">قیمت: </span>
                    <span style="text-decoration: line-through;">'.$pro_price_withoutdis_temp.'</span>
                     <span class="text-danger ml-2" style="font-size: 0.95rem;">'.$pro_priceshow.'</span>
                    </div>';
                                   
                  $price_section_dis_tag ='<div class="discountholder"> 
                                <div class="bg-danger text-right d-flex align-items-center justify-content-end px-3 rounded-sm" style="position: absolute; top: 10px;left: 10px;height: 40px;z-index: 2;">

                                    <span class="text-right" style="font-size: 1rem; color: #fff; font-weight: 400;">%</span>
                                    <span class="text-right" style="font-size: 1.1rem; color: #fff; font-weight: 400;">'.$pro_price_perc_temp.'</span> 

                                </div>


                    </div>'; 
                  
                  
              }
          
          
          
          
          
            }
          
                    
echo '<div class="col-xl-3 col-lg-4 col-md-6 col-6 mb-xl-4 mb-lg-3 mb-2  px-0 ">

    <div class="product-card  bg-white m-1 m-lg-2">'.$price_section_dis_tag.'



        <div class="row">

            <div class="col-12"> 
                <div class="product-image-holder mx-auto mt-2">
                    <div class="product-image" style="background-image: url('.$pro_img.')"></div>
                </div>
            </div>

            <div class="col-12 text-right mt-3 mb-2 px-4">
                <div class="product-title mb-1 font-weight-normal mr-1">'.$pro_name.'</div>
                '.$price_section.$price_section_dis;

?>

<?php
if($showdetails){
	echo '					<div class="text-primary text-right product-sub  font-weight-normal mt-3"   id="showinfo-'.$pro_id.'">
						<span>جزییات محصول</span>
						<i class="fa fa-info-circle ml-1"></i>
					</div>';
}
?>
				

	<?php echo'				
					
					
            </div>
			
 
			
            <div class="col-12 mt-3 ">
                <div class="rad-10 bg-white">
                    <div class="border-top border-light"></div>
                    <form class="sendme" id="sendme'.$i.'" method="post" action="'.$actiondest.'" dir="rtl" style="">
                        <div class="form-row  " style="border-radius: 15px;">

                            <div class="col-4  d-flex align-items-center justify-content-center border-left border-light" style="font-size: 0.85rem; color: #121212; font-weight: 300;">

                                <div class="text-primary">'.$intitle.'</div>
                            </div>

                            <div class="col-8  d-flex align-items-center px-0">
                            
                            
                            
                               '.$handletypesres.'
                                
                                
                                
                            </div>



                  <div class="col-12  d-flex align-items-center ">
                        <input class="form-control  border-0 bg-light my-auto text-right d-none" style="font-size: 0.8rem;" type="text" name="cartitemsname" value="'.$pro_name.'"  hidden>
                  </div>



                  <div class="col-12  d-flex align-items-center ">
                        <input class="form-control  border-0 bg-light my-auto text-right d-none" style="font-size: 0.8rem;" type="text" name="cartitemsid" value="'.$pro_id.'"  hidden>
                  </div>



                  <div class="col-12  d-flex align-items-center ">
                        <input class="form-control  border-0 bg-light my-auto text-right d-none" style="font-size: 0.8rem;" type="text" name="cartitemspri" value="'.$pro_price.'"  hidden>
                  </div>



                            <div class="col-12 text-left ">
                                <button class="cart-button product-form-btn bg-light text-success" name="addprotocart" type="submit">
                                    <span class="add-to-cart  text-success">ثبت سفارش
                                    </span> <span class="added  text-success">اضافه شد</span>
                                    <i class="fa fa-shopping-cart  text-success"></i>
                                    <i class="fa fa-square  text-success"></i>
                                </button>
                            </div>
                            
                            
                            
                        </div>
                    </form>


                </div>
            </div>

        </div>
    </div>


</div>
';      

}else if($showoutofstock){
   
 echo '<div class="col-xl-3 col-lg-4 col-md-6 col-6 mb-xl-4 mb-lg-3 mb-2  px-0">

    <div class="product-card  bg-white m-1 m-lg-2">

        <div class="row">

            <div class="col-12"> 
                <div class="product-image-holder mx-auto mt-2">
                    <div class="product-image" style="background-image: url('.$pro_img.')"></div>
                </div>
            </div>

            <div class="col-12 text-right mt-3 mb-2 px-4">
                <div class="product-title mb-1 font-weight-normal mr-1">'.$pro_name.'</div>
                <div class="product-sub  font-weight-normal mr-1 mt-3">
                    <span class="ml-2">قیمت: </span>
                    <span>'.$pro_priceshow.'</span>
                </div>

            </div>
            <div class="col-12 mt-3 ">
                <div class="rad-10 bg-white">
                    <div class="border-top border-light"></div>
                    <form class="canceled" id="canceled'.$i.'" method="post" action="" dir="rtl" style="">
                        <div class="form-row  " style="border-radius: 15px;">


                            <div class="col-12 text-left ">
                                <button class="cart-button product-form-btn bg-warning text-success" name="addprotocart" type="submit" disabled>
                                    <span class="add-to-cart  text-dark h6">اتمام موجودی

                                </button>
                            </div>
                            
                            
                            
                        </div>
                    </form>


                </div>
            </div>

        </div>
    </div>


</div>
';   
   
   
}else{
        
 
        
}
    
}    
                 
                                
                                                                
}


?>