<?

	//*************   DB for page ( 1 )  ************* 

		if ( $_GET['page']  == '1') {
				if ($_GET['stat'] == 'hide_date' ) { 
						$did = $_GET['did'];
						mysql_query("UPDATE p1_date SET  date_stop  = 1 where did = $did");	
						header("Location: index.php?page=1");
				}
	    if ($_GET['stat']  == 'add_order1') {
				
							$traf_recpt = $_POST['traf_recpt'];
							$query = mysql_query("SELECT * FROM  p1_order_info where traf_recpt = '".$traf_recpt."'"); 	
			//$query = mysql_query("SELECT * FROM p1_powers where username = '$LoginU' and password  = '$LoginP' and stop_user = 0"); 		
			
		if (mysql_num_rows($query) <> 0)
			{
								
				header("Location: index.php?page=1&stat=Error101");
									
			}else{
				
				
				
				
						$Date_a			   = $_SESSION['1_date_name'];
						$Time_a  		   = $_SESSION['1_time_name'];
						
						$did			   = $_SESSION['1_did'];
						$tdid			   = $_SESSION['1_tdid'];
						
						$traf_recpt		   = $_POST['traf_recpt'];
					//	$number_of_plate   = $_POST['number_of_plate'];
						$number_of_plate   = $_POST['Size1']+$_POST['Size2'];
						
						$Plate 			   = $_POST['Plate'];
						$Type1  		   = $_SESSION['1_Type1'];
						$Type2			   = $_POST['Type2'];
						$Size1  		   = $_POST['Size1'];
						$Size2  		   = $_POST['Size2'];
						$Remarks 		   = $_POST['Remarks'];
						$Name 			   = $_POST['Name'];
						$mobile 		   = $_POST['mobile'];
						$cpr   			   = $_POST['cpr'];
						$month_register    = $_POST['month_register'];
						$car_type  		   = $_POST['car_type'];
						$car_model 		   = $_POST['car_model'];
						$frame			   = 0;
						$Fiber		       = 0;
						if ( $_POST['BD1'] <> '' ) {
							$BD1		   = 1;
						}else{
							$BD1		   = 0;
						}
						
						$uid 			   = $_SESSION['P1_Login_uid'];
						
						$month			   = date("m");
						$year			   = date("Y");
						$date_add   = date("Y").'-'.date("m").'-'.date("d");
						//	$time_add	= (date("H")-1).':'.date("i");
						$time_add	= date("H").':'.date("i");
						$add_dt 	= date("Y").'-'.date("m").'-'.date("d").' '.(date("H")-1).':'.date("i");
						//	$serial
						
						$query = mysql_query("SELECT * FROM p1_serial where month = $month and year = $year"); 		
							if (mysql_num_rows($query) <> "0")
								{
									$serial = mysql_result($query,0,"serial");
									$next_serial = $serial+1;
									mysql_query("UPDATE p1_serial SET  serial  = $next_serial where month = $month and year = $year");	
								}else{
									mysql_query("INSERT INTO p1_serial (month,year,serial) VALUES ($month,$year,1)");
									$serial = 1;
								
								}	
						
						
					// End Serial 	
						
				
						mysql_query("INSERT INTO p1_order_info (did,tdid,Date_a,Time_a,Plate,traf_recpt,number_of_plate,Type1,Type2,Size1,Size2,Remarks,Name,mobile,cpr,month_register,car_type,car_model,uid , serial,month,year,add_dt,frame,Fiber,BD1) VALUES ($did,$tdid,'$Date_a','$Time_a','$Plate','$traf_recpt',$number_of_plate,$Type1,$Type2,'$Size1','$Size2','$Remarks','$Name','$mobile','$cpr','$month_register','$car_type','$car_model',$uid,$serial,$month,$year,'$add_dt',$frame,$Fiber,$BD1)");
				
					// Create invoice
						//Invoice No.
							$Inv_year  = $year -2000;
							if ($month < 10 ) {
								$Inv_month = '0'.$month;
							}else{
								$Inv_month = $month;
							}
							if ($serial < 10 ) {
								$Inv_serial = '0000'.$serial;
							}elseif ($serial < 100 ) {
								$Inv_serial = '000'.$serial;
							}elseif ($serial < 1000 ) {
								$Inv_serial = '00'.$serial;
							}elseif ($serial < 10000 ) {
								$Inv_serial = '0'.$serial;
							}elseif ($serial < 100000 ) {
								$Inv_serial = $serial;
							}
							$_SESSION['Inv_no'] = $Inv_year.$Inv_month.'NV'.$Inv_serial;
					// Date , Time , Traf rcpt

							$_SESSION['Inv_Date']   		   = $date_add ;
							$_SESSION['Inv_Time']  			   = $time_add ;
							$_SESSION['Inv_traf_recpt'] 	   = $traf_recpt;
							$_SESSION['Inv_mobile'] 		   = $mobile;
							$_SESSION['Inv_Name'] 			   = $Name;
							$_SESSION['Inv_Type1'] 			   = $Type1;
							$_SESSION['Inv_number_of_plate']   = $number_of_plate;
							$_SESSION['Inv_number_of_Size1']   = $Size1;
							$_SESSION['Inv_number_of_Size2']   = $Size2;
							$_SESSION['Inv_Plate'] 			   = $Plate;
							$_SESSION['Inv_frame']	 		   = $frame;
							$_SESSION['Inv_Fiber']			   = $Fiber;
							$_SESSION['Inv_BD1']			   = $BD1;
							
							
							
							

					//
					header("Location: index.php?page=1&stat=to_print");
					
				}
			}
		}
	//*************  End DB for page ( 1 )  ***********
	//*************   DB for page ( 2 )  ************* 
		if ( $_GET['page']  == '2') {
			if ( $_GET['stat'] == 'change' ) {
					$oid = $_GET['id'];
					$factory_dt 	= date("Y").'-'.date("m").'-'.date("d").' '.date("H").':'.date("i");
					$Rack = $_POST['Rack'];
					mysql_query("UPDATE p1_order_info SET  status  = 1 , factory_dt = '$factory_dt' , Rack = '$Rack' where oid = $oid");	
					header("Location: index.php?page=2");
			
			}

		}
	//*************  End DB for page ( 2 )  ***********
	//*************   DB for page ( 3 )  ************* 
		if ( $_GET['page']  == '3') {
			if ( $_GET['stat'] == 'change' ) {
					$oid = $_GET['id'];
					$delivery_dt 	= date("Y").'-'.date("m").'-'.date("d").' '.date("H").':'.date("i");
					mysql_query("UPDATE p1_order_info SET  status  = 2 , delivery_dt = '$delivery_dt' where oid = $oid");	
					header("Location: index.php?page=3");
			
			}

		}
	//*************  End DB for page ( 3 )  ***********
	//*************   DB for page ( 4 )  ************* 
		if ( $_GET['page']  == '4') {
			if ( $_GET['stat'] == 'change' ) {
					$oid = $_GET['id'];
					$tid = $_POST['tid'];
					$fixing_dt 	= date("Y").'-'.date("m").'-'.date("d").' '.date("H").':'.date("i");
					mysql_query("UPDATE p1_order_info SET  status  = 3 , fixing_dt = '$fixing_dt' , tid = $tid where oid = $oid");	
					header("Location: index.php?page=4");
			
			}

		}
	//*************  End DB for page ( 4 )  ***********
	//*************   DB for page ( 6 )  ************* 
		if ( $_GET['page']  == 6) 
			{
				if ($_GET['stat'] == 'send' ) {
				
					  	$oid 		= $_GET['oid'];					   
						$query = mysql_query("select * from p1_out_order where oid = $oid and stop1 <> 2"); 	
				    if (mysql_num_rows($query) <> 0)
					{
										
						header("Location: index.php?page=6&stat=Error102");
									
					}else{
						$status0_dt = date("Y").'-'.date("m").'-'.date("d").' '.date("H").':'.date("i");			   
						mysql_query("INSERT INTO p1_out_order (oid,status0_dt) VALUES ('$oid','$status0_dt')");
						header("Location: index.php?page=6");
					}	
				}
				if ($_GET['stat'] == 'deleverd' ) {
					  	$outid 		= $_GET['outid'];	
						$status2_dt = date("Y").'-'.date("m").'-'.date("d").' '.date("H").':'.date("i");		
						$tid = $_POST['tid'];	   
						mysql_query("UPDATE p1_out_order SET  status  = 2 , status2_dt = '$status2_dt' , tid = $tid  where outid = $outid");	
						header("Location: index.php?page=6");
				}
				if ( $_GET['stat'] == 'underfixing' ) {
					  	$outid 		= $_GET['outid'];	
						$status3_dt = date("Y").'-'.date("m").'-'.date("d").' '.date("H").':'.date("i");
						
						mysql_query("UPDATE p1_out_order SET status  = 3 , status3_dt = '$status3_dt' where outid = $outid");
						header("Location: index.php?page=6");
				}
				if ( $_GET['stat'] == 'fixed' ) {
					  	$outid 		= $_GET['outid'];	
						
						$date1 = date("Y").'-'.date("m").'-'.date("d");
						$time1 = date("H").':'.date("i");
						$status4_dt = date("Y").'-'.date("m").'-'.date("d").' '.date("H").':'.date("i");
						mysql_query("UPDATE p1_out_order SET  status  = 4 , stop1 = 1, status4_dt = '$status4_dt' where outid = $outid");	
						
						$query = mysql_query("select * from p1_out_order where outid = $outid"); 	
						$oid = mysql_result($query,0,"oid");
						
						mysql_query("UPDATE p1_order_info SET  delivered  = 1 , delivered_d = '".$date1."' , delivered_t = '".$time1."' where oid = $oid");
						
						
						header("Location: index.php?page=6");
				}				
			}
	//*************  End DB for page ( 6 )  ***********
	//*************   DB for page ( 7 )  ************* 
		if ( $_GET['page']  == 7) 
			{
				if ($_GET['stat'] == 'send' ) {
					  	$outid 		= $_GET['outid'];	
						$status1_dt = date("Y").'-'.date("m").'-'.date("d").' '.date("H").':'.date("i");			   
						mysql_query("UPDATE p1_out_order SET  status  = 1 , status1_dt = '$status1_dt' where outid = $outid");	
						header("Location: index.php?page=7");
				}
			}
	//*************  End DB for page ( 7 )  ***********
	
	//*************   DB for page ( 10 )  ************* 

		if ( $_GET['page']  == 10) 
			{
				if ($_GET['stat'] == 'add' ) {
				
				
				 $date_name = $_POST['date_name'];
				 $query = mysql_query("SELECT * FROM p1_date where date_name = '$date_name'"); 		
				  if (mysql_num_rows($query) == "0")
						{

							// add date	
								$date_name = $_POST['date_name'];
								$query = mysql_query("INSERT INTO p1_date (date_name) VALUES ('$date_name')");
							// select did 
								$query = mysql_query("select * from p1_date order by did desc"); 
								$did = mysql_result($query,0,"did");

							// add time to date	
								if ($_POST['select'] == '1' ){
									for ($i=1;$i<=13;$i++) {
										$query = mysql_query("INSERT INTO p1_time_date (tid,did) VALUES ($i,$did)");
									}
								}
								if ($_POST['select'] == '2' ){
									for ($i=1;$i<=6;$i++) {
										$query = mysql_query("INSERT INTO p1_time_date (tid,did) VALUES ($i,$did)");
									}
								}
							//	$date_name = $_POST['date_name'];
							//	$query = mysql_query("INSERT INTO p1_date (date_name) VALUES ('$date_name')");
					
								header("Location: index.php?page=10&stat=add1");
				 		 }else{
				  
								header("Location: index.php?page=10&stat=not_add");
				  
				 	  }
					
				}
			}
	//*************  End DB for page ( 10 )  ***********
	//*************   DB for page ( 11 )  ************* 
		if ( $_GET['page']  == 11) 
			{
				if ($_GET['stat'] == 'add' ) {
				
				 $username = $_POST['username'];
				 $query = mysql_query("SELECT * FROM p1_powers where username = '$username'"); 		
				  if (mysql_num_rows($query) == "0")
						{
				
					$fullname 		= $_POST['fullname'];
					$username 		= $_POST['username'];
					$password 		=  md5($_POST['password']);
					    if ($_POST['appointments'] == '' ) { 
					  		$appointments 	= 0; 
						}else{
					  		$appointments 	= 1; 
					 	}
					    if ($_POST['factory'] == '' ) { 
					  		$factory 	= 0; 
						}else{
					  		$factory 	= 1; 
					 	}
					    if ($_POST['delivery'] == '' ) { 
					  		$delivery 	= 0; 
						}else{
					  		$delivery 	= 1; 
					 	}
					    if ($_POST['fixing'] == '' ) { 
					  		$fixing 	= 0; 
						}else{
					  		$fixing 	= 1; 
					 	}
					    if ($_POST['search'] == '' ) { 
					  		$search 	= 0; 
						}else{
					  		$search 	= 1; 
					 	}
					    if ($_POST['add_new_date'] == '' ) { 
					  		$add_new_date 	= 0; 
						}else{
					  		$add_new_date 	= 1; 
					 	}
					    if ($_POST['control_user'] == '' ) { 
					  		$control_user 	= 0; 
						}else{
					  		$control_user 	= 1; 
					 	}
					    if ($_POST['report_os'] == '' ) { 
					  		$report_os 	= 0; 
						}else{
					  		$report_os 	= 1; 
					 	}
					    if ($_POST['manage_sales'] == '' ) { 
					  		$manage_sales 	= 0; 
						}else{
					  		$manage_sales 	= 1; 
					 	}						
						
						
							mysql_query("INSERT INTO p1_powers (fullname,username,password,appointments,factory,delivery,fixing,search,add_new_date,control_user,report_os,manage_sales) VALUES ('$fullname','$username','$password',$appointments,$factory,$delivery,$fixing,$search,$add_new_date,$control_user,$report_os,$manage_sales)");
							header("Location: index.php?page=11");
				   		}else{
				   
							header("Location: index.php?page=11&stat=reenter");
				   
				 		}
					}
					
				if ( $_GET['stat'] == 'stop' ) {
						$uid = $_GET['uid'];
						mysql_query("UPDATE p1_powers SET  stop_user  = 1  where uid = $uid");	
						header("Location: index.php?page=11");
				}
				if ( $_GET['stat'] == 'update' ) {
				
						$uid 			= $_GET['uid'];
						$fullname 		= $_POST['fullname'];
						$username 		= $_POST['username'];
						
						if ($_POST['newpass'] == '1' ) { 
							$password 		=  md5($_POST['password']);
						}	
					    if ($_POST['appointments'] == '' ) { 
					  		$appointments 	= 0; 
						}else{
					  		$appointments 	= 1; 
					 	}
					    if ($_POST['factory'] == '' ) { 
					  		$factory 	= 0; 
						}else{
					  		$factory 	= 1; 
					 	}
					    if ($_POST['delivery'] == '' ) { 
					  		$delivery 	= 0; 
						}else{
					  		$delivery 	= 1; 
					 	}
					    if ($_POST['fixing'] == '' ) { 
					  		$fixing 	= 0; 
						}else{
					  		$fixing 	= 1; 
					 	}
					    if ($_POST['search'] == '' ) { 
					  		$search 	= 0; 
						}else{
					  		$search 	= 1; 
					 	}
					    if ($_POST['add_new_date'] == '' ) { 
					  		$add_new_date 	= 0; 
						}else{
					  		$add_new_date 	= 1; 
					 	}
					    if ($_POST['control_user'] == '' ) { 
					  		$control_user 	= 0; 
						}else{
					  		$control_user 	= 1; 
					 	}
						if ($_POST['report_os'] == '' ) { 
					  		$report_os 	= 0; 
						}else{
					  		$report_os 	= 1; 
					 	}
					    if ($_POST['manage_sales'] == '' ) { 
					  		$manage_sales 	= 0; 
						}else{
					  		$manage_sales 	= 1; 
					 	}

						if ($_POST['newpass'] == '' ) { 
							mysql_query("UPDATE p1_powers SET fullname  = '$fullname' , username  = '$username' , appointments = $appointments, factory = $factory, delivery = $delivery, fixing = $fixing, search = $search, add_new_date = $add_new_date, control_user = $control_user , report_os = $report_os , manage_sales = $manage_sales   where uid = $uid");
						}else{
							mysql_query("UPDATE p1_powers SET fullname  = '$fullname' , username  = '$username', password  = '$password' , appointments = $appointments, factory = $factory, delivery = $delivery, fixing = $fixing, search = $search, add_new_date = $add_new_date, control_user = $control_user  , report_os = $report_os , manage_sales = $manage_sales  where uid = $uid");
						}
						
						header("Location: index.php?page=11");
				}
				
				
			}	
	//*************  End DB for page ( 11 )  ***********
	//*************   DB for page ( 12 )   ************* 
		if ( $_GET['page']  == 12) 
			{
				if ($_GET['stat'] == 'update' ) {
					$uid 		= $_SESSION['P1_Login_uid'];	
					$LoginP=md5($_POST['old_pass']);
					$query = mysql_query("SELECT * FROM p1_powers where password  = '$LoginP' and uid = $uid"); 		
					if (mysql_num_rows($query) <> "0")
						{
					  		
							$pass	= md5($_POST['new_pass']);		   
							mysql_query("UPDATE p1_powers SET password  = '$pass' where uid = $uid");	
							header("Location: index.php?page=12&stat=update1");
						}else{
							header("Location: index.php?page=12&stat=reenter");
						}
						
				}
	
	
			}
	//*************  End DB for page ( 12 )  ***********
	//*************   DB for page ( 13 )   ************* 
		if ( $_GET['page']  == 13) 
			{
				if ($_GET['stat'] == 'add' ) {
					  	$technitian 		= $_POST['technitian'];					   
						mysql_query("INSERT INTO p1_technitian (technitian) VALUES ('$technitian')");
						header("Location: index.php?page=13");
				}
				if ( $_GET['stat'] == 'stop' ) {
						$tid = $_GET['tid'];
						mysql_query("UPDATE p1_technitian SET stop_technitian  = 1 where tid = $tid");	
						header("Location: index.php?page=13");
				}
				if ( $_GET['stat'] == 'update' ) {
						$tid = $_GET['tid'];
						$technitian = $_POST['technitian'];
						mysql_query("UPDATE p1_technitian SET technitian  = '$technitian' where tid = $tid");
						header("Location: index.php?page=13");
				}
			}
	//*************  End DB for page ( 13 )  ***********
	//*************   DB for page ( 14 )   ************* 
		if ( $_GET['page']  == 14) 
			{
				if ($_GET['stat'] == 'add' ) {
					  	$time_name 		= $_POST['time_name'];	
						$max_number		= $_POST['max_number'];				   
						mysql_query("INSERT INTO p1_default_time (time_name,max_number) VALUES ('$time_name','$max_number')");
						header("Location: index.php?page=14");
				}
				if ( $_GET['stat'] == 'update' ) {
						$tid = $_GET['tid'];
						$time_name = $_POST['time_name'];
						$max_number		= $_POST['max_number'];				   
						mysql_query("UPDATE p1_default_time SET time_name  = '$time_name' , max_number  = '$max_number'   where tid = $tid");
						header("Location: index.php?page=14");
				}
			}
	//*************  End DB for page ( 14 )  ***********
	//*************   DB for page ( 15 )   ************* 
		if ( $_GET['page']  == 15) 
			{
				if ( $_GET['stat'] == 'update' ) {
						$down = $_POST['down'];
						$line = $_POST['line'];
						mysql_query("UPDATE p1_receipt SET down  = '$down' , line = $line where rid = 1");
						header("Location: index.php?page=15&stat=ok");
				}
			}
	//*************  End DB for page ( 15 )  ***********
	//*************   DB for page ( 16 )  ************* 

		if ( $_GET['page']  == '16') {
				if ($_GET['stat']  == 'add_order1') {
				
							$traf_recpt = $_POST['traf_recpt'];
							
				
						$Date_a			   = $_SESSION['1_date_name'];
						$Time_a  		   = $_SESSION['1_time_name'];
						
						$did			   = $_SESSION['1_did'];
						$tdid			   = $_SESSION['1_tdid'];
						
						$traf_recpt		   = $_POST['traf_recpt'];
					//	$number_of_plate   = $_POST['number_of_plate'];
						$number_of_plate   = $_POST['Size1']+$_POST['Size2'];
						
						$Plate 			   = $_POST['Plate'];
						$Type1  		   = $_SESSION['1_Type1'];
						$Type2			   = $_POST['Type2'];
						$Size1  		   = $_POST['Size1'];
						$Size2  		   = $_POST['Size2'];
						$Remarks 		   = $_POST['Remarks'];
						$Name 			   = $_POST['Name'];
						$mobile 		   = $_POST['mobile'];
						$cpr   			   = $_POST['cpr'];
						$month_register    = $_POST['month_register'];
						$car_type  		   = $_POST['car_type'];
						$car_model 		   = $_POST['car_model'];
						$frame			   = $_POST['frame'];
						
						if ( $_POST['Fiber'] <> '' ) {
							$Fiber		   = 1;
						}else{
							$Fiber		   = 0;
						}
						
						if ( $_POST['BD1'] <> '' ) {
							$BD1		   = 1;
						}else{
							$BD1		   = 0;
						}
						
						$uid 			   = $_SESSION['P1_Login_uid'];
						
			$oid = $_SESSION['1_oid'];
			$query_edit = mysql_query("SELECT *  FROM p1_order_info where oid = $oid"); 		

						
						
						$month			   = mysql_result($query_edit,0,"month");
						$year			   = mysql_result($query_edit,0,"year");
						$serial 		   = mysql_result($query_edit,0,"serial");
						
						$date_add   = date("Y").'-'.date("m").'-'.date("d");
						//	$time_add	= (date("H")-1).':'.date("i");
						$time_add	= date("H").':'.date("i");
					// End Serial 	
						


						mysql_query("UPDATE p1_order_info SET Plate  = '$Plate' , traf_recpt = '$traf_recpt' , number_of_plate = $number_of_plate , Type1 = $Type1 , Type2 = $Type2 , Size1 = '$Size1', Size2 = '$Size2' , Remarks = '$Remarks' , Name = '$Name' , mobile = '$mobile' , cpr = '$cpr' , month_register = '$month_register' ,  car_type = '$car_type' ,  car_model = '$car_model'  , frame = $frame , Fiber = $Fiber , BD1 = $BD1  where oid = $oid");
				
				
				
					// Create invoice
						//Invoice No.
							$Inv_year  = $year -2000;
							if ($month < 10 ) {
								$Inv_month = '0'.$month;
							}else{
								$Inv_month = $month;
							}
							if ($serial < 10 ) {
								$Inv_serial = '0000'.$serial;
							}elseif ($serial < 100 ) {
								$Inv_serial = '000'.$serial;
							}elseif ($serial < 1000 ) {
								$Inv_serial = '00'.$serial;
							}elseif ($serial < 10000 ) {
								$Inv_serial = '0'.$serial;
							}elseif ($serial < 100000 ) {
								$Inv_serial = $serial;
							}
							$_SESSION['Inv_no'] = $Inv_year.$Inv_month.'NV'.$Inv_serial;
					// Date , Time , Traf rcpt

							$_SESSION['Inv_Date']   		   = $date_add ;
							$_SESSION['Inv_Time']  			   = $time_add ;
							$_SESSION['Inv_traf_recpt'] 	   = $traf_recpt;
							$_SESSION['Inv_mobile'] 		   = $mobile;
							$_SESSION['Inv_Name'] 			   = $Name;
							$_SESSION['Inv_Type1'] 			   = $Type1;
							$_SESSION['Inv_number_of_plate']   = $number_of_plate;
							$_SESSION['Inv_number_of_Size1']   = $Size1;
							$_SESSION['Inv_number_of_Size2']   = $Size2;
							$_SESSION['Inv_Plate'] 			   = $Plate;
							$_SESSION['Inv_frame']	 		   = $frame;
							$_SESSION['Inv_Fiber']			   = $Fiber;
							$_SESSION['Inv_BD1']			   = $BD1;
					header("Location: index.php?page=16&stat=to_print");
			}
			
				if ($_GET['stat']  == 'save_time') {
						$oid 		= $_SESSION['16_oid'];
						$did		= $_SESSION['16_did'];
						$tdid		= $_GET['tdid'];
						$Date_a		= $_SESSION['16_date_name'];
						$Time_a		= $_GET['time_name'];
						mysql_query("UPDATE p1_order_info SET did = $did , tdid = $tdid , Date_a = '$Date_a', Time_a = '$Time_a'  where oid = $oid");
						header("Location: index.php?page=16");
				}
				if ($_GET['stat'] == 'select_plate_type' ) { 
						$oid 		= $_GET['oid'];
						$Type1		= $_GET['id'];
						
						
						mysql_query("UPDATE p1_order_info SET Type1 = $Type1 where oid = $oid");
						header("Location: index.php?page=16");
				}
				
				
				
		}
	//*************  End DB for page ( 16 )  ***********
	
	
	
	//*************   DB for page ( 17 )   ************* 
		if ( $_GET['page']  == 17) 
			{
				if ($_GET['stat'] == 'add' ) {
					  	$tid			= $_SESSION['17_tid'];
						$agent_date 	= date("Y").'-'.date("m").'-'.date("d").' '.date("H").':'.date("i");
						mysql_query("INSERT INTO p1_agent_order (agent_date,tid) VALUES ('$agent_date',$tid)");
						header("Location: index.php?page=17&stat=show");
				}
				
				if ($_GET['stat'] == 'deleverd' ) {
						$aid 	= $_GET['aid'];
						mysql_query("UPDATE p1_agent_order SET status = 1 where aid = $aid");
						header("Location: index.php?page=17&stat=show");
					}
				if ($_GET['stat'] == 'addagent' ) { 
						$Date_a			   = date("Y").'-'.date("m").'-'.date("d");
						//$Time_a  		   = $_SESSION['1_time_name'];
						
						$did			   = 0;
						$tdid			   = 0;
						$aid 			   = $_POST['aid'];
						$traf_recpt		   = $_SESSION['17_traf_recpt'];
						$number_of_plate   = $_POST['Size1']+$_POST['Size2'];
						
						$Plate 			   = $_POST['Plate'];
						$Type1  		   = $_SESSION['17_pid'];
						$Type2			   = 2;
						$Size1  		   = $_POST['Size1'];
						$Size2  		   = $_POST['Size2'];
						$Remarks 		   = '';
						$Name 			   = $_POST['Name'];
						$mobile 		   = '';
						$cpr   			   = $_POST['cpr'];
						$month_register    = $_POST['month_register'];
						$car_type  		   = $_POST['car_type'];
						$car_model 		   = $_POST['car_model'];
						$frame			   = 0;
						$Fiber			   = 0;
						if ( $_POST['BD1'] <> '' ) {
							$BD1		   = 1;
						}else{
							$BD1		   = 0;
						}
						
						$uid 			   = $_SESSION['P1_Login_uid'];
						
						$month			   = date("m");
						$year			   = date("Y");
						$date_add   = date("Y").'-'.date("m").'-'.date("d");
						//	$time_add	= (date("H")-1).':'.date("i");
						$time_add	= date("H").':'.date("i");
						$add_dt 	= date("Y").'-'.date("m").'-'.date("d").' '.(date("H")-1).':'.date("i");
						//	$serial
					
					$query_test_re_enter = mysql_query("SELECT * FROM p1_order_info where Plate ='$Plate' and Date_a = '$Date_a'"); 		
					if (mysql_num_rows($query_test_re_enter) == "0")
					 {	
						$query = mysql_query("SELECT * FROM p1_serial where month = $month and year = $year"); 		
							if (mysql_num_rows($query) <> "0")
								{
									$serial = mysql_result($query,0,"serial");
									$next_serial = $serial+1;
									mysql_query("UPDATE p1_serial SET  serial  = $next_serial where month = $month and year = $year");	
								}else{
									mysql_query("INSERT INTO p1_serial (month,year,serial) VALUES ($month,$year,1)");
									$serial = 1;
								
								}	
						
						
					// End Serial 	
						
				
						mysql_query("INSERT INTO p1_order_info (did,tdid,Date_a,Time_a,Plate,traf_recpt,number_of_plate,Type1,Type2,Size1,Size2,Remarks,Name,mobile,cpr,month_register,car_type,car_model,uid , serial,month,year,add_dt,frame,Fiber,BD1,aid) VALUES ($did,$tdid,'$Date_a','$Time_a','$Plate','$traf_recpt',$number_of_plate,$Type1,$Type2,'$Size1','$Size2','$Remarks','$Name','$mobile','$cpr','$month_register','$car_type','$car_model',$uid,$serial,$month,$year,'$add_dt',$frame,$Fiber,$BD1,$aid)");
					}
						header("Location: index.php?page=17&stat=show");
				
				
				}
			}
	//*************  End DB for page ( 17 )  ***********
	//*************   DB for page ( 19 )   ************* 
		if ( $_GET['page']  == 19) 
			{
				if ($_GET['stat'] == 'add' ) {
					  	$agent_name 		= $_POST['agent_name'];	
						mysql_query("INSERT INTO p1_agent (agent_name) VALUES ('$agent_name')");
						header("Location: index.php?page=19");
				}
				if ( $_GET['stat'] == 'update' ) {
						$tid = $_GET['tid'];
						$agent_name = $_POST['agent_name'];
						mysql_query("UPDATE p1_agent SET agent_name = '$agent_name' where tid = $tid");
						header("Location: index.php?page=19");
				}
			}
	//*************  End DB for page ( 19 )  ***********
	//*************   DB for page ( 20 )   ************* 
		if ( $_GET['page']  == 20) 
			{
				if ($_GET['stat'] == 'add' ) {
					  	$tid			= $_SESSION['20_tid'];
						$vip_date 	= date("Y").'-'.date("m").'-'.date("d").' '.date("H").':'.date("i");
						mysql_query("INSERT INTO p1_vip_order (vip_date,tid) VALUES ('$vip_date',$tid)");
						header("Location: index.php?page=20&stat=show");
				}
				if ($_GET['stat'] == 'addvip' ) { 
						$Date_a			   = date("Y").'-'.date("m").'-'.date("d");
						//$Time_a  		   = $_SESSION['1_time_name'];
						
						$did			   = 0;
						$tdid			   = 0;
						$vid 			   = $_POST['vid'];
						$traf_recpt		   = $_POST['traf_recpt'];
						$number_of_plate   = $_POST['Size1']+$_POST['Size2'];
						
						$Plate 			   = $_POST['Plate'];
						$Type1  		   = $_POST['tyid'];
						$Type2			   = 3;
						$Size1  		   = $_POST['Size1'];
						$Size2  		   = $_POST['Size2'];
						$Remarks 		   = '';
						$Name 			   = $_SESSION['20_vip_name'];
						$mobile 		   = '';
						$cpr   			   = '0';
						$month_register    = $_POST['month_register'];
						$car_type  		   = $_POST['car_type'];
						$car_model 		   = $_POST['car_model'];
						$frame			   = 0;
						$Fiber			   = 0;
						if ( $_POST['BD1'] == '' ) {
							$BD1		   = 0;
						}else{
							$BD1		   = 1;
						}
						
						$uid 			   = $_SESSION['P1_Login_uid'];
						
						$month			   = date("m");
						$year			   = date("Y");
						$date_add   = date("Y").'-'.date("m").'-'.date("d");
						//	$time_add	= (date("H")-1).':'.date("i");
						$time_add	= date("H").':'.date("i");
						$add_dt 	= date("Y").'-'.date("m").'-'.date("d").' '.(date("H")-1).':'.date("i");
						//	$serial
						
						$query = mysql_query("SELECT * FROM p1_serial where month = $month and year = $year"); 		
							if (mysql_num_rows($query) <> "0")
								{
									$serial = mysql_result($query,0,"serial");
									$next_serial = $serial+1;
									mysql_query("UPDATE p1_serial SET  serial  = $next_serial where month = $month and year = $year");	
								}else{
									mysql_query("INSERT INTO p1_serial (month,year,serial) VALUES ($month,$year,1)");
									$serial = 1;
								
								}	
						
						
					// End Serial 	
						
				
						mysql_query("INSERT INTO p1_order_info (did,tdid,Date_a,Time_a,Plate,traf_recpt,number_of_plate,Type1,Type2,Size1,Size2,Remarks,Name,mobile,cpr,month_register,car_type,car_model,uid , serial,month,year,add_dt,frame,Fiber,BD1,vid) VALUES ($did,$tdid,'$Date_a','$Time_a','$Plate','$traf_recpt',$number_of_plate,$Type1,$Type2,'$Size1','$Size2','$Remarks','$Name','$mobile','$cpr','$month_register','$car_type','$car_model',$uid,$serial,$month,$year,'$add_dt',$frame,$Fiber,$BD1,$vid)");
						header("Location: index.php?page=20&stat=show");
				
				
				}
				if ($_GET['stat'] == 'deleverd' ) {
						$vid 	= $_GET['vid'];
						mysql_query("UPDATE p1_vip_order SET status = 1 where vid = $vid");
						header("Location: index.php?page=20&stat=show");
					}				
			}
	//*************  End DB for page (20 )  ***********
	//*************   DB for page ( 21 )   ************* 
		if ( $_GET['page']  == 21 )
			{
				if ($_GET['stat'] == 'add' ) {
					  	$vip_name 		= $_POST['vip_name'];	
						mysql_query("INSERT INTO p1_vip (vip_name) VALUES ('$vip_name')");
						header("Location: index.php?page=21");
				}
				if ( $_GET['stat'] == 'update' ) {
						$tid = $_GET['tid'];
						$vip_name = $_POST['vip_name'];
						mysql_query("UPDATE p1_vip SET vip_name = '$vip_name' where tid = $tid");
						header("Location: index.php?page=21");
				}
				
			}
	//*************  End DB for page ( 21 )  ***********
	//*************   DB for page ( 22 )   ************* 
		if ( $_GET['page']  == 22 )
			{
				if ($_GET['stat'] == 'remove' ) {
					  	$oid 		= $_GET['oid'];	
						mysql_query("UPDATE p1_order_info SET stop1 = 1 where oid = $oid");
						header("Location: index.php?page=22");
				}
			}
	//*************  End DB for page ( 22 )  ***********
	
	//*************   DB for page ( 24 )   ************* 
		if ( $_GET['page']  == 24 )
			{
				if ($_GET['stat'] == 'update' ) {
						$status		= $_POST['status'];
					  	$oid 		= $_POST['oid'];
						$status_24  = $_POST['status_24'];
						$new_status = $_POST['new_status'];
						
						if ( $status_24  == "-1" ) {
							if ($new_status == "1" )
								{
									mysql_query("UPDATE p1_order_info SET status = 0 , delivered = 0  where oid = $oid");
								}
							if ($new_status == "2" )
								{
									mysql_query("UPDATE p1_order_info SET status = 1 , delivered = 0  where oid = $oid");
								}
							if ($new_status == "3" )
								{
									mysql_query("UPDATE p1_order_info SET status = 2 , delivered = 0  where oid = $oid");
								}
						} else{
							if ($new_status == "1" )
								{
									mysql_query("UPDATE p1_order_info SET status = 0 , delivered = 0  where oid = $oid");
									mysql_query("UPDATE p1_out_order SET stop1 = 2 where oid = $oid");
								}
							if ($new_status == "2" )
								{
									mysql_query("UPDATE p1_order_info SET status = 1 , delivered = 0  where oid = $oid");
									mysql_query("UPDATE p1_out_order SET stop1 = 2 where oid = $oid");
								}
							if ($new_status == "3"  )
								{
									mysql_query("UPDATE p1_order_info SET status = 2 , delivered = 0 where oid = $oid");
									mysql_query("UPDATE p1_out_order SET stop1 = 2 where oid = $oid");
								}

							if ($new_status == "4" )
								{
									mysql_query("UPDATE p1_out_order SET status = 1 where oid = $oid");
									mysql_query("UPDATE p1_order_info SET delivered = 0 where oid = $oid");
								}
							if ($new_status == "5" )
								{
									mysql_query("UPDATE p1_out_order SET status = 2 where oid = $oid");
									mysql_query("UPDATE p1_order_info SET delivered = 0 where oid = $oid");
								}
							if ($new_status == "6" )
								{
									mysql_query("UPDATE p1_out_order SET status = 3 where oid = $oid");
									mysql_query("UPDATE p1_order_info SET delivered = 0 where oid = $oid");
								}
							if ($new_status == "7" )
								{
									mysql_query("UPDATE p1_out_order SET status = 4 where oid = $oid");
									mysql_query("UPDATE p1_order_info SET delivered = 1 where oid = $oid");
								}
						}
						
						
						
						header("Location: index.php?page=24");
				}
			}
	//*************  End DB for page ( 24 )  ***********
	//*************   DB for page ( 25 )   ************* 
		if ( $_GET['page']  == 25) 
			{
				if ($_GET['stat'] == 'add' ) {
					  	$staff 		= $_POST['staff'];					   
						mysql_query("INSERT INTO p1_staff (staff) VALUES ('$staff')");
						header("Location: index.php?page=25");
				}
				if ( $_GET['stat'] == 'stop' ) {
						$sid = $_GET['sid'];
						mysql_query("UPDATE p1_staff SET stop_staff  = 1 where sid = $sid");	
						header("Location: index.php?page=25");
				}
				if ( $_GET['stat'] == 'update' ) {
						$sid = $_GET['sid'];
						$staff = $_POST['staff'];
						mysql_query("UPDATE p1_staff SET staff  = '$staff' where sid = $sid");
						header("Location: index.php?page=25");
				}
			}
	//*************  End DB for page ( 25 )  ***********
	//*************   DB for page ( 26 )   ************* 
		if ( $_GET['page']  == 26) 
			{
				if ($_GET['stat'] == 'addsaledb' ) {
						$did			= $_SESSION['26_did'];
						$date_name		= $_SESSION['26_date_name'];
						$create_date    = date("Y").'-'.date("m").'-'.date("d");
						$create_time	= date("H").':'.date("i");
						$uid			= $_SESSION['P1_Login_uid'];
						//$frame		= $_POST['frame'];
						//$frame_no		= $_POST['frame_no'];
						$bs				= $_POST['bs'];
						$bl				= $_POST['bl'];
						$ss				= $_POST['ss'];
						$sl				= $_POST['sl'];
						$ws				= $_POST['ws'];
						$wl				= $_POST['wl'];
						$outsidefixing	= $_POST['outsidefixing'];					
						$fiber			= $_POST['fiber'];
						$screws			= $_POST['screws'];
						$name_order		= $_POST['name_order'];
						$plate			= $_POST['plate'];
						$mobile			= $_POST['mobile'];
						
						$_SESSION['26_inv_date_name']	= $date_name;
						$_SESSION['26_inv_create_date']	= $create_date;
						$_SESSION['26_inv_create_time']	= $create_time;
					//	$_SESSION['26_inv_frame']		= $frame;
					//	$_SESSION['26_inv_frame_no']	= $frame_no;
						$_SESSION['26_inv_bs']			= $bs;
						$_SESSION['26_inv_bl']			= $bl;
						$_SESSION['26_inv_ss']			= $ss;
						$_SESSION['26_inv_sl']			= $sl;
						$_SESSION['26_inv_ws']			= $ws;
						$_SESSION['26_inv_wl']			= $wl;
						$_SESSION['26_inv_outsidefixing']= $outsidefixing;
						$_SESSION['26_inv_fiber']		= $fiber;
						$_SESSION['26_inv_screws']		= $screws;
						$_SESSION['26_inv_name_order']	= $name_order;
						$_SESSION['26_inv_plate']		= $plate;
						$_SESSION['26_inv_mobile']		= $mobile;

						
						
						
						mysql_query("INSERT INTO p1_sale (did,date_name,create_date,create_time,uid,bs,bl,ss,sl,ws,wl,fiber,screws,name_order,plate,mobile,outsidefixing) VALUES ($did,'$date_name','$create_date','$create_time',$uid,$bs,$bl,$ss,$sl,$ws,$wl,$fiber,$screws,'$name_order','$plate','$mobile',$outsidefixing)");
						
						$query = mysql_query("SELECT * FROM p1_sale order by sid desc"); 		
						$_SESSION['26_sid']		=mysql_result($query,0,"sid");
						
						
						header("Location: index.php?page=26&stat=addsale");
				}
				if ($_GET['stat'] == 'updatesaledb' ) {
						$create_date    = date("Y").'-'.date("m").'-'.date("d");
						$create_time	= date("H").':'.date("i");
						$uid			= $_SESSION['P1_Login_uid'];
						//$frame		= $_POST['frame'];
						//$frame_no		= $_POST['frame_no'];
						$bs				= $_POST['bs'];
						$bl				= $_POST['bl'];
						$ss				= $_POST['ss'];
						$sl				= $_POST['sl'];
						$ws				= $_POST['ws'];
						$wl				= $_POST['wl'];
						$outsidefixing	= $_POST['outsidefixing'];					
						$fiber			= $_POST['fiber'];
						$screws			= $_POST['screws'];
						$name_order		= $_POST['name_order'];
						$plate			= $_POST['plate'];
						$mobile			= $_POST['mobile'];
						
						$_SESSION['26_inv_date_name']	= $date_name;
						$_SESSION['26_inv_create_date']	= $create_date;
						$_SESSION['26_inv_create_time']	= $create_time;
					//	$_SESSION['26_inv_frame']		= $frame;
					//	$_SESSION['26_inv_frame_no']	= $frame_no;
						$_SESSION['26_inv_bs']			= $bs;
						$_SESSION['26_inv_bl']			= $bl;
						$_SESSION['26_inv_ss']			= $ss;
						$_SESSION['26_inv_sl']			= $sl;
						$_SESSION['26_inv_ws']			= $ws;
						$_SESSION['26_inv_wl']			= $wl;
						$_SESSION['26_inv_outsidefixing']= $outsidefixing;
						$_SESSION['26_inv_fiber']		= $fiber;
						$_SESSION['26_inv_screws']		= $screws;
						$_SESSION['26_inv_name_order']	= $name_order;
						$_SESSION['26_inv_plate']		= $plate;
						$_SESSION['26_inv_mobile']		= $mobile;

						
						mysql_query("UPDATE p1_sale SET  bs = $bs ,  bl = $bl,  ss = $ss,  sl = $sl ,  ws = $ws,  wl = $wl  ,fiber = $fiber,screws = $screws,name_order = '$name_order',plate = '$plate',mobile = '$mobile',outsidefixing = $outsidefixing  where sid = $sid");	
						
					//	mysql_query("INSERT INTO p1_sale (did,date_name,create_date,create_time,uid,bs,bl,ss,sl,ws,wl,fiber,screws,name_order,plate,mobile,outsidefixing) VALUES ($did,'$date_name','$create_date','$create_time',$uid,$bs,$bl,$ss,$sl,$ws,$wl,$fiber,$screws,'$name_order','$plate','$mobile',$outsidefixing)");
						header("Location: index.php?page=26&stat=addsale");
				}
				
				
				
				
				
		}
	//*************  End DB for page ( 26 )  ***********
	//*************   DB for page ( 27 )   ************* 
		if ( $_GET['page']  == 27) 
			{
				if ($_GET['stat'] == 'adddamagedb' ) {
						$did			= $_SESSION['27_did'];
						$date_name		= $_SESSION['27_date_name'];
						$create_date    = date("Y").'-'.date("m").'-'.date("d");
						$create_time	= date("H").':'.date("i");
						$uid			= $_SESSION['P1_Login_uid'];
						$tyid			= $_POST['tyid'];
						$sid			= $_POST['sid'];
						$plate			= $_POST['plate'];
						$plate_no_l		= $_POST['plate_no_l'];
						$plate_no_s		= $_POST['plate_no_s'];
						$reason_of_damage =  $_POST['reason_of_damage'];
						$note			= $_POST['note'];
												
						mysql_query("INSERT INTO p1_damage (did,date_name,create_date,create_time,uid,sid,plate,plate_no_l,plate_no_s,note,reason_of_damage , tyid) VALUES ($did,'$date_name','$create_date','$create_time',$uid,$sid,'$plate',$plate_no_l,$plate_no_s,'$note','$reason_of_damage' , $tyid)");
						
					

						header("Location: index.php?page=27");
				}
				
				
				if ($_GET['stat'] == 'updatedamagedb' ) {

						$tyid				= $_POST['tyid'];
						$sid				= $_POST['sid'];
						$plate				= $_POST['plate'];
						$plate_no_l			= $_POST['plate_no_l'];
						$plate_no_s			= $_POST['plate_no_s'];
						$reason_of_damage 	=  $_POST['reason_of_damage'];
						$note				= $_POST['note'];
												
					//	mysql_query("INSERT INTO p1_damage (sid,plate,plate_no_l,plate_no_s,note,reason_of_damage , tyid) VALUES ('$plate',$plate_no_l,$plate_no_s,'$note','$reason_of_damage' , $tyid)");
						
						
						mysql_query("UPDATE p1_damage SET  tyid = $tyid , sid = $sid , plate = '$plate' , plate_no_l = $plate_no_l , plate_no_s = $plate_no_s , reason_of_damage = '$reason_of_damage' , note = '$note'  where damid = ".$_SESSION["27_damid"]);	

						header("Location: index.php?page=27&stat=show_all&datec=".$_SESSION['27_date_name']);
				}
				
		}
	//*************  End DB for page ( 27 )  ***********
	//*************   DB for page ( 28 )   ************* 
		if ( $_GET['page']  == '28') {
				if ($_GET['stat'] == 'un_hide_date' ) { 
						$did = $_GET['did'];
						mysql_query("UPDATE p1_date SET  date_stop  = 0 where did = $did");	
						header("Location: index.php?page=28");
				}
			}
	//*************  End DB for page ( 28 )  ***********
	//*************   DB for page ( 61 )   ************* 
		if ( $_GET['page']  == 61) 
			{
				if ($_GET['stat'] == 'addsaledb' ) {
						$did			= $_SESSION['26_did'];
						$date_name		= $_SESSION['26_date_name'];
						$create_date    = date("Y").'-'.date("m").'-'.date("d");
						$create_time	= date("H").':'.date("i");
						$uid			= $_SESSION['P1_Login_uid'];
						//$frame		= $_POST['frame'];
						//$frame_no		= $_POST['frame_no'];
						$bs				= $_POST['bs'];
						$bl				= $_POST['bl'];
						$ss				= $_POST['ss'];
						$sl				= $_POST['sl'];
						$ws				= $_POST['ws'];
						$wl				= $_POST['wl'];
						$outsidefixing	= $_POST['outsidefixing'];					
						$fiber			= $_POST['fiber'];
						$screws			= $_POST['screws'];
						$name_order		= $_POST['name_order'];
						$plate			= $_POST['plate'];
						$mobile			= $_POST['mobile'];
						
						$_SESSION['26_inv_date_name']	= $date_name;
						$_SESSION['26_inv_create_date']	= $create_date;
						$_SESSION['26_inv_create_time']	= $create_time;
					//	$_SESSION['26_inv_frame']		= $frame;
					//	$_SESSION['26_inv_frame_no']	= $frame_no;
						$_SESSION['26_inv_bs']			= $bs;
						$_SESSION['26_inv_bl']			= $bl;
						$_SESSION['26_inv_ss']			= $ss;
						$_SESSION['26_inv_sl']			= $sl;
						$_SESSION['26_inv_ws']			= $ws;
						$_SESSION['26_inv_wl']			= $wl;
						$_SESSION['26_inv_outsidefixing']= $outsidefixing;
						$_SESSION['26_inv_fiber']		= $fiber;
						$_SESSION['26_inv_screws']		= $screws;
						$_SESSION['26_inv_name_order']	= $name_order;
						$_SESSION['26_inv_plate']		= $plate;
						$_SESSION['26_inv_mobile']		= $mobile;

						
						
						
						mysql_query("INSERT INTO p1_sale (did,date_name,create_date,create_time,uid,bs,bl,ss,sl,ws,wl,fiber,screws,name_order,plate,mobile,outsidefixing) VALUES ($did,'$date_name','$create_date','$create_time',$uid,$bs,$bl,$ss,$sl,$ws,$wl,$fiber,$screws,'$name_order','$plate','$mobile',$outsidefixing)");
						header("Location: index.php?page=61&stat=addsale");
				}
				if ($_GET['stat'] == 'updatesaledb' ) {
				
						$create_date    = date("Y").'-'.date("m").'-'.date("d");
						$create_time	= date("H").':'.date("i");
						$uid			= $_SESSION['P1_Login_uid'];
						//$frame		= $_POST['frame'];
						//$frame_no		= $_POST['frame_no'];
						$after_bs				= $_POST['bs'];
						$after_bl				= $_POST['bl'];
						$after_ss				= $_POST['ss'];
						$after_sl				= $_POST['sl'];
						$after_ws				= $_POST['ws'];
						$after_wl				= $_POST['wl'];
						$after_outsidefixing	= $_POST['outsidefixing'];					
						$after_fiber			= $_POST['fiber'];
						$after_screws			= $_POST['screws'];
						$name_order		= $_POST['name_order'];
						$plate			= $_POST['plate'];
						$mobile			= $_POST['mobile'];
						
						$sid			= $_POST['sid'];
						$bs				= $_SESSION['log_bs'];
						$bl				= $_SESSION['log_bl'];
						$ss				= $_SESSION['log_ss'];
						$sl				= $_SESSION['log_sl'];
						$ws				= $_SESSION['log_ws'];
						$wl				= $_SESSION['log_wl'];
						$outsidefixing	= $_SESSION['log_outsidefixing'];					
						$fiber			= $_SESSION['log_fiber'];
						$screws			= $_SESSION['log_screws'];
						
						
						
						
						
						
						$_SESSION['26_inv_date_name']	= $_SESSION['log_create_date'];
						$_SESSION['26_inv_create_date']	= $create_date;
						$_SESSION['26_inv_create_time']	= $create_time;
					//	$_SESSION['26_inv_frame']		= $frame;
					//	$_SESSION['26_inv_frame_no']	= $frame_no;
						$_SESSION['26_inv_bs']			= $after_bs;
						$_SESSION['26_inv_bl']			= $after_bl;
						$_SESSION['26_inv_ss']			= $after_ss;
						$_SESSION['26_inv_sl']			= $after_sl;
						$_SESSION['26_inv_ws']			= $after_ws;
						$_SESSION['26_inv_wl']			= $after_wl;
						$_SESSION['26_inv_outsidefixing']= $after_outsidefixing;
						$_SESSION['26_inv_fiber']		= $after_fiber;
						$_SESSION['26_inv_screws']		= $after_screws;
						$_SESSION['26_inv_name_order']	= $name_order;
						$_SESSION['26_inv_plate']		= $plate;
						$_SESSION['26_inv_mobile']		= $mobile;

						
						mysql_query("UPDATE p1_sale SET  bs = $after_bs ,  bl = $after_bl,  ss = $after_ss,  sl = $after_sl ,  ws = $after_ws,  wl = $after_wl  ,fiber = $after_fiber,screws = $after_screws,name_order = '$name_order',plate = '$plate',mobile = '$mobile',outsidefixing = $after_outsidefixing  where sid = $sid");	

						$Remote_Addr = getenv("REMOTE_ADDR"); 

						
						mysql_query("INSERT INTO p1_sale_log (sid,create_date,create_time,uid,befor_bs,befor_bl,befor_ss,befor_sl,befor_ws,befor_wl,befor_fiber,befor_screws,befor_outsidefixing,after_bs,after_bl,after_ss,after_sl,after_ws,after_wl,after_fiber,after_screws,after_outsidefixing,Remote_Addr) VALUES ($sid,'$create_date','$create_time',$uid,$bs,$bl,$ss,$sl,$ws,$wl,$fiber,$screws,$outsidefixing,$after_bs,$after_bl,$after_ss,$after_sl,$after_ws,$after_wl,$after_fiber,$after_screws,$after_outsidefixing,'$Remote_Addr')");
						
						
						

						header("Location: index.php?page=61&stat=addsale");
				}
				
				
				
				
				
		}
	//*************  End DB for page ( 61 )  ***********
	
?> 