<?php
session_start();
error_reporting(0);
@ini_set('display_errors', 0);
$id_user=$_SESSION['id'];
$branch=$_SESSION['branch_id'];
$business=$_SESSION['business_id'];
?>

<!DOCTYPE html>
<html>
<?php

if(isset($_GET['staffcode'])){
    $staffcode=$_GET['staffcode'];
}
else{
    $staffcode=0;
}
$showbtn="no";
include("../includes/header-links.php");
?>
    
    <head>
            <?php include("../includes/header-links.php");
$permissions = mysqli_fetch_array(mysqli_query($con,"SELECT * FROM  
  permissions,users WHERE  permissions.role_id = users.role 
  AND users.id='$id_user' AND users.business_id ='$business' AND users.branch_id ='$branch'"));

if($permissions['view_sales'] != 1){
?>
<script>window.location="../expenses/expenses.php"</script>
<?php
}
?>


      <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
        
        <!-- Bootstrap -->
        <link href="../bootstrap/css/bootstrap.min.css" rel="stylesheet" media="screen">
        <link href="../bootstrap/css/bootstrap-responsive.min.css" rel="stylesheet" media="screen">
        <link href="../assets/styles.css" rel="stylesheet" media="screen">
        <link href="../assets/DT_bootstrap.css" rel="stylesheet" media="screen">
        <!--[if lte IE 8]><script language="javascript" type="text/javascript" src="vendors/flot/excanvas.min.js"></script><![endif]-->
        <!-- HTML5 shim, for IE6-8 support of HTML5 elements -->
        <!--[if lt IE 9]>
            <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
        <![endif]-->
        <script src="../vendors/modernizr-2.6.2-respond-1.1.0.min.js"></script>
        <style type="text/css">
            #select01_chzn > a > span{
                    height: 20px;
    font-size: 20px;
            }
            #select01_chzn > div > div > input[type=text]{
              height: 30px;
            }
            #select01_chzn > a{
              height: 40px;
            }
        </style>
    </head>
    
    <body>
        <?php include '../includes/header.php';
         $total=0; ?>
        <div class="container-fluid">
            <div class="row-fluid" style="font-size: 22px;">
                <?php 
                // include '../includes/sidebar.php'; 
                ?>
                <!--/span-->
                <div class="pull-center">
                   
                                       <a href="../main/dashboard.php"> <button class="btn btn-primary"><i class="icon-shopping-cart icon-white"></i> Dashboard</button></a>

                          </div>
           <div class="span6" id="content" >

                        <div class="row-fluid">
                        <!-- block -->
                        <div class="block">
                            <div class="navbar navbar-inner block-header">
                                <div class="muted pull-left">Orders</div>
                                <div class="muted pull-right">
<?php 
$sql = "SELECT count(id) as pendings FROM sales where total_price>paid AND branch_id='$branch' AND business_id='$business'";
$result = mysqli_query($conn, $sql);

if (mysqli_num_rows($result) > 0) {
    // output data of each row
    while($row = mysqli_fetch_assoc($result)) {
        $pending_payments=$row['pendings'];
    }
} else {
    echo "0 results";
}
if ($empties==1) {
  # code...

?>                                    <?php
                                                 //if($_SESSION['role']=="admin"){
                                                 if( $permissions['view_customer_balance'] == 1){ 
                                                  ?>
                                  <a href="../reports/customer_balances.php"><button class="btn btn-primary"><i class="fa fa-hourglass-half"></i>&nbsp; Customer Balances </button></a>
                                  <?php } ?>


                                  <?php
                                                 //if($_SESSION['role']=="admin"){
                                                 if( $permissions['view_untaken_orders'] == 1){ 
                                                  ?>
                                   <a href="input_reference.php"><button class="btn btn-primary"><i class="fa fa-hourglass-half"></i>&nbsp; Un taken orders </button></a>

                                   <?php } ?>
                                   <?php
                                   }
                                   if( $permissions['view_pending_payments'] == 1){
                                    ?>
                                    <a href="payment.php"><button class="btn btn-danger"><i class="fa fa-hourglass-half"></i>&nbsp; Pending Payments (<?php echo $pending_payments; ?>)</button></a>

                                    <?php } ?>
                                </div>
                                
                                
                            </div>
                            <div class="block-content collapse in">
                                <div class="span12">
                                    <?php
                                    include '../includes/connection.php';
                                    $sql = mysqli_query($con,"SELECT id,unit_price, (select product_name from products where id=temp.product_id)as product_name, quantity,saletype,taken, (select price from products where id=temp.product_id)as unit from temp where branch_id='$branch' && user='$id_user'");
                                    if (mysqli_num_rows($sql) > 0) {
                                    	$showbtn="yes";
                                       ?>
  									<table cellpadding="0" cellspacing="0" border="0" class="table table-striped table-bordered" id="example">
										<thead>
											<tr>
												<th>Id</th>
												<th>Product Name</th>
												<th>Quantity</th>
                        <?php if ($empties==1) {
                                                  # code...
                                               ?>
                        <th>Quantity Taken</th>
                                                
                                               <?php }?>
												<th>Unit Price</th>
												<th>Total Price</th>
                                                <th>Action</th>
											</tr>
										</thead>
										<tbody>
                                        <?php
                                        
                                         // output data of each row
                                        $rno=0;
                while($row = mysqli_fetch_assoc($sql)) {
                        $total=$total+$row['unit_price']*$row['quantity'];
                        $sale_type_recorded=$row['saletype'];
                        $rno++;
                    ?>
                    <tr class="odd gradeX">

        
                                                <td><?php echo $rno; ?></td>
                                                <td><?php echo $row['product_name']; ?></td>
                                                <td><?php echo $row['quantity']; ?></td>
                                                <?php if ($empties==1) {
                                                  # code...
                                               ?>
                                                <td><?php echo $row['taken']; ?></td>

                                               <?php }?>
                                                <td class="center"> <?php echo $row['unit_price']; ?></td>
                                                <td class="center"><?php echo $row['unit_price']*$row['quantity']; ?></td>
                                                <td class="center">

                                                  <?php
                                                 //if($_SESSION['role']=="admin"){
                                                 if( $permissions['edit_order'] == 1){ 
                                                  ?>
                                                    <a href="edit_order.php?id=<?php echo $row['id']; ?>&staffcode=<?php echo $staffcode; ?>"><button class="btn btn-primary"><i class="icon-edit icon-white"></i></button></a>
                                                  <?php } ?>

                                                  <?php
                                                 //if($_SESSION['role']=="admin"){
                                                 if( $permissions['delete_order'] == 1){ 
                                                  ?>
                                                    <a href="deleteorder.php?id=<?php echo $row['id']; ?>"><button class="btn btn-danger"><i class="icon-trash icon-white"></i></button></a>

                                                    <?php } ?>


                                                </td>
                                            </tr>
                                            <?php
    }
} else {
    echo "".mysqli_error($con);
}

//mysqli_close($conn);
?>
											
											
										</tbody>
									</table>
                                    <h3><center>TOTAL: Ush. <?php echo $total; ?> </center></h3>
                                    <?php 
     $sql = "SELECT distinct (select full_name from staff where staff_code=temp.staff)as staffname, staff FROM temp where branch_id='$branch' && user='$id_user'";
$result = mysqli_query($con, $sql);

if (mysqli_num_rows($result) > 0) {
$row = mysqli_fetch_assoc($result);
$stafcodex=$row['staff'];
        $staffnamex=$row['staffname'];
                      if ($gbusiness_settings['select_staff_onsale']==1) {
                        
        ?><h4><center>Staff: &nbsp;<?php echo $row['staffname']; ?> &nbsp; (<?php echo $row['staff']; ?>) &nbsp; 
<a href="#myModal" data-toggle="modal">
        <i class="icon-pencil"></i>
</a>
        </center></h4><?php
      }
        
    
} else {
    echo "".mysqli_error($con);
}
                                     ?>

 <div id="myModal" class="modal hide">
		<div class="modal-header">
			<button data-dismiss="modal" class="close" type="button">&times;</button>
			<h3>Edit Staff</h3>
			<p><small>Edit or change the staff that has brought in the order</small></p>
		</div>
		<div class="modal-body">
			<div>
				<form action="" method="POST">
					<select class="span12" name="updatevalue">
						<option value="<?php echo $stafcodex; ?>"><?php echo $staffnamex."&nbsp; (".$stafcodex.") current"; ?></option>
				<?php
$sqlv = "SELECT * FROM staff where status=1 && suspend=1 && branch_id='$branch'";
$resultv = mysqli_query($conn, $sqlv);

if (mysqli_num_rows($resultv) > 0) {
    // output data of each row

    while($rowv = mysqli_fetch_assoc($resultv)) {
    	?>
    	<option value="<?php echo $rowv['staff_code']; ?>"><?php echo $rowv['full_name']."&nbsp (".$rowv['staff_code'].")"; ?>
    	</option>
       <?php
    }
    
} else {
    echo "0 results";
}
				?>
					</select>
					<button type="submit" class="btn btn-large btn-block btn-primary" name="save_changes">Save Changes</button>
				</form>
                <?php
if(isset($_POST['save_changes'])){
    $newcode=$_POST['updatevalue'];
    $sql = "UPDATE temp SET staff='$newcode' where branch_id='$branch' && user='$id_user'";

if (mysqli_query($conn, $sql)) {
     ?><meta http-equiv="refresh" content="0;URL='new_order.php'" /><?php
} else {
    echo "Error updating record: " . mysqli_error($conn);
}

}
                ?>
			</div>
		</div>
	</div>

                  <?php
if($showbtn=="yes"){
	?>

    <form action="processorder.php?total=<?php echo $total;?>&staffcode=<?php echo $stafcodex; ?>" method="POST">
	<div class="muted pull-left">
                      
  <label><h4>Amount Paid</h4></label><input type="number" name="amount_paid" min="0" class="form-control" value="<?php if ($gbusiness_settings['sale_amount_paid']==1) { echo $total;}else{ echo "0";} ?>"  style="height: 30px; width: 150%;" required>
       <?php 
        if ($gbusiness_settings['back_date_sales']==1) {
          ?>
          <label><h4>Sale date</h4></label><input type="date" name="sale_date" max="<?php echo date('Y-m-d'); ?>" class="form-control" value="<?php echo date('Y-m-d'); ?>" style="height: 30px; width: 150%;">
          <?php
          }
          ?>
          <?php
          if ($gbusiness_settings['record_customers']==1) {
          ?>
          <div>
          <?php
          }else{
            ?>
          <div style="display: none;">

            <?php

          }
                    
            ?>
  <label><h4>Customer Name:</h4></label><input type="list" list="customer" id="getcustomer" onchange="getdetails(this.value)" name="name" class="form-control" placeholder="Customer Name" style="height: 30px; width: 150%;">
  <datalist id="customer">
    <?php  
    $getcustomers=mysqli_query($con,"SELECT * from Sales where branch_id='$branch' && business_id='$business' && customer_name!='' group by customer_name, contact ");
    while ($rcustomer= mysqli_fetch_array($getcustomers)) {
      ?>
      <option value="<?php echo $rcustomer['customer_name']?>"><?php echo $rcustomer['customer_name']." | ".$rcustomer['contact']?></option>
      <?php
    }
   
    ?>
  </datalist>
  <script type="text/javascript">
    
function getdetails(id) {
  var xhttp = new XMLHttpRequest();
  xhttp.onreadystatechange = function() {
    if (this.readyState == 4 && this.status == 200) {

        var cust = this.responseText;
        
        document.getElementById("customercontact").value=cust;
      
      
    }
  };
  xhttp.open("GET", "getcustomerdetails.php?customer="+id, true);
  xhttp.send();
}
</script>
  <label><h4>Contact:</h4></label><input type="text" name="contact" id="customercontact" class="form-control"  style="height: 30px; width: 150%;">
  
</div>
  
  
	</div>
    <div class="muted pull-right">
    
<?php
                                                 //if($_SESSION['role']=="admin"){
                                                 if( $permissions['process_order'] == 1){ 
                                                  ?>
                                <button type="submit" name="process_order" class="btn btn-primary btn-large"> Process Order</button>
  <?php } ?>
                              </div>

                               


	<?php
}
                  ?>
                                </form>
                                </div>
                            </div>
                        </div>
                        <!-- /block -->
                    </div>

         
                </div>
                <div class="span5">
                                     <form class="form-horizontal" action="" method="POST"> 
                                      <fieldset>
                                        <legend style="font-size: 30px;">Add new Order</legend>
                                        <?php
                                          if ($business_type==1) {
                                            
                                            ?>
                                        <div class="control-group" id="salid">
                                          <label class="control-label" for="selectError" style="font-size: 20px; ">Sale Type</label>
                                          <div class="controls">
                                            <select id="saletype" class="form-control" name="saletype"  title="Please select type of sale" style="width: 100%; font-size: 18px; height: 35px;">
                                            <!-- <option disabled selected value="" style="font-size: 20px;">Select Sale Type</option> -->
                                            <?php
                                            if (isset($sale_type_recorded)) {
                                              
                                              if ($sale_type_recorded==1) {
                                                $sst="Wholesale";
                                              }else{
                                                $sst="Retail";
                                              }
                                               ?>
                                              
                                              <option value="<?php echo $sale_type_recorded;?>" style="font-size: 20px;"><?php echo $sst;?></option>

                                               <?php
                                             } else{
                                              ?>
                                              <option value="0" style="font-size: 20px;">Retail</option>
                                            <option value="1" style="font-size: 20px;">Wholesale</option>
                                              <?php
                                             }
                                             ?>
                                            
                                              


                                            
                                            </select>
                                            </div>
                                            </div>
                                            <?php
                                          }else{
                                            ?>
                                            <input type="hidden" value="0" name="" id="saletype">
                                            <?php
                                          }
                                          ?>
                                        <div class="control-group">
                                          <label class="control-label" for="selectError" style="font-size: 20px; ">Product</label>
                                          <div class="controls">
                                            <select id="select01" class="chzn-select" name="product" required="required" title="Please select product" onchange="setminmax(this.value);" style="width: 100%; font-size: 18px; height: 35px;">
                                            <option disabled selected value="" style="font-size: 18px;">Select Product</option>
                                              <?php 
$sqlv = "SELECT * FROM products where (NOT EXISTS (SELECT * from temp where product_id=products.id && branch_id='$branch' && user='$id_user')) && branch_id='$branch' && status=1";
$resultv = mysqli_query($conn, $sqlv);

if (mysqli_num_rows($resultv) > 0) {
    // output data of each row

    while($rowv = mysqli_fetch_assoc($resultv)) {
    	?>
    	<option value="<?php echo $rowv['id']; ?>" style="font-size: 18px;"><?php echo $rowv['product_name']." ".$rowv['product_code']; ?>
    	</option>
       <?php
    }
    
} else {
    echo "0 results";
}
                                              ?>
                                            
                                            </select>
<script type="text/javascript">

    function setminmax(idd){
          var xhttp = new XMLHttpRequest();
          var saltype= document.getElementById("saletype").value;
          document.getElementById("saletype").setAttribute("readonly", true);
  xhttp.onreadystatechange = function() {
    if (this.readyState == 4 && this.status == 200) {
      var response=this.responseText.split("|");
      if (response[2]==1) { 
              document.getElementById("quantitya").max =
              response[0];
              document.getElementById("quantitya").placeholder ="Stock Quantity: "+
              response[0];
              document.getElementById("txtt").innerHTML ="Stock Quantity: "+
              response[0];
              //document.getElementById("txttprice").innerHTML=response[1];
              if(response[0]==0){
                document.getElementById("txtt").innerHTML ="! Item is out of stock !";
               document.getElementById("txtt").style.color="red" 
               document.getElementById("approved").style.display="none";
               //document.getElementById("approved").style.disabled=true;
                document.getElementById("txttReserveprice").innerHTML="";
                document.getElementById("txttprice").innerHTML="";
              }
              else{
                document.getElementById("txtt").style.color="green";
                document.getElementById("txttReserveprice").innerHTML="Reserve price: "+response[3];
                document.getElementById("txttprice").innerHTML="Unit price:"+response[1];
              document.getElementById("approved").style.display="block";
              }

      }else{

              document.getElementById("quantitya").max ='';
              document.getElementById("quantitya").placeholder ="";
              document.getElementById("txtt").innerHTML ="";
              //document.getElementById("txttprice").innerHTML=response[1];
              if(response[0]==0){
                document.getElementById("txtt").innerHTML ="";
               document.getElementById("txtt").style.color="red" 
               document.getElementById("approved").style.display="block";
               //document.getElementById("approved").style.disabled=true;
                document.getElementById("txttprice").innerHTML="Unit price: "+response[1];
                document.getElementById("txttReserveprice").innerHTML="Reserve price: "+response[3];

              }
              else{
                document.getElementById("txtt").style.color="green";
                document.getElementById("txttprice").innerHTML="Unit price: "+response[1];
                document.getElementById("txttReserveprice").innerHTML="Reserve price: "+response[3];
              document.getElementById("approved").style.display="block";
              }


      }
      
      
    }
  };
  xhttp.open("GET", "getminmax.php?id="+idd+"&saletype="+saltype, true);
  xhttp.send();

    }

</script>
                                          </div>
                                        </div>
                                        <div class="text-center" style="color: green;"><b>
                                            <h3 id="txtt" align="center"></h3>
                                            <h3 id="txttprice" align="center"></h3></b>
                                            <?php
                                           if ($gbusiness_settings['inlude_reserve_prices']==1) {
                                            ?>
                                            <h3 id="txttReserveprice" align="center"></h3></b>
                                            <?php 
                                              }else{
                                                ?> 
                                            <h3 id="txttReserveprice" align="center" style="display: none;"></h3></b>

                                                <?php
                                              }
                                              ?>
                                        </div>

                                        <div id="approved">
                                        <div class="control-group">
                                          <label class="control-label"  for="focusedInput" style="font-size: 18px;">Quantity</label>
                                          <div class="controls">
                                            <input class="input-xlarge focused" name="quantity" id="quantitya" type="number" value="1"  min="0.25" required style="width: 100%; font-size: 18px; height: 35px;" step="any" onkeyup="setmaxtaken(this.value);">
                                          </div>
                                        </div>
  <script type="text/javascript">

    function setmaxtaken(mxt){
      
      document.getElementById("quantitytaken").max =mxt;
      document.getElementById("quantitytaken").value =mxt;
      
    }

</script>
                                        <?php if ($empties==1) {
                                                  
                                               ?>
                                               <div class="control-group">
                                          <label class="control-label"  for="focusedInput" style="font-size: 18px;">Quantity Taken</label>
                                          <div class="controls">
                                            <input class="input-xlarge focused" name="quantitytaken" id="quantitytaken" type="number" value="1" min="0.25" required style="width: 100%; font-size: 18px; height: 35px;" step="any">
                                          </div>
                                        </div>
                                                
                                               <?php }?>
                                               <?php
                                               if ($gbusiness_settings['select_staff_onsale']==1) {
                                                ?>
                                        <div class="control-group">
                                        <?php 
                                          }else{
                                            ?>
                                        <div class="control-group" style="display: none;">

                                            <?php

                                          }
                                        ?>


<?php
if(isset($stafcodex)){
    $ads=$stafcodex;
?>
                                          <label class="control-label"  for="focusedInput" style="font-size: 18px;">Staff No</label>
                                          <div class="controls">
                                            <input class="input-xlarge focused" name="staffno" id="focusedInput" type="text" value="<?php echo $ads; ?>" style="width: 100%; font-size: 18px;  height: 35px;" readonly>
                                          </div>
                                        </div>
<?php
                      

}else{
    ?>
                                          <label class="control-label"  for="focusedInput" style="font-size: 18px;">Staff Number</label>
                                          <div class="controls">
                                          <select id="select01" class="chzn-select" name="staffno" required="required" title="Please select staff"  style="width: 100%; font-size: 18px; height: 35px;">
                                          
                                           <?php 
                                           $user=$_SESSION['id'];
                                           $compare=mysqli_fetch_array(mysqli_query($con,"SELECT user_code from users where id='$user' && branch_id='$branch'"));
                                           $ucode=$compare['user_code'];
                                          $chk=mysqli_query($con,"SELECT * FROM staff where staff_code='$ucode'");
                                           $getluser=mysqli_fetch_array($chk);
                                           if (mysqli_num_rows($chk)<1) {
                                            ?>
                                            <option disabled selected value="" style="font-size: 18px;">Select Staff</option>
                                            <?php
                                           }else{
                                            ?>
                                            <option value="<?php echo $getluser['staff_code']?>" style="font-size: 18px;"><?php echo $getluser['full_name']?></option>
                                            <?php

                                           }

                                           ?>
                                            
                                            
                                            <?php

                                      $sqlm= "SELECT * FROM staff where status=1 && suspend=1 && role>0 && branch_id='$branch'";
                                      $resultm = mysqli_query($con, $sqlm);

                                      if (mysqli_num_rows($resultm) > 0) {
                                          // output data of each row
                                          while($rowm = mysqli_fetch_assoc($resultm)) {
                                              $val=$rowm['staff_code'];
                                              $nem=$rowm['full_name'];
                                              $role=$rowm['role'];
                                              if (strlen($role)==o) {
                                                ?>
                                                 <option value="<?php echo $val; ?>"  style="font-size: 18px;"><?php echo $nem; ?> (User)</option>
                                                <?php
                                              }else{
                                              ?>
                                              <option value="<?php echo $val; ?>"  style="font-size: 18px;"><?php echo $nem; ?></option>
                                              <?php
                                            }
                                          }
                                      } else {
                                          echo "<option value='0".mysqli_error($con)."'>";
                                      }
                                      ?>


                                      </select>
                                                                                </div>

    <?php
}
?>
                           </div>            
                                       
                                        
                                        <div class="form-actions">

                                          <?php
                                                 //if($_SESSION['role']=="admin"){
                                                 if( $permissions['add_order'] == 1){ 
                                                  ?>
                                          <button id="btnadd" type="submit" class="btn btn-primary btn-large" name="add"><i class="icon-plus icon-white"></i>&nbsp; Add</button>
                                          <button type="reset" class="btn  btn-large btn-sucess">Cancel</button>
                                          <?php } ?>

                                        </div>
                                        </div>
                                      </fieldset>
                                    </form>
                                    <?php
                                        include '../includes/connection.php';

                                        if(isset($_POST['add'])){
                                            if ($business_type==1) {
                                            $saletype=$_POST['saletype'];
                                              
                                            }else{
                                            $saletype=0;
                                             
                                            }
                                            $product=$_POST['product'];
                                            $staffno=$_POST['staffno'];
                                            $quantity=$_POST['quantity'];
                                            if ($empties==1) {
                                             $quantitytaken=$_POST['quantitytaken'];
                                            }else{
                                              $quantitytaken=$quantity;
                                            }
                                            //select initial unit price
                                            $sql_select_unitprice=mysqli_query($con,"SELECT price,price_whole from products where id='$product'");
                                            if($sql_select_unitprice){
                                              $row_unitprice=mysqli_fetch_array($sql_select_unitprice);
                                              if (strlen($saletype)<1 || $saletype==0) {
                                                $unitprice=$row_unitprice['price'];
                                              }else{
                                                $unitprice=$row_unitprice['price_whole'];
                                              }
                                              
                                            }else{
                                              $unitprice=0;
                                            }
                                        $sql2 = mysqli_query($con,"INSERT INTO temp (saletype,product_id, quantity,taken, staff,branch_id,business_id,user,unit_price)
                                        VALUES ('$saletype','$product', '$quantity','$quantitytaken','$staffno','$branch','$business','$id_user','$unitprice')");

                                        if ($sql2) {
                                           ?><meta http-equiv="refresh" content="0;URL='new_order.php?staffcode=<?php echo $staffno; ?>'" /><?php
                                        } else {
                                            echo "Error: " . $sql . "<br>" . mysqli_error($conn);
                                        }

                                       
                                        }
                                        
                                        ?>

                                </div>
            </div>

<div class="row-fluid">
    
</div>

            <hr>
            <?php include '../includes/footer.php'; ?>
        </div>
        <!--/.fluid-container-->

        <script src="../vendors/jquery-1.9.1.js"></script>
        <script src="../bootstrap/js/bootstrap.min.js"></script>
        <script src="../vendors/datatables/js/jquery.dataTables.min.js"></script>


        <script src="../assets/scripts.js"></script>
        <script src="../assets/DT_bootstrap.js"></script>


        <link href="../vendors/datepicker.css" rel="stylesheet" media="screen">
        <link href="../vendors/uniform.default.css" rel="stylesheet" media="screen">
        <link href="../vendors/chosen.min.css" rel="stylesheet" media="screen">

        <link href="../vendors/wysiwyg/bootstrap-wysihtml5.css" rel="stylesheet" media="screen">

        <script src="../vendors/jquery-1.9.1.js"></script>
        <script src="../vendors/jquery.uniform.min.js"></script>
        <script src="../vendors/chosen.jquery.min.js"></script>
        <script src="../vendors/bootstrap-datepicker.js"></script>

        <script src="../vendors/wysiwyg/wysihtml5-0.3.0.js"></script>
        <script src="../vendors/wysiwyg/bootstrap-wysihtml5.js"></script>

        <script src="../vendors/wizard/jquery.bootstrap.wizard.min.js"></script>
        <script type="text/javascript" src="../vendors/jquery-validation/dist/jquery.validate.min.js"></script>
    <script src="../assets/form-validation.js"></script>
        
    <script src="../assets/scripts.js"></script>
        <script>
        $(function() {
            
        });
        </script>
        <script>

    jQuery(document).ready(function() {   
       FormValidation.init();
    });
    

        $(function() {
            $(".datepicker").datepicker();
            $(".uniform_on").uniform();
            $(".chzn-select").chosen();
            $(".chzn-select1").chosen();
            $('.textarea').wysihtml5();

            $('#rootwizard').bootstrapWizard({onTabShow: function(tab, navigation, index) {
                var $total = navigation.find('li').length;
                var $current = index+1;
                var $percent = ($current/$total) * 100;
                $('#rootwizard').find('.bar').css({width:$percent+'%'});
                // If it's the last tab then hide the last button and show the finish instead
                if($current >= $total) {
                    $('#rootwizard').find('.pager .next').hide();
                    $('#rootwizard').find('.pager .finish').show();
                    $('#rootwizard').find('.pager .finish').removeClass('disabled');
                } else {
                    $('#rootwizard').find('.pager .next').show();
                    $('#rootwizard').find('.pager .finish').hide();
                }
            }});
            $('#rootwizard .finish').click(function() {
                alert('Finished!, Starting over!');
                $('#rootwizard').find("a[href*='tab1']").trigger('click');
            });
        });
        </script>

    </body>

</html>