<?php 


$table_name = $_SESSION['db_prefix']."_quotations";
$quote_query = "SELECT quote_no, cust_id, quote_type, quotation_date, project_no, project_place, project_description, quote_value, seller, branch FROM $table_name WHERE  status = 'quoted' AND branch = 'Gaborone' AND quote_no > '2301001' ORDER BY quote_no DESC ";
$quote_result = mySQL_query($quote_query);
$quote_num = mysql_num_rows($quote_result);
?>

<link rel="stylesheet" type="text/css" href="../css/tabs.css" />
<div class="wizard_page_middle_frame" style="width:695px; height:425px;">

<ul class="tabs">
      <li>
          <input type="radio" checked  name="tabs" id="tab1" >
          <label class="tab" for="tab1"><a class="tabs" href="quote_updateWizbase.php?branch=Gaborone&date=&p=1&s=" onclick="needToConfirm = false;">Gaborone</a></label>
<div id="tab-content1" class="tab-content animated fadeIn" style="height:375px;">    

<form id="form1" name="form1" method="get" action="quote_updateWizbase.php">
  <table width=595 border="0" align="center" cellpadding="10" cellspacing="0" bordercolor="#0066FF" border-collapse="collapse">
    <tr>
      <td width="525" valign="top" >
        <label class="label_std">Select quotation:
          &nbsp;&nbsp;(click on quote number to continue)</label>
        <div class="scroll_frame_medium" style="width:630px; height:230px;">
          <table width="595" id="table_list" class="sortable-onload-1r rowstyle-alt no-arrow " >
            <tr>
              <th width="12" style="border-right-style:hidden;">&nbsp;</th>
              <th width="75" align="left" class="sortable-numeric" >Quote no</th>
              <th width="82" align="left" class="sortable-date-dmy" >Date</th>
              <th width="75" align="left" class="sortable-numeric" >Type</th>
              <th width="101" align="left" class="sortable-text" >Branch</th>
              <th width="211" align="left" class="sortable-text" >Customer</th>
              <th width="86" align="left" class="sortable-numeric" >Value</th>
              <th width="86" align="left" class="sortable-text" >Sales rep</th>
              
            </tr>
            <?php 
	$i=0;
	$quoteTT_line = '';
	while ($i<$quote_num) {
		$a1 = mysql_result($quote_result, $i, "quote_no");
		$a2 = mysql_result($quote_result, $i, "cust_id");
			$table_name = $_SESSION['db_prefix']."_customer";
			$customer_query = "SELECT status, comp_name, bag_box, box_no, postal_place, phone, contact_1  FROM $table_name WHERE cust_id = '".$a2."' ";
			$customer_result = mySQL_query($customer_query);
			$customer_num = mysql_num_rows($customer_result);
			if ($customer_num!=0) {
			$a2a = mysql_result($customer_result, 0, "comp_name");
			$a2b = mysql_result($customer_result, 0, "bag_box");
			$a2c = mysql_result($customer_result, 0, "box_no");
			$a2d = mysql_result($customer_result, 0, "postal_place");
			$a2e = mysql_result($customer_result, 0, "phone");
			$a2f = mysql_result($customer_result, 0, "contact_1");
			$a2g = mysql_result($customer_result, 0, "status");
			}
			
		 $a3 = mysql_result($quote_result, $i, "quotation_date");
		 $a4 = mysql_result($quote_result, $i, "project_no");
		 $a5 = mysql_result($quote_result, $i, "project_place");
		 $a6 = mysql_result($quote_result, $i, "project_description");
		 $a7 = mysql_result($quote_result, $i, "quote_value");
		 $a8 = mysql_result($quote_result, $i, "quote_type");
		 $a9 = mysql_result($quote_result, $i, "branch");
		 $a10 = mysql_result($quote_result, $i, "seller");
		 
		 if ($a8=='tiles') {$a8="Tiles & Acc.";}
		 if ($a8=='trusses') {$a8="Installation";}
		 
		 $_SESSION['quote_type'] = $a8;

		$quoteTT_line = '';
		$table_name = $_SESSION['db_prefix']."_quotation_notes";
		$notes_query = "SELECT note_date, note_text FROM $table_name WHERE quote_number = '".$a1."' ORDER BY line_id DESC "; 
		$notes_result = mySQL_query($notes_query);
		$notes_num = mysql_num_rows($notes_result);
		$j=0;
		while ($j<$notes_num) {
		$note_date = mysql_result($notes_result, $j, "note_date");
		$note_text = mysql_result($notes_result, $j, "note_text"); 	
		$quoteTT_line = $quoteTT_line.'<tr><td>'.date("d-m-Y", strtotime($note_date)).'</td><td>'.$note_text.'</td><tr>';
		$j++;	
		}
		
		$customerTT ="<table id=table_tool_tip width=250 ><tr><td  width=75>Company:</td><td width=175>".$a2a."</td></tr><tr><td>Address:</td><td>".$a2b."&nbsp;".$a2c."<br>".$a2d."</td></tr><tr><td>Phone:</td><td>".$a2e."</td></tr><tr><td>Contact:</td><td>".$a2f."</td></tr></table><br><b>Click for details</b>";
		
		$quoteTT ="<table id=table_tool_tip width=300 ><tr><td  width=100>Quote no:</td><td width=175>".$a1."</td></tr><tr><td valign=top>Project no /place:</td><td>".$a4."&nbsp;".$a5."</td></tr><tr><td>Project description:</td><td>".$a6."</td></tr><tr><td>Sales rep:</td><td>".$a10."</td></tr><tr><td>Value:</td><td>P".number_format($a7, 2, '.', ',')."</td></tr><tr><td>Notes:</td><td>&nbsp;</td></tr>".$quoteTT_line."</table><br><b>Click for details</b>";	
	?>
            <tr>
              <td style="border-right-style:hidden; padding-right:0px;">Q</td>
              <td style="padding-left:0px">
               <?php if ($_SESSION['userbranch']=='Gaborone') { ?>
              <a href="quote_updateWizbase.php?quote_no=<?php echo $a1?>&cust_id=<?php echo $a2 ?>&p=2&s=1" onMouseover="ddrivetip('<?php echo $quoteTT ?>', 300)"; onMouseout="hideddrivetip()" onClick="needToConfirm = false; MM_showHideLayers('wait','','show');"><?php echo $a1?></a>
              <?php } else { ?>
              <a href="" onMouseover="ddrivetip('You need to be a <?php echo $a9 ?> branch user to change the status of this quotation.', 400)"; onMouseout="hideddrivetip()" onClick="needToConfirm = false; MM_showHideLayers('wait','','show');"><?php echo $a1?></a>
              <?php } ?>
              </td>
              <td><?php echo date("d-m-Y", strtotime($a3)) ?>&nbsp;</td>
              <td><?php echo $a8?></td>
              <td><a href="" onMouseover="ddrivetip('<?php echo $customerTT ?>', 250)"; onMouseout="hideddrivetip()"><?php echo $a9?></a></td>
              <td><a href="" onMouseover="ddrivetip('<?php echo $customerTT ?>', 250)"; onMouseout="hideddrivetip()"><?php echo $a2a?></a></td>
              <td align="right"><?php echo number_format($a7, 2, '.', ',') ?>&nbsp;</td>
              <td><?php echo $a10 ?>&nbsp;</td>
            </tr>
            <?php 
	$i++;
	}
	?>
          </table>
          <br>
        </div></td>
    </tr>
    <tr>
      <td><table width="675" height="50" align="center" id="table_button_bar">
          <tr>
            <td width="117">&nbsp;</td>
            <td width="115"><input name="p" type="hidden" id="p" value="1" />
              <input name="error" type="hidden" id="error" value="0" />
              <input name="s" type="hidden" id="s" value="1" /></td>
            <td width="99">&nbsp;</td>
            <td width="125"><input name="cancelbutton" type="button" class="imagebutton" id="cancelbutton" onClick="needToConfirm = false; cancel_confirmation(1, '../sales/sales_main.php?branch=<?php $_SESSION['userbranch']?>&date='); " value="Cancel" /></td>
            <td width="110" align="right">&nbsp;</td>
          </tr>
        </table></td>
    </tr>
  </table>
</form>
</div>
</li>
        <li>
          <input type="radio" name="tabs" id="tab2">
          <label  class="tab" for="tab2"><a class="tabs" href="quote_updateWizbase.php?branch=Francistown&date=&p=1&s="  onclick="needToConfirm = false;">Francistown</a></label>
<div id="tab-content2" class="tab-content animated fadeIn">
</div>
        </li>
        <li>
          <input type="radio" name="tabs" id="tab3">
          <label class="tab"for="tab3"><a class="tabs" href="quote_updateWizbase.php?branch=Combined&date=&p=1&s="  onclick="needToConfirm = false;">Combined</a></label>
           
 <div id="tab-content3" class="tab-content animated fadeIn">
 
          </div>
        </li>
</ul>
</div>
