<?php
if(basename($_SERVER['PHP_SELF']) == 'bope.php') 
  $fn=" class='current'";
include'header.php';
include'connection.php';
$user=$loge;
$dato=$Date;
$pto=0;

if(isset($_POST['depos']))
		{
			$emplo=$_POST['emplo'];
			$amo=$_POST['amo'];
				$amo=preg_replace('/,/', '', $amo);
			$purpo=$_POST['purpo'];
				$purpo=str_replace("'", "`", $purpo);
			$part=$_POST['part'];
			$dato=$_POST['dato'];
			$payto=$_POST['payto'];
			$ope=$_POST['ope'];
			$acco=$_POST['acco'];
			$source='DEPOSIT';
				$bra=0;
				
		$do=mysqli_query($conn, "SELECT *FROM `baccount` WHERE `Number`='$acco' ORDER BY `Number` ASC");
				$ro=mysqli_fetch_assoc($do);
					$sacco=$ro['Account'];
					$sra=$ro['Rate'];

$and=mysqli_query($conn, "INSERT INTO `deposit` (`Number`, `Date`, `Time`, `User`, `Item`, `Refer`, `Amount`, `Customer`, `Operation`, `Status`, `Valid`, `Account`, `Descri`, `Client`, `Voucher`, `Source`, `Record`, `Branche`, `Bank`, `Rate`) VALUES (NULL, '$dato', '$Time', '$loge', 'DEPOSIT', 'x1', '$amo', '$payto', '$ope', '0', '0', '$acco', '$purpo', '0', '0', '$source', '0', '$bra', '$sacco', '$sra')");
		$pto=20;
		}


		if(isset($_POST['withs']))
		{
			$emplo=$_POST['emplo'];
			$amo=$_POST['amo'];
				$amo=preg_replace('/,/', '', $amo);
			$purpo=$_POST['purpo'];
				$purpo=str_replace("'", "`", $purpo);
			$part=$_POST['part'];
			$dato=$_POST['dato'];
			$payto=$_POST['payto'];
			$ope=$_POST['ope'];
			$acco=$_POST['acco'];
			$classe=$_POST['classe'];
			$reo=$_POST['reo'];
			
	$do=mysqli_query($conn, "SELECT *FROM `baccount` WHERE `Number`='$acco' ORDER BY `Number` ASC");
		$ro=mysqli_fetch_assoc($do);
			$dacco=$ro['Account'];
			$dra=$ro['Rate'];
			$currency=$ro['Currency'];

$and=mysqli_query($conn, "INSERT INTO `deposit` (`Number`, `Date`, `Time`, `User`, `Item`, `Refer`, `Amount`, `Customer`, `Operation`, `Status`, `Valid`, `Account`, `Descri`, `Client`, `Voucher`, `Source`, `Record`, `Bank`, `Rate`, `Classy`) VALUES (NULL, '$dato', '$Time', '$loge', '$part', 'x2', '$amo', '$payto', '$ope', '0', '0', '$acco', '$purpo', '0', '0', 'DIRECT', '0', '$dacco', '$dra', '$classe')");
    $last_id = mysqli_insert_id($conn);

        if($classe){
            $amo=$amo*$reo;
$cl=mysqli_query($conn, "INSERT INTO `expenses` (`Date`, `Time`, `User`, `Type`, `Purpose`, `Amount`, `Store`, `Payment`, `Payto`, `Status`, `Invoice`, `Classfy`, `Expense`, `Service`, `External`) VALUES ('$dato', '$Time', '$loge', 'PAYMENT', '$purpo', '$amo', 'REMERA', 'BANK', '$payto', '0', '$last_id', 'EXPENSE', '$classe', '$last_id', '1')");
}

if($part=='SUPPLIER PAYMENT'){
    $sup=$_POST['sup'];
    
    $dee=mysqli_query($conn, "SELECT `Number` FROM `services` WHERE `Paid`<`Amount` AND `Supplier` = '$sup' ORDER BY `Number` ASC LIMIT 1");
	        $ree=mysqli_fetch_assoc($dee);
	            $naso=$ree['Number'];
$so=mysqli_query($conn, "INSERT INTO `payment` (`Date`, `Time`, `User`, `Amount`, `Pline`, `Invoice`, `Status`, `Customer`, `Action`, `Descri`, `Destin`, `Cheno`, `Bname`, `Pdate`, `Container`, `Currency`, `Rate`, `Files`, `Linked`) VALUES ('$dato', '$Time', '$loge', '$amo', 'DEPOSIT', '$naso', '0', '$sup', 'SUPPLIER', '', '', '$cheno', '$dacco', '$dato', '', '$currency', '$dra', '', '$last_id')");
}
		$pto=10;
		}
		
		if(isset($_POST['transfer']))
		{
			$source=$_POST['source'];
			$amo=preg_replace('/,/', '', $_POST['amount']);
			$descri=str_replace("'", "`", $_POST['descri']);
			$destin=$_POST['destin'];
			$dato=$_POST['dato'];
			$reo=$_POST['reo'];
			if($destin==$source)
			    $pto=30;
			else{
        $doi=mysqli_query($conn, "SELECT *FROM `baccount` WHERE `Number`='$source' ORDER BY `Number` ASC");
				$roi=mysqli_fetch_assoc($doi);
					$fna=$roi['Bank'];
					$sacco=$roi['Account'];
					$sra=$roi['Rate'];

$andi=mysqli_query($conn, "INSERT INTO `deposit` (`Number`, `Date`, `Time`, `User`, `Item`, `Refer`, `Amount`, `Customer`, `Operation`, `Status`, `Valid`, `Account`, `Descri`, `Client`, `Voucher`, `Source`, `Record`, `Bank`, `Rate`) VALUES (NULL, '$dato', '$Time', '$loge', 'TRANSFER', 'x2', '$amo', 'Auto transfer', 'WITHDRAWAL', '0', '0', '$source', '$descri', '0', '0', '$fna', '$destin', '$sacco', '$sra')");

        $do=mysqli_query($conn, "SELECT *FROM `baccount` WHERE `Number`='$destin' ORDER BY `Number` ASC");
				$ro=mysqli_fetch_assoc($do);
					$fna=$ro['Bank'];
					$dacco=$ro['Account'];
					$dra=$ro['Rate'];
					if($sra==$dra)
					    $dra=1;
					$amo=$amo/$dra;

$and=mysqli_query($conn, "INSERT INTO `deposit` (`Number`, `Date`, `Time`, `User`, `Item`, `Refer`, `Amount`, `Customer`, `Operation`, `Status`, `Valid`, `Account`, `Descri`, `Client`, `Voucher`, `Source`, `Record`, `Bank`, `Rate`) VALUES (NULL, '$dato', '$Time', '$loge', 'DEPOSIT', 'x1', '$amo', 'Auto transfer', 'DEPOSIT', '0', '0', '$destin', '$descri', '0', '0', '$fna', '$source', '$dacco', '$dra')");
			  
			  $pto=40;  
			}
		}
		
		
		// Upload cashbox to finance
		if(isset($_POST['upload']))
		{
			$dato=$_POST['dato'];
			$dano=str_replace('-', '', $dato);	
			
			
			// ******************* Transport cashing ****************
			        $cash=0;
	$setaca=mysqli_query($conn, "SELECT SUM(`Amount`*`Rate`) AS `Cash` FROM `payment` WHERE `Date`='$dato' AND `Pline`='CASH' AND `Status`='0' AND `Action`='TRANSPORT' AND `Bname`=''");
	if($fetaca=mysqli_num_rows($setaca)){
		$reca=mysqli_fetch_assoc($setaca);
		    $cash=$reca['Cash'];
		    $bran="TRANSPORT";
            $desc="CASH TRANSPORT";
        
    $so=mysqli_query($conn, "SELECT `Number` FROM `deposit` WHERE `Date`='$dato' AND `Item`='DEPOSIT' AND `Descri`='$desc' AND `Operation`='DEPOSIT' AND `Account`='30' AND `Source`='$bran' AND `Voucher`='$dano' ORDER BY `Number` ASC LIMIT 1");
    if($fo=mysqli_num_rows($so))
    $sso=mysqli_query($conn, "UPDATE `deposit` SET `Amount` = '$cash' WHERE `Date`='$dato' AND `Item`='DEPOSIT' AND `Descri`='$desc' AND `Operation`='DEPOSIT' AND `Account`='30' AND `Source`='$bran' AND `Voucher`='$dano' ORDER BY `Number` ASC LIMIT 1");
    else{
        $do=mysqli_query($conn, "SELECT *FROM `baccount` WHERE `Number`='30' ORDER BY `Number` ASC");
				$ro=mysqli_fetch_assoc($do);
					$bank=$ro['Account'];
					$rat=$ro['Rate'];
    $sso=mysqli_query($conn, "INSERT INTO `deposit` (`Number`, `Date`, `Time`, `User`, `Item`, `Refer`, `Amount`, `Customer`, `Operation`, `Status`, `Valid`, `Account`, `Descri`, `Client`, `Voucher`, `Source`, `Record`, `Branche`, `Bank`, `Rate`) VALUES (NULL, '$dato', '$Time', 'SYSTEM', 'DEPOSIT', 'x1', '$cash', 'From sales', 'DEPOSIT', '0', '0', '30', '$desc', '0', '$dano', '$bran', '0', '', '$bank', '$rat')");
            }
	    }
		
			
	$cuse=mysqli_query($conn, "SELECT `Branch`, `Link_file` FROM `datatable` WHERE `Link_file`!='' ORDER BY `Number` ASC");
	    if($fuse=mysqli_num_rows($cuse)){
			while($ruce=mysqli_fetch_assoc($cuse)){
				$dbname=$ruce['Link_file'];
				$bran=$ruce['Branch'];
                $conx = mysqli_connect("$serv", "$log", "$pass", "$dbname");
	// ************************* Sales cashing ******************************
             $cash=0;
    $sales=mysqli_query($conx, "SELECT SUM(`Cash`) AS 'Pay' FROM `payment` WHERE `Date`='$dato' AND `Delo`='0' AND `Invoice`!='0'");
            $rales=mysqli_fetch_assoc($sales);
                $cash+=$rales['Pay'];
                
    $payment=mysqli_query($conx, "SELECT SUM(`Amount`) AS 'Paid' FROM `payaco` WHERE `Date`='$dato' AND `Pline`='CASH' AND `Account`!='0'");
            $rala=mysqli_fetch_assoc($payment);
                $cash+=$rala['Paid'];
                
    $advance=mysqli_query($conx, "SELECT SUM(`Amount`) AS 'Adva' FROM `adrecord` WHERE `Date`='$dato' AND `Pline`='CASH' AND `Customer`!='0'");
            $rava=mysqli_fetch_assoc($advance);
                $cash+=$rava['Adva']; 
                
    $expense=mysqli_query($conx, "SELECT SUM(`Amount`) AS 'Expe' FROM `cashbox` WHERE `Date`='$dato' AND `Chamo`='0' AND `Momo`='0'");
            $raxe=mysqli_fetch_assoc($expense);
                $cash+=$raxe['Expe'];  
                
    $adused=mysqli_query($conx, "SELECT SUM(`Amount`) AS 'Aduse' FROM `aduse` WHERE `Date`='$dato' AND `Invoice`!='0' AND `Customer`!='0'");
            $race=mysqli_fetch_assoc($adused);
                $cash-=$race['Aduse']; 
          
                $desc="CASH SALES";
        
    $so=mysqli_query($conn, "SELECT `Number` FROM `deposit` WHERE `Date`='$dato' AND `Item`='DEPOSIT' AND `Descri`='$desc' AND `Operation`='DEPOSIT' AND `Account`='30' AND `Source`='$bran' AND `Voucher`='$dano' ORDER BY `Number` ASC LIMIT 1");
    if($fo=mysqli_num_rows($so))
    $sso=mysqli_query($conn, "UPDATE `deposit` SET `Amount` = '$cash' WHERE `Date`='$dato' AND `Item`='DEPOSIT' AND `Descri`='$desc' AND `Operation`='DEPOSIT' AND `Account`='30' AND `Source`='$bran' AND `Voucher`='$dano' ORDER BY `Number` ASC LIMIT 1");
    else{
        $do=mysqli_query($conn, "SELECT *FROM `baccount` WHERE `Number`='30' ORDER BY `Number` ASC");
				$ro=mysqli_fetch_assoc($do);
					$dacco=$ro['Account'];
					$dra=$ro['Rate'];
    $sso=mysqli_query($conn, "INSERT INTO `deposit` (`Number`, `Date`, `Time`, `User`, `Item`, `Refer`, `Amount`, `Customer`, `Operation`, `Status`, `Valid`, `Account`, `Descri`, `Client`, `Voucher`, `Source`, `Record`, `Branche`, `Bank`, `Rate`) VALUES (NULL, '$dato', '$Time', 'SYSTEM', 'DEPOSIT', 'x1', '$cash', 'From sales', 'DEPOSIT', '0', '0', '30', '$desc', '0', '$dano', '$bran', '0', '0', '$dacco', '$dra')");
    }
                }
            }
		}
		

		// Delete a given particular
if(isset($_POST['editobon']))
		{
			$num=$_POST['num'];
				$soso=mysqli_query($conn, "DELETE FROM `parts` WHERE `Number`='$num' ORDER BY `Number` ASC LIMIT 1");
		}

		// Create a new particular
if(isset($_POST['eddobon']))
		{
			$namei=$_POST['namei'];
	$so=mysqli_query($conn, "INSERT INTO `parts` (`Parts`) VALUES ('$namei')");
		}
?>


<div class="container-fluid main-content">
        <div class="page-title hidden-print">
          <h2 style='margin-top:-20px; margin-bottom: 5px; color:#ffcc33'>
        Bank Operations
          </h2>
                 </div>
     
         <div class="row">
  <div class="col-lg-2 hidden-print">
   
   <ul class="list-group">
      
    <li class="list-group-item active">
	  <a href="bope.php">
                <p>
                <i class="lnr lnr-briefcase"></i>&nbsp;Bank Operation
                </p>
              </a></li>   

    <li class="list-group-item">
	  <a href="deposit.php">
                <p>
                <i class="lnr lnr-menu-circle"></i>&nbsp;Bank Slip Record
                </p>
              </a></li>  

	 <li class="list-group-item">
	  <a href="deporepo.php">
                <p>
                <i class="lnr lnr-menu-circle"></i>&nbsp;Deposit Report
                </p>
              </a></li>
      
    <li class="list-group-item">
	  <a href="withrepo.php">
                <p>
                <i class="lnr lnr-menu-circle"></i>&nbsp;Withdrwal Report
                </p>
              </a></li> 
      
    <li class="list-group-item">
	  <a href="staterepo.php">
                <p>
                <i class="lnr lnr-menu-circle"></i>&nbsp;Statement Report
                </p>
              </a></li> 
                         
            </ul><br><br>
     
            <ul class="list-group">
     <?php
     if($_SESSION['Cbt']){
         ?>
   <li class="list-group-item" style="border:1px dashed #00ccee; border-radius:5px; margin:0px 0px 4px 0px;">
	  <a href="#" style="color:#00ccee; padding-left:30px;" data-toggle="modal" data-target="#modal-x3123">
                <p> 
                <i class="lnr lnr-laptop-phone"></i>&nbsp;&nbsp;Bank Transfer
                </p>
              </a></li>
      <?php
     }
     if($_SESSION['Ucs']==10){
         ?>
   <li class="list-group-item" style="border:1px dashed #E09B1A; border-radius:5px; margin:0px 0px 4px 0px;">
	  <a href="#" style="color:#E09B1A; padding-left:30px;" data-toggle="modal" data-target="#modal-x31238">
                <p> 
                <i class="lnr lnr-upload"></i>&nbsp;&nbsp;Upload Cashbox
                </p>
              </a></li>
              <?php
     }
     ?>
			  
			  </ul>	  
			 
  </div>
  
  <?php
  
  // ******************** Bank transfer *****************************
  	echo"<div id='modal-x3123' class='modal fade' role='dialog'>
  <div class='modal-dialog' role='document'>
    <div class='modal-content'>
      <div class='modal-header'><form method='post' action=''>
        <h5 class='modal-title' id='exampleModalLabel'> BANK TRANSFER </h5>
		<button type='submit' name='load' class='btn btn-xs btn-default' style='float:right; margin-top:-20px; width:80px;' data-toggle='tooltip' data-placement='top' data-dismiss='modal'>CLOSE</button></div>
      <div class='modal-body' style='height:290px;'>
      
       <br><label class='control-label col-md-4 text-right'> Due Date </label>
	<label class='control-label col-md-6'>
	<div class='input-group date' data-provide='datepicker'><input type='text' class='form-control text-center' name='dato' onkeypress='return isNumberKey(event)' onkeyup='format(this);' value='$Date' required><span class='input-group-addon'><i class='lnr lnr-calendar-full'></i></span>
			</div></label<label class='control-label col-md-2'> </label>
	
	
	<label class='control-label col-md-4 text-right'> From Account </label>
	<label class='control-label col-md-6'><select class='form-control' name='source' required>			
	<option value='' selected='selected'> Select Source  </option>";
			
	$doi=mysqli_query($conn, "SELECT *FROM `baccount` WHERE `Status`='0'  ORDER BY `Number` ASC");
			while($roi=mysqli_fetch_assoc($doi)){
				$nuo=$roi['Number'];
				$fna=$roi['Account'];
				$bna=$roi['Bank'];
	echo"<option value='$nuo'> $fna / $bna </option>";
			}
		
		echo"</select></label><label class='control-label col-md-2'> </label>
		
		<label class='control-label col-md-4 text-right'> To Account </label>
	<label class='control-label col-md-6'><select class='form-control' name='destin' required>			
	<option value='' selected='selected'> Select Destination  </option>";
			
	$dois=mysqli_query($conn, "SELECT *FROM `baccount` WHERE `Status`='0'  ORDER BY `Number` ASC");
			while($rois=mysqli_fetch_assoc($dois)){
				$nuos=$rois['Number'];
				$fnas=$rois['Account'];
				$bnas=$rois['Bank'];
	echo"<option value='$nuos'> $fnas / $bnas </option>";
			}
		        $raso=number_format($rase);      
		echo"</select></label<label class='control-label col-md-2'> </label>
		
			<label class='control-label col-md-4 text-right'> Total Amount </label>
	<label class='control-label col-md-6'><div class='input-group'>
	<input type='text' class='form-control text-center' name='amount' onkeypress='return isNumberKey(event)' onkeyup='format(this);' required><span class='input-group-addon' style='width:40%; padding:0px; height:33px; border:0px;'><select class='form-control' name='reo' style='text-align:center; font-size:16px; height:34px; border-radius:0px 5px 5px 0px;' required><option value='1' style='text-align:center; font-size:16px;' selected> 1  </option>
	<option value='$rase' style='text-align:center; font-size:16px;'> $raso </option></select></span></div>
	</label><label class='control-label col-md-2'> </label>
	
	<label class='control-label col-md-4 text-right'> Description </label>
	<label class='control-label col-md-6'><textarea class='form-control' name='descri'></textarea></label<label class='control-label col-md-2'> </label>
       
      </div>
      <div class='modal-header' style='height:50px; margin-top:-10px; padding-top:10px; border:0px solid blue;'>
      
	<label class='control-label col-md-5'> </label>
	<label class='control-label col-md-3'>
        <button type='button' class='btn btn-sm btn-warning btn-block' data-dismiss='modal'> CANCEL </button></label>
        
	<label class='control-label col-md-3'>
        <button type='submit' name='transfer' class='btn btn-sm btn-success btn-block'> TRANSFER </button></label>
      </div></form>
    </div></div>
</div>";


// **************************** Upload cashbox *****************************

  	echo"<div id='modal-x31238' class='modal fade' role='dialog'>
  <div class='modal-dialog' role='document'>
    <div class='modal-content'>
      <div class='modal-header'><form method='post' action=''>
        <h5 class='modal-title' id='exampleModalLabel'> UPLOAD CASHBOX </h5>
		<button type='submit' name='load' class='btn btn-xs btn-default' style='float:right; margin-top:-20px; width:80px;' data-toggle='tooltip' data-placement='top' data-dismiss='modal'>CLOSE</button></div>
      <div class='modal-body' style='height:120px;'>
      
       <br><label class='control-label col-md-4 text-right' style='padding-top:5px;'> Due Date </label>
	<label class='control-label col-md-6'>
	<div class='input-group date' data-provide='datepicker'><input type='text' class='form-control text-center' name='dato' onkeypress='return isNumberKey(event)' onkeyup='format(this);' value='$Date' required><span class='input-group-addon'><i class='lnr lnr-calendar-full'></i></span>
			</div></label<label class='control-label col-md-2'> </label>
       
      </div>
      <div class='modal-header' style='height:50px; margin-top:-10px; padding-top:10px; border:0px solid blue;'>
      
	<label class='control-label col-md-5'> </label>
	<label class='control-label col-md-3'>
        <button type='button' class='btn btn-sm btn-warning btn-block' data-dismiss='modal'> CANCEL </button></label>
        
	<label class='control-label col-md-3'>
        <button type='submit' name='upload' class='btn btn-sm btn-success btn-block'> UPLOAD </button></label>
      </div></form>
    </div></div>
</div>";
?>
 <div class="col-md-10">
 <div class="widget-container fluid-height clearfix" style='margin-top:-40px;'>
 <div class="widget-content padded">
 <form method="post" class="form-horizontal" action="" enctype="multipart/form-data">
 <input name="app_file_size" id="app_file_size" type="hidden">
 <br>
 <?php 
 $amos=number_format($amo);
if($pto==10)
echo"<center><div class='alert alert-success' style='width:80%;text-align:center;float:center;margin-top:-20px;color: #ffffff;border-radius:5px;'>
		<i class='lnr lnr-checkmark-circle'></i> &nbsp;&nbsp; <button class='close' data-dismiss='alert' type='button'>&times;</button> Withdrawal operation is saved successfull.
		</div></center>";
if($pto==20)
echo"<center><div class='alert alert-success' style='width:80%;text-align:center;float:center;margin-top:-20px;color: #ffffff;border-radius:5px;'>
		<i class='lnr lnr-checkmark-circle'></i> &nbsp;&nbsp; <button class='close' data-dismiss='alert' type='button'>&times;</button> Deposit operation is saved successfull.
		</div></center>";
if($pto==30)
echo"<center><div class='alert alert-danger' style='width:80%; text-align:center; float:center; color: #ffffff; border-radius:5px; margin-top:-20px;'>
		<i class='lnr lnr-checkmark-circle'></i> &nbsp;&nbsp; <button class='close' data-dismiss='alert' type='button'>&times;</button> Operation not done, you have selected same account.
		</div></center>";
if($pto==40)
echo"<center><div class='alert alert-success' style='width:80%;text-align:center;float:center;margin-top:-20px;color: #ffffff;border-radius:5px;'>
		<i class='lnr lnr-checkmark-circle'></i> &nbsp;&nbsp; <button class='close' data-dismiss='alert' type='button'>&times;</button> Transfer operation for $amos is saved successfull.
		</div></center>";
	
			echo"<input value='$code' name='rowid' type='hidden'>";
			?>
			<div class="form-group">
            <label class="control-label col-md-3">Operation Type</label>
            <div class="col-md-6">
    <select class="form-control" name="ope" onchange="showDiv(this.value);" required><option value='' selected='selected'>Select Operation</option>			
	<OPTION VALUE="WITHDRAWAL">WITHDRAWAL</OPTION>
		<OPTION VALUE="DEPOSIT">DEPOSIT</OPTION>
</SELECT>
            </div>
			<span style="color:#d43f3a">
                         *
                      </span>  
 </div>
  <div class="form-group">
            <label class="control-label col-md-3">Total Amount</label>
            <div class="col-md-6">
              <input name="amo" class="form-control" type="text" onkeypress='return isNumberKey(event)' onkeyup='format(this);' required>
            </div>
			  <span style="color:#d43f3a">
                         *
                      </span>  
 </div>
 <div class="form-group">
   <label class="control-label col-md-3">Description</label>
                  <div class="col-md-6">
              <input class="form-control" name="purpo" type="text">
            </div> 
			  <span style="color:#d43f3a">
                         *
                      </span>  
			</div>

 <div class="form-group">
   <label class="control-label col-md-3">Done&nbsp;By&nbsp;&nbsp;</label>
                  <div class="col-md-6">
              <input class="form-control" name="payto" type="text" id="searcho" OnKeyup="return cUpper(this);">
            </div> 
			  <span style="color:#d43f3a">
                         *
                      </span>  
			</div>

	<div class="form-group">
   <label class="control-label col-md-3">Account</label>
                  <div class="col-md-6">
             <select class="form-control" name="acco" required>
				<option value='' selected='selected'>SELECT ACCOUNT</option>
			<?php
			$doi=mysqli_query($conn, "SELECT *FROM `baccount` ORDER BY `Number` ASC");
			while($roi=mysqli_fetch_assoc($doi)){
				$nu=$roi['Number'];
				$fna=$roi['Bank'];
				$acco=$roi['Account'];
			echo"<option value='$nu' title='$fna $acco'> $fna $acco </option>";
			}
			?>   
                            </select>
            </div> 
			  <span style="color:#d43f3a">
                         *
                      </span>  
			</div>

  <div class="form-group">
            <label class="control-label col-md-3"><br>&nbsp;</label>
            <div class="col-md-2" style='margin-right:30px;'>
              <br><input name="user" class="form-control" value="<?php echo $user ?>" type="text" style='width:210px;' readonly> &nbsp;&nbsp; 
			 </div> 

			  <label class="control-label col-md-1"><br>Date</label>
			<div class="col-md-5"><br>
			  <input name="dato" id="from" class="form-control" value="<?php echo $dato ?>" type="text" style='width:210px; text-align:center;' required>
            </div> 
 </div>

 <div class="form-group">
  <label class="control-label col-md-2"> </label>
    <label class="control-label col-md-3">Document File</label>
                     <div class="col-md-1">
              <div class="fileupload fileupload-new" data-provides="fileupload"><input value="<?php echo $rowid ?>" name="rowid" type="hidden">
                <span class="btn btn-default btn-file"><span class="fileupload-new">Select</span><span class="fileupload-exists">Change</span><input name="file1" id="app_file" type="file" readonly='readonly'></span><span class="fileupload-preview"></span><button class="close fileupload-exists" data-dismiss="fileupload" style="float:none" type="button">×</button>
		<?php echo $dfile ?>
				
                     
              </div></div>
			  
			  &nbsp;&nbsp;&nbsp;&nbsp;<small>Zip, txt, jpeg, png, pdf, doc (Max : 2M)</small>
            
            </div>

  <div class="form-group">
  <div class="col-md-12">
  
		<div class="col-sm-1"> </div>
		 <div class="col-sm-9" align='center' style='border:0px solid black;'>
		 
		 <div id='DEPOSIT' class='hiddenDiv' style='border:0px;'>
		 <?php
		 if($_SESSION['Xacco']!='1'){
			 ?>
			
			<div class="col-sm-1"> </div><br>
		 <button class="btn btn-lg btn-block btn-info" type="submit" name="depos"><i class="lnr lnr-exit-up"></i>&nbsp;&nbsp;BANK DEPOSIT </button> 
		 <?php
		}
		?></div>

			 <div id='WITHDRAWAL' class='hiddenDiv' style='border:0px;'>
		 <?php
		 if($_SESSION['Xacco']!='1'){
			 ?>
		
  <div class="col-sm-1">  </div><div class="col-sm-4">
  <div class='input-group'><select class="form-control" name="part" onchange="showDive(this.value);"><option value='' selected='selected'> SELECT PARTICULAR </option>
			<?php
	$doi=mysqli_query($conn, "SELECT *FROM `parts` ORDER BY `Number` ASC");
			while($roi=mysqli_fetch_assoc($doi)){
				$nu=$roi['Number'];
				$fna=$roi['Parts'];
			echo"<option value='$fna' title='$fna'> $fna </option>";
			}
			?>   
         </select><span class='input-group-addon'><a href='#' data-placement='top' data-toggle='modal' data-target='#modal-x1123'>
		 <i class="lnr lnr-sync"></i></a></span>
	
	</div></div>
	
<div class='col-sm-4' style='padding-left:40px;'>
<select class='form-control' name='classe' style='font-size:16px; height:34px;'>
<option value="" style="color:blue;"> Classification </option><?php

    $doi=mysqli_query($conn, "SELECT `Type` FROM `expetype` GROUP BY `Type` ORDER BY `Number` ASC");
			while($roi=mysqli_fetch_assoc($doi)){
				$fna=$roi['Type'];
	    echo"<option value='' style='color:red;'> --- $fna --- </option>";
	    
	$doe=mysqli_query($conn, "SELECT `Expense` FROM `expetype` WHERE `Type`='$fna' GROUP BY `Expense` ORDER BY `Expense` ASC");
			while($roe=mysqli_fetch_assoc($doe)){
				$expe=$roe['Expense'];
	    echo"<option value='$expe'> $expe </option>";
			}
			}
			
			
        ?></select>
            </div><div class="col-sm-2">
        <select class='form-control' name='reo' required>
                <?php
    echo"<option value='1' style='text-align:center; font-size:16px;' selected> 1  </option>
	<option value='$rase' style='text-align:center; font-size:16px;'> $raso </option>";
	?></select></div><br><div class='row'> </div>
	<div id='SUPPLIER PAYMENT' class='hiddenDive' style='border:0px;'>
	  <div class="col-sm-5"> </div><div class="col-sm-6" style='padding-left:40px;'><br><select class='form-control' name='sup'>
	      <option value=''> SELECT A SUPPLIER </option>
	      <?php 
	 $dee=mysqli_query($conn, "SELECT *FROM `services` WHERE `Paid`<`Amount` GROUP BY `Supplier` ORDER BY `Supplier` ASC");
	        while($ree=mysqli_fetch_assoc($dee)){
	            $sup=$ree['Supplier'];
	            $nuo=$ree['Number'];
	  echo"<option value='$sup'> $sup </option>";
	        }
	 ?></select><br><br></div>  
	    </div><br><br>

<button class="btn btn-lg btn-block btn-info" type="submit" name="withs">
		 <i class="lnr lnr-enter-down"></i>&nbsp;&nbsp;WITHDRAWAL </button> </div>
   </div>
      
 </div></div></form>
		 <?php
		}
 else{
			 ?></div>
   </div>
      
 </div></div></form>
 <?php
 }







 // ********************************************* Create particulars **************************************************************
	echo"<div id='modal-x1123' class='modal fade' role='dialog'>
  <div class='modal-dialog' role='document'>
    <div class='modal-content'>
      <div class='modal-header'>
        <h5 class='modal-title' id='exampleModalLabel'> CREATE A NEW PARTICULAR
				&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
					 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </h5>

      </div>
      <div class='modal-body' style='height:440px; overflow-y:auto;'>
	  <table class='table table-striped table-hover' style='margin-top:-15px;'>";
			$stl="padding:0px 2px; 0px 2px";
			$clr="";	  

		print("<tr><form method='post' action=''><td class='hidden-xs' style='$stl $clr'>
		<div align='center'>&nbsp;&nbsp;&nbsp;&nbsp;1&nbsp;&nbsp;</td>

						<td style='$stl $clr'><div align='left'>
						<input name='namei' class='form-control' type='text' style='text-align:left; width:320px; height:24px; margin:0px 0px 0px 0px; padding:0px 10px 0px 10px; background-color:transparent;' OnKeyup='return cUpper(this);' onChange=this.style.color='#ff3366'></td>

				<td style='$stl $clr'><div align='center'><button type='submit' class='btn btn-xs btn-success hidden-print' name='eddobon' style='height:22px; margin:0px 0px 0px 0px; padding:0px;' title='Add New' data-toggle='tooltip' data-placement='top'>&nbsp;&nbsp;<i class='lnr lnr-plus-circle'></i>&nbsp;&nbsp;</button></td></form></tr>");

				$i=2;
	  $dob=mysqli_query($conn, "SELECT *FROM `parts` ORDER BY `Parts` ASC");
		while($rob=mysqli_fetch_assoc($dob)){
			$num=$rob['Number'];
			$acco=$rob['Parts'];

			print("<tr style='height:10px;'><form method='post' action=''>
			<td class='hidden-xs' style='$stl $clr'><div align='center'>&nbsp;&nbsp;&nbsp;&nbsp;$i&nbsp;&nbsp;</td>

						<td style='$stl $clr'><div align='left'><input type='hidden' name='num' value='$num'>
						<input name='name' class='form-control' type='text' style='text-align:left; width:320px; height:24px; margin:0px 0px 0px 0px; padding:0px 10px 0px 10px; background-color:transparent;' OnKeyup='return cUpper(this);' value='$acco' onChange=this.style.color='#ff3366'></td>

						<td style='$stl $clr'><div align='center'><button type='submit' class='btn btn-xs btn-danger hidden-print' name='editobon' style='height:22px; margin:0px 0px 0px 0px; padding:0px;' title='Edit' data-toggle='tooltip' data-placement='top'>&nbsp;&nbsp;<i class='lnr lnr-trash'></i>&nbsp;&nbsp;</button></td></form></tr>");

						$i++;
		}

			echo"</table></div><div class='modal-header text-right' style='margin-top:-10px; height:50px; padding-top:15px; border:0px solid blue;'>
       
        <button type='button' class='btn btn-sm btn-warning' data-dismiss='modal' style='height:30px; padding-top:0px; width:120px;'>CLOSE</button>
      </div>
    </div>
  </div>
</div>";

// *************************************************** End of Modal ************************************************************
 ?>
 
 </form>
 </div>
 </div>
 </div>
 </div> 
</div>  
   <?php
   include'footer.php';
   ?>