<?php
if(isset($_POST['Save']))
	{
	$path = "Add_file/";
	if(!empty($_FILES['add_file']['name']))
	{
	$name = $_FILES['add_file']['name']; 
	$tmp = $_FILES['add_file']['tmp_name'];
	move_uploaded_file($tmp, $path.$name);				
	}
	$time=$_REQUEST['setup_time']." ".$_REQUEST['start_AMPM'];
	
	$data['code']=$_REQUEST['code'];
	$data['name']=$_REQUEST['name'];
	$data['under_group']=$_REQUEST['under_group'];
	$data['sr_no']=$_REQUEST['sr_no'];
	$data['model_no']=$_REQUEST['model_no'];
	$data['chesis_no']=$_REQUEST['chesis_no'];
	$data['warranty_type']=$_REQUEST['warranty_type'];
	$data['add_file']=$name;
	$data['start_period']=FormatDateForSQL($_REQUEST['start_period']);
	$data['end_period']=FormatDateForSQL($_REQUEST['end_period']);
	$data['status']=$_REQUEST['status'];
	$data['amc_on_value']=$_REQUEST['amc_on_value'];
	$data['amc_per']=$_REQUEST['amc_per'];
	$data['emi_year']=$_REQUEST['emi_year'];
	$data['fule_type']=$_REQUEST['fuel_type'];
	$data['one_day_capacity']=$_REQUEST['one_day_capacity'];
	$data['setup_time']=$time;
	$data['average_production_qty']=$_REQUEST['average_production_qty'];
	$data['accounting_group']=$_REQUEST['accounting_group'];
	$data['depriciation_ac_gl']=$_REQUEST['depriciation_ac_gl'];
	$data['sale_status']=$_REQUEST['sale_status'];
	$data['sale_amount']=$_REQUEST['sale_amount'];
	$data['sale_date']=FormatDateForSQL($_REQUEST['sale_date']);
	$data['sale_party']=$_REQUEST['sale_party'];
	$data['accumulative_depriciation']=$_REQUEST['accumlative_depriciation'];
	$data['total_till_date']=$_REQUEST['total_till_date'];
	$data['location']=$_REQUEST['location'];
	$data['insatallation_by']=$_REQUEST['installation_by'];
	$data['date']=FormatDateForSQL($_REQUEST['date']);
	$data['CompanyId']=$_SESSION['ACGCompanyId'];
	$s->RecordInsert('machine_center', $data);
	$s->pageLocation("index.php?route=view_machine_center".$rurl);
}
?>
<link rel="stylesheet" href="css/new_mxerp.css">
<div class="body_contain">
<div class="tab_div">
<h1>Machine Center Master</h1>
<form action="" method="post" enctype="multipart/form-data">
<table width="100%" border="0" cellpadding="3" cellspacing="0">
<tr class="row1">
	<td colspan="4"><h3>Machine Details</h3></td>
</tr>
<tr class="row1">
        <td class="tabledata1">Code</td>
        <td>
          <input type="text" name="code" id="code" style="width:150px;" />
        </td>
		<td class="tabledata1" scope="row">Name</td>
        <td><input type="text" name="name" id="name" style="width:150px;"/></td>
</tr>
<tr class="row1">
        <td class="tabledata1" scope="row">Under Group</td>
        <td>
        <select name="under_group"  id="under_group" style="width:150px;" >
        <option value="0">Select</option>	
        <?php $sql="select * from machine_group_master";
		$query=DB_query($sql,$db);
		while($row1=DB_fetch_array($query))
		{
			?>
			<option value="<?php echo $row1['id']; ?>"><?php echo $row1['machine_gp_location']; ?></option>
		<?php }	?>
        	
        </select>	
        	
        	</td>
		<td class="tabledata1" scope="row">Sr. No.</td>
        <td><input type="text" name="sr_no" id="sr_no" style="width:150px;"/></td>

</tr>
<tr class="row1">
        <td class="tabledata1" scope="row">Model No.</td>
        <td><input type="text" name="model_no" id="model_no" style="width:150px;"/></td>
		<td class="tabledata1" scope="row">Chesis No.</td>
        <td><input type="text" name="chesis_no" id="Chesis_no" style="width:150px;"/></td>
</tr>
<tr class="row1">
	<td colspan="4"><h3>Warranty</h3></td>
</tr>
<tr class="row1">
        <td class="tabledata1">Warranty Type</td>
        <td><select name="warranty_type" id="warranty_type" style="width:150px;">
        <option value="0">--Select---</option>
        <option value="Annual">Annual</option>
		</select></td>
		<td class="tabledata1">Add File</td>
        <td><input type="file" name="add_file" id="add_file" style="width:150px;" /></td>

</tr>
<tr class="row1">
        <td class="tabledata1">Start Period</td>
        <td><input type="text" name="start_period" id="start_period" style="width:150px;" class="datepicker"/> 
        <td class="tabledata1">End Period</td>
        <td><input type="text" name="end_period" id="end_period" style="width:150px;" class="datepicker"/></td>
</tr>
<tr class="row1">
        <td class="tabledata1">Status</td>
        <td><input type="text" name="status" id="status" style="width:150px;"/></td>
		<td class="tabledata1">AMC On Value</td>
        <td><input type="text" name="amc_on_value" id="amc_on_value" style="width:150px;"/></td>
</tr>
<tr class="row1">
        <td class="tabledata1">AMC %</td>
        <td><input type="text" name="amc_per" id="amc_per" style="width:150px;"/></td>
		<td class="tabledata1">EMI Of Year</td>
        <td><input type="text" name="emi_year" id="emi_year" style="width:150px;"/></td>
</tr>
<tr class="row1">
	<td colspan="4"><h3>Running Capacity</h3></td>
</tr>
<tr class="row1">
	<td class="tabledata1">Fuel Type</td>
    <td><select name="fuel_type" style="width:150px;" id="fuel_type">
        	<option value="0">---Select---</option>	
        	<option value="Petrol">Petrol</option>	
        	<option value="Diesel">Diesel</option>	
        	<option value="Cng">CNG</option>	
        	</select></td>
	<td class="tabledata1">One Day</td>
	<td><input type="text" name="one_day_capacity" id="one_day" style="width:150px;"/></td>

</tr>
<tr class="row1">
	<td class="tabledata1">Setup Time</td>
	<td><input type="text" name="setup_time" id="setup_time" style="width:150px;"/>
	<select name="start_AMPM" id="start_AMPM" style="width:40px">
	<option value="AM"<?php echo ($row1['start_AMPM']=='AM'?'selected':'')?>>AM</option>
	<option value="PM"<?php echo ($row1['start_AMPM']=='PM'?'selected':'')?>>PM</option>
	</select>
	</td>
	<td class="tabledata1">Average Production Qty</td>
	<td><input type="text" name="average_production_qty" id="average_production_qty" style="width:150px;"/></td>
</tr>
<tr class="row1">
	<td colspan="4"><h3>Asset Manager</h3></td>
</tr>
<tr class="row1">
	<td class="tabledata1">Accounting Group</td>
    <td><select name="accounting_group" id="accounting_group" style="width:150px;" >
        <option value="0">Select </option>
        <?php 
        $sql2="select * from accountcategory_master where categoryName='ASSETS'";
		$query1=DB_query($sql2,$db);
		while($rowdata=DB_fetch_array($query1))
		{
		$sqlassect="select * from accountgroupmaster where MainGroupId='".$rowdata['id']."'";
		$sqlquery=DB_query($sqlassect,$db);
		while($row2=DB_fetch_array($sqlquery))
		{?>
			<option value="<?php echo $row2['GroupId']; ?>"><?php echo $row2['GroupName']; ?></option>	
        <?php } }?>	 	
        	
        </select></td>
		        <td class="tabledata1">Depriciation Account GL Link</td>
        <td>
        	 <select name="depriciation_ac_gl" id="depriciation_ac_gl" style="width:150px;" >
        <option value="0">Select </option>
        <?php 
        $sql2="select * from accountcategory_master where categoryName='ASSETS'";
		$query1=DB_query($sql2,$db);
		while($rowdata=DB_fetch_array($query1))
		{
		$sqlassect="select * from accountgroupmaster where MainGroupId='".$rowdata['id']."'";
		$sqlquery=DB_query($sqlassect,$db);
		while($row2=DB_fetch_array($sqlquery))
		{?>
			<option value="<?php echo $row2['GroupId']; ?>"><?php echo $row2['GroupName']; ?></option>	
        <?php } }?>	 	        	
        </select>	    	
        </td>

</tr>
<tr class="row1">
        <td class="tabledata1">Sale Status</td>
        <td><input type="text" name="sale_status" id="sale_status" style="width:150px;"/></td>
		<td class="tabledata1">Sale Amount</td>
        <td><input type="text" name="sale_amount" id="sale_amount" style="width:150px;"/></td>
</tr>
<tr class="row1">
	<td class="tabledata1">Sale Date</td>
	<td><input type="text" name="sale_date" id="sale_date" style="width:150px;" class="Datepicker"/></td>
	<td class="tabledata1">Sale Party</td>
    <td><select name="sale_party" id="sale_party" style="width:150px;">
        		<option value="0">Select</option>
         <?php $vendor=DB_query("select vendor_code,vendor_name from suppliers",$db);
        	   while($vendor_row=DB_fetch_array($vendor)){?>
         <option value="<?php echo $vendor_row['vendor_code']; ?>"><?php echo $vendor_row['vendor_name']; ?></option>	
        <?php } ?>  
        </select></td>
</tr>
<tr class="row1">
        <td class="tabledata1">Accumulative Depriciation Amt.</td>
        <td><input type="text" name="accumlative_depriciation" id="accumlative_depriciation" style="width:150px;"/></td>
		<td class="tabledata1">Total Till Date Net Gross Block Amt.</td>
        <td><input type="text" name="total_till_date" id="total_till_date" style="width:150px;"/></td>
</tr>
<tr class="row1">
	<td colspan="4"><h3>Location</h3></td>
</tr>
<tr class="row1">
        <td class="tabledata1">Location</td>
        <td><select name="location" id="location" style="width:150px;">
    <option value="0">All Branches</option>
     <?php 
		$site_sql = "Select loccode, locationname from locations where CompanyId='".$_SESSION['ACGCompanyId']."' and loccode in('".$_SESSION['AssignedBranch']."')";
		$site_result = DB_query($site_sql,$db);
		while($site_row = DB_fetch_array($site_result))
		{
		?>
         <option value="<?php echo $site_row['loccode']; ?>" ><?php echo $site_row['locationname']; ?></option>
            <?php } ?>
    </select></td>
	<td class="tabledata1">Installation By</td>
	<td><input type="text" name="installation_by" id="installation_by" style="width:150px;"/></td>
</tr>
<tr class="row1">
	<td class="tabledata1" scope="row">Date</td>
	<td colspan="3"><input type="text" name="date" id="date" style="width:150px;" class="datepicker"/></td>

</tr>
<tr class="row1">
	<td colspan="4"><p align="center"><input type="submit" name="Save" value="Save" class="search" /></p></td>
</tr>
</table>
</form>
</div>
</div>