<?php
	include('common/header.php');
?>
		<div class="">
			<div class="col-xm-12">
				<div class="widget-box light-border">
					<div class="widget-header header-color-grey">
						<h4 class="smaller">
							Invoice
						</h4>
					</div>

					<div class="widget-body">
						<div class="widget-main">
						  <div class="row">
							<div class="col-sm-12">
							<form class="form-horizontal" name="add_employee" role="form">
								<!-- PAGE CONTENT BEGINS -->
								<div class="col-sm-12">
								<div class="col-sm-6">
									<div class="form-group">
										<label class="col-sm-5 control-label" for="form-field-1-1">Dealer Company <font color="red">*</font></label>

										<div class="col-sm-7">
											<select name="dealer_id" id="dealer_id">
												<option value="">Select Dealer Company</option>
												<option value="1">Gurudev Corporation</option>
												<option value="2">Sharp Enterprise</option>
												<option value="3">Kreedai Exim</option>
											</select>
											<?php echo form_error('dealer_id');	?>
										</div>
									</div>

									<div class="space-4"></div>

									<div class="form-group">
										<label class="col-sm-5 control-label" for="form-field-1-1">Client <font color="red">*</font></label>

										<div class="col-sm-7">
											<select name="client_id" id="client_id">
												<option value="">Select Client</option>
												<option value="1">Ganraj PVT LTD</option>
												<option value="2">ABC</option>
												<option value="3">XYZ</option>
											</select>
											<?php echo form_error('client_id');	?>
										</div>
									</div>

									<div class="space-4"></div>
									
									<div class="form-group">
										<label class="col-sm-5 control-label" for="form-field-1-1">Client Address <font color="red">*</font></label>

										<div class="col-sm-7">
											<textarea readonly rows="3" cols="20"></textarea>
										</div>
									</div>

									<div class="space-4"></div>
									
									
							</div>
							<div class="col-sm-6">
								
								<div class="form-group">
										<label class="col-sm-5 control-label" for="form-field-1-1">Agent <font color="red">*</font></label>

										<div class="col-sm-7">
											<select name="agent_id" id="agent_id">
												<option value="">Select Agent</option>
												<option value="1">ABX</option>
												<option value="2">XYU</option>
												<option value="3">ERT</option>
											</select>
											<?php echo form_error('agent_id');	?>
										</div>
									</div>

									<div class="space-4"></div>
								<div class="form-group">
									<label class="col-sm-5 control-label" for="form-field-1-1">Vessels <font color="red">*</font></label>

									<div class="col-sm-7">
										<select name="vessel_id" id="vessel_id">
											<option value="">Select Vessel</option>
											<option value="1">ABX</option>
											<option value="2">XYU</option>
											<option value="3">ERT</option>
										</select>
										<?php echo form_error('vessel_id');	?>
									</div>
								</div>
								<div class="space-4"></div>
								
							</div>
							</div>
						</form>	
							
						</div>
						</div>
					   </div>	
					</div>
				</div>
				<div class="space-4"></div>
				<div class="widget-box light-border">
					<div class="widget-header header-color-grey">
						<h4 class="smaller">
							Invoice Details
						</h4>
					</div>

					<div class="widget-body">
						<div class="widget-main">
						  <div class="row">
							<div class="col-sm-12">
							<form class="form-horizontal" role="form">
							<div class="col-sm-6">
								<!-- PAGE CONTENT BEGINS -->
									<div class="form-group">
										<label class="col-sm-5 control-label" for="form-field-2">Invoice No <font color="red">*</font></label>

										<div class="col-sm-7">
											<?php	
												$invoice_no_data=array('name'=>'invoice_no',
																	  'id'=>'invoice_no',
																	  'placeholder'=>'Invoice No',
																	  'value'=> ''
																		);
												echo form_input($invoice_no_data,'');
												echo form_error('invoice_no');
											?>
										</div>
									</div>
									<div class="space-4"></div>
									
									<!--<div class="form-group">
										<label class="col-sm-5 control-label" for="form-field-2">Dispatched Challan No <font color="red">*</font></label>

										<div class="col-sm-7">
											<?php	
												$invoice_no_data=array('name'=>'challan_no',
																	  'id'=>'challan_no',
																	  'placeholder'=>'Dispatched Challan No',
																	  'value'=> ''
																		);
												echo form_input($invoice_no_data,'');
												echo form_error('challan_no');
											?>
										</div>
									</div>
									<div class="space-4"></div>-->
									
									<div class="form-group">
										<label class="col-sm-5 control-label" for="form-field-2">Dispatched From <font color="red">*</font></label>

										<div class="col-sm-7">
											<?php	
												$dispatched_from_data=array('name'=>'dispatched_from',
																	  'id'=>'dispatched_from',
																	  'placeholder'=>'Dispatched From',
																	  'value'=> ''
																		);
												echo form_input($dispatched_from_data,'');
												echo form_error('dispatched_from');
											?>
										</div>
									</div>

									<div class="space-4"></div>
									
									<div class="form-group">
										<label class="col-sm-5 control-label" for="form-field-2">Unloaded At <font color="red">*</font></label>

										<div class="col-sm-7">
											<?php	
												$unloaded_at_data=array('name'=>'unloaded_at',
																	  'id'=>'unloaded_at',
																	  'placeholder'=>'Unloaded At',
																	  'value'=> ''
																		);
												echo form_input($unloaded_at_data,'');
												echo form_error('unloaded_at');
											?>
										</div>
									</div>

									<div class="space-4"></div>
							</div>
							<div class="col-sm-6">
								<!-- PAGE CONTENT BEGINS -->
								
									<div class="form-group">
										<label class="col-sm-5 control-label" for="form-field-2">Invoice Date <font color="red">*</font></label>

										<div class="col-sm-7">	
										<?php	
											$period_data=array('name'=>'invoice_date',
																	 'id'=>'invoice_date',
																	 'maxlength'=>'10',
																	 'placeholder'=>'Invoice Date',
																	 'value'=> ''
																	);
											echo form_input($period_data,'');
											echo form_error('invoice_date');
										?>
									</div>
									</div>
									
									<div class="space-4"></div>
									
									<!--<div class="form-group">
										<label class="col-sm-5 control-label" for="form-field-2">Dispatched Challan Date <font color="red">*</font></label>

										<div class="col-sm-7">	
										<?php	
											$period_data=array('name'=>'challan_date',
																	 'id'=>'challan_date',
																	 'maxlength'=>'10',
																	 'placeholder'=>'Challan Date',
																	 'value'=> ''
																	);
											echo form_input($period_data,'');
											echo form_error('challan_date');
										?>
									</div>
									</div>
									
									<div class="space-4"></div>-->
							
									<div class="form-group">
										<label class="col-sm-5 control-label" for="form-field-2">Dispatched To <font color="red">*</font></label>

										<div class="col-sm-7">
											<?php	
												$dispatched_to_data=array('name'=>'dispatched_to',
																	  'id'=>'dispatched_to',
																	  'placeholder'=>'Dispatched To',
																	  'value'=> ''
																		);
												echo form_input($dispatched_to_data,'');
												echo form_error('dispatched_to');
											?>
										</div>
									</div>

									<div class="space-4"></div>
									
									<div class="form-group">
										<label class="col-sm-5 control-label" for="form-field-2">Truck No <font color="red">*</font></label>

										<div class="col-sm-7">
											<?php	
												$truk_no_data=array('name'=>'truk_no',
																	  'id'=>'truk_no',
																	  'placeholder'=>'Truck No',
																	  'value'=> ''
																		);
												echo form_input($truk_no_data,'');
												echo form_error('truk_no');
											?>
										</div>
									</div>

									<div class="space-4"></div>
									
							</div>
						</form>	
							
						</div>
						</div>
					   </div>	
					</div>
				</div>
				<div class="space-4"></div>
				<div class="widget-box light-border">
					<div class="widget-header header-color-grey">
						<h4 class="smaller">
							Payment Conditions
						</h4>
					</div>

					<div class="widget-body">
						<div class="widget-main">
						  <div class="row">
							<div class="col-sm-12">
							<form class="form-horizontal" name="add_employee" role="form">
								<!-- PAGE CONTENT BEGINS -->
								<div class="col-sm-12">
								<div class="col-sm-6">
									<div class="form-group">
										<label class="col-sm-5 control-label" for="form-field-2">Credit Days <font color="red">*</font></label>

										<div class="col-sm-7">
											<?php	
												/* $credit_days_data=array('name'=>'credit_days',
																	  'id'=>'credit_days',
																	  'placeholder'=>'Credit Days',
																	  'value'=> ''
																		);
												echo form_input($credit_days_data,'');
												echo form_error('credit_days'); */
											?>
											<select name="credit_days" id="credit_days">
												<option value="">Select Credit Days</option>
												<option value="1">1 - 3 Months</option>
												<option value="2">4 - 6 Months</option>
												<option value="3">7 - 9 Months</option>
												<option value="4">10 - 12 Months</option>
											</select>
											<?php echo form_error('credit_days');	?>
										</div>
									</div>
									<div class="space-4"></div>
									<div class="form-group">
										<label class="col-sm-5 control-label" for="form-field-2">Payment Reminder Start Days<font color="red">*</font></label>

										<div class="col-sm-7">
											<?php	
												$credit_days_data=array('name'=>'payment_reminder_start_days',
																	  'id'=>'payment_reminder_start_days',
																	  'placeholder'=>'Payment Reminder Start Days',
																	  'value'=> ''
																		);
												echo form_input($credit_days_data,'');
												echo form_error('payment_reminder_start_days');
											?>
										</div>
									</div>

									<div class="space-4"></div>
									<div class="form-group">
										<label class="col-sm-5 control-label" for="form-field-2">Payment Reminder Frequency<font color="red">*</font></label>

										<div class="col-sm-7">
											<select name="payment_reminder_frequency" id="payment_reminder_frequency">
												<option value="">Select Payment Reminder Frequency</option>
												<option value="1">Daily</option>
												<option value="2">Weekly</option>
												<option value="3">Monthly</option>
											</select>
											<?php	
												echo form_error('payment_reminder_frequency');
											?>
										</div>
									</div>

									<div class="space-4"></div>
									
							</div>
							<div class="col-sm-6">
								<div class="form-group">
										<label class="col-sm-5 control-label" for="form-field-2">Part Payment Percentage <font color="red">*</font></label>

										<div class="col-sm-7">
											<?php	
												$truk_no_data=array('name'=>'percentage_of_amt',
																	  'id'=>'percentage_of_amt',
																	  'placeholder'=>'Percentage of Total Amount',
																	  'value'=> ''
																		);
												echo form_input($truk_no_data,'');
												echo form_error('percentage_of_amt');
											?>
										</div>
									</div>

									<div class="space-4"></div>
									<div class="form-group">
										<label class="col-sm-5 control-label" for="form-field-2">No of Days within Part Payment to be Received <font color="red">*</font></label>

										<div class="col-sm-7">
											<?php	
												$credit_days_data=array('name'=>'per_no_of_days',
																	  'id'=>'per_no_of_days',
																	  'placeholder'=>'No of Days',
																	  'value'=> ''
																		);
												echo form_input($credit_days_data,'');
												echo form_error('per_no_of_days');
											?>
										</div>
									</div>

									<div class="space-4"></div>
								</div>
							</div>
						</form>	
							
						</div>
						</div>
					   </div>	
					</div>
				</div>
				<div class="space-4"></div>
				<div class="widget-box light-border">
					<div class="widget-header header-color-grey">
						<h4 class="smaller">
							Invoice Items Description
							
						</h4>
					</div>

					<div class="widget-body">
						<div class="widget-main">
						  <div class="row">
							<div class="col-sm-12">
							<div class="table-responsive">
							<table  cellspacing="0" width="100%" id="invoice_items" class="table table-bordered dataTable no-footer">
								<thead>		
									<tr>
										<th class="text-color-label">Item Description</th>
										<th class="text-color-label">HSN Code</th>
										<th class="text-color-label">Qty Pieces</th>
										<th class="text-color-label">Volume</th>
										<th class="text-color-label" nowrap>CBM / CFT</th>
										<th class="text-color-label">Rate</th>
										<th class="text-color-label">Amount (IN INR)</th>
									</tr>	
								</thead>
								<tbody>	
									<tr id="tr_1">
										<td class="text-color-value">
											<?php	
												$description_data=array('name'=>'description[1]',
																	  'id'=>'description_1',
																	  'placeholder'=>'Description',
																	  'value'=> ''
																		);
												echo form_input($description_data,'');
												echo form_error('description');
											?>
										</td>
										<td class="text-color-value">
											<select name="hsn_code[1]" id="hsn_code_1">
												<option value="">Select HSN Code</option>
												<option value="4407">4407</option>
												<option value="4403">4403</option>
											</select>
											<?php	
												echo form_error('hsn_code');
											?>
										</td>
										<td class="text-color-value">
											<?php	
												$quantity_data=array('name'=>'quantity[1]',
																	  'id'=>'quantity_1',
																	  'placeholder'=>'Qty Pieces',
																	  'value'=> ''
																		);
												echo form_input($quantity_data,'');
												echo form_error('quantity');
											?>
										</td>
										<td class="text-color-value">
											<?php	
												$volume_data=array('name'=>'volume[1]',
																	  'id'=>'volume_1',
																	  'placeholder'=>'Volume',
																	  'value'=> ''
																		);
												echo form_input($volume_data,'');
												echo form_error('volume');
											?>
										</td>
										<td nowrap class="text-color-value">
											<label class="line-height-1 blue inline">
												<input name="volume_type[1]" value="cbm" type="radio" class="ace">
												<span class="lbl"> CBM </span>
											</label>
											<label class="line-height-1 blue inline">
												<input name="volume_type[1]" value="cft" type="radio" class="ace">
												<span class="lbl"> CFT </span>
											</label>
										</td>
										<td class="text-color-value">
											<?php	
												$rate_data=array('name'=>'rate[1]',
																	  'id'=>'rate_1',
																	  'placeholder'=>'Rate',
																	  'value'=> ''
																		);
												echo form_input($rate_data,'');
												echo form_error('rate');
											?>
										</td>
										<td class="text-color-value">
											<?php	
												$amount_data=array('name'=>'amount[1]',
																	  'id'=>'amount_1',
																	  'placeholder'=>'Amount',
																	  'value'=> ''
																		);
												echo form_input($amount_data,'');
												echo form_error('amount');
											?>
										</td>
									</tr>
									
									</tbody>
									
									<tfoot>
										<tr>
											<td colspan="7" class="text-color-value text-right"><a href="javascript:void(0);" onclick="add_more();">Add More</a></td>
										</tr>
										<tr>
											
											<td colspan="4" rowspan="5" class="text-right text-color-label"></td>
											<td colspan="2" class="text-center text-color-label"><b>TOTAL SALE VALUE</b></td>
											<td class="total_sale_val text-color-value">
												<?php	
													$grand_total_amount_data=array('name'=>'total_sale_value',
																		  'id'=>'total_sale_value',
																		  'value'=> '0.000',
																		  'readonly' => 'readonly'
																			);
													echo form_input($grand_total_amount_data,'');
													echo form_error('total_sale_value');
												?>
											</td>
										</tr>
										<tr>
											<td colspan="1" class="text-center text-color-label"><b>Add CGST @</b></td>
											<td class="text-color-label text-center mgst"><b>9%</b></td>
											<td class="text-color-value cgst">
												<?php	
													$grand_total_amount_data=array('name'=>'cgst_value',
																		  'id'=>'cgst_value',
																		  'value'=> '0.000',
																		  'readonly' => 'readonly'
																			);
													echo form_input($grand_total_amount_data,'');
													echo form_error('cgst_value');
												?>
											</td>
										</tr>
										<tr>
											<td colspan="1" class="text-center text-color-label"><b>Add SGST @</b></td>
											<td class="text-color-label text-center mgst"><b>9%</b></td>
											<td class="text-color-value sgst">
												<?php	
													$grand_total_amount_data=array('name'=>'sgst_value',
																		  'id'=>'sgst_value',
																		  'value'=> '0.000',
																		  'readonly' => 'readonly'
																			);
													echo form_input($grand_total_amount_data,'');
													echo form_error('sgst_value');
												?>
											</td>												
										</tr>
										<tr>
											<td colspan="1" class="text-center text-color-label"><b>Add IGST @</b></td>
											<td class="text-color-label text-center igst"><b>18%</b></td>
											<td class="text-color-value igst">
												<?php	
													$grand_total_amount_data=array('name'=>'igst_value',
																		  'id'=>'igst_value',
																		  'value'=> '0.000',
																		  'readonly' => 'readonly'
																			);
													echo form_input($grand_total_amount_data,'');
													echo form_error('igst_value');
												?>
											</td>
										</tr>
										<tr>
											<td colspan="2" class="text-right text-color-label"><b>TOTAL SALE VALUE WITH GST</b></td>
											<td class="text-color-value total_sale_gst_val">
												<?php	
													$grand_total_amount_data=array('name'=>'total_sale_gst_value',
																		  'id'=>'total_sale_gst_value',
																		  'value'=> '0.000',
																		  'readonly' => 'readonly'
																			);
													echo form_input($grand_total_amount_data,'');
													echo form_error('total_sale_gst_value');
												?>
											</td>
										</tr>
									</tfoot>
								</table>
							</div>
							</div>
						</div>
					   </div>	
					</div>
				</div>
				</div>
			</div>
      	<!-- /.col -->
		</div>
		<div class="clearfix form-actions">
			<div class="col-md-offset-5 col-md-5">
				<a href="<?php echo base_url();?>index.php/<?php echo INVOICE_PATH;?>view_invoice/confirm">
				<button class="btn btn-info" type="submit">
					<?php echo ucfirst($purpose)?> Invoice
				</button>
				</a>
			</div>
		</div>
		<div class="space-4"></div>
		<!-- /.page-row -->
        <!-- /.page-content --> 
      </div>
      <!-- /.main-content --> 
      
    </div>
    <!-- /#ace-settings-container --> 
  </div>
  
  <!-- /.main-container-inner --> 
 <script type="text/javascript">
$(document).ready(function() {
    $('form:first *:input[type!=hidden]:first').focus();

    $( "#invoice_date" ).datepicker({
		changeMonth: true,
		changeYear: true,
		showOn: "button",
			  buttonImage: "<?php echo ASSETS_PATH;?>images/calendar.jpg",
			  buttonImageOnly: true,
			  buttonText: "Select date",
		dateFormat:'dd/mm/yy'	
	});
	$( "#challan_date" ).datepicker({
		changeMonth: true,
		changeYear: true,
		showOn: "button",
			  buttonImage: "<?php echo ASSETS_PATH;?>images/calendar.jpg",
			  buttonImageOnly: true,
			  buttonText: "Select date",
		dateFormat:'dd/mm/yy'	
	});
	
});
function add_more()
{
	var i = $('#invoice_items tbody tr').size() + 1;
	$("#invoice_items tbody").append('<tr id="tr_'+i+'">'+
										'<td class="text-color-value">'+
											'<input type="text" name="description['+i+']" id="description_'+i+'" value="" placeholder="Description">'+
										'</td>'+
										'<td class="text-color-value">'+
											'<select name="hsn_code['+i+']" id="hsn_code_'+i+'">'+
												'<option value="">Select HSN Code</option>'+
												'<option value="4407">4407</option>'+
												'<option value="4403">4403</option>'+
											'</select>'+
										'</td>'+
										'<td class="text-color-value">'+
											'<input type="text" name="quantity['+i+']" id="quantity_'+i+'" value="" placeholder="Qty Pieces">'+
										'</td>'+
										'<td class="text-color-value">'+
											'<input type="text" name="volume['+i+']" id="volume_'+i+'" value="" placeholder="Volume">'+
										'</td>'+
										'<td class="text-color-value">'+
											'<label class="line-height-1 blue inline">'+
												'<input name="volume_type['+i+']" value="cbm" type="radio" class="ace">'+
												'<span class="lbl"> CBM </span>'+
											'</label> '+
											'<label class="line-height-1 blue inline">'+
												'<input name="volume_type['+i+']" value="cft" type="radio" class="ace">'+
												'<span class="lbl"> CFT </span>'+
											'</label>'+
										'</td>'+
										'<td class="text-color-value">'+
											'<input type="text" name="rate['+i+']" id="rate_'+i+'" value="" placeholder="Rate">'+
										'</td>'+
										'<td class="text-color-value">'+
											'<input type="text" name="amount['+i+']" id="amount_'+i+'" value="" placeholder="Amount" style="float:left;">&nbsp;<a href="javascript:void(0);" id="remScnt_'+i+'" onclick="remove_row('+i+');"><i class="fa fa-times"></i></a>'+
										'</td>'+
										
									'</tr>');
}
function remove_row(i)
{
	$('#tr_'+i).remove();
	i--;
	return false;
}
</script>
<?php
	include('common/footer.php');
?>