<head>
<?php   
require_once('../include/tc_calendar.php');

$table_name = $_SESSION['db_prefix']."_quotations";
$quote_query = "SELECT cust_id, company_contact, contact_phone, seller, quotation_date, project, project_no, project_description, finalised, result, notes, project_place, priority, value  FROM $table_name WHERE quote_no ='".$_SESSION['quote_no']."' ";
$quote_result = mySQL_query($quote_query);


$cust_id = mysql_result($quote_result, 0, "cust_id");
$company_contact = mysql_result($quote_result, 0, "company_contact");
$contact_phone = mysql_result($quote_result, 0, "contact_phone");
$seller = mysql_result($quote_result, 0, "seller");
$quotation_date = mysql_result($quote_result, 0, "quotation_date");

$project = mysql_result($quote_result, 0, "project");
$project_no = mysql_result($quote_result, 0, "project_no");
$project_place = mysql_result($quote_result, 0, "project_place");
$project_description = mysql_result($quote_result, 0, "project_description");
$a10 = mysql_result($quote_result, 0, "finalised");
$a11 = mysql_result($quote_result, 0, "result");
$a12 = mysql_result($quote_result, 0, "notes");

$_SESSION['saved_priority'] = mysql_result($quote_result, 0, "priority");
$_SESSION['priority'] = mysql_result($quote_result, 0, "priority");
$quote_value = mysql_result($quote_result, 0, "value");

$quote_no = $_SESSION['quote_no'];
$job_card_no='';
$quote='yes';

$table_name = $_SESSION['db_prefix']."_quotation_notes";  
$notes_query = "SELECT  *   FROM $table_name WHERE quote_number = '".$_SESSION['quote_no']."' ORDER BY note_date DESC  ";
$notes_result = mySQL_query($notes_query);
$notes_num = mysql_num_rows($notes_result);



      $table_name = $_SESSION['db_prefix']."_customer";
      $customer_query = "SELECT status, account_type, comp_name, name_2, title, bag_box, box_no, postal_place, phone, cell_1  FROM $table_name WHERE cust_id = '".$cust_id."' ";
      $customer_result = mySQL_query($customer_query);
      $customer_num = mysql_num_rows($customer_result);
      if ($customer_num!=0) {
      $type = mysql_result($customer_result, 0, "account_type");
      if ($type=="corporate") { 
        $a2a = mysql_result($customer_result, 0, "comp_name"); 
      } 
      else {
        $a2a = mysql_result($customer_result, 0, "title")." ".mysql_result($customer_result, 0, "name_2")." ".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, "cell_1");
      $a2g = mysql_result($customer_result, 0, "status");
      $a2h="";
      }
      else {
      $a2a='';
      }

$custTT_header = '<b>Customer details:</b><br><table width=250px;>';
$custTT_body= '<tr><td >Customer:</td><td>'.$a2a.'</td></tr><tr><td valign=top>Address:</td><td valign=top>'.$a2b.' '.$a2c.'<br>'.$a2d.'</td></tr><tr><td >Phone:</td><td>'.$a2e.'</td></tr><tr><tr><td >Contact:</td><td>'.$company_contact.'</td></tr><tr><tr><td >Contact phone:</td><td>'.$contact_phone.'</td></tr><tr>';
$custTT_foot = '</table>';
$custTT = $custTT_header.$custTT_body.$custTT_foot;

$projectTT_header = '<b>Project details:</b><br><table width=250px;>';
$projectTT_body= '<tr><td >Project:</td><td>'.$project.'</td></tr><tr><td valign=top>Project location:</td><td valign=top>'.$project_no.' '.$project_place.'<br>'.$a2d.'</td></tr><tr><td >Quote no:</td><td>'.$quote_no.'</td></tr><tr><tr><td >Quote value:</td><td>'.$quote_value.'</td></tr><tr><tr><td >Project description:</td><td>'.$project_description.'</td></tr><tr>';
$projectTT_foot = '</table>';
$projectTT = $projectTT_header.$projectTT_body.$projectTT_foot;

require_once ('../include/tc_calendar.php');
$start = strtotime($_SESSION['entry_date']);
$d = date("d", $start );
$m = date("m", $start );
$y = date("Y", $start );


$table_name = $_SESSION['db_prefix']."_list_sellers";
$suppliersQuery = "SELECT item_name FROM $table_name  ORDER BY item_name ASC";
  $suppliersResult = execsql($suppliersQuery);
  $suppliersNum = mysql_num_rows($suppliersResult);
  $w = 0;
  $arrId2 = array ();
  $arrName2 = array ();
  while ($w < $suppliersNum) {
    $arrId2[$w] = mysql_result($suppliersResult, $w, "item_name");
    $arrName2[$w] = mysql_result($suppliersResult, $w, "item_name");
    $w++;
  }

$table_name = $_SESSION['db_prefix']."_list_quote_validity";
    $position_query = "SELECT item_name FROM $table_name ORDER BY item_name ASC";
  $arrId3 = array ();
  $arrName3 = array ();
  $position_result = execsql($position_query);
  if ($position_result!="") {
  $position_num = mysql_num_rows($position_result);
  $k = 0;
  while ($k < $position_num) {
    $arrId3[$k] = mysql_result($position_result, $k, "item_name");
    $arrName3[$k] = mysql_result($position_result, $k, "item_name");
    $k++;
  }
  }

  
?>

<!--jscript-->
<script language="JavaScript" src="../jscript/tooltip.js"  type="text/javascript"></script> 
<script language="javascript" src="../jscript/calendar.js"></script>
<script language="JavaScript" src="../jscript/gen_validatorv4.js"  type="text/javascript" xml:space="preserve"></script>
<script language="JavaScript" src="../jscript/alert_message.js"  type="text/javascript"></script>

<!--style sheets-->
<link rel="stylesheet" type="text/css" href="../css/tooltip.css" />
<script type="text/javascript">
function MM_showHideLayers() { //v9.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) 
  with (document) if (getElementById && ((obj=getElementById(args[i]))!=null)) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}
</script>
</head>
<?php include('../include/wait.php') ?>
<body onLoad="MM_showHideLayers('wait','','hide')" onFocus="MM_showHideLayers('wait','','hide');">

<form id="feedbackform" method="get" action="quote_updateWiz6.php" >
<div class="page_middle_frame">

   <div class="wizard_frame">
             <?php 
       if ($_SESSION['name']=='Bill of quantity') {
         echo 'Bill of quantity';
       }
       else {
        ?>
                <table width="600" id="table_details_display">
  <tr>
    <td width="86">Project:</td>
    <td width="146"><a href=" " onMouseover="ddrivetip('<?php echo  $projectTT?>', 250)"; onMouseout="hideddrivetip()" onClick="needToConfirm = false;"><?php echo $project ?></a></td>
    <td width="96">Customer:</td>
    <td width="252"><a href=" " onMouseover="ddrivetip('<?php echo  $custTT?>', 250)"; onMouseout="hideddrivetip()" onClick="needToConfirm = false;"><?php echo $a2a ?></a></td>
  </tr>
  <tr>
    <td>Sales rep:</td>
    <td><?php echo $seller ?>
      <input type="hidden" name="seller_text" id="seller_text" value="<?php echo $seller ?>">
      </td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
</table>
<?php
  }
?>
</div>
 <br>
 <div class="wizard_frame">
      <table width="633" border="0" cellspacing="0" cellpadding="0">
            <tr>
              <td width="131" height="30"><label class="label_std">Entry date:</label>
              </td>
              <td colspan="3"><?php 
          //instantiate class and set properties
    $myCalendar = new tc_calendar("entry_date", true);
    $myCalendar->setIcon("../images/iconCalendar.gif");
    $myCalendar->setDate($d, $m, $y);
    $myCalendar->setYearInterval(2010, 2099);
    //output the calendar
    $myCalendar->writeScript();
?>
              <br /></td>
            </tr>
            <tr>
              <td height="43">Priority:</td>
              <td colspan="3"><label>
                <input type="radio" name="priority_group" value="Cold" id="priority_group_0" <?php if ($_SESSION['priority']=='Cold') {?> checked=checked <?php } ?> />
                <img src="../images/flame_blue.png" width="24" height="24">Cold</label>
                <label>
                  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                  <input type="radio" name="priority_group" value="Warm" id="priority_group_1"<?php if ($_SESSION['priority']=='Warm') {?> checked=checked <?php } ?> />
                  <img src="../images/flame_orange.png" width="24" height="24"> Warm</label>
                <label>
                  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="radio" name="priority_group" value="Hot" id="priority_group_2" <?php if ($_SESSION['priority']=='Hot'){ ?> checked=checked <?php } ?> />
              <img src="../images/flame_red.png" width="24" height="24"> Hot</label></td>
            </tr>
            
        <tr>
              <td height="52">Status:</td>
              <td colspan="3" valign="middle">
                <input type="radio" name="status_group" value="quoted" id="status_group_0" <?php if ($_SESSION['status']=="quoted") { ?> checked="checked" <?php } ?> />
                  Pending
                &nbsp;&nbsp;&nbsp;&nbsp;
                <input type="radio" name="status_group" value="unsuccessful" id="status_group_1" <?php if ($_SESSION['status']=="unsuccessful") { ?> checked="checked" <?php } ?>/>
                  Unsuccessful
                  &nbsp;&nbsp;&nbsp;&nbsp;
                
                  <input name="status_group" type="radio" id="status_group_2" onClick="alertMessage(2, '../quote_updateWizbase.php?p=3&s=', 'You have set this quote to successful. You need to complete the -Create job wizard- (which follows when you click next) to set it successful.<br><br>If this wizard is not completed, the quotation will stay listed as pending.'); " value="successful"  <?php if ($_SESSION['status']=="successful") { ?>checked="checked" <?php } ?>/>
                  Successful
                </td>
             </tr>
            <tr>
              <td height="50"><label class="label_std">Entered by:&nbsp;&nbsp;<label class="star">*</label></label></td>
              <td colspan="3"><select name="seller_select" id="seller_select" class="select300">
                <option value="<?php echo $_SESSION['seller']?>" selected="selected"><?php echo $_SESSION['seller']?></option>
                <?php 
      for ($w = 0; $w < count($arrId2); $w++) {
    echo "<option value=\"".$arrId2[$w] . "\"" . ">" . $arrName2[$w] . "</option>";  
      }
     ?>
              </select>
              <br /></td>
            </tr>
        
    <tr>
      <td width="131" valign="top"><label class="label_std">Notes: &nbsp;&nbsp;</label>
        <label class="star">*</label></td>
      <td width="502" valign="top"><label for="textarea"></label>
        <textarea name="notes_text" cols="80" rows="5" class="text_box" id="notes_text"><?php echo  $_SESSION['notes'];  ?></textarea></td>
    </tr>
</table>          
          </div>
            
            <br />
            <div class="wizard_frame">
              <div align="left">Notes:</div>
              <table width="650" id="table_details_display">
                <tr>
                  <td width="80" height="25">Date:</td>
                  <td width="142">&nbsp;Entry by:</td>
                  <td width="412">Note:&nbsp;</td>
                </tr>
               <?php
         $i=0;
         while ($i<$notes_num) {
           $c1 = mysql_result($notes_result, $i, "note_date");  
           $c2 = mysql_result($notes_result, $i, "note_text");  
           $c3 = mysql_result($notes_result, $i, "seller"); 
           ?>  
                <tr>
                  <td height="25"><?php echo date("d-m-Y", strtotime($c1 ))?></td>
                  <td><?php echo $c3 ?></td>
                  <td><?php echo str_replace("\'", "'", $c2);   ?></td>
                </tr>
                  <?php 
          $i++;
         }?>
              </table>
            </div>
           
            
            <div class="wizard_frame">
            <table  id="table_button_bar">
                <tr>
                  <td width="117"><input type="button" name="lastprev_button" class="imagebutton" value="Prev" onClick="needToConfirm = false;MM_showHideLayers('wait','','show');MM_goToURL('parent','quote_updateWizbase.php?s=&amp;p=1');return document.MM_returnValue" tabindex="2"/></td>
                  <td width="115">&nbsp;</td>
                  <td width="99"><input name="p" type="hidden" id="p" value="2" />
                    <input name="s" type="hidden" id="s" value="2" />
                  </td>
                  <td width="63" align="right"><input name="cancelbutton" type="button" class="imagebutton" id="cancelbutton" onClick="needToConfirm = false; cancel_confirmation(1, '../sales/sales_main.php?date='); " value="Cancel" tabindex="3"/></td>
                  <td width="86" align="right" valign="middle"><input type="submit" name="new_button" class="imagebutton" id="new_button" value="New" onClick="needToConfirm = false;MM_showHideLayers('wait','','show')" /></td>
                  <td width="142" align="right" valign="middle"><input  name="finish_button" type="submit" class="imagebutton" id="finish_button" value="Finish" onClick="needToConfirm = false;MM_showHideLayers('wait','','show'); "  /></td>
                </tr>
              </table>
 </div>
 

</div>
</form>


<script language="JavaScript" type="text/javascript" xml:space="preserve">
  var frmvalidator  = new Validator("feedbackform");
  frmvalidator.EnableMsgsTogether();
  frmvalidator.addValidation("priority_group","selone","- select priority.");
  frmvalidator.addValidation("status_group","selone","- select status.");
  frmvalidator.addValidation("seller_select","req","- select sales rep.");
  frmvalidator.addValidation("notes_text","req","- enter a note.");
</script>

  
    </body>