<?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'];
}

$getp = 0;  
if(isset($_GET['p'])){    
      $getp = $_GET['p'];  
      if(empty(trim($getp))){
         header("Location: dashboard.php");    
      }
}else{
    header("Location: dashboard.php"); 
}

?>


<?php
if(isset($_POST['upya'])){
       
       $yads = $_POST['fields'];
       if(is_array($yads) && (sizeof($yads) > 0)){
            $readytoupdate = array();         
           for($i=0;sizeof($yads)>$i;$i++){
               
                      $yaditem = $yads[$i];
                      if(!empty(trim($yaditem))){
                     
                          array_push($readytoupdate,$yaditem); 
                         
                      }

               
           }
           
           $readytoupdate=json_encode($readytoupdate,false);    
           $queries -> updateyad("EXEC updateyad @cod = ".$getp.", @yad = N'".$readytoupdate."' ");

                     
                     
                     
       }
             
             
             
}  



$prcyad = $queries -> getprcyad("EXEC selectyad @cod = ".$getp);
$prcname = $queries -> getprcnam("EXEC selectyad @cod = ".$getp);

$prcyad = json_decode($prcyad,false);
 

$inputsvalues='';

for($j=0;sizeof($prcyad)>$j;$j++){
               
      $prcyaditem = $prcyad[$j];
      if(!empty(trim($prcyaditem))){
                          
         $inputsvalues .= '<div class="entry input-group col-xs-3"><input class="form-control text-right" name="fields[]" type="text" placeholder="" value="'.$prcyaditem.'"><span class="input-group-btn"><button class="btn btn-remove btn-danger" type="button"><span class="glyphicon glyphicon-minus">-</span></button></span></div>';
                         
     }

               
}




?>

<!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>';

 
}
                                    

                                 
									
//$nowww = array();    
//for($i=0;$i<3;$i++){
//	$rname = "اءلاعات مورىنيار".$i;
//		            $rname = str_replace('ی','ي',$rname);
//                  
//                    $nam  =  iconv( "UTF-8", "Windows-1256",$rname); 
// 
//   array_push($nowww,$rname); 
//} 
//$nowww=json_encode($nowww,false);   
     
    
//$prcyad = $queries -> updateyad("EXEC updateyad @cod = 33520, @yad = N'".$nowww."' ");
//$prcyad = $queries -> getprcyad("EXEC selectyad @cod = 33520");
//var_dump(json_decode($prcyad,false));                                       
?>

                                   
                                </div>
                            </li>
 
                        </ul>
 
                    </div>
                </nav>

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

                    <div class="text-right">

                        <div class="p-3 m-md-3 m-2 bg-primary shadow rounded text-white h6">
                            <?php echo  ' نام محصول: '.$prcname;?>
                        </div>

                    </div>



                </div>

 

                <div class="d-flex justify-content-center ">
                    <div class="control-group  bg-light p-md-3 p-2 rounded shadow-sm m-2 w-75" id="fields">
                        <label class="control-label text-right w-100 " for="field1">:فرم جزییات محصول</label>
                        <label class="control-label text-right w-100 " for="field1"> <?php echo  ' نام محصول: '.$prcname;?></label>
                        <div class="controls">
                            <form class="text-right" role="form" autocomplete="off" method="post" action="product.php?p=<?php echo $getp;?>">
                                <div class="entryinputs my-3">
                                    
                                    
                                     <?php echo $inputsvalues;?>
                                    
                                    
                                    <div class="entry input-group col-xs-3">

                                        <input class="form-control text-right" name="fields[]" type="text" placeholder="" />
                                        <span class="input-group-btn">
                                            <button class="btn btn-success btn-add" type="button">
                                                <span class="glyphicon glyphicon-plus">+</span>
                                            </button>
                                        </span>
                                    </div>

                                </div>

                                <button type="submit" class="btn btn-primary mt-2" name="upya">ثبت اطلاعات</button>
                            </form>
                            <br>

                        </div>
                    </div>
                </div> <!-- /div.row -->

            </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"></script>

</body>

</html>