{include file="head.tpl"}
{include file="left.tpl"}
<table width="100%" height="100%" border="0" cellspacing="0" cellpadding="0" align="center">
<tr>
<td height="21"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><img src="images/corner9.gif" width="5" height="21"></td>
<td width="99%" class="header"><span class="whitetext">
Add Purchase Order
</span></td>
<td><img src="images/corner10.gif" width="5" height="21"></td>
</tr>
</table></td>
</tr>
<tr>
<td class="border3side" valign="top" height="100%"><table width="100%" height="100%" border="0" cellspacing="8" cellpadding="0">
<tr>
<td valign="top">
<!-- ####################### Paste the Table to Table from here ############## -->
<table cellSpacing="0" cellPadding="0" width="98%" align="center" border="0">
<tr>
<td>
{if $status == 4}
<table cellSpacing="1" cellPadding="0" width="100%" border="0">
<tr>
<td class="txt" align="center" width="20%" height="23">
<font color="RED">{$mes}{$mm}</font>
</td>
</tr>
</table>
{/if}
{if $status < 4}
<table cellSpacing="1" cellPadding="0" width="100%" border="0">
<form name="f1" action="?act=add" method="post" onSubmit="return validate();">
<tr>
{if $mm_cat ==""}
<td class="txtbox_bgcolor" width="20%"> Category Name</td>
<td class="txtbox_bgcolor" width="33%">
<select name="category" id="category" onchange="return showequip();">
<option value="">Select Category</option>
{section name=index loop=$category_id}
<option value="{$category_id[index]}" {if $cat_id==$category_id[index] } selected {/if}>{$category_name[index]}</option>
{/section}
</select>
</td>
{else}
<td class="txt" colspan="4" align="center" width="25%" height="23"><font color="RED">{$mm_cat}</font></td>
{/if}
</tr>
{if $f==5 && $cat_id != $valueofbook}
<tr>
<td class="alttxtbox_bgcolor" width="20%">
Select Equipment</td>
<td class="alttxtbox_bgcolor" width="33%">
<table width="100%" border="0">
{if $no1 > 0}
{*
############# OLD #############
<select name="equipment_id[]" id="eq_id" multiple onClick="Javascript:alert(this.value);">
<option value="" selected>-- Select Equipment --</option>
{section name=index loop=$equip_id}
<option value="{$equip_id[index]}">{$equip_name[index]} [{$equip_model[index]}] </option>
{/section}
</select>
################################
*}
{section name=index loop=$equip_id}
{if !($i++ % 2 > 0)}
<td>
{else}
<tr><td>
{/if}
{if $eq_siz > 1 }
<input type="checkbox" id="eq_id" name="equipment_id[]" value="{$equip_id[index]}" onClick="return put_val('{$equip_id[index]}', '{$equip_name[index]}')">
{else}
<input type="checkbox" id="eq_id" name="equipment_id" value="{$equip_id[index]}" onClick="return put_val('{$equip_id[index]}', '{$equip_name[index]}')">
{/if}
{$equip_name[index]} [<font color="#003366">{$equip_model[index]}</font>]
<br><br>
<div align="center" id="{$equip_id[index]}" style="width:auto;display:none; border:#999999 1px solid; background-color:#cccc99; padding:1px;">
No of Pcs for {$equip_name[index]} <input type="text" name="eq_pc[]" id="eq_pc" value="0" size="4" maxlength="3" onKeyPress="if ((event.keyCode < 48)||(event.keyCode > 57)) event.returnValue = false;">
</div>
{if !($i % 2 > 0)}
</td>
{else}
</td></tr>
{/if}
{/section}
<input type="hidden" name="h_eq" value="{$eq_siz}">
<tr><td><a href="#" onclick="sh_al()"><font color="#333333">Show All</font></a></td><td><a href="#" onclick="hd_al()"><font color="#333333">Hide All</font></a></td></tr>
{else}
<font color="RED">No Equipment Still Aded !</font>
{/if}
</table>
</td>
</tr>
<tr>
<td class="txtbox_bgcolor" width="20%">
Date</td>
<td class="txtbox_bgcolor" width="33%">
<input name="date" id="date_date" type="text" size="20" class="text" readonly />
<a href="javascript:cal4.popup();"> <img src="images/calender.gif" border="0" alt="Click to pickup date-time..."></a> </td></td>
</tr>
<tr>
<td class="alttxtbox_bgcolor" width="20%">
Vendor</td>
<td class="alttxtbox_bgcolor" width="33%">
{if $no2 > 0}
<select name="vendor_id">
<option value="">-- Select Vendor --</option>
{section name=index loop=$vendor_id}
<option value="{$vendor_id[index]}">{$vendor_name[index]}</option>
{/section}
</select>
{else}
<font color="RED">No Vendor Still Aded !</font>
{/if} </td>
</tr>
<tr>
<td class="btn_bg" colSpan="1"></td>
<td class="btn_bg" colSpan="1">
<input type="image" src="images/add_po.gif" name="add" {if $no1 ==0 || $no2==0}disabled{/if} title="add purchase order"></td>
</tr>
</table>
{else}
<table cellSpacing="1" cellPadding="0" width="100%" border="0">
<!--<tr>
<td class="txt" align="center" width="20%" bgColor="#cccccc" height="23">
<font color="RED">{$mes}</font>
</td>
</tr>-->
</table>
{/if}
{/if}
{if $cat_id== $valueofbook && $status !=4}
<table cellSpacing="1" cellPadding="0" width="100%" border="0">
{if $count_cat !=0 }
<tr>
<td class="btn_bg" colSpan="1" width="38%"></td>
<td class="btn_bg" colSpan="1">
<input type="image" src="images/add_po.gif" name="add" {if $no1==0 || $no2==0}disabled{/if} title="add purchase order"></td>
</tr>
{/if}
</table>
{/if}
</td>
</tr>
<!--<tr>
<td style="border-left: 1px solid #bbbbbb; border-right: 1px solid #bbbbbb" bgColor="#bbbbbb">
<img title height="4" alt src="images/blank.gif" width="1"></td>
</tr>-->
</table>
</td>
</tr>
</form>
</table>
<!-- ######################## End Here ##########################-->
{include file="foot.tpl"}
{literal}
<script language="Javascript">
function validate()
{
if(document.f1.category.value=="")
{
alert("Please Select A Category !");
//document.f1.equipment_id.focus();
return false;
}
//alert(document.f1.h_eq.value);
var eq = document.f1.eq_id;
var fl = 0;
if(document.f1.h_eq.value > 1)
{
for(var i=0; i<eq.length; i++)
{
if(eq[i].checked)
{
fl = 1;
}
}
}
else if(document.f1.h_eq.value==1)
{
if(document.f1.equipment_id.checked)
{
fl = 1;
}
else
{
fl = 0;
}
}
//alert(equipment_id.length);
if(fl==0)
{
alert("Please Select at least one Equipment !");
return false;
}
if(document.f1.h_eq.value > 1)
{
for(var i=0; i<eq.length; i++)
{
if(eq[i].checked)
{
if((document.f1.eq_pc[i].value=="0") || (document.f1.eq_pc[i].value=="") )
{
alert("Please enter No of Pcs !");
sh_al();
document.f1.eq_pc[i].focus();
document.f1.eq_pc[i].value.select;
return false;
break;
}
}
}
}
else
{
if(document.f1.equipment_id.checked)
{
if((document.f1.eq_pc.value=="0") || (document.f1.eq_pc.value=="") )
{
alert("Please enter No of Pcs !");
sh_al();
document.f1.eq_pc.focus();
document.f1.eq_pc.value.select;
return false;
// break;
}
}
}
if(document.f1.date.value=="")
{
alert("Please Select Date !");
document.f1.date.focus();
return false;
}
if(document.f1.vendor_id.value=="")
{
alert("Please Select a Vendor !");
document.f1.vendor_id.focus();
return false;
}
return confirm("Are you sure? The Purchase Order will be added!");
}
function showequip()
{
var a;
a=document.f1.category.value;
if(a === "")
url= "add_purchase.php";
else
url="add_purchase.php?cat_id=";
location=url+a;
}
</script>
{/literal}
{if $f==5}
{literal}
<script language="JavaScript" src="js/calendar.js"></script>
<script language="JavaScript">
var cal4 = new calendar1(document.f1.elements['date']);
cal4.year_scroll = true;
var cal5 = new calendar1(document.f1.elements['date']);
cal5.year_scroll = true;
</script>
<script language="Javascript">
function hd_al()
{
var eq = document.f1.eq_id;
var epc = document.f1.eq_pc;
var fl = 0;
for(var i=0; i<eq.length; i++)
{
if(eq[i].checked)
{
}
else
{
epc[i].value = 0;
}
document.getElementById(eq[i].value).style.display='none';
}
}
function sh_al()
{
var eq = document.f1.eq_id;
var epc = document.f1.eq_pc;
var fl = 0;
for(var i=0; i<eq.length; i++)
{
if(eq[i].checked)
{
}
else
{
epc[i].value = 0;
}
document.getElementById(eq[i].value).style.display='inline';
}
}
function put_val(i, v)
{
hd_al();
document.getElementById(i).style.display='inline';
}
</script>
{/literal}
{/if}