1019 lines
37 KiB
PHP
1019 lines
37 KiB
PHP
<?php
|
|
$cv = $this->controller->view_data["custom_values"];
|
|
$data=array();
|
|
//print_r($cv);
|
|
$CustomVal = '';
|
|
$Secondary = '';
|
|
|
|
//echo $quoteid;
|
|
//echo($qid);
|
|
|
|
if($quoteid == '' && $qid != '')
|
|
{
|
|
$quo = $qid;
|
|
}
|
|
|
|
else if($qid == '' && $quoteid != '')
|
|
{
|
|
$quo = $quoteid;
|
|
}
|
|
|
|
else if($quoteid != '' || $qid != '')
|
|
{
|
|
$quo = $qid;
|
|
}
|
|
|
|
else
|
|
{
|
|
$quo = '';
|
|
}
|
|
|
|
|
|
|
|
|
|
if(!empty($Duedate))
|
|
{
|
|
foreach ($Duedate as $Due)
|
|
{
|
|
$CustomVal = $Due->client_custom_fieldvalue;
|
|
}
|
|
}
|
|
|
|
|
|
if(!empty($GetSecondary))
|
|
{
|
|
foreach ($GetSecondary as $GetSec)
|
|
{
|
|
$Secondary = $GetSec->Secondary;
|
|
}
|
|
|
|
|
|
}
|
|
|
|
$inv_st='';
|
|
//print_r($inv_status);
|
|
|
|
foreach($inv_status as $st)
|
|
{
|
|
$inv_st= $st->invoice_status_id;
|
|
}
|
|
|
|
//echo $inv_st;
|
|
|
|
$primarystatecode='';
|
|
foreach ($GetClientPrimaryStateCode as $primary)
|
|
{
|
|
$primarystatecode=$primary->client_custom_fieldvalue;
|
|
}
|
|
|
|
$secondarystatecode='';
|
|
|
|
foreach ($GetClientSecondaryStateCode as $secondary)
|
|
{
|
|
$secondarystatecode=$secondary->client_custom_fieldvalue;
|
|
}
|
|
|
|
|
|
|
|
|
|
//print_r($fields);
|
|
// echo $secondarystatecode;
|
|
// echo $primarystatecode;
|
|
//print_r($custom_fields);
|
|
|
|
// echo $CustomVal ;
|
|
?>
|
|
|
|
|
|
|
|
<script>
|
|
$(function () {
|
|
$('.item-task-id').each(function () {
|
|
// Disable client chaning if at least one item already has a task id assigned
|
|
if ($(this).val().length > 0) {
|
|
$('#invoice_change_client').hide();
|
|
return false;
|
|
}
|
|
});
|
|
|
|
$('.btn_add_product').click(function () {
|
|
$('#modal-placeholder').load(
|
|
"<?php echo site_url('products/ajax/modal_product_lookups'); ?>/" + Math.floor(Math.random() * 1000)
|
|
);
|
|
});
|
|
|
|
$('.btn_add_task').click(function () {
|
|
$('#modal-placeholder').load("<?php echo site_url('tasks/ajax/modal_task_lookups/' . $invoice_id); ?>/" + Math.floor(Math.random() * 1000));
|
|
});
|
|
|
|
$('.btn_add_row').click(function () {
|
|
$('#new_row').clone().appendTo('#item_table').removeAttr('id').addClass('item').show();
|
|
});
|
|
|
|
<?php if (!$items) { ?>
|
|
$('#new_row').clone().appendTo('#item_table').removeAttr('id').addClass('item').show();
|
|
<?php } ?>
|
|
|
|
$('#btn_create_recurring').click(function () {
|
|
$('#modal-placeholder').load(
|
|
"<?php echo site_url('invoices/ajax/modal_create_recurring'); ?>",
|
|
{
|
|
invoice_id: <?php echo $invoice_id; ?>
|
|
}
|
|
);
|
|
});
|
|
|
|
$('#invoice_change_client').click(function () {
|
|
|
|
$('#modal-placeholder').load("<?php echo site_url('invoices/ajax/modal_change_client'); ?>", {
|
|
invoice_id: <?php echo $invoice_id; ?>,
|
|
client_id: "<?php echo $this->db->escape_str($invoice->client_id); ?>"
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$('#btn_save_invoice').click(function () {
|
|
|
|
if(valuecheck())
|
|
{
|
|
// alert('if');
|
|
|
|
var items = [];
|
|
//alert();
|
|
var item_order = 1;
|
|
$('table tbody#new_row').each(function () {
|
|
//$('table tbody.item').each(function () {
|
|
//alert('each fm')
|
|
var row = {};
|
|
$(this).find('input,select,textarea').each(function () {
|
|
|
|
if ($(this).is(':checkbox')) {
|
|
row[$(this).attr('name')] = $(this).is(':checked');
|
|
} else {
|
|
|
|
var aa=$(this).attr('name');
|
|
|
|
var cleanedQuestionText = aa.replace(/[0-9]/g, '');
|
|
//alert(cleanedQuestionText);
|
|
// row[$(this).attr('name')] = $(this).val();
|
|
row[cleanedQuestionText] = $(this).val();
|
|
|
|
|
|
}
|
|
|
|
});
|
|
|
|
row['item_order'] = item_order;
|
|
item_order++;
|
|
items.push(row);
|
|
|
|
|
|
});
|
|
|
|
//console.log(items);
|
|
//return false;
|
|
var qu= $('#quoteid').val();
|
|
var quo = $('#quote').val();
|
|
|
|
if(qu == "")
|
|
{
|
|
quoteid=0;
|
|
}
|
|
|
|
else
|
|
{
|
|
quoteid=qu;
|
|
}
|
|
|
|
// alert(quoteid);
|
|
// die();
|
|
|
|
$.post("<?php echo site_url('invoices/ajax/save'); ?>", {
|
|
|
|
qu:$('#quote').val(),
|
|
invoice_id: <?php echo $invoice_id; ?>,
|
|
invoice_number: $('#invoice_number').val(),
|
|
invoice_date_created: $('#invoice_date_created').val(),
|
|
invoice_date_due: $('#invoice_date_due').val(),
|
|
invoice_status_id: $('#invoice_status_id').val(),
|
|
invoice_password: $('#invoice_password').val(),
|
|
items: JSON.stringify(items),
|
|
invoice_discount_amount: $('#invoice_discount_amount').val(),
|
|
invoice_discount_percent: $('#invoice_discount_percent').val(),
|
|
invoice_terms: $('#invoice_terms').val(),
|
|
quoteid : quoteid,
|
|
custom: $('input[name^=custom],select[name^=custom]').serializeArray(),
|
|
payment_method: $('#payment_method').val(),
|
|
deletestatus:$('#deletestatus').val()
|
|
|
|
},
|
|
|
|
function (data) {
|
|
//console.log(data);
|
|
|
|
<?php echo(IP_DEBUG ? 'console.log(data);' : ''); ?>
|
|
|
|
//console.log(data);
|
|
var response = JSON.parse(data);
|
|
|
|
|
|
if (response.success === 1) {
|
|
window.location = "<?php echo site_url('invoices/view'); ?>/" + <?php echo $invoice_id; ?>;
|
|
} else {
|
|
$('#fullpage-loader').hide();
|
|
$('.control-group').removeClass('has-error');
|
|
$('div.alert[class*="alert-"]').remove();
|
|
var resp_errors = response.validation_errors,
|
|
all_resp_errors = '';
|
|
for (var key in resp_errors) {
|
|
$('#' + key).parent().addClass('has-error');
|
|
all_resp_errors += resp_errors[key];
|
|
}
|
|
$('#invoice_form').prepend('<div class="alert alert-danger">' + all_resp_errors + '</div>');
|
|
}
|
|
});
|
|
}
|
|
});
|
|
|
|
$('#btn_generate_pdf').click(function () {
|
|
window.open('<?php echo site_url('invoices/generate_pdf/' . $invoice_id); ?>', '_blank');
|
|
});
|
|
|
|
<?php if ($invoice->is_read_only != 1): ?>
|
|
var fixHelper = function (e, tr) {
|
|
var $originals = tr.children();
|
|
var $helper = tr.clone();
|
|
$helper.children().each(function (index) {
|
|
$(this).width($originals.eq(index).width())
|
|
});
|
|
return $helper;
|
|
};
|
|
|
|
$("#item_table").sortable({
|
|
items: 'tbody',
|
|
helper: fixHelper
|
|
});
|
|
per=$('#invoice_discount_percent').val();
|
|
|
|
if(per==undefined)
|
|
{
|
|
|
|
}
|
|
else
|
|
{
|
|
if ($('#invoice_discount_percent').val().length > 0) {
|
|
$('#invoice_discount_amount').prop('disabled', true);
|
|
}
|
|
if ($('#invoice_discount_amount').val().length > 0) {
|
|
$('#invoice_discount_percent').prop('disabled', true);
|
|
}
|
|
}
|
|
$('#invoice_discount_amount').keyup(function () {
|
|
if (this.value.length > 0) {
|
|
$('#invoice_discount_percent').prop('disabled', true);
|
|
} else {
|
|
$('#invoice_discount_percent').prop('disabled', false);
|
|
}
|
|
});
|
|
$('#invoice_discount_percent').keyup(function () {
|
|
if (this.value.length > 0) {
|
|
$('#invoice_discount_amount').prop('disabled', true);
|
|
} else {
|
|
$('#invoice_discount_amount').prop('disabled', false);
|
|
}
|
|
});
|
|
<?php endif; ?>
|
|
|
|
});
|
|
</script>
|
|
|
|
<?php
|
|
echo $modal_delete_invoice;
|
|
echo $modal_add_invoice_tax;
|
|
if ($this->config->item('disable_read_only') == true) {
|
|
$invoice->is_read_only = 0;
|
|
}
|
|
?>
|
|
<style>
|
|
.form-group {
|
|
margin-bottom: -0px !important;
|
|
}
|
|
</style>
|
|
<div id="headerbar">
|
|
<h3 class="headerbar-title">
|
|
<a href="<?php echo site_url('clients/view/' . $invoice->client_id); ?>">
|
|
<?php _htmlsc(format_client($invoice)) ?>
|
|
</a>
|
|
<?php if ($invoice->invoice_status_id == 1 && !$invoice->creditinvoice_parent_id) { ?>
|
|
<span id="invoice_change_client" class="fa fa-edit cursor-pointer small"
|
|
data-toggle="tooltip" data-placement="bottom"
|
|
title="<?php _trans('change_client'); ?>"></span>
|
|
<?php } ?>
|
|
</h3>
|
|
|
|
|
|
<div class="headerbar-item pull-right <?php if ($invoice->is_read_only != 1 || $invoice->invoice_status_id != 4) { ?>btn-group<?php } ?>">
|
|
|
|
<table>
|
|
<tr>
|
|
|
|
<td style="padding-right:2%;">
|
|
<!-- <?php print_r($invoice_statuses)?> -->
|
|
<select name="invoice_status_id" id="invoice_status_id"
|
|
class="form-control btn-group btn-group-sm simple-select"
|
|
<?php if ($invoice->is_read_only == 1 && $invoice->invoice_status_id == 4) {
|
|
echo 'disabled="disabled"';
|
|
} ?>>
|
|
|
|
<?php foreach ($invoice_statuses as $key => $status) { ?>
|
|
<option value="<?php echo $key; ?>"
|
|
<?php if ($key == $invoice->invoice_status_id) { ?>selected="selected"<?php } ?>>
|
|
<?php echo $status['label']; ?>
|
|
</option>
|
|
<?php } ?>
|
|
</select>
|
|
</td>
|
|
<td> <div class="options btn-group btn-group-sm">
|
|
<a class="btn btn-sm btn-default dropdown-toggle" data-toggle="dropdown" href="#">
|
|
<i class="fa fa-caret-down no-margin"></i> <?php _trans('options'); ?>
|
|
</a>
|
|
<ul class="dropdown-menu">
|
|
<?php if ($invoice->is_read_only != 1) { ?>
|
|
<li>
|
|
<a href="#add-invoice-tax" data-toggle="modal">
|
|
<i class="fa fa-plus fa-margin"></i> <?php _trans('add_invoice_tax'); ?>
|
|
</a>
|
|
</li>
|
|
<?php } ?>
|
|
|
|
|
|
<?php if(($inv_st == "2")&&($invoice->is_read_only !='1')) {?>
|
|
|
|
|
|
<li>
|
|
<a href="#" id="btn_create_credit" data-invoice-id="<?php echo $invoice_id; ?>">
|
|
<i class="fa fa-minus fa-margin"></i> <?php _trans('create_credit_invoice'); ?>
|
|
</a>
|
|
</li>
|
|
|
|
|
|
<?php }?>
|
|
|
|
<?php if ($invoice->invoice_balance != 0) : ?>
|
|
<li>
|
|
<a href="#" class="invoice-add-payment"
|
|
data-invoice-id="<?php echo $invoice_id; ?>"
|
|
data-invoice-balance="<?php echo $invoice->invoice_balance; ?>"
|
|
data-invoice-payment-method="<?php echo $invoice->payment_method; ?>">
|
|
<i class="fa fa-credit-card fa-margin"></i>
|
|
<?php _trans('enter_payment'); ?>
|
|
</a>
|
|
</li>
|
|
<?php endif; ?>
|
|
<li>
|
|
<a href="#" id="btn_generate_pdf"
|
|
data-invoice-id="<?php echo $invoice_id; ?>">
|
|
<i class="fa fa-print fa-margin"></i>
|
|
<?php _trans('download_pdf'); ?>
|
|
</a>
|
|
</li>
|
|
<li>
|
|
<a href="<?php echo site_url('mailer/invoice/' . $invoice->invoice_id); ?>">
|
|
<i class="fa fa-send fa-margin"></i>
|
|
<?php _trans('send_email'); ?>
|
|
</a>
|
|
</li>
|
|
<li class="divider"></li>
|
|
<li>
|
|
<a href="#" id="btn_create_recurring"
|
|
data-invoice-id="<?php echo $invoice_id; ?>">
|
|
<i class="fa fa-repeat fa-margin"></i>
|
|
<?php _trans('create_recurring'); ?>
|
|
</a>
|
|
</li>
|
|
<li>
|
|
<a href="#" id="btn_copy_invoice"
|
|
data-invoice-id="<?php echo $invoice_id; ?>">
|
|
<i class="fa fa-copy fa-margin"></i>
|
|
<?php _trans('copy_invoice'); ?>
|
|
</a>
|
|
</li>
|
|
<?php if ($invoice->invoice_status_id == 1 || ($this->config->item('enable_invoice_deletion') === true && $invoice->is_read_only != 1)) { ?>
|
|
<li>
|
|
<a href="#delete-invoice" data-toggle="modal">
|
|
<i class="fa fa-trash-o fa-margin"></i>
|
|
<?php _trans('delete'); ?>
|
|
</a>
|
|
</li>
|
|
<?php } ?>
|
|
</ul>
|
|
</div>
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
</table>
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
<div class="headerbar-item invoice-labels pull-right">
|
|
<?php if ($invoice->invoice_is_recurring) { ?>
|
|
<span class="label label-info"><?php _trans('recurring'); ?></span>
|
|
<?php } ?>
|
|
<?php if ($invoice->is_read_only == 1) { ?>
|
|
<span class="label label-danger">
|
|
<i class="fa fa-read-only"></i> <?php _trans('read_only'); ?>
|
|
</span>
|
|
<?php } ?>
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div id="content">
|
|
|
|
|
|
<?php echo $this->layout->load_view('layout/alerts'); ?>
|
|
|
|
<!-- <?php print_r($custom_fields)?> -->
|
|
<form id="invoice_form">
|
|
<div class="invoice">
|
|
|
|
<div class="row">
|
|
<div class="col-xs-12 col-sm-6 col-md-5">
|
|
|
|
<div class="col-md-6" id="BillingAddress">
|
|
<div class="client-address">
|
|
<p><b>Primary Address</b></p>
|
|
<?php $this->layout->load_view('clients/partial_client_address', array('client' => $invoice)); ?>
|
|
</div>
|
|
</div>
|
|
<div class="col-md-6" id='SecondayAddress' style="display:none;">
|
|
<div >
|
|
<p><b>Shipping Address</b></p>
|
|
<div class="client-address">
|
|
<?php echo $Secondary; ?>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<input type="hidden" id="statecode" value="" name="statecode"/>
|
|
|
|
<?php if ($custom_fields): ?>
|
|
<div class="row" id='NewAddress' style="display:none;">
|
|
<div class="col-xs-12">
|
|
<div class="panel panel-default">
|
|
|
|
<div class="panel-body" style="padding: 7px;">
|
|
<div class="row">
|
|
|
|
<div class="col-xs-12 col-md-4">
|
|
|
|
<?php foreach ($custom_fields as $custom_field): ?>
|
|
<?php if ($custom_field->custom_field_location != 0) {
|
|
continue;
|
|
} ?>
|
|
|
|
<?php if ($custom_field->custom_field_order == 7): ?>
|
|
<?php print_field($this->mdl_invoices, $custom_field, $cv); ?>
|
|
<?php endif; ?>
|
|
<?php if ($custom_field->custom_field_order == 9): ?>
|
|
<?php print_field($this->mdl_invoices, $custom_field, $cv); ?>
|
|
<?php endif; ?>
|
|
<?php if ($custom_field->custom_field_order == 13): ?>
|
|
<?php print_field($this->mdl_invoices, $custom_field, $cv); ?>
|
|
<?php endif; ?>
|
|
<?php endforeach; ?>
|
|
</div>
|
|
<div class="col-xs-12 col-md-4">
|
|
<!-- <?php print_r($custom_fields)?> -->
|
|
<?php foreach ($custom_fields as $custom_field): ?>
|
|
<?php if ($custom_field->custom_field_location != 0) {
|
|
continue;
|
|
} ?>
|
|
|
|
<?php if ($custom_field->custom_field_order == 8): ?>
|
|
<?php print_field($this->mdl_invoices, $custom_field, $cv); ?>
|
|
<?php endif; ?>
|
|
<?php if ($custom_field->custom_field_order == 10): ?>
|
|
<?php print_field($this->mdl_invoices, $custom_field, $cv); ?>
|
|
<?php endif; ?>
|
|
|
|
|
|
|
|
|
|
<?php if ($custom_field->custom_field_order == 14): ?>
|
|
<?php print_field($this->mdl_invoices, $custom_field, $cv); ?>
|
|
|
|
|
|
<?php endif; ?>
|
|
|
|
<?php endforeach; ?>
|
|
</div>
|
|
<div class="col-xs-12 col-md-4">
|
|
|
|
<?php foreach ($custom_fields as $custom_field): ?>
|
|
<?php if ($custom_field->custom_field_location != 0) {
|
|
continue;
|
|
} ?>
|
|
|
|
<?php if ($custom_field->custom_field_order == 11): ?>
|
|
<?php print_field($this->mdl_invoices, $custom_field, $cv); ?>
|
|
<?php endif; ?>
|
|
<?php if ($custom_field->custom_field_order == 12): ?>
|
|
<?php print_field($this->mdl_invoices, $custom_field, $cv); ?>
|
|
<?php endif; ?>
|
|
<?php if ($custom_field->custom_field_order == 15): ?>
|
|
<?php print_field($this->mdl_invoices, $custom_field, $cv); ?>
|
|
<?php endif; ?>
|
|
<?php endforeach; ?>
|
|
</div>
|
|
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
</div>
|
|
</div>
|
|
<?php endif; ?>
|
|
|
|
|
|
<?php if ($invoice->client_phone || $invoice->client_email) : ?>
|
|
<hr>
|
|
<?php endif; ?>
|
|
<?php if ($invoice->client_phone): ?>
|
|
<div>
|
|
<?php _trans('phone'); ?>:
|
|
<?php _htmlsc($invoice->client_phone); ?>
|
|
</div>
|
|
<?php endif; ?>
|
|
<?php if ($invoice->client_email): ?>
|
|
<div>
|
|
<?php _trans('email'); ?>:
|
|
<?php echo $invoice->client_email; ?>
|
|
</div>
|
|
<?php endif; ?>
|
|
|
|
</div>
|
|
|
|
<div class="col-xs-12 visible-xs"><br></div>
|
|
|
|
<div class="col-xs-12 col-sm-5 col-md-7 ">
|
|
<div class="details-box panel panel-default panel-body" style="padding:6px;">
|
|
<div class="row">
|
|
|
|
<?php if ($invoice->invoice_sign == -1) { ?>
|
|
<div class="col-xs-12">
|
|
<div class="alert alert-warning small">
|
|
<!-- <i class="fa fa-credit-invoice"></i> -->
|
|
<?php
|
|
echo trans('credit_invoice_for_invoice') . ' ';
|
|
$parent_invoice_number = $this->mdl_invoices->get_parent_invoice_number($invoice->creditinvoice_parent_id);
|
|
echo anchor('/invoices/view/' . $invoice->creditinvoice_parent_id, $parent_invoice_number);
|
|
?>
|
|
</div>
|
|
</div>
|
|
<?php } ?>
|
|
|
|
<div class="col-xs-12 col-md-4">
|
|
|
|
<div class="invoice-properties">
|
|
<?php if($invoice->invoice_group_id == '7'){?>
|
|
|
|
<label><?php _trans('Credit Note'); ?> #</label>
|
|
|
|
<?php }
|
|
else{?>
|
|
|
|
<label><?php _trans('invoice'); ?> #</label><?php } ?>
|
|
<input type="text" id="invoice_number" class="form-control input-sm"
|
|
<?php if ($invoice->invoice_number) : ?>
|
|
value="<?php echo $invoice->invoice_number; ?>"
|
|
<?php else : ?>
|
|
placeholder="<?php _trans('not_set'); ?>"
|
|
<?php endif; ?>
|
|
<?php if ($invoice->is_read_only == 1) {
|
|
echo 'disabled="disabled"';
|
|
} ?>>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div class="invoice-properties has-feedback">
|
|
<label><?php _trans('date'); ?></label>
|
|
|
|
<div class="input-group">
|
|
<input name="invoice_date_created" id="invoice_date_created"
|
|
class="form-control input-sm datepicker"
|
|
value="<?php echo date_from_mysql($invoice->invoice_date_created); ?>"
|
|
<?php if ($invoice->is_read_only == 1) {
|
|
echo 'disabled="disabled"';
|
|
} ?>>
|
|
<span class="input-group-addon">
|
|
<i class="fa fa-calendar fa-fw"></i>
|
|
</span>
|
|
</div>
|
|
</div>
|
|
<!-- Custom fields For Select Shipping Address-->
|
|
<?php foreach ($custom_fields as $custom_field): ?>
|
|
<?php if ($custom_field->custom_field_location != 1) {
|
|
continue;
|
|
} ?>
|
|
<?php if($custom_field->custom_field_order == 0 ){
|
|
print_field($this->mdl_invoices, $custom_field, $cv); }
|
|
?>
|
|
<?php endforeach; ?>
|
|
<?php
|
|
//print_r($invoice_id);
|
|
if($drop_check == 1){?>
|
|
<div> <label><?php _trans('quote'); ?></label>
|
|
<select id="po_select" name="po_select" tabindex="2" onchange="get_quotes(this);" required autofocus class="simple-select">
|
|
<option value="1" name="1">Select Sales Order</option>
|
|
<?php foreach($quotes as $quote):
|
|
|
|
for($i = $quote->quote_id; $i <= $quote->quote_id; $i++): ?>
|
|
<option value="<?php echo $quote->quote_number; ?>" name="<?php echo $quote->quote_number ?>" id="<?php echo $quote->quote_id ?>"><?php echo $quote->quote_number?></option>
|
|
<?php endfor;
|
|
endforeach;
|
|
?>
|
|
</select>
|
|
|
|
</div>
|
|
|
|
<input type="hidden" name="quote" id="quote" value="0">
|
|
<?php }?>
|
|
|
|
</div>
|
|
|
|
|
|
<div class="col-xs-12 col-md-4">
|
|
<!-- Custom fields For place Of Supply , PO NO & PO Date-->
|
|
<?php foreach ($custom_fields as $custom_field): ?>
|
|
<?php if ($custom_field->custom_field_location != 1) {
|
|
continue;
|
|
} ?>
|
|
<?php if($custom_field->custom_field_order == 4 ){
|
|
print_field($this->mdl_invoices, $custom_field, $cv); }
|
|
?>
|
|
<?php if($custom_field->custom_field_order == 5 ){
|
|
print_field($this->mdl_invoices, $custom_field, $cv); }
|
|
?>
|
|
<?php if($custom_field->custom_field_order == 6 ){
|
|
print_field($this->mdl_invoices, $custom_field, $cv); }
|
|
?>
|
|
<?php if($custom_field->custom_field_order == 17 ){
|
|
print_field($this->mdl_invoices, $custom_field, $cv); }
|
|
?>
|
|
<?php endforeach; ?>
|
|
</div>
|
|
<div class="col-xs-12 col-md-4">
|
|
<!-- Custom fields For Select Transport Mode , Vechile NO & Driver-->
|
|
<?php foreach ($custom_fields as $custom_field): ?>
|
|
<?php if ($custom_field->custom_field_location != 1) {
|
|
continue;
|
|
} ?>
|
|
<?php if($custom_field->custom_field_order == 1){
|
|
print_field($this->mdl_invoices, $custom_field, $cv); }
|
|
?>
|
|
<?php if($custom_field->custom_field_order == 2 ){
|
|
print_field($this->mdl_invoices, $custom_field, $cv); }
|
|
?>
|
|
|
|
<?php if($custom_field->custom_field_order == 3 ){
|
|
print_field($this->mdl_invoices, $custom_field, $cv); }
|
|
?>
|
|
<?php if($custom_field->custom_field_order == 16 ){
|
|
print_field($this->mdl_invoices, $custom_field, $cv); }
|
|
?>
|
|
|
|
|
|
|
|
<?php endforeach; ?>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div class="col-xs-12 col-md-4" style="display:none">
|
|
<div class="invoice-properties has-feedback">
|
|
<label><?php _trans('due_date'); ?></label>
|
|
|
|
<div class="input-group">
|
|
<input name="invoice_date_due" id="invoice_date_due"
|
|
class="form-control input-sm datepicker"
|
|
value="<?php
|
|
|
|
$Date = $invoice->invoice_date_created;
|
|
if(strlen($CustomVal)>0)
|
|
{
|
|
echo date('d-m-Y', strtotime($Date. '+ '.trim($CustomVal).'days'));
|
|
}
|
|
else
|
|
{
|
|
echo date('d-m-Y', strtotime($Date));
|
|
}
|
|
|
|
|
|
?>"
|
|
<?php if ($invoice->is_read_only == 1) {
|
|
echo 'disabled="disabled"';
|
|
} ?>>
|
|
<span class="input-group-addon">
|
|
<i class="fa fa-calendar fa-fw"></i>
|
|
</span>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<input type="hidden" name="quoteid" id="quoteid" value="<?php echo $quo?>">
|
|
<!-- <?php print_r($data);?> -->
|
|
<div id="state" name="state"></div>
|
|
|
|
<?php $this->layout->load_view('invoices/partial_item_table',$inv_status); ?>
|
|
|
|
|
|
</div>
|
|
|
|
</form>
|
|
<div align="right">
|
|
<?php if ($invoice->is_read_only != 1 || $invoice->invoice_status_id != 4) { ?>
|
|
<a href="#" class="btn btn-sm btn-success ajax-loader" id="btn_save_invoice">
|
|
<i class="fa fa-check"></i> <?php _trans('save'); ?>
|
|
</a>
|
|
<?php } ?>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
var invst= <?php echo json_encode($inv_st, JSON_PRETTY_PRINT) ?>;
|
|
|
|
if(invst=='4')
|
|
{
|
|
$("#invoice_status_id option").attr("disabled", "disabled");
|
|
$( "#invoice_date_created" ).datepicker( "option", "disabled", true );
|
|
$("input").prop('disabled', true);
|
|
}
|
|
|
|
|
|
|
|
function myFun(a){
|
|
|
|
// var as=document.getElementById(a).value;
|
|
// console.log(as);
|
|
|
|
|
|
|
|
var pstate= <?php echo json_encode($primarystatecode, JSON_PRETTY_PRINT) ?>;
|
|
|
|
var sstate= <?php echo json_encode($secondarystatecode, JSON_PRETTY_PRINT) ?>;
|
|
|
|
// console.log(pstate);
|
|
// console.log(sstate);
|
|
var invoice_id = <?php echo json_encode($invoice_id)?>;
|
|
//alert(invoice_id);
|
|
var state = '';
|
|
if(document.getElementById(a).value=="9")
|
|
{
|
|
//alert(sstate);
|
|
document.getElementById("SecondayAddress").style.display="block";
|
|
document.getElementById("NewAddress").style.display="none";
|
|
document.getElementById("BillingAddress").style.display="none";
|
|
|
|
$('#statecode').val(sstate);
|
|
|
|
state = sstate;
|
|
|
|
}
|
|
else if(document.getElementById(a).value=="8")
|
|
{
|
|
document.getElementById("NewAddress").style.display="block";
|
|
document.getElementById("SecondayAddress").style.display="none";
|
|
document.getElementById("BillingAddress").style.display="none";
|
|
|
|
|
|
}
|
|
else
|
|
{
|
|
document.getElementById("SecondayAddress").style.display="none";
|
|
document.getElementById("NewAddress").style.display="none";
|
|
document.getElementById("BillingAddress").style.display="block";
|
|
$('#statecode').val(pstate);
|
|
|
|
var state = pstate;
|
|
}
|
|
|
|
|
|
$.ajax({
|
|
data:{state:state,invoice_id:invoice_id},
|
|
type:"POST",
|
|
url:"<?php echo base_url();?>index.php/invoices/test",
|
|
success:function(state){
|
|
//alert(state);
|
|
}
|
|
});
|
|
|
|
// var hidstate=$('#state').val();
|
|
|
|
}
|
|
function get_quotes(q)
|
|
{
|
|
//alert(q);
|
|
|
|
|
|
var adID = q[q.selectedIndex].value; // get ID
|
|
var adVALUE = q[q.selectedIndex].id;
|
|
var invoice_id=inv_id;
|
|
//alert(invoice_id)
|
|
$('#quote').val(adVALUE);
|
|
// $('#quoteid').val(adVALUE);
|
|
$.ajax
|
|
({
|
|
|
|
data:{qid:adVALUE,quno:adID,invoice_id:invoice_id},
|
|
type:"POST",
|
|
dataType:"json",
|
|
url:"<?php echo base_url() ?>index.php/invoices/get_quote_items",
|
|
success:function(json)
|
|
{
|
|
//alert('Succes')
|
|
//alert(json.quotedetails[0]['item_name'])
|
|
|
|
selectedquotedetails=json.quotedetails;
|
|
// console.log(selectedquotedetails);
|
|
|
|
|
|
var last_item_row = $('#item_table tbody:last');
|
|
last_item_row.find('input[name=item_name]').val(json.quotedetails[0]['item_name']);
|
|
last_item_row.find('input[name=item_price]').val(json.quotedetails[0]['item_price']);
|
|
last_item_row.find('input[name= item_quantity]').val(json.quotedetails[0]['item_balancequantity']);
|
|
|
|
last_item_row.find('input[name= item_product_id]').val(json.quotedetails[0]['item_product_id']);
|
|
|
|
$('#item_name1').val(json.quotedetails[0]['item_name']);
|
|
$('#item_price1').val(json.quotedetails[0]['item_price']);
|
|
$('#item_quantity1').val(json.quotedetails[0]['item_balancequantity']);
|
|
$('#item_product_id1').val(json.quotedetails[0]['item_product_id']);
|
|
|
|
|
|
var uom= json.quotedetails[0]['unit_id'];
|
|
var sgst= json.quotedetails[0]['Sgst_item_tax_rate_id'];
|
|
var cgst= json.quotedetails[0]['Cgst_item_tax_rate_id'];
|
|
var igst= json.quotedetails[0]['Igst_item_tax_rate_id'];
|
|
var item= json.quotedetails[0]['item_description'];
|
|
var itemproductid= json.quotedetails[0][''];
|
|
|
|
var dropdownuom = document.getElementById('item_product_unit_id1');
|
|
|
|
//alert(dropdownuom);
|
|
|
|
if(dropdownuom <=0)
|
|
{
|
|
alert('Please add a row before selecting the Sales Order')
|
|
}
|
|
|
|
else
|
|
{
|
|
|
|
var uomlength=dropdownuom.length;
|
|
for(var i=0;i<=uomlength;i++)
|
|
{
|
|
|
|
var ouom=document.getElementById("item_product_unit_id1").options[i].text;
|
|
var optuom=document.getElementById("item_product_unit_id1").options[i].text;
|
|
//var optauom = optuom.substr(0,optsgst.indexOf('%'));
|
|
var optuomval=document.getElementById("item_product_unit_id1").options[i].value;
|
|
|
|
if(uom==optuomval)
|
|
{
|
|
// alert('uomif')
|
|
|
|
// $('[name=item_product_unit_id]').val(optuomval);
|
|
$('#item_product_unit_id1').val(optuomval);
|
|
break;
|
|
}
|
|
|
|
}
|
|
|
|
var dropdownsgst=document.getElementById('Sgst_item_tax_rate_id1');
|
|
var sgstlength=dropdownsgst.length;
|
|
|
|
for(var i=0;i<sgstlength;i++)
|
|
{
|
|
//var sgst=document.getElementById("Sgst_item_tax_rate_id").options[i].text;
|
|
var optsgst=document.getElementById("Sgst_item_tax_rate_id1").options[i].text;
|
|
var optasgst = optsgst.substr(0,optsgst.indexOf('%'));
|
|
var optsgstval=document.getElementById("Sgst_item_tax_rate_id1").options[i].value;
|
|
|
|
if(sgst==optsgstval)
|
|
{
|
|
|
|
//$('[name=Sgst_item_tax_rate_id]').val(optsgstval);
|
|
$('#Sgst_item_tax_rate_id1').val(optsgstval);
|
|
break;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
var dropdownitem = document.getElementById('item_description1');
|
|
//console.log(dropdownitem);
|
|
var itemlength=dropdownitem.length;
|
|
for(var i=0;i<itemlength;i++)
|
|
{
|
|
var optitem=document.getElementById("item_description1").options[i].text;
|
|
var optitemval=document.getElementById("item_description1").options[i].value;
|
|
//console.log('optitemval'+optitemval)
|
|
//console.log('item'+item);
|
|
//console.log('optitem'+optitem);
|
|
if(item==optitemval)
|
|
{
|
|
$('#item_description1').val(optitemval);
|
|
|
|
// alert(optitemval)
|
|
break;
|
|
}
|
|
}
|
|
|
|
|
|
var dropdowncgst = document.getElementById('Cgst_item_tax_rate_id1');
|
|
var cgstlength=dropdowncgst.length;
|
|
for(var i=0;i<cgstlength;i++)
|
|
{
|
|
|
|
//var cgst=document.getElementById("Cgst_item_tax_rate_id").options[i].text;
|
|
var optcgst=document.getElementById("Cgst_item_tax_rate_id1").options[i].text;
|
|
var optacgst = optcgst.substr(0,optcgst.indexOf('%'));
|
|
var optcgstval=document.getElementById("Cgst_item_tax_rate_id1").options[i].value;
|
|
|
|
if(cgst==optcgstval)
|
|
{ //alert('cgstif');
|
|
//$('[name=Cgst_item_tax_rate_id]').val(optcgstval);
|
|
$('#Cgst_item_tax_rate_id1').val(optcgstval);
|
|
break;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var dropdownigst=document.getElementById('Igst_item_tax_rate_id1');
|
|
//console.log(dropdownigst);
|
|
var igstlength=dropdownigst.length;
|
|
|
|
for(var i=0;i<igstlength;i++)
|
|
{
|
|
|
|
//var igsta=document.getElementById("Igst_item_tax_rate_id").options[i].text;
|
|
var optigst=document.getElementById("Igst_item_tax_rate_id1").options[i].text;
|
|
var optaigst = optigst.substr(0,optigst.indexOf('%'));
|
|
//console.log(optaigst)
|
|
var optigstval=document.getElementById("Igst_item_tax_rate_id1").options[i].value;
|
|
|
|
// console.log(optigstval);
|
|
|
|
if(igst==optigstval)
|
|
{ //console.log(optaigst);
|
|
|
|
$('#Igst_item_tax_rate_id1').val(optigstval);
|
|
//$('[name=Igst_item_tax_rate_id]').val(optigstval);
|
|
break;
|
|
}
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
});
|
|
}
|
|
|
|
|
|
</script>
|
|
|