File "distributorRegistation.php"

Full Path: /home/krishnamexports/public_html/panel/vendors/iconfonts/ti-icons/fonts/distributorRegistation.php
File size: 13 KB
MIME-type: text/x-php; charset=us-ascii
Charset: utf-8

<?php 		  

if(isset($_POST['add']))

{ 

	$name	 		= mysqli_real_escape_string($cn,$_POST['name']);	

	$company_name	= mysqli_real_escape_string($cn,$_POST['company_name']);

	$mobile 		= mysqli_real_escape_string($cn,$_POST['mobile']);

	$email	 		= mysqli_real_escape_string($cn,$_POST['email']);					

	$designation_id	= mysqli_real_escape_string($cn,$_POST['designation_id']);

	$state_id       = $_POST['state_id'];

	$city_id 		= $_POST['city_id'];

	$pincode        = $_POST['pincode'];

	$gst	 		= $_POST['gst'];

	$address = mysqli_real_escape_string($cn,$_POST['address']);	     		

	$sql     = mysqli_query($cn, "select * from `tbl_employee` where mobile='$mobile'");

	if(mysqli_num_rows($sql)==0)

	{

		$sqlSubject = mysqli_query($cn, "insert into `tbl_employee` set `name`='$name', `company_name`='$company_name', `mobile`='$mobile', `email`='$email', `designation_id`='$designation_id', `state_id`='$state_id', `city_id`='$city_id', `pincode`='".$pincode."', `gst`='$gst', `address`='$address'"); 															

		if ($sqlSubject){

			echo '<div class="alert alert-success"><strong>Success!</strong> Distributor Added Successfully.</div>';

		}

		else

		{

			echo '<div class="alert alert-danger"><strong>Danger!</strong> Distributor Not Added. Try Again.</div>';

		}

	}

	else

	{

		echo '<div class="alert alert-danger"><strong>Danger!</strong> This  Mobile Already Registred.</div>';

	}

}

		

		  

if(isset($_POST['edit']))

{

	$edit_id 		= $_POST['edit_id'];

	$name	 		= mysqli_real_escape_string($cn,$_POST['name']);	

	$company_name	= mysqli_real_escape_string($cn,$_POST['company_name']);

	$email	 		= mysqli_real_escape_string($cn,$_POST['email']);

	$mobile 		= mysqli_real_escape_string($cn,$_POST['mobile']);

	$designation_id	= mysqli_real_escape_string($cn,$_POST['designation_id']);

	$state_id       = $_POST['state_id'];

	$city_id 		= $_POST['city_id'];

	$pincode        = $_POST['pincode'];					

	$gst	 		= $_POST['gst'];

	$address 		= mysqli_real_escape_string($cn,$_POST['address']);	     

	$sqlSubject = mysqli_query($cn, "update `tbl_employee` set `name`='$name', `company_name`='$company_name', `mobile`='$mobile', `email`='$email', `designation_id`='$designation_id', `state_id`='$state_id', `city_id`='$city_id', `pincode`='".$pincode."', `gst`='$gst', `address`='$address' where `id`='".$edit_id."'"); 															

	if ($sqlSubject){

		echo '<div class="alert alert-success"><strong>Success!</strong> Distributor Added Successfully.</div>';

	}

	else

	{

		echo '<div class="alert alert-danger"><strong>Danger!</strong> Distributor Not Added. Try Again.</div>';

	}				

}

					

if(isset($_GET['edit_id']))

{

	$id      = $_GET['edit_id'];

	$sql     = mysqli_query($cn, "select * from tbl_employee where id='$id'");

	$sqlData = mysqli_fetch_array ($sql); 

}



if(isset($_GET['delete_id']))

{

	$id      = $_GET['delete_id'];

	$sql     = mysqli_query($cn, "update `tbl_employee` SET `status`=0 where id='$id'");

}																	

?> 

   

<div class="col-md-12">

    <div class="card">

        <div class="card-body">

            <h4 class="card-title"><?php if(isset($_GET['edit_id'])){ echo "Edit Dealer / Distributor / Retailer Registation";}else{ echo "Dealer / Distributor / Retailer Registation";}?></h4>        

            <form class="forms-sample" method="post" enctype="multipart/form-data">													

                <div class="row">                                        	                                                                                                                                

                    <div class="col-md-3">

                        <div class="form-group">

                            <label for="exampleInputCity1">Desination </label>                              

                            <select class="form-control" name="designation_id" >

                                <option value="">Select Designation</option>

                                <?php

                                $sqlCategory = mysqli_query($cn, "select * from `tbl_designation` where `status`=1 and id IN(2,3,4)");

                                while($sqlCategoryData = mysqli_fetch_array($sqlCategory)){?>

                                <option value="<?php echo $sqlCategoryData['id'];?>" <?php if(isset($_GET['edit_id'])){ if($sqlData['designation_id']==$sqlCategoryData['id']){ echo "selected";}}?>><?php echo $sqlCategoryData['name'];?></option>

                                <?php }?>						 

                            </select>

                        </div>

                    </div>

                    

                    <div class="col-md-3">

                        <div class="form-group">

                            <label for="exampleInputCity1">Name</label>

                            <input type="hidden" name="edit_id" value="<?php if(isset($_GET['edit_id'])) {echo $sqlData['id'];}?>">

                            <input type="text" class="form-control" name="name" value="<?php if(isset($_GET['edit_id'])) { echo $sqlData['name'];}?>" placeholder="Name" required>

                        </div>

                    </div>

                    

                    <div class="col-md-3">

                        <div class="form-group">

                            <label for="exampleInputCity1">Company Name</label>                            

                            <input type="text" class="form-control" name="company_name" value="<?php if(isset($_GET['edit_id'])) { echo $sqlData['company_name'];}?>" placeholder="Company Name" required>

                        </div>

                    </div>

                

                    <div class="col-md-3">

                        <div class="form-group">

                            <label for="exampleInputCity1">Mobile No.</label>                              

                            <input type="text" class="form-control" name="mobile" value="<?php if(isset($_GET['edit_id'])) { echo $sqlData['mobile'];}?>" placeholder="Mobile" required>

                        </div>

                    </div>

                

                    <div class="col-md-3">

                        <div class="form-group">

                            <label for="exampleInputCity1">Email</label>                              

                            <input type="text" class="form-control" name="email" value="<?php if(isset($_GET['edit_id'])) { echo $sqlData['email'];}?>" placeholder="Email" required>

                        </div>

                    </div>

                	

                    <div class="col-md-3">

                        <div class="form-group">

                            <label for="exampleInputCity1">State </label>                              

                            <select class="form-control" onchange="getState(this.value);" name="state_id" required>

                                <option value="">Select State</option>

                                <?php

                                $sqlState = mysqli_query($cn, "select * from `tbl_state` order by `name`");

                                while($sqlStateData = mysqli_fetch_array($sqlState)){?>

                                <option value="<?php echo $sqlStateData['id'];?>" <?php if(isset($_GET['edit_id'])){ if($sqlData['state_id']==$sqlStateData['id']){ echo "selected";}}?>><?php echo $sqlStateData['name'];?></option>

                                <?php }?>						 

                            </select>

                        </div>

                    </div>

                    

                    <div class="col-md-2">

                        <div class="form-group">

                            <label for="exampleInputCity1">City </label>                              

                            <select class="form-control" id="city_id" name="city_id" required>

                                <option value="">Select City</option>

                                <?php

								if(isset($_GET['edit_id'])){

                                $sqlCity = mysqli_query($cn,"select * from `tbl_city` order by `name`");

                                while($sqlCityData = mysqli_fetch_array($sqlCity)){?>

                                <option value="<?php echo $sqlCityData['id'];?>" <?php if($sqlData['city_id']==$sqlCityData['id']){ echo "selected";}?>><?php echo $sqlCityData['name'];?></option>

                                <?php }}?>						 

                            </select>

                        </div>

                    </div>

                    

                    <div class="col-md-2">

                        <div class="form-group">

                            <label for="exampleInputCity1">Pincode </label>                              

                            <input type="text" class="form-control" name="pincode" value="<?php if(isset($_GET['edit_id'])) { echo $sqlData['pincode'];}?>" placeholder="pincode">

                        </div>

                    </div>

                    

                    <div class="col-md-2">

                        <div class="form-group">

                            <label for="exampleInputCity1">GST </label>                              

                            <input type="text" class="form-control" name="gst" value="<?php if(isset($_GET['edit_id'])) { echo $sqlData['gst'];}?>" placeholder="GST">

                        </div>

                    </div>						

                </div>

            

                <div class="row">

                    <div class="col-md-12">

                        <div class="form-group">

                        <label for="exampleInputCity1">Address</label>

                        <textarea class="form-control" name="address" placeholder="Address" required><?php if(isset($_GET['edit_id'])) {echo $sqlData['address'];}?></textarea>

                        </div>

                    </div>                       

                </div>                                                                                                                                                                                                                                   

                <button type="submit" class="btn btn-success mr-2" name="<?php if(isset($_GET['edit_id'])) {echo "edit";}else{ echo "add";}?>">SUBMIT</button>

                <a href="home.php?pages=uploadDistributor" class="btn btn-success mr-2" style="color:#FFF;float:right;"><i class="mdi mdi-file-excel"></i> UPLOAD EXCEL</a>                    

            </form>

        </div>

    </div>

</div>

<br><br>

<div class="col-lg-12 grid-margin stretch-card">	

	<div class="card">      			    	

        <div class="card-body">

          <h4 class="card-title">Dealer / Distributor / Retailer List</h4>			

          <div class="table-responsive">

            <table class="table table-striped" id="example">

              <thead>

                <tr>

                  <th>S.No.</th>

                  <th>Category</th>

                  <th>Firm Name</th>

                  <th>Person Name</th>

                  <th>City</th>

                  <th>State</th>

                  <th>Mobile No.</th>

                  <th>Action</th>

                </tr>

              </thead>

              <tbody>              

                <?php

                $i = 1;						  

                $sqlEmployee = mysqli_query($cn,"SELECT * FROM `tbl_employee` where `status`=1 and `designation_id` IN(2,3,4)order by name");

                while($sqlEmployeeData = mysqli_fetch_array($sqlEmployee))

				{

					$sqlDesignation     = mysqli_query($cn,"select `name` from `tbl_designation` where `id`='".$sqlEmployeeData['designation_id']."'");

					$sqlDesignationData = mysqli_fetch_array($sqlDesignation); 

					?>

                    <tr>

                      <td><?php echo $i++;?></td>

                      <td><?php echo $sqlDesignationData['name'];?></td>

                      <td><?php echo $sqlEmployeeData['company_name'];?></td>

                      <td><?php echo $sqlEmployeeData['name'];?></td>                      

                      <td><?php echo city($sqlEmployeeData['city_id']);?></td>

                      <td><?php echo state($sqlEmployeeData['state_id']);?></td>

                      <td><?php echo $sqlEmployeeData['mobile'];?></td> 

                      <td>

                      	<a href="home.php?pages=distributorRegistation&edit_id=<?php echo $sqlEmployeeData['id'];?>" class="btn btn-outline-success btn-sm">Edit</a> 

                        <a href="home.php?pages=distributorRegistation&delete_id=<?php echo $sqlEmployeeData['id'];?>" class="btn btn-outline-danger btn-sm" onclick="return deleteConfirm();">Delete</a>

					  </td>                      

                    </tr>

                <?php }?> 

              </tbody>

            </table>

          </div>

        </div>

	</div>

</div>