<?php
/* $Id: index.php 6941 2014-10-26 23:18:08Z daintree $*/
error_reporting(E_ALL & ~E_NOTICE);

			
	   $servername = "localhost";
$username = "sooggoo";
$password = "4Compassion*";
$dbname = "evergreenint";

// Create connection
$connect = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($connect->connect_error) {
    die("Connection failed: " . $connect->connect_error);
} 


   $SQL= "SELECT  transno,sales_gl,department
											
											
		                            FROM debtortrans
									WHERE gl_status = 0
									";

$result=mysqli_query($connect,$connect,$SQL);
while ($myrow=mysqli_fetch_array($result)){

	//fire contract fiji wide
	if ($myrow['sales_gl'] == '7100500'){
		
		
		$SQLupdate = "UPDATE debtortrans set old_sales_code = '103',
                                        	old_gl_code = 'G610',
											gl_status = '1'
										WHERE transno = '" . $myrow['transno'] ."' ";

$resultupdate=mysqli_query($connect,$SQLupdate);
		
		
		
	}
	//7102400 Security Guard Contract Income

		   if ($myrow['sales_gl'] == '7102400'){
		
		
		$SQLupdate = "UPDATE debtortrans set old_sales_code = '602',
                                        	old_gl_code = 'G70021',
											gl_status = '1'
										WHERE transno = '" . $myrow['transno'] ."' 
										AND department = 2";

$resultupdate=mysqli_query($connect,$SQLupdate);
		
	}
	   if ($myrow['sales_gl'] == '7102400'){
		
		
		$SQLupdate = "UPDATE debtortrans set old_sales_code = '601',
                                        	old_gl_code = 'G70011',
											gl_status = '1'
										WHERE transno = '" . $myrow['transno'] ."' 
										AND department = 1";

$resultupdate=mysqli_query($connect,$SQLupdate);
		
	}
	
	//security mobile income
			   if ($myrow['sales_gl'] == '7102401'){
		
		
		$SQLupdate = "UPDATE debtortrans set old_sales_code = '604',
                                        	old_gl_code = 'G70022',
											gl_status = '1'
										WHERE transno = '" . $myrow['transno'] ."' 
										AND department = 2";

$resultupdate=mysqli_query($connect,$SQLupdate);
		
	}
	   if ($myrow['sales_gl'] == '7102401'){
		
		
		$SQLupdate = "UPDATE debtortrans set old_sales_code = '603',
                                        	old_gl_code = 'G70012',
											gl_status = '1'
										WHERE transno = '" . $myrow['transno'] ."' 
										AND department = 1";

$resultupdate=mysqli_query($connect,$SQLupdate);
		
	}
	  if ($myrow['sales_gl'] == '7102401'){
		
		
		$SQLupdate = "UPDATE debtortrans set old_sales_code = '609',
                                        	old_gl_code = 'G70031',
											gl_status = '1'
										WHERE transno = '" . $myrow['transno'] ."' 
										AND department = 3";

$resultupdate=mysqli_query($connect,$SQLupdate);
		
	}
	
		   if ($myrow['sales_gl'] == '7102400'){
		
		
		$SQLupdate = "UPDATE debtortrans set old_sales_code = '609',
                                        	old_gl_code = 'G70031',
											gl_status = '1'
										WHERE transno = '" . $myrow['transno'] ."' 
										AND department = 3";

$resultupdate=mysqli_query($connect,$SQLupdate);
		
	}
	
	
//Fire Equipment contract
	 if ($myrow['sales_gl'] == '7102301'){
		
		
		$SQLupdate = "UPDATE debtortrans set old_sales_code = '104',
                                        	old_gl_code = 'G610',
											gl_status = '1'
										WHERE transno = '" . $myrow['transno'] ."' ";

$resultupdate=mysqli_query($connect,$SQLupdate);
		
	}
	
	//Fire sprinkler contract
	
	 if ($myrow['sales_gl'] == '7102300'){
		
		
		$SQLupdate = "UPDATE debtortrans set old_sales_code = '107',
                                        	old_gl_code = 'G610',
											gl_status = '1'
										WHERE transno = '" . $myrow['transno'] ."' ";

$resultupdate=mysqli_query($connect,$SQLupdate);
		
	}

	//Fire Prepaid suva
	
	 if ($myrow['sales_gl'] == '7101005'){
		
		
		$SQLupdate = "UPDATE debtortrans set old_sales_code = '111',
                                        	old_gl_code = 'G61101',
											gl_status = '1'
										WHERE transno = '" . $myrow['transno'] ."' ";

$resultupdate=mysqli_query($connect,$SQLupdate);
		
	}
	
	
	//FE Sales
	 if ($myrow['sales_gl'] == '7100900'){
		
		
		$SQLupdate = "UPDATE debtortrans set old_sales_code = '202',
                                        	old_gl_code = 'W7020102',
											gl_status = '1'
										WHERE transno = '" . $myrow['transno'] ."' 
										AND department = 6";

$resultupdate=mysqli_query($connect,$SQLupdate);
		
	}
	 if ($myrow['sales_gl'] == '7100900'){
		
		
		$SQLupdate = "UPDATE debtortrans set old_sales_code = '302',
                                        	old_gl_code = 'W7020202',
											gl_status = '1'
										WHERE transno = '" . $myrow['transno'] ."' 
										AND department = 7";

$resultupdate=mysqli_query($connect,$SQLupdate);
		
	}
   if ($myrow['sales_gl'] == '7100900'){
		
		
		$SQLupdate = "UPDATE debtortrans set old_sales_code = '402',
                                        	old_gl_code = 'W7020302',
											gl_status = '1'
										WHERE transno = '" . $myrow['transno'] ."' 
										AND department = 8";

$resultupdate=mysqli_query($connect,$SQLupdate);
		
	}
	
	// FE servicing
	   if ($myrow['sales_gl'] == '7101003'){
		
		
		$SQLupdate = "UPDATE debtortrans set old_sales_code = '210',
                                        	old_gl_code = 'W7020106',
											gl_status = '1'
										WHERE transno = '" . $myrow['transno'] ."' 
										AND department = 6";

$resultupdate=mysqli_query($connect,$SQLupdate);
		
	}
	   if ($myrow['sales_gl'] == '7101003'){
		
		
		$SQLupdate = "UPDATE debtortrans set old_sales_code = '310',
                                        	old_gl_code = 'W7020206',
											gl_status = '1'
										WHERE transno = '" . $myrow['transno'] ."' 
										AND department = 7";

$resultupdate=mysqli_query($connect,$SQLupdate);
		
	}
		  if ($myrow['sales_gl'] == '7101003'){
		
		
		$SQLupdate = "UPDATE debtortrans set old_sales_code = '410',
                                        	old_gl_code = 'W7020306',
											gl_status = '1'
										WHERE transno = '" . $myrow['transno'] ."' 
										AND department = 8";

$resultupdate=mysqli_query($connect,$SQLupdate);
		
	}
	
	//fire alarm small jobs
	
	  if ($myrow['sales_gl'] == '7100600'){
		
		
		$SQLupdate = "UPDATE debtortrans set old_sales_code = '207',
                                        	old_gl_code = 'W7060103',
											gl_status = '1'
										WHERE transno = '" . $myrow['transno'] ."' 
										AND department = 6";

$resultupdate=mysqli_query($connect,$SQLupdate);
		
	}
	   if ($myrow['sales_gl'] == '7100600'){
		
		
		$SQLupdate = "UPDATE debtortrans set old_sales_code = '307',
                                        	old_gl_code = 'W7060203',
											gl_status = '1'
										WHERE transno = '" . $myrow['transno'] ."' 
										AND department = 7";

$resultupdate=mysqli_query($connect,$SQLupdate);
		
	}
		//7102200 Fire Sprinkler Small Jobs
	   if ($myrow['sales_gl'] == '7102200'){
		
		
		$SQLupdate = "UPDATE debtortrans set old_sales_code = '212',
                                        	old_gl_code = 'W7060107',
											gl_status = '1'
										WHERE transno = '" . $myrow['transno'] ."' 
										AND department = 6";

$resultupdate=mysqli_query($connect,$SQLupdate);
		
	}
	   if ($myrow['sales_gl'] == '7102200'){
		
		
		$SQLupdate = "UPDATE debtortrans set old_sales_code = '312',
                                        	old_gl_code = 'W7060207',
											gl_status = '1'
										WHERE transno = '" . $myrow['transno'] ."' 
										AND department = 7";

$resultupdate=mysqli_query($connect,$SQLupdate);
		
	}
		 //7100700  Annuals Survey  fee
	
	
	//7101001 Fire alarm monthly testing

	//7100300 Brigade Sales
	   if ($myrow['sales_gl'] == '7100300'){
		
		
		$SQLupdate = "UPDATE debtortrans set old_sales_code = '201',
                                        	old_gl_code = 'W7020101',
											gl_status = '1'
										WHERE transno = '" . $myrow['transno'] ."' 
										AND department = 6";

$resultupdate=mysqli_query($connect,$SQLupdate);
		
	}
	   if ($myrow['sales_gl'] == '7100300'){
		
		
		$SQLupdate = "UPDATE debtortrans set old_sales_code = '301',
                                        	old_gl_code = 'W7020201',
											gl_status = '1'
										WHERE transno = '" . $myrow['transno'] ."' 
										AND department = 7";

$resultupdate=mysqli_query($connect,$SQLupdate);
		
	}
		  if ($myrow['sales_gl'] == '7100300'){
		
		
		$SQLupdate = "UPDATE debtortrans set old_sales_code = '401',
                                        	old_gl_code = 'W7020301',
											gl_status = '1'
										WHERE transno = '" . $myrow['transno'] ."' 
										AND department = 8";

$resultupdate=mysqli_query($connect,$SQLupdate);
		
	}
	
	
	
	//7101006 Fire Pump Biannual Servicing
	
	
//7100603 Special Hazard R102 Servicing
   if ($myrow['sales_gl'] == '7100603'){
		
		
		$SQLupdate = "UPDATE debtortrans set old_sales_code = '301',
                                        	old_gl_code = 'W7020201',
											gl_status = '1'
										WHERE transno = '" . $myrow['transno'] ."' 
										AND department = 7";

$resultupdate=mysqli_query($connect,$SQLupdate);
		
	}
	
	//7101001 Fire alarm weekly testing

	   if ($myrow['sales_gl'] == '7101001'){
		
		
		$SQLupdate = "UPDATE debtortrans set old_sales_code = '205',
                                        	old_gl_code = 'W7040103',
											gl_status = '1'
										WHERE transno = '" . $myrow['transno'] ."' 
										AND department = 6";

$resultupdate=mysqli_query($connect,$SQLupdate);
		
	}
	   if ($myrow['sales_gl'] == '7101001'){
		
		
		$SQLupdate = "UPDATE debtortrans set old_sales_code = '305',
                                        	old_gl_code = 'W7040203',
											gl_status = '1'
										WHERE transno = '" . $myrow['transno'] ."' 
										AND department = 7";

$resultupdate=mysqli_query($connect,$SQLupdate);
		
	}
	   if ($myrow['sales_gl'] == '7101001'){
		
		
		$SQLupdate = "UPDATE debtortrans set old_sales_code = '405',
                                        	old_gl_code = 'W7040303',
											gl_status = '1'
										WHERE transno = '" . $myrow['transno'] ."' 
										AND department = 8";

$resultupdate=mysqli_query($connect,$SQLupdate);
		
	}
	
	//7100700  Annuals Survey  fee
	   if ($myrow['sales_gl'] == '7100700'){
		
		
		$SQLupdate = "UPDATE debtortrans set old_sales_code = '204',
                                        	old_gl_code = 'W7030103',
											gl_status = '1'
										WHERE transno = '" . $myrow['transno'] ."' 
										AND department = 6";

$resultupdate=mysqli_query($connect,$SQLupdate);
		
	}
	   if ($myrow['sales_gl'] == '7100700'){
		
		
		$SQLupdate = "UPDATE debtortrans set old_sales_code = '304',
                                        	old_gl_code = 'W7040203',
											gl_status = '1'
										WHERE transno = '" . $myrow['transno'] ."' 
										AND department = 7";

$resultupdate=mysqli_query($connect,$SQLupdate);
		
	}
	
	
	
	//7101000	Fire Training Sales
	
		   if ($myrow['sales_gl'] == '7101000'){
		
		
		$SQLupdate = "UPDATE debtortrans set old_sales_code = '206',
                                        	old_gl_code = 'W7020401',
											gl_status = '1'
										WHERE transno = '" . $myrow['transno'] ."' 
										AND department = 6";

$resultupdate=mysqli_query($connect,$SQLupdate);
		
	}
	   if ($myrow['sales_gl'] == '7101000'){
		
		
		$SQLupdate = "UPDATE debtortrans set old_sales_code = '306',
                                        	old_gl_code = 'W7020402',
											gl_status = '1'
										WHERE transno = '" . $myrow['transno'] ."' 
										AND department = 7";

$resultupdate=mysqli_query($connect,$SQLupdate);
		
	}
	
	//7100200 Installs Access System Small Jobs Income
			   if ($myrow['sales_gl'] == '7100200'){
		
		
		$SQLupdate = "UPDATE debtortrans set old_sales_code = '704',
                                        	old_gl_code = 'S70004',
											gl_status = '1'
										WHERE transno = '" . $myrow['transno'] ."' 
										AND department = 9";

$resultupdate=mysqli_query($connect,$SQLupdate);
		
	}
	   if ($myrow['sales_gl'] == '7100200'){
		
		
		$SQLupdate = "UPDATE debtortrans set old_sales_code = '734',
                                        	old_gl_code = 'S700204',
											gl_status = '1'
										WHERE transno = '" . $myrow['transno'] ."' 
										AND department = 10";

$resultupdate=mysqli_query($connect,$SQLupdate);
		
	}
	   if ($myrow['sales_gl'] == '7100200'){
		
		
		$SQLupdate = "UPDATE debtortrans set old_sales_code = '703',
                                        	old_gl_code = 's700301',
											gl_status = '1'
										WHERE transno = '" . $myrow['transno'] ."' 
										AND department = 21";

$resultupdate=mysqli_query($connect,$SQLupdate);
		
	}
	
	//access system contract 7100100
		   if ($myrow['sales_gl'] == '7100100'){
		
		
		$SQLupdate = "UPDATE debtortrans set old_sales_code = '600',
                                        	old_gl_code = 'G610',
											gl_status = '1'
										WHERE transno = '" . $myrow['transno'] ."' 
										AND department = 9";

$resultupdate=mysqli_query($connect,$SQLupdate);
		
	}
	   if ($myrow['sales_gl'] == '7100200'){
		
		
		$SQLupdate = "UPDATE debtortrans set old_sales_code = '700',
                                        	old_gl_code = 'G610',
											gl_status = '1'
										WHERE transno = '" . $myrow['transno'] ."' 
										AND department = 10";

$resultupdate=mysqli_query($connect,$SQLupdate);
		
	}
	//cctv contract 7100400
	   if ($myrow['sales_gl'] == '7100400'){
		
		
		$SQLupdate = "UPDATE debtortrans set old_sales_code = '600',
                                        	old_gl_code = 'G610',
											gl_status = '1'
										WHERE transno = '" . $myrow['transno'] ."' 
										AND department = 9";

$resultupdate=mysqli_query($connect,$SQLupdate);
		
	}
	   if ($myrow['sales_gl'] == '7100400'){
		
		
		$SQLupdate = "UPDATE debtortrans set old_sales_code = '700',
                                        	old_gl_code = 'G610',
											gl_status = '1'
										WHERE transno = '" . $myrow['transno'] ."' 
										AND department = 10";

$resultupdate=mysqli_query($connect,$SQLupdate);
		
	}

	//cctv small jobs
			   if ($myrow['sales_gl'] == '7100401'){
		
		
		$SQLupdate = "UPDATE debtortrans set old_sales_code = '704',
                                        	old_gl_code = 'S70004',
											gl_status = '1'
										WHERE transno = '" . $myrow['transno'] ."' 
										AND department = 9";

$resultupdate=mysqli_query($connect,$SQLupdate);
		
	}
	   if ($myrow['sales_gl'] == '7100401'){
		
		
		$SQLupdate = "UPDATE debtortrans set old_sales_code = '734',
                                        	old_gl_code = 'S700204',
											gl_status = '1'
										WHERE transno = '" . $myrow['transno'] ."' 
										AND department = 10";

$resultupdate=mysqli_query($connect,$SQLupdate);
		
	}
	
	//7100602	Installs Alarm Small Jobs
	
	 if ($myrow['sales_gl'] == '7100602'){
		
		
		$SQLupdate = "UPDATE debtortrans set old_sales_code = '704',
                                        	old_gl_code = 'S70004',
											gl_status = '1'
										WHERE transno = '" . $myrow['transno'] ."' 
										AND department = 9";

$resultupdate=mysqli_query($connect,$SQLupdate);
		
	}
	   if ($myrow['sales_gl'] == '7100602'){
		
		
		$SQLupdate = "UPDATE debtortrans set old_sales_code = '734',
                                        	old_gl_code = 'S700204',
											gl_status = '1'
										WHERE transno = '" . $myrow['transno'] ."' 
										AND department = 10";

$resultupdate=mysqli_query($connect,$SQLupdate);
		
	}
	
	//7100601	Installs Alarm Contract
	  if ($myrow['sales_gl'] == '7100601'){
		
		
		$SQLupdate = "UPDATE debtortrans set old_sales_code = '600',
                                        	old_gl_code = 'G610',
											gl_status = '1'
										WHERE transno = '" . $myrow['transno'] ."' 
										AND department = 9";

$resultupdate=mysqli_query($connect,$SQLupdate);
		
	}
	   if ($myrow['sales_gl'] == '7100601'){
		
		
		$SQLupdate = "UPDATE debtortrans set old_sales_code = '700',
                                        	old_gl_code = 'G610',
											gl_status = '1'
										WHERE transno = '" . $myrow['transno'] ."' 
										AND department = 10";

$resultupdate=mysqli_query($connect,$SQLupdate);
		
	}
	
	
	//7100201	Installs Prepaid Incomen G61101

		  if ($myrow['sales_gl'] == '7100201'){
		
		
		$SQLupdate = "UPDATE debtortrans set old_sales_code = '801',
                                        	old_gl_code = 'G61101',
											gl_status = '1'
										WHERE transno = '" . $myrow['transno'] ."' 
										AND department = 9";

$resultupdate=mysqli_query($connect,$SQLupdate);
		
	}
	   if ($myrow['sales_gl'] == '7100201'){
		
		
		$SQLupdate = "UPDATE debtortrans set old_sales_code = '621',
                                        	old_gl_code = 'G61101',
											gl_status = '1'
										WHERE transno = '" . $myrow['transno'] ."' 
										AND department = 10";

$resultupdate=mysqli_query($connect,$SQLupdate);
		
	}
	
	// 7100202 installs alarm testing
	  if ($myrow['sales_gl'] == '7100202'){
		
		
		$SQLupdate = "UPDATE debtortrans set old_sales_code = '701',
                                        	old_gl_code = 'S70002',
											gl_status = '1'
										WHERE transno = '" . $myrow['transno'] ."' 
										AND department = 9";

$resultupdate=mysqli_query($connect,$SQLupdate);
		
	}
	  
	
	//monitoring
	
	  if ($myrow['sales_gl'] == '7101800' || $myrow['sales_gl'] == '7102000' ){
		
		
		$SQLupdate = "UPDATE debtortrans set old_sales_code = '803',
                                        	old_gl_code = 'S70005',
											gl_status = '1'
										WHERE transno = '" . $myrow['transno'] ."' 
										AND department = 11";

$resultupdate=mysqli_query($connect,$SQLupdate);
		
	}
	
	//cit
	
	  if ($myrow['sales_gl'] == '7102600'){
		
		
		$SQLupdate = "UPDATE debtortrans set old_sales_code = '900',
                                        	old_gl_code = 'G70050',
											gl_status = '1'
										WHERE transno = '" . $myrow['transno'] ."' 
										AND department = 9";

$resultupdate=mysqli_query($connect,$SQLupdate);
		
	}
	
	
}
mysqli_close($connect);
echo "success";
	?>
						

		
		
