<? if($_SESSION['page'] == '1' and $_SESSION['section'] == '3') { ?>
<link href="../admin.css" rel="stylesheet" type="text/css" />
<script type="text/javascript">
			window.addEvent('domready', function() { 
				new vlaDatePicker('From', { style: 'adobe_cs3',separator: '-', format: 'y/m/d'});
				new vlaDatePicker('To', { style: 'adobe_cs3',separator: '-', format: 'y/m/d'});
			});	
		</script>
        
        
        
<script src="SpryAssets/SpryValidationTextField.js" type="text/javascript"></script>
<link href="SpryAssets/SpryValidationTextField.css" rel="stylesheet" type="text/css" />
<table width="95%" border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="#F7D782">
<tr>
        <td><table width="100%" border="0" align="center" cellpadding="0" cellspacing="0" bordercolor="#EFB412">
          <tr>
            <td class="Main_Text">Delivery Plates Report</td>
            <td width="10%" class="Main_Text"><div align="right"><img src="image/more_info.gif" width="32" height="32" border="0" /></a></div></td>
          </tr>
          <tr>
            <td colspan="2">
              <? if ($_GET['stat'] == '' ) {
			  ?>
              <form action="index.php?stat=show" method="post" name="form1" id="form1">
                <br />
                <table width="95%" border="0" align="center">
                <tr>
                  <td width="15%" class="Main_Text1_case">Date From</td>
                  <td class="text_row1"><span id="sprytextfield1">
                    <label>
                    <input name="From" type="text" id="From" />
                    <span class="textfieldInvalidFormatMsg">*</span><span class="textfieldRequiredMsg">*</span></label>
                  </span></td>
                  <td width="15%" class="Main_Text1_case">Date To</td>
                  <td class="text_row1"><span id="sprytextfield2">
                  <input type="text" name="To" id="To" />
                  <span class="textfieldRequiredMsg">*</span><span class="textfieldInvalidFormatMsg">*</span></span></td>
                  <td width="150" rowspan="3"><div align="center">
                    <input name="Submit" type="submit" class="Button1" id="Submit" value="   Create   " />
                  </div></td>
                </tr>
                <tr>
                  <td class="Main_Text1_case">Time From</td>
                  <td class="text_row1"><span id="sprytextfield3">
                  <label>
                  <input name="time_from" type="text" id="time_from" value="00:00" />
                  </label>
                  <span class="textfieldRequiredMsg">*</span><span class="textfieldInvalidFormatMsg">Invalid format.</span></span></td>
                  <td class="Main_Text1_case">Time To</td>
                  <td class="text_row1"><span id="sprytextfield4">
                  <label>
                  <input name="time_to" type="text" id="time_to" value="23:59" />
                  </label>
                  <span class="textfieldRequiredMsg">*</span><span class="textfieldInvalidFormatMsg">Invalid format.</span></span></td>
                  </tr>
                <tr>
                  <td class="Main_Text1_case">Detailed</td>
                  <td class="text_row1"><label>
                    <input name="detailed" type="checkbox" id="detailed" value="1" />
                  </label></td>
                  <td class="Main_Text1_case">Chart</td>
                  <td class="text_row1"><input name="pchart" type="radio" id="radio" value="0" checked="checked" />
                  No chart
                    <input type="radio" name="pchart" id="radio2" value="1" />
  &nbsp;Pie Chart&nbsp;&nbsp;
  <input type="radio" name="pchart" id="radio3" value="2" />  
  &nbsp;Column Chart</td>
                </tr>
                <tr>
                  <td class="Main_Text1_case">Mode</td>
                  <td class="text_row1"><input name="mode_print" type="checkbox" id="mode_print" value="1" />
                    Print</td>
                  <td>&nbsp;</td>
                  <td>&nbsp;</td>
                  <td>&nbsp;</td>
                </tr>
              </table>
            
                <br />
              </form>
              <div align="center">
                <? } if ($_GET['stat'] == 'show' ) { 
					$plate_sum = 0;
					$result = mysql_query('SELECT *  FROM p1_plate_type',$db); 
					while($row = mysql_fetch_array($result)){ 
						$plate_sum = $plate_sum + 1;
						$plate_name[$plate_sum] = $row['plate_type'];
						
					
					}
				?>
                <br />
               
                <? if ($_POST['detailed'] == '') {
						  		$From = $_POST["From"];
						  		$To = $_POST["To"];
						  		$time_from = $_POST["time_from"];
						  		$time_to = $_POST["time_to"];
					
					?>
                        <br />
                        <table width="60%" border="0" align="center">
                          <tr>
                            <td class="Main_Text1">Date</td>
                            <td class="text_row1"><div align="center">From </div></td>
                            <td class="text_box_textarea"><div align="center"><? echo $From;?></div></td>
                            <td class="text_row1"><div align="center">to</div></td>
                            <td class="text_box_textarea"><div align="center"><? echo $To;?></div></td>
                          </tr>
                          <tr>
                            <td class="Main_Text1">Time</td>
                            <td class="text_row1"><div align="center">From </div></td>
                            <td class="text_box_textarea"><div align="center"><? echo $time_from;?></div></td>
                            <td class="text_row1"> <div align="center">to</div></td>
                            <td class="text_box_textarea"><div align="center"><? echo $time_to;?></div></td>
                          </tr>
                        </table>
    <br />
                      	<div align="center">
                     
                        <?
							
							for ($loop=1;$loop<=$plate_sum;$loop++)
						  		{	
									$total_all_order[$loop] = 0;
									$total_all_onsite[$loop]= 0;
								}


							$result = mysql_query("select sum(number_of_plate) ,Date_a from p1_order_info where Date_a between  '".$From."' AND '".$To."' and stop1=0 group by Date_a"); 
							$sum_nop = 0;
							while($row = mysql_fetch_array($result)){ 
					
							
							for ($loop=1;$loop<=$plate_sum;$loop++)
						  		{	
									$query1 = mysql_query("SELECT sum(number_of_plate)  number_of_plate  FROM p1_order_info where Date_a = '".$row['Date_a']."' and type1 = ".$loop." and stop1 = 0"); 		
												if (mysql_result($query1,0,"number_of_plate") *1 > 0 )
													{								
														$total_order1[$loop] = mysql_result($query1,0,"number_of_plate");	
													}else{
														$total_order1[$loop] = 0;
													}
										$total_all_order[$loop] = $total_all_order[$loop]+$total_order1[$loop];			
								}				
							
							
							
							$total_onsite= 0;
									
							

							
							for ($loop=1;$loop<=$plate_sum;$loop++)
						  		{	
									$query1 = mysql_query("SELECT sum(p1_order_info.number_of_plate) number_of_plate FROM p1_out_order INNER JOIN p1_order_info ON p1_out_order.oid = p1_order_info.oid WHERE (((p1_out_order.stop1)=1) and p1_out_order.status4_dt like '".$row['Date_a']."%' AND ((p1_out_order.status)=4) AND ((p1_order_info.Type1)= ".$loop." ))");

								$total_onsite= $total_onsite+mysql_result($query1,0,"number_of_plate");
								$total_one_onsite[$loop] = mysql_result($query1,0,"number_of_plate");
								$total_all_onsite[$loop] = $total_all_onsite[$loop]+mysql_result($query1,0,"number_of_plate");
								
								}
							$TotalAllOnsite = $TotalAllOnsite+$total_onsite;
						
							
							$AGENT_total = 0;
							for ($loop=1;$loop<=$plate_sum;$loop++)
						  		{	
									$query1 = mysql_query("SELECT sum(number_of_plate)  number_of_plate  FROM p1_order_info where Date_a = '".$row['Date_a']."' and type1 = ".$loop." and stop1 = 0 and aid <> 0"); 		
											if (mysql_result($query1,0,"number_of_plate") *1 > 0 )
												{								
													$AGENT_total = $AGENT_total+mysql_result($query1,0,"number_of_plate");
													$total_agent1[$loop] = mysql_result($query1,0,"number_of_plate");
												}else{
													$total_agent1[$loop] = 0;
												}
										$total_all_agent1[$loop] = $total_all_agent1[$loop]+$total_agent1[$loop];	
								}					
							

							$total_all_agent = $total_all_agent + $AGENT_total;
							

							$VIP_total = 0;
							for ($loop=1;$loop<=$plate_sum;$loop++)
						  		{	
								
									$query1 = mysql_query("SELECT sum(number_of_plate)  number_of_plate  FROM p1_order_info where Date_a = '".$row['Date_a']."' and type1 = ".$loop." and stop1 = 0 and vid <> 0"); 		
											if (mysql_result($query1,0,"number_of_plate") *1 > 0 )
												{								
													$VIP_total = $VIP_total+mysql_result($query1,0,"number_of_plate");
													$total_vip1[$loop] = mysql_result($query1,0,"number_of_plate");
												}else{
													$total_vip1[$loop] = 0;
												}
										$total_all_vip1[$loop] = $total_all_vip1[$loop]+$total_vip1[$loop];	
								}


							$total_all_vip = $total_all_vip + $VIP_total;
						
								$sum_nop = $sum_nop + $row['sum(number_of_plate)'];
						
							}
						?>

                         <table width="90%" border="1" align="center" bordercolor="#000000">
                          <tr>
                            <td width="10%" rowspan="2" class="Main_Text1_case">Date</td>
                            <td colspan="2" rowspan="2" class="Main_Text1_case">Plates Type</td>
                            <td colspan="<? echo $plate_sum?>" class="Main_Text1_case"><div align="center">Plate Color code</div></td>
                            <td rowspan="2" class="Main_Text1_case">Total</td>
                           </tr>
                          <tr>
                          <? for ($loop=1;$loop<=$plate_sum;$loop++)  	{	?>
                            <td class="Main_Text1_case"><? echo $plate_name[$loop];?></td>
                          <? } ?>
                          </tr>
                          
                          <tr>
                            <td rowspan="5" ><div align="center"><strong>All Date</strong></div></td>
                            <td colspan="2" class="Main_SText_case"><div align="center">ORDERED</div></td>
                            <? for ($loop=1;$loop<=$plate_sum;$loop++)  	{	?>
                           		 <td class="Main_SText_case" ><div align="center"><? echo $total_all_order[$loop]?></div></td>
                             <? 
							 	$total_all_order_loop = $total_all_order_loop +  $total_all_order[$loop];
							 } ?>
                            <td class="Main_SText_case" ><div align="center"><? echo $total_all_order_loop?></div></td>
                           </tr>
                          <tr>
                            <td rowspan="4" class="Main_color2"><div align="center">DELIVERED</div></td>
                            <td class="Main_SText_casew"><div align="center">OnSite</div></td>
                            <? for ($loop=1;$loop<=$plate_sum;$loop++)  	{	?>
                           		 <td class="Main_SText_casew" ><div align="center"><? echo $total_all_onsite[$loop]?></div></td>
                             <?  } ?>
                            <td class="Main_SText_casew" ><div align="center"><? echo $TotalAllOnsite?></div></td>
                           </tr>
                          <tr>
                            <td class="Main_SText_casew"><div align="center">AGENT</div></td>
                            <? for ($loop=1;$loop<=$plate_sum;$loop++)  	{	?>
                            <td class="Main_SText_casew" ><div align="center"><? echo $total_all_agent1[$loop];?></div></td>
                             <?  } ?>
                            <td class="Main_SText_casew" ><div align="center"><? echo $total_all_agent;?></div></td>
                           </tr>
                          <tr>
                            <td class="Main_SText_casew"><div align="center">VIPs</div></td>
                            <? for ($loop=1;$loop<=$plate_sum;$loop++)  	{	?>
                            <td class="Main_SText_casew" ><div align="center"><? echo $total_all_vip1[$loop];?></div></td>

                            <?  } ?>
                            <td class="Main_SText_casew" ><div align="center"><? echo $total_all_vip;?></div></td>
                           </tr>
                          <tr>
                            <td class="Main_color2"><div align="center">Total</div></td>
                             <? for ($loop=1;$loop<=$plate_sum;$loop++)  	{	?>
                            <td class="Main_color2"><div align="center"><? echo $total_all_onsite[$loop]+$total_all_agent1[$loop]+$total_all_vip1[$loop];?></div></td>
                            <? } ?>
                            
                            <td class="Main_color2"><div align="center"><? echo $TotalAllOnsite+$total_all_agent+$total_all_vip;?></div></td>
                          </tr>
                        </table>               	       
              </div>
                      
    				<? } else {
						  		$From = $_POST["From"];
						  		$To = $_POST["To"];
						  		$time_from = $_POST["time_from"];
						  		$time_to = $_POST["time_to"];
					
					?>
                        <br />
                        <table width="60%" border="0" align="center">
                          <tr>
                            <td class="Main_Text1">Date</td>
                            <td class="text_row1"><div align="center">From </div></td>
                            <td class="text_box_textarea"><div align="center"><? echo $From;?></div></td>
                            <td class="text_row1"><div align="center">to</div></td>
                            <td class="text_box_textarea"><div align="center"><? echo $To;?></div></td>
                          </tr>
                          <tr>
                            <td class="Main_Text1">Time</td>
                            <td class="text_row1"><div align="center">From </div></td>
                            <td class="text_box_textarea"><div align="center"><? echo $time_from;?></div></td>
                            <td class="text_row1"> <div align="center">to</div></td>
                            <td class="text_box_textarea"><div align="center"><? echo $time_to;?></div></td>
                          </tr>
                        </table>
    <br />
                      	<div align="center">
                        <table width="90%" border="1" align="center" bordercolor="#000000">
                          <tr>
                            <td width="10%" rowspan="2" class="Main_Text1_case">Date</td>
                            <td colspan="2" rowspan="2" class="Main_Text1_case">Plates Type</td>
                            <td colspan="<? echo $plate_sum?>" class="Main_Text1_case">Plate Color code</td>
                            <td rowspan="2" class="Main_Text1_case">Total</td>
                          </tr>
                          <tr>
                          	<? for ($loop=1;$loop<=$plate_sum;$loop++)
						  	{	
							?>
                            <td class="Main_Text1_case"><? echo $plate_name[$loop];?></td>
   
                            <? } ?>                          
                          </tr>
                        <?
							for ($loop=1;$loop<=$plate_sum;$loop++)
						  		{	
									$total_all_order[$loop] = 0;
									$total_all_onsite[$loop]= 0;
								}

						


							$result = mysql_query("select sum(number_of_plate),Date_a from p1_order_info where Date_a between  '".$From."' AND '".$To."' and stop1=0 group by Date_a"); 
							$sum_nop = 0;
							while($row = mysql_fetch_array($result)){ 
						?>
                          <tr>
                            <td rowspan="5"><? echo $row['Date_a'];?></td>
                            <td colspan="2" class="Main_SText_case"><div align="center">ORDERED</div></td>
                            
                            								

						<? for ($loop=1;$loop<=$plate_sum;$loop++) {  ?>
                        
                            <td class="Main_SText_case"><div align="center">
                              <? 
							
							$query1 = mysql_query("SELECT sum(number_of_plate)  number_of_plate  FROM p1_order_info where Date_a = '".$row['Date_a']."' and type1 = ".$loop." and stop1 = 0"); 		
											if (mysql_result($query1,0,"number_of_plate") *1 > 0 )
												{								
													echo mysql_result($query1,0,"number_of_plate");	
													$total_order1[$loop] = mysql_result($query1,0,"number_of_plate");	
												}else{
													echo 0;
													$total_order1[$loop] = 0;
												}
									$total_all_order[$loop] = $total_all_order[$loop]+$total_order1[$loop];			
												
							?>
                            </div></td>
                       <? } ?>     
                            

                            <td class="Main_SText_case"><div align="center"><? echo $row['sum(number_of_plate)'];?></div></td>
                          </tr>
                          <tr>
                            <td rowspan="4" class="Main_color2"><div align="center">DELIVERED</div></td>
                            <td class="Main_SText_casew"><div align="center">OnSite</div></td>
                            <?
								$total_onsite= 0;
							for ($loop=1;$loop<=$plate_sum;$loop++)
						  		{	?>
                            <td class="Main_SText_casew">
                              <div align="center">
                                <? 
								
									$query1 = mysql_query("SELECT sum(p1_order_info.number_of_plate) number_of_plate FROM p1_order_info INNER JOIN p1_out_order ON p1_order_info.oid = p1_out_order.oid WHERE p1_out_order.status4_dt  like '".$row['Date_a']."%' AND p1_out_order.status=4 AND p1_out_order.stop1=1 and Type1 = ".$loop);

									echo mysql_result($query1,0,"number_of_plate");	
									$total_onsite=  $total_onsite +mysql_result($query1,0,"number_of_plate");
									$total_one_onsite[$loop] =mysql_result($query1,0,"number_of_plate");
									$total_all_onsite[$loop] = $total_all_onsite[$loop]+mysql_result($query1,0,"number_of_plate");
								?>                           
                              </div></td>
                            <? } ?>
                         
                            <td class="Main_SText_casew"><div align="center"><? 
							echo $total_onsite;
							$TotalAllOnsite = $TotalAllOnsite+$total_onsite;
							 ?></div></td>
                          </tr>
                          <tr>
                            <td class="Main_SText_casew"><div align="center">AGENT</div></td>
                            
							<? 
							$AGENT_total = 0;
							for ($loop=1;$loop<=$plate_sum;$loop++) {	
                            ?>
                            <td class="Main_SText_casew"><div align="center">
                              <? 
							
							$query1 = mysql_query("SELECT sum(number_of_plate)  number_of_plate  FROM p1_order_info where Date_a = '".$row['Date_a']."' and type1 = ".$loop." and stop1 = 0 and aid <> 0"); 		
											if (mysql_result($query1,0,"number_of_plate") *1 > 0 )
												{								
													echo mysql_result($query1,0,"number_of_plate");	
													$AGENT_total = $AGENT_total+mysql_result($query1,0,"number_of_plate");
													$total_agent1[$loop] = mysql_result($query1,0,"number_of_plate");
												}else{
													echo 0;
													$total_agent1[$loop] = 0;
												}
										$total_all_agent1[$loop] = $total_all_agent1[$loop]+$total_agent1[$loop];	
												
							?>
                            </div></td>
                            <? } ?>
                          
                            <td class="Main_SText_casew"><div align="center"><? 
							$total_all_agent = $total_all_agent + $AGENT_total;
							
							echo $AGENT_total?></div></td>
                          </tr>
                          <tr>
                            <td class="Main_SText_casew"><div align="center">VIPs</div></td>
							<? 
							$VIP_total = 0;
							for ($loop=1;$loop<=$plate_sum;$loop++) {	
                            ?>
                            <td class="Main_SText_casew"><div align="center">
                              <? 
									$query1 = mysql_query("SELECT sum(number_of_plate)  number_of_plate  FROM p1_order_info where Date_a = '".$row['Date_a']."' and type1 = ".$loop." and stop1 = 0 and vid <> 0"); 		
											if (mysql_result($query1,0,"number_of_plate") *1 > 0 )
												{								
													echo mysql_result($query1,0,"number_of_plate");	
													$VIP_total = $VIP_total+mysql_result($query1,0,"number_of_plate");
													$total_vip1[$loop] = mysql_result($query1,0,"number_of_plate");
												}else{
													echo 0;
													$total_vip1[$loop] = 0;
												}
										$total_all_vip1[$loop] = $total_all_vip1[$loop]+$total_vip1[$loop];	
							?>
                            </div></td>
                           <? } ?>
                           
                      
                            <td class="Main_SText_casew"><div align="center"><? 
							$total_all_vip = $total_all_vip + $VIP_total;
							echo $VIP_total?></div></td>
                          </tr>
                          <tr>
                            <td class="Main_color2"><div align="center">Total</div></td>
                            <? for ($loop=1;$loop<=$plate_sum;$loop++) 	{	?>
                            <td class="Main_color2"><div align="center"><? echo $total_one_onsite[$loop]?></div></td>
                            <? } ?>
                            <td class="Main_color2"><div align="center"><? echo $total_onsite+$AGENT_total+$VIP_total;?></div></td>
                          </tr>
						<? 
						
								$sum_nop = $sum_nop + $row['sum(number_of_plate)'];
						
							}
						?>
                          </table>
                          <br />

                         <table width="90%" border="1" align="center" bordercolor="#000000">
                          <tr>
                            <td width="10%" rowspan="2" class="Main_Text1_case">Date</td>
                            <td colspan="2" rowspan="2" class="Main_Text1_case">Plates Type</td>
                            <td colspan="<? echo $plate_sum?>" class="Main_Text1_case"><div align="center">Plate Color code</div></td>
                            <td rowspan="2" class="Main_Text1_case">Total</td>
                           </tr>
                          <tr>
                          <? for ($loop=1;$loop<=$plate_sum;$loop++)  	{	?>
                            <td class="Main_Text1_case"><? echo $plate_name[$loop];?></td>
                          <? } ?>
                          </tr>
                          
                          <tr>
                            <td rowspan="5" ><div align="center"><strong>All Date</strong></div></td>
                            <td colspan="2" class="Main_SText_case"><div align="center">ORDERED</div></td>
                            <? for ($loop=1;$loop<=$plate_sum;$loop++)  	{	?>
                           		 <td class="Main_SText_case" ><div align="center"><? echo $total_all_order[$loop]?></div></td>
                             <? 
							 	$total_all_order_loop = $total_all_order_loop +  $total_all_order[$loop];
							 } ?>
                            <td class="Main_SText_case" ><div align="center"><? echo $total_all_order_loop?></div></td>
                           </tr>
                          <tr>
                            <td rowspan="4" class="Main_color2"><div align="center">DELIVERED</div></td>
                            <td class="Main_SText_casew"><div align="center">OnSite</div></td>
                            <? for ($loop=1;$loop<=$plate_sum;$loop++)  	{	?>
                           		 <td class="Main_SText_casew" ><div align="center"><? echo $total_all_onsite[$loop]?></div></td>
                             <?  } ?>
                            <td class="Main_SText_casew" ><div align="center"><? echo $TotalAllOnsite?></div></td>
                           </tr>
                          <tr>
                            <td class="Main_SText_casew"><div align="center">AGENT</div></td>
                            <? for ($loop=1;$loop<=$plate_sum;$loop++)  	{	?>
                            <td class="Main_SText_casew" ><div align="center"><? echo $total_all_agent1[$loop];?></div></td>
                             <?  } ?>
                            <td class="Main_SText_casew" ><div align="center"><? echo $total_all_agent;?></div></td>
                           </tr>
                          <tr>
                            <td class="Main_SText_casew"><div align="center">VIPs</div></td>
                            <? for ($loop=1;$loop<=$plate_sum;$loop++)  	{	?>
                            <td class="Main_SText_casew" ><div align="center"><? echo $total_all_vip1[$loop];?></div></td>

                            <?  } ?>
                            <td class="Main_SText_casew" ><div align="center"><? echo $total_all_vip;?></div></td>
                           </tr>
                          <tr>
                            <td class="Main_color2"><div align="center">Total</div></td>
                            <? for ($loop=1;$loop<=$plate_sum;$loop++)  	{	?>
                            <td class="Main_color2"><div align="center"><? echo $total_all_onsite[$loop]+$total_all_agent1[$loop]+$total_all_vip1[$loop];?></div></td>
                            <?  } ?>
                            
                            <td class="Main_color2"><div align="center"><? echo $TotalAllOnsite+$total_all_agent+$total_all_vip;?></div></td>
                          </tr>
                        </table>               	       
              </div>
                      
    				<? } ?>
                    <? if ($_POST['pchart'] == '1') {?>
                    
          <script type="text/javascript">

        var chart;
		var legend;

        var chartData = [{sumry:"Private",litres:<? echo $total_all_onsite[1]+$total_all_agent1[1]+$total_all_vip1[1];?>},
				{sumry:"Orange",litres:<? echo $total_all_onsite[2]+$total_all_agent1[2]+$total_all_vip1[2];?>},
				{sumry:"Police",litres:<? echo $total_all_onsite[3]+$total_all_agent1[3]+$total_all_vip1[3];?>},
				{sumry:"CD",litres:<? echo $total_all_onsite[4]+$total_all_agent1[4]+$total_all_vip1[4];?>},
				{sumry:"M/Cycle",litres:<? echo $total_all_onsite[5]+$total_all_agent1[5]+$total_all_vip1[5];?>},
				{sumry:"Yellow",litres:<? echo $total_all_onsite[6]+$total_all_agent1[6]+$total_all_vip1[6];?>},
				{sumry:"RC",litres:<? echo $total_all_onsite[7]+$total_all_agent1[7]+$total_all_vip1[7];?>}];

         window.onload = function() {
            chart = new AmCharts.AmPieChart();
            chart.dataProvider = chartData;
            chart.titleField = "sumry";
			chart.valueField = "litres";

			legend = new AmCharts.AmLegend();
			legend.align = "center";
			legend.markerType = "circle";
			chart.addLegend(legend);

			chart.write("chartdiv");
		}


		function setLabelPosition(){

			if(document.getElementById("rb1").checked){
				chart.labelRadius = 30;
				chart.labelText = "[[title]]: [[value]]";
			}
			else{
				chart.labelRadius = -30;
				chart.labelText = "[[percents]]%";
			}
			chart.validateNow();
		}


		function set3D(){

			if(document.getElementById("rb3").checked){
				chart.depth3D = 10;
				chart.angle = 10;
			}
			else{
				chart.depth3D = 0;
				chart.angle = 0;
			}
			chart.validateNow();
		}

		function setSwitch(){

			if(document.getElementById("rb5").checked){
				legend.switchType = "x";
			}
			else{
				legend.switchType = "v";
			}
			legend.validateNow();
		}

	    </script>
    <p>&nbsp;</p>
  			<table width="90%" border="0" align="center">
              <tr>
                <td valign="top">
                <? if ($_POST['mode_print'] == '') {  ?>
                  <table width="100%" border="0">
                    <tr>
                      <td colspan="2" class="Main_Text1_case">labels</td>
                    </tr>
                    <tr>
                      <td class="text_row1"><input type="radio" checked="true" name="group" id="rb1" onclick="setLabelPosition()" /></td>
                      <td class="Main_SText">outside</td>
                    </tr>
                    <tr>
                      <td class="text_row1"><input type="radio" name="group" id="rb2" onclick="setLabelPosition()" /></td>
                      <td class="Main_SText"> inside</td>
                    </tr>
                    <tr>
                      <td colspan="2" class="Main_Text1_case">Type of chart</td>
                    </tr>
                    <tr>
                      <td class="text_row1"><input type="radio" name="group2" id="rb3" onclick="set3D()" /></td>
                      <td class="Main_SText">3D</td>
                    </tr>
                    <tr>
                      <td class="text_row1"><input type="radio" checked="true" name="group2" id="rb4" onclick="set3D()" /></td>
                      <td class="Main_SText">2D</td>
                    </tr>
                    <tr>
                      <td colspan="2" class="Main_Text1_case">Legend switch type</td>
                    </tr>
                    <tr>
                      <td class="text_row1"><input type="radio" checked="true" name="group3" id="rb5" onclick="setSwitch()" /></td>
                      <td class="Main_SText">x</td>
                    </tr>
                    <tr>
                      <td class="text_row1"><input type="radio" name="group3" id="rb6" onclick="setSwitch()" /></td>
                      <td class="Main_SText">v </td>
                    </tr>
                  </table>
                  <? } ?>
                  <p>&nbsp;</p>
                </td>
                <td width="80%"><div id="chartdiv" style="width: 100%; height: 600px;"></div></td>
              </tr>
            </table>
    				<? } ?>
                    <? if ($_POST['pchart'] == '2') {?>
				       <script type="text/javascript">
                        
                                var chart;
                        
                                var chartData = [{plate:'Private',income:<? echo $total_all_order[1]?>,expenses:<? echo $total_all_onsite[1]+$total_all_agent1[1]+$total_all_vip1[1];?>},
                                        {plate:'Orange',income:<? echo $total_all_order[2]?>,expenses:<? echo  $total_all_onsite[2]+$total_all_agent1[2]+$total_all_vip1[2];?>},
                                        {plate:'Police',income:<? echo $total_all_order[3]?>,expenses:<? echo $total_all_onsite[3]+$total_all_agent1[3]+$total_all_vip1[3];?>},
                                        {plate:'CD',income:<? echo $total_all_order[4]?>,expenses:<? echo $total_all_onsite[4]+$total_all_agent1[4]+$total_all_vip1[4];?>},
                                        {plate:'M/Cycle',income:<? echo $total_all_order[5]?>,expenses:<? echo $total_all_onsite[5]+$total_all_agent1[5]+$total_all_vip1[5];?>},
										{plate:'Yellow',income:<? echo $total_all_order[6]?>,expenses:<? echo $total_all_onsite[6]+$total_all_agent1[6]+$total_all_vip1[6];?>},
	   								    {plate:'RC',income:<? echo $total_all_order[7]?>,expenses:<? echo $total_all_onsite[7]+$total_all_agent1[7]+$total_all_vip1[7];?>}];
                        
                        
                                window.onload = function() {
                                    chart = new AmCharts.AmSerialChart();
                                    chart.dataProvider = chartData;
                                    chart.categoryField = "plate";
                                    chart.startDuration = 1;
                                    chart.marginTop = 25;
                                    chart.marginLeft = 60;
                                    chart.rotate = true;
                        
                                    var graph1 = new AmCharts.AmGraph();
                                    graph1.title = "ORDERED";
                                    graph1.valueField = "income";
                                    graph1.type = "column";
                                    graph1.lineAlpha = 0;
                                    graph1.fillColors = "#4F81BC";
                                    graph1.fillAlphas = 1;
                                    chart.addGraph(graph1);
                        
                                    var graph2 = new AmCharts.AmGraph();
                                    graph2.title = "DELIVERED";
                                    graph2.valueField = "expenses";
                                    graph2.type = "column";
                                    graph2.lineAlpha = 0;
                                    graph2.fillColors = "#C0504E";
                                    graph2.fillAlphas = 1;
                                    chart.addGraph(graph2);
                        
                                    var catAxis = chart.categoryAxis;
                                    catAxis.gridPosition = "start";
                                    catAxis.dashLength = 5;
                        
                                    var valAxis = new AmCharts.ValueAxis();
                                    valAxis.dashLength = 5;
                                    chart.addValueAxis(valAxis);
                        
                                    var valAxis2 = new AmCharts.ValueAxis();
                                    valAxis2.position = "top";
                                    chart.addValueAxis(valAxis2);
                                    
                                    var legend = new AmCharts.AmLegend();
                                    legend.marginLeft = 50;
                                    chart.addLegend(legend);
                        
                                    chart.write("chartdiv1");
                                }
                        
                        
                                </script>
                    
                    
		                  <div align="center"><div id="chartdiv1" style="width: 90%; height: 600px;"></div></div>
                    <? } ?>
	          <br />
	          <? } ?>
            </td>
          </tr>
        </table></td>
      </tr>
</table>
<script type="text/javascript">
<!--
var sprytextfield1 = new Spry.Widget.ValidationTextField("sprytextfield1", "date", {format:"yyyy-mm-dd"});
var sprytextfield2 = new Spry.Widget.ValidationTextField("sprytextfield2", "date", {format:"yyyy-mm-dd"});
var sprytextfield3 = new Spry.Widget.ValidationTextField("sprytextfield3", "time");
var sprytextfield4 = new Spry.Widget.ValidationTextField("sprytextfield4", "time");
//-->
</script>
<? } ?>
