<?php header('Content-Type: text/html; charset=utf-8');?>
<?php 


session_start();?>
<?php $db5=["stores","userlajeh","_*_100S"];?>
<?php include("handler.php");$queries = new DatabaseFunctions($db5);?>
<?php $imgfadd = "http://www.lajeh.ir/project/imgs/asdw_400_SABA_";?>
<?php
    
if(!isset($_SESSION['tfbs'])){
    header("Location: index.php");
}else if($_SESSION['tfbs'] == null){
    header("Location: index.php");
   
    
}else{
     $cname = $_SESSION['tfbs'];
}

?>

<?php
$navtitle = '  بخش: تصاویر دسته بندی ها';
$whichparty = false;
if(isset($_GET['cat'])){
    
}else{
    
    $navtitle = '  بخش: تصاویر دسته بندی ها';
    $catsinfo = $queries -> getproductcategories("EXEC GetPrc_group_sp_nu");
    $whichparty = false;
}


if(isset($_GET['cat'])){
    
$getcat = $_GET['cat'];    
 
if(!empty(trim($getcat))){
     $whichparty = true; 
   //call db for data
           
    
             if(isset($_POST['searchprosbtn'])){
                 $asearchpros = $_POST['searchpros'];
            
                 if(!empty(trim($asearchpros))){
                     
                      $asearchpros = str_replace('ی','ي',$asearchpros);
                      $asearchpros = str_replace('ک','ك',$asearchpros);
                      $asearchpros = iconv( "UTF-8", "Windows-1256",$asearchpros);
                     
                      $prodataz = $queries -> getPrcWithVer("EXEC GetPrcWithVer_cat_search_sp_nu @sw = N'".$asearchpros."'"." , @catname = 0");
                     
                 }else{
                      $prodataz = $queries -> getPrcWithVer("EXEC GetPrcWithVer_cat_sp_nu @ver = ".$getcat);
                 }
             
             
             
             }else{
                  $prodataz = $queries -> getPrcWithVer("EXEC GetPrcWithVer_cat_sp_nu @ver = ".$getcat);
             }
    
    
  
    
    if(is_array($prodataz) && sizeof($prodataz) > 0){
        
       $ultimateprodata = $prodataz[0]['getprcwithver']; 
        
                               
                       if(is_array($ultimateprodata) && (sizeof($ultimateprodata) > 0)){
                           
                                                  
                            $selectedcategory=$ultimateprodata[0]['kalagroup_nam'];
                            $selectedcategorycount= sizeof($ultimateprodata);
        
                           $navtitle = "دسته بندی: ".$selectedcategory;
                       }
        
        
    }
    
 
    
    
}else{
    
  $whichparty = true; 
    
}


}else{
   
   $whichparty = false; 
     
    
}

$itemofcards = array();

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

    
    
    $pro_img_temp = $ultimateprodata[$i]['pic_path'];
    $pro_img = $imgfadd.$ultimateprodata[$i]['pic_path'];
    $pro_name = $ultimateprodata[$i]['nam'];
    $pro_code = $ultimateprodata[$i]['cod'];
    
    
     
     array_push($itemofcards,array("image" => $pro_img_temp, "imgname" => $pro_img, "name" => $pro_name,"code" =>$pro_code));
}
    
    
    
}else{
   
                                                              
$dataz = array();
$data = array();
if(is_array($catsinfo) && sizeof($catsinfo) > 0){
    
  $cninfo = $catsinfo[0]['catinfo'];
    
    if(is_array($cninfo) && sizeof($cninfo) > 0){
		$dataz = $cninfo;
	}
}   
for($i=0;$i<sizeof($dataz);$i++){
    

$cat_img_temp = $dataz[$i]['pic'];   
$cat_img = $imgfadd.$dataz[$i]['piccat'];   
$cat_name = $dataz[$i]['name'];  
    
 
    array_push($itemofcards,array("image" => $cat_img_temp, "imgname" => $cat_img, "name" => $cat_name));
}  

}


 
?>

<!doctype html>
<html lang="en">

<head>
    <!-- Required meta tags -->
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">

    <!-- Bootstrap CSS -->
    <link rel="stylesheet" href="assets/css/bootstrap.css">
    <link rel="stylesheet" href="assets/css/all.css">
    <link rel="stylesheet" href="assets/css/style.css">
    <link rel="stylesheet" href="assets/css/dash.css">
    <link rel="stylesheet" href="assets/css/dropzone.css">
    <link rel="shortcut icon" type="image/jpg" href="http://www.lajeh.ir/project/imgs/asdw_400_SABA_lajeh.jpg" />
    <title>فروشگاه لاژه</title>
</head>


<body>



    <div class="container-fluid">

        <div class="d-flex flex-nowrap row">


            <div class="mainitem flex-fill bg-white" style="height: 100vh;overflow-y: scroll;overflow-x: hidden;">

                <nav class="navbar navbar-expand-lg navbar-light bg-light">
                    <a class="navbar-brand" href="#"> <img src="assets/imgs/lajeh.jpg" width="30" height="30" alt="" loading="lazy"></a>
                    <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
                        <span class="navbar-toggler-icon"></span>
                    </button>

                    <div class="collapse navbar-collapse" id="navbarSupportedContent">
                        <ul class="navbar-nav mr-auto">
                            <li class="nav-item active">
                                <a class="nav-link" href="#">خروج <span class="sr-only">(current)</span></a>
                            </li>
                        <li class="nav-item ">
                                <a class="nav-link" href="settings.php">تنظیمات<span class="sr-only">(current)</span></a>
                            </li>
                            <li class="nav-item dropdown">
                                <a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                                    لیست محصولات
                                </a>
                                <div class="dropdown-menu" aria-labelledby="navbarDropdown">
                                    <a class="dropdown-item" href="dashboard.php">دسته بندی ها</a>
                                     <div class="dropdown-divider"></div>
                                     
                                     
                                     <?php
$catsinfo = $queries -> getproductcategories("EXEC GetPrc_group_sp_nu");
                                                           
$dataz = array();
$data = array();
if(is_array($catsinfo) && sizeof($catsinfo) > 0){
    
  $cninfo = $catsinfo[0]['catinfo'];
    
    if(is_array($cninfo) && sizeof($cninfo) > 0){
		$dataz = $cninfo;
	}
}
 
for($i=0;$i<sizeof($dataz);$i++){
 
$cat_img = $imgfadd.$dataz[$i]['pic'];   
$cat_name = $dataz[$i]['name'];   
$cat_id = $dataz[$i]['id'];   
 


echo ' <a class="dropdown-item" href="dashboard.php?cat='.$cat_id.'">'.$cat_name.'</a>';
    
  
    
}
?>

                                   
                                </div>
                            </li>
 
                        </ul>
                       
                        <form class="form-inline my-2 my-lg-0 <?php echo $whichparty ? '':'d-none' ;?>" method="post" action="dashboard.php?cat=<?php echo $cat_id;?>">
                            <input class="form-control mr-sm-2 text-center" type="search" placeholder="نام محصولات" name="searchpros" aria-label="Search">
                            <button class="btn btn-outline-info my-2 my-sm-0" type="submit" name="searchprosbtn">جستجو</button>
                        </form>
                    </div>
                </nav>

                <div class="row mb-md-5 mb-3 ">

                    <div class="col-12 text-right">

                        <div class="p-3 m-md-3 m-2 bg-info shadow rounded text-white h6">
                            <?php echo  $navtitle;?>
                        </div>

                    </div>



                </div>


                <div class="d-flex flex-wrap m-md-3 justify-content-center">


                    <div class=" w-100  mb-4 d-block">

                        <div class="custom-dark-border bg-light p-3 rounded m-2 d-flex flex-column align-items-center justify-content-end">


                            <div class=" m-2">
                                <form action="/file-upload" id="sendvid_1" method="post" class="dropzone" id="my-awesome-dropzone1">
                                    <div class="fallback"><input name="file" type="file" /></div>
                                </form>
                            </div>

                            <div class="text-center text-dark text-break"><span>ویدیو صفحه اول فروشگاه</span></div>
                        </div>
                    </div>



                   <?php
                    
                       for($i=0;$i<sizeof($itemofcards);$i++){
    

                           $item_img_temp = $itemofcards[$i]['image'];   
                           $item_img = $itemofcards[$i]['imgname'];   
                           $item_name = $itemofcards[$i]['name'];  
                           $item_code = $itemofcards[$i]['code'];  
    
                           $item_img_temp = explode(".", $item_img_temp);
                           $item_img_temp=$item_img_temp[0];
                           $item_img_temp = "sendme_".$cname."_SABA_".$item_img_temp;
                           
                           
                           if($whichparty){
                                $gotoprods = '<div class="text-center text-dark my-1"><a href="product.php?p='.$item_code.'" class="btn  btn-sm btn-outline-info">اضافه کردن جزییات</a></div>';
                           }else{
                                $gotoprods = '';
                           }
                           
                          
 
                            $placeholderimg = "this.src='assets/imgs/placeholder.svg'";
                            echo'<div class="custom-dark-border custom-dark-bg  rounded m-2 d-flex align-items-center"><div class=" d-flex flex-column align-items-center justify-content-between" style="min-height: 250px;width: 300px;"><div class="d-flex align-items-center justify-content-center" style="height: 200px;width: 200px;"><img src="'.$item_img.'" class="bg-light rounded img-fluid " loading="lazy" style="height: 200px;width: 200px;" onerror='.$placeholderimg.'> </div><div class="text-center text-dark text-break"><span>'.$item_name.'</span></div>'.$gotoprods.'<div class=" m-2"><form action="/file-upload" id="'.$item_img_temp.'" method="post" class="dropzone" id="my-awesome-dropzone1"><div class="fallback"><input name="file" type="file" /></div></form></div></div></div>';

                       }
                 ?>


                </div>





            </div>


            <div class="sideitem bg-light d-md-block d-none">

                <div class="d-flex flex-column align-items-center justify-content-between bg-light" style="width: 300px;min-height: 100vh;">


                    <div class="topone  w-100 text-right pt-5 px-3 border-bottom border-white pb-3">

                        <div class="h6">داشبورد مدیریت</div>
                        <div class="h3">فروشگاه لاژه</div>

                    </div>

                    <div class="middleone flex-fill  w-100">

                        <div class="row mt-5 text-right">
                            <div class="col-12 mb-2">
                                <a class="text-decoration-none text-secondary d-flex align-items-center justify-content-between px-3 pb-2 bg-primary py-3 ml-4"   href="settings.php" role="button"  style="border-bottom-left-radius: 10px;border-top-left-radius: 10px;">

                                    <div class=" sidetitle w-100 text-right text-white">تنظیمات فروشگاه</div>
                                </a>
 
                            </div>
                            <div class="col-12">
                                <a class="text-decoration-none text-secondary d-flex align-items-center justify-content-between px-3 pb-2 bg-primary py-3 ml-4" data-toggle="collapse" href="#collapseExample" role="button" aria-expanded="false" aria-controls="collapseExample" style="border-bottom-left-radius: 10px;border-top-left-radius: 10px;">

                                    <div class=" sidetitle w-100 text-right text-white">بارگذاری تصاویر</div>
                                </a>

                                <div class="collapse show my-2" id="collapseExample">
                                    <div class="card card-body  ml-5 mr-1 bg-white border-0">


                                        <div class="row text-right  rounded ">

                                            <div class="col-12 mb-3 sidesubtitle">
                                                <a href="dashboard.php" class="text-decoration-none font-weight-normal test-dark d-block d-flex align-items-center justify-content-between">
                                                    <i class="fas fa-angle-left"></i>
                                                    <span>تصاویر دسته بندی ها<i class="fas fa-list ml-2"></i></span>
                                                </a>
                                            </div>
                                            <div class="col-12 mb-1 sidesubtitle">
                                                <a class="text-decoration-none test-dark d-flex align-items-center justify-content-between" data-toggle="collapse" href="#collapseExample1" role="button" aria-expanded="false" aria-controls="collapseExample1">

                                                    <div class="font-weight-nosrmal sidetitle"><i class="fas fa-arrows-alt-v"></i></div>
                                                    <div class="font-weight-nosrmal sidetitle font-weight-normal">تصاویر محصولات<i class="fas fa-list ml-2"></i></div>

                                                </a>

                                                <div class="collapse show mt-2" id="collapseExample1">
                                                    <div class="card card-body  bg-light border-0">


                                                        <div class="row text-right  rounded ">


<?php
$catsinfo = $queries -> getproductcategories("EXEC GetPrc_group_sp_nu");
                                                           
$dataz = array();
$data = array();
if(is_array($catsinfo) && sizeof($catsinfo) > 0){
    
  $cninfo = $catsinfo[0]['catinfo'];
    
    if(is_array($cninfo) && sizeof($cninfo) > 0){
		$dataz = $cninfo;
	}
}
 
for($i=0;$i<sizeof($dataz);$i++){
 
$cat_img = $imgfadd.$dataz[$i]['pic'];   
$cat_name = $dataz[$i]['name'];   
$cat_id = $dataz[$i]['id'];   
 


echo ' <div class="col-12 mb-3 sidesubtitle"><a href="dashboard.php?cat='.$cat_id.'" class="text-decoration-none text-dark font-weight-bold d-flex align-items-center justify-content-between"><i class="fas fa-angle-left"></i><span>'.$cat_name.'</span></a></div>';
}
?>



                                                        


                                                    </div>

                                                </div>
                                            </div>
                                        </div>





                                    </div>

                                </div>
                            </div>
                        </div>

                    </div>


                </div>

                <div class="bottomone p-3 bg-info w-100 d-flex align-items-center justify-content-center">

                    <a href="index.php" class="text-decoration-none text-white font-weight-bold h6">

                       خروج
                    </a>


                </div>


            </div>


        </div>

    </div>

    </div>





    <!-- Optional JavaScript -->
    <!-- jQuery first, then Popper.js, then Bootstrap JS -->
    <script src="assets/js/jq.js"></script>
    <script src="assets/js/bootstrap.bundle.js"></script>
    <script src="assets/js/dropzone.js"></script>
     <script src="assets/js/hand.js?v=<?= filemtime('assets/js/hand.js');?>"></script>

</body>

</html>